@opencxh/ui-kit 3.103.0 → 3.105.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const De=require("clsx"),e=require("react/jsx-runtime"),K=require("lucide-react"),u=require("react");function m(...t){return De.clsx(t)}function Ae(t){return(n,s)=>t[n]?.[s]||""}function Ie(t){return n=>t[n]||""}function ze({tiles:t,pinned:n,className:s}){if(n)return e.jsxs("div",{className:m("flex flex-col md:flex-row gap-2 h-full min-h-0",s),children:[e.jsx("div",{className:"flex-1 min-h-0",children:n}),t.length>0&&e.jsx("div",{className:"flex md:flex-col gap-2 md:w-48 overflow-auto",children:t.map((a,o)=>e.jsx("div",{className:"min-w-[160px] md:min-w-0",children:a},o))})]});const r=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:m("grid gap-2 h-full",r,s),children:t.map((a,o)=>e.jsx("div",{children:a},o))})}function Be({name:t,avatarUrl:n,muted:s,speaking:r,hasVideo:a,videoSlot:o,className:i,fill:p}){return e.jsxs("div",{className:m("relative rounded-lg overflow-hidden bg-gray-800 flex items-center justify-center",p?"h-full w-full":"aspect-video",r&&"ring-2 ring-emerald-400",i),children:[a&&o?e.jsx("div",{className:"absolute inset-0",children:o}):e.jsx("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:n?e.jsx("img",{src:n,alt:t,className:"w-16 h-16 rounded-full object-cover"}):e.jsx("div",{className:"w-16 h-16 rounded-full bg-gray-700 flex items-center justify-center",children:a?e.jsx(K.VideoOff,{className:"w-8 h-8"}):e.jsx(K.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-black/50 text-white text-xs",children:[s?e.jsx(K.MicOff,{className:"w-3 h-3"}):e.jsx(K.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-[140px]",children:t})]})]})}function Pe({attach:t,active:n=!0,mirrored:s=!1,className:r}){const a=u.useRef(null);return u.useEffect(()=>{if(!n||!a.current)return;const o=t(a.current);return()=>{typeof o=="function"&&o(),a.current&&(a.current.innerHTML="")}},[t,n]),e.jsx("div",{ref:a,className:m("w-full h-full bg-gray-900 overflow-hidden",s&&"[&>*]:scale-x-[-1]",r)})}const Re={primary:"btn o__primary",secondary:"btn o__secondary",outline:"btn o__secondary",ghost:"btn o__tertiary",destructive:"btn o__destructive"},_e={xs:"px-2 py-1 text-xs",sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base",xl:"px-8 py-4 text-lg",full:"px-4 py-3 text-base"},Fe={xs:"p-1",sm:"p-1.5",md:"p-2",lg:"p-3",xl:"p-4",full:"p-4"},Z=u.forwardRef(({variant:t="primary",size:n="md",fullWidth:s=!1,loading:r=!1,leftIcon:a,rightIcon:o,iconOnly:i=!1,className:p,children:b,disabled:g,...f},l)=>{const x=g||r;return e.jsxs("button",{ref:l,type:"button",className:m("inline-flex items-center justify-center transition-colors duration-200","disabled:opacity-50 disabled:cursor-not-allowed",Re[t],i?Fe[n]:_e[n],s&&"w-full",r&&"cursor-wait",p),disabled:x,...f,children:[r&&e.jsxs("svg",{className:m("animate-spin",i?"h-4 w-4":"h-4 w-4 mr-2"),fill:"none",viewBox:"0 0 24 24",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"})]}),!r&&a&&e.jsx("span",{className:m("flex-shrink-0",!i&&"mr-2"),children:a}),!i&&b,!r&&o&&e.jsx("span",{className:m("flex-shrink-0",!i&&"ml-2"),children:o}),i&&!r&&!a&&!o&&b]})});Z.displayName="Button";const Oe=({children:t,size:n="md",orientation:s="horizontal",attached:r=!0,className:a})=>{const o=m("inline-flex",{"flex-row":s==="horizontal","flex-col":s==="vertical","[&>*:not(:first-child):not(:last-child)]:rounded-none":r,"[&>*:first-child]:rounded-r-none":r&&s==="horizontal","[&>*:last-child]:rounded-l-none":r&&s==="horizontal","[&>*:first-child]:rounded-b-none":r&&s==="vertical","[&>*:last-child]:rounded-t-none":r&&s==="vertical","[&>*:not(:first-child)]:-ml-px":r&&s==="horizontal","[&>*:not(:first-child)]:-mt-px":r&&s==="vertical","gap-1":!r&&n==="xs","gap-2":!r&&(n==="sm"||n==="md"),"gap-3":!r&&(n==="lg"||n==="xl")},a);return e.jsx("div",{className:o,role:"group",children:t})};function Ve(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function We({label:t,active:n=!1,caret:s=!1,onClear:r,onClick:a,className:o}){return e.jsxs("span",{onClick:a,className:m("inline-flex cursor-pointer select-none items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors",n?"bg-accent-fill text-on-accent":"border border-neutral-emphasis text-muted hover:bg-neutral-container",o),children:[t,s&&e.jsx(Ve,{}),n&&r&&e.jsx("button",{type:"button","aria-label":"Filter wissen",onClick:i=>{i.stopPropagation(),r()},className:"ml-0.5 text-[10px] leading-none opacity-80 hover:opacity-100",children:"✕"})]})}const He=({variant:t="default",size:n="md",color:s="primary",disabled:r=!1,external:a=!1,className:o,children:i,href:p,target:b,rel:g,...f})=>{const l=a||p&&(p.startsWith("http")||p.startsWith("mailto:")),x=m("inline-flex items-center gap-1 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2",{"text-xs":n==="xs","text-sm":n==="sm","text-base":n==="md","text-lg":n==="lg","text-xl":n==="xl"},{"text-link hover:underline":(s==="primary"||s==="info")&&!r,"text-muted hover:text-default":(s==="secondary"||s==="neutral")&&!r,"text-accent hover:underline":s==="accent"&&!r,"text-success hover:underline":s==="success"&&!r,"text-[var(--notice-fill)] hover:underline":s==="warning"&&!r,"text-error hover:underline":s==="error"&&!r},{"":t==="default","text-opacity-70 hover:text-opacity-100":t==="subtle","underline underline-offset-2 decoration-1 hover:decoration-2":t==="underline","px-3 py-1.5 rounded-lg":t==="button","bg-accent-container":t==="button"&&(s==="primary"||s==="accent"),"bg-neutral-container":t==="button"&&(s==="secondary"||s==="neutral"),"bg-success-container":t==="button"&&s==="success","bg-notice-container":t==="button"&&s==="warning","bg-error-container":t==="button"&&s==="error","bg-beta-container":t==="button"&&s==="info"},{"opacity-50 cursor-not-allowed pointer-events-none":r},o),h={...f,href:r?void 0:p,target:l?"_blank":b,rel:l?"noopener noreferrer":g};return e.jsxs("a",{className:x,...h,children:[i,l&&e.jsx("svg",{className:"w-3 h-3 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},qe={sm:"text-xs px-2.5 py-1",md:"text-sm px-3 py-1.5"};function Ge({options:t,value:n,onChange:s,size:r="sm",className:a,"aria-label":o}){return e.jsx("div",{role:"tablist","aria-label":o,className:m("inline-flex gap-0.5 rounded-lg bg-neutral-container p-0.5",a),children:t.map(i=>{const p=i.value===n;return e.jsx("button",{role:"tab","aria-selected":p,type:"button",onClick:()=>s(i.value),className:m("rounded-md font-medium text-default transition-colors",qe[r],p?"bg-module font-ui-650 shadow-lvl-0":"hover:bg-neutral-container-emphasis"),children:i.label},i.value)})})}const ye=({trigger:t,children:n,placement:s="bottom-start",className:r,disabled:a=!1,triggerLabel:o})=>{const[i,p]=u.useState(!1),[b,g]=u.useState({}),f=u.useRef(null),l=u.useRef(null);u.useEffect(()=>{if(!i)return;const w=j=>{f.current&&!f.current.contains(j.target)&&p(!1)},N=j=>{j.key==="Escape"&&p(!1)};return document.addEventListener("mousedown",w),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",N)}},[i]);const x=w=>{if(w.stopPropagation(),!a){if(!i){const N=l.current?.getBoundingClientRect();if(N){const I={};s.startsWith("bottom")?I.top=N.bottom+6:I.bottom=window.innerHeight-N.top+6,s.endsWith("start")?I.left=N.left:I.right=window.innerWidth-N.right,g(I)}}p(N=>!N)}},h=()=>p(!1);return e.jsxs("div",{ref:f,className:"relative inline-flex",children:[e.jsx("button",{ref:l,type:"button",onClick:x,disabled:a,"aria-label":o,"aria-expanded":i,className:m("inline-flex items-center",a&&"opacity-50 cursor-not-allowed"),children:t}),i&&e.jsx("div",{className:m("fixed z-[60] bg-module rounded-[10px] shadow-[var(--shadow-dropdown)] border border-neutral",r),style:b,children:typeof n=="function"?n(h):n})]})},Ke={primary:"btn o__primary",secondary:"btn o__secondary",outline:"btn o__secondary"};function pe({label:t,onClick:n,variant:s="primary",size:r="md",icon:a,options:o,disabled:i=!1,loading:p=!1,menuPlacement:b="bottom-end",menuLabel:g="More options"}){const f=i||p,l=o.length>0;return e.jsxs("div",{className:"inline-flex items-center gap-px",children:[e.jsx(Z,{variant:s,size:r,onClick:n,disabled:i,loading:p,leftIcon:a,className:m(l&&"!rounded-r-none"),children:t}),l&&e.jsx(ye,{placement:b,disabled:f,triggerLabel:g,className:"min-w-[200px] py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:m("inline-flex items-center justify-center transition-colors duration-200",Ke[s],r==="sm"?"px-1.5 py-1.5":"px-2 py-2","!rounded-l-none"),children:e.jsx(K.ChevronDown,{className:"h-4 w-4"})}),children:x=>e.jsx(e.Fragment,{children:o.map(h=>e.jsxs("button",{type:"button",onClick:()=>{h.onClick(),x()},className:m("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors",h.variant==="destructive"?"text-error hover:bg-error-container":"text-default hover:bg-neutral-container"),children:[h.icon&&e.jsx("span",{className:"flex-shrink-0",children:h.icon}),h.label]},h.id))})})]})}const Ue={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},Je={sm:"text-sm",md:"text-sm",lg:"text-base",full:"text-base"},ce=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",indeterminate:a=!1,containerClassName:o,labelClassName:i,className:p,id:b,...g},f)=>{const l=b||`checkbox-${Math.random().toString(36).substr(2,9)}`,x=!!s;return u.useEffect(()=>{f&&typeof f=="object"&&f.current&&(f.current.indeterminate=a)},[a,f]),e.jsxs("div",{className:m("flex flex-col",o),children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex items-center h-5",children:e.jsx("input",{ref:f,id:l,type:"checkbox",className:m("rounded border transition-colors duration-200","focus:ring-2 focus:ring-offset-2 focus:outline-none","disabled:opacity-50 disabled:cursor-not-allowed",Ue[r],x?"border-error [&:not(:checked)]:bg-[var(--base-input)] text-error focus:border-error focus:ring-error":"border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-accent focus:border-[var(--accent-fill)] focus:ring-[var(--accent-fill)]",p),...g})}),t&&e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsx("label",{htmlFor:l,className:m("font-medium cursor-pointer",x?"text-error":"text-default",Je[r],i),children:t}),n&&!s&&e.jsx("p",{className:"mt-1 text-xs text-muted",children:n})]})]}),s&&e.jsx("p",{className:"mt-1 text-xs text-error",children:s})]})});ce.displayName="Checkbox";const Ye=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),Ze=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m15 18-6-6 6-6"})}),Xe=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m9 18 6-6-6-6"})}),ie=u.forwardRef(({value:t,onChange:n,placeholder:s="Select date",disabled:r=!1,required:a=!1,size:o="md",className:i,minDate:p,maxDate:b,format:g="MM/dd/yyyy"},f)=>{const[l,x]=u.useState(!1),[h,w]=u.useState(()=>t||new Date),N=u.useRef(null);u.useEffect(()=>{const $=_=>{N.current&&!N.current.contains(_.target)&&x(!1)};return l&&document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[l]);const j=$=>{if(!$)return"";const _=$.getDate().toString().padStart(2,"0"),O=($.getMonth()+1).toString().padStart(2,"0"),d=$.getFullYear();switch(g){case"dd/MM/yyyy":return`${_}/${O}/${d}`;case"yyyy-MM-dd":return`${d}-${O}-${_}`;case"MM/dd/yyyy":default:return`${O}/${_}/${d}`}},I=()=>{const $=h.getFullYear(),_=h.getMonth(),O=new Date($,_,1),d=new Date(O);d.setDate(d.getDate()-O.getDay());const v=[],E=new Date(d);for(let C=0;C<42;C++)v.push(new Date(E)),E.setDate(E.getDate()+1);return v},y=$=>{$.getMonth()===h.getMonth()&&(p&&$<p||b&&$>b||(n?.($),x(!1)))},H=()=>{w(new Date(h.getFullYear(),h.getMonth()-1,1))},P=()=>{w(new Date(h.getFullYear(),h.getMonth()+1,1))},q=()=>{n?.(null),x(!1)},F=m("w-full border border-neutral rounded-[9px] transition-colors duration-200","bg-module text-default","placeholder:text-muted","focus:outline-none focus:border-[var(--accent-fill)]","disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-module-subtle",{"px-3 py-2 text-sm":o==="sm","px-3 py-2 text-base":o==="md","px-4 py-3 text-lg":o==="lg","px-4 py-3 text-base":o==="full"},i),A=I(),W=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:N,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:f,type:"text",value:j(t??null),placeholder:s,disabled:r,required:a,readOnly:!0,onClick:()=>!r&&x(!l),className:m(F,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!r&&x(!l),disabled:r,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-muted hover:text-muted",children:e.jsx(Ye,{})})]}),l&&e.jsxs("div",{className:"absolute z-50 mt-1 bg-module border border-neutral rounded-[10px] shadow-[var(--shadow-dropdown)] p-4 min-w-[280px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:H,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(Ze,{})}),e.jsxs("h3",{className:"text-sm font-medium text-default",children:[W[h.getMonth()]," ",h.getFullYear()]}),e.jsx("button",{onClick:P,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(Xe,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map($=>e.jsx("div",{className:"text-xs font-medium text-muted text-center py-1",children:$},$))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:A.map(($,_)=>{const O=$.getMonth()===h.getMonth(),d=t&&$.toDateString()===t.toDateString(),v=$.toDateString()===new Date().toDateString(),E=!O||p&&$<p||b&&$>b;return e.jsx("button",{onClick:()=>!E&&y($),disabled:E,className:m("w-8 h-8 text-sm rounded transition-colors duration-200",{"text-default hover:bg-neutral-container":O&&!d&&!E,"bg-accent-fill text-on-accent":d,"bg-neutral-container text-default":v&&!d,"text-muted cursor-not-allowed":E}),children:$.getDate()},_)})}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-neutral",children:[e.jsx("button",{onClick:q,className:"text-sm text-muted hover:text-default",children:"Clear"}),e.jsx("button",{onClick:()=>x(!1),className:"text-sm text-link hover:underline",children:"Close"})]})]})]})}),ae=(...t)=>t.filter(Boolean).join(" "),Qe=t=>e.jsx("svg",{...t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.197 5.197a7.5 7.5 0 0 0 10.606 10.606Z"})}),et=t=>e.jsx("svg",{...t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})}),tt={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},me={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},Ne=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:a=!1,startIcon:o=e.jsx(Qe,{}),loading:i=!1,containerClassName:p,labelClassName:b,className:g,id:f,options:l,onRemoteSearch:x,onSelect:h,debounceTime:w=500,showAllOnOpen:N=!1,value:j,onChange:I,...y},H)=>{const P=f||`searchfield-${Math.random().toString(36).substr(2,9)}`,q=!!s,F=u.useRef(null),A=u.useRef(null),[W,$]=u.useState(j||""),[_,O]=u.useState(!1),[d,v]=u.useState(!1),[E,C]=u.useState(!1);u.useEffect(()=>{j!==void 0&&$(j)},[j]);const L=u.useMemo(()=>{if(N&&!E||!W)return l;const T=String(W).toLowerCase();return l.filter(D=>String(D.label).toLowerCase().includes(T))},[W,l,N,E]);u.useEffect(()=>{if(!x||!W){v(!1);return}const T=setTimeout(async()=>{v(!0);try{await x(String(W))}catch(D){console.error("Remote search failed:",D)}finally{v(!1)}},w);return()=>{clearTimeout(T),v(!1)}},[W,w,x]),u.useEffect(()=>{const T=D=>{F.current&&!F.current.contains(D.target)&&O(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=T=>{const D=T.target.value;$(D),O(!0),C(!0),I&&I(T)},X=T=>{$(T.label),O(!1),C(!1),h&&h(T.value)},ee=()=>{(l.length>0||x)&&(O(!0),C(!1))},Y=i||d,M=_&&(L.length>0||Y),z=u.useMemo(()=>H||A,[H]);return e.jsxs("div",{className:ae("flex flex-col",a?"w-full":"",p||"","relative"),ref:F,children:[t&&e.jsx("label",{htmlFor:P,className:ae("block text-sm font-medium mb-1",q?"text-error":"text-default",b||""),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:ae("text-muted",me[r]),children:o})}),e.jsx("input",{ref:z,id:P,value:W,onChange:S,onFocus:ee,className:ae("block w-full rounded-lg border transition-colors duration-200 bg-input","placeholder:text-[var(--text-muted)] focus:outline-none","disabled:opacity-50 disabled:cursor-not-allowed",tt[r],o?"pl-10":"","pr-10",q?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default",g||""),...y}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:Y||i?e.jsxs("svg",{className:ae("animate-spin text-link",me[r]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",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"})]}):e.jsx(et,{className:ae("text-muted cursor-pointer transition-transform",me[r],_?"rotate-180":"rotate-0"),onClick:()=>{O(T=>(T||C(!1),!T))}})})]}),M&&e.jsx("ul",{className:"absolute z-10 mt-1 w-full bg-module border border-neutral rounded-lg shadow-lg max-h-60 overflow-auto top-full",role:"listbox",children:L.length>0?L.map(T=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-default hover:bg-accent-container hover:text-accent transition-colors",onClick:()=>X(T),role:"option","aria-selected":W===T.label,children:T.label},T.value)):e.jsx("li",{className:"px-4 py-2 text-muted",children:Y||i?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(s||n)&&e.jsx("p",{className:ae("mt-1 text-xs",q?"text-error":"text-muted"),children:s||n}),x&&e.jsxs("p",{className:"mt-2 text-xs text-success",children:["Huidige zoekterm (niet-gedebounced): ",String(W)]})]})});Ne.displayName="SearchableTextField";const st={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},oe=t=>t.trim().toLowerCase(),le=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:a=!1,options:o,placeholder:i,containerClassName:p,labelClassName:b,className:g,id:f,searchable:l,multiple:x,value:h,onChange:w,allowCreate:N,onCreateOption:j,...I},y)=>{const H=f||`select-${Math.random().toString(36).substr(2,9)}`,P=!!s,[q,F]=u.useState(!1),[A,W]=u.useState(""),$=u.useRef(null),[_,O]=u.useState(o);u.useImperativeHandle(y,()=>$.current),u.useEffect(()=>{const M=z=>{$.current&&!$.current.contains(z.target)&&F(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const d=u.useCallback((M,z)=>M.some(T=>oe(T.value)===oe(z)||oe(T.label)===oe(z)),[]),v=u.useCallback((M,z)=>{const T=[...M],D=Q=>{const te=(Q??"").trim();te&&(d(T,te)||T.push({value:te,label:te}))};return Array.isArray(z)?z.forEach(D):D(z),T},[d]);u.useEffect(()=>{O(M=>{const z=[...o];return M.forEach(T=>{!d(z,T.value)&&!d(z,T.label)&&z.push(T)}),v(z,h)})},[o,h,v,d]);const E=M=>{if(x){const z=Array.isArray(h)?h:[],T=z.includes(M)?z.filter(D=>D!==M):[...z,M];w?.(T)}else w?.(M),F(!1),W("")},C=x?null:_.find(M=>M.value===h),L=x?_.filter(M=>Array.isArray(h)&&h.includes(M.value)):[],S=l&&A?_.filter(M=>M.label.toLowerCase().includes(A.toLowerCase())):_,X=!!N&&!!l&&!!A.trim()&&!d(_,A),ee=M=>{const z=M.trim();if(!z)return;const T=j?.(z)??{value:z,label:z};if(d(_,T.value)||d(_,T.label)){E(T.value),W(""),x||F(!1);return}O(D=>[...D,T]),E(T.value),W(""),x||F(!1)},Y=()=>x?L.length>0?L.map(M=>M.label).join(", "):i||"Select options":C?.label||i||"Select an option";return e.jsxs("div",{ref:$,className:m("relative flex flex-col",a&&"w-full",p),...I,children:[t&&e.jsx("label",{htmlFor:H,onClick:()=>F(!q),className:m("block text-[10.5px] font-ui-650 uppercase tracking-[0.08em] mb-1.5",P?"text-error":"text-muted",b),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",id:H,onClick:()=>F(!q),className:m("flex w-full items-center justify-between gap-2 rounded-[9px] border transition-colors duration-200 text-left","focus:outline-none focus:border-[var(--accent-fill)] focus:ring-0 focus:ring-offset-0","disabled:opacity-50 disabled:cursor-not-allowed","bg-module",st[r],P?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default",g),children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:Y()}),e.jsx(K.ChevronDownIcon,{size:16,className:m("shrink-0 opacity-60 transition-transform duration-200",q&&"rotate-180")})]}),q&&e.jsxs("div",{className:"absolute z-10 mt-1 w-full rounded-[10px] bg-module shadow-[var(--shadow-dropdown)] border border-neutral",children:[l&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:A,onChange:M=>W(M.target.value),onKeyDown:M=>{M.key==="Enter"&&X&&(M.preventDefault(),ee(A))},className:m("w-full px-3 py-2 text-sm rounded-md border","text-default border-neutral focus:outline-none focus:ring-0")})}),X&&e.jsxs("div",{className:m("px-4 py-2 text-sm cursor-pointer","text-link hover:bg-neutral-container"),onClick:()=>ee(A),children:["+: “",A.trim(),"”"]}),e.jsxs("ul",{className:"max-h-60 overflow-auto py-1",children:[i&&!x&&e.jsx("li",{className:"px-4 py-2 text-sm text-muted cursor-pointer hover:bg-neutral-container",onClick:()=>{w?.(""),F(!1)},children:i}),S.map(M=>{const z=x?Array.isArray(h)&&h.includes(M.value):h===M.value;return e.jsx("li",{onClick:()=>!M.disabled&&E(M.value),className:m("px-4 py-2 text-sm cursor-pointer","text-default",M.disabled?"opacity-50 cursor-not-allowed":"hover:bg-neutral-container",z&&"bg-accent-container text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[x&&e.jsx("input",{type:"checkbox",checked:z,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-accent focus:ring-[var(--accent-fill)]"}),e.jsx("span",{children:M.label})]})},M.value)})]})]})]}),(s||n)&&e.jsx("p",{className:m("mt-1 text-xs",P?"text-error":"text-muted"),children:s||n})]})});le.displayName="Select";const rt={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-4 py-3 text-base",full:"px-4 py-3 text-base"},de=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:a=!1,loading:o=!1,containerClassName:i,labelClassName:p,className:b,id:g,rows:f=4,...l},x)=>{const h=g||`textarea-${Math.random().toString(36).substr(2,9)}`,w=!!s;return e.jsxs("div",{className:m("flex flex-col",a&&"w-full",i),children:[t&&e.jsx("label",{htmlFor:h,className:m("block text-[10.5px] font-ui-650 uppercase tracking-[0.08em] mb-1.5",w?"text-error":"text-muted",p),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:x,id:h,rows:f,className:m("block w-full rounded-lg border transition-colors duration-200 resize-vertical bg-input","placeholder:text-[var(--text-muted)] focus:outline-none focus:ring-0","disabled:opacity-50 disabled:cursor-not-allowed",rt[r],w?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default",b),...l}),o&&e.jsx("div",{className:"absolute top-3 right-3",children:e.jsxs("svg",{className:"animate-spin h-4 w-4 text-muted",fill:"none",viewBox:"0 0 24 24",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"})]})})]}),(s||n)&&e.jsx("p",{className:m("mt-1 text-xs",w?"text-error":"text-muted"),children:s||n})]})});de.displayName="TextArea";const nt={sm:"px-3 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3 py-2 text-sm",full:"px-3 py-2 text-sm"},fe={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},ne=u.forwardRef(({label:t,helperText:n,error:s,size:r="md",fullWidth:a=!1,startIcon:o,endIcon:i,loading:p=!1,containerClassName:b,labelClassName:g,className:f,id:l,...x},h)=>{const w=l||`textfield-${Math.random().toString(36).substr(2,9)}`,N=!!s;return e.jsxs("div",{className:m("flex flex-col",a&&"w-full",b),children:[t&&e.jsx("label",{htmlFor:w,className:m("block text-[10.5px] font-ui-650 uppercase tracking-[0.08em] mb-1.5",N?"text-error":"text-muted",g),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:m("text-muted",fe[r]),children:o})}),e.jsx("input",{ref:h,id:w,className:m("block w-full rounded-lg border transition-colors duration-200 bg-input","placeholder:text-[var(--text-muted)] focus:outline-none focus:ring-1 focus:ring-offset-0","disabled:opacity-50 disabled:cursor-not-allowed",nt[r],o&&"pl-10",i&&"pr-10",N?"border-error text-error focus:border-error focus:ring-error":"border-neutral text-default focus:border-[var(--accent-fill)] focus:ring-[var(--accent-fill)]",f),...x}),(i||p)&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:p?e.jsxs("svg",{className:m("animate-spin text-muted",fe[r]),fill:"none",viewBox:"0 0 24 24",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"})]}):i&&e.jsx("span",{className:m("text-muted",fe[r]),children:i})})]}),(s||n)&&e.jsx("p",{className:m("mt-1 text-xs",N?"text-error":"text-muted"),children:s||n})]})});ne.displayName="TextField";const re=({icon:t,size:n="md",color:s="current",clickable:r=!1,onClick:a,className:o,"aria-label":i,...p})=>{const b=typeof n=="number"?n:at(n),g=m("inline-block",{"text-default":s==="primary","text-muted":s==="secondary","text-accent":s==="accent","text-success":s==="success","text-warning":s==="warning","text-error":s==="error","text-info":s==="info","text-neutral":s==="neutral","text-current":s==="current"},{"cursor-pointer hover:opacity-80 transition-opacity duration-200":r,"focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[var(--accent-border)] rounded":r},o),f={size:b,className:g,onClick:r?a:void 0,"aria-label":i,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:r?l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),a?.())}:void 0,...p};return e.jsx(t,{...f})};function at(t){return{xs:12,sm:16,md:20,lg:24,xl:32}[t]}function we({children:t,showTableSkeleton:n=!1,tableColumns:s=6,tableRows:r=8}){return t?e.jsx("main",{className:"flex-1 bg-module p-6",children:e.jsx("div",{className:"w-full max-w-6xl mx-auto animate-pulse",children:t})}):e.jsx("main",{className:"flex-1 bg-module p-6",children:e.jsxs("div",{className:"w-full mx-auto space-y-6 animate-pulse",children:[!n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-6 bg-neutral-container-emphasis rounded w-1/4"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-1/2"})]})]}),n&&e.jsxs("div",{className:"rounded-lg overflow-hidden",children:[e.jsx("div",{className:`grid grid-cols-${s} gap-2 bg-neutral-container p-3`,children:Array.from({length:s}).map((a,o)=>e.jsx("div",{className:"h-4 bg-neutral-border-emphasis rounded w-2/3"},`header-${o}`))}),Array.from({length:r}).map((a,o)=>e.jsx("div",{className:`grid grid-cols-${s} gap-2 p-3 border-t border-neutral`,children:Array.from({length:s}).map((i,p)=>e.jsx("div",{className:"h-4 bg-neutral-container-emphasis rounded w-full"},`cell-${o}-${p}`))},`row-${o}`))]})]})})}const ke=({trigger:t,options:n,value:s,onSelect:r,placement:a="bottom-start",disabled:o=!1,className:i,showCheck:p=!0,header:b})=>{const[g,f]=u.useState(!1),[l,x]=u.useState(null),[h,w]=u.useState({top:0,left:0}),[N,j]=u.useState({}),I=u.useRef(null),y=u.useRef(null),H=u.useRef(null),P=u.useRef(null);u.useEffect(()=>{const d=v=>{I.current&&(!I.current.contains(v.target)||H.current&&!H.current.contains(v.target))&&(f(!1),x(null),P.current&&(clearTimeout(P.current),P.current=null))};return g&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[g]),u.useEffect(()=>{const d=v=>{v.key==="Escape"&&(f(!1),x(null),P.current&&(clearTimeout(P.current),P.current=null))};return g&&document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[g]),u.useEffect(()=>{if(l&&I.current){const d=I.current.querySelector(`[data-option-value="${l}"]`);if(d){const v=d.getBoundingClientRect();w({top:v.top,left:v.right+8})}}},[l]),u.useEffect(()=>()=>{P.current&&clearTimeout(P.current)},[]);const q=d=>{if(d.stopPropagation(),!o){if(!g){const v=y.current?.getBoundingClientRect();if(v){const C={};a.startsWith("bottom")?C.top=v.bottom+6:C.bottom=window.innerHeight-v.top+6,a.endsWith("start")?C.left=v.left:C.right=window.innerWidth-v.right,j(C)}}f(!g),x(null),P.current&&(clearTimeout(P.current),P.current=null)}},F=(d,v,E)=>{d.stopPropagation(),!v.disabled&&!v.divider&&(!v.children||v.children.length===0)&&(r?.(v.value,E),f(!1),x(null))},A=d=>{P.current&&(clearTimeout(P.current),P.current=null),d.children&&d.children.length>0?x(d.value):x(null)},W=d=>{d.children&&d.children.length>0?P.current=setTimeout(()=>{x(null)},150):x(null)},$=(d,v,E)=>{d.stopPropagation(),!v.disabled&&!v.divider&&(r?.(v.value,E),f(!1),x(null))},_=m("fixed z-[60] min-w-[200px] bg-module rounded-[10px] shadow-[var(--shadow-dropdown)] border border-neutral","max-h-60 overflow-auto"),O=m("fixed z-[60] min-w-[200px] bg-module rounded-[10px] shadow-[var(--shadow-dropdown)] border border-neutral","max-h-60 overflow-auto");return e.jsxs("div",{ref:I,className:m("relative flex flex-row items-center justify-center rounded-lg hover:bg-neutral-container",i),children:[e.jsx("button",{ref:y,onClick:q,disabled:o,className:m("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":o}),children:t}),g&&e.jsx("div",{className:_,style:N,children:e.jsxs("div",{className:"p-2",children:[b&&(typeof b=="string"?e.jsx("div",{className:"text-xs font-medium text-muted uppercase tracking-wider px-3 py-2",children:b}):b),n.map((d,v)=>{if(d.divider)return e.jsx("div",{className:"border-t border-neutral my-2"},`divider-${v}`);const E=d.children&&d.children.length>0,C=l===d.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":d.value,onClick:L=>F(L,d),onMouseEnter:()=>A(d),onMouseLeave:()=>W(d),disabled:d.disabled,className:m("w-full flex items-center justify-between px-3 py-2 text-sm text-default hover:bg-neutral-container rounded-md transition-colors",{"opacity-50 cursor-not-allowed":d.disabled,"bg-neutral-container":C&&E}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[d.icon&&e.jsx("span",{className:"flex-shrink-0",children:d.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:d.label}),d.description&&e.jsx("span",{className:"text-xs text-muted",children:d.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[p&&s===d.value&&e.jsx("span",{className:"h-4 w-4 text-success flex-shrink-0 text-sm font-bold",children:"✓"}),E&&e.jsx("span",{className:"text-muted text-xs",children:"▶"})]})]}),E&&C&&e.jsx("div",{ref:H,className:O,style:{top:`${h.top}px`,left:`${h.left}px`},onMouseEnter:()=>{P.current&&(clearTimeout(P.current),P.current=null),x(d.value)},onMouseLeave:()=>{P.current=setTimeout(()=>{x(null)},150)},children:e.jsx("div",{className:"p-2",children:d.children.map((L,S)=>{if(L.divider)return e.jsx("div",{className:"border-t border-neutral my-2"},`divider-${S}`);const X=typeof s=="object"&&s[d.value]&&s[d.value].includes(L.value)||s===L.value;return e.jsxs("button",{onClick:ee=>$(ee,L,d.value),disabled:L.disabled,className:m("w-full flex items-center justify-between px-3 py-2 text-sm text-default hover:bg-neutral-container rounded-md transition-colors",{"opacity-50 cursor-not-allowed":L.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[L.icon&&e.jsx("span",{className:"flex-shrink-0",children:L.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:L.label}),L.description&&e.jsx("span",{className:"text-xs text-muted",children:L.description})]})]}),p&&X&&e.jsx("span",{className:"h-4 w-4 text-success flex-shrink-0 text-sm font-bold",children:"✓"})]},L.value)})})})]},d.value)}),(()=>{const d=n.reduce((v,E)=>{if(E.divider)return v;const C=E.children?E.children.filter(L=>!L.divider).length:0;return v+1+C},0);return d>1&&e.jsx("div",{className:"border-t border-neutral mt-2 pt-2",children:e.jsxs("div",{className:"text-xs text-muted px-3 py-1",children:[d," options available"]})})})()]})})]})},lt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ot=({active:t})=>e.jsx("svg",{className:m("h-3 w-3",t?"text-default":"text-muted"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m18 15-6-6-6 6"})}),ct=({active:t})=>e.jsx("svg",{className:m("h-3 w-3",t?"text-default":"text-muted"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m6 9 6 6 6-6"})}),it=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m15 18-6-6 6-6"})}),dt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m9 18 6-6-6-6"})}),ut=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m11 17-5-5 5-5m6 10-5-5 5-5"})}),xt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m7 17 5-5-5-5m6 10 5-5-5-5"})}),Ce=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m6 9 6 6 6-6"})}),mt=t=>{const n=r=>t.multiSelect&&Array.isArray(t.value)?t.value?.includes(r):t.value===r,s=r=>{t.multiSelect&&Array.isArray(t.value)?t.onChange(t.value.filter(a=>a!==r)):t.onChange(r)};return t.type==="date"?e.jsx("div",{className:"flex items-center space-x-1 max-w-[160px]",children:e.jsx(ie,{size:"sm",value:t.value,onChange:r=>t.onChange(r),placeholder:t.placeholder||`Select ${t.label.toLowerCase()}`,className:"min-w-[160px] btn btn o__secondary"})}):e.jsx("div",{className:"flex items-center space-x-1 max-w-[240px]",children:e.jsx("div",{className:"relative",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex items-center space-x-2 cursor-pointer rounded-full px-3 py-2 text-sm btn btn o__secondary",children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:"text-default",children:t.multiSelect&&Array.isArray(t.value)?t.value?.map(r=>t.options?.find(a=>a.value===r)?.label).join(", "):t.options?.find(r=>r.value===t.value)?.label}),e.jsx("span",{className:"text-muted text-sm group-open:rotate-180 transition-transform",children:e.jsx(Ce,{})})]}),e.jsxs("div",{className:"absolute z-10 left-0 mt-1 bg-module border border-neutral rounded-[10px] shadow-[var(--shadow-dropdown)] p-2 w-48",children:[t.options?.map(r=>e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-neutral-container text-sm text-default flex items-center space-x-2",onClick:()=>s(r.value),children:e.jsx("span",{className:m(n(r.value)&&"text-accent"),children:r.label})},r.value)),t.value&&e.jsx("button",{className:"w-full text-left px-3 py-2 rounded-md hover:bg-neutral-container text-sm text-default flex items-center space-x-2 mt-2",onClick:()=>s(null),children:e.jsx("span",{className:"text-muted",children:"Clear filter"})})]})]})})})},he=({data:t,columns:n,loading:s=!1,searchable:r=!1,searchPlaceholder:a="Search...",filters:o=[],paginated:i=!1,pageSizeOptions:p=[10,25,50,100],defaultPageSize:b=10,actions:g=[],onRowClick:f,selectable:l=!1,selectedRows:x=[],onSelectionChange:h,getRowKey:w=(q,F)=>F,emptyContent:N,hoverable:j=!0,bordered:I=!1,striped:y=!1,className:H,rowClassName:P})=>{const[q,F]=u.useState(""),[A,W]=u.useState({column:null,direction:null}),[$,_]=u.useState({page:0,pageSize:b}),O=u.useRef(null),d=u.useMemo(()=>{let c=t;if(r&&q.trim()){const k=n.filter(V=>V.searchable!==!1),R=q.toLowerCase();c=c.filter(V=>k.some(B=>{const U=typeof B.accessor=="function"?B.accessor(V):V[B.accessor];return String(U||"").toLowerCase().includes(R)}))}return o.forEach(k=>{k.value&&k.value!=="all"&&(c=c.filter(R=>{const V=n.find(U=>U.id===k.id);if(!V)return!0;const B=typeof V.accessor=="function"?V.accessor(R):R[V.accessor];return String(B||"")===k.value}))}),c},[t,q,n,r,o]),v=u.useMemo(()=>{if(!A.column||!A.direction)return d;const c=n.find(k=>k.id===A.column);return c?[...d].sort((k,R)=>{const V=typeof c.accessor=="function"?c.accessor(k):k[c.accessor],B=typeof c.accessor=="function"?c.accessor(R):R[c.accessor];let U=0;return V<B?U=-1:V>B&&(U=1),A.direction==="desc"?-U:U}):d},[d,A,n]),E=u.useMemo(()=>{if(!i)return v;const c=$.page*$.pageSize,k=c+$.pageSize;return v.slice(c,k)},[v,$,i]),C=u.useCallback(c=>{n.find(R=>R.id===c)?.sortable&&W(R=>R.column!==c?{column:c,direction:"asc"}:R.direction==="asc"?{column:c,direction:"desc"}:{column:null,direction:null})},[n]),L=u.useCallback(c=>{_(k=>({...k,page:c}))},[]),S=u.useCallback(c=>{_({page:0,pageSize:c})},[]),X=u.useCallback((c,k)=>{if(!h)return;const R=w(c,0);x.map((V,B)=>w(V,B)),h(k?[...x,c]:x.filter((V,B)=>w(x[B],B)!==R))},[x,h,w]),ee=u.useCallback(c=>{h&&h(c?[...E]:[])},[E,h]);u.useEffect(()=>{_(c=>({...c,page:0}))},[q,A]),u.useEffect(()=>{_(c=>({...c,page:0}))},[o.map(c=>c.value).join(",")]);const Y=v.length,M=Math.ceil(Y/$.pageSize),z=$.page*$.pageSize+1,T=Math.min(z+$.pageSize-1,Y),D=E.length>0&&E.every(c=>{const k=w(c,0);return x.some((R,V)=>w(R,V)===k)}),Q=E.some(c=>{const k=w(c,0);return x.some((R,V)=>w(R,V)===k)}),te=m("w-full text-sm leading-5 text-[var(--text-default)] border-collapse",H),G=m("bg-[var(--base-module)]"),se=m("text-[var(--text-default)] p-3 border-b border-[var(--neutral-border)]"),ue=m("h-12",{"hover:bg-[var(--neutral-container)] dark:hover:bg-[var(--neutral-container-emphasis)]":j,"cursor-pointer":f});return e.jsxs("div",{className:"space-y-4",children:[(r||o.length>0)&&e.jsx("div",{className:"pt-4 pb-2",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-start",children:[o.map(c=>e.jsx(mt,{...c},c.id)),e.jsx("div",{className:"w-full sm:w-auto sm:ml-auto min-w-[200px]",children:e.jsx(ne,{placeholder:a,value:q,onChange:c=>F(c.target.value),startIcon:e.jsx(lt,{}),className:"max-w-sm"})})]})}),e.jsxs("div",{className:"relative w-full overflow-x-auto min-h-[400px]",children:[s&&e.jsx("div",{className:"flex items-center justify-center z-10",children:e.jsx(we,{showTableSkeleton:!0,tableRows:10,tableColumns:n.length})}),e.jsxs("table",{ref:O,className:m(te,"min-w-full"),children:[e.jsx("thead",{className:G,children:e.jsxs("tr",{children:[l&&e.jsx("th",{className:m(se,"w-12"),children:e.jsx("input",{type:"checkbox",checked:D,ref:c=>{c&&(c.indeterminate=Q&&!D)},onChange:c=>ee(c.target.checked),className:"rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-accent"})}),!s&&n.map(c=>e.jsx("th",{className:m(se,"font-semibold text-xs text-[var(--text-muted)] uppercase tracking-wider","group",{"text-left":c.align==="left"||!c.align,"text-center":c.align==="center","text-right":c.align==="right","cursor-pointer select-none":c.sortable,"sticky left-0 bg-module":c.sticky==="left","sticky right-0 bg-module":c.sticky==="right"}),style:{width:c.width},onClick:()=>c.sortable&&C(c.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[c.headerCell?c.headerCell():c.header,c.sortable&&e.jsxs("div",{className:m("flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",A.column===c.id&&"opacity-100"),children:[e.jsx(ot,{active:A.column===c.id&&A.direction==="asc"}),e.jsx(ct,{active:A.column===c.id&&A.direction==="desc"})]})]})},c.id)),g.length>0&&e.jsx("th",{className:m(se,"w-20"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:E.length===0||s?!s&&e.jsx("tr",{children:e.jsx("td",{colSpan:n.length+(l?1:0)+(g.length>0?1:0),className:m(se,"text-center py-8 text-muted"),children:N||"No data available"})}):E.map((c,k)=>{const R=w(c,k),V=x.some((B,U)=>w(B,U)===R);return e.jsxs("tr",{className:m(ue,{"bg-accent-container":V},P?.(c,k)),onClick:B=>{B.stopPropagation(),f?.(c,k)},children:[l&&e.jsx("td",{className:se,children:e.jsx("input",{type:"checkbox",checked:V,onChange:B=>{B.stopPropagation(),X(c,B.target.checked)},className:"rounded border-neutral [&:not(:checked)]:bg-[var(--base-input)] text-accent"})}),n.map(B=>{const U=typeof B.accessor=="function"?B.accessor(c):c[B.accessor];return e.jsx("td",{className:m(se,{"text-left":B.align==="left"||!B.align,"text-center":B.align==="center","text-right":B.align==="right","sticky left-0 bg-module":B.sticky==="left","sticky right-0 bg-module":B.sticky==="right"}),children:B.cell?B.cell(U,c,k):String(U||"")},B.id)}),g.length>0&&e.jsx("td",{className:se,children:e.jsx(ke,{trigger:e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-1 text-sm text-muted hover:text-default",children:[e.jsx("span",{children:"Options"}),e.jsx(Ce,{})]}),options:g.map(B=>({value:B.id,label:B.label,icon:B.icon,disabled:B.disabled?.(c)})),onSelect:B=>{const U=g.find(xe=>xe.id===B);U&&U.onClick(c,k)},placement:"bottom-end"})})]},R)})})]})]}),i&&Y>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-muted",children:["Showing ",z," to ",T," of ",Y," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted",children:"Rows per page:"}),e.jsx("select",{value:$.pageSize,onChange:c=>S(Number(c.target.value)),className:"border border-[var(--neutral-border)] text-[var(--text-default)] rounded-md px-2 py-1 text-sm bg-[var(--base-input)] w-16",children:p.map(c=>e.jsx("option",{value:c,children:c},c))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>L(0),disabled:$.page===0,iconOnly:!0,children:e.jsx(ut,{})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>L($.page-1),disabled:$.page===0,iconOnly:!0,children:e.jsx(it,{})}),e.jsxs("span",{className:"px-3 py-1 text-sm text-muted",children:["Page ",$.page+1," of ",M]}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>L($.page+1),disabled:$.page>=M-1,iconOnly:!0,children:e.jsx(dt,{})}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>L(M-1),disabled:$.page>=M-1,iconOnly:!0,children:e.jsx(xt,{})})]})]})]})},ft=u.createContext(null),ht=({items:t,activeTab:n,onTabChange:s,className:r})=>{const[a,o]=u.useState(t[0]?.id||""),i=n||a,p=b=>{s?s(b):o(b)};return e.jsx("div",{className:m("border-b border-neutral",r),children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:t.map(b=>e.jsx("button",{onClick:()=>!b.disabled&&p(b.id),disabled:b.disabled,className:m("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-200",{"border-[var(--accent-fill)] text-default":i===b.id,"border-transparent text-muted hover:text-default":i!==b.id&&!b.disabled,"border-transparent text-disabled cursor-not-allowed":b.disabled}),children:e.jsxs("span",{className:"flex items-center gap-2",children:[b.label,b.badge&&e.jsx("span",{className:m("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",i===b.id?"bg-accent-container text-accent":"bg-neutral-container text-muted"),children:b.badge})]})},b.id))})})},Se=({items:t,defaultTab:n,activeTab:s,onTabChange:r,variant:a="default",size:o="md",className:i})=>{const[p,b]=u.useState(n||s||t[0]?.id||""),g=s||p,f=N=>{r?r(N):b(N)},l={activeTab:g,setActiveTab:f},x=t.find(N=>N.id===g),h=m("flex",{"border-b border-neutral px-2":a==="default"||a==="underline","bg-neutral-container p-1 rounded-lg":a==="pills","space-x-1":a==="pills","space-x-8":a==="default"||a==="underline"},i),w=(N,j)=>{const I="transition-colors duration-200 font-medium",y={"text-xs px-2 py-1":o==="sm","text-sm px-3 py-2":o==="md","text-base px-4 py-3":o==="lg"},H={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},P={"opacity-50 cursor-not-allowed":N.disabled,"cursor-pointer":!N.disabled},q=j?{"border-[var(--accent-fill)] text-default":a==="default"||a==="underline","bg-module text-default shadow-lvl-0":a==="pills"}:{},F=!j&&!N.disabled?{"border-transparent text-muted hover:text-default":a==="default","text-muted hover:text-default":a==="pills","border-transparent text-muted hover:text-default hover:border-neutral":a==="underline"}:{};return m(I,y,H,P,q,F)};return e.jsx(ft.Provider,{value:l,children:e.jsxs("div",{children:[e.jsx("div",{className:h,role:"tablist",children:t.map(N=>e.jsx("button",{type:"button",role:"tab","aria-selected":g===N.id,"aria-controls":`tabpanel-${N.id}`,disabled:N.disabled,onClick:()=>!N.disabled&&f(N.id),className:w(N,g===N.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[N.label,N.badge&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-neutral-container-emphasis text-muted",children:N.badge})]})},N.id))}),x?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${g}`,"aria-labelledby":`tab-${g}`,className:"mt-4",children:x.content})]})})},pt={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function Ee({open:t,onClose:n,title:s,size:r="md",closeOnBackdropClick:a=!0,closeOnEscape:o=!0,className:i,backdropClassName:p,children:b,footer:g,showCloseButton:f=!0}){const l=u.useRef(null),x=u.useRef(null);u.useEffect(()=>{if(!t||!o)return;const w=N=>{N.key==="Escape"&&n()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,o,n]),u.useEffect(()=>(t?(x.current=document.activeElement,l.current&&l.current.focus(),document.body.style.overflow="hidden"):(x.current&&x.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const h=w=>{a&&w.target===w.currentTarget&&n()};return t?e.jsx("div",{className:m("fixed inset-0 z-50 flex items-center justify-center p-4","bg-[var(--base-modal-blanket)]",p),onClick:h,children:e.jsxs("div",{ref:l,className:m("relative w-full bg-module rounded-2xl shadow-[var(--shadow-modal)]","focus:outline-none",pt[r],i),role:"dialog","aria-modal":"true","aria-labelledby":s?"modal-title":void 0,tabIndex:-1,children:[(s||f)&&e.jsxs("div",{className:"flex items-center justify-between p-6 pb-0",children:[s&&e.jsx("span",{id:"modal-title",className:"text-lg font-semibold text-default",children:s}),f&&e.jsx("button",{onClick:n,className:"p-1 text-muted hover:text-default transition-colors","aria-label":"Close modal",children:e.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-6",children:b}),g&&e.jsx("div",{className:"px-6 py-4",children:g})]})}):null}const J=({variant:t="body",size:n="md",weight:s="normal",color:r="current",align:a="left",truncate:o=!1,italic:i=!1,underline:p=!1,lineHeight:b="normal",as:g,className:f,children:l,...x})=>{const h=g||bt(t),w=m("font-primary",{"leading-relaxed":t==="body","text-sm leading-tight":t==="caption","text-sm font-medium leading-none":t==="label","font-mono text-sm bg-neutral-container px-1 py-0.5 rounded":t==="code"},t!=="code"&&{"text-xs":n==="xs","text-sm":n==="sm","text-base":n==="md","text-lg":n==="lg","text-xl":n==="xl"},t!=="label"&&{"font-light":s==="light","font-normal":s==="normal","font-medium":s==="medium","font-semibold":s==="semibold","font-bold":s==="bold"},{"text-default":r==="primary","text-muted":r==="secondary","text-[var(--text-accent)]":r==="accent","text-[var(--text-success)]":r==="success","text-warning":r==="warning","text-[var(--text-error)]":r==="error","text-info":r==="info","text-[var(--text-default)]":r==="neutral","text-current":r==="current","text-[var(--text-muted)]":r==="muted"},{"text-left":a==="left","text-center":a==="center","text-right":a==="right","text-justify":a==="justify"},t==="body"&&{"leading-tight":b==="tight","leading-normal":b==="normal","leading-relaxed":b==="relaxed"},{italic:i,underline:p,truncate:o},f),N=h;return e.jsx(N,{className:w,...x,children:l})};function bt(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Le=({value:t,onChange:n,label:s,placeholder:r="Select or upload a file",error:a,disabled:o,accept:i,onListFiles:p,onListMounts:b,onUploadFile:g,onDownloadFile:f,onRegisterFile:l})=>{const[x,h]=u.useState(!1),[w,N]=u.useState([]),[j,I]=u.useState(null),[y,H]=u.useState("/"),[P,q]=u.useState([]),[F,A]=u.useState(!1),[W,$]=u.useState(""),[_,O]=u.useState(typeof t=="object"?t:null),[d,v]=u.useState(!1),[E,C]=u.useState(""),L=u.useRef(null);u.useEffect(()=>{x&&S()},[x]),u.useEffect(()=>{x&&j&&X()},[x,j,y,W]);const S=async()=>{A(!0);try{const c=await b?.();c?.data&&N(c.data)}catch(c){console.error("Failed to load mounts",c)}finally{A(!1)}},X=async()=>{if(j){A(!0);try{const c=await p?.({mountId:j.id,name:W,path:y});c?.data&&q(c.data)}catch(c){console.error("Failed to load files",c)}finally{A(!1)}}},ee=async c=>{const k=c.target.files?.[0];if(k){A(!0);try{const R=await k.arrayBuffer(),V=new Uint8Array(R),B={id:`local-${Date.now()}`,name:k.name,type:"file",path:"/",mimeType:k.type||"application/octet-stream",size:k.size,mountId:"local",providerKey:k.name,ownerId:"me"};O(B),n(B,V),h(!1)}catch(R){console.error("Local file selection failed",R)}finally{A(!1)}}},Y=async c=>{const k=c.target.files?.[0];if(!(!k||!j)){A(!0);try{const R=await k.arrayBuffer(),V=await g?.({file:new Uint8Array(R),filename:k.name,mimeType:k.type||"application/octet-stream",mountId:j.id,path:y});if(V?.data){const B=V.data;O(B),n(B,new Uint8Array(R)),h(!1)}}catch(R){console.error("Upload failed",R)}finally{A(!1)}}},M=async()=>{if(!(!E||!j)){A(!0);try{const c=`${y}${E}/`;l&&(await l({name:E,type:"folder",path:y,mimeType:"application/x-directory",size:0,mountId:j.id,providerKey:c,ownerId:"me"}),await X()),v(!1),C("")}catch(c){console.error("Failed to create folder",c)}finally{A(!1)}}},z=async c=>{A(!0);try{const k=await f?.(c.id);O(c),n(c,k),h(!1)}catch(k){console.error("Failed to download file",k)}finally{A(!1)}},T=c=>{c.stopPropagation(),O(null),n(null)},D=u.useMemo(()=>{const c=new Set,k=[];return P.forEach(R=>{if(R.type==="folder"){R.path===y&&c.add(R.name);return}const V=R.providerKey||R.name,U=(y?V.substring(y.length):V).split("/").filter(xe=>xe!=="");U.length>1?c.add(U[0]):U.length===1&&k.push(R)}),{folders:Array.from(c).sort(),files:k.sort((R,V)=>R.name.localeCompare(V.name))}},[P,y]),Q=c=>{H(k=>`${k}${c}/`)},te=()=>{const c=y.split("/").filter(k=>k!=="");c.pop(),c.length===0?H("/"):H(`${c.join("/")}/`)},G=u.useMemo(()=>{const c=D.folders.map(k=>({id:`folder-${k}`,name:k,type:"folder"}));return D.files.forEach(k=>{c.push({...k,type:"file"})}),c},[D]),se=[{id:"name",header:"Name",accessor:"name",cell:(c,k)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{icon:k.type==="folder"?K.Folder:K.FileText,size:"sm",color:k.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:m(k.type==="folder"&&"font-medium"),children:c})]})},{id:"type",header:"Type",accessor:c=>c.type==="folder"?"Folder":c.mimeType},{id:"size",header:"Size",accessor:c=>c.type==="file"?`${(c.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(c,k)=>e.jsx(Z,{size:"sm",variant:"outline",onClick:R=>{R.stopPropagation(),k.type==="folder"?Q(k.name):z(k)},loading:F&&k.type==="file"&&_?.id===k.id,children:k.type==="folder"?"Open":"Select"})}],ue=[{id:"name",header:"Mount Name",accessor:"name",cell:c=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(re,{icon:K.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:c})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(c,k)=>e.jsx(Z,{size:"sm",variant:"outline",onClick:()=>I(k),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx(J,{variant:"label",size:"sm",weight:"medium",children:s}),e.jsxs("div",{onClick:()=>!o&&h(!0),className:m("flex items-center gap-3 px-3 py-2 border rounded-lg cursor-pointer transition-colors","hover:border-neutral-emphasis bg-module",a?"border-error":"border-neutral",o&&"opacity-50 cursor-not-allowed bg-module-subtle"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(re,{icon:_?K.FileText:K.HardDrive,color:_?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:_?e.jsx("span",{className:"text-sm text-default font-medium",children:_.name}):e.jsx("span",{className:"text-sm text-muted",children:r})}),_&&!o&&e.jsx("button",{onClick:T,className:"p-1 hover:bg-neutral-container rounded",children:e.jsx(re,{icon:K.X,size:"xs"})})]}),a&&e.jsx(J,{variant:"body",size:"xs",className:"text-error",children:a}),e.jsx(Ee,{open:x,onClose:()=>{h(!1),I(null),H("/"),v(!1)},title:j?`Explorer: ${j.name}`:"Select Storage Mount",size:"lg",children:e.jsx(Se,{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(Z,{variant:"ghost",size:"sm",onClick:()=>{y&&y!=="/"?te():I(null)},leftIcon:e.jsx(re,{icon:K.ArrowLeft,size:"xs"}),children:y?"Back":"Back to Mounts"}),e.jsx("div",{className:"flex items-center gap-1 text-xs text-muted overflow-hidden bg-neutral-container px-2 py-1 rounded",children:e.jsx("span",{className:"truncate",children:y})}),e.jsx("div",{className:"flex-grow min-w-[150px]",children:e.jsx(ne,{placeholder:"Search...",value:W,onChange:c=>$(c.target.value),startIcon:e.jsx(K.Search,{size:14}),fullWidth:!0,size:"sm"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{variant:"outline",size:"sm",onClick:()=>v(!0),leftIcon:e.jsx(re,{icon:K.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(Z,{variant:"primary",size:"sm",onClick:()=>L.current?.click(),leftIcon:e.jsx(re,{icon:K.Upload,size:"xs"}),loading:F,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:L,onChange:Y,accept:i})]})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-module-subtle rounded-lg border border-neutral",children:[e.jsx(re,{icon:K.Folder,size:"sm",color:"warning"}),e.jsx(ne,{size:"sm",placeholder:"Folder name",value:E,onChange:c=>C(c.target.value),autoFocus:!0}),e.jsx(Z,{size:"sm",onClick:M,loading:F,children:"Create"}),e.jsx(Z,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-[400px] overflow-auto rounded-lg border border-neutral",children:e.jsx(he,{data:G,columns:se,loading:F,emptyContent:"This folder is empty",onRowClick:c=>c.type==="folder"?Q(c.name):z(c)})})]}):e.jsx("div",{className:"max-h-[400px] overflow-auto rounded-lg border border-neutral",children:e.jsx(he,{data:w,columns:ue,loading:F,emptyContent:"No storage mounts configured",onRowClick:c=>I(c)})})})},{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-neutral rounded-xl bg-module-subtle/50",children:[e.jsx("div",{className:"p-4 bg-accent-container rounded-full mb-4",children:e.jsx(re,{icon:K.FileText,size:"xl",color:"primary"})}),e.jsx(J,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(J,{variant:"body",size:"sm",className:"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.jsxs("div",{className:m("inline-flex items-center justify-center font-medium rounded-lg transition-colors duration-200 px-6 py-3 text-base bg-accent-fill text-on-accent hover:opacity-90",F&&"opacity-50 cursor-wait"),children:[F&&e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",fill:"none",viewBox:"0 0 24 24",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"})]}),"Browse Local File"]}),e.jsx("input",{type:"file",className:"hidden",onChange:ee,accept:i,disabled:F})]})]})})}]})})]})};function Me({value:t,onChange:n,onListFolders:s,disabled:r,size:a="md",placeholder:o,templatePlaceholder:i,showTemplate:p=!0}){const[b,g]=u.useState([]);u.useEffect(()=>{let l=!0;return Promise.resolve(s?.()).then(x=>{l&&x&&g(x.data??[])}).catch(()=>{}),()=>{l=!1}},[]);const f=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{size:a,fullWidth:!0,value:f.folderId??"",options:b.map(l=>({value:l.id,label:l.name})),placeholder:o??"Select a folder",onChange:l=>n?.({...f,folderId:l})}),p&&e.jsx(ne,{size:a,disabled:r??!1,value:f.pathTemplate??"",placeholder:i??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:l=>n?.({...f,pathTemplate:l.target.value})})]})}function ge(t,n){return n.split(".").reduce((s,r)=>s&&typeof s=="object"&&r in s?s[r]:void 0,t)}function gt(t,n,s){const r=n.split("."),a=Array.isArray(t)?[...t]:{...t};let o=a;for(let i=0;i<r.length-1;i++){const p=r[i],b=o[p];o[p]=b&&typeof b=="object"?Array.isArray(b)?[...b]:{...b}:{},o=o[p]}return o[r[r.length-1]]=s,a}function vt(t,n){const s=n.split("."),r=Array.isArray(t)?[...t]:{...t};let a=r;for(let o=0;o<s.length-1;o++){const i=s[o];if(!a[i]||typeof a[i]!="object")return r;a[i]=Array.isArray(a[i])?[...a[i]]:{...a[i]},a=a[i]}return delete a[s[s.length-1]],r}const jt=({groups:t,data:n,onSubmit:s,onCancel:r,onChange:a,transform:o,validate:i,submitButton:p={label:"Submit",variant:"primary"},cancelButton:b={label:"Cancel",variant:"outline"},showButtons:g=!0,layout:f="vertical",size:l="md",loading:x=!1,className:h,ref:w,sdk:N})=>{const[j,I]=u.useState(n||{}),[y,H]=u.useState({}),[P,q]=u.useState({});u.useEffect(()=>{n&&I({...n})},[n]);const F=u.useCallback((d,v,E)=>{const C=t.flatMap(L=>L.items).find(L=>L.name===d);if(!C)return null;if(C.required&&(v==null||v===""))return`${C.label} is required`;if(C.type==="array"){if(C.required&&(!v||v.length===0))return`${C.label} cannot be empty.`;if(v&&!Array.isArray(v))return`${C.label} must be an array.`;if(Array.isArray(v)&&C.arrayFields){const L=[];let S=!1;if(v.forEach((X,ee)=>{const Y={};for(const M of C.arrayFields){const z=X?.[M.name];if(M.required&&(z==null||z===""))Y[M.name]=`${M.label} is required`,S=!0;else if(M.validator){const T=M.validator(z,X);T&&(Y[M.name]=T,S=!0)}}L[ee]=Y}),S)return JSON.stringify(L)}}return C.validator?C.validator(v,E):null},[t]),A=u.useCallback((d,v)=>{let E=gt(j,d,v);t.flatMap(S=>S.items).find(S=>S.name===d)?.removeIfEmpty&&(v==null||v==="")&&(E=vt(E,d)),I(E),q(S=>({...S,[d]:!0}));const L=F(d,v,E);H(S=>({...S,[d]:L||""})),a?.(E,d)},[j,t,F,a]),W=u.useCallback(async d=>{if(console.log("handleSubmit"),d.preventDefault(),x)return;const v={},E=t.flatMap(L=>L.items);for(const L of E){if(L.hidden||L.conditional&&!L.conditional(j))continue;const S=F(L.name,ge(j,L.name),j);S&&(v[L.name]=S)}if(i){const L=i(j);L&&Object.assign(v,L)}if(H(v),console.log("newErrors",v),Object.keys(v).some(L=>v[L]))return;const C=o?o(j):j;await s?.(j,C)},[j,t,F,i,o,s,x]),$=u.useCallback(d=>{const v=ge(j,d.name),E=P[d.name]?y[d.name]:void 0,C=d.disabled||x,L={value:v||"",disabled:C,required:d.required,placeholder:d.placeholder,...d.fieldProps};switch(d.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ne,{...L,onChange:S=>A(d.name,S.target.value),type:d.textType||d.type,autoComplete:d.autocomplete,error:E,size:l});case"textarea":return e.jsx(de,{...L,onChange:S=>A(d.name,S.target.value),rows:4,error:E,size:l});case"select":return e.jsx(le,{...L,onChange:S=>A(d.name,S),options:(d.options||[]).map(S=>({...S,value:String(S.value)})),searchable:d.searchable,multiple:d.multiple,allowCreate:d.allowCreate,error:E,size:l});case"checkbox":return e.jsx(ce,{...L,checked:!!v,onChange:S=>A(d.name,S.target.checked),size:l});case"radio":return e.jsx("div",{className:"space-y-1",children:d.options?.map(S=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:d.name,value:S.value,checked:v===S.value,onChange:()=>A(d.name,S.value),disabled:C||S.disabled,className:"rounded-full border-neutral"}),e.jsx(J,{variant:"label",size:"sm",children:S.label})]},S.value))});case"date":return e.jsx(ie,{...L,value:v?new Date(v):null,onChange:S=>A(d.name,S),size:l});case"file":return e.jsx(Le,{...L,value:v,onChange:S=>A(d.name,S),error:E,onListFiles:S=>N?.http.invoke({method:"POST",action:"storage.file.list",body:S}),onListMounts:()=>N?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:S=>N?.http.invoke({method:"POST",action:"storage.file.upload",body:S}),onDownloadFile:S=>N?.http.invoke({method:"GET",action:`storage.file.${S}.download`}),onRegisterFile:S=>N?.http.invoke({method:"POST",action:"storage.file.folder",body:S})});case"folder":return e.jsx(Me,{value:v||{},onChange:S=>A(d.name,S),onListFolders:()=>N?.http.invoke({method:"GET",action:"storage.mount"}),disabled:C,size:l,placeholder:d.placeholder});case"custom":return d.customComponent?.({value:v,onChange:S=>A(d.name,S),error:E,disabled:C});case"array":{const S=v||[];let X=[];if(typeof E=="string"&&E.startsWith("["))try{X=JSON.parse(E)}catch{}const ee=()=>{A(d.name,[...S,{}])},Y=z=>{A(d.name,S.filter((T,D)=>D!==z))},M=(z,T,D)=>{const Q=[...S];Q[z]={...Q[z],[T]:D},A(d.name,Q)};return e.jsxs("div",{className:"space-y-2",children:[S.map((z,T)=>e.jsxs("div",{className:"p-4 border border-neutral rounded-lg bg-module space-y-2 relative",children:[e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>Y(T),disabled:C,children:"Remove"})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:d.arrayFields?.map(D=>{const Q=X?.[T]?.[D.name];return e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block",children:e.jsxs("span",{className:"block text-[10.5px] font-ui-650 uppercase tracking-[0.08em] text-muted",children:[D.label,D.required&&e.jsx("span",{className:"text-error ml-1",children:"*"})]})}),(()=>{const te={value:z?.[D.name]||"",disabled:C,required:D.required,placeholder:D.placeholder,...D.fieldProps};switch(D.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ne,{...te,onChange:G=>M(T,D.name,G.target.value),type:D.textType||D.type,autoComplete:D.autocomplete,error:Q,size:l});case"textarea":return e.jsx(de,{...te,onChange:G=>M(T,D.name,G.target.value),rows:4,error:Q,size:l});case"select":return e.jsx(le,{...te,onChange:G=>M(T,D.name,G),options:(D.options||[]).map(G=>({...G,value:String(G.value)})),searchable:D.searchable,multiple:D.multiple,allowCreate:D.allowCreate,error:Q,size:l});case"checkbox":return e.jsx(ce,{...te,checked:!!z?.[D.name],onChange:G=>M(T,D.name,G.target.checked),size:l});case"radio":return e.jsx("div",{className:"space-y-1",children:D.options?.map(G=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:`${d.name}.${T}.${D.name}`,value:G.value,checked:z?.[D.name]===G.value,onChange:()=>M(T,D.name,G.value),disabled:C||G.disabled,className:"rounded-full border-neutral"}),e.jsx(J,{variant:"label",size:"sm",children:G.label})]},G.value))});case"date":{const G=z?.[D.name];return e.jsx(ie,{...te,value:G?new Date(G):null,onChange:se=>M(T,D.name,se),size:l})}case"custom":return D.customComponent?.({value:z?.[D.name],onChange:G=>M(T,D.name,G),error:Q,disabled:C});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",D.type]})}})(),Q&&e.jsx(J,{variant:"body",size:"sm",className:"text-error",children:Q})]},D.name)})})]},T)),e.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:ee,disabled:C,children:["Add ",d.label]})]})}default:return null}},[j,P,y,x,l,A]),_=u.useCallback(d=>{if(d.conditional&&!d.conditional(j))return null;const v=d.items.filter(C=>!(C.hidden||C.conditional&&!C.conditional(j)));if(v.length===0)return null;const E=m("space-y-2",{"grid gap-2":d.layout==="grid","flex flex-wrap gap-2":d.layout==="flex"},d.layout==="grid"&&{"grid-cols-1":!d.columns||d.columns===1,"grid-cols-2":d.columns===2,"grid-cols-3":d.columns===3,"grid-cols-4":d.columns===4},d.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 p-5 border border-neutral rounded-xl bg-module",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(J,{variant:"label",size:"md",weight:"semibold",className:"text-default",children:d.title}),d.description&&e.jsx(J,{variant:"body",size:"sm",className:"text-muted mt-1 leading-relaxed",children:d.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:E,children:v.map(C=>(P[C.name]&&y[C.name],e.jsxs("div",{className:m("space-y-1",C.width&&typeof C.width=="string"&&`w-[${C.width}]`,C.width&&typeof C.width=="number"&&`col-span-${C.width}`),children:[C.type!=="custom"&&e.jsxs("label",{className:"block text-[10.5px] font-ui-650 uppercase tracking-[0.08em] text-muted",children:[C.label,C.required&&e.jsx("span",{className:"text-error ml-1",children:"*"})]}),$(C)]},C.name)))})})]},d.id)},[j,P,y,$]),O=m("space-y-6",{"max-w-md":l==="sm","max-w-2xl":l==="md","max-w-4xl":l==="lg","max-w-full":l==="full"},h);return e.jsxs("form",{ref:w,onSubmit:W,className:O,children:[e.jsx("div",{className:"space-y-8",children:t.map(_)}),g&&e.jsxs("div",{className:m("flex gap-3 justify-end pt-8"),children:[r&&e.jsx(Z,{type:"button",variant:b.variant,size:b.size||l,disabled:b.disabled||x,onClick:r,className:b.className,children:b.label}),e.jsx(Z,{type:"submit",variant:p.variant,size:p.size||l,disabled:p.disabled||x,loading:x,className:p.className,children:p.label})]})]})},yt={default:"bg-neutral-container text-default",primary:"bg-accent-container text-accent",secondary:"bg-neutral-container text-muted",success:"bg-success-container text-success",warning:"bg-notice-container text-on-notice",error:"bg-error-container text-error",info:"bg-beta-container text-link"},Nt={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},wt={default:"bg-neutral-fill",primary:"bg-accent-fill",secondary:"bg-neutral-fill",success:"bg-success-fill",warning:"bg-notice-fill",error:"bg-error-fill",info:"bg-beta-fill"};function kt({variant:t="default",size:n="md",dot:s=!1,icon:r,dismissible:a=!1,onDismiss:o,className:i,children:p,...b}){return e.jsxs("span",{className:m("inline-flex items-center font-medium rounded-full",yt[t],Nt[n],i),...b,children:[s&&e.jsx("span",{className:m("w-2 h-2 rounded-full mr-1.5",wt[t])}),r&&e.jsx("span",{className:m("flex-shrink-0",p&&"mr-1"),children:r}),p,a&&o&&e.jsx("button",{onClick:o,className:"ml-1.5 flex-shrink-0 hover:opacity-70 transition-opacity","aria-label":"Remove badge",children:e.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})}const Ct={neutral:"bg-neutral-container text-muted",success:"bg-success-container text-success"};function St({icon:t,tone:n="neutral",title:s,description:r,actions:a,card:o=!1,className:i,...p}){return e.jsxs("div",{className:m("flex flex-col items-center gap-2.5 text-center",o&&"rounded-2xl border border-neutral bg-module px-11 py-9 shadow-lvl-1",i),...p,children:[t!=null&&e.jsx("span",{className:m("flex h-[52px] w-[52px] items-center justify-center rounded-full text-2xl",Ct[n]),children:t}),e.jsx("div",{className:"text-lg font-ui-650 text-default",children:s}),r&&e.jsx("div",{className:"max-w-sm text-sm leading-relaxed text-muted",children:r}),a&&e.jsx("div",{className:"flex gap-2 pt-1.5",children:a})]})}function Et({children:t,className:n,...s}){return e.jsx("kbd",{className:m("inline-flex items-center rounded border border-neutral px-1.5 py-px text-[10px] font-medium leading-none text-muted",n),...s,children:t})}const Lt={sm:"h-1",md:"h-1.5"},Mt={accent:"bg-accent-fill",success:"bg-success-fill"};function Tt({value:t,variant:n="accent",size:s="md",className:r,...a}){const o=Math.max(0,Math.min(100,t));return e.jsx("div",{role:"progressbar","aria-valuenow":Math.round(o),"aria-valuemin":0,"aria-valuemax":100,className:m("w-full overflow-hidden rounded-full bg-neutral-container",Lt[s],r),...a,children:e.jsx("div",{className:m("h-full rounded-full transition-[width] duration-300 ease-out",Mt[n]),style:{width:`${o}%`}})})}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"},Dt={primary:"text-accent",secondary:"text-muted",white:"text-white",current:"text-current"},At={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function It({size:t="md",variant:n="primary",label:s="Loading...",showLabel:r=!1,className:a,...o}){return e.jsxs("div",{className:m("inline-flex items-center",r?"flex-col space-y-2":"",a),...o,children:[e.jsxs("svg",{className:m("animate-spin",$t[t],Dt[n]),fill:"none",viewBox:"0 0 24 24","aria-hidden":!r,role:r?"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"})]}),r&&e.jsx("span",{className:m("text-muted",At[t]),children:s}),!r&&e.jsx("span",{className:"sr-only",children:s})]})}function zt({title:t,icon:n="✦",action:s,children:r,className:a,...o}){return e.jsxs("div",{className:m("flex flex-col gap-2 rounded-xl border p-4","border-[var(--assistant-border)] bg-[var(--assistant-tint)]",a),...o,children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--assistant-accent)]",children:[e.jsx("span",{"aria-hidden":!0,children:n}),e.jsx("span",{className:"text-sm font-ui-650",children:t}),s&&e.jsx("span",{className:"ml-auto",children:s})]}),r&&e.jsx("div",{className:"text-sm leading-relaxed text-default",children:r})]})}const Bt={xs:"w-5 h-5 text-[10px]",sm:"w-6 h-6 text-xs",md:"w-7 h-7 text-[13px]",lg:"w-9 h-9 text-sm"};function Pt(t){if(!t)return"?";const n=t.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():n.length===1?n[0].slice(0,2).toUpperCase():"?"}const Te=({name:t,src:n,size:s="sm",className:r,title:a})=>{const[o,i]=u.useState(!1),p=m("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none bg-neutral-border-emphasis text-default",Bt[s],r);return n&&!o?e.jsx("img",{src:n,alt:t??"",title:a??t,className:m(p,"object-cover"),onError:()=>i(!0)}):e.jsx("span",{className:p,title:a??t,"aria-label":t,children:Pt(t)})},ve="shadow-[0_0_0_2px_var(--base-module)]",Rt="shadow-[0_0_0_2px_var(--base-module),0_0_0_3.5px_var(--accent-border)]",_t=({people:t,max:n=4,size:s="sm",className:r})=>{if(t.length===0)return null;const a=t.slice(0,n),o=t.length-a.length;return e.jsxs("span",{className:m("inline-flex items-center",r),children:[a.map((i,p)=>e.jsx(Te,{name:i.name,src:i.src,size:s,title:i.name?i.seen===!1?`${i.name} — nog niet gelezen`:i.name:void 0,className:m(p>0&&"-ml-2",i.owner?Rt:ve,i.seen===!1&&"opacity-40")},i.id??`${i.name}-${p}`)),o>0&&e.jsxs("span",{className:m("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-neutral-container text-muted",s==="xs"?"w-5 h-5 text-[10px]":s==="md"?"w-7 h-7 text-[11px]":s==="lg"?"w-9 h-9 text-xs":"w-6 h-6 text-[10px]",ve),children:["+",o]})]})},je={mail:{fg:"text-ch-mail",bg:"bg-ch-mail"},wa:{fg:"text-ch-wa",bg:"bg-ch-wa"},chat:{fg:"text-ch-chat",bg:"bg-ch-chat"},tel:{fg:"text-ch-tel",bg:"bg-ch-tel"},note:{fg:"text-ch-note",bg:"bg-ch-note"}},Ft={sm:"h-[18px] w-[18px] rounded-[5px] text-[9.5px]",md:"h-6 w-6 rounded-[7px] text-[11px]",lg:"h-[34px] w-[34px] rounded-[10px] text-[13px]"};function Ot({channel:t,children:n,size:s="md",className:r,title:a}){const o=je[t in je?t:"note"];return e.jsx("span",{title:a,className:m("inline-flex shrink-0 items-center justify-center font-bold",Ft[s],o.fg,o.bg,r),children:n})}const Vt={default:"text-default",urgent:"text-urgency",success:"text-success"},Wt={default:"border-neutral",urgent:"border-error",success:"border-neutral"};function Ht({value:t,label:n,tone:s="default",className:r,...a}){return e.jsxs("div",{className:m("rounded-xl border bg-module px-4 py-3.5",Wt[s],r),...a,children:[e.jsx("div",{className:m("text-2xl font-ui-650",Vt[s]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-muted",children:n})]})}function qt({label:t,dotColor:n,onClick:s,className:r}){return e.jsxs("button",{type:"button",onClick:s,className:m("inline-flex max-w-full items-center gap-1.5 rounded-full bg-neutral-container px-2.5 py-1 text-xs text-muted transition-colors hover:bg-neutral-container-emphasis",r),children:[n&&e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:n},"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:t}),e.jsx("span",{"aria-hidden":!0,className:"shrink-0 opacity-70",children:"↗"})]})}const Gt=({src:t,alt:n,size:s="md",aspectRatio:r="auto",radius:a="md",showLoading:o=!0,showError:i=!0,fallback:p,loadingContent:b,errorContent:g,className:f,onLoad:l,onError:x,...h})=>{const[w,N]=u.useState(!0),[j,I]=u.useState(!1),[y,H]=u.useState(t),P=O=>{N(!1),I(!1),l?.(O)},q=O=>{if(N(!1),I(!0),p&&y!==p){H(p),I(!1),N(!0);return}x?.(O)},F=m("relative overflow-hidden bg-neutral-container",{"w-8 h-8":s==="xs","w-12 h-12":s==="sm","w-16 h-16":s==="md","w-24 h-24":s==="lg","w-32 h-32":s==="xl","w-full h-full":s==="full"},{"aspect-square":r==="square","aspect-video":r==="video","aspect-[3/4]":r==="portrait","aspect-[4/3]":r==="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"},f),A=m("w-full h-full object-cover transition-opacity duration-200",{"opacity-0":w||j,"opacity-100":!w&&!j}),W=m("absolute inset-0 flex items-center justify-center","text-muted"),$=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-neutral-container-emphasis rounded"})}),_=e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-6 h-6 mx-auto mb-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:F,children:[e.jsx("img",{...h,src:y,alt:n,className:A,onLoad:P,onError:q}),w&&o&&e.jsx("div",{className:W,children:b||$}),j&&i&&e.jsx("div",{className:W,children:g||_})]})},Kt=({title:t,subtitle:n,actions:s=[],children:r,className:a,backLabel:o="Back",backClassName:i,onBack:p,editable:b=!1,onTitleChange:g})=>{const[f,l]=u.useState(!1),[x,h]=u.useState(t),w=u.useRef(null);u.useEffect(()=>{h(t)},[t]),u.useEffect(()=>{f&&w.current&&(w.current.focus(),w.current.select())},[f]);const N=()=>{b&&l(!0)},j=()=>{l(!1),x.trim()!==""&&x!==t&&g?g(x.trim()):h(t)},I=y=>{y.key==="Enter"?w.current?.blur():y.key==="Escape"&&(h(t),l(!1))};return e.jsxs("div",{className:m("p-5 pb-3 border-b border-neutral",a),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-default",children:[p&&e.jsx("button",{type:"button",onClick:p,className:m("flex items-center text-sm cursor-pointer transition",i),children:e.jsx(K.ArrowLeft,{size:16,color:"currentColor"})}),f?e.jsx("input",{ref:w,type:"text",value:x,onChange:y=>h(y.target.value),onBlur:j,onKeyDown:I,className:"text-1xl font-semibold bg-transparent border-b-1 border-neutral 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:N,className:m("text-2xl font-ui-650 truncate",b&&"cursor-pointer"),title:b?"Klik om te bewerken":void 0,children:t}),n&&e.jsx("span",{className:"shrink-0 text-[13px] text-muted truncate",children:n}),b&&e.jsx(K.Pencil,{size:15,onClick:N,className:"shrink-0 cursor-pointer text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]})]})}),s.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:s.map(y=>y.splitOptions&&y.splitOptions.length>0?e.jsx(pe,{label:y.label,onClick:y.onClick,icon:y.icon,variant:y.variant==="primary"?"primary":"secondary",options:y.splitOptions,disabled:y.disabled},y.id):e.jsxs("button",{type:"button",onClick:H=>{H.stopPropagation(),H.target.blur(),y.onClick()},disabled:y.disabled,className:m("btn",{o__primary:y.variant==="primary",o__secondary:y.variant==="secondary"||y.variant==="outline",o__tertiary:y.variant==="ghost",o__destructive:y.variant==="destructive"}),children:[y.icon&&e.jsx("span",{className:"mr-2",children:y.icon}),y.label]},y.id))})]}),r&&e.jsx("div",{className:"mt-4",children:r})]})},Ut=({actions:t=[],onBack:n,backLabel:s="Back",className:r,children:a})=>e.jsxs("div",{className:m("flex items-center gap-2 mb-3",r),children:[n&&e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 text-sm text-muted hover:text-default cursor-pointer transition px-2 py-1 rounded",children:[e.jsx(K.ArrowLeft,{size:16}),e.jsx("span",{children:s})]}),a&&e.jsx("div",{className:"flex-1 min-w-0",children:a}),t.length>0&&e.jsx("div",{className:m("flex flex-wrap gap-2",!a&&"ml-auto"),children:t.map(o=>o.splitOptions&&o.splitOptions.length>0?e.jsx(pe,{label:o.label,onClick:o.onClick,icon:o.icon,variant:o.variant==="primary"?"primary":"secondary",options:o.splitOptions,disabled:o.disabled},o.id):e.jsxs("button",{type:"button",onClick:i=>{i.stopPropagation(),i.target.blur(),o.onClick()},disabled:o.disabled,className:m("btn",{o__primary:o.variant==="primary",o__secondary:o.variant==="secondary"||o.variant==="outline",o__ghost:o.variant==="ghost",o__destructive:o.variant==="destructive"}),children:[o.icon&&e.jsx("span",{className:"mr-2",children:o.icon}),o.label]},o.id))})]});function Jt(t,n){return n.split(".").reduce((s,r)=>s&&typeof s=="object"&&r in s?s[r]:void 0,t)}const Yt=({groups:t,data:n,size:s="md",className:r})=>{const a=f=>{if(!f)return"-";try{return new Date(f).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(f)}},o=f=>f?"Ja":"Nee",i=(f,l)=>{if(!l)return String(f||"-");const x=l.find(h=>h.value===f);return x?x.label:String(f||"-")},p=u.useCallback(f=>{const l=Jt(n,f.name);if(f.type==="array"){const h=l;return!h||h.length===0?e.jsx(J,{variant:"body",size:"sm",className:"text-muted",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:h.map((w,N)=>e.jsxs("div",{className:"p-4 border border-neutral rounded-xl space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(J,{variant:"label",size:"sm",weight:"medium",className:"text-muted",children:[f.label," ",N+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:f.arrayFields?.map(j=>{const I=w?.[j.name];let y="-";switch(j.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":y=I||"-";break;case"select":case"radio":y=i(I,j.options);break;case"checkbox":y=o(I);break;case"date":y=a(I);break;case"custom":y=j.customComponent?.({value:I});break;default:y=String(I||"-")}return j.format&&(y=j.format(I,w)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(J,{variant:"label",size:"xs",className:"text-muted",children:j.label}),e.jsx(J,{variant:"body",size:"sm",className:"text-default",children:y})]},j.name)})})]},N))})}if(f.type==="custom"&&f.customComponent)return f.customComponent({value:l});if(f.format){const h=f.format(l,n);return e.jsx(J,{variant:"body",size:"sm",className:"text-default",children:h})}let x="-";switch(f.type){case"text":case"email":case"password":case"number":case"tel":case"url":x=l?String(l):"-";break;case"textarea":x=l?e.jsx("div",{className:"whitespace-pre-wrap",children:String(l||"-")}):"-";break;case"select":case"radio":x=i(l,f.options);break;case"checkbox":x=o(l);break;case"date":x=a(l);break;default:x=l?String(l):"-"}return e.jsx(J,{variant:"body",size:"sm",className:"text-default",children:x})},[n]),b=u.useCallback(f=>{if(f.conditional&&!f.conditional(n))return null;const l=f.items.filter(h=>!(h.hidden||h.conditional&&!h.conditional(n)));if(l.length===0)return null;const x=m("space-y-4",{"grid gap-4":f.layout==="grid","flex flex-wrap gap-4":f.layout==="flex"},f.layout==="grid"&&{"grid-cols-1":!f.columns||f.columns===1,"grid-cols-2":f.columns===2,"grid-cols-3":f.columns===3,"grid-cols-4":f.columns===4},f.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 p-6 border border-neutral rounded-xl",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(J,{variant:"label",size:"lg",weight:"semibold",className:"text-default",children:f.title}),f.description&&e.jsx(J,{variant:"body",size:"sm",className:"text-muted mt-1",children:f.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:x,children:l.map(h=>e.jsxs("div",{className:m("space-y-1",h.width&&typeof h.width=="string"&&`w-[${h.width}]`,h.width&&typeof h.width=="number"&&`col-span-${h.width}`),children:[h.type!=="custom"&&e.jsx(J,{variant:"label",size:"sm",className:"font-medium text-muted",children:h.label}),p(h)]},h.name))})})]},f.id)},[n,p]),g=m("space-y-6",{"max-w-md":s==="sm","max-w-2xl":s==="md","max-w-4xl":s==="lg","max-w-full":s==="full"},r);return e.jsx("div",{className:g,children:e.jsx("div",{className:"space-y-8",children:t.map(b)})})},$e=({item:t,isSelectedHandler:n,onClick:s,depth:r=0})=>{const[a,o]=u.useState(t.defaultCollapsed??!1),i=t.children&&t.children.length>0,p=i&&r===0,b=()=>{i&&o(!a)},g=n?n(t.path):!1;return e.jsxs("li",{children:[e.jsxs("div",{className:m("flex flex-row w-full py-1 rounded-lg items-center h-8 transition-colors cursor-pointer px-2.5 pr-1 no-underline text-sm",{"bg-accent-container text-accent":g&&!i,"hover:bg-neutral-container":!(g&&!i),"font-semibold":g||p}),onClick:()=>{i?b():t.path&&s?.(t.path)},children:[t.icon&&e.jsx("span",{className:"mr-2 shrink-0",children:t.icon}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:"ml-2 mr-1.5",children:t.count}),i&&e.jsx("span",{className:`${a?"collapsed":""}`,children:e.jsx(K.ChevronDownIcon,{className:"w-4 h-4 text-muted"})})]}),i&&!a&&e.jsx("ul",{className:"sidebar-menu-nested-items mb-1",children:t.children?.map((f,l)=>e.jsx($e,{item:f,isSelectedHandler:n,onClick:s,depth:r+1},l))})]})},Zt=({title:t,actionIcons:n,items:s,isSelectedHandler:r,onClick:a,preMenuItemsComponent:o})=>e.jsxs("div",{className:"flex flex-col h-screen mb-6",children:[e.jsxs("div",{className:"sidebar-menu-header",children:[e.jsx("span",{className:"text-[15px] font-ui-650 text-default mb-2",children:t}),e.jsx("div",{className:"sidebar-menu-actions",children:n?.map((i,p)=>e.jsx("span",{className:"sidebar-menu-action-icon",children:i},p))})]}),o&&e.jsx("div",{className:"sidebar-menu-pre-items mb-4",children:o}),e.jsx("ul",{children:s.map((i,p)=>!i.path&&!i.label&&!i.children?e.jsx("span",{className:"flex w-full h-4"},p):e.jsx($e,{item:i,isSelectedHandler:r,onClick:a},p))})]}),Xt=({level:t=1,size:n,weight:s="bold",color:r="current",align:a="left",truncate:o=!1,className:i,children:p,...b})=>{const g=n||Qt(t),f=m("font-primary",{"text-xs":g==="xs","text-sm":g==="sm","text-base":g==="md","text-lg":g==="lg","text-xl":g==="xl","text-2xl":g==="2xl","text-3xl":g==="3xl","text-4xl":g==="4xl"},{"font-light":s==="light","font-normal":s==="normal","font-medium":s==="medium","font-semibold":s==="semibold","font-bold":s==="bold"},{"text-default":r==="primary","text-muted":r==="secondary","text-[var(--text-accent)]":r==="accent","text-[var(--text-success)]":r==="success","text-warning":r==="warning","text-[var(--text-error)]":r==="error","text-info":r==="info","text-[var(--text-default)]":r==="neutral","text-current":r==="current"},{"text-left":a==="left","text-center":a==="center","text-right":a==="right"},{truncate:o},i),l=`h${t}`;return e.jsx(l,{className:f,...b,children:p})};function Qt(t){return{1:"4xl",2:"3xl",3:"2xl",4:"xl",5:"lg",6:"md"}[t]||"md"}const es=({items:t,type:n="unordered",variant:s="default",size:r="md",interactive:a=!1,className:o,itemClassName:i})=>{const p=m("space-y-1",{"":s==="default","space-y-0":s==="flush","border border-neutral rounded-lg overflow-hidden":s==="bordered","divide-y divide-[color:var(--neutral-border)]":s==="divided"},{"text-sm":r==="sm","text-base":r==="md","text-lg":r==="lg"},o),b=(l,x)=>m("transition-colors duration-200",{"py-1 px-2":r==="sm"&&(s==="bordered"||s==="divided"),"py-2 px-3":r==="md"&&(s==="bordered"||s==="divided"),"py-3 px-4":r==="lg"&&(s==="bordered"||s==="divided")},a&&!l.disabled&&{"cursor-pointer hover:bg-neutral-container":!0,"focus:outline-none focus:bg-neutral-container":!0},l.disabled&&{"opacity-50 cursor-not-allowed":!0},i),g=l=>{a&&!l.disabled&&l.onClick&&l.onClick()},f=(l,x)=>{a&&!x.disabled&&(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),x.onClick?.())};return n==="ordered"?e.jsx("ol",{className:p,children:t.map((l,x)=>e.jsx("li",{className:b(l),onClick:()=>g(l),onKeyDown:h=>f(h,l),tabIndex:a&&!l.disabled?0:void 0,role:a?"button":void 0,children:l.content},l.id||x))}):n==="description"?e.jsx("dl",{className:p,children:t.map((l,x)=>e.jsx("div",{className:b(l),onClick:()=>g(l),onKeyDown:h=>f(h,l),tabIndex:a&&!l.disabled?0:void 0,role:a?"button":void 0,children:l.content},l.id||x))}):e.jsx("ul",{className:p,children:t.map((l,x)=>e.jsx("li",{className:b(l),onClick:()=>g(l),onKeyDown:h=>f(h,l),tabIndex:a&&!l.disabled?0:void 0,role:a?"button":void 0,children:l.content},l.id||x))})},ts=({commands:t,isOpen:n,onClose:s,labels:r,initialCommandPath:a,initialActiveIndex:o})=>{const[i,p]=u.useState(""),[b,g]=u.useState(a||[]),[f,l]=u.useState(o||0),x=u.useRef(null),h=u.useRef(null),N=(b.length?t.find(j=>j.id===b[0])?.subCommands||[]:t).filter(j=>j.label.toLowerCase().includes(i.toLowerCase()));return u.useEffect(()=>{n||(p(""),g(a||[]),l(o||0))},[n]),u.useEffect(()=>{const j=I=>{if(n){if(I.key==="Escape")s();else if(I.key==="ArrowUp")l(y=>y>0?y-1:N.length-1);else if(I.key==="ArrowDown")l(y=>y<N.length-1?y+1:0);else if(I.key==="Enter"){const y=N[f];y&&(y.subCommands?(g([...b,y.id]),l(0)):y.action&&(y.action(),s()))}}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[n,s,N,f,b]),u.useEffect(()=>{const j=I=>{x.current&&!x.current.contains(I.target)&&s()};return n&&document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[n,s]),u.useEffect(()=>{if(!n)return;h.current?.querySelector(`[data-index="${f}"]`)?.scrollIntoView({block:"nearest"})},[f,n]),n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[var(--base-modal-blanket)]",children:e.jsxs("div",{className:"flex flex-col w-full max-w-lg max-h-[80vh] p-2 mx-auto rounded-2xl border border-neutral shadow-[var(--shadow-modal)] bg-module",ref:x,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(K.Search,{className:"w-4 h-4 text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:r?.searchPlaceholder||"Search commands...",value:i,onChange:j=>p(j.target.value),className:"w-full py-2 text-default border-0 focus:outline-none focus:ring-0 focus:border-0 focus:shadow-none bg-transparent"})]}),e.jsxs("div",{ref:h,className:"mt-2 pt-2 text-sm border-t border-neutral max-h-[50vh] overflow-y-auto",children:[N.length===0&&e.jsx("div",{className:"text-muted text-center text-sm",children:r?.noCommandsFound||"No commands found"}),N.map((j,I)=>e.jsxs("div",{"data-index":I,className:`flex items-center p-2 cursor-pointer rounded-md ${I===f?"bg-accent-container text-accent":"text-default"}`,onClick:()=>{j.subCommands?(g([...b,j.id]),l(0)):j.action&&(j.action(),s())},onMouseEnter:()=>l(I),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-muted",children:e.jsx(K.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-muted border-t border-neutral",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"↑↓"}),r?.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-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"↵"}),r?.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-[1.25rem] px-1 py-0.5 rounded border border-neutral bg-module-subtle text-[10px] font-medium not-italic",children:"Esc"}),r?.close||"to close"]})]})]})}):null},ss={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},rs={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},ns={none:"",primary:"bg-accent-fill",secondary:"bg-neutral-container",accent:"bg-accent-container",success:"bg-success",warning:"bg-warning",error:"bg-error",info:"bg-info",neutral:"bg-neutral",white:"bg-white",module:"bg-module","module-subtle":"bg-module-subtle",backdrop:"bg-backdrop",editor:"bg-editor",input:"bg-input"},as={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},ls={none:"shadow-none",sm:"shadow-lvl-0",md:"shadow-lvl-1",lg:"shadow-lvl-2",xl:"shadow-lvl-3","2xl":"shadow-lvl-3"},os={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},cs={primary:"border-accent",secondary:"border-neutral",accent:"border-accent",success:"border-[var(--success-border)]",warning:"border-[var(--notice-border)]",error:"border-error",info:"border-beta",neutral:"border-neutral",white:"border-[var(--base-module)]"},be=u.forwardRef(({padding:t,margin:n,background:s,radius:r,shadow:a,border:o,borderColor:i,className:p,children:b,...g},f)=>e.jsx("div",{ref:f,className:m(t&&ss[t],n&&rs[n],s&&ns[s],r&&as[r],a&&ls[a],o&&os[o],i&&cs[i],p),...g,children:b}));be.displayName="Box";const is=({children:t,title:n,...s})=>e.jsxs(be,{background:"module",radius:"xl",shadow:"sm",border:"sm",borderColor:"neutral",...s,children:[n&&e.jsx("span",{className:"text-base font-medium text-default mb-2",children:n}),t]});function ds({identifier:t,resourceLoader:n,framework:s="react",fallback:r,componentProps:a,className:o}){const i=u.useRef(null),[p,b]=u.useState(!0),[g,f]=u.useState(null),l=u.useRef(null);return u.useRef(null),u.useEffect(()=>{let x=!0;return(async()=>{b(!0);try{const w=await n();if(!x)return;const N=w.component||w.default||w;f(s==="react"?()=>N:()=>w)}catch(w){console.error(`[FederatedResource] Load failed: ${t}`,w)}finally{x&&b(!1)}})(),()=>{x=!1}},[t,n]),u.useEffect(()=>{if(p||!g||s==="react")return;const x=i.current;if(x){if(s==="svelte"){const h=g.default||g,w=new h({target:x,props:a||{}});return l.current=w,()=>w.$destroy()}if(g.mount){const h=g.mount({container:x,props:a||{}});return()=>{typeof h=="function"?h():g.unmount?.(x)}}}},[g,s,p]),u.useEffect(()=>{s==="svelte"&&l.current&&l.current.$set?.(a)},[a,s]),e.jsxs("div",{ref:i,className:o,style:{display:"contents"},children:[p&&r,s==="react"&&g&&e.jsx(g,{...a})]})}class us extends u.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,s){console.error(`[ErrorBoundary] Error in ${this.props.name||"Component"}:`,n,s)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:e.jsxs("div",{className:"p-4 m-4 border border-error bg-error-container rounded-lg",children:[e.jsx("h2",{className:"text-lg font-semibold text-error",children:"Something went wrong"}),e.jsx("p",{className:"text-sm text-error 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-error-fill 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=zt;exports.Avatar=Te;exports.AvatarStack=_t;exports.Badge=kt;exports.Box=be;exports.Button=Z;exports.ButtonGroup=Oe;exports.Card=is;exports.ChannelBadge=Ot;exports.Checkbox=ce;exports.CommandPalette=ts;exports.ContentLoading=we;exports.DatePicker=ie;exports.Dropdown=ke;exports.EmptyState=St;exports.ErrorBoundary=us;exports.FederatedResource=ds;exports.FilterChip=We;exports.FolderSelect=Me;exports.Form=jt;exports.Heading=Xt;exports.Icon=re;exports.Image=Gt;exports.Kbd=Et;exports.KpiCard=Ht;exports.Link=He;exports.List=es;exports.MeetingGrid=ze;exports.Modal=Ee;exports.PageHeader=Kt;exports.PageToolbar=Ut;exports.ParticipantTile=Be;exports.Popover=ye;exports.ProgressBar=Tt;exports.SearchableTextField=Ne;exports.SegmentedToggle=Ge;exports.Select=le;exports.SidebarMenu=Zt;exports.SourceChip=qt;exports.Spinner=It;exports.SplitButton=pe;exports.StorageInput=Le;exports.TabBar=ht;exports.Table=he;exports.Tabs=Se;exports.Text=J;exports.TextArea=de;exports.TextField=ne;exports.VideoSurface=Pe;exports.View=Yt;exports.cn=m;exports.createSizes=Ie;exports.createVariants=Ae;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=require("clsx"),e=require("react/jsx-runtime"),U=require("lucide-react"),d=require("react");function f(...t){return $e.clsx(t)}function Ae(t){return(r,s)=>t[r]?.[s]||""}function De(t){return r=>t[r]||""}function Ie({tiles:t,pinned:r,className:s}){if(r)return e.jsxs("div",{className:f("flex flex-col md:flex-row gap-2 h-full min-h-0",s),children:[e.jsx("div",{className:"flex-1 min-h-0",children:r}),t.length>0&&e.jsx("div",{className:"flex md:flex-col gap-2 md:w-48 overflow-auto",children:t.map((a,o)=>e.jsx("div",{className:"min-w-40 md:min-w-0",children:a},o))})]});const n=t.length<=1?"grid-cols-1":t.length<=4?"grid-cols-2":t.length<=9?"grid-cols-3":"grid-cols-4";return e.jsx("div",{className:f("grid gap-2 h-full",n,s),children:t.map((a,o)=>e.jsx("div",{children:a},o))})}function Pe({name:t,avatarUrl:r,muted:s,speaking:n,hasVideo:a,videoSlot:o,className:i,fill:b}){return e.jsxs("div",{className:f("relative rounded-lg overflow-hidden bg-video-surface flex items-center justify-center",b?"h-full w-full":"aspect-video",n&&"ring-2 ring-speaking",i),children:[a&&o?e.jsx("div",{className:"absolute inset-0",children:o}):e.jsx("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:r?e.jsx("img",{src:r,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(U.VideoOff,{className:"w-8 h-8"}):e.jsx(U.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:[s?e.jsx(U.MicOff,{className:"w-3 h-3"}):e.jsx(U.Mic,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-35",children:t})]})]})}function Be({attach:t,active:r=!0,mirrored:s=!1,className:n}){const a=d.useRef(null);return d.useEffect(()=>{if(!r||!a.current)return;const o=t(a.current);return()=>{typeof o=="function"&&o(),a.current&&(a.current.innerHTML="")}},[t,r]),e.jsx("div",{ref:a,className:f("w-full h-full bg-video-surface-strong overflow-hidden",s&&"[&>*]:scale-x-[-1]",n)})}const Re={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"},Fe={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",full:"h-control-md px-4 text-sm"},Oe={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",full:"h-control-md w-8"},K=d.forwardRef(({variant:t="primary",size:r="md",fullWidth:s=!1,loading:n=!1,leftIcon:a,rightIcon:o,iconOnly:i=!1,className:b,children:g,disabled:y,...m},u)=>{const x=y||n;return e.jsxs("button",{ref:u,type:"button",className:f("inline-flex shrink-0 items-center justify-center gap-2 rounded-md font-semibold","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",Re[t],i?Oe[r]:Fe[r],(s||r==="full")&&"w-full",n&&"cursor-wait",b),disabled:x,"aria-busy":n||void 0,...m,children:[n&&e.jsx("span",{"aria-hidden":!0,className:"size-icon-md shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent"}),!n&&a&&e.jsx("span",{className:"shrink-0",children:a}),!i&&g,!n&&o&&e.jsx("span",{className:"shrink-0",children:o}),i&&!n&&!a&&!o&&g]})});K.displayName="Button";const Ve=({children:t,size:r="md",orientation:s="horizontal",attached:n=!0,className:a})=>{const o=f("inline-flex",{"flex-row":s==="horizontal","flex-col":s==="vertical","[&>*:not(:first-child):not(:last-child)]:rounded-none":n,"[&>*:first-child]:rounded-r-none":n&&s==="horizontal","[&>*:last-child]:rounded-l-none":n&&s==="horizontal","[&>*:first-child]:rounded-b-none":n&&s==="vertical","[&>*:last-child]:rounded-t-none":n&&s==="vertical","[&>*:not(:first-child)]:-ml-px":n&&s==="horizontal","[&>*:not(:first-child)]:-mt-px":n&&s==="vertical","gap-1":!n&&r==="xs","gap-2":!n&&(r==="sm"||r==="md"),"gap-3":!n&&(r==="lg"||r==="xl")},a);return e.jsx("div",{className:o,role:"group",children:t})},We={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"},re=({icon:t,size:r="md",color:s="current",clickable:n=!1,onClick:a,className:o,"aria-label":i,...b})=>{const g=typeof r=="number"?r:qe(r),y=f("inline-block shrink-0",We[s],n&&["cursor-pointer rounded-sm transition-opacity duration-fast ease-out hover:opacity-80","focus-visible:outline-none focus-visible:focus-ring"],o),m={size:g,strokeWidth:2,className:y,onClick:n?a:void 0,"aria-label":i,"aria-hidden":i?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,...b};return e.jsx(t,{...m})};function qe(t){return{xs:12,sm:14,md:16,lg:20,xl:24}[t]}function He(){return e.jsx("svg",{className:"size-icon-sm",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function Ge({label:t,active:r=!1,caret:s=!1,onClear:n,onClick:a,className:o}){return e.jsxs("span",{onClick:a,className:f("inline-flex h-control-sm cursor-pointer select-none items-center gap-1.5 rounded-full px-3 text-sm font-semibold","transition-colors duration-fast ease-out",r?"bg-accent text-accent-fg":"border border-border text-text-muted hover:bg-surface-hover hover:text-text",o),children:[t,s&&e.jsx(He,{}),r&&n&&e.jsx("button",{type:"button","aria-label":"Filter wissen",onClick:i=>{i.stopPropagation(),n()},className:"ml-0.5 inline-flex items-center rounded-full focus-visible:outline-none focus-visible:focus-ring",children:e.jsx(re,{icon:U.X,size:"xs"})})]})}const Ue={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},_e={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"},Ke={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"},Je=({variant:t="default",size:r="md",color:s="primary",disabled:n=!1,external:a=!1,className:o,children:i,href:b,target:g,rel:y,...m})=>{const u=a||b&&(b.startsWith("http")||b.startsWith("mailto:")),x=f("inline-flex items-center gap-1 underline-offset-2","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",Ue[r],!n&&_e[s],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",Ke[s]],n&&"pointer-events-none cursor-not-allowed text-text-disabled opacity-50",o),h={...m,href:n?void 0:b,target:u?"_blank":g,rel:u?"noopener noreferrer":y,"aria-disabled":n||void 0};return e.jsxs("a",{className:x,...h,children:[i,u&&e.jsx(U.ExternalLink,{className:"size-icon-sm shrink-0","aria-hidden":!0})]})},Ye={sm:"h-control-sm px-3 text-sm",md:"h-control-md px-3 text-sm"};function Xe({options:t,value:r,onChange:s,size:n="sm",className:a,"aria-label":o}){return e.jsx("div",{role:"tablist","aria-label":o,className:f("inline-flex gap-0.5 rounded-md bg-surface-hover p-0.5",a),children:t.map(i=>{const b=i.value===r;return e.jsx("button",{role:"tab","aria-selected":b,type:"button",onClick:()=>s(i.value),className:f("inline-flex items-center justify-center rounded-sm font-semibold","transition-colors duration-fast ease-out","focus-visible:outline-none focus-visible:focus-ring",Ye[n],b?"bg-surface text-text":"text-text-muted hover:text-text"),children:i.label},i.value)})})}const je=({trigger:t,children:r,placement:s="bottom-start",className:n,disabled:a=!1,triggerLabel:o})=>{const[i,b]=d.useState(!1),[g,y]=d.useState({}),m=d.useRef(null),u=d.useRef(null);d.useEffect(()=>{if(!i)return;const N=p=>{m.current&&!m.current.contains(p.target)&&b(!1)},v=p=>{p.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",N),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",v)}},[i]);const x=N=>{if(N.stopPropagation(),!a){if(!i){const v=u.current?.getBoundingClientRect();if(v){const z={};s.startsWith("bottom")?z.top=v.bottom+6:z.bottom=window.innerHeight-v.top+6,s.endsWith("start")?z.left=v.left:z.right=window.innerWidth-v.right,y(z)}}b(v=>!v)}},h=()=>b(!1);return e.jsxs("div",{ref:m,className:"relative inline-flex",children:[e.jsx("button",{ref:u,type:"button",onClick:x,disabled:a,"aria-label":o,"aria-expanded":i,className:f("inline-flex items-center",a&&"cursor-not-allowed opacity-50"),children:t}),i&&e.jsx("div",{className:f("fixed z-overlay bg-surface rounded-lg shadow-overlay border border-border",n),style:g,children:typeof r=="function"?r(h):r})]})},Ze={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"},Qe={sm:"h-control-sm w-7",md:"h-control-md w-8"};function he({label:t,onClick:r,variant:s="primary",size:n="md",icon:a,options:o,disabled:i=!1,loading:b=!1,menuPlacement:g="bottom-end",menuLabel:y="More options"}){const m=i||b,u=o.length>0;return e.jsxs("div",{className:"inline-flex items-center gap-px",children:[e.jsx(K,{variant:s,size:n,onClick:r,disabled:i,loading:b,leftIcon:a,className:f(u&&"rounded-r-none"),children:t}),u&&e.jsx(je,{placement:g,disabled:m,triggerLabel:y,className:"min-w-menu py-1",trigger:e.jsx("span",{"aria-hidden":"true",className:f("inline-flex items-center justify-center rounded-md rounded-l-none","transition-colors duration-fast ease-out",Ze[s],Qe[n],m&&"cursor-not-allowed opacity-50"),children:e.jsx(U.ChevronDown,{className:"size-icon-md"})}),children:x=>e.jsx(e.Fragment,{children:o.map(h=>e.jsxs("button",{type:"button",onClick:()=>{h.onClick(),x()},className:f("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",h.variant==="destructive"?"text-danger-fg hover:bg-danger-soft":"text-text hover:bg-surface-hover"),children:[h.icon&&e.jsx("span",{className:"shrink-0",children:h.icon}),h.label]},h.id))})})]})}const et={sm:"size-checkbox",md:"size-checkbox",lg:"size-checkbox",full:"size-checkbox"},tt={sm:"text-sm",md:"text-base",lg:"text-md",full:"text-md"},le=d.forwardRef(({label:t,helperText:r,error:s,size:n="md",indeterminate:a=!1,containerClassName:o,labelClassName:i,className:b,id:g,...y},m)=>{const u=d.useId(),x=g||`checkbox-${u}`,h=!!s,N=d.useRef(null),v=d.useCallback(p=>{N.current=p,typeof m=="function"?m(p):m&&typeof m=="object"&&(m.current=p)},[m]);return d.useEffect(()=>{N.current&&(N.current.indeterminate=a)},[a]),e.jsxs("div",{className:f("flex flex-col",o),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{ref:v,id:x,type:"checkbox","aria-invalid":h||void 0,className:f("mt-0.5 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",et[n],h?"border-danger-border":"border-border-strong",b),...y}),t&&e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:x,className:f("cursor-pointer",h?"text-danger-fg":"text-text",tt[n],i),children:t}),r&&!s&&e.jsx("p",{className:"mt-0.5 text-xs text-text-subtle",children:r})]})]}),s&&e.jsx("p",{className:"mt-1 text-xs text-danger-fg",children:s})]})});le.displayName="Checkbox";const st=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),rt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m15 18-6-6 6-6"})}),nt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m9 18 6-6-6-6"})}),ie=d.forwardRef(({value:t,onChange:r,placeholder:s="Select date",disabled:n=!1,required:a=!1,size:o="md",className:i,minDate:b,maxDate:g,format:y="MM/dd/yyyy"},m)=>{const[u,x]=d.useState(!1),[h,N]=d.useState(()=>t||new Date),v=d.useRef(null);d.useEffect(()=>{const M=F=>{v.current&&!v.current.contains(F.target)&&x(!1)};return u&&document.addEventListener("mousedown",M),()=>{document.removeEventListener("mousedown",M)}},[u]);const p=M=>{if(!M)return"";const F=M.getDate().toString().padStart(2,"0"),A=(M.getMonth()+1).toString().padStart(2,"0"),l=M.getFullYear();switch(y){case"dd/MM/yyyy":return`${F}/${A}/${l}`;case"yyyy-MM-dd":return`${l}-${A}-${F}`;case"MM/dd/yyyy":default:return`${A}/${F}/${l}`}},z=()=>{const M=h.getFullYear(),F=h.getMonth(),A=new Date(M,F,1),l=new Date(A);l.setDate(l.getDate()-A.getDay());const j=[],E=new Date(l);for(let k=0;k<42;k++)j.push(new Date(E)),E.setDate(E.getDate()+1);return j},w=M=>{M.getMonth()===h.getMonth()&&(b&&M<b||g&&M>g||(r?.(M),x(!1)))},H=()=>{N(new Date(h.getFullYear(),h.getMonth()-1,1))},R=()=>{N(new Date(h.getFullYear(),h.getMonth()+1,1))},G=()=>{r?.(null),x(!1)},V=f("w-full border border-border rounded-md transition-colors duration-fast","bg-surface text-text","placeholder:text-text-muted","focus-visible:outline-none focus-visible:focus-ring","disabled:cursor-not-allowed disabled:bg-surface-hover disabled:text-text-disabled",{"h-control-sm px-3 text-sm":o==="sm","h-control-md px-3 text-base":o==="md","h-control-lg px-3 text-base":o==="lg","h-control-md w-full px-3 text-base":o==="full"},i),D=z(),W=["January","February","March","April","May","June","July","August","September","October","November","December"];return e.jsxs("div",{ref:v,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:m,type:"text",value:p(t??null),placeholder:s,disabled:n,required:a,readOnly:!0,onClick:()=>!n&&x(!u),className:f(V,"pr-10 cursor-pointer")}),e.jsx("button",{type:"button",onClick:()=>!n&&x(!u),disabled:n,className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted hover:text-text-muted",children:e.jsx(st,{})})]}),u&&e.jsxs("div",{className:"absolute z-50 mt-1 bg-surface border border-border rounded-lg shadow-overlay p-4 min-w-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:H,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(rt,{})}),e.jsxs("h3",{className:"text-sm font-medium text-text",children:[W[h.getMonth()]," ",h.getFullYear()]}),e.jsx("button",{onClick:R,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(nt,{})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(M=>e.jsx("div",{className:"text-xs font-medium text-text-muted text-center py-1",children:M},M))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:D.map((M,F)=>{const A=M.getMonth()===h.getMonth(),l=t&&M.toDateString()===t.toDateString(),j=M.toDateString()===new Date().toDateString(),E=!A||b&&M<b||g&&M>g;return e.jsx("button",{onClick:()=>!E&&w(M),disabled:E,className:f("w-8 h-8 text-sm rounded transition-colors duration-fast",{"text-text hover:bg-surface-hover":A&&!l&&!E,"bg-accent text-accent-fg":l,"bg-surface-hover text-text":j&&!l,"text-text-muted cursor-not-allowed":E}),children:M.getDate()},F)})}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-border",children:[e.jsx("button",{onClick:G,className:"text-sm text-text-muted hover:text-text",children:"Clear"}),e.jsx("button",{onClick:()=>x(!1),className:"text-sm text-info-fg hover:underline",children:"Close"})]})]})]})}),at={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"},ce=t=>t.trim().toLowerCase(),oe=d.forwardRef(({label:t,helperText:r,error:s,size:n="md",fullWidth:a=!1,options:o,placeholder:i,containerClassName:b,labelClassName:g,className:y,id:m,searchable:u,multiple:x,value:h,onChange:N,allowCreate:v,onCreateOption:p,...z},w)=>{const H=m||`select-${Math.random().toString(36).substr(2,9)}`,R=!!s,[G,V]=d.useState(!1),[D,W]=d.useState(""),M=d.useRef(null),[F,A]=d.useState(o);d.useImperativeHandle(w,()=>M.current),d.useEffect(()=>{const T=P=>{M.current&&!M.current.contains(P.target)&&V(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const l=d.useCallback((T,P)=>T.some($=>ce($.value)===ce(P)||ce($.label)===ce(P)),[]),j=d.useCallback((T,P)=>{const $=[...T],I=Q=>{const te=(Q??"").trim();te&&(l($,te)||$.push({value:te,label:te}))};return Array.isArray(P)?P.forEach(I):I(P),$},[l]);d.useEffect(()=>{A(T=>{const P=[...o];return T.forEach($=>{!l(P,$.value)&&!l(P,$.label)&&P.push($)}),j(P,h)})},[o,h,j,l]);const E=T=>{if(x){const P=Array.isArray(h)?h:[],$=P.includes(T)?P.filter(I=>I!==T):[...P,T];N?.($)}else N?.(T),V(!1),W("")},k=x?null:F.find(T=>T.value===h),L=x?F.filter(T=>Array.isArray(h)&&h.includes(T.value)):[],S=u&&D?F.filter(T=>T.label.toLowerCase().includes(D.toLowerCase())):F,Z=!!v&&!!u&&!!D.trim()&&!l(F,D),ee=T=>{const P=T.trim();if(!P)return;const $=p?.(P)??{value:P,label:P};if(l(F,$.value)||l(F,$.label)){E($.value),W(""),x||V(!1);return}A(I=>[...I,$]),E($.value),W(""),x||V(!1)},X=()=>x?L.length>0?L.map(T=>T.label).join(", "):i||"Select options":k?.label||i||"Select an option";return e.jsxs("div",{ref:M,className:f("relative flex flex-col",a&&"w-full",b),...z,children:[t&&e.jsx("label",{htmlFor:H,onClick:()=>V(!G),className:f("block text-xs font-semibold uppercase tracking-label mb-1.5",R?"text-danger-fg":"text-text-muted",g),children:t}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",id:H,onClick:()=>V(!G),className:f("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",at[n],R?"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:X()}),e.jsx(U.ChevronDownIcon,{size:16,className:f("shrink-0 opacity-60 transition-transform duration-fast",G&&"rotate-180")})]}),G&&e.jsxs("div",{className:"absolute z-10 mt-1 w-full rounded-lg bg-surface shadow-overlay border border-border",children:[u&&e.jsx("div",{className:"p-2",children:e.jsx("input",{type:"text",placeholder:"Search...",value:D,onChange:T=>W(T.target.value),onKeyDown:T=>{T.key==="Enter"&&Z&&(T.preventDefault(),ee(D))},className:f("w-full px-3 py-2 text-sm rounded-md border","text-text border-border focus-visible:outline-none focus-visible:focus-ring")})}),Z&&e.jsxs("div",{className:f("cursor-pointer px-3 py-1.5 text-sm","text-info-fg hover:bg-surface-hover"),onClick:()=>ee(D),children:["+: “",D.trim(),"”"]}),e.jsxs("ul",{className:"max-h-60 overflow-auto py-1",children:[i&&!x&&e.jsx("li",{className:"cursor-pointer px-3 py-1.5 text-sm text-text-muted hover:bg-surface-hover",onClick:()=>{N?.(""),V(!1)},children:i}),S.map(T=>{const P=x?Array.isArray(h)&&h.includes(T.value):h===T.value;return e.jsx("li",{onClick:()=>!T.disabled&&E(T.value),className:f("cursor-pointer px-3 py-1.5 text-sm","text-text",T.disabled?"opacity-50 cursor-not-allowed":"hover:bg-surface-hover",P&&"bg-accent-soft text-accent font-semibold"),children:e.jsxs("div",{className:"flex items-center",children:[x&&e.jsx("input",{type:"checkbox",checked:P,readOnly:!0,className:"mr-3 h-4 w-4 rounded border-border [&:not(:checked)]:bg-surface-input text-accent "}),e.jsx("span",{children:T.label})]})},T.value)})]})]})]}),(s||r)&&e.jsx("p",{className:f("mt-1 text-xs",R?"text-danger-fg":"text-text-muted"),children:s||r})]})});oe.displayName="Select";const lt={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"},ye="mb-1.5 block text-xs font-semibold uppercase tracking-label",ne=d.forwardRef(({label:t,helperText:r,error:s,size:n="md",fullWidth:a=!1,startIcon:o,endIcon:i,loading:b=!1,containerClassName:g,labelClassName:y,className:m,id:u,...x},h)=>{const N=d.useId(),v=u||`textfield-${N}`,p=!!s,z=s||r?`${v}-description`:void 0;return e.jsxs("div",{className:f("flex flex-col",a&&"w-full",g),children:[t&&e.jsx("label",{htmlFor:v,className:f(ye,p?"text-danger-fg":"text-text-subtle",y),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 text-text-muted",children:o}),e.jsx("input",{ref:h,id:v,"aria-invalid":p||void 0,"aria-describedby":z,className:f("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",lt[n],o&&"pl-9",(i||b)&&"pr-9",p?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",m),...x}),(i||b)&&e.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 text-text-muted",children:b?e.jsx("span",{"aria-hidden":!0,className:"size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"}):i})]}),(s||r)&&e.jsx("p",{id:z,className:f("mt-1 text-xs",p?"text-danger-fg":"text-text-subtle"),children:s||r})]})});ne.displayName="TextField";function Ne({value:t,onChange:r,onListFolders:s,disabled:n,size:a="md",placeholder:o,templatePlaceholder:i,showTemplate:b=!0}){const[g,y]=d.useState([]);d.useEffect(()=>{let u=!0;return Promise.resolve(s?.()).then(x=>{u&&x&&y(x.data??[])}).catch(()=>{}),()=>{u=!1}},[]);const m=t??{};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(oe,{size:a,fullWidth:!0,value:m.folderId??"",options:g.map(u=>({value:u.id,label:u.name})),placeholder:o??"Select a folder",onChange:u=>r?.({...m,folderId:u})}),b&&e.jsx(ne,{size:a,disabled:n??!1,value:m.pathTemplate??"",placeholder:i??"Sub-path e.g. {yyyy}/{mm}/{dd} (optional)",onChange:u=>r?.({...m,pathTemplate:u.target.value})})]})}const ae=(...t)=>t.filter(Boolean).join(" "),ot=t=>e.jsx("svg",{...t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.197 5.197a7.5 7.5 0 0 0 10.606 10.606Z"})}),ct=t=>e.jsx("svg",{...t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})}),it={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"},me={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",full:"h-6 w-6"},we=d.forwardRef(({label:t,helperText:r,error:s,size:n="md",fullWidth:a=!1,startIcon:o=e.jsx(ot,{}),loading:i=!1,containerClassName:b,labelClassName:g,className:y,id:m,options:u,onRemoteSearch:x,onSelect:h,debounceTime:N=500,showAllOnOpen:v=!1,value:p,onChange:z,...w},H)=>{const R=m||`searchfield-${Math.random().toString(36).substr(2,9)}`,G=!!s,V=d.useRef(null),D=d.useRef(null),[W,M]=d.useState(p||""),[F,A]=d.useState(!1),[l,j]=d.useState(!1),[E,k]=d.useState(!1);d.useEffect(()=>{p!==void 0&&M(p)},[p]);const L=d.useMemo(()=>{if(v&&!E||!W)return u;const $=String(W).toLowerCase();return u.filter(I=>String(I.label).toLowerCase().includes($))},[W,u,v,E]);d.useEffect(()=>{if(!x||!W){j(!1);return}const $=setTimeout(async()=>{j(!0);try{await x(String(W))}catch(I){console.error("Remote search failed:",I)}finally{j(!1)}},N);return()=>{clearTimeout($),j(!1)}},[W,N,x]),d.useEffect(()=>{const $=I=>{V.current&&!V.current.contains(I.target)&&A(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const S=$=>{const I=$.target.value;M(I),A(!0),k(!0),z&&z($)},Z=$=>{M($.label),A(!1),k(!1),h&&h($.value)},ee=()=>{(u.length>0||x)&&(A(!0),k(!1))},X=i||l,T=F&&(L.length>0||X),P=d.useMemo(()=>H||D,[H]);return e.jsxs("div",{className:ae("flex flex-col",a?"w-full":"",b||"","relative"),ref:V,children:[t&&e.jsx("label",{htmlFor:R,className:ae("block text-sm font-medium mb-1",G?"text-danger-fg":"text-text",g||""),children:t}),e.jsxs("div",{className:"relative",children:[o&&e.jsx("div",{className:"absolute left-0 pl-3 flex items-center pointer-events-none h-full",children:e.jsx("span",{className:ae("text-text-muted",me[n]),children:o})}),e.jsx("input",{ref:P,id:R,value:W,onChange:S,onFocus:ee,className:ae("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",it[n],o?"pl-10":"","pr-10",G?"border-danger-border text-danger-fg focus-visible:focus-ring":"border-border text-text",y||""),...w}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:X||i?e.jsxs("svg",{className:ae("animate-spin text-info-fg",me[n]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",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"})]}):e.jsx(ct,{className:ae("text-text-muted cursor-pointer transition-transform",me[n],F?"rotate-180":"rotate-0"),onClick:()=>{A($=>($||k(!1),!$))}})})]}),T&&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:L.length>0?L.map($=>e.jsx("li",{className:"px-4 py-2 cursor-pointer text-text hover:bg-accent-soft hover:text-accent transition-colors",onClick:()=>Z($),role:"option","aria-selected":W===$.label,children:$.label},$.value)):e.jsx("li",{className:"px-4 py-2 text-text-muted",children:X||i?"Zoeken op afstand...":"Geen resultaten gevonden."})}),(s||r)&&e.jsx("p",{className:ae("mt-1 text-xs",G?"text-danger-fg":"text-text-muted"),children:s||r}),x&&e.jsxs("p",{className:"mt-2 text-xs text-success-fg",children:["Huidige zoekterm (niet-gedebounced): ",String(W)]})]})});we.displayName="SearchableTextField";function ke({children:t,showTableSkeleton:r=!1,tableColumns:s=6,tableRows:n=8}){return t?e.jsx("main",{className:"flex-1 bg-surface p-6",children:e.jsx("div",{className:"w-full max-w-6xl mx-auto animate-pulse",children:t})}):e.jsx("main",{className:"flex-1 bg-surface p-6",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(${s}, minmax(0, 1fr))`},children:Array.from({length:s}).map((a,o)=>e.jsx("div",{className:"h-4 w-2/3 rounded-sm bg-border-strong"},`header-${o}`))}),Array.from({length:n}).map((a,o)=>e.jsx("div",{className:"grid gap-2 border-t border-border-subtle p-3",style:{gridTemplateColumns:`repeat(${s}, minmax(0, 1fr))`},children:Array.from({length:s}).map((i,b)=>e.jsx("div",{className:"h-4 w-full rounded-sm bg-surface-hover"},`cell-${o}-${b}`))},`row-${o}`))]})]})})}const Ce=({trigger:t,options:r,value:s,onSelect:n,placement:a="bottom-start",disabled:o=!1,className:i,showCheck:b=!0,header:g})=>{const[y,m]=d.useState(!1),[u,x]=d.useState(null),[h,N]=d.useState({top:0,left:0}),[v,p]=d.useState({}),z=d.useRef(null),w=d.useRef(null),H=d.useRef(null),R=d.useRef(null);d.useEffect(()=>{const l=j=>{z.current&&(!z.current.contains(j.target)||H.current&&!H.current.contains(j.target))&&(m(!1),x(null),R.current&&(clearTimeout(R.current),R.current=null))};return y&&document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[y]),d.useEffect(()=>{const l=j=>{j.key==="Escape"&&(m(!1),x(null),R.current&&(clearTimeout(R.current),R.current=null))};return y&&document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[y]),d.useEffect(()=>{if(u&&z.current){const l=z.current.querySelector(`[data-option-value="${u}"]`);if(l){const j=l.getBoundingClientRect();N({top:j.top,left:j.right+8})}}},[u]),d.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]);const G=l=>{if(l.stopPropagation(),!o){if(!y){const j=w.current?.getBoundingClientRect();if(j){const k={};a.startsWith("bottom")?k.top=j.bottom+6:k.bottom=window.innerHeight-j.top+6,a.endsWith("start")?k.left=j.left:k.right=window.innerWidth-j.right,p(k)}}m(!y),x(null),R.current&&(clearTimeout(R.current),R.current=null)}},V=(l,j,E)=>{l.stopPropagation(),!j.disabled&&!j.divider&&(!j.children||j.children.length===0)&&(n?.(j.value,E),m(!1),x(null))},D=l=>{R.current&&(clearTimeout(R.current),R.current=null),l.children&&l.children.length>0?x(l.value):x(null)},W=l=>{l.children&&l.children.length>0?R.current=setTimeout(()=>{x(null)},150):x(null)},M=(l,j,E)=>{l.stopPropagation(),!j.disabled&&!j.divider&&(n?.(j.value,E),m(!1),x(null))},F=f("fixed z-overlay min-w-menu bg-surface rounded-lg shadow-overlay border border-border","max-h-60 overflow-auto"),A=f("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:z,className:f("relative flex flex-row items-center justify-center rounded-lg hover:bg-surface-hover",i),children:[e.jsx("button",{ref:w,onClick:G,disabled:o,className:f("inline-flex items-center justify-center",{"opacity-50 cursor-not-allowed":o}),children:t}),y&&e.jsx("div",{className:F,style:v,children:e.jsxs("div",{className:"p-2",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),r.map((l,j)=>{if(l.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${j}`);const E=l.children&&l.children.length>0,k=u===l.value;return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{"data-option-value":l.value,onClick:L=>V(L,l),onMouseEnter:()=>D(l),onMouseLeave:()=>W(l),disabled:l.disabled,className:f("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":l.disabled,"bg-surface-hover":k&&E}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[l.icon&&e.jsx("span",{className:"flex-shrink-0",children:l.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:l.label}),l.description&&e.jsx("span",{className:"text-xs text-text-muted",children:l.description})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[b&&s===l.value&&e.jsx(U.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0}),E&&e.jsx("span",{className:"text-text-muted text-xs",children:"▶"})]})]}),E&&k&&e.jsx("div",{ref:H,className:A,style:{top:`${h.top}px`,left:`${h.left}px`},onMouseEnter:()=>{R.current&&(clearTimeout(R.current),R.current=null),x(l.value)},onMouseLeave:()=>{R.current=setTimeout(()=>{x(null)},150)},children:e.jsx("div",{className:"p-2",children:l.children.map((L,S)=>{if(L.divider)return e.jsx("div",{className:"border-t border-border my-2"},`divider-${S}`);const Z=typeof s=="object"&&s[l.value]&&s[l.value].includes(L.value)||s===L.value;return e.jsxs("button",{onClick:ee=>M(ee,L,l.value),disabled:L.disabled,className:f("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":L.disabled}),children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[L.icon&&e.jsx("span",{className:"flex-shrink-0",children:L.icon}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"font-base truncate",children:L.label}),L.description&&e.jsx("span",{className:"text-xs text-text-muted",children:L.description})]})]}),b&&Z&&e.jsx(U.Check,{className:"size-icon-md shrink-0 text-success-fg","aria-hidden":!0})]},L.value)})})})]},l.value)}),(()=>{const l=r.reduce((j,E)=>{if(E.divider)return j;const k=E.children?E.children.filter(L=>!L.divider).length:0;return j+1+k},0);return l>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:[l," options available"]})})})()]})})]})},dt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ut=({active:t})=>e.jsx("svg",{className:f("h-3 w-3",t?"text-text":"text-text-muted"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m18 15-6-6-6 6"})}),xt=({active:t})=>e.jsx("svg",{className:f("h-3 w-3",t?"text-text":"text-text-muted"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m6 9 6 6 6-6"})}),mt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m15 18-6-6 6-6"})}),ft=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m9 18 6-6-6-6"})}),ht=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m11 17-5-5 5-5m6 10-5-5 5-5"})}),bt=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m7 17 5-5-5-5m6 10 5-5-5-5"})}),Se=()=>e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m6 9 6 6 6-6"})}),pt=t=>{const r=n=>t.multiSelect&&Array.isArray(t.value)?t.value?.includes(n):t.value===n,s=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(ie,{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(Se,{})})]}),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:()=>s(n.value),children:e.jsx("span",{className:f(r(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:()=>s(null),children:e.jsx("span",{className:"text-text-muted",children:"Clear filter"})})]})]})})})},fe=({data:t,columns:r,loading:s=!1,searchable:n=!1,searchPlaceholder:a="Search...",filters:o=[],paginated:i=!1,pageSizeOptions:b=[10,25,50,100],defaultPageSize:g=10,actions:y=[],onRowClick:m,selectable:u=!1,selectedRows:x=[],onSelectionChange:h,getRowKey:N=(G,V)=>V,emptyContent:v,hoverable:p=!0,bordered:z=!1,striped:w=!1,className:H,rowClassName:R})=>{const[G,V]=d.useState(""),[D,W]=d.useState({column:null,direction:null}),[M,F]=d.useState({page:0,pageSize:g}),A=d.useRef(null),l=d.useMemo(()=>{let c=t;if(n&&G.trim()){const C=r.filter(q=>q.searchable!==!1),O=G.toLowerCase();c=c.filter(q=>C.some(B=>{const J=typeof B.accessor=="function"?B.accessor(q):q[B.accessor];return String(J||"").toLowerCase().includes(O)}))}return o.forEach(C=>{C.value&&C.value!=="all"&&(c=c.filter(O=>{const q=r.find(J=>J.id===C.id);if(!q)return!0;const B=typeof q.accessor=="function"?q.accessor(O):O[q.accessor];return String(B||"")===C.value}))}),c},[t,G,r,n,o]),j=d.useMemo(()=>{if(!D.column||!D.direction)return l;const c=r.find(C=>C.id===D.column);return c?[...l].sort((C,O)=>{const q=typeof c.accessor=="function"?c.accessor(C):C[c.accessor],B=typeof c.accessor=="function"?c.accessor(O):O[c.accessor];let J=0;return q<B?J=-1:q>B&&(J=1),D.direction==="desc"?-J:J}):l},[l,D,r]),E=d.useMemo(()=>{if(!i)return j;const c=M.page*M.pageSize,C=c+M.pageSize;return j.slice(c,C)},[j,M,i]),k=d.useCallback(c=>{r.find(O=>O.id===c)?.sortable&&W(O=>O.column!==c?{column:c,direction:"asc"}:O.direction==="asc"?{column:c,direction:"desc"}:{column:null,direction:null})},[r]),L=d.useCallback(c=>{F(C=>({...C,page:c}))},[]),S=d.useCallback(c=>{F({page:0,pageSize:c})},[]),Z=d.useCallback((c,C)=>{if(!h)return;const O=N(c,0);x.map((q,B)=>N(q,B)),h(C?[...x,c]:x.filter((q,B)=>N(x[B],B)!==O))},[x,h,N]),ee=d.useCallback(c=>{h&&h(c?[...E]:[])},[E,h]);d.useEffect(()=>{F(c=>({...c,page:0}))},[G,D]),d.useEffect(()=>{F(c=>({...c,page:0}))},[o.map(c=>c.value).join(",")]);const X=j.length,T=Math.ceil(X/M.pageSize),P=M.page*M.pageSize+1,$=Math.min(P+M.pageSize-1,X),I=E.length>0&&E.every(c=>{const C=N(c,0);return x.some((O,q)=>N(O,q)===C)}),Q=E.some(c=>{const C=N(c,0);return x.some((O,q)=>N(O,q)===C)}),te=f("w-full text-sm leading-5 text-text border-collapse",H),_=f("bg-surface"),se=f("text-text p-3 border-b border-border"),ue=f("h-row-lg",{"hover:bg-surface-sunk":p,"cursor-pointer":m});return e.jsxs("div",{className:"space-y-4",children:[(n||o.length>0)&&e.jsx("div",{className:"pt-4 pb-2",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-start",children:[o.map(c=>e.jsx(pt,{...c},c.id)),e.jsx("div",{className:"w-full sm:w-auto sm:ml-auto min-w-menu",children:e.jsx(ne,{placeholder:a,value:G,onChange:c=>V(c.target.value),startIcon:e.jsx(dt,{}),className:"max-w-sm"})})]})}),e.jsxs("div",{className:"relative w-full overflow-x-auto min-h-100",children:[s&&e.jsx("div",{className:"flex items-center justify-center z-10",children:e.jsx(ke,{showTableSkeleton:!0,tableRows:10,tableColumns:r.length})}),e.jsxs("table",{ref:A,className:f(te,"min-w-full"),children:[e.jsx("thead",{className:_,children:e.jsxs("tr",{children:[u&&e.jsx("th",{className:f(se,"w-12"),children:e.jsx("input",{type:"checkbox",checked:I,ref:c=>{c&&(c.indeterminate=Q&&!I)},onChange:c=>ee(c.target.checked),className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),!s&&r.map(c=>e.jsx("th",{className:f(se,"font-semibold text-xs text-text-muted uppercase tracking-label","group",{"text-left":c.align==="left"||!c.align,"text-center":c.align==="center","text-right":c.align==="right","cursor-pointer select-none":c.sortable,"sticky left-0 bg-surface":c.sticky==="left","sticky right-0 bg-surface":c.sticky==="right"}),style:{width:c.width},onClick:()=>c.sortable&&k(c.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[c.headerCell?c.headerCell():c.header,c.sortable&&e.jsxs("div",{className:f("flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",D.column===c.id&&"opacity-100"),children:[e.jsx(ut,{active:D.column===c.id&&D.direction==="asc"}),e.jsx(xt,{active:D.column===c.id&&D.direction==="desc"})]})]})},c.id)),y.length>0&&e.jsx("th",{className:f(se,"w-20"),children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:E.length===0||s?!s&&e.jsx("tr",{children:e.jsx("td",{colSpan:r.length+(u?1:0)+(y.length>0?1:0),className:f(se,"text-center py-8 text-text-muted"),children:v||"No data available"})}):E.map((c,C)=>{const O=N(c,C),q=x.some((B,J)=>N(B,J)===O);return e.jsxs("tr",{className:f(ue,{"bg-accent-soft":q},R?.(c,C)),onClick:B=>{B.stopPropagation(),m?.(c,C)},children:[u&&e.jsx("td",{className:se,children:e.jsx("input",{type:"checkbox",checked:q,onChange:B=>{B.stopPropagation(),Z(c,B.target.checked)},className:"rounded border-border [&:not(:checked)]:bg-surface-input text-accent"})}),r.map(B=>{const J=typeof B.accessor=="function"?B.accessor(c):c[B.accessor];return e.jsx("td",{className:f(se,{"text-left":B.align==="left"||!B.align,"text-center":B.align==="center","text-right":B.align==="right","sticky left-0 bg-surface":B.sticky==="left","sticky right-0 bg-surface":B.sticky==="right"}),children:B.cell?B.cell(J,c,C):String(J||"")},B.id)}),y.length>0&&e.jsx("td",{className:se,children:e.jsx(Ce,{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(Se,{})]}),options:y.map(B=>({value:B.id,label:B.label,icon:B.icon,disabled:B.disabled?.(c)})),onSelect:B=>{const J=y.find(xe=>xe.id===B);J&&J.onClick(c,C)},placement:"bottom-end"})})]},O)})})]})]}),i&&X>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 ",P," to ",$," of ",X," 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:M.pageSize,onChange:c=>S(Number(c.target.value)),className:"h-control-sm w-16 rounded-md border border-border bg-surface-input px-2 text-sm text-text",children:b.map(c=>e.jsx("option",{value:c,children:c},c))})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>L(0),disabled:M.page===0,iconOnly:!0,children:e.jsx(ht,{})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>L(M.page-1),disabled:M.page===0,iconOnly:!0,children:e.jsx(mt,{})}),e.jsxs("span",{className:"px-3 py-1 text-sm text-text-muted",children:["Page ",M.page+1," of ",T]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>L(M.page+1),disabled:M.page>=T-1,iconOnly:!0,children:e.jsx(ft,{})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>L(T-1),disabled:M.page>=T-1,iconOnly:!0,children:e.jsx(bt,{})})]})]})]})},gt=d.createContext(null),vt=({items:t,activeTab:r,onTabChange:s,className:n})=>{const[a,o]=d.useState(t[0]?.id||""),i=r||a,b=g=>{s?s(g):o(g)};return e.jsx("div",{className:f("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&&b(g.id),disabled:g.disabled,className:f("border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-fast",{"border-accent-border text-text":i===g.id,"border-transparent text-text-muted hover:text-text":i!==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:f("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",i===g.id?"bg-accent-soft text-accent":"bg-surface-hover text-text-muted"),children:g.badge})]})},g.id))})})},Ee=({items:t,defaultTab:r,activeTab:s,onTabChange:n,variant:a="default",size:o="md",className:i})=>{const[b,g]=d.useState(r||s||t[0]?.id||""),y=s||b,m=v=>{n?n(v):g(v)},u={activeTab:y,setActiveTab:m},x=t.find(v=>v.id===y),h=f("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"},i),N=(v,p)=>{const z="transition-colors duration-fast font-medium",w={"text-xs px-2 py-1":o==="sm","text-sm px-3 py-2":o==="md","text-base px-4 py-3":o==="lg"},H={"border-b-2 -mb-px":a==="default","rounded-md":a==="pills","border-b-2 pb-2":a==="underline"},R={"opacity-50 cursor-not-allowed":v.disabled,"cursor-pointer":!v.disabled},G=p?{"border-accent-border text-text":a==="default"||a==="underline","bg-surface text-text shadow-none":a==="pills"}:{},V=!p&&!v.disabled?{"border-transparent text-text-muted hover:text-text":a==="default","text-text-muted hover:text-text":a==="pills","border-transparent text-text-muted hover:text-text hover:border-border":a==="underline"}:{};return f(z,w,H,R,G,V)};return e.jsx(gt.Provider,{value:u,children:e.jsxs("div",{children:[e.jsx("div",{className:h,role:"tablist",children:t.map(v=>e.jsx("button",{type:"button",role:"tab","aria-selected":y===v.id,"aria-controls":`tabpanel-${v.id}`,disabled:v.disabled,onClick:()=>!v.disabled&&m(v.id),className:N(v,y===v.id),children:e.jsxs("span",{className:"flex items-center gap-2",children:[v.label,v.badge&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-surface-hover text-text-muted",children:v.badge})]})},v.id))}),x?.content&&e.jsx("div",{role:"tabpanel",id:`tabpanel-${y}`,"aria-labelledby":`tab-${y}`,className:"mt-4",children:x.content})]})})},jt={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full mx-4"};function Me({open:t,onClose:r,title:s,size:n="md",closeOnBackdropClick:a=!0,closeOnEscape:o=!0,className:i,backdropClassName:b,children:g,footer:y,showCloseButton:m=!0}){const u=d.useRef(null),x=d.useRef(null);d.useEffect(()=>{if(!t||!o)return;const N=v=>{v.key==="Escape"&&r()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[t,o,r]),d.useEffect(()=>(t?(x.current=document.activeElement,u.current&&u.current.focus(),document.body.style.overflow="hidden"):(x.current&&x.current.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}),[t]);const h=N=>{a&&N.target===N.currentTarget&&r()};return t?e.jsx("div",{className:f("fixed inset-0 z-modal flex items-center justify-center p-4","bg-scrim",b),onClick:h,children:e.jsxs("div",{ref:u,className:f("relative w-full bg-surface rounded-lg shadow-modal","focus:outline-none",jt[n],i),role:"dialog","aria-modal":"true","aria-labelledby":s?"modal-title":void 0,tabIndex:-1,children:[(s||m)&&e.jsxs("div",{className:"flex items-center justify-between p-6 pb-0",children:[s&&e.jsx("span",{id:"modal-title",className:"text-lg font-semibold text-text",children:s}),m&&e.jsx("button",{onClick:r,className:"p-1 text-text-muted hover:text-text transition-colors","aria-label":"Close modal",children:e.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-6",children:g}),y&&e.jsx("div",{className:"px-6 py-4",children:y})]})}):null}const yt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-md",xl:"text-lg"},Nt={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},wt={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"},kt={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"},Ct={tight:"leading-tight",normal:"leading-normal",relaxed:"leading-relaxed"},Y=({variant:t="body",size:r="md",weight:s="normal",color:n="current",align:a="left",truncate:o=!1,italic:i=!1,underline:b=!1,lineHeight:g="normal",as:y,className:m,children:u,...x})=>{const h=y||St(t),N=t==="caption",v=t==="label",p=t==="code",z=f("font-sans",N&&"text-xs text-text-subtle",v&&"text-xs font-semibold uppercase tracking-label text-text-subtle",p&&"font-mono text-sm rounded-sm bg-surface-hover px-1 py-0.5",!N&&!v&&!p&&yt[r],!v&&Nt[s],wt[n],kt[a],t==="body"&&Ct[g],i&&"italic",b&&"underline",o&&"truncate",m);return e.jsx(h,{className:z,...x,children:u})};function St(t){return{body:"p",caption:"span",label:"span",code:"code"}[t]||"p"}const Le=({value:t,onChange:r,label:s,placeholder:n="Select or upload a file",error:a,disabled:o,accept:i,onListFiles:b,onListMounts:g,onUploadFile:y,onDownloadFile:m,onRegisterFile:u})=>{const[x,h]=d.useState(!1),[N,v]=d.useState([]),[p,z]=d.useState(null),[w,H]=d.useState("/"),[R,G]=d.useState([]),[V,D]=d.useState(!1),[W,M]=d.useState(""),[F,A]=d.useState(typeof t=="object"?t:null),[l,j]=d.useState(!1),[E,k]=d.useState(""),L=d.useRef(null);d.useEffect(()=>{x&&S()},[x]),d.useEffect(()=>{x&&p&&Z()},[x,p,w,W]);const S=async()=>{D(!0);try{const c=await g?.();c?.data&&v(c.data)}catch(c){console.error("Failed to load mounts",c)}finally{D(!1)}},Z=async()=>{if(p){D(!0);try{const c=await b?.({mountId:p.id,name:W,path:w});c?.data&&G(c.data)}catch(c){console.error("Failed to load files",c)}finally{D(!1)}}},ee=async c=>{const C=c.target.files?.[0];if(C){D(!0);try{const O=await C.arrayBuffer(),q=new Uint8Array(O),B={id:`local-${Date.now()}`,name:C.name,type:"file",path:"/",mimeType:C.type||"application/octet-stream",size:C.size,mountId:"local",providerKey:C.name,ownerId:"me"};A(B),r(B,q),h(!1)}catch(O){console.error("Local file selection failed",O)}finally{D(!1)}}},X=async c=>{const C=c.target.files?.[0];if(!(!C||!p)){D(!0);try{const O=await C.arrayBuffer(),q=await y?.({file:new Uint8Array(O),filename:C.name,mimeType:C.type||"application/octet-stream",mountId:p.id,path:w});if(q?.data){const B=q.data;A(B),r(B,new Uint8Array(O)),h(!1)}}catch(O){console.error("Upload failed",O)}finally{D(!1)}}},T=async()=>{if(!(!E||!p)){D(!0);try{const c=`${w}${E}/`;u&&(await u({name:E,type:"folder",path:w,mimeType:"application/x-directory",size:0,mountId:p.id,providerKey:c,ownerId:"me"}),await Z()),j(!1),k("")}catch(c){console.error("Failed to create folder",c)}finally{D(!1)}}},P=async c=>{D(!0);try{const C=await m?.(c.id);A(c),r(c,C),h(!1)}catch(C){console.error("Failed to download file",C)}finally{D(!1)}},$=c=>{c.stopPropagation(),A(null),r(null)},I=d.useMemo(()=>{const c=new Set,C=[];return R.forEach(O=>{if(O.type==="folder"){O.path===w&&c.add(O.name);return}const q=O.providerKey||O.name,J=(w?q.substring(w.length):q).split("/").filter(xe=>xe!=="");J.length>1?c.add(J[0]):J.length===1&&C.push(O)}),{folders:Array.from(c).sort(),files:C.sort((O,q)=>O.name.localeCompare(q.name))}},[R,w]),Q=c=>{H(C=>`${C}${c}/`)},te=()=>{const c=w.split("/").filter(C=>C!=="");c.pop(),c.length===0?H("/"):H(`${c.join("/")}/`)},_=d.useMemo(()=>{const c=I.folders.map(C=>({id:`folder-${C}`,name:C,type:"folder"}));return I.files.forEach(C=>{c.push({...C,type:"file"})}),c},[I]),se=[{id:"name",header:"Name",accessor:"name",cell:(c,C)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{icon:C.type==="folder"?U.Folder:U.FileText,size:"sm",color:C.type==="folder"?"warning":"secondary"}),e.jsx("span",{className:f(C.type==="folder"&&"font-medium"),children:c})]})},{id:"type",header:"Type",accessor:c=>c.type==="folder"?"Folder":c.mimeType},{id:"size",header:"Size",accessor:c=>c.type==="file"?`${(c.size/1024).toFixed(1)} KB`:"-"},{id:"actions",header:"",accessor:"id",align:"right",cell:(c,C)=>e.jsx(K,{size:"sm",variant:"outline",onClick:O=>{O.stopPropagation(),C.type==="folder"?Q(C.name):P(C)},loading:V&&C.type==="file"&&F?.id===C.id,children:C.type==="folder"?"Open":"Select"})}],ue=[{id:"name",header:"Mount Name",accessor:"name",cell:c=>e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(re,{icon:U.HardDrive,size:"sm",color:"primary"}),e.jsx("span",{children:c})]})},{id:"actions",header:"",accessor:"id",align:"right",cell:(c,C)=>e.jsx(K,{size:"sm",variant:"outline",onClick:()=>z(C),children:"Open"})}];return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx(Y,{variant:"label",size:"sm",weight:"medium",children:s}),e.jsxs("div",{onClick:()=>!o&&h(!0),className:f("flex items-center gap-3 px-3 py-2 border rounded-lg cursor-pointer transition-colors","hover:border-border-strong bg-surface",a?"border-danger-border":"border-border",o&&"opacity-50 cursor-not-allowed bg-surface-sunk"),children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(re,{icon:F?U.FileText:U.HardDrive,color:F?"primary":"secondary"})}),e.jsx("div",{className:"flex-grow truncate",children:F?e.jsx("span",{className:"text-sm text-text font-medium",children:F.name}):e.jsx("span",{className:"text-sm text-text-muted",children:n})}),F&&!o&&e.jsx("button",{onClick:$,className:"p-1 hover:bg-surface-hover rounded",children:e.jsx(re,{icon:U.X,size:"xs"})})]}),a&&e.jsx(Y,{variant:"body",size:"xs",className:"text-danger-fg",children:a}),e.jsx(Me,{open:x,onClose:()=>{h(!1),z(null),H("/"),j(!1)},title:p?`Explorer: ${p.name}`:"Select Storage Mount",size:"lg",children:e.jsx(Ee,{variant:"pills",items:[{id:"remote",label:"Platform Storage",content:e.jsx("div",{className:"space-y-4",children:p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{w&&w!=="/"?te():z(null)},leftIcon:e.jsx(re,{icon:U.ArrowLeft,size:"xs"}),children:w?"Back":"Back to Mounts"}),e.jsx("div",{className:"flex items-center gap-1 text-xs text-text-muted overflow-hidden bg-surface-hover px-2 py-1 rounded",children:e.jsx("span",{className:"truncate",children:w})}),e.jsx("div",{className:"flex-grow min-w-40",children:e.jsx(ne,{placeholder:"Search...",value:W,onChange:c=>M(c.target.value),startIcon:e.jsx(U.Search,{size:14}),fullWidth:!0,size:"sm"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>j(!0),leftIcon:e.jsx(re,{icon:U.FolderPlus,size:"xs"}),children:"New Folder"}),e.jsx(K,{variant:"primary",size:"sm",onClick:()=>L.current?.click(),leftIcon:e.jsx(re,{icon:U.Upload,size:"xs"}),loading:V,children:"Upload"}),e.jsx("input",{type:"file",className:"hidden",ref:L,onChange:X,accept:i})]})]}),l&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-surface-sunk rounded-lg border border-border",children:[e.jsx(re,{icon:U.Folder,size:"sm",color:"warning"}),e.jsx(ne,{size:"sm",placeholder:"Folder name",value:E,onChange:c=>k(c.target.value),autoFocus:!0}),e.jsx(K,{size:"sm",onClick:T,loading:V,children:"Create"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>j(!1),children:"Cancel"})]}),e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(fe,{data:_,columns:se,loading:V,emptyContent:"This folder is empty",onRowClick:c=>c.type==="folder"?Q(c.name):P(c)})})]}):e.jsx("div",{className:"max-h-100 overflow-auto rounded-lg border border-border",children:e.jsx(fe,{data:N,columns:ue,loading:V,emptyContent:"No storage mounts configured",onRowClick:c=>z(c)})})})},{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(re,{icon:U.FileText,size:"xl",color:"primary"})}),e.jsx(Y,{variant:"label",size:"lg",weight:"semibold",children:"Select a file from your computer"}),e.jsxs(Y,{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(K,{variant:"primary",size:"lg",loading:V,className:"pointer-events-none",children:"Browse Local File"}),e.jsx("input",{type:"file",className:"hidden",onChange:ee,accept:i,disabled:V})]})]})})}]})})]})},Et={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"},de=d.forwardRef(({label:t,helperText:r,error:s,size:n="md",fullWidth:a=!1,loading:o=!1,containerClassName:i,labelClassName:b,className:g,id:y,rows:m=4,...u},x)=>{const h=d.useId(),N=y||`textarea-${h}`,v=!!s,p=s||r?`${N}-description`:void 0;return e.jsxs("div",{className:f("flex flex-col",a&&"w-full",i),children:[t&&e.jsx("label",{htmlFor:N,className:f(ye,v?"text-danger-fg":"text-text-subtle",b),children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:x,id:N,rows:m,"aria-invalid":v||void 0,"aria-describedby":p,className:f("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",Et[n],v?"border-danger-border bg-danger-soft":"border-border hover:border-border-strong",g),...u}),o&&e.jsx("span",{"aria-hidden":!0,className:"absolute top-2 right-3 size-icon-md animate-spin rounded-full border-2 border-border border-t-transparent"})]}),(s||r)&&e.jsx("p",{id:p,className:f("mt-1 text-xs",v?"text-danger-fg":"text-text-subtle"),children:s||r})]})});de.displayName="TextArea";function pe(t,r){return r.split(".").reduce((s,n)=>s&&typeof s=="object"&&n in s?s[n]:void 0,t)}function Mt(t,r,s){const n=r.split("."),a=Array.isArray(t)?[...t]:{...t};let o=a;for(let i=0;i<n.length-1;i++){const b=n[i],g=o[b];o[b]=g&&typeof g=="object"?Array.isArray(g)?[...g]:{...g}:{},o=o[b]}return o[n[n.length-1]]=s,a}function Lt(t,r){const s=r.split("."),n=Array.isArray(t)?[...t]:{...t};let a=n;for(let o=0;o<s.length-1;o++){const i=s[o];if(!a[i]||typeof a[i]!="object")return n;a[i]=Array.isArray(a[i])?[...a[i]]:{...a[i]},a=a[i]}return delete a[s[s.length-1]],n}const zt=({groups:t,data:r,onSubmit:s,onCancel:n,onChange:a,transform:o,validate:i,submitButton:b={label:"Submit",variant:"primary"},cancelButton:g={label:"Cancel",variant:"outline"},showButtons:y=!0,layout:m="vertical",size:u="md",loading:x=!1,className:h,ref:N,sdk:v})=>{const[p,z]=d.useState(r||{}),[w,H]=d.useState({}),[R,G]=d.useState({});d.useEffect(()=>{r&&z({...r})},[r]);const V=d.useCallback((l,j,E)=>{const k=t.flatMap(L=>L.items).find(L=>L.name===l);if(!k)return null;if(k.required&&(j==null||j===""))return`${k.label} is required`;if(k.type==="array"){if(k.required&&(!j||j.length===0))return`${k.label} cannot be empty.`;if(j&&!Array.isArray(j))return`${k.label} must be an array.`;if(Array.isArray(j)&&k.arrayFields){const L=[];let S=!1;if(j.forEach((Z,ee)=>{const X={};for(const T of k.arrayFields){const P=Z?.[T.name];if(T.required&&(P==null||P===""))X[T.name]=`${T.label} is required`,S=!0;else if(T.validator){const $=T.validator(P,Z);$&&(X[T.name]=$,S=!0)}}L[ee]=X}),S)return JSON.stringify(L)}}return k.validator?k.validator(j,E):null},[t]),D=d.useCallback((l,j)=>{let E=Mt(p,l,j);t.flatMap(S=>S.items).find(S=>S.name===l)?.removeIfEmpty&&(j==null||j==="")&&(E=Lt(E,l)),z(E),G(S=>({...S,[l]:!0}));const L=V(l,j,E);H(S=>({...S,[l]:L||""})),a?.(E,l)},[p,t,V,a]),W=d.useCallback(async l=>{if(console.log("handleSubmit"),l.preventDefault(),x)return;const j={},E=t.flatMap(L=>L.items);for(const L of E){if(L.hidden||L.conditional&&!L.conditional(p))continue;const S=V(L.name,pe(p,L.name),p);S&&(j[L.name]=S)}if(i){const L=i(p);L&&Object.assign(j,L)}if(H(j),console.log("newErrors",j),Object.keys(j).some(L=>j[L]))return;const k=o?o(p):p;await s?.(p,k)},[p,t,V,i,o,s,x]),M=d.useCallback(l=>{const j=pe(p,l.name),E=R[l.name]?w[l.name]:void 0,k=l.disabled||x,L={value:j||"",disabled:k,required:l.required,placeholder:l.placeholder,...l.fieldProps};switch(l.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ne,{...L,onChange:S=>D(l.name,S.target.value),type:l.textType||l.type,autoComplete:l.autocomplete,error:E,size:u});case"textarea":return e.jsx(de,{...L,onChange:S=>D(l.name,S.target.value),rows:4,error:E,size:u});case"select":return e.jsx(oe,{...L,onChange:S=>D(l.name,S),options:(l.options||[]).map(S=>({...S,value:String(S.value)})),searchable:l.searchable,multiple:l.multiple,allowCreate:l.allowCreate,error:E,size:u});case"checkbox":return e.jsx(le,{...L,checked:!!j,onChange:S=>D(l.name,S.target.checked),size:u});case"radio":return e.jsx("div",{className:"space-y-1",children:l.options?.map(S=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:l.name,value:S.value,checked:j===S.value,onChange:()=>D(l.name,S.value),disabled:k||S.disabled,className:"rounded-full border-border"}),e.jsx(Y,{variant:"label",size:"sm",children:S.label})]},S.value))});case"date":return e.jsx(ie,{...L,value:j?new Date(j):null,onChange:S=>D(l.name,S),size:u});case"file":return e.jsx(Le,{...L,value:j,onChange:S=>D(l.name,S),error:E,onListFiles:S=>v?.http.invoke({method:"POST",action:"storage.file.list",body:S}),onListMounts:()=>v?.http.invoke({method:"GET",action:"storage.mount"}),onUploadFile:S=>v?.http.invoke({method:"POST",action:"storage.file.upload",body:S}),onDownloadFile:S=>v?.http.invoke({method:"GET",action:`storage.file.${S}.download`}),onRegisterFile:S=>v?.http.invoke({method:"POST",action:"storage.file.folder",body:S})});case"folder":return e.jsx(Ne,{value:j||{},onChange:S=>D(l.name,S),onListFolders:()=>v?.http.invoke({method:"GET",action:"storage.mount"}),disabled:k,size:u,placeholder:l.placeholder});case"custom":return l.customComponent?.({value:j,onChange:S=>D(l.name,S),error:E,disabled:k});case"array":{const S=j||[];let Z=[];if(typeof E=="string"&&E.startsWith("["))try{Z=JSON.parse(E)}catch{}const ee=()=>{D(l.name,[...S,{}])},X=P=>{D(l.name,S.filter(($,I)=>I!==P))},T=(P,$,I)=>{const Q=[...S];Q[P]={...Q[P],[$]:I},D(l.name,Q)};return e.jsxs("div",{className:"space-y-2",children:[S.map((P,$)=>e.jsxs("div",{className:"p-4 border border-border rounded-lg bg-surface space-y-2 relative",children:[e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>X($),disabled:k,children:"Remove"})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:l.arrayFields?.map(I=>{const Q=Z?.[$]?.[I.name];return e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block",children:e.jsxs("span",{className:"block text-xs font-semibold uppercase tracking-label text-text-muted",children:[I.label,I.required&&e.jsx("span",{className:"text-danger-fg ml-1",children:"*"})]})}),(()=>{const te={value:P?.[I.name]||"",disabled:k,required:I.required,placeholder:I.placeholder,...I.fieldProps};switch(I.type){case"text":case"email":case"password":case"number":case"tel":case"url":return e.jsx(ne,{...te,onChange:_=>T($,I.name,_.target.value),type:I.textType||I.type,autoComplete:I.autocomplete,error:Q,size:u});case"textarea":return e.jsx(de,{...te,onChange:_=>T($,I.name,_.target.value),rows:4,error:Q,size:u});case"select":return e.jsx(oe,{...te,onChange:_=>T($,I.name,_),options:(I.options||[]).map(_=>({..._,value:String(_.value)})),searchable:I.searchable,multiple:I.multiple,allowCreate:I.allowCreate,error:Q,size:u});case"checkbox":return e.jsx(le,{...te,checked:!!P?.[I.name],onChange:_=>T($,I.name,_.target.checked),size:u});case"radio":return e.jsx("div",{className:"space-y-1",children:I.options?.map(_=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:`${l.name}.${$}.${I.name}`,value:_.value,checked:P?.[I.name]===_.value,onChange:()=>T($,I.name,_.value),disabled:k||_.disabled,className:"rounded-full border-border"}),e.jsx(Y,{variant:"label",size:"sm",children:_.label})]},_.value))});case"date":{const _=P?.[I.name];return e.jsx(ie,{...te,value:_?new Date(_):null,onChange:se=>T($,I.name,se),size:u})}case"custom":return I.customComponent?.({value:P?.[I.name],onChange:_=>T($,I.name,_),error:Q,disabled:k});default:return e.jsxs("p",{children:["Unsupported field type in array:"," ",I.type]})}})(),Q&&e.jsx(Y,{variant:"body",size:"sm",className:"text-danger-fg",children:Q})]},I.name)})})]},$)),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ee,disabled:k,children:["Add ",l.label]})]})}default:return null}},[p,R,w,x,u,D]),F=d.useCallback(l=>{if(l.conditional&&!l.conditional(p))return null;const j=l.items.filter(k=>!(k.hidden||k.conditional&&!k.conditional(p)));if(j.length===0)return null;const E=f("space-y-2",{"grid gap-2":l.layout==="grid","flex flex-wrap gap-2":l.layout==="flex"},l.layout==="grid"&&{"grid-cols-1":!l.columns||l.columns===1,"grid-cols-2":l.columns===2,"grid-cols-3":l.columns===3,"grid-cols-4":l.columns===4},l.className);return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 p-5 border border-border rounded-xl bg-surface",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx(Y,{variant:"label",size:"md",weight:"semibold",className:"text-text",children:l.title}),l.description&&e.jsx(Y,{variant:"body",size:"sm",className:"text-text-muted mt-1 leading-relaxed",children:l.description})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:E,children:j.map(k=>(R[k.name]&&w[k.name],e.jsxs("div",{className:f("space-y-1",k.width&&typeof k.width=="string"&&`w-[${k.width}]`,k.width&&typeof k.width=="number"&&`col-span-${k.width}`),children:[k.type!=="custom"&&e.jsxs("label",{className:"block text-xs font-semibold uppercase tracking-label text-text-muted",children:[k.label,k.required&&e.jsx("span",{className:"text-danger-fg ml-1",children:"*"})]}),M(k)]},k.name)))})})]},l.id)},[p,R,w,M]),A=f("space-y-6",{"max-w-md":u==="sm","max-w-2xl":u==="md","max-w-4xl":u==="lg","max-w-full":u==="full"},h);return e.jsxs("form",{ref:N,onSubmit:W,className:A,children:[e.jsx("div",{className:"space-y-8",children:t.map(F)}),y&&e.jsxs("div",{className:f("flex gap-3 justify-end pt-8"),children:[n&&e.jsx(K,{type:"button",variant:g.variant,size:g.size||u,disabled:g.disabled||x,onClick:n,className:g.className,children:g.label}),e.jsx(K,{type:"submit",variant:b.variant,size:b.size||u,disabled:b.disabled||x,loading:x,className:b.className,children:b.label})]})]})},Tt={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"},$t={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"},At={default:"bg-surface-hover",primary:"bg-accent",secondary:"bg-surface-hover",success:"bg-success",warning:"bg-warning",error:"bg-danger",info:"bg-info"};function Dt({variant:t="default",size:r="md",dot:s=!1,icon:n,dismissible:a=!1,onDismiss:o,className:i,children:b,...g}){return e.jsxs("span",{className:f("inline-flex items-center font-medium rounded-full",Tt[t],$t[r],i),...g,children:[s&&e.jsx("span",{className:f("w-2 h-2 rounded-full mr-1.5",At[t])}),n&&e.jsx("span",{className:f("flex-shrink-0",b&&"mr-1"),children:n}),b,a&&o&&e.jsx("button",{onClick:o,className:"ml-1.5 flex-shrink-0 hover:opacity-70 transition-opacity","aria-label":"Remove badge",children:e.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})}const It={neutral:"bg-surface-hover text-text-muted",success:"bg-success-soft text-success-fg"};function Pt({icon:t,tone:r="neutral",title:s,description:n,actions:a,card:o=!1,className:i,...b}){return e.jsxs("div",{className:f("flex flex-col items-center gap-2.5 text-center",o&&"rounded-lg border border-border bg-surface px-11 py-9 shadow-overlay",i),...b,children:[t!=null&&e.jsx("span",{className:f("flex size-disc items-center justify-center rounded-full text-2xl",It[r]),children:t}),e.jsx("div",{className:"text-lg font-semibold text-text",children:s}),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 Bt({children:t,className:r,...s}){return e.jsx("kbd",{className:f("inline-flex items-center rounded border border-border px-1.5 py-px text-xs font-medium leading-none text-text-muted",r),...s,children:t})}const Rt={sm:"h-1",md:"h-1.5"},Ft={accent:"bg-accent",success:"bg-success"};function Ot({value:t,variant:r="accent",size:s="md",className:n,...a}){const o=Math.max(0,Math.min(100,t));return e.jsx("div",{role:"progressbar","aria-valuenow":Math.round(o),"aria-valuemin":0,"aria-valuemax":100,className:f("w-full overflow-hidden rounded-full bg-surface-hover",Rt[s],n),...a,children:e.jsx("div",{className:f("h-full rounded-full transition-[width] duration-300 ease-out",Ft[r]),style:{width:`${o}%`}})})}const Vt={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"},Wt={primary:"text-accent",secondary:"text-text-muted",white:"text-white",current:"text-current"},qt={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"};function Ht({size:t="md",variant:r="primary",label:s="Loading...",showLabel:n=!1,className:a,...o}){return e.jsxs("div",{className:f("inline-flex items-center",n?"flex-col space-y-2":"",a),...o,children:[e.jsxs("svg",{className:f("animate-spin",Vt[t],Wt[r]),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:f("text-text-muted",qt[t]),children:s}),!n&&e.jsx("span",{className:"sr-only",children:s})]})}function Gt({title:t,icon:r=e.jsx(U.Sparkles,{className:"size-icon-md","aria-hidden":!0}),action:s,children:n,className:a,...o}){return e.jsxs("div",{className:f("flex flex-col gap-2 rounded-xl border p-4","border-assistant-border bg-assistant-soft",a),...o,children:[e.jsxs("div",{className:"flex items-center gap-2 text-assistant",children:[e.jsx("span",{"aria-hidden":!0,children:r}),e.jsx("span",{className:"text-sm font-semibold",children:t}),s&&e.jsx("span",{className:"ml-auto",children:s})]}),n&&e.jsx("div",{className:"text-sm leading-relaxed text-text",children:n})]})}const Ut={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 _t(t){if(!t)return"?";const r=t.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return r.length>=2?(r[0][0]+r[1][0]).toUpperCase():r.length===1?r[0].slice(0,2).toUpperCase():"?"}const ze=({name:t,src:r,size:s="sm",className:n,title:a})=>{const[o,i]=d.useState(!1),b=f("inline-flex items-center justify-center rounded-full overflow-hidden shrink-0 font-semibold select-none bg-surface-hover-border-emphasis text-text",Ut[s],n);return r&&!o?e.jsx("img",{src:r,alt:t??"",title:a??t,className:f(b,"object-cover"),onError:()=>i(!0)}):e.jsx("span",{className:b,title:a??t,"aria-label":t,children:_t(t)})},ge="ring-surface",Kt="ring-surface-accent",Jt=({people:t,max:r=4,size:s="sm",className:n})=>{if(t.length===0)return null;const a=t.slice(0,r),o=t.length-a.length;return e.jsxs("span",{className:f("inline-flex items-center",n),children:[a.map((i,b)=>e.jsx(ze,{name:i.name,src:i.src,size:s,title:i.name?i.seen===!1?`${i.name} — nog niet gelezen`:i.name:void 0,className:f(b>0&&"-ml-2",i.owner?Kt:ge,i.seen===!1&&"opacity-40")},i.id??`${i.name}-${b}`)),o>0&&e.jsxs("span",{className:f("inline-flex items-center justify-center rounded-full shrink-0 -ml-2 font-semibold bg-surface-hover text-text-muted",s==="xs"?"w-5 h-5 text-xs":s==="md"?"w-7 h-7 text-xs":s==="lg"?"w-9 h-9 text-xs":"w-6 h-6 text-xs",ge),children:["+",o]})]})},ve={mail:{fg:"text-ch-mail",bg:"bg-ch-mail"},wa:{fg:"text-ch-wa",bg:"bg-ch-wa"},chat:{fg:"text-ch-chat",bg:"bg-ch-chat"},tel:{fg:"text-ch-tel",bg:"bg-ch-tel"},note:{fg:"text-ch-note",bg:"bg-ch-note"}},Yt={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 Xt({channel:t,children:r,size:s="md",className:n,title:a}){const o=ve[t in ve?t:"note"];return e.jsx("span",{title:a,className:f("inline-flex shrink-0 items-center justify-center font-bold",Yt[s],o.fg,o.bg,n),children:r})}const Zt=({src:t,alt:r,size:s="md",aspectRatio:n="auto",radius:a="md",showLoading:o=!0,showError:i=!0,fallback:b,loadingContent:g,errorContent:y,className:m,onLoad:u,onError:x,...h})=>{const[N,v]=d.useState(!0),[p,z]=d.useState(!1),[w,H]=d.useState(t),R=A=>{v(!1),z(!1),u?.(A)},G=A=>{if(v(!1),z(!0),b&&w!==b){H(b),z(!1),v(!0);return}x?.(A)},V=f("relative overflow-hidden bg-surface-hover",{"w-8 h-8":s==="xs","w-12 h-12":s==="sm","w-16 h-16":s==="md","w-24 h-24":s==="lg","w-32 h-32":s==="xl","w-full h-full":s==="full"},{"aspect-square":n==="square","aspect-video":n==="video","aspect-portrait":n==="portrait","aspect-landscape":n==="landscape"},{"rounded-none":a==="none","rounded-sm":a==="sm","rounded-md":a==="md","rounded-lg":a==="lg","rounded-xl":a==="xl","rounded-full":a==="full"},m),D=f("w-full h-full object-cover transition-opacity duration-fast",{"opacity-0":N||p,"opacity-100":!N&&!p}),W=f("absolute inset-0 flex items-center justify-center","text-text-muted"),M=e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"w-6 h-6 bg-surface-hover rounded"})}),F=e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-6 h-6 mx-auto mb-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsx("span",{className:"text-xs",children:"Failed to load"})]});return e.jsxs("div",{className:V,children:[e.jsx("img",{...h,src:w,alt:r,className:D,onLoad:R,onError:G}),N&&o&&e.jsx("div",{className:W,children:g||M}),p&&i&&e.jsx("div",{className:W,children:y||F})]})};function Qt({items:t,getRowKey:r,variant:s="divided",leading:n,renderItem:a,trailing:o,onSelect:i,isActive:b,unread:g,dimmed:y,selectable:m=!1,selectedItems:u=[],onSelectionChange:x,bulkActions:h,bordered:N=!1,emptyContent:v,loading:p=!1,loadingRows:z=4,className:w,"aria-label":H}){const R=(A,l)=>r?r(A,l):l,G=A=>u.includes(A),V=(A,l)=>{x&&x(l?[...u,A]:u.filter(j=>j!==A))},D=A=>x?.(A?[...t]:[]),W=f("flex flex-col",N&&"overflow-hidden rounded-lg border border-border-subtle",w);if(p)return e.jsx("div",{className:W,children:Array.from({length:z}).map((A,l)=>e.jsxs("div",{className:f("flex animate-pulse items-center gap-3 px-4 py-2.5",s==="divided"&&l>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-${l}`))});if(t.length===0&&v)return e.jsx("div",{className:W,children:v});const M=t.length>0&&u.length===t.length,F=u.length>0&&!M;return e.jsxs("div",{className:W,children:[m&&u.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(le,{checked:M,indeterminate:F,onChange:A=>D(A.target.checked),"aria-label":"Alles selecteren"}),e.jsxs("span",{className:"text-xs text-text-subtle",children:[u.length," geselecteerd"]}),h&&e.jsx("div",{className:"ml-auto flex gap-2",children:h})]}),e.jsx("ul",{"aria-label":H,className:"flex flex-col",children:t.map((A,l)=>{const j=b?.(A,l)??!1,E=g?.(A,l)??!1,k=y?.(A,l)??!1,L=m&&G(A);return e.jsxs("li",{onClick:i?()=>i(A,l):void 0,className:f("flex items-center gap-3 px-4 py-2.5 text-base","transition-colors duration-fast ease-out",s==="divided"&&l>0&&"border-t border-border-subtle",i&&"cursor-pointer",j||L?"bg-accent-soft text-text":i&&"hover:bg-surface-hover",E&&"font-bold",k&&"opacity-55"),children:[m&&e.jsx("span",{onClick:S=>S.stopPropagation(),children:e.jsx(le,{checked:G(A),onChange:S=>V(A,S.target.checked),"aria-label":"Rij selecteren"})}),s==="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(A,l)}),E&&e.jsx("span",{"aria-hidden":!0,className:"size-1.5 shrink-0 rounded-full bg-accent",title:"Ongelezen"}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:a?a(A,l):String(A)}),o&&e.jsx("span",{className:"shrink-0 text-xs text-text-subtle",children:o(A,l)})]},R(A,l))})})]})}const es={default:"text-text",urgent:"text-danger-fg",success:"text-success-fg"},ts={default:"border-border",urgent:"border-danger-border",success:"border-border"};function ss({value:t,label:r,tone:s="default",className:n,...a}){return e.jsxs("div",{className:f("rounded-xl border bg-surface px-4 py-3.5",ts[s],n),...a,children:[e.jsx("div",{className:f("text-2xl font-semibold",es[s]),children:t}),e.jsx("div",{className:"pt-0.5 text-xs text-text-muted",children:r})]})}const rs=({title:t,subtitle:r,actions:s=[],children:n,className:a,backLabel:o="Back",backClassName:i,onBack:b,editable:g=!1,onTitleChange:y})=>{const[m,u]=d.useState(!1),[x,h]=d.useState(t),N=d.useRef(null);d.useEffect(()=>{h(t)},[t]),d.useEffect(()=>{m&&N.current&&(N.current.focus(),N.current.select())},[m]);const v=()=>{g&&u(!0)},p=()=>{u(!1),x.trim()!==""&&x!==t&&y?y(x.trim()):h(t)},z=w=>{w.key==="Enter"?N.current?.blur():w.key==="Escape"&&(h(t),u(!1))};return e.jsxs("div",{className:f("p-5 pb-3 border-b border-border",a),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:[b&&e.jsx("button",{type:"button",onClick:b,className:f("flex items-center text-sm cursor-pointer transition",i),children:e.jsx(U.ArrowLeft,{size:16,color:"currentColor"})}),m?e.jsx("input",{ref:N,type:"text",value:x,onChange:w=>h(w.target.value),onBlur:p,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:v,className:f("text-2xl font-semibold truncate",g&&"cursor-pointer"),title:g?"Klik om te bewerken":void 0,children:t}),r&&e.jsx("span",{className:"shrink-0 text-base text-text-muted truncate",children:r}),g&&e.jsx(U.Pencil,{size:15,onClick:v,className:"shrink-0 cursor-pointer text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]})]})}),s.length>0&&e.jsx("div",{className:"flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3",children:s.map(w=>w.splitOptions&&w.splitOptions.length>0?e.jsx(he,{label:w.label,onClick:w.onClick,icon:w.icon,variant:w.variant==="primary"?"primary":"secondary",options:w.splitOptions,disabled:w.disabled},w.id):e.jsx(K,{variant:w.variant??"secondary",onClick:H=>{H.stopPropagation(),H.target.blur(),w.onClick()},disabled:w.disabled,leftIcon:w.icon,children:w.label},w.id))})]}),n&&e.jsx("div",{className:"mt-4",children:n})]})},ns=({actions:t=[],onBack:r,backLabel:s="Back",className:n,children:a})=>e.jsxs("div",{className:f("flex items-center gap-2 mb-3",n),children:[r&&e.jsx(K,{variant:"ghost",size:"sm",onClick:r,leftIcon:e.jsx(U.ArrowLeft,{size:14}),children:s}),a&&e.jsx("div",{className:"flex-1 min-w-0",children:a}),t.length>0&&e.jsx("div",{className:f("flex flex-wrap gap-2",!a&&"ml-auto"),children:t.map(o=>o.splitOptions&&o.splitOptions.length>0?e.jsx(he,{label:o.label,onClick:o.onClick,icon:o.icon,variant:o.variant==="primary"?"primary":"secondary",options:o.splitOptions,disabled:o.disabled},o.id):e.jsx(K,{variant:o.variant??"secondary",size:"sm",onClick:i=>{i.stopPropagation(),i.target.blur(),o.onClick()},disabled:o.disabled,leftIcon:o.icon,children:o.label},o.id))})]});function as({label:t,dotColor:r,onClick:s,className:n}){return e.jsxs("button",{type:"button",onClick:s,className:f("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:[r&&e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:r},"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:t}),e.jsx("span",{"aria-hidden":!0,className:"shrink-0 opacity-70",children:"↗"})]})}function ls(t,r){return r.split(".").reduce((s,n)=>s&&typeof s=="object"&&n in s?s[n]:void 0,t)}const os=({groups:t,data:r,size:s="md",className:n})=>{const a=m=>{if(!m)return"-";try{return new Date(m).toLocaleDateString("nl-NL",{year:"numeric",month:"long",day:"numeric"})}catch{return String(m)}},o=m=>m?"Ja":"Nee",i=(m,u)=>{if(!u)return String(m||"-");const x=u.find(h=>h.value===m);return x?x.label:String(m||"-")},b=d.useCallback(m=>{const u=ls(r,m.name);if(m.type==="array"){const h=u;return!h||h.length===0?e.jsx(Y,{variant:"body",size:"sm",className:"text-text-muted",children:"Geen items"}):e.jsx("div",{className:"space-y-3",children:h.map((N,v)=>e.jsxs("div",{className:"p-4 border border-border rounded-xl space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(Y,{variant:"label",size:"sm",weight:"medium",className:"text-text-muted",children:[m.label," ",v+1]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:m.arrayFields?.map(p=>{const z=N?.[p.name];let w="-";switch(p.type){case"text":case"email":case"number":case"tel":case"url":case"textarea":w=z||"-";break;case"select":case"radio":w=i(z,p.options);break;case"checkbox":w=o(z);break;case"date":w=a(z);break;case"custom":w=p.customComponent?.({value:z});break;default:w=String(z||"-")}return p.format&&(w=p.format(z,N)),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Y,{variant:"label",size:"xs",className:"text-text-muted",children:p.label}),e.jsx(Y,{variant:"body",size:"sm",className:"text-text",children:w})]},p.name)})})]},v))})}if(m.type==="custom"&&m.customComponent)return m.customComponent({value:u});if(m.format){const h=m.format(u,r);return e.jsx(Y,{variant:"body",size:"sm",className:"text-text",children:h})}let x="-";switch(m.type){case"text":case"email":case"password":case"number":case"tel":case"url":x=u?String(u):"-";break;case"textarea":x=u?e.jsx("div",{className:"whitespace-pre-wrap",children:String(u||"-")}):"-";break;case"select":case"radio":x=i(u,m.options);break;case"checkbox":x=o(u);break;case"date":x=a(u);break;default:x=u?String(u):"-"}return e.jsx(Y,{variant:"body",size:"sm",className:"text-text",children:x})},[r]),g=d.useCallback(m=>{if(m.conditional&&!m.conditional(r))return null;const u=m.items.filter(h=>!(h.hidden||h.conditional&&!h.conditional(r)));if(u.length===0)return null;const x=f("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(Y,{variant:"label",size:"lg",weight:"semibold",className:"text-text",children:m.title}),m.description&&e.jsx(Y,{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:x,children:u.map(h=>e.jsxs("div",{className:f("space-y-1",h.width&&typeof h.width=="string"&&`w-[${h.width}]`,h.width&&typeof h.width=="number"&&`col-span-${h.width}`),children:[h.type!=="custom"&&e.jsx(Y,{variant:"label",size:"sm",className:"font-medium text-text-muted",children:h.label}),b(h)]},h.name))})})]},m.id)},[r,b]),y=f("space-y-6",{"max-w-md":s==="sm","max-w-2xl":s==="md","max-w-4xl":s==="lg","max-w-full":s==="full"},n);return e.jsx("div",{className:y,children:e.jsx("div",{className:"space-y-8",children:t.map(g)})})},Te=({item:t,isSelectedHandler:r,onClick:s,depth:n=0})=>{const[a,o]=d.useState(t.defaultCollapsed??!1),i=t.children&&t.children.length>0,b=i&&n===0,g=()=>{i&&o(!a)},y=r?r(t.path):!1;return e.jsxs("li",{children:[e.jsxs("div",{className:f("flex flex-row w-full py-1 rounded-lg items-center h-8 transition-colors cursor-pointer px-2.5 pr-1 no-underline text-sm",{"bg-accent-soft text-accent":y&&!i,"hover:bg-surface-hover":!(y&&!i),"font-semibold":y||b}),onClick:()=>{i?g():t.path&&s?.(t.path)},children:[t.icon&&e.jsx("span",{className:"mr-2 shrink-0",children:t.icon}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:t.label}),t.count!==void 0&&t.count>0&&e.jsx("span",{className:"ml-2 mr-1.5",children:t.count}),i&&e.jsx("span",{className:`${a?"collapsed":""}`,children:e.jsx(U.ChevronDownIcon,{className:"w-4 h-4 text-text-muted"})})]}),i&&!a&&e.jsx("ul",{className:"sidebar-menu-nested-items mb-1",children:t.children?.map((m,u)=>e.jsx(Te,{item:m,isSelectedHandler:r,onClick:s,depth:n+1},u))})]})},cs=({title:t,actionIcons:r,items:s,isSelectedHandler:n,onClick:a,preMenuItemsComponent:o})=>e.jsxs("div",{className:"flex flex-col h-screen mb-6",children:[e.jsxs("div",{className:"sidebar-menu-header",children:[e.jsx("span",{className:"text-lg font-semibold text-text mb-2",children:t}),e.jsx("div",{className:"sidebar-menu-actions",children:r?.map((i,b)=>e.jsx("span",{className:"sidebar-menu-action-icon",children:i},b))})]}),o&&e.jsx("div",{className:"sidebar-menu-pre-items mb-4",children:o}),e.jsx("ul",{children:s.map((i,b)=>!i.path&&!i.label&&!i.children?e.jsx("span",{className:"flex w-full h-4"},b):e.jsx(Te,{item:i,isSelectedHandler:n,onClick:a},b))})]}),is={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl","3xl":"text-3xl","4xl":"text-3xl"},ds={light:"font-normal",normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},us={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"},xs={left:"text-left",center:"text-center",right:"text-right"},ms=({level:t=1,size:r,weight:s="semibold",color:n="current",align:a="left",truncate:o=!1,className:i,children:b,...g})=>{const y=`h${t}`,m=f("font-sans text-pretty",is[r||fs(t)],ds[s],us[n],xs[a],o&&"truncate",i);return e.jsx(y,{className:m,...g,children:b})};function fs(t){return{1:"2xl",2:"xl",3:"lg",4:"lg",5:"md",6:"md"}[t]||"md"}const hs=({commands:t,isOpen:r,onClose:s,labels:n,initialCommandPath:a,initialActiveIndex:o})=>{const[i,b]=d.useState(""),[g,y]=d.useState(a||[]),[m,u]=d.useState(o||0),x=d.useRef(null),h=d.useRef(null),v=(g.length?t.find(p=>p.id===g[0])?.subCommands||[]:t).filter(p=>p.label.toLowerCase().includes(i.toLowerCase()));return d.useEffect(()=>{r||(b(""),y(a||[]),u(o||0))},[r]),d.useEffect(()=>{const p=z=>{if(r){if(z.key==="Escape")s();else if(z.key==="ArrowUp")u(w=>w>0?w-1:v.length-1);else if(z.key==="ArrowDown")u(w=>w<v.length-1?w+1:0);else if(z.key==="Enter"){const w=v[m];w&&(w.subCommands?(y([...g,w.id]),u(0)):w.action&&(w.action(),s()))}}};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[r,s,v,m,g]),d.useEffect(()=>{const p=z=>{x.current&&!x.current.contains(z.target)&&s()};return r&&document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r,s]),d.useEffect(()=>{if(!r)return;h.current?.querySelector(`[data-index="${m}"]`)?.scrollIntoView({block:"nearest"})},[m,r]),r?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:x,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 flex-shrink-0",children:[e.jsx(U.Search,{className:"w-4 h-4 text-text-muted shrink-0"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:n?.searchPlaceholder||"Search commands...",value:i,onChange:p=>b(p.target.value),className:"w-full border-0 bg-transparent py-2 text-text focus:outline-none"})]}),e.jsxs("div",{ref:h,className:"mt-2 pt-2 text-sm border-t border-border max-h-dialog-list overflow-y-auto",children:[v.length===0&&e.jsx("div",{className:"text-text-muted text-center text-sm",children:n?.noCommandsFound||"No commands found"}),v.map((p,z)=>e.jsxs("div",{"data-index":z,className:`flex items-center p-2 cursor-pointer rounded-md ${z===m?"bg-accent-soft text-accent":"text-text"}`,onClick:()=>{p.subCommands?(y([...g,p.id]),u(0)):p.action&&(p.action(),s())},onMouseEnter:()=>u(z),children:[p.icon&&e.jsx("span",{className:"mr-3",children:p.icon}),e.jsx("span",{className:"flex-grow",children:p.label}),p.subCommands&&e.jsx("span",{className:"text-text-muted",children:e.jsx(U.ChevronRight,{className:"w-4 h-4"})})]},p.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},bs={none:"p-0",xs:"p-1",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8","2xl":"p-12"},ps={none:"m-0",xs:"m-1",sm:"m-2",md:"m-4",lg:"m-6",xl:"m-8","2xl":"m-12"},gs={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"},vs={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",full:"rounded-full"},js={none:"shadow-none",sm:"shadow-none",md:"shadow-overlay",lg:"shadow-overlay",xl:"shadow-modal","2xl":"shadow-modal"},ys={none:"border-0",sm:"border",md:"border-2",lg:"border-4"},Ns={primary:"border-accent-border",secondary:"border-border",accent:"border-accent-border",success:"border-success-border",warning:"border-warning-border",error:"border-danger-border",info:"border-info-border",neutral:"border-border-subtle",white:"border-border-subtle"},be=d.forwardRef(({padding:t,margin:r,background:s,radius:n,shadow:a,border:o,borderColor:i,className:b,children:g,...y},m)=>e.jsx("div",{ref:m,className:f(t&&bs[t],r&&ps[r],s&&gs[s],n&&vs[n],a&&js[a],o&&ys[o],i&&Ns[i],b),...y,children:g}));be.displayName="Box";const ws=({children:t,title:r,...s})=>e.jsxs(be,{background:"module",radius:"lg",shadow:"none",border:"sm",borderColor:"neutral",...s,children:[r&&e.jsx("span",{className:"mb-2 block text-sm font-semibold text-text",children:r}),t]});function ks({identifier:t,resourceLoader:r,framework:s="react",fallback:n,componentProps:a,className:o}){const i=d.useRef(null),[b,g]=d.useState(!0),[y,m]=d.useState(null),u=d.useRef(null);return d.useRef(null),d.useEffect(()=>{let x=!0;return(async()=>{g(!0);try{const N=await r();if(!x)return;const v=N.component||N.default||N;m(s==="react"?()=>v:()=>N)}catch(N){console.error(`[FederatedResource] Load failed: ${t}`,N)}finally{x&&g(!1)}})(),()=>{x=!1}},[t,r]),d.useEffect(()=>{if(b||!y||s==="react")return;const x=i.current;if(x){if(s==="svelte"){const h=y.default||y,N=new h({target:x,props:a||{}});return u.current=N,()=>N.$destroy()}if(y.mount){const h=y.mount({container:x,props:a||{}});return()=>{typeof h=="function"?h():y.unmount?.(x)}}}},[y,s,b]),d.useEffect(()=>{s==="svelte"&&u.current&&u.current.$set?.(a)},[a,s]),e.jsxs("div",{ref:i,className:o,style:{display:"contents"},children:[b&&n,s==="react"&&y&&e.jsx(y,{...a})]})}class Cs extends d.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,s){console.error(`[ErrorBoundary] Error in ${this.props.name||"Component"}:`,r,s)}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=Gt;exports.Avatar=ze;exports.AvatarStack=Jt;exports.Badge=Dt;exports.Box=be;exports.Button=K;exports.ButtonGroup=Ve;exports.Card=ws;exports.ChannelBadge=Xt;exports.Checkbox=le;exports.CommandPalette=hs;exports.ContentLoading=ke;exports.DatePicker=ie;exports.Dropdown=Ce;exports.EmptyState=Pt;exports.ErrorBoundary=Cs;exports.FederatedResource=ks;exports.FilterChip=Ge;exports.FolderSelect=Ne;exports.Form=zt;exports.Heading=ms;exports.Icon=re;exports.Image=Zt;exports.Kbd=Bt;exports.KpiCard=ss;exports.Link=Je;exports.List=Qt;exports.MeetingGrid=Ie;exports.Modal=Me;exports.PageHeader=rs;exports.PageToolbar=ns;exports.ParticipantTile=Pe;exports.Popover=je;exports.ProgressBar=Ot;exports.SearchableTextField=we;exports.SegmentedToggle=Xe;exports.Select=oe;exports.SidebarMenu=cs;exports.SourceChip=as;exports.Spinner=Ht;exports.SplitButton=he;exports.StorageInput=Le;exports.TabBar=vt;exports.Table=fe;exports.Tabs=Ee;exports.Text=Y;exports.TextArea=de;exports.TextField=ne;exports.VideoSurface=Be;exports.View=os;exports.cn=f;exports.createSizes=De;exports.createVariants=Ae;
2
2
  //# sourceMappingURL=index.cjs.map