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