@opencxh/ui-kit 3.125.0 → 3.132.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 +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +800 -745
- package/dist/index.js.map +1 -1
- package/dist/src/content/RichText.d.ts +14 -0
- package/dist/src/forms/Form.d.ts +6 -0
- package/dist/src/index.d.ts +1 -0
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Oe=require("clsx"),e=require("react/jsx-runtime"),I=require("lucide-react"),i=require("react");function d(...t){return Oe.clsx(t)}function Be(t){return(s,r)=>t[s]?.[r]||""}function Ve(t){return s=>t[s]||""}function He({tiles:t,pinned:s,className:r}){if(s)return e.jsxs("div",{className:d("flex flex-col md:flex-row gap-2 h-full min-h-0",r),children:[e.jsx("div",{className:"flex-1 min-h-0",children:s}),t.length>0&&e.jsx("div",{className:"flex md:flex-col gap-2 md:w-48 overflow-auto",children:t.map((a,o)=>e.jsx("div",{className:"min-w-40 md:min-w-0",children:a},o))})]});const n=t.length<=1?"grid-cols-1":t.length<=4?"grid-cols-2":t.length<=9?"grid-cols-3":"grid-cols-4";return e.jsx("div",{className:d("grid gap-2 h-full",n,r),children:t.map((a,o)=>e.jsx("div",{children:a},o))})}function qe({name:t,avatarUrl:s,muted:r,speaking:n,hasVideo:a,videoSlot:o,className:l,fill:u}){return e.jsxs("div",{className:d("relative rounded-lg overflow-hidden bg-video-surface flex items-center justify-center",u?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",l),children:[a&&o?e.jsx("div",{className:"absolute inset-0",children:o}):e.jsx("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:s?e.jsx("img",{src:s,alt:t,className:"w-16 h-16 rounded-full object-cover"}):e.jsx("div",{className:"w-16 h-16 rounded-full bg-video-surface-strong flex items-center justify-center",children:a?e.jsx(I.VideoOff,{className:"w-8 h-8"}):e.jsx(I.User,{className:"w-8 h-8"})})}),e.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded bg-video-overlay text-white text-xs",children:[r?e.jsx(I.MicOff,{className:"w-3 h-3"}):e.jsx(I.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-35",children:t})]})]})}function Ue({attach:t,active:s=!0,mirrored:r=!1,className:n}){const a=i.useRef(null);return i.useEffect(()=>{if(!s||!a.current)return;const o=t(a.current);return()=>{typeof o=="function"&&o(),a.current&&(a.current.innerHTML="")}},[t,s]),e.jsx("div",{ref:a,className:d("w-full h-full bg-video-surface-strong overflow-hidden",r&&"[&>*]:scale-x-[-1]",n)})}const We={primary:"bg-accent text-accent-fg hover:bg-accent-hover disabled:bg-surface-hover",secondary:"bg-gray-100 text-text hover:bg-surface-hover disabled:bg-surface-hover",outline:"border border-border text-accent 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"},Ke={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"},_e={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=i.forwardRef(({variant:t="primary",size:s="md",fullWidth:r=!1,loading:n=!1,leftIcon:a,rightIcon:o,iconOnly:l=!1,shape:u="default",className:x,children:j,disabled:m,...f},h)=>{const g=m||n;return e.jsxs("button",{ref:h,type:"button",className:d("inline-flex shrink-0 items-center justify-center gap-2 cursor-pointer font-semibold",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",We[t],l?_e[s]:Ke[s],(r||s==="full")&&"w-full",n&&"cursor-wait",x),disabled:g,"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}),!l&&j,!n&&o&&e.jsx("span",{className:"flex items-center justify-center shrink-0",children:o}),l&&!n&&!a&&!o&&j]})});se.displayName="Button";const Ge=({children:t,size:s="md",orientation:r="horizontal",attached:n=!0,className:a})=>{const o=d("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:o,role:"group",children:t})},Je={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:o,"aria-label":l,...u})=>{const x=typeof s=="number"?s:Ye(s),j=d("inline-block shrink-0",Je[r],n&&["cursor-pointer rounded-sm transition-opacity duration-fast ease-out hover:opacity-80","focus-visible:outline-none focus-visible:focus-ring"],o),m={size:x,strokeWidth:2,className:j,onClick:n?a:void 0,"aria-label":l,"aria-hidden":l?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,{...m})};function Ye(t){return{xs:12,sm:14,md:16,lg:20,xl:24}[t]}const Xe={none:"border-none hover:bg-surface-hover hover:text-text",default:"border-border text-text-muted hover:bg-surface-hover hover:text-text",muted:"border-border text-text-subtle hover:bg-surface-hover hover:text-text",warning:"border-warning-border bg-warning-soft text-warning-fg hover:bg-surface-hover",danger:"border-danger-border bg-danger-soft text-danger-fg hover:bg-surface-hover"};function Ze({label:t,icon:s,tone:r="default",shape:n="pill",size:a="md",active:o=!1,caret:l=!1,onClear:u,clearLabel:x="Filter wissen",onClick:j,title:m,className:f}){const h=o&&!!u,g=n==="pill"?"rounded-full":"rounded-md",N=d("inline-flex cursor-pointer select-none items-center text-sm font-semibold",a==="sm"?"h-control-sm":"h-control-md","transition-colors duration-fast ease-out",g,o?"bg-accent text-accent-fg":d("border",Xe[r]),f),p=e.jsxs(e.Fragment,{children:[s,t,l&&e.jsx(Y,{icon:I.ChevronDown,size:"xs"})]}),b=d("inline-flex items-center gap-1.5 pl-3",g,h?"pr-1.5":"pr-3","focus-visible:outline-none focus-visible:focus-ring");return h?e.jsxs("span",{className:N,title:m,children:[e.jsx("button",{type:"button",onClick:j,className:b,children:p}),e.jsx("button",{type:"button","aria-label":x,onClick:u,className:d("inline-flex h-full items-center pr-3 focus-visible:outline-none focus-visible:focus-ring",g),children:e.jsx(Y,{icon:I.X,size:"xs"})})]}):e.jsx("button",{type:"button",title:m,onClick:j,className:d(N,b),children:p})}const Qe={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},et={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"},tt={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"},st=({variant:t="default",size:s="md",color:r="primary",disabled:n=!1,external:a=!1,className:o,children:l,href:u,target:x,rel:j,...m})=>{const f=a||u&&(u.startsWith("http")||u.startsWith("mailto:")),h=d("inline-flex items-center gap-1 underline-offset-2","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",Qe[s],!n&&et[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",tt[r]],n&&"pointer-events-none cursor-not-allowed text-text-disabled opacity-50",o),g={...m,href:n?void 0:u,target:f?"_blank":x,rel:f?"noopener noreferrer":j,"aria-disabled":n||void 0};return e.jsxs("a",{className:h,...g,children:[l,f&&e.jsx(I.ExternalLink,{className:"size-icon-sm shrink-0","aria-hidden":!0})]})},rt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm"};function nt({options:t,value:s,onChange:r,size:n="sm",className:a,"aria-label":o}){return e.jsx("div",{role:"tablist","aria-label":o,className:d("inline-flex gap-0.5 rounded-md bg-surface-hover p-0.5",a),children:t.map(l=>{const u=l.value===s;return e.jsx("button",{role:"tab","aria-selected":u,type:"button",onClick:()=>r(l.value),className:d("inline-flex items-center justify-center rounded-sm","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",rt[n],u?"bg-surface text-text font-semibold":"text-text-muted hover:text-text"),children:l.label},l.value)})})}function be(t,s,{gap:r=6,matchWidth:n=!1,placement:a="bottom-start"}={}){const[o,l]=i.useState({});return i.useLayoutEffect(()=>{if(!t)return;const u=()=>{const x=s.current;if(!x)return;const j=x.getBoundingClientRect(),m=window.innerHeight-j.bottom,f=j.top,h=a.startsWith("top"),g=h?f<200&&m>f:m<200&&f>m,N=h!==g,p={position:"fixed"};N?(p.bottom=window.innerHeight-j.top+r,p.maxHeight=Math.max(120,f-r*2)):(p.top=j.bottom+r,p.maxHeight=Math.max(120,m-r*2)),a.endsWith("end")?p.right=window.innerWidth-j.right:p.left=j.left,n&&(p.width=j.width),l(p)};return u(),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[t,s,r,n,a]),o}const Ee=({trigger:t,children:s,placement:r="bottom-start",className:n,rootClassName:a,triggerClassName:o,disabled:l=!1,triggerLabel:u})=>{const[x,j]=i.useState(!1),m=i.useRef(null),f=i.useRef(null),h=be(x,f,{placement:r});i.useEffect(()=>{if(!x)return;const p=L=>{m.current&&!m.current.contains(L.target)&&j(!1)},b=L=>{L.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",b)}},[x]);const g=p=>{p.stopPropagation(),!l&&j(b=>!b)},N=()=>j(!1);return e.jsxs("div",{ref:m,className:d("relative inline-flex",a),children:[e.jsx("button",{ref:f,type:"button",onClick:g,disabled:l,"aria-label":u,"aria-expanded":x,className:d("inline-flex items-center",l&&"cursor-not-allowed opacity-50",o),children:t}),x&&e.jsx("div",{className:d("fixed z-overlay overflow-y-auto rounded-lg border border-border bg-surface shadow-overlay",n),style:h,children:typeof s=="function"?s(N):s})]})},at={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"},lt={sm:"h-control-sm w-7",md:"h-control-md w-8"};function ve({label:t,onClick:s,variant:r="primary",size:n="md",icon:a,options:o,disabled:l=!1,loading:u=!1,menuPlacement:x="bottom-end",menuLabel:j="More options"}){const m=l||u,f=o.length>0;return e.jsxs("div",{className:d("inline-flex items-center",r==="primary"&&"gap-0.5"),children:[e.jsx(se,{variant:r,size:n,onClick:s,disabled:l,loading:u,leftIcon:a,className:d(f&&"rounded-r-none"),children:t}),f&&e.jsx(Ee,{placement:x,disabled:m,triggerLabel:j,className:"min-w-menu py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:d("inline-flex items-center justify-center rounded-md rounded-l-none","transition-colors duration-fast ease-out",at[r],lt[n],m&&"cursor-not-allowed opacity-50"),children:e.jsx(I.ChevronDown,{className:"size-icon-md"})}),children:h=>e.jsx(e.Fragment,{children:o.map(g=>e.jsxs("button",{type:"button",onClick:()=>{g.onClick(),h()},className:d("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",g.variant==="destructive"?"text-danger-fg hover:bg-danger-soft":"text-text hover:bg-surface-hover"),children:[g.icon&&e.jsx("span",{className:"shrink-0",children:g.icon}),g.label]},g.id))})})]})}const ot={sm:"size-checkbox-sm",md:"size-checkbox",lg:"size-checkbox-lg",full:"size-checkbox"},ct={sm:"min-h-control-sm",md:"min-h-control-md",lg:"min-h-control-lg",full:"min-h-control-md"},it={sm:"text-sm",md:"text-base",lg:"text-md",full:"text-base"},de=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",indeterminate:a=!1,containerClassName:o,labelClassName:l,className:u,id:x,...j},m)=>{const f=i.useId(),h=x||`checkbox-${f}`,g=!!r,N=i.useRef(null),p=i.useCallback(b=>{N.current=b,typeof m=="function"?m(b):m&&typeof m=="object"&&(m.current=b)},[m]);return i.useEffect(()=>{N.current&&(N.current.indeterminate=a)},[a]),e.jsxs("div",{className:d("flex flex-col",o),children:[e.jsxs("div",{className:d("flex items-center gap-3",ct[n]),children:[e.jsx("input",{ref:p,id:h,type:"checkbox","aria-invalid":g||void 0,className:d("shrink-0 rounded-md 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",ot[n],g?"border-danger-border":"border-border-strong",u),...j}),t&&e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:h,className:d("cursor-pointer",g?"text-danger-fg":"text-text",it[n],l),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})]})});de.displayName="Checkbox";const dt=()=>e.jsx(Y,{icon:I.Calendar,size:"md",color:"current"}),ut=()=>e.jsx(Y,{icon:I.ChevronLeft,size:"md",color:"current"}),xt=()=>e.jsx(Y,{icon:I.ChevronRight,size:"md",color:"current"}),me=i.forwardRef(({value:t,onChange:s,placeholder:r="Select date",disabled:n=!1,required:a=!1,size:o="md",className:l,minDate:u,maxDate:x,format:j="MM/dd/yyyy",withTime:m=!1},f)=>{const[h,g]=i.useState(!1),[N,p]=i.useState(()=>t||new Date),b=i.useRef(null),L=i.useRef(null),$=be(h,L);i.useEffect(()=>{const c=C=>{b.current&&!b.current.contains(C.target)&&g(!1)};return h&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[h]);const _=c=>{if(!c)return"";const C=c.getDate().toString().padStart(2,"0"),y=(c.getMonth()+1).toString().padStart(2,"0"),T=c.getFullYear(),w=j==="dd/MM/yyyy"?`${C}/${y}/${T}`:j==="yyyy-MM-dd"?`${T}-${y}-${C}`:`${y}/${C}/${T}`;return m?`${w} ${M(c)}`:w},M=c=>`${c.getHours().toString().padStart(2,"0")}:${c.getMinutes().toString().padStart(2,"0")}`,X=c=>{const[C,y]=c.split(":").map(Number);if(Number.isNaN(C)||Number.isNaN(y))return;const T=t?new Date(t):new Date;T.setHours(C,y,0,0),s?.(T)},W=()=>{const c=N.getFullYear(),C=N.getMonth(),y=new Date(c,C,1),T=new Date(y);T.setDate(T.getDate()-y.getDay());const w=[],Q=new Date(T);for(let re=0;re<42;re++)w.push(new Date(Q)),Q.setDate(Q.getDate()+1);return w},R=c=>{if(c.getMonth()===N.getMonth()&&!(u&&c<u)&&!(x&&c>x)){if(m){const y=new Date(c);y.setHours(t?.getHours()??0,t?.getMinutes()??0,0,0),s?.(y);return}s?.(c),g(!1)}},U=()=>{p(new Date(N.getFullYear(),N.getMonth()-1,1))},K=()=>{p(new Date(N.getFullYear(),N.getMonth()+1,1))},te=()=>{s?.(null),g(!1)},F=d("w-full border border-border rounded-md 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":o==="sm","h-control-md px-3 text-base":o==="md","h-control-lg px-3 text-base":o==="lg","h-control-md w-full px-3 text-base":o==="full"},l),ae=W(),k=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:b,className:"relative",children:[e.jsxs("div",{ref:L,className:"relative",children:[e.jsx("input",{ref:f,type:"text",value:_(t??null),placeholder:r,disabled:n,required:a,readOnly:!0,onClick:()=>!n&&g(!h),className:d(F,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!n&&g(!h),disabled:n,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted hover:text-text-muted",children:e.jsx(dt,{})})]}),h&&e.jsxs("div",{style:$,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:U,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(ut,{})}),e.jsxs("h3",{className:"text-sm font-medium text-text",children:[k[N.getMonth()]," ",N.getFullYear()]}),e.jsx("button",{onClick:K,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(xt,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(c=>e.jsx("div",{className:"text-xs font-medium text-text-muted text-center py-1",children:c},c))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:ae.map((c,C)=>{const y=c.getMonth()===N.getMonth(),T=t&&c.toDateString()===t.toDateString(),w=c.toDateString()===new Date().toDateString(),Q=!y||u&&c<u||x&&c>x;return e.jsx("button",{onClick:()=>!Q&&R(c),disabled:Q,className:d("w-8 h-8 text-sm rounded transition-colors duration-fast",{"text-text hover:bg-surface-hover":y&&!T&&!Q,"bg-accent text-accent-fg":T,"bg-surface-hover text-text":w&&!T,"text-text-muted cursor-not-allowed":Q}),children:c.getDate()},C)})}),m&&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?M(t):"",onChange:c=>X(c.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:te,className:"text-sm text-text-muted hover:text-text",children:"Clear"}),e.jsx("button",{onClick:()=>g(!1),className:"text-sm text-info-fg hover:underline",children:"Close"})]})]})]})}),ft={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"},fe=t=>t.trim().toLowerCase(),ue=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,disabled:o=!1,options:l,placeholder:u,containerClassName:x,labelClassName:j,className:m,id:f,searchable:h,multiple:g,value:N,onChange:p,allowCreate:b,onCreateOption:L,...$},_)=>{const M=f||`select-${Math.random().toString(36).substr(2,9)}`,X=!!r,[W,R]=i.useState(!1),[U,K]=i.useState(""),te=i.useRef(null),F=i.useRef(null),ae=be(W,F,{matchWidth:!0}),[k,c]=i.useState(l);i.useImperativeHandle(_,()=>te.current),i.useEffect(()=>{const E=D=>{te.current&&!te.current.contains(D.target)&&R(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const C=i.useCallback((E,D)=>E.some(S=>fe(S.value)===fe(D)||fe(S.label)===fe(D)),[]),y=i.useCallback((E,D)=>{const S=[...E],V=B=>{const H=(B??"").trim();H&&(C(S,H)||S.push({value:H,label:H}))};return Array.isArray(D)?D.forEach(V):V(D),S},[C]);i.useEffect(()=>{c(E=>{const D=[...l];return E.forEach(S=>{!C(D,S.value)&&!C(D,S.label)&&D.push(S)}),y(D,N)})},[l,N,y,C]);const T=E=>{if(g){const D=Array.isArray(N)?N:[],S=D.includes(E)?D.filter(V=>V!==E):[...D,E];p?.(S)}else p?.(E),R(!1),K("")},w=g?null:k.find(E=>E.value===N),Q=g?k.filter(E=>Array.isArray(N)&&N.includes(E.value)):[],re=h&&U?k.filter(E=>E.label.toLowerCase().includes(U.toLowerCase())):k,ne=!!b&&!!h&&!!U.trim()&&!C(k,U),G=E=>{const D=E.trim();if(!D)return;const S=L?.(D)??{value:D,label:D};if(C(k,S.value)||C(k,S.label)){T(S.value),K(""),g||R(!1);return}c(V=>[...V,S]),T(S.value),K(""),g||R(!1)},P=()=>g?Q.length>0?Q.map(E=>E.label).join(", "):u||"Select options":w?.label||u||"Select an option";return e.jsxs("div",{ref:te,className:d("relative flex flex-col",a&&"w-full",x),...$,children:[t&&e.jsx("label",{htmlFor:M,onClick:()=>R(!W),className:d("block text-xs font-semibold uppercase tracking-label mb-1.5",X?"text-danger-fg":"text-text-muted",j),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:F,type:"button",id:M,disabled:o,onClick:()=>R(!W),className:d("flex w-full items-center justify-between gap-2 rounded-md 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",ft[n],X?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",m),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:P()}),e.jsx(I.ChevronDownIcon,{size:16,className:d("shrink-0 opacity-60 transition-transform duration-fast",W&&"rotate-180")})]}),W&&e.jsxs("div",{style:ae,className:"fixed z-overlay flex flex-col overflow-hidden rounded-lg border border-border bg-surface shadow-overlay",children:[h&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:U,onChange:E=>K(E.target.value),onKeyDown:E=>{E.key==="Enter"&&ne&&(E.preventDefault(),G(U))},className:d("w-full px-3 py-2 text-sm rounded-md border","text-text border-border focus-visible:outline-none focus-visible:focus-ring")})}),ne&&e.jsxs("div",{className:d("cursor-pointer px-3 py-1.5 text-sm","text-info-fg hover:bg-surface-hover"),onClick:()=>G(U),children:["+: “",U.trim(),"”"]}),e.jsxs("ul",{className:"min-h-0 flex-1 overflow-auto py-1",children:[u&&!g&&e.jsx("li",{className:"cursor-pointer px-3 py-1.5 text-sm text-text-muted hover:bg-surface-hover",onClick:()=>{p?.(""),R(!1)},children:u}),re.map(E=>{const D=g?Array.isArray(N)&&N.includes(E.value):N===E.value;return e.jsx("li",{onClick:()=>!E.disabled&&T(E.value),className:d("cursor-pointer px-3 py-1.5 text-sm","text-text",E.disabled?"opacity-50 cursor-not-allowed":"hover:bg-surface-hover",D&&"bg-accent-soft text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[g&&e.jsx("input",{type:"checkbox",checked:D,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-border [&:not(:checked)]:bg-surface-input text-accent "}),e.jsx("span",{children:E.label})]})},E.value)})]})]})]}),(r||s)&&e.jsx("p",{className:d("mt-1 text-xs",X?"text-danger-fg":"text-text-muted"),children:r||s})]})});ue.displayName="Select";const mt={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"},ze="mb-1.5 block text-xs font-semibold uppercase tracking-label",ce=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:o,endIcon:l,loading:u=!1,containerClassName:x,labelClassName:j,className:m,id:f,...h},g)=>{const N=i.useId(),p=f||`textfield-${N}`,b=!!r,L=r||s?`${p}-description`:void 0;return e.jsxs("div",{className:d("flex flex-col",a&&"w-full",x),children:[t&&e.jsx("label",{htmlFor:p,className:d(ze,b?"text-danger-fg":"text-text-subtle",j),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 text-text-muted",children:o}),e.jsx("input",{ref:g,id:p,"aria-invalid":b||void 0,"aria-describedby":L,className:d("block w-full rounded-md 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",mt[n],o&&"pl-9",(l||u)&&"pr-9",b?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",m),...h}),(l||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"}):l})]}),(r||s)&&e.jsx("p",{id:L,className:d("mt-1 text-xs",b?"text-danger-fg":"text-text-subtle"),children:r||s})]})});ce.displayName="TextField";function Me({value:t,onChange:s,onListFolders:r,disabled:n,size:a="md",placeholder:o,templatePlaceholder:l,showTemplate:u=!0}){const[x,j]=i.useState([]);i.useEffect(()=>{let f=!0;return Promise.resolve(r?.()).then(h=>{f&&h&&j(h.data??[])}).catch(()=>{}),()=>{f=!1}},[]);const m=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ue,{size:a,fullWidth:!0,value:m.folderId??"",options:x.map(f=>({value:f.id,label:f.name})),placeholder:o??"Select a folder",onChange:f=>s?.({...m,folderId:f})}),u&&e.jsx(ce,{size:a,disabled:n??!1,value:m.pathTemplate??"",placeholder:l??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:f=>s?.({...m,pathTemplate:f.target.value})})]})}const ie=(...t)=>t.filter(Boolean).join(" "),ht=t=>e.jsx(I.Search,{...t,strokeWidth:1.5,"aria-hidden":!0}),bt=t=>e.jsx(I.ChevronDown,{...t,strokeWidth:1.5,"aria-hidden":!0}),gt={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"},ge={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},De=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:o=e.jsx(ht,{}),loading:l=!1,containerClassName:u,labelClassName:x,className:j,id:m,options:f,onRemoteSearch:h,onSelect:g,debounceTime:N=500,showAllOnOpen:p=!1,value:b,onChange:L,...$},_)=>{const M=m||`searchfield-${Math.random().toString(36).substr(2,9)}`,X=!!r,W=i.useRef(null),R=i.useRef(null),[U,K]=i.useState(b||""),[te,F]=i.useState(!1),[ae,k]=i.useState(!1),[c,C]=i.useState(!1);i.useEffect(()=>{b!==void 0&&K(b)},[b]);const y=i.useMemo(()=>{if(p&&!c||!U)return f;const P=String(U).toLowerCase();return f.filter(E=>String(E.label).toLowerCase().includes(P))},[U,f,p,c]);i.useEffect(()=>{if(!h||!U){k(!1);return}const P=setTimeout(async()=>{k(!0);try{await h(String(U))}catch(E){console.error("Remote search failed:",E)}finally{k(!1)}},N);return()=>{clearTimeout(P),k(!1)}},[U,N,h]),i.useEffect(()=>{const P=E=>{W.current&&!W.current.contains(E.target)&&F(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);const T=P=>{const E=P.target.value;K(E),F(!0),C(!0),L&&L(P)},w=P=>{K(P.label),F(!1),C(!1),g&&g(P.value)},Q=()=>{(f.length>0||h)&&(F(!0),C(!1))},re=l||ae,ne=te&&(y.length>0||re),G=i.useMemo(()=>_||R,[_]);return e.jsxs("div",{className:ie("flex flex-col",a?"w-full":"",u||"","relative"),ref:W,children:[t&&e.jsx("label",{htmlFor:M,className:ie("block text-sm font-medium mb-1",X?"text-danger-fg":"text-text",x||""),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:ie("text-text-muted",ge[n]),children:o})}),e.jsx("input",{ref:G,id:M,value:U,onChange:T,onFocus:Q,className:ie("block w-full rounded-md 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",gt[n],o?"pl-10":"","pr-10",X?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",j||""),...$}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:re||l?e.jsx(I.Loader2,{className:ie("animate-spin text-info-fg",ge[n]),"aria-hidden":!0}):e.jsx(bt,{className:ie("text-text-muted cursor-pointer transition-transform",ge[n],te?"rotate-180":"rotate-0"),onClick:()=>{F(P=>(P||C(!1),!P))}})})]}),ne&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-surface border border-border rounded-lg shadow-lg max-h-60 overflow-auto top-full",role:"listbox",children:y.length>0?y.map(P=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>w(P),role:"option","aria-selected":U===P.label,children:P.label},P.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:re||l?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(r||s)&&e.jsx("p",{className:ie("mt-1 text-xs",X?"text-danger-fg":"text-text-muted"),children:r||s}),h&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String(U)]})]})});De.displayName="SearchableTextField";const $e=i.forwardRef(({checked:t,onChange:s,label:r,disabled:n=!1,className:a,...o},l)=>{const u=e.jsx("span",{"aria-hidden":!0,className:d("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:d("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:d("inline-flex items-center gap-2",n?"cursor-not-allowed":"cursor-pointer",a),children:[e.jsx("input",{ref:l,type:"checkbox",role:"switch",checked:t,disabled:n,onChange:x=>s(x.target.checked),className:"peer sr-only",...o}),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})]})});$e.displayName="Switch";function Te({variant:t="page",children:s,showTableSkeleton:r=!1,tableColumns:n=6,tableRows:a=8}){const o=({children:l})=>t==="inline"?e.jsx(e.Fragment,{children:l}):e.jsx("main",{className:"flex-1 bg-surface p-6",children:l});return s?e.jsx(o,{children:e.jsx("div",{className:"w-full max-w-6xl mx-auto animate-pulse",children:s})}):e.jsx(o,{children:e.jsxs("div",{className:"w-full mx-auto space-y-6 animate-pulse",children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-6 w-1/4 rounded-sm bg-surface-hover"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-3/4 rounded-sm bg-surface-hover"}),e.jsx("div",{className:"h-4 w-1/2 rounded-sm bg-surface-hover"})]})]}),r&&e.jsxs("div",{className:"rounded-lg overflow-hidden",children:[e.jsx("div",{className:"grid gap-2 bg-surface-hover p-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:Array.from({length:n}).map((l,u)=>e.jsx("div",{className:"h-4 w-2/3 rounded-sm bg-border-strong"},`header-${u}`))}),Array.from({length:a}).map((l,u)=>e.jsx("div",{className:"grid gap-2 border-t border-border-subtle p-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:Array.from({length:n}).map((x,j)=>e.jsx("div",{className:"h-4 w-full rounded-sm bg-surface-hover"},`cell-${u}-${j}`))},`row-${u}`))]})]})})}const Le=({trigger:t,options:s,value:r,onSelect:n,placement:a="bottom-start",disabled:o=!1,className:l,showCheck:u=!0,header:x})=>{const[j,m]=i.useState(!1),[f,h]=i.useState(null),[g,N]=i.useState({top:0,left:0}),p=i.useRef(null),b=i.useRef(null),L=i.useRef(null),$=i.useRef(null),_=be(j,b,{placement:a}),M=i.useRef(null),X=()=>Array.from($.current?.querySelectorAll("button[data-option-value]:not(:disabled)")??[]);i.useEffect(()=>{j&&X()[0]?.focus()},[j]);const W=c=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(c.key))return;const y=X();if(y.length===0)return;c.preventDefault();const T=y.indexOf(document.activeElement),w=c.key==="Home"?0:c.key==="End"?y.length-1:c.key==="ArrowDown"?(T+1)%y.length:(T-1+y.length)%y.length;y[w]?.focus()};i.useEffect(()=>{const c=C=>{p.current&&(!p.current.contains(C.target)||L.current&&!L.current.contains(C.target))&&(m(!1),h(null),M.current&&(clearTimeout(M.current),M.current=null))};return j&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[j]),i.useEffect(()=>{const c=C=>{C.key==="Escape"&&(m(!1),h(null),b.current?.focus(),M.current&&(clearTimeout(M.current),M.current=null))};return j&&document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[j]),i.useEffect(()=>{if(f&&p.current){const c=p.current.querySelector(`[data-option-value="${f}"]`);if(c){const C=c.getBoundingClientRect();N({top:C.top,left:C.right+8})}}},[f]),i.useEffect(()=>()=>{M.current&&clearTimeout(M.current)},[]);const R=c=>{c.stopPropagation(),!o&&(m(!j),h(null),M.current&&(clearTimeout(M.current),M.current=null))},U=(c,C,y)=>{c.stopPropagation(),!C.disabled&&!C.divider&&(!C.children||C.children.length===0)&&(n?.(C.value,y),m(!1),h(null))},K=c=>{M.current&&(clearTimeout(M.current),M.current=null),c.children&&c.children.length>0?h(c.value):h(null)},te=c=>{c.children&&c.children.length>0?M.current=setTimeout(()=>{h(null)},150):h(null)},F=(c,C,y)=>{c.stopPropagation(),!C.disabled&&!C.divider&&(n?.(C.value,y),m(!1),h(null))},ae=d("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto"),k=d("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto");return e.jsxs("div",{ref:p,className:d("relative flex flex-row items-center justify-center rounded-lg hover:bg-surface-hover",l),children:[e.jsx("button",{ref:b,onClick:R,disabled:o,"aria-haspopup":"menu","aria-expanded":j,className:d("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":o}),children:t}),j&&e.jsx("div",{ref:$,className:ae,style:_,onKeyDown:W,children:e.jsxs("div",{className:"p-2",role:"menu",children:[x&&(typeof x=="string"?e.jsx("div",{className:"text-xs font-medium text-text-muted uppercase tracking-label px-3 py-2",children:x}):x),s.map((c,C)=>{if(c.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${C}`);const y=c.children&&c.children.length>0,T=f===c.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":c.value,role:"menuitem","aria-haspopup":y?"menu":void 0,onClick:w=>U(w,c),onMouseEnter:()=>K(c),onMouseLeave:()=>te(c),disabled:c.disabled,className:d("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":c.disabled,"bg-surface-hover":T&&y}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[c.icon&&e.jsx("span",{className:"flex-shrink-0",children:c.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:c.label}),c.description&&e.jsx("span",{className:"text-xs text-text-muted",children:c.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[u&&r===c.value&&e.jsx(I.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0}),y&&e.jsx("span",{className:"text-text-muted text-xs",children:"▶"})]})]}),y&&T&&e.jsx("div",{ref:L,className:k,style:{top:`${g.top}px`,left:`${g.left}px`},onMouseEnter:()=>{M.current&&(clearTimeout(M.current),M.current=null),h(c.value)},onMouseLeave:()=>{M.current=setTimeout(()=>{h(null)},150)},children:e.jsx("div",{className:"p-2",children:c.children.map((w,Q)=>{if(w.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${Q}`);const re=typeof r=="object"&&r[c.value]&&r[c.value].includes(w.value)||r===w.value;return e.jsxs("button",{onClick:ne=>F(ne,w,c.value),disabled:w.disabled,className:d("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":w.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[w.icon&&e.jsx("span",{className:"flex-shrink-0",children:w.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:w.label}),w.description&&e.jsx("span",{className:"text-xs text-text-muted",children:w.description})]})]}),u&&re&&e.jsx(I.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0})]},w.value)})})})]},c.value)}),(()=>{const c=s.reduce((C,y)=>{if(y.divider)return C;const T=y.children?y.children.filter(w=>!w.divider).length:0;return C+1+T},0);return c>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:[c," options available"]})})})()]})})]})},Ne={none:"pl-0",sm:"pl-2",md:"pl-4",lg:"pl-6"},we={none:"pr-0",sm:"pr-2",md:"pr-4",lg:"pr-6"},pt=()=>e.jsx(Y,{icon:I.Search,size:"md",color:"current"}),vt=({active:t})=>e.jsx(Y,{icon:I.ChevronUp,size:"sm",className:t?"text-text":"text-text-subtle"}),jt=({active:t})=>e.jsx(Y,{icon:I.ChevronDown,size:"sm",className:t?"text-text":"text-text-subtle"}),yt=()=>e.jsx(Y,{icon:I.ChevronLeft,size:"md",color:"current"}),Nt=()=>e.jsx(Y,{icon:I.ChevronRight,size:"md",color:"current"}),wt=()=>e.jsx(Y,{icon:I.ChevronsLeft,size:"md",color:"current"}),kt=()=>e.jsx(Y,{icon:I.ChevronsRight,size:"md",color:"current"}),Ae=()=>e.jsx(Y,{icon:I.ChevronDown,size:"md",color:"current"}),Ct=t=>{const s=n=>t.multiSelect&&Array.isArray(t.value)?t.value?.includes(n):t.value===n,r=n=>{t.multiSelect&&Array.isArray(t.value)?t.onChange(t.value.filter(a=>a!==n)):t.onChange(n)};return t.type==="date"?e.jsx("div",{className:"flex items-center space-x-1 max-w-40",children:e.jsx(me,{size:"sm",value:t.value,onChange:n=>t.onChange(n),placeholder:t.placeholder||`Select ${t.label.toLowerCase()}`,className:"min-w-40 border border-border bg-surface text-text hover:bg-surface-hover"})}):e.jsx("div",{className:"flex items-center space-x-1 max-w-60",children:e.jsx("div",{className:"relative",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex h-control-md cursor-pointer items-center gap-2 rounded-full border border-border bg-surface px-3 text-sm font-semibold text-text hover:bg-surface-hover",children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:"text-text",children:t.multiSelect&&Array.isArray(t.value)?t.value?.map(n=>t.options?.find(a=>a.value===n)?.label).join(", "):t.options?.find(n=>n.value===t.value)?.label}),e.jsx("span",{className:"text-text-muted text-sm group-open:rotate-180 transition-transform",children:e.jsx(Ae,{})})]}),e.jsxs("div",{className:"absolute z-10 left-0 mt-1 bg-surface border border-border rounded-lg shadow-overlay p-2 w-48",children:[t.options?.map(n=>e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-surface-hover text-sm text-text flex items-center space-x-2",onClick:()=>r(n.value),children:e.jsx("span",{className:d(s(n.value)&&"text-accent"),children:n.label})},n.value)),t.value&&e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-surface-hover text-sm text-text flex items-center space-x-2 mt-2",onClick:()=>r(null),children:e.jsx("span",{className:"text-text-muted",children:"Clear filter"})})]})]})})})},pe=({data:t,columns:s,loading:r=!1,searchable:n=!1,searchPlaceholder:a="Search...",filters:o=[],paginated:l=!1,pageSizeOptions:u=[10,25,50,100],defaultPageSize:x=10,actions:j=[],onRowClick:m,selectable:f=!1,selectedRows:h=[],onSelectionChange:g,getRowKey:N=(R,U)=>U,emptyContent:p,hoverable:b=!0,bordered:L=!1,striped:$=!1,padding:_="md",className:M,rowClassName:X,headerBackground:W=!0})=>{const[R,U]=i.useState(""),[K,te]=i.useState({column:null,direction:null}),[F,ae]=i.useState({page:0,pageSize:x}),k=i.useRef(null),c=i.useMemo(()=>{let v=t;if(n&&R.trim()){const q=s.filter(J=>J.searchable!==!1),Z=R.toLowerCase();v=v.filter(J=>q.some(O=>{const le=typeof O.accessor=="function"?O.accessor(J):J[O.accessor];return String(le||"").toLowerCase().includes(Z)}))}return o.forEach(q=>{q.value&&q.value!=="all"&&(v=v.filter(Z=>{const J=s.find(le=>le.id===q.id);if(!J)return!0;const O=typeof J.accessor=="function"?J.accessor(Z):Z[J.accessor];return String(O||"")===q.value}))}),v},[t,R,s,n,o]),C=i.useMemo(()=>{if(!K.column||!K.direction)return c;const v=s.find(q=>q.id===K.column);return v?[...c].sort((q,Z)=>{const J=typeof v.accessor=="function"?v.accessor(q):q[v.accessor],O=typeof v.accessor=="function"?v.accessor(Z):Z[v.accessor];let le=0;return J<O?le=-1:J>O&&(le=1),K.direction==="desc"?-le:le}):c},[c,K,s]),y=i.useMemo(()=>{if(!l)return C;const v=F.page*F.pageSize,q=v+F.pageSize;return C.slice(v,q)},[C,F,l]),T=i.useCallback(v=>{s.find(Z=>Z.id===v)?.sortable&&te(Z=>Z.column!==v?{column:v,direction:"asc"}:Z.direction==="asc"?{column:v,direction:"desc"}:{column:null,direction:null})},[s]),w=i.useCallback(v=>{ae(q=>({...q,page:v}))},[]),Q=i.useCallback(v=>{ae({page:0,pageSize:v})},[]),re=i.useCallback((v,q)=>{if(!g)return;const Z=N(v,0);h.map((J,O)=>N(J,O)),g(q?[...h,v]:h.filter((J,O)=>N(h[O],O)!==Z))},[h,g,N]),ne=i.useCallback(v=>{g&&g(v?[...y]:[])},[y,g]);i.useEffect(()=>{ae(v=>({...v,page:0}))},[R,K]),i.useEffect(()=>{ae(v=>({...v,page:0}))},[o.map(v=>v.value).join(",")]);const G=C.length,P=Math.ceil(G/F.pageSize),E=F.page*F.pageSize+1,D=Math.min(E+F.pageSize-1,G),S=y.length>0&&y.every(v=>{const q=N(v,0);return h.some((Z,J)=>N(Z,J)===q)}),V=y.some(v=>{const q=N(v,0);return h.some((Z,J)=>N(Z,J)===q)}),B=d("w-full text-sm leading-5 text-text border-collapse",M),H=W?"bg-surface-sunk border-border border-t":"bg-surface",z=d(H,"h-control-lg"),A=d("text-text border-b border-border p-2"),ee=d("h-row-lg",{"hover:bg-surface-sunk":b,"cursor-pointer":m});return e.jsxs("div",{className:"space-y-4",children:[(n||o.length>0)&&e.jsx("div",{className:"px-4 pt-4 pb-2",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-start",children:[o.map(v=>e.jsx(Ct,{...v},v.id)),e.jsx("div",{className:"w-full sm:w-auto sm:ml-auto min-w-menu",children:e.jsx(ce,{placeholder:a,value:R,onChange:v=>U(v.target.value),startIcon:e.jsx(pt,{}),className:"max-w-sm"})})]})}),e.jsxs("div",{className:"relative w-full overflow-x-auto min-h-100",children:[r&&e.jsx("div",{className:"flex items-center justify-center z-10",children:e.jsx(Te,{showTableSkeleton:!0,tableRows:10,tableColumns:s.length})}),e.jsxs("table",{ref:k,className:d(B,"min-w-full"),children:[e.jsx("thead",{className:z,children:e.jsxs("tr",{children:[f&&e.jsx("th",{className:d(A,"w-12"),children:e.jsx("input",{type:"checkbox",checked:S,ref:v=>{v&&(v.indeterminate=V&&!S)},onChange:v=>ne(v.target.checked),className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),!r&&s.map((v,q)=>e.jsx("th",{className:d(A,"font-semibold text-xs text-text-muted uppercase tracking-label","group",{"text-left":v.align==="left"||!v.align,"text-center":v.align==="center","text-right":v.align==="right","cursor-pointer select-none":v.sortable,[`sticky left-0 ${H}`]:v.sticky==="left",[`sticky right-0 ${H}`]:v.sticky==="right"},q===0&&Ne[_],q===s.length-1&&we[_]),style:{width:v.width},onClick:()=>v.sortable&&T(v.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[v.headerCell?v.headerCell():v.header,v.sortable&&e.jsxs("div",{className:d("flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",K.column===v.id&&"opacity-100"),children:[e.jsx(vt,{active:K.column===v.id&&K.direction==="asc"}),e.jsx(jt,{active:K.column===v.id&&K.direction==="desc"})]})]})},v.id)),j.length>0&&e.jsx("th",{className:d(A,"w-20"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:y.length===0||r?!r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(f?1:0)+(j.length>0?1:0),className:d(A,"text-center py-8 text-text-muted"),children:p||"No data available"})}):y.map((v,q)=>{const Z=N(v,q),J=h.some((O,le)=>N(O,le)===Z);return e.jsxs("tr",{className:d(ee,{"bg-accent-soft":J},X?.(v,q)),onClick:O=>{O.stopPropagation(),m?.(v,q)},children:[f&&e.jsx("td",{className:A,children:e.jsx("input",{type:"checkbox",checked:J,onChange:O=>{O.stopPropagation(),re(v,O.target.checked)},className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),s.map((O,le)=>{const xe=typeof O.accessor=="function"?O.accessor(v):v[O.accessor];return e.jsx("td",{className:d(A,{"text-left":O.align==="left"||!O.align,"text-center":O.align==="center","text-right":O.align==="right","sticky left-0 bg-surface":O.sticky==="left","sticky right-0 bg-surface":O.sticky==="right"},le===0&&Ne[_],le===s.length-1&&we[_]),children:O.cell?O.cell(xe,v,le):String(xe||"")},O.id)}),j.length>0&&e.jsx("td",{className:A,children:e.jsx(Le,{trigger:e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-1 text-sm text-text-muted hover:text-text",children:[e.jsx("span",{children:"Options"}),e.jsx(Ae,{})]}),options:j.map(O=>({value:O.id,label:O.label,icon:O.icon,disabled:O.disabled?.(v)})),onSelect:O=>{const le=j.find(xe=>xe.id===O);le&&le.onClick(v,q)},placement:"bottom-end"})})]},Z)})})]})]}),l&&G>0&&e.jsxs("div",{className:"flex items-center justify-between px-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-text-muted",children:["Showing ",E," to ",D," of ",G," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-text-muted",children:"Rows per page:"}),e.jsx("select",{value:F.pageSize,onChange:v=>Q(Number(v.target.value)),className:"h-control-sm w-16 rounded-md border border-border bg-surface-input px-2 text-sm text-text",children:u.map(v=>e.jsx("option",{value:v,children:v},v))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>w(0),disabled:F.page===0,iconOnly:!0,children:e.jsx(wt,{})}),e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>w(F.page-1),disabled:F.page===0,iconOnly:!0,children:e.jsx(yt,{})}),e.jsxs("span",{className:"px-3 py-1 text-sm text-text-muted",children:["Page ",F.page+1," of ",P]}),e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>w(F.page+1),disabled:F.page>=P-1,iconOnly:!0,children:e.jsx(Nt,{})}),e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>w(P-1),disabled:F.page>=P-1,iconOnly:!0,children:e.jsx(kt,{})})]})]})]})},St=i.createContext(null),Et=({items:t,activeTab:s,onTabChange:r,className:n})=>{const[a,o]=i.useState(t[0]?.id||""),l=s||a,u=x=>{r?r(x):o(x)};return e.jsx("div",{className:d("border-b border-border",n),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(x=>e.jsx("button",{onClick:()=>!x.disabled&&u(x.id),disabled:x.disabled,className:d("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-fast",{"border-accent-border text-text":l===x.id,"border-transparent text-text-muted hover:text-text":l!==x.id&&!x.disabled,"border-transparent text-disabled cursor-not-allowed":x.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[x.label,x.badge&&e.jsx("span",{className:d("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",l===x.id?"bg-accent-soft text-accent":"bg-surface-hover text-text-muted"),children:x.badge})]})},x.id))})})},Re=({items:t,defaultTab:s,activeTab:r,onTabChange:n,variant:a="default",size:o="md",className:l})=>{const[u,x]=i.useState(s||r||t[0]?.id||""),j=r||u,m=p=>{n?n(p):x(p)},f={activeTab:j,setActiveTab:m},h=t.find(p=>p.id===j),g=d("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"},l),N=(p,b)=>{const L="transition-colors duration-fast font-medium",$={"text-xs px-2 py-1":o==="sm","text-sm px-3 py-2":o==="md","text-base px-4 py-3":o==="lg"},_={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},M={"opacity-50 cursor-not-allowed":p.disabled,"cursor-pointer":!p.disabled},X=b?{"border-accent-border text-text":a==="default"||a==="underline","bg-surface text-text shadow-none":a==="pills"}:{},W=!b&&!p.disabled?{"border-transparent text-text-muted hover:text-text":a==="default","text-text-muted hover:text-text":a==="pills","border-transparent text-text-muted hover:text-text hover:border-border":a==="underline"}:{};return d(L,$,_,M,X,W)};return e.jsx(St.Provider,{value:f,children:e.jsxs("div",{children:[e.jsx("div",{className:g,role:"tablist",children:t.map(p=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===p.id,"aria-controls":`tabpanel-${p.id}`,disabled:p.disabled,onClick:()=>!p.disabled&&m(p.id),className:N(p,j===p.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[p.label,p.badge&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-surface-hover text-text-muted",children:p.badge})]})},p.id))}),h?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${j}`,"aria-labelledby":`tab-${j}`,className:"mt-4",children:h.content})]})})},zt={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function je({open:t,onClose:s,title:r,size:n="md",closeOnBackdropClick:a=!0,closeOnEscape:o=!0,className:l,backdropClassName:u,children:x,footer:j,showCloseButton:m=!0}){const f=i.useRef(null),h=i.useRef(null);i.useEffect(()=>{if(!t||!o)return;const N=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[t,o,s]),i.useEffect(()=>(t?(h.current=document.activeElement,f.current&&f.current.focus(),document.body.style.overflow="hidden"):(h.current&&h.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const g=N=>{a&&N.target===N.currentTarget&&s()};return t?e.jsx("div",{className:d("fixed inset-0 z-modal flex items-center justify-center p-4","bg-scrim",u),onClick:g,children:e.jsxs("div",{ref:f,className:d("relative w-full bg-surface rounded-lg shadow-modal","focus:outline-none",zt[n],l),role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,tabIndex:-1,children:[(r||m)&&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}),m&&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:I.X,size:"lg",color:"current"})})]}),e.jsx("div",{className:"p-6",children:x}),j&&e.jsx("div",{className:"px-6 py-4",children:j})]})}):null}const Mt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Dt={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},$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",current:"text-current",muted:"text-text-subtle"},Tt={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"},Lt={tight:"leading-tight",normal:"leading-normal",relaxed:"leading-relaxed"},oe=({variant:t="body",size:s="md",weight:r="normal",color:n="current",align:a="left",truncate:o=!1,italic:l=!1,underline:u=!1,lineHeight:x="normal",as:j,className:m,children:f,...h})=>{const g=j||At(t),N=t==="caption",p=t==="label",b=t==="code",L=d("font-sans",N&&"text-xs text-text-subtle",p&&"text-xs font-semibold uppercase tracking-label text-text-subtle",b&&"font-mono text-sm rounded-sm bg-surface-hover px-1 py-0.5",!N&&!p&&!b&&Mt[s],!p&&Dt[r],$t[n],Tt[a],t==="body"&&Lt[x],l&&"italic",u&&"underline",o&&"truncate",m);return e.jsx(g,{className:L,...h,children:f})};function At(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Ie=({value:t,onChange:s,label:r,placeholder:n="Select or upload a file",error:a,disabled:o,accept:l,onListFiles:u,onListMounts:x,onUploadFile:j,onDownloadFile:m,onRegisterFile:f})=>{const[h,g]=i.useState(!1),[N,p]=i.useState([]),[b,L]=i.useState(null),[$,_]=i.useState("/"),[M,X]=i.useState([]),[W,R]=i.useState(!1),[U,K]=i.useState(""),[te,F]=i.useState(typeof t=="object"?t:null),[ae,k]=i.useState(!1),[c,C]=i.useState(""),y=i.useRef(null);i.useEffect(()=>{h&&T()},[h]),i.useEffect(()=>{h&&b&&w()},[h,b,$,U]);const T=async()=>{R(!0);try{const z=await x?.();z?.data&&p(z.data)}catch(z){console.error("Failed to load mounts",z)}finally{R(!1)}},w=async()=>{if(b){R(!0);try{const z=await u?.({mountId:b.id,name:U,path:$});z?.data&&X(z.data)}catch(z){console.error("Failed to load files",z)}finally{R(!1)}}},Q=async z=>{const A=z.target.files?.[0];if(A){R(!0);try{const ee=await A.arrayBuffer(),v=new Uint8Array(ee),q={id:`local-${Date.now()}`,name:A.name,type:"file",path:"/",mimeType:A.type||"application/octet-stream",size:A.size,mountId:"local",providerKey:A.name,ownerId:"me"};F(q),s(q,v),g(!1)}catch(ee){console.error("Local file selection failed",ee)}finally{R(!1)}}},re=async z=>{const A=z.target.files?.[0];if(!(!A||!b)){R(!0);try{const ee=await A.arrayBuffer(),v=await j?.({file:new Uint8Array(ee),filename:A.name,mimeType:A.type||"application/octet-stream",mountId:b.id,path:$});if(v?.data){const q=v.data;F(q),s(q,new Uint8Array(ee)),g(!1)}}catch(ee){console.error("Upload failed",ee)}finally{R(!1)}}},ne=async()=>{if(!(!c||!b)){R(!0);try{const z=`${$}${c}/`;f&&(await f({name:c,type:"folder",path:$,mimeType:"application/x-directory",size:0,mountId:b.id,providerKey:z,ownerId:"me"}),await w()),k(!1),C("")}catch(z){console.error("Failed to create folder",z)}finally{R(!1)}}},G=async z=>{R(!0);try{const A=await m?.(z.id);F(z),s(z,A),g(!1)}catch(A){console.error("Failed to download file",A)}finally{R(!1)}},P=z=>{z.stopPropagation(),F(null),s(null)},E=i.useMemo(()=>{const z=new Set,A=[];return M.forEach(ee=>{if(ee.type==="folder"){ee.path===$&&z.add(ee.name);return}const v=ee.providerKey||ee.name,Z=($?v.substring($.length):v).split("/").filter(J=>J!=="");Z.length>1?z.add(Z[0]):Z.length===1&&A.push(ee)}),{folders:Array.from(z).sort(),files:A.sort((ee,v)=>ee.name.localeCompare(v.name))}},[M,$]),D=z=>{_(A=>`${A}${z}/`)},S=()=>{const z=$.split("/").filter(A=>A!=="");z.pop(),z.length===0?_("/"):_(`${z.join("/")}/`)},V=i.useMemo(()=>{const z=E.folders.map(A=>({id:`folder-${A}`,name:A,type:"folder"}));return E.files.forEach(A=>{z.push({...A,type:"file"})}),z},[E]),B=[{id:"name",header:"Name",accessor:"name",cell:(z,A)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{icon:A.type==="folder"?I.Folder:I.FileText,size:"sm",color:A.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:d(A.type==="folder"&&"font-medium"),children:z})]})},{id:"type",header:"Type",accessor:z=>z.type==="folder"?"Folder":z.mimeType},{id:"size",header:"Size",accessor:z=>z.type==="file"?`${(z.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(z,A)=>e.jsx(se,{size:"sm",variant:"outline",onClick:ee=>{ee.stopPropagation(),A.type==="folder"?D(A.name):G(A)},loading:W&&A.type==="file"&&te?.id===A.id,children:A.type==="folder"?"Open":"Select"})}],H=[{id:"name",header:"Mount Name",accessor:"name",cell:z=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Y,{icon:I.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:z})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(z,A)=>e.jsx(se,{size:"sm",variant:"outline",onClick:()=>L(A),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx(oe,{variant:"label",size:"sm",weight:"medium",children:r}),e.jsxs("div",{onClick:()=>!o&&g(!0),className:d("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",o&&"opacity-50 cursor-not-allowed bg-surface-sunk"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Y,{icon:te?I.FileText:I.HardDrive,color:te?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:te?e.jsx("span",{className:"text-sm text-text font-medium",children:te.name}):e.jsx("span",{className:"text-sm text-text-muted",children:n})}),te&&!o&&e.jsx("button",{onClick:P,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(Y,{icon:I.X,size:"xs"})})]}),a&&e.jsx(oe,{variant:"body",size:"xs",className:"text-danger-fg",children:a}),e.jsx(je,{open:h,onClose:()=>{g(!1),L(null),_("/"),k(!1)},title:b?`Explorer: ${b.name}`:"Select Storage Mount",size:"lg",children:e.jsx(Re,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>{$&&$!=="/"?S():L(null)},leftIcon:e.jsx(Y,{icon:I.ArrowLeft,size:"xs"}),children:$?"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.jsx("div",{className:"flex-grow min-w-40",children:e.jsx(ce,{placeholder:"Search...",value:U,onChange:z=>K(z.target.value),startIcon:e.jsx(I.Search,{size:14}),fullWidth:!0,size:"sm"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:()=>k(!0),leftIcon:e.jsx(Y,{icon:I.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(se,{variant:"primary",size:"sm",onClick:()=>y.current?.click(),leftIcon:e.jsx(Y,{icon:I.Upload,size:"xs"}),loading:W,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:y,onChange:re,accept:l})]})]}),ae&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-surface-sunk rounded-lg border border-border",children:[e.jsx(Y,{icon:I.Folder,size:"sm",color:"warning"}),e.jsx(ce,{size:"sm",placeholder:"Folder name",value:c,onChange:z=>C(z.target.value),autoFocus:!0}),e.jsx(se,{size:"sm",onClick:ne,loading:W,children:"Create"}),e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>k(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(pe,{data:V,columns:B,loading:W,emptyContent:"This folder is empty",onRowClick:z=>z.type==="folder"?D(z.name):G(z)})})]}):e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(pe,{data:N,columns:H,loading:W,emptyContent:"No storage mounts configured",onRowClick:z=>L(z)})})})},{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:I.FileText,size:"xl",color:"primary"})}),e.jsx(oe,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(oe,{variant:"body",size:"sm",className:"text-text-muted mt-1 mb-6 text-center max-w-xs",children:["This file will be used directly in the form and will ",e.jsx("strong",{children:"not"})," be uploaded to platform storage."]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(se,{variant:"primary",size:"lg",loading:W,className:"pointer-events-none",children:"Browse Local File"}),e.jsx("input",{type:"file",className:"hidden",onChange:Q,accept:l,disabled:W})]})]})})}]})})]})},Rt={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"},he=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,loading:o=!1,containerClassName:l,labelClassName:u,className:x,id:j,rows:m=4,...f},h)=>{const g=i.useId(),N=j||`textarea-${g}`,p=!!r,b=r||s?`${N}-description`:void 0;return e.jsxs("div",{className:d("flex flex-col",a&&"w-full",l),children:[t&&e.jsx("label",{htmlFor:N,className:d(ze,p?"text-danger-fg":"text-text-subtle",u),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:h,id:N,rows:m,"aria-invalid":p||void 0,"aria-describedby":b,className:d("block w-full resize-y rounded-md 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",Rt[n],p?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",x),...f}),o&&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:b,className:d("mt-1 text-xs",p?"text-danger-fg":"text-text-subtle"),children:r||s})]})});he.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 It(t,s,r){const n=s.split("."),a=Array.isArray(t)?[...t]:{...t};let o=a;for(let l=0;l<n.length-1;l++){const u=n[l],x=o[u];o[u]=x&&typeof x=="object"?Array.isArray(x)?[...x]:{...x}:{},o=o[u]}return o[n[n.length-1]]=r,a}function Pt(t,s){const r=s.split("."),n=Array.isArray(t)?[...t]:{...t};let a=n;for(let o=0;o<r.length-1;o++){const l=r[o];if(!a[l]||typeof a[l]!="object")return n;a[l]=Array.isArray(a[l])?[...a[l]]:{...a[l]},a=a[l]}return delete a[r[r.length-1]],n}const Ft=({groups:t,data:s,onSubmit:r,onCancel:n,onChange:a,transform:o,validate:l,submitButton:u={label:"Submit",variant:"primary"},cancelButton:x={label:"Cancel",variant:"outline"},showButtons:j=!0,layout:m="vertical",size:f="md",loading:h=!1,className:g,ref:N,sdk:p})=>{const[b,L]=i.useState(s||{}),[$,_]=i.useState({}),[M,X]=i.useState({});i.useEffect(()=>{s&&L({...s})},[s]);const W=i.useCallback((k,c,C)=>{const y=t.flatMap(T=>T.items).find(T=>T.name===k);if(!y)return null;if(y.required&&(c==null||c===""))return`${y.label} is required`;if(y.type==="array"){if(y.required&&(!c||c.length===0))return`${y.label} cannot be empty.`;if(c&&!Array.isArray(c))return`${y.label} must be an array.`;if(Array.isArray(c)&&y.arrayFields){const T=[];let w=!1;if(c.forEach((Q,re)=>{const ne={};for(const G of y.arrayFields){const P=Q?.[G.name];if(G.required&&(P==null||P===""))ne[G.name]=`${G.label} is required`,w=!0;else if(G.validator){const E=G.validator(P,Q);E&&(ne[G.name]=E,w=!0)}}T[re]=ne}),w)return JSON.stringify(T)}}return y.validator?y.validator(c,C):null},[t]),R=i.useCallback((k,c)=>{let C=It(b,k,c);t.flatMap(w=>w.items).find(w=>w.name===k)?.removeIfEmpty&&(c==null||c==="")&&(C=Pt(C,k)),L(C),X(w=>({...w,[k]:!0}));const T=W(k,c,C);_(w=>({...w,[k]:T||""})),a?.(C,k)},[b,t,W,a]),U=i.useCallback(async k=>{if(k.preventDefault(),h)return;const c={},C=t.flatMap(T=>T.items);for(const T of C){if(T.hidden||T.conditional&&!T.conditional(b))continue;const w=W(T.name,ke(b,T.name),b);w&&(c[T.name]=w)}if(l){const T=l(b);T&&Object.assign(c,T)}if(_(c),Object.keys(c).some(T=>c[T]))return;const y=o?o(b):b;await r?.(b,y)},[b,t,W,l,o,r,h]),K=i.useCallback(k=>{const c=ke(b,k.name),C=M[k.name]?$[k.name]:void 0,y=k.disabled||h,T={value:c||"",disabled:y,required:k.required,placeholder:k.placeholder,...k.fieldProps};switch(k.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ce,{...T,onChange:w=>R(k.name,w.target.value),type:k.textType||k.type,autoComplete:k.autocomplete,error:C,size:f});case"textarea":return e.jsx(he,{...T,onChange:w=>R(k.name,w.target.value),rows:4,error:C,size:f});case"select":return e.jsx(ue,{...T,onChange:w=>R(k.name,w),options:(k.options||[]).map(w=>({...w,value:String(w.value)})),searchable:k.searchable,multiple:k.multiple,allowCreate:k.allowCreate,error:C,size:f});case"checkbox":return e.jsx(de,{...T,label:k.label,checked:!!c,onChange:w=>R(k.name,w.target.checked),size:f});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:k.options?.map(w=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 text-base text-text",children:[e.jsx("input",{type:"radio",name:k.name,value:w.value,checked:c===w.value,onChange:()=>R(k.name,w.value),disabled:y||w.disabled,className:"size-checkbox shrink-0 border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),w.label]},w.value))});case"date":return e.jsx(me,{...T,value:c?new Date(c):null,onChange:w=>R(k.name,w),size:f});case"file":return e.jsx(Ie,{...T,value:c,onChange:w=>R(k.name,w),error:C,onListFiles:w=>p?.http.invoke({method:"POST",action:"storage.file.list",body:w}),onListMounts:()=>p?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:w=>p?.http.invoke({method:"POST",action:"storage.file.upload",body:w}),onDownloadFile:w=>p?.http.invoke({method:"GET",action:`storage.file.${w}.download`}),onRegisterFile:w=>p?.http.invoke({method:"POST",action:"storage.file.folder",body:w})});case"folder":return e.jsx(Me,{value:c||{},onChange:w=>R(k.name,w),onListFolders:()=>p?.http.invoke({method:"GET",action:"storage.mount"}),disabled:y,size:f,placeholder:k.placeholder});case"custom":return k.customComponent?.({value:c,onChange:w=>R(k.name,w),error:C,disabled:y});case"array":{const w=c||[];let Q=[];if(typeof C=="string"&&C.startsWith("["))try{Q=JSON.parse(C)}catch{}const re=()=>{R(k.name,[...w,{}])},ne=P=>{R(k.name,w.filter((E,D)=>D!==P))},G=(P,E,D)=>{const S=[...w];S[P]={...S[P],[E]:D},R(k.name,S)};return e.jsxs("div",{className:"flex flex-col gap-2",children:[w.map((P,E)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"grid flex-1 gap-2 sm:grid-cols-2",children:k.arrayFields?.map(D=>{const S=Q?.[E]?.[D.name];return e.jsxs("div",{className:"flex flex-col gap-1",children:[E===0&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[D.label,D.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),(()=>{const V={value:P?.[D.name]||"",disabled:y,required:D.required,placeholder:D.placeholder,...D.fieldProps};switch(D.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ce,{...V,onChange:B=>G(E,D.name,B.target.value),type:D.textType||D.type,autoComplete:D.autocomplete,error:S,size:f});case"textarea":return e.jsx(he,{...V,onChange:B=>G(E,D.name,B.target.value),rows:4,error:S,size:f});case"select":return e.jsx(ue,{...V,onChange:B=>G(E,D.name,B),options:(D.options||[]).map(B=>({...B,value:String(B.value)})),searchable:D.searchable,multiple:D.multiple,allowCreate:D.allowCreate,error:S,size:f});case"checkbox":return e.jsx(de,{...V,checked:!!P?.[D.name],onChange:B=>G(E,D.name,B.target.checked),size:f});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:D.options?.map(B=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:`${k.name}.${E}.${D.name}`,value:B.value,checked:P?.[D.name]===B.value,onChange:()=>G(E,D.name,B.value),disabled:y||B.disabled,className:"size-checkbox shrink-0 border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),B.label]},B.value))});case"date":{const B=P?.[D.name];return e.jsx(me,{...V,value:B?new Date(B):null,onChange:H=>G(E,D.name,H),size:f})}case"custom":return D.customComponent?.({value:P?.[D.name],onChange:B=>G(E,D.name,B),error:S,disabled:y});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",D.type]})}})(),S&&e.jsx("p",{className:"text-xs text-danger-fg",children:S})]},D.name)})}),e.jsx(se,{type:"button",iconOnly:!0,variant:"ghost",size:"md","aria-label":`${k.label} verwijderen`,onClick:()=>ne(E),disabled:y,className:d("shrink-0",E===0&&"mt-5"),children:e.jsx(I.Trash2,{className:"size-icon-md"})})]},E)),e.jsxs(se,{type:"button",variant:"secondary",size:"sm",leftIcon:e.jsx(I.Plus,{className:"size-icon-sm"}),onClick:re,disabled:y,children:[k.label," toevoegen"]})]})}default:return null}},[b,M,$,h,f,R]),te=i.useCallback(k=>{if(k.conditional&&!k.conditional(b))return null;const c=k.items.filter(y=>!(y.hidden||y.conditional&&!y.conditional(b)));if(c.length===0)return null;const C=d(k.layout==="flex"?"flex flex-wrap gap-3":"grid gap-3",k.layout!=="flex"&&{"grid-cols-1":!k.columns||k.columns===1,"grid-cols-2":k.columns===2,"grid-cols-3":k.columns===3,"grid-cols-4":k.columns===4},k.className);return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4 not-first:border-t not-first:border-border-subtle sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"w-full shrink-0 sm:w-form-label",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:k.title}),k.description&&e.jsx("p",{className:"mt-1 text-xs leading-4 text-text-subtle",children:k.description})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:C,children:c.map(y=>(M[y.name]&&$[y.name],e.jsxs("div",{className:d("flex min-w-0 flex-col gap-1.5",y.type==="checkbox"&&"justify-center"),style:{width:typeof y.width=="string"?y.width:void 0,gridColumn:typeof y.width=="number"?`span ${y.width} / span ${y.width}`:void 0},children:[y.type!=="custom"&&y.type!=="checkbox"&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[y.label,y.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),K(y)]},y.name)))})})]},k.id)},[b,M,$,K]),F=d("overflow-hidden rounded-lg border border-border bg-surface",{"max-w-md":f==="sm","max-w-2xl":f==="md","max-w-4xl":f==="lg","max-w-full":f==="full"},g),ae=f==="full"?"md":f;return e.jsxs("form",{ref:N,onSubmit:U,className:F,children:[!j&&e.jsx("button",{type:"submit",className:"hidden",tabIndex:-1,"aria-hidden":!0}),e.jsx("div",{className:"flex flex-col",children:t.map(te)}),e.jsx("div",{className:"flex items-center gap-2 border-t border-border-subtle bg-surface-sunk px-5 py-3",children:j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ml-auto"}),n&&e.jsx(se,{type:"button",variant:x.variant??"ghost",size:x.size||ae,disabled:x.disabled||h,onClick:n,className:x.className,children:x.label}),e.jsx(se,{type:"submit",variant:u.variant,size:u.size||ae,disabled:u.disabled||h,loading:h,className:u.className,children:u.label})]})})]})};function Ot({open:t,title:s,description:r,confirmLabel:n="Bevestigen",cancelLabel:a="Annuleren",tone:o="default",loading:l=!1,onConfirm:u,onCancel:x}){return e.jsx(je,{open:t,onClose:x,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:x,disabled:l,children:a}),e.jsx(se,{variant:o==="danger"?"destructive":"primary",onClick:u,loading:l,children:n})]}),children:r&&e.jsx(oe,{color:"secondary",children:r})})}const Bt={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"},Vt={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},Ht={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 qt({variant:t="default",size:s="md",dot:r=!1,icon:n,dismissible:a=!1,onDismiss:o,className:l,children:u,...x}){return e.jsxs("span",{className:d("inline-flex items-center font-medium rounded-full",Bt[t],Vt[s],l),...x,children:[r&&e.jsx("span",{className:d("w-2 h-2 rounded-full mr-1.5",Ht[t])}),n&&e.jsx("span",{className:d("flex-shrink-0",u&&"mr-1"),children:n}),u,a&&o&&e.jsx("button",{onClick:o,className:"ml-1.5 flex-shrink-0 hover:opacity-70 transition-opacity","aria-label":"Remove badge",children:e.jsx(Y,{icon:I.X,size:"xs",color:"current"})})]})}const Ut={neutral:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg"};function Wt({icon:t,tone:s="neutral",title:r,description:n,actions:a,card:o=!1,className:l,...u}){return e.jsxs("div",{className:d("flex flex-col items-center gap-2.5 text-center",o&&"rounded-lg border border-border bg-surface px-11 py-9 shadow-overlay",l),...u,children:[t!=null&&e.jsx("span",{className:d("flex size-disc items-center justify-center rounded-full text-2xl",Ut[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 Kt({children:t,className:s,...r}){return e.jsx("kbd",{className:d("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 _t={sm:"h-1",md:"h-1.5"},Gt={accent:"bg-accent",success:"bg-success"};function Jt({value:t,variant:s="accent",size:r="md",className:n,...a}){const o=Math.max(0,Math.min(100,t));return e.jsx("div",{role:"progressbar","aria-valuenow":Math.round(o),"aria-valuemin":0,"aria-valuemax":100,className:d("w-full overflow-hidden rounded-full bg-surface-hover",_t[r],n),...a,children:e.jsx("div",{className:d("h-full rounded-full transition-[width] duration-300 ease-out",Gt[s]),style:{width:`${o}%`}})})}const Yt={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"},Xt={primary:"text-accent",secondary:"text-text-muted",white:"text-white",current:"text-current"},Zt={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function Qt({size:t="md",variant:s="primary",label:r="Loading...",showLabel:n=!1,className:a,...o}){return e.jsxs("div",{className:d("inline-flex items-center",n?"flex-col space-y-2":"",a),...o,children:[e.jsxs("svg",{className:d("animate-spin",Yt[t],Xt[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:d("text-text-muted",Zt[t]),children:r}),!n&&e.jsx("span",{className:"sr-only",children:r})]})}const es={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 ts({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:d("inline-block size-dot shrink-0",s==="round"?"rounded-full":"rounded-sm",es[t],r&&"animate-pulse",a)})}function ss({steps:t,current:s,variant:r="numbered",label:n,className:a}){const o=t.indexOf(s),l={role:n?"group":void 0,"aria-label":n,"aria-hidden":n?void 0:!0};return r==="dots"?e.jsx("div",{...l,className:d("flex items-center gap-1.5",a),children:t.map((u,x)=>e.jsx("span",{className:d("h-step-bar rounded-full transition-all duration-fast ease-out",x===o?"w-5 bg-accent":"w-3.5",x<o&&"bg-border-strong",x>o&&"bg-border")},u))}):e.jsx("div",{...l,className:d("flex items-center gap-2",a),children:t.map((u,x)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-current":x===o?"step":void 0,className:d("flex size-tile-sm items-center justify-center rounded-full text-xs font-medium",x===o&&"bg-accent text-accent-fg",x<o&&"bg-accent-soft text-accent",x>o&&"bg-surface-hover text-text-muted"),children:x+1}),x<t.length-1&&e.jsx("span",{className:"h-px w-8 bg-border-strong"})]},u))})}function rs({title:t,icon:s=e.jsx(I.Sparkles,{className:"size-icon-md","aria-hidden":!0}),action:r,children:n,className:a,...o}){return e.jsxs("div",{className:d("flex flex-col gap-2 rounded-xl border p-4","border-assistant-border bg-assistant-soft",a),...o,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 ns={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 as(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,size:r="sm",className:n,title:a})=>{const[o,l]=i.useState(!1),u=d("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none bg-surface-hover text-text",ns[r],n);return s&&!o?e.jsx("img",{src:s,alt:t??"",title:a??t,className:d(u,"object-cover"),onError:()=>l(!0)}):e.jsx("span",{className:u,title:a??t,"aria-label":t,children:as(t)})},Ce="ring-surface",ls="ring-surface-accent",os=({people:t,max:s=4,size:r="sm",className:n})=>{if(t.length===0)return null;const a=t.slice(0,s),o=t.length-a.length;return e.jsxs("span",{className:d("inline-flex items-center",n),children:[a.map((l,u)=>e.jsx(Pe,{name:l.name,src:l.src,size:r,title:l.name?l.seen===!1?`${l.name} — nog niet gelezen`:l.name:void 0,className:d(u>0&&"-ml-2",l.owner?ls:Ce,l.seen===!1&&"opacity-40")},l.id??`${l.name}-${u}`)),o>0&&e.jsxs("span",{className:d("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-surface-hover text-text-muted",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",Ce),children:["+",o]})]})},Se={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"}},cs={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 is({channel:t,children:s,size:r="md",className:n,title:a}){const o=Se[t in Se?t:"note"];return e.jsx("span",{title:a,className:d("inline-flex shrink-0 items-center justify-center font-bold",cs[r],o.fg,o.bg,n),children:s})}const ds=({src:t,alt:s,size:r="md",aspectRatio:n="auto",radius:a="md",showLoading:o=!0,showError:l=!0,fallback:u,loadingContent:x,errorContent:j,className:m,onLoad:f,onError:h,...g})=>{const[N,p]=i.useState(!0),[b,L]=i.useState(!1),[$,_]=i.useState(t),M=F=>{p(!1),L(!1),f?.(F)},X=F=>{if(p(!1),L(!0),u&&$!==u){_(u),L(!1),p(!0);return}h?.(F)},W=d("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"},m),R=d("w-full h-full object-cover transition-opacity duration-fast",{"opacity-0":N||b,"opacity-100":!N&&!b}),U=d("absolute inset-0 flex items-center justify-center","text-text-muted"),K=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-surface-hover rounded"})}),te=e.jsxs("div",{className:"text-center",children:[e.jsx(Y,{icon:I.ImageOff,size:"lg",className:"mx-auto mb-1"}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:W,children:[e.jsx("img",{...g,src:$,alt:s,className:R,onLoad:M,onError:X}),N&&o&&e.jsx("div",{className:U,children:x||K}),b&&l&&e.jsx("div",{className:U,children:j||te})]})};function us({items:t,getRowKey:s,variant:r="divided",leading:n,renderItem:a,trailing:o,onSelect:l,onActiveIndexChange:u,isActive:x,unread:j,dimmed:m,groupBy:f,groups:h,renderGroupHeader:g,stickyGroupHeaders:N=!1,collapsibleGroups:p=!1,hideGroupCount:b=!1,selectable:L=!1,selectedItems:$=[],onSelectionChange:_,bulkActions:M,header:X,stickyHeader:W=!1,bordered:R=!1,emptyContent:U,loading:K=!1,loadingRows:te=4,className:F,"aria-label":ae}){const[k,c]=i.useState(()=>Object.fromEntries((h??[]).filter(S=>S.defaultCollapsed).map(S=>[S.id,!0]))),C=i.useRef(null),y=S=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(S.key))return;const B=Array.from(C.current?.querySelectorAll("li[data-list-row]")??[]);if(B.length===0)return;S.preventDefault();const H=B.indexOf(document.activeElement),z=S.key==="Home"?0:S.key==="End"?B.length-1:S.key==="ArrowDown"?(H+1)%B.length:(H-1+B.length)%B.length;B[z]?.focus()},T=(S,V)=>s?s(S,V):V,w=S=>$.includes(S),Q=(S,V)=>{_&&_(V?[...$,S]:$.filter(B=>B!==S))},re=S=>_?.(S?[...t]:[]),ne=d("flex flex-col",R&&"overflow-hidden rounded-lg border border-border-subtle",F);if(K)return e.jsx("div",{className:ne,children:Array.from({length:te}).map((S,V)=>e.jsxs("div",{className:d("flex animate-pulse items-center gap-3 px-4 py-2",r==="divided"&&V>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-${V}`))});if(t.length===0&&U)return e.jsx("div",{className:ne,children:U});const G=t.length>0&&$.length===t.length,P=$.length>0&&!G,E=(S,V,B)=>{const H=x?.(S,V)??!1,z=j?.(S,V)??!1,A=m?.(S,V)??!1,ee=L&&w(S);return e.jsxs("li",{...l?{role:"button",tabIndex:0,"data-list-row":"","aria-current":H||void 0,onClick:()=>l(S,V),onFocus:()=>u?.(V),onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),l(S,V))}}:{},className:d("flex items-center gap-3 px-4 py-2 text-base","transition-colors duration-fast ease-out",r==="divided"&&!B&&"border-t border-border-subtle",l&&"cursor-pointer focus-visible:outline-none focus-visible:focus-ring",H||ee?"bg-accent-soft text-text":l&&"hover:bg-surface-hover",z&&"font-bold",A&&"opacity-55"),children:[L&&e.jsx("span",{onClick:v=>v.stopPropagation(),children:e.jsx(de,{checked:w(S),onChange:v=>Q(S,v.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(S,V)}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:a?a(S,V):String(S)}),o&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:o(S,V)})]},T(S,V))},D=(()=>{if(!f)return t.map((H,z)=>E(H,z,z===0));const S=new Map;t.forEach((H,z)=>{const A=f(H,z);S.has(A)||S.set(A,[]),S.get(A).push({item:H,index:z})});const V=h??[];return[...V.filter(H=>S.has(H.id)),...[...S.keys()].filter(H=>!V.some(z=>z.id===H)).map(H=>({id:H}))].flatMap((H,z)=>{const A=S.get(H.id)??[],ee=p&&k[H.id],v=H.title??H.id,q=H.count??A.length,Z=e.jsx("li",{onClick:p?()=>c(J=>({...J,[H.id]:!J[H.id]})):void 0,className:d("flex items-center gap-2 bg-surface-sunk px-4 py-1.5","text-xs font-semibold uppercase tracking-label text-text-subtle","border-border-subtle",z>0&&"border-t","border-b",N&&"sticky z-10",p&&"cursor-pointer select-none hover:text-text"),"aria-expanded":p?!ee:void 0,style:N?{top:W?28:0}:void 0,children:g?g(H,A.map(J=>J.item)):e.jsxs(e.Fragment,{children:[p&&e.jsx(I.ChevronRight,{"aria-hidden":!0,className:d("size-icon-sm shrink-0 transition-transform duration-fast ease-out",!ee&&"rotate-90")}),e.jsx("span",{children:v}),!b&&e.jsx("span",{className:"ml-auto font-normal tabular-nums",children:q})]})},`group-${H.id}`);return ee?[Z]:[Z,...A.map(({item:J,index:O},le)=>E(J,O,le===0))]})})();return e.jsxs("div",{ref:C,className:ne,onKeyDown:l?y:void 0,children:[L&&$.length>0&&e.jsxs("div",{className:"flex items-center gap-3 border-b border-border-subtle bg-surface-sunk px-4 py-2",children:[e.jsx(de,{checked:G,indeterminate:P,onChange:S=>re(S.target.checked),"aria-label":"Alles selecteren"}),e.jsxs("span",{className:"text-xs text-text-subtle",children:[$.length," geselecteerd"]}),M&&e.jsx("div",{className:"ml-auto flex gap-2",children:M})]}),X&&e.jsx("div",{className:d("flex items-center gap-3 border-b border-border-subtle px-4 py-1.5","text-xs font-semibold uppercase tracking-label text-text-subtle",W&&"sticky top-0 z-20"),children:X}),e.jsx("ul",{"aria-label":ae,className:"flex flex-col",children:D})]})}function xs({side:t,continued:s=!1,tone:r="default",className:n,children:a}){return e.jsx("div",{className:d("min-w-0 max-w-bubble md:max-w-bubble-md shadow-sm",t==="out"?"rounded-lg rounded-tr-sm":"rounded-lg rounded-tl-sm",r==="note"?"bg-note-soft":"bg-surface",s&&"mt-1",n),children:a})}const fs={default:"text-text",urgent:"text-danger-fg",success:"text-success-fg"};function ms({value:t,label:s,tone:r="default",className:n,...a}){return e.jsxs("div",{className:d("rounded-xl shadow-sm bg-surface px-4 py-3.5",n),...a,children:[e.jsx("div",{className:d("text-2xl font-semibold",fs[r]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:s})]})}const hs=({surface:t=!1,title:s,subtitle:r,meta:n,actions:a=[],children:o,className:l,backLabel:u="Back",backClassName:x,onBack:j,editable:m=!1,onTitleChange:f})=>{const[h,g]=i.useState(!1),[N,p]=i.useState(s),b=i.useRef(null);i.useEffect(()=>{p(s)},[s]),i.useEffect(()=>{h&&b.current&&(b.current.focus(),b.current.select())},[h]);const L=()=>{m&&g(!0)},$=()=>{g(!1),N.trim()!==""&&N!==s&&f?f(N.trim()):p(s)},_=M=>{M.key==="Enter"?b.current?.blur():M.key==="Escape"&&(p(s),g(!1))};return e.jsxs("div",{className:d("p-5 pb-3",t&&"bg-surface border-b border-border",l),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:[j&&e.jsx(se,{variant:"outline",onClick:j,leftIcon:e.jsx(Y,{icon:I.ChevronLeft,size:"sm"}),iconOnly:!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[h?e.jsx("input",{ref:b,type:"text",value:N,onChange:M=>p(M.target.value),onBlur:$,onKeyDown:_,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:L,className:d("text-xl font-semibold truncate",m&&"cursor-pointer"),title:m?"Click to edit":void 0,children:s}),r&&e.jsx("span",{className:"shrink-0 text-base text-text-muted truncate",children:r}),m&&e.jsx(I.Pencil,{size:15,onClick:L,className:"shrink-0 cursor-pointer text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]}),n&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:n})]})]})}),a.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:a.map(M=>M.render?e.jsx(i.Fragment,{children:M.render()},M.id):M.splitOptions&&M.splitOptions.length>0?e.jsx(ve,{label:M.label,onClick:M.onClick,icon:M.icon,variant:M.variant==="primary"?"primary":"outline",options:M.splitOptions,disabled:M.disabled},M.id):e.jsx(se,{variant:M.variant??"secondary",onClick:X=>{X.stopPropagation(),X.target.blur(),M.onClick()},disabled:M.disabled,leftIcon:M.icon,children:M.label},M.id))})]}),o&&e.jsx("div",{className:"mt-4",children:o})]})},bs={none:"p-0",sm:"p-2",md:"p-4",lg:"p-6"},gs=({actions:t=[],onBack:s,backLabel:r="Back",className:n,padding:a="md",children:o})=>e.jsxs("div",{className:d("flex items-center gap-2 mb-3",bs[a],n),children:[s&&e.jsx(se,{variant:"secondary",onClick:s,leftIcon:e.jsx(Y,{icon:I.ChevronLeft,size:"sm"}),iconOnly:!0}),o&&e.jsx("div",{className:"flex-1 min-w-0",children:o}),t.length>0&&e.jsx("div",{className:d("flex flex-wrap gap-4",!o&&"ml-auto"),children:t.map(l=>l.splitOptions&&l.splitOptions.length>0?e.jsx(ve,{label:l.label,onClick:l.onClick,icon:l.icon,variant:l.variant==="primary"?"primary":"secondary",options:l.splitOptions,disabled:l.disabled},l.id):e.jsx(se,{variant:l.variant??"secondary",size:"sm",onClick:u=>{u.stopPropagation(),u.target.blur(),l.onClick()},disabled:l.disabled,leftIcon:l.icon,children:l.label},l.id))})]});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:d("flex items-center py-2",n),children:a}):e.jsxs("div",{className:d("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})]})}function vs({label:t,description:s,control:r,bordered:n=!1,disabled:a=!1,className:o}){return e.jsxs("div",{className:d("flex items-center justify-between gap-4 py-2",n&&"rounded-lg border border-border px-3",a&&"opacity-50",o),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 js({icon:t,title:s,description:r,actions:n,children:a,className:o}){return e.jsxs("section",{className:d("flex flex-col gap-2",o),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:d("flex flex-col",t&&"pl-6"),children:a})]})}function ys({label:t,dotColor:s,onClick:r,className:n}){return e.jsxs("button",{type:"button",onClick:r,className:d("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:I.ArrowUpRight,size:"xs",className:"opacity-70"})]})}function Ns(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}const ws=({groups:t,data:s,size:r="md",className:n})=>{const a=m=>{if(!m)return"-";try{return new Date(m).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(m)}},o=m=>m?"Ja":"Nee",l=(m,f)=>{if(!f)return String(m||"-");const h=f.find(g=>g.value===m);return h?h.label:String(m||"-")},u=i.useCallback(m=>{const f=Ns(s,m.name);if(m.type==="array"){const g=f;return!g||g.length===0?e.jsx(oe,{variant:"body",size:"sm",className:"text-text-muted",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:g.map((N,p)=>e.jsxs("div",{className:"p-4 border border-border rounded-xl space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(oe,{variant:"label",size:"sm",weight:"medium",className:"text-text-muted",children:[m.label," ",p+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:m.arrayFields?.map(b=>{const L=N?.[b.name];let $="-";switch(b.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":$=L||"-";break;case"select":case"radio":$=l(L,b.options);break;case"checkbox":$=o(L);break;case"date":$=a(L);break;case"custom":$=b.customComponent?.({value:L});break;default:$=String(L||"-")}return b.format&&($=b.format(L,N)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(oe,{variant:"label",size:"xs",className:"text-text-muted",children:b.label}),e.jsx(oe,{variant:"body",size:"sm",className:"text-text",children:$})]},b.name)})})]},p))})}if(m.type==="custom"&&m.customComponent)return m.customComponent({value:f});if(m.format){const g=m.format(f,s);return e.jsx(oe,{variant:"body",size:"sm",className:"text-text",children:g})}let h="-";switch(m.type){case"text":case"email":case"password":case"number":case"tel":case"url":h=f?String(f):"-";break;case"textarea":h=f?e.jsx("div",{className:"whitespace-pre-wrap",children:String(f||"-")}):"-";break;case"select":case"radio":h=l(f,m.options);break;case"checkbox":h=o(f);break;case"date":h=a(f);break;default:h=f?String(f):"-"}return e.jsx(oe,{variant:"body",size:"sm",className:"text-text",children:h})},[s]),x=i.useCallback(m=>{if(m.conditional&&!m.conditional(s))return null;const f=m.items.filter(g=>!(g.hidden||g.conditional&&!g.conditional(s)));if(f.length===0)return null;const h=d("space-y-4",{"grid gap-4":m.layout==="grid","flex flex-wrap gap-4":m.layout==="flex"},m.layout==="grid"&&{"grid-cols-1":!m.columns||m.columns===1,"grid-cols-2":m.columns===2,"grid-cols-3":m.columns===3,"grid-cols-4":m.columns===4},m.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 p-6 border border-border rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(oe,{variant:"label",size:"lg",weight:"semibold",className:"text-text",children:m.title}),m.description&&e.jsx(oe,{variant:"body",size:"sm",className:"text-text-muted mt-1",children:m.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:h,children:f.map(g=>e.jsxs("div",{className:"space-y-1",style:{width:typeof g.width=="string"?g.width:void 0,gridColumn:typeof g.width=="number"?`span ${g.width} / span ${g.width}`:void 0},children:[g.type!=="custom"&&e.jsx(oe,{variant:"label",size:"sm",className:"font-medium text-text-muted",children:g.label}),u(g)]},g.name))})})]},m.id)},[s,u]),j=d("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:j,children:e.jsx("div",{className:"space-y-8",children:t.map(x)})})},Fe=({item:t,isSelectedHandler:s,onClick:r,depth:n=0})=>{const a=!!(t.children&&t.children.length>0),o=s?s(t.path):!1;if(a)return e.jsxs("li",{children:[e.jsxs("div",{className:d("flex items-center gap-2 px-2 pt-4 pb-1 text-xs font-semibold uppercase tracking-label text-text-subtle"),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-0.5",children:t.children?.map((x,j)=>e.jsx(Fe,{item:x,isSelectedHandler:s,onClick:r,depth:n+1},j))})]});const l=t.action,u=l?.visibility!=="always";return e.jsx("li",{children:e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>t.path&&r?.(t.path),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),t.path&&r?.(t.path))},className:d("group/item flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-base no-underline","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",o?"bg-accent-soft font-semibold text-accent":"text-text-muted hover:bg-surface-hover hover:text-text"),children:[t.icon&&e.jsx("span",{className:"flex w-5 shrink-0 items-center justify-center",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:d("shrink-0 text-xs tabular-nums",o?"rounded-full bg-accent px-2 font-semibold text-accent-fg":"text-text-subtle",l&&u&&"group-hover/item:hidden group-focus-within/item:hidden"),children:t.count}),l&&e.jsx("button",{type:"button","aria-label":l.label,title:l.label,onClick:x=>{x.stopPropagation(),l.onClick()},onKeyDown:x=>x.stopPropagation(),className:d("flex size-5 shrink-0 items-center justify-center rounded","text-text-subtle transition-colors duration-fast ease-out","hover:bg-surface-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:l.icon})]})})},ks=({title:t,actionIcons:s,items:r,isSelectedHandler:n,onClick:a,preMenuItemsComponent:o})=>e.jsxs("nav",{className:"flex h-full shrink-0 flex-col p-3 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 pb-3",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-lg font-semibold text-text",children:t}),s&&s.length>0&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s.map((l,u)=>e.jsx("span",{className:d("flex h-control-sm w-7 cursor-pointer items-center justify-center rounded-md text-text-strong","transition-colors duration-fast ease-out hover:bg-surface-hover hover:text-text-strong","focus-visible:outline-none focus-visible:focus-ring"),children:l},u))})]}),o&&e.jsx("div",{className:"px-1 pb-3",children:o}),e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:r.map((l,u)=>!l.path&&!l.label&&!l.children?e.jsx("li",{"aria-hidden":!0,className:"h-4"},u):e.jsx(Fe,{item:l,isSelectedHandler:n,onClick:a},u))})]}),Cs={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl","3xl":"text-3xl","4xl":"text-3xl"},Ss={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},Es={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"},zs={left:"text-left",center:"text-center",right:"text-right"},Ms=({level:t=1,size:s,weight:r="semibold",color:n="current",align:a="left",truncate:o=!1,className:l,children:u,...x})=>{const j=`h${t}`,m=d("font-sans text-pretty",Cs[s||Ds(t)],Ss[r],Es[n],zs[a],o&&"truncate",l);return e.jsx(j,{className:m,...x,children:u})};function Ds(t){return{1:"2xl",2:"xl",3:"lg",4:"lg",5:"md",6:"md"}[t]||"md"}const $s=({commands:t,isOpen:s,onClose:r,labels:n,initialCommandPath:a,initialActiveIndex:o})=>{const[l,u]=i.useState(""),[x,j]=i.useState(a||[]),[m,f]=i.useState(o||0),h=i.useRef(null),g=i.useRef(null),p=(x.length?t.find(b=>b.id===x[0])?.subCommands||[]:t).filter(b=>b.label.toLowerCase().includes(l.toLowerCase()));return i.useEffect(()=>{s||(u(""),j(a||[]),f(o||0))},[s]),i.useEffect(()=>{const b=L=>{if(s){if(L.key==="Escape")r();else if(L.key==="ArrowUp")f($=>$>0?$-1:p.length-1);else if(L.key==="ArrowDown")f($=>$<p.length-1?$+1:0);else if(L.key==="Enter"){const $=p[m];$&&($.subCommands?(j([...x,$.id]),f(0)):$.action&&($.action(),r()))}}};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s,r,p,m,x]),i.useEffect(()=>{const b=L=>{h.current&&!h.current.contains(L.target)&&r()};return s&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s,r]),i.useEffect(()=>{if(!s)return;g.current?.querySelector(`[data-index="${m}"]`)?.scrollIntoView({block:"nearest"})},[m,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:h,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(I.Search,{className:"w-4 h-4 text-text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:n?.searchPlaceholder||"Search commands...",value:l,onChange:b=>u(b.target.value),className:"w-full border-0 bg-transparent py-2 text-text focus:outline-none"})]}),e.jsxs("div",{ref:g,className:"mt-2 pt-2 text-sm border-t border-border max-h-dialog-list overflow-y-auto",children:[p.length===0&&e.jsx("div",{className:"text-text-muted text-center text-sm",children:n?.noCommandsFound||"No commands found"}),p.map((b,L)=>e.jsxs("div",{"data-index":L,className:`flex items-center p-2 cursor-pointer rounded-md ${L===m?"bg-accent-soft text-accent":"text-text"}`,onClick:()=>{b.subCommands?(j([...x,b.id]),f(0)):b.action&&(b.action(),r())},onMouseEnter:()=>f(L),children:[b.icon&&e.jsx("span",{className:"mr-3",children:b.icon}),e.jsx("span",{className:"flex-grow",children:b.label}),b.subCommands&&e.jsx("span",{className:"text-text-muted",children:e.jsx(I.ChevronRight,{className:"w-4 h-4"})})]},b.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},Ts={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},Ls={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},As={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"},Rs={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},Is={none:"shadow-none",sm:"shadow-none",md:"shadow-overlay",lg:"shadow-overlay",xl:"shadow-modal","2xl":"shadow-modal"},Ps={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},Fs={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"},ye=i.forwardRef(({padding:t,margin:s,background:r,radius:n,shadow:a,border:o,borderColor:l,className:u,children:x,...j},m)=>e.jsx("div",{ref:m,className:d(t&&Ts[t],s&&Ls[s],r&&As[r],n&&Rs[n],a&&Is[a],o&&Ps[o],l&&Fs[l],u),...j,children:x}));ye.displayName="Box";const Os=({children:t,title:s,...r})=>e.jsxs(ye,{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]});function Bs({identifier:t,resourceLoader:s,framework:r="react",fallback:n,componentProps:a,className:o}){const l=i.useRef(null),[u,x]=i.useState(!0),[j,m]=i.useState(null),f=i.useRef(null);return i.useRef(null),i.useEffect(()=>{let h=!0;return(async()=>{x(!0);try{const N=await s();if(!h)return;const p=N.component||N.default||N;m(r==="react"?()=>p:()=>N)}catch(N){console.error(`[FederatedResource] Load failed: ${t}`,N)}finally{h&&x(!1)}})(),()=>{h=!1}},[t,s]),i.useEffect(()=>{if(u||!j||r==="react")return;const h=l.current;if(h){if(r==="svelte"){const g=j.default||j,N=new g({target:h,props:a||{}});return f.current=N,()=>N.$destroy()}if(j.mount){const g=j.mount({container:h,props:a||{}});return()=>{typeof g=="function"?g():j.unmount?.(h)}}}},[j,r,u]),i.useEffect(()=>{r==="svelte"&&f.current&&f.current.$set?.(a)},[a,r]),e.jsxs("div",{ref:l,className:o,style:{display:"contents"},children:[u&&n,r==="react"&&j&&e.jsx(j,{...a})]})}class Vs extends i.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-on-error rounded hover:opacity-90 transition-opacity text-sm",onClick:()=>this.setState({hasError:!1,error:null}),children:"Try again"})]}):this.props.children}}exports.AssistantCard=rs;exports.Avatar=Pe;exports.AvatarStack=os;exports.Badge=qt;exports.Box=ye;exports.Button=se;exports.ButtonGroup=Ge;exports.Card=Os;exports.ChannelBadge=is;exports.Checkbox=de;exports.CommandPalette=$s;exports.ConfirmDialog=Ot;exports.ContentLoading=Te;exports.DatePicker=me;exports.Dropdown=Le;exports.EmptyState=Wt;exports.ErrorBoundary=Vs;exports.FederatedResource=Bs;exports.FilterChip=Ze;exports.FolderSelect=Me;exports.Form=Ft;exports.Heading=Ms;exports.Icon=Y;exports.Image=ds;exports.Kbd=Kt;exports.KpiCard=ms;exports.Link=st;exports.List=us;exports.MeetingGrid=He;exports.MessageBubble=xs;exports.Modal=je;exports.PageHeader=hs;exports.PageToolbar=gs;exports.ParticipantTile=qe;exports.Popover=Ee;exports.ProgressBar=Jt;exports.SearchableTextField=De;exports.SectionDivider=ps;exports.SegmentedToggle=nt;exports.Select=ue;exports.SettingsRow=vs;exports.SettingsSection=js;exports.SidebarMenu=ks;exports.SourceChip=ys;exports.Spinner=Qt;exports.SplitButton=ve;exports.StatusDot=ts;exports.StepIndicator=ss;exports.StorageInput=Ie;exports.Switch=$e;exports.TabBar=Et;exports.Table=pe;exports.Tabs=Re;exports.Text=oe;exports.TextArea=he;exports.TextField=ce;exports.VideoSurface=Ue;exports.View=ws;exports.cn=d;exports.createSizes=Ve;exports.createVariants=Be;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Fe=require("clsx"),e=require("react/jsx-runtime"),R=require("lucide-react"),i=require("react"),Oe=require("dompurify"),Be=require("react-markdown"),qe=require("remark-gfm");function d(...t){return Fe.clsx(t)}function Ve(t){return(s,r)=>t[s]?.[r]||""}function He(t){return s=>t[s]||""}function Ue({tiles:t,pinned:s,className:r}){if(s)return e.jsxs("div",{className:d("flex flex-col md:flex-row gap-2 h-full min-h-0",r),children:[e.jsx("div",{className:"flex-1 min-h-0",children:s}),t.length>0&&e.jsx("div",{className:"flex md:flex-col gap-2 md:w-48 overflow-auto",children:t.map((a,o)=>e.jsx("div",{className:"min-w-40 md:min-w-0",children:a},o))})]});const n=t.length<=1?"grid-cols-1":t.length<=4?"grid-cols-2":t.length<=9?"grid-cols-3":"grid-cols-4";return e.jsx("div",{className:d("grid gap-2 h-full",n,r),children:t.map((a,o)=>e.jsx("div",{children:a},o))})}function We({name:t,avatarUrl:s,muted:r,speaking:n,hasVideo:a,videoSlot:o,className:l,fill:u}){return e.jsxs("div",{className:d("relative rounded-lg overflow-hidden bg-video-surface flex items-center justify-center",u?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",l),children:[a&&o?e.jsx("div",{className:"absolute inset-0",children:o}):e.jsx("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:s?e.jsx("img",{src:s,alt:t,className:"w-16 h-16 rounded-full object-cover"}):e.jsx("div",{className:"w-16 h-16 rounded-full bg-video-surface-strong flex items-center justify-center",children:a?e.jsx(R.VideoOff,{className:"w-8 h-8"}):e.jsx(R.User,{className:"w-8 h-8"})})}),e.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded bg-video-overlay text-white text-xs",children:[r?e.jsx(R.MicOff,{className:"w-3 h-3"}):e.jsx(R.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-35",children:t})]})]})}function Ke({attach:t,active:s=!0,mirrored:r=!1,className:n}){const a=i.useRef(null);return i.useEffect(()=>{if(!s||!a.current)return;const o=t(a.current);return()=>{typeof o=="function"&&o(),a.current&&(a.current.innerHTML="")}},[t,s]),e.jsx("div",{ref:a,className:d("w-full h-full bg-video-surface-strong overflow-hidden",r&&"[&>*]:scale-x-[-1]",n)})}const Ge={primary:"bg-accent text-accent-fg hover:bg-accent-hover disabled:bg-surface-hover",secondary:"bg-gray-100 text-text hover:bg-surface-hover disabled:bg-surface-hover",outline:"border border-border text-accent 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"},Je={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"},Ye={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=i.forwardRef(({variant:t="primary",size:s="md",fullWidth:r=!1,loading:n=!1,leftIcon:a,rightIcon:o,iconOnly:l=!1,shape:u="default",className:x,children:j,disabled:m,...f},h)=>{const p=m||n;return e.jsxs("button",{ref:h,type:"button",className:d("inline-flex shrink-0 items-center justify-center gap-2 cursor-pointer font-semibold",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",Ge[t],l?Ye[s]:Je[s],(r||s==="full")&&"w-full",n&&"cursor-wait",x),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}),!l&&j,!n&&o&&e.jsx("span",{className:"flex items-center justify-center shrink-0",children:o}),l&&!n&&!a&&!o&&j]})});se.displayName="Button";const Xe=({children:t,size:s="md",orientation:r="horizontal",attached:n=!0,className:a})=>{const o=d("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:o,role:"group",children:t})},Ze={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:o,"aria-label":l,...u})=>{const x=typeof s=="number"?s:Qe(s),j=d("inline-block shrink-0",Ze[r],n&&["cursor-pointer rounded-sm transition-opacity duration-fast ease-out hover:opacity-80","focus-visible:outline-none focus-visible:focus-ring"],o),m={size:x,strokeWidth:2,className:j,onClick:n?a:void 0,"aria-label":l,"aria-hidden":l?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,{...m})};function Qe(t){return{xs:12,sm:14,md:16,lg:20,xl:24}[t]}const et={none:"border-none hover:bg-surface-hover hover:text-text",default:"border-border text-text-muted hover:bg-surface-hover hover:text-text",muted:"border-border text-text-subtle hover:bg-surface-hover hover:text-text",warning:"border-warning-border bg-warning-soft text-warning-fg hover:bg-surface-hover",danger:"border-danger-border bg-danger-soft text-danger-fg hover:bg-surface-hover"};function tt({label:t,icon:s,tone:r="default",shape:n="pill",size:a="md",active:o=!1,caret:l=!1,onClear:u,clearLabel:x="Filter wissen",onClick:j,title:m,className:f}){const h=o&&!!u,p=n==="pill"?"rounded-full":"rounded-md",N=d("inline-flex cursor-pointer select-none items-center text-sm font-semibold",a==="sm"?"h-control-sm":"h-control-md","transition-colors duration-fast ease-out",p,o?"bg-accent text-accent-fg":d("border",et[r]),f),g=e.jsxs(e.Fragment,{children:[s,t,l&&e.jsx(Y,{icon:R.ChevronDown,size:"xs"})]}),b=d("inline-flex items-center gap-1.5 pl-3",p,h?"pr-1.5":"pr-3","focus-visible:outline-none focus-visible:focus-ring");return h?e.jsxs("span",{className:N,title:m,children:[e.jsx("button",{type:"button",onClick:j,className:b,children:g}),e.jsx("button",{type:"button","aria-label":x,onClick:u,className:d("inline-flex h-full items-center pr-3 focus-visible:outline-none focus-visible:focus-ring",p),children:e.jsx(Y,{icon:R.X,size:"xs"})})]}):e.jsx("button",{type:"button",title:m,onClick:j,className:d(N,b),children:g})}const st={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},rt={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"},nt={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"},at=({variant:t="default",size:s="md",color:r="primary",disabled:n=!1,external:a=!1,className:o,children:l,href:u,target:x,rel:j,...m})=>{const f=a||u&&(u.startsWith("http")||u.startsWith("mailto:")),h=d("inline-flex items-center gap-1 underline-offset-2","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",st[s],!n&&rt[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",nt[r]],n&&"pointer-events-none cursor-not-allowed text-text-disabled opacity-50",o),p={...m,href:n?void 0:u,target:f?"_blank":x,rel:f?"noopener noreferrer":j,"aria-disabled":n||void 0};return e.jsxs("a",{className:h,...p,children:[l,f&&e.jsx(R.ExternalLink,{className:"size-icon-sm shrink-0","aria-hidden":!0})]})},lt={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm"};function ot({options:t,value:s,onChange:r,size:n="sm",className:a,"aria-label":o}){return e.jsx("div",{role:"tablist","aria-label":o,className:d("inline-flex gap-0.5 rounded-md bg-surface-hover p-0.5",a),children:t.map(l=>{const u=l.value===s;return e.jsx("button",{role:"tab","aria-selected":u,type:"button",onClick:()=>r(l.value),className:d("inline-flex items-center justify-center rounded-sm","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",lt[n],u?"bg-surface text-text font-semibold":"text-text-muted hover:text-text"),children:l.label},l.value)})})}function be(t,s,{gap:r=6,matchWidth:n=!1,placement:a="bottom-start"}={}){const[o,l]=i.useState({});return i.useLayoutEffect(()=>{if(!t)return;const u=()=>{const x=s.current;if(!x)return;const j=x.getBoundingClientRect(),m=window.innerHeight-j.bottom,f=j.top,h=a.startsWith("top"),p=h?f<200&&m>f:m<200&&f>m,N=h!==p,g={position:"fixed"};N?(g.bottom=window.innerHeight-j.top+r,g.maxHeight=Math.max(120,f-r*2)):(g.top=j.bottom+r,g.maxHeight=Math.max(120,m-r*2)),a.endsWith("end")?g.right=window.innerWidth-j.right:g.left=j.left,n&&(g.width=j.width),l(g)};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]),o}const Ee=({trigger:t,children:s,placement:r="bottom-start",className:n,rootClassName:a,triggerClassName:o,disabled:l=!1,triggerLabel:u})=>{const[x,j]=i.useState(!1),m=i.useRef(null),f=i.useRef(null),h=be(x,f,{placement:r});i.useEffect(()=>{if(!x)return;const g=L=>{m.current&&!m.current.contains(L.target)&&j(!1)},b=L=>{L.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",b)}},[x]);const p=g=>{g.stopPropagation(),!l&&j(b=>!b)},N=()=>j(!1);return e.jsxs("div",{ref:m,className:d("relative inline-flex",a),children:[e.jsx("button",{ref:f,type:"button",onClick:p,disabled:l,"aria-label":u,"aria-expanded":x,className:d("inline-flex items-center",l&&"cursor-not-allowed opacity-50",o),children:t}),x&&e.jsx("div",{className:d("fixed z-overlay overflow-y-auto rounded-lg border border-border bg-surface shadow-overlay",n),style:h,children:typeof s=="function"?s(N):s})]})},ct={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"},it={sm:"h-control-sm w-7",md:"h-control-md w-8"};function ve({label:t,onClick:s,variant:r="primary",size:n="md",icon:a,options:o,disabled:l=!1,loading:u=!1,menuPlacement:x="bottom-end",menuLabel:j="More options"}){const m=l||u,f=o.length>0;return e.jsxs("div",{className:d("inline-flex items-center",r==="primary"&&"gap-0.5"),children:[e.jsx(se,{variant:r,size:n,onClick:s,disabled:l,loading:u,leftIcon:a,className:d(f&&"rounded-r-none"),children:t}),f&&e.jsx(Ee,{placement:x,disabled:m,triggerLabel:j,className:"min-w-menu py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:d("inline-flex items-center justify-center rounded-md rounded-l-none","transition-colors duration-fast ease-out",ct[r],it[n],m&&"cursor-not-allowed opacity-50"),children:e.jsx(R.ChevronDown,{className:"size-icon-md"})}),children:h=>e.jsx(e.Fragment,{children:o.map(p=>e.jsxs("button",{type:"button",onClick:()=>{p.onClick(),h()},className:d("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 dt={sm:"size-checkbox-sm",md:"size-checkbox",lg:"size-checkbox-lg",full:"size-checkbox"},ut={sm:"min-h-control-sm",md:"min-h-control-md",lg:"min-h-control-lg",full:"min-h-control-md"},xt={sm:"text-sm",md:"text-base",lg:"text-md",full:"text-base"},de=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",indeterminate:a=!1,containerClassName:o,labelClassName:l,className:u,id:x,...j},m)=>{const f=i.useId(),h=x||`checkbox-${f}`,p=!!r,N=i.useRef(null),g=i.useCallback(b=>{N.current=b,typeof m=="function"?m(b):m&&typeof m=="object"&&(m.current=b)},[m]);return i.useEffect(()=>{N.current&&(N.current.indeterminate=a)},[a]),e.jsxs("div",{className:d("flex flex-col",o),children:[e.jsxs("div",{className:d("flex items-center gap-3",ut[n]),children:[e.jsx("input",{ref:g,id:h,type:"checkbox","aria-invalid":p||void 0,className:d("shrink-0 rounded-md 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",dt[n],p?"border-danger-border":"border-border-strong",u),...j}),t&&e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:h,className:d("cursor-pointer",p?"text-danger-fg":"text-text",xt[n],l),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})]})});de.displayName="Checkbox";const ft=()=>e.jsx(Y,{icon:R.Calendar,size:"md",color:"current"}),mt=()=>e.jsx(Y,{icon:R.ChevronLeft,size:"md",color:"current"}),ht=()=>e.jsx(Y,{icon:R.ChevronRight,size:"md",color:"current"}),me=i.forwardRef(({value:t,onChange:s,placeholder:r="Select date",disabled:n=!1,required:a=!1,size:o="md",className:l,minDate:u,maxDate:x,format:j="MM/dd/yyyy",withTime:m=!1},f)=>{const[h,p]=i.useState(!1),[N,g]=i.useState(()=>t||new Date),b=i.useRef(null),L=i.useRef(null),$=be(h,L);i.useEffect(()=>{const c=C=>{b.current&&!b.current.contains(C.target)&&p(!1)};return h&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[h]);const K=c=>{if(!c)return"";const C=c.getDate().toString().padStart(2,"0"),y=(c.getMonth()+1).toString().padStart(2,"0"),T=c.getFullYear(),w=j==="dd/MM/yyyy"?`${C}/${y}/${T}`:j==="yyyy-MM-dd"?`${T}-${y}-${C}`:`${y}/${C}/${T}`;return m?`${w} ${M(c)}`:w},M=c=>`${c.getHours().toString().padStart(2,"0")}:${c.getMinutes().toString().padStart(2,"0")}`,X=c=>{const[C,y]=c.split(":").map(Number);if(Number.isNaN(C)||Number.isNaN(y))return;const T=t?new Date(t):new Date;T.setHours(C,y,0,0),s?.(T)},U=()=>{const c=N.getFullYear(),C=N.getMonth(),y=new Date(c,C,1),T=new Date(y);T.setDate(T.getDate()-y.getDay());const w=[],Q=new Date(T);for(let re=0;re<42;re++)w.push(new Date(Q)),Q.setDate(Q.getDate()+1);return w},_=c=>{if(c.getMonth()===N.getMonth()&&!(u&&c<u)&&!(x&&c>x)){if(m){const y=new Date(c);y.setHours(t?.getHours()??0,t?.getMinutes()??0,0,0),s?.(y);return}s?.(c),p(!1)}},H=()=>{g(new Date(N.getFullYear(),N.getMonth()-1,1))},W=()=>{g(new Date(N.getFullYear(),N.getMonth()+1,1))},te=()=>{s?.(null),p(!1)},P=d("w-full border border-border rounded-md 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":o==="sm","h-control-md px-3 text-base":o==="md","h-control-lg px-3 text-base":o==="lg","h-control-md w-full px-3 text-base":o==="full"},l),ae=U(),k=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:b,className:"relative",children:[e.jsxs("div",{ref:L,className:"relative",children:[e.jsx("input",{ref:f,type:"text",value:K(t??null),placeholder:r,disabled:n,required:a,readOnly:!0,onClick:()=>!n&&p(!h),className:d(P,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!n&&p(!h),disabled:n,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted hover:text-text-muted",children:e.jsx(ft,{})})]}),h&&e.jsxs("div",{style:$,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:H,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(mt,{})}),e.jsxs("h3",{className:"text-sm font-medium text-text",children:[k[N.getMonth()]," ",N.getFullYear()]}),e.jsx("button",{onClick:W,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(ht,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(c=>e.jsx("div",{className:"text-xs font-medium text-text-muted text-center py-1",children:c},c))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:ae.map((c,C)=>{const y=c.getMonth()===N.getMonth(),T=t&&c.toDateString()===t.toDateString(),w=c.toDateString()===new Date().toDateString(),Q=!y||u&&c<u||x&&c>x;return e.jsx("button",{onClick:()=>!Q&&_(c),disabled:Q,className:d("w-8 h-8 text-sm rounded transition-colors duration-fast",{"text-text hover:bg-surface-hover":y&&!T&&!Q,"bg-accent text-accent-fg":T,"bg-surface-hover text-text":w&&!T,"text-text-muted cursor-not-allowed":Q}),children:c.getDate()},C)})}),m&&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?M(t):"",onChange:c=>X(c.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:te,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"})]})]})]})}),bt={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"},fe=t=>t.trim().toLowerCase(),ue=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,disabled:o=!1,options:l,placeholder:u,containerClassName:x,labelClassName:j,className:m,id:f,searchable:h,multiple:p,value:N,onChange:g,allowCreate:b,onCreateOption:L,...$},K)=>{const M=f||`select-${Math.random().toString(36).substr(2,9)}`,X=!!r,[U,_]=i.useState(!1),[H,W]=i.useState(""),te=i.useRef(null),P=i.useRef(null),ae=be(U,P,{matchWidth:!0}),[k,c]=i.useState(l);i.useImperativeHandle(K,()=>te.current),i.useEffect(()=>{const E=D=>{te.current&&!te.current.contains(D.target)&&_(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const C=i.useCallback((E,D)=>E.some(S=>fe(S.value)===fe(D)||fe(S.label)===fe(D)),[]),y=i.useCallback((E,D)=>{const S=[...E],B=O=>{const q=(O??"").trim();q&&(C(S,q)||S.push({value:q,label:q}))};return Array.isArray(D)?D.forEach(B):B(D),S},[C]);i.useEffect(()=>{c(E=>{const D=[...l];return E.forEach(S=>{!C(D,S.value)&&!C(D,S.label)&&D.push(S)}),y(D,N)})},[l,N,y,C]);const T=E=>{if(p){const D=Array.isArray(N)?N:[],S=D.includes(E)?D.filter(B=>B!==E):[...D,E];g?.(S)}else g?.(E),_(!1),W("")},w=p?null:k.find(E=>E.value===N),Q=p?k.filter(E=>Array.isArray(N)&&N.includes(E.value)):[],re=h&&H?k.filter(E=>E.label.toLowerCase().includes(H.toLowerCase())):k,ne=!!b&&!!h&&!!H.trim()&&!C(k,H),G=E=>{const D=E.trim();if(!D)return;const S=L?.(D)??{value:D,label:D};if(C(k,S.value)||C(k,S.label)){T(S.value),W(""),p||_(!1);return}c(B=>[...B,S]),T(S.value),W(""),p||_(!1)},I=()=>p?Q.length>0?Q.map(E=>E.label).join(", "):u||"Select options":w?.label||u||"Select an option";return e.jsxs("div",{ref:te,className:d("relative flex flex-col",a&&"w-full",x),...$,children:[t&&e.jsx("label",{htmlFor:M,onClick:()=>_(!U),className:d("block text-xs font-semibold uppercase tracking-label mb-1.5",X?"text-danger-fg":"text-text-muted",j),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:P,type:"button",id:M,disabled:o,onClick:()=>_(!U),className:d("flex w-full items-center justify-between gap-2 rounded-md 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",bt[n],X?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",m),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:I()}),e.jsx(R.ChevronDownIcon,{size:16,className:d("shrink-0 opacity-60 transition-transform duration-fast",U&&"rotate-180")})]}),U&&e.jsxs("div",{style:ae,className:"fixed z-overlay flex flex-col overflow-hidden rounded-lg border border-border bg-surface shadow-overlay",children:[h&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:H,onChange:E=>W(E.target.value),onKeyDown:E=>{E.key==="Enter"&&ne&&(E.preventDefault(),G(H))},className:d("w-full px-3 py-2 text-sm rounded-md border","text-text border-border focus-visible:outline-none focus-visible:focus-ring")})}),ne&&e.jsxs("div",{className:d("cursor-pointer px-3 py-1.5 text-sm","text-info-fg hover:bg-surface-hover"),onClick:()=>G(H),children:["+: “",H.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:()=>{g?.(""),_(!1)},children:u}),re.map(E=>{const D=p?Array.isArray(N)&&N.includes(E.value):N===E.value;return e.jsx("li",{onClick:()=>!E.disabled&&T(E.value),className:d("cursor-pointer px-3 py-1.5 text-sm","text-text",E.disabled?"opacity-50 cursor-not-allowed":"hover:bg-surface-hover",D&&"bg-accent-soft text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[p&&e.jsx("input",{type:"checkbox",checked:D,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-border [&:not(:checked)]:bg-surface-input text-accent "}),e.jsx("span",{children:E.label})]})},E.value)})]})]})]}),(r||s)&&e.jsx("p",{className:d("mt-1 text-xs",X?"text-danger-fg":"text-text-muted"),children:r||s})]})});ue.displayName="Select";const pt={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"},ze="mb-1.5 block text-xs font-semibold uppercase tracking-label",ce=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:o,endIcon:l,loading:u=!1,containerClassName:x,labelClassName:j,className:m,id:f,...h},p)=>{const N=i.useId(),g=f||`textfield-${N}`,b=!!r,L=r||s?`${g}-description`:void 0;return e.jsxs("div",{className:d("flex flex-col",a&&"w-full",x),children:[t&&e.jsx("label",{htmlFor:g,className:d(ze,b?"text-danger-fg":"text-text-subtle",j),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 text-text-muted",children:o}),e.jsx("input",{ref:p,id:g,"aria-invalid":b||void 0,"aria-describedby":L,className:d("block w-full rounded-md 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",pt[n],o&&"pl-9",(l||u)&&"pr-9",b?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",m),...h}),(l||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"}):l})]}),(r||s)&&e.jsx("p",{id:L,className:d("mt-1 text-xs",b?"text-danger-fg":"text-text-subtle"),children:r||s})]})});ce.displayName="TextField";function Me({value:t,onChange:s,onListFolders:r,disabled:n,size:a="md",placeholder:o,templatePlaceholder:l,showTemplate:u=!0}){const[x,j]=i.useState([]);i.useEffect(()=>{let f=!0;return Promise.resolve(r?.()).then(h=>{f&&h&&j(h.data??[])}).catch(()=>{}),()=>{f=!1}},[]);const m=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ue,{size:a,fullWidth:!0,value:m.folderId??"",options:x.map(f=>({value:f.id,label:f.name})),placeholder:o??"Select a folder",onChange:f=>s?.({...m,folderId:f})}),u&&e.jsx(ce,{size:a,disabled:n??!1,value:m.pathTemplate??"",placeholder:l??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:f=>s?.({...m,pathTemplate:f.target.value})})]})}const ie=(...t)=>t.filter(Boolean).join(" "),gt=t=>e.jsx(R.Search,{...t,strokeWidth:1.5,"aria-hidden":!0}),vt=t=>e.jsx(R.ChevronDown,{...t,strokeWidth:1.5,"aria-hidden":!0}),jt={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"},pe={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},De=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,startIcon:o=e.jsx(gt,{}),loading:l=!1,containerClassName:u,labelClassName:x,className:j,id:m,options:f,onRemoteSearch:h,onSelect:p,debounceTime:N=500,showAllOnOpen:g=!1,value:b,onChange:L,...$},K)=>{const M=m||`searchfield-${Math.random().toString(36).substr(2,9)}`,X=!!r,U=i.useRef(null),_=i.useRef(null),[H,W]=i.useState(b||""),[te,P]=i.useState(!1),[ae,k]=i.useState(!1),[c,C]=i.useState(!1);i.useEffect(()=>{b!==void 0&&W(b)},[b]);const y=i.useMemo(()=>{if(g&&!c||!H)return f;const I=String(H).toLowerCase();return f.filter(E=>String(E.label).toLowerCase().includes(I))},[H,f,g,c]);i.useEffect(()=>{if(!h||!H){k(!1);return}const I=setTimeout(async()=>{k(!0);try{await h(String(H))}catch(E){console.error("Remote search failed:",E)}finally{k(!1)}},N);return()=>{clearTimeout(I),k(!1)}},[H,N,h]),i.useEffect(()=>{const I=E=>{U.current&&!U.current.contains(E.target)&&P(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);const T=I=>{const E=I.target.value;W(E),P(!0),C(!0),L&&L(I)},w=I=>{W(I.label),P(!1),C(!1),p&&p(I.value)},Q=()=>{(f.length>0||h)&&(P(!0),C(!1))},re=l||ae,ne=te&&(y.length>0||re),G=i.useMemo(()=>K||_,[K]);return e.jsxs("div",{className:ie("flex flex-col",a?"w-full":"",u||"","relative"),ref:U,children:[t&&e.jsx("label",{htmlFor:M,className:ie("block text-sm font-medium mb-1",X?"text-danger-fg":"text-text",x||""),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:ie("text-text-muted",pe[n]),children:o})}),e.jsx("input",{ref:G,id:M,value:H,onChange:T,onFocus:Q,className:ie("block w-full rounded-md 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",jt[n],o?"pl-10":"","pr-10",X?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",j||""),...$}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:re||l?e.jsx(R.Loader2,{className:ie("animate-spin text-info-fg",pe[n]),"aria-hidden":!0}):e.jsx(vt,{className:ie("text-text-muted cursor-pointer transition-transform",pe[n],te?"rotate-180":"rotate-0"),onClick:()=>{P(I=>(I||C(!1),!I))}})})]}),ne&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-surface border border-border rounded-lg shadow-lg max-h-60 overflow-auto top-full",role:"listbox",children:y.length>0?y.map(I=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>w(I),role:"option","aria-selected":H===I.label,children:I.label},I.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:re||l?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(r||s)&&e.jsx("p",{className:ie("mt-1 text-xs",X?"text-danger-fg":"text-text-muted"),children:r||s}),h&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String(H)]})]})});De.displayName="SearchableTextField";const Te=i.forwardRef(({checked:t,onChange:s,label:r,disabled:n=!1,className:a,...o},l)=>{const u=e.jsx("span",{"aria-hidden":!0,className:d("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:d("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:d("inline-flex items-center gap-2",n?"cursor-not-allowed":"cursor-pointer",a),children:[e.jsx("input",{ref:l,type:"checkbox",role:"switch",checked:t,disabled:n,onChange:x=>s(x.target.checked),className:"peer sr-only",...o}),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})]})});Te.displayName="Switch";function $e({variant:t="page",children:s,showTableSkeleton:r=!1,tableColumns:n=6,tableRows:a=8}){const o=({children:l})=>t==="inline"?e.jsx(e.Fragment,{children:l}):e.jsx("main",{className:"flex-1 bg-surface p-6",children:l});return s?e.jsx(o,{children:e.jsx("div",{className:"w-full max-w-6xl mx-auto animate-pulse",children:s})}):e.jsx(o,{children:e.jsxs("div",{className:"w-full mx-auto space-y-6 animate-pulse",children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-6 w-1/4 rounded-sm bg-surface-hover"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-3/4 rounded-sm bg-surface-hover"}),e.jsx("div",{className:"h-4 w-1/2 rounded-sm bg-surface-hover"})]})]}),r&&e.jsxs("div",{className:"rounded-lg overflow-hidden",children:[e.jsx("div",{className:"grid gap-2 bg-surface-hover p-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:Array.from({length:n}).map((l,u)=>e.jsx("div",{className:"h-4 w-2/3 rounded-sm bg-border-strong"},`header-${u}`))}),Array.from({length:a}).map((l,u)=>e.jsx("div",{className:"grid gap-2 border-t border-border-subtle p-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:Array.from({length:n}).map((x,j)=>e.jsx("div",{className:"h-4 w-full rounded-sm bg-surface-hover"},`cell-${u}-${j}`))},`row-${u}`))]})]})})}const Le=({trigger:t,options:s,value:r,onSelect:n,placement:a="bottom-start",disabled:o=!1,className:l,showCheck:u=!0,header:x})=>{const[j,m]=i.useState(!1),[f,h]=i.useState(null),[p,N]=i.useState({top:0,left:0}),g=i.useRef(null),b=i.useRef(null),L=i.useRef(null),$=i.useRef(null),K=be(j,b,{placement:a}),M=i.useRef(null),X=()=>Array.from($.current?.querySelectorAll("button[data-option-value]:not(:disabled)")??[]);i.useEffect(()=>{j&&X()[0]?.focus()},[j]);const U=c=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(c.key))return;const y=X();if(y.length===0)return;c.preventDefault();const T=y.indexOf(document.activeElement),w=c.key==="Home"?0:c.key==="End"?y.length-1:c.key==="ArrowDown"?(T+1)%y.length:(T-1+y.length)%y.length;y[w]?.focus()};i.useEffect(()=>{const c=C=>{g.current&&(!g.current.contains(C.target)||L.current&&!L.current.contains(C.target))&&(m(!1),h(null),M.current&&(clearTimeout(M.current),M.current=null))};return j&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[j]),i.useEffect(()=>{const c=C=>{C.key==="Escape"&&(m(!1),h(null),b.current?.focus(),M.current&&(clearTimeout(M.current),M.current=null))};return j&&document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[j]),i.useEffect(()=>{if(f&&g.current){const c=g.current.querySelector(`[data-option-value="${f}"]`);if(c){const C=c.getBoundingClientRect();N({top:C.top,left:C.right+8})}}},[f]),i.useEffect(()=>()=>{M.current&&clearTimeout(M.current)},[]);const _=c=>{c.stopPropagation(),!o&&(m(!j),h(null),M.current&&(clearTimeout(M.current),M.current=null))},H=(c,C,y)=>{c.stopPropagation(),!C.disabled&&!C.divider&&(!C.children||C.children.length===0)&&(n?.(C.value,y),m(!1),h(null))},W=c=>{M.current&&(clearTimeout(M.current),M.current=null),c.children&&c.children.length>0?h(c.value):h(null)},te=c=>{c.children&&c.children.length>0?M.current=setTimeout(()=>{h(null)},150):h(null)},P=(c,C,y)=>{c.stopPropagation(),!C.disabled&&!C.divider&&(n?.(C.value,y),m(!1),h(null))},ae=d("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto"),k=d("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:g,className:d("relative flex flex-row items-center justify-center rounded-lg hover:bg-surface-hover",l),children:[e.jsx("button",{ref:b,onClick:_,disabled:o,"aria-haspopup":"menu","aria-expanded":j,className:d("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":o}),children:t}),j&&e.jsx("div",{ref:$,className:ae,style:K,onKeyDown:U,children:e.jsxs("div",{className:"p-2",role:"menu",children:[x&&(typeof x=="string"?e.jsx("div",{className:"text-xs font-medium text-text-muted uppercase tracking-label px-3 py-2",children:x}):x),s.map((c,C)=>{if(c.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${C}`);const y=c.children&&c.children.length>0,T=f===c.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":c.value,role:"menuitem","aria-haspopup":y?"menu":void 0,onClick:w=>H(w,c),onMouseEnter:()=>W(c),onMouseLeave:()=>te(c),disabled:c.disabled,className:d("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":c.disabled,"bg-surface-hover":T&&y}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[c.icon&&e.jsx("span",{className:"flex-shrink-0",children:c.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:c.label}),c.description&&e.jsx("span",{className:"text-xs text-text-muted",children:c.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[u&&r===c.value&&e.jsx(R.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0}),y&&e.jsx("span",{className:"text-text-muted text-xs",children:"▶"})]})]}),y&&T&&e.jsx("div",{ref:L,className:k,style:{top:`${p.top}px`,left:`${p.left}px`},onMouseEnter:()=>{M.current&&(clearTimeout(M.current),M.current=null),h(c.value)},onMouseLeave:()=>{M.current=setTimeout(()=>{h(null)},150)},children:e.jsx("div",{className:"p-2",children:c.children.map((w,Q)=>{if(w.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${Q}`);const re=typeof r=="object"&&r[c.value]&&r[c.value].includes(w.value)||r===w.value;return e.jsxs("button",{onClick:ne=>P(ne,w,c.value),disabled:w.disabled,className:d("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":w.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[w.icon&&e.jsx("span",{className:"flex-shrink-0",children:w.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:w.label}),w.description&&e.jsx("span",{className:"text-xs text-text-muted",children:w.description})]})]}),u&&re&&e.jsx(R.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0})]},w.value)})})})]},c.value)}),(()=>{const c=s.reduce((C,y)=>{if(y.divider)return C;const T=y.children?y.children.filter(w=>!w.divider).length:0;return C+1+T},0);return c>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:[c," options available"]})})})()]})})]})},Ne={none:"pl-0",sm:"pl-2",md:"pl-4",lg:"pl-6"},we={none:"pr-0",sm:"pr-2",md:"pr-4",lg:"pr-6"},yt=()=>e.jsx(Y,{icon:R.Search,size:"md",color:"current"}),Nt=({active:t})=>e.jsx(Y,{icon:R.ChevronUp,size:"sm",className:t?"text-text":"text-text-subtle"}),wt=({active:t})=>e.jsx(Y,{icon:R.ChevronDown,size:"sm",className:t?"text-text":"text-text-subtle"}),kt=()=>e.jsx(Y,{icon:R.ChevronLeft,size:"md",color:"current"}),Ct=()=>e.jsx(Y,{icon:R.ChevronRight,size:"md",color:"current"}),St=()=>e.jsx(Y,{icon:R.ChevronsLeft,size:"md",color:"current"}),Et=()=>e.jsx(Y,{icon:R.ChevronsRight,size:"md",color:"current"}),Ae=()=>e.jsx(Y,{icon:R.ChevronDown,size:"md",color:"current"}),zt=t=>{const s=n=>t.multiSelect&&Array.isArray(t.value)?t.value?.includes(n):t.value===n,r=n=>{t.multiSelect&&Array.isArray(t.value)?t.onChange(t.value.filter(a=>a!==n)):t.onChange(n)};return t.type==="date"?e.jsx("div",{className:"flex items-center space-x-1 max-w-40",children:e.jsx(me,{size:"sm",value:t.value,onChange:n=>t.onChange(n),placeholder:t.placeholder||`Select ${t.label.toLowerCase()}`,className:"min-w-40 border border-border bg-surface text-text hover:bg-surface-hover"})}):e.jsx("div",{className:"flex items-center space-x-1 max-w-60",children:e.jsx("div",{className:"relative",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex h-control-md cursor-pointer items-center gap-2 rounded-full border border-border bg-surface px-3 text-sm font-semibold text-text hover:bg-surface-hover",children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:"text-text",children:t.multiSelect&&Array.isArray(t.value)?t.value?.map(n=>t.options?.find(a=>a.value===n)?.label).join(", "):t.options?.find(n=>n.value===t.value)?.label}),e.jsx("span",{className:"text-text-muted text-sm group-open:rotate-180 transition-transform",children:e.jsx(Ae,{})})]}),e.jsxs("div",{className:"absolute z-10 left-0 mt-1 bg-surface border border-border rounded-lg shadow-overlay p-2 w-48",children:[t.options?.map(n=>e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-surface-hover text-sm text-text flex items-center space-x-2",onClick:()=>r(n.value),children:e.jsx("span",{className:d(s(n.value)&&"text-accent"),children:n.label})},n.value)),t.value&&e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-surface-hover text-sm text-text flex items-center space-x-2 mt-2",onClick:()=>r(null),children:e.jsx("span",{className:"text-text-muted",children:"Clear filter"})})]})]})})})},ge=({data:t,columns:s,loading:r=!1,searchable:n=!1,searchPlaceholder:a="Search...",filters:o=[],paginated:l=!1,pageSizeOptions:u=[10,25,50,100],defaultPageSize:x=10,actions:j=[],onRowClick:m,selectable:f=!1,selectedRows:h=[],onSelectionChange:p,getRowKey:N=(_,H)=>H,emptyContent:g,hoverable:b=!0,bordered:L=!1,striped:$=!1,padding:K="md",className:M,rowClassName:X,headerBackground:U=!0})=>{const[_,H]=i.useState(""),[W,te]=i.useState({column:null,direction:null}),[P,ae]=i.useState({page:0,pageSize:x}),k=i.useRef(null),c=i.useMemo(()=>{let v=t;if(n&&_.trim()){const V=s.filter(J=>J.searchable!==!1),Z=_.toLowerCase();v=v.filter(J=>V.some(F=>{const le=typeof F.accessor=="function"?F.accessor(J):J[F.accessor];return String(le||"").toLowerCase().includes(Z)}))}return o.forEach(V=>{V.value&&V.value!=="all"&&(v=v.filter(Z=>{const J=s.find(le=>le.id===V.id);if(!J)return!0;const F=typeof J.accessor=="function"?J.accessor(Z):Z[J.accessor];return String(F||"")===V.value}))}),v},[t,_,s,n,o]),C=i.useMemo(()=>{if(!W.column||!W.direction)return c;const v=s.find(V=>V.id===W.column);return v?[...c].sort((V,Z)=>{const J=typeof v.accessor=="function"?v.accessor(V):V[v.accessor],F=typeof v.accessor=="function"?v.accessor(Z):Z[v.accessor];let le=0;return J<F?le=-1:J>F&&(le=1),W.direction==="desc"?-le:le}):c},[c,W,s]),y=i.useMemo(()=>{if(!l)return C;const v=P.page*P.pageSize,V=v+P.pageSize;return C.slice(v,V)},[C,P,l]),T=i.useCallback(v=>{s.find(Z=>Z.id===v)?.sortable&&te(Z=>Z.column!==v?{column:v,direction:"asc"}:Z.direction==="asc"?{column:v,direction:"desc"}:{column:null,direction:null})},[s]),w=i.useCallback(v=>{ae(V=>({...V,page:v}))},[]),Q=i.useCallback(v=>{ae({page:0,pageSize:v})},[]),re=i.useCallback((v,V)=>{if(!p)return;const Z=N(v,0);h.map((J,F)=>N(J,F)),p(V?[...h,v]:h.filter((J,F)=>N(h[F],F)!==Z))},[h,p,N]),ne=i.useCallback(v=>{p&&p(v?[...y]:[])},[y,p]);i.useEffect(()=>{ae(v=>({...v,page:0}))},[_,W]),i.useEffect(()=>{ae(v=>({...v,page:0}))},[o.map(v=>v.value).join(",")]);const G=C.length,I=Math.ceil(G/P.pageSize),E=P.page*P.pageSize+1,D=Math.min(E+P.pageSize-1,G),S=y.length>0&&y.every(v=>{const V=N(v,0);return h.some((Z,J)=>N(Z,J)===V)}),B=y.some(v=>{const V=N(v,0);return h.some((Z,J)=>N(Z,J)===V)}),O=d("w-full text-sm leading-5 text-text border-collapse",M),q=U?"bg-surface-sunk border-border border-t":"bg-surface",z=d(q,"h-control-lg"),A=d("text-text border-b border-border p-2"),ee=d("h-row-lg",{"hover:bg-surface-sunk":b,"cursor-pointer":m});return e.jsxs("div",{className:"space-y-4",children:[(n||o.length>0)&&e.jsx("div",{className:"px-4 pt-4 pb-2",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-start",children:[o.map(v=>e.jsx(zt,{...v},v.id)),e.jsx("div",{className:"w-full sm:w-auto sm:ml-auto min-w-menu",children:e.jsx(ce,{placeholder:a,value:_,onChange:v=>H(v.target.value),startIcon:e.jsx(yt,{}),className:"max-w-sm"})})]})}),e.jsxs("div",{className:"relative w-full overflow-x-auto min-h-100",children:[r&&e.jsx("div",{className:"flex items-center justify-center z-10",children:e.jsx($e,{showTableSkeleton:!0,tableRows:10,tableColumns:s.length})}),e.jsxs("table",{ref:k,className:d(O,"min-w-full"),children:[e.jsx("thead",{className:z,children:e.jsxs("tr",{children:[f&&e.jsx("th",{className:d(A,"w-12"),children:e.jsx("input",{type:"checkbox",checked:S,ref:v=>{v&&(v.indeterminate=B&&!S)},onChange:v=>ne(v.target.checked),className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),!r&&s.map((v,V)=>e.jsx("th",{className:d(A,"font-semibold text-xs text-text-muted uppercase tracking-label","group",{"text-left":v.align==="left"||!v.align,"text-center":v.align==="center","text-right":v.align==="right","cursor-pointer select-none":v.sortable,[`sticky left-0 ${q}`]:v.sticky==="left",[`sticky right-0 ${q}`]:v.sticky==="right"},V===0&&Ne[K],V===s.length-1&&we[K]),style:{width:v.width},onClick:()=>v.sortable&&T(v.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[v.headerCell?v.headerCell():v.header,v.sortable&&e.jsxs("div",{className:d("flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",W.column===v.id&&"opacity-100"),children:[e.jsx(Nt,{active:W.column===v.id&&W.direction==="asc"}),e.jsx(wt,{active:W.column===v.id&&W.direction==="desc"})]})]})},v.id)),j.length>0&&e.jsx("th",{className:d(A,"w-20"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:y.length===0||r?!r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(f?1:0)+(j.length>0?1:0),className:d(A,"text-center py-8 text-text-muted"),children:g||"No data available"})}):y.map((v,V)=>{const Z=N(v,V),J=h.some((F,le)=>N(F,le)===Z);return e.jsxs("tr",{className:d(ee,{"bg-accent-soft":J},X?.(v,V)),onClick:F=>{F.stopPropagation(),m?.(v,V)},children:[f&&e.jsx("td",{className:A,children:e.jsx("input",{type:"checkbox",checked:J,onChange:F=>{F.stopPropagation(),re(v,F.target.checked)},className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),s.map((F,le)=>{const xe=typeof F.accessor=="function"?F.accessor(v):v[F.accessor];return e.jsx("td",{className:d(A,{"text-left":F.align==="left"||!F.align,"text-center":F.align==="center","text-right":F.align==="right","sticky left-0 bg-surface":F.sticky==="left","sticky right-0 bg-surface":F.sticky==="right"},le===0&&Ne[K],le===s.length-1&&we[K]),children:F.cell?F.cell(xe,v,le):String(xe||"")},F.id)}),j.length>0&&e.jsx("td",{className:A,children:e.jsx(Le,{trigger:e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-1 text-sm text-text-muted hover:text-text",children:[e.jsx("span",{children:"Options"}),e.jsx(Ae,{})]}),options:j.map(F=>({value:F.id,label:F.label,icon:F.icon,disabled:F.disabled?.(v)})),onSelect:F=>{const le=j.find(xe=>xe.id===F);le&&le.onClick(v,V)},placement:"bottom-end"})})]},Z)})})]})]}),l&&G>0&&e.jsxs("div",{className:"flex items-center justify-between px-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-text-muted",children:["Showing ",E," to ",D," of ",G," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-text-muted",children:"Rows per page:"}),e.jsx("select",{value:P.pageSize,onChange:v=>Q(Number(v.target.value)),className:"h-control-sm w-16 rounded-md border border-border bg-surface-input px-2 text-sm text-text",children:u.map(v=>e.jsx("option",{value:v,children:v},v))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>w(0),disabled:P.page===0,iconOnly:!0,children:e.jsx(St,{})}),e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>w(P.page-1),disabled:P.page===0,iconOnly:!0,children:e.jsx(kt,{})}),e.jsxs("span",{className:"px-3 py-1 text-sm text-text-muted",children:["Page ",P.page+1," of ",I]}),e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>w(P.page+1),disabled:P.page>=I-1,iconOnly:!0,children:e.jsx(Ct,{})}),e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>w(I-1),disabled:P.page>=I-1,iconOnly:!0,children:e.jsx(Et,{})})]})]})]})},Mt=i.createContext(null),Dt=({items:t,activeTab:s,onTabChange:r,className:n})=>{const[a,o]=i.useState(t[0]?.id||""),l=s||a,u=x=>{r?r(x):o(x)};return e.jsx("div",{className:d("border-b border-border",n),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(x=>e.jsx("button",{onClick:()=>!x.disabled&&u(x.id),disabled:x.disabled,className:d("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-fast",{"border-accent-border text-text":l===x.id,"border-transparent text-text-muted hover:text-text":l!==x.id&&!x.disabled,"border-transparent text-disabled cursor-not-allowed":x.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[x.label,x.badge&&e.jsx("span",{className:d("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",l===x.id?"bg-accent-soft text-accent":"bg-surface-hover text-text-muted"),children:x.badge})]})},x.id))})})},_e=({items:t,defaultTab:s,activeTab:r,onTabChange:n,variant:a="default",size:o="md",className:l})=>{const[u,x]=i.useState(s||r||t[0]?.id||""),j=r||u,m=g=>{n?n(g):x(g)},f={activeTab:j,setActiveTab:m},h=t.find(g=>g.id===j),p=d("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"},l),N=(g,b)=>{const L="transition-colors duration-fast font-medium",$={"text-xs px-2 py-1":o==="sm","text-sm px-3 py-2":o==="md","text-base px-4 py-3":o==="lg"},K={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},M={"opacity-50 cursor-not-allowed":g.disabled,"cursor-pointer":!g.disabled},X=b?{"border-accent-border text-text":a==="default"||a==="underline","bg-surface text-text shadow-none":a==="pills"}:{},U=!b&&!g.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 d(L,$,K,M,X,U)};return e.jsx(Mt.Provider,{value:f,children:e.jsxs("div",{children:[e.jsx("div",{className:p,role:"tablist",children:t.map(g=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===g.id,"aria-controls":`tabpanel-${g.id}`,disabled:g.disabled,onClick:()=>!g.disabled&&m(g.id),className:N(g,j===g.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[g.label,g.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:g.badge})]})},g.id))}),h?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${j}`,"aria-labelledby":`tab-${j}`,className:"mt-4",children:h.content})]})})},Tt={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function je({open:t,onClose:s,title:r,size:n="md",closeOnBackdropClick:a=!0,closeOnEscape:o=!0,className:l,backdropClassName:u,children:x,footer:j,showCloseButton:m=!0}){const f=i.useRef(null),h=i.useRef(null);i.useEffect(()=>{if(!t||!o)return;const N=g=>{g.key==="Escape"&&s()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[t,o,s]),i.useEffect(()=>(t?(h.current=document.activeElement,f.current&&f.current.focus(),document.body.style.overflow="hidden"):(h.current&&h.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:d("fixed inset-0 z-modal flex items-center justify-center p-4","bg-scrim",u),onClick:p,children:e.jsxs("div",{ref:f,className:d("relative w-full bg-surface rounded-lg shadow-modal","focus:outline-none",Tt[n],l),role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,tabIndex:-1,children:[(r||m)&&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}),m&&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:R.X,size:"lg",color:"current"})})]}),e.jsx("div",{className:"p-6",children:x}),j&&e.jsx("div",{className:"px-6 py-4",children:j})]})}):null}const $t={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Lt={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},At={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"},_t={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"},Rt={tight:"leading-tight",normal:"leading-normal",relaxed:"leading-relaxed"},oe=({variant:t="body",size:s="md",weight:r="normal",color:n="current",align:a="left",truncate:o=!1,italic:l=!1,underline:u=!1,lineHeight:x="normal",as:j,className:m,children:f,...h})=>{const p=j||It(t),N=t==="caption",g=t==="label",b=t==="code",L=d("font-sans",N&&"text-xs text-text-subtle",g&&"text-xs font-semibold uppercase tracking-label text-text-subtle",b&&"font-mono text-sm rounded-sm bg-surface-hover px-1 py-0.5",!N&&!g&&!b&&$t[s],!g&&Lt[r],At[n],_t[a],t==="body"&&Rt[x],l&&"italic",u&&"underline",o&&"truncate",m);return e.jsx(p,{className:L,...h,children:f})};function It(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Re=({value:t,onChange:s,label:r,placeholder:n="Select or upload a file",error:a,disabled:o,accept:l,onListFiles:u,onListMounts:x,onUploadFile:j,onDownloadFile:m,onRegisterFile:f})=>{const[h,p]=i.useState(!1),[N,g]=i.useState([]),[b,L]=i.useState(null),[$,K]=i.useState("/"),[M,X]=i.useState([]),[U,_]=i.useState(!1),[H,W]=i.useState(""),[te,P]=i.useState(typeof t=="object"?t:null),[ae,k]=i.useState(!1),[c,C]=i.useState(""),y=i.useRef(null);i.useEffect(()=>{h&&T()},[h]),i.useEffect(()=>{h&&b&&w()},[h,b,$,H]);const T=async()=>{_(!0);try{const z=await x?.();z?.data&&g(z.data)}catch(z){console.error("Failed to load mounts",z)}finally{_(!1)}},w=async()=>{if(b){_(!0);try{const z=await u?.({mountId:b.id,name:H,path:$});z?.data&&X(z.data)}catch(z){console.error("Failed to load files",z)}finally{_(!1)}}},Q=async z=>{const A=z.target.files?.[0];if(A){_(!0);try{const ee=await A.arrayBuffer(),v=new Uint8Array(ee),V={id:`local-${Date.now()}`,name:A.name,type:"file",path:"/",mimeType:A.type||"application/octet-stream",size:A.size,mountId:"local",providerKey:A.name,ownerId:"me"};P(V),s(V,v),p(!1)}catch(ee){console.error("Local file selection failed",ee)}finally{_(!1)}}},re=async z=>{const A=z.target.files?.[0];if(!(!A||!b)){_(!0);try{const ee=await A.arrayBuffer(),v=await j?.({file:new Uint8Array(ee),filename:A.name,mimeType:A.type||"application/octet-stream",mountId:b.id,path:$});if(v?.data){const V=v.data;P(V),s(V,new Uint8Array(ee)),p(!1)}}catch(ee){console.error("Upload failed",ee)}finally{_(!1)}}},ne=async()=>{if(!(!c||!b)){_(!0);try{const z=`${$}${c}/`;f&&(await f({name:c,type:"folder",path:$,mimeType:"application/x-directory",size:0,mountId:b.id,providerKey:z,ownerId:"me"}),await w()),k(!1),C("")}catch(z){console.error("Failed to create folder",z)}finally{_(!1)}}},G=async z=>{_(!0);try{const A=await m?.(z.id);P(z),s(z,A),p(!1)}catch(A){console.error("Failed to download file",A)}finally{_(!1)}},I=z=>{z.stopPropagation(),P(null),s(null)},E=i.useMemo(()=>{const z=new Set,A=[];return M.forEach(ee=>{if(ee.type==="folder"){ee.path===$&&z.add(ee.name);return}const v=ee.providerKey||ee.name,Z=($?v.substring($.length):v).split("/").filter(J=>J!=="");Z.length>1?z.add(Z[0]):Z.length===1&&A.push(ee)}),{folders:Array.from(z).sort(),files:A.sort((ee,v)=>ee.name.localeCompare(v.name))}},[M,$]),D=z=>{K(A=>`${A}${z}/`)},S=()=>{const z=$.split("/").filter(A=>A!=="");z.pop(),z.length===0?K("/"):K(`${z.join("/")}/`)},B=i.useMemo(()=>{const z=E.folders.map(A=>({id:`folder-${A}`,name:A,type:"folder"}));return E.files.forEach(A=>{z.push({...A,type:"file"})}),z},[E]),O=[{id:"name",header:"Name",accessor:"name",cell:(z,A)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{icon:A.type==="folder"?R.Folder:R.FileText,size:"sm",color:A.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:d(A.type==="folder"&&"font-medium"),children:z})]})},{id:"type",header:"Type",accessor:z=>z.type==="folder"?"Folder":z.mimeType},{id:"size",header:"Size",accessor:z=>z.type==="file"?`${(z.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(z,A)=>e.jsx(se,{size:"sm",variant:"outline",onClick:ee=>{ee.stopPropagation(),A.type==="folder"?D(A.name):G(A)},loading:U&&A.type==="file"&&te?.id===A.id,children:A.type==="folder"?"Open":"Select"})}],q=[{id:"name",header:"Mount Name",accessor:"name",cell:z=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Y,{icon:R.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:z})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(z,A)=>e.jsx(se,{size:"sm",variant:"outline",onClick:()=>L(A),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx(oe,{variant:"label",size:"sm",weight:"medium",children:r}),e.jsxs("div",{onClick:()=>!o&&p(!0),className:d("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",o&&"opacity-50 cursor-not-allowed bg-surface-sunk"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Y,{icon:te?R.FileText:R.HardDrive,color:te?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:te?e.jsx("span",{className:"text-sm text-text font-medium",children:te.name}):e.jsx("span",{className:"text-sm text-text-muted",children:n})}),te&&!o&&e.jsx("button",{onClick:I,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(Y,{icon:R.X,size:"xs"})})]}),a&&e.jsx(oe,{variant:"body",size:"xs",className:"text-danger-fg",children:a}),e.jsx(je,{open:h,onClose:()=>{p(!1),L(null),K("/"),k(!1)},title:b?`Explorer: ${b.name}`:"Select Storage Mount",size:"lg",children:e.jsx(_e,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>{$&&$!=="/"?S():L(null)},leftIcon:e.jsx(Y,{icon:R.ArrowLeft,size:"xs"}),children:$?"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.jsx("div",{className:"flex-grow min-w-40",children:e.jsx(ce,{placeholder:"Search...",value:H,onChange:z=>W(z.target.value),startIcon:e.jsx(R.Search,{size:14}),fullWidth:!0,size:"sm"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:()=>k(!0),leftIcon:e.jsx(Y,{icon:R.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(se,{variant:"primary",size:"sm",onClick:()=>y.current?.click(),leftIcon:e.jsx(Y,{icon:R.Upload,size:"xs"}),loading:U,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:y,onChange:re,accept:l})]})]}),ae&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-surface-sunk rounded-lg border border-border",children:[e.jsx(Y,{icon:R.Folder,size:"sm",color:"warning"}),e.jsx(ce,{size:"sm",placeholder:"Folder name",value:c,onChange:z=>C(z.target.value),autoFocus:!0}),e.jsx(se,{size:"sm",onClick:ne,loading:U,children:"Create"}),e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>k(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(ge,{data:B,columns:O,loading:U,emptyContent:"This folder is empty",onRowClick:z=>z.type==="folder"?D(z.name):G(z)})})]}):e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(ge,{data:N,columns:q,loading:U,emptyContent:"No storage mounts configured",onRowClick:z=>L(z)})})})},{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:R.FileText,size:"xl",color:"primary"})}),e.jsx(oe,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(oe,{variant:"body",size:"sm",className:"text-text-muted mt-1 mb-6 text-center max-w-xs",children:["This file will be used directly in the form and will ",e.jsx("strong",{children:"not"})," be uploaded to platform storage."]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(se,{variant:"primary",size:"lg",loading:U,className:"pointer-events-none",children:"Browse Local File"}),e.jsx("input",{type:"file",className:"hidden",onChange:Q,accept:l,disabled:U})]})]})})}]})})]})},Pt={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"},he=i.forwardRef(({label:t,helperText:s,error:r,size:n="md",fullWidth:a=!1,loading:o=!1,containerClassName:l,labelClassName:u,className:x,id:j,rows:m=4,...f},h)=>{const p=i.useId(),N=j||`textarea-${p}`,g=!!r,b=r||s?`${N}-description`:void 0;return e.jsxs("div",{className:d("flex flex-col",a&&"w-full",l),children:[t&&e.jsx("label",{htmlFor:N,className:d(ze,g?"text-danger-fg":"text-text-subtle",u),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:h,id:N,rows:m,"aria-invalid":g||void 0,"aria-describedby":b,className:d("block w-full resize-y rounded-md 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",Pt[n],g?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",x),...f}),o&&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:b,className:d("mt-1 text-xs",g?"text-danger-fg":"text-text-subtle"),children:r||s})]})});he.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 Ft(t,s,r){const n=s.split("."),a=Array.isArray(t)?[...t]:{...t};let o=a;for(let l=0;l<n.length-1;l++){const u=n[l],x=o[u];o[u]=x&&typeof x=="object"?Array.isArray(x)?[...x]:{...x}:{},o=o[u]}return o[n[n.length-1]]=r,a}function Ot(t,s){const r=s.split("."),n=Array.isArray(t)?[...t]:{...t};let a=n;for(let o=0;o<r.length-1;o++){const l=r[o];if(!a[l]||typeof a[l]!="object")return n;a[l]=Array.isArray(a[l])?[...a[l]]:{...a[l]},a=a[l]}return delete a[r[r.length-1]],n}const Bt=({groups:t,data:s,onSubmit:r,onCancel:n,onChange:a,transform:o,validate:l,submitButton:u={label:"Submit",variant:"primary"},cancelButton:x={label:"Cancel",variant:"outline"},showButtons:j=!0,layout:m="vertical",size:f="md",loading:h=!1,className:p,ref:N,sdk:g})=>{const[b,L]=i.useState(s||{}),[$,K]=i.useState({}),[M,X]=i.useState({});i.useEffect(()=>{s&&L({...s})},[s]);const U=i.useCallback((k,c,C)=>{const y=t.flatMap(T=>T.items).find(T=>T.name===k);if(!y)return null;if(y.required&&(c==null||c===""))return`${y.label} is required`;if(y.type==="array"){if(y.required&&(!c||c.length===0))return`${y.label} cannot be empty.`;if(c&&!Array.isArray(c))return`${y.label} must be an array.`;if(Array.isArray(c)&&y.arrayFields){const T=[];let w=!1;if(c.forEach((Q,re)=>{const ne={};for(const G of y.arrayFields){const I=Q?.[G.name];if(G.required&&(I==null||I===""))ne[G.name]=`${G.label} is required`,w=!0;else if(G.validator){const E=G.validator(I,Q);E&&(ne[G.name]=E,w=!0)}}T[re]=ne}),w)return JSON.stringify(T)}}return y.validator?y.validator(c,C):null},[t]),_=i.useCallback((k,c)=>{let C=Ft(b,k,c);t.flatMap(w=>w.items).find(w=>w.name===k)?.removeIfEmpty&&(c==null||c==="")&&(C=Ot(C,k)),L(C),X(w=>({...w,[k]:!0}));const T=U(k,c,C);K(w=>({...w,[k]:T||""})),a?.(C,k)},[b,t,U,a]),H=i.useCallback(async k=>{if(k.preventDefault(),h)return;const c={},C=t.flatMap(T=>T.items);for(const T of C){if(T.hidden||T.conditional&&!T.conditional(b))continue;const w=U(T.name,ke(b,T.name),b);w&&(c[T.name]=w)}if(l){const T=l(b);T&&Object.assign(c,T)}if(K(c),Object.keys(c).some(T=>c[T]))return;const y=o?o(b):b;await r?.(b,y)},[b,t,U,l,o,r,h]),W=i.useCallback(k=>{const c=ke(b,k.name),C=M[k.name]?$[k.name]:void 0,y=k.disabled||h,T={value:c||"",disabled:y,required:k.required,placeholder:k.placeholder,...k.fieldProps};switch(k.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ce,{...T,onChange:w=>_(k.name,w.target.value),type:k.textType||k.type,autoComplete:k.autocomplete,error:C,size:f});case"textarea":return e.jsx(he,{...T,onChange:w=>_(k.name,w.target.value),rows:4,error:C,size:f});case"select":return e.jsx(ue,{...T,onChange:w=>_(k.name,w),options:(k.options||[]).map(w=>({...w,value:String(w.value)})),searchable:k.searchable,multiple:k.multiple,allowCreate:k.allowCreate,error:C,size:f});case"checkbox":return e.jsx(de,{...T,label:k.label,checked:!!c,onChange:w=>_(k.name,w.target.checked),size:f});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:k.options?.map(w=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 text-base text-text",children:[e.jsx("input",{type:"radio",name:k.name,value:w.value,checked:c===w.value,onChange:()=>_(k.name,w.value),disabled:y||w.disabled,className:"size-checkbox shrink-0 border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),w.label]},w.value))});case"date":return e.jsx(me,{...T,value:c?new Date(c):null,onChange:w=>_(k.name,w),size:f});case"file":return e.jsx(Re,{...T,value:c,onChange:w=>_(k.name,w),error:C,onListFiles:w=>g?.http.invoke({method:"POST",action:"storage.file.list",body:w}),onListMounts:()=>g?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:w=>g?.http.invoke({method:"POST",action:"storage.file.upload",body:w}),onDownloadFile:w=>g?.http.invoke({method:"GET",action:`storage.file.${w}.download`}),onRegisterFile:w=>g?.http.invoke({method:"POST",action:"storage.file.folder",body:w})});case"folder":return e.jsx(Me,{value:c||{},onChange:w=>_(k.name,w),onListFolders:()=>g?.http.invoke({method:"GET",action:"storage.mount"}),disabled:y,size:f,placeholder:k.placeholder});case"custom":return k.customComponent?.({value:c,onChange:w=>_(k.name,w),error:C,disabled:y});case"array":{const w=c||[];let Q=[];if(typeof C=="string"&&C.startsWith("["))try{Q=JSON.parse(C)}catch{}const re=()=>{_(k.name,[...w,{}])},ne=I=>{_(k.name,w.filter((E,D)=>D!==I))},G=(I,E,D)=>{const S=[...w];S[I]={...S[I],[E]:D},_(k.name,S)};return e.jsxs("div",{className:"flex flex-col gap-2",children:[w.map((I,E)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"grid flex-1 gap-2 sm:grid-cols-2",children:k.arrayFields?.map(D=>{const S=Q?.[E]?.[D.name];return e.jsxs("div",{className:"flex flex-col gap-1",children:[E===0&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[D.label,D.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),(()=>{const B={value:I?.[D.name]||"",disabled:y,required:D.required,placeholder:D.placeholder,...D.fieldProps};switch(D.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ce,{...B,onChange:O=>G(E,D.name,O.target.value),type:D.textType||D.type,autoComplete:D.autocomplete,error:S,size:f});case"textarea":return e.jsx(he,{...B,onChange:O=>G(E,D.name,O.target.value),rows:4,error:S,size:f});case"select":return e.jsx(ue,{...B,onChange:O=>G(E,D.name,O),options:(D.options||[]).map(O=>({...O,value:String(O.value)})),searchable:D.searchable,multiple:D.multiple,allowCreate:D.allowCreate,error:S,size:f});case"checkbox":return e.jsx(de,{...B,checked:!!I?.[D.name],onChange:O=>G(E,D.name,O.target.checked),size:f});case"radio":return e.jsx("div",{className:"flex flex-col gap-2",children:D.options?.map(O=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-base text-text",children:[e.jsx("input",{type:"radio",name:`${k.name}.${E}.${D.name}`,value:O.value,checked:I?.[D.name]===O.value,onChange:()=>G(E,D.name,O.value),disabled:y||O.disabled,className:"size-checkbox shrink-0 border border-border-strong bg-surface-input accent-accent focus-visible:outline-none focus-visible:focus-ring"}),O.label]},O.value))});case"date":{const O=I?.[D.name];return e.jsx(me,{...B,value:O?new Date(O):null,onChange:q=>G(E,D.name,q),size:f})}case"custom":return D.customComponent?.({value:I?.[D.name],onChange:O=>G(E,D.name,O),error:S,disabled:y});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",D.type]})}})(),S&&e.jsx("p",{className:"text-xs text-danger-fg",children:S})]},D.name)})}),e.jsx(se,{type:"button",iconOnly:!0,variant:"ghost",size:"md","aria-label":`${k.label} verwijderen`,onClick:()=>ne(E),disabled:y,className:d("shrink-0",E===0&&"mt-5"),children:e.jsx(R.Trash2,{className:"size-icon-md"})})]},E)),e.jsxs(se,{type:"button",variant:"secondary",size:"sm",leftIcon:e.jsx(R.Plus,{className:"size-icon-sm"}),onClick:re,disabled:y,children:[k.label," toevoegen"]})]})}default:return null}},[b,M,$,h,f,_]),te=i.useCallback(k=>{if(k.conditional&&!k.conditional(b))return null;const c=k.items.filter(y=>!(y.hidden||y.conditional&&!y.conditional(b)));if(c.length===0)return null;const C=d(k.layout==="flex"?"flex flex-wrap gap-3":"grid gap-3",k.layout!=="flex"&&{"grid-cols-1":!k.columns||k.columns===1,"grid-cols-2":k.columns===2,"grid-cols-3":k.columns===3,"grid-cols-4":k.columns===4},k.className);return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4 not-first:border-t not-first:border-border-subtle sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"w-full shrink-0 sm:w-form-label",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:k.title}),k.description&&e.jsx("p",{className:"mt-1 text-xs leading-4 text-text-subtle",children:k.description})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:C,children:c.map(y=>{const T=M[y.name]?$[y.name]:void 0;return e.jsxs("div",{className:d("flex min-w-0 flex-col gap-1.5",y.type==="checkbox"&&"justify-center"),style:{width:typeof y.width=="string"?y.width:void 0,gridColumn:typeof y.width=="number"?`span ${y.width} / span ${y.width}`:void 0},children:[y.type!=="custom"&&y.type!=="checkbox"&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-subtle",children:[y.label,y.required&&e.jsx("span",{className:"ml-1 text-danger-fg",children:"*"})]}),W(y),y.help&&!T&&e.jsx("p",{className:"text-xs leading-4 text-text-subtle",children:y.help})]},y.name)})})})]},k.id)},[b,M,$,W]),P=d("overflow-hidden rounded-lg border border-border bg-surface",{"max-w-md":f==="sm","max-w-2xl":f==="md","max-w-4xl":f==="lg","max-w-full":f==="full"},p),ae=f==="full"?"md":f;return e.jsxs("form",{ref:N,onSubmit:H,className:P,children:[!j&&e.jsx("button",{type:"submit",className:"hidden",tabIndex:-1,"aria-hidden":!0}),e.jsx("div",{className:"flex flex-col",children:t.map(te)}),e.jsx("div",{className:"flex items-center gap-2 border-t border-border-subtle bg-surface-sunk px-5 py-3",children:j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ml-auto"}),n&&e.jsx(se,{type:"button",variant:x.variant??"ghost",size:x.size||ae,disabled:x.disabled||h,onClick:n,className:x.className,children:x.label}),e.jsx(se,{type:"submit",variant:u.variant,size:u.size||ae,disabled:u.disabled||h,loading:h,className:u.className,children:u.label})]})})]})};function qt({open:t,title:s,description:r,confirmLabel:n="Bevestigen",cancelLabel:a="Annuleren",tone:o="default",loading:l=!1,onConfirm:u,onCancel:x}){return e.jsx(je,{open:t,onClose:x,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:x,disabled:l,children:a}),e.jsx(se,{variant:o==="danger"?"destructive":"primary",onClick:u,loading:l,children:n})]}),children:r&&e.jsx(oe,{color:"secondary",children:r})})}const Vt={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"},Ht={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},Ut={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 Wt({variant:t="default",size:s="md",dot:r=!1,icon:n,dismissible:a=!1,onDismiss:o,className:l,children:u,...x}){return e.jsxs("span",{className:d("inline-flex items-center font-medium rounded-full",Vt[t],Ht[s],l),...x,children:[r&&e.jsx("span",{className:d("w-2 h-2 rounded-full mr-1.5",Ut[t])}),n&&e.jsx("span",{className:d("flex-shrink-0",u&&"mr-1"),children:n}),u,a&&o&&e.jsx("button",{onClick:o,className:"ml-1.5 flex-shrink-0 hover:opacity-70 transition-opacity","aria-label":"Remove badge",children:e.jsx(Y,{icon:R.X,size:"xs",color:"current"})})]})}const Kt={neutral:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg"};function Gt({icon:t,tone:s="neutral",title:r,description:n,actions:a,card:o=!1,className:l,...u}){return e.jsxs("div",{className:d("flex flex-col items-center gap-2.5 text-center",o&&"rounded-lg border border-border bg-surface px-11 py-9 shadow-overlay",l),...u,children:[t!=null&&e.jsx("span",{className:d("flex size-disc items-center justify-center rounded-full text-2xl",Kt[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 Jt({children:t,className:s,...r}){return e.jsx("kbd",{className:d("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 Yt={sm:"h-1",md:"h-1.5"},Xt={accent:"bg-accent",success:"bg-success"};function Zt({value:t,variant:s="accent",size:r="md",className:n,...a}){const o=Math.max(0,Math.min(100,t));return e.jsx("div",{role:"progressbar","aria-valuenow":Math.round(o),"aria-valuemin":0,"aria-valuemax":100,className:d("w-full overflow-hidden rounded-full bg-surface-hover",Yt[r],n),...a,children:e.jsx("div",{className:d("h-full rounded-full transition-[width] duration-300 ease-out",Xt[s]),style:{width:`${o}%`}})})}const Qt={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"},es={primary:"text-accent",secondary:"text-text-muted",white:"text-white",current:"text-current"},ts={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function ss({size:t="md",variant:s="primary",label:r="Loading...",showLabel:n=!1,className:a,...o}){return e.jsxs("div",{className:d("inline-flex items-center",n?"flex-col space-y-2":"",a),...o,children:[e.jsxs("svg",{className:d("animate-spin",Qt[t],es[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:d("text-text-muted",ts[t]),children:r}),!n&&e.jsx("span",{className:"sr-only",children:r})]})}const rs={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 ns({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:d("inline-block size-dot shrink-0",s==="round"?"rounded-full":"rounded-sm",rs[t],r&&"animate-pulse",a)})}function as({steps:t,current:s,variant:r="numbered",label:n,className:a}){const o=t.indexOf(s),l={role:n?"group":void 0,"aria-label":n,"aria-hidden":n?void 0:!0};return r==="dots"?e.jsx("div",{...l,className:d("flex items-center gap-1.5",a),children:t.map((u,x)=>e.jsx("span",{className:d("h-step-bar rounded-full transition-all duration-fast ease-out",x===o?"w-5 bg-accent":"w-3.5",x<o&&"bg-border-strong",x>o&&"bg-border")},u))}):e.jsx("div",{...l,className:d("flex items-center gap-2",a),children:t.map((u,x)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-current":x===o?"step":void 0,className:d("flex size-tile-sm items-center justify-center rounded-full text-xs font-medium",x===o&&"bg-accent text-accent-fg",x<o&&"bg-accent-soft text-accent",x>o&&"bg-surface-hover text-text-muted"),children:x+1}),x<t.length-1&&e.jsx("span",{className:"h-px w-8 bg-border-strong"})]},u))})}function ls({title:t,icon:s=e.jsx(R.Sparkles,{className:"size-icon-md","aria-hidden":!0}),action:r,children:n,className:a,...o}){return e.jsxs("div",{className:d("flex flex-col gap-2 rounded-xl border p-4","border-assistant-border bg-assistant-soft",a),...o,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 os={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 cs(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 Ie=({name:t,src:s,size:r="sm",className:n,title:a})=>{const[o,l]=i.useState(!1),u=d("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none bg-surface-hover text-text",os[r],n);return s&&!o?e.jsx("img",{src:s,alt:t??"",title:a??t,className:d(u,"object-cover"),onError:()=>l(!0)}):e.jsx("span",{className:u,title:a??t,"aria-label":t,children:cs(t)})},Ce="ring-surface",is="ring-surface-accent",ds=({people:t,max:s=4,size:r="sm",className:n})=>{if(t.length===0)return null;const a=t.slice(0,s),o=t.length-a.length;return e.jsxs("span",{className:d("inline-flex items-center",n),children:[a.map((l,u)=>e.jsx(Ie,{name:l.name,src:l.src,size:r,title:l.name?l.seen===!1?`${l.name} — nog niet gelezen`:l.name:void 0,className:d(u>0&&"-ml-2",l.owner?is:Ce,l.seen===!1&&"opacity-40")},l.id??`${l.name}-${u}`)),o>0&&e.jsxs("span",{className:d("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-surface-hover text-text-muted",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",Ce),children:["+",o]})]})},Se={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"}},us={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 xs({channel:t,children:s,size:r="md",className:n,title:a}){const o=Se[t in Se?t:"note"];return e.jsx("span",{title:a,className:d("inline-flex shrink-0 items-center justify-center font-bold",us[r],o.fg,o.bg,n),children:s})}const fs=({src:t,alt:s,size:r="md",aspectRatio:n="auto",radius:a="md",showLoading:o=!0,showError:l=!0,fallback:u,loadingContent:x,errorContent:j,className:m,onLoad:f,onError:h,...p})=>{const[N,g]=i.useState(!0),[b,L]=i.useState(!1),[$,K]=i.useState(t),M=P=>{g(!1),L(!1),f?.(P)},X=P=>{if(g(!1),L(!0),u&&$!==u){K(u),L(!1),g(!0);return}h?.(P)},U=d("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"},m),_=d("w-full h-full object-cover transition-opacity duration-fast",{"opacity-0":N||b,"opacity-100":!N&&!b}),H=d("absolute inset-0 flex items-center justify-center","text-text-muted"),W=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-surface-hover rounded"})}),te=e.jsxs("div",{className:"text-center",children:[e.jsx(Y,{icon:R.ImageOff,size:"lg",className:"mx-auto mb-1"}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:U,children:[e.jsx("img",{...p,src:$,alt:s,className:_,onLoad:M,onError:X}),N&&o&&e.jsx("div",{className:H,children:x||W}),b&&l&&e.jsx("div",{className:H,children:j||te})]})};function ms({items:t,getRowKey:s,variant:r="divided",leading:n,renderItem:a,trailing:o,onSelect:l,onActiveIndexChange:u,isActive:x,unread:j,dimmed:m,groupBy:f,groups:h,renderGroupHeader:p,stickyGroupHeaders:N=!1,collapsibleGroups:g=!1,hideGroupCount:b=!1,selectable:L=!1,selectedItems:$=[],onSelectionChange:K,bulkActions:M,header:X,stickyHeader:U=!1,bordered:_=!1,emptyContent:H,loading:W=!1,loadingRows:te=4,className:P,"aria-label":ae}){const[k,c]=i.useState(()=>Object.fromEntries((h??[]).filter(S=>S.defaultCollapsed).map(S=>[S.id,!0]))),C=i.useRef(null),y=S=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(S.key))return;const O=Array.from(C.current?.querySelectorAll("li[data-list-row]")??[]);if(O.length===0)return;S.preventDefault();const q=O.indexOf(document.activeElement),z=S.key==="Home"?0:S.key==="End"?O.length-1:S.key==="ArrowDown"?(q+1)%O.length:(q-1+O.length)%O.length;O[z]?.focus()},T=(S,B)=>s?s(S,B):B,w=S=>$.includes(S),Q=(S,B)=>{K&&K(B?[...$,S]:$.filter(O=>O!==S))},re=S=>K?.(S?[...t]:[]),ne=d("flex flex-col",_&&"overflow-hidden rounded-lg border border-border-subtle",P);if(W)return e.jsx("div",{className:ne,children:Array.from({length:te}).map((S,B)=>e.jsxs("div",{className:d("flex animate-pulse items-center gap-3 px-4 py-2",r==="divided"&&B>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-${B}`))});if(t.length===0&&H)return e.jsx("div",{className:ne,children:H});const G=t.length>0&&$.length===t.length,I=$.length>0&&!G,E=(S,B,O)=>{const q=x?.(S,B)??!1,z=j?.(S,B)??!1,A=m?.(S,B)??!1,ee=L&&w(S);return e.jsxs("li",{...l?{role:"button",tabIndex:0,"data-list-row":"","aria-current":q||void 0,onClick:()=>l(S,B),onFocus:()=>u?.(B),onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),l(S,B))}}:{},className:d("flex items-center gap-3 px-4 py-2 text-base","transition-colors duration-fast ease-out",r==="divided"&&!O&&"border-t border-border-subtle",l&&"cursor-pointer focus-visible:outline-none focus-visible:focus-ring",q||ee?"bg-accent-soft text-text":l&&"hover:bg-surface-hover",z&&"font-bold",A&&"opacity-55"),children:[L&&e.jsx("span",{onClick:v=>v.stopPropagation(),children:e.jsx(de,{checked:w(S),onChange:v=>Q(S,v.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(S,B)}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:a?a(S,B):String(S)}),o&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:o(S,B)})]},T(S,B))},D=(()=>{if(!f)return t.map((q,z)=>E(q,z,z===0));const S=new Map;t.forEach((q,z)=>{const A=f(q,z);S.has(A)||S.set(A,[]),S.get(A).push({item:q,index:z})});const B=h??[];return[...B.filter(q=>S.has(q.id)),...[...S.keys()].filter(q=>!B.some(z=>z.id===q)).map(q=>({id:q}))].flatMap((q,z)=>{const A=S.get(q.id)??[],ee=g&&k[q.id],v=q.title??q.id,V=q.count??A.length,Z=e.jsx("li",{onClick:g?()=>c(J=>({...J,[q.id]:!J[q.id]})):void 0,className:d("flex items-center gap-2 bg-surface-sunk px-4 py-1.5","text-xs font-semibold uppercase tracking-label text-text-subtle","border-border-subtle",z>0&&"border-t","border-b",N&&"sticky z-10",g&&"cursor-pointer select-none hover:text-text"),"aria-expanded":g?!ee:void 0,style:N?{top:U?28:0}:void 0,children:p?p(q,A.map(J=>J.item)):e.jsxs(e.Fragment,{children:[g&&e.jsx(R.ChevronRight,{"aria-hidden":!0,className:d("size-icon-sm shrink-0 transition-transform duration-fast ease-out",!ee&&"rotate-90")}),e.jsx("span",{children:v}),!b&&e.jsx("span",{className:"ml-auto font-normal tabular-nums",children:V})]})},`group-${q.id}`);return ee?[Z]:[Z,...A.map(({item:J,index:F},le)=>E(J,F,le===0))]})})();return e.jsxs("div",{ref:C,className:ne,onKeyDown:l?y:void 0,children:[L&&$.length>0&&e.jsxs("div",{className:"flex items-center gap-3 border-b border-border-subtle bg-surface-sunk px-4 py-2",children:[e.jsx(de,{checked:G,indeterminate:I,onChange:S=>re(S.target.checked),"aria-label":"Alles selecteren"}),e.jsxs("span",{className:"text-xs text-text-subtle",children:[$.length," geselecteerd"]}),M&&e.jsx("div",{className:"ml-auto flex gap-2",children:M})]}),X&&e.jsx("div",{className:d("flex items-center gap-3 border-b border-border-subtle px-4 py-1.5","text-xs font-semibold uppercase tracking-label text-text-subtle",U&&"sticky top-0 z-20"),children:X}),e.jsx("ul",{"aria-label":ae,className:"flex flex-col",children:D})]})}function hs({side:t,continued:s=!1,tone:r="default",className:n,children:a}){return e.jsx("div",{className:d("min-w-0 max-w-bubble md:max-w-bubble-md shadow-sm",t==="out"?"rounded-lg rounded-tr-sm":"rounded-lg rounded-tl-sm",r==="note"?"bg-note-soft":"bg-surface",s&&"mt-1",n),children:a})}const bs={default:"text-text",urgent:"text-danger-fg",success:"text-success-fg"};function ps({value:t,label:s,tone:r="default",className:n,...a}){return e.jsxs("div",{className:d("rounded-xl shadow-sm bg-surface px-4 py-3.5",n),...a,children:[e.jsx("div",{className:d("text-2xl font-semibold",bs[r]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:s})]})}const gs=({surface:t=!1,title:s,subtitle:r,meta:n,actions:a=[],children:o,className:l,backLabel:u="Back",backClassName:x,onBack:j,editable:m=!1,onTitleChange:f})=>{const[h,p]=i.useState(!1),[N,g]=i.useState(s),b=i.useRef(null);i.useEffect(()=>{g(s)},[s]),i.useEffect(()=>{h&&b.current&&(b.current.focus(),b.current.select())},[h]);const L=()=>{m&&p(!0)},$=()=>{p(!1),N.trim()!==""&&N!==s&&f?f(N.trim()):g(s)},K=M=>{M.key==="Enter"?b.current?.blur():M.key==="Escape"&&(g(s),p(!1))};return e.jsxs("div",{className:d("p-5 pb-3",t&&"bg-surface border-b border-border",l),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:[j&&e.jsx(se,{variant:"outline",onClick:j,leftIcon:e.jsx(Y,{icon:R.ChevronLeft,size:"sm"}),iconOnly:!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[h?e.jsx("input",{ref:b,type:"text",value:N,onChange:M=>g(M.target.value),onBlur:$,onKeyDown:K,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:L,className:d("text-xl font-semibold truncate",m&&"cursor-pointer"),title:m?"Click to edit":void 0,children:s}),r&&e.jsx("span",{className:"shrink-0 text-base text-text-muted truncate",children:r}),m&&e.jsx(R.Pencil,{size:15,onClick:L,className:"shrink-0 cursor-pointer text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]}),n&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:n})]})]})}),a.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:a.map(M=>M.render?e.jsx(i.Fragment,{children:M.render()},M.id):M.splitOptions&&M.splitOptions.length>0?e.jsx(ve,{label:M.label,onClick:M.onClick,icon:M.icon,variant:M.variant==="primary"?"primary":"outline",options:M.splitOptions,disabled:M.disabled},M.id):e.jsx(se,{variant:M.variant??"secondary",onClick:X=>{X.stopPropagation(),X.target.blur(),M.onClick()},disabled:M.disabled,leftIcon:M.icon,children:M.label},M.id))})]}),o&&e.jsx("div",{className:"mt-4",children:o})]})},vs={none:"p-0",sm:"p-2",md:"p-4",lg:"p-6"},js=({actions:t=[],onBack:s,backLabel:r="Back",className:n,padding:a="md",children:o})=>e.jsxs("div",{className:d("flex items-center gap-2 mb-3",vs[a],n),children:[s&&e.jsx(se,{variant:"secondary",onClick:s,leftIcon:e.jsx(Y,{icon:R.ChevronLeft,size:"sm"}),iconOnly:!0}),o&&e.jsx("div",{className:"flex-1 min-w-0",children:o}),t.length>0&&e.jsx("div",{className:d("flex flex-wrap gap-4",!o&&"ml-auto"),children:t.map(l=>l.splitOptions&&l.splitOptions.length>0?e.jsx(ve,{label:l.label,onClick:l.onClick,icon:l.icon,variant:l.variant==="primary"?"primary":"secondary",options:l.splitOptions,disabled:l.disabled},l.id):e.jsx(se,{variant:l.variant??"secondary",size:"sm",onClick:u=>{u.stopPropagation(),u.target.blur(),l.onClick()},disabled:l.disabled,leftIcon:l.icon,children:l.label},l.id))})]}),ys=/<[a-z][\s\S]*>/i,Ns=["[&_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(" "),ws={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 ks({text:t,className:s,as:r}){const n=t??"";return(r?r==="html":ys.test(n))?e.jsx("div",{className:d("break-words",Ns,s),dangerouslySetInnerHTML:{__html:Oe.sanitize(n,{ADD_ATTR:["target","rel"]})}}):e.jsx("div",{className:d("break-words",s),children:e.jsx(Be,{remarkPlugins:[qe],components:ws,children:n})})}function Cs({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:d("flex items-center py-2",n),children:a}):e.jsxs("div",{className:d("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})]})}function Ss({label:t,description:s,control:r,bordered:n=!1,disabled:a=!1,className:o}){return e.jsxs("div",{className:d("flex items-center justify-between gap-4 py-2",n&&"rounded-lg border border-border px-3",a&&"opacity-50",o),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 Es({icon:t,title:s,description:r,actions:n,children:a,className:o}){return e.jsxs("section",{className:d("flex flex-col gap-2",o),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:d("flex flex-col",t&&"pl-6"),children:a})]})}function zs({label:t,dotColor:s,onClick:r,className:n}){return e.jsxs("button",{type:"button",onClick:r,className:d("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:R.ArrowUpRight,size:"xs",className:"opacity-70"})]})}function Ms(t,s){return s.split(".").reduce((r,n)=>r&&typeof r=="object"&&n in r?r[n]:void 0,t)}const Ds=({groups:t,data:s,size:r="md",className:n})=>{const a=m=>{if(!m)return"-";try{return new Date(m).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(m)}},o=m=>m?"Ja":"Nee",l=(m,f)=>{if(!f)return String(m||"-");const h=f.find(p=>p.value===m);return h?h.label:String(m||"-")},u=i.useCallback(m=>{const f=Ms(s,m.name);if(m.type==="array"){const p=f;return!p||p.length===0?e.jsx(oe,{variant:"body",size:"sm",className:"text-text-muted",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:p.map((N,g)=>e.jsxs("div",{className:"p-4 border border-border rounded-xl space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(oe,{variant:"label",size:"sm",weight:"medium",className:"text-text-muted",children:[m.label," ",g+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:m.arrayFields?.map(b=>{const L=N?.[b.name];let $="-";switch(b.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":$=L||"-";break;case"select":case"radio":$=l(L,b.options);break;case"checkbox":$=o(L);break;case"date":$=a(L);break;case"custom":$=b.customComponent?.({value:L});break;default:$=String(L||"-")}return b.format&&($=b.format(L,N)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(oe,{variant:"label",size:"xs",className:"text-text-muted",children:b.label}),e.jsx(oe,{variant:"body",size:"sm",className:"text-text",children:$})]},b.name)})})]},g))})}if(m.type==="custom"&&m.customComponent)return m.customComponent({value:f});if(m.format){const p=m.format(f,s);return e.jsx(oe,{variant:"body",size:"sm",className:"text-text",children:p})}let h="-";switch(m.type){case"text":case"email":case"password":case"number":case"tel":case"url":h=f?String(f):"-";break;case"textarea":h=f?e.jsx("div",{className:"whitespace-pre-wrap",children:String(f||"-")}):"-";break;case"select":case"radio":h=l(f,m.options);break;case"checkbox":h=o(f);break;case"date":h=a(f);break;default:h=f?String(f):"-"}return e.jsx(oe,{variant:"body",size:"sm",className:"text-text",children:h})},[s]),x=i.useCallback(m=>{if(m.conditional&&!m.conditional(s))return null;const f=m.items.filter(p=>!(p.hidden||p.conditional&&!p.conditional(s)));if(f.length===0)return null;const h=d("space-y-4",{"grid gap-4":m.layout==="grid","flex flex-wrap gap-4":m.layout==="flex"},m.layout==="grid"&&{"grid-cols-1":!m.columns||m.columns===1,"grid-cols-2":m.columns===2,"grid-cols-3":m.columns===3,"grid-cols-4":m.columns===4},m.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 p-6 border border-border rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(oe,{variant:"label",size:"lg",weight:"semibold",className:"text-text",children:m.title}),m.description&&e.jsx(oe,{variant:"body",size:"sm",className:"text-text-muted mt-1",children:m.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:h,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(oe,{variant:"label",size:"sm",className:"font-medium text-text-muted",children:p.label}),u(p)]},p.name))})})]},m.id)},[s,u]),j=d("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:j,children:e.jsx("div",{className:"space-y-8",children:t.map(x)})})},Pe=({item:t,isSelectedHandler:s,onClick:r,depth:n=0})=>{const a=!!(t.children&&t.children.length>0),o=s?s(t.path):!1;if(a)return e.jsxs("li",{children:[e.jsxs("div",{className:d("flex items-center gap-2 px-2 pt-4 pb-1 text-xs font-semibold uppercase tracking-label text-text-subtle"),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-0.5",children:t.children?.map((x,j)=>e.jsx(Pe,{item:x,isSelectedHandler:s,onClick:r,depth:n+1},j))})]});const l=t.action,u=l?.visibility!=="always";return e.jsx("li",{children:e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>t.path&&r?.(t.path),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),t.path&&r?.(t.path))},className:d("group/item flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-base no-underline","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",o?"bg-accent-soft font-semibold text-accent":"text-text-muted hover:bg-surface-hover hover:text-text"),children:[t.icon&&e.jsx("span",{className:"flex w-5 shrink-0 items-center justify-center",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:d("shrink-0 text-xs tabular-nums",o?"rounded-full bg-accent px-2 font-semibold text-accent-fg":"text-text-subtle",l&&u&&"group-hover/item:hidden group-focus-within/item:hidden"),children:t.count}),l&&e.jsx("button",{type:"button","aria-label":l.label,title:l.label,onClick:x=>{x.stopPropagation(),l.onClick()},onKeyDown:x=>x.stopPropagation(),className:d("flex size-5 shrink-0 items-center justify-center rounded","text-text-subtle transition-colors duration-fast ease-out","hover:bg-surface-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:l.icon})]})})},Ts=({title:t,actionIcons:s,items:r,isSelectedHandler:n,onClick:a,preMenuItemsComponent:o})=>e.jsxs("nav",{className:"flex h-full shrink-0 flex-col p-3 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 pb-3",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-lg font-semibold text-text",children:t}),s&&s.length>0&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s.map((l,u)=>e.jsx("span",{className:d("flex h-control-sm w-7 cursor-pointer items-center justify-center rounded-md text-text-strong","transition-colors duration-fast ease-out hover:bg-surface-hover hover:text-text-strong","focus-visible:outline-none focus-visible:focus-ring"),children:l},u))})]}),o&&e.jsx("div",{className:"px-1 pb-3",children:o}),e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:r.map((l,u)=>!l.path&&!l.label&&!l.children?e.jsx("li",{"aria-hidden":!0,className:"h-4"},u):e.jsx(Pe,{item:l,isSelectedHandler:n,onClick:a},u))})]}),$s={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl","3xl":"text-3xl","4xl":"text-3xl"},Ls={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},As={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"},_s={left:"text-left",center:"text-center",right:"text-right"},Rs=({level:t=1,size:s,weight:r="semibold",color:n="current",align:a="left",truncate:o=!1,className:l,children:u,...x})=>{const j=`h${t}`,m=d("font-sans text-pretty",$s[s||Is(t)],Ls[r],As[n],_s[a],o&&"truncate",l);return e.jsx(j,{className:m,...x,children:u})};function Is(t){return{1:"2xl",2:"xl",3:"lg",4:"lg",5:"md",6:"md"}[t]||"md"}const Ps=({commands:t,isOpen:s,onClose:r,labels:n,initialCommandPath:a,initialActiveIndex:o})=>{const[l,u]=i.useState(""),[x,j]=i.useState(a||[]),[m,f]=i.useState(o||0),h=i.useRef(null),p=i.useRef(null),g=(x.length?t.find(b=>b.id===x[0])?.subCommands||[]:t).filter(b=>b.label.toLowerCase().includes(l.toLowerCase()));return i.useEffect(()=>{s||(u(""),j(a||[]),f(o||0))},[s]),i.useEffect(()=>{const b=L=>{if(s){if(L.key==="Escape")r();else if(L.key==="ArrowUp")f($=>$>0?$-1:g.length-1);else if(L.key==="ArrowDown")f($=>$<g.length-1?$+1:0);else if(L.key==="Enter"){const $=g[m];$&&($.subCommands?(j([...x,$.id]),f(0)):$.action&&($.action(),r()))}}};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s,r,g,m,x]),i.useEffect(()=>{const b=L=>{h.current&&!h.current.contains(L.target)&&r()};return s&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s,r]),i.useEffect(()=>{if(!s)return;p.current?.querySelector(`[data-index="${m}"]`)?.scrollIntoView({block:"nearest"})},[m,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:h,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(R.Search,{className:"w-4 h-4 text-text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:n?.searchPlaceholder||"Search commands...",value:l,onChange:b=>u(b.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:[g.length===0&&e.jsx("div",{className:"text-text-muted text-center text-sm",children:n?.noCommandsFound||"No commands found"}),g.map((b,L)=>e.jsxs("div",{"data-index":L,className:`flex items-center p-2 cursor-pointer rounded-md ${L===m?"bg-accent-soft text-accent":"text-text"}`,onClick:()=>{b.subCommands?(j([...x,b.id]),f(0)):b.action&&(b.action(),r())},onMouseEnter:()=>f(L),children:[b.icon&&e.jsx("span",{className:"mr-3",children:b.icon}),e.jsx("span",{className:"flex-grow",children:b.label}),b.subCommands&&e.jsx("span",{className:"text-text-muted",children:e.jsx(R.ChevronRight,{className:"w-4 h-4"})})]},b.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},Fs={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},Os={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},Bs={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"},qs={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},Vs={none:"shadow-none",sm:"shadow-none",md:"shadow-overlay",lg:"shadow-overlay",xl:"shadow-modal","2xl":"shadow-modal"},Hs={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},Us={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"},ye=i.forwardRef(({padding:t,margin:s,background:r,radius:n,shadow:a,border:o,borderColor:l,className:u,children:x,...j},m)=>e.jsx("div",{ref:m,className:d(t&&Fs[t],s&&Os[s],r&&Bs[r],n&&qs[n],a&&Vs[a],o&&Hs[o],l&&Us[l],u),...j,children:x}));ye.displayName="Box";const Ws=({children:t,title:s,...r})=>e.jsxs(ye,{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]});function Ks({identifier:t,resourceLoader:s,framework:r="react",fallback:n,componentProps:a,className:o}){const l=i.useRef(null),[u,x]=i.useState(!0),[j,m]=i.useState(null),f=i.useRef(null);return i.useRef(null),i.useEffect(()=>{let h=!0;return(async()=>{x(!0);try{const N=await s();if(!h)return;const g=N.component||N.default||N;m(r==="react"?()=>g:()=>N)}catch(N){console.error(`[FederatedResource] Load failed: ${t}`,N)}finally{h&&x(!1)}})(),()=>{h=!1}},[t,s]),i.useEffect(()=>{if(u||!j||r==="react")return;const h=l.current;if(h){if(r==="svelte"){const p=j.default||j,N=new p({target:h,props:a||{}});return f.current=N,()=>N.$destroy()}if(j.mount){const p=j.mount({container:h,props:a||{}});return()=>{typeof p=="function"?p():j.unmount?.(h)}}}},[j,r,u]),i.useEffect(()=>{r==="svelte"&&f.current&&f.current.$set?.(a)},[a,r]),e.jsxs("div",{ref:l,className:o,style:{display:"contents"},children:[u&&n,r==="react"&&j&&e.jsx(j,{...a})]})}class Gs extends i.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-on-error rounded hover:opacity-90 transition-opacity text-sm",onClick:()=>this.setState({hasError:!1,error:null}),children:"Try again"})]}):this.props.children}}exports.AssistantCard=ls;exports.Avatar=Ie;exports.AvatarStack=ds;exports.Badge=Wt;exports.Box=ye;exports.Button=se;exports.ButtonGroup=Xe;exports.Card=Ws;exports.ChannelBadge=xs;exports.Checkbox=de;exports.CommandPalette=Ps;exports.ConfirmDialog=qt;exports.ContentLoading=$e;exports.DatePicker=me;exports.Dropdown=Le;exports.EmptyState=Gt;exports.ErrorBoundary=Gs;exports.FederatedResource=Ks;exports.FilterChip=tt;exports.FolderSelect=Me;exports.Form=Bt;exports.Heading=Rs;exports.Icon=Y;exports.Image=fs;exports.Kbd=Jt;exports.KpiCard=ps;exports.Link=at;exports.List=ms;exports.MeetingGrid=Ue;exports.MessageBubble=hs;exports.Modal=je;exports.PageHeader=gs;exports.PageToolbar=js;exports.ParticipantTile=We;exports.Popover=Ee;exports.ProgressBar=Zt;exports.RichText=ks;exports.SearchableTextField=De;exports.SectionDivider=Cs;exports.SegmentedToggle=ot;exports.Select=ue;exports.SettingsRow=Ss;exports.SettingsSection=Es;exports.SidebarMenu=Ts;exports.SourceChip=zs;exports.Spinner=ss;exports.SplitButton=ve;exports.StatusDot=ns;exports.StepIndicator=as;exports.StorageInput=Re;exports.Switch=Te;exports.TabBar=Dt;exports.Table=ge;exports.Tabs=_e;exports.Text=oe;exports.TextArea=he;exports.TextField=ce;exports.VideoSurface=Ke;exports.View=Ds;exports.cn=d;exports.createSizes=He;exports.createVariants=Ve;
|
|
2
3
|
//# sourceMappingURL=index.cjs.map
|