obeyaka-ui 0.1.28 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -9036,7 +9036,12 @@ const Ae = ({
9036
9036
  {
9037
9037
  value: t,
9038
9038
  onChange: (M) => {
9039
- i == null || i(M.target.value);
9039
+ const z = M.target.value;
9040
+ if (i) {
9041
+ i(z);
9042
+ return;
9043
+ }
9044
+ r == null || r(z);
9040
9045
  },
9041
9046
  onFocus: () => {
9042
9047
  I(!0), a == null || a(!0);
package/dist/index.js CHANGED
@@ -15,4 +15,4 @@
15
15
  from { width: 200px; opacity: 1; }
16
16
  to { width: 0; opacity: 0; }
17
17
  }
18
- `})]})},ze=({activeFilters:t,onFiltersChange:r,availableFilters:o,size:s="md",filterButtonDropdownPosition:a="bottom-end"})=>{const i=n.useCombobox({onDropdownClose:()=>i.resetSelectedOption(),onDropdownOpen:()=>i.updateSelectedOptionIndex("active")}),[c,l]=u.useState(!1),d=t.length>0,f=I=>{if(I==="remove-filters")r([]);else{const g=o==null?void 0:o.find(b=>b.value===I);if(g){const b={id:`${g.value}-${Date.now()}`,filterOption:g};r([...t,b])}}i.closeDropdown()},h=(o||[]).filter(I=>!t.some(g=>g.filterOption.value===I.value)),m={borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",color:"var(--mantine-color-gray-7)",fontWeight:"500"},y=(()=>{switch(s){case"sm":return{height:"32px",width:"32px",iconSize:20};case"md":return{height:"32px",width:"32px",iconSize:20};default:return{height:"32px",width:"32px",iconSize:20}}})(),p=e.jsx(n.Box,{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundColor:d||c?"var(--mantine-color-gray-0)":"transparent",color:"var(--mantine-color-gray-6)",borderRadius:"var(--mantine-radius-md)",cursor:"pointer",transition:"all 0.2s ease",...y},onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onClick:()=>i.toggleDropdown(),children:e.jsx(M.IconFilter,{size:20,stroke:2.3})});return e.jsxs(n.Combobox,{store:i,onOptionSubmit:f,withinPortal:!1,offset:4,position:a,children:[e.jsx(n.Combobox.Target,{children:d?e.jsx(n.Indicator,{offset:2,position:"top-end",color:"var(--mantine-color-yellow-7)",children:p}):p}),e.jsx(n.Combobox.Dropdown,{styles:{dropdown:{borderRadius:"var(--mantine-radius-md)",border:"1px solid var(--mantine-color-gray-2)",boxShadow:"var(--mantine-shadow-md)",padding:"4px",width:"auto",minWidth:"160px"}},children:e.jsxs(n.Combobox.Options,{children:[h.map(I=>e.jsx(n.Combobox.Option,{value:I.value,style:{...m},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"8px"},children:[I.icon,I.label]})},I.value)),d&&e.jsx(n.Combobox.Option,{value:"remove-filters",style:{borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",fontWeight:"500",color:"var(--mantine-color-red-6)"},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(M.IconFilterOff,{size:16,stroke:2}),"Remove filters"]})})]})})]})},vt=({filterTag:t,onUpdate:r,onRemove:o,options:s=[],filterTagDropdownPosition:a="bottom-start"})=>{var x;const i=n.useCombobox({onDropdownClose:()=>i.resetSelectedOption(),onDropdownOpen:()=>i.updateSelectedOptionIndex("active")}),c=!!t.selectedOption,l=c?`${t.filterOption.label}: ${(x=t.selectedOption)==null?void 0:x.label}`:t.filterOption.label,d=s&&s.length>0?s:[{value:"option-a",label:"TagFilterOptionA"},{value:"option-b",label:"TagFilterOptionB"},{value:"option-c",label:"TagFilterOptionC"}],f=y=>{if(y==="remove")o();else{const p=d.find(I=>I.value===y);p&&r({...t,selectedOption:p})}i.closeDropdown()},h={borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",color:"var(--mantine-color-gray-7)",fontWeight:"500"},m={display:"inline-flex",alignItems:"center",gap:"4px",backgroundColor:c?"var(--mantine-color-blue-0)":"var(--mantine-color-gray-0)",color:c?"var(--mantine-color-blue-7)":"var(--mantine-color-gray-6)",borderRadius:"var(--mantine-radius-xl)",cursor:"pointer",transition:"all 0.2s ease",height:"32px",fontSize:"var(--mantine-font-size-sm)",padding:"0 12px"};return e.jsxs(n.Combobox,{store:i,onOptionSubmit:f,withinPortal:!1,offset:4,position:a,middlewares:{flip:!1,shift:!0},children:[e.jsx(n.Combobox.Target,{children:e.jsxs(n.Box,{style:{...m},onClick:()=>i.toggleDropdown(),fw:500,pl:"sm",children:[e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.filterOption.icon,l]}),e.jsx(M.IconChevronDown,{size:16,strokeWidth:2,color:"var(--mantine-color-gray-5)"})]})}),e.jsx(n.Combobox.Dropdown,{styles:{dropdown:{borderRadius:"var(--mantine-radius-md)",border:"1px solid var(--mantine-color-gray-2)",boxShadow:"var(--mantine-shadow-md)",padding:"4px",minWidth:"150px"}},children:e.jsxs(n.Combobox.Options,{children:[d.map(y=>{var p;return e.jsx(n.Combobox.Option,{value:y.value,active:((p=t.selectedOption)==null?void 0:p.value)===y.value,style:{...h},children:y.label},y.value)}),e.jsx(n.Combobox.Option,{value:"remove",style:{borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",fontWeight:"500",color:"var(--mantine-color-red-6)"},children:"Or remove filter"})]})})]})},jt=({activeFilters:t,onFiltersChange:r,availableFilters:o,addFilterButtonDropdownPosition:s="bottom-start"})=>{const a=n.useCombobox({onDropdownClose:()=>a.resetSelectedOption(),onDropdownOpen:()=>a.updateSelectedOptionIndex("active")}),[i,c]=u.useState(!1),l=x=>{const y=o==null?void 0:o.find(p=>p.value===x);if(y){const p={id:`${y.value}-${Date.now()}`,filterOption:y};r([...t,p])}a.closeDropdown()},d=(o||[]).filter(x=>!t.some(y=>y.filterOption.value===x.value)),f={display:"inline-flex",alignItems:"center",backgroundColor:i?"var(--mantine-color-gray-0)":"transparent",borderRadius:"var(--mantine-radius-xl)",cursor:"pointer",transition:"all 0.2s ease",border:"1px solid transparent",height:"32px",fontSize:"var(--mantine-font-size-sm)",padding:"0 12px"},h={dropdown:{borderRadius:"var(--mantine-radius-md)",border:"1px solid var(--mantine-color-gray-2)",boxShadow:"var(--mantine-shadow-md)",padding:"4px",width:"auto",minWidth:"120px"}},m={borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",color:"var(--mantine-color-gray-7)",fontWeight:"500"};return e.jsxs(n.Combobox,{store:a,onOptionSubmit:l,withinPortal:!1,offset:4,position:s,children:[e.jsx(n.Combobox.Target,{children:e.jsx(n.Box,{style:{...f},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:()=>a.toggleDropdown(),children:e.jsx(n.Box,{style:{fontWeight:"500",color:"var(--mantine-color-blue-6)"},children:"Add filter"})})}),e.jsx(n.Combobox.Dropdown,{styles:{...h},children:e.jsx(n.Combobox.Options,{children:d.map(x=>e.jsx(n.Combobox.Option,{value:x.value,style:{...m},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x.icon,x.label]})},x.value))})})]})},Re=({activeFilters:t,onFiltersChange:r,availableFilters:o,size:s="sm",getFilterOptions:a,filterTagDropdownPosition:i="bottom-start"})=>{const c=f=>{const h=(t||[]).map(m=>m.id===f.id?f:m);r(h)},l=f=>{const h=(t||[]).filter(m=>m.id!==f);r(h)},d=(o||[]).filter(f=>!t.some(h=>h.filterOption.value===f.value));return!t||t.length===0?null:e.jsx("div",{style:{width:"100%"},children:e.jsxs(n.Group,{gap:"sm",align:"center",wrap:"wrap",children:[(t||[]).map(f=>{const h=a?a(f.filterOption.value)||[]:[];return e.jsx(vt,{filterTag:f,onUpdate:c,onRemove:()=>l(f.id),size:s,options:h,filterTagDropdownPosition:i},f.id)}),d.length>0&&e.jsx(jt,{activeFilters:t,onFiltersChange:r,availableFilters:d,size:s})]})})},bt=({activeFilters:t,onFiltersChange:r,availableFilters:o,size:s="md",getFilterOptions:a,filterTagDropdownPosition:i="bottom-start"})=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsx(ze,{activeFilters:t,onFiltersChange:r,availableFilters:o,size:s}),e.jsx(Re,{activeFilters:t,onFiltersChange:r,availableFilters:o,size:"sm",getFilterOptions:a,filterTagDropdownPosition:i})]}),wt=Object.assign(bt,{Button:ze,Filters:Re}),St=({children:t,danger:r,active:o,...s})=>e.jsx(n.MenuItem,{...s,style:{borderRadius:"8px",color:o?"var(--mantine-color-blue-7)":r?"var(--mantine-color-red-9)":"var(--mantine-color-gray-9)",backgroundColor:o?"var(--mantine-color-blue-0)":"transparent",...s.style},children:t}),ye=({trigger:t,menuItems:r,children:o,...s})=>{const a=u.useRef(null),[i,c]=u.useState(0);return u.useEffect(()=>{a.current&&c(a.current.offsetWidth)},[t]),e.jsxs(n.Menu,{...s,children:[e.jsx(n.Menu.Target,{children:e.jsx("div",{ref:a,onClick:l=>l.stopPropagation(),style:{cursor:"pointer",outline:"none",boxShadow:"none",display:"flex",alignItems:"center"},children:t})}),e.jsxs(n.Menu.Dropdown,{styles:{dropdown:{cursor:"pointer",borderRadius:"8px",minWidth:`${i}px`}},children:[o,r==null?void 0:r.map((l,d)=>e.jsx(St,{...l},d))]})]})},Ye=({label:t,icon:r,onClick:o,color:s="gray",disabled:a=!1,"aria-label":i,indicator:c,fullWidth:l,isActive:d=!1,...f})=>{const[h,m]=u.useState(!1),x=()=>{a||o==null||o()};return e.jsx(n.Box,{style:{cursor:a?"not-allowed":"pointer",borderRadius:"var(--mantine-radius-md)"},variant:"transparent",justify:"flex-start",display:"flex",color:s,radius:"md",w:l?"100%":"auto",px:6,h:40,onMouseEnter:()=>!a&&m(!0),onMouseLeave:()=>m(!1),onClick:x,bg:h||d?"gray.1":"transparent","aria-label":i||`${t} navigation button`,...f,children:e.jsxs(n.Group,{w:"100%",wrap:"nowrap",gap:8,justify:"left",align:"center",children:[e.jsx(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px"},children:r}),e.jsx(n.Text,{ta:"left",size:"sm",fw:600,c:"var(--mantine-color-gray-8)",truncate:!0,style:{flex:1,opacity:a?.5:1},children:t}),c&&e.jsx(n.Box,{style:{cursor:"pointer",backgroundColor:"var(--mantine-color-red-7)",color:"var(--mantine-color-white)",borderRadius:"var(--mantine-radius-lg)",padding:"0px 4px",fontSize:"12px",fontWeight:600,height:"20px",minWidth:"20px",display:"flex",alignItems:"center",justifyContent:"center"},children:c})]})})},_e=({label:t,rightLabel:r,children:o,onAddChild:s,onMenuAction:a,menuItems:i,color:c="gray",defaultText:l="No items",level:d=0,disabled:f=!1,noChild:h=!1,isActive:m=!1,showAvatar:x=!0,avatar:y,placeholder:p,onClick:I,"aria-label":g,...b})=>{const[v,S]=u.useState(!1),[w,T]=u.useState(!1),k=u.Children.count(o)>0,C=!h&&k&&(x?w:!0),j=u.useCallback(()=>{f||I==null||I()},[I,f]),R=u.useCallback(F=>{F.stopPropagation(),!f&&(s==null||s())},[s,f]),D=u.useCallback(F=>{F==null||F.stopPropagation(),!f&&k&&!h&&S(U=>!U)},[f,k,h]),O=u.useCallback(()=>{f||s==null||s()},[s,f]),E=u.useCallback(F=>{f||a==null||a(F)},[a,f,t]),H=u.useCallback(()=>k?u.Children.map(o,F=>u.isValidElement(F)?u.cloneElement(F,{...F.props,level:d+1}):F):null,[o,k,d]),$=(i==null?void 0:i.map(F=>({children:e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[F.icon&&e.jsx(F.icon,{size:16}),e.jsx(n.Text,{size:"sm",children:F.label})]}),onClick:()=>E(F.action)})))||[],W=[{children:e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[e.jsx(M.IconPlus,{size:16}),e.jsx(n.Text,{size:"sm",children:"Add child"})]}),onClick:R}],L=$.length>0?$:W;return e.jsxs(n.Stack,{gap:0,children:[e.jsx(n.Box,{style:{cursor:f?"not-allowed":"pointer",borderRadius:"8px"},variant:"transparent",justify:"space-between",display:"flex",color:c,size:"md",radius:"md",w:"100%",px:6,h:40,onMouseEnter:()=>!f&&T(!0),onMouseLeave:()=>T(!1),onClick:j,bg:m||w?"var(--mantine-color-gray-1)":"transparent","aria-expanded":v,"aria-label":g||`${t} navigation link`,...b,children:e.jsxs(n.Group,{w:"100%",wrap:"nowrap",gap:8,onClick:j,style:{paddingLeft:h&&!C?`${(d+1)*32}px`:d>0?`${d*32}px`:"0px"},children:[C?e.jsx(fe,{icon:v?M.IconChevronDown:M.IconChevronRight,iconOnHover:v?M.IconChevronDown:M.IconChevronRight,grayScaleBaseColor:w?1:0,color:"var(--mantine-color-gray-7)",onClick:D,disabled:f}):x?e.jsx(se,{size:"xs",avatar:y,showPlaceholder:!0,placeholder:p}):null,e.jsx(n.Text,{size:"sm",fw:600,c:"var(--mantine-color-gray-7)",truncate:!0,w:"100%",style:{opacity:f?.5:1},children:t}),e.jsxs(n.Group,{gap:"xs",align:"center",children:[r&&e.jsx(n.Text,{size:"xs",c:"dimmed",children:r}),w&&!f&&e.jsxs(n.Group,{gap:4,wrap:"nowrap",children:[s&&e.jsx(fe,{icon:M.IconPlus,grayScaleBaseColor:w?1:0,onClick:O,color:"var(--mantine-color-gray-7)"}),(i&&i.length>0||s)&&e.jsx("div",{onClick:F=>F.stopPropagation(),children:e.jsx(ye,{menuItems:L,trigger:e.jsx(fe,{icon:M.IconDots,grayScaleBaseColor:1,color:"var(--mantine-color-gray-7)"}),position:"bottom-end",shadow:"md"})})]})]})]})}),v&&!h&&e.jsx(n.Stack,{gap:0,style:{width:"100%"},children:k?H():e.jsx(n.Box,{style:{marginLeft:d>0?`${d*16}px`:"0px"},children:e.jsx(n.Text,{size:"sm",c:"dimmed",ta:"left",p:"sm",fw:500,children:l})})})]})},kt="userChip-module__pill___DgFME",Ct={pill:kt},Me=({avatar:t,name:r,withRemoveButton:o=!1,onRemove:s})=>e.jsx(n.Pill,{withRemoveButton:o,onRemove:s,radius:"md",p:"0px",size:"md",className:Ct.pill,bg:"transparent",children:e.jsxs(n.Group,{gap:4,wrap:"nowrap",style:{alignItems:"center"},children:[e.jsx(se,{avatar:t,size:24,placeholder:r,showPlaceholder:!0}),e.jsx(n.Text,{size:"sm",fw:450,c:"var(--mantine-color-gray-9)",children:r})]})}),Mt="200px",Tt="4px 8px",Bt=40,Ot="var(--mantine-radius-md)",zt=16,hn=({item:t,withAvatars:r,disabled:o=!1,onClick:s,selected:a=!1})=>{const[i,c]=u.useState(!1);return e.jsx(n.Box,{onMouseEnter:()=>!o&&c(!0),onMouseLeave:()=>!o&&c(!1),onClick:l=>{l.preventDefault(),l.stopPropagation(),o||s==null||s(t.value)},onMouseDown:l=>{l.stopPropagation()},style:{minWidth:Mt,backgroundColor:o?"transparent":i?"var(--mantine-color-gray-1)":"transparent",cursor:o?"default":"pointer",borderRadius:Ot,padding:Tt,transition:"background-color 0.2s ease",opacity:o?.5:1},children:e.jsxs(n.Group,{gap:"sm",wrap:"nowrap",align:"flex-start",style:{alignItems:"center"},h:Bt,children:[r&&t.avatar&&e.jsx("img",{src:t.avatar,alt:t.label,style:{width:"24px",height:"24px",borderRadius:"var(--mantine-radius-sm)",objectFit:"cover"}}),e.jsxs(n.Stack,{gap:0,style:{flex:1},children:[e.jsx(n.Text,{size:"sm",fw:500,lh:-1,c:o?"var(--mantine-color-gray-5)":"var(--mantine-color-gray-9)",children:t.label}),e.jsx(n.Text,{size:"xs",c:o?"var(--mantine-color-gray-4)":"dimmed",children:t.description})]}),a&&e.jsx(M.IconCheck,{size:zt,color:"var(--mantine-color-gray-9)"})]})})},Rt="bottom-end",Dt=1e4,Et="24px",At="0 8px",Lt="6px",Je="var(--mantine-radius-md)",Ft="46px",De=({value:t,onChange:r,data:o,withRemove:s=!1,withAvatars:a=!1,onRemove:i,disabledOptions:c=[],disabled:l=!1,defaultOption:d,popoverStyles:f,dropdownStyles:h,triggerStyles:m,textStyles:x})=>{const[y,p]=u.useState(!1),I=(o||[]).find(j=>j.value===t)||d,[g,b]=u.useState(!1),[v,S]=u.useState(!1),[w,T]=u.useState(!1),k=s?e.jsx(n.Group,{p:"sm",onClick:j=>{j.stopPropagation(),i==null||i(t)},style:{cursor:"pointer",height:Ft,display:"flex",alignItems:"center",borderRadius:Je,backgroundColor:v?"var(--mantine-color-red-0)":"transparent",transition:"background-color 0.2s ease"},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:e.jsx(n.Text,{size:"sm",c:"var(--mantine-color-red-6)",fw:500,children:"Remove user"})}):null,C=e.jsxs(n.Box,{onMouseEnter:()=>!l&&b(!0),onMouseLeave:()=>!l&&b(!1),onClick:()=>{l||(p(!0),T(!0))},style:{height:Et,cursor:l?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",borderRadius:Je,backgroundColor:l?"transparent":g||w?"var(--mantine-color-gray-1)":"transparent",transition:"background-color 0.2s ease",padding:At,gap:Lt,width:"auto",opacity:l?.6:1,...m},children:[e.jsx(n.Text,{size:"sm",fw:x!=null&&x.fontWeight?void 0:500,c:l?"var(--mantine-color-gray-4)":"var(--mantine-color-gray-6)",style:{color:l?"var(--mantine-color-gray-4)":"var(--mantine-color-gray-6)",lineHeight:"24px",whiteSpace:"nowrap",...x},children:(I==null?void 0:I.label)||"Select option"}),e.jsx(M.IconChevronDown,{size:16,style:{color:l?"var(--mantine-color-gray-3)":"var(--mantine-color-gray-6)"}})]});return e.jsxs(n.Popover,{opened:y,onChange:j=>{p(j),j||T(!1)},position:Rt,shadow:"md",withinPortal:!0,zIndex:Dt,styles:f,children:[e.jsx(n.Popover.Target,{children:C}),e.jsx(n.Popover.Dropdown,{onClick:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),styles:{dropdown:{borderRadius:"var(--mantine-radius-md)",padding:"4px",...h}},children:e.jsxs(n.Stack,{gap:0,onClick:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),children:[(o||[]).map(j=>{const R=c.includes(j.value),D=j.value===t;return e.jsx(hn,{item:j,withAvatars:a,disabled:R,selected:D,onClick:O=>{r==null||r(O),p(!1),T(!1)}},j.value)}),k]})})]})},Ut=(t,r,o,s)=>{const a=u.useRef(null),i=u.useRef(null),c=u.useCallback(d=>{d[0].isIntersecting&&o&&!s&&r&&r()},[o,s,r]),l=u.useCallback(()=>{if(!(!a.current||!t||!r)){i.current&&(i.current.disconnect(),i.current=null);try{const d=new IntersectionObserver(c,{threshold:.1,rootMargin:"50px"});d.observe(a.current),i.current=d}catch(d){console.error("Failed to setup intersection observer:",d)}}},[t,r,c]);return u.useEffect(()=>(l(),()=>{i.current&&(i.current.disconnect(),i.current=null)}),[l]),u.useEffect(()=>()=>{i.current&&(i.current.disconnect(),i.current=null)},[]),{loadMoreRef:a}},xn=({tableName:t,data:r,columns:o,onAddItem:s,addItemComponent:a,addItemLabel:i="Add item",loading:c=!1,emptyMessage:l="No data found",searchPlaceholder:d="Search...",enableAutoFilters:f=!0,customFilters:h=[],onCustomFilter:m,onSort:x,sortColumn:y,sortDirection:p,onSearch:I,onRowClick:g,size:b="md",striped:v=!1,highlightOnHover:S=!0,enableInfiniteScroll:w=!1,isLoadingMore:T=!1,hasMore:k=!1,onLoadMore:C})=>{const[j,R]=u.useState(""),[D,O]=u.useState([]),{loadMoreRef:E}=Ut(w,C||(()=>{}),k,T),H=u.useMemo(()=>[...f?o.filter(z=>z.type==="select"&&z.options).map(z=>({value:z.key,label:z.label})):[],...h],[o,f,h]),$=u.useMemo(()=>{let B=r||[];if(j){const z=j.toLowerCase();B=B.filter(A=>o.some(N=>{if(!N.searchable)return!1;const V=A[N.key];return V==null?!1:String(V).toLowerCase().includes(z)}))}return D.forEach(z=>{if(z.filterTag.selectedOption){const A=o.find(N=>N.key===z.filterTag.filterOption.value);A&&(B=B.filter(N=>{var ne;const V=N[A.key];return String(V)===((ne=z.filterTag.selectedOption)==null?void 0:ne.value)}))}}),B},[r,j,D,o]),W=B=>{R(B),I==null||I(B)},L=B=>{const z=o.find(N=>N.key===B);if(!(z!=null&&z.sortable))return;const A=y===B&&p==="asc"?"desc":"asc";x==null||x(B,A)},F=B=>{const z=o.find(A=>A.key===B);return(z==null?void 0:z.type)==="select"&&z.options?z.options.map(A=>({value:A.value,label:A.label})):(z==null?void 0:z.type)==="badge"?[...new Set(r.map(N=>N[z.key]).filter(Boolean))].map(N=>({value:String(N),label:String(N).charAt(0).toUpperCase()+String(N).slice(1)})):z?[...new Set(r.map(N=>N[z.key]).filter(Boolean))].map(N=>({value:String(N),label:String(N).charAt(0).toUpperCase()+String(N).slice(1)})):[]},U=(B,z)=>{var N,V,ne,P,oe;const A=z[B.key];switch(B.type){case"text":return e.jsx(n.Text,{size:"sm",c:A?void 0:"dimmed",children:A||"—"});case"date":if(!A)return e.jsx(n.Text,{size:"sm",c:"dimmed",children:"—"});const X=new Date(A),de=B.format?X.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):X.toLocaleDateString();return e.jsx(n.Text,{size:"sm",c:"dimmed",children:de});case"select":return B.options?e.jsx(De,{value:A,data:B.options,placeholder:B.label,onChange:re=>{var me;return(me=B.onSelectChange)==null?void 0:me.call(B,re,z)},disabled:(N=B.disabled)==null?void 0:N.call(B,z)}):e.jsx(n.Text,{size:"sm",c:"dimmed",children:"—"});case"badge":const Ae=((V=B.badgeColors)==null?void 0:V[A])||"gray";return e.jsx(n.Badge,{color:Ae,variant:"light",size:"sm",radius:"md",fw:600,children:A||"Unknown"});case"avatar":const Le=((ne=B.fallbackText)==null?void 0:ne.call(B,z))||String(A).charAt(0).toUpperCase();return e.jsx(se,{avatar:A,size:"xs",placeholder:Le,showPlaceholder:!0});case"custom":return((P=B.render)==null?void 0:P.call(B,A,z))||e.jsx(n.Text,{size:"sm",c:"dimmed",children:"—"});case"actions":return(oe=B.actions)!=null&&oe.length?e.jsxs(n.Menu,{shadow:"md",width:200,position:"bottom-end",styles:{dropdown:{borderRadius:"var(--mantine-radius-md)"}},children:[e.jsx(n.Menu.Target,{children:e.jsx(n.ActionIcon,{variant:"subtle",size:"md",color:"gray",radius:"md",children:e.jsx(M.IconDots,{size:16})})}),e.jsx(n.Menu.Dropdown,{children:B.actions.map((re,me)=>{var be;return e.jsx(n.Menu.Item,{color:re.color,leftSection:re.icon,disabled:(be=re.disabled)==null?void 0:be.call(re,z),onClick:()=>re.onClick(z),styles:{item:{borderRadius:"var(--mantine-radius-md)"}},children:re.label},me)})})]}):null;default:return e.jsx(n.Text,{size:"sm",c:"dimmed",children:"—"})}},Z=B=>{var z;return(z=o.find(A=>A.key===B))!=null&&z.sortable?y===B?p==="asc"?e.jsx(M.IconChevronUp,{size:14}):e.jsx(M.IconChevronDown,{size:14}):e.jsx(M.IconChevronUp,{size:14,style:{opacity:.3}}):null},G=(()=>{switch(b){case"sm":return{buttonSize:"xs",textSize:"sm"};case"lg":return{buttonSize:"md",textSize:"md"};default:return{buttonSize:"sm",textSize:"sm"}}})();return e.jsxs(n.Box,{pos:"relative",children:[e.jsx(n.LoadingOverlay,{visible:c}),e.jsxs(n.Stack,{gap:"sm",w:"100%",children:[e.jsxs(n.Group,{gap:"sm",wrap:"nowrap",justify:"space-between",children:[e.jsx(n.Text,{fw:600,c:"var(--mantine-color-gray-8)",children:t}),e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[e.jsxs(n.Group,{gap:4,wrap:"nowrap",children:[e.jsx(fn,{placeholder:d,value:j,onChange:W,onSearch:W,expandDirection:"right",size:G.buttonSize}),H.length>0&&e.jsx(ze,{activeFilters:D.map(B=>B.filterTag),onFiltersChange:B=>{O(B.map(z=>({filterTag:z,onUpdate:()=>{},onRemove:()=>{}}))),m==null||m(B)},availableFilters:H,size:G.buttonSize})]}),s&&e.jsx(n.Button,{size:"compact-md",h:32,style:{fontSize:`var(--mantine-font-size-${G.textSize})`,border:"none"},radius:"md",onClick:s,children:i})]})]}),H.length>0&&e.jsx(Re,{activeFilters:D.map(B=>B.filterTag),onFiltersChange:B=>{O(B.map(z=>({filterTag:z,onUpdate:()=>{},onRemove:()=>{}}))),m==null||m(B)},availableFilters:H,size:"md",getFilterOptions:F})]}),a,e.jsxs(n.Table,{striped:v,highlightOnHover:S,highlightOnHoverColor:"var(--mantine-color-gray-0)",mt:"xs",children:[e.jsx(n.Table.Thead,{children:e.jsx(n.Table.Tr,{children:o.map(B=>e.jsx(n.Table.Th,{c:"var(--mantine-color-gray-6)",style:{width:B.width,textAlign:B.align||"left",cursor:B.sortable?"pointer":"default"},onClick:()=>B.sortable&&L(B.key),children:e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[B.icon&&e.jsx(n.Box,{style:{display:"flex",alignItems:"center"},children:B.icon}),e.jsx(n.Text,{size:G.textSize,fw:500,children:B.label}),Z(B.key)]})},String(B.key)))})}),e.jsx(n.Table.Tbody,{children:$.length===0?e.jsx(n.Table.Tr,{children:e.jsx(n.Table.Td,{colSpan:o.length,ta:"center",py:"xl",children:e.jsx(n.Text,{c:"dimmed",children:l})})}):$.map((B,z)=>e.jsx(n.Table.Tr,{style:{cursor:g?"pointer":"default"},onClick:()=>g==null?void 0:g(B),children:o.map(A=>e.jsx(n.Table.Td,{style:{textAlign:A.align||"left"},children:U(A,B)},String(A.key)))},B.id||z))})]}),w&&e.jsx(n.Box,{ref:E,style:{padding:"16px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:"60px"},children:T&&e.jsxs(n.Group,{display:"flex",ta:"center",gap:"xs",children:[e.jsx(n.Loader,{size:"sm",color:"gray.5"}),e.jsx(n.Text,{size:"sm",c:"dimmed",fw:500,children:"Loading more..."})]})})]})};Object.assign(xn,{});const Nt=({onAvatarSelect:t,onEmojiSelect:r,onImageSelect:o,onIconSelect:s}={})=>{const[a,i]=u.useState("emoji"),[c,l]=u.useState(null),[d,f]=u.useState(null),[h,m]=u.useState(null),[x,y]=u.useState(null),[p,I]=u.useState(null),g=u.useCallback(j=>{i(j)},[]),b=u.useCallback(j=>{l(j)},[]),v=u.useCallback(j=>{I(j);const R=new FileReader;R.onload=D=>{var E;const O=(E=D.target)==null?void 0:E.result;f(O)},R.readAsDataURL(j)},[]),S=u.useCallback(j=>{m(j),f(null),I(null),y(null),t==null||t({type:"emoji",value:j}),r==null||r(j)},[t,r]),w=u.useCallback(j=>{y(j),f(null),I(null),m(null),t==null||t({type:"icon",value:j}),s==null||s(j)},[t,s]),T=u.useCallback(()=>{if(p&&d){const j=URL.createObjectURL(p);t==null||t({type:"image",value:j}),o==null||o(p)}},[p,d,t,o]),k=u.useCallback(()=>{f(null),I(null),m(null),y(null)},[]),C=u.useCallback(()=>{f(null),m(null),y(null),I(null),i("emoji"),l(null)},[]);return{selectedTab:a,tabHovered:c,previewImage:d,selectedEmoji:h,selectedIcon:x,selectedFile:p,handleTabChange:g,handleTabHover:b,handleImagePreview:v,handleImageAccept:T,handleEmojiSelect:S,handleIconSelect:w,clearImagePreview:k,resetState:C}},Wt=({opened:t,onClose:r,popoverRef:o})=>{const s=u.useCallback(i=>{t&&o.current&&!o.current.contains(i.target)&&(console.log("Click outside detected, closing popover"),r())},[t,r,o]),a=u.useCallback(i=>{i.key==="Escape"&&t&&(console.log("Escape key pressed, closing popover"),r())},[t,r]);return u.useEffect(()=>{if(t)return document.addEventListener("mousedown",s),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",a)}},[t,s,a]),{handleClickOutside:s,handleEscape:a}},$t=({selectedTab:t,tabHovered:r,onTabChange:o,onTabHover:s,onRemove:a,hasAvatar:i=!1,children:c})=>{const[l,d]=u.useState(!1);return e.jsxs(n.Tabs,{color:"black",value:t,styles:{tab:{backgroundColor:"transparent"}},children:[e.jsxs(n.Tabs.List,{px:"var(--mantine-spacing-sm)",pt:"xs",w:"100%",children:[e.jsx(n.Tabs.Tab,{value:"emoji",p:0,pb:"xs",onClick:()=>o("emoji"),onMouseEnter:()=>s("emoji"),onMouseLeave:()=>s(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{borderRadius:"var(--mantine-radius-md)",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",border:"none",backgroundColor:r==="emoji"?"var(--mantine-color-gray-1)":"transparent",color:t==="emoji"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:e.jsx(n.Group,{gap:4,children:"Emoji"})})}),e.jsx(n.Tabs.Tab,{value:"icons",p:0,pb:"xs",onClick:()=>o("icons"),onMouseEnter:()=>s("icons"),onMouseLeave:()=>s(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",borderRadius:"var(--mantine-radius-md)",border:"none",backgroundColor:r==="icons"?"var(--mantine-color-gray-1)":"transparent",color:t==="icons"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:e.jsx(n.Group,{gap:4,children:"Icons"})})}),e.jsx(n.Tabs.Tab,{value:"image",p:0,pb:"xs",onClick:()=>o("image"),onMouseEnter:()=>s("image"),onMouseLeave:()=>s(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",borderRadius:"var(--mantine-radius-md)",border:"none",backgroundColor:r==="image"?"var(--mantine-color-gray-1)":"transparent",color:t==="image"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:e.jsx(n.Group,{gap:4,children:"Image"})})}),a&&i&&e.jsx(n.Group,{justify:"flex-end",display:"flex",flex:1,pb:"xs",children:e.jsx(n.Box,{style:{height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",borderRadius:"var(--mantine-radius-md)",border:"none",backgroundColor:l?"var(--mantine-color-red-0)":"transparent",color:l?"var(--mantine-color-red-6)":"var(--mantine-color-gray-6)",cursor:"pointer",transition:"all 0.1s ease"},fw:500,fz:"var(--mantine-font-size-sm)",onClick:a,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:"Remove"})})]}),e.jsx(n.Tabs.Panel,{value:"emoji",children:t==="emoji"?c:null}),e.jsx(n.Tabs.Panel,{value:"icons",children:t==="icons"?c:null}),e.jsx(n.Tabs.Panel,{value:"image",children:t==="image"?c:null})]})};let en=!1;en||(tn.init({data:Te}),en=!0);const Pt=()=>{const t=[{id:"frequent",name:"Frequently Used",icon:e.jsx(M.IconClock,{size:20,strokeWidth:2.5})}];return Te.categories.forEach(r=>{if(r.emojis&&r.emojis.length>0){let o=e.jsx(M.IconMoodSmile,{size:20,strokeWidth:2}),s=r.name;switch(r.id){case"people":o=e.jsx(M.IconMoodSmile,{size:20,strokeWidth:2}),s="Smileys & People";break;case"nature":o=e.jsx(M.IconTrees,{size:20,strokeWidth:2}),s="Animals & Nature";break;case"foods":o=e.jsx(M.IconApple,{size:20,strokeWidth:2}),s="Food & Drink";break;case"activity":o=e.jsx(M.IconBallBasketball,{size:20,strokeWidth:2}),s="Activities";break;case"travel":o=e.jsx(M.IconPlane,{size:20,strokeWidth:2}),s="Travel & Places";break;case"places":o=e.jsx(M.IconPlane,{size:20,strokeWidth:2}),s="Travel & Places";break;case"objects":o=e.jsx(M.IconBulb,{size:20,strokeWidth:2}),s="Objects";break;case"symbols":o=e.jsx(M.IconHeart,{size:20,strokeWidth:2}),s="Symbols";break;case"flags":o=e.jsx(M.IconFlag,{size:20,strokeWidth:2}),s="Flags";break;case"frequent":return;default:o=e.jsx(M.IconMoodSmile,{size:20,strokeWidth:2}),s=`Category: ${r.id}`;break}t.push({id:r.id,name:s,icon:o})}}),t},Ht=({onEmojiSelect:t,height:r=200})=>{const[o,s]=u.useState(""),[a,i]=u.useState("people"),[c,l]=u.useState(()=>{if(typeof window<"u"){const g=localStorage.getItem("emoji-frequent");return g?JSON.parse(g):[]}return[]}),[d,f]=u.useState([]),[h,m]=u.useState(!1),x=Pt();u.useEffect(()=>{o.trim()?(m(!0),tn.SearchIndex.search(o).then(g=>{f(g.map(b=>({id:b.id,native:b.skins[0].native,name:b.name,keywords:b.keywords}))),m(!1)})):f([])},[o]);const y=u.useMemo(()=>{if(o.trim())return d;if(a==="frequent")return c.map(b=>({id:b,native:b,name:"",keywords:[]}));const g=Te.categories.find(b=>b.id===a);return g?g.emojis.map(b=>{const v=Te.emojis[b];return{id:v.id,native:v.skins[0].native,name:v.name,keywords:v.keywords}}):[]},[o,a,c,d]),p=g=>{t(g),l(b=>{const v=b.filter(w=>w!==g),S=[g,...v].slice(0,20);return typeof window<"u"&&localStorage.setItem("emoji-frequent",JSON.stringify(S)),S})},I=g=>{if(o.trim())return"Results";const b=x.find(v=>v.id===g);return b?b.name:g.charAt(0).toUpperCase()+g.slice(1)};return e.jsxs(n.Stack,{gap:0,style:{height:r,width:"100%"},children:[e.jsx(n.Box,{p:"sm",pb:"xs",children:e.jsxs(n.Stack,{gap:"xs",children:[e.jsx(n.TextInput,{placeholder:"Search emojis...",value:o,onChange:g=>s(g.target.value),leftSection:e.jsx(M.IconSearch,{size:16,strokeWidth:2.5}),fw:500,size:"sm",radius:"md",styles:{input:{backgroundColor:"var(--mantine-color-gray-0)",color:"var(--mantine-color-gray-9)"}}}),e.jsx(n.Text,{size:"sm",c:"var(--mantine-color-gray-6)",ta:"left",fw:500,children:I(a)})]})}),e.jsx(n.Box,{style:{flex:1,overflow:"hidden"},children:e.jsx(n.ScrollArea,{h:"100%",type:"hover",offsetScrollbars:!1,children:e.jsx(n.Box,{style:{display:"grid",gridTemplateColumns:"repeat(9, 1fr)",gap:"0px",padding:"0px 12px 12px 12px"},children:h?e.jsx(n.Text,{size:"sm",c:"dimmed",ta:"center",py:"xl",style:{gridColumn:"1 / -1"},children:"Searching..."}):y.length>0?y.map(g=>e.jsx(n.Tooltip,{label:g.name||g.id,position:"top",withArrow:!0,openDelay:300,withinPortal:!0,zIndex:1e3,color:"dark",children:e.jsx(n.Button,{variant:"subtle",size:"sm",p:0,onClick:()=>p(g.native),style:{width:"40px",height:"40px",fontSize:"22px",border:"none",backgroundColor:"transparent",borderRadius:"var(--mantine-radius-md)",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:b=>{b.currentTarget.style.backgroundColor="var(--mantine-color-gray-1)"},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="transparent"},children:g.native})},g.id)):e.jsx(n.Text,{size:"sm",c:"dimmed",ta:"center",py:"xl",style:{gridColumn:"1 / -1"},children:"No emojis found"})})})}),e.jsx(n.Box,{px:"sm",py:"xs",style:{borderTop:"1px solid var(--mantine-color-gray-3)"},children:e.jsx(n.Flex,{gap:"0px",justify:"center",wrap:"wrap",children:x.map(g=>e.jsx(n.Tooltip,{label:g.name,position:"top",withArrow:!0,openDelay:500,withinPortal:!0,zIndex:1e3,color:"dark",children:e.jsx(n.Box,{onClick:()=>{i(g.id),s("")},style:{width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"var(--mantine-radius-md)",cursor:"pointer","&:hover":{backgroundColor:"var(--mantine-color-gray-0)"},backgroundColor:a===g.id?"var(--mantine-color-gray-0)":"transparent",color:a===g.id?"var(--mantine-color-blue-6)":"var(--mantine-color-gray-6)",transition:"all 0.1s ease"},onMouseEnter:b=>{b.currentTarget.style.backgroundColor="var(--mantine-color-gray-1)"},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="transparent"},children:g.icon})},g.id))})})]})},pn=["IconUser","IconUserCircle","IconUserCheck","IconUserX","IconUserPlus","IconUserMinus","IconUserEdit","IconUserCog","IconUserShield","IconUserStar","IconUserSearch","IconUserQuestion","IconUserOff","IconUsers","IconUserBolt","IconUserCode","IconUserDollar","IconUserExclamation","IconUserFilled","IconUserHexagon","IconUserKey","IconUserPause","IconUserPin","IconUserPlay","IconUserScan","IconUserShare","IconUserSquare","IconUserUp","IconUserVoice","IconUserWrench"],mn=["IconBriefcase","IconBuilding","IconBuildingStore","IconBuildingBank","IconBuildingWarehouse","IconBuildingSkyscraper","IconBuildingBridge","IconBuildingCar","IconBuildingFactory","IconBuildingHospital","IconBuildingMonument","IconBuildingPavilon","IconBuildingTunnel","IconBuildingWindmill","IconChartBar","IconChartLine","IconChartPie","IconChartDots","IconChartArea","IconChartArcs","IconChartCandle","IconChartDonut","IconChartRadar","IconTrendingUp","IconTrendingDown","IconTarget","IconFlag","IconTrophy","IconAward","IconMedal","IconCertificate","IconBadge","IconCrown","IconStar","IconStarFilled","IconStarHalf","IconStarOff","IconFileText","IconFile","IconFileAlert","IconFileAnalytics","IconFileBarcode","IconFileBroken","IconFileCertificate","IconFileChart","IconFileCheck","IconFileCode","IconFileDatabase","IconFileDollar","IconFileDownload","IconFileEuro","IconFileExport","IconFileFunction","IconFileImport","IconFileInfo","IconFileInvoice","IconFileLambda","IconFileLike","IconFileMinus","IconFileMusic","IconFileOff","IconFilePencil","IconFilePhone","IconFilePlus","IconFileReport","IconFileRss","IconFileScissors","IconFileSearch","IconFileSettings","IconFileShredder","IconFileSignal","IconFileSpreadsheet","IconFileStar","IconFileSymlink","IconFileTime","IconFileType","IconFileTypography","IconFileUnknown","IconFileUpload","IconFileVector","IconFileX","IconFileZip","IconFolder","IconFolderOpen","IconFolderPlus","IconFolderMinus","IconFolderX","IconFolderCheck","IconFolderCog","IconFolderDown","IconFolderHeart","IconFolderOff","IconFolderPause","IconFolderPin","IconFolderQuestion","IconFolderSearch","IconFolderShare","IconFolderStar","IconFolderUp","IconFolderWrench","IconArchive","IconArchiveOff","IconBox","IconBoxMultiple","IconBoxOff","IconBoxPadding","IconBoxSeam","IconBriefcaseOff","IconClipboard","IconClipboardCheck","IconClipboardCopy","IconClipboardData","IconClipboardHeart","IconClipboardList","IconClipboardOff","IconClipboardPaste","IconClipboardText","IconClipboardTypography","IconClipboardX","IconCopy","IconCut","IconPaste","IconDuplicate","IconEdit","IconEditCircle","IconEditCircleOff"],gn=["IconDeviceDesktop","IconDeviceLaptop","IconDeviceMobile","IconDeviceTablet","IconDeviceWatch","IconDeviceTv","IconDeviceGamepad","IconDeviceAirpods","IconDeviceImac","IconDeviceIpad","IconDeviceIphone","IconDeviceMacbook","IconDeviceNintendo","IconDevicePlaystation","IconDeviceXbox","IconCode","IconTerminal","IconDatabase","IconServer","IconWifi","IconBluetooth","IconCpu","IconKeyboard","IconMouse","IconCamera","IconVideo","IconMicrophone","IconSpeaker","IconHeadphones","IconPrinter","IconScanner","IconRouter","IconModem","IconAntenna","IconSatellite","IconRadar","IconRadar2","IconBroadcast","IconBroadcastOff","IconRadio","IconRadioactive","IconRadioactiveOff","IconSignal","IconSignal4G","IconSignal5G","IconSignalOff","IconBattery","IconBattery1","IconBattery2","IconBattery3","IconBattery4","IconBatteryOff","IconBatteryCharging","IconBatteryAutomotive","IconBatteryEco","IconBatteryFilled","IconPlug","IconPlugConnected","IconPlugConnectedX","IconPlugOff","IconPlugX","IconPower","IconPowerOff","IconOutlet","IconCable","IconCableOff","IconCircuitAmmeter","IconCircuitBattery","IconCircuitBulb","IconCircuitCapacitor","IconCircuitCell","IconCircuitCellPlus","IconCircuitChangeover","IconCircuitDiode","IconCircuitDiodeZener","IconCircuitGround","IconCircuitGroundDigital","IconCircuitInductor","IconCircuitMotor","IconCircuitPushbutton","IconCircuitResistor","IconCircuitSwitchClosed","IconCircuitSwitchOpen","IconCircuitVoltmeter","IconCpu2","IconCpuOff","IconMemory","IconMemoryCard","IconMemoryStick","IconHardDrive","IconHardDrive2","IconDisk","IconDiskOff","IconCd","IconCdOff","IconDvd","IconDvdOff","IconFloppyDisk","IconFloppyDiskOff","IconUsb","IconUsbOff","IconSdCard","IconSdCardOff","IconCloud","IconCloudComputing","IconCloudDataConnection","IconCloudDownload","IconCloudLock","IconCloudOff","IconCloudRain","IconCloudSnow","IconCloudStorm","IconCloudUpload","IconCloudCheck","IconCloudCode","IconCloudCog","IconCloudDollar","IconCloudDown","IconCloudExclamation","IconCloudHeart","IconCloudMinus","IconCloudPause","IconCloudPin","IconCloudPlus","IconCloudQuestion","IconCloudSearch","IconCloudShare","IconCloudStar","IconCloudUp","IconCloudX"],In=["IconMoodSmile","IconMoodHappy","IconMoodWink","IconMoodSad","IconMoodConfused","IconMoodAnnoyed","IconMoodAngry","IconMoodCry","IconMoodTongue","IconMoodKiss","IconMoodHeart","IconMoodLove","IconMoodEmpty","IconMoodNervous","IconMoodSuprised","IconMoodSilence","IconMoodSick","IconMoodTongueWink","IconMoodTongueWink2","IconMoodWink2","IconHeart","IconHeartFilled","IconHeartBroken","IconHeartHandshake","IconHeartMinus","IconHeartOff","IconHeartPlus","IconHeartRateMonitor","IconThumbUp","IconThumbDown","IconSmile","IconFrown","IconMeh","IconLaugh","IconWink","IconKiss","IconTongue","IconGrin","IconSmirk"],yn=["IconTrees","IconLeaf","IconFlower","IconPlant","IconSun","IconMoon","IconStar","IconCloud","IconCloudRain","IconCloudSnow","IconSnowflake","IconDroplet","IconFlame","IconMountain","IconTree","IconPineTree","IconBug","IconButterfly","IconFish","IconBird","IconCat","IconDog","IconRabbit","IconPaw","IconPawprint","IconFeather","IconSeeding","IconSeedingOff","IconPlant2","IconPlantOff","IconLeafOff","IconFlower2","IconFlowerOff","IconTreesOff","IconTreeOff","IconPineTreeOff","IconPalmTree","IconPalmTreeOff","IconSunOff","IconSunHigh","IconSunLow","IconMoonOff","IconMoonStars","IconMoon2","IconMoonFilled","IconStars","IconStarsOff","IconStarFilled","IconStarHalf","IconStarOff","IconCloudOff","IconCloudStorm","IconCloudFog","IconCloudWind","IconSnowflakeOff","IconDropletOff","IconDropletFilled","IconDropletHalf","IconDropletHalf2","IconDropletHalfFilled","IconFlameOff","IconFire","IconFireExtinguisher","IconMountainOff","IconMountain2","IconHills","IconHillsOff","IconValley","IconValleyOff","IconBugOff","IconButterflyOff","IconBee","IconBeeOff","IconSpider","IconSpiderOff","IconAnt","IconAntOff","IconLadybug","IconLadybugOff","IconGrasshopper","IconGrasshopperOff","IconCricket","IconCricketOff","IconFishOff","IconFishBone","IconFishBoneOff","IconShark","IconSharkOff","IconWhale","IconWhaleOff","IconDolphin","IconDolphinOff","IconOctopus","IconOctopusOff","IconSeahorse","IconSeahorseOff","IconBirdOff","IconEagle","IconEagleOff","IconOwl","IconOwlOff","IconParrot","IconParrotOff","IconPeacock","IconPeacockOff","IconPenguin","IconPenguinOff","IconSwan","IconSwanOff","IconCatOff","IconDogOff","IconRabbitOff","IconFeatherOff","IconWing","IconWingOff","IconEgg","IconEggOff","IconEggCracked","IconEggCrackedOff","IconEggFilled","IconEggFilledOff","IconEggFried","IconEggFriedOff","IconNest","IconNestOff","IconNestEggs","IconNestEggsOff"],vn=["IconCircle","IconSquare","IconTriangle","IconDiamond","IconHexagon","IconPentagon","IconOctagon","IconCross","IconPlus","IconMinus","IconCheck","IconX","IconArrowUp","IconArrowDown","IconArrowLeft","IconArrowRight","IconArrowUpLeft","IconArrowUpRight","IconArrowDownLeft","IconArrowDownRight","IconArrowLeftUp","IconArrowLeftDown","IconArrowRightUp","IconArrowRightDown","IconPlay","IconPause","IconStop","IconRecord","IconSkipBack","IconSkipForward","IconRewind","IconFastForward","IconCircleDot","IconCircleFilled","IconCircleHalf","IconCircleHalf2","IconCircleHalfFilled","IconCircleOff","IconCircleX","IconSquareDot","IconSquareFilled","IconSquareHalf","IconSquareHalfFilled","IconSquareOff","IconSquareRounded","IconSquareRoundedDot","IconSquareRoundedFilled","IconSquareRoundedHalf","IconSquareRoundedHalfFilled","IconSquareRoundedOff","IconSquareRoundedX","IconSquareX","IconTriangleFilled","IconTriangleInverted","IconTriangleInvertedFilled","IconTriangleOff","IconTriangleSquare","IconTriangleSquareCircle","IconDiamondFilled","IconDiamondOff","IconHexagonFilled","IconHexagonOff","IconPentagonFilled","IconPentagonOff","IconOctagonFilled","IconOctagonOff","IconCrossOff","IconPlusMinus","IconMinusMinus","IconCheckbox","IconCheckboxOff","IconChecks","IconXbox","IconXboxOff","IconYinYang","IconYinYangOff","IconYoga","IconYogaOff","IconZodiac","IconZodiacOff","IconZoom","IconZoomCancel","IconZoomCode","IconZoomExclamation","IconZoomFilled","IconZoomIn","IconZoomInArea","IconZoomInAreaFilled","IconZoomInFilled","IconZoomMoney","IconZoomPan","IconZoomQuestion","IconZoomReplace","IconZoomReset","IconZoomScan","IconZoomScanFilled","IconZoomX"],jn=["IconEdit","IconDelete","IconSave","IconOpen","IconClose","IconAdd","IconRemove","IconSearch","IconFilter","IconSort","IconRefresh","IconReload","IconUndo","IconRedo","IconCut","IconCopy","IconPaste","IconDuplicate","IconMove","IconRotate","IconFlip","IconResize","IconScale","IconCrop","IconTransform","IconWrench","IconHammer","IconScrewdriver","IconTool","IconTools","IconSaw","IconDrill","IconDrillOff","IconAxe","IconAxeOff","IconPickaxe","IconPickaxeOff","IconShovel","IconShovelOff","IconRake","IconRakeOff","IconHoe","IconHoeOff","IconScythe","IconScytheOff","IconPitchfork","IconPitchforkOff","IconFork","IconForkOff","IconKnife","IconKnifeOff","IconSword","IconSwordOff","IconDagger","IconDaggerOff","IconSpear","IconSpearOff","IconBow","IconBowOff","IconArrow","IconArrowOff","IconCrossbow","IconCrossbowOff","IconGun","IconGunOff","IconPistol","IconPistolOff","IconRifle","IconRifleOff","IconShotgun","IconShotgunOff","IconBomb","IconBombOff","IconGrenade","IconGrenadeOff","IconDynamite","IconDynamiteOff","IconMine","IconMineOff","IconTorpedo","IconTorpedoOff","IconMissile","IconMissileOff","IconRocket","IconRocketOff","IconBazooka","IconBazookaOff","IconCannon","IconCannonOff","IconTank","IconTankOff","IconHelicopter","IconHelicopterOff","IconPlane","IconPlaneOff","IconJet","IconJetOff","IconSatellite","IconSatelliteOff","IconSpace","IconSpaceOff","IconGalaxy","IconGalaxyOff","IconPlanet","IconPlanetOff","IconEarth","IconEarthOff","IconMoon","IconMoonOff","IconSun","IconSunOff","IconStar","IconStarOff","IconAsteroid","IconAsteroidOff","IconComet","IconCometOff","IconMeteor","IconMeteorOff","IconUfo","IconUfoOff","IconAlien","IconAlienOff","IconRobot","IconRobotOff","IconAndroid","IconAndroidOff","IconIos","IconIosOff","IconWindows","IconWindowsOff","IconLinux","IconLinuxOff","IconMac","IconMacOff","IconUbuntu","IconUbuntuOff","IconDebian","IconDebianOff","IconRedhat","IconRedhatOff","IconCentos","IconCentosOff","IconFedora","IconFedoraOff","IconSuse","IconSuseOff","IconArch","IconArchOff","IconGentoo","IconGentooOff","IconSlackware","IconSlackwareOff","IconMint","IconMintOff","IconKali","IconKaliOff","IconParrot","IconParrotOff","IconBacktrack","IconBacktrackOff","IconBlackarch","IconBlackarchOff","IconPentoo","IconPentooOff","IconMatriux","IconMatriuxOff","IconNodezero","IconNodezeroOff","IconBugtraq","IconBugtraqOff","IconCyborg","IconCyborgOff","IconDefensive","IconDefensiveOff","IconDracos","IconDracosOff","IconFembuntu","IconFembuntuOff","IconGnacktrack","IconGnacktrackOff","IconHackintosh","IconHackintoshOff","IconHak5","IconHak5Off","IconHavij","IconHavijOff","IconJackal","IconJackalOff","IconKnoppix","IconKnoppixOff","IconKodachi","IconKodachiOff","IconLion","IconLionOff","IconMandriva","IconMandrivaOff","IconMobily","IconMobilyOff","IconMuslim","IconMuslimOff","IconNetrunner","IconNetrunnerOff","IconPardus","IconPardusOff","IconQubes","IconQubesOff","IconSabayon","IconSabayonOff","IconScientific","IconScientificOff","IconSemplice","IconSempliceOff","IconSiduction","IconSiductionOff","IconSlax","IconSlaxOff","IconSli","IconSliOff","IconTails","IconTailsOff","IconVector","IconVectorOff","IconVoid","IconVoidOff","IconWhonix","IconWhonixOff","IconZorin","IconZorinOff","IconAlpine","IconAlpineOff","IconElementary","IconElementaryOff","IconManjaro","IconManjaroOff","IconOpenbsd","IconOpenbsdOff","IconOpenSuse","IconOpenSuseOff","IconPop","IconPopOff","IconSolus","IconSolusOff"],bn=["IconMessage","IconMessageCircle","IconMessageDots","IconMessagePlus","IconMessageReport","IconMessageShare","IconMessageText","IconMessages","IconMessagesOff","IconMail","IconMailOpened","IconMailFast","IconMailOff","IconMailPause","IconMailPin","IconMailPlus","IconMailQuestion","IconMailSearch","IconMailShare","IconMailStar","IconMailUp","IconMailX","IconPhone","IconPhoneCall","IconPhoneIncoming","IconPhoneOff","IconPhoneOutgoing","IconPhonePause","IconPhonePlus","IconPhoneX","IconVideo","IconVideoOff","IconVideoPlus","IconCamera","IconCameraOff","IconCameraPlus","IconMicrophone","IconMicrophoneOff","IconMicrophone2","IconMicrophone2Off","IconHeadphones","IconHeadphonesOff","IconSpeaker","IconSpeakerOff","IconBroadcast","IconBroadcastOff","IconRadio","IconRadioactive","IconRadioactiveOff","IconAntenna","IconAntennaBars1","IconAntennaBars2","IconAntennaBars3","IconAntennaBars4","IconAntennaBars5","IconAntennaOff","IconSatellite","IconSatelliteOff","IconWifi","IconWifi0","IconWifi1","IconWifi2","IconWifiOff","IconBluetooth","IconBluetoothConnected","IconBluetoothOff","IconBluetoothX","IconShare","IconShareOff","IconShare2","IconShare3","IconAt","IconHash","IconLink","IconLinkOff","IconExternalLink","IconExternalLinkOff","IconSend","IconSendOff","IconSend2","IconReceipt","IconReceiptOff","IconReceipt2","IconReceiptRefund","IconReceiptTax","IconReceiptEuro","IconReceiptDollar","IconReceiptPound","IconReceiptYen","IconReceiptYuan","IconReceiptWon","IconReceiptRupee","IconReceiptBaht","IconReceiptLira","IconReceiptRuble","IconReceiptShekel","IconReceiptTaka","IconReceiptHryvnia","IconReceiptKrone","IconReceiptKrona","IconReceiptZloty","IconReceiptForint","IconReceiptLeu","IconReceiptLev","IconReceiptKuna","IconReceiptDinar","IconReceiptDirham","IconReceiptRial","IconReceiptRiyal","IconReceiptAfghani","IconReceiptAriary","IconReceiptCedi","IconReceiptDalasi","IconReceiptFranc","IconReceiptGourde","IconReceiptKina","IconReceiptKip","IconReceiptKwacha","IconReceiptKwanza","IconReceiptLari","IconReceiptLek","IconReceiptLilangeni","IconReceiptLoti","IconReceiptManat","IconReceiptMetical","IconReceiptNaira","IconReceiptPeso","IconReceiptPula","IconReceiptRand","IconReceiptRupiah","IconReceiptShilling","IconReceiptSom","IconReceiptSomoni","IconReceiptTenge","IconReceiptVatu","IconReceiptWon","IconReceiptXof","IconReceiptYuan","IconReceiptZloty"];[...pn,...mn,...gn,...In,...yn,...vn,...jn,...bn];const ge=[{id:"recent",name:"Recently Used",icons:[],isDynamic:!0},{id:"user",name:"User & Profile",icons:pn},{id:"business",name:"Business & Work",icons:mn},{id:"tech",name:"Technology",icons:gn},{id:"expressions",name:"Expressions",icons:In},{id:"nature",name:"Nature & Animals",icons:yn},{id:"shapes",name:"Shapes & Symbols",icons:vn},{id:"actions",name:"Actions & Tools",icons:jn},{id:"communication",name:"Communication",icons:bn}],Gt={recent:e.jsx(M.IconClock,{size:20,strokeWidth:2.5}),user:e.jsx(M.IconUser,{size:20,strokeWidth:2.5}),business:e.jsx(M.IconBriefcase,{size:20,strokeWidth:2.5}),tech:e.jsx(M.IconDeviceDesktop,{size:20,strokeWidth:2.5}),expressions:e.jsx(M.IconMoodSmile,{size:20,strokeWidth:2.5}),nature:e.jsx(M.IconTrees,{size:20,strokeWidth:2.5}),shapes:e.jsx(M.IconCircle,{size:20,strokeWidth:2.5}),actions:e.jsx(M.IconTool,{size:20,strokeWidth:2.5}),communication:e.jsx(M.IconMessage,{size:20,strokeWidth:2.5})},Vt=({selectedCategory:t,onCategoryChange:r})=>e.jsx(n.Flex,{gap:"0px",justify:"center",wrap:"wrap",children:ge.map(o=>{const s=Gt[o.id];return e.jsx(n.Tooltip,{label:o.name,position:"top",withArrow:!0,openDelay:500,withinPortal:!0,zIndex:1e3,color:"dark",children:e.jsx(n.Box,{onClick:()=>r(o.id),style:{width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"var(--mantine-radius-md)",cursor:"pointer",backgroundColor:t===o.id?"var(--mantine-color-gray-0)":"transparent",color:t===o.id?"var(--mantine-color-blue-6)":"var(--mantine-color-gray-6)",transition:"all 0.2s ease"},onMouseEnter:a=>{a.currentTarget.style.backgroundColor="var(--mantine-color-gray-1)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor=t===o.id?"var(--mantine-color-gray-0)":"transparent"},children:s})},o.id)})}),wn=u.memo(({onIconSelect:t,height:r=358})=>{var g,b;const[o,s]=u.useState(""),[a,i]=u.useState("recent"),[c,l]=u.useState(!1),[d,f]=u.useState([]);u.useLayoutEffect(()=>{if(typeof window<"u"){const v=localStorage.getItem("avatar-icon-recent");if(v)try{f(JSON.parse(v))}catch(S){console.warn("Error parsing recent icons from localStorage:",S)}}},[]);const h=u.useMemo(()=>ge.filter(v=>v.id!=="recent"&&!("isDynamic"in v)).flatMap(v=>v.icons),[]),m=u.useMemo(()=>{if(a==="recent"){const S=new Set(h);return d.filter(w=>S.has(w))}const v=ge.find(S=>S.id===a);return(v==null?void 0:v.icons)||[]},[a,d,h]),x=u.useCallback((v,S)=>{if(!v.trim())return S;const w=v.toLowerCase().trim(),T=w.split(/\s+/);return S.filter(k=>{const j=k.replace(/^Icon/,"").split(/(?=[A-Z])/).map(R=>R.toLowerCase().trim()).filter(R=>R.length>0);return!!(j.some(R=>T.some(D=>R===D))||w.length>2&&j.some(R=>T.some(D=>R.startsWith(D)))||w.length<=2&&j.some(R=>T.some(D=>R.includes(D)))||T.length>1&&T.every(R=>j.some(D=>D===R||D.startsWith(R))))})},[]),y=u.useMemo(()=>o.trim()?x(o,h):m,[o,m,h,x]),p=u.useCallback(v=>{h.includes(v)&&f(w=>{const T=[v,...w.filter(k=>k!==v)].slice(0,20);return typeof window<"u"&&localStorage.setItem("avatar-icon-recent",JSON.stringify(T)),T}),t(v)},[t,h]),I=u.useCallback(v=>{a!==v&&(s(""),i(v),requestAnimationFrame(()=>{l(!0),setTimeout(()=>l(!1),100)}))},[a]);return e.jsxs(n.Stack,{gap:0,style:{height:r,width:"100%"},children:[e.jsx(n.Box,{p:"sm",pb:"xs",children:e.jsxs(n.Stack,{gap:"xs",children:[e.jsx(n.TextInput,{placeholder:o.trim()?"Search all icons...":`Search in ${(g=ge.find(v=>v.id===a))==null?void 0:g.name}...`,value:o,onChange:v=>s(v.target.value),leftSection:e.jsx(M.IconSearch,{size:16}),fw:500,size:"sm",radius:"md",styles:{input:{backgroundColor:"var(--mantine-color-gray-0)",color:"var(--mantine-color-gray-9)"}}}),e.jsx(n.Text,{size:"sm",c:"var(--mantine-color-gray-6)",ta:"left",fw:500,children:o.trim()?"Results":(b=ge.find(v=>v.id===a))==null?void 0:b.name})]})}),e.jsx(n.Box,{style:{flex:1,overflow:"hidden"},children:e.jsx(n.ScrollArea,{h:"100%",type:"hover",children:e.jsx(n.Box,{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:"4px",padding:"0 12px 12px 12px",opacity:c?.7:1,transition:"opacity 0.05s ease"},children:y.map(v=>e.jsx(rn,{iconName:v,onClick:()=>p(v),size:20},o.trim()?`search-${v}`:`${a}-${v}`))},`${a}-${o}`)})}),e.jsx(n.Box,{px:"sm",py:"xs",style:{borderTop:"1px solid var(--mantine-color-gray-3)"},children:e.jsx(Vt,{selectedCategory:a,onCategoryChange:I})})]})});wn.displayName="IconGrid";const _t=({previewImage:t,fileInputRef:r,selectedEmoji:o,size:s,loading:a,onFileInputClick:i,onImageChange:c,onImageAccept:l,onClearImagePreview:d})=>e.jsx(n.Box,{p:"sm",style:{width:"384px"},children:e.jsxs(n.Stack,{gap:"md",align:"center",children:[t||o?e.jsxs(n.Box,{children:[e.jsx(n.Text,{size:"sm",fw:500,mb:"xs",children:"Preview"}),e.jsx(n.Avatar,{src:t,radius:"md",style:{width:`${xe(s)}px !important`,height:`${xe(s)}px !important`,minWidth:`${xe(s)}px`,minHeight:`${xe(s)}px`,maxWidth:`${xe(s)}px`,maxHeight:`${xe(s)}px`,border:"1px solid var(--mantine-color-gray-4)",objectFit:"cover",boxSizing:"border-box"},children:o})]}):e.jsx(n.Button,{variant:"subtle",bg:"gray.0",styles:{root:{height:"64px"}},leftSection:e.jsx(M.IconPhoto,{size:20}),onClick:i,loading:a,disabled:a,fullWidth:!0,children:"Choose Image"}),t||o?e.jsx(n.Button,{variant:"outline",leftSection:e.jsx(M.IconPhoto,{size:16}),onClick:i,loading:a,disabled:a,fullWidth:!0,children:t||o?"Change Image":"Choose Image"}):null,e.jsx("input",{ref:r,type:"file",accept:"image/jpeg,image/jpg,image/png,image/gif,image/webp",onChange:f=>{var h;return c(((h=f.target.files)==null?void 0:h[0])||null)},style:{display:"none"},disabled:a}),(t||o)&&e.jsxs(n.Group,{gap:"sm",w:"100%",children:[e.jsx(n.Button,{variant:"outline",color:"gray",onClick:d,fullWidth:!0,children:"Back"}),e.jsx(n.Button,{color:"blue",onClick:l,loading:a,disabled:a,fullWidth:!0,children:"Accept"})]}),e.jsx(n.Text,{size:"xs",c:"var(--mantine-color-gray-6)",ta:"center",children:"Supported formats: JPG, PNG, GIF, WebP"})]})}),Qt=({onEmojiSelect:t})=>e.jsx(Ht,{onEmojiSelect:t,height:358}),Yt=({onIconSelect:t})=>e.jsx(wn,{onIconSelect:t,height:358}),qt=({previewImage:t,selectedEmoji:r,size:o,loading:s,onFileInputClick:a,onImageChange:i,onImageAccept:c,onClearImagePreview:l,fileInputRef:d})=>e.jsx(_t,{previewImage:t,fileInputRef:d,selectedEmoji:r,size:o,loading:s,onFileInputClick:a,onImageChange:i,onImageAccept:c,onClearImagePreview:l}),Zt=()=>e.jsx(n.Box,{style:{width:400,height:358,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs(n.Stack,{align:"center",gap:"sm",children:[e.jsx(n.Loader,{size:"sm"}),e.jsx(n.Text,{size:"sm",c:"gray.6",children:"Loading avatar options..."})]})}),Ee=({editable:t=!0,opened:r,onOpen:o,onClose:s,avatar:a,onAvatarSelect:i,onRemove:c,size:l="lg",loading:d=!1,placeholder:f,showPlaceholder:h=!0,position:m="bottom-start",withinPortal:x=!0,zIndex:y=1e3})=>{const p=u.useRef(null),I=u.useRef(null),g=u.useRef(null),{selectedTab:b,tabHovered:v,previewImage:S,selectedEmoji:w,selectedIcon:T,selectedFile:k,handleTabChange:C,handleTabHover:j,handleImagePreview:R,handleImageAccept:D,handleEmojiSelect:O,handleIconSelect:E,clearImagePreview:H,resetState:$}=Nt({onAvatarSelect:i});Wt({opened:r,onClose:s,popoverRef:I}),u.useEffect(()=>{r||$()},[r,$]);const W=X=>{console.log("Emoji clicked:",X),O(X),s()},L=X=>{console.log("Icon clicked:",X),E(X),s()},F=X=>{X&&R(X)},U=()=>{k?(D(),s()):(w||T)&&s()},Z=()=>{p.current&&p.current.click()},_=()=>{H()},G=()=>{console.log("Avatar removed"),c==null||c(),s()},B=()=>!!a,z=()=>d?e.jsx(Be,{size:l,loading:!0}):e.jsx(se,{avatar:a,size:l,placeholder:f,showPlaceholder:h,editable:!0,onClick:()=>{!d&&!r&&o()}}),A=e.jsx(Qt,{onEmojiSelect:W}),N=e.jsx(Yt,{onIconSelect:L}),V=e.jsx(qt,{previewImage:S,selectedEmoji:w,size:l,loading:d,onFileInputClick:Z,onImageChange:F,onImageAccept:U,onClearImagePreview:_,fileInputRef:p}),ne=e.jsx(n.Box,{children:e.jsx($t,{selectedTab:b,tabHovered:v,onTabChange:C,onTabHover:j,onRemove:G,hasAvatar:B(),children:b==="emoji"?A:b==="icons"?N:V})}),P=e.jsx("div",{style:{position:"relative",display:"inline-block"},children:e.jsxs(n.Popover,{opened:r,onClose:()=>{console.log("Popover onClose called"),s()},position:m,withinPortal:x,withArrow:!0,shadow:"md",radius:"md",closeOnClickOutside:!1,closeOnEscape:!1,offset:8,children:[e.jsx(n.Popover.Target,{children:e.jsx("div",{ref:g,style:{position:"relative"},children:z()})}),e.jsx(n.Popover.Dropdown,{ref:I,p:0,style:{width:"auto",overflow:"hidden",zIndex:y},children:e.jsx(u.Suspense,{fallback:e.jsx(Zt,{}),children:ne})})]})}),oe=e.jsx(se,{avatar:a,size:l,placeholder:f,showPlaceholder:h});return e.jsx(e.Fragment,{children:t?P:oe})},Xt=t=>{if(!t||typeof t!="string")return!1;const r=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return t.length<5||t.length>254?!1:r.test(t.trim())},Kt=t=>{const r=[];return t.forEach(o=>{Xt(o)||r.push({email:o,error:"Please enter a valid email address"})}),{isValid:r.length===0,errors:r}},Jt=t=>{const r=[],o=new Set;return t.forEach(s=>{const a=s.toLowerCase().trim();o.has(a)?r.push({email:s,error:"This email has already been added"}):o.add(a)}),r},eo=t=>{const r=Kt(t),o=Jt(t),s=[...r.errors,...o];return{isValid:s.length===0,errors:s}},no=({value:t,onChange:r,onInputChange:o,suggestedUsers:s=[],tagDisplayMap:a={}})=>{const[i,c]=u.useState(""),[l,d]=u.useState([]),f=u.useRef(null),h=t.map(I=>{if(a[I])return a[I];const g=s.find(b=>b.email===I);return g&&g.name?g.name:I});u.useEffect(()=>{o&&o(i)},[i,o]),u.useEffect(()=>{if(t.length>0){const I=eo(t);d(I.errors)}else d([])},[t]),u.useEffect(()=>{const I=f.current;if(!I)return;let g;const b=v=>{const w=v.target.value||"";clearTimeout(g),g=setTimeout(()=>{c(w)},150)};return I.addEventListener("input",b),()=>{I.removeEventListener("input",b),clearTimeout(g)}},[]);const m=u.useCallback(I=>{const g=s.map(v=>({name:v.name||v.email,email:v.email})),b=I.map(v=>{const S=g.find(w=>w.name.toLowerCase()===v.toLowerCase());return S?S.email:v}).filter(v=>v.includes("@")?!0:!g.some(w=>{const T=w.name.toLowerCase(),k=v.toLowerCase();return T.startsWith(k)&&k!==T}));r(b),c("")},[r,s]),x=u.useCallback(()=>{f.current&&(f.current.value="",c(""))},[]),y=l.length===0&&t.length>0,p=u.useCallback((I,g,b)=>{I&&t.length>0&&g&&(I(t,g,b),c(""))},[t]);return{inputText:i,tagsInputRef:f,displayValue:h,validationErrors:l,isValid:y,handleEmailChange:m,clearInput:x,handleInvite:p}},Sn=({onInvite:t,onUpdateRole:r,onRemoveUser:o,invitedUsers:s=[],suggestedUsers:a=[],roleOptions:i=[]})=>{const[c,l]=u.useState([]),[d,f]=u.useState([]),[h,m]=u.useState(""),[x,y]=u.useState({}),p=i.length>0?i[0].value:void 0,[I,g]=u.useState(p);u.useEffect(()=>{i.length>0&&!I&&g(i[0].value)},[i.length,I]),u.useEffect(()=>{const O=a.filter(E=>c.includes(E.email)).map(E=>E.id);f(E=>E.filter(H=>O.includes(H)))},[c,a.length]);const[b,v]=u.useState("invite"),[S,w]=u.useState(null),T=(O,E,H)=>{t&&t(O,E,H),l([]),m("")},k=(O,E)=>{r&&r(O,E)},C=O=>{o&&o(O)},j=O=>{f(E=>E.includes(O)?E.filter(H=>H!==O):[...E,O])},R=O=>{c.includes(O.email)||(l([...c,O.email]),y(E=>({...E,[O.email]:O.name||O.email})),d.includes(O.id)||f([...d,O.id]),m(""))},D=h.trim()?a.filter(O=>{var H;const E=h.toLowerCase();return O.email.toLowerCase().includes(E)||((H=O.name)==null?void 0:H.toLowerCase().includes(E))}):[];return{emails:c,setEmails:l,selectedUsers:d,setSelectedUsers:f,inputText:h,setInputText:m,tagDisplayMap:x,setTagDisplayMap:y,selectedRole:I,setSelectedRole:g,selectedTab:b,setSelectedTab:v,tabHovered:S,setTabHovered:w,filteredUsers:D,handleInvite:T,handleUpdateRole:k,handleRemoveUser:C,handleToggleUser:j,handleAddSuggestedUser:R}},kn=u.forwardRef(({value:t,onChange:r,placeholder:o="Add one or more emails",onInvite:s,roleOptions:a=[],selectedRole:i,onRoleChange:c,onInputChange:l,suggestedUsers:d=[],tagDisplayMap:f={}},h)=>{const[m,x]=u.useState("Hello, I would like to invite you to join my workspace"),{tagsInputRef:y,displayValue:p,validationErrors:I,isValid:g,handleEmailChange:b,clearInput:v,handleInvite:S}=no({value:t,onChange:r,onInputChange:l,suggestedUsers:d,tagDisplayMap:f}),w=()=>{S(s,i,m),x("")};u.useImperativeHandle(h,()=>({clearInput:v}),[v]);const T=p.length>0,k=c&&a.length>0,C=I.length>0;return e.jsxs(n.Stack,{gap:"md",children:[e.jsxs(n.Box,{children:[e.jsx(n.Box,{style:{maxHeight:"120px",overflowY:"auto",overflowX:"hidden",paddingRight:"8px",marginRight:"-8px"},children:e.jsx(n.TagsInput,{ref:y,value:p,onChange:b,placeholder:T?"":o,radius:"md",rightSection:k?e.jsx(n.Box,{style:{position:"absolute",right:"8px",top:"17px",transform:"translateY(-50%)",height:"24px",display:"flex",alignItems:"center"},children:e.jsx(De,{value:i||"",onChange:j=>c(j),data:a,placeholder:"Select role",defaultOption:a[a.length-1],disabledOptions:["owner"]})}):null,rightSectionProps:{style:{width:k?"120px":"0px",position:"absolute",height:"32px",right:"8px"}},styles:{input:{paddingRight:k?"130px":"12px",minHeight:"36px",display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px",borderRadius:"var(--mantine-radius-md)",border:C?"2px solid var(--mantine-color-red-6)":"2px solid var(--mantine-color-blue-7)",backgroundColor:"var(--mantine-color-gray-0)"},pillsList:{height:"24px !important",borderRadius:"var(--mantine-radius-md) !important"},pill:{height:"24px !important",borderRadius:"var(--mantine-radius-md) !important",backgroundColor:C?"var(--mantine-color-red-1) !important":"var(--mantine-color-orange-1) !important",color:C?"var(--mantine-color-red-7) !important":"var(--mantine-color-gray-7) !important",fontSize:"var(--mantine-font-size-sm)"}}})}),C&&e.jsx(n.Stack,{gap:"xs",mt:"xs",children:I.map((j,R)=>e.jsxs(n.Text,{size:"xs",c:"red",children:[j.email,": ",j.error]},R))})]}),T&&e.jsxs(n.Stack,{gap:"sm",children:[e.jsx(n.Textarea,{size:"sm",value:m,onChange:j=>x(j.currentTarget.value),minRows:2,maxRows:4,radius:"md"}),e.jsx(n.Button,{variant:"filled",color:"blue",onClick:w,fullWidth:!0,radius:"md",disabled:!g,children:"Send invitations"})]})]})}),to=t=>{switch(t){case"member":return"green";case"invited":return"orange";case"declined":return"red";case"revoked":return"red";case"expired":return"red";default:return"gray"}},oo=t=>{switch(t){case"member":return"Member";case"invited":return"Invited";case"declined":return"Declined";case"revoked":return"Revoked";case"expired":return"Expired";default:return"Unknown"}},ro=t=>{if(t){if(typeof t=="object"&&"type"in t)return t;if(typeof t=="string")return{type:"image",value:t}}},ve=({user:t,isSelected:r=!1,onToggle:o,onUpdateRole:s,onRemoveUser:a,roleOptions:i=[],variant:c="invited",onClick:l})=>{var g;const d=((g=t.name)==null?void 0:g.trim())||t.email,f=()=>{o&&o(t.id)},h=b=>{if(s){const v=b;s(t.id,v)}},m=c==="suggested"||c==="read-only",x=c==="invited"&&i.length>0,[y,p]=u.useState(!1),I=()=>{l==null||l()};return e.jsxs(n.Group,{justify:"space-between",align:"center",wrap:"nowrap",w:"100%",style:{cursor:"pointer",borderRadius:"var(--mantine-radius-md)",padding:"6px"},onClick:I,bg:y?"var(--mantine-color-gray-0)":"transparent",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[e.jsxs(n.Group,{gap:"sm",w:"100%",align:"flex-start",wrap:"nowrap",children:[e.jsx(se,{avatar:ro(t.avatar),size:"md",placeholder:d,showPlaceholder:!0}),e.jsxs(n.Stack,{gap:0,w:"100%",justify:"flex-start",align:"flex-start",children:[e.jsxs(n.Group,{gap:"sm",align:"flex-start",wrap:"nowrap",children:[e.jsxs(n.Group,{gap:"sm",align:"flex-start",wrap:"nowrap",children:[e.jsx(n.Text,{size:"sm",fw:500,lineClamp:1,mb:-2,children:d}),t.isCurrentUser&&e.jsx(n.Badge,{size:"xs",variant:"light",color:"gray",radius:"sm",children:"Owner"})]}),t.status!=="member"&&e.jsx(n.Badge,{size:"xs",variant:"light",color:to(t.status),radius:"sm",children:oo(t.status)})]}),e.jsx(n.Text,{size:"xs",c:"dimmed",lineClamp:1,children:t.email})]})]}),e.jsxs(n.Group,{gap:"sm",align:"center",children:[m&&c!=="read-only"&&e.jsx(n.Radio,{checked:r,onChange:f,size:"sm",onClick:b=>b.stopPropagation(),pr:4}),x&&!t.isCurrentUser&&e.jsx(De,{value:t.role,onChange:h,data:i,placeholder:"Select role",defaultOption:i.find(b=>b.value===t.role),withRemove:!0,onRemove:()=>a==null?void 0:a(t.id)})]})]})},Cn=({opened:t,onClose:r,onInvite:o,onUpdateRole:s,onRemoveUser:a,invitedUsers:i=[],children:c,roleOptions:l=[],suggestedUsers:d=[]})=>{const f=u.useRef(null),{emails:h,setEmails:m,selectedUsers:x,inputText:y,setInputText:p,tagDisplayMap:I,selectedRole:g,setSelectedRole:b,selectedTab:v,setSelectedTab:S,tabHovered:w,setTabHovered:T,filteredUsers:k,handleInvite:C,handleUpdateRole:j,handleRemoveUser:R,handleToggleUser:D,handleAddSuggestedUser:O}=Sn({onInvite:o,onUpdateRole:s,onRemoveUser:a,invitedUsers:i,suggestedUsers:d,roleOptions:l}),E=L=>{O(L),f.current&&f.current.clearInput()},H=e.jsxs(e.Fragment,{children:[e.jsx(kn,{ref:f,value:h,onChange:m,onInvite:C,roleOptions:l,selectedRole:g,onRoleChange:b,onInputChange:p,suggestedUsers:d,tagDisplayMap:I}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.ScrollArea,{mah:200,type:"auto",style:{overflow:"visible"},children:e.jsx(n.Box,{children:i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(n.Text,{size:"sm",fw:500,children:"Already members"}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.Stack,{gap:"sm",children:i.map(L=>e.jsx(ve,{user:L,isSelected:x.includes(L.id),onToggle:D,onUpdateRole:j,onRemoveUser:R,roleOptions:l,variant:"invited"},L.id))})]})})}),k.length>0&&e.jsx(n.ScrollArea,{pt:"sm",mah:200,type:"auto",style:{overflow:"visible"},children:e.jsx(n.Box,{children:k.length>0?e.jsxs(e.Fragment,{children:[e.jsxs(n.Text,{size:"sm",fw:500,children:["Suggested ",y.trim()&&`(filtered by "${y}")`]}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.Stack,{gap:"sm",children:k.map(L=>e.jsx(ve,{user:L,isSelected:x.includes(L.id),onToggle:D,onUpdateRole:j,onRemoveUser:R,roleOptions:l,variant:"suggested",onClick:()=>E(L)},L.id))})]}):null})})]}),$=e.jsx(e.Fragment,{children:e.jsxs(n.Stack,{gap:"md",p:"sm",children:[e.jsxs(n.Stack,{gap:4,align:"center",children:[e.jsx(n.Text,{size:"sm",fw:500,ta:"center",children:"Publish to the web"}),e.jsx(n.Text,{size:"sm",fw:500,color:"var(--mantine-color-gray-6)",ta:"center",children:"Anyone with the link can view this page"})]}),e.jsx(n.Button,{variant:"filled",size:"xs",radius:"md",fw:500,fz:"var(--mantine-font-size-sm)",ta:"center",children:"Publish"})]})}),W=e.jsx(n.Box,{style:{width:"400px",maxHeight:"600px",overflow:"visible"},children:e.jsx(n.Stack,{gap:"lg",children:e.jsxs(n.Tabs,{color:"black",defaultValue:"invite",styles:{tab:{backgroundColor:"transparent"}},children:[e.jsxs(n.Tabs.List,{px:"var(--mantine-spacing-sm)",pt:"xs",children:[e.jsx(n.Tabs.Tab,{value:"invite",p:0,pb:6,onClick:()=>{S("invite")},onMouseEnter:()=>T("invite"),onMouseLeave:()=>T(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{borderRadius:"var(--mantine-radius-md)",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",border:"none",backgroundColor:w==="invite"?"var(--mantine-color-gray-1)":"transparent",color:v==="invite"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:"Invite"})}),e.jsx(n.Tabs.Tab,{value:"publish",p:0,pb:6,onClick:()=>{S("publish")},onMouseEnter:()=>T("publish"),onMouseLeave:()=>T(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",borderRadius:"var(--mantine-radius-md)",border:"none",backgroundColor:w==="publish"?"var(--mantine-color-gray-1)":"transparent",color:v==="publish"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:"Publish"})})]}),e.jsx(n.Tabs.Panel,{value:"invite",children:e.jsx(n.Box,{p:"sm",children:H})}),e.jsx(n.Tabs.Panel,{value:"publish",children:e.jsx(n.Box,{p:"sm",children:$})})]})})});return e.jsx(ye,{trigger:c,menuItems:[],opened:t,onClose:r,styles:{dropdown:{padding:"0",borderRadius:"var(--mantine-radius-md)"}},children:W})},so=({onInvite:t,onUpdateRole:r,onRemoveUser:o,invitedUsers:s,currentUser:a,roleOptions:i,suggestedUsers:c,label:l="Share"})=>{const[d,f]=u.useState(!1),h=()=>f(!1),m=e.jsx(Oe,{label:l,onClick:()=>f(!0),isActive:d});return e.jsx(Cn,{opened:d,onClose:h,onInvite:t,onUpdateRole:r,onRemoveUser:o,invitedUsers:s,currentUser:a,roleOptions:i,suggestedUsers:c,children:m})},ao=({opened:t,onClose:r,onInvite:o,onUpdateRole:s,onRemoveUser:a,invitedUsers:i=[],roleOptions:c=[],suggestedUsers:l=[]})=>{const d=u.useRef(null),{emails:f,setEmails:h,selectedUsers:m,inputText:x,setInputText:y,tagDisplayMap:p,selectedRole:I,setSelectedRole:g,filteredUsers:b,handleInvite:v,handleUpdateRole:S,handleRemoveUser:w,handleToggleUser:T,handleAddSuggestedUser:k}=Sn({onInvite:o,onUpdateRole:s,onRemoveUser:a,invitedUsers:i,suggestedUsers:l,roleOptions:c}),C=j=>{k(j),d.current&&d.current.clearInput()};return e.jsx(n.Modal,{opened:t,onClose:r,size:"md",withCloseButton:!1,radius:"md",centered:!0,closeOnClickOutside:!1,closeOnEscape:!0,trapFocus:!1,zIndex:300,children:e.jsxs(n.Stack,{gap:"lg",children:[e.jsxs(n.Group,{justify:"space-between",wrap:"nowrap",children:[e.jsx(n.Text,{size:"md",fw:500,c:"var(--mantine-color-gray-8)",children:"Share"}),e.jsx(ee,{icon:M.IconX,size:"md",onClick:r,color:"var(--mantine-color-gray-8)"})]}),e.jsx(kn,{ref:d,value:f,onChange:h,onInvite:v,roleOptions:c,selectedRole:I,onRoleChange:g,onInputChange:y,suggestedUsers:l,tagDisplayMap:p}),i.length>0&&e.jsxs(n.Box,{children:[e.jsx(n.Text,{size:"sm",fw:500,children:"Already members"}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.Box,{style:{maxHeight:"200px",minHeight:"60px",overflowY:"auto",overflowX:"hidden",paddingRight:"8px",marginRight:"-8px"},children:e.jsx(n.Stack,{gap:"sm",children:i.map(j=>e.jsx(ve,{user:j,isSelected:m.includes(j.id),onToggle:T,onUpdateRole:S,onRemoveUser:w,roleOptions:c,variant:"invited"},j.id))})})]}),b.length>0&&e.jsxs(n.Box,{children:[e.jsxs(n.Text,{size:"sm",fw:500,children:["Suggested ",x.trim()&&`(filtered by "${x}")`]}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.Box,{style:{maxHeight:"200px",minHeight:"60px",overflowY:"auto",overflowX:"hidden",paddingRight:"8px",marginRight:"-8px"},children:e.jsx(n.Stack,{gap:"sm",children:b.map(j=>e.jsx(ve,{user:j,isSelected:m.includes(j.id),onToggle:T,onUpdateRole:S,onRemoveUser:w,roleOptions:c,variant:"suggested",onClick:()=>C(j)},j.id))})})]})]})})},io=({opened:t,onClose:r,options:o=[],onSave:s,onCancel:a,groups:i=[],styles:c})=>{const[l,d]=u.useState("");u.useEffect(()=>{t&&o.length>0?d(o[0].id):t||d("")},[t,o]);const f=()=>{s&&s(),r()},h=()=>{a&&a(),r()},m=()=>{r()},x=o.find(y=>y.id===l);return e.jsxs(n.Modal,{opened:t,onClose:m,size:"90%",centered:!0,closeOnClickOutside:!0,closeOnEscape:!0,withCloseButton:!1,p:"none",styles:{body:{...c==null?void 0:c.body,padding:0,height:"80vh"}},radius:"md",children:[e.jsx(n.FocusTrap.InitialFocus,{}),e.jsxs(n.Box,{style:{display:"flex",height:"100%",...c==null?void 0:c.body},children:[e.jsx(n.Box,{style:{width:"240px",backgroundColor:"var(--mantine-color-gray-0)"},children:e.jsx(n.ScrollArea,{h:"100%",children:e.jsx(n.Stack,{gap:0,p:"sm",children:i.map(y=>e.jsx(n.Box,{mb:"md",children:e.jsxs(u.Fragment,{children:[e.jsx(n.Text,{size:"xs",fw:600,c:"dimmed",m:4,children:y}),o.filter(p=>p.group===y).map(p=>e.jsx(Ye,{label:p.label,icon:p.icon,onClick:()=>d(p.id),isActive:l===p.id},p.id))]},y)}))})})}),e.jsxs(n.Box,{style:{flex:1,display:"flex",flexDirection:"column"},children:[x?e.jsxs(e.Fragment,{children:[e.jsx(n.Box,{p:"md",children:e.jsx(n.Group,{gap:"md",wrap:"nowrap",children:e.jsxs(n.Stack,{gap:4,children:[e.jsx(n.Text,{size:"md",fw:600,children:x.alternateLabel||x.label}),x.description&&e.jsx(n.Text,{size:"sm",c:"var(--mantine-color-gray-6)",children:x.description})]})})}),e.jsx(n.ScrollArea,{style:{flex:1},children:e.jsx(n.Box,{px:"md",children:x.content})})]}):e.jsx(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:e.jsx(n.Text,{c:"var(--mantine-color-gray-6)",size:"lg",children:"Select an option from the sidebar"})}),(x==null?void 0:x.saveButton)&&e.jsx(n.Box,{p:"md",children:e.jsxs(n.Group,{justify:"flex-end",gap:"md",children:[e.jsx(n.Button,{variant:"subtle",onClick:h,color:"gray",children:"Cancel"}),e.jsx(n.Button,{onClick:f,color:"blue",children:"Save Changes"})]})})]})]})]})},co=(t,r="es")=>{const o=new Date,s=typeof t=="string"?new Date(t):t,a=Math.floor((o.getTime()-s.getTime())/1e3),i={es:{now:"ahora",seconds:"segundos",second:"segundo",minutes:"minutos",minute:"minuto",hours:"horas",hour:"hora",days:"días",day:"día",weeks:"semanas",week:"semana",months:"meses",month:"mes",years:"años",year:"año",ago:"hace"},en:{now:"now",seconds:"seconds",second:"second",minutes:"minutes",minute:"minute",hours:"hours",hour:"hour",days:"days",day:"day",weeks:"weeks",week:"week",months:"months",month:"month",years:"years",year:"year",ago:"ago"}},c=i[r]||i.en;if(a<5)return c.now;if(a<60)return r==="es"?`${c.ago} ${a} ${a===1?c.second:c.seconds}`:`${a} ${a===1?c.second:c.seconds} ${c.ago}`;const l=Math.floor(a/60);if(l<60)return r==="es"?`${c.ago} ${l} ${l===1?c.minute:c.minutes}`:`${l} ${l===1?c.minute:c.minutes} ${c.ago}`;const d=Math.floor(l/60);if(d<24)return r==="es"?`${c.ago} ${d} ${d===1?c.hour:c.hours}`:`${d} ${d===1?c.hour:c.hours} ${c.ago}`;const f=Math.floor(d/24);if(f<7)return r==="es"?`${c.ago} ${f} ${f===1?c.day:c.days}`:`${f} ${f===1?c.day:c.days} ${c.ago}`;const h=Math.floor(f/7);if(h<4)return r==="es"?`${c.ago} ${h} ${h===1?c.week:c.weeks}`:`${h} ${h===1?c.week:c.weeks} ${c.ago}`;const m=Math.floor(f/30);if(m<12)return r==="es"?`${c.ago} ${m} ${m===1?c.month:c.months}`:`${m} ${m===1?c.month:c.months} ${c.ago}`;const x=Math.floor(f/365);return r==="es"?`${c.ago} ${x} ${x===1?c.year:c.years}`:`${x} ${x===1?c.year:c.years} ${c.ago}`},lo=(t,r="es")=>{const o=typeof t=="string"?new Date(t):t,s={es:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],en:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},i=(s[r]||s.en)[o.getMonth()],c=o.getDate();return r==="es"?`${c} ${i}`:`${i} ${c}`},uo=t=>{const r=typeof t=="string"?new Date(t):t,o=new Date;return r.toDateString()===o.toDateString()},fo=t=>{const r=typeof t=="string"?new Date(t):t,o=new Date;return o.setDate(o.getDate()-1),r.toDateString()===o.toDateString()},ho=(t,r="es")=>uo(t)?r==="es"?"Hoy":"Today":fo(t)?r==="es"?"Ayer":"Yesterday":co(t,r),xo=({notification:t,message:r,markAsRead:o,archiveNotification:s,children:a,actions:i})=>{var h,m,x,y,p;const c=new Date().getTime()-new Date(t.timestamp).getTime()<6048e5?ho(t.timestamp,"en"):lo(t.timestamp,"en"),[l,d]=u.useState(!1),f=e.jsxs(n.Group,{bg:"var(--mantine-color-gray-1)",p:4,style:{borderRadius:"var(--mantine-radius-md)"},w:"auto",wrap:"nowrap",gap:0,children:[!t.isRead&&e.jsx(ee,{onClick:()=>o(t.id),icon:M.IconCheck}),!t.isArchived&&e.jsx(ee,{onClick:()=>s(t.id),icon:M.IconArchive})]});return e.jsxs(n.Box,{p:"sm",bg:l?"var(--mantine-color-gray-0)":"white",style:{cursor:"pointer",borderTop:"1px solid var(--mantine-color-gray-2)"},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[e.jsxs(n.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",style:{margin:0},children:[(h=t.metadata)!=null&&h.avatar_url?e.jsx(n.Avatar,{name:(m=t.metadata)==null?void 0:m.fullname,size:"sm",radius:"md",src:(x=t.metadata)==null?void 0:x.avatar_url}):e.jsx(dn,{size:"xs",showText:!1,radius:"xs"}),e.jsxs(n.Stack,{gap:"xs",justify:"flex-start",w:"100%",children:[e.jsx(n.Box,{fz:"sm",m:0,style:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden",textOverflow:"ellipsis",minHeight:"unset",height:"auto",whiteSpace:"normal",wordBreak:"break-word"},children:r}),e.jsxs(n.Text,{size:"xs",c:"dimmed",fw:500,style:{whiteSpace:"nowrap"},children:[t.category?((y=t.category)==null?void 0:y.charAt(0).toUpperCase())+((p=t.category)==null?void 0:p.slice(1)):""," ","• ",c]})]}),l?f:!t.isRead&&e.jsx(n.Indicator,{color:"var(--mantine-color-blue-6)",size:10,position:"top-end"})]}),a,i&&e.jsx(n.Group,{justify:"flex-start",align:"flex-start",gap:"xs",wrap:"nowrap",pl:36,pt:8,children:i})]})},po=(t,r,o,s,a)=>{const[i,c]=u.useState(!1),l=u.useRef(null),d=u.useRef(null),f=u.useRef(null);u.useEffect(()=>{c(t)},[t]);const h=u.useCallback(x=>{x[0].isIntersecting&&s&&!a&&o&&o()},[s,a,o]),m=u.useCallback(()=>{if(!(!l.current||!t||!r||!o)){d.current&&(d.current.disconnect(),d.current=null);try{const x=new IntersectionObserver(h,{threshold:.1,rootMargin:"50px"});x.observe(l.current),d.current=x}catch(x){console.error("Failed to setup intersection observer:",x)}}},[t,r,o,h]);return u.useEffect(()=>{if(f.current&&(clearTimeout(f.current),f.current=null),!t||!r||!o){d.current&&(d.current.disconnect(),d.current=null);return}if(!l.current){f.current=setTimeout(()=>m(),50);return}return m(),()=>{f.current&&(clearTimeout(f.current),f.current=null),d.current&&(d.current.disconnect(),d.current=null)}},[t,r,o,m]),u.useEffect(()=>()=>{f.current&&clearTimeout(f.current),d.current&&d.current.disconnect()},[]),{isActive:i,loadMoreRef:l}},mo=({notifications:t,isLoading:r=!1,isLoadingMore:o=!1,hasMore:s=!1,unreadCount:a=0,markAllAsRead:i,archiveAllNotifications:c,markAsRead:l,archiveNotification:d,loadMore:f,onFilterChange:h,currentFilter:m="all",customRenderer:x,opened:y=!1,onOpen:p=()=>{},onClose:I=()=>{},enableInfiniteScroll:g=!0})=>{const b=[{children:"Mark all as read",leftSection:e.jsx(M.IconChecklist,{size:16}),onClick:()=>i()},{children:"Archive all",leftSection:e.jsx(M.IconArchive,{size:16}),onClick:()=>c()}],v=[{children:"All",leftSection:e.jsx(M.IconChecklist,{size:16}),onClick:()=>h==null?void 0:h("all"),active:m==="all"},{children:"Unread",leftSection:e.jsx(M.IconChecklist,{size:16}),onClick:()=>h==null?void 0:h("unread"),active:m==="unread"},{children:"Archived",leftSection:e.jsx(M.IconArchive,{size:16}),onClick:()=>h==null?void 0:h("archived"),active:m==="archived"}],S=k=>x&&k.category&&["welcome","upgrade"].includes(k.category)?x(k,l,d):e.jsx(xo,{notification:k,markAsRead:l,archiveNotification:d,message:k.message,actions:k.actions},k.id),{isActive:w,loadMoreRef:T}=po(y,g,f||(()=>{}),s,o);return e.jsxs(e.Fragment,{children:[e.jsx(Ye,{isActive:w,icon:e.jsx(M.IconBell,{strokeWidth:2,size:20,color:"var(--mantine-color-gray-7)"}),onClick:()=>{y?I():p()},disabled:!1,variant:"subtle",color:"gray",fullWidth:!0,style:{borderRadius:"var(--mantine-radius-md)",cursor:"pointer"},label:"Inbox",indicator:a>0?a>99?"99+":a:void 0}),e.jsxs(n.Drawer,{opened:y,onClose:I,position:"left",size:400,style:{position:"relative",left:300,zIndex:0,borderLeft:"1px solid var(--mantine-color-gray-2)"},withCloseButton:!1,padding:0,withOverlay:!0,closeOnClickOutside:!0,closeOnEscape:!0,overlayProps:{backgroundOpacity:0,blur:0},children:[e.jsx(n.FocusTrap.InitialFocus,{}),e.jsxs(n.Box,{p:0,h:"100%",style:{display:"flex",flexDirection:"column"},children:[e.jsx(n.Box,{style:{position:"sticky",top:0,zIndex:10,backgroundColor:"var(--mantine-color-white)"},children:e.jsxs(n.Group,{justify:"space-between",align:"center",gap:"xs",style:{borderRadius:"var(--mantine-radius-md)"},px:"sm",py:"md",children:[e.jsx(n.Text,{size:"sm",fw:500,children:"Inbox"}),e.jsxs(n.Group,{gap:"xs",children:[e.jsx(ye,{position:"bottom-end",menuItems:v,trigger:e.jsx(ee,{icon:M.IconFilter})}),e.jsx(ye,{position:"bottom-end",menuItems:b,trigger:e.jsx(ee,{onClick:()=>{},icon:M.IconDots,changeIconOnHover:!0,iconHovered:M.IconDots})})]})]})}),e.jsxs(n.Box,{style:{flex:1,overflow:"auto"},children:[r&&t.length===0?e.jsx(n.Stack,{gap:0,w:"100%",h:"100%",justify:"center",align:"center",py:"xl",children:e.jsx(n.Loader,{})}):t.length>0?e.jsx(n.Stack,{gap:0,children:t.map(k=>S(k))}):e.jsxs(n.Stack,{gap:0,w:"100%",h:"100%",justify:"center",align:"center",py:"xl",children:[e.jsx(M.IconInbox,{size:24,color:"var(--mantine-color-gray-6)"}),e.jsx(n.Text,{size:"sm",fw:500,c:"dimmed",ta:"center",mt:"sm",children:"No new updates"})]}),e.jsx(n.Box,{ref:T,style:{padding:"16px",display:g?"flex":"none",justifyContent:"center",alignItems:"center",minHeight:"60px"},children:o&&e.jsxs(n.Group,{display:"flex",ta:"center",gap:"xs",children:[e.jsx(n.Loader,{size:"sm",color:"gray.5"}),e.jsx(n.Text,{size:"sm",c:"dimmed",fw:500,children:"Loading more ..."})]})}),o&&!g&&e.jsxs(n.Group,{display:"flex",ta:"center",gap:"xs",children:[e.jsx(n.Loader,{size:"sm",color:"gray.5"}),e.jsx(n.Text,{size:"sm",c:"dimmed",fw:500,children:"Loading more ..."})]}),!g&&s&&f&&e.jsx(n.Button,{color:"var(--mantine-color-gray-3)",variant:"subtle",onClick:f,loading:o,disabled:o,style:{alignSelf:"center"},children:o?"Loading...":"Load More"})]})]})]})]})},Qe=({header:t,body:r,footer:o,withBorder:s=!0,position:a="left",bg:i="var(--mantine-color-gray-0)"})=>{const[c,l]=u.useState(!1),d=()=>{if(!s)return{};const f="var(--mantine-color-gray-3)",h="1px";return a==="left"?{borderRight:`${h} solid ${f}`}:a==="right"?{borderLeft:`${h} solid ${f}`}:{}};return e.jsxs(n.Stack,{gap:"sm",h:"100%",p:"sm",bg:i,style:d(),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t&&e.jsx(n.Box,{children:typeof t=="function"?t({hovered:c}):t}),r&&e.jsx(n.Box,{style:{flex:1,minHeight:0,width:"100%",overflow:"hidden"},children:typeof r=="function"?r({hovered:c}):r}),o&&e.jsx(n.Box,{children:typeof o=="function"?o({hovered:c}):o})]})},Mn=u.createContext(void 0),go=({children:t})=>{const[r,{open:o,close:s}]=Ie.useDisclosure(!1),a={openedNotificationSidebar:r,openNotificationSidebar:o,closeNotificationSidebar:s};return e.jsx(Mn.Provider,{value:a,children:t})},Io=()=>{const t=u.useContext(Mn);if(t===void 0)throw new Error("useNavbar must be used within an NavbarProvider");return t},Tn=({workspace:t,currentUserId:r,currentWorkspaceId:o,onClick:s})=>{const a=o===t.id,i=r&&t.ownerId===r;return e.jsxs(n.Box,{onClick:s,style:{display:"flex",alignItems:"center",padding:"6px",borderRadius:"var(--mantine-radius-md)",cursor:"pointer",gap:"8px",width:"100%",boxSizing:"border-box"},onMouseEnter:c=>{c.currentTarget.style.backgroundColor="var(--mantine-color-gray-0)"},onMouseLeave:c=>{c.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(se,{size:"xs",avatar:typeof t.avatar=="string"?{type:"image",value:t.avatar}:t.avatar,placeholder:t.name,showPlaceholder:!0,style:{flexShrink:0}}),e.jsx(n.Text,{size:"sm",fw:500,c:"gray.9",truncate:!0,style:{flex:1,minWidth:0},children:t.name}),e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"4px",flexShrink:0,paddingLeft:"8px"},children:[a&&e.jsx(M.IconCheck,{size:16,color:"var(--mantine-color-blue-6)"}),i&&e.jsx(n.Badge,{size:"xs",variant:"light",color:"yellow",radius:"sm",children:"Owner"})]})]})},yo="workspace-selector-module__menuItem___FSB6P",vo="workspace-selector-module__workspaceButton___-P6kp",jo="workspace-selector-module__workspaceText___YDAlj",bo="workspace-selector-module__scrollWrapper___MzrJY",Ve={menuItem:yo,workspaceButton:vo,workspaceText:jo,scrollWrapper:bo},wo=({workspaces:t=[],currentWorkspace:r,currentUserId:o,isLoading:s=!1,error:a=null,onWorkspaceSelect:i,onCreateWorkspace:c,emptyMessage:l="No workspaces found",loadingMessage:d="Loading workspaces...",errorMessage:f="Failed to load workspaces",className:h,onCloseSidebar:m,sidebarHovered:x=!1,children:y,menuItems:p})=>{const[I,g]=u.useState(!1),[b,v]=u.useState(""),S=u.useMemo(()=>b?t.filter(C=>{var j;return C.name.toLowerCase().includes(b.toLowerCase())||((j=C.ownerEmail)==null?void 0:j.toLowerCase().includes(b.toLowerCase()))}):t,[t,b]),w=C=>{i==null||i(C.id),g(!1),v("")};if(s)return e.jsxs(n.Group,{gap:"xs",children:[e.jsx(n.Loader,{size:"sm"}),e.jsx(n.Text,{size:"sm",c:"dimmed",children:d})]});if(a)return e.jsx(n.Alert,{color:"red",title:"Error",children:f});const[T,k]=u.useState(x);return t.length===0&&!s&&!a?e.jsx(n.Box,{children:e.jsx(n.Text,{size:"sm",c:"dimmed",children:l})}):e.jsxs(n.Menu,{opened:I,onOpen:()=>g(!0),onClose:()=>g(!1),position:"bottom-start",styles:{dropdown:{width:"350px",overflow:"hidden"}},withinPortal:!0,children:[e.jsx(n.Menu.Target,{children:e.jsx(n.Box,{w:"100%",onClick:()=>g(!I),style:{padding:"6px",display:"flex",alignItems:"center",borderRadius:"var(--mantine-radius-md)",cursor:"pointer"},className:`${Ve.workspaceButton} ${h||""}`,bg:T||I?"var(--mantine-color-gray-1)":"transparent",onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),children:e.jsx(n.Group,{gap:"xs",wrap:"nowrap",style:{width:"100%",overflow:"hidden"},children:r?e.jsxs(e.Fragment,{children:[e.jsx(se,{size:"xs",avatar:typeof r.avatar=="string"?{type:"image",value:r.avatar}:r.avatar,placeholder:r.name,showPlaceholder:!0,style:{flexShrink:0}}),e.jsx(n.Text,{size:"sm",fw:500,c:"gray.9",truncate:!0,style:{flex:1,minWidth:0},children:r.name}),e.jsxs(n.Group,{gap:4,wrap:"nowrap",style:{flexShrink:0},children:[e.jsx(fe,{icon:M.IconChevronDown,size:"md",onClick:()=>g(!I),grayScaleBaseColor:T?1:0}),(T||x)&&e.jsx(fe,{icon:M.IconChevronsLeft,size:"md",onClick:()=>{m==null||m()},grayScaleBaseColor:T?1:0})]})]}):e.jsx(n.Text,{size:"sm",c:"dimmed",children:"Select workspace"})})})}),e.jsx(n.Menu.Dropdown,{style:{borderRadius:"var(--mantine-radius-md)"},p:0,children:e.jsxs(n.Stack,{gap:0,children:[y,e.jsx(n.Menu.Divider,{style:{margin:"1px 0px"}}),e.jsx(n.Stack,{gap:0,px:4,children:S.length===0?e.jsx(n.Menu.Item,{disabled:!0,children:e.jsx(n.Text,{size:"sm",c:"dimmed",children:l})}):e.jsxs(e.Fragment,{children:[e.jsxs(n.Group,{justify:"space-between",align:"center",p:4,children:[e.jsx(n.Text,{size:"xs",c:"dimmed",fw:500,p:4,truncate:!0,children:"Workspaces"}),c&&e.jsx(n.Anchor,{onClick:()=>{c(),g(!1)},size:"xs",underline:"never",fw:500,p:4,truncate:!0,style:{display:"flex",alignItems:"center",gap:"4px"},children:"Add"})]}),e.jsx("div",{className:Ve.scrollWrapper,children:e.jsx(n.ScrollArea,{mah:150,scrollbarSize:6,scrollHideDelay:0,children:e.jsx(n.Stack,{gap:0,mb:6,children:S.map(C=>e.jsx(n.Box,{onClick:()=>w(C),className:Ve.menuItem,style:{padding:0,borderRadius:"var(--mantine-radius-md)",cursor:"pointer",overflow:"hidden"},onMouseEnter:j=>{j.currentTarget.style.backgroundColor="var(--mantine-color-gray-1)"},onMouseLeave:j=>{j.currentTarget.style.backgroundColor="transparent"},children:e.jsx(Tn,{workspace:C,currentUserId:o,currentWorkspaceId:r==null?void 0:r.id,onClick:()=>w(C)})},C.id))})})})]})}),p&&e.jsx(n.Menu.Divider,{style:{margin:"1px 0px"}}),p&&e.jsx(n.Box,{p:4,children:p==null?void 0:p.map(C=>e.jsx(n.MenuItem,{onClick:C.onClick,leftSection:C.icon,children:C.label,color:C.color,"data-danger":C.color,fw:500,style:{height:"40px",borderRadius:"var(--mantine-radius-md)",padding:"6px"}},C.label))})]})})]})},Bn=({children:t,style:r,...o})=>e.jsx(n.Box,{style:{backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",minHeight:"20vh",width:"100%",flex:"1 1 0%",minWidth:0,maxWidth:"none",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",...r},...o,children:t});Bn.displayName="MatrixCenter";const On=({children:t,style:r,size:o="50px",state:s="empty",onStateChange:a,interactive:i=!0,...c})=>{const[l,d]=u.useState(s),[f,h]=u.useState(!1),m=a?s:i?l:s,x=()=>{if(!i)return;const I=["empty","outline","filled"],b=(I.indexOf(m)+1)%I.length,v=I[b];a?a(v):d(v)},y=()=>{switch(m){case"empty":return null;case"outline":return e.jsx(M.IconPoint,{size:16,color:"var(--mantine-color-gray-8)",stroke:2.5});case"filled":return e.jsx(M.IconPointFilled,{size:16,color:"var(--mantine-color-gray-8)",stroke:2.5});default:return null}},p=()=>{switch(m){case"empty":return"var(--mantine-color-gray-2)";case"outline":return"var(--mantine-color-blue-0)";case"filled":return"var(--mantine-color-green-0)";default:return"var(--mantine-color-gray-2)"}};return e.jsx(n.Box,{style:{width:o,height:o,backgroundColor:p(),borderRadius:"var(--mantine-radius-md)",display:"flex",alignItems:"center",justifyContent:"center",cursor:i?"pointer":"default",transition:"all 0.2s ease",boxShadow:f&&i?"0 2px 8px rgba(0, 0, 0, 0.15)":"none",transform:f&&i?"translateY(-1px)":"translateY(0)",border:m==="outline"?"2px solid var(--mantine-color-gray-0)":"2px solid transparent",...r},onClick:x,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),...c,children:t||y()})};On.displayName="MatrixCell";const zn=({children:t,style:r,size:o="50px",blockId:s,isVisible:a=!0,isDimmed:i=!1,shouldShowBlueBorder:c=!1,onBlockClick:l,onBlockPress:d,...f})=>{const[h,m]=u.useState(!1),x=u.useRef(null),y=u.useRef(!1),p=()=>{!s||!d||(m(!0),y.current=!1,x.current=setTimeout(()=>{y.current=!0,d(s)},500))},I=()=>{s&&(m(!1),x.current&&(clearTimeout(x.current),x.current=null),!y.current&&l&&l(s),y.current=!1)},g=()=>{m(!1),x.current&&(clearTimeout(x.current),x.current=null),y.current=!1};return e.jsx(n.Box,{style:{width:o,height:"100%",minWidth:o,minHeight:o,backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",overflow:"hidden",display:"flex",alignItems:"stretch",justifyContent:"stretch",border:c?"2px solid var(--mantine-color-blue-5)":"2px solid transparent",opacity:h?.8:i?.3:1,transition:"all 0.2s ease",cursor:s?"pointer":"default",...r},onMouseDown:p,onMouseUp:I,onMouseLeave:g,...f,children:t})};zn.displayName="MatrixBlockLeft";const Rn=({children:t,style:r,size:o="50px",blockId:s,isVisible:a=!0,isDimmed:i=!1,shouldShowBlueBorder:c=!1,onBlockClick:l,onBlockPress:d,...f})=>{const[h,m]=u.useState(!1),x=u.useRef(null),y=u.useRef(!1),p=()=>{!s||!d||(m(!0),y.current=!1,x.current=setTimeout(()=>{y.current=!0,d(s)},500))},I=()=>{s&&(m(!1),x.current&&(clearTimeout(x.current),x.current=null),!y.current&&l&&l(s),y.current=!1)},g=()=>{m(!1),x.current&&(clearTimeout(x.current),x.current=null),y.current=!1};return e.jsx(n.Box,{style:{width:o,height:"100%",minWidth:o,minHeight:o,backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",overflow:"hidden",display:"flex",alignItems:"stretch",justifyContent:"stretch",border:c?"2px solid var(--mantine-color-blue-5)":"2px solid transparent",opacity:h?.8:i?.3:1,transition:"all 0.2s ease",cursor:s?"pointer":"default",...r},onMouseDown:p,onMouseUp:I,onMouseLeave:g,...f,children:t})};Rn.displayName="MatrixBlockRight";const Dn=({children:t,style:r,size:o="50px",blockId:s,isVisible:a=!0,isDimmed:i=!1,shouldShowBlueBorder:c=!1,onBlockClick:l,onBlockPress:d,...f})=>{const[h,m]=u.useState(!1),x=u.useRef(null),y=u.useRef(!1),p=()=>{!s||!d||(m(!0),y.current=!1,x.current=setTimeout(()=>{y.current=!0,d(s)},500))},I=()=>{s&&(m(!1),x.current&&(clearTimeout(x.current),x.current=null),!y.current&&l&&l(s),y.current=!1)},g=()=>{m(!1),x.current&&(clearTimeout(x.current),x.current=null),y.current=!1};return e.jsx(n.Box,{style:{width:"100%",height:o,minWidth:o,minHeight:o,backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",overflow:"hidden",display:"flex",alignItems:"stretch",justifyContent:"stretch",border:c?"2px solid var(--mantine-color-blue-5)":"2px solid transparent",opacity:h?.8:i?.3:1,transition:"all 0.2s ease",cursor:s?"pointer":"default",...r},onMouseDown:p,onMouseUp:I,onMouseLeave:g,...f,children:t})};Dn.displayName="MatrixBlockUp";const En=({children:t,style:r,size:o="50px",blockId:s,isVisible:a=!0,isDimmed:i=!1,shouldShowBlueBorder:c=!1,onBlockClick:l,onBlockPress:d,...f})=>{const[h,m]=u.useState(!1),x=u.useRef(null),y=u.useRef(!1),p=()=>{!s||!d||(m(!0),y.current=!1,x.current=setTimeout(()=>{y.current=!0,d(s)},500))},I=()=>{s&&(m(!1),x.current&&(clearTimeout(x.current),x.current=null),!y.current&&l&&l(s),y.current=!1)},g=()=>{m(!1),x.current&&(clearTimeout(x.current),x.current=null),y.current=!1};return e.jsx(n.Box,{style:{width:"100%",height:o,minWidth:o,minHeight:o,backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",overflow:"hidden",display:"flex",alignItems:"stretch",justifyContent:"stretch",border:c?"2px solid var(--mantine-color-blue-5)":"2px solid transparent",opacity:h?.8:i?.3:1,transition:"all 0.2s ease",cursor:s?"pointer":"default",...r},onMouseDown:p,onMouseUp:I,onMouseLeave:g,...f,children:t})};En.displayName="MatrixBlockDown";const An=({onLeftHover:t,onRightHover:r,onUpHover:o,onDownHover:s,showLeftControls:a=!1,showRightControls:i=!1,showUpControls:c=!1,showDownControls:l=!1})=>{const[d,f]=u.useState(!1),[h,m]=u.useState(!1),[x,y]=u.useState(!1),[p,I]=u.useState(!1),g=w=>{f(w),t==null||t(w)},b=w=>{m(w),r==null||r(w)},v=w=>{y(w),o==null||o(w)},S=w=>{I(w),s==null||s(w)};return e.jsxs(e.Fragment,{children:[a&&e.jsx(n.Box,{style:{position:"absolute",left:0,top:0,bottom:0,width:"80px",zIndex:5,pointerEvents:"auto",background:"transparent"},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1)}),i&&e.jsx(n.Box,{style:{position:"absolute",right:0,top:0,bottom:0,width:"80px",zIndex:5,pointerEvents:"auto",background:"transparent"},onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1)}),c&&e.jsx(n.Box,{style:{position:"absolute",top:0,left:0,right:0,height:"80px",zIndex:5,pointerEvents:"auto",background:"transparent"},onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1)}),l&&e.jsx(n.Box,{style:{position:"absolute",bottom:0,left:0,right:0,height:"80px",zIndex:5,pointerEvents:"auto",background:"transparent"},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1)})]})};An.displayName="HoverZones";const Ln=({onLeftPrevious:t,onLeftNext:r,leftCurrentPage:o=1,leftTotalPages:s=1,leftDisabled:a=!1,leftVisible:i=!1,onLeftHover:c,onRightPrevious:l,onRightNext:d,rightCurrentPage:f=1,rightTotalPages:h=1,rightDisabled:m=!1,rightVisible:x=!1,onRightHover:y,onUpPrevious:p,onUpNext:I,upCurrentPage:g=1,upTotalPages:b=1,upDisabled:v=!1,upVisible:S=!1,onUpHover:w,onDownPrevious:T,onDownNext:k,downCurrentPage:C=1,downTotalPages:j=1,downDisabled:R=!1,downVisible:D=!1,onDownHover:O,onLeftAdd:E,onRightAdd:H,onUpAdd:$,onDownAdd:W,size:L="md",inline:F=!1})=>{const U=()=>s<=1||a?null:e.jsxs(n.Stack,{gap:"xs",align:"center",children:[e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:()=>t==null?void 0:t(),disabled:o<=1,color:"gray",radius:"md","aria-label":"Previous left blocks",children:e.jsx(M.IconChevronRight,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:E,color:"blue",radius:"md","aria-label":"Add left blocks",children:e.jsx(M.IconPlus,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:r,disabled:o>=s,color:"gray",radius:"md","aria-label":"Next left blocks",children:e.jsx(M.IconChevronLeft,{size:16,stroke:2})})]}),Z=()=>h<=1||m?null:e.jsxs(n.Stack,{gap:"xs",align:"center",children:[e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:l,disabled:f<=1,color:"gray",radius:"md","aria-label":"Previous right blocks",children:e.jsx(M.IconChevronLeft,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:H,color:"blue",radius:"md","aria-label":"Add right blocks",children:e.jsx(M.IconPlus,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:d,disabled:f>=h,color:"gray",radius:"md","aria-label":"Next right blocks",children:e.jsx(M.IconChevronRight,{size:16,stroke:2})})]}),_=()=>b<=1||v?null:e.jsxs(n.Group,{gap:"xs",align:"center",wrap:"nowrap",children:[e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:p,disabled:g<=1,color:"gray",radius:"md","aria-label":"Previous up blocks",children:e.jsx(M.IconChevronDown,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:$,color:"blue",radius:"md","aria-label":"Add up blocks",children:e.jsx(M.IconPlus,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:I,disabled:g>=b,color:"gray",radius:"md","aria-label":"Next up blocks",children:e.jsx(M.IconChevronUp,{size:16,stroke:2})})]}),G=()=>j<=1||R?null:e.jsxs(n.Group,{gap:"xs",align:"center",wrap:"nowrap",children:[e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:T,disabled:C<=1,color:"gray",radius:"md","aria-label":"Previous down blocks",children:e.jsx(M.IconChevronDown,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:W,color:"blue",radius:"md","aria-label":"Add down blocks",children:e.jsx(M.IconPlus,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:k,disabled:C>=j,color:"gray",radius:"md","aria-label":"Next down blocks",children:e.jsx(M.IconChevronUp,{size:16,stroke:2})})]}),B=s>1&&!a,z=h>1&&!m,A=b>1&&!v,N=j>1&&!R;return!B&&!z&&!A&&!N?null:F?e.jsxs(e.Fragment,{children:[B&&i&&t&&r&&e.jsx("div",{onMouseEnter:()=>c==null?void 0:c(!0),onMouseLeave:()=>c==null?void 0:c(!1),children:U()}),z&&x&&l&&d&&e.jsx("div",{onMouseEnter:()=>y==null?void 0:y(!0),onMouseLeave:()=>y==null?void 0:y(!1),children:Z()}),A&&S&&p&&I&&e.jsx("div",{onMouseEnter:()=>w==null?void 0:w(!0),onMouseLeave:()=>w==null?void 0:w(!1),children:_()}),N&&D&&T&&k&&e.jsx("div",{onMouseEnter:()=>O==null?void 0:O(!0),onMouseLeave:()=>O==null?void 0:O(!1),children:G()})]}):e.jsxs(e.Fragment,{children:[B&&i&&t&&r&&e.jsx(n.Box,{style:{position:"absolute",left:"20px",top:"50%",transform:"translateY(-50%)",zIndex:10,pointerEvents:"auto",opacity:i?1:0,transition:"opacity 0.2s ease"},onMouseEnter:()=>c==null?void 0:c(!0),onMouseLeave:()=>c==null?void 0:c(!1),children:U()}),z&&x&&l&&d&&e.jsx(n.Box,{style:{position:"absolute",right:"20px",top:"50%",transform:"translateY(-50%)",zIndex:10,pointerEvents:"auto",opacity:x?1:0,transition:"opacity 0.2s ease"},onMouseEnter:()=>y==null?void 0:y(!0),onMouseLeave:()=>y==null?void 0:y(!1),children:Z()}),A&&S&&p&&I&&e.jsx(n.Box,{style:{position:"absolute",top:"20px",left:"50%",transform:"translateX(-50%)",zIndex:10,pointerEvents:"auto",opacity:S?1:0,transition:"opacity 0.2s ease"},onMouseEnter:()=>w==null?void 0:w(!0),onMouseLeave:()=>w==null?void 0:w(!1),children:_()}),e.jsx(n.Box,{style:{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)",zIndex:10,pointerEvents:"auto",opacity:D?1:0,transition:"opacity 0.2s ease"},onMouseEnter:()=>O==null?void 0:O(!0),onMouseLeave:()=>O==null?void 0:O(!1),children:N&&D&&T&&k&&G()})]})};Ln.displayName="NavigationControls";const Ce=({direction:t,text:r,show:o,actions:s,currentPage:a,totalPages:i,disabled:c,hoverState:l,onHover:d})=>{if(!r)return null;const f={left:{position:"absolute",left:"20px",top:"50%",transform:"translateY(-50%)"},right:{position:"absolute",right:"20px",top:"50%",transform:"translateY(-50%)"},up:{position:"absolute",top:"20px",left:"50%",transform:"translateX(-50%)"},down:{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)"}},h={left:{onLeftPrevious:s.prev,onLeftNext:s.next,leftCurrentPage:a,leftTotalPages:i,leftDisabled:c,leftVisible:!0},right:{onRightPrevious:s.prev,onRightNext:s.next,rightCurrentPage:a,rightTotalPages:i,rightDisabled:c,rightVisible:!0},up:{onUpPrevious:s.prev,onUpNext:s.next,upCurrentPage:a,upTotalPages:i,upDisabled:c,upVisible:!0},down:{onDownPrevious:s.prev,onDownNext:s.next,downCurrentPage:a,downTotalPages:i,downDisabled:c,downVisible:!0}};return e.jsxs("div",{style:{...f[t],zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",width:"80px",height:"60px"},children:[e.jsx("div",{style:{color:"var(--mantine-color-gray-6)",fontSize:"14px",fontWeight:"500",opacity:l?0:1,transition:"opacity 0.2s ease",position:"absolute"},children:r}),o&&e.jsx("div",{style:{opacity:l?1:0,transition:"opacity 0.2s ease",position:"absolute"},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:e.jsx(Ln,{...h[t],size:"sm",showLabels:!0,inline:!0})})]})},So=t=>{const{totalBlocksLeft:r=0,totalBlocksRight:o=0,totalBlocksUp:s=0,totalBlocksDown:a=0,visibleBlocksLeft:i=1,visibleBlocksRight:c=1,visibleBlocksUp:l=1,visibleBlocksDown:d=1}=t,f=u.useMemo(()=>{const p=Math.max(1,Math.ceil(r/i)),I=Math.max(1,Math.ceil(o/c)),g=Math.max(1,Math.ceil(s/l)),b=Math.max(1,Math.ceil(a/d));return{leftTotalPages:p,rightTotalPages:I,upTotalPages:g,downTotalPages:b,leftStartIndex:0,leftEndIndex:0,rightStartIndex:0,rightEndIndex:0,upStartIndex:0,upEndIndex:0,downStartIndex:0,downEndIndex:0}},[r,o,s,a,i,c,l,d]),[h,m]=u.useState({leftStartIndex:0,rightStartIndex:0,upStartIndex:0,downStartIndex:0}),x=u.useMemo(()=>{const{leftTotalPages:p,rightTotalPages:I,upTotalPages:g,downTotalPages:b}=f,v=Math.min(h.leftStartIndex,Math.max(0,r-i)),S=Math.min(v+i,r),w=Math.min(h.rightStartIndex,Math.max(0,o-c)),T=Math.min(w+c,o),k=Math.min(h.upStartIndex,Math.max(0,s-l)),C=Math.min(k+l,s),j=Math.min(h.downStartIndex,Math.max(0,a-d)),R=Math.min(j+d,a);return{leftTotalPages:p,rightTotalPages:I,upTotalPages:g,downTotalPages:b,leftStartIndex:v,leftEndIndex:S,rightStartIndex:w,rightEndIndex:T,upStartIndex:k,upEndIndex:C,downStartIndex:j,downEndIndex:R}},[h,f,i,c,l,d,r,o,s,a]),y={goToLeftPage:u.useCallback(p=>{const I=Math.max(0,(p-1)*i);m(g=>({...g,leftStartIndex:Math.min(I,Math.max(0,r-i))}))},[i,r]),goToRightPage:u.useCallback(p=>{const I=Math.max(0,(p-1)*c);m(g=>({...g,rightStartIndex:Math.min(I,Math.max(0,o-c))}))},[c,o]),goToUpPage:u.useCallback(p=>{const I=Math.max(0,(p-1)*l);m(g=>({...g,upStartIndex:Math.min(I,Math.max(0,s-l))}))},[l,s]),goToDownPage:u.useCallback(p=>{const I=Math.max(0,(p-1)*d);m(g=>({...g,downStartIndex:Math.min(I,Math.max(0,a-d))}))},[d,a]),nextLeftPage:u.useCallback(()=>{m(p=>({...p,leftStartIndex:Math.min(p.leftStartIndex+1,Math.max(0,r-i))}))},[r,i]),previousLeftPage:u.useCallback(()=>{m(p=>({...p,leftStartIndex:Math.max(p.leftStartIndex-1,0)}))},[]),nextRightPage:u.useCallback(()=>{m(p=>({...p,rightStartIndex:Math.min(p.rightStartIndex+1,Math.max(0,o-c))}))},[o,c]),previousRightPage:u.useCallback(()=>{m(p=>({...p,rightStartIndex:Math.max(p.rightStartIndex-1,0)}))},[]),nextUpPage:u.useCallback(()=>{m(p=>({...p,upStartIndex:Math.min(p.upStartIndex+1,Math.max(0,s-l))}))},[s,l]),previousUpPage:u.useCallback(()=>{m(p=>({...p,upStartIndex:Math.max(p.upStartIndex-1,0)}))},[]),nextDownPage:u.useCallback(()=>{m(p=>({...p,downStartIndex:Math.min(p.downStartIndex+1,Math.max(0,a-d))}))},[a,d]),previousDownPage:u.useCallback(()=>{m(p=>({...p,downStartIndex:Math.max(p.downStartIndex-1,0)}))},[])};return[h,y,x]},ko=(t,r=0,o=0,s=0,a=0)=>{const[i,c]=u.useState({width:typeof window<"u"?window.innerWidth:1920,height:typeof window<"u"?window.innerHeight:1080});return u.useEffect(()=>{if(typeof window>"u")return;const d=()=>{c({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[]),u.useMemo(()=>{const{gap:d,cellSize:f,minBlocksPerSide:h=2,maxBlocksPerSide:m=15,minBlocksLeft:x=1,maxBlocksLeft:y=8,minBlocksRight:p=1,maxBlocksRight:I=8,minBlocksUp:g=1,maxBlocksUp:b=8,minBlocksDown:v=1,maxBlocksDown:S=8,responsiveCellSize:w=!1,minCellSize:T="30px",maxCellSize:k="80px"}=t,C=parseFloat(d.replace("px","")),j=parseFloat(f.replace("px","")),R=i.width-C*4,D=i.height-C*4,O=j+C,E=Math.floor(R/(2*O)),H=j+C,$=Math.floor(D/H)+2,W=Math.min(E,$),L=Math.max(h,Math.min(m,W)),F=Math.max(x,Math.min(y,Math.floor(W/2))),U=Math.max(p,Math.min(I,Math.floor(W/2)));let Z=f;if(w){const A=parseFloat(T.replace("px","")),N=parseFloat(k.replace("px","")),V=Math.min(R/(i.width*.8),D/(i.height*.8));Z=`${Math.max(A,Math.min(N,j*V))}px`}const _=Math.min(i.width/1920,i.height/1080);let G,B;if(s>0&&a>0){const A=Math.max(s,a);G=Math.max(g,Math.min(b,A)),B=G}else{const A=Math.max(g,v),N=Math.min(b,S),V=Math.max(A,Math.min(N,Math.ceil(A+(N-A)*_)));G=V,B=V}if(G+B+1>$){const A=Math.max(2,$-1);if(Math.max(g,v)*2>A){const V=Math.max(1,Math.floor(A/2));G=V,B=V}else{const V=Math.max(g,v);G=V,B=V}}return console.log("Responsive Matrix Debug:",{windowSize:i,screenSizeRatio:_,minBlocksUp:g,minBlocksDown:v,maxBlocksUp:b,maxBlocksDown:S,blocksUp:s,blocksDown:a,calculatedBlocksUp:G,calculatedBlocksDown:B,totalVerticalBlocks:G+B+1,isSymmetric:G===B,availableHeight:D,maxBlocksVertical:$}),{blocksPerSide:L,blocksLeft:F,blocksRight:U,cellSize:Z,blocksUp:G,blocksDown:B}},[i,t,r,o,s,a])},Co=({gap:t,cellSize:r,blocksLeft:o,blocksRight:s,blocksUp:a,blocksDown:i,totalBlocksLeft:c,totalBlocksRight:l,totalBlocksUp:d,totalBlocksDown:f,responsive:h,minBlocksPerSide:m,maxBlocksPerSide:x,minBlocksLeft:y,maxBlocksLeft:p,minBlocksRight:I,maxBlocksRight:g,minBlocksUp:b,maxBlocksUp:v,minBlocksDown:S,maxBlocksDown:w,responsiveCellSize:T,minCellSize:k,maxCellSize:C})=>{const j=u.useMemo(()=>c!==void 0||l!==void 0||d!==void 0||f!==void 0,[c,l,d,f]),R=ko({gap:t,cellSize:r,minBlocksPerSide:m,maxBlocksPerSide:x,minBlocksLeft:y,maxBlocksLeft:p,minBlocksRight:I,maxBlocksRight:g,minBlocksUp:b,maxBlocksUp:v,minBlocksDown:S,maxBlocksDown:w,responsiveCellSize:T,minCellSize:k,maxCellSize:C},o??0,s??0,a,i),D=u.useMemo(()=>{let $=h?R.blocksLeft:o??0,W=h?R.blocksRight:s??0,L=h?R.blocksUp:a??0,F=h?R.blocksDown:i??0;if(!h){const U=parseFloat(t.replace("px","")),Z=parseFloat(r.replace("px","")),_=typeof window<"u"?window.innerWidth-U*4:1920,G=typeof window<"u"?window.innerHeight-U*4:1080,B=Z+U,z=Math.floor(_/(2*B)),A=Math.floor(G/(2*B));$=Math.min($,z),W=Math.min(W,z),L=Math.min(L,A),F=Math.min(F,A)}return{left:$,right:W,up:L,down:F}},[h,R,o,s,a,i,t,r]),O=u.useMemo(()=>{const $=j&&c?Math.min(D.left,c):D.left,W=j&&l?Math.min(D.right,l):D.right,L=j&&d?Math.min(D.up,d):D.up,F=j&&f?Math.min(D.down,f):D.down;return{left:$,right:W,up:L,down:F}},[j,D,c,l,d,f]),E=h?R.cellSize:r,H=u.useMemo(()=>{const $=(O.left>0?O.left:0)+1+(O.right>0?O.right:0),W=O.up>0||O.down>0?O.up+1+O.down:1,L=`${E} `.repeat(O.left)+"1fr "+`${E} `.repeat(O.right),F=O.up>0||O.down>0?`${E} `.repeat(O.up)+"1fr "+`${E} `.repeat(O.down):"1fr";return{totalColumns:$,totalRows:W,gridTemplateColumns:L.trim(),gridTemplateRows:F.trim()}},[O,E]);return{usePagination:j,visibleBlocks:D,finalBlocks:O,finalCellSize:E,gridDimensions:H}},Mo=({blockItems:t})=>{const r=u.useMemo(()=>t.reduce((a,i)=>(a[i.id]=i,a),{}),[t]);return{getBlockContent:(a,i)=>{const c=`${a}-${i}`,l=r[c];return l?l.content:u.createElement("div",{style:{padding:"4px",textAlign:"center",fontSize:"10px",writingMode:a==="left"||a==="right"?"vertical-rl":"horizontal-tb",textOrientation:"mixed",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"}})},getIntersectionText:(a,i,c,l)=>{const d=[];if(a!==null){const f=r[`left-${a}`];d.push(f?`left-${a}`:`left${a+1}`)}if(i!==null){const f=r[`right-${i}`];d.push(f?`right-${i}`:`right${i+1}`)}if(c!==null){const f=r[`up-${c}`];d.push(f?`up-${c}`:`up${c+1}`)}if(l!==null){const f=r[`down-${l}`];d.push(f?`down-${l}`:`down${l+1}`)}return d.join(", ")}}},To=({blockConnections:t})=>{const r=u.useMemo(()=>{const s=new Map;return t.forEach(a=>{const i=`${a.source}-${a.target}`,c=`${a.target}-${a.source}`;s.set(i,a),s.set(c,a)}),s},[t]);return{getConnectionStateFromText:s=>{const a=s.split(", ").map(i=>i.trim());for(let i=0;i<a.length;i++)for(let c=i+1;c<a.length;c++){const l=a[i],d=a[c],f=`${l}-${d}`,h=r.get(f);if(h)return h.type}return"empty"}}},Bo=({usePagination:t,totalBlocksLeft:r,totalBlocksRight:o,totalBlocksUp:s,totalBlocksDown:a,paginationActions:i,paginationState:c,paginationInfo:l})=>{const[d,f]=u.useState({left:!1,right:!1,up:!1,down:!1}),h=(x,y)=>{f(p=>({...p,[x]:y}))};return{hoverStates:d,handleHover:h,getNavigationControlProps:x=>{const y={left:r,right:o,up:s,down:a}[x],p={left:{prev:i.previousLeftPage,next:i.nextLeftPage},right:{prev:i.previousRightPage,next:i.nextRightPage},up:{prev:i.previousUpPage,next:i.nextUpPage},down:{prev:i.previousDownPage,next:i.nextDownPage}}[x],I={left:c.leftStartIndex,right:c.rightStartIndex,up:c.upStartIndex,down:c.downStartIndex}[x],g={left:l.leftTotalPages,right:l.rightTotalPages,up:l.upTotalPages,down:l.downTotalPages}[x];return{show:t&&!!y,totalBlocks:y,actions:p,currentPage:I+1,totalPages:g,disabled:!y,hoverState:d[x],onHover:b=>h(x,b)}}}},Oo=({blockItems:t,blockConnections:r})=>{const[o,s]=u.useState(null),[a,i]=u.useState(!1),c=u.useMemo(()=>{const I=new Map;return r.forEach(g=>{const b=`${g.source}-${g.target}`,v=`${g.target}-${g.source}`;I.set(b,g),I.set(v,g)}),I},[r]),l=u.useCallback(I=>{const g=[];return t.forEach(b=>{if(b.id!==I){const v=`${I}-${b.id}`;c.has(v)&&g.push(b.id)}}),g},[t,c]),d=u.useCallback(I=>{const g=t.find(S=>S.id===I);if(!g)return[];const b=l(I),v=[I];switch(g.type){case"up":b.forEach(S=>{const w=t.find(T=>T.id===S);w&&(w.type==="left"||w.type==="right")&&(v.push(S),l(S).forEach(k=>{const C=t.find(j=>j.id===k);C&&C.type==="down"&&v.push(k)}))});break;case"down":b.forEach(S=>{const w=t.find(T=>T.id===S);w&&(w.type==="left"||w.type==="right")&&(v.push(S),l(S).forEach(k=>{const C=t.find(j=>j.id===k);C&&C.type==="up"&&v.push(k)}))});break;case"left":b.forEach(S=>{const w=t.find(T=>T.id===S);w&&(w.type==="up"||w.type==="down")&&(v.push(S),l(S).forEach(k=>{const C=t.find(j=>j.id===k);C&&C.type==="right"&&v.push(k)}))});break;case"right":b.forEach(S=>{const w=t.find(T=>T.id===S);w&&(w.type==="up"||w.type==="down")&&(v.push(S),l(S).forEach(k=>{const C=t.find(j=>j.id===k);C&&C.type==="left"&&v.push(k)}))});break}return[...new Set(v)]},[t,l]),f=u.useCallback(I=>!0,[]),h=u.useCallback(I=>!a||!o?!1:!d(o).includes(I),[a,o,d]),m=u.useCallback(I=>!a||!o?!1:d(o).includes(I),[a,o,d]),x=u.useCallback(I=>{a&&o===I?(i(!1),s(null)):(s(I),i(!0))},[a,o]),y=u.useCallback(I=>{console.log(`Block clicked: ${I}`)},[]),p=u.useCallback(()=>{i(!1),s(null)},[]);return{selectedBlockId:o,isFiltering:a,isBlockVisible:f,isBlockDimmed:h,shouldShowBlueBorder:m,handleBlockPress:x,handleBlockClick:y,clearFiltering:p,getFilteredBlockIds:d}},nn=t=>parseInt(t.replace(/[^\d]/g,""),10)||0,zo=(t,r)=>{const[o,s]=u.useState({width:0,height:0}),a=u.useCallback(()=>{const{width:i,height:c}=o;if(i===0||c===0)return{blocksUp:r.minVerticalBlocks/2,blocksDown:r.minVerticalBlocks/2,blocksLeft:r.minHorizontalBlocks/2,blocksRight:r.minHorizontalBlocks/2,containerWidth:i,containerHeight:c};const l=nn(r.cellSize),d=nn(r.gap),f=l+d,h=i-d*2,m=c-d*2,x=Math.floor(m*r.verticalMaxPercent/100/f),y=Math.floor(h*r.horizontalMaxPercent/100/f),p=Math.floor(m*r.verticalMinPercent/100/f),I=Math.floor(h*r.horizontalMinPercent/100/f),g=Math.max(r.minVerticalBlocks,p),b=Math.max(r.minHorizontalBlocks,I),v=Math.max(g,x),S=Math.max(b,y),w=Math.floor(v/2),T=Math.floor(v/2),k=Math.floor(S/2),C=Math.floor(S/2);return{blocksUp:w,blocksDown:T,blocksLeft:k,blocksRight:C,containerWidth:i,containerHeight:c}},[o,r]);return u.useEffect(()=>{const i=()=>{if(t.current){const l=t.current.getBoundingClientRect();s({width:l.width,height:l.height})}};i();const c=new ResizeObserver(i);return t.current&&c.observe(t.current),()=>{c.disconnect()}},[t]),a()},Ro={verticalMinPercent:20,verticalMaxPercent:50,horizontalMinPercent:30,horizontalMaxPercent:50,minVerticalBlocks:2,minHorizontalBlocks:4,cellSize:"50px",gap:"8px"},Fn=({children:t,style:r,gap:o="8px",cellSize:s="50px",verticalBlocks:a,horizontalBlocks:i,responsiveConfig:c,enableResponsive:l=!1,blocksLeft:d,blocksRight:f,blocksUp:h=0,blocksDown:m=0,blockItems:x=[],blockConnections:y=[],enableFiltering:p=!1,onBlockClick:I,totalBlocksLeft:g,totalBlocksRight:b,totalBlocksUp:v,totalBlocksDown:S,usePagination:w=!1,responsive:T=!1,minBlocksPerSide:k=2,maxBlocksPerSide:C=15,minBlocksHorizontal:j=2,maxBlocksHorizontal:R=16,minBlocksVertical:D=2,maxBlocksVertical:O=16,minBlocksLeft:E=1,maxBlocksLeft:H=8,minBlocksRight:$=1,maxBlocksRight:W=8,minBlocksUp:L=1,maxBlocksUp:F=8,minBlocksDown:U=1,maxBlocksDown:Z=8,responsiveCellSize:_=!1,minCellSize:G="30px",maxCellSize:B="80px",directionTexts:z,...A})=>{const N=u.useRef(null),V=zo(N,{...Ro,cellSize:s,gap:o,...c});let ne=d,P=f,oe=h,X=m;l?(ne=Math.floor(V.blocksLeft),P=Math.floor(V.blocksRight),oe=Math.floor(V.blocksUp),X=Math.floor(V.blocksDown)):(a!==void 0||i!==void 0)&&(a!==void 0&&(oe=Math.floor(a/2),X=Math.floor(a/2)),i!==void 0&&(ne=Math.floor(i/2),P=Math.floor(i/2)));const de=E!==1?E:Math.floor(j/2),Ae=H!==8?H:Math.floor(R/2),Le=$!==1?$:Math.ceil(j/2),re=W!==8?W:Math.ceil(R/2),me=L!==1?L:Math.floor(D/2),be=F!==8?F:Math.floor(O/2),Vn=U!==1?U:Math.ceil(D/2),_n=Z!==8?Z:Math.ceil(O/2),{usePagination:Qn,finalBlocks:Q,finalCellSize:ae,gridDimensions:we}=Co({gap:o,cellSize:s,blocksLeft:ne,blocksRight:P,blocksUp:oe,blocksDown:X,totalBlocksLeft:g,totalBlocksRight:b,totalBlocksUp:v,totalBlocksDown:S,responsive:T,minBlocksPerSide:k,maxBlocksPerSide:C,minBlocksLeft:de,maxBlocksLeft:Ae,minBlocksRight:Le,maxBlocksRight:re,minBlocksUp:me,maxBlocksUp:be,minBlocksDown:Vn,maxBlocksDown:_n,responsiveCellSize:_,minCellSize:G,maxCellSize:B}),{getBlockContent:Se,getIntersectionText:Yn}=Mo({blockItems:x}),{getConnectionStateFromText:qn}=To({blockConnections:y}),Y=Oo({blockItems:x,blockConnections:y});u.useEffect(()=>{if(!p)return;const Fe=K=>{K.key==="Escape"&&Y.clearFiltering()};return window.addEventListener("keydown",Fe),()=>window.removeEventListener("keydown",Fe)},[p,Y]);const[ie,Zn,Xn]=So({totalBlocksLeft:g??0,totalBlocksRight:b??0,totalBlocksUp:v??0,totalBlocksDown:S??0,visibleBlocksLeft:Q.left,visibleBlocksRight:Q.right,visibleBlocksUp:Q.up,visibleBlocksDown:Q.down}),{getNavigationControlProps:ue}=Bo({usePagination:Qn,totalBlocksLeft:g,totalBlocksRight:b,totalBlocksUp:v,totalBlocksDown:S,paginationActions:Zn,paginationState:ie,paginationInfo:Xn});return e.jsxs(n.Box,{ref:N,style:{display:"grid",gridTemplateColumns:we.gridTemplateColumns,gridTemplateRows:we.gridTemplateRows,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",padding:o,boxSizing:"border-box",gap:o,overflow:"hidden",...r},...A,children:[Array.from({length:we.totalRows},(Fe,K)=>Array.from({length:we.totalColumns},(nr,te)=>{const Ue=Q.up>0?K===Q.up:K===0,Ne=te===Q.left;if(Ue&&Ne)return e.jsxs(Bn,{style:{width:"100%",height:"100%",maxWidth:"none",maxHeight:"none",position:"relative"},children:[t,e.jsx(Ce,{direction:"left",text:z==null?void 0:z.left,...ue("left")}),e.jsx(Ce,{direction:"right",text:z==null?void 0:z.right,...ue("right")}),e.jsx(Ce,{direction:"up",text:z==null?void 0:z.up,...ue("up")}),e.jsx(Ce,{direction:"down",text:z==null?void 0:z.down,...ue("down")}),w&&e.jsx(An,{showLeftControls:!!g,showRightControls:!!b,showUpControls:!!v,showDownControls:!!S,onLeftHover:q=>ue("left").onHover(q),onRightHover:q=>ue("right").onHover(q),onUpHover:q=>ue("up").onHover(q),onDownHover:q=>ue("down").onHover(q)})]},`center-${K}-${te}`);if(Ue&&te<Q.left){const q=w&&g?ie.leftStartIndex+te:te,J=`left-${q}`;return e.jsx(zn,{size:ae,blockId:p?J:void 0,isVisible:p?Y.isBlockVisible(J):!0,isDimmed:p?Y.isBlockDimmed(J):!1,shouldShowBlueBorder:p?Y.shouldShowBlueBorder(J):!1,onBlockClick:p?Y.handleBlockClick:I,onBlockPress:p?Y.handleBlockPress:void 0,children:Se("left",q)},`left-${te}`)}if(Ue&&te>Q.left){const q=te-Q.left-1,J=w&&b?ie.rightStartIndex+(Q.right-1-q):Q.right-1-q,ce=`right-${J}`;return e.jsx(Rn,{size:ae,blockId:p?ce:void 0,isVisible:p?Y.isBlockVisible(ce):!0,isDimmed:p?Y.isBlockDimmed(ce):!1,shouldShowBlueBorder:p?Y.shouldShowBlueBorder(ce):!1,onBlockClick:p?Y.handleBlockClick:I,onBlockPress:p?Y.handleBlockPress:void 0,children:Se("right",J)},`right-${q}`)}if(Ne&&K<Q.up){const q=w&&v?ie.upStartIndex+K:K,J=`up-${q}`;return e.jsx(Dn,{size:ae,blockId:p?J:void 0,isVisible:p?Y.isBlockVisible(J):!0,isDimmed:p?Y.isBlockDimmed(J):!1,shouldShowBlueBorder:p?Y.shouldShowBlueBorder(J):!1,onBlockClick:p?Y.handleBlockClick:I,onBlockPress:p?Y.handleBlockPress:void 0,children:Se("up",q)},`up-${K}`)}if(Ne&&K>Q.up){const q=K-Q.up-1,J=w&&S?ie.downStartIndex+q:q,ce=`down-${J}`;return e.jsx(En,{size:ae,blockId:p?ce:void 0,isVisible:p?Y.isBlockVisible(ce):!0,isDimmed:p?Y.isBlockDimmed(ce):!1,shouldShowBlueBorder:p?Y.shouldShowBlueBorder(ce):!1,onBlockClick:p?Y.handleBlockClick:I,onBlockPress:p?Y.handleBlockPress:void 0,children:Se("down",J)},`down-${q}`)}const We=te<Q.left?te:null,ke=te>Q.left?te-Q.left-1:null,$e=K<Q.up?K:null,Pe=K>Q.up?K-Q.up-1:null,Kn=w&&g&&We!==null?ie.leftStartIndex+We:We,Jn=w&&b&&ke!==null?ie.rightStartIndex+(Q.right-1-ke):ke!==null?Q.right-1-ke:null,et=w&&v&&$e!==null?ie.upStartIndex+$e:$e,nt=w&&S&&Pe!==null?ie.downStartIndex+Pe:Pe,He=Yn(Kn,Jn,et,nt);if(He&&He.length>0){const q=qn(He);return e.jsx(On,{size:ae,state:q,interactive:!1},`intersection-${K}-${te}`)}return e.jsx("div",{style:{width:ae,height:ae,minWidth:ae,minHeight:ae}},`empty-${K}-${te}`)})).flat(),p&&Y.isFiltering&&e.jsx(n.Box,{style:{position:"fixed",top:12,right:12,background:"rgba(255, 255, 255, 0.9)",color:"var(--mantine-color-dark-7)",padding:"8px 12px",borderRadius:"8px",boxShadow:"0 2px 10px rgba(0,0,0,0.12)",fontSize:12,fontWeight:600,pointerEvents:"none",zIndex:1e3},children:"Press Esc to clear filter"})]})};Fn.displayName="Matrix";const he=({editable:t=!1,children:r,label:o,icon:s,value:a,className:i,style:c,...l})=>{const d={className:i,style:c};return Ie.useMediaQuery("(max-width: 550px)",!1,{getInitialValueInEffect:!0})?e.jsxs(n.Stack,{gap:0,w:"100%",...d,children:[e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:8},h:"auto",children:[s&&e.jsx(s,{size:20,style:{flexShrink:0},color:"var(--mantine-color-gray-6)",strokeWidth:2}),e.jsx(n.Text,{size:"sm",fw:500,c:"gray.6",children:o})]}),e.jsx(n.Box,{style:{display:"flex",alignItems:"flex-start"},w:"100%",children:t&&r?r:a})]}):e.jsxs(n.Group,{align:"flex-start",gap:0,w:"100%",...l,...d,children:[e.jsxs(n.Box,{w:"30%",style:{display:"flex",alignItems:"center",gap:8},h:"40px",children:[s&&e.jsx(s,{size:20,style:{flexShrink:0},color:"var(--mantine-color-gray-6)",strokeWidth:2}),e.jsx(n.Text,{size:"sm",fw:500,truncate:!0,c:"gray.6",children:o})]}),e.jsx(n.Box,{w:"70%",style:{display:"flex",alignItems:"flex-start"},mih:40,children:t&&r?r:a})]})},Do=({label:t,icon:r,value:o,onChange:s,editable:a=!1,placeholder:i,disabled:c=!1})=>a&&s?e.jsx(he,{label:t,icon:r,value:e.jsx(je,{value:o,onChange:s,placeholder:i,disabled:c,size:"sm"})}):e.jsx(he,{label:t,icon:r,value:e.jsx(n.Text,{size:"sm",c:o?void 0:"dimmed",fw:500,truncate:!0,children:o||i||"—"})}),Eo=({label:t,icon:r,href:o,text:s,target:a="_blank"})=>{const i=s||o;return e.jsx(he,{label:t,icon:r,value:e.jsx(n.Anchor,{href:o,target:a,size:"sm",underline:"hover",children:i})})},Ao=({label:t,icon:r,value:o,onChange:s,editable:a=!1,format:i,placeholder:c})=>{const l=o??null,d=l!==null&&i?i(l):l!==null?l.toString():null,f=h=>{if(!s)return;const m=h.trim();if(m===""){s(null);return}const x=Number(m);isNaN(x)||s(x)};return a&&s?e.jsx(he,{label:t,icon:r,value:e.jsx(je,{value:d||"",onChange:f,placeholder:c||"Enter number",size:"sm"})}):e.jsx(he,{label:t,icon:r,value:e.jsx(n.Text,{size:"sm",c:l!==null?void 0:"dimmed",children:d||c||"—"})})},Lo=300,Fo=({users:t,onSearch:r,debounceSearch:o=!0,debounceDelay:s=Lo})=>{const[a,i]=u.useState(""),[c,l]=u.useState(t),[d,f]=u.useState(!1),h=u.useRef(null);return u.useEffect(()=>{if(!r){l(t);return}if(h.current&&clearTimeout(h.current),a.trim()){const m=async()=>{f(!0);try{const x=await r(a);l(x)}catch(x){console.error("Search error:",x)}finally{f(!1)}};o?h.current=setTimeout(m,s):m()}else l(t),f(!1);return()=>{h.current&&clearTimeout(h.current)}},[a,r,o,s,t]),u.useEffect(()=>{(!a.trim()||!r)&&l(t)},[t,a,r]),{searchQuery:a,setSearchQuery:i,displayedUsers:c,setDisplayedUsers:l,isSearching:d}},Uo=({value:t,multiple:r,users:o,displayedUsers:s,searchQuery:a,onSearch:i})=>{const c=u.useMemo(()=>r?Array.isArray(t)?t:[]:t?[t]:[],[t,r]),l=u.useMemo(()=>o.filter(h=>c.includes(h.id)),[o,c]),d=u.useMemo(()=>{if(!a.trim()||i)return s;const h=a.toLowerCase();return s.filter(m=>m.name.toLowerCase().includes(h)||m.email.toLowerCase().includes(h))},[s,a,i]),f=u.useMemo(()=>{const h=d.filter(y=>c.includes(y.id)),m=d.filter(y=>!c.includes(y.id)),x=l.filter(y=>!d.some(p=>p.id===y.id));return[...h,...x,...m]},[d,c,l]);return{selectedIds:c,selectedUsers:l,sortedUsers:f}},No=({isFocused:t,dropdownRef:r})=>{const[o,s]=u.useState("bottom"),a=u.useCallback(i=>{if(r.current=i,i){const c=i.dataset.position;c==="top"||c==="bottom"?s(c):requestAnimationFrame(()=>{if(i.dataset.position){const l=i.dataset.position;(l==="top"||l==="bottom")&&s(l)}})}},[r]);return u.useLayoutEffect(()=>{if(!t||!r.current)return;const i=()=>{if(r.current){const d=r.current.dataset.position;(d==="top"||d==="bottom")&&s(d)}};i();const c=requestAnimationFrame(i),l=new MutationObserver(()=>{i()});return r.current&&l.observe(r.current,{attributes:!0,attributeFilter:["data-position"]}),()=>{cancelAnimationFrame(c),l.disconnect()}},[t,r]),{placement:o,dropdownRefCallback:a}},Wo=({onLoadMore:t,hasMore:r,loading:o,setDisplayedUsers:s})=>{const a=u.useRef(null);return u.useEffect(()=>{if(!t||!r||o)return;const i=new IntersectionObserver(c=>{c[0].isIntersecting&&r&&!o&&t().then(l=>{s(d=>[...d,...l])})},{threshold:.1});return a.current&&i.observe(a.current),()=>{i.disconnect()}},[t,r,o,s]),{loadMoreRef:a}},$o=({combobox:t,dropdownRef:r})=>{const[o,s]=u.useState(!1),[a,i]=u.useState(!1),c=u.useCallback(()=>{s(!0),t.openDropdown()},[t]),l=u.useCallback(h=>{setTimeout(()=>{const m=h==null?void 0:h.relatedTarget;m&&r.current&&r.current.contains(m)||t.dropdownOpened||s(!1)},0)},[t,r]),d=u.useCallback(()=>{i(!0)},[]),f=u.useCallback(()=>{i(!1)},[]);return{isFocused:o,setIsFocused:s,isHovered:a,handleFocus:c,handleBlur:l,handleMouseEnter:d,handleMouseLeave:f}},Po=({multiple:t,value:r,onChange:o,combobox:s})=>{const a=u.useCallback(c=>{if(t){const l=Array.isArray(r)?r:[],d=l.includes(c)?l.filter(f=>f!==c):[...l,c];o==null||o(d)}else o==null||o(c),s.closeDropdown()},[t,r,o,s]),i=u.useCallback(c=>{if(t){const l=Array.isArray(r)?r:[];o==null||o(l.filter(d=>d!==c))}else o==null||o("")},[t,r,o]);return{handleSelect:a,handleRemove:i}},Ho="40px",Go=300,pe=({editable:t=!1,label:r,icon:o,value:s,users:a=[],onChange:i,placeholder:c="Select users",multiple:l=!1,disabled:d=!1,onSearch:f,debounceSearch:h=!0,debounceDelay:m=Go,onLoadMore:x,hasMore:y=!1,loading:p=!1})=>{const I=u.useRef(null),g=u.useRef(null),b=u.useRef(null),{searchQuery:v,setSearchQuery:S,displayedUsers:w,setDisplayedUsers:T,isSearching:k}=Fo({users:a,onSearch:f,debounceSearch:h,debounceDelay:m}),C=n.useCombobox({onDropdownClose:()=>{C.resetSelectedOption(),S(""),R(!1)},onDropdownOpen:()=>{C.updateSelectedOptionIndex("active"),R(!0)}}),{isFocused:j,setIsFocused:R,isHovered:D,handleFocus:O,handleBlur:E,handleMouseEnter:H,handleMouseLeave:$}=$o({combobox:C,dropdownRef:b}),{placement:W,dropdownRefCallback:L}=No({isFocused:j,dropdownRef:b}),{selectedIds:F,selectedUsers:U,sortedUsers:Z}=Uo({value:s,multiple:l,users:a,displayedUsers:w,searchQuery:v,onSearch:f}),{loadMoreRef:_}=Wo({onLoadMore:x,hasMore:y,loading:p,setDisplayedUsers:T}),{handleSelect:G,handleRemove:B}=Po({multiple:l,value:s,onChange:i,combobox:C}),z=()=>{if(!l)return null;const P=5,oe=U.slice(0,P),X=U.length-P;return e.jsxs(n.Group,{gap:"xs",children:[oe.map(de=>e.jsx(Me,{avatar:de.avatar,name:de.name,withRemoveButton:j,onRemove:()=>B(de.id)},de.id)),X>0&&e.jsx(n.Pill,{ml:"xs",radius:"md",size:"md",bg:"transparent",children:e.jsxs(n.Group,{gap:"2px",wrap:"nowrap",style:{alignItems:"center",display:"flex"},h:"24px",children:[e.jsx(M.IconPlus,{size:16,style:{color:"var(--mantine-color-blue-5)"}}),e.jsxs(n.Text,{size:"sm",fw:400,c:"var(--mantine-color-blue-5)",children:[X," more"]})]})})]})},A=()=>{if(l)return null;const P=U[0];return P?e.jsx(Me,{avatar:P.avatar,name:P.name}):null},N=()=>j?"var(--mantine-color-gray-2)":"var(--mantine-color-gray-0)",V=()=>({input:{position:j?"absolute":"relative",zIndex:j?1e3:1,fontWeight:"400",color:"var(--mantine-color-gray-9)",cursor:d?"not-allowed":"pointer",backgroundColor:j||D?"var(--mantine-color-gray-0)":"transparent",border:j?"1px solid var(--mantine-color-gray-2)":"1px solid transparent",borderRadius:j&&W==="bottom"?"var(--mantine-radius-md) var(--mantine-radius-md) 0 0":j&&W==="top"?"0 0 var(--mantine-radius-md) var(--mantine-radius-md)":"var(--mantine-radius-md)",paddingY:"6px",display:"flex",alignItems:"center",padding:"6px 14px",minHeight:"40px",flexWrap:l?"wrap":"nowrap",boxShadow:j&&W==="bottom"?"0 -4px 10px 0 rgba(0, 0, 0, 0.1)":j&&W==="top"?"0 4px 10px 0 rgba(0, 0, 0, 0.1)":"none"}}),ne={group:{alignItems:"center",gap:"4px",minHeight:"0",lineHeight:"normal"}};return e.jsx(he,{editable:t,label:r,icon:o,value:e.jsx(n.Group,{gap:"sm",wrap:"nowrap",style:{alignItems:"center"},w:"100%",h:40,p:"14px",children:U.map(P=>e.jsx(Me,{avatar:P.avatar,name:P.name,withRemoveButton:j,onRemove:()=>B(P.id)},P.id))}),children:e.jsxs(n.Combobox,{store:C,onOptionSubmit:G,withinPortal:!1,offset:-2,children:[e.jsx(n.Combobox.DropdownTarget,{children:e.jsx(n.PillsInput,{onClick:()=>!d&&C.openDropdown(),radius:"md",disabled:d,styles:V,onFocus:O,onBlur:E,onMouseEnter:()=>!d&&H(),onMouseLeave:$,w:"100%",children:e.jsxs(n.Pill.Group,{styles:ne,children:[l?z():A(),e.jsx(n.Combobox.EventsTarget,{children:e.jsx(n.PillsInput.Field,{ref:I,onFocus:O,onBlur:E,placeholder:U.length===0||j||v.length>0?c:"",value:v,onChange:P=>{C.updateSelectedOptionIndex(),S(P.currentTarget.value)},onMouseDown:P=>{P.stopPropagation()},onKeyDown:P=>{P.key==="Backspace"&&v.length===0&&(P.preventDefault(),l&&U.length>0?B(U[U.length-1].id):!l&&U.length>0&&B(U[0].id))},pointer:!0,disabled:d,styles:{field:{minWidth:j||v.length>0||U.length===0?"60px":"0px",width:j||v.length>0||U.length===0?"auto":"0px",flex:j||v.length>0||U.length===0?"1":"0",border:"none",outline:"none",background:"transparent",fontSize:"inherit",fontFamily:"inherit",padding:"0",margin:"0",overflow:"hidden",lineHeight:"24px",display:"flex",alignItems:"center",height:j||v.length>0||U.length===0?"auto":"0px",minHeight:j||v.length>0||U.length===0?"auto":"0px","&::placeholder":{opacity:U.length===0||j||v.length>0?1:0,display:U.length===0||j||v.length>0?"block":"none",color:"var(--mantine-color-gray-9)",lineHeight:"24px"}}}})})]})})}),e.jsx(n.Combobox.Dropdown,{styles:{dropdown:{borderRadius:W==="bottom"?"0 0 var(--mantine-radius-md) var(--mantine-radius-md)":"var(--mantine-radius-md) var(--mantine-radius-md) 0 0",borderTop:"none",border:`1px solid ${N()}`,marginTop:"0",padding:"4px",boxShadow:W==="bottom"?"0 4px 10px 0 rgba(0, 0, 0, 0.1)":"0 -4px 10px 0 rgba(0, 0, 0, 0.1)"}},ref:L,children:e.jsx(n.Combobox.Options,{children:e.jsx(n.ScrollArea,{ref:g,h:Math.min(Z.length*parseFloat(Ho),300),scrollbarSize:6,children:e.jsxs(n.Stack,{gap:2,children:[Z.map(P=>{const oe=F.includes(P.id);return e.jsx(n.Combobox.Option,{value:P.id,active:oe,onMouseDown:X=>{X.preventDefault(),G(P.id)},style:{borderRadius:"var(--mantine-radius-md)",height:"40px"},children:e.jsxs(n.Group,{gap:"sm",wrap:"nowrap",style:{display:"flex",alignItems:"center"},h:"28px",children:[e.jsx(se,{avatar:P.avatar,size:24,placeholder:P.name,showPlaceholder:!0}),e.jsx(n.Text,{size:"sm",fw:400,truncate:!0,children:P.name}),oe&&e.jsx(M.IconCheck,{size:16,color:"var(--mantine-color-blue-6)"})]})},P.id)}),(k||p)&&e.jsx(n.Box,{style:{padding:"12px",display:"flex",justifyContent:"center"},children:e.jsx(n.Loader,{size:"sm"})}),x&&y&&!p&&e.jsx("div",{ref:_,style:{height:"20px"}}),Z.length===0&&!k&&!p&&e.jsx(n.Box,{style:{padding:"24px",textAlign:"center"},children:e.jsx(n.Text,{size:"sm",c:"dimmed",children:"No users found"})})]})})})})]})})},qe=({label:t,icon:r,value:o,onChange:s,onDraftChange:a,onFocusChange:i,editable:c=!1,placeholder:l,disabled:d=!1,minRows:f=1,maxRows:h,autosize:m=!0})=>{const[x,y]=u.useState(!1),[p,I]=u.useState(!1),g={wrapper:{...!m&&{height:"40px",minHeight:"40px",boxSizing:"border-box"},borderRadius:"var(--mantine-radius-md)"},input:{backgroundColor:x||p?"var(--mantine-color-gray-0)":"transparent",color:"var(--mantine-color-gray-9)",border:x?"1px solid var(--mantine-color-gray-2)":"1px solid transparent",borderRadius:"var(--mantine-radius-md)",width:"100%",cursor:"pointer",...!m&&{height:"40px",minHeight:"40px",boxSizing:"border-box"},padding:"8px 14px",lineHeight:m?"1.5":"24px",fontWeight:450}},b=()=>{y(!0),i==null||i(!0)},v=w=>{y(!1),i==null||i(!1),s==null||s(w.target.value)},S=w=>{a==null||a(w.target.value)};return e.jsx(he,{editable:c,label:t,icon:r,value:e.jsx(n.Box,{w:"100%",style:{display:"flex",alignItems:"flex-start",minHeight:40},p:"xs",h:40,children:e.jsx(n.Text,{size:"sm",c:o?void 0:"dimmed",fw:400,style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:o||l||"—"})}),children:e.jsx(n.Box,{w:"100%",style:{boxShadow:x?"var(--mantine-shadow-sm)":"none",borderRadius:"var(--mantine-radius-md)"},children:e.jsx(n.Textarea,{value:o,onChange:S,onFocus:b,onBlur:v,onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),placeholder:l,disabled:d,size:"sm",radius:"md",fw:400,minRows:x?1:f,maxRows:h,autosize:m,styles:{...g}})})})},Vo=({opened:t,onClose:r,children:o,...s})=>e.jsxs(n.Modal,{withCloseButton:!1,opened:t,onClose:r,size:"70%",centered:!0,overlayProps:{backgroundOpacity:.55},styles:{content:{minHeight:"100%"}},padding:"md",...s,children:[e.jsxs(n.Group,{justify:"space-between",wrap:"nowrap",children:[e.jsx(n.Group,{justify:"space-between",wrap:"nowrap",gap:"xs",children:e.jsx(ee,{icon:M.IconMaximize,size:"md",onClick:()=>{}})}),e.jsxs(n.Group,{justify:"space-between",gap:"xs",children:[e.jsx(ee,{icon:M.IconStar,size:"md",onClick:()=>{}}),e.jsx(ee,{icon:M.IconDots,size:"md",onClick:()=>{}})]})]}),o]}),Un=({opened:t,onClose:r,editable:o,content:s,position:a="right",size:i="xl",onMaximize:c,rightCornerActions:l,headerProps:d,propertiesProps:f})=>{var w,T;const[h,m]=u.useState(!1),x=(f==null?void 0:f.hiddenProperties)&&f.hiddenProperties.length>0,[y,p]=u.useState(!1),[I,g]=u.useState(d==null?void 0:d.avatar),[b,v]=u.useState(!1);u.useEffect(()=>{g(d==null?void 0:d.avatar)},[d==null?void 0:d.avatar]);const S=e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray",mb:"md",onClick:()=>{var C;const k={type:"emoji",value:"😊"};g(k),(C=d==null?void 0:d.onAvatarChange)==null||C.call(d,k)},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(M.IconMoodSmileFilled,{size:16}),e.jsx(n.Text,{size:"sm",fw:500,children:"Add avatar"})]})});return e.jsxs(n.Drawer,{opened:t,onClose:r,position:a,size:i,padding:"md",withCloseButton:!1,overlayProps:{backgroundOpacity:0},shadow:"none",children:[e.jsxs(n.Group,{justify:"space-between",wrap:"nowrap",children:[e.jsxs(n.Group,{justify:"space-between",wrap:"nowrap",gap:"xs",children:[e.jsx(ee,{icon:M.IconChevronsRight,size:"md",onClick:r}),e.jsx(ee,{icon:M.IconMaximize,size:"md",onClick:()=>c()})]}),e.jsx(n.Group,{justify:"space-between",gap:"xs",children:l})]}),e.jsxs(n.Box,{p:"3rem",children:[d&&e.jsxs(n.Box,{children:[e.jsx(n.Box,{onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:I?e.jsx(Ee,{editable:o,avatar:I,size:"xl",opened:b,onOpen:()=>v(!0),onClose:()=>v(!1),onAvatarSelect:k=>{var C;g(k),(C=d==null?void 0:d.onAvatarChange)==null||C.call(d,k)},onRemove:()=>{g(void 0)}}):e.jsx(n.Box,{h:24,children:y&&S})}),o?e.jsx(je,{value:d.title||"",onChange:k=>{var C;return(C=d.onTitleChange)==null?void 0:C.call(d,k)},onDraftChange:d.onTitleDraftChange,pageTitle:!0,placeholder:d.placeholder}):e.jsx(n.Box,{h:80,style:{display:"flex",alignItems:"center"},children:e.jsx(n.Text,{size:"2.5rem",fw:700,children:d.title})})]}),e.jsx(n.Stack,{gap:"sm",children:(w=f==null?void 0:f.visibleProperties)==null?void 0:w.map((k,C)=>e.jsx(n.Box,{children:k},C))}),x&&!h&&e.jsx(n.Box,{w:"100%",style:{display:"flex",justifyContent:"center"},children:e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray.4",onClick:()=>m(!0),children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.Text,{size:"sm",fw:500,c:"var(--mantine-color-blue-5)",children:"Show"}),e.jsx(M.IconChevronDown,{size:16,color:"var(--mantine-color-blue-5)"})]})})}),e.jsx(n.Collapse,{in:h,children:e.jsx(n.Stack,{gap:"sm",mt:"sm",children:(T=f==null?void 0:f.hiddenProperties)==null?void 0:T.map((k,C)=>e.jsx(n.Box,{children:k},C))})}),x&&h&&e.jsx(n.Box,{w:"100%",style:{display:"flex",justifyContent:"center"},mt:"sm",children:e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray.4",onClick:()=>m(!1),children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.Text,{size:"sm",fw:500,c:"var(--mantine-color-blue-5)",children:"Hide"}),e.jsx(M.IconChevronUp,{size:16,color:"var(--mantine-color-blue-5)"})]})})}),s]})]})},_o=({children:t})=>e.jsx(n.Box,{style:{minHeight:"100vh",width:"100%",maxWidth:"100%",margin:"0 auto"},id:"full-page",children:t}),Nn=u.createContext(void 0),Wn=({children:t})=>{const[r,{toggle:o,open:s,close:a}]=Ie.useDisclosure(!0),[i,{toggle:c,open:l,close:d}]=Ie.useDisclosure(!1),[f,{open:h,close:m}]=Ie.useDisclosure(!1),[x,y]=u.useState(300),[p,I]=u.useState(500),g={opened:r,toggle:o,open:s,close:a,asideOpened:i,toggleAside:c,openAside:l,closeAside:d,sidebarWidth:x,setSidebarWidth:y,asideWidth:p,setAsideWidth:I,openedNotificationSidebar:f,openNotificationSidebar:h,closeNotificationSidebar:m};return e.jsx(Nn.Provider,{value:g,children:t})},Ze=()=>{const t=u.useContext(Nn);if(t===void 0)throw new Error("useAppLayout must be used within an AppLayoutProvider");return t},$n=({header:t,navbar:r,aside:o,children:s,...a})=>{const{opened:i,asideOpened:c,sidebarWidth:l,asideWidth:d}=Ze();return e.jsxs(n.AppShell,{header:{height:t?60:0},navbar:{width:i?l:0,breakpoint:"sm",collapsed:{mobile:!0}},aside:{width:c?d:0,breakpoint:"sm",collapsed:{mobile:!0}},padding:0,...a,children:[t&&e.jsx(n.AppShell.Header,{children:t}),e.jsx(n.AppShell.Navbar,{style:{display:i?"block":"none",width:i?l:0,border:"none"},children:r}),e.jsx(n.AppShell.Aside,{style:{display:c?"block":"none",width:c?d:0},children:o}),e.jsx(n.AppShell.Main,{children:s})]})},Qo=({items:t,selectedId:r,onSelect:o})=>e.jsx(n.Stack,{gap:0,children:t.map(s=>{var a;return e.jsx(_e,{label:s.label,isActive:r===s.id,noChild:!s.children||s.children.length===0,onClick:()=>(!s.children||s.children.length===0)&&(o==null?void 0:o(s.id)),children:(a=s.children)==null?void 0:a.map(i=>e.jsx(_e,{label:i.label,noChild:!0,level:4,isActive:r===i.id,onClick:()=>o==null?void 0:o(i.id)},i.id))},s.id)})}),Yo=({items:t,selectedId:r,onSelect:o,headerLeft:s,headerRight:a,renderPreview:i,renderAside:c,sidebarTitle:l="Documentation",topNavItems:d,selectedTopNavId:f,onTopNavSelect:h})=>{const{opened:m,toggle:x}=Ze(),[y,p]=u.useState(r),I=r??y,g=b=>{o==null||o(b),r===void 0&&p(b)};return e.jsx($n,{header:d?e.jsx(Qe,{withBorder:!0,bg:"transparent",position:"left",header:e.jsx(n.Group,{h:40,w:"100%",justify:"space-between",wrap:"nowrap",children:e.jsx(n.Group,{gap:"xs",wrap:"nowrap",children:m&&e.jsx(n.Text,{fw:600,size:"sm",children:l})})})}):void 0,navbar:e.jsx(Qe,{withBorder:!0,bg:"transparent",position:"left",header:e.jsxs(n.Group,{h:40,w:"100%",justify:"space-between",wrap:"nowrap",children:[e.jsx(n.Group,{gap:"xs",wrap:"nowrap",children:m&&e.jsx(n.Text,{fw:600,size:"sm",children:l})}),e.jsx(ee,{icon:m?M.IconChevronsLeft:M.IconChevronsRight,size:"md",onClick:x})]}),body:m&&e.jsx(n.ScrollArea,{h:"100%",type:"hover",scrollbarSize:10,styles:{scrollbar:{'&[data-state="visible"]':{background:"transparent"}},thumb:{backgroundColor:"var(--mantine-color-gray-4)",opacity:.3,"&:hover":{backgroundColor:"var(--mantine-color-gray-4)",opacity:.3}}},children:e.jsx(Qo,{items:t,selectedId:I,onSelect:g})}),footer:e.jsx(e.Fragment,{})}),aside:e.jsx(n.Box,{p:"md",h:"100%",children:c==null?void 0:c(I)}),children:e.jsxs(n.Box,{style:{height:"100vh",display:"flex",flexDirection:"column",background:"var(--mantine-color-body)"},children:[e.jsxs(n.Group,{p:"md",justify:"space-between",align:"center",children:[e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[!m&&e.jsx(ee,{icon:M.IconChevronsRight,size:"md",variant:"subtle",tooltip:"Open sidebar",onClick:x}),s??e.jsx(Oe,{label:I||"Select a topic",onClick:()=>{}})]}),!d&&a]}),e.jsx(n.Box,{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"40px"},children:e.jsx(n.Box,{p:"xl",style:{borderRadius:"var(--mantine-radius-md)",width:"100%"},children:i(I)})})]})})},qo=t=>e.jsx(Wn,{children:e.jsx(Yo,{...t})}),Xe=(t,r)=>{const o=u.useCallback(i=>{const c=Array.isArray(i)?i:[i];t.onUserIdsChange(c)},[t]),s=u.useCallback(i=>{const c=Array.isArray(i)?i:[i],l=r.members.filter(y=>c.includes(y.id)),d=l.map(y=>y.id),f=c.filter(y=>!d.includes(y)),m=[...r.members,...t.users].filter(y=>f.includes(y.id)),x=[...l,...m];r.onMembersChange(x)},[r,t]);return{availableMembersUsers:u.useMemo(()=>{const i=[...r.members];return t.users.forEach(c=>{i.find(l=>l.id===c.id)||i.push(c)}),i},[r.members,t.users]),handleResponsibleChange:o,handleMembersChange:s}},Zo=({opened:t,onClose:r,onMaximize:o,editable:s,name:a,onNameChange:i,avatar:c,onAvatarChange:l,owner:d,responsibleProps:f,membersProps:h,descriptionProps:m})=>{const{availableMembersUsers:x,handleResponsibleChange:y,handleMembersChange:p}=Xe(f,h),I=u.useMemo(()=>[e.jsx(qe,{label:"Description",icon:M.IconAlignLeft,value:m.description,onChange:m.onDescriptionChange,editable:s},"description"),e.jsx(pe,{editable:!1,label:"Team Owner",icon:M.IconUserCircle,value:d.id,users:[d]},"owner"),e.jsx(pe,{multiple:!1,editable:s,label:"Team Leader",icon:M.IconUser,value:f.userIds.length>0?f.userIds[0]:void 0,users:f.users,onChange:y,onSearch:f.handleSearch,onLoadMore:f.handleLoadMore,hasMore:f.hasMore},"leader"),e.jsx(pe,{multiple:!0,editable:s,label:"Team Members",icon:M.IconUsers,value:h.members.map(g=>g.id),users:x,onChange:p,onSearch:h.handleSearch,onLoadMore:h.handleLoadMore,hasMore:h.hasMore},"members")],[m.description,m.onDescriptionChange,s,d,f.handleLoadMore,f.handleSearch,f.hasMore,f.userIds,f.users,y,h.handleLoadMore,h.handleSearch,h.hasMore,h.members,x,p]);return e.jsx(Un,{opened:t,onClose:r,onMaximize:o,editable:s,headerProps:{avatar:c,onAvatarChange:g=>l==null?void 0:l(g),title:a,onTitleChange:i,placeholder:"Team name"},propertiesProps:{visibleProperties:I}})},Pn=({isSidebarOpen:t,fullWidth:r=!1,editable:o,rightNavigation:s,headerProps:a,properties:i,children:c,footer:l})=>{const[d,f]=u.useState(a==null?void 0:a.avatar),[h,m]=u.useState(!1),[x,y]=u.useState(!1),p=r?"0":{base:"1rem",sm:"2rem",md:"4rem",lg:"8rem",xl:"10rem"},[I,g]=u.useState(t);u.useEffect(()=>{g(t)},[t]);const b=()=>{g(v=>!v)};return e.jsxs(n.Stack,{gap:"md",p:"md",children:[e.jsxs(n.Group,{justify:"space-between",children:[e.jsxs(n.Group,{gap:4,wrap:"nowrap",children:[e.jsx(ee,{icon:I?M.IconChevronsRight:M.IconMenu2,size:"md",color:"gray",changeIconOnHover:!0,iconHovered:I?M.IconMenu2:M.IconChevronsRight,variant:"subtle",onClick:b,"aria-pressed":I}),e.jsx(Oe,{label:a.title,onClick:()=>{}})]}),e.jsx(n.Box,{children:s})]}),e.jsx(n.Box,{px:p,w:"100%",maw:{base:"100%",md:"80vw"},mx:"auto",children:e.jsxs(n.Stack,{gap:"md",children:[a&&e.jsxs(n.Stack,{gap:"md",children:[e.jsx(n.Box,{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),h:d?64:24,children:d?e.jsx(Ee,{editable:o,avatar:d,size:64,opened:h,onOpen:()=>m(!0),onClose:()=>m(!1),onAvatarSelect:v=>{var S;f(v),(S=a==null?void 0:a.onAvatarChange)==null||S.call(a,v)},onRemove:()=>{f(void 0)}}):e.jsx(n.Box,{h:24,children:x&&e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray",mb:"md",onClick:()=>{var S;const v={type:"emoji",value:"😊"};f(v),(S=a==null?void 0:a.onAvatarChange)==null||S.call(a,v)},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(M.IconMoodSmileFilled,{size:16}),e.jsx(n.Text,{size:"sm",fw:500,children:"Add avatar"})]})})})}),e.jsx(n.Box,{children:o?e.jsx(un,{value:a.title||"",onChange:v=>{var S;return(S=a.onTitleChange)==null?void 0:S.call(a,v)},placeholder:a.placeholder,pageTitle:!0}):e.jsx(n.Box,{h:80,style:{display:"flex",alignItems:"center"},children:e.jsx(n.Text,{size:"2.5rem",fw:700,children:a.title})})})]}),i,c,l]})})]})},Hn=({editable:t,owner:r,descriptionProps:o,responsibleProps:s,membersProps:a})=>{const{availableMembersUsers:i,handleResponsibleChange:c,handleMembersChange:l}=Xe(s,a);return e.jsxs(n.Stack,{gap:"sm",children:[e.jsx(qe,{label:"Description",icon:M.IconAlignLeft,value:o.description,onChange:o.onDescriptionChange,editable:t},"description"),e.jsx(pe,{editable:!1,label:"Team Owner",icon:M.IconUserCircle,value:r.id,users:[r]},"owner"),e.jsx(pe,{multiple:!1,editable:t,label:"Team Leader",icon:M.IconUser,value:s.userIds.length>0?s.userIds[0]:void 0,users:s.users,onChange:c,onSearch:s.handleSearch,onLoadMore:s.handleLoadMore,hasMore:s.hasMore},"leader"),e.jsx(pe,{multiple:!0,editable:t,label:"Team Members",icon:M.IconUsers,value:a.members.map(d=>d.id),users:i,onChange:l,onSearch:a.handleSearch,onLoadMore:a.handleLoadMore,hasMore:a.hasMore},"members")]})},Xo=({editable:t,headerProps:r,rightNavigation:o,properties:s,children:a,footer:i})=>e.jsx(Pn,{isSidebarOpen:!0,editable:t,rightNavigation:o,headerProps:r,properties:e.jsx(Hn,{...s}),children:a,footer:i}),Ko=({title:t,properties:r,children:o})=>e.jsxs(n.Stack,{gap:"sm",p:"3rem",children:[e.jsx(n.Text,{size:"2.5rem",fw:600,children:t}),e.jsx(n.Space,{h:"md"}),e.jsx(n.Stack,{gap:"xs",children:r}),e.jsx(n.Space,{h:"md"}),e.jsx(n.Box,{children:o})]}),Jo=({opened:t,onClose:r,position:o,size:s,onMaximize:a,editable:i,rightNavigation:c,headerProps:l,properties:d,children:f,footer:h})=>{var S,w;const[m,x]=u.useState(l==null?void 0:l.avatar),[y,p]=u.useState(!1),[I,g]=u.useState(!1);u.useEffect(()=>{x(l==null?void 0:l.avatar)},[l==null?void 0:l.avatar]);const b=(S=l==null?void 0:l.loading)==null?void 0:S.avatar,v=(w=l==null?void 0:l.loading)==null?void 0:w.title;return e.jsx(n.Drawer,{opened:t,onClose:r,position:o,size:s,padding:"md",withCloseButton:!1,overlayProps:{backgroundOpacity:0},shadow:"none",trapFocus:!1,children:e.jsxs(n.Stack,{gap:"md",children:[e.jsxs(n.Group,{justify:"space-between",children:[e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[e.jsx(fe,{icon:M.IconChevronsRight,onClick:r}),e.jsx(fe,{icon:M.IconMaximize,onClick:()=>a()})]})," ",e.jsx(n.Box,{children:c})]}),e.jsx(n.Box,{p:"3rem",w:"100%",children:e.jsxs(n.Stack,{gap:"md",children:[l&&e.jsxs(n.Box,{children:[" ",e.jsx(n.Box,{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),h:b||m?64:24,children:b?e.jsx(n.Skeleton,{height:64,width:64,radius:"md"}):m?e.jsx(Ee,{editable:i,avatar:m,size:64,opened:y,onOpen:()=>p(!0),onClose:()=>p(!1),onAvatarSelect:T=>{var k;x(T),(k=l==null?void 0:l.onAvatarChange)==null||k.call(l,T)},onRemove:()=>{x(void 0)}}):e.jsx(n.Box,{h:24,children:I&&e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray",mb:"md",onClick:()=>{var k;const T={type:"emoji",value:"😊"};x(T),(k=l==null?void 0:l.onAvatarChange)==null||k.call(l,T)},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(M.IconMoodSmileFilled,{size:16}),e.jsx(n.Text,{size:"sm",fw:500,children:"Add avatar"})]})})})}),v?e.jsx(n.Skeleton,{height:64,width:"100%",radius:"md",mt:"md"}):i?e.jsx(je,{value:l.title||"",onChange:T=>{var k;return(k=l.onTitleChange)==null?void 0:k.call(l,T)},onDraftChange:l.onTitleDraftChange,pageTitle:!0,placeholder:l.placeholder}):e.jsx(n.Box,{h:80,style:{display:"flex",alignItems:"center"},children:e.jsx(n.Text,{size:"2.5rem",fw:700,children:l.title})})]}),d,f,h]})})]})})},Gn=n.createTheme({primaryColor:"blue",fontFamily:"Inter, system-ui, Avenir, Helvetica, Arial, sans-serif",fontFamilyMonospace:"Monaco, Courier, monospace",headings:{fontFamily:"Inter, system-ui, Avenir, Helvetica, Arial, sans-serif"},colors:{},components:{}});function er({children:t,theme:r}){return e.jsxs(n.MantineProvider,{theme:r||Gn,children:[e.jsx(ct.Notifications,{}),e.jsx(lt.ModalsProvider,{children:e.jsx(dt.DatesProvider,{settings:{firstDayOfWeek:0},children:t})})]})}exports.ActionButton=ee;exports.ActionIcon=fe;exports.AppLayout=$n;exports.AppLayoutProvider=Wn;exports.AvatarSelector=Ee;exports.BaseLayout=Ko;exports.BoxAvatar=se;exports.CenterPeek=Vo;exports.DocsTemplate=qo;exports.EditableText=je;exports.EditableTextarea=un;exports.EmojiAvatar=on;exports.ExpandableSearch=fn;exports.FilterDropdown=wt;exports.FilterDropdownButton=ze;exports.FilterDropdownFilters=Re;exports.FullPage=_o;exports.GenericTable=xn;exports.IconAvatar=an;exports.ImageAvatar=cn;exports.InvitedUserCard=ve;exports.LinkProperty=Eo;exports.Logo=dn;exports.Matrix=Fn;exports.Menu=ye;exports.ModalSettings=io;exports.NavButton=Ye;exports.NavLink=_e;exports.Navbar=Qe;exports.NavbarProvider=go;exports.NotificationSidebar=mo;exports.NumberProperty=Ao;exports.PageLayout=Pn;exports.PageProperty=he;exports.PlaceholderAvatar=Be;exports.PopoverItem=hn;exports.PopoverSelector=De;exports.SelectUserProperty=pe;exports.ShareButton=so;exports.ShareMenu=Cn;exports.ShareModal=ao;exports.SidePeek=Un;exports.SidePeekLayout=Jo;exports.TeamPage=Xo;exports.TeamProperties=Hn;exports.TeamSidePeek=Zo;exports.TextButton=Oe;exports.TextProperty=Do;exports.TextareaProperty=qe;exports.ThemeProvider=er;exports.UserChip=Me;exports.WorkspaceSelector=wo;exports.WorkspaceSelectorItem=Tn;exports.getInitialsFromName=ln;exports.theme=Gn;exports.useAppLayout=Ze;exports.useNavbar=Io;exports.useTeamProperties=Xe;
18
+ `})]})},ze=({activeFilters:t,onFiltersChange:r,availableFilters:o,size:s="md",filterButtonDropdownPosition:a="bottom-end"})=>{const i=n.useCombobox({onDropdownClose:()=>i.resetSelectedOption(),onDropdownOpen:()=>i.updateSelectedOptionIndex("active")}),[c,l]=u.useState(!1),d=t.length>0,f=I=>{if(I==="remove-filters")r([]);else{const g=o==null?void 0:o.find(b=>b.value===I);if(g){const b={id:`${g.value}-${Date.now()}`,filterOption:g};r([...t,b])}}i.closeDropdown()},h=(o||[]).filter(I=>!t.some(g=>g.filterOption.value===I.value)),m={borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",color:"var(--mantine-color-gray-7)",fontWeight:"500"},y=(()=>{switch(s){case"sm":return{height:"32px",width:"32px",iconSize:20};case"md":return{height:"32px",width:"32px",iconSize:20};default:return{height:"32px",width:"32px",iconSize:20}}})(),p=e.jsx(n.Box,{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundColor:d||c?"var(--mantine-color-gray-0)":"transparent",color:"var(--mantine-color-gray-6)",borderRadius:"var(--mantine-radius-md)",cursor:"pointer",transition:"all 0.2s ease",...y},onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onClick:()=>i.toggleDropdown(),children:e.jsx(M.IconFilter,{size:20,stroke:2.3})});return e.jsxs(n.Combobox,{store:i,onOptionSubmit:f,withinPortal:!1,offset:4,position:a,children:[e.jsx(n.Combobox.Target,{children:d?e.jsx(n.Indicator,{offset:2,position:"top-end",color:"var(--mantine-color-yellow-7)",children:p}):p}),e.jsx(n.Combobox.Dropdown,{styles:{dropdown:{borderRadius:"var(--mantine-radius-md)",border:"1px solid var(--mantine-color-gray-2)",boxShadow:"var(--mantine-shadow-md)",padding:"4px",width:"auto",minWidth:"160px"}},children:e.jsxs(n.Combobox.Options,{children:[h.map(I=>e.jsx(n.Combobox.Option,{value:I.value,style:{...m},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"8px"},children:[I.icon,I.label]})},I.value)),d&&e.jsx(n.Combobox.Option,{value:"remove-filters",style:{borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",fontWeight:"500",color:"var(--mantine-color-red-6)"},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(M.IconFilterOff,{size:16,stroke:2}),"Remove filters"]})})]})})]})},vt=({filterTag:t,onUpdate:r,onRemove:o,options:s=[],filterTagDropdownPosition:a="bottom-start"})=>{var x;const i=n.useCombobox({onDropdownClose:()=>i.resetSelectedOption(),onDropdownOpen:()=>i.updateSelectedOptionIndex("active")}),c=!!t.selectedOption,l=c?`${t.filterOption.label}: ${(x=t.selectedOption)==null?void 0:x.label}`:t.filterOption.label,d=s&&s.length>0?s:[{value:"option-a",label:"TagFilterOptionA"},{value:"option-b",label:"TagFilterOptionB"},{value:"option-c",label:"TagFilterOptionC"}],f=y=>{if(y==="remove")o();else{const p=d.find(I=>I.value===y);p&&r({...t,selectedOption:p})}i.closeDropdown()},h={borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",color:"var(--mantine-color-gray-7)",fontWeight:"500"},m={display:"inline-flex",alignItems:"center",gap:"4px",backgroundColor:c?"var(--mantine-color-blue-0)":"var(--mantine-color-gray-0)",color:c?"var(--mantine-color-blue-7)":"var(--mantine-color-gray-6)",borderRadius:"var(--mantine-radius-xl)",cursor:"pointer",transition:"all 0.2s ease",height:"32px",fontSize:"var(--mantine-font-size-sm)",padding:"0 12px"};return e.jsxs(n.Combobox,{store:i,onOptionSubmit:f,withinPortal:!1,offset:4,position:a,middlewares:{flip:!1,shift:!0},children:[e.jsx(n.Combobox.Target,{children:e.jsxs(n.Box,{style:{...m},onClick:()=>i.toggleDropdown(),fw:500,pl:"sm",children:[e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.filterOption.icon,l]}),e.jsx(M.IconChevronDown,{size:16,strokeWidth:2,color:"var(--mantine-color-gray-5)"})]})}),e.jsx(n.Combobox.Dropdown,{styles:{dropdown:{borderRadius:"var(--mantine-radius-md)",border:"1px solid var(--mantine-color-gray-2)",boxShadow:"var(--mantine-shadow-md)",padding:"4px",minWidth:"150px"}},children:e.jsxs(n.Combobox.Options,{children:[d.map(y=>{var p;return e.jsx(n.Combobox.Option,{value:y.value,active:((p=t.selectedOption)==null?void 0:p.value)===y.value,style:{...h},children:y.label},y.value)}),e.jsx(n.Combobox.Option,{value:"remove",style:{borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",fontWeight:"500",color:"var(--mantine-color-red-6)"},children:"Or remove filter"})]})})]})},jt=({activeFilters:t,onFiltersChange:r,availableFilters:o,addFilterButtonDropdownPosition:s="bottom-start"})=>{const a=n.useCombobox({onDropdownClose:()=>a.resetSelectedOption(),onDropdownOpen:()=>a.updateSelectedOptionIndex("active")}),[i,c]=u.useState(!1),l=x=>{const y=o==null?void 0:o.find(p=>p.value===x);if(y){const p={id:`${y.value}-${Date.now()}`,filterOption:y};r([...t,p])}a.closeDropdown()},d=(o||[]).filter(x=>!t.some(y=>y.filterOption.value===x.value)),f={display:"inline-flex",alignItems:"center",backgroundColor:i?"var(--mantine-color-gray-0)":"transparent",borderRadius:"var(--mantine-radius-xl)",cursor:"pointer",transition:"all 0.2s ease",border:"1px solid transparent",height:"32px",fontSize:"var(--mantine-font-size-sm)",padding:"0 12px"},h={dropdown:{borderRadius:"var(--mantine-radius-md)",border:"1px solid var(--mantine-color-gray-2)",boxShadow:"var(--mantine-shadow-md)",padding:"4px",width:"auto",minWidth:"120px"}},m={borderRadius:"var(--mantine-radius-md)",fontSize:"var(--mantine-font-size-sm)",color:"var(--mantine-color-gray-7)",fontWeight:"500"};return e.jsxs(n.Combobox,{store:a,onOptionSubmit:l,withinPortal:!1,offset:4,position:s,children:[e.jsx(n.Combobox.Target,{children:e.jsx(n.Box,{style:{...f},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:()=>a.toggleDropdown(),children:e.jsx(n.Box,{style:{fontWeight:"500",color:"var(--mantine-color-blue-6)"},children:"Add filter"})})}),e.jsx(n.Combobox.Dropdown,{styles:{...h},children:e.jsx(n.Combobox.Options,{children:d.map(x=>e.jsx(n.Combobox.Option,{value:x.value,style:{...m},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x.icon,x.label]})},x.value))})})]})},Re=({activeFilters:t,onFiltersChange:r,availableFilters:o,size:s="sm",getFilterOptions:a,filterTagDropdownPosition:i="bottom-start"})=>{const c=f=>{const h=(t||[]).map(m=>m.id===f.id?f:m);r(h)},l=f=>{const h=(t||[]).filter(m=>m.id!==f);r(h)},d=(o||[]).filter(f=>!t.some(h=>h.filterOption.value===f.value));return!t||t.length===0?null:e.jsx("div",{style:{width:"100%"},children:e.jsxs(n.Group,{gap:"sm",align:"center",wrap:"wrap",children:[(t||[]).map(f=>{const h=a?a(f.filterOption.value)||[]:[];return e.jsx(vt,{filterTag:f,onUpdate:c,onRemove:()=>l(f.id),size:s,options:h,filterTagDropdownPosition:i},f.id)}),d.length>0&&e.jsx(jt,{activeFilters:t,onFiltersChange:r,availableFilters:d,size:s})]})})},bt=({activeFilters:t,onFiltersChange:r,availableFilters:o,size:s="md",getFilterOptions:a,filterTagDropdownPosition:i="bottom-start"})=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsx(ze,{activeFilters:t,onFiltersChange:r,availableFilters:o,size:s}),e.jsx(Re,{activeFilters:t,onFiltersChange:r,availableFilters:o,size:"sm",getFilterOptions:a,filterTagDropdownPosition:i})]}),wt=Object.assign(bt,{Button:ze,Filters:Re}),St=({children:t,danger:r,active:o,...s})=>e.jsx(n.MenuItem,{...s,style:{borderRadius:"8px",color:o?"var(--mantine-color-blue-7)":r?"var(--mantine-color-red-9)":"var(--mantine-color-gray-9)",backgroundColor:o?"var(--mantine-color-blue-0)":"transparent",...s.style},children:t}),ye=({trigger:t,menuItems:r,children:o,...s})=>{const a=u.useRef(null),[i,c]=u.useState(0);return u.useEffect(()=>{a.current&&c(a.current.offsetWidth)},[t]),e.jsxs(n.Menu,{...s,children:[e.jsx(n.Menu.Target,{children:e.jsx("div",{ref:a,onClick:l=>l.stopPropagation(),style:{cursor:"pointer",outline:"none",boxShadow:"none",display:"flex",alignItems:"center"},children:t})}),e.jsxs(n.Menu.Dropdown,{styles:{dropdown:{cursor:"pointer",borderRadius:"8px",minWidth:`${i}px`}},children:[o,r==null?void 0:r.map((l,d)=>e.jsx(St,{...l},d))]})]})},Ye=({label:t,icon:r,onClick:o,color:s="gray",disabled:a=!1,"aria-label":i,indicator:c,fullWidth:l,isActive:d=!1,...f})=>{const[h,m]=u.useState(!1),x=()=>{a||o==null||o()};return e.jsx(n.Box,{style:{cursor:a?"not-allowed":"pointer",borderRadius:"var(--mantine-radius-md)"},variant:"transparent",justify:"flex-start",display:"flex",color:s,radius:"md",w:l?"100%":"auto",px:6,h:40,onMouseEnter:()=>!a&&m(!0),onMouseLeave:()=>m(!1),onClick:x,bg:h||d?"gray.1":"transparent","aria-label":i||`${t} navigation button`,...f,children:e.jsxs(n.Group,{w:"100%",wrap:"nowrap",gap:8,justify:"left",align:"center",children:[e.jsx(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px"},children:r}),e.jsx(n.Text,{ta:"left",size:"sm",fw:600,c:"var(--mantine-color-gray-8)",truncate:!0,style:{flex:1,opacity:a?.5:1},children:t}),c&&e.jsx(n.Box,{style:{cursor:"pointer",backgroundColor:"var(--mantine-color-red-7)",color:"var(--mantine-color-white)",borderRadius:"var(--mantine-radius-lg)",padding:"0px 4px",fontSize:"12px",fontWeight:600,height:"20px",minWidth:"20px",display:"flex",alignItems:"center",justifyContent:"center"},children:c})]})})},_e=({label:t,rightLabel:r,children:o,onAddChild:s,onMenuAction:a,menuItems:i,color:c="gray",defaultText:l="No items",level:d=0,disabled:f=!1,noChild:h=!1,isActive:m=!1,showAvatar:x=!0,avatar:y,placeholder:p,onClick:I,"aria-label":g,...b})=>{const[v,S]=u.useState(!1),[w,T]=u.useState(!1),k=u.Children.count(o)>0,C=!h&&k&&(x?w:!0),j=u.useCallback(()=>{f||I==null||I()},[I,f]),R=u.useCallback(F=>{F.stopPropagation(),!f&&(s==null||s())},[s,f]),D=u.useCallback(F=>{F==null||F.stopPropagation(),!f&&k&&!h&&S(U=>!U)},[f,k,h]),O=u.useCallback(()=>{f||s==null||s()},[s,f]),E=u.useCallback(F=>{f||a==null||a(F)},[a,f,t]),H=u.useCallback(()=>k?u.Children.map(o,F=>u.isValidElement(F)?u.cloneElement(F,{...F.props,level:d+1}):F):null,[o,k,d]),$=(i==null?void 0:i.map(F=>({children:e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[F.icon&&e.jsx(F.icon,{size:16}),e.jsx(n.Text,{size:"sm",children:F.label})]}),onClick:()=>E(F.action)})))||[],W=[{children:e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[e.jsx(M.IconPlus,{size:16}),e.jsx(n.Text,{size:"sm",children:"Add child"})]}),onClick:R}],L=$.length>0?$:W;return e.jsxs(n.Stack,{gap:0,children:[e.jsx(n.Box,{style:{cursor:f?"not-allowed":"pointer",borderRadius:"8px"},variant:"transparent",justify:"space-between",display:"flex",color:c,size:"md",radius:"md",w:"100%",px:6,h:40,onMouseEnter:()=>!f&&T(!0),onMouseLeave:()=>T(!1),onClick:j,bg:m||w?"var(--mantine-color-gray-1)":"transparent","aria-expanded":v,"aria-label":g||`${t} navigation link`,...b,children:e.jsxs(n.Group,{w:"100%",wrap:"nowrap",gap:8,onClick:j,style:{paddingLeft:h&&!C?`${(d+1)*32}px`:d>0?`${d*32}px`:"0px"},children:[C?e.jsx(fe,{icon:v?M.IconChevronDown:M.IconChevronRight,iconOnHover:v?M.IconChevronDown:M.IconChevronRight,grayScaleBaseColor:w?1:0,color:"var(--mantine-color-gray-7)",onClick:D,disabled:f}):x?e.jsx(se,{size:"xs",avatar:y,showPlaceholder:!0,placeholder:p}):null,e.jsx(n.Text,{size:"sm",fw:600,c:"var(--mantine-color-gray-7)",truncate:!0,w:"100%",style:{opacity:f?.5:1},children:t}),e.jsxs(n.Group,{gap:"xs",align:"center",children:[r&&e.jsx(n.Text,{size:"xs",c:"dimmed",children:r}),w&&!f&&e.jsxs(n.Group,{gap:4,wrap:"nowrap",children:[s&&e.jsx(fe,{icon:M.IconPlus,grayScaleBaseColor:w?1:0,onClick:O,color:"var(--mantine-color-gray-7)"}),(i&&i.length>0||s)&&e.jsx("div",{onClick:F=>F.stopPropagation(),children:e.jsx(ye,{menuItems:L,trigger:e.jsx(fe,{icon:M.IconDots,grayScaleBaseColor:1,color:"var(--mantine-color-gray-7)"}),position:"bottom-end",shadow:"md"})})]})]})]})}),v&&!h&&e.jsx(n.Stack,{gap:0,style:{width:"100%"},children:k?H():e.jsx(n.Box,{style:{marginLeft:d>0?`${d*16}px`:"0px"},children:e.jsx(n.Text,{size:"sm",c:"dimmed",ta:"left",p:"sm",fw:500,children:l})})})]})},kt="userChip-module__pill___DgFME",Ct={pill:kt},Me=({avatar:t,name:r,withRemoveButton:o=!1,onRemove:s})=>e.jsx(n.Pill,{withRemoveButton:o,onRemove:s,radius:"md",p:"0px",size:"md",className:Ct.pill,bg:"transparent",children:e.jsxs(n.Group,{gap:4,wrap:"nowrap",style:{alignItems:"center"},children:[e.jsx(se,{avatar:t,size:24,placeholder:r,showPlaceholder:!0}),e.jsx(n.Text,{size:"sm",fw:450,c:"var(--mantine-color-gray-9)",children:r})]})}),Mt="200px",Tt="4px 8px",Bt=40,Ot="var(--mantine-radius-md)",zt=16,hn=({item:t,withAvatars:r,disabled:o=!1,onClick:s,selected:a=!1})=>{const[i,c]=u.useState(!1);return e.jsx(n.Box,{onMouseEnter:()=>!o&&c(!0),onMouseLeave:()=>!o&&c(!1),onClick:l=>{l.preventDefault(),l.stopPropagation(),o||s==null||s(t.value)},onMouseDown:l=>{l.stopPropagation()},style:{minWidth:Mt,backgroundColor:o?"transparent":i?"var(--mantine-color-gray-1)":"transparent",cursor:o?"default":"pointer",borderRadius:Ot,padding:Tt,transition:"background-color 0.2s ease",opacity:o?.5:1},children:e.jsxs(n.Group,{gap:"sm",wrap:"nowrap",align:"flex-start",style:{alignItems:"center"},h:Bt,children:[r&&t.avatar&&e.jsx("img",{src:t.avatar,alt:t.label,style:{width:"24px",height:"24px",borderRadius:"var(--mantine-radius-sm)",objectFit:"cover"}}),e.jsxs(n.Stack,{gap:0,style:{flex:1},children:[e.jsx(n.Text,{size:"sm",fw:500,lh:-1,c:o?"var(--mantine-color-gray-5)":"var(--mantine-color-gray-9)",children:t.label}),e.jsx(n.Text,{size:"xs",c:o?"var(--mantine-color-gray-4)":"dimmed",children:t.description})]}),a&&e.jsx(M.IconCheck,{size:zt,color:"var(--mantine-color-gray-9)"})]})})},Rt="bottom-end",Dt=1e4,Et="24px",At="0 8px",Lt="6px",Je="var(--mantine-radius-md)",Ft="46px",De=({value:t,onChange:r,data:o,withRemove:s=!1,withAvatars:a=!1,onRemove:i,disabledOptions:c=[],disabled:l=!1,defaultOption:d,popoverStyles:f,dropdownStyles:h,triggerStyles:m,textStyles:x})=>{const[y,p]=u.useState(!1),I=(o||[]).find(j=>j.value===t)||d,[g,b]=u.useState(!1),[v,S]=u.useState(!1),[w,T]=u.useState(!1),k=s?e.jsx(n.Group,{p:"sm",onClick:j=>{j.stopPropagation(),i==null||i(t)},style:{cursor:"pointer",height:Ft,display:"flex",alignItems:"center",borderRadius:Je,backgroundColor:v?"var(--mantine-color-red-0)":"transparent",transition:"background-color 0.2s ease"},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:e.jsx(n.Text,{size:"sm",c:"var(--mantine-color-red-6)",fw:500,children:"Remove user"})}):null,C=e.jsxs(n.Box,{onMouseEnter:()=>!l&&b(!0),onMouseLeave:()=>!l&&b(!1),onClick:()=>{l||(p(!0),T(!0))},style:{height:Et,cursor:l?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",borderRadius:Je,backgroundColor:l?"transparent":g||w?"var(--mantine-color-gray-1)":"transparent",transition:"background-color 0.2s ease",padding:At,gap:Lt,width:"auto",opacity:l?.6:1,...m},children:[e.jsx(n.Text,{size:"sm",fw:x!=null&&x.fontWeight?void 0:500,c:l?"var(--mantine-color-gray-4)":"var(--mantine-color-gray-6)",style:{color:l?"var(--mantine-color-gray-4)":"var(--mantine-color-gray-6)",lineHeight:"24px",whiteSpace:"nowrap",...x},children:(I==null?void 0:I.label)||"Select option"}),e.jsx(M.IconChevronDown,{size:16,style:{color:l?"var(--mantine-color-gray-3)":"var(--mantine-color-gray-6)"}})]});return e.jsxs(n.Popover,{opened:y,onChange:j=>{p(j),j||T(!1)},position:Rt,shadow:"md",withinPortal:!0,zIndex:Dt,styles:f,children:[e.jsx(n.Popover.Target,{children:C}),e.jsx(n.Popover.Dropdown,{onClick:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),styles:{dropdown:{borderRadius:"var(--mantine-radius-md)",padding:"4px",...h}},children:e.jsxs(n.Stack,{gap:0,onClick:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),children:[(o||[]).map(j=>{const R=c.includes(j.value),D=j.value===t;return e.jsx(hn,{item:j,withAvatars:a,disabled:R,selected:D,onClick:O=>{r==null||r(O),p(!1),T(!1)}},j.value)}),k]})})]})},Ut=(t,r,o,s)=>{const a=u.useRef(null),i=u.useRef(null),c=u.useCallback(d=>{d[0].isIntersecting&&o&&!s&&r&&r()},[o,s,r]),l=u.useCallback(()=>{if(!(!a.current||!t||!r)){i.current&&(i.current.disconnect(),i.current=null);try{const d=new IntersectionObserver(c,{threshold:.1,rootMargin:"50px"});d.observe(a.current),i.current=d}catch(d){console.error("Failed to setup intersection observer:",d)}}},[t,r,c]);return u.useEffect(()=>(l(),()=>{i.current&&(i.current.disconnect(),i.current=null)}),[l]),u.useEffect(()=>()=>{i.current&&(i.current.disconnect(),i.current=null)},[]),{loadMoreRef:a}},xn=({tableName:t,data:r,columns:o,onAddItem:s,addItemComponent:a,addItemLabel:i="Add item",loading:c=!1,emptyMessage:l="No data found",searchPlaceholder:d="Search...",enableAutoFilters:f=!0,customFilters:h=[],onCustomFilter:m,onSort:x,sortColumn:y,sortDirection:p,onSearch:I,onRowClick:g,size:b="md",striped:v=!1,highlightOnHover:S=!0,enableInfiniteScroll:w=!1,isLoadingMore:T=!1,hasMore:k=!1,onLoadMore:C})=>{const[j,R]=u.useState(""),[D,O]=u.useState([]),{loadMoreRef:E}=Ut(w,C||(()=>{}),k,T),H=u.useMemo(()=>[...f?o.filter(z=>z.type==="select"&&z.options).map(z=>({value:z.key,label:z.label})):[],...h],[o,f,h]),$=u.useMemo(()=>{let B=r||[];if(j){const z=j.toLowerCase();B=B.filter(A=>o.some(N=>{if(!N.searchable)return!1;const V=A[N.key];return V==null?!1:String(V).toLowerCase().includes(z)}))}return D.forEach(z=>{if(z.filterTag.selectedOption){const A=o.find(N=>N.key===z.filterTag.filterOption.value);A&&(B=B.filter(N=>{var ne;const V=N[A.key];return String(V)===((ne=z.filterTag.selectedOption)==null?void 0:ne.value)}))}}),B},[r,j,D,o]),W=B=>{R(B),I==null||I(B)},L=B=>{const z=o.find(N=>N.key===B);if(!(z!=null&&z.sortable))return;const A=y===B&&p==="asc"?"desc":"asc";x==null||x(B,A)},F=B=>{const z=o.find(A=>A.key===B);return(z==null?void 0:z.type)==="select"&&z.options?z.options.map(A=>({value:A.value,label:A.label})):(z==null?void 0:z.type)==="badge"?[...new Set(r.map(N=>N[z.key]).filter(Boolean))].map(N=>({value:String(N),label:String(N).charAt(0).toUpperCase()+String(N).slice(1)})):z?[...new Set(r.map(N=>N[z.key]).filter(Boolean))].map(N=>({value:String(N),label:String(N).charAt(0).toUpperCase()+String(N).slice(1)})):[]},U=(B,z)=>{var N,V,ne,P,oe;const A=z[B.key];switch(B.type){case"text":return e.jsx(n.Text,{size:"sm",c:A?void 0:"dimmed",children:A||"—"});case"date":if(!A)return e.jsx(n.Text,{size:"sm",c:"dimmed",children:"—"});const X=new Date(A),de=B.format?X.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):X.toLocaleDateString();return e.jsx(n.Text,{size:"sm",c:"dimmed",children:de});case"select":return B.options?e.jsx(De,{value:A,data:B.options,placeholder:B.label,onChange:re=>{var me;return(me=B.onSelectChange)==null?void 0:me.call(B,re,z)},disabled:(N=B.disabled)==null?void 0:N.call(B,z)}):e.jsx(n.Text,{size:"sm",c:"dimmed",children:"—"});case"badge":const Ae=((V=B.badgeColors)==null?void 0:V[A])||"gray";return e.jsx(n.Badge,{color:Ae,variant:"light",size:"sm",radius:"md",fw:600,children:A||"Unknown"});case"avatar":const Le=((ne=B.fallbackText)==null?void 0:ne.call(B,z))||String(A).charAt(0).toUpperCase();return e.jsx(se,{avatar:A,size:"xs",placeholder:Le,showPlaceholder:!0});case"custom":return((P=B.render)==null?void 0:P.call(B,A,z))||e.jsx(n.Text,{size:"sm",c:"dimmed",children:"—"});case"actions":return(oe=B.actions)!=null&&oe.length?e.jsxs(n.Menu,{shadow:"md",width:200,position:"bottom-end",styles:{dropdown:{borderRadius:"var(--mantine-radius-md)"}},children:[e.jsx(n.Menu.Target,{children:e.jsx(n.ActionIcon,{variant:"subtle",size:"md",color:"gray",radius:"md",children:e.jsx(M.IconDots,{size:16})})}),e.jsx(n.Menu.Dropdown,{children:B.actions.map((re,me)=>{var be;return e.jsx(n.Menu.Item,{color:re.color,leftSection:re.icon,disabled:(be=re.disabled)==null?void 0:be.call(re,z),onClick:()=>re.onClick(z),styles:{item:{borderRadius:"var(--mantine-radius-md)"}},children:re.label},me)})})]}):null;default:return e.jsx(n.Text,{size:"sm",c:"dimmed",children:"—"})}},Z=B=>{var z;return(z=o.find(A=>A.key===B))!=null&&z.sortable?y===B?p==="asc"?e.jsx(M.IconChevronUp,{size:14}):e.jsx(M.IconChevronDown,{size:14}):e.jsx(M.IconChevronUp,{size:14,style:{opacity:.3}}):null},G=(()=>{switch(b){case"sm":return{buttonSize:"xs",textSize:"sm"};case"lg":return{buttonSize:"md",textSize:"md"};default:return{buttonSize:"sm",textSize:"sm"}}})();return e.jsxs(n.Box,{pos:"relative",children:[e.jsx(n.LoadingOverlay,{visible:c}),e.jsxs(n.Stack,{gap:"sm",w:"100%",children:[e.jsxs(n.Group,{gap:"sm",wrap:"nowrap",justify:"space-between",children:[e.jsx(n.Text,{fw:600,c:"var(--mantine-color-gray-8)",children:t}),e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[e.jsxs(n.Group,{gap:4,wrap:"nowrap",children:[e.jsx(fn,{placeholder:d,value:j,onChange:W,onSearch:W,expandDirection:"right",size:G.buttonSize}),H.length>0&&e.jsx(ze,{activeFilters:D.map(B=>B.filterTag),onFiltersChange:B=>{O(B.map(z=>({filterTag:z,onUpdate:()=>{},onRemove:()=>{}}))),m==null||m(B)},availableFilters:H,size:G.buttonSize})]}),s&&e.jsx(n.Button,{size:"compact-md",h:32,style:{fontSize:`var(--mantine-font-size-${G.textSize})`,border:"none"},radius:"md",onClick:s,children:i})]})]}),H.length>0&&e.jsx(Re,{activeFilters:D.map(B=>B.filterTag),onFiltersChange:B=>{O(B.map(z=>({filterTag:z,onUpdate:()=>{},onRemove:()=>{}}))),m==null||m(B)},availableFilters:H,size:"md",getFilterOptions:F})]}),a,e.jsxs(n.Table,{striped:v,highlightOnHover:S,highlightOnHoverColor:"var(--mantine-color-gray-0)",mt:"xs",children:[e.jsx(n.Table.Thead,{children:e.jsx(n.Table.Tr,{children:o.map(B=>e.jsx(n.Table.Th,{c:"var(--mantine-color-gray-6)",style:{width:B.width,textAlign:B.align||"left",cursor:B.sortable?"pointer":"default"},onClick:()=>B.sortable&&L(B.key),children:e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[B.icon&&e.jsx(n.Box,{style:{display:"flex",alignItems:"center"},children:B.icon}),e.jsx(n.Text,{size:G.textSize,fw:500,children:B.label}),Z(B.key)]})},String(B.key)))})}),e.jsx(n.Table.Tbody,{children:$.length===0?e.jsx(n.Table.Tr,{children:e.jsx(n.Table.Td,{colSpan:o.length,ta:"center",py:"xl",children:e.jsx(n.Text,{c:"dimmed",children:l})})}):$.map((B,z)=>e.jsx(n.Table.Tr,{style:{cursor:g?"pointer":"default"},onClick:()=>g==null?void 0:g(B),children:o.map(A=>e.jsx(n.Table.Td,{style:{textAlign:A.align||"left"},children:U(A,B)},String(A.key)))},B.id||z))})]}),w&&e.jsx(n.Box,{ref:E,style:{padding:"16px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:"60px"},children:T&&e.jsxs(n.Group,{display:"flex",ta:"center",gap:"xs",children:[e.jsx(n.Loader,{size:"sm",color:"gray.5"}),e.jsx(n.Text,{size:"sm",c:"dimmed",fw:500,children:"Loading more..."})]})})]})};Object.assign(xn,{});const Nt=({onAvatarSelect:t,onEmojiSelect:r,onImageSelect:o,onIconSelect:s}={})=>{const[a,i]=u.useState("emoji"),[c,l]=u.useState(null),[d,f]=u.useState(null),[h,m]=u.useState(null),[x,y]=u.useState(null),[p,I]=u.useState(null),g=u.useCallback(j=>{i(j)},[]),b=u.useCallback(j=>{l(j)},[]),v=u.useCallback(j=>{I(j);const R=new FileReader;R.onload=D=>{var E;const O=(E=D.target)==null?void 0:E.result;f(O)},R.readAsDataURL(j)},[]),S=u.useCallback(j=>{m(j),f(null),I(null),y(null),t==null||t({type:"emoji",value:j}),r==null||r(j)},[t,r]),w=u.useCallback(j=>{y(j),f(null),I(null),m(null),t==null||t({type:"icon",value:j}),s==null||s(j)},[t,s]),T=u.useCallback(()=>{if(p&&d){const j=URL.createObjectURL(p);t==null||t({type:"image",value:j}),o==null||o(p)}},[p,d,t,o]),k=u.useCallback(()=>{f(null),I(null),m(null),y(null)},[]),C=u.useCallback(()=>{f(null),m(null),y(null),I(null),i("emoji"),l(null)},[]);return{selectedTab:a,tabHovered:c,previewImage:d,selectedEmoji:h,selectedIcon:x,selectedFile:p,handleTabChange:g,handleTabHover:b,handleImagePreview:v,handleImageAccept:T,handleEmojiSelect:S,handleIconSelect:w,clearImagePreview:k,resetState:C}},Wt=({opened:t,onClose:r,popoverRef:o})=>{const s=u.useCallback(i=>{t&&o.current&&!o.current.contains(i.target)&&(console.log("Click outside detected, closing popover"),r())},[t,r,o]),a=u.useCallback(i=>{i.key==="Escape"&&t&&(console.log("Escape key pressed, closing popover"),r())},[t,r]);return u.useEffect(()=>{if(t)return document.addEventListener("mousedown",s),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",a)}},[t,s,a]),{handleClickOutside:s,handleEscape:a}},$t=({selectedTab:t,tabHovered:r,onTabChange:o,onTabHover:s,onRemove:a,hasAvatar:i=!1,children:c})=>{const[l,d]=u.useState(!1);return e.jsxs(n.Tabs,{color:"black",value:t,styles:{tab:{backgroundColor:"transparent"}},children:[e.jsxs(n.Tabs.List,{px:"var(--mantine-spacing-sm)",pt:"xs",w:"100%",children:[e.jsx(n.Tabs.Tab,{value:"emoji",p:0,pb:"xs",onClick:()=>o("emoji"),onMouseEnter:()=>s("emoji"),onMouseLeave:()=>s(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{borderRadius:"var(--mantine-radius-md)",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",border:"none",backgroundColor:r==="emoji"?"var(--mantine-color-gray-1)":"transparent",color:t==="emoji"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:e.jsx(n.Group,{gap:4,children:"Emoji"})})}),e.jsx(n.Tabs.Tab,{value:"icons",p:0,pb:"xs",onClick:()=>o("icons"),onMouseEnter:()=>s("icons"),onMouseLeave:()=>s(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",borderRadius:"var(--mantine-radius-md)",border:"none",backgroundColor:r==="icons"?"var(--mantine-color-gray-1)":"transparent",color:t==="icons"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:e.jsx(n.Group,{gap:4,children:"Icons"})})}),e.jsx(n.Tabs.Tab,{value:"image",p:0,pb:"xs",onClick:()=>o("image"),onMouseEnter:()=>s("image"),onMouseLeave:()=>s(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",borderRadius:"var(--mantine-radius-md)",border:"none",backgroundColor:r==="image"?"var(--mantine-color-gray-1)":"transparent",color:t==="image"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:e.jsx(n.Group,{gap:4,children:"Image"})})}),a&&i&&e.jsx(n.Group,{justify:"flex-end",display:"flex",flex:1,pb:"xs",children:e.jsx(n.Box,{style:{height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",borderRadius:"var(--mantine-radius-md)",border:"none",backgroundColor:l?"var(--mantine-color-red-0)":"transparent",color:l?"var(--mantine-color-red-6)":"var(--mantine-color-gray-6)",cursor:"pointer",transition:"all 0.1s ease"},fw:500,fz:"var(--mantine-font-size-sm)",onClick:a,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:"Remove"})})]}),e.jsx(n.Tabs.Panel,{value:"emoji",children:t==="emoji"?c:null}),e.jsx(n.Tabs.Panel,{value:"icons",children:t==="icons"?c:null}),e.jsx(n.Tabs.Panel,{value:"image",children:t==="image"?c:null})]})};let en=!1;en||(tn.init({data:Te}),en=!0);const Pt=()=>{const t=[{id:"frequent",name:"Frequently Used",icon:e.jsx(M.IconClock,{size:20,strokeWidth:2.5})}];return Te.categories.forEach(r=>{if(r.emojis&&r.emojis.length>0){let o=e.jsx(M.IconMoodSmile,{size:20,strokeWidth:2}),s=r.name;switch(r.id){case"people":o=e.jsx(M.IconMoodSmile,{size:20,strokeWidth:2}),s="Smileys & People";break;case"nature":o=e.jsx(M.IconTrees,{size:20,strokeWidth:2}),s="Animals & Nature";break;case"foods":o=e.jsx(M.IconApple,{size:20,strokeWidth:2}),s="Food & Drink";break;case"activity":o=e.jsx(M.IconBallBasketball,{size:20,strokeWidth:2}),s="Activities";break;case"travel":o=e.jsx(M.IconPlane,{size:20,strokeWidth:2}),s="Travel & Places";break;case"places":o=e.jsx(M.IconPlane,{size:20,strokeWidth:2}),s="Travel & Places";break;case"objects":o=e.jsx(M.IconBulb,{size:20,strokeWidth:2}),s="Objects";break;case"symbols":o=e.jsx(M.IconHeart,{size:20,strokeWidth:2}),s="Symbols";break;case"flags":o=e.jsx(M.IconFlag,{size:20,strokeWidth:2}),s="Flags";break;case"frequent":return;default:o=e.jsx(M.IconMoodSmile,{size:20,strokeWidth:2}),s=`Category: ${r.id}`;break}t.push({id:r.id,name:s,icon:o})}}),t},Ht=({onEmojiSelect:t,height:r=200})=>{const[o,s]=u.useState(""),[a,i]=u.useState("people"),[c,l]=u.useState(()=>{if(typeof window<"u"){const g=localStorage.getItem("emoji-frequent");return g?JSON.parse(g):[]}return[]}),[d,f]=u.useState([]),[h,m]=u.useState(!1),x=Pt();u.useEffect(()=>{o.trim()?(m(!0),tn.SearchIndex.search(o).then(g=>{f(g.map(b=>({id:b.id,native:b.skins[0].native,name:b.name,keywords:b.keywords}))),m(!1)})):f([])},[o]);const y=u.useMemo(()=>{if(o.trim())return d;if(a==="frequent")return c.map(b=>({id:b,native:b,name:"",keywords:[]}));const g=Te.categories.find(b=>b.id===a);return g?g.emojis.map(b=>{const v=Te.emojis[b];return{id:v.id,native:v.skins[0].native,name:v.name,keywords:v.keywords}}):[]},[o,a,c,d]),p=g=>{t(g),l(b=>{const v=b.filter(w=>w!==g),S=[g,...v].slice(0,20);return typeof window<"u"&&localStorage.setItem("emoji-frequent",JSON.stringify(S)),S})},I=g=>{if(o.trim())return"Results";const b=x.find(v=>v.id===g);return b?b.name:g.charAt(0).toUpperCase()+g.slice(1)};return e.jsxs(n.Stack,{gap:0,style:{height:r,width:"100%"},children:[e.jsx(n.Box,{p:"sm",pb:"xs",children:e.jsxs(n.Stack,{gap:"xs",children:[e.jsx(n.TextInput,{placeholder:"Search emojis...",value:o,onChange:g=>s(g.target.value),leftSection:e.jsx(M.IconSearch,{size:16,strokeWidth:2.5}),fw:500,size:"sm",radius:"md",styles:{input:{backgroundColor:"var(--mantine-color-gray-0)",color:"var(--mantine-color-gray-9)"}}}),e.jsx(n.Text,{size:"sm",c:"var(--mantine-color-gray-6)",ta:"left",fw:500,children:I(a)})]})}),e.jsx(n.Box,{style:{flex:1,overflow:"hidden"},children:e.jsx(n.ScrollArea,{h:"100%",type:"hover",offsetScrollbars:!1,children:e.jsx(n.Box,{style:{display:"grid",gridTemplateColumns:"repeat(9, 1fr)",gap:"0px",padding:"0px 12px 12px 12px"},children:h?e.jsx(n.Text,{size:"sm",c:"dimmed",ta:"center",py:"xl",style:{gridColumn:"1 / -1"},children:"Searching..."}):y.length>0?y.map(g=>e.jsx(n.Tooltip,{label:g.name||g.id,position:"top",withArrow:!0,openDelay:300,withinPortal:!0,zIndex:1e3,color:"dark",children:e.jsx(n.Button,{variant:"subtle",size:"sm",p:0,onClick:()=>p(g.native),style:{width:"40px",height:"40px",fontSize:"22px",border:"none",backgroundColor:"transparent",borderRadius:"var(--mantine-radius-md)",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:b=>{b.currentTarget.style.backgroundColor="var(--mantine-color-gray-1)"},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="transparent"},children:g.native})},g.id)):e.jsx(n.Text,{size:"sm",c:"dimmed",ta:"center",py:"xl",style:{gridColumn:"1 / -1"},children:"No emojis found"})})})}),e.jsx(n.Box,{px:"sm",py:"xs",style:{borderTop:"1px solid var(--mantine-color-gray-3)"},children:e.jsx(n.Flex,{gap:"0px",justify:"center",wrap:"wrap",children:x.map(g=>e.jsx(n.Tooltip,{label:g.name,position:"top",withArrow:!0,openDelay:500,withinPortal:!0,zIndex:1e3,color:"dark",children:e.jsx(n.Box,{onClick:()=>{i(g.id),s("")},style:{width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"var(--mantine-radius-md)",cursor:"pointer","&:hover":{backgroundColor:"var(--mantine-color-gray-0)"},backgroundColor:a===g.id?"var(--mantine-color-gray-0)":"transparent",color:a===g.id?"var(--mantine-color-blue-6)":"var(--mantine-color-gray-6)",transition:"all 0.1s ease"},onMouseEnter:b=>{b.currentTarget.style.backgroundColor="var(--mantine-color-gray-1)"},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="transparent"},children:g.icon})},g.id))})})]})},pn=["IconUser","IconUserCircle","IconUserCheck","IconUserX","IconUserPlus","IconUserMinus","IconUserEdit","IconUserCog","IconUserShield","IconUserStar","IconUserSearch","IconUserQuestion","IconUserOff","IconUsers","IconUserBolt","IconUserCode","IconUserDollar","IconUserExclamation","IconUserFilled","IconUserHexagon","IconUserKey","IconUserPause","IconUserPin","IconUserPlay","IconUserScan","IconUserShare","IconUserSquare","IconUserUp","IconUserVoice","IconUserWrench"],mn=["IconBriefcase","IconBuilding","IconBuildingStore","IconBuildingBank","IconBuildingWarehouse","IconBuildingSkyscraper","IconBuildingBridge","IconBuildingCar","IconBuildingFactory","IconBuildingHospital","IconBuildingMonument","IconBuildingPavilon","IconBuildingTunnel","IconBuildingWindmill","IconChartBar","IconChartLine","IconChartPie","IconChartDots","IconChartArea","IconChartArcs","IconChartCandle","IconChartDonut","IconChartRadar","IconTrendingUp","IconTrendingDown","IconTarget","IconFlag","IconTrophy","IconAward","IconMedal","IconCertificate","IconBadge","IconCrown","IconStar","IconStarFilled","IconStarHalf","IconStarOff","IconFileText","IconFile","IconFileAlert","IconFileAnalytics","IconFileBarcode","IconFileBroken","IconFileCertificate","IconFileChart","IconFileCheck","IconFileCode","IconFileDatabase","IconFileDollar","IconFileDownload","IconFileEuro","IconFileExport","IconFileFunction","IconFileImport","IconFileInfo","IconFileInvoice","IconFileLambda","IconFileLike","IconFileMinus","IconFileMusic","IconFileOff","IconFilePencil","IconFilePhone","IconFilePlus","IconFileReport","IconFileRss","IconFileScissors","IconFileSearch","IconFileSettings","IconFileShredder","IconFileSignal","IconFileSpreadsheet","IconFileStar","IconFileSymlink","IconFileTime","IconFileType","IconFileTypography","IconFileUnknown","IconFileUpload","IconFileVector","IconFileX","IconFileZip","IconFolder","IconFolderOpen","IconFolderPlus","IconFolderMinus","IconFolderX","IconFolderCheck","IconFolderCog","IconFolderDown","IconFolderHeart","IconFolderOff","IconFolderPause","IconFolderPin","IconFolderQuestion","IconFolderSearch","IconFolderShare","IconFolderStar","IconFolderUp","IconFolderWrench","IconArchive","IconArchiveOff","IconBox","IconBoxMultiple","IconBoxOff","IconBoxPadding","IconBoxSeam","IconBriefcaseOff","IconClipboard","IconClipboardCheck","IconClipboardCopy","IconClipboardData","IconClipboardHeart","IconClipboardList","IconClipboardOff","IconClipboardPaste","IconClipboardText","IconClipboardTypography","IconClipboardX","IconCopy","IconCut","IconPaste","IconDuplicate","IconEdit","IconEditCircle","IconEditCircleOff"],gn=["IconDeviceDesktop","IconDeviceLaptop","IconDeviceMobile","IconDeviceTablet","IconDeviceWatch","IconDeviceTv","IconDeviceGamepad","IconDeviceAirpods","IconDeviceImac","IconDeviceIpad","IconDeviceIphone","IconDeviceMacbook","IconDeviceNintendo","IconDevicePlaystation","IconDeviceXbox","IconCode","IconTerminal","IconDatabase","IconServer","IconWifi","IconBluetooth","IconCpu","IconKeyboard","IconMouse","IconCamera","IconVideo","IconMicrophone","IconSpeaker","IconHeadphones","IconPrinter","IconScanner","IconRouter","IconModem","IconAntenna","IconSatellite","IconRadar","IconRadar2","IconBroadcast","IconBroadcastOff","IconRadio","IconRadioactive","IconRadioactiveOff","IconSignal","IconSignal4G","IconSignal5G","IconSignalOff","IconBattery","IconBattery1","IconBattery2","IconBattery3","IconBattery4","IconBatteryOff","IconBatteryCharging","IconBatteryAutomotive","IconBatteryEco","IconBatteryFilled","IconPlug","IconPlugConnected","IconPlugConnectedX","IconPlugOff","IconPlugX","IconPower","IconPowerOff","IconOutlet","IconCable","IconCableOff","IconCircuitAmmeter","IconCircuitBattery","IconCircuitBulb","IconCircuitCapacitor","IconCircuitCell","IconCircuitCellPlus","IconCircuitChangeover","IconCircuitDiode","IconCircuitDiodeZener","IconCircuitGround","IconCircuitGroundDigital","IconCircuitInductor","IconCircuitMotor","IconCircuitPushbutton","IconCircuitResistor","IconCircuitSwitchClosed","IconCircuitSwitchOpen","IconCircuitVoltmeter","IconCpu2","IconCpuOff","IconMemory","IconMemoryCard","IconMemoryStick","IconHardDrive","IconHardDrive2","IconDisk","IconDiskOff","IconCd","IconCdOff","IconDvd","IconDvdOff","IconFloppyDisk","IconFloppyDiskOff","IconUsb","IconUsbOff","IconSdCard","IconSdCardOff","IconCloud","IconCloudComputing","IconCloudDataConnection","IconCloudDownload","IconCloudLock","IconCloudOff","IconCloudRain","IconCloudSnow","IconCloudStorm","IconCloudUpload","IconCloudCheck","IconCloudCode","IconCloudCog","IconCloudDollar","IconCloudDown","IconCloudExclamation","IconCloudHeart","IconCloudMinus","IconCloudPause","IconCloudPin","IconCloudPlus","IconCloudQuestion","IconCloudSearch","IconCloudShare","IconCloudStar","IconCloudUp","IconCloudX"],In=["IconMoodSmile","IconMoodHappy","IconMoodWink","IconMoodSad","IconMoodConfused","IconMoodAnnoyed","IconMoodAngry","IconMoodCry","IconMoodTongue","IconMoodKiss","IconMoodHeart","IconMoodLove","IconMoodEmpty","IconMoodNervous","IconMoodSuprised","IconMoodSilence","IconMoodSick","IconMoodTongueWink","IconMoodTongueWink2","IconMoodWink2","IconHeart","IconHeartFilled","IconHeartBroken","IconHeartHandshake","IconHeartMinus","IconHeartOff","IconHeartPlus","IconHeartRateMonitor","IconThumbUp","IconThumbDown","IconSmile","IconFrown","IconMeh","IconLaugh","IconWink","IconKiss","IconTongue","IconGrin","IconSmirk"],yn=["IconTrees","IconLeaf","IconFlower","IconPlant","IconSun","IconMoon","IconStar","IconCloud","IconCloudRain","IconCloudSnow","IconSnowflake","IconDroplet","IconFlame","IconMountain","IconTree","IconPineTree","IconBug","IconButterfly","IconFish","IconBird","IconCat","IconDog","IconRabbit","IconPaw","IconPawprint","IconFeather","IconSeeding","IconSeedingOff","IconPlant2","IconPlantOff","IconLeafOff","IconFlower2","IconFlowerOff","IconTreesOff","IconTreeOff","IconPineTreeOff","IconPalmTree","IconPalmTreeOff","IconSunOff","IconSunHigh","IconSunLow","IconMoonOff","IconMoonStars","IconMoon2","IconMoonFilled","IconStars","IconStarsOff","IconStarFilled","IconStarHalf","IconStarOff","IconCloudOff","IconCloudStorm","IconCloudFog","IconCloudWind","IconSnowflakeOff","IconDropletOff","IconDropletFilled","IconDropletHalf","IconDropletHalf2","IconDropletHalfFilled","IconFlameOff","IconFire","IconFireExtinguisher","IconMountainOff","IconMountain2","IconHills","IconHillsOff","IconValley","IconValleyOff","IconBugOff","IconButterflyOff","IconBee","IconBeeOff","IconSpider","IconSpiderOff","IconAnt","IconAntOff","IconLadybug","IconLadybugOff","IconGrasshopper","IconGrasshopperOff","IconCricket","IconCricketOff","IconFishOff","IconFishBone","IconFishBoneOff","IconShark","IconSharkOff","IconWhale","IconWhaleOff","IconDolphin","IconDolphinOff","IconOctopus","IconOctopusOff","IconSeahorse","IconSeahorseOff","IconBirdOff","IconEagle","IconEagleOff","IconOwl","IconOwlOff","IconParrot","IconParrotOff","IconPeacock","IconPeacockOff","IconPenguin","IconPenguinOff","IconSwan","IconSwanOff","IconCatOff","IconDogOff","IconRabbitOff","IconFeatherOff","IconWing","IconWingOff","IconEgg","IconEggOff","IconEggCracked","IconEggCrackedOff","IconEggFilled","IconEggFilledOff","IconEggFried","IconEggFriedOff","IconNest","IconNestOff","IconNestEggs","IconNestEggsOff"],vn=["IconCircle","IconSquare","IconTriangle","IconDiamond","IconHexagon","IconPentagon","IconOctagon","IconCross","IconPlus","IconMinus","IconCheck","IconX","IconArrowUp","IconArrowDown","IconArrowLeft","IconArrowRight","IconArrowUpLeft","IconArrowUpRight","IconArrowDownLeft","IconArrowDownRight","IconArrowLeftUp","IconArrowLeftDown","IconArrowRightUp","IconArrowRightDown","IconPlay","IconPause","IconStop","IconRecord","IconSkipBack","IconSkipForward","IconRewind","IconFastForward","IconCircleDot","IconCircleFilled","IconCircleHalf","IconCircleHalf2","IconCircleHalfFilled","IconCircleOff","IconCircleX","IconSquareDot","IconSquareFilled","IconSquareHalf","IconSquareHalfFilled","IconSquareOff","IconSquareRounded","IconSquareRoundedDot","IconSquareRoundedFilled","IconSquareRoundedHalf","IconSquareRoundedHalfFilled","IconSquareRoundedOff","IconSquareRoundedX","IconSquareX","IconTriangleFilled","IconTriangleInverted","IconTriangleInvertedFilled","IconTriangleOff","IconTriangleSquare","IconTriangleSquareCircle","IconDiamondFilled","IconDiamondOff","IconHexagonFilled","IconHexagonOff","IconPentagonFilled","IconPentagonOff","IconOctagonFilled","IconOctagonOff","IconCrossOff","IconPlusMinus","IconMinusMinus","IconCheckbox","IconCheckboxOff","IconChecks","IconXbox","IconXboxOff","IconYinYang","IconYinYangOff","IconYoga","IconYogaOff","IconZodiac","IconZodiacOff","IconZoom","IconZoomCancel","IconZoomCode","IconZoomExclamation","IconZoomFilled","IconZoomIn","IconZoomInArea","IconZoomInAreaFilled","IconZoomInFilled","IconZoomMoney","IconZoomPan","IconZoomQuestion","IconZoomReplace","IconZoomReset","IconZoomScan","IconZoomScanFilled","IconZoomX"],jn=["IconEdit","IconDelete","IconSave","IconOpen","IconClose","IconAdd","IconRemove","IconSearch","IconFilter","IconSort","IconRefresh","IconReload","IconUndo","IconRedo","IconCut","IconCopy","IconPaste","IconDuplicate","IconMove","IconRotate","IconFlip","IconResize","IconScale","IconCrop","IconTransform","IconWrench","IconHammer","IconScrewdriver","IconTool","IconTools","IconSaw","IconDrill","IconDrillOff","IconAxe","IconAxeOff","IconPickaxe","IconPickaxeOff","IconShovel","IconShovelOff","IconRake","IconRakeOff","IconHoe","IconHoeOff","IconScythe","IconScytheOff","IconPitchfork","IconPitchforkOff","IconFork","IconForkOff","IconKnife","IconKnifeOff","IconSword","IconSwordOff","IconDagger","IconDaggerOff","IconSpear","IconSpearOff","IconBow","IconBowOff","IconArrow","IconArrowOff","IconCrossbow","IconCrossbowOff","IconGun","IconGunOff","IconPistol","IconPistolOff","IconRifle","IconRifleOff","IconShotgun","IconShotgunOff","IconBomb","IconBombOff","IconGrenade","IconGrenadeOff","IconDynamite","IconDynamiteOff","IconMine","IconMineOff","IconTorpedo","IconTorpedoOff","IconMissile","IconMissileOff","IconRocket","IconRocketOff","IconBazooka","IconBazookaOff","IconCannon","IconCannonOff","IconTank","IconTankOff","IconHelicopter","IconHelicopterOff","IconPlane","IconPlaneOff","IconJet","IconJetOff","IconSatellite","IconSatelliteOff","IconSpace","IconSpaceOff","IconGalaxy","IconGalaxyOff","IconPlanet","IconPlanetOff","IconEarth","IconEarthOff","IconMoon","IconMoonOff","IconSun","IconSunOff","IconStar","IconStarOff","IconAsteroid","IconAsteroidOff","IconComet","IconCometOff","IconMeteor","IconMeteorOff","IconUfo","IconUfoOff","IconAlien","IconAlienOff","IconRobot","IconRobotOff","IconAndroid","IconAndroidOff","IconIos","IconIosOff","IconWindows","IconWindowsOff","IconLinux","IconLinuxOff","IconMac","IconMacOff","IconUbuntu","IconUbuntuOff","IconDebian","IconDebianOff","IconRedhat","IconRedhatOff","IconCentos","IconCentosOff","IconFedora","IconFedoraOff","IconSuse","IconSuseOff","IconArch","IconArchOff","IconGentoo","IconGentooOff","IconSlackware","IconSlackwareOff","IconMint","IconMintOff","IconKali","IconKaliOff","IconParrot","IconParrotOff","IconBacktrack","IconBacktrackOff","IconBlackarch","IconBlackarchOff","IconPentoo","IconPentooOff","IconMatriux","IconMatriuxOff","IconNodezero","IconNodezeroOff","IconBugtraq","IconBugtraqOff","IconCyborg","IconCyborgOff","IconDefensive","IconDefensiveOff","IconDracos","IconDracosOff","IconFembuntu","IconFembuntuOff","IconGnacktrack","IconGnacktrackOff","IconHackintosh","IconHackintoshOff","IconHak5","IconHak5Off","IconHavij","IconHavijOff","IconJackal","IconJackalOff","IconKnoppix","IconKnoppixOff","IconKodachi","IconKodachiOff","IconLion","IconLionOff","IconMandriva","IconMandrivaOff","IconMobily","IconMobilyOff","IconMuslim","IconMuslimOff","IconNetrunner","IconNetrunnerOff","IconPardus","IconPardusOff","IconQubes","IconQubesOff","IconSabayon","IconSabayonOff","IconScientific","IconScientificOff","IconSemplice","IconSempliceOff","IconSiduction","IconSiductionOff","IconSlax","IconSlaxOff","IconSli","IconSliOff","IconTails","IconTailsOff","IconVector","IconVectorOff","IconVoid","IconVoidOff","IconWhonix","IconWhonixOff","IconZorin","IconZorinOff","IconAlpine","IconAlpineOff","IconElementary","IconElementaryOff","IconManjaro","IconManjaroOff","IconOpenbsd","IconOpenbsdOff","IconOpenSuse","IconOpenSuseOff","IconPop","IconPopOff","IconSolus","IconSolusOff"],bn=["IconMessage","IconMessageCircle","IconMessageDots","IconMessagePlus","IconMessageReport","IconMessageShare","IconMessageText","IconMessages","IconMessagesOff","IconMail","IconMailOpened","IconMailFast","IconMailOff","IconMailPause","IconMailPin","IconMailPlus","IconMailQuestion","IconMailSearch","IconMailShare","IconMailStar","IconMailUp","IconMailX","IconPhone","IconPhoneCall","IconPhoneIncoming","IconPhoneOff","IconPhoneOutgoing","IconPhonePause","IconPhonePlus","IconPhoneX","IconVideo","IconVideoOff","IconVideoPlus","IconCamera","IconCameraOff","IconCameraPlus","IconMicrophone","IconMicrophoneOff","IconMicrophone2","IconMicrophone2Off","IconHeadphones","IconHeadphonesOff","IconSpeaker","IconSpeakerOff","IconBroadcast","IconBroadcastOff","IconRadio","IconRadioactive","IconRadioactiveOff","IconAntenna","IconAntennaBars1","IconAntennaBars2","IconAntennaBars3","IconAntennaBars4","IconAntennaBars5","IconAntennaOff","IconSatellite","IconSatelliteOff","IconWifi","IconWifi0","IconWifi1","IconWifi2","IconWifiOff","IconBluetooth","IconBluetoothConnected","IconBluetoothOff","IconBluetoothX","IconShare","IconShareOff","IconShare2","IconShare3","IconAt","IconHash","IconLink","IconLinkOff","IconExternalLink","IconExternalLinkOff","IconSend","IconSendOff","IconSend2","IconReceipt","IconReceiptOff","IconReceipt2","IconReceiptRefund","IconReceiptTax","IconReceiptEuro","IconReceiptDollar","IconReceiptPound","IconReceiptYen","IconReceiptYuan","IconReceiptWon","IconReceiptRupee","IconReceiptBaht","IconReceiptLira","IconReceiptRuble","IconReceiptShekel","IconReceiptTaka","IconReceiptHryvnia","IconReceiptKrone","IconReceiptKrona","IconReceiptZloty","IconReceiptForint","IconReceiptLeu","IconReceiptLev","IconReceiptKuna","IconReceiptDinar","IconReceiptDirham","IconReceiptRial","IconReceiptRiyal","IconReceiptAfghani","IconReceiptAriary","IconReceiptCedi","IconReceiptDalasi","IconReceiptFranc","IconReceiptGourde","IconReceiptKina","IconReceiptKip","IconReceiptKwacha","IconReceiptKwanza","IconReceiptLari","IconReceiptLek","IconReceiptLilangeni","IconReceiptLoti","IconReceiptManat","IconReceiptMetical","IconReceiptNaira","IconReceiptPeso","IconReceiptPula","IconReceiptRand","IconReceiptRupiah","IconReceiptShilling","IconReceiptSom","IconReceiptSomoni","IconReceiptTenge","IconReceiptVatu","IconReceiptWon","IconReceiptXof","IconReceiptYuan","IconReceiptZloty"];[...pn,...mn,...gn,...In,...yn,...vn,...jn,...bn];const ge=[{id:"recent",name:"Recently Used",icons:[],isDynamic:!0},{id:"user",name:"User & Profile",icons:pn},{id:"business",name:"Business & Work",icons:mn},{id:"tech",name:"Technology",icons:gn},{id:"expressions",name:"Expressions",icons:In},{id:"nature",name:"Nature & Animals",icons:yn},{id:"shapes",name:"Shapes & Symbols",icons:vn},{id:"actions",name:"Actions & Tools",icons:jn},{id:"communication",name:"Communication",icons:bn}],Gt={recent:e.jsx(M.IconClock,{size:20,strokeWidth:2.5}),user:e.jsx(M.IconUser,{size:20,strokeWidth:2.5}),business:e.jsx(M.IconBriefcase,{size:20,strokeWidth:2.5}),tech:e.jsx(M.IconDeviceDesktop,{size:20,strokeWidth:2.5}),expressions:e.jsx(M.IconMoodSmile,{size:20,strokeWidth:2.5}),nature:e.jsx(M.IconTrees,{size:20,strokeWidth:2.5}),shapes:e.jsx(M.IconCircle,{size:20,strokeWidth:2.5}),actions:e.jsx(M.IconTool,{size:20,strokeWidth:2.5}),communication:e.jsx(M.IconMessage,{size:20,strokeWidth:2.5})},Vt=({selectedCategory:t,onCategoryChange:r})=>e.jsx(n.Flex,{gap:"0px",justify:"center",wrap:"wrap",children:ge.map(o=>{const s=Gt[o.id];return e.jsx(n.Tooltip,{label:o.name,position:"top",withArrow:!0,openDelay:500,withinPortal:!0,zIndex:1e3,color:"dark",children:e.jsx(n.Box,{onClick:()=>r(o.id),style:{width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"var(--mantine-radius-md)",cursor:"pointer",backgroundColor:t===o.id?"var(--mantine-color-gray-0)":"transparent",color:t===o.id?"var(--mantine-color-blue-6)":"var(--mantine-color-gray-6)",transition:"all 0.2s ease"},onMouseEnter:a=>{a.currentTarget.style.backgroundColor="var(--mantine-color-gray-1)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor=t===o.id?"var(--mantine-color-gray-0)":"transparent"},children:s})},o.id)})}),wn=u.memo(({onIconSelect:t,height:r=358})=>{var g,b;const[o,s]=u.useState(""),[a,i]=u.useState("recent"),[c,l]=u.useState(!1),[d,f]=u.useState([]);u.useLayoutEffect(()=>{if(typeof window<"u"){const v=localStorage.getItem("avatar-icon-recent");if(v)try{f(JSON.parse(v))}catch(S){console.warn("Error parsing recent icons from localStorage:",S)}}},[]);const h=u.useMemo(()=>ge.filter(v=>v.id!=="recent"&&!("isDynamic"in v)).flatMap(v=>v.icons),[]),m=u.useMemo(()=>{if(a==="recent"){const S=new Set(h);return d.filter(w=>S.has(w))}const v=ge.find(S=>S.id===a);return(v==null?void 0:v.icons)||[]},[a,d,h]),x=u.useCallback((v,S)=>{if(!v.trim())return S;const w=v.toLowerCase().trim(),T=w.split(/\s+/);return S.filter(k=>{const j=k.replace(/^Icon/,"").split(/(?=[A-Z])/).map(R=>R.toLowerCase().trim()).filter(R=>R.length>0);return!!(j.some(R=>T.some(D=>R===D))||w.length>2&&j.some(R=>T.some(D=>R.startsWith(D)))||w.length<=2&&j.some(R=>T.some(D=>R.includes(D)))||T.length>1&&T.every(R=>j.some(D=>D===R||D.startsWith(R))))})},[]),y=u.useMemo(()=>o.trim()?x(o,h):m,[o,m,h,x]),p=u.useCallback(v=>{h.includes(v)&&f(w=>{const T=[v,...w.filter(k=>k!==v)].slice(0,20);return typeof window<"u"&&localStorage.setItem("avatar-icon-recent",JSON.stringify(T)),T}),t(v)},[t,h]),I=u.useCallback(v=>{a!==v&&(s(""),i(v),requestAnimationFrame(()=>{l(!0),setTimeout(()=>l(!1),100)}))},[a]);return e.jsxs(n.Stack,{gap:0,style:{height:r,width:"100%"},children:[e.jsx(n.Box,{p:"sm",pb:"xs",children:e.jsxs(n.Stack,{gap:"xs",children:[e.jsx(n.TextInput,{placeholder:o.trim()?"Search all icons...":`Search in ${(g=ge.find(v=>v.id===a))==null?void 0:g.name}...`,value:o,onChange:v=>s(v.target.value),leftSection:e.jsx(M.IconSearch,{size:16}),fw:500,size:"sm",radius:"md",styles:{input:{backgroundColor:"var(--mantine-color-gray-0)",color:"var(--mantine-color-gray-9)"}}}),e.jsx(n.Text,{size:"sm",c:"var(--mantine-color-gray-6)",ta:"left",fw:500,children:o.trim()?"Results":(b=ge.find(v=>v.id===a))==null?void 0:b.name})]})}),e.jsx(n.Box,{style:{flex:1,overflow:"hidden"},children:e.jsx(n.ScrollArea,{h:"100%",type:"hover",children:e.jsx(n.Box,{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:"4px",padding:"0 12px 12px 12px",opacity:c?.7:1,transition:"opacity 0.05s ease"},children:y.map(v=>e.jsx(rn,{iconName:v,onClick:()=>p(v),size:20},o.trim()?`search-${v}`:`${a}-${v}`))},`${a}-${o}`)})}),e.jsx(n.Box,{px:"sm",py:"xs",style:{borderTop:"1px solid var(--mantine-color-gray-3)"},children:e.jsx(Vt,{selectedCategory:a,onCategoryChange:I})})]})});wn.displayName="IconGrid";const _t=({previewImage:t,fileInputRef:r,selectedEmoji:o,size:s,loading:a,onFileInputClick:i,onImageChange:c,onImageAccept:l,onClearImagePreview:d})=>e.jsx(n.Box,{p:"sm",style:{width:"384px"},children:e.jsxs(n.Stack,{gap:"md",align:"center",children:[t||o?e.jsxs(n.Box,{children:[e.jsx(n.Text,{size:"sm",fw:500,mb:"xs",children:"Preview"}),e.jsx(n.Avatar,{src:t,radius:"md",style:{width:`${xe(s)}px !important`,height:`${xe(s)}px !important`,minWidth:`${xe(s)}px`,minHeight:`${xe(s)}px`,maxWidth:`${xe(s)}px`,maxHeight:`${xe(s)}px`,border:"1px solid var(--mantine-color-gray-4)",objectFit:"cover",boxSizing:"border-box"},children:o})]}):e.jsx(n.Button,{variant:"subtle",bg:"gray.0",styles:{root:{height:"64px"}},leftSection:e.jsx(M.IconPhoto,{size:20}),onClick:i,loading:a,disabled:a,fullWidth:!0,children:"Choose Image"}),t||o?e.jsx(n.Button,{variant:"outline",leftSection:e.jsx(M.IconPhoto,{size:16}),onClick:i,loading:a,disabled:a,fullWidth:!0,children:t||o?"Change Image":"Choose Image"}):null,e.jsx("input",{ref:r,type:"file",accept:"image/jpeg,image/jpg,image/png,image/gif,image/webp",onChange:f=>{var h;return c(((h=f.target.files)==null?void 0:h[0])||null)},style:{display:"none"},disabled:a}),(t||o)&&e.jsxs(n.Group,{gap:"sm",w:"100%",children:[e.jsx(n.Button,{variant:"outline",color:"gray",onClick:d,fullWidth:!0,children:"Back"}),e.jsx(n.Button,{color:"blue",onClick:l,loading:a,disabled:a,fullWidth:!0,children:"Accept"})]}),e.jsx(n.Text,{size:"xs",c:"var(--mantine-color-gray-6)",ta:"center",children:"Supported formats: JPG, PNG, GIF, WebP"})]})}),Qt=({onEmojiSelect:t})=>e.jsx(Ht,{onEmojiSelect:t,height:358}),Yt=({onIconSelect:t})=>e.jsx(wn,{onIconSelect:t,height:358}),qt=({previewImage:t,selectedEmoji:r,size:o,loading:s,onFileInputClick:a,onImageChange:i,onImageAccept:c,onClearImagePreview:l,fileInputRef:d})=>e.jsx(_t,{previewImage:t,fileInputRef:d,selectedEmoji:r,size:o,loading:s,onFileInputClick:a,onImageChange:i,onImageAccept:c,onClearImagePreview:l}),Zt=()=>e.jsx(n.Box,{style:{width:400,height:358,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs(n.Stack,{align:"center",gap:"sm",children:[e.jsx(n.Loader,{size:"sm"}),e.jsx(n.Text,{size:"sm",c:"gray.6",children:"Loading avatar options..."})]})}),Ee=({editable:t=!0,opened:r,onOpen:o,onClose:s,avatar:a,onAvatarSelect:i,onRemove:c,size:l="lg",loading:d=!1,placeholder:f,showPlaceholder:h=!0,position:m="bottom-start",withinPortal:x=!0,zIndex:y=1e3})=>{const p=u.useRef(null),I=u.useRef(null),g=u.useRef(null),{selectedTab:b,tabHovered:v,previewImage:S,selectedEmoji:w,selectedIcon:T,selectedFile:k,handleTabChange:C,handleTabHover:j,handleImagePreview:R,handleImageAccept:D,handleEmojiSelect:O,handleIconSelect:E,clearImagePreview:H,resetState:$}=Nt({onAvatarSelect:i});Wt({opened:r,onClose:s,popoverRef:I}),u.useEffect(()=>{r||$()},[r,$]);const W=X=>{console.log("Emoji clicked:",X),O(X),s()},L=X=>{console.log("Icon clicked:",X),E(X),s()},F=X=>{X&&R(X)},U=()=>{k?(D(),s()):(w||T)&&s()},Z=()=>{p.current&&p.current.click()},_=()=>{H()},G=()=>{console.log("Avatar removed"),c==null||c(),s()},B=()=>!!a,z=()=>d?e.jsx(Be,{size:l,loading:!0}):e.jsx(se,{avatar:a,size:l,placeholder:f,showPlaceholder:h,editable:!0,onClick:()=>{!d&&!r&&o()}}),A=e.jsx(Qt,{onEmojiSelect:W}),N=e.jsx(Yt,{onIconSelect:L}),V=e.jsx(qt,{previewImage:S,selectedEmoji:w,size:l,loading:d,onFileInputClick:Z,onImageChange:F,onImageAccept:U,onClearImagePreview:_,fileInputRef:p}),ne=e.jsx(n.Box,{children:e.jsx($t,{selectedTab:b,tabHovered:v,onTabChange:C,onTabHover:j,onRemove:G,hasAvatar:B(),children:b==="emoji"?A:b==="icons"?N:V})}),P=e.jsx("div",{style:{position:"relative",display:"inline-block"},children:e.jsxs(n.Popover,{opened:r,onClose:()=>{console.log("Popover onClose called"),s()},position:m,withinPortal:x,withArrow:!0,shadow:"md",radius:"md",closeOnClickOutside:!1,closeOnEscape:!1,offset:8,children:[e.jsx(n.Popover.Target,{children:e.jsx("div",{ref:g,style:{position:"relative"},children:z()})}),e.jsx(n.Popover.Dropdown,{ref:I,p:0,style:{width:"auto",overflow:"hidden",zIndex:y},children:e.jsx(u.Suspense,{fallback:e.jsx(Zt,{}),children:ne})})]})}),oe=e.jsx(se,{avatar:a,size:l,placeholder:f,showPlaceholder:h});return e.jsx(e.Fragment,{children:t?P:oe})},Xt=t=>{if(!t||typeof t!="string")return!1;const r=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return t.length<5||t.length>254?!1:r.test(t.trim())},Kt=t=>{const r=[];return t.forEach(o=>{Xt(o)||r.push({email:o,error:"Please enter a valid email address"})}),{isValid:r.length===0,errors:r}},Jt=t=>{const r=[],o=new Set;return t.forEach(s=>{const a=s.toLowerCase().trim();o.has(a)?r.push({email:s,error:"This email has already been added"}):o.add(a)}),r},eo=t=>{const r=Kt(t),o=Jt(t),s=[...r.errors,...o];return{isValid:s.length===0,errors:s}},no=({value:t,onChange:r,onInputChange:o,suggestedUsers:s=[],tagDisplayMap:a={}})=>{const[i,c]=u.useState(""),[l,d]=u.useState([]),f=u.useRef(null),h=t.map(I=>{if(a[I])return a[I];const g=s.find(b=>b.email===I);return g&&g.name?g.name:I});u.useEffect(()=>{o&&o(i)},[i,o]),u.useEffect(()=>{if(t.length>0){const I=eo(t);d(I.errors)}else d([])},[t]),u.useEffect(()=>{const I=f.current;if(!I)return;let g;const b=v=>{const w=v.target.value||"";clearTimeout(g),g=setTimeout(()=>{c(w)},150)};return I.addEventListener("input",b),()=>{I.removeEventListener("input",b),clearTimeout(g)}},[]);const m=u.useCallback(I=>{const g=s.map(v=>({name:v.name||v.email,email:v.email})),b=I.map(v=>{const S=g.find(w=>w.name.toLowerCase()===v.toLowerCase());return S?S.email:v}).filter(v=>v.includes("@")?!0:!g.some(w=>{const T=w.name.toLowerCase(),k=v.toLowerCase();return T.startsWith(k)&&k!==T}));r(b),c("")},[r,s]),x=u.useCallback(()=>{f.current&&(f.current.value="",c(""))},[]),y=l.length===0&&t.length>0,p=u.useCallback((I,g,b)=>{I&&t.length>0&&g&&(I(t,g,b),c(""))},[t]);return{inputText:i,tagsInputRef:f,displayValue:h,validationErrors:l,isValid:y,handleEmailChange:m,clearInput:x,handleInvite:p}},Sn=({onInvite:t,onUpdateRole:r,onRemoveUser:o,invitedUsers:s=[],suggestedUsers:a=[],roleOptions:i=[]})=>{const[c,l]=u.useState([]),[d,f]=u.useState([]),[h,m]=u.useState(""),[x,y]=u.useState({}),p=i.length>0?i[0].value:void 0,[I,g]=u.useState(p);u.useEffect(()=>{i.length>0&&!I&&g(i[0].value)},[i.length,I]),u.useEffect(()=>{const O=a.filter(E=>c.includes(E.email)).map(E=>E.id);f(E=>E.filter(H=>O.includes(H)))},[c,a.length]);const[b,v]=u.useState("invite"),[S,w]=u.useState(null),T=(O,E,H)=>{t&&t(O,E,H),l([]),m("")},k=(O,E)=>{r&&r(O,E)},C=O=>{o&&o(O)},j=O=>{f(E=>E.includes(O)?E.filter(H=>H!==O):[...E,O])},R=O=>{c.includes(O.email)||(l([...c,O.email]),y(E=>({...E,[O.email]:O.name||O.email})),d.includes(O.id)||f([...d,O.id]),m(""))},D=h.trim()?a.filter(O=>{var H;const E=h.toLowerCase();return O.email.toLowerCase().includes(E)||((H=O.name)==null?void 0:H.toLowerCase().includes(E))}):[];return{emails:c,setEmails:l,selectedUsers:d,setSelectedUsers:f,inputText:h,setInputText:m,tagDisplayMap:x,setTagDisplayMap:y,selectedRole:I,setSelectedRole:g,selectedTab:b,setSelectedTab:v,tabHovered:S,setTabHovered:w,filteredUsers:D,handleInvite:T,handleUpdateRole:k,handleRemoveUser:C,handleToggleUser:j,handleAddSuggestedUser:R}},kn=u.forwardRef(({value:t,onChange:r,placeholder:o="Add one or more emails",onInvite:s,roleOptions:a=[],selectedRole:i,onRoleChange:c,onInputChange:l,suggestedUsers:d=[],tagDisplayMap:f={}},h)=>{const[m,x]=u.useState("Hello, I would like to invite you to join my workspace"),{tagsInputRef:y,displayValue:p,validationErrors:I,isValid:g,handleEmailChange:b,clearInput:v,handleInvite:S}=no({value:t,onChange:r,onInputChange:l,suggestedUsers:d,tagDisplayMap:f}),w=()=>{S(s,i,m),x("")};u.useImperativeHandle(h,()=>({clearInput:v}),[v]);const T=p.length>0,k=c&&a.length>0,C=I.length>0;return e.jsxs(n.Stack,{gap:"md",children:[e.jsxs(n.Box,{children:[e.jsx(n.Box,{style:{maxHeight:"120px",overflowY:"auto",overflowX:"hidden",paddingRight:"8px",marginRight:"-8px"},children:e.jsx(n.TagsInput,{ref:y,value:p,onChange:b,placeholder:T?"":o,radius:"md",rightSection:k?e.jsx(n.Box,{style:{position:"absolute",right:"8px",top:"17px",transform:"translateY(-50%)",height:"24px",display:"flex",alignItems:"center"},children:e.jsx(De,{value:i||"",onChange:j=>c(j),data:a,placeholder:"Select role",defaultOption:a[a.length-1],disabledOptions:["owner"]})}):null,rightSectionProps:{style:{width:k?"120px":"0px",position:"absolute",height:"32px",right:"8px"}},styles:{input:{paddingRight:k?"130px":"12px",minHeight:"36px",display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px",borderRadius:"var(--mantine-radius-md)",border:C?"2px solid var(--mantine-color-red-6)":"2px solid var(--mantine-color-blue-7)",backgroundColor:"var(--mantine-color-gray-0)"},pillsList:{height:"24px !important",borderRadius:"var(--mantine-radius-md) !important"},pill:{height:"24px !important",borderRadius:"var(--mantine-radius-md) !important",backgroundColor:C?"var(--mantine-color-red-1) !important":"var(--mantine-color-orange-1) !important",color:C?"var(--mantine-color-red-7) !important":"var(--mantine-color-gray-7) !important",fontSize:"var(--mantine-font-size-sm)"}}})}),C&&e.jsx(n.Stack,{gap:"xs",mt:"xs",children:I.map((j,R)=>e.jsxs(n.Text,{size:"xs",c:"red",children:[j.email,": ",j.error]},R))})]}),T&&e.jsxs(n.Stack,{gap:"sm",children:[e.jsx(n.Textarea,{size:"sm",value:m,onChange:j=>x(j.currentTarget.value),minRows:2,maxRows:4,radius:"md"}),e.jsx(n.Button,{variant:"filled",color:"blue",onClick:w,fullWidth:!0,radius:"md",disabled:!g,children:"Send invitations"})]})]})}),to=t=>{switch(t){case"member":return"green";case"invited":return"orange";case"declined":return"red";case"revoked":return"red";case"expired":return"red";default:return"gray"}},oo=t=>{switch(t){case"member":return"Member";case"invited":return"Invited";case"declined":return"Declined";case"revoked":return"Revoked";case"expired":return"Expired";default:return"Unknown"}},ro=t=>{if(t){if(typeof t=="object"&&"type"in t)return t;if(typeof t=="string")return{type:"image",value:t}}},ve=({user:t,isSelected:r=!1,onToggle:o,onUpdateRole:s,onRemoveUser:a,roleOptions:i=[],variant:c="invited",onClick:l})=>{var g;const d=((g=t.name)==null?void 0:g.trim())||t.email,f=()=>{o&&o(t.id)},h=b=>{if(s){const v=b;s(t.id,v)}},m=c==="suggested"||c==="read-only",x=c==="invited"&&i.length>0,[y,p]=u.useState(!1),I=()=>{l==null||l()};return e.jsxs(n.Group,{justify:"space-between",align:"center",wrap:"nowrap",w:"100%",style:{cursor:"pointer",borderRadius:"var(--mantine-radius-md)",padding:"6px"},onClick:I,bg:y?"var(--mantine-color-gray-0)":"transparent",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[e.jsxs(n.Group,{gap:"sm",w:"100%",align:"flex-start",wrap:"nowrap",children:[e.jsx(se,{avatar:ro(t.avatar),size:"md",placeholder:d,showPlaceholder:!0}),e.jsxs(n.Stack,{gap:0,w:"100%",justify:"flex-start",align:"flex-start",children:[e.jsxs(n.Group,{gap:"sm",align:"flex-start",wrap:"nowrap",children:[e.jsxs(n.Group,{gap:"sm",align:"flex-start",wrap:"nowrap",children:[e.jsx(n.Text,{size:"sm",fw:500,lineClamp:1,mb:-2,children:d}),t.isCurrentUser&&e.jsx(n.Badge,{size:"xs",variant:"light",color:"gray",radius:"sm",children:"Owner"})]}),t.status!=="member"&&e.jsx(n.Badge,{size:"xs",variant:"light",color:to(t.status),radius:"sm",children:oo(t.status)})]}),e.jsx(n.Text,{size:"xs",c:"dimmed",lineClamp:1,children:t.email})]})]}),e.jsxs(n.Group,{gap:"sm",align:"center",children:[m&&c!=="read-only"&&e.jsx(n.Radio,{checked:r,onChange:f,size:"sm",onClick:b=>b.stopPropagation(),pr:4}),x&&!t.isCurrentUser&&e.jsx(De,{value:t.role,onChange:h,data:i,placeholder:"Select role",defaultOption:i.find(b=>b.value===t.role),withRemove:!0,onRemove:()=>a==null?void 0:a(t.id)})]})]})},Cn=({opened:t,onClose:r,onInvite:o,onUpdateRole:s,onRemoveUser:a,invitedUsers:i=[],children:c,roleOptions:l=[],suggestedUsers:d=[]})=>{const f=u.useRef(null),{emails:h,setEmails:m,selectedUsers:x,inputText:y,setInputText:p,tagDisplayMap:I,selectedRole:g,setSelectedRole:b,selectedTab:v,setSelectedTab:S,tabHovered:w,setTabHovered:T,filteredUsers:k,handleInvite:C,handleUpdateRole:j,handleRemoveUser:R,handleToggleUser:D,handleAddSuggestedUser:O}=Sn({onInvite:o,onUpdateRole:s,onRemoveUser:a,invitedUsers:i,suggestedUsers:d,roleOptions:l}),E=L=>{O(L),f.current&&f.current.clearInput()},H=e.jsxs(e.Fragment,{children:[e.jsx(kn,{ref:f,value:h,onChange:m,onInvite:C,roleOptions:l,selectedRole:g,onRoleChange:b,onInputChange:p,suggestedUsers:d,tagDisplayMap:I}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.ScrollArea,{mah:200,type:"auto",style:{overflow:"visible"},children:e.jsx(n.Box,{children:i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(n.Text,{size:"sm",fw:500,children:"Already members"}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.Stack,{gap:"sm",children:i.map(L=>e.jsx(ve,{user:L,isSelected:x.includes(L.id),onToggle:D,onUpdateRole:j,onRemoveUser:R,roleOptions:l,variant:"invited"},L.id))})]})})}),k.length>0&&e.jsx(n.ScrollArea,{pt:"sm",mah:200,type:"auto",style:{overflow:"visible"},children:e.jsx(n.Box,{children:k.length>0?e.jsxs(e.Fragment,{children:[e.jsxs(n.Text,{size:"sm",fw:500,children:["Suggested ",y.trim()&&`(filtered by "${y}")`]}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.Stack,{gap:"sm",children:k.map(L=>e.jsx(ve,{user:L,isSelected:x.includes(L.id),onToggle:D,onUpdateRole:j,onRemoveUser:R,roleOptions:l,variant:"suggested",onClick:()=>E(L)},L.id))})]}):null})})]}),$=e.jsx(e.Fragment,{children:e.jsxs(n.Stack,{gap:"md",p:"sm",children:[e.jsxs(n.Stack,{gap:4,align:"center",children:[e.jsx(n.Text,{size:"sm",fw:500,ta:"center",children:"Publish to the web"}),e.jsx(n.Text,{size:"sm",fw:500,color:"var(--mantine-color-gray-6)",ta:"center",children:"Anyone with the link can view this page"})]}),e.jsx(n.Button,{variant:"filled",size:"xs",radius:"md",fw:500,fz:"var(--mantine-font-size-sm)",ta:"center",children:"Publish"})]})}),W=e.jsx(n.Box,{style:{width:"400px",maxHeight:"600px",overflow:"visible"},children:e.jsx(n.Stack,{gap:"lg",children:e.jsxs(n.Tabs,{color:"black",defaultValue:"invite",styles:{tab:{backgroundColor:"transparent"}},children:[e.jsxs(n.Tabs.List,{px:"var(--mantine-spacing-sm)",pt:"xs",children:[e.jsx(n.Tabs.Tab,{value:"invite",p:0,pb:6,onClick:()=>{S("invite")},onMouseEnter:()=>T("invite"),onMouseLeave:()=>T(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{borderRadius:"var(--mantine-radius-md)",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",border:"none",backgroundColor:w==="invite"?"var(--mantine-color-gray-1)":"transparent",color:v==="invite"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:"Invite"})}),e.jsx(n.Tabs.Tab,{value:"publish",p:0,pb:6,onClick:()=>{S("publish")},onMouseEnter:()=>T("publish"),onMouseLeave:()=>T(null),style:{backgroundColor:"transparent"},children:e.jsx(n.Box,{style:{height:"24px",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 8px",borderRadius:"var(--mantine-radius-md)",border:"none",backgroundColor:w==="publish"?"var(--mantine-color-gray-1)":"transparent",color:v==="publish"?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-6)",cursor:"pointer"},fw:500,fz:"var(--mantine-font-size-sm)",children:"Publish"})})]}),e.jsx(n.Tabs.Panel,{value:"invite",children:e.jsx(n.Box,{p:"sm",children:H})}),e.jsx(n.Tabs.Panel,{value:"publish",children:e.jsx(n.Box,{p:"sm",children:$})})]})})});return e.jsx(ye,{trigger:c,menuItems:[],opened:t,onClose:r,styles:{dropdown:{padding:"0",borderRadius:"var(--mantine-radius-md)"}},children:W})},so=({onInvite:t,onUpdateRole:r,onRemoveUser:o,invitedUsers:s,currentUser:a,roleOptions:i,suggestedUsers:c,label:l="Share"})=>{const[d,f]=u.useState(!1),h=()=>f(!1),m=e.jsx(Oe,{label:l,onClick:()=>f(!0),isActive:d});return e.jsx(Cn,{opened:d,onClose:h,onInvite:t,onUpdateRole:r,onRemoveUser:o,invitedUsers:s,currentUser:a,roleOptions:i,suggestedUsers:c,children:m})},ao=({opened:t,onClose:r,onInvite:o,onUpdateRole:s,onRemoveUser:a,invitedUsers:i=[],roleOptions:c=[],suggestedUsers:l=[]})=>{const d=u.useRef(null),{emails:f,setEmails:h,selectedUsers:m,inputText:x,setInputText:y,tagDisplayMap:p,selectedRole:I,setSelectedRole:g,filteredUsers:b,handleInvite:v,handleUpdateRole:S,handleRemoveUser:w,handleToggleUser:T,handleAddSuggestedUser:k}=Sn({onInvite:o,onUpdateRole:s,onRemoveUser:a,invitedUsers:i,suggestedUsers:l,roleOptions:c}),C=j=>{k(j),d.current&&d.current.clearInput()};return e.jsx(n.Modal,{opened:t,onClose:r,size:"md",withCloseButton:!1,radius:"md",centered:!0,closeOnClickOutside:!1,closeOnEscape:!0,trapFocus:!1,zIndex:300,children:e.jsxs(n.Stack,{gap:"lg",children:[e.jsxs(n.Group,{justify:"space-between",wrap:"nowrap",children:[e.jsx(n.Text,{size:"md",fw:500,c:"var(--mantine-color-gray-8)",children:"Share"}),e.jsx(ee,{icon:M.IconX,size:"md",onClick:r,color:"var(--mantine-color-gray-8)"})]}),e.jsx(kn,{ref:d,value:f,onChange:h,onInvite:v,roleOptions:c,selectedRole:I,onRoleChange:g,onInputChange:y,suggestedUsers:l,tagDisplayMap:p}),i.length>0&&e.jsxs(n.Box,{children:[e.jsx(n.Text,{size:"sm",fw:500,children:"Already members"}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.Box,{style:{maxHeight:"200px",minHeight:"60px",overflowY:"auto",overflowX:"hidden",paddingRight:"8px",marginRight:"-8px"},children:e.jsx(n.Stack,{gap:"sm",children:i.map(j=>e.jsx(ve,{user:j,isSelected:m.includes(j.id),onToggle:T,onUpdateRole:S,onRemoveUser:w,roleOptions:c,variant:"invited"},j.id))})})]}),b.length>0&&e.jsxs(n.Box,{children:[e.jsxs(n.Text,{size:"sm",fw:500,children:["Suggested ",x.trim()&&`(filtered by "${x}")`]}),e.jsx(n.Space,{h:"sm"}),e.jsx(n.Box,{style:{maxHeight:"200px",minHeight:"60px",overflowY:"auto",overflowX:"hidden",paddingRight:"8px",marginRight:"-8px"},children:e.jsx(n.Stack,{gap:"sm",children:b.map(j=>e.jsx(ve,{user:j,isSelected:m.includes(j.id),onToggle:T,onUpdateRole:S,onRemoveUser:w,roleOptions:c,variant:"suggested",onClick:()=>C(j)},j.id))})})]})]})})},io=({opened:t,onClose:r,options:o=[],onSave:s,onCancel:a,groups:i=[],styles:c})=>{const[l,d]=u.useState("");u.useEffect(()=>{t&&o.length>0?d(o[0].id):t||d("")},[t,o]);const f=()=>{s&&s(),r()},h=()=>{a&&a(),r()},m=()=>{r()},x=o.find(y=>y.id===l);return e.jsxs(n.Modal,{opened:t,onClose:m,size:"90%",centered:!0,closeOnClickOutside:!0,closeOnEscape:!0,withCloseButton:!1,p:"none",styles:{body:{...c==null?void 0:c.body,padding:0,height:"80vh"}},radius:"md",children:[e.jsx(n.FocusTrap.InitialFocus,{}),e.jsxs(n.Box,{style:{display:"flex",height:"100%",...c==null?void 0:c.body},children:[e.jsx(n.Box,{style:{width:"240px",backgroundColor:"var(--mantine-color-gray-0)"},children:e.jsx(n.ScrollArea,{h:"100%",children:e.jsx(n.Stack,{gap:0,p:"sm",children:i.map(y=>e.jsx(n.Box,{mb:"md",children:e.jsxs(u.Fragment,{children:[e.jsx(n.Text,{size:"xs",fw:600,c:"dimmed",m:4,children:y}),o.filter(p=>p.group===y).map(p=>e.jsx(Ye,{label:p.label,icon:p.icon,onClick:()=>d(p.id),isActive:l===p.id},p.id))]},y)}))})})}),e.jsxs(n.Box,{style:{flex:1,display:"flex",flexDirection:"column"},children:[x?e.jsxs(e.Fragment,{children:[e.jsx(n.Box,{p:"md",children:e.jsx(n.Group,{gap:"md",wrap:"nowrap",children:e.jsxs(n.Stack,{gap:4,children:[e.jsx(n.Text,{size:"md",fw:600,children:x.alternateLabel||x.label}),x.description&&e.jsx(n.Text,{size:"sm",c:"var(--mantine-color-gray-6)",children:x.description})]})})}),e.jsx(n.ScrollArea,{style:{flex:1},children:e.jsx(n.Box,{px:"md",children:x.content})})]}):e.jsx(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:e.jsx(n.Text,{c:"var(--mantine-color-gray-6)",size:"lg",children:"Select an option from the sidebar"})}),(x==null?void 0:x.saveButton)&&e.jsx(n.Box,{p:"md",children:e.jsxs(n.Group,{justify:"flex-end",gap:"md",children:[e.jsx(n.Button,{variant:"subtle",onClick:h,color:"gray",children:"Cancel"}),e.jsx(n.Button,{onClick:f,color:"blue",children:"Save Changes"})]})})]})]})]})},co=(t,r="es")=>{const o=new Date,s=typeof t=="string"?new Date(t):t,a=Math.floor((o.getTime()-s.getTime())/1e3),i={es:{now:"ahora",seconds:"segundos",second:"segundo",minutes:"minutos",minute:"minuto",hours:"horas",hour:"hora",days:"días",day:"día",weeks:"semanas",week:"semana",months:"meses",month:"mes",years:"años",year:"año",ago:"hace"},en:{now:"now",seconds:"seconds",second:"second",minutes:"minutes",minute:"minute",hours:"hours",hour:"hour",days:"days",day:"day",weeks:"weeks",week:"week",months:"months",month:"month",years:"years",year:"year",ago:"ago"}},c=i[r]||i.en;if(a<5)return c.now;if(a<60)return r==="es"?`${c.ago} ${a} ${a===1?c.second:c.seconds}`:`${a} ${a===1?c.second:c.seconds} ${c.ago}`;const l=Math.floor(a/60);if(l<60)return r==="es"?`${c.ago} ${l} ${l===1?c.minute:c.minutes}`:`${l} ${l===1?c.minute:c.minutes} ${c.ago}`;const d=Math.floor(l/60);if(d<24)return r==="es"?`${c.ago} ${d} ${d===1?c.hour:c.hours}`:`${d} ${d===1?c.hour:c.hours} ${c.ago}`;const f=Math.floor(d/24);if(f<7)return r==="es"?`${c.ago} ${f} ${f===1?c.day:c.days}`:`${f} ${f===1?c.day:c.days} ${c.ago}`;const h=Math.floor(f/7);if(h<4)return r==="es"?`${c.ago} ${h} ${h===1?c.week:c.weeks}`:`${h} ${h===1?c.week:c.weeks} ${c.ago}`;const m=Math.floor(f/30);if(m<12)return r==="es"?`${c.ago} ${m} ${m===1?c.month:c.months}`:`${m} ${m===1?c.month:c.months} ${c.ago}`;const x=Math.floor(f/365);return r==="es"?`${c.ago} ${x} ${x===1?c.year:c.years}`:`${x} ${x===1?c.year:c.years} ${c.ago}`},lo=(t,r="es")=>{const o=typeof t=="string"?new Date(t):t,s={es:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],en:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},i=(s[r]||s.en)[o.getMonth()],c=o.getDate();return r==="es"?`${c} ${i}`:`${i} ${c}`},uo=t=>{const r=typeof t=="string"?new Date(t):t,o=new Date;return r.toDateString()===o.toDateString()},fo=t=>{const r=typeof t=="string"?new Date(t):t,o=new Date;return o.setDate(o.getDate()-1),r.toDateString()===o.toDateString()},ho=(t,r="es")=>uo(t)?r==="es"?"Hoy":"Today":fo(t)?r==="es"?"Ayer":"Yesterday":co(t,r),xo=({notification:t,message:r,markAsRead:o,archiveNotification:s,children:a,actions:i})=>{var h,m,x,y,p;const c=new Date().getTime()-new Date(t.timestamp).getTime()<6048e5?ho(t.timestamp,"en"):lo(t.timestamp,"en"),[l,d]=u.useState(!1),f=e.jsxs(n.Group,{bg:"var(--mantine-color-gray-1)",p:4,style:{borderRadius:"var(--mantine-radius-md)"},w:"auto",wrap:"nowrap",gap:0,children:[!t.isRead&&e.jsx(ee,{onClick:()=>o(t.id),icon:M.IconCheck}),!t.isArchived&&e.jsx(ee,{onClick:()=>s(t.id),icon:M.IconArchive})]});return e.jsxs(n.Box,{p:"sm",bg:l?"var(--mantine-color-gray-0)":"white",style:{cursor:"pointer",borderTop:"1px solid var(--mantine-color-gray-2)"},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[e.jsxs(n.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",style:{margin:0},children:[(h=t.metadata)!=null&&h.avatar_url?e.jsx(n.Avatar,{name:(m=t.metadata)==null?void 0:m.fullname,size:"sm",radius:"md",src:(x=t.metadata)==null?void 0:x.avatar_url}):e.jsx(dn,{size:"xs",showText:!1,radius:"xs"}),e.jsxs(n.Stack,{gap:"xs",justify:"flex-start",w:"100%",children:[e.jsx(n.Box,{fz:"sm",m:0,style:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden",textOverflow:"ellipsis",minHeight:"unset",height:"auto",whiteSpace:"normal",wordBreak:"break-word"},children:r}),e.jsxs(n.Text,{size:"xs",c:"dimmed",fw:500,style:{whiteSpace:"nowrap"},children:[t.category?((y=t.category)==null?void 0:y.charAt(0).toUpperCase())+((p=t.category)==null?void 0:p.slice(1)):""," ","• ",c]})]}),l?f:!t.isRead&&e.jsx(n.Indicator,{color:"var(--mantine-color-blue-6)",size:10,position:"top-end"})]}),a,i&&e.jsx(n.Group,{justify:"flex-start",align:"flex-start",gap:"xs",wrap:"nowrap",pl:36,pt:8,children:i})]})},po=(t,r,o,s,a)=>{const[i,c]=u.useState(!1),l=u.useRef(null),d=u.useRef(null),f=u.useRef(null);u.useEffect(()=>{c(t)},[t]);const h=u.useCallback(x=>{x[0].isIntersecting&&s&&!a&&o&&o()},[s,a,o]),m=u.useCallback(()=>{if(!(!l.current||!t||!r||!o)){d.current&&(d.current.disconnect(),d.current=null);try{const x=new IntersectionObserver(h,{threshold:.1,rootMargin:"50px"});x.observe(l.current),d.current=x}catch(x){console.error("Failed to setup intersection observer:",x)}}},[t,r,o,h]);return u.useEffect(()=>{if(f.current&&(clearTimeout(f.current),f.current=null),!t||!r||!o){d.current&&(d.current.disconnect(),d.current=null);return}if(!l.current){f.current=setTimeout(()=>m(),50);return}return m(),()=>{f.current&&(clearTimeout(f.current),f.current=null),d.current&&(d.current.disconnect(),d.current=null)}},[t,r,o,m]),u.useEffect(()=>()=>{f.current&&clearTimeout(f.current),d.current&&d.current.disconnect()},[]),{isActive:i,loadMoreRef:l}},mo=({notifications:t,isLoading:r=!1,isLoadingMore:o=!1,hasMore:s=!1,unreadCount:a=0,markAllAsRead:i,archiveAllNotifications:c,markAsRead:l,archiveNotification:d,loadMore:f,onFilterChange:h,currentFilter:m="all",customRenderer:x,opened:y=!1,onOpen:p=()=>{},onClose:I=()=>{},enableInfiniteScroll:g=!0})=>{const b=[{children:"Mark all as read",leftSection:e.jsx(M.IconChecklist,{size:16}),onClick:()=>i()},{children:"Archive all",leftSection:e.jsx(M.IconArchive,{size:16}),onClick:()=>c()}],v=[{children:"All",leftSection:e.jsx(M.IconChecklist,{size:16}),onClick:()=>h==null?void 0:h("all"),active:m==="all"},{children:"Unread",leftSection:e.jsx(M.IconChecklist,{size:16}),onClick:()=>h==null?void 0:h("unread"),active:m==="unread"},{children:"Archived",leftSection:e.jsx(M.IconArchive,{size:16}),onClick:()=>h==null?void 0:h("archived"),active:m==="archived"}],S=k=>x&&k.category&&["welcome","upgrade"].includes(k.category)?x(k,l,d):e.jsx(xo,{notification:k,markAsRead:l,archiveNotification:d,message:k.message,actions:k.actions},k.id),{isActive:w,loadMoreRef:T}=po(y,g,f||(()=>{}),s,o);return e.jsxs(e.Fragment,{children:[e.jsx(Ye,{isActive:w,icon:e.jsx(M.IconBell,{strokeWidth:2,size:20,color:"var(--mantine-color-gray-7)"}),onClick:()=>{y?I():p()},disabled:!1,variant:"subtle",color:"gray",fullWidth:!0,style:{borderRadius:"var(--mantine-radius-md)",cursor:"pointer"},label:"Inbox",indicator:a>0?a>99?"99+":a:void 0}),e.jsxs(n.Drawer,{opened:y,onClose:I,position:"left",size:400,style:{position:"relative",left:300,zIndex:0,borderLeft:"1px solid var(--mantine-color-gray-2)"},withCloseButton:!1,padding:0,withOverlay:!0,closeOnClickOutside:!0,closeOnEscape:!0,overlayProps:{backgroundOpacity:0,blur:0},children:[e.jsx(n.FocusTrap.InitialFocus,{}),e.jsxs(n.Box,{p:0,h:"100%",style:{display:"flex",flexDirection:"column"},children:[e.jsx(n.Box,{style:{position:"sticky",top:0,zIndex:10,backgroundColor:"var(--mantine-color-white)"},children:e.jsxs(n.Group,{justify:"space-between",align:"center",gap:"xs",style:{borderRadius:"var(--mantine-radius-md)"},px:"sm",py:"md",children:[e.jsx(n.Text,{size:"sm",fw:500,children:"Inbox"}),e.jsxs(n.Group,{gap:"xs",children:[e.jsx(ye,{position:"bottom-end",menuItems:v,trigger:e.jsx(ee,{icon:M.IconFilter})}),e.jsx(ye,{position:"bottom-end",menuItems:b,trigger:e.jsx(ee,{onClick:()=>{},icon:M.IconDots,changeIconOnHover:!0,iconHovered:M.IconDots})})]})]})}),e.jsxs(n.Box,{style:{flex:1,overflow:"auto"},children:[r&&t.length===0?e.jsx(n.Stack,{gap:0,w:"100%",h:"100%",justify:"center",align:"center",py:"xl",children:e.jsx(n.Loader,{})}):t.length>0?e.jsx(n.Stack,{gap:0,children:t.map(k=>S(k))}):e.jsxs(n.Stack,{gap:0,w:"100%",h:"100%",justify:"center",align:"center",py:"xl",children:[e.jsx(M.IconInbox,{size:24,color:"var(--mantine-color-gray-6)"}),e.jsx(n.Text,{size:"sm",fw:500,c:"dimmed",ta:"center",mt:"sm",children:"No new updates"})]}),e.jsx(n.Box,{ref:T,style:{padding:"16px",display:g?"flex":"none",justifyContent:"center",alignItems:"center",minHeight:"60px"},children:o&&e.jsxs(n.Group,{display:"flex",ta:"center",gap:"xs",children:[e.jsx(n.Loader,{size:"sm",color:"gray.5"}),e.jsx(n.Text,{size:"sm",c:"dimmed",fw:500,children:"Loading more ..."})]})}),o&&!g&&e.jsxs(n.Group,{display:"flex",ta:"center",gap:"xs",children:[e.jsx(n.Loader,{size:"sm",color:"gray.5"}),e.jsx(n.Text,{size:"sm",c:"dimmed",fw:500,children:"Loading more ..."})]}),!g&&s&&f&&e.jsx(n.Button,{color:"var(--mantine-color-gray-3)",variant:"subtle",onClick:f,loading:o,disabled:o,style:{alignSelf:"center"},children:o?"Loading...":"Load More"})]})]})]})]})},Qe=({header:t,body:r,footer:o,withBorder:s=!0,position:a="left",bg:i="var(--mantine-color-gray-0)"})=>{const[c,l]=u.useState(!1),d=()=>{if(!s)return{};const f="var(--mantine-color-gray-3)",h="1px";return a==="left"?{borderRight:`${h} solid ${f}`}:a==="right"?{borderLeft:`${h} solid ${f}`}:{}};return e.jsxs(n.Stack,{gap:"sm",h:"100%",p:"sm",bg:i,style:d(),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t&&e.jsx(n.Box,{children:typeof t=="function"?t({hovered:c}):t}),r&&e.jsx(n.Box,{style:{flex:1,minHeight:0,width:"100%",overflow:"hidden"},children:typeof r=="function"?r({hovered:c}):r}),o&&e.jsx(n.Box,{children:typeof o=="function"?o({hovered:c}):o})]})},Mn=u.createContext(void 0),go=({children:t})=>{const[r,{open:o,close:s}]=Ie.useDisclosure(!1),a={openedNotificationSidebar:r,openNotificationSidebar:o,closeNotificationSidebar:s};return e.jsx(Mn.Provider,{value:a,children:t})},Io=()=>{const t=u.useContext(Mn);if(t===void 0)throw new Error("useNavbar must be used within an NavbarProvider");return t},Tn=({workspace:t,currentUserId:r,currentWorkspaceId:o,onClick:s})=>{const a=o===t.id,i=r&&t.ownerId===r;return e.jsxs(n.Box,{onClick:s,style:{display:"flex",alignItems:"center",padding:"6px",borderRadius:"var(--mantine-radius-md)",cursor:"pointer",gap:"8px",width:"100%",boxSizing:"border-box"},onMouseEnter:c=>{c.currentTarget.style.backgroundColor="var(--mantine-color-gray-0)"},onMouseLeave:c=>{c.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(se,{size:"xs",avatar:typeof t.avatar=="string"?{type:"image",value:t.avatar}:t.avatar,placeholder:t.name,showPlaceholder:!0,style:{flexShrink:0}}),e.jsx(n.Text,{size:"sm",fw:500,c:"gray.9",truncate:!0,style:{flex:1,minWidth:0},children:t.name}),e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:"4px",flexShrink:0,paddingLeft:"8px"},children:[a&&e.jsx(M.IconCheck,{size:16,color:"var(--mantine-color-blue-6)"}),i&&e.jsx(n.Badge,{size:"xs",variant:"light",color:"yellow",radius:"sm",children:"Owner"})]})]})},yo="workspace-selector-module__menuItem___FSB6P",vo="workspace-selector-module__workspaceButton___-P6kp",jo="workspace-selector-module__workspaceText___YDAlj",bo="workspace-selector-module__scrollWrapper___MzrJY",Ve={menuItem:yo,workspaceButton:vo,workspaceText:jo,scrollWrapper:bo},wo=({workspaces:t=[],currentWorkspace:r,currentUserId:o,isLoading:s=!1,error:a=null,onWorkspaceSelect:i,onCreateWorkspace:c,emptyMessage:l="No workspaces found",loadingMessage:d="Loading workspaces...",errorMessage:f="Failed to load workspaces",className:h,onCloseSidebar:m,sidebarHovered:x=!1,children:y,menuItems:p})=>{const[I,g]=u.useState(!1),[b,v]=u.useState(""),S=u.useMemo(()=>b?t.filter(C=>{var j;return C.name.toLowerCase().includes(b.toLowerCase())||((j=C.ownerEmail)==null?void 0:j.toLowerCase().includes(b.toLowerCase()))}):t,[t,b]),w=C=>{i==null||i(C.id),g(!1),v("")};if(s)return e.jsxs(n.Group,{gap:"xs",children:[e.jsx(n.Loader,{size:"sm"}),e.jsx(n.Text,{size:"sm",c:"dimmed",children:d})]});if(a)return e.jsx(n.Alert,{color:"red",title:"Error",children:f});const[T,k]=u.useState(x);return t.length===0&&!s&&!a?e.jsx(n.Box,{children:e.jsx(n.Text,{size:"sm",c:"dimmed",children:l})}):e.jsxs(n.Menu,{opened:I,onOpen:()=>g(!0),onClose:()=>g(!1),position:"bottom-start",styles:{dropdown:{width:"350px",overflow:"hidden"}},withinPortal:!0,children:[e.jsx(n.Menu.Target,{children:e.jsx(n.Box,{w:"100%",onClick:()=>g(!I),style:{padding:"6px",display:"flex",alignItems:"center",borderRadius:"var(--mantine-radius-md)",cursor:"pointer"},className:`${Ve.workspaceButton} ${h||""}`,bg:T||I?"var(--mantine-color-gray-1)":"transparent",onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),children:e.jsx(n.Group,{gap:"xs",wrap:"nowrap",style:{width:"100%",overflow:"hidden"},children:r?e.jsxs(e.Fragment,{children:[e.jsx(se,{size:"xs",avatar:typeof r.avatar=="string"?{type:"image",value:r.avatar}:r.avatar,placeholder:r.name,showPlaceholder:!0,style:{flexShrink:0}}),e.jsx(n.Text,{size:"sm",fw:500,c:"gray.9",truncate:!0,style:{flex:1,minWidth:0},children:r.name}),e.jsxs(n.Group,{gap:4,wrap:"nowrap",style:{flexShrink:0},children:[e.jsx(fe,{icon:M.IconChevronDown,size:"md",onClick:()=>g(!I),grayScaleBaseColor:T?1:0}),(T||x)&&e.jsx(fe,{icon:M.IconChevronsLeft,size:"md",onClick:()=>{m==null||m()},grayScaleBaseColor:T?1:0})]})]}):e.jsx(n.Text,{size:"sm",c:"dimmed",children:"Select workspace"})})})}),e.jsx(n.Menu.Dropdown,{style:{borderRadius:"var(--mantine-radius-md)"},p:0,children:e.jsxs(n.Stack,{gap:0,children:[y,e.jsx(n.Menu.Divider,{style:{margin:"1px 0px"}}),e.jsx(n.Stack,{gap:0,px:4,children:S.length===0?e.jsx(n.Menu.Item,{disabled:!0,children:e.jsx(n.Text,{size:"sm",c:"dimmed",children:l})}):e.jsxs(e.Fragment,{children:[e.jsxs(n.Group,{justify:"space-between",align:"center",p:4,children:[e.jsx(n.Text,{size:"xs",c:"dimmed",fw:500,p:4,truncate:!0,children:"Workspaces"}),c&&e.jsx(n.Anchor,{onClick:()=>{c(),g(!1)},size:"xs",underline:"never",fw:500,p:4,truncate:!0,style:{display:"flex",alignItems:"center",gap:"4px"},children:"Add"})]}),e.jsx("div",{className:Ve.scrollWrapper,children:e.jsx(n.ScrollArea,{mah:150,scrollbarSize:6,scrollHideDelay:0,children:e.jsx(n.Stack,{gap:0,mb:6,children:S.map(C=>e.jsx(n.Box,{onClick:()=>w(C),className:Ve.menuItem,style:{padding:0,borderRadius:"var(--mantine-radius-md)",cursor:"pointer",overflow:"hidden"},onMouseEnter:j=>{j.currentTarget.style.backgroundColor="var(--mantine-color-gray-1)"},onMouseLeave:j=>{j.currentTarget.style.backgroundColor="transparent"},children:e.jsx(Tn,{workspace:C,currentUserId:o,currentWorkspaceId:r==null?void 0:r.id,onClick:()=>w(C)})},C.id))})})})]})}),p&&e.jsx(n.Menu.Divider,{style:{margin:"1px 0px"}}),p&&e.jsx(n.Box,{p:4,children:p==null?void 0:p.map(C=>e.jsx(n.MenuItem,{onClick:C.onClick,leftSection:C.icon,children:C.label,color:C.color,"data-danger":C.color,fw:500,style:{height:"40px",borderRadius:"var(--mantine-radius-md)",padding:"6px"}},C.label))})]})})]})},Bn=({children:t,style:r,...o})=>e.jsx(n.Box,{style:{backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",minHeight:"20vh",width:"100%",flex:"1 1 0%",minWidth:0,maxWidth:"none",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",...r},...o,children:t});Bn.displayName="MatrixCenter";const On=({children:t,style:r,size:o="50px",state:s="empty",onStateChange:a,interactive:i=!0,...c})=>{const[l,d]=u.useState(s),[f,h]=u.useState(!1),m=a?s:i?l:s,x=()=>{if(!i)return;const I=["empty","outline","filled"],b=(I.indexOf(m)+1)%I.length,v=I[b];a?a(v):d(v)},y=()=>{switch(m){case"empty":return null;case"outline":return e.jsx(M.IconPoint,{size:16,color:"var(--mantine-color-gray-8)",stroke:2.5});case"filled":return e.jsx(M.IconPointFilled,{size:16,color:"var(--mantine-color-gray-8)",stroke:2.5});default:return null}},p=()=>{switch(m){case"empty":return"var(--mantine-color-gray-2)";case"outline":return"var(--mantine-color-blue-0)";case"filled":return"var(--mantine-color-green-0)";default:return"var(--mantine-color-gray-2)"}};return e.jsx(n.Box,{style:{width:o,height:o,backgroundColor:p(),borderRadius:"var(--mantine-radius-md)",display:"flex",alignItems:"center",justifyContent:"center",cursor:i?"pointer":"default",transition:"all 0.2s ease",boxShadow:f&&i?"0 2px 8px rgba(0, 0, 0, 0.15)":"none",transform:f&&i?"translateY(-1px)":"translateY(0)",border:m==="outline"?"2px solid var(--mantine-color-gray-0)":"2px solid transparent",...r},onClick:x,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),...c,children:t||y()})};On.displayName="MatrixCell";const zn=({children:t,style:r,size:o="50px",blockId:s,isVisible:a=!0,isDimmed:i=!1,shouldShowBlueBorder:c=!1,onBlockClick:l,onBlockPress:d,...f})=>{const[h,m]=u.useState(!1),x=u.useRef(null),y=u.useRef(!1),p=()=>{!s||!d||(m(!0),y.current=!1,x.current=setTimeout(()=>{y.current=!0,d(s)},500))},I=()=>{s&&(m(!1),x.current&&(clearTimeout(x.current),x.current=null),!y.current&&l&&l(s),y.current=!1)},g=()=>{m(!1),x.current&&(clearTimeout(x.current),x.current=null),y.current=!1};return e.jsx(n.Box,{style:{width:o,height:"100%",minWidth:o,minHeight:o,backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",overflow:"hidden",display:"flex",alignItems:"stretch",justifyContent:"stretch",border:c?"2px solid var(--mantine-color-blue-5)":"2px solid transparent",opacity:h?.8:i?.3:1,transition:"all 0.2s ease",cursor:s?"pointer":"default",...r},onMouseDown:p,onMouseUp:I,onMouseLeave:g,...f,children:t})};zn.displayName="MatrixBlockLeft";const Rn=({children:t,style:r,size:o="50px",blockId:s,isVisible:a=!0,isDimmed:i=!1,shouldShowBlueBorder:c=!1,onBlockClick:l,onBlockPress:d,...f})=>{const[h,m]=u.useState(!1),x=u.useRef(null),y=u.useRef(!1),p=()=>{!s||!d||(m(!0),y.current=!1,x.current=setTimeout(()=>{y.current=!0,d(s)},500))},I=()=>{s&&(m(!1),x.current&&(clearTimeout(x.current),x.current=null),!y.current&&l&&l(s),y.current=!1)},g=()=>{m(!1),x.current&&(clearTimeout(x.current),x.current=null),y.current=!1};return e.jsx(n.Box,{style:{width:o,height:"100%",minWidth:o,minHeight:o,backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",overflow:"hidden",display:"flex",alignItems:"stretch",justifyContent:"stretch",border:c?"2px solid var(--mantine-color-blue-5)":"2px solid transparent",opacity:h?.8:i?.3:1,transition:"all 0.2s ease",cursor:s?"pointer":"default",...r},onMouseDown:p,onMouseUp:I,onMouseLeave:g,...f,children:t})};Rn.displayName="MatrixBlockRight";const Dn=({children:t,style:r,size:o="50px",blockId:s,isVisible:a=!0,isDimmed:i=!1,shouldShowBlueBorder:c=!1,onBlockClick:l,onBlockPress:d,...f})=>{const[h,m]=u.useState(!1),x=u.useRef(null),y=u.useRef(!1),p=()=>{!s||!d||(m(!0),y.current=!1,x.current=setTimeout(()=>{y.current=!0,d(s)},500))},I=()=>{s&&(m(!1),x.current&&(clearTimeout(x.current),x.current=null),!y.current&&l&&l(s),y.current=!1)},g=()=>{m(!1),x.current&&(clearTimeout(x.current),x.current=null),y.current=!1};return e.jsx(n.Box,{style:{width:"100%",height:o,minWidth:o,minHeight:o,backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",overflow:"hidden",display:"flex",alignItems:"stretch",justifyContent:"stretch",border:c?"2px solid var(--mantine-color-blue-5)":"2px solid transparent",opacity:h?.8:i?.3:1,transition:"all 0.2s ease",cursor:s?"pointer":"default",...r},onMouseDown:p,onMouseUp:I,onMouseLeave:g,...f,children:t})};Dn.displayName="MatrixBlockUp";const En=({children:t,style:r,size:o="50px",blockId:s,isVisible:a=!0,isDimmed:i=!1,shouldShowBlueBorder:c=!1,onBlockClick:l,onBlockPress:d,...f})=>{const[h,m]=u.useState(!1),x=u.useRef(null),y=u.useRef(!1),p=()=>{!s||!d||(m(!0),y.current=!1,x.current=setTimeout(()=>{y.current=!0,d(s)},500))},I=()=>{s&&(m(!1),x.current&&(clearTimeout(x.current),x.current=null),!y.current&&l&&l(s),y.current=!1)},g=()=>{m(!1),x.current&&(clearTimeout(x.current),x.current=null),y.current=!1};return e.jsx(n.Box,{style:{width:"100%",height:o,minWidth:o,minHeight:o,backgroundColor:"var(--mantine-color-gray-1)",borderRadius:"var(--mantine-radius-md)",overflow:"hidden",display:"flex",alignItems:"stretch",justifyContent:"stretch",border:c?"2px solid var(--mantine-color-blue-5)":"2px solid transparent",opacity:h?.8:i?.3:1,transition:"all 0.2s ease",cursor:s?"pointer":"default",...r},onMouseDown:p,onMouseUp:I,onMouseLeave:g,...f,children:t})};En.displayName="MatrixBlockDown";const An=({onLeftHover:t,onRightHover:r,onUpHover:o,onDownHover:s,showLeftControls:a=!1,showRightControls:i=!1,showUpControls:c=!1,showDownControls:l=!1})=>{const[d,f]=u.useState(!1),[h,m]=u.useState(!1),[x,y]=u.useState(!1),[p,I]=u.useState(!1),g=w=>{f(w),t==null||t(w)},b=w=>{m(w),r==null||r(w)},v=w=>{y(w),o==null||o(w)},S=w=>{I(w),s==null||s(w)};return e.jsxs(e.Fragment,{children:[a&&e.jsx(n.Box,{style:{position:"absolute",left:0,top:0,bottom:0,width:"80px",zIndex:5,pointerEvents:"auto",background:"transparent"},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1)}),i&&e.jsx(n.Box,{style:{position:"absolute",right:0,top:0,bottom:0,width:"80px",zIndex:5,pointerEvents:"auto",background:"transparent"},onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1)}),c&&e.jsx(n.Box,{style:{position:"absolute",top:0,left:0,right:0,height:"80px",zIndex:5,pointerEvents:"auto",background:"transparent"},onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1)}),l&&e.jsx(n.Box,{style:{position:"absolute",bottom:0,left:0,right:0,height:"80px",zIndex:5,pointerEvents:"auto",background:"transparent"},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1)})]})};An.displayName="HoverZones";const Ln=({onLeftPrevious:t,onLeftNext:r,leftCurrentPage:o=1,leftTotalPages:s=1,leftDisabled:a=!1,leftVisible:i=!1,onLeftHover:c,onRightPrevious:l,onRightNext:d,rightCurrentPage:f=1,rightTotalPages:h=1,rightDisabled:m=!1,rightVisible:x=!1,onRightHover:y,onUpPrevious:p,onUpNext:I,upCurrentPage:g=1,upTotalPages:b=1,upDisabled:v=!1,upVisible:S=!1,onUpHover:w,onDownPrevious:T,onDownNext:k,downCurrentPage:C=1,downTotalPages:j=1,downDisabled:R=!1,downVisible:D=!1,onDownHover:O,onLeftAdd:E,onRightAdd:H,onUpAdd:$,onDownAdd:W,size:L="md",inline:F=!1})=>{const U=()=>s<=1||a?null:e.jsxs(n.Stack,{gap:"xs",align:"center",children:[e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:()=>t==null?void 0:t(),disabled:o<=1,color:"gray",radius:"md","aria-label":"Previous left blocks",children:e.jsx(M.IconChevronRight,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:E,color:"blue",radius:"md","aria-label":"Add left blocks",children:e.jsx(M.IconPlus,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:r,disabled:o>=s,color:"gray",radius:"md","aria-label":"Next left blocks",children:e.jsx(M.IconChevronLeft,{size:16,stroke:2})})]}),Z=()=>h<=1||m?null:e.jsxs(n.Stack,{gap:"xs",align:"center",children:[e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:l,disabled:f<=1,color:"gray",radius:"md","aria-label":"Previous right blocks",children:e.jsx(M.IconChevronLeft,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:H,color:"blue",radius:"md","aria-label":"Add right blocks",children:e.jsx(M.IconPlus,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:d,disabled:f>=h,color:"gray",radius:"md","aria-label":"Next right blocks",children:e.jsx(M.IconChevronRight,{size:16,stroke:2})})]}),_=()=>b<=1||v?null:e.jsxs(n.Group,{gap:"xs",align:"center",wrap:"nowrap",children:[e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:p,disabled:g<=1,color:"gray",radius:"md","aria-label":"Previous up blocks",children:e.jsx(M.IconChevronDown,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:$,color:"blue",radius:"md","aria-label":"Add up blocks",children:e.jsx(M.IconPlus,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:I,disabled:g>=b,color:"gray",radius:"md","aria-label":"Next up blocks",children:e.jsx(M.IconChevronUp,{size:16,stroke:2})})]}),G=()=>j<=1||R?null:e.jsxs(n.Group,{gap:"xs",align:"center",wrap:"nowrap",children:[e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:T,disabled:C<=1,color:"gray",radius:"md","aria-label":"Previous down blocks",children:e.jsx(M.IconChevronDown,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:W,color:"blue",radius:"md","aria-label":"Add down blocks",children:e.jsx(M.IconPlus,{size:16,stroke:2})}),e.jsx(n.ActionIcon,{size:L,variant:"subtle",onClick:k,disabled:C>=j,color:"gray",radius:"md","aria-label":"Next down blocks",children:e.jsx(M.IconChevronUp,{size:16,stroke:2})})]}),B=s>1&&!a,z=h>1&&!m,A=b>1&&!v,N=j>1&&!R;return!B&&!z&&!A&&!N?null:F?e.jsxs(e.Fragment,{children:[B&&i&&t&&r&&e.jsx("div",{onMouseEnter:()=>c==null?void 0:c(!0),onMouseLeave:()=>c==null?void 0:c(!1),children:U()}),z&&x&&l&&d&&e.jsx("div",{onMouseEnter:()=>y==null?void 0:y(!0),onMouseLeave:()=>y==null?void 0:y(!1),children:Z()}),A&&S&&p&&I&&e.jsx("div",{onMouseEnter:()=>w==null?void 0:w(!0),onMouseLeave:()=>w==null?void 0:w(!1),children:_()}),N&&D&&T&&k&&e.jsx("div",{onMouseEnter:()=>O==null?void 0:O(!0),onMouseLeave:()=>O==null?void 0:O(!1),children:G()})]}):e.jsxs(e.Fragment,{children:[B&&i&&t&&r&&e.jsx(n.Box,{style:{position:"absolute",left:"20px",top:"50%",transform:"translateY(-50%)",zIndex:10,pointerEvents:"auto",opacity:i?1:0,transition:"opacity 0.2s ease"},onMouseEnter:()=>c==null?void 0:c(!0),onMouseLeave:()=>c==null?void 0:c(!1),children:U()}),z&&x&&l&&d&&e.jsx(n.Box,{style:{position:"absolute",right:"20px",top:"50%",transform:"translateY(-50%)",zIndex:10,pointerEvents:"auto",opacity:x?1:0,transition:"opacity 0.2s ease"},onMouseEnter:()=>y==null?void 0:y(!0),onMouseLeave:()=>y==null?void 0:y(!1),children:Z()}),A&&S&&p&&I&&e.jsx(n.Box,{style:{position:"absolute",top:"20px",left:"50%",transform:"translateX(-50%)",zIndex:10,pointerEvents:"auto",opacity:S?1:0,transition:"opacity 0.2s ease"},onMouseEnter:()=>w==null?void 0:w(!0),onMouseLeave:()=>w==null?void 0:w(!1),children:_()}),e.jsx(n.Box,{style:{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)",zIndex:10,pointerEvents:"auto",opacity:D?1:0,transition:"opacity 0.2s ease"},onMouseEnter:()=>O==null?void 0:O(!0),onMouseLeave:()=>O==null?void 0:O(!1),children:N&&D&&T&&k&&G()})]})};Ln.displayName="NavigationControls";const Ce=({direction:t,text:r,show:o,actions:s,currentPage:a,totalPages:i,disabled:c,hoverState:l,onHover:d})=>{if(!r)return null;const f={left:{position:"absolute",left:"20px",top:"50%",transform:"translateY(-50%)"},right:{position:"absolute",right:"20px",top:"50%",transform:"translateY(-50%)"},up:{position:"absolute",top:"20px",left:"50%",transform:"translateX(-50%)"},down:{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)"}},h={left:{onLeftPrevious:s.prev,onLeftNext:s.next,leftCurrentPage:a,leftTotalPages:i,leftDisabled:c,leftVisible:!0},right:{onRightPrevious:s.prev,onRightNext:s.next,rightCurrentPage:a,rightTotalPages:i,rightDisabled:c,rightVisible:!0},up:{onUpPrevious:s.prev,onUpNext:s.next,upCurrentPage:a,upTotalPages:i,upDisabled:c,upVisible:!0},down:{onDownPrevious:s.prev,onDownNext:s.next,downCurrentPage:a,downTotalPages:i,downDisabled:c,downVisible:!0}};return e.jsxs("div",{style:{...f[t],zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",width:"80px",height:"60px"},children:[e.jsx("div",{style:{color:"var(--mantine-color-gray-6)",fontSize:"14px",fontWeight:"500",opacity:l?0:1,transition:"opacity 0.2s ease",position:"absolute"},children:r}),o&&e.jsx("div",{style:{opacity:l?1:0,transition:"opacity 0.2s ease",position:"absolute"},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:e.jsx(Ln,{...h[t],size:"sm",showLabels:!0,inline:!0})})]})},So=t=>{const{totalBlocksLeft:r=0,totalBlocksRight:o=0,totalBlocksUp:s=0,totalBlocksDown:a=0,visibleBlocksLeft:i=1,visibleBlocksRight:c=1,visibleBlocksUp:l=1,visibleBlocksDown:d=1}=t,f=u.useMemo(()=>{const p=Math.max(1,Math.ceil(r/i)),I=Math.max(1,Math.ceil(o/c)),g=Math.max(1,Math.ceil(s/l)),b=Math.max(1,Math.ceil(a/d));return{leftTotalPages:p,rightTotalPages:I,upTotalPages:g,downTotalPages:b,leftStartIndex:0,leftEndIndex:0,rightStartIndex:0,rightEndIndex:0,upStartIndex:0,upEndIndex:0,downStartIndex:0,downEndIndex:0}},[r,o,s,a,i,c,l,d]),[h,m]=u.useState({leftStartIndex:0,rightStartIndex:0,upStartIndex:0,downStartIndex:0}),x=u.useMemo(()=>{const{leftTotalPages:p,rightTotalPages:I,upTotalPages:g,downTotalPages:b}=f,v=Math.min(h.leftStartIndex,Math.max(0,r-i)),S=Math.min(v+i,r),w=Math.min(h.rightStartIndex,Math.max(0,o-c)),T=Math.min(w+c,o),k=Math.min(h.upStartIndex,Math.max(0,s-l)),C=Math.min(k+l,s),j=Math.min(h.downStartIndex,Math.max(0,a-d)),R=Math.min(j+d,a);return{leftTotalPages:p,rightTotalPages:I,upTotalPages:g,downTotalPages:b,leftStartIndex:v,leftEndIndex:S,rightStartIndex:w,rightEndIndex:T,upStartIndex:k,upEndIndex:C,downStartIndex:j,downEndIndex:R}},[h,f,i,c,l,d,r,o,s,a]),y={goToLeftPage:u.useCallback(p=>{const I=Math.max(0,(p-1)*i);m(g=>({...g,leftStartIndex:Math.min(I,Math.max(0,r-i))}))},[i,r]),goToRightPage:u.useCallback(p=>{const I=Math.max(0,(p-1)*c);m(g=>({...g,rightStartIndex:Math.min(I,Math.max(0,o-c))}))},[c,o]),goToUpPage:u.useCallback(p=>{const I=Math.max(0,(p-1)*l);m(g=>({...g,upStartIndex:Math.min(I,Math.max(0,s-l))}))},[l,s]),goToDownPage:u.useCallback(p=>{const I=Math.max(0,(p-1)*d);m(g=>({...g,downStartIndex:Math.min(I,Math.max(0,a-d))}))},[d,a]),nextLeftPage:u.useCallback(()=>{m(p=>({...p,leftStartIndex:Math.min(p.leftStartIndex+1,Math.max(0,r-i))}))},[r,i]),previousLeftPage:u.useCallback(()=>{m(p=>({...p,leftStartIndex:Math.max(p.leftStartIndex-1,0)}))},[]),nextRightPage:u.useCallback(()=>{m(p=>({...p,rightStartIndex:Math.min(p.rightStartIndex+1,Math.max(0,o-c))}))},[o,c]),previousRightPage:u.useCallback(()=>{m(p=>({...p,rightStartIndex:Math.max(p.rightStartIndex-1,0)}))},[]),nextUpPage:u.useCallback(()=>{m(p=>({...p,upStartIndex:Math.min(p.upStartIndex+1,Math.max(0,s-l))}))},[s,l]),previousUpPage:u.useCallback(()=>{m(p=>({...p,upStartIndex:Math.max(p.upStartIndex-1,0)}))},[]),nextDownPage:u.useCallback(()=>{m(p=>({...p,downStartIndex:Math.min(p.downStartIndex+1,Math.max(0,a-d))}))},[a,d]),previousDownPage:u.useCallback(()=>{m(p=>({...p,downStartIndex:Math.max(p.downStartIndex-1,0)}))},[])};return[h,y,x]},ko=(t,r=0,o=0,s=0,a=0)=>{const[i,c]=u.useState({width:typeof window<"u"?window.innerWidth:1920,height:typeof window<"u"?window.innerHeight:1080});return u.useEffect(()=>{if(typeof window>"u")return;const d=()=>{c({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[]),u.useMemo(()=>{const{gap:d,cellSize:f,minBlocksPerSide:h=2,maxBlocksPerSide:m=15,minBlocksLeft:x=1,maxBlocksLeft:y=8,minBlocksRight:p=1,maxBlocksRight:I=8,minBlocksUp:g=1,maxBlocksUp:b=8,minBlocksDown:v=1,maxBlocksDown:S=8,responsiveCellSize:w=!1,minCellSize:T="30px",maxCellSize:k="80px"}=t,C=parseFloat(d.replace("px","")),j=parseFloat(f.replace("px","")),R=i.width-C*4,D=i.height-C*4,O=j+C,E=Math.floor(R/(2*O)),H=j+C,$=Math.floor(D/H)+2,W=Math.min(E,$),L=Math.max(h,Math.min(m,W)),F=Math.max(x,Math.min(y,Math.floor(W/2))),U=Math.max(p,Math.min(I,Math.floor(W/2)));let Z=f;if(w){const A=parseFloat(T.replace("px","")),N=parseFloat(k.replace("px","")),V=Math.min(R/(i.width*.8),D/(i.height*.8));Z=`${Math.max(A,Math.min(N,j*V))}px`}const _=Math.min(i.width/1920,i.height/1080);let G,B;if(s>0&&a>0){const A=Math.max(s,a);G=Math.max(g,Math.min(b,A)),B=G}else{const A=Math.max(g,v),N=Math.min(b,S),V=Math.max(A,Math.min(N,Math.ceil(A+(N-A)*_)));G=V,B=V}if(G+B+1>$){const A=Math.max(2,$-1);if(Math.max(g,v)*2>A){const V=Math.max(1,Math.floor(A/2));G=V,B=V}else{const V=Math.max(g,v);G=V,B=V}}return console.log("Responsive Matrix Debug:",{windowSize:i,screenSizeRatio:_,minBlocksUp:g,minBlocksDown:v,maxBlocksUp:b,maxBlocksDown:S,blocksUp:s,blocksDown:a,calculatedBlocksUp:G,calculatedBlocksDown:B,totalVerticalBlocks:G+B+1,isSymmetric:G===B,availableHeight:D,maxBlocksVertical:$}),{blocksPerSide:L,blocksLeft:F,blocksRight:U,cellSize:Z,blocksUp:G,blocksDown:B}},[i,t,r,o,s,a])},Co=({gap:t,cellSize:r,blocksLeft:o,blocksRight:s,blocksUp:a,blocksDown:i,totalBlocksLeft:c,totalBlocksRight:l,totalBlocksUp:d,totalBlocksDown:f,responsive:h,minBlocksPerSide:m,maxBlocksPerSide:x,minBlocksLeft:y,maxBlocksLeft:p,minBlocksRight:I,maxBlocksRight:g,minBlocksUp:b,maxBlocksUp:v,minBlocksDown:S,maxBlocksDown:w,responsiveCellSize:T,minCellSize:k,maxCellSize:C})=>{const j=u.useMemo(()=>c!==void 0||l!==void 0||d!==void 0||f!==void 0,[c,l,d,f]),R=ko({gap:t,cellSize:r,minBlocksPerSide:m,maxBlocksPerSide:x,minBlocksLeft:y,maxBlocksLeft:p,minBlocksRight:I,maxBlocksRight:g,minBlocksUp:b,maxBlocksUp:v,minBlocksDown:S,maxBlocksDown:w,responsiveCellSize:T,minCellSize:k,maxCellSize:C},o??0,s??0,a,i),D=u.useMemo(()=>{let $=h?R.blocksLeft:o??0,W=h?R.blocksRight:s??0,L=h?R.blocksUp:a??0,F=h?R.blocksDown:i??0;if(!h){const U=parseFloat(t.replace("px","")),Z=parseFloat(r.replace("px","")),_=typeof window<"u"?window.innerWidth-U*4:1920,G=typeof window<"u"?window.innerHeight-U*4:1080,B=Z+U,z=Math.floor(_/(2*B)),A=Math.floor(G/(2*B));$=Math.min($,z),W=Math.min(W,z),L=Math.min(L,A),F=Math.min(F,A)}return{left:$,right:W,up:L,down:F}},[h,R,o,s,a,i,t,r]),O=u.useMemo(()=>{const $=j&&c?Math.min(D.left,c):D.left,W=j&&l?Math.min(D.right,l):D.right,L=j&&d?Math.min(D.up,d):D.up,F=j&&f?Math.min(D.down,f):D.down;return{left:$,right:W,up:L,down:F}},[j,D,c,l,d,f]),E=h?R.cellSize:r,H=u.useMemo(()=>{const $=(O.left>0?O.left:0)+1+(O.right>0?O.right:0),W=O.up>0||O.down>0?O.up+1+O.down:1,L=`${E} `.repeat(O.left)+"1fr "+`${E} `.repeat(O.right),F=O.up>0||O.down>0?`${E} `.repeat(O.up)+"1fr "+`${E} `.repeat(O.down):"1fr";return{totalColumns:$,totalRows:W,gridTemplateColumns:L.trim(),gridTemplateRows:F.trim()}},[O,E]);return{usePagination:j,visibleBlocks:D,finalBlocks:O,finalCellSize:E,gridDimensions:H}},Mo=({blockItems:t})=>{const r=u.useMemo(()=>t.reduce((a,i)=>(a[i.id]=i,a),{}),[t]);return{getBlockContent:(a,i)=>{const c=`${a}-${i}`,l=r[c];return l?l.content:u.createElement("div",{style:{padding:"4px",textAlign:"center",fontSize:"10px",writingMode:a==="left"||a==="right"?"vertical-rl":"horizontal-tb",textOrientation:"mixed",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"}})},getIntersectionText:(a,i,c,l)=>{const d=[];if(a!==null){const f=r[`left-${a}`];d.push(f?`left-${a}`:`left${a+1}`)}if(i!==null){const f=r[`right-${i}`];d.push(f?`right-${i}`:`right${i+1}`)}if(c!==null){const f=r[`up-${c}`];d.push(f?`up-${c}`:`up${c+1}`)}if(l!==null){const f=r[`down-${l}`];d.push(f?`down-${l}`:`down${l+1}`)}return d.join(", ")}}},To=({blockConnections:t})=>{const r=u.useMemo(()=>{const s=new Map;return t.forEach(a=>{const i=`${a.source}-${a.target}`,c=`${a.target}-${a.source}`;s.set(i,a),s.set(c,a)}),s},[t]);return{getConnectionStateFromText:s=>{const a=s.split(", ").map(i=>i.trim());for(let i=0;i<a.length;i++)for(let c=i+1;c<a.length;c++){const l=a[i],d=a[c],f=`${l}-${d}`,h=r.get(f);if(h)return h.type}return"empty"}}},Bo=({usePagination:t,totalBlocksLeft:r,totalBlocksRight:o,totalBlocksUp:s,totalBlocksDown:a,paginationActions:i,paginationState:c,paginationInfo:l})=>{const[d,f]=u.useState({left:!1,right:!1,up:!1,down:!1}),h=(x,y)=>{f(p=>({...p,[x]:y}))};return{hoverStates:d,handleHover:h,getNavigationControlProps:x=>{const y={left:r,right:o,up:s,down:a}[x],p={left:{prev:i.previousLeftPage,next:i.nextLeftPage},right:{prev:i.previousRightPage,next:i.nextRightPage},up:{prev:i.previousUpPage,next:i.nextUpPage},down:{prev:i.previousDownPage,next:i.nextDownPage}}[x],I={left:c.leftStartIndex,right:c.rightStartIndex,up:c.upStartIndex,down:c.downStartIndex}[x],g={left:l.leftTotalPages,right:l.rightTotalPages,up:l.upTotalPages,down:l.downTotalPages}[x];return{show:t&&!!y,totalBlocks:y,actions:p,currentPage:I+1,totalPages:g,disabled:!y,hoverState:d[x],onHover:b=>h(x,b)}}}},Oo=({blockItems:t,blockConnections:r})=>{const[o,s]=u.useState(null),[a,i]=u.useState(!1),c=u.useMemo(()=>{const I=new Map;return r.forEach(g=>{const b=`${g.source}-${g.target}`,v=`${g.target}-${g.source}`;I.set(b,g),I.set(v,g)}),I},[r]),l=u.useCallback(I=>{const g=[];return t.forEach(b=>{if(b.id!==I){const v=`${I}-${b.id}`;c.has(v)&&g.push(b.id)}}),g},[t,c]),d=u.useCallback(I=>{const g=t.find(S=>S.id===I);if(!g)return[];const b=l(I),v=[I];switch(g.type){case"up":b.forEach(S=>{const w=t.find(T=>T.id===S);w&&(w.type==="left"||w.type==="right")&&(v.push(S),l(S).forEach(k=>{const C=t.find(j=>j.id===k);C&&C.type==="down"&&v.push(k)}))});break;case"down":b.forEach(S=>{const w=t.find(T=>T.id===S);w&&(w.type==="left"||w.type==="right")&&(v.push(S),l(S).forEach(k=>{const C=t.find(j=>j.id===k);C&&C.type==="up"&&v.push(k)}))});break;case"left":b.forEach(S=>{const w=t.find(T=>T.id===S);w&&(w.type==="up"||w.type==="down")&&(v.push(S),l(S).forEach(k=>{const C=t.find(j=>j.id===k);C&&C.type==="right"&&v.push(k)}))});break;case"right":b.forEach(S=>{const w=t.find(T=>T.id===S);w&&(w.type==="up"||w.type==="down")&&(v.push(S),l(S).forEach(k=>{const C=t.find(j=>j.id===k);C&&C.type==="left"&&v.push(k)}))});break}return[...new Set(v)]},[t,l]),f=u.useCallback(I=>!0,[]),h=u.useCallback(I=>!a||!o?!1:!d(o).includes(I),[a,o,d]),m=u.useCallback(I=>!a||!o?!1:d(o).includes(I),[a,o,d]),x=u.useCallback(I=>{a&&o===I?(i(!1),s(null)):(s(I),i(!0))},[a,o]),y=u.useCallback(I=>{console.log(`Block clicked: ${I}`)},[]),p=u.useCallback(()=>{i(!1),s(null)},[]);return{selectedBlockId:o,isFiltering:a,isBlockVisible:f,isBlockDimmed:h,shouldShowBlueBorder:m,handleBlockPress:x,handleBlockClick:y,clearFiltering:p,getFilteredBlockIds:d}},nn=t=>parseInt(t.replace(/[^\d]/g,""),10)||0,zo=(t,r)=>{const[o,s]=u.useState({width:0,height:0}),a=u.useCallback(()=>{const{width:i,height:c}=o;if(i===0||c===0)return{blocksUp:r.minVerticalBlocks/2,blocksDown:r.minVerticalBlocks/2,blocksLeft:r.minHorizontalBlocks/2,blocksRight:r.minHorizontalBlocks/2,containerWidth:i,containerHeight:c};const l=nn(r.cellSize),d=nn(r.gap),f=l+d,h=i-d*2,m=c-d*2,x=Math.floor(m*r.verticalMaxPercent/100/f),y=Math.floor(h*r.horizontalMaxPercent/100/f),p=Math.floor(m*r.verticalMinPercent/100/f),I=Math.floor(h*r.horizontalMinPercent/100/f),g=Math.max(r.minVerticalBlocks,p),b=Math.max(r.minHorizontalBlocks,I),v=Math.max(g,x),S=Math.max(b,y),w=Math.floor(v/2),T=Math.floor(v/2),k=Math.floor(S/2),C=Math.floor(S/2);return{blocksUp:w,blocksDown:T,blocksLeft:k,blocksRight:C,containerWidth:i,containerHeight:c}},[o,r]);return u.useEffect(()=>{const i=()=>{if(t.current){const l=t.current.getBoundingClientRect();s({width:l.width,height:l.height})}};i();const c=new ResizeObserver(i);return t.current&&c.observe(t.current),()=>{c.disconnect()}},[t]),a()},Ro={verticalMinPercent:20,verticalMaxPercent:50,horizontalMinPercent:30,horizontalMaxPercent:50,minVerticalBlocks:2,minHorizontalBlocks:4,cellSize:"50px",gap:"8px"},Fn=({children:t,style:r,gap:o="8px",cellSize:s="50px",verticalBlocks:a,horizontalBlocks:i,responsiveConfig:c,enableResponsive:l=!1,blocksLeft:d,blocksRight:f,blocksUp:h=0,blocksDown:m=0,blockItems:x=[],blockConnections:y=[],enableFiltering:p=!1,onBlockClick:I,totalBlocksLeft:g,totalBlocksRight:b,totalBlocksUp:v,totalBlocksDown:S,usePagination:w=!1,responsive:T=!1,minBlocksPerSide:k=2,maxBlocksPerSide:C=15,minBlocksHorizontal:j=2,maxBlocksHorizontal:R=16,minBlocksVertical:D=2,maxBlocksVertical:O=16,minBlocksLeft:E=1,maxBlocksLeft:H=8,minBlocksRight:$=1,maxBlocksRight:W=8,minBlocksUp:L=1,maxBlocksUp:F=8,minBlocksDown:U=1,maxBlocksDown:Z=8,responsiveCellSize:_=!1,minCellSize:G="30px",maxCellSize:B="80px",directionTexts:z,...A})=>{const N=u.useRef(null),V=zo(N,{...Ro,cellSize:s,gap:o,...c});let ne=d,P=f,oe=h,X=m;l?(ne=Math.floor(V.blocksLeft),P=Math.floor(V.blocksRight),oe=Math.floor(V.blocksUp),X=Math.floor(V.blocksDown)):(a!==void 0||i!==void 0)&&(a!==void 0&&(oe=Math.floor(a/2),X=Math.floor(a/2)),i!==void 0&&(ne=Math.floor(i/2),P=Math.floor(i/2)));const de=E!==1?E:Math.floor(j/2),Ae=H!==8?H:Math.floor(R/2),Le=$!==1?$:Math.ceil(j/2),re=W!==8?W:Math.ceil(R/2),me=L!==1?L:Math.floor(D/2),be=F!==8?F:Math.floor(O/2),Vn=U!==1?U:Math.ceil(D/2),_n=Z!==8?Z:Math.ceil(O/2),{usePagination:Qn,finalBlocks:Q,finalCellSize:ae,gridDimensions:we}=Co({gap:o,cellSize:s,blocksLeft:ne,blocksRight:P,blocksUp:oe,blocksDown:X,totalBlocksLeft:g,totalBlocksRight:b,totalBlocksUp:v,totalBlocksDown:S,responsive:T,minBlocksPerSide:k,maxBlocksPerSide:C,minBlocksLeft:de,maxBlocksLeft:Ae,minBlocksRight:Le,maxBlocksRight:re,minBlocksUp:me,maxBlocksUp:be,minBlocksDown:Vn,maxBlocksDown:_n,responsiveCellSize:_,minCellSize:G,maxCellSize:B}),{getBlockContent:Se,getIntersectionText:Yn}=Mo({blockItems:x}),{getConnectionStateFromText:qn}=To({blockConnections:y}),Y=Oo({blockItems:x,blockConnections:y});u.useEffect(()=>{if(!p)return;const Fe=K=>{K.key==="Escape"&&Y.clearFiltering()};return window.addEventListener("keydown",Fe),()=>window.removeEventListener("keydown",Fe)},[p,Y]);const[ie,Zn,Xn]=So({totalBlocksLeft:g??0,totalBlocksRight:b??0,totalBlocksUp:v??0,totalBlocksDown:S??0,visibleBlocksLeft:Q.left,visibleBlocksRight:Q.right,visibleBlocksUp:Q.up,visibleBlocksDown:Q.down}),{getNavigationControlProps:ue}=Bo({usePagination:Qn,totalBlocksLeft:g,totalBlocksRight:b,totalBlocksUp:v,totalBlocksDown:S,paginationActions:Zn,paginationState:ie,paginationInfo:Xn});return e.jsxs(n.Box,{ref:N,style:{display:"grid",gridTemplateColumns:we.gridTemplateColumns,gridTemplateRows:we.gridTemplateRows,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",padding:o,boxSizing:"border-box",gap:o,overflow:"hidden",...r},...A,children:[Array.from({length:we.totalRows},(Fe,K)=>Array.from({length:we.totalColumns},(nr,te)=>{const Ue=Q.up>0?K===Q.up:K===0,Ne=te===Q.left;if(Ue&&Ne)return e.jsxs(Bn,{style:{width:"100%",height:"100%",maxWidth:"none",maxHeight:"none",position:"relative"},children:[t,e.jsx(Ce,{direction:"left",text:z==null?void 0:z.left,...ue("left")}),e.jsx(Ce,{direction:"right",text:z==null?void 0:z.right,...ue("right")}),e.jsx(Ce,{direction:"up",text:z==null?void 0:z.up,...ue("up")}),e.jsx(Ce,{direction:"down",text:z==null?void 0:z.down,...ue("down")}),w&&e.jsx(An,{showLeftControls:!!g,showRightControls:!!b,showUpControls:!!v,showDownControls:!!S,onLeftHover:q=>ue("left").onHover(q),onRightHover:q=>ue("right").onHover(q),onUpHover:q=>ue("up").onHover(q),onDownHover:q=>ue("down").onHover(q)})]},`center-${K}-${te}`);if(Ue&&te<Q.left){const q=w&&g?ie.leftStartIndex+te:te,J=`left-${q}`;return e.jsx(zn,{size:ae,blockId:p?J:void 0,isVisible:p?Y.isBlockVisible(J):!0,isDimmed:p?Y.isBlockDimmed(J):!1,shouldShowBlueBorder:p?Y.shouldShowBlueBorder(J):!1,onBlockClick:p?Y.handleBlockClick:I,onBlockPress:p?Y.handleBlockPress:void 0,children:Se("left",q)},`left-${te}`)}if(Ue&&te>Q.left){const q=te-Q.left-1,J=w&&b?ie.rightStartIndex+(Q.right-1-q):Q.right-1-q,ce=`right-${J}`;return e.jsx(Rn,{size:ae,blockId:p?ce:void 0,isVisible:p?Y.isBlockVisible(ce):!0,isDimmed:p?Y.isBlockDimmed(ce):!1,shouldShowBlueBorder:p?Y.shouldShowBlueBorder(ce):!1,onBlockClick:p?Y.handleBlockClick:I,onBlockPress:p?Y.handleBlockPress:void 0,children:Se("right",J)},`right-${q}`)}if(Ne&&K<Q.up){const q=w&&v?ie.upStartIndex+K:K,J=`up-${q}`;return e.jsx(Dn,{size:ae,blockId:p?J:void 0,isVisible:p?Y.isBlockVisible(J):!0,isDimmed:p?Y.isBlockDimmed(J):!1,shouldShowBlueBorder:p?Y.shouldShowBlueBorder(J):!1,onBlockClick:p?Y.handleBlockClick:I,onBlockPress:p?Y.handleBlockPress:void 0,children:Se("up",q)},`up-${K}`)}if(Ne&&K>Q.up){const q=K-Q.up-1,J=w&&S?ie.downStartIndex+q:q,ce=`down-${J}`;return e.jsx(En,{size:ae,blockId:p?ce:void 0,isVisible:p?Y.isBlockVisible(ce):!0,isDimmed:p?Y.isBlockDimmed(ce):!1,shouldShowBlueBorder:p?Y.shouldShowBlueBorder(ce):!1,onBlockClick:p?Y.handleBlockClick:I,onBlockPress:p?Y.handleBlockPress:void 0,children:Se("down",J)},`down-${q}`)}const We=te<Q.left?te:null,ke=te>Q.left?te-Q.left-1:null,$e=K<Q.up?K:null,Pe=K>Q.up?K-Q.up-1:null,Kn=w&&g&&We!==null?ie.leftStartIndex+We:We,Jn=w&&b&&ke!==null?ie.rightStartIndex+(Q.right-1-ke):ke!==null?Q.right-1-ke:null,et=w&&v&&$e!==null?ie.upStartIndex+$e:$e,nt=w&&S&&Pe!==null?ie.downStartIndex+Pe:Pe,He=Yn(Kn,Jn,et,nt);if(He&&He.length>0){const q=qn(He);return e.jsx(On,{size:ae,state:q,interactive:!1},`intersection-${K}-${te}`)}return e.jsx("div",{style:{width:ae,height:ae,minWidth:ae,minHeight:ae}},`empty-${K}-${te}`)})).flat(),p&&Y.isFiltering&&e.jsx(n.Box,{style:{position:"fixed",top:12,right:12,background:"rgba(255, 255, 255, 0.9)",color:"var(--mantine-color-dark-7)",padding:"8px 12px",borderRadius:"8px",boxShadow:"0 2px 10px rgba(0,0,0,0.12)",fontSize:12,fontWeight:600,pointerEvents:"none",zIndex:1e3},children:"Press Esc to clear filter"})]})};Fn.displayName="Matrix";const he=({editable:t=!1,children:r,label:o,icon:s,value:a,className:i,style:c,...l})=>{const d={className:i,style:c};return Ie.useMediaQuery("(max-width: 550px)",!1,{getInitialValueInEffect:!0})?e.jsxs(n.Stack,{gap:0,w:"100%",...d,children:[e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",gap:8},h:"auto",children:[s&&e.jsx(s,{size:20,style:{flexShrink:0},color:"var(--mantine-color-gray-6)",strokeWidth:2}),e.jsx(n.Text,{size:"sm",fw:500,c:"gray.6",children:o})]}),e.jsx(n.Box,{style:{display:"flex",alignItems:"flex-start"},w:"100%",children:t&&r?r:a})]}):e.jsxs(n.Group,{align:"flex-start",gap:0,w:"100%",...l,...d,children:[e.jsxs(n.Box,{w:"30%",style:{display:"flex",alignItems:"center",gap:8},h:"40px",children:[s&&e.jsx(s,{size:20,style:{flexShrink:0},color:"var(--mantine-color-gray-6)",strokeWidth:2}),e.jsx(n.Text,{size:"sm",fw:500,truncate:!0,c:"gray.6",children:o})]}),e.jsx(n.Box,{w:"70%",style:{display:"flex",alignItems:"flex-start"},mih:40,children:t&&r?r:a})]})},Do=({label:t,icon:r,value:o,onChange:s,editable:a=!1,placeholder:i,disabled:c=!1})=>a&&s?e.jsx(he,{label:t,icon:r,value:e.jsx(je,{value:o,onChange:s,placeholder:i,disabled:c,size:"sm"})}):e.jsx(he,{label:t,icon:r,value:e.jsx(n.Text,{size:"sm",c:o?void 0:"dimmed",fw:500,truncate:!0,children:o||i||"—"})}),Eo=({label:t,icon:r,href:o,text:s,target:a="_blank"})=>{const i=s||o;return e.jsx(he,{label:t,icon:r,value:e.jsx(n.Anchor,{href:o,target:a,size:"sm",underline:"hover",children:i})})},Ao=({label:t,icon:r,value:o,onChange:s,editable:a=!1,format:i,placeholder:c})=>{const l=o??null,d=l!==null&&i?i(l):l!==null?l.toString():null,f=h=>{if(!s)return;const m=h.trim();if(m===""){s(null);return}const x=Number(m);isNaN(x)||s(x)};return a&&s?e.jsx(he,{label:t,icon:r,value:e.jsx(je,{value:d||"",onChange:f,placeholder:c||"Enter number",size:"sm"})}):e.jsx(he,{label:t,icon:r,value:e.jsx(n.Text,{size:"sm",c:l!==null?void 0:"dimmed",children:d||c||"—"})})},Lo=300,Fo=({users:t,onSearch:r,debounceSearch:o=!0,debounceDelay:s=Lo})=>{const[a,i]=u.useState(""),[c,l]=u.useState(t),[d,f]=u.useState(!1),h=u.useRef(null);return u.useEffect(()=>{if(!r){l(t);return}if(h.current&&clearTimeout(h.current),a.trim()){const m=async()=>{f(!0);try{const x=await r(a);l(x)}catch(x){console.error("Search error:",x)}finally{f(!1)}};o?h.current=setTimeout(m,s):m()}else l(t),f(!1);return()=>{h.current&&clearTimeout(h.current)}},[a,r,o,s,t]),u.useEffect(()=>{(!a.trim()||!r)&&l(t)},[t,a,r]),{searchQuery:a,setSearchQuery:i,displayedUsers:c,setDisplayedUsers:l,isSearching:d}},Uo=({value:t,multiple:r,users:o,displayedUsers:s,searchQuery:a,onSearch:i})=>{const c=u.useMemo(()=>r?Array.isArray(t)?t:[]:t?[t]:[],[t,r]),l=u.useMemo(()=>o.filter(h=>c.includes(h.id)),[o,c]),d=u.useMemo(()=>{if(!a.trim()||i)return s;const h=a.toLowerCase();return s.filter(m=>m.name.toLowerCase().includes(h)||m.email.toLowerCase().includes(h))},[s,a,i]),f=u.useMemo(()=>{const h=d.filter(y=>c.includes(y.id)),m=d.filter(y=>!c.includes(y.id)),x=l.filter(y=>!d.some(p=>p.id===y.id));return[...h,...x,...m]},[d,c,l]);return{selectedIds:c,selectedUsers:l,sortedUsers:f}},No=({isFocused:t,dropdownRef:r})=>{const[o,s]=u.useState("bottom"),a=u.useCallback(i=>{if(r.current=i,i){const c=i.dataset.position;c==="top"||c==="bottom"?s(c):requestAnimationFrame(()=>{if(i.dataset.position){const l=i.dataset.position;(l==="top"||l==="bottom")&&s(l)}})}},[r]);return u.useLayoutEffect(()=>{if(!t||!r.current)return;const i=()=>{if(r.current){const d=r.current.dataset.position;(d==="top"||d==="bottom")&&s(d)}};i();const c=requestAnimationFrame(i),l=new MutationObserver(()=>{i()});return r.current&&l.observe(r.current,{attributes:!0,attributeFilter:["data-position"]}),()=>{cancelAnimationFrame(c),l.disconnect()}},[t,r]),{placement:o,dropdownRefCallback:a}},Wo=({onLoadMore:t,hasMore:r,loading:o,setDisplayedUsers:s})=>{const a=u.useRef(null);return u.useEffect(()=>{if(!t||!r||o)return;const i=new IntersectionObserver(c=>{c[0].isIntersecting&&r&&!o&&t().then(l=>{s(d=>[...d,...l])})},{threshold:.1});return a.current&&i.observe(a.current),()=>{i.disconnect()}},[t,r,o,s]),{loadMoreRef:a}},$o=({combobox:t,dropdownRef:r})=>{const[o,s]=u.useState(!1),[a,i]=u.useState(!1),c=u.useCallback(()=>{s(!0),t.openDropdown()},[t]),l=u.useCallback(h=>{setTimeout(()=>{const m=h==null?void 0:h.relatedTarget;m&&r.current&&r.current.contains(m)||t.dropdownOpened||s(!1)},0)},[t,r]),d=u.useCallback(()=>{i(!0)},[]),f=u.useCallback(()=>{i(!1)},[]);return{isFocused:o,setIsFocused:s,isHovered:a,handleFocus:c,handleBlur:l,handleMouseEnter:d,handleMouseLeave:f}},Po=({multiple:t,value:r,onChange:o,combobox:s})=>{const a=u.useCallback(c=>{if(t){const l=Array.isArray(r)?r:[],d=l.includes(c)?l.filter(f=>f!==c):[...l,c];o==null||o(d)}else o==null||o(c),s.closeDropdown()},[t,r,o,s]),i=u.useCallback(c=>{if(t){const l=Array.isArray(r)?r:[];o==null||o(l.filter(d=>d!==c))}else o==null||o("")},[t,r,o]);return{handleSelect:a,handleRemove:i}},Ho="40px",Go=300,pe=({editable:t=!1,label:r,icon:o,value:s,users:a=[],onChange:i,placeholder:c="Select users",multiple:l=!1,disabled:d=!1,onSearch:f,debounceSearch:h=!0,debounceDelay:m=Go,onLoadMore:x,hasMore:y=!1,loading:p=!1})=>{const I=u.useRef(null),g=u.useRef(null),b=u.useRef(null),{searchQuery:v,setSearchQuery:S,displayedUsers:w,setDisplayedUsers:T,isSearching:k}=Fo({users:a,onSearch:f,debounceSearch:h,debounceDelay:m}),C=n.useCombobox({onDropdownClose:()=>{C.resetSelectedOption(),S(""),R(!1)},onDropdownOpen:()=>{C.updateSelectedOptionIndex("active"),R(!0)}}),{isFocused:j,setIsFocused:R,isHovered:D,handleFocus:O,handleBlur:E,handleMouseEnter:H,handleMouseLeave:$}=$o({combobox:C,dropdownRef:b}),{placement:W,dropdownRefCallback:L}=No({isFocused:j,dropdownRef:b}),{selectedIds:F,selectedUsers:U,sortedUsers:Z}=Uo({value:s,multiple:l,users:a,displayedUsers:w,searchQuery:v,onSearch:f}),{loadMoreRef:_}=Wo({onLoadMore:x,hasMore:y,loading:p,setDisplayedUsers:T}),{handleSelect:G,handleRemove:B}=Po({multiple:l,value:s,onChange:i,combobox:C}),z=()=>{if(!l)return null;const P=5,oe=U.slice(0,P),X=U.length-P;return e.jsxs(n.Group,{gap:"xs",children:[oe.map(de=>e.jsx(Me,{avatar:de.avatar,name:de.name,withRemoveButton:j,onRemove:()=>B(de.id)},de.id)),X>0&&e.jsx(n.Pill,{ml:"xs",radius:"md",size:"md",bg:"transparent",children:e.jsxs(n.Group,{gap:"2px",wrap:"nowrap",style:{alignItems:"center",display:"flex"},h:"24px",children:[e.jsx(M.IconPlus,{size:16,style:{color:"var(--mantine-color-blue-5)"}}),e.jsxs(n.Text,{size:"sm",fw:400,c:"var(--mantine-color-blue-5)",children:[X," more"]})]})})]})},A=()=>{if(l)return null;const P=U[0];return P?e.jsx(Me,{avatar:P.avatar,name:P.name}):null},N=()=>j?"var(--mantine-color-gray-2)":"var(--mantine-color-gray-0)",V=()=>({input:{position:j?"absolute":"relative",zIndex:j?1e3:1,fontWeight:"400",color:"var(--mantine-color-gray-9)",cursor:d?"not-allowed":"pointer",backgroundColor:j||D?"var(--mantine-color-gray-0)":"transparent",border:j?"1px solid var(--mantine-color-gray-2)":"1px solid transparent",borderRadius:j&&W==="bottom"?"var(--mantine-radius-md) var(--mantine-radius-md) 0 0":j&&W==="top"?"0 0 var(--mantine-radius-md) var(--mantine-radius-md)":"var(--mantine-radius-md)",paddingY:"6px",display:"flex",alignItems:"center",padding:"6px 14px",minHeight:"40px",flexWrap:l?"wrap":"nowrap",boxShadow:j&&W==="bottom"?"0 -4px 10px 0 rgba(0, 0, 0, 0.1)":j&&W==="top"?"0 4px 10px 0 rgba(0, 0, 0, 0.1)":"none"}}),ne={group:{alignItems:"center",gap:"4px",minHeight:"0",lineHeight:"normal"}};return e.jsx(he,{editable:t,label:r,icon:o,value:e.jsx(n.Group,{gap:"sm",wrap:"nowrap",style:{alignItems:"center"},w:"100%",h:40,p:"14px",children:U.map(P=>e.jsx(Me,{avatar:P.avatar,name:P.name,withRemoveButton:j,onRemove:()=>B(P.id)},P.id))}),children:e.jsxs(n.Combobox,{store:C,onOptionSubmit:G,withinPortal:!1,offset:-2,children:[e.jsx(n.Combobox.DropdownTarget,{children:e.jsx(n.PillsInput,{onClick:()=>!d&&C.openDropdown(),radius:"md",disabled:d,styles:V,onFocus:O,onBlur:E,onMouseEnter:()=>!d&&H(),onMouseLeave:$,w:"100%",children:e.jsxs(n.Pill.Group,{styles:ne,children:[l?z():A(),e.jsx(n.Combobox.EventsTarget,{children:e.jsx(n.PillsInput.Field,{ref:I,onFocus:O,onBlur:E,placeholder:U.length===0||j||v.length>0?c:"",value:v,onChange:P=>{C.updateSelectedOptionIndex(),S(P.currentTarget.value)},onMouseDown:P=>{P.stopPropagation()},onKeyDown:P=>{P.key==="Backspace"&&v.length===0&&(P.preventDefault(),l&&U.length>0?B(U[U.length-1].id):!l&&U.length>0&&B(U[0].id))},pointer:!0,disabled:d,styles:{field:{minWidth:j||v.length>0||U.length===0?"60px":"0px",width:j||v.length>0||U.length===0?"auto":"0px",flex:j||v.length>0||U.length===0?"1":"0",border:"none",outline:"none",background:"transparent",fontSize:"inherit",fontFamily:"inherit",padding:"0",margin:"0",overflow:"hidden",lineHeight:"24px",display:"flex",alignItems:"center",height:j||v.length>0||U.length===0?"auto":"0px",minHeight:j||v.length>0||U.length===0?"auto":"0px","&::placeholder":{opacity:U.length===0||j||v.length>0?1:0,display:U.length===0||j||v.length>0?"block":"none",color:"var(--mantine-color-gray-9)",lineHeight:"24px"}}}})})]})})}),e.jsx(n.Combobox.Dropdown,{styles:{dropdown:{borderRadius:W==="bottom"?"0 0 var(--mantine-radius-md) var(--mantine-radius-md)":"var(--mantine-radius-md) var(--mantine-radius-md) 0 0",borderTop:"none",border:`1px solid ${N()}`,marginTop:"0",padding:"4px",boxShadow:W==="bottom"?"0 4px 10px 0 rgba(0, 0, 0, 0.1)":"0 -4px 10px 0 rgba(0, 0, 0, 0.1)"}},ref:L,children:e.jsx(n.Combobox.Options,{children:e.jsx(n.ScrollArea,{ref:g,h:Math.min(Z.length*parseFloat(Ho),300),scrollbarSize:6,children:e.jsxs(n.Stack,{gap:2,children:[Z.map(P=>{const oe=F.includes(P.id);return e.jsx(n.Combobox.Option,{value:P.id,active:oe,onMouseDown:X=>{X.preventDefault(),G(P.id)},style:{borderRadius:"var(--mantine-radius-md)",height:"40px"},children:e.jsxs(n.Group,{gap:"sm",wrap:"nowrap",style:{display:"flex",alignItems:"center"},h:"28px",children:[e.jsx(se,{avatar:P.avatar,size:24,placeholder:P.name,showPlaceholder:!0}),e.jsx(n.Text,{size:"sm",fw:400,truncate:!0,children:P.name}),oe&&e.jsx(M.IconCheck,{size:16,color:"var(--mantine-color-blue-6)"})]})},P.id)}),(k||p)&&e.jsx(n.Box,{style:{padding:"12px",display:"flex",justifyContent:"center"},children:e.jsx(n.Loader,{size:"sm"})}),x&&y&&!p&&e.jsx("div",{ref:_,style:{height:"20px"}}),Z.length===0&&!k&&!p&&e.jsx(n.Box,{style:{padding:"24px",textAlign:"center"},children:e.jsx(n.Text,{size:"sm",c:"dimmed",children:"No users found"})})]})})})})]})})},qe=({label:t,icon:r,value:o,onChange:s,onDraftChange:a,onFocusChange:i,editable:c=!1,placeholder:l,disabled:d=!1,minRows:f=1,maxRows:h,autosize:m=!0})=>{const[x,y]=u.useState(!1),[p,I]=u.useState(!1),g={wrapper:{...!m&&{height:"40px",minHeight:"40px",boxSizing:"border-box"},borderRadius:"var(--mantine-radius-md)"},input:{backgroundColor:x||p?"var(--mantine-color-gray-0)":"transparent",color:"var(--mantine-color-gray-9)",border:x?"1px solid var(--mantine-color-gray-2)":"1px solid transparent",borderRadius:"var(--mantine-radius-md)",width:"100%",cursor:"pointer",...!m&&{height:"40px",minHeight:"40px",boxSizing:"border-box"},padding:"8px 14px",lineHeight:m?"1.5":"24px",fontWeight:450}},b=()=>{y(!0),i==null||i(!0)},v=w=>{y(!1),i==null||i(!1),s==null||s(w.target.value)},S=w=>{const T=w.target.value;if(a){a(T);return}s==null||s(T)};return e.jsx(he,{editable:c,label:t,icon:r,value:e.jsx(n.Box,{w:"100%",style:{display:"flex",alignItems:"flex-start",minHeight:40},p:"xs",h:40,children:e.jsx(n.Text,{size:"sm",c:o?void 0:"dimmed",fw:400,style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:o||l||"—"})}),children:e.jsx(n.Box,{w:"100%",style:{boxShadow:x?"var(--mantine-shadow-sm)":"none",borderRadius:"var(--mantine-radius-md)"},children:e.jsx(n.Textarea,{value:o,onChange:S,onFocus:b,onBlur:v,onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),placeholder:l,disabled:d,size:"sm",radius:"md",fw:400,minRows:x?1:f,maxRows:h,autosize:m,styles:{...g}})})})},Vo=({opened:t,onClose:r,children:o,...s})=>e.jsxs(n.Modal,{withCloseButton:!1,opened:t,onClose:r,size:"70%",centered:!0,overlayProps:{backgroundOpacity:.55},styles:{content:{minHeight:"100%"}},padding:"md",...s,children:[e.jsxs(n.Group,{justify:"space-between",wrap:"nowrap",children:[e.jsx(n.Group,{justify:"space-between",wrap:"nowrap",gap:"xs",children:e.jsx(ee,{icon:M.IconMaximize,size:"md",onClick:()=>{}})}),e.jsxs(n.Group,{justify:"space-between",gap:"xs",children:[e.jsx(ee,{icon:M.IconStar,size:"md",onClick:()=>{}}),e.jsx(ee,{icon:M.IconDots,size:"md",onClick:()=>{}})]})]}),o]}),Un=({opened:t,onClose:r,editable:o,content:s,position:a="right",size:i="xl",onMaximize:c,rightCornerActions:l,headerProps:d,propertiesProps:f})=>{var w,T;const[h,m]=u.useState(!1),x=(f==null?void 0:f.hiddenProperties)&&f.hiddenProperties.length>0,[y,p]=u.useState(!1),[I,g]=u.useState(d==null?void 0:d.avatar),[b,v]=u.useState(!1);u.useEffect(()=>{g(d==null?void 0:d.avatar)},[d==null?void 0:d.avatar]);const S=e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray",mb:"md",onClick:()=>{var C;const k={type:"emoji",value:"😊"};g(k),(C=d==null?void 0:d.onAvatarChange)==null||C.call(d,k)},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(M.IconMoodSmileFilled,{size:16}),e.jsx(n.Text,{size:"sm",fw:500,children:"Add avatar"})]})});return e.jsxs(n.Drawer,{opened:t,onClose:r,position:a,size:i,padding:"md",withCloseButton:!1,overlayProps:{backgroundOpacity:0},shadow:"none",children:[e.jsxs(n.Group,{justify:"space-between",wrap:"nowrap",children:[e.jsxs(n.Group,{justify:"space-between",wrap:"nowrap",gap:"xs",children:[e.jsx(ee,{icon:M.IconChevronsRight,size:"md",onClick:r}),e.jsx(ee,{icon:M.IconMaximize,size:"md",onClick:()=>c()})]}),e.jsx(n.Group,{justify:"space-between",gap:"xs",children:l})]}),e.jsxs(n.Box,{p:"3rem",children:[d&&e.jsxs(n.Box,{children:[e.jsx(n.Box,{onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:I?e.jsx(Ee,{editable:o,avatar:I,size:"xl",opened:b,onOpen:()=>v(!0),onClose:()=>v(!1),onAvatarSelect:k=>{var C;g(k),(C=d==null?void 0:d.onAvatarChange)==null||C.call(d,k)},onRemove:()=>{g(void 0)}}):e.jsx(n.Box,{h:24,children:y&&S})}),o?e.jsx(je,{value:d.title||"",onChange:k=>{var C;return(C=d.onTitleChange)==null?void 0:C.call(d,k)},onDraftChange:d.onTitleDraftChange,pageTitle:!0,placeholder:d.placeholder}):e.jsx(n.Box,{h:80,style:{display:"flex",alignItems:"center"},children:e.jsx(n.Text,{size:"2.5rem",fw:700,children:d.title})})]}),e.jsx(n.Stack,{gap:"sm",children:(w=f==null?void 0:f.visibleProperties)==null?void 0:w.map((k,C)=>e.jsx(n.Box,{children:k},C))}),x&&!h&&e.jsx(n.Box,{w:"100%",style:{display:"flex",justifyContent:"center"},children:e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray.4",onClick:()=>m(!0),children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.Text,{size:"sm",fw:500,c:"var(--mantine-color-blue-5)",children:"Show"}),e.jsx(M.IconChevronDown,{size:16,color:"var(--mantine-color-blue-5)"})]})})}),e.jsx(n.Collapse,{in:h,children:e.jsx(n.Stack,{gap:"sm",mt:"sm",children:(T=f==null?void 0:f.hiddenProperties)==null?void 0:T.map((k,C)=>e.jsx(n.Box,{children:k},C))})}),x&&h&&e.jsx(n.Box,{w:"100%",style:{display:"flex",justifyContent:"center"},mt:"sm",children:e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray.4",onClick:()=>m(!1),children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.Text,{size:"sm",fw:500,c:"var(--mantine-color-blue-5)",children:"Hide"}),e.jsx(M.IconChevronUp,{size:16,color:"var(--mantine-color-blue-5)"})]})})}),s]})]})},_o=({children:t})=>e.jsx(n.Box,{style:{minHeight:"100vh",width:"100%",maxWidth:"100%",margin:"0 auto"},id:"full-page",children:t}),Nn=u.createContext(void 0),Wn=({children:t})=>{const[r,{toggle:o,open:s,close:a}]=Ie.useDisclosure(!0),[i,{toggle:c,open:l,close:d}]=Ie.useDisclosure(!1),[f,{open:h,close:m}]=Ie.useDisclosure(!1),[x,y]=u.useState(300),[p,I]=u.useState(500),g={opened:r,toggle:o,open:s,close:a,asideOpened:i,toggleAside:c,openAside:l,closeAside:d,sidebarWidth:x,setSidebarWidth:y,asideWidth:p,setAsideWidth:I,openedNotificationSidebar:f,openNotificationSidebar:h,closeNotificationSidebar:m};return e.jsx(Nn.Provider,{value:g,children:t})},Ze=()=>{const t=u.useContext(Nn);if(t===void 0)throw new Error("useAppLayout must be used within an AppLayoutProvider");return t},$n=({header:t,navbar:r,aside:o,children:s,...a})=>{const{opened:i,asideOpened:c,sidebarWidth:l,asideWidth:d}=Ze();return e.jsxs(n.AppShell,{header:{height:t?60:0},navbar:{width:i?l:0,breakpoint:"sm",collapsed:{mobile:!0}},aside:{width:c?d:0,breakpoint:"sm",collapsed:{mobile:!0}},padding:0,...a,children:[t&&e.jsx(n.AppShell.Header,{children:t}),e.jsx(n.AppShell.Navbar,{style:{display:i?"block":"none",width:i?l:0,border:"none"},children:r}),e.jsx(n.AppShell.Aside,{style:{display:c?"block":"none",width:c?d:0},children:o}),e.jsx(n.AppShell.Main,{children:s})]})},Qo=({items:t,selectedId:r,onSelect:o})=>e.jsx(n.Stack,{gap:0,children:t.map(s=>{var a;return e.jsx(_e,{label:s.label,isActive:r===s.id,noChild:!s.children||s.children.length===0,onClick:()=>(!s.children||s.children.length===0)&&(o==null?void 0:o(s.id)),children:(a=s.children)==null?void 0:a.map(i=>e.jsx(_e,{label:i.label,noChild:!0,level:4,isActive:r===i.id,onClick:()=>o==null?void 0:o(i.id)},i.id))},s.id)})}),Yo=({items:t,selectedId:r,onSelect:o,headerLeft:s,headerRight:a,renderPreview:i,renderAside:c,sidebarTitle:l="Documentation",topNavItems:d,selectedTopNavId:f,onTopNavSelect:h})=>{const{opened:m,toggle:x}=Ze(),[y,p]=u.useState(r),I=r??y,g=b=>{o==null||o(b),r===void 0&&p(b)};return e.jsx($n,{header:d?e.jsx(Qe,{withBorder:!0,bg:"transparent",position:"left",header:e.jsx(n.Group,{h:40,w:"100%",justify:"space-between",wrap:"nowrap",children:e.jsx(n.Group,{gap:"xs",wrap:"nowrap",children:m&&e.jsx(n.Text,{fw:600,size:"sm",children:l})})})}):void 0,navbar:e.jsx(Qe,{withBorder:!0,bg:"transparent",position:"left",header:e.jsxs(n.Group,{h:40,w:"100%",justify:"space-between",wrap:"nowrap",children:[e.jsx(n.Group,{gap:"xs",wrap:"nowrap",children:m&&e.jsx(n.Text,{fw:600,size:"sm",children:l})}),e.jsx(ee,{icon:m?M.IconChevronsLeft:M.IconChevronsRight,size:"md",onClick:x})]}),body:m&&e.jsx(n.ScrollArea,{h:"100%",type:"hover",scrollbarSize:10,styles:{scrollbar:{'&[data-state="visible"]':{background:"transparent"}},thumb:{backgroundColor:"var(--mantine-color-gray-4)",opacity:.3,"&:hover":{backgroundColor:"var(--mantine-color-gray-4)",opacity:.3}}},children:e.jsx(Qo,{items:t,selectedId:I,onSelect:g})}),footer:e.jsx(e.Fragment,{})}),aside:e.jsx(n.Box,{p:"md",h:"100%",children:c==null?void 0:c(I)}),children:e.jsxs(n.Box,{style:{height:"100vh",display:"flex",flexDirection:"column",background:"var(--mantine-color-body)"},children:[e.jsxs(n.Group,{p:"md",justify:"space-between",align:"center",children:[e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[!m&&e.jsx(ee,{icon:M.IconChevronsRight,size:"md",variant:"subtle",tooltip:"Open sidebar",onClick:x}),s??e.jsx(Oe,{label:I||"Select a topic",onClick:()=>{}})]}),!d&&a]}),e.jsx(n.Box,{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"40px"},children:e.jsx(n.Box,{p:"xl",style:{borderRadius:"var(--mantine-radius-md)",width:"100%"},children:i(I)})})]})})},qo=t=>e.jsx(Wn,{children:e.jsx(Yo,{...t})}),Xe=(t,r)=>{const o=u.useCallback(i=>{const c=Array.isArray(i)?i:[i];t.onUserIdsChange(c)},[t]),s=u.useCallback(i=>{const c=Array.isArray(i)?i:[i],l=r.members.filter(y=>c.includes(y.id)),d=l.map(y=>y.id),f=c.filter(y=>!d.includes(y)),m=[...r.members,...t.users].filter(y=>f.includes(y.id)),x=[...l,...m];r.onMembersChange(x)},[r,t]);return{availableMembersUsers:u.useMemo(()=>{const i=[...r.members];return t.users.forEach(c=>{i.find(l=>l.id===c.id)||i.push(c)}),i},[r.members,t.users]),handleResponsibleChange:o,handleMembersChange:s}},Zo=({opened:t,onClose:r,onMaximize:o,editable:s,name:a,onNameChange:i,avatar:c,onAvatarChange:l,owner:d,responsibleProps:f,membersProps:h,descriptionProps:m})=>{const{availableMembersUsers:x,handleResponsibleChange:y,handleMembersChange:p}=Xe(f,h),I=u.useMemo(()=>[e.jsx(qe,{label:"Description",icon:M.IconAlignLeft,value:m.description,onChange:m.onDescriptionChange,editable:s},"description"),e.jsx(pe,{editable:!1,label:"Team Owner",icon:M.IconUserCircle,value:d.id,users:[d]},"owner"),e.jsx(pe,{multiple:!1,editable:s,label:"Team Leader",icon:M.IconUser,value:f.userIds.length>0?f.userIds[0]:void 0,users:f.users,onChange:y,onSearch:f.handleSearch,onLoadMore:f.handleLoadMore,hasMore:f.hasMore},"leader"),e.jsx(pe,{multiple:!0,editable:s,label:"Team Members",icon:M.IconUsers,value:h.members.map(g=>g.id),users:x,onChange:p,onSearch:h.handleSearch,onLoadMore:h.handleLoadMore,hasMore:h.hasMore},"members")],[m.description,m.onDescriptionChange,s,d,f.handleLoadMore,f.handleSearch,f.hasMore,f.userIds,f.users,y,h.handleLoadMore,h.handleSearch,h.hasMore,h.members,x,p]);return e.jsx(Un,{opened:t,onClose:r,onMaximize:o,editable:s,headerProps:{avatar:c,onAvatarChange:g=>l==null?void 0:l(g),title:a,onTitleChange:i,placeholder:"Team name"},propertiesProps:{visibleProperties:I}})},Pn=({isSidebarOpen:t,fullWidth:r=!1,editable:o,rightNavigation:s,headerProps:a,properties:i,children:c,footer:l})=>{const[d,f]=u.useState(a==null?void 0:a.avatar),[h,m]=u.useState(!1),[x,y]=u.useState(!1),p=r?"0":{base:"1rem",sm:"2rem",md:"4rem",lg:"8rem",xl:"10rem"},[I,g]=u.useState(t);u.useEffect(()=>{g(t)},[t]);const b=()=>{g(v=>!v)};return e.jsxs(n.Stack,{gap:"md",p:"md",children:[e.jsxs(n.Group,{justify:"space-between",children:[e.jsxs(n.Group,{gap:4,wrap:"nowrap",children:[e.jsx(ee,{icon:I?M.IconChevronsRight:M.IconMenu2,size:"md",color:"gray",changeIconOnHover:!0,iconHovered:I?M.IconMenu2:M.IconChevronsRight,variant:"subtle",onClick:b,"aria-pressed":I}),e.jsx(Oe,{label:a.title,onClick:()=>{}})]}),e.jsx(n.Box,{children:s})]}),e.jsx(n.Box,{px:p,w:"100%",maw:{base:"100%",md:"80vw"},mx:"auto",children:e.jsxs(n.Stack,{gap:"md",children:[a&&e.jsxs(n.Stack,{gap:"md",children:[e.jsx(n.Box,{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),h:d?64:24,children:d?e.jsx(Ee,{editable:o,avatar:d,size:64,opened:h,onOpen:()=>m(!0),onClose:()=>m(!1),onAvatarSelect:v=>{var S;f(v),(S=a==null?void 0:a.onAvatarChange)==null||S.call(a,v)},onRemove:()=>{f(void 0)}}):e.jsx(n.Box,{h:24,children:x&&e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray",mb:"md",onClick:()=>{var S;const v={type:"emoji",value:"😊"};f(v),(S=a==null?void 0:a.onAvatarChange)==null||S.call(a,v)},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(M.IconMoodSmileFilled,{size:16}),e.jsx(n.Text,{size:"sm",fw:500,children:"Add avatar"})]})})})}),e.jsx(n.Box,{children:o?e.jsx(un,{value:a.title||"",onChange:v=>{var S;return(S=a.onTitleChange)==null?void 0:S.call(a,v)},placeholder:a.placeholder,pageTitle:!0}):e.jsx(n.Box,{h:80,style:{display:"flex",alignItems:"center"},children:e.jsx(n.Text,{size:"2.5rem",fw:700,children:a.title})})})]}),i,c,l]})})]})},Hn=({editable:t,owner:r,descriptionProps:o,responsibleProps:s,membersProps:a})=>{const{availableMembersUsers:i,handleResponsibleChange:c,handleMembersChange:l}=Xe(s,a);return e.jsxs(n.Stack,{gap:"sm",children:[e.jsx(qe,{label:"Description",icon:M.IconAlignLeft,value:o.description,onChange:o.onDescriptionChange,editable:t},"description"),e.jsx(pe,{editable:!1,label:"Team Owner",icon:M.IconUserCircle,value:r.id,users:[r]},"owner"),e.jsx(pe,{multiple:!1,editable:t,label:"Team Leader",icon:M.IconUser,value:s.userIds.length>0?s.userIds[0]:void 0,users:s.users,onChange:c,onSearch:s.handleSearch,onLoadMore:s.handleLoadMore,hasMore:s.hasMore},"leader"),e.jsx(pe,{multiple:!0,editable:t,label:"Team Members",icon:M.IconUsers,value:a.members.map(d=>d.id),users:i,onChange:l,onSearch:a.handleSearch,onLoadMore:a.handleLoadMore,hasMore:a.hasMore},"members")]})},Xo=({editable:t,headerProps:r,rightNavigation:o,properties:s,children:a,footer:i})=>e.jsx(Pn,{isSidebarOpen:!0,editable:t,rightNavigation:o,headerProps:r,properties:e.jsx(Hn,{...s}),children:a,footer:i}),Ko=({title:t,properties:r,children:o})=>e.jsxs(n.Stack,{gap:"sm",p:"3rem",children:[e.jsx(n.Text,{size:"2.5rem",fw:600,children:t}),e.jsx(n.Space,{h:"md"}),e.jsx(n.Stack,{gap:"xs",children:r}),e.jsx(n.Space,{h:"md"}),e.jsx(n.Box,{children:o})]}),Jo=({opened:t,onClose:r,position:o,size:s,onMaximize:a,editable:i,rightNavigation:c,headerProps:l,properties:d,children:f,footer:h})=>{var S,w;const[m,x]=u.useState(l==null?void 0:l.avatar),[y,p]=u.useState(!1),[I,g]=u.useState(!1);u.useEffect(()=>{x(l==null?void 0:l.avatar)},[l==null?void 0:l.avatar]);const b=(S=l==null?void 0:l.loading)==null?void 0:S.avatar,v=(w=l==null?void 0:l.loading)==null?void 0:w.title;return e.jsx(n.Drawer,{opened:t,onClose:r,position:o,size:s,padding:"md",withCloseButton:!1,overlayProps:{backgroundOpacity:0},shadow:"none",trapFocus:!1,children:e.jsxs(n.Stack,{gap:"md",children:[e.jsxs(n.Group,{justify:"space-between",children:[e.jsxs(n.Group,{gap:"xs",wrap:"nowrap",children:[e.jsx(fe,{icon:M.IconChevronsRight,onClick:r}),e.jsx(fe,{icon:M.IconMaximize,onClick:()=>a()})]})," ",e.jsx(n.Box,{children:c})]}),e.jsx(n.Box,{p:"3rem",w:"100%",children:e.jsxs(n.Stack,{gap:"md",children:[l&&e.jsxs(n.Box,{children:[" ",e.jsx(n.Box,{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),h:b||m?64:24,children:b?e.jsx(n.Skeleton,{height:64,width:64,radius:"md"}):m?e.jsx(Ee,{editable:i,avatar:m,size:64,opened:y,onOpen:()=>p(!0),onClose:()=>p(!1),onAvatarSelect:T=>{var k;x(T),(k=l==null?void 0:l.onAvatarChange)==null||k.call(l,T)},onRemove:()=>{x(void 0)}}):e.jsx(n.Box,{h:24,children:I&&e.jsx(n.Button,{size:"xs",radius:"md",w:"fit-content",variant:"subtle",px:"var(--mantine-spacing-sm)",color:"gray",mb:"md",onClick:()=>{var k;const T={type:"emoji",value:"😊"};x(T),(k=l==null?void 0:l.onAvatarChange)==null||k.call(l,T)},children:e.jsxs(n.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(M.IconMoodSmileFilled,{size:16}),e.jsx(n.Text,{size:"sm",fw:500,children:"Add avatar"})]})})})}),v?e.jsx(n.Skeleton,{height:64,width:"100%",radius:"md",mt:"md"}):i?e.jsx(je,{value:l.title||"",onChange:T=>{var k;return(k=l.onTitleChange)==null?void 0:k.call(l,T)},onDraftChange:l.onTitleDraftChange,pageTitle:!0,placeholder:l.placeholder}):e.jsx(n.Box,{h:80,style:{display:"flex",alignItems:"center"},children:e.jsx(n.Text,{size:"2.5rem",fw:700,children:l.title})})]}),d,f,h]})})]})})},Gn=n.createTheme({primaryColor:"blue",fontFamily:"Inter, system-ui, Avenir, Helvetica, Arial, sans-serif",fontFamilyMonospace:"Monaco, Courier, monospace",headings:{fontFamily:"Inter, system-ui, Avenir, Helvetica, Arial, sans-serif"},colors:{},components:{}});function er({children:t,theme:r}){return e.jsxs(n.MantineProvider,{theme:r||Gn,children:[e.jsx(ct.Notifications,{}),e.jsx(lt.ModalsProvider,{children:e.jsx(dt.DatesProvider,{settings:{firstDayOfWeek:0},children:t})})]})}exports.ActionButton=ee;exports.ActionIcon=fe;exports.AppLayout=$n;exports.AppLayoutProvider=Wn;exports.AvatarSelector=Ee;exports.BaseLayout=Ko;exports.BoxAvatar=se;exports.CenterPeek=Vo;exports.DocsTemplate=qo;exports.EditableText=je;exports.EditableTextarea=un;exports.EmojiAvatar=on;exports.ExpandableSearch=fn;exports.FilterDropdown=wt;exports.FilterDropdownButton=ze;exports.FilterDropdownFilters=Re;exports.FullPage=_o;exports.GenericTable=xn;exports.IconAvatar=an;exports.ImageAvatar=cn;exports.InvitedUserCard=ve;exports.LinkProperty=Eo;exports.Logo=dn;exports.Matrix=Fn;exports.Menu=ye;exports.ModalSettings=io;exports.NavButton=Ye;exports.NavLink=_e;exports.Navbar=Qe;exports.NavbarProvider=go;exports.NotificationSidebar=mo;exports.NumberProperty=Ao;exports.PageLayout=Pn;exports.PageProperty=he;exports.PlaceholderAvatar=Be;exports.PopoverItem=hn;exports.PopoverSelector=De;exports.SelectUserProperty=pe;exports.ShareButton=so;exports.ShareMenu=Cn;exports.ShareModal=ao;exports.SidePeek=Un;exports.SidePeekLayout=Jo;exports.TeamPage=Xo;exports.TeamProperties=Hn;exports.TeamSidePeek=Zo;exports.TextButton=Oe;exports.TextProperty=Do;exports.TextareaProperty=qe;exports.ThemeProvider=er;exports.UserChip=Me;exports.WorkspaceSelector=wo;exports.WorkspaceSelectorItem=Tn;exports.getInitialsFromName=ln;exports.theme=Gn;exports.useAppLayout=Ze;exports.useNavbar=Io;exports.useTeamProperties=Xe;
@@ -1 +1 @@
1
- {"version":3,"file":"TextareaProperty.d.ts","sourceRoot":"","sources":["../../../../../../src/components/organisms/Property/TextareaProperty/TextareaProperty.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAmH5D,CAAC"}
1
+ {"version":3,"file":"TextareaProperty.d.ts","sourceRoot":"","sources":["../../../../../../src/components/organisms/Property/TextareaProperty/TextareaProperty.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA0H5D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obeyaka-ui",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "Professional UI component library with React, TypeScript, Storybook, and Mantine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",