@powerhousedao/connect 6.0.0-dev.24 → 6.0.0-dev.26
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-D_CKgy-G.js → AddDriveModal-CrueuRfQ.js} +1 -1
- package/dist/assets/{ClearStorageModal-Cbezj62K.js → ClearStorageModal-DcpPO-I3.js} +1 -1
- package/dist/assets/CookiesPolicyModal-D_fXQPVs.js +1 -0
- package/dist/assets/{CreateDocumentModal-BWk3waQv.js → CreateDocumentModal-Dyo_3hio.js} +1 -1
- package/dist/assets/{DebugSettingsModal-ofyWz4_u.js → DebugSettingsModal-C1ftvYc2.js} +1 -1
- package/dist/assets/{DeleteDriveModal-BMM2s6fJ.js → DeleteDriveModal-szwiCtbM.js} +1 -1
- package/dist/assets/{DeleteItemModal-DF-901U8.js → DeleteItemModal-DidHhqe6.js} +1 -1
- package/dist/assets/DisclaimerModal-BJZ4iCue.js +1 -0
- package/dist/assets/{DriveSettingsModal-DcUJMzXk.js → DriveSettingsModal-DFmkdHFh.js} +1 -1
- package/dist/assets/{ExportDocumentWithErrorsModal-Ba4OmhSV.js → ExportDocumentWithErrorsModal-BgssbqP3.js} +1 -1
- package/dist/assets/{SettingsModal-yQIDMzTY.js → SettingsModal-CT9Ygl-q.js} +1 -1
- package/dist/assets/UpgradeDriveModal-DiwcKft5.js +1 -0
- package/dist/assets/{design_system-BkKQ626l.js → design_system-C2cn-i_6.js} +1 -1
- package/dist/assets/{design_system_connect-CM07lTkc.js → design_system_connect-CEF8vh_d.js} +5 -5
- package/dist/assets/{design_system_ui-CFJrH_IB.js → design_system_ui-D2fobb5H.js} +1 -1
- package/dist/assets/{document_drive-Bubv8iix.js → document_drive-D_syJkZt.js} +2 -2
- package/dist/assets/{document_engineering-B672dX2R.js → document_engineering-B2B5Du5E.js} +1 -1
- package/dist/assets/{document_model-_oCbt5YE.js → document_model-Cvww2VA-.js} +1 -1
- package/dist/assets/{document_model_editor-CoYfquJG.js → document_model_editor-_uYV5sBF.js} +4 -4
- package/dist/assets/{drive_explorer-acsplHJS.js → drive_explorer-XNO5XkhP.js} +2 -2
- package/dist/assets/{graphql-editor-B4IoMXVd.js → graphql-editor-nel36GVq.js} +1 -1
- package/dist/assets/{hooks-DNykyMxl.js → hooks-MzUW1Gro.js} +1 -1
- package/dist/assets/{index-BCHrxL4i.js → index-Cx_zG0En.js} +2 -2
- package/dist/assets/index-Df9NBjHI.css +1 -0
- package/dist/assets/{index-BQijeNOd.js → index-c-YcxuA8.js} +3 -3
- package/dist/assets/{json-editor-DIi0-hRZ.js → json-editor-f-IgBsIW.js} +1 -1
- package/dist/assets/{nodefs-DIxUMZis.js → nodefs-V7ew4ffB.js} +1 -1
- package/dist/assets/{opfs-ahp-Oa76d9mZ.js → opfs-ahp-DguxTmgy.js} +1 -1
- package/dist/assets/{reactor_browser-BnRsHQ1D.js → reactor_browser-LOlgwHbC.js} +11 -11
- package/dist/assets/{state-schemas-CEbl0TPZ.js → state-schemas-C1TXdrU1.js} +2 -2
- package/dist/index.html +10 -10
- package/heroku/Dockerfile +1 -1
- package/lib/package.copy.json +2 -2
- package/lib/style.css +0 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.copy.json +3 -3
- package/package.json +11 -11
- package/dist/assets/CookiesPolicyModal-DaIRB9vU.js +0 -1
- package/dist/assets/DisclaimerModal-TTkhK3iX.js +0 -1
- package/dist/assets/UpgradeDriveModal-DM_tW0ce.js +0 -1
- package/dist/assets/index-DYdiZMfn.css +0 -1
|
@@ -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-CoYfquJG.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-BkKQ626l.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-CM07lTkc.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-_uYV5sBF.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-C2cn-i_6.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-CEF8vh_d.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,4 +1,4 @@
|
|
|
1
|
-
import{c as oe,a as as,i as cs,B as us,b as ds,d as ls,e as hs,f as fs,g as $e,h as $t,j as gs,k as Ve,p as Ar,l as Ue,v as Ge,m as or,n as ar,r as ps,o as bt,s as Je,q as ms,t as ys,u as vs,w as We,x as Nr,y as ws,z as bs,A as Ds,C as Ye}from"./document_model-
|
|
1
|
+
import{c as oe,a as as,i as cs,B as us,b as ds,d as ls,e as hs,f as fs,g as $e,h as $t,j as gs,k as Ve,p as Ar,l as Ue,v as Ge,m as or,n as ar,r as ps,o as bt,s as Je,q as ms,t as ys,u as vs,w as We,x as Nr,y as ws,z as bs,A as Ds,C as Ye}from"./document_model-Cvww2VA-.js";import{a as Ss,p as Es,G as Is,b as Ts,c as Dt,d as cr,e as St,f as Rs,g as Ms}from"./graphql-AKTCpY7l.js";import{c as Ee,g as Pt}from"./react-DQSxOgtG.js";import{o as W,s as $,e as tt,a as pe,_ as Cr,d as Oe,u as Os,b as _s}from"./zod-9j67vCAu.js";import{i as As,L as he}from"./config-CU-aFfVJ.js";function Ns(i,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in i)){const s=Object.getOwnPropertyDescriptor(r,n);s&&Object.defineProperty(i,n,s.get?s:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}const ur=i=>{const e={};for(const[t,r]of Object.entries(i.operations))r&&(e[t]=r.map(n=>(delete n.resultingState,n)));return{...i,operations:e}};class Cs{index=0;cache;constructor(e){this.cache=e}createStorage(){const e=this.index;this.index+=1;function t(n){return`${e}-${n}`}const r={get:n=>this.cache.get(t(n)),set:(n,s)=>(this.cache.set(t(n),s),r),delete:n=>this.cache.delete(t(n)),clear:()=>{this.cache.clear()}};return r}}class xs{cache;cacheStorageManager;idToDocument;idToDrive;slugToDriveId;constructor(e=new Map){this.cache=e,this.cacheStorageManager=new Cs(e),this.idToDocument=this.cacheStorageManager.createStorage(),this.idToDrive=this.cacheStorageManager.createStorage(),this.slugToDriveId=this.cacheStorageManager.createStorage()}clear(){this.idToDocument.clear(),this.idToDrive.clear(),this.slugToDriveId.clear()}async setDocument(e,t){const r=ur(t);this.idToDocument.set(e,r)}async getDocument(e){return this.idToDocument.get(e)}async deleteDocument(e){return this.idToDocument.delete(e)}async setDrive(e,t){const r=ur(t);this.idToDrive.set(e,r)}async getDrive(e){return this.idToDrive.get(e)}async deleteDrive(e){const t=this.idToDrive.get(e);if(!t)return!1;const r=t.header.slug.length>0?t.header.slug:e;return r&&this.slugToDriveId.delete(r),this.idToDrive.delete(e)}async setDriveBySlug(e,t){const r=t.header.id;this.slugToDriveId.set(e,r),this.setDrive(r,t)}async getDriveBySlug(e){const t=this.slugToDriveId.get(e);if(t)return this.getDrive(t)}async deleteDriveBySlug(e){const t=this.slugToDriveId.get(e);return t?(this.slugToDriveId.delete(e),this.deleteDrive(t)):!1}}var $s={};class xr{#e;#t="env";#r;constructor(e,t){this.#e=(e||[]).map(r=>`[${r}]`),this.#r=t,this.log=this.log.bind(this),this.info=this.info.bind(this),this.warn=this.warn.bind(this),this.error=this.error.bind(this),this.debug=this.debug.bind(this),this.verbose=this.verbose.bind(this)}get level(){return this.#t}set level(e){if(e!=="env"&&!As(e))throw new Error(`Invalid log level: ${JSON.stringify(e)}.
|
|
2
2
|
Must be one of ${Object.keys(he).concat(["env"]).join(", ")}.`);this.#t=e}get errorHandler(){return this.#r}set errorHandler(e){this.#r=e}get#n(){if(this.#t==="env"){const e=typeof globalThis<"u"&&globalThis.process&&"env"in globalThis.process?$s.LOG_LEVEL:void 0;return e?e in he?he[e]:he.info:he.info}return he[this.#t]}log(...e){return this.debug(...e)}verbose(...e){if(!(this.#n>he.verbose))return this.debug(...e)}debug(...e){if(!(this.#n>he.debug))return console.debug(...this.#e,...e)}info(...e){if(!(this.#n>he.info))return console.info(...this.#e,...e)}warn(...e){if(!(this.#n>he.warn))return console.warn(...this.#e,...e)}error(...e){if(!(this.#n>he.error))return this.#r&&this.#r(...e),console.error(...this.#e,...e)}}const ct=new xr;let Lt="env",$r;ct.level=Lt;ct.errorHandler=$r;const fe=ct,Mo=i=>{Lt=i,ct.level=i},me=i=>{const e=new xr(i);return e.level=Lt,e.errorHandler=$r,e},Ps="phdd",Ls=i=>i!=null;_s().refine(i=>Ls(i));const Us=Cr(["Internal","MatrixConnect","PullResponder","RESTWebhook","SecureConnect","SwitchboardPush"]),Bs=Cr(["PullResponder"]);function Pr(){return W({documentType:$(),id:$(),name:$(),parentFolder:$().nullish()})}function Lr(){return W({id:$(),name:$(),parentFolder:$().nullish()})}function Ur(){return W({listener:qr()})}function Br(){return W({trigger:Kr()})}function Fr(){return W({srcId:$(),targetId:$(),targetName:$().nullish(),targetParentFolder:$().nullish()})}function kr(){return W({id:$()})}function Fs(){return W({__typename:pe("DocumentDriveLocalState").optional(),availableOffline:tt(),listeners:Oe(qr()),sharingType:$().nullable(),triggers:Oe(Kr())})}function ks(){return W({__typename:pe("DocumentDriveState").optional(),icon:$().nullable(),name:$(),nodes:Oe(Gs())})}function qs(){return W({__typename:pe("FileNode").optional(),documentType:$(),id:$(),kind:$(),name:$(),parentFolder:$().nullable()})}function zs(){return W({__typename:pe("FolderNode").optional(),id:$(),kind:$(),name:$(),parentFolder:$().nullable()})}function qr(){return W({__typename:pe("Listener").optional(),block:tt(),callInfo:js().nullable(),filter:Hs(),label:$().nullable(),listenerId:$(),system:tt()})}function js(){return W({__typename:pe("ListenerCallInfo").optional(),data:$().nullable(),name:$().nullable(),transmitterType:Us.nullable()})}function Hs(){return W({__typename:pe("ListenerFilter").optional(),branch:Oe($()).nullable(),documentId:Oe($()).nullable(),documentType:Oe($()),scope:Oe($()).nullable()})}function zr(){return W({srcFolder:$(),targetParentFolder:$().nullish()})}function Gs(){return Os([qs(),zs()])}function Js(){return W({__typename:pe("PullResponderTriggerData").optional(),interval:$(),listenerId:$(),url:$()})}function jr(){return W({listenerId:$()})}function Hr(){return W({triggerId:$()})}function Gr(){return W({availableOffline:tt()})}function Jr(){return W({icon:$()})}function Yr(){return W({name:$()})}function Qr(){return W({type:$()})}function Kr(){return W({__typename:pe("Trigger").optional(),data:Ys().nullable(),id:$(),type:Bs})}function Ys(){return Js()}function Vr(){return W({documentType:$().nullish(),id:$(),name:$().nullish(),parentFolder:$().nullish()})}function Wr(){return W({id:$(),name:$().nullish(),parentFolder:$().nullish()})}function Qs(i){return i&&typeof i=="object"&&"synchronizationUnits"in i?oe("ADD_FILE",{...i},void 0,void 0,"global"):oe("ADD_FILE",{...i},void 0,Pr,"global")}const Ks=i=>oe("ADD_FOLDER",{...i},void 0,Lr,"global"),Vs=i=>oe("DELETE_NODE",{...i},void 0,kr,"global"),Ws=i=>oe("UPDATE_FILE",{...i},void 0,Vr,"global"),Xs=i=>oe("UPDATE_NODE",{...i},void 0,Wr,"global"),Zs=i=>oe("COPY_NODE",{...i},void 0,Fr,"global"),ei=i=>oe("MOVE_NODE",{...i},void 0,zr,"global"),ti=i=>oe("SET_DRIVE_NAME",{...i},void 0,Yr,"global"),ri=i=>oe("SET_DRIVE_ICON",{...i},void 0,Jr,"global"),Xr=i=>oe("SET_SHARING_TYPE",{...i},void 0,Qr,"local"),ni=i=>oe("SET_AVAILABLE_OFFLINE",{...i},void 0,Gr,"local"),si=i=>oe("ADD_LISTENER",{...i},void 0,Ur,"local"),Zr=i=>oe("REMOVE_LISTENER",{...i},void 0,jr,"local"),ii=i=>oe("ADD_TRIGGER",{...i},void 0,Br,"local"),en=i=>oe("REMOVE_TRIGGER",{...i},void 0,Hr,"local"),oi=Object.freeze(Object.defineProperty({__proto__:null,addFile:Qs,addFolder:Ks,addListener:si,addTrigger:ii,copyNode:Zs,deleteNode:Vs,moveNode:ei,removeListener:Zr,removeTrigger:en,setAvailableOffline:ni,setDriveIcon:ri,setDriveName:ti,setSharingType:Xr,updateFile:Ws,updateNode:Xs},Symbol.toStringTag,{value:"Module"})),ai={id:"powerhouse/document-drive",name:"DocumentDrive",extension:"phdd",description:"",author:{name:"Powerhouse Inc",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],state:{global:{schema:`type FolderNode {
|
|
3
3
|
id: String!
|
|
4
4
|
name: String!
|
|
@@ -118,7 +118,7 @@ type DocumentDriveLocalState{
|
|
|
118
118
|
trigger: Trigger!
|
|
119
119
|
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z30dsU=",name:"REMOVE_TRIGGER",description:"",schema:`input RemoveTriggerInput {
|
|
120
120
|
triggerId: String!
|
|
121
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"}]}]}]},ut="powerhouse/document-drive",Se={setDriveNameOperation(i,e,t){i.name=e.input.name},setDriveIconOperation(i,e,t){i.icon=e.input.icon},setSharingTypeOperation(i,e,t){i.sharingType=e.input.type},setAvailableOfflineOperation(i,e,t){i.availableOffline=e.input.availableOffline},addListenerOperation(i,e,t){if(i.listeners.find(r=>r.listenerId===e.input.listener.listenerId))throw new Error(`A listener with Id: ${e.input.listener.listenerId} already exists`);i.listeners.push(e.input.listener)},removeListenerOperation(i,e,t){i.listeners=i.listeners.filter(r=>r.listenerId!==e.input.listenerId)},addTriggerOperation(i,e,t){if(i.triggers.find(r=>r.id===e.input.trigger.id))throw new Error(`A trigger with Id: ${e.input.trigger.id} already exists`);i.triggers.push(e.input.trigger)},removeTriggerOperation(i,e,t){i.triggers=i.triggers.filter(r=>r.id!==e.input.triggerId)}};function dr(i){return i.kind==="file"}function ci(i){return i.kind==="folder"}function rt(i,e){const t=e.filter(n=>n.parentFolder===i.id),r=t.map(n=>rt(n,e));return[...t,...r.flat()]}function Oo(i,e,t){const r=t.find(d=>d.id===i.srcId);if(!r)throw new Error(`Node with id ${i.srcId} not found`);const n=[{...r,name:i.targetName||r.name,parentFolder:i.targetParentFolder||null},...rt(r,t)],s={};i.targetParentFolder&&(s[i.targetParentFolder]=i.targetParentFolder);const o=d=>{let l=s[d.id];if(!l){const y=d.id;l=e(d),s[y]=l}return l};return n.map(d=>({srcId:d.id,targetId:o(d),targetName:d.name,targetParentFolder:d.parentFolder?s[d.parentFolder]:null}))}function ui(i,e){let t=0;const r=new RegExp(`^${di(e)} \\(copy\\)(?: (\\d+))?$`);for(const n of i){const s=n.match(r);if(s){const o=s[1]?parseInt(s[1],10):1;o>t&&(t=o)}}return t+1}function di(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(i){const{nodes:e,targetParentFolder:t,srcName:r}=i,n=e.filter(a=>t===""?a.parentFolder===null:a.parentFolder===t).map(a=>a.name);return n.includes(r)?`${r} (copy) ${ui(n,r)}`:r}const Qe=i=>/^[a-zA-Z0-9-_.\s()]+$/.test(i),Te={addFileOperation(i,e,t){if(i.nodes.find(s=>s.id===e.input.id))throw new Error(`Node with id ${e.input.id} already exists!`);if(!Qe(e.input.name))throw new Error(`Invalid name: '${e.input.name}'. Names must be valid URL characters.`);const r=Ne({nodes:i.nodes,srcName:e.input.name,targetParentFolder:e.input.parentFolder||null}),n={id:e.input.id,name:r,kind:"file",parentFolder:e.input.parentFolder??null,documentType:e.input.documentType};i.nodes.push(n),t?.({type:"CREATE_CHILD_DOCUMENT",input:{id:e.input.id,documentType:e.input.documentType}})},addFolderOperation(i,e){if(i.nodes.find(r=>r.id===e.input.id))throw new Error(`Node with id ${e.input.id} already exists!`);if(!Qe(e.input.name))throw new Error(`Invalid name: '${e.input.name}'. Names must be valid URL characters.`);const t=Ne({nodes:i.nodes,srcName:e.input.name,targetParentFolder:e.input.parentFolder||null});i.nodes.push({...e.input,name:t,kind:"folder",parentFolder:e.input.parentFolder??null})},deleteNodeOperation(i,e,t){const r=i.nodes.find(s=>s.id===e.input.id);if(!r)throw new Error(`Node with id ${e.input.id} not found`);const n=rt(r,i.nodes);i.nodes=i.nodes.filter(s=>s.id!==e.input.id&&!n.find(o=>o.id===s.id)),[r,...n].filter(s=>dr(s)).forEach(s=>{t?.({type:"DELETE_CHILD_DOCUMENT",input:{id:s.id}})})},updateFileOperation(i,e){if(e.input.name&&!Qe(e.input.name))throw new Error(`Invalid name: '${e.input.name}'. Names must be valid URL characters.`);i.nodes=i.nodes.map(t=>t.id===e.input.id?{...t,name:Ne({nodes:i.nodes,srcName:e.input.name??t.name,targetParentFolder:e.input.parentFolder||null}),documentType:e.input.documentType??t.documentType}:t)},updateNodeOperation(i,e){if(e.input.name&&!Qe(e.input.name))throw new Error(`Invalid name: '${e.input.name}'. Names must be valid URL characters.`);i.nodes=i.nodes.map(t=>t.id===e.input.id?{...t,name:Ne({nodes:i.nodes,srcName:e.input.name??t.name,targetParentFolder:e.input.parentFolder||null}),parentFolder:e.input.parentFolder===null?null:t.parentFolder}:t)},copyNodeOperation(i,e,t){const r=i.nodes.find(d=>d.id===e.input.srcId);if(!r)throw new Error(`Node with id ${e.input.srcId} not found`);if(i.nodes.find(d=>d.id===e.input.targetId))throw new Error(`Node with id ${e.input.targetId} already exists`);const s=Ne({nodes:i.nodes,srcName:e.input.targetName||r.name,targetParentFolder:e.input.targetParentFolder||null}),o={...r,id:e.input.targetId,slug:e.input.targetId,name:s,parentFolder:e.input.targetParentFolder||null};i.nodes.push(o),dr(o)&&t?.({type:"COPY_CHILD_DOCUMENT",input:{id:e.input.srcId,newId:e.input.targetId}})},moveNodeOperation(i,e){if(e.input.srcFolder===e.input.targetParentFolder)throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");const t=i.nodes.find(n=>n.id===e.input.srcFolder);if(!t)throw new Error(`Node with id ${e.input.srcFolder} not found`);const r=Ne({nodes:i.nodes,srcName:t.name,targetParentFolder:e.input.targetParentFolder||null});if(ci(t)&&rt(t,i.nodes).find(s=>s.id===e.input.targetParentFolder))throw new Error("Circular Reference Error: Cannot move a folder to one of its descendants");i.nodes=i.nodes.map(n=>n.id===e.input.srcFolder?{...n,name:r,parentFolder:e.input.targetParentFolder||null}:n)}},li=(i,e,t)=>{if(cs(e))return i;const r=e;switch(r.type){case"ADD_FILE":Pr().parse(r.input),Te.addFileOperation(i[r.scope],e,t);break;case"ADD_FOLDER":Lr().parse(r.input),Te.addFolderOperation(i[r.scope],e,t);break;case"DELETE_NODE":kr().parse(r.input),Te.deleteNodeOperation(i[r.scope],e,t);break;case"UPDATE_FILE":Vr().parse(r.input),Te.updateFileOperation(i[r.scope],e,t);break;case"UPDATE_NODE":Wr().parse(r.input),Te.updateNodeOperation(i[r.scope],e,t);break;case"COPY_NODE":Fr().parse(r.input),Te.copyNodeOperation(i[r.scope],e,t);break;case"MOVE_NODE":zr().parse(r.input),Te.moveNodeOperation(i[r.scope],e,t);break;case"SET_DRIVE_NAME":Yr().parse(r.input),Se.setDriveNameOperation(i[r.scope],e,t);break;case"SET_DRIVE_ICON":Jr().parse(r.input),Se.setDriveIconOperation(i[r.scope],e,t);break;case"SET_SHARING_TYPE":Qr().parse(r.input),Se.setSharingTypeOperation(i[r.scope],e,t);break;case"SET_AVAILABLE_OFFLINE":Gr().parse(r.input),Se.setAvailableOfflineOperation(i[r.scope],e,t);break;case"ADD_LISTENER":Ur().parse(r.input),Se.addListenerOperation(i[r.scope],e,t);break;case"REMOVE_LISTENER":jr().parse(r.input),Se.removeListenerOperation(i[r.scope],e,t);break;case"ADD_TRIGGER":Br().parse(r.input),Se.addTriggerOperation(i[r.scope],e,t);break;case"REMOVE_TRIGGER":Hr().parse(r.input),Se.removeTriggerOperation(i[r.scope],e,t);break;default:return i}},tn=as(li),hi=ds.extend({documentType:pe(ut)}),nt=us.extend({global:ks(),local:Fs()}),rn=W({header:hi,state:nt,initialState:nt});function fi(i){return nt.safeParse(i).success}function gi(i){nt.parse(i)}function pi(i){return rn.safeParse(i).success}function mi(i){rn.parse(i)}const yi={name:"",nodes:[],icon:null},vi={listeners:[],triggers:[],sharingType:"private",availableOffline:!1},Ut=i=>({...$t(),global:{...yi,...i?.global},local:{...vi,...i?.local}}),nn=i=>{const e=fs(Ut,i);return e.header.documentType=ut,e.header.id=$e(),e},wi=(i,e)=>ls(i,e),bi=i=>hs(i,tn),Di=i=>fi(i),Si=i=>{gi(i)},Ei=i=>pi(i),Ii=i=>{mi(i)},Ti={actions:oi,reducer:tn,documentModel:gs($t(),ai),utils:{fileExtension:Ps,createState:Ut,createDocument:nn,loadFromInput:bi,saveToFileHandle:wi,isStateOfType:Di,assertIsStateOfType:Si,isDocumentOfType:Ei,assertIsDocumentOfType:Ii}};class Ri extends Error{id;constructor(e,t){super(`Document model "${e}" not found`,{cause:t}),this.id=e}}class ie extends Error{status;operation;constructor(e,t,r,n){super(r,{cause:n??t}),this.status=e,this.operation=t,n instanceof Error&&(this.stack=n.stack)}}class Mi extends ie{constructor(e,t){super("CONFLICT",t,`Conflicting operation on index ${t.index}`,{existingOperation:e,newOperation:t})}}var ke;(function(i){i.ID="id",i.SLUG="slug"})(ke||(ke={}));class qe extends Error{documentId;constructor(e,t=ke.ID){super(`Document (${e}) uses ${t} that already exists`),this.documentId=e}}class we extends Error{documentId;constructor(e){super(`Document with id ${e} not found`),this.documentId=e}}class Oi extends Error{syncUnitId;constructor(e){super(`Sync unit ${JSON.stringify(e)} not found`),this.syncUnitId=e}}function ve(i){return i.header.documentType===ut}function st(i,e){const t=Object.keys(i).reduce((n,s)=>{const o=s,a=i[o];return n[o]=a?.at(-1)?.index??0,n},{}),r=e.find(n=>n.index<(t[n.action.scope]??0));if(r)throw new ie("ERROR",r,`Tried to add operation with index ${r.index} and document is at index ${t[r.action.scope]}`);return e.sort((n,s)=>n.index-s.index).reduce((n,s)=>{const o=n[s.action.scope]||[];return{...n,[s.action.scope]:[...o,s]}},i)}function _i(i,e){return new Date(i)<new Date(e)}function Ie(i){const e=i?.at(-1);return e?e.index+1:0}const lr=typeof MessageChannel>"u"?new Error("MessageChannel is not supported"):i=>{const e=new AbortController,t=e.signal,r=new MessageChannel;return r.port1.postMessage(null),r.port2.addEventListener("message",()=>{i(),r.port1.close(),r.port2.close()},{once:!0,signal:t}),r.port2.start(),()=>e.abort()},hr=(()=>{const i=typeof window=="object"&&window||typeof global=="object"&&global||typeof self=="object"&&self;if(!i)return new Error("No global object found");const e=i;if(!e.postMessage||!e.addEventListener||e.importScripts)return new Error("postMessage is not supported");let t=0;const r=new Map;function n(){return t===9007199254740991?0:++t}const s="com.usePostMessage"+Math.random();return e.addEventListener("message",o=>{const a=o;if(typeof a.data!="string"||a.source!==e||!a.data.startsWith(s))return;const d=a.data.split(":").at(1);if(d===void 0)return;const l=+d,y=r.get(l);y&&(y(),r.delete(l))},!1),o=>{const a=n();return r.set(a,o),e.postMessage(s+":"+a,{targetOrigin:"*"}),()=>{r.delete(a)}}})(),fr=typeof window<"u"?new Error("setImmediate is not supported on the browser"):typeof setImmediate>"u"?new Error("setImmediate is not supported"):i=>{const e=setImmediate(i);return()=>clearImmediate(e)},Ai=i=>{const e=setTimeout(i,0);return()=>clearTimeout(e)};function Bt(i){return fr instanceof Error?lr instanceof Error?hr instanceof Error?Ai(i):hr(i):lr(i):fr(i)}function xt(i,e=Bt){if(e instanceof Error)throw new Error("queueMethod is not supported",{cause:e});return new Promise((t,r)=>{e(()=>{i().then(t).catch(r)})})}class Ni{drive;processor;taskQueueMethod;transmitQueue;constructor(e,t,r){this.drive=e,this.processor=t,this.taskQueueMethod=r===void 0?Bt:r}async#e(e){const t=[],r=new Map,n=async s=>{const o=r.get(s);if(o)return o;const a={revisions:{[e.scope]:s},checkHashes:!1},d=await(e.documentId===e.driveId?this.drive.getDrive(e.driveId,a):this.drive.getDocument(e.documentId,a));return s<0?r.set(s,d.initialState[e.scope]):r.set(s,d.state[e.scope]),r.get(s)};for(const s of e.operations){const o=()=>n(s.index),a=await(this.taskQueueMethod?xt(o,this.taskQueueMethod):o()),d=()=>n(s.index-1),l=await(this.taskQueueMethod?xt(d,this.taskQueueMethod):d()),y={id:s.actionId,timestampUtcMs:s.timestampUtcMs,type:s.type,input:s.input,context:s.context,scope:e.scope};t.push({...s,id:s.id??Ve(e.documentId,e.scope,e.branch,s.actionId),state:a,previousState:l,action:y})}return t}async transmit(e,t){const r=async()=>{const n=[];for(const s of e){const o=await this.#e(s),a=await this.drive.getDocument(s.documentId),d=o.at(-1)?.state??a.initialState[s.scope];n.push({...s,documentType:a.header.documentType,operations:o,state:d,document:a})}try{return await this.processor.onStrands(n),e.map(({operations:s,...o})=>({...o,status:"SUCCESS",revision:Ie(s)}))}catch(s){return fe.error(s),e.map(({operations:o,...a})=>({...a,status:"ERROR",revision:o.at(0)?.index??0}))}};return this.transmitQueue=this.transmitQueue?.then(()=>r())??r(),this.transmitQueue}async disconnect(){await this.processor.onDisconnect()}}function sn(i){return{selectFrom:i.selectFrom.bind(i),selectNoFrom:i.selectNoFrom.bind(i),with:i.with.bind(i),withRecursive:i.withRecursive.bind(i),withSchema:e=>sn(i.withSchema(e))}}const gr=Symbol.for("ph.IS_RELATIONAL_DB_PROCESSOR");class Ci{_namespace;_filter;relationalDb;constructor(e,t,r){this._namespace=e,this._filter=t,this.relationalDb=r}static[gr]=!0;static is(e){let t=Object.getPrototypeOf(e);for(;t;){if(t.constructor?.[gr])return!0;t=Object.getPrototypeOf(t)}return!1}static getNamespace(e){return`${this.name}_${e.replaceAll("-","_")}`}static query(e,t){return t.queryNamespace(this.getNamespace(e))}get filter(){return this._filter}get namespace(){return this._namespace}get query(){return sn(this.relationalDb)}}function pr(i){return Ci.is(i)}class _o{listeners;drive;logger=me(["document-drive","processor-manager"]);processorsByDrive=new Map;idToFactory=new Map;identifierToListeners=new Map;constructor(e,t){this.listeners=e,this.drive=t}async registerFactory(e,t){this.logger.debug(`Registering factory '${e}'.`),this.idToFactory.set(e,t);const r=await this.drive.getDrives();for(const n of r)await this.createProcessors(n,e,t)}async unregisterFactory(e){const t=this.identifierToListeners.get(e)??[];for(const r of t)await this.listeners.removeListener(r.driveId,r.listenerId).catch(this.logger.error),r.transmitter?.disconnect&&await r.transmitter.disconnect();this.identifierToListeners.set(e,[])}async registerDrive(e){this.logger.debug(`Registering drive '${e}'.`);for(const[t,r]of this.idToFactory)await this.createProcessors(e,t,r)}async createProcessors(e,t,r){const n=await this.drive.getDrive(e);let s=this.identifierToListeners.get(t);s||(s=[],this.identifierToListeners.set(t,s));let o=this.processorsByDrive.get(e);o||(o=[],this.processorsByDrive.set(e,o));let a=[];try{a=await r(n.header)}catch(d){this.logger.error(`Error creating processors for drive ${e}:`,d);return}for(const{filter:d,processor:l}of a){const y=pr(l);if(y&&o.some(b=>pr(b.processor)&&b.processor.namespace===l.namespace)){this.logger.debug(`Processor with namespace '${l.namespace}' already registered for drive '${e}'.`);continue}y&&await l.initAndUpgrade();const f=$e(),w={driveId:e,listenerId:f,block:!1,system:!1,filter:d,callInfo:void 0,transmitter:new Ni(this.drive,l)};await this.listeners.setListener(e,w),s.push(w),o.push({filter:d,processor:l})}}}class xi{id;running=!1;deleted=!1;items=[];dependencies=new Array;constructor(e){this.id=e}async isRunning(){return this.running}async setRunning(e){this.running=e}async setDeleted(e){this.deleted=e}async isDeleted(){return this.deleted}async addJob(e){return this.items.push(e),Promise.resolve()}async getNextJob(){const e=this.items.shift();return Promise.resolve(e)}async amountOfJobs(){return Promise.resolve(this.items.length)}getId(){return this.id}async isBlocked(){return this.running||this.deleted||this.dependencies.length>0}async getJobs(){return this.items}async addDependency(e){this.dependencies.includes(e.jobId)||this.dependencies.push(e.jobId)}async removeDependency(e){const t=this.dependencies.indexOf(e.jobId);t>-1&&this.dependencies.splice(t,1)}}let on=()=>({emit(i,...e){for(let t=this.events[i]||[],r=0,n=t.length;r<n;r++)t[r](...e)},events:{},on(i,e){return(this.events[i]||=[]).push(e),()=>{this.events[i]=this.events[i]?.filter(t=>e!==t)}}});function Xe(i){return"documentType"in i}function an(i){return"operations"in i}function $i(i){return"actions"in i}class Pi{logger=me(["EventQueueManager"]);emitter=on();queues=new Map;globalQueue=new Array;isFindingJob=!1;maxWorkers;workers;runningJobs=new Array;timeout;delegate;onError;constructor(e=1,t=0){this.maxWorkers=e,this.workers=0,this.timeout=t}async init(e,t){this.delegate=e,this.onError=t;function r(n){return(async(...s)=>{try{await n(...s)}catch(o){throw o instanceof Error?o:new Error(JSON.stringify(o))}})}return this.emitter.on("jobAdded",r(async n=>{this.logger.verbose("Added job",n),await this.processNextJob()})),this.emitter.on("jobStarted",r(async n=>{this.logger.verbose("Started job",n.jobId),this.runningJobs.push(n),await this.processNextJob()})),this.emitter.on("jobCompleted",r(async(n,s)=>{this.logger.verbose("Completed job",n.jobId),await this.handleJobCompleted(n,s)})),this.emitter.on("jobFailed",r(async(n,s)=>{this.logger.error("Failed job",n,s),this.removeJob(n),t(s),await this.processNextJob()})),Promise.resolve()}async addJob(e){if(!this.delegate)throw new Error("No server delegate defined");const t=$e(),r=Xe(e),n=Xe(e)?void 0:an(e)?e.operations:e.actions;if(!r&&!n?.length)throw new Error("Job has no operations or actions: "+JSON.stringify(e));const s=n?.at(0),o=s?"action"in s?s.action.scope:s.scope:"global";if(n?.find(l=>("action"in l?l.action.scope:l.scope)!==o))throw new Error("Job has actions with different scopes");const a=this.getQueue(e.documentId,o);if(!Xe(e)&&await a.isDeleted())throw new Error("Job has operations for deleted document");const d=Object.freeze({jobId:t,...e});return await a.addJob(d),this.globalQueue.push({jobId:t,documentId:e.documentId,scope:o,timestampUtcMs:new Date().toUTCString()}),this.emit("jobAdded",d),t}getQueue(e,t){let r=this.queues.get(e);r||(r=new Map,this.queues.set(e,r));let n=r.get(t);return n||(n=new xi(t),r.set(t,n)),n}getDocumentQueues(e){return this.queues.get(e)}removeQueue(e,t){const n=this.queues.get(e)?.delete(t);return n&&this.emit("queueRemoved",{documentId:e,scope:t}),n}removeDocumentQueues(e){this.queues.get(e)?.keys().forEach(r=>{this.removeQueue(e,r)})}removeJob(e){const t=this.runningJobs.findIndex(n=>n.jobId===e.jobId);t===-1&&this.logger.warn("Running job not found",e.jobId),this.runningJobs.splice(t,1);const r=this.globalQueue.findIndex(n=>n.jobId===e.jobId);r===-1&&this.logger.warn("Job not found on global queue",e.jobId),this.globalQueue.splice(r,1)}async handleJobCompleted(e,t){return this.removeJob(e),this.processNextJob()}isBusy(){return this.workers>=this.maxWorkers}async processNextJob(){if(this.isFindingJob)return;if(!this.delegate)throw new Error("No server delegate defined");if(this.globalQueue.length===0||this.isBusy())return;this.isFindingJob=!0,this.workers++;let e,t;try{const r=await this.findNextJob();e=r?.queue,t=r?.job}catch(r){fe.error("Error finding next job",r)}if(!e||!t){this.workers--,this.isFindingJob=!1;return}try{await e.setRunning(!0),this.isFindingJob=!1,this.emit("jobStarted",t);const r=await this.delegate.processJob(t);this.workers--,await e.setRunning(!1),this.emit("jobCompleted",t,r)}catch(r){fe.error("Job failed",r),this.workers--,this.isFindingJob=!1,await e.setRunning(!1),this.emit("jobFailed",t,r instanceof Error?r:new Error(JSON.stringify(r)))}}async findNextJob(){const e=new Set;for(const t of this.globalQueue){const r=this.getQueue(t.documentId,t.scope),n=r.getId();if(e.has(n))continue;if(await r.isBlocked()){e.add(r.getId());continue}const s=await r.getNextJob();if(s?.jobId!==t.jobId){fe.warn("Queue has different job waiting to be picked up"),fe.error(t,s);continue}return{queue:r,job:s}}}emit(e,...t){this.emitter.emit(e,...t)}on(e,t){return this.emitter.on(e,t)}}class dt extends Error{}class Re extends dt{constructor(e){super(`Read drive ${e} not found.`)}}class Li extends dt{constructor(e){super(`Read drive with slug ${e} not found.`)}}class mr extends dt{constructor(e,t){super(`Document with id ${t} not found on read drive ${e}.`)}}const Ft=JSON,Ui=i=>i.toUpperCase(),Bi=i=>{const e={};return i.forEach((t,r)=>{e[r]=t}),e},Fi=(i,e,t)=>i.document?i:{document:i,variables:e,requestHeaders:t,signal:void 0},ki=(i,e,t)=>i.query?i:{query:i,variables:e,requestHeaders:t,signal:void 0},qi=(i,e)=>i.documents?i:{documents:i,requestHeaders:e,signal:void 0},yr=i=>{let e;const t=i.definitions.filter(r=>r.kind==="OperationDefinition");return t.length===1&&(e=t[0]?.name?.value),e},Et=i=>{if(typeof i=="string"){let t;try{const r=Ss(i);t=yr(r)}catch{}return{query:i,operationName:t}}const e=yr(i);return{query:Es(i),operationName:e}};class xe extends Error{constructor(e,t){const r=`${xe.extractMessage(e)}: ${JSON.stringify({response:e,request:t})}`;super(r),Object.setPrototypeOf(this,xe.prototype),this.response=e,this.request=t,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,xe)}static extractMessage(e){return e.errors?.[0]?.message??`GraphQL Error (Code: ${e.status})`}}var Ke={exports:{}},vr;function zi(){return vr||(vr=1,(function(i,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Ee<"u"&&Ee,r=(function(){function s(){this.fetch=!1,this.DOMException=t.DOMException}return s.prototype=t,new s})();(function(s){(function(o){var a=typeof s<"u"&&s||typeof self<"u"&&self||typeof Ee<"u"&&Ee||{},d={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function l(D){return D&&DataView.prototype.isPrototypeOf(D)}if(d.arrayBuffer)var y=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=ArrayBuffer.isView||function(D){return D&&y.indexOf(Object.prototype.toString.call(D))>-1};function w(D){if(typeof D!="string"&&(D=String(D)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(D)||D==="")throw new TypeError('Invalid character in header field name: "'+D+'"');return D.toLowerCase()}function b(D){return typeof D!="string"&&(D=String(D)),D}function p(D){var R={next:function(){var B=D.shift();return{done:B===void 0,value:B}}};return d.iterable&&(R[Symbol.iterator]=function(){return R}),R}function E(D){this.map={},D instanceof E?D.forEach(function(R,B){this.append(B,R)},this):Array.isArray(D)?D.forEach(function(R){if(R.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+R.length);this.append(R[0],R[1])},this):D&&Object.getOwnPropertyNames(D).forEach(function(R){this.append(R,D[R])},this)}E.prototype.append=function(D,R){D=w(D),R=b(R);var B=this.map[D];this.map[D]=B?B+", "+R:R},E.prototype.delete=function(D){delete this.map[w(D)]},E.prototype.get=function(D){return D=w(D),this.has(D)?this.map[D]:null},E.prototype.has=function(D){return this.map.hasOwnProperty(w(D))},E.prototype.set=function(D,R){this.map[w(D)]=b(R)},E.prototype.forEach=function(D,R){for(var B in this.map)this.map.hasOwnProperty(B)&&D.call(R,this.map[B],B,this)},E.prototype.keys=function(){var D=[];return this.forEach(function(R,B){D.push(B)}),p(D)},E.prototype.values=function(){var D=[];return this.forEach(function(R){D.push(R)}),p(D)},E.prototype.entries=function(){var D=[];return this.forEach(function(R,B){D.push([B,R])}),p(D)},d.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function _(D){if(!D._noBody){if(D.bodyUsed)return Promise.reject(new TypeError("Already read"));D.bodyUsed=!0}}function A(D){return new Promise(function(R,B){D.onload=function(){R(D.result)},D.onerror=function(){B(D.error)}})}function C(D){var R=new FileReader,B=A(R);return R.readAsArrayBuffer(D),B}function U(D){var R=new FileReader,B=A(R),G=/charset=([A-Za-z0-9_-]+)/.exec(D.type),V=G?G[1]:"utf-8";return R.readAsText(D,V),B}function F(D){for(var R=new Uint8Array(D),B=new Array(R.length),G=0;G<R.length;G++)B[G]=String.fromCharCode(R[G]);return B.join("")}function I(D){if(D.slice)return D.slice(0);var R=new Uint8Array(D.byteLength);return R.set(new Uint8Array(D)),R.buffer}function P(){return this.bodyUsed=!1,this._initBody=function(D){this.bodyUsed=this.bodyUsed,this._bodyInit=D,D?typeof D=="string"?this._bodyText=D:d.blob&&Blob.prototype.isPrototypeOf(D)?this._bodyBlob=D:d.formData&&FormData.prototype.isPrototypeOf(D)?this._bodyFormData=D:d.searchParams&&URLSearchParams.prototype.isPrototypeOf(D)?this._bodyText=D.toString():d.arrayBuffer&&d.blob&&l(D)?(this._bodyArrayBuffer=I(D.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):d.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(D)||f(D))?this._bodyArrayBuffer=I(D):this._bodyText=D=Object.prototype.toString.call(D):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof D=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):d.searchParams&&URLSearchParams.prototype.isPrototypeOf(D)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},d.blob&&(this.blob=function(){var D=_(this);if(D)return D;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 D=_(this);return D||(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(d.blob)return this.blob().then(C);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var D=_(this);if(D)return D;if(this._bodyBlob)return U(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(F(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},d.formData&&(this.formData=function(){return this.text().then(K)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function j(D){var R=D.toUpperCase();return L.indexOf(R)>-1?R:D}function H(D,R){if(!(this instanceof H))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var B=R.body;if(D instanceof H){if(D.bodyUsed)throw new TypeError("Already read");this.url=D.url,this.credentials=D.credentials,R.headers||(this.headers=new E(D.headers)),this.method=D.method,this.mode=D.mode,this.signal=D.signal,!B&&D._bodyInit!=null&&(B=D._bodyInit,D.bodyUsed=!0)}else this.url=String(D);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new E(R.headers)),this.method=j(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal||(function(){if("AbortController"in a){var z=new AbortController;return z.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&B)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(B),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var G=/([?&])_=[^&]*/;if(G.test(this.url))this.url=this.url.replace(G,"$1_="+new Date().getTime());else{var V=/\?/;this.url+=(V.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}H.prototype.clone=function(){return new H(this,{body:this._bodyInit})};function K(D){var R=new FormData;return D.trim().split("&").forEach(function(B){if(B){var G=B.split("="),V=G.shift().replace(/\+/g," "),z=G.join("=").replace(/\+/g," ");R.append(decodeURIComponent(V),decodeURIComponent(z))}}),R}function Z(D){var R=new E,B=D.replace(/\r?\n[\t ]+/g," ");return B.split("\r").map(function(G){return G.indexOf(`
|
|
121
|
+
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"}]}]}]},ut="powerhouse/document-drive",Se={setDriveNameOperation(i,e,t){i.name=e.input.name},setDriveIconOperation(i,e,t){i.icon=e.input.icon},setSharingTypeOperation(i,e,t){i.sharingType=e.input.type},setAvailableOfflineOperation(i,e,t){i.availableOffline=e.input.availableOffline},addListenerOperation(i,e,t){if(i.listeners.find(r=>r.listenerId===e.input.listener.listenerId))throw new Error(`A listener with Id: ${e.input.listener.listenerId} already exists`);i.listeners.push(e.input.listener)},removeListenerOperation(i,e,t){i.listeners=i.listeners.filter(r=>r.listenerId!==e.input.listenerId)},addTriggerOperation(i,e,t){if(i.triggers.find(r=>r.id===e.input.trigger.id))throw new Error(`A trigger with Id: ${e.input.trigger.id} already exists`);i.triggers.push(e.input.trigger)},removeTriggerOperation(i,e,t){i.triggers=i.triggers.filter(r=>r.id!==e.input.triggerId)}};function dr(i){return i.kind==="file"}function ci(i){return i.kind==="folder"}function rt(i,e){const t=e.filter(n=>n.parentFolder===i.id),r=t.map(n=>rt(n,e));return[...t,...r.flat()]}function Oo(i,e,t){const r=t.find(d=>d.id===i.srcId);if(!r)throw new Error(`Node with id ${i.srcId} not found`);const n=[{...r,name:i.targetName||r.name,parentFolder:i.targetParentFolder||null},...rt(r,t)],s={};i.targetParentFolder&&(s[i.targetParentFolder]=i.targetParentFolder);const o=d=>{let l=s[d.id];if(!l){const y=d.id;l=e(d),s[y]=l}return l};return n.map(d=>({srcId:d.id,targetId:o(d),targetName:d.name,targetParentFolder:d.parentFolder?s[d.parentFolder]:null}))}function ui(i,e){let t=0;const r=new RegExp(`^${di(e)} \\(copy\\)(?: (\\d+))?$`);for(const n of i){const s=n.match(r);if(s){const o=s[1]?parseInt(s[1],10):1;o>t&&(t=o)}}return t+1}function di(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(i){const{nodes:e,targetParentFolder:t,srcName:r}=i,n=e.filter(a=>t===""?a.parentFolder===null:a.parentFolder===t).map(a=>a.name);return n.includes(r)?`${r} (copy) ${ui(n,r)}`:r}const Qe=i=>/^[a-zA-Z0-9-_.\s()]+$/.test(i),Te={addFileOperation(i,e,t){if(i.nodes.find(s=>s.id===e.input.id))throw new Error(`Node with id ${e.input.id} already exists!`);if(!Qe(e.input.name))throw new Error(`Invalid name: '${e.input.name}'. Names must be valid URL characters.`);const r=Ne({nodes:i.nodes,srcName:e.input.name,targetParentFolder:e.input.parentFolder||null}),n={id:e.input.id,name:r,kind:"file",parentFolder:e.input.parentFolder??null,documentType:e.input.documentType};i.nodes.push(n),i.nodes.sort((s,o)=>s.id.localeCompare(o.id)),t?.({type:"CREATE_CHILD_DOCUMENT",input:{id:e.input.id,documentType:e.input.documentType}})},addFolderOperation(i,e){if(i.nodes.find(r=>r.id===e.input.id))throw new Error(`Node with id ${e.input.id} already exists!`);if(!Qe(e.input.name))throw new Error(`Invalid name: '${e.input.name}'. Names must be valid URL characters.`);const t=Ne({nodes:i.nodes,srcName:e.input.name,targetParentFolder:e.input.parentFolder||null});i.nodes.push({...e.input,name:t,kind:"folder",parentFolder:e.input.parentFolder??null}),i.nodes.sort((r,n)=>r.id.localeCompare(n.id))},deleteNodeOperation(i,e,t){const r=i.nodes.find(s=>s.id===e.input.id);if(!r)throw new Error(`Node with id ${e.input.id} not found`);const n=rt(r,i.nodes);i.nodes=i.nodes.filter(s=>s.id!==e.input.id&&!n.find(o=>o.id===s.id)),[r,...n].filter(s=>dr(s)).forEach(s=>{t?.({type:"DELETE_CHILD_DOCUMENT",input:{id:s.id}})})},updateFileOperation(i,e){if(e.input.name&&!Qe(e.input.name))throw new Error(`Invalid name: '${e.input.name}'. Names must be valid URL characters.`);i.nodes=i.nodes.map(t=>t.id===e.input.id?{...t,name:Ne({nodes:i.nodes,srcName:e.input.name??t.name,targetParentFolder:e.input.parentFolder||null}),documentType:e.input.documentType??t.documentType}:t),i.nodes.sort((t,r)=>t.id.localeCompare(r.id))},updateNodeOperation(i,e){if(e.input.name&&!Qe(e.input.name))throw new Error(`Invalid name: '${e.input.name}'. Names must be valid URL characters.`);i.nodes=i.nodes.map(t=>t.id===e.input.id?{...t,name:Ne({nodes:i.nodes,srcName:e.input.name??t.name,targetParentFolder:e.input.parentFolder||null}),parentFolder:e.input.parentFolder===null?null:t.parentFolder}:t),i.nodes.sort((t,r)=>t.id.localeCompare(r.id))},copyNodeOperation(i,e,t){const r=i.nodes.find(d=>d.id===e.input.srcId);if(!r)throw new Error(`Node with id ${e.input.srcId} not found`);if(i.nodes.find(d=>d.id===e.input.targetId))throw new Error(`Node with id ${e.input.targetId} already exists`);const s=Ne({nodes:i.nodes,srcName:e.input.targetName||r.name,targetParentFolder:e.input.targetParentFolder||null}),o={...r,id:e.input.targetId,slug:e.input.targetId,name:s,parentFolder:e.input.targetParentFolder||null};i.nodes.push(o),i.nodes.sort((d,l)=>d.id.localeCompare(l.id)),dr(o)&&t?.({type:"COPY_CHILD_DOCUMENT",input:{id:e.input.srcId,newId:e.input.targetId}})},moveNodeOperation(i,e){if(e.input.srcFolder===e.input.targetParentFolder)throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");const t=i.nodes.find(n=>n.id===e.input.srcFolder);if(!t)throw new Error(`Node with id ${e.input.srcFolder} not found`);const r=Ne({nodes:i.nodes,srcName:t.name,targetParentFolder:e.input.targetParentFolder||null});if(ci(t)&&rt(t,i.nodes).find(s=>s.id===e.input.targetParentFolder))throw new Error("Circular Reference Error: Cannot move a folder to one of its descendants");i.nodes=i.nodes.map(n=>n.id===e.input.srcFolder?{...n,name:r,parentFolder:e.input.targetParentFolder||null}:n),i.nodes.sort((n,s)=>n.id.localeCompare(s.id))}},li=(i,e,t)=>{if(cs(e))return i;const r=e;switch(r.type){case"ADD_FILE":Pr().parse(r.input),Te.addFileOperation(i[r.scope],e,t);break;case"ADD_FOLDER":Lr().parse(r.input),Te.addFolderOperation(i[r.scope],e,t);break;case"DELETE_NODE":kr().parse(r.input),Te.deleteNodeOperation(i[r.scope],e,t);break;case"UPDATE_FILE":Vr().parse(r.input),Te.updateFileOperation(i[r.scope],e,t);break;case"UPDATE_NODE":Wr().parse(r.input),Te.updateNodeOperation(i[r.scope],e,t);break;case"COPY_NODE":Fr().parse(r.input),Te.copyNodeOperation(i[r.scope],e,t);break;case"MOVE_NODE":zr().parse(r.input),Te.moveNodeOperation(i[r.scope],e,t);break;case"SET_DRIVE_NAME":Yr().parse(r.input),Se.setDriveNameOperation(i[r.scope],e,t);break;case"SET_DRIVE_ICON":Jr().parse(r.input),Se.setDriveIconOperation(i[r.scope],e,t);break;case"SET_SHARING_TYPE":Qr().parse(r.input),Se.setSharingTypeOperation(i[r.scope],e,t);break;case"SET_AVAILABLE_OFFLINE":Gr().parse(r.input),Se.setAvailableOfflineOperation(i[r.scope],e,t);break;case"ADD_LISTENER":Ur().parse(r.input),Se.addListenerOperation(i[r.scope],e,t);break;case"REMOVE_LISTENER":jr().parse(r.input),Se.removeListenerOperation(i[r.scope],e,t);break;case"ADD_TRIGGER":Br().parse(r.input),Se.addTriggerOperation(i[r.scope],e,t);break;case"REMOVE_TRIGGER":Hr().parse(r.input),Se.removeTriggerOperation(i[r.scope],e,t);break;default:return i}},tn=as(li),hi=ds.extend({documentType:pe(ut)}),nt=us.extend({global:ks(),local:Fs()}),rn=W({header:hi,state:nt,initialState:nt});function fi(i){return nt.safeParse(i).success}function gi(i){nt.parse(i)}function pi(i){return rn.safeParse(i).success}function mi(i){rn.parse(i)}const yi={name:"",nodes:[],icon:null},vi={listeners:[],triggers:[],sharingType:"private",availableOffline:!1},Ut=i=>({...$t(),global:{...yi,...i?.global},local:{...vi,...i?.local}}),nn=i=>{const e=fs(Ut,i);return e.header.documentType=ut,e.header.id=$e(),e},wi=(i,e)=>ls(i,e),bi=i=>hs(i,tn),Di=i=>fi(i),Si=i=>{gi(i)},Ei=i=>pi(i),Ii=i=>{mi(i)},Ti={actions:oi,reducer:tn,documentModel:gs($t(),ai),utils:{fileExtension:Ps,createState:Ut,createDocument:nn,loadFromInput:bi,saveToFileHandle:wi,isStateOfType:Di,assertIsStateOfType:Si,isDocumentOfType:Ei,assertIsDocumentOfType:Ii}};class Ri extends Error{id;constructor(e,t){super(`Document model "${e}" not found`,{cause:t}),this.id=e}}class ie extends Error{status;operation;constructor(e,t,r,n){super(r,{cause:n??t}),this.status=e,this.operation=t,n instanceof Error&&(this.stack=n.stack)}}class Mi extends ie{constructor(e,t){super("CONFLICT",t,`Conflicting operation on index ${t.index}`,{existingOperation:e,newOperation:t})}}var ke;(function(i){i.ID="id",i.SLUG="slug"})(ke||(ke={}));class qe extends Error{documentId;constructor(e,t=ke.ID){super(`Document (${e}) uses ${t} that already exists`),this.documentId=e}}class we extends Error{documentId;constructor(e){super(`Document with id ${e} not found`),this.documentId=e}}class Oi extends Error{syncUnitId;constructor(e){super(`Sync unit ${JSON.stringify(e)} not found`),this.syncUnitId=e}}function ve(i){return i.header.documentType===ut}function st(i,e){const t=Object.keys(i).reduce((n,s)=>{const o=s,a=i[o];return n[o]=a?.at(-1)?.index??0,n},{}),r=e.find(n=>n.index<(t[n.action.scope]??0));if(r)throw new ie("ERROR",r,`Tried to add operation with index ${r.index} and document is at index ${t[r.action.scope]}`);return e.sort((n,s)=>n.index-s.index).reduce((n,s)=>{const o=n[s.action.scope]||[];return{...n,[s.action.scope]:[...o,s]}},i)}function _i(i,e){return new Date(i)<new Date(e)}function Ie(i){const e=i?.at(-1);return e?e.index+1:0}const lr=typeof MessageChannel>"u"?new Error("MessageChannel is not supported"):i=>{const e=new AbortController,t=e.signal,r=new MessageChannel;return r.port1.postMessage(null),r.port2.addEventListener("message",()=>{i(),r.port1.close(),r.port2.close()},{once:!0,signal:t}),r.port2.start(),()=>e.abort()},hr=(()=>{const i=typeof window=="object"&&window||typeof global=="object"&&global||typeof self=="object"&&self;if(!i)return new Error("No global object found");const e=i;if(!e.postMessage||!e.addEventListener||e.importScripts)return new Error("postMessage is not supported");let t=0;const r=new Map;function n(){return t===9007199254740991?0:++t}const s="com.usePostMessage"+Math.random();return e.addEventListener("message",o=>{const a=o;if(typeof a.data!="string"||a.source!==e||!a.data.startsWith(s))return;const d=a.data.split(":").at(1);if(d===void 0)return;const l=+d,y=r.get(l);y&&(y(),r.delete(l))},!1),o=>{const a=n();return r.set(a,o),e.postMessage(s+":"+a,{targetOrigin:"*"}),()=>{r.delete(a)}}})(),fr=typeof window<"u"?new Error("setImmediate is not supported on the browser"):typeof setImmediate>"u"?new Error("setImmediate is not supported"):i=>{const e=setImmediate(i);return()=>clearImmediate(e)},Ai=i=>{const e=setTimeout(i,0);return()=>clearTimeout(e)};function Bt(i){return fr instanceof Error?lr instanceof Error?hr instanceof Error?Ai(i):hr(i):lr(i):fr(i)}function xt(i,e=Bt){if(e instanceof Error)throw new Error("queueMethod is not supported",{cause:e});return new Promise((t,r)=>{e(()=>{i().then(t).catch(r)})})}class Ni{drive;processor;taskQueueMethod;transmitQueue;constructor(e,t,r){this.drive=e,this.processor=t,this.taskQueueMethod=r===void 0?Bt:r}async#e(e){const t=[],r=new Map,n=async s=>{const o=r.get(s);if(o)return o;const a={revisions:{[e.scope]:s},checkHashes:!1},d=await(e.documentId===e.driveId?this.drive.getDrive(e.driveId,a):this.drive.getDocument(e.documentId,a));return s<0?r.set(s,d.initialState[e.scope]):r.set(s,d.state[e.scope]),r.get(s)};for(const s of e.operations){const o=()=>n(s.index),a=await(this.taskQueueMethod?xt(o,this.taskQueueMethod):o()),d=()=>n(s.index-1),l=await(this.taskQueueMethod?xt(d,this.taskQueueMethod):d()),y={id:s.actionId,timestampUtcMs:s.timestampUtcMs,type:s.type,input:s.input,context:s.context,scope:e.scope};t.push({...s,id:s.id??Ve(e.documentId,e.scope,e.branch,s.actionId),state:a,previousState:l,action:y})}return t}async transmit(e,t){const r=async()=>{const n=[];for(const s of e){const o=await this.#e(s),a=await this.drive.getDocument(s.documentId),d=o.at(-1)?.state??a.initialState[s.scope];n.push({...s,documentType:a.header.documentType,operations:o,state:d,document:a})}try{return await this.processor.onStrands(n),e.map(({operations:s,...o})=>({...o,status:"SUCCESS",revision:Ie(s)}))}catch(s){return fe.error(s),e.map(({operations:o,...a})=>({...a,status:"ERROR",revision:o.at(0)?.index??0}))}};return this.transmitQueue=this.transmitQueue?.then(()=>r())??r(),this.transmitQueue}async disconnect(){await this.processor.onDisconnect()}}function sn(i){return{selectFrom:i.selectFrom.bind(i),selectNoFrom:i.selectNoFrom.bind(i),with:i.with.bind(i),withRecursive:i.withRecursive.bind(i),withSchema:e=>sn(i.withSchema(e))}}const gr=Symbol.for("ph.IS_RELATIONAL_DB_PROCESSOR");class Ci{_namespace;_filter;relationalDb;constructor(e,t,r){this._namespace=e,this._filter=t,this.relationalDb=r}static[gr]=!0;static is(e){let t=Object.getPrototypeOf(e);for(;t;){if(t.constructor?.[gr])return!0;t=Object.getPrototypeOf(t)}return!1}static getNamespace(e){return`${this.name}_${e.replaceAll("-","_")}`}static query(e,t){return t.queryNamespace(this.getNamespace(e))}get filter(){return this._filter}get namespace(){return this._namespace}get query(){return sn(this.relationalDb)}}function pr(i){return Ci.is(i)}class _o{listeners;drive;logger=me(["document-drive","processor-manager"]);processorsByDrive=new Map;idToFactory=new Map;identifierToListeners=new Map;constructor(e,t){this.listeners=e,this.drive=t}async registerFactory(e,t){this.logger.debug(`Registering factory '${e}'.`),this.idToFactory.set(e,t);const r=await this.drive.getDrives();for(const n of r)await this.createProcessors(n,e,t)}async unregisterFactory(e){const t=this.identifierToListeners.get(e)??[];for(const r of t)await this.listeners.removeListener(r.driveId,r.listenerId).catch(this.logger.error),r.transmitter?.disconnect&&await r.transmitter.disconnect();this.identifierToListeners.set(e,[])}async registerDrive(e){this.logger.debug(`Registering drive '${e}'.`);for(const[t,r]of this.idToFactory)await this.createProcessors(e,t,r)}async createProcessors(e,t,r){const n=await this.drive.getDrive(e);let s=this.identifierToListeners.get(t);s||(s=[],this.identifierToListeners.set(t,s));let o=this.processorsByDrive.get(e);o||(o=[],this.processorsByDrive.set(e,o));let a=[];try{a=await r(n.header)}catch(d){this.logger.error(`Error creating processors for drive ${e}:`,d);return}for(const{filter:d,processor:l}of a){const y=pr(l);if(y&&o.some(b=>pr(b.processor)&&b.processor.namespace===l.namespace)){this.logger.debug(`Processor with namespace '${l.namespace}' already registered for drive '${e}'.`);continue}y&&await l.initAndUpgrade();const f=$e(),w={driveId:e,listenerId:f,block:!1,system:!1,filter:d,callInfo:void 0,transmitter:new Ni(this.drive,l)};await this.listeners.setListener(e,w),s.push(w),o.push({filter:d,processor:l})}}}class xi{id;running=!1;deleted=!1;items=[];dependencies=new Array;constructor(e){this.id=e}async isRunning(){return this.running}async setRunning(e){this.running=e}async setDeleted(e){this.deleted=e}async isDeleted(){return this.deleted}async addJob(e){return this.items.push(e),Promise.resolve()}async getNextJob(){const e=this.items.shift();return Promise.resolve(e)}async amountOfJobs(){return Promise.resolve(this.items.length)}getId(){return this.id}async isBlocked(){return this.running||this.deleted||this.dependencies.length>0}async getJobs(){return this.items}async addDependency(e){this.dependencies.includes(e.jobId)||this.dependencies.push(e.jobId)}async removeDependency(e){const t=this.dependencies.indexOf(e.jobId);t>-1&&this.dependencies.splice(t,1)}}let on=()=>({emit(i,...e){for(let t=this.events[i]||[],r=0,n=t.length;r<n;r++)t[r](...e)},events:{},on(i,e){return(this.events[i]||=[]).push(e),()=>{this.events[i]=this.events[i]?.filter(t=>e!==t)}}});function Xe(i){return"documentType"in i}function an(i){return"operations"in i}function $i(i){return"actions"in i}class Pi{logger=me(["EventQueueManager"]);emitter=on();queues=new Map;globalQueue=new Array;isFindingJob=!1;maxWorkers;workers;runningJobs=new Array;timeout;delegate;onError;constructor(e=1,t=0){this.maxWorkers=e,this.workers=0,this.timeout=t}async init(e,t){this.delegate=e,this.onError=t;function r(n){return(async(...s)=>{try{await n(...s)}catch(o){throw o instanceof Error?o:new Error(JSON.stringify(o))}})}return this.emitter.on("jobAdded",r(async n=>{this.logger.verbose("Added job",n),await this.processNextJob()})),this.emitter.on("jobStarted",r(async n=>{this.logger.verbose("Started job",n.jobId),this.runningJobs.push(n),await this.processNextJob()})),this.emitter.on("jobCompleted",r(async(n,s)=>{this.logger.verbose("Completed job",n.jobId),await this.handleJobCompleted(n,s)})),this.emitter.on("jobFailed",r(async(n,s)=>{this.logger.error("Failed job",n,s),this.removeJob(n),t(s),await this.processNextJob()})),Promise.resolve()}async addJob(e){if(!this.delegate)throw new Error("No server delegate defined");const t=$e(),r=Xe(e),n=Xe(e)?void 0:an(e)?e.operations:e.actions;if(!r&&!n?.length)throw new Error("Job has no operations or actions: "+JSON.stringify(e));const s=n?.at(0),o=s?"action"in s?s.action.scope:s.scope:"global";if(n?.find(l=>("action"in l?l.action.scope:l.scope)!==o))throw new Error("Job has actions with different scopes");const a=this.getQueue(e.documentId,o);if(!Xe(e)&&await a.isDeleted())throw new Error("Job has operations for deleted document");const d=Object.freeze({jobId:t,...e});return await a.addJob(d),this.globalQueue.push({jobId:t,documentId:e.documentId,scope:o,timestampUtcMs:new Date().toUTCString()}),this.emit("jobAdded",d),t}getQueue(e,t){let r=this.queues.get(e);r||(r=new Map,this.queues.set(e,r));let n=r.get(t);return n||(n=new xi(t),r.set(t,n)),n}getDocumentQueues(e){return this.queues.get(e)}removeQueue(e,t){const n=this.queues.get(e)?.delete(t);return n&&this.emit("queueRemoved",{documentId:e,scope:t}),n}removeDocumentQueues(e){this.queues.get(e)?.keys().forEach(r=>{this.removeQueue(e,r)})}removeJob(e){const t=this.runningJobs.findIndex(n=>n.jobId===e.jobId);t===-1&&this.logger.warn("Running job not found",e.jobId),this.runningJobs.splice(t,1);const r=this.globalQueue.findIndex(n=>n.jobId===e.jobId);r===-1&&this.logger.warn("Job not found on global queue",e.jobId),this.globalQueue.splice(r,1)}async handleJobCompleted(e,t){return this.removeJob(e),this.processNextJob()}isBusy(){return this.workers>=this.maxWorkers}async processNextJob(){if(this.isFindingJob)return;if(!this.delegate)throw new Error("No server delegate defined");if(this.globalQueue.length===0||this.isBusy())return;this.isFindingJob=!0,this.workers++;let e,t;try{const r=await this.findNextJob();e=r?.queue,t=r?.job}catch(r){fe.error("Error finding next job",r)}if(!e||!t){this.workers--,this.isFindingJob=!1;return}try{await e.setRunning(!0),this.isFindingJob=!1,this.emit("jobStarted",t);const r=await this.delegate.processJob(t);this.workers--,await e.setRunning(!1),this.emit("jobCompleted",t,r)}catch(r){fe.error("Job failed",r),this.workers--,this.isFindingJob=!1,await e.setRunning(!1),this.emit("jobFailed",t,r instanceof Error?r:new Error(JSON.stringify(r)))}}async findNextJob(){const e=new Set;for(const t of this.globalQueue){const r=this.getQueue(t.documentId,t.scope),n=r.getId();if(e.has(n))continue;if(await r.isBlocked()){e.add(r.getId());continue}const s=await r.getNextJob();if(s?.jobId!==t.jobId){fe.warn("Queue has different job waiting to be picked up"),fe.error(t,s);continue}return{queue:r,job:s}}}emit(e,...t){this.emitter.emit(e,...t)}on(e,t){return this.emitter.on(e,t)}}class dt extends Error{}class Re extends dt{constructor(e){super(`Read drive ${e} not found.`)}}class Li extends dt{constructor(e){super(`Read drive with slug ${e} not found.`)}}class mr extends dt{constructor(e,t){super(`Document with id ${t} not found on read drive ${e}.`)}}const Ft=JSON,Ui=i=>i.toUpperCase(),Bi=i=>{const e={};return i.forEach((t,r)=>{e[r]=t}),e},Fi=(i,e,t)=>i.document?i:{document:i,variables:e,requestHeaders:t,signal:void 0},ki=(i,e,t)=>i.query?i:{query:i,variables:e,requestHeaders:t,signal:void 0},qi=(i,e)=>i.documents?i:{documents:i,requestHeaders:e,signal:void 0},yr=i=>{let e;const t=i.definitions.filter(r=>r.kind==="OperationDefinition");return t.length===1&&(e=t[0]?.name?.value),e},Et=i=>{if(typeof i=="string"){let t;try{const r=Ss(i);t=yr(r)}catch{}return{query:i,operationName:t}}const e=yr(i);return{query:Es(i),operationName:e}};class xe extends Error{constructor(e,t){const r=`${xe.extractMessage(e)}: ${JSON.stringify({response:e,request:t})}`;super(r),Object.setPrototypeOf(this,xe.prototype),this.response=e,this.request=t,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,xe)}static extractMessage(e){return e.errors?.[0]?.message??`GraphQL Error (Code: ${e.status})`}}var Ke={exports:{}},vr;function zi(){return vr||(vr=1,(function(i,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Ee<"u"&&Ee,r=(function(){function s(){this.fetch=!1,this.DOMException=t.DOMException}return s.prototype=t,new s})();(function(s){(function(o){var a=typeof s<"u"&&s||typeof self<"u"&&self||typeof Ee<"u"&&Ee||{},d={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function l(D){return D&&DataView.prototype.isPrototypeOf(D)}if(d.arrayBuffer)var y=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=ArrayBuffer.isView||function(D){return D&&y.indexOf(Object.prototype.toString.call(D))>-1};function w(D){if(typeof D!="string"&&(D=String(D)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(D)||D==="")throw new TypeError('Invalid character in header field name: "'+D+'"');return D.toLowerCase()}function b(D){return typeof D!="string"&&(D=String(D)),D}function p(D){var R={next:function(){var B=D.shift();return{done:B===void 0,value:B}}};return d.iterable&&(R[Symbol.iterator]=function(){return R}),R}function E(D){this.map={},D instanceof E?D.forEach(function(R,B){this.append(B,R)},this):Array.isArray(D)?D.forEach(function(R){if(R.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+R.length);this.append(R[0],R[1])},this):D&&Object.getOwnPropertyNames(D).forEach(function(R){this.append(R,D[R])},this)}E.prototype.append=function(D,R){D=w(D),R=b(R);var B=this.map[D];this.map[D]=B?B+", "+R:R},E.prototype.delete=function(D){delete this.map[w(D)]},E.prototype.get=function(D){return D=w(D),this.has(D)?this.map[D]:null},E.prototype.has=function(D){return this.map.hasOwnProperty(w(D))},E.prototype.set=function(D,R){this.map[w(D)]=b(R)},E.prototype.forEach=function(D,R){for(var B in this.map)this.map.hasOwnProperty(B)&&D.call(R,this.map[B],B,this)},E.prototype.keys=function(){var D=[];return this.forEach(function(R,B){D.push(B)}),p(D)},E.prototype.values=function(){var D=[];return this.forEach(function(R){D.push(R)}),p(D)},E.prototype.entries=function(){var D=[];return this.forEach(function(R,B){D.push([B,R])}),p(D)},d.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function _(D){if(!D._noBody){if(D.bodyUsed)return Promise.reject(new TypeError("Already read"));D.bodyUsed=!0}}function A(D){return new Promise(function(R,B){D.onload=function(){R(D.result)},D.onerror=function(){B(D.error)}})}function C(D){var R=new FileReader,B=A(R);return R.readAsArrayBuffer(D),B}function U(D){var R=new FileReader,B=A(R),G=/charset=([A-Za-z0-9_-]+)/.exec(D.type),V=G?G[1]:"utf-8";return R.readAsText(D,V),B}function F(D){for(var R=new Uint8Array(D),B=new Array(R.length),G=0;G<R.length;G++)B[G]=String.fromCharCode(R[G]);return B.join("")}function I(D){if(D.slice)return D.slice(0);var R=new Uint8Array(D.byteLength);return R.set(new Uint8Array(D)),R.buffer}function P(){return this.bodyUsed=!1,this._initBody=function(D){this.bodyUsed=this.bodyUsed,this._bodyInit=D,D?typeof D=="string"?this._bodyText=D:d.blob&&Blob.prototype.isPrototypeOf(D)?this._bodyBlob=D:d.formData&&FormData.prototype.isPrototypeOf(D)?this._bodyFormData=D:d.searchParams&&URLSearchParams.prototype.isPrototypeOf(D)?this._bodyText=D.toString():d.arrayBuffer&&d.blob&&l(D)?(this._bodyArrayBuffer=I(D.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):d.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(D)||f(D))?this._bodyArrayBuffer=I(D):this._bodyText=D=Object.prototype.toString.call(D):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof D=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):d.searchParams&&URLSearchParams.prototype.isPrototypeOf(D)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},d.blob&&(this.blob=function(){var D=_(this);if(D)return D;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 D=_(this);return D||(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(d.blob)return this.blob().then(C);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var D=_(this);if(D)return D;if(this._bodyBlob)return U(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(F(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},d.formData&&(this.formData=function(){return this.text().then(K)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function j(D){var R=D.toUpperCase();return L.indexOf(R)>-1?R:D}function H(D,R){if(!(this instanceof H))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var B=R.body;if(D instanceof H){if(D.bodyUsed)throw new TypeError("Already read");this.url=D.url,this.credentials=D.credentials,R.headers||(this.headers=new E(D.headers)),this.method=D.method,this.mode=D.mode,this.signal=D.signal,!B&&D._bodyInit!=null&&(B=D._bodyInit,D.bodyUsed=!0)}else this.url=String(D);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new E(R.headers)),this.method=j(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal||(function(){if("AbortController"in a){var z=new AbortController;return z.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&B)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(B),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var G=/([?&])_=[^&]*/;if(G.test(this.url))this.url=this.url.replace(G,"$1_="+new Date().getTime());else{var V=/\?/;this.url+=(V.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}H.prototype.clone=function(){return new H(this,{body:this._bodyInit})};function K(D){var R=new FormData;return D.trim().split("&").forEach(function(B){if(B){var G=B.split("="),V=G.shift().replace(/\+/g," "),z=G.join("=").replace(/\+/g," ");R.append(decodeURIComponent(V),decodeURIComponent(z))}}),R}function Z(D){var R=new E,B=D.replace(/\r?\n[\t ]+/g," ");return B.split("\r").map(function(G){return G.indexOf(`
|
|
122
122
|
`)===0?G.substr(1,G.length):G}).forEach(function(G){var V=G.split(":"),z=V.shift().trim();if(z){var ae=V.join(":").trim();try{R.append(z,ae)}catch(_e){console.warn("Response "+_e.message)}}}),R}P.call(H.prototype);function Y(D,R){if(!(this instanceof Y))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(R||(R={}),this.type="default",this.status=R.status===void 0?200:R.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=R.statusText===void 0?"":""+R.statusText,this.headers=new E(R.headers),this.url=R.url||"",this._initBody(D)}P.call(Y.prototype),Y.prototype.clone=function(){return new Y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},Y.error=function(){var D=new Y(null,{status:200,statusText:""});return D.ok=!1,D.status=0,D.type="error",D};var se=[301,302,303,307,308];Y.redirect=function(D,R){if(se.indexOf(R)===-1)throw new RangeError("Invalid status code");return new Y(null,{status:R,headers:{location:D}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(R,B){this.message=R,this.name=B;var G=Error(R);this.stack=G.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function le(D,R){return new Promise(function(B,G){var V=new H(D,R);if(V.signal&&V.signal.aborted)return G(new o.DOMException("Aborted","AbortError"));var z=new XMLHttpRequest;function ae(){z.abort()}z.onload=function(){var ne={statusText:z.statusText,headers:Z(z.getAllResponseHeaders()||"")};V.url.indexOf("file://")===0&&(z.status<200||z.status>599)?ne.status=200:ne.status=z.status,ne.url="responseURL"in z?z.responseURL:ne.headers.get("X-Request-URL");var ye="response"in z?z.response:z.responseText;setTimeout(function(){B(new Y(ye,ne))},0)},z.onerror=function(){setTimeout(function(){G(new TypeError("Network request failed"))},0)},z.ontimeout=function(){setTimeout(function(){G(new TypeError("Network request timed out"))},0)},z.onabort=function(){setTimeout(function(){G(new o.DOMException("Aborted","AbortError"))},0)};function _e(ne){try{return ne===""&&a.location.href?a.location.href:ne}catch{return ne}}if(z.open(V.method,_e(V.url),!0),V.credentials==="include"?z.withCredentials=!0:V.credentials==="omit"&&(z.withCredentials=!1),"responseType"in z&&(d.blob?z.responseType="blob":d.arrayBuffer&&(z.responseType="arraybuffer")),R&&typeof R.headers=="object"&&!(R.headers instanceof E||a.Headers&&R.headers instanceof a.Headers)){var ze=[];Object.getOwnPropertyNames(R.headers).forEach(function(ne){ze.push(w(ne)),z.setRequestHeader(ne,b(R.headers[ne]))}),V.headers.forEach(function(ne,ye){ze.indexOf(ye)===-1&&z.setRequestHeader(ye,ne)})}else V.headers.forEach(function(ne,ye){z.setRequestHeader(ye,ne)});V.signal&&(V.signal.addEventListener("abort",ae),z.onreadystatechange=function(){z.readyState===4&&V.signal.removeEventListener("abort",ae)}),z.send(typeof V._bodyInit>"u"?null:V._bodyInit)})}return le.polyfill=!0,a.fetch||(a.fetch=le,a.Headers=E,a.Request=H,a.Response=Y),o.Headers=E,o.Request=H,o.Response=Y,o.fetch=le,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var n=t.fetch?t:r;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,i.exports=e})(Ke,Ke.exports)),Ke.exports}var it=zi();const Ze=Pt(it),ji=Ns({__proto__:null,default:Ze},[it]),Ce=i=>{let e={};return i&&(typeof Headers<"u"&&i instanceof Headers||ji&&it.Headers&&i instanceof it.Headers?e=Bi(i):Array.isArray(i)?i.forEach(([t,r])=>{t&&r!==void 0&&(e[t]=r)}):e=i),e},wr=i=>i.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),Hi=i=>{if(!Array.isArray(i.query)){const r=i,n=[`query=${encodeURIComponent(wr(r.query))}`];return i.variables&&n.push(`variables=${encodeURIComponent(r.jsonSerializer.stringify(r.variables))}`),r.operationName&&n.push(`operationName=${encodeURIComponent(r.operationName)}`),n.join("&")}if(typeof i.variables<"u"&&!Array.isArray(i.variables))throw new Error("Cannot create query with given variable type, array expected");const e=i,t=i.query.reduce((r,n,s)=>(r.push({query:wr(n),variables:e.variables?e.jsonSerializer.stringify(e.variables[s]):void 0}),r),[]);return`query=${encodeURIComponent(e.jsonSerializer.stringify(t))}`},Gi=i=>async e=>{const{url:t,query:r,variables:n,operationName:s,fetch:o,fetchOptions:a,middleware:d}=e,l={...e.headers};let y="",f;i==="POST"?(f=Yi(r,n,s,a.jsonSerializer),typeof f=="string"&&(l["Content-Type"]="application/json")):y=Hi({query:r,variables:n,operationName:s,jsonSerializer:a.jsonSerializer??Ft});const w={method:i,headers:l,body:f,...a};let b=t,p=w;if(d){const E=await Promise.resolve(d({...w,url:t,operationName:s,variables:n})),{url:_,...A}=E;b=_,p=A}return y&&(b=`${b}?${y}`),await o(b,p)};class Ji{constructor(e,t={}){this.url=e,this.requestConfig=t,this.rawRequest=async(...r)=>{const[n,s,o]=r,a=ki(n,s,o),{headers:d,fetch:l=Ze,method:y="POST",requestMiddleware:f,responseMiddleware:w,...b}=this.requestConfig,{url:p}=this;a.signal!==void 0&&(b.signal=a.signal);const{operationName:E}=Et(a.query);return It({url:p,query:a.query,variables:a.variables,headers:{...Ce(Tt(d)),...Ce(a.requestHeaders)},operationName:E,fetch:l,method:y,fetchOptions:b,middleware:f}).then(_=>(w&&w(_),_)).catch(_=>{throw w&&w(_),_})}}async request(e,...t){const[r,n]=t,s=Fi(e,r,n),{headers:o,fetch:a=Ze,method:d="POST",requestMiddleware:l,responseMiddleware:y,...f}=this.requestConfig,{url:w}=this;s.signal!==void 0&&(f.signal=s.signal);const{query:b,operationName:p}=Et(s.document);return It({url:w,query:b,variables:s.variables,headers:{...Ce(Tt(o)),...Ce(s.requestHeaders)},operationName:p,fetch:a,method:d,fetchOptions:f,middleware:l}).then(E=>(y&&y(E),E.data)).catch(E=>{throw y&&y(E),E})}batchRequests(e,t){const r=qi(e,t),{headers:n,...s}=this.requestConfig;r.signal!==void 0&&(s.signal=r.signal);const o=r.documents.map(({document:d})=>Et(d).query),a=r.documents.map(({variables:d})=>d);return It({url:this.url,query:o,variables:a,headers:{...Ce(Tt(n)),...Ce(r.requestHeaders)},operationName:void 0,fetch:this.requestConfig.fetch??Ze,method:this.requestConfig.method||"POST",fetchOptions:s,middleware:this.requestConfig.requestMiddleware}).then(d=>(this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(d),d.data)).catch(d=>{throw this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(d),d})}setHeaders(e){return this.requestConfig.headers=e,this}setHeader(e,t){const{headers:r}=this.requestConfig;return r?r[e]=t:this.requestConfig.headers={[e]:t},this}setEndpoint(e){return this.url=e,this}}const It=async i=>{const{query:e,variables:t,fetchOptions:r}=i,n=Gi(Ui(i.method??"post")),s=Array.isArray(i.query),o=await n(i),a=await Qi(o,r.jsonSerializer??Ft),d=Array.isArray(a)?!a.some(({data:y})=>!y):!!a.data,l=Array.isArray(a)||!a.errors||Array.isArray(a.errors)&&!a.errors.length||r.errorPolicy==="all"||r.errorPolicy==="ignore";if(o.ok&&l&&d){const{errors:y,...f}=(Array.isArray(a),a),w=r.errorPolicy==="ignore"?f:a;return{...s?{data:w}:w,headers:o.headers,status:o.status}}else{const y=typeof a=="string"?{error:a}:a;throw new xe({...y,status:o.status,headers:o.headers},{query:e,variables:t})}},Yi=(i,e,t,r)=>{const n=r??Ft;if(!Array.isArray(i))return n.stringify({query:i,variables:e,operationName:t});if(typeof e<"u"&&!Array.isArray(e))throw new Error("Cannot create request body with given variable type, array expected");const s=i.reduce((o,a,d)=>(o.push({query:a,variables:e?e[d]:void 0}),o),[]);return n.stringify(s)},Qi=async(i,e)=>{let t;return i.headers.forEach((r,n)=>{n.toLowerCase()==="content-type"&&(t=r)}),t&&(t.toLowerCase().startsWith("application/json")||t.toLowerCase().startsWith("application/graphql+json")||t.toLowerCase().startsWith("application/graphql-response+json"))?e.parse(await i.text()):i.text()},Tt=i=>typeof i=="function"?i():i,ge=(i,...e)=>i.reduce((t,r,n)=>`${t}${r}${n in e?String(e[n]):""}`,"");async function ce(i,e,t,r){const n=new Ji(i,{fetch,headers:r||{}}),{errors:s,...o}=await n.request(e,t),a={...o};return s?.length&&(a.errors=s.map(({message:d,...l})=>new Is(d,l))),a}function et(i,e){return i instanceof Dt?Object.entries(i.getFields()).map(([t,r])=>{const n=r.type instanceof cr?r.type.ofType:r.type;if(n instanceof Dt||n instanceof St)return`${t} { ${et(n,e)} }`;if(n instanceof Rs){const s=n.ofType instanceof cr?n.ofType.ofType:n.ofType;if(s instanceof Ms)return t;if(s instanceof Dt||s instanceof St)return`${t} { ${et(s,e)} }`;throw new Error(`List item type ${s.toString()} is not handled`)}return t}).join(" "):i instanceof St?i.getTypes().map(t=>`... on ${e?`${e}_`:""}${t.name} { ${et(t,e)} }`).join(" "):""}function Ki(i,e,t){const r=Ar(i.name),n=i.specifications.at(-1);if(!n)throw new Error("No document model specification found");const s=`${n.state.global.schema} type Query { ${r}: ${r}State }`,a=Ts(s).getQueryType();if(!a)throw new Error("No query type found");const l=a.getFields()[r];if(!l)throw new Error("No state query found");return et(l.type,e)}async function Fe(i,e){const t=await e.generateJwtHandler?.(i),r=t?{Authorization:`Bearer ${t}`}:{};return cn(i,r)}async function cn(i,e){let t;try{const r=await ce(i,ge`
|
|
123
123
|
query getDrive {
|
|
124
124
|
drive {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./sentry_react-cODD7zWc.js";import"./document_model_editor-
|
|
1
|
+
import"./sentry_react-cODD7zWc.js";import"./document_model_editor-_uYV5sBF.js";import"./react-DQSxOgtG.js";
|