@opencxh/ui-kit 3.176.1 → 3.177.0

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