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