@powerhousedao/connect 6.0.0-dev.36 → 6.0.0-dev.38
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-CbbhwoK5.js → AddDriveModal-DQFXtw_S.js} +1 -1
- package/dist/assets/{ClearStorageModal-D9ImX_Y2.js → ClearStorageModal-Bn6Hs4x2.js} +1 -1
- package/dist/assets/{CookiesPolicyModal-DZyR4I6Q.js → CookiesPolicyModal-CJm7uquv.js} +1 -1
- package/dist/assets/{CreateDocumentModal-cuFCUL54.js → CreateDocumentModal-B9wNM9gh.js} +1 -1
- package/dist/assets/{DebugSettingsModal-VZC-kyV4.js → DebugSettingsModal-DS0GlMhY.js} +1 -1
- package/dist/assets/{DeleteDriveModal-CZ8ybNGd.js → DeleteDriveModal-Vqn89DDe.js} +1 -1
- package/dist/assets/{DeleteItemModal-C4TMzdIM.js → DeleteItemModal-DhEB9XC0.js} +1 -1
- package/dist/assets/DisclaimerModal-KImr4tMa.js +1 -0
- package/dist/assets/{DriveSettingsModal-CZUaaimi.js → DriveSettingsModal-D7fhWStQ.js} +1 -1
- package/dist/assets/{ExportDocumentWithErrorsModal-DGqH3ZUh.js → ExportDocumentWithErrorsModal-BfVDLSe2.js} +1 -1
- package/dist/assets/{SettingsModal-BAwPX5lx.js → SettingsModal-Bw1yhjJE.js} +1 -1
- package/dist/assets/UpgradeDriveModal-TdAM-Nv_.js +1 -0
- package/dist/assets/{design_system-2B9-gBoy.js → design_system-gRtxS73S.js} +1 -1
- package/dist/assets/{design_system_connect-BDSRzEbz.js → design_system_connect-BM4udPUI.js} +35 -35
- package/dist/assets/{design_system_ui-DfgQWIF6.js → design_system_ui-DDBl0KT-.js} +1 -1
- package/dist/assets/document_drive-CDoSbU60.js +132 -0
- package/dist/assets/{document_engineering-Ml4bCoxs.js → document_engineering-DrHxNTED.js} +1 -1
- package/dist/assets/{document_model-DxDgOZQk.js → document_model-Dc-BTYKH.js} +6 -6
- package/dist/assets/{document_model_editor-HMgNrWzH.js → document_model_editor-8Rt5FvRZ.js} +4 -4
- package/dist/assets/{drive_explorer-Ci_KsiFF.js → drive_explorer-CZKd_9V_.js} +2 -2
- package/dist/assets/{graphql-editor-D6R-QKan.js → graphql-editor-CbCCBvWl.js} +1 -1
- package/dist/assets/{hooks-BAkpcESF.js → hooks-gkbkNyXc.js} +1 -1
- package/dist/assets/{index-Cunlfu9j.js → index-Cy9Y2XiY.js} +2 -2
- package/dist/assets/{index-Do-t7JyC.js → index-_nvp47tf.js} +3 -3
- package/dist/assets/{json-editor-Bmu8AdkO.js → json-editor-Ddm55-9U.js} +1 -1
- package/dist/assets/nodefs-abWu13w1.js +1 -0
- package/dist/assets/{opfs-ahp-W4_dEVA8.js → opfs-ahp-CNCCHAfx.js} +1 -1
- package/dist/assets/{reactor_browser-DKT7DitQ.js → reactor_browser-DABkDW8h.js} +15 -15
- package/dist/assets/{state-schemas-CGHq7g1z.js → state-schemas-CnulJXFp.js} +2 -2
- package/dist/index.html +9 -9
- package/lib/package.copy.json +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.copy.json +1 -1
- package/package.json +10 -10
- package/dist/assets/DisclaimerModal-C5IAgg0F.js +0 -1
- package/dist/assets/UpgradeDriveModal-CqiN9g24.js +0 -1
- package/dist/assets/document_drive-CDMxtf9f.js +0 -132
- package/dist/assets/nodefs-DzwRvn5F.js +0 -1
- package/dist/assets/rwa-report-Bb0W5-ac.png +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a,S as $t,d as qt,u as Ce,P as ee,c as pe,e as Ze,f as Bt,C as Kt,a as Ht}from"./document_model_editor-HMgNrWzH.js";import{r as l,a as G}from"./sentry_react-cODD7zWc.js";import{c as m,a as Je,f as Te,P as he,d as Qe,e as ae,E as Gt,I as V,u as ne,F as Ut,G as Wt,O as Xt,H as Zt,b as Ye,R as Jt,A as et,g as Qt,J as Yt,K as er,L as tr,N as rr,Q as ar,D as nr,C as sr,i as or}from"./design_system-2B9-gBoy.js";import{R as lr,T as ir,P as dr,C as cr,a as Ie,u as ur,b as fr}from"./design_system_connect-BDSRzEbz.js";import{t as gr}from"./tailwind_merge-Dr4f9Rms.js";const pr=qt(m("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"}}),hr=l.forwardRef(({variant:e,className:t,asChild:r=!1,...o},n)=>{const s=r?$t:"button";return a.jsx(s,{className:m(pr({variant:e,className:t})),ref:n,...o})});function mr(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var je="Checkbox",[xr]=Je(je),[vr,Le]=xr(je);function br(e){const{__scopeCheckbox:t,checked:r,children:o,defaultChecked:n,disabled:s,form:c,name:i,onCheckedChange:f,required:d,value:g="on",internal_do_not_use_render:h}=e,[y,v]=Qe({prop:r,defaultProp:n??!1,onChange:f,caller:je}),[N,P]=l.useState(null),[b,j]=l.useState(null),k=l.useRef(!1),$=N?!!c||!!N.closest("form"):!0,T={checked:y,disabled:s,setChecked:v,control:N,setControl:P,name:i,form:c,value:g,hasConsumerStoppedPropagationRef:k,required:d,defaultChecked:Y(n)?!1:n,isFormControl:$,bubbleInput:b,setBubbleInput:j};return a.jsx(vr,{scope:t,...T,children:yr(h)?h(T):o})}var tt="CheckboxTrigger",rt=l.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...o},n)=>{const{control:s,value:c,disabled:i,checked:f,required:d,setControl:g,setChecked:h,hasConsumerStoppedPropagationRef:y,isFormControl:v,bubbleInput:N}=Le(tt,e),P=Ce(n,g),b=l.useRef(f);return l.useEffect(()=>{const j=s?.form;if(j){const k=()=>h(b.current);return j.addEventListener("reset",k),()=>j.removeEventListener("reset",k)}},[s,h]),a.jsx(he.button,{type:"button",role:"checkbox","aria-checked":Y(f)?"mixed":f,"aria-required":d,"data-state":it(f),"data-disabled":i?"":void 0,disabled:i,value:c,...o,ref:P,onKeyDown:ae(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:ae(r,j=>{h(k=>Y(k)?!0:!k),N&&v&&(y.current=j.isPropagationStopped(),y.current||j.stopPropagation())})})});rt.displayName=tt;var at=l.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:o,checked:n,defaultChecked:s,required:c,disabled:i,value:f,onCheckedChange:d,form:g,...h}=e;return a.jsx(br,{__scopeCheckbox:r,checked:n,defaultChecked:s,disabled:i,required:c,onCheckedChange:d,name:o,form:g,value:f,internal_do_not_use_render:({isFormControl:y})=>a.jsxs(a.Fragment,{children:[a.jsx(rt,{...h,ref:t,__scopeCheckbox:r}),y&&a.jsx(lt,{__scopeCheckbox:r})]})})});at.displayName=je;var nt="CheckboxIndicator",st=l.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:o,...n}=e,s=Le(nt,r);return a.jsx(Te,{present:o||Y(s.checked)||s.checked===!0,children:a.jsx(he.span,{"data-state":it(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:t,style:{pointerEvents:"none",...e.style}})})});st.displayName=nt;var ot="CheckboxBubbleInput",lt=l.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:o,hasConsumerStoppedPropagationRef:n,checked:s,defaultChecked:c,required:i,disabled:f,name:d,value:g,form:h,bubbleInput:y,setBubbleInput:v}=Le(ot,e),N=Ce(r,v),P=mr(s),b=Gt(o);l.useEffect(()=>{const k=y;if(!k)return;const $=window.HTMLInputElement.prototype,O=Object.getOwnPropertyDescriptor($,"checked").set,R=!n.current;if(P!==s&&O){const A=new Event("click",{bubbles:R});k.indeterminate=Y(s),O.call(k,Y(s)?!1:s),k.dispatchEvent(A)}},[y,P,s,n]);const j=l.useRef(Y(s)?!1:s);return a.jsx(he.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??j.current,required:i,disabled:f,name:d,value:g,form:h,...t,tabIndex:-1,ref:N,style:{...t.style,...b,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});lt.displayName=ot;function yr(e){return typeof e=="function"}function Y(e){return e==="indeterminate"}function it(e){return Y(e)?"indeterminate":e?"checked":"unchecked"}const dt=l.forwardRef(({className:e,checked:t,invalid:r,...o},n)=>a.jsx(at,{ref:n,className:m("peer size-4 shrink-0 rounded","border-input border shadow-sm shadow-black/[.04]","ring-offset-background transition-shadow","focus-visible:border-ring focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:border-gray-700 disabled:data-[invalid=false]:data-[state=checked]:bg-gray-700 disabled:data-[invalid=false]:data-[state=indeterminate]:bg-gray-700 dark:disabled:data-[invalid=false]:data-[state=checked]:bg-gray-500 dark:disabled:data-[invalid=false]:data-[state=indeterminate]:bg-gray-500","data-[state]:border-gray-700 dark:data-[state]:border-gray-500","data-[state=checked]:bg-gray-900 data-[state=indeterminate]:bg-gray-900 dark:data-[state=checked]:bg-gray-400 dark:data-[state=indeterminate]:bg-gray-400","data-[state=checked]:text-slate-50 data-[state=indeterminate]:text-slate-50 dark:data-[state=checked]:text-gray-900 dark:data-[state=indeterminate]:text-gray-900",!o.disabled&&["group-hover:border-gray-900 data-[state=checked]:group-hover:bg-gray-900 data-[state=indeterminate]:group-hover:bg-gray-900","dark:group-hover:border-slate-50 dark:data-[state=checked]:group-hover:bg-slate-50 dark:data-[state=indeterminate]:group-hover:bg-slate-50"],"data-[invalid=true]:data-[state]:!border-red-800 data-[invalid=true]:data-[state=checked]:!bg-red-800 data-[invalid=true]:data-[state=indeterminate]:!bg-red-800","dark:data-[invalid=true]:data-[state]:!border-red-800 dark:data-[invalid=true]:data-[state=checked]:!bg-red-800 dark:data-[invalid=true]:data-[state=indeterminate]:!bg-red-800","data-[invalid=true]:group-hover:!border-red-900 data-[invalid=true]:data-[state=checked]:group-hover:!bg-red-900 data-[invalid=true]:data-[state=indeterminate]:group-hover:!bg-red-900",e),checked:t,"data-invalid":r,...o,children:a.jsx(st,{className:"flex items-center justify-center text-current",children:t==="indeterminate"?a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 9 9",fill:"currentcolor",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.75 4.5C0.75 4.08579 1.08579 3.75 1.5 3.75H7.5C7.91421 3.75 8.25 4.08579 8.25 4.5C8.25 4.91421 7.91421 5.25 7.5 5.25H1.5C1.08579 5.25 0.75 4.91421 0.75 4.5Z"})}):t?a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 9 9",fill:"currentcolor",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.53547 0.62293C8.88226 0.849446 8.97976 1.3142 8.75325 1.66099L4.5083 8.1599C4.38833 8.34356 4.19397 8.4655 3.9764 8.49358C3.75883 8.52167 3.53987 8.45309 3.3772 8.30591L0.616113 5.80777C0.308959 5.52987 0.285246 5.05559 0.563148 4.74844C0.84105 4.44128 1.31533 4.41757 1.62249 4.69547L3.73256 6.60459L7.49741 0.840706C7.72393 0.493916 8.18868 0.396414 8.53547 0.62293Z"})}):null})}));dt.displayName="CheckboxBase";const kr=l.forwardRef(({children:e,className:t,...r},o)=>a.jsx(cr,{ref:o,...r,className:m("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})),Oe=({content:e,children:t,triggerAsChild:r=!1,delayDuration:o=0,...n})=>{const{open:s,defaultOpen:c,onOpenChange:i,...f}=n;return a.jsxs(lr,{defaultOpen:c,delayDuration:o,onOpenChange:i,open:s,children:[a.jsx(ir,{asChild:r,type:r?void 0:"button",children:t}),a.jsx(dr,{children:a.jsx(kr,{sideOffset:3,...f,children:e})})]})},Me=({children:e,required:t,disabled:r,description:o,hasError:n,inline:s,className:c,...i})=>{const f=m("inline-flex items-center text-sm font-medium",s?"leading-[22px]":"leading-4",`text-gray-900 ${s?"dark:text-gray-400":"dark:text-gray-50"}`,n&&"group-hover:!text-red-900 dark:group-hover:!text-red-900",n&&s&&"text-red-800 dark:text-red-800",n&&!s&&"text-red-900 dark:text-red-900",r&&`cursor-not-allowed text-gray-700 ${s?"dark:text-gray-600":"dark:text-gray-300"}`,s?!r&&"group-hover:text-gray-900 dark:group-hover:text-slate-50":"mb-[3px]",c);if(!e)return null;const d={...i};return a.jsxs("label",{className:f,...d,children:[e,t&&a.jsx("span",{className:m("ml-1 text-gray-800 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-slate-50",n&&`${s?"!text-red-800":"!text-red-900"} group-hover:!text-red-900`),children:"*"}),o&&a.jsx(Ie,{children:a.jsx(Oe,{content:o,children:a.jsx(V,{name:"CircleInfo",size:16,className:m("ml-1 cursor-pointer text-gray-600 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-500",r&&"text-gray-500")})})})]})},Cr="p",He=({children:e,type:t="info",as:r,className:o,...n})=>{const s=r||Cr,i=m("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],o);return a.jsx(s,{"data-type":t,className:i,...n,children:e})},de=({messages:e,type:t="info",className:r,...o})=>{if(e.length===0)return null;if(e.length===1)return a.jsx(He,{type:t,...o,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:m("flex flex-col gap-1",r),...o,children:e.map(s=>a.jsx(He,{as:"li",type:t,className:m("relative pl-4","before:absolute before:left-0 before:top-[0.4em] before:size-2 before:rounded-full",n[t]),children:s},s))})},jr=G.forwardRef(({id:e,name:t,label:r,value:o,defaultValue:n,disabled:s,required:c,description:i,errors:f,warnings:d,onChange:g,className:h,...y},v)=>{const N=l.useId(),P=e??N,b=!!f?.length,j=k=>k==="true"?!0:k==="false"?!1:k;return a.jsxs("div",{className:m("flex flex-col gap-2"),children:[a.jsxs("div",{className:m("group flex items-center space-x-2",h),children:[a.jsx(dt,{id:P,name:t,checked:j(o??n),disabled:s,onCheckedChange:g,required:c,invalid:b,"aria-invalid":b,ref:v,...y}),a.jsx(Me,{htmlFor:P,required:c,disabled:s,hasError:b,description:i,className:m(!s&&"group-hover:cursor-pointer"),inline:!0,children:r})]}),d&&a.jsx(de,{type:"warning",messages:d}),f&&a.jsx(de,{type:"error",messages:f})]})});jr.displayName="Checkbox";var Ge=1,wr=.9,Nr=.8,Rr=.17,Ee=.1,Se=.999,Er=.9999,Sr=.99,Pr=/[\\\/_+.#"@\[\(\{&]/,Ar=/[\\\/_+.#"@\[\(\{&]/g,Ir=/[\s-]/,ct=/[\s-]/g;function De(e,t,r,o,n,s,c){if(s===t.length)return n===e.length?Ge:Sr;var i=`${n},${s}`;if(c[i]!==void 0)return c[i];for(var f=o.charAt(s),d=r.indexOf(f,n),g=0,h,y,v,N;d>=0;)h=De(e,t,r,o,d+1,s+1,c),h>g&&(d===n?h*=Ge:Pr.test(e.charAt(d-1))?(h*=Nr,v=e.slice(n,d-1).match(Ar),v&&n>0&&(h*=Math.pow(Se,v.length))):Ir.test(e.charAt(d-1))?(h*=wr,N=e.slice(n,d-1).match(ct),N&&n>0&&(h*=Math.pow(Se,N.length))):(h*=Rr,n>0&&(h*=Math.pow(Se,d-n))),e.charAt(d)!==t.charAt(s)&&(h*=Er)),(h<Ee&&r.charAt(d-1)===o.charAt(s+1)||o.charAt(s+1)===o.charAt(s)&&r.charAt(d-1)!==o.charAt(s))&&(y=De(e,t,r,o,d+1,s+2,c),y*Ee>h&&(h=y*Ee)),h>g&&(g=h),d=r.indexOf(f,d+1);return c[i]=g,g}function Ue(e){return e.toLowerCase().replace(ct," ")}function Or(e,t,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,De(e,t,Ue(e),Ue(t),0,0,{})}var fe='[cmdk-group=""]',Pe='[cmdk-group-items=""]',Dr='[cmdk-group-heading=""]',ut='[cmdk-item=""]',We=`${ut}:not([aria-disabled="true"])`,Fe="cmdk-item-select",le="data-value",Fr=(e,t,r)=>Or(e,t,r),ft=l.createContext(void 0),me=()=>l.useContext(ft),gt=l.createContext(void 0),ze=()=>l.useContext(gt),pt=l.createContext(void 0),ht=l.forwardRef((e,t)=>{let r=ie(()=>{var u,C;return{search:"",value:(C=(u=e.value)!=null?u:e.defaultValue)!=null?C:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),o=ie(()=>new Set),n=ie(()=>new Map),s=ie(()=>new Map),c=ie(()=>new Set),i=mt(e),{label:f,children:d,value:g,onValueChange:h,filter:y,shouldFilter:v,loop:N,disablePointerSelection:P=!1,vimBindings:b=!0,...j}=e,k=ne(),$=ne(),T=ne(),O=l.useRef(null),R=Hr();se(()=>{if(g!==void 0){let u=g.trim();r.current.value=u,A.emit()}},[g]),se(()=>{R(6,w)},[]);let A=l.useMemo(()=>({subscribe:u=>(c.current.add(u),()=>c.current.delete(u)),snapshot:()=>r.current,setState:(u,C,x)=>{var p,E,S,F;if(!Object.is(r.current[u],C)){if(r.current[u]=C,u==="search")U(),I(),R(1,q);else if(u==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let _=document.getElementById(T);_?_.focus():(p=document.getElementById(k))==null||p.focus()}if(R(7,()=>{var _;r.current.selectedItemId=(_=D())==null?void 0:_.id,A.emit()}),x||R(5,w),((E=i.current)==null?void 0:E.value)!==void 0){let _=C??"";(F=(S=i.current).onValueChange)==null||F.call(S,_);return}}A.emit()}},emit:()=>{c.current.forEach(u=>u())}}),[]),L=l.useMemo(()=>({value:(u,C,x)=>{var p;C!==((p=s.current.get(u))==null?void 0:p.value)&&(s.current.set(u,{value:C,keywords:x}),r.current.filtered.items.set(u,M(C,x)),R(2,()=>{I(),A.emit()}))},item:(u,C)=>(o.current.add(u),C&&(n.current.has(C)?n.current.get(C).add(u):n.current.set(C,new Set([u]))),R(3,()=>{U(),I(),r.current.value||q(),A.emit()}),()=>{s.current.delete(u),o.current.delete(u),r.current.filtered.items.delete(u);let x=D();R(4,()=>{U(),x?.getAttribute("id")===u&&q(),A.emit()})}),group:u=>(n.current.has(u)||n.current.set(u,new Set),()=>{s.current.delete(u),n.current.delete(u)}),filter:()=>i.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:k,inputId:T,labelId:$,listInnerRef:O}),[]);function M(u,C){var x,p;let E=(p=(x=i.current)==null?void 0:x.filter)!=null?p:Fr;return u?E(u,r.current.search,C):0}function I(){if(!r.current.search||i.current.shouldFilter===!1)return;let u=r.current.filtered.items,C=[];r.current.filtered.groups.forEach(p=>{let E=n.current.get(p),S=0;E.forEach(F=>{let _=u.get(F);S=Math.max(_,S)}),C.push([p,S])});let x=O.current;B().sort((p,E)=>{var S,F;let _=p.getAttribute("id"),X=E.getAttribute("id");return((S=u.get(X))!=null?S:0)-((F=u.get(_))!=null?F:0)}).forEach(p=>{let E=p.closest(Pe);E?E.appendChild(p.parentElement===E?p:p.closest(`${Pe} > *`)):x.appendChild(p.parentElement===x?p:p.closest(`${Pe} > *`))}),C.sort((p,E)=>E[1]-p[1]).forEach(p=>{var E;let S=(E=O.current)==null?void 0:E.querySelector(`${fe}[${le}="${encodeURIComponent(p[0])}"]`);S?.parentElement.appendChild(S)})}function q(){let u=B().find(x=>x.getAttribute("aria-disabled")!=="true"),C=u?.getAttribute(le);A.setState("value",C||void 0)}function U(){var u,C,x,p;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=o.current.size;return}r.current.filtered.groups=new Set;let E=0;for(let S of o.current){let F=(C=(u=s.current.get(S))==null?void 0:u.value)!=null?C:"",_=(p=(x=s.current.get(S))==null?void 0:x.keywords)!=null?p:[],X=M(F,_);r.current.filtered.items.set(S,X),X>0&&E++}for(let[S,F]of n.current)for(let _ of F)if(r.current.filtered.items.get(_)>0){r.current.filtered.groups.add(S);break}r.current.filtered.count=E}function w(){var u,C,x;let p=D();p&&(((u=p.parentElement)==null?void 0:u.firstChild)===p&&((x=(C=p.closest(fe))==null?void 0:C.querySelector(Dr))==null||x.scrollIntoView({block:"nearest"})),p.scrollIntoView({block:"nearest"}))}function D(){var u;return(u=O.current)==null?void 0:u.querySelector(`${ut}[aria-selected="true"]`)}function B(){var u;return Array.from(((u=O.current)==null?void 0:u.querySelectorAll(We))||[])}function W(u){let C=B()[u];C&&A.setState("value",C.getAttribute(le))}function J(u){var C;let x=D(),p=B(),E=p.findIndex(F=>F===x),S=p[E+u];(C=i.current)!=null&&C.loop&&(S=E+u<0?p[p.length-1]:E+u===p.length?p[0]:p[E+u]),S&&A.setState("value",S.getAttribute(le))}function z(u){let C=D(),x=C?.closest(fe),p;for(;x&&!p;)x=u>0?Br(x,fe):Kr(x,fe),p=x?.querySelector(We);p?A.setState("value",p.getAttribute(le)):J(u)}let K=()=>W(B().length-1),re=u=>{u.preventDefault(),u.metaKey?K():u.altKey?z(1):J(1)},oe=u=>{u.preventDefault(),u.metaKey?W(0):u.altKey?z(-1):J(-1)};return l.createElement(ee.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:u=>{var C;(C=j.onKeyDown)==null||C.call(j,u);let x=u.nativeEvent.isComposing||u.keyCode===229;if(!(u.defaultPrevented||x))switch(u.key){case"n":case"j":{b&&u.ctrlKey&&re(u);break}case"ArrowDown":{re(u);break}case"p":case"k":{b&&u.ctrlKey&&oe(u);break}case"ArrowUp":{oe(u);break}case"Home":{u.preventDefault(),W(0);break}case"End":{u.preventDefault(),K();break}case"Enter":{u.preventDefault();let p=D();if(p){let E=new Event(Fe);p.dispatchEvent(E)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:L.inputId,id:L.labelId,style:Ur},f),we(e,u=>l.createElement(gt.Provider,{value:A},l.createElement(ft.Provider,{value:L},u))))}),_r=l.forwardRef((e,t)=>{var r,o;let n=ne(),s=l.useRef(null),c=l.useContext(pt),i=me(),f=mt(e),d=(o=(r=f.current)==null?void 0:r.forceMount)!=null?o:c?.forceMount;se(()=>{if(!d)return i.item(n,c?.id)},[d]);let g=xt(n,s,[e.value,e.children,s],e.keywords),h=ze(),y=Q(R=>R.value&&R.value===g.current),v=Q(R=>d||i.filter()===!1?!0:R.search?R.filtered.items.get(n)>0:!0);l.useEffect(()=>{let R=s.current;if(!(!R||e.disabled))return R.addEventListener(Fe,N),()=>R.removeEventListener(Fe,N)},[v,e.onSelect,e.disabled]);function N(){var R,A;P(),(A=(R=f.current).onSelect)==null||A.call(R,g.current)}function P(){h.setState("value",g.current,!0)}if(!v)return null;let{disabled:b,value:j,onSelect:k,forceMount:$,keywords:T,...O}=e;return l.createElement(ee.div,{ref:pe(s,t),...O,id:n,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!y,"data-disabled":!!b,"data-selected":!!y,onPointerMove:b||i.getDisablePointerSelection()?void 0:P,onClick:b?void 0:N},e.children)}),Tr=l.forwardRef((e,t)=>{let{heading:r,children:o,forceMount:n,...s}=e,c=ne(),i=l.useRef(null),f=l.useRef(null),d=ne(),g=me(),h=Q(v=>n||g.filter()===!1?!0:v.search?v.filtered.groups.has(c):!0);se(()=>g.group(c),[]),xt(c,i,[e.value,e.heading,f]);let y=l.useMemo(()=>({id:c,forceMount:n}),[n]);return l.createElement(ee.div,{ref:pe(i,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},r&&l.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:d},r),we(e,v=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?d:void 0},l.createElement(pt.Provider,{value:y},v))))}),Lr=l.forwardRef((e,t)=>{let{alwaysRender:r,...o}=e,n=l.useRef(null),s=Q(c=>!c.search);return!r&&!s?null:l.createElement(ee.div,{ref:pe(n,t),...o,"cmdk-separator":"",role:"separator"})}),Mr=l.forwardRef((e,t)=>{let{onValueChange:r,...o}=e,n=e.value!=null,s=ze(),c=Q(d=>d.search),i=Q(d=>d.selectedItemId),f=me();return l.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),l.createElement(ee.input,{ref:t,...o,"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:c,onChange:d=>{n||s.setState("search",d.target.value),r?.(d.target.value)}})}),zr=l.forwardRef((e,t)=>{let{children:r,label:o="Suggestions",...n}=e,s=l.useRef(null),c=l.useRef(null),i=Q(d=>d.selectedItemId),f=me();return l.useEffect(()=>{if(c.current&&s.current){let d=c.current,g=s.current,h,y=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let v=d.offsetHeight;g.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return y.observe(d),()=>{cancelAnimationFrame(h),y.unobserve(d)}}},[]),l.createElement(ee.div,{ref:pe(s,t),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":o,id:f.listId},we(e,d=>l.createElement("div",{ref:pe(c,f.listInnerRef),"cmdk-list-sizer":""},d)))}),Vr=l.forwardRef((e,t)=>{let{open:r,onOpenChange:o,overlayClassName:n,contentClassName:s,container:c,...i}=e;return l.createElement(Ut,{open:r,onOpenChange:o},l.createElement(Wt,{container:c},l.createElement(Xt,{"cmdk-overlay":"",className:n}),l.createElement(Zt,{"aria-label":e.label,"cmdk-dialog":"",className:s},l.createElement(ht,{ref:t,...i}))))}),$r=l.forwardRef((e,t)=>Q(r=>r.filtered.count===0)?l.createElement(ee.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),qr=l.forwardRef((e,t)=>{let{progress:r,children:o,label:n="Loading...",...s}=e;return l.createElement(ee.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},we(e,c=>l.createElement("div",{"aria-hidden":!0},c)))}),H=Object.assign(ht,{List:zr,Item:_r,Input:Mr,Group:Tr,Separator:Lr,Dialog:Vr,Empty:$r,Loading:qr});function Br(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function Kr(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function mt(e){let t=l.useRef(e);return se(()=>{t.current=e}),t}var se=typeof window>"u"?l.useEffect:l.useLayoutEffect;function ie(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Q(e){let t=ze(),r=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,r,r)}function xt(e,t,r,o=[]){let n=l.useRef(),s=me();return se(()=>{var c;let i=(()=>{var d;for(let g of r){if(typeof g=="string")return g.trim();if(typeof g=="object"&&"current"in g)return g.current?(d=g.current.textContent)==null?void 0:d.trim():n.current}})(),f=o.map(d=>d.trim());s.value(e,i,f),(c=t.current)==null||c.setAttribute(le,i),n.current=i}),n}var Hr=()=>{let[e,t]=l.useState(),r=ie(()=>new Map);return se(()=>{r.current.forEach(o=>o()),r.current=new Map},[e]),(o,n)=>{r.current.set(o,n),t({})}};function Gr(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function we({asChild:e,children:t},r){return e&&l.isValidElement(t)?l.cloneElement(Gr(t),{ref:t.ref},r(t.props.children)):r(t)}var Ur={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const vt=G.forwardRef(({className:e,...t},r)=>a.jsx(H,{ref:r,className:m("flex size-full flex-col rounded-md [&_[cmdk-label]]:hidden",e),...t}));vt.displayName=H.displayName;const bt=G.forwardRef(({wrapperClassName:e,className:t,...r},o)=>a.jsxs("div",{className:m("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(V,{name:"Search",size:16,className:m("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(H.Input,{ref:o,className:m("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})]}));bt.displayName=H.Input.displayName;const Ve=G.forwardRef(({className:e,...t},r)=>a.jsx(H.List,{ref:r,className:m("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}));Ve.displayName=H.List.displayName;const Wr=G.forwardRef((e,t)=>a.jsx(H.Loading,{ref:t,...e}));Wr.displayName=H.Loading.displayName;const $e=G.forwardRef((e,t)=>a.jsx(H.Empty,{ref:t,...e}));$e.displayName=H.Empty.displayName;const ye=G.forwardRef(({className:e,...t},r)=>a.jsx(H.Group,{ref:r,className:m("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}));ye.displayName=H.Group.displayName;const Ne=G.forwardRef(({className:e,...t},r)=>a.jsx(H.Item,{ref:r,className:m("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}));Ne.displayName=H.Item.displayName;function ge(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((o,n)=>ge(o,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 o=Object.keys(e),n=Object.keys(t);return o.length===n.length&&o.every(s=>s in t&&ge(e[s],t[s],r))}return!1}const ke={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}})},Xr=(e,t)=>l.forwardRef(({value:r,name:o,showErrorOnBlur:n,showErrorOnChange:s,validators:c,...i},f)=>{const{onChange:d,onBlur:g}=i,{control:h,formState:{errors:y,defaultValues:v},trigger:N,setValue:P,getValues:b}=Ze(),{submitCount:j}=Bt();if(!o)throw new Error(`[Field: ${e.displayName}] The name prop is required.`);const k=[...y[o]?.types?Object.values(y[o].types??[]):[]];k.length===0&&y[o]&&k.push("Invalid value"),l.useEffect(()=>{j>0&&N(o)},[i.required]),l.useEffect(()=>{i.errors&&i.errors.length>0&&N(o)},[o,i.errors,N]);const[$,T]=l.useState(!1);return l.useEffect(()=>{$&&P(o,r),T(!0)},[o,r]),r!==void 0&&!d&&console.warn(`[Field: ${o}] Value prop provided without onChange so it will be ignored. Use disabled/readOnly if you want to prevent changes.`),a.jsx(Kt,{control:h,name:o,defaultValue:r??i.defaultValue,disabled:i.disabled,render:({field:{onChange:O,onBlur:R,value:A,...L}})=>{const M=l.useCallback(w=>{n?N(o):R(),g&&g(w)},[R,n]),I=l.useCallback(w=>{if(d)Object.hasOwn(w,"target")?P(o,w.target.value):P(o,w),d(w);else{let D=w;(w instanceof Event||w.target instanceof HTMLElement)&&(D=w.target.value),P(o,D)}s===void 0&&n===void 0?j>0&&N(o):s&&N(o)},[A,s,n,j]),{ref:q}=L,U=w=>{typeof f=="function"?f(w):f&&(f.current=w),q(w)};return a.jsx(e,{...i,...L,value:A,onBlur:M,onChange:I,errors:k,ref:U})},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((O,R)=>[`_propError${R}`,()=>O]):[]):{},...c!==void 0?Object.fromEntries((Array.isArray(c)?c:[c]).map((O,R)=>[`customValidation${R}`,O])):{}}}})}),yt=({children:e,as:t,className:r})=>{const o=t??"p";return a.jsx(o,{className:m("font-sans text-sm font-normal leading-5 text-gray-600 dark:text-gray-500",r),children:e})},kt=({children:e})=>a.jsx("div",{className:"flex flex-col gap-2",children:e});var Re="Popover",[Ct]=Je(Re,[Ye]),xe=Ye(),[Zr,te]=Ct(Re),jt=e=>{const{__scopePopover:t,children:r,open:o,defaultOpen:n,onOpenChange:s,modal:c=!1}=e,i=xe(t),f=l.useRef(null),[d,g]=l.useState(!1),[h,y]=Qe({prop:o,defaultProp:n??!1,onChange:s,caller:Re});return a.jsx(Jt,{...i,children:a.jsx(Zr,{scope:t,contentId:ne(),triggerRef:f,open:h,onOpenChange:y,onOpenToggle:l.useCallback(()=>y(v=>!v),[y]),hasCustomAnchor:d,onCustomAnchorAdd:l.useCallback(()=>g(!0),[]),onCustomAnchorRemove:l.useCallback(()=>g(!1),[]),modal:c,children:r})})};jt.displayName=Re;var wt="PopoverAnchor",Nt=l.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=te(wt,r),s=xe(r),{onCustomAnchorAdd:c,onCustomAnchorRemove:i}=n;return l.useEffect(()=>(c(),()=>i()),[c,i]),a.jsx(et,{...s,...o,ref:t})});Nt.displayName=wt;var Rt="PopoverTrigger",Et=l.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=te(Rt,r),s=xe(r),c=Ce(t,n.triggerRef),i=a.jsx(he.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":Ot(n.open),...o,ref:c,onClick:ae(e.onClick,n.onOpenToggle)});return n.hasCustomAnchor?i:a.jsx(et,{asChild:!0,...s,children:i})});Et.displayName=Rt;var qe="PopoverPortal",[Jr,Qr]=Ct(qe,{forceMount:void 0}),St=e=>{const{__scopePopover:t,forceMount:r,children:o,container:n}=e,s=te(qe,t);return a.jsx(Jr,{scope:t,forceMount:r,children:a.jsx(Te,{present:r||s.open,children:a.jsx(Qt,{asChild:!0,container:n,children:o})})})};St.displayName=qe;var ce="PopoverContent",Pt=l.forwardRef((e,t)=>{const r=Qr(ce,e.__scopePopover),{forceMount:o=r.forceMount,...n}=e,s=te(ce,e.__scopePopover);return a.jsx(Te,{present:o||s.open,children:s.modal?a.jsx(ea,{...n,ref:t}):a.jsx(ta,{...n,ref:t})})});Pt.displayName=ce;var Yr=tr("PopoverContent.RemoveScroll"),ea=l.forwardRef((e,t)=>{const r=te(ce,e.__scopePopover),o=l.useRef(null),n=Ce(t,o),s=l.useRef(!1);return l.useEffect(()=>{const c=o.current;if(c)return Yt(c)},[]),a.jsx(er,{as:Yr,allowPinchZoom:!0,children:a.jsx(At,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,c=>{c.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,c=>{const i=c.detail.originalEvent,f=i.button===0&&i.ctrlKey===!0,d=i.button===2||f;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:ae(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),ta=l.forwardRef((e,t)=>{const r=te(ce,e.__scopePopover),o=l.useRef(!1),n=l.useRef(!1);return a.jsx(At,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(o.current||r.triggerRef.current?.focus(),s.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(o.current=!0,s.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const c=s.target;r.triggerRef.current?.contains(c)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&n.current&&s.preventDefault()}})}),At=l.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:g,...h}=e,y=te(ce,r),v=xe(r);return rr(),a.jsx(ar,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,onUnmountAutoFocus:s,children:a.jsx(nr,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:g,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:d,onDismiss:()=>y.onOpenChange(!1),children:a.jsx(sr,{"data-state":Ot(y.open),role:"dialog",id:y.contentId,...v,...h,ref:t,style:{...h.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)"}})})})}),It="PopoverClose",ra=l.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=te(It,r);return a.jsx(he.button,{type:"button",...o,ref:t,onClick:ae(e.onClick,()=>n.onOpenChange(!1))})});ra.displayName=It;var aa="PopoverArrow",na=l.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=xe(r);return a.jsx(or,{...n,...o,ref:t})});na.displayName=aa;function Ot(e){return e?"open":"closed"}var sa=jt,oa=Nt,la=Et,ia=St,da=Pt;const Dt=sa,ca=oa,ua=la,Ft=G.forwardRef(({align:e="center",sideOffset:t=4,className:r,...o},n)=>a.jsx(ia,{children:a.jsx(da,{align:e,sideOffset:t,className:m(["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,...o})})),fa=e=>typeof e=="string"?a.jsx(V,{name:e,size:16,className:m("text-gray-700 dark:text-gray-400")}):e&&a.jsx(e,{className:m("size-4","text-gray-700 dark:text-gray-400")}),Xe=({options:e=[],selectedValues:t,multiple:r,selectionIcon:o,selectionIconPosition:n,hasAnyIcon:s,toggleOption:c,tabIndex:i})=>a.jsx(a.Fragment,{children:e.map(f=>{const d=t.includes(f.value);return a.jsxs(Ne,{tabIndex:i,value:f.label,onSelect:()=>!f.disabled&&c(f.value),disabled:f.disabled,className:m("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":d,children:[o==="auto"&&(r?a.jsx("div",{className:m("flex size-4 items-center justify-center rounded-md border","border-gray-700 dark:border-gray-400",d&&"bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"),children:d&&a.jsx(V,{name:"Checkmark",size:16})}):a.jsx("div",{className:m("relative size-4 rounded-full border",d?"border-gray-900 dark:border-gray-400":"border-gray-800 dark:border-gray-400","bg-transparent dark:bg-transparent"),children:d&&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"})})),o==="checkmark"&&!(n==="right"&&s)&&a.jsx("div",{className:"size-4",children:n==="left"&&d&&a.jsx(V,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})}),fa(f.icon),a.jsx("span",{className:m("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}),o==="checkmark"&&n==="right"&&a.jsx("div",{className:"size-4",children:d&&a.jsx(V,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})})]},`favorite-${f.value}`)})}),ga=({searchable:e,commandListRef:t,multiple:r,selectedValues:o,selectionIcon:n,selectionIconPosition:s,options:c=[],toggleAll:i,toggleOption:f,favoriteOptions:d=[]})=>{const g=c.filter(v=>!v.disabled),h=c.some(v=>v.icon),y=Q(v=>v.search);return l.useEffect(()=>{t.current?.scrollTo({top:0,behavior:"instant"})},[t,y]),a.jsxs(a.Fragment,{children:[e&&a.jsx(bt,{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(Ve,{ref:t,tabIndex:e?void 0:0,children:[a.jsx($e,{className:"p-4 text-center text-[14px] font-normal leading-5 text-gray-700 dark:text-gray-400",children:"No results found."}),r&&y===""&&a.jsx(ye,{className:"pb-0",children:a.jsx(Ne,{value:"select-all",onSelect:i,disabled:!1,className:m("cursor-pointer","data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900"),role:"option","aria-selected":o.length===g.length,children:a.jsxs("div",{className:"flex w-full items-center gap-2",children:[n==="auto"&&a.jsx("div",{className:m("flex size-4 items-center justify-center rounded-md border","border-gray-700 dark:border-gray-400",o.length===g.length&&"bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"),children:o.length===g.length&&a.jsx(V,{name:"Checkmark",size:16})}),n==="checkmark"&&!(s==="right"&&h)&&a.jsx("div",{className:"size-4",children:s==="left"&&o.length===g.length&&a.jsx(V,{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:o.length===g.length?"Deselect All":"Select All"}),n==="checkmark"&&s==="right"&&a.jsx("div",{className:"ml-auto size-4",children:o.length===g.length&&a.jsx(V,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})})]})})}),a.jsxs(ye,{className:r&&y===""?"pt-0":void 0,children:[a.jsx(Xe,{options:d,selectedValues:o,multiple:r,selectionIcon:n,selectionIconPosition:s,hasAnyIcon:h,toggleOption:f,tabIndex:e?void 0:0}),d.length>0&&a.jsx("div",{className:"my-1 border-b border-gray-300 dark:border-gray-600"}),a.jsx(Xe,{options:c,selectedValues:o,multiple:r,selectionIcon:n,selectionIconPosition:s,hasAnyIcon:h,toggleOption:f,tabIndex:e?void 0:0})]})]})]})},pa=({selectedValues:e,options:t=[],multiple:r,searchable:o,placeholder:n,handleClear:s})=>{const c=i=>typeof i=="string"?a.jsx(V,{name:i,size:16}):i&&a.jsx(i,{className:"size-4"});return e.length===0?a.jsxs("div",{className:m("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}),o?a.jsx(V,{name:"CaretSort",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"}):a.jsx(V,{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:m("max-w-full truncate text-gray-900 dark:text-gray-50",!r&&"flex items-center gap-2"),children:e.map((i,f)=>{const d=t.find(g=>g.value===i);return r?a.jsx("span",{className:m("text-[14px] font-normal leading-5",f!==e.length-1&&"mr-1"),children:f!==e.length-1?`${d?.label},`:d?.label},i):a.jsxs(G.Fragment,{children:[c(d?.icon),a.jsx("span",{className:"truncate text-[14px] font-normal leading-5",children:d?.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(),s()},className:"size-4 p-0",children:a.jsx(V,{name:"XmarkLight",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})}),o?a.jsx(V,{name:"CaretSort",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"}):a.jsx(V,{name:"ChevronDown",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})]})]})};function ha({options:e=[],multiple:t=!1,defaultValue:r,value:o,onChange:n}){const s=l.useRef(!1),c=l.useRef(null),[i,f]=l.useState(!1),[d,g]=l.useState(()=>{const b=o??r??[];return b===""?[]:Array.isArray(b)?b:[b]});l.useEffect(()=>{if(s.current){s.current=!1;return}const b=o??r??[];g(b===""?[]:Array.isArray(b)?b:[b])},[o]);const h=l.useCallback(b=>{f(b)},[]),y=l.useCallback(b=>{s.current=!0;let j;t?j=d.includes(b)?d.filter(k=>k!==b):[...d,b]:(j=d[0]===b?[]:[b],f(!1)),g(j),n?.(t?j:j[0]??"")},[t,d,e,n]),v=l.useCallback(()=>{s.current=!0,g([]),n?.(t?[]:"")},[t,n]),N=l.useCallback(()=>{s.current=!0;const b=e.filter(k=>!k.disabled).map(k=>k.value),j=d.length===b.length?[]:b;g(j),n?.(t?j:j[0])},[e,d,t,n]),P=l.useRef(t);return l.useEffect(()=>{if(P.current!==t){if(P.current=t,!t&&d.length>1){s.current=!0,g([d[0]]),n?.(d[0]);return}d.length>0&&(s.current=!0,n?.(t?[d[0]]:d[0]))}},[t]),{selectedValues:d,isPopoverOpen:i,commandListRef:c,toggleOption:y,handleClear:v,toggleAll:N,handleOpenChange:h}}const ma=G.forwardRef(({options:e=[],favoriteOptions:t=[],defaultValue:r,value:o,onChange:n,onBlur:s,id:c,name:i,label:f,required:d,disabled:g,errors:h=[],warnings:y=[],multiple:v,selectionIcon:N="auto",selectionIconPosition:P="left",searchable:b,description:j,placeholder:k,className:$,contentClassName:T,contentAlign:O="start",...R},A)=>{const L=l.useId(),M=c??`${L}-select`,{selectedValues:I,isPopoverOpen:q,commandListRef:U,toggleOption:w,handleClear:D,toggleAll:B,handleOpenChange:W}=ha({options:e,multiple:v,defaultValue:r,value:o,onChange:n}),J=l.useCallback(z=>{q||s?.(z)},[s,q]);return a.jsxs(kt,{children:[f&&a.jsx(Me,{htmlFor:M,required:d,disabled:g,hasError:h.length>0,inline:!1,onClick:z=>{z.preventDefault(),z.target.control?.focus()},children:f}),a.jsxs(Dt,{open:q,onOpenChange:z=>{W(z),!z&&document.activeElement?.id!==M&&s?.({target:{}})},children:[a.jsx(ua,{asChild:!0,children:a.jsx(hr,{id:M,name:i,type:"button",role:"combobox",onBlur:J,disabled:g,"aria-invalid":h.length>0,"aria-label":f?void 0:v?"Multi select":"Select","aria-required":d,"aria-expanded":q,className:m("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"],$),...R,ref:A,children:a.jsx(pa,{selectedValues:I,options:[...t,...e],multiple:v,searchable:b,placeholder:k,handleClear:D})})}),a.jsx(Ft,{align:O,onEscapeKeyDown:z=>{z.preventDefault(),W(!1)},className:T,children:a.jsx(vt,{defaultValue:!v&&I[0]?e.find(z=>z.value===I[0])?.label:void 0,children:a.jsx(ga,{favoriteOptions:t,searchable:b,commandListRef:U,multiple:v,selectedValues:I,selectionIcon:N,selectionIconPosition:P,options:e,toggleAll:B,toggleOption:w})})})]}),j&&a.jsx(yt,{children:j}),y.length>0&&a.jsx(de,{messages:y,type:"warning"}),h.length>0&&a.jsx(de,{messages:h,type:"error"})]})}),xa=Xr(ma);xa.displayName="SelectField";function _t(...e){return gr(Ht(e))}const va=_t("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"),Be=l.forwardRef(({className:e,type:t,...r},o)=>a.jsx("input",{type:t,className:_t(va,e),ref:o,...r}));Be.displayName="Input";function Ae(e,t){const r=Object.getOwnPropertyDescriptor(e,"value")?.set,o=Object.getPrototypeOf(e),n=Object.getOwnPropertyDescriptor(o,"value")?.set;r&&r!==n?n?.call(e,t):r?.call(e,t)}function be(e,t,r="blur"){return e.reduce((o,n)=>typeof n=="function"?r==="blur"||r==="all"?n(o):o:(n.options?.trigger??"blur")!==r&&r!=="all"?o:n.options?.if===void 0||n.options.if?n.transformer(o):o,t)}function Tt({transformers:e,children:t}){const o=Ze()?.setValue;return l.useEffect(()=>{const n=t.props.value,s=be(e,n,"all");ge(s,n)||(typeof o=="function"?o(t.props.name,s):t.props.onChange?.({target:{value:s}}))},[e,o]),G.cloneElement(t,{...t.props,onChange:n=>{const s=be(e,n.target.value,"change");s!==n.target.value&&o&&(o(t.props.name,s),Ae(n.target,s)),t.props.onChange?.(n)},onBlur:n=>{t.props.onBlur?.(n);const s=n.target,c=be(e,s.value,"blur");if(!ge(c,s.value)){Ae(s,c);const i=new Event("change",{bubbles:!0});s.dispatchEvent(i)}},onKeyDown:n=>{if(t.props.onKeyDown?.(n),n.key==="Enter"){const s=n.target,c=be(e,s.value,"keyDown");if(!ge(c,s.value)){Ae(s,c);const i=new Event("change",{bubbles:!0});s.dispatchEvent(i)}}}})}const ba=G.forwardRef(({id:e,name:t,value:r,className:o,isLoading:n,haveFetchError:s,disabled:c,onChange:i,onBlur:f,onClick:d,selectedOption:g,optionsLength:h,handleOpenChange:y,onKeyDown:v,onMouseDown:N,placeholder:P,hasError:b,label:j,required:k,isPopoverOpen:$,maxLength:T,handlePaste:O,onPaste:R,...A},L)=>{const[M,I]=l.useState(!1),q=ur("(hover: hover) and (pointer: fine)"),U=l.useMemo(()=>[ke.trimOnBlur(),ke.trimOnEnter()],[]);return a.jsxs("div",{className:m("group relative"),children:[a.jsx(Tt,{transformers:U,children:a.jsx(H.Input,{asChild:!0,children:a.jsx(Be,{id:e,name:t,value:r,className:m("pr-9",o),disabled:c,onChange:i,onBlur:f,onClick:w=>{const D=w.target;!(n||s)&&!g&&D.value!==""&&y?.(!0),d?.(w)},onKeyDown:w=>{v?.(w);const D=["ArrowUp","ArrowDown","Enter"].includes(w.key);if(w.key==="Enter"&&$&&h===0){y?.(!1),w.preventDefault();return}D&&$&&h>0||w.stopPropagation()},onMouseDown:w=>{const D=w.target;D.contains(document.activeElement)||requestAnimationFrame(()=>{D.select()}),N?.(w)},onPaste:w=>{O?.(w),R?.(w)},placeholder:P,"aria-invalid":b,"aria-label":j?void 0:"Id Autocomplete","aria-required":k,"aria-expanded":$,maxLength:T,...A,ref:L})})}),a.jsxs("div",{className:m("absolute right-3 top-1/2 flex size-4 -translate-y-1/2 items-center",!n&&!s&&!g&&"pointer-events-none"),children:[n&&a.jsx(V,{name:"Reload",size:16,className:m("animate-spin text-gray-500 dark:text-gray-600")}),s&&a.jsx(Ie,{children:a.jsx(Oe,{content:"Network error!",children:a.jsx(V,{name:"Error",size:16,className:m("text-red-900")})})}),g&&!n&&!s&&a.jsx(Ie,{children:a.jsx(Oe,{content:"Copied!",open:M,triggerAsChild:!0,children:a.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(g.value).then(()=>{I(!0),setTimeout(()=>I(!1),2e3)}).catch(w=>{console.error("Failed to copy value: ",w)})},className:m("focus-visible:outline-none [&_svg]:pointer-events-none",q&&"opacity-0 transition-opacity duration-500 group-hover:opacity-100"),children:a.jsx(V,{name:"Copy",size:16,className:m("text-gray-500 dark:text-gray-600")})})})})]})]})}),ya=({customIcon:e,asPlaceholder:t})=>typeof e=="string"?a.jsx(V,{name:e,size:24,className:m("shrink-0",t?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300")}):G.isValidElement(e)?a.jsx("div",{className:"size-6 shrink-0 overflow-hidden",children:e}):null,ka=({isLoadingSelectedOption:e,handleFetchSelectedOption:t,isFetchSelectedOptionSync:r,value:o})=>a.jsx("div",{children:a.jsx("button",{type:"button",disabled:e||r,onClick:()=>{!e&&!r&&t(o)},className:m("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(V,{name:r?"Checkmark":"Reload",size:16,className:m("text-gray-500 dark:text-gray-600",e&&"animate-spin",r&&"animate-in fade-in duration-500")})})}),_e=({variant:e="withValue",icon:t,title:r="Title not available",path:o="Path not available",value:n,description:s="Description not available",asPlaceholder:c,showValue:i=!0,isLoadingSelectedOption:f,handleFetchSelectedOption:d,isFetchSelectedOptionSync:g,className:h,placeholderIcon:y="PowerhouseLogoSmall",...v})=>{const N=()=>a.jsx("div",{className:m("flex w-full items-center"),children:a.jsx("span",{className:m("truncate text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:n})}),P=(b=!0)=>a.jsxs("div",{className:m("flex w-full flex-col gap-1"),children:[a.jsxs("div",{className:m("flex gap-2"),children:[a.jsx(ya,{customIcon:c?y:t,asPlaceholder:c}),a.jsxs("div",{className:m("flex min-w-0 grow flex-col gap-[-2px]"),children:[a.jsx("span",{className:m("truncate text-sm font-bold leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300"),children:r}),!i&&typeof o=="object"?a.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:m("truncate text-xs leading-5 text-blue-900 hover:underline focus-visible:outline-none"),children:o.text}):a.jsx("span",{className:m("truncate text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:typeof o=="object"?o.text:o})]}),c===!1&&d&&a.jsx(ka,{isLoadingSelectedOption:f,handleFetchSelectedOption:d,isFetchSelectedOptionSync:g,value:n})]}),i&&a.jsx("div",{className:m("flex max-w-full items-center"),children:a.jsx("span",{className:m("truncate text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:n})}),b&&a.jsx("div",{className:m("flex flex-col"),children:a.jsx("p",{className:m("line-clamp-2 text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300"),children:s})}),b&&"agentType"in v&&typeof v.agentType=="string"&&a.jsx("div",{className:m("flex max-w-full items-center justify-end"),children:a.jsx("span",{className:m("truncate text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:v.agentType})})]});return a.jsxs("div",{className:m("w-full max-w-full rounded-md bg-transparent px-3 pb-2",e==="withValue"?"pt-2":"pt-3",h),children:[e==="withValue"&&N(),e==="withValueAndTitle"&&P(!1),e==="withValueTitleAndDescription"&&P()]})},Ca=({variant:e,commandListRef:t,selectedValue:r,options:o=[],toggleOption:n,renderOption:s,previewPlaceholder:c})=>{const i=Q(d=>d.search),f=c||{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(Ve,{ref:t,children:[a.jsx($e,{className:m("h-full p-1"),children:s?s(f,{asPlaceholder:!0,showValue:!0,className:m("pb-0")}):a.jsx(_e,{variant:e,icon:f.icon,title:f.title,path:f.path,value:f.value,description:f.description,asPlaceholder:!0,className:m("pb-0")})}),a.jsx(ye,{className:m("px-1"),children:o.map(d=>{const g=r===d.value;return a.jsx(Ne,{value:d.value,onSelect:()=>n?.(d.value),className:m("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:s?s(d,{asPlaceholder:!1,showValue:!0}):a.jsx(_e,{variant:e,...d})},d.value)})})]})},ja=l.createContext({}),wa=()=>l.useContext(ja);function Na({autoComplete:e,defaultValue:t,value:r,isOpenByDefault:o,initialOptions:n,onChange:s,onBlur:c,fetchOptions:i,fetchSelectedOption:f}){const d=wa(),g=l.useRef(!1),h=l.useRef(!1),y=l.useRef(null),[v,N]=l.useState(o??!1),[P,b]=l.useState(n??[]),[j,k]=l.useState(!1),[$,T]=l.useState(!1),[O,R]=l.useState(!1),[A,L]=l.useState(r??t??""),[M,I]=l.useState(void 0),[q,U]=l.useState(""),[w,D]=l.useState(!1),B=l.useCallback(()=>{R(!1),k(!1),T(!1),N(!1)},[]),W=fr(l.useCallback(x=>{if(!(!e||!i)){if(x===""){B(),b([]),L(""),I(void 0);return}R(!1),k(!0);try{const p=i(x,d);Promise.resolve(p).then(E=>{b(E);const S=E.find(F=>F.value===x);S?(I(S),N(!1)):(I(void 0),N(!0)),k(!1)}).catch(()=>{R(!0),k(!1)})}catch{R(!0),k(!1)}}},[B,e,i,d])),J=l.useCallback(x=>{if(!(!e||!f)){T(!0);try{const p=f(x),E=p instanceof Promise;Promise.resolve(p).then(S=>{S?(I(S),b(F=>{const _=F.findIndex(X=>X.value===x);if(_!==-1){const X=[...F];return X[_]=S,X}return F})):(B(),b([]),L(""),I(void 0)),T(!1),E||(D(!0),setTimeout(()=>{D(!1)},1500))}).catch(()=>{T(!1)})}catch{T(!1)}}},[B,e,f]),z=l.useCallback(x=>{x||U(P[0]?.value??""),N(x)},[P]),K=l.useCallback(x=>{g.current=!1,h.current=!0,L(x),I(P.find(p=>p.value===x)),B(),s?.(x)},[s,B,P]),re=l.useCallback(x=>{const p=x.target.value;g.current=!0,L(p),I(void 0),s?.(p)},[s]),oe=l.useCallback(x=>{U(x)},[]),u=l.useCallback(x=>{v||c?.(x)},[c,v]),C=l.useCallback(x=>{const p=x.clipboardData.getData("text"),E=p.trim();if(p!==E){x.preventDefault();const S=x.currentTarget,F=S.selectionStart||0,_=S.selectionEnd||0,X=S.value,ue=X.substring(0,F)+E+X.substring(_);s?.(ue),requestAnimationFrame(()=>{const ve=F+E.length;S.setSelectionRange(ve,ve),W(ue)})}else p===A&&W(A)},[A,W,s]);return l.useEffect(()=>{e?g.current&&W(A):(B(),b([]),L(""),I(void 0))},[e,A,W,B]),l.useEffect(()=>{h.current||(g.current=!1,L(r??t??""),I(void 0)),h.current=!1},[r]),l.useEffect(()=>{if(n?.length&&A){const x=n.find(p=>p.value===A);x&&I(x)}},[]),{selectedValue:A,selectedOption:M,isPopoverOpen:v,commandListRef:y,options:P,isLoading:j,isLoadingSelectedOption:$,haveFetchError:O,commandValue:q,isFetchSelectedOptionSync:w,toggleOption:K,handleOpenChange:z,onTriggerBlur:u,handleChange:re,handleCommandValue:oe,handleFetchSelectedOption:J,handlePaste:C}}const Ra=G.forwardRef(({id:e,name:t,className:r,label:o,description:n,value:s,defaultValue:c,disabled:i,placeholder:f,required:d,errors:g,warnings:h,onChange:y,onBlur:v,onClick:N,onKeyDown:P,onMouseDown:b,autoComplete:j=!0,variant:k="withValue",maxLength:$,fetchOptionsCallback:T,fetchSelectedOptionCallback:O,isOpenByDefault:R,initialOptions:A,renderOption:L,previewPlaceholder:M,...I},q)=>{const U=l.useId(),w=e??`${U}-id-autocomplete`,D=l.useRef(null),B=Z=>{D.current=Z,typeof q=="function"?q(Z):q&&(q.current=Z)},W=Array.isArray(h)&&h.length>0,J=Array.isArray(g)&&g.length>0,{selectedValue:z,selectedOption:K,isPopoverOpen:re,commandListRef:oe,options:u,isLoading:C,isLoadingSelectedOption:x,haveFetchError:p,commandValue:E,isFetchSelectedOptionSync:S,toggleOption:F,handleOpenChange:_,onTriggerBlur:X,handleChange:ue,handleCommandValue:ve,handleFetchSelectedOption:Ke,handlePaste:Lt}=Na({autoComplete:j,defaultValue:c,value:s,isOpenByDefault:R,initialOptions:A,onChange:y,onBlur:v,fetchOptions:T,fetchSelectedOption:O}),Mt=Z=>{F(Z),D.current?.focus()},zt=k==="withValueAndTitle"||k==="withValueTitleAndDescription",Vt=l.useMemo(()=>[ke.trimOnBlur(),ke.trimOnEnter()],[]);return a.jsxs(kt,{children:[!!o&&a.jsx(Me,{htmlFor:w,disabled:i,hasError:J,required:d,onClick:Z=>{Z.preventDefault(),Z.target.control?.focus()},children:o}),j&&T?a.jsx(Dt,{open:re,onOpenChange:_,children:a.jsxs(H,{shouldFilter:!1,value:E,onValueChange:ve,className:m("dark:bg-charcoal-900 bg-gray-100"),children:[a.jsx(ca,{asChild:!0,children:a.jsx(ba,{id:w,name:t,value:z,className:r,isLoading:C,haveFetchError:p,disabled:i,onChange:ue,onBlur:X,onClick:N,selectedOption:K,optionsLength:u.length,handleOpenChange:_,onKeyDown:P,onMouseDown:b,placeholder:f,hasError:J,label:o,required:d,isPopoverOpen:re,maxLength:$,handlePaste:Lt,...I,ref:B})}),zt&&(L?L(K===void 0&&M?{...M}:{...K,value:K?.value??""},{asPlaceholder:K===void 0,showValue:!1,isLoadingSelectedOption:x,handleFetchSelectedOption:O?Ke:void 0,isFetchSelectedOptionSync:S,className:m("rounded-t-none pt-2")}):a.jsx(_e,{variant:k,icon:K?.icon??M?.icon,title:K?.title??M?.title,path:K?.path??M?.path,value:K?.value??M?.value??"",description:K?.description??M?.description,asPlaceholder:K===void 0,showValue:!1,isLoadingSelectedOption:x,handleFetchSelectedOption:O?Ke:void 0,isFetchSelectedOptionSync:S,className:m("rounded-t-none pt-2")})),a.jsx(Ft,{align:"start",onOpenAutoFocus:Z=>Z.preventDefault(),onInteractOutside:Z=>{Z.target instanceof Element&&Z.target.id===w&&Z.preventDefault()},children:a.jsx(Ca,{variant:k,commandListRef:oe,selectedValue:z,options:u,toggleOption:Mt,renderOption:L,previewPlaceholder:M})})]})}):a.jsx(Tt,{transformers:Vt,children:a.jsx(Be,{id:w,name:t,value:z,className:r,disabled:i,onChange:ue,onBlur:v,onClick:N,onMouseDown:b,placeholder:f,"aria-invalid":J,"aria-label":o?void 0:"Id Autocomplete","aria-required":d,maxLength:$,...I,ref:B})}),!!n&&a.jsx(yt,{children:n}),W&&a.jsx(de,{messages:h,type:"warning"}),J&&a.jsx(de,{messages:g,type:"error"})]})});Ra.displayName="IdAutocomplete";export{jr as C,Be as I,Dt as P,ma as S,ua as a,Ft as b,Ra as c};
|
|
1
|
+
import{j as a,S as $t,d as qt,u as Ce,P as ee,c as pe,e as Ze,f as Bt,C as Kt,a as Ht}from"./document_model_editor-8Rt5FvRZ.js";import{r as l,a as G}from"./sentry_react-cODD7zWc.js";import{c as m,a as Je,f as Te,P as he,d as Qe,e as ae,E as Gt,I as V,u as ne,F as Ut,G as Wt,O as Xt,H as Zt,b as Ye,R as Jt,A as et,g as Qt,J as Yt,K as er,L as tr,N as rr,Q as ar,D as nr,C as sr,i as or}from"./design_system-gRtxS73S.js";import{R as lr,T as ir,P as dr,C as cr,a as Ie,u as ur,b as fr}from"./design_system_connect-BM4udPUI.js";import{t as gr}from"./tailwind_merge-Dr4f9Rms.js";const pr=qt(m("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"}}),hr=l.forwardRef(({variant:e,className:t,asChild:r=!1,...o},n)=>{const s=r?$t:"button";return a.jsx(s,{className:m(pr({variant:e,className:t})),ref:n,...o})});function mr(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var je="Checkbox",[xr]=Je(je),[vr,Le]=xr(je);function br(e){const{__scopeCheckbox:t,checked:r,children:o,defaultChecked:n,disabled:s,form:c,name:i,onCheckedChange:f,required:d,value:g="on",internal_do_not_use_render:h}=e,[y,v]=Qe({prop:r,defaultProp:n??!1,onChange:f,caller:je}),[N,P]=l.useState(null),[b,j]=l.useState(null),k=l.useRef(!1),$=N?!!c||!!N.closest("form"):!0,T={checked:y,disabled:s,setChecked:v,control:N,setControl:P,name:i,form:c,value:g,hasConsumerStoppedPropagationRef:k,required:d,defaultChecked:Y(n)?!1:n,isFormControl:$,bubbleInput:b,setBubbleInput:j};return a.jsx(vr,{scope:t,...T,children:yr(h)?h(T):o})}var tt="CheckboxTrigger",rt=l.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...o},n)=>{const{control:s,value:c,disabled:i,checked:f,required:d,setControl:g,setChecked:h,hasConsumerStoppedPropagationRef:y,isFormControl:v,bubbleInput:N}=Le(tt,e),P=Ce(n,g),b=l.useRef(f);return l.useEffect(()=>{const j=s?.form;if(j){const k=()=>h(b.current);return j.addEventListener("reset",k),()=>j.removeEventListener("reset",k)}},[s,h]),a.jsx(he.button,{type:"button",role:"checkbox","aria-checked":Y(f)?"mixed":f,"aria-required":d,"data-state":it(f),"data-disabled":i?"":void 0,disabled:i,value:c,...o,ref:P,onKeyDown:ae(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:ae(r,j=>{h(k=>Y(k)?!0:!k),N&&v&&(y.current=j.isPropagationStopped(),y.current||j.stopPropagation())})})});rt.displayName=tt;var at=l.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:o,checked:n,defaultChecked:s,required:c,disabled:i,value:f,onCheckedChange:d,form:g,...h}=e;return a.jsx(br,{__scopeCheckbox:r,checked:n,defaultChecked:s,disabled:i,required:c,onCheckedChange:d,name:o,form:g,value:f,internal_do_not_use_render:({isFormControl:y})=>a.jsxs(a.Fragment,{children:[a.jsx(rt,{...h,ref:t,__scopeCheckbox:r}),y&&a.jsx(lt,{__scopeCheckbox:r})]})})});at.displayName=je;var nt="CheckboxIndicator",st=l.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:o,...n}=e,s=Le(nt,r);return a.jsx(Te,{present:o||Y(s.checked)||s.checked===!0,children:a.jsx(he.span,{"data-state":it(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:t,style:{pointerEvents:"none",...e.style}})})});st.displayName=nt;var ot="CheckboxBubbleInput",lt=l.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:o,hasConsumerStoppedPropagationRef:n,checked:s,defaultChecked:c,required:i,disabled:f,name:d,value:g,form:h,bubbleInput:y,setBubbleInput:v}=Le(ot,e),N=Ce(r,v),P=mr(s),b=Gt(o);l.useEffect(()=>{const k=y;if(!k)return;const $=window.HTMLInputElement.prototype,O=Object.getOwnPropertyDescriptor($,"checked").set,R=!n.current;if(P!==s&&O){const A=new Event("click",{bubbles:R});k.indeterminate=Y(s),O.call(k,Y(s)?!1:s),k.dispatchEvent(A)}},[y,P,s,n]);const j=l.useRef(Y(s)?!1:s);return a.jsx(he.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??j.current,required:i,disabled:f,name:d,value:g,form:h,...t,tabIndex:-1,ref:N,style:{...t.style,...b,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});lt.displayName=ot;function yr(e){return typeof e=="function"}function Y(e){return e==="indeterminate"}function it(e){return Y(e)?"indeterminate":e?"checked":"unchecked"}const dt=l.forwardRef(({className:e,checked:t,invalid:r,...o},n)=>a.jsx(at,{ref:n,className:m("peer size-4 shrink-0 rounded","border-input border shadow-sm shadow-black/[.04]","ring-offset-background transition-shadow","focus-visible:border-ring focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:border-gray-700 disabled:data-[invalid=false]:data-[state=checked]:bg-gray-700 disabled:data-[invalid=false]:data-[state=indeterminate]:bg-gray-700 dark:disabled:data-[invalid=false]:data-[state=checked]:bg-gray-500 dark:disabled:data-[invalid=false]:data-[state=indeterminate]:bg-gray-500","data-[state]:border-gray-700 dark:data-[state]:border-gray-500","data-[state=checked]:bg-gray-900 data-[state=indeterminate]:bg-gray-900 dark:data-[state=checked]:bg-gray-400 dark:data-[state=indeterminate]:bg-gray-400","data-[state=checked]:text-slate-50 data-[state=indeterminate]:text-slate-50 dark:data-[state=checked]:text-gray-900 dark:data-[state=indeterminate]:text-gray-900",!o.disabled&&["group-hover:border-gray-900 data-[state=checked]:group-hover:bg-gray-900 data-[state=indeterminate]:group-hover:bg-gray-900","dark:group-hover:border-slate-50 dark:data-[state=checked]:group-hover:bg-slate-50 dark:data-[state=indeterminate]:group-hover:bg-slate-50"],"data-[invalid=true]:data-[state]:!border-red-800 data-[invalid=true]:data-[state=checked]:!bg-red-800 data-[invalid=true]:data-[state=indeterminate]:!bg-red-800","dark:data-[invalid=true]:data-[state]:!border-red-800 dark:data-[invalid=true]:data-[state=checked]:!bg-red-800 dark:data-[invalid=true]:data-[state=indeterminate]:!bg-red-800","data-[invalid=true]:group-hover:!border-red-900 data-[invalid=true]:data-[state=checked]:group-hover:!bg-red-900 data-[invalid=true]:data-[state=indeterminate]:group-hover:!bg-red-900",e),checked:t,"data-invalid":r,...o,children:a.jsx(st,{className:"flex items-center justify-center text-current",children:t==="indeterminate"?a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 9 9",fill:"currentcolor",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.75 4.5C0.75 4.08579 1.08579 3.75 1.5 3.75H7.5C7.91421 3.75 8.25 4.08579 8.25 4.5C8.25 4.91421 7.91421 5.25 7.5 5.25H1.5C1.08579 5.25 0.75 4.91421 0.75 4.5Z"})}):t?a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 9 9",fill:"currentcolor",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.53547 0.62293C8.88226 0.849446 8.97976 1.3142 8.75325 1.66099L4.5083 8.1599C4.38833 8.34356 4.19397 8.4655 3.9764 8.49358C3.75883 8.52167 3.53987 8.45309 3.3772 8.30591L0.616113 5.80777C0.308959 5.52987 0.285246 5.05559 0.563148 4.74844C0.84105 4.44128 1.31533 4.41757 1.62249 4.69547L3.73256 6.60459L7.49741 0.840706C7.72393 0.493916 8.18868 0.396414 8.53547 0.62293Z"})}):null})}));dt.displayName="CheckboxBase";const kr=l.forwardRef(({children:e,className:t,...r},o)=>a.jsx(cr,{ref:o,...r,className:m("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})),Oe=({content:e,children:t,triggerAsChild:r=!1,delayDuration:o=0,...n})=>{const{open:s,defaultOpen:c,onOpenChange:i,...f}=n;return a.jsxs(lr,{defaultOpen:c,delayDuration:o,onOpenChange:i,open:s,children:[a.jsx(ir,{asChild:r,type:r?void 0:"button",children:t}),a.jsx(dr,{children:a.jsx(kr,{sideOffset:3,...f,children:e})})]})},Me=({children:e,required:t,disabled:r,description:o,hasError:n,inline:s,className:c,...i})=>{const f=m("inline-flex items-center text-sm font-medium",s?"leading-[22px]":"leading-4",`text-gray-900 ${s?"dark:text-gray-400":"dark:text-gray-50"}`,n&&"group-hover:!text-red-900 dark:group-hover:!text-red-900",n&&s&&"text-red-800 dark:text-red-800",n&&!s&&"text-red-900 dark:text-red-900",r&&`cursor-not-allowed text-gray-700 ${s?"dark:text-gray-600":"dark:text-gray-300"}`,s?!r&&"group-hover:text-gray-900 dark:group-hover:text-slate-50":"mb-[3px]",c);if(!e)return null;const d={...i};return a.jsxs("label",{className:f,...d,children:[e,t&&a.jsx("span",{className:m("ml-1 text-gray-800 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-slate-50",n&&`${s?"!text-red-800":"!text-red-900"} group-hover:!text-red-900`),children:"*"}),o&&a.jsx(Ie,{children:a.jsx(Oe,{content:o,children:a.jsx(V,{name:"CircleInfo",size:16,className:m("ml-1 cursor-pointer text-gray-600 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-500",r&&"text-gray-500")})})})]})},Cr="p",He=({children:e,type:t="info",as:r,className:o,...n})=>{const s=r||Cr,i=m("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],o);return a.jsx(s,{"data-type":t,className:i,...n,children:e})},de=({messages:e,type:t="info",className:r,...o})=>{if(e.length===0)return null;if(e.length===1)return a.jsx(He,{type:t,...o,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:m("flex flex-col gap-1",r),...o,children:e.map(s=>a.jsx(He,{as:"li",type:t,className:m("relative pl-4","before:absolute before:left-0 before:top-[0.4em] before:size-2 before:rounded-full",n[t]),children:s},s))})},jr=G.forwardRef(({id:e,name:t,label:r,value:o,defaultValue:n,disabled:s,required:c,description:i,errors:f,warnings:d,onChange:g,className:h,...y},v)=>{const N=l.useId(),P=e??N,b=!!f?.length,j=k=>k==="true"?!0:k==="false"?!1:k;return a.jsxs("div",{className:m("flex flex-col gap-2"),children:[a.jsxs("div",{className:m("group flex items-center space-x-2",h),children:[a.jsx(dt,{id:P,name:t,checked:j(o??n),disabled:s,onCheckedChange:g,required:c,invalid:b,"aria-invalid":b,ref:v,...y}),a.jsx(Me,{htmlFor:P,required:c,disabled:s,hasError:b,description:i,className:m(!s&&"group-hover:cursor-pointer"),inline:!0,children:r})]}),d&&a.jsx(de,{type:"warning",messages:d}),f&&a.jsx(de,{type:"error",messages:f})]})});jr.displayName="Checkbox";var Ge=1,wr=.9,Nr=.8,Rr=.17,Ee=.1,Se=.999,Er=.9999,Sr=.99,Pr=/[\\\/_+.#"@\[\(\{&]/,Ar=/[\\\/_+.#"@\[\(\{&]/g,Ir=/[\s-]/,ct=/[\s-]/g;function De(e,t,r,o,n,s,c){if(s===t.length)return n===e.length?Ge:Sr;var i=`${n},${s}`;if(c[i]!==void 0)return c[i];for(var f=o.charAt(s),d=r.indexOf(f,n),g=0,h,y,v,N;d>=0;)h=De(e,t,r,o,d+1,s+1,c),h>g&&(d===n?h*=Ge:Pr.test(e.charAt(d-1))?(h*=Nr,v=e.slice(n,d-1).match(Ar),v&&n>0&&(h*=Math.pow(Se,v.length))):Ir.test(e.charAt(d-1))?(h*=wr,N=e.slice(n,d-1).match(ct),N&&n>0&&(h*=Math.pow(Se,N.length))):(h*=Rr,n>0&&(h*=Math.pow(Se,d-n))),e.charAt(d)!==t.charAt(s)&&(h*=Er)),(h<Ee&&r.charAt(d-1)===o.charAt(s+1)||o.charAt(s+1)===o.charAt(s)&&r.charAt(d-1)!==o.charAt(s))&&(y=De(e,t,r,o,d+1,s+2,c),y*Ee>h&&(h=y*Ee)),h>g&&(g=h),d=r.indexOf(f,d+1);return c[i]=g,g}function Ue(e){return e.toLowerCase().replace(ct," ")}function Or(e,t,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,De(e,t,Ue(e),Ue(t),0,0,{})}var fe='[cmdk-group=""]',Pe='[cmdk-group-items=""]',Dr='[cmdk-group-heading=""]',ut='[cmdk-item=""]',We=`${ut}:not([aria-disabled="true"])`,Fe="cmdk-item-select",le="data-value",Fr=(e,t,r)=>Or(e,t,r),ft=l.createContext(void 0),me=()=>l.useContext(ft),gt=l.createContext(void 0),ze=()=>l.useContext(gt),pt=l.createContext(void 0),ht=l.forwardRef((e,t)=>{let r=ie(()=>{var u,C;return{search:"",value:(C=(u=e.value)!=null?u:e.defaultValue)!=null?C:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),o=ie(()=>new Set),n=ie(()=>new Map),s=ie(()=>new Map),c=ie(()=>new Set),i=mt(e),{label:f,children:d,value:g,onValueChange:h,filter:y,shouldFilter:v,loop:N,disablePointerSelection:P=!1,vimBindings:b=!0,...j}=e,k=ne(),$=ne(),T=ne(),O=l.useRef(null),R=Hr();se(()=>{if(g!==void 0){let u=g.trim();r.current.value=u,A.emit()}},[g]),se(()=>{R(6,w)},[]);let A=l.useMemo(()=>({subscribe:u=>(c.current.add(u),()=>c.current.delete(u)),snapshot:()=>r.current,setState:(u,C,x)=>{var p,E,S,F;if(!Object.is(r.current[u],C)){if(r.current[u]=C,u==="search")U(),I(),R(1,q);else if(u==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let _=document.getElementById(T);_?_.focus():(p=document.getElementById(k))==null||p.focus()}if(R(7,()=>{var _;r.current.selectedItemId=(_=D())==null?void 0:_.id,A.emit()}),x||R(5,w),((E=i.current)==null?void 0:E.value)!==void 0){let _=C??"";(F=(S=i.current).onValueChange)==null||F.call(S,_);return}}A.emit()}},emit:()=>{c.current.forEach(u=>u())}}),[]),L=l.useMemo(()=>({value:(u,C,x)=>{var p;C!==((p=s.current.get(u))==null?void 0:p.value)&&(s.current.set(u,{value:C,keywords:x}),r.current.filtered.items.set(u,M(C,x)),R(2,()=>{I(),A.emit()}))},item:(u,C)=>(o.current.add(u),C&&(n.current.has(C)?n.current.get(C).add(u):n.current.set(C,new Set([u]))),R(3,()=>{U(),I(),r.current.value||q(),A.emit()}),()=>{s.current.delete(u),o.current.delete(u),r.current.filtered.items.delete(u);let x=D();R(4,()=>{U(),x?.getAttribute("id")===u&&q(),A.emit()})}),group:u=>(n.current.has(u)||n.current.set(u,new Set),()=>{s.current.delete(u),n.current.delete(u)}),filter:()=>i.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:k,inputId:T,labelId:$,listInnerRef:O}),[]);function M(u,C){var x,p;let E=(p=(x=i.current)==null?void 0:x.filter)!=null?p:Fr;return u?E(u,r.current.search,C):0}function I(){if(!r.current.search||i.current.shouldFilter===!1)return;let u=r.current.filtered.items,C=[];r.current.filtered.groups.forEach(p=>{let E=n.current.get(p),S=0;E.forEach(F=>{let _=u.get(F);S=Math.max(_,S)}),C.push([p,S])});let x=O.current;B().sort((p,E)=>{var S,F;let _=p.getAttribute("id"),X=E.getAttribute("id");return((S=u.get(X))!=null?S:0)-((F=u.get(_))!=null?F:0)}).forEach(p=>{let E=p.closest(Pe);E?E.appendChild(p.parentElement===E?p:p.closest(`${Pe} > *`)):x.appendChild(p.parentElement===x?p:p.closest(`${Pe} > *`))}),C.sort((p,E)=>E[1]-p[1]).forEach(p=>{var E;let S=(E=O.current)==null?void 0:E.querySelector(`${fe}[${le}="${encodeURIComponent(p[0])}"]`);S?.parentElement.appendChild(S)})}function q(){let u=B().find(x=>x.getAttribute("aria-disabled")!=="true"),C=u?.getAttribute(le);A.setState("value",C||void 0)}function U(){var u,C,x,p;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=o.current.size;return}r.current.filtered.groups=new Set;let E=0;for(let S of o.current){let F=(C=(u=s.current.get(S))==null?void 0:u.value)!=null?C:"",_=(p=(x=s.current.get(S))==null?void 0:x.keywords)!=null?p:[],X=M(F,_);r.current.filtered.items.set(S,X),X>0&&E++}for(let[S,F]of n.current)for(let _ of F)if(r.current.filtered.items.get(_)>0){r.current.filtered.groups.add(S);break}r.current.filtered.count=E}function w(){var u,C,x;let p=D();p&&(((u=p.parentElement)==null?void 0:u.firstChild)===p&&((x=(C=p.closest(fe))==null?void 0:C.querySelector(Dr))==null||x.scrollIntoView({block:"nearest"})),p.scrollIntoView({block:"nearest"}))}function D(){var u;return(u=O.current)==null?void 0:u.querySelector(`${ut}[aria-selected="true"]`)}function B(){var u;return Array.from(((u=O.current)==null?void 0:u.querySelectorAll(We))||[])}function W(u){let C=B()[u];C&&A.setState("value",C.getAttribute(le))}function J(u){var C;let x=D(),p=B(),E=p.findIndex(F=>F===x),S=p[E+u];(C=i.current)!=null&&C.loop&&(S=E+u<0?p[p.length-1]:E+u===p.length?p[0]:p[E+u]),S&&A.setState("value",S.getAttribute(le))}function z(u){let C=D(),x=C?.closest(fe),p;for(;x&&!p;)x=u>0?Br(x,fe):Kr(x,fe),p=x?.querySelector(We);p?A.setState("value",p.getAttribute(le)):J(u)}let K=()=>W(B().length-1),re=u=>{u.preventDefault(),u.metaKey?K():u.altKey?z(1):J(1)},oe=u=>{u.preventDefault(),u.metaKey?W(0):u.altKey?z(-1):J(-1)};return l.createElement(ee.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:u=>{var C;(C=j.onKeyDown)==null||C.call(j,u);let x=u.nativeEvent.isComposing||u.keyCode===229;if(!(u.defaultPrevented||x))switch(u.key){case"n":case"j":{b&&u.ctrlKey&&re(u);break}case"ArrowDown":{re(u);break}case"p":case"k":{b&&u.ctrlKey&&oe(u);break}case"ArrowUp":{oe(u);break}case"Home":{u.preventDefault(),W(0);break}case"End":{u.preventDefault(),K();break}case"Enter":{u.preventDefault();let p=D();if(p){let E=new Event(Fe);p.dispatchEvent(E)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:L.inputId,id:L.labelId,style:Ur},f),we(e,u=>l.createElement(gt.Provider,{value:A},l.createElement(ft.Provider,{value:L},u))))}),_r=l.forwardRef((e,t)=>{var r,o;let n=ne(),s=l.useRef(null),c=l.useContext(pt),i=me(),f=mt(e),d=(o=(r=f.current)==null?void 0:r.forceMount)!=null?o:c?.forceMount;se(()=>{if(!d)return i.item(n,c?.id)},[d]);let g=xt(n,s,[e.value,e.children,s],e.keywords),h=ze(),y=Q(R=>R.value&&R.value===g.current),v=Q(R=>d||i.filter()===!1?!0:R.search?R.filtered.items.get(n)>0:!0);l.useEffect(()=>{let R=s.current;if(!(!R||e.disabled))return R.addEventListener(Fe,N),()=>R.removeEventListener(Fe,N)},[v,e.onSelect,e.disabled]);function N(){var R,A;P(),(A=(R=f.current).onSelect)==null||A.call(R,g.current)}function P(){h.setState("value",g.current,!0)}if(!v)return null;let{disabled:b,value:j,onSelect:k,forceMount:$,keywords:T,...O}=e;return l.createElement(ee.div,{ref:pe(s,t),...O,id:n,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!y,"data-disabled":!!b,"data-selected":!!y,onPointerMove:b||i.getDisablePointerSelection()?void 0:P,onClick:b?void 0:N},e.children)}),Tr=l.forwardRef((e,t)=>{let{heading:r,children:o,forceMount:n,...s}=e,c=ne(),i=l.useRef(null),f=l.useRef(null),d=ne(),g=me(),h=Q(v=>n||g.filter()===!1?!0:v.search?v.filtered.groups.has(c):!0);se(()=>g.group(c),[]),xt(c,i,[e.value,e.heading,f]);let y=l.useMemo(()=>({id:c,forceMount:n}),[n]);return l.createElement(ee.div,{ref:pe(i,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},r&&l.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:d},r),we(e,v=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?d:void 0},l.createElement(pt.Provider,{value:y},v))))}),Lr=l.forwardRef((e,t)=>{let{alwaysRender:r,...o}=e,n=l.useRef(null),s=Q(c=>!c.search);return!r&&!s?null:l.createElement(ee.div,{ref:pe(n,t),...o,"cmdk-separator":"",role:"separator"})}),Mr=l.forwardRef((e,t)=>{let{onValueChange:r,...o}=e,n=e.value!=null,s=ze(),c=Q(d=>d.search),i=Q(d=>d.selectedItemId),f=me();return l.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),l.createElement(ee.input,{ref:t,...o,"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:c,onChange:d=>{n||s.setState("search",d.target.value),r?.(d.target.value)}})}),zr=l.forwardRef((e,t)=>{let{children:r,label:o="Suggestions",...n}=e,s=l.useRef(null),c=l.useRef(null),i=Q(d=>d.selectedItemId),f=me();return l.useEffect(()=>{if(c.current&&s.current){let d=c.current,g=s.current,h,y=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let v=d.offsetHeight;g.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return y.observe(d),()=>{cancelAnimationFrame(h),y.unobserve(d)}}},[]),l.createElement(ee.div,{ref:pe(s,t),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":o,id:f.listId},we(e,d=>l.createElement("div",{ref:pe(c,f.listInnerRef),"cmdk-list-sizer":""},d)))}),Vr=l.forwardRef((e,t)=>{let{open:r,onOpenChange:o,overlayClassName:n,contentClassName:s,container:c,...i}=e;return l.createElement(Ut,{open:r,onOpenChange:o},l.createElement(Wt,{container:c},l.createElement(Xt,{"cmdk-overlay":"",className:n}),l.createElement(Zt,{"aria-label":e.label,"cmdk-dialog":"",className:s},l.createElement(ht,{ref:t,...i}))))}),$r=l.forwardRef((e,t)=>Q(r=>r.filtered.count===0)?l.createElement(ee.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),qr=l.forwardRef((e,t)=>{let{progress:r,children:o,label:n="Loading...",...s}=e;return l.createElement(ee.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},we(e,c=>l.createElement("div",{"aria-hidden":!0},c)))}),H=Object.assign(ht,{List:zr,Item:_r,Input:Mr,Group:Tr,Separator:Lr,Dialog:Vr,Empty:$r,Loading:qr});function Br(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function Kr(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function mt(e){let t=l.useRef(e);return se(()=>{t.current=e}),t}var se=typeof window>"u"?l.useEffect:l.useLayoutEffect;function ie(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Q(e){let t=ze(),r=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,r,r)}function xt(e,t,r,o=[]){let n=l.useRef(),s=me();return se(()=>{var c;let i=(()=>{var d;for(let g of r){if(typeof g=="string")return g.trim();if(typeof g=="object"&&"current"in g)return g.current?(d=g.current.textContent)==null?void 0:d.trim():n.current}})(),f=o.map(d=>d.trim());s.value(e,i,f),(c=t.current)==null||c.setAttribute(le,i),n.current=i}),n}var Hr=()=>{let[e,t]=l.useState(),r=ie(()=>new Map);return se(()=>{r.current.forEach(o=>o()),r.current=new Map},[e]),(o,n)=>{r.current.set(o,n),t({})}};function Gr(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function we({asChild:e,children:t},r){return e&&l.isValidElement(t)?l.cloneElement(Gr(t),{ref:t.ref},r(t.props.children)):r(t)}var Ur={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const vt=G.forwardRef(({className:e,...t},r)=>a.jsx(H,{ref:r,className:m("flex size-full flex-col rounded-md [&_[cmdk-label]]:hidden",e),...t}));vt.displayName=H.displayName;const bt=G.forwardRef(({wrapperClassName:e,className:t,...r},o)=>a.jsxs("div",{className:m("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(V,{name:"Search",size:16,className:m("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(H.Input,{ref:o,className:m("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})]}));bt.displayName=H.Input.displayName;const Ve=G.forwardRef(({className:e,...t},r)=>a.jsx(H.List,{ref:r,className:m("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}));Ve.displayName=H.List.displayName;const Wr=G.forwardRef((e,t)=>a.jsx(H.Loading,{ref:t,...e}));Wr.displayName=H.Loading.displayName;const $e=G.forwardRef((e,t)=>a.jsx(H.Empty,{ref:t,...e}));$e.displayName=H.Empty.displayName;const ye=G.forwardRef(({className:e,...t},r)=>a.jsx(H.Group,{ref:r,className:m("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}));ye.displayName=H.Group.displayName;const Ne=G.forwardRef(({className:e,...t},r)=>a.jsx(H.Item,{ref:r,className:m("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}));Ne.displayName=H.Item.displayName;function ge(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((o,n)=>ge(o,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 o=Object.keys(e),n=Object.keys(t);return o.length===n.length&&o.every(s=>s in t&&ge(e[s],t[s],r))}return!1}const ke={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}})},Xr=(e,t)=>l.forwardRef(({value:r,name:o,showErrorOnBlur:n,showErrorOnChange:s,validators:c,...i},f)=>{const{onChange:d,onBlur:g}=i,{control:h,formState:{errors:y,defaultValues:v},trigger:N,setValue:P,getValues:b}=Ze(),{submitCount:j}=Bt();if(!o)throw new Error(`[Field: ${e.displayName}] The name prop is required.`);const k=[...y[o]?.types?Object.values(y[o].types??[]):[]];k.length===0&&y[o]&&k.push("Invalid value"),l.useEffect(()=>{j>0&&N(o)},[i.required]),l.useEffect(()=>{i.errors&&i.errors.length>0&&N(o)},[o,i.errors,N]);const[$,T]=l.useState(!1);return l.useEffect(()=>{$&&P(o,r),T(!0)},[o,r]),r!==void 0&&!d&&console.warn(`[Field: ${o}] Value prop provided without onChange so it will be ignored. Use disabled/readOnly if you want to prevent changes.`),a.jsx(Kt,{control:h,name:o,defaultValue:r??i.defaultValue,disabled:i.disabled,render:({field:{onChange:O,onBlur:R,value:A,...L}})=>{const M=l.useCallback(w=>{n?N(o):R(),g&&g(w)},[R,n]),I=l.useCallback(w=>{if(d)Object.hasOwn(w,"target")?P(o,w.target.value):P(o,w),d(w);else{let D=w;(w instanceof Event||w.target instanceof HTMLElement)&&(D=w.target.value),P(o,D)}s===void 0&&n===void 0?j>0&&N(o):s&&N(o)},[A,s,n,j]),{ref:q}=L,U=w=>{typeof f=="function"?f(w):f&&(f.current=w),q(w)};return a.jsx(e,{...i,...L,value:A,onBlur:M,onChange:I,errors:k,ref:U})},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((O,R)=>[`_propError${R}`,()=>O]):[]):{},...c!==void 0?Object.fromEntries((Array.isArray(c)?c:[c]).map((O,R)=>[`customValidation${R}`,O])):{}}}})}),yt=({children:e,as:t,className:r})=>{const o=t??"p";return a.jsx(o,{className:m("font-sans text-sm font-normal leading-5 text-gray-600 dark:text-gray-500",r),children:e})},kt=({children:e})=>a.jsx("div",{className:"flex flex-col gap-2",children:e});var Re="Popover",[Ct]=Je(Re,[Ye]),xe=Ye(),[Zr,te]=Ct(Re),jt=e=>{const{__scopePopover:t,children:r,open:o,defaultOpen:n,onOpenChange:s,modal:c=!1}=e,i=xe(t),f=l.useRef(null),[d,g]=l.useState(!1),[h,y]=Qe({prop:o,defaultProp:n??!1,onChange:s,caller:Re});return a.jsx(Jt,{...i,children:a.jsx(Zr,{scope:t,contentId:ne(),triggerRef:f,open:h,onOpenChange:y,onOpenToggle:l.useCallback(()=>y(v=>!v),[y]),hasCustomAnchor:d,onCustomAnchorAdd:l.useCallback(()=>g(!0),[]),onCustomAnchorRemove:l.useCallback(()=>g(!1),[]),modal:c,children:r})})};jt.displayName=Re;var wt="PopoverAnchor",Nt=l.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=te(wt,r),s=xe(r),{onCustomAnchorAdd:c,onCustomAnchorRemove:i}=n;return l.useEffect(()=>(c(),()=>i()),[c,i]),a.jsx(et,{...s,...o,ref:t})});Nt.displayName=wt;var Rt="PopoverTrigger",Et=l.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=te(Rt,r),s=xe(r),c=Ce(t,n.triggerRef),i=a.jsx(he.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":Ot(n.open),...o,ref:c,onClick:ae(e.onClick,n.onOpenToggle)});return n.hasCustomAnchor?i:a.jsx(et,{asChild:!0,...s,children:i})});Et.displayName=Rt;var qe="PopoverPortal",[Jr,Qr]=Ct(qe,{forceMount:void 0}),St=e=>{const{__scopePopover:t,forceMount:r,children:o,container:n}=e,s=te(qe,t);return a.jsx(Jr,{scope:t,forceMount:r,children:a.jsx(Te,{present:r||s.open,children:a.jsx(Qt,{asChild:!0,container:n,children:o})})})};St.displayName=qe;var ce="PopoverContent",Pt=l.forwardRef((e,t)=>{const r=Qr(ce,e.__scopePopover),{forceMount:o=r.forceMount,...n}=e,s=te(ce,e.__scopePopover);return a.jsx(Te,{present:o||s.open,children:s.modal?a.jsx(ea,{...n,ref:t}):a.jsx(ta,{...n,ref:t})})});Pt.displayName=ce;var Yr=tr("PopoverContent.RemoveScroll"),ea=l.forwardRef((e,t)=>{const r=te(ce,e.__scopePopover),o=l.useRef(null),n=Ce(t,o),s=l.useRef(!1);return l.useEffect(()=>{const c=o.current;if(c)return Yt(c)},[]),a.jsx(er,{as:Yr,allowPinchZoom:!0,children:a.jsx(At,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,c=>{c.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,c=>{const i=c.detail.originalEvent,f=i.button===0&&i.ctrlKey===!0,d=i.button===2||f;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:ae(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),ta=l.forwardRef((e,t)=>{const r=te(ce,e.__scopePopover),o=l.useRef(!1),n=l.useRef(!1);return a.jsx(At,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(o.current||r.triggerRef.current?.focus(),s.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(o.current=!0,s.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const c=s.target;r.triggerRef.current?.contains(c)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&n.current&&s.preventDefault()}})}),At=l.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:g,...h}=e,y=te(ce,r),v=xe(r);return rr(),a.jsx(ar,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,onUnmountAutoFocus:s,children:a.jsx(nr,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:g,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:d,onDismiss:()=>y.onOpenChange(!1),children:a.jsx(sr,{"data-state":Ot(y.open),role:"dialog",id:y.contentId,...v,...h,ref:t,style:{...h.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)"}})})})}),It="PopoverClose",ra=l.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=te(It,r);return a.jsx(he.button,{type:"button",...o,ref:t,onClick:ae(e.onClick,()=>n.onOpenChange(!1))})});ra.displayName=It;var aa="PopoverArrow",na=l.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=xe(r);return a.jsx(or,{...n,...o,ref:t})});na.displayName=aa;function Ot(e){return e?"open":"closed"}var sa=jt,oa=Nt,la=Et,ia=St,da=Pt;const Dt=sa,ca=oa,ua=la,Ft=G.forwardRef(({align:e="center",sideOffset:t=4,className:r,...o},n)=>a.jsx(ia,{children:a.jsx(da,{align:e,sideOffset:t,className:m(["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,...o})})),fa=e=>typeof e=="string"?a.jsx(V,{name:e,size:16,className:m("text-gray-700 dark:text-gray-400")}):e&&a.jsx(e,{className:m("size-4","text-gray-700 dark:text-gray-400")}),Xe=({options:e=[],selectedValues:t,multiple:r,selectionIcon:o,selectionIconPosition:n,hasAnyIcon:s,toggleOption:c,tabIndex:i})=>a.jsx(a.Fragment,{children:e.map(f=>{const d=t.includes(f.value);return a.jsxs(Ne,{tabIndex:i,value:f.label,onSelect:()=>!f.disabled&&c(f.value),disabled:f.disabled,className:m("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":d,children:[o==="auto"&&(r?a.jsx("div",{className:m("flex size-4 items-center justify-center rounded-md border","border-gray-700 dark:border-gray-400",d&&"bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"),children:d&&a.jsx(V,{name:"Checkmark",size:16})}):a.jsx("div",{className:m("relative size-4 rounded-full border",d?"border-gray-900 dark:border-gray-400":"border-gray-800 dark:border-gray-400","bg-transparent dark:bg-transparent"),children:d&&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"})})),o==="checkmark"&&!(n==="right"&&s)&&a.jsx("div",{className:"size-4",children:n==="left"&&d&&a.jsx(V,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})}),fa(f.icon),a.jsx("span",{className:m("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}),o==="checkmark"&&n==="right"&&a.jsx("div",{className:"size-4",children:d&&a.jsx(V,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})})]},`favorite-${f.value}`)})}),ga=({searchable:e,commandListRef:t,multiple:r,selectedValues:o,selectionIcon:n,selectionIconPosition:s,options:c=[],toggleAll:i,toggleOption:f,favoriteOptions:d=[]})=>{const g=c.filter(v=>!v.disabled),h=c.some(v=>v.icon),y=Q(v=>v.search);return l.useEffect(()=>{t.current?.scrollTo({top:0,behavior:"instant"})},[t,y]),a.jsxs(a.Fragment,{children:[e&&a.jsx(bt,{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(Ve,{ref:t,tabIndex:e?void 0:0,children:[a.jsx($e,{className:"p-4 text-center text-[14px] font-normal leading-5 text-gray-700 dark:text-gray-400",children:"No results found."}),r&&y===""&&a.jsx(ye,{className:"pb-0",children:a.jsx(Ne,{value:"select-all",onSelect:i,disabled:!1,className:m("cursor-pointer","data-[selected=true]:bg-gray-100 dark:data-[selected=true]:bg-gray-900"),role:"option","aria-selected":o.length===g.length,children:a.jsxs("div",{className:"flex w-full items-center gap-2",children:[n==="auto"&&a.jsx("div",{className:m("flex size-4 items-center justify-center rounded-md border","border-gray-700 dark:border-gray-400",o.length===g.length&&"bg-gray-900 text-slate-50 dark:bg-gray-400 dark:text-black"),children:o.length===g.length&&a.jsx(V,{name:"Checkmark",size:16})}),n==="checkmark"&&!(s==="right"&&h)&&a.jsx("div",{className:"size-4",children:s==="left"&&o.length===g.length&&a.jsx(V,{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:o.length===g.length?"Deselect All":"Select All"}),n==="checkmark"&&s==="right"&&a.jsx("div",{className:"ml-auto size-4",children:o.length===g.length&&a.jsx(V,{name:"Checkmark",size:16,className:"text-gray-900 dark:text-gray-50"})})]})})}),a.jsxs(ye,{className:r&&y===""?"pt-0":void 0,children:[a.jsx(Xe,{options:d,selectedValues:o,multiple:r,selectionIcon:n,selectionIconPosition:s,hasAnyIcon:h,toggleOption:f,tabIndex:e?void 0:0}),d.length>0&&a.jsx("div",{className:"my-1 border-b border-gray-300 dark:border-gray-600"}),a.jsx(Xe,{options:c,selectedValues:o,multiple:r,selectionIcon:n,selectionIconPosition:s,hasAnyIcon:h,toggleOption:f,tabIndex:e?void 0:0})]})]})]})},pa=({selectedValues:e,options:t=[],multiple:r,searchable:o,placeholder:n,handleClear:s})=>{const c=i=>typeof i=="string"?a.jsx(V,{name:i,size:16}):i&&a.jsx(i,{className:"size-4"});return e.length===0?a.jsxs("div",{className:m("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}),o?a.jsx(V,{name:"CaretSort",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"}):a.jsx(V,{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:m("max-w-full truncate text-gray-900 dark:text-gray-50",!r&&"flex items-center gap-2"),children:e.map((i,f)=>{const d=t.find(g=>g.value===i);return r?a.jsx("span",{className:m("text-[14px] font-normal leading-5",f!==e.length-1&&"mr-1"),children:f!==e.length-1?`${d?.label},`:d?.label},i):a.jsxs(G.Fragment,{children:[c(d?.icon),a.jsx("span",{className:"truncate text-[14px] font-normal leading-5",children:d?.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(),s()},className:"size-4 p-0",children:a.jsx(V,{name:"XmarkLight",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})}),o?a.jsx(V,{name:"CaretSort",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"}):a.jsx(V,{name:"ChevronDown",size:16,className:"cursor-pointer text-gray-700 dark:text-gray-400"})]})]})};function ha({options:e=[],multiple:t=!1,defaultValue:r,value:o,onChange:n}){const s=l.useRef(!1),c=l.useRef(null),[i,f]=l.useState(!1),[d,g]=l.useState(()=>{const b=o??r??[];return b===""?[]:Array.isArray(b)?b:[b]});l.useEffect(()=>{if(s.current){s.current=!1;return}const b=o??r??[];g(b===""?[]:Array.isArray(b)?b:[b])},[o]);const h=l.useCallback(b=>{f(b)},[]),y=l.useCallback(b=>{s.current=!0;let j;t?j=d.includes(b)?d.filter(k=>k!==b):[...d,b]:(j=d[0]===b?[]:[b],f(!1)),g(j),n?.(t?j:j[0]??"")},[t,d,e,n]),v=l.useCallback(()=>{s.current=!0,g([]),n?.(t?[]:"")},[t,n]),N=l.useCallback(()=>{s.current=!0;const b=e.filter(k=>!k.disabled).map(k=>k.value),j=d.length===b.length?[]:b;g(j),n?.(t?j:j[0])},[e,d,t,n]),P=l.useRef(t);return l.useEffect(()=>{if(P.current!==t){if(P.current=t,!t&&d.length>1){s.current=!0,g([d[0]]),n?.(d[0]);return}d.length>0&&(s.current=!0,n?.(t?[d[0]]:d[0]))}},[t]),{selectedValues:d,isPopoverOpen:i,commandListRef:c,toggleOption:y,handleClear:v,toggleAll:N,handleOpenChange:h}}const ma=G.forwardRef(({options:e=[],favoriteOptions:t=[],defaultValue:r,value:o,onChange:n,onBlur:s,id:c,name:i,label:f,required:d,disabled:g,errors:h=[],warnings:y=[],multiple:v,selectionIcon:N="auto",selectionIconPosition:P="left",searchable:b,description:j,placeholder:k,className:$,contentClassName:T,contentAlign:O="start",...R},A)=>{const L=l.useId(),M=c??`${L}-select`,{selectedValues:I,isPopoverOpen:q,commandListRef:U,toggleOption:w,handleClear:D,toggleAll:B,handleOpenChange:W}=ha({options:e,multiple:v,defaultValue:r,value:o,onChange:n}),J=l.useCallback(z=>{q||s?.(z)},[s,q]);return a.jsxs(kt,{children:[f&&a.jsx(Me,{htmlFor:M,required:d,disabled:g,hasError:h.length>0,inline:!1,onClick:z=>{z.preventDefault(),z.target.control?.focus()},children:f}),a.jsxs(Dt,{open:q,onOpenChange:z=>{W(z),!z&&document.activeElement?.id!==M&&s?.({target:{}})},children:[a.jsx(ua,{asChild:!0,children:a.jsx(hr,{id:M,name:i,type:"button",role:"combobox",onBlur:J,disabled:g,"aria-invalid":h.length>0,"aria-label":f?void 0:v?"Multi select":"Select","aria-required":d,"aria-expanded":q,className:m("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"],$),...R,ref:A,children:a.jsx(pa,{selectedValues:I,options:[...t,...e],multiple:v,searchable:b,placeholder:k,handleClear:D})})}),a.jsx(Ft,{align:O,onEscapeKeyDown:z=>{z.preventDefault(),W(!1)},className:T,children:a.jsx(vt,{defaultValue:!v&&I[0]?e.find(z=>z.value===I[0])?.label:void 0,children:a.jsx(ga,{favoriteOptions:t,searchable:b,commandListRef:U,multiple:v,selectedValues:I,selectionIcon:N,selectionIconPosition:P,options:e,toggleAll:B,toggleOption:w})})})]}),j&&a.jsx(yt,{children:j}),y.length>0&&a.jsx(de,{messages:y,type:"warning"}),h.length>0&&a.jsx(de,{messages:h,type:"error"})]})}),xa=Xr(ma);xa.displayName="SelectField";function _t(...e){return gr(Ht(e))}const va=_t("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"),Be=l.forwardRef(({className:e,type:t,...r},o)=>a.jsx("input",{type:t,className:_t(va,e),ref:o,...r}));Be.displayName="Input";function Ae(e,t){const r=Object.getOwnPropertyDescriptor(e,"value")?.set,o=Object.getPrototypeOf(e),n=Object.getOwnPropertyDescriptor(o,"value")?.set;r&&r!==n?n?.call(e,t):r?.call(e,t)}function be(e,t,r="blur"){return e.reduce((o,n)=>typeof n=="function"?r==="blur"||r==="all"?n(o):o:(n.options?.trigger??"blur")!==r&&r!=="all"?o:n.options?.if===void 0||n.options.if?n.transformer(o):o,t)}function Tt({transformers:e,children:t}){const o=Ze()?.setValue;return l.useEffect(()=>{const n=t.props.value,s=be(e,n,"all");ge(s,n)||(typeof o=="function"?o(t.props.name,s):t.props.onChange?.({target:{value:s}}))},[e,o]),G.cloneElement(t,{...t.props,onChange:n=>{const s=be(e,n.target.value,"change");s!==n.target.value&&o&&(o(t.props.name,s),Ae(n.target,s)),t.props.onChange?.(n)},onBlur:n=>{t.props.onBlur?.(n);const s=n.target,c=be(e,s.value,"blur");if(!ge(c,s.value)){Ae(s,c);const i=new Event("change",{bubbles:!0});s.dispatchEvent(i)}},onKeyDown:n=>{if(t.props.onKeyDown?.(n),n.key==="Enter"){const s=n.target,c=be(e,s.value,"keyDown");if(!ge(c,s.value)){Ae(s,c);const i=new Event("change",{bubbles:!0});s.dispatchEvent(i)}}}})}const ba=G.forwardRef(({id:e,name:t,value:r,className:o,isLoading:n,haveFetchError:s,disabled:c,onChange:i,onBlur:f,onClick:d,selectedOption:g,optionsLength:h,handleOpenChange:y,onKeyDown:v,onMouseDown:N,placeholder:P,hasError:b,label:j,required:k,isPopoverOpen:$,maxLength:T,handlePaste:O,onPaste:R,...A},L)=>{const[M,I]=l.useState(!1),q=ur("(hover: hover) and (pointer: fine)"),U=l.useMemo(()=>[ke.trimOnBlur(),ke.trimOnEnter()],[]);return a.jsxs("div",{className:m("group relative"),children:[a.jsx(Tt,{transformers:U,children:a.jsx(H.Input,{asChild:!0,children:a.jsx(Be,{id:e,name:t,value:r,className:m("pr-9",o),disabled:c,onChange:i,onBlur:f,onClick:w=>{const D=w.target;!(n||s)&&!g&&D.value!==""&&y?.(!0),d?.(w)},onKeyDown:w=>{v?.(w);const D=["ArrowUp","ArrowDown","Enter"].includes(w.key);if(w.key==="Enter"&&$&&h===0){y?.(!1),w.preventDefault();return}D&&$&&h>0||w.stopPropagation()},onMouseDown:w=>{const D=w.target;D.contains(document.activeElement)||requestAnimationFrame(()=>{D.select()}),N?.(w)},onPaste:w=>{O?.(w),R?.(w)},placeholder:P,"aria-invalid":b,"aria-label":j?void 0:"Id Autocomplete","aria-required":k,"aria-expanded":$,maxLength:T,...A,ref:L})})}),a.jsxs("div",{className:m("absolute right-3 top-1/2 flex size-4 -translate-y-1/2 items-center",!n&&!s&&!g&&"pointer-events-none"),children:[n&&a.jsx(V,{name:"Reload",size:16,className:m("animate-spin text-gray-500 dark:text-gray-600")}),s&&a.jsx(Ie,{children:a.jsx(Oe,{content:"Network error!",children:a.jsx(V,{name:"Error",size:16,className:m("text-red-900")})})}),g&&!n&&!s&&a.jsx(Ie,{children:a.jsx(Oe,{content:"Copied!",open:M,triggerAsChild:!0,children:a.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(g.value).then(()=>{I(!0),setTimeout(()=>I(!1),2e3)}).catch(w=>{console.error("Failed to copy value: ",w)})},className:m("focus-visible:outline-none [&_svg]:pointer-events-none",q&&"opacity-0 transition-opacity duration-500 group-hover:opacity-100"),children:a.jsx(V,{name:"Copy",size:16,className:m("text-gray-500 dark:text-gray-600")})})})})]})]})}),ya=({customIcon:e,asPlaceholder:t})=>typeof e=="string"?a.jsx(V,{name:e,size:24,className:m("shrink-0",t?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300")}):G.isValidElement(e)?a.jsx("div",{className:"size-6 shrink-0 overflow-hidden",children:e}):null,ka=({isLoadingSelectedOption:e,handleFetchSelectedOption:t,isFetchSelectedOptionSync:r,value:o})=>a.jsx("div",{children:a.jsx("button",{type:"button",disabled:e||r,onClick:()=>{!e&&!r&&t(o)},className:m("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(V,{name:r?"Checkmark":"Reload",size:16,className:m("text-gray-500 dark:text-gray-600",e&&"animate-spin",r&&"animate-in fade-in duration-500")})})}),_e=({variant:e="withValue",icon:t,title:r="Title not available",path:o="Path not available",value:n,description:s="Description not available",asPlaceholder:c,showValue:i=!0,isLoadingSelectedOption:f,handleFetchSelectedOption:d,isFetchSelectedOptionSync:g,className:h,placeholderIcon:y="PowerhouseLogoSmall",...v})=>{const N=()=>a.jsx("div",{className:m("flex w-full items-center"),children:a.jsx("span",{className:m("truncate text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:n})}),P=(b=!0)=>a.jsxs("div",{className:m("flex w-full flex-col gap-1"),children:[a.jsxs("div",{className:m("flex gap-2"),children:[a.jsx(ya,{customIcon:c?y:t,asPlaceholder:c}),a.jsxs("div",{className:m("flex min-w-0 grow flex-col gap-[-2px]"),children:[a.jsx("span",{className:m("truncate text-sm font-bold leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300"),children:r}),!i&&typeof o=="object"?a.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:m("truncate text-xs leading-5 text-blue-900 hover:underline focus-visible:outline-none"),children:o.text}):a.jsx("span",{className:m("truncate text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:typeof o=="object"?o.text:o})]}),c===!1&&d&&a.jsx(ka,{isLoadingSelectedOption:f,handleFetchSelectedOption:d,isFetchSelectedOptionSync:g,value:n})]}),i&&a.jsx("div",{className:m("flex max-w-full items-center"),children:a.jsx("span",{className:m("truncate text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:n})}),b&&a.jsx("div",{className:m("flex flex-col"),children:a.jsx("p",{className:m("line-clamp-2 text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-900 dark:text-gray-300"),children:s})}),b&&"agentType"in v&&typeof v.agentType=="string"&&a.jsx("div",{className:m("flex max-w-full items-center justify-end"),children:a.jsx("span",{className:m("truncate text-xs leading-5",c?"text-gray-400 dark:text-gray-700":"text-gray-500 dark:text-gray-600"),children:v.agentType})})]});return a.jsxs("div",{className:m("w-full max-w-full rounded-md bg-transparent px-3 pb-2",e==="withValue"?"pt-2":"pt-3",h),children:[e==="withValue"&&N(),e==="withValueAndTitle"&&P(!1),e==="withValueTitleAndDescription"&&P()]})},Ca=({variant:e,commandListRef:t,selectedValue:r,options:o=[],toggleOption:n,renderOption:s,previewPlaceholder:c})=>{const i=Q(d=>d.search),f=c||{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(Ve,{ref:t,children:[a.jsx($e,{className:m("h-full p-1"),children:s?s(f,{asPlaceholder:!0,showValue:!0,className:m("pb-0")}):a.jsx(_e,{variant:e,icon:f.icon,title:f.title,path:f.path,value:f.value,description:f.description,asPlaceholder:!0,className:m("pb-0")})}),a.jsx(ye,{className:m("px-1"),children:o.map(d=>{const g=r===d.value;return a.jsx(Ne,{value:d.value,onSelect:()=>n?.(d.value),className:m("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:s?s(d,{asPlaceholder:!1,showValue:!0}):a.jsx(_e,{variant:e,...d})},d.value)})})]})},ja=l.createContext({}),wa=()=>l.useContext(ja);function Na({autoComplete:e,defaultValue:t,value:r,isOpenByDefault:o,initialOptions:n,onChange:s,onBlur:c,fetchOptions:i,fetchSelectedOption:f}){const d=wa(),g=l.useRef(!1),h=l.useRef(!1),y=l.useRef(null),[v,N]=l.useState(o??!1),[P,b]=l.useState(n??[]),[j,k]=l.useState(!1),[$,T]=l.useState(!1),[O,R]=l.useState(!1),[A,L]=l.useState(r??t??""),[M,I]=l.useState(void 0),[q,U]=l.useState(""),[w,D]=l.useState(!1),B=l.useCallback(()=>{R(!1),k(!1),T(!1),N(!1)},[]),W=fr(l.useCallback(x=>{if(!(!e||!i)){if(x===""){B(),b([]),L(""),I(void 0);return}R(!1),k(!0);try{const p=i(x,d);Promise.resolve(p).then(E=>{b(E);const S=E.find(F=>F.value===x);S?(I(S),N(!1)):(I(void 0),N(!0)),k(!1)}).catch(()=>{R(!0),k(!1)})}catch{R(!0),k(!1)}}},[B,e,i,d])),J=l.useCallback(x=>{if(!(!e||!f)){T(!0);try{const p=f(x),E=p instanceof Promise;Promise.resolve(p).then(S=>{S?(I(S),b(F=>{const _=F.findIndex(X=>X.value===x);if(_!==-1){const X=[...F];return X[_]=S,X}return F})):(B(),b([]),L(""),I(void 0)),T(!1),E||(D(!0),setTimeout(()=>{D(!1)},1500))}).catch(()=>{T(!1)})}catch{T(!1)}}},[B,e,f]),z=l.useCallback(x=>{x||U(P[0]?.value??""),N(x)},[P]),K=l.useCallback(x=>{g.current=!1,h.current=!0,L(x),I(P.find(p=>p.value===x)),B(),s?.(x)},[s,B,P]),re=l.useCallback(x=>{const p=x.target.value;g.current=!0,L(p),I(void 0),s?.(p)},[s]),oe=l.useCallback(x=>{U(x)},[]),u=l.useCallback(x=>{v||c?.(x)},[c,v]),C=l.useCallback(x=>{const p=x.clipboardData.getData("text"),E=p.trim();if(p!==E){x.preventDefault();const S=x.currentTarget,F=S.selectionStart||0,_=S.selectionEnd||0,X=S.value,ue=X.substring(0,F)+E+X.substring(_);s?.(ue),requestAnimationFrame(()=>{const ve=F+E.length;S.setSelectionRange(ve,ve),W(ue)})}else p===A&&W(A)},[A,W,s]);return l.useEffect(()=>{e?g.current&&W(A):(B(),b([]),L(""),I(void 0))},[e,A,W,B]),l.useEffect(()=>{h.current||(g.current=!1,L(r??t??""),I(void 0)),h.current=!1},[r]),l.useEffect(()=>{if(n?.length&&A){const x=n.find(p=>p.value===A);x&&I(x)}},[]),{selectedValue:A,selectedOption:M,isPopoverOpen:v,commandListRef:y,options:P,isLoading:j,isLoadingSelectedOption:$,haveFetchError:O,commandValue:q,isFetchSelectedOptionSync:w,toggleOption:K,handleOpenChange:z,onTriggerBlur:u,handleChange:re,handleCommandValue:oe,handleFetchSelectedOption:J,handlePaste:C}}const Ra=G.forwardRef(({id:e,name:t,className:r,label:o,description:n,value:s,defaultValue:c,disabled:i,placeholder:f,required:d,errors:g,warnings:h,onChange:y,onBlur:v,onClick:N,onKeyDown:P,onMouseDown:b,autoComplete:j=!0,variant:k="withValue",maxLength:$,fetchOptionsCallback:T,fetchSelectedOptionCallback:O,isOpenByDefault:R,initialOptions:A,renderOption:L,previewPlaceholder:M,...I},q)=>{const U=l.useId(),w=e??`${U}-id-autocomplete`,D=l.useRef(null),B=Z=>{D.current=Z,typeof q=="function"?q(Z):q&&(q.current=Z)},W=Array.isArray(h)&&h.length>0,J=Array.isArray(g)&&g.length>0,{selectedValue:z,selectedOption:K,isPopoverOpen:re,commandListRef:oe,options:u,isLoading:C,isLoadingSelectedOption:x,haveFetchError:p,commandValue:E,isFetchSelectedOptionSync:S,toggleOption:F,handleOpenChange:_,onTriggerBlur:X,handleChange:ue,handleCommandValue:ve,handleFetchSelectedOption:Ke,handlePaste:Lt}=Na({autoComplete:j,defaultValue:c,value:s,isOpenByDefault:R,initialOptions:A,onChange:y,onBlur:v,fetchOptions:T,fetchSelectedOption:O}),Mt=Z=>{F(Z),D.current?.focus()},zt=k==="withValueAndTitle"||k==="withValueTitleAndDescription",Vt=l.useMemo(()=>[ke.trimOnBlur(),ke.trimOnEnter()],[]);return a.jsxs(kt,{children:[!!o&&a.jsx(Me,{htmlFor:w,disabled:i,hasError:J,required:d,onClick:Z=>{Z.preventDefault(),Z.target.control?.focus()},children:o}),j&&T?a.jsx(Dt,{open:re,onOpenChange:_,children:a.jsxs(H,{shouldFilter:!1,value:E,onValueChange:ve,className:m("dark:bg-charcoal-900 bg-gray-100"),children:[a.jsx(ca,{asChild:!0,children:a.jsx(ba,{id:w,name:t,value:z,className:r,isLoading:C,haveFetchError:p,disabled:i,onChange:ue,onBlur:X,onClick:N,selectedOption:K,optionsLength:u.length,handleOpenChange:_,onKeyDown:P,onMouseDown:b,placeholder:f,hasError:J,label:o,required:d,isPopoverOpen:re,maxLength:$,handlePaste:Lt,...I,ref:B})}),zt&&(L?L(K===void 0&&M?{...M}:{...K,value:K?.value??""},{asPlaceholder:K===void 0,showValue:!1,isLoadingSelectedOption:x,handleFetchSelectedOption:O?Ke:void 0,isFetchSelectedOptionSync:S,className:m("rounded-t-none pt-2")}):a.jsx(_e,{variant:k,icon:K?.icon??M?.icon,title:K?.title??M?.title,path:K?.path??M?.path,value:K?.value??M?.value??"",description:K?.description??M?.description,asPlaceholder:K===void 0,showValue:!1,isLoadingSelectedOption:x,handleFetchSelectedOption:O?Ke:void 0,isFetchSelectedOptionSync:S,className:m("rounded-t-none pt-2")})),a.jsx(Ft,{align:"start",onOpenAutoFocus:Z=>Z.preventDefault(),onInteractOutside:Z=>{Z.target instanceof Element&&Z.target.id===w&&Z.preventDefault()},children:a.jsx(Ca,{variant:k,commandListRef:oe,selectedValue:z,options:u,toggleOption:Mt,renderOption:L,previewPlaceholder:M})})]})}):a.jsx(Tt,{transformers:Vt,children:a.jsx(Be,{id:w,name:t,value:z,className:r,disabled:i,onChange:ue,onBlur:v,onClick:N,onMouseDown:b,placeholder:f,"aria-invalid":J,"aria-label":o?void 0:"Id Autocomplete","aria-required":d,maxLength:$,...I,ref:B})}),!!n&&a.jsx(yt,{children:n}),W&&a.jsx(de,{messages:h,type:"warning"}),J&&a.jsx(de,{messages:g,type:"error"})]})});Ra.displayName="IdAutocomplete";export{jr as C,Be as I,Dt as P,ma as S,ua as a,Ft as b,Ra as c};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import{o as y,s as c,e as k,a as N,_ as ae,d as C,u as Ue,b as He}from"./zod-9j67vCAu.js";import{c as v,a as Me,i as je,B as Ge,b as ke,d as ze,e as $e,f as Ve,g as Je,h as de,j as Qe,l as We}from"./document_model-Dc-BTYKH.js";import{a as Ye,p as Ke,G as Xe}from"./graphql-DwmBvzSo.js";import{c as H,g as Ze}from"./react-DQSxOgtG.js";function er(e,r){for(var i=0;i<r.length;i++){const t=r[i];if(typeof t!="string"&&!Array.isArray(t)){for(const s in t)if(s!=="default"&&!(s in e)){const a=Object.getOwnPropertyDescriptor(t,s);a&&Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const rr="phdd",tr=e=>e!=null;He().refine(e=>tr(e));const nr=ae(["Internal","MatrixConnect","PullResponder","RESTWebhook","SecureConnect","SwitchboardPush"]),ir=ae(["PullResponder"]);function le(){return y({documentType:c(),id:c(),name:c(),parentFolder:c().nullish()})}function ue(){return y({id:c(),name:c(),parentFolder:c().nullish()})}function ce(){return y({listener:me()})}function pe(){return y({trigger:we()})}function fe(){return y({srcId:c(),targetId:c(),targetName:c().nullish(),targetParentFolder:c().nullish()})}function he(){return y({id:c()})}function or(){return y({__typename:N("DocumentDriveLocalState").optional(),availableOffline:k(),listeners:C(me()),sharingType:c().nullable(),triggers:C(we())})}function sr(){return y({__typename:N("DocumentDriveState").optional(),icon:c().nullable(),name:c(),nodes:C(cr())})}function ar(){return y({__typename:N("FileNode").optional(),documentType:c(),id:c(),kind:c(),name:c(),parentFolder:c().nullable()})}function dr(){return y({__typename:N("FolderNode").optional(),id:c(),kind:c(),name:c(),parentFolder:c().nullable()})}function me(){return y({__typename:N("Listener").optional(),block:k(),callInfo:lr().nullable(),filter:ur(),label:c().nullable(),listenerId:c(),system:k()})}function lr(){return y({__typename:N("ListenerCallInfo").optional(),data:c().nullable(),name:c().nullable(),transmitterType:nr.nullable()})}function ur(){return y({__typename:N("ListenerFilter").optional(),branch:C(c()).nullable(),documentId:C(c()).nullable(),documentType:C(c()),scope:C(c()).nullable()})}function ye(){return y({srcFolder:c(),targetParentFolder:c().nullish()})}function cr(){return Ue([ar(),dr()])}function pr(){return y({__typename:N("PullResponderTriggerData").optional(),interval:c(),listenerId:c(),url:c()})}function ge(){return y({listenerId:c()})}function be(){return y({triggerId:c()})}function Ee(){return y({availableOffline:k()})}function Te(){return y({icon:c()})}function De(){return y({name:c()})}function ve(){return y({type:c()})}function we(){return y({__typename:N("Trigger").optional(),data:fr().nullable(),id:c(),type:ir})}function fr(){return pr()}function Ie(){return y({documentType:c().nullish(),id:c(),name:c().nullish(),parentFolder:c().nullish()})}function Se(){return y({id:c(),name:c().nullish(),parentFolder:c().nullish()})}function hr(e){return e&&typeof e=="object"&&"synchronizationUnits"in e?v("ADD_FILE",{...e},void 0,void 0,"global"):v("ADD_FILE",{...e},void 0,le,"global")}const mr=e=>v("ADD_FOLDER",{...e},void 0,ue,"global"),yr=e=>v("DELETE_NODE",{...e},void 0,he,"global"),gr=e=>v("UPDATE_FILE",{...e},void 0,Ie,"global"),br=e=>v("UPDATE_NODE",{...e},void 0,Se,"global"),Er=e=>v("COPY_NODE",{...e},void 0,fe,"global"),Tr=e=>v("MOVE_NODE",{...e},void 0,ye,"global"),Dr=e=>v("SET_DRIVE_NAME",{...e},void 0,De,"global"),vr=e=>v("SET_DRIVE_ICON",{...e},void 0,Te,"global"),wr=e=>v("SET_SHARING_TYPE",{...e},void 0,ve,"local"),Ir=e=>v("SET_AVAILABLE_OFFLINE",{...e},void 0,Ee,"local"),Sr=e=>v("ADD_LISTENER",{...e},void 0,ce,"local"),_r=e=>v("REMOVE_LISTENER",{...e},void 0,ge,"local"),Ar=e=>v("ADD_TRIGGER",{...e},void 0,pe,"local"),Nr=e=>v("REMOVE_TRIGGER",{...e},void 0,be,"local"),Or=Object.freeze(Object.defineProperty({__proto__:null,addFile:hr,addFolder:mr,addListener:Sr,addTrigger:Ar,copyNode:Er,deleteNode:yr,moveNode:Tr,removeListener:_r,removeTrigger:Nr,setAvailableOffline:Ir,setDriveIcon:vr,setDriveName:Dr,setSharingType:wr,updateFile:gr,updateNode:br},Symbol.toStringTag,{value:"Module"})),Fr={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 {
|
|
2
|
+
id: String!
|
|
3
|
+
name: String!
|
|
4
|
+
kind: String!
|
|
5
|
+
parentFolder: String
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type FileNode {
|
|
9
|
+
id: String!
|
|
10
|
+
name: String!
|
|
11
|
+
kind: String!
|
|
12
|
+
documentType: String!
|
|
13
|
+
parentFolder: String
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
union Node = FolderNode | FileNode
|
|
17
|
+
|
|
18
|
+
type DocumentDriveState {
|
|
19
|
+
name: String!
|
|
20
|
+
nodes: [Node!]!
|
|
21
|
+
icon: String
|
|
22
|
+
}`,initialValue:'"{\\"name\\":\\"\\",\\"nodes\\":[],\\"icon\\":null}"',examples:[]},local:{schema:`type ListenerFilter {
|
|
23
|
+
documentType: [String!]!
|
|
24
|
+
documentId: [ID!]
|
|
25
|
+
scope: [String!]
|
|
26
|
+
branch: [String!]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
enum TransmitterType {
|
|
30
|
+
Internal,
|
|
31
|
+
SwitchboardPush,
|
|
32
|
+
PullResponder,
|
|
33
|
+
SecureConnect,
|
|
34
|
+
MatrixConnect,
|
|
35
|
+
RESTWebhook
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type ListenerCallInfo {
|
|
39
|
+
transmitterType: TransmitterType
|
|
40
|
+
name: String
|
|
41
|
+
data: String
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type Listener {
|
|
45
|
+
listenerId: ID!
|
|
46
|
+
label: String
|
|
47
|
+
block: Boolean!
|
|
48
|
+
system: Boolean!
|
|
49
|
+
filter: ListenerFilter!
|
|
50
|
+
callInfo: ListenerCallInfo
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
enum TriggerType {
|
|
54
|
+
PullResponder
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type PullResponderTriggerData {
|
|
58
|
+
listenerId: ID!
|
|
59
|
+
url: String!
|
|
60
|
+
interval: String!
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
union TriggerData = PullResponderTriggerData
|
|
64
|
+
|
|
65
|
+
type Trigger {
|
|
66
|
+
id: ID!
|
|
67
|
+
type: TriggerType!
|
|
68
|
+
data: TriggerData
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type DocumentDriveLocalState{
|
|
72
|
+
sharingType: String
|
|
73
|
+
listeners: [Listener!]!
|
|
74
|
+
triggers: [Trigger!]!
|
|
75
|
+
availableOffline: Boolean!
|
|
76
|
+
}`,initialValue:'"{ \\"listeners\\": [], \\"triggers\\": [], \\"sharingType\\": \\"private\\", \\"availableOffline\\": false}"',examples:[]}},modules:[{id:"GRzuvv78tBvmB6ciitokLfonNHA=",name:"Node",description:"",operations:[{id:"7xiTdxonc9yEASR8sfV/KnbSV10=",name:"ADD_FILE",description:"",schema:`input AddFileInput {
|
|
77
|
+
id: ID!
|
|
78
|
+
name: String!
|
|
79
|
+
documentType: String!
|
|
80
|
+
parentFolder: ID
|
|
81
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"4lzNMMKKdIAtEU6i12xLgi9hp+U=",name:"ADD_FOLDER",description:"",schema:`input AddFolderInput {
|
|
82
|
+
id: ID!
|
|
83
|
+
name: String!
|
|
84
|
+
parentFolder: ID
|
|
85
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"53jH2/3TWTTcgCJiv2C+BmuC6i0=",name:"DELETE_NODE",description:"",schema:`input DeleteNodeInput {
|
|
86
|
+
id: ID!
|
|
87
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"pNn+Y1/HVq/GNMk7t0u3g3gtMLE=",name:"UPDATE_FILE",description:"",schema:`input UpdateFileInput {
|
|
88
|
+
id: ID!
|
|
89
|
+
parentFolder: ID
|
|
90
|
+
name: String
|
|
91
|
+
documentType: String
|
|
92
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"P0x1M8Mnt+Q/+9nggkwgVbfybsc=",name:"UPDATE_NODE",description:"",schema:`input UpdateNodeInput {
|
|
93
|
+
id: ID!
|
|
94
|
+
parentFolder: ID
|
|
95
|
+
name: String
|
|
96
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"vnQ7OB5b3wGLgjhbgJqAIpA+JLE=",name:"COPY_NODE",description:"",schema:`input CopyNodeInput {
|
|
97
|
+
srcId: ID!
|
|
98
|
+
targetId: ID!
|
|
99
|
+
targetName: String
|
|
100
|
+
targetParentFolder: ID
|
|
101
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"VNyiD/sNGzk6k9A1Qe7s8dmrJxA=",name:"MOVE_NODE",description:"",schema:`input MoveNodeInput {
|
|
102
|
+
srcFolder: ID!
|
|
103
|
+
targetParentFolder: ID
|
|
104
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"}]},{id:"0dHwHlxOM9x0vMZ+gLnKxf2qTEo=",name:"Drive",description:"",operations:[{id:"qGCiPGpTt/cyz3HzyrBn92z1dsU=",name:"SET_DRIVE_NAME",description:"",schema:`input SetDriveNameInput {
|
|
105
|
+
name: String!
|
|
106
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"qGCiPGpTt/cyz3HzyrBn92z30dsU=",name:"SET_DRIVE_ICON",description:"",schema:`input SetDriveIconInput {
|
|
107
|
+
icon: String!
|
|
108
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"qGCiPGpTt/cyz3HzyrBn92z2dsU=",name:"SET_SHARING_TYPE",description:"",schema:`input SetSharingTypeInput {
|
|
109
|
+
type: String!
|
|
110
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z3dsU=",name:"SET_AVAILABLE_OFFLINE",description:"",schema:`input SetAvailableOfflineInput {
|
|
111
|
+
availableOffline: Boolean!
|
|
112
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z9dsU=",name:"ADD_LISTENER",description:"",schema:`input AddListenerInput {
|
|
113
|
+
listener: Listener!
|
|
114
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z10dsU=",name:"REMOVE_LISTENER",description:"",schema:`input RemoveListenerInput {
|
|
115
|
+
listenerId: String!
|
|
116
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z20dsU=",name:"ADD_TRIGGER",description:"",schema:`input AddTriggerInput {
|
|
117
|
+
trigger: Trigger!
|
|
118
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z30dsU=",name:"REMOVE_TRIGGER",description:"",schema:`input RemoveTriggerInput {
|
|
119
|
+
triggerId: String!
|
|
120
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"}]}]}]},_e="powerhouse/document-drive",F={setDriveNameOperation(e,r,i){e.name=r.input.name},setDriveIconOperation(e,r,i){e.icon=r.input.icon},setSharingTypeOperation(e,r,i){e.sharingType=r.input.type},setAvailableOfflineOperation(e,r,i){e.availableOffline=r.input.availableOffline},addListenerOperation(e,r,i){if(e.listeners.find(t=>t.listenerId===r.input.listener.listenerId))throw new Error(`A listener with Id: ${r.input.listener.listenerId} already exists`);e.listeners.push(r.input.listener)},removeListenerOperation(e,r,i){e.listeners=e.listeners.filter(t=>t.listenerId!==r.input.listenerId)},addTriggerOperation(e,r,i){if(e.triggers.find(t=>t.id===r.input.trigger.id))throw new Error(`A trigger with Id: ${r.input.trigger.id} already exists`);e.triggers.push(r.input.trigger)},removeTriggerOperation(e,r,i){e.triggers=e.triggers.filter(t=>t.id!==r.input.triggerId)}};function te(e){return e.kind==="file"}function Rr(e){return e.kind==="folder"}function z(e,r){const i=r.filter(s=>s.parentFolder===e.id),t=i.map(s=>z(s,r));return[...i,...t.flat()]}function ht(e,r,i){const t=i.find(l=>l.id===e.srcId);if(!t)throw new Error(`Node with id ${e.srcId} not found`);const s=[{...t,name:e.targetName||t.name,parentFolder:e.targetParentFolder||null},...z(t,i)],a={};e.targetParentFolder&&(a[e.targetParentFolder]=e.targetParentFolder);const u=l=>{let b=a[l.id];if(!b){const E=l.id;b=r(l),a[E]=b}return b};return s.map(l=>({srcId:l.id,targetId:u(l),targetName:l.name,targetParentFolder:l.parentFolder?a[l.parentFolder]:null}))}function Pr(e,r){let i=0;const t=new RegExp(`^${Cr(r)} \\(copy\\)(?: (\\d+))?$`);for(const s of e){const a=s.match(t);if(a){const u=a[1]?parseInt(a[1],10):1;u>i&&(i=u)}}return i+1}function Cr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(e){const{nodes:r,targetParentFolder:i,srcName:t}=e,s=r.filter(d=>i===""?d.parentFolder===null:d.parentFolder===i).map(d=>d.name);return s.includes(t)?`${t} (copy) ${Pr(s,t)}`:t}const M=e=>/^[a-zA-Z0-9-_.\s()]+$/.test(e),P={addFileOperation(e,r,i){if(e.nodes.find(a=>a.id===r.input.id))throw new Error(`Node with id ${r.input.id} already exists!`);if(!M(r.input.name))throw new Error(`Invalid name: '${r.input.name}'. Names must be valid URL characters.`);const t=L({nodes:e.nodes,srcName:r.input.name,targetParentFolder:r.input.parentFolder||null}),s={id:r.input.id,name:t,kind:"file",parentFolder:r.input.parentFolder??null,documentType:r.input.documentType};e.nodes.push(s),e.nodes.sort((a,u)=>a.id.localeCompare(u.id)),i?.({type:"CREATE_CHILD_DOCUMENT",input:{id:r.input.id,documentType:r.input.documentType}})},addFolderOperation(e,r){if(e.nodes.find(t=>t.id===r.input.id))throw new Error(`Node with id ${r.input.id} already exists!`);if(!M(r.input.name))throw new Error(`Invalid name: '${r.input.name}'. Names must be valid URL characters.`);const i=L({nodes:e.nodes,srcName:r.input.name,targetParentFolder:r.input.parentFolder||null});e.nodes.push({...r.input,name:i,kind:"folder",parentFolder:r.input.parentFolder??null}),e.nodes.sort((t,s)=>t.id.localeCompare(s.id))},deleteNodeOperation(e,r,i){const t=e.nodes.find(a=>a.id===r.input.id);if(!t)throw new Error(`Node with id ${r.input.id} not found`);const s=z(t,e.nodes);e.nodes=e.nodes.filter(a=>a.id!==r.input.id&&!s.find(u=>u.id===a.id)),[t,...s].filter(a=>te(a)).forEach(a=>{i?.({type:"DELETE_CHILD_DOCUMENT",input:{id:a.id}})})},updateFileOperation(e,r){if(r.input.name&&!M(r.input.name))throw new Error(`Invalid name: '${r.input.name}'. Names must be valid URL characters.`);e.nodes=e.nodes.map(i=>i.id===r.input.id?{...i,name:L({nodes:e.nodes,srcName:r.input.name??i.name,targetParentFolder:r.input.parentFolder||null}),documentType:r.input.documentType??i.documentType}:i),e.nodes.sort((i,t)=>i.id.localeCompare(t.id))},updateNodeOperation(e,r){if(r.input.name&&!M(r.input.name))throw new Error(`Invalid name: '${r.input.name}'. Names must be valid URL characters.`);e.nodes=e.nodes.map(i=>i.id===r.input.id?{...i,name:L({nodes:e.nodes,srcName:r.input.name??i.name,targetParentFolder:r.input.parentFolder||null}),parentFolder:r.input.parentFolder===null?null:i.parentFolder}:i),e.nodes.sort((i,t)=>i.id.localeCompare(t.id))},copyNodeOperation(e,r,i){const t=e.nodes.find(l=>l.id===r.input.srcId);if(!t)throw new Error(`Node with id ${r.input.srcId} not found`);if(e.nodes.find(l=>l.id===r.input.targetId))throw new Error(`Node with id ${r.input.targetId} already exists`);const a=L({nodes:e.nodes,srcName:r.input.targetName||t.name,targetParentFolder:r.input.targetParentFolder||null}),u={...t,id:r.input.targetId,slug:r.input.targetId,name:a,parentFolder:r.input.targetParentFolder||null};e.nodes.push(u),e.nodes.sort((l,b)=>l.id.localeCompare(b.id)),te(u)&&i?.({type:"COPY_CHILD_DOCUMENT",input:{id:r.input.srcId,newId:r.input.targetId}})},moveNodeOperation(e,r){if(r.input.srcFolder===r.input.targetParentFolder)throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");const i=e.nodes.find(s=>s.id===r.input.srcFolder);if(!i)throw new Error(`Node with id ${r.input.srcFolder} not found`);const t=L({nodes:e.nodes,srcName:i.name,targetParentFolder:r.input.targetParentFolder||null});if(Rr(i)&&z(i,e.nodes).find(a=>a.id===r.input.targetParentFolder))throw new Error("Circular Reference Error: Cannot move a folder to one of its descendants");e.nodes=e.nodes.map(s=>s.id===r.input.srcFolder?{...s,name:t,parentFolder:r.input.targetParentFolder||null}:s),e.nodes.sort((s,a)=>s.id.localeCompare(a.id))}},Lr=(e,r,i)=>{if(je(r))return e;const t=r;switch(t.type){case"ADD_FILE":le().parse(t.input),P.addFileOperation(e[t.scope],r,i);break;case"ADD_FOLDER":ue().parse(t.input),P.addFolderOperation(e[t.scope],r,i);break;case"DELETE_NODE":he().parse(t.input),P.deleteNodeOperation(e[t.scope],r,i);break;case"UPDATE_FILE":Ie().parse(t.input),P.updateFileOperation(e[t.scope],r,i);break;case"UPDATE_NODE":Se().parse(t.input),P.updateNodeOperation(e[t.scope],r,i);break;case"COPY_NODE":fe().parse(t.input),P.copyNodeOperation(e[t.scope],r,i);break;case"MOVE_NODE":ye().parse(t.input),P.moveNodeOperation(e[t.scope],r,i);break;case"SET_DRIVE_NAME":De().parse(t.input),F.setDriveNameOperation(e[t.scope],r,i);break;case"SET_DRIVE_ICON":Te().parse(t.input),F.setDriveIconOperation(e[t.scope],r,i);break;case"SET_SHARING_TYPE":ve().parse(t.input),F.setSharingTypeOperation(e[t.scope],r,i);break;case"SET_AVAILABLE_OFFLINE":Ee().parse(t.input),F.setAvailableOfflineOperation(e[t.scope],r,i);break;case"ADD_LISTENER":ce().parse(t.input),F.addListenerOperation(e[t.scope],r,i);break;case"REMOVE_LISTENER":ge().parse(t.input),F.removeListenerOperation(e[t.scope],r,i);break;case"ADD_TRIGGER":pe().parse(t.input),F.addTriggerOperation(e[t.scope],r,i);break;case"REMOVE_TRIGGER":be().parse(t.input),F.removeTriggerOperation(e[t.scope],r,i);break;default:return e}},Ae=Me(Lr),qr=ke.extend({documentType:N(_e)}),$=Ge.extend({global:sr(),local:or()}),Ne=y({header:qr,state:$,initialState:$});function xr(e){return $.safeParse(e).success}function Br(e){$.parse(e)}function Ur(e){return Ne.safeParse(e).success}function Hr(e){Ne.parse(e)}const Mr={name:"",nodes:[],icon:null},jr={listeners:[],triggers:[],sharingType:"private",availableOffline:!1},Oe=e=>({...de(),global:{...Mr,...e?.global},local:{...jr,...e?.local}}),Gr=e=>{const r=Ve(Oe,e);return r.header.documentType=_e,r.header.id=Je(),r},kr=(e,r)=>ze(e,r),zr=e=>$e(e,Ae),$r=e=>xr(e),Vr=e=>{Br(e)},Jr=e=>Ur(e),Qr=e=>{Hr(e)},mt={actions:Or,reducer:Ae,documentModel:Qe(de(),Fr),utils:{fileExtension:rr,createState:Oe,createDocument:Gr,loadFromInput:zr,saveToFileHandle:kr,isStateOfType:$r,assertIsStateOfType:Vr,isDocumentOfType:Jr,assertIsDocumentOfType:Qr}};class yt extends Error{id;constructor(r,i){super(`Document model "${r}" not found`,{cause:i}),this.id=r}}var ne;(function(e){e.ID="id",e.SLUG="slug"})(ne||(ne={}));class gt extends Error{documentId;constructor(r){super(`Document with id ${r} not found`),this.documentId=r}}const X=JSON,Wr=e=>e.toUpperCase(),Yr=e=>{const r={};return e.forEach((i,t)=>{r[t]=i}),r},Kr=(e,r,i)=>e.document?e:{document:e,variables:r,requestHeaders:i,signal:void 0},Xr=(e,r,i)=>e.query?e:{query:e,variables:r,requestHeaders:i,signal:void 0},Zr=(e,r)=>e.documents?e:{documents:e,requestHeaders:r,signal:void 0},ie=e=>{let r;const i=e.definitions.filter(t=>t.kind==="OperationDefinition");return i.length===1&&(r=i[0]?.name?.value),r},W=e=>{if(typeof e=="string"){let i;try{const t=Ye(e);i=ie(t)}catch{}return{query:e,operationName:i}}const r=ie(e);return{query:Ke(e),operationName:r}};class x extends Error{constructor(r,i){const t=`${x.extractMessage(r)}: ${JSON.stringify({response:r,request:i})}`;super(t),Object.setPrototypeOf(this,x.prototype),this.response=r,this.request=i,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,x)}static extractMessage(r){return r.errors?.[0]?.message??`GraphQL Error (Code: ${r.status})`}}var j={exports:{}},oe;function et(){return oe||(oe=1,(function(e,r){var i=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof H<"u"&&H,t=(function(){function a(){this.fetch=!1,this.DOMException=i.DOMException}return a.prototype=i,new a})();(function(a){(function(u){var d=typeof a<"u"&&a||typeof self<"u"&&self||typeof H<"u"&&H||{},l={searchParams:"URLSearchParams"in d,iterable:"Symbol"in d&&"iterator"in Symbol,blob:"FileReader"in d&&"Blob"in d&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in d,arrayBuffer:"ArrayBuffer"in d};function b(n){return n&&DataView.prototype.isPrototypeOf(n)}if(l.arrayBuffer)var E=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],I=ArrayBuffer.isView||function(n){return n&&E.indexOf(Object.prototype.toString.call(n))>-1};function T(n){if(typeof n!="string"&&(n=String(n)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(n)||n==="")throw new TypeError('Invalid character in header field name: "'+n+'"');return n.toLowerCase()}function w(n){return typeof n!="string"&&(n=String(n)),n}function A(n){var o={next:function(){var p=n.shift();return{done:p===void 0,value:p}}};return l.iterable&&(o[Symbol.iterator]=function(){return o}),o}function h(n){this.map={},n instanceof h?n.forEach(function(o,p){this.append(p,o)},this):Array.isArray(n)?n.forEach(function(o){if(o.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+o.length);this.append(o[0],o[1])},this):n&&Object.getOwnPropertyNames(n).forEach(function(o){this.append(o,n[o])},this)}h.prototype.append=function(n,o){n=T(n),o=w(o);var p=this.map[n];this.map[n]=p?p+", "+o:o},h.prototype.delete=function(n){delete this.map[T(n)]},h.prototype.get=function(n){return n=T(n),this.has(n)?this.map[n]:null},h.prototype.has=function(n){return this.map.hasOwnProperty(T(n))},h.prototype.set=function(n,o){this.map[T(n)]=w(o)},h.prototype.forEach=function(n,o){for(var p in this.map)this.map.hasOwnProperty(p)&&n.call(o,this.map[p],p,this)},h.prototype.keys=function(){var n=[];return this.forEach(function(o,p){n.push(p)}),A(n)},h.prototype.values=function(){var n=[];return this.forEach(function(o){n.push(o)}),A(n)},h.prototype.entries=function(){var n=[];return this.forEach(function(o,p){n.push([p,o])}),A(n)},l.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);function S(n){if(!n._noBody){if(n.bodyUsed)return Promise.reject(new TypeError("Already read"));n.bodyUsed=!0}}function B(n){return new Promise(function(o,p){n.onload=function(){o(n.result)},n.onerror=function(){p(n.error)}})}function Fe(n){var o=new FileReader,p=B(o);return o.readAsArrayBuffer(n),p}function Re(n){var o=new FileReader,p=B(o),m=/charset=([A-Za-z0-9_-]+)/.exec(n.type),g=m?m[1]:"utf-8";return o.readAsText(n,g),p}function Pe(n){for(var o=new Uint8Array(n),p=new Array(o.length),m=0;m<o.length;m++)p[m]=String.fromCharCode(o[m]);return p.join("")}function Z(n){if(n.slice)return n.slice(0);var o=new Uint8Array(n.byteLength);return o.set(new Uint8Array(n)),o.buffer}function ee(){return this.bodyUsed=!1,this._initBody=function(n){this.bodyUsed=this.bodyUsed,this._bodyInit=n,n?typeof n=="string"?this._bodyText=n:l.blob&&Blob.prototype.isPrototypeOf(n)?this._bodyBlob=n:l.formData&&FormData.prototype.isPrototypeOf(n)?this._bodyFormData=n:l.searchParams&&URLSearchParams.prototype.isPrototypeOf(n)?this._bodyText=n.toString():l.arrayBuffer&&l.blob&&b(n)?(this._bodyArrayBuffer=Z(n.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):l.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(n)||I(n))?this._bodyArrayBuffer=Z(n):this._bodyText=n=Object.prototype.toString.call(n):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof n=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):l.searchParams&&URLSearchParams.prototype.isPrototypeOf(n)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},l.blob&&(this.blob=function(){var n=S(this);if(n)return n;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var n=S(this);return n||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(l.blob)return this.blob().then(Fe);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var n=S(this);if(n)return n;if(this._bodyBlob)return Re(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(Pe(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},l.formData&&(this.formData=function(){return this.text().then(qe)}),this.json=function(){return this.text().then(JSON.parse)},this}var Ce=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function Le(n){var o=n.toUpperCase();return Ce.indexOf(o)>-1?o:n}function O(n,o){if(!(this instanceof O))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');o=o||{};var p=o.body;if(n instanceof O){if(n.bodyUsed)throw new TypeError("Already read");this.url=n.url,this.credentials=n.credentials,o.headers||(this.headers=new h(n.headers)),this.method=n.method,this.mode=n.mode,this.signal=n.signal,!p&&n._bodyInit!=null&&(p=n._bodyInit,n.bodyUsed=!0)}else this.url=String(n);if(this.credentials=o.credentials||this.credentials||"same-origin",(o.headers||!this.headers)&&(this.headers=new h(o.headers)),this.method=Le(o.method||this.method||"GET"),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal||(function(){if("AbortController"in d){var f=new AbortController;return f.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&p)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(p),(this.method==="GET"||this.method==="HEAD")&&(o.cache==="no-store"||o.cache==="no-cache")){var m=/([?&])_=[^&]*/;if(m.test(this.url))this.url=this.url.replace(m,"$1_="+new Date().getTime());else{var g=/\?/;this.url+=(g.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}O.prototype.clone=function(){return new O(this,{body:this._bodyInit})};function qe(n){var o=new FormData;return n.trim().split("&").forEach(function(p){if(p){var m=p.split("="),g=m.shift().replace(/\+/g," "),f=m.join("=").replace(/\+/g," ");o.append(decodeURIComponent(g),decodeURIComponent(f))}}),o}function xe(n){var o=new h,p=n.replace(/\r?\n[\t ]+/g," ");return p.split("\r").map(function(m){return m.indexOf(`
|
|
121
|
+
`)===0?m.substr(1,m.length):m}).forEach(function(m){var g=m.split(":"),f=g.shift().trim();if(f){var U=g.join(":").trim();try{o.append(f,U)}catch(Q){console.warn("Response "+Q.message)}}}),o}ee.call(O.prototype);function _(n,o){if(!(this instanceof _))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(o||(o={}),this.type="default",this.status=o.status===void 0?200:o.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=o.statusText===void 0?"":""+o.statusText,this.headers=new h(o.headers),this.url=o.url||"",this._initBody(n)}ee.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},_.error=function(){var n=new _(null,{status:200,statusText:""});return n.ok=!1,n.status=0,n.type="error",n};var Be=[301,302,303,307,308];_.redirect=function(n,o){if(Be.indexOf(o)===-1)throw new RangeError("Invalid status code");return new _(null,{status:o,headers:{location:n}})},u.DOMException=d.DOMException;try{new u.DOMException}catch{u.DOMException=function(o,p){this.message=o,this.name=p;var m=Error(o);this.stack=m.stack},u.DOMException.prototype=Object.create(Error.prototype),u.DOMException.prototype.constructor=u.DOMException}function J(n,o){return new Promise(function(p,m){var g=new O(n,o);if(g.signal&&g.signal.aborted)return m(new u.DOMException("Aborted","AbortError"));var f=new XMLHttpRequest;function U(){f.abort()}f.onload=function(){var D={statusText:f.statusText,headers:xe(f.getAllResponseHeaders()||"")};g.url.indexOf("file://")===0&&(f.status<200||f.status>599)?D.status=200:D.status=f.status,D.url="responseURL"in f?f.responseURL:D.headers.get("X-Request-URL");var R="response"in f?f.response:f.responseText;setTimeout(function(){p(new _(R,D))},0)},f.onerror=function(){setTimeout(function(){m(new TypeError("Network request failed"))},0)},f.ontimeout=function(){setTimeout(function(){m(new TypeError("Network request timed out"))},0)},f.onabort=function(){setTimeout(function(){m(new u.DOMException("Aborted","AbortError"))},0)};function Q(D){try{return D===""&&d.location.href?d.location.href:D}catch{return D}}if(f.open(g.method,Q(g.url),!0),g.credentials==="include"?f.withCredentials=!0:g.credentials==="omit"&&(f.withCredentials=!1),"responseType"in f&&(l.blob?f.responseType="blob":l.arrayBuffer&&(f.responseType="arraybuffer")),o&&typeof o.headers=="object"&&!(o.headers instanceof h||d.Headers&&o.headers instanceof d.Headers)){var re=[];Object.getOwnPropertyNames(o.headers).forEach(function(D){re.push(T(D)),f.setRequestHeader(D,w(o.headers[D]))}),g.headers.forEach(function(D,R){re.indexOf(R)===-1&&f.setRequestHeader(R,D)})}else g.headers.forEach(function(D,R){f.setRequestHeader(R,D)});g.signal&&(g.signal.addEventListener("abort",U),f.onreadystatechange=function(){f.readyState===4&&g.signal.removeEventListener("abort",U)}),f.send(typeof g._bodyInit>"u"?null:g._bodyInit)})}return J.polyfill=!0,d.fetch||(d.fetch=J,d.Headers=h,d.Request=O,d.Response=_),u.Headers=h,u.Request=O,u.Response=_,u.fetch=J,Object.defineProperty(u,"__esModule",{value:!0}),u})({})})(t),t.fetch.ponyfill=!0,delete t.fetch.polyfill;var s=i.fetch?i:t;r=s.fetch,r.default=s.fetch,r.fetch=s.fetch,r.Headers=s.Headers,r.Request=s.Request,r.Response=s.Response,e.exports=r})(j,j.exports)),j.exports}var V=et();const G=Ze(V),rt=er({__proto__:null,default:G},[V]),q=e=>{let r={};return e&&(typeof Headers<"u"&&e instanceof Headers||rt&&V.Headers&&e instanceof V.Headers?r=Yr(e):Array.isArray(e)?e.forEach(([i,t])=>{i&&t!==void 0&&(r[i]=t)}):r=e),r},se=e=>e.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),tt=e=>{if(!Array.isArray(e.query)){const t=e,s=[`query=${encodeURIComponent(se(t.query))}`];return e.variables&&s.push(`variables=${encodeURIComponent(t.jsonSerializer.stringify(t.variables))}`),t.operationName&&s.push(`operationName=${encodeURIComponent(t.operationName)}`),s.join("&")}if(typeof e.variables<"u"&&!Array.isArray(e.variables))throw new Error("Cannot create query with given variable type, array expected");const r=e,i=e.query.reduce((t,s,a)=>(t.push({query:se(s),variables:r.variables?r.jsonSerializer.stringify(r.variables[a]):void 0}),t),[]);return`query=${encodeURIComponent(r.jsonSerializer.stringify(i))}`},nt=e=>async r=>{const{url:i,query:t,variables:s,operationName:a,fetch:u,fetchOptions:d,middleware:l}=r,b={...r.headers};let E="",I;e==="POST"?(I=ot(t,s,a,d.jsonSerializer),typeof I=="string"&&(b["Content-Type"]="application/json")):E=tt({query:t,variables:s,operationName:a,jsonSerializer:d.jsonSerializer??X});const T={method:e,headers:b,body:I,...d};let w=i,A=T;if(l){const h=await Promise.resolve(l({...T,url:i,operationName:a,variables:s})),{url:S,...B}=h;w=S,A=B}return E&&(w=`${w}?${E}`),await u(w,A)};class it{constructor(r,i={}){this.url=r,this.requestConfig=i,this.rawRequest=async(...t)=>{const[s,a,u]=t,d=Xr(s,a,u),{headers:l,fetch:b=G,method:E="POST",requestMiddleware:I,responseMiddleware:T,...w}=this.requestConfig,{url:A}=this;d.signal!==void 0&&(w.signal=d.signal);const{operationName:h}=W(d.query);return Y({url:A,query:d.query,variables:d.variables,headers:{...q(K(l)),...q(d.requestHeaders)},operationName:h,fetch:b,method:E,fetchOptions:w,middleware:I}).then(S=>(T&&T(S),S)).catch(S=>{throw T&&T(S),S})}}async request(r,...i){const[t,s]=i,a=Kr(r,t,s),{headers:u,fetch:d=G,method:l="POST",requestMiddleware:b,responseMiddleware:E,...I}=this.requestConfig,{url:T}=this;a.signal!==void 0&&(I.signal=a.signal);const{query:w,operationName:A}=W(a.document);return Y({url:T,query:w,variables:a.variables,headers:{...q(K(u)),...q(a.requestHeaders)},operationName:A,fetch:d,method:l,fetchOptions:I,middleware:b}).then(h=>(E&&E(h),h.data)).catch(h=>{throw E&&E(h),h})}batchRequests(r,i){const t=Zr(r,i),{headers:s,...a}=this.requestConfig;t.signal!==void 0&&(a.signal=t.signal);const u=t.documents.map(({document:l})=>W(l).query),d=t.documents.map(({variables:l})=>l);return Y({url:this.url,query:u,variables:d,headers:{...q(K(s)),...q(t.requestHeaders)},operationName:void 0,fetch:this.requestConfig.fetch??G,method:this.requestConfig.method||"POST",fetchOptions:a,middleware:this.requestConfig.requestMiddleware}).then(l=>(this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(l),l.data)).catch(l=>{throw this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(l),l})}setHeaders(r){return this.requestConfig.headers=r,this}setHeader(r,i){const{headers:t}=this.requestConfig;return t?t[r]=i:this.requestConfig.headers={[r]:i},this}setEndpoint(r){return this.url=r,this}}const Y=async e=>{const{query:r,variables:i,fetchOptions:t}=e,s=nt(Wr(e.method??"post")),a=Array.isArray(e.query),u=await s(e),d=await st(u,t.jsonSerializer??X),l=Array.isArray(d)?!d.some(({data:E})=>!E):!!d.data,b=Array.isArray(d)||!d.errors||Array.isArray(d.errors)&&!d.errors.length||t.errorPolicy==="all"||t.errorPolicy==="ignore";if(u.ok&&b&&l){const{errors:E,...I}=(Array.isArray(d),d),T=t.errorPolicy==="ignore"?I:d;return{...a?{data:T}:T,headers:u.headers,status:u.status}}else{const E=typeof d=="string"?{error:d}:d;throw new x({...E,status:u.status,headers:u.headers},{query:r,variables:i})}},ot=(e,r,i,t)=>{const s=t??X;if(!Array.isArray(e))return s.stringify({query:e,variables:r,operationName:i});if(typeof r<"u"&&!Array.isArray(r))throw new Error("Cannot create request body with given variable type, array expected");const a=e.reduce((u,d,l)=>(u.push({query:d,variables:r?r[l]:void 0}),u),[]);return s.stringify(a)},st=async(e,r)=>{let i;return e.headers.forEach((t,s)=>{s.toLowerCase()==="content-type"&&(i=t)}),i&&(i.toLowerCase().startsWith("application/json")||i.toLowerCase().startsWith("application/graphql+json")||i.toLowerCase().startsWith("application/graphql-response+json"))?r.parse(await e.text()):e.text()},K=e=>typeof e=="function"?e():e,at=(e,...r)=>e.reduce((i,t,s)=>`${i}${t}${s in r?String(r[s]):""}`,"");async function dt(e,r,i,t){const s=new it(e,{fetch,headers:t||{}}),{errors:a,...u}=await s.request(r,i),d={...u};return a?.length&&(d.errors=a.map(({message:l,...b})=>new Xe(l,b))),d}async function bt(e,r){const i=e.split("/").pop()??"",t=new URL(e),s=`${t.protocol}//${t.host}/graphql/r`;let a;try{const u=await dt(s,at`
|
|
122
|
+
query getDocument($identifier: String!) {
|
|
123
|
+
document(identifier: $identifier) {
|
|
124
|
+
document {
|
|
125
|
+
id
|
|
126
|
+
name
|
|
127
|
+
slug
|
|
128
|
+
state
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`,{identifier:i},r);if(u.errors?.length||!u.document?.document)throw u.errors?.at(0)??new Error("Drive not found");const d=u.document.document,l=d.state.global;a={id:d.id,name:d.name,slug:d.slug??"",icon:l?.icon,meta:l?.meta}}catch(u){throw We.error("@error",u),new Error("Couldn't find drive info")}return a}function lt(e){return["LOCAL","CLOUD","PUBLIC"].includes(e)}function Et(e){if(typeof e!="object")return"LOCAL";const r="readContext"in e,{sharingType:i}=r?{sharingType:"PUBLIC"}:e.state.local,t=i?.toUpperCase();return!t||t==="PRIVATE"||!lt(t)?"LOCAL":t}class Tt extends Error{constructor(r){super(r||"Aborted"),this.name="AbortError"}}export{Tt as A,gt as D,mr as a,te as b,Er as c,yr as d,hr as e,Ir as f,ht as g,L as h,Rr as i,Gr as j,yt as k,Et as l,M as m,mt as n,bt as r,wr as s,br as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./sentry_react-cODD7zWc.js";import"./document_model_editor-
|
|
1
|
+
import"./sentry_react-cODD7zWc.js";import"./document_model_editor-8Rt5FvRZ.js";import"./react-DQSxOgtG.js";
|