@opencxh/ui-kit 3.181.0 → 3.182.1

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.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),kt=require("clsx"),F=require("lucide-react"),$e=require("dompurify"),Ct=require("react-markdown"),St=require("remark-gfm");function Et(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const Tt=Et(F);function i(...t){return kt.clsx(t)}function Mt(t){return(s,r)=>t[s]?.[r]||""}function At(t){return s=>t[s]||""}const zt={primary:"bg-accent text-accent-fg hover:bg-accent-hover disabled:bg-surface-hover",secondary:"bg-surface-sunk text-text-strong hover:bg-surface-hover disabled:bg-surface-hover",outline:"border border-border text-text-strong hover:bg-surface-hover",ghost:"text-text-muted hover:bg-surface-hover hover:text-text",destructive:"border border-danger-border bg-danger-soft text-danger-fg hover:border-danger disabled:bg-surface-hover",success:"bg-success text-text-inverse hover:opacity-90 disabled:bg-surface-hover",warning:"bg-warning text-text-inverse hover:opacity-90 disabled:bg-surface-hover","danger-solid":"bg-danger text-text-inverse hover:opacity-90 disabled:bg-surface-hover"},Dt={xs:"h-control-xs px-2 text-xs",sm:"h-control-sm px-3 text-sm",md:"h-control-md px-4 text-sm",lg:"h-control-lg px-4 text-sm",xl:"h-control-xl px-6 text-base","2xl":"h-control-2xl px-6 text-base",full:"h-control-md px-4 text-sm"},_t={xs:"h-control-xs w-6",sm:"h-control-sm w-7",md:"h-control-md w-8",lg:"h-control-lg w-9",xl:"h-control-xl w-10","2xl":"h-control-2xl w-12",full:"h-control-md w-8"},re=d.forwardRef(({variant:t="primary",size:s="md",fullWidth:r=!1,loading:n=!1,leftIcon:a,rightIcon:l,iconOnly:o=!1,shape:u="default",className:c,children:p,disabled:x,...f},g)=>{const b=x||n;return e.jsxs("button",{ref:g,type:"button",className:i("inline-flex shrink-0 items-center justify-center gap-2 cursor-pointer font-medium",u==="circle"?"rounded-full":"rounded-md","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:border-border-subtle","disabled:text-text-disabled",zt[t],o?_t[s]:Dt[s],(r||s==="full")&&"w-full",n&&"cursor-wait",c),disabled:b,"aria-busy":n||void 0,...f,children:[n&&e.jsx("span",{"aria-hidden":!0,className:"size-icon-md shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent"}),!n&&a&&e.jsx("span",{className:"flex items-center justify-center shrink-0",children:a}),!o&&p,!n&&l&&e.jsx("span",{className:"flex items-center justify-center shrink-0",children:l}),o&&!n&&!a&&!l&&p]})});re.displayName="Button";const Rt=({children:t,size:s="md",orientation:r="horizontal",attached:n=!0,className:a})=>{const l=i("inline-flex",{"flex-row":r==="horizontal","flex-col":r==="vertical","[&>*:not(:first-child):not(:last-child)]:rounded-none":n,"[&>*:first-child]:rounded-r-none":n&&r==="horizontal","[&>*:last-child]:rounded-l-none":n&&r==="horizontal","[&>*:first-child]:rounded-b-none":n&&r==="vertical","[&>*:last-child]:rounded-t-none":n&&r==="vertical","[&>*:not(:first-child)]:-ml-px":n&&r==="horizontal","[&>*:not(:first-child)]:-mt-px":n&&r==="vertical","gap-1":!n&&s==="xs","gap-2":!n&&(s==="sm"||s==="md"),"gap-3":!n&&(s==="lg"||s==="xl")},a);return e.jsx("div",{className:l,role:"group",children:t})};function Xe(t){if(!t)return;const s=t.split(/[-_ ]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(""),r=Tt[s];return typeof r=="function"||typeof r=="object"&&r!==null?r:void 0}const $t={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text-subtle",current:"text-current"},Z=({icon:t,size:s="md",color:r="current",clickable:n=!1,onClick:a,className:l,"aria-label":o,...u})=>{const c=typeof s=="number"?s:Lt(s),p=i("inline-block shrink-0",$t[r],n&&["cursor-pointer rounded-sm transition-opacity duration-fast ease-out hover:opacity-80","focus-visible:outline-none focus-visible:focus-ring"],l),x={size:c,strokeWidth:2,className:p,onClick:n?a:void 0,"aria-label":o,"aria-hidden":o?void 0:!0,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:n?f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a?.())}:void 0,...u};return e.jsx(t,{...x})};function Lt(t){return{xs:12,sm:14,md:16,lg:20,xl:24}[t]}function ve(t,s,{gap:r=6,matchWidth:n=!1,placement:a="bottom-start"}={}){const[l,o]=d.useState({});return d.useLayoutEffect(()=>{if(!t)return;const u=()=>{const c=s.current;if(!c)return;const p=c.getBoundingClientRect(),x=window.innerHeight-p.bottom,f=p.top,g=a.startsWith("top"),b=g?f<200&&x>f:x<200&&f>x,N=g!==b,v={position:"fixed"};N?(v.bottom=window.innerHeight-p.top+r,v.maxHeight=Math.max(120,f-r*2)):(v.top=p.bottom+r,v.maxHeight=Math.max(120,x-r*2)),a.endsWith("end")?(v.right=window.innerWidth-p.right,v.maxWidth=Math.max(160,p.right-r)):(v.left=p.left,v.maxWidth=Math.max(160,window.innerWidth-p.left-r)),n&&(v.width=p.width),o(v)};return u(),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[t,s,r,n,a]),l}const Le=({trigger:t,children:s,placement:r="bottom-start",className:n,rootClassName:a,triggerClassName:l,disabled:o=!1,triggerLabel:u})=>{const[c,p]=d.useState(!1),x=d.useRef(null),f=d.useRef(null),g=ve(c,f,{placement:r});d.useEffect(()=>{if(!c)return;const v=k=>{x.current&&!x.current.contains(k.target)&&p(!1)},m=k=>{k.key==="Escape"&&p(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",m)}},[c]);const b=v=>{v.stopPropagation(),!o&&p(m=>!m)},N=()=>p(!1);return e.jsxs("div",{ref:x,className:i("relative inline-flex",a),children:[e.jsx("button",{ref:f,type:"button",onClick:b,disabled:o,"aria-label":u,"aria-expanded":c,className:i("inline-flex items-center",o&&"cursor-not-allowed opacity-50",l),children:t}),c&&e.jsx("div",{className:i("fixed z-overlay overflow-y-auto rounded-lg border border-border bg-surface shadow-overlay",n),style:g,children:typeof s=="function"?s(N):s})]})},It={none:"hover:bg-surface-sunk hover:text-text",default:"bg-surface-sunk text-text-muted hover:text-text",muted:"bg-surface-sunk text-text-subtle hover:text-text",outline:"text-text-muted ring-1 ring-inset ring-border-strong hover:bg-surface-hover hover:text-text",warning:"bg-warning-soft text-warning-fg",danger:"bg-danger-soft text-danger-fg"},Pt=t=>i("inline-flex cursor-pointer select-none items-center text-sm font-medium",t.size==="sm"?"h-control-sm":"h-control-md","transition-colors duration-fast ease-out",t.shape==="pill"?"rounded-full":"rounded-md",t.active?"bg-info-soft text-info-fg":It[t.tone??"default"],t.className),Ot=t=>i("inline-flex items-center gap-1.5 pl-3",t.shape==="pill"?"rounded-full":"rounded-md",t.withClear?"pr-1.5":"pr-3","focus-visible:outline-none focus-visible:focus-ring");function Ye({label:t,icon:s,tone:r="default",shape:n="rect",size:a="md",active:l=!1,caret:o=!1,menu:u,menuClassName:c,onClear:p,clearLabel:x="Filter wissen",onClick:f,title:g,className:b}){const N=l&&!!p,v=n==="pill"?"rounded-full":"rounded-md",m=Pt({active:l,tone:r,shape:n,size:a,className:b}),k=e.jsxs(e.Fragment,{children:[s,t,o&&e.jsx(Z,{icon:F.ChevronDown,size:"xs"})]}),w=Ot({shape:n,withClear:N}),I=N&&e.jsx("button",{type:"button","aria-label":x,onClick:p,className:i("inline-flex h-full items-center pr-3 focus-visible:outline-none focus-visible:focus-ring",v),children:e.jsx(Z,{icon:F.X,size:"xs"})});return u?e.jsxs("span",{className:m,title:g,children:[e.jsx(Le,{trigger:k,rootClassName:"h-full",triggerClassName:i(w,"h-full"),className:i("min-w-menu p-1.5",c),children:u}),I]}):N?e.jsxs("span",{className:m,title:g,children:[e.jsx("button",{type:"button",onClick:f,className:w,children:k}),I]}):e.jsx("button",{type:"button",title:g,onClick:f,className:i(m,w),children:k})}const Ft={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Bt={primary:"text-text hover:text-info-fg hover:underline",info:"text-info-fg hover:underline",secondary:"text-text-muted hover:text-text",neutral:"text-text-muted hover:text-text",accent:"text-accent hover:underline",success:"text-success-fg hover:underline",warning:"text-warning-fg hover:underline",error:"text-danger-fg hover:underline"},Ht={primary:"bg-accent-soft",accent:"bg-accent-soft",secondary:"bg-surface-hover",neutral:"bg-surface-hover",success:"bg-success-soft",warning:"bg-warning-soft",error:"bg-danger-soft",info:"bg-info-soft"},qt=({variant:t="default",size:s="md",color:r="primary",disabled:n=!1,external:a=!1,className:l,children:o,href:u,target:c,rel:p,...x})=>{const f=a||u&&(u.startsWith("http")||u.startsWith("mailto:")),g=i("inline-flex items-center gap-1 underline-offset-2","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",Ft[s],!n&&Bt[r],t==="subtle"&&"no-underline opacity-70 hover:opacity-100",t==="underline"&&"underline decoration-1 hover:decoration-2",t==="button"&&["h-control-md rounded-md px-3 font-semibold no-underline hover:no-underline",Ht[r]],n&&"pointer-events-none cursor-not-allowed text-text-disabled opacity-50",l),b={...x,href:n?void 0:u,target:f?"_blank":c,rel:f?"noopener noreferrer":p,"aria-disabled":n||void 0};return e.jsxs("a",{className:g,...b,children:[o,f&&e.jsx(F.ExternalLink,{className:"size-icon-sm shrink-0","aria-hidden":!0})]})},Vt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm"};function Ze({options:t,value:s,onChange:r,size:n="sm",tone:a="sunk",fullWidth:l=!1,className:o,"aria-label":u}){return e.jsx("div",{role:"tablist","aria-label":u,className:i("gap-0.5 rounded-md p-0.5",a==="track"?"bg-surface-track":"bg-surface-sunk",l?"flex w-full":"inline-flex",o),children:t.map(c=>{const p=c.value===s;return e.jsx("button",{role:"tab","aria-selected":p,"aria-label":c.title,title:c.title,type:"button",onClick:()=>r(c.value),className:i("inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-sm","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",l&&"min-w-0 flex-1",Vt[n],p?"bg-surface text-text font-medium shadow-sm":"text-text-muted hover:text-text"),children:c.label},c.value)})})}const Ut={primary:"bg-accent text-accent-fg hover:bg-accent-hover",secondary:"border border-border bg-surface text-text hover:bg-surface-hover",outline:"border border-accent-border text-accent hover:bg-accent-soft"},Kt={sm:"h-control-sm w-7",md:"h-control-md w-8"};function Ie({label:t,onClick:s,variant:r="primary",size:n="md",icon:a,options:l,disabled:o=!1,loading:u=!1,menuPlacement:c="bottom-end",menuLabel:p="More options"}){const x=o||u,f=l.length>0;return e.jsxs("div",{className:i("inline-flex items-center",r==="primary"&&"gap-px"),children:[e.jsx(re,{variant:r,size:n,onClick:s,disabled:o,loading:u,leftIcon:a,className:i(f&&"rounded-r-none"),children:t}),f&&e.jsx(Le,{placement:c,disabled:x,triggerLabel:p,className:"min-w-menu py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:i("inline-flex items-center justify-center rounded-md rounded-l-none","transition-colors duration-fast ease-out",Ut[r],Kt[n],x&&"cursor-not-allowed opacity-50"),children:e.jsx(F.ChevronDown,{className:"size-icon-md"})}),children:g=>e.jsx(e.Fragment,{children:l.map(b=>e.jsxs("button",{type:"button",onClick:()=>{b.onClick(),g()},className:i("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",b.variant==="destructive"?"text-danger-fg hover:bg-danger-soft":"text-text hover:bg-surface-hover"),children:[b.icon&&e.jsx("span",{className:"shrink-0",children:b.icon}),b.label]},b.id))})})]})}const Wt=({commands:t,isOpen:s,onClose:r,labels:n,initialCommandPath:a,initialActiveIndex:l})=>{const[o,u]=d.useState(""),[c,p]=d.useState(a||[]),[x,f]=d.useState(l||0),g=d.useRef(null),b=d.useRef(null),v=(c.length?t.find(m=>m.id===c[0])?.subCommands||[]:t).filter(m=>m.label.toLowerCase().includes(o.toLowerCase()));return d.useEffect(()=>{s||(u(""),p(a||[]),f(l||0))},[s,a,l]),d.useEffect(()=>{const m=k=>{if(s){if(k.key==="Escape")r();else if(k.key==="ArrowUp")f(w=>w>0?w-1:v.length-1);else if(k.key==="ArrowDown")f(w=>w<v.length-1?w+1:0);else if(k.key==="Enter"){const w=v[x];w&&(w.subCommands?(p([...c,w.id]),f(0)):w.action&&(w.action(),r()))}}};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[s,r,v,x,c]),d.useEffect(()=>{const m=k=>{g.current&&!g.current.contains(k.target)&&r()};return s&&document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[s,r]),d.useEffect(()=>{if(!s)return;b.current?.querySelector(`[data-index="${x}"]`)?.scrollIntoView({block:"nearest"})},[x,s]),s?e.jsx("div",{className:"fixed inset-0 z-modal flex items-center justify-center bg-scrim",children:e.jsxs("div",{className:"flex flex-col w-full max-w-lg max-h-dialog p-2 mx-auto rounded-lg border border-border shadow-modal bg-surface",ref:g,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(F.Search,{className:"w-4 h-4 text-text-muted shrink-0"}),e.jsx("input",{type:"text",placeholder:n?.searchPlaceholder||"Search commands...",value:o,onChange:m=>u(m.target.value),className:"w-full border-0 bg-transparent py-2 text-text focus:outline-none"})]}),e.jsxs("div",{ref:b,className:"mt-2 pt-2 text-sm border-t border-border max-h-dialog-list overflow-y-auto",children:[v.length===0&&e.jsx("div",{className:"text-text-muted text-center text-sm",children:n?.noCommandsFound||"No commands found"}),v.map((m,k)=>e.jsxs("div",{"data-index":k,className:`flex items-center p-2 cursor-pointer rounded-md ${k===x?"bg-accent-soft text-accent":"text-text"}`,onClick:()=>{m.subCommands?(p([...c,m.id]),f(0)):m.action&&(m.action(),r())},onMouseEnter:()=>f(k),children:[m.icon&&e.jsx("span",{className:"mr-3",children:m.icon}),e.jsx("span",{className:"flex-grow",children:m.label}),m.subCommands&&e.jsx("span",{className:"text-text-muted",children:e.jsx(F.ChevronRight,{className:"w-4 h-4"})})]},m.id))]}),e.jsxs("div",{className:"flex items-center gap-4 px-3 pt-2 mt-2 text-xs text-text-muted border-t border-border",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-5 px-1 py-0.5 rounded border border-border bg-surface-sunk text-xs font-medium not-italic",children:"↑↓"}),n?.navigate||"to navigate"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-5 px-1 py-0.5 rounded border border-border bg-surface-sunk text-xs font-medium not-italic",children:"↵"}),n?.select||"to select"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-5 px-1 py-0.5 rounded border border-border bg-surface-sunk text-xs font-medium not-italic",children:"Esc"}),n?.close||"to close"]})]})]})}):null},Pe=["[&_[data-mention-id]]:bg-info-soft","[&_[data-mention-id]]:text-info-fg","[&_[data-mention-id]]:font-semibold","[&_[data-mention-id]]:px-1","[&_[data-mention-id]]:rounded-md"].join(" "),Ce="data-mention-id",Se=t=>t.type==="text",Gt=(t,s)=>t.type==="element"&&t.tagName===s,Jt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Xt(t){if(!Gt(t,"a"))return null;const s=t.properties?.href,[r]=t.children??[];return typeof s!="string"||!s.startsWith("mailto:")||!r||!Se(r)?null:s===`mailto:${r.value}`?r.value:null}function Yt(t){const s=[],r=n=>{const a=s[s.length-1];a&&Se(a)?a.value+=n:s.push({type:"text",value:n})};for(const n of t){const a=Xt(n);a!==null?r(a):Se(n)?r(n.value):s.push(n)}return s}function Zt(t){return{type:"element",tagName:"span",properties:{dataMentionId:t.id},children:[{type:"text",value:`@${t.name}`}]}}function Qt(t,s,r){const n=[];let a=0;r.lastIndex=0;let l=r.exec(t);for(;l;){l.index>a&&n.push({type:"text",value:t.slice(a,l.index)});const o=l[0].slice(1),u=s.find(c=>c.name===o);n.push(u?Zt(u):{type:"text",value:l[0]}),a=r.lastIndex,l=r.exec(t)}return a<t.length&&n.push({type:"text",value:t.slice(a)}),n}function Qe(t,s,r){if(!t.children)return;const n=Yt(t.children),a=[];for(const l of n)Se(l)?a.push(...Qt(l.value,s,r)):(Qe(l,s,r),a.push(l));t.children=a}function es(t){const s=t.filter(n=>n.name),r=new RegExp(`@(?:${[...s].sort((n,a)=>a.name.length-n.name.length).map(n=>Jt(n.name)).join("|")})`,"g");return()=>n=>{s.length!==0&&Qe(n,s,r)}}const ts=/<[a-z][\s\S]*>/i,ss=["[&_p]:my-1.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0 [&_p]:leading-relaxed","[&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2","[&_strong]:font-semibold [&_em]:italic","[&_ul]:my-1.5 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-1.5 [&_ol]:list-decimal [&_ol]:pl-5","[&_li]:leading-relaxed","[&_h1]:mb-1 [&_h1]:mt-2 [&_h1]:font-semibold [&_h2]:mb-1 [&_h2]:mt-2 [&_h2]:font-semibold [&_h3]:mb-1 [&_h3]:mt-2 [&_h3]:font-semibold","[&_blockquote]:my-1.5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-text-muted","[&_hr]:my-2 [&_hr]:border-border","[&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-surface-sunk [&_pre]:p-2 [&_pre]:text-xs","[&_code]:rounded-sm [&_code]:bg-surface-sunk [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-xs","[&_pre_code]:bg-transparent [&_pre_code]:p-0","[&_table]:my-1.5 [&_table]:w-full [&_table]:border-collapse [&_table]:text-xs","[&_th]:border [&_th]:border-border [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:font-semibold","[&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1",Pe].join(" ");function rs(t,s){if(!t?.startsWith("mailto:"))return!1;const r=typeof s=="string"?s:null;return r!==null&&t===`mailto:${r}`}const ns={p:t=>e.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",...t}),a:({href:t,children:s,...r})=>rs(t,s)?e.jsx(e.Fragment,{children:s}):e.jsx("a",{className:"text-accent underline underline-offset-2 hover:opacity-80",target:"_blank",rel:"noopener noreferrer",href:t,...r,children:s}),strong:t=>e.jsx("strong",{className:"font-semibold",...t}),em:t=>e.jsx("em",{className:"italic",...t}),ul:t=>e.jsx("ul",{className:"my-1.5 list-disc space-y-0.5 pl-5",...t}),ol:t=>e.jsx("ol",{className:"my-1.5 list-decimal space-y-0.5 pl-5",...t}),li:t=>e.jsx("li",{className:"leading-relaxed",...t}),h1:t=>e.jsx("h1",{className:"mb-1 mt-2 text-md font-semibold first:mt-0",...t}),h2:t=>e.jsx("h2",{className:"mb-1 mt-2 text-base font-semibold first:mt-0",...t}),h3:t=>e.jsx("h3",{className:"mb-1 mt-2 text-base font-semibold first:mt-0",...t}),blockquote:t=>e.jsx("blockquote",{className:"my-1.5 border-l-2 border-border pl-3 text-text-muted",...t}),hr:t=>e.jsx("hr",{className:"my-2 border-border",...t}),pre:t=>e.jsx("pre",{className:"my-1.5 overflow-x-auto rounded-md bg-surface-sunk p-2 text-xs",...t}),code:({className:t,children:s,...r})=>{const n=String(s??"");return/language-/.test(t??"")||n.includes(`
2
2
  `)?e.jsx("code",{className:"font-mono text-xs",...r,children:s}):e.jsx("code",{className:"rounded-sm bg-surface-sunk px-1 py-0.5 font-mono text-xs",...r,children:s})},table:t=>e.jsx("div",{className:"my-1.5 overflow-x-auto",children:e.jsx("table",{className:"w-full border-collapse text-xs",...t})}),th:t=>e.jsx("th",{className:"border border-border px-2 py-1 text-left font-semibold",...t}),td:t=>e.jsx("td",{className:"border border-border px-2 py-1",...t})};function je({text:t,className:s,as:r,mentions:n}){const a=t??"";return(r?r==="html":ts.test(a))?e.jsx("div",{className:i("break-words",ss,s),dangerouslySetInnerHTML:{__html:$e.sanitize(a,{ADD_ATTR:["target","rel",Ce]})}}):e.jsx("div",{className:i("break-words",Pe,s),children:e.jsx(Ct,{remarkPlugins:[St],rehypePlugins:n?.length?[es(n)]:void 0,components:ns,children:a})})}const as={info:"text-info-fg",success:"text-success-fg",warning:"text-warning-fg",destructive:"text-danger-fg"},ls={info:"bg-info-soft border-info-border",success:"bg-success-soft border-success-border",warning:"bg-warning-soft border-warning-border",destructive:"bg-danger-soft border-danger-border"},os={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"};function cs({block:t}){switch(t.type){case"heading":return t.level===1?e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-text",children:t.text}):t.level===2?e.jsx("h2",{className:"pt-2 text-base font-semibold tracking-tight text-text",children:t.text}):e.jsx("h3",{className:"pt-1 text-sm font-semibold text-text",children:t.text});case"paragraph":return e.jsx(je,{as:"markdown",text:t.text,className:"text-sm text-text"});case"quote":return e.jsx("blockquote",{className:"border-l-2 border-border pl-3.5",children:e.jsx(je,{as:"markdown",text:t.text,className:"text-sm text-text-muted"})});case"code":return e.jsx("pre",{className:"overflow-x-auto rounded-lg bg-surface-sunk p-3 text-xs",children:e.jsx("code",{className:"font-mono",children:t.text})});case"divider":return e.jsx("hr",{className:"border-border-subtle"});case"list":{const s=t.style==="numbered"?"ol":"ul";return e.jsx(s,{className:i("flex flex-col gap-2 pl-5 text-sm text-text",t.style==="numbered"?"list-decimal":"list-disc"),children:t.items.map((r,n)=>e.jsxs("li",{className:"leading-relaxed marker:text-text-subtle",children:[r.lead&&e.jsxs("strong",{className:"font-semibold",children:[r.lead," "]}),e.jsx(je,{as:"markdown",text:r.text,className:"inline"})]},n))})}case"table":return e.jsxs("figure",{className:"m-0",children:[e.jsx("div",{className:"overflow-x-auto rounded-lg ring-1 ring-border",children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-surface-sunk",children:t.columns.map((s,r)=>e.jsx("th",{className:i("px-4 py-2.5 text-xs font-semibold text-text-muted",s.align==="right"?"text-right":"text-left"),children:s.label},r))})}),e.jsx("tbody",{children:t.rows.map((s,r)=>e.jsx("tr",{className:"border-t border-border-subtle",children:s.map((n,a)=>e.jsx("td",{className:i("px-4 py-2.5 tabular-nums text-text",t.columns[a]?.align==="right"?"text-right":"text-left"),children:n},a))},r))})]})}),t.caption&&e.jsx("figcaption",{className:"pt-2 text-xs italic text-text-subtle",children:t.caption})]});case"kpi":return e.jsx("div",{className:i("grid gap-3",os[t.items.length]??"grid-cols-4"),children:t.items.map((s,r)=>e.jsxs("div",{className:"rounded-lg bg-surface-sunk px-4 py-3.5",children:[e.jsx("div",{className:i("text-2xl font-semibold tracking-tight",s.tone?as[s.tone]:"text-text"),children:s.value}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:s.label})]},r))});case"callout":return e.jsxs("div",{className:i("rounded-lg border px-4 py-3",ls[t.tone]),children:[t.title&&e.jsx("div",{className:"pb-0.5 text-sm font-semibold text-text",children:t.title}),e.jsx(je,{as:"markdown",text:t.text,className:"text-sm text-text"})]});default:return null}}function is({blocks:t,runtime:s="inert",className:r}){return s!=="inert"?e.jsxs("div",{className:i("rounded-lg border border-warning-border bg-warning-soft px-4 py-3",r),children:[e.jsx("div",{className:"text-sm font-semibold text-text",children:"Deze versie kan hier niet getoond worden"}),e.jsxs("div",{className:"pt-0.5 text-xs text-text-muted",children:["Hij is opgeslagen als ",e.jsx("code",{className:"font-mono",children:s}),", en deze weergave tekent alleen inerte inhoud."]})]}):e.jsx("article",{className:i("flex flex-col gap-4",r),children:t.map((n,a)=>e.jsx(cs,{block:n},n.block_id??a))})}function ds({title:t,icon:s=e.jsx(F.Sparkles,{className:"size-icon-md","aria-hidden":!0}),action:r,children:n,className:a,...l}){return e.jsxs("div",{className:i("flex flex-col gap-2 rounded-xl border p-4","border-assistant-border bg-assistant-soft",a),...l,children:[e.jsxs("div",{className:"flex items-center gap-2 text-assistant",children:[e.jsx("span",{"aria-hidden":!0,children:s}),e.jsx("span",{className:"text-sm font-semibold",children:t}),r&&e.jsx("span",{className:"ml-auto",children:r})]}),n&&e.jsx("div",{className:"text-sm leading-relaxed text-text",children:n})]})}const et=5;function us(t){let s=2166136261;for(let r=0;r<t.length;r++)s^=t.charCodeAt(r),s=Math.imul(s,16777619);return s>>>0}function Oe(t){const s=(t??"").trim().toLowerCase();return s?us(s)%et+1:1}const xs={1:"bg-cat-1-soft text-cat-1-fg",2:"bg-cat-2-soft text-cat-2-fg",3:"bg-cat-3-soft text-cat-3-fg",4:"bg-cat-4-soft text-cat-4-fg",5:"bg-cat-5-soft text-cat-5-fg"},fs={1:"bg-cat-1",2:"bg-cat-2",3:"bg-cat-3",4:"bg-cat-4",5:"bg-cat-5"};function Fe(t){return xs[Oe(t)]}function ms(t){return fs[Oe(t)]}const hs={default:"bg-avatar text-avatar-fg",in:"bg-avatar-in text-avatar-in-fg",out:"bg-accent text-accent-fg",note:"bg-avatar-note text-avatar-note-fg"},gs={xs:"w-5 h-5 text-xs",sm:"w-6 h-6 text-xs",md:"w-7 h-7 text-base",lg:"w-9 h-9 text-sm"};function bs(t){if(!t)return"?";const s=t.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return s.length>=2?(s[0][0]+s[1][0]).toUpperCase():s.length===1?s[0].slice(0,2).toUpperCase():"?"}const Be=({name:t,src:s,tone:r="default",size:n="sm",className:a,title:l})=>{const[o,u]=d.useState(!1),c=i("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none",r==="identity"?Fe(t):hs[r],gs[n],a);return s&&!o?e.jsx("img",{src:s,alt:t??"",title:l??t,className:i(c,"object-cover"),onError:()=>u(!0)}):e.jsx("span",{className:c,title:l??t,"aria-label":t,children:bs(t)})},Ke="ring-surface",ps="ring-surface-accent",vs=({people:t,max:s=4,size:r="sm",className:n})=>{if(t.length===0)return null;const a=t.slice(0,s),l=t.length-a.length;return e.jsxs("span",{className:i("inline-flex items-center",n),children:[a.map((o,u)=>e.jsx(Be,{name:o.name,src:o.src,size:r,title:o.name?o.seen===!1?`${o.name} — nog niet gelezen`:o.name:void 0,className:i(u>0&&"-ml-2",o.owner?ps:Ke,o.seen===!1&&"opacity-40")},o.id??`${o.name}-${u}`)),l>0&&e.jsxs("span",{className:i("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-avatar text-avatar-fg",r==="xs"?"w-5 h-5 text-xs":r==="md"?"w-7 h-7 text-xs":r==="lg"?"w-9 h-9 text-xs":"w-6 h-6 text-xs",Ke),children:["+",l]})]})},js={neutral:"bg-surface-sunk",out:"bg-bubble-out-soft",note:"bg-note-soft",assistant:"bg-assistant-soft"},ys={neutral:"text-text",out:"text-text",note:"text-note",assistant:"text-text"};function Ns({avatar:t,title:s,context:r,meta:n,time:a,tone:l="neutral",actions:o,below:u,children:c}){return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3.5",children:[e.jsx("span",{className:"mt-0.5 shrink-0",children:t}),e.jsxs("div",{className:i("min-w-0 flex-1 overflow-hidden rounded-lg px-4 py-3.5",js[l]),children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:i("min-w-0 truncate text-md font-semibold",!r&&"flex-1",ys[l]),children:s}),r&&e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-text-muted",children:r}),(n||a)&&e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[n,a&&e.jsx("span",{className:"text-xs tabular-nums text-text-subtle",children:a})]})]}),c&&e.jsx("div",{className:"pt-2",children:c}),o&&e.jsx("div",{className:"-ml-2.5 flex flex-wrap items-center gap-0.5 pt-2.5",children:o})]})]}),u]})}const ws="hover:bg-surface-track";function ks({name:t,src:s,tone:r="in"}){return e.jsx(Be,{name:t,src:s,tone:r,size:"sm"})}function Cs({icon:t,tone:s="neutral",title:r}){return e.jsx("span",{title:r,className:i("grid size-avatar-md shrink-0 place-items-center rounded-full",s==="assistant"?"bg-assistant-soft text-assistant":"bg-surface-track text-text-muted"),children:e.jsx(Z,{icon:t,size:"sm",color:"current"})})}function Ss({children:t,className:s}){return e.jsx("div",{className:i("flex items-center gap-2.5 rounded-md bg-surface px-3 py-2.5",s),children:t})}function Es({icon:t,text:s,time:r,joinUrl:n,joinLabel:a}){const l=Xe(t);return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 pl-10.5 text-xs text-text-subtle",children:[l&&e.jsx(Z,{icon:l,size:"sm",color:"current"}),e.jsx("span",{className:"min-w-0 truncate",children:s}),e.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-text-disabled",children:"·"}),e.jsx("span",{className:"shrink-0 tabular-nums",children:r}),n&&e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"shrink-0 text-xs font-medium text-info-fg hover:underline",children:[a??"Join"," ",e.jsx(Z,{icon:F.ArrowUpRight,size:"xs"})]})]})}const we={mail:{fg:"text-channel-mail-fg",bg:"bg-channel-mail-soft"},wa:{fg:"text-channel-whatsapp-fg",bg:"bg-channel-whatsapp-soft"},chat:{fg:"text-channel-chat-fg",bg:"bg-channel-chat-soft"},tel:{fg:"text-channel-phone-fg",bg:"bg-channel-phone-soft"},note:{fg:"text-channel-note-fg",bg:"bg-channel-note-soft"}},Ts={sm:"size-avatar-xs rounded-sm text-xs",md:"size-avatar-sm rounded-md text-xs",lg:"size-avatar-lg rounded-md text-base"};function Ms({channel:t,children:s,size:r="md",className:n,title:a}){const l=t in we?we[t]:void 0;return e.jsx("span",{title:a,className:i("inline-flex shrink-0 items-center justify-center font-bold",Ts[r],l?i(l.fg,l.bg):t?Fe(t):i(we.note.fg,we.note.bg),n),children:s})}const As=({src:t,alt:s,size:r="md",aspectRatio:n="auto",radius:a="md",showLoading:l=!0,showError:o=!0,fallback:u,loadingContent:c,errorContent:p,className:x,onLoad:f,onError:g,...b})=>{const[N,v]=d.useState(!0),[m,k]=d.useState(!1),[w,I]=d.useState(t),z=V=>{v(!1),k(!1),f?.(V)},X=V=>{if(v(!1),k(!0),u&&w!==u){I(u),k(!1),v(!0);return}g?.(V)},B=i("relative overflow-hidden bg-surface-hover",{"w-8 h-8":r==="xs","w-12 h-12":r==="sm","w-16 h-16":r==="md","w-24 h-24":r==="lg","w-32 h-32":r==="xl","w-full h-full":r==="full"},{"aspect-square":n==="square","aspect-video":n==="video","aspect-portrait":n==="portrait","aspect-landscape":n==="landscape"},{"rounded-none":a==="none","rounded-sm":a==="sm","rounded-md":a==="md","rounded-lg":a==="lg","rounded-xl":a==="xl","rounded-full":a==="full"},x),D=i("w-full h-full object-cover transition-opacity duration-fast",{"opacity-0":N||m,"opacity-100":!N&&!m}),$=i("absolute inset-0 flex items-center justify-center","text-text-muted"),L=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-surface-hover rounded"})}),H=e.jsxs("div",{className:"text-center",children:[e.jsx(Z,{icon:F.ImageOff,size:"lg",className:"mx-auto mb-1"}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:B,children:[e.jsx("img",{...b,src:w,alt:s,className:D,onLoad:z,onError:X}),N&&l&&e.jsx("div",{className:$,children:c||L}),m&&o&&e.jsx("div",{className:$,children:p||H})]})},zs={default:"text-text",urgent:"text-danger-fg",success:"text-success-fg"};function Ds({value:t,label:s,tone:r="default",className:n,...a}){return e.jsxs("div",{className:i("rounded-xl bg-editor px-4 py-3.5",n),...a,children:[e.jsx("div",{className:i("text-2xl font-semibold",zs[r]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:s})]})}const _s={sm:"size-checkbox-sm",md:"size-checkbox",lg:"size-checkbox-lg",full:"size-checkbox"},Rs={sm:"min-h-control-sm",md:"min-h-control-md",lg:"min-h-control-lg",full:"min-h-control-md"},$s={sm:"text-sm",md:"text-base",lg:"text-md",full:"text-base"},he=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",indeterminate:a=!1,containerClassName:l,labelClassName:o,className:u,id:c,...p},x)=>{const f=d.useId(),g=c||`checkbox-${f}`,b=!!r,N=d.useRef(null),v=d.useCallback(m=>{N.current=m,typeof x=="function"?x(m):x&&typeof x=="object"&&(x.current=m)},[x]);return d.useEffect(()=>{N.current&&(N.current.indeterminate=a)},[a]),e.jsxs("div",{className:i("flex flex-col",l),children:[e.jsxs("div",{className:i("flex items-center gap-3",Rs[n]),children:[e.jsx("input",{ref:v,id:g,type:"checkbox","aria-invalid":b||void 0,className:i("shrink-0 rounded-xs border accent-accent","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover",_s[n],b?"border-danger-border":"border-border-strong",u),...p}),t&&e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:g,className:i("cursor-pointer",b?"text-danger-fg":"text-text",$s[n],o),children:t}),s&&!r&&e.jsx("p",{className:"mt-0.5 text-xs text-text-subtle",children:s})]})]}),r&&e.jsx("p",{className:"mt-1 text-xs text-danger-fg",children:r})]})});he.displayName="Checkbox";function Ls({icon:t,onClick:s,children:r}){return e.jsxs("button",{type:"button",onClick:s,className:i("inline-flex h-control-sm shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5","text-sm font-medium whitespace-nowrap","transition-colors duration-fast ease-out hover:bg-white/15","focus-visible:outline-none focus-visible:focus-ring"),children:[t,r]})}function Is({items:t,getRowKey:s,variant:r="divided",leading:n,renderItem:a,trailing:l,onSelect:o,onActiveIndexChange:u,isActive:c,unread:p,dimmed:x,groupBy:f,groups:g,renderGroupHeader:b,stickyGroupHeaders:N=!1,collapsibleGroups:v=!1,hideGroupCount:m=!1,selectable:k=!1,selectedItems:w=[],onSelectionChange:I,bulkActions:z,header:X,stickyHeader:B=!1,bordered:D=!1,emptyContent:$,loading:L=!1,loadingRows:H=4,className:V,"aria-label":ee}){const[W,j]=d.useState(()=>Object.fromEntries((g??[]).filter(C=>C.defaultCollapsed).map(C=>[C.id,!0]))),h=d.useRef(null),S=C=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(C.key))return;const Y=Array.from(h.current?.querySelectorAll("li[data-list-row]")??[]);if(Y.length===0)return;C.preventDefault();const q=Y.indexOf(document.activeElement),y=C.key==="Home"?0:C.key==="End"?Y.length-1:C.key==="ArrowDown"?(q+1)%Y.length:(q-1+Y.length)%Y.length;Y[y]?.focus()},_=(C,T)=>s?s(C,T):T,E=C=>w.includes(C),R=(C,T)=>{I&&I(T?[...w,C]:w.filter(Y=>Y!==C))},M=C=>I?.(C?[...t]:[]),ae=i("flex flex-col",k&&w.length>0&&"min-h-full",D&&"overflow-hidden rounded-lg border border-border-subtle",V);if(L)return e.jsx("div",{className:ae,children:Array.from({length:H}).map((C,T)=>e.jsxs("div",{className:i("flex animate-pulse items-center gap-3 px-4 py-2",r==="divided"&&T>0&&"border-t border-border-subtle"),children:[e.jsx("span",{className:"size-tile-sm shrink-0 rounded-md bg-surface-hover"}),e.jsx("span",{className:"h-3 w-30 shrink-0 rounded-sm bg-surface-hover"}),e.jsx("span",{className:"h-3 flex-1 rounded-sm bg-surface-hover"}),e.jsx("span",{className:"h-3 w-8 shrink-0 rounded-sm bg-surface-hover"})]},`skeleton-${T}`))});if(t.length===0&&$)return e.jsx("div",{className:ae,children:$});const le=t.length>0&&w.length===t.length,G=w.length>0&&!le,K=(C,T,Y)=>{const q=c?.(C,T)??!1,y=p?.(C,T)??!1,O=x?.(C,T)??!1,te=k&&E(C);return e.jsxs("li",{...o?{role:"button",tabIndex:0,"data-list-row":"","aria-current":q||void 0,onClick:()=>o(C,T),onFocus:()=>u?.(T),onKeyDown:ne=>{ne.key!=="Enter"&&ne.key!==" "||(ne.preventDefault(),o(C,T))}}:{},className:i("flex items-center gap-3 text-base","transition-colors duration-fast ease-out",r==="inset"?"mx-2 rounded-lg px-3 py-2.5":"px-5 py-2.5",r==="divided"&&!Y&&"border-t border-border-subtle",o&&"cursor-pointer focus-visible:outline-none focus-visible:focus-ring",q||te?"bg-accent-soft text-text":y?i("bg-surface-unread",o&&"hover:bg-surface-unread-hover"):o&&"hover:bg-surface-hover",O&&"text-text-muted"),children:[k&&e.jsx("span",{onClick:ne=>ne.stopPropagation(),children:e.jsx(he,{checked:E(C),onChange:ne=>R(C,ne.target.checked),"aria-label":"Rij selecteren"})}),r==="bulleted"&&e.jsx("span",{"aria-hidden":!0,className:"mt-2 size-1.5 shrink-0 self-start rounded-full bg-border-strong"}),n&&e.jsx("span",{className:"shrink-0",children:n(C,T)}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:a?a(C,T):String(C)}),l&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:l(C,T)})]},_(C,T))},P=(()=>{if(!f)return t.map((q,y)=>K(q,y,y===0));const C=new Map;t.forEach((q,y)=>{const O=f(q,y);C.has(O)||C.set(O,[]),C.get(O)?.push({item:q,index:y})});const T=g??[];return[...T.filter(q=>C.has(q.id)),...[...C.keys()].filter(q=>!T.some(y=>y.id===q)).map(q=>({id:q}))].flatMap((q,y)=>{const O=C.get(q.id)??[],te=v&&W[q.id],ne=q.title??q.id,xe=q.count??O.length,me=e.jsx("li",{onClick:v?()=>j(de=>({...de,[q.id]:!de[q.id]})):void 0,className:i("flex items-center gap-2.5 bg-surface px-5 pb-1.5 text-base font-semibold",y>0?"pt-5":"pt-3",q.tone==="danger"?"text-danger-fg":q.tone==="muted"?"text-text-subtle":"text-text",N&&"sticky z-10",v&&"cursor-pointer select-none"),"aria-expanded":v?!te:void 0,style:N?{top:B?28:0}:void 0,children:b?b(q,O.map(de=>de.item)):e.jsxs(e.Fragment,{children:[v&&e.jsx(F.ChevronRight,{"aria-hidden":!0,className:i("size-icon-md shrink-0 text-text-subtle transition-transform duration-fast ease-out",!te&&"rotate-90")}),e.jsx("span",{children:ne}),!m&&e.jsx("span",{className:i("rounded-full px-2 text-xs font-normal tabular-nums",q.tone==="danger"?"bg-danger-soft text-danger-fg":"bg-surface-sunk text-text-subtle"),children:xe})]})},`group-${q.id}`);return te?[me]:[me,...O.map(({item:de,index:ue},Ae)=>K(de,ue,Ae===0))]})})();return e.jsxs("div",{ref:h,className:ae,onKeyDown:o?S:void 0,children:[X&&e.jsxs("div",{className:i("flex h-row-sm items-end gap-3 border-b border-border bg-surface px-5 pb-2","text-xs font-semibold uppercase tracking-wider text-text-disabled",B&&"sticky top-0 z-20"),children:[k&&e.jsx("span",{className:"flex items-center",children:e.jsx(he,{checked:le,indeterminate:G,onChange:C=>M(C.target.checked),"aria-label":"Alles selecteren"})}),X]}),e.jsx("ul",{"aria-label":ee,className:"flex flex-col",children:P}),k&&w.length>0&&e.jsx("div",{className:"pointer-events-none sticky bottom-0 z-10 flex justify-center px-5 pb-4",children:e.jsxs("div",{className:"pointer-events-auto flex items-center gap-1.5 rounded-lg bg-accent py-1.5 pl-3.5 pr-1.5 text-accent-fg shadow-overlay",children:[e.jsxs("span",{className:"text-sm font-medium",children:[w.length," geselecteerd"]}),e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 h-4 w-px bg-current opacity-25"}),z,e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 h-4 w-px bg-current opacity-25"}),e.jsx("button",{type:"button",onClick:()=>I?.([]),"aria-label":"Selectie wissen",className:"grid size-tile-md shrink-0 cursor-pointer place-items-center rounded-md transition-colors duration-fast ease-out hover:bg-white/15 focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(F.X,{className:"size-icon-lg"})})]})})]})}function Ps({side:t,continued:s=!1,tone:r="default",className:n,children:a}){return e.jsx("div",{className:i("min-w-0 max-w-bubble md:max-w-bubble-md",t==="out"?"rounded-lg rounded-tr-sm":"rounded-lg rounded-tl-sm",r==="note"?"bg-note-soft":t==="out"?"bg-bubble-out-soft":"bg-surface-sunk",s&&"mt-1",n),children:a})}function Os({icon:t,label:s,unset:r,className:n}){return e.jsxs("span",{className:i("inline-flex min-w-0 items-center gap-1.5 border-b border-dashed pb-px transition-colors duration-fast ease-out",r?"border-border text-text-subtle hover:border-border-strong hover:text-text-muted":"border-border-strong text-text-muted hover:text-text",n),children:[t,e.jsx("span",{className:"truncate",children:s})]})}function Fs(){return e.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-text-disabled",children:"·"})}const ie=({className:t})=>e.jsx("span",{className:i("block rounded-xs bg-surface-hover",t)});function Bs({shape:t,rows:s,columns:r}){switch(t){case"table":return e.jsxs("div",{className:"overflow-hidden rounded-lg ring-1 ring-border",children:[e.jsx("div",{className:"grid gap-2 bg-surface-hover p-3",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:Array.from({length:r}).map((n,a)=>e.jsx(ie,{className:"h-4 w-2/3 bg-border-strong"},`h-${a}`))}),Array.from({length:s}).map((n,a)=>e.jsx("div",{className:"grid gap-2 border-t border-border-subtle p-3",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:Array.from({length:r}).map((l,o)=>e.jsx(ie,{className:"h-4 w-full"},`c-${a}-${o}`))},`r-${a}`))]});case"list":return e.jsx("div",{className:"flex flex-col divide-y divide-border-subtle rounded-lg ring-1 ring-border",children:Array.from({length:s}).map((n,a)=>e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsx(ie,{className:"size-avatar-sm shrink-0 rounded-full"}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[e.jsx(ie,{className:"h-3"}),e.jsx(ie,{className:"h-2.5 opacity-70"})]})]},a))});case"form":return e.jsx("div",{className:"flex flex-col gap-5",children:Array.from({length:s}).map((n,a)=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ie,{className:"h-2.5 w-28"}),e.jsx(ie,{className:"h-control-md w-full rounded-md"})]},a))});case"menu":return e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:"px-2.5 pb-2 pt-5",children:e.jsx(ie,{className:"h-2 w-16"})}),Array.from({length:s}).map((n,a)=>e.jsxs("div",{className:"flex h-row-md items-center gap-2.5 px-2.5",children:[e.jsx(ie,{className:"size-4 shrink-0"}),e.jsx(ie,{className:"h-2"})]},a))]});case"cards":return e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:Array.from({length:s*r}).map((n,a)=>e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg p-4 ring-1 ring-border",children:[e.jsx(ie,{className:"h-3 w-1/2"}),e.jsx(ie,{className:"h-2.5"}),e.jsx(ie,{className:"h-2.5 w-3/4 opacity-70"})]},a))});default:return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ie,{className:"h-6 w-1/4"}),e.jsx("div",{className:"flex flex-col gap-2",children:Array.from({length:s}).map((n,a)=>e.jsx(ie,{className:"h-4"},a))})]})}}const Hs={text:2,table:8,list:6,form:5,menu:4,cards:2};function Me({variant:t="page",shape:s,rows:r,columns:n,children:a,className:l,showTableSkeleton:o=!1,tableColumns:u,tableRows:c}){const p=s??(o?"table":"text"),x=r??c??Hs[p],f=n??u??(p==="cards"?3:6),g=e.jsx("div",{className:i("w-full animate-pulse",l),"aria-hidden":!0,children:a??e.jsx(Bs,{shape:p,rows:x,columns:f})});return t==="inline"?g:e.jsx("main",{className:"flex-1 bg-surface p-6",children:g})}const tt=({surface:t=!1,title:s,subtitle:r,meta:n,actions:a=[],children:l,className:o,backLabel:u="Back",backClassName:c,onBack:p,editable:x=!1,onTitleChange:f})=>{const[g,b]=d.useState(!1),[N,v]=d.useState(s),m=d.useRef(null);d.useEffect(()=>{v(s)},[s]),d.useEffect(()=>{g&&m.current&&(m.current.focus(),m.current.select())},[g]);const k=()=>{x&&b(!0)},w=()=>{b(!1),N.trim()!==""&&N!==s&&f?f(N.trim()):v(s)},I=z=>{z.key==="Enter"?m.current?.blur():z.key==="Escape"&&(v(s),b(!1))};return e.jsxs("div",{className:i("px-5 pt-4 pb-2.5",t&&"border-b border-border",o),children:[e.jsxs("div",{className:"flex flex-row sm:items-start sm:justify-between items-center gap-4",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start gap-4 text-text",children:[p&&e.jsx(re,{variant:"ghost",onClick:p,leftIcon:e.jsx(Z,{icon:F.ChevronLeft,size:"md"}),iconOnly:!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[g?e.jsx("input",{ref:m,type:"text",value:N,onChange:z=>v(z.target.value),onBlur:w,onKeyDown:I,className:"text-1xl font-semibold bg-transparent border-b-1 border-border rounded-lg outline-none focus:border-none px-1 -mx-1 min-w-0 w-full"}):e.jsxs("div",{className:"group flex items-baseline gap-2.5 min-w-0",children:[e.jsx("h2",{onClick:k,className:i("text-lg font-semibold tracking-title truncate",x&&"cursor-pointer"),title:x?"Click to edit":void 0,children:s}),r&&e.jsx("span",{className:"shrink-0 text-base text-text-muted truncate",children:r}),x&&e.jsx(F.Pencil,{size:15,onClick:k,className:"shrink-0 cursor-pointer text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]}),n&&e.jsx("div",{className:i("mt-1 min-w-0 text-sm text-text-subtle",typeof n=="string"&&"truncate"),children:n})]})]})}),a.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:a.map(z=>z.render?e.jsx(d.Fragment,{children:z.render()},z.id):z.splitOptions&&z.splitOptions.length>0?e.jsx(Ie,{label:z.label,onClick:z.onClick,icon:z.icon,variant:z.variant==="primary"?"primary":"outline",options:z.splitOptions,disabled:z.disabled},z.id):e.jsx(re,{variant:z.variant??"secondary",onClick:X=>{X.stopPropagation(),X.target.blur(),z.onClick()},disabled:z.disabled,leftIcon:z.icon,children:z.label},z.id))})]}),l&&e.jsx("div",{className:"mt-4",children:l})]})},qs={none:"",sm:"px-3 pb-3 pt-1",md:"px-5 pb-5 pt-1.5"},Vs=({title:t,subtitle:s,meta:r,actions:n,onBack:a,editable:l,onTitleChange:o,surface:u=!1,headerContent:c,loading:p=!1,loadingShape:x="table",empty:f,padding:g="md",scroll:b=!0,className:N,contentClassName:v,children:m})=>{const k=p?e.jsx(Me,{variant:"inline",shape:x}):f?e.jsx("div",{className:"flex flex-col items-center justify-center py-12",children:f}):m;return e.jsxs("div",{className:i(b?"flex h-full min-h-0 flex-col":"flex flex-col",N),children:[e.jsx(tt,{surface:u,title:t,subtitle:s,meta:r,actions:n,onBack:a,editable:l,onTitleChange:o,className:b?"shrink-0":void 0,children:c}),e.jsx("div",{className:i(b&&"min-h-0 flex-1 overflow-y-auto",qs[g],v),children:k})]})},be=({actions:t,defaultVariant:s="secondary",className:r})=>t.length===0?null:e.jsx("div",{className:i("flex flex-wrap items-center gap-2",r),children:t.map(n=>n.render?e.jsx(d.Fragment,{children:n.render()},n.id):n.splitOptions&&n.splitOptions.length>0?e.jsx(Ie,{label:n.label,onClick:n.onClick,icon:n.icon,variant:n.variant==="primary"?"primary":"secondary",options:n.splitOptions,disabled:n.disabled},n.id):e.jsx(re,{variant:n.variant??s,onClick:a=>{a.stopPropagation(),a.target.blur(),n.onClick()},disabled:n.disabled,leftIcon:n.icon,children:n.label},n.id))}),Us={none:"p-0",sm:"p-2",md:"px-5 py-4",lg:"p-6"},Ks=({actions:t=[],onBack:s,backLabel:r="Back",className:n,padding:a="md",children:l})=>e.jsxs("div",{className:i("flex items-center gap-2",Us[a],n),children:[s&&e.jsx(re,{variant:"secondary",onClick:s,"aria-label":r,leftIcon:e.jsx(Z,{icon:F.ChevronLeft,size:"sm"}),iconOnly:!0}),l&&e.jsx("div",{className:"min-w-0 flex-1",children:l}),e.jsx(be,{actions:t,className:i(!l&&"ml-auto")})]}),Ws=({label:t,meta:s,action:r,className:n})=>e.jsxs("div",{className:i("flex items-center gap-2 px-1 pb-2 pt-7 first:pt-0",n),children:[e.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-label text-text-subtle",children:t}),s&&e.jsx("span",{className:"min-w-0 flex-1 truncate text-right text-xs tabular-nums text-text-subtle",children:s}),r&&e.jsx("span",{className:"ml-auto shrink-0",children:r})]});function Gs({label:t,trailing:s,align:r="center",className:n}){const a=e.jsx("span",{className:"h-px flex-1 bg-border-subtle","aria-hidden":!0});return!t&&!s?e.jsx("div",{className:i("flex items-center py-2",n),children:a}):e.jsxs("div",{className:i("flex items-center gap-3 py-2",n),children:[r==="center"&&a,e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-muted",children:t}),a,s&&e.jsx("span",{className:"shrink-0",children:s})]})}const st=d.createContext(null),Js=st.Provider;function rt(){return d.useContext(st)}function Xs(){const[t,s]=d.useState(null),r=d.useMemo(()=>({setTrail:(n,a)=>s(l=>a?{ownerId:n,entry:a}:l&&l.ownerId!==n?l:null)}),[]);return{trail:t?.entry??null,api:r}}const Ys={none:"",sm:"px-3 py-3",md:"px-5 py-4"},Zs=({children:t,actions:s=[],secondaryActions:r=[],actionsPlacement:n="header",onBack:a,backLabel:l="Back",title:o,loading:u=!1,loadingShape:c="form",padding:p="md",className:x,contentClassName:f})=>{const g=rt(),b=d.useId(),N=d.useRef(a);N.current=a;const v=!!a,m=d.useRef(s);m.current=s;const k=d.useRef(r);k.current=r;const w=n==="header",I=w&&(s.length>0||r.length>0);I&&JSON.stringify([...r,...s].map(B=>[B.id,B.label,B.variant,B.disabled]));const z=d.useMemo(()=>{if(!I)return;const B=D=>($,L)=>({...$,onClick:()=>{(D==="primary"?m.current:k.current)[L]?.onClick()}});return{actions:m.current.map(B("primary")),secondaryActions:k.current.map(B("secondary"))}},[I]);d.useEffect(()=>{if(g&&!(!v&&!o&&!z))return g.setTrail(b,{title:o,onBack:v?()=>N.current?.():void 0,actions:z?.actions,secondaryActions:z?.secondaryActions}),()=>g.setTrail(b,null)},[g,b,o,v,z]);const X=!w&&(s.length>0||r.length>0);return e.jsxs("div",{className:i("flex min-h-full flex-col",x),children:[!g&&(v||o||I)&&e.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-5 pt-4",children:[v&&e.jsx(re,{variant:"ghost",onClick:()=>N.current?.(),"aria-label":l,leftIcon:e.jsx(Z,{icon:F.ChevronLeft,size:"sm"}),iconOnly:!0}),o&&e.jsx("h2",{className:"min-w-0 truncate text-md font-semibold tracking-title text-text",children:o}),w&&e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.length>0&&e.jsx(be,{actions:r,defaultVariant:"ghost"}),s.length>0&&e.jsx(be,{actions:s})]})]}),e.jsx("div",{className:i("flex-1",Ys[p],f),children:u?e.jsx(Me,{variant:"inline",shape:c}):t}),X&&e.jsxs("div",{className:"sticky bottom-0 z-10 flex shrink-0 items-center gap-2 border-t border-border bg-surface px-5 py-3",children:[r.length>0&&e.jsx(be,{actions:r,defaultVariant:"ghost"}),s.length>0&&e.jsx(be,{actions:s,className:"ml-auto"})]})]})};function Qs({label:t,description:s,control:r,bordered:n=!1,disabled:a=!1,className:l}){return e.jsxs("div",{className:i("flex items-center justify-between gap-4 py-2",n&&"rounded-lg border border-border px-3",a&&"opacity-50",l),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-text",children:t}),s&&e.jsx("div",{className:"text-xs text-text-muted",children:s})]}),e.jsx("div",{className:"shrink-0",children:r})]})}function er({icon:t,title:s,description:r,actions:n,children:a,className:l}){return e.jsxs("section",{className:i("flex flex-col gap-2",l),children:[e.jsxs("div",{className:"flex items-start gap-2",children:[t&&e.jsx(Z,{icon:t,size:"md",color:"secondary",className:"mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-semibold text-text",children:s}),r&&e.jsx("p",{className:"text-xs text-text-muted",children:r})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:i("flex flex-col",t&&"pl-6"),children:a})]})}function tr({label:t,dotColor:s,onClick:r,className:n}){return e.jsxs("button",{type:"button",onClick:r,className:i("inline-flex max-w-full items-center gap-1.5 rounded-full bg-surface-sunk px-2.5 py-1 text-xs text-text-muted transition-colors duration-fast ease-out hover:bg-surface-hover hover:text-text",n),children:[s&&e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:s},"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:t}),e.jsx(Z,{icon:F.ArrowUpRight,size:"xs",className:"opacity-70"})]})}const sr=()=>e.jsx(Z,{icon:F.Calendar,size:"md",color:"current"}),rr=()=>e.jsx(Z,{icon:F.ChevronLeft,size:"md",color:"current"}),nr=()=>e.jsx(Z,{icon:F.ChevronRight,size:"md",color:"current"}),Ee=d.forwardRef(({value:t,onChange:s,placeholder:r="Select date",disabled:n=!1,required:a=!1,size:l="md",className:o,minDate:u,maxDate:c,format:p="MM/dd/yyyy",withTime:x=!1},f)=>{const[g,b]=d.useState(!1),[N,v]=d.useState(()=>t||new Date),m=d.useRef(null),k=d.useRef(null),w=ve(g,k);d.useEffect(()=>{const j=h=>{m.current&&!m.current.contains(h.target)&&b(!1)};return g&&document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[g]);const I=j=>{if(!j)return"";const h=j.getDate().toString().padStart(2,"0"),S=(j.getMonth()+1).toString().padStart(2,"0"),_=j.getFullYear(),E=p==="dd/MM/yyyy"?`${h}/${S}/${_}`:p==="yyyy-MM-dd"?`${_}-${S}-${h}`:`${S}/${h}/${_}`;return x?`${E} ${z(j)}`:E},z=j=>`${j.getHours().toString().padStart(2,"0")}:${j.getMinutes().toString().padStart(2,"0")}`,X=j=>{const[h,S]=j.split(":").map(Number);if(Number.isNaN(h)||Number.isNaN(S))return;const _=t?new Date(t):new Date;_.setHours(h,S,0,0),s?.(_)},B=()=>{const j=N.getFullYear(),h=N.getMonth(),S=new Date(j,h,1),_=new Date(S);_.setDate(_.getDate()-S.getDay());const E=[],R=new Date(_);for(let M=0;M<42;M++)E.push(new Date(R)),R.setDate(R.getDate()+1);return E},D=j=>{if(j.getMonth()===N.getMonth()&&!(u&&j<u)&&!(c&&j>c)){if(x){const S=new Date(j);S.setHours(t?.getHours()??0,t?.getMinutes()??0,0,0),s?.(S);return}s?.(j),b(!1)}},$=()=>{v(new Date(N.getFullYear(),N.getMonth()-1,1))},L=()=>{v(new Date(N.getFullYear(),N.getMonth()+1,1))},H=()=>{s?.(null),b(!1)},V=i("w-full border border-border-strong rounded-tile transition-colors duration-fast","bg-surface text-text","placeholder:text-text-muted","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",{"h-control-sm px-3 text-sm":l==="sm","h-control-md px-3 text-base":l==="md","h-control-lg px-3 text-base":l==="lg","h-control-md w-full px-3 text-base":l==="full"},o),ee=B(),W=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:m,className:"relative",children:[e.jsxs("div",{ref:k,className:"relative",children:[e.jsx("input",{ref:f,type:"text",value:I(t??null),placeholder:r,disabled:n,required:a,readOnly:!0,onClick:()=>!n&&b(!g),className:i(V,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!n&&b(!g),disabled:n,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted hover:text-text-muted",children:e.jsx(sr,{})})]}),g&&e.jsxs("div",{style:w,className:"fixed z-overlay overflow-auto rounded-lg border border-border bg-surface p-4 shadow-overlay min-w-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:$,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(rr,{})}),e.jsxs("h3",{className:"text-sm font-medium text-text",children:[W[N.getMonth()]," ",N.getFullYear()]}),e.jsx("button",{onClick:L,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(nr,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(j=>e.jsx("div",{className:"text-xs font-medium text-text-muted text-center py-1",children:j},j))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:ee.map((j,h)=>{const S=j.getMonth()===N.getMonth(),_=t&&j.toDateString()===t.toDateString(),E=j.toDateString()===new Date().toDateString(),R=!S||u&&j<u||c&&j>c;return e.jsx("button",{onClick:()=>!R&&D(j),disabled:R,className:i("w-8 h-8 text-sm rounded transition-colors duration-fast",{"text-text hover:bg-surface-hover":S&&!_&&!R,"bg-accent text-accent-fg":_,"bg-surface-hover text-text":E&&!_,"text-text-muted cursor-not-allowed":R}),children:j.getDate()},h)})}),x&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-border pt-3",children:[e.jsx("label",{htmlFor:"datepicker-time",className:"text-sm text-text-muted",children:"Tijd"}),e.jsx("input",{id:"datepicker-time",type:"time",value:t?z(t):"",onChange:j=>X(j.target.value),className:"h-control-sm rounded-md border border-border bg-surface-input px-2 text-sm text-text focus-visible:outline-none focus-visible:focus-ring"})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-border",children:[e.jsx("button",{onClick:H,className:"text-sm text-text-muted hover:text-text",children:"Clear"}),e.jsx("button",{onClick:()=>b(!1),className:"text-sm text-info-fg hover:underline",children:"Close"})]})]})]})}),He=d.forwardRef(({value:t,onValueChange:s,hint:r,size:n="md",clearLabel:a="Clear search",containerClassName:l,className:o,disabled:u,...c},p)=>e.jsxs("div",{className:i("flex items-center gap-2 rounded-md bg-surface-sunk px-2.5 text-text-muted","transition-colors duration-fast ease-out",n==="sm"?"h-control-sm":"h-control-md",u&&"opacity-60",l),children:[e.jsx(Z,{icon:F.Search,size:"md",color:"current",className:"shrink-0"}),e.jsx("input",{ref:p,type:"search",value:t,disabled:u,onChange:x=>s(x.target.value),className:i("min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-text shadow-none","placeholder:text-text-subtle","focus:border-0 focus:shadow-none focus:outline-none focus:ring-0","[&::-webkit-search-cancel-button]:appearance-none",o),...c}),t?e.jsx("button",{type:"button","aria-label":a,onClick:()=>s(""),className:"grid size-4 shrink-0 cursor-pointer place-items-center rounded-xs text-text-subtle transition-colors duration-fast ease-out hover:text-text focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(Z,{icon:F.X,size:"sm",color:"current"})}):r&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:r})]}));He.displayName="SearchField";const nt=({trigger:t,options:s,value:r,onSelect:n,placement:a="bottom-start",disabled:l=!1,className:o,showCheck:u=!0,header:c})=>{const[p,x]=d.useState(!1),[f,g]=d.useState(null),[b,N]=d.useState({top:0,left:0}),v=d.useRef(null),m=d.useRef(null),k=d.useRef(null),w=d.useRef(null),I=ve(p,m,{placement:a}),z=d.useRef(null),X=()=>Array.from(w.current?.querySelectorAll("button[data-option-value]:not(:disabled)")??[]);d.useEffect(()=>{p&&X()[0]?.focus()},[p,X]);const B=j=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(j.key))return;const S=X();if(S.length===0)return;j.preventDefault();const _=S.indexOf(document.activeElement),E=j.key==="Home"?0:j.key==="End"?S.length-1:j.key==="ArrowDown"?(_+1)%S.length:(_-1+S.length)%S.length;S[E]?.focus()};d.useEffect(()=>{const j=h=>{v.current&&(!v.current.contains(h.target)||k.current&&!k.current.contains(h.target))&&(x(!1),g(null),z.current&&(clearTimeout(z.current),z.current=null))};return p&&document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[p]),d.useEffect(()=>{const j=h=>{h.key==="Escape"&&(x(!1),g(null),m.current?.focus(),z.current&&(clearTimeout(z.current),z.current=null))};return p&&document.addEventListener("keydown",j),()=>{document.removeEventListener("keydown",j)}},[p]),d.useEffect(()=>{if(f&&v.current){const j=v.current.querySelector(`[data-option-value="${f}"]`);if(j){const h=j.getBoundingClientRect();N({top:h.top,left:h.right+8})}}},[f]),d.useEffect(()=>()=>{z.current&&clearTimeout(z.current)},[]);const D=j=>{j.stopPropagation(),!l&&(x(!p),g(null),z.current&&(clearTimeout(z.current),z.current=null))},$=(j,h,S)=>{j.stopPropagation(),!h.disabled&&!h.divider&&(!h.children||h.children.length===0)&&(n?.(h.value,S),x(!1),g(null))},L=j=>{z.current&&(clearTimeout(z.current),z.current=null),j.children&&j.children.length>0?g(j.value):g(null)},H=j=>{j.children&&j.children.length>0?z.current=setTimeout(()=>{g(null)},150):g(null)},V=(j,h,S)=>{j.stopPropagation(),!h.disabled&&!h.divider&&(n?.(h.value,S),x(!1),g(null))},ee=i("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto"),W=i("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto");return e.jsxs("div",{ref:v,className:i("relative flex flex-row items-center justify-center rounded-lg hover:bg-surface-hover",o),children:[e.jsx("button",{ref:m,onClick:D,disabled:l,"aria-haspopup":"menu","aria-expanded":p,className:i("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":l}),children:t}),p&&e.jsx("div",{ref:w,className:ee,style:I,onKeyDown:B,children:e.jsxs("div",{className:"p-2",role:"menu",children:[c&&(typeof c=="string"?e.jsx("div",{className:"text-xs font-medium text-text-muted uppercase tracking-label px-3 py-2",children:c}):c),s.map((j,h)=>{if(j.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${h}`);const S=j.children&&j.children.length>0,_=f===j.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":j.value,role:"menuitem","aria-haspopup":S?"menu":void 0,onClick:E=>$(E,j),onMouseEnter:()=>L(j),onMouseLeave:()=>H(j),disabled:j.disabled,className:i("flex w-full items-center justify-between rounded-md px-3 py-1.5 text-sm text-text transition-colors duration-fast ease-out hover:bg-surface-hover focus-visible:outline-none focus-visible:focus-ring",{"opacity-50 cursor-not-allowed":j.disabled,"bg-surface-hover":_&&S}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[j.icon&&e.jsx("span",{className:"flex-shrink-0",children:j.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:j.label}),j.description&&e.jsx("span",{className:"text-xs text-text-muted",children:j.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[u&&r===j.value&&e.jsx(F.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0}),S&&e.jsx("span",{className:"text-text-muted text-xs",children:"▶"})]})]}),S&&_&&e.jsx("div",{ref:k,className:W,style:{top:`${b.top}px`,left:`${b.left}px`},onMouseEnter:()=>{z.current&&(clearTimeout(z.current),z.current=null),g(j.value)},onMouseLeave:()=>{z.current=setTimeout(()=>{g(null)},150)},children:e.jsx("div",{className:"p-2",children:j.children?.map((E,R)=>{if(E.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${R}`);const M=typeof r=="object"&&r[j.value]&&r[j.value].includes(E.value)||r===E.value;return e.jsxs("button",{onClick:ae=>V(ae,E,j.value),disabled:E.disabled,className:i("flex w-full items-center justify-between rounded-md px-3 py-1.5 text-sm text-text transition-colors duration-fast ease-out hover:bg-surface-hover",{"opacity-50 cursor-not-allowed":E.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[E.icon&&e.jsx("span",{className:"flex-shrink-0",children:E.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:E.label}),E.description&&e.jsx("span",{className:"text-xs text-text-muted",children:E.description})]})]}),u&&M&&e.jsx(F.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0})]},E.value)})})})]},j.value)}),(()=>{const j=s.reduce((h,S)=>{if(S.divider)return h;const _=S.children?S.children.filter(E=>!E.divider).length:0;return h+1+_},0);return j>1&&e.jsx("div",{className:"border-t border-border mt-2 pt-2",children:e.jsxs("div",{className:"text-xs text-text-muted px-3 py-1",children:[j," options available"]})})})()]})})]})},ar=t=>s=>t(s instanceof Date?s:null),lr=t=>s=>t(typeof s=="string"?s:""),or=t=>s=>t(Array.isArray(s)?s:typeof s=="string"&&s?[s]:[]),cr={none:"px-0",sm:"px-2",md:"px-3.5",lg:"px-5"},ir={sm:"h-row-lg",md:"h-row-xl",lg:"h-14"},dr=8,We=["62%","44%","74%","52%","68%","48%","80%","56%"];function ur(t,s){if(s<=7)return Array.from({length:s},(l,o)=>o);const n=[...new Set([0,s-1,t-1,t,t+1])].filter(l=>l>=0&&l<s).sort((l,o)=>l-o),a=[];return n.forEach((l,o)=>{o>0&&l-n[o-1]>1&&a.push("gap"),a.push(l)}),a}const xr=t=>{const s=Array.isArray(t.value)?t.value:t.value!=null&&t.value!==""&&t.value!=="all"?[t.value]:[];if(t.type==="date"){const o=t.value instanceof Date;return e.jsx(Ee,{value:t.value,onChange:u=>t.onChange(u),placeholder:t.placeholder||t.label,className:i("min-w-40",o&&"bg-info-soft text-info-fg")})}const r=o=>t.options?.find(u=>u.value===o)?.label??String(o),n=o=>Array.isArray(t.value)?t.value.includes(o):t.value===o,a=o=>{if(!t.multiSelect)return t.onChange(o);const u=Array.isArray(t.value)?t.value:[];t.onChange(u.includes(o)?u.filter(c=>c!==o):[...u,o])},l=s.length>0;return e.jsx(Ye,{tone:"outline",caret:!0,icon:t.icon,active:l,label:l?`${t.label}: ${s.map(r).join(", ")}`:t.label,title:t.label,onClear:()=>t.onChange(t.multiSelect?[]:"all"),menu:o=>e.jsx("div",{role:"listbox",className:"flex flex-col",children:t.options?.map(u=>e.jsx("button",{type:"button",role:"option","aria-selected":n(u.value),onClick:()=>{a(u.value),t.multiSelect||o()},className:i("flex cursor-pointer items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm","transition-colors duration-fast ease-out hover:bg-surface-hover","focus-visible:outline-none focus-visible:focus-ring",n(u.value)?"font-medium text-text":"text-text-muted"),children:u.label},u.value))})})},_e=({data:t,columns:s,loading:r=!1,searchable:n=!1,searchPlaceholder:a="Search...",searchValue:l,onSearchChange:o,filters:u=[],toolbarActions:c=[],toolbarContent:p,groupBy:x,groups:f,paginated:g=!1,defaultPageSize:b=10,actions:N=[],onRowClick:v,selectable:m=!1,selectedRows:k=[],onSelectionChange:w,getRowKey:I=(ee,W)=>W,emptyContent:z,footerSummary:X,size:B="md",hoverable:D=!0,padding:$="md",className:L,rowClassName:H,headerBackground:V=!0})=>{const[ee,W]=d.useState(""),j=l!==void 0,h=j?l:ee,S=o??W,[_,E]=d.useState({column:null,direction:null}),[R,M]=d.useState({page:0,pageSize:b}),ae=d.useRef(null),le=d.useMemo(()=>{let A=t;if(n&&!j&&h.trim()){const J=s.filter(oe=>oe.searchable!==!1),se=h.toLowerCase();A=A.filter(oe=>J.some(Q=>{const U=typeof Q.accessor=="function"?Q.accessor(oe):oe[Q.accessor];return String(U||"").toLowerCase().includes(se)}))}return A},[t,h,j,s,n]),G=d.useMemo(()=>{if(!_.column||!_.direction)return le;const A=s.find(J=>J.id===_.column);return A?[...le].sort((J,se)=>{const oe=typeof A.accessor=="function"?A.accessor(J):J[A.accessor],Q=typeof A.accessor=="function"?A.accessor(se):se[A.accessor];let U=0;return oe<Q?U=-1:oe>Q&&(U=1),_.direction==="desc"?-U:U}):le},[le,_,s]),K=d.useMemo(()=>{if(!g||x)return G;const A=R.page*R.pageSize,J=A+R.pageSize;return G.slice(A,J)},[G,R,g,x]),P=d.useCallback(A=>{s.find(se=>se.id===A)?.sortable&&E(se=>se.column!==A?{column:A,direction:"asc"}:se.direction==="asc"?{column:A,direction:"desc"}:{column:null,direction:null})},[s]),C=d.useCallback(A=>{M(J=>({...J,page:A}))},[]),T=d.useCallback((A,J)=>{if(!w)return;const se=I(A,0);w(J?[...k,A]:k.filter((oe,Q)=>I(k[Q],Q)!==se))},[k,w,I]),Y=d.useCallback(A=>{w&&w(A?[...K]:[])},[K,w]);d.useEffect(()=>{M(A=>({...A,page:0}))},[]),d.useEffect(()=>{M(A=>({...A,page:0}))},[]);const q=G.length,y=Math.ceil(q/R.pageSize),O=R.page*R.pageSize+1,te=Math.min(O+R.pageSize-1,q),ne=K.length>0&&K.every(A=>{const J=I(A,0);return k.some((se,oe)=>I(se,oe)===J)}),xe=K.some(A=>{const J=I(A,0);return k.some((se,oe)=>I(se,oe)===J)}),me=cr[$],de=V?"bg-surface-sunk":"bg-surface",ue=i("text-text",me),Ae=n||u.length>0||c.length>0||!!p,jt=d.useMemo(()=>{const A=K.map((Q,U)=>({row:Q,index:U}));if(!x)return[{group:null,rows:A}];const J=new Map;for(const Q of A){const U=x(Q.row,Q.index),fe=J.get(U);fe?fe.push(Q):J.set(U,[Q])}const se=f??[];return[...se.filter(Q=>J.has(Q.id)),...[...J.keys()].filter(Q=>!se.some(U=>U.id===Q)).map(Q=>({id:Q}))].map(Q=>({group:Q,rows:J.get(Q.id)??[]}))},[K,x,f]),yt=s.length+(m?1:0)+(N.length>0?1:0),Ue=g&&q>0,Nt=Ue||X!==void 0;return e.jsxs("div",{className:i("flex min-w-0 flex-col",L),children:[Ae&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pb-3",children:[n&&e.jsx(He,{value:h,onValueChange:S,placeholder:a,containerClassName:"w-full sm:w-66"}),u.map(A=>e.jsx(xr,{...A},A.id)),p,c.length>0&&e.jsx(be,{actions:c,className:"ml-auto"})]}),e.jsx("div",{className:"relative w-full overflow-x-auto rounded-lg ring-1 ring-border",children:e.jsxs("table",{ref:ae,className:"min-w-full border-collapse text-base text-text",children:[e.jsx("thead",{className:i(de,"h-control-lg"),children:e.jsxs("tr",{children:[m&&e.jsx("th",{className:i(ue,"w-10"),children:e.jsx(he,{size:"sm",checked:ne,indeterminate:xe&&!ne,onChange:A=>Y(A.target.checked),"aria-label":"Select all rows"})}),s.map(A=>e.jsx("th",{className:i(ue,"text-xs font-semibold uppercase tracking-label text-text-muted","group",{"text-left":A.align==="left"||!A.align,"text-center":A.align==="center","text-right":A.align==="right","cursor-pointer select-none":A.sortable,[`sticky left-0 ${de}`]:A.sticky==="left",[`sticky right-0 ${de}`]:A.sticky==="right"}),style:{width:A.width},onClick:()=>A.sortable&&P(A.id),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[A.headerCell?A.headerCell():A.header,A.sortable&&e.jsx(Z,{icon:_.column===A.id&&_.direction==="desc"?F.ChevronDown:F.ChevronUp,size:"xs",className:i("transition-opacity duration-fast ease-out",_.column===A.id?"text-text opacity-100":"text-text-subtle opacity-0 group-hover:opacity-100")})]})},A.id)),N.length>0&&e.jsx("th",{className:i(ue,"w-10"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:r?Array.from({length:dr}).map((A,J)=>e.jsxs("tr",{className:"animate-pulse border-t border-border-subtle","aria-hidden":!0,children:[m&&e.jsx("td",{className:i(ue,"h-row-lg"),children:e.jsx("span",{className:"block size-4 rounded-xs bg-surface-hover"})}),s.map((se,oe)=>e.jsx("td",{className:i(ue,"h-row-lg"),style:{width:se.width},children:e.jsx("span",{className:"block h-3 rounded-xs bg-surface-hover",style:{width:We[(J+oe)%We.length]}})},se.id)),N.length>0&&e.jsx("td",{className:i(ue,"h-row-lg")})]},`skeleton-${J}`)):K.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(m?1:0)+(N.length>0?1:0),className:i(ue,"border-t border-border-subtle py-10 text-center text-text-muted"),children:z||"No data available"})}):jt.flatMap(A=>[...A.group?[e.jsx("tr",{children:e.jsx("td",{colSpan:yt,className:i("border-t border-border-subtle bg-surface px-4 pb-1.5 pt-4 text-sm font-semibold",A.group.tone==="danger"?"text-danger-fg":A.group.tone==="muted"?"text-text-subtle":"text-text"),children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[A.group.title??A.group.id,e.jsx("span",{className:"rounded-full bg-surface-sunk px-1.5 py-0.5 text-xs font-medium text-text-muted tabular-nums",children:A.group.count??A.rows.length})]})})},`group-${A.group.id}`)]:[],...A.rows.map(({row:J,index:se})=>{const oe=I(J,se),Q=k.some((U,fe)=>I(U,fe)===oe);return e.jsxs("tr",{className:i(ir[B],"border-t border-border-subtle",D&&"transition-colors duration-fast ease-out hover:bg-surface-hover",v&&"cursor-pointer",Q&&"bg-accent-soft",H?.(J,se)),onClick:U=>{U.stopPropagation(),v?.(J,se)},children:[m&&e.jsx("td",{className:ue,children:e.jsx(he,{size:"sm",checked:Q,onClick:U=>U.stopPropagation(),onChange:U=>{U.stopPropagation(),T(J,U.target.checked)},"aria-label":"Select row"})}),s.map(U=>{const fe=typeof U.accessor=="function"?U.accessor(J):J[U.accessor];return e.jsx("td",{className:i(ue,{"text-left":U.align==="left"||!U.align,"text-center":U.align==="center","text-right":U.align==="right","sticky left-0 bg-surface":U.sticky==="left","sticky right-0 bg-surface":U.sticky==="right"}),children:U.cell?U.cell(fe,J,se):String(fe||"")},U.id)}),N.length>0&&e.jsx("td",{className:ue,children:e.jsx(nt,{className:"rounded-md",trigger:e.jsx("span",{className:"grid size-7 place-items-center text-text-subtle",children:e.jsx(Z,{icon:F.Ellipsis,size:"md",color:"current"})}),options:N.map(U=>({value:U.id,label:U.label,icon:U.icon,disabled:U.disabled?.(J)})),onSelect:U=>{const fe=N.find(wt=>wt.id===U);fe&&fe.onClick(J,se)},placement:"bottom-end"})})]},oe)})])})]})}),Nt&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-1 pt-3 text-xs text-text-muted",children:[e.jsx("span",{className:"min-w-0 flex-1",children:X??`Showing ${O}–${te} of ${q}`}),Ue&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(re,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Previous page",onClick:()=>C(R.page-1),disabled:R.page===0,children:e.jsx(Z,{icon:F.ChevronLeft,size:"md",color:"current"})}),ur(R.page,y).map((A,J)=>A==="gap"?e.jsx("span",{className:"px-1 text-text-subtle",children:"…"},`gap-${J}`):e.jsx("button",{type:"button","aria-current":A===R.page?"page":void 0,onClick:()=>C(A),className:i("h-control-xs min-w-6 cursor-pointer rounded-sm px-1.5 tabular-nums","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",A===R.page?"bg-surface-sunk font-semibold text-text":"text-text-muted hover:bg-surface-hover hover:text-text"),children:A+1},A)),e.jsx(re,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Next page",onClick:()=>C(R.page+1),disabled:R.page>=y-1,children:e.jsx(Z,{icon:F.ChevronRight,size:"md",color:"current"})})]})]})]})},fr={default:"bg-surface-hover text-text",primary:"bg-accent-soft text-accent",secondary:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg",warning:"bg-warning-soft text-warning-fg",error:"bg-danger-soft text-danger-fg",info:"bg-info-soft text-info-fg",note:"bg-note-soft text-note"},mr={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},hr={default:"bg-surface-hover",primary:"bg-accent",secondary:"bg-surface-hover",success:"bg-success",warning:"bg-warning",error:"bg-danger",info:"bg-info",note:"bg-note"};function at({variant:t="default",size:s="md",dot:r=!1,icon:n,dismissible:a=!1,onDismiss:l,className:o,children:u,...c}){return e.jsxs("span",{className:i("inline-flex items-center font-medium rounded-full",fr[t],mr[s],o),...c,children:[r&&e.jsx("span",{className:i("w-2 h-2 rounded-full mr-1.5",hr[t])}),n&&e.jsx("span",{className:i("flex-shrink-0",u&&"mr-1"),children:n}),u,a&&l&&e.jsx("button",{onClick:l,className:"ml-1.5 flex-shrink-0 hover:opacity-70 transition-opacity","aria-label":"Remove badge",children:e.jsx(Z,{icon:F.X,size:"xs",color:"current"})})]})}function lt(t){const{id:s,header:r,accessor:n,label:a,tone:l,visible:o,width:u,sortable:c,align:p}=t;return{id:s,header:r,accessor:x=>a(n(x),x),cell:(x,f)=>{const g=n(f);return o&&!o(g,f)?null:e.jsx(at,{variant:l?l(g,f):"default",size:"sm",children:a(g,f)})},width:u,sortable:c,align:p}}function gr(t){const{id:s,header:r,accessor:n,onLabel:a,offLabel:l,onTone:o="success",offTone:u="secondary",width:c,sortable:p}=t;return lt({id:s,header:r,accessor:x=>!!n(x),label:x=>x?a:l,tone:x=>x?o:u,width:c,sortable:p})}function br(t){const{id:s,header:r,accessor:n,label:a,empty:l="—",separator:o=", ",width:u,searchable:c,sortable:p}=t;return{id:s,header:r,accessor:x=>{const f=n(x),b=(f==null?[]:Array.isArray(f)?f:[f]).filter(Boolean).map(N=>a(N)??N);return b.length?b.join(o):l},width:u,searchable:c,sortable:p}}const pr={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},vr={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},jr={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text",current:"text-current",muted:"text-text-subtle"},yr={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"},Nr={tight:"leading-tight",normal:"leading-normal",relaxed:"leading-relaxed"},ce=({variant:t="body",size:s="md",weight:r="normal",color:n="current",align:a="left",truncate:l=!1,italic:o=!1,underline:u=!1,lineHeight:c="normal",as:p,className:x,children:f,...g})=>{const b=p||wr(t),N=t==="caption",v=t==="label",m=t==="code",k=i("font-sans",N&&"text-xs text-text-subtle",v&&"text-xs font-semibold uppercase tracking-label text-text-subtle",m&&"font-mono text-sm rounded-sm bg-surface-hover px-1 py-0.5",!N&&!v&&!m&&pr[s],!v&&vr[r],jr[n],yr[a],t==="body"&&Nr[c],o&&"italic",u&&"underline",l&&"truncate",x);return e.jsx(b,{className:k,...g,children:f})};function wr(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}function kr(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}const Cr=({groups:t,data:s,size:r="md",className:n})=>{const a=x=>{if(!x)return"-";try{return new Date(x).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(x)}},l=x=>x?"Ja":"Nee",o=(x,f)=>{if(!f)return String(x||"-");const g=f.find(b=>b.value===x);return g?g.label:String(x||"-")},u=d.useCallback(x=>{const f=kr(s,x.name);if(x.type==="array"){const b=f;return!b||b.length===0?e.jsx(ce,{variant:"body",size:"sm",className:"text-text-muted",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:b.map((N,v)=>e.jsxs("div",{className:"p-4 border border-border rounded-xl space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(ce,{variant:"label",size:"sm",weight:"medium",className:"text-text-muted",children:[x.label," ",v+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:x.arrayFields?.map(m=>{const k=N?.[m.name];let w="-";switch(m.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":w=k||"-";break;case"select":case"radio":w=o(k,m.options);break;case"checkbox":w=l(k);break;case"date":w=a(k);break;case"custom":w=m.customComponent?.({value:k});break;default:w=String(k||"-")}return m.format&&(w=m.format(k,N)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ce,{variant:"label",size:"xs",className:"text-text-muted",children:m.label}),e.jsx(ce,{variant:"body",size:"sm",className:"text-text",children:w})]},m.name)})})]},v))})}if(x.type==="custom"&&x.customComponent)return x.customComponent({value:f});if(x.format){const b=x.format(f,s);return e.jsx(ce,{variant:"body",size:"sm",className:"text-text",children:b})}let g="-";switch(x.type){case"text":case"email":case"password":case"number":case"tel":case"url":g=f?String(f):"-";break;case"textarea":g=f?e.jsx("div",{className:"whitespace-pre-wrap",children:String(f||"-")}):"-";break;case"select":case"radio":g=o(f,x.options);break;case"checkbox":g=l(f);break;case"date":g=a(f);break;default:g=f?String(f):"-"}return e.jsx(ce,{variant:"body",size:"sm",className:"text-text",children:g})},[s,o,a,l]),c=d.useCallback(x=>{if(x.conditional&&!x.conditional(s))return null;const f=x.items.filter(b=>!(b.hidden||b.conditional&&!b.conditional(s)));if(f.length===0)return null;const g=i("space-y-4",{"grid gap-4":x.layout==="grid","flex flex-wrap gap-4":x.layout==="flex"},x.layout==="grid"&&{"grid-cols-1":!x.columns||x.columns===1,"grid-cols-2":x.columns===2,"grid-cols-3":x.columns===3,"grid-cols-4":x.columns===4},x.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 p-6 border border-border rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(ce,{variant:"label",size:"lg",weight:"semibold",className:"text-text",children:x.title}),x.description&&e.jsx(ce,{variant:"body",size:"sm",className:"text-text-muted mt-1",children:x.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:g,children:f.map(b=>e.jsxs("div",{className:"space-y-1",style:{width:typeof b.width=="string"?b.width:void 0,gridColumn:typeof b.width=="number"?`span ${b.width} / span ${b.width}`:void 0},children:[b.type!=="custom"&&e.jsx(ce,{variant:"label",size:"sm",className:"font-medium text-text-muted",children:b.label}),u(b)]},b.name))})})]},x.id)},[s,u]),p=i("space-y-6",{"max-w-md":r==="sm","max-w-2xl":r==="md","max-w-4xl":r==="lg","max-w-full":r==="full"},n);return e.jsx("div",{className:p,children:e.jsx("div",{className:"space-y-8",children:t.map(c)})})};class Sr extends d.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error(`[ErrorBoundary] Error in ${this.props.name||"Component"}:`,s,r)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:e.jsxs("div",{className:"p-4 m-4 border border-danger-border bg-danger-soft rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold text-danger-fg",children:"Something went wrong"}),e.jsx("p",{className:"text-sm text-danger-fg mt-1",children:this.props.name?`Error in ${this.props.name}`:"The component failed to render."}),e.jsx("button",{className:"mt-4 px-4 py-2 bg-danger text-danger-fg rounded hover:opacity-90 transition-opacity text-sm",onClick:()=>this.setState({hasError:!1,error:null}),children:"Try again"})]}):this.props.children}}const ze=new Map;function Er({identifier:t,resourceLoader:s,framework:r="react",fallback:n,errorFallback:a,componentProps:l,className:o}){const u=d.useRef(null),[c,p]=d.useState(null),[,x]=d.useState(0),f=d.useRef(null),g=d.useRef(s);g.current=s,d.useEffect(()=>{if(ze.has(t))return;let k=!0;return(async()=>{try{const I=await g.current();if(!k)return;ze.set(t,I),x(z=>z+1)}catch(I){console.error(`[FederatedResource] Load failed: ${t}`,I),k&&p(t)}})(),()=>{k=!1}},[t]);const b=ze.get(t)??null,N=!b&&c===t,v=!b&&!N,m=b?r==="react"&&(b.component||b.default)||b:null;return d.useEffect(()=>{if(!m||r==="react")return;const k=u.current;if(k){if(r==="svelte"){const w=m.default||m,I=new w({target:k,props:l||{}});return f.current=I,()=>I.$destroy()}if(m.mount){const w=m.mount({container:k,props:l||{}});return()=>{typeof w=="function"?w():m.unmount?.(k)}}}},[m,r,l]),d.useEffect(()=>{r==="svelte"&&f.current&&f.current.$set?.(l)},[l,r]),e.jsxs("div",{ref:u,className:o,style:{display:"contents"},children:[v&&n,N&&a,r==="react"&&m&&e.jsx(m,{...l})]})}const Tr={neutral:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg"};function Mr({icon:t,tone:s="neutral",title:r,description:n,actions:a,card:l=!1,className:o,...u}){return e.jsxs("div",{className:i("flex flex-col items-center gap-2.5 text-center",l&&"rounded-lg border border-border bg-surface px-11 py-9 shadow-overlay",o),...u,children:[t!=null&&e.jsx("span",{className:i("flex size-disc items-center justify-center rounded-full text-2xl",Tr[s]),children:t}),e.jsx("div",{className:"text-lg font-semibold text-text",children:r}),n&&e.jsx("div",{className:"max-w-sm text-sm leading-relaxed text-text-muted",children:n}),a&&e.jsx("div",{className:"flex gap-2 pt-1.5",children:a})]})}function Ar({children:t,className:s,...r}){return e.jsx("kbd",{className:i("inline-flex items-center rounded border border-border px-1.5 py-px text-xs font-medium leading-none text-text-muted",s),...r,children:t})}const zr={sm:"h-1",md:"h-1.5"},Dr={accent:"bg-accent",success:"bg-success"};function _r({value:t,variant:s="accent",size:r="md",className:n,...a}){const l=Math.max(0,Math.min(100,t));return e.jsx("div",{role:"progressbar","aria-valuenow":Math.round(l),"aria-valuemin":0,"aria-valuemax":100,className:i("w-full overflow-hidden rounded-full bg-surface-hover",zr[r],n),...a,children:e.jsx("div",{className:i("h-full rounded-full transition-[width] duration-300 ease-out",Dr[s]),style:{width:`${l}%`}})})}const Rr={xs:"h-3 w-3",sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8",xl:"h-12 w-12"},$r={primary:"text-accent",secondary:"text-text-muted",white:"text-white",current:"text-current"},Lr={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function Ir({size:t="md",variant:s="primary",label:r="Loading...",showLabel:n=!1,className:a,...l}){return e.jsxs("div",{className:i("inline-flex items-center",n?"flex-col space-y-2":"",a),...l,children:[e.jsxs("svg",{className:i("animate-spin",Rr[t],$r[s]),fill:"none",viewBox:"0 0 24 24","aria-hidden":!n,role:n?"status":void 0,children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),n&&e.jsx("span",{className:i("text-text-muted",Lr[t]),children:r}),!n&&e.jsx("span",{className:"sr-only",children:r})]})}const Pr={neutral:"bg-text-disabled",accent:"bg-accent",success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",note:"bg-note","cat-1":"bg-cat-1","cat-2":"bg-cat-2","cat-3":"bg-cat-3","cat-4":"bg-cat-4","cat-5":"bg-cat-5"};function Or({tone:t="neutral",shape:s="round",pulse:r=!1,label:n,className:a}){return e.jsx("span",{role:n?"img":void 0,"aria-label":n,"aria-hidden":n?void 0:!0,className:i("inline-block size-dot shrink-0",s==="round"?"rounded-full":"rounded-sm",Pr[t],r&&"animate-pulse",a)})}function Fr({steps:t,current:s,variant:r="numbered",label:n,className:a}){const l=t.indexOf(s),o={role:n?"group":void 0,"aria-label":n,"aria-hidden":n?void 0:!0};return r==="dots"?e.jsx("div",{...o,className:i("flex items-center gap-1.5",a),children:t.map((u,c)=>e.jsx("span",{className:i("h-step-bar rounded-full transition-all duration-fast ease-out",c===l?"w-5 bg-accent":"w-3.5",c<l&&"bg-border-strong",c>l&&"bg-border")},u))}):e.jsx("div",{...o,className:i("flex items-center gap-2",a),children:t.map((u,c)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-current":c===l?"step":void 0,className:i("flex size-tile-sm items-center justify-center rounded-full text-xs font-medium",c===l&&"bg-accent text-accent-fg",c<l&&"bg-accent-soft text-accent",c>l&&"bg-surface-hover text-text-muted"),children:c+1}),c<t.length-1&&e.jsx("span",{className:"h-px w-8 bg-border-strong"})]},u))})}const Br=new Set(["name","given-name","family-name","additional-name","nickname","honorific-prefix","honorific-suffix","email","username","organization","organization-title","tel","tel-country-code","tel-national","tel-extension","url","photo","language","bday","sex","street-address","address-line1","address-line2","address-line3","address-level1","address-level2","country","country-name","postal-code","current-password","new-password","one-time-code"]);function Re(t){return t&&Br.has(t)?{autoComplete:t}:{autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other"}}const ye=t=>t==null?"":String(t),ot=t=>ye(t).trim().toLowerCase(),Hr={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm",lg:"h-control-lg px-3 text-base",full:"h-control-md w-full px-3 text-sm"},ke=ot,Ne=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,disabled:l=!1,options:o,placeholder:u,containerClassName:c,labelClassName:p,className:x,id:f,searchable:g,multiple:b,value:N,onChange:v,allowCreate:m,onCreateOption:k,...w},I)=>{const z=f||`select-${Math.random().toString(36).substr(2,9)}`,X=!!r,[B,D]=d.useState(!1),[$,L]=d.useState(""),H=d.useRef(null),V=d.useRef(null),ee=ve(B,V,{matchWidth:!0}),[W,j]=d.useState(o);d.useImperativeHandle(I,()=>H.current),d.useEffect(()=>{const P=C=>{H.current&&!H.current.contains(C.target)&&D(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);const h=d.useCallback((P,C)=>P.some(T=>ke(T.value)===ke(C)||ke(T.label)===ke(C)),[]),S=d.useCallback((P,C)=>{const T=[...P],Y=q=>{const y=ye(q).trim();y&&(h(T,y)||T.push({value:y,label:y}))};return Array.isArray(C)?C.forEach(Y):Y(C),T},[h]);d.useEffect(()=>{j(P=>{const C=[...o];return P.forEach(T=>{!h(C,T.value)&&!h(C,T.label)&&C.push(T)}),S(C,N)})},[o,N,S,h]);const _=d.useMemo(()=>Array.isArray(N)?N.map(ye):N==null?void 0:ye(N),[N]),E=P=>{if(b){const C=Array.isArray(_)?_:[],T=C.includes(P)?C.filter(Y=>Y!==P):[...C,P];v?.(T)}else v?.(P),D(!1),L("")},R=b?null:W.find(P=>P.value===_),M=b?W.filter(P=>Array.isArray(_)&&_.includes(P.value)):[],ae=g&&$?W.filter(P=>P.label.toLowerCase().includes($.toLowerCase())):W,le=!!m&&!!g&&!!$.trim()&&!h(W,$),G=P=>{const C=P.trim();if(!C)return;const T=k?.(C)??{value:C,label:C};if(h(W,T.value)||h(W,T.label)){E(T.value),L(""),b||D(!1);return}j(Y=>[...Y,T]),E(T.value),L(""),b||D(!1)},K=()=>b?M.length>0?M.map(P=>P.label).join(", "):u||"Select options":R?.label||u||"Select an option";return e.jsxs("div",{ref:H,className:i("relative flex flex-col",a&&"w-full",c),...w,children:[t&&e.jsx("label",{htmlFor:z,onClick:()=>D(!B),className:i("block text-xs font-semibold uppercase tracking-label mb-1.5",X?"text-danger-fg":"text-text-muted",p),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:V,type:"button",id:z,disabled:l,onClick:()=>D(!B),className:i("flex w-full items-center justify-between gap-2 rounded-tile border transition-colors duration-fast text-left","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled","bg-surface",Hr[n],X?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border-strong text-text",x),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:K()}),e.jsx(F.ChevronDownIcon,{size:16,className:i("shrink-0 opacity-60 transition-transform duration-fast",B&&"rotate-180")})]}),B&&e.jsxs("div",{style:ee,className:"fixed z-overlay flex flex-col overflow-hidden rounded-lg border border-border bg-surface shadow-overlay",children:[g&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:$,onChange:P=>L(P.target.value),onKeyDown:P=>{P.key==="Enter"&&le&&(P.preventDefault(),G($))},className:i("w-full px-3 py-2 text-sm rounded-md border","text-text border-border focus-visible:outline-none focus-visible:focus-ring")})}),le&&e.jsxs("div",{className:i("cursor-pointer px-3 py-1.5 text-sm","text-info-fg hover:bg-surface-hover"),onClick:()=>G($),children:["+: “",$.trim(),"”"]}),e.jsxs("ul",{className:"min-h-0 flex-1 overflow-auto py-1",children:[u&&!b&&e.jsx("li",{className:"cursor-pointer px-3 py-1.5 text-sm text-text-muted hover:bg-surface-hover",onClick:()=>{v?.(""),D(!1)},children:u}),ae.map(P=>{const C=b?Array.isArray(_)&&_.includes(P.value):_===P.value;return e.jsx("li",{onClick:()=>!P.disabled&&E(P.value),className:i("cursor-pointer px-3 py-1.5 text-sm","text-text",P.disabled?"opacity-50 cursor-not-allowed":"hover:bg-surface-hover",C&&"bg-accent-soft text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[b&&e.jsx("input",{type:"checkbox",checked:C,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-border [&:not(:checked)]:bg-surface-input text-accent "}),e.jsx("span",{children:P.label})]})},P.value)})]})]})]}),(r||s)&&e.jsx("p",{className:i("mt-1 text-xs",X?"text-danger-fg":"text-text-muted"),children:r||s})]})});Ne.displayName="Select";const qr={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-base",lg:"h-control-lg px-3 text-base",full:"h-control-md px-3 text-base"},ct="mb-1.5 block text-sm font-medium",it="block w-full rounded-tile border bg-surface-input text-text transition-colors duration-fast ease-out placeholder:text-text-subtle focus-visible:outline-none focus-visible:focus-ring disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",dt=t=>t?"border-danger-border bg-danger-soft":"border-border-strong",pe=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l,endIcon:o,loading:u=!1,containerClassName:c,labelClassName:p,className:x,id:f,...g},b)=>{const N=d.useId(),v=f||`textfield-${N}`,m=!!r,k=r||s?`${v}-description`:void 0;return e.jsxs("div",{className:i("flex flex-col",a&&"w-full",c),children:[t&&e.jsx("label",{htmlFor:v,className:i(ct,m?"text-danger-fg":"text-text-muted",p),children:t}),e.jsxs("div",{className:"relative",children:[l&&e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 text-text-muted",children:l}),e.jsx("input",{ref:b,id:v,"aria-invalid":m||void 0,"aria-describedby":k,className:i(it,qr[n],l&&"pl-9",(o||u)&&"pr-9",dt(m),x),...g}),(o||u)&&e.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted",children:u?e.jsx("span",{"aria-hidden":!0,className:"size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"}):o})]}),(r||s)&&e.jsx("p",{id:k,className:i("mt-1 text-xs",m?"text-danger-fg":"text-text-subtle"),children:r||s})]})});pe.displayName="TextField";function ut({value:t,onChange:s,onListFolders:r,disabled:n,size:a="md",placeholder:l,templatePlaceholder:o,showTemplate:u=!0}){const[c,p]=d.useState([]);d.useEffect(()=>{let f=!0;return Promise.resolve(r?.()).then(g=>{f&&g&&p(g.data??[])}).catch(()=>{}),()=>{f=!1}},[r]);const x=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ne,{size:a,fullWidth:!0,value:x.folderId??"",options:c.map(f=>({value:f.id,label:f.name})),placeholder:l??"Select a folder",onChange:f=>s?.({...x,folderId:f})}),u&&e.jsx(pe,{size:a,disabled:n??!1,value:x.pathTemplate??"",placeholder:o??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:f=>s?.({...x,pathTemplate:f.target.value})})]})}const Vr=d.createContext(null),Ur=({items:t,activeTab:s,onTabChange:r,className:n})=>{const[a,l]=d.useState(t[0]?.id||""),o=s||a,u=c=>{r?r(c):l(c)};return e.jsx("div",{className:i("border-b border-border",n),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(c=>e.jsx("button",{onClick:()=>!c.disabled&&u(c.id),disabled:c.disabled,className:i("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-fast",{"border-accent-border text-text":o===c.id,"border-transparent text-text-muted hover:text-text":o!==c.id&&!c.disabled,"border-transparent text-text-disabled cursor-not-allowed":c.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[c.label,c.badge&&e.jsx("span",{className:i("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",o===c.id?"bg-accent-soft text-accent":"bg-surface-hover text-text-muted"),children:c.badge})]})},c.id))})})},xt=({items:t,defaultTab:s,activeTab:r,onTabChange:n,variant:a="default",size:l="md",className:o})=>{const[u,c]=d.useState(s||r||t[0]?.id||""),p=r||u,x=v=>{n?n(v):c(v)},f={activeTab:p,setActiveTab:x},g=t.find(v=>v.id===p),b=i("flex",{"border-b border-border px-2":a==="default"||a==="underline","bg-surface-hover p-1 rounded-lg":a==="pills","space-x-1":a==="pills","space-x-8":a==="default"||a==="underline"},o),N=(v,m)=>{const k="transition-colors duration-fast font-medium",w={"text-xs px-2 py-1":l==="sm","text-sm px-3 py-2":l==="md","text-base px-4 py-3":l==="lg"},I={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},z={"opacity-50 cursor-not-allowed":v.disabled,"cursor-pointer":!v.disabled},X=m?{"border-accent-border text-text":a==="default"||a==="underline","bg-surface text-text shadow-none":a==="pills"}:{},B=!m&&!v.disabled?{"border-transparent text-text-muted hover:text-text":a==="default","text-text-muted hover:text-text":a==="pills","border-transparent text-text-muted hover:text-text hover:border-border":a==="underline"}:{};return i(k,w,I,z,X,B)};return e.jsx(Vr.Provider,{value:f,children:e.jsxs("div",{children:[e.jsx("div",{className:b,role:"tablist",children:t.map(v=>e.jsx("button",{type:"button",role:"tab","aria-selected":p===v.id,"aria-controls":`tabpanel-${v.id}`,disabled:v.disabled,onClick:()=>!v.disabled&&x(v.id),className:N(v,p===v.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[v.label,v.badge&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-surface-hover text-text-muted",children:v.badge})]})},v.id))}),g?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${p}`,"aria-labelledby":`tab-${p}`,className:"mt-4",children:g.content})]})})},Kr={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function qe({open:t,onClose:s,title:r,size:n="md",closeOnBackdropClick:a=!0,closeOnEscape:l=!0,className:o,backdropClassName:u,children:c,footer:p,showCloseButton:x=!0}){const f=d.useRef(null),g=d.useRef(null);d.useEffect(()=>{if(!t||!l)return;const N=v=>{v.key==="Escape"&&s()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[t,l,s]),d.useEffect(()=>(t?(g.current=document.activeElement,f.current&&f.current.focus(),document.body.style.overflow="hidden"):(g.current&&g.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const b=N=>{a&&N.target===N.currentTarget&&s()};return t?e.jsx("div",{className:i("fixed inset-0 z-modal flex items-center justify-center p-4","bg-scrim",u),onClick:b,children:e.jsxs("div",{ref:f,className:i("relative w-full bg-surface rounded-lg shadow-modal","focus:outline-none",Kr[n],o),role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,tabIndex:-1,children:[(r||x)&&e.jsxs("div",{className:"flex items-center justify-between p-6 pb-0",children:[r&&e.jsx("span",{id:"modal-title",className:"text-lg font-semibold text-text",children:r}),x&&e.jsx("button",{onClick:s,className:"p-1 text-text-muted hover:text-text transition-colors","aria-label":"Close modal",children:e.jsx(Z,{icon:F.X,size:"lg",color:"current"})})]}),e.jsx("div",{className:"p-6",children:c}),p&&e.jsx("div",{className:"px-6 py-4",children:p})]})}):null}const ft=({value:t,onChange:s,label:r,placeholder:n="Select or upload a file",error:a,disabled:l,accept:o,onListFiles:u,onListMounts:c,onUploadFile:p,onDownloadFile:x,onRegisterFile:f})=>{const[g,b]=d.useState(!1),[N,v]=d.useState([]),[m,k]=d.useState(null),[w,I]=d.useState("/"),[z,X]=d.useState([]),[B,D]=d.useState(!1),[$,L]=d.useState(""),[H,V]=d.useState(typeof t=="object"?t:null),[ee,W]=d.useState(!1),[j,h]=d.useState(""),S=d.useRef(null),_=d.useCallback(async()=>{D(!0);try{const y=await c?.();y?.data&&v(y.data)}catch(y){console.error("Failed to load mounts",y)}finally{D(!1)}},[c]),E=d.useCallback(async()=>{if(m){D(!0);try{const y=await u?.({mountId:m.id,name:$,path:w});y?.data&&X(y.data)}catch(y){console.error("Failed to load files",y)}finally{D(!1)}}},[w,u,$,m]);d.useEffect(()=>{g&&_()},[g,_]),d.useEffect(()=>{g&&m&&E()},[g,m,E]);const R=async y=>{const O=y.target.files?.[0];if(O){D(!0);try{const te=await O.arrayBuffer(),ne=new Uint8Array(te),xe={id:`local-${Date.now()}`,name:O.name,type:"file",path:"/",mimeType:O.type||"application/octet-stream",size:O.size,mountId:"local",providerKey:O.name,ownerId:"me"};V(xe),s(xe,ne),b(!1)}catch(te){console.error("Local file selection failed",te)}finally{D(!1)}}},M=async y=>{const O=y.target.files?.[0];if(!(!O||!m)){D(!0);try{const te=await O.arrayBuffer(),ne=await p?.({file:new Uint8Array(te),filename:O.name,mimeType:O.type||"application/octet-stream",mountId:m.id,path:w});if(ne?.data){const xe=ne.data;V(xe),s(xe,new Uint8Array(te)),b(!1)}}catch(te){console.error("Upload failed",te)}finally{D(!1)}}},ae=async()=>{if(!(!j||!m)){D(!0);try{const y=`${w}${j}/`;f&&(await f({name:j,type:"folder",path:w,mimeType:"application/x-directory",size:0,mountId:m.id,providerKey:y,ownerId:"me"}),await E()),W(!1),h("")}catch(y){console.error("Failed to create folder",y)}finally{D(!1)}}},le=async y=>{D(!0);try{const O=await x?.(y.id);V(y),s(y,O),b(!1)}catch(O){console.error("Failed to download file",O)}finally{D(!1)}},G=y=>{y.stopPropagation(),V(null),s(null)},K=d.useMemo(()=>{const y=new Set,O=[];return z.forEach(te=>{if(te.type==="folder"){te.path===w&&y.add(te.name);return}const ne=te.providerKey||te.name,me=(w?ne.substring(w.length):ne).split("/").filter(de=>de!=="");me.length>1?y.add(me[0]):me.length===1&&O.push(te)}),{folders:Array.from(y).sort(),files:O.sort((te,ne)=>te.name.localeCompare(ne.name))}},[z,w]),P=y=>{I(O=>`${O}${y}/`)},C=()=>{const y=w.split("/").filter(O=>O!=="");y.pop(),y.length===0?I("/"):I(`${y.join("/")}/`)},T=d.useMemo(()=>{const y=K.folders.map(O=>({id:`folder-${O}`,name:O,type:"folder"}));return K.files.forEach(O=>{y.push({...O,type:"file"})}),y},[K]),Y=[{id:"name",header:"Name",accessor:"name",cell:(y,O)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{icon:O.type==="folder"?F.Folder:F.FileText,size:"sm",color:O.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:i(O.type==="folder"&&"font-medium"),children:y})]})},{id:"type",header:"Type",accessor:y=>y.type==="folder"?"Folder":y.mimeType},{id:"size",header:"Size",accessor:y=>y.type==="file"?`${(y.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(y,O)=>e.jsx(re,{variant:"outline",onClick:te=>{te.stopPropagation(),O.type==="folder"?P(O.name):le(O)},loading:B&&O.type==="file"&&H?.id===O.id,children:O.type==="folder"?"Open":"Select"})}],q=[{id:"name",header:"Mount Name",accessor:"name",cell:y=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Z,{icon:F.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:y})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(y,O)=>e.jsx(re,{variant:"outline",onClick:()=>k(O),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx(ce,{variant:"label",size:"sm",weight:"medium",children:r}),e.jsxs("div",{onClick:()=>!l&&b(!0),className:i("flex items-center gap-3 px-3 py-2 border rounded-lg cursor-pointer transition-colors","hover:border-border-strong bg-surface",a?"border-danger-border":"border-border",l&&"opacity-50 cursor-not-allowed bg-surface-sunk"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Z,{icon:H?F.FileText:F.HardDrive,color:H?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:H?e.jsx("span",{className:"text-sm text-text font-medium",children:H.name}):e.jsx("span",{className:"text-sm text-text-muted",children:n})}),H&&!l&&e.jsx("button",{onClick:G,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(Z,{icon:F.X,size:"xs"})})]}),a&&e.jsx(ce,{variant:"body",size:"xs",className:"text-danger-fg",children:a}),e.jsx(qe,{open:g,onClose:()=>{b(!1),k(null),I("/"),W(!1)},title:m?`Explorer: ${m.name}`:"Select Storage Mount",size:"lg",children:e.jsx(xt,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(re,{variant:"ghost",onClick:()=>{w&&w!=="/"?C():k(null)},leftIcon:e.jsx(Z,{icon:F.ArrowLeft,size:"xs"}),children:w?"Back":"Back to Mounts"}),e.jsx("div",{className:"flex items-center gap-1 text-xs text-text-muted overflow-hidden bg-surface-hover px-2 py-1 rounded",children:e.jsx("span",{className:"truncate",children:w})}),e.jsx("div",{className:"flex-grow min-w-40",children:e.jsx(pe,{placeholder:"Search...",value:$,onChange:y=>L(y.target.value),startIcon:e.jsx(F.Search,{size:14}),fullWidth:!0})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(re,{variant:"outline",onClick:()=>W(!0),leftIcon:e.jsx(Z,{icon:F.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(re,{variant:"primary",onClick:()=>S.current?.click(),leftIcon:e.jsx(Z,{icon:F.Upload,size:"xs"}),loading:B,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:S,onChange:M,accept:o})]})]}),ee&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-surface-sunk rounded-lg border border-border",children:[e.jsx(Z,{icon:F.Folder,size:"sm",color:"warning"}),e.jsx(pe,{placeholder:"Folder name",value:j,onChange:y=>h(y.target.value),autoFocus:!0}),e.jsx(re,{onClick:ae,loading:B,children:"Create"}),e.jsx(re,{variant:"ghost",onClick:()=>W(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(_e,{data:T,columns:Y,loading:B,emptyContent:"This folder is empty",onRowClick:y=>y.type==="folder"?P(y.name):le(y)})})]}):e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(_e,{data:N,columns:q,loading:B,emptyContent:"No storage mounts configured",onRowClick:y=>k(y)})})})},{id:"local",label:"Local File",content:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 border-2 border-dashed border-border rounded-xl bg-surface-sunk/50",children:[e.jsx("div",{className:"p-4 bg-accent-soft rounded-full mb-4",children:e.jsx(Z,{icon:F.FileText,size:"xl",color:"primary"})}),e.jsx(ce,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(ce,{variant:"body",size:"sm",className:"text-text-muted mt-1 mb-6 text-center max-w-xs",children:["This file will be used directly in the form and will ",e.jsx("strong",{children:"not"})," be uploaded to platform storage."]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(re,{variant:"primary",size:"lg",loading:B,className:"pointer-events-none",children:"Browse Local File"}),e.jsx("input",{type:"file",className:"hidden",onChange:R,accept:o,disabled:B})]})]})})}]})})]})},Wr={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-base",lg:"px-3 py-2 text-md",full:"px-3 py-2 text-md"},Te=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,loading:l=!1,containerClassName:o,labelClassName:u,className:c,id:p,rows:x=4,...f},g)=>{const b=d.useId(),N=p||`textarea-${b}`,v=!!r,m=r||s?`${N}-description`:void 0;return e.jsxs("div",{className:i("flex flex-col",a&&"w-full",o),children:[t&&e.jsx("label",{htmlFor:N,className:i(ct,v?"text-danger-fg":"text-text-muted",u),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:g,id:N,rows:x,"aria-invalid":v||void 0,"aria-describedby":m,className:i(it,"resize-y leading-relaxed",Wr[n],dt(v),c),...f}),l&&e.jsx("span",{"aria-hidden":!0,className:"absolute top-2 right-3 size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"})]}),(r||s)&&e.jsx("p",{id:m,className:i("mt-1 text-xs",v?"text-danger-fg":"text-text-subtle"),children:r||s})]})});Te.displayName="TextArea";function Ge(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}function Gr(t,s,r){const n=s.split("."),a=Array.isArray(t)?[...t]:{...t};let l=a;for(let o=0;o<n.length-1;o++){const u=n[o],c=l[u];l[u]=c&&typeof c=="object"?Array.isArray(c)?[...c]:{...c}:{},l=l[u]}return l[n[n.length-1]]=r,a}function Jr(t,s){const r=s.split("."),n=Array.isArray(t)?[...t]:{...t};let a=n;for(let l=0;l<r.length-1;l++){const o=r[l];if(!a[o]||typeof a[o]!="object")return n;a[o]=Array.isArray(a[o])?[...a[o]]:{...a[o]},a=a[o]}return delete a[r[r.length-1]],n}function mt({title:t,description:s,className:r,children:n}){return!t&&!s?e.jsx("div",{children:n}):e.jsxs("div",{className:i("flex flex-col gap-4 py-6 sm:flex-row sm:gap-8",r),children:[e.jsxs("div",{className:"w-full shrink-0 sm:w-form-label",children:[t&&e.jsx("span",{className:"text-base font-semibold text-text",children:t}),s&&e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-pretty text-text-subtle",children:s})]}),e.jsx("div",{className:"min-w-0 flex-1",children:n})]})}const Xr=({groups:t,data:s,onSubmit:r,onCancel:n,onChange:a,transform:l,validate:o,submitButton:u={label:"Submit",variant:"primary"},cancelButton:c={label:"Cancel",variant:"outline"},showButtons:p=!0,layout:x="vertical",size:f="md",loading:g=!1,className:b,ref:N,sdk:v})=>{const[m,k]=d.useState(s||{}),w=d.useId(),I=d.useCallback(h=>`${w}-${String(h).replace(/\./g,"-")}`,[w]),[z,X]=d.useState({}),[B,D]=d.useState({});d.useEffect(()=>{s&&k({...s})},[s]);const $=d.useCallback((h,S,_)=>{const E=t.flatMap(R=>R.items).find(R=>R.name===h);if(!E)return null;if(E.required&&(S==null||S===""))return`${E.label} is required`;if(E.type==="array"){if(E.required&&(!S||S.length===0))return`${E.label} cannot be empty.`;if(S&&!Array.isArray(S))return`${E.label} must be an array.`;if(Array.isArray(S)&&E.arrayFields){const R=[];let M=!1;if(S.forEach((ae,le)=>{const G={};for(const K of E.arrayFields){const P=ae?.[K.name];if(K.required&&(P==null||P===""))G[K.name]=`${K.label} is required`,M=!0;else if(K.validator){const C=K.validator(P,ae);C&&(G[K.name]=C,M=!0)}}R[le]=G}),M)return JSON.stringify(R)}}return E.validator?E.validator(S,_):null},[t]),L=d.useCallback((h,S)=>{let _=Gr(m,h,S);t.flatMap(M=>M.items).find(M=>M.name===h)?.removeIfEmpty&&(S==null||S==="")&&(_=Jr(_,h)),k(_),D(M=>({...M,[h]:!0}));const R=$(h,S,_);X(M=>({...M,[h]:R||""})),a?.(_,h)},[m,t,$,a]),H=d.useCallback(async h=>{if(h.preventDefault(),g)return;const S={},_=t.flatMap(R=>R.items);for(const R of _){if(R.hidden||R.conditional&&!R.conditional(m))continue;const M=$(R.name,Ge(m,R.name),m);M&&(S[R.name]=M)}if(o){const R=o(m);R&&Object.assign(S,R)}if(X(S),Object.keys(S).some(R=>S[R]))return;const E=l?l(m):m;await r?.(m,E)},[m,t,$,o,l,r,g]),V=d.useCallback(h=>{const S=Ge(m,h.name),_=B[h.name]?z[h.name]:void 0,E=h.disabled||g,R={id:I(h.name),value:S||"",disabled:E,required:h.required,placeholder:h.placeholder,...h.fieldProps};switch(h.type){case"text":case"email":case"password":case"number":case"tel":case"url":case"color":return e.jsx(pe,{...R,onChange:M=>L(h.name,M.target.value),type:h.textType||h.type,...Re(h.autocomplete),error:_,size:f});case"textarea":return e.jsx(Te,{...R,onChange:M=>L(h.name,M.target.value),rows:h.rows??4,error:_,size:f});case"select":return e.jsx(Ne,{...R,onChange:M=>L(h.name,M),options:(h.options||[]).map(M=>({...M,value:String(M.value)})),searchable:h.searchable,multiple:h.multiple,allowCreate:h.allowCreate,error:_,size:f});case"segmented":return e.jsx(Ze,{"aria-label":h.label,value:S==null?"":String(S),onChange:M=>L(h.name,M),options:(h.options||[]).map(M=>({value:String(M.value),label:M.label})),size:f==="sm"?"sm":"md",className:h.disabled?"pointer-events-none opacity-50":void 0});case"checkbox":return e.jsx(he,{...R,label:h.label,checked:!!S,onChange:M=>L(h.name,M.target.checked),size:f});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:h.options?.map(M=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 text-base text-text",children:[e.jsx("input",{type:"radio",name:h.name,value:M.value,checked:S===M.value,onChange:()=>L(h.name,M.value),disabled:E||M.disabled,className:"size-checkbox shrink-0 rounded-xs border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),M.label]},M.value))});case"date":return e.jsx(Ee,{...R,value:S?new Date(S):null,onChange:M=>L(h.name,M),size:f});case"file":return e.jsx(ft,{...R,value:S,onChange:M=>L(h.name,M),error:_,onListFiles:M=>v?.http.invoke({method:"POST",action:"storage.file.list",body:M}),onListMounts:()=>v?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:M=>v?.http.invoke({method:"POST",action:"storage.file.upload",body:M}),onDownloadFile:M=>v?.http.invoke({method:"GET",action:`storage.file.${M}.download`}),onRegisterFile:M=>v?.http.invoke({method:"POST",action:"storage.file.folder",body:M})});case"folder":return e.jsx(ut,{value:S||{},onChange:M=>L(h.name,M),onListFolders:()=>v?.http.invoke({method:"GET",action:"storage.mount"}),disabled:E,size:f,placeholder:h.placeholder});case"custom":return h.customComponent?.({value:S,onChange:M=>L(h.name,M),error:_,disabled:E});case"array":{const M=S||[];let ae=[];if(typeof _=="string"&&_.startsWith("["))try{ae=JSON.parse(_)}catch{}const le=()=>{L(h.name,[...M,{}])},G=P=>{L(h.name,M.filter((C,T)=>T!==P))},K=(P,C,T)=>{const Y=[...M];Y[P]={...Y[P],[C]:T},L(h.name,Y)};return e.jsxs("div",{className:"flex flex-col gap-2",children:[M.map((P,C)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"grid flex-1 gap-2 sm:grid-cols-2",children:h.arrayFields?.map(T=>{const Y=ae?.[C]?.[T.name];return e.jsxs("div",{className:"flex flex-col gap-1",children:[C===0&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[T.label,T.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),(()=>{const q={value:P?.[T.name]||"",disabled:E,required:T.required,placeholder:T.placeholder,...T.fieldProps};switch(T.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(pe,{...q,onChange:y=>K(C,T.name,y.target.value),type:T.textType||T.type,...Re(T.autocomplete),error:Y,size:f});case"textarea":return e.jsx(Te,{...q,onChange:y=>K(C,T.name,y.target.value),rows:T.rows??4,error:Y,size:f});case"select":return e.jsx(Ne,{...q,onChange:y=>K(C,T.name,y),options:(T.options||[]).map(y=>({...y,value:String(y.value)})),searchable:T.searchable,multiple:T.multiple,allowCreate:T.allowCreate,error:Y,size:f});case"checkbox":return e.jsx(he,{...q,checked:!!P?.[T.name],onChange:y=>K(C,T.name,y.target.checked),size:f});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:T.options?.map(y=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:`${h.name}.${C}.${T.name}`,value:y.value,checked:P?.[T.name]===y.value,onChange:()=>K(C,T.name,y.value),disabled:E||y.disabled,className:"size-checkbox shrink-0 rounded-xs border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),y.label]},y.value))});case"date":{const y=P?.[T.name];return e.jsx(Ee,{...q,value:y?new Date(y):null,onChange:O=>K(C,T.name,O),size:f})}case"custom":return T.customComponent?.({value:P?.[T.name],onChange:y=>K(C,T.name,y),error:Y,disabled:E});default:return e.jsxs("p",{children:["Unsupported field type in array: ",T.type]})}})(),Y&&e.jsx("p",{className:"text-xs text-danger-fg",children:Y})]},T.name)})}),e.jsx(re,{type:"button",iconOnly:!0,variant:"ghost",size:"md","aria-label":`${h.label} verwijderen`,onClick:()=>G(C),disabled:E,className:i("shrink-0",C===0&&"mt-5"),children:e.jsx(F.Trash2,{className:"size-icon-md"})})]},C)),e.jsxs(re,{type:"button",variant:"secondary",leftIcon:e.jsx(F.Plus,{className:"size-icon-sm"}),onClick:le,disabled:E,children:[h.label," toevoegen"]})]})}default:return null}},[m,B,z,g,f,L,I,v?.http.invoke]),ee=d.useCallback(h=>{if(h.conditional&&!h.conditional(m))return null;const S=h.items.filter(E=>!(E.hidden||E.conditional&&!E.conditional(m)));if(S.length===0)return null;const _=i(h.layout==="flex"?"flex flex-wrap gap-3.5":"grid gap-3.5",h.layout!=="flex"&&{"grid-cols-1":!h.columns||h.columns===1,"grid-cols-2":h.columns===2,"grid-cols-3":h.columns===3,"grid-cols-4":h.columns===4},h.className);return e.jsx(mt,{title:h.title,description:h.description,className:"not-last:border-b not-last:border-border-subtle",children:e.jsx("div",{children:e.jsx("div",{className:_,children:S.map(E=>{const R=B[E.name]?z[E.name]:void 0;return e.jsxs("div",{className:i("flex min-w-0 flex-col gap-1.5",E.type==="checkbox"&&"justify-center"),style:{width:typeof E.width=="string"?E.width:void 0,gridColumn:typeof E.width=="number"?`span ${E.width} / span ${E.width}`:void 0},children:[E.type!=="custom"&&E.type!=="checkbox"&&e.jsxs("label",{htmlFor:I(E.name),className:"block text-sm font-medium text-text-muted",children:[E.label,E.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),V(E),E.help&&!R&&e.jsx("p",{className:"text-xs leading-4 text-text-subtle",children:E.help})]},E.name)})})})},h.id)},[m,B,z,V,I]),W=i({"max-w-settings":f==="sm","max-w-form":f==="md","max-w-6xl":f==="lg","max-w-full":f==="full"},b),j=f==="full"?"md":f;return e.jsxs("form",{ref:N,onSubmit:H,className:W,children:[!p&&e.jsx("button",{type:"submit",className:"hidden",tabIndex:-1,"aria-hidden":!0}),e.jsx("div",{className:"flex flex-col",children:t.map(ee)}),p&&e.jsxs("div",{className:"flex items-center gap-2 border-t border-border-subtle py-4",children:[e.jsx("div",{className:"ml-auto"}),n&&e.jsx(re,{type:"button",variant:c.variant??"ghost",size:c.size||j,disabled:c.disabled||g,onClick:n,className:c.className,children:c.label}),e.jsx(re,{type:"submit",variant:u.variant,size:u.size||j,disabled:u.disabled||g,loading:g,className:u.className,children:u.label})]})]})};function Yr({label:t,value:s,onChange:r,maxDimension:n=256,maxBytes:a,aspect:l="square",helperText:o,disabled:u,className:c,chooseLabel:p="Choose",removeLabel:x="Remove",tooLargeLabel:f="That image is too large."}){const g=d.useRef(null),[b,N]=d.useState(null),v=async m=>{if(!m)return;N(null);const k=await Qr(m,n);if(a&&Zr(k)>a){N(f);return}r(k)};return e.jsxs("div",{className:i("flex flex-col gap-1.5",c),children:[t&&e.jsx("span",{className:"text-sm font-medium text-text",children:t}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:i("flex items-center justify-center overflow-hidden rounded-md border border-border bg-surface-sunk",l==="square"?"h-16 w-16":"h-16 w-28"),children:s?e.jsx("img",{src:s,alt:"",className:"h-full w-full object-contain"}):e.jsx(ce,{variant:"caption",color:"muted",children:"—"})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(re,{type:"button",variant:"secondary",disabled:u,onClick:()=>g.current?.click(),children:p}),s&&e.jsx(re,{type:"button",variant:"ghost",disabled:u,onClick:()=>{N(null),r(void 0)},children:x})]}),(b||o)&&e.jsx(ce,{variant:"caption",color:b?"error":"muted",children:b??o})]})]}),e.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:m=>void v(m.target.files?.[0])})]})}function Zr(t){const s=t.slice(t.indexOf(",")+1),r=s.endsWith("==")?2:s.endsWith("=")?1:0;return Math.floor(s.length*3/4)-r}function Qr(t,s){return new Promise((r,n)=>{const a=new FileReader;a.onload=()=>{const l=new Image;l.onload=()=>{const o=Math.min(1,s/Math.max(l.width,l.height)),u=Math.round(l.width*o),c=Math.round(l.height*o),p=document.createElement("canvas");p.width=u,p.height=c;const x=p.getContext("2d");if(!x){r(a.result);return}x.drawImage(l,0,0,u,c),r(p.toDataURL("image/png"))},l.onerror=n,l.src=a.result},a.onerror=n,a.readAsDataURL(t)})}function en(t){const s=[];return t.querySelectorAll(`[${Ce}]`).forEach(r=>{const n=r.getAttribute(Ce);n&&s.push(n)}),{text:t.innerText??"",mentions:s,html:ht(t.innerHTML)}}function tn(t){return $e.sanitize(t.replace(/\n/g,"<br>"))}function ht(t){return $e.sanitize(t,{ADD_ATTR:[Ce,"contenteditable"]})}const gt=d.forwardRef(({initialContent:t,onChange:s,people:r,placeholder:n,onSubmit:a,autoFocus:l,className:o},u)=>{const c=d.useRef(null),[p,x]=d.useState(null),[f,g]=d.useState(null),[b,N]=d.useState(0),v=d.useMemo(()=>({current:f}),[f]),m=d.useMemo(()=>{if(p===null)return[];const D=p.toLowerCase();return r.filter($=>$.name.toLowerCase().includes(D)).slice(0,8)},[r,p]),k=ve(m.length>0,v,{gap:4}),w=d.useCallback(()=>{if(!c.current)return;const{text:D,mentions:$,html:L}=en(c.current);s(D,$,L)},[s]),I=d.useCallback(()=>{x(null),g(null),N(0)},[]);d.useImperativeHandle(u,()=>({insertText:D=>{const $=c.current;if(!$)return;const L=window.getSelection();if(L&&L.rangeCount>0&&$.contains(L.anchorNode)){const H=L.getRangeAt(0);H.deleteContents();const V=document.createDocumentFragment(),ee=D.split(`
3
- `);ee.forEach((W,j)=>{V.appendChild(document.createTextNode(W)),j<ee.length-1&&V.appendChild(document.createElement("br"))}),H.insertNode(V),H.collapse(!1),L.removeAllRanges(),L.addRange(H)}else $.innerHTML+=tn(D);w()},clear:()=>{c.current&&(c.current.innerHTML="",I(),w())},focus:()=>c.current?.focus()})),d.useEffect(()=>{!c.current||!t||(c.current.innerHTML=ht(t),w())},[t,w]),d.useEffect(()=>{l&&(window.matchMedia?.("(max-width: 767px)").matches||c.current?.focus())},[l]);const z=d.useCallback(D=>{if(["Escape","Enter","ArrowUp","ArrowDown","Tab"].includes(D.key))return;const $=window.getSelection();if(!$||$.rangeCount===0)return;const L=$.getRangeAt(0);if(!L.collapsed||L.startContainer.nodeType!==Node.TEXT_NODE)return;const H=L.startContainer,V=(H.textContent??"").slice(0,L.startOffset),ee=V.lastIndexOf("@");if(ee===-1||V.slice(ee+1).includes(" ")){x(null),g(null);return}const W=document.createRange();W.setStart(H,ee),W.setEnd(H,L.startOffset),x(V.slice(ee+1)),g(W),N(0)},[]),X=d.useCallback(D=>{if(!c.current||!f)return;const $=window.getSelection();if(!$)return;f.deleteContents();const L=document.createElement("span");L.textContent=`@${D.name}`,L.setAttribute("data-mention-id",D.id),L.setAttribute("contenteditable","false");const H=document.createTextNode(" ");f.insertNode(H),f.insertNode(L);const V=document.createRange();V.setStartAfter(H),V.collapse(!0),$.removeAllRanges(),$.addRange(V),I(),w()},[f,w,I]),B=d.useCallback(D=>{if(!c.current)return;if(m.length>0){if(D.key==="ArrowDown"){D.preventDefault(),N(j=>(j+1)%m.length);return}if(D.key==="ArrowUp"){D.preventDefault(),N(j=>(j-1+m.length)%m.length);return}if(D.key==="Enter"||D.key==="Tab"){D.preventDefault(),X(m[b]);return}if(D.key==="Escape"){D.preventDefault(),I();return}}if(a&&D.key==="Enter"&&(D.metaKey||D.ctrlKey)){D.preventDefault(),a();return}const $=window.getSelection();if(!$||$.rangeCount===0)return;const L=$.getRangeAt(0);if(!L.collapsed)return;const H=L.startContainer,V=L.startOffset,ee=j=>H.nodeType===Node.TEXT_NODE?j==="prev"?H.previousSibling:H.nextSibling:H.childNodes[j==="prev"?V-1:V],W=D.key==="Backspace"?ee("prev"):D.key==="Delete"?ee("next"):null;W instanceof HTMLElement&&W.hasAttribute("data-mention-id")&&(D.preventDefault(),W.remove(),w())},[m,b,X,I,w,a]);return e.jsxs("div",{className:"relative w-full",children:[e.jsx("div",{ref:c,contentEditable:!0,role:"textbox",tabIndex:0,"aria-multiline":"true","aria-label":n,className:i("block w-full min-h-16 rounded-lg p-3 text-sm","border-border text-text focus:outline-none",Pe,"empty:before:content-[attr(data-placeholder)] empty:before:text-text-subtle",o),"data-placeholder":n,onInput:w,onKeyUp:z,onKeyDown:B,onBlur:I}),m.length>0&&e.jsx("ul",{style:k,className:"z-50 w-64 overflow-y-auto overscroll-contain rounded-md border border-border bg-surface text-text shadow-lg",children:m.map((D,$)=>e.jsx("li",{children:e.jsx("button",{type:"button",onMouseDown:L=>{L.preventDefault(),X(D)},onMouseEnter:()=>N($),className:i("block w-full px-4 py-2 text-left text-sm",$===b&&"bg-beta-container"),children:D.name})},D.id))})]})});gt.displayName="MentionComposer";const ge=(...t)=>t.filter(Boolean).join(" "),sn=t=>e.jsx(F.Search,{...t,strokeWidth:1.5,"aria-hidden":!0}),rn=t=>e.jsx(F.ChevronDown,{...t,strokeWidth:1.5,"aria-hidden":!0}),nn={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-base",lg:"h-control-lg px-3 text-base",full:"h-control-md w-full px-3 text-base"},De={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},bt=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l=e.jsx(sn,{}),loading:o=!1,containerClassName:u,labelClassName:c,className:p,id:x,options:f,onRemoteSearch:g,onSelect:b,debounceTime:N=500,showAllOnOpen:v=!1,value:m,onChange:k,...w},I)=>{const z=x||`searchfield-${Math.random().toString(36).substr(2,9)}`,X=!!r,B=d.useRef(null),D=d.useRef(null),[$,L]=d.useState(m||""),[H,V]=d.useState(!1),[ee,W]=d.useState(!1),[j,h]=d.useState(!1);d.useEffect(()=>{m!==void 0&&L(m)},[m]);const S=d.useMemo(()=>{if(v&&!j||!$)return f;const G=String($).toLowerCase();return f.filter(K=>String(K.label).toLowerCase().includes(G))},[$,f,v,j]);d.useEffect(()=>{if(!g||!$){W(!1);return}const G=setTimeout(async()=>{W(!0);try{await g(String($))}catch(K){console.error("Remote search failed:",K)}finally{W(!1)}},N);return()=>{clearTimeout(G),W(!1)}},[$,N,g]),d.useEffect(()=>{const G=K=>{B.current&&!B.current.contains(K.target)&&V(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[]);const _=G=>{const K=G.target.value;L(K),V(!0),h(!0),k&&k(G)},E=G=>{L(G.label),V(!1),h(!1),b&&b(G.value)},R=()=>{(f.length>0||g)&&(V(!0),h(!1))},M=o||ee,ae=H&&(S.length>0||M),le=d.useMemo(()=>I||D,[I]);return e.jsxs("div",{className:ge("flex flex-col",a?"w-full":"",u||"","relative"),ref:B,children:[t&&e.jsx("label",{htmlFor:z,className:ge("block text-sm font-medium mb-1",X?"text-danger-fg":"text-text",c||""),children:t}),e.jsxs("div",{className:"relative",children:[l&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:ge("text-text-muted",De[n]),children:l})}),e.jsx("input",{ref:le,id:z,value:$,onChange:_,onFocus:R,className:ge("block w-full rounded-tile border bg-surface-input transition-colors duration-fast ease-out","placeholder:text-text-subtle focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",nn[n],l?"pl-10":"","pr-10",X?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border-strong text-text",p||""),...w}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:M||o?e.jsx(F.Loader2,{className:ge("animate-spin text-info-fg",De[n]),"aria-hidden":!0}):e.jsx(rn,{className:ge("text-text-muted cursor-pointer transition-transform",De[n],H?"rotate-180":"rotate-0"),onClick:()=>{V(G=>(G||h(!1),!G))}})})]}),ae&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-surface border border-border rounded-lg shadow-lg max-h-60 overflow-auto top-full",children:S.length>0?S.map(G=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>E(G),"aria-selected":$===G.label,children:G.label},G.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:M||o?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(r||s)&&e.jsx("p",{className:ge("mt-1 text-xs",X?"text-danger-fg":"text-text-muted"),children:r||s}),g&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String($)]})]})});bt.displayName="SearchableTextField";const pt=d.forwardRef(({checked:t,onChange:s,label:r,disabled:n=!1,className:a,...l},o)=>{const u=e.jsx("span",{"aria-hidden":!0,className:i("relative inline-flex size-switch-track shrink-0 items-center rounded-full","transition-colors duration-fast ease-out",t?"bg-accent":"bg-surface-hover",n&&"opacity-50"),children:e.jsx("span",{className:i("absolute left-0.5 size-switch-knob rounded-full bg-surface shadow-overlay","transition-transform duration-fast ease-out",t&&"translate-switch")})});return e.jsxs("label",{className:i("inline-flex items-center gap-2",n?"cursor-not-allowed":"cursor-pointer",a),children:[e.jsx("input",{ref:o,type:"checkbox",role:"switch",checked:t,disabled:n,onChange:c=>s(c.target.checked),className:"peer sr-only",...l}),e.jsx("span",{className:"inline-flex rounded-full peer-focus-visible:focus-ring",children:u}),r&&e.jsx("span",{className:"text-sm text-text",children:r})]})});pt.displayName="Switch";const an=[{upTo:1,cols:"grid-cols-1"},{upTo:2,cols:"grid-cols-1 @[22rem]:grid-cols-2"},{upTo:4,cols:"grid-cols-1 @[18rem]:grid-cols-2"},{upTo:9,cols:"grid-cols-2 @[26rem]:grid-cols-3"}],ln="grid-cols-2 @[26rem]:grid-cols-3 @[40rem]:grid-cols-4";function on(t){return an.find(s=>t<=s.upTo)?.cols??ln}function cn(t,s){const r=s??t;if(t<=r)return{shown:t,hidden:0};const n=Math.max(0,r-1);return{shown:n,hidden:t-n}}function dn({tiles:t,pinned:s,maxStrip:r,className:n}){if(s){const{shown:a,hidden:l}=cn(t.length,r),o=t.slice(0,a);return e.jsxs("div",{className:i("@container flex h-full min-h-0 flex-col gap-2",n),children:[e.jsx("div",{className:"min-h-0 flex-1",children:s}),t.length>0&&e.jsxs("div",{className:"flex h-[22%] min-h-14 shrink-0 gap-2 overflow-x-auto",children:[o.map((u,c)=>e.jsx("div",{className:"h-full min-w-0 shrink-0 aspect-video",children:u},c)),l>0&&e.jsxs("div",{className:"flex h-full aspect-video shrink-0 items-center justify-center rounded-lg bg-video-surface text-sm font-semibold tabular-nums text-white/80",children:["+",l]})]})]})}return e.jsx("div",{className:i("@container grid h-full min-h-0 auto-rows-fr gap-2",on(t.length),n),children:t.map((a,l)=>e.jsx("div",{className:"min-h-0 min-w-0",children:a},l))})}function un({name:t,avatarUrl:s,muted:r,speaking:n,hasVideo:a,videoSlot:l,className:o,fill:u}){return e.jsxs("div",{className:i("@container relative flex min-h-0 min-w-0 items-center justify-center overflow-hidden rounded-lg bg-video-surface",u?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",o),children:[a&&l?e.jsx("div",{className:"absolute inset-0",children:l}):e.jsx("div",{className:"flex min-h-0 min-w-0 items-center justify-center text-gray-300",children:s?e.jsx("img",{src:s,alt:t,className:"aspect-square w-[38%] max-w-16 min-w-6 rounded-full object-cover"}):e.jsx("div",{className:"flex aspect-square w-[38%] max-w-16 min-w-6 items-center justify-center rounded-full bg-video-surface-strong",children:a?e.jsx(F.VideoOff,{className:"w-1/2 h-1/2"}):e.jsx(F.User,{className:"w-1/2 h-1/2"})})}),e.jsxs("div",{className:"absolute inset-x-2 bottom-2 flex w-fit max-w-[calc(100%-1rem)] items-center gap-1.5 rounded bg-video-overlay px-1.5 py-1 text-xs text-white",children:[r?e.jsx(F.MicOff,{className:"size-3 shrink-0"}):e.jsx(F.Mic,{className:"size-3 shrink-0"}),e.jsx("span",{className:"hidden truncate @[9rem]:inline",children:t})]})]})}function xn({attach:t,active:s=!0,mirrored:r=!1,className:n}){const a=d.useRef(null);return d.useEffect(()=>{if(!s||!a.current)return;const l=t(a.current);return()=>{typeof l=="function"&&l(),a.current&&(a.current.innerHTML="")}},[t,s]),e.jsx("div",{ref:a,className:i("w-full h-full bg-video-surface-strong overflow-hidden",r&&"[&>*]:scale-x-[-1]",n)})}const fn=()=>e.jsx(Me,{variant:"inline",shape:"menu"}),vt=({item:t,isSelectedHandler:s,onClick:r,depth:n=0})=>{const a=!!(t.children&&t.children.length>0),l=s?s(t.path):!1;if(a)return e.jsxs("li",{children:[t.label&&e.jsxs("div",{className:i("flex items-center gap-2 px-2.5 pt-5 pb-2 text-2xs font-semibold uppercase tracking-label text-text-disabled"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:"font-normal tabular-nums",children:t.count})]}),e.jsx("ul",{className:"flex flex-col gap-px",children:t.children?.map((c,p)=>e.jsx(vt,{item:c,isSelectedHandler:s,onClick:r,depth:n+1},p))})]});const o=t.action,u=o?.visibility!=="always";return e.jsx("li",{children:e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>t.path&&r?.(t.path),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),t.path&&r?.(t.path))},className:i("group/item flex h-row-md cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-base no-underline","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",l?"bg-surface-hover font-medium text-text shadow-sm":"text-text-muted hover:bg-page-hover hover:text-text"),children:[t.icon&&e.jsx("span",{className:i("flex w-5 shrink-0 items-center justify-center",l?"text-text-muted":"text-text-subtle"),children:t.icon}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:i("shrink-0 text-xs tabular-nums",l?"rounded-full bg-accent px-1.5 font-semibold text-accent-fg":"text-text-subtle",o&&u&&"group-hover/item:hidden group-focus-within/item:hidden"),children:t.count}),t.count===void 0&&t.meta!==void 0&&e.jsx("span",{className:i("shrink-0 text-xs text-text-subtle",o&&u&&"group-hover/item:hidden group-focus-within/item:hidden"),children:t.meta}),o&&e.jsx("button",{type:"button","aria-label":o.label,title:o.label,onClick:c=>{c.stopPropagation(),o.onClick()},onKeyDown:c=>c.stopPropagation(),className:i("flex size-5 shrink-0 items-center justify-center rounded-sm","text-text-subtle transition-colors duration-fast ease-out","hover:bg-page-hover hover:text-text","focus-visible:outline-none focus-visible:focus-ring",u&&"opacity-0 group-hover/item:opacity-100 focus-visible:opacity-100"),children:o.icon})]})})},mn=({items:t,isSelectedHandler:s,onClick:r,preMenuItemsComponent:n,loading:a=!1})=>a?e.jsxs("nav",{className:"flex h-full min-h-0 shrink-0 flex-col",children:[n&&e.jsx("div",{className:"pb-4",children:n}),e.jsx(fn,{})]}):e.jsxs("nav",{className:"flex h-full min-h-0 shrink-0 flex-col",children:[n&&e.jsx("div",{className:"pb-4",children:n}),e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-px overflow-y-auto",children:t.map((l,o)=>!l.path&&!l.label&&!l.children?e.jsx("li",{"aria-hidden":!0,className:"h-4"},o):e.jsx(vt,{item:l,isSelectedHandler:s,onClick:r},o))})]});function hn({open:t,title:s,description:r,confirmLabel:n="Bevestigen",cancelLabel:a="Annuleren",tone:l="default",loading:o=!1,onConfirm:u,onCancel:c}){return e.jsx(qe,{open:t,onClose:c,title:s,size:"sm",footer:e.jsxs("div",{className:"flex w-full items-center justify-end gap-2",children:[e.jsx(re,{variant:"ghost",onClick:c,disabled:o,children:a}),e.jsx(re,{variant:l==="danger"?"destructive":"primary",onClick:u,loading:o,children:n})]}),children:r&&e.jsx(ce,{color:"secondary",children:r})})}const gn={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},bn={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},pn={none:"",primary:"bg-accent text-accent-fg",secondary:"bg-surface-hover",accent:"bg-accent-soft",success:"bg-success-soft",warning:"bg-warning-soft",error:"bg-danger-soft",info:"bg-info-soft",neutral:"bg-surface-hover",white:"bg-surface",module:"bg-surface","module-subtle":"bg-surface-sunk",backdrop:"bg-page",editor:"bg-surface",input:"bg-surface-input"},vn={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},jn={none:"shadow-none",sm:"shadow-none",md:"shadow-overlay",lg:"shadow-overlay",xl:"shadow-modal","2xl":"shadow-modal"},yn={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},Nn={primary:"border-accent-border",secondary:"border-border",accent:"border-accent-border",success:"border-success-border",warning:"border-warning-border",error:"border-danger-border",info:"border-info-border",neutral:"border-border-subtle",white:"border-border-subtle"},Ve=d.forwardRef(({padding:t,margin:s,background:r,radius:n,shadow:a,border:l,borderColor:o,className:u,children:c,...p},x)=>e.jsx("div",{ref:x,className:i(t&&gn[t],s&&bn[s],r&&pn[r],n&&vn[n],a&&jn[a],l&&yn[l],o&&Nn[o],u),...p,children:c}));Ve.displayName="Box";const wn=({children:t,title:s,...r})=>e.jsxs(Ve,{background:"module",radius:"lg",shadow:"none",border:"sm",borderColor:"neutral",...r,children:[s&&e.jsx("span",{className:"mb-2 block text-sm font-semibold text-text",children:s}),t]}),kn={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl","3xl":"text-3xl","4xl":"text-3xl"},Cn={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},Sn={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text",current:"text-current"},En={left:"text-left",center:"text-center",right:"text-right"},Tn=({level:t=1,size:s,weight:r="semibold",color:n="current",align:a="left",truncate:l=!1,className:o,children:u,...c})=>{const p=`h${t}`,x=i("font-sans text-pretty",kn[s||Mn(t)],Cn[r],Sn[n],En[a],l&&"truncate",o);return e.jsx(p,{className:x,...c,children:u})};function Mn(t){return{1:"2xl",2:"xl",3:"lg",4:"lg",5:"md",6:"md"}[t]||"md"}const Je=["cat-1","cat-2","cat-3","cat-4","cat-5"];function An(t){let s=0;for(let r=0;r<t.length;r++)s=s*31+t.charCodeAt(r)>>>0;return Je[s%Je.length]}exports.ActivityAvatar=ks;exports.ActivityGlyph=Cs;exports.ActivityRow=Ns;exports.ArtifactView=is;exports.AssistantCard=ds;exports.Avatar=Be;exports.AvatarStack=vs;exports.Badge=at;exports.Box=Ve;exports.Button=re;exports.ButtonGroup=Rt;exports.Card=wn;exports.ChannelBadge=Ms;exports.Checkbox=he;exports.CommandPalette=Wt;exports.ConfirmDialog=hn;exports.ContentLoading=Me;exports.DatePicker=Ee;exports.Dropdown=nt;exports.EmptyState=Mr;exports.ErrorBoundary=Sr;exports.FederatedResource=Er;exports.FilterChip=Ye;exports.FolderSelect=ut;exports.Form=Xr;exports.FormSection=mt;exports.Heading=Tn;exports.IDENTITY_TONE_COUNT=et;exports.Icon=Z;exports.Image=As;exports.ImageField=Yr;exports.Kbd=Ar;exports.KpiCard=Ds;exports.Link=qt;exports.List=Is;exports.ListBulkAction=Ls;exports.MeetingGrid=dn;exports.MentionComposer=gt;exports.MessageBubble=Ps;exports.MetaSeparator=Fs;exports.MetaValue=Os;exports.Modal=qe;exports.Page=Vs;exports.PageHeader=tt;exports.PageToolbar=Ks;exports.PageToolbarActions=be;exports.ParticipantTile=un;exports.Popover=Le;exports.ProgressBar=_r;exports.RichText=je;exports.RowCard=Ss;exports.SearchField=He;exports.SearchableTextField=bt;exports.SectionCaption=Ws;exports.SectionDivider=Gs;exports.SegmentedToggle=Ze;exports.Select=Ne;exports.SettingsFrameProvider=Js;exports.SettingsPage=Zs;exports.SettingsRow=Qs;exports.SettingsSection=er;exports.SidebarMenu=mn;exports.SourceChip=tr;exports.Spinner=Ir;exports.SplitButton=Ie;exports.StatusDot=Or;exports.StepIndicator=Fr;exports.StorageInput=ft;exports.Switch=pt;exports.TabBar=Ur;exports.Table=_e;exports.Tabs=xt;exports.Text=ce;exports.TextArea=Te;exports.TextField=pe;exports.TimelineEvent=Es;exports.VideoSurface=xn;exports.View=Cr;exports.autofillProps=Re;exports.badgeColumn=lt;exports.booleanBadgeColumn=gr;exports.cardActionClass=ws;exports.catTone=An;exports.cn=i;exports.createSizes=At;exports.createVariants=Mt;exports.dateFilterHandler=ar;exports.identityDotClass=ms;exports.identityPlateClass=Fe;exports.identityTone=Oe;exports.labelsColumn=br;exports.multiSelectFilterHandler=or;exports.normalizeText=ot;exports.resolveLucideIcon=Xe;exports.selectFilterHandler=lr;exports.text=ye;exports.useAnchoredPosition=ve;exports.useSettingsFrame=rt;exports.useSettingsFrameHost=Xs;
3
+ `);ee.forEach((W,j)=>{V.appendChild(document.createTextNode(W)),j<ee.length-1&&V.appendChild(document.createElement("br"))}),H.insertNode(V),H.collapse(!1),L.removeAllRanges(),L.addRange(H)}else $.innerHTML+=tn(D);w()},clear:()=>{c.current&&(c.current.innerHTML="",I(),w())},focus:()=>c.current?.focus()})),d.useEffect(()=>{!c.current||!t||(c.current.innerHTML=ht(t),w())},[t,w]),d.useEffect(()=>{l&&(window.matchMedia?.("(max-width: 767px)").matches||c.current?.focus())},[l]);const z=d.useCallback(D=>{if(["Escape","Enter","ArrowUp","ArrowDown","Tab"].includes(D.key))return;const $=window.getSelection();if(!$||$.rangeCount===0)return;const L=$.getRangeAt(0);if(!L.collapsed||L.startContainer.nodeType!==Node.TEXT_NODE)return;const H=L.startContainer,V=(H.textContent??"").slice(0,L.startOffset),ee=V.lastIndexOf("@");if(ee===-1||V.slice(ee+1).includes(" ")){x(null),g(null);return}const W=document.createRange();W.setStart(H,ee),W.setEnd(H,L.startOffset),x(V.slice(ee+1)),g(W),N(0)},[]),X=d.useCallback(D=>{if(!c.current||!f)return;const $=window.getSelection();if(!$)return;f.deleteContents();const L=document.createElement("span");L.textContent=`@${D.name}`,L.setAttribute("data-mention-id",D.id),L.setAttribute("contenteditable","false");const H=document.createTextNode(" ");f.insertNode(H),f.insertNode(L);const V=document.createRange();V.setStartAfter(H),V.collapse(!0),$.removeAllRanges(),$.addRange(V),I(),w()},[f,w,I]),B=d.useCallback(D=>{if(!c.current)return;if(m.length>0){if(D.key==="ArrowDown"){D.preventDefault(),N(j=>(j+1)%m.length);return}if(D.key==="ArrowUp"){D.preventDefault(),N(j=>(j-1+m.length)%m.length);return}if(D.key==="Enter"||D.key==="Tab"){D.preventDefault(),X(m[b]);return}if(D.key==="Escape"){D.preventDefault(),I();return}}if(a&&D.key==="Enter"&&(D.metaKey||D.ctrlKey)){D.preventDefault(),a();return}const $=window.getSelection();if(!$||$.rangeCount===0)return;const L=$.getRangeAt(0);if(!L.collapsed)return;const H=L.startContainer,V=L.startOffset,ee=j=>H.nodeType===Node.TEXT_NODE?j==="prev"?H.previousSibling:H.nextSibling:H.childNodes[j==="prev"?V-1:V],W=D.key==="Backspace"?ee("prev"):D.key==="Delete"?ee("next"):null;W instanceof HTMLElement&&W.hasAttribute("data-mention-id")&&(D.preventDefault(),W.remove(),w())},[m,b,X,I,w,a]);return e.jsxs("div",{className:"relative w-full",children:[e.jsx("div",{ref:c,contentEditable:!0,role:"textbox",tabIndex:0,"aria-multiline":"true","aria-label":n,className:i("block w-full min-h-16 rounded-lg p-3 text-sm","border-border text-text focus:outline-none",Pe,"empty:before:content-[attr(data-placeholder)] empty:before:text-text-subtle",o),"data-placeholder":n,onInput:w,onKeyUp:z,onKeyDown:B,onBlur:I}),m.length>0&&e.jsx("ul",{style:k,className:"z-50 w-64 overflow-y-auto overscroll-contain rounded-md border border-border bg-surface text-text shadow-lg",children:m.map((D,$)=>e.jsx("li",{children:e.jsx("button",{type:"button",onMouseDown:L=>{L.preventDefault(),X(D)},onMouseEnter:()=>N($),className:i("block w-full px-4 py-2 text-left text-sm",$===b&&"bg-beta-container"),children:D.name})},D.id))})]})});gt.displayName="MentionComposer";const ge=(...t)=>t.filter(Boolean).join(" "),sn=t=>e.jsx(F.Search,{...t,strokeWidth:1.5,"aria-hidden":!0}),rn=t=>e.jsx(F.ChevronDown,{...t,strokeWidth:1.5,"aria-hidden":!0}),nn={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-base",lg:"h-control-lg px-3 text-base",full:"h-control-md w-full px-3 text-base"},De={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},bt=d.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:l=e.jsx(sn,{}),loading:o=!1,containerClassName:u,labelClassName:c,className:p,id:x,options:f,onRemoteSearch:g,onSelect:b,debounceTime:N=500,showAllOnOpen:v=!1,value:m,onChange:k,...w},I)=>{const z=x||`searchfield-${Math.random().toString(36).substr(2,9)}`,X=!!r,B=d.useRef(null),D=d.useRef(null),[$,L]=d.useState(m||""),[H,V]=d.useState(!1),[ee,W]=d.useState(!1),[j,h]=d.useState(!1);d.useEffect(()=>{m!==void 0&&L(m)},[m]);const S=d.useMemo(()=>{if(v&&!j||!$)return f;const G=String($).toLowerCase();return f.filter(K=>String(K.label).toLowerCase().includes(G))},[$,f,v,j]);d.useEffect(()=>{if(!g||!$){W(!1);return}const G=setTimeout(async()=>{W(!0);try{await g(String($))}catch(K){console.error("Remote search failed:",K)}finally{W(!1)}},N);return()=>{clearTimeout(G),W(!1)}},[$,N,g]),d.useEffect(()=>{const G=K=>{B.current&&!B.current.contains(K.target)&&V(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[]);const _=G=>{const K=G.target.value;L(K),V(!0),h(!0),k&&k(G)},E=G=>{L(G.label),V(!1),h(!1),b&&b(G.value)},R=()=>{(f.length>0||g)&&(V(!0),h(!1))},M=o||ee,ae=H&&(S.length>0||M),le=d.useMemo(()=>I||D,[I]);return e.jsxs("div",{className:ge("flex flex-col",a?"w-full":"",u||"","relative"),ref:B,children:[t&&e.jsx("label",{htmlFor:z,className:ge("block text-sm font-medium mb-1",X?"text-danger-fg":"text-text",c||""),children:t}),e.jsxs("div",{className:"relative",children:[l&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:ge("text-text-muted",De[n]),children:l})}),e.jsx("input",{ref:le,id:z,value:$,onChange:_,onFocus:R,className:ge("block w-full rounded-tile border bg-surface-input transition-colors duration-fast ease-out","placeholder:text-text-subtle focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",nn[n],l?"pl-10":"","pr-10",X?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border-strong text-text",p||""),...w}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:M||o?e.jsx(F.Loader2,{className:ge("animate-spin text-info-fg",De[n]),"aria-hidden":!0}):e.jsx(rn,{className:ge("text-text-muted cursor-pointer transition-transform",De[n],H?"rotate-180":"rotate-0"),onClick:()=>{V(G=>(G||h(!1),!G))}})})]}),ae&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-surface border border-border rounded-lg shadow-lg max-h-60 overflow-auto top-full",children:S.length>0?S.map(G=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>E(G),"aria-selected":$===G.label,children:G.label},G.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:M||o?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(r||s)&&e.jsx("p",{className:ge("mt-1 text-xs",X?"text-danger-fg":"text-text-muted"),children:r||s}),g&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String($)]})]})});bt.displayName="SearchableTextField";const pt=d.forwardRef(({checked:t,onChange:s,label:r,disabled:n=!1,className:a,...l},o)=>{const u=e.jsx("span",{"aria-hidden":!0,className:i("relative inline-flex size-switch-track shrink-0 items-center rounded-full","transition-colors duration-fast ease-out",t?"bg-accent":"bg-surface-hover",n&&"opacity-50"),children:e.jsx("span",{className:i("absolute left-0.5 size-switch-knob rounded-full bg-surface shadow-overlay","transition-transform duration-fast ease-out",t&&"translate-switch")})});return e.jsxs("label",{className:i("inline-flex items-center gap-2",n?"cursor-not-allowed":"cursor-pointer",a),children:[e.jsx("input",{ref:o,type:"checkbox",role:"switch",checked:t,disabled:n,onChange:c=>s(c.target.checked),className:"peer sr-only",...l}),e.jsx("span",{className:"inline-flex rounded-full peer-focus-visible:focus-ring",children:u}),r&&e.jsx("span",{className:"text-sm text-text",children:r})]})});pt.displayName="Switch";const an=[{upTo:1,cols:"grid-cols-1"},{upTo:2,cols:"grid-cols-1 @[22rem]:grid-cols-2"},{upTo:4,cols:"grid-cols-1 @[18rem]:grid-cols-2"},{upTo:9,cols:"grid-cols-2 @[26rem]:grid-cols-3"}],ln="grid-cols-2 @[26rem]:grid-cols-3 @[40rem]:grid-cols-4";function on(t){return an.find(s=>t<=s.upTo)?.cols??ln}function cn(t,s){const r=s??t;if(t<=r)return{shown:t,hidden:0};const n=Math.max(0,r-1);return{shown:n,hidden:t-n}}function dn({tiles:t,pinned:s,maxStrip:r,className:n}){if(s){const{shown:a,hidden:l}=cn(t.length,r),o=t.slice(0,a);return e.jsxs("div",{className:i("@container flex h-full min-h-0 flex-col gap-2",n),children:[e.jsx("div",{className:"min-h-0 flex-1",children:s}),t.length>0&&e.jsxs("div",{className:"flex h-[22%] min-h-14 shrink-0 gap-2 overflow-x-auto",children:[o.map((u,c)=>e.jsx("div",{className:"h-full min-w-0 shrink-0 aspect-video",children:u},c)),l>0&&e.jsxs("div",{className:"flex h-full aspect-video shrink-0 items-center justify-center rounded-lg bg-video-surface text-sm font-semibold tabular-nums text-white/80",children:["+",l]})]})]})}return e.jsx("div",{className:i("@container grid h-full min-h-0 auto-rows-fr gap-2",on(t.length),n),children:t.map((a,l)=>e.jsx("div",{className:"min-h-0 min-w-0",children:a},l))})}function un({name:t,avatarUrl:s,muted:r,speaking:n,hasVideo:a,videoSlot:l,className:o,fill:u}){return e.jsxs("div",{className:i("@container relative flex min-h-0 min-w-0 items-center justify-center overflow-hidden rounded-lg bg-video-surface",u?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",o),children:[a&&l?e.jsx("div",{className:"absolute inset-0",children:l}):e.jsx("div",{className:"flex min-h-0 min-w-0 items-center justify-center text-gray-300",children:s?e.jsx("img",{src:s,alt:t,className:"aspect-square w-[38%] max-w-16 min-w-6 rounded-full object-cover"}):e.jsx("div",{className:"flex aspect-square w-[38%] max-w-16 min-w-6 items-center justify-center rounded-full bg-video-surface-strong",children:a?e.jsx(F.VideoOff,{className:"w-1/2 h-1/2"}):e.jsx(F.User,{className:"w-1/2 h-1/2"})})}),e.jsxs("div",{className:"absolute inset-x-2 bottom-2 flex w-fit max-w-[calc(100%-1rem)] items-center gap-1.5 rounded bg-video-overlay px-1.5 py-1 text-xs text-white",children:[r?e.jsx(F.MicOff,{className:"size-3 shrink-0"}):e.jsx(F.Mic,{className:"size-3 shrink-0"}),e.jsx("span",{className:"hidden truncate @[9rem]:inline",children:t})]})]})}function xn({attach:t,active:s=!0,mirrored:r=!1,className:n}){const a=d.useRef(null);return d.useEffect(()=>{if(!s||!a.current)return;const l=t(a.current);return()=>{typeof l=="function"&&l(),a.current&&(a.current.innerHTML="")}},[t,s]),e.jsx("div",{ref:a,className:i("w-full h-full bg-video-surface-strong overflow-hidden",r&&"[&>*]:scale-x-[-1]",n)})}const fn=()=>e.jsx(Me,{variant:"inline",shape:"menu"}),vt=({item:t,isSelectedHandler:s,onClick:r,depth:n=0})=>{const a=!!(t.children&&t.children.length>0),l=s?s(t.path):!1;if(a)return e.jsxs("li",{children:[t.label&&e.jsxs("div",{className:i("flex items-center gap-2 px-2.5 pt-5 pb-2 text-2xs font-semibold uppercase tracking-label text-text-disabled"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:"font-normal tabular-nums",children:t.count})]}),e.jsx("ul",{className:"flex flex-col gap-px",children:t.children?.map((c,p)=>e.jsx(vt,{item:c,isSelectedHandler:s,onClick:r,depth:n+1},p))})]});const o=t.action,u=o?.visibility!=="always";return e.jsx("li",{children:e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>t.path&&r?.(t.path),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),t.path&&r?.(t.path))},className:i("group/item flex h-row-md cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-base no-underline","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",l?"bg-surface-hover font-medium text-text shadow-sm":"text-text-muted hover:bg-page-hover hover:text-text"),children:[t.icon&&e.jsx("span",{className:i("flex min-w-5 shrink-0 items-center justify-center",l?"text-text-muted":"text-text-subtle"),children:t.icon}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:i("shrink-0 text-xs tabular-nums",l?"rounded-full bg-accent px-1.5 font-semibold text-accent-fg":"text-text-subtle",o&&u&&"group-hover/item:hidden group-focus-within/item:hidden"),children:t.count}),t.count===void 0&&t.meta!==void 0&&e.jsx("span",{className:i("shrink-0 text-xs text-text-subtle",o&&u&&"group-hover/item:hidden group-focus-within/item:hidden"),children:t.meta}),o&&e.jsx("button",{type:"button","aria-label":o.label,title:o.label,onClick:c=>{c.stopPropagation(),o.onClick()},onKeyDown:c=>c.stopPropagation(),className:i("flex size-5 shrink-0 items-center justify-center rounded-sm","text-text-subtle transition-colors duration-fast ease-out","hover:bg-page-hover hover:text-text","focus-visible:outline-none focus-visible:focus-ring",u&&"opacity-0 group-hover/item:opacity-100 focus-visible:opacity-100"),children:o.icon})]})})},mn=({items:t,isSelectedHandler:s,onClick:r,preMenuItemsComponent:n,loading:a=!1})=>a?e.jsxs("nav",{className:"flex h-full min-h-0 shrink-0 flex-col",children:[n&&e.jsx("div",{className:"pb-4",children:n}),e.jsx(fn,{})]}):e.jsxs("nav",{className:"flex h-full min-h-0 shrink-0 flex-col",children:[n&&e.jsx("div",{className:"pb-4",children:n}),e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-px overflow-y-auto",children:t.map((l,o)=>!l.path&&!l.label&&!l.children?e.jsx("li",{"aria-hidden":!0,className:"h-4"},o):e.jsx(vt,{item:l,isSelectedHandler:s,onClick:r},o))})]});function hn({open:t,title:s,description:r,confirmLabel:n="Bevestigen",cancelLabel:a="Annuleren",tone:l="default",loading:o=!1,onConfirm:u,onCancel:c}){return e.jsx(qe,{open:t,onClose:c,title:s,size:"sm",footer:e.jsxs("div",{className:"flex w-full items-center justify-end gap-2",children:[e.jsx(re,{variant:"ghost",onClick:c,disabled:o,children:a}),e.jsx(re,{variant:l==="danger"?"destructive":"primary",onClick:u,loading:o,children:n})]}),children:r&&e.jsx(ce,{color:"secondary",children:r})})}const gn={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},bn={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},pn={none:"",primary:"bg-accent text-accent-fg",secondary:"bg-surface-hover",accent:"bg-accent-soft",success:"bg-success-soft",warning:"bg-warning-soft",error:"bg-danger-soft",info:"bg-info-soft",neutral:"bg-surface-hover",white:"bg-surface",module:"bg-surface","module-subtle":"bg-surface-sunk",backdrop:"bg-page",editor:"bg-surface",input:"bg-surface-input"},vn={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},jn={none:"shadow-none",sm:"shadow-none",md:"shadow-overlay",lg:"shadow-overlay",xl:"shadow-modal","2xl":"shadow-modal"},yn={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},Nn={primary:"border-accent-border",secondary:"border-border",accent:"border-accent-border",success:"border-success-border",warning:"border-warning-border",error:"border-danger-border",info:"border-info-border",neutral:"border-border-subtle",white:"border-border-subtle"},Ve=d.forwardRef(({padding:t,margin:s,background:r,radius:n,shadow:a,border:l,borderColor:o,className:u,children:c,...p},x)=>e.jsx("div",{ref:x,className:i(t&&gn[t],s&&bn[s],r&&pn[r],n&&vn[n],a&&jn[a],l&&yn[l],o&&Nn[o],u),...p,children:c}));Ve.displayName="Box";const wn=({children:t,title:s,...r})=>e.jsxs(Ve,{background:"module",radius:"lg",shadow:"none",border:"sm",borderColor:"neutral",...r,children:[s&&e.jsx("span",{className:"mb-2 block text-sm font-semibold text-text",children:s}),t]}),kn={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl","3xl":"text-3xl","4xl":"text-3xl"},Cn={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},Sn={primary:"text-text",secondary:"text-text-muted",accent:"text-accent",success:"text-success-fg",warning:"text-warning-fg",error:"text-danger-fg",info:"text-info-fg",neutral:"text-text",current:"text-current"},En={left:"text-left",center:"text-center",right:"text-right"},Tn=({level:t=1,size:s,weight:r="semibold",color:n="current",align:a="left",truncate:l=!1,className:o,children:u,...c})=>{const p=`h${t}`,x=i("font-sans text-pretty",kn[s||Mn(t)],Cn[r],Sn[n],En[a],l&&"truncate",o);return e.jsx(p,{className:x,...c,children:u})};function Mn(t){return{1:"2xl",2:"xl",3:"lg",4:"lg",5:"md",6:"md"}[t]||"md"}const Je=["cat-1","cat-2","cat-3","cat-4","cat-5"];function An(t){let s=0;for(let r=0;r<t.length;r++)s=s*31+t.charCodeAt(r)>>>0;return Je[s%Je.length]}exports.ActivityAvatar=ks;exports.ActivityGlyph=Cs;exports.ActivityRow=Ns;exports.ArtifactView=is;exports.AssistantCard=ds;exports.Avatar=Be;exports.AvatarStack=vs;exports.Badge=at;exports.Box=Ve;exports.Button=re;exports.ButtonGroup=Rt;exports.Card=wn;exports.ChannelBadge=Ms;exports.Checkbox=he;exports.CommandPalette=Wt;exports.ConfirmDialog=hn;exports.ContentLoading=Me;exports.DatePicker=Ee;exports.Dropdown=nt;exports.EmptyState=Mr;exports.ErrorBoundary=Sr;exports.FederatedResource=Er;exports.FilterChip=Ye;exports.FolderSelect=ut;exports.Form=Xr;exports.FormSection=mt;exports.Heading=Tn;exports.IDENTITY_TONE_COUNT=et;exports.Icon=Z;exports.Image=As;exports.ImageField=Yr;exports.Kbd=Ar;exports.KpiCard=Ds;exports.Link=qt;exports.List=Is;exports.ListBulkAction=Ls;exports.MeetingGrid=dn;exports.MentionComposer=gt;exports.MessageBubble=Ps;exports.MetaSeparator=Fs;exports.MetaValue=Os;exports.Modal=qe;exports.Page=Vs;exports.PageHeader=tt;exports.PageToolbar=Ks;exports.PageToolbarActions=be;exports.ParticipantTile=un;exports.Popover=Le;exports.ProgressBar=_r;exports.RichText=je;exports.RowCard=Ss;exports.SearchField=He;exports.SearchableTextField=bt;exports.SectionCaption=Ws;exports.SectionDivider=Gs;exports.SegmentedToggle=Ze;exports.Select=Ne;exports.SettingsFrameProvider=Js;exports.SettingsPage=Zs;exports.SettingsRow=Qs;exports.SettingsSection=er;exports.SidebarMenu=mn;exports.SourceChip=tr;exports.Spinner=Ir;exports.SplitButton=Ie;exports.StatusDot=Or;exports.StepIndicator=Fr;exports.StorageInput=ft;exports.Switch=pt;exports.TabBar=Ur;exports.Table=_e;exports.Tabs=xt;exports.Text=ce;exports.TextArea=Te;exports.TextField=pe;exports.TimelineEvent=Es;exports.VideoSurface=xn;exports.View=Cr;exports.autofillProps=Re;exports.badgeColumn=lt;exports.booleanBadgeColumn=gr;exports.cardActionClass=ws;exports.catTone=An;exports.cn=i;exports.createSizes=At;exports.createVariants=Mt;exports.dateFilterHandler=ar;exports.identityDotClass=ms;exports.identityPlateClass=Fe;exports.identityTone=Oe;exports.labelsColumn=br;exports.multiSelectFilterHandler=or;exports.normalizeText=ot;exports.resolveLucideIcon=Xe;exports.selectFilterHandler=lr;exports.text=ye;exports.useAnchoredPosition=ve;exports.useSettingsFrame=rt;exports.useSettingsFrameHost=Xs;
4
4
  //# sourceMappingURL=index.cjs.map