@powerhousedao/connect 5.1.0-dev.13 → 5.1.0-dev.15
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/assets/{AddDriveModal-CJ-bVy3_.js → AddDriveModal-CFiZUwbG.js} +1 -1
- package/dist/assets/{ClearStorageModal-D3RZAgrW.js → ClearStorageModal-B08dxM9Q.js} +1 -1
- package/dist/assets/{CookiesPolicyModal-BIve839u.js → CookiesPolicyModal-1L0r5OwI.js} +1 -1
- package/dist/assets/CreateDocumentModal-D56YVF3R.js +1 -0
- package/dist/assets/{DebugSettingsModal-BXk4_2QI.js → DebugSettingsModal-FF8F5iL9.js} +1 -1
- package/dist/assets/{DeleteDriveModal-D1nliv0t.js → DeleteDriveModal-BX2F5ijO.js} +1 -1
- package/dist/assets/DeleteItemModal-Dp0yI59L.js +1 -0
- package/dist/assets/DisclaimerModal-lDeplIo2.js +1 -0
- package/dist/assets/DriveSettingsModal-DOebf6uN.js +1 -0
- package/dist/assets/{ExportDocumentWithErrorsModal-T6DgSPPe.js → ExportDocumentWithErrorsModal-CU2IqI_V.js} +1 -1
- package/dist/assets/{SettingsModal-uUVQnlan.js → SettingsModal-C51lS85m.js} +1 -1
- package/dist/assets/UpgradeDriveModal-DcIAJzVB.js +1 -0
- package/dist/assets/{design_system-CXWL2el7.js → design_system-UWj0AhHV.js} +1 -1
- package/dist/assets/{design_system_connect-BziKm0Dg.js → design_system_connect-lcd2b25T.js} +4 -4
- package/dist/assets/{design_system_ui-Dxl4iPBf.js → design_system_ui-CErGSL3p.js} +1 -1
- package/dist/assets/{document_drive-CVkeqJ3l.js → document_drive-DZ6mXkbS.js} +1 -1
- package/dist/assets/{document_engineering-DBRB-fgc.js → document_engineering-BXuZzkFN.js} +1 -1
- package/dist/assets/{document_model-LXEZCDPq.js → document_model-D4RwF66T.js} +1 -1
- package/dist/assets/{document_model_editor-z5olAhx3.js → document_model_editor-D_BY44WX.js} +4 -4
- package/dist/assets/{drive_explorer-DWgA9K4r.js → drive_explorer-DQY98xjB.js} +2 -2
- package/dist/assets/{graphql-editor-D886web_.js → graphql-editor-DmoLtFTg.js} +1 -1
- package/dist/assets/{hooks-e_ii3Esl.js → hooks-CYkOxZbe.js} +1 -1
- package/dist/assets/index-BtQu1SOl.js +20 -0
- package/dist/assets/{json-editor-CHuyzVLs.js → json-editor-VziZWCXO.js} +1 -1
- package/dist/assets/{nodefs-B7lQTpJ4.js → nodefs-BrkZxu2e.js} +1 -1
- package/dist/assets/{opfs-ahp-CusaWQGU.js → opfs-ahp-DivB1_J8.js} +1 -1
- package/dist/assets/reactor_browser-BWiRZG4C.js +25 -0
- package/dist/assets/{state-schemas-BO2eMHcE.js → state-schemas-DTWL4CA4.js} +2 -2
- package/dist/index.html +9 -9
- package/lib/package.copy.json +1 -1
- package/lib/src/feature-flags.js +4 -4
- package/lib/src/feature-flags.js.map +1 -1
- package/lib/src/hooks/useClientErrorHandler.d.ts.map +1 -1
- package/lib/src/hooks/useClientErrorHandler.js +13 -2
- package/lib/src/hooks/useClientErrorHandler.js.map +1 -1
- package/lib/src/store/reactor.d.ts.map +1 -1
- package/lib/src/store/reactor.js +67 -28
- package/lib/src/store/reactor.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/nginx.conf +7 -0
- package/package.copy.json +1 -1
- package/package.json +10 -10
- package/dist/assets/CreateDocumentModal-BmIO-7Pc.js +0 -1
- package/dist/assets/DeleteItemModal-CbszPdS6.js +0 -1
- package/dist/assets/DisclaimerModal-BKVNrbUc.js +0 -1
- package/dist/assets/DriveSettingsModal-Doz_7CYW.js +0 -1
- package/dist/assets/UpgradeDriveModal-dK4Ihal5.js +0 -1
- package/dist/assets/index-DcOzw2lF.js +0 -20
- package/dist/assets/reactor_browser-CwsD6kpc.js +0 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a,S as Et,d as At,P as Z,c as fe,e as Ke,f as St,C as Pt,u as Be,a as Ot}from"./document_model_editor-z5olAhx3.js";import{r as l,a as X}from"./sentry_react-cODD7zWc.js";import{c as p,I as L,u as re,E as It,F as Dt,O as Ft,G as Tt,b as He,d as Vt,R as zt,a as _t,P as Ge,e as de,A as Ue,f as We,g as Lt,H as $t,J as Mt,K as qt,L as Kt,N as Bt,D as Ht,C as Gt,i as Ut}from"./design_system-CXWL2el7.js";import{R as Wt,T as Jt,P as Xt,C as Qt,a as Ee,u as Yt,b as Zt}from"./design_system_connect-BziKm0Dg.js";import{t as er}from"./tailwind_merge-Dr4f9Rms.js";import"./react-DQSxOgtG.js";import"./reactor_browser-CwsD6kpc.js";import{r as tr}from"./react-dom/client-BVPiT_FE.js";var xa=tr();const rr=At(p("inline-flex items-center justify-center gap-2","whitespace-nowrap rounded-md text-sm font-medium","transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:pointer-events-none","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"),{variants:{variant:{default:"",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground"}},defaultVariants:{variant:"default"}}),ar=l.forwardRef(({variant:e,className:t,asChild:r=!1,...s},n)=>{const o=r?Et:"button";return a.jsx(o,{className:p(rr({variant:e,className:t})),ref:n,...s})}),nr=l.forwardRef(({children:e,className:t,...r},s)=>a.jsx(Qt,{ref:s,...r,className:p("z-50 overflow-hidden rounded-md text-sm","border border-gray-200 bg-white text-gray-900 dark:border-gray-900 dark:bg-slate-900 dark:text-gray-200","px-3 py-1.5 shadow-md","data-[state=open]:animate-fade-in data-[state=open]:animate-zoom-in","data-[state=closed]:animate-fade-out data-[state=closed]:animate-zoom-out","data-[side=bottom]:animate-slide-in-from-top","data-[side=left]:animate-slide-in-from-right","data-[side=right]:animate-slide-in-from-left","data-[side=top]:animate-slide-in-from-bottom",t),children:e})),Ae=({content:e,children:t,triggerAsChild:r=!1,delayDuration:s=0,...n})=>{const{open:o,defaultOpen:d,onOpenChange:i,...f}=n;return a.jsxs(Wt,{defaultOpen:d,delayDuration:s,onOpenChange:i,open:o,children:[a.jsx(Jt,{asChild:r,type:r?void 0:"button",children:t}),a.jsx(Xt,{children:a.jsx(nr,{sideOffset:3,...f,children:e})})]})},Je=({children:e,required:t,disabled:r,description:s,hasError:n,inline:o,className:d,...i})=>{const f=p("inline-flex items-center text-sm font-medium",o?"leading-[22px]":"leading-4",`text-gray-900 ${o?"dark:text-gray-400":"dark:text-gray-50"}`,n&&"group-hover:!text-red-900 dark:group-hover:!text-red-900",n&&o&&"text-red-800 dark:text-red-800",n&&!o&&"text-red-900 dark:text-red-900",r&&`cursor-not-allowed text-gray-700 ${o?"dark:text-gray-600":"dark:text-gray-300"}`,o?!r&&"group-hover:text-gray-900 dark:group-hover:text-slate-50":"mb-[3px]",d);if(!e)return null;const c={...i};return a.jsxs("label",{className:f,...c,children:[e,t&&a.jsx("span",{className:p("ml-1 text-gray-800 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-slate-50",n&&`${o?"!text-red-800":"!text-red-900"} group-hover:!text-red-900`),children:"*"}),s&&a.jsx(Ee,{children:a.jsx(Ae,{content:s,children:a.jsx(L,{name:"CircleInfo",size:16,className:p("ml-1 cursor-pointer text-gray-600 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-500",r&&"text-gray-500")})})})]})},sr="p",_e=({children:e,type:t="info",as:r,className:s,...n})=>{const o=r||sr,i=p("mb-0 inline-flex items-center text-xs font-medium",{error:"text-red-900 dark:text-red-900",info:"text-blue-900 dark:text-blue-900",warning:"text-yellow-900 dark:text-yellow-900"}[t],s);return a.jsx(o,{"data-type":t,className:i,...n,children:e})},xe=({messages:e,type:t="info",className:r,...s})=>{if(e.length===0)return null;if(e.length===1)return a.jsx(_e,{type:t,...s,children:e[0]});const n={error:"before:bg-red-900 dark:before:bg-red-900",info:"before:bg-blue-900 dark:before:bg-blue-900",warning:"before:bg-orange-900 dark:before:bg-orange-900"};return a.jsx("ul",{className:p("flex flex-col gap-1",r),...s,children:e.map(o=>a.jsx(_e,{as:"li",type:t,className:p("relative pl-4","before:absolute before:left-0 before:top-[0.4em] before:size-2 before:rounded-full",n[t]),children:o},o))})};var Le=1,or=.9,lr=.8,ir=.17,we=.1,Ce=.999,cr=.9999,dr=.99,ur=/[\\\/_+.#"@\[\(\{&]/,fr=/[\\\/_+.#"@\[\(\{&]/g,gr=/[\s-]/,Xe=/[\s-]/g;function Se(e,t,r,s,n,o,d){if(o===t.length)return n===e.length?Le:dr;var i=`${n},${o}`;if(d[i]!==void 0)return d[i];for(var f=s.charAt(o),c=r.indexOf(f,n),g=0,x,j,v,R;c>=0;)x=Se(e,t,r,s,c+1,o+1,d),x>g&&(c===n?x*=Le:ur.test(e.charAt(c-1))?(x*=lr,v=e.slice(n,c-1).match(fr),v&&n>0&&(x*=Math.pow(Ce,v.length))):gr.test(e.charAt(c-1))?(x*=or,R=e.slice(n,c-1).match(Xe),R&&n>0&&(x*=Math.pow(Ce,R.length))):(x*=ir,n>0&&(x*=Math.pow(Ce,c-n))),e.charAt(c)!==t.charAt(o)&&(x*=cr)),(x<we&&r.charAt(c-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&r.charAt(c-1)!==s.charAt(o))&&(j=Se(e,t,r,s,c+1,o+2,d),j*we>x&&(x=j*we)),x>g&&(g=x),c=r.indexOf(f,c+1);return d[i]=g,g}function $e(e){return e.toLowerCase().replace(Xe," ")}function mr(e,t,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,Se(e,t,$e(e),$e(t),0,0,{})}var ce='[cmdk-group=""]',Ne='[cmdk-group-items=""]',pr='[cmdk-group-heading=""]',Qe='[cmdk-item=""]',Me=`${Qe}:not([aria-disabled="true"])`,Pe="cmdk-item-select",se="data-value",hr=(e,t,r)=>mr(e,t,r),Ye=l.createContext(void 0),ge=()=>l.useContext(Ye),Ze=l.createContext(void 0),Ie=()=>l.useContext(Ze),et=l.createContext(void 0),tt=l.forwardRef((e,t)=>{let r=oe(()=>{var u,y;return{search:"",value:(y=(u=e.value)!=null?u:e.defaultValue)!=null?y:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=oe(()=>new Set),n=oe(()=>new Map),o=oe(()=>new Map),d=oe(()=>new Set),i=rt(e),{label:f,children:c,value:g,onValueChange:x,filter:j,shouldFilter:v,loop:R,disablePointerSelection:O=!1,vimBindings:b=!0,...A}=e,S=re(),H=re(),q=re(),T=l.useRef(null),w=Er();ae(()=>{if(g!==void 0){let u=g.trim();r.current.value=u,E.emit()}},[g]),ae(()=>{w(6,k)},[]);let E=l.useMemo(()=>({subscribe:u=>(d.current.add(u),()=>d.current.delete(u)),snapshot:()=>r.current,setState:(u,y,h)=>{var m,C,N,D;if(!Object.is(r.current[u],y)){if(r.current[u]=y,u==="search")G(),P(),w(1,$);else if(u==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let F=document.getElementById(q);F?F.focus():(m=document.getElementById(S))==null||m.focus()}if(w(7,()=>{var F;r.current.selectedItemId=(F=I())==null?void 0:F.id,E.emit()}),h||w(5,k),((C=i.current)==null?void 0:C.value)!==void 0){let F=y??"";(D=(N=i.current).onValueChange)==null||D.call(N,F);return}}E.emit()}},emit:()=>{d.current.forEach(u=>u())}}),[]),V=l.useMemo(()=>({value:(u,y,h)=>{var m;y!==((m=o.current.get(u))==null?void 0:m.value)&&(o.current.set(u,{value:y,keywords:h}),r.current.filtered.items.set(u,z(y,h)),w(2,()=>{P(),E.emit()}))},item:(u,y)=>(s.current.add(u),y&&(n.current.has(y)?n.current.get(y).add(u):n.current.set(y,new Set([u]))),w(3,()=>{G(),P(),r.current.value||$(),E.emit()}),()=>{o.current.delete(u),s.current.delete(u),r.current.filtered.items.delete(u);let h=I();w(4,()=>{G(),h?.getAttribute("id")===u&&$(),E.emit()})}),group:u=>(n.current.has(u)||n.current.set(u,new Set),()=>{o.current.delete(u),n.current.delete(u)}),filter:()=>i.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:q,labelId:H,listInnerRef:T}),[]);function z(u,y){var h,m;let C=(m=(h=i.current)==null?void 0:h.filter)!=null?m:hr;return u?C(u,r.current.search,y):0}function P(){if(!r.current.search||i.current.shouldFilter===!1)return;let u=r.current.filtered.items,y=[];r.current.filtered.groups.forEach(m=>{let C=n.current.get(m),N=0;C.forEach(D=>{let F=u.get(D);N=Math.max(F,N)}),y.push([m,N])});let h=T.current;M().sort((m,C)=>{var N,D;let F=m.getAttribute("id"),W=C.getAttribute("id");return((N=u.get(W))!=null?N:0)-((D=u.get(F))!=null?D:0)}).forEach(m=>{let C=m.closest(Ne);C?C.appendChild(m.parentElement===C?m:m.closest(`${Ne} > *`)):h.appendChild(m.parentElement===h?m:m.closest(`${Ne} > *`))}),y.sort((m,C)=>C[1]-m[1]).forEach(m=>{var C;let N=(C=T.current)==null?void 0:C.querySelector(`${ce}[${se}="${encodeURIComponent(m[0])}"]`);N?.parentElement.appendChild(N)})}function $(){let u=M().find(h=>h.getAttribute("aria-disabled")!=="true"),y=u?.getAttribute(se);E.setState("value",y||void 0)}function G(){var u,y,h,m;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=s.current.size;return}r.current.filtered.groups=new Set;let C=0;for(let N of s.current){let D=(y=(u=o.current.get(N))==null?void 0:u.value)!=null?y:"",F=(m=(h=o.current.get(N))==null?void 0:h.keywords)!=null?m:[],W=z(D,F);r.current.filtered.items.set(N,W),W>0&&C++}for(let[N,D]of n.current)for(let F of D)if(r.current.filtered.items.get(F)>0){r.current.filtered.groups.add(N);break}r.current.filtered.count=C}function k(){var u,y,h;let m=I();m&&(((u=m.parentElement)==null?void 0:u.firstChild)===m&&((h=(y=m.closest(ce))==null?void 0:y.querySelector(pr))==null||h.scrollIntoView({block:"nearest"})),m.scrollIntoView({block:"nearest"}))}function I(){var u;return(u=T.current)==null?void 0:u.querySelector(`${Qe}[aria-selected="true"]`)}function M(){var u;return Array.from(((u=T.current)==null?void 0:u.querySelectorAll(Me))||[])}function U(u){let y=M()[u];y&&E.setState("value",y.getAttribute(se))}function Q(u){var y;let h=I(),m=M(),C=m.findIndex(D=>D===h),N=m[C+u];(y=i.current)!=null&&y.loop&&(N=C+u<0?m[m.length-1]:C+u===m.length?m[0]:m[C+u]),N&&E.setState("value",N.getAttribute(se))}function _(u){let y=I(),h=y?.closest(ce),m;for(;h&&!m;)h=u>0?Nr(h,ce):Rr(h,ce),m=h?.querySelector(Me);m?E.setState("value",m.getAttribute(se)):Q(u)}let K=()=>U(M().length-1),te=u=>{u.preventDefault(),u.metaKey?K():u.altKey?_(1):Q(1)},ne=u=>{u.preventDefault(),u.metaKey?U(0):u.altKey?_(-1):Q(-1)};return l.createElement(Z.div,{ref:t,tabIndex:-1,...A,"cmdk-root":"",onKeyDown:u=>{var y;(y=A.onKeyDown)==null||y.call(A,u);let h=u.nativeEvent.isComposing||u.keyCode===229;if(!(u.defaultPrevented||h))switch(u.key){case"n":case"j":{b&&u.ctrlKey&&te(u);break}case"ArrowDown":{te(u);break}case"p":case"k":{b&&u.ctrlKey&&ne(u);break}case"ArrowUp":{ne(u);break}case"Home":{u.preventDefault(),U(0);break}case"End":{u.preventDefault(),K();break}case"Enter":{u.preventDefault();let m=I();if(m){let C=new Event(Pe);m.dispatchEvent(C)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:V.inputId,id:V.labelId,style:Sr},f),ye(e,u=>l.createElement(Ze.Provider,{value:E},l.createElement(Ye.Provider,{value:V},u))))}),xr=l.forwardRef((e,t)=>{var r,s;let n=re(),o=l.useRef(null),d=l.useContext(et),i=ge(),f=rt(e),c=(s=(r=f.current)==null?void 0:r.forceMount)!=null?s:d?.forceMount;ae(()=>{if(!c)return i.item(n,d?.id)},[c]);let g=at(n,o,[e.value,e.children,o],e.keywords),x=Ie(),j=Y(w=>w.value&&w.value===g.current),v=Y(w=>c||i.filter()===!1?!0:w.search?w.filtered.items.get(n)>0:!0);l.useEffect(()=>{let w=o.current;if(!(!w||e.disabled))return w.addEventListener(Pe,R),()=>w.removeEventListener(Pe,R)},[v,e.onSelect,e.disabled]);function R(){var w,E;O(),(E=(w=f.current).onSelect)==null||E.call(w,g.current)}function O(){x.setState("value",g.current,!0)}if(!v)return null;let{disabled:b,value:A,onSelect:S,forceMount:H,keywords:q,...T}=e;return l.createElement(Z.div,{ref:fe(o,t),...T,id:n,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!j,"data-disabled":!!b,"data-selected":!!j,onPointerMove:b||i.getDisablePointerSelection()?void 0:O,onClick:b?void 0:R},e.children)}),vr=l.forwardRef((e,t)=>{let{heading:r,children:s,forceMount:n,...o}=e,d=re(),i=l.useRef(null),f=l.useRef(null),c=re(),g=ge(),x=Y(v=>n||g.filter()===!1?!0:v.search?v.filtered.groups.has(d):!0);ae(()=>g.group(d),[]),at(d,i,[e.value,e.heading,f]);let j=l.useMemo(()=>({id:d,forceMount:n}),[n]);return l.createElement(Z.div,{ref:fe(i,t),...o,"cmdk-group":"",role:"presentation",hidden:x?void 0:!0},r&&l.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:c},r),ye(e,v=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?c:void 0},l.createElement(et.Provider,{value:j},v))))}),br=l.forwardRef((e,t)=>{let{alwaysRender:r,...s}=e,n=l.useRef(null),o=Y(d=>!d.search);return!r&&!o?null:l.createElement(Z.div,{ref:fe(n,t),...s,"cmdk-separator":"",role:"separator"})}),yr=l.forwardRef((e,t)=>{let{onValueChange:r,...s}=e,n=e.value!=null,o=Ie(),d=Y(c=>c.search),i=Y(c=>c.selectedItemId),f=ge();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(Z.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,"aria-activedescendant":i,id:f.inputId,type:"text",value:n?e.value:d,onChange:c=>{n||o.setState("search",c.target.value),r?.(c.target.value)}})}),kr=l.forwardRef((e,t)=>{let{children:r,label:s="Suggestions",...n}=e,o=l.useRef(null),d=l.useRef(null),i=Y(c=>c.selectedItemId),f=ge();return l.useEffect(()=>{if(d.current&&o.current){let c=d.current,g=o.current,x,j=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let v=c.offsetHeight;g.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return j.observe(c),()=>{cancelAnimationFrame(x),j.unobserve(c)}}},[]),l.createElement(Z.div,{ref:fe(o,t),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":s,id:f.listId},ye(e,c=>l.createElement("div",{ref:fe(d,f.listInnerRef),"cmdk-list-sizer":""},c)))}),jr=l.forwardRef((e,t)=>{let{open:r,onOpenChange:s,overlayClassName:n,contentClassName:o,container:d,...i}=e;return l.createElement(It,{open:r,onOpenChange:s},l.createElement(Dt,{container:d},l.createElement(Ft,{"cmdk-overlay":"",className:n}),l.createElement(Tt,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(tt,{ref:t,...i}))))}),wr=l.forwardRef((e,t)=>Y(r=>r.filtered.count===0)?l.createElement(Z.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Cr=l.forwardRef((e,t)=>{let{progress:r,children:s,label:n="Loading...",...o}=e;return l.createElement(Z.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},ye(e,d=>l.createElement("div",{"aria-hidden":!0},d)))}),B=Object.assign(tt,{List:kr,Item:xr,Input:yr,Group:vr,Separator:br,Dialog:jr,Empty:wr,Loading:Cr});function Nr(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function Rr(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function rt(e){let t=l.useRef(e);return ae(()=>{t.current=e}),t}var ae=typeof window>"u"?l.useEffect:l.useLayoutEffect;function oe(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Y(e){let t=Ie(),r=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,r,r)}function at(e,t,r,s=[]){let n=l.useRef(),o=ge();return ae(()=>{var d;let i=(()=>{var c;for(let g of r){if(typeof g=="string")return g.trim();if(typeof g=="object"&&"current"in g)return g.current?(c=g.current.textContent)==null?void 0:c.trim():n.current}})(),f=s.map(c=>c.trim());o.value(e,i,f),(d=t.current)==null||d.setAttribute(se,i),n.current=i}),n}var Er=()=>{let[e,t]=l.useState(),r=oe(()=>new Map);return ae(()=>{r.current.forEach(s=>s()),r.current=new Map},[e]),(s,n)=>{r.current.set(s,n),t({})}};function Ar(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ye({asChild:e,children:t},r){return e&&l.isValidElement(t)?l.cloneElement(Ar(t),{ref:t.ref},r(t.props.children)):r(t)}var Sr={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const nt=X.forwardRef(({className:e,...t},r)=>a.jsx(B,{ref:r,className:p("flex size-full flex-col rounded-md [&_[cmdk-label]]:hidden",e),...t}));nt.displayName=B.displayName;const st=X.forwardRef(({wrapperClassName:e,className:t,...r},s)=>a.jsxs("div",{className:p("group relative flex items-center border-b","border-b-gray-300 dark:border-b-gray-900","hover:border-b-gray-300 dark:hover:border-b-gray-800","hover:bg-gray-100 dark:hover:bg-gray-900","focus-within:border-b-gray-300 dark:focus-within:border-b-gray-800","focus-within:bg-gray-100 dark:focus-within:bg-gray-900",e),"cmdk-input-wrapper":"",children:[a.jsx(L,{name:"Search",size:16,className:p("pointer-events-none absolute left-2 top-3.5 text-gray-500 dark:text-gray-700","group-hover:text-gray-700 dark:group-hover:text-gray-500","group-focus-within:!text-gray-900 dark:group-focus-within:!text-gray-50")}),a.jsx(B.Input,{ref:s,className:p("flex w-full bg-transparent pb-2 pl-8 pr-3 pt-3 text-[14px] font-normal leading-5 outline-none","placeholder:text-gray-500 dark:placeholder:text-gray-700","group-hover:placeholder:text-gray-700 dark:group-hover:placeholder:text-gray-500","group-focus-within:placeholder:!text-gray-700 dark:group-focus-within:placeholder:!text-gray-300","disabled:cursor-not-allowed",t),...r})]}));st.displayName=B.Input.displayName;const De=X.forwardRef(({className:e,...t},r)=>a.jsx(B.List,{ref:r,className:p("max-h-[300px] overflow-y-auto overflow-x-hidden","focus:outline-none","scrollbar-thin scrollbar-gutter-stable","scrollbar-track-transparent","scrollbar-thumb-gray-300 hover:scrollbar-thumb-gray-300","dark:scrollbar-thumb-charcoal-700 dark:hover:scrollbar-thumb-charcoal-700","scrollbar-thumb-rounded-md",e),...t}));De.displayName=B.List.displayName;const Pr=X.forwardRef((e,t)=>a.jsx(B.Loading,{ref:t,...e}));Pr.displayName=B.Loading.displayName;const Fe=X.forwardRef((e,t)=>a.jsx(B.Empty,{ref:t,...e}));Fe.displayName=B.Empty.displayName;const ve=X.forwardRef(({className:e,...t},r)=>a.jsx(B.Group,{ref:r,className:p("overflow-hidden px-0.5 py-1","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t}));ve.displayName=B.Group.displayName;const ke=X.forwardRef(({className:e,...t},r)=>a.jsx(B.Item,{ref:r,className:p("relative flex select-none items-center justify-between","h-8 gap-2 rounded-md py-1.5 pl-1.5 pr-2.5","text-[14px] leading-4 outline-none","border-y-2 border-white dark:border-slate-600","data-[disabled=true]:pointer-events-none","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));ke.displayName=B.Item.displayName;function ue(e,t,r=new Map){if(e===t)return!0;if(e===null||t===null||e===void 0||t===void 0||typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t))return r.get(e)===t?!0:(r.set(e,t),e.length===t.length&&e.every((s,n)=>ue(s,t[n],r)));if(typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){if(r.get(e)===t)return!0;r.set(e,t);const s=Object.keys(e),n=Object.keys(t);return s.length===n.length&&s.every(o=>o in t&&ue(e[o],t[o],r))}return!1}const be={trimOnBlur:(e=!0)=>({transformer:t=>t?.trim(),options:{trigger:"blur",if:e}}),lowercaseOnChange:(e=!0)=>({transformer:t=>t?.toLowerCase(),options:{trigger:"change",if:e}}),uppercaseOnChange:(e=!0)=>({transformer:t=>t?.toUpperCase(),options:{trigger:"change",if:e}}),trimOnEnter:(e=!0)=>({transformer:t=>t?.trim(),options:{trigger:"keyDown",if:e}})},Or=(e,t)=>l.forwardRef(({value:r,name:s,showErrorOnBlur:n,showErrorOnChange:o,validators:d,...i},f)=>{const{onChange:c,onBlur:g}=i,{control:x,formState:{errors:j,defaultValues:v},trigger:R,setValue:O,getValues:b}=Ke(),{submitCount:A}=St();if(!s)throw new Error(`[Field: ${e.displayName}] The name prop is required.`);const S=[...j[s]?.types?Object.values(j[s].types??[]):[]];S.length===0&&j[s]&&S.push("Invalid value"),l.useEffect(()=>{A>0&&R(s)},[i.required]),l.useEffect(()=>{i.errors&&i.errors.length>0&&R(s)},[s,i.errors,R]);const[H,q]=l.useState(!1);return l.useEffect(()=>{H&&O(s,r),q(!0)},[s,r]),r!==void 0&&!c&&console.warn(`[Field: ${s}] Value prop provided without onChange so it will be ignored. Use disabled/readOnly if you want to prevent changes.`),a.jsx(Pt,{control:x,name:s,defaultValue:r??i.defaultValue,disabled:i.disabled,render:({field:{onChange:T,onBlur:w,value:E,...V}})=>{const z=l.useCallback(k=>{n?R(s):w(),g&&g(k)},[w,n]),P=l.useCallback(k=>{if(c)Object.hasOwn(k,"target")?O(s,k.target.value):O(s,k),c(k);else{let I=k;(k instanceof Event||k.target instanceof HTMLElement)&&(I=k.target.value),O(s,I)}o===void 0&&n===void 0?A>0&&R(s):o&&R(s)},[E,o,n,A]),{ref:$}=V,G=k=>{typeof f=="function"?f(k):f&&(f.current=k),$(k)};return a.jsx(e,{...i,...V,value:E,onBlur:z,onChange:P,errors:S,ref:G})},rules:{...i.required?{required:{value:i.required,message:"This field is required"}}:{required:void 0},...i.pattern&&{pattern:{value:new RegExp(i.pattern),message:"This field does not match the required pattern"}},...i.maxLength!==void 0&&i.maxLength>=0?{maxLength:{value:i.maxLength,message:`This field must be at most ${i.maxLength} characters`}}:{maxLength:void 0},...i.minLength!==void 0&&i.minLength>=0?{minLength:{value:i.minLength,message:`This field must be at least ${i.minLength} characters`}}:{minLength:void 0},...i.minValue&&{min:{value:i.minValue,message:`This field must be greater than or equal to ${i.minValue}`}},...i.maxValue&&{max:{value:i.maxValue,message:`This field must be less than or equal to ${i.maxValue}`}},validate:{...i.errors?Object.fromEntries(Array.isArray(i.errors)?i.errors.map((T,w)=>[`_propError${w}`,()=>T]):[]):{},...d!==void 0?Object.fromEntries((Array.isArray(d)?d:[d]).map((T,w)=>[`customValidation${w}`,T])):{}}}})}),ot=({children:e,as:t,className:r})=>{const s=t??"p";return a.jsx(s,{className:p("font-sans text-sm font-normal leading-5 text-gray-600 dark:text-gray-500",r),children:e})},lt=({children:e})=>a.jsx("div",{className:"flex flex-col gap-2",children:e});var je="Popover",[it]=_t(je,[He]),me=He(),[Ir,ee]=it(je),ct=e=>{const{__scopePopover:t,children:r,open:s,defaultOpen:n,onOpenChange:o,modal:d=!1}=e,i=me(t),f=l.useRef(null),[c,g]=l.useState(!1),[x,j]=Vt({prop:s,defaultProp:n??!1,onChange:o,caller:je});return a.jsx(zt,{...i,children:a.jsx(Ir,{scope:t,contentId:re(),triggerRef:f,open:x,onOpenChange:j,onOpenToggle:l.useCallback(()=>j(v=>!v),[j]),hasCustomAnchor:c,onCustomAnchorAdd:l.useCallback(()=>g(!0),[]),onCustomAnchorRemove:l.useCallback(()=>g(!1),[]),modal:d,children:r})})};ct.displayName=je;var dt="PopoverAnchor",ut=l.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,n=ee(dt,r),o=me(r),{onCustomAnchorAdd:d,onCustomAnchorRemove:i}=n;return l.useEffect(()=>(d(),()=>i()),[d,i]),a.jsx(Ue,{...o,...s,ref:t})});ut.displayName=dt;var ft="PopoverTrigger",gt=l.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,n=ee(ft,r),o=me(r),d=Be(t,n.triggerRef),i=a.jsx(Ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":vt(n.open),...s,ref:d,onClick:de(e.onClick,n.onOpenToggle)});return n.hasCustomAnchor?i:a.jsx(Ue,{asChild:!0,...o,children:i})});gt.displayName=ft;var Te="PopoverPortal",[Dr,Fr]=it(Te,{forceMount:void 0}),mt=e=>{const{__scopePopover:t,forceMount:r,children:s,container:n}=e,o=ee(Te,t);return a.jsx(Dr,{scope:t,forceMount:r,children:a.jsx(We,{present:r||o.open,children:a.jsx(Lt,{asChild:!0,container:n,children:s})})})};mt.displayName=Te;var le="PopoverContent",pt=l.forwardRef((e,t)=>{const r=Fr(le,e.__scopePopover),{forceMount:s=r.forceMount,...n}=e,o=ee(le,e.__scopePopover);return a.jsx(We,{present:s||o.open,children:o.modal?a.jsx(Vr,{...n,ref:t}):a.jsx(zr,{...n,ref:t})})});pt.displayName=le;var Tr=qt("PopoverContent.RemoveScroll"),Vr=l.forwardRef((e,t)=>{const r=ee(le,e.__scopePopover),s=l.useRef(null),n=Be(t,s),o=l.useRef(!1);return l.useEffect(()=>{const d=s.current;if(d)return $t(d)},[]),a.jsx(Mt,{as:Tr,allowPinchZoom:!0,children:a.jsx(ht,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:de(e.onCloseAutoFocus,d=>{d.preventDefault(),o.current||r.triggerRef.current?.focus()}),onPointerDownOutside:de(e.onPointerDownOutside,d=>{const i=d.detail.originalEvent,f=i.button===0&&i.ctrlKey===!0,c=i.button===2||f;o.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:de(e.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1})})})}),zr=l.forwardRef((e,t)=>{const r=ee(le,e.__scopePopover),s=l.useRef(!1),n=l.useRef(!1);return a.jsx(ht,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(s.current||r.triggerRef.current?.focus(),o.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const d=o.target;r.triggerRef.current?.contains(d)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),ht=l.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:o,disableOutsidePointerEvents:d,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:c,onInteractOutside:g,...x}=e,j=ee(le,r),v=me(r);return Kt(),a.jsx(Bt,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:n,onUnmountAutoFocus:o,children:a.jsx(Ht,{asChild:!0,disableOutsidePointerEvents:d,onInteractOutside:g,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:c,onDismiss:()=>j.onOpenChange(!1),children:a.jsx(Gt,{"data-state":vt(j.open),role:"dialog",id:j.contentId,...v,...x,ref:t,style:{...x.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),xt="PopoverClose",_r=l.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,n=ee(xt,r);return a.jsx(Ge.button,{type:"button",...s,ref:t,onClick:de(e.onClick,()=>n.onOpenChange(!1))})});_r.displayName=xt;var Lr="PopoverArrow",$r=l.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,n=me(r);return a.jsx(Ut,{...n,...s,ref:t})});$r.displayName=Lr;function vt(e){return e?"open":"closed"}var Mr=ct,qr=ut,Kr=gt,Br=mt,Hr=pt;const bt=Mr,Gr=qr,Ur=Kr,yt=X.forwardRef(({align:e="center",sideOffset:t=4,className:r,...s},n)=>a.jsx(Br,{children:a.jsx(Hr,{align:e,sideOffset:t,className:p(["data-[state=closed]:animate-fade-out data-[state=open]:animate-fade-in","data-[state=closed]:animate-zoom-out data-[state=open]:animate-zoom-in","data-[side=bottom]:animate-slide-in-from-top data-[side=left]:animate-slide-in-from-right","data-[side=right]:animate-slide-in-from-left data-[side=top]:animate-slide-in-from-bottom","w-(--radix-popover-trigger-width) z-50 border p-0 outline-none","border-gray-300 bg-white dark:border-slate-500 dark:bg-slate-600","rounded-md shadow-[1px_4px_15px_0px_rgba(74,88,115,0.25)] dark:shadow-[1px_4px_15.3px_0px_#141921]"],r),ref:n,...s})})),Wr=e=>typeof e=="string"?a.jsx(L,{name:e,size:16,className:p("text-gray-700 dark:text-gray-400")}):e&&a.jsx(e,{className:p("size-4","text-gray-700 dark:text-gray-400")}),qe=({options:e=[],selectedValues:t,multiple:r,selectionIcon:s,selectionIconPosition:n,hasAnyIcon:o,toggleOption:d,tabIndex:i})=>a.jsx(a.Fragment,{children:e.map(f=>{const c=t.includes(f.value);return a.jsxs(ke,{tabIndex:i,value:f.label,onSelect:()=>!f.disabled&&d(f.value),disabled:f.disabled,className:p("cursor-pointer","data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900",f.disabled&&"!pointer-events-auto cursor-not-allowed hover:bg-transparent dark:hover:bg-transparent"),role:"option","aria-selected":c,children:[s==="auto"&&(r?a.jsx("div",{className:p("flex size-4 items-center justify-center rounded-md border","border-gray-700 dark:border-gray-400",c&&"bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"),children:c&&a.jsx(L,{name:"Checkmark",size:16})}):a.jsx("div",{className:p("relative size-4 rounded-full border",c?"border-gray-900 dark:border-gray-400":"border-gray-800 dark:border-gray-400","bg-transparent dark:bg-transparent"),children:c&&a.jsx("div",{className:"absolute left-1/2 top-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-gray-900 dark:bg-gray-400"})})),s==="checkmark"&&!(n==="right"&&o)&&a.jsx("div",{className:"size-4",children:n==="left"&&c&&a.jsx(L,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})}),Wr(f.icon),a.jsx("span",{className:p("flex-1 truncate text-[14px] font-normal leading-4","text-gray-700 dark:text-gray-500",f.disabled&&"text-gray-600 dark:text-gray-600"),children:f.label}),s==="checkmark"&&n==="right"&&a.jsx("div",{className:"size-4",children:c&&a.jsx(L,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})})]},`favorite-${f.value}`)})}),Jr=({searchable:e,commandListRef:t,multiple:r,selectedValues:s,selectionIcon:n,selectionIconPosition:o,options:d=[],toggleAll:i,toggleOption:f,favoriteOptions:c=[]})=>{const g=d.filter(v=>!v.disabled),x=d.some(v=>v.icon),j=Y(v=>v.search);return l.useEffect(()=>{t.current?.scrollTo({top:0,behavior:"instant"})},[t,j]),a.jsxs(a.Fragment,{children:[e&&a.jsx(st,{placeholder:"Search...",onKeyDown:v=>{["ArrowUp","ArrowDown","Enter"].includes(v.key)&&g.length>0||v.stopPropagation()},wrapperClassName:"rounded-t",className:"text-gray-900 dark:text-gray-50"}),a.jsxs(De,{ref:t,tabIndex:e?void 0:0,children:[a.jsx(Fe,{className:"p-4 text-center text-[14px] font-normal leading-5 text-gray-700 dark:text-gray-400",children:"No results found."}),r&&j===""&&a.jsx(ve,{className:"pb-0",children:a.jsx(ke,{value:"select-all",onSelect:i,disabled:!1,className:p("cursor-pointer","data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900"),role:"option","aria-selected":s.length===g.length,children:a.jsxs("div",{className:"flex w-full items-center gap-2",children:[n==="auto"&&a.jsx("div",{className:p("flex size-4 items-center justify-center rounded-md border","border-gray-700 dark:border-gray-400",s.length===g.length&&"bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"),children:s.length===g.length&&a.jsx(L,{name:"Checkmark",size:16})}),n==="checkmark"&&!(o==="right"&&x)&&a.jsx("div",{className:"size-4",children:o==="left"&&s.length===g.length&&a.jsx(L,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})}),a.jsx("span",{className:"text-[14px] font-semibold leading-4 text-gray-900 dark:text-gray-50",children:s.length===g.length?"Deselect All":"Select All"}),n==="checkmark"&&o==="right"&&a.jsx("div",{className:"ml-auto size-4",children:s.length===g.length&&a.jsx(L,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})})]})})}),a.jsxs(ve,{className:r&&j===""?"pt-0":void 0,children:[a.jsx(qe,{options:c,selectedValues:s,multiple:r,selectionIcon:n,selectionIconPosition:o,hasAnyIcon:x,toggleOption:f,tabIndex:e?void 0:0}),c.length>0&&a.jsx("div",{className:"my-1 border-b border-gray-300 dark:border-gray-600"}),a.jsx(qe,{options:d,selectedValues:s,multiple:r,selectionIcon:n,selectionIconPosition:o,hasAnyIcon:x,toggleOption:f,tabIndex:e?void 0:0})]})]})]})},Xr=({selectedValues:e,options:t=[],multiple:r,searchable:s,placeholder:n,handleClear:o})=>{const d=i=>typeof i=="string"?a.jsx(L,{name:i,size:16}):i&&a.jsx(i,{className:"size-4"});return e.length===0?a.jsxs("div",{className:p("mx-auto flex w-full items-center",n?"justify-between":"justify-end"),children:[n&&a.jsx("span",{className:"text-[14px] font-normal leading-5 text-gray-600 dark:text-gray-500",children:n}),s?a.jsx(L,{name:"CaretSort",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"}):a.jsx(L,{name:"ChevronDown",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})]}):a.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("div",{className:p("max-w-full truncate text-gray-900 dark:text-gray-50",!r&&"flex items-center gap-2"),children:e.map((i,f)=>{const c=t.find(g=>g.value===i);return r?a.jsx("span",{className:p("text-[14px] font-normal leading-5",f!==e.length-1&&"mr-1"),children:f!==e.length-1?`${c?.label},`:c?.label},i):a.jsxs(X.Fragment,{children:[d(c?.icon),a.jsx("span",{className:"truncate text-[14px] font-normal leading-5",children:c?.label})]},i)})}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r&&e.length>0&&a.jsx("div",{onClick:i=>{i.preventDefault(),i.stopPropagation(),o()},className:"size-4 p-0",children:a.jsx(L,{name:"XmarkLight",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})}),s?a.jsx(L,{name:"CaretSort",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"}):a.jsx(L,{name:"ChevronDown",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})]})]})};function Qr({options:e=[],multiple:t=!1,defaultValue:r,value:s,onChange:n}){const o=l.useRef(!1),d=l.useRef(null),[i,f]=l.useState(!1),[c,g]=l.useState(()=>{const b=s??r??[];return b===""?[]:Array.isArray(b)?b:[b]});l.useEffect(()=>{if(o.current){o.current=!1;return}const b=s??r??[];g(b===""?[]:Array.isArray(b)?b:[b])},[s]);const x=l.useCallback(b=>{f(b)},[]),j=l.useCallback(b=>{o.current=!0;let A;t?A=c.includes(b)?c.filter(S=>S!==b):[...c,b]:(A=c[0]===b?[]:[b],f(!1)),g(A),n?.(t?A:A[0]??"")},[t,c,e,n]),v=l.useCallback(()=>{o.current=!0,g([]),n?.(t?[]:"")},[t,n]),R=l.useCallback(()=>{o.current=!0;const b=e.filter(S=>!S.disabled).map(S=>S.value),A=c.length===b.length?[]:b;g(A),n?.(t?A:A[0])},[e,c,t,n]),O=l.useRef(t);return l.useEffect(()=>{if(O.current!==t){if(O.current=t,!t&&c.length>1){o.current=!0,g([c[0]]),n?.(c[0]);return}c.length>0&&(o.current=!0,n?.(t?[c[0]]:c[0]))}},[t]),{selectedValues:c,isPopoverOpen:i,commandListRef:d,toggleOption:j,handleClear:v,toggleAll:R,handleOpenChange:x}}const Yr=X.forwardRef(({options:e=[],favoriteOptions:t=[],defaultValue:r,value:s,onChange:n,onBlur:o,id:d,name:i,label:f,required:c,disabled:g,errors:x=[],warnings:j=[],multiple:v,selectionIcon:R="auto",selectionIconPosition:O="left",searchable:b,description:A,placeholder:S,className:H,contentClassName:q,contentAlign:T="start",...w},E)=>{const V=l.useId(),z=d??`${V}-select`,{selectedValues:P,isPopoverOpen:$,commandListRef:G,toggleOption:k,handleClear:I,toggleAll:M,handleOpenChange:U}=Qr({options:e,multiple:v,defaultValue:r,value:s,onChange:n}),Q=l.useCallback(_=>{$||o?.(_)},[o,$]);return a.jsxs(lt,{children:[f&&a.jsx(Je,{htmlFor:z,required:c,disabled:g,hasError:x.length>0,inline:!1,onClick:_=>{_.preventDefault(),_.target.control?.focus()},children:f}),a.jsxs(bt,{open:$,onOpenChange:_=>{U(_),!_&&document.activeElement?.id!==z&&o?.({target:{}})},children:[a.jsx(Ur,{asChild:!0,children:a.jsx(ar,{id:z,name:i,type:"button",role:"combobox",onBlur:Q,disabled:g,"aria-invalid":x.length>0,"aria-label":f?void 0:v?"Multi select":"Select","aria-required":c,"aria-expanded":$,className:p("flex h-9 w-full items-center justify-between px-3 py-2","dark:border-charcoal-700 dark:bg-charcoal-900 rounded-md border border-gray-300 bg-white","hover:border-gray-300 hover:bg-gray-100","dark:hover:border-charcoal-700 dark:hover:bg-charcoal-800","dark:focus:ring-charcoal-300 focus:outline-none focus:ring-1 focus:ring-gray-900 focus:ring-offset-0","dark:focus-visible:ring-charcoal-300 focus-visible:ring-1 focus-visible:ring-gray-900 focus-visible:ring-offset-0",g&&["!pointer-events-auto cursor-not-allowed bg-gray-50","dark:hover:border-charcoal-700 dark:hover:bg-charcoal-900 hover:border-gray-300 hover:bg-gray-50"],H),...w,ref:E,children:a.jsx(Xr,{selectedValues:P,options:[...t,...e],multiple:v,searchable:b,placeholder:S,handleClear:I})})}),a.jsx(yt,{align:T,onEscapeKeyDown:_=>{_.preventDefault(),U(!1)},className:q,children:a.jsx(nt,{defaultValue:!v&&P[0]?e.find(_=>_.value===P[0])?.label:void 0,children:a.jsx(Jr,{favoriteOptions:t,searchable:b,commandListRef:G,multiple:v,selectedValues:P,selectionIcon:R,selectionIconPosition:O,options:e,toggleAll:M,toggleOption:k})})})]}),A&&a.jsx(ot,{children:A}),j.length>0&&a.jsx(xe,{messages:j,type:"warning"}),x.length>0&&a.jsx(xe,{messages:x,type:"error"})]})}),Zr=Or(Yr);Zr.displayName="SelectField";function kt(...e){return er(Ot(e))}const ea=kt("flex h-9 w-full rounded-md text-sm font-normal leading-5 text-gray-900 dark:text-gray-50","dark:border-charcoal-700 dark:bg-charcoal-900 border border-gray-300 bg-white","px-3 py-2","font-sans placeholder:text-gray-500 dark:placeholder:text-gray-600","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-900 focus-visible:ring-offset-0 focus-visible:ring-offset-white","dark:focus-visible:ring-charcoal-300 dark:focus-visible:ring-offset-charcoal-900 dark:focus:bg-charcoal-900 focus:bg-gray-50","disabled:cursor-not-allowed","disabled:border-gray-300 disabled:bg-gray-50 disabled:text-gray-700","disabled:dark:border-charcoal-800 disabled:dark:bg-charcoal-900 disabled:dark:text-gray-300"),Ve=l.forwardRef(({className:e,type:t,...r},s)=>a.jsx("input",{type:t,className:kt(ea,e),ref:s,...r}));Ve.displayName="Input";function Re(e,t){const r=Object.getOwnPropertyDescriptor(e,"value")?.set,s=Object.getPrototypeOf(e),n=Object.getOwnPropertyDescriptor(s,"value")?.set;r&&r!==n?n?.call(e,t):r?.call(e,t)}function he(e,t,r="blur"){return e.reduce((s,n)=>typeof n=="function"?r==="blur"||r==="all"?n(s):s:(n.options?.trigger??"blur")!==r&&r!=="all"?s:n.options?.if===void 0||n.options.if?n.transformer(s):s,t)}function jt({transformers:e,children:t}){const s=Ke()?.setValue;return l.useEffect(()=>{const n=t.props.value,o=he(e,n,"all");ue(o,n)||(typeof s=="function"?s(t.props.name,o):t.props.onChange?.({target:{value:o}}))},[e,s]),X.cloneElement(t,{...t.props,onChange:n=>{const o=he(e,n.target.value,"change");o!==n.target.value&&s&&(s(t.props.name,o),Re(n.target,o)),t.props.onChange?.(n)},onBlur:n=>{t.props.onBlur?.(n);const o=n.target,d=he(e,o.value,"blur");if(!ue(d,o.value)){Re(o,d);const i=new Event("change",{bubbles:!0});o.dispatchEvent(i)}},onKeyDown:n=>{if(t.props.onKeyDown?.(n),n.key==="Enter"){const o=n.target,d=he(e,o.value,"keyDown");if(!ue(d,o.value)){Re(o,d);const i=new Event("change",{bubbles:!0});o.dispatchEvent(i)}}}})}const ta=X.forwardRef(({id:e,name:t,value:r,className:s,isLoading:n,haveFetchError:o,disabled:d,onChange:i,onBlur:f,onClick:c,selectedOption:g,optionsLength:x,handleOpenChange:j,onKeyDown:v,onMouseDown:R,placeholder:O,hasError:b,label:A,required:S,isPopoverOpen:H,maxLength:q,handlePaste:T,onPaste:w,...E},V)=>{const[z,P]=l.useState(!1),$=Yt("(hover: hover) and (pointer: fine)"),G=l.useMemo(()=>[be.trimOnBlur(),be.trimOnEnter()],[]);return a.jsxs("div",{className:p("group relative"),children:[a.jsx(jt,{transformers:G,children:a.jsx(B.Input,{asChild:!0,children:a.jsx(Ve,{id:e,name:t,value:r,className:p("pr-9",s),disabled:d,onChange:i,onBlur:f,onClick:k=>{const I=k.target;!(n||o)&&!g&&I.value!==""&&j?.(!0),c?.(k)},onKeyDown:k=>{v?.(k);const I=["ArrowUp","ArrowDown","Enter"].includes(k.key);if(k.key==="Enter"&&H&&x===0){j?.(!1),k.preventDefault();return}I&&H&&x>0||k.stopPropagation()},onMouseDown:k=>{const I=k.target;I.contains(document.activeElement)||requestAnimationFrame(()=>{I.select()}),R?.(k)},onPaste:k=>{T?.(k),w?.(k)},placeholder:O,"aria-invalid":b,"aria-label":A?void 0:"Id Autocomplete","aria-required":S,"aria-expanded":H,maxLength:q,...E,ref:V})})}),a.jsxs("div",{className:p("absolute right-3 top-1/2 flex size-4 -translate-y-1/2 items-center",!n&&!o&&!g&&"pointer-events-none"),children:[n&&a.jsx(L,{name:"Reload",size:16,className:p("animate-spin text-gray-500 dark:text-gray-600")}),o&&a.jsx(Ee,{children:a.jsx(Ae,{content:"Network error!",children:a.jsx(L,{name:"Error",size:16,className:p("text-red-900")})})}),g&&!n&&!o&&a.jsx(Ee,{children:a.jsx(Ae,{content:"Copied!",open:z,triggerAsChild:!0,children:a.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(g.value).then(()=>{P(!0),setTimeout(()=>P(!1),2e3)}).catch(k=>{console.error("Failed to copy value: ",k)})},className:p("focus-visible:outline-none [&_svg]:pointer-events-none",$&&"opacity-0 transition-opacity duration-500 group-hover:opacity-100"),children:a.jsx(L,{name:"Copy",size:16,className:p("text-gray-500 dark:text-gray-600")})})})})]})]})}),ra=({customIcon:e,asPlaceholder:t})=>typeof e=="string"?a.jsx(L,{name:e,size:24,className:p("shrink-0",t?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300")}):X.isValidElement(e)?a.jsx("div",{className:"size-6 shrink-0 overflow-hidden",children:e}):null,aa=({isLoadingSelectedOption:e,handleFetchSelectedOption:t,isFetchSelectedOptionSync:r,value:s})=>a.jsx("div",{children:a.jsx("button",{type:"button",disabled:e||r,onClick:()=>{!e&&!r&&t(s)},className:p("mt-0.5 focus-visible:outline-none","disabled:pointer-events-none [&_svg]:pointer-events-none"),"aria-label":e?"Loading":r?"Success":"Reload",children:a.jsx(L,{name:r?"Checkmark":"Reload",size:16,className:p("text-gray-500 dark:text-gray-600",e&&"animate-spin",r&&"animate-in fade-in duration-500")})})}),Oe=({variant:e="withValue",icon:t,title:r="Title not available",path:s="Path not available",value:n,description:o="Description not available",asPlaceholder:d,showValue:i=!0,isLoadingSelectedOption:f,handleFetchSelectedOption:c,isFetchSelectedOptionSync:g,className:x,placeholderIcon:j="PowerhouseLogoSmall",...v})=>{const R=()=>a.jsx("div",{className:p("flex w-full items-center"),children:a.jsx("span",{className:p("truncate text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:n})}),O=(b=!0)=>a.jsxs("div",{className:p("flex w-full flex-col gap-1"),children:[a.jsxs("div",{className:p("flex gap-2"),children:[a.jsx(ra,{customIcon:d?j:t,asPlaceholder:d}),a.jsxs("div",{className:p("flex min-w-0 grow flex-col gap-[-2px]"),children:[a.jsx("span",{className:p("truncate text-sm font-bold leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300"),children:r}),!i&&typeof s=="object"?a.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:p("truncate text-xs leading-5 text-blue-900 hover:underline focus-visible:outline-none"),children:s.text}):a.jsx("span",{className:p("truncate text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:typeof s=="object"?s.text:s})]}),d===!1&&c&&a.jsx(aa,{isLoadingSelectedOption:f,handleFetchSelectedOption:c,isFetchSelectedOptionSync:g,value:n})]}),i&&a.jsx("div",{className:p("flex max-w-full items-center"),children:a.jsx("span",{className:p("truncate text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:n})}),b&&a.jsx("div",{className:p("flex flex-col"),children:a.jsx("p",{className:p("line-clamp-2 text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300"),children:o})}),b&&"agentType"in v&&typeof v.agentType=="string"&&a.jsx("div",{className:p("flex max-w-full items-center justify-end"),children:a.jsx("span",{className:p("truncate text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:v.agentType})})]});return a.jsxs("div",{className:p("w-full max-w-full rounded-md bg-transparent px-3 pb-2",e==="withValue"?"pt-2":"pt-3",x),children:[e==="withValue"&&R(),e==="withValueAndTitle"&&O(!1),e==="withValueTitleAndDescription"&&O()]})},na=({variant:e,commandListRef:t,selectedValue:r,options:s=[],toggleOption:n,renderOption:o,previewPlaceholder:d})=>{const i=Y(c=>c.search),f=d||{value:"value not available",title:"Title not available",path:"Path not available",description:"Description not available"};return l.useEffect(()=>{t?.current?.scrollTo({top:0,behavior:"instant"})},[t,i]),a.jsxs(De,{ref:t,children:[a.jsx(Fe,{className:p("h-full p-1"),children:o?o(f,{asPlaceholder:!0,showValue:!0,className:p("pb-0")}):a.jsx(Oe,{variant:e,icon:f.icon,title:f.title,path:f.path,value:f.value,description:f.description,asPlaceholder:!0,className:p("pb-0")})}),a.jsx(ve,{className:p("px-1"),children:s.map(c=>{const g=r===c.value;return a.jsx(ke,{value:c.value,onSelect:()=>n?.(c.value),className:p("h-full cursor-pointer border-y-0 p-0","data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900"),role:"option","aria-selected":g,children:o?o(c,{asPlaceholder:!1,showValue:!0}):a.jsx(Oe,{variant:e,...c})},c.value)})})]})},sa=l.createContext({}),oa=()=>l.useContext(sa);function la({autoComplete:e,defaultValue:t,value:r,isOpenByDefault:s,initialOptions:n,onChange:o,onBlur:d,fetchOptions:i,fetchSelectedOption:f}){const c=oa(),g=l.useRef(!1),x=l.useRef(!1),j=l.useRef(null),[v,R]=l.useState(s??!1),[O,b]=l.useState(n??[]),[A,S]=l.useState(!1),[H,q]=l.useState(!1),[T,w]=l.useState(!1),[E,V]=l.useState(r??t??""),[z,P]=l.useState(void 0),[$,G]=l.useState(""),[k,I]=l.useState(!1),M=l.useCallback(()=>{w(!1),S(!1),q(!1),R(!1)},[]),U=Zt(l.useCallback(h=>{if(!(!e||!i)){if(h===""){M(),b([]),V(""),P(void 0);return}w(!1),S(!0);try{const m=i(h,c);Promise.resolve(m).then(C=>{b(C);const N=C.find(D=>D.value===h);N?(P(N),R(!1)):(P(void 0),R(!0)),S(!1)}).catch(()=>{w(!0),S(!1)})}catch{w(!0),S(!1)}}},[M,e,i,c])),Q=l.useCallback(h=>{if(!(!e||!f)){q(!0);try{const m=f(h),C=m instanceof Promise;Promise.resolve(m).then(N=>{N?(P(N),b(D=>{const F=D.findIndex(W=>W.value===h);if(F!==-1){const W=[...D];return W[F]=N,W}return D})):(M(),b([]),V(""),P(void 0)),q(!1),C||(I(!0),setTimeout(()=>{I(!1)},1500))}).catch(()=>{q(!1)})}catch{q(!1)}}},[M,e,f]),_=l.useCallback(h=>{h||G(O[0]?.value??""),R(h)},[O]),K=l.useCallback(h=>{g.current=!1,x.current=!0,V(h),P(O.find(m=>m.value===h)),M(),o?.(h)},[o,M,O]),te=l.useCallback(h=>{const m=h.target.value;g.current=!0,V(m),P(void 0),o?.(m)},[o]),ne=l.useCallback(h=>{G(h)},[]),u=l.useCallback(h=>{v||d?.(h)},[d,v]),y=l.useCallback(h=>{const m=h.clipboardData.getData("text"),C=m.trim();if(m!==C){h.preventDefault();const N=h.currentTarget,D=N.selectionStart||0,F=N.selectionEnd||0,W=N.value,ie=W.substring(0,D)+C+W.substring(F);o?.(ie),requestAnimationFrame(()=>{const pe=D+C.length;N.setSelectionRange(pe,pe),U(ie)})}else m===E&&U(E)},[E,U,o]);return l.useEffect(()=>{e?g.current&&U(E):(M(),b([]),V(""),P(void 0))},[e,E,U,M]),l.useEffect(()=>{x.current||(g.current=!1,V(r??t??""),P(void 0)),x.current=!1},[r]),l.useEffect(()=>{if(n?.length&&E){const h=n.find(m=>m.value===E);h&&P(h)}},[]),{selectedValue:E,selectedOption:z,isPopoverOpen:v,commandListRef:j,options:O,isLoading:A,isLoadingSelectedOption:H,haveFetchError:T,commandValue:$,isFetchSelectedOptionSync:k,toggleOption:K,handleOpenChange:_,onTriggerBlur:u,handleChange:te,handleCommandValue:ne,handleFetchSelectedOption:Q,handlePaste:y}}const ia=X.forwardRef(({id:e,name:t,className:r,label:s,description:n,value:o,defaultValue:d,disabled:i,placeholder:f,required:c,errors:g,warnings:x,onChange:j,onBlur:v,onClick:R,onKeyDown:O,onMouseDown:b,autoComplete:A=!0,variant:S="withValue",maxLength:H,fetchOptionsCallback:q,fetchSelectedOptionCallback:T,isOpenByDefault:w,initialOptions:E,renderOption:V,previewPlaceholder:z,...P},$)=>{const G=l.useId(),k=e??`${G}-id-autocomplete`,I=l.useRef(null),M=J=>{I.current=J,typeof $=="function"?$(J):$&&($.current=J)},U=Array.isArray(x)&&x.length>0,Q=Array.isArray(g)&&g.length>0,{selectedValue:_,selectedOption:K,isPopoverOpen:te,commandListRef:ne,options:u,isLoading:y,isLoadingSelectedOption:h,haveFetchError:m,commandValue:C,isFetchSelectedOptionSync:N,toggleOption:D,handleOpenChange:F,onTriggerBlur:W,handleChange:ie,handleCommandValue:pe,handleFetchSelectedOption:ze,handlePaste:wt}=la({autoComplete:A,defaultValue:d,value:o,isOpenByDefault:w,initialOptions:E,onChange:j,onBlur:v,fetchOptions:q,fetchSelectedOption:T}),Ct=J=>{D(J),I.current?.focus()},Nt=S==="withValueAndTitle"||S==="withValueTitleAndDescription",Rt=l.useMemo(()=>[be.trimOnBlur(),be.trimOnEnter()],[]);return a.jsxs(lt,{children:[!!s&&a.jsx(Je,{htmlFor:k,disabled:i,hasError:Q,required:c,onClick:J=>{J.preventDefault(),J.target.control?.focus()},children:s}),A&&q?a.jsx(bt,{open:te,onOpenChange:F,children:a.jsxs(B,{shouldFilter:!1,value:C,onValueChange:pe,className:p("dark:bg-charcoal-900 bg-gray-100"),children:[a.jsx(Gr,{asChild:!0,children:a.jsx(ta,{id:k,name:t,value:_,className:r,isLoading:y,haveFetchError:m,disabled:i,onChange:ie,onBlur:W,onClick:R,selectedOption:K,optionsLength:u.length,handleOpenChange:F,onKeyDown:O,onMouseDown:b,placeholder:f,hasError:Q,label:s,required:c,isPopoverOpen:te,maxLength:H,handlePaste:wt,...P,ref:M})}),Nt&&(V?V(K===void 0&&z?{...z}:{...K,value:K?.value??""},{asPlaceholder:K===void 0,showValue:!1,isLoadingSelectedOption:h,handleFetchSelectedOption:T?ze:void 0,isFetchSelectedOptionSync:N,className:p("rounded-t-none pt-2")}):a.jsx(Oe,{variant:S,icon:K?.icon??z?.icon,title:K?.title??z?.title,path:K?.path??z?.path,value:K?.value??z?.value??"",description:K?.description??z?.description,asPlaceholder:K===void 0,showValue:!1,isLoadingSelectedOption:h,handleFetchSelectedOption:T?ze:void 0,isFetchSelectedOptionSync:N,className:p("rounded-t-none pt-2")})),a.jsx(yt,{align:"start",onOpenAutoFocus:J=>J.preventDefault(),onInteractOutside:J=>{J.target instanceof Element&&J.target.id===k&&J.preventDefault()},children:a.jsx(na,{variant:S,commandListRef:ne,selectedValue:_,options:u,toggleOption:Ct,renderOption:V,previewPlaceholder:z})})]})}):a.jsx(jt,{transformers:Rt,children:a.jsx(Ve,{id:k,name:t,value:_,className:r,disabled:i,onChange:ie,onBlur:v,onClick:R,onMouseDown:b,placeholder:f,"aria-invalid":Q,"aria-label":s?void 0:"Id Autocomplete","aria-required":c,maxLength:H,...P,ref:M})}),!!n&&a.jsx(ot,{children:n}),U&&a.jsx(xe,{messages:x,type:"warning"}),Q&&a.jsx(xe,{messages:g,type:"error"})]})});ia.displayName="IdAutocomplete";export{Ve as I,bt as P,Yr as S,Ur as a,yt as b,ia as c,xa as d};
|
|
1
|
+
import{j as a,S as Et,d as At,P as Z,c as fe,e as Ke,f as St,C as Pt,u as Be,a as Ot}from"./document_model_editor-D_BY44WX.js";import{r as l,a as X}from"./sentry_react-cODD7zWc.js";import{c as p,I as L,u as re,E as It,F as Dt,O as Ft,G as Tt,b as He,d as Vt,R as zt,a as _t,P as Ge,e as de,A as Ue,f as We,g as Lt,H as $t,J as Mt,K as qt,L as Kt,N as Bt,D as Ht,C as Gt,i as Ut}from"./design_system-UWj0AhHV.js";import{R as Wt,T as Jt,P as Xt,C as Qt,a as Ee,u as Yt,b as Zt}from"./design_system_connect-lcd2b25T.js";import{t as er}from"./tailwind_merge-Dr4f9Rms.js";import"./react-DQSxOgtG.js";import"./reactor_browser-BWiRZG4C.js";import{r as tr}from"./react-dom/client-BVPiT_FE.js";var xa=tr();const rr=At(p("inline-flex items-center justify-center gap-2","whitespace-nowrap rounded-md text-sm font-medium","transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:pointer-events-none","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"),{variants:{variant:{default:"",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground"}},defaultVariants:{variant:"default"}}),ar=l.forwardRef(({variant:e,className:t,asChild:r=!1,...s},n)=>{const o=r?Et:"button";return a.jsx(o,{className:p(rr({variant:e,className:t})),ref:n,...s})}),nr=l.forwardRef(({children:e,className:t,...r},s)=>a.jsx(Qt,{ref:s,...r,className:p("z-50 overflow-hidden rounded-md text-sm","border border-gray-200 bg-white text-gray-900 dark:border-gray-900 dark:bg-slate-900 dark:text-gray-200","px-3 py-1.5 shadow-md","data-[state=open]:animate-fade-in data-[state=open]:animate-zoom-in","data-[state=closed]:animate-fade-out data-[state=closed]:animate-zoom-out","data-[side=bottom]:animate-slide-in-from-top","data-[side=left]:animate-slide-in-from-right","data-[side=right]:animate-slide-in-from-left","data-[side=top]:animate-slide-in-from-bottom",t),children:e})),Ae=({content:e,children:t,triggerAsChild:r=!1,delayDuration:s=0,...n})=>{const{open:o,defaultOpen:d,onOpenChange:i,...f}=n;return a.jsxs(Wt,{defaultOpen:d,delayDuration:s,onOpenChange:i,open:o,children:[a.jsx(Jt,{asChild:r,type:r?void 0:"button",children:t}),a.jsx(Xt,{children:a.jsx(nr,{sideOffset:3,...f,children:e})})]})},Je=({children:e,required:t,disabled:r,description:s,hasError:n,inline:o,className:d,...i})=>{const f=p("inline-flex items-center text-sm font-medium",o?"leading-[22px]":"leading-4",`text-gray-900 ${o?"dark:text-gray-400":"dark:text-gray-50"}`,n&&"group-hover:!text-red-900 dark:group-hover:!text-red-900",n&&o&&"text-red-800 dark:text-red-800",n&&!o&&"text-red-900 dark:text-red-900",r&&`cursor-not-allowed text-gray-700 ${o?"dark:text-gray-600":"dark:text-gray-300"}`,o?!r&&"group-hover:text-gray-900 dark:group-hover:text-slate-50":"mb-[3px]",d);if(!e)return null;const c={...i};return a.jsxs("label",{className:f,...c,children:[e,t&&a.jsx("span",{className:p("ml-1 text-gray-800 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-slate-50",n&&`${o?"!text-red-800":"!text-red-900"} group-hover:!text-red-900`),children:"*"}),s&&a.jsx(Ee,{children:a.jsx(Ae,{content:s,children:a.jsx(L,{name:"CircleInfo",size:16,className:p("ml-1 cursor-pointer text-gray-600 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-500",r&&"text-gray-500")})})})]})},sr="p",_e=({children:e,type:t="info",as:r,className:s,...n})=>{const o=r||sr,i=p("mb-0 inline-flex items-center text-xs font-medium",{error:"text-red-900 dark:text-red-900",info:"text-blue-900 dark:text-blue-900",warning:"text-yellow-900 dark:text-yellow-900"}[t],s);return a.jsx(o,{"data-type":t,className:i,...n,children:e})},xe=({messages:e,type:t="info",className:r,...s})=>{if(e.length===0)return null;if(e.length===1)return a.jsx(_e,{type:t,...s,children:e[0]});const n={error:"before:bg-red-900 dark:before:bg-red-900",info:"before:bg-blue-900 dark:before:bg-blue-900",warning:"before:bg-orange-900 dark:before:bg-orange-900"};return a.jsx("ul",{className:p("flex flex-col gap-1",r),...s,children:e.map(o=>a.jsx(_e,{as:"li",type:t,className:p("relative pl-4","before:absolute before:left-0 before:top-[0.4em] before:size-2 before:rounded-full",n[t]),children:o},o))})};var Le=1,or=.9,lr=.8,ir=.17,we=.1,Ce=.999,cr=.9999,dr=.99,ur=/[\\\/_+.#"@\[\(\{&]/,fr=/[\\\/_+.#"@\[\(\{&]/g,gr=/[\s-]/,Xe=/[\s-]/g;function Se(e,t,r,s,n,o,d){if(o===t.length)return n===e.length?Le:dr;var i=`${n},${o}`;if(d[i]!==void 0)return d[i];for(var f=s.charAt(o),c=r.indexOf(f,n),g=0,x,j,v,R;c>=0;)x=Se(e,t,r,s,c+1,o+1,d),x>g&&(c===n?x*=Le:ur.test(e.charAt(c-1))?(x*=lr,v=e.slice(n,c-1).match(fr),v&&n>0&&(x*=Math.pow(Ce,v.length))):gr.test(e.charAt(c-1))?(x*=or,R=e.slice(n,c-1).match(Xe),R&&n>0&&(x*=Math.pow(Ce,R.length))):(x*=ir,n>0&&(x*=Math.pow(Ce,c-n))),e.charAt(c)!==t.charAt(o)&&(x*=cr)),(x<we&&r.charAt(c-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&r.charAt(c-1)!==s.charAt(o))&&(j=Se(e,t,r,s,c+1,o+2,d),j*we>x&&(x=j*we)),x>g&&(g=x),c=r.indexOf(f,c+1);return d[i]=g,g}function $e(e){return e.toLowerCase().replace(Xe," ")}function mr(e,t,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,Se(e,t,$e(e),$e(t),0,0,{})}var ce='[cmdk-group=""]',Ne='[cmdk-group-items=""]',pr='[cmdk-group-heading=""]',Qe='[cmdk-item=""]',Me=`${Qe}:not([aria-disabled="true"])`,Pe="cmdk-item-select",se="data-value",hr=(e,t,r)=>mr(e,t,r),Ye=l.createContext(void 0),ge=()=>l.useContext(Ye),Ze=l.createContext(void 0),Ie=()=>l.useContext(Ze),et=l.createContext(void 0),tt=l.forwardRef((e,t)=>{let r=oe(()=>{var u,y;return{search:"",value:(y=(u=e.value)!=null?u:e.defaultValue)!=null?y:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=oe(()=>new Set),n=oe(()=>new Map),o=oe(()=>new Map),d=oe(()=>new Set),i=rt(e),{label:f,children:c,value:g,onValueChange:x,filter:j,shouldFilter:v,loop:R,disablePointerSelection:O=!1,vimBindings:b=!0,...A}=e,S=re(),H=re(),q=re(),T=l.useRef(null),w=Er();ae(()=>{if(g!==void 0){let u=g.trim();r.current.value=u,E.emit()}},[g]),ae(()=>{w(6,k)},[]);let E=l.useMemo(()=>({subscribe:u=>(d.current.add(u),()=>d.current.delete(u)),snapshot:()=>r.current,setState:(u,y,h)=>{var m,C,N,D;if(!Object.is(r.current[u],y)){if(r.current[u]=y,u==="search")G(),P(),w(1,$);else if(u==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let F=document.getElementById(q);F?F.focus():(m=document.getElementById(S))==null||m.focus()}if(w(7,()=>{var F;r.current.selectedItemId=(F=I())==null?void 0:F.id,E.emit()}),h||w(5,k),((C=i.current)==null?void 0:C.value)!==void 0){let F=y??"";(D=(N=i.current).onValueChange)==null||D.call(N,F);return}}E.emit()}},emit:()=>{d.current.forEach(u=>u())}}),[]),V=l.useMemo(()=>({value:(u,y,h)=>{var m;y!==((m=o.current.get(u))==null?void 0:m.value)&&(o.current.set(u,{value:y,keywords:h}),r.current.filtered.items.set(u,z(y,h)),w(2,()=>{P(),E.emit()}))},item:(u,y)=>(s.current.add(u),y&&(n.current.has(y)?n.current.get(y).add(u):n.current.set(y,new Set([u]))),w(3,()=>{G(),P(),r.current.value||$(),E.emit()}),()=>{o.current.delete(u),s.current.delete(u),r.current.filtered.items.delete(u);let h=I();w(4,()=>{G(),h?.getAttribute("id")===u&&$(),E.emit()})}),group:u=>(n.current.has(u)||n.current.set(u,new Set),()=>{o.current.delete(u),n.current.delete(u)}),filter:()=>i.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:q,labelId:H,listInnerRef:T}),[]);function z(u,y){var h,m;let C=(m=(h=i.current)==null?void 0:h.filter)!=null?m:hr;return u?C(u,r.current.search,y):0}function P(){if(!r.current.search||i.current.shouldFilter===!1)return;let u=r.current.filtered.items,y=[];r.current.filtered.groups.forEach(m=>{let C=n.current.get(m),N=0;C.forEach(D=>{let F=u.get(D);N=Math.max(F,N)}),y.push([m,N])});let h=T.current;M().sort((m,C)=>{var N,D;let F=m.getAttribute("id"),W=C.getAttribute("id");return((N=u.get(W))!=null?N:0)-((D=u.get(F))!=null?D:0)}).forEach(m=>{let C=m.closest(Ne);C?C.appendChild(m.parentElement===C?m:m.closest(`${Ne} > *`)):h.appendChild(m.parentElement===h?m:m.closest(`${Ne} > *`))}),y.sort((m,C)=>C[1]-m[1]).forEach(m=>{var C;let N=(C=T.current)==null?void 0:C.querySelector(`${ce}[${se}="${encodeURIComponent(m[0])}"]`);N?.parentElement.appendChild(N)})}function $(){let u=M().find(h=>h.getAttribute("aria-disabled")!=="true"),y=u?.getAttribute(se);E.setState("value",y||void 0)}function G(){var u,y,h,m;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=s.current.size;return}r.current.filtered.groups=new Set;let C=0;for(let N of s.current){let D=(y=(u=o.current.get(N))==null?void 0:u.value)!=null?y:"",F=(m=(h=o.current.get(N))==null?void 0:h.keywords)!=null?m:[],W=z(D,F);r.current.filtered.items.set(N,W),W>0&&C++}for(let[N,D]of n.current)for(let F of D)if(r.current.filtered.items.get(F)>0){r.current.filtered.groups.add(N);break}r.current.filtered.count=C}function k(){var u,y,h;let m=I();m&&(((u=m.parentElement)==null?void 0:u.firstChild)===m&&((h=(y=m.closest(ce))==null?void 0:y.querySelector(pr))==null||h.scrollIntoView({block:"nearest"})),m.scrollIntoView({block:"nearest"}))}function I(){var u;return(u=T.current)==null?void 0:u.querySelector(`${Qe}[aria-selected="true"]`)}function M(){var u;return Array.from(((u=T.current)==null?void 0:u.querySelectorAll(Me))||[])}function U(u){let y=M()[u];y&&E.setState("value",y.getAttribute(se))}function Q(u){var y;let h=I(),m=M(),C=m.findIndex(D=>D===h),N=m[C+u];(y=i.current)!=null&&y.loop&&(N=C+u<0?m[m.length-1]:C+u===m.length?m[0]:m[C+u]),N&&E.setState("value",N.getAttribute(se))}function _(u){let y=I(),h=y?.closest(ce),m;for(;h&&!m;)h=u>0?Nr(h,ce):Rr(h,ce),m=h?.querySelector(Me);m?E.setState("value",m.getAttribute(se)):Q(u)}let K=()=>U(M().length-1),te=u=>{u.preventDefault(),u.metaKey?K():u.altKey?_(1):Q(1)},ne=u=>{u.preventDefault(),u.metaKey?U(0):u.altKey?_(-1):Q(-1)};return l.createElement(Z.div,{ref:t,tabIndex:-1,...A,"cmdk-root":"",onKeyDown:u=>{var y;(y=A.onKeyDown)==null||y.call(A,u);let h=u.nativeEvent.isComposing||u.keyCode===229;if(!(u.defaultPrevented||h))switch(u.key){case"n":case"j":{b&&u.ctrlKey&&te(u);break}case"ArrowDown":{te(u);break}case"p":case"k":{b&&u.ctrlKey&&ne(u);break}case"ArrowUp":{ne(u);break}case"Home":{u.preventDefault(),U(0);break}case"End":{u.preventDefault(),K();break}case"Enter":{u.preventDefault();let m=I();if(m){let C=new Event(Pe);m.dispatchEvent(C)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:V.inputId,id:V.labelId,style:Sr},f),ye(e,u=>l.createElement(Ze.Provider,{value:E},l.createElement(Ye.Provider,{value:V},u))))}),xr=l.forwardRef((e,t)=>{var r,s;let n=re(),o=l.useRef(null),d=l.useContext(et),i=ge(),f=rt(e),c=(s=(r=f.current)==null?void 0:r.forceMount)!=null?s:d?.forceMount;ae(()=>{if(!c)return i.item(n,d?.id)},[c]);let g=at(n,o,[e.value,e.children,o],e.keywords),x=Ie(),j=Y(w=>w.value&&w.value===g.current),v=Y(w=>c||i.filter()===!1?!0:w.search?w.filtered.items.get(n)>0:!0);l.useEffect(()=>{let w=o.current;if(!(!w||e.disabled))return w.addEventListener(Pe,R),()=>w.removeEventListener(Pe,R)},[v,e.onSelect,e.disabled]);function R(){var w,E;O(),(E=(w=f.current).onSelect)==null||E.call(w,g.current)}function O(){x.setState("value",g.current,!0)}if(!v)return null;let{disabled:b,value:A,onSelect:S,forceMount:H,keywords:q,...T}=e;return l.createElement(Z.div,{ref:fe(o,t),...T,id:n,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!j,"data-disabled":!!b,"data-selected":!!j,onPointerMove:b||i.getDisablePointerSelection()?void 0:O,onClick:b?void 0:R},e.children)}),vr=l.forwardRef((e,t)=>{let{heading:r,children:s,forceMount:n,...o}=e,d=re(),i=l.useRef(null),f=l.useRef(null),c=re(),g=ge(),x=Y(v=>n||g.filter()===!1?!0:v.search?v.filtered.groups.has(d):!0);ae(()=>g.group(d),[]),at(d,i,[e.value,e.heading,f]);let j=l.useMemo(()=>({id:d,forceMount:n}),[n]);return l.createElement(Z.div,{ref:fe(i,t),...o,"cmdk-group":"",role:"presentation",hidden:x?void 0:!0},r&&l.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:c},r),ye(e,v=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?c:void 0},l.createElement(et.Provider,{value:j},v))))}),br=l.forwardRef((e,t)=>{let{alwaysRender:r,...s}=e,n=l.useRef(null),o=Y(d=>!d.search);return!r&&!o?null:l.createElement(Z.div,{ref:fe(n,t),...s,"cmdk-separator":"",role:"separator"})}),yr=l.forwardRef((e,t)=>{let{onValueChange:r,...s}=e,n=e.value!=null,o=Ie(),d=Y(c=>c.search),i=Y(c=>c.selectedItemId),f=ge();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(Z.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,"aria-activedescendant":i,id:f.inputId,type:"text",value:n?e.value:d,onChange:c=>{n||o.setState("search",c.target.value),r?.(c.target.value)}})}),kr=l.forwardRef((e,t)=>{let{children:r,label:s="Suggestions",...n}=e,o=l.useRef(null),d=l.useRef(null),i=Y(c=>c.selectedItemId),f=ge();return l.useEffect(()=>{if(d.current&&o.current){let c=d.current,g=o.current,x,j=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let v=c.offsetHeight;g.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return j.observe(c),()=>{cancelAnimationFrame(x),j.unobserve(c)}}},[]),l.createElement(Z.div,{ref:fe(o,t),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":s,id:f.listId},ye(e,c=>l.createElement("div",{ref:fe(d,f.listInnerRef),"cmdk-list-sizer":""},c)))}),jr=l.forwardRef((e,t)=>{let{open:r,onOpenChange:s,overlayClassName:n,contentClassName:o,container:d,...i}=e;return l.createElement(It,{open:r,onOpenChange:s},l.createElement(Dt,{container:d},l.createElement(Ft,{"cmdk-overlay":"",className:n}),l.createElement(Tt,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(tt,{ref:t,...i}))))}),wr=l.forwardRef((e,t)=>Y(r=>r.filtered.count===0)?l.createElement(Z.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Cr=l.forwardRef((e,t)=>{let{progress:r,children:s,label:n="Loading...",...o}=e;return l.createElement(Z.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},ye(e,d=>l.createElement("div",{"aria-hidden":!0},d)))}),B=Object.assign(tt,{List:kr,Item:xr,Input:yr,Group:vr,Separator:br,Dialog:jr,Empty:wr,Loading:Cr});function Nr(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function Rr(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function rt(e){let t=l.useRef(e);return ae(()=>{t.current=e}),t}var ae=typeof window>"u"?l.useEffect:l.useLayoutEffect;function oe(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Y(e){let t=Ie(),r=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,r,r)}function at(e,t,r,s=[]){let n=l.useRef(),o=ge();return ae(()=>{var d;let i=(()=>{var c;for(let g of r){if(typeof g=="string")return g.trim();if(typeof g=="object"&&"current"in g)return g.current?(c=g.current.textContent)==null?void 0:c.trim():n.current}})(),f=s.map(c=>c.trim());o.value(e,i,f),(d=t.current)==null||d.setAttribute(se,i),n.current=i}),n}var Er=()=>{let[e,t]=l.useState(),r=oe(()=>new Map);return ae(()=>{r.current.forEach(s=>s()),r.current=new Map},[e]),(s,n)=>{r.current.set(s,n),t({})}};function Ar(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ye({asChild:e,children:t},r){return e&&l.isValidElement(t)?l.cloneElement(Ar(t),{ref:t.ref},r(t.props.children)):r(t)}var Sr={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const nt=X.forwardRef(({className:e,...t},r)=>a.jsx(B,{ref:r,className:p("flex size-full flex-col rounded-md [&_[cmdk-label]]:hidden",e),...t}));nt.displayName=B.displayName;const st=X.forwardRef(({wrapperClassName:e,className:t,...r},s)=>a.jsxs("div",{className:p("group relative flex items-center border-b","border-b-gray-300 dark:border-b-gray-900","hover:border-b-gray-300 dark:hover:border-b-gray-800","hover:bg-gray-100 dark:hover:bg-gray-900","focus-within:border-b-gray-300 dark:focus-within:border-b-gray-800","focus-within:bg-gray-100 dark:focus-within:bg-gray-900",e),"cmdk-input-wrapper":"",children:[a.jsx(L,{name:"Search",size:16,className:p("pointer-events-none absolute left-2 top-3.5 text-gray-500 dark:text-gray-700","group-hover:text-gray-700 dark:group-hover:text-gray-500","group-focus-within:!text-gray-900 dark:group-focus-within:!text-gray-50")}),a.jsx(B.Input,{ref:s,className:p("flex w-full bg-transparent pb-2 pl-8 pr-3 pt-3 text-[14px] font-normal leading-5 outline-none","placeholder:text-gray-500 dark:placeholder:text-gray-700","group-hover:placeholder:text-gray-700 dark:group-hover:placeholder:text-gray-500","group-focus-within:placeholder:!text-gray-700 dark:group-focus-within:placeholder:!text-gray-300","disabled:cursor-not-allowed",t),...r})]}));st.displayName=B.Input.displayName;const De=X.forwardRef(({className:e,...t},r)=>a.jsx(B.List,{ref:r,className:p("max-h-[300px] overflow-y-auto overflow-x-hidden","focus:outline-none","scrollbar-thin scrollbar-gutter-stable","scrollbar-track-transparent","scrollbar-thumb-gray-300 hover:scrollbar-thumb-gray-300","dark:scrollbar-thumb-charcoal-700 dark:hover:scrollbar-thumb-charcoal-700","scrollbar-thumb-rounded-md",e),...t}));De.displayName=B.List.displayName;const Pr=X.forwardRef((e,t)=>a.jsx(B.Loading,{ref:t,...e}));Pr.displayName=B.Loading.displayName;const Fe=X.forwardRef((e,t)=>a.jsx(B.Empty,{ref:t,...e}));Fe.displayName=B.Empty.displayName;const ve=X.forwardRef(({className:e,...t},r)=>a.jsx(B.Group,{ref:r,className:p("overflow-hidden px-0.5 py-1","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t}));ve.displayName=B.Group.displayName;const ke=X.forwardRef(({className:e,...t},r)=>a.jsx(B.Item,{ref:r,className:p("relative flex select-none items-center justify-between","h-8 gap-2 rounded-md py-1.5 pl-1.5 pr-2.5","text-[14px] leading-4 outline-none","border-y-2 border-white dark:border-slate-600","data-[disabled=true]:pointer-events-none","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));ke.displayName=B.Item.displayName;function ue(e,t,r=new Map){if(e===t)return!0;if(e===null||t===null||e===void 0||t===void 0||typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t))return r.get(e)===t?!0:(r.set(e,t),e.length===t.length&&e.every((s,n)=>ue(s,t[n],r)));if(typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){if(r.get(e)===t)return!0;r.set(e,t);const s=Object.keys(e),n=Object.keys(t);return s.length===n.length&&s.every(o=>o in t&&ue(e[o],t[o],r))}return!1}const be={trimOnBlur:(e=!0)=>({transformer:t=>t?.trim(),options:{trigger:"blur",if:e}}),lowercaseOnChange:(e=!0)=>({transformer:t=>t?.toLowerCase(),options:{trigger:"change",if:e}}),uppercaseOnChange:(e=!0)=>({transformer:t=>t?.toUpperCase(),options:{trigger:"change",if:e}}),trimOnEnter:(e=!0)=>({transformer:t=>t?.trim(),options:{trigger:"keyDown",if:e}})},Or=(e,t)=>l.forwardRef(({value:r,name:s,showErrorOnBlur:n,showErrorOnChange:o,validators:d,...i},f)=>{const{onChange:c,onBlur:g}=i,{control:x,formState:{errors:j,defaultValues:v},trigger:R,setValue:O,getValues:b}=Ke(),{submitCount:A}=St();if(!s)throw new Error(`[Field: ${e.displayName}] The name prop is required.`);const S=[...j[s]?.types?Object.values(j[s].types??[]):[]];S.length===0&&j[s]&&S.push("Invalid value"),l.useEffect(()=>{A>0&&R(s)},[i.required]),l.useEffect(()=>{i.errors&&i.errors.length>0&&R(s)},[s,i.errors,R]);const[H,q]=l.useState(!1);return l.useEffect(()=>{H&&O(s,r),q(!0)},[s,r]),r!==void 0&&!c&&console.warn(`[Field: ${s}] Value prop provided without onChange so it will be ignored. Use disabled/readOnly if you want to prevent changes.`),a.jsx(Pt,{control:x,name:s,defaultValue:r??i.defaultValue,disabled:i.disabled,render:({field:{onChange:T,onBlur:w,value:E,...V}})=>{const z=l.useCallback(k=>{n?R(s):w(),g&&g(k)},[w,n]),P=l.useCallback(k=>{if(c)Object.hasOwn(k,"target")?O(s,k.target.value):O(s,k),c(k);else{let I=k;(k instanceof Event||k.target instanceof HTMLElement)&&(I=k.target.value),O(s,I)}o===void 0&&n===void 0?A>0&&R(s):o&&R(s)},[E,o,n,A]),{ref:$}=V,G=k=>{typeof f=="function"?f(k):f&&(f.current=k),$(k)};return a.jsx(e,{...i,...V,value:E,onBlur:z,onChange:P,errors:S,ref:G})},rules:{...i.required?{required:{value:i.required,message:"This field is required"}}:{required:void 0},...i.pattern&&{pattern:{value:new RegExp(i.pattern),message:"This field does not match the required pattern"}},...i.maxLength!==void 0&&i.maxLength>=0?{maxLength:{value:i.maxLength,message:`This field must be at most ${i.maxLength} characters`}}:{maxLength:void 0},...i.minLength!==void 0&&i.minLength>=0?{minLength:{value:i.minLength,message:`This field must be at least ${i.minLength} characters`}}:{minLength:void 0},...i.minValue&&{min:{value:i.minValue,message:`This field must be greater than or equal to ${i.minValue}`}},...i.maxValue&&{max:{value:i.maxValue,message:`This field must be less than or equal to ${i.maxValue}`}},validate:{...i.errors?Object.fromEntries(Array.isArray(i.errors)?i.errors.map((T,w)=>[`_propError${w}`,()=>T]):[]):{},...d!==void 0?Object.fromEntries((Array.isArray(d)?d:[d]).map((T,w)=>[`customValidation${w}`,T])):{}}}})}),ot=({children:e,as:t,className:r})=>{const s=t??"p";return a.jsx(s,{className:p("font-sans text-sm font-normal leading-5 text-gray-600 dark:text-gray-500",r),children:e})},lt=({children:e})=>a.jsx("div",{className:"flex flex-col gap-2",children:e});var je="Popover",[it]=_t(je,[He]),me=He(),[Ir,ee]=it(je),ct=e=>{const{__scopePopover:t,children:r,open:s,defaultOpen:n,onOpenChange:o,modal:d=!1}=e,i=me(t),f=l.useRef(null),[c,g]=l.useState(!1),[x,j]=Vt({prop:s,defaultProp:n??!1,onChange:o,caller:je});return a.jsx(zt,{...i,children:a.jsx(Ir,{scope:t,contentId:re(),triggerRef:f,open:x,onOpenChange:j,onOpenToggle:l.useCallback(()=>j(v=>!v),[j]),hasCustomAnchor:c,onCustomAnchorAdd:l.useCallback(()=>g(!0),[]),onCustomAnchorRemove:l.useCallback(()=>g(!1),[]),modal:d,children:r})})};ct.displayName=je;var dt="PopoverAnchor",ut=l.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,n=ee(dt,r),o=me(r),{onCustomAnchorAdd:d,onCustomAnchorRemove:i}=n;return l.useEffect(()=>(d(),()=>i()),[d,i]),a.jsx(Ue,{...o,...s,ref:t})});ut.displayName=dt;var ft="PopoverTrigger",gt=l.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,n=ee(ft,r),o=me(r),d=Be(t,n.triggerRef),i=a.jsx(Ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":vt(n.open),...s,ref:d,onClick:de(e.onClick,n.onOpenToggle)});return n.hasCustomAnchor?i:a.jsx(Ue,{asChild:!0,...o,children:i})});gt.displayName=ft;var Te="PopoverPortal",[Dr,Fr]=it(Te,{forceMount:void 0}),mt=e=>{const{__scopePopover:t,forceMount:r,children:s,container:n}=e,o=ee(Te,t);return a.jsx(Dr,{scope:t,forceMount:r,children:a.jsx(We,{present:r||o.open,children:a.jsx(Lt,{asChild:!0,container:n,children:s})})})};mt.displayName=Te;var le="PopoverContent",pt=l.forwardRef((e,t)=>{const r=Fr(le,e.__scopePopover),{forceMount:s=r.forceMount,...n}=e,o=ee(le,e.__scopePopover);return a.jsx(We,{present:s||o.open,children:o.modal?a.jsx(Vr,{...n,ref:t}):a.jsx(zr,{...n,ref:t})})});pt.displayName=le;var Tr=qt("PopoverContent.RemoveScroll"),Vr=l.forwardRef((e,t)=>{const r=ee(le,e.__scopePopover),s=l.useRef(null),n=Be(t,s),o=l.useRef(!1);return l.useEffect(()=>{const d=s.current;if(d)return $t(d)},[]),a.jsx(Mt,{as:Tr,allowPinchZoom:!0,children:a.jsx(ht,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:de(e.onCloseAutoFocus,d=>{d.preventDefault(),o.current||r.triggerRef.current?.focus()}),onPointerDownOutside:de(e.onPointerDownOutside,d=>{const i=d.detail.originalEvent,f=i.button===0&&i.ctrlKey===!0,c=i.button===2||f;o.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:de(e.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1})})})}),zr=l.forwardRef((e,t)=>{const r=ee(le,e.__scopePopover),s=l.useRef(!1),n=l.useRef(!1);return a.jsx(ht,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(s.current||r.triggerRef.current?.focus(),o.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const d=o.target;r.triggerRef.current?.contains(d)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),ht=l.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:o,disableOutsidePointerEvents:d,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:c,onInteractOutside:g,...x}=e,j=ee(le,r),v=me(r);return Kt(),a.jsx(Bt,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:n,onUnmountAutoFocus:o,children:a.jsx(Ht,{asChild:!0,disableOutsidePointerEvents:d,onInteractOutside:g,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:c,onDismiss:()=>j.onOpenChange(!1),children:a.jsx(Gt,{"data-state":vt(j.open),role:"dialog",id:j.contentId,...v,...x,ref:t,style:{...x.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),xt="PopoverClose",_r=l.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,n=ee(xt,r);return a.jsx(Ge.button,{type:"button",...s,ref:t,onClick:de(e.onClick,()=>n.onOpenChange(!1))})});_r.displayName=xt;var Lr="PopoverArrow",$r=l.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,n=me(r);return a.jsx(Ut,{...n,...s,ref:t})});$r.displayName=Lr;function vt(e){return e?"open":"closed"}var Mr=ct,qr=ut,Kr=gt,Br=mt,Hr=pt;const bt=Mr,Gr=qr,Ur=Kr,yt=X.forwardRef(({align:e="center",sideOffset:t=4,className:r,...s},n)=>a.jsx(Br,{children:a.jsx(Hr,{align:e,sideOffset:t,className:p(["data-[state=closed]:animate-fade-out data-[state=open]:animate-fade-in","data-[state=closed]:animate-zoom-out data-[state=open]:animate-zoom-in","data-[side=bottom]:animate-slide-in-from-top data-[side=left]:animate-slide-in-from-right","data-[side=right]:animate-slide-in-from-left data-[side=top]:animate-slide-in-from-bottom","w-(--radix-popover-trigger-width) z-50 border p-0 outline-none","border-gray-300 bg-white dark:border-slate-500 dark:bg-slate-600","rounded-md shadow-[1px_4px_15px_0px_rgba(74,88,115,0.25)] dark:shadow-[1px_4px_15.3px_0px_#141921]"],r),ref:n,...s})})),Wr=e=>typeof e=="string"?a.jsx(L,{name:e,size:16,className:p("text-gray-700 dark:text-gray-400")}):e&&a.jsx(e,{className:p("size-4","text-gray-700 dark:text-gray-400")}),qe=({options:e=[],selectedValues:t,multiple:r,selectionIcon:s,selectionIconPosition:n,hasAnyIcon:o,toggleOption:d,tabIndex:i})=>a.jsx(a.Fragment,{children:e.map(f=>{const c=t.includes(f.value);return a.jsxs(ke,{tabIndex:i,value:f.label,onSelect:()=>!f.disabled&&d(f.value),disabled:f.disabled,className:p("cursor-pointer","data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900",f.disabled&&"!pointer-events-auto cursor-not-allowed hover:bg-transparent dark:hover:bg-transparent"),role:"option","aria-selected":c,children:[s==="auto"&&(r?a.jsx("div",{className:p("flex size-4 items-center justify-center rounded-md border","border-gray-700 dark:border-gray-400",c&&"bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"),children:c&&a.jsx(L,{name:"Checkmark",size:16})}):a.jsx("div",{className:p("relative size-4 rounded-full border",c?"border-gray-900 dark:border-gray-400":"border-gray-800 dark:border-gray-400","bg-transparent dark:bg-transparent"),children:c&&a.jsx("div",{className:"absolute left-1/2 top-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-gray-900 dark:bg-gray-400"})})),s==="checkmark"&&!(n==="right"&&o)&&a.jsx("div",{className:"size-4",children:n==="left"&&c&&a.jsx(L,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})}),Wr(f.icon),a.jsx("span",{className:p("flex-1 truncate text-[14px] font-normal leading-4","text-gray-700 dark:text-gray-500",f.disabled&&"text-gray-600 dark:text-gray-600"),children:f.label}),s==="checkmark"&&n==="right"&&a.jsx("div",{className:"size-4",children:c&&a.jsx(L,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})})]},`favorite-${f.value}`)})}),Jr=({searchable:e,commandListRef:t,multiple:r,selectedValues:s,selectionIcon:n,selectionIconPosition:o,options:d=[],toggleAll:i,toggleOption:f,favoriteOptions:c=[]})=>{const g=d.filter(v=>!v.disabled),x=d.some(v=>v.icon),j=Y(v=>v.search);return l.useEffect(()=>{t.current?.scrollTo({top:0,behavior:"instant"})},[t,j]),a.jsxs(a.Fragment,{children:[e&&a.jsx(st,{placeholder:"Search...",onKeyDown:v=>{["ArrowUp","ArrowDown","Enter"].includes(v.key)&&g.length>0||v.stopPropagation()},wrapperClassName:"rounded-t",className:"text-gray-900 dark:text-gray-50"}),a.jsxs(De,{ref:t,tabIndex:e?void 0:0,children:[a.jsx(Fe,{className:"p-4 text-center text-[14px] font-normal leading-5 text-gray-700 dark:text-gray-400",children:"No results found."}),r&&j===""&&a.jsx(ve,{className:"pb-0",children:a.jsx(ke,{value:"select-all",onSelect:i,disabled:!1,className:p("cursor-pointer","data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900"),role:"option","aria-selected":s.length===g.length,children:a.jsxs("div",{className:"flex w-full items-center gap-2",children:[n==="auto"&&a.jsx("div",{className:p("flex size-4 items-center justify-center rounded-md border","border-gray-700 dark:border-gray-400",s.length===g.length&&"bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"),children:s.length===g.length&&a.jsx(L,{name:"Checkmark",size:16})}),n==="checkmark"&&!(o==="right"&&x)&&a.jsx("div",{className:"size-4",children:o==="left"&&s.length===g.length&&a.jsx(L,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})}),a.jsx("span",{className:"text-[14px] font-semibold leading-4 text-gray-900 dark:text-gray-50",children:s.length===g.length?"Deselect All":"Select All"}),n==="checkmark"&&o==="right"&&a.jsx("div",{className:"ml-auto size-4",children:s.length===g.length&&a.jsx(L,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})})]})})}),a.jsxs(ve,{className:r&&j===""?"pt-0":void 0,children:[a.jsx(qe,{options:c,selectedValues:s,multiple:r,selectionIcon:n,selectionIconPosition:o,hasAnyIcon:x,toggleOption:f,tabIndex:e?void 0:0}),c.length>0&&a.jsx("div",{className:"my-1 border-b border-gray-300 dark:border-gray-600"}),a.jsx(qe,{options:d,selectedValues:s,multiple:r,selectionIcon:n,selectionIconPosition:o,hasAnyIcon:x,toggleOption:f,tabIndex:e?void 0:0})]})]})]})},Xr=({selectedValues:e,options:t=[],multiple:r,searchable:s,placeholder:n,handleClear:o})=>{const d=i=>typeof i=="string"?a.jsx(L,{name:i,size:16}):i&&a.jsx(i,{className:"size-4"});return e.length===0?a.jsxs("div",{className:p("mx-auto flex w-full items-center",n?"justify-between":"justify-end"),children:[n&&a.jsx("span",{className:"text-[14px] font-normal leading-5 text-gray-600 dark:text-gray-500",children:n}),s?a.jsx(L,{name:"CaretSort",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"}):a.jsx(L,{name:"ChevronDown",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})]}):a.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("div",{className:p("max-w-full truncate text-gray-900 dark:text-gray-50",!r&&"flex items-center gap-2"),children:e.map((i,f)=>{const c=t.find(g=>g.value===i);return r?a.jsx("span",{className:p("text-[14px] font-normal leading-5",f!==e.length-1&&"mr-1"),children:f!==e.length-1?`${c?.label},`:c?.label},i):a.jsxs(X.Fragment,{children:[d(c?.icon),a.jsx("span",{className:"truncate text-[14px] font-normal leading-5",children:c?.label})]},i)})}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r&&e.length>0&&a.jsx("div",{onClick:i=>{i.preventDefault(),i.stopPropagation(),o()},className:"size-4 p-0",children:a.jsx(L,{name:"XmarkLight",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})}),s?a.jsx(L,{name:"CaretSort",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"}):a.jsx(L,{name:"ChevronDown",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})]})]})};function Qr({options:e=[],multiple:t=!1,defaultValue:r,value:s,onChange:n}){const o=l.useRef(!1),d=l.useRef(null),[i,f]=l.useState(!1),[c,g]=l.useState(()=>{const b=s??r??[];return b===""?[]:Array.isArray(b)?b:[b]});l.useEffect(()=>{if(o.current){o.current=!1;return}const b=s??r??[];g(b===""?[]:Array.isArray(b)?b:[b])},[s]);const x=l.useCallback(b=>{f(b)},[]),j=l.useCallback(b=>{o.current=!0;let A;t?A=c.includes(b)?c.filter(S=>S!==b):[...c,b]:(A=c[0]===b?[]:[b],f(!1)),g(A),n?.(t?A:A[0]??"")},[t,c,e,n]),v=l.useCallback(()=>{o.current=!0,g([]),n?.(t?[]:"")},[t,n]),R=l.useCallback(()=>{o.current=!0;const b=e.filter(S=>!S.disabled).map(S=>S.value),A=c.length===b.length?[]:b;g(A),n?.(t?A:A[0])},[e,c,t,n]),O=l.useRef(t);return l.useEffect(()=>{if(O.current!==t){if(O.current=t,!t&&c.length>1){o.current=!0,g([c[0]]),n?.(c[0]);return}c.length>0&&(o.current=!0,n?.(t?[c[0]]:c[0]))}},[t]),{selectedValues:c,isPopoverOpen:i,commandListRef:d,toggleOption:j,handleClear:v,toggleAll:R,handleOpenChange:x}}const Yr=X.forwardRef(({options:e=[],favoriteOptions:t=[],defaultValue:r,value:s,onChange:n,onBlur:o,id:d,name:i,label:f,required:c,disabled:g,errors:x=[],warnings:j=[],multiple:v,selectionIcon:R="auto",selectionIconPosition:O="left",searchable:b,description:A,placeholder:S,className:H,contentClassName:q,contentAlign:T="start",...w},E)=>{const V=l.useId(),z=d??`${V}-select`,{selectedValues:P,isPopoverOpen:$,commandListRef:G,toggleOption:k,handleClear:I,toggleAll:M,handleOpenChange:U}=Qr({options:e,multiple:v,defaultValue:r,value:s,onChange:n}),Q=l.useCallback(_=>{$||o?.(_)},[o,$]);return a.jsxs(lt,{children:[f&&a.jsx(Je,{htmlFor:z,required:c,disabled:g,hasError:x.length>0,inline:!1,onClick:_=>{_.preventDefault(),_.target.control?.focus()},children:f}),a.jsxs(bt,{open:$,onOpenChange:_=>{U(_),!_&&document.activeElement?.id!==z&&o?.({target:{}})},children:[a.jsx(Ur,{asChild:!0,children:a.jsx(ar,{id:z,name:i,type:"button",role:"combobox",onBlur:Q,disabled:g,"aria-invalid":x.length>0,"aria-label":f?void 0:v?"Multi select":"Select","aria-required":c,"aria-expanded":$,className:p("flex h-9 w-full items-center justify-between px-3 py-2","dark:border-charcoal-700 dark:bg-charcoal-900 rounded-md border border-gray-300 bg-white","hover:border-gray-300 hover:bg-gray-100","dark:hover:border-charcoal-700 dark:hover:bg-charcoal-800","dark:focus:ring-charcoal-300 focus:outline-none focus:ring-1 focus:ring-gray-900 focus:ring-offset-0","dark:focus-visible:ring-charcoal-300 focus-visible:ring-1 focus-visible:ring-gray-900 focus-visible:ring-offset-0",g&&["!pointer-events-auto cursor-not-allowed bg-gray-50","dark:hover:border-charcoal-700 dark:hover:bg-charcoal-900 hover:border-gray-300 hover:bg-gray-50"],H),...w,ref:E,children:a.jsx(Xr,{selectedValues:P,options:[...t,...e],multiple:v,searchable:b,placeholder:S,handleClear:I})})}),a.jsx(yt,{align:T,onEscapeKeyDown:_=>{_.preventDefault(),U(!1)},className:q,children:a.jsx(nt,{defaultValue:!v&&P[0]?e.find(_=>_.value===P[0])?.label:void 0,children:a.jsx(Jr,{favoriteOptions:t,searchable:b,commandListRef:G,multiple:v,selectedValues:P,selectionIcon:R,selectionIconPosition:O,options:e,toggleAll:M,toggleOption:k})})})]}),A&&a.jsx(ot,{children:A}),j.length>0&&a.jsx(xe,{messages:j,type:"warning"}),x.length>0&&a.jsx(xe,{messages:x,type:"error"})]})}),Zr=Or(Yr);Zr.displayName="SelectField";function kt(...e){return er(Ot(e))}const ea=kt("flex h-9 w-full rounded-md text-sm font-normal leading-5 text-gray-900 dark:text-gray-50","dark:border-charcoal-700 dark:bg-charcoal-900 border border-gray-300 bg-white","px-3 py-2","font-sans placeholder:text-gray-500 dark:placeholder:text-gray-600","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-900 focus-visible:ring-offset-0 focus-visible:ring-offset-white","dark:focus-visible:ring-charcoal-300 dark:focus-visible:ring-offset-charcoal-900 dark:focus:bg-charcoal-900 focus:bg-gray-50","disabled:cursor-not-allowed","disabled:border-gray-300 disabled:bg-gray-50 disabled:text-gray-700","disabled:dark:border-charcoal-800 disabled:dark:bg-charcoal-900 disabled:dark:text-gray-300"),Ve=l.forwardRef(({className:e,type:t,...r},s)=>a.jsx("input",{type:t,className:kt(ea,e),ref:s,...r}));Ve.displayName="Input";function Re(e,t){const r=Object.getOwnPropertyDescriptor(e,"value")?.set,s=Object.getPrototypeOf(e),n=Object.getOwnPropertyDescriptor(s,"value")?.set;r&&r!==n?n?.call(e,t):r?.call(e,t)}function he(e,t,r="blur"){return e.reduce((s,n)=>typeof n=="function"?r==="blur"||r==="all"?n(s):s:(n.options?.trigger??"blur")!==r&&r!=="all"?s:n.options?.if===void 0||n.options.if?n.transformer(s):s,t)}function jt({transformers:e,children:t}){const s=Ke()?.setValue;return l.useEffect(()=>{const n=t.props.value,o=he(e,n,"all");ue(o,n)||(typeof s=="function"?s(t.props.name,o):t.props.onChange?.({target:{value:o}}))},[e,s]),X.cloneElement(t,{...t.props,onChange:n=>{const o=he(e,n.target.value,"change");o!==n.target.value&&s&&(s(t.props.name,o),Re(n.target,o)),t.props.onChange?.(n)},onBlur:n=>{t.props.onBlur?.(n);const o=n.target,d=he(e,o.value,"blur");if(!ue(d,o.value)){Re(o,d);const i=new Event("change",{bubbles:!0});o.dispatchEvent(i)}},onKeyDown:n=>{if(t.props.onKeyDown?.(n),n.key==="Enter"){const o=n.target,d=he(e,o.value,"keyDown");if(!ue(d,o.value)){Re(o,d);const i=new Event("change",{bubbles:!0});o.dispatchEvent(i)}}}})}const ta=X.forwardRef(({id:e,name:t,value:r,className:s,isLoading:n,haveFetchError:o,disabled:d,onChange:i,onBlur:f,onClick:c,selectedOption:g,optionsLength:x,handleOpenChange:j,onKeyDown:v,onMouseDown:R,placeholder:O,hasError:b,label:A,required:S,isPopoverOpen:H,maxLength:q,handlePaste:T,onPaste:w,...E},V)=>{const[z,P]=l.useState(!1),$=Yt("(hover: hover) and (pointer: fine)"),G=l.useMemo(()=>[be.trimOnBlur(),be.trimOnEnter()],[]);return a.jsxs("div",{className:p("group relative"),children:[a.jsx(jt,{transformers:G,children:a.jsx(B.Input,{asChild:!0,children:a.jsx(Ve,{id:e,name:t,value:r,className:p("pr-9",s),disabled:d,onChange:i,onBlur:f,onClick:k=>{const I=k.target;!(n||o)&&!g&&I.value!==""&&j?.(!0),c?.(k)},onKeyDown:k=>{v?.(k);const I=["ArrowUp","ArrowDown","Enter"].includes(k.key);if(k.key==="Enter"&&H&&x===0){j?.(!1),k.preventDefault();return}I&&H&&x>0||k.stopPropagation()},onMouseDown:k=>{const I=k.target;I.contains(document.activeElement)||requestAnimationFrame(()=>{I.select()}),R?.(k)},onPaste:k=>{T?.(k),w?.(k)},placeholder:O,"aria-invalid":b,"aria-label":A?void 0:"Id Autocomplete","aria-required":S,"aria-expanded":H,maxLength:q,...E,ref:V})})}),a.jsxs("div",{className:p("absolute right-3 top-1/2 flex size-4 -translate-y-1/2 items-center",!n&&!o&&!g&&"pointer-events-none"),children:[n&&a.jsx(L,{name:"Reload",size:16,className:p("animate-spin text-gray-500 dark:text-gray-600")}),o&&a.jsx(Ee,{children:a.jsx(Ae,{content:"Network error!",children:a.jsx(L,{name:"Error",size:16,className:p("text-red-900")})})}),g&&!n&&!o&&a.jsx(Ee,{children:a.jsx(Ae,{content:"Copied!",open:z,triggerAsChild:!0,children:a.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(g.value).then(()=>{P(!0),setTimeout(()=>P(!1),2e3)}).catch(k=>{console.error("Failed to copy value: ",k)})},className:p("focus-visible:outline-none [&_svg]:pointer-events-none",$&&"opacity-0 transition-opacity duration-500 group-hover:opacity-100"),children:a.jsx(L,{name:"Copy",size:16,className:p("text-gray-500 dark:text-gray-600")})})})})]})]})}),ra=({customIcon:e,asPlaceholder:t})=>typeof e=="string"?a.jsx(L,{name:e,size:24,className:p("shrink-0",t?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300")}):X.isValidElement(e)?a.jsx("div",{className:"size-6 shrink-0 overflow-hidden",children:e}):null,aa=({isLoadingSelectedOption:e,handleFetchSelectedOption:t,isFetchSelectedOptionSync:r,value:s})=>a.jsx("div",{children:a.jsx("button",{type:"button",disabled:e||r,onClick:()=>{!e&&!r&&t(s)},className:p("mt-0.5 focus-visible:outline-none","disabled:pointer-events-none [&_svg]:pointer-events-none"),"aria-label":e?"Loading":r?"Success":"Reload",children:a.jsx(L,{name:r?"Checkmark":"Reload",size:16,className:p("text-gray-500 dark:text-gray-600",e&&"animate-spin",r&&"animate-in fade-in duration-500")})})}),Oe=({variant:e="withValue",icon:t,title:r="Title not available",path:s="Path not available",value:n,description:o="Description not available",asPlaceholder:d,showValue:i=!0,isLoadingSelectedOption:f,handleFetchSelectedOption:c,isFetchSelectedOptionSync:g,className:x,placeholderIcon:j="PowerhouseLogoSmall",...v})=>{const R=()=>a.jsx("div",{className:p("flex w-full items-center"),children:a.jsx("span",{className:p("truncate text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:n})}),O=(b=!0)=>a.jsxs("div",{className:p("flex w-full flex-col gap-1"),children:[a.jsxs("div",{className:p("flex gap-2"),children:[a.jsx(ra,{customIcon:d?j:t,asPlaceholder:d}),a.jsxs("div",{className:p("flex min-w-0 grow flex-col gap-[-2px]"),children:[a.jsx("span",{className:p("truncate text-sm font-bold leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300"),children:r}),!i&&typeof s=="object"?a.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:p("truncate text-xs leading-5 text-blue-900 hover:underline focus-visible:outline-none"),children:s.text}):a.jsx("span",{className:p("truncate text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:typeof s=="object"?s.text:s})]}),d===!1&&c&&a.jsx(aa,{isLoadingSelectedOption:f,handleFetchSelectedOption:c,isFetchSelectedOptionSync:g,value:n})]}),i&&a.jsx("div",{className:p("flex max-w-full items-center"),children:a.jsx("span",{className:p("truncate text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:n})}),b&&a.jsx("div",{className:p("flex flex-col"),children:a.jsx("p",{className:p("line-clamp-2 text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300"),children:o})}),b&&"agentType"in v&&typeof v.agentType=="string"&&a.jsx("div",{className:p("flex max-w-full items-center justify-end"),children:a.jsx("span",{className:p("truncate text-xs leading-5",d?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:v.agentType})})]});return a.jsxs("div",{className:p("w-full max-w-full rounded-md bg-transparent px-3 pb-2",e==="withValue"?"pt-2":"pt-3",x),children:[e==="withValue"&&R(),e==="withValueAndTitle"&&O(!1),e==="withValueTitleAndDescription"&&O()]})},na=({variant:e,commandListRef:t,selectedValue:r,options:s=[],toggleOption:n,renderOption:o,previewPlaceholder:d})=>{const i=Y(c=>c.search),f=d||{value:"value not available",title:"Title not available",path:"Path not available",description:"Description not available"};return l.useEffect(()=>{t?.current?.scrollTo({top:0,behavior:"instant"})},[t,i]),a.jsxs(De,{ref:t,children:[a.jsx(Fe,{className:p("h-full p-1"),children:o?o(f,{asPlaceholder:!0,showValue:!0,className:p("pb-0")}):a.jsx(Oe,{variant:e,icon:f.icon,title:f.title,path:f.path,value:f.value,description:f.description,asPlaceholder:!0,className:p("pb-0")})}),a.jsx(ve,{className:p("px-1"),children:s.map(c=>{const g=r===c.value;return a.jsx(ke,{value:c.value,onSelect:()=>n?.(c.value),className:p("h-full cursor-pointer border-y-0 p-0","data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900"),role:"option","aria-selected":g,children:o?o(c,{asPlaceholder:!1,showValue:!0}):a.jsx(Oe,{variant:e,...c})},c.value)})})]})},sa=l.createContext({}),oa=()=>l.useContext(sa);function la({autoComplete:e,defaultValue:t,value:r,isOpenByDefault:s,initialOptions:n,onChange:o,onBlur:d,fetchOptions:i,fetchSelectedOption:f}){const c=oa(),g=l.useRef(!1),x=l.useRef(!1),j=l.useRef(null),[v,R]=l.useState(s??!1),[O,b]=l.useState(n??[]),[A,S]=l.useState(!1),[H,q]=l.useState(!1),[T,w]=l.useState(!1),[E,V]=l.useState(r??t??""),[z,P]=l.useState(void 0),[$,G]=l.useState(""),[k,I]=l.useState(!1),M=l.useCallback(()=>{w(!1),S(!1),q(!1),R(!1)},[]),U=Zt(l.useCallback(h=>{if(!(!e||!i)){if(h===""){M(),b([]),V(""),P(void 0);return}w(!1),S(!0);try{const m=i(h,c);Promise.resolve(m).then(C=>{b(C);const N=C.find(D=>D.value===h);N?(P(N),R(!1)):(P(void 0),R(!0)),S(!1)}).catch(()=>{w(!0),S(!1)})}catch{w(!0),S(!1)}}},[M,e,i,c])),Q=l.useCallback(h=>{if(!(!e||!f)){q(!0);try{const m=f(h),C=m instanceof Promise;Promise.resolve(m).then(N=>{N?(P(N),b(D=>{const F=D.findIndex(W=>W.value===h);if(F!==-1){const W=[...D];return W[F]=N,W}return D})):(M(),b([]),V(""),P(void 0)),q(!1),C||(I(!0),setTimeout(()=>{I(!1)},1500))}).catch(()=>{q(!1)})}catch{q(!1)}}},[M,e,f]),_=l.useCallback(h=>{h||G(O[0]?.value??""),R(h)},[O]),K=l.useCallback(h=>{g.current=!1,x.current=!0,V(h),P(O.find(m=>m.value===h)),M(),o?.(h)},[o,M,O]),te=l.useCallback(h=>{const m=h.target.value;g.current=!0,V(m),P(void 0),o?.(m)},[o]),ne=l.useCallback(h=>{G(h)},[]),u=l.useCallback(h=>{v||d?.(h)},[d,v]),y=l.useCallback(h=>{const m=h.clipboardData.getData("text"),C=m.trim();if(m!==C){h.preventDefault();const N=h.currentTarget,D=N.selectionStart||0,F=N.selectionEnd||0,W=N.value,ie=W.substring(0,D)+C+W.substring(F);o?.(ie),requestAnimationFrame(()=>{const pe=D+C.length;N.setSelectionRange(pe,pe),U(ie)})}else m===E&&U(E)},[E,U,o]);return l.useEffect(()=>{e?g.current&&U(E):(M(),b([]),V(""),P(void 0))},[e,E,U,M]),l.useEffect(()=>{x.current||(g.current=!1,V(r??t??""),P(void 0)),x.current=!1},[r]),l.useEffect(()=>{if(n?.length&&E){const h=n.find(m=>m.value===E);h&&P(h)}},[]),{selectedValue:E,selectedOption:z,isPopoverOpen:v,commandListRef:j,options:O,isLoading:A,isLoadingSelectedOption:H,haveFetchError:T,commandValue:$,isFetchSelectedOptionSync:k,toggleOption:K,handleOpenChange:_,onTriggerBlur:u,handleChange:te,handleCommandValue:ne,handleFetchSelectedOption:Q,handlePaste:y}}const ia=X.forwardRef(({id:e,name:t,className:r,label:s,description:n,value:o,defaultValue:d,disabled:i,placeholder:f,required:c,errors:g,warnings:x,onChange:j,onBlur:v,onClick:R,onKeyDown:O,onMouseDown:b,autoComplete:A=!0,variant:S="withValue",maxLength:H,fetchOptionsCallback:q,fetchSelectedOptionCallback:T,isOpenByDefault:w,initialOptions:E,renderOption:V,previewPlaceholder:z,...P},$)=>{const G=l.useId(),k=e??`${G}-id-autocomplete`,I=l.useRef(null),M=J=>{I.current=J,typeof $=="function"?$(J):$&&($.current=J)},U=Array.isArray(x)&&x.length>0,Q=Array.isArray(g)&&g.length>0,{selectedValue:_,selectedOption:K,isPopoverOpen:te,commandListRef:ne,options:u,isLoading:y,isLoadingSelectedOption:h,haveFetchError:m,commandValue:C,isFetchSelectedOptionSync:N,toggleOption:D,handleOpenChange:F,onTriggerBlur:W,handleChange:ie,handleCommandValue:pe,handleFetchSelectedOption:ze,handlePaste:wt}=la({autoComplete:A,defaultValue:d,value:o,isOpenByDefault:w,initialOptions:E,onChange:j,onBlur:v,fetchOptions:q,fetchSelectedOption:T}),Ct=J=>{D(J),I.current?.focus()},Nt=S==="withValueAndTitle"||S==="withValueTitleAndDescription",Rt=l.useMemo(()=>[be.trimOnBlur(),be.trimOnEnter()],[]);return a.jsxs(lt,{children:[!!s&&a.jsx(Je,{htmlFor:k,disabled:i,hasError:Q,required:c,onClick:J=>{J.preventDefault(),J.target.control?.focus()},children:s}),A&&q?a.jsx(bt,{open:te,onOpenChange:F,children:a.jsxs(B,{shouldFilter:!1,value:C,onValueChange:pe,className:p("dark:bg-charcoal-900 bg-gray-100"),children:[a.jsx(Gr,{asChild:!0,children:a.jsx(ta,{id:k,name:t,value:_,className:r,isLoading:y,haveFetchError:m,disabled:i,onChange:ie,onBlur:W,onClick:R,selectedOption:K,optionsLength:u.length,handleOpenChange:F,onKeyDown:O,onMouseDown:b,placeholder:f,hasError:Q,label:s,required:c,isPopoverOpen:te,maxLength:H,handlePaste:wt,...P,ref:M})}),Nt&&(V?V(K===void 0&&z?{...z}:{...K,value:K?.value??""},{asPlaceholder:K===void 0,showValue:!1,isLoadingSelectedOption:h,handleFetchSelectedOption:T?ze:void 0,isFetchSelectedOptionSync:N,className:p("rounded-t-none pt-2")}):a.jsx(Oe,{variant:S,icon:K?.icon??z?.icon,title:K?.title??z?.title,path:K?.path??z?.path,value:K?.value??z?.value??"",description:K?.description??z?.description,asPlaceholder:K===void 0,showValue:!1,isLoadingSelectedOption:h,handleFetchSelectedOption:T?ze:void 0,isFetchSelectedOptionSync:N,className:p("rounded-t-none pt-2")})),a.jsx(yt,{align:"start",onOpenAutoFocus:J=>J.preventDefault(),onInteractOutside:J=>{J.target instanceof Element&&J.target.id===k&&J.preventDefault()},children:a.jsx(na,{variant:S,commandListRef:ne,selectedValue:_,options:u,toggleOption:Ct,renderOption:V,previewPlaceholder:z})})]})}):a.jsx(jt,{transformers:Rt,children:a.jsx(Ve,{id:k,name:t,value:_,className:r,disabled:i,onChange:ie,onBlur:v,onClick:R,onMouseDown:b,placeholder:f,"aria-invalid":Q,"aria-label":s?void 0:"Id Autocomplete","aria-required":c,maxLength:H,...P,ref:M})}),!!n&&a.jsx(ot,{children:n}),U&&a.jsx(xe,{messages:x,type:"warning"}),Q&&a.jsx(xe,{messages:g,type:"error"})]})});ia.displayName="IdAutocomplete";export{Ve as I,bt as P,Yr as S,Ur as a,yt as b,ia as c,xa as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ee,g as Pt}from"./react-DQSxOgtG.js";import{c as oe,a as ds,i as ls,B as hs,b as fs,d as gs,e as ps,f as ms,g as ct,h as Lt,j as ys,p as Nr,k as Le,v as He,l as ar,m as cr,r as vs,n as Dt,s as Ge,o as ws,q as bs,t as Ds,u as Ve,w as Cr,x as Ss,y as Es,z as Is,A as Je}from"./document_model-
|
|
1
|
+
import{c as Ee,g as Pt}from"./react-DQSxOgtG.js";import{c as oe,a as ds,i as ls,B as hs,b as fs,d as gs,e as ps,f as ms,g as ct,h as Lt,j as ys,p as Nr,k as Le,v as He,l as ar,m as cr,r as vs,n as Dt,s as Ge,o as ws,q as bs,t as Ds,u as Ve,w as Cr,x as Ss,y as Es,z as Is,A as Je}from"./document_model-D4RwF66T.js";import{a as Ts,p as Rs,G as Ms,b as Os,c as St,d as ur,e as Et,f as _s,g as As}from"./graphql-BS4Brs_E.js";import{o as W,s as $,f as Ze,b as ge,e as xr,d as Oe,a as Ns,c as Cs}from"./zod-C6yxFxyo.js";import{i as xs,L as he}from"./config-CU-aFfVJ.js";function $s(i,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in i)){const s=Object.getOwnPropertyDescriptor(r,n);s&&Object.defineProperty(i,n,s.get?s:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var Ps={};class $r{#e;#t="env";#r;constructor(e,t){this.#e=(e||[]).map(r=>`[${r}]`),this.#r=t,this.log=this.log.bind(this),this.info=this.info.bind(this),this.warn=this.warn.bind(this),this.error=this.error.bind(this),this.debug=this.debug.bind(this),this.verbose=this.verbose.bind(this)}get level(){return this.#t}set level(e){if(e!=="env"&&!xs(e))throw new Error(`Invalid log level: ${JSON.stringify(e)}.
|
|
2
2
|
Must be one of ${Object.keys(he).concat(["env"]).join(", ")}.`);this.#t=e}get errorHandler(){return this.#r}set errorHandler(e){this.#r=e}get#n(){if(this.#t==="env"){const e=typeof globalThis<"u"&&globalThis.process&&"env"in globalThis.process?Ps.LOG_LEVEL:void 0;return e?e in he?he[e]:he.info:he.info}return he[this.#t]}log(...e){return this.debug(...e)}verbose(...e){if(!(this.#n>he.verbose))return this.debug(...e)}debug(...e){if(!(this.#n>he.debug))return console.debug(...this.#e,...e)}info(...e){if(!(this.#n>he.info))return console.info(...this.#e,...e)}warn(...e){if(!(this.#n>he.warn))return console.warn(...this.#e,...e)}error(...e){if(!(this.#n>he.error))return this.#r&&this.#r(...e),console.error(...this.#e,...e)}}const ut=new $r;let Ut="env",Pr;ut.level=Ut;ut.errorHandler=Pr;const fe=ut,Ao=i=>{Ut=i,ut.level=i},pe=i=>{const e=new $r(i);return e.level=Ut,e.errorHandler=Pr,e},dr=i=>{const e={};for(const[t,r]of Object.entries(i.operations))r&&(e[t]=r.map(n=>(delete n.resultingState,n)));return{...i,operations:e}};class Ls{index=0;cache;constructor(e){this.cache=e}createStorage(){const e=this.index;this.index+=1;function t(n){return`${e}-${n}`}const r={get:n=>this.cache.get(t(n)),set:(n,s)=>(this.cache.set(t(n),s),r),delete:n=>this.cache.delete(t(n)),clear:()=>{this.cache.clear()}};return r}}class Us{cache;cacheStorageManager;idToDocument;idToDrive;slugToDriveId;constructor(e=new Map){this.cache=e,this.cacheStorageManager=new Ls(e),this.idToDocument=this.cacheStorageManager.createStorage(),this.idToDrive=this.cacheStorageManager.createStorage(),this.slugToDriveId=this.cacheStorageManager.createStorage()}clear(){this.idToDocument.clear(),this.idToDrive.clear(),this.slugToDriveId.clear()}async setDocument(e,t){const r=dr(t);this.idToDocument.set(e,r)}async getDocument(e){return this.idToDocument.get(e)}async deleteDocument(e){return this.idToDocument.delete(e)}async setDrive(e,t){const r=dr(t);this.idToDrive.set(e,r)}async getDrive(e){return this.idToDrive.get(e)}async deleteDrive(e){const t=this.idToDrive.get(e);if(!t)return!1;const r=t.header.slug.length>0?t.header.slug:e;return r&&this.slugToDriveId.delete(r),this.idToDrive.delete(e)}async setDriveBySlug(e,t){const r=t.header.id;this.slugToDriveId.set(e,r),this.setDrive(r,t)}async getDriveBySlug(e){const t=this.slugToDriveId.get(e);if(t)return this.getDrive(t)}async deleteDriveBySlug(e){const t=this.slugToDriveId.get(e);return t?(this.slugToDriveId.delete(e),this.deleteDrive(t)):!1}}const Bs="phdd",Fs=i=>i!=null;Cs().refine(i=>Fs(i));const ks=xr(["Internal","MatrixConnect","PullResponder","RESTWebhook","SecureConnect","SwitchboardPush"]),qs=xr(["PullResponder"]);function Lr(){return W({documentType:$(),id:$(),name:$(),parentFolder:$().nullish()})}function Ur(){return W({id:$(),name:$(),parentFolder:$().nullish()})}function Br(){return W({listener:zr()})}function Fr(){return W({trigger:Kr()})}function kr(){return W({srcId:$(),targetId:$(),targetName:$().nullish(),targetParentFolder:$().nullish()})}function qr(){return W({id:$()})}function zs(){return W({__typename:ge("DocumentDriveLocalState").optional(),availableOffline:Ze(),listeners:Oe(zr()),sharingType:$().nullable(),triggers:Oe(Kr())})}function js(){return W({__typename:ge("DocumentDriveState").optional(),icon:$().nullable(),name:$(),nodes:Oe(Qs())})}function Hs(){return W({__typename:ge("FileNode").optional(),documentType:$(),id:$(),kind:$(),name:$(),parentFolder:$().nullable()})}function Gs(){return W({__typename:ge("FolderNode").optional(),id:$(),kind:$(),name:$(),parentFolder:$().nullable()})}function zr(){return W({__typename:ge("Listener").optional(),block:Ze(),callInfo:Js().nullable(),filter:Ys(),label:$().nullable(),listenerId:$(),system:Ze()})}function Js(){return W({__typename:ge("ListenerCallInfo").optional(),data:$().nullable(),name:$().nullable(),transmitterType:ks.nullable()})}function Ys(){return W({__typename:ge("ListenerFilter").optional(),branch:Oe($()).nullable(),documentId:Oe($()).nullable(),documentType:Oe($()),scope:Oe($()).nullable()})}function jr(){return W({srcFolder:$(),targetParentFolder:$().nullish()})}function Qs(){return Ns([Hs(),Gs()])}function Vs(){return W({__typename:ge("PullResponderTriggerData").optional(),interval:$(),listenerId:$(),url:$()})}function Hr(){return W({listenerId:$()})}function Gr(){return W({triggerId:$()})}function Jr(){return W({availableOffline:Ze()})}function Yr(){return W({icon:$()})}function Qr(){return W({name:$()})}function Vr(){return W({type:$()})}function Kr(){return W({__typename:ge("Trigger").optional(),data:Ks().nullable(),id:$(),type:qs})}function Ks(){return Vs()}function Wr(){return W({documentType:$().nullish(),id:$(),name:$().nullish(),parentFolder:$().nullish()})}function Xr(){return W({id:$(),name:$().nullish(),parentFolder:$().nullish()})}function Ws(i){return i&&typeof i=="object"&&"synchronizationUnits"in i?oe("ADD_FILE",{...i},void 0,void 0,"global"):oe("ADD_FILE",{...i},void 0,Lr,"global")}const Xs=i=>oe("ADD_FOLDER",{...i},void 0,Ur,"global"),Zs=i=>oe("DELETE_NODE",{...i},void 0,qr,"global"),ei=i=>oe("UPDATE_FILE",{...i},void 0,Wr,"global"),ti=i=>oe("UPDATE_NODE",{...i},void 0,Xr,"global"),ri=i=>oe("COPY_NODE",{...i},void 0,kr,"global"),ni=i=>oe("MOVE_NODE",{...i},void 0,jr,"global"),si=i=>oe("SET_DRIVE_NAME",{...i},void 0,Qr,"global"),ii=i=>oe("SET_DRIVE_ICON",{...i},void 0,Yr,"global"),Zr=i=>oe("SET_SHARING_TYPE",{...i},void 0,Vr,"local"),oi=i=>oe("SET_AVAILABLE_OFFLINE",{...i},void 0,Jr,"local"),ai=i=>oe("ADD_LISTENER",{...i},void 0,Br,"local"),en=i=>oe("REMOVE_LISTENER",{...i},void 0,Hr,"local"),ci=i=>oe("ADD_TRIGGER",{...i},void 0,Fr,"local"),tn=i=>oe("REMOVE_TRIGGER",{...i},void 0,Gr,"local"),ui=Object.freeze(Object.defineProperty({__proto__:null,addFile:Ws,addFolder:Xs,addListener:ai,addTrigger:ci,copyNode:ri,deleteNode:Zs,moveNode:ni,removeListener:en,removeTrigger:tn,setAvailableOffline:oi,setDriveIcon:ii,setDriveName:si,setSharingType:Zr,updateFile:ei,updateNode:ti},Symbol.toStringTag,{value:"Module"})),di={id:"powerhouse/document-drive",name:"DocumentDrive",extension:"phdd",description:"",author:{name:"Powerhouse Inc",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],state:{global:{schema:`type FolderNode {
|
|
3
3
|
id: String!
|
|
4
4
|
name: String!
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./sentry_react-cODD7zWc.js";import"./document_model_editor-
|
|
1
|
+
import"./sentry_react-cODD7zWc.js";import"./document_model_editor-D_BY44WX.js";import"./react-DQSxOgtG.js";
|
|
@@ -227,4 +227,4 @@ type DocumentModelGlobalState {
|
|
|
227
227
|
}`,template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"REORDER_STATE_EXAMPLES",id:"",description:"Changes the order of state examples for a document scope",schema:`input ReorderStateExamplesInput {
|
|
228
228
|
scope: String!
|
|
229
229
|
order: [ID!]!
|
|
230
|
-
}`,template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}]}]},br="powerhouse/document-model",Is=ee({id:L(),name:L(),createdAtUtcIso:L(),lastModifiedAtUtcIso:L(),documentType:L()}),As=ee({global:sn()}),Rs=Is.extend({documentType:be(br)}),gt=As.extend({global:vo()}),yr=ee({header:Rs,state:gt,initialState:gt});function ks(e){return gt.safeParse(e).success}function Ts(e){gt.parse(e)}function Ds(e){return yr.safeParse(e).success}function Cs(e){yr.parse(e)}function tt(e){const t={};return e.forEach((n,r)=>t[n]=r),(n,r)=>(t[r.id]||999999)-(t[n.id]||999999)}const je={setModelNameOperation(e,t){e.name=t.input.name},setModelIdOperation(e,t){e.id=t.input.id},setModelExtensionOperation(e,t){e.extension=t.input.extension},setModelDescriptionOperation(e,t){e.description=t.input.description},setAuthorNameOperation(e,t){e.author=e.author||{name:"",website:null},e.author.name=t.input.authorName},setAuthorWebsiteOperation(e,t){e.author=e.author||{name:"",website:null},e.author.website=t.input.authorWebsite}},Xe={addModuleOperation(e,t){e.specifications[e.specifications.length-1].modules.push({id:t.input.id,name:t.input.name,description:t.input.description||"",operations:[]})},setModuleNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id===t.input.id&&(n.modules[r].name=t.input.name||"")},setModuleDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id===t.input.id&&(n.modules[r].description=t.input.description||"")},deleteModuleOperation(e,t){const n=e.specifications[e.specifications.length-1];n.modules=n.modules.filter(r=>r.id!=t.input.id)},reorderModulesOperation(e,t){e.specifications[e.specifications.length-1].modules.sort(tt(t.input.order))}},ze={addOperationErrorOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].errors.push({id:t.input.id,name:t.input.errorName||"",code:t.input.errorCode||"",description:t.input.errorDescription||"",template:t.input.errorTemplate||""})},setOperationErrorCodeOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].errors.length;s++)n.modules[r].operations[i].errors[s].id==t.input.id&&(n.modules[r].operations[i].errors[s].code=t.input.errorCode||"")},setOperationErrorNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].errors.length;s++)n.modules[r].operations[i].errors[s].id==t.input.id&&(n.modules[r].operations[i].errors[s].name=t.input.errorName||"")},setOperationErrorDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].errors.length;s++)n.modules[r].operations[i].errors[s].id==t.input.id&&(n.modules[r].operations[i].errors[s].description=t.input.errorDescription||"")},setOperationErrorTemplateOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].errors.length;s++)n.modules[r].operations[i].errors[s].id==t.input.id&&(n.modules[r].operations[i].errors[s].template=t.input.errorTemplate||"")},deleteOperationErrorOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].errors=n.modules[r].operations[i].errors.filter(s=>s.id!=t.input.id)},reorderOperationErrorsOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].errors.sort(tt(t.input.order))}},ut={addOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].examples.push({id:t.input.id,value:t.input.example})},updateOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].examples.length;s++)n.modules[r].operations[i].examples[s].id==t.input.id&&(n.modules[r].operations[i].examples[s].value=t.input.example)},deleteOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].examples=n.modules[r].operations[i].examples.filter(s=>s.id!=t.input.id)},reorderOperationExamplesOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].examples.sort(tt(t.input.order))}},ve={addOperationOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id==t.input.moduleId&&n.modules[r].operations.push({id:t.input.id,name:t.input.name,description:t.input.description||"",schema:t.input.schema||"",template:t.input.template||t.input.description||"",reducer:t.input.reducer||"",errors:[],examples:[],scope:t.input.scope||"global"})},setOperationNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].name=t.input.name||"")},setOperationScopeOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].scope=t.input.scope||"global")},setOperationSchemaOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].schema=t.input.schema||"")},setOperationDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].description=t.input.description||"")},setOperationTemplateOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].template=t.input.template||"")},setOperationReducerOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].reducer=t.input.reducer||"")},moveOperationOperation(e,t){const n=[],r=e.specifications[e.specifications.length-1];for(let i=0;i<r.modules.length;i++)r.modules[i].operations=r.modules[i].operations.filter(s=>s.id==t.input.operationId?(n.push(s),!1):!0);for(let i=0;i<r.modules.length;i++)r.modules[i].id==t.input.newModuleId&&r.modules[i].operations.push(...n)},deleteOperationOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].operations=n.modules[r].operations.filter(i=>i.id!=t.input.id)},reorderModuleOperationsOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id==t.input.moduleId&&n.modules[r].operations.sort(tt(t.input.order))}},Be={setStateSchemaOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].schema=t.input.schema;else throw new Error(`Invalid scope: ${t.input.scope}`)},setInitialStateOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].initialValue=t.input.initialValue;else throw new Error(`Invalid scope: ${t.input.scope}`)},addStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples.push({id:t.input.id,value:t.input.example});else throw new Error(`Invalid scope: ${t.input.scope}`)},updateStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(!Object.keys(n.state).includes(t.input.scope))throw new Error(`Invalid scope: ${t.input.scope}`);const r=n.state[t.input.scope].examples;for(let i=0;i<r.length;i++)r[i].id==t.input.id&&(r[i].value=t.input.newExample)},deleteStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples=n.state[t.input.scope].examples.filter(r=>r.id!=t.input.id);else throw new Error(`Invalid scope: ${t.input.scope}`)},reorderStateExamplesOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples.sort(tt(t.input.order));else throw new Error(`Invalid scope: ${t.input.scope}`)}},Ke={addChangeLogItemOperation(e,t){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(e,t){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(e,t){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(e,t){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(e,t){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},Ms=(e,t)=>{if(_n(t))return e;switch(t.type){case"SET_MODEL_NAME":nr().parse(t.input),je.setModelNameOperation(e.global,t);break;case"SET_MODEL_ID":tr().parse(t.input),je.setModelIdOperation(e.global,t);break;case"SET_MODEL_EXTENSION":er().parse(t.input),je.setModelExtensionOperation(e.global,t);break;case"SET_MODEL_DESCRIPTION":Qn().parse(t.input),je.setModelDescriptionOperation(e.global,t);break;case"SET_AUTHOR_NAME":Jn().parse(t.input),je.setAuthorNameOperation(e.global,t);break;case"SET_AUTHOR_WEBSITE":qn().parse(t.input),je.setAuthorWebsiteOperation(e.global,t);break;case"ADD_CHANGE_LOG_ITEM":Mn().parse(t.input),Ke.addChangeLogItemOperation(e.global,t);break;case"UPDATE_CHANGE_LOG_ITEM":gr().parse(t.input),Ke.updateChangeLogItemOperation(e.global,t);break;case"DELETE_CHANGE_LOG_ITEM":jn().parse(t.input),Ke.deleteChangeLogItemOperation(e.global,t);break;case"REORDER_CHANGE_LOG_ITEMS":Zn().parse(t.input),Ke.reorderChangeLogItemsOperation(e.global,t);break;case"RELEASE_NEW_VERSION":if(Object.keys(t.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");Ke.releaseNewVersionOperation(e.global,t);break;case"ADD_MODULE":Nn().parse(t.input),Xe.addModuleOperation(e.global,t);break;case"SET_MODULE_NAME":ir().parse(t.input),Xe.setModuleNameOperation(e.global,t);break;case"SET_MODULE_DESCRIPTION":rr().parse(t.input),Xe.setModuleDescriptionOperation(e.global,t);break;case"DELETE_MODULE":Bn().parse(t.input),Xe.deleteModuleOperation(e.global,t);break;case"REORDER_MODULES":Vn().parse(t.input),Xe.reorderModulesOperation(e.global,t);break;case"ADD_OPERATION_ERROR":zn().parse(t.input),ze.addOperationErrorOperation(e.global,t);break;case"SET_OPERATION_ERROR_CODE":sr().parse(t.input),ze.setOperationErrorCodeOperation(e.global,t);break;case"SET_OPERATION_ERROR_NAME":lr().parse(t.input),ze.setOperationErrorNameOperation(e.global,t);break;case"SET_OPERATION_ERROR_DESCRIPTION":ar().parse(t.input),ze.setOperationErrorDescriptionOperation(e.global,t);break;case"SET_OPERATION_ERROR_TEMPLATE":ur().parse(t.input),ze.setOperationErrorTemplateOperation(e.global,t);break;case"DELETE_OPERATION_ERROR":Fn().parse(t.input),ze.deleteOperationErrorOperation(e.global,t);break;case"REORDER_OPERATION_ERRORS":Xn().parse(t.input),ze.reorderOperationErrorsOperation(e.global,t);break;case"ADD_OPERATION_EXAMPLE":wo().parse(t.input),ut.addOperationExampleOperation(e.global,t);break;case"UPDATE_OPERATION_EXAMPLE":Co().parse(t.input),ut.updateOperationExampleOperation(e.global,t);break;case"DELETE_OPERATION_EXAMPLE":xo().parse(t.input),ut.deleteOperationExampleOperation(e.global,t);break;case"REORDER_OPERATION_EXAMPLES":To().parse(t.input),ut.reorderOperationExamplesOperation(e.global,t);break;case"ADD_OPERATION":Pn().parse(t.input),ve.addOperationOperation(e.global,t);break;case"SET_OPERATION_NAME":cr().parse(t.input),ve.setOperationNameOperation(e.global,t);break;case"SET_OPERATION_SCOPE":pr().parse(t.input),ve.setOperationScopeOperation(e.global,t);break;case"SET_OPERATION_SCHEMA":fr().parse(t.input),ve.setOperationSchemaOperation(e.global,t);break;case"SET_OPERATION_DESCRIPTION":or().parse(t.input),ve.setOperationDescriptionOperation(e.global,t);break;case"SET_OPERATION_TEMPLATE":hr().parse(t.input),ve.setOperationTemplateOperation(e.global,t);break;case"SET_OPERATION_REDUCER":dr().parse(t.input),ve.setOperationReducerOperation(e.global,t);break;case"MOVE_OPERATION":Hn().parse(t.input),ve.moveOperationOperation(e.global,t);break;case"DELETE_OPERATION":$n().parse(t.input),ve.deleteOperationOperation(e.global,t);break;case"REORDER_MODULE_OPERATIONS":Gn().parse(t.input),ve.reorderModuleOperationsOperation(e.global,t);break;case"SET_STATE_SCHEMA":mr().parse(t.input),Be.setStateSchemaOperation(e.global,t);break;case"SET_INITIAL_STATE":Yn().parse(t.input),Be.setInitialStateOperation(e.global,t);break;case"ADD_STATE_EXAMPLE":Ln().parse(t.input),Be.addStateExampleOperation(e.global,t);break;case"UPDATE_STATE_EXAMPLE":_r().parse(t.input),Be.updateStateExampleOperation(e.global,t);break;case"DELETE_STATE_EXAMPLE":Wn().parse(t.input),Be.deleteStateExampleOperation(e.global,t);break;case"REORDER_STATE_EXAMPLES":Kn().parse(t.input),Be.reorderStateExamplesOperation(e.global,t);break;default:return e}},Er=Tn(Ms),Ns=(e,t)=>Fi(e,t),zs=e=>$i(e,Er),Sr=e=>({...$t(),global:{...xs,...e?.global??{}},local:{...Os,...e?.local??{}}});function Ps(){return{...$t(),author:{name:"",website:""},description:"",extension:"",id:"",name:"",specifications:[]}}function Ls(){return{}}function Us(e){return{...Ps(),...e||{}}}function js(e){return{...Ls()}}function Bs(e,t,n){return{...So(e?.auth,e?.document),global:Us(t),local:js()}}function Fs(e){const t=bn(Sr,e);return t.header.documentType=br,t}const $s=e=>ks(e),Ws=e=>{Ts(e)},Hs=e=>Ds(e),Zs=e=>{Cs(e)},Gs={fileExtension:ws,createState:Sr,createDocument:Fs,loadFromInput:zs,saveToFileHandle:Ns,isStateOfType:$s,assertIsStateOfType:Ws,isDocumentOfType:Hs,assertIsDocumentOfType:Zs},pa={reducer:Er,documentModel:Bs($t(),vs),actions:Ss,utils:Gs},Vs=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Xs=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Ks=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Js=/[^\p{L}\d]+/giu,nn="$1\0$2",rn="";function wr(e){let t=e.trim();t=t.replace(Vs,nn).replace(Xs,nn),t=t.replace(Js,"\0");let n=0,r=t.length;for(;t.charAt(n)==="\0";)n++;if(n===r)return[];for(;t.charAt(r-1)==="\0";)r--;return t.slice(n,r).split(/\0/g)}function qs(e){const t=wr(e);for(let n=0;n<t.length;n++){const r=t[n],i=Ks.exec(r);if(i){const s=i.index+(i[1]??i[2]).length;t.splice(n,1,r.slice(0,s),r.slice(s))}}return t}function Ys(e,t){const[n,r,i]=nt(e,t);return n+r.map(bt(t?.locale)).join(t?.delimiter??" ")+i}function on(e,t){const[n,r,i]=nt(e,t),s=bt(t?.locale),l=yt(t?.locale),o=t?.mergeAmbiguousCharacters?Wt(s,l):Qs(s,l);return n+r.map(o).join(t?.delimiter??"")+i}function da(e,t){const[n,r,i]=nt(e,t),s=bt(t?.locale),l=yt(t?.locale);return n+r.map(Wt(s,l)).join(" ")+i}function fa(e,t){const[n,r,i]=nt(e,t);return n+r.map(yt(t?.locale)).join("_")+i}function ha(e,t){const[n,r,i]=nt(e,t),s=bt(t?.locale),l=yt(t?.locale),o=Wt(s,l);return n+r.map((u,d)=>d===0?o(u):s(u)).join(" ")+i}function ma(e,t){return Ys(e,{delimiter:"_",...t})}function bt(e){return e===!1?t=>t.toLowerCase():t=>t.toLocaleLowerCase(e)}function yt(e){return e===!1?t=>t.toUpperCase():t=>t.toLocaleUpperCase(e)}function Wt(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function Qs(e,t){return(n,r)=>{const i=n[0];return(r>0&&i>="0"&&i<="9"?"_"+i:t(i))+e(n.slice(1))}}function nt(e,t={}){const n=t.split??(t.separateNumbers?qs:wr),r=t.prefixCharacters??rn,i=t.suffixCharacters??rn;let s=0,l=e.length;for(;s<e.length;){const o=e.charAt(s);if(!r.includes(o))break;s++}for(;l>s;){const o=l-1,u=e.charAt(o);if(!i.includes(u))break;l=o}return[e.slice(0,s),n(e.slice(s,l)),e.slice(l)]}function ga(e,t=!1){const n=[];if(t&&e==="")return n;try{const r=JSON.parse(e);!t&&!Object.keys(r).length&&n.push({message:"Initial state cannot be empty",details:{initialState:e}})}catch{n.push({message:"Invalid initial state",details:{initialState:e}})}return n}function _a(e,t,n="",r=!0){const i=[];if(!r&&!e)return i.push({message:"State schema is required",details:{schema:e}}),i;if(r&&!e)return i;const s=`type ${on(t)}${on(n)}State`;return e.includes(s)||i.push({message:`Invalid state schema name. Expected ${s}`,details:{schema:e}}),i}function ba(e){const t=[];e.length||t.push({message:"Modules are required",details:{modules:e}});const n=e.reduce((r,i)=>[...r,...ea(i)],[]);return[...t,...n]}function ea(e){const t=[];e.name||t.push({message:"Module name is required",details:{module:e}}),e.operations.length||t.push({message:"Module operations are required",details:{module:e}});const n=e.operations.reduce((r,i)=>[...r,...ta(i)],[]);return[...t,...n]}function ta(e){const t=[];return e.name||t.push({message:"Operation name is required",details:{operation:e}}),e.schema||t.push({message:"Operation schema is required",details:{operation:e}}),t}export{da as $,lt as A,As as B,ma as C,fa as D,ha as E,No as F,ls as G,zo as H,Lo as I,Po as J,Uo as K,jo as L,us as M,Bo as N,Fo as O,Wo as P,Go as Q,Xo as R,Ko as S,Qo as T,ts as U,ss as V,rs as W,Zo as X,ia as Y,br as Z,Bi as _,Tn as a,ga as a0,_a as a1,ba as a2,di as a3,pi as a4,Ss as a5,pa as a6,Is as b,oe as c,Fi as d,$i as e,bn as f,Dt as g,$t as h,_n as i,Bs as j,xi as k,Ct as l,ua as m,Re as n,aa as o,on as p,la as q,ca as r,Te as s,Ri as t,dt as u,oa as v,yn as w,Di as x,Ni as y,sa as z};
|
|
230
|
+
}`,template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}]}]},br="powerhouse/document-model",Is=ee({id:L(),name:L(),createdAtUtcIso:L(),lastModifiedAtUtcIso:L(),documentType:L()}),As=ee({global:sn()}),Rs=Is.extend({documentType:be(br)}),gt=As.extend({global:vo()}),yr=ee({header:Rs,state:gt,initialState:gt});function ks(e){return gt.safeParse(e).success}function Ts(e){gt.parse(e)}function Ds(e){return yr.safeParse(e).success}function Cs(e){yr.parse(e)}function tt(e){const t={};return e.forEach((n,r)=>t[n]=r),(n,r)=>(t[r.id]||999999)-(t[n.id]||999999)}const je={setModelNameOperation(e,t){e.name=t.input.name},setModelIdOperation(e,t){e.id=t.input.id},setModelExtensionOperation(e,t){e.extension=t.input.extension},setModelDescriptionOperation(e,t){e.description=t.input.description},setAuthorNameOperation(e,t){e.author=e.author||{name:"",website:null},e.author.name=t.input.authorName},setAuthorWebsiteOperation(e,t){e.author=e.author||{name:"",website:null},e.author.website=t.input.authorWebsite}},Xe={addModuleOperation(e,t){e.specifications[e.specifications.length-1].modules.push({id:t.input.id,name:t.input.name,description:t.input.description||"",operations:[]})},setModuleNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id===t.input.id&&(n.modules[r].name=t.input.name||"")},setModuleDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id===t.input.id&&(n.modules[r].description=t.input.description||"")},deleteModuleOperation(e,t){const n=e.specifications[e.specifications.length-1];n.modules=n.modules.filter(r=>r.id!=t.input.id)},reorderModulesOperation(e,t){e.specifications[e.specifications.length-1].modules.sort(tt(t.input.order))}},ze={addOperationErrorOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].errors.push({id:t.input.id,name:t.input.errorName||"",code:t.input.errorCode||"",description:t.input.errorDescription||"",template:t.input.errorTemplate||""})},setOperationErrorCodeOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].errors.length;s++)n.modules[r].operations[i].errors[s].id==t.input.id&&(n.modules[r].operations[i].errors[s].code=t.input.errorCode||"")},setOperationErrorNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].errors.length;s++)n.modules[r].operations[i].errors[s].id==t.input.id&&(n.modules[r].operations[i].errors[s].name=t.input.errorName||"")},setOperationErrorDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].errors.length;s++)n.modules[r].operations[i].errors[s].id==t.input.id&&(n.modules[r].operations[i].errors[s].description=t.input.errorDescription||"")},setOperationErrorTemplateOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].errors.length;s++)n.modules[r].operations[i].errors[s].id==t.input.id&&(n.modules[r].operations[i].errors[s].template=t.input.errorTemplate||"")},deleteOperationErrorOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].errors=n.modules[r].operations[i].errors.filter(s=>s.id!=t.input.id)},reorderOperationErrorsOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].errors.sort(tt(t.input.order))}},ut={addOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].examples.push({id:t.input.id,value:t.input.example})},updateOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)for(let s=0;s<n.modules[r].operations[i].examples.length;s++)n.modules[r].operations[i].examples[s].id==t.input.id&&(n.modules[r].operations[i].examples[s].value=t.input.example)},deleteOperationExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].examples=n.modules[r].operations[i].examples.filter(s=>s.id!=t.input.id)},reorderOperationExamplesOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.operationId&&n.modules[r].operations[i].examples.sort(tt(t.input.order))}},ve={addOperationOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id==t.input.moduleId&&n.modules[r].operations.push({id:t.input.id,name:t.input.name,description:t.input.description||"",schema:t.input.schema||"",template:t.input.template||t.input.description||"",reducer:t.input.reducer||"",errors:[],examples:[],scope:t.input.scope||"global"})},setOperationNameOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].name=t.input.name||"")},setOperationScopeOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].scope=t.input.scope||"global")},setOperationSchemaOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].schema=t.input.schema||"")},setOperationDescriptionOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].description=t.input.description||"")},setOperationTemplateOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].template=t.input.template||"")},setOperationReducerOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)for(let i=0;i<n.modules[r].operations.length;i++)n.modules[r].operations[i].id==t.input.id&&(n.modules[r].operations[i].reducer=t.input.reducer||"")},moveOperationOperation(e,t){const n=[],r=e.specifications[e.specifications.length-1];for(let i=0;i<r.modules.length;i++)r.modules[i].operations=r.modules[i].operations.filter(s=>s.id==t.input.operationId?(n.push(s),!1):!0);for(let i=0;i<r.modules.length;i++)r.modules[i].id==t.input.newModuleId&&r.modules[i].operations.push(...n)},deleteOperationOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].operations=n.modules[r].operations.filter(i=>i.id!=t.input.id)},reorderModuleOperationsOperation(e,t){const n=e.specifications[e.specifications.length-1];for(let r=0;r<n.modules.length;r++)n.modules[r].id==t.input.moduleId&&n.modules[r].operations.sort(tt(t.input.order))}},Be={setStateSchemaOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].schema=t.input.schema;else throw new Error(`Invalid scope: ${t.input.scope}`)},setInitialStateOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].initialValue=t.input.initialValue;else throw new Error(`Invalid scope: ${t.input.scope}`)},addStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples.push({id:t.input.id,value:t.input.example});else throw new Error(`Invalid scope: ${t.input.scope}`)},updateStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(!Object.keys(n.state).includes(t.input.scope))throw new Error(`Invalid scope: ${t.input.scope}`);const r=n.state[t.input.scope].examples;for(let i=0;i<r.length;i++)r[i].id==t.input.id&&(r[i].value=t.input.newExample)},deleteStateExampleOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples=n.state[t.input.scope].examples.filter(r=>r.id!=t.input.id);else throw new Error(`Invalid scope: ${t.input.scope}`)},reorderStateExamplesOperation(e,t){const n=e.specifications[e.specifications.length-1];if(Object.keys(n.state).includes(t.input.scope))n.state[t.input.scope].examples.sort(tt(t.input.order));else throw new Error(`Invalid scope: ${t.input.scope}`)}},Ke={addChangeLogItemOperation(e,t){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(e,t){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(e,t){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(e,t){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(e,t){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},Ms=(e,t)=>{if(_n(t))return e;switch(t.type){case"SET_MODEL_NAME":nr().parse(t.input),je.setModelNameOperation(e.global,t);break;case"SET_MODEL_ID":tr().parse(t.input),je.setModelIdOperation(e.global,t);break;case"SET_MODEL_EXTENSION":er().parse(t.input),je.setModelExtensionOperation(e.global,t);break;case"SET_MODEL_DESCRIPTION":Qn().parse(t.input),je.setModelDescriptionOperation(e.global,t);break;case"SET_AUTHOR_NAME":Jn().parse(t.input),je.setAuthorNameOperation(e.global,t);break;case"SET_AUTHOR_WEBSITE":qn().parse(t.input),je.setAuthorWebsiteOperation(e.global,t);break;case"ADD_CHANGE_LOG_ITEM":Mn().parse(t.input),Ke.addChangeLogItemOperation(e.global,t);break;case"UPDATE_CHANGE_LOG_ITEM":gr().parse(t.input),Ke.updateChangeLogItemOperation(e.global,t);break;case"DELETE_CHANGE_LOG_ITEM":jn().parse(t.input),Ke.deleteChangeLogItemOperation(e.global,t);break;case"REORDER_CHANGE_LOG_ITEMS":Zn().parse(t.input),Ke.reorderChangeLogItemsOperation(e.global,t);break;case"RELEASE_NEW_VERSION":if(Object.keys(t.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");Ke.releaseNewVersionOperation(e.global,t);break;case"ADD_MODULE":Nn().parse(t.input),Xe.addModuleOperation(e.global,t);break;case"SET_MODULE_NAME":ir().parse(t.input),Xe.setModuleNameOperation(e.global,t);break;case"SET_MODULE_DESCRIPTION":rr().parse(t.input),Xe.setModuleDescriptionOperation(e.global,t);break;case"DELETE_MODULE":Bn().parse(t.input),Xe.deleteModuleOperation(e.global,t);break;case"REORDER_MODULES":Vn().parse(t.input),Xe.reorderModulesOperation(e.global,t);break;case"ADD_OPERATION_ERROR":zn().parse(t.input),ze.addOperationErrorOperation(e.global,t);break;case"SET_OPERATION_ERROR_CODE":sr().parse(t.input),ze.setOperationErrorCodeOperation(e.global,t);break;case"SET_OPERATION_ERROR_NAME":lr().parse(t.input),ze.setOperationErrorNameOperation(e.global,t);break;case"SET_OPERATION_ERROR_DESCRIPTION":ar().parse(t.input),ze.setOperationErrorDescriptionOperation(e.global,t);break;case"SET_OPERATION_ERROR_TEMPLATE":ur().parse(t.input),ze.setOperationErrorTemplateOperation(e.global,t);break;case"DELETE_OPERATION_ERROR":Fn().parse(t.input),ze.deleteOperationErrorOperation(e.global,t);break;case"REORDER_OPERATION_ERRORS":Xn().parse(t.input),ze.reorderOperationErrorsOperation(e.global,t);break;case"ADD_OPERATION_EXAMPLE":wo().parse(t.input),ut.addOperationExampleOperation(e.global,t);break;case"UPDATE_OPERATION_EXAMPLE":Co().parse(t.input),ut.updateOperationExampleOperation(e.global,t);break;case"DELETE_OPERATION_EXAMPLE":xo().parse(t.input),ut.deleteOperationExampleOperation(e.global,t);break;case"REORDER_OPERATION_EXAMPLES":To().parse(t.input),ut.reorderOperationExamplesOperation(e.global,t);break;case"ADD_OPERATION":Pn().parse(t.input),ve.addOperationOperation(e.global,t);break;case"SET_OPERATION_NAME":cr().parse(t.input),ve.setOperationNameOperation(e.global,t);break;case"SET_OPERATION_SCOPE":pr().parse(t.input),ve.setOperationScopeOperation(e.global,t);break;case"SET_OPERATION_SCHEMA":fr().parse(t.input),ve.setOperationSchemaOperation(e.global,t);break;case"SET_OPERATION_DESCRIPTION":or().parse(t.input),ve.setOperationDescriptionOperation(e.global,t);break;case"SET_OPERATION_TEMPLATE":hr().parse(t.input),ve.setOperationTemplateOperation(e.global,t);break;case"SET_OPERATION_REDUCER":dr().parse(t.input),ve.setOperationReducerOperation(e.global,t);break;case"MOVE_OPERATION":Hn().parse(t.input),ve.moveOperationOperation(e.global,t);break;case"DELETE_OPERATION":$n().parse(t.input),ve.deleteOperationOperation(e.global,t);break;case"REORDER_MODULE_OPERATIONS":Gn().parse(t.input),ve.reorderModuleOperationsOperation(e.global,t);break;case"SET_STATE_SCHEMA":mr().parse(t.input),Be.setStateSchemaOperation(e.global,t);break;case"SET_INITIAL_STATE":Yn().parse(t.input),Be.setInitialStateOperation(e.global,t);break;case"ADD_STATE_EXAMPLE":Ln().parse(t.input),Be.addStateExampleOperation(e.global,t);break;case"UPDATE_STATE_EXAMPLE":_r().parse(t.input),Be.updateStateExampleOperation(e.global,t);break;case"DELETE_STATE_EXAMPLE":Wn().parse(t.input),Be.deleteStateExampleOperation(e.global,t);break;case"REORDER_STATE_EXAMPLES":Kn().parse(t.input),Be.reorderStateExamplesOperation(e.global,t);break;default:return e}},Er=Tn(Ms),Ns=(e,t)=>Fi(e,t),zs=e=>$i(e,Er),Sr=e=>({...$t(),global:{...xs,...e?.global??{}},local:{...Os,...e?.local??{}}});function Ps(){return{...$t(),author:{name:"",website:""},description:"",extension:"",id:"",name:"",specifications:[]}}function Ls(){return{}}function Us(e){return{...Ps(),...e||{}}}function js(e){return{...Ls()}}function Bs(e,t,n){return{...So(e?.auth,e?.document),global:Us(t),local:js()}}function Fs(e){const t=bn(Sr,e);return t.header.documentType=br,t}const $s=e=>ks(e),Ws=e=>{Ts(e)},Hs=e=>Ds(e),Zs=e=>{Cs(e)},Gs={fileExtension:ws,createState:Sr,createDocument:Fs,loadFromInput:zs,saveToFileHandle:Ns,isStateOfType:$s,assertIsStateOfType:Ws,isDocumentOfType:Hs,assertIsDocumentOfType:Zs},pa={reducer:Er,documentModel:Bs($t(),vs),actions:Ss,utils:Gs},Vs=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Xs=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Ks=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Js=/[^\p{L}\d]+/giu,nn="$1\0$2",rn="";function wr(e){let t=e.trim();t=t.replace(Vs,nn).replace(Xs,nn),t=t.replace(Js,"\0");let n=0,r=t.length;for(;t.charAt(n)==="\0";)n++;if(n===r)return[];for(;t.charAt(r-1)==="\0";)r--;return t.slice(n,r).split(/\0/g)}function qs(e){const t=wr(e);for(let n=0;n<t.length;n++){const r=t[n],i=Ks.exec(r);if(i){const s=i.index+(i[1]??i[2]).length;t.splice(n,1,r.slice(0,s),r.slice(s))}}return t}function Ys(e,t){const[n,r,i]=nt(e,t);return n+r.map(bt(t?.locale)).join(t?.delimiter??" ")+i}function on(e,t){const[n,r,i]=nt(e,t),s=bt(t?.locale),l=yt(t?.locale),o=t?.mergeAmbiguousCharacters?Wt(s,l):Qs(s,l);return n+r.map(o).join(t?.delimiter??"")+i}function da(e,t){const[n,r,i]=nt(e,t),s=bt(t?.locale),l=yt(t?.locale);return n+r.map(Wt(s,l)).join(" ")+i}function fa(e,t){const[n,r,i]=nt(e,t);return n+r.map(yt(t?.locale)).join("_")+i}function ha(e,t){const[n,r,i]=nt(e,t),s=bt(t?.locale),l=yt(t?.locale),o=Wt(s,l);return n+r.map((u,d)=>d===0?o(u):s(u)).join(" ")+i}function ma(e,t){return Ys(e,{delimiter:"_",...t})}function bt(e){return e===!1?t=>t.toLowerCase():t=>t.toLocaleLowerCase(e)}function yt(e){return e===!1?t=>t.toUpperCase():t=>t.toLocaleUpperCase(e)}function Wt(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function Qs(e,t){return(n,r)=>{const i=n[0];return(r>0&&i>="0"&&i<="9"?"_"+i:t(i))+e(n.slice(1))}}function nt(e,t={}){const n=t.split??(t.separateNumbers?qs:wr),r=t.prefixCharacters??rn,i=t.suffixCharacters??rn;let s=0,l=e.length;for(;s<e.length;){const o=e.charAt(s);if(!r.includes(o))break;s++}for(;l>s;){const o=l-1,u=e.charAt(o);if(!i.includes(u))break;l=o}return[e.slice(0,s),n(e.slice(s,l)),e.slice(l)]}function ga(e,t=!1){const n=[];if(t&&e==="")return n;try{const r=JSON.parse(e);!t&&!Object.keys(r).length&&n.push({message:"Initial state cannot be empty",details:{initialState:e}})}catch{n.push({message:"Invalid initial state",details:{initialState:e}})}return n}function _a(e,t,n="",r=!0){const i=[];if(!r&&!e)return i.push({message:"State schema is required",details:{schema:e}}),i;if(r&&!e)return i;const s=`type ${on(t)}${on(n)}State`;return e.includes(s)||i.push({message:`Invalid state schema name. Expected ${s}`,details:{schema:e}}),i}function ba(e){const t=[];e.length||t.push({message:"Modules are required",details:{modules:e}});const n=e.reduce((r,i)=>[...r,...ea(i)],[]);return[...t,...n]}function ea(e){const t=[];e.name||t.push({message:"Module name is required",details:{module:e}}),e.operations.length||t.push({message:"Module operations are required",details:{module:e}});const n=e.operations.reduce((r,i)=>[...r,...ta(i)],[]);return[...t,...n]}function ta(e){const t=[];return e.name||t.push({message:"Operation name is required",details:{operation:e}}),e.schema||t.push({message:"Operation schema is required",details:{operation:e}}),t}export{Bi as $,lt as A,As as B,ma as C,fa as D,ha as E,No as F,ls as G,zo as H,Lo as I,Po as J,Uo as K,jo as L,us as M,Bo as N,Fo as O,Wo as P,Go as Q,Xo as R,Ko as S,Qo as T,ts as U,ss as V,rs as W,Zo as X,da as Y,ia as Z,br as _,Tn as a,ga as a0,_a as a1,ba as a2,di as a3,pi as a4,Ss as a5,pa as a6,Is as b,oe as c,Fi as d,$i as e,bn as f,Dt as g,$t as h,_n as i,Bs as j,xi as k,Ct as l,ua as m,Re as n,aa as o,on as p,la as q,ca as r,Te as s,Ri as t,dt as u,oa as v,yn as w,Di as x,Ni as y,sa as z};
|