@neuralnomads/codenomad-dev 0.20.0-dev-20260925-ec1c0bed → 0.20.0-dev-20260925-25e07c74
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/package.json +1 -1
- package/public/assets/App-DJjznRZ_.js +58 -0
- package/public/assets/App-DJjznRZ_.js.map +1 -0
- package/public/assets/FilesTab-CIZ1puTy.js +3 -0
- package/public/assets/{FilesTab-BGDp8P8-.js.map → FilesTab-CIZ1puTy.js.map} +1 -1
- package/public/assets/GitChangesTab-DwMgRf-D.js +3 -0
- package/public/assets/{GitChangesTab-DxMyCYbp.js.map → GitChangesTab-DwMgRf-D.js.map} +1 -1
- package/public/assets/{SplitFilePanel-DfkEaV8T.js → SplitFilePanel-BCLtSYpn.js} +2 -2
- package/public/assets/{SplitFilePanel-DfkEaV8T.js.map → SplitFilePanel-BCLtSYpn.js.map} +1 -1
- package/public/assets/StatusTab-I954HOlT.js +2 -0
- package/public/assets/StatusTab-I954HOlT.js.map +1 -0
- package/public/assets/{align-justify-BADRRld7.js → align-justify-ClApgjuX.js} +2 -2
- package/public/assets/{align-justify-BADRRld7.js.map → align-justify-ClApgjuX.js.map} +1 -1
- package/public/assets/{bundle-full-Ds4j0r8b.js → bundle-full-Bv-Zo-BN.js} +2 -2
- package/public/assets/{bundle-full-Ds4j0r8b.js.map → bundle-full-Bv-Zo-BN.js.map} +1 -1
- package/public/assets/{client-state-Brb7YeOo.js → client-state-BUfw9mlB.js} +2 -2
- package/public/assets/{client-state-Brb7YeOo.js.map → client-state-BUfw9mlB.js.map} +1 -1
- package/public/assets/diff-viewer-DTYmoMJJ.js +2 -0
- package/public/assets/{diff-viewer-C1WW4LNh.js.map → diff-viewer-DTYmoMJJ.js.map} +1 -1
- package/public/assets/{index-CrhQXZUm.js → index--pzZg96p.js} +2 -2
- package/public/assets/{index-CrhQXZUm.js.map → index--pzZg96p.js.map} +1 -1
- package/public/assets/{index-DfKVCgfr.js → index-B7Rzw0N8.js} +2 -2
- package/public/assets/{index-DfKVCgfr.js.map → index-B7Rzw0N8.js.map} +1 -1
- package/public/assets/{index-D68UOUEy.js → index-BpxnUbDV.js} +2 -2
- package/public/assets/{index-D68UOUEy.js.map → index-BpxnUbDV.js.map} +1 -1
- package/public/assets/{index-Dp_g4ObO.js → index-ByEDZSKg.js} +3 -3
- package/public/assets/{index-Dp_g4ObO.js.map → index-ByEDZSKg.js.map} +1 -1
- package/public/assets/{index-C-4MHX3f.js → index-CIsPS6rK.js} +2 -2
- package/public/assets/{index-C-4MHX3f.js.map → index-CIsPS6rK.js.map} +1 -1
- package/public/assets/{index-Dqd_-YI4.js → index-Cq3k5jiZ.js} +2 -2
- package/public/assets/{index-Dqd_-YI4.js.map → index-Cq3k5jiZ.js.map} +1 -1
- package/public/assets/{index-B_nqRKS8.js → index-CvvEjI09.js} +2 -2
- package/public/assets/{index-B_nqRKS8.js.map → index-CvvEjI09.js.map} +1 -1
- package/public/assets/{index-UD8hCFG8.js → index-DFYhjWFw.js} +2 -2
- package/public/assets/{index-UD8hCFG8.js.map → index-DFYhjWFw.js.map} +1 -1
- package/public/assets/index-NCKXobfr.css +1 -0
- package/public/assets/{index-Fc9xv2mA.js → index-QPxBkmUK.js} +2 -2
- package/public/assets/{index-Fc9xv2mA.js.map → index-QPxBkmUK.js.map} +1 -1
- package/public/assets/{index-DXsN55dj.js → index-cCIfI5Gs.js} +2 -2
- package/public/assets/{index-DXsN55dj.js.map → index-cCIfI5Gs.js.map} +1 -1
- package/public/assets/{index-Dz83P2V8.js → index-kCzCI98C.js} +2 -2
- package/public/assets/{index-Dz83P2V8.js.map → index-kCzCI98C.js.map} +1 -1
- package/public/assets/{index-D6fhZZF8.js → index-q1q2jGr4.js} +2 -2
- package/public/assets/{index-D6fhZZF8.js.map → index-q1q2jGr4.js.map} +1 -1
- package/public/assets/{loading-Cyqe6-mR.js → loading-DUGpBMNV.js} +2 -2
- package/public/assets/{loading-Cyqe6-mR.js.map → loading-DUGpBMNV.js.map} +1 -1
- package/public/assets/{main-CHx9Ep16.js → main-CcoQlXKa.js} +7 -7
- package/public/assets/{main-CHx9Ep16.js.map → main-CcoQlXKa.js.map} +1 -1
- package/public/assets/{markdown-Ca4DSqip.js → markdown-B2LqHvL9.js} +37 -36
- package/public/assets/markdown-B2LqHvL9.js.map +1 -0
- package/public/assets/{startup-state-settings-card-BrHxjQL8.js → startup-state-settings-card-BCKRPH7W.js} +2 -2
- package/public/assets/{startup-state-settings-card-BrHxjQL8.js.map → startup-state-settings-card-BCKRPH7W.js.map} +1 -1
- package/public/assets/{terminal-square-C6Lcru-E.js → terminal-square-BgSAfXCt.js} +2 -2
- package/public/assets/{terminal-square-C6Lcru-E.js.map → terminal-square-BgSAfXCt.js.map} +1 -1
- package/public/assets/{tool-call-K1OzjfZ4.js → tool-call-Df4j6aME.js} +5 -5
- package/public/assets/{tool-call-K1OzjfZ4.js.map → tool-call-Df4j6aME.js.map} +1 -1
- package/public/assets/{unified-picker-DcpK--5d.js → unified-picker-DZfkh5jj.js} +2 -2
- package/public/assets/{unified-picker-DcpK--5d.js.map → unified-picker-DZfkh5jj.js.map} +1 -1
- package/public/assets/{wrap-text-BC1Y2abh.js → wrap-text-BFsJjS2I.js} +2 -2
- package/public/assets/{wrap-text-BC1Y2abh.js.map → wrap-text-BFsJjS2I.js.map} +1 -1
- package/public/index.html +3 -3
- package/public/loading.html +3 -3
- package/public/sw.js +1 -1
- package/public/sw.js.map +1 -1
- package/public/assets/App-DdteBqTo.js +0 -57
- package/public/assets/App-DdteBqTo.js.map +0 -1
- package/public/assets/FilesTab-BGDp8P8-.js +0 -3
- package/public/assets/GitChangesTab-DxMyCYbp.js +0 -3
- package/public/assets/StatusTab-BoRtv1br.js +0 -2
- package/public/assets/StatusTab-BoRtv1br.js.map +0 -1
- package/public/assets/diff-viewer-C1WW4LNh.js +0 -2
- package/public/assets/index-Cx7w6zfy.css +0 -1
- package/public/assets/markdown-Ca4DSqip.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/startup-state-settings-card-
|
|
2
|
-
var GT=Object.defineProperty;var ZT=(e,t,n)=>t in e?GT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>ZT(e,typeof t!="symbol"?t+"":t,n);import{u as Dt,i as Ms,c as YT,a as Bn,b as Dn,r as $n,l as Xu,_ as ls,t as $e,d as Mh,e as $p,f as ia,g as Cp,h as JT,j as QT,p as Aw,I as XT}from"./index-Dp_g4ObO.js";import{c as Ep,p as pt,t as O,i as p,s as kr,a as ws,b as lr,u as dr,m as Ee,d as me,D as Tp,P as Mp,e as Xt,f as $g,g as Cg,h as Ut,j as xs,k as kt,l as lk,n as Un,o as eM,q as tM,r as Dw,B as nM,v as sM,L as rM,w as oM,x as Ui,y as Pw,z as Bc,A as ao,C as Eg,E as iM,F as aM,G as cM,H as lM,I as dM,J as uM,K as Sr,M as Ap,N as dk,O as ef,Q as fM,R as gM,S as Dp,T as hM,U as mM,V as Iw,W as Rw,X as pM,Y as yM,Z as vM,_ as wM}from"./monaco-viewer-BQXd7g3w.js";import{b as Uc,e as R,u as aa,d as Ze,o as dt,k as y,F as zt,a as de,M as Ki,p as _e,w as uk,c as Te,n as Ys,i as bM,s as Nt,x as yi,l as qr,m as zr,t as Do,S as ee,v as fk,y as gk,z as hk,A as mk,h as gn,B as SM}from"./git-diff-vendor-CT8HfOQw.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";const kM=e=>typeof e=="function",jd=(e,t)=>kM(e)?e(t):e;var dn;(function(e){e[e.ADD_TOAST=0]="ADD_TOAST",e[e.UPDATE_TOAST=1]="UPDATE_TOAST",e[e.UPSERT_TOAST=2]="UPSERT_TOAST",e[e.DISMISS_TOAST=3]="DISMISS_TOAST",e[e.REMOVE_TOAST=4]="REMOVE_TOAST",e[e.START_PAUSE=5]="START_PAUSE",e[e.END_PAUSE=6]="END_PAUSE"})(dn||(dn={}));const[Go,Yr]=Ep({toasts:[],pausedAt:void 0}),xM=()=>{const{pausedAt:e,toasts:t}=Go;if(e)return;const n=Date.now();return t.map(r=>{if(r.duration===1/0)return;const o=(r.duration||0)+r.pauseDuration-(n-r.createdAt);if(o<=0){r.visible&&Ks({type:dn.DISMISS_TOAST,toastId:r.id});return}return setTimeout(()=>{Ks({type:dn.DISMISS_TOAST,toastId:r.id})},o)})},Tc=new Map,Ow=(e,t)=>{if(Tc.has(e))return;const n=setTimeout(()=>{Tc.delete(e),Ks({type:dn.REMOVE_TOAST,toastId:e})},t);Tc.set(e,n)},_M=e=>{const t=Tc.get(e);Tc.delete(e),t&&clearTimeout(t)},Ks=e=>{switch(e.type){case dn.ADD_TOAST:Yr("toasts",r=>{const o=r;return[e.toast,...o]});break;case dn.DISMISS_TOAST:const{toastId:t}=e,n=Go.toasts;if(t){const r=n.find(o=>o.id===t);r&&Ow(t,r.unmountDelay),Yr("toasts",o=>o.id===t,pt(o=>o.visible=!1))}else n.forEach(r=>{Ow(r.id,r.unmountDelay)}),Yr("toasts",r=>r.id!==void 0,pt(r=>r.visible=!1));break;case dn.REMOVE_TOAST:if(!e.toastId){Yr("toasts",[]);break}Yr("toasts",r=>r.filter(a=>a.id!==e.toastId));break;case dn.UPDATE_TOAST:e.toast.id&&_M(e.toast.id),Yr("toasts",r=>r.id===e.toast.id,r=>({...r,...e.toast}));break;case dn.UPSERT_TOAST:Go.toasts.find(r=>r.id===e.toast.id)?Ks({type:dn.UPDATE_TOAST,toast:e.toast}):Ks({type:dn.ADD_TOAST,toast:e.toast});break;case dn.START_PAUSE:Yr(pt(r=>{r.pausedAt=Date.now(),r.toasts.forEach(o=>{o.paused=!0})}));break;case dn.END_PAUSE:const s=e.time-(Go.pausedAt||0);Yr(pt(r=>{r.pausedAt=void 0,r.toasts.forEach(o=>{o.pauseDuration+=s,o.paused=!1})}));break}},$M={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Gi={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},pk={position:"top-right",toastOptions:Gi,gutter:8,containerStyle:{},containerClassName:""},Gl="16px",CM={position:"fixed","z-index":9999,top:Gl,bottom:Gl,left:Gl,right:Gl,"pointer-events":"none"},EM=(()=>{let e=0;return()=>String(++e)})(),TM=e=>{OM(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},MM=(e,t)=>{const s=e.includes("top")?{top:0,"margin-top":`${t}px`}:{bottom:0,"margin-bottom":`${t}px`},r=e.includes("center")?{"justify-content":"center"}:e.includes("right")?{"justify-content":"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:"all 230ms cubic-bezier(.21,1.02,.73,1)",...s,...r}},AM=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Ks({type:dn.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},DM=(e,t)=>{const{toasts:n}=Go,s=Oi().gutter||pk.gutter||8,r=n.filter(c=>(c.position||t)===t&&c.height),o=r.findIndex(c=>c.id===e.id),a=r.filter((c,l)=>l<o&&c.visible).length;return r.slice(0,a).reduce((c,l)=>c+s+(l.height||0),0)},PM=(e,t)=>(e.position||t).includes("top")?1:-1,IM={display:"flex","align-items":"center",color:"#363636",background:"white","box-shadow":"0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)","max-width":"350px","pointer-events":"auto",padding:"8px 10px","border-radius":"4px","line-height":"1.3","will-change":"transform"},RM={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},Zl={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},qd=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[Oi,OM]=R(pk),LM=(e,t="blank",n)=>{var s,r,o;return{...Gi,...Oi().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||EM(),paused:!1,style:{...Gi.style,...(s=Oi().toastOptions)==null?void 0:s.style,...n.style},duration:n.duration||((r=Oi().toastOptions)==null?void 0:r.duration)||$M[t],position:n.position||((o=Oi().toastOptions)==null?void 0:o.position)||Oi().position||Gi.position}},hl=e=>(t,n={})=>Uc(()=>{const s=Go.toasts.find(o=>o.id===n.id),r=LM(t,e,{...s,duration:void 0,...n});return Ks({type:dn.UPSERT_TOAST,toast:r}),r.id}),jn=(e,t)=>hl("blank")(e,t);aa(()=>jn);jn.error=hl("error");jn.success=hl("success");jn.loading=hl("loading");jn.custom=hl("custom");jn.dismiss=e=>{Ks({type:dn.DISMISS_TOAST,toastId:e})};jn.promise=(e,t,n)=>{const s=jn.loading(t.loading,{...n});return e.then(r=>(jn.success(jd(t.success,r),{id:s,...n}),r)).catch(r=>{jn.error(jd(t.error,r),{id:s,...n})}),e};jn.remove=e=>{Ks({type:dn.REMOVE_TOAST,toastId:e})};var NM=O("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const FM=e=>(Ze(()=>{TM(e)}),Ze(()=>{const t=xM();dt(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=NM();return t.firstChild,p(t,y(zt,{get each(){return Go.toasts},children:n=>y(VM,{toast:n})}),null),de(n=>{var s={...CM,...e.containerStyle},r=e.containerClassName;return n.e=kr(t,s,n.e),r!==n.t&&ws(t,n.t=r),n},{e:void 0,t:void 0}),t})());var Yl=O("<div>"),BM=O("<div><div>");const UM=e=>{let t;return Ze(()=>{if(!t)return;const n=PM(e.toast,e.position);e.toast.visible?t.animate([{transform:`translate3d(0,${n*-200}%,0) scale(.6)`,opacity:.5},{transform:"translate3d(0,0,0) scale(1)",opacity:1}],{duration:350,fill:"forwards",easing:"cubic-bezier(.21,1.02,.73,1)"}):t.animate([{transform:"translate3d(0,0,-1px) scale(1)",opacity:1},{transform:`translate3d(0,${n*-150}%,-1px) scale(.4)`,opacity:0}],{duration:400,fill:"forwards",easing:"cubic-bezier(.06,.71,.55,1)"})}),(()=>{var n=BM(),s=n.firstChild,r=t;return typeof r=="function"?dr(r,n):t=n,p(n,y(uk,{get children(){return[y(Ki,{get when(){return e.toast.icon},get children(){var o=Yl();return p(o,()=>e.toast.icon),de(a=>kr(o,Zl,a)),o}}),y(Ki,{get when(){return e.toast.type==="loading"},get children(){var o=Yl();return p(o,y(YM,_e(()=>e.toast.iconTheme))),de(a=>kr(o,Zl,a)),o}}),y(Ki,{get when(){return e.toast.type==="success"},get children(){var o=Yl();return p(o,y(WM,_e(()=>e.toast.iconTheme))),de(a=>kr(o,Zl,a)),o}}),y(Ki,{get when(){return e.toast.type==="error"},get children(){var o=Yl();return p(o,y(GM,_e(()=>e.toast.iconTheme))),de(a=>kr(o,Zl,a)),o}})]}}),s),lr(s,_e(()=>e.toast.ariaProps),!1,!0),p(s,()=>jd(e.toast.message,e.toast)),de(o=>{var a=e.toast.className,i={...IM,...e.toast.style},c=RM;return a!==o.e&&ws(n,o.e=a),o.t=kr(n,i,o.t),o.a=kr(s,c,o.a),o},{e:void 0,t:void 0,a:void 0}),n})()};var KM=O("<div>");const VM=e=>{const t=()=>{const r=e.toast.position||Gi.position,o=DM(e.toast,r);return MM(r,o)},n=Te(()=>t());let s;return Ys(()=>{s&&AM(s,e.toast)}),(()=>{var r=KM();r.addEventListener("mouseleave",()=>Ks({type:dn.END_PAUSE,time:Date.now()})),r.addEventListener("mouseenter",()=>Ks({type:dn.START_PAUSE,time:Date.now()}));var o=s;return typeof o=="function"?dr(o,r):s=r,p(r,(()=>{var a=Ee(()=>e.toast.type==="custom");return()=>a()?jd(e.toast.message,e.toast):y(UM,{get toast(){return e.toast},get position(){return e.toast.position||Gi.position}})})()),de(a=>{var i=n(),c=e.toast.visible?"sldt-active":"";return a.e=kr(r,i,a.e),c!==a.t&&ws(r,a.t=c),a},{e:void 0,t:void 0}),r})()};var jM=O('<svg><circle cx=16 cy=16 r=0><animate attributeName=opacity values="0; 1; 1"></animate><animate attributeName=r values="0; 17.5; 16"></svg>',!1,!0,!1),qM=O('<svg><circle cx=16 cy=16 r=12 opacity=0><animate attributeName=opacity values="1; 0"></animate><animate attributeName=r values="12; 26"></svg>',!1,!0,!1);const yk=e=>{const t={dur:"0.35s",begin:"100ms",fill:"freeze",calcMode:"spline",keyTimes:"0; 0.6; 1",keySplines:"0.25 0.71 0.4 0.88; .59 .22 .87 .63"};return(()=>{var n=jM(),s=n.firstChild,r=s.nextSibling;return lr(s,t,!0,!1),lr(r,t,!0,!1),de(()=>me(n,"fill",e.fill)),n})()},vk=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...qd("0.0 0.0 0.2 1")};return(()=>{var n=qM(),s=n.firstChild,r=s.nextSibling;return lr(s,t,!0,!1),lr(r,t,!0,!1),de(()=>me(n,"fill",e.fill)),n})()};var zM=O('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-dasharray=22 stroke-dashoffset=22 stroke-linecap=round stroke-miterlimit=10 d=M9.8,17.2l3.8,3.6c0.1,0.1,0.3,0.1,0.4,0l9.6-9.7><animate attributeName=stroke-dashoffset values=22;0 dur=0.25s begin=250ms fill=freeze>');const WM=e=>{const t=e.primary||"#34C759";return(()=>{var n=zM(),s=n.firstChild,r=s.firstChild;return p(n,y(yk,{fill:t}),s),p(n,y(vk,{fill:t,begin:"350ms"}),s),lr(r,_e(()=>qd("0.0, 0.0, 0.58, 1.0")),!0,!1),de(()=>me(s,"stroke",e.secondary||"#FCFCFC")),n})()};var HM=O('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-dasharray=9 stroke-dashoffset=9 stroke-linecap=round d=M16,7l0,9><animate attributeName=stroke-dashoffset values=9;0 dur=0.2s begin=250ms fill=freeze></animate></path><circle cx=16 cy=23 r=2.5 opacity=0><animate attributeName=opacity values=0;1 dur=0.25s begin=350ms fill=freeze>');const GM=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=HM(),s=n.firstChild,r=s.firstChild,o=s.nextSibling,a=o.firstChild;return p(n,y(yk,{fill:t}),s),p(n,y(vk,{fill:t}),s),lr(r,_e(()=>qd("0.0, 0.0, 0.58, 1.0")),!0,!1),lr(a,_e(()=>qd("0.0, 0.0, 0.58, 1.0")),!0,!1),de(i=>{var c=e.secondary||"#FFFFFF",l=e.secondary||"#FFFFFF";return c!==i.e&&me(s,"stroke",i.e=c),l!==i.t&&me(o,"fill",i.t=l),i},{e:void 0,t:void 0}),n})()};var ZM=O('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-miterlimit=10 d=M16,6c3,0,5.7,1.3,7.5,3.4c1.5,1.8,2.5,4,2.5,6.6c0,5.5-4.5,10-10,10S6,21.6,6,16S10.5,6,16,6z></path><path fill=none stroke-width=4 stroke-linecap=round stroke-miterlimit=10 d=M16,6c3,0,5.7,1.3,7.5,3.4c0.6,0.7,1.1,1.4,1.5,2.2><animateTransform attributeName=transform type=rotate from="0 16 16"to="360 16 16"dur=0.75s repeatCount=indefinite>');const YM=e=>(()=>{var t=ZM(),n=t.firstChild,s=n.nextSibling;return de(r=>{var o=e.primary||"#E5E7EB",a=e.secondary||"#4b5563";return o!==r.e&&me(n,"stroke",r.e=o),a!==r.t&&me(s,"stroke",r.t=a),r},{e:void 0,t:void 0}),t})();function JM(e){return(...t)=>{for(const n of e)n&&n(...t)}}const he=e=>typeof e=="function"&&!e.length?e():e,Lw=e=>Array.isArray(e)?e:e?[e]:[];function QM(e,...t){return typeof e=="function"?e(...t):e}const XM=dt;function e2(e,t,n,s){return e.addEventListener(t,n,s),XM(e.removeEventListener.bind(e,t,n,s))}function t2(e,t,n,s){const r=()=>{Lw(he(e)).forEach(o=>{o&&Lw(he(t)).forEach(a=>e2(o,a,n,s))})};typeof e=="function"?Ze(r):de(r)}const Tg=Symbol("fallback");function Nw(e){for(const t of e)t.dispose()}function n2(e,t,n,s={}){const r=new Map;return dt(()=>Nw(r.values())),()=>{const a=e()||[];return a[bM],aa(()=>{var d,u;if(!a.length)return Nw(r.values()),r.clear(),s.fallback?[Uc(g=>(r.set(Tg,{dispose:g}),s.fallback()))]:[];const i=new Array(a.length),c=r.get(Tg);if(!r.size||c){c==null||c.dispose(),r.delete(Tg);for(let f=0;f<a.length;f++){const g=a[f],m=t(g,f);o(i,g,f,m)}return i}const l=new Set(r.keys());for(let f=0;f<a.length;f++){const g=a[f],m=t(g,f);l.delete(m);const w=r.get(m);w?(i[f]=w.mapped,(d=w.setIndex)==null||d.call(w,f),w.setItem(()=>g)):o(i,g,f,m)}for(const f of l)(u=r.get(f))==null||u.dispose(),r.delete(f);return i})};function o(a,i,c,l){Uc(d=>{const[u,f]=R(i),g={setItem:f,dispose:d};if(n.length>1){const[m,w]=R(c);g.setIndex=w,g.mapped=n(u,m)}else g.mapped=n(u);r.set(l,g),a[c]=g.mapped})}}function s2(e){const{by:t}=e;return Te(n2(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const r2=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Fw(e){const t={};let n;for(;n=r2.exec(e);)t[n[1]]=n[2];return t}function ml(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Fw(e)}else typeof t=="string"&&(t=Fw(t));return{...e,...t}}function Kn(...e){return JM(e)}function oH(e,t,n=-1){return n in e?[...e.slice(0,n),t,...e.slice(n)]:[...e,t]}function Bw(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function o2(e){return typeof e=="number"}function Li(e){return Object.prototype.toString.call(e)==="[object String]"}function tf(e){return typeof e=="function"}function ja(e){return t=>`${e()}-${t}`}function Tr(e,t){return e?e===t||e.contains(t):!1}function hc(e,t=!1){const{activeElement:n}=Or(e);if(!(n!=null&&n.nodeName))return null;if(wk(n)&&n.contentDocument)return hc(n.contentDocument.body,t);if(t){const s=n.getAttribute("aria-activedescendant");if(s){const r=Or(n).getElementById(s);if(r)return r}}return n}function i2(e){return Or(e).defaultView||window}function Or(e){return e?e.ownerDocument||e:document}function wk(e){return e.tagName==="IFRAME"}var Pp=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(Pp||{});function bk(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)==null?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function Ip(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function pl(){return Ip(/^Mac/i)}function a2(){return Ip(/^iPhone/i)}function c2(){return Ip(/^iPad/i)||pl()&&navigator.maxTouchPoints>1}function l2(){return a2()||c2()}function d2(){return pl()||l2()}function u2(){return bk(/AppleWebKit/i)&&!f2()}function f2(){return bk(/Chrome/i)}function on(e,t){return t&&(tf(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function vs(e){return t=>{for(const n of e)on(t,n)}}function g2(e){return pl()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function On(e){if(e)if(h2())e.focus({preventScroll:!0});else{const t=m2(e);e.focus(),p2(t)}}var Jl=null;function h2(){if(Jl==null){Jl=!1;try{document.createElement("div").focus({get preventScroll(){return Jl=!0,!0}})}catch{}}return Jl}function m2(e){let t=e.parentNode;const n=[],s=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==s;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return s instanceof HTMLElement&&n.push({element:s,scrollTop:s.scrollTop,scrollLeft:s.scrollLeft}),n}function p2(e){for(const{element:t,scrollTop:n,scrollLeft:s}of e)t.scrollTop=n,t.scrollLeft=s}var Sk=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],y2=[...Sk,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Rp=`${Sk.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,v2=y2.join(':not([hidden]):not([tabindex="-1"]),');function kk(e,t){const s=Array.from(e.querySelectorAll(Rp)).filter(Uw);return t&&Uw(e)&&s.unshift(e),s.forEach((r,o)=>{if(wk(r)&&r.contentDocument){const a=r.contentDocument.body,i=kk(a,!1);s.splice(o,1,...i)}}),s}function Uw(e){return xk(e)&&!w2(e)}function xk(e){return e.matches(Rp)&&Op(e)}function w2(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function Op(e,t){return e.nodeName!=="#comment"&&b2(e)&&S2(e,t)&&(!e.parentElement||Op(e.parentElement,e))}function b2(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;const{display:t,visibility:n}=e.style;let s=t!=="none"&&n!=="hidden"&&n!=="collapse";if(s){if(!e.ownerDocument.defaultView)return s;const{getComputedStyle:r}=e.ownerDocument.defaultView,{display:o,visibility:a}=r(e);s=o!=="none"&&a!=="hidden"&&a!=="collapse"}return s}function S2(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function k2(e,t,n){const s=t!=null&&t.tabbable?v2:Rp,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(o){var a;return(a=t==null?void 0:t.from)!=null&&a.contains(o)?NodeFilter.FILTER_REJECT:o.matches(s)&&Op(o)&&(!(t!=null&&t.accept)||t.accept(o))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(r.currentNode=t.from),r}function Kw(e){let t=e;for(;t&&!x2(t);)t=t.parentElement;return t||document.scrollingElement||document.documentElement}function x2(e){const t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function _2(){}function iH(e){return[e.clientX,e.clientY]}function aH(e,t){const[n,s]=e;let r=!1;const o=t.length;for(let a=o,i=0,c=a-1;i<a;c=i++){const[l,d]=t[i],[u,f]=t[c],[,g]=t[c===0?a-1:c-1]||[0,0],m=(d-f)*(n-l)-(l-u)*(s-d);if(f<d){if(s>=f&&s<d){if(m===0)return!0;m>0&&(s===f?s>g&&(r=!r):r=!r)}}else if(d<f){if(s>d&&s<=f){if(m===0)return!0;m<0&&(s===f?s<g&&(r=!r):r=!r)}}else if(s===d&&(n>=u&&n<=l||n>=l&&n<=u))return!0}return r}function Kt(e,t){return _e(e,t)}var sc=new Map,Vw=new Set;function jw(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let s=sc.get(n.target);s||(s=new Set,sc.set(n.target,s),n.target.addEventListener("transitioncancel",t)),s.add(n.propertyName)},t=n=>{if(!n.target)return;const s=sc.get(n.target);if(s&&(s.delete(n.propertyName),s.size===0&&(n.target.removeEventListener("transitioncancel",t),sc.delete(n.target)),sc.size===0)){for(const r of Vw)r();Vw.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?jw():document.addEventListener("DOMContentLoaded",jw));function Ah(e,t){const n=qw(e,t,"left"),s=qw(e,t,"top"),r=t.offsetWidth,o=t.offsetHeight;let a=e.scrollLeft,i=e.scrollTop;const c=a+e.offsetWidth,l=i+e.offsetHeight;n<=a?a=n:n+r>c&&(a+=n+r-c),s<=i?i=s:s+o>l&&(i+=s+o-l),e.scrollLeft=a,e.scrollTop=i}function qw(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let r=0;for(;t.offsetParent&&(r+=t[s],t.offsetParent!==e);){if(t.offsetParent.contains(e)){r-=e[s];break}t=t.offsetParent}return r}function cH(e,t){var n,s;if(document.contains(e)){const r=document.scrollingElement||document.documentElement;if(window.getComputedStyle(r).overflow==="hidden"){let a=Kw(e);for(;e&&a&&e!==r&&a!==r;)Ah(a,e),e=a,a=Kw(e)}else{const{left:a,top:i}=e.getBoundingClientRect();(n=e==null?void 0:e.scrollIntoView)==null||n.call(e,{block:"nearest"});const{left:c,top:l}=e.getBoundingClientRect();(Math.abs(a-c)>1||Math.abs(i-l)>1)&&((s=e.scrollIntoView)==null||s.call(e,{block:"nearest"}))}}}var nf={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"},zd="data-kb-top-layer",_k,Dh=!1,Lr=[];function Kc(e){return Lr.findIndex(t=>t.node===e)}function $2(e){return Lr[Kc(e)]}function C2(e){return Lr[Lr.length-1].node===e}function $k(){return Lr.filter(e=>e.isPointerBlocking)}function E2(){return[...$k()].slice(-1)[0]}function Lp(){return $k().length>0}function Ck(e){var n;const t=Kc((n=E2())==null?void 0:n.node);return Kc(e)<t}function T2(e){Lr.push(e)}function M2(e){const t=Kc(e);t<0||Lr.splice(t,1)}function A2(){for(const{node:e}of Lr)e.style.pointerEvents=Ck(e)?"none":"auto"}function D2(e){if(Lp()&&!Dh){const t=Or(e);_k=document.body.style.pointerEvents,t.body.style.pointerEvents="none",Dh=!0}}function P2(e){if(Lp())return;const t=Or(e);t.body.style.pointerEvents=_k,t.body.style.length===0&&t.body.removeAttribute("style"),Dh=!1}var ss={layers:Lr,isTopMostLayer:C2,hasPointerBlockingLayer:Lp,isBelowPointerBlockingLayer:Ck,addLayer:T2,removeLayer:M2,indexOf:Kc,find:$2,assignPointerEventToLayers:A2,disableBodyPointerEvents:D2,restoreBodyPointerEvents:P2},Mg="focusScope.autoFocusOnMount",Ag="focusScope.autoFocusOnUnmount",zw={bubbles:!1,cancelable:!0},Ww={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=Bw(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=Bw(this.stack,e),(t=this.active())==null||t.resume()}};function Ek(e,t){const[n,s]=R(!1),r={pause(){s(!0)},resume(){s(!1)}};let o=null;const a=m=>{var w;return(w=e.onMountAutoFocus)==null?void 0:w.call(e,m)},i=m=>{var w;return(w=e.onUnmountAutoFocus)==null?void 0:w.call(e,m)},c=()=>Or(t()),l=()=>{const m=c().createElement("span");return m.setAttribute("data-focus-trap",""),m.tabIndex=0,Object.assign(m.style,nf),m},d=()=>{const m=t();return m?kk(m,!0).filter(w=>!w.hasAttribute("data-focus-trap")):[]},u=()=>{const m=d();return m.length>0?m[0]:null},f=()=>{const m=d();return m.length>0?m[m.length-1]:null},g=()=>{const m=t();if(!m)return!1;const w=hc(m);return!w||Tr(m,w)?!1:xk(w)};Ze(()=>{const m=t();if(!m)return;Ww.add(r);const w=hc(m);if(!Tr(m,w)){const b=new CustomEvent(Mg,zw);m.addEventListener(Mg,a),m.dispatchEvent(b),b.defaultPrevented||setTimeout(()=>{On(u()),hc(m)===w&&On(m)},0)}dt(()=>{m.removeEventListener(Mg,a),setTimeout(()=>{const b=new CustomEvent(Ag,zw);g()&&b.preventDefault(),m.addEventListener(Ag,i),m.dispatchEvent(b),b.defaultPrevented||On(w??c().body),m.removeEventListener(Ag,i),Ww.remove(r)},0)})}),Ze(()=>{const m=t();if(!m||!he(e.trapFocus)||n())return;const w=b=>{const v=b.target;v!=null&&v.closest(`[${zd}]`)||(Tr(m,v)?o=v:On(o))},S=b=>{const k=b.relatedTarget??hc(m);k!=null&&k.closest(`[${zd}]`)||Tr(m,k)||On(o)};c().addEventListener("focusin",w),c().addEventListener("focusout",S),dt(()=>{c().removeEventListener("focusin",w),c().removeEventListener("focusout",S)})}),Ze(()=>{const m=t();if(!m||!he(e.trapFocus)||n())return;const w=l();m.insertAdjacentElement("afterbegin",w);const S=l();m.insertAdjacentElement("beforeend",S);function b(k){const C=u(),_=f();k.relatedTarget===C?On(_):On(C)}w.addEventListener("focusin",b),S.addEventListener("focusin",b);const v=new MutationObserver(k=>{for(const C of k)C.previousSibling===S&&(S.remove(),m.insertAdjacentElement("beforeend",S)),C.nextSibling===w&&(w.remove(),m.insertAdjacentElement("afterbegin",w))});v.observe(m,{childList:!0,subtree:!1}),dt(()=>{w.removeEventListener("focusin",b),S.removeEventListener("focusin",b),w.remove(),S.remove(),v.disconnect()})})}var Tk=7e3,Dg=null,I2="data-live-announcer";function lH(e,t="assertive",n=Tk){Dg||(Dg=new R2),Dg.announce(e,t,n)}var R2=class{constructor(){ae(this,"node");ae(this,"assertiveLog");ae(this,"politeLog");this.node=document.createElement("div"),this.node.dataset.liveAnnouncer="true",Object.assign(this.node.style,nf),this.assertiveLog=this.createLog("assertive"),this.node.appendChild(this.assertiveLog),this.politeLog=this.createLog("polite"),this.node.appendChild(this.politeLog),document.body.prepend(this.node)}createLog(e){const t=document.createElement("div");return t.setAttribute("role","log"),t.setAttribute("aria-live",e),t.setAttribute("aria-relevant","additions"),t}destroy(){this.node&&(document.body.removeChild(this.node),this.node=null)}announce(e,t="assertive",n=Tk){if(!this.node)return;const s=document.createElement("div");s.textContent=e,t==="assertive"?this.assertiveLog.appendChild(s):this.politeLog.appendChild(s),e!==""&&setTimeout(()=>{s.remove()},n)}clear(e){this.node&&((!e||e==="assertive")&&(this.assertiveLog.innerHTML=""),(!e||e==="polite")&&(this.politeLog.innerHTML=""))}};function Mk(e){Ze(()=>{he(e.isDisabled)||dt(O2(he(e.targets),he(e.root)))})}var rc=new WeakMap,ms=[];function O2(e,t=document.body){const n=new Set(e),s=new Set,r=c=>{for(const f of c.querySelectorAll(`[${I2}], [${zd}]`))n.add(f);const l=f=>{if(n.has(f)||f.parentElement&&s.has(f.parentElement)&&f.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(const g of n)if(f.contains(g))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},d=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,{acceptNode:l}),u=l(c);if(u===NodeFilter.FILTER_ACCEPT&&o(c),u!==NodeFilter.FILTER_REJECT){let f=d.nextNode();for(;f!=null;)o(f),f=d.nextNode()}},o=c=>{const l=rc.get(c)??0;c.getAttribute("aria-hidden")==="true"&&l===0||(l===0&&c.setAttribute("aria-hidden","true"),s.add(c),rc.set(c,l+1))};ms.length&&ms[ms.length-1].disconnect(),r(t);const a=new MutationObserver(c=>{for(const l of c)if(!(l.type!=="childList"||l.addedNodes.length===0)&&![...n,...s].some(d=>d.contains(l.target))){for(const d of l.removedNodes)d instanceof Element&&(n.delete(d),s.delete(d));for(const d of l.addedNodes)(d instanceof HTMLElement||d instanceof SVGElement)&&(d.dataset.liveAnnouncer==="true"||d.dataset.reactAriaTopLayer==="true")?n.add(d):d instanceof Element&&r(d)}});a.observe(t,{childList:!0,subtree:!0});const i={observe(){a.observe(t,{childList:!0,subtree:!0})},disconnect(){a.disconnect()}};return ms.push(i),()=>{a.disconnect();for(const c of s){const l=rc.get(c);if(l==null)return;l===1?(c.removeAttribute("aria-hidden"),rc.delete(c)):rc.set(c,l-1)}i===ms[ms.length-1]?(ms.pop(),ms.length&&ms[ms.length-1].observe()):ms.splice(ms.indexOf(i),1)}}var Hw="interactOutside.pointerDownOutside",Gw="interactOutside.focusOutside";function L2(e,t){let n,s=_2;const r=()=>Or(t()),o=u=>{var f;return(f=e.onPointerDownOutside)==null?void 0:f.call(e,u)},a=u=>{var f;return(f=e.onFocusOutside)==null?void 0:f.call(e,u)},i=u=>{var f;return(f=e.onInteractOutside)==null?void 0:f.call(e,u)},c=u=>{var g;const f=u.target;return!(f instanceof Element)||f.closest(`[${zd}]`)||!Tr(r(),f)||Tr(t(),f)?!1:!((g=e.shouldExcludeElement)!=null&&g.call(e,f))},l=u=>{function f(){const g=t(),m=u.target;if(!g||!m||!c(u))return;const w=vs([o,i]);m.addEventListener(Hw,w,{once:!0});const S=new CustomEvent(Hw,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||g2(u)&&u.button===0}});m.dispatchEvent(S)}u.pointerType==="touch"?(r().removeEventListener("click",f),s=f,r().addEventListener("click",f,{once:!0})):f()},d=u=>{const f=t(),g=u.target;if(!f||!g||!c(u))return;const m=vs([a,i]);g.addEventListener(Gw,m,{once:!0});const w=new CustomEvent(Gw,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});g.dispatchEvent(w)};Ze(()=>{he(e.isDisabled)||(n=window.setTimeout(()=>{r().addEventListener("pointerdown",l,!0)},0),r().addEventListener("focusin",d,!0),dt(()=>{window.clearTimeout(n),r().removeEventListener("click",s),r().removeEventListener("pointerdown",l,!0),r().removeEventListener("focusin",d,!0)}))})}function N2(e){const t=n=>{var s;n.key===Pp.Escape&&((s=e.onEscapeKeyDown)==null||s.call(e,n))};Ze(()=>{var s;if(he(e.isDisabled))return;const n=((s=e.ownerDocument)==null?void 0:s.call(e))??Or();n.addEventListener("keydown",t),dt(()=>{n.removeEventListener("keydown",t)})})}function en(e){const[t,n]=Nt(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return y(Tp,_e(n,{get component(){return t.as}}))}var Ak=qr();function F2(){return zr(Ak)}function Dk(e){let t;const n=F2(),[s,r]=Nt(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),o=new Set([]),a=u=>{o.add(u);const f=n==null?void 0:n.registerNestedLayer(u);return()=>{o.delete(u),f==null||f()}};L2({shouldExcludeElement:u=>{var f;return t?((f=s.excludedElements)==null?void 0:f.some(g=>Tr(g(),u)))||[...o].some(g=>Tr(g,u)):!1},onPointerDownOutside:u=>{var f,g,m;!t||ss.isBelowPointerBlockingLayer(t)||!s.bypassTopMostLayerCheck&&!ss.isTopMostLayer(t)||((f=s.onPointerDownOutside)==null||f.call(s,u),(g=s.onInteractOutside)==null||g.call(s,u),u.defaultPrevented||(m=s.onDismiss)==null||m.call(s))},onFocusOutside:u=>{var f,g,m;(f=s.onFocusOutside)==null||f.call(s,u),(g=s.onInteractOutside)==null||g.call(s,u),u.defaultPrevented||(m=s.onDismiss)==null||m.call(s)}},()=>t),N2({ownerDocument:()=>Or(t),onEscapeKeyDown:u=>{var f;!t||!ss.isTopMostLayer(t)||((f=s.onEscapeKeyDown)==null||f.call(s,u),!u.defaultPrevented&&s.onDismiss&&(u.preventDefault(),s.onDismiss()))}}),Ys(()=>{if(!t)return;ss.addLayer({node:t,isPointerBlocking:s.disableOutsidePointerEvents,dismiss:s.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);ss.assignPointerEventToLayers(),ss.disableBodyPointerEvents(t),dt(()=>{t&&(ss.removeLayer(t),u==null||u(),ss.assignPointerEventToLayers(),ss.restoreBodyPointerEvents(t))})}),Ze(yi([()=>t,()=>s.disableOutsidePointerEvents],([u,f])=>{if(!u)return;const g=ss.find(u);g&&g.isPointerBlocking!==f&&(g.isPointerBlocking=f,ss.assignPointerEventToLayers()),f&&ss.disableBodyPointerEvents(u),dt(()=>{ss.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:a};return y(Ak.Provider,{value:d,get children(){return y(en,_e({as:"div",ref(u){var f=Kn(g=>t=g,s.ref);typeof f=="function"&&f(u)}},r))}})}function Np(e){var a;const[t,n]=R((a=e.defaultValue)==null?void 0:a.call(e)),s=Te(()=>{var i;return((i=e.value)==null?void 0:i.call(e))!==void 0}),r=Te(()=>{var i;return s()?(i=e.value)==null?void 0:i.call(e):t()});return[r,i=>{aa(()=>{var l;const c=QM(i,r());return Object.is(c,r())||(s()||n(c),(l=e.onChange)==null||l.call(e,c)),c})}]}function Pk(e){const[t,n]=Np(e);return[()=>t()??!1,n]}function dH(e){const[t,n]=Np(e);return[()=>t()??[],n]}function Ik(e={}){const[t,n]=Pk({value:()=>he(e.open),defaultValue:()=>!!he(e.defaultOpen),onChange:a=>{var i;return(i=e.onOpenChange)==null?void 0:i.call(e,a)}}),s=()=>{n(!0)},r=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:s,close:r,toggle:()=>{t()?r():s()}}}function Rk(e,t){const[n,s]=R(Zw(t==null?void 0:t()));return Ze(()=>{var r;s(((r=e())==null?void 0:r.tagName.toLowerCase())||Zw(t==null?void 0:t()))}),n}function Zw(e){return Li(e)?e:void 0}var B2=Object.defineProperty,yl=(e,t)=>{for(var n in t)B2(e,n,{get:t[n],enumerable:!0})},U2={};yl(U2,{Button:()=>j2,Root:()=>vl});var K2=["button","color","file","image","reset","submit"];function V2(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?K2.indexOf(e.type)!==-1:!1}function vl(e){let t;const n=Kt({type:"button"},e),[s,r]=Nt(n,["ref","type","disabled"]),o=Rk(()=>t,()=>"button"),a=Te(()=>{const l=o();return l==null?!1:V2({tagName:l,type:s.type})}),i=Te(()=>o()==="input"),c=Te(()=>o()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return y(en,_e({as:"button",ref(l){var d=Kn(u=>t=u,s.ref);typeof d=="function"&&d(l)},get type(){return Ee(()=>!!(a()||i()))()?s.type:void 0},get role(){return!a()&&!c()?"button":void 0},get tabIndex(){return!a()&&!c()&&!s.disabled?0:void 0},get disabled(){return Ee(()=>!!(a()||i()))()?s.disabled:void 0},get"aria-disabled"(){return!a()&&!i()&&s.disabled?!0:void 0},get"data-disabled"(){return s.disabled?"":void 0}},r))}var j2=vl;function bs(e){return t=>(e(t),()=>e(void 0))}var Rn=e=>typeof e=="function"?e():e,Ph=(e,t)=>{if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},Ql=new Map,q2=e=>{Ze(()=>{const t=Rn(e.style)??{},n=Rn(e.properties)??[],s={};for(const o in t)s[o]=e.element.style[o];const r=Ql.get(e.key);r?r.activeCount++:Ql.set(e.key,{activeCount:1,originalStyles:s,properties:n.map(o=>o.key)}),Object.assign(e.element.style,e.style);for(const o of n)e.element.style.setProperty(o.key,o.value);dt(()=>{var a;const o=Ql.get(e.key);if(o){if(o.activeCount!==1){o.activeCount--;return}Ql.delete(e.key);for(const[i,c]of Object.entries(o.originalStyles))e.element.style[i]=c;for(const i of o.properties)e.element.style.removeProperty(i);e.element.style.length===0&&e.element.removeAttribute("style"),(a=e.cleanup)==null||a.call(e)}})})},Yw=q2,z2=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},W2=(e,t)=>{const n=getComputedStyle(e),s=t==="x"?n.overflowX:n.overflowY;return s==="auto"||s==="scroll"||e.tagName==="HTML"&&s==="visible"},H2=(e,t,n)=>{const s=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let r=e,o=0,a=0,i=!1;do{const[c,l,d]=z2(r,t),u=d-c-s*l;(l!==0||u!==0)&&W2(r,t)&&(o+=u,a+=l),r===(n??document.documentElement)?i=!0:r=r._$host??r.parentElement}while(r&&!i);return[o,a]},[Jw,Qw]=R([]),G2=e=>Jw().indexOf(e)===Jw().length-1,Z2=e=>{const t=_e({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=Do();let s=[0,0],r=null,o=null;Ze(()=>{Rn(t.enabled)&&(Qw(l=>[...l,n]),dt(()=>{Qw(l=>l.filter(d=>d!==n))}))}),Ze(()=>{if(!Rn(t.enabled)||!Rn(t.hideScrollbar))return;const{body:l}=document,d=window.innerWidth-l.offsetWidth;if(Rn(t.preventScrollbarShift)){const u={overflow:"hidden"},f=[];d>0&&(Rn(t.preventScrollbarShiftMode)==="padding"?u.paddingRight=`calc(${window.getComputedStyle(l).paddingRight} + ${d}px)`:u.marginRight=`calc(${window.getComputedStyle(l).marginRight} + ${d}px)`,f.push({key:"--scrollbar-width",value:`${d}px`}));const g=window.scrollY,m=window.scrollX;Yw({key:"prevent-scroll",element:l,style:u,properties:f,cleanup:()=>{Rn(t.restoreScrollPosition)&&d>0&&window.scrollTo(m,g)}})}else Yw({key:"prevent-scroll",element:l,style:{overflow:"hidden"}})}),Ze(()=>{!G2(n)||!Rn(t.enabled)||(document.addEventListener("wheel",i,{passive:!1}),document.addEventListener("touchstart",a,{passive:!1}),document.addEventListener("touchmove",c,{passive:!1}),dt(()=>{document.removeEventListener("wheel",i),document.removeEventListener("touchstart",a),document.removeEventListener("touchmove",c)}))});const a=l=>{s=Xw(l),r=null,o=null},i=l=>{const d=l.target,u=Rn(t.element),f=Y2(l),g=Math.abs(f[0])>Math.abs(f[1])?"x":"y",m=g==="x"?f[0]:f[1],w=eb(d,g,m,u);let S;u&&Ph(u,d)?S=!w:S=!0,S&&l.cancelable&&l.preventDefault()},c=l=>{const d=Rn(t.element),u=l.target;let f;if(l.touches.length===2)f=!Rn(t.allowPinchZoom);else{if(r==null||o===null){const g=Xw(l).map((w,S)=>s[S]-w),m=Math.abs(g[0])>Math.abs(g[1])?"x":"y";r=m,o=m==="x"?g[0]:g[1]}if(u.type==="range")f=!1;else{const g=eb(u,r,o,d);d&&Ph(d,u)?f=!g:f=!0}}f&&l.cancelable&&l.preventDefault()}},Y2=e=>[e.deltaX,e.deltaY],Xw=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],eb=(e,t,n,s)=>{const r=s!==null&&Ph(s,e),[o,a]=H2(e,t,r?s:void 0);return!(n>0&&Math.abs(o)<=1||n<0&&Math.abs(a)<1)},J2=Z2,Ok=J2,Q2=e=>{const t=Te(()=>{const a=Rn(e.element);if(a)return getComputedStyle(a)}),n=()=>{var a;return((a=t())==null?void 0:a.animationName)??"none"},[s,r]=R(Rn(e.show)?"present":"hidden");let o="none";return Ze(a=>{const i=Rn(e.show);return aa(()=>{var d;if(a===i)return i;const c=o,l=n();i?r("present"):l==="none"||((d=t())==null?void 0:d.display)==="none"?r("hidden"):r(a===!0&&c!==l?"hiding":"hidden")}),i}),Ze(()=>{const a=Rn(e.element);if(!a)return;const i=l=>{l.target===a&&(o=n())},c=l=>{const u=n().includes(l.animationName);l.target===a&&u&&s()==="hiding"&&r("hidden")};a.addEventListener("animationstart",i),a.addEventListener("animationcancel",c),a.addEventListener("animationend",c),dt(()=>{a.removeEventListener("animationstart",i),a.removeEventListener("animationcancel",c),a.removeEventListener("animationend",c)})}),{present:()=>s()==="present"||s()==="hiding",state:s,setState:r}},X2=Q2,Ih=X2,eA={};yl(eA,{CloseButton:()=>Nk,Content:()=>Fk,Description:()=>Bk,Dialog:()=>Ot,Overlay:()=>Uk,Portal:()=>Kk,Root:()=>Vk,Title:()=>jk,Trigger:()=>qk,useDialogContext:()=>Po});var Lk=qr();function Po(){const e=zr(Lk);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function Nk(e){const t=Po(),[n,s]=Nt(e,["aria-label","onClick"]);return y(vl,_e({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:o=>{on(o,n.onClick),t.close()}},s))}function Fk(e){let t;const n=Po(),s=Kt({id:n.generateId("content")},e),[r,o]=Nt(s,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let a=!1,i=!1;const c=f=>{var g;(g=r.onPointerDownOutside)==null||g.call(r,f),n.modal()&&f.detail.isContextMenu&&f.preventDefault()},l=f=>{var g;(g=r.onFocusOutside)==null||g.call(r,f),n.modal()&&f.preventDefault()},d=f=>{var g;(g=r.onInteractOutside)==null||g.call(r,f),!n.modal()&&(f.defaultPrevented||(a=!0,f.detail.originalEvent.type==="pointerdown"&&(i=!0)),Tr(n.triggerRef(),f.target)&&f.preventDefault(),f.detail.originalEvent.type==="focusin"&&i&&f.preventDefault())},u=f=>{var g;(g=r.onCloseAutoFocus)==null||g.call(r,f),n.modal()?(f.preventDefault(),On(n.triggerRef())):(f.defaultPrevented||(a||On(n.triggerRef()),f.preventDefault()),a=!1,i=!1)};return Mk({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),Ok({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),Ek({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:r.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),Ze(()=>dt(n.registerContentId(o.id))),y(ee,{get when(){return n.contentPresent()},get children(){return y(Dk,_e({ref(f){var g=Kn(m=>{n.setContentRef(m),t=m},r.ref);typeof g=="function"&&g(f)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return Ee(()=>!!n.modal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get"aria-labelledby"(){return n.titleId()},get"aria-describedby"(){return n.descriptionId()},get"data-expanded"(){return n.isOpen()?"":void 0},get"data-closed"(){return n.isOpen()?void 0:""},onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:d,get onDismiss(){return n.close}},o))}})}function Bk(e){const t=Po(),n=Kt({id:t.generateId("description")},e),[s,r]=Nt(n,["id"]);return Ze(()=>dt(t.registerDescriptionId(s.id))),y(en,_e({as:"p",get id(){return s.id}},r))}function Uk(e){const t=Po(),[n,s]=Nt(e,["ref","style","onPointerDown"]),r=o=>{on(o,n.onPointerDown),o.target===o.currentTarget&&o.preventDefault()};return y(ee,{get when(){return t.overlayPresent()},get children(){return y(en,_e({as:"div",ref(o){var a=Kn(t.setOverlayRef,n.ref);typeof a=="function"&&a(o)},get style(){return ml({"pointer-events":"auto"},n.style)},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onPointerDown:r},s))}})}function Kk(e){const t=Po();return y(ee,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return y(Mp,e)}})}var tb={dismiss:"Dismiss"};function Vk(e){const t=`dialog-${Do()}`,n=Kt({id:t,modal:!0,translations:tb},e),[s,r]=R(),[o,a]=R(),[i,c]=R(),[l,d]=R(),[u,f]=R(),[g,m]=R(),w=Ik({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:C=>{var _;return(_=n.onOpenChange)==null?void 0:_.call(n,C)}}),S=()=>n.forceMount||w.isOpen(),{present:b}=Ih({show:S,element:()=>l()??null}),{present:v}=Ih({show:S,element:()=>u()??null}),k={translations:()=>n.translations??tb,isOpen:w.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??k.modal(),contentId:s,titleId:o,descriptionId:i,triggerRef:g,overlayRef:l,setOverlayRef:d,contentRef:u,setContentRef:f,overlayPresent:b,contentPresent:v,close:w.close,toggle:w.toggle,setTriggerRef:m,generateId:ja(()=>n.id),registerContentId:bs(r),registerTitleId:bs(a),registerDescriptionId:bs(c)};return y(Lk.Provider,{value:k,get children(){return n.children}})}function jk(e){const t=Po(),n=Kt({id:t.generateId("title")},e),[s,r]=Nt(n,["id"]);return Ze(()=>dt(t.registerTitleId(s.id))),y(en,_e({as:"h2",get id(){return s.id}},r))}function qk(e){const t=Po(),[n,s]=Nt(e,["ref","onClick"]);return y(vl,_e({ref(o){var a=Kn(t.setTriggerRef,n.ref);typeof a=="function"&&a(o)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return Ee(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:o=>{on(o,n.onClick),t.toggle()}},s))}var Ot=Object.assign(Vk,{CloseButton:Nk,Content:Fk,Description:Bk,Overlay:Uk,Portal:Kk,Title:jk,Trigger:qk});const[Ed,sf]=R(null);function Ns(e,t){sf({type:"alert",message:e,...t})}function ca(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(s=>{sf({type:"confirm",message:e,...t,resolve:s})})}function tA(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(s=>{sf({type:"prompt",message:e,...t,resolvePrompt:s})})}function Pg(){sf(null)}var nA=O('<div class="flex items-start gap-3"><div class="flex h-12 w-12 shrink-0 items-center justify-center border text-base font-semibold"aria-hidden></div><div class="flex-1 min-w-0">'),sA=O('<div class=mt-4><label for=prompt-input class="text-sm font-medium text-secondary"></label><input id=prompt-input class="form-input mt-2"autocapitalize=off autocorrect=off>'),rA=O('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),oA=O('<p class="mt-2 text-secondary">'),iA=O("<button type=button class=button-secondary>");const aA={info:{badgeBg:"var(--badge-neutral-bg)",badgeBorder:"var(--border-base)",badgeText:"var(--accent-primary)",symbol:"i"},warning:{badgeBg:"rgba(255, 152, 0, 0.14)",badgeBorder:"var(--status-warning)",badgeText:"var(--status-warning)",symbol:"!"},error:{badgeBg:"var(--danger-soft-bg)",badgeBorder:"var(--status-error)",badgeText:"var(--status-error)",symbol:"!"}};function Xl(e,t,n){var r,o,a,i,c,l,d,u;const s=t??Ed();if((s==null?void 0:s.type)==="confirm"){e?(r=s.onConfirm)==null||r.call(s):(o=s.onCancel)==null||o.call(s),(a=s.resolve)==null||a.call(s,e),Pg();return}if((s==null?void 0:s.type)==="prompt"){e?((i=s.onConfirm)==null||i.call(s),(c=s.resolvePrompt)==null||c.call(s,n??"")):((l=s.onCancel)==null||l.call(s),(d=s.resolvePrompt)==null||d.call(s,null)),Pg();return}e&&((u=s==null?void 0:s.onConfirm)==null||u.call(s)),Pg()}const cA=()=>{const{t:e}=Dt();let t,n;return Ze(()=>{const s=Ed();!s||$g.required()||queueMicrotask(()=>{if(!($g.required()||Ed()!==s)){if(s.type==="prompt"){n==null||n.focus(),n==null||n.select();return}t==null||t.focus()}})}),y(ee,{get when(){return Ed()},keyed:!0,children:s=>{const r=s.variant??"info",o=aA[r],a=e(r==="warning"?"alertDialog.fallbackTitle.warning":r==="error"?"alertDialog.fallbackTitle.error":"alertDialog.fallbackTitle.info"),i=s.title||a,c=s.type==="confirm",l=s.type==="prompt",d=s.confirmLabel||e(c?"alertDialog.actions.confirm":l?"alertDialog.actions.run":"alertDialog.actions.ok"),u=s.cancelLabel||e("alertDialog.actions.cancel"),[f,g]=R(s.inputDefaultValue??"");return y(Ot,{get open(){return!$g.required()},modal:!0,onOpenChange:m=>{!m&&s.dismissible!==!1&&Xl(!1,s)},get children(){return y(Ot.Portal,{get children(){return[y(Ot.Overlay,{class:"modal-overlay z-[60]"}),y(Ot.Content,{class:"modal-surface fixed left-1/2 top-1/2 z-[1310] w-full max-w-sm -translate-x-1/2 -translate-y-1/2 p-6 border border-base shadow-2xl",tabIndex:-1,get children(){return[(()=>{var m=nA(),w=m.firstChild,S=w.nextSibling;return p(w,()=>o.symbol),p(S,y(Ot.Title,{class:"text-lg font-semibold text-primary",children:i}),null),p(S,y(Ot.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line break-words",get children(){return[Ee(()=>s.message),Ee(()=>Ee(()=>!!s.detail)()&&(()=>{var b=oA();return p(b,()=>s.detail),b})())]}}),null),de(b=>{var v=o.badgeBg,k=o.badgeBorder,C=o.badgeText;return v!==b.e&&Cg(w,"background-color",b.e=v),k!==b.t&&Cg(w,"border-color",b.t=k),C!==b.a&&Cg(w,"color",b.a=C),b},{e:void 0,t:void 0,a:void 0}),m})(),y(ee,{when:l,get children(){var m=sA(),w=m.firstChild,S=w.nextSibling;return p(w,()=>s.inputLabel||e("alertDialog.prompt.inputLabel")),S.$$keydown=b=>{b.key==="Enter"&&(b.preventDefault(),Xl(!0,s,f()))},S.$$input=b=>g(b.currentTarget.value),dr(b=>{n=b},S),me(S,"spellcheck",!1),de(()=>me(S,"placeholder",s.inputPlaceholder||"")),de(()=>S.value=f()),m}}),(()=>{var m=rA(),w=m.firstChild;return p(m,(c||l)&&(()=>{var S=iA();return S.$$click=()=>Xl(!1,s),p(S,u),S})(),w),w.$$click=()=>Xl(!0,s,f()),dr(S=>{t=S},w),p(w,d),m})()]}})]}})}})}})};Xt(["input","keydown","click"]);function lA(e,t,n){if(e.has(t))return e;const s=new Map(e);return s.set(t,n),s}function dA(e,t){return e==="disconnected"||e==="error"?e:t!=="connected"?"connecting":e}const Uo=Ut("sse"),[nb,sb]=R(new Map),[uA,fA]=R("connecting");class gA{constructor(){Uo.info("sseManager initialized: listening for SSE disconnect and reconnect"),xs.on("instance.eventStatus",t=>{var s;const n=t;if(this.updateConnectionStatus(n.instanceId,n.status),n.status==="disconnected"){if(n.reason==="workspace stopped")return;const r=n.reason??"Instance disconnected";(s=this.onConnectionLost)==null||s.call(this,n.instanceId,r)}}),xs.on("instance.event",t=>{const n=t;this.updateConnectionStatus(n.instanceId,"connected"),this.handleEvent(n.instanceId,n.event)}),xs.onTransportStatus(t=>{Uo.info("SSE transport status changed",{status:t}),fA(t)})}seedStatus(t,n){this.updateConnectionStatus(t,n)}seedStatusIfMissing(t,n){sb(s=>lA(s,t,n))}handleEvent(t,n){var s,r,o,a,i,c,l,d,u,f,g,m,w,S,b,v;if(!n||typeof n!="object"||typeof n.type!="string"){Uo.warn("Dropping malformed event",n);return}switch(Uo.info("Received event",{type:n.type,event:n}),(s=this.onInvalidation)==null||s.call(this,t,n),n.type){case"session.created":(r=this.onSessionUpdate)==null||r.call(this,t,n);break;case"session.revert.staged":case"session.revert.cleared":case"session.revert.committed":(o=this.onSessionUpdate)==null||o.call(this,t,n);break;case"session.deleted":(a=this.onSessionDeleted)==null||a.call(this,t,n);break;case"session.compaction.ended":(i=this.onSessionCompacted)==null||i.call(this,t,n);break;case"session.execution.failed":(c=this.onSessionError)==null||c.call(this,t,n);break;case"tui.toast.show":(l=this.onTuiToast)==null||l.call(this,t,n);break;case"session.idle":(d=this.onSessionIdle)==null||d.call(this,t,n);break;case"session.status":(u=this.onSessionStatus)==null||u.call(this,t,n);break;case"permission.asked":(f=this.onPermissionUpdated)==null||f.call(this,t,n);break;case"permission.replied":(g=this.onPermissionReplied)==null||g.call(this,t,n);break;case"server.instance.disposed":(m=this.onInstanceDisposed)==null||m.call(this,t,n);break;case"worktree.ready":try{const k=(w=this.onWorktreeReady)==null?void 0:w.call(this,t,n);k==null||k.catch(C=>{Uo.warn("Failed to handle worktree ready event",{instanceId:t,error:C})})}catch(k){Uo.warn("Failed to handle worktree ready event",{instanceId:t,error:k})}break;case"worktree.updated":(b=(S=this.onWorktreeUpdated)==null?void 0:S.call(this,t))==null||b.catch(k=>Uo.warn("Failed to refresh native worktrees",k));break;default:(v=this.onNativeSessionEvent)==null||v.call(this,t,n)}}updateConnectionStatus(t,n){sb(s=>{if(s.get(t)===n)return s;const r=new Map(s);return r.set(t,n),r})}getStatus(t){return dA(nb().get(t)??null,uA())}getStatuses(){return nb()}}const vn=new gA,[ur,rf]=R(),[Rh,la]=R(!1),[mo,Oh]=R(!1),[zk,Vc]=R(!1),[xr,Wd]=R(!1),[Lh,jc]=R(),[mc,Nh]=R(),[Mc,Fh]=R(!1),[Bh,Xo]=R();let Ln=0,rb=-1,Os;const[Hd,Fp]=R(),Wk=()=>!!Hd();function Zi(e=ur()){return!xr()&&((e==null?void 0:e.serviceState)==="ready"||(e==null?void 0:e.serviceState)==="restart_available")}async function Hk(){if(!Zi()||mo()||Mc())return;const e=Ln,t=Hd();await Fs(),!(e!==Ln||mo()||!Zi()||Hd()!==t)&&(Fp(void 0),la(!1),await(t==null?void 0:t()))}function Uh(e=ur()){return(e==null?void 0:e.state)==="missing"||(e==null?void 0:e.state)==="update_required"||(e==null?void 0:e.serviceState)==="restart_required"||(e==null?void 0:e.serviceState)==="incompatible"}function Bp(e){e&&Fp(()=>e),Xo(void 0),la(!0),Fs()}function hA(){mo()||rb===Ln||(rb=Ln,Bp())}function Gk(){Ln++,Os=void 0,rf(void 0),Xo(void 0),Wd(!1),Vc(!1),jc(void 0),Fs()}function Fs(e=!1,t=!1){if(mo()&&!e)return Promise.resolve();if(Os)return Os.again=!0,Os.announce||(Os.announce=t),Os.promise;const n=Ln,s={promise:Promise.resolve(),again:!1,announce:t};return Os=s,Fh(!0),Xo(void 0),s.promise=(async()=>{do{s.again=!1;try{const r=await kt.fetchOpenCodeUpdateStatus();if(n!==Ln)return;rf(r),Wd(!1),Vc(!1),jc(void 0),!s.again&&s.announce&&!r.checkError&&!r.serviceError&&r.state!=="error"&&Xo("checked")}catch{if(n!==Ln)return;Wd(!0)}}while(s.again&&n===Ln)})().finally(()=>{Os===s&&(Os=void 0,Fh(!1))}),s.promise}async function pc(e,t={}){var s,r;if(mo())return;const n=++Ln;Os=void 0,Oh(!0),Nh(e),Xo(void 0),Vc(!1),jc(void 0);try{if(e==="install"&&await kt.updateOpenCode(),n!==Ln||(await Fs(!0),n!==Ln||xr())||e!=="restart"&&(((s=ur())==null?void 0:s.serviceState)==="restart_required"||((r=ur())==null?void 0:r.serviceState)==="incompatible"))return;const o=e==="reload"?await kt.reloadOpenCodeConfiguration():await kt.startOpenCode(e==="restart");if(n!==Ln)return;if(rf(o),o.state==="ready"&&(o.serviceState==="ready"||o.serviceState==="restart_available")){const a=t.resumeWorkspace===!1?void 0:Hd();return t.resumeWorkspace!==!1&&Fp(void 0),e==="reload"&&Xo("reloaded"),a&&o.serviceState==="ready"&&la(!1),await(a==null?void 0:a()),o}}catch(o){if(n===Ln){if(await Fs(!0),n!==Ln)return;Vc(!0),o instanceof Error&&(o.message==="installation_busy"||o.message==="installation_in_use")&&jc(o.message)}}finally{Oh(!1),Nh(void 0),n!==Ln&&Fs()}}const mA=Object.freeze(Object.defineProperty({__proto__:null,canContinueOpenCodeSetup:Wk,continueOpenCodeSetup:Hk,invalidateOpenCodeSetup:Gk,isOpenCodeConnected:Zi,needsOpenCodeSetup:Uh,openCodeInstallationError:Lh,openCodeSetupAction:mc,openCodeSetupBusy:mo,openCodeSetupCheckError:xr,openCodeSetupChecking:Mc,openCodeSetupError:zk,openCodeSetupFeedback:Bh,openCodeSetupOpen:Rh,openCodeSetupStatus:ur,openOpenCodeSetup:Bp,refreshOpenCodeSetup:Fs,reportOpenCodeSetupRequired:hA,runOpenCodeSetup:pc,setOpenCodeInstallationError:jc,setOpenCodeSetupAction:Nh,setOpenCodeSetupBusy:Oh,setOpenCodeSetupCheckError:Wd,setOpenCodeSetupChecking:Fh,setOpenCodeSetupError:Vc,setOpenCodeSetupFeedback:Xo,setOpenCodeSetupOpen:la,setOpenCodeSetupStatus:rf},Symbol.toStringTag,{value:"Module"}));var ob=O("<p class=settings-error-message role=alert>"),Di=O("<p role=status>"),pA=O("<div class=opencode-setup-panel><div class=settings-info-actions><button type=button class=settings-pill-button>"),yA=O("<p class=settings-toggle-title role=status>"),vA=O("<div class=settings-info-grid><div class=settings-info-row><span></span><span></span></div><div class=settings-info-row><span></span><span>"),wA=O('<p class="settings-toggle-caption break-all">'),ed=O("<p class=settings-toggle-caption>"),ib=O("<p role=alert>"),bA=O("<p>"),td=O("<button type=button class=settings-pill-button>"),SA=O("<div class=settings-info-actions>"),kA=O("<details class=opencode-setup-details><summary></summary><div class=settings-info-grid><div class=settings-info-row><span></span><span></span></div><div class=settings-info-row><span></span><span></span></div></div><p class=settings-toggle-caption>"),xA=O("<details class=opencode-setup-details><summary></summary><p class=settings-toggle-caption></p><div class=settings-info-actions><button type=button class=settings-pill-button>");function Zk(e={}){const{t}=Dt(),n=()=>mo()||Mc(),s=()=>Mc()?"settings.opencode.update.checking":mc()==="install"?"settings.opencode.update.updating":mc()?`settings.opencode.setup.progress.${mc()}`:void 0;return(()=>{var r=pA(),o=r.firstChild,a=o.firstChild;return p(r,y(ee,{get when(){return ur()},get fallback(){return(()=>{var i=Di();return p(i,()=>t(s()??(xr()?"settings.opencode.setup.serviceError":"settings.opencode.update.checking"))),i})()},children:i=>[(()=>{var c=yA();return p(c,()=>t(s()??(xr()?"settings.opencode.setup.disconnected":Zi()?"settings.opencode.setup.connected":i().state==="ready"?"settings.opencode.setup.disconnected":`settings.opencode.setup.${i().state}`))),c})(),(()=>{var c=vA(),l=c.firstChild,d=l.firstChild,u=d.nextSibling,f=l.nextSibling,g=f.firstChild,m=g.nextSibling;return p(d,()=>t("settings.opencode.update.installed")),p(u,()=>i().currentVersion??"—"),p(g,()=>t("settings.opencode.setup.daemon")),p(m,()=>i().daemonVersion??"—"),c})(),(()=>{var c=wA();return p(c,()=>i().binaryPath),c})(),y(ee,{get when(){return i().installationSource},children:c=>(()=>{var l=ed();return p(l,()=>t(`settings.opencode.setup.source.${c()}`)),l})()}),y(ee,{get when(){return Ee(()=>!!i().updateAvailable)()&&i().latestVersion},get children(){var c=Di();return p(c,()=>t("settings.opencode.update.available",{version:i().latestVersion??""})),c}}),y(ee,{get when(){return Ee(()=>!!(i().updateAvailable===!1&&i().latestVersion))()&&!i().checkError},get children(){var c=Di();return p(c,()=>t("settings.opencode.update.upToDate")),c}}),y(ee,{get when(){return i().target==="wsl"},get children(){var c=ed();return p(c,()=>t("settings.opencode.setup.wsl")),c}}),y(ee,{get when(){return i().serviceState==="restart_required"||i().serviceState==="restart_available"},get children(){var c=Di();return p(c,()=>t(i().serviceState==="restart_required"?"settings.opencode.setup.restartRequired":"settings.opencode.setup.restartAvailable")),c}}),y(ee,{get when(){return Ee(()=>!xr())()&&i().serviceState==="error"},get children(){var c=ib();return p(c,()=>t("settings.opencode.setup.serviceError")),c}}),y(ee,{get when(){return i().checkError},get children(){var c=Di();return p(c,()=>t("settings.opencode.update.checkFailed")),c}}),y(ee,{get when(){return Ee(()=>!i().canUpgrade)()&&(i().updateAvailable||i().state==="missing"||i().state==="update_required"||i().serviceState==="incompatible")},get children(){var c=bA();return p(c,()=>t("settings.opencode.setup.manual")),c}}),y(ee,{get when(){return Ee(()=>!!(i().daemonVersion||i().currentVersion))()&&i().versionAssessment==="untested"},get children(){var c=ed();return p(c,()=>t("settings.opencode.setup.untested",{version:i().daemonVersion??i().currentVersion??""})),c}}),(()=>{var c=SA();return p(c,y(ee,{get when(){return i().canUpgrade},get children(){var l=td();return l.$$click=()=>void pc("install"),p(l,(()=>{var d=Ee(()=>mc()==="install");return()=>d()?t("settings.opencode.update.updating"):Ee(()=>!!i().needsSharedInstallation)()?t("settings.opencode.setup.sharedInstall"):Ee(()=>i().state==="missing")()?t("settings.opencode.setup.install"):t("settings.opencode.update.action",{version:i().latestVersion??""})})()),de(()=>l.disabled=n()),l}}),null),p(c,y(ee,{get when(){return Ee(()=>i().state==="ready"&&!Zi()&&i().serviceState!=="restart_required")()&&i().serviceState!=="incompatible"},get children(){var l=td();return l.$$click=()=>void pc("start"),p(l,()=>t("settings.opencode.setup.connect")),de(()=>l.disabled=n()),l}}),null),p(c,y(ee,{get when(){return Ee(()=>!!Zi())()&&Wk()},get children(){var l=td();return l.$$click=()=>void Hk(),p(l,()=>t("settings.opencode.setup.continue")),de(()=>l.disabled=n()),l}}),null),p(c,y(ee,{get when(){return i().canRestart},get children(){var l=td();return l.$$click=()=>void pc("restart"),p(l,()=>t("settings.opencode.setup.restart")),de(()=>l.disabled=n()||xr()),l}}),null),c})(),y(ee,{get when(){return Ee(()=>!!i().canUpgrade)()&&(i().state==="missing"||i().needsSharedInstallation)},get children(){var c=ed();return p(c,()=>t("settings.opencode.setup.sharedInstallDescription")),c}})]}),o),p(r,y(ee,{get when(){return xr()},get children(){var i=ob();return p(i,()=>t("settings.opencode.setup.serviceError")),i}}),o),p(r,y(ee,{get when(){return zk()},get children(){var i=ob();return p(i,()=>t(Lh()?`settings.opencode.setup.${Lh()}`:"settings.opencode.setup.actionFailed")),i}}),o),p(r,y(ee,{get when(){return Bh()},get children(){var i=Di();return p(i,()=>t(`settings.opencode.setup.${Bh()}`)),i}}),o),a.$$click=()=>void Fs(!1,!0),p(a,()=>t(Mc()?"settings.opencode.update.checking":"settings.opencode.setup.check")),p(r,()=>e.children,null),p(r,y(ee,{get when(){return ur()},children:i=>[(()=>{var c=kA(),l=c.firstChild,d=l.nextSibling,u=d.firstChild,f=u.firstChild,g=f.nextSibling,m=u.nextSibling,w=m.firstChild,S=w.nextSibling,b=d.nextSibling;return p(l,()=>t("settings.opencode.setup.diagnostics")),p(f,()=>t("settings.opencode.setup.minimum")),p(g,()=>i().minimumVersion),p(w,()=>t("settings.opencode.setup.recommended")),p(S,()=>i().recommendedVersion),p(b,()=>t("settings.opencode.setup.minimumReason",{version:i().minimumVersion})),p(c,y(ee,{get when(){return Ee(()=>!!i().incompatibilityReason)()&&i().incompatibilityReason!=="step_timestamp"},get children(){var v=ib();return p(v,()=>t(`settings.opencode.setup.${i().incompatibilityReason}`)),v}}),null),c})(),y(ee,{get when(){return i().canReload},get children(){var c=xA(),l=c.firstChild,d=l.nextSibling,u=d.nextSibling,f=u.firstChild;return p(l,()=>t("settings.opencode.setup.troubleshooting")),p(d,()=>t("settings.opencode.setup.reloadDescription")),f.$$click=()=>void pc("reload"),p(f,()=>t("settings.opencode.setup.reload")),de(()=>f.disabled=n()||xr()),c}})]}),null),de(i=>{var c=n(),l=n();return c!==i.e&&me(r,"aria-busy",i.e=c),l!==i.t&&(a.disabled=i.t=l),i},{e:void 0,t:void 0}),r})()}Xt(["click"]);const Pi={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var _A=O("<svg>");const $A=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),nt=e=>{const[t,n]=Nt(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var s=_A();return lr(s,_e(Pi,{get width(){return t.size??Pi.width},get height(){return t.size??Pi.height},get stroke(){return t.color??Pi.stroke},get"stroke-width"(){return Ee(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??Pi["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??Pi["stroke-width"])},get class(){return`lucide lucide-${$A((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),p(s,y(zt,{get each(){return t.iconNode},children:([r,o])=>y(Tp,_e({component:r},o))})),s})()},CA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],EA=e=>y(nt,_e(e,{name:"AlertCircle",iconNode:CA})),TA=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Yk=e=>y(nt,_e(e,{name:"ArrowLeft",iconNode:TA})),MA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]],AA=e=>y(nt,_e(e,{name:"ArrowRightSquare",iconNode:MA})),DA=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],PA=e=>y(nt,_e(e,{name:"ArrowUpLeft",iconNode:DA})),IA=[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]],Jk=e=>y(nt,_e(e,{name:"Bell",iconNode:IA})),RA=[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]],OA=e=>y(nt,_e(e,{name:"BookOpen",iconNode:RA})),LA=[["path",{d:"M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z",key:"1mhkh5"}],["path",{d:"M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z",key:"1d6s00"}]],NA=e=>y(nt,_e(e,{name:"Brain",iconNode:LA})),FA=[["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}],["path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11",key:"1jnkn4"}]],BA=e=>y(nt,_e(e,{name:"CheckSquare",iconNode:FA})),UA=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Qk=e=>y(nt,_e(e,{name:"Check",iconNode:UA})),KA=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],fr=e=>y(nt,_e(e,{name:"ChevronDown",iconNode:KA})),VA=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jA=e=>y(nt,_e(e,{name:"ChevronRight",iconNode:VA})),qA=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],zA=e=>y(nt,_e(e,{name:"ClipboardCheck",iconNode:qA})),WA=[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]],HA=e=>y(nt,_e(e,{name:"Code",iconNode:WA})),GA=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],ZA=e=>y(nt,_e(e,{name:"Coins",iconNode:GA})),YA=[["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}],["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["line",{x1:"10",x2:"21",y1:"14",y2:"3",key:"18c3s4"}]],Yi=e=>y(nt,_e(e,{name:"ExternalLink",iconNode:YA})),JA=[["circle",{cx:"6",cy:"13",r:"3",key:"1z65bp"}],["path",{d:"m9.7 14.4-.9-.3",key:"o1luaq"}],["path",{d:"m3.2 11.9-.9-.3",key:"qm3zk5"}],["path",{d:"m4.6 16.7.3-.9",key:"1o0ect"}],["path",{d:"m7.6 16.7-.4-1",key:"1ym8d1"}],["path",{d:"m4.8 10.3-.4-1",key:"18q26g"}],["path",{d:"m2.3 14.6 1-.4",key:"121m88"}],["path",{d:"m8.7 11.8 1-.4",key:"9meqp2"}],["path",{d:"m7.4 9.3-.3.9",key:"136qqn"}],["path",{d:"M14 2v6h6",key:"1kof46"}],["path",{d:"M4 5.5V4a2 2 0 0 1 2-2h8.5L20 7.5V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-1.5",key:"xwe04"}]],QA=e=>y(nt,_e(e,{name:"FileCog",iconNode:JA})),XA=[["path",{d:"M4 13.5V4a2 2 0 0 1 2-2h8.5L20 7.5V20a2 2 0 0 1-2 2h-5.5",key:"1bg6eb"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M10.42 12.61a2.1 2.1 0 1 1 2.97 2.97L7.95 21 4 22l.99-3.95 5.43-5.44Z",key:"1rgxu8"}]],eD=e=>y(nt,_e(e,{name:"FileEdit",iconNode:XA})),tD=[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]],nD=e=>y(nt,_e(e,{name:"File",iconNode:tD})),sD=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],rD=e=>y(nt,_e(e,{name:"FolderOpen",iconNode:sD})),oD=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],iD=e=>y(nt,_e(e,{name:"FolderPlus",iconNode:oD})),aD=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Xk=e=>y(nt,_e(e,{name:"Folder",iconNode:aD})),cD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ei=e=>y(nt,_e(e,{name:"Globe",iconNode:cD})),lD=[["path",{d:"M22 10v6M2 10l10-5 10 5-10 5z",key:"1ef52a"}],["path",{d:"M6 12v5c3 3 9 3 12 0v-5",key:"1f75yj"}]],dD=e=>y(nt,_e(e,{name:"GraduationCap",iconNode:lD})),uD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],fD=e=>y(nt,_e(e,{name:"HelpCircle",iconNode:uD})),gD=[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]],hD=e=>y(nt,_e(e,{name:"Home",iconNode:gD})),mD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Up=e=>y(nt,_e(e,{name:"Info",iconNode:mD})),pD=[["path",{d:"M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z",key:"167ctg"}],["circle",{cx:"16.5",cy:"7.5",r:".5",key:"1kog09"}]],yD=e=>y(nt,_e(e,{name:"KeyRound",iconNode:pD})),vD=[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]],ab=e=>y(nt,_e(e,{name:"Key",iconNode:vD})),wD=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],bD=e=>y(nt,_e(e,{name:"Languages",iconNode:wD})),SD=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],kD=e=>y(nt,_e(e,{name:"LayoutGrid",iconNode:SD})),xD=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Td=e=>y(nt,_e(e,{name:"Link2",iconNode:xD})),_D=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Zn=e=>y(nt,_e(e,{name:"Loader2",iconNode:_D})),$D=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],CD=e=>y(nt,_e(e,{name:"LogIn",iconNode:$D})),ED=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],TD=e=>y(nt,_e(e,{name:"Maximize2",iconNode:ED})),MD=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],AD=e=>y(nt,_e(e,{name:"MessageSquare",iconNode:MD})),DD=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],Ig=e=>y(nt,_e(e,{name:"Mic",iconNode:DD})),PD=[["path",{d:"M5 12h14",key:"1ays0h"}]],ID=e=>y(nt,_e(e,{name:"Minus",iconNode:PD})),RD=[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],OD=e=>y(nt,_e(e,{name:"MonitorUp",iconNode:RD})),LD=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],ND=e=>y(nt,_e(e,{name:"Network",iconNode:LD})),FD=[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]],BD=e=>y(nt,_e(e,{name:"Paperclip",iconNode:FD})),UD=[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],KD=e=>y(nt,_e(e,{name:"Pencil",iconNode:UD})),VD=[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],ex=e=>y(nt,_e(e,{name:"PlugZap",iconNode:VD})),jD=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],of=e=>y(nt,_e(e,{name:"Plus",iconNode:jD})),qD=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Gd=e=>y(nt,_e(e,{name:"RefreshCw",iconNode:qD})),zD=[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]],WD=e=>y(nt,_e(e,{name:"Save",iconNode:zD})),HD=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],cb=e=>y(nt,_e(e,{name:"Search",iconNode:HD})),GD=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],nd=e=>y(nt,_e(e,{name:"Settings",iconNode:GD})),ZD=[["path",{d:"M19.7 14a6.9 6.9 0 0 0 .3-2V5l-8-3-3.2 1.2",key:"342pvf"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4.7 4.7 4 5v7c0 6 8 10 8 10a20.3 20.3 0 0 0 5.62-4.38",key:"p0ycf4"}]],lb=e=>y(nt,_e(e,{name:"ShieldOff",iconNode:ZD})),YD=[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}]],Zd=e=>y(nt,_e(e,{name:"Shield",iconNode:YD})),JD=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],QD=e=>y(nt,_e(e,{name:"SlidersHorizontal",iconNode:JD})),XD=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],db=e=>y(nt,_e(e,{name:"Square",iconNode:XD})),eP=[["path",{d:"M4.8 2.3A.3.3 0 1 0 5 2H4a2 2 0 0 0-2 2v5a6 6 0 0 0 6 6v0a6 6 0 0 0 6-6V4a2 2 0 0 0-2-2h-1a.2.2 0 1 0 .3.3",key:"1jd90r"}],["path",{d:"M8 15v1a6 6 0 0 0 6 6v0a6 6 0 0 0 6-6v-4",key:"126ukv"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],tP=e=>y(nt,_e(e,{name:"Stethoscope",iconNode:eP})),nP=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],Kp=e=>y(nt,_e(e,{name:"Terminal",iconNode:nP})),sP=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],af=e=>y(nt,_e(e,{name:"Trash2",iconNode:sP})),rP=[["polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",key:"16drj5"}],["path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",key:"ltjumu"}],["path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",key:"1kegas"}]],Kh=e=>y(nt,_e(e,{name:"Volume2",iconNode:rP})),oP=[["path",{d:"M5 13a10 10 0 0 1 14 0",key:"6v8j51"}],["path",{d:"M8.5 16.5a5 5 0 0 1 7 0",key:"sej527"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["line",{x1:"12",x2:"12.01",y1:"20",y2:"20",key:"of4bc4"}]],iP=e=>y(nt,_e(e,{name:"Wifi",iconNode:oP})),aP=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ti=e=>y(nt,_e(e,{name:"X",iconNode:aP})),uH={maxFileBytes:5*1024*1024,maxFiles:10,maxTotalBytes:20*1024*1024,maxRequestBodyBytes:32*1024*1024},ub="__drives__",Vh="opencode_v2_required",cP="session_environment_failed";var lP=O("<div class=directory-browser-destinations role=listbox>"),dP=O('<div class=directory-browser-address><input type=text role=combobox aria-autocomplete=list class="selector-input directory-browser-current-path">'),uP=O("<button type=button role=option class=directory-browser-destination><span class=truncate>");const fP=e=>{const{t}=Dt(),n=Do(),[s,r]=R(-1),o=()=>e.open&&e.destinations.length>0;return Ze(()=>{var a;o()&&s()>=0&&((a=document.getElementById(`${n}-${s()}`))==null||a.scrollIntoView({block:"nearest"}))}),(()=>{var a=dP(),i=a.firstChild;return a.$$focusout=c=>{c.currentTarget.contains(c.relatedTarget)||e.onOpenChange(!1)},i.$$keydown=c=>{if(c.key==="Escape"&&e.open)c.preventDefault(),c.stopPropagation(),e.onOpenChange(!1),e.onReset();else if(c.key==="ArrowDown"&&!e.open&&e.destinations.length>0)c.preventDefault(),e.onOpenChange(!0),r(0);else if(c.key==="ArrowDown"&&o())c.preventDefault(),r(l=>Math.min(l+1,e.destinations.length-1));else if(c.key==="ArrowUp"&&o())c.preventDefault(),r(l=>Math.max(l-1,-1));else if(c.key==="Enter"){c.preventDefault();const l=o()?e.destinations[s()]:void 0;l?e.onChoose(l):e.onSubmit(),e.onOpenChange(!1),r(-1)}},i.$$click=()=>{e.open||(e.onOpenChange(!0),r(-1))},i.addEventListener("focus",()=>{e.onOpenChange(!0),r(-1)}),i.$$input=c=>{e.onInput(c.currentTarget.value),r(-1)},me(i,"spellcheck",!1),p(a,y(ee,{get when(){return o()},get children(){var c=lP();return me(c,"id",n),p(c,y(zt,{get each(){return e.destinations},children:(l,d)=>(()=>{var u=uP(),f=u.firstChild;return u.$$click=()=>{e.onChoose(l),e.onOpenChange(!1),r(-1)},u.$$mousedown=g=>g.preventDefault(),p(u,(()=>{var g=Ee(()=>l.kind==="initial");return()=>g()?y(Yk,{class:"w-4 h-4"}):Ee(()=>l.kind==="parent")()?y(PA,{class:"w-4 h-4"}):Ee(()=>l.kind==="home")()?y(hD,{class:"w-4 h-4"}):y(Xk,{class:"w-4 h-4"})})(),f),p(f,()=>l.label),de(g=>{var m=`${n}-${d()}`,w=s()===d()?"":void 0,S=s()===d(),b=l.target;return m!==g.e&&me(u,"id",g.e=m),w!==g.t&&me(u,"data-active",g.t=w),S!==g.a&&me(u,"aria-selected",g.a=S),b!==g.o&&me(u,"title",g.o=b),g},{e:void 0,t:void 0,a:void 0,o:void 0}),u})()})),de(()=>me(c,"aria-label",t("directoryBrowser.goTo"))),c}}),null),de(c=>{var l=t("directoryBrowser.currentFolder.inputPlaceholder"),d=t("directoryBrowser.currentFolder.inputAriaLabel"),u=o(),f=o()?n:void 0,g=o()&&s()>=0?`${n}-${s()}`:void 0;return l!==c.e&&me(i,"placeholder",c.e=l),d!==c.t&&me(i,"aria-label",c.t=d),u!==c.a&&me(i,"aria-expanded",c.a=u),f!==c.o&&me(i,"aria-controls",c.o=f),g!==c.i&&me(i,"aria-activedescendant",c.i=g),c},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),de(()=>i.value=e.value),a})()};Xt(["focusout","input","click","keydown","mousedown"]);var gP=O('<button type=button class="selector-button selector-button-secondary directory-browser-select directory-browser-new-folder"><span class="inline-flex items-center gap-2">'),hP=O('<div><span class=directory-browser-current-label></span><button type=button class="selector-button selector-button-secondary directory-browser-open-path"><span>'),mP=O('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),pP=O('<div class="fixed inset-0 z-[1305] flex items-center justify-center bg-black/60 p-6"><div class="modal-surface directory-browser-modal"role=dialog aria-modal=true><div class="panel directory-browser-panel"><div class=directory-browser-header><div class=directory-browser-heading><h3 class=directory-browser-title></h3><p class=directory-browser-description></p></div><button type=button class=directory-browser-close></button></div><div class="panel-body directory-browser-body">'),yP=O("<div class=directory-browser-loading><span>"),fb=O('<div class="panel-empty-state flex-1">'),vP=O("<span class=text-red-500>"),wP=O('<div class=panel-list-item role=option><div class="panel-list-item-content directory-browser-row"><button type=button class=directory-browser-row-main><div class=directory-browser-row-icon></div><div class=directory-browser-row-text><span class=directory-browser-row-name>'),bP=O('<button type=button class="selector-button selector-button-secondary directory-browser-select">');function Ko(e){if(!e||e==="."||e==="./")return".";if(e===ub)return ub;let t=e.replace(/\\/g,"/");if(/^[a-zA-Z]:/.test(t)){const[n,s=""]=t.split(":"),r=s.startsWith("/")?s:s?`/${s}`:"/";return`${n.toUpperCase()}:${r.replace(/\/+/g,"/")}`}return t.startsWith("//")?`//${t.slice(2).replace(/\/+/g,"/")}`:t.startsWith("/")?`/${t.slice(1).replace(/\/+/g,"/")}`:(t=t.replace(/^\.\/+/,"").replace(/\/+/g,"/"),t===""?".":t)}function jh(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function Md(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(jh(t))return t;const n=e.includes("\\")?"\\":"/",s=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${s}${r}`}function oc(e){return!e||e.pathKind==="drives"?"":e.pathKind==="relative"?Md(e.rootPath,e.currentPath):e.displayPath}const SP=e=>{const{t}=Dt(),[n,s]=R(""),[r,o]=R(!1),[a,i]=R(null),[c,l]=R(""),[d,u]=R(!1),[f,g]=R(!1),[m,w]=R(new Map),[S,b]=R(new Set),[v,k]=R(null),[C,_]=R(null),[T,P]=R(""),[I,j]=R(!1),ne=new Map,W=new Map;let q=0,U=0;function G(){++U,++q,s(""),w(new Map),b(new Set),k(null),_(null),l(""),u(!1),P(""),j(!1),ne.clear(),W.clear(),i(null)}Ze(()=>{if(!e.open)return;G(),le(U);const B=se=>{se.key==="Escape"&&(se.preventDefault(),e.onClose())};window.addEventListener("keydown",B),dt(()=>{window.removeEventListener("keydown",B)})});async function le(B){var se;o(!0);try{const pe=(se=e.initialPath)==null?void 0:se.trim();if(pe){const Se=await N(pe);if(B!==U||!e.open)return;if(Se){P(oc(Se));return}i(null)}B===U&&e.open&&await N(void 0)}finally{B===U&&e.open&&o(!1)}}function K(B){const se=Ko(B.currentPath);k(se),_(B),s(B.rootPath)}async function M(B){const se=U,pe=B?Ko(B):void 0;if(pe){const Q=ne.get(pe);if(Q)return Q;const be=W.get(pe);if(be)return be}const Se=(async()=>{pe&&b(He=>{const re=new Set(He);return re.add(pe),re});const Q=await kt.listFileSystem(B,{includeFiles:e.mode==="files"});if(se!==U||!e.open)return Q.metadata;const be=Ko(Q.metadata.currentPath),Ve=Q.entries.filter(He=>e.mode==="files"||He.type==="directory").sort((He,re)=>{const F=He.type==="directory"?0:1,V=re.type==="directory"?0:1;return F!==V?F-V:He.name.localeCompare(re.name)});return w(He=>{const re=new Map(He);return re.set(be,Ve),re}),ne.set(be,Q.metadata),b(He=>{const re=new Set(He);return pe&&re.delete(pe),re.delete(be),re}),Q.metadata})().catch(Q=>{throw pe&&se===U&&b(be=>{const Ve=new Set(be);return Ve.delete(pe),Ve}),Q}).finally(()=>{pe&&W.get(pe)===Se&&W.delete(pe)});return pe&&W.set(pe,Se),Se}async function N(B){const se=++q;i(null);try{const pe=await M(B);return se!==q||!e.open?null:(K(pe),pe)}catch(pe){if(se!==q||!e.open)return null;const Se=pe instanceof Error?pe.message:t("directoryBrowser.load.errorFallback");return i(Se),null}}const oe=Te(()=>{const B=v();return B?m().get(B)??[]:[]});function ge(B){u(!1),N(B)}const Ie=Te(()=>oc(C()));Ze(()=>{const B=Ie();d()||l(B)});const ke=Te(()=>!!Ie()),we=Te(()=>c().trim().length>0),Ae=Te(()=>{const B=C();if(!B)return[];const se=Ie(),pe=[],Se=new Set([Ko(se)]),Q=V=>{const Me=Ko(V.target);Se.has(Me)||(Se.add(Me),pe.push(V))},be=T();if(be){const V=be.split(/[\\/]/).filter(Boolean).at(-1)??be;Q({target:be,label:t("directoryBrowser.goToInitial",{name:V}),kind:"initial"})}if(B.scope==="unrestricted"&&B.homePath&&Q({target:B.homePath,label:t("directoryBrowser.goToHome"),kind:"home"}),B.parentPath){const V=B.pathKind==="relative"?Md(B.rootPath,B.parentPath):B.parentPath;Q({target:V,label:t("directoryBrowser.goToParent"),kind:"parent"})}const Ve=c().trim().replace(/\\/g,"/"),He=se.replace(/\\/g,"/"),re=He.replace(/\/$/,""),F=Ve===He?"":Ve.startsWith(`${re}/`)?Ve.slice(re.length+1):!Ve.includes("/")&&!Ve.includes(":")?Ve:null;if(!F||F.includes("/"))return pe;for(const V of m().get(v()??"")??[])V.type!=="directory"||!V.name.toLocaleLowerCase().startsWith(F.toLocaleLowerCase())||Q({target:V.absolutePath??(jh(V.path)?V.path:Md(B.rootPath,V.path)),label:V.name,kind:"folder"});return pe});function Ge(B){j(!1),u(!1),N(B.target)}async function H(){j(!1);const B=c().trim();if(!B)return;const se=await N(B);se&&(u(!1),l(oc(se)))}async function h(){const B=c().trim(),se=B&&B!==Ie()?await N(B):C();if(!se)return;u(!1);const pe=oc(se);pe&&e.mode!=="files"&&(l(pe),e.onSelect(pe))}function $(B){const se=B.absolutePath?B.absolutePath:jh(B.path)?B.path:Md(n(),B.path);e.onSelect(se,B)}async function D(){var Se;if(f())return;const B=c().trim(),se=B&&B!==Ie()?await N(B):C();if(!se||se.pathKind==="drives")return;u(!1),l(oc(se));const pe=((Se=await tA(t("directoryBrowser.createFolder.promptMessage"),{title:t("directoryBrowser.createFolder.title"),inputLabel:t("directoryBrowser.createFolder.inputLabel"),inputPlaceholder:t("directoryBrowser.createFolder.inputPlaceholder"),confirmLabel:t("directoryBrowser.createFolder.confirmLabel"),cancelLabel:t("directoryBrowser.createFolder.cancelLabel")}))==null?void 0:Se.trim())??"";if(pe){if(pe==="."||pe===".."||pe.startsWith("~")||pe.includes("/")||pe.includes("\\")){Ns(t("directoryBrowser.createFolder.invalidNameMessage"),{variant:"warning",detail:t("directoryBrowser.createFolder.invalidNameDetail")});return}g(!0);try{const Q=Ko(se.currentPath);ne.delete(Q),W.delete(Q),w(Ve=>{const He=new Map(Ve);return He.delete(Q),He});const be=await kt.createFileSystemFolder(se.currentPath,pe);await N(be.path)}catch(Q){const be=Q instanceof Error?Q.message:t("directoryBrowser.createFolder.errorFallback");Ns(be,{variant:"error",title:t("directoryBrowser.createFolder.errorFallback")})}finally{g(!1)}}}function E(B){return S().has(Ko(B))}function Z(B){B.target===B.currentTarget&&e.onClose()}return y(ee,{get when(){return e.open},get children(){var B=pP(),se=B.firstChild,pe=se.firstChild,Se=pe.firstChild,Q=Se.firstChild,be=Q.firstChild,Ve=be.nextSibling,He=Q.nextSibling,re=Se.nextSibling;return B.$$click=Z,p(be,()=>e.title),p(Ve,()=>e.description||t("directoryBrowser.defaultDescription")),lk(He,"click",e.onClose,!0),p(He,y(ti,{class:"w-5 h-5"})),p(re,y(ee,{get when(){return n()},get children(){var F=hP(),V=F.firstChild,Me=V.nextSibling,xe=Me.firstChild;return p(V,()=>t("directoryBrowser.currentFolder")),p(F,y(fP,{get value(){return c()},get destinations(){return Ae()},get open(){return Ee(()=>!!I())()&&!f()},onOpenChange:j,onInput:Re=>{l(Re),u(!0)},onReset:()=>{u(!1),l(Ie())},onSubmit:()=>void H(),onChoose:Ge}),Me),p(F,y(ee,{get when(){return e.mode!=="files"},get children(){var Re=gP(),Be=Re.firstChild;return Re.$$click=()=>void D(),p(Be,y(iD,{class:"w-4 h-4"}),null),p(Be,(()=>{var et=Ee(()=>!!f());return()=>et()?t("directoryBrowser.creating"):t("directoryBrowser.newFolder")})(),null),de(()=>Re.disabled=!ke()||f()),Re}}),Me),Me.$$click=()=>void h(),p(Me,y(AA,{class:"w-4 h-4"}),xe),p(xe,()=>t("directoryBrowser.openCurrent")),de(Re=>{var Be=`directory-browser-current ${e.mode==="files"?"directory-browser-current--files":""}`,et=!ke()&&!we()||f(),Ue=t("directoryBrowser.openCurrent"),We=t("directoryBrowser.openCurrent");return Be!==Re.e&&ws(F,Re.e=Be),et!==Re.t&&(Me.disabled=Re.t=et),Ue!==Re.a&&me(Me,"title",Re.a=Ue),We!==Re.o&&me(Me,"aria-label",Re.o=We),Re},{e:void 0,t:void 0,a:void 0,o:void 0}),F}}),null),p(re,y(ee,{get when(){return Ee(()=>!r())()&&!a()},get fallback(){return(()=>{var F=fb();return p(F,y(ee,{get when(){return r()},get fallback(){return(()=>{var V=vP();return p(V,a),V})()},get children(){var V=yP(),Me=V.firstChild;return p(V,y(Zn,{class:"w-5 h-5 animate-spin"}),Me),p(Me,()=>t("directoryBrowser.loadingFolders")),V}})),F})()},get children(){return y(ee,{get when(){return oe().length>0},get fallback(){return(()=>{var F=fb();return p(F,()=>t("directoryBrowser.noFolders")),F})()},get children(){var F=mP();return p(F,y(zt,{get each(){return oe()},children:V=>{const Me=V.type==="directory",xe=e.mode==="files"?V.type==="file":Me,Re=()=>{if(Me){ge(V.path);return}$(V)};return(()=>{var Be=wP(),et=Be.firstChild,Ue=et.firstChild,We=Ue.firstChild,st=We.nextSibling,at=st.firstChild;return Ue.$$click=Re,p(We,y(ee,{when:!Me,get fallback(){return y(Xk,{class:"w-4 h-4"})},get children(){return y(nD,{class:"w-4 h-4"})}})),p(at,()=>V.name||V.path),p(Ue,y(ee,{get when(){return Me&&E(V.path)},get children(){return y(Zn,{class:"directory-browser-row-spinner animate-spin"})}}),null),p(et,xe?(()=>{var ht=bP();return ht.$$click=ut=>{ut.stopPropagation(),$(V)},p(ht,()=>t("directoryBrowser.select")),ht})():null,null),Be})()}})),F}})}}),null),de(()=>me(He,"aria-label",t("directoryBrowser.close"))),B}})};Xt(["click"]);const kP=Ut("actions");function xP(e){return!e||e.canceled?[]:(Array.isArray(e.paths)?e.paths:e.path?[e.path]:[]).filter(n=>typeof n=="string"&&n.trim().length>0)}async function _P(e){if(typeof window>"u")return null;const t=window.electronAPI;if(!(t!=null&&t.openDialog))return null;try{const n=await t.openDialog(e),s=xP(n);return e.multiple?s:s[0]??null}catch(n){return kP.error("[native] electron dialog failed",n),null}}async function $P(e={}){return typeof e=="object"&&Object.freeze(e),await Ms("plugin:dialog|open",{options:e})}const CP=Ut("actions");async function EP(e){var t;if(typeof window>"u")return null;try{const n=await $P({title:e.title,defaultPath:e.defaultPath,directory:e.mode==="directory",multiple:!!e.multiple,filters:(t=e.filters)==null?void 0:t.map(s=>({name:s.name??"Files",extensions:s.extensions}))});return n?Array.isArray(n)?e.multiple?n:n[0]??null:e.multiple?[n]:n:null}catch(n){return CP.error("[native] tauri dialog failed",n),null}}function TP(){return Bn()?_P:Dn()?EP:null}function MP(){return YT()}async function tx(e){const t=TP();return t?t(e):null}async function fH(e){const t=await tx({mode:"directory",...e??{}});return Array.isArray(t)?t[0]??null:t}async function AP(e){const t=await tx({mode:"file",...e??{}});return Array.isArray(t)?t[0]??null:t}var DP=O('<div class="selector-loading text-xs"><span>'),PP=O("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),IP=O('<div class=panel><div class="panel-header flex items-center justify-between gap-3"><div><h3 class=panel-title></h3><p class=panel-subtitle></p></div></div><div class="panel-body space-y-3"><div class=selector-input-group><input type=text class=selector-input><button type=button class="selector-button selector-button-primary"></button></div><button type=button class="selector-button selector-button-secondary w-full flex items-center justify-center gap-2"></button></div><div class="panel-list panel-list--fill max-h-80 overflow-y-auto">'),RP=O('<div class="text-xs font-mono truncate pl-6 text-muted">'),OP=O("<span class=selector-badge-version>"),Rg=O("<span class=selector-badge-time>"),LP=O('<button type=button class="p-2 text-muted hover:text-primary">'),NP=O('<div class="panel-list-item flex items-center"><button type=button class="panel-list-item-content flex-1"><div class="flex flex-col flex-1 min-w-0 gap-1.5"><div class="flex items-center gap-2"><span class="text-sm font-medium truncate text-primary"></span></div><div class="flex items-center gap-2 text-xs text-muted pl-6 flex-wrap">');const FP=Ut("actions"),BP=e=>{const{t}=Dt(),{opencodeBinaries:n,addOpenCodeBinary:s,removeOpenCodeBinary:r,serverSettings:o}=Un(),[a,i]=R(""),[c,l]=R(!1),[d,u]=R(null),[f,g]=R(new Map),[m,w]=R(new Set),[S,b]=R(!1),v=()=>n(),k=()=>o().opencodeBinary,C=Te(()=>v().filter(M=>M.path!=="opencode"&&M.path!=="opencode2")),_=Te(()=>[{path:"opencode2",isDefault:!0},...C()]),T=()=>e.selectedBinary||"opencode2";Ze(()=>{if(!e.selectedBinary&&k())e.onBinaryChange(k());else if(!e.selectedBinary){const M=v()[0];M&&e.onBinaryChange(M.path)}}),Ze(()=>{const M=new Map(f());let N=!1;v().forEach(oe=>{oe.version&&!M.has(oe.path)&&(M.set(oe.path,oe.version),N=!0)}),N&&g(M)}),Ze(()=>{if(!e.isVisible)return;const M=f(),N=["opencode2",...C().map(oe=>oe.path)].filter(oe=>!M.has(oe));N.length!==0&&setTimeout(()=>{N.forEach(oe=>{P(oe).catch(ge=>FP.error("Failed to validate binary",{path:oe,error:ge}))})},0)}),dt(()=>{w(new Set),l(!1)});async function P(M){if(m().has(M))return{valid:!1,error:t("opencodeBinarySelector.validation.alreadyValidating")};try{w(ge=>new Set(ge).add(M)),l(!0),u(null);const N=await kt.validateBinary(M),oe=N.errorCode===Vh?{...N,error:t("opencodeBinarySelector.validation.v2Required")}:N;if(oe.valid&&oe.version){const ge=new Map(f());ge.set(M,oe.version),g(ge)}return oe}catch(N){return{valid:!1,error:N instanceof Error?N.message:String(N)}}finally{w(N=>{const oe=new Set(N);return oe.delete(M),oe.size===0&&l(!1),oe})}}async function I(){if(!e.disabled){if(u(null),MP()){const M=await AP({title:t("opencodeBinarySelector.dialog.title")});M&&(i(M),j(M));return}b(!0)}}async function j(M){const N=await P(M);N.valid?(s(M,N.version),e.onBinaryChange(M),i(""),u(null)):u(N.error||t("opencodeBinarySelector.validation.invalidBinary"))}function ne(M){b(!1),i(M),j(M)}async function W(){const M=a().trim();M&&await j(M)}function q(M){e.disabled||M!==e.selectedBinary&&e.onBinaryChange(M)}function U(M,N){N.stopPropagation(),!e.disabled&&(r(M),e.selectedBinary===M&&e.onBinaryChange("opencode2"))}function G(M){if(!M)return"";const N=Math.floor((Date.now()-M)/1e3),oe=Math.floor(N/60),ge=Math.floor(oe/60),Ie=Math.floor(ge/24);return Ie>0?t("time.relative.daysAgoShort",{count:Ie}):ge>0?t("time.relative.hoursAgoShort",{count:ge}):oe>0?t("time.relative.minutesAgoShort",{count:oe}):t("time.relative.justNow")}function le(M){if(M==="opencode2")return t("opencodeBinarySelector.display.systemPath",{name:"opencode2"});const N=M.split(/[/\\]/);return N[N.length-1]??M}const K=M=>m().has(M);return[(()=>{var M=IP(),N=M.firstChild,oe=N.firstChild,ge=oe.firstChild,Ie=ge.nextSibling,ke=N.nextSibling,we=ke.firstChild,Ae=we.firstChild,Ge=Ae.nextSibling,H=we.nextSibling,h=ke.nextSibling;return p(ge,()=>t("opencodeBinarySelector.title")),p(Ie,()=>t("opencodeBinarySelector.subtitle")),p(N,y(ee,{get when(){return c()},get children(){var $=DP(),D=$.firstChild;return p($,y(Zn,{class:"selector-loading-spinner"}),D),p(D,()=>t("opencodeBinarySelector.status.checkingVersions")),$}}),null),Ae.$$keydown=$=>{$.key==="Enter"&&($.preventDefault(),W())},Ae.$$input=$=>i($.currentTarget.value),Ge.$$click=W,p(Ge,y(of,{class:"w-4 h-4"}),null),p(Ge,()=>t("opencodeBinarySelector.actions.add"),null),H.$$click=()=>void I(),p(H,y(rD,{class:"w-4 h-4"}),null),p(H,()=>t("opencodeBinarySelector.actions.browse"),null),p(ke,y(ee,{get when(){return d()},get children(){var $=PP(),D=$.firstChild,E=D.firstChild;return p(D,y(EA,{class:"selector-validation-error-icon"}),E),p(E,d),$}}),null),p(h,y(zt,{get each(){return _()},children:$=>{const D=$.isDefault,E=()=>(D?e.defaultVersion:void 0)??f().get($.path)??$.version;return(()=>{var Z=NP(),B=Z.firstChild,se=B.firstChild,pe=se.firstChild,Se=pe.firstChild,Q=pe.nextSibling;return B.$$click=()=>q($.path),p(pe,y(Qk,{get class(){return`w-4 h-4 transition-opacity ${T()===$.path?"opacity-100":"opacity-0"}`}}),Se),p(Se,()=>le($.path)),p(se,y(ee,{when:!D,get children(){var be=RP();return p(be,()=>$.path),be}}),Q),p(Q,y(ee,{get when(){return E()},get children(){var be=OP();return p(be,()=>t("opencodeBinarySelector.versionLabel",{version:E()})),be}}),null),p(Q,y(ee,{get when(){return K($.path)},get children(){var be=Rg();return p(be,()=>t("opencodeBinarySelector.status.checking")),be}}),null),p(Q,y(ee,{get when(){return!D&&$.lastUsed},get children(){var be=Rg();return p(be,()=>G($.lastUsed)),be}}),null),p(Q,y(ee,{when:D,get children(){var be=Rg();return p(be,()=>t("opencodeBinarySelector.badge.systemPath")),be}}),null),p(Z,y(ee,{when:!D,get children(){var be=LP();return be.$$click=Ve=>U($.path,Ve),p(be,y(af,{class:"w-3.5 h-3.5"})),de(Ve=>{var He=e.disabled,re=t("opencodeBinarySelector.actions.removeTitle");return He!==Ve.e&&(be.disabled=Ve.e=He),re!==Ve.t&&me(be,"title",Ve.t=re),Ve},{e:void 0,t:void 0}),be}}),null),de(be=>{var Ve=T()===$.path,He=e.disabled;return Ve!==be.e&&Z.classList.toggle("panel-list-item-highlight",be.e=Ve),He!==be.t&&(B.disabled=be.t=He),be},{e:void 0,t:void 0}),Z})()}})),de($=>{var D=e.disabled,E=t("opencodeBinarySelector.customPath.placeholder",{name:"opencode2"}),Z=e.disabled||!a().trim(),B=e.disabled;return D!==$.e&&(Ae.disabled=$.e=D),E!==$.t&&me(Ae,"placeholder",$.t=E),Z!==$.a&&(Ge.disabled=$.a=Z),B!==$.o&&(H.disabled=$.o=B),$},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>Ae.value=a()),M})(),y(SP,{get open(){return S()},mode:"files",get title(){return t("opencodeBinarySelector.dialog.title")},get description(){return t("opencodeBinarySelector.dialog.description")},onClose:()=>b(!1),onSelect:ne})]};Xt(["input","keydown","click"]);var UP=O('<div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server">');function nx(){const{t:e}=Dt(),{serverSettings:t,updateLastUsedBinary:n}=Un();return(()=>{var s=UP(),r=s.firstChild,o=r.firstChild,a=o.firstChild,i=a.firstChild,c=i.nextSibling,l=o.nextSibling;return p(o,y(Kp,{class:"settings-card-heading-icon"}),a),p(i,()=>e("settings.opencode.runtime.title")),p(c,()=>e("settings.opencode.runtime.subtitle")),p(l,()=>e("settings.scope.server")),p(s,y(BP,{get selectedBinary(){return t().opencodeBinary||"opencode2"},get defaultVersion(){var d;return Ee(()=>{var u;return!!((u=ur())!=null&&u.installationSource)})()?((d=ur())==null?void 0:d.currentVersion)??void 0:void 0},onBinaryChange:n,get disabled(){return mo()},isVisible:!0}),null),s})()}var KP=O('<div class="fixed bottom-4 right-4 z-50 border border-base bg-surface-secondary p-3"role=status><button class=selector-button>'),VP=O("<header class=window-header>"),jP=O("<div class=window-body>"),qP=O('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');function zP(e={}){const{t}=Dt(),{serverSettings:n}=Un();Ze(()=>{n().opencodeBinary,aa(Gk)}),Ze(()=>{vn.getStatuses(),aa(()=>{document.hidden||Fs()})});let s="";return Ze(()=>{if(e.automatic===!1)return;const r=ur();if(!r||!Uh(r)){s="";return}const o=`${r.binaryPath}:${r.state}:${r.daemonVersion??""}`;s!==o&&(s=o,la(!0))}),Ys(()=>{const r=()=>{document.hidden||Fs()};window.addEventListener("focus",r),document.addEventListener("visibilitychange",r),dt(()=>{window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",r)})}),[y(ee,{get when(){return Ee(()=>!!(e.automatic!==!1&&Uh()))()&&!Rh()},get children(){return y(Mp,{get children(){var r=KP(),o=r.firstChild;return o.$$click=()=>Bp(),p(o,()=>t("settings.opencode.setup.required")),r}})}}),y(Ot,{get open(){return Rh()},onOpenChange:la,get children(){return y(Ot.Portal,{get children(){return[y(Ot.Overlay,{class:"modal-overlay"}),(()=>{var r=qP();return p(r,y(Ot.Content,{class:"modal-surface w-full max-w-2xl max-h-[85vh] overflow-auto",get children(){return[(()=>{var o=VP();return p(o,y(Ot.Title,{class:"window-title",get children(){return t("settings.opencode.setup.required")}}),null),p(o,y(Ot.CloseButton,{class:"window-action",get"aria-label"(){return t("app.launchError.close")},get children(){return t("app.launchError.close")}}),null),o})(),(()=>{var o=jP();return p(o,y(Zk,{get children(){return y(nx,{})}})),o})()]}})),r})()]}})}})]}Xt(["click"]);function sx(e){let t=e.startIndex??0;const n=e.startLevel??0,s=[],r=c=>{if(c==null)return"";const l=e.getKey??"key",d=Li(l)?c[l]:l(c);return d!=null?String(d):""},o=c=>{if(c==null)return"";const l=e.getTextValue??"textValue",d=Li(l)?c[l]:l(c);return d!=null?String(d):""},a=c=>{if(c==null)return!1;const l=e.getDisabled??"disabled";return(Li(l)?c[l]:l(c))??!1},i=c=>{var l;if(c!=null)return Li(e.getSectionChildren)?c[e.getSectionChildren]:(l=e.getSectionChildren)==null?void 0:l.call(e,c)};for(const c of e.dataSource){if(Li(c)||o2(c)){s.push({type:"item",rawValue:c,key:String(c),textValue:String(c),disabled:a(c),level:n,index:t}),t++;continue}if(i(c)!=null){s.push({type:"section",rawValue:c,key:"",textValue:"",disabled:!1,level:n,index:t}),t++;const l=i(c)??[];if(l.length>0){const d=sx({dataSource:l,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:t,startLevel:n+1});s.push(...d),t+=d.length}}else s.push({type:"item",rawValue:c,key:r(c),textValue:o(c),disabled:a(c),level:n,index:t}),t++}return s}function WP(e,t=[]){return Te(()=>{const n=sx({dataSource:he(e.dataSource),getKey:he(e.getKey),getTextValue:he(e.getTextValue),getDisabled:he(e.getDisabled),getSectionChildren:he(e.getSectionChildren)});for(let s=0;s<t.length;s++)t[s]();return e.factory(n)})}var HP=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),GP=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function ZP(e){if(Intl.Locale){const n=new Intl.Locale(e).maximize().script??"";return HP.has(n)}const t=e.split("-")[0];return GP.has(t)}function YP(e){return ZP(e)?"rtl":"ltr"}function rx(){let e=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:YP(e)}}var qh=rx(),yc=new Set;function gb(){qh=rx();for(const e of yc)e(qh)}function JP(){const[e,t]=R(qh),n=Te(()=>e());return Ys(()=>{yc.size===0&&window.addEventListener("languagechange",gb),yc.add(t),dt(()=>{yc.delete(t),yc.size===0&&window.removeEventListener("languagechange",gb)})}),{locale:()=>n().locale,direction:()=>n().direction}}var QP=qr();function Vp(){const e=JP();return zr(QP)||e}var Og=new Map;function jp(e){const{locale:t}=Vp(),n=Te(()=>t()+(e?Object.entries(e).sort((s,r)=>s[0]<r[0]?-1:1).join():""));return Te(()=>{const s=n();let r;return Og.has(s)&&(r=Og.get(s)),r||(r=new Intl.Collator(t(),e),Og.set(s,r)),r})}function gH(e){const t=jp({usage:"search",...e});return{startsWith:(o,a)=>{if(a.length===0)return!0;const i=o.normalize("NFC"),c=a.normalize("NFC");return t().compare(i.slice(0,c.length),c)===0},endsWith:(o,a)=>{if(a.length===0)return!0;const i=o.normalize("NFC"),c=a.normalize("NFC");return t().compare(i.slice(-c.length),c)===0},contains:(o,a)=>{if(a.length===0)return!0;const i=o.normalize("NFC"),c=a.normalize("NFC");let l=0;const d=a.length;for(;l+d<=i.length;l++){const u=i.slice(l,l+d);if(t().compare(c,u)===0)return!0}return!1}}}var sr=class ox extends Set{constructor(n,s,r){super(n);ae(this,"anchorKey");ae(this,"currentKey");n instanceof ox?(this.anchorKey=s||n.anchorKey,this.currentKey=r||n.currentKey):(this.anchorKey=s,this.currentKey=r)}};function XP(e){const[t,n]=Np(e);return[()=>t()??new sr,n]}function ix(e){return d2()?e.altKey:e.ctrlKey}function Ni(e){return pl()?e.metaKey:e.ctrlKey}function hb(e){return new sr(e)}function ax(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function eI(e){const t=Kt({selectionMode:"none",selectionBehavior:"toggle"},e),[n,s]=R(!1),[r,o]=R(),a=Te(()=>{const w=he(t.selectedKeys);return w!=null?hb(w):w}),i=Te(()=>{const w=he(t.defaultSelectedKeys);return w!=null?hb(w):new sr}),[c,l]=XP({value:a,defaultValue:i,onChange:w=>{var S;return(S=t.onSelectionChange)==null?void 0:S.call(t,w)}}),[d,u]=R(he(t.selectionBehavior)),f=()=>he(t.selectionMode),g=()=>he(t.disallowEmptySelection)??!1,m=w=>{(he(t.allowDuplicateSelectionEvents)||!ax(w,c()))&&l(w)};return Ze(()=>{const w=c();he(t.selectionBehavior)==="replace"&&d()==="toggle"&&typeof w=="object"&&w.size===0&&u("replace")}),Ze(()=>{u(he(t.selectionBehavior)??"toggle")}),{selectionMode:f,disallowEmptySelection:g,selectionBehavior:d,setSelectionBehavior:u,isFocused:n,setFocused:s,focusedKey:r,setFocusedKey:o,selectedKeys:c,setSelectedKeys:m}}function cx(e){const[t,n]=R(""),[s,r]=R(-1);return{typeSelectHandlers:{onKeyDown:a=>{var f;if(he(e.isDisabled))return;const i=he(e.keyboardDelegate),c=he(e.selectionManager);if(!i.getKeyForSearch)return;const l=tI(a.key);if(!l||a.ctrlKey||a.metaKey)return;l===" "&&t().trim().length>0&&(a.preventDefault(),a.stopPropagation());let d=n(g=>g+l),u=i.getKeyForSearch(d,c.focusedKey())??i.getKeyForSearch(d);u==null&&nI(d)&&(d=d[0],u=i.getKeyForSearch(d,c.focusedKey())??i.getKeyForSearch(d)),u!=null&&(c.setFocusedKey(u),(f=e.onTypeSelect)==null||f.call(e,u)),clearTimeout(s()),r(window.setTimeout(()=>n(""),500))}}}}function tI(e){return e.length===1||!/^[A-Z]/i.test(e)?e:""}function nI(e){return e.split("").every(t=>t===e[0])}function sI(e,t,n){const r=_e({selectOnFocus:()=>he(e.selectionManager).selectionBehavior()==="replace"},e),o=()=>(n==null?void 0:n())??t(),{direction:a}=Vp();let i={top:0,left:0};t2(()=>he(r.isVirtualized)?void 0:o(),"scroll",()=>{const S=o();S&&(i={top:S.scrollTop,left:S.scrollLeft})});const{typeSelectHandlers:c}=cx({isDisabled:()=>he(r.disallowTypeAhead),keyboardDelegate:()=>he(r.keyboardDelegate),selectionManager:()=>he(r.selectionManager)}),l=()=>he(r.orientation)??"vertical",d=S=>{var I,j,ne,W,q,U,G,le;on(S,c.onKeyDown),S.altKey&&S.key==="Tab"&&S.preventDefault();const b=t();if(!(b!=null&&b.contains(S.target)))return;const v=he(r.selectionManager),k=he(r.selectOnFocus),C=K=>{K!=null&&(v.setFocusedKey(K),S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(K):k&&!ix(S)&&v.replaceSelection(K))},_=he(r.keyboardDelegate),T=he(r.shouldFocusWrap),P=v.focusedKey();switch(S.key){case(l()==="vertical"?"ArrowDown":"ArrowRight"):{if(_.getKeyBelow){S.preventDefault();let K;P!=null?K=_.getKeyBelow(P):K=(I=_.getFirstKey)==null?void 0:I.call(_),K==null&&T&&(K=(j=_.getFirstKey)==null?void 0:j.call(_,P)),C(K)}break}case(l()==="vertical"?"ArrowUp":"ArrowLeft"):{if(_.getKeyAbove){S.preventDefault();let K;P!=null?K=_.getKeyAbove(P):K=(ne=_.getLastKey)==null?void 0:ne.call(_),K==null&&T&&(K=(W=_.getLastKey)==null?void 0:W.call(_,P)),C(K)}break}case(l()==="vertical"?"ArrowLeft":"ArrowUp"):{if(_.getKeyLeftOf){S.preventDefault();const K=a()==="rtl";let M;P!=null?M=_.getKeyLeftOf(P):M=K?(q=_.getFirstKey)==null?void 0:q.call(_):(U=_.getLastKey)==null?void 0:U.call(_),C(M)}break}case(l()==="vertical"?"ArrowRight":"ArrowDown"):{if(_.getKeyRightOf){S.preventDefault();const K=a()==="rtl";let M;P!=null?M=_.getKeyRightOf(P):M=K?(G=_.getLastKey)==null?void 0:G.call(_):(le=_.getFirstKey)==null?void 0:le.call(_),C(M)}break}case"Home":if(_.getFirstKey){S.preventDefault();const K=_.getFirstKey(P,Ni(S));K!=null&&(v.setFocusedKey(K),Ni(S)&&S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(K):k&&v.replaceSelection(K))}break;case"End":if(_.getLastKey){S.preventDefault();const K=_.getLastKey(P,Ni(S));K!=null&&(v.setFocusedKey(K),Ni(S)&&S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(K):k&&v.replaceSelection(K))}break;case"PageDown":if(_.getKeyPageBelow&&P!=null){S.preventDefault();const K=_.getKeyPageBelow(P);C(K)}break;case"PageUp":if(_.getKeyPageAbove&&P!=null){S.preventDefault();const K=_.getKeyPageAbove(P);C(K)}break;case"a":Ni(S)&&v.selectionMode()==="multiple"&&he(r.disallowSelectAll)!==!0&&(S.preventDefault(),v.selectAll());break;case"Escape":S.defaultPrevented||(S.preventDefault(),he(r.disallowEmptySelection)||v.clearSelection());break;case"Tab":if(!he(r.allowsTabNavigation)){if(S.shiftKey)b.focus();else{const K=k2(b,{tabbable:!0});let M,N;do N=K.lastChild(),N&&(M=N);while(N);M&&!M.contains(document.activeElement)&&On(M)}break}}},u=S=>{var C,_;const b=he(r.selectionManager),v=he(r.keyboardDelegate),k=he(r.selectOnFocus);if(b.isFocused()){S.currentTarget.contains(S.target)||b.setFocused(!1);return}if(S.currentTarget.contains(S.target)){if(b.setFocused(!0),b.focusedKey()==null){const T=I=>{I!=null&&(b.setFocusedKey(I),k&&b.replaceSelection(I))},P=S.relatedTarget;P&&S.currentTarget.compareDocumentPosition(P)&Node.DOCUMENT_POSITION_FOLLOWING?T(b.lastSelectedKey()??((C=v.getLastKey)==null?void 0:C.call(v))):T(b.firstSelectedKey()??((_=v.getFirstKey)==null?void 0:_.call(v)))}else if(!he(r.isVirtualized)){const T=o();if(T){T.scrollTop=i.top,T.scrollLeft=i.left;const P=T.querySelector(`[data-key="${b.focusedKey()}"]`);P&&(On(P),Ah(T,P))}}}},f=S=>{const b=he(r.selectionManager);S.currentTarget.contains(S.relatedTarget)||b.setFocused(!1)},g=S=>{o()===S.target&&S.preventDefault()},m=()=>{var T,P;const S=he(r.autoFocus);if(!S)return;const b=he(r.selectionManager),v=he(r.keyboardDelegate);let k;S==="first"&&(k=(T=v.getFirstKey)==null?void 0:T.call(v)),S==="last"&&(k=(P=v.getLastKey)==null?void 0:P.call(v));const C=b.selectedKeys();C.size&&(k=C.values().next().value),b.setFocused(!0),b.setFocusedKey(k);const _=t();_&&k==null&&!he(r.shouldUseVirtualFocus)&&On(_)};return Ys(()=>{r.deferAutoFocus?setTimeout(m,0):m()}),Ze(yi([o,()=>he(r.isVirtualized),()=>he(r.selectionManager).focusedKey()],S=>{var C;const[b,v,k]=S;if(v)k&&((C=r.scrollToKey)==null||C.call(r,k));else if(k&&b){const _=b.querySelector(`[data-key="${k}"]`);_&&Ah(b,_)}})),{tabIndex:Te(()=>{if(!he(r.shouldUseVirtualFocus))return he(r.selectionManager).focusedKey()==null?0:-1}),onKeyDown:d,onMouseDown:g,onFocusIn:u,onFocusOut:f}}function rI(e,t){const n=()=>he(e.selectionManager),s=()=>he(e.key),r=()=>he(e.shouldUseVirtualFocus),o=v=>{n().selectionMode()!=="none"&&(n().selectionMode()==="single"?n().isSelected(s())&&!n().disallowEmptySelection()?n().toggleSelection(s()):n().replaceSelection(s()):v!=null&&v.shiftKey?n().extendSelection(s()):n().selectionBehavior()==="toggle"||Ni(v)||"pointerType"in v&&v.pointerType==="touch"?n().toggleSelection(s()):n().replaceSelection(s()))},a=()=>n().isSelected(s()),i=()=>he(e.disabled)||n().isDisabled(s()),c=()=>!i()&&n().canSelectItem(s());let l=null;const d=v=>{c()&&(l=v.pointerType,v.pointerType==="mouse"&&v.button===0&&!he(e.shouldSelectOnPressUp)&&o(v))},u=v=>{c()&&v.pointerType==="mouse"&&v.button===0&&he(e.shouldSelectOnPressUp)&&he(e.allowsDifferentPressOrigin)&&o(v)},f=v=>{c()&&(he(e.shouldSelectOnPressUp)&&!he(e.allowsDifferentPressOrigin)||l!=="mouse")&&o(v)},g=v=>{!c()||!["Enter"," "].includes(v.key)||(ix(v)?n().toggleSelection(s()):o(v))},m=v=>{i()&&v.preventDefault()},w=v=>{const k=t();r()||i()||!k||v.target===k&&n().setFocusedKey(s())},S=Te(()=>{if(!(r()||i()))return s()===n().focusedKey()?0:-1}),b=Te(()=>he(e.virtualized)?void 0:s());return Ze(yi([t,s,r,()=>n().focusedKey(),()=>n().isFocused()],([v,k,C,_,T])=>{v&&k===_&&T&&!C&&document.activeElement!==v&&(e.focus?e.focus():On(v))})),{isSelected:a,isDisabled:i,allowsSelection:c,tabIndex:S,dataKey:b,onPointerDown:d,onPointerUp:u,onClick:f,onKeyDown:g,onMouseDown:m,onFocus:w}}var oI=class{constructor(e,t){ae(this,"collection");ae(this,"state");this.collection=e,this.state=t}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(e==null||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if(this.state.selectionMode()==="none")return!1;const t=this.getKey(e);return t==null?!1:this.state.selectedKeys().has(t)}isEmpty(){return this.state.selectedKeys().size===0}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every(t=>e.has(t))}firstSelectedKey(){let e;for(const t of this.state.selectedKeys()){const n=this.collection().getItem(t),s=(n==null?void 0:n.index)!=null&&(e==null?void 0:e.index)!=null&&n.index<e.index;(!e||s)&&(e=n)}return e==null?void 0:e.key}lastSelectedKey(){let e;for(const t of this.state.selectedKeys()){const n=this.collection().getItem(t),s=(n==null?void 0:n.index)!=null&&(e==null?void 0:e.index)!=null&&n.index>e.index;(!e||s)&&(e=n)}return e==null?void 0:e.key}extendSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"){this.replaceSelection(e);return}const t=this.getKey(e);if(t==null)return;const n=this.state.selectedKeys(),s=n.anchorKey||t,r=new sr(n,s,t);for(const o of this.getKeyRange(s,n.currentKey||t))r.delete(o);for(const o of this.getKeyRange(t,s))this.canSelectItem(o)&&r.add(o);this.state.setSelectedKeys(r)}getKeyRange(e,t){const n=this.collection().getItem(e),s=this.collection().getItem(t);return n&&s?n.index!=null&&s.index!=null&&n.index<=s.index?this.getKeyRangeInternal(e,t):this.getKeyRangeInternal(t,e):[]}getKeyRangeInternal(e,t){const n=[];let s=e;for(;s!=null;){const r=this.collection().getItem(s);if(r&&r.type==="item"&&n.push(s),s===t)return n;s=this.collection().getKeyAfter(s)}return[]}getKey(e){const t=this.collection().getItem(e);return t?!t||t.type!=="item"?null:t.key:e}toggleSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"&&!this.isSelected(e)){this.replaceSelection(e);return}const t=this.getKey(e);if(t==null)return;const n=new sr(this.state.selectedKeys());n.has(t)?n.delete(t):this.canSelectItem(t)&&(n.add(t),n.anchorKey=t,n.currentKey=t),!(this.disallowEmptySelection()&&n.size===0)&&this.state.setSelectedKeys(n)}replaceSelection(e){if(this.selectionMode()==="none")return;const t=this.getKey(e);if(t==null)return;const n=this.canSelectItem(t)?new sr([t],t,t):new sr;this.state.setSelectedKeys(n)}setSelectedKeys(e){if(this.selectionMode()==="none")return;const t=new sr;for(const n of e){const s=this.getKey(n);if(s!=null&&(t.add(s),this.selectionMode()==="single"))break}this.state.setSelectedKeys(t)}selectAll(){this.selectionMode()==="multiple"&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new sr)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,t){this.selectionMode()!=="none"&&(this.selectionMode()==="single"?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):this.selectionBehavior()==="toggle"||t&&t.pointerType==="touch"?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const t=this.selectedKeys();if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;for(const n of t)if(!e.has(n))return!1;return!0}canSelectItem(e){if(this.state.selectionMode()==="none")return!1;const t=this.collection().getItem(e);return t!=null&&!t.disabled}isDisabled(e){const t=this.collection().getItem(e);return!t||t.disabled}getAllSelectableKeys(){const e=[];return(n=>{for(;n!=null;){if(this.canSelectItem(n)){const s=this.collection().getItem(n);if(!s)continue;s.type==="item"&&e.push(n)}n=this.collection().getKeyAfter(n)}})(this.collection().getFirstKey()),e}},mb=class{constructor(e){ae(this,"keyMap",new Map);ae(this,"iterable");ae(this,"firstKey");ae(this,"lastKey");this.iterable=e;for(const s of e)this.keyMap.set(s.key,s);if(this.keyMap.size===0)return;let t,n=0;for(const[s,r]of this.keyMap)t?(t.nextKey=s,r.prevKey=t.key):(this.firstKey=s,r.prevKey=void 0),r.type==="item"&&(r.index=n++),t=r,t.nextKey=void 0;this.lastKey=t.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){var t;return(t=this.keyMap.get(e))==null?void 0:t.prevKey}getKeyAfter(e){var t;return(t=this.keyMap.get(e))==null?void 0:t.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const t=[...this.getKeys()];return this.getItem(t[e])}};function lx(e){const t=eI(e),s=WP({dataSource:()=>he(e.dataSource),getKey:()=>he(e.getKey),getTextValue:()=>he(e.getTextValue),getDisabled:()=>he(e.getDisabled),getSectionChildren:()=>he(e.getSectionChildren),factory:o=>e.filter?new mb(e.filter(o)):new mb(o)},[()=>e.filter]),r=new oI(s,t);return fk(()=>{const o=t.focusedKey();o!=null&&!s().getItem(o)&&t.setFocusedKey(void 0)}),{collection:s,selectionManager:()=>r}}var dx=["id","name","validationState","required","disabled","readOnly"];function ux(e){const t=`form-control-${Do()}`,n=Kt({id:t},e),[s,r]=R(),[o,a]=R(),[i,c]=R(),[l,d]=R(),u=(w,S,b)=>{const v=b!=null||s()!=null;return[b,s(),v&&S!=null?w:void 0].filter(Boolean).join(" ")||void 0},f=w=>[i(),l(),w].filter(Boolean).join(" ")||void 0,g=Te(()=>({"data-valid":he(n.validationState)==="valid"?"":void 0,"data-invalid":he(n.validationState)==="invalid"?"":void 0,"data-required":he(n.required)?"":void 0,"data-disabled":he(n.disabled)?"":void 0,"data-readonly":he(n.readOnly)?"":void 0}));return{formControlContext:{name:()=>he(n.name)??he(n.id),dataset:g,validationState:()=>he(n.validationState),isRequired:()=>he(n.required),isDisabled:()=>he(n.disabled),isReadOnly:()=>he(n.readOnly),labelId:s,fieldId:o,descriptionId:i,errorMessageId:l,getAriaLabelledBy:u,getAriaDescribedBy:f,generateId:ja(()=>he(n.id)),registerLabel:bs(r),registerField:bs(a),registerDescription:bs(c),registerErrorMessage:bs(d)}}}var qp=qr();function pr(){const e=zr(qp);if(e===void 0)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function zp(e){const t=pr(),n=Kt({id:t.generateId("description")},e);return Ze(()=>dt(t.registerDescription(n.id))),y(en,_e({as:"div"},()=>t.dataset(),n))}var iI=O("<option>"),aI=O("<div aria-hidden=true><input type=text style=font-size:16px><select tabindex=-1><option>");function cI(e){let t;const[n,s]=Nt(e,["ref","onChange","collection","selectionManager","isOpen","isMultiple","isVirtualized","focusTrigger"]),r=pr(),[o,a]=R(!1),i=c=>{const l=n.collection.getItem(c);return y(ee,{get when(){return(l==null?void 0:l.type)==="item"},get children(){var d=iI();return d.value=c,p(d,()=>l==null?void 0:l.textValue),de(()=>d.selected=n.selectionManager.isSelected(c)),d}})};return Ze(yi(()=>n.selectionManager.selectedKeys(),(c,l)=>{l&&ax(c,l)||(a(!0),t==null||t.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t==null||t.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0})))},{defer:!0})),(()=>{var c=aI(),l=c.firstChild,d=l.nextSibling;d.firstChild,l.addEventListener("focus",()=>n.focusTrigger()),d.addEventListener("change",f=>{on(f,n.onChange),o()||n.selectionManager.setSelectedKeys(new Set([f.target.value])),a(!1)});var u=Kn(f=>t=f,n.ref);return typeof u=="function"&&dr(u,d),lr(d,_e({get multiple(){return n.isMultiple},get name(){return r.name()},get required(){return r.isRequired()},get disabled(){return r.isDisabled()},get size(){return n.collection.getSize()},get value(){return n.selectionManager.firstSelectedKey()??""}},s),!1,!0),p(d,y(ee,{get when(){return n.isVirtualized},get fallback(){return y(zt,{get each(){return[...n.collection.getKeys()]},children:i})},get children(){return y(zt,{get each(){return[...n.selectionManager.selectedKeys()]},children:i})}}),null),de(f=>{var g=nf,m=n.selectionManager.isFocused()||n.isOpen?-1:0,w=r.isRequired(),S=r.isDisabled(),b=r.isReadOnly();return f.e=kr(c,g,f.e),m!==f.t&&me(l,"tabindex",f.t=m),w!==f.a&&(l.required=f.a=w),S!==f.o&&(l.disabled=f.o=S),b!==f.i&&(l.readOnly=f.i=b),f},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),c})()}var pb=new WeakMap;function lI(e){let t=pb.get(e);if(t!=null)return t;t=0;for(const n of e)n.type==="item"&&t++;return pb.set(e,t),t}var fx=class{constructor(e,t,n){ae(this,"collection");ae(this,"ref");ae(this,"collator");this.collection=e,this.ref=t,this.collator=n}getKeyBelow(e){let t=this.collection().getKeyAfter(e);for(;t!=null;){const n=this.collection().getItem(t);if(n&&n.type==="item"&&!n.disabled)return t;t=this.collection().getKeyAfter(t)}}getKeyAbove(e){let t=this.collection().getKeyBefore(e);for(;t!=null;){const n=this.collection().getItem(t);if(n&&n.type==="item"&&!n.disabled)return t;t=this.collection().getKeyBefore(t)}}getFirstKey(){let e=this.collection().getFirstKey();for(;e!=null;){const t=this.collection().getItem(e);if(t&&t.type==="item"&&!t.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;e!=null;){const t=this.collection().getItem(e);if(t&&t.type==="item"&&!t.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){var t,n;return((n=(t=this.ref)==null?void 0:t.call(this))==null?void 0:n.querySelector(`[data-key="${e}"]`))??null}getKeyPageAbove(e){var o;const t=(o=this.ref)==null?void 0:o.call(this);let n=this.getItem(e);if(!t||!n)return;const s=Math.max(0,n.offsetTop+n.offsetHeight-t.offsetHeight);let r=e;for(;r&&n&&n.offsetTop>s;)r=this.getKeyAbove(r),n=r!=null?this.getItem(r):null;return r}getKeyPageBelow(e){var o;const t=(o=this.ref)==null?void 0:o.call(this);let n=this.getItem(e);if(!t||!n)return;const s=Math.min(t.scrollHeight,n.offsetTop-n.offsetHeight+t.offsetHeight);let r=e;for(;r&&n&&n.offsetTop<s;)r=this.getKeyBelow(r),n=r!=null?this.getItem(r):null;return r}getKeyForSearch(e,t){var r;const n=(r=this.collator)==null?void 0:r.call(this);if(!n)return;let s=t!=null?this.getKeyBelow(t):this.getFirstKey();for(;s!=null;){const o=this.collection().getItem(s);if(o){const a=o.textValue.slice(0,e.length);if(o.textValue&&n.compare(a,e)===0)return s}s=this.getKeyBelow(s)}}};function dI(e,t,n){const s=jp({usage:"search",sensitivity:"base"}),r=Te(()=>{const o=he(e.keyboardDelegate);return o||new fx(e.collection,t,s)});return sI({selectionManager:()=>he(e.selectionManager),keyboardDelegate:r,autoFocus:()=>he(e.autoFocus),deferAutoFocus:()=>he(e.deferAutoFocus),shouldFocusWrap:()=>he(e.shouldFocusWrap),disallowEmptySelection:()=>he(e.disallowEmptySelection),selectOnFocus:()=>he(e.selectOnFocus),disallowTypeAhead:()=>he(e.disallowTypeAhead),shouldUseVirtualFocus:()=>he(e.shouldUseVirtualFocus),allowsTabNavigation:()=>he(e.allowsTabNavigation),isVirtualized:()=>he(e.isVirtualized),scrollToKey:o=>{var a;return(a=he(e.scrollToKey))==null?void 0:a(o)},orientation:()=>he(e.orientation)},t,n)}var uI={};yl(uI,{Item:()=>cf,ItemDescription:()=>lf,ItemIndicator:()=>df,ItemLabel:()=>uf,Listbox:()=>fI,Root:()=>Hp,Section:()=>ff,useListboxContext:()=>hx});var gx=qr();function hx(){const e=zr(gx);if(e===void 0)throw new Error("[kobalte]: `useListboxContext` must be used within a `Listbox` component");return e}var mx=qr();function Wp(){const e=zr(mx);if(e===void 0)throw new Error("[kobalte]: `useListboxItemContext` must be used within a `Listbox.Item` component");return e}function cf(e){let t;const n=hx(),s=`${n.generateId("item")}-${Do()}`,r=Kt({id:s},e),[o,a]=Nt(r,["ref","item","aria-label","aria-labelledby","aria-describedby","onPointerMove","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[i,c]=R(),[l,d]=R(),u=()=>n.listState().selectionManager(),f=()=>u().focusedKey()===o.item.key,g=rI({key:()=>o.item.key,selectionManager:u,shouldSelectOnPressUp:n.shouldSelectOnPressUp,allowsDifferentPressOrigin:()=>n.shouldSelectOnPressUp()&&n.shouldFocusOnHover(),shouldUseVirtualFocus:n.shouldUseVirtualFocus,disabled:()=>o.item.disabled},()=>t),m=()=>{if(u().selectionMode()!=="none")return g.isSelected()},w=Te(()=>!(pl()&&u2())),S=()=>w()?o["aria-label"]:void 0,b=()=>w()?i():void 0,v=()=>w()?l():void 0,k=()=>{var j;if(!n.isVirtualized())return;const I=(j=n.listState().collection().getItem(o.item.key))==null?void 0:j.index;return I!=null?I+1:void 0},C=()=>{if(n.isVirtualized())return lI(n.listState().collection())},_=I=>{on(I,o.onPointerMove),I.pointerType==="mouse"&&!g.isDisabled()&&n.shouldFocusOnHover()&&(On(I.currentTarget),u().setFocused(!0),u().setFocusedKey(o.item.key))},T=Te(()=>({"data-disabled":g.isDisabled()?"":void 0,"data-selected":g.isSelected()?"":void 0,"data-highlighted":f()?"":void 0})),P={isSelected:g.isSelected,dataset:T,generateId:ja(()=>a.id),registerLabelId:bs(c),registerDescriptionId:bs(d)};return y(mx.Provider,{value:P,get children(){return y(en,_e({as:"li",ref(I){var j=Kn(ne=>t=ne,o.ref);typeof j=="function"&&j(I)},role:"option",get tabIndex(){return g.tabIndex()},get"aria-disabled"(){return g.isDisabled()},get"aria-selected"(){return m()},get"aria-label"(){return S()},get"aria-labelledby"(){return b()},get"aria-describedby"(){return v()},get"aria-posinset"(){return k()},get"aria-setsize"(){return C()},get"data-key"(){return g.dataKey()},get onPointerDown(){return vs([o.onPointerDown,g.onPointerDown])},get onPointerUp(){return vs([o.onPointerUp,g.onPointerUp])},get onClick(){return vs([o.onClick,g.onClick])},get onKeyDown(){return vs([o.onKeyDown,g.onKeyDown])},get onMouseDown(){return vs([o.onMouseDown,g.onMouseDown])},get onFocus(){return vs([o.onFocus,g.onFocus])},onPointerMove:_},T,a))}})}function lf(e){const t=Wp(),n=Kt({id:t.generateId("description")},e);return Ze(()=>dt(t.registerDescriptionId(n.id))),y(en,_e({as:"div"},()=>t.dataset(),n))}function df(e){const t=Wp(),n=Kt({id:t.generateId("indicator")},e),[s,r]=Nt(n,["forceMount"]);return y(ee,{get when(){return s.forceMount||t.isSelected()},get children(){return y(en,_e({as:"div","aria-hidden":"true"},()=>t.dataset(),r))}})}function uf(e){const t=Wp(),n=Kt({id:t.generateId("label")},e);return Ze(()=>dt(t.registerLabelId(n.id))),y(en,_e({as:"div"},()=>t.dataset(),n))}function Hp(e){let t;const n=`listbox-${Do()}`,s=Kt({id:n,selectionMode:"single",virtualized:!1},e),[r,o]=Nt(s,["ref","children","renderItem","renderSection","value","defaultValue","onChange","options","optionValue","optionTextValue","optionDisabled","optionGroupChildren","state","keyboardDelegate","autoFocus","selectionMode","shouldFocusWrap","shouldUseVirtualFocus","shouldSelectOnPressUp","shouldFocusOnHover","allowDuplicateSelectionEvents","disallowEmptySelection","selectionBehavior","selectOnFocus","disallowTypeAhead","allowsTabNavigation","virtualized","scrollToItem","scrollRef","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]),a=Te(()=>r.state?r.state:lx({selectedKeys:()=>r.value,defaultSelectedKeys:()=>r.defaultValue,onSelectionChange:r.onChange,allowDuplicateSelectionEvents:()=>he(r.allowDuplicateSelectionEvents),disallowEmptySelection:()=>he(r.disallowEmptySelection),selectionBehavior:()=>he(r.selectionBehavior),selectionMode:()=>he(r.selectionMode),dataSource:()=>r.options??[],getKey:()=>r.optionValue,getTextValue:()=>r.optionTextValue,getDisabled:()=>r.optionDisabled,getSectionChildren:()=>r.optionGroupChildren})),i=dI({selectionManager:()=>a().selectionManager(),collection:()=>a().collection(),autoFocus:()=>he(r.autoFocus),shouldFocusWrap:()=>he(r.shouldFocusWrap),keyboardDelegate:()=>r.keyboardDelegate,disallowEmptySelection:()=>he(r.disallowEmptySelection),selectOnFocus:()=>he(r.selectOnFocus),disallowTypeAhead:()=>he(r.disallowTypeAhead),shouldUseVirtualFocus:()=>he(r.shouldUseVirtualFocus),allowsTabNavigation:()=>he(r.allowsTabNavigation),isVirtualized:()=>r.virtualized,scrollToKey:()=>r.scrollToItem},()=>t,()=>{var l;return(l=r.scrollRef)==null?void 0:l.call(r)}),c={listState:a,generateId:ja(()=>o.id),shouldUseVirtualFocus:()=>s.shouldUseVirtualFocus,shouldSelectOnPressUp:()=>s.shouldSelectOnPressUp,shouldFocusOnHover:()=>s.shouldFocusOnHover,isVirtualized:()=>r.virtualized};return y(gx.Provider,{value:c,get children(){return y(en,_e({as:"ul",ref(l){var d=Kn(u=>t=u,r.ref);typeof d=="function"&&d(l)},role:"listbox",get tabIndex(){return i.tabIndex()},get"aria-multiselectable"(){return a().selectionManager().selectionMode()==="multiple"?!0:void 0},get onKeyDown(){return vs([r.onKeyDown,i.onKeyDown])},get onMouseDown(){return vs([r.onMouseDown,i.onMouseDown])},get onFocusIn(){return vs([r.onFocusIn,i.onFocusIn])},get onFocusOut(){return vs([r.onFocusOut,i.onFocusOut])}},o,{get children(){return y(ee,{get when(){return!r.virtualized},get fallback(){var l;return(l=r.children)==null?void 0:l.call(r,a().collection)},get children(){return y(s2,{get each(){return[...a().collection()]},by:"key",children:l=>y(uk,{get children(){return[y(Ki,{get when(){return l().type==="section"},get children(){var d;return(d=r.renderSection)==null?void 0:d.call(r,l())}}),y(Ki,{get when(){return l().type==="item"},get children(){var d;return(d=r.renderItem)==null?void 0:d.call(r,l())}})]}})})}})}}))}})}function ff(e){return y(en,_e({as:"li",role:"presentation"},e))}var fI=Object.assign(Hp,{Item:cf,ItemDescription:lf,ItemIndicator:df,ItemLabel:uf,Section:ff});const gI=["top","right","bottom","left"],po=Math.min,rs=Math.max,Yd=Math.round,sd=Math.floor,ir=e=>({x:e,y:e}),hI={left:"right",right:"left",bottom:"top",top:"bottom"},mI={start:"end",end:"start"};function zh(e,t,n){return rs(e,po(t,n))}function vi(e,t){return typeof e=="function"?e(t):e}function yo(e){return e.split("-")[0]}function qa(e){return e.split("-")[1]}function px(e){return e==="x"?"y":"x"}function Gp(e){return e==="y"?"height":"width"}const pI=new Set(["top","bottom"]);function Mr(e){return pI.has(yo(e))?"y":"x"}function Zp(e){return px(Mr(e))}function yI(e,t,n){n===void 0&&(n=!1);const s=qa(e),r=Zp(e),o=Gp(r);let a=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Jd(a)),[a,Jd(a)]}function vI(e){const t=Jd(e);return[Wh(e),t,Wh(t)]}function Wh(e){return e.replace(/start|end/g,t=>mI[t])}const yb=["left","right"],vb=["right","left"],wI=["top","bottom"],bI=["bottom","top"];function SI(e,t,n){switch(e){case"top":case"bottom":return n?t?vb:yb:t?yb:vb;case"left":case"right":return t?wI:bI;default:return[]}}function kI(e,t,n,s){const r=qa(e);let o=SI(yo(e),n==="start",s);return r&&(o=o.map(a=>a+"-"+r),t&&(o=o.concat(o.map(Wh)))),o}function Jd(e){return e.replace(/left|right|bottom|top/g,t=>hI[t])}function xI(e){return{top:0,right:0,bottom:0,left:0,...e}}function yx(e){return typeof e!="number"?xI(e):{top:e,right:e,bottom:e,left:e}}function Qd(e){const{x:t,y:n,width:s,height:r}=e;return{width:s,height:r,top:n,left:t,right:t+s,bottom:n+r,x:t,y:n}}function wb(e,t,n){let{reference:s,floating:r}=e;const o=Mr(t),a=Zp(t),i=Gp(a),c=yo(t),l=o==="y",d=s.x+s.width/2-r.width/2,u=s.y+s.height/2-r.height/2,f=s[i]/2-r[i]/2;let g;switch(c){case"top":g={x:d,y:s.y-r.height};break;case"bottom":g={x:d,y:s.y+s.height};break;case"right":g={x:s.x+s.width,y:u};break;case"left":g={x:s.x-r.width,y:u};break;default:g={x:s.x,y:s.y}}switch(qa(t)){case"start":g[a]-=f*(n&&l?-1:1);break;case"end":g[a]+=f*(n&&l?-1:1);break}return g}const _I=async(e,t,n)=>{const{placement:s="bottom",strategy:r="absolute",middleware:o=[],platform:a}=n,i=o.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(t));let l=await a.getElementRects({reference:e,floating:t,strategy:r}),{x:d,y:u}=wb(l,s,c),f=s,g={},m=0;for(let w=0;w<i.length;w++){const{name:S,fn:b}=i[w],{x:v,y:k,data:C,reset:_}=await b({x:d,y:u,initialPlacement:s,placement:f,strategy:r,middlewareData:g,rects:l,platform:a,elements:{reference:e,floating:t}});d=v??d,u=k??u,g={...g,[S]:{...g[S],...C}},_&&m<=50&&(m++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(l=_.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:d,y:u}=wb(l,f,c)),w=-1)}return{x:d,y:u,placement:f,strategy:r,middlewareData:g}};async function qc(e,t){var n;t===void 0&&(t={});const{x:s,y:r,platform:o,rects:a,elements:i,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:f=!1,padding:g=0}=vi(t,e),m=yx(g),S=i[f?u==="floating"?"reference":"floating":u],b=Qd(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(S)))==null||n?S:S.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(i.floating)),boundary:l,rootBoundary:d,strategy:c})),v=u==="floating"?{x:s,y:r,width:a.floating.width,height:a.floating.height}:a.reference,k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(i.floating)),C=await(o.isElement==null?void 0:o.isElement(k))?await(o.getScale==null?void 0:o.getScale(k))||{x:1,y:1}:{x:1,y:1},_=Qd(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:v,offsetParent:k,strategy:c}):v);return{top:(b.top-_.top+m.top)/C.y,bottom:(_.bottom-b.bottom+m.bottom)/C.y,left:(b.left-_.left+m.left)/C.x,right:(_.right-b.right+m.right)/C.x}}const $I=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:r,rects:o,platform:a,elements:i,middlewareData:c}=t,{element:l,padding:d=0}=vi(e,t)||{};if(l==null)return{};const u=yx(d),f={x:n,y:s},g=Zp(r),m=Gp(g),w=await a.getDimensions(l),S=g==="y",b=S?"top":"left",v=S?"bottom":"right",k=S?"clientHeight":"clientWidth",C=o.reference[m]+o.reference[g]-f[g]-o.floating[m],_=f[g]-o.reference[g],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l));let P=T?T[k]:0;(!P||!await(a.isElement==null?void 0:a.isElement(T)))&&(P=i.floating[k]||o.floating[m]);const I=C/2-_/2,j=P/2-w[m]/2-1,ne=po(u[b],j),W=po(u[v],j),q=ne,U=P-w[m]-W,G=P/2-w[m]/2+I,le=zh(q,G,U),K=!c.arrow&&qa(r)!=null&&G!==le&&o.reference[m]/2-(G<q?ne:W)-w[m]/2<0,M=K?G<q?G-q:G-U:0;return{[g]:f[g]+M,data:{[g]:le,centerOffset:G-le-M,...K&&{alignmentOffset:M}},reset:K}}}),CI=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:r,middlewareData:o,rects:a,initialPlacement:i,platform:c,elements:l}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:w=!0,...S}=vi(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const b=yo(r),v=Mr(i),k=yo(i)===i,C=await(c.isRTL==null?void 0:c.isRTL(l.floating)),_=f||(k||!w?[Jd(i)]:vI(i)),T=m!=="none";!f&&T&&_.push(...kI(i,w,m,C));const P=[i,..._],I=await qc(t,S),j=[];let ne=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&j.push(I[b]),u){const G=yI(r,a,C);j.push(I[G[0]],I[G[1]])}if(ne=[...ne,{placement:r,overflows:j}],!j.every(G=>G<=0)){var W,q;const G=(((W=o.flip)==null?void 0:W.index)||0)+1,le=P[G];if(le&&(!(u==="alignment"?v!==Mr(le):!1)||ne.every(N=>Mr(N.placement)===v?N.overflows[0]>0:!0)))return{data:{index:G,overflows:ne},reset:{placement:le}};let K=(q=ne.filter(M=>M.overflows[0]<=0).sort((M,N)=>M.overflows[1]-N.overflows[1])[0])==null?void 0:q.placement;if(!K)switch(g){case"bestFit":{var U;const M=(U=ne.filter(N=>{if(T){const oe=Mr(N.placement);return oe===v||oe==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(oe=>oe>0).reduce((oe,ge)=>oe+ge,0)]).sort((N,oe)=>N[1]-oe[1])[0])==null?void 0:U[0];M&&(K=M);break}case"initialPlacement":K=i;break}if(r!==K)return{reset:{placement:K}}}return{}}}};function bb(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Sb(e){return gI.some(t=>e[t]>=0)}const EI=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:s="referenceHidden",...r}=vi(e,t);switch(s){case"referenceHidden":{const o=await qc(t,{...r,elementContext:"reference"}),a=bb(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Sb(a)}}}case"escaped":{const o=await qc(t,{...r,altBoundary:!0}),a=bb(o,n.floating);return{data:{escapedOffsets:a,escaped:Sb(a)}}}default:return{}}}}},TI=new Set(["left","top"]);async function MI(e,t){const{placement:n,platform:s,elements:r}=e,o=await(s.isRTL==null?void 0:s.isRTL(r.floating)),a=yo(n),i=qa(n),c=Mr(n)==="y",l=TI.has(a)?-1:1,d=o&&c?-1:1,u=vi(t,e);let{mainAxis:f,crossAxis:g,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return i&&typeof m=="number"&&(g=i==="end"?m*-1:m),c?{x:g*d,y:f*l}:{x:f*l,y:g*d}}const AI=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:r,y:o,placement:a,middlewareData:i}=t,c=await MI(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(s=i.arrow)!=null&&s.alignmentOffset?{}:{x:r+c.x,y:o+c.y,data:{...c,placement:a}}}}},DI=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:r}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:i={fn:S=>{let{x:b,y:v}=S;return{x:b,y:v}}},...c}=vi(e,t),l={x:n,y:s},d=await qc(t,c),u=Mr(yo(r)),f=px(u);let g=l[f],m=l[u];if(o){const S=f==="y"?"top":"left",b=f==="y"?"bottom":"right",v=g+d[S],k=g-d[b];g=zh(v,g,k)}if(a){const S=u==="y"?"top":"left",b=u==="y"?"bottom":"right",v=m+d[S],k=m-d[b];m=zh(v,m,k)}const w=i.fn({...t,[f]:g,[u]:m});return{...w,data:{x:w.x-n,y:w.y-s,enabled:{[f]:o,[u]:a}}}}}},PI=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:r,rects:o,platform:a,elements:i}=t,{apply:c=()=>{},...l}=vi(e,t),d=await qc(t,l),u=yo(r),f=qa(r),g=Mr(r)==="y",{width:m,height:w}=o.floating;let S,b;u==="top"||u==="bottom"?(S=u,b=f===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(b=u,S=f==="end"?"top":"bottom");const v=w-d.top-d.bottom,k=m-d.left-d.right,C=po(w-d[S],v),_=po(m-d[b],k),T=!t.middlewareData.shift;let P=C,I=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=k),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(P=v),T&&!f){const ne=rs(d.left,0),W=rs(d.right,0),q=rs(d.top,0),U=rs(d.bottom,0);g?I=m-2*(ne!==0||W!==0?ne+W:rs(d.left,d.right)):P=w-2*(q!==0||U!==0?q+U:rs(d.top,d.bottom))}await c({...t,availableWidth:I,availableHeight:P});const j=await a.getDimensions(i.floating);return m!==j.width||w!==j.height?{reset:{rects:!0}}:{}}}};function gf(){return typeof window<"u"}function za(e){return vx(e)?(e.nodeName||"").toLowerCase():"#document"}function as(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yr(e){var t;return(t=(vx(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vx(e){return gf()?e instanceof Node||e instanceof as(e).Node:!1}function Vs(e){return gf()?e instanceof Element||e instanceof as(e).Element:!1}function gr(e){return gf()?e instanceof HTMLElement||e instanceof as(e).HTMLElement:!1}function kb(e){return!gf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof as(e).ShadowRoot}const II=new Set(["inline","contents"]);function wl(e){const{overflow:t,overflowX:n,overflowY:s,display:r}=js(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!II.has(r)}const RI=new Set(["table","td","th"]);function OI(e){return RI.has(za(e))}const LI=[":popover-open",":modal"];function hf(e){return LI.some(t=>{try{return e.matches(t)}catch{return!1}})}const NI=["transform","translate","scale","rotate","perspective"],FI=["transform","translate","scale","rotate","perspective","filter"],BI=["paint","layout","strict","content"];function Yp(e){const t=Jp(),n=Vs(e)?js(e):e;return NI.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||FI.some(s=>(n.willChange||"").includes(s))||BI.some(s=>(n.contain||"").includes(s))}function UI(e){let t=vo(e);for(;gr(t)&&!da(t);){if(Yp(t))return t;if(hf(t))return null;t=vo(t)}return null}function Jp(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const KI=new Set(["html","body","#document"]);function da(e){return KI.has(za(e))}function js(e){return as(e).getComputedStyle(e)}function mf(e){return Vs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vo(e){if(za(e)==="html")return e;const t=e.assignedSlot||e.parentNode||kb(e)&&e.host||yr(e);return kb(t)?t.host:t}function wx(e){const t=vo(e);return da(t)?e.ownerDocument?e.ownerDocument.body:e.body:gr(t)&&wl(t)?t:wx(t)}function zc(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=wx(e),o=r===((s=e.ownerDocument)==null?void 0:s.body),a=as(r);if(o){const i=Hh(a);return t.concat(a,a.visualViewport||[],wl(r)?r:[],i&&n?zc(i):[])}return t.concat(r,zc(r,[],n))}function Hh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bx(e){const t=js(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const r=gr(e),o=r?e.offsetWidth:n,a=r?e.offsetHeight:s,i=Yd(n)!==o||Yd(s)!==a;return i&&(n=o,s=a),{width:n,height:s,$:i}}function Qp(e){return Vs(e)?e:e.contextElement}function Ji(e){const t=Qp(e);if(!gr(t))return ir(1);const n=t.getBoundingClientRect(),{width:s,height:r,$:o}=bx(t);let a=(o?Yd(n.width):n.width)/s,i=(o?Yd(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const VI=ir(0);function Sx(e){const t=as(e);return!Jp()||!t.visualViewport?VI:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jI(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==as(e)?!1:t}function ni(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=Qp(e);let a=ir(1);t&&(s?Vs(s)&&(a=Ji(s)):a=Ji(e));const i=jI(o,n,s)?Sx(o):ir(0);let c=(r.left+i.x)/a.x,l=(r.top+i.y)/a.y,d=r.width/a.x,u=r.height/a.y;if(o){const f=as(o),g=s&&Vs(s)?as(s):s;let m=f,w=Hh(m);for(;w&&s&&g!==m;){const S=Ji(w),b=w.getBoundingClientRect(),v=js(w),k=b.left+(w.clientLeft+parseFloat(v.paddingLeft))*S.x,C=b.top+(w.clientTop+parseFloat(v.paddingTop))*S.y;c*=S.x,l*=S.y,d*=S.x,u*=S.y,c+=k,l+=C,m=as(w),w=Hh(m)}}return Qd({width:d,height:u,x:c,y:l})}function pf(e,t){const n=mf(e).scrollLeft;return t?t.left+n:ni(yr(e)).left+n}function kx(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-pf(e,n),r=n.top+t.scrollTop;return{x:s,y:r}}function qI(e){let{elements:t,rect:n,offsetParent:s,strategy:r}=e;const o=r==="fixed",a=yr(s),i=t?hf(t.floating):!1;if(s===a||i&&o)return n;let c={scrollLeft:0,scrollTop:0},l=ir(1);const d=ir(0),u=gr(s);if((u||!u&&!o)&&((za(s)!=="body"||wl(a))&&(c=mf(s)),gr(s))){const g=ni(s);l=Ji(s),d.x=g.x+s.clientLeft,d.y=g.y+s.clientTop}const f=a&&!u&&!o?kx(a,c):ir(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+d.x+f.x,y:n.y*l.y-c.scrollTop*l.y+d.y+f.y}}function zI(e){return Array.from(e.getClientRects())}function WI(e){const t=yr(e),n=mf(e),s=e.ownerDocument.body,r=rs(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),o=rs(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+pf(e);const i=-n.scrollTop;return js(s).direction==="rtl"&&(a+=rs(t.clientWidth,s.clientWidth)-r),{width:r,height:o,x:a,y:i}}const xb=25;function HI(e,t){const n=as(e),s=yr(e),r=n.visualViewport;let o=s.clientWidth,a=s.clientHeight,i=0,c=0;if(r){o=r.width,a=r.height;const d=Jp();(!d||d&&t==="fixed")&&(i=r.offsetLeft,c=r.offsetTop)}const l=pf(s);if(l<=0){const d=s.ownerDocument,u=d.body,f=getComputedStyle(u),g=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(s.clientWidth-u.clientWidth-g);m<=xb&&(o-=m)}else l<=xb&&(o+=l);return{width:o,height:a,x:i,y:c}}const GI=new Set(["absolute","fixed"]);function ZI(e,t){const n=ni(e,!0,t==="fixed"),s=n.top+e.clientTop,r=n.left+e.clientLeft,o=gr(e)?Ji(e):ir(1),a=e.clientWidth*o.x,i=e.clientHeight*o.y,c=r*o.x,l=s*o.y;return{width:a,height:i,x:c,y:l}}function _b(e,t,n){let s;if(t==="viewport")s=HI(e,n);else if(t==="document")s=WI(yr(e));else if(Vs(t))s=ZI(t,n);else{const r=Sx(e);s={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Qd(s)}function xx(e,t){const n=vo(e);return n===t||!Vs(n)||da(n)?!1:js(n).position==="fixed"||xx(n,t)}function YI(e,t){const n=t.get(e);if(n)return n;let s=zc(e,[],!1).filter(i=>Vs(i)&&za(i)!=="body"),r=null;const o=js(e).position==="fixed";let a=o?vo(e):e;for(;Vs(a)&&!da(a);){const i=js(a),c=Yp(a);!c&&i.position==="fixed"&&(r=null),(o?!c&&!r:!c&&i.position==="static"&&!!r&&GI.has(r.position)||wl(a)&&!c&&xx(e,a))?s=s.filter(d=>d!==a):r=i,a=vo(a)}return t.set(e,s),s}function JI(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const a=[...n==="clippingAncestors"?hf(t)?[]:YI(t,this._c):[].concat(n),s],i=a[0],c=a.reduce((l,d)=>{const u=_b(t,d,r);return l.top=rs(u.top,l.top),l.right=po(u.right,l.right),l.bottom=po(u.bottom,l.bottom),l.left=rs(u.left,l.left),l},_b(t,i,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function QI(e){const{width:t,height:n}=bx(e);return{width:t,height:n}}function XI(e,t,n){const s=gr(t),r=yr(t),o=n==="fixed",a=ni(e,!0,o,t);let i={scrollLeft:0,scrollTop:0};const c=ir(0);function l(){c.x=pf(r)}if(s||!s&&!o)if((za(t)!=="body"||wl(r))&&(i=mf(t)),s){const g=ni(t,!0,o,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else r&&l();o&&!s&&r&&l();const d=r&&!s&&!o?kx(r,i):ir(0),u=a.left+i.scrollLeft-c.x-d.x,f=a.top+i.scrollTop-c.y-d.y;return{x:u,y:f,width:a.width,height:a.height}}function Lg(e){return js(e).position==="static"}function $b(e,t){if(!gr(e)||js(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yr(e)===n&&(n=n.ownerDocument.body),n}function _x(e,t){const n=as(e);if(hf(e))return n;if(!gr(e)){let r=vo(e);for(;r&&!da(r);){if(Vs(r)&&!Lg(r))return r;r=vo(r)}return n}let s=$b(e,t);for(;s&&OI(s)&&Lg(s);)s=$b(s,t);return s&&da(s)&&Lg(s)&&!Yp(s)?n:s||UI(e)||n}const e4=async function(e){const t=this.getOffsetParent||_x,n=this.getDimensions,s=await n(e.floating);return{reference:XI(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function t4(e){return js(e).direction==="rtl"}const $x={convertOffsetParentRelativeRectToViewportRelativeRect:qI,getDocumentElement:yr,getClippingRect:JI,getOffsetParent:_x,getElementRects:e4,getClientRects:zI,getDimensions:QI,getScale:Ji,isElement:Vs,isRTL:t4};function Cx(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function n4(e,t){let n=null,s;const r=yr(e);function o(){var i;clearTimeout(s),(i=n)==null||i.disconnect(),n=null}function a(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),o();const l=e.getBoundingClientRect(),{left:d,top:u,width:f,height:g}=l;if(i||t(),!f||!g)return;const m=sd(u),w=sd(r.clientWidth-(d+f)),S=sd(r.clientHeight-(u+g)),b=sd(d),k={rootMargin:-m+"px "+-w+"px "+-S+"px "+-b+"px",threshold:rs(0,po(1,c))||1};let C=!0;function _(T){const P=T[0].intersectionRatio;if(P!==c){if(!C)return a();P?a(!1,P):s=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!Cx(l,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(_,{...k,root:r.ownerDocument})}catch{n=new IntersectionObserver(_,k)}n.observe(e)}return a(!0),o}function s4(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=s,l=Qp(e),d=r||o?[...l?zc(l):[],...zc(t)]:[];d.forEach(b=>{r&&b.addEventListener("scroll",n,{passive:!0}),o&&b.addEventListener("resize",n)});const u=l&&i?n4(l,n):null;let f=-1,g=null;a&&(g=new ResizeObserver(b=>{let[v]=b;v&&v.target===l&&g&&(g.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var k;(k=g)==null||k.observe(t)})),n()}),l&&!c&&g.observe(l),g.observe(t));let m,w=c?ni(e):null;c&&S();function S(){const b=ni(e);w&&!Cx(w,b)&&n(),w=b,m=requestAnimationFrame(S)}return n(),()=>{var b;d.forEach(v=>{r&&v.removeEventListener("scroll",n),o&&v.removeEventListener("resize",n)}),u==null||u(),(b=g)==null||b.disconnect(),g=null,c&&cancelAnimationFrame(m)}}const r4=AI,o4=DI,i4=CI,a4=PI,c4=EI,l4=$I,d4=(e,t,n)=>{const s=new Map,r={platform:$x,...n},o={...r.platform,_c:s};return _I(e,t,{...r,platform:o})};var u4=O('<svg display=block viewBox="0 0 30 30"style=transform:scale(1.02)><g><path fill=none d=M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z></path><path stroke=none d=M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z>'),Xp=qr();function ey(){const e=zr(Xp);if(e===void 0)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var Gh=30,Cb=Gh/2,f4={top:180,right:-90,bottom:0,left:90};function ty(e){const t=ey(),n=Kt({size:Gh},e),[s,r]=Nt(n,["ref","style","size"]),o=()=>t.currentPlacement().split("-")[0],a=g4(t.contentRef),i=()=>{var f;return((f=a())==null?void 0:f.getPropertyValue("background-color"))||"none"},c=()=>{var f;return((f=a())==null?void 0:f.getPropertyValue(`border-${o()}-color`))||"none"},l=()=>{var f;return((f=a())==null?void 0:f.getPropertyValue(`border-${o()}-width`))||"0px"},d=()=>Number.parseInt(l())*2*(Gh/s.size),u=()=>`rotate(${f4[o()]} ${Cb} ${Cb}) translate(0 2)`;return y(en,_e({as:"div",ref(f){var g=Kn(t.setArrowRef,s.ref);typeof g=="function"&&g(f)},"aria-hidden":"true",get style(){return ml({position:"absolute","font-size":`${s.size}px`,width:"1em",height:"1em","pointer-events":"none",fill:i(),stroke:c(),"stroke-width":d()},s.style)}},r,{get children(){var f=u4(),g=f.firstChild,m=g.firstChild;return m.nextSibling,de(()=>me(g,"transform",u())),f}}))}function g4(e){const[t,n]=R();return Ze(()=>{const s=e();s&&n(i2(s).getComputedStyle(s))}),t}function h4(e){const t=ey(),[n,s]=Nt(e,["ref","style"]);return y(en,_e({as:"div",ref(r){var o=Kn(t.setPositionerRef,n.ref);typeof o=="function"&&o(r)},"data-popper-positioner":"",get style(){return ml({position:"absolute",top:0,left:0,"min-width":"max-content"},n.style)}},s))}function Eb(e){const{x:t=0,y:n=0,width:s=0,height:r=0}=e??{};if(typeof DOMRect=="function")return new DOMRect(t,n,s,r);const o={x:t,y:n,width:s,height:r,top:n,right:t+s,bottom:n+r,left:t};return{...o,toJSON:()=>o}}function m4(e,t){return{contextElement:e,getBoundingClientRect:()=>{const s=t(e);return s?Eb(s):e?e.getBoundingClientRect():Eb()}}}function p4(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var y4={top:"bottom",right:"left",bottom:"top",left:"right"};function v4(e,t){const[n,s]=e.split("-"),r=y4[n];return s?n==="left"||n==="right"?`${r} ${s==="start"?"top":"bottom"}`:s==="start"?`${r} ${t==="rtl"?"right":"left"}`:`${r} ${t==="rtl"?"left":"right"}`:`${r} center`}function w4(e){const t=Kt({getAnchorRect:f=>f==null?void 0:f.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},e),[n,s]=R(),[r,o]=R(),[a,i]=R(t.placement),c=()=>{var f;return m4((f=t.anchorRef)==null?void 0:f.call(t),t.getAnchorRect)},{direction:l}=Vp();async function d(){var T,P;const f=c(),g=n(),m=r();if(!f||!g)return;const w=((m==null?void 0:m.clientHeight)||0)/2,S=typeof t.gutter=="number"?t.gutter+w:t.gutter??w;g.style.setProperty("--kb-popper-content-overflow-padding",`${t.overflowPadding}px`),f.getBoundingClientRect();const b=[r4(({placement:I})=>{const j=!!I.split("-")[1];return{mainAxis:S,crossAxis:j?void 0:t.shift,alignmentAxis:t.shift}})];if(t.flip!==!1){const I=typeof t.flip=="string"?t.flip.split(" "):void 0;if(I!==void 0&&!I.every(p4))throw new Error("`flip` expects a spaced-delimited list of placements");b.push(i4({padding:t.overflowPadding,fallbackPlacements:I}))}(t.slide||t.overlap)&&b.push(o4({mainAxis:t.slide,crossAxis:t.overlap,padding:t.overflowPadding})),b.push(a4({padding:t.overflowPadding,apply({availableWidth:I,availableHeight:j,rects:ne}){const W=Math.round(ne.reference.width);I=Math.floor(I),j=Math.floor(j),g.style.setProperty("--kb-popper-anchor-width",`${W}px`),g.style.setProperty("--kb-popper-content-available-width",`${I}px`),g.style.setProperty("--kb-popper-content-available-height",`${j}px`),t.sameWidth&&(g.style.width=`${W}px`),t.fitViewport&&(g.style.maxWidth=`${I}px`,g.style.maxHeight=`${j}px`)}})),t.hideWhenDetached&&b.push(c4({padding:t.detachedPadding})),m&&b.push(l4({element:m,padding:t.arrowPadding}));const v=await d4(f,g,{placement:t.placement,strategy:"absolute",middleware:b,platform:{...$x,isRTL:()=>l()==="rtl"}});if(i(v.placement),(T=t.onCurrentPlacementChange)==null||T.call(t,v.placement),!g)return;g.style.setProperty("--kb-popper-content-transform-origin",v4(v.placement,l()));const k=Math.round(v.x),C=Math.round(v.y);let _;if(t.hideWhenDetached&&(_=(P=v.middlewareData.hide)!=null&&P.referenceHidden?"hidden":"visible"),Object.assign(g.style,{top:"0",left:"0",transform:`translate3d(${k}px, ${C}px, 0)`,visibility:_}),m&&v.middlewareData.arrow){const{x:I,y:j}=v.middlewareData.arrow,ne=v.placement.split("-")[0];Object.assign(m.style,{left:I!=null?`${I}px`:"",top:j!=null?`${j}px`:"",[ne]:"100%"})}}Ze(()=>{const f=c(),g=n();if(!f||!g)return;const m=s4(f,g,d,{elementResize:typeof ResizeObserver=="function"});dt(m)}),Ze(()=>{var m;const f=n(),g=(m=t.contentRef)==null?void 0:m.call(t);!f||!g||queueMicrotask(()=>{f.style.zIndex=getComputedStyle(g).zIndex})});const u={currentPlacement:a,contentRef:()=>{var f;return(f=t.contentRef)==null?void 0:f.call(t)},setPositionerRef:s,setArrowRef:o};return y(Xp.Provider,{value:u,get children(){return t.children}})}var Ex=Object.assign(w4,{Arrow:ty,Context:Xp,usePopperContext:ey,Positioner:h4}),Tx=["id","aria-label","aria-labelledby","aria-describedby"];function Mx(e){const t=pr(),n=Kt({id:t.generateId("field")},e);return Ze(()=>dt(t.registerField(he(n.id)))),{fieldProps:{id:()=>he(n.id),ariaLabel:()=>he(n["aria-label"]),ariaLabelledBy:()=>t.getAriaLabelledBy(he(n.id),he(n["aria-label"]),he(n["aria-labelledby"])),ariaDescribedBy:()=>t.getAriaDescribedBy(he(n["aria-describedby"]))}}}function Ax(e){let t;const n=pr(),s=Kt({id:n.generateId("label")},e),[r,o]=Nt(s,["ref"]),a=Rk(()=>t,()=>"label");return Ze(()=>dt(n.registerLabel(o.id))),y(en,_e({as:"label",ref(i){var c=Kn(l=>t=l,r.ref);typeof c=="function"&&c(i)},get for(){return Ee(()=>a()==="label")()?n.fieldId():void 0}},()=>n.dataset(),o))}function Dx(e,t){Ze(yi(e,n=>{if(n==null)return;const s=b4(n);s!=null&&(s.addEventListener("reset",t,{passive:!0}),dt(()=>{s.removeEventListener("reset",t)}))}))}function b4(e){return S4(e)?e.form:e.closest("form")}function S4(e){return e.matches("textarea, input, select, button")}function ny(e){const t=pr(),n=Kt({id:t.generateId("error-message")},e),[s,r]=Nt(n,["forceMount"]),o=()=>t.validationState()==="invalid";return Ze(()=>{o()&&dt(t.registerErrorMessage(r.id))}),y(ee,{get when(){return s.forceMount||o()},get children(){return y(en,_e({as:"div"},()=>t.dataset(),r))}})}var k4={};yl(k4,{Arrow:()=>ty,Content:()=>Ix,Description:()=>zp,ErrorMessage:()=>ny,HiddenSelect:()=>Rx,Icon:()=>Ox,Item:()=>cf,ItemDescription:()=>lf,ItemIndicator:()=>df,ItemLabel:()=>uf,Label:()=>Lx,Listbox:()=>Nx,Portal:()=>Fx,Root:()=>Bx,Section:()=>ff,Select:()=>De,Trigger:()=>Ux,Value:()=>Kx,useSelectContext:()=>Wr});var Px=qr();function Wr(){const e=zr(Px);if(e===void 0)throw new Error("[kobalte]: `useSelectContext` must be used within a `Select` component");return e}function Ix(e){let t;const n=Wr(),[s,r]=Nt(e,["ref","style","onCloseAutoFocus","onFocusOutside"]),o=i=>{n.close()},a=i=>{var c;(c=s.onFocusOutside)==null||c.call(s,i),n.isOpen()&&n.isModal()&&i.preventDefault()};return Mk({isDisabled:()=>!(n.isOpen()&&n.isModal()),targets:()=>t?[t]:[]}),Ok({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),Ek({trapFocus:()=>n.isOpen()&&n.isModal(),onMountAutoFocus:i=>{i.preventDefault()},onUnmountAutoFocus:i=>{var c;(c=s.onCloseAutoFocus)==null||c.call(s,i),i.defaultPrevented||(On(n.triggerRef()),i.preventDefault())}},()=>t),y(ee,{get when(){return n.contentPresent()},get children(){return y(Ex.Positioner,{get children(){return y(Dk,_e({ref(i){var c=Kn(l=>{n.setContentRef(l),t=l},s.ref);typeof c=="function"&&c(i)},get disableOutsidePointerEvents(){return Ee(()=>!!n.isModal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get style(){return ml({"--kb-select-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},s.style)},onEscapeKeyDown:o,onFocusOutside:a,get onDismiss(){return n.close}},()=>n.dataset(),r))}})}})}function Rx(e){const t=Wr();return y(cI,_e({get collection(){return t.listState().collection()},get selectionManager(){return t.listState().selectionManager()},get isOpen(){return t.isOpen()},get isMultiple(){return t.isMultiple()},get isVirtualized(){return t.isVirtualized()},focusTrigger:()=>{var n;return(n=t.triggerRef())==null?void 0:n.focus()}},e))}function Ox(e){const t=Wr(),n=Kt({children:"▼"},e);return y(en,_e({as:"span","aria-hidden":"true"},()=>t.dataset(),n))}function Lx(e){const t=Wr(),[n,s]=Nt(e,["onClick"]);return y(Ax,_e({as:"span",onClick:o=>{var a;on(o,n.onClick),t.isDisabled()||(a=t.triggerRef())==null||a.focus()}},s))}function Nx(e){const t=Wr(),n=Kt({id:t.generateId("listbox")},e),[s,r]=Nt(n,["ref","id","onKeyDown"]);return Ze(()=>dt(t.registerListboxId(s.id))),y(Hp,_e({ref(a){var i=Kn(t.setListboxRef,s.ref);typeof i=="function"&&i(a)},get id(){return s.id},get state(){return t.listState()},get virtualized(){return t.isVirtualized()},get autoFocus(){return t.autoFocus()},shouldSelectOnPressUp:!0,shouldFocusOnHover:!0,get shouldFocusWrap(){return t.shouldFocusWrap()},get disallowTypeAhead(){return t.disallowTypeAhead()},get"aria-labelledby"(){return t.listboxAriaLabelledBy()},get renderItem(){return t.renderItem},get renderSection(){return t.renderSection},onKeyDown:a=>{on(a,s.onKeyDown),a.key==="Escape"&&a.preventDefault()}},r))}function Fx(e){const t=Wr();return y(ee,{get when(){return t.contentPresent()},get children(){return y(Mp,e)}})}function x4(e){const t=`select-${Do()}`,n=Kt({id:t,selectionMode:"single",disallowEmptySelection:!1,closeOnSelection:e.selectionMode==="single",allowDuplicateSelectionEvents:!0,gutter:8,sameWidth:!0,modal:!1},e),[s,r,o,a]=Nt(n,["itemComponent","sectionComponent","open","defaultOpen","onOpenChange","value","defaultValue","onChange","placeholder","options","optionValue","optionTextValue","optionDisabled","optionGroupChildren","keyboardDelegate","allowDuplicateSelectionEvents","disallowEmptySelection","closeOnSelection","disallowTypeAhead","shouldFocusWrap","selectionBehavior","selectionMode","virtualized","modal","preventScroll","forceMount"],["getAnchorRect","placement","gutter","shift","flip","slide","overlap","sameWidth","fitViewport","hideWhenDetached","detachedPadding","arrowPadding","overflowPadding"],dx),[i,c]=R(),[l,d]=R(),[u,f]=R(),[g,m]=R(),[w,S]=R(),[b,v]=R(),[k,C]=R(),[_,T]=R(!0),P=h=>{const $=s.optionValue;return $==null?String(h):String(tf($)?$(h):h[$])},I=Te(()=>{const h=s.optionGroupChildren;return h==null?s.options:s.options.flatMap($=>$[h]??$)}),j=Te(()=>I().map(h=>P(h))),ne=h=>[...h].map($=>I().find(D=>P(D)===$)).filter($=>$!=null),W=Ik({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:h=>{var $;return($=s.onOpenChange)==null?void 0:$.call(s,h)}}),q=lx({selectedKeys:()=>s.value!=null?s.value.map(P):s.value,defaultSelectedKeys:()=>s.defaultValue!=null?s.defaultValue.map(P):s.defaultValue,onSelectionChange:h=>{var $;($=s.onChange)==null||$.call(s,ne(h)),s.closeOnSelection&&N()},allowDuplicateSelectionEvents:()=>he(s.allowDuplicateSelectionEvents),disallowEmptySelection:()=>he(s.disallowEmptySelection),selectionBehavior:()=>he(s.selectionBehavior),selectionMode:()=>s.selectionMode,dataSource:()=>s.options??[],getKey:()=>s.optionValue,getTextValue:()=>s.optionTextValue,getDisabled:()=>s.optionDisabled,getSectionChildren:()=>s.optionGroupChildren}),U=Te(()=>ne(q.selectionManager().selectedKeys())),G=h=>{q.selectionManager().toggleSelection(P(h))},{present:le}=Ih({show:()=>s.forceMount||W.isOpen(),element:()=>w()??null}),K=()=>{const h=b();h&&On(h)},M=h=>{if(s.options.length<=0)return;T(h),W.open();let $=q.selectionManager().firstSelectedKey();$==null&&(h==="first"?$=q.collection().getFirstKey():h==="last"&&($=q.collection().getLastKey())),K(),q.selectionManager().setFocused(!0),q.selectionManager().setFocusedKey($)},N=()=>{W.close(),q.selectionManager().setFocused(!1),q.selectionManager().setFocusedKey(void 0)},oe=h=>{W.isOpen()?N():M(h)},{formControlContext:ge}=ux(o);Dx(g,()=>{const h=s.defaultValue?[...s.defaultValue].map(P):new sr;q.selectionManager().setSelectedKeys(h)});const Ie=jp({usage:"search",sensitivity:"base"}),ke=Te(()=>{const h=he(s.keyboardDelegate);return h||new fx(q.collection,void 0,Ie)}),we=h=>{var $;return($=s.itemComponent)==null?void 0:$.call(s,{item:h})},Ae=h=>{var $;return($=s.sectionComponent)==null?void 0:$.call(s,{section:h})};Ze(yi([j],([h])=>{const D=[...q.selectionManager().selectedKeys()].filter(E=>h.includes(E));q.selectionManager().setSelectedKeys(D)},{defer:!0}));const Ge=Te(()=>({"data-expanded":W.isOpen()?"":void 0,"data-closed":W.isOpen()?void 0:""})),H={dataset:Ge,isOpen:W.isOpen,isDisabled:()=>ge.isDisabled()??!1,isMultiple:()=>he(s.selectionMode)==="multiple",isVirtualized:()=>s.virtualized??!1,isModal:()=>s.modal??!1,preventScroll:()=>s.preventScroll??H.isModal(),disallowTypeAhead:()=>s.disallowTypeAhead??!1,shouldFocusWrap:()=>s.shouldFocusWrap??!1,selectedOptions:U,contentPresent:le,autoFocus:_,triggerRef:g,listState:()=>q,keyboardDelegate:ke,triggerId:i,valueId:l,listboxId:u,listboxAriaLabelledBy:k,setListboxAriaLabelledBy:C,setTriggerRef:m,setContentRef:S,setListboxRef:v,open:M,close:N,toggle:oe,placeholder:()=>s.placeholder,renderItem:we,renderSection:Ae,removeOptionFromSelection:G,generateId:ja(()=>he(o.id)),registerTriggerId:bs(c),registerValueId:bs(d),registerListboxId:bs(f)};return y(qp.Provider,{value:ge,get children(){return y(Px.Provider,{value:H,get children(){return y(Ex,_e({anchorRef:g,contentRef:w},r,{get children(){return y(en,_e({as:"div",role:"group",get id(){return he(o.id)}},()=>ge.dataset(),Ge,a))}}))}})}})}function Bx(e){const[t,n]=Nt(e,["value","defaultValue","onChange","multiple"]),s=Te(()=>t.value!=null?t.multiple?t.value:[t.value]:t.value),r=Te(()=>t.defaultValue!=null?t.multiple?t.defaultValue:[t.defaultValue]:t.defaultValue);return y(x4,_e({get value(){return s()},get defaultValue(){return r()},onChange:a=>{var i,c;t.multiple?(i=t.onChange)==null||i.call(t,a??[]):(c=t.onChange)==null||c.call(t,a[0]??null)},get selectionMode(){return t.multiple?"multiple":"single"}},n))}function Ux(e){const t=pr(),n=Wr(),s=Kt({id:n.generateId("trigger")},e),[r,o,a]=Nt(s,["ref","disabled","onPointerDown","onClick","onKeyDown","onFocus","onBlur"],Tx),i=()=>n.listState().selectionManager(),c=()=>n.keyboardDelegate(),l=()=>r.disabled||n.isDisabled(),{fieldProps:d}=Mx(o),{typeSelectHandlers:u}=cx({keyboardDelegate:c,selectionManager:i,onTypeSelect:v=>i().select(v)}),f=()=>[n.listboxAriaLabelledBy(),n.valueId()].filter(Boolean).join(" ")||void 0,g=v=>{on(v,r.onPointerDown),v.currentTarget.dataset.pointerType=v.pointerType,!l()&&v.pointerType!=="touch"&&v.button===0&&(v.preventDefault(),n.toggle(!0))},m=v=>{on(v,r.onClick),!l()&&v.currentTarget.dataset.pointerType==="touch"&&n.toggle(!0)},w=v=>{var k,C,_,T,P,I,j,ne;if(on(v,r.onKeyDown),!l())switch(on(v,u.onKeyDown),v.key){case"Enter":case" ":case"ArrowDown":v.stopPropagation(),v.preventDefault(),n.toggle("first");break;case"ArrowUp":v.stopPropagation(),v.preventDefault(),n.toggle("last");break;case"ArrowLeft":{if(v.preventDefault(),n.isMultiple())return;const W=i().firstSelectedKey(),q=W!=null?(C=(k=c()).getKeyAbove)==null?void 0:C.call(k,W):(T=(_=c()).getFirstKey)==null?void 0:T.call(_);q!=null&&i().select(q);break}case"ArrowRight":{if(v.preventDefault(),n.isMultiple())return;const W=i().firstSelectedKey(),q=W!=null?(I=(P=c()).getKeyBelow)==null?void 0:I.call(P,W):(ne=(j=c()).getFirstKey)==null?void 0:ne.call(j);q!=null&&i().select(q);break}}},S=v=>{on(v,r.onFocus),!i().isFocused()&&i().setFocused(!0)},b=v=>{on(v,r.onBlur),!n.isOpen()&&i().setFocused(!1)};return Ze(()=>dt(n.registerTriggerId(d.id()))),Ze(()=>{n.setListboxAriaLabelledBy([d.ariaLabelledBy(),d.ariaLabel()&&!d.ariaLabelledBy()?d.id():null].filter(Boolean).join(" ")||void 0)}),y(vl,_e({ref(v){var k=Kn(n.setTriggerRef,r.ref);typeof k=="function"&&k(v)},get id(){return d.id()},get disabled(){return l()},"aria-haspopup":"listbox",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return Ee(()=>!!n.isOpen())()?n.listboxId():void 0},get"aria-label"(){return d.ariaLabel()},get"aria-labelledby"(){return f()},get"aria-describedby"(){return d.ariaDescribedBy()},onPointerDown:g,onClick:m,onKeyDown:w,onFocus:S,onBlur:b},()=>n.dataset(),()=>t.dataset(),a))}function Kx(e){const t=pr(),n=Wr(),s=Kt({id:n.generateId("value")},e),[r,o]=Nt(s,["id","children"]),a=()=>n.listState().selectionManager(),i=()=>{const c=a().selectedKeys();return c.size===1&&c.has("")?!0:a().isEmpty()};return Ze(()=>dt(n.registerValueId(r.id))),y(en,_e({as:"span",get id(){return r.id},get"data-placeholder-shown"(){return i()?"":void 0}},()=>t.dataset(),o,{get children(){return y(ee,{get when(){return!i()},get fallback(){return n.placeholder()},get children(){return y(_4,{state:{selectedOption:()=>n.selectedOptions()[0],selectedOptions:()=>n.selectedOptions(),remove:c=>n.removeOptionFromSelection(c),clear:()=>a().clearSelection()},get children(){return r.children}})}})}}))}function _4(e){const t=gk(()=>{const n=e.children;return tf(n)?n(e.state):n});return Ee(t)}var De=Object.assign(Bx,{Arrow:ty,Content:Ix,Description:zp,ErrorMessage:ny,HiddenSelect:Rx,Icon:Ox,Item:cf,ItemDescription:lf,ItemIndicator:df,ItemLabel:uf,Label:Lx,Listbox:Nx,Portal:Fx,Section:ff,Trigger:Ux,Value:Kx});const Tb="@media ";function $4(e){let t=typeof e=="function"?e(eM()):e;t.startsWith(Tb)&&(t=t.slice(Tb.length));const n=window.matchMedia(t),[s,r]=R(n.matches),o=a=>r(a.matches);return n.addEventListener?n.addEventListener("change",o):n.addListener(o),dt(()=>n.removeEventListener("change",o)),s}const Zh=new Set(["general","chat","notifications","speech","remote","opencode","providers","sidecars","config-files","advanced","info"]);function Xd(e){if(typeof e=="string")return Zh.has(e)?{section:e}:null;if(!e||typeof e!="object")return null;const t=e;if(!Zh.has(t.section))return null;const n=t.location;return{section:t.section,...Number.isSafeInteger(t.scrollTop)&&t.scrollTop>=0&&t.scrollTop<=1e7?{scrollTop:t.scrollTop}:{},...typeof t.instanceId=="string"&&t.instanceId?{instanceId:t.instanceId}:{},...n&&typeof n=="object"&&typeof n.directory=="string"?{location:n}:{}}}function C4(e){const t=new URL(e).searchParams,n=t.get("preferences");if(!n||!Zh.has(n))return null;const s=t.get("preferencesInstanceId")||void 0,r=t.get("preferencesDirectory"),o=t.get("preferencesWorkspaceId")||void 0;return{section:n,...s?{instanceId:s}:{},...r!==null?{location:{directory:r,...o?{workspaceID:o}:{}}}:{}}}async function E4(e,t=!1,n=!1){var s;if($n.host==="electron"){const r=(s=window.electronAPI)==null?void 0:s.openPreferences;if(!r)throw new Error("Native Preferences is unavailable");await r(e.section,{instanceId:e.instanceId,location:e.location},t,n);return}if($n.host==="tauri"){await Ms("open_preferences_window",{request:e,toggle:t,resume:n});return}throw new Error("Native Preferences is unavailable")}async function T4(){var e,t;Bn()?await((t=(e=window.electronAPI)==null?void 0:e.preferencesReady)==null?void 0:t.call(e)):Dn()&&await Ms("preferences_window_ready")}async function M4(e,t){var n,s;Bn()?await((s=(n=window.electronAPI)==null?void 0:n.acceptPreferencesRequest)==null?void 0:s.call(n,e)):Dn()&&await Ms("preferences_accept_request",{request:e,generation:t})}async function A4(e){return Bn()?(window.__CODENOMAD_FLUSH_CLIENT_STATE_BEFORE_NATIVE_SHUTDOWN__=e,()=>{window.__CODENOMAD_FLUSH_CLIENT_STATE_BEFORE_NATIVE_SHUTDOWN__===e&&delete window.__CODENOMAD_FLUSH_CLIENT_STATE_BEFORE_NATIVE_SHUTDOWN__}):Dn()?Xu("client-state:flush-requested",t=>{e(t.payload.generation).catch(n=>Ut("actions").warn("Preferences shutdown flush failed",n))}):()=>{}}async function D4(){var t;const e=C4(window.location.href);if(Bn()){const n=window.electronAPI,s=n!=null&&n.getPreferencesRequest?await n.getPreferencesRequest():await((t=n==null?void 0:n.getPreferencesSection)==null?void 0:t.call(n));return Xd(s)??e??{section:"general"}}if(Dn()){const n=await Ms("preferences_get_request");return Xd(n)??e??{section:"general"}}return e??{section:"general"}}async function P4(e){var t,n;return Bn()?((n=(t=window.electronAPI)==null?void 0:t.onPreferencesSection)==null?void 0:n.call(t,s=>{const r=Xd(s);r&&e(r)}))??(()=>{}):Dn()?await Xu("preferences:section",s=>{const r=Xd(s.payload);r&&e(r)}):()=>{}}async function I4(e){var t,n;return Bn()?((n=(t=window.electronAPI)==null?void 0:t.onPreferencesCloseRequested)==null?void 0:n.call(t,e))??(()=>{}):Dn()?await Xu("preferences:close-requested",e):()=>{}}async function R4(e){var n,s;const t=r=>{r&&typeof r=="object"&&Number.isSafeInteger(r.id)&&e(r.id)};return Bn()?((s=(n=window.electronAPI)==null?void 0:n.onPreferencesTransitionRequested)==null?void 0:s.call(n,t))??(()=>{}):Dn()?await Xu("preferences:transition-requested",r=>t(r.payload)):()=>{}}async function O4(e,t){var n,s;Bn()?await((s=(n=window.electronAPI)==null?void 0:n.resolvePreferencesTransition)==null?void 0:s.call(n,e,t)):Dn()&&await Ms("preferences_resolve_transition",{id:e,approved:t})}const Yh=new Set;let Mb=Promise.resolve();function Vx(e){return Yh.add(e),()=>Yh.delete(e)}function Qi(){const e=Mb.then(async()=>{for(const t of Array.from(Yh))if(!await t())return!1;return!0});return Mb=e.then(()=>{},()=>{}),e}const[jx,Jh]=R(!1),[Ii,sy]=R("general"),L4=Ut("actions");async function qx(e,t=!1){if(t&&jx()){await Qi()&&Jh(!1);return}if(e&&sy(e),($n.host==="electron"||$n.host==="tauri")&&$n.windowContext==="local")try{const{activeInstanceId:n}=await ls(async()=>{const{activeInstanceId:o}=await Promise.resolve().then(()=>T9);return{activeInstanceId:o}},void 0),s=n()??void 0,r={section:e??"general",instanceId:s};if(s){const{getActiveCatalogLocation:o}=await ls(async()=>{const{getActiveCatalogLocation:a}=await Promise.resolve().then(()=>Z6);return{getActiveCatalogLocation:a}},void 0);r.location=o(s)}await E4(r,t,e===void 0);return}catch(n){L4.warn("Native Preferences failed; opening settings in this window",n)}Jh(!0)}const hH=e=>qx(e,!0);function N4(){Jh(!1)}function ps(e){return $e(e).split(",").map(t=>t.trim()).filter(Boolean)}function Jr(e,t,n){e()!==n&&t()}function Qh(e){const t=e.toolCallExpansionDefaults;return t.tools.other?t.tools.other:t.preset==="minimal"||t.preset==="balanced"?"collapsed":t.preset==="detailed"||t.preset==="everything"?"expanded":e.toolOutputExpansion??"expanded"}function ry(e){const t=e.preferences,n=e.updatePreferences;return[{kind:"toggle",id:"behavior.keyboardShortcutHints",titleKey:"settings.behavior.keyboardHints.title",subtitleKey:"settings.behavior.keyboardHints.subtitle",get:s=>!!(s.showKeyboardShortcutHints??!1),set:s=>{if(n){n({showKeyboardShortcutHints:s});return}Jr(()=>!!(t().showKeyboardShortcutHints??!1),e.toggleKeyboardShortcutHints,s)},disabled:()=>Mh()},{kind:"toggle",id:"behavior.thinkingBlocks",titleKey:"settings.behavior.thinking.title",subtitleKey:"settings.behavior.thinking.subtitle",get:s=>!!s.showThinkingBlocks,set:s=>{if(n){n({showThinkingBlocks:s});return}Jr(()=>!!t().showThinkingBlocks,e.toggleShowThinkingBlocks,s)}},{kind:"enum",id:"behavior.thinkingBlocksDefault",titleKey:"settings.behavior.thinkingDefault.title",subtitleKey:"settings.behavior.thinkingDefault.subtitle",get:s=>s.thinkingBlocksExpansion??"expanded",set:s=>{if(n){n({thinkingBlocksExpansion:s});return}e.setThinkingBlocksExpansion(s)},options:[{value:"expanded",labelKey:"commands.common.expanded"},{value:"collapsed",labelKey:"commands.common.collapsed"}]},{kind:"toggle",id:"behavior.messageTimeline",titleKey:"settings.behavior.messageTimeline.title",subtitleKey:"settings.behavior.messageTimeline.subtitle",get:s=>!!(s.showMessageTimeline??!0),set:s=>{if(n){n({showMessageTimeline:s});return}Jr(()=>!!(t().showMessageTimeline??!0),e.toggleShowMessageTimeline,s)}},{kind:"toggle",id:"behavior.timelineToolCalls",titleKey:"settings.behavior.timelineTools.title",subtitleKey:"settings.behavior.timelineTools.subtitle",get:s=>!!s.showTimelineTools,set:s=>{if(n){n({showTimelineTools:s});return}Jr(()=>!!t().showTimelineTools,e.toggleShowTimelineTools,s)}},{kind:"enum",id:"behavior.diffViewMode",titleKey:"settings.behavior.diffView.title",subtitleKey:"settings.behavior.diffView.subtitle",get:s=>s.diffViewMode??"split",set:s=>{if(n){n({diffViewMode:s});return}e.setDiffViewMode(s)},options:[{value:"split",labelKey:"settings.behavior.diffView.option.split"},{value:"unified",labelKey:"settings.behavior.diffView.option.unified"}]},{kind:"enum",id:"behavior.toolOutputsDefault",titleKey:"settings.behavior.toolOutputsDefault.title",subtitleKey:"settings.behavior.toolOutputsDefault.subtitle",get:Qh,set:s=>{if(n){const r=s,o=t();n({toolOutputExpansion:r==="hidden"?o.toolOutputExpansion:r,toolCallExpansionDefaults:{...o.toolCallExpansionDefaults,preset:"custom",tools:{...o.toolCallExpansionDefaults.tools,other:r}}});return}e.setToolOutputExpansion(s)},options:[{value:"hidden",labelKey:"commands.common.hidden"},{value:"expanded",labelKey:"commands.common.expanded"},{value:"collapsed",labelKey:"commands.common.collapsed"}]},{kind:"enum",id:"behavior.diagnosticsDefault",titleKey:"settings.behavior.diagnosticsDefault.title",subtitleKey:"settings.behavior.diagnosticsDefault.subtitle",get:s=>s.diagnosticsExpansion??"expanded",set:s=>{if(n){n({diagnosticsExpansion:s});return}e.setDiagnosticsExpansion(s)},options:[{value:"hidden",labelKey:"commands.common.hidden"},{value:"expanded",labelKey:"commands.common.expanded"},{value:"collapsed",labelKey:"commands.common.collapsed"}]},{kind:"enum",id:"behavior.toolInputsVisibility",titleKey:"settings.behavior.toolInputsVisibility.title",subtitleKey:"settings.behavior.toolInputsVisibility.subtitle",get:s=>s.toolInputsVisibility??"hidden",set:s=>{if(n){n({toolInputsVisibility:s});return}e.setToolInputsVisibility(s)},options:[{value:"hidden",labelKey:"commands.common.hidden"},{value:"collapsed",labelKey:"commands.common.collapsed"},{value:"expanded",labelKey:"commands.common.expanded"}]},{kind:"toggle",id:"behavior.usageMetrics",titleKey:"settings.behavior.usageMetrics.title",subtitleKey:"settings.behavior.usageMetrics.subtitle",get:s=>!!(s.showUsageMetrics??!0),set:s=>{if(n){n({showUsageMetrics:s});return}Jr(()=>!!(t().showUsageMetrics??!0),e.toggleUsageMetrics,s)}},{kind:"toggle",id:"behavior.autoCleanupBlankSessions",titleKey:"settings.behavior.autoCleanup.title",subtitleKey:"settings.behavior.autoCleanup.subtitle",get:s=>!!s.autoCleanupBlankSessions,set:s=>{if(n){n({autoCleanupBlankSessions:s});return}Jr(()=>!!t().autoCleanupBlankSessions,e.toggleAutoCleanupBlankSessions,s)}},{kind:"toggle",id:"behavior.keepUnseenSubagentIdleStatus",titleKey:"settings.behavior.keepUnseenSubagentIdle.title",subtitleKey:"settings.behavior.keepUnseenSubagentIdle.subtitle",get:s=>!!s.keepUnseenSubagentIdleStatus,set:s=>{n&&n({keepUnseenSubagentIdleStatus:s})}},{kind:"toggle",id:"behavior.focusExistingWindowOnSecondLaunch",titleKey:"settings.behavior.focusExistingWindowOnSecondLaunch.title",subtitleKey:"settings.behavior.focusExistingWindowOnSecondLaunch.subtitle",get:s=>s.focusExistingWindowOnSecondLaunch,set:async s=>{if(await(n==null?void 0:n({focusExistingWindowOnSecondLaunch:s}))===!1)throw new Error("Failed to persist second-launch behavior")}},{kind:"toggle",id:"behavior.providerUsageCreditBalance",titleKey:"settings.behavior.providerUsageCreditBalance.title",subtitleKey:"settings.behavior.providerUsageCreditBalance.subtitle",get:s=>!!s.showProviderUsageCreditBalance,set:s=>{n==null||n({showProviderUsageCreditBalance:s})}},...$p()&&e.useTauriNativeEventTransport&&e.setUseTauriNativeEventTransport?[{kind:"toggle",id:"behavior.tauriNativeEventTransport",titleKey:"settings.behavior.tauriNativeEventTransport.title",subtitleKey:"settings.behavior.tauriNativeEventTransport.subtitle",get:()=>e.useTauriNativeEventTransport(),set:s=>{e.setUseTauriNativeEventTransport(s)}}]:[],{kind:"toggle",id:"behavior.promptVoiceInput",titleKey:"settings.behavior.promptVoiceInput.title",subtitleKey:"settings.behavior.promptVoiceInput.subtitle",get:s=>!!(s.showPromptVoiceInput??!0),set:s=>{if(n){n({showPromptVoiceInput:s});return}Jr(()=>!!(t().showPromptVoiceInput??!0),e.toggleShowPromptVoiceInput,s)}},{kind:"enum",id:"behavior.followUpBehavior",titleKey:"settings.behavior.followUpBehavior.title",subtitleKey:"settings.behavior.followUpBehavior.subtitle",get:s=>s.followUpBehavior,set:s=>n==null?void 0:n({followUpBehavior:s}),options:[{value:"steer",labelKey:"settings.behavior.followUpBehavior.option.steer"},{value:"queue",labelKey:"settings.behavior.followUpBehavior.option.queue"}]},{kind:"toggle",id:"behavior.promptSubmitOnEnter",titleKey:"settings.behavior.promptSubmit.title",subtitleKey:"settings.behavior.promptSubmit.subtitle",get:s=>!!s.promptSubmitOnEnter,set:s=>{if(n){n({promptSubmitOnEnter:s});return}Jr(()=>!!t().promptSubmitOnEnter,e.togglePromptSubmitOnEnter,s)}}]}function F4(e){return[{id:"prompt-submit-shortcut",label:()=>e.preferences().promptSubmitOnEnter?$e("commands.promptSubmitShortcut.label.swapped"):$e("commands.promptSubmitShortcut.label.default"),description:()=>$e("commands.promptSubmitShortcut.description"),category:"Input & Focus",keywords:()=>ps("commands.promptSubmitShortcut.keywords"),action:e.togglePromptSubmitOnEnter},{id:"thinking",label:()=>$e(e.preferences().showThinkingBlocks?"commands.thinkingBlocks.label.hide":"commands.thinkingBlocks.label.show"),description:()=>$e("commands.thinkingBlocks.description"),category:"System",keywords:()=>["/thinking",...ps("commands.thinkingBlocks.keywords")],action:e.toggleShowThinkingBlocks},{id:"timeline-tools",label:()=>$e(e.preferences().showTimelineTools?"commands.timelineToolCalls.label.hide":"commands.timelineToolCalls.label.show"),description:()=>$e("commands.timelineToolCalls.description"),category:"System",keywords:()=>ps("commands.timelineToolCalls.keywords"),action:e.toggleShowTimelineTools},{id:"keyboard-shortcut-hints",label:()=>$e(e.preferences().showKeyboardShortcutHints?"commands.keyboardShortcutHints.label.hide":"commands.keyboardShortcutHints.label.show"),description:()=>$e(Mh()?"commands.keyboardShortcutHints.description.disabledWeb":"commands.keyboardShortcutHints.description"),category:"System",keywords:()=>ps("commands.keyboardShortcutHints.keywords"),disabled:()=>Mh(),action:e.toggleKeyboardShortcutHints},{id:"thinking-default-visibility",label:()=>{const n=(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?$e("commands.common.expanded"):$e("commands.common.collapsed");return $e("commands.thinkingBlocksDefault.label",{state:n})},description:()=>$e("commands.thinkingBlocksDefault.description"),category:"System",keywords:()=>["/thinking",...ps("commands.thinkingBlocksDefault.keywords")],action:()=>{const n=(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?"collapsed":"expanded";e.setThinkingBlocksExpansion(n)}},{id:"diff-view-split",label:()=>`${(e.preferences().diffViewMode||"split")==="split"?"✓ ":""}${$e("commands.diffViewSplit.label")}`,description:()=>$e("commands.diffViewSplit.description"),category:"System",keywords:()=>ps("commands.diffViewSplit.keywords"),action:()=>e.setDiffViewMode("split")},{id:"diff-view-unified",label:()=>`${(e.preferences().diffViewMode||"split")==="unified"?"✓ ":""}${$e("commands.diffViewUnified.label")}`,description:()=>$e("commands.diffViewUnified.description"),category:"System",keywords:()=>ps("commands.diffViewUnified.keywords"),action:()=>e.setDiffViewMode("unified")},{id:"tool-output-default-visibility",label:()=>{const t=Qh(e.preferences()),n=t==="expanded"?$e("commands.common.expanded"):t==="collapsed"?$e("commands.common.collapsed"):$e("commands.common.hidden");return $e("commands.toolOutputsDefault.label",{state:n})},description:()=>$e("commands.toolOutputsDefault.description"),category:"System",keywords:()=>ps("commands.toolOutputsDefault.keywords"),action:()=>{const t=Qh(e.preferences()),n=t==="hidden"?"collapsed":t==="collapsed"?"expanded":"hidden";e.setToolOutputExpansion(n)}},{id:"diagnostics-default-visibility",label:()=>{const t=e.preferences().diagnosticsExpansion||"expanded",n=t==="expanded"?$e("commands.common.expanded"):t==="collapsed"?$e("commands.common.collapsed"):$e("commands.common.hidden");return $e("commands.diagnosticsDefault.label",{state:n})},description:()=>$e("commands.diagnosticsDefault.description"),category:"System",keywords:()=>ps("commands.diagnosticsDefault.keywords"),action:()=>{const t=e.preferences().diagnosticsExpansion||"expanded",n=t==="hidden"?"collapsed":t==="collapsed"?"expanded":"hidden";e.setDiagnosticsExpansion(n)}},{id:"tool-inputs-visibility",label:()=>{const t=e.preferences().toolInputsVisibility||"hidden",n=t==="expanded"?$e("commands.common.expanded"):t==="collapsed"?$e("commands.common.collapsed"):$e("commands.common.hidden");return $e("commands.toolInputsVisibility.label",{state:n})},description:()=>$e("commands.toolInputsVisibility.description"),category:"System",keywords:()=>ps("commands.toolInputsVisibility.keywords"),action:()=>{const t=e.preferences().toolInputsVisibility||"hidden",n=t==="hidden"?"collapsed":t==="collapsed"?"expanded":"hidden";e.setToolInputsVisibility(n)}},{id:"token-usage-visibility",label:()=>{const n=e.preferences().showUsageMetrics??!0?$e("commands.common.visible"):$e("commands.common.hidden");return $e("commands.tokenUsageDisplay.label",{state:n})},description:()=>$e("commands.tokenUsageDisplay.description"),category:"System",keywords:()=>ps("commands.tokenUsageDisplay.keywords"),action:e.toggleUsageMetrics},{id:"auto-cleanup-blank-sessions",label:()=>{const n=e.preferences().autoCleanupBlankSessions?$e("commands.common.enabled"):$e("commands.common.disabled");return $e("commands.autoCleanupBlankSessions.label",{state:n})},description:()=>$e("commands.autoCleanupBlankSessions.description"),category:"System",keywords:()=>ps("commands.autoCleanupBlankSessions.keywords"),action:e.toggleAutoCleanupBlankSessions}]}function mH(e,t){F4(t).forEach(s=>e(s))}var B4=O('<div class="flex-1 min-w-0">'),U4=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const Ng=[{value:"en",label:"English"},{value:"es",label:"Español"},{value:"fr",label:"Français"},{value:"ru",label:"Русский"},{value:"ja",label:"日本語"},{value:"zh-Hans",label:"简体中文"},{value:"he",label:"עברית"},{value:"de",label:"Deutsch"},{value:"ne",label:"नेपाली"},{value:"tr",label:"Türkçe"}],K4=()=>{const{t:e,locale:t}=Dt(),{updatePreferences:n}=Un(),s=()=>Ng.find(r=>r.value===t())??Ng[0];return y(De,{get value(){return s()},onChange:r=>{!r||r.value===t()||n({locale:r.value})},options:Ng,optionValue:"value",optionTextValue:"label",itemComponent:r=>y(De.Item,{get item(){return r.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return r.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger",get"aria-label"(){return e("folderSelection.language.ariaLabel")},get title(){return e("folderSelection.language.ariaLabel")},get children(){return[y(bD,{class:"w-4 h-4 icon-muted","aria-hidden":"true"}),(()=>{var r=B4();return p(r,y(De.Value,{children:o=>(()=>{var a=U4();return p(a,()=>{var i;return(i=o.selectedOption())==null?void 0:i.label}),a})()})),r})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover min-w-[180px]",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})};var Ab=O('<div class="flex-1 min-w-0">'),Db=O("<div><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>"),Pb=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const oy=e=>{const{t}=Dt(),[n,s]=R(new Map),r=(i,c)=>{s(l=>{const d=new Map(l);return d.set(i,c),d})};Ze(()=>{const i=n();if(i.size===0)return;let c=!1;const l=new Map(i);for(const d of e.settings())l.has(d.id)&&Object.is(d.get(e.preferences()),l.get(d.id))&&(l.delete(d.id),c=!0);c&&s(l)});const o=i=>{const c=n();return c.has(i.id)?c.get(i.id):i.get(e.preferences())},a=i=>{const c=i.setting,l=Te(()=>{var f;return!!((f=c.disabled)!=null&&f.call(c))});if(c.kind==="toggle"){const f=Te(()=>[{value:"true",label:t("settings.common.enabled")},{value:"false",label:t("settings.common.disabled")}]),g=Te(()=>f().find(m=>m.value===String(!!o(c))));return(()=>{var m=Db(),w=m.firstChild,S=w.firstChild,b=S.nextSibling;return p(S,()=>t(c.titleKey)),p(b,()=>t(c.subtitleKey)),p(m,y(De,{get value(){return g()},onChange:async v=>{if(!v)return;const k=v.value==="true";try{await c.set(k),r(c.id,k)}catch{return}},get options(){return f()},optionValue:"value",optionTextValue:"label",get disabled(){return l()},itemComponent:v=>y(De.Item,{get item(){return v.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return v.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger",get"aria-label"(){return t(c.titleKey)},get children(){return[(()=>{var v=Ab();return p(v,y(De.Value,{children:k=>(()=>{var C=Pb();return p(C,()=>{var _;return(_=k.selectedOption())==null?void 0:_.label}),C})()})),v})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),null),de(()=>ws(m,`settings-toggle-row ${l()?"opacity-60":""}`)),m})()}const d=Te(()=>c.options.map(f=>({value:String(f.value),label:t(f.labelKey)}))),u=Te(()=>d().find(f=>f.value===String(o(c)??"")));return(()=>{var f=Db(),g=f.firstChild,m=g.firstChild,w=m.nextSibling;return p(m,()=>t(c.titleKey)),p(w,()=>t(c.subtitleKey)),p(f,y(De,{get value(){return u()},onChange:S=>{S&&(r(c.id,S.value),c.set(S.value))},get options(){return d()},optionValue:"value",optionTextValue:"label",get disabled(){return l()},itemComponent:S=>y(De.Item,{get item(){return S.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return S.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger",get"aria-label"(){return t(c.titleKey)},get children(){return[(()=>{var S=Ab();return p(S,y(De.Value,{children:b=>(()=>{var v=Pb();return p(v,()=>{var k;return(k=b.selectedOption())==null?void 0:k.label}),v})()})),S})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),null),de(()=>ws(f,`settings-toggle-row ${l()?"opacity-60":""}`)),f})()};return y(zt,{get each(){return e.settings()},children:i=>y(a,{setting:i})})};var Fg=O('<button type=button class="selector-button selector-button-secondary">'),V4=O('<button type=button class="selector-button selector-button-primary">'),j4=O("<label class=theme-scheme-name-editor><span></span><input class=selector-input maxlength=80>"),q4=O("<p class=theme-scheme-warning role=alert>"),z4=O('<div class="settings-card theme-scheme-settings"><div class=settings-card-header><h3 class=settings-card-title></h3><span class=settings-scope-badge></span></div><div class=theme-scheme-list><div class=theme-scheme-mode><span></span><div class=theme-scheme-appearance-options role=group></div></div><p class=settings-card-subtitle></p><div class=theme-scheme-workbench><select class="selector-input theme-scheme-picker"></select><div class=theme-scheme-actions>'),W4=O("<button type=button class=theme-scheme-appearance-option>"),H4=O("<option>"),G4=O("<div class=theme-scheme-swatches>"),Z4=O("<label class=theme-scheme-swatch><input type=color>");const Ib=[{key:"surfaceBase",labelKey:"settings.appearance.colorScheme.custom.field.surfaceBase"},{key:"surfaceSecondary",labelKey:"settings.appearance.colorScheme.custom.field.surfaceSecondary"},{key:"surfaceMuted",labelKey:"settings.appearance.colorScheme.custom.field.surfaceMuted"},{key:"borderBase",labelKey:"settings.appearance.colorScheme.custom.field.borderBase"},{key:"textPrimary",labelKey:"settings.appearance.colorScheme.custom.field.textPrimary"},{key:"textMuted",labelKey:"settings.appearance.colorScheme.custom.field.textMuted"},{key:"accentPrimary",labelKey:"settings.appearance.colorScheme.custom.field.accentPrimary"},{key:"statusSuccess",labelKey:"settings.appearance.colorScheme.custom.field.statusSuccess"},{key:"statusWarning",labelKey:"settings.appearance.colorScheme.custom.field.statusWarning"},{key:"statusError",labelKey:"settings.appearance.colorScheme.custom.field.statusError"},{key:"userAccent",labelKey:"settings.appearance.colorScheme.custom.field.userAccent"},{key:"agentAccent",labelKey:"settings.appearance.colorScheme.custom.field.agentAccent"},{key:"compactionAccent",labelKey:"settings.appearance.colorScheme.custom.field.compactionAccent"}],Y4=()=>{const{t:e}=Dt(),t=Un(),n=tM(),[s,r]=R({...Dw}),[o,a]=R("dark"),[i,c]=R("dark"),l=()=>t.getAppearancePalette(i()),d=()=>t.getAppearancePresetId(i()),[u,f]=R(""),[g,m]=R(e("settings.appearance.colorScheme.option.custom")),[w,S]=R(""),[b,v]=R(!1),[k,C]=R(!1),[_,T]=R(!1),[P,I]=R(!1),[j,ne]=R(),[W,q]=R(!1),U=Te(()=>[...nM.filter(E=>E.id!=="system"&&(E.id!=="custom"||!sM(t.customColorSchemePreference().colors)||t.customColorSchemePreference().appearance==="light"||l().id==="custom"&&!d())).map(E=>{const Z=E.id==="custom"&&l().id==="custom"&&!d(),B=E.id==="light"?rM:E.colors??Dw,se=E.id==="system"?void 0:E.id==="custom"?Z?l().colors:t.customColorSchemePreference().colors:t.colorSchemeOverrides()[E.id]??(l().id===E.id?l().colors:void 0);return{key:`builtin:${E.id}`,id:E.id,name:e(E.id==="custom"?"settings.appearance.palette.saved":E.labelKey),description:e(E.descriptionKey),appearance:E.id==="custom"?(Z?l():t.customColorSchemePreference()).appearance==="light"?"light":"dark":E.appearance==="light"?"light":"dark",colors:se??B,originalColors:B}}),...Object.entries(t.colorSchemePresets()).map(([E,Z])=>({key:`preset:${E}`,presetId:E,name:Z.name,description:e("settings.appearance.colorScheme.description.custom"),appearance:Z.appearance,colors:Z.colors,originalColors:Z.colors}))]),G=Te(()=>d()?`preset:${d()}`:`builtin:${l().id}`),le=Te(()=>U().filter(E=>E.id!=="system"&&E.appearance===i())),K=Te(()=>U().find(E=>E.key===u())),M=Te(()=>oM(s())),N=Te(()=>{const E=K();return E!=null&&E.id?E.id==="custom"?Ib.some(Z=>E.colors[Z.key]!==E.originalColors[Z.key]):!!t.colorSchemeOverrides()[E.id]:!1});Ze(()=>{if(!t.isLoaded()||k()||_())return;const E=U().find(Z=>Z.key===G());E&&(f(E.key),m(E.name),a(E.appearance),r({...E.colors}))}),Ze(()=>{const E=n.isDark()?"dark":"light";!k()&&!_()&&c(E)});const oe=async()=>!k()||ca(e("settings.configFiles.confirmDiscard.message"),{variant:"warning",confirmLabel:e("settings.configFiles.confirmDiscard.confirmLabel"),cancelLabel:e("settings.configFiles.confirmDiscard.cancelLabel"),dismissible:!1}),ge=Vx(oe);dt(ge);const Ie=async E=>{if(!(_()||u()===E.key||!await oe())){T(!0),C(!1),v(!1),q(!1),f(E.key),m(E.name),a(E.appearance),r({...E.colors});try{E.presetId?await t.selectColorSchemePreset(E.presetId):await t.setColorSchemePreference(E.id==="custom"?Ui({id:"custom",appearance:E.appearance,colors:E.colors}):Ui(E.id))}catch{q(!0)}finally{T(!1)}}},ke=async(E,Z,B)=>{if(_()||u()!==E.key&&!await oe())return!1;const se=u()===E.key?s():E.colors;return f(E.key),m(E.name),a(E.appearance),r({...se,[Z]:B.toUpperCase()}),C(!0),q(!1),!0},we=async()=>{const E=K();if(E!=null&&E.id){T(!0),q(!1);try{E.id==="custom"?await t.setColorSchemePreference(Ui({id:"custom",appearance:E.appearance,colors:E.originalColors})):await t.resetColorSchemeOverride(E.id),r({...E.originalColors}),a(E.appearance),C(!1)}catch{q(!0)}finally{T(!1)}}},Ae=()=>{const E=Pw(g(),Object.values(t.colorSchemePresets()).map(Z=>Z.name));S(E),v(!0),C(!0),q(!1)},Ge=async()=>{if(!k()||!M())return;const E=K();if(!E)return;const Z=b()?void 0:E.presetId,B=b()?w().trim():Z?E.name:Pw(g(),Object.values(t.colorSchemePresets()).map(se=>se.name));if(B){T(!0),q(!1);try{if(!b()&&E.id){E.id==="custom"?await t.setColorSchemePreference(Ui({id:"custom",appearance:E.appearance,colors:s()})):await t.saveColorSchemeOverride(E.id,E.appearance,s()),C(!1);return}const se=await t.saveColorSchemePreset(B,o(),s(),Z);f(`preset:${se}`),m(B),v(!1),C(!1)}catch{q(!0)}finally{T(!1)}}},H=async E=>{if(!(!E.presetId||!await ca(e("settings.appearance.colorScheme.custom.deleteConfirm",{name:E.name}),{variant:"warning",confirmLabel:e("settings.appearance.colorScheme.custom.delete"),dismissible:!1}))){T(!0),q(!1);try{await t.deleteColorSchemePreset(E.presetId);const B=U().find(se=>se.key===G())??U().find(se=>se.appearance===i());f(B.key),m(B.name),a(B.appearance),c(B.appearance),r({...B.colors}),v(!1),C(!1)}catch{q(!0)}finally{T(!1)}}},h=async E=>{if(!(_()||!await oe())){T(!0),q(!1);try{await t.setThemePreference(E),C(!1),v(!1)}catch{q(!0)}finally{T(!1)}}},$=async E=>{if(ne(E),!P()){I(!0);try{for(;j();){const Z=j();await Ie(Z),j()===Z&&ne(void 0)}}finally{I(!1)}}},D=E=>u()===E.key?s():E.colors;return(()=>{var E=z4(),Z=E.firstChild,B=Z.firstChild,se=B.nextSibling,pe=Z.nextSibling,Se=pe.firstChild,Q=Se.firstChild,be=Q.nextSibling,Ve=Se.nextSibling,He=Ve.nextSibling,re=He.firstChild,F=re.nextSibling;return p(B,()=>e("settings.appearance.colorScheme.title")),p(se,()=>e("settings.scope.device")),p(Q,()=>e("settings.appearance.palette.mode")),p(be,y(zt,{each:["system","dark","light"],children:V=>(()=>{var Me=W4();return Me.$$click=()=>void h(V),p(Me,()=>e(V==="system"?"settings.appearance.palette.auto":`settings.appearance.colorScheme.custom.appearance.${V}`)),de(xe=>{var Re=_(),Be=t.themePreference()===V?"true":"false",et=t.themePreference()===V;return Re!==xe.e&&(Me.disabled=xe.e=Re),Be!==xe.t&&me(Me,"data-selected",xe.t=Be),et!==xe.a&&me(Me,"aria-pressed",xe.a=et),xe},{e:void 0,t:void 0,a:void 0}),Me})()})),p(Ve,()=>e("settings.appearance.palette.independent")),re.addEventListener("change",V=>{const Me=V.currentTarget,xe=U().find(Re=>Re.key===Me.value);xe&&$(xe)}),p(re,y(zt,{get each(){return le()},children:V=>(()=>{var Me=H4();return p(Me,()=>V.name),de(()=>{var xe;return Me.selected=(((xe=j())==null?void 0:xe.key)??u())===V.key}),de(()=>Me.value=V.key),Me})()})),p(He,y(ee,{get when(){return K()},keyed:!0,children:V=>(()=>{var Me=G4();return p(Me,y(zt,{each:Ib,children:xe=>{const Re=()=>D(V)[xe.key],Be=()=>e(xe.labelKey);return(()=>{var et=Z4(),Ue=et.firstChild;return Ue.$$input=We=>{const st=We.currentTarget;ke(V,xe.key,st.value).then(at=>{at||(st.value=Re())})},de(We=>{var st=Be(),at=_(),ht=`${V.name} · ${Be()} · ${Re()}`;return st!==We.e&&me(et,"title",We.e=st),at!==We.t&&(Ue.disabled=We.t=at),ht!==We.a&&me(Ue,"aria-label",We.a=ht),We},{e:void 0,t:void 0,a:void 0}),de(()=>Ue.value=Re()),et})()}})),Me})()}),F),p(F,y(ee,{get when(){var V;return(V=K())==null?void 0:V.presetId},get children(){var V=Fg();return V.$$click=()=>void H(K()),p(V,()=>e("settings.appearance.colorScheme.custom.delete")),de(()=>V.disabled=b()||_()),V}}),null),p(F,y(ee,{get when(){return N()},get children(){var V=Fg();return V.$$click=()=>void we(),p(V,()=>e("settings.appearance.colorScheme.custom.reset")),de(()=>V.disabled=b()||_()),V}}),null),p(F,y(ee,{get when(){return!b()},get children(){var V=Fg();return V.$$click=Ae,p(V,()=>e("settings.appearance.colorScheme.custom.new")),de(()=>V.disabled=_()),V}}),null),p(F,y(ee,{get when(){return k()},get children(){var V=V4();return V.$$click=()=>void Ge(),p(V,()=>e("settings.appearance.colorScheme.custom.save")),de(()=>V.disabled=!M()||_()||b()&&!w().trim()),V}}),null),p(pe,y(ee,{get when(){return b()},get children(){var V=j4(),Me=V.firstChild,xe=Me.nextSibling;return p(Me,()=>e("settings.appearance.colorScheme.custom.name")),xe.$$input=Re=>S(Re.currentTarget.value),de(()=>xe.value=w()),V}}),null),p(pe,y(ee,{get when(){return W()},get children(){var V=q4();return p(V,()=>e("settings.appearance.colorScheme.custom.saveError")),V}}),null),de(V=>{var Me=e("settings.appearance.palette.mode"),xe=_()&&!P(),Re=P(),Be=e("settings.appearance.colorScheme.title");return Me!==V.e&&me(be,"aria-label",V.e=Me),xe!==V.t&&(re.disabled=V.t=xe),Re!==V.a&&me(re,"aria-busy",V.a=Re),Be!==V.o&&me(re,"aria-label",V.o=Be),V},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>{var V,Me;return re.value=((V=j())==null?void 0:V.key)??((Me=K())==null?void 0:Me.key)??""}),E})()};Xt(["click","input"]);var J4=O("<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class=settings-scope-badge></span></div></div><div class=settings-card><div class=settings-stack>");const Q4=hk(()=>ls(()=>import("./startup-state-settings-card-BrHxjQL8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.StartupStateSettingsCard}))),Rb=e=>{const{t}=Dt(),n=Un(),s=Te(()=>ry(n).filter(r=>r.id==="behavior.keyboardShortcutHints"||r.id==="behavior.messageTimeline"||r.id==="behavior.timelineToolCalls"||r.id==="behavior.diffViewMode"||r.id==="behavior.followUpBehavior"||r.id==="behavior.promptSubmitOnEnter"));return(()=>{var r=J4(),o=r.firstChild,a=o.firstChild,i=a.firstChild,c=i.firstChild,l=c.nextSibling,d=i.nextSibling,u=o.nextSibling,f=u.firstChild;return p(c,()=>t("folderSelection.language.ariaLabel")),p(l,()=>t("settings.general.language.subtitle")),p(d,()=>t("settings.scope.device")),p(o,y(K4,{}),null),p(r,y(Y4,{}),u),p(r,y(ee,{get when(){return e.showStartupState!==!1},get children(){return y(Q4,{})}}),u),p(f,y(oy,{settings:s,get preferences(){return n.preferences}})),r})()},bl="other",eu={minimal:"collapsed",balanced:"collapsed",detailed:"expanded",everything:"expanded"},vt="expanded",Ft="collapsed";const iy=[{tool:"bash",label:"shell",aliases:["shell"],configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"read",label:"read",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:Ft,everything:vt}},{tool:"write",label:"write",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"edit",label:"edit",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"patch",label:"patch",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"apply_patch",label:"apply_patch",configurable:!1,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"webfetch",label:"webfetch",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}},{tool:"websearch",label:"websearch",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}},{tool:"glob",label:"glob",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}},{tool:"grep",label:"grep",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}},{tool:"todowrite",label:"todowrite",configurable:!1,expansionPresets:{minimal:vt,balanced:vt,detailed:vt,everything:vt}},{tool:"task",label:"subagent",aliases:["subagent"],configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"execute",label:"execute",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"skill",label:"skill",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:Ft,everything:vt}},{tool:"question",label:"question",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"invalid",label:"invalid",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:Ft,everything:vt}},{tool:bl,label:"Other tools",labelKey:"settings.behavior.expansionDefaults.otherTools",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}}],Xh=iy.find(e=>e.tool===bl),X4=iy.reduce((e,t)=>{var n;return e[t.tool]=t,(n=t.aliases)==null||n.forEach(s=>{e[s]=t}),e},{});function zx(e){return X4[e]??Xh}function pH(e){return zx(e).tool}function ay(){return iy.filter(e=>e.configurable)}function eR(e){const t={};for(const n of ay())t[n.tool]=n.expansionPresets[e];return t}function cy(e,t){const n=zx(t),s=n.configurable?n:Xh,r=e.toolCallExpansionDefaults,o=r.preset==="custom"?void 0:s.expansionPresets[r.preset],a=r.preset==="custom"?void 0:Xh.expansionPresets[r.preset];return r.tools[s.tool]??o??r.tools[bl]??a??e.toolOutputExpansion??"expanded"}function yH(e,t){return cy(e,t)==="expanded"}function vH(e){const t=e.toolCallExpansionDefaults;return(t.thinking??(t.preset==="custom"?void 0:eu[t.preset])??e.thinkingBlocksExpansion??"expanded")==="expanded"}const Ob={thinking:NA,diagnostics:tP,inputs:CD,usage:ZA,system:Up,bash:Kp,read:OA,write:eD,edit:KD,patch:BD,apply_patch:Td,webfetch:ei,glob:cb,grep:cb,todowrite:zA,task:BA,execute:HA,websearch:ei,skill:dD,question:fD,invalid:ti,other:kD},tR={"apply-patch":"apply_patch",shell:"bash",subagent:"task",terminal:"bash",todo:"todowrite",todo_write:"todowrite",web_fetch:"webfetch"};function nR(e){const t=(e==null?void 0:e.trim().toLowerCase().replace(/^opencode_/,""))??"",n=tR[t]??t;return Ob[n]??Ob.other}function sR(e){return[{kind:"thinking",key:"thinking",label:e("settings.behavior.expansionDefaults.thinking")},{kind:"diagnostics",key:"diagnostics",label:e("settings.behavior.diagnosticsDefault.title")},{kind:"inputs",key:"inputs",label:e("settings.behavior.toolInputsVisibility.title")},{kind:"usage",key:"usage",label:e("settings.behavior.usageMetrics.title")},{kind:"system",key:"system",label:e("transcriptFilters.systemMessages")},...ay().map(t=>({kind:"tool",key:t.tool,label:t.labelKey?e(t.labelKey):t.label}))]}function Wx(e){const t=e.toolCallExpansionDefaults;return t.thinking??(t.preset==="custom"?void 0:eu[t.preset])??e.thinkingBlocksExpansion??"expanded"}function Lb(e,t){switch(t.kind){case"thinking":return e.showThinkingBlocks?Wx(e):"hidden";case"tool":return cy(e,t.key);case"diagnostics":return e.diagnosticsExpansion;case"inputs":return e.toolInputsVisibility;case"usage":return e.showUsageMetrics?e.usageMetricsExpansion:"hidden";case"system":return e.systemMessagesVisibility??"hidden"}}function rR(e,t,n){if(t.kind==="system")return{systemMessagesVisibility:n};if(t.kind==="diagnostics")return{diagnosticsExpansion:n};if(t.kind==="inputs")return{toolInputsVisibility:n};if(t.kind==="usage")return{showUsageMetrics:n!=="hidden",usageMetricsExpansion:n==="hidden"?e.usageMetricsExpansion:n};const s=Object.fromEntries(ay().map(o=>[o.tool,cy(e,o.tool)]));t.kind==="tool"&&(s[t.key]=n);const r=t.kind==="thinking"&&n!=="hidden"?n:Wx(e);return{showThinkingBlocks:t.kind==="thinking"?n!=="hidden":e.showThinkingBlocks,toolCallExpansionDefaults:{preset:"custom",thinking:r,tools:s},thinkingBlocksExpansion:t.kind==="thinking"&&n!=="hidden"?n:e.thinkingBlocksExpansion,toolOutputExpansion:t.kind==="tool"&&t.key===bl&&n!=="hidden"?n:e.toolOutputExpansion}}var oR=O("<div class=settings-section-stack><section class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class=settings-scope-badge></span></div><div class=settings-expansion-presets></div><div class=settings-expansion-table role=table><div class=settings-expansion-table-header role=row><span role=columnheader></span><span role=columnheader>"),iR=O("<button type=button class=settings-expansion-preset><span class=settings-expansion-preset-title></span><span class=settings-expansion-preset-copy>"),aR=O('<div class="flex-1 min-w-0">'),cR=O('<div class=settings-expansion-row role=row><div class="settings-expansion-row-label flex items-center gap-2"role=cell><code></code></div><div class=settings-expansion-row-control role=cell>'),lR=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const dR=["minimal","balanced","detailed","everything"],Nb={minimal:{systemMessagesVisibility:"hidden",showThinkingBlocks:!1,diagnosticsExpansion:"collapsed",toolInputsVisibility:"hidden",showUsageMetrics:!1,usageMetricsExpansion:"collapsed"},balanced:{systemMessagesVisibility:"hidden",showThinkingBlocks:!1,diagnosticsExpansion:"expanded",toolInputsVisibility:"collapsed",showUsageMetrics:!0,usageMetricsExpansion:"collapsed"},detailed:{systemMessagesVisibility:"collapsed",showThinkingBlocks:!0,diagnosticsExpansion:"expanded",toolInputsVisibility:"collapsed",showUsageMetrics:!0,usageMetricsExpansion:"expanded"},everything:{systemMessagesVisibility:"expanded",showThinkingBlocks:!0,diagnosticsExpansion:"expanded",toolInputsVisibility:"expanded",showUsageMetrics:!0,usageMetricsExpansion:"expanded"}},uR=()=>{const{t:e}=Dt(),{preferences:t,updatePreferences:n}=Un(),s=Te(()=>[{value:"hidden",label:e("commands.common.hidden")},{value:"collapsed",label:e("commands.common.collapsed")},{value:"expanded",label:e("commands.common.expanded")}]),r=Te(()=>sR(e)),o=()=>Lb(t(),{kind:"thinking",key:"thinking"}),a=Te(()=>{const f=t(),g=f.toolCallExpansionDefaults.preset;if(g==="custom")return g;const m=Nb[g],w=m.showThinkingBlocks?eu[g]:"hidden";return o()===w&&f.diagnosticsExpansion===m.diagnosticsExpansion&&f.systemMessagesVisibility===m.systemMessagesVisibility&&f.toolInputsVisibility===m.toolInputsVisibility&&f.showUsageMetrics===m.showUsageMetrics&&f.usageMetricsExpansion===m.usageMetricsExpansion?g:"custom"}),i=f=>{const g=eR(f),m=eu[f];n({...Nb[f],toolCallExpansionDefaults:{preset:f,thinking:m,tools:g},thinkingBlocksExpansion:m,toolOutputExpansion:g[bl]==="expanded"?"expanded":"collapsed"})},c=(f,g)=>{n(rR(t(),f,g))},l=f=>Lb(t(),f),d=f=>s().find(g=>g.value===f),u=f=>e(`settings.behavior.expansionPreset.${f}.title`);return(()=>{var f=oR(),g=f.firstChild,m=g.firstChild,w=m.firstChild,S=w.firstChild,b=S.nextSibling,v=w.nextSibling,k=m.nextSibling,C=k.nextSibling,_=C.firstChild,T=_.firstChild,P=T.nextSibling;return p(S,()=>e("settings.behavior.expansionPresets.ariaLabel")),p(b,()=>e("settings.appearance.behavior.subtitle")),p(v,()=>u(a())),p(k,y(zt,{each:dR,children:I=>(()=>{var j=iR(),ne=j.firstChild,W=ne.nextSibling;return j.$$click=()=>i(I),p(ne,()=>u(I)),p(W,()=>e(`settings.behavior.expansionPreset.${I}.description`)),de(()=>me(j,"data-selected",a()===I?"true":"false")),j})()})),p(T,()=>e("settings.behavior.expansionDefaults.itemColumn")),p(P,()=>e("settings.behavior.expansionDefaults.stateColumn")),p(C,y(zt,{get each(){return r()},children:I=>{const j=Te(()=>d(l(I)));return(()=>{var ne=cR(),W=ne.firstChild,q=W.firstChild,U=W.nextSibling;return p(W,y(Tp,{get component(){return nR(I.key)},class:"w-4 h-4 shrink-0 text-secondary","aria-hidden":"true"}),q),p(q,()=>I.label),p(U,y(De,{get value(){return j()},onChange:G=>G&&c(I,G.value),get options(){return s()},optionValue:"value",optionTextValue:"label",itemComponent:G=>y(De.Item,{get item(){return G.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return G.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger settings-expansion-select",get"aria-label"(){return e("settings.behavior.expansionDefaults.rowAriaLabel",{item:I.label})},get children(){return[(()=>{var G=aR();return p(G,y(De.Value,{children:le=>(()=>{var K=lR();return p(K,()=>{var M;return(M=le.selectedOption())==null?void 0:M.label}),K})()})),G})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})),ne})()}}),null),de(I=>{var j=e("settings.behavior.expansionPresets.ariaLabel"),ne=e("settings.behavior.expansionDefaults.title");return j!==I.e&&me(k,"aria-label",I.e=j),ne!==I.t&&me(C,"aria-label",I.t=ne),I},{e:void 0,t:void 0}),f})()};Xt(["click"]);const tr=Ut("actions");function _r(e){var t,n;return!((t=e==null?void 0:e.signal)!=null&&t.aborted)&&((n=e==null?void 0:e.isCurrent)==null?void 0:n.call(e))!==!1}async function Hx(e,t){if(!_r(t))return!1;try{if(typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText)return _r(t)?(await navigator.clipboard.writeText(e),tr.info("Copied text using Clipboard API"),!0):!1}catch(r){if(!_r(t))return!1;tr.warn("Clipboard API failed, trying fallback:",r)}if(!_r(t))return!1;let n;const s=typeof document<"u"?document.activeElement:null;try{return typeof document>"u"?(tr.error("Document not available for clipboard fallback"),!1):(n=document.createElement("textarea"),n.value=e,n.readOnly=!0,n.style.position="fixed",n.style.left="-9999px",n.style.top="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select(),_r(t)?document.execCommand("copy")?(tr.info("Copied text using execCommand fallback"),!0):(tr.error("execCommand copy failed"),!1):!1)}catch(r){return tr.error("Clipboard fallback failed:",r),!1}finally{try{n==null||n.remove()}catch(r){tr.warn("Failed to remove clipboard fallback element:",r)}try{s==null||s.focus()}catch(r){tr.warn("Failed to restore focus after clipboard fallback:",r)}}}async function wH(e,t){var n;if(!_r(t))return!1;try{if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.write)&&typeof ClipboardItem<"u"){const s=new ClipboardItem({"text/plain":new Blob([...e],{type:"text/plain"})});return _r(t)?(await navigator.clipboard.write([s]),tr.info("Copied text chunks using Clipboard API"),!0):!1}}catch(s){if(!_r(t))return!1;tr.warn("Clipboard chunk write failed, trying text fallback:",s)}return _r(t)?Hx(e.join(""),t):!1}let Bg=null,ic=null;async function Fb(e=!1){if(Bg&&!e)return Bg;if(ic)return ic;const t=kt.fetchServerMeta().then(n=>(Bg=n,n));ic=t;try{return await t}finally{ic===t&&(ic=null)}}function em(e){return Gx(e.host)?"all":e.listeningMode==="all"?"specific":e.listeningMode}function tm(e){if(Gx(e.host))return e.addresses;const t=nm(e.host);return e.addresses.filter(n=>nm(n.ip)===t)}function Gx(e){const t=nm(e);return t==="0.0.0.0"?!0:t.includes(":")&&t.split(":").every(n=>n===""||/^0+$/.test(n))}function nm(e){const t=e.trim().toLowerCase();return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}function Bb(e,t,n,s,r=new Date){var c,l;const o=e?tm(e):[],a=e?s.modes[em(e)]:"—",i=[s.reportTitle,"============================",`${s.generated}: ${r.toISOString()}`,`${s.serverVersion}: ${(e==null?void 0:e.serverVersion)??"—"}`,`${s.uiVersion}: ${((c=e==null?void 0:e.ui)==null?void 0:c.version)??"—"}`,`${s.uiSource}: ${((l=e==null?void 0:e.ui)==null?void 0:l.source)??"—"}`,`${s.runtime}: ${n.host}`,`${s.platform}: ${n.platform}`,`${s.windowContext}: ${n.windowContext}`,`${s.os}: ${t}`,`${s.listeningMode}: ${a}`,`${s.bindHost}: ${(e==null?void 0:e.host)??"—"}`,`${s.localListener}: ${(e==null?void 0:e.localUrl)??"—"}`,`${s.remoteListener}: ${(e==null?void 0:e.remoteUrl)??"—"}`,`${s.workspaceRoot}: ${(e==null?void 0:e.workspaceRoot)??"—"}`,`${s.candidateAddresses}: ${o.length}`];for(const d of o)i.push(`- ${d.family}/${s.scopes[d.scope]}: ${d.remoteUrl}`);return i.push(""),i.join(`
|
|
3
|
-
`)}var fR=O("<div class=settings-card-message role=status aria-live=polite>"),Ub=O("<div class=settings-error-message role=alert>"),gR=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div></div><div class=settings-info-grid><div class=settings-info-row><span class=settings-info-label></span><span class=settings-info-value></span></div><div class=settings-info-row><span class=settings-info-label></span><span class="settings-info-value settings-info-value-muted"></span></div><div class=settings-info-row><span class=settings-info-label></span><span class=settings-info-value></span></div><div class=settings-info-row><span class=settings-info-label></span><span class=settings-info-value></span></div><div class=settings-info-row><span class=settings-info-label></span><span class="settings-info-value settings-info-value-muted"></span></div></div></div><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div></div></div><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><div class=settings-info-grid><div class=settings-info-row><span class=settings-info-label></span><span class=settings-info-value></span></div><div class=settings-info-row><span class=settings-info-label></span><span class="settings-info-value settings-info-value-muted"></span></div></div><div class=settings-info-actions><button type=button class=settings-pill-button></button></div></div><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><div class=settings-card-message></div><div class=settings-info-actions><button type=button class=settings-pill-button></button><button type=button class=settings-pill-button>'),hR=O('<dl class=settings-info-grid><div class=settings-info-row><dt class=settings-info-label></dt><dd class=settings-info-value dir=ltr></dd></div><div class=settings-info-row><dt class=settings-info-label></dt><dd class=settings-info-value></dd></div><div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr></dd></div><div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr></dd></div><div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),mR=O("<h4 class=settings-card-title>"),pR=O("<dl class=settings-info-grid>"),yR=O("<p class=settings-help-text>"),vR=O("<div class=settings-info-actions><button type=button class=settings-pill-button>"),wR=O('<div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),bR=O("<div class=settings-card-message>"),SR=O('<div class=settings-info-row><dt class=settings-info-label> · </dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),kR=O('<a target=_blank rel="noopener noreferrer"class=settings-pill-button>'),xR=O("<div class=settings-info-toast role=status aria-live=polite>");function Zx(){return navigator.userAgentData}function _R(){if(typeof navigator>"u")return"Unknown";const e=Zx();if(e!=null&&e.platform){const r=Kb(navigator.userAgent);return r?`${e.platform} ${r}`:e.platform}const t=navigator.userAgent,n=navigator.platform;if(!n)return"Unknown";const s=Kb(t);return s&&!n.includes(s)?`${n} ${s}`:n}function Kb(e){const t=e.match(/Linux\s+(x86_64|aarch64|armv[0-9]+[a-z]*|i[3-6]86)/i)??e.match(/Win64;\s*(x64|arm64)/i)??e.match(/Mac\s*OS\s*X[^)]*?_(x86_64|arm64)/i);return t?t[1]:null}async function $R(){try{const e=Zx();if(!(e!=null&&e.getHighEntropyValues))return null;const t=await e.getHighEntropyValues(["architecture","bitness"]),n=[];return t.architecture&&!t.architecture.startsWith("x86")&&n.push(t.architecture),t.bitness&&t.bitness!=="64"&&n.push(`${t.bitness}-bit`),!n.length&&t.architecture&&n.push(t.architecture),n.length>0?n.join(" "):null}catch{return null}}function CR(e,t){const n=new Blob([t],{type:"text/plain;charset=utf-8"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s)}function Vb(e){return e.replace(/^v/,"").split("-")[0]}function ER(e,t){const n=Vb(e).split(".").map(Number),s=Vb(t).split(".").map(Number);return n.some(isNaN)||s.some(isNaN)?null:s[0]>n[0]?!0:s[0]<n[0]?!1:s[1]>n[1]?!0:s[1]<n[1]?!1:s[2]>n[2]}const TR=()=>{const{t:e}=Dt(),[t,n]=R(!1),[s,{mutate:r}]=mk(async()=>{n(!1);try{return await Fb()}catch{return n(!0),null}}),[o,a]=R(null),[i,c]=R(null);Ze(()=>{$R().then(k=>{k&&c(k)})});const l=Te(()=>{const k=s();return k!=null&&k.update?k.update:null}),d=Te(()=>{var k;return((k=s())==null?void 0:k.support)??null}),u=Te(()=>({reportTitle:e("settings.info.diagnostics.reportTitle"),generated:e("settings.info.diagnostics.generated"),serverVersion:e("settings.info.version.server"),uiVersion:e("settings.info.version.ui"),uiSource:e("settings.info.version.uiSource"),runtime:e("settings.info.runtime.type"),platform:e("settings.info.runtime.platform"),windowContext:e("settings.info.runtime.windowContext"),os:e("settings.info.runtime.os"),listeningMode:e("remoteAccess.sections.listeningMode.label"),bindHost:e("settings.info.connectivity.host"),localListener:e("settings.info.connectivity.localListener"),remoteListener:e("settings.info.connectivity.remoteListener"),workspaceRoot:e("settings.info.server.root"),candidateAddresses:e("remoteAccess.sections.addresses.label"),modes:{local:e("settings.info.connectivity.mode.local"),all:e("settings.info.connectivity.mode.all"),specific:e("settings.info.connectivity.mode.specific")},scopes:{external:e("remoteAccess.address.scope.network"),internal:e("remoteAccess.address.scope.internal"),loopback:e("remoteAccess.address.scope.loopback")}})),f=Te(()=>{var C;const k=l();return k!=null&&k.version?k.version:((C=d())==null?void 0:C.latestServerVersion)??null}),g=Te(()=>{var P,I;let k=null;const C=l();if(C!=null&&C.url?k=C.url:(P=d())!=null&&P.latestServerUrl&&(k=d().latestServerUrl??null),!k)return{url:null,show:!1};if(C!=null&&C.url)return{url:k,show:!0};const _=(I=s())==null?void 0:I.serverVersion,T=f();return!_||!T?{url:null,show:!1}:{url:k,show:ER(_,T)!==!1}});let m;Ze(()=>{o()&&(clearTimeout(m),m=setTimeout(()=>a(null),2500))}),dt(()=>clearTimeout(m));const w=async()=>{n(!1);try{const k=await Fb(!0);r(k)}catch{n(!0)}},S=Te(()=>{const k=_R(),C=i();return C?`${k} (${C})`:k}),b=async()=>{const k=Bb(s()??null,S(),$n,u()),C=await Hx(k);a(C?"success":"error")},v=()=>{const k=Bb(s()??null,S(),$n,u()),C=new Date().toISOString().replace(/[:.]/g,"-");CR(`codenomad-diagnostics-${C}.txt`,k)};return(()=>{var k=gR(),C=k.firstChild,_=C.firstChild,T=_.firstChild,P=T.firstChild,I=P.firstChild,j=I.nextSibling,ne=_.nextSibling,W=ne.firstChild,q=W.firstChild,U=q.nextSibling,G=W.nextSibling,le=G.firstChild,K=le.nextSibling,M=G.nextSibling,N=M.firstChild,oe=N.nextSibling,ge=M.nextSibling,Ie=ge.firstChild,ke=Ie.nextSibling,we=ge.nextSibling,Ae=we.firstChild,Ge=Ae.nextSibling,H=C.nextSibling,h=H.firstChild,$=h.firstChild,D=$.firstChild,E=D.firstChild,Z=E.nextSibling,B=H.nextSibling,se=B.firstChild,pe=se.firstChild,Se=pe.firstChild,Q=Se.nextSibling,be=se.nextSibling,Ve=be.firstChild,He=Ve.firstChild,re=He.nextSibling,F=Ve.nextSibling,V=F.firstChild,Me=V.nextSibling,xe=be.nextSibling,Re=xe.firstChild,Be=B.nextSibling,et=Be.firstChild,Ue=et.firstChild,We=Ue.firstChild,st=We.nextSibling,at=et.nextSibling,ht=at.nextSibling,ut=ht.firstChild,Ct=ut.nextSibling;return p(T,y(Up,{class:"settings-card-heading-icon"}),P),p(I,()=>e("settings.section.info.title")),p(j,()=>e("settings.section.info.subtitle")),p(q,()=>e("settings.info.version.ui")),p(U,()=>{var Qe,tt;return((tt=(Qe=s())==null?void 0:Qe.ui)==null?void 0:tt.version)??"—"}),p(le,()=>e("settings.info.version.uiSource")),p(K,()=>{var Qe,tt;return((tt=(Qe=s())==null?void 0:Qe.ui)==null?void 0:tt.source)??"—"}),p(N,()=>e("settings.info.runtime.type")),p(oe,()=>$n.host),p(Ie,()=>e("settings.info.runtime.platform")),p(ke,()=>$n.platform),p(Ae,()=>e("settings.info.runtime.os")),p(Ge,S),p($,y(ND,{class:"settings-card-heading-icon"}),D),p(E,()=>e("settings.info.connectivity.title")),p(Z,()=>e("settings.info.connectivity.subtitle")),p(H,y(ee,{get when(){return s.loading},get children(){var Qe=fR();return p(Qe,()=>e("remoteAccess.addresses.loading")),Qe}}),null),p(H,y(ee,{get when(){return t()},get children(){var Qe=Ub();return p(Qe,()=>e("settings.info.connectivity.loadFailed")),Qe}}),null),p(H,y(ee,{get when(){return s()},children:Qe=>[(()=>{var tt=hR(),At=tt.firstChild,xt=At.firstChild,x=xt.nextSibling,A=At.nextSibling,L=A.firstChild,X=L.nextSibling,Y=A.nextSibling,ue=Y.firstChild,ce=ue.nextSibling,ve=Y.nextSibling,je=ve.firstChild,Ke=je.nextSibling,rt=ve.nextSibling,ot=rt.firstChild,Pt=ot.nextSibling;return p(xt,()=>e("settings.info.version.server")),p(x,()=>Qe().serverVersion??"—"),p(L,()=>e("remoteAccess.sections.listeningMode.label")),p(X,()=>e(em(Qe())==="specific"?"settings.info.connectivity.mode.specific":em(Qe())==="all"?"settings.info.connectivity.mode.all":"settings.info.connectivity.mode.local")),p(ue,()=>e("settings.info.connectivity.host")),p(ce,()=>Qe().host),p(je,()=>e("settings.info.connectivity.localListener")),p(Ke,()=>Qe().localUrl),p(tt,y(ee,{get when(){return Qe().remoteUrl},children:In=>(()=>{var wn=wR(),zn=wn.firstChild,Et=zn.nextSibling;return p(zn,()=>e("settings.info.connectivity.remoteListener")),p(Et,In),wn})()}),rt),p(ot,()=>e("settings.info.server.root")),p(Pt,()=>Qe().workspaceRoot),tt})(),(()=>{var tt=mR();return p(tt,()=>e("remoteAccess.sections.addresses.label")),tt})(),y(ee,{get when(){return tm(Qe()).length>0},get fallback(){return(()=>{var tt=bR();return p(tt,()=>e("remoteAccess.addresses.none")),tt})()},get children(){var tt=pR();return p(tt,y(zt,{get each(){return tm(Qe())},children:At=>(()=>{var xt=SR(),x=xt.firstChild,A=x.firstChild,L=x.nextSibling;return p(x,()=>At.family.toUpperCase(),A),p(x,()=>e(At.scope==="external"?"remoteAccess.address.scope.network":At.scope==="internal"?"remoteAccess.address.scope.internal":"remoteAccess.address.scope.loopback"),null),p(L,()=>At.remoteUrl),xt})()})),tt}}),(()=>{var tt=yR();return p(tt,()=>e("settings.info.connectivity.disclaimer")),tt})(),y(ee,{get when(){return ia()},get children(){var tt=vR(),At=tt.firstChild;return At.$$click=()=>qx("remote"),p(At,()=>e("settings.nav.remote")),tt}})]}),null),p(Se,()=>e("settings.info.updates.title")),p(Q,()=>e("settings.info.updates.subtitle")),p(He,()=>e("settings.info.version.server")),p(re,()=>{var Qe;return((Qe=s())==null?void 0:Qe.serverVersion)??"—"}),p(V,()=>e("settings.info.updates.latest")),p(Me,()=>f()??"—"),p(xe,(()=>{var Qe=Ee(()=>!!g().show);return()=>Qe()&&(()=>{var tt=kR();return p(tt,()=>e("settings.info.updates.download")),de(()=>me(tt,"href",g().url)),tt})()})(),Re),Re.$$click=w,p(Re,()=>e("settings.info.updates.refresh")),p(We,()=>e("settings.info.diagnostics.title")),p(st,()=>e("settings.info.diagnostics.subtitle")),p(at,()=>e("settings.info.diagnostics.privacy")),ut.$$click=b,p(ut,()=>e("settings.info.diagnostics.copy")),Ct.$$click=v,p(Ct,()=>e("settings.info.diagnostics.download")),p(Be,(()=>{var Qe=Ee(()=>o()==="success");return()=>Qe()&&(()=>{var tt=xR();return p(tt,()=>e("settings.info.diagnostics.copied")),tt})()})(),null),p(Be,(()=>{var Qe=Ee(()=>o()==="error");return()=>Qe()&&(()=>{var tt=Ub();return p(tt,()=>e("settings.info.diagnostics.copyFailed")),tt})()})(),null),de(()=>Re.disabled=s.loading),k})()};Xt(["click"]);var MR=O('<div><button type=button class="absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center text-slate-200/80 hover:text-slate-50 hover:bg-white/10">x</button><div class="flex items-start gap-3 pr-6"><span></span><div class="min-w-0 flex-1 text-sm leading-snug"><p>'),AR=O("<p>"),DR=O('<button type=button class="mt-3 inline-flex items-center text-xs font-semibold uppercase tracking-wide text-sky-300 hover:text-sky-200">');const jb=50;let _s=[];const sm=new Set,[PR,IR]=R(0);function bH(){return PR}function Sl(){IR(_s.filter(e=>!e.read).length)}function kl(){const e=[..._s];sm.forEach(t=>{try{t(e)}catch(n){console.error("[notifications] subscriber error:",n)}})}function RR(){return`toast_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function OR(){_s.length>jb&&(_s=_s.slice(0,jb))}function LR(e){const t={...e,id:RR(),createdAt:Date.now(),read:!1};return _s.unshift(t),OR(),Sl(),kl(),t.id}function SH(){_s=[],Sl(),kl()}function kH(e){const t=_s.find(n=>n.id===e);t&&!t.read&&(t.read=!0,Sl(),kl())}function xH(){let e=!1;_s.forEach(t=>{t.read||(t.read=!0,e=!0)}),e&&(Sl(),kl())}function _H(e){const t=_s.findIndex(n=>n.id===e);t!==-1&&(_s.splice(t,1),Sl(),kl())}function $H(e){return sm.add(e),e([..._s]),()=>{sm.delete(e)}}async function qb(e){if(!(typeof window>"u")){try{if(Dn()){const{openUrl:t}=await ls(async()=>{const{openUrl:n}=await import("./index-DXsN55dj.js");return{openUrl:n}},__vite__mapDeps([9,6,2,3,4,5,1,7]));await t(e);return}}catch(t){console.warn("[notifications] unable to open via system opener",t)}try{window.open(e,"_blank","noopener,noreferrer")}catch(t){console.warn("[notifications] unable to open external url",t),jn.error($e("toastHistory.openLinkError"))}}}async function NR(e){if(!e.onClick){await qb(e.href);return}try{await e.onClick()}catch(t){console.warn("[notifications] action failed; opening fallback link",t),await qb(e.href)}}const FR={info:{badge:"bg-sky-500/40",container:"bg-slate-900/95 border-slate-700 text-slate-100",headline:"text-slate-50",body:"text-slate-200/80"},success:{badge:"bg-emerald-500/40",container:"bg-emerald-950/90 border-emerald-800 text-emerald-50",headline:"text-emerald-50",body:"text-emerald-100/80"},warning:{badge:"bg-amber-500/40",container:"bg-amber-950/90 border-amber-800 text-amber-50",headline:"text-amber-50",body:"text-amber-100/80"},error:{badge:"bg-rose-500/40",container:"bg-rose-950/90 border-rose-800 text-rose-50",headline:"text-rose-50",body:"text-rose-100/80"}};function Hn(e){const t=FR[e.variant],n=e.duration??1e4;LR({title:e.title,message:e.message,variant:e.variant,action:e.action});const s=jn.custom(()=>(()=>{var r=MR(),o=r.firstChild,a=o.nextSibling,i=a.firstChild,c=i.nextSibling,l=c.firstChild;return o.$$click=()=>jn.dismiss(s),p(c,(()=>{var d=Ee(()=>!!e.title);return()=>d()&&(()=>{var u=AR();return p(u,()=>e.title),de(()=>ws(u,`break-words ${t.headline} font-semibold`)),u})()})(),l),p(l,()=>e.message),p(c,(()=>{var d=Ee(()=>!!e.action);return()=>d()&&(()=>{var u=DR();return u.$$click=()=>void NR(e.action),p(u,()=>e.action.label),u})()})(),null),de(d=>{var u=`pointer-events-auto relative w-[320px] max-w-[360px] border px-4 py-3 shadow-xl ${t.container}`,f=$e("toastHistory.close"),g=$e("toastHistory.close"),m=`mt-1 inline-block h-2.5 w-2.5 rounded-full ${t.badge}`,w=`${t.body} ${e.title?"mt-1":""} whitespace-pre-wrap break-words [overflow-wrap:anywhere]`;return u!==d.e&&ws(r,d.e=u),f!==d.t&&me(o,"aria-label",d.t=f),g!==d.a&&me(o,"title",d.a=g),m!==d.o&&ws(i,d.o=m),w!==d.i&&ws(l,d.i=w),d},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r})(),{duration:n,position:e.position??"top-right",ariaProps:{role:"status","aria-live":"polite"}});return{id:s,dismiss:()=>jn.dismiss(s)}}Xt(["click"]);const yf=Ut("actions");function vf(){return typeof window<"u"&&typeof window.Notification<"u"}function ly(){if(!vf())return"unsupported";const e=window.Notification.permission;return e==="granted"?"granted":e==="denied"?"denied":"default"}async function BR(){if(!vf())return"unsupported";try{const e=await window.Notification.requestPermission();return e==="granted"?"granted":e==="denied"?"denied":"default"}catch(e){return yf.warn("[os-notifications] requestPermission failed",e),ly()}}async function UR(e){if(!vf())throw new Error("Web notifications not supported");if(ly()!=="granted")throw new Error("Web notification permission not granted");new window.Notification(e.title,{body:e.body})}function dy(){if(typeof window>"u")return!1;const e=window.electronAPI;return!!(e&&typeof e.showNotification=="function")}function CH(){return typeof window>"u"?!1:Bn()?dy():Dn()?!0:vf()}async function KR(e){const t=window.electronAPI;if(!t||typeof t.showNotification!="function")throw new Error("Electron notification bridge unavailable");await t.showNotification(e)}async function uy(){try{return await ls(()=>import("./index-Fc9xv2mA.js"),__vite__mapDeps([10,6,2,3,4,5,1,7]))}catch(e){return yf.info("[os-notifications] tauri notification plugin not available",e),null}}async function Yx(){const e=await uy();if(!e)return"unsupported";try{return await e.isPermissionGranted()?"granted":"default"}catch(t){return yf.warn("[os-notifications] failed to check tauri notification permission",t),"default"}}async function VR(){const e=await uy();if(!e)return"unsupported";try{const t=await e.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"default"}catch(t){return yf.warn("[os-notifications] failed to request tauri notification permission",t),await Yx()}}async function jR(e){const t=await uy();if(!t)throw new Error("Tauri notification plugin unavailable");await t.sendNotification({title:e.title,body:e.body})}async function qR(){if(typeof window>"u")return{supported:!1,permission:"unsupported",info:"Not available in this environment."};if(Bn())return dy()?{supported:!0,permission:"granted",info:"Notifications are managed by your OS notification settings."}:{supported:!1,permission:"unsupported",info:"Electron notification bridge is not available."};if(Dn()){const n=await Yx(),s=n!=="unsupported";return{supported:s,permission:n,info:s?void 0:"Tauri notification support is not available in this build."}}const e=ly(),t=e!=="unsupported";return{supported:t,permission:e,info:t?void 0:"This browser does not support OS notifications (or notifications are blocked by the environment)."}}async function zb(){return typeof window>"u"?"unsupported":Bn()?dy()?"granted":"unsupported":Dn()?await VR():await BR()}async function zR(e){if(!(typeof window>"u")){if(Bn()){await KR(e);return}if(Dn()){await jR(e);return}await UR(e)}}var WR=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap">'),Wb=O("<div class=settings-inline-note>"),HR=O("<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class=settings-scope-badge></span></div><div class=settings-stack><div class=settings-toggle-row><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><label class=settings-checkbox-toggle><input type=checkbox><span></span></label></div><div class=settings-toggle-row><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><label class=settings-checkbox-toggle><input type=checkbox><span></span></label></div></div></div><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class=settings-scope-badge></span></div><div class=settings-stack><div class=settings-toggle-row><div><div class=settings-toggle-title></div></div><label class=settings-checkbox-toggle><input type=checkbox><span></span></label></div><div class=settings-toggle-row><div><div class=settings-toggle-title></div></div><label class=settings-checkbox-toggle><input type=checkbox><span>");function GR(e,t){switch(e){case"granted":return t("settings.notifications.permission.granted");case"denied":return t("settings.notifications.permission.denied");case"default":return t("settings.notifications.permission.default");case"unsupported":return t("settings.notifications.permission.unsupported");default:return String(e)}}const ZR=()=>{const{t:e}=Dt(),{preferences:t,updatePreferences:n}=Un(),[s,{refetch:r}]=mk(()=>qR());Ze(()=>{r()});const o=async d=>{if(!d){n({osNotificationsEnabled:!1});return}const u=s();if(u&&!u.supported){Hn({title:e("settings.section.notifications.title"),message:u.info??e("settings.notifications.messages.unsupportedEnvironment"),variant:"warning"}),n({osNotificationsEnabled:!1});return}const f=await zb();if(f!=="granted"){Hn({title:e("settings.section.notifications.title"),message:e(f==="denied"?"settings.notifications.messages.permissionDenied":"settings.notifications.messages.permissionNotGranted"),variant:"warning"}),n({osNotificationsEnabled:!1});return}n({osNotificationsEnabled:!0}),r()},a=async()=>{const d=s();if(d&&!d.supported){Hn({title:e("settings.section.notifications.title"),message:d.info??e("settings.notifications.messages.unsupportedGeneral"),variant:"warning"});return}const u=await zb();if(u==="granted"){Hn({title:e("settings.section.notifications.title"),message:e("settings.notifications.messages.permissionGranted"),variant:"success",duration:6e3}),r();return}Hn({title:e("settings.section.notifications.title"),message:e(u==="denied"?"settings.notifications.messages.permissionRequestDenied":"settings.notifications.messages.permissionNotGranted"),variant:"warning"}),r()},i=()=>{var d;return((d=s())==null?void 0:d.supported)??!1},c=()=>{var d;return GR(((d=s())==null?void 0:d.permission)??"unsupported",e)},l=()=>{var d;return(d=s())==null?void 0:d.info};return(()=>{var d=HR(),u=d.firstChild,f=u.firstChild,g=f.firstChild,m=g.firstChild,w=m.firstChild,S=w.nextSibling,b=g.nextSibling,v=f.nextSibling,k=v.firstChild,C=k.firstChild,_=C.firstChild,T=_.nextSibling,P=C.nextSibling,I=P.firstChild,j=I.nextSibling,ne=k.nextSibling,W=ne.firstChild,q=W.firstChild,U=q.nextSibling,G=W.nextSibling,le=G.firstChild,K=le.nextSibling,M=u.nextSibling,N=M.firstChild,oe=N.firstChild,ge=oe.firstChild,Ie=ge.nextSibling,ke=oe.nextSibling,we=N.nextSibling,Ae=we.firstChild,Ge=Ae.firstChild,H=Ge.firstChild,h=Ge.nextSibling,$=h.firstChild,D=$.nextSibling,E=Ae.nextSibling,Z=E.firstChild,B=Z.firstChild,se=Z.nextSibling,pe=se.firstChild,Se=pe.nextSibling;return p(g,y(Jk,{class:"settings-card-heading-icon"}),m),p(w,()=>e("settings.notifications.sessionStatus.title")),p(S,()=>e("settings.notifications.sessionStatus.subtitle")),p(b,()=>e("settings.scope.device")),p(_,()=>e("settings.notifications.enable.title")),p(T,()=>e("settings.notifications.enable.permission",{permission:c()})),I.addEventListener("change",Q=>void o(Q.currentTarget.checked)),p(j,()=>e("settings.common.enabled")),p(v,y(ee,{get when(){var Q;return Ee(()=>!!i())()&&(((Q=s())==null?void 0:Q.permission)??"unsupported")!=="granted"},get children(){var Q=WR(),be=Q.firstChild,Ve=be.firstChild,He=Ve.nextSibling,re=be.nextSibling;return p(Ve,()=>e("settings.notifications.requestPermission.title")),p(He,()=>e("settings.notifications.requestPermission.subtitle")),re.$$click=()=>void a(),p(re,()=>e("settings.notifications.requestPermission.action")),Q}}),ne),p(q,()=>e("settings.notifications.allowVisible.title")),p(U,()=>e("settings.notifications.allowVisible.subtitle")),le.addEventListener("change",Q=>n({osNotificationsAllowWhenVisible:Q.currentTarget.checked})),p(K,()=>e("settings.common.enabled")),p(v,y(ee,{get when(){return!!l()},get children(){var Q=Wb();return p(Q,l),Q}}),null),p(v,y(ee,{get when(){return Ee(()=>!i())()&&s.state==="ready"},get children(){var Q=Wb();return p(Q,()=>e("settings.notifications.unsupportedNote")),Q}}),null),p(ge,()=>e("settings.notifications.events.title")),p(Ie,()=>e("settings.notifications.events.subtitle")),p(ke,()=>e("settings.scope.device")),p(H,()=>e("settings.notifications.events.needsInput")),$.addEventListener("change",Q=>n({notifyOnNeedsInput:Q.currentTarget.checked})),p(D,()=>e("settings.common.enabled")),p(B,()=>e("settings.notifications.events.idle")),pe.addEventListener("change",Q=>n({notifyOnIdle:Q.currentTarget.checked})),p(Se,()=>e("settings.common.enabled")),de(Q=>{var be=!i()&&s.state==="ready",Ve=!t().osNotificationsEnabled,He=!t().osNotificationsEnabled,re=!t().osNotificationsEnabled;return be!==Q.e&&(I.disabled=Q.e=be),Ve!==Q.t&&(le.disabled=Q.t=Ve),He!==Q.a&&($.disabled=Q.a=He),re!==Q.o&&(pe.disabled=Q.o=re),Q},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>I.checked=!!t().osNotificationsEnabled),de(()=>le.checked=!!t().osNotificationsAllowWhenVisible),de(()=>$.checked=!!t().notifyOnNeedsInput),de(()=>pe.checked=!!t().notifyOnIdle),d})()};Xt(["click"]);function Hb(e,t,n,s,r,o){if(e)return{apiKey:null,baseUrl:null,model:null};const a=t.trim(),i=(n.trim()||"")!==(r||""),c=s.trim()===o.trim();return i?{...a?{apiKey:a}:{apiKey:null},baseUrl:n.trim()||null,model:c?null:s.trim()||null}:{...a?{apiKey:a}:{},model:c?null:s.trim()||null}}function Jx(e){return e==="wav"?"audio/wav":e==="opus"?YR(e):e==="aac"?"audio/aac":"audio/mpeg"}function Qx(e){return e==="wav"?["audio/wav"]:e==="opus"?['audio/ogg; codecs="opus"','audio/webm; codecs="opus"',"audio/opus"]:e==="aac"?["audio/aac","audio/mp4",'audio/mp4; codecs="mp4a.40.2"']:["audio/mpeg"]}function YR(e){const t=Qx(e);return typeof MediaSource>"u"?t[0]:t.find(n=>MediaSource.isTypeSupported(n))??t[0]}function Wc(e){var t;return typeof window>"u"||typeof window.Audio>"u"?{available:!1,reason:"unsupported-environment"}:e.playbackMode!=="streaming"?{available:!0}:(t=e.capabilities)!=null&&t.supportsStreamingTts?typeof MediaSource>"u"||!Qx(e.ttsFormat).some(n=>MediaSource.isTypeSupported(n))?{available:!1,reason:"browser-streaming-unavailable"}:{available:!0}:{available:!1,reason:"provider-streaming-unavailable"}}const rm=new Map;let xn=null;function JR(e){var t;(t=rm.get(e))==null||t()}function om(e){if(!xn||e&&xn.ownerId!==e)return;const t=xn;xn=null,t.stop()}function Gb(e,t){if((xn==null?void 0:xn.ownerId)===e){xn={ownerId:e,stop:t};return}om(),xn={ownerId:e,stop:t}}function QR(e){const{t}=Dt(),{serverSettings:n}=Un(),[s,r]=R("idle");let o=0,a=null,i=null,c=null;Ze(()=>{Bc()});const l=()=>{c&&(c.abort(),c=null),a&&(a.pause(),a.currentTime=0,a.src="",a.load(),a=null),i&&(URL.revokeObjectURL(i),i=null)},d=()=>{o+=1,l(),r("idle")};rm.set(e.id(),d),dt(()=>{rm.delete(e.id()),om(e.id()),d()});const u=()=>typeof window<"u"&&typeof window.Audio<"u",f=()=>{var k;return{...n().speech,...((k=e.settingsOverride)==null?void 0:k.call(e))??{}}},g=()=>{const k=ao();return!u()||!(k!=null&&k.available)||!(k!=null&&k.ttsConfigured)||!(k!=null&&k.supportsTts)?!1:Wc({playbackMode:f().playbackMode,ttsFormat:f().ttsFormat,capabilities:k}).available},m=()=>{(xn==null?void 0:xn.ownerId)===e.id()&&(xn=null),d()},w=async()=>{const k=e.id(),C=e.text().trim();if(!C||s()==="loading"||s()==="playing")return;if(!u()){Ns(t("messageItem.actions.speak.error.unsupported"),{title:t("messageItem.actions.speak.error.title"),variant:"error"});return}const _=await Bc()??ao();if(!(_!=null&&_.available)||!(_!=null&&_.ttsConfigured)||!(_!=null&&_.supportsTts)){Ns(t("messageItem.actions.speak.error.unavailable"),{title:t("messageItem.actions.speak.error.title"),variant:"error"});return}const T=Wc({playbackMode:f().playbackMode,ttsFormat:f().ttsFormat,capabilities:_});if(!T.available){const ne=T.reason==="provider-streaming-unavailable"?"settings.speech.compatibility.streamingUnavailable":T.reason==="browser-streaming-unavailable"?"settings.speech.compatibility.browserStreamingUnavailable":"messageItem.actions.speak.error.unsupported";Ns(t("messageItem.actions.speak.error.unavailable"),{title:t("messageItem.actions.speak.error.title"),detail:t(ne),variant:"error"});return}o+=1;const P=o;om(),l(),r("loading");const I=f(),j=I.ttsFormat;try{I.playbackMode==="streaming"?await b(k,P,C,j):await S(k,P,C,j)}catch(ne){if(P!==o)return;d(),Ns(t("messageItem.actions.speak.error.generate"),{title:t("messageItem.actions.speak.error.title"),detail:ne instanceof Error?ne.message:String(ne),variant:"error"})}};async function S(k,C,_,T){const P=await kt.synthesizeSpeech({text:_,format:T});if(C!==o)return;const I=nO(P.audioBase64,P.mimeType),j=new Audio(I);i=I,a=j,Zb(k,j),Gb(k,()=>{l(),r("idle")}),r("playing"),await j.play()}async function b(k,C,_,T){if(typeof MediaSource>"u")throw new Error("MediaSource is not available in this browser.");const P=new AbortController;c=P;const I=await kt.synthesizeSpeechStream({text:_,format:T},P.signal),j=I.headers.get("content-type")||Jx(T);if(!MediaSource.isTypeSupported(j))throw new Error(`Streaming playback is not supported for ${j}.`);const ne=I.body;if(!ne)throw new Error("Speech stream did not include a response body.");const W=new MediaSource,q=URL.createObjectURL(W),U=new Audio(q);i=q,a=U,Zb(k,U),Gb(k,()=>{l(),r("idle")}),await new Promise((G,le)=>{const K=()=>{W.removeEventListener("sourceopen",K),XR({mediaSource:W,stream:ne,mimeType:j,audioElement:U,onPlayable:async()=>{if(C===o){s()!=="playing"&&r("playing");try{await U.play()}catch(M){le(M)}}},onComplete:G,onError:le})};W.addEventListener("sourceopen",K,{once:!0}),U.addEventListener("error",()=>le(new Error("Unable to play streamed speech.")),{once:!0})})}return{state:s,canUseSpeech:g,isLoading:()=>s()==="loading",isPlaying:()=>s()==="playing",toggle:async()=>{if(s()==="idle"){await w();return}m()},stop:m,buttonTitle:()=>s()==="loading"?t("messageItem.actions.generatingSpeech"):s()==="playing"?t("messageItem.actions.stopSpeech"):t("messageItem.actions.speak")}}function Zb(e,t){const n=()=>{(xn==null?void 0:xn.ownerId)===e&&(xn=null),JR(e)};t.addEventListener("ended",n,{once:!0}),t.addEventListener("error",n,{once:!0})}async function XR(e){try{const t=e.mediaSource.addSourceBuffer(e.mimeType),n=e.stream.getReader();let s=!1,r=[],o=!1;const a=async()=>{if(o||t.updating||r.length===0)return;o=!0;const i=r.shift();await eO(t,i),s||(s=!0,await e.onPlayable()),o=!1,await a()};for(;;){const{done:i,value:c}=await n.read();if(i)break;c&&c.byteLength>0&&(r.push(c),await a())}for(;r.length>0||t.updating;)r.length>0?await a():await tO(t);e.mediaSource.readyState==="open"&&e.mediaSource.endOfStream(),e.onComplete()}catch(t){e.onError(t)}}function eO(e,t){return new Promise((n,s)=>{const r=()=>{a(),n()},o=()=>{a(),s(new Error("Failed to append audio stream chunk."))},a=()=>{e.removeEventListener("updateend",r),e.removeEventListener("error",o)};e.addEventListener("updateend",r,{once:!0}),e.addEventListener("error",o,{once:!0}),e.appendBuffer(new Uint8Array(t).buffer)})}function tO(e){return new Promise(t=>{e.addEventListener("updateend",()=>t(),{once:!0})})}function nO(e,t){const n=atob(e),s=new Uint8Array(n.length);for(let r=0;r<n.length;r+=1)s[r]=n.charCodeAt(r);return URL.createObjectURL(new Blob([s],{type:t||"audio/mpeg"}))}async function sO(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let s="";for(const r of n)s+=String.fromCharCode(r);return btoa(s)}function rO(e){const n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(s=>typeof MediaRecorder.isTypeSupported!="function"||MediaRecorder.isTypeSupported(s));return n?new MediaRecorder(e,{mimeType:n}):new MediaRecorder(e)}function Yb(e){e==null||e.getTracks().forEach(t=>t.stop())}function oO(){const{t:e}=Dt(),[t,n]=R("idle"),[s,r]=R(null);let o=null,a=null,i=[],c=0,l=!1;const d=()=>{var v;return typeof window>"u"?!1:typeof window.MediaRecorder<"u"&&!!((v=navigator.mediaDevices)!=null&&v.getUserMedia)},u=()=>{const v=ao();return!!(d()&&(v!=null&&v.available)&&(v!=null&&v.sttConfigured)&&(v!=null&&v.supportsStt))},f=()=>{Yb(a),a=null},g=()=>{o&&o.state!=="inactive"&&o.stop(),o=null,f(),i=[]};dt(()=>{l=!0,c+=1,g()});const m=async()=>{var k,C;if(!d()){Ns(e("promptInput.voiceInput.error.unsupported"),{title:e("promptInput.voiceInput.error.title"),variant:"error"});return}const v=++c;n("requesting"),r(null);try{if(Bn()){const P=await((C=(k=window.electronAPI)==null?void 0:k.requestMicrophoneAccess)==null?void 0:C.call(k));if(P&&!P.granted)throw new Error(e("promptInput.voiceInput.error.permissionDenied"))}const _=await navigator.mediaDevices.getUserMedia({audio:!0});if(v!==c||l){Yb(_);return}i=[],a=_;const T=rO(_);o=T,T.addEventListener("dataavailable",P=>{P.data.size>0&&v===c&&i.push(P.data)}),T.addEventListener("error",()=>{v===c&&(g(),n("idle"))}),T.addEventListener("stop",()=>{v===c&&S(v)}),n("recording"),T.start()}catch(_){if(v!==c)return;g(),n("idle"),Ns(e("promptInput.voiceInput.error.permission"),{title:e("promptInput.voiceInput.error.title"),detail:_ instanceof Error?_.message:String(_),variant:"error"})}},w=()=>{!o||t()!=="recording"||(o.stop(),f(),n("transcribing"))},S=async v=>{var T;const k=i;i=[];const C=o;if(o=null,v!==c||k.length===0){v===c&&n("idle");return}const _=(C==null?void 0:C.mimeType)||((T=k[0])==null?void 0:T.type)||"audio/webm";try{const P=new Blob(k,{type:_}),I=await kt.transcribeAudio({audioBase64:await sO(P),mimeType:_});v===c&&r(I.text.trim()||e("settings.speech.testInput.empty"))}catch(P){v===c&&Ns(e("promptInput.voiceInput.error.transcribe"),{title:e("promptInput.voiceInput.error.title"),detail:P instanceof Error?P.message:String(P),variant:"error"})}finally{v===c&&n("idle")}};return{state:t,result:s,canUseTranscription:u,isRecording:()=>t()==="recording",isTranscribing:()=>t()==="transcribing",toggle:async()=>{if(t()==="recording"){w();return}t()==="idle"&&await m()},buttonTitle:()=>t()==="requesting"?e("settings.speech.testInput.requesting"):t()==="recording"?e("settings.speech.testInput.stop"):t()==="transcribing"?e("settings.speech.testInput.transcribing"):e("settings.speech.testInput.action")}}var iO=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><label class=settings-checkbox-toggle><input type=checkbox><span>'),Ug=O('<button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap">'),aO=O("<div class=settings-inline-note> "),Jb=O("<div class=settings-card-section-header><h4 class=settings-card-section-title>"),Kg=O("<div class=settings-inline-note>"),cO=O('<div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server"></span></div><div class=settings-stack><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><div class=settings-toolbar-inline><span class=settings-inline-note></span><span class=settings-inline-note></span><span class=settings-inline-note></span><button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap inline-flex items-center gap-2"><span></span></button><button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap inline-flex items-center gap-2"><span></span></button><button type=button class="selector-button selector-button-primary w-auto whitespace-nowrap"></button></div></div><div class=settings-inline-note></div><div class=settings-inline-note>'),lO=O("<span class=settings-inline-note>"),dO=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><div class="flex items-center gap-2 w-full min-w-0 sm:min-w-[18rem] sm:max-w-[24rem]"><input class="selector-input w-full">'),uO=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><div class="w-full min-w-0 sm:min-w-[18rem] sm:max-w-[24rem]"><select class="selector-input w-full">'),fO=O("<option>");const gO=Ut("actions");function Qb(e,t){const n=e[t];return{apiKey:"",baseUrl:n.baseUrl??"",model:n.model}}function Vg(e){return{separateProviders:e.separateProviders,apiKey:"",baseUrl:e.baseUrl??"",sttModel:e.sttModel,ttsModel:e.ttsModel,ttsVoice:e.ttsVoice,playbackMode:e.playbackMode,ttsFormat:e.ttsFormat,stt:Qb(e,"stt"),tts:Qb(e,"tts")}}function Xb(e,t){return e.apiKey===t.apiKey&&e.baseUrl===t.baseUrl&&e.model===t.model}function hO(e,t){return e.separateProviders===t.separateProviders&&e.apiKey===t.apiKey&&e.baseUrl===t.baseUrl&&e.sttModel===t.sttModel&&e.ttsModel===t.ttsModel&&e.ttsVoice===t.ttsVoice&&e.playbackMode===t.playbackMode&&e.ttsFormat===t.ttsFormat&&Xb(e.stt,t.stt)&&Xb(e.tts,t.tts)}const mO=()=>{const{t:e}=Dt(),{serverSettings:t,updateSpeechSettings:n}=Un(),s=Vg(t().speech),[r,o]=R(!1),[a,i]=R("saved"),[c,l]=R(s),[d,u]=R(!1),[f,g]=R(!1),[m,w]=R(!1),[S,b]=R(!1),[v,k]=R(!1),[C,_]=R(!1),T=QR({id:()=>"settings-speech-test",text:()=>e("settings.speech.testPlayback.sample"),settingsOverride:()=>({playbackMode:c().playbackMode,ttsFormat:c().ttsFormat})}),P=oO();Ze(()=>{const M=t().speech,N=Vg(M);if(!r()&&!G()){const oe=Eg()?N:{...N,separateProviders:!1};hO(c(),oe)||l(oe),d()&&u(!1),f()&&g(!1),m()&&w(!1),S()&&b(!1),v()&&k(!1),C()&&_(!1)}}),Ze(()=>{Bc()});const I=()=>{if(iM())return e("settings.speech.status.loading");if(aM())return e("settings.speech.status.error");const M=ao();return M!=null&&M.separateProviders?M.sttConfigured&&M.ttsConfigured?e("settings.speech.status.configured"):M.sttConfigured||M.ttsConfigured?e("settings.speech.status.partial"):e("settings.speech.status.missing"):M!=null&&M.configured?e("settings.speech.status.configured"):e("settings.speech.status.missing")},j=(M,N)=>{i("idle"),M==="apiKey"&&(u(!0),g(!1)),l(oe=>({...oe,[M]:N}))},ne=(M,N,oe)=>{i("idle"),N==="apiKey"&&(M==="stt"?(w(!0),b(!1)):(k(!0),_(!1))),l(ge=>({...ge,[M]:{...ge[M],[N]:oe}}))},W=Te(()=>f()||c().apiKey.trim().length>0),q=Te(()=>Wc({playbackMode:c().playbackMode,ttsFormat:c().ttsFormat,capabilities:ao()})),U=Te(()=>{const M=ao();return!(M!=null&&M.available)||!(M!=null&&M.ttsConfigured)||!(M!=null&&M.supportsTts)?null:c().playbackMode==="streaming"&&!M.supportsStreamingTts?e("settings.speech.compatibility.streamingUnavailable"):c().playbackMode==="streaming"&&!q().available?e("settings.speech.compatibility.browserStreamingUnavailable"):e("settings.speech.compatibility.runtimeNote")}),G=Te(()=>{const M=t().speech,N=c();if(N.separateProviders!==M.separateProviders)return!0;if(N.separateProviders){const oe=M.stt,ge=M.tts,Ie=S()||N.stt.apiKey.trim().length>0||(N.stt.baseUrl||"")!==(oe.baseUrl||"")||N.stt.model!==oe.model,ke=C()||N.tts.apiKey.trim().length>0||(N.tts.baseUrl||"")!==(ge.baseUrl||"")||N.tts.model!==ge.model||N.ttsVoice!==M.ttsVoice||N.playbackMode!==M.playbackMode||N.ttsFormat!==M.ttsFormat;return Ie||ke}return W()||(N.baseUrl||"")!==(M.baseUrl||"")||N.sttModel!==M.sttModel||N.ttsModel!==M.ttsModel||N.ttsVoice!==M.ttsVoice||N.playbackMode!==M.playbackMode||N.ttsFormat!==M.ttsFormat}),le=()=>r()?e("settings.speech.save.saving"):a()==="saved"?e("settings.speech.save.saved"):a()==="error"?e("settings.speech.save.error"):e("settings.speech.save.unsaved");async function K(){if(!G()||r())return;const M=c(),N=t().speech;o(!0),i("idle");try{if(M.separateProviders)await n({separateProviders:!0,stt:Hb(S(),M.stt.apiKey,M.stt.baseUrl,M.stt.model,N.stt.baseUrl,N.sttModel),tts:Hb(C(),M.tts.apiKey,M.tts.baseUrl,M.tts.model,N.tts.baseUrl,N.ttsModel),...M.sttModel!==N.sttModel?{sttModel:M.sttModel.trim()||null}:{},...M.ttsModel!==N.ttsModel?{ttsModel:M.ttsModel.trim()||null}:{},...M.baseUrl!==(N.baseUrl||"")?{baseUrl:M.baseUrl.trim()||null,...f()?{}:M.apiKey.trim()?{}:{apiKey:null}}:{},...f()?{apiKey:null}:M.apiKey.trim()?{apiKey:M.apiKey.trim()}:{},ttsVoice:M.ttsVoice.trim()||null,playbackMode:M.playbackMode,ttsFormat:M.ttsFormat});else{const oe=M.apiKey.trim(),ge=(M.baseUrl.trim()||"")!==(N.baseUrl||"");await n({separateProviders:!1,...f()?{apiKey:null}:oe?{apiKey:oe}:ge?{apiKey:null}:{},...ge?{baseUrl:M.baseUrl.trim()||null}:{},sttModel:M.sttModel.trim()||null,ttsModel:M.ttsModel.trim()||null,ttsVoice:M.ttsVoice.trim()||null,playbackMode:M.playbackMode,ttsFormat:M.ttsFormat})}await Bc(!0),l(Vg(t().speech)),u(!1),g(!1),w(!1),b(!1),k(!1),_(!1),i("saved")}catch(oe){gO.error("Failed to save speech settings",oe),i("error")}finally{o(!1)}}return(()=>{var M=cO(),N=M.firstChild,oe=N.firstChild,ge=oe.firstChild,Ie=ge.firstChild,ke=Ie.nextSibling,we=oe.nextSibling,Ae=N.nextSibling,Ge=Ae.firstChild,H=Ge.firstChild,h=H.firstChild,$=h.nextSibling,D=H.nextSibling,E=D.firstChild,Z=E.nextSibling,B=Z.nextSibling,se=B.nextSibling,pe=se.firstChild,Se=se.nextSibling,Q=Se.firstChild,be=Se.nextSibling,Ve=Ge.nextSibling,He=Ve.nextSibling;return p(oe,y(Kh,{class:"settings-card-heading-icon"}),ge),p(Ie,()=>e("settings.speech.title")),p(ke,()=>e("settings.speech.subtitle")),p(we,()=>e("settings.scope.server")),p(h,()=>e("settings.speech.provider.title")),p($,()=>e("settings.speech.provider.subtitle")),p(E,()=>e("settings.speech.provider.openaiCompatible")),p(Z,I),p(B,le),se.$$click=()=>void P.toggle(),p(se,y(ee,{get when(){return P.isTranscribing()||P.state()==="requesting"},get fallback(){return y(ee,{get when(){return P.isRecording()},get fallback(){return y(Ig,{class:"w-3.5 h-3.5","aria-hidden":"true"})},get children(){return y(db,{class:"w-3.5 h-3.5","aria-hidden":"true"})}})},get children(){return y(Zn,{class:"w-3.5 h-3.5 animate-spin","aria-hidden":"true"})}}),pe),p(pe,()=>P.buttonTitle()),p(D,y(ee,{get when(){return P.result()},children:re=>(()=>{var F=lO();return p(F,(()=>{var V=Ee(()=>re().length>40);return()=>V()?`${re().slice(0,40)}…`:re()})()),de(()=>me(F,"title",re())),F})()}),Se),Se.$$click=()=>void T.toggle(),p(Se,y(ee,{get when(){return T.isLoading()},get fallback(){return y(ee,{get when(){return T.isPlaying()},get fallback(){return y(Kh,{class:"w-3.5 h-3.5","aria-hidden":"true"})},get children(){return y(db,{class:"w-3.5 h-3.5","aria-hidden":"true"})}})},get children(){return y(Zn,{class:"w-3.5 h-3.5 animate-spin","aria-hidden":"true"})}}),Q),p(Q,(()=>{var re=Ee(()=>!!T.isPlaying());return()=>re()?e("settings.speech.testPlayback.stop"):Ee(()=>!!T.isLoading())()?e("settings.speech.testPlayback.generating"):e("settings.speech.testPlayback.action")})()),be.$$click=()=>void K(),p(be,(()=>{var re=Ee(()=>!!r());return()=>re()?e("settings.speech.save.saving"):e("settings.speech.save.action")})()),p(Ae,y(ee,{get when(){return Eg()},get children(){var re=iO(),F=re.firstChild,V=F.firstChild,Me=V.nextSibling,xe=F.nextSibling,Re=xe.firstChild,Be=Re.nextSibling;return p(V,()=>e("settings.speech.separateProviders.title")),p(Me,()=>e("settings.speech.separateProviders.subtitle")),Re.addEventListener("change",et=>{i("idle"),l(Ue=>({...Ue,separateProviders:et.currentTarget.checked}))}),p(Be,()=>e("settings.common.enabled")),de(()=>Re.disabled=r()),de(()=>Re.checked=c().separateProviders),re}}),Ve),p(Ae,y(ee,{get when(){return!c().separateProviders},get children(){return[y(ys,{get label(){return e("settings.speech.apiKey.title")},get caption(){return e("settings.speech.apiKey.subtitle")},get value(){return c().apiKey},onInput:re=>j("apiKey",re),type:"password",get placeholder(){return Ee(()=>!!t().speech.hasApiKey)()?e("settings.speech.apiKey.placeholder"):void 0}}),y(ee,{get when(){return Ee(()=>!!(t().speech.hasApiKey&&!d()))()&&c().apiKey.length===0},get children(){var re=aO(),F=re.firstChild;return p(re,(()=>{var V=Ee(()=>!!f());return()=>V()?e("settings.speech.apiKey.clearPending"):e("settings.speech.apiKey.storedNote")})(),F),p(re,y(ee,{get when(){return!f()},get children(){var V=Ug();return V.$$click=()=>{g(!0),i("idle")},p(V,()=>e("settings.speech.apiKey.clearAction")),V}}),null),re}}),y(ys,{get label(){return e("settings.speech.baseUrl.title")},get caption(){return e("settings.speech.baseUrl.subtitle")},get value(){return c().baseUrl},onInput:re=>j("baseUrl",re),get placeholder(){return e("settings.speech.baseUrl.placeholder")}}),y(ys,{get label(){return e("settings.speech.sttModel.title")},get caption(){return e("settings.speech.sttModel.subtitle")},get value(){return c().sttModel},onInput:re=>j("sttModel",re)}),y(ys,{get label(){return e("settings.speech.ttsModel.title")},get caption(){return e("settings.speech.ttsModel.subtitle")},get value(){return c().ttsModel},onInput:re=>j("ttsModel",re)}),y(ys,{get label(){return e("settings.speech.ttsVoice.title")},get caption(){return e("settings.speech.ttsVoice.subtitle")},get value(){return c().ttsVoice},onInput:re=>j("ttsVoice",re),get icon(){return y(Ig,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"})}})]}}),Ve),p(Ae,y(ee,{get when(){return Ee(()=>!!c().separateProviders)()&&Eg()},get children(){return[(()=>{var re=Jb(),F=re.firstChild;return p(F,()=>e("settings.speech.stt.section.title")),re})(),y(ys,{get label(){return e("settings.speech.stt.apiKey.title")},get caption(){return e("settings.speech.stt.apiKey.subtitle")},get value(){return c().stt.apiKey},onInput:re=>ne("stt","apiKey",re),type:"password",get placeholder(){return Ee(()=>!!(t().speech.stt.hasApiKey||t().speech.hasApiKey))()?e("settings.speech.stt.apiKey.placeholder"):void 0}}),y(ee,{get when(){return Ee(()=>!!((t().speech.stt.hasApiKey||t().speech.hasApiKey)&&!m()))()&&c().stt.apiKey.length===0},get children(){var re=Kg();return p(re,y(ee,{get when(){return t().speech.stt.hasApiKey},get fallback(){return e("settings.speech.stt.apiKey.usingShared")},get children(){return[Ee(()=>Ee(()=>!!S())()?e("settings.speech.stt.apiKey.clearPending"):e("settings.speech.stt.apiKey.storedNote"))," ",y(ee,{get when(){return!S()},get children(){var F=Ug();return F.$$click=()=>{b(!0),i("idle")},p(F,()=>e("settings.speech.stt.apiKey.clearAction")),F}})]}})),re}}),y(ys,{get label(){return e("settings.speech.stt.baseUrl.title")},get caption(){return e("settings.speech.stt.baseUrl.subtitle")},get value(){return c().stt.baseUrl},onInput:re=>ne("stt","baseUrl",re),get placeholder(){return e("settings.speech.stt.baseUrl.placeholder")}}),y(ys,{get label(){return e("settings.speech.stt.model.title")},get caption(){return e("settings.speech.stt.model.subtitle")},get value(){return c().stt.model},onInput:re=>ne("stt","model",re)}),(()=>{var re=Jb(),F=re.firstChild;return p(F,()=>e("settings.speech.tts.section.title")),re})(),y(ys,{get label(){return e("settings.speech.tts.apiKey.title")},get caption(){return e("settings.speech.tts.apiKey.subtitle")},get value(){return c().tts.apiKey},onInput:re=>ne("tts","apiKey",re),type:"password",get placeholder(){return Ee(()=>!!(t().speech.tts.hasApiKey||t().speech.hasApiKey))()?e("settings.speech.tts.apiKey.placeholder"):void 0}}),y(ee,{get when(){return Ee(()=>!!((t().speech.tts.hasApiKey||t().speech.hasApiKey)&&!v()))()&&c().tts.apiKey.length===0},get children(){var re=Kg();return p(re,y(ee,{get when(){return t().speech.tts.hasApiKey},get fallback(){return e("settings.speech.tts.apiKey.usingShared")},get children(){return[Ee(()=>Ee(()=>!!C())()?e("settings.speech.tts.apiKey.clearPending"):e("settings.speech.tts.apiKey.storedNote"))," ",y(ee,{get when(){return!C()},get children(){var F=Ug();return F.$$click=()=>{_(!0),i("idle")},p(F,()=>e("settings.speech.tts.apiKey.clearAction")),F}})]}})),re}}),y(ys,{get label(){return e("settings.speech.tts.baseUrl.title")},get caption(){return e("settings.speech.tts.baseUrl.subtitle")},get value(){return c().tts.baseUrl},onInput:re=>ne("tts","baseUrl",re),get placeholder(){return e("settings.speech.tts.baseUrl.placeholder")}}),y(ys,{get label(){return e("settings.speech.tts.model.title")},get caption(){return e("settings.speech.tts.model.subtitle")},get value(){return c().tts.model},onInput:re=>ne("tts","model",re)}),y(ys,{get label(){return e("settings.speech.ttsVoice.title")},get caption(){return e("settings.speech.ttsVoice.subtitle")},get value(){return c().ttsVoice},onInput:re=>j("ttsVoice",re),get icon(){return y(Ig,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"})}})]}}),Ve),p(Ae,y(e0,{get label(){return e("settings.speech.playbackMode.title")},get caption(){return e("settings.speech.playbackMode.subtitle")},get value(){return c().playbackMode},onInput:re=>j("playbackMode",re),get options(){return[{value:"streaming",label:e("settings.speech.playbackMode.streaming")},{value:"buffered",label:e("settings.speech.playbackMode.buffered")}]}}),Ve),p(Ae,y(e0,{get label(){return e("settings.speech.ttsFormat.title")},get caption(){return e("settings.speech.ttsFormat.subtitle")},get value(){return c().ttsFormat},onInput:re=>j("ttsFormat",re),options:[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"opus",label:"Opus"},{value:"aac",label:"AAC"}]}),Ve),p(Ve,()=>e("settings.speech.help")),p(Ae,y(ee,{get when(){return U()},children:re=>(()=>{var F=Kg();return p(F,re),F})()}),He),p(He,()=>e("settings.speech.testPlayback.note")),de(re=>{var F=r()&&P.state()!=="recording"||P.state()==="requesting"||P.state()==="transcribing"||P.state()==="idle"&&!P.canUseTranscription(),V=P.buttonTitle(),Me=P.buttonTitle(),xe=r(),Re=T.buttonTitle(),Be=T.buttonTitle(),et=!G()||r();return F!==re.e&&(se.disabled=re.e=F),V!==re.t&&me(se,"title",re.t=V),Me!==re.a&&me(se,"aria-label",re.a=Me),xe!==re.o&&(Se.disabled=re.o=xe),Re!==re.i&&me(Se,"title",re.i=Re),Be!==re.n&&me(Se,"aria-label",re.n=Be),et!==re.s&&(be.disabled=re.s=et),re},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),M})()},ys=e=>(()=>{var t=dO(),n=t.firstChild,s=n.firstChild,r=s.nextSibling,o=n.nextSibling,a=o.firstChild;return p(s,()=>e.label),p(r,()=>e.caption),p(o,()=>e.icon,a),a.$$input=i=>e.onInput(i.currentTarget.value),de(i=>{var c=e.type??"text",l=e.placeholder;return c!==i.e&&me(a,"type",i.e=c),l!==i.t&&me(a,"placeholder",i.t=l),i},{e:void 0,t:void 0}),de(()=>a.value=e.value),t})(),e0=e=>(()=>{var t=uO(),n=t.firstChild,s=n.firstChild,r=s.nextSibling,o=n.nextSibling,a=o.firstChild;return p(s,()=>e.label),p(r,()=>e.caption),a.$$input=i=>e.onInput(i.currentTarget.value),p(a,y(zt,{get each(){return e.options},children:i=>(()=>{var c=fO();return p(c,()=>i.label),de(()=>c.value=i.value),c})()})),de(()=>a.value=e.value),t})();Xt(["click","input"]);var pO=O("<div class=settings-section-stack><div class=settings-card><div class=settings-stack>");const yO=()=>{const e=Un(),t=Te(()=>ry(e).filter(n=>n.id==="behavior.promptVoiceInput"));return(()=>{var n=pO(),s=n.firstChild,r=s.firstChild;return p(r,y(oy,{settings:t,get preferences(){return e.preferences}})),p(n,y(mO,{}),null),n})()};function Xx(e,t){if(!e)return t;const n=e.metadata??{},s=t.metadata??{};return{...e,...t,metadata:{...n,...s},source:t.source??e.source}}function vO(e){return(e==null?void 0:e.id)??""}function ua(e){return e==null?void 0:e.sessionID}function wO(e){var t;return(t=e==null?void 0:e.source)==null?void 0:t.messageID}function bO(e){var t;return(t=e==null?void 0:e.source)==null?void 0:t.id}function e_(e){return(e==null?void 0:e.action)??"permission"}function SO(e){return(e==null?void 0:e.resources.filter(t=>typeof t=="string"))??[]}function EH(e){const t=e_(e),n=SO(e);return n.length>0?`${t}: ${n.join(", ")}`:t}function kO(e){return e==null?void 0:e.requestID}var xO=Object.defineProperty,_O=e=>e;function $O(e,t){this[e]=_O.bind(null,t)}var fy=(e,t)=>{for(var n in t)xO(e,n,{get:t[n],enumerable:!0,configurable:!0,set:$O.bind(t,n)})},t0={};fy(t0,{SharedEvents:()=>t0,make:()=>t_});function t_(e){let t;function s(o){o.connected=void 0,o.controller.abort(),t===o&&(t=void 0)}async function r(o){var c;let a,i={};try{if(o.controller.signal.aborted)return;for(a=e(o.controller.signal,()=>{o.subscribers.forEach(l=>{var d;return(d=l.activity)==null?void 0:d.call(l)})})[Symbol.asyncIterator]();!o.controller.signal.aborted;){const l=await a.next();if(l.done||o.controller.signal.aborted)break;l.value.type==="server.connected"&&(o.connected=l.value),o.subscribers.forEach(d=>d.push(l.value))}}catch(l){i={error:l}}finally{s(o);try{await((c=a==null?void 0:a.return)==null?void 0:c.call(a))}catch(l){"error"in i||(i={error:l})}o.subscribers.forEach(l=>l.finish(i))}}return{subscribe(o){return{[Symbol.asyncIterator](){const a=[],i=[];let c=!1,l,d;function u(w,S=!0){var b;l=w,S&&(i.length=0),(b=o==null?void 0:o.signal)==null||b.removeEventListener("abort",f),d!=null&&d.subscribers.delete(g)&&!d.subscribers.size&&s(d),a.splice(0).forEach(v=>{"error"in w?v.reject(w.error):v.resolve({done:!0,value:void 0})})}function f(){u({})}const g={activity:o==null?void 0:o.onActivity,finish(w){u(w,!1)},push(w){if(l)return;const S=a.shift();if(S){S.resolve({done:!1,value:w});return}if(i.length===4096){u({error:new Error("Event subscriber exceeded its 4096-event capacity")});return}i.push(w)}};function m(){if(l)return;const w=!t;d=t??{controller:new AbortController,subscribers:new Set},t=d,d.subscribers.add(g),d.connected&&g.push(d.connected),w&&r(d)}return{next(){var b,v;const w=i.shift();if(w)return Promise.resolve({done:!1,value:w});if(l)return"error"in l?Promise.reject(l.error):Promise.resolve({done:!0,value:void 0});if((b=o==null?void 0:o.signal)!=null&&b.aborted)return f(),Promise.resolve({done:!0,value:void 0});const S=Promise.withResolvers();return a.push(S),c||(c=!0,(v=o==null?void 0:o.signal)==null||v.addEventListener("abort",f,{once:!0}),m()),S.promise},return(){return u({}),Promise.resolve({done:!0,value:void 0})}}}}}}}class Ls extends Error{constructor(n,s){const r=(s==null?void 0:s.detail)??((s==null?void 0:s.cause)instanceof Error?s.cause.message:void 0);super(r?`${n}: ${r}`:n,s);ae(this,"reason");ae(this,"name","ClientError");this.reason=n}}var CO={};fy(CO,{make:()=>n_});var EO=16*1024*1024;function n_(e){const t=e.fetch??globalThis.fetch,n=(i,c)=>{const l=new URL(e.baseUrl);l.pathname.endsWith("/")||(l.pathname+="/");const d=new URL(i.path.slice(1),l);for(const[f,g]of Object.entries(i.query??{}))im(d.searchParams,f,g);const u=new Headers(e.headers);for(const[f,g]of Object.entries(i.headers??{}))g!=null&&u.set(f,String(g));for(const[f,g]of new Headers(c==null?void 0:c.headers))u.set(f,g);return i.body!==void 0&&!u.has("content-type")&&u.set("content-type",i.binaryBody?"application/octet-stream":"application/json"),{url:d,init:{method:i.method,signal:c==null?void 0:c.signal,headers:u,body:i.body===void 0?void 0:i.binaryBody?i.body:JSON.stringify(i.body)}}},s=async(i,c)=>{try{const l=n(i,c);return await t(l.url,l.init)}catch(l){throw new Ls("Transport",{cause:l})}},r=async(i,c)=>{var l;if(c.declaredStatuses.includes(i.status))throw MO(await n0(i));try{await((l=i.body)==null?void 0:l.cancel())}catch{}throw new Ls("UnexpectedStatus",{cause:{status:i.status},detail:String(i.status)})},o=async(i,c)=>{var d;const l=await s(i,c);if(l.status!==i.successStatus)return r(l,i);if(i.binary)return new Uint8Array(await l.arrayBuffer());if(i.empty){try{await((d=l.body)==null?void 0:d.cancel())}catch{}return}return await n0(l)},a=(i,c)=>({async*[Symbol.asyncIterator](){var g,m;const l=await s(i,c);if(l.status!==i.successStatus&&await r(l,i),!s_(l,"text/event-stream")){try{await((g=l.body)==null?void 0:g.cancel())}catch{}throw new Ls("UnsupportedContentType",{detail:l.headers.get("content-type")})}if(l.body===null)throw new Ls("MalformedResponse");const d=l.body.getReader(),u=new TextDecoder;let f="";try{for(;;){let w;try{w=await d.read()}catch(v){throw new Ls("Transport",{cause:v})}if(w.done||(m=c==null?void 0:c.onActivity)==null||m.call(c),f+=u.decode(w.value,{stream:!w.done}),f.length>EO)throw new Ls("SseEventTooLarge");const S=!w.done&&f.endsWith("\r");S&&(f=f.slice(0,-1)),f=f.replaceAll(`\r
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/startup-state-settings-card-BCKRPH7W.js","assets/monaco-viewer-BQXd7g3w.js","assets/git-diff-vendor-CT8HfOQw.js","assets/fast-diff-vendor-DgdwVvTQ.js","assets/highlight-vendor-8FKMu9os.js","assets/git-diff-vendor-HAZkIolJ.css","assets/index-ByEDZSKg.js","assets/index-NCKXobfr.css","assets/client-state-BUfw9mlB.js","assets/index-cCIfI5Gs.js","assets/index-QPxBkmUK.js","assets/App-DJjznRZ_.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var GT=Object.defineProperty;var ZT=(e,t,n)=>t in e?GT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>ZT(e,typeof t!="symbol"?t+"":t,n);import{u as Dt,i as Ms,c as YT,a as Bn,b as Dn,r as $n,l as Xu,_ as ls,t as $e,d as Mh,e as $p,f as ia,g as Cp,h as JT,j as QT,p as Aw,I as XT}from"./index-ByEDZSKg.js";import{c as Ep,p as pt,t as O,i as p,s as kr,a as ws,b as lr,u as dr,m as Ee,d as me,D as Tp,P as Mp,e as Xt,f as $g,g as Cg,h as Ut,j as xs,k as kt,l as lk,n as Un,o as eM,q as tM,r as Dw,B as nM,v as sM,L as rM,w as oM,x as Ui,y as Pw,z as Bc,A as ao,C as Eg,E as iM,F as aM,G as cM,H as lM,I as dM,J as uM,K as Sr,M as Ap,N as dk,O as ef,Q as fM,R as gM,S as Dp,T as hM,U as mM,V as Iw,W as Rw,X as pM,Y as yM,Z as vM,_ as wM}from"./monaco-viewer-BQXd7g3w.js";import{b as Uc,e as R,u as aa,d as Ze,o as dt,k as y,F as zt,a as de,M as Ki,p as _e,w as uk,c as Te,n as Ys,i as bM,s as Nt,x as yi,l as qr,m as zr,t as Do,S as ee,v as fk,y as gk,z as hk,A as mk,h as gn,B as SM}from"./git-diff-vendor-CT8HfOQw.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";const kM=e=>typeof e=="function",jd=(e,t)=>kM(e)?e(t):e;var dn;(function(e){e[e.ADD_TOAST=0]="ADD_TOAST",e[e.UPDATE_TOAST=1]="UPDATE_TOAST",e[e.UPSERT_TOAST=2]="UPSERT_TOAST",e[e.DISMISS_TOAST=3]="DISMISS_TOAST",e[e.REMOVE_TOAST=4]="REMOVE_TOAST",e[e.START_PAUSE=5]="START_PAUSE",e[e.END_PAUSE=6]="END_PAUSE"})(dn||(dn={}));const[Go,Yr]=Ep({toasts:[],pausedAt:void 0}),xM=()=>{const{pausedAt:e,toasts:t}=Go;if(e)return;const n=Date.now();return t.map(r=>{if(r.duration===1/0)return;const o=(r.duration||0)+r.pauseDuration-(n-r.createdAt);if(o<=0){r.visible&&Ks({type:dn.DISMISS_TOAST,toastId:r.id});return}return setTimeout(()=>{Ks({type:dn.DISMISS_TOAST,toastId:r.id})},o)})},Tc=new Map,Ow=(e,t)=>{if(Tc.has(e))return;const n=setTimeout(()=>{Tc.delete(e),Ks({type:dn.REMOVE_TOAST,toastId:e})},t);Tc.set(e,n)},_M=e=>{const t=Tc.get(e);Tc.delete(e),t&&clearTimeout(t)},Ks=e=>{switch(e.type){case dn.ADD_TOAST:Yr("toasts",r=>{const o=r;return[e.toast,...o]});break;case dn.DISMISS_TOAST:const{toastId:t}=e,n=Go.toasts;if(t){const r=n.find(o=>o.id===t);r&&Ow(t,r.unmountDelay),Yr("toasts",o=>o.id===t,pt(o=>o.visible=!1))}else n.forEach(r=>{Ow(r.id,r.unmountDelay)}),Yr("toasts",r=>r.id!==void 0,pt(r=>r.visible=!1));break;case dn.REMOVE_TOAST:if(!e.toastId){Yr("toasts",[]);break}Yr("toasts",r=>r.filter(a=>a.id!==e.toastId));break;case dn.UPDATE_TOAST:e.toast.id&&_M(e.toast.id),Yr("toasts",r=>r.id===e.toast.id,r=>({...r,...e.toast}));break;case dn.UPSERT_TOAST:Go.toasts.find(r=>r.id===e.toast.id)?Ks({type:dn.UPDATE_TOAST,toast:e.toast}):Ks({type:dn.ADD_TOAST,toast:e.toast});break;case dn.START_PAUSE:Yr(pt(r=>{r.pausedAt=Date.now(),r.toasts.forEach(o=>{o.paused=!0})}));break;case dn.END_PAUSE:const s=e.time-(Go.pausedAt||0);Yr(pt(r=>{r.pausedAt=void 0,r.toasts.forEach(o=>{o.pauseDuration+=s,o.paused=!1})}));break}},$M={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Gi={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},pk={position:"top-right",toastOptions:Gi,gutter:8,containerStyle:{},containerClassName:""},Gl="16px",CM={position:"fixed","z-index":9999,top:Gl,bottom:Gl,left:Gl,right:Gl,"pointer-events":"none"},EM=(()=>{let e=0;return()=>String(++e)})(),TM=e=>{OM(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},MM=(e,t)=>{const s=e.includes("top")?{top:0,"margin-top":`${t}px`}:{bottom:0,"margin-bottom":`${t}px`},r=e.includes("center")?{"justify-content":"center"}:e.includes("right")?{"justify-content":"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:"all 230ms cubic-bezier(.21,1.02,.73,1)",...s,...r}},AM=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Ks({type:dn.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},DM=(e,t)=>{const{toasts:n}=Go,s=Oi().gutter||pk.gutter||8,r=n.filter(c=>(c.position||t)===t&&c.height),o=r.findIndex(c=>c.id===e.id),a=r.filter((c,l)=>l<o&&c.visible).length;return r.slice(0,a).reduce((c,l)=>c+s+(l.height||0),0)},PM=(e,t)=>(e.position||t).includes("top")?1:-1,IM={display:"flex","align-items":"center",color:"#363636",background:"white","box-shadow":"0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)","max-width":"350px","pointer-events":"auto",padding:"8px 10px","border-radius":"4px","line-height":"1.3","will-change":"transform"},RM={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},Zl={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},qd=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[Oi,OM]=R(pk),LM=(e,t="blank",n)=>{var s,r,o;return{...Gi,...Oi().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||EM(),paused:!1,style:{...Gi.style,...(s=Oi().toastOptions)==null?void 0:s.style,...n.style},duration:n.duration||((r=Oi().toastOptions)==null?void 0:r.duration)||$M[t],position:n.position||((o=Oi().toastOptions)==null?void 0:o.position)||Oi().position||Gi.position}},hl=e=>(t,n={})=>Uc(()=>{const s=Go.toasts.find(o=>o.id===n.id),r=LM(t,e,{...s,duration:void 0,...n});return Ks({type:dn.UPSERT_TOAST,toast:r}),r.id}),jn=(e,t)=>hl("blank")(e,t);aa(()=>jn);jn.error=hl("error");jn.success=hl("success");jn.loading=hl("loading");jn.custom=hl("custom");jn.dismiss=e=>{Ks({type:dn.DISMISS_TOAST,toastId:e})};jn.promise=(e,t,n)=>{const s=jn.loading(t.loading,{...n});return e.then(r=>(jn.success(jd(t.success,r),{id:s,...n}),r)).catch(r=>{jn.error(jd(t.error,r),{id:s,...n})}),e};jn.remove=e=>{Ks({type:dn.REMOVE_TOAST,toastId:e})};var NM=O("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const FM=e=>(Ze(()=>{TM(e)}),Ze(()=>{const t=xM();dt(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=NM();return t.firstChild,p(t,y(zt,{get each(){return Go.toasts},children:n=>y(VM,{toast:n})}),null),de(n=>{var s={...CM,...e.containerStyle},r=e.containerClassName;return n.e=kr(t,s,n.e),r!==n.t&&ws(t,n.t=r),n},{e:void 0,t:void 0}),t})());var Yl=O("<div>"),BM=O("<div><div>");const UM=e=>{let t;return Ze(()=>{if(!t)return;const n=PM(e.toast,e.position);e.toast.visible?t.animate([{transform:`translate3d(0,${n*-200}%,0) scale(.6)`,opacity:.5},{transform:"translate3d(0,0,0) scale(1)",opacity:1}],{duration:350,fill:"forwards",easing:"cubic-bezier(.21,1.02,.73,1)"}):t.animate([{transform:"translate3d(0,0,-1px) scale(1)",opacity:1},{transform:`translate3d(0,${n*-150}%,-1px) scale(.4)`,opacity:0}],{duration:400,fill:"forwards",easing:"cubic-bezier(.06,.71,.55,1)"})}),(()=>{var n=BM(),s=n.firstChild,r=t;return typeof r=="function"?dr(r,n):t=n,p(n,y(uk,{get children(){return[y(Ki,{get when(){return e.toast.icon},get children(){var o=Yl();return p(o,()=>e.toast.icon),de(a=>kr(o,Zl,a)),o}}),y(Ki,{get when(){return e.toast.type==="loading"},get children(){var o=Yl();return p(o,y(YM,_e(()=>e.toast.iconTheme))),de(a=>kr(o,Zl,a)),o}}),y(Ki,{get when(){return e.toast.type==="success"},get children(){var o=Yl();return p(o,y(WM,_e(()=>e.toast.iconTheme))),de(a=>kr(o,Zl,a)),o}}),y(Ki,{get when(){return e.toast.type==="error"},get children(){var o=Yl();return p(o,y(GM,_e(()=>e.toast.iconTheme))),de(a=>kr(o,Zl,a)),o}})]}}),s),lr(s,_e(()=>e.toast.ariaProps),!1,!0),p(s,()=>jd(e.toast.message,e.toast)),de(o=>{var a=e.toast.className,i={...IM,...e.toast.style},c=RM;return a!==o.e&&ws(n,o.e=a),o.t=kr(n,i,o.t),o.a=kr(s,c,o.a),o},{e:void 0,t:void 0,a:void 0}),n})()};var KM=O("<div>");const VM=e=>{const t=()=>{const r=e.toast.position||Gi.position,o=DM(e.toast,r);return MM(r,o)},n=Te(()=>t());let s;return Ys(()=>{s&&AM(s,e.toast)}),(()=>{var r=KM();r.addEventListener("mouseleave",()=>Ks({type:dn.END_PAUSE,time:Date.now()})),r.addEventListener("mouseenter",()=>Ks({type:dn.START_PAUSE,time:Date.now()}));var o=s;return typeof o=="function"?dr(o,r):s=r,p(r,(()=>{var a=Ee(()=>e.toast.type==="custom");return()=>a()?jd(e.toast.message,e.toast):y(UM,{get toast(){return e.toast},get position(){return e.toast.position||Gi.position}})})()),de(a=>{var i=n(),c=e.toast.visible?"sldt-active":"";return a.e=kr(r,i,a.e),c!==a.t&&ws(r,a.t=c),a},{e:void 0,t:void 0}),r})()};var jM=O('<svg><circle cx=16 cy=16 r=0><animate attributeName=opacity values="0; 1; 1"></animate><animate attributeName=r values="0; 17.5; 16"></svg>',!1,!0,!1),qM=O('<svg><circle cx=16 cy=16 r=12 opacity=0><animate attributeName=opacity values="1; 0"></animate><animate attributeName=r values="12; 26"></svg>',!1,!0,!1);const yk=e=>{const t={dur:"0.35s",begin:"100ms",fill:"freeze",calcMode:"spline",keyTimes:"0; 0.6; 1",keySplines:"0.25 0.71 0.4 0.88; .59 .22 .87 .63"};return(()=>{var n=jM(),s=n.firstChild,r=s.nextSibling;return lr(s,t,!0,!1),lr(r,t,!0,!1),de(()=>me(n,"fill",e.fill)),n})()},vk=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...qd("0.0 0.0 0.2 1")};return(()=>{var n=qM(),s=n.firstChild,r=s.nextSibling;return lr(s,t,!0,!1),lr(r,t,!0,!1),de(()=>me(n,"fill",e.fill)),n})()};var zM=O('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-dasharray=22 stroke-dashoffset=22 stroke-linecap=round stroke-miterlimit=10 d=M9.8,17.2l3.8,3.6c0.1,0.1,0.3,0.1,0.4,0l9.6-9.7><animate attributeName=stroke-dashoffset values=22;0 dur=0.25s begin=250ms fill=freeze>');const WM=e=>{const t=e.primary||"#34C759";return(()=>{var n=zM(),s=n.firstChild,r=s.firstChild;return p(n,y(yk,{fill:t}),s),p(n,y(vk,{fill:t,begin:"350ms"}),s),lr(r,_e(()=>qd("0.0, 0.0, 0.58, 1.0")),!0,!1),de(()=>me(s,"stroke",e.secondary||"#FCFCFC")),n})()};var HM=O('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-dasharray=9 stroke-dashoffset=9 stroke-linecap=round d=M16,7l0,9><animate attributeName=stroke-dashoffset values=9;0 dur=0.2s begin=250ms fill=freeze></animate></path><circle cx=16 cy=23 r=2.5 opacity=0><animate attributeName=opacity values=0;1 dur=0.25s begin=350ms fill=freeze>');const GM=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=HM(),s=n.firstChild,r=s.firstChild,o=s.nextSibling,a=o.firstChild;return p(n,y(yk,{fill:t}),s),p(n,y(vk,{fill:t}),s),lr(r,_e(()=>qd("0.0, 0.0, 0.58, 1.0")),!0,!1),lr(a,_e(()=>qd("0.0, 0.0, 0.58, 1.0")),!0,!1),de(i=>{var c=e.secondary||"#FFFFFF",l=e.secondary||"#FFFFFF";return c!==i.e&&me(s,"stroke",i.e=c),l!==i.t&&me(o,"fill",i.t=l),i},{e:void 0,t:void 0}),n})()};var ZM=O('<svg viewBox="0 0 32 32"width=1.25rem height=1.25rem style=overflow:visible><path fill=none stroke-width=4 stroke-miterlimit=10 d=M16,6c3,0,5.7,1.3,7.5,3.4c1.5,1.8,2.5,4,2.5,6.6c0,5.5-4.5,10-10,10S6,21.6,6,16S10.5,6,16,6z></path><path fill=none stroke-width=4 stroke-linecap=round stroke-miterlimit=10 d=M16,6c3,0,5.7,1.3,7.5,3.4c0.6,0.7,1.1,1.4,1.5,2.2><animateTransform attributeName=transform type=rotate from="0 16 16"to="360 16 16"dur=0.75s repeatCount=indefinite>');const YM=e=>(()=>{var t=ZM(),n=t.firstChild,s=n.nextSibling;return de(r=>{var o=e.primary||"#E5E7EB",a=e.secondary||"#4b5563";return o!==r.e&&me(n,"stroke",r.e=o),a!==r.t&&me(s,"stroke",r.t=a),r},{e:void 0,t:void 0}),t})();function JM(e){return(...t)=>{for(const n of e)n&&n(...t)}}const he=e=>typeof e=="function"&&!e.length?e():e,Lw=e=>Array.isArray(e)?e:e?[e]:[];function QM(e,...t){return typeof e=="function"?e(...t):e}const XM=dt;function e2(e,t,n,s){return e.addEventListener(t,n,s),XM(e.removeEventListener.bind(e,t,n,s))}function t2(e,t,n,s){const r=()=>{Lw(he(e)).forEach(o=>{o&&Lw(he(t)).forEach(a=>e2(o,a,n,s))})};typeof e=="function"?Ze(r):de(r)}const Tg=Symbol("fallback");function Nw(e){for(const t of e)t.dispose()}function n2(e,t,n,s={}){const r=new Map;return dt(()=>Nw(r.values())),()=>{const a=e()||[];return a[bM],aa(()=>{var d,u;if(!a.length)return Nw(r.values()),r.clear(),s.fallback?[Uc(g=>(r.set(Tg,{dispose:g}),s.fallback()))]:[];const i=new Array(a.length),c=r.get(Tg);if(!r.size||c){c==null||c.dispose(),r.delete(Tg);for(let f=0;f<a.length;f++){const g=a[f],m=t(g,f);o(i,g,f,m)}return i}const l=new Set(r.keys());for(let f=0;f<a.length;f++){const g=a[f],m=t(g,f);l.delete(m);const w=r.get(m);w?(i[f]=w.mapped,(d=w.setIndex)==null||d.call(w,f),w.setItem(()=>g)):o(i,g,f,m)}for(const f of l)(u=r.get(f))==null||u.dispose(),r.delete(f);return i})};function o(a,i,c,l){Uc(d=>{const[u,f]=R(i),g={setItem:f,dispose:d};if(n.length>1){const[m,w]=R(c);g.setIndex=w,g.mapped=n(u,m)}else g.mapped=n(u);r.set(l,g),a[c]=g.mapped})}}function s2(e){const{by:t}=e;return Te(n2(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const r2=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Fw(e){const t={};let n;for(;n=r2.exec(e);)t[n[1]]=n[2];return t}function ml(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Fw(e)}else typeof t=="string"&&(t=Fw(t));return{...e,...t}}function Kn(...e){return JM(e)}function oH(e,t,n=-1){return n in e?[...e.slice(0,n),t,...e.slice(n)]:[...e,t]}function Bw(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function o2(e){return typeof e=="number"}function Li(e){return Object.prototype.toString.call(e)==="[object String]"}function tf(e){return typeof e=="function"}function ja(e){return t=>`${e()}-${t}`}function Tr(e,t){return e?e===t||e.contains(t):!1}function hc(e,t=!1){const{activeElement:n}=Or(e);if(!(n!=null&&n.nodeName))return null;if(wk(n)&&n.contentDocument)return hc(n.contentDocument.body,t);if(t){const s=n.getAttribute("aria-activedescendant");if(s){const r=Or(n).getElementById(s);if(r)return r}}return n}function i2(e){return Or(e).defaultView||window}function Or(e){return e?e.ownerDocument||e:document}function wk(e){return e.tagName==="IFRAME"}var Pp=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(Pp||{});function bk(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)==null?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function Ip(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function pl(){return Ip(/^Mac/i)}function a2(){return Ip(/^iPhone/i)}function c2(){return Ip(/^iPad/i)||pl()&&navigator.maxTouchPoints>1}function l2(){return a2()||c2()}function d2(){return pl()||l2()}function u2(){return bk(/AppleWebKit/i)&&!f2()}function f2(){return bk(/Chrome/i)}function on(e,t){return t&&(tf(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function vs(e){return t=>{for(const n of e)on(t,n)}}function g2(e){return pl()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function On(e){if(e)if(h2())e.focus({preventScroll:!0});else{const t=m2(e);e.focus(),p2(t)}}var Jl=null;function h2(){if(Jl==null){Jl=!1;try{document.createElement("div").focus({get preventScroll(){return Jl=!0,!0}})}catch{}}return Jl}function m2(e){let t=e.parentNode;const n=[],s=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==s;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return s instanceof HTMLElement&&n.push({element:s,scrollTop:s.scrollTop,scrollLeft:s.scrollLeft}),n}function p2(e){for(const{element:t,scrollTop:n,scrollLeft:s}of e)t.scrollTop=n,t.scrollLeft=s}var Sk=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],y2=[...Sk,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Rp=`${Sk.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,v2=y2.join(':not([hidden]):not([tabindex="-1"]),');function kk(e,t){const s=Array.from(e.querySelectorAll(Rp)).filter(Uw);return t&&Uw(e)&&s.unshift(e),s.forEach((r,o)=>{if(wk(r)&&r.contentDocument){const a=r.contentDocument.body,i=kk(a,!1);s.splice(o,1,...i)}}),s}function Uw(e){return xk(e)&&!w2(e)}function xk(e){return e.matches(Rp)&&Op(e)}function w2(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function Op(e,t){return e.nodeName!=="#comment"&&b2(e)&&S2(e,t)&&(!e.parentElement||Op(e.parentElement,e))}function b2(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;const{display:t,visibility:n}=e.style;let s=t!=="none"&&n!=="hidden"&&n!=="collapse";if(s){if(!e.ownerDocument.defaultView)return s;const{getComputedStyle:r}=e.ownerDocument.defaultView,{display:o,visibility:a}=r(e);s=o!=="none"&&a!=="hidden"&&a!=="collapse"}return s}function S2(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function k2(e,t,n){const s=t!=null&&t.tabbable?v2:Rp,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(o){var a;return(a=t==null?void 0:t.from)!=null&&a.contains(o)?NodeFilter.FILTER_REJECT:o.matches(s)&&Op(o)&&(!(t!=null&&t.accept)||t.accept(o))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(r.currentNode=t.from),r}function Kw(e){let t=e;for(;t&&!x2(t);)t=t.parentElement;return t||document.scrollingElement||document.documentElement}function x2(e){const t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function _2(){}function iH(e){return[e.clientX,e.clientY]}function aH(e,t){const[n,s]=e;let r=!1;const o=t.length;for(let a=o,i=0,c=a-1;i<a;c=i++){const[l,d]=t[i],[u,f]=t[c],[,g]=t[c===0?a-1:c-1]||[0,0],m=(d-f)*(n-l)-(l-u)*(s-d);if(f<d){if(s>=f&&s<d){if(m===0)return!0;m>0&&(s===f?s>g&&(r=!r):r=!r)}}else if(d<f){if(s>d&&s<=f){if(m===0)return!0;m<0&&(s===f?s<g&&(r=!r):r=!r)}}else if(s===d&&(n>=u&&n<=l||n>=l&&n<=u))return!0}return r}function Kt(e,t){return _e(e,t)}var sc=new Map,Vw=new Set;function jw(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let s=sc.get(n.target);s||(s=new Set,sc.set(n.target,s),n.target.addEventListener("transitioncancel",t)),s.add(n.propertyName)},t=n=>{if(!n.target)return;const s=sc.get(n.target);if(s&&(s.delete(n.propertyName),s.size===0&&(n.target.removeEventListener("transitioncancel",t),sc.delete(n.target)),sc.size===0)){for(const r of Vw)r();Vw.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?jw():document.addEventListener("DOMContentLoaded",jw));function Ah(e,t){const n=qw(e,t,"left"),s=qw(e,t,"top"),r=t.offsetWidth,o=t.offsetHeight;let a=e.scrollLeft,i=e.scrollTop;const c=a+e.offsetWidth,l=i+e.offsetHeight;n<=a?a=n:n+r>c&&(a+=n+r-c),s<=i?i=s:s+o>l&&(i+=s+o-l),e.scrollLeft=a,e.scrollTop=i}function qw(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let r=0;for(;t.offsetParent&&(r+=t[s],t.offsetParent!==e);){if(t.offsetParent.contains(e)){r-=e[s];break}t=t.offsetParent}return r}function cH(e,t){var n,s;if(document.contains(e)){const r=document.scrollingElement||document.documentElement;if(window.getComputedStyle(r).overflow==="hidden"){let a=Kw(e);for(;e&&a&&e!==r&&a!==r;)Ah(a,e),e=a,a=Kw(e)}else{const{left:a,top:i}=e.getBoundingClientRect();(n=e==null?void 0:e.scrollIntoView)==null||n.call(e,{block:"nearest"});const{left:c,top:l}=e.getBoundingClientRect();(Math.abs(a-c)>1||Math.abs(i-l)>1)&&((s=e.scrollIntoView)==null||s.call(e,{block:"nearest"}))}}}var nf={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"},zd="data-kb-top-layer",_k,Dh=!1,Lr=[];function Kc(e){return Lr.findIndex(t=>t.node===e)}function $2(e){return Lr[Kc(e)]}function C2(e){return Lr[Lr.length-1].node===e}function $k(){return Lr.filter(e=>e.isPointerBlocking)}function E2(){return[...$k()].slice(-1)[0]}function Lp(){return $k().length>0}function Ck(e){var n;const t=Kc((n=E2())==null?void 0:n.node);return Kc(e)<t}function T2(e){Lr.push(e)}function M2(e){const t=Kc(e);t<0||Lr.splice(t,1)}function A2(){for(const{node:e}of Lr)e.style.pointerEvents=Ck(e)?"none":"auto"}function D2(e){if(Lp()&&!Dh){const t=Or(e);_k=document.body.style.pointerEvents,t.body.style.pointerEvents="none",Dh=!0}}function P2(e){if(Lp())return;const t=Or(e);t.body.style.pointerEvents=_k,t.body.style.length===0&&t.body.removeAttribute("style"),Dh=!1}var ss={layers:Lr,isTopMostLayer:C2,hasPointerBlockingLayer:Lp,isBelowPointerBlockingLayer:Ck,addLayer:T2,removeLayer:M2,indexOf:Kc,find:$2,assignPointerEventToLayers:A2,disableBodyPointerEvents:D2,restoreBodyPointerEvents:P2},Mg="focusScope.autoFocusOnMount",Ag="focusScope.autoFocusOnUnmount",zw={bubbles:!1,cancelable:!0},Ww={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=Bw(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=Bw(this.stack,e),(t=this.active())==null||t.resume()}};function Ek(e,t){const[n,s]=R(!1),r={pause(){s(!0)},resume(){s(!1)}};let o=null;const a=m=>{var w;return(w=e.onMountAutoFocus)==null?void 0:w.call(e,m)},i=m=>{var w;return(w=e.onUnmountAutoFocus)==null?void 0:w.call(e,m)},c=()=>Or(t()),l=()=>{const m=c().createElement("span");return m.setAttribute("data-focus-trap",""),m.tabIndex=0,Object.assign(m.style,nf),m},d=()=>{const m=t();return m?kk(m,!0).filter(w=>!w.hasAttribute("data-focus-trap")):[]},u=()=>{const m=d();return m.length>0?m[0]:null},f=()=>{const m=d();return m.length>0?m[m.length-1]:null},g=()=>{const m=t();if(!m)return!1;const w=hc(m);return!w||Tr(m,w)?!1:xk(w)};Ze(()=>{const m=t();if(!m)return;Ww.add(r);const w=hc(m);if(!Tr(m,w)){const b=new CustomEvent(Mg,zw);m.addEventListener(Mg,a),m.dispatchEvent(b),b.defaultPrevented||setTimeout(()=>{On(u()),hc(m)===w&&On(m)},0)}dt(()=>{m.removeEventListener(Mg,a),setTimeout(()=>{const b=new CustomEvent(Ag,zw);g()&&b.preventDefault(),m.addEventListener(Ag,i),m.dispatchEvent(b),b.defaultPrevented||On(w??c().body),m.removeEventListener(Ag,i),Ww.remove(r)},0)})}),Ze(()=>{const m=t();if(!m||!he(e.trapFocus)||n())return;const w=b=>{const v=b.target;v!=null&&v.closest(`[${zd}]`)||(Tr(m,v)?o=v:On(o))},S=b=>{const k=b.relatedTarget??hc(m);k!=null&&k.closest(`[${zd}]`)||Tr(m,k)||On(o)};c().addEventListener("focusin",w),c().addEventListener("focusout",S),dt(()=>{c().removeEventListener("focusin",w),c().removeEventListener("focusout",S)})}),Ze(()=>{const m=t();if(!m||!he(e.trapFocus)||n())return;const w=l();m.insertAdjacentElement("afterbegin",w);const S=l();m.insertAdjacentElement("beforeend",S);function b(k){const C=u(),_=f();k.relatedTarget===C?On(_):On(C)}w.addEventListener("focusin",b),S.addEventListener("focusin",b);const v=new MutationObserver(k=>{for(const C of k)C.previousSibling===S&&(S.remove(),m.insertAdjacentElement("beforeend",S)),C.nextSibling===w&&(w.remove(),m.insertAdjacentElement("afterbegin",w))});v.observe(m,{childList:!0,subtree:!1}),dt(()=>{w.removeEventListener("focusin",b),S.removeEventListener("focusin",b),w.remove(),S.remove(),v.disconnect()})})}var Tk=7e3,Dg=null,I2="data-live-announcer";function lH(e,t="assertive",n=Tk){Dg||(Dg=new R2),Dg.announce(e,t,n)}var R2=class{constructor(){ae(this,"node");ae(this,"assertiveLog");ae(this,"politeLog");this.node=document.createElement("div"),this.node.dataset.liveAnnouncer="true",Object.assign(this.node.style,nf),this.assertiveLog=this.createLog("assertive"),this.node.appendChild(this.assertiveLog),this.politeLog=this.createLog("polite"),this.node.appendChild(this.politeLog),document.body.prepend(this.node)}createLog(e){const t=document.createElement("div");return t.setAttribute("role","log"),t.setAttribute("aria-live",e),t.setAttribute("aria-relevant","additions"),t}destroy(){this.node&&(document.body.removeChild(this.node),this.node=null)}announce(e,t="assertive",n=Tk){if(!this.node)return;const s=document.createElement("div");s.textContent=e,t==="assertive"?this.assertiveLog.appendChild(s):this.politeLog.appendChild(s),e!==""&&setTimeout(()=>{s.remove()},n)}clear(e){this.node&&((!e||e==="assertive")&&(this.assertiveLog.innerHTML=""),(!e||e==="polite")&&(this.politeLog.innerHTML=""))}};function Mk(e){Ze(()=>{he(e.isDisabled)||dt(O2(he(e.targets),he(e.root)))})}var rc=new WeakMap,ms=[];function O2(e,t=document.body){const n=new Set(e),s=new Set,r=c=>{for(const f of c.querySelectorAll(`[${I2}], [${zd}]`))n.add(f);const l=f=>{if(n.has(f)||f.parentElement&&s.has(f.parentElement)&&f.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(const g of n)if(f.contains(g))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},d=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,{acceptNode:l}),u=l(c);if(u===NodeFilter.FILTER_ACCEPT&&o(c),u!==NodeFilter.FILTER_REJECT){let f=d.nextNode();for(;f!=null;)o(f),f=d.nextNode()}},o=c=>{const l=rc.get(c)??0;c.getAttribute("aria-hidden")==="true"&&l===0||(l===0&&c.setAttribute("aria-hidden","true"),s.add(c),rc.set(c,l+1))};ms.length&&ms[ms.length-1].disconnect(),r(t);const a=new MutationObserver(c=>{for(const l of c)if(!(l.type!=="childList"||l.addedNodes.length===0)&&![...n,...s].some(d=>d.contains(l.target))){for(const d of l.removedNodes)d instanceof Element&&(n.delete(d),s.delete(d));for(const d of l.addedNodes)(d instanceof HTMLElement||d instanceof SVGElement)&&(d.dataset.liveAnnouncer==="true"||d.dataset.reactAriaTopLayer==="true")?n.add(d):d instanceof Element&&r(d)}});a.observe(t,{childList:!0,subtree:!0});const i={observe(){a.observe(t,{childList:!0,subtree:!0})},disconnect(){a.disconnect()}};return ms.push(i),()=>{a.disconnect();for(const c of s){const l=rc.get(c);if(l==null)return;l===1?(c.removeAttribute("aria-hidden"),rc.delete(c)):rc.set(c,l-1)}i===ms[ms.length-1]?(ms.pop(),ms.length&&ms[ms.length-1].observe()):ms.splice(ms.indexOf(i),1)}}var Hw="interactOutside.pointerDownOutside",Gw="interactOutside.focusOutside";function L2(e,t){let n,s=_2;const r=()=>Or(t()),o=u=>{var f;return(f=e.onPointerDownOutside)==null?void 0:f.call(e,u)},a=u=>{var f;return(f=e.onFocusOutside)==null?void 0:f.call(e,u)},i=u=>{var f;return(f=e.onInteractOutside)==null?void 0:f.call(e,u)},c=u=>{var g;const f=u.target;return!(f instanceof Element)||f.closest(`[${zd}]`)||!Tr(r(),f)||Tr(t(),f)?!1:!((g=e.shouldExcludeElement)!=null&&g.call(e,f))},l=u=>{function f(){const g=t(),m=u.target;if(!g||!m||!c(u))return;const w=vs([o,i]);m.addEventListener(Hw,w,{once:!0});const S=new CustomEvent(Hw,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||g2(u)&&u.button===0}});m.dispatchEvent(S)}u.pointerType==="touch"?(r().removeEventListener("click",f),s=f,r().addEventListener("click",f,{once:!0})):f()},d=u=>{const f=t(),g=u.target;if(!f||!g||!c(u))return;const m=vs([a,i]);g.addEventListener(Gw,m,{once:!0});const w=new CustomEvent(Gw,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});g.dispatchEvent(w)};Ze(()=>{he(e.isDisabled)||(n=window.setTimeout(()=>{r().addEventListener("pointerdown",l,!0)},0),r().addEventListener("focusin",d,!0),dt(()=>{window.clearTimeout(n),r().removeEventListener("click",s),r().removeEventListener("pointerdown",l,!0),r().removeEventListener("focusin",d,!0)}))})}function N2(e){const t=n=>{var s;n.key===Pp.Escape&&((s=e.onEscapeKeyDown)==null||s.call(e,n))};Ze(()=>{var s;if(he(e.isDisabled))return;const n=((s=e.ownerDocument)==null?void 0:s.call(e))??Or();n.addEventListener("keydown",t),dt(()=>{n.removeEventListener("keydown",t)})})}function en(e){const[t,n]=Nt(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return y(Tp,_e(n,{get component(){return t.as}}))}var Ak=qr();function F2(){return zr(Ak)}function Dk(e){let t;const n=F2(),[s,r]=Nt(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),o=new Set([]),a=u=>{o.add(u);const f=n==null?void 0:n.registerNestedLayer(u);return()=>{o.delete(u),f==null||f()}};L2({shouldExcludeElement:u=>{var f;return t?((f=s.excludedElements)==null?void 0:f.some(g=>Tr(g(),u)))||[...o].some(g=>Tr(g,u)):!1},onPointerDownOutside:u=>{var f,g,m;!t||ss.isBelowPointerBlockingLayer(t)||!s.bypassTopMostLayerCheck&&!ss.isTopMostLayer(t)||((f=s.onPointerDownOutside)==null||f.call(s,u),(g=s.onInteractOutside)==null||g.call(s,u),u.defaultPrevented||(m=s.onDismiss)==null||m.call(s))},onFocusOutside:u=>{var f,g,m;(f=s.onFocusOutside)==null||f.call(s,u),(g=s.onInteractOutside)==null||g.call(s,u),u.defaultPrevented||(m=s.onDismiss)==null||m.call(s)}},()=>t),N2({ownerDocument:()=>Or(t),onEscapeKeyDown:u=>{var f;!t||!ss.isTopMostLayer(t)||((f=s.onEscapeKeyDown)==null||f.call(s,u),!u.defaultPrevented&&s.onDismiss&&(u.preventDefault(),s.onDismiss()))}}),Ys(()=>{if(!t)return;ss.addLayer({node:t,isPointerBlocking:s.disableOutsidePointerEvents,dismiss:s.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);ss.assignPointerEventToLayers(),ss.disableBodyPointerEvents(t),dt(()=>{t&&(ss.removeLayer(t),u==null||u(),ss.assignPointerEventToLayers(),ss.restoreBodyPointerEvents(t))})}),Ze(yi([()=>t,()=>s.disableOutsidePointerEvents],([u,f])=>{if(!u)return;const g=ss.find(u);g&&g.isPointerBlocking!==f&&(g.isPointerBlocking=f,ss.assignPointerEventToLayers()),f&&ss.disableBodyPointerEvents(u),dt(()=>{ss.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:a};return y(Ak.Provider,{value:d,get children(){return y(en,_e({as:"div",ref(u){var f=Kn(g=>t=g,s.ref);typeof f=="function"&&f(u)}},r))}})}function Np(e){var a;const[t,n]=R((a=e.defaultValue)==null?void 0:a.call(e)),s=Te(()=>{var i;return((i=e.value)==null?void 0:i.call(e))!==void 0}),r=Te(()=>{var i;return s()?(i=e.value)==null?void 0:i.call(e):t()});return[r,i=>{aa(()=>{var l;const c=QM(i,r());return Object.is(c,r())||(s()||n(c),(l=e.onChange)==null||l.call(e,c)),c})}]}function Pk(e){const[t,n]=Np(e);return[()=>t()??!1,n]}function dH(e){const[t,n]=Np(e);return[()=>t()??[],n]}function Ik(e={}){const[t,n]=Pk({value:()=>he(e.open),defaultValue:()=>!!he(e.defaultOpen),onChange:a=>{var i;return(i=e.onOpenChange)==null?void 0:i.call(e,a)}}),s=()=>{n(!0)},r=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:s,close:r,toggle:()=>{t()?r():s()}}}function Rk(e,t){const[n,s]=R(Zw(t==null?void 0:t()));return Ze(()=>{var r;s(((r=e())==null?void 0:r.tagName.toLowerCase())||Zw(t==null?void 0:t()))}),n}function Zw(e){return Li(e)?e:void 0}var B2=Object.defineProperty,yl=(e,t)=>{for(var n in t)B2(e,n,{get:t[n],enumerable:!0})},U2={};yl(U2,{Button:()=>j2,Root:()=>vl});var K2=["button","color","file","image","reset","submit"];function V2(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?K2.indexOf(e.type)!==-1:!1}function vl(e){let t;const n=Kt({type:"button"},e),[s,r]=Nt(n,["ref","type","disabled"]),o=Rk(()=>t,()=>"button"),a=Te(()=>{const l=o();return l==null?!1:V2({tagName:l,type:s.type})}),i=Te(()=>o()==="input"),c=Te(()=>o()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return y(en,_e({as:"button",ref(l){var d=Kn(u=>t=u,s.ref);typeof d=="function"&&d(l)},get type(){return Ee(()=>!!(a()||i()))()?s.type:void 0},get role(){return!a()&&!c()?"button":void 0},get tabIndex(){return!a()&&!c()&&!s.disabled?0:void 0},get disabled(){return Ee(()=>!!(a()||i()))()?s.disabled:void 0},get"aria-disabled"(){return!a()&&!i()&&s.disabled?!0:void 0},get"data-disabled"(){return s.disabled?"":void 0}},r))}var j2=vl;function bs(e){return t=>(e(t),()=>e(void 0))}var Rn=e=>typeof e=="function"?e():e,Ph=(e,t)=>{if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},Ql=new Map,q2=e=>{Ze(()=>{const t=Rn(e.style)??{},n=Rn(e.properties)??[],s={};for(const o in t)s[o]=e.element.style[o];const r=Ql.get(e.key);r?r.activeCount++:Ql.set(e.key,{activeCount:1,originalStyles:s,properties:n.map(o=>o.key)}),Object.assign(e.element.style,e.style);for(const o of n)e.element.style.setProperty(o.key,o.value);dt(()=>{var a;const o=Ql.get(e.key);if(o){if(o.activeCount!==1){o.activeCount--;return}Ql.delete(e.key);for(const[i,c]of Object.entries(o.originalStyles))e.element.style[i]=c;for(const i of o.properties)e.element.style.removeProperty(i);e.element.style.length===0&&e.element.removeAttribute("style"),(a=e.cleanup)==null||a.call(e)}})})},Yw=q2,z2=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},W2=(e,t)=>{const n=getComputedStyle(e),s=t==="x"?n.overflowX:n.overflowY;return s==="auto"||s==="scroll"||e.tagName==="HTML"&&s==="visible"},H2=(e,t,n)=>{const s=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let r=e,o=0,a=0,i=!1;do{const[c,l,d]=z2(r,t),u=d-c-s*l;(l!==0||u!==0)&&W2(r,t)&&(o+=u,a+=l),r===(n??document.documentElement)?i=!0:r=r._$host??r.parentElement}while(r&&!i);return[o,a]},[Jw,Qw]=R([]),G2=e=>Jw().indexOf(e)===Jw().length-1,Z2=e=>{const t=_e({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=Do();let s=[0,0],r=null,o=null;Ze(()=>{Rn(t.enabled)&&(Qw(l=>[...l,n]),dt(()=>{Qw(l=>l.filter(d=>d!==n))}))}),Ze(()=>{if(!Rn(t.enabled)||!Rn(t.hideScrollbar))return;const{body:l}=document,d=window.innerWidth-l.offsetWidth;if(Rn(t.preventScrollbarShift)){const u={overflow:"hidden"},f=[];d>0&&(Rn(t.preventScrollbarShiftMode)==="padding"?u.paddingRight=`calc(${window.getComputedStyle(l).paddingRight} + ${d}px)`:u.marginRight=`calc(${window.getComputedStyle(l).marginRight} + ${d}px)`,f.push({key:"--scrollbar-width",value:`${d}px`}));const g=window.scrollY,m=window.scrollX;Yw({key:"prevent-scroll",element:l,style:u,properties:f,cleanup:()=>{Rn(t.restoreScrollPosition)&&d>0&&window.scrollTo(m,g)}})}else Yw({key:"prevent-scroll",element:l,style:{overflow:"hidden"}})}),Ze(()=>{!G2(n)||!Rn(t.enabled)||(document.addEventListener("wheel",i,{passive:!1}),document.addEventListener("touchstart",a,{passive:!1}),document.addEventListener("touchmove",c,{passive:!1}),dt(()=>{document.removeEventListener("wheel",i),document.removeEventListener("touchstart",a),document.removeEventListener("touchmove",c)}))});const a=l=>{s=Xw(l),r=null,o=null},i=l=>{const d=l.target,u=Rn(t.element),f=Y2(l),g=Math.abs(f[0])>Math.abs(f[1])?"x":"y",m=g==="x"?f[0]:f[1],w=eb(d,g,m,u);let S;u&&Ph(u,d)?S=!w:S=!0,S&&l.cancelable&&l.preventDefault()},c=l=>{const d=Rn(t.element),u=l.target;let f;if(l.touches.length===2)f=!Rn(t.allowPinchZoom);else{if(r==null||o===null){const g=Xw(l).map((w,S)=>s[S]-w),m=Math.abs(g[0])>Math.abs(g[1])?"x":"y";r=m,o=m==="x"?g[0]:g[1]}if(u.type==="range")f=!1;else{const g=eb(u,r,o,d);d&&Ph(d,u)?f=!g:f=!0}}f&&l.cancelable&&l.preventDefault()}},Y2=e=>[e.deltaX,e.deltaY],Xw=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],eb=(e,t,n,s)=>{const r=s!==null&&Ph(s,e),[o,a]=H2(e,t,r?s:void 0);return!(n>0&&Math.abs(o)<=1||n<0&&Math.abs(a)<1)},J2=Z2,Ok=J2,Q2=e=>{const t=Te(()=>{const a=Rn(e.element);if(a)return getComputedStyle(a)}),n=()=>{var a;return((a=t())==null?void 0:a.animationName)??"none"},[s,r]=R(Rn(e.show)?"present":"hidden");let o="none";return Ze(a=>{const i=Rn(e.show);return aa(()=>{var d;if(a===i)return i;const c=o,l=n();i?r("present"):l==="none"||((d=t())==null?void 0:d.display)==="none"?r("hidden"):r(a===!0&&c!==l?"hiding":"hidden")}),i}),Ze(()=>{const a=Rn(e.element);if(!a)return;const i=l=>{l.target===a&&(o=n())},c=l=>{const u=n().includes(l.animationName);l.target===a&&u&&s()==="hiding"&&r("hidden")};a.addEventListener("animationstart",i),a.addEventListener("animationcancel",c),a.addEventListener("animationend",c),dt(()=>{a.removeEventListener("animationstart",i),a.removeEventListener("animationcancel",c),a.removeEventListener("animationend",c)})}),{present:()=>s()==="present"||s()==="hiding",state:s,setState:r}},X2=Q2,Ih=X2,eA={};yl(eA,{CloseButton:()=>Nk,Content:()=>Fk,Description:()=>Bk,Dialog:()=>Ot,Overlay:()=>Uk,Portal:()=>Kk,Root:()=>Vk,Title:()=>jk,Trigger:()=>qk,useDialogContext:()=>Po});var Lk=qr();function Po(){const e=zr(Lk);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function Nk(e){const t=Po(),[n,s]=Nt(e,["aria-label","onClick"]);return y(vl,_e({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:o=>{on(o,n.onClick),t.close()}},s))}function Fk(e){let t;const n=Po(),s=Kt({id:n.generateId("content")},e),[r,o]=Nt(s,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let a=!1,i=!1;const c=f=>{var g;(g=r.onPointerDownOutside)==null||g.call(r,f),n.modal()&&f.detail.isContextMenu&&f.preventDefault()},l=f=>{var g;(g=r.onFocusOutside)==null||g.call(r,f),n.modal()&&f.preventDefault()},d=f=>{var g;(g=r.onInteractOutside)==null||g.call(r,f),!n.modal()&&(f.defaultPrevented||(a=!0,f.detail.originalEvent.type==="pointerdown"&&(i=!0)),Tr(n.triggerRef(),f.target)&&f.preventDefault(),f.detail.originalEvent.type==="focusin"&&i&&f.preventDefault())},u=f=>{var g;(g=r.onCloseAutoFocus)==null||g.call(r,f),n.modal()?(f.preventDefault(),On(n.triggerRef())):(f.defaultPrevented||(a||On(n.triggerRef()),f.preventDefault()),a=!1,i=!1)};return Mk({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),Ok({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),Ek({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:r.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),Ze(()=>dt(n.registerContentId(o.id))),y(ee,{get when(){return n.contentPresent()},get children(){return y(Dk,_e({ref(f){var g=Kn(m=>{n.setContentRef(m),t=m},r.ref);typeof g=="function"&&g(f)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return Ee(()=>!!n.modal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get"aria-labelledby"(){return n.titleId()},get"aria-describedby"(){return n.descriptionId()},get"data-expanded"(){return n.isOpen()?"":void 0},get"data-closed"(){return n.isOpen()?void 0:""},onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:d,get onDismiss(){return n.close}},o))}})}function Bk(e){const t=Po(),n=Kt({id:t.generateId("description")},e),[s,r]=Nt(n,["id"]);return Ze(()=>dt(t.registerDescriptionId(s.id))),y(en,_e({as:"p",get id(){return s.id}},r))}function Uk(e){const t=Po(),[n,s]=Nt(e,["ref","style","onPointerDown"]),r=o=>{on(o,n.onPointerDown),o.target===o.currentTarget&&o.preventDefault()};return y(ee,{get when(){return t.overlayPresent()},get children(){return y(en,_e({as:"div",ref(o){var a=Kn(t.setOverlayRef,n.ref);typeof a=="function"&&a(o)},get style(){return ml({"pointer-events":"auto"},n.style)},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onPointerDown:r},s))}})}function Kk(e){const t=Po();return y(ee,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return y(Mp,e)}})}var tb={dismiss:"Dismiss"};function Vk(e){const t=`dialog-${Do()}`,n=Kt({id:t,modal:!0,translations:tb},e),[s,r]=R(),[o,a]=R(),[i,c]=R(),[l,d]=R(),[u,f]=R(),[g,m]=R(),w=Ik({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:C=>{var _;return(_=n.onOpenChange)==null?void 0:_.call(n,C)}}),S=()=>n.forceMount||w.isOpen(),{present:b}=Ih({show:S,element:()=>l()??null}),{present:v}=Ih({show:S,element:()=>u()??null}),k={translations:()=>n.translations??tb,isOpen:w.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??k.modal(),contentId:s,titleId:o,descriptionId:i,triggerRef:g,overlayRef:l,setOverlayRef:d,contentRef:u,setContentRef:f,overlayPresent:b,contentPresent:v,close:w.close,toggle:w.toggle,setTriggerRef:m,generateId:ja(()=>n.id),registerContentId:bs(r),registerTitleId:bs(a),registerDescriptionId:bs(c)};return y(Lk.Provider,{value:k,get children(){return n.children}})}function jk(e){const t=Po(),n=Kt({id:t.generateId("title")},e),[s,r]=Nt(n,["id"]);return Ze(()=>dt(t.registerTitleId(s.id))),y(en,_e({as:"h2",get id(){return s.id}},r))}function qk(e){const t=Po(),[n,s]=Nt(e,["ref","onClick"]);return y(vl,_e({ref(o){var a=Kn(t.setTriggerRef,n.ref);typeof a=="function"&&a(o)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return Ee(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:o=>{on(o,n.onClick),t.toggle()}},s))}var Ot=Object.assign(Vk,{CloseButton:Nk,Content:Fk,Description:Bk,Overlay:Uk,Portal:Kk,Title:jk,Trigger:qk});const[Ed,sf]=R(null);function Ns(e,t){sf({type:"alert",message:e,...t})}function ca(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(s=>{sf({type:"confirm",message:e,...t,resolve:s})})}function tA(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(s=>{sf({type:"prompt",message:e,...t,resolvePrompt:s})})}function Pg(){sf(null)}var nA=O('<div class="flex items-start gap-3"><div class="flex h-12 w-12 shrink-0 items-center justify-center border text-base font-semibold"aria-hidden></div><div class="flex-1 min-w-0">'),sA=O('<div class=mt-4><label for=prompt-input class="text-sm font-medium text-secondary"></label><input id=prompt-input class="form-input mt-2"autocapitalize=off autocorrect=off>'),rA=O('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),oA=O('<p class="mt-2 text-secondary">'),iA=O("<button type=button class=button-secondary>");const aA={info:{badgeBg:"var(--badge-neutral-bg)",badgeBorder:"var(--border-base)",badgeText:"var(--accent-primary)",symbol:"i"},warning:{badgeBg:"rgba(255, 152, 0, 0.14)",badgeBorder:"var(--status-warning)",badgeText:"var(--status-warning)",symbol:"!"},error:{badgeBg:"var(--danger-soft-bg)",badgeBorder:"var(--status-error)",badgeText:"var(--status-error)",symbol:"!"}};function Xl(e,t,n){var r,o,a,i,c,l,d,u;const s=t??Ed();if((s==null?void 0:s.type)==="confirm"){e?(r=s.onConfirm)==null||r.call(s):(o=s.onCancel)==null||o.call(s),(a=s.resolve)==null||a.call(s,e),Pg();return}if((s==null?void 0:s.type)==="prompt"){e?((i=s.onConfirm)==null||i.call(s),(c=s.resolvePrompt)==null||c.call(s,n??"")):((l=s.onCancel)==null||l.call(s),(d=s.resolvePrompt)==null||d.call(s,null)),Pg();return}e&&((u=s==null?void 0:s.onConfirm)==null||u.call(s)),Pg()}const cA=()=>{const{t:e}=Dt();let t,n;return Ze(()=>{const s=Ed();!s||$g.required()||queueMicrotask(()=>{if(!($g.required()||Ed()!==s)){if(s.type==="prompt"){n==null||n.focus(),n==null||n.select();return}t==null||t.focus()}})}),y(ee,{get when(){return Ed()},keyed:!0,children:s=>{const r=s.variant??"info",o=aA[r],a=e(r==="warning"?"alertDialog.fallbackTitle.warning":r==="error"?"alertDialog.fallbackTitle.error":"alertDialog.fallbackTitle.info"),i=s.title||a,c=s.type==="confirm",l=s.type==="prompt",d=s.confirmLabel||e(c?"alertDialog.actions.confirm":l?"alertDialog.actions.run":"alertDialog.actions.ok"),u=s.cancelLabel||e("alertDialog.actions.cancel"),[f,g]=R(s.inputDefaultValue??"");return y(Ot,{get open(){return!$g.required()},modal:!0,onOpenChange:m=>{!m&&s.dismissible!==!1&&Xl(!1,s)},get children(){return y(Ot.Portal,{get children(){return[y(Ot.Overlay,{class:"modal-overlay z-[60]"}),y(Ot.Content,{class:"modal-surface fixed left-1/2 top-1/2 z-[1310] w-full max-w-sm -translate-x-1/2 -translate-y-1/2 p-6 border border-base shadow-2xl",tabIndex:-1,get children(){return[(()=>{var m=nA(),w=m.firstChild,S=w.nextSibling;return p(w,()=>o.symbol),p(S,y(Ot.Title,{class:"text-lg font-semibold text-primary",children:i}),null),p(S,y(Ot.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line break-words",get children(){return[Ee(()=>s.message),Ee(()=>Ee(()=>!!s.detail)()&&(()=>{var b=oA();return p(b,()=>s.detail),b})())]}}),null),de(b=>{var v=o.badgeBg,k=o.badgeBorder,C=o.badgeText;return v!==b.e&&Cg(w,"background-color",b.e=v),k!==b.t&&Cg(w,"border-color",b.t=k),C!==b.a&&Cg(w,"color",b.a=C),b},{e:void 0,t:void 0,a:void 0}),m})(),y(ee,{when:l,get children(){var m=sA(),w=m.firstChild,S=w.nextSibling;return p(w,()=>s.inputLabel||e("alertDialog.prompt.inputLabel")),S.$$keydown=b=>{b.key==="Enter"&&(b.preventDefault(),Xl(!0,s,f()))},S.$$input=b=>g(b.currentTarget.value),dr(b=>{n=b},S),me(S,"spellcheck",!1),de(()=>me(S,"placeholder",s.inputPlaceholder||"")),de(()=>S.value=f()),m}}),(()=>{var m=rA(),w=m.firstChild;return p(m,(c||l)&&(()=>{var S=iA();return S.$$click=()=>Xl(!1,s),p(S,u),S})(),w),w.$$click=()=>Xl(!0,s,f()),dr(S=>{t=S},w),p(w,d),m})()]}})]}})}})}})};Xt(["input","keydown","click"]);function lA(e,t,n){if(e.has(t))return e;const s=new Map(e);return s.set(t,n),s}function dA(e,t){return e==="disconnected"||e==="error"?e:t!=="connected"?"connecting":e}const Uo=Ut("sse"),[nb,sb]=R(new Map),[uA,fA]=R("connecting");class gA{constructor(){Uo.info("sseManager initialized: listening for SSE disconnect and reconnect"),xs.on("instance.eventStatus",t=>{var s;const n=t;if(this.updateConnectionStatus(n.instanceId,n.status),n.status==="disconnected"){if(n.reason==="workspace stopped")return;const r=n.reason??"Instance disconnected";(s=this.onConnectionLost)==null||s.call(this,n.instanceId,r)}}),xs.on("instance.event",t=>{const n=t;this.updateConnectionStatus(n.instanceId,"connected"),this.handleEvent(n.instanceId,n.event)}),xs.onTransportStatus(t=>{Uo.info("SSE transport status changed",{status:t}),fA(t)})}seedStatus(t,n){this.updateConnectionStatus(t,n)}seedStatusIfMissing(t,n){sb(s=>lA(s,t,n))}handleEvent(t,n){var s,r,o,a,i,c,l,d,u,f,g,m,w,S,b,v;if(!n||typeof n!="object"||typeof n.type!="string"){Uo.warn("Dropping malformed event",n);return}switch(Uo.info("Received event",{type:n.type,event:n}),(s=this.onInvalidation)==null||s.call(this,t,n),n.type){case"session.created":(r=this.onSessionUpdate)==null||r.call(this,t,n);break;case"session.revert.staged":case"session.revert.cleared":case"session.revert.committed":(o=this.onSessionUpdate)==null||o.call(this,t,n);break;case"session.deleted":(a=this.onSessionDeleted)==null||a.call(this,t,n);break;case"session.compaction.ended":(i=this.onSessionCompacted)==null||i.call(this,t,n);break;case"session.execution.failed":(c=this.onSessionError)==null||c.call(this,t,n);break;case"tui.toast.show":(l=this.onTuiToast)==null||l.call(this,t,n);break;case"session.idle":(d=this.onSessionIdle)==null||d.call(this,t,n);break;case"session.status":(u=this.onSessionStatus)==null||u.call(this,t,n);break;case"permission.asked":(f=this.onPermissionUpdated)==null||f.call(this,t,n);break;case"permission.replied":(g=this.onPermissionReplied)==null||g.call(this,t,n);break;case"server.instance.disposed":(m=this.onInstanceDisposed)==null||m.call(this,t,n);break;case"worktree.ready":try{const k=(w=this.onWorktreeReady)==null?void 0:w.call(this,t,n);k==null||k.catch(C=>{Uo.warn("Failed to handle worktree ready event",{instanceId:t,error:C})})}catch(k){Uo.warn("Failed to handle worktree ready event",{instanceId:t,error:k})}break;case"worktree.updated":(b=(S=this.onWorktreeUpdated)==null?void 0:S.call(this,t))==null||b.catch(k=>Uo.warn("Failed to refresh native worktrees",k));break;default:(v=this.onNativeSessionEvent)==null||v.call(this,t,n)}}updateConnectionStatus(t,n){sb(s=>{if(s.get(t)===n)return s;const r=new Map(s);return r.set(t,n),r})}getStatus(t){return dA(nb().get(t)??null,uA())}getStatuses(){return nb()}}const vn=new gA,[ur,rf]=R(),[Rh,la]=R(!1),[mo,Oh]=R(!1),[zk,Vc]=R(!1),[xr,Wd]=R(!1),[Lh,jc]=R(),[mc,Nh]=R(),[Mc,Fh]=R(!1),[Bh,Xo]=R();let Ln=0,rb=-1,Os;const[Hd,Fp]=R(),Wk=()=>!!Hd();function Zi(e=ur()){return!xr()&&((e==null?void 0:e.serviceState)==="ready"||(e==null?void 0:e.serviceState)==="restart_available")}async function Hk(){if(!Zi()||mo()||Mc())return;const e=Ln,t=Hd();await Fs(),!(e!==Ln||mo()||!Zi()||Hd()!==t)&&(Fp(void 0),la(!1),await(t==null?void 0:t()))}function Uh(e=ur()){return(e==null?void 0:e.state)==="missing"||(e==null?void 0:e.state)==="update_required"||(e==null?void 0:e.serviceState)==="restart_required"||(e==null?void 0:e.serviceState)==="incompatible"}function Bp(e){e&&Fp(()=>e),Xo(void 0),la(!0),Fs()}function hA(){mo()||rb===Ln||(rb=Ln,Bp())}function Gk(){Ln++,Os=void 0,rf(void 0),Xo(void 0),Wd(!1),Vc(!1),jc(void 0),Fs()}function Fs(e=!1,t=!1){if(mo()&&!e)return Promise.resolve();if(Os)return Os.again=!0,Os.announce||(Os.announce=t),Os.promise;const n=Ln,s={promise:Promise.resolve(),again:!1,announce:t};return Os=s,Fh(!0),Xo(void 0),s.promise=(async()=>{do{s.again=!1;try{const r=await kt.fetchOpenCodeUpdateStatus();if(n!==Ln)return;rf(r),Wd(!1),Vc(!1),jc(void 0),!s.again&&s.announce&&!r.checkError&&!r.serviceError&&r.state!=="error"&&Xo("checked")}catch{if(n!==Ln)return;Wd(!0)}}while(s.again&&n===Ln)})().finally(()=>{Os===s&&(Os=void 0,Fh(!1))}),s.promise}async function pc(e,t={}){var s,r;if(mo())return;const n=++Ln;Os=void 0,Oh(!0),Nh(e),Xo(void 0),Vc(!1),jc(void 0);try{if(e==="install"&&await kt.updateOpenCode(),n!==Ln||(await Fs(!0),n!==Ln||xr())||e!=="restart"&&(((s=ur())==null?void 0:s.serviceState)==="restart_required"||((r=ur())==null?void 0:r.serviceState)==="incompatible"))return;const o=e==="reload"?await kt.reloadOpenCodeConfiguration():await kt.startOpenCode(e==="restart");if(n!==Ln)return;if(rf(o),o.state==="ready"&&(o.serviceState==="ready"||o.serviceState==="restart_available")){const a=t.resumeWorkspace===!1?void 0:Hd();return t.resumeWorkspace!==!1&&Fp(void 0),e==="reload"&&Xo("reloaded"),a&&o.serviceState==="ready"&&la(!1),await(a==null?void 0:a()),o}}catch(o){if(n===Ln){if(await Fs(!0),n!==Ln)return;Vc(!0),o instanceof Error&&(o.message==="installation_busy"||o.message==="installation_in_use")&&jc(o.message)}}finally{Oh(!1),Nh(void 0),n!==Ln&&Fs()}}const mA=Object.freeze(Object.defineProperty({__proto__:null,canContinueOpenCodeSetup:Wk,continueOpenCodeSetup:Hk,invalidateOpenCodeSetup:Gk,isOpenCodeConnected:Zi,needsOpenCodeSetup:Uh,openCodeInstallationError:Lh,openCodeSetupAction:mc,openCodeSetupBusy:mo,openCodeSetupCheckError:xr,openCodeSetupChecking:Mc,openCodeSetupError:zk,openCodeSetupFeedback:Bh,openCodeSetupOpen:Rh,openCodeSetupStatus:ur,openOpenCodeSetup:Bp,refreshOpenCodeSetup:Fs,reportOpenCodeSetupRequired:hA,runOpenCodeSetup:pc,setOpenCodeInstallationError:jc,setOpenCodeSetupAction:Nh,setOpenCodeSetupBusy:Oh,setOpenCodeSetupCheckError:Wd,setOpenCodeSetupChecking:Fh,setOpenCodeSetupError:Vc,setOpenCodeSetupFeedback:Xo,setOpenCodeSetupOpen:la,setOpenCodeSetupStatus:rf},Symbol.toStringTag,{value:"Module"}));var ob=O("<p class=settings-error-message role=alert>"),Di=O("<p role=status>"),pA=O("<div class=opencode-setup-panel><div class=settings-info-actions><button type=button class=settings-pill-button>"),yA=O("<p class=settings-toggle-title role=status>"),vA=O("<div class=settings-info-grid><div class=settings-info-row><span></span><span></span></div><div class=settings-info-row><span></span><span>"),wA=O('<p class="settings-toggle-caption break-all">'),ed=O("<p class=settings-toggle-caption>"),ib=O("<p role=alert>"),bA=O("<p>"),td=O("<button type=button class=settings-pill-button>"),SA=O("<div class=settings-info-actions>"),kA=O("<details class=opencode-setup-details><summary></summary><div class=settings-info-grid><div class=settings-info-row><span></span><span></span></div><div class=settings-info-row><span></span><span></span></div></div><p class=settings-toggle-caption>"),xA=O("<details class=opencode-setup-details><summary></summary><p class=settings-toggle-caption></p><div class=settings-info-actions><button type=button class=settings-pill-button>");function Zk(e={}){const{t}=Dt(),n=()=>mo()||Mc(),s=()=>Mc()?"settings.opencode.update.checking":mc()==="install"?"settings.opencode.update.updating":mc()?`settings.opencode.setup.progress.${mc()}`:void 0;return(()=>{var r=pA(),o=r.firstChild,a=o.firstChild;return p(r,y(ee,{get when(){return ur()},get fallback(){return(()=>{var i=Di();return p(i,()=>t(s()??(xr()?"settings.opencode.setup.serviceError":"settings.opencode.update.checking"))),i})()},children:i=>[(()=>{var c=yA();return p(c,()=>t(s()??(xr()?"settings.opencode.setup.disconnected":Zi()?"settings.opencode.setup.connected":i().state==="ready"?"settings.opencode.setup.disconnected":`settings.opencode.setup.${i().state}`))),c})(),(()=>{var c=vA(),l=c.firstChild,d=l.firstChild,u=d.nextSibling,f=l.nextSibling,g=f.firstChild,m=g.nextSibling;return p(d,()=>t("settings.opencode.update.installed")),p(u,()=>i().currentVersion??"—"),p(g,()=>t("settings.opencode.setup.daemon")),p(m,()=>i().daemonVersion??"—"),c})(),(()=>{var c=wA();return p(c,()=>i().binaryPath),c})(),y(ee,{get when(){return i().installationSource},children:c=>(()=>{var l=ed();return p(l,()=>t(`settings.opencode.setup.source.${c()}`)),l})()}),y(ee,{get when(){return Ee(()=>!!i().updateAvailable)()&&i().latestVersion},get children(){var c=Di();return p(c,()=>t("settings.opencode.update.available",{version:i().latestVersion??""})),c}}),y(ee,{get when(){return Ee(()=>!!(i().updateAvailable===!1&&i().latestVersion))()&&!i().checkError},get children(){var c=Di();return p(c,()=>t("settings.opencode.update.upToDate")),c}}),y(ee,{get when(){return i().target==="wsl"},get children(){var c=ed();return p(c,()=>t("settings.opencode.setup.wsl")),c}}),y(ee,{get when(){return i().serviceState==="restart_required"||i().serviceState==="restart_available"},get children(){var c=Di();return p(c,()=>t(i().serviceState==="restart_required"?"settings.opencode.setup.restartRequired":"settings.opencode.setup.restartAvailable")),c}}),y(ee,{get when(){return Ee(()=>!xr())()&&i().serviceState==="error"},get children(){var c=ib();return p(c,()=>t("settings.opencode.setup.serviceError")),c}}),y(ee,{get when(){return i().checkError},get children(){var c=Di();return p(c,()=>t("settings.opencode.update.checkFailed")),c}}),y(ee,{get when(){return Ee(()=>!i().canUpgrade)()&&(i().updateAvailable||i().state==="missing"||i().state==="update_required"||i().serviceState==="incompatible")},get children(){var c=bA();return p(c,()=>t("settings.opencode.setup.manual")),c}}),y(ee,{get when(){return Ee(()=>!!(i().daemonVersion||i().currentVersion))()&&i().versionAssessment==="untested"},get children(){var c=ed();return p(c,()=>t("settings.opencode.setup.untested",{version:i().daemonVersion??i().currentVersion??""})),c}}),(()=>{var c=SA();return p(c,y(ee,{get when(){return i().canUpgrade},get children(){var l=td();return l.$$click=()=>void pc("install"),p(l,(()=>{var d=Ee(()=>mc()==="install");return()=>d()?t("settings.opencode.update.updating"):Ee(()=>!!i().needsSharedInstallation)()?t("settings.opencode.setup.sharedInstall"):Ee(()=>i().state==="missing")()?t("settings.opencode.setup.install"):t("settings.opencode.update.action",{version:i().latestVersion??""})})()),de(()=>l.disabled=n()),l}}),null),p(c,y(ee,{get when(){return Ee(()=>i().state==="ready"&&!Zi()&&i().serviceState!=="restart_required")()&&i().serviceState!=="incompatible"},get children(){var l=td();return l.$$click=()=>void pc("start"),p(l,()=>t("settings.opencode.setup.connect")),de(()=>l.disabled=n()),l}}),null),p(c,y(ee,{get when(){return Ee(()=>!!Zi())()&&Wk()},get children(){var l=td();return l.$$click=()=>void Hk(),p(l,()=>t("settings.opencode.setup.continue")),de(()=>l.disabled=n()),l}}),null),p(c,y(ee,{get when(){return i().canRestart},get children(){var l=td();return l.$$click=()=>void pc("restart"),p(l,()=>t("settings.opencode.setup.restart")),de(()=>l.disabled=n()||xr()),l}}),null),c})(),y(ee,{get when(){return Ee(()=>!!i().canUpgrade)()&&(i().state==="missing"||i().needsSharedInstallation)},get children(){var c=ed();return p(c,()=>t("settings.opencode.setup.sharedInstallDescription")),c}})]}),o),p(r,y(ee,{get when(){return xr()},get children(){var i=ob();return p(i,()=>t("settings.opencode.setup.serviceError")),i}}),o),p(r,y(ee,{get when(){return zk()},get children(){var i=ob();return p(i,()=>t(Lh()?`settings.opencode.setup.${Lh()}`:"settings.opencode.setup.actionFailed")),i}}),o),p(r,y(ee,{get when(){return Bh()},get children(){var i=Di();return p(i,()=>t(`settings.opencode.setup.${Bh()}`)),i}}),o),a.$$click=()=>void Fs(!1,!0),p(a,()=>t(Mc()?"settings.opencode.update.checking":"settings.opencode.setup.check")),p(r,()=>e.children,null),p(r,y(ee,{get when(){return ur()},children:i=>[(()=>{var c=kA(),l=c.firstChild,d=l.nextSibling,u=d.firstChild,f=u.firstChild,g=f.nextSibling,m=u.nextSibling,w=m.firstChild,S=w.nextSibling,b=d.nextSibling;return p(l,()=>t("settings.opencode.setup.diagnostics")),p(f,()=>t("settings.opencode.setup.minimum")),p(g,()=>i().minimumVersion),p(w,()=>t("settings.opencode.setup.recommended")),p(S,()=>i().recommendedVersion),p(b,()=>t("settings.opencode.setup.minimumReason",{version:i().minimumVersion})),p(c,y(ee,{get when(){return Ee(()=>!!i().incompatibilityReason)()&&i().incompatibilityReason!=="step_timestamp"},get children(){var v=ib();return p(v,()=>t(`settings.opencode.setup.${i().incompatibilityReason}`)),v}}),null),c})(),y(ee,{get when(){return i().canReload},get children(){var c=xA(),l=c.firstChild,d=l.nextSibling,u=d.nextSibling,f=u.firstChild;return p(l,()=>t("settings.opencode.setup.troubleshooting")),p(d,()=>t("settings.opencode.setup.reloadDescription")),f.$$click=()=>void pc("reload"),p(f,()=>t("settings.opencode.setup.reload")),de(()=>f.disabled=n()||xr()),c}})]}),null),de(i=>{var c=n(),l=n();return c!==i.e&&me(r,"aria-busy",i.e=c),l!==i.t&&(a.disabled=i.t=l),i},{e:void 0,t:void 0}),r})()}Xt(["click"]);const Pi={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var _A=O("<svg>");const $A=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),nt=e=>{const[t,n]=Nt(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var s=_A();return lr(s,_e(Pi,{get width(){return t.size??Pi.width},get height(){return t.size??Pi.height},get stroke(){return t.color??Pi.stroke},get"stroke-width"(){return Ee(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??Pi["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??Pi["stroke-width"])},get class(){return`lucide lucide-${$A((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),p(s,y(zt,{get each(){return t.iconNode},children:([r,o])=>y(Tp,_e({component:r},o))})),s})()},CA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],EA=e=>y(nt,_e(e,{name:"AlertCircle",iconNode:CA})),TA=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Yk=e=>y(nt,_e(e,{name:"ArrowLeft",iconNode:TA})),MA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]],AA=e=>y(nt,_e(e,{name:"ArrowRightSquare",iconNode:MA})),DA=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],PA=e=>y(nt,_e(e,{name:"ArrowUpLeft",iconNode:DA})),IA=[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]],Jk=e=>y(nt,_e(e,{name:"Bell",iconNode:IA})),RA=[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]],OA=e=>y(nt,_e(e,{name:"BookOpen",iconNode:RA})),LA=[["path",{d:"M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z",key:"1mhkh5"}],["path",{d:"M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z",key:"1d6s00"}]],NA=e=>y(nt,_e(e,{name:"Brain",iconNode:LA})),FA=[["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}],["path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11",key:"1jnkn4"}]],BA=e=>y(nt,_e(e,{name:"CheckSquare",iconNode:FA})),UA=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Qk=e=>y(nt,_e(e,{name:"Check",iconNode:UA})),KA=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],fr=e=>y(nt,_e(e,{name:"ChevronDown",iconNode:KA})),VA=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jA=e=>y(nt,_e(e,{name:"ChevronRight",iconNode:VA})),qA=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],zA=e=>y(nt,_e(e,{name:"ClipboardCheck",iconNode:qA})),WA=[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]],HA=e=>y(nt,_e(e,{name:"Code",iconNode:WA})),GA=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],ZA=e=>y(nt,_e(e,{name:"Coins",iconNode:GA})),YA=[["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}],["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["line",{x1:"10",x2:"21",y1:"14",y2:"3",key:"18c3s4"}]],Yi=e=>y(nt,_e(e,{name:"ExternalLink",iconNode:YA})),JA=[["circle",{cx:"6",cy:"13",r:"3",key:"1z65bp"}],["path",{d:"m9.7 14.4-.9-.3",key:"o1luaq"}],["path",{d:"m3.2 11.9-.9-.3",key:"qm3zk5"}],["path",{d:"m4.6 16.7.3-.9",key:"1o0ect"}],["path",{d:"m7.6 16.7-.4-1",key:"1ym8d1"}],["path",{d:"m4.8 10.3-.4-1",key:"18q26g"}],["path",{d:"m2.3 14.6 1-.4",key:"121m88"}],["path",{d:"m8.7 11.8 1-.4",key:"9meqp2"}],["path",{d:"m7.4 9.3-.3.9",key:"136qqn"}],["path",{d:"M14 2v6h6",key:"1kof46"}],["path",{d:"M4 5.5V4a2 2 0 0 1 2-2h8.5L20 7.5V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-1.5",key:"xwe04"}]],QA=e=>y(nt,_e(e,{name:"FileCog",iconNode:JA})),XA=[["path",{d:"M4 13.5V4a2 2 0 0 1 2-2h8.5L20 7.5V20a2 2 0 0 1-2 2h-5.5",key:"1bg6eb"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M10.42 12.61a2.1 2.1 0 1 1 2.97 2.97L7.95 21 4 22l.99-3.95 5.43-5.44Z",key:"1rgxu8"}]],eD=e=>y(nt,_e(e,{name:"FileEdit",iconNode:XA})),tD=[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]],nD=e=>y(nt,_e(e,{name:"File",iconNode:tD})),sD=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],rD=e=>y(nt,_e(e,{name:"FolderOpen",iconNode:sD})),oD=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],iD=e=>y(nt,_e(e,{name:"FolderPlus",iconNode:oD})),aD=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Xk=e=>y(nt,_e(e,{name:"Folder",iconNode:aD})),cD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ei=e=>y(nt,_e(e,{name:"Globe",iconNode:cD})),lD=[["path",{d:"M22 10v6M2 10l10-5 10 5-10 5z",key:"1ef52a"}],["path",{d:"M6 12v5c3 3 9 3 12 0v-5",key:"1f75yj"}]],dD=e=>y(nt,_e(e,{name:"GraduationCap",iconNode:lD})),uD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],fD=e=>y(nt,_e(e,{name:"HelpCircle",iconNode:uD})),gD=[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]],hD=e=>y(nt,_e(e,{name:"Home",iconNode:gD})),mD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Up=e=>y(nt,_e(e,{name:"Info",iconNode:mD})),pD=[["path",{d:"M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z",key:"167ctg"}],["circle",{cx:"16.5",cy:"7.5",r:".5",key:"1kog09"}]],yD=e=>y(nt,_e(e,{name:"KeyRound",iconNode:pD})),vD=[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]],ab=e=>y(nt,_e(e,{name:"Key",iconNode:vD})),wD=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],bD=e=>y(nt,_e(e,{name:"Languages",iconNode:wD})),SD=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],kD=e=>y(nt,_e(e,{name:"LayoutGrid",iconNode:SD})),xD=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Td=e=>y(nt,_e(e,{name:"Link2",iconNode:xD})),_D=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Zn=e=>y(nt,_e(e,{name:"Loader2",iconNode:_D})),$D=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],CD=e=>y(nt,_e(e,{name:"LogIn",iconNode:$D})),ED=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],TD=e=>y(nt,_e(e,{name:"Maximize2",iconNode:ED})),MD=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],AD=e=>y(nt,_e(e,{name:"MessageSquare",iconNode:MD})),DD=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],Ig=e=>y(nt,_e(e,{name:"Mic",iconNode:DD})),PD=[["path",{d:"M5 12h14",key:"1ays0h"}]],ID=e=>y(nt,_e(e,{name:"Minus",iconNode:PD})),RD=[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],OD=e=>y(nt,_e(e,{name:"MonitorUp",iconNode:RD})),LD=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],ND=e=>y(nt,_e(e,{name:"Network",iconNode:LD})),FD=[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]],BD=e=>y(nt,_e(e,{name:"Paperclip",iconNode:FD})),UD=[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],KD=e=>y(nt,_e(e,{name:"Pencil",iconNode:UD})),VD=[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],ex=e=>y(nt,_e(e,{name:"PlugZap",iconNode:VD})),jD=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],of=e=>y(nt,_e(e,{name:"Plus",iconNode:jD})),qD=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Gd=e=>y(nt,_e(e,{name:"RefreshCw",iconNode:qD})),zD=[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]],WD=e=>y(nt,_e(e,{name:"Save",iconNode:zD})),HD=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],cb=e=>y(nt,_e(e,{name:"Search",iconNode:HD})),GD=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],nd=e=>y(nt,_e(e,{name:"Settings",iconNode:GD})),ZD=[["path",{d:"M19.7 14a6.9 6.9 0 0 0 .3-2V5l-8-3-3.2 1.2",key:"342pvf"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4.7 4.7 4 5v7c0 6 8 10 8 10a20.3 20.3 0 0 0 5.62-4.38",key:"p0ycf4"}]],lb=e=>y(nt,_e(e,{name:"ShieldOff",iconNode:ZD})),YD=[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}]],Zd=e=>y(nt,_e(e,{name:"Shield",iconNode:YD})),JD=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],QD=e=>y(nt,_e(e,{name:"SlidersHorizontal",iconNode:JD})),XD=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],db=e=>y(nt,_e(e,{name:"Square",iconNode:XD})),eP=[["path",{d:"M4.8 2.3A.3.3 0 1 0 5 2H4a2 2 0 0 0-2 2v5a6 6 0 0 0 6 6v0a6 6 0 0 0 6-6V4a2 2 0 0 0-2-2h-1a.2.2 0 1 0 .3.3",key:"1jd90r"}],["path",{d:"M8 15v1a6 6 0 0 0 6 6v0a6 6 0 0 0 6-6v-4",key:"126ukv"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],tP=e=>y(nt,_e(e,{name:"Stethoscope",iconNode:eP})),nP=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],Kp=e=>y(nt,_e(e,{name:"Terminal",iconNode:nP})),sP=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],af=e=>y(nt,_e(e,{name:"Trash2",iconNode:sP})),rP=[["polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",key:"16drj5"}],["path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",key:"ltjumu"}],["path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",key:"1kegas"}]],Kh=e=>y(nt,_e(e,{name:"Volume2",iconNode:rP})),oP=[["path",{d:"M5 13a10 10 0 0 1 14 0",key:"6v8j51"}],["path",{d:"M8.5 16.5a5 5 0 0 1 7 0",key:"sej527"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["line",{x1:"12",x2:"12.01",y1:"20",y2:"20",key:"of4bc4"}]],iP=e=>y(nt,_e(e,{name:"Wifi",iconNode:oP})),aP=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ti=e=>y(nt,_e(e,{name:"X",iconNode:aP})),uH={maxFileBytes:5*1024*1024,maxFiles:10,maxTotalBytes:20*1024*1024,maxRequestBodyBytes:32*1024*1024},ub="__drives__",Vh="opencode_v2_required",cP="session_environment_failed";var lP=O("<div class=directory-browser-destinations role=listbox>"),dP=O('<div class=directory-browser-address><input type=text role=combobox aria-autocomplete=list class="selector-input directory-browser-current-path">'),uP=O("<button type=button role=option class=directory-browser-destination><span class=truncate>");const fP=e=>{const{t}=Dt(),n=Do(),[s,r]=R(-1),o=()=>e.open&&e.destinations.length>0;return Ze(()=>{var a;o()&&s()>=0&&((a=document.getElementById(`${n}-${s()}`))==null||a.scrollIntoView({block:"nearest"}))}),(()=>{var a=dP(),i=a.firstChild;return a.$$focusout=c=>{c.currentTarget.contains(c.relatedTarget)||e.onOpenChange(!1)},i.$$keydown=c=>{if(c.key==="Escape"&&e.open)c.preventDefault(),c.stopPropagation(),e.onOpenChange(!1),e.onReset();else if(c.key==="ArrowDown"&&!e.open&&e.destinations.length>0)c.preventDefault(),e.onOpenChange(!0),r(0);else if(c.key==="ArrowDown"&&o())c.preventDefault(),r(l=>Math.min(l+1,e.destinations.length-1));else if(c.key==="ArrowUp"&&o())c.preventDefault(),r(l=>Math.max(l-1,-1));else if(c.key==="Enter"){c.preventDefault();const l=o()?e.destinations[s()]:void 0;l?e.onChoose(l):e.onSubmit(),e.onOpenChange(!1),r(-1)}},i.$$click=()=>{e.open||(e.onOpenChange(!0),r(-1))},i.addEventListener("focus",()=>{e.onOpenChange(!0),r(-1)}),i.$$input=c=>{e.onInput(c.currentTarget.value),r(-1)},me(i,"spellcheck",!1),p(a,y(ee,{get when(){return o()},get children(){var c=lP();return me(c,"id",n),p(c,y(zt,{get each(){return e.destinations},children:(l,d)=>(()=>{var u=uP(),f=u.firstChild;return u.$$click=()=>{e.onChoose(l),e.onOpenChange(!1),r(-1)},u.$$mousedown=g=>g.preventDefault(),p(u,(()=>{var g=Ee(()=>l.kind==="initial");return()=>g()?y(Yk,{class:"w-4 h-4"}):Ee(()=>l.kind==="parent")()?y(PA,{class:"w-4 h-4"}):Ee(()=>l.kind==="home")()?y(hD,{class:"w-4 h-4"}):y(Xk,{class:"w-4 h-4"})})(),f),p(f,()=>l.label),de(g=>{var m=`${n}-${d()}`,w=s()===d()?"":void 0,S=s()===d(),b=l.target;return m!==g.e&&me(u,"id",g.e=m),w!==g.t&&me(u,"data-active",g.t=w),S!==g.a&&me(u,"aria-selected",g.a=S),b!==g.o&&me(u,"title",g.o=b),g},{e:void 0,t:void 0,a:void 0,o:void 0}),u})()})),de(()=>me(c,"aria-label",t("directoryBrowser.goTo"))),c}}),null),de(c=>{var l=t("directoryBrowser.currentFolder.inputPlaceholder"),d=t("directoryBrowser.currentFolder.inputAriaLabel"),u=o(),f=o()?n:void 0,g=o()&&s()>=0?`${n}-${s()}`:void 0;return l!==c.e&&me(i,"placeholder",c.e=l),d!==c.t&&me(i,"aria-label",c.t=d),u!==c.a&&me(i,"aria-expanded",c.a=u),f!==c.o&&me(i,"aria-controls",c.o=f),g!==c.i&&me(i,"aria-activedescendant",c.i=g),c},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),de(()=>i.value=e.value),a})()};Xt(["focusout","input","click","keydown","mousedown"]);var gP=O('<button type=button class="selector-button selector-button-secondary directory-browser-select directory-browser-new-folder"><span class="inline-flex items-center gap-2">'),hP=O('<div><span class=directory-browser-current-label></span><button type=button class="selector-button selector-button-secondary directory-browser-open-path"><span>'),mP=O('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),pP=O('<div class="fixed inset-0 z-[1305] flex items-center justify-center bg-black/60 p-6"><div class="modal-surface directory-browser-modal"role=dialog aria-modal=true><div class="panel directory-browser-panel"><div class=directory-browser-header><div class=directory-browser-heading><h3 class=directory-browser-title></h3><p class=directory-browser-description></p></div><button type=button class=directory-browser-close></button></div><div class="panel-body directory-browser-body">'),yP=O("<div class=directory-browser-loading><span>"),fb=O('<div class="panel-empty-state flex-1">'),vP=O("<span class=text-red-500>"),wP=O('<div class=panel-list-item role=option><div class="panel-list-item-content directory-browser-row"><button type=button class=directory-browser-row-main><div class=directory-browser-row-icon></div><div class=directory-browser-row-text><span class=directory-browser-row-name>'),bP=O('<button type=button class="selector-button selector-button-secondary directory-browser-select">');function Ko(e){if(!e||e==="."||e==="./")return".";if(e===ub)return ub;let t=e.replace(/\\/g,"/");if(/^[a-zA-Z]:/.test(t)){const[n,s=""]=t.split(":"),r=s.startsWith("/")?s:s?`/${s}`:"/";return`${n.toUpperCase()}:${r.replace(/\/+/g,"/")}`}return t.startsWith("//")?`//${t.slice(2).replace(/\/+/g,"/")}`:t.startsWith("/")?`/${t.slice(1).replace(/\/+/g,"/")}`:(t=t.replace(/^\.\/+/,"").replace(/\/+/g,"/"),t===""?".":t)}function jh(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function Md(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(jh(t))return t;const n=e.includes("\\")?"\\":"/",s=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${s}${r}`}function oc(e){return!e||e.pathKind==="drives"?"":e.pathKind==="relative"?Md(e.rootPath,e.currentPath):e.displayPath}const SP=e=>{const{t}=Dt(),[n,s]=R(""),[r,o]=R(!1),[a,i]=R(null),[c,l]=R(""),[d,u]=R(!1),[f,g]=R(!1),[m,w]=R(new Map),[S,b]=R(new Set),[v,k]=R(null),[C,_]=R(null),[T,P]=R(""),[I,j]=R(!1),ne=new Map,W=new Map;let q=0,U=0;function G(){++U,++q,s(""),w(new Map),b(new Set),k(null),_(null),l(""),u(!1),P(""),j(!1),ne.clear(),W.clear(),i(null)}Ze(()=>{if(!e.open)return;G(),le(U);const B=se=>{se.key==="Escape"&&(se.preventDefault(),e.onClose())};window.addEventListener("keydown",B),dt(()=>{window.removeEventListener("keydown",B)})});async function le(B){var se;o(!0);try{const pe=(se=e.initialPath)==null?void 0:se.trim();if(pe){const Se=await N(pe);if(B!==U||!e.open)return;if(Se){P(oc(Se));return}i(null)}B===U&&e.open&&await N(void 0)}finally{B===U&&e.open&&o(!1)}}function K(B){const se=Ko(B.currentPath);k(se),_(B),s(B.rootPath)}async function M(B){const se=U,pe=B?Ko(B):void 0;if(pe){const Q=ne.get(pe);if(Q)return Q;const be=W.get(pe);if(be)return be}const Se=(async()=>{pe&&b(He=>{const re=new Set(He);return re.add(pe),re});const Q=await kt.listFileSystem(B,{includeFiles:e.mode==="files"});if(se!==U||!e.open)return Q.metadata;const be=Ko(Q.metadata.currentPath),Ve=Q.entries.filter(He=>e.mode==="files"||He.type==="directory").sort((He,re)=>{const F=He.type==="directory"?0:1,V=re.type==="directory"?0:1;return F!==V?F-V:He.name.localeCompare(re.name)});return w(He=>{const re=new Map(He);return re.set(be,Ve),re}),ne.set(be,Q.metadata),b(He=>{const re=new Set(He);return pe&&re.delete(pe),re.delete(be),re}),Q.metadata})().catch(Q=>{throw pe&&se===U&&b(be=>{const Ve=new Set(be);return Ve.delete(pe),Ve}),Q}).finally(()=>{pe&&W.get(pe)===Se&&W.delete(pe)});return pe&&W.set(pe,Se),Se}async function N(B){const se=++q;i(null);try{const pe=await M(B);return se!==q||!e.open?null:(K(pe),pe)}catch(pe){if(se!==q||!e.open)return null;const Se=pe instanceof Error?pe.message:t("directoryBrowser.load.errorFallback");return i(Se),null}}const oe=Te(()=>{const B=v();return B?m().get(B)??[]:[]});function ge(B){u(!1),N(B)}const Ie=Te(()=>oc(C()));Ze(()=>{const B=Ie();d()||l(B)});const ke=Te(()=>!!Ie()),we=Te(()=>c().trim().length>0),Ae=Te(()=>{const B=C();if(!B)return[];const se=Ie(),pe=[],Se=new Set([Ko(se)]),Q=V=>{const Me=Ko(V.target);Se.has(Me)||(Se.add(Me),pe.push(V))},be=T();if(be){const V=be.split(/[\\/]/).filter(Boolean).at(-1)??be;Q({target:be,label:t("directoryBrowser.goToInitial",{name:V}),kind:"initial"})}if(B.scope==="unrestricted"&&B.homePath&&Q({target:B.homePath,label:t("directoryBrowser.goToHome"),kind:"home"}),B.parentPath){const V=B.pathKind==="relative"?Md(B.rootPath,B.parentPath):B.parentPath;Q({target:V,label:t("directoryBrowser.goToParent"),kind:"parent"})}const Ve=c().trim().replace(/\\/g,"/"),He=se.replace(/\\/g,"/"),re=He.replace(/\/$/,""),F=Ve===He?"":Ve.startsWith(`${re}/`)?Ve.slice(re.length+1):!Ve.includes("/")&&!Ve.includes(":")?Ve:null;if(!F||F.includes("/"))return pe;for(const V of m().get(v()??"")??[])V.type!=="directory"||!V.name.toLocaleLowerCase().startsWith(F.toLocaleLowerCase())||Q({target:V.absolutePath??(jh(V.path)?V.path:Md(B.rootPath,V.path)),label:V.name,kind:"folder"});return pe});function Ge(B){j(!1),u(!1),N(B.target)}async function H(){j(!1);const B=c().trim();if(!B)return;const se=await N(B);se&&(u(!1),l(oc(se)))}async function h(){const B=c().trim(),se=B&&B!==Ie()?await N(B):C();if(!se)return;u(!1);const pe=oc(se);pe&&e.mode!=="files"&&(l(pe),e.onSelect(pe))}function $(B){const se=B.absolutePath?B.absolutePath:jh(B.path)?B.path:Md(n(),B.path);e.onSelect(se,B)}async function D(){var Se;if(f())return;const B=c().trim(),se=B&&B!==Ie()?await N(B):C();if(!se||se.pathKind==="drives")return;u(!1),l(oc(se));const pe=((Se=await tA(t("directoryBrowser.createFolder.promptMessage"),{title:t("directoryBrowser.createFolder.title"),inputLabel:t("directoryBrowser.createFolder.inputLabel"),inputPlaceholder:t("directoryBrowser.createFolder.inputPlaceholder"),confirmLabel:t("directoryBrowser.createFolder.confirmLabel"),cancelLabel:t("directoryBrowser.createFolder.cancelLabel")}))==null?void 0:Se.trim())??"";if(pe){if(pe==="."||pe===".."||pe.startsWith("~")||pe.includes("/")||pe.includes("\\")){Ns(t("directoryBrowser.createFolder.invalidNameMessage"),{variant:"warning",detail:t("directoryBrowser.createFolder.invalidNameDetail")});return}g(!0);try{const Q=Ko(se.currentPath);ne.delete(Q),W.delete(Q),w(Ve=>{const He=new Map(Ve);return He.delete(Q),He});const be=await kt.createFileSystemFolder(se.currentPath,pe);await N(be.path)}catch(Q){const be=Q instanceof Error?Q.message:t("directoryBrowser.createFolder.errorFallback");Ns(be,{variant:"error",title:t("directoryBrowser.createFolder.errorFallback")})}finally{g(!1)}}}function E(B){return S().has(Ko(B))}function Z(B){B.target===B.currentTarget&&e.onClose()}return y(ee,{get when(){return e.open},get children(){var B=pP(),se=B.firstChild,pe=se.firstChild,Se=pe.firstChild,Q=Se.firstChild,be=Q.firstChild,Ve=be.nextSibling,He=Q.nextSibling,re=Se.nextSibling;return B.$$click=Z,p(be,()=>e.title),p(Ve,()=>e.description||t("directoryBrowser.defaultDescription")),lk(He,"click",e.onClose,!0),p(He,y(ti,{class:"w-5 h-5"})),p(re,y(ee,{get when(){return n()},get children(){var F=hP(),V=F.firstChild,Me=V.nextSibling,xe=Me.firstChild;return p(V,()=>t("directoryBrowser.currentFolder")),p(F,y(fP,{get value(){return c()},get destinations(){return Ae()},get open(){return Ee(()=>!!I())()&&!f()},onOpenChange:j,onInput:Re=>{l(Re),u(!0)},onReset:()=>{u(!1),l(Ie())},onSubmit:()=>void H(),onChoose:Ge}),Me),p(F,y(ee,{get when(){return e.mode!=="files"},get children(){var Re=gP(),Be=Re.firstChild;return Re.$$click=()=>void D(),p(Be,y(iD,{class:"w-4 h-4"}),null),p(Be,(()=>{var et=Ee(()=>!!f());return()=>et()?t("directoryBrowser.creating"):t("directoryBrowser.newFolder")})(),null),de(()=>Re.disabled=!ke()||f()),Re}}),Me),Me.$$click=()=>void h(),p(Me,y(AA,{class:"w-4 h-4"}),xe),p(xe,()=>t("directoryBrowser.openCurrent")),de(Re=>{var Be=`directory-browser-current ${e.mode==="files"?"directory-browser-current--files":""}`,et=!ke()&&!we()||f(),Ue=t("directoryBrowser.openCurrent"),We=t("directoryBrowser.openCurrent");return Be!==Re.e&&ws(F,Re.e=Be),et!==Re.t&&(Me.disabled=Re.t=et),Ue!==Re.a&&me(Me,"title",Re.a=Ue),We!==Re.o&&me(Me,"aria-label",Re.o=We),Re},{e:void 0,t:void 0,a:void 0,o:void 0}),F}}),null),p(re,y(ee,{get when(){return Ee(()=>!r())()&&!a()},get fallback(){return(()=>{var F=fb();return p(F,y(ee,{get when(){return r()},get fallback(){return(()=>{var V=vP();return p(V,a),V})()},get children(){var V=yP(),Me=V.firstChild;return p(V,y(Zn,{class:"w-5 h-5 animate-spin"}),Me),p(Me,()=>t("directoryBrowser.loadingFolders")),V}})),F})()},get children(){return y(ee,{get when(){return oe().length>0},get fallback(){return(()=>{var F=fb();return p(F,()=>t("directoryBrowser.noFolders")),F})()},get children(){var F=mP();return p(F,y(zt,{get each(){return oe()},children:V=>{const Me=V.type==="directory",xe=e.mode==="files"?V.type==="file":Me,Re=()=>{if(Me){ge(V.path);return}$(V)};return(()=>{var Be=wP(),et=Be.firstChild,Ue=et.firstChild,We=Ue.firstChild,st=We.nextSibling,at=st.firstChild;return Ue.$$click=Re,p(We,y(ee,{when:!Me,get fallback(){return y(Xk,{class:"w-4 h-4"})},get children(){return y(nD,{class:"w-4 h-4"})}})),p(at,()=>V.name||V.path),p(Ue,y(ee,{get when(){return Me&&E(V.path)},get children(){return y(Zn,{class:"directory-browser-row-spinner animate-spin"})}}),null),p(et,xe?(()=>{var ht=bP();return ht.$$click=ut=>{ut.stopPropagation(),$(V)},p(ht,()=>t("directoryBrowser.select")),ht})():null,null),Be})()}})),F}})}}),null),de(()=>me(He,"aria-label",t("directoryBrowser.close"))),B}})};Xt(["click"]);const kP=Ut("actions");function xP(e){return!e||e.canceled?[]:(Array.isArray(e.paths)?e.paths:e.path?[e.path]:[]).filter(n=>typeof n=="string"&&n.trim().length>0)}async function _P(e){if(typeof window>"u")return null;const t=window.electronAPI;if(!(t!=null&&t.openDialog))return null;try{const n=await t.openDialog(e),s=xP(n);return e.multiple?s:s[0]??null}catch(n){return kP.error("[native] electron dialog failed",n),null}}async function $P(e={}){return typeof e=="object"&&Object.freeze(e),await Ms("plugin:dialog|open",{options:e})}const CP=Ut("actions");async function EP(e){var t;if(typeof window>"u")return null;try{const n=await $P({title:e.title,defaultPath:e.defaultPath,directory:e.mode==="directory",multiple:!!e.multiple,filters:(t=e.filters)==null?void 0:t.map(s=>({name:s.name??"Files",extensions:s.extensions}))});return n?Array.isArray(n)?e.multiple?n:n[0]??null:e.multiple?[n]:n:null}catch(n){return CP.error("[native] tauri dialog failed",n),null}}function TP(){return Bn()?_P:Dn()?EP:null}function MP(){return YT()}async function tx(e){const t=TP();return t?t(e):null}async function fH(e){const t=await tx({mode:"directory",...e??{}});return Array.isArray(t)?t[0]??null:t}async function AP(e){const t=await tx({mode:"file",...e??{}});return Array.isArray(t)?t[0]??null:t}var DP=O('<div class="selector-loading text-xs"><span>'),PP=O("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),IP=O('<div class=panel><div class="panel-header flex items-center justify-between gap-3"><div><h3 class=panel-title></h3><p class=panel-subtitle></p></div></div><div class="panel-body space-y-3"><div class=selector-input-group><input type=text class=selector-input><button type=button class="selector-button selector-button-primary"></button></div><button type=button class="selector-button selector-button-secondary w-full flex items-center justify-center gap-2"></button></div><div class="panel-list panel-list--fill max-h-80 overflow-y-auto">'),RP=O('<div class="text-xs font-mono truncate pl-6 text-muted">'),OP=O("<span class=selector-badge-version>"),Rg=O("<span class=selector-badge-time>"),LP=O('<button type=button class="p-2 text-muted hover:text-primary">'),NP=O('<div class="panel-list-item flex items-center"><button type=button class="panel-list-item-content flex-1"><div class="flex flex-col flex-1 min-w-0 gap-1.5"><div class="flex items-center gap-2"><span class="text-sm font-medium truncate text-primary"></span></div><div class="flex items-center gap-2 text-xs text-muted pl-6 flex-wrap">');const FP=Ut("actions"),BP=e=>{const{t}=Dt(),{opencodeBinaries:n,addOpenCodeBinary:s,removeOpenCodeBinary:r,serverSettings:o}=Un(),[a,i]=R(""),[c,l]=R(!1),[d,u]=R(null),[f,g]=R(new Map),[m,w]=R(new Set),[S,b]=R(!1),v=()=>n(),k=()=>o().opencodeBinary,C=Te(()=>v().filter(M=>M.path!=="opencode"&&M.path!=="opencode2")),_=Te(()=>[{path:"opencode2",isDefault:!0},...C()]),T=()=>e.selectedBinary||"opencode2";Ze(()=>{if(!e.selectedBinary&&k())e.onBinaryChange(k());else if(!e.selectedBinary){const M=v()[0];M&&e.onBinaryChange(M.path)}}),Ze(()=>{const M=new Map(f());let N=!1;v().forEach(oe=>{oe.version&&!M.has(oe.path)&&(M.set(oe.path,oe.version),N=!0)}),N&&g(M)}),Ze(()=>{if(!e.isVisible)return;const M=f(),N=["opencode2",...C().map(oe=>oe.path)].filter(oe=>!M.has(oe));N.length!==0&&setTimeout(()=>{N.forEach(oe=>{P(oe).catch(ge=>FP.error("Failed to validate binary",{path:oe,error:ge}))})},0)}),dt(()=>{w(new Set),l(!1)});async function P(M){if(m().has(M))return{valid:!1,error:t("opencodeBinarySelector.validation.alreadyValidating")};try{w(ge=>new Set(ge).add(M)),l(!0),u(null);const N=await kt.validateBinary(M),oe=N.errorCode===Vh?{...N,error:t("opencodeBinarySelector.validation.v2Required")}:N;if(oe.valid&&oe.version){const ge=new Map(f());ge.set(M,oe.version),g(ge)}return oe}catch(N){return{valid:!1,error:N instanceof Error?N.message:String(N)}}finally{w(N=>{const oe=new Set(N);return oe.delete(M),oe.size===0&&l(!1),oe})}}async function I(){if(!e.disabled){if(u(null),MP()){const M=await AP({title:t("opencodeBinarySelector.dialog.title")});M&&(i(M),j(M));return}b(!0)}}async function j(M){const N=await P(M);N.valid?(s(M,N.version),e.onBinaryChange(M),i(""),u(null)):u(N.error||t("opencodeBinarySelector.validation.invalidBinary"))}function ne(M){b(!1),i(M),j(M)}async function W(){const M=a().trim();M&&await j(M)}function q(M){e.disabled||M!==e.selectedBinary&&e.onBinaryChange(M)}function U(M,N){N.stopPropagation(),!e.disabled&&(r(M),e.selectedBinary===M&&e.onBinaryChange("opencode2"))}function G(M){if(!M)return"";const N=Math.floor((Date.now()-M)/1e3),oe=Math.floor(N/60),ge=Math.floor(oe/60),Ie=Math.floor(ge/24);return Ie>0?t("time.relative.daysAgoShort",{count:Ie}):ge>0?t("time.relative.hoursAgoShort",{count:ge}):oe>0?t("time.relative.minutesAgoShort",{count:oe}):t("time.relative.justNow")}function le(M){if(M==="opencode2")return t("opencodeBinarySelector.display.systemPath",{name:"opencode2"});const N=M.split(/[/\\]/);return N[N.length-1]??M}const K=M=>m().has(M);return[(()=>{var M=IP(),N=M.firstChild,oe=N.firstChild,ge=oe.firstChild,Ie=ge.nextSibling,ke=N.nextSibling,we=ke.firstChild,Ae=we.firstChild,Ge=Ae.nextSibling,H=we.nextSibling,h=ke.nextSibling;return p(ge,()=>t("opencodeBinarySelector.title")),p(Ie,()=>t("opencodeBinarySelector.subtitle")),p(N,y(ee,{get when(){return c()},get children(){var $=DP(),D=$.firstChild;return p($,y(Zn,{class:"selector-loading-spinner"}),D),p(D,()=>t("opencodeBinarySelector.status.checkingVersions")),$}}),null),Ae.$$keydown=$=>{$.key==="Enter"&&($.preventDefault(),W())},Ae.$$input=$=>i($.currentTarget.value),Ge.$$click=W,p(Ge,y(of,{class:"w-4 h-4"}),null),p(Ge,()=>t("opencodeBinarySelector.actions.add"),null),H.$$click=()=>void I(),p(H,y(rD,{class:"w-4 h-4"}),null),p(H,()=>t("opencodeBinarySelector.actions.browse"),null),p(ke,y(ee,{get when(){return d()},get children(){var $=PP(),D=$.firstChild,E=D.firstChild;return p(D,y(EA,{class:"selector-validation-error-icon"}),E),p(E,d),$}}),null),p(h,y(zt,{get each(){return _()},children:$=>{const D=$.isDefault,E=()=>(D?e.defaultVersion:void 0)??f().get($.path)??$.version;return(()=>{var Z=NP(),B=Z.firstChild,se=B.firstChild,pe=se.firstChild,Se=pe.firstChild,Q=pe.nextSibling;return B.$$click=()=>q($.path),p(pe,y(Qk,{get class(){return`w-4 h-4 transition-opacity ${T()===$.path?"opacity-100":"opacity-0"}`}}),Se),p(Se,()=>le($.path)),p(se,y(ee,{when:!D,get children(){var be=RP();return p(be,()=>$.path),be}}),Q),p(Q,y(ee,{get when(){return E()},get children(){var be=OP();return p(be,()=>t("opencodeBinarySelector.versionLabel",{version:E()})),be}}),null),p(Q,y(ee,{get when(){return K($.path)},get children(){var be=Rg();return p(be,()=>t("opencodeBinarySelector.status.checking")),be}}),null),p(Q,y(ee,{get when(){return!D&&$.lastUsed},get children(){var be=Rg();return p(be,()=>G($.lastUsed)),be}}),null),p(Q,y(ee,{when:D,get children(){var be=Rg();return p(be,()=>t("opencodeBinarySelector.badge.systemPath")),be}}),null),p(Z,y(ee,{when:!D,get children(){var be=LP();return be.$$click=Ve=>U($.path,Ve),p(be,y(af,{class:"w-3.5 h-3.5"})),de(Ve=>{var He=e.disabled,re=t("opencodeBinarySelector.actions.removeTitle");return He!==Ve.e&&(be.disabled=Ve.e=He),re!==Ve.t&&me(be,"title",Ve.t=re),Ve},{e:void 0,t:void 0}),be}}),null),de(be=>{var Ve=T()===$.path,He=e.disabled;return Ve!==be.e&&Z.classList.toggle("panel-list-item-highlight",be.e=Ve),He!==be.t&&(B.disabled=be.t=He),be},{e:void 0,t:void 0}),Z})()}})),de($=>{var D=e.disabled,E=t("opencodeBinarySelector.customPath.placeholder",{name:"opencode2"}),Z=e.disabled||!a().trim(),B=e.disabled;return D!==$.e&&(Ae.disabled=$.e=D),E!==$.t&&me(Ae,"placeholder",$.t=E),Z!==$.a&&(Ge.disabled=$.a=Z),B!==$.o&&(H.disabled=$.o=B),$},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>Ae.value=a()),M})(),y(SP,{get open(){return S()},mode:"files",get title(){return t("opencodeBinarySelector.dialog.title")},get description(){return t("opencodeBinarySelector.dialog.description")},onClose:()=>b(!1),onSelect:ne})]};Xt(["input","keydown","click"]);var UP=O('<div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server">');function nx(){const{t:e}=Dt(),{serverSettings:t,updateLastUsedBinary:n}=Un();return(()=>{var s=UP(),r=s.firstChild,o=r.firstChild,a=o.firstChild,i=a.firstChild,c=i.nextSibling,l=o.nextSibling;return p(o,y(Kp,{class:"settings-card-heading-icon"}),a),p(i,()=>e("settings.opencode.runtime.title")),p(c,()=>e("settings.opencode.runtime.subtitle")),p(l,()=>e("settings.scope.server")),p(s,y(BP,{get selectedBinary(){return t().opencodeBinary||"opencode2"},get defaultVersion(){var d;return Ee(()=>{var u;return!!((u=ur())!=null&&u.installationSource)})()?((d=ur())==null?void 0:d.currentVersion)??void 0:void 0},onBinaryChange:n,get disabled(){return mo()},isVisible:!0}),null),s})()}var KP=O('<div class="fixed bottom-4 right-4 z-50 border border-base bg-surface-secondary p-3"role=status><button class=selector-button>'),VP=O("<header class=window-header>"),jP=O("<div class=window-body>"),qP=O('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');function zP(e={}){const{t}=Dt(),{serverSettings:n}=Un();Ze(()=>{n().opencodeBinary,aa(Gk)}),Ze(()=>{vn.getStatuses(),aa(()=>{document.hidden||Fs()})});let s="";return Ze(()=>{if(e.automatic===!1)return;const r=ur();if(!r||!Uh(r)){s="";return}const o=`${r.binaryPath}:${r.state}:${r.daemonVersion??""}`;s!==o&&(s=o,la(!0))}),Ys(()=>{const r=()=>{document.hidden||Fs()};window.addEventListener("focus",r),document.addEventListener("visibilitychange",r),dt(()=>{window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",r)})}),[y(ee,{get when(){return Ee(()=>!!(e.automatic!==!1&&Uh()))()&&!Rh()},get children(){return y(Mp,{get children(){var r=KP(),o=r.firstChild;return o.$$click=()=>Bp(),p(o,()=>t("settings.opencode.setup.required")),r}})}}),y(Ot,{get open(){return Rh()},onOpenChange:la,get children(){return y(Ot.Portal,{get children(){return[y(Ot.Overlay,{class:"modal-overlay"}),(()=>{var r=qP();return p(r,y(Ot.Content,{class:"modal-surface w-full max-w-2xl max-h-[85vh] overflow-auto",get children(){return[(()=>{var o=VP();return p(o,y(Ot.Title,{class:"window-title",get children(){return t("settings.opencode.setup.required")}}),null),p(o,y(Ot.CloseButton,{class:"window-action",get"aria-label"(){return t("app.launchError.close")},get children(){return t("app.launchError.close")}}),null),o})(),(()=>{var o=jP();return p(o,y(Zk,{get children(){return y(nx,{})}})),o})()]}})),r})()]}})}})]}Xt(["click"]);function sx(e){let t=e.startIndex??0;const n=e.startLevel??0,s=[],r=c=>{if(c==null)return"";const l=e.getKey??"key",d=Li(l)?c[l]:l(c);return d!=null?String(d):""},o=c=>{if(c==null)return"";const l=e.getTextValue??"textValue",d=Li(l)?c[l]:l(c);return d!=null?String(d):""},a=c=>{if(c==null)return!1;const l=e.getDisabled??"disabled";return(Li(l)?c[l]:l(c))??!1},i=c=>{var l;if(c!=null)return Li(e.getSectionChildren)?c[e.getSectionChildren]:(l=e.getSectionChildren)==null?void 0:l.call(e,c)};for(const c of e.dataSource){if(Li(c)||o2(c)){s.push({type:"item",rawValue:c,key:String(c),textValue:String(c),disabled:a(c),level:n,index:t}),t++;continue}if(i(c)!=null){s.push({type:"section",rawValue:c,key:"",textValue:"",disabled:!1,level:n,index:t}),t++;const l=i(c)??[];if(l.length>0){const d=sx({dataSource:l,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:t,startLevel:n+1});s.push(...d),t+=d.length}}else s.push({type:"item",rawValue:c,key:r(c),textValue:o(c),disabled:a(c),level:n,index:t}),t++}return s}function WP(e,t=[]){return Te(()=>{const n=sx({dataSource:he(e.dataSource),getKey:he(e.getKey),getTextValue:he(e.getTextValue),getDisabled:he(e.getDisabled),getSectionChildren:he(e.getSectionChildren)});for(let s=0;s<t.length;s++)t[s]();return e.factory(n)})}var HP=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),GP=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function ZP(e){if(Intl.Locale){const n=new Intl.Locale(e).maximize().script??"";return HP.has(n)}const t=e.split("-")[0];return GP.has(t)}function YP(e){return ZP(e)?"rtl":"ltr"}function rx(){let e=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:YP(e)}}var qh=rx(),yc=new Set;function gb(){qh=rx();for(const e of yc)e(qh)}function JP(){const[e,t]=R(qh),n=Te(()=>e());return Ys(()=>{yc.size===0&&window.addEventListener("languagechange",gb),yc.add(t),dt(()=>{yc.delete(t),yc.size===0&&window.removeEventListener("languagechange",gb)})}),{locale:()=>n().locale,direction:()=>n().direction}}var QP=qr();function Vp(){const e=JP();return zr(QP)||e}var Og=new Map;function jp(e){const{locale:t}=Vp(),n=Te(()=>t()+(e?Object.entries(e).sort((s,r)=>s[0]<r[0]?-1:1).join():""));return Te(()=>{const s=n();let r;return Og.has(s)&&(r=Og.get(s)),r||(r=new Intl.Collator(t(),e),Og.set(s,r)),r})}function gH(e){const t=jp({usage:"search",...e});return{startsWith:(o,a)=>{if(a.length===0)return!0;const i=o.normalize("NFC"),c=a.normalize("NFC");return t().compare(i.slice(0,c.length),c)===0},endsWith:(o,a)=>{if(a.length===0)return!0;const i=o.normalize("NFC"),c=a.normalize("NFC");return t().compare(i.slice(-c.length),c)===0},contains:(o,a)=>{if(a.length===0)return!0;const i=o.normalize("NFC"),c=a.normalize("NFC");let l=0;const d=a.length;for(;l+d<=i.length;l++){const u=i.slice(l,l+d);if(t().compare(c,u)===0)return!0}return!1}}}var sr=class ox extends Set{constructor(n,s,r){super(n);ae(this,"anchorKey");ae(this,"currentKey");n instanceof ox?(this.anchorKey=s||n.anchorKey,this.currentKey=r||n.currentKey):(this.anchorKey=s,this.currentKey=r)}};function XP(e){const[t,n]=Np(e);return[()=>t()??new sr,n]}function ix(e){return d2()?e.altKey:e.ctrlKey}function Ni(e){return pl()?e.metaKey:e.ctrlKey}function hb(e){return new sr(e)}function ax(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function eI(e){const t=Kt({selectionMode:"none",selectionBehavior:"toggle"},e),[n,s]=R(!1),[r,o]=R(),a=Te(()=>{const w=he(t.selectedKeys);return w!=null?hb(w):w}),i=Te(()=>{const w=he(t.defaultSelectedKeys);return w!=null?hb(w):new sr}),[c,l]=XP({value:a,defaultValue:i,onChange:w=>{var S;return(S=t.onSelectionChange)==null?void 0:S.call(t,w)}}),[d,u]=R(he(t.selectionBehavior)),f=()=>he(t.selectionMode),g=()=>he(t.disallowEmptySelection)??!1,m=w=>{(he(t.allowDuplicateSelectionEvents)||!ax(w,c()))&&l(w)};return Ze(()=>{const w=c();he(t.selectionBehavior)==="replace"&&d()==="toggle"&&typeof w=="object"&&w.size===0&&u("replace")}),Ze(()=>{u(he(t.selectionBehavior)??"toggle")}),{selectionMode:f,disallowEmptySelection:g,selectionBehavior:d,setSelectionBehavior:u,isFocused:n,setFocused:s,focusedKey:r,setFocusedKey:o,selectedKeys:c,setSelectedKeys:m}}function cx(e){const[t,n]=R(""),[s,r]=R(-1);return{typeSelectHandlers:{onKeyDown:a=>{var f;if(he(e.isDisabled))return;const i=he(e.keyboardDelegate),c=he(e.selectionManager);if(!i.getKeyForSearch)return;const l=tI(a.key);if(!l||a.ctrlKey||a.metaKey)return;l===" "&&t().trim().length>0&&(a.preventDefault(),a.stopPropagation());let d=n(g=>g+l),u=i.getKeyForSearch(d,c.focusedKey())??i.getKeyForSearch(d);u==null&&nI(d)&&(d=d[0],u=i.getKeyForSearch(d,c.focusedKey())??i.getKeyForSearch(d)),u!=null&&(c.setFocusedKey(u),(f=e.onTypeSelect)==null||f.call(e,u)),clearTimeout(s()),r(window.setTimeout(()=>n(""),500))}}}}function tI(e){return e.length===1||!/^[A-Z]/i.test(e)?e:""}function nI(e){return e.split("").every(t=>t===e[0])}function sI(e,t,n){const r=_e({selectOnFocus:()=>he(e.selectionManager).selectionBehavior()==="replace"},e),o=()=>(n==null?void 0:n())??t(),{direction:a}=Vp();let i={top:0,left:0};t2(()=>he(r.isVirtualized)?void 0:o(),"scroll",()=>{const S=o();S&&(i={top:S.scrollTop,left:S.scrollLeft})});const{typeSelectHandlers:c}=cx({isDisabled:()=>he(r.disallowTypeAhead),keyboardDelegate:()=>he(r.keyboardDelegate),selectionManager:()=>he(r.selectionManager)}),l=()=>he(r.orientation)??"vertical",d=S=>{var I,j,ne,W,q,U,G,le;on(S,c.onKeyDown),S.altKey&&S.key==="Tab"&&S.preventDefault();const b=t();if(!(b!=null&&b.contains(S.target)))return;const v=he(r.selectionManager),k=he(r.selectOnFocus),C=K=>{K!=null&&(v.setFocusedKey(K),S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(K):k&&!ix(S)&&v.replaceSelection(K))},_=he(r.keyboardDelegate),T=he(r.shouldFocusWrap),P=v.focusedKey();switch(S.key){case(l()==="vertical"?"ArrowDown":"ArrowRight"):{if(_.getKeyBelow){S.preventDefault();let K;P!=null?K=_.getKeyBelow(P):K=(I=_.getFirstKey)==null?void 0:I.call(_),K==null&&T&&(K=(j=_.getFirstKey)==null?void 0:j.call(_,P)),C(K)}break}case(l()==="vertical"?"ArrowUp":"ArrowLeft"):{if(_.getKeyAbove){S.preventDefault();let K;P!=null?K=_.getKeyAbove(P):K=(ne=_.getLastKey)==null?void 0:ne.call(_),K==null&&T&&(K=(W=_.getLastKey)==null?void 0:W.call(_,P)),C(K)}break}case(l()==="vertical"?"ArrowLeft":"ArrowUp"):{if(_.getKeyLeftOf){S.preventDefault();const K=a()==="rtl";let M;P!=null?M=_.getKeyLeftOf(P):M=K?(q=_.getFirstKey)==null?void 0:q.call(_):(U=_.getLastKey)==null?void 0:U.call(_),C(M)}break}case(l()==="vertical"?"ArrowRight":"ArrowDown"):{if(_.getKeyRightOf){S.preventDefault();const K=a()==="rtl";let M;P!=null?M=_.getKeyRightOf(P):M=K?(G=_.getLastKey)==null?void 0:G.call(_):(le=_.getFirstKey)==null?void 0:le.call(_),C(M)}break}case"Home":if(_.getFirstKey){S.preventDefault();const K=_.getFirstKey(P,Ni(S));K!=null&&(v.setFocusedKey(K),Ni(S)&&S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(K):k&&v.replaceSelection(K))}break;case"End":if(_.getLastKey){S.preventDefault();const K=_.getLastKey(P,Ni(S));K!=null&&(v.setFocusedKey(K),Ni(S)&&S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(K):k&&v.replaceSelection(K))}break;case"PageDown":if(_.getKeyPageBelow&&P!=null){S.preventDefault();const K=_.getKeyPageBelow(P);C(K)}break;case"PageUp":if(_.getKeyPageAbove&&P!=null){S.preventDefault();const K=_.getKeyPageAbove(P);C(K)}break;case"a":Ni(S)&&v.selectionMode()==="multiple"&&he(r.disallowSelectAll)!==!0&&(S.preventDefault(),v.selectAll());break;case"Escape":S.defaultPrevented||(S.preventDefault(),he(r.disallowEmptySelection)||v.clearSelection());break;case"Tab":if(!he(r.allowsTabNavigation)){if(S.shiftKey)b.focus();else{const K=k2(b,{tabbable:!0});let M,N;do N=K.lastChild(),N&&(M=N);while(N);M&&!M.contains(document.activeElement)&&On(M)}break}}},u=S=>{var C,_;const b=he(r.selectionManager),v=he(r.keyboardDelegate),k=he(r.selectOnFocus);if(b.isFocused()){S.currentTarget.contains(S.target)||b.setFocused(!1);return}if(S.currentTarget.contains(S.target)){if(b.setFocused(!0),b.focusedKey()==null){const T=I=>{I!=null&&(b.setFocusedKey(I),k&&b.replaceSelection(I))},P=S.relatedTarget;P&&S.currentTarget.compareDocumentPosition(P)&Node.DOCUMENT_POSITION_FOLLOWING?T(b.lastSelectedKey()??((C=v.getLastKey)==null?void 0:C.call(v))):T(b.firstSelectedKey()??((_=v.getFirstKey)==null?void 0:_.call(v)))}else if(!he(r.isVirtualized)){const T=o();if(T){T.scrollTop=i.top,T.scrollLeft=i.left;const P=T.querySelector(`[data-key="${b.focusedKey()}"]`);P&&(On(P),Ah(T,P))}}}},f=S=>{const b=he(r.selectionManager);S.currentTarget.contains(S.relatedTarget)||b.setFocused(!1)},g=S=>{o()===S.target&&S.preventDefault()},m=()=>{var T,P;const S=he(r.autoFocus);if(!S)return;const b=he(r.selectionManager),v=he(r.keyboardDelegate);let k;S==="first"&&(k=(T=v.getFirstKey)==null?void 0:T.call(v)),S==="last"&&(k=(P=v.getLastKey)==null?void 0:P.call(v));const C=b.selectedKeys();C.size&&(k=C.values().next().value),b.setFocused(!0),b.setFocusedKey(k);const _=t();_&&k==null&&!he(r.shouldUseVirtualFocus)&&On(_)};return Ys(()=>{r.deferAutoFocus?setTimeout(m,0):m()}),Ze(yi([o,()=>he(r.isVirtualized),()=>he(r.selectionManager).focusedKey()],S=>{var C;const[b,v,k]=S;if(v)k&&((C=r.scrollToKey)==null||C.call(r,k));else if(k&&b){const _=b.querySelector(`[data-key="${k}"]`);_&&Ah(b,_)}})),{tabIndex:Te(()=>{if(!he(r.shouldUseVirtualFocus))return he(r.selectionManager).focusedKey()==null?0:-1}),onKeyDown:d,onMouseDown:g,onFocusIn:u,onFocusOut:f}}function rI(e,t){const n=()=>he(e.selectionManager),s=()=>he(e.key),r=()=>he(e.shouldUseVirtualFocus),o=v=>{n().selectionMode()!=="none"&&(n().selectionMode()==="single"?n().isSelected(s())&&!n().disallowEmptySelection()?n().toggleSelection(s()):n().replaceSelection(s()):v!=null&&v.shiftKey?n().extendSelection(s()):n().selectionBehavior()==="toggle"||Ni(v)||"pointerType"in v&&v.pointerType==="touch"?n().toggleSelection(s()):n().replaceSelection(s()))},a=()=>n().isSelected(s()),i=()=>he(e.disabled)||n().isDisabled(s()),c=()=>!i()&&n().canSelectItem(s());let l=null;const d=v=>{c()&&(l=v.pointerType,v.pointerType==="mouse"&&v.button===0&&!he(e.shouldSelectOnPressUp)&&o(v))},u=v=>{c()&&v.pointerType==="mouse"&&v.button===0&&he(e.shouldSelectOnPressUp)&&he(e.allowsDifferentPressOrigin)&&o(v)},f=v=>{c()&&(he(e.shouldSelectOnPressUp)&&!he(e.allowsDifferentPressOrigin)||l!=="mouse")&&o(v)},g=v=>{!c()||!["Enter"," "].includes(v.key)||(ix(v)?n().toggleSelection(s()):o(v))},m=v=>{i()&&v.preventDefault()},w=v=>{const k=t();r()||i()||!k||v.target===k&&n().setFocusedKey(s())},S=Te(()=>{if(!(r()||i()))return s()===n().focusedKey()?0:-1}),b=Te(()=>he(e.virtualized)?void 0:s());return Ze(yi([t,s,r,()=>n().focusedKey(),()=>n().isFocused()],([v,k,C,_,T])=>{v&&k===_&&T&&!C&&document.activeElement!==v&&(e.focus?e.focus():On(v))})),{isSelected:a,isDisabled:i,allowsSelection:c,tabIndex:S,dataKey:b,onPointerDown:d,onPointerUp:u,onClick:f,onKeyDown:g,onMouseDown:m,onFocus:w}}var oI=class{constructor(e,t){ae(this,"collection");ae(this,"state");this.collection=e,this.state=t}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(e==null||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if(this.state.selectionMode()==="none")return!1;const t=this.getKey(e);return t==null?!1:this.state.selectedKeys().has(t)}isEmpty(){return this.state.selectedKeys().size===0}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every(t=>e.has(t))}firstSelectedKey(){let e;for(const t of this.state.selectedKeys()){const n=this.collection().getItem(t),s=(n==null?void 0:n.index)!=null&&(e==null?void 0:e.index)!=null&&n.index<e.index;(!e||s)&&(e=n)}return e==null?void 0:e.key}lastSelectedKey(){let e;for(const t of this.state.selectedKeys()){const n=this.collection().getItem(t),s=(n==null?void 0:n.index)!=null&&(e==null?void 0:e.index)!=null&&n.index>e.index;(!e||s)&&(e=n)}return e==null?void 0:e.key}extendSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"){this.replaceSelection(e);return}const t=this.getKey(e);if(t==null)return;const n=this.state.selectedKeys(),s=n.anchorKey||t,r=new sr(n,s,t);for(const o of this.getKeyRange(s,n.currentKey||t))r.delete(o);for(const o of this.getKeyRange(t,s))this.canSelectItem(o)&&r.add(o);this.state.setSelectedKeys(r)}getKeyRange(e,t){const n=this.collection().getItem(e),s=this.collection().getItem(t);return n&&s?n.index!=null&&s.index!=null&&n.index<=s.index?this.getKeyRangeInternal(e,t):this.getKeyRangeInternal(t,e):[]}getKeyRangeInternal(e,t){const n=[];let s=e;for(;s!=null;){const r=this.collection().getItem(s);if(r&&r.type==="item"&&n.push(s),s===t)return n;s=this.collection().getKeyAfter(s)}return[]}getKey(e){const t=this.collection().getItem(e);return t?!t||t.type!=="item"?null:t.key:e}toggleSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"&&!this.isSelected(e)){this.replaceSelection(e);return}const t=this.getKey(e);if(t==null)return;const n=new sr(this.state.selectedKeys());n.has(t)?n.delete(t):this.canSelectItem(t)&&(n.add(t),n.anchorKey=t,n.currentKey=t),!(this.disallowEmptySelection()&&n.size===0)&&this.state.setSelectedKeys(n)}replaceSelection(e){if(this.selectionMode()==="none")return;const t=this.getKey(e);if(t==null)return;const n=this.canSelectItem(t)?new sr([t],t,t):new sr;this.state.setSelectedKeys(n)}setSelectedKeys(e){if(this.selectionMode()==="none")return;const t=new sr;for(const n of e){const s=this.getKey(n);if(s!=null&&(t.add(s),this.selectionMode()==="single"))break}this.state.setSelectedKeys(t)}selectAll(){this.selectionMode()==="multiple"&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new sr)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,t){this.selectionMode()!=="none"&&(this.selectionMode()==="single"?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):this.selectionBehavior()==="toggle"||t&&t.pointerType==="touch"?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const t=this.selectedKeys();if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;for(const n of t)if(!e.has(n))return!1;return!0}canSelectItem(e){if(this.state.selectionMode()==="none")return!1;const t=this.collection().getItem(e);return t!=null&&!t.disabled}isDisabled(e){const t=this.collection().getItem(e);return!t||t.disabled}getAllSelectableKeys(){const e=[];return(n=>{for(;n!=null;){if(this.canSelectItem(n)){const s=this.collection().getItem(n);if(!s)continue;s.type==="item"&&e.push(n)}n=this.collection().getKeyAfter(n)}})(this.collection().getFirstKey()),e}},mb=class{constructor(e){ae(this,"keyMap",new Map);ae(this,"iterable");ae(this,"firstKey");ae(this,"lastKey");this.iterable=e;for(const s of e)this.keyMap.set(s.key,s);if(this.keyMap.size===0)return;let t,n=0;for(const[s,r]of this.keyMap)t?(t.nextKey=s,r.prevKey=t.key):(this.firstKey=s,r.prevKey=void 0),r.type==="item"&&(r.index=n++),t=r,t.nextKey=void 0;this.lastKey=t.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){var t;return(t=this.keyMap.get(e))==null?void 0:t.prevKey}getKeyAfter(e){var t;return(t=this.keyMap.get(e))==null?void 0:t.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const t=[...this.getKeys()];return this.getItem(t[e])}};function lx(e){const t=eI(e),s=WP({dataSource:()=>he(e.dataSource),getKey:()=>he(e.getKey),getTextValue:()=>he(e.getTextValue),getDisabled:()=>he(e.getDisabled),getSectionChildren:()=>he(e.getSectionChildren),factory:o=>e.filter?new mb(e.filter(o)):new mb(o)},[()=>e.filter]),r=new oI(s,t);return fk(()=>{const o=t.focusedKey();o!=null&&!s().getItem(o)&&t.setFocusedKey(void 0)}),{collection:s,selectionManager:()=>r}}var dx=["id","name","validationState","required","disabled","readOnly"];function ux(e){const t=`form-control-${Do()}`,n=Kt({id:t},e),[s,r]=R(),[o,a]=R(),[i,c]=R(),[l,d]=R(),u=(w,S,b)=>{const v=b!=null||s()!=null;return[b,s(),v&&S!=null?w:void 0].filter(Boolean).join(" ")||void 0},f=w=>[i(),l(),w].filter(Boolean).join(" ")||void 0,g=Te(()=>({"data-valid":he(n.validationState)==="valid"?"":void 0,"data-invalid":he(n.validationState)==="invalid"?"":void 0,"data-required":he(n.required)?"":void 0,"data-disabled":he(n.disabled)?"":void 0,"data-readonly":he(n.readOnly)?"":void 0}));return{formControlContext:{name:()=>he(n.name)??he(n.id),dataset:g,validationState:()=>he(n.validationState),isRequired:()=>he(n.required),isDisabled:()=>he(n.disabled),isReadOnly:()=>he(n.readOnly),labelId:s,fieldId:o,descriptionId:i,errorMessageId:l,getAriaLabelledBy:u,getAriaDescribedBy:f,generateId:ja(()=>he(n.id)),registerLabel:bs(r),registerField:bs(a),registerDescription:bs(c),registerErrorMessage:bs(d)}}}var qp=qr();function pr(){const e=zr(qp);if(e===void 0)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function zp(e){const t=pr(),n=Kt({id:t.generateId("description")},e);return Ze(()=>dt(t.registerDescription(n.id))),y(en,_e({as:"div"},()=>t.dataset(),n))}var iI=O("<option>"),aI=O("<div aria-hidden=true><input type=text style=font-size:16px><select tabindex=-1><option>");function cI(e){let t;const[n,s]=Nt(e,["ref","onChange","collection","selectionManager","isOpen","isMultiple","isVirtualized","focusTrigger"]),r=pr(),[o,a]=R(!1),i=c=>{const l=n.collection.getItem(c);return y(ee,{get when(){return(l==null?void 0:l.type)==="item"},get children(){var d=iI();return d.value=c,p(d,()=>l==null?void 0:l.textValue),de(()=>d.selected=n.selectionManager.isSelected(c)),d}})};return Ze(yi(()=>n.selectionManager.selectedKeys(),(c,l)=>{l&&ax(c,l)||(a(!0),t==null||t.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t==null||t.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0})))},{defer:!0})),(()=>{var c=aI(),l=c.firstChild,d=l.nextSibling;d.firstChild,l.addEventListener("focus",()=>n.focusTrigger()),d.addEventListener("change",f=>{on(f,n.onChange),o()||n.selectionManager.setSelectedKeys(new Set([f.target.value])),a(!1)});var u=Kn(f=>t=f,n.ref);return typeof u=="function"&&dr(u,d),lr(d,_e({get multiple(){return n.isMultiple},get name(){return r.name()},get required(){return r.isRequired()},get disabled(){return r.isDisabled()},get size(){return n.collection.getSize()},get value(){return n.selectionManager.firstSelectedKey()??""}},s),!1,!0),p(d,y(ee,{get when(){return n.isVirtualized},get fallback(){return y(zt,{get each(){return[...n.collection.getKeys()]},children:i})},get children(){return y(zt,{get each(){return[...n.selectionManager.selectedKeys()]},children:i})}}),null),de(f=>{var g=nf,m=n.selectionManager.isFocused()||n.isOpen?-1:0,w=r.isRequired(),S=r.isDisabled(),b=r.isReadOnly();return f.e=kr(c,g,f.e),m!==f.t&&me(l,"tabindex",f.t=m),w!==f.a&&(l.required=f.a=w),S!==f.o&&(l.disabled=f.o=S),b!==f.i&&(l.readOnly=f.i=b),f},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),c})()}var pb=new WeakMap;function lI(e){let t=pb.get(e);if(t!=null)return t;t=0;for(const n of e)n.type==="item"&&t++;return pb.set(e,t),t}var fx=class{constructor(e,t,n){ae(this,"collection");ae(this,"ref");ae(this,"collator");this.collection=e,this.ref=t,this.collator=n}getKeyBelow(e){let t=this.collection().getKeyAfter(e);for(;t!=null;){const n=this.collection().getItem(t);if(n&&n.type==="item"&&!n.disabled)return t;t=this.collection().getKeyAfter(t)}}getKeyAbove(e){let t=this.collection().getKeyBefore(e);for(;t!=null;){const n=this.collection().getItem(t);if(n&&n.type==="item"&&!n.disabled)return t;t=this.collection().getKeyBefore(t)}}getFirstKey(){let e=this.collection().getFirstKey();for(;e!=null;){const t=this.collection().getItem(e);if(t&&t.type==="item"&&!t.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;e!=null;){const t=this.collection().getItem(e);if(t&&t.type==="item"&&!t.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){var t,n;return((n=(t=this.ref)==null?void 0:t.call(this))==null?void 0:n.querySelector(`[data-key="${e}"]`))??null}getKeyPageAbove(e){var o;const t=(o=this.ref)==null?void 0:o.call(this);let n=this.getItem(e);if(!t||!n)return;const s=Math.max(0,n.offsetTop+n.offsetHeight-t.offsetHeight);let r=e;for(;r&&n&&n.offsetTop>s;)r=this.getKeyAbove(r),n=r!=null?this.getItem(r):null;return r}getKeyPageBelow(e){var o;const t=(o=this.ref)==null?void 0:o.call(this);let n=this.getItem(e);if(!t||!n)return;const s=Math.min(t.scrollHeight,n.offsetTop-n.offsetHeight+t.offsetHeight);let r=e;for(;r&&n&&n.offsetTop<s;)r=this.getKeyBelow(r),n=r!=null?this.getItem(r):null;return r}getKeyForSearch(e,t){var r;const n=(r=this.collator)==null?void 0:r.call(this);if(!n)return;let s=t!=null?this.getKeyBelow(t):this.getFirstKey();for(;s!=null;){const o=this.collection().getItem(s);if(o){const a=o.textValue.slice(0,e.length);if(o.textValue&&n.compare(a,e)===0)return s}s=this.getKeyBelow(s)}}};function dI(e,t,n){const s=jp({usage:"search",sensitivity:"base"}),r=Te(()=>{const o=he(e.keyboardDelegate);return o||new fx(e.collection,t,s)});return sI({selectionManager:()=>he(e.selectionManager),keyboardDelegate:r,autoFocus:()=>he(e.autoFocus),deferAutoFocus:()=>he(e.deferAutoFocus),shouldFocusWrap:()=>he(e.shouldFocusWrap),disallowEmptySelection:()=>he(e.disallowEmptySelection),selectOnFocus:()=>he(e.selectOnFocus),disallowTypeAhead:()=>he(e.disallowTypeAhead),shouldUseVirtualFocus:()=>he(e.shouldUseVirtualFocus),allowsTabNavigation:()=>he(e.allowsTabNavigation),isVirtualized:()=>he(e.isVirtualized),scrollToKey:o=>{var a;return(a=he(e.scrollToKey))==null?void 0:a(o)},orientation:()=>he(e.orientation)},t,n)}var uI={};yl(uI,{Item:()=>cf,ItemDescription:()=>lf,ItemIndicator:()=>df,ItemLabel:()=>uf,Listbox:()=>fI,Root:()=>Hp,Section:()=>ff,useListboxContext:()=>hx});var gx=qr();function hx(){const e=zr(gx);if(e===void 0)throw new Error("[kobalte]: `useListboxContext` must be used within a `Listbox` component");return e}var mx=qr();function Wp(){const e=zr(mx);if(e===void 0)throw new Error("[kobalte]: `useListboxItemContext` must be used within a `Listbox.Item` component");return e}function cf(e){let t;const n=hx(),s=`${n.generateId("item")}-${Do()}`,r=Kt({id:s},e),[o,a]=Nt(r,["ref","item","aria-label","aria-labelledby","aria-describedby","onPointerMove","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[i,c]=R(),[l,d]=R(),u=()=>n.listState().selectionManager(),f=()=>u().focusedKey()===o.item.key,g=rI({key:()=>o.item.key,selectionManager:u,shouldSelectOnPressUp:n.shouldSelectOnPressUp,allowsDifferentPressOrigin:()=>n.shouldSelectOnPressUp()&&n.shouldFocusOnHover(),shouldUseVirtualFocus:n.shouldUseVirtualFocus,disabled:()=>o.item.disabled},()=>t),m=()=>{if(u().selectionMode()!=="none")return g.isSelected()},w=Te(()=>!(pl()&&u2())),S=()=>w()?o["aria-label"]:void 0,b=()=>w()?i():void 0,v=()=>w()?l():void 0,k=()=>{var j;if(!n.isVirtualized())return;const I=(j=n.listState().collection().getItem(o.item.key))==null?void 0:j.index;return I!=null?I+1:void 0},C=()=>{if(n.isVirtualized())return lI(n.listState().collection())},_=I=>{on(I,o.onPointerMove),I.pointerType==="mouse"&&!g.isDisabled()&&n.shouldFocusOnHover()&&(On(I.currentTarget),u().setFocused(!0),u().setFocusedKey(o.item.key))},T=Te(()=>({"data-disabled":g.isDisabled()?"":void 0,"data-selected":g.isSelected()?"":void 0,"data-highlighted":f()?"":void 0})),P={isSelected:g.isSelected,dataset:T,generateId:ja(()=>a.id),registerLabelId:bs(c),registerDescriptionId:bs(d)};return y(mx.Provider,{value:P,get children(){return y(en,_e({as:"li",ref(I){var j=Kn(ne=>t=ne,o.ref);typeof j=="function"&&j(I)},role:"option",get tabIndex(){return g.tabIndex()},get"aria-disabled"(){return g.isDisabled()},get"aria-selected"(){return m()},get"aria-label"(){return S()},get"aria-labelledby"(){return b()},get"aria-describedby"(){return v()},get"aria-posinset"(){return k()},get"aria-setsize"(){return C()},get"data-key"(){return g.dataKey()},get onPointerDown(){return vs([o.onPointerDown,g.onPointerDown])},get onPointerUp(){return vs([o.onPointerUp,g.onPointerUp])},get onClick(){return vs([o.onClick,g.onClick])},get onKeyDown(){return vs([o.onKeyDown,g.onKeyDown])},get onMouseDown(){return vs([o.onMouseDown,g.onMouseDown])},get onFocus(){return vs([o.onFocus,g.onFocus])},onPointerMove:_},T,a))}})}function lf(e){const t=Wp(),n=Kt({id:t.generateId("description")},e);return Ze(()=>dt(t.registerDescriptionId(n.id))),y(en,_e({as:"div"},()=>t.dataset(),n))}function df(e){const t=Wp(),n=Kt({id:t.generateId("indicator")},e),[s,r]=Nt(n,["forceMount"]);return y(ee,{get when(){return s.forceMount||t.isSelected()},get children(){return y(en,_e({as:"div","aria-hidden":"true"},()=>t.dataset(),r))}})}function uf(e){const t=Wp(),n=Kt({id:t.generateId("label")},e);return Ze(()=>dt(t.registerLabelId(n.id))),y(en,_e({as:"div"},()=>t.dataset(),n))}function Hp(e){let t;const n=`listbox-${Do()}`,s=Kt({id:n,selectionMode:"single",virtualized:!1},e),[r,o]=Nt(s,["ref","children","renderItem","renderSection","value","defaultValue","onChange","options","optionValue","optionTextValue","optionDisabled","optionGroupChildren","state","keyboardDelegate","autoFocus","selectionMode","shouldFocusWrap","shouldUseVirtualFocus","shouldSelectOnPressUp","shouldFocusOnHover","allowDuplicateSelectionEvents","disallowEmptySelection","selectionBehavior","selectOnFocus","disallowTypeAhead","allowsTabNavigation","virtualized","scrollToItem","scrollRef","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]),a=Te(()=>r.state?r.state:lx({selectedKeys:()=>r.value,defaultSelectedKeys:()=>r.defaultValue,onSelectionChange:r.onChange,allowDuplicateSelectionEvents:()=>he(r.allowDuplicateSelectionEvents),disallowEmptySelection:()=>he(r.disallowEmptySelection),selectionBehavior:()=>he(r.selectionBehavior),selectionMode:()=>he(r.selectionMode),dataSource:()=>r.options??[],getKey:()=>r.optionValue,getTextValue:()=>r.optionTextValue,getDisabled:()=>r.optionDisabled,getSectionChildren:()=>r.optionGroupChildren})),i=dI({selectionManager:()=>a().selectionManager(),collection:()=>a().collection(),autoFocus:()=>he(r.autoFocus),shouldFocusWrap:()=>he(r.shouldFocusWrap),keyboardDelegate:()=>r.keyboardDelegate,disallowEmptySelection:()=>he(r.disallowEmptySelection),selectOnFocus:()=>he(r.selectOnFocus),disallowTypeAhead:()=>he(r.disallowTypeAhead),shouldUseVirtualFocus:()=>he(r.shouldUseVirtualFocus),allowsTabNavigation:()=>he(r.allowsTabNavigation),isVirtualized:()=>r.virtualized,scrollToKey:()=>r.scrollToItem},()=>t,()=>{var l;return(l=r.scrollRef)==null?void 0:l.call(r)}),c={listState:a,generateId:ja(()=>o.id),shouldUseVirtualFocus:()=>s.shouldUseVirtualFocus,shouldSelectOnPressUp:()=>s.shouldSelectOnPressUp,shouldFocusOnHover:()=>s.shouldFocusOnHover,isVirtualized:()=>r.virtualized};return y(gx.Provider,{value:c,get children(){return y(en,_e({as:"ul",ref(l){var d=Kn(u=>t=u,r.ref);typeof d=="function"&&d(l)},role:"listbox",get tabIndex(){return i.tabIndex()},get"aria-multiselectable"(){return a().selectionManager().selectionMode()==="multiple"?!0:void 0},get onKeyDown(){return vs([r.onKeyDown,i.onKeyDown])},get onMouseDown(){return vs([r.onMouseDown,i.onMouseDown])},get onFocusIn(){return vs([r.onFocusIn,i.onFocusIn])},get onFocusOut(){return vs([r.onFocusOut,i.onFocusOut])}},o,{get children(){return y(ee,{get when(){return!r.virtualized},get fallback(){var l;return(l=r.children)==null?void 0:l.call(r,a().collection)},get children(){return y(s2,{get each(){return[...a().collection()]},by:"key",children:l=>y(uk,{get children(){return[y(Ki,{get when(){return l().type==="section"},get children(){var d;return(d=r.renderSection)==null?void 0:d.call(r,l())}}),y(Ki,{get when(){return l().type==="item"},get children(){var d;return(d=r.renderItem)==null?void 0:d.call(r,l())}})]}})})}})}}))}})}function ff(e){return y(en,_e({as:"li",role:"presentation"},e))}var fI=Object.assign(Hp,{Item:cf,ItemDescription:lf,ItemIndicator:df,ItemLabel:uf,Section:ff});const gI=["top","right","bottom","left"],po=Math.min,rs=Math.max,Yd=Math.round,sd=Math.floor,ir=e=>({x:e,y:e}),hI={left:"right",right:"left",bottom:"top",top:"bottom"},mI={start:"end",end:"start"};function zh(e,t,n){return rs(e,po(t,n))}function vi(e,t){return typeof e=="function"?e(t):e}function yo(e){return e.split("-")[0]}function qa(e){return e.split("-")[1]}function px(e){return e==="x"?"y":"x"}function Gp(e){return e==="y"?"height":"width"}const pI=new Set(["top","bottom"]);function Mr(e){return pI.has(yo(e))?"y":"x"}function Zp(e){return px(Mr(e))}function yI(e,t,n){n===void 0&&(n=!1);const s=qa(e),r=Zp(e),o=Gp(r);let a=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Jd(a)),[a,Jd(a)]}function vI(e){const t=Jd(e);return[Wh(e),t,Wh(t)]}function Wh(e){return e.replace(/start|end/g,t=>mI[t])}const yb=["left","right"],vb=["right","left"],wI=["top","bottom"],bI=["bottom","top"];function SI(e,t,n){switch(e){case"top":case"bottom":return n?t?vb:yb:t?yb:vb;case"left":case"right":return t?wI:bI;default:return[]}}function kI(e,t,n,s){const r=qa(e);let o=SI(yo(e),n==="start",s);return r&&(o=o.map(a=>a+"-"+r),t&&(o=o.concat(o.map(Wh)))),o}function Jd(e){return e.replace(/left|right|bottom|top/g,t=>hI[t])}function xI(e){return{top:0,right:0,bottom:0,left:0,...e}}function yx(e){return typeof e!="number"?xI(e):{top:e,right:e,bottom:e,left:e}}function Qd(e){const{x:t,y:n,width:s,height:r}=e;return{width:s,height:r,top:n,left:t,right:t+s,bottom:n+r,x:t,y:n}}function wb(e,t,n){let{reference:s,floating:r}=e;const o=Mr(t),a=Zp(t),i=Gp(a),c=yo(t),l=o==="y",d=s.x+s.width/2-r.width/2,u=s.y+s.height/2-r.height/2,f=s[i]/2-r[i]/2;let g;switch(c){case"top":g={x:d,y:s.y-r.height};break;case"bottom":g={x:d,y:s.y+s.height};break;case"right":g={x:s.x+s.width,y:u};break;case"left":g={x:s.x-r.width,y:u};break;default:g={x:s.x,y:s.y}}switch(qa(t)){case"start":g[a]-=f*(n&&l?-1:1);break;case"end":g[a]+=f*(n&&l?-1:1);break}return g}const _I=async(e,t,n)=>{const{placement:s="bottom",strategy:r="absolute",middleware:o=[],platform:a}=n,i=o.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(t));let l=await a.getElementRects({reference:e,floating:t,strategy:r}),{x:d,y:u}=wb(l,s,c),f=s,g={},m=0;for(let w=0;w<i.length;w++){const{name:S,fn:b}=i[w],{x:v,y:k,data:C,reset:_}=await b({x:d,y:u,initialPlacement:s,placement:f,strategy:r,middlewareData:g,rects:l,platform:a,elements:{reference:e,floating:t}});d=v??d,u=k??u,g={...g,[S]:{...g[S],...C}},_&&m<=50&&(m++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(l=_.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:d,y:u}=wb(l,f,c)),w=-1)}return{x:d,y:u,placement:f,strategy:r,middlewareData:g}};async function qc(e,t){var n;t===void 0&&(t={});const{x:s,y:r,platform:o,rects:a,elements:i,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:f=!1,padding:g=0}=vi(t,e),m=yx(g),S=i[f?u==="floating"?"reference":"floating":u],b=Qd(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(S)))==null||n?S:S.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(i.floating)),boundary:l,rootBoundary:d,strategy:c})),v=u==="floating"?{x:s,y:r,width:a.floating.width,height:a.floating.height}:a.reference,k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(i.floating)),C=await(o.isElement==null?void 0:o.isElement(k))?await(o.getScale==null?void 0:o.getScale(k))||{x:1,y:1}:{x:1,y:1},_=Qd(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:v,offsetParent:k,strategy:c}):v);return{top:(b.top-_.top+m.top)/C.y,bottom:(_.bottom-b.bottom+m.bottom)/C.y,left:(b.left-_.left+m.left)/C.x,right:(_.right-b.right+m.right)/C.x}}const $I=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:r,rects:o,platform:a,elements:i,middlewareData:c}=t,{element:l,padding:d=0}=vi(e,t)||{};if(l==null)return{};const u=yx(d),f={x:n,y:s},g=Zp(r),m=Gp(g),w=await a.getDimensions(l),S=g==="y",b=S?"top":"left",v=S?"bottom":"right",k=S?"clientHeight":"clientWidth",C=o.reference[m]+o.reference[g]-f[g]-o.floating[m],_=f[g]-o.reference[g],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l));let P=T?T[k]:0;(!P||!await(a.isElement==null?void 0:a.isElement(T)))&&(P=i.floating[k]||o.floating[m]);const I=C/2-_/2,j=P/2-w[m]/2-1,ne=po(u[b],j),W=po(u[v],j),q=ne,U=P-w[m]-W,G=P/2-w[m]/2+I,le=zh(q,G,U),K=!c.arrow&&qa(r)!=null&&G!==le&&o.reference[m]/2-(G<q?ne:W)-w[m]/2<0,M=K?G<q?G-q:G-U:0;return{[g]:f[g]+M,data:{[g]:le,centerOffset:G-le-M,...K&&{alignmentOffset:M}},reset:K}}}),CI=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:r,middlewareData:o,rects:a,initialPlacement:i,platform:c,elements:l}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:w=!0,...S}=vi(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const b=yo(r),v=Mr(i),k=yo(i)===i,C=await(c.isRTL==null?void 0:c.isRTL(l.floating)),_=f||(k||!w?[Jd(i)]:vI(i)),T=m!=="none";!f&&T&&_.push(...kI(i,w,m,C));const P=[i,..._],I=await qc(t,S),j=[];let ne=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&j.push(I[b]),u){const G=yI(r,a,C);j.push(I[G[0]],I[G[1]])}if(ne=[...ne,{placement:r,overflows:j}],!j.every(G=>G<=0)){var W,q;const G=(((W=o.flip)==null?void 0:W.index)||0)+1,le=P[G];if(le&&(!(u==="alignment"?v!==Mr(le):!1)||ne.every(N=>Mr(N.placement)===v?N.overflows[0]>0:!0)))return{data:{index:G,overflows:ne},reset:{placement:le}};let K=(q=ne.filter(M=>M.overflows[0]<=0).sort((M,N)=>M.overflows[1]-N.overflows[1])[0])==null?void 0:q.placement;if(!K)switch(g){case"bestFit":{var U;const M=(U=ne.filter(N=>{if(T){const oe=Mr(N.placement);return oe===v||oe==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(oe=>oe>0).reduce((oe,ge)=>oe+ge,0)]).sort((N,oe)=>N[1]-oe[1])[0])==null?void 0:U[0];M&&(K=M);break}case"initialPlacement":K=i;break}if(r!==K)return{reset:{placement:K}}}return{}}}};function bb(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Sb(e){return gI.some(t=>e[t]>=0)}const EI=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:s="referenceHidden",...r}=vi(e,t);switch(s){case"referenceHidden":{const o=await qc(t,{...r,elementContext:"reference"}),a=bb(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Sb(a)}}}case"escaped":{const o=await qc(t,{...r,altBoundary:!0}),a=bb(o,n.floating);return{data:{escapedOffsets:a,escaped:Sb(a)}}}default:return{}}}}},TI=new Set(["left","top"]);async function MI(e,t){const{placement:n,platform:s,elements:r}=e,o=await(s.isRTL==null?void 0:s.isRTL(r.floating)),a=yo(n),i=qa(n),c=Mr(n)==="y",l=TI.has(a)?-1:1,d=o&&c?-1:1,u=vi(t,e);let{mainAxis:f,crossAxis:g,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return i&&typeof m=="number"&&(g=i==="end"?m*-1:m),c?{x:g*d,y:f*l}:{x:f*l,y:g*d}}const AI=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:r,y:o,placement:a,middlewareData:i}=t,c=await MI(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(s=i.arrow)!=null&&s.alignmentOffset?{}:{x:r+c.x,y:o+c.y,data:{...c,placement:a}}}}},DI=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:r}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:i={fn:S=>{let{x:b,y:v}=S;return{x:b,y:v}}},...c}=vi(e,t),l={x:n,y:s},d=await qc(t,c),u=Mr(yo(r)),f=px(u);let g=l[f],m=l[u];if(o){const S=f==="y"?"top":"left",b=f==="y"?"bottom":"right",v=g+d[S],k=g-d[b];g=zh(v,g,k)}if(a){const S=u==="y"?"top":"left",b=u==="y"?"bottom":"right",v=m+d[S],k=m-d[b];m=zh(v,m,k)}const w=i.fn({...t,[f]:g,[u]:m});return{...w,data:{x:w.x-n,y:w.y-s,enabled:{[f]:o,[u]:a}}}}}},PI=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:r,rects:o,platform:a,elements:i}=t,{apply:c=()=>{},...l}=vi(e,t),d=await qc(t,l),u=yo(r),f=qa(r),g=Mr(r)==="y",{width:m,height:w}=o.floating;let S,b;u==="top"||u==="bottom"?(S=u,b=f===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(b=u,S=f==="end"?"top":"bottom");const v=w-d.top-d.bottom,k=m-d.left-d.right,C=po(w-d[S],v),_=po(m-d[b],k),T=!t.middlewareData.shift;let P=C,I=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=k),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(P=v),T&&!f){const ne=rs(d.left,0),W=rs(d.right,0),q=rs(d.top,0),U=rs(d.bottom,0);g?I=m-2*(ne!==0||W!==0?ne+W:rs(d.left,d.right)):P=w-2*(q!==0||U!==0?q+U:rs(d.top,d.bottom))}await c({...t,availableWidth:I,availableHeight:P});const j=await a.getDimensions(i.floating);return m!==j.width||w!==j.height?{reset:{rects:!0}}:{}}}};function gf(){return typeof window<"u"}function za(e){return vx(e)?(e.nodeName||"").toLowerCase():"#document"}function as(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yr(e){var t;return(t=(vx(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vx(e){return gf()?e instanceof Node||e instanceof as(e).Node:!1}function Vs(e){return gf()?e instanceof Element||e instanceof as(e).Element:!1}function gr(e){return gf()?e instanceof HTMLElement||e instanceof as(e).HTMLElement:!1}function kb(e){return!gf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof as(e).ShadowRoot}const II=new Set(["inline","contents"]);function wl(e){const{overflow:t,overflowX:n,overflowY:s,display:r}=js(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!II.has(r)}const RI=new Set(["table","td","th"]);function OI(e){return RI.has(za(e))}const LI=[":popover-open",":modal"];function hf(e){return LI.some(t=>{try{return e.matches(t)}catch{return!1}})}const NI=["transform","translate","scale","rotate","perspective"],FI=["transform","translate","scale","rotate","perspective","filter"],BI=["paint","layout","strict","content"];function Yp(e){const t=Jp(),n=Vs(e)?js(e):e;return NI.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||FI.some(s=>(n.willChange||"").includes(s))||BI.some(s=>(n.contain||"").includes(s))}function UI(e){let t=vo(e);for(;gr(t)&&!da(t);){if(Yp(t))return t;if(hf(t))return null;t=vo(t)}return null}function Jp(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const KI=new Set(["html","body","#document"]);function da(e){return KI.has(za(e))}function js(e){return as(e).getComputedStyle(e)}function mf(e){return Vs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vo(e){if(za(e)==="html")return e;const t=e.assignedSlot||e.parentNode||kb(e)&&e.host||yr(e);return kb(t)?t.host:t}function wx(e){const t=vo(e);return da(t)?e.ownerDocument?e.ownerDocument.body:e.body:gr(t)&&wl(t)?t:wx(t)}function zc(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=wx(e),o=r===((s=e.ownerDocument)==null?void 0:s.body),a=as(r);if(o){const i=Hh(a);return t.concat(a,a.visualViewport||[],wl(r)?r:[],i&&n?zc(i):[])}return t.concat(r,zc(r,[],n))}function Hh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bx(e){const t=js(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const r=gr(e),o=r?e.offsetWidth:n,a=r?e.offsetHeight:s,i=Yd(n)!==o||Yd(s)!==a;return i&&(n=o,s=a),{width:n,height:s,$:i}}function Qp(e){return Vs(e)?e:e.contextElement}function Ji(e){const t=Qp(e);if(!gr(t))return ir(1);const n=t.getBoundingClientRect(),{width:s,height:r,$:o}=bx(t);let a=(o?Yd(n.width):n.width)/s,i=(o?Yd(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const VI=ir(0);function Sx(e){const t=as(e);return!Jp()||!t.visualViewport?VI:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jI(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==as(e)?!1:t}function ni(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=Qp(e);let a=ir(1);t&&(s?Vs(s)&&(a=Ji(s)):a=Ji(e));const i=jI(o,n,s)?Sx(o):ir(0);let c=(r.left+i.x)/a.x,l=(r.top+i.y)/a.y,d=r.width/a.x,u=r.height/a.y;if(o){const f=as(o),g=s&&Vs(s)?as(s):s;let m=f,w=Hh(m);for(;w&&s&&g!==m;){const S=Ji(w),b=w.getBoundingClientRect(),v=js(w),k=b.left+(w.clientLeft+parseFloat(v.paddingLeft))*S.x,C=b.top+(w.clientTop+parseFloat(v.paddingTop))*S.y;c*=S.x,l*=S.y,d*=S.x,u*=S.y,c+=k,l+=C,m=as(w),w=Hh(m)}}return Qd({width:d,height:u,x:c,y:l})}function pf(e,t){const n=mf(e).scrollLeft;return t?t.left+n:ni(yr(e)).left+n}function kx(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-pf(e,n),r=n.top+t.scrollTop;return{x:s,y:r}}function qI(e){let{elements:t,rect:n,offsetParent:s,strategy:r}=e;const o=r==="fixed",a=yr(s),i=t?hf(t.floating):!1;if(s===a||i&&o)return n;let c={scrollLeft:0,scrollTop:0},l=ir(1);const d=ir(0),u=gr(s);if((u||!u&&!o)&&((za(s)!=="body"||wl(a))&&(c=mf(s)),gr(s))){const g=ni(s);l=Ji(s),d.x=g.x+s.clientLeft,d.y=g.y+s.clientTop}const f=a&&!u&&!o?kx(a,c):ir(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+d.x+f.x,y:n.y*l.y-c.scrollTop*l.y+d.y+f.y}}function zI(e){return Array.from(e.getClientRects())}function WI(e){const t=yr(e),n=mf(e),s=e.ownerDocument.body,r=rs(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),o=rs(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+pf(e);const i=-n.scrollTop;return js(s).direction==="rtl"&&(a+=rs(t.clientWidth,s.clientWidth)-r),{width:r,height:o,x:a,y:i}}const xb=25;function HI(e,t){const n=as(e),s=yr(e),r=n.visualViewport;let o=s.clientWidth,a=s.clientHeight,i=0,c=0;if(r){o=r.width,a=r.height;const d=Jp();(!d||d&&t==="fixed")&&(i=r.offsetLeft,c=r.offsetTop)}const l=pf(s);if(l<=0){const d=s.ownerDocument,u=d.body,f=getComputedStyle(u),g=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(s.clientWidth-u.clientWidth-g);m<=xb&&(o-=m)}else l<=xb&&(o+=l);return{width:o,height:a,x:i,y:c}}const GI=new Set(["absolute","fixed"]);function ZI(e,t){const n=ni(e,!0,t==="fixed"),s=n.top+e.clientTop,r=n.left+e.clientLeft,o=gr(e)?Ji(e):ir(1),a=e.clientWidth*o.x,i=e.clientHeight*o.y,c=r*o.x,l=s*o.y;return{width:a,height:i,x:c,y:l}}function _b(e,t,n){let s;if(t==="viewport")s=HI(e,n);else if(t==="document")s=WI(yr(e));else if(Vs(t))s=ZI(t,n);else{const r=Sx(e);s={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Qd(s)}function xx(e,t){const n=vo(e);return n===t||!Vs(n)||da(n)?!1:js(n).position==="fixed"||xx(n,t)}function YI(e,t){const n=t.get(e);if(n)return n;let s=zc(e,[],!1).filter(i=>Vs(i)&&za(i)!=="body"),r=null;const o=js(e).position==="fixed";let a=o?vo(e):e;for(;Vs(a)&&!da(a);){const i=js(a),c=Yp(a);!c&&i.position==="fixed"&&(r=null),(o?!c&&!r:!c&&i.position==="static"&&!!r&&GI.has(r.position)||wl(a)&&!c&&xx(e,a))?s=s.filter(d=>d!==a):r=i,a=vo(a)}return t.set(e,s),s}function JI(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const a=[...n==="clippingAncestors"?hf(t)?[]:YI(t,this._c):[].concat(n),s],i=a[0],c=a.reduce((l,d)=>{const u=_b(t,d,r);return l.top=rs(u.top,l.top),l.right=po(u.right,l.right),l.bottom=po(u.bottom,l.bottom),l.left=rs(u.left,l.left),l},_b(t,i,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function QI(e){const{width:t,height:n}=bx(e);return{width:t,height:n}}function XI(e,t,n){const s=gr(t),r=yr(t),o=n==="fixed",a=ni(e,!0,o,t);let i={scrollLeft:0,scrollTop:0};const c=ir(0);function l(){c.x=pf(r)}if(s||!s&&!o)if((za(t)!=="body"||wl(r))&&(i=mf(t)),s){const g=ni(t,!0,o,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else r&&l();o&&!s&&r&&l();const d=r&&!s&&!o?kx(r,i):ir(0),u=a.left+i.scrollLeft-c.x-d.x,f=a.top+i.scrollTop-c.y-d.y;return{x:u,y:f,width:a.width,height:a.height}}function Lg(e){return js(e).position==="static"}function $b(e,t){if(!gr(e)||js(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yr(e)===n&&(n=n.ownerDocument.body),n}function _x(e,t){const n=as(e);if(hf(e))return n;if(!gr(e)){let r=vo(e);for(;r&&!da(r);){if(Vs(r)&&!Lg(r))return r;r=vo(r)}return n}let s=$b(e,t);for(;s&&OI(s)&&Lg(s);)s=$b(s,t);return s&&da(s)&&Lg(s)&&!Yp(s)?n:s||UI(e)||n}const e4=async function(e){const t=this.getOffsetParent||_x,n=this.getDimensions,s=await n(e.floating);return{reference:XI(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function t4(e){return js(e).direction==="rtl"}const $x={convertOffsetParentRelativeRectToViewportRelativeRect:qI,getDocumentElement:yr,getClippingRect:JI,getOffsetParent:_x,getElementRects:e4,getClientRects:zI,getDimensions:QI,getScale:Ji,isElement:Vs,isRTL:t4};function Cx(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function n4(e,t){let n=null,s;const r=yr(e);function o(){var i;clearTimeout(s),(i=n)==null||i.disconnect(),n=null}function a(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),o();const l=e.getBoundingClientRect(),{left:d,top:u,width:f,height:g}=l;if(i||t(),!f||!g)return;const m=sd(u),w=sd(r.clientWidth-(d+f)),S=sd(r.clientHeight-(u+g)),b=sd(d),k={rootMargin:-m+"px "+-w+"px "+-S+"px "+-b+"px",threshold:rs(0,po(1,c))||1};let C=!0;function _(T){const P=T[0].intersectionRatio;if(P!==c){if(!C)return a();P?a(!1,P):s=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!Cx(l,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(_,{...k,root:r.ownerDocument})}catch{n=new IntersectionObserver(_,k)}n.observe(e)}return a(!0),o}function s4(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=s,l=Qp(e),d=r||o?[...l?zc(l):[],...zc(t)]:[];d.forEach(b=>{r&&b.addEventListener("scroll",n,{passive:!0}),o&&b.addEventListener("resize",n)});const u=l&&i?n4(l,n):null;let f=-1,g=null;a&&(g=new ResizeObserver(b=>{let[v]=b;v&&v.target===l&&g&&(g.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var k;(k=g)==null||k.observe(t)})),n()}),l&&!c&&g.observe(l),g.observe(t));let m,w=c?ni(e):null;c&&S();function S(){const b=ni(e);w&&!Cx(w,b)&&n(),w=b,m=requestAnimationFrame(S)}return n(),()=>{var b;d.forEach(v=>{r&&v.removeEventListener("scroll",n),o&&v.removeEventListener("resize",n)}),u==null||u(),(b=g)==null||b.disconnect(),g=null,c&&cancelAnimationFrame(m)}}const r4=AI,o4=DI,i4=CI,a4=PI,c4=EI,l4=$I,d4=(e,t,n)=>{const s=new Map,r={platform:$x,...n},o={...r.platform,_c:s};return _I(e,t,{...r,platform:o})};var u4=O('<svg display=block viewBox="0 0 30 30"style=transform:scale(1.02)><g><path fill=none d=M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z></path><path stroke=none d=M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z>'),Xp=qr();function ey(){const e=zr(Xp);if(e===void 0)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var Gh=30,Cb=Gh/2,f4={top:180,right:-90,bottom:0,left:90};function ty(e){const t=ey(),n=Kt({size:Gh},e),[s,r]=Nt(n,["ref","style","size"]),o=()=>t.currentPlacement().split("-")[0],a=g4(t.contentRef),i=()=>{var f;return((f=a())==null?void 0:f.getPropertyValue("background-color"))||"none"},c=()=>{var f;return((f=a())==null?void 0:f.getPropertyValue(`border-${o()}-color`))||"none"},l=()=>{var f;return((f=a())==null?void 0:f.getPropertyValue(`border-${o()}-width`))||"0px"},d=()=>Number.parseInt(l())*2*(Gh/s.size),u=()=>`rotate(${f4[o()]} ${Cb} ${Cb}) translate(0 2)`;return y(en,_e({as:"div",ref(f){var g=Kn(t.setArrowRef,s.ref);typeof g=="function"&&g(f)},"aria-hidden":"true",get style(){return ml({position:"absolute","font-size":`${s.size}px`,width:"1em",height:"1em","pointer-events":"none",fill:i(),stroke:c(),"stroke-width":d()},s.style)}},r,{get children(){var f=u4(),g=f.firstChild,m=g.firstChild;return m.nextSibling,de(()=>me(g,"transform",u())),f}}))}function g4(e){const[t,n]=R();return Ze(()=>{const s=e();s&&n(i2(s).getComputedStyle(s))}),t}function h4(e){const t=ey(),[n,s]=Nt(e,["ref","style"]);return y(en,_e({as:"div",ref(r){var o=Kn(t.setPositionerRef,n.ref);typeof o=="function"&&o(r)},"data-popper-positioner":"",get style(){return ml({position:"absolute",top:0,left:0,"min-width":"max-content"},n.style)}},s))}function Eb(e){const{x:t=0,y:n=0,width:s=0,height:r=0}=e??{};if(typeof DOMRect=="function")return new DOMRect(t,n,s,r);const o={x:t,y:n,width:s,height:r,top:n,right:t+s,bottom:n+r,left:t};return{...o,toJSON:()=>o}}function m4(e,t){return{contextElement:e,getBoundingClientRect:()=>{const s=t(e);return s?Eb(s):e?e.getBoundingClientRect():Eb()}}}function p4(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var y4={top:"bottom",right:"left",bottom:"top",left:"right"};function v4(e,t){const[n,s]=e.split("-"),r=y4[n];return s?n==="left"||n==="right"?`${r} ${s==="start"?"top":"bottom"}`:s==="start"?`${r} ${t==="rtl"?"right":"left"}`:`${r} ${t==="rtl"?"left":"right"}`:`${r} center`}function w4(e){const t=Kt({getAnchorRect:f=>f==null?void 0:f.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},e),[n,s]=R(),[r,o]=R(),[a,i]=R(t.placement),c=()=>{var f;return m4((f=t.anchorRef)==null?void 0:f.call(t),t.getAnchorRect)},{direction:l}=Vp();async function d(){var T,P;const f=c(),g=n(),m=r();if(!f||!g)return;const w=((m==null?void 0:m.clientHeight)||0)/2,S=typeof t.gutter=="number"?t.gutter+w:t.gutter??w;g.style.setProperty("--kb-popper-content-overflow-padding",`${t.overflowPadding}px`),f.getBoundingClientRect();const b=[r4(({placement:I})=>{const j=!!I.split("-")[1];return{mainAxis:S,crossAxis:j?void 0:t.shift,alignmentAxis:t.shift}})];if(t.flip!==!1){const I=typeof t.flip=="string"?t.flip.split(" "):void 0;if(I!==void 0&&!I.every(p4))throw new Error("`flip` expects a spaced-delimited list of placements");b.push(i4({padding:t.overflowPadding,fallbackPlacements:I}))}(t.slide||t.overlap)&&b.push(o4({mainAxis:t.slide,crossAxis:t.overlap,padding:t.overflowPadding})),b.push(a4({padding:t.overflowPadding,apply({availableWidth:I,availableHeight:j,rects:ne}){const W=Math.round(ne.reference.width);I=Math.floor(I),j=Math.floor(j),g.style.setProperty("--kb-popper-anchor-width",`${W}px`),g.style.setProperty("--kb-popper-content-available-width",`${I}px`),g.style.setProperty("--kb-popper-content-available-height",`${j}px`),t.sameWidth&&(g.style.width=`${W}px`),t.fitViewport&&(g.style.maxWidth=`${I}px`,g.style.maxHeight=`${j}px`)}})),t.hideWhenDetached&&b.push(c4({padding:t.detachedPadding})),m&&b.push(l4({element:m,padding:t.arrowPadding}));const v=await d4(f,g,{placement:t.placement,strategy:"absolute",middleware:b,platform:{...$x,isRTL:()=>l()==="rtl"}});if(i(v.placement),(T=t.onCurrentPlacementChange)==null||T.call(t,v.placement),!g)return;g.style.setProperty("--kb-popper-content-transform-origin",v4(v.placement,l()));const k=Math.round(v.x),C=Math.round(v.y);let _;if(t.hideWhenDetached&&(_=(P=v.middlewareData.hide)!=null&&P.referenceHidden?"hidden":"visible"),Object.assign(g.style,{top:"0",left:"0",transform:`translate3d(${k}px, ${C}px, 0)`,visibility:_}),m&&v.middlewareData.arrow){const{x:I,y:j}=v.middlewareData.arrow,ne=v.placement.split("-")[0];Object.assign(m.style,{left:I!=null?`${I}px`:"",top:j!=null?`${j}px`:"",[ne]:"100%"})}}Ze(()=>{const f=c(),g=n();if(!f||!g)return;const m=s4(f,g,d,{elementResize:typeof ResizeObserver=="function"});dt(m)}),Ze(()=>{var m;const f=n(),g=(m=t.contentRef)==null?void 0:m.call(t);!f||!g||queueMicrotask(()=>{f.style.zIndex=getComputedStyle(g).zIndex})});const u={currentPlacement:a,contentRef:()=>{var f;return(f=t.contentRef)==null?void 0:f.call(t)},setPositionerRef:s,setArrowRef:o};return y(Xp.Provider,{value:u,get children(){return t.children}})}var Ex=Object.assign(w4,{Arrow:ty,Context:Xp,usePopperContext:ey,Positioner:h4}),Tx=["id","aria-label","aria-labelledby","aria-describedby"];function Mx(e){const t=pr(),n=Kt({id:t.generateId("field")},e);return Ze(()=>dt(t.registerField(he(n.id)))),{fieldProps:{id:()=>he(n.id),ariaLabel:()=>he(n["aria-label"]),ariaLabelledBy:()=>t.getAriaLabelledBy(he(n.id),he(n["aria-label"]),he(n["aria-labelledby"])),ariaDescribedBy:()=>t.getAriaDescribedBy(he(n["aria-describedby"]))}}}function Ax(e){let t;const n=pr(),s=Kt({id:n.generateId("label")},e),[r,o]=Nt(s,["ref"]),a=Rk(()=>t,()=>"label");return Ze(()=>dt(n.registerLabel(o.id))),y(en,_e({as:"label",ref(i){var c=Kn(l=>t=l,r.ref);typeof c=="function"&&c(i)},get for(){return Ee(()=>a()==="label")()?n.fieldId():void 0}},()=>n.dataset(),o))}function Dx(e,t){Ze(yi(e,n=>{if(n==null)return;const s=b4(n);s!=null&&(s.addEventListener("reset",t,{passive:!0}),dt(()=>{s.removeEventListener("reset",t)}))}))}function b4(e){return S4(e)?e.form:e.closest("form")}function S4(e){return e.matches("textarea, input, select, button")}function ny(e){const t=pr(),n=Kt({id:t.generateId("error-message")},e),[s,r]=Nt(n,["forceMount"]),o=()=>t.validationState()==="invalid";return Ze(()=>{o()&&dt(t.registerErrorMessage(r.id))}),y(ee,{get when(){return s.forceMount||o()},get children(){return y(en,_e({as:"div"},()=>t.dataset(),r))}})}var k4={};yl(k4,{Arrow:()=>ty,Content:()=>Ix,Description:()=>zp,ErrorMessage:()=>ny,HiddenSelect:()=>Rx,Icon:()=>Ox,Item:()=>cf,ItemDescription:()=>lf,ItemIndicator:()=>df,ItemLabel:()=>uf,Label:()=>Lx,Listbox:()=>Nx,Portal:()=>Fx,Root:()=>Bx,Section:()=>ff,Select:()=>De,Trigger:()=>Ux,Value:()=>Kx,useSelectContext:()=>Wr});var Px=qr();function Wr(){const e=zr(Px);if(e===void 0)throw new Error("[kobalte]: `useSelectContext` must be used within a `Select` component");return e}function Ix(e){let t;const n=Wr(),[s,r]=Nt(e,["ref","style","onCloseAutoFocus","onFocusOutside"]),o=i=>{n.close()},a=i=>{var c;(c=s.onFocusOutside)==null||c.call(s,i),n.isOpen()&&n.isModal()&&i.preventDefault()};return Mk({isDisabled:()=>!(n.isOpen()&&n.isModal()),targets:()=>t?[t]:[]}),Ok({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),Ek({trapFocus:()=>n.isOpen()&&n.isModal(),onMountAutoFocus:i=>{i.preventDefault()},onUnmountAutoFocus:i=>{var c;(c=s.onCloseAutoFocus)==null||c.call(s,i),i.defaultPrevented||(On(n.triggerRef()),i.preventDefault())}},()=>t),y(ee,{get when(){return n.contentPresent()},get children(){return y(Ex.Positioner,{get children(){return y(Dk,_e({ref(i){var c=Kn(l=>{n.setContentRef(l),t=l},s.ref);typeof c=="function"&&c(i)},get disableOutsidePointerEvents(){return Ee(()=>!!n.isModal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get style(){return ml({"--kb-select-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},s.style)},onEscapeKeyDown:o,onFocusOutside:a,get onDismiss(){return n.close}},()=>n.dataset(),r))}})}})}function Rx(e){const t=Wr();return y(cI,_e({get collection(){return t.listState().collection()},get selectionManager(){return t.listState().selectionManager()},get isOpen(){return t.isOpen()},get isMultiple(){return t.isMultiple()},get isVirtualized(){return t.isVirtualized()},focusTrigger:()=>{var n;return(n=t.triggerRef())==null?void 0:n.focus()}},e))}function Ox(e){const t=Wr(),n=Kt({children:"▼"},e);return y(en,_e({as:"span","aria-hidden":"true"},()=>t.dataset(),n))}function Lx(e){const t=Wr(),[n,s]=Nt(e,["onClick"]);return y(Ax,_e({as:"span",onClick:o=>{var a;on(o,n.onClick),t.isDisabled()||(a=t.triggerRef())==null||a.focus()}},s))}function Nx(e){const t=Wr(),n=Kt({id:t.generateId("listbox")},e),[s,r]=Nt(n,["ref","id","onKeyDown"]);return Ze(()=>dt(t.registerListboxId(s.id))),y(Hp,_e({ref(a){var i=Kn(t.setListboxRef,s.ref);typeof i=="function"&&i(a)},get id(){return s.id},get state(){return t.listState()},get virtualized(){return t.isVirtualized()},get autoFocus(){return t.autoFocus()},shouldSelectOnPressUp:!0,shouldFocusOnHover:!0,get shouldFocusWrap(){return t.shouldFocusWrap()},get disallowTypeAhead(){return t.disallowTypeAhead()},get"aria-labelledby"(){return t.listboxAriaLabelledBy()},get renderItem(){return t.renderItem},get renderSection(){return t.renderSection},onKeyDown:a=>{on(a,s.onKeyDown),a.key==="Escape"&&a.preventDefault()}},r))}function Fx(e){const t=Wr();return y(ee,{get when(){return t.contentPresent()},get children(){return y(Mp,e)}})}function x4(e){const t=`select-${Do()}`,n=Kt({id:t,selectionMode:"single",disallowEmptySelection:!1,closeOnSelection:e.selectionMode==="single",allowDuplicateSelectionEvents:!0,gutter:8,sameWidth:!0,modal:!1},e),[s,r,o,a]=Nt(n,["itemComponent","sectionComponent","open","defaultOpen","onOpenChange","value","defaultValue","onChange","placeholder","options","optionValue","optionTextValue","optionDisabled","optionGroupChildren","keyboardDelegate","allowDuplicateSelectionEvents","disallowEmptySelection","closeOnSelection","disallowTypeAhead","shouldFocusWrap","selectionBehavior","selectionMode","virtualized","modal","preventScroll","forceMount"],["getAnchorRect","placement","gutter","shift","flip","slide","overlap","sameWidth","fitViewport","hideWhenDetached","detachedPadding","arrowPadding","overflowPadding"],dx),[i,c]=R(),[l,d]=R(),[u,f]=R(),[g,m]=R(),[w,S]=R(),[b,v]=R(),[k,C]=R(),[_,T]=R(!0),P=h=>{const $=s.optionValue;return $==null?String(h):String(tf($)?$(h):h[$])},I=Te(()=>{const h=s.optionGroupChildren;return h==null?s.options:s.options.flatMap($=>$[h]??$)}),j=Te(()=>I().map(h=>P(h))),ne=h=>[...h].map($=>I().find(D=>P(D)===$)).filter($=>$!=null),W=Ik({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:h=>{var $;return($=s.onOpenChange)==null?void 0:$.call(s,h)}}),q=lx({selectedKeys:()=>s.value!=null?s.value.map(P):s.value,defaultSelectedKeys:()=>s.defaultValue!=null?s.defaultValue.map(P):s.defaultValue,onSelectionChange:h=>{var $;($=s.onChange)==null||$.call(s,ne(h)),s.closeOnSelection&&N()},allowDuplicateSelectionEvents:()=>he(s.allowDuplicateSelectionEvents),disallowEmptySelection:()=>he(s.disallowEmptySelection),selectionBehavior:()=>he(s.selectionBehavior),selectionMode:()=>s.selectionMode,dataSource:()=>s.options??[],getKey:()=>s.optionValue,getTextValue:()=>s.optionTextValue,getDisabled:()=>s.optionDisabled,getSectionChildren:()=>s.optionGroupChildren}),U=Te(()=>ne(q.selectionManager().selectedKeys())),G=h=>{q.selectionManager().toggleSelection(P(h))},{present:le}=Ih({show:()=>s.forceMount||W.isOpen(),element:()=>w()??null}),K=()=>{const h=b();h&&On(h)},M=h=>{if(s.options.length<=0)return;T(h),W.open();let $=q.selectionManager().firstSelectedKey();$==null&&(h==="first"?$=q.collection().getFirstKey():h==="last"&&($=q.collection().getLastKey())),K(),q.selectionManager().setFocused(!0),q.selectionManager().setFocusedKey($)},N=()=>{W.close(),q.selectionManager().setFocused(!1),q.selectionManager().setFocusedKey(void 0)},oe=h=>{W.isOpen()?N():M(h)},{formControlContext:ge}=ux(o);Dx(g,()=>{const h=s.defaultValue?[...s.defaultValue].map(P):new sr;q.selectionManager().setSelectedKeys(h)});const Ie=jp({usage:"search",sensitivity:"base"}),ke=Te(()=>{const h=he(s.keyboardDelegate);return h||new fx(q.collection,void 0,Ie)}),we=h=>{var $;return($=s.itemComponent)==null?void 0:$.call(s,{item:h})},Ae=h=>{var $;return($=s.sectionComponent)==null?void 0:$.call(s,{section:h})};Ze(yi([j],([h])=>{const D=[...q.selectionManager().selectedKeys()].filter(E=>h.includes(E));q.selectionManager().setSelectedKeys(D)},{defer:!0}));const Ge=Te(()=>({"data-expanded":W.isOpen()?"":void 0,"data-closed":W.isOpen()?void 0:""})),H={dataset:Ge,isOpen:W.isOpen,isDisabled:()=>ge.isDisabled()??!1,isMultiple:()=>he(s.selectionMode)==="multiple",isVirtualized:()=>s.virtualized??!1,isModal:()=>s.modal??!1,preventScroll:()=>s.preventScroll??H.isModal(),disallowTypeAhead:()=>s.disallowTypeAhead??!1,shouldFocusWrap:()=>s.shouldFocusWrap??!1,selectedOptions:U,contentPresent:le,autoFocus:_,triggerRef:g,listState:()=>q,keyboardDelegate:ke,triggerId:i,valueId:l,listboxId:u,listboxAriaLabelledBy:k,setListboxAriaLabelledBy:C,setTriggerRef:m,setContentRef:S,setListboxRef:v,open:M,close:N,toggle:oe,placeholder:()=>s.placeholder,renderItem:we,renderSection:Ae,removeOptionFromSelection:G,generateId:ja(()=>he(o.id)),registerTriggerId:bs(c),registerValueId:bs(d),registerListboxId:bs(f)};return y(qp.Provider,{value:ge,get children(){return y(Px.Provider,{value:H,get children(){return y(Ex,_e({anchorRef:g,contentRef:w},r,{get children(){return y(en,_e({as:"div",role:"group",get id(){return he(o.id)}},()=>ge.dataset(),Ge,a))}}))}})}})}function Bx(e){const[t,n]=Nt(e,["value","defaultValue","onChange","multiple"]),s=Te(()=>t.value!=null?t.multiple?t.value:[t.value]:t.value),r=Te(()=>t.defaultValue!=null?t.multiple?t.defaultValue:[t.defaultValue]:t.defaultValue);return y(x4,_e({get value(){return s()},get defaultValue(){return r()},onChange:a=>{var i,c;t.multiple?(i=t.onChange)==null||i.call(t,a??[]):(c=t.onChange)==null||c.call(t,a[0]??null)},get selectionMode(){return t.multiple?"multiple":"single"}},n))}function Ux(e){const t=pr(),n=Wr(),s=Kt({id:n.generateId("trigger")},e),[r,o,a]=Nt(s,["ref","disabled","onPointerDown","onClick","onKeyDown","onFocus","onBlur"],Tx),i=()=>n.listState().selectionManager(),c=()=>n.keyboardDelegate(),l=()=>r.disabled||n.isDisabled(),{fieldProps:d}=Mx(o),{typeSelectHandlers:u}=cx({keyboardDelegate:c,selectionManager:i,onTypeSelect:v=>i().select(v)}),f=()=>[n.listboxAriaLabelledBy(),n.valueId()].filter(Boolean).join(" ")||void 0,g=v=>{on(v,r.onPointerDown),v.currentTarget.dataset.pointerType=v.pointerType,!l()&&v.pointerType!=="touch"&&v.button===0&&(v.preventDefault(),n.toggle(!0))},m=v=>{on(v,r.onClick),!l()&&v.currentTarget.dataset.pointerType==="touch"&&n.toggle(!0)},w=v=>{var k,C,_,T,P,I,j,ne;if(on(v,r.onKeyDown),!l())switch(on(v,u.onKeyDown),v.key){case"Enter":case" ":case"ArrowDown":v.stopPropagation(),v.preventDefault(),n.toggle("first");break;case"ArrowUp":v.stopPropagation(),v.preventDefault(),n.toggle("last");break;case"ArrowLeft":{if(v.preventDefault(),n.isMultiple())return;const W=i().firstSelectedKey(),q=W!=null?(C=(k=c()).getKeyAbove)==null?void 0:C.call(k,W):(T=(_=c()).getFirstKey)==null?void 0:T.call(_);q!=null&&i().select(q);break}case"ArrowRight":{if(v.preventDefault(),n.isMultiple())return;const W=i().firstSelectedKey(),q=W!=null?(I=(P=c()).getKeyBelow)==null?void 0:I.call(P,W):(ne=(j=c()).getFirstKey)==null?void 0:ne.call(j);q!=null&&i().select(q);break}}},S=v=>{on(v,r.onFocus),!i().isFocused()&&i().setFocused(!0)},b=v=>{on(v,r.onBlur),!n.isOpen()&&i().setFocused(!1)};return Ze(()=>dt(n.registerTriggerId(d.id()))),Ze(()=>{n.setListboxAriaLabelledBy([d.ariaLabelledBy(),d.ariaLabel()&&!d.ariaLabelledBy()?d.id():null].filter(Boolean).join(" ")||void 0)}),y(vl,_e({ref(v){var k=Kn(n.setTriggerRef,r.ref);typeof k=="function"&&k(v)},get id(){return d.id()},get disabled(){return l()},"aria-haspopup":"listbox",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return Ee(()=>!!n.isOpen())()?n.listboxId():void 0},get"aria-label"(){return d.ariaLabel()},get"aria-labelledby"(){return f()},get"aria-describedby"(){return d.ariaDescribedBy()},onPointerDown:g,onClick:m,onKeyDown:w,onFocus:S,onBlur:b},()=>n.dataset(),()=>t.dataset(),a))}function Kx(e){const t=pr(),n=Wr(),s=Kt({id:n.generateId("value")},e),[r,o]=Nt(s,["id","children"]),a=()=>n.listState().selectionManager(),i=()=>{const c=a().selectedKeys();return c.size===1&&c.has("")?!0:a().isEmpty()};return Ze(()=>dt(n.registerValueId(r.id))),y(en,_e({as:"span",get id(){return r.id},get"data-placeholder-shown"(){return i()?"":void 0}},()=>t.dataset(),o,{get children(){return y(ee,{get when(){return!i()},get fallback(){return n.placeholder()},get children(){return y(_4,{state:{selectedOption:()=>n.selectedOptions()[0],selectedOptions:()=>n.selectedOptions(),remove:c=>n.removeOptionFromSelection(c),clear:()=>a().clearSelection()},get children(){return r.children}})}})}}))}function _4(e){const t=gk(()=>{const n=e.children;return tf(n)?n(e.state):n});return Ee(t)}var De=Object.assign(Bx,{Arrow:ty,Content:Ix,Description:zp,ErrorMessage:ny,HiddenSelect:Rx,Icon:Ox,Item:cf,ItemDescription:lf,ItemIndicator:df,ItemLabel:uf,Label:Lx,Listbox:Nx,Portal:Fx,Section:ff,Trigger:Ux,Value:Kx});const Tb="@media ";function $4(e){let t=typeof e=="function"?e(eM()):e;t.startsWith(Tb)&&(t=t.slice(Tb.length));const n=window.matchMedia(t),[s,r]=R(n.matches),o=a=>r(a.matches);return n.addEventListener?n.addEventListener("change",o):n.addListener(o),dt(()=>n.removeEventListener("change",o)),s}const Zh=new Set(["general","chat","notifications","speech","remote","opencode","providers","sidecars","config-files","advanced","info"]);function Xd(e){if(typeof e=="string")return Zh.has(e)?{section:e}:null;if(!e||typeof e!="object")return null;const t=e;if(!Zh.has(t.section))return null;const n=t.location;return{section:t.section,...Number.isSafeInteger(t.scrollTop)&&t.scrollTop>=0&&t.scrollTop<=1e7?{scrollTop:t.scrollTop}:{},...typeof t.instanceId=="string"&&t.instanceId?{instanceId:t.instanceId}:{},...n&&typeof n=="object"&&typeof n.directory=="string"?{location:n}:{}}}function C4(e){const t=new URL(e).searchParams,n=t.get("preferences");if(!n||!Zh.has(n))return null;const s=t.get("preferencesInstanceId")||void 0,r=t.get("preferencesDirectory"),o=t.get("preferencesWorkspaceId")||void 0;return{section:n,...s?{instanceId:s}:{},...r!==null?{location:{directory:r,...o?{workspaceID:o}:{}}}:{}}}async function E4(e,t=!1,n=!1){var s;if($n.host==="electron"){const r=(s=window.electronAPI)==null?void 0:s.openPreferences;if(!r)throw new Error("Native Preferences is unavailable");await r(e.section,{instanceId:e.instanceId,location:e.location},t,n);return}if($n.host==="tauri"){await Ms("open_preferences_window",{request:e,toggle:t,resume:n});return}throw new Error("Native Preferences is unavailable")}async function T4(){var e,t;Bn()?await((t=(e=window.electronAPI)==null?void 0:e.preferencesReady)==null?void 0:t.call(e)):Dn()&&await Ms("preferences_window_ready")}async function M4(e,t){var n,s;Bn()?await((s=(n=window.electronAPI)==null?void 0:n.acceptPreferencesRequest)==null?void 0:s.call(n,e)):Dn()&&await Ms("preferences_accept_request",{request:e,generation:t})}async function A4(e){return Bn()?(window.__CODENOMAD_FLUSH_CLIENT_STATE_BEFORE_NATIVE_SHUTDOWN__=e,()=>{window.__CODENOMAD_FLUSH_CLIENT_STATE_BEFORE_NATIVE_SHUTDOWN__===e&&delete window.__CODENOMAD_FLUSH_CLIENT_STATE_BEFORE_NATIVE_SHUTDOWN__}):Dn()?Xu("client-state:flush-requested",t=>{e(t.payload.generation).catch(n=>Ut("actions").warn("Preferences shutdown flush failed",n))}):()=>{}}async function D4(){var t;const e=C4(window.location.href);if(Bn()){const n=window.electronAPI,s=n!=null&&n.getPreferencesRequest?await n.getPreferencesRequest():await((t=n==null?void 0:n.getPreferencesSection)==null?void 0:t.call(n));return Xd(s)??e??{section:"general"}}if(Dn()){const n=await Ms("preferences_get_request");return Xd(n)??e??{section:"general"}}return e??{section:"general"}}async function P4(e){var t,n;return Bn()?((n=(t=window.electronAPI)==null?void 0:t.onPreferencesSection)==null?void 0:n.call(t,s=>{const r=Xd(s);r&&e(r)}))??(()=>{}):Dn()?await Xu("preferences:section",s=>{const r=Xd(s.payload);r&&e(r)}):()=>{}}async function I4(e){var t,n;return Bn()?((n=(t=window.electronAPI)==null?void 0:t.onPreferencesCloseRequested)==null?void 0:n.call(t,e))??(()=>{}):Dn()?await Xu("preferences:close-requested",e):()=>{}}async function R4(e){var n,s;const t=r=>{r&&typeof r=="object"&&Number.isSafeInteger(r.id)&&e(r.id)};return Bn()?((s=(n=window.electronAPI)==null?void 0:n.onPreferencesTransitionRequested)==null?void 0:s.call(n,t))??(()=>{}):Dn()?await Xu("preferences:transition-requested",r=>t(r.payload)):()=>{}}async function O4(e,t){var n,s;Bn()?await((s=(n=window.electronAPI)==null?void 0:n.resolvePreferencesTransition)==null?void 0:s.call(n,e,t)):Dn()&&await Ms("preferences_resolve_transition",{id:e,approved:t})}const Yh=new Set;let Mb=Promise.resolve();function Vx(e){return Yh.add(e),()=>Yh.delete(e)}function Qi(){const e=Mb.then(async()=>{for(const t of Array.from(Yh))if(!await t())return!1;return!0});return Mb=e.then(()=>{},()=>{}),e}const[jx,Jh]=R(!1),[Ii,sy]=R("general"),L4=Ut("actions");async function qx(e,t=!1){if(t&&jx()){await Qi()&&Jh(!1);return}if(e&&sy(e),($n.host==="electron"||$n.host==="tauri")&&$n.windowContext==="local")try{const{activeInstanceId:n}=await ls(async()=>{const{activeInstanceId:o}=await Promise.resolve().then(()=>T9);return{activeInstanceId:o}},void 0),s=n()??void 0,r={section:e??"general",instanceId:s};if(s){const{getActiveCatalogLocation:o}=await ls(async()=>{const{getActiveCatalogLocation:a}=await Promise.resolve().then(()=>Z6);return{getActiveCatalogLocation:a}},void 0);r.location=o(s)}await E4(r,t,e===void 0);return}catch(n){L4.warn("Native Preferences failed; opening settings in this window",n)}Jh(!0)}const hH=e=>qx(e,!0);function N4(){Jh(!1)}function ps(e){return $e(e).split(",").map(t=>t.trim()).filter(Boolean)}function Jr(e,t,n){e()!==n&&t()}function Qh(e){const t=e.toolCallExpansionDefaults;return t.tools.other?t.tools.other:t.preset==="minimal"||t.preset==="balanced"?"collapsed":t.preset==="detailed"||t.preset==="everything"?"expanded":e.toolOutputExpansion??"expanded"}function ry(e){const t=e.preferences,n=e.updatePreferences;return[{kind:"toggle",id:"behavior.keyboardShortcutHints",titleKey:"settings.behavior.keyboardHints.title",subtitleKey:"settings.behavior.keyboardHints.subtitle",get:s=>!!(s.showKeyboardShortcutHints??!1),set:s=>{if(n){n({showKeyboardShortcutHints:s});return}Jr(()=>!!(t().showKeyboardShortcutHints??!1),e.toggleKeyboardShortcutHints,s)},disabled:()=>Mh()},{kind:"toggle",id:"behavior.thinkingBlocks",titleKey:"settings.behavior.thinking.title",subtitleKey:"settings.behavior.thinking.subtitle",get:s=>!!s.showThinkingBlocks,set:s=>{if(n){n({showThinkingBlocks:s});return}Jr(()=>!!t().showThinkingBlocks,e.toggleShowThinkingBlocks,s)}},{kind:"enum",id:"behavior.thinkingBlocksDefault",titleKey:"settings.behavior.thinkingDefault.title",subtitleKey:"settings.behavior.thinkingDefault.subtitle",get:s=>s.thinkingBlocksExpansion??"expanded",set:s=>{if(n){n({thinkingBlocksExpansion:s});return}e.setThinkingBlocksExpansion(s)},options:[{value:"expanded",labelKey:"commands.common.expanded"},{value:"collapsed",labelKey:"commands.common.collapsed"}]},{kind:"toggle",id:"behavior.messageTimeline",titleKey:"settings.behavior.messageTimeline.title",subtitleKey:"settings.behavior.messageTimeline.subtitle",get:s=>!!(s.showMessageTimeline??!0),set:s=>{if(n){n({showMessageTimeline:s});return}Jr(()=>!!(t().showMessageTimeline??!0),e.toggleShowMessageTimeline,s)}},{kind:"toggle",id:"behavior.timelineToolCalls",titleKey:"settings.behavior.timelineTools.title",subtitleKey:"settings.behavior.timelineTools.subtitle",get:s=>!!s.showTimelineTools,set:s=>{if(n){n({showTimelineTools:s});return}Jr(()=>!!t().showTimelineTools,e.toggleShowTimelineTools,s)}},{kind:"enum",id:"behavior.diffViewMode",titleKey:"settings.behavior.diffView.title",subtitleKey:"settings.behavior.diffView.subtitle",get:s=>s.diffViewMode??"split",set:s=>{if(n){n({diffViewMode:s});return}e.setDiffViewMode(s)},options:[{value:"split",labelKey:"settings.behavior.diffView.option.split"},{value:"unified",labelKey:"settings.behavior.diffView.option.unified"}]},{kind:"enum",id:"behavior.toolOutputsDefault",titleKey:"settings.behavior.toolOutputsDefault.title",subtitleKey:"settings.behavior.toolOutputsDefault.subtitle",get:Qh,set:s=>{if(n){const r=s,o=t();n({toolOutputExpansion:r==="hidden"?o.toolOutputExpansion:r,toolCallExpansionDefaults:{...o.toolCallExpansionDefaults,preset:"custom",tools:{...o.toolCallExpansionDefaults.tools,other:r}}});return}e.setToolOutputExpansion(s)},options:[{value:"hidden",labelKey:"commands.common.hidden"},{value:"expanded",labelKey:"commands.common.expanded"},{value:"collapsed",labelKey:"commands.common.collapsed"}]},{kind:"enum",id:"behavior.diagnosticsDefault",titleKey:"settings.behavior.diagnosticsDefault.title",subtitleKey:"settings.behavior.diagnosticsDefault.subtitle",get:s=>s.diagnosticsExpansion??"expanded",set:s=>{if(n){n({diagnosticsExpansion:s});return}e.setDiagnosticsExpansion(s)},options:[{value:"hidden",labelKey:"commands.common.hidden"},{value:"expanded",labelKey:"commands.common.expanded"},{value:"collapsed",labelKey:"commands.common.collapsed"}]},{kind:"enum",id:"behavior.toolInputsVisibility",titleKey:"settings.behavior.toolInputsVisibility.title",subtitleKey:"settings.behavior.toolInputsVisibility.subtitle",get:s=>s.toolInputsVisibility??"hidden",set:s=>{if(n){n({toolInputsVisibility:s});return}e.setToolInputsVisibility(s)},options:[{value:"hidden",labelKey:"commands.common.hidden"},{value:"collapsed",labelKey:"commands.common.collapsed"},{value:"expanded",labelKey:"commands.common.expanded"}]},{kind:"toggle",id:"behavior.usageMetrics",titleKey:"settings.behavior.usageMetrics.title",subtitleKey:"settings.behavior.usageMetrics.subtitle",get:s=>!!(s.showUsageMetrics??!0),set:s=>{if(n){n({showUsageMetrics:s});return}Jr(()=>!!(t().showUsageMetrics??!0),e.toggleUsageMetrics,s)}},{kind:"toggle",id:"behavior.autoCleanupBlankSessions",titleKey:"settings.behavior.autoCleanup.title",subtitleKey:"settings.behavior.autoCleanup.subtitle",get:s=>!!s.autoCleanupBlankSessions,set:s=>{if(n){n({autoCleanupBlankSessions:s});return}Jr(()=>!!t().autoCleanupBlankSessions,e.toggleAutoCleanupBlankSessions,s)}},{kind:"toggle",id:"behavior.keepUnseenSubagentIdleStatus",titleKey:"settings.behavior.keepUnseenSubagentIdle.title",subtitleKey:"settings.behavior.keepUnseenSubagentIdle.subtitle",get:s=>!!s.keepUnseenSubagentIdleStatus,set:s=>{n&&n({keepUnseenSubagentIdleStatus:s})}},{kind:"toggle",id:"behavior.focusExistingWindowOnSecondLaunch",titleKey:"settings.behavior.focusExistingWindowOnSecondLaunch.title",subtitleKey:"settings.behavior.focusExistingWindowOnSecondLaunch.subtitle",get:s=>s.focusExistingWindowOnSecondLaunch,set:async s=>{if(await(n==null?void 0:n({focusExistingWindowOnSecondLaunch:s}))===!1)throw new Error("Failed to persist second-launch behavior")}},{kind:"toggle",id:"behavior.providerUsageCreditBalance",titleKey:"settings.behavior.providerUsageCreditBalance.title",subtitleKey:"settings.behavior.providerUsageCreditBalance.subtitle",get:s=>!!s.showProviderUsageCreditBalance,set:s=>{n==null||n({showProviderUsageCreditBalance:s})}},...$p()&&e.useTauriNativeEventTransport&&e.setUseTauriNativeEventTransport?[{kind:"toggle",id:"behavior.tauriNativeEventTransport",titleKey:"settings.behavior.tauriNativeEventTransport.title",subtitleKey:"settings.behavior.tauriNativeEventTransport.subtitle",get:()=>e.useTauriNativeEventTransport(),set:s=>{e.setUseTauriNativeEventTransport(s)}}]:[],{kind:"toggle",id:"behavior.promptVoiceInput",titleKey:"settings.behavior.promptVoiceInput.title",subtitleKey:"settings.behavior.promptVoiceInput.subtitle",get:s=>!!(s.showPromptVoiceInput??!0),set:s=>{if(n){n({showPromptVoiceInput:s});return}Jr(()=>!!(t().showPromptVoiceInput??!0),e.toggleShowPromptVoiceInput,s)}},{kind:"enum",id:"behavior.followUpBehavior",titleKey:"settings.behavior.followUpBehavior.title",subtitleKey:"settings.behavior.followUpBehavior.subtitle",get:s=>s.followUpBehavior,set:s=>n==null?void 0:n({followUpBehavior:s}),options:[{value:"steer",labelKey:"settings.behavior.followUpBehavior.option.steer"},{value:"queue",labelKey:"settings.behavior.followUpBehavior.option.queue"}]},{kind:"toggle",id:"behavior.promptSubmitOnEnter",titleKey:"settings.behavior.promptSubmit.title",subtitleKey:"settings.behavior.promptSubmit.subtitle",get:s=>!!s.promptSubmitOnEnter,set:s=>{if(n){n({promptSubmitOnEnter:s});return}Jr(()=>!!t().promptSubmitOnEnter,e.togglePromptSubmitOnEnter,s)}}]}function F4(e){return[{id:"prompt-submit-shortcut",label:()=>e.preferences().promptSubmitOnEnter?$e("commands.promptSubmitShortcut.label.swapped"):$e("commands.promptSubmitShortcut.label.default"),description:()=>$e("commands.promptSubmitShortcut.description"),category:"Input & Focus",keywords:()=>ps("commands.promptSubmitShortcut.keywords"),action:e.togglePromptSubmitOnEnter},{id:"thinking",label:()=>$e(e.preferences().showThinkingBlocks?"commands.thinkingBlocks.label.hide":"commands.thinkingBlocks.label.show"),description:()=>$e("commands.thinkingBlocks.description"),category:"System",keywords:()=>["/thinking",...ps("commands.thinkingBlocks.keywords")],action:e.toggleShowThinkingBlocks},{id:"timeline-tools",label:()=>$e(e.preferences().showTimelineTools?"commands.timelineToolCalls.label.hide":"commands.timelineToolCalls.label.show"),description:()=>$e("commands.timelineToolCalls.description"),category:"System",keywords:()=>ps("commands.timelineToolCalls.keywords"),action:e.toggleShowTimelineTools},{id:"keyboard-shortcut-hints",label:()=>$e(e.preferences().showKeyboardShortcutHints?"commands.keyboardShortcutHints.label.hide":"commands.keyboardShortcutHints.label.show"),description:()=>$e(Mh()?"commands.keyboardShortcutHints.description.disabledWeb":"commands.keyboardShortcutHints.description"),category:"System",keywords:()=>ps("commands.keyboardShortcutHints.keywords"),disabled:()=>Mh(),action:e.toggleKeyboardShortcutHints},{id:"thinking-default-visibility",label:()=>{const n=(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?$e("commands.common.expanded"):$e("commands.common.collapsed");return $e("commands.thinkingBlocksDefault.label",{state:n})},description:()=>$e("commands.thinkingBlocksDefault.description"),category:"System",keywords:()=>["/thinking",...ps("commands.thinkingBlocksDefault.keywords")],action:()=>{const n=(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?"collapsed":"expanded";e.setThinkingBlocksExpansion(n)}},{id:"diff-view-split",label:()=>`${(e.preferences().diffViewMode||"split")==="split"?"✓ ":""}${$e("commands.diffViewSplit.label")}`,description:()=>$e("commands.diffViewSplit.description"),category:"System",keywords:()=>ps("commands.diffViewSplit.keywords"),action:()=>e.setDiffViewMode("split")},{id:"diff-view-unified",label:()=>`${(e.preferences().diffViewMode||"split")==="unified"?"✓ ":""}${$e("commands.diffViewUnified.label")}`,description:()=>$e("commands.diffViewUnified.description"),category:"System",keywords:()=>ps("commands.diffViewUnified.keywords"),action:()=>e.setDiffViewMode("unified")},{id:"tool-output-default-visibility",label:()=>{const t=Qh(e.preferences()),n=t==="expanded"?$e("commands.common.expanded"):t==="collapsed"?$e("commands.common.collapsed"):$e("commands.common.hidden");return $e("commands.toolOutputsDefault.label",{state:n})},description:()=>$e("commands.toolOutputsDefault.description"),category:"System",keywords:()=>ps("commands.toolOutputsDefault.keywords"),action:()=>{const t=Qh(e.preferences()),n=t==="hidden"?"collapsed":t==="collapsed"?"expanded":"hidden";e.setToolOutputExpansion(n)}},{id:"diagnostics-default-visibility",label:()=>{const t=e.preferences().diagnosticsExpansion||"expanded",n=t==="expanded"?$e("commands.common.expanded"):t==="collapsed"?$e("commands.common.collapsed"):$e("commands.common.hidden");return $e("commands.diagnosticsDefault.label",{state:n})},description:()=>$e("commands.diagnosticsDefault.description"),category:"System",keywords:()=>ps("commands.diagnosticsDefault.keywords"),action:()=>{const t=e.preferences().diagnosticsExpansion||"expanded",n=t==="hidden"?"collapsed":t==="collapsed"?"expanded":"hidden";e.setDiagnosticsExpansion(n)}},{id:"tool-inputs-visibility",label:()=>{const t=e.preferences().toolInputsVisibility||"hidden",n=t==="expanded"?$e("commands.common.expanded"):t==="collapsed"?$e("commands.common.collapsed"):$e("commands.common.hidden");return $e("commands.toolInputsVisibility.label",{state:n})},description:()=>$e("commands.toolInputsVisibility.description"),category:"System",keywords:()=>ps("commands.toolInputsVisibility.keywords"),action:()=>{const t=e.preferences().toolInputsVisibility||"hidden",n=t==="hidden"?"collapsed":t==="collapsed"?"expanded":"hidden";e.setToolInputsVisibility(n)}},{id:"token-usage-visibility",label:()=>{const n=e.preferences().showUsageMetrics??!0?$e("commands.common.visible"):$e("commands.common.hidden");return $e("commands.tokenUsageDisplay.label",{state:n})},description:()=>$e("commands.tokenUsageDisplay.description"),category:"System",keywords:()=>ps("commands.tokenUsageDisplay.keywords"),action:e.toggleUsageMetrics},{id:"auto-cleanup-blank-sessions",label:()=>{const n=e.preferences().autoCleanupBlankSessions?$e("commands.common.enabled"):$e("commands.common.disabled");return $e("commands.autoCleanupBlankSessions.label",{state:n})},description:()=>$e("commands.autoCleanupBlankSessions.description"),category:"System",keywords:()=>ps("commands.autoCleanupBlankSessions.keywords"),action:e.toggleAutoCleanupBlankSessions}]}function mH(e,t){F4(t).forEach(s=>e(s))}var B4=O('<div class="flex-1 min-w-0">'),U4=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const Ng=[{value:"en",label:"English"},{value:"es",label:"Español"},{value:"fr",label:"Français"},{value:"ru",label:"Русский"},{value:"ja",label:"日本語"},{value:"zh-Hans",label:"简体中文"},{value:"he",label:"עברית"},{value:"de",label:"Deutsch"},{value:"ne",label:"नेपाली"},{value:"tr",label:"Türkçe"}],K4=()=>{const{t:e,locale:t}=Dt(),{updatePreferences:n}=Un(),s=()=>Ng.find(r=>r.value===t())??Ng[0];return y(De,{get value(){return s()},onChange:r=>{!r||r.value===t()||n({locale:r.value})},options:Ng,optionValue:"value",optionTextValue:"label",itemComponent:r=>y(De.Item,{get item(){return r.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return r.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger",get"aria-label"(){return e("folderSelection.language.ariaLabel")},get title(){return e("folderSelection.language.ariaLabel")},get children(){return[y(bD,{class:"w-4 h-4 icon-muted","aria-hidden":"true"}),(()=>{var r=B4();return p(r,y(De.Value,{children:o=>(()=>{var a=U4();return p(a,()=>{var i;return(i=o.selectedOption())==null?void 0:i.label}),a})()})),r})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover min-w-[180px]",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})};var Ab=O('<div class="flex-1 min-w-0">'),Db=O("<div><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>"),Pb=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const oy=e=>{const{t}=Dt(),[n,s]=R(new Map),r=(i,c)=>{s(l=>{const d=new Map(l);return d.set(i,c),d})};Ze(()=>{const i=n();if(i.size===0)return;let c=!1;const l=new Map(i);for(const d of e.settings())l.has(d.id)&&Object.is(d.get(e.preferences()),l.get(d.id))&&(l.delete(d.id),c=!0);c&&s(l)});const o=i=>{const c=n();return c.has(i.id)?c.get(i.id):i.get(e.preferences())},a=i=>{const c=i.setting,l=Te(()=>{var f;return!!((f=c.disabled)!=null&&f.call(c))});if(c.kind==="toggle"){const f=Te(()=>[{value:"true",label:t("settings.common.enabled")},{value:"false",label:t("settings.common.disabled")}]),g=Te(()=>f().find(m=>m.value===String(!!o(c))));return(()=>{var m=Db(),w=m.firstChild,S=w.firstChild,b=S.nextSibling;return p(S,()=>t(c.titleKey)),p(b,()=>t(c.subtitleKey)),p(m,y(De,{get value(){return g()},onChange:async v=>{if(!v)return;const k=v.value==="true";try{await c.set(k),r(c.id,k)}catch{return}},get options(){return f()},optionValue:"value",optionTextValue:"label",get disabled(){return l()},itemComponent:v=>y(De.Item,{get item(){return v.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return v.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger",get"aria-label"(){return t(c.titleKey)},get children(){return[(()=>{var v=Ab();return p(v,y(De.Value,{children:k=>(()=>{var C=Pb();return p(C,()=>{var _;return(_=k.selectedOption())==null?void 0:_.label}),C})()})),v})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),null),de(()=>ws(m,`settings-toggle-row ${l()?"opacity-60":""}`)),m})()}const d=Te(()=>c.options.map(f=>({value:String(f.value),label:t(f.labelKey)}))),u=Te(()=>d().find(f=>f.value===String(o(c)??"")));return(()=>{var f=Db(),g=f.firstChild,m=g.firstChild,w=m.nextSibling;return p(m,()=>t(c.titleKey)),p(w,()=>t(c.subtitleKey)),p(f,y(De,{get value(){return u()},onChange:S=>{S&&(r(c.id,S.value),c.set(S.value))},get options(){return d()},optionValue:"value",optionTextValue:"label",get disabled(){return l()},itemComponent:S=>y(De.Item,{get item(){return S.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return S.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger",get"aria-label"(){return t(c.titleKey)},get children(){return[(()=>{var S=Ab();return p(S,y(De.Value,{children:b=>(()=>{var v=Pb();return p(v,()=>{var k;return(k=b.selectedOption())==null?void 0:k.label}),v})()})),S})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),null),de(()=>ws(f,`settings-toggle-row ${l()?"opacity-60":""}`)),f})()};return y(zt,{get each(){return e.settings()},children:i=>y(a,{setting:i})})};var Fg=O('<button type=button class="selector-button selector-button-secondary">'),V4=O('<button type=button class="selector-button selector-button-primary">'),j4=O("<label class=theme-scheme-name-editor><span></span><input class=selector-input maxlength=80>"),q4=O("<p class=theme-scheme-warning role=alert>"),z4=O('<div class="settings-card theme-scheme-settings"><div class=settings-card-header><h3 class=settings-card-title></h3><span class=settings-scope-badge></span></div><div class=theme-scheme-list><div class=theme-scheme-mode><span></span><div class=theme-scheme-appearance-options role=group></div></div><p class=settings-card-subtitle></p><div class=theme-scheme-workbench><select class="selector-input theme-scheme-picker"></select><div class=theme-scheme-actions>'),W4=O("<button type=button class=theme-scheme-appearance-option>"),H4=O("<option>"),G4=O("<div class=theme-scheme-swatches>"),Z4=O("<label class=theme-scheme-swatch><input type=color>");const Ib=[{key:"surfaceBase",labelKey:"settings.appearance.colorScheme.custom.field.surfaceBase"},{key:"surfaceSecondary",labelKey:"settings.appearance.colorScheme.custom.field.surfaceSecondary"},{key:"surfaceMuted",labelKey:"settings.appearance.colorScheme.custom.field.surfaceMuted"},{key:"borderBase",labelKey:"settings.appearance.colorScheme.custom.field.borderBase"},{key:"textPrimary",labelKey:"settings.appearance.colorScheme.custom.field.textPrimary"},{key:"textMuted",labelKey:"settings.appearance.colorScheme.custom.field.textMuted"},{key:"accentPrimary",labelKey:"settings.appearance.colorScheme.custom.field.accentPrimary"},{key:"statusSuccess",labelKey:"settings.appearance.colorScheme.custom.field.statusSuccess"},{key:"statusWarning",labelKey:"settings.appearance.colorScheme.custom.field.statusWarning"},{key:"statusError",labelKey:"settings.appearance.colorScheme.custom.field.statusError"},{key:"userAccent",labelKey:"settings.appearance.colorScheme.custom.field.userAccent"},{key:"agentAccent",labelKey:"settings.appearance.colorScheme.custom.field.agentAccent"},{key:"compactionAccent",labelKey:"settings.appearance.colorScheme.custom.field.compactionAccent"}],Y4=()=>{const{t:e}=Dt(),t=Un(),n=tM(),[s,r]=R({...Dw}),[o,a]=R("dark"),[i,c]=R("dark"),l=()=>t.getAppearancePalette(i()),d=()=>t.getAppearancePresetId(i()),[u,f]=R(""),[g,m]=R(e("settings.appearance.colorScheme.option.custom")),[w,S]=R(""),[b,v]=R(!1),[k,C]=R(!1),[_,T]=R(!1),[P,I]=R(!1),[j,ne]=R(),[W,q]=R(!1),U=Te(()=>[...nM.filter(E=>E.id!=="system"&&(E.id!=="custom"||!sM(t.customColorSchemePreference().colors)||t.customColorSchemePreference().appearance==="light"||l().id==="custom"&&!d())).map(E=>{const Z=E.id==="custom"&&l().id==="custom"&&!d(),B=E.id==="light"?rM:E.colors??Dw,se=E.id==="system"?void 0:E.id==="custom"?Z?l().colors:t.customColorSchemePreference().colors:t.colorSchemeOverrides()[E.id]??(l().id===E.id?l().colors:void 0);return{key:`builtin:${E.id}`,id:E.id,name:e(E.id==="custom"?"settings.appearance.palette.saved":E.labelKey),description:e(E.descriptionKey),appearance:E.id==="custom"?(Z?l():t.customColorSchemePreference()).appearance==="light"?"light":"dark":E.appearance==="light"?"light":"dark",colors:se??B,originalColors:B}}),...Object.entries(t.colorSchemePresets()).map(([E,Z])=>({key:`preset:${E}`,presetId:E,name:Z.name,description:e("settings.appearance.colorScheme.description.custom"),appearance:Z.appearance,colors:Z.colors,originalColors:Z.colors}))]),G=Te(()=>d()?`preset:${d()}`:`builtin:${l().id}`),le=Te(()=>U().filter(E=>E.id!=="system"&&E.appearance===i())),K=Te(()=>U().find(E=>E.key===u())),M=Te(()=>oM(s())),N=Te(()=>{const E=K();return E!=null&&E.id?E.id==="custom"?Ib.some(Z=>E.colors[Z.key]!==E.originalColors[Z.key]):!!t.colorSchemeOverrides()[E.id]:!1});Ze(()=>{if(!t.isLoaded()||k()||_())return;const E=U().find(Z=>Z.key===G());E&&(f(E.key),m(E.name),a(E.appearance),r({...E.colors}))}),Ze(()=>{const E=n.isDark()?"dark":"light";!k()&&!_()&&c(E)});const oe=async()=>!k()||ca(e("settings.configFiles.confirmDiscard.message"),{variant:"warning",confirmLabel:e("settings.configFiles.confirmDiscard.confirmLabel"),cancelLabel:e("settings.configFiles.confirmDiscard.cancelLabel"),dismissible:!1}),ge=Vx(oe);dt(ge);const Ie=async E=>{if(!(_()||u()===E.key||!await oe())){T(!0),C(!1),v(!1),q(!1),f(E.key),m(E.name),a(E.appearance),r({...E.colors});try{E.presetId?await t.selectColorSchemePreset(E.presetId):await t.setColorSchemePreference(E.id==="custom"?Ui({id:"custom",appearance:E.appearance,colors:E.colors}):Ui(E.id))}catch{q(!0)}finally{T(!1)}}},ke=async(E,Z,B)=>{if(_()||u()!==E.key&&!await oe())return!1;const se=u()===E.key?s():E.colors;return f(E.key),m(E.name),a(E.appearance),r({...se,[Z]:B.toUpperCase()}),C(!0),q(!1),!0},we=async()=>{const E=K();if(E!=null&&E.id){T(!0),q(!1);try{E.id==="custom"?await t.setColorSchemePreference(Ui({id:"custom",appearance:E.appearance,colors:E.originalColors})):await t.resetColorSchemeOverride(E.id),r({...E.originalColors}),a(E.appearance),C(!1)}catch{q(!0)}finally{T(!1)}}},Ae=()=>{const E=Pw(g(),Object.values(t.colorSchemePresets()).map(Z=>Z.name));S(E),v(!0),C(!0),q(!1)},Ge=async()=>{if(!k()||!M())return;const E=K();if(!E)return;const Z=b()?void 0:E.presetId,B=b()?w().trim():Z?E.name:Pw(g(),Object.values(t.colorSchemePresets()).map(se=>se.name));if(B){T(!0),q(!1);try{if(!b()&&E.id){E.id==="custom"?await t.setColorSchemePreference(Ui({id:"custom",appearance:E.appearance,colors:s()})):await t.saveColorSchemeOverride(E.id,E.appearance,s()),C(!1);return}const se=await t.saveColorSchemePreset(B,o(),s(),Z);f(`preset:${se}`),m(B),v(!1),C(!1)}catch{q(!0)}finally{T(!1)}}},H=async E=>{if(!(!E.presetId||!await ca(e("settings.appearance.colorScheme.custom.deleteConfirm",{name:E.name}),{variant:"warning",confirmLabel:e("settings.appearance.colorScheme.custom.delete"),dismissible:!1}))){T(!0),q(!1);try{await t.deleteColorSchemePreset(E.presetId);const B=U().find(se=>se.key===G())??U().find(se=>se.appearance===i());f(B.key),m(B.name),a(B.appearance),c(B.appearance),r({...B.colors}),v(!1),C(!1)}catch{q(!0)}finally{T(!1)}}},h=async E=>{if(!(_()||!await oe())){T(!0),q(!1);try{await t.setThemePreference(E),C(!1),v(!1)}catch{q(!0)}finally{T(!1)}}},$=async E=>{if(ne(E),!P()){I(!0);try{for(;j();){const Z=j();await Ie(Z),j()===Z&&ne(void 0)}}finally{I(!1)}}},D=E=>u()===E.key?s():E.colors;return(()=>{var E=z4(),Z=E.firstChild,B=Z.firstChild,se=B.nextSibling,pe=Z.nextSibling,Se=pe.firstChild,Q=Se.firstChild,be=Q.nextSibling,Ve=Se.nextSibling,He=Ve.nextSibling,re=He.firstChild,F=re.nextSibling;return p(B,()=>e("settings.appearance.colorScheme.title")),p(se,()=>e("settings.scope.device")),p(Q,()=>e("settings.appearance.palette.mode")),p(be,y(zt,{each:["system","dark","light"],children:V=>(()=>{var Me=W4();return Me.$$click=()=>void h(V),p(Me,()=>e(V==="system"?"settings.appearance.palette.auto":`settings.appearance.colorScheme.custom.appearance.${V}`)),de(xe=>{var Re=_(),Be=t.themePreference()===V?"true":"false",et=t.themePreference()===V;return Re!==xe.e&&(Me.disabled=xe.e=Re),Be!==xe.t&&me(Me,"data-selected",xe.t=Be),et!==xe.a&&me(Me,"aria-pressed",xe.a=et),xe},{e:void 0,t:void 0,a:void 0}),Me})()})),p(Ve,()=>e("settings.appearance.palette.independent")),re.addEventListener("change",V=>{const Me=V.currentTarget,xe=U().find(Re=>Re.key===Me.value);xe&&$(xe)}),p(re,y(zt,{get each(){return le()},children:V=>(()=>{var Me=H4();return p(Me,()=>V.name),de(()=>{var xe;return Me.selected=(((xe=j())==null?void 0:xe.key)??u())===V.key}),de(()=>Me.value=V.key),Me})()})),p(He,y(ee,{get when(){return K()},keyed:!0,children:V=>(()=>{var Me=G4();return p(Me,y(zt,{each:Ib,children:xe=>{const Re=()=>D(V)[xe.key],Be=()=>e(xe.labelKey);return(()=>{var et=Z4(),Ue=et.firstChild;return Ue.$$input=We=>{const st=We.currentTarget;ke(V,xe.key,st.value).then(at=>{at||(st.value=Re())})},de(We=>{var st=Be(),at=_(),ht=`${V.name} · ${Be()} · ${Re()}`;return st!==We.e&&me(et,"title",We.e=st),at!==We.t&&(Ue.disabled=We.t=at),ht!==We.a&&me(Ue,"aria-label",We.a=ht),We},{e:void 0,t:void 0,a:void 0}),de(()=>Ue.value=Re()),et})()}})),Me})()}),F),p(F,y(ee,{get when(){var V;return(V=K())==null?void 0:V.presetId},get children(){var V=Fg();return V.$$click=()=>void H(K()),p(V,()=>e("settings.appearance.colorScheme.custom.delete")),de(()=>V.disabled=b()||_()),V}}),null),p(F,y(ee,{get when(){return N()},get children(){var V=Fg();return V.$$click=()=>void we(),p(V,()=>e("settings.appearance.colorScheme.custom.reset")),de(()=>V.disabled=b()||_()),V}}),null),p(F,y(ee,{get when(){return!b()},get children(){var V=Fg();return V.$$click=Ae,p(V,()=>e("settings.appearance.colorScheme.custom.new")),de(()=>V.disabled=_()),V}}),null),p(F,y(ee,{get when(){return k()},get children(){var V=V4();return V.$$click=()=>void Ge(),p(V,()=>e("settings.appearance.colorScheme.custom.save")),de(()=>V.disabled=!M()||_()||b()&&!w().trim()),V}}),null),p(pe,y(ee,{get when(){return b()},get children(){var V=j4(),Me=V.firstChild,xe=Me.nextSibling;return p(Me,()=>e("settings.appearance.colorScheme.custom.name")),xe.$$input=Re=>S(Re.currentTarget.value),de(()=>xe.value=w()),V}}),null),p(pe,y(ee,{get when(){return W()},get children(){var V=q4();return p(V,()=>e("settings.appearance.colorScheme.custom.saveError")),V}}),null),de(V=>{var Me=e("settings.appearance.palette.mode"),xe=_()&&!P(),Re=P(),Be=e("settings.appearance.colorScheme.title");return Me!==V.e&&me(be,"aria-label",V.e=Me),xe!==V.t&&(re.disabled=V.t=xe),Re!==V.a&&me(re,"aria-busy",V.a=Re),Be!==V.o&&me(re,"aria-label",V.o=Be),V},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>{var V,Me;return re.value=((V=j())==null?void 0:V.key)??((Me=K())==null?void 0:Me.key)??""}),E})()};Xt(["click","input"]);var J4=O("<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class=settings-scope-badge></span></div></div><div class=settings-card><div class=settings-stack>");const Q4=hk(()=>ls(()=>import("./startup-state-settings-card-BCKRPH7W.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.StartupStateSettingsCard}))),Rb=e=>{const{t}=Dt(),n=Un(),s=Te(()=>ry(n).filter(r=>r.id==="behavior.keyboardShortcutHints"||r.id==="behavior.messageTimeline"||r.id==="behavior.timelineToolCalls"||r.id==="behavior.diffViewMode"||r.id==="behavior.followUpBehavior"||r.id==="behavior.promptSubmitOnEnter"));return(()=>{var r=J4(),o=r.firstChild,a=o.firstChild,i=a.firstChild,c=i.firstChild,l=c.nextSibling,d=i.nextSibling,u=o.nextSibling,f=u.firstChild;return p(c,()=>t("folderSelection.language.ariaLabel")),p(l,()=>t("settings.general.language.subtitle")),p(d,()=>t("settings.scope.device")),p(o,y(K4,{}),null),p(r,y(Y4,{}),u),p(r,y(ee,{get when(){return e.showStartupState!==!1},get children(){return y(Q4,{})}}),u),p(f,y(oy,{settings:s,get preferences(){return n.preferences}})),r})()},bl="other",eu={minimal:"collapsed",balanced:"collapsed",detailed:"expanded",everything:"expanded"},vt="expanded",Ft="collapsed";const iy=[{tool:"bash",label:"shell",aliases:["shell"],configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"read",label:"read",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:Ft,everything:vt}},{tool:"write",label:"write",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"edit",label:"edit",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"patch",label:"patch",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"apply_patch",label:"apply_patch",configurable:!1,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"webfetch",label:"webfetch",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}},{tool:"websearch",label:"websearch",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}},{tool:"glob",label:"glob",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}},{tool:"grep",label:"grep",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}},{tool:"todowrite",label:"todowrite",configurable:!1,expansionPresets:{minimal:vt,balanced:vt,detailed:vt,everything:vt}},{tool:"task",label:"subagent",aliases:["subagent"],configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"execute",label:"execute",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"skill",label:"skill",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:Ft,everything:vt}},{tool:"question",label:"question",configurable:!0,expansionPresets:{minimal:Ft,balanced:vt,detailed:vt,everything:vt}},{tool:"invalid",label:"invalid",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:Ft,everything:vt}},{tool:bl,label:"Other tools",labelKey:"settings.behavior.expansionDefaults.otherTools",configurable:!0,expansionPresets:{minimal:Ft,balanced:Ft,detailed:vt,everything:vt}}],Xh=iy.find(e=>e.tool===bl),X4=iy.reduce((e,t)=>{var n;return e[t.tool]=t,(n=t.aliases)==null||n.forEach(s=>{e[s]=t}),e},{});function zx(e){return X4[e]??Xh}function pH(e){return zx(e).tool}function ay(){return iy.filter(e=>e.configurable)}function eR(e){const t={};for(const n of ay())t[n.tool]=n.expansionPresets[e];return t}function cy(e,t){const n=zx(t),s=n.configurable?n:Xh,r=e.toolCallExpansionDefaults,o=r.preset==="custom"?void 0:s.expansionPresets[r.preset],a=r.preset==="custom"?void 0:Xh.expansionPresets[r.preset];return r.tools[s.tool]??o??r.tools[bl]??a??e.toolOutputExpansion??"expanded"}function yH(e,t){return cy(e,t)==="expanded"}function vH(e){const t=e.toolCallExpansionDefaults;return(t.thinking??(t.preset==="custom"?void 0:eu[t.preset])??e.thinkingBlocksExpansion??"expanded")==="expanded"}const Ob={thinking:NA,diagnostics:tP,inputs:CD,usage:ZA,system:Up,bash:Kp,read:OA,write:eD,edit:KD,patch:BD,apply_patch:Td,webfetch:ei,glob:cb,grep:cb,todowrite:zA,task:BA,execute:HA,websearch:ei,skill:dD,question:fD,invalid:ti,other:kD},tR={"apply-patch":"apply_patch",shell:"bash",subagent:"task",terminal:"bash",todo:"todowrite",todo_write:"todowrite",web_fetch:"webfetch"};function nR(e){const t=(e==null?void 0:e.trim().toLowerCase().replace(/^opencode_/,""))??"",n=tR[t]??t;return Ob[n]??Ob.other}function sR(e){return[{kind:"thinking",key:"thinking",label:e("settings.behavior.expansionDefaults.thinking")},{kind:"diagnostics",key:"diagnostics",label:e("settings.behavior.diagnosticsDefault.title")},{kind:"inputs",key:"inputs",label:e("settings.behavior.toolInputsVisibility.title")},{kind:"usage",key:"usage",label:e("settings.behavior.usageMetrics.title")},{kind:"system",key:"system",label:e("transcriptFilters.systemMessages")},...ay().map(t=>({kind:"tool",key:t.tool,label:t.labelKey?e(t.labelKey):t.label}))]}function Wx(e){const t=e.toolCallExpansionDefaults;return t.thinking??(t.preset==="custom"?void 0:eu[t.preset])??e.thinkingBlocksExpansion??"expanded"}function Lb(e,t){switch(t.kind){case"thinking":return e.showThinkingBlocks?Wx(e):"hidden";case"tool":return cy(e,t.key);case"diagnostics":return e.diagnosticsExpansion;case"inputs":return e.toolInputsVisibility;case"usage":return e.showUsageMetrics?e.usageMetricsExpansion:"hidden";case"system":return e.systemMessagesVisibility??"hidden"}}function rR(e,t,n){if(t.kind==="system")return{systemMessagesVisibility:n};if(t.kind==="diagnostics")return{diagnosticsExpansion:n};if(t.kind==="inputs")return{toolInputsVisibility:n};if(t.kind==="usage")return{showUsageMetrics:n!=="hidden",usageMetricsExpansion:n==="hidden"?e.usageMetricsExpansion:n};const s=Object.fromEntries(ay().map(o=>[o.tool,cy(e,o.tool)]));t.kind==="tool"&&(s[t.key]=n);const r=t.kind==="thinking"&&n!=="hidden"?n:Wx(e);return{showThinkingBlocks:t.kind==="thinking"?n!=="hidden":e.showThinkingBlocks,toolCallExpansionDefaults:{preset:"custom",thinking:r,tools:s},thinkingBlocksExpansion:t.kind==="thinking"&&n!=="hidden"?n:e.thinkingBlocksExpansion,toolOutputExpansion:t.kind==="tool"&&t.key===bl&&n!=="hidden"?n:e.toolOutputExpansion}}var oR=O("<div class=settings-section-stack><section class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class=settings-scope-badge></span></div><div class=settings-expansion-presets></div><div class=settings-expansion-table role=table><div class=settings-expansion-table-header role=row><span role=columnheader></span><span role=columnheader>"),iR=O("<button type=button class=settings-expansion-preset><span class=settings-expansion-preset-title></span><span class=settings-expansion-preset-copy>"),aR=O('<div class="flex-1 min-w-0">'),cR=O('<div class=settings-expansion-row role=row><div class="settings-expansion-row-label flex items-center gap-2"role=cell><code></code></div><div class=settings-expansion-row-control role=cell>'),lR=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const dR=["minimal","balanced","detailed","everything"],Nb={minimal:{systemMessagesVisibility:"hidden",showThinkingBlocks:!1,diagnosticsExpansion:"collapsed",toolInputsVisibility:"hidden",showUsageMetrics:!1,usageMetricsExpansion:"collapsed"},balanced:{systemMessagesVisibility:"hidden",showThinkingBlocks:!1,diagnosticsExpansion:"expanded",toolInputsVisibility:"collapsed",showUsageMetrics:!0,usageMetricsExpansion:"collapsed"},detailed:{systemMessagesVisibility:"collapsed",showThinkingBlocks:!0,diagnosticsExpansion:"expanded",toolInputsVisibility:"collapsed",showUsageMetrics:!0,usageMetricsExpansion:"expanded"},everything:{systemMessagesVisibility:"expanded",showThinkingBlocks:!0,diagnosticsExpansion:"expanded",toolInputsVisibility:"expanded",showUsageMetrics:!0,usageMetricsExpansion:"expanded"}},uR=()=>{const{t:e}=Dt(),{preferences:t,updatePreferences:n}=Un(),s=Te(()=>[{value:"hidden",label:e("commands.common.hidden")},{value:"collapsed",label:e("commands.common.collapsed")},{value:"expanded",label:e("commands.common.expanded")}]),r=Te(()=>sR(e)),o=()=>Lb(t(),{kind:"thinking",key:"thinking"}),a=Te(()=>{const f=t(),g=f.toolCallExpansionDefaults.preset;if(g==="custom")return g;const m=Nb[g],w=m.showThinkingBlocks?eu[g]:"hidden";return o()===w&&f.diagnosticsExpansion===m.diagnosticsExpansion&&f.systemMessagesVisibility===m.systemMessagesVisibility&&f.toolInputsVisibility===m.toolInputsVisibility&&f.showUsageMetrics===m.showUsageMetrics&&f.usageMetricsExpansion===m.usageMetricsExpansion?g:"custom"}),i=f=>{const g=eR(f),m=eu[f];n({...Nb[f],toolCallExpansionDefaults:{preset:f,thinking:m,tools:g},thinkingBlocksExpansion:m,toolOutputExpansion:g[bl]==="expanded"?"expanded":"collapsed"})},c=(f,g)=>{n(rR(t(),f,g))},l=f=>Lb(t(),f),d=f=>s().find(g=>g.value===f),u=f=>e(`settings.behavior.expansionPreset.${f}.title`);return(()=>{var f=oR(),g=f.firstChild,m=g.firstChild,w=m.firstChild,S=w.firstChild,b=S.nextSibling,v=w.nextSibling,k=m.nextSibling,C=k.nextSibling,_=C.firstChild,T=_.firstChild,P=T.nextSibling;return p(S,()=>e("settings.behavior.expansionPresets.ariaLabel")),p(b,()=>e("settings.appearance.behavior.subtitle")),p(v,()=>u(a())),p(k,y(zt,{each:dR,children:I=>(()=>{var j=iR(),ne=j.firstChild,W=ne.nextSibling;return j.$$click=()=>i(I),p(ne,()=>u(I)),p(W,()=>e(`settings.behavior.expansionPreset.${I}.description`)),de(()=>me(j,"data-selected",a()===I?"true":"false")),j})()})),p(T,()=>e("settings.behavior.expansionDefaults.itemColumn")),p(P,()=>e("settings.behavior.expansionDefaults.stateColumn")),p(C,y(zt,{get each(){return r()},children:I=>{const j=Te(()=>d(l(I)));return(()=>{var ne=cR(),W=ne.firstChild,q=W.firstChild,U=W.nextSibling;return p(W,y(Tp,{get component(){return nR(I.key)},class:"w-4 h-4 shrink-0 text-secondary","aria-hidden":"true"}),q),p(q,()=>I.label),p(U,y(De,{get value(){return j()},onChange:G=>G&&c(I,G.value),get options(){return s()},optionValue:"value",optionTextValue:"label",itemComponent:G=>y(De.Item,{get item(){return G.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return G.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger settings-expansion-select",get"aria-label"(){return e("settings.behavior.expansionDefaults.rowAriaLabel",{item:I.label})},get children(){return[(()=>{var G=aR();return p(G,y(De.Value,{children:le=>(()=>{var K=lR();return p(K,()=>{var M;return(M=le.selectedOption())==null?void 0:M.label}),K})()})),G})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})),ne})()}}),null),de(I=>{var j=e("settings.behavior.expansionPresets.ariaLabel"),ne=e("settings.behavior.expansionDefaults.title");return j!==I.e&&me(k,"aria-label",I.e=j),ne!==I.t&&me(C,"aria-label",I.t=ne),I},{e:void 0,t:void 0}),f})()};Xt(["click"]);const tr=Ut("actions");function _r(e){var t,n;return!((t=e==null?void 0:e.signal)!=null&&t.aborted)&&((n=e==null?void 0:e.isCurrent)==null?void 0:n.call(e))!==!1}async function Hx(e,t){if(!_r(t))return!1;try{if(typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText)return _r(t)?(await navigator.clipboard.writeText(e),tr.info("Copied text using Clipboard API"),!0):!1}catch(r){if(!_r(t))return!1;tr.warn("Clipboard API failed, trying fallback:",r)}if(!_r(t))return!1;let n;const s=typeof document<"u"?document.activeElement:null;try{return typeof document>"u"?(tr.error("Document not available for clipboard fallback"),!1):(n=document.createElement("textarea"),n.value=e,n.readOnly=!0,n.style.position="fixed",n.style.left="-9999px",n.style.top="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select(),_r(t)?document.execCommand("copy")?(tr.info("Copied text using execCommand fallback"),!0):(tr.error("execCommand copy failed"),!1):!1)}catch(r){return tr.error("Clipboard fallback failed:",r),!1}finally{try{n==null||n.remove()}catch(r){tr.warn("Failed to remove clipboard fallback element:",r)}try{s==null||s.focus()}catch(r){tr.warn("Failed to restore focus after clipboard fallback:",r)}}}async function wH(e,t){var n;if(!_r(t))return!1;try{if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.write)&&typeof ClipboardItem<"u"){const s=new ClipboardItem({"text/plain":new Blob([...e],{type:"text/plain"})});return _r(t)?(await navigator.clipboard.write([s]),tr.info("Copied text chunks using Clipboard API"),!0):!1}}catch(s){if(!_r(t))return!1;tr.warn("Clipboard chunk write failed, trying text fallback:",s)}return _r(t)?Hx(e.join(""),t):!1}let Bg=null,ic=null;async function Fb(e=!1){if(Bg&&!e)return Bg;if(ic)return ic;const t=kt.fetchServerMeta().then(n=>(Bg=n,n));ic=t;try{return await t}finally{ic===t&&(ic=null)}}function em(e){return Gx(e.host)?"all":e.listeningMode==="all"?"specific":e.listeningMode}function tm(e){if(Gx(e.host))return e.addresses;const t=nm(e.host);return e.addresses.filter(n=>nm(n.ip)===t)}function Gx(e){const t=nm(e);return t==="0.0.0.0"?!0:t.includes(":")&&t.split(":").every(n=>n===""||/^0+$/.test(n))}function nm(e){const t=e.trim().toLowerCase();return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}function Bb(e,t,n,s,r=new Date){var c,l;const o=e?tm(e):[],a=e?s.modes[em(e)]:"—",i=[s.reportTitle,"============================",`${s.generated}: ${r.toISOString()}`,`${s.serverVersion}: ${(e==null?void 0:e.serverVersion)??"—"}`,`${s.uiVersion}: ${((c=e==null?void 0:e.ui)==null?void 0:c.version)??"—"}`,`${s.uiSource}: ${((l=e==null?void 0:e.ui)==null?void 0:l.source)??"—"}`,`${s.runtime}: ${n.host}`,`${s.platform}: ${n.platform}`,`${s.windowContext}: ${n.windowContext}`,`${s.os}: ${t}`,`${s.listeningMode}: ${a}`,`${s.bindHost}: ${(e==null?void 0:e.host)??"—"}`,`${s.localListener}: ${(e==null?void 0:e.localUrl)??"—"}`,`${s.remoteListener}: ${(e==null?void 0:e.remoteUrl)??"—"}`,`${s.workspaceRoot}: ${(e==null?void 0:e.workspaceRoot)??"—"}`,`${s.candidateAddresses}: ${o.length}`];for(const d of o)i.push(`- ${d.family}/${s.scopes[d.scope]}: ${d.remoteUrl}`);return i.push(""),i.join(`
|
|
3
|
+
`)}var fR=O("<div class=settings-card-message role=status aria-live=polite>"),Ub=O("<div class=settings-error-message role=alert>"),gR=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div></div><div class=settings-info-grid><div class=settings-info-row><span class=settings-info-label></span><span class=settings-info-value></span></div><div class=settings-info-row><span class=settings-info-label></span><span class="settings-info-value settings-info-value-muted"></span></div><div class=settings-info-row><span class=settings-info-label></span><span class=settings-info-value></span></div><div class=settings-info-row><span class=settings-info-label></span><span class=settings-info-value></span></div><div class=settings-info-row><span class=settings-info-label></span><span class="settings-info-value settings-info-value-muted"></span></div></div></div><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div></div></div><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><div class=settings-info-grid><div class=settings-info-row><span class=settings-info-label></span><span class=settings-info-value></span></div><div class=settings-info-row><span class=settings-info-label></span><span class="settings-info-value settings-info-value-muted"></span></div></div><div class=settings-info-actions><button type=button class=settings-pill-button></button></div></div><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><div class=settings-card-message></div><div class=settings-info-actions><button type=button class=settings-pill-button></button><button type=button class=settings-pill-button>'),hR=O('<dl class=settings-info-grid><div class=settings-info-row><dt class=settings-info-label></dt><dd class=settings-info-value dir=ltr></dd></div><div class=settings-info-row><dt class=settings-info-label></dt><dd class=settings-info-value></dd></div><div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr></dd></div><div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr></dd></div><div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),mR=O("<h4 class=settings-card-title>"),pR=O("<dl class=settings-info-grid>"),yR=O("<p class=settings-help-text>"),vR=O("<div class=settings-info-actions><button type=button class=settings-pill-button>"),wR=O('<div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),bR=O("<div class=settings-card-message>"),SR=O('<div class=settings-info-row><dt class=settings-info-label> · </dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),kR=O('<a target=_blank rel="noopener noreferrer"class=settings-pill-button>'),xR=O("<div class=settings-info-toast role=status aria-live=polite>");function Zx(){return navigator.userAgentData}function _R(){if(typeof navigator>"u")return"Unknown";const e=Zx();if(e!=null&&e.platform){const r=Kb(navigator.userAgent);return r?`${e.platform} ${r}`:e.platform}const t=navigator.userAgent,n=navigator.platform;if(!n)return"Unknown";const s=Kb(t);return s&&!n.includes(s)?`${n} ${s}`:n}function Kb(e){const t=e.match(/Linux\s+(x86_64|aarch64|armv[0-9]+[a-z]*|i[3-6]86)/i)??e.match(/Win64;\s*(x64|arm64)/i)??e.match(/Mac\s*OS\s*X[^)]*?_(x86_64|arm64)/i);return t?t[1]:null}async function $R(){try{const e=Zx();if(!(e!=null&&e.getHighEntropyValues))return null;const t=await e.getHighEntropyValues(["architecture","bitness"]),n=[];return t.architecture&&!t.architecture.startsWith("x86")&&n.push(t.architecture),t.bitness&&t.bitness!=="64"&&n.push(`${t.bitness}-bit`),!n.length&&t.architecture&&n.push(t.architecture),n.length>0?n.join(" "):null}catch{return null}}function CR(e,t){const n=new Blob([t],{type:"text/plain;charset=utf-8"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(s)}function Vb(e){return e.replace(/^v/,"").split("-")[0]}function ER(e,t){const n=Vb(e).split(".").map(Number),s=Vb(t).split(".").map(Number);return n.some(isNaN)||s.some(isNaN)?null:s[0]>n[0]?!0:s[0]<n[0]?!1:s[1]>n[1]?!0:s[1]<n[1]?!1:s[2]>n[2]}const TR=()=>{const{t:e}=Dt(),[t,n]=R(!1),[s,{mutate:r}]=mk(async()=>{n(!1);try{return await Fb()}catch{return n(!0),null}}),[o,a]=R(null),[i,c]=R(null);Ze(()=>{$R().then(k=>{k&&c(k)})});const l=Te(()=>{const k=s();return k!=null&&k.update?k.update:null}),d=Te(()=>{var k;return((k=s())==null?void 0:k.support)??null}),u=Te(()=>({reportTitle:e("settings.info.diagnostics.reportTitle"),generated:e("settings.info.diagnostics.generated"),serverVersion:e("settings.info.version.server"),uiVersion:e("settings.info.version.ui"),uiSource:e("settings.info.version.uiSource"),runtime:e("settings.info.runtime.type"),platform:e("settings.info.runtime.platform"),windowContext:e("settings.info.runtime.windowContext"),os:e("settings.info.runtime.os"),listeningMode:e("remoteAccess.sections.listeningMode.label"),bindHost:e("settings.info.connectivity.host"),localListener:e("settings.info.connectivity.localListener"),remoteListener:e("settings.info.connectivity.remoteListener"),workspaceRoot:e("settings.info.server.root"),candidateAddresses:e("remoteAccess.sections.addresses.label"),modes:{local:e("settings.info.connectivity.mode.local"),all:e("settings.info.connectivity.mode.all"),specific:e("settings.info.connectivity.mode.specific")},scopes:{external:e("remoteAccess.address.scope.network"),internal:e("remoteAccess.address.scope.internal"),loopback:e("remoteAccess.address.scope.loopback")}})),f=Te(()=>{var C;const k=l();return k!=null&&k.version?k.version:((C=d())==null?void 0:C.latestServerVersion)??null}),g=Te(()=>{var P,I;let k=null;const C=l();if(C!=null&&C.url?k=C.url:(P=d())!=null&&P.latestServerUrl&&(k=d().latestServerUrl??null),!k)return{url:null,show:!1};if(C!=null&&C.url)return{url:k,show:!0};const _=(I=s())==null?void 0:I.serverVersion,T=f();return!_||!T?{url:null,show:!1}:{url:k,show:ER(_,T)!==!1}});let m;Ze(()=>{o()&&(clearTimeout(m),m=setTimeout(()=>a(null),2500))}),dt(()=>clearTimeout(m));const w=async()=>{n(!1);try{const k=await Fb(!0);r(k)}catch{n(!0)}},S=Te(()=>{const k=_R(),C=i();return C?`${k} (${C})`:k}),b=async()=>{const k=Bb(s()??null,S(),$n,u()),C=await Hx(k);a(C?"success":"error")},v=()=>{const k=Bb(s()??null,S(),$n,u()),C=new Date().toISOString().replace(/[:.]/g,"-");CR(`codenomad-diagnostics-${C}.txt`,k)};return(()=>{var k=gR(),C=k.firstChild,_=C.firstChild,T=_.firstChild,P=T.firstChild,I=P.firstChild,j=I.nextSibling,ne=_.nextSibling,W=ne.firstChild,q=W.firstChild,U=q.nextSibling,G=W.nextSibling,le=G.firstChild,K=le.nextSibling,M=G.nextSibling,N=M.firstChild,oe=N.nextSibling,ge=M.nextSibling,Ie=ge.firstChild,ke=Ie.nextSibling,we=ge.nextSibling,Ae=we.firstChild,Ge=Ae.nextSibling,H=C.nextSibling,h=H.firstChild,$=h.firstChild,D=$.firstChild,E=D.firstChild,Z=E.nextSibling,B=H.nextSibling,se=B.firstChild,pe=se.firstChild,Se=pe.firstChild,Q=Se.nextSibling,be=se.nextSibling,Ve=be.firstChild,He=Ve.firstChild,re=He.nextSibling,F=Ve.nextSibling,V=F.firstChild,Me=V.nextSibling,xe=be.nextSibling,Re=xe.firstChild,Be=B.nextSibling,et=Be.firstChild,Ue=et.firstChild,We=Ue.firstChild,st=We.nextSibling,at=et.nextSibling,ht=at.nextSibling,ut=ht.firstChild,Ct=ut.nextSibling;return p(T,y(Up,{class:"settings-card-heading-icon"}),P),p(I,()=>e("settings.section.info.title")),p(j,()=>e("settings.section.info.subtitle")),p(q,()=>e("settings.info.version.ui")),p(U,()=>{var Qe,tt;return((tt=(Qe=s())==null?void 0:Qe.ui)==null?void 0:tt.version)??"—"}),p(le,()=>e("settings.info.version.uiSource")),p(K,()=>{var Qe,tt;return((tt=(Qe=s())==null?void 0:Qe.ui)==null?void 0:tt.source)??"—"}),p(N,()=>e("settings.info.runtime.type")),p(oe,()=>$n.host),p(Ie,()=>e("settings.info.runtime.platform")),p(ke,()=>$n.platform),p(Ae,()=>e("settings.info.runtime.os")),p(Ge,S),p($,y(ND,{class:"settings-card-heading-icon"}),D),p(E,()=>e("settings.info.connectivity.title")),p(Z,()=>e("settings.info.connectivity.subtitle")),p(H,y(ee,{get when(){return s.loading},get children(){var Qe=fR();return p(Qe,()=>e("remoteAccess.addresses.loading")),Qe}}),null),p(H,y(ee,{get when(){return t()},get children(){var Qe=Ub();return p(Qe,()=>e("settings.info.connectivity.loadFailed")),Qe}}),null),p(H,y(ee,{get when(){return s()},children:Qe=>[(()=>{var tt=hR(),At=tt.firstChild,xt=At.firstChild,x=xt.nextSibling,A=At.nextSibling,L=A.firstChild,X=L.nextSibling,Y=A.nextSibling,ue=Y.firstChild,ce=ue.nextSibling,ve=Y.nextSibling,je=ve.firstChild,Ke=je.nextSibling,rt=ve.nextSibling,ot=rt.firstChild,Pt=ot.nextSibling;return p(xt,()=>e("settings.info.version.server")),p(x,()=>Qe().serverVersion??"—"),p(L,()=>e("remoteAccess.sections.listeningMode.label")),p(X,()=>e(em(Qe())==="specific"?"settings.info.connectivity.mode.specific":em(Qe())==="all"?"settings.info.connectivity.mode.all":"settings.info.connectivity.mode.local")),p(ue,()=>e("settings.info.connectivity.host")),p(ce,()=>Qe().host),p(je,()=>e("settings.info.connectivity.localListener")),p(Ke,()=>Qe().localUrl),p(tt,y(ee,{get when(){return Qe().remoteUrl},children:In=>(()=>{var wn=wR(),zn=wn.firstChild,Et=zn.nextSibling;return p(zn,()=>e("settings.info.connectivity.remoteListener")),p(Et,In),wn})()}),rt),p(ot,()=>e("settings.info.server.root")),p(Pt,()=>Qe().workspaceRoot),tt})(),(()=>{var tt=mR();return p(tt,()=>e("remoteAccess.sections.addresses.label")),tt})(),y(ee,{get when(){return tm(Qe()).length>0},get fallback(){return(()=>{var tt=bR();return p(tt,()=>e("remoteAccess.addresses.none")),tt})()},get children(){var tt=pR();return p(tt,y(zt,{get each(){return tm(Qe())},children:At=>(()=>{var xt=SR(),x=xt.firstChild,A=x.firstChild,L=x.nextSibling;return p(x,()=>At.family.toUpperCase(),A),p(x,()=>e(At.scope==="external"?"remoteAccess.address.scope.network":At.scope==="internal"?"remoteAccess.address.scope.internal":"remoteAccess.address.scope.loopback"),null),p(L,()=>At.remoteUrl),xt})()})),tt}}),(()=>{var tt=yR();return p(tt,()=>e("settings.info.connectivity.disclaimer")),tt})(),y(ee,{get when(){return ia()},get children(){var tt=vR(),At=tt.firstChild;return At.$$click=()=>qx("remote"),p(At,()=>e("settings.nav.remote")),tt}})]}),null),p(Se,()=>e("settings.info.updates.title")),p(Q,()=>e("settings.info.updates.subtitle")),p(He,()=>e("settings.info.version.server")),p(re,()=>{var Qe;return((Qe=s())==null?void 0:Qe.serverVersion)??"—"}),p(V,()=>e("settings.info.updates.latest")),p(Me,()=>f()??"—"),p(xe,(()=>{var Qe=Ee(()=>!!g().show);return()=>Qe()&&(()=>{var tt=kR();return p(tt,()=>e("settings.info.updates.download")),de(()=>me(tt,"href",g().url)),tt})()})(),Re),Re.$$click=w,p(Re,()=>e("settings.info.updates.refresh")),p(We,()=>e("settings.info.diagnostics.title")),p(st,()=>e("settings.info.diagnostics.subtitle")),p(at,()=>e("settings.info.diagnostics.privacy")),ut.$$click=b,p(ut,()=>e("settings.info.diagnostics.copy")),Ct.$$click=v,p(Ct,()=>e("settings.info.diagnostics.download")),p(Be,(()=>{var Qe=Ee(()=>o()==="success");return()=>Qe()&&(()=>{var tt=xR();return p(tt,()=>e("settings.info.diagnostics.copied")),tt})()})(),null),p(Be,(()=>{var Qe=Ee(()=>o()==="error");return()=>Qe()&&(()=>{var tt=Ub();return p(tt,()=>e("settings.info.diagnostics.copyFailed")),tt})()})(),null),de(()=>Re.disabled=s.loading),k})()};Xt(["click"]);var MR=O('<div><button type=button class="absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center text-slate-200/80 hover:text-slate-50 hover:bg-white/10">x</button><div class="flex items-start gap-3 pr-6"><span></span><div class="min-w-0 flex-1 text-sm leading-snug"><p>'),AR=O("<p>"),DR=O('<button type=button class="mt-3 inline-flex items-center text-xs font-semibold uppercase tracking-wide text-sky-300 hover:text-sky-200">');const jb=50;let _s=[];const sm=new Set,[PR,IR]=R(0);function bH(){return PR}function Sl(){IR(_s.filter(e=>!e.read).length)}function kl(){const e=[..._s];sm.forEach(t=>{try{t(e)}catch(n){console.error("[notifications] subscriber error:",n)}})}function RR(){return`toast_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function OR(){_s.length>jb&&(_s=_s.slice(0,jb))}function LR(e){const t={...e,id:RR(),createdAt:Date.now(),read:!1};return _s.unshift(t),OR(),Sl(),kl(),t.id}function SH(){_s=[],Sl(),kl()}function kH(e){const t=_s.find(n=>n.id===e);t&&!t.read&&(t.read=!0,Sl(),kl())}function xH(){let e=!1;_s.forEach(t=>{t.read||(t.read=!0,e=!0)}),e&&(Sl(),kl())}function _H(e){const t=_s.findIndex(n=>n.id===e);t!==-1&&(_s.splice(t,1),Sl(),kl())}function $H(e){return sm.add(e),e([..._s]),()=>{sm.delete(e)}}async function qb(e){if(!(typeof window>"u")){try{if(Dn()){const{openUrl:t}=await ls(async()=>{const{openUrl:n}=await import("./index-cCIfI5Gs.js");return{openUrl:n}},__vite__mapDeps([9,6,2,3,4,5,1,7]));await t(e);return}}catch(t){console.warn("[notifications] unable to open via system opener",t)}try{window.open(e,"_blank","noopener,noreferrer")}catch(t){console.warn("[notifications] unable to open external url",t),jn.error($e("toastHistory.openLinkError"))}}}async function NR(e){if(!e.onClick){await qb(e.href);return}try{await e.onClick()}catch(t){console.warn("[notifications] action failed; opening fallback link",t),await qb(e.href)}}const FR={info:{badge:"bg-sky-500/40",container:"bg-slate-900/95 border-slate-700 text-slate-100",headline:"text-slate-50",body:"text-slate-200/80"},success:{badge:"bg-emerald-500/40",container:"bg-emerald-950/90 border-emerald-800 text-emerald-50",headline:"text-emerald-50",body:"text-emerald-100/80"},warning:{badge:"bg-amber-500/40",container:"bg-amber-950/90 border-amber-800 text-amber-50",headline:"text-amber-50",body:"text-amber-100/80"},error:{badge:"bg-rose-500/40",container:"bg-rose-950/90 border-rose-800 text-rose-50",headline:"text-rose-50",body:"text-rose-100/80"}};function Hn(e){const t=FR[e.variant],n=e.duration??1e4;LR({title:e.title,message:e.message,variant:e.variant,action:e.action});const s=jn.custom(()=>(()=>{var r=MR(),o=r.firstChild,a=o.nextSibling,i=a.firstChild,c=i.nextSibling,l=c.firstChild;return o.$$click=()=>jn.dismiss(s),p(c,(()=>{var d=Ee(()=>!!e.title);return()=>d()&&(()=>{var u=AR();return p(u,()=>e.title),de(()=>ws(u,`break-words ${t.headline} font-semibold`)),u})()})(),l),p(l,()=>e.message),p(c,(()=>{var d=Ee(()=>!!e.action);return()=>d()&&(()=>{var u=DR();return u.$$click=()=>void NR(e.action),p(u,()=>e.action.label),u})()})(),null),de(d=>{var u=`pointer-events-auto relative w-[320px] max-w-[360px] border px-4 py-3 shadow-xl ${t.container}`,f=$e("toastHistory.close"),g=$e("toastHistory.close"),m=`mt-1 inline-block h-2.5 w-2.5 rounded-full ${t.badge}`,w=`${t.body} ${e.title?"mt-1":""} whitespace-pre-wrap break-words [overflow-wrap:anywhere]`;return u!==d.e&&ws(r,d.e=u),f!==d.t&&me(o,"aria-label",d.t=f),g!==d.a&&me(o,"title",d.a=g),m!==d.o&&ws(i,d.o=m),w!==d.i&&ws(l,d.i=w),d},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r})(),{duration:n,position:e.position??"top-right",ariaProps:{role:"status","aria-live":"polite"}});return{id:s,dismiss:()=>jn.dismiss(s)}}Xt(["click"]);const yf=Ut("actions");function vf(){return typeof window<"u"&&typeof window.Notification<"u"}function ly(){if(!vf())return"unsupported";const e=window.Notification.permission;return e==="granted"?"granted":e==="denied"?"denied":"default"}async function BR(){if(!vf())return"unsupported";try{const e=await window.Notification.requestPermission();return e==="granted"?"granted":e==="denied"?"denied":"default"}catch(e){return yf.warn("[os-notifications] requestPermission failed",e),ly()}}async function UR(e){if(!vf())throw new Error("Web notifications not supported");if(ly()!=="granted")throw new Error("Web notification permission not granted");new window.Notification(e.title,{body:e.body})}function dy(){if(typeof window>"u")return!1;const e=window.electronAPI;return!!(e&&typeof e.showNotification=="function")}function CH(){return typeof window>"u"?!1:Bn()?dy():Dn()?!0:vf()}async function KR(e){const t=window.electronAPI;if(!t||typeof t.showNotification!="function")throw new Error("Electron notification bridge unavailable");await t.showNotification(e)}async function uy(){try{return await ls(()=>import("./index-QPxBkmUK.js"),__vite__mapDeps([10,6,2,3,4,5,1,7]))}catch(e){return yf.info("[os-notifications] tauri notification plugin not available",e),null}}async function Yx(){const e=await uy();if(!e)return"unsupported";try{return await e.isPermissionGranted()?"granted":"default"}catch(t){return yf.warn("[os-notifications] failed to check tauri notification permission",t),"default"}}async function VR(){const e=await uy();if(!e)return"unsupported";try{const t=await e.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"default"}catch(t){return yf.warn("[os-notifications] failed to request tauri notification permission",t),await Yx()}}async function jR(e){const t=await uy();if(!t)throw new Error("Tauri notification plugin unavailable");await t.sendNotification({title:e.title,body:e.body})}async function qR(){if(typeof window>"u")return{supported:!1,permission:"unsupported",info:"Not available in this environment."};if(Bn())return dy()?{supported:!0,permission:"granted",info:"Notifications are managed by your OS notification settings."}:{supported:!1,permission:"unsupported",info:"Electron notification bridge is not available."};if(Dn()){const n=await Yx(),s=n!=="unsupported";return{supported:s,permission:n,info:s?void 0:"Tauri notification support is not available in this build."}}const e=ly(),t=e!=="unsupported";return{supported:t,permission:e,info:t?void 0:"This browser does not support OS notifications (or notifications are blocked by the environment)."}}async function zb(){return typeof window>"u"?"unsupported":Bn()?dy()?"granted":"unsupported":Dn()?await VR():await BR()}async function zR(e){if(!(typeof window>"u")){if(Bn()){await KR(e);return}if(Dn()){await jR(e);return}await UR(e)}}var WR=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap">'),Wb=O("<div class=settings-inline-note>"),HR=O("<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class=settings-scope-badge></span></div><div class=settings-stack><div class=settings-toggle-row><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><label class=settings-checkbox-toggle><input type=checkbox><span></span></label></div><div class=settings-toggle-row><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><label class=settings-checkbox-toggle><input type=checkbox><span></span></label></div></div></div><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class=settings-scope-badge></span></div><div class=settings-stack><div class=settings-toggle-row><div><div class=settings-toggle-title></div></div><label class=settings-checkbox-toggle><input type=checkbox><span></span></label></div><div class=settings-toggle-row><div><div class=settings-toggle-title></div></div><label class=settings-checkbox-toggle><input type=checkbox><span>");function GR(e,t){switch(e){case"granted":return t("settings.notifications.permission.granted");case"denied":return t("settings.notifications.permission.denied");case"default":return t("settings.notifications.permission.default");case"unsupported":return t("settings.notifications.permission.unsupported");default:return String(e)}}const ZR=()=>{const{t:e}=Dt(),{preferences:t,updatePreferences:n}=Un(),[s,{refetch:r}]=mk(()=>qR());Ze(()=>{r()});const o=async d=>{if(!d){n({osNotificationsEnabled:!1});return}const u=s();if(u&&!u.supported){Hn({title:e("settings.section.notifications.title"),message:u.info??e("settings.notifications.messages.unsupportedEnvironment"),variant:"warning"}),n({osNotificationsEnabled:!1});return}const f=await zb();if(f!=="granted"){Hn({title:e("settings.section.notifications.title"),message:e(f==="denied"?"settings.notifications.messages.permissionDenied":"settings.notifications.messages.permissionNotGranted"),variant:"warning"}),n({osNotificationsEnabled:!1});return}n({osNotificationsEnabled:!0}),r()},a=async()=>{const d=s();if(d&&!d.supported){Hn({title:e("settings.section.notifications.title"),message:d.info??e("settings.notifications.messages.unsupportedGeneral"),variant:"warning"});return}const u=await zb();if(u==="granted"){Hn({title:e("settings.section.notifications.title"),message:e("settings.notifications.messages.permissionGranted"),variant:"success",duration:6e3}),r();return}Hn({title:e("settings.section.notifications.title"),message:e(u==="denied"?"settings.notifications.messages.permissionRequestDenied":"settings.notifications.messages.permissionNotGranted"),variant:"warning"}),r()},i=()=>{var d;return((d=s())==null?void 0:d.supported)??!1},c=()=>{var d;return GR(((d=s())==null?void 0:d.permission)??"unsupported",e)},l=()=>{var d;return(d=s())==null?void 0:d.info};return(()=>{var d=HR(),u=d.firstChild,f=u.firstChild,g=f.firstChild,m=g.firstChild,w=m.firstChild,S=w.nextSibling,b=g.nextSibling,v=f.nextSibling,k=v.firstChild,C=k.firstChild,_=C.firstChild,T=_.nextSibling,P=C.nextSibling,I=P.firstChild,j=I.nextSibling,ne=k.nextSibling,W=ne.firstChild,q=W.firstChild,U=q.nextSibling,G=W.nextSibling,le=G.firstChild,K=le.nextSibling,M=u.nextSibling,N=M.firstChild,oe=N.firstChild,ge=oe.firstChild,Ie=ge.nextSibling,ke=oe.nextSibling,we=N.nextSibling,Ae=we.firstChild,Ge=Ae.firstChild,H=Ge.firstChild,h=Ge.nextSibling,$=h.firstChild,D=$.nextSibling,E=Ae.nextSibling,Z=E.firstChild,B=Z.firstChild,se=Z.nextSibling,pe=se.firstChild,Se=pe.nextSibling;return p(g,y(Jk,{class:"settings-card-heading-icon"}),m),p(w,()=>e("settings.notifications.sessionStatus.title")),p(S,()=>e("settings.notifications.sessionStatus.subtitle")),p(b,()=>e("settings.scope.device")),p(_,()=>e("settings.notifications.enable.title")),p(T,()=>e("settings.notifications.enable.permission",{permission:c()})),I.addEventListener("change",Q=>void o(Q.currentTarget.checked)),p(j,()=>e("settings.common.enabled")),p(v,y(ee,{get when(){var Q;return Ee(()=>!!i())()&&(((Q=s())==null?void 0:Q.permission)??"unsupported")!=="granted"},get children(){var Q=WR(),be=Q.firstChild,Ve=be.firstChild,He=Ve.nextSibling,re=be.nextSibling;return p(Ve,()=>e("settings.notifications.requestPermission.title")),p(He,()=>e("settings.notifications.requestPermission.subtitle")),re.$$click=()=>void a(),p(re,()=>e("settings.notifications.requestPermission.action")),Q}}),ne),p(q,()=>e("settings.notifications.allowVisible.title")),p(U,()=>e("settings.notifications.allowVisible.subtitle")),le.addEventListener("change",Q=>n({osNotificationsAllowWhenVisible:Q.currentTarget.checked})),p(K,()=>e("settings.common.enabled")),p(v,y(ee,{get when(){return!!l()},get children(){var Q=Wb();return p(Q,l),Q}}),null),p(v,y(ee,{get when(){return Ee(()=>!i())()&&s.state==="ready"},get children(){var Q=Wb();return p(Q,()=>e("settings.notifications.unsupportedNote")),Q}}),null),p(ge,()=>e("settings.notifications.events.title")),p(Ie,()=>e("settings.notifications.events.subtitle")),p(ke,()=>e("settings.scope.device")),p(H,()=>e("settings.notifications.events.needsInput")),$.addEventListener("change",Q=>n({notifyOnNeedsInput:Q.currentTarget.checked})),p(D,()=>e("settings.common.enabled")),p(B,()=>e("settings.notifications.events.idle")),pe.addEventListener("change",Q=>n({notifyOnIdle:Q.currentTarget.checked})),p(Se,()=>e("settings.common.enabled")),de(Q=>{var be=!i()&&s.state==="ready",Ve=!t().osNotificationsEnabled,He=!t().osNotificationsEnabled,re=!t().osNotificationsEnabled;return be!==Q.e&&(I.disabled=Q.e=be),Ve!==Q.t&&(le.disabled=Q.t=Ve),He!==Q.a&&($.disabled=Q.a=He),re!==Q.o&&(pe.disabled=Q.o=re),Q},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>I.checked=!!t().osNotificationsEnabled),de(()=>le.checked=!!t().osNotificationsAllowWhenVisible),de(()=>$.checked=!!t().notifyOnNeedsInput),de(()=>pe.checked=!!t().notifyOnIdle),d})()};Xt(["click"]);function Hb(e,t,n,s,r,o){if(e)return{apiKey:null,baseUrl:null,model:null};const a=t.trim(),i=(n.trim()||"")!==(r||""),c=s.trim()===o.trim();return i?{...a?{apiKey:a}:{apiKey:null},baseUrl:n.trim()||null,model:c?null:s.trim()||null}:{...a?{apiKey:a}:{},model:c?null:s.trim()||null}}function Jx(e){return e==="wav"?"audio/wav":e==="opus"?YR(e):e==="aac"?"audio/aac":"audio/mpeg"}function Qx(e){return e==="wav"?["audio/wav"]:e==="opus"?['audio/ogg; codecs="opus"','audio/webm; codecs="opus"',"audio/opus"]:e==="aac"?["audio/aac","audio/mp4",'audio/mp4; codecs="mp4a.40.2"']:["audio/mpeg"]}function YR(e){const t=Qx(e);return typeof MediaSource>"u"?t[0]:t.find(n=>MediaSource.isTypeSupported(n))??t[0]}function Wc(e){var t;return typeof window>"u"||typeof window.Audio>"u"?{available:!1,reason:"unsupported-environment"}:e.playbackMode!=="streaming"?{available:!0}:(t=e.capabilities)!=null&&t.supportsStreamingTts?typeof MediaSource>"u"||!Qx(e.ttsFormat).some(n=>MediaSource.isTypeSupported(n))?{available:!1,reason:"browser-streaming-unavailable"}:{available:!0}:{available:!1,reason:"provider-streaming-unavailable"}}const rm=new Map;let xn=null;function JR(e){var t;(t=rm.get(e))==null||t()}function om(e){if(!xn||e&&xn.ownerId!==e)return;const t=xn;xn=null,t.stop()}function Gb(e,t){if((xn==null?void 0:xn.ownerId)===e){xn={ownerId:e,stop:t};return}om(),xn={ownerId:e,stop:t}}function QR(e){const{t}=Dt(),{serverSettings:n}=Un(),[s,r]=R("idle");let o=0,a=null,i=null,c=null;Ze(()=>{Bc()});const l=()=>{c&&(c.abort(),c=null),a&&(a.pause(),a.currentTime=0,a.src="",a.load(),a=null),i&&(URL.revokeObjectURL(i),i=null)},d=()=>{o+=1,l(),r("idle")};rm.set(e.id(),d),dt(()=>{rm.delete(e.id()),om(e.id()),d()});const u=()=>typeof window<"u"&&typeof window.Audio<"u",f=()=>{var k;return{...n().speech,...((k=e.settingsOverride)==null?void 0:k.call(e))??{}}},g=()=>{const k=ao();return!u()||!(k!=null&&k.available)||!(k!=null&&k.ttsConfigured)||!(k!=null&&k.supportsTts)?!1:Wc({playbackMode:f().playbackMode,ttsFormat:f().ttsFormat,capabilities:k}).available},m=()=>{(xn==null?void 0:xn.ownerId)===e.id()&&(xn=null),d()},w=async()=>{const k=e.id(),C=e.text().trim();if(!C||s()==="loading"||s()==="playing")return;if(!u()){Ns(t("messageItem.actions.speak.error.unsupported"),{title:t("messageItem.actions.speak.error.title"),variant:"error"});return}const _=await Bc()??ao();if(!(_!=null&&_.available)||!(_!=null&&_.ttsConfigured)||!(_!=null&&_.supportsTts)){Ns(t("messageItem.actions.speak.error.unavailable"),{title:t("messageItem.actions.speak.error.title"),variant:"error"});return}const T=Wc({playbackMode:f().playbackMode,ttsFormat:f().ttsFormat,capabilities:_});if(!T.available){const ne=T.reason==="provider-streaming-unavailable"?"settings.speech.compatibility.streamingUnavailable":T.reason==="browser-streaming-unavailable"?"settings.speech.compatibility.browserStreamingUnavailable":"messageItem.actions.speak.error.unsupported";Ns(t("messageItem.actions.speak.error.unavailable"),{title:t("messageItem.actions.speak.error.title"),detail:t(ne),variant:"error"});return}o+=1;const P=o;om(),l(),r("loading");const I=f(),j=I.ttsFormat;try{I.playbackMode==="streaming"?await b(k,P,C,j):await S(k,P,C,j)}catch(ne){if(P!==o)return;d(),Ns(t("messageItem.actions.speak.error.generate"),{title:t("messageItem.actions.speak.error.title"),detail:ne instanceof Error?ne.message:String(ne),variant:"error"})}};async function S(k,C,_,T){const P=await kt.synthesizeSpeech({text:_,format:T});if(C!==o)return;const I=nO(P.audioBase64,P.mimeType),j=new Audio(I);i=I,a=j,Zb(k,j),Gb(k,()=>{l(),r("idle")}),r("playing"),await j.play()}async function b(k,C,_,T){if(typeof MediaSource>"u")throw new Error("MediaSource is not available in this browser.");const P=new AbortController;c=P;const I=await kt.synthesizeSpeechStream({text:_,format:T},P.signal),j=I.headers.get("content-type")||Jx(T);if(!MediaSource.isTypeSupported(j))throw new Error(`Streaming playback is not supported for ${j}.`);const ne=I.body;if(!ne)throw new Error("Speech stream did not include a response body.");const W=new MediaSource,q=URL.createObjectURL(W),U=new Audio(q);i=q,a=U,Zb(k,U),Gb(k,()=>{l(),r("idle")}),await new Promise((G,le)=>{const K=()=>{W.removeEventListener("sourceopen",K),XR({mediaSource:W,stream:ne,mimeType:j,audioElement:U,onPlayable:async()=>{if(C===o){s()!=="playing"&&r("playing");try{await U.play()}catch(M){le(M)}}},onComplete:G,onError:le})};W.addEventListener("sourceopen",K,{once:!0}),U.addEventListener("error",()=>le(new Error("Unable to play streamed speech.")),{once:!0})})}return{state:s,canUseSpeech:g,isLoading:()=>s()==="loading",isPlaying:()=>s()==="playing",toggle:async()=>{if(s()==="idle"){await w();return}m()},stop:m,buttonTitle:()=>s()==="loading"?t("messageItem.actions.generatingSpeech"):s()==="playing"?t("messageItem.actions.stopSpeech"):t("messageItem.actions.speak")}}function Zb(e,t){const n=()=>{(xn==null?void 0:xn.ownerId)===e&&(xn=null),JR(e)};t.addEventListener("ended",n,{once:!0}),t.addEventListener("error",n,{once:!0})}async function XR(e){try{const t=e.mediaSource.addSourceBuffer(e.mimeType),n=e.stream.getReader();let s=!1,r=[],o=!1;const a=async()=>{if(o||t.updating||r.length===0)return;o=!0;const i=r.shift();await eO(t,i),s||(s=!0,await e.onPlayable()),o=!1,await a()};for(;;){const{done:i,value:c}=await n.read();if(i)break;c&&c.byteLength>0&&(r.push(c),await a())}for(;r.length>0||t.updating;)r.length>0?await a():await tO(t);e.mediaSource.readyState==="open"&&e.mediaSource.endOfStream(),e.onComplete()}catch(t){e.onError(t)}}function eO(e,t){return new Promise((n,s)=>{const r=()=>{a(),n()},o=()=>{a(),s(new Error("Failed to append audio stream chunk."))},a=()=>{e.removeEventListener("updateend",r),e.removeEventListener("error",o)};e.addEventListener("updateend",r,{once:!0}),e.addEventListener("error",o,{once:!0}),e.appendBuffer(new Uint8Array(t).buffer)})}function tO(e){return new Promise(t=>{e.addEventListener("updateend",()=>t(),{once:!0})})}function nO(e,t){const n=atob(e),s=new Uint8Array(n.length);for(let r=0;r<n.length;r+=1)s[r]=n.charCodeAt(r);return URL.createObjectURL(new Blob([s],{type:t||"audio/mpeg"}))}async function sO(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let s="";for(const r of n)s+=String.fromCharCode(r);return btoa(s)}function rO(e){const n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(s=>typeof MediaRecorder.isTypeSupported!="function"||MediaRecorder.isTypeSupported(s));return n?new MediaRecorder(e,{mimeType:n}):new MediaRecorder(e)}function Yb(e){e==null||e.getTracks().forEach(t=>t.stop())}function oO(){const{t:e}=Dt(),[t,n]=R("idle"),[s,r]=R(null);let o=null,a=null,i=[],c=0,l=!1;const d=()=>{var v;return typeof window>"u"?!1:typeof window.MediaRecorder<"u"&&!!((v=navigator.mediaDevices)!=null&&v.getUserMedia)},u=()=>{const v=ao();return!!(d()&&(v!=null&&v.available)&&(v!=null&&v.sttConfigured)&&(v!=null&&v.supportsStt))},f=()=>{Yb(a),a=null},g=()=>{o&&o.state!=="inactive"&&o.stop(),o=null,f(),i=[]};dt(()=>{l=!0,c+=1,g()});const m=async()=>{var k,C;if(!d()){Ns(e("promptInput.voiceInput.error.unsupported"),{title:e("promptInput.voiceInput.error.title"),variant:"error"});return}const v=++c;n("requesting"),r(null);try{if(Bn()){const P=await((C=(k=window.electronAPI)==null?void 0:k.requestMicrophoneAccess)==null?void 0:C.call(k));if(P&&!P.granted)throw new Error(e("promptInput.voiceInput.error.permissionDenied"))}const _=await navigator.mediaDevices.getUserMedia({audio:!0});if(v!==c||l){Yb(_);return}i=[],a=_;const T=rO(_);o=T,T.addEventListener("dataavailable",P=>{P.data.size>0&&v===c&&i.push(P.data)}),T.addEventListener("error",()=>{v===c&&(g(),n("idle"))}),T.addEventListener("stop",()=>{v===c&&S(v)}),n("recording"),T.start()}catch(_){if(v!==c)return;g(),n("idle"),Ns(e("promptInput.voiceInput.error.permission"),{title:e("promptInput.voiceInput.error.title"),detail:_ instanceof Error?_.message:String(_),variant:"error"})}},w=()=>{!o||t()!=="recording"||(o.stop(),f(),n("transcribing"))},S=async v=>{var T;const k=i;i=[];const C=o;if(o=null,v!==c||k.length===0){v===c&&n("idle");return}const _=(C==null?void 0:C.mimeType)||((T=k[0])==null?void 0:T.type)||"audio/webm";try{const P=new Blob(k,{type:_}),I=await kt.transcribeAudio({audioBase64:await sO(P),mimeType:_});v===c&&r(I.text.trim()||e("settings.speech.testInput.empty"))}catch(P){v===c&&Ns(e("promptInput.voiceInput.error.transcribe"),{title:e("promptInput.voiceInput.error.title"),detail:P instanceof Error?P.message:String(P),variant:"error"})}finally{v===c&&n("idle")}};return{state:t,result:s,canUseTranscription:u,isRecording:()=>t()==="recording",isTranscribing:()=>t()==="transcribing",toggle:async()=>{if(t()==="recording"){w();return}t()==="idle"&&await m()},buttonTitle:()=>t()==="requesting"?e("settings.speech.testInput.requesting"):t()==="recording"?e("settings.speech.testInput.stop"):t()==="transcribing"?e("settings.speech.testInput.transcribing"):e("settings.speech.testInput.action")}}var iO=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><label class=settings-checkbox-toggle><input type=checkbox><span>'),Ug=O('<button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap">'),aO=O("<div class=settings-inline-note> "),Jb=O("<div class=settings-card-section-header><h4 class=settings-card-section-title>"),Kg=O("<div class=settings-inline-note>"),cO=O('<div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server"></span></div><div class=settings-stack><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><div class=settings-toolbar-inline><span class=settings-inline-note></span><span class=settings-inline-note></span><span class=settings-inline-note></span><button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap inline-flex items-center gap-2"><span></span></button><button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap inline-flex items-center gap-2"><span></span></button><button type=button class="selector-button selector-button-primary w-auto whitespace-nowrap"></button></div></div><div class=settings-inline-note></div><div class=settings-inline-note>'),lO=O("<span class=settings-inline-note>"),dO=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><div class="flex items-center gap-2 w-full min-w-0 sm:min-w-[18rem] sm:max-w-[24rem]"><input class="selector-input w-full">'),uO=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><div class="w-full min-w-0 sm:min-w-[18rem] sm:max-w-[24rem]"><select class="selector-input w-full">'),fO=O("<option>");const gO=Ut("actions");function Qb(e,t){const n=e[t];return{apiKey:"",baseUrl:n.baseUrl??"",model:n.model}}function Vg(e){return{separateProviders:e.separateProviders,apiKey:"",baseUrl:e.baseUrl??"",sttModel:e.sttModel,ttsModel:e.ttsModel,ttsVoice:e.ttsVoice,playbackMode:e.playbackMode,ttsFormat:e.ttsFormat,stt:Qb(e,"stt"),tts:Qb(e,"tts")}}function Xb(e,t){return e.apiKey===t.apiKey&&e.baseUrl===t.baseUrl&&e.model===t.model}function hO(e,t){return e.separateProviders===t.separateProviders&&e.apiKey===t.apiKey&&e.baseUrl===t.baseUrl&&e.sttModel===t.sttModel&&e.ttsModel===t.ttsModel&&e.ttsVoice===t.ttsVoice&&e.playbackMode===t.playbackMode&&e.ttsFormat===t.ttsFormat&&Xb(e.stt,t.stt)&&Xb(e.tts,t.tts)}const mO=()=>{const{t:e}=Dt(),{serverSettings:t,updateSpeechSettings:n}=Un(),s=Vg(t().speech),[r,o]=R(!1),[a,i]=R("saved"),[c,l]=R(s),[d,u]=R(!1),[f,g]=R(!1),[m,w]=R(!1),[S,b]=R(!1),[v,k]=R(!1),[C,_]=R(!1),T=QR({id:()=>"settings-speech-test",text:()=>e("settings.speech.testPlayback.sample"),settingsOverride:()=>({playbackMode:c().playbackMode,ttsFormat:c().ttsFormat})}),P=oO();Ze(()=>{const M=t().speech,N=Vg(M);if(!r()&&!G()){const oe=Eg()?N:{...N,separateProviders:!1};hO(c(),oe)||l(oe),d()&&u(!1),f()&&g(!1),m()&&w(!1),S()&&b(!1),v()&&k(!1),C()&&_(!1)}}),Ze(()=>{Bc()});const I=()=>{if(iM())return e("settings.speech.status.loading");if(aM())return e("settings.speech.status.error");const M=ao();return M!=null&&M.separateProviders?M.sttConfigured&&M.ttsConfigured?e("settings.speech.status.configured"):M.sttConfigured||M.ttsConfigured?e("settings.speech.status.partial"):e("settings.speech.status.missing"):M!=null&&M.configured?e("settings.speech.status.configured"):e("settings.speech.status.missing")},j=(M,N)=>{i("idle"),M==="apiKey"&&(u(!0),g(!1)),l(oe=>({...oe,[M]:N}))},ne=(M,N,oe)=>{i("idle"),N==="apiKey"&&(M==="stt"?(w(!0),b(!1)):(k(!0),_(!1))),l(ge=>({...ge,[M]:{...ge[M],[N]:oe}}))},W=Te(()=>f()||c().apiKey.trim().length>0),q=Te(()=>Wc({playbackMode:c().playbackMode,ttsFormat:c().ttsFormat,capabilities:ao()})),U=Te(()=>{const M=ao();return!(M!=null&&M.available)||!(M!=null&&M.ttsConfigured)||!(M!=null&&M.supportsTts)?null:c().playbackMode==="streaming"&&!M.supportsStreamingTts?e("settings.speech.compatibility.streamingUnavailable"):c().playbackMode==="streaming"&&!q().available?e("settings.speech.compatibility.browserStreamingUnavailable"):e("settings.speech.compatibility.runtimeNote")}),G=Te(()=>{const M=t().speech,N=c();if(N.separateProviders!==M.separateProviders)return!0;if(N.separateProviders){const oe=M.stt,ge=M.tts,Ie=S()||N.stt.apiKey.trim().length>0||(N.stt.baseUrl||"")!==(oe.baseUrl||"")||N.stt.model!==oe.model,ke=C()||N.tts.apiKey.trim().length>0||(N.tts.baseUrl||"")!==(ge.baseUrl||"")||N.tts.model!==ge.model||N.ttsVoice!==M.ttsVoice||N.playbackMode!==M.playbackMode||N.ttsFormat!==M.ttsFormat;return Ie||ke}return W()||(N.baseUrl||"")!==(M.baseUrl||"")||N.sttModel!==M.sttModel||N.ttsModel!==M.ttsModel||N.ttsVoice!==M.ttsVoice||N.playbackMode!==M.playbackMode||N.ttsFormat!==M.ttsFormat}),le=()=>r()?e("settings.speech.save.saving"):a()==="saved"?e("settings.speech.save.saved"):a()==="error"?e("settings.speech.save.error"):e("settings.speech.save.unsaved");async function K(){if(!G()||r())return;const M=c(),N=t().speech;o(!0),i("idle");try{if(M.separateProviders)await n({separateProviders:!0,stt:Hb(S(),M.stt.apiKey,M.stt.baseUrl,M.stt.model,N.stt.baseUrl,N.sttModel),tts:Hb(C(),M.tts.apiKey,M.tts.baseUrl,M.tts.model,N.tts.baseUrl,N.ttsModel),...M.sttModel!==N.sttModel?{sttModel:M.sttModel.trim()||null}:{},...M.ttsModel!==N.ttsModel?{ttsModel:M.ttsModel.trim()||null}:{},...M.baseUrl!==(N.baseUrl||"")?{baseUrl:M.baseUrl.trim()||null,...f()?{}:M.apiKey.trim()?{}:{apiKey:null}}:{},...f()?{apiKey:null}:M.apiKey.trim()?{apiKey:M.apiKey.trim()}:{},ttsVoice:M.ttsVoice.trim()||null,playbackMode:M.playbackMode,ttsFormat:M.ttsFormat});else{const oe=M.apiKey.trim(),ge=(M.baseUrl.trim()||"")!==(N.baseUrl||"");await n({separateProviders:!1,...f()?{apiKey:null}:oe?{apiKey:oe}:ge?{apiKey:null}:{},...ge?{baseUrl:M.baseUrl.trim()||null}:{},sttModel:M.sttModel.trim()||null,ttsModel:M.ttsModel.trim()||null,ttsVoice:M.ttsVoice.trim()||null,playbackMode:M.playbackMode,ttsFormat:M.ttsFormat})}await Bc(!0),l(Vg(t().speech)),u(!1),g(!1),w(!1),b(!1),k(!1),_(!1),i("saved")}catch(oe){gO.error("Failed to save speech settings",oe),i("error")}finally{o(!1)}}return(()=>{var M=cO(),N=M.firstChild,oe=N.firstChild,ge=oe.firstChild,Ie=ge.firstChild,ke=Ie.nextSibling,we=oe.nextSibling,Ae=N.nextSibling,Ge=Ae.firstChild,H=Ge.firstChild,h=H.firstChild,$=h.nextSibling,D=H.nextSibling,E=D.firstChild,Z=E.nextSibling,B=Z.nextSibling,se=B.nextSibling,pe=se.firstChild,Se=se.nextSibling,Q=Se.firstChild,be=Se.nextSibling,Ve=Ge.nextSibling,He=Ve.nextSibling;return p(oe,y(Kh,{class:"settings-card-heading-icon"}),ge),p(Ie,()=>e("settings.speech.title")),p(ke,()=>e("settings.speech.subtitle")),p(we,()=>e("settings.scope.server")),p(h,()=>e("settings.speech.provider.title")),p($,()=>e("settings.speech.provider.subtitle")),p(E,()=>e("settings.speech.provider.openaiCompatible")),p(Z,I),p(B,le),se.$$click=()=>void P.toggle(),p(se,y(ee,{get when(){return P.isTranscribing()||P.state()==="requesting"},get fallback(){return y(ee,{get when(){return P.isRecording()},get fallback(){return y(Ig,{class:"w-3.5 h-3.5","aria-hidden":"true"})},get children(){return y(db,{class:"w-3.5 h-3.5","aria-hidden":"true"})}})},get children(){return y(Zn,{class:"w-3.5 h-3.5 animate-spin","aria-hidden":"true"})}}),pe),p(pe,()=>P.buttonTitle()),p(D,y(ee,{get when(){return P.result()},children:re=>(()=>{var F=lO();return p(F,(()=>{var V=Ee(()=>re().length>40);return()=>V()?`${re().slice(0,40)}…`:re()})()),de(()=>me(F,"title",re())),F})()}),Se),Se.$$click=()=>void T.toggle(),p(Se,y(ee,{get when(){return T.isLoading()},get fallback(){return y(ee,{get when(){return T.isPlaying()},get fallback(){return y(Kh,{class:"w-3.5 h-3.5","aria-hidden":"true"})},get children(){return y(db,{class:"w-3.5 h-3.5","aria-hidden":"true"})}})},get children(){return y(Zn,{class:"w-3.5 h-3.5 animate-spin","aria-hidden":"true"})}}),Q),p(Q,(()=>{var re=Ee(()=>!!T.isPlaying());return()=>re()?e("settings.speech.testPlayback.stop"):Ee(()=>!!T.isLoading())()?e("settings.speech.testPlayback.generating"):e("settings.speech.testPlayback.action")})()),be.$$click=()=>void K(),p(be,(()=>{var re=Ee(()=>!!r());return()=>re()?e("settings.speech.save.saving"):e("settings.speech.save.action")})()),p(Ae,y(ee,{get when(){return Eg()},get children(){var re=iO(),F=re.firstChild,V=F.firstChild,Me=V.nextSibling,xe=F.nextSibling,Re=xe.firstChild,Be=Re.nextSibling;return p(V,()=>e("settings.speech.separateProviders.title")),p(Me,()=>e("settings.speech.separateProviders.subtitle")),Re.addEventListener("change",et=>{i("idle"),l(Ue=>({...Ue,separateProviders:et.currentTarget.checked}))}),p(Be,()=>e("settings.common.enabled")),de(()=>Re.disabled=r()),de(()=>Re.checked=c().separateProviders),re}}),Ve),p(Ae,y(ee,{get when(){return!c().separateProviders},get children(){return[y(ys,{get label(){return e("settings.speech.apiKey.title")},get caption(){return e("settings.speech.apiKey.subtitle")},get value(){return c().apiKey},onInput:re=>j("apiKey",re),type:"password",get placeholder(){return Ee(()=>!!t().speech.hasApiKey)()?e("settings.speech.apiKey.placeholder"):void 0}}),y(ee,{get when(){return Ee(()=>!!(t().speech.hasApiKey&&!d()))()&&c().apiKey.length===0},get children(){var re=aO(),F=re.firstChild;return p(re,(()=>{var V=Ee(()=>!!f());return()=>V()?e("settings.speech.apiKey.clearPending"):e("settings.speech.apiKey.storedNote")})(),F),p(re,y(ee,{get when(){return!f()},get children(){var V=Ug();return V.$$click=()=>{g(!0),i("idle")},p(V,()=>e("settings.speech.apiKey.clearAction")),V}}),null),re}}),y(ys,{get label(){return e("settings.speech.baseUrl.title")},get caption(){return e("settings.speech.baseUrl.subtitle")},get value(){return c().baseUrl},onInput:re=>j("baseUrl",re),get placeholder(){return e("settings.speech.baseUrl.placeholder")}}),y(ys,{get label(){return e("settings.speech.sttModel.title")},get caption(){return e("settings.speech.sttModel.subtitle")},get value(){return c().sttModel},onInput:re=>j("sttModel",re)}),y(ys,{get label(){return e("settings.speech.ttsModel.title")},get caption(){return e("settings.speech.ttsModel.subtitle")},get value(){return c().ttsModel},onInput:re=>j("ttsModel",re)}),y(ys,{get label(){return e("settings.speech.ttsVoice.title")},get caption(){return e("settings.speech.ttsVoice.subtitle")},get value(){return c().ttsVoice},onInput:re=>j("ttsVoice",re),get icon(){return y(Ig,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"})}})]}}),Ve),p(Ae,y(ee,{get when(){return Ee(()=>!!c().separateProviders)()&&Eg()},get children(){return[(()=>{var re=Jb(),F=re.firstChild;return p(F,()=>e("settings.speech.stt.section.title")),re})(),y(ys,{get label(){return e("settings.speech.stt.apiKey.title")},get caption(){return e("settings.speech.stt.apiKey.subtitle")},get value(){return c().stt.apiKey},onInput:re=>ne("stt","apiKey",re),type:"password",get placeholder(){return Ee(()=>!!(t().speech.stt.hasApiKey||t().speech.hasApiKey))()?e("settings.speech.stt.apiKey.placeholder"):void 0}}),y(ee,{get when(){return Ee(()=>!!((t().speech.stt.hasApiKey||t().speech.hasApiKey)&&!m()))()&&c().stt.apiKey.length===0},get children(){var re=Kg();return p(re,y(ee,{get when(){return t().speech.stt.hasApiKey},get fallback(){return e("settings.speech.stt.apiKey.usingShared")},get children(){return[Ee(()=>Ee(()=>!!S())()?e("settings.speech.stt.apiKey.clearPending"):e("settings.speech.stt.apiKey.storedNote"))," ",y(ee,{get when(){return!S()},get children(){var F=Ug();return F.$$click=()=>{b(!0),i("idle")},p(F,()=>e("settings.speech.stt.apiKey.clearAction")),F}})]}})),re}}),y(ys,{get label(){return e("settings.speech.stt.baseUrl.title")},get caption(){return e("settings.speech.stt.baseUrl.subtitle")},get value(){return c().stt.baseUrl},onInput:re=>ne("stt","baseUrl",re),get placeholder(){return e("settings.speech.stt.baseUrl.placeholder")}}),y(ys,{get label(){return e("settings.speech.stt.model.title")},get caption(){return e("settings.speech.stt.model.subtitle")},get value(){return c().stt.model},onInput:re=>ne("stt","model",re)}),(()=>{var re=Jb(),F=re.firstChild;return p(F,()=>e("settings.speech.tts.section.title")),re})(),y(ys,{get label(){return e("settings.speech.tts.apiKey.title")},get caption(){return e("settings.speech.tts.apiKey.subtitle")},get value(){return c().tts.apiKey},onInput:re=>ne("tts","apiKey",re),type:"password",get placeholder(){return Ee(()=>!!(t().speech.tts.hasApiKey||t().speech.hasApiKey))()?e("settings.speech.tts.apiKey.placeholder"):void 0}}),y(ee,{get when(){return Ee(()=>!!((t().speech.tts.hasApiKey||t().speech.hasApiKey)&&!v()))()&&c().tts.apiKey.length===0},get children(){var re=Kg();return p(re,y(ee,{get when(){return t().speech.tts.hasApiKey},get fallback(){return e("settings.speech.tts.apiKey.usingShared")},get children(){return[Ee(()=>Ee(()=>!!C())()?e("settings.speech.tts.apiKey.clearPending"):e("settings.speech.tts.apiKey.storedNote"))," ",y(ee,{get when(){return!C()},get children(){var F=Ug();return F.$$click=()=>{_(!0),i("idle")},p(F,()=>e("settings.speech.tts.apiKey.clearAction")),F}})]}})),re}}),y(ys,{get label(){return e("settings.speech.tts.baseUrl.title")},get caption(){return e("settings.speech.tts.baseUrl.subtitle")},get value(){return c().tts.baseUrl},onInput:re=>ne("tts","baseUrl",re),get placeholder(){return e("settings.speech.tts.baseUrl.placeholder")}}),y(ys,{get label(){return e("settings.speech.tts.model.title")},get caption(){return e("settings.speech.tts.model.subtitle")},get value(){return c().tts.model},onInput:re=>ne("tts","model",re)}),y(ys,{get label(){return e("settings.speech.ttsVoice.title")},get caption(){return e("settings.speech.ttsVoice.subtitle")},get value(){return c().ttsVoice},onInput:re=>j("ttsVoice",re),get icon(){return y(Ig,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"})}})]}}),Ve),p(Ae,y(e0,{get label(){return e("settings.speech.playbackMode.title")},get caption(){return e("settings.speech.playbackMode.subtitle")},get value(){return c().playbackMode},onInput:re=>j("playbackMode",re),get options(){return[{value:"streaming",label:e("settings.speech.playbackMode.streaming")},{value:"buffered",label:e("settings.speech.playbackMode.buffered")}]}}),Ve),p(Ae,y(e0,{get label(){return e("settings.speech.ttsFormat.title")},get caption(){return e("settings.speech.ttsFormat.subtitle")},get value(){return c().ttsFormat},onInput:re=>j("ttsFormat",re),options:[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"opus",label:"Opus"},{value:"aac",label:"AAC"}]}),Ve),p(Ve,()=>e("settings.speech.help")),p(Ae,y(ee,{get when(){return U()},children:re=>(()=>{var F=Kg();return p(F,re),F})()}),He),p(He,()=>e("settings.speech.testPlayback.note")),de(re=>{var F=r()&&P.state()!=="recording"||P.state()==="requesting"||P.state()==="transcribing"||P.state()==="idle"&&!P.canUseTranscription(),V=P.buttonTitle(),Me=P.buttonTitle(),xe=r(),Re=T.buttonTitle(),Be=T.buttonTitle(),et=!G()||r();return F!==re.e&&(se.disabled=re.e=F),V!==re.t&&me(se,"title",re.t=V),Me!==re.a&&me(se,"aria-label",re.a=Me),xe!==re.o&&(Se.disabled=re.o=xe),Re!==re.i&&me(Se,"title",re.i=Re),Be!==re.n&&me(Se,"aria-label",re.n=Be),et!==re.s&&(be.disabled=re.s=et),re},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),M})()},ys=e=>(()=>{var t=dO(),n=t.firstChild,s=n.firstChild,r=s.nextSibling,o=n.nextSibling,a=o.firstChild;return p(s,()=>e.label),p(r,()=>e.caption),p(o,()=>e.icon,a),a.$$input=i=>e.onInput(i.currentTarget.value),de(i=>{var c=e.type??"text",l=e.placeholder;return c!==i.e&&me(a,"type",i.e=c),l!==i.t&&me(a,"placeholder",i.t=l),i},{e:void 0,t:void 0}),de(()=>a.value=e.value),t})(),e0=e=>(()=>{var t=uO(),n=t.firstChild,s=n.firstChild,r=s.nextSibling,o=n.nextSibling,a=o.firstChild;return p(s,()=>e.label),p(r,()=>e.caption),a.$$input=i=>e.onInput(i.currentTarget.value),p(a,y(zt,{get each(){return e.options},children:i=>(()=>{var c=fO();return p(c,()=>i.label),de(()=>c.value=i.value),c})()})),de(()=>a.value=e.value),t})();Xt(["click","input"]);var pO=O("<div class=settings-section-stack><div class=settings-card><div class=settings-stack>");const yO=()=>{const e=Un(),t=Te(()=>ry(e).filter(n=>n.id==="behavior.promptVoiceInput"));return(()=>{var n=pO(),s=n.firstChild,r=s.firstChild;return p(r,y(oy,{settings:t,get preferences(){return e.preferences}})),p(n,y(mO,{}),null),n})()};function Xx(e,t){if(!e)return t;const n=e.metadata??{},s=t.metadata??{};return{...e,...t,metadata:{...n,...s},source:t.source??e.source}}function vO(e){return(e==null?void 0:e.id)??""}function ua(e){return e==null?void 0:e.sessionID}function wO(e){var t;return(t=e==null?void 0:e.source)==null?void 0:t.messageID}function bO(e){var t;return(t=e==null?void 0:e.source)==null?void 0:t.id}function e_(e){return(e==null?void 0:e.action)??"permission"}function SO(e){return(e==null?void 0:e.resources.filter(t=>typeof t=="string"))??[]}function EH(e){const t=e_(e),n=SO(e);return n.length>0?`${t}: ${n.join(", ")}`:t}function kO(e){return e==null?void 0:e.requestID}var xO=Object.defineProperty,_O=e=>e;function $O(e,t){this[e]=_O.bind(null,t)}var fy=(e,t)=>{for(var n in t)xO(e,n,{get:t[n],enumerable:!0,configurable:!0,set:$O.bind(t,n)})},t0={};fy(t0,{SharedEvents:()=>t0,make:()=>t_});function t_(e){let t;function s(o){o.connected=void 0,o.controller.abort(),t===o&&(t=void 0)}async function r(o){var c;let a,i={};try{if(o.controller.signal.aborted)return;for(a=e(o.controller.signal,()=>{o.subscribers.forEach(l=>{var d;return(d=l.activity)==null?void 0:d.call(l)})})[Symbol.asyncIterator]();!o.controller.signal.aborted;){const l=await a.next();if(l.done||o.controller.signal.aborted)break;l.value.type==="server.connected"&&(o.connected=l.value),o.subscribers.forEach(d=>d.push(l.value))}}catch(l){i={error:l}}finally{s(o);try{await((c=a==null?void 0:a.return)==null?void 0:c.call(a))}catch(l){"error"in i||(i={error:l})}o.subscribers.forEach(l=>l.finish(i))}}return{subscribe(o){return{[Symbol.asyncIterator](){const a=[],i=[];let c=!1,l,d;function u(w,S=!0){var b;l=w,S&&(i.length=0),(b=o==null?void 0:o.signal)==null||b.removeEventListener("abort",f),d!=null&&d.subscribers.delete(g)&&!d.subscribers.size&&s(d),a.splice(0).forEach(v=>{"error"in w?v.reject(w.error):v.resolve({done:!0,value:void 0})})}function f(){u({})}const g={activity:o==null?void 0:o.onActivity,finish(w){u(w,!1)},push(w){if(l)return;const S=a.shift();if(S){S.resolve({done:!1,value:w});return}if(i.length===4096){u({error:new Error("Event subscriber exceeded its 4096-event capacity")});return}i.push(w)}};function m(){if(l)return;const w=!t;d=t??{controller:new AbortController,subscribers:new Set},t=d,d.subscribers.add(g),d.connected&&g.push(d.connected),w&&r(d)}return{next(){var b,v;const w=i.shift();if(w)return Promise.resolve({done:!1,value:w});if(l)return"error"in l?Promise.reject(l.error):Promise.resolve({done:!0,value:void 0});if((b=o==null?void 0:o.signal)!=null&&b.aborted)return f(),Promise.resolve({done:!0,value:void 0});const S=Promise.withResolvers();return a.push(S),c||(c=!0,(v=o==null?void 0:o.signal)==null||v.addEventListener("abort",f,{once:!0}),m()),S.promise},return(){return u({}),Promise.resolve({done:!0,value:void 0})}}}}}}}class Ls extends Error{constructor(n,s){const r=(s==null?void 0:s.detail)??((s==null?void 0:s.cause)instanceof Error?s.cause.message:void 0);super(r?`${n}: ${r}`:n,s);ae(this,"reason");ae(this,"name","ClientError");this.reason=n}}var CO={};fy(CO,{make:()=>n_});var EO=16*1024*1024;function n_(e){const t=e.fetch??globalThis.fetch,n=(i,c)=>{const l=new URL(e.baseUrl);l.pathname.endsWith("/")||(l.pathname+="/");const d=new URL(i.path.slice(1),l);for(const[f,g]of Object.entries(i.query??{}))im(d.searchParams,f,g);const u=new Headers(e.headers);for(const[f,g]of Object.entries(i.headers??{}))g!=null&&u.set(f,String(g));for(const[f,g]of new Headers(c==null?void 0:c.headers))u.set(f,g);return i.body!==void 0&&!u.has("content-type")&&u.set("content-type",i.binaryBody?"application/octet-stream":"application/json"),{url:d,init:{method:i.method,signal:c==null?void 0:c.signal,headers:u,body:i.body===void 0?void 0:i.binaryBody?i.body:JSON.stringify(i.body)}}},s=async(i,c)=>{try{const l=n(i,c);return await t(l.url,l.init)}catch(l){throw new Ls("Transport",{cause:l})}},r=async(i,c)=>{var l;if(c.declaredStatuses.includes(i.status))throw MO(await n0(i));try{await((l=i.body)==null?void 0:l.cancel())}catch{}throw new Ls("UnexpectedStatus",{cause:{status:i.status},detail:String(i.status)})},o=async(i,c)=>{var d;const l=await s(i,c);if(l.status!==i.successStatus)return r(l,i);if(i.binary)return new Uint8Array(await l.arrayBuffer());if(i.empty){try{await((d=l.body)==null?void 0:d.cancel())}catch{}return}return await n0(l)},a=(i,c)=>({async*[Symbol.asyncIterator](){var g,m;const l=await s(i,c);if(l.status!==i.successStatus&&await r(l,i),!s_(l,"text/event-stream")){try{await((g=l.body)==null?void 0:g.cancel())}catch{}throw new Ls("UnsupportedContentType",{detail:l.headers.get("content-type")})}if(l.body===null)throw new Ls("MalformedResponse");const d=l.body.getReader(),u=new TextDecoder;let f="";try{for(;;){let w;try{w=await d.read()}catch(v){throw new Ls("Transport",{cause:v})}if(w.done||(m=c==null?void 0:c.onActivity)==null||m.call(c),f+=u.decode(w.value,{stream:!w.done}),f.length>EO)throw new Ls("SseEventTooLarge");const S=!w.done&&f.endsWith("\r");S&&(f=f.slice(0,-1)),f=f.replaceAll(`\r
|
|
4
4
|
`,`
|
|
5
5
|
`).replaceAll("\r",`
|
|
6
6
|
`),S&&(f+="\r"),w.done&&f!==""&&(f+=`
|
|
@@ -11,7 +11,7 @@ var GT=Object.defineProperty;var ZT=(e,t,n)=>t in e?GT(e,t,{enumerable:!0,config
|
|
|
11
11
|
`).flatMap(C=>C.startsWith("data:")?[C.slice(5).trimStart()]:[]).join(`
|
|
12
12
|
`);if(k!=="")try{yield JSON.parse(k)}catch(C){throw new Ls("MalformedResponse",{cause:C})}b=f.indexOf(`
|
|
13
13
|
|
|
14
|
-
`)}if(w.done)return}}finally{try{await d.cancel()}catch{}d.releaseLock()}}});return{server:{info:i=>o({method:"GET",path:"/api/info",successStatus:200,declaredStatuses:[400,401],empty:!1},i)},location:{get:(i,c)=>o({method:"GET",path:"/api/location",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),reload:i=>o({method:"POST",path:"/api/location/reload",successStatus:204,declaredStatuses:[400,401,503],empty:!0},i)},agent:{list:(i,c)=>o({method:"GET",path:"/api/agent",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/agent/${encodeURIComponent(i.agentID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c)},plugin:{list:(i,c)=>o({method:"GET",path:"/api/plugin",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),check:(i,c)=>o({method:"POST",path:"/api/plugin/check",query:{location:i==null?void 0:i.location},body:{target:i==null?void 0:i.target},successStatus:200,declaredStatuses:[400,401],empty:!1},c),update:(i,c)=>o({method:"POST",path:"/api/plugin/update",query:{location:i.location},body:{targets:i.targets},successStatus:204,declaredStatuses:[400,401,503],empty:!0},c)},session:{list:(i,c)=>o({method:"GET",path:"/api/session",query:{limit:i==null?void 0:i.limit,order:i==null?void 0:i.order,search:i==null?void 0:i.search,parentID:i==null?void 0:i.parentID,directory:i==null?void 0:i.directory,project:i==null?void 0:i.project,subpath:i==null?void 0:i.subpath,cursor:i==null?void 0:i.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},c),stats:(i,c)=>o({method:"GET",path:"/api/experimental/session/stats",query:{from:i==null?void 0:i.from,to:i==null?void 0:i.to,project:i==null?void 0:i.project,timezone:i==null?void 0:i.timezone,tools:i==null?void 0:i.tools},successStatus:200,declaredStatuses:[400,401],empty:!1},c).then(l=>l.data),create:(i,c)=>o({method:"POST",path:"/api/session",body:{id:i==null?void 0:i.id,title:i==null?void 0:i.title,agent:i==null?void 0:i.agent,model:i==null?void 0:i.model,location:i==null?void 0:i.location,metadata:i==null?void 0:i.metadata,permissions:i==null?void 0:i.permissions},successStatus:200,declaredStatuses:[400,401],empty:!1},c).then(l=>l.data),import:(i,c)=>o({method:"POST",path:"/api/experimental/session/import",body:{info:i.info,messages:i.messages,location:i.location},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),export:(i,c)=>o({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/export`,query:{sanitize:i.sanitize},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},c).then(l=>l.data),active:i=>o({method:"GET",path:"/api/session/active",successStatus:200,declaredStatuses:[400,401],empty:!1},i).then(c=>c.data),get:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),remove:(i,c)=>o({method:"DELETE",path:`/api/session/${encodeURIComponent(i.sessionID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),fork:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/fork`,body:{before:i.before},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),switchAgent:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/agent`,body:{agent:i.agent},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),switchModel:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/model`,body:{model:i.model},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),update:(i,c)=>o({method:"PATCH",path:`/api/session/${encodeURIComponent(i.sessionID)}`,body:{title:i.title,metadata:i.metadata,permissions:i.permissions},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),move:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/move`,body:{directory:i.directory,delivery:i.delivery},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),prompt:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/prompt`,body:{id:i.id,text:i.text,files:i.files,agents:i.agents,skills:i.skills,metadata:i.metadata,delivery:i.delivery,resume:i.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),command:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/command`,body:{name:i.name,text:i.text,files:i.files,agents:i.agents,skills:i.skills,delivery:i.delivery},successStatus:204,declaredStatuses:[400,401,404,500],empty:!0},c),skill:(i,c)=>o({method:"POST",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/skill`,body:{id:i.id,resume:i.resume},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),synthetic:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/synthetic`,body:{id:i.id,text:i.text,description:i.description,metadata:i.metadata,delivery:i.delivery,resume:i.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),shell:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/shell`,body:{id:i.id,command:i.command},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),compact:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/compact`,body:{id:i.id,delivery:i.delivery},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),wait:(i,c)=>o({method:"POST",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},c),revert:{stage:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/revert/stage`,body:{messageID:i.messageID,files:i.files},successStatus:200,declaredStatuses:[400,401,404,409,500],empty:!1},c).then(l=>l.data),clear:(i,c)=>o({method:"DELETE",path:`/api/session/${encodeURIComponent(i.sessionID)}/revert`,successStatus:204,declaredStatuses:[400,401,404,409,500],empty:!0},c),commit:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},c)},context:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/context`,successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},c).then(l=>l.data),diff:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/diff`,query:{from:i.from,to:i.to,context:i.context},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},c).then(l=>l.data),inbox:{list:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/inbox`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),cancel:(i,c)=>o({method:"DELETE",path:`/api/session/${encodeURIComponent(i.sessionID)}/inbox/${encodeURIComponent(i.inboxID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),update:(i,c)=>o({method:"PATCH",path:`/api/session/${encodeURIComponent(i.sessionID)}/inbox/${encodeURIComponent(i.inboxID)}`,body:{delivery:i.delivery},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},c)},instructions:{entry:{list:(i,c)=>o({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),put:(i,c)=>o({method:"PUT",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/instructions/entries/${encodeURIComponent(i.key)}`,body:{value:i.value},successStatus:204,declaredStatuses:[400,401,404,413],empty:!0},c),remove:(i,c)=>o({method:"DELETE",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/instructions/entries/${encodeURIComponent(i.key)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)}},generate:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/generate`,body:{prompt:i.prompt},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c).then(l=>l.data),log:(i,c)=>a({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/log`,query:{after:i.after,follow:i.follow},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),interrupt:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/interrupt`,query:{resume:i.resume},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),background:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/background`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),message:{get:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/message/${encodeURIComponent(i.messageID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data)},form:{list:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/form`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),create:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/form`,body:{id:i.id,title:i.title,metadata:i.metadata,fields:i.fields},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),get:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/form/${encodeURIComponent(i.formID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),reply:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/form/${encodeURIComponent(i.formID)}/reply`,body:{answer:i.answer},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},c),cancel:(i,c)=>o({method:"DELETE",path:`/api/session/${encodeURIComponent(i.sessionID)}/form/${encodeURIComponent(i.formID)}`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},c)},environment:(i,c)=>o({method:"PUT",path:`/api/session/${encodeURIComponent(i.sessionID)}/environment`,body:{variables:i.variables},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),view:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/view`,body:{idle:i.idle},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)},message:{list:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/message`,query:{limit:i.limit,order:i.order,cursor:i.cursor,type:i.type},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},c)},model:{list:(i,c)=>o({method:"GET",path:"/api/model",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c),default:(i,c)=>o({method:"GET",path:"/api/model/default",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c)},generate:{text:(i,c)=>o({method:"POST",path:"/api/experimental/generate",body:{prompt:i.prompt,model:i.model},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c).then(l=>l.data)},provider:{list:(i,c)=>o({method:"GET",path:"/api/provider",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/provider/${encodeURIComponent(i.providerID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c)},integration:{list:(i,c)=>o({method:"GET",path:"/api/integration",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/integration/${encodeURIComponent(i.integrationID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),wellknown:{add:(i,c)=>o({method:"POST",path:"/api/experimental/integration/wellknown",query:{location:i.location},body:{url:i.url},successStatus:204,declaredStatuses:[400,401],empty:!0},c)},connect:{key:(i,c)=>o({method:"POST",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/key`,query:{location:i.location},body:{key:i.key,answer:i.answer,label:i.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)},oauth:{connect:(i,c)=>o({method:"POST",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/oauth`,query:{location:i.location},body:{methodID:i.methodID,answer:i.answer,label:i.label},successStatus:200,declaredStatuses:[400,401],empty:!1},c),status:(i,c)=>o({method:"GET",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/oauth/${encodeURIComponent(i.attemptID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),complete:(i,c)=>o({method:"POST",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/oauth/${encodeURIComponent(i.attemptID)}/complete`,query:{location:i.location},body:{code:i.code},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),cancel:(i,c)=>o({method:"DELETE",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/oauth/${encodeURIComponent(i.attemptID)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401],empty:!0},c)},command:{connect:(i,c)=>o({method:"POST",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/command`,query:{location:i.location},body:{methodID:i.methodID,label:i.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),status:(i,c)=>o({method:"GET",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/command/${encodeURIComponent(i.attemptID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),cancel:(i,c)=>o({method:"DELETE",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/command/${encodeURIComponent(i.attemptID)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401],empty:!0},c)}},mcp:{list:(i,c)=>o({method:"GET",path:"/api/mcp",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),add:(i,c)=>o({method:"PUT",path:`/api/experimental/mcp/${encodeURIComponent(i.server)}`,query:{location:i.location},body:{config:i.config},successStatus:204,declaredStatuses:[400,401],empty:!0},c),remove:(i,c)=>o({method:"DELETE",path:`/api/experimental/mcp/${encodeURIComponent(i.server)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),connect:(i,c)=>o({method:"POST",path:`/api/experimental/mcp/${encodeURIComponent(i.server)}/connect`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),disconnect:(i,c)=>o({method:"POST",path:`/api/experimental/mcp/${encodeURIComponent(i.server)}/disconnect`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),resource:{catalog:(i,c)=>o({method:"GET",path:"/api/mcp/resource",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)}},credential:{update:(i,c)=>o({method:"PATCH",path:`/api/credential/${encodeURIComponent(i.credentialID)}`,body:{label:i.label},successStatus:204,declaredStatuses:[400,401],empty:!0},c),activate:(i,c)=>o({method:"POST",path:`/api/credential/${encodeURIComponent(i.credentialID)}/activate`,successStatus:204,declaredStatuses:[400,401],empty:!0},c),remove:(i,c)=>o({method:"DELETE",path:`/api/credential/${encodeURIComponent(i.credentialID)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},c)},project:{list:i=>o({method:"GET",path:"/api/project",successStatus:200,declaredStatuses:[400,401],empty:!1},i),update:(i,c)=>o({method:"PATCH",path:`/api/project/${encodeURIComponent(i.projectID)}`,body:{canonical:i.canonical,name:i.name,icon:i.icon,commands:i.commands},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c)},form:{list:(i,c)=>o({method:"GET",path:"/api/form",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},permission:{request:{list:(i,c)=>o({method:"GET",path:"/api/permission/request",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},saved:{list:(i,c)=>o({method:"GET",path:"/api/permission/saved",query:{projectID:i==null?void 0:i.projectID},successStatus:200,declaredStatuses:[400,401],empty:!1},c).then(l=>l.data),remove:(i,c)=>o({method:"DELETE",path:`/api/permission/saved/${encodeURIComponent(i.id)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},c)},create:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/permission`,body:{id:i.id,action:i.action,resources:i.resources,save:i.save,metadata:i.metadata,source:i.source,agent:i.agent},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),list:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/permission`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),get:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/permission/${encodeURIComponent(i.requestID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),reply:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/permission/${encodeURIComponent(i.requestID)}/reply`,body:{decision:i.decision,message:i.message},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)},file:{read:(i,c)=>o({method:"GET",path:`/api/fs/read/${TO(i.path)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},c),list:(i,c)=>o({method:"GET",path:"/api/fs/list",query:{location:i==null?void 0:i.location,path:i==null?void 0:i.path},successStatus:200,declaredStatuses:[400,401],empty:!1},c),find:(i,c)=>o({method:"GET",path:"/api/fs/find",query:{location:i.location,query:i.query,type:i.type,limit:i.limit},successStatus:200,declaredStatuses:[400,401],empty:!1},c),write:(i,c)=>o({method:"POST",path:"/api/experimental/fs/write",query:{location:i.location,path:i.path},body:i.payload,successStatus:200,declaredStatuses:[400,401],empty:!1,binaryBody:!0},c)},command:{list:(i,c)=>o({method:"GET",path:"/api/command",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},skill:{list:(i,c)=>o({method:"GET",path:"/api/skill",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},rpc:{call:(i,c)=>o({method:"POST",path:`/api/rpc/${encodeURIComponent(i.rpcID)}/${encodeURIComponent(i.method)}`,query:{location:i.location},body:{input:i.input},successStatus:200,declaredStatuses:[400,401,500],empty:!1},c)},event:{subscribe:i=>a({method:"GET",path:"/api/event",successStatus:200,declaredStatuses:[400,401],empty:!1},i)},pty:{list:(i,c)=>o({method:"GET",path:"/api/pty",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),create:(i,c)=>o({method:"POST",path:"/api/pty",query:{location:i==null?void 0:i.location},body:{command:i==null?void 0:i.command,args:i==null?void 0:i.args,cwd:i==null?void 0:i.cwd,title:i==null?void 0:i.title,env:i==null?void 0:i.env},successStatus:200,declaredStatuses:[400,401],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/pty/${encodeURIComponent(i.ptyID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),update:(i,c)=>o({method:"PUT",path:`/api/pty/${encodeURIComponent(i.ptyID)}`,query:{location:i.location},body:{title:i.title,size:i.size},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),remove:(i,c)=>o({method:"DELETE",path:`/api/pty/${encodeURIComponent(i.ptyID)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),connect:{token:(i,c)=>o({method:"POST",path:`/api/pty/${encodeURIComponent(i.ptyID)}/connect-token`,query:{location:i.location},headers:{"x-opencode-ticket":i["x-opencode-ticket"]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},c)}},experimental:{persistentPty:{read:(i,c)=>o({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/terminal/read`,query:{lines:i.lines},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c).then(l=>l.data),list:(i,c)=>o({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/terminal`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},c).then(l=>l.data),create:(i,c)=>o({method:"POST",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/terminal`,body:{command:i.command,args:i.args,cwd:i.cwd,title:i.title,env:i.env,size:i.size},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c).then(l=>l.data),shutdown:i=>o({method:"POST",path:"/api/experimental/persistent-pty/shutdown",successStatus:204,declaredStatuses:[400,401,503],empty:!0},i),handoff:i=>o({method:"POST",path:"/api/experimental/persistent-pty/handoff",successStatus:200,declaredStatuses:[400,401,503],empty:!1},i),get:(i,c)=>o({method:"GET",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c).then(l=>l.data),update:(i,c)=>o({method:"PUT",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}`,body:{attachmentID:i.attachmentID,size:i.size},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c).then(l=>l.data),snapshot:(i,c)=>o({method:"GET",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}/snapshot`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c).then(l=>l.data),remove:(i,c)=>o({method:"DELETE",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},c),connectToken:(i,c)=>o({method:"POST",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}/connect-token`,headers:{"x-opencode-ticket":i["x-opencode-ticket"]},successStatus:200,declaredStatuses:[400,401,403,404,503],empty:!1},c).then(l=>l.data)}},shell:{list:(i,c)=>o({method:"GET",path:"/api/shell",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),create:(i,c)=>o({method:"POST",path:"/api/shell",query:{location:i.location},body:{command:i.command,cwd:i.cwd,timeout:i.timeout,metadata:i.metadata},successStatus:200,declaredStatuses:[400,401],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/shell/${encodeURIComponent(i.id)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),output:(i,c)=>o({method:"GET",path:`/api/shell/${encodeURIComponent(i.id)}/output`,query:{location:i.location,cursor:i.cursor,limit:i.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),remove:(i,c)=>o({method:"DELETE",path:`/api/shell/${encodeURIComponent(i.id)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401],empty:!0},c)},reference:{list:(i,c)=>o({method:"GET",path:"/api/reference",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},worktree:{list:(i,c)=>o({method:"GET",path:"/api/worktree",query:{projectID:i.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),create:(i,c)=>o({method:"POST",path:"/api/worktree",body:{projectID:i.projectID,from:i.from,branch:i.branch,directory:i.directory,name:i.name},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),remove:(i,c)=>o({method:"DELETE",path:"/api/worktree",body:{projectID:i.projectID,directory:i.directory,force:i.force},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),refresh:(i,c)=>o({method:"POST",path:"/api/worktree/refresh",body:{projectID:i.projectID},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)},vcs:{get:(i,c)=>o({method:"GET",path:"/api/vcs",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),base:(i,c)=>o({method:"GET",path:"/api/vcs/base",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c),status:(i,c)=>o({method:"GET",path:"/api/vcs/status",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),branch:{list:(i,c)=>o({method:"GET",path:"/api/vcs/branch",query:{location:i==null?void 0:i.location,search:i==null?void 0:i.search,limit:i==null?void 0:i.limit},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},diff:(i,c)=>o({method:"GET",path:"/api/vcs/diff",query:{location:i.location,mode:i.mode,base:i.base,context:i.context},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c)},debug:{location:{list:i=>o({method:"GET",path:"/api/debug/location",successStatus:200,declaredStatuses:[400,401],empty:!1},i),evict:(i,c)=>o({method:"DELETE",path:"/api/debug/location",query:{location:i==null?void 0:i.location},successStatus:204,declaredStatuses:[400,401],empty:!0},c)}},migration:{v1:{status:i=>o({method:"GET",path:"/api/experimental/migration/v1",successStatus:200,declaredStatuses:[400,401],empty:!1},i)}},websearch:{providers:(i,c)=>o({method:"GET",path:"/api/websearch/provider",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c),query:(i,c)=>o({method:"POST",path:"/api/websearch",query:{location:i.location},body:{query:i.query,providerID:i.providerID},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c)},config:{get:(i,c)=>o({method:"GET",path:"/api/config",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),shells:i=>o({method:"GET",path:"/api/config/shell",successStatus:200,declaredStatuses:[400,401],empty:!1},i),update:(i,c)=>o({method:"PATCH",path:"/api/experimental/config",body:{shell:i.shell},successStatus:204,declaredStatuses:[400,401],empty:!0},c)}}}function TO(e){return e.split("/").map(encodeURIComponent).join("/")}function im(e,t,n){if(n!==void 0){if(n===null){e.append(t,"null");return}if(Array.isArray(n)){for(const s of n)im(e,t,s);return}if(typeof n=="object"){for(const[s,r]of Object.entries(n))im(e,`${t}[${s}]`,r);return}e.append(t,String(n))}}async function n0(e){var n,s;if(!s_(e,"application/json")&&!((n=e.headers.get("content-type"))!=null&&n.includes("+json"))){try{await((s=e.body)==null?void 0:s.cancel())}catch{}throw new Ls("UnsupportedContentType",{detail:e.headers.get("content-type")})}let t;try{t=await e.text()}catch(r){throw new Ls("Transport",{cause:r})}if(t==="")throw new Ls("MalformedResponse");try{return JSON.parse(t)}catch(r){throw new Ls("MalformedResponse",{cause:r})}}function MO(e){var n;const t=Object.assign(new Error(e.message??((n=e.data)==null?void 0:n.message)),e);return e._tag&&(t.name=e._tag),t}function s_(e,t){var n,s;return((s=(n=e.headers.get("content-type"))==null?void 0:n.split(";",1)[0])==null?void 0:s.trim().toLowerCase())===t}var AO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="SessionNotFoundError",DO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="SessionBusyError",PO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="FormNotFoundError",IO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="FormAlreadySettledError",RO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="PermissionNotFoundError",OO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="RpcError",LO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="RpcInternalError";function NO(e,t){return n=>{const s=(r,o)=>{if(!Object.hasOwn(n.events,r))throw new Error(`Unknown RPC event: ${n.id}.${r}`);const a=FO(n,r);return{[Symbol.asyncIterator](){const i=new AbortController,c=o!=null&&o.signal?AbortSignal.any([i.signal,o.signal]):i.signal,l=async function*(){try{for await(const d of t.subscribe({signal:c})){if(c.aborted)return;d.type===a&&(yield d)}}catch(d){if(!c.aborted)throw d}finally{i.abort()}}();return{next:()=>l.next(),return:()=>(i.abort(),l.return())}}}};return Object.assign(Object.fromEntries(Object.keys(n.methods).map(r=>[r,async(o,a)=>{try{return(await e.rpc.call({rpcID:n.id,method:r,input:o,location:a==null?void 0:a.location},{signal:a==null?void 0:a.signal,headers:a==null?void 0:a.headers})).output}catch(i){throw!OO(i)&&!LO(i)?i:i.data===void 0?{type:i.type,message:i.message}:{type:i.type,message:i.message,data:i.data}}}])),{events:{subscribe:s,on:(r,o,a)=>{const i=new AbortController,c=a!=null&&a.signal?AbortSignal.any([i.signal,a.signal]):i.signal,l=s(r,{signal:c});return(async()=>{for await(const d of l)await o(d)})().catch(d=>console.error(d)),()=>i.abort()}}})}}function FO(e,t){return`rpc.${e.id}.${t}`}var am={};fy(am,{OpenCode:()=>am,make:()=>BO});function BO(e){const t=n_(e),n=t_((s,r)=>t.event.subscribe({signal:s,onActivity:r}));return{...t,rpc:Object.assign(NO(t,n),t.rpc),event:n}}class UO{constructor(t=2){this.concurrency=t,this.active=0,this.waiting=[],this.visibleWaiting=[]}async run(t,n,s="normal"){t.throwIfAborted();const r=s==="visible"?this.visibleWaiting:this.waiting;await new Promise((o,a)=>{const i=()=>{const l=r.indexOf(c);l>=0&&r.splice(l,1),a(t.reason)},c=()=>{t.removeEventListener("abort",i),this.active+=1,o()};this.active<this.concurrency?c():(r.push(c),t.addEventListener("abort",i,{once:!0}))});try{return t.throwIfAborted(),await n()}finally{this.active-=1;const o=this.visibleWaiting.shift()??this.waiting.shift();o==null||o()}}}const gy=new UO(2);async function wf(e,t,n){if(t.throwIfAborted(),e())return n();const s=new AbortController,r=Symbol("foreground read"),o=()=>s.abort(t.reason);t.addEventListener("abort",o,{once:!0});let a=!1;const i=Uc(c=>(fk(()=>{e()&&!a&&s.abort(r)}),c));try{return await gy.run(s.signal,()=>(a=!0,i(),n()))}catch(c){if(c!==r)throw c;return t.throwIfAborted(),n()}finally{i(),t.removeEventListener("abort",o)}}class KO{constructor(){this.clients=new Map}key(t,n){return`${t}:${r_(n)}`}createClient(t,n,s=()=>!1){const r=this.key(t,n),o=this.clients.get(r);if(o)return o;const a=VO(n),i=am.make({baseUrl:a,fetch:jO(a,s)});return this.clients.set(r,i),i}destroyClientsForInstance(t){for(const n of Array.from(this.clients.keys()))(n===t||n.startsWith(`${t}:`))&&this.clients.delete(n)}}function VO(e,t=cM){const n=r_(e);return`${qO(t??"")}${n}/`}function jO(e,t=()=>!1){return(n,s)=>{const r=new URL(n instanceof Request?n.url:n),o=new URL(e,r).pathname.replace(/\/+$/,"")+"/",a=r.pathname.startsWith(o)?`/${r.pathname.slice(o.length)}`:r.pathname,i=async()=>{const l=await lM(n,{...s,credentials:(s==null?void 0:s.credentials)??"include"});if(l.status===426){const{reportOpenCodeSetupRequired:d}=await ls(async()=>{const{reportOpenCodeSetupRequired:u}=await Promise.resolve().then(()=>mA);return{reportOpenCodeSetupRequired:u}},void 0);d()}if(l.status===502){const d=await l.clone().json().catch(()=>{});if((d==null?void 0:d.error)===cP){const{tGlobal:u}=await ls(async()=>{const{tGlobal:f}=await import("./index-Dp_g4ObO.js").then(g=>g.s);return{tGlobal:f}},__vite__mapDeps([6,2,3,4,5,1,7]));throw new Error(u("envEditor.applyFailed"))}}return l},c=(s==null?void 0:s.method)??(n instanceof Request?n.method:"GET");return c==="GET"&&/^\/api\/location\/?$/.test(a)?wf(t,(s==null?void 0:s.signal)??(n instanceof Request?n.signal:new AbortController().signal),i):c==="GET"&&/^\/api\/(?:project|location|agent(?:\/[^/]+)?|provider|model(?:\/default)?|command|shell|session\/active)\/?$/.test(a)?gy.run((s==null?void 0:s.signal)??(n instanceof Request?n.signal:new AbortController().signal),i):i()}}function r_(e){return(e.startsWith("/")?e:`/${e}`).replace(/\/+/g,"/").replace(/\/+$/,"")}function qO(e){return e.replace(/\/+$/,"")}const fa=new KO;function hy(e,t,n,s=Date.now()){return t!=="idle"?null:e&&e!=="idle"?s:n??null}function zO(e){return!e||e.type==="idle"?"idle":"working"}function WO(e){return!e||e.type!=="retry"?null:{attempt:typeof e.attempt=="number"?e.attempt:1,message:typeof e.message=="string"?e.message:"",next:typeof e.next=="number"?e.next:Date.now()}}function HO(e,t,n="",s={providerId:"",modelId:""},r="idle"){return{...e,instanceId:t,parentId:e.parentID||null,agent:n,model:s,status:r,idleSince:null,generationRecovery:null,runtimeStatusKnown:!1}}function o_(e){return!e.hidden&&e.mode!=="subagent"}function GO(e,t){return e.find(n=>n.id===t)}function ZO(e,t){const n=GO(e,t);if(n)return n.id;const s=e.filter(r=>r.name===t);return s.length===1?s[0].id:t}function TH(e,t,n){if(!n)return e.filter(o_);const s=e.filter(o=>!o.hidden),r=e.find(o=>o.hidden&&o.id===t);return r&&!s.some(o=>o.id===r.id)?[...s,r]:s}async function YO(e,t,n,s){var c,l;const r=()=>{if(!s())throw new Error("Session fork was superseded by reconnect")};let o,a;const i=new Set;for(;;){r();const d=await e.message.list({sessionID:t,limit:200,...a?{cursor:a}:{order:"desc"}});r();for(const f of d.data){if(f.id===n){if(f.type==="assistant"&&!f.time.completed)throw new Error("Cannot fork after an unfinished response");const g=await e.session.fork({sessionID:t,...o?{before:o}:{}});if(r(),!o&&(((c=g.fork)==null?void 0:c.boundary.type)!=="through"||g.fork.boundary.messageID!==n))throw await e.session.remove({sessionID:g.id}),new Error("Session changed while forking; please try again");return g}o=f.id}const u=(l=d.cursor)==null?void 0:l.next;if(!u)throw new Error("Fork message no longer exists");if(i.has(u))throw new Error("Repeated message cursor");i.add(u),a=u}}var Mt;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const o={};for(const a of r)o[a]=a;return o},e.getValidEnumValues=r=>{const o=e.objectKeys(r).filter(i=>typeof r[r[i]]!="number"),a={};for(const i of o)a[i]=r[i];return e.objectValues(a)},e.objectValues=r=>e.objectKeys(r).map(function(o){return r[o]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const o=[];for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&o.push(a);return o},e.find=(r,o)=>{for(const a of r)if(o(a))return a},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,o=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}e.joinValues=s,e.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o})(Mt||(Mt={}));var s0;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(s0||(s0={}));const Je=Mt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Xr=e=>{switch(typeof e){case"undefined":return Je.undefined;case"string":return Je.string;case"number":return Number.isNaN(e)?Je.nan:Je.number;case"boolean":return Je.boolean;case"function":return Je.function;case"bigint":return Je.bigint;case"symbol":return Je.symbol;case"object":return Array.isArray(e)?Je.array:e===null?Je.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Je.promise:typeof Map<"u"&&e instanceof Map?Je.map:typeof Set<"u"&&e instanceof Set?Je.set:typeof Date<"u"&&e instanceof Date?Je.date:Je.object;default:return Je.unknown}},Pe=Mt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Nr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(o){return o.message},s={_errors:[]},r=o=>{for(const a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)s._errors.push(n(a));else{let i=s,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(n(a))):i[l]=i[l]||{_errors:[]},i=i[l],c++}}};return r(this),s}static assert(t){if(!(t instanceof Nr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Mt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},s=[];for(const r of this.issues)if(r.path.length>0){const o=r.path[0];n[o]=n[o]||[],n[o].push(t(r))}else s.push(t(r));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}Nr.create=e=>new Nr(e);const cm=(e,t)=>{let n;switch(e.code){case Pe.invalid_type:e.received===Je.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Pe.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Mt.jsonStringifyReplacer)}`;break;case Pe.unrecognized_keys:n=`Unrecognized key(s) in object: ${Mt.joinValues(e.keys,", ")}`;break;case Pe.invalid_union:n="Invalid input";break;case Pe.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Mt.joinValues(e.options)}`;break;case Pe.invalid_enum_value:n=`Invalid enum value. Expected ${Mt.joinValues(e.options)}, received '${e.received}'`;break;case Pe.invalid_arguments:n="Invalid function arguments";break;case Pe.invalid_return_type:n="Invalid function return type";break;case Pe.invalid_date:n="Invalid date";break;case Pe.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Mt.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Pe.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Pe.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Pe.custom:n="Invalid input";break;case Pe.invalid_intersection_types:n="Intersection results could not be merged";break;case Pe.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Pe.not_finite:n="Number must be finite";break;default:n=t.defaultError,Mt.assertNever(e)}return{message:n}};let JO=cm;function QO(){return JO}const XO=e=>{const{data:t,path:n,errorMaps:s,issueData:r}=e,o=[...n,...r.path||[]],a={...r,path:o};if(r.message!==void 0)return{...r,path:o,message:r.message};let i="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)i=l(a,{data:t,defaultError:i}).message;return{...r,path:o,message:i}};function ze(e,t){const n=QO(),s=XO({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===cm?void 0:cm].filter(r=>!!r)});e.common.issues.push(s)}class ds{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const s=[];for(const r of n){if(r.status==="aborted")return lt;r.status==="dirty"&&t.dirty(),s.push(r.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,n){const s=[];for(const r of n){const o=await r.key,a=await r.value;s.push({key:o,value:a})}return ds.mergeObjectSync(t,s)}static mergeObjectSync(t,n){const s={};for(const r of n){const{key:o,value:a}=r;if(o.status==="aborted"||a.status==="aborted")return lt;o.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||r.alwaysSet)&&(s[o.value]=a.value)}return{status:t.value,value:s}}}const lt=Object.freeze({status:"aborted"}),vc=e=>({status:"dirty",value:e}),Ps=e=>({status:"valid",value:e}),r0=e=>e.status==="aborted",o0=e=>e.status==="dirty",ga=e=>e.status==="valid",tu=e=>typeof Promise<"u"&&e instanceof Promise;var Xe;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Xe||(Xe={}));class wo{constructor(t,n,s,r){this._cachedPath=[],this.parent=t,this.data=n,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const i0=(e,t)=>{if(ga(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Nr(e.common.issues);return this._error=n,this._error}}};function St(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:s,description:r}=e;if(t&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:r}:{errorMap:(a,i)=>{const{message:c}=e;return a.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??s??i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:c??n??i.defaultError}},description:r}}class Tt{get description(){return this._def.description}_getType(t){return Xr(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Xr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ds,ctx:{common:t.parent.common,data:t.data,parsedType:Xr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(tu(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const s=this.safeParse(t,n);if(s.success)return s.data;throw s.error}safeParse(t,n){const s={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)},r=this._parseSync({data:t,path:s.path,parent:s});return i0(s,r)}"~validate"(t){var s,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)};if(!this["~standard"].async)try{const o=this._parseSync({data:t,path:[],parent:n});return ga(o)?{value:o.value}:{issues:n.common.issues}}catch(o){(r=(s=o==null?void 0:o.message)==null?void 0:s.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(o=>ga(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(t,n){const s=await this.safeParseAsync(t,n);if(s.success)return s.data;throw s.error}async safeParseAsync(t,n){const s={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)},r=this._parse({data:t,path:s.path,parent:s}),o=await(tu(r)?r:Promise.resolve(r));return i0(s,o)}refine(t,n){const s=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,o)=>{const a=t(r),i=()=>o.addIssue({code:Pe.custom,...s(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(i(),!1)):a?!0:(i(),!1)})}refinement(t,n){return this._refinement((s,r)=>t(s)?!0:(r.addIssue(typeof n=="function"?n(s,r):n),!1))}_refinement(t){return new oi({schema:this,typeName:gt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ar.create(this,this._def)}nullable(){return ii.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ar.create(this)}promise(){return iu.create(this,this._def)}or(t){return su.create([this,t],this._def)}and(t){return ru.create(this,t,this._def)}transform(t){return new oi({...St(this._def),schema:this,typeName:gt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new au({...St(this._def),innerType:this,defaultValue:n,typeName:gt.ZodDefault})}brand(){return new l_({typeName:gt.ZodBranded,type:this,...St(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new cu({...St(this._def),innerType:this,catchValue:n,typeName:gt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return py.create(this,t)}readonly(){return lu.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const eL=/^c[^\s-]{8,}$/i,tL=/^[0-9a-z]+$/,nL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,sL=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,rL=/^[a-z0-9_-]{21}$/i,oL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,iL=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,aL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let jg;const lL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,dL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,uL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,fL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,hL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,i_="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",mL=new RegExp(`^${i_}$`);function a_(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function pL(e){return new RegExp(`^${a_(e)}$`)}function yL(e){let t=`${i_}T${a_(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function vL(e,t){return!!((t==="v4"||!t)&&lL.test(e)||(t==="v6"||!t)&&uL.test(e))}function wL(e,t){if(!oL.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&r.alg!==t)}catch{return!1}}function bL(e,t){return!!((t==="v4"||!t)&&dL.test(e)||(t==="v6"||!t)&&fL.test(e))}class ro extends Tt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Je.string){const o=this._getOrReturnCtx(t);return ze(o,{code:Pe.invalid_type,expected:Je.string,received:o.parsedType}),lt}const s=new ds;let r;for(const o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="max")t.data.length>o.value&&(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="length"){const a=t.data.length>o.value,i=t.data.length<o.value;(a||i)&&(r=this._getOrReturnCtx(t,r),a?ze(r,{code:Pe.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):i&&ze(r,{code:Pe.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if(o.kind==="email")aL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"email",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="emoji")jg||(jg=new RegExp(cL,"u")),jg.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"emoji",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="uuid")sL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"uuid",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="nanoid")rL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"nanoid",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid")eL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"cuid",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid2")tL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"cuid2",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="ulid")nL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"ulid",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),ze(r,{validation:"url",code:Pe.invalid_string,message:o.message}),s.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"regex",code:Pe.invalid_string,message:o.message}),s.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),s.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):o.kind==="datetime"?yL(o).test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:"datetime",message:o.message}),s.dirty()):o.kind==="date"?mL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:"date",message:o.message}),s.dirty()):o.kind==="time"?pL(o).test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:"time",message:o.message}),s.dirty()):o.kind==="duration"?iL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"duration",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="ip"?vL(t.data,o.version)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"ip",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="jwt"?wL(t.data,o.alg)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"jwt",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="cidr"?bL(t.data,o.version)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"cidr",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="base64"?gL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"base64",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="base64url"?hL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"base64url",code:Pe.invalid_string,message:o.message}),s.dirty()):Mt.assertNever(o);return{status:s.value,value:t.data}}_regex(t,n,s){return this.refinement(r=>t.test(r),{validation:n,code:Pe.invalid_string,...Xe.errToObj(s)})}_addCheck(t){return new ro({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Xe.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Xe.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Xe.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Xe.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Xe.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Xe.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Xe.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Xe.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Xe.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Xe.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Xe.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Xe.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Xe.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Xe.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Xe.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Xe.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Xe.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Xe.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Xe.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Xe.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Xe.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Xe.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Xe.errToObj(n)})}nonempty(t){return this.min(1,Xe.errToObj(t))}trim(){return new ro({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ro({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ro({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ro.create=e=>new ro({checks:[],typeName:gt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...St(e)});function SL(e,t){const n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,r=n>s?n:s,o=Number.parseInt(e.toFixed(r).replace(".","")),a=Number.parseInt(t.toFixed(r).replace(".",""));return o%a/10**r}class ha extends Tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Je.number){const o=this._getOrReturnCtx(t);return ze(o,{code:Pe.invalid_type,expected:Je.number,received:o.parsedType}),lt}let s;const r=new ds;for(const o of this._def.checks)o.kind==="int"?Mt.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.invalid_type,expected:"integer",received:"float",message:o.message}),r.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="multipleOf"?SL(t.data,o.value)!==0&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.not_finite,message:o.message}),r.dirty()):Mt.assertNever(o);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Xe.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Xe.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Xe.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Xe.toString(n))}setLimit(t,n,s,r){return new ha({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:Xe.toString(r)}]})}_addCheck(t){return new ha({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Xe.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Xe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Xe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Xe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Xe.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Xe.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Xe.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Xe.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Xe.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Mt.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(t===null||s.value<t)&&(t=s.value)}return Number.isFinite(n)&&Number.isFinite(t)}}ha.create=e=>new ha({checks:[],typeName:gt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...St(e)});class Hc extends Tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Je.bigint)return this._getInvalidInput(t);let s;const r=new ds;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):Mt.assertNever(o);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ze(n,{code:Pe.invalid_type,expected:Je.bigint,received:n.parsedType}),lt}gte(t,n){return this.setLimit("min",t,!0,Xe.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Xe.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Xe.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Xe.toString(n))}setLimit(t,n,s,r){return new Hc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:Xe.toString(r)}]})}_addCheck(t){return new Hc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Xe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Xe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Xe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Xe.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Xe.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Hc.create=e=>new Hc({checks:[],typeName:gt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...St(e)});class lm extends Tt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Je.boolean){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.boolean,received:s.parsedType}),lt}return Ps(t.data)}}lm.create=e=>new lm({typeName:gt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...St(e)});class nu extends Tt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Je.date){const o=this._getOrReturnCtx(t);return ze(o,{code:Pe.invalid_type,expected:Je.date,received:o.parsedType}),lt}if(Number.isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return ze(o,{code:Pe.invalid_date}),lt}const s=new ds;let r;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),s.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),s.dirty()):Mt.assertNever(o);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new nu({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Xe.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Xe.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}nu.create=e=>new nu({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:gt.ZodDate,...St(e)});class a0 extends Tt{_parse(t){if(this._getType(t)!==Je.symbol){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.symbol,received:s.parsedType}),lt}return Ps(t.data)}}a0.create=e=>new a0({typeName:gt.ZodSymbol,...St(e)});class dm extends Tt{_parse(t){if(this._getType(t)!==Je.undefined){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.undefined,received:s.parsedType}),lt}return Ps(t.data)}}dm.create=e=>new dm({typeName:gt.ZodUndefined,...St(e)});class um extends Tt{_parse(t){if(this._getType(t)!==Je.null){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.null,received:s.parsedType}),lt}return Ps(t.data)}}um.create=e=>new um({typeName:gt.ZodNull,...St(e)});class c0 extends Tt{constructor(){super(...arguments),this._any=!0}_parse(t){return Ps(t.data)}}c0.create=e=>new c0({typeName:gt.ZodAny,...St(e)});class l0 extends Tt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ps(t.data)}}l0.create=e=>new l0({typeName:gt.ZodUnknown,...St(e)});class bo extends Tt{_parse(t){const n=this._getOrReturnCtx(t);return ze(n,{code:Pe.invalid_type,expected:Je.never,received:n.parsedType}),lt}}bo.create=e=>new bo({typeName:gt.ZodNever,...St(e)});class d0 extends Tt{_parse(t){if(this._getType(t)!==Je.undefined){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.void,received:s.parsedType}),lt}return Ps(t.data)}}d0.create=e=>new d0({typeName:gt.ZodVoid,...St(e)});class ar extends Tt{_parse(t){const{ctx:n,status:s}=this._processInputParams(t),r=this._def;if(n.parsedType!==Je.array)return ze(n,{code:Pe.invalid_type,expected:Je.array,received:n.parsedType}),lt;if(r.exactLength!==null){const a=n.data.length>r.exactLength.value,i=n.data.length<r.exactLength.value;(a||i)&&(ze(n,{code:a?Pe.too_big:Pe.too_small,minimum:i?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(ze(n,{code:Pe.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(ze(n,{code:Pe.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((a,i)=>r.type._parseAsync(new wo(n,a,n.path,i)))).then(a=>ds.mergeArray(s,a));const o=[...n.data].map((a,i)=>r.type._parseSync(new wo(n,a,n.path,i)));return ds.mergeArray(s,o)}get element(){return this._def.type}min(t,n){return new ar({...this._def,minLength:{value:t,message:Xe.toString(n)}})}max(t,n){return new ar({...this._def,maxLength:{value:t,message:Xe.toString(n)}})}length(t,n){return new ar({...this._def,exactLength:{value:t,message:Xe.toString(n)}})}nonempty(t){return this.min(1,t)}}ar.create=(e,t)=>new ar({type:e,minLength:null,maxLength:null,exactLength:null,typeName:gt.ZodArray,...St(t)});function Fi(e){if(e instanceof ln){const t={};for(const n in e.shape){const s=e.shape[n];t[n]=Ar.create(Fi(s))}return new ln({...e._def,shape:()=>t})}else return e instanceof ar?new ar({...e._def,type:Fi(e.element)}):e instanceof Ar?Ar.create(Fi(e.unwrap())):e instanceof ii?ii.create(Fi(e.unwrap())):e instanceof si?si.create(e.items.map(t=>Fi(t))):e}class ln extends Tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Mt.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Je.object){const l=this._getOrReturnCtx(t);return ze(l,{code:Pe.invalid_type,expected:Je.object,received:l.parsedType}),lt}const{status:s,ctx:r}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof bo&&this._def.unknownKeys==="strip"))for(const l in r.data)a.includes(l)||i.push(l);const c=[];for(const l of a){const d=o[l],u=r.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new wo(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof bo){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of i)c.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(l==="strict")i.length>0&&(ze(r,{code:Pe.unrecognized_keys,keys:i}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of i){const u=r.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new wo(r,u,r.path,d)),alwaysSet:d in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of c){const u=await d.key,f=await d.value;l.push({key:u,value:f,alwaysSet:d.alwaysSet})}return l}).then(l=>ds.mergeObjectSync(s,l)):ds.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(t){return Xe.errToObj,new ln({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,s)=>{var o,a;const r=((a=(o=this._def).errorMap)==null?void 0:a.call(o,n,s).message)??s.defaultError;return n.code==="unrecognized_keys"?{message:Xe.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new ln({...this._def,unknownKeys:"strip"})}passthrough(){return new ln({...this._def,unknownKeys:"passthrough"})}extend(t){return new ln({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new ln({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:gt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new ln({...this._def,catchall:t})}pick(t){const n={};for(const s of Mt.objectKeys(t))t[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new ln({...this._def,shape:()=>n})}omit(t){const n={};for(const s of Mt.objectKeys(this.shape))t[s]||(n[s]=this.shape[s]);return new ln({...this._def,shape:()=>n})}deepPartial(){return Fi(this)}partial(t){const n={};for(const s of Mt.objectKeys(this.shape)){const r=this.shape[s];t&&!t[s]?n[s]=r:n[s]=r.optional()}return new ln({...this._def,shape:()=>n})}required(t){const n={};for(const s of Mt.objectKeys(this.shape))if(t&&!t[s])n[s]=this.shape[s];else{let o=this.shape[s];for(;o instanceof Ar;)o=o._def.innerType;n[s]=o}return new ln({...this._def,shape:()=>n})}keyof(){return c_(Mt.objectKeys(this.shape))}}ln.create=(e,t)=>new ln({shape:()=>e,unknownKeys:"strip",catchall:bo.create(),typeName:gt.ZodObject,...St(t)});ln.strictCreate=(e,t)=>new ln({shape:()=>e,unknownKeys:"strict",catchall:bo.create(),typeName:gt.ZodObject,...St(t)});ln.lazycreate=(e,t)=>new ln({shape:e,unknownKeys:"strip",catchall:bo.create(),typeName:gt.ZodObject,...St(t)});class su extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t),s=this._def.options;function r(o){for(const i of o)if(i.result.status==="valid")return i.result;for(const i of o)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(i=>new Nr(i.ctx.common.issues));return ze(n,{code:Pe.invalid_union,unionErrors:a}),lt}if(n.common.async)return Promise.all(s.map(async o=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(r);{let o;const a=[];for(const c of s){const l={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(c=>new Nr(c));return ze(n,{code:Pe.invalid_union,unionErrors:i}),lt}}get options(){return this._def.options}}su.create=(e,t)=>new su({options:e,typeName:gt.ZodUnion,...St(t)});const br=e=>e instanceof gm?br(e.schema):e instanceof oi?br(e.innerType()):e instanceof ou?[e.value]:e instanceof ri?e.options:e instanceof hm?Mt.objectValues(e.enum):e instanceof au?br(e._def.innerType):e instanceof dm?[void 0]:e instanceof um?[null]:e instanceof Ar?[void 0,...br(e.unwrap())]:e instanceof ii?[null,...br(e.unwrap())]:e instanceof l_||e instanceof lu?br(e.unwrap()):e instanceof cu?br(e._def.innerType):[];class my extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.object)return ze(n,{code:Pe.invalid_type,expected:Je.object,received:n.parsedType}),lt;const s=this.discriminator,r=n.data[s],o=this.optionsMap.get(r);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(ze(n,{code:Pe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),lt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,s){const r=new Map;for(const o of n){const a=br(o.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const i of a){if(r.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);r.set(i,o)}}return new my({typeName:gt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:r,...St(s)})}}function fm(e,t){const n=Xr(e),s=Xr(t);if(e===t)return{valid:!0,data:e};if(n===Je.object&&s===Je.object){const r=Mt.objectKeys(t),o=Mt.objectKeys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of o){const c=fm(e[i],t[i]);if(!c.valid)return{valid:!1};a[i]=c.data}return{valid:!0,data:a}}else if(n===Je.array&&s===Je.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let o=0;o<e.length;o++){const a=e[o],i=t[o],c=fm(a,i);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===Je.date&&s===Je.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class ru extends Tt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t),r=(o,a)=>{if(r0(o)||r0(a))return lt;const i=fm(o.value,a.value);return i.valid?((o0(o)||o0(a))&&n.dirty(),{status:n.value,value:i.data}):(ze(s,{code:Pe.invalid_intersection_types}),lt)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([o,a])=>r(o,a)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ru.create=(e,t,n)=>new ru({left:e,right:t,typeName:gt.ZodIntersection,...St(n)});class si extends Tt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.array)return ze(s,{code:Pe.invalid_type,expected:Je.array,received:s.parsedType}),lt;if(s.data.length<this._def.items.length)return ze(s,{code:Pe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),lt;!this._def.rest&&s.data.length>this._def.items.length&&(ze(s,{code:Pe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...s.data].map((a,i)=>{const c=this._def.items[i]||this._def.rest;return c?c._parse(new wo(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(o).then(a=>ds.mergeArray(n,a)):ds.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new si({...this._def,rest:t})}}si.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new si({items:e,typeName:gt.ZodTuple,rest:null,...St(t)})};class u0 extends Tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.map)return ze(s,{code:Pe.invalid_type,expected:Je.map,received:s.parsedType}),lt;const r=this._def.keyType,o=this._def.valueType,a=[...s.data.entries()].map(([i,c],l)=>({key:r._parse(new wo(s,i,s.path,[l,"key"])),value:o._parse(new wo(s,c,s.path,[l,"value"]))}));if(s.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return lt;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),i.set(l.value,d.value)}return{status:n.value,value:i}})}else{const i=new Map;for(const c of a){const l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return lt;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),i.set(l.value,d.value)}return{status:n.value,value:i}}}}u0.create=(e,t,n)=>new u0({valueType:t,keyType:e,typeName:gt.ZodMap,...St(n)});class Gc extends Tt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.set)return ze(s,{code:Pe.invalid_type,expected:Je.set,received:s.parsedType}),lt;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(ze(s,{code:Pe.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(ze(s,{code:Pe.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const o=this._def.valueType;function a(c){const l=new Set;for(const d of c){if(d.status==="aborted")return lt;d.status==="dirty"&&n.dirty(),l.add(d.value)}return{status:n.value,value:l}}const i=[...s.data.values()].map((c,l)=>o._parse(new wo(s,c,s.path,l)));return s.common.async?Promise.all(i).then(c=>a(c)):a(i)}min(t,n){return new Gc({...this._def,minSize:{value:t,message:Xe.toString(n)}})}max(t,n){return new Gc({...this._def,maxSize:{value:t,message:Xe.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Gc.create=(e,t)=>new Gc({valueType:e,minSize:null,maxSize:null,typeName:gt.ZodSet,...St(t)});class gm extends Tt{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}gm.create=(e,t)=>new gm({getter:e,typeName:gt.ZodLazy,...St(t)});class ou extends Tt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ze(n,{received:n.data,code:Pe.invalid_literal,expected:this._def.value}),lt}return{status:"valid",value:t.data}}get value(){return this._def.value}}ou.create=(e,t)=>new ou({value:e,typeName:gt.ZodLiteral,...St(t)});function c_(e,t){return new ri({values:e,typeName:gt.ZodEnum,...St(t)})}class ri extends Tt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),s=this._def.values;return ze(n,{expected:Mt.joinValues(s),received:n.parsedType,code:Pe.invalid_type}),lt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),s=this._def.values;return ze(n,{received:n.data,code:Pe.invalid_enum_value,options:s}),lt}return Ps(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return ri.create(t,{...this._def,...n})}exclude(t,n=this._def){return ri.create(this.options.filter(s=>!t.includes(s)),{...this._def,...n})}}ri.create=c_;class hm extends Tt{_parse(t){const n=Mt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==Je.string&&s.parsedType!==Je.number){const r=Mt.objectValues(n);return ze(s,{expected:Mt.joinValues(r),received:s.parsedType,code:Pe.invalid_type}),lt}if(this._cache||(this._cache=new Set(Mt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=Mt.objectValues(n);return ze(s,{received:s.data,code:Pe.invalid_enum_value,options:r}),lt}return Ps(t.data)}get enum(){return this._def.values}}hm.create=(e,t)=>new hm({values:e,typeName:gt.ZodNativeEnum,...St(t)});class iu extends Tt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.promise&&n.common.async===!1)return ze(n,{code:Pe.invalid_type,expected:Je.promise,received:n.parsedType}),lt;const s=n.parsedType===Je.promise?n.data:Promise.resolve(n.data);return Ps(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}iu.create=(e,t)=>new iu({type:e,typeName:gt.ZodPromise,...St(t)});class oi extends Tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:s}=this._processInputParams(t),r=this._def.effect||null,o={addIssue:a=>{ze(s,a),a.fatal?n.abort():n.dirty()},get path(){return s.path}};if(o.addIssue=o.addIssue.bind(o),r.type==="preprocess"){const a=r.transform(s.data,o);if(s.common.async)return Promise.resolve(a).then(async i=>{if(n.value==="aborted")return lt;const c=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return c.status==="aborted"?lt:c.status==="dirty"||n.value==="dirty"?vc(c.value):c});{if(n.value==="aborted")return lt;const i=this._def.schema._parseSync({data:a,path:s.path,parent:s});return i.status==="aborted"?lt:i.status==="dirty"||n.value==="dirty"?vc(i.value):i}}if(r.type==="refinement"){const a=i=>{const c=r.refinement(i,o);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?lt:(i.status==="dirty"&&n.dirty(),a(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>i.status==="aborted"?lt:(i.status==="dirty"&&n.dirty(),a(i.value).then(()=>({status:n.value,value:i.value}))))}if(r.type==="transform")if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ga(a))return lt;const i=r.transform(a.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>ga(a)?Promise.resolve(r.transform(a.value,o)).then(i=>({status:n.value,value:i})):lt);Mt.assertNever(r)}}oi.create=(e,t,n)=>new oi({schema:e,typeName:gt.ZodEffects,effect:t,...St(n)});oi.createWithPreprocess=(e,t,n)=>new oi({schema:t,effect:{type:"preprocess",transform:e},typeName:gt.ZodEffects,...St(n)});class Ar extends Tt{_parse(t){return this._getType(t)===Je.undefined?Ps(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ar.create=(e,t)=>new Ar({innerType:e,typeName:gt.ZodOptional,...St(t)});class ii extends Tt{_parse(t){return this._getType(t)===Je.null?Ps(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ii.create=(e,t)=>new ii({innerType:e,typeName:gt.ZodNullable,...St(t)});class au extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t);let s=n.data;return n.parsedType===Je.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}au.create=(e,t)=>new au({innerType:e,typeName:gt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...St(t)});class cu extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t),s={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return tu(r)?r.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Nr(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Nr(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}cu.create=(e,t)=>new cu({innerType:e,typeName:gt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...St(t)});class f0 extends Tt{_parse(t){if(this._getType(t)!==Je.nan){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.nan,received:s.parsedType}),lt}return{status:"valid",value:t.data}}}f0.create=e=>new f0({typeName:gt.ZodNaN,...St(e)});class l_ extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class py extends Tt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?lt:o.status==="dirty"?(n.dirty(),vc(o.value)):this._def.out._parseAsync({data:o.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?lt:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(t,n){return new py({in:t,out:n,typeName:gt.ZodPipeline})}}class lu extends Tt{_parse(t){const n=this._def.innerType._parse(t),s=r=>(ga(r)&&(r.value=Object.freeze(r.value)),r);return tu(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}lu.create=(e,t)=>new lu({innerType:e,typeName:gt.ZodReadonly,...St(t)});var gt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(gt||(gt={}));const qs=ro.create,Yn=ha.create,yy=lm.create;bo.create;const So=ar.create,Qt=ln.create,xl=su.create,kL=my.create;ru.create;si.create;const os=ou.create,vy=ri.create;iu.create;Ar.create;ii.create;const xL="codenomad.session-pruning",_L=`rpc.${xL}.pruned`,mm=qs().min(1).max(256),wy=Qt({sessionID:mm,messageID:mm}).strict();wy.extend({revision:qs().regex(/^[a-f0-9]{64}$/)}).strict();wy.extend({revision:qs().regex(/^[a-f0-9]{64}$/),indexes:So(Yn().int().min(0).max(1e5)).min(1).max(100001).refine(e=>new Set(e).size===e.length)}).strict();const _l=Qt({status:os("blocked"),reason:vy(["unavailable","maintenance_required","conflict","not_deletable","unsupported_storage"])}).strict();xl([Qt({status:os("pruned"),messageID:mm,revision:qs().regex(/^[a-f0-9]{64}$/),removedCount:Yn().int().positive()}).strict(),_l]);xl([Qt({status:os("preview"),revision:qs().regex(/^[a-f0-9]{64}$/),liveMutation:yy(),parts:So(Qt({index:Yn().int().nonnegative(),type:vy(["tool","reasoning"]),bytes:Yn().int().nonnegative()}))}).strict(),_l]);const $L=wy.extend({revision:qs().regex(/^[a-f0-9]{64}$/)}).strict(),cr=qs().min(1).max(256),Ac=kL("kind",[Qt({kind:os("latest")}).strict(),Qt({kind:os("oldest")}).strict(),Qt({kind:os("around"),messageID:cr}).strict(),Qt({kind:os("before"),messageID:cr}).strict(),Qt({kind:os("after"),messageID:cr}).strict()]);Qt({sessionID:cr,target:Ac}).strict();const d_=Qt({after:Yn().int().nonnegative(),through:Yn().int().nonnegative()}).strict(),u_=Qt({after:Yn().int().min(-1),through:Yn().int().nonnegative(),digest:qs().regex(/^[a-f0-9]{64}$/)}).strict();Qt({sessionID:cr,cursor:d_.optional(),after:Yn().int().min(-1).optional(),known:So(u_).max(512).optional()}).strict();const f_=vy(["user","assistant","system","synthetic","skill","shell","compaction","idle","agent-switched","model-switched","location-switched"]),CL=Qt({id:cr,seq:Yn().int().nonnegative(),type:f_,tools:Yn().int().nonnegative(),reasoning:Yn().int().nonnegative(),toolName:qs().max(256).optional()}).strict();xl([_l,Qt({status:os("outline"),entries:So(CL).max(16384),total:Yn().int().nonnegative(),cursor:d_.nullable(),checkpoints:So(u_.extend({changed:yy()})).max(512)}).strict()]);Qt({sessionID:cr,messageIDs:So(cr).min(1).max(12)}).strict();xl([_l,Qt({status:os("previews"),entries:So(Qt({id:cr,text:qs().max(4096),tools:qs().max(4096)}).strict()).max(12)}).strict()]);xl([_l,Qt({status:os("blocked"),reason:os("anchor_missing")}).strict(),Qt({status:os("window"),messages:So(Qt({id:cr,type:f_,time:Qt({created:Yn()}).passthrough()}).passthrough()).max(200),older:Ac.nullable(),newer:Ac.nullable(),resume:Ac,latest:yy()}).strict()]);const pm="codenomad:history-window:1:";class g_ extends Error{constructor(){super($e("session.pruning.conflict"))}}const Ad=e=>pm+encodeURIComponent(JSON.stringify(e));function EL(e){if(e!=null&&e.startsWith(pm))return Ac.parse(JSON.parse(decodeURIComponent(e.slice(pm.length))))}async function TL(e,t,n,s){const r=await kt.fetchHistoryWindow(e,t,n,s);if(s==null||s.throwIfAborted(),r.status!=="window")throw r.reason==="anchor_missing"?new g_:new Error($e(`session.pruning.${r.reason}`));return{response:{data:r.messages,cursor:{}},window:{kind:r.latest?"latest":"history",resumeCursor:Ad(r.resume),olderCursor:r.older?Ad(r.older):void 0,newerCursors:[r.newer?Ad(r.newer):null]}}}const h_=200;function zs(e){const t=e==null?void 0:e.trim();if(!t)return"";const s=t.replace(/\\/g,"/").replace(/\/+$/,"")||"/",r=s.match(/^\/\/(wsl(?:\.localhost|\$)?)[/]([^/]+)(.*)$/i);return r?`//${r[1].toLowerCase()}/${r[2].toLowerCase()}${r[3]}`:/^[A-Za-z]:\//.test(s)||s.startsWith("//")||t.includes("\\")?s.toLowerCase():s}function ML(e){return e.cursor?{cursor:e.cursor}:{...e.directory?{directory:e.directory}:{},...e.search?{search:e.search}:{},...e.project?{project:e.project}:{},...e.subpath?{subpath:e.subpath}:{},...e.parentID!==void 0?{parentID:e.parentID}:{},...e.order?{order:e.order}:{},limit:h_}}const ma=Ut("api"),[du,g0]=R(new Map),[ym,h0]=R(new Map),Vi=new Map,rd=new Set,od=new Map,id=new Map,[AL,m0]=R(new Map),vm=new Map;async function m_(e,t){const n=Vi.get(e);if(n)return t||rd.add(e),n;const s=async o=>{try{const a=await wf(()=>Ds()===e,new AbortController().signal,()=>kt.fetchWorktrees(e));a.defaultDirectory?vm.set(e,a.defaultDirectory):vm.delete(e),g0(i=>{const c=new Map(i);return c.set(e,a.worktrees??[]),c}),h0(i=>{const c=new Map(i);return c.set(e,typeof a.isGitRepo=="boolean"?a.isGitRepo:null),c})}catch(a){if(ma.warn(o?"Failed to load worktrees":"Failed to reload worktrees",{instanceId:e,error:a}),!o)throw a;g0(i=>{const c=new Map(i);return c.set(e,[]),c}),h0(i=>{if(i.has(e))return i;const c=new Map(i);return c.set(e,null),c})}},r=Promise.resolve().then(async()=>{let o=t;do{rd.delete(e);try{await s(o)}catch(a){if(!rd.has(e))throw a}o=!1}while(rd.has(e))});Vi.set(e,r),await r.finally(()=>{Vi.get(e)===r&&Vi.delete(e)})}async function Xi(e){if(!e||du().has(e)&&ym().has(e))return;const t=Vi.get(e);t&&(await t,du().has(e)&&ym().has(e))||await m_(e,!0)}async function wi(e){e&&await m_(e,!1)}xs.on("workspace.worktreesChanged",e=>{if(e.type!=="workspace.worktreesChanged")return;const t=e.workspaceId;!du().has(t)&&!Vi.has(t)||wi(t).catch(n=>ma.warn("Failed to receive refreshed worktrees",{instanceId:t,error:n}))});async function DL(e,t,n=wi){var o;if(!e)return;ma.info("OpenCode worktree ready",{instanceId:e,directory:t.directory,name:(o=t.properties)==null?void 0:o.name});const s=od.get(e),r=((s==null?void 0:s.catch(()=>{}))??Promise.resolve()).then(async()=>{await n(e)});od.set(e,r),await r.finally(()=>{od.get(e)===r&&od.delete(e)})}function qg(e){return ym().get(e)??null}function Zo(e){return ko(e).find(t=>t.slug==="root"&&t.directoryOnly)}async function MH(e,t,n="root"){if(!e)throw new Error("Missing instanceId");const s=(t??"").trim();if(!s)throw new Error("Worktree name is required");return kt.createWorktree(e,{slug:s,fromSlug:n})}async function AH(e,t,n,s=r=>ls(async()=>{const{fetchSessions:o}=await Promise.resolve().then(()=>OC);return{fetchSessions:o}},void 0).then(({fetchSessions:o})=>o(r,{reset:!0,strictStatus:!0}))){if(!e)throw new Error("Missing instanceId");const r=(t??"").trim();if(!r||r==="root")throw new Error("Invalid worktree");let o;try{await kt.deleteWorktree(e,r,n)}catch(l){o=l}const a=[()=>wi(e),()=>s(e)],c=(await Promise.allSettled(a.map(l=>l()))).flatMap((l,d)=>l.status==="rejected"?[d]:[]);if(c.length){const l=await Promise.allSettled(c.map(d=>a[d]()));for(const d of l)d.status==="rejected"&&ma.warn("Failed to refresh after worktree deletion",{instanceId:e,slug:r,error:d.reason})}if(o)throw o}function ko(e){return du().get(e)??[]}function by(e,t){return(t??"").trim()||"root"}function DH(e){return by(e,"root")}function p_(e,t){var n;return((n=Ia(e,t))==null?void 0:n.id)??t}function uu(e){return zs(e)}function PL(e,t){var r,o,a;const n=(o=(r=Ne().get(e))==null?void 0:r.get(t))==null?void 0:o.location.directory,s=n&&((a=ko(e).find(i=>uu(i.serviceDirectory??i.directory)===uu(n)))==null?void 0:a.slug);return s?by(e,s):"root"}function PH(e,t){return PL(e,t)}function p0(e){return vm.get(e)}function IH(e,t){return AL().get(`${e}:${p_(e,t)}`)}async function RH(e,t,n,s={}){var m,w;await Xi(e);const r=p_(e,t),o=by(e,n),a=ko(e).find(S=>S.slug===o);if(!a)throw new Error(`Worktree not found: ${o}`);const i=(w=(m=Ne().get(e))==null?void 0:m.get(r))==null?void 0:w.location.directory,c=a.serviceDirectory??a.directory;if(i&&uu(i)===uu(c))return;const l=`${e}:${r}`,d=id.get(l),u=s.moveFamily??((S,b,v)=>kt.moveSessionFamily(S,b,{worktreeSlug:v})),f=s.refreshSessions??(S=>ls(async()=>{const{fetchSessions:b}=await Promise.resolve().then(()=>OC);return{fetchSessions:b}},void 0).then(({fetchSessions:b})=>b(S,{reset:!0,strictStatus:!0}))),g=((d==null?void 0:d.catch(()=>{}))??Promise.resolve()).then(async()=>{let S;try{await u(e,r,o)}catch(b){S=b}try{await f(e)}catch{await f(e).catch(b=>{ma.warn("Failed to refresh sessions after family move",{instanceId:e,rootSessionId:r,error:b})})}if(S)throw ma.warn("Failed to move session family",{instanceId:e,rootSessionId:r,error:S}),Hn({message:$e("sessionList.worktreeMove.error"),variant:"error"}),S});id.set(l,g),m0(S=>new Map(S).set(l,o)),await g.finally(()=>{id.get(l)===g&&(id.delete(l),m0(S=>{const b=new Map(S);return b.delete(l),b}))})}function y0(e,t,n){const s=new Set([t,...n.flatMap(i=>[i.directory,i.serviceDirectory??i.directory])].map(zs).filter(Boolean)),r=new Map(e.map(i=>[i.id,i])),o=i=>{const c=new Set;for(;i.parentID&&r.has(i.parentID)&&!c.has(i.id);)c.add(i.id),i=r.get(i.parentID);return i.id},a=new Set(e.filter(i=>s.has(zs(i.location.directory))).map(o));return e.filter(i=>a.has(o(i)))}const[Sy,y_]=R(new Map),ky=(e,t)=>`${e}:${t}`;function $l(e,t,n){const s=ky(e,t);y_(r=>{const o=new Map(r);return n?o.set(s,n):o.delete(s),o})}function xy(e,t){var n;return((n=Sy().get(ky(e,t)))==null?void 0:n.values)??[]}function v_(e){const t=`${e}:`;return[...Sy()].filter(([n])=>n.startsWith(t)).map(([n,s])=>[n.slice(t.length),s])}function OH(e){return e?Object.fromEntries(v_(e).filter(([,t])=>t.values.length>0).map(([t,n])=>[t,[...n.values]])):{}}function LH(e){return e?new Set(v_(e).filter(([,t])=>t.authoritative).map(([t])=>t)):new Set}function NH(e,t,n){$l(e,t,{values:[...xy(e,t),n],authoritative:!0})}function FH(e,t,n){$l(e,t,{values:xy(e,t).filter(s=>s.id!==n),authoritative:!0})}function BH(e,t){$l(e,t,{values:[],authoritative:!0})}function IL(e,t){$l(e,t)}function UH(e,t,n){var s;$l(e,t,{values:[...n],authoritative:((s=Sy().get(ky(e,t)))==null?void 0:s.authoritative)??!1})}function RL(e,t=!1){if(!e)return;const n=`${e}:`;y_(s=>{const r=new Map(s);for(const[o,a]of r)o.startsWith(n)&&(t&&a.authoritative?r.set(o,{...a,values:[]}):r.delete(o));return r})}function OL(e){return`/workspaces/${encodeURIComponent(e)}/instance`}function $t(e){return fa.createClient(e,OL(e),()=>Ds()===e)}function LL(e){return e?{directory:e}:{}}function Io(e){return e.directory?{directory:e.directory}:{}}function bf(e){if(!(!("workspaceID"in e)||e.workspaceID===void 0)){if(typeof e.workspaceID!="string"||!e.workspaceID.trim())throw new Error("Invalid native location identity");return e.workspaceID}}function Bs(e){return JSON.stringify([e.directory,bf(e)])}function Zt(e,t){var s;if(!e)return;const n=bf(e);if(!(n===void 0&&!(t!=null&&t.includeDirectory))){if(!((s=e.directory)!=null&&s.trim()))throw new Error("Missing native location directory");return{headers:{"x-codenomad-location":encodeURIComponent(JSON.stringify({directory:e.directory,workspaceID:n}))}}}}function NL(e,t){var r;const n=[LL(e)],s=new Set(n.map(Bs));for(const o of t){const a=(r=o.directory)==null?void 0:r.trim();if(!a)continue;const i={directory:a,...o.workspaceID===void 0?{}:{workspaceID:o.workspaceID}},c=Bs(i);s.has(c)||(s.add(c),n.push(i))}return n}const Dc=32e3;function Nn(e){var r,o;const t=Fe().get(e),n=es().get(e);return(n&&n!=="info"?(o=(r=Ne().get(e))==null?void 0:r.get(n))==null?void 0:o.location:void 0)??{directory:(t==null?void 0:t.folder)??""}}function pa(e,t){if(!(t!=null&&t.providerId)||!t.modelId)return!1;const s=(Ti().get(e)||[]).find(r=>r.id===t.providerId);return s?s.models.some(r=>r.id===t.modelId):!1}function FL(e){const t=uM().models.recents??[];for(const n of t)if(pa(e,n))return n}async function Sf(e,t){const n=Ti().get(e)||[],s=Rv().get(e)||[],r=t?ZO(s,t):"";if(r){const a=s.find(c=>c.id===r);if(a&&a.model&&pa(e,a.model))return{providerId:a.model.providerId,modelId:a.model.modelId};const i=await dM(e,r);if(pa(e,i))return i}const o=FL(e);if(o)return o;for(const a of n)if(a.defaultModelId){const i=a.models.find(c=>c.id===a.defaultModelId);if(i)return{providerId:a.id,modelId:i.id}}if(n.length>0){const a=n[0],i=a.models[0];if(i)return{providerId:a.id,modelId:i.id}}if(!n.some(a=>a.models.length>0)){const a=Fe().get(e);if(a!=null&&a.client){const i=await $t(e).model.default({location:Io(Nn(e))},Zt(Nn(e))).catch(()=>null);if(i!=null&&i.data)return{providerId:i.data.providerID,modelId:i.data.id}}}return{providerId:"",modelId:""}}const BL={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",sh:"bash",bash:"bash",json:"json",html:"html",css:"css",md:"markdown",yaml:"yaml",yml:"yaml",sql:"sql",rs:"rust",go:"go",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",h:"cpp",c:"c",java:"java",cs:"csharp",php:"php",rb:"ruby",swift:"swift",kt:"kotlin"};function KH(e){var n;if(!e)return;const t=(n=e.split(".").pop())==null?void 0:n.toLowerCase();return t?BL[t]:void 0}function ea(e){if(!e.includes("&"))return e;const t=/&(#x?[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]+);/g,n={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};let s=e,r="";for(;s.includes("&")&&s!==r;)r=s,s=s.replace(t,(o,a)=>{var c;if(!a)return o;if(a[0]==="#"){const d=((c=a[1])==null?void 0:c.toLowerCase())==="x"?parseInt(a.slice(2),16):parseInt(a.slice(1),10);if(!Number.isNaN(d))try{return String.fromCodePoint(d)}catch{return o}return o}const i=n[a.toLowerCase()];return i!==void 0?i:o});return s}function VH(e){const t={"&":"&","<":"<",'"':""","'":"'"};return e.replace(/[&<"']/g,n=>t[n])}function UL(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="file"&&typeof t.mime=="string"&&/^image\//i.test(t.mime)&&typeof t.uri=="string"}function jH(e){if(/^data:/i.test(e.uri))return e.uri.slice(0,e.uri.indexOf(",")+1).toLowerCase()===`data:${e.mime.toLowerCase()};base64,`?e.uri:void 0;try{const t=new URL(e.uri);if((t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password)return e.uri}catch{}}function Dd(e){if(typeof e=="string")return ea(e);if(e&&typeof e=="object"){const t={...e};return typeof t.text=="string"&&(t.text=ea(t.text)),typeof t.value=="string"&&(t.value=ea(t.value)),Array.isArray(t.content)&&(t.content=t.content.map(n=>Dd(n))),t}return e}function ad(e){if(!e||typeof e!="object")return e;if(e.type==="tool"&&(typeof e.id!="string"||e.id.length===0))throw new Error("Tool part missing id");if(e.type!=="text"&&e.type!=="reasoning")return e;const t={...e,renderCache:void 0};if(typeof t.text=="string")t.text=ea(t.text);else if(t.text&&typeof t.text=="object"){const n={...t.text};typeof n.value=="string"&&(n.value=ea(n.value)),Array.isArray(n.content)&&(n.content=n.content.map(s=>Dd(s))),typeof n.text=="string"&&(n.text=ea(n.text)),t.text=n}if(Array.isArray(t.content)&&(t.content=t.content.map(n=>Dd(n))),t.thinking&&typeof t.thinking=="object"){const n={...t.thinking};Array.isArray(n.content)&&(n.content=n.content.map(s=>Dd(s))),t.thinking=n}return t}function v0(e){return{...e,name:e.type==="aborted"?"MessageAbortedError":e.type,data:{message:e.message}}}function KL(e){return e.type==="idle"?e.outcome==="failed"||e.outcome==="interrupted"?"error":"complete":e.type==="assistant"?e.error?"error":e.time.completed?"complete":"streaming":e.type==="compaction"?e.status==="failed"?"error":e.status==="running"?"sent":"complete":e.type==="shell"?e.status==="running"?"sent":e.status==="exited"&&(e.exit===void 0||e.exit===0)?"complete":"error":"complete"}function VL(e){return Array.isArray(e)?e.filter(n=>(n==null?void 0:n.type)==="text"&&typeof n.text=="string").map(n=>n.text).join(`
|
|
14
|
+
`)}if(w.done)return}}finally{try{await d.cancel()}catch{}d.releaseLock()}}});return{server:{info:i=>o({method:"GET",path:"/api/info",successStatus:200,declaredStatuses:[400,401],empty:!1},i)},location:{get:(i,c)=>o({method:"GET",path:"/api/location",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),reload:i=>o({method:"POST",path:"/api/location/reload",successStatus:204,declaredStatuses:[400,401,503],empty:!0},i)},agent:{list:(i,c)=>o({method:"GET",path:"/api/agent",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/agent/${encodeURIComponent(i.agentID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c)},plugin:{list:(i,c)=>o({method:"GET",path:"/api/plugin",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),check:(i,c)=>o({method:"POST",path:"/api/plugin/check",query:{location:i==null?void 0:i.location},body:{target:i==null?void 0:i.target},successStatus:200,declaredStatuses:[400,401],empty:!1},c),update:(i,c)=>o({method:"POST",path:"/api/plugin/update",query:{location:i.location},body:{targets:i.targets},successStatus:204,declaredStatuses:[400,401,503],empty:!0},c)},session:{list:(i,c)=>o({method:"GET",path:"/api/session",query:{limit:i==null?void 0:i.limit,order:i==null?void 0:i.order,search:i==null?void 0:i.search,parentID:i==null?void 0:i.parentID,directory:i==null?void 0:i.directory,project:i==null?void 0:i.project,subpath:i==null?void 0:i.subpath,cursor:i==null?void 0:i.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},c),stats:(i,c)=>o({method:"GET",path:"/api/experimental/session/stats",query:{from:i==null?void 0:i.from,to:i==null?void 0:i.to,project:i==null?void 0:i.project,timezone:i==null?void 0:i.timezone,tools:i==null?void 0:i.tools},successStatus:200,declaredStatuses:[400,401],empty:!1},c).then(l=>l.data),create:(i,c)=>o({method:"POST",path:"/api/session",body:{id:i==null?void 0:i.id,title:i==null?void 0:i.title,agent:i==null?void 0:i.agent,model:i==null?void 0:i.model,location:i==null?void 0:i.location,metadata:i==null?void 0:i.metadata,permissions:i==null?void 0:i.permissions},successStatus:200,declaredStatuses:[400,401],empty:!1},c).then(l=>l.data),import:(i,c)=>o({method:"POST",path:"/api/experimental/session/import",body:{info:i.info,messages:i.messages,location:i.location},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),export:(i,c)=>o({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/export`,query:{sanitize:i.sanitize},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},c).then(l=>l.data),active:i=>o({method:"GET",path:"/api/session/active",successStatus:200,declaredStatuses:[400,401],empty:!1},i).then(c=>c.data),get:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),remove:(i,c)=>o({method:"DELETE",path:`/api/session/${encodeURIComponent(i.sessionID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),fork:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/fork`,body:{before:i.before},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),switchAgent:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/agent`,body:{agent:i.agent},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),switchModel:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/model`,body:{model:i.model},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),update:(i,c)=>o({method:"PATCH",path:`/api/session/${encodeURIComponent(i.sessionID)}`,body:{title:i.title,metadata:i.metadata,permissions:i.permissions},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),move:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/move`,body:{directory:i.directory,delivery:i.delivery},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),prompt:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/prompt`,body:{id:i.id,text:i.text,files:i.files,agents:i.agents,skills:i.skills,metadata:i.metadata,delivery:i.delivery,resume:i.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),command:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/command`,body:{name:i.name,text:i.text,files:i.files,agents:i.agents,skills:i.skills,delivery:i.delivery},successStatus:204,declaredStatuses:[400,401,404,500],empty:!0},c),skill:(i,c)=>o({method:"POST",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/skill`,body:{id:i.id,resume:i.resume},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),synthetic:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/synthetic`,body:{id:i.id,text:i.text,description:i.description,metadata:i.metadata,delivery:i.delivery,resume:i.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),shell:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/shell`,body:{id:i.id,command:i.command},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),compact:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/compact`,body:{id:i.id,delivery:i.delivery},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),wait:(i,c)=>o({method:"POST",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},c),revert:{stage:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/revert/stage`,body:{messageID:i.messageID,files:i.files},successStatus:200,declaredStatuses:[400,401,404,409,500],empty:!1},c).then(l=>l.data),clear:(i,c)=>o({method:"DELETE",path:`/api/session/${encodeURIComponent(i.sessionID)}/revert`,successStatus:204,declaredStatuses:[400,401,404,409,500],empty:!0},c),commit:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},c)},context:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/context`,successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},c).then(l=>l.data),diff:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/diff`,query:{from:i.from,to:i.to,context:i.context},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},c).then(l=>l.data),inbox:{list:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/inbox`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),cancel:(i,c)=>o({method:"DELETE",path:`/api/session/${encodeURIComponent(i.sessionID)}/inbox/${encodeURIComponent(i.inboxID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),update:(i,c)=>o({method:"PATCH",path:`/api/session/${encodeURIComponent(i.sessionID)}/inbox/${encodeURIComponent(i.inboxID)}`,body:{delivery:i.delivery},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},c)},instructions:{entry:{list:(i,c)=>o({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),put:(i,c)=>o({method:"PUT",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/instructions/entries/${encodeURIComponent(i.key)}`,body:{value:i.value},successStatus:204,declaredStatuses:[400,401,404,413],empty:!0},c),remove:(i,c)=>o({method:"DELETE",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/instructions/entries/${encodeURIComponent(i.key)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)}},generate:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/generate`,body:{prompt:i.prompt},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c).then(l=>l.data),log:(i,c)=>a({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/log`,query:{after:i.after,follow:i.follow},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),interrupt:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/interrupt`,query:{resume:i.resume},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),background:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/background`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),message:{get:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/message/${encodeURIComponent(i.messageID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data)},form:{list:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/form`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),create:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/form`,body:{id:i.id,title:i.title,metadata:i.metadata,fields:i.fields},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},c).then(l=>l.data),get:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/form/${encodeURIComponent(i.formID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),reply:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/form/${encodeURIComponent(i.formID)}/reply`,body:{answer:i.answer},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},c),cancel:(i,c)=>o({method:"DELETE",path:`/api/session/${encodeURIComponent(i.sessionID)}/form/${encodeURIComponent(i.formID)}`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},c)},environment:(i,c)=>o({method:"PUT",path:`/api/session/${encodeURIComponent(i.sessionID)}/environment`,body:{variables:i.variables},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),view:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/view`,body:{idle:i.idle},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)},message:{list:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/message`,query:{limit:i.limit,order:i.order,cursor:i.cursor,type:i.type},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},c)},model:{list:(i,c)=>o({method:"GET",path:"/api/model",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c),default:(i,c)=>o({method:"GET",path:"/api/model/default",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c)},generate:{text:(i,c)=>o({method:"POST",path:"/api/experimental/generate",body:{prompt:i.prompt,model:i.model},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c).then(l=>l.data)},provider:{list:(i,c)=>o({method:"GET",path:"/api/provider",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/provider/${encodeURIComponent(i.providerID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c)},integration:{list:(i,c)=>o({method:"GET",path:"/api/integration",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/integration/${encodeURIComponent(i.integrationID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),wellknown:{add:(i,c)=>o({method:"POST",path:"/api/experimental/integration/wellknown",query:{location:i.location},body:{url:i.url},successStatus:204,declaredStatuses:[400,401],empty:!0},c)},connect:{key:(i,c)=>o({method:"POST",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/key`,query:{location:i.location},body:{key:i.key,answer:i.answer,label:i.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)},oauth:{connect:(i,c)=>o({method:"POST",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/oauth`,query:{location:i.location},body:{methodID:i.methodID,answer:i.answer,label:i.label},successStatus:200,declaredStatuses:[400,401],empty:!1},c),status:(i,c)=>o({method:"GET",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/oauth/${encodeURIComponent(i.attemptID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),complete:(i,c)=>o({method:"POST",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/oauth/${encodeURIComponent(i.attemptID)}/complete`,query:{location:i.location},body:{code:i.code},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),cancel:(i,c)=>o({method:"DELETE",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/oauth/${encodeURIComponent(i.attemptID)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401],empty:!0},c)},command:{connect:(i,c)=>o({method:"POST",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/command`,query:{location:i.location},body:{methodID:i.methodID,label:i.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),status:(i,c)=>o({method:"GET",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/command/${encodeURIComponent(i.attemptID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),cancel:(i,c)=>o({method:"DELETE",path:`/api/integration/${encodeURIComponent(i.integrationID)}/connect/command/${encodeURIComponent(i.attemptID)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401],empty:!0},c)}},mcp:{list:(i,c)=>o({method:"GET",path:"/api/mcp",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),add:(i,c)=>o({method:"PUT",path:`/api/experimental/mcp/${encodeURIComponent(i.server)}`,query:{location:i.location},body:{config:i.config},successStatus:204,declaredStatuses:[400,401],empty:!0},c),remove:(i,c)=>o({method:"DELETE",path:`/api/experimental/mcp/${encodeURIComponent(i.server)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),connect:(i,c)=>o({method:"POST",path:`/api/experimental/mcp/${encodeURIComponent(i.server)}/connect`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),disconnect:(i,c)=>o({method:"POST",path:`/api/experimental/mcp/${encodeURIComponent(i.server)}/disconnect`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),resource:{catalog:(i,c)=>o({method:"GET",path:"/api/mcp/resource",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)}},credential:{update:(i,c)=>o({method:"PATCH",path:`/api/credential/${encodeURIComponent(i.credentialID)}`,body:{label:i.label},successStatus:204,declaredStatuses:[400,401],empty:!0},c),activate:(i,c)=>o({method:"POST",path:`/api/credential/${encodeURIComponent(i.credentialID)}/activate`,successStatus:204,declaredStatuses:[400,401],empty:!0},c),remove:(i,c)=>o({method:"DELETE",path:`/api/credential/${encodeURIComponent(i.credentialID)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},c)},project:{list:i=>o({method:"GET",path:"/api/project",successStatus:200,declaredStatuses:[400,401],empty:!1},i),update:(i,c)=>o({method:"PATCH",path:`/api/project/${encodeURIComponent(i.projectID)}`,body:{canonical:i.canonical,name:i.name,icon:i.icon,commands:i.commands},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c)},form:{list:(i,c)=>o({method:"GET",path:"/api/form",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},permission:{request:{list:(i,c)=>o({method:"GET",path:"/api/permission/request",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},saved:{list:(i,c)=>o({method:"GET",path:"/api/permission/saved",query:{projectID:i==null?void 0:i.projectID},successStatus:200,declaredStatuses:[400,401],empty:!1},c).then(l=>l.data),remove:(i,c)=>o({method:"DELETE",path:`/api/permission/saved/${encodeURIComponent(i.id)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},c)},create:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/permission`,body:{id:i.id,action:i.action,resources:i.resources,save:i.save,metadata:i.metadata,source:i.source,agent:i.agent},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),list:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/permission`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),get:(i,c)=>o({method:"GET",path:`/api/session/${encodeURIComponent(i.sessionID)}/permission/${encodeURIComponent(i.requestID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},c).then(l=>l.data),reply:(i,c)=>o({method:"POST",path:`/api/session/${encodeURIComponent(i.sessionID)}/permission/${encodeURIComponent(i.requestID)}/reply`,body:{decision:i.decision,message:i.message},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)},file:{read:(i,c)=>o({method:"GET",path:`/api/fs/read/${TO(i.path)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},c),list:(i,c)=>o({method:"GET",path:"/api/fs/list",query:{location:i==null?void 0:i.location,path:i==null?void 0:i.path},successStatus:200,declaredStatuses:[400,401],empty:!1},c),find:(i,c)=>o({method:"GET",path:"/api/fs/find",query:{location:i.location,query:i.query,type:i.type,limit:i.limit},successStatus:200,declaredStatuses:[400,401],empty:!1},c),write:(i,c)=>o({method:"POST",path:"/api/experimental/fs/write",query:{location:i.location,path:i.path},body:i.payload,successStatus:200,declaredStatuses:[400,401],empty:!1,binaryBody:!0},c)},command:{list:(i,c)=>o({method:"GET",path:"/api/command",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},skill:{list:(i,c)=>o({method:"GET",path:"/api/skill",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},rpc:{call:(i,c)=>o({method:"POST",path:`/api/rpc/${encodeURIComponent(i.rpcID)}/${encodeURIComponent(i.method)}`,query:{location:i.location},body:{input:i.input},successStatus:200,declaredStatuses:[400,401,500],empty:!1},c)},event:{subscribe:i=>a({method:"GET",path:"/api/event",successStatus:200,declaredStatuses:[400,401],empty:!1},i)},pty:{list:(i,c)=>o({method:"GET",path:"/api/pty",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),create:(i,c)=>o({method:"POST",path:"/api/pty",query:{location:i==null?void 0:i.location},body:{command:i==null?void 0:i.command,args:i==null?void 0:i.args,cwd:i==null?void 0:i.cwd,title:i==null?void 0:i.title,env:i==null?void 0:i.env},successStatus:200,declaredStatuses:[400,401],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/pty/${encodeURIComponent(i.ptyID)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),update:(i,c)=>o({method:"PUT",path:`/api/pty/${encodeURIComponent(i.ptyID)}`,query:{location:i.location},body:{title:i.title,size:i.size},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),remove:(i,c)=>o({method:"DELETE",path:`/api/pty/${encodeURIComponent(i.ptyID)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),connect:{token:(i,c)=>o({method:"POST",path:`/api/pty/${encodeURIComponent(i.ptyID)}/connect-token`,query:{location:i.location},headers:{"x-opencode-ticket":i["x-opencode-ticket"]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},c)}},experimental:{persistentPty:{read:(i,c)=>o({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/terminal/read`,query:{lines:i.lines},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c).then(l=>l.data),list:(i,c)=>o({method:"GET",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/terminal`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},c).then(l=>l.data),create:(i,c)=>o({method:"POST",path:`/api/experimental/session/${encodeURIComponent(i.sessionID)}/terminal`,body:{command:i.command,args:i.args,cwd:i.cwd,title:i.title,env:i.env,size:i.size},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c).then(l=>l.data),shutdown:i=>o({method:"POST",path:"/api/experimental/persistent-pty/shutdown",successStatus:204,declaredStatuses:[400,401,503],empty:!0},i),handoff:i=>o({method:"POST",path:"/api/experimental/persistent-pty/handoff",successStatus:200,declaredStatuses:[400,401,503],empty:!1},i),get:(i,c)=>o({method:"GET",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c).then(l=>l.data),update:(i,c)=>o({method:"PUT",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}`,body:{attachmentID:i.attachmentID,size:i.size},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c).then(l=>l.data),snapshot:(i,c)=>o({method:"GET",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}/snapshot`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},c).then(l=>l.data),remove:(i,c)=>o({method:"DELETE",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},c),connectToken:(i,c)=>o({method:"POST",path:`/api/experimental/persistent-pty/${encodeURIComponent(i.ptyID)}/connect-token`,headers:{"x-opencode-ticket":i["x-opencode-ticket"]},successStatus:200,declaredStatuses:[400,401,403,404,503],empty:!1},c).then(l=>l.data)}},shell:{list:(i,c)=>o({method:"GET",path:"/api/shell",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),create:(i,c)=>o({method:"POST",path:"/api/shell",query:{location:i.location},body:{command:i.command,cwd:i.cwd,timeout:i.timeout,metadata:i.metadata},successStatus:200,declaredStatuses:[400,401],empty:!1},c),get:(i,c)=>o({method:"GET",path:`/api/shell/${encodeURIComponent(i.id)}`,query:{location:i.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),output:(i,c)=>o({method:"GET",path:`/api/shell/${encodeURIComponent(i.id)}/output`,query:{location:i.location,cursor:i.cursor,limit:i.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),remove:(i,c)=>o({method:"DELETE",path:`/api/shell/${encodeURIComponent(i.id)}`,query:{location:i.location},successStatus:204,declaredStatuses:[400,401],empty:!0},c)},reference:{list:(i,c)=>o({method:"GET",path:"/api/reference",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},worktree:{list:(i,c)=>o({method:"GET",path:"/api/worktree",query:{projectID:i.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),create:(i,c)=>o({method:"POST",path:"/api/worktree",body:{projectID:i.projectID,from:i.from,branch:i.branch,directory:i.directory,name:i.name},successStatus:200,declaredStatuses:[400,401,404],empty:!1},c),remove:(i,c)=>o({method:"DELETE",path:"/api/worktree",body:{projectID:i.projectID,directory:i.directory,force:i.force},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c),refresh:(i,c)=>o({method:"POST",path:"/api/worktree/refresh",body:{projectID:i.projectID},successStatus:204,declaredStatuses:[400,401,404],empty:!0},c)},vcs:{get:(i,c)=>o({method:"GET",path:"/api/vcs",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),base:(i,c)=>o({method:"GET",path:"/api/vcs/base",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c),status:(i,c)=>o({method:"GET",path:"/api/vcs/status",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),branch:{list:(i,c)=>o({method:"GET",path:"/api/vcs/branch",query:{location:i==null?void 0:i.location,search:i==null?void 0:i.search,limit:i==null?void 0:i.limit},successStatus:200,declaredStatuses:[400,401],empty:!1},c)},diff:(i,c)=>o({method:"GET",path:"/api/vcs/diff",query:{location:i.location,mode:i.mode,base:i.base,context:i.context},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c)},debug:{location:{list:i=>o({method:"GET",path:"/api/debug/location",successStatus:200,declaredStatuses:[400,401],empty:!1},i),evict:(i,c)=>o({method:"DELETE",path:"/api/debug/location",query:{location:i==null?void 0:i.location},successStatus:204,declaredStatuses:[400,401],empty:!0},c)}},migration:{v1:{status:i=>o({method:"GET",path:"/api/experimental/migration/v1",successStatus:200,declaredStatuses:[400,401],empty:!1},i)}},websearch:{providers:(i,c)=>o({method:"GET",path:"/api/websearch/provider",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c),query:(i,c)=>o({method:"POST",path:"/api/websearch",query:{location:i.location},body:{query:i.query,providerID:i.providerID},successStatus:200,declaredStatuses:[400,401,503],empty:!1},c)},config:{get:(i,c)=>o({method:"GET",path:"/api/config",query:{location:i==null?void 0:i.location},successStatus:200,declaredStatuses:[400,401],empty:!1},c),shells:i=>o({method:"GET",path:"/api/config/shell",successStatus:200,declaredStatuses:[400,401],empty:!1},i),update:(i,c)=>o({method:"PATCH",path:"/api/experimental/config",body:{shell:i.shell},successStatus:204,declaredStatuses:[400,401],empty:!0},c)}}}function TO(e){return e.split("/").map(encodeURIComponent).join("/")}function im(e,t,n){if(n!==void 0){if(n===null){e.append(t,"null");return}if(Array.isArray(n)){for(const s of n)im(e,t,s);return}if(typeof n=="object"){for(const[s,r]of Object.entries(n))im(e,`${t}[${s}]`,r);return}e.append(t,String(n))}}async function n0(e){var n,s;if(!s_(e,"application/json")&&!((n=e.headers.get("content-type"))!=null&&n.includes("+json"))){try{await((s=e.body)==null?void 0:s.cancel())}catch{}throw new Ls("UnsupportedContentType",{detail:e.headers.get("content-type")})}let t;try{t=await e.text()}catch(r){throw new Ls("Transport",{cause:r})}if(t==="")throw new Ls("MalformedResponse");try{return JSON.parse(t)}catch(r){throw new Ls("MalformedResponse",{cause:r})}}function MO(e){var n;const t=Object.assign(new Error(e.message??((n=e.data)==null?void 0:n.message)),e);return e._tag&&(t.name=e._tag),t}function s_(e,t){var n,s;return((s=(n=e.headers.get("content-type"))==null?void 0:n.split(";",1)[0])==null?void 0:s.trim().toLowerCase())===t}var AO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="SessionNotFoundError",DO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="SessionBusyError",PO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="FormNotFoundError",IO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="FormAlreadySettledError",RO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="PermissionNotFoundError",OO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="RpcError",LO=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="RpcInternalError";function NO(e,t){return n=>{const s=(r,o)=>{if(!Object.hasOwn(n.events,r))throw new Error(`Unknown RPC event: ${n.id}.${r}`);const a=FO(n,r);return{[Symbol.asyncIterator](){const i=new AbortController,c=o!=null&&o.signal?AbortSignal.any([i.signal,o.signal]):i.signal,l=async function*(){try{for await(const d of t.subscribe({signal:c})){if(c.aborted)return;d.type===a&&(yield d)}}catch(d){if(!c.aborted)throw d}finally{i.abort()}}();return{next:()=>l.next(),return:()=>(i.abort(),l.return())}}}};return Object.assign(Object.fromEntries(Object.keys(n.methods).map(r=>[r,async(o,a)=>{try{return(await e.rpc.call({rpcID:n.id,method:r,input:o,location:a==null?void 0:a.location},{signal:a==null?void 0:a.signal,headers:a==null?void 0:a.headers})).output}catch(i){throw!OO(i)&&!LO(i)?i:i.data===void 0?{type:i.type,message:i.message}:{type:i.type,message:i.message,data:i.data}}}])),{events:{subscribe:s,on:(r,o,a)=>{const i=new AbortController,c=a!=null&&a.signal?AbortSignal.any([i.signal,a.signal]):i.signal,l=s(r,{signal:c});return(async()=>{for await(const d of l)await o(d)})().catch(d=>console.error(d)),()=>i.abort()}}})}}function FO(e,t){return`rpc.${e.id}.${t}`}var am={};fy(am,{OpenCode:()=>am,make:()=>BO});function BO(e){const t=n_(e),n=t_((s,r)=>t.event.subscribe({signal:s,onActivity:r}));return{...t,rpc:Object.assign(NO(t,n),t.rpc),event:n}}class UO{constructor(t=2){this.concurrency=t,this.active=0,this.waiting=[],this.visibleWaiting=[]}async run(t,n,s="normal"){t.throwIfAborted();const r=s==="visible"?this.visibleWaiting:this.waiting;await new Promise((o,a)=>{const i=()=>{const l=r.indexOf(c);l>=0&&r.splice(l,1),a(t.reason)},c=()=>{t.removeEventListener("abort",i),this.active+=1,o()};this.active<this.concurrency?c():(r.push(c),t.addEventListener("abort",i,{once:!0}))});try{return t.throwIfAborted(),await n()}finally{this.active-=1;const o=this.visibleWaiting.shift()??this.waiting.shift();o==null||o()}}}const gy=new UO(2);async function wf(e,t,n){if(t.throwIfAborted(),e())return n();const s=new AbortController,r=Symbol("foreground read"),o=()=>s.abort(t.reason);t.addEventListener("abort",o,{once:!0});let a=!1;const i=Uc(c=>(fk(()=>{e()&&!a&&s.abort(r)}),c));try{return await gy.run(s.signal,()=>(a=!0,i(),n()))}catch(c){if(c!==r)throw c;return t.throwIfAborted(),n()}finally{i(),t.removeEventListener("abort",o)}}class KO{constructor(){this.clients=new Map}key(t,n){return`${t}:${r_(n)}`}createClient(t,n,s=()=>!1){const r=this.key(t,n),o=this.clients.get(r);if(o)return o;const a=VO(n),i=am.make({baseUrl:a,fetch:jO(a,s)});return this.clients.set(r,i),i}destroyClientsForInstance(t){for(const n of Array.from(this.clients.keys()))(n===t||n.startsWith(`${t}:`))&&this.clients.delete(n)}}function VO(e,t=cM){const n=r_(e);return`${qO(t??"")}${n}/`}function jO(e,t=()=>!1){return(n,s)=>{const r=new URL(n instanceof Request?n.url:n),o=new URL(e,r).pathname.replace(/\/+$/,"")+"/",a=r.pathname.startsWith(o)?`/${r.pathname.slice(o.length)}`:r.pathname,i=async()=>{const l=await lM(n,{...s,credentials:(s==null?void 0:s.credentials)??"include"});if(l.status===426){const{reportOpenCodeSetupRequired:d}=await ls(async()=>{const{reportOpenCodeSetupRequired:u}=await Promise.resolve().then(()=>mA);return{reportOpenCodeSetupRequired:u}},void 0);d()}if(l.status===502){const d=await l.clone().json().catch(()=>{});if((d==null?void 0:d.error)===cP){const{tGlobal:u}=await ls(async()=>{const{tGlobal:f}=await import("./index-ByEDZSKg.js").then(g=>g.s);return{tGlobal:f}},__vite__mapDeps([6,2,3,4,5,1,7]));throw new Error(u("envEditor.applyFailed"))}}return l},c=(s==null?void 0:s.method)??(n instanceof Request?n.method:"GET");return c==="GET"&&/^\/api\/location\/?$/.test(a)?wf(t,(s==null?void 0:s.signal)??(n instanceof Request?n.signal:new AbortController().signal),i):c==="GET"&&/^\/api\/(?:project|location|agent(?:\/[^/]+)?|provider|model(?:\/default)?|command|shell|session\/active)\/?$/.test(a)?gy.run((s==null?void 0:s.signal)??(n instanceof Request?n.signal:new AbortController().signal),i):i()}}function r_(e){return(e.startsWith("/")?e:`/${e}`).replace(/\/+/g,"/").replace(/\/+$/,"")}function qO(e){return e.replace(/\/+$/,"")}const fa=new KO;function hy(e,t,n,s=Date.now()){return t!=="idle"?null:e&&e!=="idle"?s:n??null}function zO(e){return!e||e.type==="idle"?"idle":"working"}function WO(e){return!e||e.type!=="retry"?null:{attempt:typeof e.attempt=="number"?e.attempt:1,message:typeof e.message=="string"?e.message:"",next:typeof e.next=="number"?e.next:Date.now()}}function HO(e,t,n="",s={providerId:"",modelId:""},r="idle"){return{...e,instanceId:t,parentId:e.parentID||null,agent:n,model:s,status:r,idleSince:null,generationRecovery:null,runtimeStatusKnown:!1}}function o_(e){return!e.hidden&&e.mode!=="subagent"}function GO(e,t){return e.find(n=>n.id===t)}function ZO(e,t){const n=GO(e,t);if(n)return n.id;const s=e.filter(r=>r.name===t);return s.length===1?s[0].id:t}function TH(e,t,n){if(!n)return e.filter(o_);const s=e.filter(o=>!o.hidden),r=e.find(o=>o.hidden&&o.id===t);return r&&!s.some(o=>o.id===r.id)?[...s,r]:s}async function YO(e,t,n,s){var c,l;const r=()=>{if(!s())throw new Error("Session fork was superseded by reconnect")};let o,a;const i=new Set;for(;;){r();const d=await e.message.list({sessionID:t,limit:200,...a?{cursor:a}:{order:"desc"}});r();for(const f of d.data){if(f.id===n){if(f.type==="assistant"&&!f.time.completed)throw new Error("Cannot fork after an unfinished response");const g=await e.session.fork({sessionID:t,...o?{before:o}:{}});if(r(),!o&&(((c=g.fork)==null?void 0:c.boundary.type)!=="through"||g.fork.boundary.messageID!==n))throw await e.session.remove({sessionID:g.id}),new Error("Session changed while forking; please try again");return g}o=f.id}const u=(l=d.cursor)==null?void 0:l.next;if(!u)throw new Error("Fork message no longer exists");if(i.has(u))throw new Error("Repeated message cursor");i.add(u),a=u}}var Mt;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const o={};for(const a of r)o[a]=a;return o},e.getValidEnumValues=r=>{const o=e.objectKeys(r).filter(i=>typeof r[r[i]]!="number"),a={};for(const i of o)a[i]=r[i];return e.objectValues(a)},e.objectValues=r=>e.objectKeys(r).map(function(o){return r[o]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const o=[];for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&o.push(a);return o},e.find=(r,o)=>{for(const a of r)if(o(a))return a},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,o=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}e.joinValues=s,e.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o})(Mt||(Mt={}));var s0;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(s0||(s0={}));const Je=Mt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Xr=e=>{switch(typeof e){case"undefined":return Je.undefined;case"string":return Je.string;case"number":return Number.isNaN(e)?Je.nan:Je.number;case"boolean":return Je.boolean;case"function":return Je.function;case"bigint":return Je.bigint;case"symbol":return Je.symbol;case"object":return Array.isArray(e)?Je.array:e===null?Je.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Je.promise:typeof Map<"u"&&e instanceof Map?Je.map:typeof Set<"u"&&e instanceof Set?Je.set:typeof Date<"u"&&e instanceof Date?Je.date:Je.object;default:return Je.unknown}},Pe=Mt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Nr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(o){return o.message},s={_errors:[]},r=o=>{for(const a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)s._errors.push(n(a));else{let i=s,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(n(a))):i[l]=i[l]||{_errors:[]},i=i[l],c++}}};return r(this),s}static assert(t){if(!(t instanceof Nr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Mt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},s=[];for(const r of this.issues)if(r.path.length>0){const o=r.path[0];n[o]=n[o]||[],n[o].push(t(r))}else s.push(t(r));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}Nr.create=e=>new Nr(e);const cm=(e,t)=>{let n;switch(e.code){case Pe.invalid_type:e.received===Je.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Pe.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Mt.jsonStringifyReplacer)}`;break;case Pe.unrecognized_keys:n=`Unrecognized key(s) in object: ${Mt.joinValues(e.keys,", ")}`;break;case Pe.invalid_union:n="Invalid input";break;case Pe.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Mt.joinValues(e.options)}`;break;case Pe.invalid_enum_value:n=`Invalid enum value. Expected ${Mt.joinValues(e.options)}, received '${e.received}'`;break;case Pe.invalid_arguments:n="Invalid function arguments";break;case Pe.invalid_return_type:n="Invalid function return type";break;case Pe.invalid_date:n="Invalid date";break;case Pe.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Mt.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Pe.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Pe.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Pe.custom:n="Invalid input";break;case Pe.invalid_intersection_types:n="Intersection results could not be merged";break;case Pe.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Pe.not_finite:n="Number must be finite";break;default:n=t.defaultError,Mt.assertNever(e)}return{message:n}};let JO=cm;function QO(){return JO}const XO=e=>{const{data:t,path:n,errorMaps:s,issueData:r}=e,o=[...n,...r.path||[]],a={...r,path:o};if(r.message!==void 0)return{...r,path:o,message:r.message};let i="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)i=l(a,{data:t,defaultError:i}).message;return{...r,path:o,message:i}};function ze(e,t){const n=QO(),s=XO({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===cm?void 0:cm].filter(r=>!!r)});e.common.issues.push(s)}class ds{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const s=[];for(const r of n){if(r.status==="aborted")return lt;r.status==="dirty"&&t.dirty(),s.push(r.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,n){const s=[];for(const r of n){const o=await r.key,a=await r.value;s.push({key:o,value:a})}return ds.mergeObjectSync(t,s)}static mergeObjectSync(t,n){const s={};for(const r of n){const{key:o,value:a}=r;if(o.status==="aborted"||a.status==="aborted")return lt;o.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||r.alwaysSet)&&(s[o.value]=a.value)}return{status:t.value,value:s}}}const lt=Object.freeze({status:"aborted"}),vc=e=>({status:"dirty",value:e}),Ps=e=>({status:"valid",value:e}),r0=e=>e.status==="aborted",o0=e=>e.status==="dirty",ga=e=>e.status==="valid",tu=e=>typeof Promise<"u"&&e instanceof Promise;var Xe;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Xe||(Xe={}));class wo{constructor(t,n,s,r){this._cachedPath=[],this.parent=t,this.data=n,this._path=s,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const i0=(e,t)=>{if(ga(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Nr(e.common.issues);return this._error=n,this._error}}};function St(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:s,description:r}=e;if(t&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:r}:{errorMap:(a,i)=>{const{message:c}=e;return a.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??s??i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:c??n??i.defaultError}},description:r}}class Tt{get description(){return this._def.description}_getType(t){return Xr(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Xr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ds,ctx:{common:t.parent.common,data:t.data,parsedType:Xr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(tu(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const s=this.safeParse(t,n);if(s.success)return s.data;throw s.error}safeParse(t,n){const s={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)},r=this._parseSync({data:t,path:s.path,parent:s});return i0(s,r)}"~validate"(t){var s,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)};if(!this["~standard"].async)try{const o=this._parseSync({data:t,path:[],parent:n});return ga(o)?{value:o.value}:{issues:n.common.issues}}catch(o){(r=(s=o==null?void 0:o.message)==null?void 0:s.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(o=>ga(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(t,n){const s=await this.safeParseAsync(t,n);if(s.success)return s.data;throw s.error}async safeParseAsync(t,n){const s={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)},r=this._parse({data:t,path:s.path,parent:s}),o=await(tu(r)?r:Promise.resolve(r));return i0(s,o)}refine(t,n){const s=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,o)=>{const a=t(r),i=()=>o.addIssue({code:Pe.custom,...s(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(i(),!1)):a?!0:(i(),!1)})}refinement(t,n){return this._refinement((s,r)=>t(s)?!0:(r.addIssue(typeof n=="function"?n(s,r):n),!1))}_refinement(t){return new oi({schema:this,typeName:gt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ar.create(this,this._def)}nullable(){return ii.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ar.create(this)}promise(){return iu.create(this,this._def)}or(t){return su.create([this,t],this._def)}and(t){return ru.create(this,t,this._def)}transform(t){return new oi({...St(this._def),schema:this,typeName:gt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new au({...St(this._def),innerType:this,defaultValue:n,typeName:gt.ZodDefault})}brand(){return new l_({typeName:gt.ZodBranded,type:this,...St(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new cu({...St(this._def),innerType:this,catchValue:n,typeName:gt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return py.create(this,t)}readonly(){return lu.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const eL=/^c[^\s-]{8,}$/i,tL=/^[0-9a-z]+$/,nL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,sL=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,rL=/^[a-z0-9_-]{21}$/i,oL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,iL=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,aL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let jg;const lL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,dL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,uL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,fL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,hL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,i_="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",mL=new RegExp(`^${i_}$`);function a_(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function pL(e){return new RegExp(`^${a_(e)}$`)}function yL(e){let t=`${i_}T${a_(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function vL(e,t){return!!((t==="v4"||!t)&&lL.test(e)||(t==="v6"||!t)&&uL.test(e))}function wL(e,t){if(!oL.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&r.alg!==t)}catch{return!1}}function bL(e,t){return!!((t==="v4"||!t)&&dL.test(e)||(t==="v6"||!t)&&fL.test(e))}class ro extends Tt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Je.string){const o=this._getOrReturnCtx(t);return ze(o,{code:Pe.invalid_type,expected:Je.string,received:o.parsedType}),lt}const s=new ds;let r;for(const o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="max")t.data.length>o.value&&(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="length"){const a=t.data.length>o.value,i=t.data.length<o.value;(a||i)&&(r=this._getOrReturnCtx(t,r),a?ze(r,{code:Pe.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):i&&ze(r,{code:Pe.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if(o.kind==="email")aL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"email",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="emoji")jg||(jg=new RegExp(cL,"u")),jg.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"emoji",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="uuid")sL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"uuid",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="nanoid")rL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"nanoid",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid")eL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"cuid",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid2")tL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"cuid2",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="ulid")nL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"ulid",code:Pe.invalid_string,message:o.message}),s.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),ze(r,{validation:"url",code:Pe.invalid_string,message:o.message}),s.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"regex",code:Pe.invalid_string,message:o.message}),s.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),s.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):o.kind==="datetime"?yL(o).test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:"datetime",message:o.message}),s.dirty()):o.kind==="date"?mL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:"date",message:o.message}),s.dirty()):o.kind==="time"?pL(o).test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.invalid_string,validation:"time",message:o.message}),s.dirty()):o.kind==="duration"?iL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"duration",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="ip"?vL(t.data,o.version)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"ip",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="jwt"?wL(t.data,o.alg)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"jwt",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="cidr"?bL(t.data,o.version)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"cidr",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="base64"?gL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"base64",code:Pe.invalid_string,message:o.message}),s.dirty()):o.kind==="base64url"?hL.test(t.data)||(r=this._getOrReturnCtx(t,r),ze(r,{validation:"base64url",code:Pe.invalid_string,message:o.message}),s.dirty()):Mt.assertNever(o);return{status:s.value,value:t.data}}_regex(t,n,s){return this.refinement(r=>t.test(r),{validation:n,code:Pe.invalid_string,...Xe.errToObj(s)})}_addCheck(t){return new ro({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Xe.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Xe.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Xe.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Xe.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Xe.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Xe.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Xe.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Xe.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Xe.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Xe.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Xe.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Xe.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Xe.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Xe.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Xe.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Xe.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Xe.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Xe.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Xe.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Xe.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Xe.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Xe.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Xe.errToObj(n)})}nonempty(t){return this.min(1,Xe.errToObj(t))}trim(){return new ro({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ro({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ro({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ro.create=e=>new ro({checks:[],typeName:gt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...St(e)});function SL(e,t){const n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,r=n>s?n:s,o=Number.parseInt(e.toFixed(r).replace(".","")),a=Number.parseInt(t.toFixed(r).replace(".",""));return o%a/10**r}class ha extends Tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Je.number){const o=this._getOrReturnCtx(t);return ze(o,{code:Pe.invalid_type,expected:Je.number,received:o.parsedType}),lt}let s;const r=new ds;for(const o of this._def.checks)o.kind==="int"?Mt.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.invalid_type,expected:"integer",received:"float",message:o.message}),r.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="multipleOf"?SL(t.data,o.value)!==0&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.not_finite,message:o.message}),r.dirty()):Mt.assertNever(o);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Xe.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Xe.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Xe.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Xe.toString(n))}setLimit(t,n,s,r){return new ha({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:Xe.toString(r)}]})}_addCheck(t){return new ha({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Xe.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Xe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Xe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Xe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Xe.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Xe.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Xe.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Xe.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Xe.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Mt.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(t===null||s.value<t)&&(t=s.value)}return Number.isFinite(n)&&Number.isFinite(t)}}ha.create=e=>new ha({checks:[],typeName:gt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...St(e)});class Hc extends Tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Je.bigint)return this._getInvalidInput(t);let s;const r=new ds;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),ze(s,{code:Pe.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):Mt.assertNever(o);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ze(n,{code:Pe.invalid_type,expected:Je.bigint,received:n.parsedType}),lt}gte(t,n){return this.setLimit("min",t,!0,Xe.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Xe.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Xe.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Xe.toString(n))}setLimit(t,n,s,r){return new Hc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:Xe.toString(r)}]})}_addCheck(t){return new Hc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Xe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Xe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Xe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Xe.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Xe.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Hc.create=e=>new Hc({checks:[],typeName:gt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...St(e)});class lm extends Tt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Je.boolean){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.boolean,received:s.parsedType}),lt}return Ps(t.data)}}lm.create=e=>new lm({typeName:gt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...St(e)});class nu extends Tt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Je.date){const o=this._getOrReturnCtx(t);return ze(o,{code:Pe.invalid_type,expected:Je.date,received:o.parsedType}),lt}if(Number.isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return ze(o,{code:Pe.invalid_date}),lt}const s=new ds;let r;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),s.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(r=this._getOrReturnCtx(t,r),ze(r,{code:Pe.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),s.dirty()):Mt.assertNever(o);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new nu({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Xe.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Xe.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}nu.create=e=>new nu({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:gt.ZodDate,...St(e)});class a0 extends Tt{_parse(t){if(this._getType(t)!==Je.symbol){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.symbol,received:s.parsedType}),lt}return Ps(t.data)}}a0.create=e=>new a0({typeName:gt.ZodSymbol,...St(e)});class dm extends Tt{_parse(t){if(this._getType(t)!==Je.undefined){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.undefined,received:s.parsedType}),lt}return Ps(t.data)}}dm.create=e=>new dm({typeName:gt.ZodUndefined,...St(e)});class um extends Tt{_parse(t){if(this._getType(t)!==Je.null){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.null,received:s.parsedType}),lt}return Ps(t.data)}}um.create=e=>new um({typeName:gt.ZodNull,...St(e)});class c0 extends Tt{constructor(){super(...arguments),this._any=!0}_parse(t){return Ps(t.data)}}c0.create=e=>new c0({typeName:gt.ZodAny,...St(e)});class l0 extends Tt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ps(t.data)}}l0.create=e=>new l0({typeName:gt.ZodUnknown,...St(e)});class bo extends Tt{_parse(t){const n=this._getOrReturnCtx(t);return ze(n,{code:Pe.invalid_type,expected:Je.never,received:n.parsedType}),lt}}bo.create=e=>new bo({typeName:gt.ZodNever,...St(e)});class d0 extends Tt{_parse(t){if(this._getType(t)!==Je.undefined){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.void,received:s.parsedType}),lt}return Ps(t.data)}}d0.create=e=>new d0({typeName:gt.ZodVoid,...St(e)});class ar extends Tt{_parse(t){const{ctx:n,status:s}=this._processInputParams(t),r=this._def;if(n.parsedType!==Je.array)return ze(n,{code:Pe.invalid_type,expected:Je.array,received:n.parsedType}),lt;if(r.exactLength!==null){const a=n.data.length>r.exactLength.value,i=n.data.length<r.exactLength.value;(a||i)&&(ze(n,{code:a?Pe.too_big:Pe.too_small,minimum:i?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(ze(n,{code:Pe.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(ze(n,{code:Pe.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((a,i)=>r.type._parseAsync(new wo(n,a,n.path,i)))).then(a=>ds.mergeArray(s,a));const o=[...n.data].map((a,i)=>r.type._parseSync(new wo(n,a,n.path,i)));return ds.mergeArray(s,o)}get element(){return this._def.type}min(t,n){return new ar({...this._def,minLength:{value:t,message:Xe.toString(n)}})}max(t,n){return new ar({...this._def,maxLength:{value:t,message:Xe.toString(n)}})}length(t,n){return new ar({...this._def,exactLength:{value:t,message:Xe.toString(n)}})}nonempty(t){return this.min(1,t)}}ar.create=(e,t)=>new ar({type:e,minLength:null,maxLength:null,exactLength:null,typeName:gt.ZodArray,...St(t)});function Fi(e){if(e instanceof ln){const t={};for(const n in e.shape){const s=e.shape[n];t[n]=Ar.create(Fi(s))}return new ln({...e._def,shape:()=>t})}else return e instanceof ar?new ar({...e._def,type:Fi(e.element)}):e instanceof Ar?Ar.create(Fi(e.unwrap())):e instanceof ii?ii.create(Fi(e.unwrap())):e instanceof si?si.create(e.items.map(t=>Fi(t))):e}class ln extends Tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Mt.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Je.object){const l=this._getOrReturnCtx(t);return ze(l,{code:Pe.invalid_type,expected:Je.object,received:l.parsedType}),lt}const{status:s,ctx:r}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof bo&&this._def.unknownKeys==="strip"))for(const l in r.data)a.includes(l)||i.push(l);const c=[];for(const l of a){const d=o[l],u=r.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new wo(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof bo){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of i)c.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(l==="strict")i.length>0&&(ze(r,{code:Pe.unrecognized_keys,keys:i}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of i){const u=r.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new wo(r,u,r.path,d)),alwaysSet:d in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of c){const u=await d.key,f=await d.value;l.push({key:u,value:f,alwaysSet:d.alwaysSet})}return l}).then(l=>ds.mergeObjectSync(s,l)):ds.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(t){return Xe.errToObj,new ln({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,s)=>{var o,a;const r=((a=(o=this._def).errorMap)==null?void 0:a.call(o,n,s).message)??s.defaultError;return n.code==="unrecognized_keys"?{message:Xe.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new ln({...this._def,unknownKeys:"strip"})}passthrough(){return new ln({...this._def,unknownKeys:"passthrough"})}extend(t){return new ln({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new ln({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:gt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new ln({...this._def,catchall:t})}pick(t){const n={};for(const s of Mt.objectKeys(t))t[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new ln({...this._def,shape:()=>n})}omit(t){const n={};for(const s of Mt.objectKeys(this.shape))t[s]||(n[s]=this.shape[s]);return new ln({...this._def,shape:()=>n})}deepPartial(){return Fi(this)}partial(t){const n={};for(const s of Mt.objectKeys(this.shape)){const r=this.shape[s];t&&!t[s]?n[s]=r:n[s]=r.optional()}return new ln({...this._def,shape:()=>n})}required(t){const n={};for(const s of Mt.objectKeys(this.shape))if(t&&!t[s])n[s]=this.shape[s];else{let o=this.shape[s];for(;o instanceof Ar;)o=o._def.innerType;n[s]=o}return new ln({...this._def,shape:()=>n})}keyof(){return c_(Mt.objectKeys(this.shape))}}ln.create=(e,t)=>new ln({shape:()=>e,unknownKeys:"strip",catchall:bo.create(),typeName:gt.ZodObject,...St(t)});ln.strictCreate=(e,t)=>new ln({shape:()=>e,unknownKeys:"strict",catchall:bo.create(),typeName:gt.ZodObject,...St(t)});ln.lazycreate=(e,t)=>new ln({shape:e,unknownKeys:"strip",catchall:bo.create(),typeName:gt.ZodObject,...St(t)});class su extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t),s=this._def.options;function r(o){for(const i of o)if(i.result.status==="valid")return i.result;for(const i of o)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(i=>new Nr(i.ctx.common.issues));return ze(n,{code:Pe.invalid_union,unionErrors:a}),lt}if(n.common.async)return Promise.all(s.map(async o=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(r);{let o;const a=[];for(const c of s){const l={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(c=>new Nr(c));return ze(n,{code:Pe.invalid_union,unionErrors:i}),lt}}get options(){return this._def.options}}su.create=(e,t)=>new su({options:e,typeName:gt.ZodUnion,...St(t)});const br=e=>e instanceof gm?br(e.schema):e instanceof oi?br(e.innerType()):e instanceof ou?[e.value]:e instanceof ri?e.options:e instanceof hm?Mt.objectValues(e.enum):e instanceof au?br(e._def.innerType):e instanceof dm?[void 0]:e instanceof um?[null]:e instanceof Ar?[void 0,...br(e.unwrap())]:e instanceof ii?[null,...br(e.unwrap())]:e instanceof l_||e instanceof lu?br(e.unwrap()):e instanceof cu?br(e._def.innerType):[];class my extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.object)return ze(n,{code:Pe.invalid_type,expected:Je.object,received:n.parsedType}),lt;const s=this.discriminator,r=n.data[s],o=this.optionsMap.get(r);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(ze(n,{code:Pe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),lt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,s){const r=new Map;for(const o of n){const a=br(o.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const i of a){if(r.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);r.set(i,o)}}return new my({typeName:gt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:r,...St(s)})}}function fm(e,t){const n=Xr(e),s=Xr(t);if(e===t)return{valid:!0,data:e};if(n===Je.object&&s===Je.object){const r=Mt.objectKeys(t),o=Mt.objectKeys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of o){const c=fm(e[i],t[i]);if(!c.valid)return{valid:!1};a[i]=c.data}return{valid:!0,data:a}}else if(n===Je.array&&s===Je.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let o=0;o<e.length;o++){const a=e[o],i=t[o],c=fm(a,i);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===Je.date&&s===Je.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class ru extends Tt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t),r=(o,a)=>{if(r0(o)||r0(a))return lt;const i=fm(o.value,a.value);return i.valid?((o0(o)||o0(a))&&n.dirty(),{status:n.value,value:i.data}):(ze(s,{code:Pe.invalid_intersection_types}),lt)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([o,a])=>r(o,a)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ru.create=(e,t,n)=>new ru({left:e,right:t,typeName:gt.ZodIntersection,...St(n)});class si extends Tt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.array)return ze(s,{code:Pe.invalid_type,expected:Je.array,received:s.parsedType}),lt;if(s.data.length<this._def.items.length)return ze(s,{code:Pe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),lt;!this._def.rest&&s.data.length>this._def.items.length&&(ze(s,{code:Pe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...s.data].map((a,i)=>{const c=this._def.items[i]||this._def.rest;return c?c._parse(new wo(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(o).then(a=>ds.mergeArray(n,a)):ds.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new si({...this._def,rest:t})}}si.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new si({items:e,typeName:gt.ZodTuple,rest:null,...St(t)})};class u0 extends Tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.map)return ze(s,{code:Pe.invalid_type,expected:Je.map,received:s.parsedType}),lt;const r=this._def.keyType,o=this._def.valueType,a=[...s.data.entries()].map(([i,c],l)=>({key:r._parse(new wo(s,i,s.path,[l,"key"])),value:o._parse(new wo(s,c,s.path,[l,"value"]))}));if(s.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return lt;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),i.set(l.value,d.value)}return{status:n.value,value:i}})}else{const i=new Map;for(const c of a){const l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return lt;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),i.set(l.value,d.value)}return{status:n.value,value:i}}}}u0.create=(e,t,n)=>new u0({valueType:t,keyType:e,typeName:gt.ZodMap,...St(n)});class Gc extends Tt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==Je.set)return ze(s,{code:Pe.invalid_type,expected:Je.set,received:s.parsedType}),lt;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(ze(s,{code:Pe.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(ze(s,{code:Pe.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const o=this._def.valueType;function a(c){const l=new Set;for(const d of c){if(d.status==="aborted")return lt;d.status==="dirty"&&n.dirty(),l.add(d.value)}return{status:n.value,value:l}}const i=[...s.data.values()].map((c,l)=>o._parse(new wo(s,c,s.path,l)));return s.common.async?Promise.all(i).then(c=>a(c)):a(i)}min(t,n){return new Gc({...this._def,minSize:{value:t,message:Xe.toString(n)}})}max(t,n){return new Gc({...this._def,maxSize:{value:t,message:Xe.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Gc.create=(e,t)=>new Gc({valueType:e,minSize:null,maxSize:null,typeName:gt.ZodSet,...St(t)});class gm extends Tt{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}gm.create=(e,t)=>new gm({getter:e,typeName:gt.ZodLazy,...St(t)});class ou extends Tt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ze(n,{received:n.data,code:Pe.invalid_literal,expected:this._def.value}),lt}return{status:"valid",value:t.data}}get value(){return this._def.value}}ou.create=(e,t)=>new ou({value:e,typeName:gt.ZodLiteral,...St(t)});function c_(e,t){return new ri({values:e,typeName:gt.ZodEnum,...St(t)})}class ri extends Tt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),s=this._def.values;return ze(n,{expected:Mt.joinValues(s),received:n.parsedType,code:Pe.invalid_type}),lt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),s=this._def.values;return ze(n,{received:n.data,code:Pe.invalid_enum_value,options:s}),lt}return Ps(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return ri.create(t,{...this._def,...n})}exclude(t,n=this._def){return ri.create(this.options.filter(s=>!t.includes(s)),{...this._def,...n})}}ri.create=c_;class hm extends Tt{_parse(t){const n=Mt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==Je.string&&s.parsedType!==Je.number){const r=Mt.objectValues(n);return ze(s,{expected:Mt.joinValues(r),received:s.parsedType,code:Pe.invalid_type}),lt}if(this._cache||(this._cache=new Set(Mt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=Mt.objectValues(n);return ze(s,{received:s.data,code:Pe.invalid_enum_value,options:r}),lt}return Ps(t.data)}get enum(){return this._def.values}}hm.create=(e,t)=>new hm({values:e,typeName:gt.ZodNativeEnum,...St(t)});class iu extends Tt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Je.promise&&n.common.async===!1)return ze(n,{code:Pe.invalid_type,expected:Je.promise,received:n.parsedType}),lt;const s=n.parsedType===Je.promise?n.data:Promise.resolve(n.data);return Ps(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}iu.create=(e,t)=>new iu({type:e,typeName:gt.ZodPromise,...St(t)});class oi extends Tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:s}=this._processInputParams(t),r=this._def.effect||null,o={addIssue:a=>{ze(s,a),a.fatal?n.abort():n.dirty()},get path(){return s.path}};if(o.addIssue=o.addIssue.bind(o),r.type==="preprocess"){const a=r.transform(s.data,o);if(s.common.async)return Promise.resolve(a).then(async i=>{if(n.value==="aborted")return lt;const c=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return c.status==="aborted"?lt:c.status==="dirty"||n.value==="dirty"?vc(c.value):c});{if(n.value==="aborted")return lt;const i=this._def.schema._parseSync({data:a,path:s.path,parent:s});return i.status==="aborted"?lt:i.status==="dirty"||n.value==="dirty"?vc(i.value):i}}if(r.type==="refinement"){const a=i=>{const c=r.refinement(i,o);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?lt:(i.status==="dirty"&&n.dirty(),a(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>i.status==="aborted"?lt:(i.status==="dirty"&&n.dirty(),a(i.value).then(()=>({status:n.value,value:i.value}))))}if(r.type==="transform")if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ga(a))return lt;const i=r.transform(a.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>ga(a)?Promise.resolve(r.transform(a.value,o)).then(i=>({status:n.value,value:i})):lt);Mt.assertNever(r)}}oi.create=(e,t,n)=>new oi({schema:e,typeName:gt.ZodEffects,effect:t,...St(n)});oi.createWithPreprocess=(e,t,n)=>new oi({schema:t,effect:{type:"preprocess",transform:e},typeName:gt.ZodEffects,...St(n)});class Ar extends Tt{_parse(t){return this._getType(t)===Je.undefined?Ps(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ar.create=(e,t)=>new Ar({innerType:e,typeName:gt.ZodOptional,...St(t)});class ii extends Tt{_parse(t){return this._getType(t)===Je.null?Ps(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ii.create=(e,t)=>new ii({innerType:e,typeName:gt.ZodNullable,...St(t)});class au extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t);let s=n.data;return n.parsedType===Je.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}au.create=(e,t)=>new au({innerType:e,typeName:gt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...St(t)});class cu extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t),s={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return tu(r)?r.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Nr(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Nr(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}cu.create=(e,t)=>new cu({innerType:e,typeName:gt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...St(t)});class f0 extends Tt{_parse(t){if(this._getType(t)!==Je.nan){const s=this._getOrReturnCtx(t);return ze(s,{code:Pe.invalid_type,expected:Je.nan,received:s.parsedType}),lt}return{status:"valid",value:t.data}}}f0.create=e=>new f0({typeName:gt.ZodNaN,...St(e)});class l_ extends Tt{_parse(t){const{ctx:n}=this._processInputParams(t),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class py extends Tt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?lt:o.status==="dirty"?(n.dirty(),vc(o.value)):this._def.out._parseAsync({data:o.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?lt:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(t,n){return new py({in:t,out:n,typeName:gt.ZodPipeline})}}class lu extends Tt{_parse(t){const n=this._def.innerType._parse(t),s=r=>(ga(r)&&(r.value=Object.freeze(r.value)),r);return tu(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}lu.create=(e,t)=>new lu({innerType:e,typeName:gt.ZodReadonly,...St(t)});var gt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(gt||(gt={}));const qs=ro.create,Yn=ha.create,yy=lm.create;bo.create;const So=ar.create,Qt=ln.create,xl=su.create,kL=my.create;ru.create;si.create;const os=ou.create,vy=ri.create;iu.create;Ar.create;ii.create;const xL="codenomad.session-pruning",_L=`rpc.${xL}.pruned`,mm=qs().min(1).max(256),wy=Qt({sessionID:mm,messageID:mm}).strict();wy.extend({revision:qs().regex(/^[a-f0-9]{64}$/)}).strict();wy.extend({revision:qs().regex(/^[a-f0-9]{64}$/),indexes:So(Yn().int().min(0).max(1e5)).min(1).max(100001).refine(e=>new Set(e).size===e.length)}).strict();const _l=Qt({status:os("blocked"),reason:vy(["unavailable","maintenance_required","conflict","not_deletable","unsupported_storage"])}).strict();xl([Qt({status:os("pruned"),messageID:mm,revision:qs().regex(/^[a-f0-9]{64}$/),removedCount:Yn().int().positive()}).strict(),_l]);xl([Qt({status:os("preview"),revision:qs().regex(/^[a-f0-9]{64}$/),liveMutation:yy(),parts:So(Qt({index:Yn().int().nonnegative(),type:vy(["tool","reasoning"]),bytes:Yn().int().nonnegative()}))}).strict(),_l]);const $L=wy.extend({revision:qs().regex(/^[a-f0-9]{64}$/)}).strict(),cr=qs().min(1).max(256),Ac=kL("kind",[Qt({kind:os("latest")}).strict(),Qt({kind:os("oldest")}).strict(),Qt({kind:os("around"),messageID:cr}).strict(),Qt({kind:os("before"),messageID:cr}).strict(),Qt({kind:os("after"),messageID:cr}).strict()]);Qt({sessionID:cr,target:Ac}).strict();const d_=Qt({after:Yn().int().nonnegative(),through:Yn().int().nonnegative()}).strict(),u_=Qt({after:Yn().int().min(-1),through:Yn().int().nonnegative(),digest:qs().regex(/^[a-f0-9]{64}$/)}).strict();Qt({sessionID:cr,cursor:d_.optional(),after:Yn().int().min(-1).optional(),known:So(u_).max(512).optional()}).strict();const f_=vy(["user","assistant","system","synthetic","skill","shell","compaction","idle","agent-switched","model-switched","location-switched"]),CL=Qt({id:cr,seq:Yn().int().nonnegative(),type:f_,tools:Yn().int().nonnegative(),reasoning:Yn().int().nonnegative(),toolName:qs().max(256).optional()}).strict();xl([_l,Qt({status:os("outline"),entries:So(CL).max(16384),total:Yn().int().nonnegative(),cursor:d_.nullable(),checkpoints:So(u_.extend({changed:yy()})).max(512)}).strict()]);Qt({sessionID:cr,messageIDs:So(cr).min(1).max(12)}).strict();xl([_l,Qt({status:os("previews"),entries:So(Qt({id:cr,text:qs().max(4096),tools:qs().max(4096)}).strict()).max(12)}).strict()]);xl([_l,Qt({status:os("blocked"),reason:os("anchor_missing")}).strict(),Qt({status:os("window"),messages:So(Qt({id:cr,type:f_,time:Qt({created:Yn()}).passthrough()}).passthrough()).max(200),older:Ac.nullable(),newer:Ac.nullable(),resume:Ac,latest:yy()}).strict()]);const pm="codenomad:history-window:1:";class g_ extends Error{constructor(){super($e("session.pruning.conflict"))}}const Ad=e=>pm+encodeURIComponent(JSON.stringify(e));function EL(e){if(e!=null&&e.startsWith(pm))return Ac.parse(JSON.parse(decodeURIComponent(e.slice(pm.length))))}async function TL(e,t,n,s){const r=await kt.fetchHistoryWindow(e,t,n,s);if(s==null||s.throwIfAborted(),r.status!=="window")throw r.reason==="anchor_missing"?new g_:new Error($e(`session.pruning.${r.reason}`));return{response:{data:r.messages,cursor:{}},window:{kind:r.latest?"latest":"history",resumeCursor:Ad(r.resume),olderCursor:r.older?Ad(r.older):void 0,newerCursors:[r.newer?Ad(r.newer):null]}}}const h_=200;function zs(e){const t=e==null?void 0:e.trim();if(!t)return"";const s=t.replace(/\\/g,"/").replace(/\/+$/,"")||"/",r=s.match(/^\/\/(wsl(?:\.localhost|\$)?)[/]([^/]+)(.*)$/i);return r?`//${r[1].toLowerCase()}/${r[2].toLowerCase()}${r[3]}`:/^[A-Za-z]:\//.test(s)||s.startsWith("//")||t.includes("\\")?s.toLowerCase():s}function ML(e){return e.cursor?{cursor:e.cursor}:{...e.directory?{directory:e.directory}:{},...e.search?{search:e.search}:{},...e.project?{project:e.project}:{},...e.subpath?{subpath:e.subpath}:{},...e.parentID!==void 0?{parentID:e.parentID}:{},...e.order?{order:e.order}:{},limit:h_}}const ma=Ut("api"),[du,g0]=R(new Map),[ym,h0]=R(new Map),Vi=new Map,rd=new Set,od=new Map,id=new Map,[AL,m0]=R(new Map),vm=new Map;async function m_(e,t){const n=Vi.get(e);if(n)return t||rd.add(e),n;const s=async o=>{try{const a=await wf(()=>Ds()===e,new AbortController().signal,()=>kt.fetchWorktrees(e));a.defaultDirectory?vm.set(e,a.defaultDirectory):vm.delete(e),g0(i=>{const c=new Map(i);return c.set(e,a.worktrees??[]),c}),h0(i=>{const c=new Map(i);return c.set(e,typeof a.isGitRepo=="boolean"?a.isGitRepo:null),c})}catch(a){if(ma.warn(o?"Failed to load worktrees":"Failed to reload worktrees",{instanceId:e,error:a}),!o)throw a;g0(i=>{const c=new Map(i);return c.set(e,[]),c}),h0(i=>{if(i.has(e))return i;const c=new Map(i);return c.set(e,null),c})}},r=Promise.resolve().then(async()=>{let o=t;do{rd.delete(e);try{await s(o)}catch(a){if(!rd.has(e))throw a}o=!1}while(rd.has(e))});Vi.set(e,r),await r.finally(()=>{Vi.get(e)===r&&Vi.delete(e)})}async function Xi(e){if(!e||du().has(e)&&ym().has(e))return;const t=Vi.get(e);t&&(await t,du().has(e)&&ym().has(e))||await m_(e,!0)}async function wi(e){e&&await m_(e,!1)}xs.on("workspace.worktreesChanged",e=>{if(e.type!=="workspace.worktreesChanged")return;const t=e.workspaceId;!du().has(t)&&!Vi.has(t)||wi(t).catch(n=>ma.warn("Failed to receive refreshed worktrees",{instanceId:t,error:n}))});async function DL(e,t,n=wi){var o;if(!e)return;ma.info("OpenCode worktree ready",{instanceId:e,directory:t.directory,name:(o=t.properties)==null?void 0:o.name});const s=od.get(e),r=((s==null?void 0:s.catch(()=>{}))??Promise.resolve()).then(async()=>{await n(e)});od.set(e,r),await r.finally(()=>{od.get(e)===r&&od.delete(e)})}function qg(e){return ym().get(e)??null}function Zo(e){return ko(e).find(t=>t.slug==="root"&&t.directoryOnly)}async function MH(e,t,n="root"){if(!e)throw new Error("Missing instanceId");const s=(t??"").trim();if(!s)throw new Error("Worktree name is required");return kt.createWorktree(e,{slug:s,fromSlug:n})}async function AH(e,t,n,s=r=>ls(async()=>{const{fetchSessions:o}=await Promise.resolve().then(()=>OC);return{fetchSessions:o}},void 0).then(({fetchSessions:o})=>o(r,{reset:!0,strictStatus:!0}))){if(!e)throw new Error("Missing instanceId");const r=(t??"").trim();if(!r||r==="root")throw new Error("Invalid worktree");let o;try{await kt.deleteWorktree(e,r,n)}catch(l){o=l}const a=[()=>wi(e),()=>s(e)],c=(await Promise.allSettled(a.map(l=>l()))).flatMap((l,d)=>l.status==="rejected"?[d]:[]);if(c.length){const l=await Promise.allSettled(c.map(d=>a[d]()));for(const d of l)d.status==="rejected"&&ma.warn("Failed to refresh after worktree deletion",{instanceId:e,slug:r,error:d.reason})}if(o)throw o}function ko(e){return du().get(e)??[]}function by(e,t){return(t??"").trim()||"root"}function DH(e){return by(e,"root")}function p_(e,t){var n;return((n=Ia(e,t))==null?void 0:n.id)??t}function uu(e){return zs(e)}function PL(e,t){var r,o,a;const n=(o=(r=Ne().get(e))==null?void 0:r.get(t))==null?void 0:o.location.directory,s=n&&((a=ko(e).find(i=>uu(i.serviceDirectory??i.directory)===uu(n)))==null?void 0:a.slug);return s?by(e,s):"root"}function PH(e,t){return PL(e,t)}function p0(e){return vm.get(e)}function IH(e,t){return AL().get(`${e}:${p_(e,t)}`)}async function RH(e,t,n,s={}){var m,w;await Xi(e);const r=p_(e,t),o=by(e,n),a=ko(e).find(S=>S.slug===o);if(!a)throw new Error(`Worktree not found: ${o}`);const i=(w=(m=Ne().get(e))==null?void 0:m.get(r))==null?void 0:w.location.directory,c=a.serviceDirectory??a.directory;if(i&&uu(i)===uu(c))return;const l=`${e}:${r}`,d=id.get(l),u=s.moveFamily??((S,b,v)=>kt.moveSessionFamily(S,b,{worktreeSlug:v})),f=s.refreshSessions??(S=>ls(async()=>{const{fetchSessions:b}=await Promise.resolve().then(()=>OC);return{fetchSessions:b}},void 0).then(({fetchSessions:b})=>b(S,{reset:!0,strictStatus:!0}))),g=((d==null?void 0:d.catch(()=>{}))??Promise.resolve()).then(async()=>{let S;try{await u(e,r,o)}catch(b){S=b}try{await f(e)}catch{await f(e).catch(b=>{ma.warn("Failed to refresh sessions after family move",{instanceId:e,rootSessionId:r,error:b})})}if(S)throw ma.warn("Failed to move session family",{instanceId:e,rootSessionId:r,error:S}),Hn({message:$e("sessionList.worktreeMove.error"),variant:"error"}),S});id.set(l,g),m0(S=>new Map(S).set(l,o)),await g.finally(()=>{id.get(l)===g&&(id.delete(l),m0(S=>{const b=new Map(S);return b.delete(l),b}))})}function y0(e,t,n){const s=new Set([t,...n.flatMap(i=>[i.directory,i.serviceDirectory??i.directory])].map(zs).filter(Boolean)),r=new Map(e.map(i=>[i.id,i])),o=i=>{const c=new Set;for(;i.parentID&&r.has(i.parentID)&&!c.has(i.id);)c.add(i.id),i=r.get(i.parentID);return i.id},a=new Set(e.filter(i=>s.has(zs(i.location.directory))).map(o));return e.filter(i=>a.has(o(i)))}const[Sy,y_]=R(new Map),ky=(e,t)=>`${e}:${t}`;function $l(e,t,n){const s=ky(e,t);y_(r=>{const o=new Map(r);return n?o.set(s,n):o.delete(s),o})}function xy(e,t){var n;return((n=Sy().get(ky(e,t)))==null?void 0:n.values)??[]}function v_(e){const t=`${e}:`;return[...Sy()].filter(([n])=>n.startsWith(t)).map(([n,s])=>[n.slice(t.length),s])}function OH(e){return e?Object.fromEntries(v_(e).filter(([,t])=>t.values.length>0).map(([t,n])=>[t,[...n.values]])):{}}function LH(e){return e?new Set(v_(e).filter(([,t])=>t.authoritative).map(([t])=>t)):new Set}function NH(e,t,n){$l(e,t,{values:[...xy(e,t),n],authoritative:!0})}function FH(e,t,n){$l(e,t,{values:xy(e,t).filter(s=>s.id!==n),authoritative:!0})}function BH(e,t){$l(e,t,{values:[],authoritative:!0})}function IL(e,t){$l(e,t)}function UH(e,t,n){var s;$l(e,t,{values:[...n],authoritative:((s=Sy().get(ky(e,t)))==null?void 0:s.authoritative)??!1})}function RL(e,t=!1){if(!e)return;const n=`${e}:`;y_(s=>{const r=new Map(s);for(const[o,a]of r)o.startsWith(n)&&(t&&a.authoritative?r.set(o,{...a,values:[]}):r.delete(o));return r})}function OL(e){return`/workspaces/${encodeURIComponent(e)}/instance`}function $t(e){return fa.createClient(e,OL(e),()=>Ds()===e)}function LL(e){return e?{directory:e}:{}}function Io(e){return e.directory?{directory:e.directory}:{}}function bf(e){if(!(!("workspaceID"in e)||e.workspaceID===void 0)){if(typeof e.workspaceID!="string"||!e.workspaceID.trim())throw new Error("Invalid native location identity");return e.workspaceID}}function Bs(e){return JSON.stringify([e.directory,bf(e)])}function Zt(e,t){var s;if(!e)return;const n=bf(e);if(!(n===void 0&&!(t!=null&&t.includeDirectory))){if(!((s=e.directory)!=null&&s.trim()))throw new Error("Missing native location directory");return{headers:{"x-codenomad-location":encodeURIComponent(JSON.stringify({directory:e.directory,workspaceID:n}))}}}}function NL(e,t){var r;const n=[LL(e)],s=new Set(n.map(Bs));for(const o of t){const a=(r=o.directory)==null?void 0:r.trim();if(!a)continue;const i={directory:a,...o.workspaceID===void 0?{}:{workspaceID:o.workspaceID}},c=Bs(i);s.has(c)||(s.add(c),n.push(i))}return n}const Dc=32e3;function Nn(e){var r,o;const t=Fe().get(e),n=es().get(e);return(n&&n!=="info"?(o=(r=Ne().get(e))==null?void 0:r.get(n))==null?void 0:o.location:void 0)??{directory:(t==null?void 0:t.folder)??""}}function pa(e,t){if(!(t!=null&&t.providerId)||!t.modelId)return!1;const s=(Ti().get(e)||[]).find(r=>r.id===t.providerId);return s?s.models.some(r=>r.id===t.modelId):!1}function FL(e){const t=uM().models.recents??[];for(const n of t)if(pa(e,n))return n}async function Sf(e,t){const n=Ti().get(e)||[],s=Rv().get(e)||[],r=t?ZO(s,t):"";if(r){const a=s.find(c=>c.id===r);if(a&&a.model&&pa(e,a.model))return{providerId:a.model.providerId,modelId:a.model.modelId};const i=await dM(e,r);if(pa(e,i))return i}const o=FL(e);if(o)return o;for(const a of n)if(a.defaultModelId){const i=a.models.find(c=>c.id===a.defaultModelId);if(i)return{providerId:a.id,modelId:i.id}}if(n.length>0){const a=n[0],i=a.models[0];if(i)return{providerId:a.id,modelId:i.id}}if(!n.some(a=>a.models.length>0)){const a=Fe().get(e);if(a!=null&&a.client){const i=await $t(e).model.default({location:Io(Nn(e))},Zt(Nn(e))).catch(()=>null);if(i!=null&&i.data)return{providerId:i.data.providerID,modelId:i.data.id}}}return{providerId:"",modelId:""}}const BL={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",sh:"bash",bash:"bash",json:"json",html:"html",css:"css",md:"markdown",yaml:"yaml",yml:"yaml",sql:"sql",rs:"rust",go:"go",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",h:"cpp",c:"c",java:"java",cs:"csharp",php:"php",rb:"ruby",swift:"swift",kt:"kotlin"};function KH(e){var n;if(!e)return;const t=(n=e.split(".").pop())==null?void 0:n.toLowerCase();return t?BL[t]:void 0}function ea(e){if(!e.includes("&"))return e;const t=/&(#x?[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]+);/g,n={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};let s=e,r="";for(;s.includes("&")&&s!==r;)r=s,s=s.replace(t,(o,a)=>{var c;if(!a)return o;if(a[0]==="#"){const d=((c=a[1])==null?void 0:c.toLowerCase())==="x"?parseInt(a.slice(2),16):parseInt(a.slice(1),10);if(!Number.isNaN(d))try{return String.fromCodePoint(d)}catch{return o}return o}const i=n[a.toLowerCase()];return i!==void 0?i:o});return s}function VH(e){const t={"&":"&","<":"<",'"':""","'":"'"};return e.replace(/[&<"']/g,n=>t[n])}function UL(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="file"&&typeof t.mime=="string"&&/^image\//i.test(t.mime)&&typeof t.uri=="string"}function jH(e){if(/^data:/i.test(e.uri))return e.uri.slice(0,e.uri.indexOf(",")+1).toLowerCase()===`data:${e.mime.toLowerCase()};base64,`?e.uri:void 0;try{const t=new URL(e.uri);if((t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password)return e.uri}catch{}}function Dd(e){if(typeof e=="string")return ea(e);if(e&&typeof e=="object"){const t={...e};return typeof t.text=="string"&&(t.text=ea(t.text)),typeof t.value=="string"&&(t.value=ea(t.value)),Array.isArray(t.content)&&(t.content=t.content.map(n=>Dd(n))),t}return e}function ad(e){if(!e||typeof e!="object")return e;if(e.type==="tool"&&(typeof e.id!="string"||e.id.length===0))throw new Error("Tool part missing id");if(e.type!=="text"&&e.type!=="reasoning")return e;const t={...e,renderCache:void 0};if(typeof t.text=="string")t.text=ea(t.text);else if(t.text&&typeof t.text=="object"){const n={...t.text};typeof n.value=="string"&&(n.value=ea(n.value)),Array.isArray(n.content)&&(n.content=n.content.map(s=>Dd(s))),typeof n.text=="string"&&(n.text=ea(n.text)),t.text=n}if(Array.isArray(t.content)&&(t.content=t.content.map(n=>Dd(n))),t.thinking&&typeof t.thinking=="object"){const n={...t.thinking};Array.isArray(n.content)&&(n.content=n.content.map(s=>Dd(s))),t.thinking=n}return t}function v0(e){return{...e,name:e.type==="aborted"?"MessageAbortedError":e.type,data:{message:e.message}}}function KL(e){return e.type==="idle"?e.outcome==="failed"||e.outcome==="interrupted"?"error":"complete":e.type==="assistant"?e.error?"error":e.time.completed?"complete":"streaming":e.type==="compaction"?e.status==="failed"?"error":e.status==="running"?"sent":"complete":e.type==="shell"?e.status==="running"?"sent":e.status==="exited"&&(e.exit===void 0||e.exit===0)?"complete":"error":"complete"}function VL(e){return Array.isArray(e)?e.filter(n=>(n==null?void 0:n.type)==="text"&&typeof n.text=="string").map(n=>n.text).join(`
|
|
15
15
|
`)||e.filter(n=>!UL(n)):e}function kf(e,t){var a,i,c,l;const n=t.type==="assistant"?t:void 0,s=t.type==="user"?"user":"assistant",r={nativeType:t.type,id:t.id,sessionID:e,role:s,time:t.type==="idle"?{...t.time,completed:t.time.created}:t.time,...n?{mode:n.agent,agent:n.agent,providerID:(a=n.model)==null?void 0:a.providerID,modelID:(i=n.model)==null?void 0:i.id,variant:(c=n.model)==null?void 0:c.variant,cost:n.cost,tokens:n.tokens,error:n.error?v0(n.error):void 0}:{},...t.type==="compaction"&&t.status==="failed"?{error:v0(t.error)}:{},...t.type==="user"?{text:t.text}:{}};let o;if(t.type==="assistant")o=t.content.map((d,u)=>{if(d.type!=="tool")return ad({...d,id:`${t.id}-${d.type}-${u}`,sessionID:e,messageID:t.id});const f=d.state,g=f.status==="streaming"?{status:"pending"}:{...f,...f.status==="completed"?{output:VL(f.content)}:{},...f.status==="error"?{error:f.error.message}:{}};return{id:d.id,type:"tool",tool:d.name,callID:d.id,sessionID:e,messageID:t.id,time:d.time,state:g}}),o.length===0&&t.error&&(o=[ad({id:`${t.id}-error`,type:"text",text:"",sessionID:e,messageID:t.id})]);else if(t.type==="user")o=[ad({id:`${t.id}-text`,type:"text",text:t.text,sessionID:e,messageID:t.id}),...(t.files??[]).map((d,u)=>({id:`${t.id}-file-${u}`,type:"file",url:d.source.type==="uri"?d.source.uri:`data:${d.mime};base64,${d.data}`,mime:d.mime,filename:d.name,sessionID:e,messageID:t.id}))];else if(t.type==="system")o=[{id:t.id,type:"system",text:t.text,description:t.description,sessionID:e,messageID:t.id}];else if(t.type==="idle")o=[];else if(t.type==="compaction")o=[{id:t.id,type:"compaction",auto:t.reason==="auto",text:"summary"in t?t.summary:t.error.message,...t.status==="completed"?{model:t.model,providerState:t.providerState}:{},sessionID:e,messageID:t.id}];else{const d="text"in t?t.text:t.type==="shell"?((l=t.output)==null?void 0:l.output)??t.command:t.type;o=[ad({id:t.id,type:"text",text:d,synthetic:!0,sessionID:e,messageID:t.id})]}return{info:r,message:{id:t.id,sessionId:e,type:s,parts:o,timestamp:t.time.created,status:KL(t),version:0}}}var JS;const zg=(JS=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength"))==null?void 0:JS.get;var QS;const Wg=(QS=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"resizable"))==null?void 0:QS.get,w_=24,b_=16;function fu(e){try{return{bytes:zg==null?void 0:zg.call(e),growable:!!(Wg!=null&&Wg.call(e))}}catch{return}}function Cl(e,t=Number.POSITIVE_INFINITY){const n=new WeakSet,s=[e],r=[];let o=0;for(;(s.length>0||r.length>0)&&o<=t;){if(s.length===0){const i=r[r.length-1].next();if(i.done){r.pop();continue}if(o+=i.value.keyBytes,o>t)break;s.push(i.value.value)}const a=s.pop();if(typeof a=="string")o+=a.length*2+16;else if(typeof a=="number"||typeof a=="bigint")o+=8;else if(typeof a=="boolean")o+=4;else if(a&&typeof a=="object"){if(ArrayBuffer.isView(a)){if(n.has(a.buffer))continue;n.add(a.buffer);const c=fu(a.buffer);o+=c!=null&&c.growable?t+1:(c==null?void 0:c.bytes)??a.byteLength;continue}if(n.has(a))continue;n.add(a);const i=fu(a);if(i!==void 0){o+=i.growable?t+1:i.bytes;continue}o+=Array.isArray(a)?24+a.length*8:a instanceof Map?32+a.size*w_:a instanceof Set?32+a.size*b_:32,o<=t&&r.push(S_(a))}}return o}function qH(e,t){return Cl(e,t)>t}async function jL(e,t={}){var u,f,g,m;const n=new WeakSet,s=[],r=[],o=t.rootIterable?e[Symbol.iterator]():void 0;o||s.push(e);const a=Math.max(1,t.yieldEvery??500),i=t.maxBytes??Number.POSITIVE_INFINITY,c=t.maxNodes??Number.POSITIVE_INFINITY;let l=0,d=0;for(;s.length>0||r.length>0||o;){if((u=t.signal)==null||u.throwIfAborted(),s.length===0){const S=(f=r[r.length-1])==null?void 0:f.next();if(S&&!S.done){if(d+=S.value.keyBytes,d>i)return Number.POSITIVE_INFINITY;s.push(S.value.value)}else if(S){r.pop();continue}else{const b=o.next();if(b.done)break;s.push(b.value)}}if(++l>c)return Number.POSITIVE_INFINITY;l%a===0&&(await new Promise(S=>setTimeout(S,0)),(g=t.signal)==null||g.throwIfAborted());const w=s.pop();if(typeof w=="string")d+=w.length*2+16;else if(typeof w=="number"||typeof w=="bigint")d+=8;else if(typeof w=="boolean")d+=4;else if(w&&typeof w=="object"){if(ArrayBuffer.isView(w)){if(n.has(w.buffer))continue;n.add(w.buffer);const b=fu(w.buffer);d+=b!=null&&b.growable?Number.POSITIVE_INFINITY:(b==null?void 0:b.bytes)??w.byteLength;continue}if(n.has(w))continue;n.add(w);const S=fu(w);if(S!==void 0){d+=S.growable?Number.POSITIVE_INFINITY:S.bytes;continue}d+=Array.isArray(w)?24+w.length*8:w instanceof Map?32+w.size*w_:w instanceof Set?32+w.size*b_:32,r.push(S_(w))}if(d>i)return Number.POSITIVE_INFINITY}return(m=t.signal)==null||m.throwIfAborted(),d}function*S_(e){if(e instanceof Map)for(const[t,n]of e)yield{value:t,keyBytes:0},yield{value:n,keyBytes:0};else if(e instanceof Set)for(const t of e)yield{value:t,keyBytes:0};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(yield{value:e[t],keyBytes:t.length*2+8})}const wm="GLOBAL",k_=64,w0=4*1024*1024,qL=32*1024*1024,x_=4096,cs=new Map;let _y=0,zL=0;const eo=new Map,bm=new WeakMap,Sm=new Set;let to=0,no=0,__=0;function $y(){to=0,no=0;for(const e of cs.values())for(const t of e.values())for(const n of t.values())for(const s of n.values())to+=s.byteSize,no+=1}function Tn(e){return e&&e.length>0?e:wm}function Cy(e,t,n,s){return`${e}\0${t}\0${n}\0${s}`}function xf(){_y+=1,eo.clear()}function gu(e,t,n,s){eo.delete(Cy(e,t,n,s))}function Pd(e){if(!(!e.instanceId||!e.sessionId))for(const t of Sm)t(e.instanceId,e.sessionId)}function zH(e){return Sm.add(e),()=>Sm.delete(e)}function*WL(e,t){var s;const n=(s=cs.get(Tn(e)))==null?void 0:s.get(Tn(t));if(n)for(const r of n.values())for(const o of r.values())yield{value:o.value,keyBytes:o.keyBytes}}function b0(e){const t=Tn(e.instanceId),n=Tn(e.sessionId),s=`${t}\0${n}\0${e.scope}\0`,r=Cy(t,n,e.scope,e.cacheId),o=[...eo.keys()].filter(c=>c.startsWith(s)&&c!==r);o.length>=k_&&eo.delete(o[0]),eo.size>=x_&&!eo.has(r)&&xf();const a=++zL;eo.set(r,a);const i={instanceKey:t,sessionKey:n,scope:e.scope,cacheId:e.cacheId,version:e.version,generation:_y,writeToken:a};return bm.set(e,i),i}function HL(e,t){const n=Tn(e.instanceId),s=Tn(e.sessionId);return n===t.instanceKey&&s===t.sessionKey&&e.scope===t.scope&&e.cacheId===t.cacheId&&e.version===t.version&&_y===t.generation&&eo.get(Cy(n,s,e.scope,e.cacheId))===t.writeToken}function Id(e,t){const n=Tn(e.instanceId),s=Tn(e.sessionId);let r=cs.get(n);if(!r){if(!t)return;r=new Map,cs.set(n,r)}let o=r.get(s);if(!o){if(!t)return;o=new Map,r.set(s,o)}let a=o.get(e.scope);if(!a){if(!t)return;a=new Map,o.set(e.scope,a)}return a}function hu(e,t,n){const s=cs.get(e);if(!s)return;const r=s.get(t);if(!r){s.size===0&&cs.delete(e);return}if(n){const o=r.get(n);o&&o.size===0&&r.delete(n)}r.size===0&&s.delete(t),s.size===0&&cs.delete(e)}function GL(){var t,n,s;let e;for(const[r,o]of cs)for(const[a,i]of o)for(const[c,l]of i)for(const[d,u]of l)(!e||u.accessedAt<e.entry.accessedAt)&&(e={instanceKey:r,sessionKey:a,scope:c,cacheId:d,entry:u});return e?((s=(n=(t=cs.get(e.instanceKey))==null?void 0:t.get(e.sessionKey))==null?void 0:n.get(e.scope))==null||s.delete(e.cacheId),to-=e.entry.byteSize,no-=1,gu(e.instanceKey,e.sessionKey,e.scope,e.cacheId),hu(e.instanceKey,e.sessionKey,e.scope),e.instanceKey!==wm&&e.sessionKey!==wm&&Pd({instanceId:e.instanceKey,sessionId:e.sessionKey,scope:e.scope}),!0):!1}function WH(e,t,n){var u;const s=Tn(e.instanceId),r=Tn(e.sessionId),o=n??bm.get(e);if(bm.delete(e),o&&!HL(e,o))return;if(gu(s,r,e.scope,e.cacheId),t===void 0){const f=Id(e,!1),g=f==null?void 0:f.get(e.cacheId);to-=(g==null?void 0:g.byteSize)??0,g&&(no-=1),f==null||f.delete(e.cacheId),hu(s,r,e.scope),g&&Pd(e);return}const a=Id(e,!1),i=a==null?void 0:a.get(e.cacheId);to-=(i==null?void 0:i.byteSize)??0,i&&(no-=1),a==null||a.delete(e.cacheId);const c=[e.instanceId,e.sessionId,e.scope,e.cacheId,e.version].reduce((f,g)=>f+((g==null?void 0:g.length)??0)*2+16,0),l=Cl(t,w0)+c;if(l>w0){a==null||a.delete(e.cacheId),hu(s,r,e.scope),i&&Pd(e);return}for(;(to+l>qL||no>=x_)&&GL(););const d=Id(e,!0);if(d){for(d.delete(e.cacheId),d.set(e.cacheId,{version:e.version,value:t,byteSize:l,keyBytes:c,accessedAt:++__}),to+=l,no+=1;d.size>k_;){const f=d.keys().next().value;if(f===void 0)break;to-=((u=d.get(f))==null?void 0:u.byteSize)??0,d.delete(f),no-=1,gu(s,r,e.scope,f)}Pd(e)}}function HH(e){const t=Id(e,!1),n=t==null?void 0:t.get(e.cacheId);if(!n||n.version!==e.version){b0(e);return}return gu(Tn(e.instanceId),Tn(e.sessionId),e.scope,e.cacheId),t.delete(e.cacheId),n.accessedAt=++__,t.set(e.cacheId,n),b0(e),n.value}function GH(e){const t=Tn(e.instanceId),n=Tn(e.sessionId);xf();const s=cs.get(t);if(!s)return;const r=s.get(n);r&&(r.delete(e.scope),hu(t,n),$y())}function km(e,t){const n=Tn(e),s=Tn(t);xf();const r=cs.get(n);r&&(r.delete(s),r.size===0&&cs.delete(n),$y())}function mu(e){const t=Tn(e);xf(),cs.delete(t),$y()}const ji="codenomad:prompt-display:v3",S0="codenomad:prompt-display:v2",ZL=512,YL=1024*1024,k0=64*1024;let x0=!1;const Gn=new Map,pu=new Map;let yu=0;function $_(){var t;const e=typeof window>"u"?"":(t=window.__CODENOMAD_WINDOW_ID__)==null?void 0:t.trim();return e?`${ji}:${e}`:ji}function Zc(e,t,n){return`${t}:${n}`}function JL(e){const t=e.indexOf(":");if(t<=0)return!1;const n=e.indexOf(":",t+1);return n>t+1&&n<e.length-1}function QL(e){return JL(e)?e.slice(e.indexOf(":")+1):e}function C_(){return typeof window>"u"||!window.localStorage?null:window.localStorage}function Wa(){if(x0)return;x0=!0;const e=C_();if(e)try{const t=$_(),n=e.getItem(t);n&&Hg(JSON.parse(n),!1);const s=t!==ji&&!n,r=s?e.getItem(ji):null;r&&Hg(JSON.parse(r),!1);const o=t===ji||s?e.getItem(S0):null;if(o&&Hg(JSON.parse(o),!0),!r&&!o||!Ha())return;r&&e.removeItem(ji),o&&e.removeItem(S0)}catch{Gn.clear(),pu.clear(),yu=0}}function Hg(e,t){for(const[n,s]of Object.entries(e))E_(s)&&Ey(t?QL(n):n,s)}function ai(e){const t=pu.get(e);return t===void 0?!1:(yu-=t,pu.delete(e),Gn.delete(e),!0)}function Ey(e,t){const n=e.length*2+Cl(t,k0);if(n>k0)return!1;for(ai(e),Gn.set(e,t),pu.set(e,n),yu+=n;Gn.size>ZL||yu>YL;){const s=Gn.keys().next().value;if(s===void 0)break;ai(s)}return Gn.has(e)}function Ha(){const e=C_();if(!e)return!1;try{return e.setItem($_(),JSON.stringify(Object.fromEntries(Gn))),!0}catch{return!1}}function E_(e){if(!e||typeof e!="object")return!1;const t=e.segments;return!Array.isArray(t)||t.length===0?!1:t.every(n=>n&&typeof n=="object"&&(n.kind==="inline"||n.kind==="pasted")&&typeof n.length=="number"&&n.length>=0)}function XL(e,t,n){Wa();const s=Zc(e,t,n),r=Gn.get(s);return r&&(Gn.delete(s),Gn.set(s,r)),r}function _0(e,t,n,s){Wa();const r=Zc(e,t,n),o=Gn.get(r);if(s&&E_(s)){const a=JSON.stringify(s);if(o&&JSON.stringify(o)===a||!Ey(r,s))return}else if(!ai(r))return;Ha()}function eN(e,t,n,s){Wa();const r=Zc(e,t,n),o=Gn.get(r);if(!o)return;const a=Zc(e,t,s);r!==a&&Ey(a,o)&&(ai(r),Ha())}function Gg(e,t,n){Wa(),ai(Zc(e,t,n))&&Ha()}function tN(e,t){Wa();const n=`${t}:`,s=`${e}:${t}:`;let r=!1;for(const o of Gn.keys())(o.startsWith(n)||o.startsWith(s))&&(ai(o),r=!0);r&&Ha()}function nN(e,t=[]){Wa();let n=!1;for(const s of Gn.keys()){const r=t.some(a=>s.startsWith(`${a}:`)),o=s.startsWith(`${e}:`);(r||o)&&(ai(s),n=!0)}n&&Ha()}const ya=new Map,sN=1e4,rN=1e3;function oN(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.array)&&typeof t.index=="number"}function $0(e,t,n){const s=[],r=[e],o=new WeakSet;let a=0,i=0;for(;r.length>0&&a<t&&i<n;){const c=r.pop();if(i+=1,oN(c)){if(c.index>=c.array.length)continue;r.push({array:c.array,index:c.index+1},c.array[c.index]);continue}if(typeof c=="string"){const d=s.length>0?1:0,u=t-a-d;if(u<=0)break;const f=c.slice(0,u);if(/\S/.test(f)&&(s.push(f),a+=f.length+d),f.length<c.length)break;continue}if(!c||typeof c!="object"||o.has(c))continue;if(o.add(c),Array.isArray(c)){r.push({array:c,index:0});continue}const l=c;r.push(l.content,l.value,l.text)}return s.join(`
|
|
16
16
|
`)}function T_(e,t,n){const s=e;return!s||typeof s!="object"?"":$0(s.text,t,n)||$0(s.content,t,n)}function iN(e){return T_(e,sN,rN)}function ZH(e){return T_(e,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}function Ty(e,t){return`${e}:${t}`}function YH(e,t){const n=Ty(e,t);let s=ya.get(n);return s||(s={messageItems:new Map,toolItems:new Map,messageBlocks:new Map},ya.set(n,s)),s}function aN(e,t){return ya.get(Ty(e,t))}function cN(e,t){ya.delete(Ty(e,t))}function lN(e){const t=`${e}:`;for(const n of ya.keys())n.startsWith(t)&&ya.delete(n)}function JH(e,t){const n=new Set(t);for(const s of n)e.messageBlocks.delete(s);for(const[s,r]of e.messageItems)n.has(r.messageId)&&e.messageItems.delete(s);for(const[s,r]of e.toolItems)n.has(r.messageId)&&e.toolItems.delete(s)}const va=new Map,Rd=200;function My(e,t){return`${e}:${t}`}function dN(e){if(e.partIds.length<=Rd)return e.partIds;const t=Math.floor(Rd/2);return[...e.partIds.slice(0,t),...e.partIds.slice(-(Rd-t))]}function QH(e,t){const n=My(e,t.id),s=va.get(n);if(s&&s.revision===t.revision)return s.data;const r=[],o=dN(t);for(const i of o){const c=t.parts[i];if(!(c!=null&&c.data))continue;const l=c.data;if(l.type==="reasoning"){const d=l.time;r.push({id:l.id,type:"reasoning",text:iN(l),time:d?{start:d.start,end:d.end,created:d.created}:void 0,revision:c.revision});continue}r.push({...l,revision:c.revision})}const a={orderedParts:r,truncated:t.partIds.length>Rd};return va.set(n,{revision:t.revision,data:a}),a}function uN(e){const t=`${e}:`;for(const n of va.keys())n.startsWith(t)&&va.delete(n)}function ac(e,t){for(const n of t)typeof n!="string"||n.length===0||va.delete(My(e,n))}function*fN(e,t){for(const n of t){const s=va.get(My(e,n));s&&(yield s)}}function gN(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function hN(e){const t=e.existing;return!!(t&&e.existingAtLocationId===e.incomingId&&e.activeId===e.expectedActiveId&&t.messageId===e.incomingMessageId&&t.partId===e.incomingPartId&&t.enqueuedAt===e.incomingEnqueuedAt&&gN(e.existingValue,e.incomingValue))}const mN=Ut("session");function C0(e){return{instanceId:e,sessions:{},sessionOrder:[],messages:{},lastAssistantMessageIds:{},messageInfoVersion:{},pendingParts:{},sessionRevisions:{},permissions:{queue:[],active:null,byMessage:{}},usage:{},scrollState:{},latestTodos:{}}}function E0(e,t,n){if(typeof t.id=="string"&&t.id.length>0)return t.id;if(t.type==="tool")throw new Error("Tool part missing id");const s=`${e}-part-${n}`;return t.id=s,s}const pN=3e4,T0=100,yN=100,vN=500,xm=1024*1024,wN=4*1024*1024,_m=8*1024*1024,bN=500,M0=64*1024*1024,SN=5e5,M_=Symbol("pendingPartRetainedBytes"),Od=Symbol("pendingPartBudgetId");let kN=0;const $r=new Map;function xN(e){return e[M_]??Cl(e,xm)}function Ri(e){const t=e[Od];t!==void 0&&$r.delete(t)}function _N(){for(const[n,s]of $r)s.isRetained()||$r.delete(n);let e=0;for(const n of $r.values())e+=n.bytes;if(e<=_m)return;const t=[...$r.entries()].sort((n,s)=>n[1].receivedAt-s[1].receivedAt||n[0]-s[0]);for(const[n,s]of t){if(e<=_m)break;$r.delete(n),e-=s.bytes,s.remove()}}function $N(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function $m(){return{entries:{},totalInputTokens:0,totalOutputTokens:0,totalReasoningTokens:0,totalCost:0,actualUsageTokens:0,latestMessageId:void 0}}function A0(e,t,n){if(t.clientPromptDisplayMetadata)return t.clientPromptDisplayMetadata;const s=XL(e,t.sessionId,t.id);return s||(n==null?void 0:n.clientPromptDisplayMetadata)}function A_(e){var l,d,u;if(!e||e.role!=="assistant")return null;const t=typeof e.id=="string"?e.id:void 0;if(!t)return null;const n=e.tokens;if(!n)return null;const s=n.input??0,r=n.output??0,o=n.reasoning??0,a=((l=n.cache)==null?void 0:l.read)??0,i=((d=n.cache)==null?void 0:d.write)??0;if(s===0&&r===0&&o===0&&a===0&&i===0)return null;const c=e.summary?r:s+a+i+r+o;return{messageId:t,inputTokens:s,outputTokens:r,reasoningTokens:o,cacheReadTokens:a,cacheWriteTokens:i,combinedTokens:c,cost:e.cost??0,timestamp:((u=e.time)==null?void 0:u.created)??0,hasContextUsage:s+a+i>0}}function D_(e,t){var n;t&&(e.entries[t.messageId]=t,e.totalInputTokens+=t.inputTokens,e.totalOutputTokens+=t.outputTokens,e.totalReasoningTokens+=t.reasoningTokens,e.totalCost+=t.cost,(!e.latestMessageId||t.timestamp>=(((n=e.entries[e.latestMessageId])==null?void 0:n.timestamp)??0))&&(e.latestMessageId=t.messageId,e.actualUsageTokens=t.combinedTokens))}function D0(e,t){if(!t)return;const n=e.entries[t];if(n&&(e.totalInputTokens-=n.inputTokens,e.totalOutputTokens-=n.outputTokens,e.totalReasoningTokens-=n.reasoningTokens,e.totalCost-=n.cost,delete e.entries[t],e.latestMessageId===t)){e.latestMessageId=void 0,e.actualUsageTokens=0;let s=null;for(const r of Object.values(e.entries))(!s||r.timestamp>=s.timestamp)&&(s=r);s&&(e.latestMessageId=s.messageId,e.actualUsageTokens=s.combinedTokens)}}function P0(e){const t=$m();for(const n of e){const s=A_(n);s&&D_(t,s)}return t}function CN(e,t){const[n,s]=Ep(C0(e)),r="todowrite",o=new Map,a=new Set,i=new Set,c=new Map;function l(x){a.delete(x),c.delete(x)}function d(x){return a.has(x)}function u(x){var A;for(let L=x.length-1;L>=0;L-=1){const X=x[L];if(((A=n.messages[X])==null?void 0:A.role)==="assistant")return X}}function f(x,A){var L;x&&s("lastAssistantMessageIds",x,u(A??((L=n.sessions[x])==null?void 0:L.messageIds)??[]))}function g(x){var L,X;if(!x)return-1;const A=((L=n.sessions[x])==null?void 0:L.messageIds)??[];for(let Y=A.length-1;Y>=0;Y--){const ue=A[Y],ce=n.messages[ue];if(!(!ce||!Array.isArray(ce.partIds)||ce.partIds.length===0))for(const ve of ce.partIds){const je=(X=ce.parts[ve])==null?void 0:X.data;if((je==null?void 0:je.type)==="compaction")return Y}}return-1}function m(x){if(!x||x.type!=="tool"||(typeof x.tool=="string"?x.tool:"")!==r)return!1;const L=x.state;return!L||typeof L!="object"?!1:L.status==="completed"}function w(x,A){x&&s("latestTodos",x,L=>L&&L.timestamp>A.timestamp?L:A)}function S(x){if(!(!x||!Array.isArray(x.partIds)||x.partIds.length===0))for(let A=x.partIds.length-1;A>=0;A-=1){const L=x.partIds[A],X=x.parts[L];if(X&&m(X.data)){const Y=typeof x.updatedAt=="number"?x.updatedAt:Date.now();w(x.sessionId,{messageId:x.id,partId:L,timestamp:Y});break}}}function b(x){s("latestTodos",x,void 0)}function v(x){var X;const A=n.latestTodos[x];return A&&(((X=n.sessions[x])==null?void 0:X.messageIds)??[]).indexOf(A.messageId)>g(x)?A:void 0}function k(x){var A;x&&(s("sessionRevisions",x,(L=0)=>L+1),(A=t==null?void 0:t.onSessionChanged)==null||A.call(t,e,x))}function C(x){return n.sessionRevisions[x]??0}function _(x){return n.lastAssistantMessageIds[x]}function T(x,A){s("usage",x,L=>{const X=L?{...L,entries:{...L.entries}}:$m();return A(X),X})}function P(x){if(!x||typeof x.sessionID!="string")return;const A=typeof x.id=="string"?x.id:void 0;A&&T(x.sessionID,L=>{D0(L,A);const X=A_(x);X&&D_(L,X)})}function I(x,A){const L=P0(A);s("usage",x,L)}function j(x){return n.usage[x]}function ne(x){var A;for(const L of((A=n.sessions[x])==null?void 0:A.messageIds)??[]){const X=n.messages[L];if(a.has(L)||(X==null?void 0:X.status)==="sending"||(X==null?void 0:X.status)==="streaming")return!0}return!1}function W(x){var A;for(const L of a)if(((A=n.messages[L])==null?void 0:A.sessionId)===x)return!0;return!1}function q(x,A){var je;const L=n.sessions[x],X=aN(e,x),Y=[...WL(e,x)],ue=Y.reduce((Ke,rt)=>Ke+rt.keyBytes,0);let ce=!1;for(const Ke in n.pendingParts)if((je=n.pendingParts[Ke])!=null&&je.some(rt=>rt.sessionId===x)){ce=!0;break}if((!L||L.messageIds.length===0&&!L.revert)&&!X&&!ce&&Y.length===0)return Promise.resolve(0);function*ve(){L&&(yield L);for(const Ke of(L==null?void 0:L.messageIds)??[])yield n.messages[Ke],yield o.get(Ke),yield n.messageInfoVersion[Ke],yield n.pendingParts[Ke];for(const Ke in n.pendingParts){const rt=n.pendingParts[Ke];rt!=null&&rt.some(ot=>ot.sessionId===x)&&!n.messages[Ke]&&(yield rt)}for(const Ke of n.permissions.queue)Ke.permission.sessionID===x&&(yield Ke);L&&(yield n.usage[x],yield n.sessionRevisions[x],yield n.lastAssistantMessageIds[x],yield n.latestTodos[x]),yield X,L&&(yield*fN(e,L.messageIds));for(const Ke of Y)yield Ke.value}return ue>M0?Promise.resolve(Number.POSITIVE_INFINITY):jL(ve(),{signal:A,rootIterable:!0,maxBytes:M0-ue,maxNodes:SN}).then(Ke=>Number.isFinite(Ke)?Ke+ue:Ke)}function U(x){const A=n.sessions[x];if(A)return A;const L=Date.now(),X={id:x,createdAt:L,updatedAt:L,messageIds:[]};return s("sessions",x,X),s("sessionOrder",Y=>Y.includes(x)?Y:[...Y,x]),X}function G(x){const A=U(x.id),L=[...A.messageIds],X=Array.isArray(x.messageIds)?x.messageIds:A.messageIds;s("sessions",x.id,{...A,title:x.title??A.title,parentId:x.parentId??A.parentId??null,updatedAt:Date.now(),messageIds:X,revert:x.revert!==void 0?x.revert:A.revert??null}),Array.isArray(x.messageIds)&&!$N(L,X)&&(f(x.id,X),k(x.id))}function le(x,A,L,X){if(!x||!A||x.length!==L.length)return!0;for(let Y=0;Y<L.length;Y++)if(x[Y]!==L[Y])return!0;for(const Y of L){const ue=A[Y],ce=X[Y];if(ue!==ce&&(!ue||!ce||JSON.stringify(ue.data)!==JSON.stringify(ce.data)))return!0}return!1}function K(x,A,L,X){var mt,qe,yt,it;if(!Array.isArray(A)||A.length===0)return;U(x);const Y=new Set,ue=(qe=(mt=n.sessions[x])==null?void 0:mt.revert)==null?void 0:qe.messageID,ce=A.filter(ye=>ue&&ye.id>=ue||Y.has(ye.id)?!1:(Y.add(ye.id),!0));for(const ye of ce)i.delete(ye.id);const ve=ce.map(ye=>ye.id),je=new Set(ve),Ke=new Set(ce.filter(ye=>ye.parts!==void 0).map(ye=>ye.id)),rt=((yt=n.sessions[x])==null?void 0:yt.messageIds)??[],ot=[],Pt=[];for(const ye of rt){if(je.has(ye))continue;n.messages[ye]&&d(ye)?ot.push(ye):Pt.push(ye)}const wn=[...X!=null&&X.preserveOmitted?Pt:[],...ve,...ot],zn={},Et=Date.now();ce.forEach(ye=>{const Ye=h(ye.id,ye.parts),ct=n.messages[ye.id],fn=Ye?le(ct==null?void 0:ct.partIds,ct==null?void 0:ct.parts,Ye.ids,Ye.map):!1,Ai=ct?ct.status!==ye.status:!0,HT=!!(ye.bumpRevision||fn||Ai),Mw=A0(e,ye,ct);zn[ye.id]={id:ye.id,sessionId:ye.sessionId,role:ye.role,status:ye.status,createdAt:ye.createdAt??(ct==null?void 0:ct.createdAt)??Et,updatedAt:ye.updatedAt??Et,isEphemeral:ye.isEphemeral??(ct==null?void 0:ct.isEphemeral)??!1,clientPromptDisplayMetadata:Mw,revision:ct?ct.revision+(HT?1:0):0,partIds:Ye?Ye.ids:(ct==null?void 0:ct.partIds)??[],parts:Ye?Ye.map:(ct==null?void 0:ct.parts)??{}},_0(e,ye.sessionId,ye.id,Mw)});const tn=ye=>!ue||ye.id<ue,J=L?Array.from(L).filter(tn):void 0,ie=X!=null&&X.preserveOmitted&&J?new Map([...Array.from(o.values()).filter(ye=>ye.sessionID===x&&tn(ye)).map(ye=>[ye.id,ye]),...J.map(ye=>[ye.id,ye])]).values():J,Oe=ie?P0(ie):n.usage[x],Le={...n.messages},Ce={...n.messageInfoVersion},ft={...n.pendingParts},bt={...n.permissions.byMessage};if(Object.entries(zn).forEach(([ye,Ye])=>{Le[ye]=Ye}),!(X!=null&&X.preserveOmitted)&&Pt.length>0&&(Pt.forEach(ye=>{var Ye;o.delete(ye),l(ye),Gg(e,x,ye),(Ye=ft[ye])==null||Ye.forEach(Ri),delete Le[ye],delete Ce[ye],delete ft[ye],delete bt[ye]}),ac(e,Pt),(it=t==null?void 0:t.onMessagesRemoved)==null||it.call(t,e,x,Pt)),(X==null?void 0:X.confirmPending)!==!1&&ve.forEach(ye=>{a.delete(ye),Ke.has(ye)&&c.delete(ye)}),J)for(const ye of J){const Ye=ye.id;if(!je.has(Ye))continue;const ct=o.get(Ye),fn=!ct||JSON.stringify(ct)!==JSON.stringify(ye);if(o.set(Ye,ye),fn){const Ai=Ce[Ye]??0;Ce[Ye]=Ai+1}}gn(()=>{s("messages",()=>Le),s("messageInfoVersion",()=>Ce),s("pendingParts",()=>ft),s("permissions","byMessage",()=>bt),!(X!=null&&X.preserveOmitted)&&Pt.length>0&&(s("messages",pt(ye=>{Pt.forEach(Ye=>{delete ye[Ye]})})),s("messageInfoVersion",pt(ye=>{Pt.forEach(Ye=>{delete ye[Ye]})})),s("pendingParts",pt(ye=>{Pt.forEach(Ye=>{delete ye[Ye]})})),s("permissions",pt(ye=>{const Ye=new Set(Pt);Pt.forEach(ct=>{delete ye.byMessage[ct]}),ye.queue=ye.queue.filter(ct=>!ct.messageId||!Ye.has(ct.messageId)),ye.active=ye.queue[0]??null}))),Oe&&s("usage",x,Oe),s("sessions",x,ye=>({...ye,messageIds:wn,updatedAt:Date.now()})),f(x,wn),b(x),wn.forEach(ye=>{S(Le[ye])}),k(x)})}function M(x,A,L){var Y;const X=(((Y=n.sessions[x])==null?void 0:Y.messageIds)??[]).filter(ue=>{var ce;return!L.has(ue)||A.has(ue)||((ce=n.messages[ue])==null?void 0:ce.revision)!==L.get(ue)});if(X.length===0){Ge(x);return}K(x,X.flatMap(ue=>{const ce=n.messages[ue];return ce?[{id:ce.id,sessionId:ce.sessionId,role:ce.role,status:ce.status,createdAt:ce.createdAt,updatedAt:ce.updatedAt,isEphemeral:ce.isEphemeral,parts:ce.partIds.flatMap(ve=>{var je;return((je=ce.parts[ve])==null?void 0:je.data)??[]}),bumpRevision:!1}]:[]}),X.flatMap(ue=>o.get(ue)??[]))}function N(x){if(!x)return;a.add(x);const A=n.messages[x];c.set(x,new Set((A==null?void 0:A.partIds)??[]))}function oe(x,A){const L=n.messages[x];!L||L.status!=="sending"&&!(A==="error"&&L.status==="sent")||(s("messages",x,pt(X=>{X.status=A,X.isEphemeral=A==="error",X.updatedAt=Date.now(),X.revision+=1})),k(L.sessionId))}function ge(x){oe(x,"sent")}function Ie(x,A){var ve;const L=c.get(x);a.delete(x),A!=null&&A.clearOptimisticParts&&c.delete(x);const X=n.messages[x];if(X&&((ve=t==null?void 0:t.onSessionChanged)==null||ve.call(t,e,X.sessionId)),!X)return;const Y=A!=null&&A.clearOptimisticParts&&X.role==="user"?X.partIds.filter(je=>L==null?void 0:L.has(je)):[],ue=X.role==="user"&&(X.status==="sending"||X.status==="error");(X.isEphemeral||Y.length>0||ue)&&(s("messages",x,pt(je=>{if(je.isEphemeral=!1,ue&&(je.status="sent"),Y.length>0){const Ke=new Set(Y);je.partIds=je.partIds.filter(rt=>!Ke.has(rt)),Y.forEach(rt=>{delete je.parts[rt]})}je.updatedAt=Date.now(),je.revision+=1})),k(X.sessionId))}function ke(x){a.has(x)&&(a.delete(x),oe(x,"error"))}function we(x){var A;for(const L of Array.from(a))((A=n.messages[L])==null?void 0:A.sessionId)===x&&ke(L)}function Ae(x){var L;let A=!1;for(const X of Array.from(a)){const Y=n.messages[X];(Y==null?void 0:Y.sessionId)===x&&Y.status==="sent"&&(a.delete(X),A=!0)}A&&((L=t==null?void 0:t.onSessionChanged)==null||L.call(t,e,x))}function Ge(x){var ue;const A=n.sessions[x];if(!A)return;const L=A.messageIds??[],X=[],Y=[];for(const ce of L)n.messages[ce]&&d(ce)?X.push(ce):Y.push(ce);Y.length!==0&&(Y.forEach(ce=>{var ve;o.delete(ce),l(ce),Gg(e,x,ce),(ve=n.pendingParts[ce])==null||ve.forEach(Ri)}),ac(e,Y),(ue=t==null?void 0:t.onMessagesRemoved)==null||ue.call(t,e,x,Y),gn(()=>{s("messages",pt(ce=>{Y.forEach(ve=>{delete ce[ve]})})),s("messageInfoVersion",pt(ce=>{Y.forEach(ve=>{delete ce[ve]})})),s("pendingParts",pt(ce=>{Y.forEach(ve=>{delete ce[ve]})})),s("permissions",pt(ce=>{const ve=new Set(Y);Y.forEach(je=>{delete ce.byMessage[je]}),ce.queue=ce.queue.filter(je=>!je.messageId||!ve.has(je.messageId)),ce.active=ce.queue[0]??null})),s("usage",x,$m()),s("latestTodos",x,void 0),s("sessions",x,ce=>({...ce,messageIds:X,updatedAt:Date.now()})),f(x,X),k(x)}))}function H(x,A){U(x),s("sessions",x,"messageIds",(L=[])=>L.includes(A)?L:[...L,A])}function h(x,A){if(!A)return null;const L={},X=[],Y=new Set;return A.forEach((ue,ce)=>{const ve=E0(x,ue,ce),je=ue;L[ve]={id:ve,data:je,revision:0},Y.has(ve)||(Y.add(ve),X.push(ve))}),{map:L,ids:X}}function $(x){var ce;const A=i.delete(x.id),L=h(x.id,x.parts),X=!!(x.bumpRevision||L),Y=Date.now();let ue;s("messages",x.id,ve=>{const je=ve?ve.revision+(X?1:0):0,Ke=A0(e,x,ve),rt={id:x.id,sessionId:x.sessionId,role:x.role,status:x.status,createdAt:x.createdAt??(ve==null?void 0:ve.createdAt)??Y,updatedAt:x.updatedAt??Y,isEphemeral:x.isEphemeral??(ve==null?void 0:ve.isEphemeral)??!1,clientPromptDisplayMetadata:Ke,revision:je,partIds:L?L.ids:(ve==null?void 0:ve.partIds)??[],parts:L?L.map:(ve==null?void 0:ve.parts)??{}};return _0(e,x.sessionId,x.id,Ke),ue=rt,rt}),ue&&S(ue),ue&&!(ue.isEphemeral&&ue.status==="sending")&&a.delete(x.id),H(x.sessionId,x.id),be(x.id),f(x.sessionId),k(x.sessionId),A&&((ce=t==null?void 0:t.onSessionCleared)==null||ce.call(t,e,x.sessionId))}function D(x,A){var L,X;if(A){(L=t==null?void 0:t.onSessionCleared)==null||L.call(t,e,A),(X=t==null?void 0:t.onSessionChanged)==null||X.call(t,e,A);return}for(i.delete(x),i.add(x);i.size>bN;){const Y=i.values().next().value;if(Y===void 0)break;i.delete(Y)}}function E(x){var je;const A=x.sessionId??(typeof x.part.sessionID=="string"?x.part.sessionID:void 0),L={...x,sessionId:A},X=Cl(L,xm);if(X>xm){D(x.messageId,A);return}const Y=++kN;Object.defineProperty(L,M_,{value:X}),Object.defineProperty(L,Od,{value:Y});const ue=new Set,ce=new Map;A&&ue.add(A),s("pendingParts",pt(Ke=>{const rt=[...Ke[x.messageId]??[],L];for(const Et of rt.slice(0,Math.max(0,rt.length-T0)))ce.set(x.messageId,Et.sessionId);Ke[x.messageId]=rt.slice(-T0);const ot=[];for(const Et in Ke)for(const tn of Ke[Et]??[])ot.push({messageId:Et,entry:tn,bytes:xN(tn)});ot.sort((Et,tn)=>Et.entry.receivedAt-tn.entry.receivedAt);const Pt=ot.filter(Et=>Et.entry.sessionId===A),In=new Set(ot.slice(0,Math.max(0,ot.length-vN)));for(const Et of Pt.slice(0,Math.max(0,Pt.length-yN)))In.add(Et);let wn=Pt.reduce((Et,tn)=>Et+tn.bytes,0);for(const Et of Pt){if(wn<=wN)break;In.add(Et),wn-=Et.bytes}let zn=ot.reduce((Et,tn)=>Et+tn.bytes,0);for(const Et of ot){if(zn<=_m)break;In.add(Et),zn-=Et.bytes}for(const Et of In){Ri(Et.entry),ce.set(Et.messageId,Et.entry.sessionId),Et.entry.sessionId&&ue.add(Et.entry.sessionId);const tn=Ke[Et.messageId],J=(tn==null?void 0:tn.indexOf(Et.entry))??-1;J>=0&&tn.splice(J,1),(tn==null?void 0:tn.length)===0&&delete Ke[Et.messageId]}}));const ve=()=>{var Ke;return((Ke=n.pendingParts[x.messageId])==null?void 0:Ke.some(rt=>rt[Od]===Y))??!1};ve()&&($r.set(Y,{instanceId:e,bytes:X,receivedAt:x.receivedAt,isRetained:ve,remove:()=>{s("pendingParts",pt(Ke=>{const rt=Ke[x.messageId],ot=(rt==null?void 0:rt.findIndex(Pt=>Pt[Od]===Y))??-1;ot>=0&&rt.splice(ot,1),(rt==null?void 0:rt.length)===0&&delete Ke[x.messageId]})),D(x.messageId,A)}}),_N());for(const[Ke,rt]of ce)D(Ke,rt);for(const Ke of ue)(je=t==null?void 0:t.onSessionChanged)==null||je.call(t,e,Ke)}function Z(x){const A=n.pendingParts[x];A&&(A.forEach(Ri),s("pendingParts",pt(L=>{delete L[x]})))}function B(x,A,L){if(!x||!A||L.type!=="tool")return;const X=L.callID??L.callId??L.toolCallID??L.toolCallId??L.id??void 0;X&&s("permissions","byMessage",x,pt(Y=>{var ce,ve,je,Ke;if(!Y)return;const ue=Y[A];for(const[rt,ot]of Object.entries(Y))if(!(!ot||ot.partId||(((ce=ot.permission.tool)==null?void 0:ce.callID)??((ve=ot.permission.tool)==null?void 0:ve.callId)??ot.permission.callID??ot.permission.callId??ot.permission.toolCallID??ot.permission.toolCallId??((je=ot.permission.metadata)==null?void 0:je.callID)??((Ke=ot.permission.metadata)==null?void 0:Ke.callId)??void 0)!==X)){(!ue||ue.permission.id===ot.permission.id)&&(ot.partId=A,Y[A]=ot,delete Y[rt]);break}}))}function se(x){const A=n.messages[x.messageId];if(!A){E({messageId:x.messageId,sessionId:typeof x.part.sessionID=="string"?x.part.sessionID:void 0,part:x.part,receivedAt:Date.now()});return}const L=E0(x.messageId,x.part,A.partIds.length),X=x.part;s("messages",x.messageId,pt(Y=>{Y.partIds.includes(L)||(Y.partIds=[...Y.partIds,L]);const ue=Y.parts[L],ce=ue?ue.revision+1:X.version??0;Y.parts[L]={id:L,data:X,revision:ce},Y.updatedAt=Date.now(),(x.bumpRevision??!0)&&(Y.revision+=1)})),B(x.messageId,L,X),m(X)&&w(A.sessionId,{messageId:x.messageId,partId:L,timestamp:Date.now()}),k(A.sessionId)}function pe(x){if(!(x!=null&&x.messageId)||!x.partId||!x.field||typeof x.delta!="string")return;const A=n.messages[x.messageId];if(!A)return;let L=!1;s("messages",x.messageId,pt(X=>{const Y=X.parts[x.partId];if(!(Y!=null&&Y.data))return;const ue=Y.data,ce=ue==null?void 0:ue[x.field];(typeof ce=="string"||ce===void 0||ce===null)&&(ue[x.field]=`${ce??""}${x.delta}`,L=!0),L&&(Y.revision+=1,X.updatedAt=Date.now(),(x.bumpRevision??!0)&&(X.revision+=1))})),L&&(x.bumpSessionRevision??!0)&&k(A.sessionId)}function Se(x,A){var Y;if(!x)return;l(x);const L=n.messages[x],X=new Set;L!=null&&L.sessionId&&Gg(e,L.sessionId,x),L!=null&&L.sessionId?X.add(L.sessionId):Object.values(n.sessions).forEach(ue=>{ue.messageIds.includes(x)&&X.add(ue.id)}),!X.size&&A&&X.add(A),ac(e,[x]),X.forEach(ue=>{var ce;return(ce=t==null?void 0:t.onMessagesRemoved)==null?void 0:ce.call(t,e,ue,[x])}),(Y=n.pendingParts[x])==null||Y.forEach(Ri),gn(()=>{X.forEach(ue=>{s("sessions",ue,"messageIds",(ce=[])=>ce.filter(ve=>ve!==x))}),s("messages",pt(ue=>{delete ue[x]})),s("messageInfoVersion",pt(ue=>{delete ue[x]})),o.delete(x),s("pendingParts",pt(ue=>{delete ue[x]})),s("permissions","byMessage",pt(ue=>{delete ue[x]})),X.forEach(ue=>{var ce;T(ue,ve=>D0(ve,x)),((ce=n.latestTodos[ue])==null?void 0:ce.messageId)===x&&b(ue),f(ue),k(ue)})})}function Q(x,A,L){if(!x||!A)return;const X=n.messages[x];if(!X){L&&k(L);return}ac(e,[x]),gn(()=>{s("messages",x,pt(Y=>{!Y.parts[A]&&!Y.partIds.includes(A)||(Y.partIds=Y.partIds.filter(ue=>ue!==A),delete Y.parts[A],Y.updatedAt=Date.now(),Y.revision+=1)})),s("permissions","byMessage",x,Y=>{if(!Y||!Y[A])return Y;const ue={...Y};return delete ue[A],ue}),k(X.sessionId)})}function be(x){const A=n.pendingParts[x];if(!A||A.length===0)return;const L=Date.now(),X=A.filter(Y=>L-Y.receivedAt<=pN);if(X.length===0){Z(x);return}X.forEach(Y=>se({messageId:x,part:Y.part})),Z(x)}function Ve(x){if(x.oldId===x.newId)return;const A=n.messages[x.oldId];if(!A)return;if(eN(e,A.sessionId,x.oldId,x.newId),a.has(x.oldId)&&A.isEphemeral&&A.status==="sending"){const ve=c.get(x.oldId);l(x.oldId),a.add(x.newId),ve&&c.set(x.newId,ve)}const L={...A,id:x.newId,isEphemeral:!1,updatedAt:Date.now(),partIds:x.clearParts?[]:A.partIds,parts:x.clearParts?{}:A.parts};s("messages",x.newId,L),s("messages",pt(ve=>{delete ve[x.oldId]}));const X=new Set;Object.values(n.sessions).forEach(ve=>{const je=ve.messageIds.indexOf(x.oldId);je!==-1&&(s("sessions",ve.id,"messageIds",Ke=>{const rt=[...Ke];return rt[je]=x.newId,rt}),X.add(ve.id))}),X.forEach(ve=>{f(ve),k(ve)});const Y=o.get(x.oldId);if(Y){o.set(x.newId,Y),o.delete(x.oldId);const ve=n.messageInfoVersion[x.oldId]??0;s("messageInfoVersion",x.newId,ve),s("messageInfoVersion",je=>{const Ke={...je};return delete Ke[x.oldId],Ke})}const ue=n.permissions.byMessage[x.oldId];ue&&(s("permissions","byMessage",x.newId,ue),s("permissions",ve=>{const je={...ve},Ke={...je.byMessage};return delete Ke[x.oldId],je.byMessage=Ke,je}));const ce=n.pendingParts[x.oldId];ce&&s("pendingParts",x.newId,ce),Z(x.oldId),S(L)}function He(x,A){if(!x)return;o.set(x,A);const L=(n.messageInfoVersion[x]??0)+1;s("messageInfoVersion",x,L),P(A)}function re(x){return n.messageInfoVersion[x],o.get(x)}function F(x){const A=n.permissions.queue.find(L=>L.permission.id===x.permission.id);return A?{...x,permission:Xx(A.permission,x.permission),messageId:x.messageId??A.messageId,partId:x.partId??A.partId,enqueuedAt:Math.min(A.enqueuedAt,x.enqueuedAt)}:x}function V(x){var ve,je,Ke,rt;const A=F(x),L=A.messageId??"__global__",X=A.partId??((ve=A.permission)==null?void 0:ve.id)??"__global__",Y=n.permissions.queue.find(ot=>ot.permission.id===A.permission.id),ue=(je=n.permissions.byMessage[L])==null?void 0:je[X],ce=(Ke=n.permissions.queue[0])==null?void 0:Ke.permission.id;hN({existing:Y,existingAtLocationId:ue==null?void 0:ue.permission.id,expectedActiveId:ce,activeId:(rt=n.permissions.active)==null?void 0:rt.permission.id,incomingId:A.permission.id,incomingMessageId:A.messageId,incomingPartId:A.partId,incomingEnqueuedAt:A.enqueuedAt,existingValue:Y==null?void 0:Y.permission,incomingValue:A.permission})||s("permissions",pt(ot=>{Object.keys(ot.byMessage).forEach(In=>{const wn=ot.byMessage[In];Object.keys(wn).forEach(zn=>{wn[zn].permission.id===A.permission.id&&delete wn[zn]}),Object.keys(wn).length===0&&delete ot.byMessage[In]}),ot.byMessage[L]=ot.byMessage[L]??{},ot.byMessage[L][X]=A;const Pt=ot.queue.findIndex(In=>In.permission.id===A.permission.id);Pt===-1?ot.queue.push(A):ot.queue[Pt]=A,ot.queue.sort((In,wn)=>In.enqueuedAt-wn.enqueuedAt),ot.active=ot.queue[0]??null}))}function Me(x){s("permissions",pt(A=>{var L;A.queue=A.queue.filter(X=>X.permission.id!==x),((L=A.active)==null?void 0:L.permission.id)===x&&(A.active=A.queue[0]??null),Object.keys(A.byMessage).forEach(X=>{const Y=A.byMessage[X];Object.keys(Y).forEach(ue=>{Y[ue].permission.id===x&&delete Y[ue]}),Object.keys(Y).length===0&&delete A.byMessage[X]})}))}function xe(x,A){var ce,ve;const L=x??"__global__",X=A??"__global__",Y=(ce=n.permissions.byMessage[L])==null?void 0:ce[X];if(!Y)return null;const ue=((ve=n.permissions.active)==null?void 0:ve.permission.id)===Y.permission.id;return{entry:Y,active:ue}}function Re(x,A){const L=n.sessions[x];if(!L)return;const X=L.messageIds.findIndex(ue=>ue>=A);if(X===-1)return;const Y=L.messageIds.slice(X);Y.length!==0&&gn(()=>{Y.forEach(ue=>Se(ue,x))})}function Be(x,A){x&&(U(x),A!=null&&A.messageID&&Re(x,A.messageID),s("sessions",x,"revert",A??null),k(x))}function et(x){var A;return((A=n.sessions[x])==null?void 0:A.revert)??null}function Ue(x,A){return`${x}:${A}`}function We(x,A,L){var ue;const X=Ue(x,A),Y={...L,updatedAt:Date.now()};s("scrollState",X,Y),(ue=t==null?void 0:t.onScrollSnapshotChanged)==null||ue.call(t,e,x,A,Y)}function st(x,A,L){const X=Ue(x,A);s("scrollState",X,L)}function at(x,A){const L=Ue(x,A);return n.scrollState[L]}function ht(x,A){U(x);const L={kind:A.kind,newerCursors:[...A.newerCursors]};A.resumeCursor!==void 0&&(L.resumeCursor=A.resumeCursor),A.olderCursor!==void 0&&(L.olderCursor=A.olderCursor),s("sessions",x,pt(X=>{X.messageWindow=L}))}function ut(x){var A;return(A=n.sessions[x])==null?void 0:A.messageWindow}function Ct(x,A){var Y;const L=((Y=n.sessions[x])==null?void 0:Y.messageIds)??[],X=L.length-Math.max(1,Math.floor(A));for(const ue of L.slice(0,Math.max(0,X)))Se(ue,x)}function Qe(x,A){var Y;if(!x)return;A!=null&&A.preservePromptDisplayOverrides||tN(e,x);const L=Object.values(n.messages).filter(ue=>ue.sessionId===x).map(ue=>ue.id),X=new Set(L);for(const[ue,ce]of Object.entries(n.pendingParts))for(const ve of ce)(X.has(ue)||ve.sessionId===x)&&Ri(ve);mN.info("Clearing session data",{instanceId:e,sessionId:x,messageCount:L.length}),ac(e,L),cN(e,x),L.forEach(ue=>l(ue)),gn(()=>{s("messages",pt(ce=>{L.forEach(ve=>delete ce[ve])})),s("messageInfoVersion",pt(ce=>{L.forEach(ve=>delete ce[ve])})),L.forEach(ce=>o.delete(ce)),s("pendingParts",pt(ce=>{var ve;for(const je of L)delete ce[je];for(const je in ce)(ve=ce[je])!=null&&ve.some(Ke=>Ke.sessionId===x)&&delete ce[je]}));const ue=ce=>ce.permission.sessionID===x||!!(ce.messageId&&X.has(ce.messageId));s("permissions",pt(ce=>{ce.queue=ce.queue.filter(ve=>!ue(ve)),ce.active=ce.queue[0]??null;for(const ve of Object.keys(ce.byMessage)){const je=ce.byMessage[ve];for(const Ke of Object.keys(je))(X.has(ve)||ue(je[Ke]))&&delete je[Ke];Object.keys(je).length===0&&delete ce.byMessage[ve]}})),s("usage",pt(ce=>{delete ce[x]})),s("sessionRevisions",pt(ce=>{delete ce[x]})),s("lastAssistantMessageIds",pt(ce=>{delete ce[x]})),A!=null&&A.preserveScroll||s("scrollState",pt(ce=>{const ve=`${x}:`;Object.keys(ce).forEach(je=>{je.startsWith(ve)&&delete ce[je]})})),s("sessions",x,ce=>ce&&{...ce,messageIds:[]}),s("sessions",pt(ce=>{delete ce[x]})),s("sessionOrder",ce=>ce.filter(ve=>ve!==x))}),b(x),(A==null?void 0:A.notify)!==!1&&((Y=t==null?void 0:t.onSessionCleared)==null||Y.call(t,e,x))}function tt(x){Qe(x,{preserveScroll:!0,preservePromptDisplayOverrides:!0})}function At(){for(const[x,A]of $r)A.instanceId===e&&$r.delete(x);i.clear(),nN(e,Object.keys(n.sessions)),uN(e),lN(e),o.clear(),a.clear(),c.clear(),s(Sr(C0(e)))}function xt(){s("scrollState",Sr({}))}return{instanceId:e,state:n,setState:s,addOrUpdateSession:G,hydrateMessages:K,reconcileEmptyAuthoritativeSnapshot:Ge,reconcileAuthoritativeMessageIds:M,markSendPending:N,acceptSend:ge,confirmServerMessage:Ie,failSend:ke,failPendingSends:we,retirePendingSends:Ae,upsertMessage:$,applyPartUpdate:se,applyPartDelta:pe,removeMessage:Se,removeMessagePart:Q,bufferPendingPart:E,flushPendingParts:be,replaceMessageId:Ve,setMessageInfo:He,getMessageInfo:re,upsertPermission:V,removePermission:Me,getPermissionState:xe,setSessionRevert:Be,getSessionRevert:et,rebuildUsage:I,getSessionUsage:j,setScrollSnapshot:We,restoreScrollSnapshot:st,getScrollSnapshot:at,setMessageWindow:ht,getMessageWindow:ut,getSessionRevision:C,getSessionMessageIds:x=>{var A;return((A=n.sessions[x])==null?void 0:A.messageIds)??[]},getLastAssistantMessageId:_,getLastCompactionMessageIndex:g,getMessage:x=>n.messages[x],getLatestTodoSnapshot:v,hasPendingSends:W,trimSessionMessages:Ct,estimateSessionRetainedBytes:q,hasLiveSessionMessages:ne,evictSessionTranscript:tt,clearSession:Qe,clearScrollSnapshots:xt,clearInstance:At}}const cc=Ut("session");class EN{constructor(){this.stores=new Map,this.teardownHandlers=new Set,this.sessionClearHandlers=new Set,this.sessionChangeHandlers=new Set,this.messageRemovalHandlers=new Set,this.scrollSnapshotHandlers=new Set,this.scrollSnapshotSeeds=new Map}registerInstance(t,n){if(this.stores.has(t))return this.stores.get(t);const s=n??CN(t,{onSessionCleared:(o,a)=>this.notifySessionCleared(o,a),onSessionChanged:(o,a)=>this.notifySessionChanged(o,a),onMessagesRemoved:(o,a,i)=>this.notifyMessagesRemoved(o,a,i),onScrollSnapshotChanged:(o,a,i,c)=>this.notifyScrollSnapshotChanged(o,a,i,c)});this.stores.set(t,s);const r=this.scrollSnapshotSeeds.get(t);if(r){this.scrollSnapshotSeeds.delete(t);for(const o of r)this.applyScrollSeed(s,o)}return s}onSessionCleared(t){return this.sessionClearHandlers.add(t),()=>{this.sessionClearHandlers.delete(t)}}notifySessionCleared(t,n){km(t,n);for(const s of this.sessionClearHandlers)try{s(t,n)}catch(r){cc.error("Failed to run session clear handler",r)}}onSessionChanged(t){return this.sessionChangeHandlers.add(t),()=>this.sessionChangeHandlers.delete(t)}notifySessionChanged(t,n){for(const s of this.sessionChangeHandlers)try{s(t,n)}catch(r){cc.error("Failed to run session change handler",r)}}onMessagesRemoved(t){return this.messageRemovalHandlers.add(t),()=>this.messageRemovalHandlers.delete(t)}notifyMessagesRemoved(t,n,s){km(t,n);for(const r of this.messageRemovalHandlers)try{r(t,n,s)}catch(o){cc.error("Failed to run message removal handler",o)}}onScrollSnapshotChanged(t){return this.scrollSnapshotHandlers.add(t),()=>{this.scrollSnapshotHandlers.delete(t)}}seedScrollSnapshots(t,n){if(n.length===0)return;const s=this.stores.get(t);if(s){for(const r of n)this.applyScrollSeed(s,r);return}this.scrollSnapshotSeeds.set(t,n)}applyScrollSeed(t,n){const s=t.getScrollSnapshot(n.sessionId,n.scope);s&&s.updatedAt>=n.snapshot.updatedAt||t.restoreScrollSnapshot(n.sessionId,n.scope,n.snapshot)}notifyScrollSnapshotChanged(t,n,s,r){for(const o of this.scrollSnapshotHandlers)try{o(t,n,s,r)}catch(a){cc.error("Failed to run scroll snapshot change handler",a)}}getInstance(t){return this.stores.get(t)}getOrCreate(t){return this.registerInstance(t)}clearInstanceScrollSnapshots(t){var n;(n=this.stores.get(t))==null||n.clearScrollSnapshots(),this.scrollSnapshotSeeds.delete(t)}onInstanceDestroyed(t){return this.teardownHandlers.add(t),()=>{this.teardownHandlers.delete(t)}}unregisterInstance(t){const n=this.stores.get(t);n&&n.clearInstance(),mu(t),this.notifyInstanceDestroyed(t),this.stores.delete(t),this.scrollSnapshotSeeds.delete(t)}clearAll(){for(const[t,n]of this.stores.entries())n.clearInstance(),mu(t),this.notifyInstanceDestroyed(t),this.stores.delete(t),this.scrollSnapshotSeeds.delete(t);this.scrollSnapshotSeeds.clear()}notifyInstanceDestroyed(t){for(const n of this.teardownHandlers)try{n(t)}catch(s){cc.error("Failed to run message store teardown handler",s)}}}const Ht=new EN;function TN(e){if(e!=null&&e.latestMessageId)return e.entries[e.latestMessageId]}function I0(e,t,n){if(!t||!n)return;const s=e.find(r=>r.id===t);return s==null?void 0:s.models.find(r=>r.id===n)}function wa(e,t){var W,q,U,G,le,K;const n=Ne().get(e);if(!n)return;const s=n.get(t);if(!s)return;const r=Ht.getOrCreate(e),o=r.getSessionUsage(t),a=!!(o&&Object.keys(o.entries).length>0);let i=(o==null?void 0:o.totalInputTokens)??0,c=(o==null?void 0:o.totalOutputTokens)??0,l=(o==null?void 0:o.totalReasoningTokens)??0,d=(o==null?void 0:o.totalCost)??0,u=(o==null?void 0:o.actualUsageTokens)??0;const f=TN(o);f==null||f.hasContextUsage;const g=(W=Fl().get(e))==null?void 0:W.get(t);let m=0,w=null,S=!1;s.tokens?(i=s.tokens.input,c=s.tokens.output,l=s.tokens.reasoning,d=s.cost??0,a||(u=(g==null?void 0:g.actualUsageTokens)??0)):!a&&g&&(i=g.inputTokens,c=g.outputTokens,l=g.reasoningTokens,d=g.cost,u=g.actualUsageTokens);const b=Ti().get(e)||[],v=s.model,k=v==null?void 0:v.providerId,C=v==null?void 0:v.modelId,_=f!=null&&f.messageId?r.getMessageInfo(f.messageId):void 0,T=(_==null?void 0:_.providerID)||(_==null?void 0:_.providerId)||"",P=(_==null?void 0:_.modelID)||(_==null?void 0:_.modelId)||"",I=I0(b,k,C)??I0(b,T,P);let j=Dc,ne=null;if(I){m=((q=I.limit)==null?void 0:q.context)??0;const M=(U=I.limit)==null?void 0:U.input;typeof M=="number"&&M>0&&(ne=M);const N=(G=I.limit)==null?void 0:G.output;typeof N=="number"&&N>0&&(j=Math.min(N,Dc)),(((le=I.cost)==null?void 0:le.input)??0)===0&&(((K=I.cost)==null?void 0:K.output)??0)===0&&(S=!0)}if(m===0&&g&&(m=g.contextWindow),j=Math.min(j,Dc),g){const M=g.contextWindow,N=g.contextAvailableTokens??null;m!==M?w=null:w=N,a&&S||(S=g.isSubscriptionModel)}ne!==null?w=ne:m>0?w=m:w=null,rg(M=>{const N=new Map(M),oe=new Map(M.get(e));return oe.set(t,{cost:d,contextWindow:m,isSubscriptionModel:S,inputTokens:i,outputTokens:c,reasoningTokens:l,actualUsageTokens:u,modelOutputLimit:j,contextAvailableTokens:w}),N.set(e,oe),N}),Rq(e,t)}const MN=(e,t)=>e===t;function AN(e){switch(e){case"sending":case"sent":case"streaming":case"complete":case"error":return e;default:return"complete"}}function P_(e,t,n,s,r,o=!1,a=!0){if(!t||!Array.isArray(n))return!1;const i=Ht.getOrCreate(e);if(r!==void 0&&!MN(r,i.getSessionRevision(t.id)))return!1;const c="id"in t?{id:t.id,title:t.title,parentId:t.parentId??null}:t;i.addOrUpdateSession({id:c.id,title:c.title,parentId:c.parentId??null,..."revert"in t?{revert:t.revert??null}:{}});const l=n.map(d=>({id:d.id,sessionId:d.sessionId,role:d.type,status:AN(d.status),createdAt:d.timestamp,updatedAt:d.timestamp,parts:d.parts,isEphemeral:d.status==="sending"||d.type==="assistant"&&d.status==="streaming",bumpRevision:!1}));return i.hydrateMessages(c.id,l,s==null?void 0:s.values(),{preserveOmitted:o,confirmPending:a}),!0}function I_(e){return wO(e)}function DN(e){const t=e.metadata||{};return e.partID||e.partId||t.partID||t.partId||void 0}function R_(e){return bO(e)}function O_(e,t,n){var r;if(!t||!n)return;const s=e.getMessage(t);if(s)for(const o of s.partIds){const a=(r=s.parts[o])==null?void 0:r.data;if(!a||a.type!=="tool")continue;if((a.callID??a.callId??a.toolCallID??a.toolCallId??a.id??void 0)===n&&typeof a.id=="string"&&a.id.length>0)return a.id}}function L_(e,t){if(!t)return;const n=Ht.getOrCreate(e),s=I_(t);let r=DN(t);if(!r){const o=R_(t);r=O_(n,s,o)}n.upsertPermission({permission:t,messageId:s,partId:r,enqueuedAt:Date.now()})}function PN(e,t){const n=Ht.getOrCreate(e),s=n.state.permissions.queue;if(!(!s||s.length===0))for(const r of s){if(!r)continue;const o=r.permission;if(!o)continue;const a=ua(o);if(t&&a&&a!==t)continue;const i=r.messageId??I_(o),c=R_(o),l=O_(n,i,c);r.partId&&i&&n.getPermissionState(i,r.partId)&&(!l||l===r.partId)||l&&n.upsertPermission({...r,messageId:i,partId:l})}}function _f(e,t){if(!t)return;Ht.getOrCreate(e).removePermission(t)}function R0(e,t,n){if(!t)return;Ht.getOrCreate(e).removeMessage(t,n)}function IN(e,t,n){if(!t)return;Ht.getOrCreate(e).setSessionRevert(t,n??null)}function vu(e,t){const n=new Set,s=r=>{var c,l,d;if(typeof r=="string")return r.trim()||void 0;if(!r||typeof r!="object"||n.has(r))return;n.add(r);const o=r,a=[(c=o.data)==null?void 0:c.message,(l=o.body)==null?void 0:l.message,o.error].find(u=>typeof u=="string"&&u.trim());if(a)return a.trim();const i=s(o.cause)??s(o.error)??s(o.body);if(i)return i;if(o.reason==="UnexpectedStatus"){const u=Number((d=o.cause)==null?void 0:d.status);if(Number.isInteger(u)&&u>=100&&u<=599)return`Unexpected status ${u}`}if(typeof o.message=="string"&&o.message.trim())return o.message.trim()};return s(e)??t}const[RN,N_]=R(new Map),Cm=new Map;function co(e){return RN().get(e)}function ON(e,t){N_(n=>{const s=new Map(n);return s.delete(e),s})}function F_(e,t){N_(n=>{const s=new Map(n),r=s.get(e)??{};return s.set(e,{...r,...t}),s})}function Ay(e){Cm.set(e,(Cm.get(e)??0)+1),ON(e)}function wu(e){return Cm.get(e)??0}function LN(e,t,n){return t==="working"||t==="compacting"?null:e==="interrupted"||n?"interrupted":"pending"}function B_(e,t){return t==="working"||t==="compacting"?null:e==="pending"?"interrupted":e??null}function XH(e,t){return e==="working"||e==="compacting"||t==="pending"?"working":t==="interrupted"?"interrupted":null}function lo(e,t,n,s=!1){if(s||t&&!n)return null;if(!n)return e;if(n===t)return n.generationAdmissionToken===void 0?O0(e,n):{...e,...n};const r={...e},o=new Set([...Object.keys(t??{}),...Object.keys(n)]);for(const i of o)t&&Object.is(t[i],n[i])||(Object.prototype.hasOwnProperty.call(n,i)?r[i]=n[i]:delete r[i]);const a=e.status==="working"||e.status==="compacting";if(t&&a&&n.generationAdmissionToken===void 0&&n.runtimeStatusKnown===!1&&n.generationRecovery==="pending")for(const i of["status","runtimeStatusKnown","generationRecovery","generationAdmissionToken","retry","idleSince"])r[i]=e[i];return O0(r,n)}function O0(e,t){return t.modelSelectionPending?{...e,model:t.model,modelSelectionPending:!0}:e}const L0=1e3;async function NN(e,t,n){var l,d,u,f,g;const s=n.isAuthoritative??(()=>!0),r=[],o=new Set(n.cursor?[n.cursor]:[]);let a=n.cursor,i,c;for(let m=0;m<L0&&r.length<n.limit;m+=1){if((l=n.signal)==null||l.throwIfAborted(),!s())return null;const w=n.limit-r.length,S=await e.message.list(a?{sessionID:t,limit:w,cursor:a}:{sessionID:t,limit:w,order:n.forward?"asc":"desc"},{signal:n.signal});if(!s())return null;n.forward?(m===0&&(i=((d=S.cursor)==null?void 0:d.previous)??void 0),r.push(...S.data.slice(0,w)),c=((u=S.cursor)==null?void 0:u.next)??void 0):(m===0&&(c=((f=S.cursor)==null?void 0:f.previous)??void 0),r.unshift(...S.data.slice(0,w).reverse()),i=((g=S.cursor)==null?void 0:g.next)??void 0);const b=n.forward?c:i;if(!b)return{messages:r,olderCursor:i,newerCursor:c};if(o.has(b))throw new Error(`Repeated message cursor for session ${t}`);o.add(b),a=b}if(r.length>=n.limit)return{messages:r,olderCursor:i,newerCursor:c};throw new Error(`Message window pagination exceeded ${L0} pages for session ${t}`)}const Cr=200,U_=32;function Yc(){return{kind:"latest",newerCursors:[]}}function K_(e){return!e||e.kind==="latest"}function V_(e){const t=UN(e==null?void 0:e.newerCursors);return(e==null?void 0:e.windowIsLatest)===!1||(e==null?void 0:e.windowIsLatest)!==!0&&(e!=null&&e.windowCursor)?{kind:"history",resumeCursor:e.windowCursor,newerCursors:t}:{kind:"latest",newerCursors:t}}function FN(e){if(!e.olderCursor)return null;const t=e.kind==="latest"?null:e.resumeCursor??null,n=[...e.newerCursors,t],s=Em(e.newerCursors)||n.length>U_,r=Em(n)?n.slice(2):n;return{cursor:e.olderCursor,next:{kind:"history",resumeCursor:e.olderCursor,newerCursors:s?[null,null,...r.slice(-30)]:n}}}function BN(e){if(e.kind!=="history")return null;if(Em(e.newerCursors)&&e.newerCursors.length===2&&e.resumeCursor)return{next:e,seekNewer:e.resumeCursor};if(e.newerCursors.length===0)return{next:Yc()};const t=e.newerCursors.slice(0,-1),n=e.newerCursors[e.newerCursors.length-1];if(n===null)return{next:{kind:"latest",newerCursors:t}};const s=!e.newerCursors.includes(null);return{cursor:n,next:{kind:"history",resumeCursor:n,newerCursors:t},...s?{forward:!0}:{}}}function Zg(e,t){return{...e,olderCursor:t}}function j_(e){return{windowIsLatest:e.kind==="latest",windowCursor:e.resumeCursor,newerCursors:e.newerCursors}}function eG(e,t,n){return{...e,...n?j_(n):t}}function UN(e){return e!=null&&e.length?e.slice(-U_):[]}function Em(e){return e[0]===null&&e[1]===null}const[KN,q_]=R(new Map),Tm=new Map;let VN=0;async function z_(e,t,n){const s=++VN;Tm.set(e,s);let r;try{r=await t.command.list(n?{location:Io(n)}:void 0,Zt(n)).then(o=>o.data)}catch{return!1}return Tm.get(e)!==s?!1:(q_(o=>{const a=new Map(o);return a.set(e,r),a}),!0)}function tG(e){return KN().get(e)??[]}function Dy(e){Tm.delete(e),q_(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n})}const Hr=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let s=0,r=t.length;s<r;s++)n=t[s](n);return n}}},jN={pipe(){return Hr(this,arguments)}},$f=function(){function e(){}return e.prototype=jN,e}(),Gt=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):n=>t(n,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(n,s){return arguments.length>=2?t(n,s):function(r){return t(r,n)}};case 3:return function(n,s,r){return arguments.length>=3?t(n,s,r):function(o){return t(o,n,s)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);const n=arguments;return function(s){return t(s,...n)}}}},Yo=e=>e,qN=e=>()=>e,W_=qN(void 0),zN=W_;function Ga(e){const t=new WeakMap;return n=>{const s=t.get(n);if(s!==void 0)return s;const r=e(n);return t.set(n,r),r}}function El(e){const t=new WeakMap;return n=>{const s=t.get(n);if(s!==void 0)return s;const r=e(n);return t.set(n,r),t.set(r,r),r}}const Mm=e=>{const t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");const n=Object.getPrototypeOf(e);let s=n;for(;s!==null&&s!==Object.prototype;){const r=Reflect.ownKeys(s);for(let o=0;o<r.length;o++)t.add(r[o]);s=Object.getPrototypeOf(s)}return t.has("constructor")&&typeof e.constructor=="function"&&n===e.constructor.prototype&&t.delete("constructor"),t},Am=new WeakSet;function H_(e){return typeof e=="string"}function G_(e){return typeof e=="number"}function WN(e){return typeof e=="boolean"}function HN(e){return typeof e=="symbol"}function Z_(e){return H_(e)||G_(e)||HN(e)}function Py(e){return typeof e=="function"}function GN(e){return e!==void 0}function ZN(e){return e!=null}function Y_(e){return!0}function Dm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Pm(e){return typeof e=="object"&&e!==null||Py(e)}const Vn=Gt(2,(e,t)=>Pm(e)&&t in e);function YN(e){return e instanceof Error}const Js="~effect/interfaces/Hash",Mn=e=>{switch(typeof e){case"number":return Ef(e);case"bigint":return hn(e.toString(10));case"boolean":return hn(String(e));case"symbol":return hn(String(e));case"string":return hn(e);case"undefined":return hn("undefined");case"function":case"object":{if(e===null)return hn("null");if(e instanceof Date)return Number.isNaN(e.getTime())?hn("Invalid Date"):hn(e.toISOString());if(e instanceof RegExp)return hn(e.toString());{if(Am.has(e))return Im(e);if(Jg.has(e))return Jg.get(e);const t=nF(e,()=>JN(e)?e[Js]():typeof e=="function"?Im(e):e instanceof DataView?Rm(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?Rm(e):e instanceof Map?eF(e):e instanceof Set?tF(e):XN(e));return Jg.set(e,t),t}}default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Im=e=>(Yg.has(e)||Yg.set(e,Ef(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),Yg.get(e)),Fr=Gt(2,(e,t)=>e*53^t),Cf=e=>e&3221225471|e>>>1&1073741824,JN=e=>Vn(e,Js),Ef=e=>{if(e!==e)return hn("NaN");if(e===1/0)return hn("Infinity");if(e===-1/0)return hn("-Infinity");let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Cf(t)},hn=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Cf(t)},QN=(e,t)=>{let n=12289;for(const s of t)n^=Fr(Mn(s),Mn(e[s]));return Cf(n)},XN=e=>QN(e,Mm(e)),Iy=(e,t)=>n=>{let s=e;for(const r of n)s^=t(r);return Cf(s)},Rm=Iy(6151,Mn),eF=Iy(hn("Map"),([e,t])=>Fr(Mn(e),Mn(t))),tF=Iy(hn("Set"),Mn),Yg=new WeakMap,Jg=new WeakMap,Qg=new WeakSet;function nF(e,t){if(Qg.has(e))return hn("[Circular]");Qg.add(e);const n=t();return Qg.delete(e),n}const Qs="~effect/interfaces/Equal";function As(){return arguments.length===1?e=>ci(e,arguments[0]):ci(arguments[0],arguments[1])}function ci(e,t){if(e===t)return!0;if(e==null||t==null)return!1;const n=typeof e;return n!==typeof t?!1:n==="number"&&e!==e&&t!==t?!0:n!=="object"&&n!=="function"||Am.has(e)||Am.has(t)?!1:oF(e,t,rF)}function sF(e,t,n){const s=Xg.has(e),r=eh.has(t);if(s&&r)return!0;if(s||r)return!1;Xg.add(e),eh.add(t);const o=n();return Xg.delete(e),eh.delete(t),o}const Xg=new WeakSet,eh=new WeakSet;function rF(e,t){if(Mn(e)!==Mn(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;const o=e.getTime(),a=t.getTime();return o===a||Number.isNaN(o)&&Number.isNaN(a)}else if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;const n=F0(e),s=F0(t);if(n!==s)return!1;const r=n&&s;return typeof e=="function"&&!r?!1:sF(e,t,()=>{if(r)return e[Qs](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:iF(e,t);if(ArrayBuffer.isView(e)){const o=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||o!==t instanceof DataView)return!1;if(o){const a=t;return N0(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(a.buffer,a.byteOffset,a.byteLength))}return N0(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:lF(e,t);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:uF(e,t)}return aF(e,t)})}function oF(e,t,n){let s=cd.get(e);if(!s)s=new WeakMap,cd.set(e,s);else if(s.has(t))return s.get(t);const r=n(e,t);s.set(t,r);let o=cd.get(t);return o||(o=new WeakMap,cd.set(t,o)),o.set(e,r),r}const cd=new WeakMap;function iF(e,t){for(let n=0;n<e.length;n++)if(!ci(e[n],t[n]))return!1;return!0}function N0(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function aF(e,t){const n=Mm(e),s=Mm(t);if(n.size!==s.size)return!1;for(const r of n)if(!s.has(r)||!ci(e[r],t[r]))return!1;return!0}function cF(e,t){return function(s,r){const o=Array.from(r);for(const[a,i]of s){let c=!1;for(let l=0;l<o.length;l++){const[d,u]=o[l];if(e(a,d)&&t(i,u)){o[l]=o[o.length-1],o.pop(),c=!0;break}}if(!c)return!1}return!0}}const lF=cF(ci,ci);function dF(e){return function(n,s){const r=Array.from(s);for(const o of n){let a=!1;for(let i=0;i<r.length;i++){const c=r[i];if(e(o,c)){r[i]=r[r.length-1],r.pop(),a=!0;break}}if(!a)return!1}return!0}}const uF=dF(ci),F0=e=>Vn(e,Qs),wc=e=>(t,n)=>t===n||e(t,n),fF=(e,t)=>e===t,gF=()=>fF,J_=e=>e.length>0;function rr(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Q_(e,t){for(const n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&rr(e,n,t[n])}const Tf=Symbol.for("~effect/Redactable"),hF=e=>Vn(e,Tf);function Om(e){return hF(e)?X_(e):e}function X_(e){var t;return e[Tf](((t=globalThis[Pc])==null?void 0:t.context)??mF)}const Pc="~effect/Fiber/currentFiber",B0=new Map,mF={"~effect/Context":{},base:B0,depth:0,mapUnsafe:B0,pipe(){return Hr(this,arguments)}};function jt(e,t){const n=(t==null?void 0:t.space)??0,s=new WeakSet,r=n?typeof n=="number"?" ".repeat(n):n:"",o=l=>r.repeat(l),a=(l,d)=>{const u=l==null?void 0:l.constructor;return u&&u!==Object.prototype.constructor&&u.name?`${u.name}(${d})`:d},i=l=>{try{return Reflect.ownKeys(l)}catch{return["[ownKeys threw]"]}};function c(l,d=0){if(typeof l=="string")return JSON.stringify(l);if(typeof l=="number"||l==null||typeof l=="boolean"||typeof l=="symbol")return String(l);if(typeof l=="bigint")return String(l)+"n";if(typeof l=="object"||typeof l=="function"){if(s.has(l))return pF;s.add(l);let u;if(Tf in l)u=c(X_(l),d);else if(Array.isArray(l))u=!r||l.length<=1?`[${l.map(f=>c(f,d)).join(",")}]`:`[
|
|
17
17
|
${o(d+1)}${l.map(f=>c(f,d+1)).join(`,
|
|
@@ -32,12 +32,12 @@ ${o(d)}}`;u=a(l,g)}}return s.delete(l),u}return String(l)}return c(e,0)}const pF
|
|
|
32
32
|
`)})}const pd=new Map;function jl(e,t,n){const s=`${e}:${t}`,o=(pd.get(s)??Promise.resolve()).catch(()=>{}).then(n).finally(()=>{pd.get(s)===o&&pd.delete(s)});return pd.set(s,o),o}const oo=Ut("actions"),yd=new Map;function dg(e,t,n,s){return jl(e,t,async()=>{const r=(s==null?void 0:s.optimisticGeneration)===!1?void 0:sE(e,t);try{const o=await n();return r==null||r.complete(),o}catch(o){throw r==null||r.rollback(),o}})}function FG(e,t,n){var r;const s=(r=Fe().get(e))==null?void 0:r.client;return jl(e,t,async()=>{const o=()=>{var l,d;if(!s||((l=Fe().get(e))==null?void 0:l.client)!==s||!((d=Ne().get(e))!=null&&d.has(t)))throw new Error("Instance not ready")};o();const a=$t(e),i={sessionID:t,messageID:n},c={signal:AbortSignal.timeout(15e3)};try{await a.session.revert.stage(i,c)}catch(l){if(!DO(l))throw l;o(),await a.session.interrupt({sessionID:t,resume:!1},c),o(),await a.session.wait({sessionID:t},c),o(),await a.session.revert.stage(i,c)}o()})}function CE(e,t,n,s){const r=`${e}:${t}:${n}`,a=(yd.get(r)??Promise.resolve()).catch(()=>{}).then(s).finally(()=>{yd.get(r)===a&&yd.delete(r)});return yd.set(r,a),a}function p6(e,t){if(!t.providerId||!t.modelId)return[];const s=(Ti().get(e)||[]).find(o=>o.id===t.providerId),r=s==null?void 0:s.models.find(o=>o.id===t.modelId);return(r==null?void 0:r.variantKeys)??[]}function y6(e,t){const n=gM(t);if(!n)return;const s=p6(e,t);if(s.length!==0)return s.includes(n)?n:void 0}function Jv(e,t){const n={providerID:t.providerId,id:t.modelId},s=y6(e,t);return s&&(n.variant=s),n}function v6(e,t){const n=`@${t}`,s=e.indexOf(n);return s<0?void 0:{start:s,end:s+n.length,text:n}}const w6=26,vd="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";let CS=0,hh=0;function b6(e){let t="";const n=globalThis.crypto;if(n&&typeof n.getRandomValues=="function"){const s=new Uint8Array(e);n.getRandomValues(s);for(let r=0;r<e;r++)t+=vd[s[r]%vd.length]}else for(let s=0;s<e;s++){const r=Math.floor(Math.random()*vd.length);t+=vd[r]}return t}function wd(e){const t=Date.now();t!==CS&&(CS=t,hh=0),hh++;const n=(BigInt(t)<<BigInt(12))+BigInt(hh),s=new Array(6);for(let a=0;a<6;a++){const i=BigInt(8*(5-a));s[a]=Number(n>>i&BigInt(255))}const r=s.map(a=>a.toString(16).padStart(2,"0")).join(""),o=b6(w6-12);return`${e}_${r}${o}`}async function S6(e,t,n,s=[],r={}){var T,P,I,j,ne,W,q,U;const o=Fe().get(e);if(!o||!o.client)throw new Error("Instance not ready");const a=Ne().get(e);if(!(a==null?void 0:a.get(t)))throw new Error("Session not found");const c=wd("msg"),l=wd("prt"),d=qq(n,s),u=(P=(T=r.restoredPayload)==null?void 0:T.metadata)==null?void 0:P.displayText;typeof u=="string"&&((I=r.restoredPayload)!=null&&I.text.startsWith(u))&&(d.promptToSend+=r.restoredPayload.text.slice(u.length));const f=[{id:l,type:"text",text:d.promptToSend,renderCache:void 0}],g=[],m=[],w=G=>{if(!G)return;const le=n.indexOf(G.text);return le<0?void 0:{text:G.text,start:le,end:le+G.text.length}},S=[...((j=r.restoredPayload)==null?void 0:j.files)??[]];if(s.length>0)for(const G of s){const le=G.source;if(le.type==="file"){const K=wd("prt"),M=S.findIndex(ge=>(ge.source.type==="uri"?ge.source.uri:`data:${ge.mime};base64,${ge.data}`)===G.url),N=M<0?void 0:S.splice(M,1)[0],oe=w(N==null?void 0:N.mention);g.push({uri:G.url,name:G.filename,...N!=null&&N.description?{description:N.description}:{},...oe?{mention:oe}:{}}),f.push({id:K,type:"file",url:G.url,mime:le.mime,filename:G.filename,synthetic:!0})}else if(le.type==="agent"){const K=v6(d.promptToSend,le.name)??w((q=(W=(ne=r.restoredPayload)==null?void 0:ne.agents)==null?void 0:W.find(M=>M.name===le.name))==null?void 0:q.mention);m.some(M=>M.name===le.name)||m.push({name:le.name,...K?{mention:K}:{}})}else if(le.type==="text"){const K=G.display,M=le.value,N=typeof K=="string"&&/^pasted #\d+/.test(K),oe=typeof K=="string"&&/^path:/.test(K);if(N||oe||typeof M!="string")continue;const ge=wd("prt");d.promptToSend+=`
|
|
33
33
|
|
|
34
34
|
${M}`,f.push({id:ge,type:"text",text:M,renderCache:void 0})}}const b=Ht.getOrCreate(e),v=Date.now();t6(e,t);const k=r.delivery!=="queue";k&&(b.upsertMessage({id:c,sessionId:t,role:"user",status:"sending",parts:f,createdAt:v,updatedAt:v,isEphemeral:!0,clientPromptDisplayMetadata:d.displayMetadata}),b.trimSessionMessages(t,Cr),b.markSendPending(c)),sn(e,t,()=>{});const C={id:c,text:d.promptToSend,...g.length>0?{files:g}:{},...m.length>0?{agents:m}:{},...(U=r.restoredPayload)!=null&&U.skills?{skills:r.restoredPayload.skills.flatMap(G=>{const le=w(G.mention);return G.mention&&!le?[]:[{id:G.id,...le?{mention:le}:{}}]})}:{},...r.restoredPayload?{metadata:{...r.restoredPayload.metadata,displayText:n}}:{},...r.delivery?{delivery:r.delivery}:{},...r.delivery==="queue"?{resume:!1}:{}};oo.info("sendMessage",{instanceId:e,sessionId:t,requestBody:C});let _=c;try{oo.info("session.prompt",{instanceId:e,sessionId:t,requestBody:C}),await dg(e,t,async()=>{var N;const G=Fe().get(e),le=(N=Ne().get(e))==null?void 0:N.get(t);if(!(G!=null&&G.client))throw new Error("Instance not ready");if(!le)throw new Error("Session not found");const K=$t(e);await Yv(K,e,t),r.delivery!=="queue"&&(le.agent&&await K.session.switchAgent({sessionID:t,agent:le.agent}),le.model.providerId&&le.model.modelId&&await K.session.switchModel({sessionID:t,model:Jv(e,le.model)}));const M=await K.session.prompt({sessionID:t,...C});_=(M==null?void 0:M.id)||c,k&&_!==c&&b.replaceMessageId({oldId:c,newId:_}),k&&b.acceptSend(_)})}catch(G){throw k&&b.failSend(c),oo.error("Failed to send prompt",G),G}return _}async function k6(e,t,n,s){var a;const r=Fe().get(e);if(!r||!r.client)throw new Error("Instance not ready");if(!((a=Ne().get(e))==null?void 0:a.get(t)))throw new Error("Session not found");await dg(e,t,async()=>{var c,l;if(!((c=Fe().get(e))!=null&&c.client))throw new Error("Instance not ready");if(!((l=Ne().get(e))!=null&&l.has(t)))throw new Error("Session not found");const i=$t(e);await Yv(i,e,t),await i.session.command({sessionID:t,name:n,text:s,delivery:"steer"})},{optimisticGeneration:!1})}async function x6(e,t,n){var o;const s=Fe().get(e);if(!s||!s.client)throw new Error("Instance not ready");if(!((o=Ne().get(e))==null?void 0:o.get(t)))throw new Error("Session not found");await dg(e,t,async()=>{var i,c;if(!((i=Fe().get(e))!=null&&i.client))throw new Error("Instance not ready");if(!((c=Ne().get(e))!=null&&c.has(t)))throw new Error("Session not found");const a=$t(e);await Yv(a,e,t),await a.session.shell({sessionID:t,command:n})})}async function _6(e,t){const n=Fe().get(e);if(!n||!n.client)throw new Error("Instance not ready");const s=$t(e);oo.info("abortSession",{instanceId:e,sessionId:t});try{oo.info("session.interrupt",{instanceId:e,sessionId:t}),await s.session.interrupt({sessionID:t,resume:!0}),oo.info("abortSession complete",{instanceId:e,sessionId:t})}catch(r){throw oo.error("Failed to abort session",r),r}}function $6(e,t,n){return jl(e,t,()=>C6(e,t,n))}async function C6(e,t,n){const s=Ne().get(e),r=s==null?void 0:s.get(t);if(!r)throw new Error("Session not found");const o=await Sf(e,n),a=pa(e,o),i=r.agent,c=r.model;sn(e,t,l=>{l.agent=n,a&&(l.model=o)});try{yE(e,t)||(await $t(e).session.switchAgent({sessionID:t,agent:n}),a&&await $t(e).session.switchModel({sessionID:t,model:Jv(e,o)}))}catch(l){throw sn(e,t,d=>{if(d.agent!==n)return!1;d.agent=i,a&&d.model.providerId===o.providerId&&d.model.modelId===o.modelId&&(d.model=c)}),l}n&&a&&await Ap(e,n,o),a&&wa(e,t)}function E6(e,t,n){return jl(e,t,()=>T6(e,t,n))}async function T6(e,t,n){const s=Ne().get(e),r=s==null?void 0:s.get(t);if(!r)throw new Error("Session not found");if(!pa(e,n)){oo.warn("Invalid model selection",n);return}sn(e,t,a=>{a.model=n,a.modelSelectionPending=!0});const o=Jv(e,n);try{await $t(e).session.switchModel({sessionID:t,model:o}),sn(e,t,a=>{a.model={...n},delete a.modelSelectionPending})}catch(a){throw sn(e,t,i=>{delete i.modelSelectionPending,!(i.model.providerId!==n.providerId||i.model.modelId!==n.modelId)&&(i.model=r.model)}),a}r.agent&&await Ap(e,r.agent,n),fM(n),wa(e,t)}async function M6(e,t,n){var i;const s=Fe().get(e);if(!s||!s.client)throw new Error("Instance not ready");const r=$t(e);if(!((i=Ne().get(e))==null?void 0:i.get(t)))throw new Error("Session not found");const a=n.trim();if(!a)throw new Error("Session title is required");await r.session.update({sessionID:t,title:a}),sn(e,t,c=>{c.title=a;const l={...c.time??{}};l.updated=Date.now(),c.time=l})}async function BG(e,t){await dg(e,t,async()=>{var n,s;if(!((n=Fe().get(e))!=null&&n.client))throw new Error("Instance not ready");if(!((s=Ne().get(e))!=null&&s.has(t)))throw new Error("Session not found");await $t(e).session.compact({sessionID:t})})}function EE(e,t,n){const{message:s,info:r}=kf(t,n),o=Ht.getOrCreate(e);o.upsertMessage({id:s.id,sessionId:s.sessionId,role:s.type,status:s.status,createdAt:s.timestamp,updatedAt:s.timestamp,parts:s.parts}),o.setMessageInfo(r.id,r)}function mh(e){if((e==null?void 0:e.type)==="tool")return hp({type:e.type,id:e.id});if((e==null?void 0:e.type)!=="reasoning")return;const{id:t,sessionID:n,messageID:s,renderCache:r,pendingPermission:o,...a}=e;return hp(a)}async function TE(e,t,n,s){const r=Ht.getOrCreate(e).getMessage(n),o=Array.from(new Set(s)).map(i=>{var c,l;return{partId:i,part:(c=r==null?void 0:r.parts[i])==null?void 0:c.data,identity:mh((l=r==null?void 0:r.parts[i])==null?void 0:l.data)}});if((r==null?void 0:r.sessionId)!==t||r.role!=="assistant"||!["complete","error"].includes(r.status)||o.length===0||o.some(({part:i})=>(i==null?void 0:i.type)!=="tool"&&(i==null?void 0:i.type)!=="reasoning"))throw new Error($e("session.pruning.not_deletable"));const a=r.partIds.map(i=>{var c;return mh((c=r.parts[i])==null?void 0:c.data)});if(o.some(({identity:i})=>i===void 0||a.filter(c=>c===i).length!==1))throw new Error($e("session.pruning.conflict"));return CE(e,t,n,async()=>{const c=await $t(e).session.message.get({sessionID:t,messageID:n});if(c.type!=="assistant"||!c.time.completed)throw new Error($e("session.pruning.not_deletable"));const l=kf(t,c).message.parts.map(mh),d=new Set(o.map(u=>{const f=l.flatMap((g,m)=>g===u.identity?[m]:[]);return f.length===1?f[0]:-1}));if(d.has(-1))throw new Error($e("session.pruning.conflict"));await kE(e,t,c,[...d],u=>EE(e,t,u))})}async function UG(e,t,n,s){await TE(e,t,n,[s])}async function A6(e,t,n,s){if(s){await TE(e,t,n,s);return}await CE(e,t,n,async()=>{const o=await $t(e).session.message.get({sessionID:t,messageID:n});if(o.type!=="assistant"||!o.time.completed)throw new Error($e("session.pruning.not_deletable"));if(o.content.filter(c=>c.type!=="tool"&&c.type!=="reasoning").length===o.content.length)return;const i=o.content.flatMap((c,l)=>c.type==="tool"||c.type==="reasoning"?[l]:[]);await kE(e,t,o,i,c=>EE(e,t,c))})}async function KG(e,t,n){const s=new Map;for(const r of n){const o=s.get(r.messageId)??[];o.push(r.partId),s.set(r.messageId,o)}for(const[r,o]of s)await A6(e,t,r,o)}async function D6(e,t){await $t(e).session.background({sessionID:t})}const P6=Ut("actions"),bd=new Map;function ES(e,t){var c;const n=`${e}\0${t}`,s=bd.get(n);if(s!=null&&s.current())return s.dirty=!0,s.promise;const r=(c=Fe().get(e))==null?void 0:c.client,o=cn(e),a=()=>{var l;return!!(r&&((l=Fe().get(e))==null?void 0:l.client)===r&&cn(e)===o)},i={dirty:!1,current:a,promise:Promise.resolve()};return i.promise=jl(e,t,async()=>{var l;do{i.dirty=!1;const d=(l=Ne().get(e))==null?void 0:l.get(t);if(!a()||!d)return;const u=await $t(e).session.get({sessionID:t},{signal:AbortSignal.timeout(8e3)});if(!a())return;i.dirty||sn(e,t,f=>{if(f.model!==d.model||!u.model)return!1;f.model={providerId:u.model.providerID,modelId:u.model.id}})}while(i.dirty)}).catch(l=>{P6.warn("Failed to reconcile session model",{instanceId:e,sessionId:t,error:l})}).finally(()=>{bd.get(n)===i&&bd.delete(n)}),bd.set(n,i),i.promise}const En=Ut("sse"),Sd=new Map,zu=new Map;let kd=null;const ph=new Map;function Ra(e,t){const n=`${e}\0${t}`,s=(zu.get(n)??0)+1;return zu.set(n,s),s}function I6(e,t,n){return zu.get(`${e}\0${t}`)===n}function ME(e,t){const n=Ht.getOrCreate(e),s=n.getLastAssistantMessageId(t),r=s?n.getMessage(s):void 0;if(!s||(r==null?void 0:r.status)!=="complete")return;const o=n.getMessageInfo(s);for(const a of r.partIds)n6(e,r.parts[a].data,o)}function R6(e,t){var s,r,o,a,i,c,l,d,u,f,g,m;if(Hq(e,t))return;switch(t.type){case"form.created":case"form.replied":case"form.cancelled":return;case"session.renamed":(s=Ne().get(e))!=null&&s.has(t.data.sessionID)||kc(e,t.data.sessionID,(r=t.location)==null?void 0:r.directory),sn(e,t.data.sessionID,w=>{w.title=t.data.title});return;case"session.agent.selected":(o=Ne().get(e))!=null&&o.has(t.data.sessionID)||kc(e,t.data.sessionID,(a=t.location)==null?void 0:a.directory),sn(e,t.data.sessionID,w=>{w.agent=t.data.agent});return;case"session.model.selected":(i=Ne().get(e))!=null&&i.has(t.data.sessionID)?ES(e,t.data.sessionID):kc(e,t.data.sessionID,(c=t.location)==null?void 0:c.directory).then(()=>ES(e,t.data.sessionID));return;case"session.usage.updated":sn(e,t.data.sessionID,w=>{w.cost=t.data.cost,w.tokens=t.data.tokens}),wa(e,t.data.sessionID);return;case"session.moved":L6(e,t.data);return;case"session.forked":kc(e,t.data.sessionID,(l=t.location)==null?void 0:l.directory);return;case"session.compaction.started":Ra(e,t.data.sessionID),pi(e,t.data.sessionID,"compacting",(d=t.location)==null?void 0:d.directory);return;case"session.compaction.failed":Bd(e,t.data.sessionID,{failed:!0,directory:(u=t.location)==null?void 0:u.directory});return;case"session.execution.interrupted":Bd(e,t.data.sessionID,{failed:!0,interrupted:!0,refreshMessages:!0,directory:(f=t.location)==null?void 0:f.directory});return;case"session.execution.succeeded":Bd(e,t.data.sessionID,{failed:!1,directory:(g=t.location)==null?void 0:g.directory});return}if(!t.type.startsWith("session."))return;const n="sessionID"in t.data?t.data.sessionID:void 0;n&&(t.type==="session.execution.started"||t.type==="session.step.started"||t.type==="session.step.streamed"||t.type.startsWith("session.text.")||t.type.startsWith("session.reasoning.")||t.type.startsWith("session.tool."))&&(Ra(e,n),pi(e,n,"working",(m=t.location)==null?void 0:m.directory))}async function Bd(e,t,n){var o;const s=Ra(e,t);let r=null;try{r=await $t(e).session.active()}catch(a){En.warn("Failed to reconcile terminal session state",{instanceId:e,sessionId:t,error:a})}if(I6(e,t,s)){if(r&&Object.prototype.hasOwnProperty.call(r,t)){sn(e,t,i=>{i.generationRecovery=null}),((o=Ne().get(e))==null?void 0:o.get(t))?Pa(e,t,"working",{force:!0}):pi(e,t,"working",n.directory);return}n.interrupted&&sn(e,t,a=>{a.generationRecovery="interrupted"}),O6(e,t,n.failed,n.directory),Qv(e,t,n.refreshMessages)}}function Qv(e,t,n=!1){const s=Ht.getInstance(e),r=s==null?void 0:s.getSessionMessageIds(t).some(o=>{const a=s.getMessage(o);return a==null?void 0:a.partIds.some(i=>{var l,d,u;const c=(l=a.parts[i])==null?void 0:l.data;return(c==null?void 0:c.type)==="tool"&&(((d=c.state)==null?void 0:d.status)==="pending"||((u=c.state)==null?void 0:u.status)==="running")})});(n||r)&&hr(e,t,{force:!0}).catch(o=>{En.warn("Failed to refresh settled session messages",{instanceId:e,sessionId:t,error:o})})}function O6(e,t,n,s){var o;((o=Ne().get(e))==null?void 0:o.get(t))?Pa(e,t,"idle",{force:!0}):pi(e,t,"idle"),n&&Ht.getOrCreate(e).failPendingSends(t),ME(e,t)}function L6(e,t){const{sessionID:n,location:s}=t,r=zs(s.directory),o=Array.from(Fe().values()).flatMap(c=>[c.folder,...ko(c.id).flatMap(d=>[d.directory,d.serviceDirectory])].some(d=>zs(d)===r)?[c.id]:[]),a=o.includes(e);a&&(sn(e,n,c=>{c.location=s,c.projectID=t.projectID,c.subpath=t.subpath}),es().get(e)===n&&Ma(e).catch(c=>{En.warn("Failed to refresh moved session catalog",{instanceId:e,sessionId:n,error:c})}));const i=a?[e]:[e,...o];for(const c of new Set(i)){const l=ph.get(c);l&&clearTimeout(l),ph.set(c,setTimeout(()=>{ph.delete(c),wi(c).catch(d=>{En.warn("Failed to refresh moved-session worktrees",{instanceId:c,error:d})}).then(()=>Ei(c,{reset:!0})).then(()=>es().get(c)?Ma(c):void 0).catch(d=>{En.warn("Failed to reconcile moved sessions",{instanceId:c,error:d})})},100))}}function N6(e){if(typeof document>"u")return!1;const t=dk();return!t.osNotificationsEnabled||!t.osNotificationsAllowWhenVisible&&document.visibilityState==="visible"?!1:e==="needsInput"?!!t.notifyOnNeedsInput:e==="idle"?!!t.notifyOnIdle:!1}function F6(e,t){var s;const n=(s=Ne().get(e))==null?void 0:s.get(t);return n?n.parentId!==null&&n.parentId!==void 0:null}function Xv(e,t,n){if(!N6(e))return!1;if(!n)return!0;const s=F6(t,n);return!(s===null||s)}function ug(e){var n;const t=((n=Fe().get(e))==null?void 0:n.folder)??e;return t.split(/[\\/]/).filter(Boolean).pop()??t}function ew(e,t){var r,o;if(!t)return"";const n=(r=Ne().get(e))==null?void 0:r.get(t),s=(o=n==null?void 0:n.title)==null?void 0:o.trim();return s&&s.length>0?s:t}function tw(e){zR(e).catch(t=>{En.warn("Failed to send OS notification",t)})}queueMicrotask(()=>{mT((e,t)=>{Xv("needsInput",e,t.sessionID)&&tw({title:ug(e),body:$e("settings.notifications.events.needsInput")})})});const B6=new Set(["info","success","warning","error"]);async function kc(e,t,n){const s=Fe().get(e);if(!(s!=null&&s.client))return null;const r=$t(e);try{const o=await r.session.get({sessionID:t}),a=HO(o,e);let i,c=!1;Fn(d=>{const u=new Map(d),f=new Map(d.get(e)),g=f.get(t),m=(g==null?void 0:g.status)==="compacting",w={...a,agent:(g==null?void 0:g.agent)??a.agent,model:(g==null?void 0:g.model)??a.model,status:m?"compacting":a.status,retry:m?null:a.retry,idleSince:hy(g==null?void 0:g.status,m?"compacting":a.status,g==null?void 0:g.idleSince),pendingPermission:(g==null?void 0:g.pendingPermission)??a.pendingPermission,pendingForm:(g==null?void 0:g.pendingForm)??!1,runtimeStatusKnown:m||(g==null?void 0:g.runtimeStatusKnown)||!1},S=lo(w,g,g,Zs(e).has(t));return S?(f.set(t,S),u.set(e,f),i=f,S.parentId&&S.status==="working"&&((g==null?void 0:g.status)??"idle")!=="working"&&(c=!0),u):d}),To(e,i),mr(e);const l=i==null?void 0:i.get(t);return l&&!l.parentId&&Ul(e,t),c&&lg(e,t),a}catch(o){return En.error("Failed to fetch session info",o),null}}function pi(e,t,n,s,r){var d;if((d=Ne().get(e))==null?void 0:d.get(t)){Pa(e,t,n,{retry:r});return}const a=`${e}:${t}`,i=Sd.get(a);if(i){i.status=n,i.retry=r;return}const c={status:n,retry:r},l=(async()=>{await kc(e,t)&&Pa(e,t,c.status,{retry:c.retry})})();Sd.set(a,c),l.finally(()=>{Sd.get(a)===c&&Sd.delete(a)})}function U6(e,t){var o;if(t.type!=="session.created"){const a=t.type==="session.revert.staged"?t.data.revert:null;if(IN(e,t.data.sessionID,a),sn(e,t.data.sessionID,i=>{i.revert=a??void 0}),t.type==="session.revert.cleared"){const i=t.data.sessionID;No(e,i),es().get(e)===i&&hr(e,i,{force:!0}).catch(c=>{En.error("Failed to reload messages after clearing revert",c)})}return}const n={...t.data,id:t.data.sessionID,time:{created:t.created,updated:t.created}};if(Zs(e).has(n.id))return;const r=(Ne().get(e)??new Map).get(n.id);if(r){const a={...r.time,...n.time??{}},i={...r,title:n.title||r.title,parentId:n.parentID??r.parentId,metadata:n.metadata??r.metadata,status:r.status??"idle",retry:r.retry??null,time:a};let c;Fn(l=>{const d=new Map(l),u=d.get(e)??new Map;return u.set(r.id,i),d.set(e,u),c=u,d}),To(e,c)}else{const a={id:n.id,instanceId:e,title:n.title||$e("sessionList.session.untitled"),parentId:n.parentID||null,agent:n.agent??"",model:n.model?{providerId:n.model.providerID,modelId:n.model.id}:{providerId:"",modelId:""},status:"idle",retry:null,idleSince:null,version:n.version||"0",projectID:n.projectID??"",metadata:n.metadata,cost:n.cost??0,tokens:n.tokens??{input:0,output:0,reasoning:0,cache:{read:0,write:0}},location:n.location??{directory:((o=Fe().get(e))==null?void 0:o.folder)??""},time:n.time?{...n.time}:{created:Date.now(),updated:Date.now()}};let i;Fn(c=>{const l=new Map(c),d=l.get(e)??new Map;return d.set(a.id,a),l.set(e,d),i=d,l}),To(e,i),a.parentId||Ul(e,a.id),En.info(`[SSE] New session created: ${n.id}`,a)}mr(e)}function K6(e,t){var s;const n=(s=t.data)==null?void 0:s.sessionID;n&&(En.info(`[SSE] Session deleted: ${n}`),zu.delete(`${e}\0${n}`),Yf(e,n))}function V6(e,t){var s;const n=t.data.sessionID;if(n){if(Ra(e,n),Xv("idle",e,n)){const r=ug(e),o=ew(e,n),a=o?`Session "${o}" is idle`:"Session is idle";tw({title:r,body:a})}pi(e,n,"idle",(s=t.location)==null?void 0:s.directory),Qv(e,n),ME(e,n),En.info(`[SSE] Session idle: ${n}`)}}function j6(e,t){var a;const n=t.data.sessionID;if(!n)return;Ra(e,n);const s=t.data.status,r=zO(s),o=WO(s);if(pi(e,n,r,(a=t.location)==null?void 0:a.directory,o),r==="idle"&&Qv(e,n),o){const i=Math.max(0,Math.round((o.next-Date.now())/1e3)),c=i>0?$e("sessionList.status.retryingIn",{seconds:String(i)}):$e("sessionList.status.retrying"),l=ew(e,n);kd==null||kd.dismiss(),kd=Hn({title:l||ug(e),message:$e("sessionList.status.retryToast",{countdown:c,message:o.message,attempt:String(o.attempt)}),variant:"error",duration:7e3})}En.info(`[SSE] Session status updated: ${n}`,{status:r})}function q6(e,t){var d,u,f,g;const n=t.data.sessionID;if(!n)return;En.info(`[SSE] Session compacted: ${n}`),Ra(e,n),((d=Ne().get(e))==null?void 0:d.get(n))?Pa(e,n,"working",{force:!0}):pi(e,n,"working",(u=t.location)==null?void 0:u.directory);const r=Ne().get(e),o=r==null?void 0:r.get(n),a=(f=o==null?void 0:o.title)!=null&&f.trim()?o.title:n,i=((g=Fe().get(e))==null?void 0:g.folder)??e,c=i.split(/[\\/]/).filter(Boolean).pop()??i,l=a?`"${a}"`:n;Hn({title:c,message:$e("sessionEvents.sessionCompactedToast",{label:l}),variant:"info",duration:1e4})}function z6(e,t){var o;const n=t.data.error,s=t.data.sessionID;s&&Bd(e,s,{failed:!0,directory:(o=t.location)==null?void 0:o.directory}),En.error("[SSE] Session error:",n);let r=$e("sessionEvents.sessionError.unknown");n&&("data"in n&&n.data&&typeof n.data=="object"&&"message"in n.data?r=n.data.message:"message"in n&&typeof n.message=="string"&&(r=n.message)),Ns($e("sessionEvents.sessionError.message",{message:r}),{title:$e("sessionEvents.sessionError.title"),variant:"error"})}function W6(e,t){const n=t.data;if(!n||typeof n.message!="string"||typeof n.variant!="string"||!n.message.trim())return;const s=B6.has(n.variant)?n.variant:"info";Hn({title:typeof n.title=="string"?n.title:void 0,message:n.message,variant:s,duration:typeof n.duration=="number"?n.duration:void 0})}function H6(e,t){const n=t.data;if(!n)return;const s=vO(n);if(!s)return;if(gg(e,s)){En.info(`[SSE] Ignoring stale permission request after local reply: ${s}`);return}En.info(`[SSE] Permission request: ${s} (${e_(n)})`);const r=ua(n);if(Xv("needsInput",e,r)){const o=ug(e),a=ew(e,r),i=a?`Session "${a}" needs permission`:"Session needs permission";tw({title:o,body:i})}}function G6(e,t){const n=kO(t.data);n&&(En.info(`[SSE] Permission replied: ${n}`),fg(e,n))}vn.onNativeSessionEvent=R6;vn.onSessionUpdate=U6;vn.onSessionCompacted=q6;vn.onSessionDeleted=K6;vn.onSessionError=z6;vn.onSessionIdle=V6;vn.onSessionStatus=j6;vn.onTuiToast=W6;vn.onPermissionUpdated=H6;vn.onPermissionReplied=G6;vn.onWorktreeReady=DL;vn.onWorktreeUpdated=async e=>{await wi(e),await Ei(e,{reset:!0})};const Z6=Object.freeze(Object.defineProperty({__proto__:null,abortSession:_6,activeParentSessionId:Iv,activeSessionId:es,agents:Rv,backgroundSession:D6,beginSessionGenerationAdmission:sE,cancelSessionGenerationAdmissions:Xf,clearActiveParentSession:oE,clearActiveSession:iE,clearInstanceDeletedSessionAuthority:QC,clearInstanceDraftPromptValues:eE,clearInstanceDraftPrompts:tE,clearInstanceSessionExpansionState:hE,clearInstanceSessionSelection:aE,clearSessionCatalogState:Gf,clearSessionDraftPrompt:XC,clearSessionListRequestState:Ll,clearSessionSearch:HC,createSession:$C,deleteSession:Zf,ensureSessionAncestorsExpanded:lg,executeCustomCommand:k6,expandedSessions:Lv,fetchAgents:Jf,fetchProviders:Da,fetchSessions:Ei,forkSession:CC,getActiveCatalogLocation:Nn,getActiveSession:cE,getAuthoritativeDraftSessionIdsForInstance:mq,getAuthoritativeSessionExpansionIdsForInstance:JC,getAuthoritativelyDeletedSessionIdsForInstance:Zs,getChildSessions:jv,getDefaultModel:Sf,getDescendantSessions:dE,getMessageNextCursor:IC,getSessionDraftPrompt:GC,getSessionDraftPromptsForInstance:hq,getSessionFamily:uE,getSessionHasMore:lp,getSessionInfo:Pq,getSessionListError:Dq,getSessionMessagesLoadError:mE,getSessionRoot:Ia,getSessionSearchQuery:eq,getSessionSearchSessions:_q,getSessionThreads:fE,getSessions:lE,getThreadTotals:Iq,getVisibleSessionIds:Tq,hasAuthoritativeSessionSelection:Uv,hasMoreMessages:PC,hydrateActiveSessionSelection:kq,hydrateRestoredSessionChain:Tv,hydrateSessionDraftPrompt:fq,hydrateSessionExpansion:$q,hydrateSessionGenerationRecovery:Sq,hydrateSessionIdleMarkers:bq,isLatestMessageWindow:RC,isSessionBusy:yE,isSessionExpanded:gE,isSessionMessagesLoading:Aq,isSessionSearchLoading:tq,loadAllSessions:xC,loadLatestMessageWindow:MC,loadMessageAnchor:DC,loadMessages:hr,loadMoreMessages:EC,loadMoreSessions:Mv,loadNewerMessageWindow:TC,loadOldestMessageWindow:AC,loading:tg,markSessionIdleSeen:wq,onSessionDraftHydrated:gq,providers:Ti,refreshSessionCatalog:Ma,renameSession:M6,resetSessionPagination:WC,runShellCommand:x6,searchSessions:_C,sendMessage:S6,sessionInfoByInstance:Fl,sessions:Ne,setActiveParentSession:rE,setActiveSession:Vv,setActiveSessionFromList:Mq,setSessionDraftPrompt:uq,setSessionExpanded:qv,setSessionStatus:Pa,toggleSessionExpanded:Cq,updateSessionAgent:$6,updateSessionModel:E6},Symbol.toStringTag,{value:"Module"}));function Oa(e){const n=/^(?:[A-Za-z]:[/\\]|[/\\]{2})/.test(e)?e.replace(/\\/g,"/").toLowerCase():e;return n==="/"||/^[a-z]:\/$/.test(n)?n:n.replace(/\/+$/,"")}function Y6(e,t,n){return[...e].filter(s=>!t.has(s)&&!n(s))}function VG(e,t){const n=new Map;for(const o of t){if(o.status==="stopped"||o.status==="error")continue;const a=Oa(o.folderPath);n.set(a,[...n.get(a)??[],o])}const s=new Map,r=new Set;return e.flatMap((o,a)=>{var f;if(o.kind!=="workspace"||typeof o.folderPath!="string")return[];const i=Oa(o.folderPath),c=s.get(i)??0,l=Number.isInteger(o.occurrence)&&Number(o.occurrence)>=0?Number(o.occurrence):c;s.set(i,Math.max(c,l)+1);const d=(f=n.get(i))==null?void 0:f[l],u=d&&!r.has(d.id)?d.id:null;return u&&r.add(u),[{tabIndex:a,descriptor:{kind:"workspace",folderPath:o.folderPath,occurrence:l},existingWorkspaceId:u}]})}function jG(e,t,n){const s=new Map(e.map(c=>[c.id,c])),r=c=>{let l=c?s.get(c):void 0;const d=new Set;for(;l!=null&&l.parentId;){if(d.has(l.id))return null;d.add(l.id),l=s.get(l.parentId)}return(l==null?void 0:l.id)??null},o=r(t);if(n==="info")return{parentSessionId:o,activeSessionId:"info"};const a=n?s.get(n):void 0,i=r(a==null?void 0:a.id);return a&&i&&(!o||o===i)?{parentSessionId:i,activeSessionId:a.id}:o?{parentSessionId:o,activeSessionId:o}:null}function qG(e,t,n=[]){const s=new Set(e.map(({id:a})=>a)),r=new Set(n),o=[t.activeParentSessionId,t.activeSessionId==="info"?void 0:t.activeSessionId,...t.draftSessionIds,...t.attachmentSessionIds??[],...t.scrollSessionIds,...t.idleMarkerSessionIds??[],...t.generationRecoverySessionIds??[],...t.expandedSessionIds??[]];return new Set(o.filter(a=>!!a&&!s.has(a)&&!r.has(a)))}function zG(e,t){return(Number.isInteger(t)&&t>=0?e[t]:null)||e.find(s=>!!s)||null}function WG(e,t,n){return!!(e&&t&&n)}function J6(e){switch(e){case"agent.updated":return["agents"];case"command.updated":return["commands"];case"models-dev.refreshed":return["agents","providers","commands"];case"model.updated":case"provider.updated":return["providers"];case"integration.updated":case"credential.updated":case"credential.switched":return["providers","metadata"];case"config.updated":return["agents","providers","commands","metadata"];case"plugin.updated":return["agents","providers","commands"];case"mcp.status.changed":case"mcp.resources.changed":return["metadata"];case"filesystem.changed":return["filesystem"];case"vcs.branch.updated":return["filesystem","metadata"];default:return[]}}class Q6{constructor(){this.pending=new Set}observe(t,n,s){return n==="error"||n==="disconnected"&&s!=="workspace stopped"?(this.pending.add(t),!1):n!=="connected"?!1:this.pending.delete(t)}clear(t){this.pending.delete(t)}}const[HG,X6]=R(!1),[GG,ZG]=R(null),[YG,JG]=R(!1),[QG,XG]=R(!1),[eZ,tZ]=R([]),[nZ,sZ]=R(new Map),La=new Map;function e8(e,t,n){const s=La.get(e);if(s){for(const[r,o]of s)!t.has(r)&&n>=o&&s.delete(r);s.size===0&&La.delete(e)}}function fg(e,t,n=Date.now()){if(!t)return;let s=La.get(e);s||(s=new Map,La.set(e,s)),s.set(t,n)}function gg(e,t){const n=La.get(e);return n?n.has(t):!1}function t8(e){La.delete(e)}const Na=new Map;function nw(e,t,n=Date.now()){const s=Na.get(e)??new Map;s.set(t,n),Na.set(e,s)}function AE(e,t){var n;return((n=Na.get(e))==null?void 0:n.has(t))??!1}function n8(e,t,n){const s=Na.get(e);if(s){for(const[r,o]of s)!t.has(r)&&n>=o&&s.delete(r);s.size||Na.delete(e)}}function s8(e){Na.delete(e)}let DE=(e,t)=>t;function r8(e,t){let n=e,s=e;const r=new Set;for(;n&&!r.has(n);){r.add(n);const o=t(n);if(!o)return s;if(s=o.id,o.revert||!o.parentId)return o.id;n=o.parentId}return n||e}function o8(e){DE=e}function PE(e,t){return`${e}:${DE(e,t)}`}const[i8,IE]=R(new Map);function RE(e,t){return i8().get(PE(e,t))??!1}function cl(e,t,n){IE(s=>{const r=PE(e,t);if(s.get(r)===n)return s;const o=new Map(s);return n?o.set(r,!0):o.delete(r),o})}function a8(e,t){const n=!RE(e,t);return cl(e,t,n),n}function OE(e){IE(t=>{const n=`${e}:`;let s=!1;const r=new Map(t);for(const o of Array.from(r.keys()))o.startsWith(n)&&(r.delete(o),s=!0);return s?r:t})}function c8(e,t,n,s){if(!e)return t;let r=typeof e=="string"?e:e instanceof Error?e.message:String(e);try{const o=JSON.parse(r),a=l8(o,n);if(a)return a;o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"&&(r=o.error)}catch{}return s&&(r===Vh||r.startsWith(`${Vh}:`))?s:r}function l8(e,t){if(!e||typeof e!="object")return;const n=e,s=typeof n.name=="string"?n.name:n._tag;if(!["ConfigInvalidError","ConfigJsonError","ConfigFrontmatterError","ConfigDirectoryTypoError"].includes(String(s)))return;const r=n.data&&typeof n.data=="object"?n.data:n,o=[t];typeof r.path=="string"&&r.path.trim()&&o.push(r.path.trim()),typeof r.message=="string"&&r.message.trim()&&o.push(r.message.trim());const a=typeof r.dir=="string"?r.dir.trim():"",i=typeof r.suggestion=="string"?r.suggestion.trim():"";if(a&&i?o.push(`${a} → ${i}`):(a||i)&&o.push(a||i),Array.isArray(r.issues))for(const c of r.issues){if(!c||typeof c!="object")continue;const l=c,d=Array.isArray(l.path)?l.path.map(String).join("."):"",u=typeof l.message=="string"?l.message.trim():"";d&&u?o.push(`${d}: ${u}`):u&&o.push(u)}return o.join(`
|
|
35
|
-
`)}function d8(e){const t=e.toLowerCase();return t.includes("opencode binary not found")||t.includes("binary not found")||t.includes("no such file or directory")||t.includes("binary is not executable")||t.includes("enoent")}const[rZ,LE]=R(null),TS=new Map;function u8(e){LE(e)}function oZ(){LE(null)}function f8(e){const t=e.id,n=e.error,s=c8(n,$e("app.launchError.fallbackMessage"),$e("app.launchError.invalidConfig"),$e("opencodeBinarySelector.validation.v2Required")),r=TS.get(t);if(r&&r===s)return;TS.set(t,s);const o=(e.binaryLabel||e.binaryId||"opencode2").trim()||"opencode2",a=d8(s);u8({source:"workspace",instanceId:t,message:s,binaryPath:o,missingBinary:a})}const mp=Ut("session"),fc=new Map,gc=new Map;function g8(e){return Bs(e)}function NE(e,t){var s;if(!e)return!1;const n=(s=e.mcpStatus)==null?void 0:s.location;return!!(n&&Bs(n)===Bs(t))}function h8(e,t){return!e||e.project===void 0||e.mcpStatus===void 0?!1:!t||NE(e,t)}function FE(e,t){const n=e.client;if(!n)return mp.warn("[metadata] Skipping fetch; client missing",{instanceId:e.id}),Promise.resolve();const s=(t==null?void 0:t.location)??{directory:e.folder},r=g8(s),o=co(e.id)??e.metadata;if(!(t!=null&&t.force)&&h8(o,s))return Promise.resolve();const a=wu(e.id),i=fc.get(e.id);if((i==null?void 0:i.client)===n&&i.generation===a&&i.locationKey===r)return i.promise;const c={client:n,generation:a,locationKey:r,promise:Promise.resolve()};return c.promise=(async()=>{var l;try{const d=Io(s),[u,f,g]=await Promise.allSettled([BE(e,t),n.project.list(),n.mcp.list({location:d},Zt(s))]),m=(l=co(e.id))==null?void 0:l.project,w=m&&f.status==="fulfilled"?f.value.find(v=>v.id===m.id):void 0,S=co(e.id)??o,b={...S??{}};if(S&&!NE(S,s)&&(b.mcpStatus=void 0),u.status==="fulfilled"&&m&&(w!=null&&w.vcs)&&(b.project={...m,vcs:w.vcs}),g.status==="fulfilled"&&(b.mcpStatus=g.value),!(b!=null&&b.version)&&e.binaryVersion&&(b.version=e.binaryVersion),fc.get(e.id)!==c||wu(e.id)!==a)return;F_(e.id,b)}catch(d){mp.error("Failed to load instance metadata",d)}finally{fc.get(e.id)===c&&fc.delete(e.id)}})(),fc.set(e.id,c),c.promise}function BE(e,t){const n=e.client;if(!n)return Promise.resolve();const s=co(e.id)??e.metadata;if(!(t!=null&&t.force)&&s&&"project"in s)return Promise.resolve();const r=wu(e.id),o=gc.get(e.id);if((o==null?void 0:o.client)===n&&o.generation===r)return o.promise;const a={client:n,generation:r,promise:Promise.resolve()};return a.promise=n.location.get({location:{directory:e.folder}}).then(i=>{gc.get(e.id)!==a||wu(e.id)!==r||F_(e.id,{project:i.project,...!(s!=null&&s.version)&&e.binaryVersion?{version:e.binaryVersion}:{}})}).catch(i=>mp.warn("Failed to load project metadata",{instanceId:e.id,error:i})).finally(()=>{gc.get(e.id)===a&&gc.delete(e.id)}),gc.set(e.id,a),a.promise}const[m8,sw]=R(new Map);function Zr(e){return m8().get(e)??[]}function p8(e,t){sw(n=>{const s=new Map(n),r=s.get(e)??[],o=r.findIndex(i=>i.id===t.id);if(o!==-1&&JSON.stringify(r[o])===JSON.stringify(t))return n;const a=r.slice();return o===-1?a.push(t):a[o]=t,s.set(e,a),s})}function y8(e,t){sw(n=>{const s=new Map(n),r=(s.get(e)??[]).filter(o=>o.id!==t);return r.length?s.set(e,r):s.delete(e),s})}function v8(e,t){sw(n=>{const s=new Map(n);return t.length?s.set(e,[...t]):s.delete(e),s})}function w8(e){v8(e,[])}function UE(e){var t;if(!(e.sessionID!=="global"||!e.location))return{headers:{"x-opencode-directory":encodeURIComponent(e.location.directory),...(t=Zt(e.location))==null?void 0:t.headers}}}const[b8,S8]=R(new Map);function k8(e){S8(t=>{const n=new Map(t);return n.set(e,(n.get(e)??0)+1),n})}function iZ(e){return b8().get(e)??0}function aZ(e,t=100){let n;return{trigger(){n&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e()},t)},cancel(){n&&clearTimeout(n),n=void 0}}}const[cZ,KE]=R(new Set),pp=new Set;function lZ(e){KE(t=>t.has(e)?t:new Set(t).add(e))}function x8(e){KE(t=>{if(!t.has(e))return t;const n=new Set(t);return n.delete(e),n})}function dZ(e){return pp.add(e),()=>pp.delete(e)}function _8(e){for(const t of pp)t(e)}async function $8(e,t,n,s){let r=e;for(;;){s==null||s.throwIfAborted();const o=t();if(r!==o){r=o;continue}const a=new AbortController,i=()=>a.abort(s==null?void 0:s.reason);s==null||s.addEventListener("abort",i,{once:!0});let c;try{c=await Promise.race([r.then(d=>({type:"result",result:d})),n(r,a.signal).then(()=>({type:"change"}))])}finally{s==null||s.removeEventListener("abort",i),a.abort()}if(c.type==="change")continue;const l=c.result;if(r===t()){if(l.error!==void 0)throw l.error;return}}}const yp=new Set;function uZ(e){return yp.add(e),()=>yp.delete(e)}function vp(e){for(const t of yp)t(e)}class C8 extends Error{constructor(t){super(t),this.name="RestoreTimeoutError"}}function na(e){if(e.reason instanceof Error)return e.reason;const t=new Error("Restore operation was aborted");return t.name="AbortError",t}function E8(e,t={}){return new Promise((n,s)=>{var l,d;const r=new AbortController;let o=!1;const a=u=>{var f;o||(o=!0,c&&clearTimeout(c),(f=t.signal)==null||f.removeEventListener("abort",i),u())},i=()=>{const u=na(t.signal);r.abort(u),a(()=>s(u))},c=t.timeoutMs===void 0?void 0:setTimeout(()=>{const u=new C8(t.message??"Operation timed out");r.abort(u),a(()=>s(u))},t.timeoutMs);if((l=t.signal)!=null&&l.aborted){i();return}(d=t.signal)==null||d.addEventListener("abort",i,{once:!0}),Promise.resolve().then(()=>e(r.signal)).then(u=>{a(()=>n(u))},u=>{a(()=>s(u))})})}const T8=[250,1e3,2e3];class M8{constructor(t){this.options=t,this.owned=new Map,this.pendingRequestIds=new Map}track(t){const n=this.owned.get(t.id);n?"workspace"in n&&!("released"in n)&&(n.workspace=t):this.owned.set(t.id,{workspace:t})}beginRequest(t){this.pendingRequestIds.set(t,!1)}finishRequest(t){this.pendingRequestIds.delete(t)}forgetRequest(t,n){this.pendingRequestIds.delete(n);const s=this.owned.get(t);s&&"workspace"in s&&!("completion"in s)&&s.workspace.requestId===n&&this.owned.delete(t)}quarantineRequest(t){if(this.pendingRequestIds.has(t)){this.pendingRequestIds.set(t,!0);for(const[n,s]of this.owned){if(!("workspace"in s)||s.workspace.requestId!==t)continue;const r=this.discardTracked(n,{retainTombstone:s.workspace.reused!==!0});return r.finally(()=>this.finishRequest(t)),r}}}trackPendingRequest(t){if(!t.requestId)return!1;const n=this.pendingRequestIds.get(t.requestId);return n===void 0?!1:(this.track(t),n&&this.discardTracked(t.id,{retainTombstone:t.reused!==!0}).finally(()=>this.finishRequest(t.requestId)),!0)}release(t){const n=this.owned.get(t);if(!(!n||"tombstone"in n||"released"in n||"completion"in n))return this.owned.set(t,{released:!0}),n.workspace}get(t){const n=this.owned.get(t);return n&&"workspace"in n&&!("completion"in n)?n.workspace:void 0}async releaseAfter(t,n){const s=this.release(t);if(s)try{return await n(s),s}catch(r){const o=this.owned.get(t);throw s&&o&&"released"in o&&this.owned.set(t,{workspace:s}),r}}releaseTombstoneForUserCreate(t){const n=this.owned.get(t);n&&("tombstone"in n||"released"in n)&&this.owned.delete(t)}owns(t){const n=this.owned.get(t);return!!(n&&!("released"in n))}shouldIgnoreEvent(t){const n=this.owned.get(t);return!!n&&("completion"in n||"tombstone"in n)}discardCreated(t,n){return this.start(t,n)}discardTracked(t,n){const s=this.owned.get(t);return!s||"tombstone"in s||"released"in s?Promise.resolve():"completion"in s?s.completion:this.start(s.workspace,n)}start(t,n){const s=this.owned.get(t.id);if(s&&"completion"in s)return s.completion;if(s&&("tombstone"in s||"released"in s))return Promise.resolve();let r;const o=new Promise(i=>{r=i}),a={workspace:t,completion:o,resolve:r,retainTombstone:(n==null?void 0:n.retainTombstone)===!0};return this.owned.set(t.id,a),this.run(a),o}async run(t){var a,i;let n,s=!1;const r=this.options.retryDelaysMs??T8;let o=0;try{await Dp(()=>this.options.discardWorkspace(t.workspace),{maxAttempts:r.length+1,wait:()=>(this.options.wait??(c=>new Promise(l=>setTimeout(l,c))))(r[o++]??0)}),s=!0}catch(c){n=c}if(this.owned.get(t.workspace.id)===t){if(!s)try{this.options.restoreWorkspace(t.workspace)}catch(c){n=c}if(s&&t.retainTombstone?this.owned.set(t.workspace.id,{tombstone:!0}):this.owned.delete(t.workspace.id),t.resolve(),!s)try{(i=(a=this.options).onPermanentFailure)==null||i.call(a,t.workspace,n)}catch{}}}}class A8{constructor(t,n){this.run=t,this.onError=n,this.tails=new Map}request(t){const r=(this.tails.get(t)??Promise.resolve()).then(async()=>{try{await this.run(t)}catch(o){this.onError(t,o)}}).finally(()=>{this.tails.get(t)===r&&this.tails.delete(t)});return this.tails.set(t,r),r}}async function D8(e){try{await e}catch{}}function P8(e){return Dp(()=>kt.cancelWorkspaceCreation(e),{maxAttempts:4,initialDelayMs:250,maxDelayMs:2e3,backoffMultiplier:4})}const MS=e=>e==="error"||e==="stopped"?3:e==="ready"?2:1;function AS(e,t){const n=MS(t.status)-MS(e.status);if(n!==0)return n>0?t:e;const s=Date.parse(e.updatedAt),r=Date.parse(t.updatedAt);return Number.isFinite(s)&&Number.isFinite(r)&&s!==r?r>s?t:e:t}class I8{constructor(){this.byRequestId=new Map,this.byWorkspaceId=new Map,this.stoppedByWorkspaceId=new Map}begin(t,n,s){const r={requestId:t,wait:n,workspaceIds:new Set,...s?{expectedPath:Oa(s)}:{}};return this.byRequestId.set(t,r),r}bindResponse(t,n){const s=this.byRequestId.get(t);if(!s)return;s.workspaceIds.add(n),this.byWorkspaceId.set(n,s);const r=this.stoppedByWorkspaceId.get(n);r&&(s.terminal=r,this.stoppedByWorkspaceId.delete(n))}deferWorkspace(t){const n=t.requestId?this.byRequestId.get(t.requestId)??this.byWorkspaceId.get(t.id):this.byWorkspaceId.get(t.id);return n?(n.workspace=n.workspace?AS(n.workspace,t):t,n.workspaceIds.add(t.id),this.byWorkspaceId.set(t.id,n),(t.status==="error"||t.status==="stopped")&&(n.terminal={status:t.status,message:t.error}),!0):!1}deferRefreshWorkspace(t){if(this.deferWorkspace(t))return!0;const n=Oa(t.path);return[...this.byRequestId.values()].some(s=>s.expectedPath===n)}deferStopped(t,n){const s=this.byWorkspaceId.get(t),r={status:"stopped",message:n};return s?(s.terminal=r,!0):(this.byRequestId.size>0&&this.stoppedByWorkspaceId.set(t,r),!1)}resolve(t,n){const s=this.byRequestId.get(t);return{workspace:s!=null&&s.workspace?AS(n,s.workspace):n,...s!=null&&s.terminal?{terminal:s.terminal}:{}}}end(t){const n=this.byRequestId.get(t);if(n){this.byRequestId.delete(t);for(const s of n.workspaceIds)this.byWorkspaceId.get(s)===n&&this.byWorkspaceId.delete(s),this.stoppedByWorkspaceId.delete(s);this.byRequestId.size===0&&this.stoppedByWorkspaceId.clear()}}}class R8{constructor(){this.requestRevision=0,this.mutationRevision=0,this.workspaceRevisions=new Map}begin(){return{requestRevision:++this.requestRevision,mutationRevision:this.mutationRevision}}markMutation(t){this.workspaceRevisions.set(t,++this.mutationRevision)}isCurrent(t){return t.requestRevision===this.requestRevision}allows(t,n){return this.isCurrent(t)&&(this.workspaceRevisions.get(n)??0)<=t.mutationRevision}complete(t){this.isCurrent(t)&&(this.workspaceRevisions.clear(),this.requestRevision+=1)}}const qt=Ut("api");o8((e,t)=>{const n=Ne().get(e);return n?r8(t,s=>n.get(s)):t});xs.on("yolo.stateChanged",e=>{if(e.type!=="yolo.stateChanged")return;const{instanceId:t,sessionId:n,enabled:s}=e;typeof t!="string"||typeof n!="string"||typeof s!="boolean"||(qt.info(`[SSE] Yolo state changed: ${t}:${n} -> ${s}`),cl(t,n,s))});xs.on("yolo.autoAccepted",e=>{if(e.type!=="yolo.autoAccepted")return;const{instanceId:t,permissionId:n}=e;typeof t!="string"||typeof n!="string"||(fg(t,n),zl(t,n),_f(t,n))});const[Fe,rw]=R(new Map),[Ds,VE]=R(null),[jE,hg]=R(new Map),[O8,ow]=R(new Map),L8=250,Qo=new Map;function qE(e,t){return`${e}\0${t}`}function N8(e,t,n){const s=qE(e,t),r=Qo.get(s);if(r){r.project=n;return}const o={project:n,timeout:setTimeout(()=>{Qo.delete(s),o.project()},L8)};Qo.set(s,o)}function F8(e,t){const n=qE(e,t),s=Qo.get(n);s&&(clearTimeout(s.timeout),Qo.delete(n))}function iw(e){const t=`${e}\0`;for(const[n,s]of Qo)n.startsWith(t)&&(clearTimeout(s.timeout),Qo.delete(n))}const[zE,aw]=R(new Map),[B8,WE]=R(new Map),mg=new Map,pg=new Map;function sa(e){if(e){if(typeof e=="string")return Bs({directory:Oa(e)});if(e.directory)return Bs({...e,directory:Oa(e.directory)})}}function HE(e,t,n,s){const r=sa(s);if(!r)return;const o=e.get(t)??new Map;o.set(n,r),e.set(t,o)}function GE(e,t,n){const s=e.get(t);s&&(s.delete(n),s.size||e.delete(t))}class ZE{constructor(){this.enqueuedAt=new Map,this.sessionCounts=new Map}ensureEnqueuedAt(t){const n=this.enqueuedAt.get(t.id);if(n)return n;const s=Date.now();return this.enqueuedAt.set(t.id,s),s}enqueuedAtFor(t){return this.enqueuedAt.get(t)??Date.now()}remove(t,n){this.enqueuedAt.delete(n)}increment(t,n){const s=this.sessionCounts.get(t)??new Map;s.set(n,(s.get(n)??0)+1),this.sessionCounts.set(t,s)}decrement(t,n){const s=this.sessionCounts.get(t),r=Math.max(0,((s==null?void 0:s.get(n))??0)-1);return r?s==null||s.set(n,r):s==null||s.delete(n),(s==null?void 0:s.size)===0&&this.sessionCounts.delete(t),r}sessionIds(t){var n;return((n=this.sessionCounts.get(t))==null?void 0:n.keys())??new Map().keys()}clear(t,n,s){var r;n.forEach(({id:o})=>this.enqueuedAt.delete(o));for(const o of((r=this.sessionCounts.get(t))==null?void 0:r.keys())??[])s(o);this.sessionCounts.delete(t)}}const Wn=new ZE,ho=new ZE,[U8,K8]=R(new Map);function cw(){const e=Array.from(Fe().values()).some(t=>t.status==="ready");X6(e)}const[lw,dw]=R(null),V8=1e3,xd=new Map,uw=new Map,fw=new Map,gw=new Map,Ud=new Map,Fa=new Map,Mo=new Map,ll=new Map,nr=new Map,xc=new Map,_c=new Map,hw=new Error("Pending request sync was superseded");let j8=0;async function mw(e,t,n=!0){const s=new AbortController,r=_c.get(e)??new Set;r.add(s),_c.set(e,r);try{const o=async()=>{const a=setTimeout(()=>s.abort(),1e4);try{return await t(s.signal)}finally{clearTimeout(a)}};return await(n?gy.run(s.signal,o):o())}finally{r.delete(s),!r.size&&_c.get(e)===r&&_c.delete(e)}}function Wu(e){for(const t of _c.get(e)??[])t.abort()}async function YE(e,t,n){const s=new Array(e.length);let r=0;return await Promise.all(Array.from({length:Math.min(4,e.length)},async()=>{for(;t()&&r<e.length;){const o=r++;try{s[o]={status:"fulfilled",value:await n(e[o])}}catch(a){s[o]={status:"rejected",reason:a}}}})),s.filter(o=>o!==void 0)}function Us(e,t){e.set(t,(e.get(t)??0)+1)}function dl(e){Us(Ud,e),Us(Fa,e),Us(Mo,e)}const Er=new R8,mn=new M8({discardWorkspace:e=>e.requestId?kt.cancelWorkspaceCreation(e.requestId):Promise.reject(new Error(`Restore workspace ${e.id} has no creation request`)),restoreWorkspace:e=>{Er.markMutation(e.id),ra(e)},onPermanentFailure:(e,t)=>{qt.error("Failed to cancel restore workspace ownership; restored it to the UI",{workspaceId:e.id,error:t})}});let DS=0;const so=new I8,q8=new A8(async e=>{await D8(uw.get(e));const t=Fe().get(e);if(!(t!=null&&t.client)||t.status!=="ready")return;let n;try{await Ei(e,{reset:!0})}catch(o){n=o}if(await Promise.all([wi(e),ql(e),pw(e),QE(e)]),n)throw n;const s=ng().get(e)??new Set;for(const o of s)No(e,o);const r=es().get(e);r&&s.has(r)&&await hr(e,r,{force:!0}),mr(e)},(e,t)=>{qt.warn("Failed to resync sessions after instance connection",{instanceId:e,error:t})}),JE=new Q6;function z8(e){q8.request(e)}async function QE(e){const t=Fe().get(e);if(!(t!=null&&t.client)||t.status!=="ready")return;const n=ng().get(e)??new Set;await Promise.all(Array.from(n,async s=>{var o,a;const r=((a=(o=Ne().get(e))==null?void 0:o.get(s))==null?void 0:a.location.directory)??t.folder;try{await ij(e,s,r)}catch(i){qt.warn("Failed to resync session inbox after connection",{instanceId:e,sessionId:s,error:i})}}))}const W8=["agents","providers","commands","metadata","filesystem"],$c=new Map;function pw(e,t=W8){const n=$c.get(e);if(n){for(const a of t)n.pending.add(a);return n.promise}const s=Fe().get(e);if(!(s!=null&&s.client)||s.status!=="ready")return Promise.resolve();const r=s.client,o={promise:Promise.resolve(),pending:new Set(t)};return o.promise=(async()=>{do{const a=new Set(o.pending);o.pending.clear(),a.has("filesystem")&&k8(e);const i=[],c=Nn(e);a.has("agents")&&i.push(Jf(e,c,!0)),a.has("providers")&&i.push(Da(e,c,!0)),a.has("commands")&&i.push(z_(e,r,c)),a.has("metadata")&&i.push(FE(s,{force:!0,location:c})),await Promise.all(i)}while(o.pending.size)})().finally(()=>{$c.get(e)===o&&$c.delete(e)}),$c.set(e,o),o.promise}xs.on("instance.eventStatus",e=>{var n;if(e.type!=="instance.eventStatus")return;const t=JE.observe(e.instanceId,e.status,e.reason);e.status==="connected"&&(((n=lw())==null?void 0:n.id)===e.instanceId&&dw(null),t&&z8(e.instanceId))});function H8(){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?`restore-${globalThis.crypto.randomUUID()}`:(DS+=1,`restore-${Date.now().toString(36)}-${DS.toString(36)}`)}const Hu=new Map;function ul(e,t){const n=Hu.get(e);if(n){Hu.delete(e);for(const s of n)t?s.reject(t):s.resolve()}}function mr(e){vq(e,new Set(Wn.sessionIds(e)),new Set(ho.sessionIds(e)))}function G8(e,t){const n=Fe().get(e.id);return{id:e.id,folder:e.path,projectName:t??(n==null?void 0:n.projectName)??e.name,port:e.port??(n==null?void 0:n.port)??0,pid:e.pid??(n==null?void 0:n.pid)??0,proxyPath:e.proxyPath,status:e.status,error:e.error,client:(n==null?void 0:n.client)??null,metadata:n==null?void 0:n.metadata,binaryPath:e.binaryId??e.binaryLabel??(n==null?void 0:n.binaryPath),binaryLabel:e.binaryLabel,binaryVersion:e.binaryVersion??(n==null?void 0:n.binaryVersion),environmentVariables:(n==null?void 0:n.environmentVariables)??ef().environmentVariables??{}}}function ra(e,t){const n=G8(e,t);Fe().has(e.id)?fl(e.id,n):aT(n),e.status==="ready"?(Z8(e),ul(e.id)):(e.status==="error"||e.status==="stopped")&&ul(e.id,new Error(e.error||`Workspace ${e.id} did not become ready`))}function Z8(e){const t=Fe().get(e.id);if(!t)return;const n=e.port??t.port,s=e.proxyPath;if(t.client&&t.proxyPath===s){n&&t.port!==n&&fl(e.id,{port:n});return}t.client&&(fa.destroyClientsForInstance(e.id),Ol(e.id));const r=fa.createClient(e.id,s,()=>Ds()===e.id);fl(e.id,{client:r,port:n??0,proxyPath:s,status:"ready"}),vn.seedStatusIfMissing(e.id,"connecting");const o=eT(e.id);fw.set(e.id,o.sessions),gw.set(e.id,o.workspaceMetadata);const a=tT(e.id,{propagateErrors:!0,sessionHydration:o.sessions,workspaceMetadataHydration:o.workspaceMetadata});uw.set(e.id,a),a.catch(i=>{qt.error("Failed to hydrate instance data",i)})}function yg(e){const t=Fe().get(e);return(t==null?void 0:t.status)==="ready"&&t.client?Promise.resolve():(t==null?void 0:t.status)==="error"||(t==null?void 0:t.status)==="stopped"?Promise.reject(new Error(t.error||`Workspace ${e} did not become ready`)):new Promise((n,s)=>{const r={resolve:n,reject:s},o=Hu.get(e)??new Set;o.add(r),Hu.set(e,o);const a=Fe().get(e);(a==null?void 0:a.status)==="ready"&&a.client?ul(e):((a==null?void 0:a.status)==="error"||(a==null?void 0:a.status)==="stopped")&&ul(e,new Error(a.error||`Workspace ${e} did not become ready`))})}async function Y8(e){await yg(e),await fw.get(e)}async function J8(e){await yg(e),await gw.get(e)}function yw(e){const t=Fe().get(e);t&&(t.client&&fa.destroyClientsForInstance(e),Ol(e),vn.seedStatus(e,"disconnected"))}function XE(e,t){var n;return NL(t,[Nn(e),...ko(e),...Array.from(((n=Ne().get(e))==null?void 0:n.values())??[]).map(s=>s.location),...Zr(e).flatMap(s=>s.location?[s.location]:[])])}async function Q8(e,t=!1,n=()=>!0){var o,a,i;const s=Fe().get(e);if(!(s!=null&&s.client))return;const r=Fa.get(e)??0;try{const c=Date.now(),l=[],d=XE(e,s.folder),u=new Set,f=await YE(d,n,async v=>{const k=await mw(e,C=>s.client.permission.request.list({location:Io(v)},{...Zt(v),signal:C}));return{location:v,response:k}}),g=[];for(const v of f){if(v.status==="rejected"){g.push(v.reason);continue}const{location:k,response:C}=v.value;qt.info("permission.request.list",{instanceId:e,location:k,resolvedLocation:C.location});const _={directory:C.location.directory||k.directory,workspaceID:bf(C.location)},T=sa(_);T&&(u.add(T),l.push(...C.data.map(P=>({request:P,location:_,key:T}))))}const m=new Set(l.map(({request:v})=>v.id));if(!n()||(Fa.get(e)??0)!==r){if(t)throw hw;return}g.length||e8(e,m,c);const w=l.filter(({request:v})=>!gg(e,v.id)),S=new Set(w.map(({request:v})=>v.id)),b=Fo(e);for(const v of b){const k=((o=mg.get(e))==null?void 0:o.get(v.id))??sa((i=(a=Ne().get(e))==null?void 0:a.get(ua(v)??""))==null?void 0:i.location);!S.has(v.id)&&k&&u.has(k)&&(zl(e,v.id),_f(e,v.id))}for(const{request:v,location:k}of w){const C=vw(e,v,k)??v;L_(e,C)}if(mr(e),g.length&&(qt.warn("Pending permission scan was partial",{instanceId:e,failedLocations:g.length}),t))throw g[0]}catch(c){if(qt.warn("Failed to sync pending permissions",{instanceId:e,error:c}),t)throw c}}async function X8(e,t=!1,n=()=>!0){var o,a,i;const s=Fe().get(e);if(!(s!=null&&s.client))return;const r=Mo.get(e)??0;try{const c=Date.now(),l=[],d=XE(e,s.folder),u=new Set,f=await YE(d,n,async b=>{const v=await mw(e,k=>s.client.form.list({location:Io(b)},{...Zt(b),signal:k}));return{location:b,response:v}}),g=[];for(const b of f){if(b.status==="rejected"){g.push(b.reason);continue}const{location:v,response:k}=b.value,C={directory:k.location.directory||v.directory,workspaceID:bf(k.location)},_=sa(C);_&&(u.add(_),l.push(...k.data.map(T=>({form:T.sessionID==="global"?{...T,location:k.location}:T,location:C,key:_}))))}if(!n()||(Mo.get(e)??0)!==r){if(t)throw hw;return}const m=new Set(l.map(({form:b})=>b.id));g.length||n8(e,m,c);const w=l.filter(({form:b})=>!AE(e,b.id)),S=new Set(w.map(({form:b})=>b.id));for(const b of Zr(e)){const v=((o=pg.get(e))==null?void 0:o.get(b.id))??sa(b.location)??sa((i=(a=Ne().get(e))==null?void 0:a.get(b.sessionID))==null?void 0:i.location);!S.has(b.id)&&v&&u.has(v)&&Wl(e,b.id)}for(const{form:b,location:v}of w)bw(e,b,v);if(mr(e),g.length&&(qt.warn("Pending form scan was partial",{instanceId:e,failedLocations:g.length}),t))throw g[0]}catch(c){if(qt.warn("Failed to sync pending forms",{instanceId:e,error:c}),t)throw c}}async function e9(e,t,n){for(let s=0;s<3&&!n.cancelled;s+=1){const r=(Ud.get(e)??0)+1;Ud.set(e,r);const o=()=>!n.cancelled&&Ud.get(e)===r&&ll.get(e)===t;try{await Promise.all([Q8(e,!0,o),X8(e,!0,o)]);return}catch(a){if(a!==hw)throw a}}if(!n.cancelled&&ll.get(e)===t)throw new Error("Pending request sync did not stabilize")}function ql(e,t){const n=ll.get(e);if(n===void 0)return Promise.resolve();const s=nr.get(e);if((s==null?void 0:s.generation)===n)return t==null||t(()=>{var a;((a=nr.get(e))==null?void 0:a.token)===s.token&&(s.token.cancelled=!0,Wu(e),dl(e),nr.delete(e))}),s.promise;const r={cancelled:!1},o=e9(e,n,r).finally(()=>{var a;((a=nr.get(e))==null?void 0:a.promise)===o&&nr.delete(e)});return nr.set(e,{generation:n,token:r,promise:o}),t==null||t(()=>{var a;((a=nr.get(e))==null?void 0:a.token)===r&&(r.cancelled=!0,Wu(e),dl(e),nr.delete(e))}),o}function vg(e){const t=nr.get(e);t&&(t.token.cancelled=!0),Wu(e),nr.delete(e),dl(e),ql(e).catch(n=>{qt.warn("Failed to reconcile pending requests after an ambiguous mutation",{instanceId:e,error:n})})}async function t9(e){const t=Ne().get(e),n=Array.from((t==null?void 0:t.values())??[]).some(r=>r.status==="working"||r.status==="compacting");let s;if(n||Fo(e).length||Zr(e).length)try{await mw(e,r=>SC(e,r),!1)}catch(r){s=r}if(await ql(e),mr(e),s)throw s}function n9(e){const t=xc.get(e);if(t)return t;const n=t9(e).finally(()=>{xc.get(e)===n&&xc.delete(e)});return xc.set(e,n),n}function eT(e,t=!1){const n=t?wi(e):Xi(e),s=Promise.resolve().then(async()=>{const a=Fe().get(e);a!=null&&a.client&&await BE(a,{force:t}).catch(i=>{qt.warn("Failed to load project metadata before session hydration",{instanceId:e,error:i})})}),r=Promise.all([n,s]).then(()=>{});r.catch(a=>qt.warn("Failed to hydrate workspace metadata",{instanceId:e,error:a}));const o=Promise.resolve().then(async()=>{WC(e),await Ei(e,{projectMetadata:s}).catch(a=>{qt.error("Failed to hydrate sessions",{instanceId:e,error:a})})});return o.then(async()=>{const a=Fe().get(e);a!=null&&a.client&&await FE(a,{force:t,location:Nn(e)})}).catch(a=>qt.warn("Failed to load supplemental instance metadata",{instanceId:e,error:a})),{sessions:o,workspaceMetadata:r}}async function tT(e,t){try{const n=t!=null&&t.sessionHydration?{sessions:t.sessionHydration,workspaceMetadata:t.workspaceMetadataHydration??Promise.resolve()}:eT(e,t==null?void 0:t.force);await Promise.all([n.sessions,n.workspaceMetadata,Ma(e,t==null?void 0:t.force)]),await hM(e),await ql(e)}catch(n){if(qt.error("Failed to fetch initial data",n),t!=null&&t.propagateErrors)throw n}}function nT(e){mu(e),Dy(e),Ay(e),ww(e),pT(e)}async function yh(e,t){if(xd.has(e))return xd.get(e);const n=(async()=>{const s=Fe().get(e);s!=null&&s.client&&(qt.info("Rehydrating instance",{instanceId:e,reason:t==null?void 0:t.reason}),nT(e),await tT(e,{force:!0}))})().finally(()=>{xd.delete(e)});return xd.set(e,n),n}async function sT(){if(!Cp())return;const e=Er.begin(),t=new Set(Fe().keys());try{const n=await kt.fetchWorkspaces();if(!Er.isCurrent(e))return;const s=new Set(n.map(({id:o})=>o));for(const o of n)if(Er.allows(e,o.id)&&(mn.trackPendingRequest(o),!so.deferRefreshWorkspace(o))){if(mn.owns(o.id)){mn.track(o);continue}ra(o)}const r=[...t].filter(o=>Er.allows(e,o));for(const o of Y6(r,s,a=>mn.owns(a)))yw(o),wg(o,{authoritative:!1})}finally{Er.complete(e)}}const rT=async function(){try{return await sT(),{}}catch(t){return qt.error("Failed to load workspaces",t),{error:t}}}();let Gu=rT;const wp=new Set;function s9(e){Gu=e,wp.forEach(t=>t())}function r9(e,t){return Gu!==e?Promise.resolve():new Promise((n,s)=>{const r=()=>{wp.delete(o),t==null||t.removeEventListener("abort",a)},o=()=>{r(),n()},a=()=>{r(),s(t==null?void 0:t.reason)};wp.add(o),t==null||t.addEventListener("abort",a,{once:!0}),Gu!==e&&o()})}xs.onOpen(()=>{s9(sT().then(()=>({}),e=>(qt.warn("Failed to reconcile workspaces after event reconnect",e),{error:e})))});async function o9(e){await $8(rT,()=>Gu,r9,e)}xs.on("*",e=>i9(e));function i9(e){if(!Cp())return;const t=e.type==="workspace.log"?e.entry.workspaceId:"workspace"in e?e.workspace.id:"workspaceId"in e&&typeof e.workspaceId=="string"?e.workspaceId:null;if(t&&e.type!=="workspace.log"&&Er.markMutation(t),!("workspace"in e&&(mn.trackPendingRequest(e.workspace),so.deferWorkspace(e.workspace)))&&!(e.type==="workspace.stopped"&&so.deferStopped(e.workspaceId,e.reason))&&!(t&&mn.shouldIgnoreEvent(t)))switch(e.type){case"workspace.created":ra(e.workspace);break;case"workspace.started":ra(e.workspace);break;case"workspace.error":ra(e.workspace),f8(e.workspace),OE(e.workspace.id),hT(e.workspace.id);break;case"workspace.stopped":_8(e.workspaceId),mn.release(e.workspaceId),yw(e.workspaceId),wg(e.workspaceId,{authoritative:e.reason==="deleted"});break;case"workspace.log":a9(e.entry);break}}function a9(e){const t={timestamp:new Date(e.timestamp).getTime(),level:e.level??"info",message:e.message};uT(e.workspaceId,t)}function c9(e){hg(t=>{if(t.has(e))return t;const n=new Map(t);return n.set(e,[]),n})}function oT(e){ow(t=>{if(t.has(e))return t;const n=new Map(t);return n.set(e,!1),n})}function l9(e){hg(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),ow(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n})}function d9(e){return jE().get(e)??[]}function iT(e){return O8().get(e)??!1}function u9(e,t){oT(e),ow(n=>{const s=new Map(n);return s.set(e,t),s}),t||fT(e)}function aT(e){const t=Array.from(Fe().values()).filter(n=>Ao(n.folder)===Ao(e.folder)).length;ll.set(e.id,++j8),rw(n=>{const s=new Map(n);return s.set(e.id,e),s}),c9(e.id),oT(e.id),vp({type:"opened",instanceId:e.id,folder:e.folder,occurrence:t}),cw()}function fl(e,t){var s;const n=Fe().get(e);if(t.client!==void 0&&(n!=null&&n.client)&&t.client!==n.client){Ll(e),Gf(e),Dy(e),Ay(e),iw(e),$c.delete(e);for(const r of((s=Ne().get(e))==null?void 0:s.keys())??[])No(e,r)}rw(r=>{const o=new Map(r),a=o.get(e);return a&&o.set(e,{...a,...t}),o}),cw()}function wg(e,t={}){const n=Fe().get(e),s=n?Array.from(Fe().values()).filter(o=>Ao(o.folder)===Ao(n.folder)).findIndex(o=>o.id===e):-1;n&&s>=0&&t.authoritative===!1&&vp({type:"unavailable",instanceId:e,folder:n.folder,occurrence:s}),x8(e),JE.clear(e);let r=null;rw(o=>{if(!o.has(e))return o;const a=Array.from(o.keys()),i=a.indexOf(e),c=new Map(o);if(c.delete(e),Ds()===e)if(i>0)r=a[i-1]??null;else{const l=Array.from(c.keys());r=l.length>0?l[0]??null:null}return c}),l9(e),Dy(e),ww(e),t8(e),s8(e),pT(e),Ay(e),iw(e),OE(e),hT(e),uw.delete(e),fw.delete(e),gw.delete(e),dl(e),Wu(e),xc.delete(e),ll.delete(e),ul(e,new Error(`Workspace ${e} was removed before it became ready`)),Ds()===e&&VE(r),mu(e),Ht.unregisterInstance(e),tE(e),Ll(e),Gf(e),RL(e),QC(e),hE(e),aE(e),n&&s>=0&&t.authoritative!==!1&&vp({type:"removed",instanceId:e,folder:n.folder,occurrence:s}),cw()}function cT(e){Er.markMutation(e),Fe().has(e)&&(yw(e),wg(e,{authoritative:!1}))}function Kd(e){return e.reused!==!0&&cT(e.id),mn.discardCreated(e,{retainTombstone:e.reused!==!0})}async function lT(e,t){await mn.releaseAfter(e,()=>Dp(()=>kt.releaseWorkspaceCreation(e,t),{maxAttempts:4,initialDelayMs:250,maxDelayMs:2e3,backoffMultiplier:4}))}async function dT(e,t){await P8(t)}function f9(e){const t=mn.get(e);t!=null&&t.requestId&&lT(e,t.requestId).catch(n=>{qt.warn("Failed to transfer restore workspace creation ownership to the user",{instanceId:e,error:n})})}async function PS(e,t){if(t.status==="stopped"){mn.release(e.id),cT(e.id);return}await Kd(e)}async function g9(e,t,n){var l,d,u,f,g,m,w,S,b;const s=n!=null&&n.signal?H8():void 0;s&&mn.beginRequest(s);const r=s&&(n!=null&&n.waitForCreateCommit)?so.begin(s,n.waitForCreateCommit(),e):void 0;let o=null,a=!1,i=!1;const c=()=>{if(!s)return;const v=mn.quarantineRequest(s);o??(o=v?v.then(()=>!0):dT(void 0,s).then(()=>!0,k=>(qt.warn("Failed to cancel restore workspace creation",{requestId:s,error:k}),!1)))};(l=n==null?void 0:n.signal)==null||l.addEventListener("abort",c,{once:!0});try{if((d=n==null?void 0:n.signal)!=null&&d.aborted)throw na(n.signal);const v=await kt.createWorkspace({path:e,name:t,requestId:s},{signal:n==null?void 0:n.signal});a=!0;const k=v.reused===!0;if(s&&so.bindResponse(s,v.id),(u=n==null?void 0:n.signal)!=null&&u.aborted)throw v.requestId&&await Kd(v),na(n.signal);if(n!=null&&n.signal&&v.requestId){const I=s?so.resolve(s,v).workspace:v;mn.track({...I,requestId:I.requestId??v.requestId,...k?{reused:!0}:{}})}else n!=null&&n.signal||mn.releaseTombstoneForUserCreate(v.id);if(r&&await r.wait,(f=n==null?void 0:n.signal)!=null&&f.aborted)throw v.requestId&&await Kd(v),na(n.signal);const C=s?so.resolve(s,v):{workspace:v},_={...C.workspace,requestId:C.workspace.requestId??v.requestId,...k?{reused:!0}:{}};s&&mn.track(_);const T=C.terminal??(_.status==="error"||_.status==="stopped"?{status:_.status,message:_.error}:void 0);if(T)throw i=!0,await PS(_,T),new Error(T.message||`Restore-created workspace ${v.id} ${T.status}`);const P=mn.shouldIgnoreEvent(v.id)||((g=n==null?void 0:n.shouldCreateCommit)==null?void 0:g.call(n))===!1;if(P||(Er.markMutation(v.id),(m=n==null?void 0:n.onBeforeCreateCommit)==null||m.call(n,v.id),ra(_,k?void 0:t),(w=n==null?void 0:n.onCreateCommit)==null||w.call(n,v.id)),P)throw v.requestId&&await Kd(v),new Error(`Restore-created workspace ${v.id} was closed before startup completed`);return{instanceId:v.id,reused:k,requestId:v.requestId}}catch(v){throw!i&&(r!=null&&r.terminal)&&r.workspace&&(i=!0,await PS(r.workspace,r.terminal)),(S=n==null?void 0:n.signal)!=null&&S.aborted||qt.error("Failed to create workspace",v),v}finally{if((b=n==null?void 0:n.signal)==null||b.removeEventListener("abort",c),s){so.end(s);const v=o;a||!v?mn.finishRequest(s):v.then(k=>{k&&mn.finishRequest(s)})}}}function Ao(e){const t=e.replace(/[\\/]+$/,"");return/^(?:[A-Za-z]:[\\/]|[\\/]{2})/.test(t)?t.replace(/\\/g,"/").toLowerCase():t}function h9(e){if(!e)return null;const t=Ao(e),n=Array.from(Fe().values()).filter(r=>r.status==="stopped"?!1:Ao(r.folder)===t);if(n.length===0)return null;const s=Ds();return n.find(r=>r.id===s)??n.find(r=>r.status==="ready")??n[0]??null}function m9(e,t){const n=t.trim();if(!e||!n)return;const s=Ao(e);for(const r of Fe().values())r.status!=="stopped"&&Ao(r.folder)===s&&fl(r.id,{projectName:n})}const vh=new Map;function p9(e){if(!Fe().get(e))return Promise.resolve();const n=vh.get(e);if(n)return n;const s=kt.deleteWorkspace(e).catch(r=>{qt.error("Failed to stop workspace",r);try{Hn({message:$e("app.stopInstance.toast.error"),variant:"error"})}finally{throw r}}).finally(()=>{vh.delete(e)});return vh.set(e,s),s}function y9(){const e=Ds();return e&&Fe().get(e)||null}function uT(e,t){iT(e)&&hg(n=>{const s=new Map(n),r=s.get(e)??[],o=r.length>=V8?[...r.slice(1),t]:[...r,t];return s.set(e,o),s})}function fT(e){hg(t=>{if(!t.has(e))return t;const n=new Map(t);return n.set(e,[]),n})}function Fo(e){const t=zE().get(e);return t||[]}function v9(e){return Fo(e).length}function w9(e,t){const s=Fo(e).find(r=>r.id===t);return s?Wn.ensureEnqueuedAt(s):Wn.enqueuedAtFor(t)}function b9(e){const t=Fo(e),n=Zr(e),s=[];t[0]&&s.push({kind:"permission",id:t[0].id,enqueuedAt:Wn.ensureEnqueuedAt(t[0])}),n[0]&&s.push({kind:"form",id:n[0].id,enqueuedAt:ho.ensureEnqueuedAt(n[0])}),s.sort((o,a)=>o.enqueuedAt-a.enqueuedAt);const r=s[0];return r?{kind:r.kind,id:r.id}:null}function S9(e,t){K8(n=>{const s=new Map(n);return t?s.set(e,t):s.set(e,null),s}),WE(n=>{const s=new Map(n);return(t==null?void 0:t.kind)==="permission"?s.set(e,t.id):s.set(e,null),s})}function nc(e){S9(e,b9(e))}function vw(e,t,n){Us(Fa,e),HE(mg,e,t.id,n);let s=!1,r=!1,o,a=t;if(aw(l=>{const d=new Map(l),u=d.get(e)??[],f=u.findIndex(m=>m.id===t.id);if(f!==-1){o=u[f],a=Xx(o,t);const m=u.slice();return m[f]=a,d.set(e,m.sort((w,S)=>Wn.ensureEnqueuedAt(w)-Wn.ensureEnqueuedAt(S))),r=!0,d}Wn.ensureEnqueuedAt(a);const g=[...u,a].sort((m,w)=>Wn.ensureEnqueuedAt(m)-Wn.ensureEnqueuedAt(w));return d.set(e,g),s=!0,d}),!s&&!r)return;nc(e);const i=o?ua(o):void 0,c=ua(a);if(i&&i!==c){const l=Wn.decrement(e,i);ju(e,i,l>0)}return c&&((s||i!==c)&&Wn.increment(e,c),ju(e,c,!0)),a}function zl(e,t){Us(Fa,e),GE(mg,e,t);let n=null;aw(r=>{const o=new Map(r),a=o.get(e)??[],i=[];for(const c of a){if(c.id===t){n=c;continue}i.push(c)}return i.length>0?o.set(e,i):o.delete(e),o}),nc(e),Wn.remove(e,t);const s=n;if(s){const r=ua(s);if(r){const o=Wn.decrement(e,r);ju(e,r,o>0)}}}function k9(e,t){const n=RE(e,t);a8(e,t),kt.toggleYolo(e,t).then(s=>{cl(e,t,s.enabled)}).catch(s=>{qt.warn("Failed to toggle Yolo on server",{instanceId:e,sessionId:t,error:s}),cl(e,t,n)})}const oa=new Set;function gT(e,t){if(!e||!t||t==="info")return;const n=`${e}:${t}`;oa.has(n)||(oa.add(n),kt.getYoloState(e,t).then(s=>{cl(e,t,s.enabled)}).catch(s=>{oa.delete(n),qt.warn("Failed to sync Yolo state",{instanceId:e,sessionId:t,error:s})}))}xs.onOpen(()=>{oa.clear()});function hT(e){const t=`${e}:`;for(const n of Array.from(oa))n.startsWith(t)&&oa.delete(n)}function ww(e){Us(Fa,e),mg.delete(e),Wn.clear(e,Fo(e),t=>{ju(e,t,!1)}),aw(t=>{const n=new Map(t);return n.delete(e),n}),WE(t=>{const n=new Map(t);return n.delete(e),n}),nc(e)}async function x9(e,t,n,s,r){const o=Fe().get(e);if(!(o!=null&&o.client))throw new Error("Instance not ready");try{const a=Fo(e).find(i=>i.id===n);if(!a)throw new Error(`Permission request not found: ${n}`);await $t(e).permission.reply({sessionID:a.sessionID,requestID:n,decision:s,...r?{message:r}:{}}),fg(e,n),zl(e,n),_f(e,n)}catch(a){throw qt.error("Failed to send permission response",a),vg(e),a}}async function _9(e,t,n){const s=Zr(e).find(r=>r.id===t);if(!s)throw new Error(`Form request not found: ${t}`);Us(Mo,e);try{await $t(e).session.form.reply({sessionID:s.sessionID,formID:s.id,answer:n},UE(s)),nw(e,s.id),Wl(e,s.id)}catch(r){throw vg(e),r}}let Vd;function mT(e){Vd=e}function bw(e,t,n){Us(Mo,e),HE(pg,e,t.id,n??t.location);const s=Zr(e).find(r=>r.id===t.id);if(p8(e,t),ho.ensureEnqueuedAt(t),s!=null&&s.sessionID&&s.sessionID!==t.sessionID){const r=ho.decrement(e,s.sessionID);qu(e,s.sessionID,r>0)}return(!s||s.sessionID!==t.sessionID)&&ho.increment(e,t.sessionID),qu(e,t.sessionID,!0),nc(e),s||Vd==null||Vd(e,t),s?void 0:t}function Wl(e,t){Us(Mo,e),GE(pg,e,t);const n=Zr(e).find(s=>s.id===t);if(y8(e,t),ho.remove(e,t),n){const s=ho.decrement(e,n.sessionID);qu(e,n.sessionID,s>0)}nc(e)}function pT(e){Us(Mo,e),pg.delete(e),ho.clear(e,Zr(e),t=>{qu(e,t,!1)}),w8(e),nc(e)}async function $9(e,t){const n=Zr(e).find(s=>s.id===t);if(!n)throw new Error(`Form request not found: ${t}`);Us(Mo,e);try{await $t(e).session.form.cancel({sessionID:n.sessionID,formID:n.id},UE(n)),nw(e,n.id),Wl(e,n.id)}catch(s){throw vg(e),s}}const C9=new Set(["session.step.ended","session.step.failed"]);function yT(e,t){var l,d,u,f;const n=Fe().get(e);if(!(n!=null&&n.client))return;const s="sessionID"in t.data&&typeof t.data.sessionID=="string"?t.data.sessionID:t.type==="form.created"?t.data.form.sessionID:void 0,r=t.type==="session.compaction.delta";t.type==="server.connected"&&iw(e),s&&(t.type==="session.compaction.ended"||t.type==="session.compaction.failed")&&F8(e,s);const o=(g,m=!0,w=!1)=>{var S;if(s&&t.type.startsWith("session.")&&es().get(e)!==s&&((S=ng().get(e))!=null&&S.has(s))&&No(e,s),r&&!w){s&&N8(e,s,()=>o(g,m,!0));return}s&&(w||t.type.startsWith("session."))&&es().get(e)===s&&K_(Ht.getOrCreate(e).getMessageWindow(s))&&(aj(e,s,g,m,w||t.type!=="session.inbox.enqueued"),(w||C9.has(t.type))&&wa(e,s))},a=(g,m=!0)=>{if(o(g,m),s&&t.type==="session.inbox.cancelled"&&R0(e,t.data.inboxID,s),s&&t.type==="session.revert.committed")for(const w of Ht.getOrCreate(e).getSessionMessageIds(s))w>=t.data.to&&R0(e,w,s)},i=oj(e,n.folder,t,a,g=>{o(g,!1,!0),vg(e)});if(a(i),s&&(t.type==="permission.asked"||t.type==="permission.replied")){const g=i.session.permission.list(s)??[],m=(t.type==="permission.asked"?[t.data,...g.filter(S=>S.id!==t.data.id)]:g).filter(S=>!gg(e,S.id)),w=t.location??((d=(l=Ne().get(e))==null?void 0:l.get(s))==null?void 0:d.location);for(const S of m){const b=vw(e,S,w)??S;L_(e,b)}t.type==="permission.replied"&&(zl(e,t.data.requestID),_f(e,t.data.requestID))}if(s&&t.type.startsWith("form.")){const g=i.session.form.list(s,s==="global"?t.location:void 0)??[],m=t.type==="form.created"?[t.data.form,...g.filter(S=>S.id!==t.data.form.id)]:g,w=t.location??((f=(u=Ne().get(e))==null?void 0:u.get(s))==null?void 0:f.location);for(const S of m)AE(e,S.id)||bw(e,S,w);(t.type==="form.replied"||t.type==="form.cancelled")&&(nw(e,t.data.id),Wl(e,t.data.id))}cj(e,t);const c=J6(t.type);c.length&&pw(e,c)}vn.onInvalidation=yT;vn.onConnectionLost=(e,t)=>{const n=Fe().get(e);n&&dw({id:e,folder:n.folder,reason:t})};vn.onInstanceDisposed=(e,t)=>{var r;const n=(r=t==null?void 0:t.properties)==null?void 0:r.directory;if(!n){yh(e,{reason:"disposed"});return}const s=[];for(const o of Fe().values())o.folder===n&&s.push(o.id);if(s.length===0){yh(e,{reason:"disposed"});return}for(const o of s)yh(o,{reason:"disposed"})};async function E9(){lw()&&dw(null)}const T9=Object.freeze(Object.defineProperty({__proto__:null,acknowledgeDisconnectedInstance:E9,activeInstanceId:Ds,activeInterruption:U8,activePermissionId:B8,addInstance:aT,addLog:uT,addPendingForm:bw,addPermissionToQueue:vw,cancelRestoreCreationRequest:dT,claimRestoreCreatedInstanceForUser:f9,clearLogs:fT,clearPermissionQueue:ww,clearReloadableInstanceState:nT,createInstance:g9,disconnectedInstance:lw,ensureYoloStateSynced:gT,getActiveInstance:y9,getExistingInstanceForFolder:h9,getInstanceLogs:d9,getPermissionEnqueuedAtForInstance:w9,getPermissionQueue:Fo,getPermissionQueueLength:v9,handleInstanceInvalidation:yT,hasRepliedPermission:gg,instanceLogs:jE,instances:Fe,invalidatePendingRequestSync:dl,isInstanceLogStreaming:iT,markPermissionReplied:fg,permissionQueues:zE,reconcilePendingRequestLiveness:n9,reconcilePendingSessionIndicators:mr,refreshVolatileInstanceState:pw,releaseRestoreCreatedInstance:lT,removeInstance:wg,removePendingForm:Wl,removePermissionFromQueue:zl,sendFormCancel:$9,sendFormReply:_9,sendPermissionResponse:x9,setActiveInstanceId:VE,setInstanceLogStreaming:u9,setPendingFormAddedHandler:mT,stopInstance:p9,syncLoadedSessionInboxes:QE,syncPendingRequests:ql,togglePermissionAutoAcceptForSession:k9,updateInstance:fl,updateProjectNameForFolder:m9,waitForInitialWorkspaceLoad:o9,waitForInstanceInitialSessionHydration:Y8,waitForInstanceReady:yg,waitForInstanceWorkspaceMetadataHydration:J8},Symbol.toStringTag,{value:"Module"}));async function M9(e,t="ui"){if(typeof window>"u")return!1;if($p())try{const{openUrl:n}=await ls(async()=>{const{openUrl:s}=await import("./index-DXsN55dj.js");return{openUrl:s}},__vite__mapDeps([9,6,2,3,4,5,1,7]));return await n(e),!0}catch(n){console.warn(`[${t}] unable to open via system opener`,n)}try{return window.open(e,"_blank","noopener,noreferrer")!==null}catch(n){return console.warn(`[${t}] unable to open external url`,n),!1}}function vT(e,t){return(e.type==="external"||!e.hidden)&&wT(e,t)}function wT(e,t){var n;return e.type==="external"||!((n=e.when)!=null&&n.length)?!0:e.when.every(s=>{const r=t[s.key];if(r===void 0)return!1;const o=Array.isArray(r)?r.includes(String(s.value)):r===s.value;return s.op==="eq"?o:!o})}function A9(e,t){return Object.fromEntries(e.flatMap(n=>{if(n.type==="external"||!wT(n,t))return[];const s=t[n.key]??(n.hidden?n.default:void 0);return s===void 0?[]:[[n.key,s]]}))}function bp(e){try{const t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}const wh={type:"key",label:""};function D9(e,t){if(!t)return!0;if(t==="uri")try{return new URL(e),!0}catch{return!1}return t==="email"?/^[^\s@]+@[^\s@]+$/.test(e):t==="date"?/^\d{4}-\d{2}-\d{2}$/.test(e)&&!Number.isNaN(Date.parse(`${e}T00:00:00Z`)):/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(e)&&!Number.isNaN(Date.parse(e))}function _d(e,t){var o,a;const n=e,s=n==null?void 0:n.error,r=((o=n==null?void 0:n.data)==null?void 0:o.message)??((a=s==null?void 0:s.data)==null?void 0:a.message)??(n==null?void 0:n.message)??(s==null?void 0:s.message);return typeof r=="string"&&r.trim().length>0?r:t}function IS(e){const t={};for(const n of e??[])n.type!=="external"&&n.default!==void 0&&(t[n.key]=n.default);return t}function RS(e,t){if(e)return A9(e,t)}function P9(e,t){if(e.type==="external")return!0;const n=t[e.key];if(n===void 0)return!e.required;if(e.type==="string"){if(typeof n!="string"||e.required&&n.trim().length===0||e.minLength!==void 0&&n.length<e.minLength||e.maxLength!==void 0&&n.length>e.maxLength||!D9(n,e.format)||e.options&&!e.custom&&!e.options.some(s=>s.value===n))return!1;if(e.pattern)try{if(!new RegExp(`^(?:${e.pattern})$`).test(n))return!1}catch{return!1}return!0}return e.type==="number"||e.type==="integer"?!(typeof n!="number"||!Number.isFinite(n)||e.type==="integer"&&!Number.isInteger(n)||typeof e.minimum=="number"&&n<e.minimum||typeof e.maximum=="number"&&n>e.maximum):e.type==="multiselect"?!(!Array.isArray(n)||n.some(s=>typeof s!="string")||e.required&&n.length===0||e.minItems!==void 0&&n.length<e.minItems||e.maxItems!==void 0&&n.length>e.maxItems||!e.custom&&n.some(s=>!e.options.some(r=>r.value===s))):typeof n=="boolean"}function I9(e){const t=e;return(t==null?void 0:t.name)==="AbortError"||(t==null?void 0:t.message)==="This operation was aborted"}var R9=O("<div class=providers-form-stack>"),O9=O("<label class=settings-form-label>"),OS=O("<span class=settings-toggle-caption>"),L9=O("<input class=providers-input>"),N9=O("<datalist>"),F9=O('<div class="flex-1 min-w-0">'),B9=O("<input type=number class=providers-input>"),LS=O("<label class=settings-checkbox-toggle><input type=checkbox><span>"),U9=O("<input type=text class=providers-input>"),K9=O("<div class=providers-multiselect>"),V9=O("<div class=providers-field>"),j9=O('<div class=providers-field><a target=_blank rel="noopener noreferrer"class="selector-button selector-button-secondary providers-oauth-link">'),q9=O("<option>"),z9=O("<span class=providers-select-hint>"),W9=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const H9=e=>{const{t}=Dt(),n=Te(()=>(e.fields??[]).filter(d=>vT(d,e.answer))),s=d=>d.title||d.key,r=d=>e.answer[d.key],o=d=>Array.isArray(r(d))?r(d):[],a=d=>d.type!=="string"?"text":d.format==="uri"?"url":d.format==="date-time"?"datetime-local":d.format??"text",i=d=>typeof d=="number"&&Number.isFinite(d)?d:void 0,c=(d,u,f)=>{const g=new Set(o(d));f?g.add(u):g.delete(u),e.onAnswer(d.key,[...g])},l=(d,u)=>{const f=new Set(d.options.map(w=>w.value)),g=o(d).filter(w=>f.has(w)),m=u.split(",").map(w=>w.trim()).filter(Boolean);e.onAnswer(d.key,[...g,...m])};return(()=>{var d=R9();return p(d,y(zt,{get each(){return n()},children:u=>y(ee,{get when(){return u.type!=="external"},get fallback(){return y(ee,{get when(){return Ee(()=>u.type==="external")()&&bp(u.url)},get children(){var f=j9(),g=f.firstChild;return p(g,y(Yi,{class:"w-4 h-4"}),null),p(g,()=>s(u),null),p(f,y(ee,{get when(){return u.description},get children(){var m=OS();return p(m,()=>u.description),m}}),null),de(()=>me(g,"href",u.type==="external"?u.url:void 0)),f}})},get children(){var f=V9();return p(f,y(ee,{get when(){return u.type!=="boolean"},get children(){var g=O9();return p(g,()=>s(u)),de(()=>me(g,"for",`provider-field-${u.key}`)),g}}),null),p(f,y(ee,{get when(){return u.description},get children(){var g=OS();return p(g,()=>u.description),g}}),null),p(f,y(ee,{get when(){return Ee(()=>u.type==="string")()&&(!u.options||u.custom)},get children(){return[(()=>{var g=L9();return g.$$input=m=>e.onAnswer(u.key,m.currentTarget.value),de(m=>{var w=`provider-field-${u.key}`,S=a(u),b=u.type==="string"?u.placeholder:void 0,v=u.type==="string"?u.required:void 0,k=u.type==="string"?u.minLength:void 0,C=u.type==="string"?u.maxLength:void 0,_=u.type==="string"?u.pattern:void 0,T=u.type==="string"&&u.options?`provider-options-${u.key}`:void 0,P=e.disabled;return w!==m.e&&me(g,"id",m.e=w),S!==m.t&&me(g,"type",m.t=S),b!==m.a&&me(g,"placeholder",m.a=b),v!==m.o&&(g.required=m.o=v),k!==m.i&&me(g,"minlength",m.i=k),C!==m.n&&me(g,"maxlength",m.n=C),_!==m.s&&me(g,"pattern",m.s=_),T!==m.h&&me(g,"list",m.h=T),P!==m.r&&(g.disabled=m.r=P),m},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),de(()=>g.value=typeof r(u)=="string"?r(u):""),g})(),y(ee,{get when(){return Ee(()=>u.type==="string")()&&u.options},get children(){var g=N9();return p(g,y(zt,{get each(){return Ee(()=>u.type==="string")()?u.options:[]},children:m=>(()=>{var w=q9();return p(w,()=>m.label),de(()=>w.value=m.value),w})()})),de(()=>me(g,"id",`provider-options-${u.key}`)),g}})]}}),null),p(f,y(ee,{get when(){return Ee(()=>!!(u.type==="string"&&u.options))()&&!u.custom},get children(){return y(De,{get value(){var g;return Ee(()=>u.type==="string")()?(g=u.options)==null?void 0:g.find(m=>m.value===r(u)):void 0},onChange:g=>e.onAnswer(u.key,g==null?void 0:g.value),get options(){return Ee(()=>u.type==="string")()?u.options??[]:[]},optionValue:"value",optionTextValue:"label",get disabled(){return e.disabled},itemComponent:g=>y(De.Item,{get item(){return g.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return[Ee(()=>g.item.rawValue.label),y(ee,{get when(){return g.item.rawValue.description},get children(){var m=z9();return p(m,()=>g.item.rawValue.description),m}})]}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger providers-prompt-trigger",get"aria-label"(){return s(u)},get children(){return[(()=>{var g=F9();return p(g,y(De.Value,{children:m=>(()=>{var w=W9();return p(w,()=>{var S;return((S=m.selectedOption())==null?void 0:S.label)??t("settings.providers.prompt.selectPlaceholder")}),w})()})),g})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})}}),null),p(f,y(ee,{get when(){return u.type==="number"||u.type==="integer"},get children(){var g=B9();return g.$$input=m=>e.onAnswer(u.key,m.currentTarget.value===""?void 0:m.currentTarget.valueAsNumber),de(m=>{var w=`provider-field-${u.key}`,S=u.type==="number"||u.type==="integer"?i(u.minimum):void 0,b=u.type==="number"||u.type==="integer"?i(u.maximum):void 0,v=u.type==="integer"?1:"any",k=u.type==="number"||u.type==="integer"?u.required:void 0,C=e.disabled;return w!==m.e&&me(g,"id",m.e=w),S!==m.t&&me(g,"min",m.t=S),b!==m.a&&me(g,"max",m.a=b),v!==m.o&&me(g,"step",m.o=v),k!==m.i&&(g.required=m.i=k),C!==m.n&&(g.disabled=m.n=C),m},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),de(()=>g.value=typeof r(u)=="number"?r(u):""),g}}),null),p(f,y(ee,{get when(){return u.type==="boolean"},get children(){var g=LS(),m=g.firstChild,w=m.nextSibling;return m.addEventListener("change",S=>e.onAnswer(u.key,S.currentTarget.checked)),p(w,()=>s(u)),de(()=>m.disabled=e.disabled),de(()=>m.checked=r(u)===!0),g}}),null),p(f,y(ee,{get when(){return u.type==="multiselect"},get children(){var g=K9();return p(g,y(zt,{get each(){return Ee(()=>u.type==="multiselect")()?u.options:[]},children:m=>(()=>{var w=LS(),S=w.firstChild,b=S.nextSibling;return S.addEventListener("change",v=>u.type==="multiselect"&&c(u,m.value,v.currentTarget.checked)),p(b,()=>m.label),de(()=>S.disabled=e.disabled),de(()=>S.checked=o(u).includes(m.value)),w})()}),null),p(g,y(ee,{get when(){return Ee(()=>u.type==="multiselect")()&&u.custom},get children(){var m=U9();return m.$$input=w=>u.type==="multiselect"&&l(u,w.currentTarget.value),de(w=>{var S=t("settings.providers.prompt.customValuesPlaceholder"),b=e.disabled;return S!==w.e&&me(m,"placeholder",w.e=S),b!==w.t&&(m.disabled=w.t=b),w},{e:void 0,t:void 0}),de(()=>m.value=u.type==="multiselect"?o(u).filter(w=>!u.options.some(S=>S.value===w)).join(", "):""),m}}),null),g}}),null),f}})})),d})()};Xt(["input"]);function G9(e,t,n){const s=new Set(t.filter(r=>(r.integrationID??r.id)===e).map(r=>r.id));return s.size===0&&s.add(e),n.filter(r=>s.has(r.providerID)).map(r=>({id:r.id,name:r.name||r.id,providerId:r.providerID}))}function Z9(e,t,n){const s=new Map;for(const i of t)s.set(i.providerID,(s.get(i.providerID)??0)+1);const r=new Set,o=n.map(i=>{const c=e.filter(d=>(d.integrationID??d.id)===i.id);for(const d of c)r.add(d.id);const l=i.connections.filter(d=>d.type==="credential").map(d=>d.id);return{id:i.id,name:i.name,modelCount:c.reduce((d,u)=>d+(s.get(u.id)??0),0),source:l.length>0?"api":i.connections.some(d=>d.type==="env")?"env":c.length>0?"config":"unknown",credentialIds:l,canConnect:i.methods.some(d=>d.type!=="env")}}),a=new Set(o.map(i=>i.id));for(const i of e)r.has(i.id)||a.has(i.id)||(o.push({id:i.id,name:i.name||i.id,modelCount:s.get(i.id)??0,source:"custom",credentialIds:[],canConnect:!1}),a.add(i.id));for(const[i,c]of s)r.has(i)||a.has(i)||o.push({id:i,name:i,modelCount:c,source:"unknown",credentialIds:[],canConnect:!1});return o}var Y9=O("<p class=settings-error-message role=alert>"),J9=O("<div class=provider-model-visibility-list role=list>"),Q9=O('<section class=provider-model-visibility aria-labelledby=provider-model-visibility-heading><header class=provider-model-visibility-header><button type=button class="selector-button selector-button-secondary"></button><div><h4 id=provider-model-visibility-heading class=settings-card-title></h4><p class=settings-card-subtitle></p></div></header><div class=provider-model-visibility-toolbar><label class=sr-only for=provider-model-visibility-search></label><input id=provider-model-visibility-search type=search class=providers-input><span class=provider-model-visibility-count role=status></span><button type=button class="selector-button selector-button-secondary"></button><button type=button class="selector-button selector-button-secondary">'),X9=O("<p class=settings-card-message role=status>"),ez=O("<label class=provider-model-visibility-item role=listitem><input type=checkbox><span><strong></strong><small dir=ltr>");const tz=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"})||e.id.localeCompare(t.id,void 0,{sensitivity:"base"}),nz=e=>{const{t}=Dt(),{getProviderModelVisibilityPreference:n,providerModelVisibilitySaveFailed:s,setProviderModelVisibility:r}=Un(),[o,a]=R("");let i;const c=Te(()=>[...e.models].sort(tz)),l=Te(()=>new Set(c().filter(m=>n(m.providerId).hiddenModelIds.includes(m.id)).map(m=>`${m.providerId}\0${m.id}`))),d=Te(()=>c().filter(m=>!l().has(`${m.providerId}\0${m.id}`)).length),u=Te(()=>{const m=o().trim().toLocaleLowerCase();return m?c().filter(w=>w.name.toLocaleLowerCase().includes(m)||w.id.toLocaleLowerCase().includes(m)):c()});Ze(yi(()=>e.providerId,()=>a(""))),Ys(()=>queueMicrotask(()=>i==null?void 0:i.focus()));const f=(m,w)=>{const S=n(m.providerId).hiddenModelIds;r(m.providerId,{hiddenModelIds:w?S.filter(b=>b!==m.id):[...S,m.id]}).catch(()=>{})},g=m=>{const w=new Map;for(const S of c())w.set(S.providerId,[...w.get(S.providerId)??[],S.id]);for(const[S,b]of w){const v=n(S).hiddenModelIds,k=m?v.filter(C=>!b.includes(C)):Array.from(new Set([...v,...b]));r(S,{hiddenModelIds:k}).catch(()=>{})}};return(()=>{var m=Q9(),w=m.firstChild,S=w.firstChild,b=S.nextSibling,v=b.firstChild,k=v.nextSibling,C=w.nextSibling,_=C.firstChild,T=_.nextSibling,P=T.nextSibling,I=P.nextSibling,j=I.nextSibling;lk(S,"click",e.onBack,!0),p(S,y(Yk,{class:"w-4 h-4"}),null),p(S,()=>t("settings.providers.modelVisibility.back"),null),p(v,()=>t("settings.providers.modelVisibility.title",{provider:e.providerName})),p(k,()=>t("settings.providers.modelVisibility.subtitle")),p(_,()=>t("settings.providers.modelVisibility.search.label")),T.$$input=W=>a(W.currentTarget.value);var ne=i;return typeof ne=="function"?dr(ne,T):i=T,p(P,()=>t("settings.providers.modelVisibility.count.visible",{visible:d(),total:c().length})),I.$$click=()=>g(!0),p(I,()=>t("settings.providers.modelVisibility.actions.showAll")),j.$$click=()=>g(!1),p(j,()=>t("settings.providers.modelVisibility.actions.hideAll")),p(m,y(ee,{get when(){return c().some(W=>s(W.providerId))},get children(){var W=Y9();return p(W,()=>t("settings.providers.modelVisibility.save.failed")),W}}),null),p(m,y(ee,{get when(){return u().length>0},get fallback(){return(()=>{var W=X9();return p(W,()=>t("settings.providers.modelVisibility.list.empty")),W})()},get children(){var W=J9();return p(W,y(zt,{get each(){return u()},children:q=>(()=>{var U=ez(),G=U.firstChild,le=G.nextSibling,K=le.firstChild,M=K.nextSibling;return G.addEventListener("change",N=>f(q,N.currentTarget.checked)),p(K,()=>q.name||q.id),p(M,()=>q.id),de(()=>G.checked=!l().has(`${q.providerId}\0${q.id}`)),U})()})),de(()=>me(W,"aria-label",t("settings.providers.modelVisibility.list.label",{provider:e.providerName}))),W}}),null),de(()=>me(T,"placeholder",t("settings.providers.modelVisibility.search.placeholder"))),de(()=>T.value=o()),m})()};Xt(["click","input"]);var sz=O('<div class=providers-manager-header><div class=settings-card-heading-with-icon><div><p class=settings-card-subtitle></p></div></div><button type=button class="selector-button selector-button-secondary settings-screen-close">'),bh=O("<div class=settings-card-message role=status>"),NS=O('<div class="flex-1 min-w-0">'),rz=O('<div class=providers-connect-bar><button type=button class="selector-button selector-button-primary"></button><button type=button class=settings-pill-button>'),FS=O("<div class=settings-error-message role=alert>"),oz=O('<div class="settings-toggle-row settings-toggle-row-compact providers-method-row"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>'),iz=O("<div class=providers-form-stack><label class=providers-field><span class=settings-form-label></span><div class=providers-input-wrap><input type=password class=providers-input autocomplete=off>"),az=O("<div class=providers-form-stack><div class=settings-card-message role=status></div><div class=providers-command-preview dir=ltr>"),cz=O("<div class=providers-form-stack><div class=providers-oauth-instructions><span></span></div><label class=providers-field><span class=settings-form-label></span><input type=text class=providers-input autocomplete=one-time-code>"),lz=O('<div class=providers-waiting-card role=status><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><button type=button class="selector-button selector-button-secondary providers-wait-cancel">'),dz=O('<div class=providers-oauth-actions><a target=_blank rel="noopener noreferrer"class="selector-button selector-button-secondary providers-oauth-link"></a><button type=button class="selector-button selector-button-secondary"></button><button type=button class="selector-button selector-button-secondary">'),uz=O("<div class=settings-card-message role=alert>"),fz=O("<div class=providers-success-card role=status><span>"),BS=O('<button type=button class="selector-button selector-button-primary">'),gz=O('<section class=providers-connect-panel><div class=providers-panel-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><button type=button class="selector-button selector-button-secondary settings-screen-close"></button></div><div class=providers-actions-row>'),hz=O("<section class=providers-list-section><h3 class=settings-card-title>"),mz=O("<div class=providers-manager-body>"),pz=O("<div class=selector-option-content><div class=selector-option-description><span dir=ltr></span><span> • </span><span></span><span> • </span><span>"),yz=O("<span class=selector-trigger-secondary dir=ltr> • "),vz=O('<div class="selector-trigger-label selector-trigger-label--stacked flex-1 min-w-0"><span class="selector-trigger-primary selector-trigger-primary--align-left">'),wz=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">'),bz=O("<div class=providers-loading-row role=status><span>"),Sz=O("<div class=providers-grid>"),kz=O("<bdi dir=ltr>"),xz=O("<span aria-hidden=true> • "),_z=O('<button type=button class="selector-button selector-button-secondary providers-disconnect-button">'),$z=O('<article class="providers-card settings-toggle-row settings-toggle-row-compact"><div class=providers-card-copy><h4 class=providers-card-title></h4><p class=providers-card-meta></p></div><div class=provider-model-card-actions><button type=button class="selector-button selector-button-secondary">'),Cz=O('<div class="providers-manager-modal providers-manager-embedded">');const Ez=e=>{const{t}=Dt(),[n,s]=R({}),[r,o]=R([]),[a,i]=R(null),[c,l]=R(null),[d,u]=R(null),f=new Map;let g=null;const[m,w]=R(0),[S,b]=R(""),[v,k]=R({}),[C,_]=R(null),[T,P]=R(null),[I,j]=R(null),[ne,W]=R(""),[q,U]=R("idle"),[G,le]=R(!1),[K,M]=R(null),[N,oe]=R(null),[ge,Ie]=R(!1),[ke,we]=R(!1);let Ae=null,Ge=null,H=0,h=0,$=null,D=null,E=null,Z=null,B;const se=Te(()=>Fe().get(e.instanceId)??null),pe=Te(()=>{if(e.instanceId&&e.location)return $t(e.instanceId);const J=se();return(J==null?void 0:J.status)==="ready"?J.client??null:null}),Se=()=>e.location?{...e.location}:{...Nn(e.instanceId)},Q=J=>Io(J),be=J=>{const ie=Se();return Bs(ie)===Bs(J)},Ve=Te(()=>{const J=new Map;for(const ie of r())J.set(ie.id,ie.name||ie.id);return J}),He=Te(()=>r().sort((J,ie)=>J.id.localeCompare(ie.id,void 0,{sensitivity:"base"})).map(J=>({id:J.id,name:Ve().get(J.id)??J.id,modelCount:J.modelCount,connectionSummary:zn(J.id),canConnect:J.canConnect}))),re=Te(()=>r().filter(J=>J.source!=="unknown")),F=Te(()=>re().find(J=>J.id===d())??null),V=J=>J.source==="env"?"not-disconnectable":J.credentialIds.length>0?"credential-remove":"unknown",Me=J=>{const ie=V(J);return J.source==="config"?t("settings.providers.source.config"):ie==="not-disconnectable"?t("settings.providers.source.env"):J.source==="api"?t("settings.providers.source.api"):J.source==="custom"?t("settings.providers.source.custom"):t("settings.providers.source.unknown")},xe=Te(()=>He().find(J=>J.id===a())??He()[0]??null),Re=Te(()=>{const J=c();return J?Ve().get(J)??J:""}),Be=Te(()=>{const J=c();if(!J)return[wh];const ie=n()[J];return ie&&ie.length>0?ie:[wh]}),et=Te(()=>Be().map((J,ie)=>({value:String(ie),label:J.label||(J.type==="oauth"?t("settings.providers.method.oauth"):J.type==="command"?t("settings.providers.method.command"):t("settings.providers.method.api")),method:J,index:ie}))),Ue=Te(()=>et().find(J=>J.index===m())??et()[0]),We=Te(()=>{var J;return((J=Ue())==null?void 0:J.method)??wh}),st=Te(()=>{const J=We();return J.type==="command"?void 0:J.form}),at=Te(()=>{const J=We();return J.type==="command"?J:void 0}),ht=Te(()=>{if(!c()||q()==="authorizing"||q()==="waiting"||q()==="success")return!1;const J=We();return J.type==="key"&&S().trim().length===0?!1:(J.type==="command"?[]:J.form??[]).filter(ie=>vT(ie,v())).every(ie=>P9(ie,v()))});function ut(J){var ie;J||L(null),(ie=e.onOpenChange)==null||ie.call(e,J)}function Ct(){return!$p()&&typeof window<"u"}function Qe(){if(!Ct())return null;let J=null;try{return J=window.open("","_blank"),J&&J.document&&(J.opener=null,J.document.title=t("settings.providers.oauth.popup.loadingTitle"),J.document.body.innerHTML=`<div style="font-family: sans-serif; padding: 24px; color: #111;">${t("settings.providers.oauth.popup.loadingBody")}</div>`),J}catch{return J==null||J.close(),null}}async function tt(J,ie){if(!bp(J))return ie!=null&&ie.popup&&!ie.popup.closed&&ie.popup.close(),!1;if(ie!=null&&ie.sameTab&&typeof window<"u")return window.location.assign(J),!0;const Oe=ie==null?void 0:ie.popup;if(Oe&&!Oe.closed)try{return Oe.location.href=J,!0}catch{}return await M9(J,"provider-auth")}async function At(){var ie,Oe;const J=(ie=C())==null?void 0:ie.url;if(!(!J||typeof navigator>"u"||!((Oe=navigator.clipboard)!=null&&Oe.writeText)))try{await navigator.clipboard.writeText(J),we(!0),setTimeout(()=>we(!1),1500)}catch{we(!1)}}Ze(()=>{const J=++H;if(!e.embedded&&!e.open){D=null,E=null,Z=null,A();return}const ie=e.instanceId,Oe=pe();if(!Oe){D=null,E=null,Z=null,A();return}const Le=Se(),Ce=Bs(Le);D===ie&&E===Oe&&Z===Ce||(A(),D=ie,E=Oe,Z=Ce,xt(Oe,J,Le))}),Ze(()=>{q()==="code"&&queueMicrotask(()=>B==null?void 0:B.focus())}),dt(()=>{H+=1,x()});async function xt(J,ie,Oe){const Le=()=>ie===H&&pe()===J&&be(Oe);le(!0),M(null);try{const Ce={location:Q(Oe)},[ft,bt,mt]=await Promise.all([J.provider.list(Ce,Zt(Oe)),J.model.list(Ce,Zt(Oe)),J.integration.list(Ce,Zt(Oe))]);if(!Le())return;const qe=Z9(ft.data,bt.data,mt.data).map(it=>({...it,models:G9(it.id,ft.data,bt.data)})),yt=Object.fromEntries(mt.data.map(it=>[it.id,it.methods.filter(ye=>ye.type!=="env")]));o(qe),s(yt),i(it=>{var ye,Ye;return it??((ye=qe[0])==null?void 0:ye.id)??((Ye=mt.data[0])==null?void 0:Ye.id)??null})}catch(Ce){if(!Le())return;M(_d(Ce,t("settings.providers.errors.loadFailed")))}finally{Le()&&le(!1)}}function x(){h+=1,$=null,Ae==null||Ae.abort(),Ae=null,Ge&&!Ge.closed&&Ge.close(),Ge=null}function A(){L(null),s({}),o([]),i(null),u(null),M(null),le(!1)}function L(J=null){var Oe,Le;if(J&&!((Oe=n()[J])!=null&&Oe.length))return;x(),l(J),w(0),b("");const ie=J?(Le=n()[J])==null?void 0:Le[0]:void 0;k(IS((ie==null?void 0:ie.type)==="command"||ie==null?void 0:ie.form)),_(null),P(null),j(null),W(""),U(J?"prompts":"idle"),oe(null),Ie(!1),we(!1)}function X(J,ie){k(Oe=>{const Le={...Oe};return ie===void 0?delete Le[J]:Le[J]=ie,Le})}function Y(J,ie,Oe){return J===h&&e.instanceId===ie&&pe()===Oe}async function ue(J,ie,Oe,Le){Y(Oe,ie,J)&&(e.location||await Da(ie,Le,!0).catch(()=>{}),Y(Oe,ie,J)&&await xt(J,++H,Se()).catch(()=>{}))}async function ce(){const J=pe(),ie=e.instanceId;if(!J)return;const Oe=Se();le(!0),e.location||await Da(ie,Oe,!0).catch(()=>{}),!(pe()!==J||e.instanceId!==ie)&&await xt(J,++H,Oe)}function ve(){u(null),queueMicrotask(()=>{var J;g&&((J=f.get(g))==null||J.focus())})}async function je(J,ie,Oe,Le,Ce){await ie.integration.connect.key({integrationID:J,key:S().trim(),answer:RS(st(),v()),location:Q(Ce)},Zt(Ce)),Y(Le,Oe,ie)&&(await ue(ie,Oe,Le,Ce),Y(Le,Oe,ie)&&L(null))}async function Ke(J,ie,Oe,Le,Ce){const ft=We();if(ft.type!=="oauth")throw new Error(t("settings.providers.errors.noAuthorization"));const bt=await ie.integration.oauth.connect({integrationID:J,methodID:ft.id,answer:RS(st(),v()),location:Q(Ce)},Zt(Ce));if(!Y(Le,Oe,ie))return;const mt=bt.data;if(!mt)throw new Error(t("settings.providers.errors.noAuthorization"));const qe={attemptID:mt.attemptID,url:mt.url,instructions:mt.instructions,method:mt.mode};_(qe);const yt=await tt(mt.url,{popup:Ge});if(Y(Le,Oe,ie)){if(Ge=null,Ie(!yt),mt.mode==="code"){U("code");return}for(U("waiting"),Ae=new AbortController;;){const it=await ie.integration.oauth.status({integrationID:J,attemptID:mt.attemptID,location:Q(Ce)},{...Zt(Ce),signal:Ae.signal});if(it.data.status==="complete")break;if(it.data.status==="failed")throw new Error(it.data.message);if(it.data.status==="expired")throw new Error(t("settings.providers.errors.authorizationFailed"));await new Promise(ye=>setTimeout(ye,1e3))}Y(Le,Oe,ie)&&(Ae=null,await ue(ie,Oe,Le,Ce),Y(Le,Oe,ie)&&L(null))}}async function rt(J,ie,Oe,Le,Ce){const ft=We();if(ft.type!=="command")throw new Error(t("settings.providers.errors.noAuthorization"));const bt=await ie.integration.command.connect({integrationID:J,methodID:ft.id,location:Q(Ce)},Zt(Ce));if(!Y(Le,Oe,ie))return;const mt=bt.data.attemptID;for(P(mt),j(null),U("waiting"),Ae=new AbortController;;){const qe=await ie.integration.command.status({integrationID:J,attemptID:mt,location:Q(Ce)},{...Zt(Ce),signal:Ae.signal});if(qe.data.status==="complete")break;if(qe.data.status==="failed")throw new Error(qe.data.message);if(qe.data.status==="expired")throw new Error(t("settings.providers.errors.authorizationFailed"));j(qe.data.message??null),await new Promise(yt=>setTimeout(yt,1e3))}Y(Le,Oe,ie)&&(Ae=null,await ue(ie,Oe,Le,Ce),Y(Le,Oe,ie)&&L(null))}async function ot(){const J=c(),ie=pe();if(!J||!ie||!ht())return;const Oe=e.instanceId,Le=Se(),Ce=++h;$=Le,U("authorizing"),oe(null);try{if(We().type==="key"){await je(J,ie,Oe,Ce,Le);return}if(We().type==="command"){await rt(J,ie,Oe,Ce,Le);return}Ge=Qe(),Ie(Ct()&&Ge===null),await Ke(J,ie,Oe,Ce,Le)}catch(ft){if(!Y(Ce,Oe,ie))return;if(Ge&&!Ge.closed&&Ge.close(),Ge=null,I9(ft)){U("prompts");return}oe(_d(ft,t("settings.providers.errors.authorizationFailed"))),U("error")}}async function Pt(){var ft;const J=c(),ie=pe();if(!J||!ie||!ne().trim())return;const Oe=e.instanceId,Le=$;if(!Le)return;const Ce=++h;U("authorizing"),oe(null);try{const bt=(ft=C())==null?void 0:ft.attemptID;if(!bt)throw new Error(t("settings.providers.errors.noAuthorization"));if(await ie.integration.oauth.complete({integrationID:J,attemptID:bt,code:ne().trim(),location:Q(Le)},Zt(Le)),!Y(Ce,Oe,ie))return;await ue(ie,Oe,Ce,Le),Y(Ce,Oe,ie)&&L(null)}catch(bt){if(!Y(Ce,Oe,ie))return;oe(_d(bt,t("settings.providers.errors.authorizationFailed"))),U("code")}}async function In(J){const ie=pe(),Oe=r().find(bt=>bt.id===J);if(!ie||!Oe)return;const Le=e.instanceId,Ce=Se();x();const ft=++h;oe(null),U("authorizing");try{const bt=V(Oe);if(bt==="not-disconnectable"){oe(t("settings.providers.errors.envDisconnectUnavailable")),U("error");return}if(bt!=="credential-remove"||(await Promise.all(Oe.credentialIds.map(mt=>ie.credential.remove({credentialID:mt},Zt(Ce,{includeDirectory:!0})))),!Y(ft,Le,ie)))return;await ue(ie,Le,ft,Ce),Y(ft,Le,ie)&&L(null)}catch(bt){if(!Y(ft,Le,ie))return;oe(_d(bt,t("settings.providers.errors.removeFailed"))),U("idle")}}function wn(){var ft;const J=c(),ie=(ft=C())==null?void 0:ft.attemptID,Oe=T(),Le=pe();e.instanceId;const Ce=$;J&&ie&&Le&&Ce&&Le.integration.oauth.cancel({integrationID:J,attemptID:ie,location:Q(Ce)},Zt(Ce)).catch(()=>{}),J&&Oe&&Le&&Ce&&Le.integration.command.cancel({integrationID:J,attemptID:Oe,location:Q(Ce)},Zt(Ce)).catch(()=>{}),x(),U("prompts"),_(null),P(null),j(null),oe(null)}function zn(J){var Le;const ie=n()[J];if(!ie||ie.length===0){const Ce=((Le=r().find(ft=>ft.id===J))==null?void 0:Le.source)??"unknown";return t(`settings.providers.source.${Ce}`)}const Oe=new Set(ie.map(Ce=>Ce.type));return Oe.size>1?t("settings.providers.method.mixed"):Oe.has("oauth")?t("settings.providers.method.oauth"):Oe.has("command")?t("settings.providers.method.command"):t("settings.providers.method.api")}function Et(J){const ie=J.modelCount===1?t("settings.providers.models.one",{count:J.modelCount}):t("settings.providers.models.other",{count:J.modelCount});return[...new Set([zn(J.id),Me(J),ie].filter(Boolean))].join(" • ")}const tn=()=>[y(ee,{get when(){return!e.embedded},get children(){var J=sz(),ie=J.firstChild,Oe=ie.firstChild,Le=Oe.firstChild,Ce=ie.nextSibling;return p(ie,y(ex,{class:"settings-card-heading-icon"}),Oe),p(Oe,y(Ot.Title,{class:"providers-manager-title",get children(){return t("settings.providers.title")}}),Le),p(Le,()=>t("settings.providers.subtitle")),Ce.$$click=()=>ut(!1),p(Ce,y(ti,{class:"w-4 h-4"})),de(()=>me(Ce,"aria-label",t("settings.close"))),J}}),(()=>{var J=mz();return p(J,y(ee,{get when(){return!pe()},get children(){var ie=bh();return p(ie,()=>t("settings.providers.empty.noInstance")),ie}}),null),p(J,y(ee,{get when(){return pe()},get children(){return[(()=>{var ie=rz(),Oe=ie.firstChild,Le=Oe.nextSibling;return p(ie,y(De,{get value(){return xe()},onChange:Ce=>Ce&&i(Ce.id),get options(){return He()},optionValue:"id",optionTextValue:"name",itemComponent:Ce=>y(De.Item,{get item(){return Ce.item},class:"selector-option selector-option--multiline",get children(){var ft=pz(),bt=ft.firstChild,mt=bt.firstChild,qe=mt.nextSibling,yt=qe.nextSibling,it=yt.nextSibling,ye=it.nextSibling;return p(ft,y(De.ItemLabel,{class:"selector-option-label",get children(){return Ce.item.rawValue.name}}),bt),p(mt,()=>Ce.item.rawValue.id),p(yt,(()=>{var Ye=Ee(()=>Ce.item.rawValue.modelCount===1);return()=>Ye()?t("settings.providers.models.one",{count:Ce.item.rawValue.modelCount}):t("settings.providers.models.other",{count:Ce.item.rawValue.modelCount})})()),p(ye,()=>Ce.item.rawValue.connectionSummary),ft}}),get children(){return[y(De.Trigger,{class:"selector-trigger providers-connect-select",get"aria-label"(){return t("settings.providers.selectProvider")},get children(){return[(()=>{var Ce=NS();return p(Ce,y(De.Value,{children:ft=>(()=>{var bt=vz(),mt=bt.firstChild;return p(mt,()=>{var qe;return((qe=ft.selectedOption())==null?void 0:qe.name)??t("settings.providers.selectProvider")}),p(bt,y(ee,{get when(){return ft.selectedOption()},get children(){var qe=yz(),yt=qe.firstChild;return p(qe,()=>{var it;return(it=ft.selectedOption())==null?void 0:it.id},yt),p(qe,()=>{var it;return(it=ft.selectedOption())==null?void 0:it.connectionSummary},null),qe}}),null),bt})()})),Ce})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),Oe),Oe.$$click=()=>{var Ce;return L(((Ce=xe())==null?void 0:Ce.id)??null)},p(Oe,()=>t("settings.providers.actions.connect")),Le.$$click=()=>void ce(),p(Le,y(Gd,{get class(){return G()?"providers-spin-icon":"providers-button-icon"}}),null),p(Le,()=>t("settings.providers.refresh"),null),de(Ce=>{var mt;var ft=!((mt=xe())!=null&&mt.canConnect),bt=G();return ft!==Ce.e&&(Oe.disabled=Ce.e=ft),bt!==Ce.t&&(Le.disabled=Ce.t=bt),Ce},{e:void 0,t:void 0}),ie})(),y(ee,{get when(){return K()},get children(){var ie=FS();return p(ie,K),ie}}),y(ee,{get when(){return N()},get children(){var ie=FS();return p(ie,N),ie}}),y(ee,{get when(){return c()},get children(){var ie=gz(),Oe=ie.firstChild,Le=Oe.firstChild,Ce=Le.firstChild,ft=Ce.nextSibling,bt=Le.nextSibling,mt=Oe.nextSibling;return p(Ce,()=>t("settings.providers.auth.title",{provider:Re()})),p(ft,()=>t("settings.providers.auth.subtitle")),bt.$$click=()=>L(null),p(bt,y(ti,{class:"w-4 h-4"})),p(ie,y(ee,{get when(){return et().length>1},get children(){var qe=oz(),yt=qe.firstChild,it=yt.firstChild,ye=it.nextSibling;return p(it,()=>t("settings.providers.method.title")),p(ye,()=>t("settings.providers.method.subtitle")),p(qe,y(De,{get value(){return Ue()},onChange:Ye=>{Ye&&(w(Ye.index),k(IS(Ye.method.type==="command"?void 0:Ye.method.form)),b(""),_(null),W(""),U("prompts"),oe(null))},get options(){return et()},optionValue:"value",optionTextValue:"label",get disabled(){return Ee(()=>q()!=="prompts")()&&q()!=="error"},itemComponent:Ye=>y(De.Item,{get item(){return Ye.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return Ye.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger providers-method-trigger",get"aria-label"(){return t("settings.providers.method.title")},get children(){return[(()=>{var Ye=NS();return p(Ye,y(De.Value,{children:ct=>(()=>{var fn=wz();return p(fn,()=>{var Ai;return(Ai=ct.selectedOption())==null?void 0:Ai.label}),fn})()})),Ye})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),null),qe}}),mt),p(ie,y(ee,{get when(){return We().type==="key"},get children(){var qe=iz(),yt=qe.firstChild,it=yt.firstChild,ye=it.nextSibling,Ye=ye.firstChild;return p(it,()=>t("settings.providers.apiKey.label")),p(ye,y(yD,{class:"providers-input-icon"}),Ye),Ye.$$input=ct=>b(ct.currentTarget.value),de(()=>me(Ye,"placeholder",t("settings.providers.apiKey.placeholder"))),de(()=>Ye.value=S()),qe}}),mt),p(ie,y(ee,{get when(){return st()},get children(){return y(H9,{get fields(){return st()},get answer(){return v()},get disabled(){return Ee(()=>q()!=="prompts")()&&q()!=="error"},onAnswer:X})}}),mt),p(ie,y(ee,{get when(){return Ee(()=>We().type==="oauth"&&!st())()&&(q()==="prompts"||q()==="error"||q()==="authorizing")},get children(){var qe=bh();return p(qe,()=>t("settings.providers.oauth.noPrompts")),qe}}),mt),p(ie,y(ee,{get when(){return Ee(()=>We().type==="command")()&&(q()==="prompts"||q()==="error"||q()==="authorizing")},get children(){var qe=az(),yt=qe.firstChild,it=yt.nextSibling;return p(yt,()=>t("settings.providers.command.description")),p(it,()=>{var ye;return(ye=at())==null?void 0:ye.command.join(" ")}),qe}}),mt),p(ie,y(ee,{get when(){return q()==="code"},get children(){var qe=cz(),yt=qe.firstChild,it=yt.firstChild,ye=yt.nextSibling,Ye=ye.firstChild,ct=Ye.nextSibling;return p(yt,y(Yi,{class:"providers-instructions-icon"}),it),p(it,()=>{var fn;return((fn=C())==null?void 0:fn.instructions)||t("settings.providers.oauth.enterCode")}),p(Ye,()=>t("settings.providers.oauth.codeLabel")),ct.$$input=fn=>W(fn.currentTarget.value),dr(fn=>{B=fn},ct),de(()=>me(ct,"placeholder",t("settings.providers.oauth.codePlaceholder"))),de(()=>ct.value=ne()),qe}}),mt),p(ie,y(ee,{get when(){return q()==="waiting"},get children(){var qe=lz(),yt=qe.firstChild,it=yt.firstChild,ye=it.nextSibling,Ye=yt.nextSibling;return p(qe,y(Zn,{class:"providers-spin-icon"}),yt),p(it,(()=>{var ct=Ee(()=>We().type==="command");return()=>ct()?t("settings.providers.command.waitingTitle"):t("settings.providers.oauth.waitingTitle")})()),p(ye,(()=>{var ct=Ee(()=>We().type==="command");return()=>{var fn;return ct()?I()??t("settings.providers.command.waitingMessage"):(fn=C())==null?void 0:fn.instructions}})()),Ye.$$click=wn,p(Ye,()=>t("settings.providers.oauth.cancelWait")),qe}}),mt),p(ie,y(ee,{get when(){return Ee(()=>!!(C()&&bp(C().url)))()&&(q()==="code"||q()==="waiting")},get children(){var qe=dz(),yt=qe.firstChild,it=yt.nextSibling,ye=it.nextSibling;return p(yt,y(Yi,{class:"w-4 h-4"}),null),p(yt,()=>t("settings.providers.oauth.openPage"),null),it.$$click=()=>void tt(C().url,{sameTab:!0}),p(it,()=>t("settings.providers.oauth.openHere")),ye.$$click=()=>void At(),p(ye,(()=>{var Ye=Ee(()=>!!ke());return()=>Ye()?t("settings.providers.oauth.linkCopied"):t("settings.providers.oauth.copyLink")})()),de(()=>{var Ye;return me(yt,"href",(Ye=C())==null?void 0:Ye.url)}),qe}}),mt),p(ie,y(ee,{get when(){return Ee(()=>!!ge())()&&C()},get children(){var qe=uz();return p(qe,()=>t("settings.providers.oauth.popupBlocked")),qe}}),mt),p(ie,y(ee,{get when(){return q()==="success"},get children(){var qe=fz(),yt=qe.firstChild;return p(qe,y(Qk,{class:"providers-success-icon"}),yt),p(yt,()=>t("settings.providers.success")),qe}}),mt),p(mt,y(ee,{get when(){return q()==="code"},get fallback(){return(()=>{var qe=BS();return qe.$$click=()=>void ot(),p(qe,y(ee,{get when(){return q()==="authorizing"},get fallback(){return t("settings.providers.actions.continue")},get children(){return[y(Zn,{class:"providers-spin-icon"}),Ee(()=>t("settings.providers.actions.working"))]}})),de(()=>qe.disabled=!ht()),qe})()},get children(){var qe=BS();return qe.$$click=()=>void Pt(),p(qe,()=>t("settings.providers.oauth.submitCode")),de(()=>qe.disabled=!ne().trim()),qe}})),de(qe=>{var yt=t("settings.providers.actions.close"),it=t("settings.providers.actions.close");return yt!==qe.e&&me(bt,"aria-label",qe.e=yt),it!==qe.t&&me(bt,"title",qe.t=it),qe},{e:void 0,t:void 0}),ie}}),(()=>{var ie=hz(),Oe=ie.firstChild;return p(Oe,()=>t("settings.providers.configured.title")),p(ie,y(ee,{get when(){return F()},get fallback(){return[y(ee,{get when(){return G()},get children(){var Le=bz(),Ce=Le.firstChild;return p(Le,y(Zn,{class:"providers-spin-icon"}),Ce),p(Ce,()=>t("settings.providers.loading")),Le}}),y(ee,{get when(){return Ee(()=>!G())()&&re().length===0},get children(){var Le=bh();return p(Le,()=>t("settings.providers.empty.noConfiguredProviders")),Le}}),(()=>{var Le=Sz();return p(Le,y(zt,{get each(){return re()},children:Ce=>(()=>{var ft=$z(),bt=ft.firstChild,mt=bt.firstChild,qe=mt.nextSibling,yt=bt.nextSibling,it=yt.firstChild;return p(mt,()=>Ce.name||Ce.id),p(qe,y(ee,{get when(){return Ee(()=>!!Ce.name)()&&Ce.name!==Ce.id},get children(){return[(()=>{var ye=kz();return p(ye,()=>Ce.id),ye})(),xz()]}}),null),p(qe,()=>Et(Ce),null),it.$$click=()=>{g=Ce.id,u(Ce.id)},dr(ye=>f.set(Ce.id,ye),it),p(it,()=>t("settings.providers.actions.manageModels")),p(yt,y(ee,{get when(){return V(Ce)==="credential-remove"},get children(){var ye=_z();return ye.$$click=()=>void In(Ce.id),p(ye,()=>t("settings.providers.actions.disconnect")),de(Ye=>{var ct=q()!=="idle",fn=t("settings.providers.actions.disconnect");return ct!==Ye.e&&(ye.disabled=Ye.e=ct),fn!==Ye.t&&me(ye,"title",Ye.t=fn),Ye},{e:void 0,t:void 0}),ye}}),null),ft})()})),Le})()]},children:Le=>y(nz,{get providerId(){return Le().id},get providerName(){return Le().name||Le().id},get models(){return Le().models},onBack:ve})}),null),ie})()]}}),null),J})()];return e.embedded?(()=>{var J=Cz();return p(J,tn),J})():y(Ot,{get open(){return!!e.open},onOpenChange:ut,get children(){return y(Ot.Portal,{get children(){return[y(Ot.Overlay,{class:"modal-overlay"}),y(Ot.Content,{class:"modal-surface providers-manager-modal",get children(){return tn()}})]}})}})};Xt(["click","input"]);const Tz=e=>y(Ez,{get instanceId(){return e.instanceId??Ds()??""},get location(){return e.location},embedded:!0});var Mz=O('<section class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class="settings-scope-badge settings-scope-badge-server"></span></div><div class=settings-card-body>');const Az=()=>{const{t:e}=Dt();return Ys(()=>void Fs()),(()=>{var t=Mz(),n=t.firstChild,s=n.firstChild,r=s.firstChild,o=r.nextSibling,a=s.nextSibling,i=n.nextSibling;return p(r,()=>e("settings.opencode.update.title")),p(o,()=>e("settings.opencode.setup.description")),p(a,()=>e("settings.scope.server")),p(i,y(Zk,{})),t})()};var Dz=O('<div class="flex-1 min-w-0">'),Pz=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class="settings-scope-badge settings-scope-badge-server"></span></div><div class=settings-card-body><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>'),Iz=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const Rz=()=>{const{t:e}=Dt(),{serverSettings:t,updateLogLevel:n}=Un(),s=Te(()=>[{value:"DEBUG",label:e("settings.opencode.logLevel.option.debug")},{value:"INFO",label:e("settings.opencode.logLevel.option.info")},{value:"WARN",label:e("settings.opencode.logLevel.option.warn")},{value:"ERROR",label:e("settings.opencode.logLevel.option.error")}]),r=Te(()=>s().find(o=>o.value===t().logLevel)??s()[0]);return(()=>{var o=Pz(),a=o.firstChild,i=a.firstChild,c=i.firstChild,l=c.firstChild,d=l.nextSibling,u=c.nextSibling,f=i.nextSibling,g=f.firstChild,m=g.firstChild,w=m.firstChild,S=w.nextSibling;return p(o,y(nx,{}),a),p(o,y(Az,{}),a),p(l,()=>e("settings.opencode.logLevel.title")),p(d,()=>e("settings.opencode.logLevel.subtitle")),p(u,()=>e("settings.scope.server")),p(w,()=>e("settings.opencode.logLevel.selector.title")),p(S,()=>e("settings.opencode.logLevel.selector.subtitle")),p(g,y(De,{get value(){return r()},onChange:b=>b&&n(b.value),get options(){return s()},optionValue:"value",optionTextValue:"label",itemComponent:b=>y(De.Item,{get item(){return b.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return b.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger",get"aria-label"(){return e("settings.opencode.logLevel.title")},get children(){return[(()=>{var b=Dz();return p(b,y(De.Value,{children:v=>(()=>{var k=Iz();return p(k,()=>{var C;return(C=v.selectedOption())==null?void 0:C.label}),k})()})),b})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),null),o})()};var Oz=O("<div class=space-y-2>"),Lz=O('<div class="text-xs text-muted text-center py-2">'),Nz=O('<div class=space-y-3><div class="flex items-center gap-2 mb-3"><span class="text-sm font-medium text-secondary"></span><span class="text-xs text-muted"></span></div><div class="flex items-center gap-2 pt-2 border-t border-base"><div class="flex-1 flex items-center gap-2"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"><input class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"autocomplete=new-password></div><button></button><button class="p-1.5 icon-muted icon-accent-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors"></button></div><div class="text-xs text-muted mt-2">'),Fz=O('<div class="flex items-center gap-2"><div class="flex-1 flex items-center gap-2"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-secondary border border-base text-muted cursor-not-allowed"><input class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"></div><button></button><button class="p-1.5 icon-muted icon-danger-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors">');const Bz=e=>{const{t}=Dt(),{serverSettings:n,addEnvironmentVariable:s,removeEnvironmentVariable:r,updateEnvironmentVariables:o,isSecureEnvVar:a,toggleSecureEnvVar:i}=Un(),[c,l]=R(n().environmentVariables||{}),[d,u]=R(""),[f,g]=R(""),[m,w]=R(!0),S=()=>Object.entries(c());function b(){const T=d().trim(),P=f().trim();T&&(s(T,P,m()),l({...c(),[T]:P}),u(""),g(""),w(!0))}function v(T){r(T);const{[T]:P,...I}=c();l(I)}function k(T,P){const I={...c(),[T]:P};l(I),o(I)}function C(T){i(T)}function _(T){T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),b())}return(()=>{var T=Nz(),P=T.firstChild,I=P.firstChild,j=I.nextSibling,ne=P.nextSibling,W=ne.firstChild,q=W.firstChild,U=q.nextSibling,G=W.nextSibling,le=G.nextSibling,K=ne.nextSibling;return p(P,y(ei,{class:"w-4 h-4 icon-muted"}),I),p(I,()=>t("envEditor.title")),p(j,(()=>{var M=Ee(()=>S().length===1);return()=>M()?t("envEditor.count.one",{count:S().length}):t("envEditor.count.other",{count:S().length})})()),p(T,y(ee,{get when(){return S().length>0},get children(){var M=Oz();return p(M,y(zt,{get each(){return S()},children:([N,oe])=>(()=>{var ge=Fz(),Ie=ge.firstChild,ke=Ie.firstChild,we=ke.nextSibling,Ae=Ie.nextSibling,Ge=Ae.nextSibling;return p(Ie,y(ab,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),ke),ke.value=N,we.$$input=H=>k(N,H.currentTarget.value),we.value=oe,Ae.$$click=()=>C(N),p(Ae,(()=>{var H=Ee(()=>!!a(N));return()=>H()?y(Zd,{class:"w-3.5 h-3.5"}):y(lb,{class:"w-3.5 h-3.5"})})()),Ge.$$click=()=>v(N),p(Ge,y(af,{class:"w-3.5 h-3.5"})),de(H=>{var h=e.disabled,$=t("envEditor.fields.name.placeholder"),D=t("envEditor.fields.name.readOnlyTitle"),E=a(N)?"password":"text",Z=e.disabled,B=t("envEditor.fields.value.placeholder"),se=a(N)?"new-password":"off",pe=a(N)?!1:void 0,Se=a(N)?"off":void 0,Q=e.disabled,be=`p-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${a(N)?"icon-accent-hover text-accent":"icon-muted icon-accent-hover"}`,Ve=a(N)?t("envEditor.fields.secure.enabled"):t("envEditor.fields.secure.disabled"),He=e.disabled,re=t("envEditor.actions.remove.title");return h!==H.e&&(ke.disabled=H.e=h),$!==H.t&&me(ke,"placeholder",H.t=$),D!==H.a&&me(ke,"title",H.a=D),E!==H.o&&me(we,"type",H.o=E),Z!==H.i&&(we.disabled=H.i=Z),B!==H.n&&me(we,"placeholder",H.n=B),se!==H.s&&me(we,"autocomplete",H.s=se),pe!==H.h&&me(we,"spellcheck",H.h=pe),Se!==H.r&&me(we,"autocapitalize",H.r=Se),Q!==H.d&&(Ae.disabled=H.d=Q),be!==H.l&&ws(Ae,H.l=be),Ve!==H.u&&me(Ae,"title",H.u=Ve),He!==H.c&&(Ge.disabled=H.c=He),re!==H.w&&me(Ge,"title",H.w=re),H},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0}),ge})()})),M}}),ne),p(W,y(ab,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),q),q.addEventListener("keypress",_),q.$$input=M=>u(M.currentTarget.value),U.addEventListener("keypress",_),U.$$input=M=>g(M.currentTarget.value),G.$$click=()=>w(!m()),p(G,(()=>{var M=Ee(()=>!!m());return()=>M()?y(Zd,{class:"w-3.5 h-3.5"}):y(lb,{class:"w-3.5 h-3.5"})})()),le.$$click=b,p(le,y(of,{class:"w-3.5 h-3.5"})),p(T,y(ee,{get when(){return S().length===0},get children(){var M=Lz();return p(M,()=>t("envEditor.empty")),M}}),K),p(K,()=>t("envEditor.help")),de(M=>{var N=e.disabled,oe=t("envEditor.fields.name.placeholder"),ge=m()?"password":"text",Ie=e.disabled,ke=t("envEditor.fields.value.placeholder"),we=e.disabled,Ae=`p-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${m()?"icon-accent-hover text-accent":"icon-muted icon-accent-hover"}`,Ge=m()?t("envEditor.fields.secure.enabled"):t("envEditor.fields.secure.disabled"),H=e.disabled||!d().trim(),h=t("envEditor.actions.add.title");return N!==M.e&&(q.disabled=M.e=N),oe!==M.t&&me(q,"placeholder",M.t=oe),ge!==M.a&&me(U,"type",M.a=ge),Ie!==M.o&&(U.disabled=M.o=Ie),ke!==M.i&&me(U,"placeholder",M.i=ke),we!==M.n&&(G.disabled=M.n=we),Ae!==M.s&&ws(G,M.s=Ae),Ge!==M.h&&me(G,"title",M.h=Ge),H!==M.r&&(le.disabled=M.r=H),h!==M.d&&me(le,"title",M.d=h),M},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),de(()=>q.value=d()),de(()=>U.value=f()),T})()};Xt(["input","click"]);var Uz=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class="settings-scope-badge settings-scope-badge-server"></span></div></div><div class=settings-card><div class=settings-stack>');const Kz=()=>{const{t:e}=Dt(),t=Un(),n=Te(()=>[...ry(t).filter(s=>s.id==="behavior.autoCleanupBlankSessions"||s.id==="behavior.keepUnseenSubagentIdleStatus"||s.id==="behavior.focusExistingWindowOnSecondLaunch"&&JT()||s.id==="behavior.providerUsageCreditBalance"),{kind:"toggle",id:"behavior.holdLongAssistantReplies",titleKey:"settings.behavior.holdLongAssistantReplies.title",subtitleKey:"settings.behavior.holdLongAssistantReplies.subtitle",get:s=>!!(s.holdLongAssistantReplies??!0),set:s=>t.updatePreferences({holdLongAssistantReplies:s})}]);return(()=>{var s=Uz(),r=s.firstChild,o=r.firstChild,a=o.firstChild,i=a.firstChild,c=i.nextSibling,l=a.nextSibling,d=r.nextSibling,u=d.firstChild;return p(i,()=>e("advancedSettings.environmentVariables.title")),p(c,()=>e("advancedSettings.environmentVariables.subtitle")),p(l,()=>e("settings.scope.server")),p(r,y(Bz,{}),null),p(u,y(oy,{settings:n,get preferences(){return t.preferences}})),s})()};var Vz=O("<div class=config-files-selector-value>"),jz=O('<span class="config-files-state config-files-state-inline">'),qz=O('<div class="settings-section-stack config-files-section"><h2 class=sr-only></h2><div class=config-files-card><div class=config-files-toolbar><div class=config-files-selector-field></div><div class=config-files-actions><button type=button class=files-header-icon-button></button><button type=button class=files-header-icon-button></button></div></div><div class="config-files-editor-shell file-viewer-panel">'),zz=O('<div class=selector-option-content><div class="selector-option-description config-files-selector-path">'),Wz=O('<span class=config-files-selector-value-inner><span class="selector-trigger-primary selector-trigger-primary--align-left">'),Hz=O('<span class="selector-trigger-secondary config-files-selector-path">'),Gz=O("<div class=settings-error-message>"),US=O("<div class=config-files-editor-empty>"),Zz=O('<div class="file-viewer-content file-viewer-content--monaco config-files-editor-content">');const Yz=hk(()=>ls(()=>import("./monaco-viewer-BQXd7g3w.js").then(e=>e.at),__vite__mapDeps([1,2,3,4,5])).then(e=>({default:e.MonacoFileViewer}))),Jz=()=>{const{t:e}=Dt(),[t,n]=R([]),[s,r]=R(null),[o,a]=R(""),[i,c]=R(""),[l,d]=R(null),[u,f]=R(!1),[g,m]=R(!1),[w,S]=R(!1),[b,v]=R(null);let k=0;const C=Te(()=>t().find(U=>U.id===s())??null),_=Te(()=>o()!==i()),T=async U=>{const G=++k;m(!0),v(null);try{const le=await kt.readConfigFile(U.id);if(G!==k)return;r(U.id),a(le.contents),c(le.contents),d(le.exists)}catch(le){if(G!==k)return;v(le instanceof Error?le.message:e("settings.configFiles.errors.loadContent")),a(""),c(""),d(null)}finally{G===k&&m(!1)}},P=async()=>_()?ca(e("settings.configFiles.confirmDiscard.message"),{variant:"warning",confirmLabel:e("settings.configFiles.confirmDiscard.confirmLabel"),cancelLabel:e("settings.configFiles.confirmDiscard.cancelLabel"),dismissible:!1}):!0,I=async()=>{f(!0),v(null);try{const U=await kt.listConfigFiles();n(U);const G=U[0];G&&await T(G)}catch(U){v(U instanceof Error?U.message:e("settings.configFiles.errors.loadList"))}finally{f(!1)}},j=async U=>{!U||U.id===s()||!await P()||await T(U)},ne=async()=>{const U=C();!U||!await P()||await T(U)},W=async()=>{const U=C();if(!U)return;const G=o();S(!0),v(null);try{await kt.writeConfigFile(U.id,G),o()===G&&c(G),d(!0),Hn({message:e("settings.configFiles.toast.saveSuccess"),variant:"success"})}catch(le){v(le instanceof Error?le.message:e("settings.configFiles.errors.save")),Hn({message:e("settings.configFiles.toast.saveError"),variant:"error"})}finally{S(!1)}};Ys(()=>{I()});const q=Vx(P);return dt(q),(()=>{var U=qz(),G=U.firstChild,le=G.nextSibling,K=le.firstChild,M=K.firstChild,N=M.nextSibling,oe=N.firstChild,ge=oe.nextSibling,Ie=K.nextSibling;return p(G,()=>e("settings.configFiles.title")),p(M,y(De,{get value(){return C()??void 0},onChange:ke=>void j(ke),get options(){return t()},optionValue:"id",optionTextValue:"label",get disabled(){return u()||t().length===0},itemComponent:ke=>y(De.Item,{get item(){return ke.item},class:"selector-option",get children(){var we=zz(),Ae=we.firstChild;return p(we,y(De.ItemLabel,{class:"selector-option-label",get children(){return ke.item.rawValue.label}}),Ae),p(Ae,()=>ke.item.rawValue.path),we}}),get children(){return[y(De.Trigger,{class:"selector-trigger config-files-selector-trigger",get"aria-label"(){return e("settings.configFiles.selector.label")},get children(){return[(()=>{var ke=Vz();return p(ke,y(De.Value,{children:we=>(()=>{var Ae=Wz(),Ge=Ae.firstChild;return p(Ge,()=>{var H;return((H=we.selectedOption())==null?void 0:H.label)??e("settings.configFiles.selector.placeholder")}),p(Ae,y(ee,{get when(){return we.selectedOption()},children:H=>(()=>{var h=Hz();return p(h,()=>H().path),h})()}),null),Ae})()})),ke})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})),p(N,y(ee,{get when(){return Ee(()=>!!C())()&&(_()||l()===!1)},get children(){var ke=jz();return p(ke,(()=>{var we=Ee(()=>!!_());return()=>we()?e("settings.configFiles.state.unsaved"):e("settings.configFiles.state.notCreated")})()),ke}}),oe),oe.$$click=()=>void W(),p(oe,y(ee,{get when(){return w()},get fallback(){return y(WD,{class:"h-4 w-4"})},get children(){return y(Gd,{class:"h-4 w-4 animate-spin"})}})),ge.$$click=()=>void ne(),p(ge,y(Gd,{get class(){return`h-4 w-4${g()?" animate-spin":""}`}})),p(le,y(ee,{get when(){return b()},children:ke=>(()=>{var we=Gz();return p(we,ke),we})()}),Ie),p(Ie,y(ee,{get when(){return Ee(()=>!u()&&!g())()&&C()},get fallback(){return(()=>{var ke=US();return p(ke,(()=>{var we=Ee(()=>!!(u()||g()));return()=>we()?e("instanceInfo.loading"):e("settings.configFiles.empty")})()),ke})()},children:ke=>(()=>{var we=Zz();return p(we,y(SM,{get fallback(){return(()=>{var Ae=US();return p(Ae,()=>e("instanceInfo.loading")),Ae})()},get children(){return y(Yz,{scopeKey:"settings-config-files",get path(){return ke().path},get content(){return o()},wordWrap:"off",compactGutter:!0,onSave:()=>void W(),onContentChange:Ae=>a(Ae)})}})),we})()})),de(ke=>{var we=e("settings.configFiles.actions.save"),Ae=e("settings.configFiles.actions.save"),Ge=!C()||w()||g()||!_(),H=e("settings.configFiles.actions.reload"),h=e("settings.configFiles.actions.reload"),$=!C()||g()||w();return we!==ke.e&&me(oe,"title",ke.e=we),Ae!==ke.t&&me(oe,"aria-label",ke.t=Ae),Ge!==ke.a&&(oe.disabled=ke.a=Ge),H!==ke.o&&me(ge,"title",ke.o=H),h!==ke.i&&me(ge,"aria-label",ke.i=h),$!==ke.n&&(ge.disabled=ke.n=$),ke},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),U})()};Xt(["click"]);function Qz(e={}){const[t,n]=Pk({value:()=>he(e.isSelected),defaultValue:()=>!!he(e.defaultIsSelected),onChange:o=>{var a;return(a=e.onSelectedChange)==null?void 0:a.call(e,o)}});return{isSelected:t,setIsSelected:o=>{!he(e.isReadOnly)&&!he(e.isDisabled)&&n(o)},toggle:()=>{!he(e.isReadOnly)&&!he(e.isDisabled)&&n(!t())}}}var Xz={};yl(Xz,{Control:()=>ST,Description:()=>kT,ErrorMessage:()=>xT,Input:()=>_T,Label:()=>$T,Root:()=>CT,Switch:()=>Cc,Thumb:()=>ET,useSwitchContext:()=>Mi});var bT=qr();function Mi(){const e=zr(bT);if(e===void 0)throw new Error("[kobalte]: `useSwitchContext` must be used within a `Switch` component");return e}function ST(e){const t=pr(),n=Mi(),s=Kt({id:n.generateId("control")},e),[r,o]=Nt(s,["onClick","onKeyDown"]);return y(en,_e({as:"div",onClick:c=>{var l;on(c,r.onClick),n.toggle(),(l=n.inputRef())==null||l.focus()},onKeyDown:c=>{var l;on(c,r.onKeyDown),c.key===Pp.Space&&(n.toggle(),(l=n.inputRef())==null||l.focus())}},()=>t.dataset(),()=>n.dataset(),o))}function kT(e){const t=Mi();return y(zp,_e(()=>t.dataset(),e))}function xT(e){const t=Mi();return y(ny,_e(()=>t.dataset(),e))}function _T(e){const t=pr(),n=Mi(),s=Kt({id:n.generateId("input")},e),[r,o,a]=Nt(s,["ref","style","onChange","onFocus","onBlur"],Tx),{fieldProps:i}=Mx(o);return y(en,_e({as:"input",ref(u){var f=Kn(n.setInputRef,r.ref);typeof f=="function"&&f(u)},type:"checkbox",role:"switch",get id(){return i.id()},get name(){return t.name()},get value(){return n.value()},get checked(){return n.checked()},get required(){return t.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return t.isReadOnly()},get style(){return ml({...nf},r.style)},get"aria-checked"(){return n.checked()},get"aria-label"(){return i.ariaLabel()},get"aria-labelledby"(){return i.ariaLabelledBy()},get"aria-describedby"(){return i.ariaDescribedBy()},get"aria-invalid"(){return t.validationState()==="invalid"||void 0},get"aria-required"(){return t.isRequired()||void 0},get"aria-disabled"(){return t.isDisabled()||void 0},get"aria-readonly"(){return t.isReadOnly()||void 0},onChange:u=>{on(u,r.onChange),u.stopPropagation();const f=u.target;n.setIsChecked(f.checked),f.checked=n.checked()},onFocus:u=>{on(u,r.onFocus),n.setIsFocused(!0)},onBlur:u=>{on(u,r.onBlur),n.setIsFocused(!1)}},()=>t.dataset(),()=>n.dataset(),a))}function $T(e){const t=Mi();return y(Ax,_e(()=>t.dataset(),e))}function CT(e){let t;const n=`switch-${Do()}`,s=Kt({value:"on",id:n},e),[r,o,a]=Nt(s,["ref","children","value","checked","defaultChecked","onChange","onPointerDown"],dx),[i,c]=R(),[l,d]=R(!1),{formControlContext:u}=ux(o),f=Qz({isSelected:()=>r.checked,defaultIsSelected:()=>r.defaultChecked,onSelectedChange:S=>{var b;return(b=r.onChange)==null?void 0:b.call(r,S)},isDisabled:()=>u.isDisabled(),isReadOnly:()=>u.isReadOnly()});Dx(()=>t,()=>f.setIsSelected(r.defaultChecked??!1));const g=S=>{on(S,r.onPointerDown),l()&&S.preventDefault()},m=Te(()=>({"data-checked":f.isSelected()?"":void 0})),w={value:()=>r.value,dataset:m,checked:()=>f.isSelected(),inputRef:i,generateId:ja(()=>he(o.id)),toggle:()=>f.toggle(),setIsChecked:S=>f.setIsSelected(S),setIsFocused:d,setInputRef:c};return y(qp.Provider,{value:u,get children(){return y(bT.Provider,{value:w,get children(){return y(en,_e({as:"div",ref(S){var b=Kn(v=>t=v,r.ref);typeof b=="function"&&b(S)},role:"group",get id(){return he(o.id)},onPointerDown:g},()=>u.dataset(),m,a,{get children(){return y(eW,{state:w,get children(){return r.children}})}}))}})}})}function eW(e){const t=gk(()=>{const n=e.children;return tf(n)?n(e.state):n});return Ee(t)}function ET(e){const t=pr(),n=Mi(),s=Kt({id:n.generateId("thumb")},e);return y(en,_e({as:"div"},()=>t.dataset(),()=>n.dataset(),s))}var Cc=Object.assign(CT,{Control:ST,Description:kT,ErrorMessage:xT,Input:_T,Label:$T,Thumb:ET}),tW=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},TT={},hs={};let Sw;const nW=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];hs.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};hs.getSymbolTotalCodewords=function(t){return nW[t]};hs.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};hs.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Sw=t};hs.isKanjiModeEnabled=function(){return typeof Sw<"u"};hs.toSJIS=function(t){return Sw(t)};var bg={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,r){if(e.isValid(s))return s;try{return t(s)}catch{return r}}})(bg);function MT(){this.buffer=[],this.length=0}MT.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var sW=MT;function Hl(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Hl.prototype.set=function(e,t,n,s){const r=e*this.size+t;this.data[r]=n,s&&(this.reservedBit[r]=!0)};Hl.prototype.get=function(e,t){return this.data[e*this.size+t]};Hl.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Hl.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var rW=Hl,AT={};(function(e){const t=hs.getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const r=Math.floor(s/7)+2,o=t(s),a=o===145?26:Math.ceil((o-13)/(2*r-2))*2,i=[o-7];for(let c=1;c<r-1;c++)i[c]=i[c-1]-a;return i.push(6),i.reverse()},e.getPositions=function(s){const r=[],o=e.getRowColCoords(s),a=o.length;for(let i=0;i<a;i++)for(let c=0;c<a;c++)i===0&&c===0||i===0&&c===a-1||i===a-1&&c===0||r.push([o[i],o[c]]);return r}})(AT);var DT={};const oW=hs.getSymbolSize,KS=7;DT.getPositions=function(t){const n=oW(t);return[[0,0],[n-KS,0],[0,n-KS]]};var PT={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const o=r.size;let a=0,i=0,c=0,l=null,d=null;for(let u=0;u<o;u++){i=c=0,l=d=null;for(let f=0;f<o;f++){let g=r.get(u,f);g===l?i++:(i>=5&&(a+=t.N1+(i-5)),l=g,i=1),g=r.get(f,u),g===d?c++:(c>=5&&(a+=t.N1+(c-5)),d=g,c=1)}i>=5&&(a+=t.N1+(i-5)),c>=5&&(a+=t.N1+(c-5))}return a},e.getPenaltyN2=function(r){const o=r.size;let a=0;for(let i=0;i<o-1;i++)for(let c=0;c<o-1;c++){const l=r.get(i,c)+r.get(i,c+1)+r.get(i+1,c)+r.get(i+1,c+1);(l===4||l===0)&&a++}return a*t.N2},e.getPenaltyN3=function(r){const o=r.size;let a=0,i=0,c=0;for(let l=0;l<o;l++){i=c=0;for(let d=0;d<o;d++)i=i<<1&2047|r.get(l,d),d>=10&&(i===1488||i===93)&&a++,c=c<<1&2047|r.get(d,l),d>=10&&(c===1488||c===93)&&a++}return a*t.N3},e.getPenaltyN4=function(r){let o=0;const a=r.data.length;for(let c=0;c<a;c++)o+=r.data[c];return Math.abs(Math.ceil(o*100/a/5)-10)*t.N4};function n(s,r,o){switch(s){case e.Patterns.PATTERN000:return(r+o)%2===0;case e.Patterns.PATTERN001:return r%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(r+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return r*o%2+r*o%3===0;case e.Patterns.PATTERN110:return(r*o%2+r*o%3)%2===0;case e.Patterns.PATTERN111:return(r*o%3+(r+o)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(r,o){const a=o.size;for(let i=0;i<a;i++)for(let c=0;c<a;c++)o.isReserved(c,i)||o.xor(c,i,n(r,c,i))},e.getBestMask=function(r,o){const a=Object.keys(e.Patterns).length;let i=0,c=1/0;for(let l=0;l<a;l++){o(l),e.applyMask(l,r);const d=e.getPenaltyN1(r)+e.getPenaltyN2(r)+e.getPenaltyN3(r)+e.getPenaltyN4(r);e.applyMask(l,r),d<c&&(c=d,i=l)}return i}})(PT);var Sg={};const io=bg,$d=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Cd=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Sg.getBlocksCount=function(t,n){switch(n){case io.L:return $d[(t-1)*4+0];case io.M:return $d[(t-1)*4+1];case io.Q:return $d[(t-1)*4+2];case io.H:return $d[(t-1)*4+3];default:return}};Sg.getTotalCodewordsCount=function(t,n){switch(n){case io.L:return Cd[(t-1)*4+0];case io.M:return Cd[(t-1)*4+1];case io.Q:return Cd[(t-1)*4+2];case io.H:return Cd[(t-1)*4+3];default:return}};var IT={},kg={};const Fc=new Uint8Array(512),Zu=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Fc[n]=t,Zu[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Fc[n]=Fc[n-255]})();kg.log=function(t){if(t<1)throw new Error("log("+t+")");return Zu[t]};kg.exp=function(t){return Fc[t]};kg.mul=function(t,n){return t===0||n===0?0:Fc[Zu[t]+Zu[n]]};(function(e){const t=kg;e.mul=function(s,r){const o=new Uint8Array(s.length+r.length-1);for(let a=0;a<s.length;a++)for(let i=0;i<r.length;i++)o[a+i]^=t.mul(s[a],r[i]);return o},e.mod=function(s,r){let o=new Uint8Array(s);for(;o.length-r.length>=0;){const a=o[0];for(let c=0;c<r.length;c++)o[c]^=t.mul(r[c],a);let i=0;for(;i<o.length&&o[i]===0;)i++;o=o.slice(i)}return o},e.generateECPolynomial=function(s){let r=new Uint8Array([1]);for(let o=0;o<s;o++)r=e.mul(r,new Uint8Array([1,t.exp(o)]));return r}})(IT);const RT=IT;function kw(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}kw.prototype.initialize=function(t){this.degree=t,this.genPoly=RT.generateECPolynomial(this.degree)};kw.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const s=RT.mod(n,this.genPoly),r=this.degree-s.length;if(r>0){const o=new Uint8Array(this.degree);return o.set(s,r),o}return s};var iW=kw,OT={},Bo={},xw={};xw.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var wr={};const LT="[0-9]+",aW="[A-Z $%*+\\-./:]+";let gl="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";gl=gl.replace(/u/g,"\\u");const cW="(?:(?![A-Z0-9 $%*+\\-./:]|"+gl+`)(?:.|[\r
|
|
35
|
+
`)}function d8(e){const t=e.toLowerCase();return t.includes("opencode binary not found")||t.includes("binary not found")||t.includes("no such file or directory")||t.includes("binary is not executable")||t.includes("enoent")}const[rZ,LE]=R(null),TS=new Map;function u8(e){LE(e)}function oZ(){LE(null)}function f8(e){const t=e.id,n=e.error,s=c8(n,$e("app.launchError.fallbackMessage"),$e("app.launchError.invalidConfig"),$e("opencodeBinarySelector.validation.v2Required")),r=TS.get(t);if(r&&r===s)return;TS.set(t,s);const o=(e.binaryLabel||e.binaryId||"opencode2").trim()||"opencode2",a=d8(s);u8({source:"workspace",instanceId:t,message:s,binaryPath:o,missingBinary:a})}const mp=Ut("session"),fc=new Map,gc=new Map;function g8(e){return Bs(e)}function NE(e,t){var s;if(!e)return!1;const n=(s=e.mcpStatus)==null?void 0:s.location;return!!(n&&Bs(n)===Bs(t))}function h8(e,t){return!e||e.project===void 0||e.mcpStatus===void 0?!1:!t||NE(e,t)}function FE(e,t){const n=e.client;if(!n)return mp.warn("[metadata] Skipping fetch; client missing",{instanceId:e.id}),Promise.resolve();const s=(t==null?void 0:t.location)??{directory:e.folder},r=g8(s),o=co(e.id)??e.metadata;if(!(t!=null&&t.force)&&h8(o,s))return Promise.resolve();const a=wu(e.id),i=fc.get(e.id);if((i==null?void 0:i.client)===n&&i.generation===a&&i.locationKey===r)return i.promise;const c={client:n,generation:a,locationKey:r,promise:Promise.resolve()};return c.promise=(async()=>{var l;try{const d=Io(s),[u,f,g]=await Promise.allSettled([BE(e,t),n.project.list(),n.mcp.list({location:d},Zt(s))]),m=(l=co(e.id))==null?void 0:l.project,w=m&&f.status==="fulfilled"?f.value.find(v=>v.id===m.id):void 0,S=co(e.id)??o,b={...S??{}};if(S&&!NE(S,s)&&(b.mcpStatus=void 0),u.status==="fulfilled"&&m&&(w!=null&&w.vcs)&&(b.project={...m,vcs:w.vcs}),g.status==="fulfilled"&&(b.mcpStatus=g.value),!(b!=null&&b.version)&&e.binaryVersion&&(b.version=e.binaryVersion),fc.get(e.id)!==c||wu(e.id)!==a)return;F_(e.id,b)}catch(d){mp.error("Failed to load instance metadata",d)}finally{fc.get(e.id)===c&&fc.delete(e.id)}})(),fc.set(e.id,c),c.promise}function BE(e,t){const n=e.client;if(!n)return Promise.resolve();const s=co(e.id)??e.metadata;if(!(t!=null&&t.force)&&s&&"project"in s)return Promise.resolve();const r=wu(e.id),o=gc.get(e.id);if((o==null?void 0:o.client)===n&&o.generation===r)return o.promise;const a={client:n,generation:r,promise:Promise.resolve()};return a.promise=n.location.get({location:{directory:e.folder}}).then(i=>{gc.get(e.id)!==a||wu(e.id)!==r||F_(e.id,{project:i.project,...!(s!=null&&s.version)&&e.binaryVersion?{version:e.binaryVersion}:{}})}).catch(i=>mp.warn("Failed to load project metadata",{instanceId:e.id,error:i})).finally(()=>{gc.get(e.id)===a&&gc.delete(e.id)}),gc.set(e.id,a),a.promise}const[m8,sw]=R(new Map);function Zr(e){return m8().get(e)??[]}function p8(e,t){sw(n=>{const s=new Map(n),r=s.get(e)??[],o=r.findIndex(i=>i.id===t.id);if(o!==-1&&JSON.stringify(r[o])===JSON.stringify(t))return n;const a=r.slice();return o===-1?a.push(t):a[o]=t,s.set(e,a),s})}function y8(e,t){sw(n=>{const s=new Map(n),r=(s.get(e)??[]).filter(o=>o.id!==t);return r.length?s.set(e,r):s.delete(e),s})}function v8(e,t){sw(n=>{const s=new Map(n);return t.length?s.set(e,[...t]):s.delete(e),s})}function w8(e){v8(e,[])}function UE(e){var t;if(!(e.sessionID!=="global"||!e.location))return{headers:{"x-opencode-directory":encodeURIComponent(e.location.directory),...(t=Zt(e.location))==null?void 0:t.headers}}}const[b8,S8]=R(new Map);function k8(e){S8(t=>{const n=new Map(t);return n.set(e,(n.get(e)??0)+1),n})}function iZ(e){return b8().get(e)??0}function aZ(e,t=100){let n;return{trigger(){n&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e()},t)},cancel(){n&&clearTimeout(n),n=void 0}}}const[cZ,KE]=R(new Set),pp=new Set;function lZ(e){KE(t=>t.has(e)?t:new Set(t).add(e))}function x8(e){KE(t=>{if(!t.has(e))return t;const n=new Set(t);return n.delete(e),n})}function dZ(e){return pp.add(e),()=>pp.delete(e)}function _8(e){for(const t of pp)t(e)}async function $8(e,t,n,s){let r=e;for(;;){s==null||s.throwIfAborted();const o=t();if(r!==o){r=o;continue}const a=new AbortController,i=()=>a.abort(s==null?void 0:s.reason);s==null||s.addEventListener("abort",i,{once:!0});let c;try{c=await Promise.race([r.then(d=>({type:"result",result:d})),n(r,a.signal).then(()=>({type:"change"}))])}finally{s==null||s.removeEventListener("abort",i),a.abort()}if(c.type==="change")continue;const l=c.result;if(r===t()){if(l.error!==void 0)throw l.error;return}}}const yp=new Set;function uZ(e){return yp.add(e),()=>yp.delete(e)}function vp(e){for(const t of yp)t(e)}class C8 extends Error{constructor(t){super(t),this.name="RestoreTimeoutError"}}function na(e){if(e.reason instanceof Error)return e.reason;const t=new Error("Restore operation was aborted");return t.name="AbortError",t}function E8(e,t={}){return new Promise((n,s)=>{var l,d;const r=new AbortController;let o=!1;const a=u=>{var f;o||(o=!0,c&&clearTimeout(c),(f=t.signal)==null||f.removeEventListener("abort",i),u())},i=()=>{const u=na(t.signal);r.abort(u),a(()=>s(u))},c=t.timeoutMs===void 0?void 0:setTimeout(()=>{const u=new C8(t.message??"Operation timed out");r.abort(u),a(()=>s(u))},t.timeoutMs);if((l=t.signal)!=null&&l.aborted){i();return}(d=t.signal)==null||d.addEventListener("abort",i,{once:!0}),Promise.resolve().then(()=>e(r.signal)).then(u=>{a(()=>n(u))},u=>{a(()=>s(u))})})}const T8=[250,1e3,2e3];class M8{constructor(t){this.options=t,this.owned=new Map,this.pendingRequestIds=new Map}track(t){const n=this.owned.get(t.id);n?"workspace"in n&&!("released"in n)&&(n.workspace=t):this.owned.set(t.id,{workspace:t})}beginRequest(t){this.pendingRequestIds.set(t,!1)}finishRequest(t){this.pendingRequestIds.delete(t)}forgetRequest(t,n){this.pendingRequestIds.delete(n);const s=this.owned.get(t);s&&"workspace"in s&&!("completion"in s)&&s.workspace.requestId===n&&this.owned.delete(t)}quarantineRequest(t){if(this.pendingRequestIds.has(t)){this.pendingRequestIds.set(t,!0);for(const[n,s]of this.owned){if(!("workspace"in s)||s.workspace.requestId!==t)continue;const r=this.discardTracked(n,{retainTombstone:s.workspace.reused!==!0});return r.finally(()=>this.finishRequest(t)),r}}}trackPendingRequest(t){if(!t.requestId)return!1;const n=this.pendingRequestIds.get(t.requestId);return n===void 0?!1:(this.track(t),n&&this.discardTracked(t.id,{retainTombstone:t.reused!==!0}).finally(()=>this.finishRequest(t.requestId)),!0)}release(t){const n=this.owned.get(t);if(!(!n||"tombstone"in n||"released"in n||"completion"in n))return this.owned.set(t,{released:!0}),n.workspace}get(t){const n=this.owned.get(t);return n&&"workspace"in n&&!("completion"in n)?n.workspace:void 0}async releaseAfter(t,n){const s=this.release(t);if(s)try{return await n(s),s}catch(r){const o=this.owned.get(t);throw s&&o&&"released"in o&&this.owned.set(t,{workspace:s}),r}}releaseTombstoneForUserCreate(t){const n=this.owned.get(t);n&&("tombstone"in n||"released"in n)&&this.owned.delete(t)}owns(t){const n=this.owned.get(t);return!!(n&&!("released"in n))}shouldIgnoreEvent(t){const n=this.owned.get(t);return!!n&&("completion"in n||"tombstone"in n)}discardCreated(t,n){return this.start(t,n)}discardTracked(t,n){const s=this.owned.get(t);return!s||"tombstone"in s||"released"in s?Promise.resolve():"completion"in s?s.completion:this.start(s.workspace,n)}start(t,n){const s=this.owned.get(t.id);if(s&&"completion"in s)return s.completion;if(s&&("tombstone"in s||"released"in s))return Promise.resolve();let r;const o=new Promise(i=>{r=i}),a={workspace:t,completion:o,resolve:r,retainTombstone:(n==null?void 0:n.retainTombstone)===!0};return this.owned.set(t.id,a),this.run(a),o}async run(t){var a,i;let n,s=!1;const r=this.options.retryDelaysMs??T8;let o=0;try{await Dp(()=>this.options.discardWorkspace(t.workspace),{maxAttempts:r.length+1,wait:()=>(this.options.wait??(c=>new Promise(l=>setTimeout(l,c))))(r[o++]??0)}),s=!0}catch(c){n=c}if(this.owned.get(t.workspace.id)===t){if(!s)try{this.options.restoreWorkspace(t.workspace)}catch(c){n=c}if(s&&t.retainTombstone?this.owned.set(t.workspace.id,{tombstone:!0}):this.owned.delete(t.workspace.id),t.resolve(),!s)try{(i=(a=this.options).onPermanentFailure)==null||i.call(a,t.workspace,n)}catch{}}}}class A8{constructor(t,n){this.run=t,this.onError=n,this.tails=new Map}request(t){const r=(this.tails.get(t)??Promise.resolve()).then(async()=>{try{await this.run(t)}catch(o){this.onError(t,o)}}).finally(()=>{this.tails.get(t)===r&&this.tails.delete(t)});return this.tails.set(t,r),r}}async function D8(e){try{await e}catch{}}function P8(e){return Dp(()=>kt.cancelWorkspaceCreation(e),{maxAttempts:4,initialDelayMs:250,maxDelayMs:2e3,backoffMultiplier:4})}const MS=e=>e==="error"||e==="stopped"?3:e==="ready"?2:1;function AS(e,t){const n=MS(t.status)-MS(e.status);if(n!==0)return n>0?t:e;const s=Date.parse(e.updatedAt),r=Date.parse(t.updatedAt);return Number.isFinite(s)&&Number.isFinite(r)&&s!==r?r>s?t:e:t}class I8{constructor(){this.byRequestId=new Map,this.byWorkspaceId=new Map,this.stoppedByWorkspaceId=new Map}begin(t,n,s){const r={requestId:t,wait:n,workspaceIds:new Set,...s?{expectedPath:Oa(s)}:{}};return this.byRequestId.set(t,r),r}bindResponse(t,n){const s=this.byRequestId.get(t);if(!s)return;s.workspaceIds.add(n),this.byWorkspaceId.set(n,s);const r=this.stoppedByWorkspaceId.get(n);r&&(s.terminal=r,this.stoppedByWorkspaceId.delete(n))}deferWorkspace(t){const n=t.requestId?this.byRequestId.get(t.requestId)??this.byWorkspaceId.get(t.id):this.byWorkspaceId.get(t.id);return n?(n.workspace=n.workspace?AS(n.workspace,t):t,n.workspaceIds.add(t.id),this.byWorkspaceId.set(t.id,n),(t.status==="error"||t.status==="stopped")&&(n.terminal={status:t.status,message:t.error}),!0):!1}deferRefreshWorkspace(t){if(this.deferWorkspace(t))return!0;const n=Oa(t.path);return[...this.byRequestId.values()].some(s=>s.expectedPath===n)}deferStopped(t,n){const s=this.byWorkspaceId.get(t),r={status:"stopped",message:n};return s?(s.terminal=r,!0):(this.byRequestId.size>0&&this.stoppedByWorkspaceId.set(t,r),!1)}resolve(t,n){const s=this.byRequestId.get(t);return{workspace:s!=null&&s.workspace?AS(n,s.workspace):n,...s!=null&&s.terminal?{terminal:s.terminal}:{}}}end(t){const n=this.byRequestId.get(t);if(n){this.byRequestId.delete(t);for(const s of n.workspaceIds)this.byWorkspaceId.get(s)===n&&this.byWorkspaceId.delete(s),this.stoppedByWorkspaceId.delete(s);this.byRequestId.size===0&&this.stoppedByWorkspaceId.clear()}}}class R8{constructor(){this.requestRevision=0,this.mutationRevision=0,this.workspaceRevisions=new Map}begin(){return{requestRevision:++this.requestRevision,mutationRevision:this.mutationRevision}}markMutation(t){this.workspaceRevisions.set(t,++this.mutationRevision)}isCurrent(t){return t.requestRevision===this.requestRevision}allows(t,n){return this.isCurrent(t)&&(this.workspaceRevisions.get(n)??0)<=t.mutationRevision}complete(t){this.isCurrent(t)&&(this.workspaceRevisions.clear(),this.requestRevision+=1)}}const qt=Ut("api");o8((e,t)=>{const n=Ne().get(e);return n?r8(t,s=>n.get(s)):t});xs.on("yolo.stateChanged",e=>{if(e.type!=="yolo.stateChanged")return;const{instanceId:t,sessionId:n,enabled:s}=e;typeof t!="string"||typeof n!="string"||typeof s!="boolean"||(qt.info(`[SSE] Yolo state changed: ${t}:${n} -> ${s}`),cl(t,n,s))});xs.on("yolo.autoAccepted",e=>{if(e.type!=="yolo.autoAccepted")return;const{instanceId:t,permissionId:n}=e;typeof t!="string"||typeof n!="string"||(fg(t,n),zl(t,n),_f(t,n))});const[Fe,rw]=R(new Map),[Ds,VE]=R(null),[jE,hg]=R(new Map),[O8,ow]=R(new Map),L8=250,Qo=new Map;function qE(e,t){return`${e}\0${t}`}function N8(e,t,n){const s=qE(e,t),r=Qo.get(s);if(r){r.project=n;return}const o={project:n,timeout:setTimeout(()=>{Qo.delete(s),o.project()},L8)};Qo.set(s,o)}function F8(e,t){const n=qE(e,t),s=Qo.get(n);s&&(clearTimeout(s.timeout),Qo.delete(n))}function iw(e){const t=`${e}\0`;for(const[n,s]of Qo)n.startsWith(t)&&(clearTimeout(s.timeout),Qo.delete(n))}const[zE,aw]=R(new Map),[B8,WE]=R(new Map),mg=new Map,pg=new Map;function sa(e){if(e){if(typeof e=="string")return Bs({directory:Oa(e)});if(e.directory)return Bs({...e,directory:Oa(e.directory)})}}function HE(e,t,n,s){const r=sa(s);if(!r)return;const o=e.get(t)??new Map;o.set(n,r),e.set(t,o)}function GE(e,t,n){const s=e.get(t);s&&(s.delete(n),s.size||e.delete(t))}class ZE{constructor(){this.enqueuedAt=new Map,this.sessionCounts=new Map}ensureEnqueuedAt(t){const n=this.enqueuedAt.get(t.id);if(n)return n;const s=Date.now();return this.enqueuedAt.set(t.id,s),s}enqueuedAtFor(t){return this.enqueuedAt.get(t)??Date.now()}remove(t,n){this.enqueuedAt.delete(n)}increment(t,n){const s=this.sessionCounts.get(t)??new Map;s.set(n,(s.get(n)??0)+1),this.sessionCounts.set(t,s)}decrement(t,n){const s=this.sessionCounts.get(t),r=Math.max(0,((s==null?void 0:s.get(n))??0)-1);return r?s==null||s.set(n,r):s==null||s.delete(n),(s==null?void 0:s.size)===0&&this.sessionCounts.delete(t),r}sessionIds(t){var n;return((n=this.sessionCounts.get(t))==null?void 0:n.keys())??new Map().keys()}clear(t,n,s){var r;n.forEach(({id:o})=>this.enqueuedAt.delete(o));for(const o of((r=this.sessionCounts.get(t))==null?void 0:r.keys())??[])s(o);this.sessionCounts.delete(t)}}const Wn=new ZE,ho=new ZE,[U8,K8]=R(new Map);function cw(){const e=Array.from(Fe().values()).some(t=>t.status==="ready");X6(e)}const[lw,dw]=R(null),V8=1e3,xd=new Map,uw=new Map,fw=new Map,gw=new Map,Ud=new Map,Fa=new Map,Mo=new Map,ll=new Map,nr=new Map,xc=new Map,_c=new Map,hw=new Error("Pending request sync was superseded");let j8=0;async function mw(e,t,n=!0){const s=new AbortController,r=_c.get(e)??new Set;r.add(s),_c.set(e,r);try{const o=async()=>{const a=setTimeout(()=>s.abort(),1e4);try{return await t(s.signal)}finally{clearTimeout(a)}};return await(n?gy.run(s.signal,o):o())}finally{r.delete(s),!r.size&&_c.get(e)===r&&_c.delete(e)}}function Wu(e){for(const t of _c.get(e)??[])t.abort()}async function YE(e,t,n){const s=new Array(e.length);let r=0;return await Promise.all(Array.from({length:Math.min(4,e.length)},async()=>{for(;t()&&r<e.length;){const o=r++;try{s[o]={status:"fulfilled",value:await n(e[o])}}catch(a){s[o]={status:"rejected",reason:a}}}})),s.filter(o=>o!==void 0)}function Us(e,t){e.set(t,(e.get(t)??0)+1)}function dl(e){Us(Ud,e),Us(Fa,e),Us(Mo,e)}const Er=new R8,mn=new M8({discardWorkspace:e=>e.requestId?kt.cancelWorkspaceCreation(e.requestId):Promise.reject(new Error(`Restore workspace ${e.id} has no creation request`)),restoreWorkspace:e=>{Er.markMutation(e.id),ra(e)},onPermanentFailure:(e,t)=>{qt.error("Failed to cancel restore workspace ownership; restored it to the UI",{workspaceId:e.id,error:t})}});let DS=0;const so=new I8,q8=new A8(async e=>{await D8(uw.get(e));const t=Fe().get(e);if(!(t!=null&&t.client)||t.status!=="ready")return;let n;try{await Ei(e,{reset:!0})}catch(o){n=o}if(await Promise.all([wi(e),ql(e),pw(e),QE(e)]),n)throw n;const s=ng().get(e)??new Set;for(const o of s)No(e,o);const r=es().get(e);r&&s.has(r)&&await hr(e,r,{force:!0}),mr(e)},(e,t)=>{qt.warn("Failed to resync sessions after instance connection",{instanceId:e,error:t})}),JE=new Q6;function z8(e){q8.request(e)}async function QE(e){const t=Fe().get(e);if(!(t!=null&&t.client)||t.status!=="ready")return;const n=ng().get(e)??new Set;await Promise.all(Array.from(n,async s=>{var o,a;const r=((a=(o=Ne().get(e))==null?void 0:o.get(s))==null?void 0:a.location.directory)??t.folder;try{await ij(e,s,r)}catch(i){qt.warn("Failed to resync session inbox after connection",{instanceId:e,sessionId:s,error:i})}}))}const W8=["agents","providers","commands","metadata","filesystem"],$c=new Map;function pw(e,t=W8){const n=$c.get(e);if(n){for(const a of t)n.pending.add(a);return n.promise}const s=Fe().get(e);if(!(s!=null&&s.client)||s.status!=="ready")return Promise.resolve();const r=s.client,o={promise:Promise.resolve(),pending:new Set(t)};return o.promise=(async()=>{do{const a=new Set(o.pending);o.pending.clear(),a.has("filesystem")&&k8(e);const i=[],c=Nn(e);a.has("agents")&&i.push(Jf(e,c,!0)),a.has("providers")&&i.push(Da(e,c,!0)),a.has("commands")&&i.push(z_(e,r,c)),a.has("metadata")&&i.push(FE(s,{force:!0,location:c})),await Promise.all(i)}while(o.pending.size)})().finally(()=>{$c.get(e)===o&&$c.delete(e)}),$c.set(e,o),o.promise}xs.on("instance.eventStatus",e=>{var n;if(e.type!=="instance.eventStatus")return;const t=JE.observe(e.instanceId,e.status,e.reason);e.status==="connected"&&(((n=lw())==null?void 0:n.id)===e.instanceId&&dw(null),t&&z8(e.instanceId))});function H8(){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?`restore-${globalThis.crypto.randomUUID()}`:(DS+=1,`restore-${Date.now().toString(36)}-${DS.toString(36)}`)}const Hu=new Map;function ul(e,t){const n=Hu.get(e);if(n){Hu.delete(e);for(const s of n)t?s.reject(t):s.resolve()}}function mr(e){vq(e,new Set(Wn.sessionIds(e)),new Set(ho.sessionIds(e)))}function G8(e,t){const n=Fe().get(e.id);return{id:e.id,folder:e.path,projectName:t??(n==null?void 0:n.projectName)??e.name,port:e.port??(n==null?void 0:n.port)??0,pid:e.pid??(n==null?void 0:n.pid)??0,proxyPath:e.proxyPath,status:e.status,error:e.error,client:(n==null?void 0:n.client)??null,metadata:n==null?void 0:n.metadata,binaryPath:e.binaryId??e.binaryLabel??(n==null?void 0:n.binaryPath),binaryLabel:e.binaryLabel,binaryVersion:e.binaryVersion??(n==null?void 0:n.binaryVersion),environmentVariables:(n==null?void 0:n.environmentVariables)??ef().environmentVariables??{}}}function ra(e,t){const n=G8(e,t);Fe().has(e.id)?fl(e.id,n):aT(n),e.status==="ready"?(Z8(e),ul(e.id)):(e.status==="error"||e.status==="stopped")&&ul(e.id,new Error(e.error||`Workspace ${e.id} did not become ready`))}function Z8(e){const t=Fe().get(e.id);if(!t)return;const n=e.port??t.port,s=e.proxyPath;if(t.client&&t.proxyPath===s){n&&t.port!==n&&fl(e.id,{port:n});return}t.client&&(fa.destroyClientsForInstance(e.id),Ol(e.id));const r=fa.createClient(e.id,s,()=>Ds()===e.id);fl(e.id,{client:r,port:n??0,proxyPath:s,status:"ready"}),vn.seedStatusIfMissing(e.id,"connecting");const o=eT(e.id);fw.set(e.id,o.sessions),gw.set(e.id,o.workspaceMetadata);const a=tT(e.id,{propagateErrors:!0,sessionHydration:o.sessions,workspaceMetadataHydration:o.workspaceMetadata});uw.set(e.id,a),a.catch(i=>{qt.error("Failed to hydrate instance data",i)})}function yg(e){const t=Fe().get(e);return(t==null?void 0:t.status)==="ready"&&t.client?Promise.resolve():(t==null?void 0:t.status)==="error"||(t==null?void 0:t.status)==="stopped"?Promise.reject(new Error(t.error||`Workspace ${e} did not become ready`)):new Promise((n,s)=>{const r={resolve:n,reject:s},o=Hu.get(e)??new Set;o.add(r),Hu.set(e,o);const a=Fe().get(e);(a==null?void 0:a.status)==="ready"&&a.client?ul(e):((a==null?void 0:a.status)==="error"||(a==null?void 0:a.status)==="stopped")&&ul(e,new Error(a.error||`Workspace ${e} did not become ready`))})}async function Y8(e){await yg(e),await fw.get(e)}async function J8(e){await yg(e),await gw.get(e)}function yw(e){const t=Fe().get(e);t&&(t.client&&fa.destroyClientsForInstance(e),Ol(e),vn.seedStatus(e,"disconnected"))}function XE(e,t){var n;return NL(t,[Nn(e),...ko(e),...Array.from(((n=Ne().get(e))==null?void 0:n.values())??[]).map(s=>s.location),...Zr(e).flatMap(s=>s.location?[s.location]:[])])}async function Q8(e,t=!1,n=()=>!0){var o,a,i;const s=Fe().get(e);if(!(s!=null&&s.client))return;const r=Fa.get(e)??0;try{const c=Date.now(),l=[],d=XE(e,s.folder),u=new Set,f=await YE(d,n,async v=>{const k=await mw(e,C=>s.client.permission.request.list({location:Io(v)},{...Zt(v),signal:C}));return{location:v,response:k}}),g=[];for(const v of f){if(v.status==="rejected"){g.push(v.reason);continue}const{location:k,response:C}=v.value;qt.info("permission.request.list",{instanceId:e,location:k,resolvedLocation:C.location});const _={directory:C.location.directory||k.directory,workspaceID:bf(C.location)},T=sa(_);T&&(u.add(T),l.push(...C.data.map(P=>({request:P,location:_,key:T}))))}const m=new Set(l.map(({request:v})=>v.id));if(!n()||(Fa.get(e)??0)!==r){if(t)throw hw;return}g.length||e8(e,m,c);const w=l.filter(({request:v})=>!gg(e,v.id)),S=new Set(w.map(({request:v})=>v.id)),b=Fo(e);for(const v of b){const k=((o=mg.get(e))==null?void 0:o.get(v.id))??sa((i=(a=Ne().get(e))==null?void 0:a.get(ua(v)??""))==null?void 0:i.location);!S.has(v.id)&&k&&u.has(k)&&(zl(e,v.id),_f(e,v.id))}for(const{request:v,location:k}of w){const C=vw(e,v,k)??v;L_(e,C)}if(mr(e),g.length&&(qt.warn("Pending permission scan was partial",{instanceId:e,failedLocations:g.length}),t))throw g[0]}catch(c){if(qt.warn("Failed to sync pending permissions",{instanceId:e,error:c}),t)throw c}}async function X8(e,t=!1,n=()=>!0){var o,a,i;const s=Fe().get(e);if(!(s!=null&&s.client))return;const r=Mo.get(e)??0;try{const c=Date.now(),l=[],d=XE(e,s.folder),u=new Set,f=await YE(d,n,async b=>{const v=await mw(e,k=>s.client.form.list({location:Io(b)},{...Zt(b),signal:k}));return{location:b,response:v}}),g=[];for(const b of f){if(b.status==="rejected"){g.push(b.reason);continue}const{location:v,response:k}=b.value,C={directory:k.location.directory||v.directory,workspaceID:bf(k.location)},_=sa(C);_&&(u.add(_),l.push(...k.data.map(T=>({form:T.sessionID==="global"?{...T,location:k.location}:T,location:C,key:_}))))}if(!n()||(Mo.get(e)??0)!==r){if(t)throw hw;return}const m=new Set(l.map(({form:b})=>b.id));g.length||n8(e,m,c);const w=l.filter(({form:b})=>!AE(e,b.id)),S=new Set(w.map(({form:b})=>b.id));for(const b of Zr(e)){const v=((o=pg.get(e))==null?void 0:o.get(b.id))??sa(b.location)??sa((i=(a=Ne().get(e))==null?void 0:a.get(b.sessionID))==null?void 0:i.location);!S.has(b.id)&&v&&u.has(v)&&Wl(e,b.id)}for(const{form:b,location:v}of w)bw(e,b,v);if(mr(e),g.length&&(qt.warn("Pending form scan was partial",{instanceId:e,failedLocations:g.length}),t))throw g[0]}catch(c){if(qt.warn("Failed to sync pending forms",{instanceId:e,error:c}),t)throw c}}async function e9(e,t,n){for(let s=0;s<3&&!n.cancelled;s+=1){const r=(Ud.get(e)??0)+1;Ud.set(e,r);const o=()=>!n.cancelled&&Ud.get(e)===r&&ll.get(e)===t;try{await Promise.all([Q8(e,!0,o),X8(e,!0,o)]);return}catch(a){if(a!==hw)throw a}}if(!n.cancelled&&ll.get(e)===t)throw new Error("Pending request sync did not stabilize")}function ql(e,t){const n=ll.get(e);if(n===void 0)return Promise.resolve();const s=nr.get(e);if((s==null?void 0:s.generation)===n)return t==null||t(()=>{var a;((a=nr.get(e))==null?void 0:a.token)===s.token&&(s.token.cancelled=!0,Wu(e),dl(e),nr.delete(e))}),s.promise;const r={cancelled:!1},o=e9(e,n,r).finally(()=>{var a;((a=nr.get(e))==null?void 0:a.promise)===o&&nr.delete(e)});return nr.set(e,{generation:n,token:r,promise:o}),t==null||t(()=>{var a;((a=nr.get(e))==null?void 0:a.token)===r&&(r.cancelled=!0,Wu(e),dl(e),nr.delete(e))}),o}function vg(e){const t=nr.get(e);t&&(t.token.cancelled=!0),Wu(e),nr.delete(e),dl(e),ql(e).catch(n=>{qt.warn("Failed to reconcile pending requests after an ambiguous mutation",{instanceId:e,error:n})})}async function t9(e){const t=Ne().get(e),n=Array.from((t==null?void 0:t.values())??[]).some(r=>r.status==="working"||r.status==="compacting");let s;if(n||Fo(e).length||Zr(e).length)try{await mw(e,r=>SC(e,r),!1)}catch(r){s=r}if(await ql(e),mr(e),s)throw s}function n9(e){const t=xc.get(e);if(t)return t;const n=t9(e).finally(()=>{xc.get(e)===n&&xc.delete(e)});return xc.set(e,n),n}function eT(e,t=!1){const n=t?wi(e):Xi(e),s=Promise.resolve().then(async()=>{const a=Fe().get(e);a!=null&&a.client&&await BE(a,{force:t}).catch(i=>{qt.warn("Failed to load project metadata before session hydration",{instanceId:e,error:i})})}),r=Promise.all([n,s]).then(()=>{});r.catch(a=>qt.warn("Failed to hydrate workspace metadata",{instanceId:e,error:a}));const o=Promise.resolve().then(async()=>{WC(e),await Ei(e,{projectMetadata:s}).catch(a=>{qt.error("Failed to hydrate sessions",{instanceId:e,error:a})})});return o.then(async()=>{const a=Fe().get(e);a!=null&&a.client&&await FE(a,{force:t,location:Nn(e)})}).catch(a=>qt.warn("Failed to load supplemental instance metadata",{instanceId:e,error:a})),{sessions:o,workspaceMetadata:r}}async function tT(e,t){try{const n=t!=null&&t.sessionHydration?{sessions:t.sessionHydration,workspaceMetadata:t.workspaceMetadataHydration??Promise.resolve()}:eT(e,t==null?void 0:t.force);await Promise.all([n.sessions,n.workspaceMetadata,Ma(e,t==null?void 0:t.force)]),await hM(e),await ql(e)}catch(n){if(qt.error("Failed to fetch initial data",n),t!=null&&t.propagateErrors)throw n}}function nT(e){mu(e),Dy(e),Ay(e),ww(e),pT(e)}async function yh(e,t){if(xd.has(e))return xd.get(e);const n=(async()=>{const s=Fe().get(e);s!=null&&s.client&&(qt.info("Rehydrating instance",{instanceId:e,reason:t==null?void 0:t.reason}),nT(e),await tT(e,{force:!0}))})().finally(()=>{xd.delete(e)});return xd.set(e,n),n}async function sT(){if(!Cp())return;const e=Er.begin(),t=new Set(Fe().keys());try{const n=await kt.fetchWorkspaces();if(!Er.isCurrent(e))return;const s=new Set(n.map(({id:o})=>o));for(const o of n)if(Er.allows(e,o.id)&&(mn.trackPendingRequest(o),!so.deferRefreshWorkspace(o))){if(mn.owns(o.id)){mn.track(o);continue}ra(o)}const r=[...t].filter(o=>Er.allows(e,o));for(const o of Y6(r,s,a=>mn.owns(a)))yw(o),wg(o,{authoritative:!1})}finally{Er.complete(e)}}const rT=async function(){try{return await sT(),{}}catch(t){return qt.error("Failed to load workspaces",t),{error:t}}}();let Gu=rT;const wp=new Set;function s9(e){Gu=e,wp.forEach(t=>t())}function r9(e,t){return Gu!==e?Promise.resolve():new Promise((n,s)=>{const r=()=>{wp.delete(o),t==null||t.removeEventListener("abort",a)},o=()=>{r(),n()},a=()=>{r(),s(t==null?void 0:t.reason)};wp.add(o),t==null||t.addEventListener("abort",a,{once:!0}),Gu!==e&&o()})}xs.onOpen(()=>{s9(sT().then(()=>({}),e=>(qt.warn("Failed to reconcile workspaces after event reconnect",e),{error:e})))});async function o9(e){await $8(rT,()=>Gu,r9,e)}xs.on("*",e=>i9(e));function i9(e){if(!Cp())return;const t=e.type==="workspace.log"?e.entry.workspaceId:"workspace"in e?e.workspace.id:"workspaceId"in e&&typeof e.workspaceId=="string"?e.workspaceId:null;if(t&&e.type!=="workspace.log"&&Er.markMutation(t),!("workspace"in e&&(mn.trackPendingRequest(e.workspace),so.deferWorkspace(e.workspace)))&&!(e.type==="workspace.stopped"&&so.deferStopped(e.workspaceId,e.reason))&&!(t&&mn.shouldIgnoreEvent(t)))switch(e.type){case"workspace.created":ra(e.workspace);break;case"workspace.started":ra(e.workspace);break;case"workspace.error":ra(e.workspace),f8(e.workspace),OE(e.workspace.id),hT(e.workspace.id);break;case"workspace.stopped":_8(e.workspaceId),mn.release(e.workspaceId),yw(e.workspaceId),wg(e.workspaceId,{authoritative:e.reason==="deleted"});break;case"workspace.log":a9(e.entry);break}}function a9(e){const t={timestamp:new Date(e.timestamp).getTime(),level:e.level??"info",message:e.message};uT(e.workspaceId,t)}function c9(e){hg(t=>{if(t.has(e))return t;const n=new Map(t);return n.set(e,[]),n})}function oT(e){ow(t=>{if(t.has(e))return t;const n=new Map(t);return n.set(e,!1),n})}function l9(e){hg(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),ow(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n})}function d9(e){return jE().get(e)??[]}function iT(e){return O8().get(e)??!1}function u9(e,t){oT(e),ow(n=>{const s=new Map(n);return s.set(e,t),s}),t||fT(e)}function aT(e){const t=Array.from(Fe().values()).filter(n=>Ao(n.folder)===Ao(e.folder)).length;ll.set(e.id,++j8),rw(n=>{const s=new Map(n);return s.set(e.id,e),s}),c9(e.id),oT(e.id),vp({type:"opened",instanceId:e.id,folder:e.folder,occurrence:t}),cw()}function fl(e,t){var s;const n=Fe().get(e);if(t.client!==void 0&&(n!=null&&n.client)&&t.client!==n.client){Ll(e),Gf(e),Dy(e),Ay(e),iw(e),$c.delete(e);for(const r of((s=Ne().get(e))==null?void 0:s.keys())??[])No(e,r)}rw(r=>{const o=new Map(r),a=o.get(e);return a&&o.set(e,{...a,...t}),o}),cw()}function wg(e,t={}){const n=Fe().get(e),s=n?Array.from(Fe().values()).filter(o=>Ao(o.folder)===Ao(n.folder)).findIndex(o=>o.id===e):-1;n&&s>=0&&t.authoritative===!1&&vp({type:"unavailable",instanceId:e,folder:n.folder,occurrence:s}),x8(e),JE.clear(e);let r=null;rw(o=>{if(!o.has(e))return o;const a=Array.from(o.keys()),i=a.indexOf(e),c=new Map(o);if(c.delete(e),Ds()===e)if(i>0)r=a[i-1]??null;else{const l=Array.from(c.keys());r=l.length>0?l[0]??null:null}return c}),l9(e),Dy(e),ww(e),t8(e),s8(e),pT(e),Ay(e),iw(e),OE(e),hT(e),uw.delete(e),fw.delete(e),gw.delete(e),dl(e),Wu(e),xc.delete(e),ll.delete(e),ul(e,new Error(`Workspace ${e} was removed before it became ready`)),Ds()===e&&VE(r),mu(e),Ht.unregisterInstance(e),tE(e),Ll(e),Gf(e),RL(e),QC(e),hE(e),aE(e),n&&s>=0&&t.authoritative!==!1&&vp({type:"removed",instanceId:e,folder:n.folder,occurrence:s}),cw()}function cT(e){Er.markMutation(e),Fe().has(e)&&(yw(e),wg(e,{authoritative:!1}))}function Kd(e){return e.reused!==!0&&cT(e.id),mn.discardCreated(e,{retainTombstone:e.reused!==!0})}async function lT(e,t){await mn.releaseAfter(e,()=>Dp(()=>kt.releaseWorkspaceCreation(e,t),{maxAttempts:4,initialDelayMs:250,maxDelayMs:2e3,backoffMultiplier:4}))}async function dT(e,t){await P8(t)}function f9(e){const t=mn.get(e);t!=null&&t.requestId&&lT(e,t.requestId).catch(n=>{qt.warn("Failed to transfer restore workspace creation ownership to the user",{instanceId:e,error:n})})}async function PS(e,t){if(t.status==="stopped"){mn.release(e.id),cT(e.id);return}await Kd(e)}async function g9(e,t,n){var l,d,u,f,g,m,w,S,b;const s=n!=null&&n.signal?H8():void 0;s&&mn.beginRequest(s);const r=s&&(n!=null&&n.waitForCreateCommit)?so.begin(s,n.waitForCreateCommit(),e):void 0;let o=null,a=!1,i=!1;const c=()=>{if(!s)return;const v=mn.quarantineRequest(s);o??(o=v?v.then(()=>!0):dT(void 0,s).then(()=>!0,k=>(qt.warn("Failed to cancel restore workspace creation",{requestId:s,error:k}),!1)))};(l=n==null?void 0:n.signal)==null||l.addEventListener("abort",c,{once:!0});try{if((d=n==null?void 0:n.signal)!=null&&d.aborted)throw na(n.signal);const v=await kt.createWorkspace({path:e,name:t,requestId:s},{signal:n==null?void 0:n.signal});a=!0;const k=v.reused===!0;if(s&&so.bindResponse(s,v.id),(u=n==null?void 0:n.signal)!=null&&u.aborted)throw v.requestId&&await Kd(v),na(n.signal);if(n!=null&&n.signal&&v.requestId){const I=s?so.resolve(s,v).workspace:v;mn.track({...I,requestId:I.requestId??v.requestId,...k?{reused:!0}:{}})}else n!=null&&n.signal||mn.releaseTombstoneForUserCreate(v.id);if(r&&await r.wait,(f=n==null?void 0:n.signal)!=null&&f.aborted)throw v.requestId&&await Kd(v),na(n.signal);const C=s?so.resolve(s,v):{workspace:v},_={...C.workspace,requestId:C.workspace.requestId??v.requestId,...k?{reused:!0}:{}};s&&mn.track(_);const T=C.terminal??(_.status==="error"||_.status==="stopped"?{status:_.status,message:_.error}:void 0);if(T)throw i=!0,await PS(_,T),new Error(T.message||`Restore-created workspace ${v.id} ${T.status}`);const P=mn.shouldIgnoreEvent(v.id)||((g=n==null?void 0:n.shouldCreateCommit)==null?void 0:g.call(n))===!1;if(P||(Er.markMutation(v.id),(m=n==null?void 0:n.onBeforeCreateCommit)==null||m.call(n,v.id),ra(_,k?void 0:t),(w=n==null?void 0:n.onCreateCommit)==null||w.call(n,v.id)),P)throw v.requestId&&await Kd(v),new Error(`Restore-created workspace ${v.id} was closed before startup completed`);return{instanceId:v.id,reused:k,requestId:v.requestId}}catch(v){throw!i&&(r!=null&&r.terminal)&&r.workspace&&(i=!0,await PS(r.workspace,r.terminal)),(S=n==null?void 0:n.signal)!=null&&S.aborted||qt.error("Failed to create workspace",v),v}finally{if((b=n==null?void 0:n.signal)==null||b.removeEventListener("abort",c),s){so.end(s);const v=o;a||!v?mn.finishRequest(s):v.then(k=>{k&&mn.finishRequest(s)})}}}function Ao(e){const t=e.replace(/[\\/]+$/,"");return/^(?:[A-Za-z]:[\\/]|[\\/]{2})/.test(t)?t.replace(/\\/g,"/").toLowerCase():t}function h9(e){if(!e)return null;const t=Ao(e),n=Array.from(Fe().values()).filter(r=>r.status==="stopped"?!1:Ao(r.folder)===t);if(n.length===0)return null;const s=Ds();return n.find(r=>r.id===s)??n.find(r=>r.status==="ready")??n[0]??null}function m9(e,t){const n=t.trim();if(!e||!n)return;const s=Ao(e);for(const r of Fe().values())r.status!=="stopped"&&Ao(r.folder)===s&&fl(r.id,{projectName:n})}const vh=new Map;function p9(e){if(!Fe().get(e))return Promise.resolve();const n=vh.get(e);if(n)return n;const s=kt.deleteWorkspace(e).catch(r=>{qt.error("Failed to stop workspace",r);try{Hn({message:$e("app.stopInstance.toast.error"),variant:"error"})}finally{throw r}}).finally(()=>{vh.delete(e)});return vh.set(e,s),s}function y9(){const e=Ds();return e&&Fe().get(e)||null}function uT(e,t){iT(e)&&hg(n=>{const s=new Map(n),r=s.get(e)??[],o=r.length>=V8?[...r.slice(1),t]:[...r,t];return s.set(e,o),s})}function fT(e){hg(t=>{if(!t.has(e))return t;const n=new Map(t);return n.set(e,[]),n})}function Fo(e){const t=zE().get(e);return t||[]}function v9(e){return Fo(e).length}function w9(e,t){const s=Fo(e).find(r=>r.id===t);return s?Wn.ensureEnqueuedAt(s):Wn.enqueuedAtFor(t)}function b9(e){const t=Fo(e),n=Zr(e),s=[];t[0]&&s.push({kind:"permission",id:t[0].id,enqueuedAt:Wn.ensureEnqueuedAt(t[0])}),n[0]&&s.push({kind:"form",id:n[0].id,enqueuedAt:ho.ensureEnqueuedAt(n[0])}),s.sort((o,a)=>o.enqueuedAt-a.enqueuedAt);const r=s[0];return r?{kind:r.kind,id:r.id}:null}function S9(e,t){K8(n=>{const s=new Map(n);return t?s.set(e,t):s.set(e,null),s}),WE(n=>{const s=new Map(n);return(t==null?void 0:t.kind)==="permission"?s.set(e,t.id):s.set(e,null),s})}function nc(e){S9(e,b9(e))}function vw(e,t,n){Us(Fa,e),HE(mg,e,t.id,n);let s=!1,r=!1,o,a=t;if(aw(l=>{const d=new Map(l),u=d.get(e)??[],f=u.findIndex(m=>m.id===t.id);if(f!==-1){o=u[f],a=Xx(o,t);const m=u.slice();return m[f]=a,d.set(e,m.sort((w,S)=>Wn.ensureEnqueuedAt(w)-Wn.ensureEnqueuedAt(S))),r=!0,d}Wn.ensureEnqueuedAt(a);const g=[...u,a].sort((m,w)=>Wn.ensureEnqueuedAt(m)-Wn.ensureEnqueuedAt(w));return d.set(e,g),s=!0,d}),!s&&!r)return;nc(e);const i=o?ua(o):void 0,c=ua(a);if(i&&i!==c){const l=Wn.decrement(e,i);ju(e,i,l>0)}return c&&((s||i!==c)&&Wn.increment(e,c),ju(e,c,!0)),a}function zl(e,t){Us(Fa,e),GE(mg,e,t);let n=null;aw(r=>{const o=new Map(r),a=o.get(e)??[],i=[];for(const c of a){if(c.id===t){n=c;continue}i.push(c)}return i.length>0?o.set(e,i):o.delete(e),o}),nc(e),Wn.remove(e,t);const s=n;if(s){const r=ua(s);if(r){const o=Wn.decrement(e,r);ju(e,r,o>0)}}}function k9(e,t){const n=RE(e,t);a8(e,t),kt.toggleYolo(e,t).then(s=>{cl(e,t,s.enabled)}).catch(s=>{qt.warn("Failed to toggle Yolo on server",{instanceId:e,sessionId:t,error:s}),cl(e,t,n)})}const oa=new Set;function gT(e,t){if(!e||!t||t==="info")return;const n=`${e}:${t}`;oa.has(n)||(oa.add(n),kt.getYoloState(e,t).then(s=>{cl(e,t,s.enabled)}).catch(s=>{oa.delete(n),qt.warn("Failed to sync Yolo state",{instanceId:e,sessionId:t,error:s})}))}xs.onOpen(()=>{oa.clear()});function hT(e){const t=`${e}:`;for(const n of Array.from(oa))n.startsWith(t)&&oa.delete(n)}function ww(e){Us(Fa,e),mg.delete(e),Wn.clear(e,Fo(e),t=>{ju(e,t,!1)}),aw(t=>{const n=new Map(t);return n.delete(e),n}),WE(t=>{const n=new Map(t);return n.delete(e),n}),nc(e)}async function x9(e,t,n,s,r){const o=Fe().get(e);if(!(o!=null&&o.client))throw new Error("Instance not ready");try{const a=Fo(e).find(i=>i.id===n);if(!a)throw new Error(`Permission request not found: ${n}`);await $t(e).permission.reply({sessionID:a.sessionID,requestID:n,decision:s,...r?{message:r}:{}}),fg(e,n),zl(e,n),_f(e,n)}catch(a){throw qt.error("Failed to send permission response",a),vg(e),a}}async function _9(e,t,n){const s=Zr(e).find(r=>r.id===t);if(!s)throw new Error(`Form request not found: ${t}`);Us(Mo,e);try{await $t(e).session.form.reply({sessionID:s.sessionID,formID:s.id,answer:n},UE(s)),nw(e,s.id),Wl(e,s.id)}catch(r){throw vg(e),r}}let Vd;function mT(e){Vd=e}function bw(e,t,n){Us(Mo,e),HE(pg,e,t.id,n??t.location);const s=Zr(e).find(r=>r.id===t.id);if(p8(e,t),ho.ensureEnqueuedAt(t),s!=null&&s.sessionID&&s.sessionID!==t.sessionID){const r=ho.decrement(e,s.sessionID);qu(e,s.sessionID,r>0)}return(!s||s.sessionID!==t.sessionID)&&ho.increment(e,t.sessionID),qu(e,t.sessionID,!0),nc(e),s||Vd==null||Vd(e,t),s?void 0:t}function Wl(e,t){Us(Mo,e),GE(pg,e,t);const n=Zr(e).find(s=>s.id===t);if(y8(e,t),ho.remove(e,t),n){const s=ho.decrement(e,n.sessionID);qu(e,n.sessionID,s>0)}nc(e)}function pT(e){Us(Mo,e),pg.delete(e),ho.clear(e,Zr(e),t=>{qu(e,t,!1)}),w8(e),nc(e)}async function $9(e,t){const n=Zr(e).find(s=>s.id===t);if(!n)throw new Error(`Form request not found: ${t}`);Us(Mo,e);try{await $t(e).session.form.cancel({sessionID:n.sessionID,formID:n.id},UE(n)),nw(e,n.id),Wl(e,n.id)}catch(s){throw vg(e),s}}const C9=new Set(["session.step.ended","session.step.failed"]);function yT(e,t){var l,d,u,f;const n=Fe().get(e);if(!(n!=null&&n.client))return;const s="sessionID"in t.data&&typeof t.data.sessionID=="string"?t.data.sessionID:t.type==="form.created"?t.data.form.sessionID:void 0,r=t.type==="session.compaction.delta";t.type==="server.connected"&&iw(e),s&&(t.type==="session.compaction.ended"||t.type==="session.compaction.failed")&&F8(e,s);const o=(g,m=!0,w=!1)=>{var S;if(s&&t.type.startsWith("session.")&&es().get(e)!==s&&((S=ng().get(e))!=null&&S.has(s))&&No(e,s),r&&!w){s&&N8(e,s,()=>o(g,m,!0));return}s&&(w||t.type.startsWith("session."))&&es().get(e)===s&&K_(Ht.getOrCreate(e).getMessageWindow(s))&&(aj(e,s,g,m,w||t.type!=="session.inbox.enqueued"),(w||C9.has(t.type))&&wa(e,s))},a=(g,m=!0)=>{if(o(g,m),s&&t.type==="session.inbox.cancelled"&&R0(e,t.data.inboxID,s),s&&t.type==="session.revert.committed")for(const w of Ht.getOrCreate(e).getSessionMessageIds(s))w>=t.data.to&&R0(e,w,s)},i=oj(e,n.folder,t,a,g=>{o(g,!1,!0),vg(e)});if(a(i),s&&(t.type==="permission.asked"||t.type==="permission.replied")){const g=i.session.permission.list(s)??[],m=(t.type==="permission.asked"?[t.data,...g.filter(S=>S.id!==t.data.id)]:g).filter(S=>!gg(e,S.id)),w=t.location??((d=(l=Ne().get(e))==null?void 0:l.get(s))==null?void 0:d.location);for(const S of m){const b=vw(e,S,w)??S;L_(e,b)}t.type==="permission.replied"&&(zl(e,t.data.requestID),_f(e,t.data.requestID))}if(s&&t.type.startsWith("form.")){const g=i.session.form.list(s,s==="global"?t.location:void 0)??[],m=t.type==="form.created"?[t.data.form,...g.filter(S=>S.id!==t.data.form.id)]:g,w=t.location??((f=(u=Ne().get(e))==null?void 0:u.get(s))==null?void 0:f.location);for(const S of m)AE(e,S.id)||bw(e,S,w);(t.type==="form.replied"||t.type==="form.cancelled")&&(nw(e,t.data.id),Wl(e,t.data.id))}cj(e,t);const c=J6(t.type);c.length&&pw(e,c)}vn.onInvalidation=yT;vn.onConnectionLost=(e,t)=>{const n=Fe().get(e);n&&dw({id:e,folder:n.folder,reason:t})};vn.onInstanceDisposed=(e,t)=>{var r;const n=(r=t==null?void 0:t.properties)==null?void 0:r.directory;if(!n){yh(e,{reason:"disposed"});return}const s=[];for(const o of Fe().values())o.folder===n&&s.push(o.id);if(s.length===0){yh(e,{reason:"disposed"});return}for(const o of s)yh(o,{reason:"disposed"})};async function E9(){lw()&&dw(null)}const T9=Object.freeze(Object.defineProperty({__proto__:null,acknowledgeDisconnectedInstance:E9,activeInstanceId:Ds,activeInterruption:U8,activePermissionId:B8,addInstance:aT,addLog:uT,addPendingForm:bw,addPermissionToQueue:vw,cancelRestoreCreationRequest:dT,claimRestoreCreatedInstanceForUser:f9,clearLogs:fT,clearPermissionQueue:ww,clearReloadableInstanceState:nT,createInstance:g9,disconnectedInstance:lw,ensureYoloStateSynced:gT,getActiveInstance:y9,getExistingInstanceForFolder:h9,getInstanceLogs:d9,getPermissionEnqueuedAtForInstance:w9,getPermissionQueue:Fo,getPermissionQueueLength:v9,handleInstanceInvalidation:yT,hasRepliedPermission:gg,instanceLogs:jE,instances:Fe,invalidatePendingRequestSync:dl,isInstanceLogStreaming:iT,markPermissionReplied:fg,permissionQueues:zE,reconcilePendingRequestLiveness:n9,reconcilePendingSessionIndicators:mr,refreshVolatileInstanceState:pw,releaseRestoreCreatedInstance:lT,removeInstance:wg,removePendingForm:Wl,removePermissionFromQueue:zl,sendFormCancel:$9,sendFormReply:_9,sendPermissionResponse:x9,setActiveInstanceId:VE,setInstanceLogStreaming:u9,setPendingFormAddedHandler:mT,stopInstance:p9,syncLoadedSessionInboxes:QE,syncPendingRequests:ql,togglePermissionAutoAcceptForSession:k9,updateInstance:fl,updateProjectNameForFolder:m9,waitForInitialWorkspaceLoad:o9,waitForInstanceInitialSessionHydration:Y8,waitForInstanceReady:yg,waitForInstanceWorkspaceMetadataHydration:J8},Symbol.toStringTag,{value:"Module"}));async function M9(e,t="ui"){if(typeof window>"u")return!1;if($p())try{const{openUrl:n}=await ls(async()=>{const{openUrl:s}=await import("./index-cCIfI5Gs.js");return{openUrl:s}},__vite__mapDeps([9,6,2,3,4,5,1,7]));return await n(e),!0}catch(n){console.warn(`[${t}] unable to open via system opener`,n)}try{return window.open(e,"_blank","noopener,noreferrer")!==null}catch(n){return console.warn(`[${t}] unable to open external url`,n),!1}}function vT(e,t){return(e.type==="external"||!e.hidden)&&wT(e,t)}function wT(e,t){var n;return e.type==="external"||!((n=e.when)!=null&&n.length)?!0:e.when.every(s=>{const r=t[s.key];if(r===void 0)return!1;const o=Array.isArray(r)?r.includes(String(s.value)):r===s.value;return s.op==="eq"?o:!o})}function A9(e,t){return Object.fromEntries(e.flatMap(n=>{if(n.type==="external"||!wT(n,t))return[];const s=t[n.key]??(n.hidden?n.default:void 0);return s===void 0?[]:[[n.key,s]]}))}function bp(e){try{const t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}const wh={type:"key",label:""};function D9(e,t){if(!t)return!0;if(t==="uri")try{return new URL(e),!0}catch{return!1}return t==="email"?/^[^\s@]+@[^\s@]+$/.test(e):t==="date"?/^\d{4}-\d{2}-\d{2}$/.test(e)&&!Number.isNaN(Date.parse(`${e}T00:00:00Z`)):/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(e)&&!Number.isNaN(Date.parse(e))}function _d(e,t){var o,a;const n=e,s=n==null?void 0:n.error,r=((o=n==null?void 0:n.data)==null?void 0:o.message)??((a=s==null?void 0:s.data)==null?void 0:a.message)??(n==null?void 0:n.message)??(s==null?void 0:s.message);return typeof r=="string"&&r.trim().length>0?r:t}function IS(e){const t={};for(const n of e??[])n.type!=="external"&&n.default!==void 0&&(t[n.key]=n.default);return t}function RS(e,t){if(e)return A9(e,t)}function P9(e,t){if(e.type==="external")return!0;const n=t[e.key];if(n===void 0)return!e.required;if(e.type==="string"){if(typeof n!="string"||e.required&&n.trim().length===0||e.minLength!==void 0&&n.length<e.minLength||e.maxLength!==void 0&&n.length>e.maxLength||!D9(n,e.format)||e.options&&!e.custom&&!e.options.some(s=>s.value===n))return!1;if(e.pattern)try{if(!new RegExp(`^(?:${e.pattern})$`).test(n))return!1}catch{return!1}return!0}return e.type==="number"||e.type==="integer"?!(typeof n!="number"||!Number.isFinite(n)||e.type==="integer"&&!Number.isInteger(n)||typeof e.minimum=="number"&&n<e.minimum||typeof e.maximum=="number"&&n>e.maximum):e.type==="multiselect"?!(!Array.isArray(n)||n.some(s=>typeof s!="string")||e.required&&n.length===0||e.minItems!==void 0&&n.length<e.minItems||e.maxItems!==void 0&&n.length>e.maxItems||!e.custom&&n.some(s=>!e.options.some(r=>r.value===s))):typeof n=="boolean"}function I9(e){const t=e;return(t==null?void 0:t.name)==="AbortError"||(t==null?void 0:t.message)==="This operation was aborted"}var R9=O("<div class=providers-form-stack>"),O9=O("<label class=settings-form-label>"),OS=O("<span class=settings-toggle-caption>"),L9=O("<input class=providers-input>"),N9=O("<datalist>"),F9=O('<div class="flex-1 min-w-0">'),B9=O("<input type=number class=providers-input>"),LS=O("<label class=settings-checkbox-toggle><input type=checkbox><span>"),U9=O("<input type=text class=providers-input>"),K9=O("<div class=providers-multiselect>"),V9=O("<div class=providers-field>"),j9=O('<div class=providers-field><a target=_blank rel="noopener noreferrer"class="selector-button selector-button-secondary providers-oauth-link">'),q9=O("<option>"),z9=O("<span class=providers-select-hint>"),W9=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const H9=e=>{const{t}=Dt(),n=Te(()=>(e.fields??[]).filter(d=>vT(d,e.answer))),s=d=>d.title||d.key,r=d=>e.answer[d.key],o=d=>Array.isArray(r(d))?r(d):[],a=d=>d.type!=="string"?"text":d.format==="uri"?"url":d.format==="date-time"?"datetime-local":d.format??"text",i=d=>typeof d=="number"&&Number.isFinite(d)?d:void 0,c=(d,u,f)=>{const g=new Set(o(d));f?g.add(u):g.delete(u),e.onAnswer(d.key,[...g])},l=(d,u)=>{const f=new Set(d.options.map(w=>w.value)),g=o(d).filter(w=>f.has(w)),m=u.split(",").map(w=>w.trim()).filter(Boolean);e.onAnswer(d.key,[...g,...m])};return(()=>{var d=R9();return p(d,y(zt,{get each(){return n()},children:u=>y(ee,{get when(){return u.type!=="external"},get fallback(){return y(ee,{get when(){return Ee(()=>u.type==="external")()&&bp(u.url)},get children(){var f=j9(),g=f.firstChild;return p(g,y(Yi,{class:"w-4 h-4"}),null),p(g,()=>s(u),null),p(f,y(ee,{get when(){return u.description},get children(){var m=OS();return p(m,()=>u.description),m}}),null),de(()=>me(g,"href",u.type==="external"?u.url:void 0)),f}})},get children(){var f=V9();return p(f,y(ee,{get when(){return u.type!=="boolean"},get children(){var g=O9();return p(g,()=>s(u)),de(()=>me(g,"for",`provider-field-${u.key}`)),g}}),null),p(f,y(ee,{get when(){return u.description},get children(){var g=OS();return p(g,()=>u.description),g}}),null),p(f,y(ee,{get when(){return Ee(()=>u.type==="string")()&&(!u.options||u.custom)},get children(){return[(()=>{var g=L9();return g.$$input=m=>e.onAnswer(u.key,m.currentTarget.value),de(m=>{var w=`provider-field-${u.key}`,S=a(u),b=u.type==="string"?u.placeholder:void 0,v=u.type==="string"?u.required:void 0,k=u.type==="string"?u.minLength:void 0,C=u.type==="string"?u.maxLength:void 0,_=u.type==="string"?u.pattern:void 0,T=u.type==="string"&&u.options?`provider-options-${u.key}`:void 0,P=e.disabled;return w!==m.e&&me(g,"id",m.e=w),S!==m.t&&me(g,"type",m.t=S),b!==m.a&&me(g,"placeholder",m.a=b),v!==m.o&&(g.required=m.o=v),k!==m.i&&me(g,"minlength",m.i=k),C!==m.n&&me(g,"maxlength",m.n=C),_!==m.s&&me(g,"pattern",m.s=_),T!==m.h&&me(g,"list",m.h=T),P!==m.r&&(g.disabled=m.r=P),m},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),de(()=>g.value=typeof r(u)=="string"?r(u):""),g})(),y(ee,{get when(){return Ee(()=>u.type==="string")()&&u.options},get children(){var g=N9();return p(g,y(zt,{get each(){return Ee(()=>u.type==="string")()?u.options:[]},children:m=>(()=>{var w=q9();return p(w,()=>m.label),de(()=>w.value=m.value),w})()})),de(()=>me(g,"id",`provider-options-${u.key}`)),g}})]}}),null),p(f,y(ee,{get when(){return Ee(()=>!!(u.type==="string"&&u.options))()&&!u.custom},get children(){return y(De,{get value(){var g;return Ee(()=>u.type==="string")()?(g=u.options)==null?void 0:g.find(m=>m.value===r(u)):void 0},onChange:g=>e.onAnswer(u.key,g==null?void 0:g.value),get options(){return Ee(()=>u.type==="string")()?u.options??[]:[]},optionValue:"value",optionTextValue:"label",get disabled(){return e.disabled},itemComponent:g=>y(De.Item,{get item(){return g.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return[Ee(()=>g.item.rawValue.label),y(ee,{get when(){return g.item.rawValue.description},get children(){var m=z9();return p(m,()=>g.item.rawValue.description),m}})]}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger providers-prompt-trigger",get"aria-label"(){return s(u)},get children(){return[(()=>{var g=F9();return p(g,y(De.Value,{children:m=>(()=>{var w=W9();return p(w,()=>{var S;return((S=m.selectedOption())==null?void 0:S.label)??t("settings.providers.prompt.selectPlaceholder")}),w})()})),g})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})}}),null),p(f,y(ee,{get when(){return u.type==="number"||u.type==="integer"},get children(){var g=B9();return g.$$input=m=>e.onAnswer(u.key,m.currentTarget.value===""?void 0:m.currentTarget.valueAsNumber),de(m=>{var w=`provider-field-${u.key}`,S=u.type==="number"||u.type==="integer"?i(u.minimum):void 0,b=u.type==="number"||u.type==="integer"?i(u.maximum):void 0,v=u.type==="integer"?1:"any",k=u.type==="number"||u.type==="integer"?u.required:void 0,C=e.disabled;return w!==m.e&&me(g,"id",m.e=w),S!==m.t&&me(g,"min",m.t=S),b!==m.a&&me(g,"max",m.a=b),v!==m.o&&me(g,"step",m.o=v),k!==m.i&&(g.required=m.i=k),C!==m.n&&(g.disabled=m.n=C),m},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),de(()=>g.value=typeof r(u)=="number"?r(u):""),g}}),null),p(f,y(ee,{get when(){return u.type==="boolean"},get children(){var g=LS(),m=g.firstChild,w=m.nextSibling;return m.addEventListener("change",S=>e.onAnswer(u.key,S.currentTarget.checked)),p(w,()=>s(u)),de(()=>m.disabled=e.disabled),de(()=>m.checked=r(u)===!0),g}}),null),p(f,y(ee,{get when(){return u.type==="multiselect"},get children(){var g=K9();return p(g,y(zt,{get each(){return Ee(()=>u.type==="multiselect")()?u.options:[]},children:m=>(()=>{var w=LS(),S=w.firstChild,b=S.nextSibling;return S.addEventListener("change",v=>u.type==="multiselect"&&c(u,m.value,v.currentTarget.checked)),p(b,()=>m.label),de(()=>S.disabled=e.disabled),de(()=>S.checked=o(u).includes(m.value)),w})()}),null),p(g,y(ee,{get when(){return Ee(()=>u.type==="multiselect")()&&u.custom},get children(){var m=U9();return m.$$input=w=>u.type==="multiselect"&&l(u,w.currentTarget.value),de(w=>{var S=t("settings.providers.prompt.customValuesPlaceholder"),b=e.disabled;return S!==w.e&&me(m,"placeholder",w.e=S),b!==w.t&&(m.disabled=w.t=b),w},{e:void 0,t:void 0}),de(()=>m.value=u.type==="multiselect"?o(u).filter(w=>!u.options.some(S=>S.value===w)).join(", "):""),m}}),null),g}}),null),f}})})),d})()};Xt(["input"]);function G9(e,t,n){const s=new Set(t.filter(r=>(r.integrationID??r.id)===e).map(r=>r.id));return s.size===0&&s.add(e),n.filter(r=>s.has(r.providerID)).map(r=>({id:r.id,name:r.name||r.id,providerId:r.providerID}))}function Z9(e,t,n){const s=new Map;for(const i of t)s.set(i.providerID,(s.get(i.providerID)??0)+1);const r=new Set,o=n.map(i=>{const c=e.filter(d=>(d.integrationID??d.id)===i.id);for(const d of c)r.add(d.id);const l=i.connections.filter(d=>d.type==="credential").map(d=>d.id);return{id:i.id,name:i.name,modelCount:c.reduce((d,u)=>d+(s.get(u.id)??0),0),source:l.length>0?"api":i.connections.some(d=>d.type==="env")?"env":c.length>0?"config":"unknown",credentialIds:l,canConnect:i.methods.some(d=>d.type!=="env")}}),a=new Set(o.map(i=>i.id));for(const i of e)r.has(i.id)||a.has(i.id)||(o.push({id:i.id,name:i.name||i.id,modelCount:s.get(i.id)??0,source:"custom",credentialIds:[],canConnect:!1}),a.add(i.id));for(const[i,c]of s)r.has(i)||a.has(i)||o.push({id:i,name:i,modelCount:c,source:"unknown",credentialIds:[],canConnect:!1});return o}var Y9=O("<p class=settings-error-message role=alert>"),J9=O("<div class=provider-model-visibility-list role=list>"),Q9=O('<section class=provider-model-visibility aria-labelledby=provider-model-visibility-heading><header class=provider-model-visibility-header><button type=button class="selector-button selector-button-secondary"></button><div><h4 id=provider-model-visibility-heading class=settings-card-title></h4><p class=settings-card-subtitle></p></div></header><div class=provider-model-visibility-toolbar><label class=sr-only for=provider-model-visibility-search></label><input id=provider-model-visibility-search type=search class=providers-input><span class=provider-model-visibility-count role=status></span><button type=button class="selector-button selector-button-secondary"></button><button type=button class="selector-button selector-button-secondary">'),X9=O("<p class=settings-card-message role=status>"),ez=O("<label class=provider-model-visibility-item role=listitem><input type=checkbox><span><strong></strong><small dir=ltr>");const tz=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"})||e.id.localeCompare(t.id,void 0,{sensitivity:"base"}),nz=e=>{const{t}=Dt(),{getProviderModelVisibilityPreference:n,providerModelVisibilitySaveFailed:s,setProviderModelVisibility:r}=Un(),[o,a]=R("");let i;const c=Te(()=>[...e.models].sort(tz)),l=Te(()=>new Set(c().filter(m=>n(m.providerId).hiddenModelIds.includes(m.id)).map(m=>`${m.providerId}\0${m.id}`))),d=Te(()=>c().filter(m=>!l().has(`${m.providerId}\0${m.id}`)).length),u=Te(()=>{const m=o().trim().toLocaleLowerCase();return m?c().filter(w=>w.name.toLocaleLowerCase().includes(m)||w.id.toLocaleLowerCase().includes(m)):c()});Ze(yi(()=>e.providerId,()=>a(""))),Ys(()=>queueMicrotask(()=>i==null?void 0:i.focus()));const f=(m,w)=>{const S=n(m.providerId).hiddenModelIds;r(m.providerId,{hiddenModelIds:w?S.filter(b=>b!==m.id):[...S,m.id]}).catch(()=>{})},g=m=>{const w=new Map;for(const S of c())w.set(S.providerId,[...w.get(S.providerId)??[],S.id]);for(const[S,b]of w){const v=n(S).hiddenModelIds,k=m?v.filter(C=>!b.includes(C)):Array.from(new Set([...v,...b]));r(S,{hiddenModelIds:k}).catch(()=>{})}};return(()=>{var m=Q9(),w=m.firstChild,S=w.firstChild,b=S.nextSibling,v=b.firstChild,k=v.nextSibling,C=w.nextSibling,_=C.firstChild,T=_.nextSibling,P=T.nextSibling,I=P.nextSibling,j=I.nextSibling;lk(S,"click",e.onBack,!0),p(S,y(Yk,{class:"w-4 h-4"}),null),p(S,()=>t("settings.providers.modelVisibility.back"),null),p(v,()=>t("settings.providers.modelVisibility.title",{provider:e.providerName})),p(k,()=>t("settings.providers.modelVisibility.subtitle")),p(_,()=>t("settings.providers.modelVisibility.search.label")),T.$$input=W=>a(W.currentTarget.value);var ne=i;return typeof ne=="function"?dr(ne,T):i=T,p(P,()=>t("settings.providers.modelVisibility.count.visible",{visible:d(),total:c().length})),I.$$click=()=>g(!0),p(I,()=>t("settings.providers.modelVisibility.actions.showAll")),j.$$click=()=>g(!1),p(j,()=>t("settings.providers.modelVisibility.actions.hideAll")),p(m,y(ee,{get when(){return c().some(W=>s(W.providerId))},get children(){var W=Y9();return p(W,()=>t("settings.providers.modelVisibility.save.failed")),W}}),null),p(m,y(ee,{get when(){return u().length>0},get fallback(){return(()=>{var W=X9();return p(W,()=>t("settings.providers.modelVisibility.list.empty")),W})()},get children(){var W=J9();return p(W,y(zt,{get each(){return u()},children:q=>(()=>{var U=ez(),G=U.firstChild,le=G.nextSibling,K=le.firstChild,M=K.nextSibling;return G.addEventListener("change",N=>f(q,N.currentTarget.checked)),p(K,()=>q.name||q.id),p(M,()=>q.id),de(()=>G.checked=!l().has(`${q.providerId}\0${q.id}`)),U})()})),de(()=>me(W,"aria-label",t("settings.providers.modelVisibility.list.label",{provider:e.providerName}))),W}}),null),de(()=>me(T,"placeholder",t("settings.providers.modelVisibility.search.placeholder"))),de(()=>T.value=o()),m})()};Xt(["click","input"]);var sz=O('<div class=providers-manager-header><div class=settings-card-heading-with-icon><div><p class=settings-card-subtitle></p></div></div><button type=button class="selector-button selector-button-secondary settings-screen-close">'),bh=O("<div class=settings-card-message role=status>"),NS=O('<div class="flex-1 min-w-0">'),rz=O('<div class=providers-connect-bar><button type=button class="selector-button selector-button-primary"></button><button type=button class=settings-pill-button>'),FS=O("<div class=settings-error-message role=alert>"),oz=O('<div class="settings-toggle-row settings-toggle-row-compact providers-method-row"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>'),iz=O("<div class=providers-form-stack><label class=providers-field><span class=settings-form-label></span><div class=providers-input-wrap><input type=password class=providers-input autocomplete=off>"),az=O("<div class=providers-form-stack><div class=settings-card-message role=status></div><div class=providers-command-preview dir=ltr>"),cz=O("<div class=providers-form-stack><div class=providers-oauth-instructions><span></span></div><label class=providers-field><span class=settings-form-label></span><input type=text class=providers-input autocomplete=one-time-code>"),lz=O('<div class=providers-waiting-card role=status><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><button type=button class="selector-button selector-button-secondary providers-wait-cancel">'),dz=O('<div class=providers-oauth-actions><a target=_blank rel="noopener noreferrer"class="selector-button selector-button-secondary providers-oauth-link"></a><button type=button class="selector-button selector-button-secondary"></button><button type=button class="selector-button selector-button-secondary">'),uz=O("<div class=settings-card-message role=alert>"),fz=O("<div class=providers-success-card role=status><span>"),BS=O('<button type=button class="selector-button selector-button-primary">'),gz=O('<section class=providers-connect-panel><div class=providers-panel-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><button type=button class="selector-button selector-button-secondary settings-screen-close"></button></div><div class=providers-actions-row>'),hz=O("<section class=providers-list-section><h3 class=settings-card-title>"),mz=O("<div class=providers-manager-body>"),pz=O("<div class=selector-option-content><div class=selector-option-description><span dir=ltr></span><span> • </span><span></span><span> • </span><span>"),yz=O("<span class=selector-trigger-secondary dir=ltr> • "),vz=O('<div class="selector-trigger-label selector-trigger-label--stacked flex-1 min-w-0"><span class="selector-trigger-primary selector-trigger-primary--align-left">'),wz=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">'),bz=O("<div class=providers-loading-row role=status><span>"),Sz=O("<div class=providers-grid>"),kz=O("<bdi dir=ltr>"),xz=O("<span aria-hidden=true> • "),_z=O('<button type=button class="selector-button selector-button-secondary providers-disconnect-button">'),$z=O('<article class="providers-card settings-toggle-row settings-toggle-row-compact"><div class=providers-card-copy><h4 class=providers-card-title></h4><p class=providers-card-meta></p></div><div class=provider-model-card-actions><button type=button class="selector-button selector-button-secondary">'),Cz=O('<div class="providers-manager-modal providers-manager-embedded">');const Ez=e=>{const{t}=Dt(),[n,s]=R({}),[r,o]=R([]),[a,i]=R(null),[c,l]=R(null),[d,u]=R(null),f=new Map;let g=null;const[m,w]=R(0),[S,b]=R(""),[v,k]=R({}),[C,_]=R(null),[T,P]=R(null),[I,j]=R(null),[ne,W]=R(""),[q,U]=R("idle"),[G,le]=R(!1),[K,M]=R(null),[N,oe]=R(null),[ge,Ie]=R(!1),[ke,we]=R(!1);let Ae=null,Ge=null,H=0,h=0,$=null,D=null,E=null,Z=null,B;const se=Te(()=>Fe().get(e.instanceId)??null),pe=Te(()=>{if(e.instanceId&&e.location)return $t(e.instanceId);const J=se();return(J==null?void 0:J.status)==="ready"?J.client??null:null}),Se=()=>e.location?{...e.location}:{...Nn(e.instanceId)},Q=J=>Io(J),be=J=>{const ie=Se();return Bs(ie)===Bs(J)},Ve=Te(()=>{const J=new Map;for(const ie of r())J.set(ie.id,ie.name||ie.id);return J}),He=Te(()=>r().sort((J,ie)=>J.id.localeCompare(ie.id,void 0,{sensitivity:"base"})).map(J=>({id:J.id,name:Ve().get(J.id)??J.id,modelCount:J.modelCount,connectionSummary:zn(J.id),canConnect:J.canConnect}))),re=Te(()=>r().filter(J=>J.source!=="unknown")),F=Te(()=>re().find(J=>J.id===d())??null),V=J=>J.source==="env"?"not-disconnectable":J.credentialIds.length>0?"credential-remove":"unknown",Me=J=>{const ie=V(J);return J.source==="config"?t("settings.providers.source.config"):ie==="not-disconnectable"?t("settings.providers.source.env"):J.source==="api"?t("settings.providers.source.api"):J.source==="custom"?t("settings.providers.source.custom"):t("settings.providers.source.unknown")},xe=Te(()=>He().find(J=>J.id===a())??He()[0]??null),Re=Te(()=>{const J=c();return J?Ve().get(J)??J:""}),Be=Te(()=>{const J=c();if(!J)return[wh];const ie=n()[J];return ie&&ie.length>0?ie:[wh]}),et=Te(()=>Be().map((J,ie)=>({value:String(ie),label:J.label||(J.type==="oauth"?t("settings.providers.method.oauth"):J.type==="command"?t("settings.providers.method.command"):t("settings.providers.method.api")),method:J,index:ie}))),Ue=Te(()=>et().find(J=>J.index===m())??et()[0]),We=Te(()=>{var J;return((J=Ue())==null?void 0:J.method)??wh}),st=Te(()=>{const J=We();return J.type==="command"?void 0:J.form}),at=Te(()=>{const J=We();return J.type==="command"?J:void 0}),ht=Te(()=>{if(!c()||q()==="authorizing"||q()==="waiting"||q()==="success")return!1;const J=We();return J.type==="key"&&S().trim().length===0?!1:(J.type==="command"?[]:J.form??[]).filter(ie=>vT(ie,v())).every(ie=>P9(ie,v()))});function ut(J){var ie;J||L(null),(ie=e.onOpenChange)==null||ie.call(e,J)}function Ct(){return!$p()&&typeof window<"u"}function Qe(){if(!Ct())return null;let J=null;try{return J=window.open("","_blank"),J&&J.document&&(J.opener=null,J.document.title=t("settings.providers.oauth.popup.loadingTitle"),J.document.body.innerHTML=`<div style="font-family: sans-serif; padding: 24px; color: #111;">${t("settings.providers.oauth.popup.loadingBody")}</div>`),J}catch{return J==null||J.close(),null}}async function tt(J,ie){if(!bp(J))return ie!=null&&ie.popup&&!ie.popup.closed&&ie.popup.close(),!1;if(ie!=null&&ie.sameTab&&typeof window<"u")return window.location.assign(J),!0;const Oe=ie==null?void 0:ie.popup;if(Oe&&!Oe.closed)try{return Oe.location.href=J,!0}catch{}return await M9(J,"provider-auth")}async function At(){var ie,Oe;const J=(ie=C())==null?void 0:ie.url;if(!(!J||typeof navigator>"u"||!((Oe=navigator.clipboard)!=null&&Oe.writeText)))try{await navigator.clipboard.writeText(J),we(!0),setTimeout(()=>we(!1),1500)}catch{we(!1)}}Ze(()=>{const J=++H;if(!e.embedded&&!e.open){D=null,E=null,Z=null,A();return}const ie=e.instanceId,Oe=pe();if(!Oe){D=null,E=null,Z=null,A();return}const Le=Se(),Ce=Bs(Le);D===ie&&E===Oe&&Z===Ce||(A(),D=ie,E=Oe,Z=Ce,xt(Oe,J,Le))}),Ze(()=>{q()==="code"&&queueMicrotask(()=>B==null?void 0:B.focus())}),dt(()=>{H+=1,x()});async function xt(J,ie,Oe){const Le=()=>ie===H&&pe()===J&&be(Oe);le(!0),M(null);try{const Ce={location:Q(Oe)},[ft,bt,mt]=await Promise.all([J.provider.list(Ce,Zt(Oe)),J.model.list(Ce,Zt(Oe)),J.integration.list(Ce,Zt(Oe))]);if(!Le())return;const qe=Z9(ft.data,bt.data,mt.data).map(it=>({...it,models:G9(it.id,ft.data,bt.data)})),yt=Object.fromEntries(mt.data.map(it=>[it.id,it.methods.filter(ye=>ye.type!=="env")]));o(qe),s(yt),i(it=>{var ye,Ye;return it??((ye=qe[0])==null?void 0:ye.id)??((Ye=mt.data[0])==null?void 0:Ye.id)??null})}catch(Ce){if(!Le())return;M(_d(Ce,t("settings.providers.errors.loadFailed")))}finally{Le()&&le(!1)}}function x(){h+=1,$=null,Ae==null||Ae.abort(),Ae=null,Ge&&!Ge.closed&&Ge.close(),Ge=null}function A(){L(null),s({}),o([]),i(null),u(null),M(null),le(!1)}function L(J=null){var Oe,Le;if(J&&!((Oe=n()[J])!=null&&Oe.length))return;x(),l(J),w(0),b("");const ie=J?(Le=n()[J])==null?void 0:Le[0]:void 0;k(IS((ie==null?void 0:ie.type)==="command"||ie==null?void 0:ie.form)),_(null),P(null),j(null),W(""),U(J?"prompts":"idle"),oe(null),Ie(!1),we(!1)}function X(J,ie){k(Oe=>{const Le={...Oe};return ie===void 0?delete Le[J]:Le[J]=ie,Le})}function Y(J,ie,Oe){return J===h&&e.instanceId===ie&&pe()===Oe}async function ue(J,ie,Oe,Le){Y(Oe,ie,J)&&(e.location||await Da(ie,Le,!0).catch(()=>{}),Y(Oe,ie,J)&&await xt(J,++H,Se()).catch(()=>{}))}async function ce(){const J=pe(),ie=e.instanceId;if(!J)return;const Oe=Se();le(!0),e.location||await Da(ie,Oe,!0).catch(()=>{}),!(pe()!==J||e.instanceId!==ie)&&await xt(J,++H,Oe)}function ve(){u(null),queueMicrotask(()=>{var J;g&&((J=f.get(g))==null||J.focus())})}async function je(J,ie,Oe,Le,Ce){await ie.integration.connect.key({integrationID:J,key:S().trim(),answer:RS(st(),v()),location:Q(Ce)},Zt(Ce)),Y(Le,Oe,ie)&&(await ue(ie,Oe,Le,Ce),Y(Le,Oe,ie)&&L(null))}async function Ke(J,ie,Oe,Le,Ce){const ft=We();if(ft.type!=="oauth")throw new Error(t("settings.providers.errors.noAuthorization"));const bt=await ie.integration.oauth.connect({integrationID:J,methodID:ft.id,answer:RS(st(),v()),location:Q(Ce)},Zt(Ce));if(!Y(Le,Oe,ie))return;const mt=bt.data;if(!mt)throw new Error(t("settings.providers.errors.noAuthorization"));const qe={attemptID:mt.attemptID,url:mt.url,instructions:mt.instructions,method:mt.mode};_(qe);const yt=await tt(mt.url,{popup:Ge});if(Y(Le,Oe,ie)){if(Ge=null,Ie(!yt),mt.mode==="code"){U("code");return}for(U("waiting"),Ae=new AbortController;;){const it=await ie.integration.oauth.status({integrationID:J,attemptID:mt.attemptID,location:Q(Ce)},{...Zt(Ce),signal:Ae.signal});if(it.data.status==="complete")break;if(it.data.status==="failed")throw new Error(it.data.message);if(it.data.status==="expired")throw new Error(t("settings.providers.errors.authorizationFailed"));await new Promise(ye=>setTimeout(ye,1e3))}Y(Le,Oe,ie)&&(Ae=null,await ue(ie,Oe,Le,Ce),Y(Le,Oe,ie)&&L(null))}}async function rt(J,ie,Oe,Le,Ce){const ft=We();if(ft.type!=="command")throw new Error(t("settings.providers.errors.noAuthorization"));const bt=await ie.integration.command.connect({integrationID:J,methodID:ft.id,location:Q(Ce)},Zt(Ce));if(!Y(Le,Oe,ie))return;const mt=bt.data.attemptID;for(P(mt),j(null),U("waiting"),Ae=new AbortController;;){const qe=await ie.integration.command.status({integrationID:J,attemptID:mt,location:Q(Ce)},{...Zt(Ce),signal:Ae.signal});if(qe.data.status==="complete")break;if(qe.data.status==="failed")throw new Error(qe.data.message);if(qe.data.status==="expired")throw new Error(t("settings.providers.errors.authorizationFailed"));j(qe.data.message??null),await new Promise(yt=>setTimeout(yt,1e3))}Y(Le,Oe,ie)&&(Ae=null,await ue(ie,Oe,Le,Ce),Y(Le,Oe,ie)&&L(null))}async function ot(){const J=c(),ie=pe();if(!J||!ie||!ht())return;const Oe=e.instanceId,Le=Se(),Ce=++h;$=Le,U("authorizing"),oe(null);try{if(We().type==="key"){await je(J,ie,Oe,Ce,Le);return}if(We().type==="command"){await rt(J,ie,Oe,Ce,Le);return}Ge=Qe(),Ie(Ct()&&Ge===null),await Ke(J,ie,Oe,Ce,Le)}catch(ft){if(!Y(Ce,Oe,ie))return;if(Ge&&!Ge.closed&&Ge.close(),Ge=null,I9(ft)){U("prompts");return}oe(_d(ft,t("settings.providers.errors.authorizationFailed"))),U("error")}}async function Pt(){var ft;const J=c(),ie=pe();if(!J||!ie||!ne().trim())return;const Oe=e.instanceId,Le=$;if(!Le)return;const Ce=++h;U("authorizing"),oe(null);try{const bt=(ft=C())==null?void 0:ft.attemptID;if(!bt)throw new Error(t("settings.providers.errors.noAuthorization"));if(await ie.integration.oauth.complete({integrationID:J,attemptID:bt,code:ne().trim(),location:Q(Le)},Zt(Le)),!Y(Ce,Oe,ie))return;await ue(ie,Oe,Ce,Le),Y(Ce,Oe,ie)&&L(null)}catch(bt){if(!Y(Ce,Oe,ie))return;oe(_d(bt,t("settings.providers.errors.authorizationFailed"))),U("code")}}async function In(J){const ie=pe(),Oe=r().find(bt=>bt.id===J);if(!ie||!Oe)return;const Le=e.instanceId,Ce=Se();x();const ft=++h;oe(null),U("authorizing");try{const bt=V(Oe);if(bt==="not-disconnectable"){oe(t("settings.providers.errors.envDisconnectUnavailable")),U("error");return}if(bt!=="credential-remove"||(await Promise.all(Oe.credentialIds.map(mt=>ie.credential.remove({credentialID:mt},Zt(Ce,{includeDirectory:!0})))),!Y(ft,Le,ie)))return;await ue(ie,Le,ft,Ce),Y(ft,Le,ie)&&L(null)}catch(bt){if(!Y(ft,Le,ie))return;oe(_d(bt,t("settings.providers.errors.removeFailed"))),U("idle")}}function wn(){var ft;const J=c(),ie=(ft=C())==null?void 0:ft.attemptID,Oe=T(),Le=pe();e.instanceId;const Ce=$;J&&ie&&Le&&Ce&&Le.integration.oauth.cancel({integrationID:J,attemptID:ie,location:Q(Ce)},Zt(Ce)).catch(()=>{}),J&&Oe&&Le&&Ce&&Le.integration.command.cancel({integrationID:J,attemptID:Oe,location:Q(Ce)},Zt(Ce)).catch(()=>{}),x(),U("prompts"),_(null),P(null),j(null),oe(null)}function zn(J){var Le;const ie=n()[J];if(!ie||ie.length===0){const Ce=((Le=r().find(ft=>ft.id===J))==null?void 0:Le.source)??"unknown";return t(`settings.providers.source.${Ce}`)}const Oe=new Set(ie.map(Ce=>Ce.type));return Oe.size>1?t("settings.providers.method.mixed"):Oe.has("oauth")?t("settings.providers.method.oauth"):Oe.has("command")?t("settings.providers.method.command"):t("settings.providers.method.api")}function Et(J){const ie=J.modelCount===1?t("settings.providers.models.one",{count:J.modelCount}):t("settings.providers.models.other",{count:J.modelCount});return[...new Set([zn(J.id),Me(J),ie].filter(Boolean))].join(" • ")}const tn=()=>[y(ee,{get when(){return!e.embedded},get children(){var J=sz(),ie=J.firstChild,Oe=ie.firstChild,Le=Oe.firstChild,Ce=ie.nextSibling;return p(ie,y(ex,{class:"settings-card-heading-icon"}),Oe),p(Oe,y(Ot.Title,{class:"providers-manager-title",get children(){return t("settings.providers.title")}}),Le),p(Le,()=>t("settings.providers.subtitle")),Ce.$$click=()=>ut(!1),p(Ce,y(ti,{class:"w-4 h-4"})),de(()=>me(Ce,"aria-label",t("settings.close"))),J}}),(()=>{var J=mz();return p(J,y(ee,{get when(){return!pe()},get children(){var ie=bh();return p(ie,()=>t("settings.providers.empty.noInstance")),ie}}),null),p(J,y(ee,{get when(){return pe()},get children(){return[(()=>{var ie=rz(),Oe=ie.firstChild,Le=Oe.nextSibling;return p(ie,y(De,{get value(){return xe()},onChange:Ce=>Ce&&i(Ce.id),get options(){return He()},optionValue:"id",optionTextValue:"name",itemComponent:Ce=>y(De.Item,{get item(){return Ce.item},class:"selector-option selector-option--multiline",get children(){var ft=pz(),bt=ft.firstChild,mt=bt.firstChild,qe=mt.nextSibling,yt=qe.nextSibling,it=yt.nextSibling,ye=it.nextSibling;return p(ft,y(De.ItemLabel,{class:"selector-option-label",get children(){return Ce.item.rawValue.name}}),bt),p(mt,()=>Ce.item.rawValue.id),p(yt,(()=>{var Ye=Ee(()=>Ce.item.rawValue.modelCount===1);return()=>Ye()?t("settings.providers.models.one",{count:Ce.item.rawValue.modelCount}):t("settings.providers.models.other",{count:Ce.item.rawValue.modelCount})})()),p(ye,()=>Ce.item.rawValue.connectionSummary),ft}}),get children(){return[y(De.Trigger,{class:"selector-trigger providers-connect-select",get"aria-label"(){return t("settings.providers.selectProvider")},get children(){return[(()=>{var Ce=NS();return p(Ce,y(De.Value,{children:ft=>(()=>{var bt=vz(),mt=bt.firstChild;return p(mt,()=>{var qe;return((qe=ft.selectedOption())==null?void 0:qe.name)??t("settings.providers.selectProvider")}),p(bt,y(ee,{get when(){return ft.selectedOption()},get children(){var qe=yz(),yt=qe.firstChild;return p(qe,()=>{var it;return(it=ft.selectedOption())==null?void 0:it.id},yt),p(qe,()=>{var it;return(it=ft.selectedOption())==null?void 0:it.connectionSummary},null),qe}}),null),bt})()})),Ce})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),Oe),Oe.$$click=()=>{var Ce;return L(((Ce=xe())==null?void 0:Ce.id)??null)},p(Oe,()=>t("settings.providers.actions.connect")),Le.$$click=()=>void ce(),p(Le,y(Gd,{get class(){return G()?"providers-spin-icon":"providers-button-icon"}}),null),p(Le,()=>t("settings.providers.refresh"),null),de(Ce=>{var mt;var ft=!((mt=xe())!=null&&mt.canConnect),bt=G();return ft!==Ce.e&&(Oe.disabled=Ce.e=ft),bt!==Ce.t&&(Le.disabled=Ce.t=bt),Ce},{e:void 0,t:void 0}),ie})(),y(ee,{get when(){return K()},get children(){var ie=FS();return p(ie,K),ie}}),y(ee,{get when(){return N()},get children(){var ie=FS();return p(ie,N),ie}}),y(ee,{get when(){return c()},get children(){var ie=gz(),Oe=ie.firstChild,Le=Oe.firstChild,Ce=Le.firstChild,ft=Ce.nextSibling,bt=Le.nextSibling,mt=Oe.nextSibling;return p(Ce,()=>t("settings.providers.auth.title",{provider:Re()})),p(ft,()=>t("settings.providers.auth.subtitle")),bt.$$click=()=>L(null),p(bt,y(ti,{class:"w-4 h-4"})),p(ie,y(ee,{get when(){return et().length>1},get children(){var qe=oz(),yt=qe.firstChild,it=yt.firstChild,ye=it.nextSibling;return p(it,()=>t("settings.providers.method.title")),p(ye,()=>t("settings.providers.method.subtitle")),p(qe,y(De,{get value(){return Ue()},onChange:Ye=>{Ye&&(w(Ye.index),k(IS(Ye.method.type==="command"?void 0:Ye.method.form)),b(""),_(null),W(""),U("prompts"),oe(null))},get options(){return et()},optionValue:"value",optionTextValue:"label",get disabled(){return Ee(()=>q()!=="prompts")()&&q()!=="error"},itemComponent:Ye=>y(De.Item,{get item(){return Ye.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return Ye.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger providers-method-trigger",get"aria-label"(){return t("settings.providers.method.title")},get children(){return[(()=>{var Ye=NS();return p(Ye,y(De.Value,{children:ct=>(()=>{var fn=wz();return p(fn,()=>{var Ai;return(Ai=ct.selectedOption())==null?void 0:Ai.label}),fn})()})),Ye})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),null),qe}}),mt),p(ie,y(ee,{get when(){return We().type==="key"},get children(){var qe=iz(),yt=qe.firstChild,it=yt.firstChild,ye=it.nextSibling,Ye=ye.firstChild;return p(it,()=>t("settings.providers.apiKey.label")),p(ye,y(yD,{class:"providers-input-icon"}),Ye),Ye.$$input=ct=>b(ct.currentTarget.value),de(()=>me(Ye,"placeholder",t("settings.providers.apiKey.placeholder"))),de(()=>Ye.value=S()),qe}}),mt),p(ie,y(ee,{get when(){return st()},get children(){return y(H9,{get fields(){return st()},get answer(){return v()},get disabled(){return Ee(()=>q()!=="prompts")()&&q()!=="error"},onAnswer:X})}}),mt),p(ie,y(ee,{get when(){return Ee(()=>We().type==="oauth"&&!st())()&&(q()==="prompts"||q()==="error"||q()==="authorizing")},get children(){var qe=bh();return p(qe,()=>t("settings.providers.oauth.noPrompts")),qe}}),mt),p(ie,y(ee,{get when(){return Ee(()=>We().type==="command")()&&(q()==="prompts"||q()==="error"||q()==="authorizing")},get children(){var qe=az(),yt=qe.firstChild,it=yt.nextSibling;return p(yt,()=>t("settings.providers.command.description")),p(it,()=>{var ye;return(ye=at())==null?void 0:ye.command.join(" ")}),qe}}),mt),p(ie,y(ee,{get when(){return q()==="code"},get children(){var qe=cz(),yt=qe.firstChild,it=yt.firstChild,ye=yt.nextSibling,Ye=ye.firstChild,ct=Ye.nextSibling;return p(yt,y(Yi,{class:"providers-instructions-icon"}),it),p(it,()=>{var fn;return((fn=C())==null?void 0:fn.instructions)||t("settings.providers.oauth.enterCode")}),p(Ye,()=>t("settings.providers.oauth.codeLabel")),ct.$$input=fn=>W(fn.currentTarget.value),dr(fn=>{B=fn},ct),de(()=>me(ct,"placeholder",t("settings.providers.oauth.codePlaceholder"))),de(()=>ct.value=ne()),qe}}),mt),p(ie,y(ee,{get when(){return q()==="waiting"},get children(){var qe=lz(),yt=qe.firstChild,it=yt.firstChild,ye=it.nextSibling,Ye=yt.nextSibling;return p(qe,y(Zn,{class:"providers-spin-icon"}),yt),p(it,(()=>{var ct=Ee(()=>We().type==="command");return()=>ct()?t("settings.providers.command.waitingTitle"):t("settings.providers.oauth.waitingTitle")})()),p(ye,(()=>{var ct=Ee(()=>We().type==="command");return()=>{var fn;return ct()?I()??t("settings.providers.command.waitingMessage"):(fn=C())==null?void 0:fn.instructions}})()),Ye.$$click=wn,p(Ye,()=>t("settings.providers.oauth.cancelWait")),qe}}),mt),p(ie,y(ee,{get when(){return Ee(()=>!!(C()&&bp(C().url)))()&&(q()==="code"||q()==="waiting")},get children(){var qe=dz(),yt=qe.firstChild,it=yt.nextSibling,ye=it.nextSibling;return p(yt,y(Yi,{class:"w-4 h-4"}),null),p(yt,()=>t("settings.providers.oauth.openPage"),null),it.$$click=()=>void tt(C().url,{sameTab:!0}),p(it,()=>t("settings.providers.oauth.openHere")),ye.$$click=()=>void At(),p(ye,(()=>{var Ye=Ee(()=>!!ke());return()=>Ye()?t("settings.providers.oauth.linkCopied"):t("settings.providers.oauth.copyLink")})()),de(()=>{var Ye;return me(yt,"href",(Ye=C())==null?void 0:Ye.url)}),qe}}),mt),p(ie,y(ee,{get when(){return Ee(()=>!!ge())()&&C()},get children(){var qe=uz();return p(qe,()=>t("settings.providers.oauth.popupBlocked")),qe}}),mt),p(ie,y(ee,{get when(){return q()==="success"},get children(){var qe=fz(),yt=qe.firstChild;return p(qe,y(Qk,{class:"providers-success-icon"}),yt),p(yt,()=>t("settings.providers.success")),qe}}),mt),p(mt,y(ee,{get when(){return q()==="code"},get fallback(){return(()=>{var qe=BS();return qe.$$click=()=>void ot(),p(qe,y(ee,{get when(){return q()==="authorizing"},get fallback(){return t("settings.providers.actions.continue")},get children(){return[y(Zn,{class:"providers-spin-icon"}),Ee(()=>t("settings.providers.actions.working"))]}})),de(()=>qe.disabled=!ht()),qe})()},get children(){var qe=BS();return qe.$$click=()=>void Pt(),p(qe,()=>t("settings.providers.oauth.submitCode")),de(()=>qe.disabled=!ne().trim()),qe}})),de(qe=>{var yt=t("settings.providers.actions.close"),it=t("settings.providers.actions.close");return yt!==qe.e&&me(bt,"aria-label",qe.e=yt),it!==qe.t&&me(bt,"title",qe.t=it),qe},{e:void 0,t:void 0}),ie}}),(()=>{var ie=hz(),Oe=ie.firstChild;return p(Oe,()=>t("settings.providers.configured.title")),p(ie,y(ee,{get when(){return F()},get fallback(){return[y(ee,{get when(){return G()},get children(){var Le=bz(),Ce=Le.firstChild;return p(Le,y(Zn,{class:"providers-spin-icon"}),Ce),p(Ce,()=>t("settings.providers.loading")),Le}}),y(ee,{get when(){return Ee(()=>!G())()&&re().length===0},get children(){var Le=bh();return p(Le,()=>t("settings.providers.empty.noConfiguredProviders")),Le}}),(()=>{var Le=Sz();return p(Le,y(zt,{get each(){return re()},children:Ce=>(()=>{var ft=$z(),bt=ft.firstChild,mt=bt.firstChild,qe=mt.nextSibling,yt=bt.nextSibling,it=yt.firstChild;return p(mt,()=>Ce.name||Ce.id),p(qe,y(ee,{get when(){return Ee(()=>!!Ce.name)()&&Ce.name!==Ce.id},get children(){return[(()=>{var ye=kz();return p(ye,()=>Ce.id),ye})(),xz()]}}),null),p(qe,()=>Et(Ce),null),it.$$click=()=>{g=Ce.id,u(Ce.id)},dr(ye=>f.set(Ce.id,ye),it),p(it,()=>t("settings.providers.actions.manageModels")),p(yt,y(ee,{get when(){return V(Ce)==="credential-remove"},get children(){var ye=_z();return ye.$$click=()=>void In(Ce.id),p(ye,()=>t("settings.providers.actions.disconnect")),de(Ye=>{var ct=q()!=="idle",fn=t("settings.providers.actions.disconnect");return ct!==Ye.e&&(ye.disabled=Ye.e=ct),fn!==Ye.t&&me(ye,"title",Ye.t=fn),Ye},{e:void 0,t:void 0}),ye}}),null),ft})()})),Le})()]},children:Le=>y(nz,{get providerId(){return Le().id},get providerName(){return Le().name||Le().id},get models(){return Le().models},onBack:ve})}),null),ie})()]}}),null),J})()];return e.embedded?(()=>{var J=Cz();return p(J,tn),J})():y(Ot,{get open(){return!!e.open},onOpenChange:ut,get children(){return y(Ot.Portal,{get children(){return[y(Ot.Overlay,{class:"modal-overlay"}),y(Ot.Content,{class:"modal-surface providers-manager-modal",get children(){return tn()}})]}})}})};Xt(["click","input"]);const Tz=e=>y(Ez,{get instanceId(){return e.instanceId??Ds()??""},get location(){return e.location},embedded:!0});var Mz=O('<section class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class="settings-scope-badge settings-scope-badge-server"></span></div><div class=settings-card-body>');const Az=()=>{const{t:e}=Dt();return Ys(()=>void Fs()),(()=>{var t=Mz(),n=t.firstChild,s=n.firstChild,r=s.firstChild,o=r.nextSibling,a=s.nextSibling,i=n.nextSibling;return p(r,()=>e("settings.opencode.update.title")),p(o,()=>e("settings.opencode.setup.description")),p(a,()=>e("settings.scope.server")),p(i,y(Zk,{})),t})()};var Dz=O('<div class="flex-1 min-w-0">'),Pz=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class="settings-scope-badge settings-scope-badge-server"></span></div><div class=settings-card-body><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>'),Iz=O('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const Rz=()=>{const{t:e}=Dt(),{serverSettings:t,updateLogLevel:n}=Un(),s=Te(()=>[{value:"DEBUG",label:e("settings.opencode.logLevel.option.debug")},{value:"INFO",label:e("settings.opencode.logLevel.option.info")},{value:"WARN",label:e("settings.opencode.logLevel.option.warn")},{value:"ERROR",label:e("settings.opencode.logLevel.option.error")}]),r=Te(()=>s().find(o=>o.value===t().logLevel)??s()[0]);return(()=>{var o=Pz(),a=o.firstChild,i=a.firstChild,c=i.firstChild,l=c.firstChild,d=l.nextSibling,u=c.nextSibling,f=i.nextSibling,g=f.firstChild,m=g.firstChild,w=m.firstChild,S=w.nextSibling;return p(o,y(nx,{}),a),p(o,y(Az,{}),a),p(l,()=>e("settings.opencode.logLevel.title")),p(d,()=>e("settings.opencode.logLevel.subtitle")),p(u,()=>e("settings.scope.server")),p(w,()=>e("settings.opencode.logLevel.selector.title")),p(S,()=>e("settings.opencode.logLevel.selector.subtitle")),p(g,y(De,{get value(){return r()},onChange:b=>b&&n(b.value),get options(){return s()},optionValue:"value",optionTextValue:"label",itemComponent:b=>y(De.Item,{get item(){return b.item},class:"selector-option",get children(){return y(De.ItemLabel,{class:"selector-option-label",get children(){return b.item.rawValue.label}})}}),get children(){return[y(De.Trigger,{class:"selector-trigger",get"aria-label"(){return e("settings.opencode.logLevel.title")},get children(){return[(()=>{var b=Dz();return p(b,y(De.Value,{children:v=>(()=>{var k=Iz();return p(k,()=>{var C;return(C=v.selectedOption())==null?void 0:C.label}),k})()})),b})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}}),null),o})()};var Oz=O("<div class=space-y-2>"),Lz=O('<div class="text-xs text-muted text-center py-2">'),Nz=O('<div class=space-y-3><div class="flex items-center gap-2 mb-3"><span class="text-sm font-medium text-secondary"></span><span class="text-xs text-muted"></span></div><div class="flex items-center gap-2 pt-2 border-t border-base"><div class="flex-1 flex items-center gap-2"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"><input class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"autocomplete=new-password></div><button></button><button class="p-1.5 icon-muted icon-accent-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors"></button></div><div class="text-xs text-muted mt-2">'),Fz=O('<div class="flex items-center gap-2"><div class="flex-1 flex items-center gap-2"><input type=text class="flex-1 px-2.5 py-1.5 text-sm bg-surface-secondary border border-base text-muted cursor-not-allowed"><input class="flex-1 px-2.5 py-1.5 text-sm bg-surface-base border border-base text-primary focus-ring-accent disabled:opacity-50 disabled:cursor-not-allowed"></div><button></button><button class="p-1.5 icon-muted icon-danger-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors">');const Bz=e=>{const{t}=Dt(),{serverSettings:n,addEnvironmentVariable:s,removeEnvironmentVariable:r,updateEnvironmentVariables:o,isSecureEnvVar:a,toggleSecureEnvVar:i}=Un(),[c,l]=R(n().environmentVariables||{}),[d,u]=R(""),[f,g]=R(""),[m,w]=R(!0),S=()=>Object.entries(c());function b(){const T=d().trim(),P=f().trim();T&&(s(T,P,m()),l({...c(),[T]:P}),u(""),g(""),w(!0))}function v(T){r(T);const{[T]:P,...I}=c();l(I)}function k(T,P){const I={...c(),[T]:P};l(I),o(I)}function C(T){i(T)}function _(T){T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),b())}return(()=>{var T=Nz(),P=T.firstChild,I=P.firstChild,j=I.nextSibling,ne=P.nextSibling,W=ne.firstChild,q=W.firstChild,U=q.nextSibling,G=W.nextSibling,le=G.nextSibling,K=ne.nextSibling;return p(P,y(ei,{class:"w-4 h-4 icon-muted"}),I),p(I,()=>t("envEditor.title")),p(j,(()=>{var M=Ee(()=>S().length===1);return()=>M()?t("envEditor.count.one",{count:S().length}):t("envEditor.count.other",{count:S().length})})()),p(T,y(ee,{get when(){return S().length>0},get children(){var M=Oz();return p(M,y(zt,{get each(){return S()},children:([N,oe])=>(()=>{var ge=Fz(),Ie=ge.firstChild,ke=Ie.firstChild,we=ke.nextSibling,Ae=Ie.nextSibling,Ge=Ae.nextSibling;return p(Ie,y(ab,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),ke),ke.value=N,we.$$input=H=>k(N,H.currentTarget.value),we.value=oe,Ae.$$click=()=>C(N),p(Ae,(()=>{var H=Ee(()=>!!a(N));return()=>H()?y(Zd,{class:"w-3.5 h-3.5"}):y(lb,{class:"w-3.5 h-3.5"})})()),Ge.$$click=()=>v(N),p(Ge,y(af,{class:"w-3.5 h-3.5"})),de(H=>{var h=e.disabled,$=t("envEditor.fields.name.placeholder"),D=t("envEditor.fields.name.readOnlyTitle"),E=a(N)?"password":"text",Z=e.disabled,B=t("envEditor.fields.value.placeholder"),se=a(N)?"new-password":"off",pe=a(N)?!1:void 0,Se=a(N)?"off":void 0,Q=e.disabled,be=`p-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${a(N)?"icon-accent-hover text-accent":"icon-muted icon-accent-hover"}`,Ve=a(N)?t("envEditor.fields.secure.enabled"):t("envEditor.fields.secure.disabled"),He=e.disabled,re=t("envEditor.actions.remove.title");return h!==H.e&&(ke.disabled=H.e=h),$!==H.t&&me(ke,"placeholder",H.t=$),D!==H.a&&me(ke,"title",H.a=D),E!==H.o&&me(we,"type",H.o=E),Z!==H.i&&(we.disabled=H.i=Z),B!==H.n&&me(we,"placeholder",H.n=B),se!==H.s&&me(we,"autocomplete",H.s=se),pe!==H.h&&me(we,"spellcheck",H.h=pe),Se!==H.r&&me(we,"autocapitalize",H.r=Se),Q!==H.d&&(Ae.disabled=H.d=Q),be!==H.l&&ws(Ae,H.l=be),Ve!==H.u&&me(Ae,"title",H.u=Ve),He!==H.c&&(Ge.disabled=H.c=He),re!==H.w&&me(Ge,"title",H.w=re),H},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0}),ge})()})),M}}),ne),p(W,y(ab,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),q),q.addEventListener("keypress",_),q.$$input=M=>u(M.currentTarget.value),U.addEventListener("keypress",_),U.$$input=M=>g(M.currentTarget.value),G.$$click=()=>w(!m()),p(G,(()=>{var M=Ee(()=>!!m());return()=>M()?y(Zd,{class:"w-3.5 h-3.5"}):y(lb,{class:"w-3.5 h-3.5"})})()),le.$$click=b,p(le,y(of,{class:"w-3.5 h-3.5"})),p(T,y(ee,{get when(){return S().length===0},get children(){var M=Lz();return p(M,()=>t("envEditor.empty")),M}}),K),p(K,()=>t("envEditor.help")),de(M=>{var N=e.disabled,oe=t("envEditor.fields.name.placeholder"),ge=m()?"password":"text",Ie=e.disabled,ke=t("envEditor.fields.value.placeholder"),we=e.disabled,Ae=`p-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${m()?"icon-accent-hover text-accent":"icon-muted icon-accent-hover"}`,Ge=m()?t("envEditor.fields.secure.enabled"):t("envEditor.fields.secure.disabled"),H=e.disabled||!d().trim(),h=t("envEditor.actions.add.title");return N!==M.e&&(q.disabled=M.e=N),oe!==M.t&&me(q,"placeholder",M.t=oe),ge!==M.a&&me(U,"type",M.a=ge),Ie!==M.o&&(U.disabled=M.o=Ie),ke!==M.i&&me(U,"placeholder",M.i=ke),we!==M.n&&(G.disabled=M.n=we),Ae!==M.s&&ws(G,M.s=Ae),Ge!==M.h&&me(G,"title",M.h=Ge),H!==M.r&&(le.disabled=M.r=H),h!==M.d&&me(le,"title",M.d=h),M},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),de(()=>q.value=d()),de(()=>U.value=f()),T})()};Xt(["input","click"]);var Uz=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div><span class="settings-scope-badge settings-scope-badge-server"></span></div></div><div class=settings-card><div class=settings-stack>');const Kz=()=>{const{t:e}=Dt(),t=Un(),n=Te(()=>[...ry(t).filter(s=>s.id==="behavior.autoCleanupBlankSessions"||s.id==="behavior.keepUnseenSubagentIdleStatus"||s.id==="behavior.focusExistingWindowOnSecondLaunch"&&JT()||s.id==="behavior.providerUsageCreditBalance"),{kind:"toggle",id:"behavior.holdLongAssistantReplies",titleKey:"settings.behavior.holdLongAssistantReplies.title",subtitleKey:"settings.behavior.holdLongAssistantReplies.subtitle",get:s=>!!(s.holdLongAssistantReplies??!0),set:s=>t.updatePreferences({holdLongAssistantReplies:s})}]);return(()=>{var s=Uz(),r=s.firstChild,o=r.firstChild,a=o.firstChild,i=a.firstChild,c=i.nextSibling,l=a.nextSibling,d=r.nextSibling,u=d.firstChild;return p(i,()=>e("advancedSettings.environmentVariables.title")),p(c,()=>e("advancedSettings.environmentVariables.subtitle")),p(l,()=>e("settings.scope.server")),p(r,y(Bz,{}),null),p(u,y(oy,{settings:n,get preferences(){return t.preferences}})),s})()};var Vz=O("<div class=config-files-selector-value>"),jz=O('<span class="config-files-state config-files-state-inline">'),qz=O('<div class="settings-section-stack config-files-section"><h2 class=sr-only></h2><div class=config-files-card><div class=config-files-toolbar><div class=config-files-selector-field></div><div class=config-files-actions><button type=button class=files-header-icon-button></button><button type=button class=files-header-icon-button></button></div></div><div class="config-files-editor-shell file-viewer-panel">'),zz=O('<div class=selector-option-content><div class="selector-option-description config-files-selector-path">'),Wz=O('<span class=config-files-selector-value-inner><span class="selector-trigger-primary selector-trigger-primary--align-left">'),Hz=O('<span class="selector-trigger-secondary config-files-selector-path">'),Gz=O("<div class=settings-error-message>"),US=O("<div class=config-files-editor-empty>"),Zz=O('<div class="file-viewer-content file-viewer-content--monaco config-files-editor-content">');const Yz=hk(()=>ls(()=>import("./monaco-viewer-BQXd7g3w.js").then(e=>e.at),__vite__mapDeps([1,2,3,4,5])).then(e=>({default:e.MonacoFileViewer}))),Jz=()=>{const{t:e}=Dt(),[t,n]=R([]),[s,r]=R(null),[o,a]=R(""),[i,c]=R(""),[l,d]=R(null),[u,f]=R(!1),[g,m]=R(!1),[w,S]=R(!1),[b,v]=R(null);let k=0;const C=Te(()=>t().find(U=>U.id===s())??null),_=Te(()=>o()!==i()),T=async U=>{const G=++k;m(!0),v(null);try{const le=await kt.readConfigFile(U.id);if(G!==k)return;r(U.id),a(le.contents),c(le.contents),d(le.exists)}catch(le){if(G!==k)return;v(le instanceof Error?le.message:e("settings.configFiles.errors.loadContent")),a(""),c(""),d(null)}finally{G===k&&m(!1)}},P=async()=>_()?ca(e("settings.configFiles.confirmDiscard.message"),{variant:"warning",confirmLabel:e("settings.configFiles.confirmDiscard.confirmLabel"),cancelLabel:e("settings.configFiles.confirmDiscard.cancelLabel"),dismissible:!1}):!0,I=async()=>{f(!0),v(null);try{const U=await kt.listConfigFiles();n(U);const G=U[0];G&&await T(G)}catch(U){v(U instanceof Error?U.message:e("settings.configFiles.errors.loadList"))}finally{f(!1)}},j=async U=>{!U||U.id===s()||!await P()||await T(U)},ne=async()=>{const U=C();!U||!await P()||await T(U)},W=async()=>{const U=C();if(!U)return;const G=o();S(!0),v(null);try{await kt.writeConfigFile(U.id,G),o()===G&&c(G),d(!0),Hn({message:e("settings.configFiles.toast.saveSuccess"),variant:"success"})}catch(le){v(le instanceof Error?le.message:e("settings.configFiles.errors.save")),Hn({message:e("settings.configFiles.toast.saveError"),variant:"error"})}finally{S(!1)}};Ys(()=>{I()});const q=Vx(P);return dt(q),(()=>{var U=qz(),G=U.firstChild,le=G.nextSibling,K=le.firstChild,M=K.firstChild,N=M.nextSibling,oe=N.firstChild,ge=oe.nextSibling,Ie=K.nextSibling;return p(G,()=>e("settings.configFiles.title")),p(M,y(De,{get value(){return C()??void 0},onChange:ke=>void j(ke),get options(){return t()},optionValue:"id",optionTextValue:"label",get disabled(){return u()||t().length===0},itemComponent:ke=>y(De.Item,{get item(){return ke.item},class:"selector-option",get children(){var we=zz(),Ae=we.firstChild;return p(we,y(De.ItemLabel,{class:"selector-option-label",get children(){return ke.item.rawValue.label}}),Ae),p(Ae,()=>ke.item.rawValue.path),we}}),get children(){return[y(De.Trigger,{class:"selector-trigger config-files-selector-trigger",get"aria-label"(){return e("settings.configFiles.selector.label")},get children(){return[(()=>{var ke=Vz();return p(ke,y(De.Value,{children:we=>(()=>{var Ae=Wz(),Ge=Ae.firstChild;return p(Ge,()=>{var H;return((H=we.selectedOption())==null?void 0:H.label)??e("settings.configFiles.selector.placeholder")}),p(Ae,y(ee,{get when(){return we.selectedOption()},children:H=>(()=>{var h=Hz();return p(h,()=>H().path),h})()}),null),Ae})()})),ke})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})),p(N,y(ee,{get when(){return Ee(()=>!!C())()&&(_()||l()===!1)},get children(){var ke=jz();return p(ke,(()=>{var we=Ee(()=>!!_());return()=>we()?e("settings.configFiles.state.unsaved"):e("settings.configFiles.state.notCreated")})()),ke}}),oe),oe.$$click=()=>void W(),p(oe,y(ee,{get when(){return w()},get fallback(){return y(WD,{class:"h-4 w-4"})},get children(){return y(Gd,{class:"h-4 w-4 animate-spin"})}})),ge.$$click=()=>void ne(),p(ge,y(Gd,{get class(){return`h-4 w-4${g()?" animate-spin":""}`}})),p(le,y(ee,{get when(){return b()},children:ke=>(()=>{var we=Gz();return p(we,ke),we})()}),Ie),p(Ie,y(ee,{get when(){return Ee(()=>!u()&&!g())()&&C()},get fallback(){return(()=>{var ke=US();return p(ke,(()=>{var we=Ee(()=>!!(u()||g()));return()=>we()?e("instanceInfo.loading"):e("settings.configFiles.empty")})()),ke})()},children:ke=>(()=>{var we=Zz();return p(we,y(SM,{get fallback(){return(()=>{var Ae=US();return p(Ae,()=>e("instanceInfo.loading")),Ae})()},get children(){return y(Yz,{scopeKey:"settings-config-files",get path(){return ke().path},get content(){return o()},wordWrap:"off",compactGutter:!0,onSave:()=>void W(),onContentChange:Ae=>a(Ae)})}})),we})()})),de(ke=>{var we=e("settings.configFiles.actions.save"),Ae=e("settings.configFiles.actions.save"),Ge=!C()||w()||g()||!_(),H=e("settings.configFiles.actions.reload"),h=e("settings.configFiles.actions.reload"),$=!C()||g()||w();return we!==ke.e&&me(oe,"title",ke.e=we),Ae!==ke.t&&me(oe,"aria-label",ke.t=Ae),Ge!==ke.a&&(oe.disabled=ke.a=Ge),H!==ke.o&&me(ge,"title",ke.o=H),h!==ke.i&&me(ge,"aria-label",ke.i=h),$!==ke.n&&(ge.disabled=ke.n=$),ke},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),U})()};Xt(["click"]);function Qz(e={}){const[t,n]=Pk({value:()=>he(e.isSelected),defaultValue:()=>!!he(e.defaultIsSelected),onChange:o=>{var a;return(a=e.onSelectedChange)==null?void 0:a.call(e,o)}});return{isSelected:t,setIsSelected:o=>{!he(e.isReadOnly)&&!he(e.isDisabled)&&n(o)},toggle:()=>{!he(e.isReadOnly)&&!he(e.isDisabled)&&n(!t())}}}var Xz={};yl(Xz,{Control:()=>ST,Description:()=>kT,ErrorMessage:()=>xT,Input:()=>_T,Label:()=>$T,Root:()=>CT,Switch:()=>Cc,Thumb:()=>ET,useSwitchContext:()=>Mi});var bT=qr();function Mi(){const e=zr(bT);if(e===void 0)throw new Error("[kobalte]: `useSwitchContext` must be used within a `Switch` component");return e}function ST(e){const t=pr(),n=Mi(),s=Kt({id:n.generateId("control")},e),[r,o]=Nt(s,["onClick","onKeyDown"]);return y(en,_e({as:"div",onClick:c=>{var l;on(c,r.onClick),n.toggle(),(l=n.inputRef())==null||l.focus()},onKeyDown:c=>{var l;on(c,r.onKeyDown),c.key===Pp.Space&&(n.toggle(),(l=n.inputRef())==null||l.focus())}},()=>t.dataset(),()=>n.dataset(),o))}function kT(e){const t=Mi();return y(zp,_e(()=>t.dataset(),e))}function xT(e){const t=Mi();return y(ny,_e(()=>t.dataset(),e))}function _T(e){const t=pr(),n=Mi(),s=Kt({id:n.generateId("input")},e),[r,o,a]=Nt(s,["ref","style","onChange","onFocus","onBlur"],Tx),{fieldProps:i}=Mx(o);return y(en,_e({as:"input",ref(u){var f=Kn(n.setInputRef,r.ref);typeof f=="function"&&f(u)},type:"checkbox",role:"switch",get id(){return i.id()},get name(){return t.name()},get value(){return n.value()},get checked(){return n.checked()},get required(){return t.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return t.isReadOnly()},get style(){return ml({...nf},r.style)},get"aria-checked"(){return n.checked()},get"aria-label"(){return i.ariaLabel()},get"aria-labelledby"(){return i.ariaLabelledBy()},get"aria-describedby"(){return i.ariaDescribedBy()},get"aria-invalid"(){return t.validationState()==="invalid"||void 0},get"aria-required"(){return t.isRequired()||void 0},get"aria-disabled"(){return t.isDisabled()||void 0},get"aria-readonly"(){return t.isReadOnly()||void 0},onChange:u=>{on(u,r.onChange),u.stopPropagation();const f=u.target;n.setIsChecked(f.checked),f.checked=n.checked()},onFocus:u=>{on(u,r.onFocus),n.setIsFocused(!0)},onBlur:u=>{on(u,r.onBlur),n.setIsFocused(!1)}},()=>t.dataset(),()=>n.dataset(),a))}function $T(e){const t=Mi();return y(Ax,_e(()=>t.dataset(),e))}function CT(e){let t;const n=`switch-${Do()}`,s=Kt({value:"on",id:n},e),[r,o,a]=Nt(s,["ref","children","value","checked","defaultChecked","onChange","onPointerDown"],dx),[i,c]=R(),[l,d]=R(!1),{formControlContext:u}=ux(o),f=Qz({isSelected:()=>r.checked,defaultIsSelected:()=>r.defaultChecked,onSelectedChange:S=>{var b;return(b=r.onChange)==null?void 0:b.call(r,S)},isDisabled:()=>u.isDisabled(),isReadOnly:()=>u.isReadOnly()});Dx(()=>t,()=>f.setIsSelected(r.defaultChecked??!1));const g=S=>{on(S,r.onPointerDown),l()&&S.preventDefault()},m=Te(()=>({"data-checked":f.isSelected()?"":void 0})),w={value:()=>r.value,dataset:m,checked:()=>f.isSelected(),inputRef:i,generateId:ja(()=>he(o.id)),toggle:()=>f.toggle(),setIsChecked:S=>f.setIsSelected(S),setIsFocused:d,setInputRef:c};return y(qp.Provider,{value:u,get children(){return y(bT.Provider,{value:w,get children(){return y(en,_e({as:"div",ref(S){var b=Kn(v=>t=v,r.ref);typeof b=="function"&&b(S)},role:"group",get id(){return he(o.id)},onPointerDown:g},()=>u.dataset(),m,a,{get children(){return y(eW,{state:w,get children(){return r.children}})}}))}})}})}function eW(e){const t=gk(()=>{const n=e.children;return tf(n)?n(e.state):n});return Ee(t)}function ET(e){const t=pr(),n=Mi(),s=Kt({id:n.generateId("thumb")},e);return y(en,_e({as:"div"},()=>t.dataset(),()=>n.dataset(),s))}var Cc=Object.assign(CT,{Control:ST,Description:kT,ErrorMessage:xT,Input:_T,Label:$T,Thumb:ET}),tW=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},TT={},hs={};let Sw;const nW=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];hs.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};hs.getSymbolTotalCodewords=function(t){return nW[t]};hs.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};hs.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Sw=t};hs.isKanjiModeEnabled=function(){return typeof Sw<"u"};hs.toSJIS=function(t){return Sw(t)};var bg={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,r){if(e.isValid(s))return s;try{return t(s)}catch{return r}}})(bg);function MT(){this.buffer=[],this.length=0}MT.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var sW=MT;function Hl(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Hl.prototype.set=function(e,t,n,s){const r=e*this.size+t;this.data[r]=n,s&&(this.reservedBit[r]=!0)};Hl.prototype.get=function(e,t){return this.data[e*this.size+t]};Hl.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Hl.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var rW=Hl,AT={};(function(e){const t=hs.getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const r=Math.floor(s/7)+2,o=t(s),a=o===145?26:Math.ceil((o-13)/(2*r-2))*2,i=[o-7];for(let c=1;c<r-1;c++)i[c]=i[c-1]-a;return i.push(6),i.reverse()},e.getPositions=function(s){const r=[],o=e.getRowColCoords(s),a=o.length;for(let i=0;i<a;i++)for(let c=0;c<a;c++)i===0&&c===0||i===0&&c===a-1||i===a-1&&c===0||r.push([o[i],o[c]]);return r}})(AT);var DT={};const oW=hs.getSymbolSize,KS=7;DT.getPositions=function(t){const n=oW(t);return[[0,0],[n-KS,0],[0,n-KS]]};var PT={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const o=r.size;let a=0,i=0,c=0,l=null,d=null;for(let u=0;u<o;u++){i=c=0,l=d=null;for(let f=0;f<o;f++){let g=r.get(u,f);g===l?i++:(i>=5&&(a+=t.N1+(i-5)),l=g,i=1),g=r.get(f,u),g===d?c++:(c>=5&&(a+=t.N1+(c-5)),d=g,c=1)}i>=5&&(a+=t.N1+(i-5)),c>=5&&(a+=t.N1+(c-5))}return a},e.getPenaltyN2=function(r){const o=r.size;let a=0;for(let i=0;i<o-1;i++)for(let c=0;c<o-1;c++){const l=r.get(i,c)+r.get(i,c+1)+r.get(i+1,c)+r.get(i+1,c+1);(l===4||l===0)&&a++}return a*t.N2},e.getPenaltyN3=function(r){const o=r.size;let a=0,i=0,c=0;for(let l=0;l<o;l++){i=c=0;for(let d=0;d<o;d++)i=i<<1&2047|r.get(l,d),d>=10&&(i===1488||i===93)&&a++,c=c<<1&2047|r.get(d,l),d>=10&&(c===1488||c===93)&&a++}return a*t.N3},e.getPenaltyN4=function(r){let o=0;const a=r.data.length;for(let c=0;c<a;c++)o+=r.data[c];return Math.abs(Math.ceil(o*100/a/5)-10)*t.N4};function n(s,r,o){switch(s){case e.Patterns.PATTERN000:return(r+o)%2===0;case e.Patterns.PATTERN001:return r%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(r+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return r*o%2+r*o%3===0;case e.Patterns.PATTERN110:return(r*o%2+r*o%3)%2===0;case e.Patterns.PATTERN111:return(r*o%3+(r+o)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(r,o){const a=o.size;for(let i=0;i<a;i++)for(let c=0;c<a;c++)o.isReserved(c,i)||o.xor(c,i,n(r,c,i))},e.getBestMask=function(r,o){const a=Object.keys(e.Patterns).length;let i=0,c=1/0;for(let l=0;l<a;l++){o(l),e.applyMask(l,r);const d=e.getPenaltyN1(r)+e.getPenaltyN2(r)+e.getPenaltyN3(r)+e.getPenaltyN4(r);e.applyMask(l,r),d<c&&(c=d,i=l)}return i}})(PT);var Sg={};const io=bg,$d=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Cd=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Sg.getBlocksCount=function(t,n){switch(n){case io.L:return $d[(t-1)*4+0];case io.M:return $d[(t-1)*4+1];case io.Q:return $d[(t-1)*4+2];case io.H:return $d[(t-1)*4+3];default:return}};Sg.getTotalCodewordsCount=function(t,n){switch(n){case io.L:return Cd[(t-1)*4+0];case io.M:return Cd[(t-1)*4+1];case io.Q:return Cd[(t-1)*4+2];case io.H:return Cd[(t-1)*4+3];default:return}};var IT={},kg={};const Fc=new Uint8Array(512),Zu=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Fc[n]=t,Zu[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Fc[n]=Fc[n-255]})();kg.log=function(t){if(t<1)throw new Error("log("+t+")");return Zu[t]};kg.exp=function(t){return Fc[t]};kg.mul=function(t,n){return t===0||n===0?0:Fc[Zu[t]+Zu[n]]};(function(e){const t=kg;e.mul=function(s,r){const o=new Uint8Array(s.length+r.length-1);for(let a=0;a<s.length;a++)for(let i=0;i<r.length;i++)o[a+i]^=t.mul(s[a],r[i]);return o},e.mod=function(s,r){let o=new Uint8Array(s);for(;o.length-r.length>=0;){const a=o[0];for(let c=0;c<r.length;c++)o[c]^=t.mul(r[c],a);let i=0;for(;i<o.length&&o[i]===0;)i++;o=o.slice(i)}return o},e.generateECPolynomial=function(s){let r=new Uint8Array([1]);for(let o=0;o<s;o++)r=e.mul(r,new Uint8Array([1,t.exp(o)]));return r}})(IT);const RT=IT;function kw(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}kw.prototype.initialize=function(t){this.degree=t,this.genPoly=RT.generateECPolynomial(this.degree)};kw.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const s=RT.mod(n,this.genPoly),r=this.degree-s.length;if(r>0){const o=new Uint8Array(this.degree);return o.set(s,r),o}return s};var iW=kw,OT={},Bo={},xw={};xw.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var wr={};const LT="[0-9]+",aW="[A-Z $%*+\\-./:]+";let gl="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";gl=gl.replace(/u/g,"\\u");const cW="(?:(?![A-Z0-9 $%*+\\-./:]|"+gl+`)(?:.|[\r
|
|
36
36
|
]))+`;wr.KANJI=new RegExp(gl,"g");wr.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");wr.BYTE=new RegExp(cW,"g");wr.NUMERIC=new RegExp(LT,"g");wr.ALPHANUMERIC=new RegExp(aW,"g");const lW=new RegExp("^"+gl+"$"),dW=new RegExp("^"+LT+"$"),uW=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");wr.testKanji=function(t){return lW.test(t)};wr.testNumeric=function(t){return dW.test(t)};wr.testAlphanumeric=function(t){return uW.test(t)};(function(e){const t=xw,n=wr;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(o,a){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?o.ccBits[0]:a<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return n.testNumeric(o)?e.NUMERIC:n.testAlphanumeric(o)?e.ALPHANUMERIC:n.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.ccBits};function s(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+r)}}e.from=function(o,a){if(e.isValid(o))return o;try{return s(o)}catch{return a}}})(Bo);(function(e){const t=hs,n=Sg,s=bg,r=Bo,o=xw,a=7973,i=t.getBCHDigit(a);function c(f,g,m){for(let w=1;w<=40;w++)if(g<=e.getCapacity(w,m,f))return w}function l(f,g){return r.getCharCountIndicator(f,g)+4}function d(f,g){let m=0;return f.forEach(function(w){const S=l(w.mode,g);m+=S+w.getBitsLength()}),m}function u(f,g){for(let m=1;m<=40;m++)if(d(f,m)<=e.getCapacity(m,g,r.MIXED))return m}e.from=function(g,m){return o.isValid(g)?parseInt(g,10):m},e.getCapacity=function(g,m,w){if(!o.isValid(g))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=r.BYTE);const S=t.getSymbolTotalCodewords(g),b=n.getTotalCodewordsCount(g,m),v=(S-b)*8;if(w===r.MIXED)return v;const k=v-l(w,g);switch(w){case r.NUMERIC:return Math.floor(k/10*3);case r.ALPHANUMERIC:return Math.floor(k/11*2);case r.KANJI:return Math.floor(k/13);case r.BYTE:default:return Math.floor(k/8)}},e.getBestVersionForData=function(g,m){let w;const S=s.from(m,s.M);if(Array.isArray(g)){if(g.length>1)return u(g,S);if(g.length===0)return 1;w=g[0]}else w=g;return c(w.mode,w.getLength(),S)},e.getEncodedBits=function(g){if(!o.isValid(g)||g<7)throw new Error("Invalid QR Code version");let m=g<<12;for(;t.getBCHDigit(m)-i>=0;)m^=a<<t.getBCHDigit(m)-i;return g<<12|m}})(OT);var NT={};const Sp=hs,FT=1335,fW=21522,VS=Sp.getBCHDigit(FT);NT.getEncodedBits=function(t,n){const s=t.bit<<3|n;let r=s<<10;for(;Sp.getBCHDigit(r)-VS>=0;)r^=FT<<Sp.getBCHDigit(r)-VS;return(s<<10|r)^fW};var BT={};const gW=Bo;function Ba(e){this.mode=gW.NUMERIC,this.data=e.toString()}Ba.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Ba.prototype.getLength=function(){return this.data.length};Ba.prototype.getBitsLength=function(){return Ba.getBitsLength(this.data.length)};Ba.prototype.write=function(t){let n,s,r;for(n=0;n+3<=this.data.length;n+=3)s=this.data.substr(n,3),r=parseInt(s,10),t.put(r,10);const o=this.data.length-n;o>0&&(s=this.data.substr(n),r=parseInt(s,10),t.put(r,o*3+1))};var hW=Ba;const mW=Bo,Sh=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Ua(e){this.mode=mW.ALPHANUMERIC,this.data=e}Ua.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};Ua.prototype.getLength=function(){return this.data.length};Ua.prototype.getBitsLength=function(){return Ua.getBitsLength(this.data.length)};Ua.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let s=Sh.indexOf(this.data[n])*45;s+=Sh.indexOf(this.data[n+1]),t.put(s,11)}this.data.length%2&&t.put(Sh.indexOf(this.data[n]),6)};var pW=Ua;const yW=Bo;function Ka(e){this.mode=yW.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}Ka.getBitsLength=function(t){return t*8};Ka.prototype.getLength=function(){return this.data.length};Ka.prototype.getBitsLength=function(){return Ka.getBitsLength(this.data.length)};Ka.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var vW=Ka;const wW=Bo,bW=hs;function Va(e){this.mode=wW.KANJI,this.data=e}Va.getBitsLength=function(t){return t*13};Va.prototype.getLength=function(){return this.data.length};Va.prototype.getBitsLength=function(){return Va.getBitsLength(this.data.length)};Va.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=bW.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
|
37
37
|
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var SW=Va,UT={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,s,r){var o={},a={};a[s]=0;var i=t.PriorityQueue.make();i.push(s,0);for(var c,l,d,u,f,g,m,w,S;!i.empty();){c=i.pop(),l=c.value,u=c.cost,f=n[l]||{};for(d in f)f.hasOwnProperty(d)&&(g=f[d],m=u+g,w=a[d],S=typeof a[d]>"u",(S||w>m)&&(a[d]=m,i.push(d,m),o[d]=l))}if(typeof r<"u"&&typeof a[r]>"u"){var b=["Could not find a path from ",s," to ",r,"."].join("");throw new Error(b)}return o},extract_shortest_path_from_predecessor_list:function(n,s){for(var r=[],o=s;o;)r.push(o),n[o],o=n[o];return r.reverse(),r},find_path:function(n,s,r){var o=t.single_source_shortest_paths(n,s,r);return t.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(n){var s=t.PriorityQueue,r={},o;n=n||{};for(o in s)s.hasOwnProperty(o)&&(r[o]=s[o]);return r.queue=[],r.sorter=n.sorter||s.default_sorter,r},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var r={value:n,cost:s};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(UT);var kW=UT.exports;(function(e){const t=Bo,n=hW,s=pW,r=vW,o=SW,a=wr,i=hs,c=kW;function l(b){return unescape(encodeURIComponent(b)).length}function d(b,v,k){const C=[];let _;for(;(_=b.exec(k))!==null;)C.push({data:_[0],index:_.index,mode:v,length:_[0].length});return C}function u(b){const v=d(a.NUMERIC,t.NUMERIC,b),k=d(a.ALPHANUMERIC,t.ALPHANUMERIC,b);let C,_;return i.isKanjiModeEnabled()?(C=d(a.BYTE,t.BYTE,b),_=d(a.KANJI,t.KANJI,b)):(C=d(a.BYTE_KANJI,t.BYTE,b),_=[]),v.concat(k,C,_).sort(function(P,I){return P.index-I.index}).map(function(P){return{data:P.data,mode:P.mode,length:P.length}})}function f(b,v){switch(v){case t.NUMERIC:return n.getBitsLength(b);case t.ALPHANUMERIC:return s.getBitsLength(b);case t.KANJI:return o.getBitsLength(b);case t.BYTE:return r.getBitsLength(b)}}function g(b){return b.reduce(function(v,k){const C=v.length-1>=0?v[v.length-1]:null;return C&&C.mode===k.mode?(v[v.length-1].data+=k.data,v):(v.push(k),v)},[])}function m(b){const v=[];for(let k=0;k<b.length;k++){const C=b[k];switch(C.mode){case t.NUMERIC:v.push([C,{data:C.data,mode:t.ALPHANUMERIC,length:C.length},{data:C.data,mode:t.BYTE,length:C.length}]);break;case t.ALPHANUMERIC:v.push([C,{data:C.data,mode:t.BYTE,length:C.length}]);break;case t.KANJI:v.push([C,{data:C.data,mode:t.BYTE,length:l(C.data)}]);break;case t.BYTE:v.push([{data:C.data,mode:t.BYTE,length:l(C.data)}])}}return v}function w(b,v){const k={},C={start:{}};let _=["start"];for(let T=0;T<b.length;T++){const P=b[T],I=[];for(let j=0;j<P.length;j++){const ne=P[j],W=""+T+j;I.push(W),k[W]={node:ne,lastCount:0},C[W]={};for(let q=0;q<_.length;q++){const U=_[q];k[U]&&k[U].node.mode===ne.mode?(C[U][W]=f(k[U].lastCount+ne.length,ne.mode)-f(k[U].lastCount,ne.mode),k[U].lastCount+=ne.length):(k[U]&&(k[U].lastCount=ne.length),C[U][W]=f(ne.length,ne.mode)+4+t.getCharCountIndicator(ne.mode,v))}}_=I}for(let T=0;T<_.length;T++)C[_[T]].end=0;return{map:C,table:k}}function S(b,v){let k;const C=t.getBestModeForData(b);if(k=t.from(v,C),k!==t.BYTE&&k.bit<C.bit)throw new Error('"'+b+'" cannot be encoded with mode '+t.toString(k)+`.
|
|
38
38
|
Suggested mode is: `+t.toString(C));switch(k===t.KANJI&&!i.isKanjiModeEnabled()&&(k=t.BYTE),k){case t.NUMERIC:return new n(b);case t.ALPHANUMERIC:return new s(b);case t.KANJI:return new o(b);case t.BYTE:return new r(b)}}e.fromArray=function(v){return v.reduce(function(k,C){return typeof C=="string"?k.push(S(C,null)):C.data&&k.push(S(C.data,C.mode)),k},[])},e.fromString=function(v,k){const C=u(v,i.isKanjiModeEnabled()),_=m(C),T=w(_,k),P=c.find_path(T.map,"start","end"),I=[];for(let j=1;j<P.length-1;j++)I.push(T.table[P[j]].node);return e.fromArray(g(I))},e.rawSplit=function(v){return e.fromArray(u(v,i.isKanjiModeEnabled()))}})(BT);const xg=hs,kh=bg,xW=sW,_W=rW,$W=AT,CW=DT,kp=PT,xp=Sg,EW=iW,Yu=OT,TW=NT,MW=Bo,xh=BT;function AW(e,t){const n=e.size,s=CW.getPositions(t);for(let r=0;r<s.length;r++){const o=s[r][0],a=s[r][1];for(let i=-1;i<=7;i++)if(!(o+i<=-1||n<=o+i))for(let c=-1;c<=7;c++)a+c<=-1||n<=a+c||(i>=0&&i<=6&&(c===0||c===6)||c>=0&&c<=6&&(i===0||i===6)||i>=2&&i<=4&&c>=2&&c<=4?e.set(o+i,a+c,!0,!0):e.set(o+i,a+c,!1,!0))}}function DW(e){const t=e.size;for(let n=8;n<t-8;n++){const s=n%2===0;e.set(n,6,s,!0),e.set(6,n,s,!0)}}function PW(e,t){const n=$W.getPositions(t);for(let s=0;s<n.length;s++){const r=n[s][0],o=n[s][1];for(let a=-2;a<=2;a++)for(let i=-2;i<=2;i++)a===-2||a===2||i===-2||i===2||a===0&&i===0?e.set(r+a,o+i,!0,!0):e.set(r+a,o+i,!1,!0)}}function IW(e,t){const n=e.size,s=Yu.getEncodedBits(t);let r,o,a;for(let i=0;i<18;i++)r=Math.floor(i/3),o=i%3+n-8-3,a=(s>>i&1)===1,e.set(r,o,a,!0),e.set(o,r,a,!0)}function _h(e,t,n){const s=e.size,r=TW.getEncodedBits(t,n);let o,a;for(o=0;o<15;o++)a=(r>>o&1)===1,o<6?e.set(o,8,a,!0):o<8?e.set(o+1,8,a,!0):e.set(s-15+o,8,a,!0),o<8?e.set(8,s-o-1,a,!0):o<9?e.set(8,15-o-1+1,a,!0):e.set(8,15-o-1,a,!0);e.set(s-8,8,1,!0)}function RW(e,t){const n=e.size;let s=-1,r=n-1,o=7,a=0;for(let i=n-1;i>0;i-=2)for(i===6&&i--;;){for(let c=0;c<2;c++)if(!e.isReserved(r,i-c)){let l=!1;a<t.length&&(l=(t[a]>>>o&1)===1),e.set(r,i-c,l),o--,o===-1&&(a++,o=7)}if(r+=s,r<0||n<=r){r-=s,s=-s;break}}}function OW(e,t,n){const s=new xW;n.forEach(function(c){s.put(c.mode.bit,4),s.put(c.getLength(),MW.getCharCountIndicator(c.mode,e)),c.write(s)});const r=xg.getSymbolTotalCodewords(e),o=xp.getTotalCodewordsCount(e,t),a=(r-o)*8;for(s.getLengthInBits()+4<=a&&s.put(0,4);s.getLengthInBits()%8!==0;)s.putBit(0);const i=(a-s.getLengthInBits())/8;for(let c=0;c<i;c++)s.put(c%2?17:236,8);return LW(s,e,t)}function LW(e,t,n){const s=xg.getSymbolTotalCodewords(t),r=xp.getTotalCodewordsCount(t,n),o=s-r,a=xp.getBlocksCount(t,n),i=s%a,c=a-i,l=Math.floor(s/a),d=Math.floor(o/a),u=d+1,f=l-d,g=new EW(f);let m=0;const w=new Array(a),S=new Array(a);let b=0;const v=new Uint8Array(e.buffer);for(let P=0;P<a;P++){const I=P<c?d:u;w[P]=v.slice(m,m+I),S[P]=g.encode(w[P]),m+=I,b=Math.max(b,I)}const k=new Uint8Array(s);let C=0,_,T;for(_=0;_<b;_++)for(T=0;T<a;T++)_<w[T].length&&(k[C++]=w[T][_]);for(_=0;_<f;_++)for(T=0;T<a;T++)k[C++]=S[T][_];return k}function NW(e,t,n,s){let r;if(Array.isArray(e))r=xh.fromArray(e);else if(typeof e=="string"){let l=t;if(!l){const d=xh.rawSplit(e);l=Yu.getBestVersionForData(d,n)}r=xh.fromString(e,l||40)}else throw new Error("Invalid data");const o=Yu.getBestVersionForData(r,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=o;else if(t<o)throw new Error(`
|
|
39
39
|
The chosen QR Code version cannot contain this amount of data.
|
|
40
40
|
Minimum version required to store current data is: `+o+`.
|
|
41
41
|
`);const a=OW(t,n,r),i=xg.getSymbolSize(t),c=new _W(i);return AW(c,t),DW(c),PW(c,t),_h(c,n,0),t>=7&&IW(c,t),RW(c,a),isNaN(s)&&(s=kp.getBestMask(c,_h.bind(null,c,n))),kp.applyMask(s,c),_h(c,n,s),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:s,segments:r}}TT.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let s=kh.M,r,o;return typeof n<"u"&&(s=kh.from(n.errorCorrectionLevel,kh.M),r=Yu.from(n.version),o=kp.from(n.maskPattern),n.toSJISFunc&&xg.setToSJISFunction(n.toSJISFunc)),NW(t,r,s,o)};var KT={},_w={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(o){return[o,o]}))),s.length===6&&s.push("F","F");const r=parseInt(s.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const r=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,o=s.width&&s.width>=21?s.width:void 0,a=s.scale||4;return{width:o,scale:o?4:a,margin:r,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,r){return r.width&&r.width>=s+r.margin*2?r.width/(s+r.margin*2):r.scale},e.getImageWidth=function(s,r){const o=e.getScale(s,r);return Math.floor((s+r.margin*2)*o)},e.qrToImageData=function(s,r,o){const a=r.modules.size,i=r.modules.data,c=e.getScale(a,o),l=Math.floor((a+o.margin*2)*c),d=o.margin*c,u=[o.color.light,o.color.dark];for(let f=0;f<l;f++)for(let g=0;g<l;g++){let m=(f*l+g)*4,w=o.color.light;if(f>=d&&g>=d&&f<l-d&&g<l-d){const S=Math.floor((f-d)/c),b=Math.floor((g-d)/c);w=u[i[S*a+b]?1:0]}s[m++]=w.r,s[m++]=w.g,s[m++]=w.b,s[m]=w.a}}})(_w);(function(e){const t=_w;function n(r,o,a){r.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=a,o.width=a,o.style.height=a+"px",o.style.width=a+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(o,a,i){let c=i,l=a;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),a||(l=s()),c=t.getOptions(c);const d=t.getImageWidth(o.modules.size,c),u=l.getContext("2d"),f=u.createImageData(d,d);return t.qrToImageData(f.data,o,c),n(u,l,d),u.putImageData(f,0,0),l},e.renderToDataURL=function(o,a,i){let c=i;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const l=e.render(o,a,c),d=c.type||"image/png",u=c.rendererOpts||{};return l.toDataURL(d,u.quality)}})(KT);var VT={};const FW=_w;function jS(e,t){const n=e.a/255,s=t+'="'+e.hex+'"';return n<1?s+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':s}function $h(e,t,n){let s=e+t;return typeof n<"u"&&(s+=" "+n),s}function BW(e,t,n){let s="",r=0,o=!1,a=0;for(let i=0;i<e.length;i++){const c=Math.floor(i%t),l=Math.floor(i/t);!c&&!o&&(o=!0),e[i]?(a++,i>0&&c>0&&e[i-1]||(s+=o?$h("M",c+n,.5+l+n):$h("m",r,0),r=0,o=!1),c+1<t&&e[i+1]||(s+=$h("h",a),a=0)):r++}return s}VT.render=function(t,n,s){const r=FW.getOptions(n),o=t.modules.size,a=t.modules.data,i=o+r.margin*2,c=r.color.light.a?"<path "+jS(r.color.light,"fill")+' d="M0 0h'+i+"v"+i+'H0z"/>':"",l="<path "+jS(r.color.dark,"stroke")+' d="'+BW(a,o,r.margin)+'"/>',d='viewBox="0 0 '+i+" "+i+'"',f='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+d+' shape-rendering="crispEdges">'+c+l+`</svg>
|
|
42
|
-
`;return typeof s=="function"&&s(null,f),f};const UW=tW,_p=TT,jT=KT,KW=VT;function $w(e,t,n,s,r){const o=[].slice.call(arguments,1),a=o.length,i=typeof o[a-1]=="function";if(!i&&!UW())throw new Error("Callback required as last argument");if(i){if(a<2)throw new Error("Too few arguments provided");a===2?(r=n,n=t,t=s=void 0):a===3&&(t.getContext&&typeof r>"u"?(r=s,s=void 0):(r=s,s=n,n=t,t=void 0))}else{if(a<1)throw new Error("Too few arguments provided");return a===1?(n=t,t=s=void 0):a===2&&!t.getContext&&(s=n,n=t,t=void 0),new Promise(function(c,l){try{const d=_p.create(n,s);c(e(d,t,s))}catch(d){l(d)}})}try{const c=_p.create(n,s);r(null,e(c,t,s))}catch(c){r(c)}}_p.create;$w.bind(null,jT.render);var VW=$w.bind(null,jT.renderToDataURL);$w.bind(null,function(e,t,n){return KW.render(e,n)});const jW=Ut("actions");async function qW(){var e,t;if(!QT())return!1;try{if(Bn()){const n=window.electronAPI;return n!=null&&n.restartCli?(await n.restartCli(),!0):!1}if(Dn())return typeof((t=(e=window.__TAURI__)==null?void 0:e.core)==null?void 0:t.invoke)=="function"?(await Ms("cli_restart"),!0):!1}catch(n){return jW.error("Failed to restart CLI",n),!1}return!1}function zW(e){const t=e.filter(n=>n.scope!=="loopback");return{recommended:t[0]??null,hidden:t.slice(1)}}var WW=O("<span class=remote-toggle-state>"),HW=O("<div class=remote-toggle-copy><span class=remote-toggle-title></span><span class=remote-toggle-caption>"),qS=O('<div class=settings-form-group><label class=settings-form-label></label><input class="selector-input w-full"type=password>'),GW=O("<div class=settings-password-actions><button class=settings-pill-button type=button>"),ZW=O("<div class=settings-card-content><div class=settings-password-summary-row><div class=settings-password-summary-copy><p class=settings-help-text></p><p class=settings-help-text></p></div><div class=settings-password-actions><button class=settings-pill-button type=button>"),YW=O("<div class=remote-address-disclosure-content>"),JW=O("<div class=remote-address-disclosure><button class=remote-address-disclosure-trigger type=button><span class=remote-address-disclosure-label>"),QW=O("<div class=remote-address-list>"),XW=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><div class=settings-toolbar-inline><span class="settings-scope-badge settings-scope-badge-server"></span><button class="selector-button selector-button-secondary w-auto"type=button><span></span></button></div></div><p class=remote-toggle-note></p></div><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server"></span></div></div><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server">'),e7=O("<div class=settings-card-message>"),t7=O("<div class=settings-error-message>"),zS=O("<div class=remote-card>"),n7=O("<div class=remote-error>"),Ch=O("<div class=remote-qr>"),s7=O("<div class=remote-address><div class=remote-address-main><div><p class=remote-address-url></p><p class=remote-address-meta></p></div><div class=remote-actions><button class=remote-pill type=button></button><button class=remote-pill type=button>"),Eh=O("<img class=remote-qr-img>"),WS=O("<div class=remote-address><div class=remote-address-main><div><p class=remote-address-url></p><p class=remote-address-meta> - <!> - </p></div><div class=remote-actions><button class=remote-pill type=button></button><button class=remote-pill type=button>");const HS=Ut("actions"),r7=()=>{const{t:e}=Dt(),[t,n]=R(null),[s,r]=R(null),[o,a]=R(!1),[i,c]=R(!1),[l,d]=R({}),[u,f]=R(null),[g,m]=R(null),[w,S]=R(!1),[b,v]=R(""),[k,C]=R(""),[_,T]=R(null),[P,I]=R(!1),[j,ne]=R(!1),W=Te(()=>{var ge;return((ge=t())==null?void 0:ge.addresses)??[]}),q=Te(()=>{var ge;return((ge=t())==null?void 0:ge.listeningMode)??ef().listeningMode}),U=Te(()=>q()==="all"),G=Te(()=>{const ge=W();return U()?zW(ge):{recommended:null,hidden:[]}}),le=async()=>{a(!0),m(null),T(null);try{const[ge,Ie]=await Promise.all([kt.fetchServerMeta(),kt.fetchAuthStatus()]);n(ge),r(Ie),ne(!1)}catch(ge){m(ge instanceof Error?ge.message:String(ge))}finally{a(!1)}};Ys(()=>{le()});const K=async ge=>{if(u()===ge){f(null);return}if(f(ge),!l()[ge])try{const Ie=await VW(ge,{margin:1,scale:4});d(ke=>({...ke,[ge]:Ie}))}catch(Ie){HS.error("Failed to generate QR code",Ie)}},M=async ge=>{const Ie=ge?"all":"local";if(!(Ie===q()||i()||!await ca(e("remoteAccess.listeningMode.restartConfirm.message"),{title:e(ge?"remoteAccess.listeningMode.restartConfirm.title.all":"remoteAccess.listeningMode.restartConfirm.title.local"),variant:"warning",confirmLabel:e("remoteAccess.listeningMode.restartConfirm.confirmLabel"),cancelLabel:e("remoteAccess.listeningMode.restartConfirm.cancelLabel"),dismissible:!1}))){c(!0),m(null);try{await mM(Ie),await qW()?n(Ae=>Ae&&{...Ae,listeningMode:Ie}):m(e("remoteAccess.restart.errorManual"))}catch(we){m(we instanceof Error?we.message:String(we))}finally{c(!1)}le()}},N=ge=>{try{window.open(ge,"_blank","noopener,noreferrer")}catch(Ie){HS.error("Failed to open URL",Ie)}},oe=async()=>{T(null);const ge=b(),Ie=k();if(ge.trim().length<8){T(e("remoteAccess.password.error.tooShort"));return}if(ge!==Ie){T(e("remoteAccess.password.error.mismatch"));return}I(!0);try{const ke=await kt.setServerPassword(ge);r({authenticated:!0,username:ke.username,passwordUserProvided:ke.passwordUserProvided}),v(""),C(""),S(!1)}catch(ke){T(ke instanceof Error?ke.message:String(ke))}finally{I(!1)}};return(()=>{var ge=XW(),Ie=ge.firstChild,ke=Ie.firstChild,we=ke.firstChild,Ae=we.firstChild,Ge=Ae.firstChild,H=Ge.nextSibling,h=we.nextSibling,$=h.firstChild,D=$.nextSibling,E=D.firstChild,Z=ke.nextSibling,B=Ie.nextSibling,se=B.firstChild,pe=se.firstChild,Se=pe.firstChild,Q=Se.firstChild,be=Q.nextSibling,Ve=pe.nextSibling,He=B.nextSibling,re=He.firstChild,F=re.firstChild,V=F.firstChild,Me=V.firstChild,xe=Me.nextSibling,Re=F.nextSibling;return p(we,y(Zd,{class:"settings-card-heading-icon"}),Ae),p(Ge,()=>e("remoteAccess.sections.listeningMode.label")),p(H,()=>e("remoteAccess.sections.listeningMode.help")),p($,()=>e("settings.scope.server")),D.$$click=()=>void le(),p(D,y(Gd,{get class(){return`w-4 h-4 ${o()?"remote-spin":""}`}}),E),p(E,()=>e("remoteAccess.refresh")),p(Ie,y(Cc,{class:"remote-toggle",get checked(){return U()},onChange:Be=>void M(Be),get disabled(){return o()||i()},get children(){return[y(Cc.Input,{}),y(Cc.Control,{class:"remote-toggle-switch",get"data-checked"(){return U()},get children(){return[(()=>{var Be=WW();return p(Be,(()=>{var et=Ee(()=>!!U());return()=>et()?e("remoteAccess.toggle.on"):e("remoteAccess.toggle.off")})()),Be})(),y(Cc.Thumb,{class:"remote-toggle-thumb"})]}}),(()=>{var Be=HW(),et=Be.firstChild,Ue=et.nextSibling;return p(et,()=>e("remoteAccess.toggle.title")),p(Ue,(()=>{var We=Ee(()=>!!U());return()=>We()?e("remoteAccess.toggle.caption.all"):e("remoteAccess.toggle.caption.local")})()),Be})()]}}),Z),p(Z,()=>e("remoteAccess.toggle.note")),p(pe,y(Zd,{class:"settings-card-heading-icon"}),Se),p(Q,()=>e("remoteAccess.sections.serverPassword.label")),p(be,()=>e("remoteAccess.sections.serverPassword.help")),p(Ve,()=>e("settings.scope.server")),p(B,y(ee,{get when(){return Ee(()=>!!s())()&&s().authenticated},get fallback(){return(()=>{var Be=e7();return p(Be,()=>e("remoteAccess.authStatus.unavailable")),Be})()},get children(){var Be=ZW(),et=Be.firstChild,Ue=et.firstChild,We=Ue.firstChild,st=We.nextSibling,at=Ue.nextSibling,ht=at.firstChild;return p(We,()=>e("remoteAccess.username",{username:s().username??"codenomad"})),p(st,(()=>{var ut=Ee(()=>!!s().passwordUserProvided);return()=>ut()?e("remoteAccess.password.status.set"):e("remoteAccess.password.status.unset")})()),ht.$$click=()=>{S(!w()),T(null)},p(ht,(()=>{var ut=Ee(()=>!!w());return()=>ut()?e("remoteAccess.password.actions.cancel"):Ee(()=>!!s().passwordUserProvided)()?e("remoteAccess.password.actions.change"):e("remoteAccess.password.actions.set")})()),p(Be,y(ee,{get when(){return w()},get children(){return[(()=>{var ut=qS(),Ct=ut.firstChild,Qe=Ct.nextSibling;return p(Ct,()=>e("remoteAccess.password.form.newPassword")),Qe.$$input=tt=>v(tt.currentTarget.value),de(()=>me(Qe,"placeholder",e("remoteAccess.password.form.placeholder"))),de(()=>Qe.value=b()),ut})(),(()=>{var ut=qS(),Ct=ut.firstChild,Qe=Ct.nextSibling;return p(Ct,()=>e("remoteAccess.password.form.confirmPassword")),Qe.$$input=tt=>C(tt.currentTarget.value),de(()=>Qe.value=k()),ut})(),y(ee,{get when(){return _()},children:ut=>(()=>{var Ct=t7();return p(Ct,ut),Ct})()}),(()=>{var ut=GW(),Ct=ut.firstChild;return Ct.$$click=()=>void oe(),p(Ct,(()=>{var Qe=Ee(()=>!!P());return()=>Qe()?e("remoteAccess.password.save.saving"):e("remoteAccess.password.save.label")})()),de(()=>Ct.disabled=P()),ut})()]}}),null),Be}}),null),p(F,y(iP,{class:"settings-card-heading-icon"}),V),p(Me,()=>e("remoteAccess.sections.addresses.label")),p(xe,()=>e("remoteAccess.sections.addresses.help")),p(Re,()=>e("settings.scope.server")),p(He,y(ee,{get when(){return!o()},get fallback(){return(()=>{var Be=zS();return p(Be,()=>e("remoteAccess.addresses.loading")),Be})()},get children(){return y(ee,{get when(){return!g()},get fallback(){return(()=>{var Be=n7();return p(Be,g),Be})()},get children(){return y(ee,{get when(){var Be;return!!G().recommended||((Be=t())==null?void 0:Be.localUrl)},get fallback(){return(()=>{var Be=zS();return p(Be,()=>e("remoteAccess.addresses.none")),Be})()},get children(){var Be=QW();return p(Be,y(ee,{get when(){var et;return(et=t())==null?void 0:et.localUrl},children:et=>{const Ue=()=>et(),We=()=>u()===Ue(),st=()=>l()[Ue()];return(()=>{var at=s7(),ht=at.firstChild,ut=ht.firstChild,Ct=ut.firstChild,Qe=Ct.nextSibling,tt=ut.nextSibling,At=tt.firstChild,xt=At.nextSibling;return p(Ct,Ue),p(Qe,()=>e("remoteAccess.address.scope.loopback")),At.$$click=()=>N(Ue()),p(At,y(Yi,{class:"remote-icon"}),null),p(At,()=>e("remoteAccess.address.open"),null),xt.$$click=()=>void K(Ue()),p(xt,y(Td,{class:"remote-icon"}),null),p(xt,(()=>{var x=Ee(()=>!!We());return()=>x()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(at,y(ee,{get when(){return We()},get children(){var x=Ch();return p(x,y(ee,{get when(){return st()},get fallback(){return y(Zn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:A=>(()=>{var L=Eh();return de(X=>{var Y=A(),ue=e("remoteAccess.address.qrAlt",{url:Ue()});return Y!==X.e&&me(L,"src",X.e=Y),ue!==X.t&&me(L,"alt",X.t=ue),X},{e:void 0,t:void 0}),L})()})),x}}),null),de(()=>me(xt,"aria-expanded",We())),at})()}}),null),p(Be,y(ee,{get when(){return G().recommended},children:et=>{const Ue=et(),We=Ue.remoteUrl,st=()=>u()===We,at=()=>l()[We],ht=()=>Ue.scope==="external"?e("remoteAccess.address.scope.network"):Ue.scope==="loopback"?e("remoteAccess.address.scope.loopback"):e("remoteAccess.address.scope.internal");return(()=>{var ut=WS(),Ct=ut.firstChild,Qe=Ct.firstChild,tt=Qe.firstChild,At=tt.nextSibling,xt=At.firstChild,x=xt.nextSibling;x.nextSibling;var A=Qe.nextSibling,L=A.firstChild,X=L.nextSibling;return p(tt,We),p(At,()=>Ue.family.toUpperCase(),xt),p(At,ht,x),p(At,()=>Ue.ip,null),L.$$click=()=>N(We),p(L,y(Yi,{class:"remote-icon"}),null),p(L,()=>e("remoteAccess.address.open"),null),X.$$click=()=>void K(We),p(X,y(Td,{class:"remote-icon"}),null),p(X,(()=>{var Y=Ee(()=>!!st());return()=>Y()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(ut,y(ee,{get when(){return st()},get children(){var Y=Ch();return p(Y,y(ee,{get when(){return at()},get fallback(){return y(Zn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:ue=>(()=>{var ce=Eh();return de(ve=>{var je=ue(),Ke=e("remoteAccess.address.qrAlt",{url:We});return je!==ve.e&&me(ce,"src",ve.e=je),Ke!==ve.t&&me(ce,"alt",ve.t=Ke),ve},{e:void 0,t:void 0}),ce})()})),Y}}),null),de(()=>me(X,"aria-expanded",st())),ut})()}}),null),p(Be,y(ee,{get when(){return G().hidden.length>0},get children(){var et=JW(),Ue=et.firstChild,We=Ue.firstChild;return Ue.$$click=()=>ne(!j()),p(We,(()=>{var st=Ee(()=>!!j());return()=>st()?e("remoteAccess.addresses.actions.hideOther"):e("remoteAccess.addresses.actions.showOther",{count:String(G().hidden.length)})})()),p(Ue,y(jA,{class:"remote-address-disclosure-chevron disclosure-chevron"}),null),p(et,y(ee,{get when(){return j()},get children(){var st=YW();return p(st,y(zt,{get each(){return G().hidden},children:at=>{const ht=at.remoteUrl,ut=()=>u()===ht,Ct=()=>l()[ht],Qe=()=>at.scope==="external"?e("remoteAccess.address.scope.network"):at.scope==="loopback"?e("remoteAccess.address.scope.loopback"):e("remoteAccess.address.scope.internal");return(()=>{var tt=WS(),At=tt.firstChild,xt=At.firstChild,x=xt.firstChild,A=x.nextSibling,L=A.firstChild,X=L.nextSibling;X.nextSibling;var Y=xt.nextSibling,ue=Y.firstChild,ce=ue.nextSibling;return p(x,ht),p(A,()=>at.family.toUpperCase(),L),p(A,Qe,X),p(A,()=>at.ip,null),ue.$$click=()=>N(ht),p(ue,y(Yi,{class:"remote-icon"}),null),p(ue,()=>e("remoteAccess.address.open"),null),ce.$$click=()=>void K(ht),p(ce,y(Td,{class:"remote-icon"}),null),p(ce,(()=>{var ve=Ee(()=>!!ut());return()=>ve()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(tt,y(ee,{get when(){return ut()},get children(){var ve=Ch();return p(ve,y(ee,{get when(){return Ct()},get fallback(){return y(Zn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:je=>(()=>{var Ke=Eh();return de(rt=>{var ot=je(),Pt=e("remoteAccess.address.qrAlt",{url:ht});return ot!==rt.e&&me(Ke,"src",rt.e=ot),Pt!==rt.t&&me(Ke,"alt",rt.t=Pt),rt},{e:void 0,t:void 0}),Ke})()})),ve}}),null),de(()=>me(ce,"aria-expanded",ut())),tt})()}})),st}}),null),de(st=>{var at=j(),ht=j();return at!==st.e&&me(et,"data-expanded",st.e=at),ht!==st.t&&me(Ue,"aria-expanded",st.t=ht),st},{e:void 0,t:void 0}),et}}),null),Be}})}})}}),null),de(()=>D.disabled=o()),ge})()};Xt(["click","input"]);async function o7(e,t,n){if(!ia())throw new Error("Remote server windows can only be opened from a local desktop window");const s={id:e.id,name:e.name,baseUrl:e.baseUrl,entryUrl:t,proxySessionId:n,skipTlsVerify:e.skipTlsVerify};if(Bn()){const r=window.electronAPI;if(typeof(r==null?void 0:r.openRemoteWindow)=="function"){await r.openRemoteWindow(s);return}}if(Dn()){if(n!==void 0&&(t??e.baseUrl).startsWith("https://")&&await Ms("needs_local_certificate_install")&&!await ca($e("folderSelection.servers.certificateInstall.confirmMessage"),{title:$e("folderSelection.servers.certificateInstall.title"),variant:"warning",confirmLabel:$e("folderSelection.servers.certificateInstall.confirmLabel"),cancelLabel:$e("folderSelection.servers.certificateInstall.cancelLabel")}))throw new Error($e("folderSelection.servers.certificateInstall.cancelled"));await Ms("open_remote_window",{payload:s});return}window.open(e.baseUrl,"_blank","noopener,noreferrer")}function i7(){const{t:e}=Dt(),{remoteServers:t,saveRemoteServerProfile:n,markRemoteServerConnected:s,removeRemoteServerProfile:r}=Un(),[o,a]=R(null),i=async(l,d)=>{if(d&&!ia())throw new Error("Remote server windows can only be opened from a local desktop window");const u=l.name.trim(),f=l.baseUrl.trim();if(!u||!f)throw new Error(e("folderSelection.servers.dialog.errorRequired"));const g=await kt.probeRemoteServer({baseUrl:f,skipTlsVerify:l.skipTlsVerify});if(!g.ok)throw new Error(g.error||e("folderSelection.servers.dialog.errorConnect"));const m=await n({id:l.id,name:u,baseUrl:g.normalizedUrl,skipTlsVerify:l.skipTlsVerify});if(d){const w=Dn()&&m.skipTlsVerify&&m.baseUrl.startsWith("https://")?await kt.createRemoteProxySession({baseUrl:m.baseUrl,skipTlsVerify:!0}):void 0;try{await o7(m,w==null?void 0:w.windowUrl,w==null?void 0:w.sessionId)}catch(S){throw w&&kt.deleteRemoteProxySession(w.sessionId).catch(()=>{}),S}await s(m.id)}return m};return{remoteServers:t,connectingServerId:o,saveServer:i,connectSavedServer:async l=>{if(!ia()||o())return;const d=t().find(u=>u.id===l);if(d){a(l);try{await i(d,!0)}catch(u){Ns(u instanceof Error?u.message:String(u),{title:e("folderSelection.servers.errorTitle"),variant:"warning"})}finally{a(null)}}},removeRemoteServerProfile:r}}var a7=O("<div>"),GS=O('<label class="flex flex-col gap-2 text-sm text-secondary"><span></span><input class="selector-input w-full">'),c7=O('<label class="flex items-start gap-3 text-sm text-secondary"><input type=checkbox><span>'),l7=O('<span class="inline-flex items-center gap-2">'),d7=O('<div class="flex items-center justify-end gap-3"><button type=button class="selector-button selector-button-secondary w-auto px-4"></button><button type=button class="selector-button selector-button-secondary w-auto px-4"></button><button type=button class="selector-button selector-button-secondary w-auto px-4">'),u7=O('<div class="fixed inset-0 z-[1300] flex items-center justify-center p-4">'),f7=O('<p class="text-sm text-red-500 break-words">'),g7=O("<span>");const h7=e=>{const{t}=Dt(),[n,s]=R(""),[r,o]=R(""),[a,i]=R(!1),[c,l]=R(null),[d,u]=R(!1);Ze(()=>{e.open&&(s(""),o(""),i(!1),l(null))});const f=async g=>{if(!d()){u(!0),l(null);try{await e.onSubmit({name:n(),baseUrl:r(),skipTlsVerify:a()},g),e.onOpenChange(!1)}catch(m){l(m instanceof Error?m.message:String(m))}finally{u(!1)}}};return y(Ot,{get open(){return e.open},get onOpenChange(){return e.onOpenChange},get children(){return y(Ot.Portal,{get children(){return[y(Ot.Overlay,{class:"modal-overlay"}),(()=>{var g=u7();return p(g,y(Ot.Content,{class:"modal-surface w-full max-w-lg p-6 flex flex-col gap-5",tabIndex:-1,get children(){return[(()=>{var m=a7();return p(m,y(Ot.Title,{class:"text-xl font-semibold text-primary",get children(){return t("folderSelection.servers.dialog.title")}}),null),p(m,y(Ot.Description,{class:"text-sm text-secondary mt-2",get children(){return t("folderSelection.servers.dialog.description")}}),null),m})(),(()=>{var m=GS(),w=m.firstChild,S=w.nextSibling;return p(w,()=>t("folderSelection.servers.dialog.name")),S.$$input=b=>s(b.currentTarget.value),de(()=>me(S,"placeholder",t("folderSelection.servers.dialog.namePlaceholder"))),de(()=>S.value=n()),m})(),(()=>{var m=GS(),w=m.firstChild,S=w.nextSibling;return p(w,()=>t("folderSelection.servers.dialog.url")),S.$$input=b=>o(b.currentTarget.value),de(()=>me(S,"placeholder",t("folderSelection.servers.dialog.urlPlaceholder"))),de(()=>S.value=r()),m})(),(()=>{var m=c7(),w=m.firstChild,S=w.nextSibling;return w.addEventListener("change",b=>i(b.currentTarget.checked)),p(S,()=>t("folderSelection.servers.dialog.skipTls")),de(()=>w.checked=a()),m})(),y(ee,{get when(){return c()},children:m=>(()=>{var w=f7();return p(w,m),w})()}),(()=>{var m=d7(),w=m.firstChild,S=w.nextSibling,b=S.nextSibling;return w.$$click=()=>e.onOpenChange(!1),p(w,()=>t("folderSelection.servers.dialog.cancel")),S.$$click=()=>void f(!1),p(S,()=>t("folderSelection.servers.dialog.save")),b.$$click=()=>void f(!0),p(b,y(ee,{get when(){return d()},get fallback(){return(()=>{var v=g7();return p(v,()=>t("folderSelection.servers.dialog.connect")),v})()},get children(){var v=l7();return p(v,y(Zn,{class:"w-4 h-4 animate-spin"}),null),p(v,()=>t("folderSelection.servers.dialog.connecting"),null),v}})),de(v=>{var k=d(),C=d();return k!==v.e&&(S.disabled=v.e=k),C!==v.t&&(b.disabled=v.t=C),v},{e:void 0,t:void 0}),m})()]}})),g})()]}})}})};Xt(["input","click"]);var m7=O('<div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><button type=button class="selector-button selector-button-secondary w-auto"><span></span></button></div><div class=settings-card-content>'),p7=O("<div class=settings-card-message>"),y7=O('<div class="settings-toggle-row settings-toggle-row-compact"><div class=min-w-0><div class="settings-toggle-title truncate"></div><div class="settings-toggle-caption font-mono truncate"></div></div><div class="flex items-center gap-2"><button type=button class="selector-button selector-button-secondary w-auto"></button><button type=button class="selector-button selector-button-secondary w-auto">');const v7=()=>{const{t:e}=Dt(),{remoteServers:t,connectingServerId:n,saveServer:s,connectSavedServer:r,removeRemoteServerProfile:o}=i7(),[a,i]=R(!1);return[(()=>{var c=m7(),l=c.firstChild,d=l.firstChild,u=d.firstChild,f=u.firstChild,g=f.nextSibling,m=d.nextSibling,w=m.firstChild,S=l.nextSibling;return p(d,y(ei,{class:"settings-card-heading-icon"}),u),p(f,()=>e("folderSelection.tabs.servers")),p(g,()=>e("folderSelection.servers.empty.description")),m.$$click=()=>i(!0),p(m,y(of,{class:"w-4 h-4"}),w),p(w,()=>e("folderSelection.actions.connectButton")),p(S,y(ee,{get when(){return t().length>0},get fallback(){return(()=>{var b=p7();return p(b,()=>e("folderSelection.servers.empty.title")),b})()},get children(){return y(zt,{get each(){return t()},children:b=>(()=>{var v=y7(),k=v.firstChild,C=k.firstChild,_=C.nextSibling,T=k.nextSibling,P=T.firstChild,I=P.nextSibling;return p(C,()=>b.name),p(_,()=>b.baseUrl),P.$$click=()=>void r(b.id),p(P,y(ee,{get when(){return n()===b.id},get fallback(){return y(ei,{class:"w-4 h-4"})},get children(){return y(Zn,{class:"w-4 h-4 animate-spin"})}})),I.$$click=()=>o(b.id),p(I,y(af,{class:"w-4 h-4"})),de(j=>{var ne=!!n(),W=`${e("folderSelection.servers.dialog.connect")}: ${b.name}`,q=`${e("folderSelection.servers.dialog.connect")}: ${b.name}`,U=`${e("folderSelection.servers.remove")}: ${b.name}`,G=`${e("folderSelection.servers.remove")}: ${b.name}`;return ne!==j.e&&(P.disabled=j.e=ne),W!==j.t&&me(P,"aria-label",j.t=W),q!==j.a&&me(P,"title",j.a=q),U!==j.o&&me(I,"title",j.o=U),G!==j.i&&me(I,"aria-label",j.i=G),j},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),v})()})}})),c})(),y(h7,{get open(){return a()},onOpenChange:i,onSubmit:s})]};Xt(["click"]);const w7=Ut("api");function Ju(e){return`/sidecars/${encodeURIComponent(e)}/`}const[qT,Cw]=R(new Map),[b7,_g]=R([]),[Ew,Tw]=R(null),[S7,Th]=R(!1);let Vo=null,k7=0;class x7 extends Error{constructor(t){super(t),this.name="SidecarNotFoundError"}}async function zT(e){if(!Vo){Th(!0);const n=kt.fetchSidecars().then(s=>{Cw(new Map(s.sidecars.map(r=>[r.id,r])))});Vo=n,n.then(()=>{Th(!1),Vo===n&&(Vo=null)},s=>{w7.error("Failed to load SideCars",s),Th(!1),Vo===n&&(Vo=null)})}const t=Vo;if(e!=null&&e.propagateErrors)return t;await t.catch(()=>{})}function _7(e){Cw(t=>{const n=new Map(t);return n.set(e.id,e),n}),_g(t=>t.map(n=>n.sidecarId===e.id?{...n,name:e.name,port:e.port,prefixMode:e.prefixMode,proxyBasePath:Ju(e.id).replace(/\/$/,""),shellUrl:Ju(e.id)}:n))}function $7(e){Cw(t=>{const n=new Map(t);return n.delete(e),n}),_g(t=>{var s;const n=t.filter(r=>r.sidecarId!==e);return n.some(r=>r.token===Ew())||Tw(((s=n[0])==null?void 0:s.token)??null),n})}xs.on("sidecar.updated",e=>{e.type==="sidecar.updated"&&_7(e.sidecar)});xs.on("sidecar.removed",e=>{e.type==="sidecar.removed"&&$7(e.sidecarId)});async function fZ(e,t){var o,a;if((o=t==null?void 0:t.signal)!=null&&o.aborted)throw na(t.signal);await E8(()=>zT({propagateErrors:t==null?void 0:t.propagateLoadErrors}),{signal:t==null?void 0:t.signal});const n=qT().get(e);if(!n)throw new x7($e("sidecars.open.notFound"));if(n.status!=="running")throw new Error($e("sidecars.open.notRunning"));const r={token:`${e}:${Date.now().toString(36)}:${(k7++).toString(36)}`,sidecarId:e,name:n.name,port:n.port,prefixMode:n.prefixMode,proxyBasePath:Ju(e).replace(/\/$/,""),shellUrl:Ju(e)};if((a=t==null?void 0:t.signal)!=null&&a.aborted)throw na(t.signal);return _g(i=>[...i,r]),((t==null?void 0:t.activate)??!0)&&Tw(r.token),r}function gZ(e){_g(t=>{const n=t.findIndex(r=>r.token===e);if(n<0)return t;const s=t.filter(r=>r.token!==e);if(Ew()===e){const r=s[n-1]??s[n]??null;Tw((r==null?void 0:r.token)??null)}return s})}Te(()=>b7().find(e=>e.token===Ew())??null);var ZS=O('<div class="text-sm text-red-500">'),C7=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server"></span></div><div class=settings-card-content><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>: <code>/sidecars/</code></div></div><input class="selector-input w-full max-w-xs"></div><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>127.0.0.1</div></div><input class="selector-input w-full max-w-xs"inputmode=numeric></div><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><select class="selector-input w-full max-w-xs"><option value=https></option><option value=http></option></select></div><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><select class="selector-input w-full max-w-xs"><option value=strip></option><option value=preserve></option></select></div><div class="flex justify-end"><button type=button class="selector-button selector-button-primary w-auto"><span></span></button></div></div></div><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><div class=settings-card-content>'),YS=O("<div class=settings-card-message>"),E7=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption> · <!>://127.0.0.1:</div><div class=settings-toggle-caption>: <code>/sidecars/</code> · </div></div><div class="flex items-center gap-2"><span class="text-xs text-secondary min-w-[4.5rem] text-right"></span><button type=button class="selector-button selector-button-secondary w-auto">');function T7(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")}const M7=()=>{const{t:e}=Dt(),[t,n]=R(""),[s,r]=R("3000"),[o,a]=R(!1),[i,c]=R("strip"),[l,d]=R(null),[u,f]=R(!1),[g,m]=R(null),[w,S]=R(null);Ys(()=>{zT()});const b=Te(()=>Array.from(qT().values()).sort((_,T)=>_.name.localeCompare(T.name))),v=Te(()=>T7(t())||"your-sidecar");async function k(){const _=t().trim(),T=Number(s());if(!_||!Number.isInteger(T)||T<=0||T>65535){m(e("sidecars.form.validation"));return}f(!0),m(null);try{await kt.createSidecar({kind:"port",name:_,port:T,insecure:o(),prefixMode:i()}),n(""),r("3000"),a(!1),c("strip")}catch(P){m(P instanceof Error?P.message:String(P))}finally{f(!1)}}async function C(_){d(_),S(null);try{await kt.deleteSidecar(_)}catch(T){S(T instanceof Error?T.message:String(T))}finally{d(null)}}return(()=>{var _=C7(),T=_.firstChild,P=T.firstChild,I=P.firstChild,j=I.firstChild,ne=j.firstChild,W=ne.nextSibling,q=I.nextSibling,U=P.nextSibling,G=U.firstChild,le=G.firstChild,K=le.firstChild,M=K.nextSibling,N=M.firstChild,oe=N.nextSibling;oe.firstChild;var ge=le.nextSibling,Ie=G.nextSibling,ke=Ie.firstChild,we=ke.firstChild,Ae=ke.nextSibling,Ge=Ie.nextSibling,H=Ge.firstChild,h=H.firstChild,$=h.nextSibling,D=H.nextSibling,E=D.firstChild,Z=E.nextSibling,B=Ge.nextSibling,se=B.firstChild,pe=se.firstChild,Se=pe.nextSibling,Q=se.nextSibling,be=Q.firstChild,Ve=be.nextSibling,He=B.nextSibling,re=He.firstChild,F=re.firstChild,V=T.nextSibling,Me=V.firstChild,xe=Me.firstChild,Re=xe.firstChild,Be=Re.nextSibling,et=Me.nextSibling;return p(I,y(ei,{class:"settings-card-heading-icon"}),j),p(ne,()=>e("settings.section.sidecars.title")),p(W,()=>e("settings.section.sidecars.subtitle")),p(q,()=>e("settings.scope.server")),p(K,()=>e("sidecars.form.name")),p(M,()=>e("sidecars.basePath"),N),p(oe,v,null),ge.$$input=Ue=>{m(null),n(Ue.currentTarget.value)},p(we,()=>e("sidecars.form.port")),Ae.$$input=Ue=>{m(null),r(Ue.currentTarget.value)},p(h,()=>e("sidecars.form.protocol")),p($,()=>e("sidecars.form.protocol.help")),D.addEventListener("change",Ue=>a(Ue.currentTarget.value==="http")),p(E,()=>e("sidecars.form.protocol.https")),p(Z,()=>e("sidecars.form.protocol.http")),p(pe,()=>e("sidecars.form.prefixMode")),p(Se,()=>e("sidecars.form.prefixMode.help")),Q.addEventListener("change",Ue=>c(Ue.currentTarget.value)),p(be,()=>e("sidecars.form.prefixMode.strip")),p(Ve,()=>e("sidecars.form.prefixMode.preserve")),p(U,y(ee,{get when(){return g()},get children(){var Ue=ZS();return p(Ue,g),Ue}}),He),re.$$click=()=>void k(),p(re,y(ee,{get when(){return u()},get fallback(){return y(of,{class:"w-4 h-4"})},get children(){return y(Zn,{class:"w-4 h-4 animate-spin"})}}),F),p(F,()=>e("sidecars.form.add")),p(Re,()=>e("sidecars.settings.listTitle")),p(Be,()=>e("sidecars.settings.listSubtitle")),p(et,y(ee,{get when(){return w()},get children(){var Ue=ZS();return p(Ue,w),Ue}}),null),p(et,y(ee,{get when(){return!S7()},get fallback(){return(()=>{var Ue=YS();return p(Ue,()=>e("sidecars.picker.loading")),Ue})()},get children(){return y(ee,{get when(){return b().length>0},get fallback(){return(()=>{var Ue=YS();return p(Ue,()=>e("sidecars.settings.empty")),Ue})()},get children(){return y(zt,{get each(){return b()},children:Ue=>(()=>{var We=E7(),st=We.firstChild,at=st.firstChild,ht=at.nextSibling,ut=ht.firstChild,Ct=ut.nextSibling;Ct.nextSibling;var Qe=ht.nextSibling,tt=Qe.firstChild,At=tt.nextSibling;At.firstChild,At.nextSibling;var xt=st.nextSibling,x=xt.firstChild,A=x.nextSibling;return p(at,()=>Ue.name),p(ht,()=>e("sidecars.kind.port"),ut),p(ht,()=>Ue.insecure?"http":"https",Ct),p(ht,()=>Ue.port,null),p(Qe,()=>e("sidecars.basePath"),tt),p(At,()=>Ue.id,null),p(Qe,()=>e(`sidecars.form.prefixMode.${Ue.prefixMode}`),null),p(x,()=>e(`sidecars.status.${Ue.status}`)),A.$$click=()=>void C(Ue.id),p(A,y(af,{class:"w-4 h-4"})),de(()=>A.disabled=l()===Ue.id),We})()})}})}}),null),de(()=>re.disabled=u()),de(()=>ge.value=t()),de(()=>Ae.value=s()),de(()=>D.value=o()?"http":"https"),de(()=>Q.value=i()),_})()};Xt(["input","click"]);async function Ec(e){if($n.host==="electron"){const t=window.electronAPI,n=e==="minimize"?t==null?void 0:t.minimizeWindow:e==="maximize"?t==null?void 0:t.toggleMaximizeWindow:t==null?void 0:t.closeWindow;if(!n)throw new Error(`Native window action is unavailable: ${e}`);await n();return}$n.host==="tauri"&&await Ms("window_control",{action:e})}async function A7(){$n.host==="tauri"&&await Ms("window_control",{action:"drag"})}async function D7(e,t){var r;const n=t.getBoundingClientRect(),s={x:n.left,y:n.bottom};if($n.host==="electron"){if(!((r=window.electronAPI)!=null&&r.showTitlebarMenu))throw new Error("Native titlebar menus are unavailable");await window.electronAPI.showTitlebarMenu(e,s.x,s.y)}else $n.host==="tauri"&&await Ms("popup_titlebar_menu",{menu:e,...s})}var P7=O("<nav class=native-titlebar-menu data-titlebar-interactive>"),I7=O('<header class=native-titlebar><div class=native-titlebar-brand><span class=native-titlebar-title></span></div><div class=native-titlebar-drag-region></div><div class=native-titlebar-controls><button type=button class=native-titlebar-button data-titlebar-interactive></button><button type=button class=native-titlebar-button data-titlebar-interactive></button><button type=button class="native-titlebar-button native-titlebar-close"data-titlebar-interactive>'),R7=O("<button type=button class=native-titlebar-menu-button>");const O7=["file","edit","view","window","help"],L7=e=>{const{t}=Dt(),n=()=>e.onClose?e.onClose():Ec("close");return(()=>{var s=I7(),r=s.firstChild,o=r.firstChild,a=r.nextSibling,i=a.nextSibling,c=i.firstChild,l=c.nextSibling,d=l.nextSibling;return s.$$dblclick=u=>{u.target.closest("[data-titlebar-interactive]")||Ec("maximize")},s.$$pointerdown=u=>{u.button===0&&!u.target.closest("[data-titlebar-interactive]")&&A7()},p(o,()=>e.title),p(s,y(ee,{get when(){return e.menus},get children(){var u=P7();return p(u,y(zt,{each:O7,children:f=>(()=>{var g=R7();return g.$$click=m=>void D7(f,m.currentTarget),p(g,()=>t(`window.menu.${f}`)),g})()})),de(()=>me(u,"aria-label",t("window.menu.ariaLabel"))),u}}),a),c.$$click=()=>void Ec("minimize"),p(c,y(ID,{"aria-hidden":"true"})),l.$$click=()=>void Ec("maximize"),p(l,y(TD,{"aria-hidden":"true"})),d.$$click=()=>void n(),p(d,y(ti,{"aria-hidden":"true"})),de(u=>{var f=t("window.controls.minimize"),g=t("window.controls.minimize"),m=t("window.controls.maximize"),w=t("window.controls.maximize"),S=t("window.controls.close"),b=t("window.controls.close");return f!==u.e&&me(c,"aria-label",u.e=f),g!==u.t&&me(c,"title",u.t=g),m!==u.a&&me(l,"aria-label",u.a=m),w!==u.o&&me(l,"title",u.o=w),S!==u.i&&me(d,"aria-label",u.i=S),b!==u.n&&me(d,"title",u.n=b),u},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),s})()};Xt(["pointerdown","dblclick","click"]);function N7(e,t,n){Ze(()=>{const s=t(),r=e();if(!s||!r)return;let o=!0,a=0;const i=s.scrollTop??0,c=()=>{o&&(r.scrollTop=i,r.scrollHeight-r.clientHeight>=i&&(cancelAnimationFrame(a),a=requestAnimationFrame(()=>{o=!1})))},l=()=>{o=!1,cancelAnimationFrame(a)},d=g=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(g.key)&&l()},u=()=>{o||n(Math.round(r.scrollTop))},f=new ResizeObserver(c);f.observe(r);for(const g of r.children)f.observe(g);r.addEventListener("scroll",u),r.addEventListener("wheel",l,{passive:!0}),r.addEventListener("pointerdown",l),r.addEventListener("keydown",d),c(),dt(()=>{f.disconnect(),cancelAnimationFrame(a),r.removeEventListener("scroll",u),r.removeEventListener("wheel",l),r.removeEventListener("pointerdown",l),r.removeEventListener("keydown",d)})})}var F7=O("<div class=settings-section-stack>"),B7=O("<h1 class=sr-only>"),U7=O('<div class="flex-1 min-w-0">'),K7=O('<button type=button class="window-icon-button settings-screen-close settings-screen-compact-close">'),V7=O('<aside class=settings-screen-nav><div class="window-toolbar settings-screen-compact-bar"><span class=settings-screen-compact-icon-wrap></span><div class=settings-section-selector-wrap></div></div><div class="window-header settings-screen-nav-header settings-screen-drag-handle"><div class=settings-screen-nav-title-row><span class=settings-screen-nav-icon-wrap></span><div><h2 class="window-title settings-screen-title"></h2></div></div></div><nav class=settings-screen-nav-list>'),j7=O('<button type=button class="window-icon-button settings-screen-close">'),q7=O('<div class=settings-screen-content><header class="window-header settings-screen-content-header settings-screen-drag-handle"><div class=settings-screen-content-header-title-group><p class=settings-screen-content-eyebrow></p><h1 class="window-title settings-screen-content-title"></h1></div></header><div class="window-body settings-screen-scroll">'),z7=O('<span class=settings-section-selector-value><span class="selector-trigger-primary selector-trigger-primary--align-left">'),W7=O("<button type=button class=settings-nav-button><span>"),H7=O('<div class=settings-window-root><div class="modal-surface window-shell settings-screen-shell">'),G7=O("<div class=settings-screen-frame>");const Z7=e=>{const{t}=Dt(),n=$4("(max-width: 640px)"),s=Te(()=>{const b=[{id:"general",icon:QD,label:t("settings.nav.general")},{id:"chat",icon:AD,label:t("settings.nav.chat")},{id:"notifications",icon:Jk,label:t("settings.nav.notifications")},{id:"speech",icon:Kh,label:t("settings.nav.speech")},{id:"opencode",icon:Kp,label:t("settings.nav.opencode")},{id:"providers",icon:ex,label:t("settings.nav.providers")},{id:"sidecars",icon:ei,label:t("settings.nav.sidecars")},{id:"config-files",icon:QA,label:t("settings.nav.configFiles")},{id:"advanced",icon:nd,label:t("settings.nav.advanced")},{id:"info",icon:Up,label:t("settings.nav.info")}];return(e.standalone||ia())&&b.splice(4,0,{id:"remote",icon:OD,label:t("settings.nav.remote")}),b}),r=Te(()=>s().find(b=>b.id===Ii())??s()[0]),o=()=>{switch(Ii()){case"chat":return y(uR,{});case"notifications":return y(ZR,{});case"speech":return y(yO,{});case"remote":return e.standalone||ia()?(()=>{var b=F7();return p(b,y(r7,{}),null),p(b,y(v7,{}),null),b})():y(Rb,{showStartupState:!0});case"opencode":return y(Rz,{});case"providers":return y(Tz,{get instanceId(){var b;return(b=e.providerContext)==null?void 0:b.instanceId},get location(){var b;return(b=e.providerContext)==null?void 0:b.location}});case"sidecars":return y(M7,{});case"config-files":return y(Jz,{});case"advanced":return y(Kz,{});case"info":return y(TR,{});case"general":default:return y(Rb,{get showStartupState(){return!e.standalone}})}},a=async b=>{var v;b!==Ii()&&await Qi()&&(await((v=e.onSectionChange)==null?void 0:v.call(e,b)),sy(b),u==null||u.scrollTo({top:0}))},i=async()=>{await Qi()&&(e.onClose?await e.onClose():N4())},[c,l]=R({x:0,y:0});Ze(()=>{n()&&l({x:0,y:0})});let d,u;N7(()=>u,()=>(Ii(),e.scrollPosition),b=>{var v;return(v=e.onScrollPositionChange)==null?void 0:v.call(e,b)});let f;const g=b=>{if(e.standalone||n()||b.button!==0||b.target.closest("button, input, select, textarea, a")||!d)return;const v=c(),k=d.getBoundingClientRect();f={...v,pointerX:b.clientX,pointerY:b.clientY,minX:v.x+16-k.left,maxX:v.x+window.innerWidth-16-k.right,minY:v.y+16-k.top,maxY:v.y+window.innerHeight-16-k.bottom},b.currentTarget.setPointerCapture(b.pointerId),b.preventDefault()},m=b=>{f&&l({x:Math.min(f.maxX,Math.max(f.minX,f.x+b.clientX-f.pointerX)),y:Math.min(f.maxY,Math.max(f.minY,f.y+b.clientY-f.pointerY))})},w=b=>{f=void 0;const v=b.currentTarget;v.hasPointerCapture(b.pointerId)&&v.releasePointerCapture(b.pointerId)},S=()=>[y(ee,{get when(){return e.standalone},get children(){var b=B7();return p(b,()=>t("settings.title")),b}}),(()=>{var b=V7(),v=b.firstChild,k=v.firstChild,C=k.nextSibling,_=v.nextSibling,T=_.firstChild,P=T.firstChild,I=P.nextSibling,j=I.firstChild,ne=_.nextSibling;return p(k,y(nd,{class:"settings-screen-nav-icon"})),p(C,y(De,{get value(){return r()},onChange:W=>W&&void a(W.id),get options(){return s()},optionValue:"id",optionTextValue:"label",itemComponent:W=>{const q=W.item.rawValue.icon;return y(De.Item,{get item(){return W.item},class:"selector-option settings-section-selector-option",get children(){return[y(q,{class:"settings-section-selector-option-icon"}),y(De.ItemLabel,{class:"selector-option-label",get children(){return W.item.rawValue.label}})]}})},get children(){return[y(De.Trigger,{class:"selector-trigger settings-section-selector-trigger",get"aria-label"(){return t("settings.navigationAriaLabel")},get children(){return[(()=>{var W=U7();return p(W,y(De.Value,{children:q=>{const U=q.selectedOption(),G=(U==null?void 0:U.icon)??nd;return(()=>{var le=z7(),K=le.firstChild;return p(le,y(G,{class:"settings-section-selector-value-icon"}),K),p(K,()=>U==null?void 0:U.label),le})()}})),W})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover settings-section-selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})),p(v,y(ee,{get when(){return!e.standalone},get children(){var W=K7();return W.$$click=()=>void i(),p(W,y(ti,{class:"w-4 h-4"})),de(q=>{var U=t("settings.close"),G=t("settings.close");return U!==q.e&&me(W,"aria-label",q.e=U),G!==q.t&&me(W,"title",q.t=G),q},{e:void 0,t:void 0}),W}}),null),_.addEventListener("pointercancel",w),_.$$pointerup=w,_.$$pointermove=m,_.$$pointerdown=g,p(P,y(nd,{class:"settings-screen-nav-icon"})),p(j,()=>t("settings.title")),p(ne,y(zt,{get each(){return s()},children:W=>{const q=W.icon;return(()=>{var U=W7(),G=U.firstChild;return U.$$click=()=>void a(W.id),p(U,y(q,{class:"settings-nav-button-icon"}),G),p(G,()=>W.label),de(le=>{var K=Ii()===W.id?"true":"false",M=Ii()===W.id?"page":void 0;return K!==le.e&&me(U,"data-selected",le.e=K),M!==le.t&&me(U,"aria-current",le.t=M),le},{e:void 0,t:void 0}),U})()}})),de(()=>me(ne,"aria-label",t("settings.navigationAriaLabel"))),b})(),(()=>{var b=q7(),v=b.firstChild,k=v.firstChild,C=k.firstChild,_=C.nextSibling,T=v.nextSibling;v.addEventListener("pointercancel",w),v.$$pointerup=w,v.$$pointermove=m,v.$$pointerdown=g,p(C,()=>t("settings.content.eyebrow")),p(_,()=>{var I;return(I=r())==null?void 0:I.label}),p(v,y(ee,{get when(){return!e.standalone},get children(){var I=j7();return I.$$click=()=>void i(),p(I,y(ti,{class:"w-4 h-4"})),de(j=>{var ne=t("settings.close"),W=t("settings.close");return ne!==j.e&&me(I,"aria-label",j.e=ne),W!==j.t&&me(I,"title",j.t=W),j},{e:void 0,t:void 0}),I}}),null);var P=u;return typeof P=="function"?dr(P,T):u=T,p(T,o),b})()];return e.standalone?(()=>{var b=H7(),v=b.firstChild;p(b,y(L7,{get title(){return t("settings.title")},onClose:i}),v);var k=d;return typeof k=="function"?dr(k,v):d=v,p(v,S),b})():y(Ot,{get modal(){return n()},get preventScroll(){return n()},get open(){return jx()},onOpenChange:b=>!b&&void i(),get children(){return y(Ot.Portal,{get children(){var b=G7();return p(b,y(Ot.Content,{ref(v){var k=d;typeof k=="function"?k(v):d=v},class:"modal-surface window-shell settings-screen-shell",get style(){return{transform:`translate(${c().x}px, ${c().y}px)`}},onInteractOutside:v=>v.preventDefault(),get children(){return[y(Ot.Title,{class:"sr-only",get children(){return t("settings.title")}}),Ee(()=>S())]}})),b}})}})};Xt(["click","pointerdown","pointermove","pointerup"]);const Y7=()=>{const[e,t]=R({section:"general"}),n=[];let s=Promise.resolve(),r,o=0,a,i=Promise.resolve();const c=(g,m)=>(i=i.catch(()=>{}).then(()=>M4(g(),m)),i),l=g=>(clearTimeout(a),a=void 0,c(()=>({...e(),scrollTop:o}),g)),d=async g=>{await s.catch(()=>{}),await l(g)},u=async(g,m=!0)=>{if(m&&!await Qi())return;clearTimeout(a),m&&await c(()=>g);const w=e().instanceId;w&&w!==g.instanceId&&fa.destroyClientsForInstance(w),o=g.scrollTop??0,gn(()=>{t(g),sy(g.section)})},f=async(g=!0)=>r||(r=(async()=>{(!g||await Qi())&&(await d(),await Ec("close"))})().finally(()=>{r=void 0}),r);return Ys(()=>{let g=!0,m=!1,w=!1,S=!1,b=!1,v=!1;(async()=>{try{const k=await P4(C=>{m=!0,g&&(s=s.catch(()=>{}).then(()=>u(C)))});if(!g)return k();n.push(k),w=!0}catch{}try{const k=await D4();g&&!m&&await u(k,!1)}catch{}try{const k=await I4(()=>void f());if(!g)return k();n.push(k),S=!0}catch{}try{const k=await R4(C=>{s=s.catch(()=>{}).then(async()=>{const _=await Qi();_&&await l(),await O4(C,_)})});if(!g)return k();n.push(k),b=!0}catch{}try{const k=await A4(d);if(!g)return k();n.push(k),v=!0}catch{}w&&S&&b&&v&&await T4()})(),dt(()=>{g=!1,clearTimeout(a),n.splice(0).forEach(C=>C());const k=e().instanceId;k&&fa.destroyClientsForInstance(k)})}),[y(Z7,{standalone:!0,get providerContext(){return{instanceId:e().instanceId,location:e().location}},get scrollPosition(){return e()},onScrollPositionChange:g=>{o=g,clearTimeout(a),a=setTimeout(()=>{l().catch(()=>{})},150)},onSectionChange:async g=>{clearTimeout(a);const m={...e(),section:g,scrollTop:0};await c(()=>m),o=0,t(m)},onClose:()=>f(!1)}),y(cA,{}),y(zP,{automatic:!1}),y(FM,{position:"top-right",gutter:16,toastOptions:{duration:8e3,className:"bg-transparent border-none shadow-none p-0"}})]},WT=document.getElementById("root");if(!WT)throw new Error("Root element not found");const J7=WT;typeof document<"u"&&(document.documentElement.dataset.runtimeHost=$n.host,document.documentElement.dataset.runtimePlatform=$n.platform);async function Q7(){var t;let e=Y7;if(Cp($n)){const[{initializeClientState:n},s]=await Promise.all([ls(()=>import("./client-state-Brb7YeOo.js").then(r=>r.j),__vite__mapDeps([8,2,3,4,5,6,1,7])),ls(()=>import("./App-DdteBqTo.js").then(r=>r.ab),__vite__mapDeps([11,1,2,3,4,5,6,7,8]))]);await n(),e=s.default}if(typeof document<"u")try{const[n,s]=await Promise.all([Iw.loadConfigOwner("ui"),Iw.loadStateOwner("ui")]),r=(s==null?void 0:s.theme)??(n==null?void 0:n.theme),o=(s==null?void 0:s.colorScheme)??(n==null?void 0:n.colorScheme),a=typeof((t=n==null?void 0:n.settings)==null?void 0:t.locale)=="string"?n.settings.locale:void 0;Rw(Ui(o,r),{systemDark:window.matchMedia("(prefers-color-scheme: dark)").matches}),await Aw(a)}catch{Rw(Ui("system"),{systemDark:window.matchMedia("(prefers-color-scheme: dark)").matches}),await Aw()}pM(()=>y(wM,{get children(){return y(yM,{get children(){return y(XT,{get children(){return y(vM,{get children(){return y(e,{})}})}})}})}}),J7)}Q7();export{mo as $,kH as A,Jk as B,jA as C,Ot as D,Yi as E,Xk as F,ei as G,_H as H,nt as I,CH as J,of as K,K4 as L,OD as M,hH as N,bH as O,KD as P,Fe as Q,h7 as R,nd as S,af as T,co as U,Nn as V,h8 as W,ti as X,Y8 as Y,FE as Z,Gd as _,Hn as a,Ek as a$,mc as a0,ca as a1,pc as a2,d9 as a3,iT as a4,Yk as a5,u9 as a6,fT as a7,v9 as a8,Zr as a9,km as aA,GH as aB,WH as aC,HH as aD,OG as aE,dH as aF,Kt as aG,Or as aH,oH as aI,he as aJ,Vp as aK,Rk as aL,Kn as aM,vl as aN,rI as aO,vs as aP,en as aQ,Np as aR,bs as aS,ja as aT,Qz as aU,Ik as aV,on as aW,cH as aX,On as aY,Tr as aZ,dI as a_,pH as aa,qH as ab,KH as ac,e_ as ad,EH as ae,ua as af,vT as ag,bp as ah,A9 as ai,Hx as aj,Fo as ak,U8 as al,w9 as am,Ht as an,es as ao,$9 as ap,_9 as aq,wO as ar,bO as as,Ne as at,lg as au,Mq as av,hr as aw,x9 as ax,b0 as ay,mu as az,Fb as b,Zv as b$,Ex as b0,Dk as b1,ml as b2,Ih as b3,lx as b4,Mk as b5,Ok as b6,Bw as b7,aH as b8,yl as b9,uN as bA,lN as bB,cN as bC,aN as bD,JH as bE,Ta as bF,nR as bG,$t as bH,Lu as bI,ng as bJ,mE as bK,J8 as bL,wH as bM,TC as bN,AC as bO,RC as bP,hj as bQ,cy as bR,vH as bS,g_ as bT,mj as bU,cb as bV,fr as bW,dN as bX,K_ as bY,eG as bZ,j_ as b_,ty as ba,Kh as bb,QR as bc,A6 as bd,Up as be,b7 as bf,cZ as bg,VE as bh,Tw as bi,lZ as bj,f9 as bk,Ew as bl,Ds as bm,x8 as bn,Oa as bo,vp as bp,dZ as bq,Ol as br,tg as bs,zH as bt,YH as bu,QH as bv,D6 as bw,KG as bx,ZH as by,UG as bz,i7 as c,De as c$,jq as c0,gq as c1,GC as c2,XC as c3,uq as c4,uH as c5,xy as c6,NH as c7,FH as c8,sO as c9,d2 as cA,lH as cB,lI as cC,qp as cD,tf as cE,sr as cF,ff as cG,Ax as cH,uf as cI,df as cJ,lf as cK,cf as cL,ny as cM,zp as cN,TH as cO,GO as cP,Jf as cQ,Ti as cR,Da as cS,ex as cT,Ez as cU,p_ as cV,PL as cW,IH as cX,qg as cY,Zo as cZ,ko as c_,Yb as ca,rO as cb,vu as cc,tG as cd,Rv as ce,y9 as cf,BH as cg,k6 as ch,Ig as ci,Jo as cj,NG as ck,LG as cl,BD as cm,RG as cn,_E as co,pr as cp,Hp as cq,Tx as cr,Mx as cs,cI as ct,gH as cu,dx as cv,ux as cw,Dx as cx,fx as cy,sI as cz,qx as d,DH as d$,wi as d0,MH as d1,RH as d2,AH as d3,tA as d4,Aq as d5,yE as d6,Uq as d7,SG as d8,TG as d9,HC as dA,_C as dB,eq as dC,tq as dD,Aj as dE,_q as dF,Rj as dG,kG as dH,xG as dI,BA as dJ,db as dK,Cq as dL,_G as dM,Zf as dN,Ei as dO,DG as dP,Ij as dQ,EG as dR,PG as dS,Hv as dT,Tq as dU,gE as dV,iZ as dW,aZ as dX,gy as dY,k8 as dZ,PH as d_,wq as da,MG as db,Fq as dc,DC as dd,MC as de,EC as df,IC as dg,PC as dh,CC as di,M6 as dj,FG as dk,ij as dl,_6 as dm,x6 as dn,S6 as dp,t6 as dq,yg as dr,sR as ds,Lb as dt,rR as du,zs as dv,lp as dw,Dq as dx,xC as dy,Mv as dz,h9 as e,E9 as e$,fE as e0,Iv as e1,uE as e2,Pq as e3,Vv as e4,RE as e5,Sf as e6,vn as e7,TD as e8,oE as e9,Lv as eA,hq as eB,OH as eC,JC as eD,Zs as eE,XH as eF,WG as eG,XG as eH,E8 as eI,zG as eJ,o9 as eK,VG as eL,fZ as eM,x7 as eN,g9 as eO,lT as eP,D8 as eQ,CG as eR,zP as eS,lw as eT,rZ as eU,L7 as eV,YG as eW,oZ as eX,Z7 as eY,cA as eZ,FM as e_,$C as ea,E6 as eb,rE as ec,qT as ed,zT as ee,S7 as ef,Lq as eg,lE as eh,BG as ei,mH as ej,mq as ek,LH as el,fq as em,UH as en,na as eo,Tv as ep,jG as eq,Uv as er,kq as es,qG as et,bq as eu,Sq as ev,Ku as ew,$q as ex,$G as ey,uZ as ez,Zn as f,JG as f0,c8 as f1,d8 as f2,Bp as f3,u8 as f4,gZ as f5,$6 as f6,Ia as f7,n9 as f8,ql as f9,pw as fa,QE as fb,mr as fc,No as fd,p9 as fe,VH as ff,zx as fg,UL as fh,jH as fi,yH as fj,AA as fk,Qk as fl,i2 as fm,iH as fn,jv as fo,Iq as fp,Zt as fq,k9 as fr,ea as fs,WD as ft,cn as g,HG as h,iD as i,SP as j,MP as k,fH as l,jx as m,m9 as n,M9 as o,Ns as p,IG as q,xS as r,QG as s,AG as t,$4 as u,rD as v,$H as w,NR as x,xH as y,SH as z};
|
|
43
|
-
//# sourceMappingURL=main-
|
|
42
|
+
`;return typeof s=="function"&&s(null,f),f};const UW=tW,_p=TT,jT=KT,KW=VT;function $w(e,t,n,s,r){const o=[].slice.call(arguments,1),a=o.length,i=typeof o[a-1]=="function";if(!i&&!UW())throw new Error("Callback required as last argument");if(i){if(a<2)throw new Error("Too few arguments provided");a===2?(r=n,n=t,t=s=void 0):a===3&&(t.getContext&&typeof r>"u"?(r=s,s=void 0):(r=s,s=n,n=t,t=void 0))}else{if(a<1)throw new Error("Too few arguments provided");return a===1?(n=t,t=s=void 0):a===2&&!t.getContext&&(s=n,n=t,t=void 0),new Promise(function(c,l){try{const d=_p.create(n,s);c(e(d,t,s))}catch(d){l(d)}})}try{const c=_p.create(n,s);r(null,e(c,t,s))}catch(c){r(c)}}_p.create;$w.bind(null,jT.render);var VW=$w.bind(null,jT.renderToDataURL);$w.bind(null,function(e,t,n){return KW.render(e,n)});const jW=Ut("actions");async function qW(){var e,t;if(!QT())return!1;try{if(Bn()){const n=window.electronAPI;return n!=null&&n.restartCli?(await n.restartCli(),!0):!1}if(Dn())return typeof((t=(e=window.__TAURI__)==null?void 0:e.core)==null?void 0:t.invoke)=="function"?(await Ms("cli_restart"),!0):!1}catch(n){return jW.error("Failed to restart CLI",n),!1}return!1}function zW(e){const t=e.filter(n=>n.scope!=="loopback");return{recommended:t[0]??null,hidden:t.slice(1)}}var WW=O("<span class=remote-toggle-state>"),HW=O("<div class=remote-toggle-copy><span class=remote-toggle-title></span><span class=remote-toggle-caption>"),qS=O('<div class=settings-form-group><label class=settings-form-label></label><input class="selector-input w-full"type=password>'),GW=O("<div class=settings-password-actions><button class=settings-pill-button type=button>"),ZW=O("<div class=settings-card-content><div class=settings-password-summary-row><div class=settings-password-summary-copy><p class=settings-help-text></p><p class=settings-help-text></p></div><div class=settings-password-actions><button class=settings-pill-button type=button>"),YW=O("<div class=remote-address-disclosure-content>"),JW=O("<div class=remote-address-disclosure><button class=remote-address-disclosure-trigger type=button><span class=remote-address-disclosure-label>"),QW=O("<div class=remote-address-list>"),XW=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><div class=settings-toolbar-inline><span class="settings-scope-badge settings-scope-badge-server"></span><button class="selector-button selector-button-secondary w-auto"type=button><span></span></button></div></div><p class=remote-toggle-note></p></div><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server"></span></div></div><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server">'),e7=O("<div class=settings-card-message>"),t7=O("<div class=settings-error-message>"),zS=O("<div class=remote-card>"),n7=O("<div class=remote-error>"),Ch=O("<div class=remote-qr>"),s7=O("<div class=remote-address><div class=remote-address-main><div><p class=remote-address-url></p><p class=remote-address-meta></p></div><div class=remote-actions><button class=remote-pill type=button></button><button class=remote-pill type=button>"),Eh=O("<img class=remote-qr-img>"),WS=O("<div class=remote-address><div class=remote-address-main><div><p class=remote-address-url></p><p class=remote-address-meta> - <!> - </p></div><div class=remote-actions><button class=remote-pill type=button></button><button class=remote-pill type=button>");const HS=Ut("actions"),r7=()=>{const{t:e}=Dt(),[t,n]=R(null),[s,r]=R(null),[o,a]=R(!1),[i,c]=R(!1),[l,d]=R({}),[u,f]=R(null),[g,m]=R(null),[w,S]=R(!1),[b,v]=R(""),[k,C]=R(""),[_,T]=R(null),[P,I]=R(!1),[j,ne]=R(!1),W=Te(()=>{var ge;return((ge=t())==null?void 0:ge.addresses)??[]}),q=Te(()=>{var ge;return((ge=t())==null?void 0:ge.listeningMode)??ef().listeningMode}),U=Te(()=>q()==="all"),G=Te(()=>{const ge=W();return U()?zW(ge):{recommended:null,hidden:[]}}),le=async()=>{a(!0),m(null),T(null);try{const[ge,Ie]=await Promise.all([kt.fetchServerMeta(),kt.fetchAuthStatus()]);n(ge),r(Ie),ne(!1)}catch(ge){m(ge instanceof Error?ge.message:String(ge))}finally{a(!1)}};Ys(()=>{le()});const K=async ge=>{if(u()===ge){f(null);return}if(f(ge),!l()[ge])try{const Ie=await VW(ge,{margin:1,scale:4});d(ke=>({...ke,[ge]:Ie}))}catch(Ie){HS.error("Failed to generate QR code",Ie)}},M=async ge=>{const Ie=ge?"all":"local";if(!(Ie===q()||i()||!await ca(e("remoteAccess.listeningMode.restartConfirm.message"),{title:e(ge?"remoteAccess.listeningMode.restartConfirm.title.all":"remoteAccess.listeningMode.restartConfirm.title.local"),variant:"warning",confirmLabel:e("remoteAccess.listeningMode.restartConfirm.confirmLabel"),cancelLabel:e("remoteAccess.listeningMode.restartConfirm.cancelLabel"),dismissible:!1}))){c(!0),m(null);try{await mM(Ie),await qW()?n(Ae=>Ae&&{...Ae,listeningMode:Ie}):m(e("remoteAccess.restart.errorManual"))}catch(we){m(we instanceof Error?we.message:String(we))}finally{c(!1)}le()}},N=ge=>{try{window.open(ge,"_blank","noopener,noreferrer")}catch(Ie){HS.error("Failed to open URL",Ie)}},oe=async()=>{T(null);const ge=b(),Ie=k();if(ge.trim().length<8){T(e("remoteAccess.password.error.tooShort"));return}if(ge!==Ie){T(e("remoteAccess.password.error.mismatch"));return}I(!0);try{const ke=await kt.setServerPassword(ge);r({authenticated:!0,username:ke.username,passwordUserProvided:ke.passwordUserProvided}),v(""),C(""),S(!1)}catch(ke){T(ke instanceof Error?ke.message:String(ke))}finally{I(!1)}};return(()=>{var ge=XW(),Ie=ge.firstChild,ke=Ie.firstChild,we=ke.firstChild,Ae=we.firstChild,Ge=Ae.firstChild,H=Ge.nextSibling,h=we.nextSibling,$=h.firstChild,D=$.nextSibling,E=D.firstChild,Z=ke.nextSibling,B=Ie.nextSibling,se=B.firstChild,pe=se.firstChild,Se=pe.firstChild,Q=Se.firstChild,be=Q.nextSibling,Ve=pe.nextSibling,He=B.nextSibling,re=He.firstChild,F=re.firstChild,V=F.firstChild,Me=V.firstChild,xe=Me.nextSibling,Re=F.nextSibling;return p(we,y(Zd,{class:"settings-card-heading-icon"}),Ae),p(Ge,()=>e("remoteAccess.sections.listeningMode.label")),p(H,()=>e("remoteAccess.sections.listeningMode.help")),p($,()=>e("settings.scope.server")),D.$$click=()=>void le(),p(D,y(Gd,{get class(){return`w-4 h-4 ${o()?"remote-spin":""}`}}),E),p(E,()=>e("remoteAccess.refresh")),p(Ie,y(Cc,{class:"remote-toggle",get checked(){return U()},onChange:Be=>void M(Be),get disabled(){return o()||i()},get children(){return[y(Cc.Input,{}),y(Cc.Control,{class:"remote-toggle-switch",get"data-checked"(){return U()},get children(){return[(()=>{var Be=WW();return p(Be,(()=>{var et=Ee(()=>!!U());return()=>et()?e("remoteAccess.toggle.on"):e("remoteAccess.toggle.off")})()),Be})(),y(Cc.Thumb,{class:"remote-toggle-thumb"})]}}),(()=>{var Be=HW(),et=Be.firstChild,Ue=et.nextSibling;return p(et,()=>e("remoteAccess.toggle.title")),p(Ue,(()=>{var We=Ee(()=>!!U());return()=>We()?e("remoteAccess.toggle.caption.all"):e("remoteAccess.toggle.caption.local")})()),Be})()]}}),Z),p(Z,()=>e("remoteAccess.toggle.note")),p(pe,y(Zd,{class:"settings-card-heading-icon"}),Se),p(Q,()=>e("remoteAccess.sections.serverPassword.label")),p(be,()=>e("remoteAccess.sections.serverPassword.help")),p(Ve,()=>e("settings.scope.server")),p(B,y(ee,{get when(){return Ee(()=>!!s())()&&s().authenticated},get fallback(){return(()=>{var Be=e7();return p(Be,()=>e("remoteAccess.authStatus.unavailable")),Be})()},get children(){var Be=ZW(),et=Be.firstChild,Ue=et.firstChild,We=Ue.firstChild,st=We.nextSibling,at=Ue.nextSibling,ht=at.firstChild;return p(We,()=>e("remoteAccess.username",{username:s().username??"codenomad"})),p(st,(()=>{var ut=Ee(()=>!!s().passwordUserProvided);return()=>ut()?e("remoteAccess.password.status.set"):e("remoteAccess.password.status.unset")})()),ht.$$click=()=>{S(!w()),T(null)},p(ht,(()=>{var ut=Ee(()=>!!w());return()=>ut()?e("remoteAccess.password.actions.cancel"):Ee(()=>!!s().passwordUserProvided)()?e("remoteAccess.password.actions.change"):e("remoteAccess.password.actions.set")})()),p(Be,y(ee,{get when(){return w()},get children(){return[(()=>{var ut=qS(),Ct=ut.firstChild,Qe=Ct.nextSibling;return p(Ct,()=>e("remoteAccess.password.form.newPassword")),Qe.$$input=tt=>v(tt.currentTarget.value),de(()=>me(Qe,"placeholder",e("remoteAccess.password.form.placeholder"))),de(()=>Qe.value=b()),ut})(),(()=>{var ut=qS(),Ct=ut.firstChild,Qe=Ct.nextSibling;return p(Ct,()=>e("remoteAccess.password.form.confirmPassword")),Qe.$$input=tt=>C(tt.currentTarget.value),de(()=>Qe.value=k()),ut})(),y(ee,{get when(){return _()},children:ut=>(()=>{var Ct=t7();return p(Ct,ut),Ct})()}),(()=>{var ut=GW(),Ct=ut.firstChild;return Ct.$$click=()=>void oe(),p(Ct,(()=>{var Qe=Ee(()=>!!P());return()=>Qe()?e("remoteAccess.password.save.saving"):e("remoteAccess.password.save.label")})()),de(()=>Ct.disabled=P()),ut})()]}}),null),Be}}),null),p(F,y(iP,{class:"settings-card-heading-icon"}),V),p(Me,()=>e("remoteAccess.sections.addresses.label")),p(xe,()=>e("remoteAccess.sections.addresses.help")),p(Re,()=>e("settings.scope.server")),p(He,y(ee,{get when(){return!o()},get fallback(){return(()=>{var Be=zS();return p(Be,()=>e("remoteAccess.addresses.loading")),Be})()},get children(){return y(ee,{get when(){return!g()},get fallback(){return(()=>{var Be=n7();return p(Be,g),Be})()},get children(){return y(ee,{get when(){var Be;return!!G().recommended||((Be=t())==null?void 0:Be.localUrl)},get fallback(){return(()=>{var Be=zS();return p(Be,()=>e("remoteAccess.addresses.none")),Be})()},get children(){var Be=QW();return p(Be,y(ee,{get when(){var et;return(et=t())==null?void 0:et.localUrl},children:et=>{const Ue=()=>et(),We=()=>u()===Ue(),st=()=>l()[Ue()];return(()=>{var at=s7(),ht=at.firstChild,ut=ht.firstChild,Ct=ut.firstChild,Qe=Ct.nextSibling,tt=ut.nextSibling,At=tt.firstChild,xt=At.nextSibling;return p(Ct,Ue),p(Qe,()=>e("remoteAccess.address.scope.loopback")),At.$$click=()=>N(Ue()),p(At,y(Yi,{class:"remote-icon"}),null),p(At,()=>e("remoteAccess.address.open"),null),xt.$$click=()=>void K(Ue()),p(xt,y(Td,{class:"remote-icon"}),null),p(xt,(()=>{var x=Ee(()=>!!We());return()=>x()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(at,y(ee,{get when(){return We()},get children(){var x=Ch();return p(x,y(ee,{get when(){return st()},get fallback(){return y(Zn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:A=>(()=>{var L=Eh();return de(X=>{var Y=A(),ue=e("remoteAccess.address.qrAlt",{url:Ue()});return Y!==X.e&&me(L,"src",X.e=Y),ue!==X.t&&me(L,"alt",X.t=ue),X},{e:void 0,t:void 0}),L})()})),x}}),null),de(()=>me(xt,"aria-expanded",We())),at})()}}),null),p(Be,y(ee,{get when(){return G().recommended},children:et=>{const Ue=et(),We=Ue.remoteUrl,st=()=>u()===We,at=()=>l()[We],ht=()=>Ue.scope==="external"?e("remoteAccess.address.scope.network"):Ue.scope==="loopback"?e("remoteAccess.address.scope.loopback"):e("remoteAccess.address.scope.internal");return(()=>{var ut=WS(),Ct=ut.firstChild,Qe=Ct.firstChild,tt=Qe.firstChild,At=tt.nextSibling,xt=At.firstChild,x=xt.nextSibling;x.nextSibling;var A=Qe.nextSibling,L=A.firstChild,X=L.nextSibling;return p(tt,We),p(At,()=>Ue.family.toUpperCase(),xt),p(At,ht,x),p(At,()=>Ue.ip,null),L.$$click=()=>N(We),p(L,y(Yi,{class:"remote-icon"}),null),p(L,()=>e("remoteAccess.address.open"),null),X.$$click=()=>void K(We),p(X,y(Td,{class:"remote-icon"}),null),p(X,(()=>{var Y=Ee(()=>!!st());return()=>Y()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(ut,y(ee,{get when(){return st()},get children(){var Y=Ch();return p(Y,y(ee,{get when(){return at()},get fallback(){return y(Zn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:ue=>(()=>{var ce=Eh();return de(ve=>{var je=ue(),Ke=e("remoteAccess.address.qrAlt",{url:We});return je!==ve.e&&me(ce,"src",ve.e=je),Ke!==ve.t&&me(ce,"alt",ve.t=Ke),ve},{e:void 0,t:void 0}),ce})()})),Y}}),null),de(()=>me(X,"aria-expanded",st())),ut})()}}),null),p(Be,y(ee,{get when(){return G().hidden.length>0},get children(){var et=JW(),Ue=et.firstChild,We=Ue.firstChild;return Ue.$$click=()=>ne(!j()),p(We,(()=>{var st=Ee(()=>!!j());return()=>st()?e("remoteAccess.addresses.actions.hideOther"):e("remoteAccess.addresses.actions.showOther",{count:String(G().hidden.length)})})()),p(Ue,y(jA,{class:"remote-address-disclosure-chevron disclosure-chevron"}),null),p(et,y(ee,{get when(){return j()},get children(){var st=YW();return p(st,y(zt,{get each(){return G().hidden},children:at=>{const ht=at.remoteUrl,ut=()=>u()===ht,Ct=()=>l()[ht],Qe=()=>at.scope==="external"?e("remoteAccess.address.scope.network"):at.scope==="loopback"?e("remoteAccess.address.scope.loopback"):e("remoteAccess.address.scope.internal");return(()=>{var tt=WS(),At=tt.firstChild,xt=At.firstChild,x=xt.firstChild,A=x.nextSibling,L=A.firstChild,X=L.nextSibling;X.nextSibling;var Y=xt.nextSibling,ue=Y.firstChild,ce=ue.nextSibling;return p(x,ht),p(A,()=>at.family.toUpperCase(),L),p(A,Qe,X),p(A,()=>at.ip,null),ue.$$click=()=>N(ht),p(ue,y(Yi,{class:"remote-icon"}),null),p(ue,()=>e("remoteAccess.address.open"),null),ce.$$click=()=>void K(ht),p(ce,y(Td,{class:"remote-icon"}),null),p(ce,(()=>{var ve=Ee(()=>!!ut());return()=>ve()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(tt,y(ee,{get when(){return ut()},get children(){var ve=Ch();return p(ve,y(ee,{get when(){return Ct()},get fallback(){return y(Zn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:je=>(()=>{var Ke=Eh();return de(rt=>{var ot=je(),Pt=e("remoteAccess.address.qrAlt",{url:ht});return ot!==rt.e&&me(Ke,"src",rt.e=ot),Pt!==rt.t&&me(Ke,"alt",rt.t=Pt),rt},{e:void 0,t:void 0}),Ke})()})),ve}}),null),de(()=>me(ce,"aria-expanded",ut())),tt})()}})),st}}),null),de(st=>{var at=j(),ht=j();return at!==st.e&&me(et,"data-expanded",st.e=at),ht!==st.t&&me(Ue,"aria-expanded",st.t=ht),st},{e:void 0,t:void 0}),et}}),null),Be}})}})}}),null),de(()=>D.disabled=o()),ge})()};Xt(["click","input"]);async function o7(e,t,n){if(!ia())throw new Error("Remote server windows can only be opened from a local desktop window");const s={id:e.id,name:e.name,baseUrl:e.baseUrl,entryUrl:t,proxySessionId:n,skipTlsVerify:e.skipTlsVerify};if(Bn()){const r=window.electronAPI;if(typeof(r==null?void 0:r.openRemoteWindow)=="function"){await r.openRemoteWindow(s);return}}if(Dn()){if(n!==void 0&&(t??e.baseUrl).startsWith("https://")&&await Ms("needs_local_certificate_install")&&!await ca($e("folderSelection.servers.certificateInstall.confirmMessage"),{title:$e("folderSelection.servers.certificateInstall.title"),variant:"warning",confirmLabel:$e("folderSelection.servers.certificateInstall.confirmLabel"),cancelLabel:$e("folderSelection.servers.certificateInstall.cancelLabel")}))throw new Error($e("folderSelection.servers.certificateInstall.cancelled"));await Ms("open_remote_window",{payload:s});return}window.open(e.baseUrl,"_blank","noopener,noreferrer")}function i7(){const{t:e}=Dt(),{remoteServers:t,saveRemoteServerProfile:n,markRemoteServerConnected:s,removeRemoteServerProfile:r}=Un(),[o,a]=R(null),i=async(l,d)=>{if(d&&!ia())throw new Error("Remote server windows can only be opened from a local desktop window");const u=l.name.trim(),f=l.baseUrl.trim();if(!u||!f)throw new Error(e("folderSelection.servers.dialog.errorRequired"));const g=await kt.probeRemoteServer({baseUrl:f,skipTlsVerify:l.skipTlsVerify});if(!g.ok)throw new Error(g.error||e("folderSelection.servers.dialog.errorConnect"));const m=await n({id:l.id,name:u,baseUrl:g.normalizedUrl,skipTlsVerify:l.skipTlsVerify});if(d){const w=Dn()&&m.skipTlsVerify&&m.baseUrl.startsWith("https://")?await kt.createRemoteProxySession({baseUrl:m.baseUrl,skipTlsVerify:!0}):void 0;try{await o7(m,w==null?void 0:w.windowUrl,w==null?void 0:w.sessionId)}catch(S){throw w&&kt.deleteRemoteProxySession(w.sessionId).catch(()=>{}),S}await s(m.id)}return m};return{remoteServers:t,connectingServerId:o,saveServer:i,connectSavedServer:async l=>{if(!ia()||o())return;const d=t().find(u=>u.id===l);if(d){a(l);try{await i(d,!0)}catch(u){Ns(u instanceof Error?u.message:String(u),{title:e("folderSelection.servers.errorTitle"),variant:"warning"})}finally{a(null)}}},removeRemoteServerProfile:r}}var a7=O("<div>"),GS=O('<label class="flex flex-col gap-2 text-sm text-secondary"><span></span><input class="selector-input w-full">'),c7=O('<label class="flex items-start gap-3 text-sm text-secondary"><input type=checkbox><span>'),l7=O('<span class="inline-flex items-center gap-2">'),d7=O('<div class="flex items-center justify-end gap-3"><button type=button class="selector-button selector-button-secondary w-auto px-4"></button><button type=button class="selector-button selector-button-secondary w-auto px-4"></button><button type=button class="selector-button selector-button-secondary w-auto px-4">'),u7=O('<div class="fixed inset-0 z-[1300] flex items-center justify-center p-4">'),f7=O('<p class="text-sm text-red-500 break-words">'),g7=O("<span>");const h7=e=>{const{t}=Dt(),[n,s]=R(""),[r,o]=R(""),[a,i]=R(!1),[c,l]=R(null),[d,u]=R(!1);Ze(()=>{e.open&&(s(""),o(""),i(!1),l(null))});const f=async g=>{if(!d()){u(!0),l(null);try{await e.onSubmit({name:n(),baseUrl:r(),skipTlsVerify:a()},g),e.onOpenChange(!1)}catch(m){l(m instanceof Error?m.message:String(m))}finally{u(!1)}}};return y(Ot,{get open(){return e.open},get onOpenChange(){return e.onOpenChange},get children(){return y(Ot.Portal,{get children(){return[y(Ot.Overlay,{class:"modal-overlay"}),(()=>{var g=u7();return p(g,y(Ot.Content,{class:"modal-surface w-full max-w-lg p-6 flex flex-col gap-5",tabIndex:-1,get children(){return[(()=>{var m=a7();return p(m,y(Ot.Title,{class:"text-xl font-semibold text-primary",get children(){return t("folderSelection.servers.dialog.title")}}),null),p(m,y(Ot.Description,{class:"text-sm text-secondary mt-2",get children(){return t("folderSelection.servers.dialog.description")}}),null),m})(),(()=>{var m=GS(),w=m.firstChild,S=w.nextSibling;return p(w,()=>t("folderSelection.servers.dialog.name")),S.$$input=b=>s(b.currentTarget.value),de(()=>me(S,"placeholder",t("folderSelection.servers.dialog.namePlaceholder"))),de(()=>S.value=n()),m})(),(()=>{var m=GS(),w=m.firstChild,S=w.nextSibling;return p(w,()=>t("folderSelection.servers.dialog.url")),S.$$input=b=>o(b.currentTarget.value),de(()=>me(S,"placeholder",t("folderSelection.servers.dialog.urlPlaceholder"))),de(()=>S.value=r()),m})(),(()=>{var m=c7(),w=m.firstChild,S=w.nextSibling;return w.addEventListener("change",b=>i(b.currentTarget.checked)),p(S,()=>t("folderSelection.servers.dialog.skipTls")),de(()=>w.checked=a()),m})(),y(ee,{get when(){return c()},children:m=>(()=>{var w=f7();return p(w,m),w})()}),(()=>{var m=d7(),w=m.firstChild,S=w.nextSibling,b=S.nextSibling;return w.$$click=()=>e.onOpenChange(!1),p(w,()=>t("folderSelection.servers.dialog.cancel")),S.$$click=()=>void f(!1),p(S,()=>t("folderSelection.servers.dialog.save")),b.$$click=()=>void f(!0),p(b,y(ee,{get when(){return d()},get fallback(){return(()=>{var v=g7();return p(v,()=>t("folderSelection.servers.dialog.connect")),v})()},get children(){var v=l7();return p(v,y(Zn,{class:"w-4 h-4 animate-spin"}),null),p(v,()=>t("folderSelection.servers.dialog.connecting"),null),v}})),de(v=>{var k=d(),C=d();return k!==v.e&&(S.disabled=v.e=k),C!==v.t&&(b.disabled=v.t=C),v},{e:void 0,t:void 0}),m})()]}})),g})()]}})}})};Xt(["input","click"]);var m7=O('<div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><button type=button class="selector-button selector-button-secondary w-auto"><span></span></button></div><div class=settings-card-content>'),p7=O("<div class=settings-card-message>"),y7=O('<div class="settings-toggle-row settings-toggle-row-compact"><div class=min-w-0><div class="settings-toggle-title truncate"></div><div class="settings-toggle-caption font-mono truncate"></div></div><div class="flex items-center gap-2"><button type=button class="selector-button selector-button-secondary w-auto"></button><button type=button class="selector-button selector-button-secondary w-auto">');const v7=()=>{const{t:e}=Dt(),{remoteServers:t,connectingServerId:n,saveServer:s,connectSavedServer:r,removeRemoteServerProfile:o}=i7(),[a,i]=R(!1);return[(()=>{var c=m7(),l=c.firstChild,d=l.firstChild,u=d.firstChild,f=u.firstChild,g=f.nextSibling,m=d.nextSibling,w=m.firstChild,S=l.nextSibling;return p(d,y(ei,{class:"settings-card-heading-icon"}),u),p(f,()=>e("folderSelection.tabs.servers")),p(g,()=>e("folderSelection.servers.empty.description")),m.$$click=()=>i(!0),p(m,y(of,{class:"w-4 h-4"}),w),p(w,()=>e("folderSelection.actions.connectButton")),p(S,y(ee,{get when(){return t().length>0},get fallback(){return(()=>{var b=p7();return p(b,()=>e("folderSelection.servers.empty.title")),b})()},get children(){return y(zt,{get each(){return t()},children:b=>(()=>{var v=y7(),k=v.firstChild,C=k.firstChild,_=C.nextSibling,T=k.nextSibling,P=T.firstChild,I=P.nextSibling;return p(C,()=>b.name),p(_,()=>b.baseUrl),P.$$click=()=>void r(b.id),p(P,y(ee,{get when(){return n()===b.id},get fallback(){return y(ei,{class:"w-4 h-4"})},get children(){return y(Zn,{class:"w-4 h-4 animate-spin"})}})),I.$$click=()=>o(b.id),p(I,y(af,{class:"w-4 h-4"})),de(j=>{var ne=!!n(),W=`${e("folderSelection.servers.dialog.connect")}: ${b.name}`,q=`${e("folderSelection.servers.dialog.connect")}: ${b.name}`,U=`${e("folderSelection.servers.remove")}: ${b.name}`,G=`${e("folderSelection.servers.remove")}: ${b.name}`;return ne!==j.e&&(P.disabled=j.e=ne),W!==j.t&&me(P,"aria-label",j.t=W),q!==j.a&&me(P,"title",j.a=q),U!==j.o&&me(I,"title",j.o=U),G!==j.i&&me(I,"aria-label",j.i=G),j},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),v})()})}})),c})(),y(h7,{get open(){return a()},onOpenChange:i,onSubmit:s})]};Xt(["click"]);const w7=Ut("api");function Ju(e){return`/sidecars/${encodeURIComponent(e)}/`}const[qT,Cw]=R(new Map),[b7,_g]=R([]),[Ew,Tw]=R(null),[S7,Th]=R(!1);let Vo=null,k7=0;class x7 extends Error{constructor(t){super(t),this.name="SidecarNotFoundError"}}async function zT(e){if(!Vo){Th(!0);const n=kt.fetchSidecars().then(s=>{Cw(new Map(s.sidecars.map(r=>[r.id,r])))});Vo=n,n.then(()=>{Th(!1),Vo===n&&(Vo=null)},s=>{w7.error("Failed to load SideCars",s),Th(!1),Vo===n&&(Vo=null)})}const t=Vo;if(e!=null&&e.propagateErrors)return t;await t.catch(()=>{})}function _7(e){Cw(t=>{const n=new Map(t);return n.set(e.id,e),n}),_g(t=>t.map(n=>n.sidecarId===e.id?{...n,name:e.name,port:e.port,prefixMode:e.prefixMode,proxyBasePath:Ju(e.id).replace(/\/$/,""),shellUrl:Ju(e.id)}:n))}function $7(e){Cw(t=>{const n=new Map(t);return n.delete(e),n}),_g(t=>{var s;const n=t.filter(r=>r.sidecarId!==e);return n.some(r=>r.token===Ew())||Tw(((s=n[0])==null?void 0:s.token)??null),n})}xs.on("sidecar.updated",e=>{e.type==="sidecar.updated"&&_7(e.sidecar)});xs.on("sidecar.removed",e=>{e.type==="sidecar.removed"&&$7(e.sidecarId)});async function fZ(e,t){var o,a;if((o=t==null?void 0:t.signal)!=null&&o.aborted)throw na(t.signal);await E8(()=>zT({propagateErrors:t==null?void 0:t.propagateLoadErrors}),{signal:t==null?void 0:t.signal});const n=qT().get(e);if(!n)throw new x7($e("sidecars.open.notFound"));if(n.status!=="running")throw new Error($e("sidecars.open.notRunning"));const r={token:`${e}:${Date.now().toString(36)}:${(k7++).toString(36)}`,sidecarId:e,name:n.name,port:n.port,prefixMode:n.prefixMode,proxyBasePath:Ju(e).replace(/\/$/,""),shellUrl:Ju(e)};if((a=t==null?void 0:t.signal)!=null&&a.aborted)throw na(t.signal);return _g(i=>[...i,r]),((t==null?void 0:t.activate)??!0)&&Tw(r.token),r}function gZ(e){_g(t=>{const n=t.findIndex(r=>r.token===e);if(n<0)return t;const s=t.filter(r=>r.token!==e);if(Ew()===e){const r=s[n-1]??s[n]??null;Tw((r==null?void 0:r.token)??null)}return s})}Te(()=>b7().find(e=>e.token===Ew())??null);var ZS=O('<div class="text-sm text-red-500">'),C7=O('<div class=settings-section-stack><div class=settings-card><div class=settings-card-header><div class=settings-card-heading-with-icon><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><span class="settings-scope-badge settings-scope-badge-server"></span></div><div class=settings-card-content><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>: <code>/sidecars/</code></div></div><input class="selector-input w-full max-w-xs"></div><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>127.0.0.1</div></div><input class="selector-input w-full max-w-xs"inputmode=numeric></div><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><select class="selector-input w-full max-w-xs"><option value=https></option><option value=http></option></select></div><div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption></div></div><select class="selector-input w-full max-w-xs"><option value=strip></option><option value=preserve></option></select></div><div class="flex justify-end"><button type=button class="selector-button selector-button-primary w-auto"><span></span></button></div></div></div><div class=settings-card><div class=settings-card-header><div><h3 class=settings-card-title></h3><p class=settings-card-subtitle></p></div></div><div class=settings-card-content>'),YS=O("<div class=settings-card-message>"),E7=O('<div class="settings-toggle-row settings-toggle-row-compact"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption> · <!>://127.0.0.1:</div><div class=settings-toggle-caption>: <code>/sidecars/</code> · </div></div><div class="flex items-center gap-2"><span class="text-xs text-secondary min-w-[4.5rem] text-right"></span><button type=button class="selector-button selector-button-secondary w-auto">');function T7(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")}const M7=()=>{const{t:e}=Dt(),[t,n]=R(""),[s,r]=R("3000"),[o,a]=R(!1),[i,c]=R("strip"),[l,d]=R(null),[u,f]=R(!1),[g,m]=R(null),[w,S]=R(null);Ys(()=>{zT()});const b=Te(()=>Array.from(qT().values()).sort((_,T)=>_.name.localeCompare(T.name))),v=Te(()=>T7(t())||"your-sidecar");async function k(){const _=t().trim(),T=Number(s());if(!_||!Number.isInteger(T)||T<=0||T>65535){m(e("sidecars.form.validation"));return}f(!0),m(null);try{await kt.createSidecar({kind:"port",name:_,port:T,insecure:o(),prefixMode:i()}),n(""),r("3000"),a(!1),c("strip")}catch(P){m(P instanceof Error?P.message:String(P))}finally{f(!1)}}async function C(_){d(_),S(null);try{await kt.deleteSidecar(_)}catch(T){S(T instanceof Error?T.message:String(T))}finally{d(null)}}return(()=>{var _=C7(),T=_.firstChild,P=T.firstChild,I=P.firstChild,j=I.firstChild,ne=j.firstChild,W=ne.nextSibling,q=I.nextSibling,U=P.nextSibling,G=U.firstChild,le=G.firstChild,K=le.firstChild,M=K.nextSibling,N=M.firstChild,oe=N.nextSibling;oe.firstChild;var ge=le.nextSibling,Ie=G.nextSibling,ke=Ie.firstChild,we=ke.firstChild,Ae=ke.nextSibling,Ge=Ie.nextSibling,H=Ge.firstChild,h=H.firstChild,$=h.nextSibling,D=H.nextSibling,E=D.firstChild,Z=E.nextSibling,B=Ge.nextSibling,se=B.firstChild,pe=se.firstChild,Se=pe.nextSibling,Q=se.nextSibling,be=Q.firstChild,Ve=be.nextSibling,He=B.nextSibling,re=He.firstChild,F=re.firstChild,V=T.nextSibling,Me=V.firstChild,xe=Me.firstChild,Re=xe.firstChild,Be=Re.nextSibling,et=Me.nextSibling;return p(I,y(ei,{class:"settings-card-heading-icon"}),j),p(ne,()=>e("settings.section.sidecars.title")),p(W,()=>e("settings.section.sidecars.subtitle")),p(q,()=>e("settings.scope.server")),p(K,()=>e("sidecars.form.name")),p(M,()=>e("sidecars.basePath"),N),p(oe,v,null),ge.$$input=Ue=>{m(null),n(Ue.currentTarget.value)},p(we,()=>e("sidecars.form.port")),Ae.$$input=Ue=>{m(null),r(Ue.currentTarget.value)},p(h,()=>e("sidecars.form.protocol")),p($,()=>e("sidecars.form.protocol.help")),D.addEventListener("change",Ue=>a(Ue.currentTarget.value==="http")),p(E,()=>e("sidecars.form.protocol.https")),p(Z,()=>e("sidecars.form.protocol.http")),p(pe,()=>e("sidecars.form.prefixMode")),p(Se,()=>e("sidecars.form.prefixMode.help")),Q.addEventListener("change",Ue=>c(Ue.currentTarget.value)),p(be,()=>e("sidecars.form.prefixMode.strip")),p(Ve,()=>e("sidecars.form.prefixMode.preserve")),p(U,y(ee,{get when(){return g()},get children(){var Ue=ZS();return p(Ue,g),Ue}}),He),re.$$click=()=>void k(),p(re,y(ee,{get when(){return u()},get fallback(){return y(of,{class:"w-4 h-4"})},get children(){return y(Zn,{class:"w-4 h-4 animate-spin"})}}),F),p(F,()=>e("sidecars.form.add")),p(Re,()=>e("sidecars.settings.listTitle")),p(Be,()=>e("sidecars.settings.listSubtitle")),p(et,y(ee,{get when(){return w()},get children(){var Ue=ZS();return p(Ue,w),Ue}}),null),p(et,y(ee,{get when(){return!S7()},get fallback(){return(()=>{var Ue=YS();return p(Ue,()=>e("sidecars.picker.loading")),Ue})()},get children(){return y(ee,{get when(){return b().length>0},get fallback(){return(()=>{var Ue=YS();return p(Ue,()=>e("sidecars.settings.empty")),Ue})()},get children(){return y(zt,{get each(){return b()},children:Ue=>(()=>{var We=E7(),st=We.firstChild,at=st.firstChild,ht=at.nextSibling,ut=ht.firstChild,Ct=ut.nextSibling;Ct.nextSibling;var Qe=ht.nextSibling,tt=Qe.firstChild,At=tt.nextSibling;At.firstChild,At.nextSibling;var xt=st.nextSibling,x=xt.firstChild,A=x.nextSibling;return p(at,()=>Ue.name),p(ht,()=>e("sidecars.kind.port"),ut),p(ht,()=>Ue.insecure?"http":"https",Ct),p(ht,()=>Ue.port,null),p(Qe,()=>e("sidecars.basePath"),tt),p(At,()=>Ue.id,null),p(Qe,()=>e(`sidecars.form.prefixMode.${Ue.prefixMode}`),null),p(x,()=>e(`sidecars.status.${Ue.status}`)),A.$$click=()=>void C(Ue.id),p(A,y(af,{class:"w-4 h-4"})),de(()=>A.disabled=l()===Ue.id),We})()})}})}}),null),de(()=>re.disabled=u()),de(()=>ge.value=t()),de(()=>Ae.value=s()),de(()=>D.value=o()?"http":"https"),de(()=>Q.value=i()),_})()};Xt(["input","click"]);async function Ec(e){if($n.host==="electron"){const t=window.electronAPI,n=e==="minimize"?t==null?void 0:t.minimizeWindow:e==="maximize"?t==null?void 0:t.toggleMaximizeWindow:t==null?void 0:t.closeWindow;if(!n)throw new Error(`Native window action is unavailable: ${e}`);await n();return}$n.host==="tauri"&&await Ms("window_control",{action:e})}async function A7(){$n.host==="tauri"&&await Ms("window_control",{action:"drag"})}async function D7(e,t){var r;const n=t.getBoundingClientRect(),s={x:n.left,y:n.bottom};if($n.host==="electron"){if(!((r=window.electronAPI)!=null&&r.showTitlebarMenu))throw new Error("Native titlebar menus are unavailable");await window.electronAPI.showTitlebarMenu(e,s.x,s.y)}else $n.host==="tauri"&&await Ms("popup_titlebar_menu",{menu:e,...s})}var P7=O("<nav class=native-titlebar-menu data-titlebar-interactive>"),I7=O('<header class=native-titlebar><div class=native-titlebar-brand><span class=native-titlebar-title></span></div><div class=native-titlebar-drag-region></div><div class=native-titlebar-controls><button type=button class=native-titlebar-button data-titlebar-interactive></button><button type=button class=native-titlebar-button data-titlebar-interactive></button><button type=button class="native-titlebar-button native-titlebar-close"data-titlebar-interactive>'),R7=O("<button type=button class=native-titlebar-menu-button>");const O7=["file","edit","view","window","help"],L7=e=>{const{t}=Dt(),n=()=>e.onClose?e.onClose():Ec("close");return(()=>{var s=I7(),r=s.firstChild,o=r.firstChild,a=r.nextSibling,i=a.nextSibling,c=i.firstChild,l=c.nextSibling,d=l.nextSibling;return s.$$dblclick=u=>{u.target.closest("[data-titlebar-interactive]")||Ec("maximize")},s.$$pointerdown=u=>{u.button===0&&!u.target.closest("[data-titlebar-interactive]")&&A7()},p(o,()=>e.title),p(s,y(ee,{get when(){return e.menus},get children(){var u=P7();return p(u,y(zt,{each:O7,children:f=>(()=>{var g=R7();return g.$$click=m=>void D7(f,m.currentTarget),p(g,()=>t(`window.menu.${f}`)),g})()})),de(()=>me(u,"aria-label",t("window.menu.ariaLabel"))),u}}),a),c.$$click=()=>void Ec("minimize"),p(c,y(ID,{"aria-hidden":"true"})),l.$$click=()=>void Ec("maximize"),p(l,y(TD,{"aria-hidden":"true"})),d.$$click=()=>void n(),p(d,y(ti,{"aria-hidden":"true"})),de(u=>{var f=t("window.controls.minimize"),g=t("window.controls.minimize"),m=t("window.controls.maximize"),w=t("window.controls.maximize"),S=t("window.controls.close"),b=t("window.controls.close");return f!==u.e&&me(c,"aria-label",u.e=f),g!==u.t&&me(c,"title",u.t=g),m!==u.a&&me(l,"aria-label",u.a=m),w!==u.o&&me(l,"title",u.o=w),S!==u.i&&me(d,"aria-label",u.i=S),b!==u.n&&me(d,"title",u.n=b),u},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),s})()};Xt(["pointerdown","dblclick","click"]);function N7(e,t,n){Ze(()=>{const s=t(),r=e();if(!s||!r)return;let o=!0,a=0;const i=s.scrollTop??0,c=()=>{o&&(r.scrollTop=i,r.scrollHeight-r.clientHeight>=i&&(cancelAnimationFrame(a),a=requestAnimationFrame(()=>{o=!1})))},l=()=>{o=!1,cancelAnimationFrame(a)},d=g=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(g.key)&&l()},u=()=>{o||n(Math.round(r.scrollTop))},f=new ResizeObserver(c);f.observe(r);for(const g of r.children)f.observe(g);r.addEventListener("scroll",u),r.addEventListener("wheel",l,{passive:!0}),r.addEventListener("pointerdown",l),r.addEventListener("keydown",d),c(),dt(()=>{f.disconnect(),cancelAnimationFrame(a),r.removeEventListener("scroll",u),r.removeEventListener("wheel",l),r.removeEventListener("pointerdown",l),r.removeEventListener("keydown",d)})})}var F7=O("<div class=settings-section-stack>"),B7=O("<h1 class=sr-only>"),U7=O('<div class="flex-1 min-w-0">'),K7=O('<button type=button class="window-icon-button settings-screen-close settings-screen-compact-close">'),V7=O('<aside class=settings-screen-nav><div class="window-toolbar settings-screen-compact-bar"><span class=settings-screen-compact-icon-wrap></span><div class=settings-section-selector-wrap></div></div><div class="window-header settings-screen-nav-header settings-screen-drag-handle"><div class=settings-screen-nav-title-row><span class=settings-screen-nav-icon-wrap></span><div><h2 class="window-title settings-screen-title"></h2></div></div></div><nav class=settings-screen-nav-list>'),j7=O('<button type=button class="window-icon-button settings-screen-close">'),q7=O('<div class=settings-screen-content><header class="window-header settings-screen-content-header settings-screen-drag-handle"><div class=settings-screen-content-header-title-group><p class=settings-screen-content-eyebrow></p><h1 class="window-title settings-screen-content-title"></h1></div></header><div class="window-body settings-screen-scroll">'),z7=O('<span class=settings-section-selector-value><span class="selector-trigger-primary selector-trigger-primary--align-left">'),W7=O("<button type=button class=settings-nav-button><span>"),H7=O('<div class=settings-window-root><div class="modal-surface window-shell settings-screen-shell">'),G7=O("<div class=settings-screen-frame>");const Z7=e=>{const{t}=Dt(),n=$4("(max-width: 640px)"),s=Te(()=>{const b=[{id:"general",icon:QD,label:t("settings.nav.general")},{id:"chat",icon:AD,label:t("settings.nav.chat")},{id:"notifications",icon:Jk,label:t("settings.nav.notifications")},{id:"speech",icon:Kh,label:t("settings.nav.speech")},{id:"opencode",icon:Kp,label:t("settings.nav.opencode")},{id:"providers",icon:ex,label:t("settings.nav.providers")},{id:"sidecars",icon:ei,label:t("settings.nav.sidecars")},{id:"config-files",icon:QA,label:t("settings.nav.configFiles")},{id:"advanced",icon:nd,label:t("settings.nav.advanced")},{id:"info",icon:Up,label:t("settings.nav.info")}];return(e.standalone||ia())&&b.splice(4,0,{id:"remote",icon:OD,label:t("settings.nav.remote")}),b}),r=Te(()=>s().find(b=>b.id===Ii())??s()[0]),o=()=>{switch(Ii()){case"chat":return y(uR,{});case"notifications":return y(ZR,{});case"speech":return y(yO,{});case"remote":return e.standalone||ia()?(()=>{var b=F7();return p(b,y(r7,{}),null),p(b,y(v7,{}),null),b})():y(Rb,{showStartupState:!0});case"opencode":return y(Rz,{});case"providers":return y(Tz,{get instanceId(){var b;return(b=e.providerContext)==null?void 0:b.instanceId},get location(){var b;return(b=e.providerContext)==null?void 0:b.location}});case"sidecars":return y(M7,{});case"config-files":return y(Jz,{});case"advanced":return y(Kz,{});case"info":return y(TR,{});case"general":default:return y(Rb,{get showStartupState(){return!e.standalone}})}},a=async b=>{var v;b!==Ii()&&await Qi()&&(await((v=e.onSectionChange)==null?void 0:v.call(e,b)),sy(b),u==null||u.scrollTo({top:0}))},i=async()=>{await Qi()&&(e.onClose?await e.onClose():N4())},[c,l]=R({x:0,y:0});Ze(()=>{n()&&l({x:0,y:0})});let d,u;N7(()=>u,()=>(Ii(),e.scrollPosition),b=>{var v;return(v=e.onScrollPositionChange)==null?void 0:v.call(e,b)});let f;const g=b=>{if(e.standalone||n()||b.button!==0||b.target.closest("button, input, select, textarea, a")||!d)return;const v=c(),k=d.getBoundingClientRect();f={...v,pointerX:b.clientX,pointerY:b.clientY,minX:v.x+16-k.left,maxX:v.x+window.innerWidth-16-k.right,minY:v.y+16-k.top,maxY:v.y+window.innerHeight-16-k.bottom},b.currentTarget.setPointerCapture(b.pointerId),b.preventDefault()},m=b=>{f&&l({x:Math.min(f.maxX,Math.max(f.minX,f.x+b.clientX-f.pointerX)),y:Math.min(f.maxY,Math.max(f.minY,f.y+b.clientY-f.pointerY))})},w=b=>{f=void 0;const v=b.currentTarget;v.hasPointerCapture(b.pointerId)&&v.releasePointerCapture(b.pointerId)},S=()=>[y(ee,{get when(){return e.standalone},get children(){var b=B7();return p(b,()=>t("settings.title")),b}}),(()=>{var b=V7(),v=b.firstChild,k=v.firstChild,C=k.nextSibling,_=v.nextSibling,T=_.firstChild,P=T.firstChild,I=P.nextSibling,j=I.firstChild,ne=_.nextSibling;return p(k,y(nd,{class:"settings-screen-nav-icon"})),p(C,y(De,{get value(){return r()},onChange:W=>W&&void a(W.id),get options(){return s()},optionValue:"id",optionTextValue:"label",itemComponent:W=>{const q=W.item.rawValue.icon;return y(De.Item,{get item(){return W.item},class:"selector-option settings-section-selector-option",get children(){return[y(q,{class:"settings-section-selector-option-icon"}),y(De.ItemLabel,{class:"selector-option-label",get children(){return W.item.rawValue.label}})]}})},get children(){return[y(De.Trigger,{class:"selector-trigger settings-section-selector-trigger",get"aria-label"(){return t("settings.navigationAriaLabel")},get children(){return[(()=>{var W=U7();return p(W,y(De.Value,{children:q=>{const U=q.selectedOption(),G=(U==null?void 0:U.icon)??nd;return(()=>{var le=z7(),K=le.firstChild;return p(le,y(G,{class:"settings-section-selector-value-icon"}),K),p(K,()=>U==null?void 0:U.label),le})()}})),W})(),y(De.Icon,{class:"selector-trigger-icon",get children(){return y(fr,{class:"w-3 h-3"})}})]}}),y(De.Portal,{get children(){return y(De.Content,{class:"selector-popover settings-section-selector-popover",get children(){return y(De.Listbox,{class:"selector-listbox"})}})}})]}})),p(v,y(ee,{get when(){return!e.standalone},get children(){var W=K7();return W.$$click=()=>void i(),p(W,y(ti,{class:"w-4 h-4"})),de(q=>{var U=t("settings.close"),G=t("settings.close");return U!==q.e&&me(W,"aria-label",q.e=U),G!==q.t&&me(W,"title",q.t=G),q},{e:void 0,t:void 0}),W}}),null),_.addEventListener("pointercancel",w),_.$$pointerup=w,_.$$pointermove=m,_.$$pointerdown=g,p(P,y(nd,{class:"settings-screen-nav-icon"})),p(j,()=>t("settings.title")),p(ne,y(zt,{get each(){return s()},children:W=>{const q=W.icon;return(()=>{var U=W7(),G=U.firstChild;return U.$$click=()=>void a(W.id),p(U,y(q,{class:"settings-nav-button-icon"}),G),p(G,()=>W.label),de(le=>{var K=Ii()===W.id?"true":"false",M=Ii()===W.id?"page":void 0;return K!==le.e&&me(U,"data-selected",le.e=K),M!==le.t&&me(U,"aria-current",le.t=M),le},{e:void 0,t:void 0}),U})()}})),de(()=>me(ne,"aria-label",t("settings.navigationAriaLabel"))),b})(),(()=>{var b=q7(),v=b.firstChild,k=v.firstChild,C=k.firstChild,_=C.nextSibling,T=v.nextSibling;v.addEventListener("pointercancel",w),v.$$pointerup=w,v.$$pointermove=m,v.$$pointerdown=g,p(C,()=>t("settings.content.eyebrow")),p(_,()=>{var I;return(I=r())==null?void 0:I.label}),p(v,y(ee,{get when(){return!e.standalone},get children(){var I=j7();return I.$$click=()=>void i(),p(I,y(ti,{class:"w-4 h-4"})),de(j=>{var ne=t("settings.close"),W=t("settings.close");return ne!==j.e&&me(I,"aria-label",j.e=ne),W!==j.t&&me(I,"title",j.t=W),j},{e:void 0,t:void 0}),I}}),null);var P=u;return typeof P=="function"?dr(P,T):u=T,p(T,o),b})()];return e.standalone?(()=>{var b=H7(),v=b.firstChild;p(b,y(L7,{get title(){return t("settings.title")},onClose:i}),v);var k=d;return typeof k=="function"?dr(k,v):d=v,p(v,S),b})():y(Ot,{get modal(){return n()},get preventScroll(){return n()},get open(){return jx()},onOpenChange:b=>!b&&void i(),get children(){return y(Ot.Portal,{get children(){var b=G7();return p(b,y(Ot.Content,{ref(v){var k=d;typeof k=="function"?k(v):d=v},class:"modal-surface window-shell settings-screen-shell",get style(){return{transform:`translate(${c().x}px, ${c().y}px)`}},onInteractOutside:v=>v.preventDefault(),get children(){return[y(Ot.Title,{class:"sr-only",get children(){return t("settings.title")}}),Ee(()=>S())]}})),b}})}})};Xt(["click","pointerdown","pointermove","pointerup"]);const Y7=()=>{const[e,t]=R({section:"general"}),n=[];let s=Promise.resolve(),r,o=0,a,i=Promise.resolve();const c=(g,m)=>(i=i.catch(()=>{}).then(()=>M4(g(),m)),i),l=g=>(clearTimeout(a),a=void 0,c(()=>({...e(),scrollTop:o}),g)),d=async g=>{await s.catch(()=>{}),await l(g)},u=async(g,m=!0)=>{if(m&&!await Qi())return;clearTimeout(a),m&&await c(()=>g);const w=e().instanceId;w&&w!==g.instanceId&&fa.destroyClientsForInstance(w),o=g.scrollTop??0,gn(()=>{t(g),sy(g.section)})},f=async(g=!0)=>r||(r=(async()=>{(!g||await Qi())&&(await d(),await Ec("close"))})().finally(()=>{r=void 0}),r);return Ys(()=>{let g=!0,m=!1,w=!1,S=!1,b=!1,v=!1;(async()=>{try{const k=await P4(C=>{m=!0,g&&(s=s.catch(()=>{}).then(()=>u(C)))});if(!g)return k();n.push(k),w=!0}catch{}try{const k=await D4();g&&!m&&await u(k,!1)}catch{}try{const k=await I4(()=>void f());if(!g)return k();n.push(k),S=!0}catch{}try{const k=await R4(C=>{s=s.catch(()=>{}).then(async()=>{const _=await Qi();_&&await l(),await O4(C,_)})});if(!g)return k();n.push(k),b=!0}catch{}try{const k=await A4(d);if(!g)return k();n.push(k),v=!0}catch{}w&&S&&b&&v&&await T4()})(),dt(()=>{g=!1,clearTimeout(a),n.splice(0).forEach(C=>C());const k=e().instanceId;k&&fa.destroyClientsForInstance(k)})}),[y(Z7,{standalone:!0,get providerContext(){return{instanceId:e().instanceId,location:e().location}},get scrollPosition(){return e()},onScrollPositionChange:g=>{o=g,clearTimeout(a),a=setTimeout(()=>{l().catch(()=>{})},150)},onSectionChange:async g=>{clearTimeout(a);const m={...e(),section:g,scrollTop:0};await c(()=>m),o=0,t(m)},onClose:()=>f(!1)}),y(cA,{}),y(zP,{automatic:!1}),y(FM,{position:"top-right",gutter:16,toastOptions:{duration:8e3,className:"bg-transparent border-none shadow-none p-0"}})]},WT=document.getElementById("root");if(!WT)throw new Error("Root element not found");const J7=WT;typeof document<"u"&&(document.documentElement.dataset.runtimeHost=$n.host,document.documentElement.dataset.runtimePlatform=$n.platform);async function Q7(){var t;let e=Y7;if(Cp($n)){const[{initializeClientState:n},s]=await Promise.all([ls(()=>import("./client-state-BUfw9mlB.js").then(r=>r.j),__vite__mapDeps([8,2,3,4,5,6,1,7])),ls(()=>import("./App-DJjznRZ_.js").then(r=>r.ac),__vite__mapDeps([11,1,2,3,4,5,6,7,8]))]);await n(),e=s.default}if(typeof document<"u")try{const[n,s]=await Promise.all([Iw.loadConfigOwner("ui"),Iw.loadStateOwner("ui")]),r=(s==null?void 0:s.theme)??(n==null?void 0:n.theme),o=(s==null?void 0:s.colorScheme)??(n==null?void 0:n.colorScheme),a=typeof((t=n==null?void 0:n.settings)==null?void 0:t.locale)=="string"?n.settings.locale:void 0;Rw(Ui(o,r),{systemDark:window.matchMedia("(prefers-color-scheme: dark)").matches}),await Aw(a)}catch{Rw(Ui("system"),{systemDark:window.matchMedia("(prefers-color-scheme: dark)").matches}),await Aw()}pM(()=>y(wM,{get children(){return y(yM,{get children(){return y(XT,{get children(){return y(vM,{get children(){return y(e,{})}})}})}})}}),J7)}Q7();export{Kt as $,kH as A,Jk as B,jA as C,Ot as D,Yi as E,Xk as F,ei as G,_H as H,nt as I,CH as J,of as K,K4 as L,OD as M,hH as N,bH as O,KD as P,Fe as Q,h7 as R,nd as S,af as T,co as U,Nn as V,h8 as W,ti as X,Y8 as Y,FE as Z,ty as _,Hn as a,Rk as a$,Ik as a0,Ih as a1,Or as a2,i2 as a3,Tr as a4,bs as a5,ja as a6,Ex as a7,Kn as a8,en as a9,A9 as aA,Hx as aB,Fo as aC,U8 as aD,w9 as aE,Ht as aF,es as aG,$9 as aH,_9 as aI,wO as aJ,bO as aK,Ne as aL,lg as aM,Mq as aN,hr as aO,x9 as aP,b0 as aQ,mu as aR,km as aS,GH as aT,WH as aU,HH as aV,OG as aW,dH as aX,oH as aY,he as aZ,Vp as a_,Dk as aa,ml as ab,aH as ac,iH as ad,on as ae,yl as af,Gd as ag,mo as ah,mc as ai,ca as aj,pc as ak,d9 as al,iT as am,Yk as an,u9 as ao,fT as ap,v9 as aq,Zr as ar,pH as as,qH as at,KH as au,e_ as av,EH as aw,ua as ax,vT as ay,bp as az,Fb as b,eG as b$,vl as b0,rI as b1,vs as b2,Np as b3,Qz as b4,cH as b5,On as b6,dI as b7,Ek as b8,lx as b9,ZH as bA,UG as bB,uN as bC,lN as bD,cN as bE,aN as bF,JH as bG,Ta as bH,nR as bI,$t as bJ,Lu as bK,ng as bL,mE as bM,J8 as bN,wH as bO,TC as bP,AC as bQ,RC as bR,hj as bS,cy as bT,vH as bU,g_ as bV,mj as bW,cb as bX,fr as bY,dN as bZ,K_ as b_,Mk as ba,Ok as bb,Bw as bc,Kh as bd,QR as be,A6 as bf,Up as bg,b7 as bh,cZ as bi,VE as bj,Tw as bk,lZ as bl,f9 as bm,Ew as bn,Ds as bo,x8 as bp,Oa as bq,vp as br,dZ as bs,Ol as bt,tg as bu,zH as bv,YH as bw,QH as bx,D6 as by,KG as bz,i7 as c,Zo as c$,j_ as c0,Zv as c1,jq as c2,gq as c3,GC as c4,XC as c5,uq as c6,uH as c7,xy as c8,NH as c9,fx as cA,sI as cB,d2 as cC,lH as cD,lI as cE,qp as cF,tf as cG,sr as cH,ff as cI,Ax as cJ,uf as cK,df as cL,lf as cM,cf as cN,ny as cO,zp as cP,TH as cQ,GO as cR,Jf as cS,Ti as cT,Da as cU,ex as cV,Ez as cW,p_ as cX,PL as cY,IH as cZ,qg as c_,FH as ca,sO as cb,Yb as cc,rO as cd,vu as ce,tG as cf,Rv as cg,y9 as ch,BH as ci,k6 as cj,Ig as ck,Jo as cl,NG as cm,LG as cn,BD as co,RG as cp,_E as cq,pr as cr,Hp as cs,Tx as ct,Mx as cu,cI as cv,gH as cw,dx as cx,ux as cy,Dx as cz,qx as d,k8 as d$,ko as d0,De as d1,wi as d2,MH as d3,RH as d4,AH as d5,tA as d6,Aq as d7,yE as d8,Uq as d9,xC as dA,Mv as dB,HC as dC,_C as dD,eq as dE,tq as dF,Aj as dG,_q as dH,Rj as dI,kG as dJ,xG as dK,BA as dL,db as dM,Cq as dN,_G as dO,Zf as dP,Ei as dQ,DG as dR,Ij as dS,EG as dT,PG as dU,Hv as dV,Tq as dW,gE as dX,iZ as dY,aZ as dZ,gy as d_,SG as da,TG as db,wq as dc,MG as dd,Fq as de,DC as df,MC as dg,EC as dh,IC as di,PC as dj,CC as dk,M6 as dl,FG as dm,ij as dn,_6 as dp,x6 as dq,S6 as dr,t6 as ds,yg as dt,sR as du,Lb as dv,rR as dw,zs as dx,lp as dy,Dq as dz,h9 as e,cA as e$,PH as e0,DH as e1,fE as e2,Iv as e3,uE as e4,Pq as e5,Vv as e6,RE as e7,Sf as e8,vn as e9,$G as eA,uZ as eB,Lv as eC,hq as eD,OH as eE,JC as eF,Zs as eG,XH as eH,WG as eI,XG as eJ,E8 as eK,zG as eL,o9 as eM,VG as eN,fZ as eO,x7 as eP,g9 as eQ,lT as eR,D8 as eS,CG as eT,zP as eU,lw as eV,rZ as eW,L7 as eX,YG as eY,oZ as eZ,Z7 as e_,TD as ea,oE as eb,$C as ec,E6 as ed,rE as ee,qT as ef,zT as eg,S7 as eh,Lq as ei,lE as ej,BG as ek,mH as el,mq as em,LH as en,fq as eo,UH as ep,na as eq,Tv as er,jG as es,Uv as et,kq as eu,qG as ev,bq as ew,Sq as ex,Ku as ey,$q as ez,Zn as f,FM as f0,E9 as f1,JG as f2,c8 as f3,d8 as f4,Bp as f5,u8 as f6,gZ as f7,$6 as f8,Ia as f9,n9 as fa,ql as fb,pw as fc,QE as fd,mr as fe,No as ff,p9 as fg,VH as fh,zx as fi,UL as fj,jH as fk,yH as fl,AA as fm,Qk as fn,jv as fo,Iq as fp,Zt as fq,k9 as fr,ea as fs,WD as ft,cn as g,HG as h,iD as i,SP as j,MP as k,fH as l,jx as m,m9 as n,M9 as o,Ns as p,IG as q,xS as r,QG as s,AG as t,$4 as u,rD as v,$H as w,NR as x,xH as y,SH as z};
|
|
43
|
+
//# sourceMappingURL=main-CcoQlXKa.js.map
|