import{r as w,j as d}from"./vendor-react-wBh_31cN.js";import{d as A}from"./index-dNe6i2rS.js";import{T as S}from"./tooltip-DFFgUYh6.js";const $="avatar-salt:",E="avatar-salt-change";function I(t){if(!t)return 0;const n=localStorage.getItem($+t);return n?Number(n):0}function z(t){const[n,e]=w.useState(()=>I(t));w.useEffect(()=>{e(I(t));function r(l){const{detail:c}=l;(c==null?void 0:c.key)===t&&e(c.salt)}return window.addEventListener(E,r),()=>window.removeEventListener(E,r)},[t]);const o=w.useCallback(()=>{if(!t)return;const r=Math.floor(Math.random()*1e9);localStorage.setItem($+t,String(r)),window.dispatchEvent(new CustomEvent(E,{detail:{key:t,salt:r}}))},[t]);return[n,o]}const P={sm:"size-6 text-[10px]",default:"size-8 text-xs",lg:"size-10 text-sm"};function C(t){const n=t%290;return n<100?n:n+70}function R(t){let n=5381;for(let e=0;e<t.length;e+=1)n=(n*33+t.charCodeAt(e))%2147483647;return n}const g=10;function D(t){const n=1+Math.floor(t/16)%3,e=Math.floor(t/64)%8*(Math.PI/4),o=35+Math.floor(t/512)%20,r=10+Math.floor(t/2048)%10,l=2+Math.floor(t/8192)%3,c=Math.floor(t/32768)%8*(Math.PI/4),u=55+Math.floor(t/131072)%20,p=8+Math.floor(t/524288)%10,v=[];for(let f=0;f<g;f+=1)for(let a=0;a<g;a+=1){const h=(f+.5)/g*100,x=(a+.5)/g*100,M=o+r*Math.sin(n*2*Math.PI*(h/100)+e),m=u+p*Math.sin(l*2*Math.PI*(h/100)+c);let i=0;x>=M&&(i=.35),x>=m&&(i=.75),i>0&&v.push({x:f,y:a,opacity:i})}return v}function K(t,n){const e=(t==null?void 0:t.charAt(0))??"",o=(n==null?void 0:n.charAt(0))??"";return(e+o).toUpperCase()||"?"}function T(t,n){return[t,n].filter(Boolean).join(" ")}function G({firstName:t,lastName:n,size:e="default",editable:o=!1,className:r,onClick:l,...c}){const u=T(t,n),p=`${t??""}|${n??""}`,[v,f]=z(p),a=R(`${p}|${v}`),h=C(a),x=`hsl(${h} 70% 90%)`,M=`hsl(${h} 65% 38%)`,m=D(a),i=100/g,y=o?`${u?`${u} — `:""}click to regenerate`:u,j=s=>{o&&f(),l==null||l(s)},b=s=>{o&&(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),f())};return d.jsx(S,{content:y,disabled:!y,children:d.jsxs("div",{className:A("relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full ring-1 ring-border font-semibold select-none",P[e],o&&"cursor-pointer transition-transform hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r),style:{background:x,color:M},onClick:j,onKeyDown:o?b:void 0,role:o?"button":void 0,tabIndex:o?0:void 0,...c,children:[d.jsx("svg",{viewBox:"0 0 100 100",className:"absolute inset-0 size-full animate-in fade-in zoom-in-95 duration-300",preserveAspectRatio:"none",shapeRendering:"crispEdges","aria-hidden":!0,children:m.map(s=>d.jsx("rect",{x:s.x*i,y:s.y*i,width:i,height:i,fill:M,fillOpacity:s.opacity},`${s.x}-${s.y}`))},a),d.jsx("span",{className:"relative",children:K(t,n)})]})})}export{G as A};
