@neuralnomads/codenomad-dev 0.20.0-dev-20260923-baf674fc → 0.20.0-dev-20260924-70aae0b1

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.
Files changed (108) hide show
  1. package/dist/api-types.js.map +1 -1
  2. package/dist/opencode-update/npm-runtime.js +22 -0
  3. package/dist/opencode-update/npm-runtime.js.map +1 -0
  4. package/dist/opencode-update/retired-installation.js +41 -0
  5. package/dist/opencode-update/retired-installation.js.map +1 -0
  6. package/dist/opencode-update/retired-installation.test.js +39 -0
  7. package/dist/opencode-update/retired-installation.test.js.map +1 -0
  8. package/dist/opencode-update/service.js +4 -3
  9. package/dist/opencode-update/service.js.map +1 -1
  10. package/dist/opencode-update/service.test.js +2 -2
  11. package/dist/opencode-update/service.test.js.map +1 -1
  12. package/dist/opencode-update/shared-installation.js +8 -5
  13. package/dist/opencode-update/shared-installation.js.map +1 -1
  14. package/dist/opencode-update/shared-installation.test.js +4 -2
  15. package/dist/opencode-update/shared-installation.test.js.map +1 -1
  16. package/dist/settings/binaries.js +3 -2
  17. package/dist/settings/binaries.js.map +1 -1
  18. package/dist/workspaces/spawn.js +7 -2
  19. package/dist/workspaces/spawn.js.map +1 -1
  20. package/package.json +1 -1
  21. package/public/assets/{App-DHe1TgnC.js → App-DXfroBn-.js} +7 -7
  22. package/public/assets/{App-DHe1TgnC.js.map → App-DXfroBn-.js.map} +1 -1
  23. package/public/assets/{FilesTab-D8Ik74MT.js → FilesTab-JN0c2Op2.js} +2 -2
  24. package/public/assets/{FilesTab-D8Ik74MT.js.map → FilesTab-JN0c2Op2.js.map} +1 -1
  25. package/public/assets/{GitChangesTab-CYn01GSK.js → GitChangesTab-8MxRVYHz.js} +2 -2
  26. package/public/assets/{GitChangesTab-CYn01GSK.js.map → GitChangesTab-8MxRVYHz.js.map} +1 -1
  27. package/public/assets/{SplitFilePanel-DxTSWUXW.js → SplitFilePanel-VXkE7jgT.js} +2 -2
  28. package/public/assets/{SplitFilePanel-DxTSWUXW.js.map → SplitFilePanel-VXkE7jgT.js.map} +1 -1
  29. package/public/assets/{StatusTab-CLJHjaqS.js → StatusTab-DljyzM07.js} +2 -2
  30. package/public/assets/{StatusTab-CLJHjaqS.js.map → StatusTab-DljyzM07.js.map} +1 -1
  31. package/public/assets/{align-justify-DYu1Iipu.js → align-justify-BMi4r2XK.js} +2 -2
  32. package/public/assets/{align-justify-DYu1Iipu.js.map → align-justify-BMi4r2XK.js.map} +1 -1
  33. package/public/assets/{bundle-full-DbjjKxlx.js → bundle-full-LgLNZmib.js} +2 -2
  34. package/public/assets/{bundle-full-DbjjKxlx.js.map → bundle-full-LgLNZmib.js.map} +1 -1
  35. package/public/assets/{client-state-LGeRE6k3.js → client-state-DTQzqBPJ.js} +2 -2
  36. package/public/assets/{client-state-LGeRE6k3.js.map → client-state-DTQzqBPJ.js.map} +1 -1
  37. package/public/assets/{diff-viewer-D_koHVvF.js → diff-viewer-Dxjea-rB.js} +2 -2
  38. package/public/assets/{diff-viewer-D_koHVvF.js.map → diff-viewer-Dxjea-rB.js.map} +1 -1
  39. package/public/assets/index-9bba6B1A.js +2 -0
  40. package/public/assets/index-9bba6B1A.js.map +1 -0
  41. package/public/assets/index-C5i7ut9u.js +2 -0
  42. package/public/assets/index-C5i7ut9u.js.map +1 -0
  43. package/public/assets/index-CLtLzsWy.js +2 -0
  44. package/public/assets/index-CLtLzsWy.js.map +1 -0
  45. package/public/assets/index-CTVIWXHZ.js +2 -0
  46. package/public/assets/index-CTVIWXHZ.js.map +1 -0
  47. package/public/assets/{index-CXyTJ12Z.js → index-Cgp1TEtC.js} +2 -2
  48. package/public/assets/{index-CXyTJ12Z.js.map → index-Cgp1TEtC.js.map} +1 -1
  49. package/public/assets/index-Cqd_P8c4.js +2 -0
  50. package/public/assets/index-Cqd_P8c4.js.map +1 -0
  51. package/public/assets/{index-CHztP7Qx.js → index-DTGOXoDH.js} +2 -2
  52. package/public/assets/{index-CHztP7Qx.js.map → index-DTGOXoDH.js.map} +1 -1
  53. package/public/assets/index-D_H_gYdX.js +2 -0
  54. package/public/assets/index-D_H_gYdX.js.map +1 -0
  55. package/public/assets/index-Dsd7n295.js +2 -0
  56. package/public/assets/index-Dsd7n295.js.map +1 -0
  57. package/public/assets/index-DwKq8v48.js +3 -0
  58. package/public/assets/index-DwKq8v48.js.map +1 -0
  59. package/public/assets/index-TnTncRlr.js +2 -0
  60. package/public/assets/index-TnTncRlr.js.map +1 -0
  61. package/public/assets/index-eb2qu-xk.js +2 -0
  62. package/public/assets/index-eb2qu-xk.js.map +1 -0
  63. package/public/assets/{loading-1PhCNPTJ.js → loading-j5J_ghLL.js} +2 -2
  64. package/public/assets/{loading-1PhCNPTJ.js.map → loading-j5J_ghLL.js.map} +1 -1
  65. package/public/assets/{main-UjL26F9i.js → main-Cv7E0c7r.js} +7 -7
  66. package/public/assets/{main-UjL26F9i.js.map → main-Cv7E0c7r.js.map} +1 -1
  67. package/public/assets/{markdown-BFEzPV6Z.js → markdown-Cg65SCwC.js} +4 -4
  68. package/public/assets/{markdown-BFEzPV6Z.js.map → markdown-Cg65SCwC.js.map} +1 -1
  69. package/public/assets/{startup-state-settings-card-X1QA2uNM.js → startup-state-settings-card-DMFtdRoa.js} +2 -2
  70. package/public/assets/{startup-state-settings-card-X1QA2uNM.js.map → startup-state-settings-card-DMFtdRoa.js.map} +1 -1
  71. package/public/assets/{terminal-square-BkG0S2-Z.js → terminal-square-DCn_Ac2k.js} +2 -2
  72. package/public/assets/{terminal-square-BkG0S2-Z.js.map → terminal-square-DCn_Ac2k.js.map} +1 -1
  73. package/public/assets/{todo-DKme4PqO.js → todo-DyaFCX9E.js} +2 -2
  74. package/public/assets/{todo-DKme4PqO.js.map → todo-DyaFCX9E.js.map} +1 -1
  75. package/public/assets/{tool-call-DZIN0BAW.js → tool-call-DlJUX9AW.js} +4 -4
  76. package/public/assets/{tool-call-DZIN0BAW.js.map → tool-call-DlJUX9AW.js.map} +1 -1
  77. package/public/assets/{unified-picker-Ml-4x3ux.js → unified-picker-CrW1bp1Y.js} +2 -2
  78. package/public/assets/{unified-picker-Ml-4x3ux.js.map → unified-picker-CrW1bp1Y.js.map} +1 -1
  79. package/public/assets/{wrap-text-B_W6fnE7.js → wrap-text-DLR5jp4s.js} +2 -2
  80. package/public/assets/{wrap-text-B_W6fnE7.js.map → wrap-text-DLR5jp4s.js.map} +1 -1
  81. package/public/index.html +2 -2
  82. package/public/loading.html +2 -2
  83. package/public/sw.js +1 -1
  84. package/public/sw.js.map +1 -1
  85. package/dist/opencode-update/managed-installation.js +0 -102
  86. package/dist/opencode-update/managed-installation.js.map +0 -1
  87. package/dist/opencode-update/managed-installation.test.js +0 -102
  88. package/dist/opencode-update/managed-installation.test.js.map +0 -1
  89. package/public/assets/index-Bme8jj6C.js +0 -2
  90. package/public/assets/index-Bme8jj6C.js.map +0 -1
  91. package/public/assets/index-BxPI94Ww.js +0 -2
  92. package/public/assets/index-BxPI94Ww.js.map +0 -1
  93. package/public/assets/index-Cm6Bv3OW.js +0 -2
  94. package/public/assets/index-Cm6Bv3OW.js.map +0 -1
  95. package/public/assets/index-Cn9xpv8K.js +0 -2
  96. package/public/assets/index-Cn9xpv8K.js.map +0 -1
  97. package/public/assets/index-CooBjdE-.js +0 -2
  98. package/public/assets/index-CooBjdE-.js.map +0 -1
  99. package/public/assets/index-CvWB7Vfc.js +0 -2
  100. package/public/assets/index-CvWB7Vfc.js.map +0 -1
  101. package/public/assets/index-DFCjhysu.js +0 -3
  102. package/public/assets/index-DFCjhysu.js.map +0 -1
  103. package/public/assets/index-DR8ddwAP.js +0 -2
  104. package/public/assets/index-DR8ddwAP.js.map +0 -1
  105. package/public/assets/index-THD8itHb.js +0 -2
  106. package/public/assets/index-THD8itHb.js.map +0 -1
  107. package/public/assets/index-_bmTx26k.js +0 -2
  108. package/public/assets/index-_bmTx26k.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-X1QA2uNM.js","assets/monaco-viewer-BtzCmjFO.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-DFCjhysu.js","assets/index-4mzZPz2j.css","assets/client-state-LGeRE6k3.js","assets/index-CHztP7Qx.js","assets/index-CXyTJ12Z.js","assets/App-DHe1TgnC.js"])))=>i.map(i=>d[i]);
2
- var KE=Object.defineProperty;var VE=(e,t,n)=>t in e?KE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>VE(e,typeof t!="symbol"?t+"":t,n);import{u as kt,i as vs,c as jE,a as En,b as bn,r as mn,l as Su,_ as ts,t as ke,d as Wg,e as Fm,f as qi,g as Nm,h as qE,j as zE,p as Uv,I as WE}from"./index-DFCjhysu.js";import{c as Um,p as St,t as F,i as p,s as hr,a as _s,b as Qs,u as Xs,m as _e,d as pe,D as Bm,P as Km,e as Ht,f as Wf,g as Hf,h as Lt,j as fs,k as ft,l as cS,n as Tn,o as HE,q as GE,r as Bv,B as ZE,v as JE,L as YE,w as QE,x as $i,y as Kv,z as kc,A as Jr,C as Gf,E as XE,F as eT,G as tT,H as nT,I as sT,J as rT,K as gr,M as Vm,N as lS,O as ku,Q as oT,R as iT,S as jm,T as aT,U as cT,V as Vv,W as jv,X as lT,Y as dT,Z as uT,_ as fT}from"./monaco-viewer-BtzCmjFO.js";import{b as xc,e as L,u as zi,d as qe,o as nt,k as y,F as Ut,a as de,M as _i,p as Se,w as dS,c as $e,n as Ns,i as gT,s as Et,x as ei,l as Ir,m as Lr,t as ti,S as Q,v as uS,y as fS,z as gS,A as hS,h as nn,B as hT}from"./git-diff-vendor-CT8HfOQw.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";const mT=e=>typeof e=="function",Sd=(e,t)=>mT(e)?e(t):e;var en;(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"})(en||(en={}));const[Ro,Kr]=Um({toasts:[],pausedAt:void 0}),pT=()=>{const{pausedAt:e,toasts:t}=Ro;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&&Ms({type:en.DISMISS_TOAST,toastId:r.id});return}return setTimeout(()=>{Ms({type:en.DISMISS_TOAST,toastId:r.id})},o)})},uc=new Map,qv=(e,t)=>{if(uc.has(e))return;const n=setTimeout(()=>{uc.delete(e),Ms({type:en.REMOVE_TOAST,toastId:e})},t);uc.set(e,n)},yT=e=>{const t=uc.get(e);uc.delete(e),t&&clearTimeout(t)},Ms=e=>{switch(e.type){case en.ADD_TOAST:Kr("toasts",r=>{const o=r;return[e.toast,...o]});break;case en.DISMISS_TOAST:const{toastId:t}=e,n=Ro.toasts;if(t){const r=n.find(o=>o.id===t);r&&qv(t,r.unmountDelay),Kr("toasts",o=>o.id===t,St(o=>o.visible=!1))}else n.forEach(r=>{qv(r.id,r.unmountDelay)}),Kr("toasts",r=>r.id!==void 0,St(r=>r.visible=!1));break;case en.REMOVE_TOAST:if(!e.toastId){Kr("toasts",[]);break}Kr("toasts",r=>r.filter(a=>a.id!==e.toastId));break;case en.UPDATE_TOAST:e.toast.id&&yT(e.toast.id),Kr("toasts",r=>r.id===e.toast.id,r=>({...r,...e.toast}));break;case en.UPSERT_TOAST:Ro.toasts.find(r=>r.id===e.toast.id)?Ms({type:en.UPDATE_TOAST,toast:e.toast}):Ms({type:en.ADD_TOAST,toast:e.toast});break;case en.START_PAUSE:Kr(St(r=>{r.pausedAt=Date.now(),r.toasts.forEach(o=>{o.paused=!0})}));break;case en.END_PAUSE:const s=e.time-(Ro.pausedAt||0);Kr(St(r=>{r.pausedAt=void 0,r.toasts.forEach(o=>{o.pauseDuration+=s,o.paused=!1})}));break}},vT={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Pi={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},mS={position:"top-right",toastOptions:Pi,gutter:8,containerStyle:{},containerClassName:""},Ml="16px",wT={position:"fixed","z-index":9999,top:Ml,bottom:Ml,left:Ml,right:Ml,"pointer-events":"none"},bT=(()=>{let e=0;return()=>String(++e)})(),ST=e=>{TT(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},kT=(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}},xT=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Ms({type:en.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},$T=(e,t)=>{const{toasts:n}=Ro,s=wi().gutter||mS.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)},_T=(e,t)=>(e.position||t).includes("top")?1:-1,CT={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"},ET={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},Al={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},kd=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[wi,TT]=L(mS),MT=(e,t="blank",n)=>{var s,r,o;return{...Pi,...wi().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||bT(),paused:!1,style:{...Pi.style,...(s=wi().toastOptions)==null?void 0:s.style,...n.style},duration:n.duration||((r=wi().toastOptions)==null?void 0:r.duration)||vT[t],position:n.position||((o=wi().toastOptions)==null?void 0:o.position)||wi().position||Pi.position}},Yc=e=>(t,n={})=>xc(()=>{const s=Ro.toasts.find(o=>o.id===n.id),r=MT(t,e,{...s,duration:void 0,...n});return Ms({type:en.UPSERT_TOAST,toast:r}),r.id}),Rn=(e,t)=>Yc("blank")(e,t);zi(()=>Rn);Rn.error=Yc("error");Rn.success=Yc("success");Rn.loading=Yc("loading");Rn.custom=Yc("custom");Rn.dismiss=e=>{Ms({type:en.DISMISS_TOAST,toastId:e})};Rn.promise=(e,t,n)=>{const s=Rn.loading(t.loading,{...n});return e.then(r=>(Rn.success(Sd(t.success,r),{id:s,...n}),r)).catch(r=>{Rn.error(Sd(t.error,r),{id:s,...n})}),e};Rn.remove=e=>{Ms({type:en.REMOVE_TOAST,toastId:e})};var AT=F("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const DT=e=>(qe(()=>{ST(e)}),qe(()=>{const t=pT();nt(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=AT();return t.firstChild,p(t,y(Ut,{get each(){return Ro.toasts},children:n=>y(IT,{toast:n})}),null),de(n=>{var s={...wT,...e.containerStyle},r=e.containerClassName;return n.e=hr(t,s,n.e),r!==n.t&&_s(t,n.t=r),n},{e:void 0,t:void 0}),t})());var Dl=F("<div>"),PT=F("<div><div>");const OT=e=>{let t;return qe(()=>{if(!t)return;const n=_T(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=PT(),s=n.firstChild,r=t;return typeof r=="function"?Xs(r,n):t=n,p(n,y(dS,{get children(){return[y(_i,{get when(){return e.toast.icon},get children(){var o=Dl();return p(o,()=>e.toast.icon),de(a=>hr(o,Al,a)),o}}),y(_i,{get when(){return e.toast.type==="loading"},get children(){var o=Dl();return p(o,y(jT,Se(()=>e.toast.iconTheme))),de(a=>hr(o,Al,a)),o}}),y(_i,{get when(){return e.toast.type==="success"},get children(){var o=Dl();return p(o,y(UT,Se(()=>e.toast.iconTheme))),de(a=>hr(o,Al,a)),o}}),y(_i,{get when(){return e.toast.type==="error"},get children(){var o=Dl();return p(o,y(KT,Se(()=>e.toast.iconTheme))),de(a=>hr(o,Al,a)),o}})]}}),s),Qs(s,Se(()=>e.toast.ariaProps),!1,!0),p(s,()=>Sd(e.toast.message,e.toast)),de(o=>{var a=e.toast.className,i={...CT,...e.toast.style},c=ET;return a!==o.e&&_s(n,o.e=a),o.t=hr(n,i,o.t),o.a=hr(s,c,o.a),o},{e:void 0,t:void 0,a:void 0}),n})()};var RT=F("<div>");const IT=e=>{const t=()=>{const r=e.toast.position||Pi.position,o=$T(e.toast,r);return kT(r,o)},n=$e(()=>t());let s;return Ns(()=>{s&&xT(s,e.toast)}),(()=>{var r=RT();r.addEventListener("mouseleave",()=>Ms({type:en.END_PAUSE,time:Date.now()})),r.addEventListener("mouseenter",()=>Ms({type:en.START_PAUSE,time:Date.now()}));var o=s;return typeof o=="function"?Xs(o,r):s=r,p(r,(()=>{var a=_e(()=>e.toast.type==="custom");return()=>a()?Sd(e.toast.message,e.toast):y(OT,{get toast(){return e.toast},get position(){return e.toast.position||Pi.position}})})()),de(a=>{var i=n(),c=e.toast.visible?"sldt-active":"";return a.e=hr(r,i,a.e),c!==a.t&&_s(r,a.t=c),a},{e:void 0,t:void 0}),r})()};var LT=F('<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),FT=F('<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 pS=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=LT(),s=n.firstChild,r=s.nextSibling;return Qs(s,t,!0,!1),Qs(r,t,!0,!1),de(()=>pe(n,"fill",e.fill)),n})()},yS=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...kd("0.0 0.0 0.2 1")};return(()=>{var n=FT(),s=n.firstChild,r=s.nextSibling;return Qs(s,t,!0,!1),Qs(r,t,!0,!1),de(()=>pe(n,"fill",e.fill)),n})()};var NT=F('<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 UT=e=>{const t=e.primary||"#34C759";return(()=>{var n=NT(),s=n.firstChild,r=s.firstChild;return p(n,y(pS,{fill:t}),s),p(n,y(yS,{fill:t,begin:"350ms"}),s),Qs(r,Se(()=>kd("0.0, 0.0, 0.58, 1.0")),!0,!1),de(()=>pe(s,"stroke",e.secondary||"#FCFCFC")),n})()};var BT=F('<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 KT=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=BT(),s=n.firstChild,r=s.firstChild,o=s.nextSibling,a=o.firstChild;return p(n,y(pS,{fill:t}),s),p(n,y(yS,{fill:t}),s),Qs(r,Se(()=>kd("0.0, 0.0, 0.58, 1.0")),!0,!1),Qs(a,Se(()=>kd("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&&pe(s,"stroke",i.e=c),l!==i.t&&pe(o,"fill",i.t=l),i},{e:void 0,t:void 0}),n})()};var VT=F('<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 jT=e=>(()=>{var t=VT(),n=t.firstChild,s=n.nextSibling;return de(r=>{var o=e.primary||"#E5E7EB",a=e.secondary||"#4b5563";return o!==r.e&&pe(n,"stroke",r.e=o),a!==r.t&&pe(s,"stroke",r.t=a),r},{e:void 0,t:void 0}),t})();function qT(e){return(...t)=>{for(const n of e)n&&n(...t)}}const ge=e=>typeof e=="function"&&!e.length?e():e,zv=e=>Array.isArray(e)?e:e?[e]:[];function zT(e,...t){return typeof e=="function"?e(...t):e}const WT=nt;function HT(e,t,n,s){return e.addEventListener(t,n,s),WT(e.removeEventListener.bind(e,t,n,s))}function GT(e,t,n,s){const r=()=>{zv(ge(e)).forEach(o=>{o&&zv(ge(t)).forEach(a=>HT(o,a,n,s))})};typeof e=="function"?qe(r):de(r)}const Zf=Symbol("fallback");function Wv(e){for(const t of e)t.dispose()}function ZT(e,t,n,s={}){const r=new Map;return nt(()=>Wv(r.values())),()=>{const a=e()||[];return a[gT],zi(()=>{var d,u;if(!a.length)return Wv(r.values()),r.clear(),s.fallback?[xc(h=>(r.set(Zf,{dispose:h}),s.fallback()))]:[];const i=new Array(a.length),c=r.get(Zf);if(!r.size||c){c==null||c.dispose(),r.delete(Zf);for(let f=0;f<a.length;f++){const h=a[f],m=t(h,f);o(i,h,f,m)}return i}const l=new Set(r.keys());for(let f=0;f<a.length;f++){const h=a[f],m=t(h,f);l.delete(m);const w=r.get(m);w?(i[f]=w.mapped,(d=w.setIndex)==null||d.call(w,f),w.setItem(()=>h)):o(i,h,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){xc(d=>{const[u,f]=L(i),h={setItem:f,dispose:d};if(n.length>1){const[m,w]=L(c);h.setIndex=w,h.mapped=n(u,m)}else h.mapped=n(u);r.set(l,h),a[c]=h.mapped})}}function JT(e){const{by:t}=e;return $e(ZT(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const YT=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Hv(e){const t={};let n;for(;n=YT.exec(e);)t[n[1]]=n[2];return t}function Qc(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Hv(e)}else typeof t=="string"&&(t=Hv(t));return{...e,...t}}function Mn(...e){return qT(e)}function wW(e,t,n=-1){return n in e?[...e.slice(0,n),t,...e.slice(n)]:[...e,t]}function Gv(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function QT(e){return typeof e=="number"}function bi(e){return Object.prototype.toString.call(e)==="[object String]"}function xu(e){return typeof e=="function"}function Ea(e){return t=>`${e()}-${t}`}function pr(e,t){return e?e===t||e.contains(t):!1}function Ya(e,t=!1){const{activeElement:n}=xr(e);if(!(n!=null&&n.nodeName))return null;if(vS(n)&&n.contentDocument)return Ya(n.contentDocument.body,t);if(t){const s=n.getAttribute("aria-activedescendant");if(s){const r=xr(n).getElementById(s);if(r)return r}}return n}function XT(e){return xr(e).defaultView||window}function xr(e){return e?e.ownerDocument||e:document}function vS(e){return e.tagName==="IFRAME"}var qm=(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))(qm||{});function wS(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 zm(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 Xc(){return zm(/^Mac/i)}function eM(){return zm(/^iPhone/i)}function tM(){return zm(/^iPad/i)||Xc()&&navigator.maxTouchPoints>1}function nM(){return eM()||tM()}function sM(){return Xc()||nM()}function rM(){return wS(/AppleWebKit/i)&&!oM()}function oM(){return wS(/Chrome/i)}function Zt(e,t){return t&&(xu(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function ls(e){return t=>{for(const n of e)Zt(t,n)}}function iM(e){return Xc()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function xn(e){if(e)if(aM())e.focus({preventScroll:!0});else{const t=cM(e);e.focus(),lM(t)}}var Pl=null;function aM(){if(Pl==null){Pl=!1;try{document.createElement("div").focus({get preventScroll(){return Pl=!0,!0}})}catch{}}return Pl}function cM(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 lM(e){for(const{element:t,scrollTop:n,scrollLeft:s}of e)t.scrollTop=n,t.scrollLeft=s}var bS=["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'])"],dM=[...bS,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Wm=`${bS.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,uM=dM.join(':not([hidden]):not([tabindex="-1"]),');function SS(e,t){const s=Array.from(e.querySelectorAll(Wm)).filter(Zv);return t&&Zv(e)&&s.unshift(e),s.forEach((r,o)=>{if(vS(r)&&r.contentDocument){const a=r.contentDocument.body,i=SS(a,!1);s.splice(o,1,...i)}}),s}function Zv(e){return kS(e)&&!fM(e)}function kS(e){return e.matches(Wm)&&Hm(e)}function fM(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function Hm(e,t){return e.nodeName!=="#comment"&&gM(e)&&hM(e,t)&&(!e.parentElement||Hm(e.parentElement,e))}function gM(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 hM(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function mM(e,t,n){const s=t!=null&&t.tabbable?uM:Wm,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)&&Hm(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 Jv(e){let t=e;for(;t&&!pM(t);)t=t.parentElement;return t||document.scrollingElement||document.documentElement}function pM(e){const t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function yM(){}function bW(e){return[e.clientX,e.clientY]}function SW(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],[,h]=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>h&&(r=!r):r=!r)}}else if(d<f){if(s>d&&s<=f){if(m===0)return!0;m<0&&(s===f?s<h&&(r=!r):r=!r)}}else if(s===d&&(n>=u&&n<=l||n>=l&&n<=u))return!0}return r}function Dt(e,t){return Se(e,t)}var Ka=new Map,Yv=new Set;function Qv(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let s=Ka.get(n.target);s||(s=new Set,Ka.set(n.target,s),n.target.addEventListener("transitioncancel",t)),s.add(n.propertyName)},t=n=>{if(!n.target)return;const s=Ka.get(n.target);if(s&&(s.delete(n.propertyName),s.size===0&&(n.target.removeEventListener("transitioncancel",t),Ka.delete(n.target)),Ka.size===0)){for(const r of Yv)r();Yv.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?Qv():document.addEventListener("DOMContentLoaded",Qv));function Hg(e,t){const n=Xv(e,t,"left"),s=Xv(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 Xv(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 kW(e,t){var n,s;if(document.contains(e)){const r=document.scrollingElement||document.documentElement;if(window.getComputedStyle(r).overflow==="hidden"){let a=Jv(e);for(;e&&a&&e!==r&&a!==r;)Hg(a,e),e=a,a=Jv(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 $u={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"},xd="data-kb-top-layer",xS,Gg=!1,$r=[];function $c(e){return $r.findIndex(t=>t.node===e)}function vM(e){return $r[$c(e)]}function wM(e){return $r[$r.length-1].node===e}function $S(){return $r.filter(e=>e.isPointerBlocking)}function bM(){return[...$S()].slice(-1)[0]}function Gm(){return $S().length>0}function _S(e){var n;const t=$c((n=bM())==null?void 0:n.node);return $c(e)<t}function SM(e){$r.push(e)}function kM(e){const t=$c(e);t<0||$r.splice(t,1)}function xM(){for(const{node:e}of $r)e.style.pointerEvents=_S(e)?"none":"auto"}function $M(e){if(Gm()&&!Gg){const t=xr(e);xS=document.body.style.pointerEvents,t.body.style.pointerEvents="none",Gg=!0}}function _M(e){if(Gm())return;const t=xr(e);t.body.style.pointerEvents=xS,t.body.style.length===0&&t.body.removeAttribute("style"),Gg=!1}var Zn={layers:$r,isTopMostLayer:wM,hasPointerBlockingLayer:Gm,isBelowPointerBlockingLayer:_S,addLayer:SM,removeLayer:kM,indexOf:$c,find:vM,assignPointerEventToLayers:xM,disableBodyPointerEvents:$M,restoreBodyPointerEvents:_M},Jf="focusScope.autoFocusOnMount",Yf="focusScope.autoFocusOnUnmount",ew={bubbles:!1,cancelable:!0},tw={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=Gv(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=Gv(this.stack,e),(t=this.active())==null||t.resume()}};function CS(e,t){const[n,s]=L(!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=()=>xr(t()),l=()=>{const m=c().createElement("span");return m.setAttribute("data-focus-trap",""),m.tabIndex=0,Object.assign(m.style,$u),m},d=()=>{const m=t();return m?SS(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},h=()=>{const m=t();if(!m)return!1;const w=Ya(m);return!w||pr(m,w)?!1:kS(w)};qe(()=>{const m=t();if(!m)return;tw.add(r);const w=Ya(m);if(!pr(m,w)){const b=new CustomEvent(Jf,ew);m.addEventListener(Jf,a),m.dispatchEvent(b),b.defaultPrevented||setTimeout(()=>{xn(u()),Ya(m)===w&&xn(m)},0)}nt(()=>{m.removeEventListener(Jf,a),setTimeout(()=>{const b=new CustomEvent(Yf,ew);h()&&b.preventDefault(),m.addEventListener(Yf,i),m.dispatchEvent(b),b.defaultPrevented||xn(w??c().body),m.removeEventListener(Yf,i),tw.remove(r)},0)})}),qe(()=>{const m=t();if(!m||!ge(e.trapFocus)||n())return;const w=b=>{const v=b.target;v!=null&&v.closest(`[${xd}]`)||(pr(m,v)?o=v:xn(o))},S=b=>{const k=b.relatedTarget??Ya(m);k!=null&&k.closest(`[${xd}]`)||pr(m,k)||xn(o)};c().addEventListener("focusin",w),c().addEventListener("focusout",S),nt(()=>{c().removeEventListener("focusin",w),c().removeEventListener("focusout",S)})}),qe(()=>{const m=t();if(!m||!ge(e.trapFocus)||n())return;const w=l();m.insertAdjacentElement("afterbegin",w);const S=l();m.insertAdjacentElement("beforeend",S);function b(k){const $=u(),C=f();k.relatedTarget===$?xn(C):xn($)}w.addEventListener("focusin",b),S.addEventListener("focusin",b);const v=new MutationObserver(k=>{for(const $ of k)$.previousSibling===S&&(S.remove(),m.insertAdjacentElement("beforeend",S)),$.nextSibling===w&&(w.remove(),m.insertAdjacentElement("afterbegin",w))});v.observe(m,{childList:!0,subtree:!1}),nt(()=>{w.removeEventListener("focusin",b),S.removeEventListener("focusin",b),w.remove(),S.remove(),v.disconnect()})})}var ES=7e3,Qf=null,CM="data-live-announcer";function xW(e,t="assertive",n=ES){Qf||(Qf=new EM),Qf.announce(e,t,n)}var EM=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,$u),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=ES){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 TS(e){qe(()=>{ge(e.isDisabled)||nt(TM(ge(e.targets),ge(e.root)))})}var Va=new WeakMap,is=[];function TM(e,t=document.body){const n=new Set(e),s=new Set,r=c=>{for(const f of c.querySelectorAll(`[${CM}], [${xd}]`))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 h of n)if(f.contains(h))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=Va.get(c)??0;c.getAttribute("aria-hidden")==="true"&&l===0||(l===0&&c.setAttribute("aria-hidden","true"),s.add(c),Va.set(c,l+1))};is.length&&is[is.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 is.push(i),()=>{a.disconnect();for(const c of s){const l=Va.get(c);if(l==null)return;l===1?(c.removeAttribute("aria-hidden"),Va.delete(c)):Va.set(c,l-1)}i===is[is.length-1]?(is.pop(),is.length&&is[is.length-1].observe()):is.splice(is.indexOf(i),1)}}var nw="interactOutside.pointerDownOutside",sw="interactOutside.focusOutside";function MM(e,t){let n,s=yM;const r=()=>xr(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 h;const f=u.target;return!(f instanceof Element)||f.closest(`[${xd}]`)||!pr(r(),f)||pr(t(),f)?!1:!((h=e.shouldExcludeElement)!=null&&h.call(e,f))},l=u=>{function f(){const h=t(),m=u.target;if(!h||!m||!c(u))return;const w=ls([o,i]);m.addEventListener(nw,w,{once:!0});const S=new CustomEvent(nw,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||iM(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(),h=u.target;if(!f||!h||!c(u))return;const m=ls([a,i]);h.addEventListener(sw,m,{once:!0});const w=new CustomEvent(sw,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});h.dispatchEvent(w)};qe(()=>{ge(e.isDisabled)||(n=window.setTimeout(()=>{r().addEventListener("pointerdown",l,!0)},0),r().addEventListener("focusin",d,!0),nt(()=>{window.clearTimeout(n),r().removeEventListener("click",s),r().removeEventListener("pointerdown",l,!0),r().removeEventListener("focusin",d,!0)}))})}function AM(e){const t=n=>{var s;n.key===qm.Escape&&((s=e.onEscapeKeyDown)==null||s.call(e,n))};qe(()=>{var s;if(ge(e.isDisabled))return;const n=((s=e.ownerDocument)==null?void 0:s.call(e))??xr();n.addEventListener("keydown",t),nt(()=>{n.removeEventListener("keydown",t)})})}function zt(e){const[t,n]=Et(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return y(Bm,Se(n,{get component(){return t.as}}))}var MS=Ir();function DM(){return Lr(MS)}function AS(e){let t;const n=DM(),[s,r]=Et(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()}};MM({shouldExcludeElement:u=>{var f;return t?((f=s.excludedElements)==null?void 0:f.some(h=>pr(h(),u)))||[...o].some(h=>pr(h,u)):!1},onPointerDownOutside:u=>{var f,h,m;!t||Zn.isBelowPointerBlockingLayer(t)||!s.bypassTopMostLayerCheck&&!Zn.isTopMostLayer(t)||((f=s.onPointerDownOutside)==null||f.call(s,u),(h=s.onInteractOutside)==null||h.call(s,u),u.defaultPrevented||(m=s.onDismiss)==null||m.call(s))},onFocusOutside:u=>{var f,h,m;(f=s.onFocusOutside)==null||f.call(s,u),(h=s.onInteractOutside)==null||h.call(s,u),u.defaultPrevented||(m=s.onDismiss)==null||m.call(s)}},()=>t),AM({ownerDocument:()=>xr(t),onEscapeKeyDown:u=>{var f;!t||!Zn.isTopMostLayer(t)||((f=s.onEscapeKeyDown)==null||f.call(s,u),!u.defaultPrevented&&s.onDismiss&&(u.preventDefault(),s.onDismiss()))}}),Ns(()=>{if(!t)return;Zn.addLayer({node:t,isPointerBlocking:s.disableOutsidePointerEvents,dismiss:s.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);Zn.assignPointerEventToLayers(),Zn.disableBodyPointerEvents(t),nt(()=>{t&&(Zn.removeLayer(t),u==null||u(),Zn.assignPointerEventToLayers(),Zn.restoreBodyPointerEvents(t))})}),qe(ei([()=>t,()=>s.disableOutsidePointerEvents],([u,f])=>{if(!u)return;const h=Zn.find(u);h&&h.isPointerBlocking!==f&&(h.isPointerBlocking=f,Zn.assignPointerEventToLayers()),f&&Zn.disableBodyPointerEvents(u),nt(()=>{Zn.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:a};return y(MS.Provider,{value:d,get children(){return y(zt,Se({as:"div",ref(u){var f=Mn(h=>t=h,s.ref);typeof f=="function"&&f(u)}},r))}})}function Zm(e){var a;const[t,n]=L((a=e.defaultValue)==null?void 0:a.call(e)),s=$e(()=>{var i;return((i=e.value)==null?void 0:i.call(e))!==void 0}),r=$e(()=>{var i;return s()?(i=e.value)==null?void 0:i.call(e):t()});return[r,i=>{zi(()=>{var l;const c=zT(i,r());return Object.is(c,r())||(s()||n(c),(l=e.onChange)==null||l.call(e,c)),c})}]}function DS(e){const[t,n]=Zm(e);return[()=>t()??!1,n]}function $W(e){const[t,n]=Zm(e);return[()=>t()??[],n]}function PS(e={}){const[t,n]=DS({value:()=>ge(e.open),defaultValue:()=>!!ge(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 OS(e,t){const[n,s]=L(rw(t==null?void 0:t()));return qe(()=>{var r;s(((r=e())==null?void 0:r.tagName.toLowerCase())||rw(t==null?void 0:t()))}),n}function rw(e){return bi(e)?e:void 0}var PM=Object.defineProperty,el=(e,t)=>{for(var n in t)PM(e,n,{get:t[n],enumerable:!0})},OM={};el(OM,{Button:()=>LM,Root:()=>tl});var RM=["button","color","file","image","reset","submit"];function IM(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?RM.indexOf(e.type)!==-1:!1}function tl(e){let t;const n=Dt({type:"button"},e),[s,r]=Et(n,["ref","type","disabled"]),o=OS(()=>t,()=>"button"),a=$e(()=>{const l=o();return l==null?!1:IM({tagName:l,type:s.type})}),i=$e(()=>o()==="input"),c=$e(()=>o()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return y(zt,Se({as:"button",ref(l){var d=Mn(u=>t=u,s.ref);typeof d=="function"&&d(l)},get type(){return _e(()=>!!(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 _e(()=>!!(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 LM=tl;function ds(e){return t=>(e(t),()=>e(void 0))}var kn=e=>typeof e=="function"?e():e,Zg=(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},Ol=new Map,FM=e=>{qe(()=>{const t=kn(e.style)??{},n=kn(e.properties)??[],s={};for(const o in t)s[o]=e.element.style[o];const r=Ol.get(e.key);r?r.activeCount++:Ol.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);nt(()=>{var a;const o=Ol.get(e.key);if(o){if(o.activeCount!==1){o.activeCount--;return}Ol.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)}})})},ow=FM,NM=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},UM=(e,t)=>{const n=getComputedStyle(e),s=t==="x"?n.overflowX:n.overflowY;return s==="auto"||s==="scroll"||e.tagName==="HTML"&&s==="visible"},BM=(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]=NM(r,t),u=d-c-s*l;(l!==0||u!==0)&&UM(r,t)&&(o+=u,a+=l),r===(n??document.documentElement)?i=!0:r=r._$host??r.parentElement}while(r&&!i);return[o,a]},[iw,aw]=L([]),KM=e=>iw().indexOf(e)===iw().length-1,VM=e=>{const t=Se({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=ti();let s=[0,0],r=null,o=null;qe(()=>{kn(t.enabled)&&(aw(l=>[...l,n]),nt(()=>{aw(l=>l.filter(d=>d!==n))}))}),qe(()=>{if(!kn(t.enabled)||!kn(t.hideScrollbar))return;const{body:l}=document,d=window.innerWidth-l.offsetWidth;if(kn(t.preventScrollbarShift)){const u={overflow:"hidden"},f=[];d>0&&(kn(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 h=window.scrollY,m=window.scrollX;ow({key:"prevent-scroll",element:l,style:u,properties:f,cleanup:()=>{kn(t.restoreScrollPosition)&&d>0&&window.scrollTo(m,h)}})}else ow({key:"prevent-scroll",element:l,style:{overflow:"hidden"}})}),qe(()=>{!KM(n)||!kn(t.enabled)||(document.addEventListener("wheel",i,{passive:!1}),document.addEventListener("touchstart",a,{passive:!1}),document.addEventListener("touchmove",c,{passive:!1}),nt(()=>{document.removeEventListener("wheel",i),document.removeEventListener("touchstart",a),document.removeEventListener("touchmove",c)}))});const a=l=>{s=cw(l),r=null,o=null},i=l=>{const d=l.target,u=kn(t.element),f=jM(l),h=Math.abs(f[0])>Math.abs(f[1])?"x":"y",m=h==="x"?f[0]:f[1],w=lw(d,h,m,u);let S;u&&Zg(u,d)?S=!w:S=!0,S&&l.cancelable&&l.preventDefault()},c=l=>{const d=kn(t.element),u=l.target;let f;if(l.touches.length===2)f=!kn(t.allowPinchZoom);else{if(r==null||o===null){const h=cw(l).map((w,S)=>s[S]-w),m=Math.abs(h[0])>Math.abs(h[1])?"x":"y";r=m,o=m==="x"?h[0]:h[1]}if(u.type==="range")f=!1;else{const h=lw(u,r,o,d);d&&Zg(d,u)?f=!h:f=!0}}f&&l.cancelable&&l.preventDefault()}},jM=e=>[e.deltaX,e.deltaY],cw=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],lw=(e,t,n,s)=>{const r=s!==null&&Zg(s,e),[o,a]=BM(e,t,r?s:void 0);return!(n>0&&Math.abs(o)<=1||n<0&&Math.abs(a)<1)},qM=VM,RS=qM,zM=e=>{const t=$e(()=>{const a=kn(e.element);if(a)return getComputedStyle(a)}),n=()=>{var a;return((a=t())==null?void 0:a.animationName)??"none"},[s,r]=L(kn(e.show)?"present":"hidden");let o="none";return qe(a=>{const i=kn(e.show);return zi(()=>{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}),qe(()=>{const a=kn(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),nt(()=>{a.removeEventListener("animationstart",i),a.removeEventListener("animationcancel",c),a.removeEventListener("animationend",c)})}),{present:()=>s()==="present"||s()==="hiding",state:s,setState:r}},WM=zM,Jg=WM,HM={};el(HM,{CloseButton:()=>LS,Content:()=>FS,Description:()=>NS,Dialog:()=>_t,Overlay:()=>US,Portal:()=>BS,Root:()=>KS,Title:()=>VS,Trigger:()=>jS,useDialogContext:()=>vo});var IS=Ir();function vo(){const e=Lr(IS);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function LS(e){const t=vo(),[n,s]=Et(e,["aria-label","onClick"]);return y(tl,Se({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:o=>{Zt(o,n.onClick),t.close()}},s))}function FS(e){let t;const n=vo(),s=Dt({id:n.generateId("content")},e),[r,o]=Et(s,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let a=!1,i=!1;const c=f=>{var h;(h=r.onPointerDownOutside)==null||h.call(r,f),n.modal()&&f.detail.isContextMenu&&f.preventDefault()},l=f=>{var h;(h=r.onFocusOutside)==null||h.call(r,f),n.modal()&&f.preventDefault()},d=f=>{var h;(h=r.onInteractOutside)==null||h.call(r,f),!n.modal()&&(f.defaultPrevented||(a=!0,f.detail.originalEvent.type==="pointerdown"&&(i=!0)),pr(n.triggerRef(),f.target)&&f.preventDefault(),f.detail.originalEvent.type==="focusin"&&i&&f.preventDefault())},u=f=>{var h;(h=r.onCloseAutoFocus)==null||h.call(r,f),n.modal()?(f.preventDefault(),xn(n.triggerRef())):(f.defaultPrevented||(a||xn(n.triggerRef()),f.preventDefault()),a=!1,i=!1)};return TS({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),RS({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),CS({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:r.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),qe(()=>nt(n.registerContentId(o.id))),y(Q,{get when(){return n.contentPresent()},get children(){return y(AS,Se({ref(f){var h=Mn(m=>{n.setContentRef(m),t=m},r.ref);typeof h=="function"&&h(f)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return _e(()=>!!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 NS(e){const t=vo(),n=Dt({id:t.generateId("description")},e),[s,r]=Et(n,["id"]);return qe(()=>nt(t.registerDescriptionId(s.id))),y(zt,Se({as:"p",get id(){return s.id}},r))}function US(e){const t=vo(),[n,s]=Et(e,["ref","style","onPointerDown"]),r=o=>{Zt(o,n.onPointerDown),o.target===o.currentTarget&&o.preventDefault()};return y(Q,{get when(){return t.overlayPresent()},get children(){return y(zt,Se({as:"div",ref(o){var a=Mn(t.setOverlayRef,n.ref);typeof a=="function"&&a(o)},get style(){return Qc({"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 BS(e){const t=vo();return y(Q,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return y(Km,e)}})}var dw={dismiss:"Dismiss"};function KS(e){const t=`dialog-${ti()}`,n=Dt({id:t,modal:!0,translations:dw},e),[s,r]=L(),[o,a]=L(),[i,c]=L(),[l,d]=L(),[u,f]=L(),[h,m]=L(),w=PS({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:$=>{var C;return(C=n.onOpenChange)==null?void 0:C.call(n,$)}}),S=()=>n.forceMount||w.isOpen(),{present:b}=Jg({show:S,element:()=>l()??null}),{present:v}=Jg({show:S,element:()=>u()??null}),k={translations:()=>n.translations??dw,isOpen:w.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??k.modal(),contentId:s,titleId:o,descriptionId:i,triggerRef:h,overlayRef:l,setOverlayRef:d,contentRef:u,setContentRef:f,overlayPresent:b,contentPresent:v,close:w.close,toggle:w.toggle,setTriggerRef:m,generateId:Ea(()=>n.id),registerContentId:ds(r),registerTitleId:ds(a),registerDescriptionId:ds(c)};return y(IS.Provider,{value:k,get children(){return n.children}})}function VS(e){const t=vo(),n=Dt({id:t.generateId("title")},e),[s,r]=Et(n,["id"]);return qe(()=>nt(t.registerTitleId(s.id))),y(zt,Se({as:"h2",get id(){return s.id}},r))}function jS(e){const t=vo(),[n,s]=Et(e,["ref","onClick"]);return y(tl,Se({ref(o){var a=Mn(t.setTriggerRef,n.ref);typeof a=="function"&&a(o)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return _e(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:o=>{Zt(o,n.onClick),t.toggle()}},s))}var _t=Object.assign(KS,{CloseButton:LS,Content:FS,Description:NS,Overlay:US,Portal:BS,Title:VS,Trigger:jS});const[ld,_u]=L(null);function Cs(e,t){_u({type:"alert",message:e,...t})}function Wi(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(s=>{_u({type:"confirm",message:e,...t,resolve:s})})}function GM(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(s=>{_u({type:"prompt",message:e,...t,resolvePrompt:s})})}function Xf(){_u(null)}var ZM=F('<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">'),JM=F('<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>'),YM=F('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),QM=F('<p class="mt-2 text-secondary">'),XM=F("<button type=button class=button-secondary>");const e2={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 Rl(e,t,n){var r,o,a,i,c,l,d,u;const s=t??ld();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),Xf();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)),Xf();return}e&&((u=s==null?void 0:s.onConfirm)==null||u.call(s)),Xf()}const t2=()=>{const{t:e}=kt();let t,n;return qe(()=>{const s=ld();!s||Wf.required()||queueMicrotask(()=>{if(!(Wf.required()||ld()!==s)){if(s.type==="prompt"){n==null||n.focus(),n==null||n.select();return}t==null||t.focus()}})}),y(Q,{get when(){return ld()},keyed:!0,children:s=>{const r=s.variant??"info",o=e2[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,h]=L(s.inputDefaultValue??"");return y(_t,{get open(){return!Wf.required()},modal:!0,onOpenChange:m=>{!m&&s.dismissible!==!1&&Rl(!1,s)},get children(){return y(_t.Portal,{get children(){return[y(_t.Overlay,{class:"modal-overlay z-[60]"}),y(_t.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=ZM(),w=m.firstChild,S=w.nextSibling;return p(w,()=>o.symbol),p(S,y(_t.Title,{class:"text-lg font-semibold text-primary",children:i}),null),p(S,y(_t.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line break-words",get children(){return[_e(()=>s.message),_e(()=>_e(()=>!!s.detail)()&&(()=>{var b=QM();return p(b,()=>s.detail),b})())]}}),null),de(b=>{var v=o.badgeBg,k=o.badgeBorder,$=o.badgeText;return v!==b.e&&Hf(w,"background-color",b.e=v),k!==b.t&&Hf(w,"border-color",b.t=k),$!==b.a&&Hf(w,"color",b.a=$),b},{e:void 0,t:void 0,a:void 0}),m})(),y(Q,{when:l,get children(){var m=JM(),w=m.firstChild,S=w.nextSibling;return p(w,()=>s.inputLabel||e("alertDialog.prompt.inputLabel")),S.$$keydown=b=>{b.key==="Enter"&&(b.preventDefault(),Rl(!0,s,f()))},S.$$input=b=>h(b.currentTarget.value),Xs(b=>{n=b},S),pe(S,"spellcheck",!1),de(()=>pe(S,"placeholder",s.inputPlaceholder||"")),de(()=>S.value=f()),m}}),(()=>{var m=YM(),w=m.firstChild;return p(m,(c||l)&&(()=>{var S=XM();return S.$$click=()=>Rl(!1,s),p(S,u),S})(),w),w.$$click=()=>Rl(!0,s,f()),Xs(S=>{t=S},w),p(w,d),m})()]}})]}})}})}})};Ht(["input","keydown","click"]);function n2(e,t,n){if(e.has(t))return e;const s=new Map(e);return s.set(t,n),s}function s2(e,t){return e==="disconnected"||e==="error"?e:t!=="connected"?"connecting":e}const _o=Lt("sse"),[uw,fw]=L(new Map),[r2,o2]=L("connecting");class i2{constructor(){_o.info("sseManager initialized: listening for SSE disconnect and reconnect"),fs.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)}}),fs.on("instance.event",t=>{const n=t;this.updateConnectionStatus(n.instanceId,"connected"),this.handleEvent(n.instanceId,n.event)}),fs.onTransportStatus(t=>{_o.info("SSE transport status changed",{status:t}),o2(t)})}seedStatus(t,n){this.updateConnectionStatus(t,n)}seedStatusIfMissing(t,n){fw(s=>n2(s,t,n))}handleEvent(t,n){var s,r,o,a,i,c,l,d,u,f,h,m,w,S,b,v;if(!n||typeof n!="object"||typeof n.type!="string"){_o.warn("Dropping malformed event",n);return}switch(_o.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":(h=this.onPermissionReplied)==null||h.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($=>{_o.warn("Failed to handle worktree ready event",{instanceId:t,error:$})})}catch(k){_o.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=>_o.warn("Failed to refresh native worktrees",k));break;default:(v=this.onNativeSessionEvent)==null||v.call(this,t,n)}}updateConnectionStatus(t,n){fw(s=>{if(s.get(t)===n)return s;const r=new Map(s);return r.set(t,n),r})}getStatus(t){return s2(uw().get(t)??null,r2())}getStatuses(){return uw()}}const ln=new i2,[er,Cu]=L(),[Yg,Hi]=L(!1),[ni,Qg]=L(!1),[Xg,_c]=L(!1),[eh,$d]=L(),[Qa,th]=L(),[nh,sh]=L(!1),[rh,Uo]=L();let Jn=0,gw=-1,Mo;const[Jm,Ym]=L(),qS=()=>!!Jm();function fc(e=er()){return(e==null?void 0:e.serviceState)==="ready"||(e==null?void 0:e.serviceState)==="restart_available"}async function zS(){if(!fc()||ni())return;const e=Jm();Ym(void 0),Hi(!1),await(e==null?void 0:e())}function oh(e=er()){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 Qm(e){e&&Ym(()=>e),Uo(void 0),Hi(!0),Gs()}function a2(){ni()||gw===Jn||(gw=Jn,Qm())}function WS(){Jn++,Mo=void 0,Cu(void 0),Uo(void 0),Gs()}function Gs(e=!1,t=!1){if(ni()&&!e)return Promise.resolve();if(Mo)return Mo;const n=Jn;sh(!0),t&&Uo(void 0);const s=ft.fetchOpenCodeUpdateStatus().then(r=>{n===Jn&&(Cu(r),_c(!1),$d(void 0),t&&Uo("checked"))}).catch(()=>{n===Jn&&_c(!0)}).finally(()=>{Mo===s&&(Mo=void 0,sh(!1))});return Mo=s,s}async function Xa(e){var n,s;if(ni())return;const t=++Jn;Mo=void 0,Qg(!0),th(e),Uo(void 0),_c(!1),$d(void 0);try{if(e==="install"&&await ft.updateOpenCode(),t!==Jn||(await Gs(!0),t!==Jn)||e!=="restart"&&(((n=er())==null?void 0:n.serviceState)==="restart_required"||((s=er())==null?void 0:s.serviceState)==="incompatible"))return;const r=e==="reload"?await ft.reloadOpenCodeConfiguration():await ft.startOpenCode(e==="restart");if(t!==Jn)return;if(Cu(r),r.state==="ready"&&(r.serviceState==="ready"||r.serviceState==="restart_available")){const o=Jm();Ym(void 0),e==="reload"&&Uo("reloaded"),o&&r.serviceState==="ready"&&Hi(!1),await(o==null?void 0:o())}}catch(r){if(t===Jn){if(await Gs(!0),t!==Jn)return;_c(!0),r instanceof Error&&(r.message==="installation_busy"||r.message==="installation_in_use")&&$d(r.message)}}finally{Qg(!1),th(void 0),t!==Jn&&Gs()}}const c2=Object.freeze(Object.defineProperty({__proto__:null,canContinueOpenCodeSetup:qS,continueOpenCodeSetup:zS,invalidateOpenCodeSetup:WS,isOpenCodeConnected:fc,needsOpenCodeSetup:oh,openCodeInstallationError:eh,openCodeSetupAction:Qa,openCodeSetupBusy:ni,openCodeSetupChecking:nh,openCodeSetupError:Xg,openCodeSetupFeedback:rh,openCodeSetupOpen:Yg,openCodeSetupStatus:er,openOpenCodeSetup:Qm,refreshOpenCodeSetup:Gs,reportOpenCodeSetupRequired:a2,runOpenCodeSetup:Xa,setOpenCodeInstallationError:$d,setOpenCodeSetupAction:th,setOpenCodeSetupBusy:Qg,setOpenCodeSetupChecking:sh,setOpenCodeSetupError:_c,setOpenCodeSetupFeedback:Uo,setOpenCodeSetupOpen:Hi,setOpenCodeSetupStatus:Cu},Symbol.toStringTag,{value:"Module"}));var l2=F("<p class=settings-error-message role=alert>"),Co=F("<p role=status>"),d2=F("<div class=opencode-setup-panel><div class=settings-info-actions><button type=button class=settings-pill-button>"),u2=F("<p class=settings-toggle-title role=status>"),f2=F("<div class=settings-info-grid><div class=settings-info-row><span></span><span></span></div><div class=settings-info-row><span></span><span>"),g2=F('<p class="settings-toggle-caption break-all">'),Il=F("<p class=settings-toggle-caption>"),hw=F("<p role=alert>"),h2=F("<p>"),Ll=F("<button type=button class=settings-pill-button>"),m2=F("<div class=settings-info-actions>"),p2=F("<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>"),y2=F("<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 HS(e={}){const{t}=kt(),n=()=>ni()||nh();return(()=>{var s=d2(),r=s.firstChild,o=r.firstChild;return p(s,y(Q,{get when(){return er()},get fallback(){return(()=>{var a=Co();return p(a,()=>t(Xg()?"settings.opencode.update.checkFailed":"settings.opencode.update.checking")),a})()},children:a=>[(()=>{var i=u2();return p(i,()=>t(fc()?"settings.opencode.setup.connected":a().state==="ready"?"settings.opencode.setup.disconnected":`settings.opencode.setup.${a().state}`)),i})(),(()=>{var i=f2(),c=i.firstChild,l=c.firstChild,d=l.nextSibling,u=c.nextSibling,f=u.firstChild,h=f.nextSibling;return p(l,()=>t("settings.opencode.update.installed")),p(d,()=>a().currentVersion??"—"),p(f,()=>t("settings.opencode.setup.daemon")),p(h,()=>a().daemonVersion??"—"),i})(),(()=>{var i=g2();return p(i,()=>a().binaryPath),i})(),y(Q,{get when(){return a().installationSource},children:i=>(()=>{var c=Il();return p(c,()=>t(`settings.opencode.setup.source.${i()}`)),c})()}),y(Q,{get when(){return _e(()=>!!a().updateAvailable)()&&a().latestVersion},get children(){var i=Co();return p(i,()=>t("settings.opencode.update.available",{version:a().latestVersion??""})),i}}),y(Q,{get when(){return _e(()=>!!(a().updateAvailable===!1&&a().latestVersion))()&&!a().checkError},get children(){var i=Co();return p(i,()=>t("settings.opencode.update.upToDate")),i}}),y(Q,{get when(){return a().target==="wsl"},get children(){var i=Il();return p(i,()=>t("settings.opencode.setup.wsl")),i}}),y(Q,{get when(){return a().serviceState==="restart_required"||a().serviceState==="restart_available"},get children(){var i=Co();return p(i,()=>t(a().serviceState==="restart_required"?"settings.opencode.setup.restartRequired":"settings.opencode.setup.restartAvailable")),i}}),y(Q,{get when(){return a().serviceState==="error"},get children(){var i=hw();return p(i,()=>t("settings.opencode.setup.serviceError")),i}}),y(Q,{get when(){return a().checkError},get children(){var i=Co();return p(i,()=>t("settings.opencode.update.checkFailed")),i}}),y(Q,{get when(){return _e(()=>!a().canUpgrade)()&&(a().updateAvailable||a().state==="missing"||a().state==="update_required"||a().serviceState==="incompatible")},get children(){var i=h2();return p(i,()=>t("settings.opencode.setup.manual")),i}}),y(Q,{get when(){return _e(()=>!!(a().daemonVersion||a().currentVersion))()&&a().versionAssessment==="untested"},get children(){var i=Il();return p(i,()=>t("settings.opencode.setup.untested",{version:a().daemonVersion??a().currentVersion??""})),i}}),(()=>{var i=m2();return p(i,y(Q,{get when(){return a().canUpgrade},get children(){var c=Ll();return c.$$click=()=>void Xa("install"),p(c,(()=>{var l=_e(()=>Qa()==="install");return()=>l()?t("settings.opencode.update.updating"):_e(()=>!!a().needsSharedInstallation)()?t("settings.opencode.setup.sharedInstall"):_e(()=>a().state==="missing")()?t("settings.opencode.setup.install"):t("settings.opencode.update.action",{version:a().latestVersion??""})})()),de(()=>c.disabled=n()),c}}),null),p(i,y(Q,{get when(){return _e(()=>a().state==="ready"&&!fc()&&a().serviceState!=="restart_required")()&&a().serviceState!=="incompatible"},get children(){var c=Ll();return c.$$click=()=>void Xa("start"),p(c,()=>t("settings.opencode.setup.connect")),de(()=>c.disabled=n()),c}}),null),p(i,y(Q,{get when(){return _e(()=>!!fc())()&&qS()},get children(){var c=Ll();return c.$$click=()=>void zS(),p(c,()=>t("settings.opencode.setup.continue")),de(()=>c.disabled=n()),c}}),null),p(i,y(Q,{get when(){return a().canRestart},get children(){var c=Ll();return c.$$click=()=>void Xa("restart"),p(c,()=>t("settings.opencode.setup.restart")),de(()=>c.disabled=n()),c}}),null),i})(),y(Q,{get when(){return _e(()=>!!a().canUpgrade)()&&(a().state==="missing"||a().needsSharedInstallation)},get children(){var i=Il();return p(i,()=>t("settings.opencode.setup.sharedInstallDescription")),i}})]}),r),p(s,y(Q,{get when(){return Xg()},get children(){var a=l2();return p(a,()=>t(eh()?`settings.opencode.setup.${eh()}`:"settings.opencode.setup.actionFailed")),a}}),r),p(s,y(Q,{get when(){return Qa()},get children(){var a=Co();return p(a,()=>t(Qa()==="install"?"settings.opencode.update.updating":`settings.opencode.setup.progress.${Qa()}`)),a}}),r),p(s,y(Q,{get when(){return rh()},get children(){var a=Co();return p(a,()=>t(`settings.opencode.setup.${rh()}`)),a}}),r),o.$$click=()=>void Gs(!1,!0),p(o,()=>t(nh()?"settings.opencode.update.checking":"settings.opencode.setup.check")),p(s,()=>e.children,null),p(s,y(Q,{get when(){return er()},children:a=>[(()=>{var i=p2(),c=i.firstChild,l=c.nextSibling,d=l.firstChild,u=d.firstChild,f=u.nextSibling,h=d.nextSibling,m=h.firstChild,w=m.nextSibling,S=l.nextSibling;return p(c,()=>t("settings.opencode.setup.diagnostics")),p(u,()=>t("settings.opencode.setup.minimum")),p(f,()=>a().minimumVersion),p(m,()=>t("settings.opencode.setup.recommended")),p(w,()=>a().recommendedVersion),p(S,()=>t("settings.opencode.setup.minimumReason",{version:a().minimumVersion})),p(i,y(Q,{get when(){return _e(()=>!!a().incompatibilityReason)()&&a().incompatibilityReason!=="step_timestamp"},get children(){var b=hw();return p(b,()=>t(`settings.opencode.setup.${a().incompatibilityReason}`)),b}}),null),i})(),y(Q,{get when(){return a().canReload},get children(){var i=y2(),c=i.firstChild,l=c.nextSibling,d=l.nextSibling,u=d.firstChild;return p(c,()=>t("settings.opencode.setup.troubleshooting")),p(l,()=>t("settings.opencode.setup.reloadDescription")),u.$$click=()=>void Xa("reload"),p(u,()=>t("settings.opencode.setup.reload")),de(()=>u.disabled=n()),i}})]}),null),de(a=>{var i=n(),c=n();return i!==a.e&&pe(s,"aria-busy",a.e=i),c!==a.t&&(o.disabled=a.t=c),a},{e:void 0,t:void 0}),s})()}Ht(["click"]);const yi={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 v2=F("<svg>");const w2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ye=e=>{const[t,n]=Et(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var s=v2();return Qs(s,Se(yi,{get width(){return t.size??yi.width},get height(){return t.size??yi.height},get stroke(){return t.color??yi.stroke},get"stroke-width"(){return _e(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??yi["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??yi["stroke-width"])},get class(){return`lucide lucide-${w2((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),p(s,y(Ut,{get each(){return t.iconNode},children:([r,o])=>y(Bm,Se({component:r},o))})),s})()},b2=[["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"}]],S2=e=>y(Ye,Se(e,{name:"AlertCircle",iconNode:b2})),k2=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],x2=e=>y(Ye,Se(e,{name:"ArrowLeft",iconNode:k2})),$2=[["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"}]],_2=e=>y(Ye,Se(e,{name:"ArrowRightSquare",iconNode:$2})),C2=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],E2=e=>y(Ye,Se(e,{name:"ArrowUpLeft",iconNode:C2})),T2=[["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"}]],GS=e=>y(Ye,Se(e,{name:"Bell",iconNode:T2})),M2=[["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"}]],A2=e=>y(Ye,Se(e,{name:"BookOpen",iconNode:M2})),D2=[["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"}]],P2=e=>y(Ye,Se(e,{name:"Brain",iconNode:D2})),O2=[["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"}]],R2=e=>y(Ye,Se(e,{name:"CheckSquare",iconNode:O2})),I2=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ZS=e=>y(Ye,Se(e,{name:"Check",iconNode:I2})),L2=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],tr=e=>y(Ye,Se(e,{name:"ChevronDown",iconNode:L2})),F2=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],N2=e=>y(Ye,Se(e,{name:"ChevronRight",iconNode:F2})),U2=[["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"}]],B2=e=>y(Ye,Se(e,{name:"ClipboardCheck",iconNode:U2})),K2=[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]],V2=e=>y(Ye,Se(e,{name:"Code",iconNode:K2})),j2=[["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"}]],q2=e=>y(Ye,Se(e,{name:"Coins",iconNode:j2})),z2=[["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"}]],Oi=e=>y(Ye,Se(e,{name:"ExternalLink",iconNode:z2})),W2=[["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"}]],H2=e=>y(Ye,Se(e,{name:"FileCog",iconNode:W2})),G2=[["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"}]],Z2=e=>y(Ye,Se(e,{name:"FileEdit",iconNode:G2})),J2=[["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"}]],Y2=e=>y(Ye,Se(e,{name:"File",iconNode:J2})),Q2=[["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"}]],X2=e=>y(Ye,Se(e,{name:"FolderOpen",iconNode:Q2})),eA=[["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"}]],tA=e=>y(Ye,Se(e,{name:"FolderPlus",iconNode:eA})),nA=[["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"}]],sA=e=>y(Ye,Se(e,{name:"Folder",iconNode:nA})),rA=[["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"}]],Bo=e=>y(Ye,Se(e,{name:"Globe",iconNode:rA})),oA=[["path",{d:"M22 10v6M2 10l10-5 10 5-10 5z",key:"1ef52a"}],["path",{d:"M6 12v5c3 3 9 3 12 0v-5",key:"1f75yj"}]],iA=e=>y(Ye,Se(e,{name:"GraduationCap",iconNode:oA})),aA=[["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"}]],cA=e=>y(Ye,Se(e,{name:"HelpCircle",iconNode:aA})),lA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Xm=e=>y(Ye,Se(e,{name:"Info",iconNode:lA})),dA=[["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"}]],uA=e=>y(Ye,Se(e,{name:"KeyRound",iconNode:dA})),fA=[["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"}]],mw=e=>y(Ye,Se(e,{name:"Key",iconNode:fA})),gA=[["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"}]],hA=e=>y(Ye,Se(e,{name:"Languages",iconNode:gA})),mA=[["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"}]],pA=e=>y(Ye,Se(e,{name:"LayoutGrid",iconNode:mA})),yA=[["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"}]],dd=e=>y(Ye,Se(e,{name:"Link2",iconNode:yA})),vA=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Nn=e=>y(Ye,Se(e,{name:"Loader2",iconNode:vA})),wA=[["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"}]],bA=e=>y(Ye,Se(e,{name:"LogIn",iconNode:wA})),SA=[["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"}]],kA=e=>y(Ye,Se(e,{name:"Maximize2",iconNode:SA})),xA=[["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"}]],$A=e=>y(Ye,Se(e,{name:"MessageSquare",iconNode:xA})),_A=[["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"}]],eg=e=>y(Ye,Se(e,{name:"Mic",iconNode:_A})),CA=[["path",{d:"M5 12h14",key:"1ays0h"}]],EA=e=>y(Ye,Se(e,{name:"Minus",iconNode:CA})),TA=[["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"}]],MA=e=>y(Ye,Se(e,{name:"MonitorUp",iconNode:TA})),AA=[["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"}]],DA=e=>y(Ye,Se(e,{name:"Network",iconNode:AA})),PA=[["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"}]],OA=e=>y(Ye,Se(e,{name:"Paperclip",iconNode:PA})),RA=[["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"}]],IA=e=>y(Ye,Se(e,{name:"Pencil",iconNode:RA})),LA=[["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"}]],JS=e=>y(Ye,Se(e,{name:"PlugZap",iconNode:LA})),FA=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Eu=e=>y(Ye,Se(e,{name:"Plus",iconNode:FA})),NA=[["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"}]],_d=e=>y(Ye,Se(e,{name:"RefreshCw",iconNode:NA})),UA=[["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"}]],BA=e=>y(Ye,Se(e,{name:"Save",iconNode:UA})),KA=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],pw=e=>y(Ye,Se(e,{name:"Search",iconNode:KA})),VA=[["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"}]],Fl=e=>y(Ye,Se(e,{name:"Settings",iconNode:VA})),jA=[["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"}]],yw=e=>y(Ye,Se(e,{name:"ShieldOff",iconNode:jA})),qA=[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}]],Cd=e=>y(Ye,Se(e,{name:"Shield",iconNode:qA})),zA=[["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"}]],WA=e=>y(Ye,Se(e,{name:"SlidersHorizontal",iconNode:zA})),HA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],vw=e=>y(Ye,Se(e,{name:"Square",iconNode:HA})),GA=[["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"}]],ZA=e=>y(Ye,Se(e,{name:"Stethoscope",iconNode:GA})),JA=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],ep=e=>y(Ye,Se(e,{name:"Terminal",iconNode:JA})),YA=[["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"}]],Tu=e=>y(Ye,Se(e,{name:"Trash2",iconNode:YA})),QA=[["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"}]],ih=e=>y(Ye,Se(e,{name:"Volume2",iconNode:QA})),XA=[["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"}]],eD=e=>y(Ye,Se(e,{name:"Wifi",iconNode:XA})),tD=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ko=e=>y(Ye,Se(e,{name:"X",iconNode:tD})),ww="__drives__",ah="opencode_v2_required",nD="session_environment_failed";var sD=F('<button type=button class="selector-button selector-button-secondary directory-browser-select directory-browser-new-folder"><span class="inline-flex items-center gap-2">'),rD=F('<div class=directory-browser-current><span class=directory-browser-current-label></span><input type=text class="selector-input directory-browser-current-path"><button type=button class="selector-button selector-button-secondary directory-browser-open-path"><span>'),oD=F('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),iD=F('<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">'),aD=F("<div class=directory-browser-loading><span>"),bw=F('<div class="panel-empty-state flex-1">'),cD=F("<span class=text-red-500>"),lD=F('<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>'),dD=F('<button type=button class="selector-button selector-button-secondary directory-browser-select">');function ja(e){if(!e||e==="."||e==="./")return".";if(e===ww)return ww;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 YS(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function QS(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(YS(t))return t;const n=e.includes("\\")?"\\":"/",s=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${s}${r}`}function Nl(e){return!e||e.pathKind==="drives"?"":e.pathKind==="relative"?QS(e.rootPath,e.currentPath):e.displayPath}const uD=e=>{const{t}=kt(),[n,s]=L(""),[r,o]=L(!1),[a,i]=L(null),[c,l]=L(""),[d,u]=L(!1),[f,h]=L(!1),[m,w]=L(new Map),[S,b]=L(new Set),[v,k]=L(null),[$,C]=L(null),T=new Map,D=new Map;let R=0;function q(){s(""),w(new Map),b(new Set),k(null),C(null),l(""),u(!1),T.clear(),D.clear(),i(null)}qe(()=>{if(!e.open)return;q(),re();const O=g=>{g.key==="Escape"&&(g.preventDefault(),e.onClose())};window.addEventListener("keydown",O),nt(()=>{window.removeEventListener("keydown",O)})});async function re(){var O;o(!0);try{const g=(O=e.initialPath)==null?void 0:O.trim();if(g){if(await U(g))return;i(null)}await U(void 0)}finally{o(!1)}}function ee(O){const g=ja(O.currentPath);k(g),C(O),s(O.rootPath)}async function W(O){const g=O?ja(O):void 0;if(g){const A=T.get(g);if(A)return A;const E=D.get(g);if(E)return E}const x=(async()=>{g&&b(B=>{const oe=new Set(B);return oe.add(g),oe});const A=await ft.listFileSystem(O,{includeFiles:e.mode==="files"}),E=ja(A.metadata.currentPath),H=A.entries.filter(B=>e.mode==="files"||B.type==="directory").sort((B,oe)=>{const Ae=B.type==="directory"?0:1,we=oe.type==="directory"?0:1;return Ae!==we?Ae-we:B.name.localeCompare(oe.name)});return w(B=>{const oe=new Map(B);return oe.set(E,H),oe}),T.set(E,A.metadata),b(B=>{const oe=new Set(B);return g&&oe.delete(g),oe.delete(E),oe}),A.metadata})().catch(A=>{throw g&&b(E=>{const H=new Set(E);return H.delete(g),H}),A}).finally(()=>{g&&D.delete(g)});return g&&D.set(g,x),x}async function U(O){const g=++R;i(null);try{const x=await W(O);return g!==R?null:(ee(x),x)}catch(x){if(g!==R)return null;const A=x instanceof Error?x.message:t("directoryBrowser.load.errorFallback");return i(A),null}}const J=$e(()=>{const O=[],g=$();g!=null&&g.parentPath&&O.push({type:"up",path:g.parentPath});const x=v();if(!x)return O;const A=m().get(x)??[];for(const E of A)O.push({type:"entry",entry:E});return O});function le(O){u(!1),U(O)}function z(){var g;const O=(g=$())==null?void 0:g.parentPath;O&&(u(!1),U(O))}const M=$e(()=>Nl($()));qe(()=>{const O=M();d()||l(O)});const N=$e(()=>!!M()),ce=$e(()=>c().trim().length>0);async function fe(){const O=c().trim();if(!O)return;const g=await U(O);g&&(u(!1),l(Nl(g)))}async function Re(){const O=c().trim(),g=O&&O!==M()?await U(O):$();if(!g)return;u(!1);const x=Nl(g);x&&e.mode!=="files"&&(l(x),e.onSelect(x))}function be(O){const g=O.absolutePath?O.absolutePath:YS(O.path)?O.path:QS(n(),O.path);e.onSelect(g,O)}async function ye(){var A;if(f())return;const O=c().trim(),g=O&&O!==M()?await U(O):$();if(!g||g.pathKind==="drives")return;u(!1),l(Nl(g));const x=((A=await GM(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:A.trim())??"";if(x){if(x==="."||x===".."||x.startsWith("~")||x.includes("/")||x.includes("\\")){Cs(t("directoryBrowser.createFolder.invalidNameMessage"),{variant:"warning",detail:t("directoryBrowser.createFolder.invalidNameDetail")});return}h(!0);try{const E=ja(g.currentPath);T.delete(E),D.delete(E),w(B=>{const oe=new Map(B);return oe.delete(E),oe});const H=await ft.createFileSystemFolder(g.currentPath,x);await U(H.path)}catch(E){const H=E instanceof Error?E.message:t("directoryBrowser.createFolder.errorFallback");Cs(H,{variant:"error",title:t("directoryBrowser.createFolder.errorFallback")})}finally{h(!1)}}}function Ce(O){return S().has(ja(O))}function je(O){O.target===O.currentTarget&&e.onClose()}return y(Q,{get when(){return e.open},get children(){var O=iD(),g=O.firstChild,x=g.firstChild,A=x.firstChild,E=A.firstChild,H=E.firstChild,B=H.nextSibling,oe=E.nextSibling,Ae=A.nextSibling;return O.$$click=je,p(H,()=>e.title),p(B,()=>e.description||t("directoryBrowser.defaultDescription")),cS(oe,"click",e.onClose,!0),p(oe,y(Ko,{class:"w-5 h-5"})),p(Ae,y(Q,{get when(){return n()},get children(){var we=rD(),he=we.firstChild,Ee=he.nextSibling,Ge=Ee.nextSibling,Xe=Ge.firstChild;return p(he,()=>t("directoryBrowser.currentFolder")),Ee.$$keydown=se=>{se.key==="Enter"&&(se.preventDefault(),fe())},Ee.$$input=se=>{l(se.currentTarget.value),u(!0)},pe(Ee,"spellcheck",!1),p(we,y(Q,{get when(){return e.mode!=="files"},get children(){var se=sD(),V=se.firstChild;return se.$$click=()=>void ye(),p(V,y(tA,{class:"w-4 h-4"}),null),p(V,(()=>{var Y=_e(()=>!!f());return()=>Y()?t("directoryBrowser.creating"):t("directoryBrowser.newFolder")})(),null),de(()=>se.disabled=!N()||f()),se}}),Ge),Ge.$$click=()=>void Re(),p(Ge,y(_2,{class:"w-4 h-4"}),Xe),p(Xe,()=>t("directoryBrowser.openCurrent")),de(se=>{var V=t("directoryBrowser.currentFolder.inputPlaceholder"),Y=t("directoryBrowser.currentFolder.inputAriaLabel"),Oe=!N()&&!ce()||f(),ve=t("directoryBrowser.openCurrent"),Ie=t("directoryBrowser.openCurrent");return V!==se.e&&pe(Ee,"placeholder",se.e=V),Y!==se.t&&pe(Ee,"aria-label",se.t=Y),Oe!==se.a&&(Ge.disabled=se.a=Oe),ve!==se.o&&pe(Ge,"title",se.o=ve),Ie!==se.i&&pe(Ge,"aria-label",se.i=Ie),se},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),de(()=>Ee.value=c()),we}}),null),p(Ae,y(Q,{get when(){return _e(()=>!r())()&&!a()},get fallback(){return(()=>{var we=bw();return p(we,y(Q,{get when(){return r()},get fallback(){return(()=>{var he=cD();return p(he,a),he})()},get children(){var he=aD(),Ee=he.firstChild;return p(he,y(Nn,{class:"w-5 h-5 animate-spin"}),Ee),p(Ee,()=>t("directoryBrowser.loadingFolders")),he}})),we})()},get children(){return y(Q,{get when(){return J().length>0},get fallback(){return(()=>{var we=bw();return p(we,()=>t("directoryBrowser.noFolders")),we})()},get children(){var we=oD();return p(we,y(Ut,{get each(){return J()},children:he=>{const Ee=he.type==="entry",Ge=Ee&&he.entry.type==="directory",Xe=Ee&&(e.mode==="files"?he.entry.type==="file":he.entry.type==="directory"),se=Ee?he.entry.name||he.entry.path:t("directoryBrowser.upOneLevel"),V=()=>{if(!Ee){z();return}if(he.entry.type==="directory"){le(he.entry.path);return}be(he.entry)};return(()=>{var Y=lD(),Oe=Y.firstChild,ve=Oe.firstChild,Ie=ve.firstChild,Le=Ie.nextSibling,ze=Le.firstChild;return ve.$$click=V,p(Ie,y(Q,{when:!Ge,get fallback(){return y(sA,{class:"w-4 h-4"})},get children(){return y(Q,{when:Ee,get fallback(){return y(E2,{class:"w-4 h-4"})},get children(){return y(Y2,{class:"w-4 h-4"})}})}})),p(ze,se),p(ve,y(Q,{get when(){return Ge&&Ee&&Ce(he.entry.path)},get children(){return y(Nn,{class:"directory-browser-row-spinner animate-spin"})}}),null),p(Oe,Xe?(()=>{var Ne=dD();return Ne.$$click=Je=>{Je.stopPropagation(),Ee&&be(he.entry)},p(Ne,()=>t("directoryBrowser.select")),Ne})():null,null),Y})()}})),we}})}}),null),de(()=>pe(oe,"aria-label",t("directoryBrowser.close"))),O}})};Ht(["click","input","keydown"]);const fD=Lt("actions");function gD(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 hD(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=gD(n);return e.multiple?s:s[0]??null}catch(n){return fD.error("[native] electron dialog failed",n),null}}async function mD(e={}){return typeof e=="object"&&Object.freeze(e),await vs("plugin:dialog|open",{options:e})}const pD=Lt("actions");async function yD(e){var t;if(typeof window>"u")return null;try{const n=await mD({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 pD.error("[native] tauri dialog failed",n),null}}function vD(){return En()?hD:bn()?yD:null}function wD(){return jE()}async function XS(e){const t=vD();return t?t(e):null}async function _W(e){const t=await XS({mode:"directory",...e??{}});return Array.isArray(t)?t[0]??null:t}async function bD(e){const t=await XS({mode:"file",...e??{}});return Array.isArray(t)?t[0]??null:t}var SD=F('<div class="selector-loading text-xs"><span>'),kD=F("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),xD=F('<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">'),$D=F('<div class="text-xs font-mono truncate pl-6 text-muted">'),_D=F("<span class=selector-badge-version>"),tg=F("<span class=selector-badge-time>"),CD=F('<button type=button class="p-2 text-muted hover:text-primary">'),ED=F('<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 TD=Lt("actions"),MD=e=>{const{t}=kt(),{opencodeBinaries:n,addOpenCodeBinary:s,removeOpenCodeBinary:r,serverSettings:o}=Tn(),[a,i]=L(""),[c,l]=L(!1),[d,u]=L(null),[f,h]=L(new Map),[m,w]=L(new Set),[S,b]=L(!1),v=()=>n(),k=()=>o().opencodeBinary,$=$e(()=>v().filter(M=>M.path!=="opencode"&&M.path!=="opencode2")),C=$e(()=>[{path:"opencode2",isDefault:!0},...$()]),T=()=>e.selectedBinary||"opencode2";qe(()=>{if(!e.selectedBinary&&k())e.onBinaryChange(k());else if(!e.selectedBinary){const M=v()[0];M&&e.onBinaryChange(M.path)}}),qe(()=>{const M=new Map(f());let N=!1;v().forEach(ce=>{ce.version&&!M.has(ce.path)&&(M.set(ce.path,ce.version),N=!0)}),N&&h(M)}),qe(()=>{if(!e.isVisible)return;const M=f(),N=["opencode2",...$().map(ce=>ce.path)].filter(ce=>!M.has(ce));N.length!==0&&setTimeout(()=>{N.forEach(ce=>{D(ce).catch(fe=>TD.error("Failed to validate binary",{path:ce,error:fe}))})},0)}),nt(()=>{w(new Set),l(!1)});async function D(M){if(m().has(M))return{valid:!1,error:t("opencodeBinarySelector.validation.alreadyValidating")};try{w(fe=>new Set(fe).add(M)),l(!0),u(null);const N=await ft.validateBinary(M),ce=N.errorCode===ah?{...N,error:t("opencodeBinarySelector.validation.v2Required")}:N;if(ce.valid&&ce.version){const fe=new Map(f());fe.set(M,ce.version),h(fe)}return ce}catch(N){return{valid:!1,error:N instanceof Error?N.message:String(N)}}finally{w(N=>{const ce=new Set(N);return ce.delete(M),ce.size===0&&l(!1),ce})}}async function R(){if(!e.disabled){if(u(null),wD()){const M=await bD({title:t("opencodeBinarySelector.dialog.title")});M&&(i(M),q(M));return}b(!0)}}async function q(M){const N=await D(M);N.valid?(s(M,N.version),e.onBinaryChange(M),i(""),u(null)):u(N.error||t("opencodeBinarySelector.validation.invalidBinary"))}function re(M){b(!1),i(M),q(M)}async function ee(){const M=a().trim();M&&await q(M)}function W(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 J(M){if(!M)return"";const N=Math.floor((Date.now()-M)/1e3),ce=Math.floor(N/60),fe=Math.floor(ce/60),Re=Math.floor(fe/24);return Re>0?t("time.relative.daysAgoShort",{count:Re}):fe>0?t("time.relative.hoursAgoShort",{count:fe}):ce>0?t("time.relative.minutesAgoShort",{count:ce}):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 z=M=>m().has(M);return[(()=>{var M=xD(),N=M.firstChild,ce=N.firstChild,fe=ce.firstChild,Re=fe.nextSibling,be=N.nextSibling,ye=be.firstChild,Ce=ye.firstChild,je=Ce.nextSibling,O=ye.nextSibling,g=be.nextSibling;return p(fe,()=>t("opencodeBinarySelector.title")),p(Re,()=>t("opencodeBinarySelector.subtitle")),p(N,y(Q,{get when(){return c()},get children(){var x=SD(),A=x.firstChild;return p(x,y(Nn,{class:"selector-loading-spinner"}),A),p(A,()=>t("opencodeBinarySelector.status.checkingVersions")),x}}),null),Ce.$$keydown=x=>{x.key==="Enter"&&(x.preventDefault(),ee())},Ce.$$input=x=>i(x.currentTarget.value),je.$$click=ee,p(je,y(Eu,{class:"w-4 h-4"}),null),p(je,()=>t("opencodeBinarySelector.actions.add"),null),O.$$click=()=>void R(),p(O,y(X2,{class:"w-4 h-4"}),null),p(O,()=>t("opencodeBinarySelector.actions.browse"),null),p(be,y(Q,{get when(){return d()},get children(){var x=kD(),A=x.firstChild,E=A.firstChild;return p(A,y(S2,{class:"selector-validation-error-icon"}),E),p(E,d),x}}),null),p(g,y(Ut,{get each(){return C()},children:x=>{const A=x.isDefault,E=()=>(A?e.defaultVersion:void 0)??f().get(x.path)??x.version;return(()=>{var H=ED(),B=H.firstChild,oe=B.firstChild,Ae=oe.firstChild,we=Ae.firstChild,he=Ae.nextSibling;return B.$$click=()=>W(x.path),p(Ae,y(ZS,{get class(){return`w-4 h-4 transition-opacity ${T()===x.path?"opacity-100":"opacity-0"}`}}),we),p(we,()=>le(x.path)),p(oe,y(Q,{when:!A,get children(){var Ee=$D();return p(Ee,()=>x.path),Ee}}),he),p(he,y(Q,{get when(){return E()},get children(){var Ee=_D();return p(Ee,()=>t("opencodeBinarySelector.versionLabel",{version:E()})),Ee}}),null),p(he,y(Q,{get when(){return z(x.path)},get children(){var Ee=tg();return p(Ee,()=>t("opencodeBinarySelector.status.checking")),Ee}}),null),p(he,y(Q,{get when(){return!A&&x.lastUsed},get children(){var Ee=tg();return p(Ee,()=>J(x.lastUsed)),Ee}}),null),p(he,y(Q,{when:A,get children(){var Ee=tg();return p(Ee,()=>t("opencodeBinarySelector.badge.systemPath")),Ee}}),null),p(H,y(Q,{when:!A,get children(){var Ee=CD();return Ee.$$click=Ge=>U(x.path,Ge),p(Ee,y(Tu,{class:"w-3.5 h-3.5"})),de(Ge=>{var Xe=e.disabled,se=t("opencodeBinarySelector.actions.removeTitle");return Xe!==Ge.e&&(Ee.disabled=Ge.e=Xe),se!==Ge.t&&pe(Ee,"title",Ge.t=se),Ge},{e:void 0,t:void 0}),Ee}}),null),de(Ee=>{var Ge=T()===x.path,Xe=e.disabled;return Ge!==Ee.e&&H.classList.toggle("panel-list-item-highlight",Ee.e=Ge),Xe!==Ee.t&&(B.disabled=Ee.t=Xe),Ee},{e:void 0,t:void 0}),H})()}})),de(x=>{var A=e.disabled,E=t("opencodeBinarySelector.customPath.placeholder",{name:"opencode2"}),H=e.disabled||!a().trim(),B=e.disabled;return A!==x.e&&(Ce.disabled=x.e=A),E!==x.t&&pe(Ce,"placeholder",x.t=E),H!==x.a&&(je.disabled=x.a=H),B!==x.o&&(O.disabled=x.o=B),x},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>Ce.value=a()),M})(),y(uD,{get open(){return S()},mode:"files",get title(){return t("opencodeBinarySelector.dialog.title")},get description(){return t("opencodeBinarySelector.dialog.description")},onClose:()=>b(!1),onSelect:re})]};Ht(["input","keydown","click"]);var AD=F('<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 ek(){const{t:e}=kt(),{serverSettings:t,updateLastUsedBinary:n}=Tn();return(()=>{var s=AD(),r=s.firstChild,o=r.firstChild,a=o.firstChild,i=a.firstChild,c=i.nextSibling,l=o.nextSibling;return p(o,y(ep,{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(MD,{get selectedBinary(){return t().opencodeBinary||"opencode2"},get defaultVersion(){var d;return _e(()=>{var u;return!!((u=er())!=null&&u.installationSource)})()?((d=er())==null?void 0:d.currentVersion)??void 0:void 0},onBinaryChange:n,get disabled(){return ni()},isVisible:!0}),null),s})()}var DD=F('<div class="fixed bottom-4 right-4 z-50 border border-base bg-surface-secondary p-3"role=status><button class=selector-button>'),PD=F("<header class=window-header>"),OD=F("<div class=window-body>"),RD=F('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');function ID(e={}){const{t}=kt(),{serverSettings:n}=Tn();qe(()=>{n().opencodeBinary,zi(WS)}),qe(()=>{ln.getStatuses(),zi(()=>{document.hidden||Gs()})});let s="";return qe(()=>{if(e.automatic===!1)return;const r=er();if(!r||!oh(r)){s="";return}const o=`${r.binaryPath}:${r.state}:${r.daemonVersion??""}`;s!==o&&(s=o,Hi(!0))}),Ns(()=>{const r=()=>{document.hidden||Gs()};window.addEventListener("focus",r),document.addEventListener("visibilitychange",r),nt(()=>{window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",r)})}),[y(Q,{get when(){return _e(()=>!!(e.automatic!==!1&&oh()))()&&!Yg()},get children(){return y(Km,{get children(){var r=DD(),o=r.firstChild;return o.$$click=()=>Qm(),p(o,()=>t("settings.opencode.setup.required")),r}})}}),y(_t,{get open(){return Yg()},onOpenChange:Hi,get children(){return y(_t.Portal,{get children(){return[y(_t.Overlay,{class:"modal-overlay"}),(()=>{var r=RD();return p(r,y(_t.Content,{class:"modal-surface w-full max-w-2xl max-h-[85vh] overflow-auto",get children(){return[(()=>{var o=PD();return p(o,y(_t.Title,{class:"window-title",get children(){return t("settings.opencode.setup.required")}}),null),p(o,y(_t.CloseButton,{class:"window-action",get"aria-label"(){return t("app.launchError.close")},get children(){return t("app.launchError.close")}}),null),o})(),(()=>{var o=OD();return p(o,y(HS,{get children(){return y(ek,{})}})),o})()]}})),r})()]}})}})]}Ht(["click"]);function tk(e){let t=e.startIndex??0;const n=e.startLevel??0,s=[],r=c=>{if(c==null)return"";const l=e.getKey??"key",d=bi(l)?c[l]:l(c);return d!=null?String(d):""},o=c=>{if(c==null)return"";const l=e.getTextValue??"textValue",d=bi(l)?c[l]:l(c);return d!=null?String(d):""},a=c=>{if(c==null)return!1;const l=e.getDisabled??"disabled";return(bi(l)?c[l]:l(c))??!1},i=c=>{var l;if(c!=null)return bi(e.getSectionChildren)?c[e.getSectionChildren]:(l=e.getSectionChildren)==null?void 0:l.call(e,c)};for(const c of e.dataSource){if(bi(c)||QT(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=tk({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 LD(e,t=[]){return $e(()=>{const n=tk({dataSource:ge(e.dataSource),getKey:ge(e.getKey),getTextValue:ge(e.getTextValue),getDisabled:ge(e.getDisabled),getSectionChildren:ge(e.getSectionChildren)});for(let s=0;s<t.length;s++)t[s]();return e.factory(n)})}var FD=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),ND=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function UD(e){if(Intl.Locale){const n=new Intl.Locale(e).maximize().script??"";return FD.has(n)}const t=e.split("-")[0];return ND.has(t)}function BD(e){return UD(e)?"rtl":"ltr"}function nk(){let e=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:BD(e)}}var ch=nk(),ec=new Set;function Sw(){ch=nk();for(const e of ec)e(ch)}function KD(){const[e,t]=L(ch),n=$e(()=>e());return Ns(()=>{ec.size===0&&window.addEventListener("languagechange",Sw),ec.add(t),nt(()=>{ec.delete(t),ec.size===0&&window.removeEventListener("languagechange",Sw)})}),{locale:()=>n().locale,direction:()=>n().direction}}var VD=Ir();function tp(){const e=KD();return Lr(VD)||e}var ng=new Map;function np(e){const{locale:t}=tp(),n=$e(()=>t()+(e?Object.entries(e).sort((s,r)=>s[0]<r[0]?-1:1).join():""));return $e(()=>{const s=n();let r;return ng.has(s)&&(r=ng.get(s)),r||(r=new Intl.Collator(t(),e),ng.set(s,r)),r})}function CW(e){const t=np({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 zs=class sk extends Set{constructor(n,s,r){super(n);ae(this,"anchorKey");ae(this,"currentKey");n instanceof sk?(this.anchorKey=s||n.anchorKey,this.currentKey=r||n.currentKey):(this.anchorKey=s,this.currentKey=r)}};function jD(e){const[t,n]=Zm(e);return[()=>t()??new zs,n]}function rk(e){return sM()?e.altKey:e.ctrlKey}function Si(e){return Xc()?e.metaKey:e.ctrlKey}function kw(e){return new zs(e)}function ok(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function qD(e){const t=Dt({selectionMode:"none",selectionBehavior:"toggle"},e),[n,s]=L(!1),[r,o]=L(),a=$e(()=>{const w=ge(t.selectedKeys);return w!=null?kw(w):w}),i=$e(()=>{const w=ge(t.defaultSelectedKeys);return w!=null?kw(w):new zs}),[c,l]=jD({value:a,defaultValue:i,onChange:w=>{var S;return(S=t.onSelectionChange)==null?void 0:S.call(t,w)}}),[d,u]=L(ge(t.selectionBehavior)),f=()=>ge(t.selectionMode),h=()=>ge(t.disallowEmptySelection)??!1,m=w=>{(ge(t.allowDuplicateSelectionEvents)||!ok(w,c()))&&l(w)};return qe(()=>{const w=c();ge(t.selectionBehavior)==="replace"&&d()==="toggle"&&typeof w=="object"&&w.size===0&&u("replace")}),qe(()=>{u(ge(t.selectionBehavior)??"toggle")}),{selectionMode:f,disallowEmptySelection:h,selectionBehavior:d,setSelectionBehavior:u,isFocused:n,setFocused:s,focusedKey:r,setFocusedKey:o,selectedKeys:c,setSelectedKeys:m}}function ik(e){const[t,n]=L(""),[s,r]=L(-1);return{typeSelectHandlers:{onKeyDown:a=>{var f;if(ge(e.isDisabled))return;const i=ge(e.keyboardDelegate),c=ge(e.selectionManager);if(!i.getKeyForSearch)return;const l=zD(a.key);if(!l||a.ctrlKey||a.metaKey)return;l===" "&&t().trim().length>0&&(a.preventDefault(),a.stopPropagation());let d=n(h=>h+l),u=i.getKeyForSearch(d,c.focusedKey())??i.getKeyForSearch(d);u==null&&WD(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 zD(e){return e.length===1||!/^[A-Z]/i.test(e)?e:""}function WD(e){return e.split("").every(t=>t===e[0])}function HD(e,t,n){const r=Se({selectOnFocus:()=>ge(e.selectionManager).selectionBehavior()==="replace"},e),o=()=>(n==null?void 0:n())??t(),{direction:a}=tp();let i={top:0,left:0};GT(()=>ge(r.isVirtualized)?void 0:o(),"scroll",()=>{const S=o();S&&(i={top:S.scrollTop,left:S.scrollLeft})});const{typeSelectHandlers:c}=ik({isDisabled:()=>ge(r.disallowTypeAhead),keyboardDelegate:()=>ge(r.keyboardDelegate),selectionManager:()=>ge(r.selectionManager)}),l=()=>ge(r.orientation)??"vertical",d=S=>{var R,q,re,ee,W,U,J,le;Zt(S,c.onKeyDown),S.altKey&&S.key==="Tab"&&S.preventDefault();const b=t();if(!(b!=null&&b.contains(S.target)))return;const v=ge(r.selectionManager),k=ge(r.selectOnFocus),$=z=>{z!=null&&(v.setFocusedKey(z),S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(z):k&&!rk(S)&&v.replaceSelection(z))},C=ge(r.keyboardDelegate),T=ge(r.shouldFocusWrap),D=v.focusedKey();switch(S.key){case(l()==="vertical"?"ArrowDown":"ArrowRight"):{if(C.getKeyBelow){S.preventDefault();let z;D!=null?z=C.getKeyBelow(D):z=(R=C.getFirstKey)==null?void 0:R.call(C),z==null&&T&&(z=(q=C.getFirstKey)==null?void 0:q.call(C,D)),$(z)}break}case(l()==="vertical"?"ArrowUp":"ArrowLeft"):{if(C.getKeyAbove){S.preventDefault();let z;D!=null?z=C.getKeyAbove(D):z=(re=C.getLastKey)==null?void 0:re.call(C),z==null&&T&&(z=(ee=C.getLastKey)==null?void 0:ee.call(C,D)),$(z)}break}case(l()==="vertical"?"ArrowLeft":"ArrowUp"):{if(C.getKeyLeftOf){S.preventDefault();const z=a()==="rtl";let M;D!=null?M=C.getKeyLeftOf(D):M=z?(W=C.getFirstKey)==null?void 0:W.call(C):(U=C.getLastKey)==null?void 0:U.call(C),$(M)}break}case(l()==="vertical"?"ArrowRight":"ArrowDown"):{if(C.getKeyRightOf){S.preventDefault();const z=a()==="rtl";let M;D!=null?M=C.getKeyRightOf(D):M=z?(J=C.getLastKey)==null?void 0:J.call(C):(le=C.getFirstKey)==null?void 0:le.call(C),$(M)}break}case"Home":if(C.getFirstKey){S.preventDefault();const z=C.getFirstKey(D,Si(S));z!=null&&(v.setFocusedKey(z),Si(S)&&S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(z):k&&v.replaceSelection(z))}break;case"End":if(C.getLastKey){S.preventDefault();const z=C.getLastKey(D,Si(S));z!=null&&(v.setFocusedKey(z),Si(S)&&S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(z):k&&v.replaceSelection(z))}break;case"PageDown":if(C.getKeyPageBelow&&D!=null){S.preventDefault();const z=C.getKeyPageBelow(D);$(z)}break;case"PageUp":if(C.getKeyPageAbove&&D!=null){S.preventDefault();const z=C.getKeyPageAbove(D);$(z)}break;case"a":Si(S)&&v.selectionMode()==="multiple"&&ge(r.disallowSelectAll)!==!0&&(S.preventDefault(),v.selectAll());break;case"Escape":S.defaultPrevented||(S.preventDefault(),ge(r.disallowEmptySelection)||v.clearSelection());break;case"Tab":if(!ge(r.allowsTabNavigation)){if(S.shiftKey)b.focus();else{const z=mM(b,{tabbable:!0});let M,N;do N=z.lastChild(),N&&(M=N);while(N);M&&!M.contains(document.activeElement)&&xn(M)}break}}},u=S=>{var $,C;const b=ge(r.selectionManager),v=ge(r.keyboardDelegate),k=ge(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=R=>{R!=null&&(b.setFocusedKey(R),k&&b.replaceSelection(R))},D=S.relatedTarget;D&&S.currentTarget.compareDocumentPosition(D)&Node.DOCUMENT_POSITION_FOLLOWING?T(b.lastSelectedKey()??(($=v.getLastKey)==null?void 0:$.call(v))):T(b.firstSelectedKey()??((C=v.getFirstKey)==null?void 0:C.call(v)))}else if(!ge(r.isVirtualized)){const T=o();if(T){T.scrollTop=i.top,T.scrollLeft=i.left;const D=T.querySelector(`[data-key="${b.focusedKey()}"]`);D&&(xn(D),Hg(T,D))}}}},f=S=>{const b=ge(r.selectionManager);S.currentTarget.contains(S.relatedTarget)||b.setFocused(!1)},h=S=>{o()===S.target&&S.preventDefault()},m=()=>{var T,D;const S=ge(r.autoFocus);if(!S)return;const b=ge(r.selectionManager),v=ge(r.keyboardDelegate);let k;S==="first"&&(k=(T=v.getFirstKey)==null?void 0:T.call(v)),S==="last"&&(k=(D=v.getLastKey)==null?void 0:D.call(v));const $=b.selectedKeys();$.size&&(k=$.values().next().value),b.setFocused(!0),b.setFocusedKey(k);const C=t();C&&k==null&&!ge(r.shouldUseVirtualFocus)&&xn(C)};return Ns(()=>{r.deferAutoFocus?setTimeout(m,0):m()}),qe(ei([o,()=>ge(r.isVirtualized),()=>ge(r.selectionManager).focusedKey()],S=>{var $;const[b,v,k]=S;if(v)k&&(($=r.scrollToKey)==null||$.call(r,k));else if(k&&b){const C=b.querySelector(`[data-key="${k}"]`);C&&Hg(b,C)}})),{tabIndex:$e(()=>{if(!ge(r.shouldUseVirtualFocus))return ge(r.selectionManager).focusedKey()==null?0:-1}),onKeyDown:d,onMouseDown:h,onFocusIn:u,onFocusOut:f}}function GD(e,t){const n=()=>ge(e.selectionManager),s=()=>ge(e.key),r=()=>ge(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"||Si(v)||"pointerType"in v&&v.pointerType==="touch"?n().toggleSelection(s()):n().replaceSelection(s()))},a=()=>n().isSelected(s()),i=()=>ge(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&&!ge(e.shouldSelectOnPressUp)&&o(v))},u=v=>{c()&&v.pointerType==="mouse"&&v.button===0&&ge(e.shouldSelectOnPressUp)&&ge(e.allowsDifferentPressOrigin)&&o(v)},f=v=>{c()&&(ge(e.shouldSelectOnPressUp)&&!ge(e.allowsDifferentPressOrigin)||l!=="mouse")&&o(v)},h=v=>{!c()||!["Enter"," "].includes(v.key)||(rk(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=$e(()=>{if(!(r()||i()))return s()===n().focusedKey()?0:-1}),b=$e(()=>ge(e.virtualized)?void 0:s());return qe(ei([t,s,r,()=>n().focusedKey(),()=>n().isFocused()],([v,k,$,C,T])=>{v&&k===C&&T&&!$&&document.activeElement!==v&&(e.focus?e.focus():xn(v))})),{isSelected:a,isDisabled:i,allowsSelection:c,tabIndex:S,dataKey:b,onPointerDown:d,onPointerUp:u,onClick:f,onKeyDown:h,onMouseDown:m,onFocus:w}}var ZD=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 zs(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 zs(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 zs([t],t,t):new zs;this.state.setSelectedKeys(n)}setSelectedKeys(e){if(this.selectionMode()==="none")return;const t=new zs;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 zs)}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}},xw=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 ak(e){const t=qD(e),s=LD({dataSource:()=>ge(e.dataSource),getKey:()=>ge(e.getKey),getTextValue:()=>ge(e.getTextValue),getDisabled:()=>ge(e.getDisabled),getSectionChildren:()=>ge(e.getSectionChildren),factory:o=>e.filter?new xw(e.filter(o)):new xw(o)},[()=>e.filter]),r=new ZD(s,t);return uS(()=>{const o=t.focusedKey();o!=null&&!s().getItem(o)&&t.setFocusedKey(void 0)}),{collection:s,selectionManager:()=>r}}var ck=["id","name","validationState","required","disabled","readOnly"];function lk(e){const t=`form-control-${ti()}`,n=Dt({id:t},e),[s,r]=L(),[o,a]=L(),[i,c]=L(),[l,d]=L(),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,h=$e(()=>({"data-valid":ge(n.validationState)==="valid"?"":void 0,"data-invalid":ge(n.validationState)==="invalid"?"":void 0,"data-required":ge(n.required)?"":void 0,"data-disabled":ge(n.disabled)?"":void 0,"data-readonly":ge(n.readOnly)?"":void 0}));return{formControlContext:{name:()=>ge(n.name)??ge(n.id),dataset:h,validationState:()=>ge(n.validationState),isRequired:()=>ge(n.required),isDisabled:()=>ge(n.disabled),isReadOnly:()=>ge(n.readOnly),labelId:s,fieldId:o,descriptionId:i,errorMessageId:l,getAriaLabelledBy:u,getAriaDescribedBy:f,generateId:Ea(()=>ge(n.id)),registerLabel:ds(r),registerField:ds(a),registerDescription:ds(c),registerErrorMessage:ds(d)}}}var sp=Ir();function or(){const e=Lr(sp);if(e===void 0)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function rp(e){const t=or(),n=Dt({id:t.generateId("description")},e);return qe(()=>nt(t.registerDescription(n.id))),y(zt,Se({as:"div"},()=>t.dataset(),n))}var JD=F("<option>"),YD=F("<div aria-hidden=true><input type=text style=font-size:16px><select tabindex=-1><option>");function QD(e){let t;const[n,s]=Et(e,["ref","onChange","collection","selectionManager","isOpen","isMultiple","isVirtualized","focusTrigger"]),r=or(),[o,a]=L(!1),i=c=>{const l=n.collection.getItem(c);return y(Q,{get when(){return(l==null?void 0:l.type)==="item"},get children(){var d=JD();return d.value=c,p(d,()=>l==null?void 0:l.textValue),de(()=>d.selected=n.selectionManager.isSelected(c)),d}})};return qe(ei(()=>n.selectionManager.selectedKeys(),(c,l)=>{l&&ok(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=YD(),l=c.firstChild,d=l.nextSibling;d.firstChild,l.addEventListener("focus",()=>n.focusTrigger()),d.addEventListener("change",f=>{Zt(f,n.onChange),o()||n.selectionManager.setSelectedKeys(new Set([f.target.value])),a(!1)});var u=Mn(f=>t=f,n.ref);return typeof u=="function"&&Xs(u,d),Qs(d,Se({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(Q,{get when(){return n.isVirtualized},get fallback(){return y(Ut,{get each(){return[...n.collection.getKeys()]},children:i})},get children(){return y(Ut,{get each(){return[...n.selectionManager.selectedKeys()]},children:i})}}),null),de(f=>{var h=$u,m=n.selectionManager.isFocused()||n.isOpen?-1:0,w=r.isRequired(),S=r.isDisabled(),b=r.isReadOnly();return f.e=hr(c,h,f.e),m!==f.t&&pe(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 $w=new WeakMap;function XD(e){let t=$w.get(e);if(t!=null)return t;t=0;for(const n of e)n.type==="item"&&t++;return $w.set(e,t),t}var dk=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 eP(e,t,n){const s=np({usage:"search",sensitivity:"base"}),r=$e(()=>{const o=ge(e.keyboardDelegate);return o||new dk(e.collection,t,s)});return HD({selectionManager:()=>ge(e.selectionManager),keyboardDelegate:r,autoFocus:()=>ge(e.autoFocus),deferAutoFocus:()=>ge(e.deferAutoFocus),shouldFocusWrap:()=>ge(e.shouldFocusWrap),disallowEmptySelection:()=>ge(e.disallowEmptySelection),selectOnFocus:()=>ge(e.selectOnFocus),disallowTypeAhead:()=>ge(e.disallowTypeAhead),shouldUseVirtualFocus:()=>ge(e.shouldUseVirtualFocus),allowsTabNavigation:()=>ge(e.allowsTabNavigation),isVirtualized:()=>ge(e.isVirtualized),scrollToKey:o=>{var a;return(a=ge(e.scrollToKey))==null?void 0:a(o)},orientation:()=>ge(e.orientation)},t,n)}var tP={};el(tP,{Item:()=>Mu,ItemDescription:()=>Au,ItemIndicator:()=>Du,ItemLabel:()=>Pu,Listbox:()=>nP,Root:()=>ip,Section:()=>Ou,useListboxContext:()=>fk});var uk=Ir();function fk(){const e=Lr(uk);if(e===void 0)throw new Error("[kobalte]: `useListboxContext` must be used within a `Listbox` component");return e}var gk=Ir();function op(){const e=Lr(gk);if(e===void 0)throw new Error("[kobalte]: `useListboxItemContext` must be used within a `Listbox.Item` component");return e}function Mu(e){let t;const n=fk(),s=`${n.generateId("item")}-${ti()}`,r=Dt({id:s},e),[o,a]=Et(r,["ref","item","aria-label","aria-labelledby","aria-describedby","onPointerMove","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[i,c]=L(),[l,d]=L(),u=()=>n.listState().selectionManager(),f=()=>u().focusedKey()===o.item.key,h=GD({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 h.isSelected()},w=$e(()=>!(Xc()&&rM())),S=()=>w()?o["aria-label"]:void 0,b=()=>w()?i():void 0,v=()=>w()?l():void 0,k=()=>{var q;if(!n.isVirtualized())return;const R=(q=n.listState().collection().getItem(o.item.key))==null?void 0:q.index;return R!=null?R+1:void 0},$=()=>{if(n.isVirtualized())return XD(n.listState().collection())},C=R=>{Zt(R,o.onPointerMove),R.pointerType==="mouse"&&!h.isDisabled()&&n.shouldFocusOnHover()&&(xn(R.currentTarget),u().setFocused(!0),u().setFocusedKey(o.item.key))},T=$e(()=>({"data-disabled":h.isDisabled()?"":void 0,"data-selected":h.isSelected()?"":void 0,"data-highlighted":f()?"":void 0})),D={isSelected:h.isSelected,dataset:T,generateId:Ea(()=>a.id),registerLabelId:ds(c),registerDescriptionId:ds(d)};return y(gk.Provider,{value:D,get children(){return y(zt,Se({as:"li",ref(R){var q=Mn(re=>t=re,o.ref);typeof q=="function"&&q(R)},role:"option",get tabIndex(){return h.tabIndex()},get"aria-disabled"(){return h.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 $()},get"data-key"(){return h.dataKey()},get onPointerDown(){return ls([o.onPointerDown,h.onPointerDown])},get onPointerUp(){return ls([o.onPointerUp,h.onPointerUp])},get onClick(){return ls([o.onClick,h.onClick])},get onKeyDown(){return ls([o.onKeyDown,h.onKeyDown])},get onMouseDown(){return ls([o.onMouseDown,h.onMouseDown])},get onFocus(){return ls([o.onFocus,h.onFocus])},onPointerMove:C},T,a))}})}function Au(e){const t=op(),n=Dt({id:t.generateId("description")},e);return qe(()=>nt(t.registerDescriptionId(n.id))),y(zt,Se({as:"div"},()=>t.dataset(),n))}function Du(e){const t=op(),n=Dt({id:t.generateId("indicator")},e),[s,r]=Et(n,["forceMount"]);return y(Q,{get when(){return s.forceMount||t.isSelected()},get children(){return y(zt,Se({as:"div","aria-hidden":"true"},()=>t.dataset(),r))}})}function Pu(e){const t=op(),n=Dt({id:t.generateId("label")},e);return qe(()=>nt(t.registerLabelId(n.id))),y(zt,Se({as:"div"},()=>t.dataset(),n))}function ip(e){let t;const n=`listbox-${ti()}`,s=Dt({id:n,selectionMode:"single",virtualized:!1},e),[r,o]=Et(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=$e(()=>r.state?r.state:ak({selectedKeys:()=>r.value,defaultSelectedKeys:()=>r.defaultValue,onSelectionChange:r.onChange,allowDuplicateSelectionEvents:()=>ge(r.allowDuplicateSelectionEvents),disallowEmptySelection:()=>ge(r.disallowEmptySelection),selectionBehavior:()=>ge(r.selectionBehavior),selectionMode:()=>ge(r.selectionMode),dataSource:()=>r.options??[],getKey:()=>r.optionValue,getTextValue:()=>r.optionTextValue,getDisabled:()=>r.optionDisabled,getSectionChildren:()=>r.optionGroupChildren})),i=eP({selectionManager:()=>a().selectionManager(),collection:()=>a().collection(),autoFocus:()=>ge(r.autoFocus),shouldFocusWrap:()=>ge(r.shouldFocusWrap),keyboardDelegate:()=>r.keyboardDelegate,disallowEmptySelection:()=>ge(r.disallowEmptySelection),selectOnFocus:()=>ge(r.selectOnFocus),disallowTypeAhead:()=>ge(r.disallowTypeAhead),shouldUseVirtualFocus:()=>ge(r.shouldUseVirtualFocus),allowsTabNavigation:()=>ge(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:Ea(()=>o.id),shouldUseVirtualFocus:()=>s.shouldUseVirtualFocus,shouldSelectOnPressUp:()=>s.shouldSelectOnPressUp,shouldFocusOnHover:()=>s.shouldFocusOnHover,isVirtualized:()=>r.virtualized};return y(uk.Provider,{value:c,get children(){return y(zt,Se({as:"ul",ref(l){var d=Mn(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 ls([r.onKeyDown,i.onKeyDown])},get onMouseDown(){return ls([r.onMouseDown,i.onMouseDown])},get onFocusIn(){return ls([r.onFocusIn,i.onFocusIn])},get onFocusOut(){return ls([r.onFocusOut,i.onFocusOut])}},o,{get children(){return y(Q,{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(JT,{get each(){return[...a().collection()]},by:"key",children:l=>y(dS,{get children(){return[y(_i,{get when(){return l().type==="section"},get children(){var d;return(d=r.renderSection)==null?void 0:d.call(r,l())}}),y(_i,{get when(){return l().type==="item"},get children(){var d;return(d=r.renderItem)==null?void 0:d.call(r,l())}})]}})})}})}}))}})}function Ou(e){return y(zt,Se({as:"li",role:"presentation"},e))}var nP=Object.assign(ip,{Item:Mu,ItemDescription:Au,ItemIndicator:Du,ItemLabel:Pu,Section:Ou});const sP=["top","right","bottom","left"],so=Math.min,Yn=Math.max,Ed=Math.round,Ul=Math.floor,Zs=e=>({x:e,y:e}),rP={left:"right",right:"left",bottom:"top",top:"bottom"},oP={start:"end",end:"start"};function lh(e,t,n){return Yn(e,so(t,n))}function si(e,t){return typeof e=="function"?e(t):e}function ro(e){return e.split("-")[0]}function Ta(e){return e.split("-")[1]}function hk(e){return e==="x"?"y":"x"}function ap(e){return e==="y"?"height":"width"}const iP=new Set(["top","bottom"]);function yr(e){return iP.has(ro(e))?"y":"x"}function cp(e){return hk(yr(e))}function aP(e,t,n){n===void 0&&(n=!1);const s=Ta(e),r=cp(e),o=ap(r);let a=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Td(a)),[a,Td(a)]}function cP(e){const t=Td(e);return[dh(e),t,dh(t)]}function dh(e){return e.replace(/start|end/g,t=>oP[t])}const _w=["left","right"],Cw=["right","left"],lP=["top","bottom"],dP=["bottom","top"];function uP(e,t,n){switch(e){case"top":case"bottom":return n?t?Cw:_w:t?_w:Cw;case"left":case"right":return t?lP:dP;default:return[]}}function fP(e,t,n,s){const r=Ta(e);let o=uP(ro(e),n==="start",s);return r&&(o=o.map(a=>a+"-"+r),t&&(o=o.concat(o.map(dh)))),o}function Td(e){return e.replace(/left|right|bottom|top/g,t=>rP[t])}function gP(e){return{top:0,right:0,bottom:0,left:0,...e}}function mk(e){return typeof e!="number"?gP(e):{top:e,right:e,bottom:e,left:e}}function Md(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 Ew(e,t,n){let{reference:s,floating:r}=e;const o=yr(t),a=cp(t),i=ap(a),c=ro(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 h;switch(c){case"top":h={x:d,y:s.y-r.height};break;case"bottom":h={x:d,y:s.y+s.height};break;case"right":h={x:s.x+s.width,y:u};break;case"left":h={x:s.x-r.width,y:u};break;default:h={x:s.x,y:s.y}}switch(Ta(t)){case"start":h[a]-=f*(n&&l?-1:1);break;case"end":h[a]+=f*(n&&l?-1:1);break}return h}const hP=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}=Ew(l,s,c),f=s,h={},m=0;for(let w=0;w<i.length;w++){const{name:S,fn:b}=i[w],{x:v,y:k,data:$,reset:C}=await b({x:d,y:u,initialPlacement:s,placement:f,strategy:r,middlewareData:h,rects:l,platform:a,elements:{reference:e,floating:t}});d=v??d,u=k??u,h={...h,[S]:{...h[S],...$}},C&&m<=50&&(m++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(l=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:r}):C.rects),{x:d,y:u}=Ew(l,f,c)),w=-1)}return{x:d,y:u,placement:f,strategy:r,middlewareData:h}};async function Cc(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:h=0}=si(t,e),m=mk(h),S=i[f?u==="floating"?"reference":"floating":u],b=Md(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)),$=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},C=Md(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:v,offsetParent:k,strategy:c}):v);return{top:(b.top-C.top+m.top)/$.y,bottom:(C.bottom-b.bottom+m.bottom)/$.y,left:(b.left-C.left+m.left)/$.x,right:(C.right-b.right+m.right)/$.x}}const mP=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}=si(e,t)||{};if(l==null)return{};const u=mk(d),f={x:n,y:s},h=cp(r),m=ap(h),w=await a.getDimensions(l),S=h==="y",b=S?"top":"left",v=S?"bottom":"right",k=S?"clientHeight":"clientWidth",$=o.reference[m]+o.reference[h]-f[h]-o.floating[m],C=f[h]-o.reference[h],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l));let D=T?T[k]:0;(!D||!await(a.isElement==null?void 0:a.isElement(T)))&&(D=i.floating[k]||o.floating[m]);const R=$/2-C/2,q=D/2-w[m]/2-1,re=so(u[b],q),ee=so(u[v],q),W=re,U=D-w[m]-ee,J=D/2-w[m]/2+R,le=lh(W,J,U),z=!c.arrow&&Ta(r)!=null&&J!==le&&o.reference[m]/2-(J<W?re:ee)-w[m]/2<0,M=z?J<W?J-W:J-U:0;return{[h]:f[h]+M,data:{[h]:le,centerOffset:J-le-M,...z&&{alignmentOffset:M}},reset:z}}}),pP=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:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:w=!0,...S}=si(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const b=ro(r),v=yr(i),k=ro(i)===i,$=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=f||(k||!w?[Td(i)]:cP(i)),T=m!=="none";!f&&T&&C.push(...fP(i,w,m,$));const D=[i,...C],R=await Cc(t,S),q=[];let re=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&q.push(R[b]),u){const J=aP(r,a,$);q.push(R[J[0]],R[J[1]])}if(re=[...re,{placement:r,overflows:q}],!q.every(J=>J<=0)){var ee,W;const J=(((ee=o.flip)==null?void 0:ee.index)||0)+1,le=D[J];if(le&&(!(u==="alignment"?v!==yr(le):!1)||re.every(N=>yr(N.placement)===v?N.overflows[0]>0:!0)))return{data:{index:J,overflows:re},reset:{placement:le}};let z=(W=re.filter(M=>M.overflows[0]<=0).sort((M,N)=>M.overflows[1]-N.overflows[1])[0])==null?void 0:W.placement;if(!z)switch(h){case"bestFit":{var U;const M=(U=re.filter(N=>{if(T){const ce=yr(N.placement);return ce===v||ce==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(ce=>ce>0).reduce((ce,fe)=>ce+fe,0)]).sort((N,ce)=>N[1]-ce[1])[0])==null?void 0:U[0];M&&(z=M);break}case"initialPlacement":z=i;break}if(r!==z)return{reset:{placement:z}}}return{}}}};function Tw(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Mw(e){return sP.some(t=>e[t]>=0)}const yP=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:s="referenceHidden",...r}=si(e,t);switch(s){case"referenceHidden":{const o=await Cc(t,{...r,elementContext:"reference"}),a=Tw(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Mw(a)}}}case"escaped":{const o=await Cc(t,{...r,altBoundary:!0}),a=Tw(o,n.floating);return{data:{escapedOffsets:a,escaped:Mw(a)}}}default:return{}}}}},vP=new Set(["left","top"]);async function wP(e,t){const{placement:n,platform:s,elements:r}=e,o=await(s.isRTL==null?void 0:s.isRTL(r.floating)),a=ro(n),i=Ta(n),c=yr(n)==="y",l=vP.has(a)?-1:1,d=o&&c?-1:1,u=si(t,e);let{mainAxis:f,crossAxis:h,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"&&(h=i==="end"?m*-1:m),c?{x:h*d,y:f*l}:{x:f*l,y:h*d}}const bP=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 wP(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}}}}},SP=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}=si(e,t),l={x:n,y:s},d=await Cc(t,c),u=yr(ro(r)),f=hk(u);let h=l[f],m=l[u];if(o){const S=f==="y"?"top":"left",b=f==="y"?"bottom":"right",v=h+d[S],k=h-d[b];h=lh(v,h,k)}if(a){const S=u==="y"?"top":"left",b=u==="y"?"bottom":"right",v=m+d[S],k=m-d[b];m=lh(v,m,k)}const w=i.fn({...t,[f]:h,[u]:m});return{...w,data:{x:w.x-n,y:w.y-s,enabled:{[f]:o,[u]:a}}}}}},kP=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}=si(e,t),d=await Cc(t,l),u=ro(r),f=Ta(r),h=yr(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,$=so(w-d[S],v),C=so(m-d[b],k),T=!t.middlewareData.shift;let D=$,R=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=k),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(D=v),T&&!f){const re=Yn(d.left,0),ee=Yn(d.right,0),W=Yn(d.top,0),U=Yn(d.bottom,0);h?R=m-2*(re!==0||ee!==0?re+ee:Yn(d.left,d.right)):D=w-2*(W!==0||U!==0?W+U:Yn(d.top,d.bottom))}await c({...t,availableWidth:R,availableHeight:D});const q=await a.getDimensions(i.floating);return m!==q.width||w!==q.height?{reset:{rects:!0}}:{}}}};function Ru(){return typeof window<"u"}function Ma(e){return pk(e)?(e.nodeName||"").toLowerCase():"#document"}function es(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ir(e){var t;return(t=(pk(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function pk(e){return Ru()?e instanceof Node||e instanceof es(e).Node:!1}function As(e){return Ru()?e instanceof Element||e instanceof es(e).Element:!1}function nr(e){return Ru()?e instanceof HTMLElement||e instanceof es(e).HTMLElement:!1}function Aw(e){return!Ru()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof es(e).ShadowRoot}const xP=new Set(["inline","contents"]);function nl(e){const{overflow:t,overflowX:n,overflowY:s,display:r}=Ds(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!xP.has(r)}const $P=new Set(["table","td","th"]);function _P(e){return $P.has(Ma(e))}const CP=[":popover-open",":modal"];function Iu(e){return CP.some(t=>{try{return e.matches(t)}catch{return!1}})}const EP=["transform","translate","scale","rotate","perspective"],TP=["transform","translate","scale","rotate","perspective","filter"],MP=["paint","layout","strict","content"];function lp(e){const t=dp(),n=As(e)?Ds(e):e;return EP.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)||TP.some(s=>(n.willChange||"").includes(s))||MP.some(s=>(n.contain||"").includes(s))}function AP(e){let t=oo(e);for(;nr(t)&&!Gi(t);){if(lp(t))return t;if(Iu(t))return null;t=oo(t)}return null}function dp(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const DP=new Set(["html","body","#document"]);function Gi(e){return DP.has(Ma(e))}function Ds(e){return es(e).getComputedStyle(e)}function Lu(e){return As(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function oo(e){if(Ma(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Aw(e)&&e.host||ir(e);return Aw(t)?t.host:t}function yk(e){const t=oo(e);return Gi(t)?e.ownerDocument?e.ownerDocument.body:e.body:nr(t)&&nl(t)?t:yk(t)}function Ec(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=yk(e),o=r===((s=e.ownerDocument)==null?void 0:s.body),a=es(r);if(o){const i=uh(a);return t.concat(a,a.visualViewport||[],nl(r)?r:[],i&&n?Ec(i):[])}return t.concat(r,Ec(r,[],n))}function uh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vk(e){const t=Ds(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const r=nr(e),o=r?e.offsetWidth:n,a=r?e.offsetHeight:s,i=Ed(n)!==o||Ed(s)!==a;return i&&(n=o,s=a),{width:n,height:s,$:i}}function up(e){return As(e)?e:e.contextElement}function Ri(e){const t=up(e);if(!nr(t))return Zs(1);const n=t.getBoundingClientRect(),{width:s,height:r,$:o}=vk(t);let a=(o?Ed(n.width):n.width)/s,i=(o?Ed(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const PP=Zs(0);function wk(e){const t=es(e);return!dp()||!t.visualViewport?PP:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function OP(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==es(e)?!1:t}function Vo(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=up(e);let a=Zs(1);t&&(s?As(s)&&(a=Ri(s)):a=Ri(e));const i=OP(o,n,s)?wk(o):Zs(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=es(o),h=s&&As(s)?es(s):s;let m=f,w=uh(m);for(;w&&s&&h!==m;){const S=Ri(w),b=w.getBoundingClientRect(),v=Ds(w),k=b.left+(w.clientLeft+parseFloat(v.paddingLeft))*S.x,$=b.top+(w.clientTop+parseFloat(v.paddingTop))*S.y;c*=S.x,l*=S.y,d*=S.x,u*=S.y,c+=k,l+=$,m=es(w),w=uh(m)}}return Md({width:d,height:u,x:c,y:l})}function Fu(e,t){const n=Lu(e).scrollLeft;return t?t.left+n:Vo(ir(e)).left+n}function bk(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Fu(e,n),r=n.top+t.scrollTop;return{x:s,y:r}}function RP(e){let{elements:t,rect:n,offsetParent:s,strategy:r}=e;const o=r==="fixed",a=ir(s),i=t?Iu(t.floating):!1;if(s===a||i&&o)return n;let c={scrollLeft:0,scrollTop:0},l=Zs(1);const d=Zs(0),u=nr(s);if((u||!u&&!o)&&((Ma(s)!=="body"||nl(a))&&(c=Lu(s)),nr(s))){const h=Vo(s);l=Ri(s),d.x=h.x+s.clientLeft,d.y=h.y+s.clientTop}const f=a&&!u&&!o?bk(a,c):Zs(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 IP(e){return Array.from(e.getClientRects())}function LP(e){const t=ir(e),n=Lu(e),s=e.ownerDocument.body,r=Yn(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),o=Yn(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+Fu(e);const i=-n.scrollTop;return Ds(s).direction==="rtl"&&(a+=Yn(t.clientWidth,s.clientWidth)-r),{width:r,height:o,x:a,y:i}}const Dw=25;function FP(e,t){const n=es(e),s=ir(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=dp();(!d||d&&t==="fixed")&&(i=r.offsetLeft,c=r.offsetTop)}const l=Fu(s);if(l<=0){const d=s.ownerDocument,u=d.body,f=getComputedStyle(u),h=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(s.clientWidth-u.clientWidth-h);m<=Dw&&(o-=m)}else l<=Dw&&(o+=l);return{width:o,height:a,x:i,y:c}}const NP=new Set(["absolute","fixed"]);function UP(e,t){const n=Vo(e,!0,t==="fixed"),s=n.top+e.clientTop,r=n.left+e.clientLeft,o=nr(e)?Ri(e):Zs(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 Pw(e,t,n){let s;if(t==="viewport")s=FP(e,n);else if(t==="document")s=LP(ir(e));else if(As(t))s=UP(t,n);else{const r=wk(e);s={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Md(s)}function Sk(e,t){const n=oo(e);return n===t||!As(n)||Gi(n)?!1:Ds(n).position==="fixed"||Sk(n,t)}function BP(e,t){const n=t.get(e);if(n)return n;let s=Ec(e,[],!1).filter(i=>As(i)&&Ma(i)!=="body"),r=null;const o=Ds(e).position==="fixed";let a=o?oo(e):e;for(;As(a)&&!Gi(a);){const i=Ds(a),c=lp(a);!c&&i.position==="fixed"&&(r=null),(o?!c&&!r:!c&&i.position==="static"&&!!r&&NP.has(r.position)||nl(a)&&!c&&Sk(e,a))?s=s.filter(d=>d!==a):r=i,a=oo(a)}return t.set(e,s),s}function KP(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const a=[...n==="clippingAncestors"?Iu(t)?[]:BP(t,this._c):[].concat(n),s],i=a[0],c=a.reduce((l,d)=>{const u=Pw(t,d,r);return l.top=Yn(u.top,l.top),l.right=so(u.right,l.right),l.bottom=so(u.bottom,l.bottom),l.left=Yn(u.left,l.left),l},Pw(t,i,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function VP(e){const{width:t,height:n}=vk(e);return{width:t,height:n}}function jP(e,t,n){const s=nr(t),r=ir(t),o=n==="fixed",a=Vo(e,!0,o,t);let i={scrollLeft:0,scrollTop:0};const c=Zs(0);function l(){c.x=Fu(r)}if(s||!s&&!o)if((Ma(t)!=="body"||nl(r))&&(i=Lu(t)),s){const h=Vo(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else r&&l();o&&!s&&r&&l();const d=r&&!s&&!o?bk(r,i):Zs(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 sg(e){return Ds(e).position==="static"}function Ow(e,t){if(!nr(e)||Ds(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ir(e)===n&&(n=n.ownerDocument.body),n}function kk(e,t){const n=es(e);if(Iu(e))return n;if(!nr(e)){let r=oo(e);for(;r&&!Gi(r);){if(As(r)&&!sg(r))return r;r=oo(r)}return n}let s=Ow(e,t);for(;s&&_P(s)&&sg(s);)s=Ow(s,t);return s&&Gi(s)&&sg(s)&&!lp(s)?n:s||AP(e)||n}const qP=async function(e){const t=this.getOffsetParent||kk,n=this.getDimensions,s=await n(e.floating);return{reference:jP(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function zP(e){return Ds(e).direction==="rtl"}const xk={convertOffsetParentRelativeRectToViewportRelativeRect:RP,getDocumentElement:ir,getClippingRect:KP,getOffsetParent:kk,getElementRects:qP,getClientRects:IP,getDimensions:VP,getScale:Ri,isElement:As,isRTL:zP};function $k(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function WP(e,t){let n=null,s;const r=ir(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:h}=l;if(i||t(),!f||!h)return;const m=Ul(u),w=Ul(r.clientWidth-(d+f)),S=Ul(r.clientHeight-(u+h)),b=Ul(d),k={rootMargin:-m+"px "+-w+"px "+-S+"px "+-b+"px",threshold:Yn(0,so(1,c))||1};let $=!0;function C(T){const D=T[0].intersectionRatio;if(D!==c){if(!$)return a();D?a(!1,D):s=setTimeout(()=>{a(!1,1e-7)},1e3)}D===1&&!$k(l,e.getBoundingClientRect())&&a(),$=!1}try{n=new IntersectionObserver(C,{...k,root:r.ownerDocument})}catch{n=new IntersectionObserver(C,k)}n.observe(e)}return a(!0),o}function HP(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=up(e),d=r||o?[...l?Ec(l):[],...Ec(t)]:[];d.forEach(b=>{r&&b.addEventListener("scroll",n,{passive:!0}),o&&b.addEventListener("resize",n)});const u=l&&i?WP(l,n):null;let f=-1,h=null;a&&(h=new ResizeObserver(b=>{let[v]=b;v&&v.target===l&&h&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var k;(k=h)==null||k.observe(t)})),n()}),l&&!c&&h.observe(l),h.observe(t));let m,w=c?Vo(e):null;c&&S();function S(){const b=Vo(e);w&&!$k(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=h)==null||b.disconnect(),h=null,c&&cancelAnimationFrame(m)}}const GP=bP,ZP=SP,JP=pP,YP=kP,QP=yP,XP=mP,e4=(e,t,n)=>{const s=new Map,r={platform:xk,...n},o={...r.platform,_c:s};return hP(e,t,{...r,platform:o})};var t4=F('<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>'),fp=Ir();function gp(){const e=Lr(fp);if(e===void 0)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var fh=30,Rw=fh/2,n4={top:180,right:-90,bottom:0,left:90};function hp(e){const t=gp(),n=Dt({size:fh},e),[s,r]=Et(n,["ref","style","size"]),o=()=>t.currentPlacement().split("-")[0],a=s4(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*(fh/s.size),u=()=>`rotate(${n4[o()]} ${Rw} ${Rw}) translate(0 2)`;return y(zt,Se({as:"div",ref(f){var h=Mn(t.setArrowRef,s.ref);typeof h=="function"&&h(f)},"aria-hidden":"true",get style(){return Qc({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=t4(),h=f.firstChild,m=h.firstChild;return m.nextSibling,de(()=>pe(h,"transform",u())),f}}))}function s4(e){const[t,n]=L();return qe(()=>{const s=e();s&&n(XT(s).getComputedStyle(s))}),t}function r4(e){const t=gp(),[n,s]=Et(e,["ref","style"]);return y(zt,Se({as:"div",ref(r){var o=Mn(t.setPositionerRef,n.ref);typeof o=="function"&&o(r)},"data-popper-positioner":"",get style(){return Qc({position:"absolute",top:0,left:0,"min-width":"max-content"},n.style)}},s))}function Iw(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 o4(e,t){return{contextElement:e,getBoundingClientRect:()=>{const s=t(e);return s?Iw(s):e?e.getBoundingClientRect():Iw()}}}function i4(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var a4={top:"bottom",right:"left",bottom:"top",left:"right"};function c4(e,t){const[n,s]=e.split("-"),r=a4[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 l4(e){const t=Dt({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]=L(),[r,o]=L(),[a,i]=L(t.placement),c=()=>{var f;return o4((f=t.anchorRef)==null?void 0:f.call(t),t.getAnchorRect)},{direction:l}=tp();async function d(){var T,D;const f=c(),h=n(),m=r();if(!f||!h)return;const w=((m==null?void 0:m.clientHeight)||0)/2,S=typeof t.gutter=="number"?t.gutter+w:t.gutter??w;h.style.setProperty("--kb-popper-content-overflow-padding",`${t.overflowPadding}px`),f.getBoundingClientRect();const b=[GP(({placement:R})=>{const q=!!R.split("-")[1];return{mainAxis:S,crossAxis:q?void 0:t.shift,alignmentAxis:t.shift}})];if(t.flip!==!1){const R=typeof t.flip=="string"?t.flip.split(" "):void 0;if(R!==void 0&&!R.every(i4))throw new Error("`flip` expects a spaced-delimited list of placements");b.push(JP({padding:t.overflowPadding,fallbackPlacements:R}))}(t.slide||t.overlap)&&b.push(ZP({mainAxis:t.slide,crossAxis:t.overlap,padding:t.overflowPadding})),b.push(YP({padding:t.overflowPadding,apply({availableWidth:R,availableHeight:q,rects:re}){const ee=Math.round(re.reference.width);R=Math.floor(R),q=Math.floor(q),h.style.setProperty("--kb-popper-anchor-width",`${ee}px`),h.style.setProperty("--kb-popper-content-available-width",`${R}px`),h.style.setProperty("--kb-popper-content-available-height",`${q}px`),t.sameWidth&&(h.style.width=`${ee}px`),t.fitViewport&&(h.style.maxWidth=`${R}px`,h.style.maxHeight=`${q}px`)}})),t.hideWhenDetached&&b.push(QP({padding:t.detachedPadding})),m&&b.push(XP({element:m,padding:t.arrowPadding}));const v=await e4(f,h,{placement:t.placement,strategy:"absolute",middleware:b,platform:{...xk,isRTL:()=>l()==="rtl"}});if(i(v.placement),(T=t.onCurrentPlacementChange)==null||T.call(t,v.placement),!h)return;h.style.setProperty("--kb-popper-content-transform-origin",c4(v.placement,l()));const k=Math.round(v.x),$=Math.round(v.y);let C;if(t.hideWhenDetached&&(C=(D=v.middlewareData.hide)!=null&&D.referenceHidden?"hidden":"visible"),Object.assign(h.style,{top:"0",left:"0",transform:`translate3d(${k}px, ${$}px, 0)`,visibility:C}),m&&v.middlewareData.arrow){const{x:R,y:q}=v.middlewareData.arrow,re=v.placement.split("-")[0];Object.assign(m.style,{left:R!=null?`${R}px`:"",top:q!=null?`${q}px`:"",[re]:"100%"})}}qe(()=>{const f=c(),h=n();if(!f||!h)return;const m=HP(f,h,d,{elementResize:typeof ResizeObserver=="function"});nt(m)}),qe(()=>{var m;const f=n(),h=(m=t.contentRef)==null?void 0:m.call(t);!f||!h||queueMicrotask(()=>{f.style.zIndex=getComputedStyle(h).zIndex})});const u={currentPlacement:a,contentRef:()=>{var f;return(f=t.contentRef)==null?void 0:f.call(t)},setPositionerRef:s,setArrowRef:o};return y(fp.Provider,{value:u,get children(){return t.children}})}var _k=Object.assign(l4,{Arrow:hp,Context:fp,usePopperContext:gp,Positioner:r4}),Ck=["id","aria-label","aria-labelledby","aria-describedby"];function Ek(e){const t=or(),n=Dt({id:t.generateId("field")},e);return qe(()=>nt(t.registerField(ge(n.id)))),{fieldProps:{id:()=>ge(n.id),ariaLabel:()=>ge(n["aria-label"]),ariaLabelledBy:()=>t.getAriaLabelledBy(ge(n.id),ge(n["aria-label"]),ge(n["aria-labelledby"])),ariaDescribedBy:()=>t.getAriaDescribedBy(ge(n["aria-describedby"]))}}}function Tk(e){let t;const n=or(),s=Dt({id:n.generateId("label")},e),[r,o]=Et(s,["ref"]),a=OS(()=>t,()=>"label");return qe(()=>nt(n.registerLabel(o.id))),y(zt,Se({as:"label",ref(i){var c=Mn(l=>t=l,r.ref);typeof c=="function"&&c(i)},get for(){return _e(()=>a()==="label")()?n.fieldId():void 0}},()=>n.dataset(),o))}function Mk(e,t){qe(ei(e,n=>{if(n==null)return;const s=d4(n);s!=null&&(s.addEventListener("reset",t,{passive:!0}),nt(()=>{s.removeEventListener("reset",t)}))}))}function d4(e){return u4(e)?e.form:e.closest("form")}function u4(e){return e.matches("textarea, input, select, button")}function mp(e){const t=or(),n=Dt({id:t.generateId("error-message")},e),[s,r]=Et(n,["forceMount"]),o=()=>t.validationState()==="invalid";return qe(()=>{o()&&nt(t.registerErrorMessage(r.id))}),y(Q,{get when(){return s.forceMount||o()},get children(){return y(zt,Se({as:"div"},()=>t.dataset(),r))}})}var f4={};el(f4,{Arrow:()=>hp,Content:()=>Dk,Description:()=>rp,ErrorMessage:()=>mp,HiddenSelect:()=>Pk,Icon:()=>Ok,Item:()=>Mu,ItemDescription:()=>Au,ItemIndicator:()=>Du,ItemLabel:()=>Pu,Label:()=>Rk,Listbox:()=>Ik,Portal:()=>Lk,Root:()=>Fk,Section:()=>Ou,Select:()=>Te,Trigger:()=>Nk,Value:()=>Uk,useSelectContext:()=>Fr});var Ak=Ir();function Fr(){const e=Lr(Ak);if(e===void 0)throw new Error("[kobalte]: `useSelectContext` must be used within a `Select` component");return e}function Dk(e){let t;const n=Fr(),[s,r]=Et(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 TS({isDisabled:()=>!(n.isOpen()&&n.isModal()),targets:()=>t?[t]:[]}),RS({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),CS({trapFocus:()=>n.isOpen()&&n.isModal(),onMountAutoFocus:i=>{i.preventDefault()},onUnmountAutoFocus:i=>{var c;(c=s.onCloseAutoFocus)==null||c.call(s,i),i.defaultPrevented||(xn(n.triggerRef()),i.preventDefault())}},()=>t),y(Q,{get when(){return n.contentPresent()},get children(){return y(_k.Positioner,{get children(){return y(AS,Se({ref(i){var c=Mn(l=>{n.setContentRef(l),t=l},s.ref);typeof c=="function"&&c(i)},get disableOutsidePointerEvents(){return _e(()=>!!n.isModal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get style(){return Qc({"--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 Pk(e){const t=Fr();return y(QD,Se({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 Ok(e){const t=Fr(),n=Dt({children:"▼"},e);return y(zt,Se({as:"span","aria-hidden":"true"},()=>t.dataset(),n))}function Rk(e){const t=Fr(),[n,s]=Et(e,["onClick"]);return y(Tk,Se({as:"span",onClick:o=>{var a;Zt(o,n.onClick),t.isDisabled()||(a=t.triggerRef())==null||a.focus()}},s))}function Ik(e){const t=Fr(),n=Dt({id:t.generateId("listbox")},e),[s,r]=Et(n,["ref","id","onKeyDown"]);return qe(()=>nt(t.registerListboxId(s.id))),y(ip,Se({ref(a){var i=Mn(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=>{Zt(a,s.onKeyDown),a.key==="Escape"&&a.preventDefault()}},r))}function Lk(e){const t=Fr();return y(Q,{get when(){return t.contentPresent()},get children(){return y(Km,e)}})}function g4(e){const t=`select-${ti()}`,n=Dt({id:t,selectionMode:"single",disallowEmptySelection:!1,closeOnSelection:e.selectionMode==="single",allowDuplicateSelectionEvents:!0,gutter:8,sameWidth:!0,modal:!1},e),[s,r,o,a]=Et(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"],ck),[i,c]=L(),[l,d]=L(),[u,f]=L(),[h,m]=L(),[w,S]=L(),[b,v]=L(),[k,$]=L(),[C,T]=L(!0),D=g=>{const x=s.optionValue;return x==null?String(g):String(xu(x)?x(g):g[x])},R=$e(()=>{const g=s.optionGroupChildren;return g==null?s.options:s.options.flatMap(x=>x[g]??x)}),q=$e(()=>R().map(g=>D(g))),re=g=>[...g].map(x=>R().find(A=>D(A)===x)).filter(x=>x!=null),ee=PS({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:g=>{var x;return(x=s.onOpenChange)==null?void 0:x.call(s,g)}}),W=ak({selectedKeys:()=>s.value!=null?s.value.map(D):s.value,defaultSelectedKeys:()=>s.defaultValue!=null?s.defaultValue.map(D):s.defaultValue,onSelectionChange:g=>{var x;(x=s.onChange)==null||x.call(s,re(g)),s.closeOnSelection&&N()},allowDuplicateSelectionEvents:()=>ge(s.allowDuplicateSelectionEvents),disallowEmptySelection:()=>ge(s.disallowEmptySelection),selectionBehavior:()=>ge(s.selectionBehavior),selectionMode:()=>s.selectionMode,dataSource:()=>s.options??[],getKey:()=>s.optionValue,getTextValue:()=>s.optionTextValue,getDisabled:()=>s.optionDisabled,getSectionChildren:()=>s.optionGroupChildren}),U=$e(()=>re(W.selectionManager().selectedKeys())),J=g=>{W.selectionManager().toggleSelection(D(g))},{present:le}=Jg({show:()=>s.forceMount||ee.isOpen(),element:()=>w()??null}),z=()=>{const g=b();g&&xn(g)},M=g=>{if(s.options.length<=0)return;T(g),ee.open();let x=W.selectionManager().firstSelectedKey();x==null&&(g==="first"?x=W.collection().getFirstKey():g==="last"&&(x=W.collection().getLastKey())),z(),W.selectionManager().setFocused(!0),W.selectionManager().setFocusedKey(x)},N=()=>{ee.close(),W.selectionManager().setFocused(!1),W.selectionManager().setFocusedKey(void 0)},ce=g=>{ee.isOpen()?N():M(g)},{formControlContext:fe}=lk(o);Mk(h,()=>{const g=s.defaultValue?[...s.defaultValue].map(D):new zs;W.selectionManager().setSelectedKeys(g)});const Re=np({usage:"search",sensitivity:"base"}),be=$e(()=>{const g=ge(s.keyboardDelegate);return g||new dk(W.collection,void 0,Re)}),ye=g=>{var x;return(x=s.itemComponent)==null?void 0:x.call(s,{item:g})},Ce=g=>{var x;return(x=s.sectionComponent)==null?void 0:x.call(s,{section:g})};qe(ei([q],([g])=>{const A=[...W.selectionManager().selectedKeys()].filter(E=>g.includes(E));W.selectionManager().setSelectedKeys(A)},{defer:!0}));const je=$e(()=>({"data-expanded":ee.isOpen()?"":void 0,"data-closed":ee.isOpen()?void 0:""})),O={dataset:je,isOpen:ee.isOpen,isDisabled:()=>fe.isDisabled()??!1,isMultiple:()=>ge(s.selectionMode)==="multiple",isVirtualized:()=>s.virtualized??!1,isModal:()=>s.modal??!1,preventScroll:()=>s.preventScroll??O.isModal(),disallowTypeAhead:()=>s.disallowTypeAhead??!1,shouldFocusWrap:()=>s.shouldFocusWrap??!1,selectedOptions:U,contentPresent:le,autoFocus:C,triggerRef:h,listState:()=>W,keyboardDelegate:be,triggerId:i,valueId:l,listboxId:u,listboxAriaLabelledBy:k,setListboxAriaLabelledBy:$,setTriggerRef:m,setContentRef:S,setListboxRef:v,open:M,close:N,toggle:ce,placeholder:()=>s.placeholder,renderItem:ye,renderSection:Ce,removeOptionFromSelection:J,generateId:Ea(()=>ge(o.id)),registerTriggerId:ds(c),registerValueId:ds(d),registerListboxId:ds(f)};return y(sp.Provider,{value:fe,get children(){return y(Ak.Provider,{value:O,get children(){return y(_k,Se({anchorRef:h,contentRef:w},r,{get children(){return y(zt,Se({as:"div",role:"group",get id(){return ge(o.id)}},()=>fe.dataset(),je,a))}}))}})}})}function Fk(e){const[t,n]=Et(e,["value","defaultValue","onChange","multiple"]),s=$e(()=>t.value!=null?t.multiple?t.value:[t.value]:t.value),r=$e(()=>t.defaultValue!=null?t.multiple?t.defaultValue:[t.defaultValue]:t.defaultValue);return y(g4,Se({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 Nk(e){const t=or(),n=Fr(),s=Dt({id:n.generateId("trigger")},e),[r,o,a]=Et(s,["ref","disabled","onPointerDown","onClick","onKeyDown","onFocus","onBlur"],Ck),i=()=>n.listState().selectionManager(),c=()=>n.keyboardDelegate(),l=()=>r.disabled||n.isDisabled(),{fieldProps:d}=Ek(o),{typeSelectHandlers:u}=ik({keyboardDelegate:c,selectionManager:i,onTypeSelect:v=>i().select(v)}),f=()=>[n.listboxAriaLabelledBy(),n.valueId()].filter(Boolean).join(" ")||void 0,h=v=>{Zt(v,r.onPointerDown),v.currentTarget.dataset.pointerType=v.pointerType,!l()&&v.pointerType!=="touch"&&v.button===0&&(v.preventDefault(),n.toggle(!0))},m=v=>{Zt(v,r.onClick),!l()&&v.currentTarget.dataset.pointerType==="touch"&&n.toggle(!0)},w=v=>{var k,$,C,T,D,R,q,re;if(Zt(v,r.onKeyDown),!l())switch(Zt(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 ee=i().firstSelectedKey(),W=ee!=null?($=(k=c()).getKeyAbove)==null?void 0:$.call(k,ee):(T=(C=c()).getFirstKey)==null?void 0:T.call(C);W!=null&&i().select(W);break}case"ArrowRight":{if(v.preventDefault(),n.isMultiple())return;const ee=i().firstSelectedKey(),W=ee!=null?(R=(D=c()).getKeyBelow)==null?void 0:R.call(D,ee):(re=(q=c()).getFirstKey)==null?void 0:re.call(q);W!=null&&i().select(W);break}}},S=v=>{Zt(v,r.onFocus),!i().isFocused()&&i().setFocused(!0)},b=v=>{Zt(v,r.onBlur),!n.isOpen()&&i().setFocused(!1)};return qe(()=>nt(n.registerTriggerId(d.id()))),qe(()=>{n.setListboxAriaLabelledBy([d.ariaLabelledBy(),d.ariaLabel()&&!d.ariaLabelledBy()?d.id():null].filter(Boolean).join(" ")||void 0)}),y(tl,Se({ref(v){var k=Mn(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 _e(()=>!!n.isOpen())()?n.listboxId():void 0},get"aria-label"(){return d.ariaLabel()},get"aria-labelledby"(){return f()},get"aria-describedby"(){return d.ariaDescribedBy()},onPointerDown:h,onClick:m,onKeyDown:w,onFocus:S,onBlur:b},()=>n.dataset(),()=>t.dataset(),a))}function Uk(e){const t=or(),n=Fr(),s=Dt({id:n.generateId("value")},e),[r,o]=Et(s,["id","children"]),a=()=>n.listState().selectionManager(),i=()=>{const c=a().selectedKeys();return c.size===1&&c.has("")?!0:a().isEmpty()};return qe(()=>nt(n.registerValueId(r.id))),y(zt,Se({as:"span",get id(){return r.id},get"data-placeholder-shown"(){return i()?"":void 0}},()=>t.dataset(),o,{get children(){return y(Q,{get when(){return!i()},get fallback(){return n.placeholder()},get children(){return y(h4,{state:{selectedOption:()=>n.selectedOptions()[0],selectedOptions:()=>n.selectedOptions(),remove:c=>n.removeOptionFromSelection(c),clear:()=>a().clearSelection()},get children(){return r.children}})}})}}))}function h4(e){const t=fS(()=>{const n=e.children;return xu(n)?n(e.state):n});return _e(t)}var Te=Object.assign(Fk,{Arrow:hp,Content:Dk,Description:rp,ErrorMessage:mp,HiddenSelect:Pk,Icon:Ok,Item:Mu,ItemDescription:Au,ItemIndicator:Du,ItemLabel:Pu,Label:Rk,Listbox:Ik,Portal:Lk,Section:Ou,Trigger:Nk,Value:Uk});const Lw="@media ";function m4(e){let t=typeof e=="function"?e(HE()):e;t.startsWith(Lw)&&(t=t.slice(Lw.length));const n=window.matchMedia(t),[s,r]=L(n.matches),o=a=>r(a.matches);return n.addEventListener?n.addEventListener("change",o):n.addListener(o),nt(()=>n.removeEventListener("change",o)),s}const gh=new Set(["general","chat","notifications","speech","remote","opencode","providers","sidecars","config-files","advanced","info"]);function Ad(e){if(typeof e=="string")return gh.has(e)?{section:e}:null;if(!e||typeof e!="object")return null;const t=e;if(!gh.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 p4(e){const t=new URL(e).searchParams,n=t.get("preferences");if(!n||!gh.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 y4(e,t=!1,n=!1){var s;if(mn.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(mn.host==="tauri"){await vs("open_preferences_window",{request:e,toggle:t,resume:n});return}throw new Error("Native Preferences is unavailable")}async function v4(){var e,t;En()?await((t=(e=window.electronAPI)==null?void 0:e.preferencesReady)==null?void 0:t.call(e)):bn()&&await vs("preferences_window_ready")}async function w4(e,t){var n,s;En()?await((s=(n=window.electronAPI)==null?void 0:n.acceptPreferencesRequest)==null?void 0:s.call(n,e)):bn()&&await vs("preferences_accept_request",{request:e,generation:t})}async function b4(e){return En()?(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__}):bn()?Su("client-state:flush-requested",t=>{e(t.payload.generation).catch(n=>Lt("actions").warn("Preferences shutdown flush failed",n))}):()=>{}}async function S4(){var t;const e=p4(window.location.href);if(En()){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 Ad(s)??e??{section:"general"}}if(bn()){const n=await vs("preferences_get_request");return Ad(n)??e??{section:"general"}}return e??{section:"general"}}async function k4(e){var t,n;return En()?((n=(t=window.electronAPI)==null?void 0:t.onPreferencesSection)==null?void 0:n.call(t,s=>{const r=Ad(s);r&&e(r)}))??(()=>{}):bn()?await Su("preferences:section",s=>{const r=Ad(s.payload);r&&e(r)}):()=>{}}async function x4(e){var t,n;return En()?((n=(t=window.electronAPI)==null?void 0:t.onPreferencesCloseRequested)==null?void 0:n.call(t,e))??(()=>{}):bn()?await Su("preferences:close-requested",e):()=>{}}async function $4(e){var n,s;const t=r=>{r&&typeof r=="object"&&Number.isSafeInteger(r.id)&&e(r.id)};return En()?((s=(n=window.electronAPI)==null?void 0:n.onPreferencesTransitionRequested)==null?void 0:s.call(n,t))??(()=>{}):bn()?await Su("preferences:transition-requested",r=>t(r.payload)):()=>{}}async function _4(e,t){var n,s;En()?await((s=(n=window.electronAPI)==null?void 0:n.resolvePreferencesTransition)==null?void 0:s.call(n,e,t)):bn()&&await vs("preferences_resolve_transition",{id:e,approved:t})}const hh=new Set;let Fw=Promise.resolve();function Bk(e){return hh.add(e),()=>hh.delete(e)}function Ii(){const e=Fw.then(async()=>{for(const t of Array.from(hh))if(!await t())return!1;return!0});return Fw=e.then(()=>{},()=>{}),e}const[Kk,mh]=L(!1),[vi,pp]=L("general"),C4=Lt("actions");async function Vk(e,t=!1){if(t&&Kk()){await Ii()&&mh(!1);return}if(e&&pp(e),(mn.host==="electron"||mn.host==="tauri")&&mn.windowContext==="local")try{const{activeInstanceId:n}=await ts(async()=>{const{activeInstanceId:o}=await Promise.resolve().then(()=>V6);return{activeInstanceId:o}},void 0),s=n()??void 0,r={section:e??"general",instanceId:s};if(s){const{getActiveCatalogLocation:o}=await ts(async()=>{const{getActiveCatalogLocation:a}=await Promise.resolve().then(()=>cq);return{getActiveCatalogLocation:a}},void 0);r.location=o(s)}await y4(r,t,e===void 0);return}catch(n){C4.warn("Native Preferences failed; opening settings in this window",n)}mh(!0)}const EW=e=>Vk(e,!0);function E4(){mh(!1)}function as(e){return ke(e).split(",").map(t=>t.trim()).filter(Boolean)}function Vr(e,t,n){e()!==n&&t()}function ph(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 yp(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}Vr(()=>!!(t().showKeyboardShortcutHints??!1),e.toggleKeyboardShortcutHints,s)},disabled:()=>Wg()},{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}Vr(()=>!!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}Vr(()=>!!(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}Vr(()=>!!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:ph,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}Vr(()=>!!(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}Vr(()=>!!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})}},...Fm()&&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}Vr(()=>!!(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}Vr(()=>!!t().promptSubmitOnEnter,e.togglePromptSubmitOnEnter,s)}}]}function T4(e){return[{id:"prompt-submit-shortcut",label:()=>e.preferences().promptSubmitOnEnter?ke("commands.promptSubmitShortcut.label.swapped"):ke("commands.promptSubmitShortcut.label.default"),description:()=>ke("commands.promptSubmitShortcut.description"),category:"Input & Focus",keywords:()=>as("commands.promptSubmitShortcut.keywords"),action:e.togglePromptSubmitOnEnter},{id:"thinking",label:()=>ke(e.preferences().showThinkingBlocks?"commands.thinkingBlocks.label.hide":"commands.thinkingBlocks.label.show"),description:()=>ke("commands.thinkingBlocks.description"),category:"System",keywords:()=>["/thinking",...as("commands.thinkingBlocks.keywords")],action:e.toggleShowThinkingBlocks},{id:"timeline-tools",label:()=>ke(e.preferences().showTimelineTools?"commands.timelineToolCalls.label.hide":"commands.timelineToolCalls.label.show"),description:()=>ke("commands.timelineToolCalls.description"),category:"System",keywords:()=>as("commands.timelineToolCalls.keywords"),action:e.toggleShowTimelineTools},{id:"keyboard-shortcut-hints",label:()=>ke(e.preferences().showKeyboardShortcutHints?"commands.keyboardShortcutHints.label.hide":"commands.keyboardShortcutHints.label.show"),description:()=>ke(Wg()?"commands.keyboardShortcutHints.description.disabledWeb":"commands.keyboardShortcutHints.description"),category:"System",keywords:()=>as("commands.keyboardShortcutHints.keywords"),disabled:()=>Wg(),action:e.toggleKeyboardShortcutHints},{id:"thinking-default-visibility",label:()=>{const n=(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?ke("commands.common.expanded"):ke("commands.common.collapsed");return ke("commands.thinkingBlocksDefault.label",{state:n})},description:()=>ke("commands.thinkingBlocksDefault.description"),category:"System",keywords:()=>["/thinking",...as("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"?"✓ ":""}${ke("commands.diffViewSplit.label")}`,description:()=>ke("commands.diffViewSplit.description"),category:"System",keywords:()=>as("commands.diffViewSplit.keywords"),action:()=>e.setDiffViewMode("split")},{id:"diff-view-unified",label:()=>`${(e.preferences().diffViewMode||"split")==="unified"?"✓ ":""}${ke("commands.diffViewUnified.label")}`,description:()=>ke("commands.diffViewUnified.description"),category:"System",keywords:()=>as("commands.diffViewUnified.keywords"),action:()=>e.setDiffViewMode("unified")},{id:"tool-output-default-visibility",label:()=>{const t=ph(e.preferences()),n=t==="expanded"?ke("commands.common.expanded"):t==="collapsed"?ke("commands.common.collapsed"):ke("commands.common.hidden");return ke("commands.toolOutputsDefault.label",{state:n})},description:()=>ke("commands.toolOutputsDefault.description"),category:"System",keywords:()=>as("commands.toolOutputsDefault.keywords"),action:()=>{const t=ph(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"?ke("commands.common.expanded"):t==="collapsed"?ke("commands.common.collapsed"):ke("commands.common.hidden");return ke("commands.diagnosticsDefault.label",{state:n})},description:()=>ke("commands.diagnosticsDefault.description"),category:"System",keywords:()=>as("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"?ke("commands.common.expanded"):t==="collapsed"?ke("commands.common.collapsed"):ke("commands.common.hidden");return ke("commands.toolInputsVisibility.label",{state:n})},description:()=>ke("commands.toolInputsVisibility.description"),category:"System",keywords:()=>as("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?ke("commands.common.visible"):ke("commands.common.hidden");return ke("commands.tokenUsageDisplay.label",{state:n})},description:()=>ke("commands.tokenUsageDisplay.description"),category:"System",keywords:()=>as("commands.tokenUsageDisplay.keywords"),action:e.toggleUsageMetrics},{id:"auto-cleanup-blank-sessions",label:()=>{const n=e.preferences().autoCleanupBlankSessions?ke("commands.common.enabled"):ke("commands.common.disabled");return ke("commands.autoCleanupBlankSessions.label",{state:n})},description:()=>ke("commands.autoCleanupBlankSessions.description"),category:"System",keywords:()=>as("commands.autoCleanupBlankSessions.keywords"),action:e.toggleAutoCleanupBlankSessions}]}function TW(e,t){T4(t).forEach(s=>e(s))}var M4=F('<div class="flex-1 min-w-0">'),A4=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const rg=[{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"}],D4=()=>{const{t:e,locale:t}=kt(),{updatePreferences:n}=Tn(),s=()=>rg.find(r=>r.value===t())??rg[0];return y(Te,{get value(){return s()},onChange:r=>{!r||r.value===t()||n({locale:r.value})},options:rg,optionValue:"value",optionTextValue:"label",itemComponent:r=>y(Te.Item,{get item(){return r.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return r.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger",get"aria-label"(){return e("folderSelection.language.ariaLabel")},get title(){return e("folderSelection.language.ariaLabel")},get children(){return[y(hA,{class:"w-4 h-4 icon-muted","aria-hidden":"true"}),(()=>{var r=M4();return p(r,y(Te.Value,{children:o=>(()=>{var a=A4();return p(a,()=>{var i;return(i=o.selectedOption())==null?void 0:i.label}),a})()})),r})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover min-w-[180px]",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})};var Nw=F('<div class="flex-1 min-w-0">'),Uw=F("<div><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>"),Bw=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const vp=e=>{const{t}=kt(),[n,s]=L(new Map),r=(i,c)=>{s(l=>{const d=new Map(l);return d.set(i,c),d})};qe(()=>{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=$e(()=>{var f;return!!((f=c.disabled)!=null&&f.call(c))});if(c.kind==="toggle"){const f=$e(()=>[{value:"true",label:t("settings.common.enabled")},{value:"false",label:t("settings.common.disabled")}]),h=$e(()=>f().find(m=>m.value===String(!!o(c))));return(()=>{var m=Uw(),w=m.firstChild,S=w.firstChild,b=S.nextSibling;return p(S,()=>t(c.titleKey)),p(b,()=>t(c.subtitleKey)),p(m,y(Te,{get value(){return h()},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(Te.Item,{get item(){return v.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return v.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger",get"aria-label"(){return t(c.titleKey)},get children(){return[(()=>{var v=Nw();return p(v,y(Te.Value,{children:k=>(()=>{var $=Bw();return p($,()=>{var C;return(C=k.selectedOption())==null?void 0:C.label}),$})()})),v})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),null),de(()=>_s(m,`settings-toggle-row ${l()?"opacity-60":""}`)),m})()}const d=$e(()=>c.options.map(f=>({value:String(f.value),label:t(f.labelKey)}))),u=$e(()=>d().find(f=>f.value===String(o(c)??"")));return(()=>{var f=Uw(),h=f.firstChild,m=h.firstChild,w=m.nextSibling;return p(m,()=>t(c.titleKey)),p(w,()=>t(c.subtitleKey)),p(f,y(Te,{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(Te.Item,{get item(){return S.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return S.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger",get"aria-label"(){return t(c.titleKey)},get children(){return[(()=>{var S=Nw();return p(S,y(Te.Value,{children:b=>(()=>{var v=Bw();return p(v,()=>{var k;return(k=b.selectedOption())==null?void 0:k.label}),v})()})),S})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),null),de(()=>_s(f,`settings-toggle-row ${l()?"opacity-60":""}`)),f})()};return y(Ut,{get each(){return e.settings()},children:i=>y(a,{setting:i})})};var og=F('<button type=button class="selector-button selector-button-secondary">'),P4=F('<button type=button class="selector-button selector-button-primary">'),O4=F("<label class=theme-scheme-name-editor><span></span><input class=selector-input maxlength=80>"),R4=F("<p class=theme-scheme-warning role=alert>"),I4=F('<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>'),L4=F("<button type=button class=theme-scheme-appearance-option>"),F4=F("<option>"),N4=F("<div class=theme-scheme-swatches>"),U4=F("<label class=theme-scheme-swatch><input type=color>");const Kw=[{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"}],B4=()=>{const{t:e}=kt(),t=Tn(),n=GE(),[s,r]=L({...Bv}),[o,a]=L("dark"),[i,c]=L("dark"),l=()=>t.getAppearancePalette(i()),d=()=>t.getAppearancePresetId(i()),[u,f]=L(""),[h,m]=L(e("settings.appearance.colorScheme.option.custom")),[w,S]=L(""),[b,v]=L(!1),[k,$]=L(!1),[C,T]=L(!1),[D,R]=L(!1),[q,re]=L(),[ee,W]=L(!1),U=$e(()=>[...ZE.filter(E=>E.id!=="system"&&(E.id!=="custom"||!JE(t.customColorSchemePreference().colors)||t.customColorSchemePreference().appearance==="light"||l().id==="custom"&&!d())).map(E=>{const H=E.id==="custom"&&l().id==="custom"&&!d(),B=E.id==="light"?YE:E.colors??Bv,oe=E.id==="system"?void 0:E.id==="custom"?H?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"?(H?l():t.customColorSchemePreference()).appearance==="light"?"light":"dark":E.appearance==="light"?"light":"dark",colors:oe??B,originalColors:B}}),...Object.entries(t.colorSchemePresets()).map(([E,H])=>({key:`preset:${E}`,presetId:E,name:H.name,description:e("settings.appearance.colorScheme.description.custom"),appearance:H.appearance,colors:H.colors,originalColors:H.colors}))]),J=$e(()=>d()?`preset:${d()}`:`builtin:${l().id}`),le=$e(()=>U().filter(E=>E.id!=="system"&&E.appearance===i())),z=$e(()=>U().find(E=>E.key===u())),M=$e(()=>QE(s())),N=$e(()=>{const E=z();return E!=null&&E.id?E.id==="custom"?Kw.some(H=>E.colors[H.key]!==E.originalColors[H.key]):!!t.colorSchemeOverrides()[E.id]:!1});qe(()=>{if(!t.isLoaded()||k()||C())return;const E=U().find(H=>H.key===J());E&&(f(E.key),m(E.name),a(E.appearance),r({...E.colors}))}),qe(()=>{const E=n.isDark()?"dark":"light";!k()&&!C()&&c(E)});const ce=async()=>!k()||Wi(e("settings.configFiles.confirmDiscard.message"),{variant:"warning",confirmLabel:e("settings.configFiles.confirmDiscard.confirmLabel"),cancelLabel:e("settings.configFiles.confirmDiscard.cancelLabel"),dismissible:!1}),fe=Bk(ce);nt(fe);const Re=async E=>{if(!(C()||u()===E.key||!await ce())){T(!0),$(!1),v(!1),W(!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"?$i({id:"custom",appearance:E.appearance,colors:E.colors}):$i(E.id))}catch{W(!0)}finally{T(!1)}}},be=async(E,H,B)=>{if(C()||u()!==E.key&&!await ce())return!1;const oe=u()===E.key?s():E.colors;return f(E.key),m(E.name),a(E.appearance),r({...oe,[H]:B.toUpperCase()}),$(!0),W(!1),!0},ye=async()=>{const E=z();if(E!=null&&E.id){T(!0),W(!1);try{E.id==="custom"?await t.setColorSchemePreference($i({id:"custom",appearance:E.appearance,colors:E.originalColors})):await t.resetColorSchemeOverride(E.id),r({...E.originalColors}),a(E.appearance),$(!1)}catch{W(!0)}finally{T(!1)}}},Ce=()=>{const E=Kv(h(),Object.values(t.colorSchemePresets()).map(H=>H.name));S(E),v(!0),$(!0),W(!1)},je=async()=>{if(!k()||!M())return;const E=z();if(!E)return;const H=b()?void 0:E.presetId,B=b()?w().trim():H?E.name:Kv(h(),Object.values(t.colorSchemePresets()).map(oe=>oe.name));if(B){T(!0),W(!1);try{if(!b()&&E.id){E.id==="custom"?await t.setColorSchemePreference($i({id:"custom",appearance:E.appearance,colors:s()})):await t.saveColorSchemeOverride(E.id,E.appearance,s()),$(!1);return}const oe=await t.saveColorSchemePreset(B,o(),s(),H);f(`preset:${oe}`),m(B),v(!1),$(!1)}catch{W(!0)}finally{T(!1)}}},O=async E=>{if(!(!E.presetId||!await Wi(e("settings.appearance.colorScheme.custom.deleteConfirm",{name:E.name}),{variant:"warning",confirmLabel:e("settings.appearance.colorScheme.custom.delete"),dismissible:!1}))){T(!0),W(!1);try{await t.deleteColorSchemePreset(E.presetId);const B=U().find(oe=>oe.key===J())??U().find(oe=>oe.appearance===i());f(B.key),m(B.name),a(B.appearance),c(B.appearance),r({...B.colors}),v(!1),$(!1)}catch{W(!0)}finally{T(!1)}}},g=async E=>{if(!(C()||!await ce())){T(!0),W(!1);try{await t.setThemePreference(E),$(!1),v(!1)}catch{W(!0)}finally{T(!1)}}},x=async E=>{if(re(E),!D()){R(!0);try{for(;q();){const H=q();await Re(H),q()===H&&re(void 0)}}finally{R(!1)}}},A=E=>u()===E.key?s():E.colors;return(()=>{var E=I4(),H=E.firstChild,B=H.firstChild,oe=B.nextSibling,Ae=H.nextSibling,we=Ae.firstChild,he=we.firstChild,Ee=he.nextSibling,Ge=we.nextSibling,Xe=Ge.nextSibling,se=Xe.firstChild,V=se.nextSibling;return p(B,()=>e("settings.appearance.colorScheme.title")),p(oe,()=>e("settings.scope.device")),p(he,()=>e("settings.appearance.palette.mode")),p(Ee,y(Ut,{each:["system","dark","light"],children:Y=>(()=>{var Oe=L4();return Oe.$$click=()=>void g(Y),p(Oe,()=>e(Y==="system"?"settings.appearance.palette.auto":`settings.appearance.colorScheme.custom.appearance.${Y}`)),de(ve=>{var Ie=C(),Le=t.themePreference()===Y?"true":"false",ze=t.themePreference()===Y;return Ie!==ve.e&&(Oe.disabled=ve.e=Ie),Le!==ve.t&&pe(Oe,"data-selected",ve.t=Le),ze!==ve.a&&pe(Oe,"aria-pressed",ve.a=ze),ve},{e:void 0,t:void 0,a:void 0}),Oe})()})),p(Ge,()=>e("settings.appearance.palette.independent")),se.addEventListener("change",Y=>{const Oe=Y.currentTarget,ve=U().find(Ie=>Ie.key===Oe.value);ve&&x(ve)}),p(se,y(Ut,{get each(){return le()},children:Y=>(()=>{var Oe=F4();return p(Oe,()=>Y.name),de(()=>{var ve;return Oe.selected=(((ve=q())==null?void 0:ve.key)??u())===Y.key}),de(()=>Oe.value=Y.key),Oe})()})),p(Xe,y(Q,{get when(){return z()},keyed:!0,children:Y=>(()=>{var Oe=N4();return p(Oe,y(Ut,{each:Kw,children:ve=>{const Ie=()=>A(Y)[ve.key],Le=()=>e(ve.labelKey);return(()=>{var ze=U4(),Ne=ze.firstChild;return Ne.$$input=Je=>{const ot=Je.currentTarget;be(Y,ve.key,ot.value).then(gt=>{gt||(ot.value=Ie())})},de(Je=>{var ot=Le(),gt=C(),_=`${Y.name} · ${Le()} · ${Ie()}`;return ot!==Je.e&&pe(ze,"title",Je.e=ot),gt!==Je.t&&(Ne.disabled=Je.t=gt),_!==Je.a&&pe(Ne,"aria-label",Je.a=_),Je},{e:void 0,t:void 0,a:void 0}),de(()=>Ne.value=Ie()),ze})()}})),Oe})()}),V),p(V,y(Q,{get when(){var Y;return(Y=z())==null?void 0:Y.presetId},get children(){var Y=og();return Y.$$click=()=>void O(z()),p(Y,()=>e("settings.appearance.colorScheme.custom.delete")),de(()=>Y.disabled=b()||C()),Y}}),null),p(V,y(Q,{get when(){return N()},get children(){var Y=og();return Y.$$click=()=>void ye(),p(Y,()=>e("settings.appearance.colorScheme.custom.reset")),de(()=>Y.disabled=b()||C()),Y}}),null),p(V,y(Q,{get when(){return!b()},get children(){var Y=og();return Y.$$click=Ce,p(Y,()=>e("settings.appearance.colorScheme.custom.new")),de(()=>Y.disabled=C()),Y}}),null),p(V,y(Q,{get when(){return k()},get children(){var Y=P4();return Y.$$click=()=>void je(),p(Y,()=>e("settings.appearance.colorScheme.custom.save")),de(()=>Y.disabled=!M()||C()||b()&&!w().trim()),Y}}),null),p(Ae,y(Q,{get when(){return b()},get children(){var Y=O4(),Oe=Y.firstChild,ve=Oe.nextSibling;return p(Oe,()=>e("settings.appearance.colorScheme.custom.name")),ve.$$input=Ie=>S(Ie.currentTarget.value),de(()=>ve.value=w()),Y}}),null),p(Ae,y(Q,{get when(){return ee()},get children(){var Y=R4();return p(Y,()=>e("settings.appearance.colorScheme.custom.saveError")),Y}}),null),de(Y=>{var Oe=e("settings.appearance.palette.mode"),ve=C()&&!D(),Ie=D(),Le=e("settings.appearance.colorScheme.title");return Oe!==Y.e&&pe(Ee,"aria-label",Y.e=Oe),ve!==Y.t&&(se.disabled=Y.t=ve),Ie!==Y.a&&pe(se,"aria-busy",Y.a=Ie),Le!==Y.o&&pe(se,"aria-label",Y.o=Le),Y},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>{var Y,Oe;return se.value=((Y=q())==null?void 0:Y.key)??((Oe=z())==null?void 0:Oe.key)??""}),E})()};Ht(["click","input"]);var K4=F("<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 V4=gS(()=>ts(()=>import("./startup-state-settings-card-X1QA2uNM.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.StartupStateSettingsCard}))),Vw=e=>{const{t}=kt(),n=Tn(),s=$e(()=>yp(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=K4(),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(D4,{}),null),p(r,y(B4,{}),u),p(r,y(Q,{get when(){return e.showStartupState!==!1},get children(){return y(V4,{})}}),u),p(f,y(vp,{settings:s,get preferences(){return n.preferences}})),r})()},sl="other",Dd={minimal:"collapsed",balanced:"collapsed",detailed:"expanded",everything:"expanded"},ct="expanded",Mt="collapsed";const Nu=[{tool:"bash",label:"shell",aliases:["shell"],configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"read",label:"read",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:Mt,everything:ct}},{tool:"write",label:"write",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"edit",label:"edit",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"patch",label:"patch",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"apply_patch",label:"apply_patch",configurable:!1,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"webfetch",label:"webfetch",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}},{tool:"websearch",label:"websearch",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}},{tool:"glob",label:"glob",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}},{tool:"grep",label:"grep",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}},{tool:"todowrite",label:"todowrite",configurable:!1,expansionPresets:{minimal:ct,balanced:ct,detailed:ct,everything:ct}},{tool:"task",label:"subagent",aliases:["subagent"],configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"execute",label:"execute",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"skill",label:"skill",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:Mt,everything:ct}},{tool:"question",label:"question",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"invalid",label:"invalid",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:Mt,everything:ct}},{tool:sl,label:"Other tools",labelKey:"settings.behavior.expansionDefaults.otherTools",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}}],jk=Nu.find(e=>e.tool===sl),j4=Nu.reduce((e,t)=>{var n;return e[t.tool]=t,(n=t.aliases)==null||n.forEach(s=>{e[s]=t}),e},{});function qk(e){return j4[e]??jk}function MW(e){return qk(e).tool}function q4(){return Nu}function zk(){return Nu.filter(e=>e.configurable)}function z4(e){const t={};for(const n of zk())t[n.tool]=n.expansionPresets[e];return t}function wp(e,t){const n=qk(t),s=e.toolCallExpansionDefaults,r=s.preset==="custom"?void 0:n.expansionPresets[s.preset],o=s.preset==="custom"?void 0:jk.expansionPresets[s.preset];return s.tools[n.tool]??r??s.tools[sl]??o??e.toolOutputExpansion??"expanded"}function AW(e,t){return wp(e,t)==="expanded"}function DW(e){const t=e.toolCallExpansionDefaults;return(t.thinking??(t.preset==="custom"?void 0:Dd[t.preset])??e.thinkingBlocksExpansion??"expanded")==="expanded"}const jw={thinking:P2,diagnostics:ZA,inputs:bA,usage:q2,system:Xm,bash:ep,read:A2,write:Z2,edit:IA,patch:OA,apply_patch:dd,webfetch:Bo,glob:pw,grep:pw,todowrite:B2,task:R2,execute:V2,websearch:Bo,skill:iA,question:cA,invalid:Ko,other:pA},W4={"apply-patch":"apply_patch",shell:"bash",subagent:"task",terminal:"bash",todo:"todowrite",todo_write:"todowrite",web_fetch:"webfetch"};function H4(e){const t=(e==null?void 0:e.trim().toLowerCase().replace(/^opencode_/,""))??"",n=W4[t]??t;return jw[n]??jw.other}function G4(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")},...zk().map(t=>({kind:"tool",key:t.tool,label:t.labelKey?e(t.labelKey):t.label}))]}function Wk(e){const t=e.toolCallExpansionDefaults;return t.thinking??(t.preset==="custom"?void 0:Dd[t.preset])??e.thinkingBlocksExpansion??"expanded"}function qw(e,t){switch(t.kind){case"thinking":return e.showThinkingBlocks?Wk(e):"hidden";case"tool":return wp(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 Z4(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(q4().map(o=>[o.tool,wp(e,o.tool)]));t.kind==="tool"&&(s[t.key]=n);const r=t.kind==="thinking"&&n!=="hidden"?n:Wk(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===sl&&n!=="hidden"?n:e.toolOutputExpansion}}var J4=F("<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>"),Y4=F("<button type=button class=settings-expansion-preset><span class=settings-expansion-preset-title></span><span class=settings-expansion-preset-copy>"),Q4=F('<div class="flex-1 min-w-0">'),X4=F('<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>'),eO=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const tO=["minimal","balanced","detailed","everything"],zw={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"}},nO=()=>{const{t:e}=kt(),{preferences:t,updatePreferences:n}=Tn(),s=$e(()=>[{value:"hidden",label:e("commands.common.hidden")},{value:"collapsed",label:e("commands.common.collapsed")},{value:"expanded",label:e("commands.common.expanded")}]),r=$e(()=>G4(e)),o=()=>qw(t(),{kind:"thinking",key:"thinking"}),a=$e(()=>{const f=t(),h=f.toolCallExpansionDefaults.preset;if(h==="custom")return h;const m=zw[h],w=m.showThinkingBlocks?Dd[h]:"hidden";return o()===w&&f.diagnosticsExpansion===m.diagnosticsExpansion&&f.systemMessagesVisibility===m.systemMessagesVisibility&&f.toolInputsVisibility===m.toolInputsVisibility&&f.showUsageMetrics===m.showUsageMetrics&&f.usageMetricsExpansion===m.usageMetricsExpansion?h:"custom"}),i=f=>{const h=z4(f),m=Dd[f];n({...zw[f],toolCallExpansionDefaults:{preset:f,thinking:m,tools:h},thinkingBlocksExpansion:m,toolOutputExpansion:h[sl]==="expanded"?"expanded":"collapsed"})},c=(f,h)=>{n(Z4(t(),f,h))},l=f=>qw(t(),f),d=f=>s().find(h=>h.value===f),u=f=>e(`settings.behavior.expansionPreset.${f}.title`);return(()=>{var f=J4(),h=f.firstChild,m=h.firstChild,w=m.firstChild,S=w.firstChild,b=S.nextSibling,v=w.nextSibling,k=m.nextSibling,$=k.nextSibling,C=$.firstChild,T=C.firstChild,D=T.nextSibling;return p(S,()=>e("settings.behavior.expansionPresets.ariaLabel")),p(b,()=>e("settings.appearance.behavior.subtitle")),p(v,()=>u(a())),p(k,y(Ut,{each:tO,children:R=>(()=>{var q=Y4(),re=q.firstChild,ee=re.nextSibling;return q.$$click=()=>i(R),p(re,()=>u(R)),p(ee,()=>e(`settings.behavior.expansionPreset.${R}.description`)),de(()=>pe(q,"data-selected",a()===R?"true":"false")),q})()})),p(T,()=>e("settings.behavior.expansionDefaults.itemColumn")),p(D,()=>e("settings.behavior.expansionDefaults.stateColumn")),p($,y(Ut,{get each(){return r()},children:R=>{const q=$e(()=>d(l(R)));return(()=>{var re=X4(),ee=re.firstChild,W=ee.firstChild,U=ee.nextSibling;return p(ee,y(Bm,{get component(){return H4(R.key)},class:"w-4 h-4 shrink-0 text-secondary","aria-hidden":"true"}),W),p(W,()=>R.label),p(U,y(Te,{get value(){return q()},onChange:J=>J&&c(R,J.value),get options(){return s()},optionValue:"value",optionTextValue:"label",itemComponent:J=>y(Te.Item,{get item(){return J.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return J.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger settings-expansion-select",get"aria-label"(){return e("settings.behavior.expansionDefaults.rowAriaLabel",{item:R.label})},get children(){return[(()=>{var J=Q4();return p(J,y(Te.Value,{children:le=>(()=>{var z=eO();return p(z,()=>{var M;return(M=le.selectedOption())==null?void 0:M.label}),z})()})),J})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})),re})()}}),null),de(R=>{var q=e("settings.behavior.expansionPresets.ariaLabel"),re=e("settings.behavior.expansionDefaults.title");return q!==R.e&&pe(k,"aria-label",R.e=q),re!==R.t&&pe($,"aria-label",R.t=re),R},{e:void 0,t:void 0}),f})()};Ht(["click"]);const jr=Lt("actions");async function sO(e){try{if(typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),jr.info("Copied text using Clipboard API"),!0}catch(s){jr.warn("Clipboard API failed, trying fallback:",s)}let t;const n=typeof document<"u"?document.activeElement:null;try{return typeof document>"u"?(jr.error("Document not available for clipboard fallback"),!1):(t=document.createElement("textarea"),t.value=e,t.readOnly=!0,t.style.position="fixed",t.style.left="-9999px",t.style.top="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy")?(jr.info("Copied text using execCommand fallback"),!0):(jr.error("execCommand copy failed"),!1))}catch(s){return jr.error("Clipboard fallback failed:",s),!1}finally{try{t==null||t.remove()}catch(s){jr.warn("Failed to remove clipboard fallback element:",s)}try{n==null||n.focus()}catch(s){jr.warn("Failed to restore focus after clipboard fallback:",s)}}}let ig=null,qa=null;async function Ww(e=!1){if(ig&&!e)return ig;if(qa)return qa;const t=ft.fetchServerMeta().then(n=>(ig=n,n));qa=t;try{return await t}finally{qa===t&&(qa=null)}}function yh(e){return Hk(e.host)?"all":e.listeningMode==="all"?"specific":e.listeningMode}function vh(e){if(Hk(e.host))return e.addresses;const t=wh(e.host);return e.addresses.filter(n=>wh(n.ip)===t)}function Hk(e){const t=wh(e);return t==="0.0.0.0"?!0:t.includes(":")&&t.split(":").every(n=>n===""||/^0+$/.test(n))}function wh(e){const t=e.trim().toLowerCase();return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}function Hw(e,t,n,s,r=new Date){var c,l;const o=e?vh(e):[],a=e?s.modes[yh(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 rO=F("<div class=settings-card-message role=status aria-live=polite>"),Gw=F("<div class=settings-error-message role=alert>"),oO=F('<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>'),iO=F('<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>'),aO=F("<h4 class=settings-card-title>"),cO=F("<dl class=settings-info-grid>"),lO=F("<p class=settings-help-text>"),dO=F("<div class=settings-info-actions><button type=button class=settings-pill-button>"),uO=F('<div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),fO=F("<div class=settings-card-message>"),gO=F('<div class=settings-info-row><dt class=settings-info-label> · </dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),hO=F('<a target=_blank rel="noopener noreferrer"class=settings-pill-button>'),mO=F("<div class=settings-info-toast role=status aria-live=polite>");function Gk(){return navigator.userAgentData}function pO(){if(typeof navigator>"u")return"Unknown";const e=Gk();if(e!=null&&e.platform){const r=Zw(navigator.userAgent);return r?`${e.platform} ${r}`:e.platform}const t=navigator.userAgent,n=navigator.platform;if(!n)return"Unknown";const s=Zw(t);return s&&!n.includes(s)?`${n} ${s}`:n}function Zw(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 yO(){try{const e=Gk();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 vO(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 Jw(e){return e.replace(/^v/,"").split("-")[0]}function wO(e,t){const n=Jw(e).split(".").map(Number),s=Jw(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 bO=()=>{const{t:e}=kt(),[t,n]=L(!1),[s,{mutate:r}]=hS(async()=>{n(!1);try{return await Ww()}catch{return n(!0),null}}),[o,a]=L(null),[i,c]=L(null);qe(()=>{yO().then(k=>{k&&c(k)})});const l=$e(()=>{const k=s();return k!=null&&k.update?k.update:null}),d=$e(()=>{var k;return((k=s())==null?void 0:k.support)??null}),u=$e(()=>({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=$e(()=>{var $;const k=l();return k!=null&&k.version?k.version:(($=d())==null?void 0:$.latestServerVersion)??null}),h=$e(()=>{var D,R;let k=null;const $=l();if($!=null&&$.url?k=$.url:(D=d())!=null&&D.latestServerUrl&&(k=d().latestServerUrl??null),!k)return{url:null,show:!1};if($!=null&&$.url)return{url:k,show:!0};const C=(R=s())==null?void 0:R.serverVersion,T=f();return!C||!T?{url:null,show:!1}:{url:k,show:wO(C,T)!==!1}});let m;qe(()=>{o()&&(clearTimeout(m),m=setTimeout(()=>a(null),2500))}),nt(()=>clearTimeout(m));const w=async()=>{n(!1);try{const k=await Ww(!0);r(k)}catch{n(!0)}},S=$e(()=>{const k=pO(),$=i();return $?`${k} (${$})`:k}),b=async()=>{const k=Hw(s()??null,S(),mn,u()),$=await sO(k);a($?"success":"error")},v=()=>{const k=Hw(s()??null,S(),mn,u()),$=new Date().toISOString().replace(/[:.]/g,"-");vO(`codenomad-diagnostics-${$}.txt`,k)};return(()=>{var k=oO(),$=k.firstChild,C=$.firstChild,T=C.firstChild,D=T.firstChild,R=D.firstChild,q=R.nextSibling,re=C.nextSibling,ee=re.firstChild,W=ee.firstChild,U=W.nextSibling,J=ee.nextSibling,le=J.firstChild,z=le.nextSibling,M=J.nextSibling,N=M.firstChild,ce=N.nextSibling,fe=M.nextSibling,Re=fe.firstChild,be=Re.nextSibling,ye=fe.nextSibling,Ce=ye.firstChild,je=Ce.nextSibling,O=$.nextSibling,g=O.firstChild,x=g.firstChild,A=x.firstChild,E=A.firstChild,H=E.nextSibling,B=O.nextSibling,oe=B.firstChild,Ae=oe.firstChild,we=Ae.firstChild,he=we.nextSibling,Ee=oe.nextSibling,Ge=Ee.firstChild,Xe=Ge.firstChild,se=Xe.nextSibling,V=Ge.nextSibling,Y=V.firstChild,Oe=Y.nextSibling,ve=Ee.nextSibling,Ie=ve.firstChild,Le=B.nextSibling,ze=Le.firstChild,Ne=ze.firstChild,Je=Ne.firstChild,ot=Je.nextSibling,gt=ze.nextSibling,_=gt.nextSibling,P=_.firstChild,j=P.nextSibling;return p(T,y(Xm,{class:"settings-card-heading-icon"}),D),p(R,()=>e("settings.section.info.title")),p(q,()=>e("settings.section.info.subtitle")),p(W,()=>e("settings.info.version.ui")),p(U,()=>{var K,I;return((I=(K=s())==null?void 0:K.ui)==null?void 0:I.version)??"—"}),p(le,()=>e("settings.info.version.uiSource")),p(z,()=>{var K,I;return((I=(K=s())==null?void 0:K.ui)==null?void 0:I.source)??"—"}),p(N,()=>e("settings.info.runtime.type")),p(ce,()=>mn.host),p(Re,()=>e("settings.info.runtime.platform")),p(be,()=>mn.platform),p(Ce,()=>e("settings.info.runtime.os")),p(je,S),p(x,y(DA,{class:"settings-card-heading-icon"}),A),p(E,()=>e("settings.info.connectivity.title")),p(H,()=>e("settings.info.connectivity.subtitle")),p(O,y(Q,{get when(){return s.loading},get children(){var K=rO();return p(K,()=>e("remoteAccess.addresses.loading")),K}}),null),p(O,y(Q,{get when(){return t()},get children(){var K=Gw();return p(K,()=>e("settings.info.connectivity.loadFailed")),K}}),null),p(O,y(Q,{get when(){return s()},children:K=>[(()=>{var I=iO(),Z=I.firstChild,xe=Z.firstChild,De=xe.nextSibling,Qe=Z.nextSibling,et=Qe.firstChild,Tt=et.nextSibling,He=Qe.nextSibling,yt=He.firstChild,Qt=yt.nextSibling,Ot=He.nextSibling,Dn=Ot.firstChild,Wn=Dn.nextSibling,Hn=Ot.nextSibling,Gn=Hn.firstChild,dr=Gn.nextSibling;return p(xe,()=>e("settings.info.version.server")),p(De,()=>K().serverVersion??"—"),p(et,()=>e("remoteAccess.sections.listeningMode.label")),p(Tt,()=>e(yh(K())==="specific"?"settings.info.connectivity.mode.specific":yh(K())==="all"?"settings.info.connectivity.mode.all":"settings.info.connectivity.mode.local")),p(yt,()=>e("settings.info.connectivity.host")),p(Qt,()=>K().host),p(Dn,()=>e("settings.info.connectivity.localListener")),p(Wn,()=>K().localUrl),p(I,y(Q,{get when(){return K().remoteUrl},children:mi=>(()=>{var ur=uO(),js=ur.firstChild,pi=js.nextSibling;return p(js,()=>e("settings.info.connectivity.remoteListener")),p(pi,mi),ur})()}),Hn),p(Gn,()=>e("settings.info.server.root")),p(dr,()=>K().workspaceRoot),I})(),(()=>{var I=aO();return p(I,()=>e("remoteAccess.sections.addresses.label")),I})(),y(Q,{get when(){return vh(K()).length>0},get fallback(){return(()=>{var I=fO();return p(I,()=>e("remoteAccess.addresses.none")),I})()},get children(){var I=cO();return p(I,y(Ut,{get each(){return vh(K())},children:Z=>(()=>{var xe=gO(),De=xe.firstChild,Qe=De.firstChild,et=De.nextSibling;return p(De,()=>Z.family.toUpperCase(),Qe),p(De,()=>e(Z.scope==="external"?"remoteAccess.address.scope.network":Z.scope==="internal"?"remoteAccess.address.scope.internal":"remoteAccess.address.scope.loopback"),null),p(et,()=>Z.remoteUrl),xe})()})),I}}),(()=>{var I=lO();return p(I,()=>e("settings.info.connectivity.disclaimer")),I})(),y(Q,{get when(){return qi()},get children(){var I=dO(),Z=I.firstChild;return Z.$$click=()=>Vk("remote"),p(Z,()=>e("settings.nav.remote")),I}})]}),null),p(we,()=>e("settings.info.updates.title")),p(he,()=>e("settings.info.updates.subtitle")),p(Xe,()=>e("settings.info.version.server")),p(se,()=>{var K;return((K=s())==null?void 0:K.serverVersion)??"—"}),p(Y,()=>e("settings.info.updates.latest")),p(Oe,()=>f()??"—"),p(ve,(()=>{var K=_e(()=>!!h().show);return()=>K()&&(()=>{var I=hO();return p(I,()=>e("settings.info.updates.download")),de(()=>pe(I,"href",h().url)),I})()})(),Ie),Ie.$$click=w,p(Ie,()=>e("settings.info.updates.refresh")),p(Je,()=>e("settings.info.diagnostics.title")),p(ot,()=>e("settings.info.diagnostics.subtitle")),p(gt,()=>e("settings.info.diagnostics.privacy")),P.$$click=b,p(P,()=>e("settings.info.diagnostics.copy")),j.$$click=v,p(j,()=>e("settings.info.diagnostics.download")),p(Le,(()=>{var K=_e(()=>o()==="success");return()=>K()&&(()=>{var I=mO();return p(I,()=>e("settings.info.diagnostics.copied")),I})()})(),null),p(Le,(()=>{var K=_e(()=>o()==="error");return()=>K()&&(()=>{var I=Gw();return p(I,()=>e("settings.info.diagnostics.copyFailed")),I})()})(),null),de(()=>Ie.disabled=s.loading),k})()};Ht(["click"]);var SO=F('<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>'),kO=F("<p>"),xO=F('<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 Yw=50;let gs=[];const bh=new Set,[$O,_O]=L(0);function PW(){return $O}function rl(){_O(gs.filter(e=>!e.read).length)}function ol(){const e=[...gs];bh.forEach(t=>{try{t(e)}catch(n){console.error("[notifications] subscriber error:",n)}})}function CO(){return`toast_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function EO(){gs.length>Yw&&(gs=gs.slice(0,Yw))}function TO(e){const t={...e,id:CO(),createdAt:Date.now(),read:!1};return gs.unshift(t),EO(),rl(),ol(),t.id}function OW(){gs=[],rl(),ol()}function RW(e){const t=gs.find(n=>n.id===e);t&&!t.read&&(t.read=!0,rl(),ol())}function IW(){let e=!1;gs.forEach(t=>{t.read||(t.read=!0,e=!0)}),e&&(rl(),ol())}function LW(e){const t=gs.findIndex(n=>n.id===e);t!==-1&&(gs.splice(t,1),rl(),ol())}function FW(e){return bh.add(e),e([...gs]),()=>{bh.delete(e)}}async function Qw(e){if(!(typeof window>"u")){try{if(bn()){const{openUrl:t}=await ts(async()=>{const{openUrl:n}=await import("./index-CHztP7Qx.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),Rn.error(ke("toastHistory.openLinkError"))}}}async function MO(e){if(!e.onClick){await Qw(e.href);return}try{await e.onClick()}catch(t){console.warn("[notifications] action failed; opening fallback link",t),await Qw(e.href)}}const AO={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 Fn(e){const t=AO[e.variant],n=e.duration??1e4;TO({title:e.title,message:e.message,variant:e.variant,action:e.action});const s=Rn.custom(()=>(()=>{var r=SO(),o=r.firstChild,a=o.nextSibling,i=a.firstChild,c=i.nextSibling,l=c.firstChild;return o.$$click=()=>Rn.dismiss(s),p(c,(()=>{var d=_e(()=>!!e.title);return()=>d()&&(()=>{var u=kO();return p(u,()=>e.title),de(()=>_s(u,`break-words ${t.headline} font-semibold`)),u})()})(),l),p(l,()=>e.message),p(c,(()=>{var d=_e(()=>!!e.action);return()=>d()&&(()=>{var u=xO();return u.$$click=()=>void MO(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=ke("toastHistory.close"),h=ke("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&&_s(r,d.e=u),f!==d.t&&pe(o,"aria-label",d.t=f),h!==d.a&&pe(o,"title",d.a=h),m!==d.o&&_s(i,d.o=m),w!==d.i&&_s(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:()=>Rn.dismiss(s)}}Ht(["click"]);const Uu=Lt("actions");function Bu(){return typeof window<"u"&&typeof window.Notification<"u"}function bp(){if(!Bu())return"unsupported";const e=window.Notification.permission;return e==="granted"?"granted":e==="denied"?"denied":"default"}async function DO(){if(!Bu())return"unsupported";try{const e=await window.Notification.requestPermission();return e==="granted"?"granted":e==="denied"?"denied":"default"}catch(e){return Uu.warn("[os-notifications] requestPermission failed",e),bp()}}async function PO(e){if(!Bu())throw new Error("Web notifications not supported");if(bp()!=="granted")throw new Error("Web notification permission not granted");new window.Notification(e.title,{body:e.body})}function Sp(){if(typeof window>"u")return!1;const e=window.electronAPI;return!!(e&&typeof e.showNotification=="function")}function NW(){return typeof window>"u"?!1:En()?Sp():bn()?!0:Bu()}async function OO(e){const t=window.electronAPI;if(!t||typeof t.showNotification!="function")throw new Error("Electron notification bridge unavailable");await t.showNotification(e)}async function kp(){try{return await ts(()=>import("./index-CXyTJ12Z.js"),__vite__mapDeps([10,6,2,3,4,5,1,7]))}catch(e){return Uu.info("[os-notifications] tauri notification plugin not available",e),null}}async function Zk(){const e=await kp();if(!e)return"unsupported";try{return await e.isPermissionGranted()?"granted":"default"}catch(t){return Uu.warn("[os-notifications] failed to check tauri notification permission",t),"default"}}async function RO(){const e=await kp();if(!e)return"unsupported";try{const t=await e.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"default"}catch(t){return Uu.warn("[os-notifications] failed to request tauri notification permission",t),await Zk()}}async function IO(e){const t=await kp();if(!t)throw new Error("Tauri notification plugin unavailable");await t.sendNotification({title:e.title,body:e.body})}async function LO(){if(typeof window>"u")return{supported:!1,permission:"unsupported",info:"Not available in this environment."};if(En())return Sp()?{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(bn()){const n=await Zk(),s=n!=="unsupported";return{supported:s,permission:n,info:s?void 0:"Tauri notification support is not available in this build."}}const e=bp(),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 Xw(){return typeof window>"u"?"unsupported":En()?Sp()?"granted":"unsupported":bn()?await RO():await DO()}async function FO(e){if(!(typeof window>"u")){if(En()){await OO(e);return}if(bn()){await IO(e);return}await PO(e)}}var NO=F('<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">'),eb=F("<div class=settings-inline-note>"),UO=F("<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 BO(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 KO=()=>{const{t:e}=kt(),{preferences:t,updatePreferences:n}=Tn(),[s,{refetch:r}]=hS(()=>LO());qe(()=>{r()});const o=async d=>{if(!d){n({osNotificationsEnabled:!1});return}const u=s();if(u&&!u.supported){Fn({title:e("settings.section.notifications.title"),message:u.info??e("settings.notifications.messages.unsupportedEnvironment"),variant:"warning"}),n({osNotificationsEnabled:!1});return}const f=await Xw();if(f!=="granted"){Fn({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){Fn({title:e("settings.section.notifications.title"),message:d.info??e("settings.notifications.messages.unsupportedGeneral"),variant:"warning"});return}const u=await Xw();if(u==="granted"){Fn({title:e("settings.section.notifications.title"),message:e("settings.notifications.messages.permissionGranted"),variant:"success",duration:6e3}),r();return}Fn({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 BO(((d=s())==null?void 0:d.permission)??"unsupported",e)},l=()=>{var d;return(d=s())==null?void 0:d.info};return(()=>{var d=UO(),u=d.firstChild,f=u.firstChild,h=f.firstChild,m=h.firstChild,w=m.firstChild,S=w.nextSibling,b=h.nextSibling,v=f.nextSibling,k=v.firstChild,$=k.firstChild,C=$.firstChild,T=C.nextSibling,D=$.nextSibling,R=D.firstChild,q=R.nextSibling,re=k.nextSibling,ee=re.firstChild,W=ee.firstChild,U=W.nextSibling,J=ee.nextSibling,le=J.firstChild,z=le.nextSibling,M=u.nextSibling,N=M.firstChild,ce=N.firstChild,fe=ce.firstChild,Re=fe.nextSibling,be=ce.nextSibling,ye=N.nextSibling,Ce=ye.firstChild,je=Ce.firstChild,O=je.firstChild,g=je.nextSibling,x=g.firstChild,A=x.nextSibling,E=Ce.nextSibling,H=E.firstChild,B=H.firstChild,oe=H.nextSibling,Ae=oe.firstChild,we=Ae.nextSibling;return p(h,y(GS,{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(C,()=>e("settings.notifications.enable.title")),p(T,()=>e("settings.notifications.enable.permission",{permission:c()})),R.addEventListener("change",he=>void o(he.currentTarget.checked)),p(q,()=>e("settings.common.enabled")),p(v,y(Q,{get when(){var he;return _e(()=>!!i())()&&(((he=s())==null?void 0:he.permission)??"unsupported")!=="granted"},get children(){var he=NO(),Ee=he.firstChild,Ge=Ee.firstChild,Xe=Ge.nextSibling,se=Ee.nextSibling;return p(Ge,()=>e("settings.notifications.requestPermission.title")),p(Xe,()=>e("settings.notifications.requestPermission.subtitle")),se.$$click=()=>void a(),p(se,()=>e("settings.notifications.requestPermission.action")),he}}),re),p(W,()=>e("settings.notifications.allowVisible.title")),p(U,()=>e("settings.notifications.allowVisible.subtitle")),le.addEventListener("change",he=>n({osNotificationsAllowWhenVisible:he.currentTarget.checked})),p(z,()=>e("settings.common.enabled")),p(v,y(Q,{get when(){return!!l()},get children(){var he=eb();return p(he,l),he}}),null),p(v,y(Q,{get when(){return _e(()=>!i())()&&s.state==="ready"},get children(){var he=eb();return p(he,()=>e("settings.notifications.unsupportedNote")),he}}),null),p(fe,()=>e("settings.notifications.events.title")),p(Re,()=>e("settings.notifications.events.subtitle")),p(be,()=>e("settings.scope.device")),p(O,()=>e("settings.notifications.events.needsInput")),x.addEventListener("change",he=>n({notifyOnNeedsInput:he.currentTarget.checked})),p(A,()=>e("settings.common.enabled")),p(B,()=>e("settings.notifications.events.idle")),Ae.addEventListener("change",he=>n({notifyOnIdle:he.currentTarget.checked})),p(we,()=>e("settings.common.enabled")),de(he=>{var Ee=!i()&&s.state==="ready",Ge=!t().osNotificationsEnabled,Xe=!t().osNotificationsEnabled,se=!t().osNotificationsEnabled;return Ee!==he.e&&(R.disabled=he.e=Ee),Ge!==he.t&&(le.disabled=he.t=Ge),Xe!==he.a&&(x.disabled=he.a=Xe),se!==he.o&&(Ae.disabled=he.o=se),he},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>R.checked=!!t().osNotificationsEnabled),de(()=>le.checked=!!t().osNotificationsAllowWhenVisible),de(()=>x.checked=!!t().notifyOnNeedsInput),de(()=>Ae.checked=!!t().notifyOnIdle),d})()};Ht(["click"]);function tb(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 Jk(e){return e==="wav"?"audio/wav":e==="opus"?VO(e):e==="aac"?"audio/aac":"audio/mpeg"}function Yk(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 VO(e){const t=Yk(e);return typeof MediaSource>"u"?t[0]:t.find(n=>MediaSource.isTypeSupported(n))??t[0]}function Tc(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"||!Yk(e.ttsFormat).some(n=>MediaSource.isTypeSupported(n))?{available:!1,reason:"browser-streaming-unavailable"}:{available:!0}:{available:!1,reason:"provider-streaming-unavailable"}}const Sh=new Map;let gn=null;function jO(e){var t;(t=Sh.get(e))==null||t()}function kh(e){if(!gn||e&&gn.ownerId!==e)return;const t=gn;gn=null,t.stop()}function nb(e,t){if((gn==null?void 0:gn.ownerId)===e){gn={ownerId:e,stop:t};return}kh(),gn={ownerId:e,stop:t}}function qO(e){const{t}=kt(),{serverSettings:n}=Tn(),[s,r]=L("idle");let o=0,a=null,i=null,c=null;qe(()=>{kc()});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")};Sh.set(e.id(),d),nt(()=>{Sh.delete(e.id()),kh(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))??{}}},h=()=>{const k=Jr();return!u()||!(k!=null&&k.available)||!(k!=null&&k.ttsConfigured)||!(k!=null&&k.supportsTts)?!1:Tc({playbackMode:f().playbackMode,ttsFormat:f().ttsFormat,capabilities:k}).available},m=()=>{(gn==null?void 0:gn.ownerId)===e.id()&&(gn=null),d()},w=async()=>{const k=e.id(),$=e.text().trim();if(!$||s()==="loading"||s()==="playing")return;if(!u()){Cs(t("messageItem.actions.speak.error.unsupported"),{title:t("messageItem.actions.speak.error.title"),variant:"error"});return}const C=await kc()??Jr();if(!(C!=null&&C.available)||!(C!=null&&C.ttsConfigured)||!(C!=null&&C.supportsTts)){Cs(t("messageItem.actions.speak.error.unavailable"),{title:t("messageItem.actions.speak.error.title"),variant:"error"});return}const T=Tc({playbackMode:f().playbackMode,ttsFormat:f().ttsFormat,capabilities:C});if(!T.available){const re=T.reason==="provider-streaming-unavailable"?"settings.speech.compatibility.streamingUnavailable":T.reason==="browser-streaming-unavailable"?"settings.speech.compatibility.browserStreamingUnavailable":"messageItem.actions.speak.error.unsupported";Cs(t("messageItem.actions.speak.error.unavailable"),{title:t("messageItem.actions.speak.error.title"),detail:t(re),variant:"error"});return}o+=1;const D=o;kh(),l(),r("loading");const R=f(),q=R.ttsFormat;try{R.playbackMode==="streaming"?await b(k,D,$,q):await S(k,D,$,q)}catch(re){if(D!==o)return;d(),Cs(t("messageItem.actions.speak.error.generate"),{title:t("messageItem.actions.speak.error.title"),detail:re instanceof Error?re.message:String(re),variant:"error"})}};async function S(k,$,C,T){const D=await ft.synthesizeSpeech({text:C,format:T});if($!==o)return;const R=GO(D.audioBase64,D.mimeType),q=new Audio(R);i=R,a=q,sb(k,q),nb(k,()=>{l(),r("idle")}),r("playing"),await q.play()}async function b(k,$,C,T){if(typeof MediaSource>"u")throw new Error("MediaSource is not available in this browser.");const D=new AbortController;c=D;const R=await ft.synthesizeSpeechStream({text:C,format:T},D.signal),q=R.headers.get("content-type")||Jk(T);if(!MediaSource.isTypeSupported(q))throw new Error(`Streaming playback is not supported for ${q}.`);const re=R.body;if(!re)throw new Error("Speech stream did not include a response body.");const ee=new MediaSource,W=URL.createObjectURL(ee),U=new Audio(W);i=W,a=U,sb(k,U),nb(k,()=>{l(),r("idle")}),await new Promise((J,le)=>{const z=()=>{ee.removeEventListener("sourceopen",z),zO({mediaSource:ee,stream:re,mimeType:q,audioElement:U,onPlayable:async()=>{if($===o){s()!=="playing"&&r("playing");try{await U.play()}catch(M){le(M)}}},onComplete:J,onError:le})};ee.addEventListener("sourceopen",z,{once:!0}),U.addEventListener("error",()=>le(new Error("Unable to play streamed speech.")),{once:!0})})}return{state:s,canUseSpeech:h,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 sb(e,t){const n=()=>{(gn==null?void 0:gn.ownerId)===e&&(gn=null),jO(e)};t.addEventListener("ended",n,{once:!0}),t.addEventListener("error",n,{once:!0})}async function zO(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 WO(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 HO(t);e.mediaSource.readyState==="open"&&e.mediaSource.endOfStream(),e.onComplete()}catch(t){e.onError(t)}}function WO(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 HO(e){return new Promise(t=>{e.addEventListener("updateend",()=>t(),{once:!0})})}function GO(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 ZO(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 JO(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 rb(e){e==null||e.getTracks().forEach(t=>t.stop())}function YO(){const{t:e}=kt(),[t,n]=L("idle"),[s,r]=L(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=Jr();return!!(d()&&(v!=null&&v.available)&&(v!=null&&v.sttConfigured)&&(v!=null&&v.supportsStt))},f=()=>{rb(a),a=null},h=()=>{o&&o.state!=="inactive"&&o.stop(),o=null,f(),i=[]};nt(()=>{l=!0,c+=1,h()});const m=async()=>{var k,$;if(!d()){Cs(e("promptInput.voiceInput.error.unsupported"),{title:e("promptInput.voiceInput.error.title"),variant:"error"});return}const v=++c;n("requesting"),r(null);try{if(En()){const D=await(($=(k=window.electronAPI)==null?void 0:k.requestMicrophoneAccess)==null?void 0:$.call(k));if(D&&!D.granted)throw new Error(e("promptInput.voiceInput.error.permissionDenied"))}const C=await navigator.mediaDevices.getUserMedia({audio:!0});if(v!==c||l){rb(C);return}i=[],a=C;const T=JO(C);o=T,T.addEventListener("dataavailable",D=>{D.data.size>0&&v===c&&i.push(D.data)}),T.addEventListener("error",()=>{v===c&&(h(),n("idle"))}),T.addEventListener("stop",()=>{v===c&&S(v)}),n("recording"),T.start()}catch(C){if(v!==c)return;h(),n("idle"),Cs(e("promptInput.voiceInput.error.permission"),{title:e("promptInput.voiceInput.error.title"),detail:C instanceof Error?C.message:String(C),variant:"error"})}},w=()=>{!o||t()!=="recording"||(o.stop(),f(),n("transcribing"))},S=async v=>{var T;const k=i;i=[];const $=o;if(o=null,v!==c||k.length===0){v===c&&n("idle");return}const C=($==null?void 0:$.mimeType)||((T=k[0])==null?void 0:T.type)||"audio/webm";try{const D=new Blob(k,{type:C}),R=await ft.transcribeAudio({audioBase64:await ZO(D),mimeType:C});v===c&&r(R.text.trim()||e("settings.speech.testInput.empty"))}catch(D){v===c&&Cs(e("promptInput.voiceInput.error.transcribe"),{title:e("promptInput.voiceInput.error.title"),detail:D instanceof Error?D.message:String(D),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 QO=F('<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>'),ag=F('<button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap">'),XO=F("<div class=settings-inline-note> "),ob=F("<div class=settings-card-section-header><h4 class=settings-card-section-title>"),cg=F("<div class=settings-inline-note>"),eR=F('<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>'),tR=F("<span class=settings-inline-note>"),nR=F('<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">'),sR=F('<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">'),rR=F("<option>");const oR=Lt("actions");function ib(e,t){const n=e[t];return{apiKey:"",baseUrl:n.baseUrl??"",model:n.model}}function lg(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:ib(e,"stt"),tts:ib(e,"tts")}}function ab(e,t){return e.apiKey===t.apiKey&&e.baseUrl===t.baseUrl&&e.model===t.model}function iR(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&&ab(e.stt,t.stt)&&ab(e.tts,t.tts)}const aR=()=>{const{t:e}=kt(),{serverSettings:t,updateSpeechSettings:n}=Tn(),s=lg(t().speech),[r,o]=L(!1),[a,i]=L("saved"),[c,l]=L(s),[d,u]=L(!1),[f,h]=L(!1),[m,w]=L(!1),[S,b]=L(!1),[v,k]=L(!1),[$,C]=L(!1),T=qO({id:()=>"settings-speech-test",text:()=>e("settings.speech.testPlayback.sample"),settingsOverride:()=>({playbackMode:c().playbackMode,ttsFormat:c().ttsFormat})}),D=YO();qe(()=>{const M=t().speech,N=lg(M);if(!r()&&!J()){const ce=Gf()?N:{...N,separateProviders:!1};iR(c(),ce)||l(ce),d()&&u(!1),f()&&h(!1),m()&&w(!1),S()&&b(!1),v()&&k(!1),$()&&C(!1)}}),qe(()=>{kc()});const R=()=>{if(XE())return e("settings.speech.status.loading");if(eT())return e("settings.speech.status.error");const M=Jr();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")},q=(M,N)=>{i("idle"),M==="apiKey"&&(u(!0),h(!1)),l(ce=>({...ce,[M]:N}))},re=(M,N,ce)=>{i("idle"),N==="apiKey"&&(M==="stt"?(w(!0),b(!1)):(k(!0),C(!1))),l(fe=>({...fe,[M]:{...fe[M],[N]:ce}}))},ee=$e(()=>f()||c().apiKey.trim().length>0),W=$e(()=>Tc({playbackMode:c().playbackMode,ttsFormat:c().ttsFormat,capabilities:Jr()})),U=$e(()=>{const M=Jr();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"&&!W().available?e("settings.speech.compatibility.browserStreamingUnavailable"):e("settings.speech.compatibility.runtimeNote")}),J=$e(()=>{const M=t().speech,N=c();if(N.separateProviders!==M.separateProviders)return!0;if(N.separateProviders){const ce=M.stt,fe=M.tts,Re=S()||N.stt.apiKey.trim().length>0||(N.stt.baseUrl||"")!==(ce.baseUrl||"")||N.stt.model!==ce.model,be=$()||N.tts.apiKey.trim().length>0||(N.tts.baseUrl||"")!==(fe.baseUrl||"")||N.tts.model!==fe.model||N.ttsVoice!==M.ttsVoice||N.playbackMode!==M.playbackMode||N.ttsFormat!==M.ttsFormat;return Re||be}return ee()||(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 z(){if(!J()||r())return;const M=c(),N=t().speech;o(!0),i("idle");try{if(M.separateProviders)await n({separateProviders:!0,stt:tb(S(),M.stt.apiKey,M.stt.baseUrl,M.stt.model,N.stt.baseUrl,N.sttModel),tts:tb($(),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 ce=M.apiKey.trim(),fe=(M.baseUrl.trim()||"")!==(N.baseUrl||"");await n({separateProviders:!1,...f()?{apiKey:null}:ce?{apiKey:ce}:fe?{apiKey:null}:{},...fe?{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 kc(!0),l(lg(t().speech)),u(!1),h(!1),w(!1),b(!1),k(!1),C(!1),i("saved")}catch(ce){oR.error("Failed to save speech settings",ce),i("error")}finally{o(!1)}}return(()=>{var M=eR(),N=M.firstChild,ce=N.firstChild,fe=ce.firstChild,Re=fe.firstChild,be=Re.nextSibling,ye=ce.nextSibling,Ce=N.nextSibling,je=Ce.firstChild,O=je.firstChild,g=O.firstChild,x=g.nextSibling,A=O.nextSibling,E=A.firstChild,H=E.nextSibling,B=H.nextSibling,oe=B.nextSibling,Ae=oe.firstChild,we=oe.nextSibling,he=we.firstChild,Ee=we.nextSibling,Ge=je.nextSibling,Xe=Ge.nextSibling;return p(ce,y(ih,{class:"settings-card-heading-icon"}),fe),p(Re,()=>e("settings.speech.title")),p(be,()=>e("settings.speech.subtitle")),p(ye,()=>e("settings.scope.server")),p(g,()=>e("settings.speech.provider.title")),p(x,()=>e("settings.speech.provider.subtitle")),p(E,()=>e("settings.speech.provider.openaiCompatible")),p(H,R),p(B,le),oe.$$click=()=>void D.toggle(),p(oe,y(Q,{get when(){return D.isTranscribing()||D.state()==="requesting"},get fallback(){return y(Q,{get when(){return D.isRecording()},get fallback(){return y(eg,{class:"w-3.5 h-3.5","aria-hidden":"true"})},get children(){return y(vw,{class:"w-3.5 h-3.5","aria-hidden":"true"})}})},get children(){return y(Nn,{class:"w-3.5 h-3.5 animate-spin","aria-hidden":"true"})}}),Ae),p(Ae,()=>D.buttonTitle()),p(A,y(Q,{get when(){return D.result()},children:se=>(()=>{var V=tR();return p(V,(()=>{var Y=_e(()=>se().length>40);return()=>Y()?`${se().slice(0,40)}…`:se()})()),de(()=>pe(V,"title",se())),V})()}),we),we.$$click=()=>void T.toggle(),p(we,y(Q,{get when(){return T.isLoading()},get fallback(){return y(Q,{get when(){return T.isPlaying()},get fallback(){return y(ih,{class:"w-3.5 h-3.5","aria-hidden":"true"})},get children(){return y(vw,{class:"w-3.5 h-3.5","aria-hidden":"true"})}})},get children(){return y(Nn,{class:"w-3.5 h-3.5 animate-spin","aria-hidden":"true"})}}),he),p(he,(()=>{var se=_e(()=>!!T.isPlaying());return()=>se()?e("settings.speech.testPlayback.stop"):_e(()=>!!T.isLoading())()?e("settings.speech.testPlayback.generating"):e("settings.speech.testPlayback.action")})()),Ee.$$click=()=>void z(),p(Ee,(()=>{var se=_e(()=>!!r());return()=>se()?e("settings.speech.save.saving"):e("settings.speech.save.action")})()),p(Ce,y(Q,{get when(){return Gf()},get children(){var se=QO(),V=se.firstChild,Y=V.firstChild,Oe=Y.nextSibling,ve=V.nextSibling,Ie=ve.firstChild,Le=Ie.nextSibling;return p(Y,()=>e("settings.speech.separateProviders.title")),p(Oe,()=>e("settings.speech.separateProviders.subtitle")),Ie.addEventListener("change",ze=>{i("idle"),l(Ne=>({...Ne,separateProviders:ze.currentTarget.checked}))}),p(Le,()=>e("settings.common.enabled")),de(()=>Ie.disabled=r()),de(()=>Ie.checked=c().separateProviders),se}}),Ge),p(Ce,y(Q,{get when(){return!c().separateProviders},get children(){return[y(cs,{get label(){return e("settings.speech.apiKey.title")},get caption(){return e("settings.speech.apiKey.subtitle")},get value(){return c().apiKey},onInput:se=>q("apiKey",se),type:"password",get placeholder(){return _e(()=>!!t().speech.hasApiKey)()?e("settings.speech.apiKey.placeholder"):void 0}}),y(Q,{get when(){return _e(()=>!!(t().speech.hasApiKey&&!d()))()&&c().apiKey.length===0},get children(){var se=XO(),V=se.firstChild;return p(se,(()=>{var Y=_e(()=>!!f());return()=>Y()?e("settings.speech.apiKey.clearPending"):e("settings.speech.apiKey.storedNote")})(),V),p(se,y(Q,{get when(){return!f()},get children(){var Y=ag();return Y.$$click=()=>{h(!0),i("idle")},p(Y,()=>e("settings.speech.apiKey.clearAction")),Y}}),null),se}}),y(cs,{get label(){return e("settings.speech.baseUrl.title")},get caption(){return e("settings.speech.baseUrl.subtitle")},get value(){return c().baseUrl},onInput:se=>q("baseUrl",se),get placeholder(){return e("settings.speech.baseUrl.placeholder")}}),y(cs,{get label(){return e("settings.speech.sttModel.title")},get caption(){return e("settings.speech.sttModel.subtitle")},get value(){return c().sttModel},onInput:se=>q("sttModel",se)}),y(cs,{get label(){return e("settings.speech.ttsModel.title")},get caption(){return e("settings.speech.ttsModel.subtitle")},get value(){return c().ttsModel},onInput:se=>q("ttsModel",se)}),y(cs,{get label(){return e("settings.speech.ttsVoice.title")},get caption(){return e("settings.speech.ttsVoice.subtitle")},get value(){return c().ttsVoice},onInput:se=>q("ttsVoice",se),get icon(){return y(eg,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"})}})]}}),Ge),p(Ce,y(Q,{get when(){return _e(()=>!!c().separateProviders)()&&Gf()},get children(){return[(()=>{var se=ob(),V=se.firstChild;return p(V,()=>e("settings.speech.stt.section.title")),se})(),y(cs,{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:se=>re("stt","apiKey",se),type:"password",get placeholder(){return _e(()=>!!(t().speech.stt.hasApiKey||t().speech.hasApiKey))()?e("settings.speech.stt.apiKey.placeholder"):void 0}}),y(Q,{get when(){return _e(()=>!!((t().speech.stt.hasApiKey||t().speech.hasApiKey)&&!m()))()&&c().stt.apiKey.length===0},get children(){var se=cg();return p(se,y(Q,{get when(){return t().speech.stt.hasApiKey},get fallback(){return e("settings.speech.stt.apiKey.usingShared")},get children(){return[_e(()=>_e(()=>!!S())()?e("settings.speech.stt.apiKey.clearPending"):e("settings.speech.stt.apiKey.storedNote"))," ",y(Q,{get when(){return!S()},get children(){var V=ag();return V.$$click=()=>{b(!0),i("idle")},p(V,()=>e("settings.speech.stt.apiKey.clearAction")),V}})]}})),se}}),y(cs,{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:se=>re("stt","baseUrl",se),get placeholder(){return e("settings.speech.stt.baseUrl.placeholder")}}),y(cs,{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:se=>re("stt","model",se)}),(()=>{var se=ob(),V=se.firstChild;return p(V,()=>e("settings.speech.tts.section.title")),se})(),y(cs,{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:se=>re("tts","apiKey",se),type:"password",get placeholder(){return _e(()=>!!(t().speech.tts.hasApiKey||t().speech.hasApiKey))()?e("settings.speech.tts.apiKey.placeholder"):void 0}}),y(Q,{get when(){return _e(()=>!!((t().speech.tts.hasApiKey||t().speech.hasApiKey)&&!v()))()&&c().tts.apiKey.length===0},get children(){var se=cg();return p(se,y(Q,{get when(){return t().speech.tts.hasApiKey},get fallback(){return e("settings.speech.tts.apiKey.usingShared")},get children(){return[_e(()=>_e(()=>!!$())()?e("settings.speech.tts.apiKey.clearPending"):e("settings.speech.tts.apiKey.storedNote"))," ",y(Q,{get when(){return!$()},get children(){var V=ag();return V.$$click=()=>{C(!0),i("idle")},p(V,()=>e("settings.speech.tts.apiKey.clearAction")),V}})]}})),se}}),y(cs,{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:se=>re("tts","baseUrl",se),get placeholder(){return e("settings.speech.tts.baseUrl.placeholder")}}),y(cs,{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:se=>re("tts","model",se)}),y(cs,{get label(){return e("settings.speech.ttsVoice.title")},get caption(){return e("settings.speech.ttsVoice.subtitle")},get value(){return c().ttsVoice},onInput:se=>q("ttsVoice",se),get icon(){return y(eg,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"})}})]}}),Ge),p(Ce,y(cb,{get label(){return e("settings.speech.playbackMode.title")},get caption(){return e("settings.speech.playbackMode.subtitle")},get value(){return c().playbackMode},onInput:se=>q("playbackMode",se),get options(){return[{value:"streaming",label:e("settings.speech.playbackMode.streaming")},{value:"buffered",label:e("settings.speech.playbackMode.buffered")}]}}),Ge),p(Ce,y(cb,{get label(){return e("settings.speech.ttsFormat.title")},get caption(){return e("settings.speech.ttsFormat.subtitle")},get value(){return c().ttsFormat},onInput:se=>q("ttsFormat",se),options:[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"opus",label:"Opus"},{value:"aac",label:"AAC"}]}),Ge),p(Ge,()=>e("settings.speech.help")),p(Ce,y(Q,{get when(){return U()},children:se=>(()=>{var V=cg();return p(V,se),V})()}),Xe),p(Xe,()=>e("settings.speech.testPlayback.note")),de(se=>{var V=r()&&D.state()!=="recording"||D.state()==="requesting"||D.state()==="transcribing"||D.state()==="idle"&&!D.canUseTranscription(),Y=D.buttonTitle(),Oe=D.buttonTitle(),ve=r(),Ie=T.buttonTitle(),Le=T.buttonTitle(),ze=!J()||r();return V!==se.e&&(oe.disabled=se.e=V),Y!==se.t&&pe(oe,"title",se.t=Y),Oe!==se.a&&pe(oe,"aria-label",se.a=Oe),ve!==se.o&&(we.disabled=se.o=ve),Ie!==se.i&&pe(we,"title",se.i=Ie),Le!==se.n&&pe(we,"aria-label",se.n=Le),ze!==se.s&&(Ee.disabled=se.s=ze),se},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),M})()},cs=e=>(()=>{var t=nR(),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&&pe(a,"type",i.e=c),l!==i.t&&pe(a,"placeholder",i.t=l),i},{e:void 0,t:void 0}),de(()=>a.value=e.value),t})(),cb=e=>(()=>{var t=sR(),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(Ut,{get each(){return e.options},children:i=>(()=>{var c=rR();return p(c,()=>i.label),de(()=>c.value=i.value),c})()})),de(()=>a.value=e.value),t})();Ht(["click","input"]);var cR=F("<div class=settings-section-stack><div class=settings-card><div class=settings-stack>");const lR=()=>{const e=Tn(),t=$e(()=>yp(e).filter(n=>n.id==="behavior.promptVoiceInput"));return(()=>{var n=cR(),s=n.firstChild,r=s.firstChild;return p(r,y(vp,{settings:t,get preferences(){return e.preferences}})),p(n,y(aR,{}),null),n})()};function Qk(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 dR(e){return(e==null?void 0:e.id)??""}function Zi(e){return e==null?void 0:e.sessionID}function uR(e){var t;return(t=e==null?void 0:e.source)==null?void 0:t.messageID}function fR(e){var t;return(t=e==null?void 0:e.source)==null?void 0:t.id}function Xk(e){return(e==null?void 0:e.action)??"permission"}function gR(e){return(e==null?void 0:e.resources.filter(t=>typeof t=="string"))??[]}function UW(e){const t=Xk(e),n=gR(e);return n.length>0?`${t}: ${n.join(", ")}`:t}function hR(e){return e==null?void 0:e.requestID}var mR=Object.defineProperty,pR=e=>e;function yR(e,t){this[e]=pR.bind(null,t)}var xp=(e,t)=>{for(var n in t)mR(e,n,{get:t[n],enumerable:!0,configurable:!0,set:yR.bind(t,n)})},lb={};xp(lb,{SharedEvents:()=>lb,make:()=>ex});function ex(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(h)&&!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 h={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(h),d.connected&&h.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 $s extends Error{constructor(n,s){super(n,s);ae(this,"reason");ae(this,"name","ClientError");this.reason=n}}var vR={};xp(vR,{make:()=>tx});var wR=16*1024*1024;function tx(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,h]of Object.entries(i.query??{}))xh(d.searchParams,f,h);const u=new Headers(e.headers);for(const[f,h]of Object.entries(i.headers??{}))h!=null&&u.set(f,String(h));for(const[f,h]of new Headers(c==null?void 0:c.headers))u.set(f,h);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 $s("Transport",{cause:l})}},r=async(i,c)=>{var l;if(c.declaredStatuses.includes(i.status))throw SR(await db(i));try{await((l=i.body)==null?void 0:l.cancel())}catch{}throw new $s("UnexpectedStatus",{cause:{status: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 db(l)},a=(i,c)=>({async*[Symbol.asyncIterator](){var h,m;const l=await s(i,c);if(l.status!==i.successStatus&&await r(l,i),!nx(l,"text/event-stream")){try{await((h=l.body)==null?void 0:h.cancel())}catch{}throw new $s("UnsupportedContentType")}if(l.body===null)throw new $s("MalformedResponse");const d=l.body.getReader(),u=new TextDecoder;let f="";try{for(;;){let w;try{w=await d.read()}catch(v){throw new $s("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>wR)throw new $s("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-DMFtdRoa.js","assets/monaco-viewer-BtzCmjFO.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-DwKq8v48.js","assets/index-4mzZPz2j.css","assets/client-state-DTQzqBPJ.js","assets/index-DTGOXoDH.js","assets/index-Cgp1TEtC.js","assets/App-DXfroBn-.js"])))=>i.map(i=>d[i]);
2
+ var KE=Object.defineProperty;var VE=(e,t,n)=>t in e?KE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>VE(e,typeof t!="symbol"?t+"":t,n);import{u as kt,i as vs,c as jE,a as En,b as bn,r as mn,l as Su,_ as ts,t as ke,d as Wg,e as Fm,f as qi,g as Nm,h as qE,j as zE,p as Uv,I as WE}from"./index-DwKq8v48.js";import{c as Um,p as St,t as F,i as p,s as hr,a as _s,b as Qs,u as Xs,m as _e,d as pe,D as Bm,P as Km,e as Ht,f as Wf,g as Hf,h as Lt,j as fs,k as ft,l as cS,n as Tn,o as HE,q as GE,r as Bv,B as ZE,v as JE,L as YE,w as QE,x as $i,y as Kv,z as kc,A as Jr,C as Gf,E as XE,F as eT,G as tT,H as nT,I as sT,J as rT,K as gr,M as Vm,N as lS,O as ku,Q as oT,R as iT,S as jm,T as aT,U as cT,V as Vv,W as jv,X as lT,Y as dT,Z as uT,_ as fT}from"./monaco-viewer-BtzCmjFO.js";import{b as xc,e as L,u as zi,d as qe,o as nt,k as y,F as Ut,a as de,M as _i,p as Se,w as dS,c as $e,n as Ns,i as gT,s as Et,x as ei,l as Ir,m as Lr,t as ti,S as Q,v as uS,y as fS,z as gS,A as hS,h as nn,B as hT}from"./git-diff-vendor-CT8HfOQw.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";const mT=e=>typeof e=="function",Sd=(e,t)=>mT(e)?e(t):e;var en;(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"})(en||(en={}));const[Ro,Kr]=Um({toasts:[],pausedAt:void 0}),pT=()=>{const{pausedAt:e,toasts:t}=Ro;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&&Ms({type:en.DISMISS_TOAST,toastId:r.id});return}return setTimeout(()=>{Ms({type:en.DISMISS_TOAST,toastId:r.id})},o)})},uc=new Map,qv=(e,t)=>{if(uc.has(e))return;const n=setTimeout(()=>{uc.delete(e),Ms({type:en.REMOVE_TOAST,toastId:e})},t);uc.set(e,n)},yT=e=>{const t=uc.get(e);uc.delete(e),t&&clearTimeout(t)},Ms=e=>{switch(e.type){case en.ADD_TOAST:Kr("toasts",r=>{const o=r;return[e.toast,...o]});break;case en.DISMISS_TOAST:const{toastId:t}=e,n=Ro.toasts;if(t){const r=n.find(o=>o.id===t);r&&qv(t,r.unmountDelay),Kr("toasts",o=>o.id===t,St(o=>o.visible=!1))}else n.forEach(r=>{qv(r.id,r.unmountDelay)}),Kr("toasts",r=>r.id!==void 0,St(r=>r.visible=!1));break;case en.REMOVE_TOAST:if(!e.toastId){Kr("toasts",[]);break}Kr("toasts",r=>r.filter(a=>a.id!==e.toastId));break;case en.UPDATE_TOAST:e.toast.id&&yT(e.toast.id),Kr("toasts",r=>r.id===e.toast.id,r=>({...r,...e.toast}));break;case en.UPSERT_TOAST:Ro.toasts.find(r=>r.id===e.toast.id)?Ms({type:en.UPDATE_TOAST,toast:e.toast}):Ms({type:en.ADD_TOAST,toast:e.toast});break;case en.START_PAUSE:Kr(St(r=>{r.pausedAt=Date.now(),r.toasts.forEach(o=>{o.paused=!0})}));break;case en.END_PAUSE:const s=e.time-(Ro.pausedAt||0);Kr(St(r=>{r.pausedAt=void 0,r.toasts.forEach(o=>{o.pauseDuration+=s,o.paused=!1})}));break}},vT={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Pi={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},mS={position:"top-right",toastOptions:Pi,gutter:8,containerStyle:{},containerClassName:""},Ml="16px",wT={position:"fixed","z-index":9999,top:Ml,bottom:Ml,left:Ml,right:Ml,"pointer-events":"none"},bT=(()=>{let e=0;return()=>String(++e)})(),ST=e=>{TT(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},kT=(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}},xT=(e,t)=>{const n=e.getBoundingClientRect();n.height!==t.height&&Ms({type:en.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},$T=(e,t)=>{const{toasts:n}=Ro,s=wi().gutter||mS.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)},_T=(e,t)=>(e.position||t).includes("top")?1:-1,CT={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"},ET={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},Al={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},kd=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[wi,TT]=L(mS),MT=(e,t="blank",n)=>{var s,r,o;return{...Pi,...wi().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||bT(),paused:!1,style:{...Pi.style,...(s=wi().toastOptions)==null?void 0:s.style,...n.style},duration:n.duration||((r=wi().toastOptions)==null?void 0:r.duration)||vT[t],position:n.position||((o=wi().toastOptions)==null?void 0:o.position)||wi().position||Pi.position}},Yc=e=>(t,n={})=>xc(()=>{const s=Ro.toasts.find(o=>o.id===n.id),r=MT(t,e,{...s,duration:void 0,...n});return Ms({type:en.UPSERT_TOAST,toast:r}),r.id}),Rn=(e,t)=>Yc("blank")(e,t);zi(()=>Rn);Rn.error=Yc("error");Rn.success=Yc("success");Rn.loading=Yc("loading");Rn.custom=Yc("custom");Rn.dismiss=e=>{Ms({type:en.DISMISS_TOAST,toastId:e})};Rn.promise=(e,t,n)=>{const s=Rn.loading(t.loading,{...n});return e.then(r=>(Rn.success(Sd(t.success,r),{id:s,...n}),r)).catch(r=>{Rn.error(Sd(t.error,r),{id:s,...n})}),e};Rn.remove=e=>{Ms({type:en.REMOVE_TOAST,toastId:e})};var AT=F("<div><style>.sldt-active{z-index:9999;}.sldt-active>*{pointer-events:auto;}");const DT=e=>(qe(()=>{ST(e)}),qe(()=>{const t=pT();nt(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{var t=AT();return t.firstChild,p(t,y(Ut,{get each(){return Ro.toasts},children:n=>y(IT,{toast:n})}),null),de(n=>{var s={...wT,...e.containerStyle},r=e.containerClassName;return n.e=hr(t,s,n.e),r!==n.t&&_s(t,n.t=r),n},{e:void 0,t:void 0}),t})());var Dl=F("<div>"),PT=F("<div><div>");const OT=e=>{let t;return qe(()=>{if(!t)return;const n=_T(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=PT(),s=n.firstChild,r=t;return typeof r=="function"?Xs(r,n):t=n,p(n,y(dS,{get children(){return[y(_i,{get when(){return e.toast.icon},get children(){var o=Dl();return p(o,()=>e.toast.icon),de(a=>hr(o,Al,a)),o}}),y(_i,{get when(){return e.toast.type==="loading"},get children(){var o=Dl();return p(o,y(jT,Se(()=>e.toast.iconTheme))),de(a=>hr(o,Al,a)),o}}),y(_i,{get when(){return e.toast.type==="success"},get children(){var o=Dl();return p(o,y(UT,Se(()=>e.toast.iconTheme))),de(a=>hr(o,Al,a)),o}}),y(_i,{get when(){return e.toast.type==="error"},get children(){var o=Dl();return p(o,y(KT,Se(()=>e.toast.iconTheme))),de(a=>hr(o,Al,a)),o}})]}}),s),Qs(s,Se(()=>e.toast.ariaProps),!1,!0),p(s,()=>Sd(e.toast.message,e.toast)),de(o=>{var a=e.toast.className,i={...CT,...e.toast.style},c=ET;return a!==o.e&&_s(n,o.e=a),o.t=hr(n,i,o.t),o.a=hr(s,c,o.a),o},{e:void 0,t:void 0,a:void 0}),n})()};var RT=F("<div>");const IT=e=>{const t=()=>{const r=e.toast.position||Pi.position,o=$T(e.toast,r);return kT(r,o)},n=$e(()=>t());let s;return Ns(()=>{s&&xT(s,e.toast)}),(()=>{var r=RT();r.addEventListener("mouseleave",()=>Ms({type:en.END_PAUSE,time:Date.now()})),r.addEventListener("mouseenter",()=>Ms({type:en.START_PAUSE,time:Date.now()}));var o=s;return typeof o=="function"?Xs(o,r):s=r,p(r,(()=>{var a=_e(()=>e.toast.type==="custom");return()=>a()?Sd(e.toast.message,e.toast):y(OT,{get toast(){return e.toast},get position(){return e.toast.position||Pi.position}})})()),de(a=>{var i=n(),c=e.toast.visible?"sldt-active":"";return a.e=hr(r,i,a.e),c!==a.t&&_s(r,a.t=c),a},{e:void 0,t:void 0}),r})()};var LT=F('<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),FT=F('<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 pS=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=LT(),s=n.firstChild,r=s.nextSibling;return Qs(s,t,!0,!1),Qs(r,t,!0,!1),de(()=>pe(n,"fill",e.fill)),n})()},yS=e=>{const t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...kd("0.0 0.0 0.2 1")};return(()=>{var n=FT(),s=n.firstChild,r=s.nextSibling;return Qs(s,t,!0,!1),Qs(r,t,!0,!1),de(()=>pe(n,"fill",e.fill)),n})()};var NT=F('<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 UT=e=>{const t=e.primary||"#34C759";return(()=>{var n=NT(),s=n.firstChild,r=s.firstChild;return p(n,y(pS,{fill:t}),s),p(n,y(yS,{fill:t,begin:"350ms"}),s),Qs(r,Se(()=>kd("0.0, 0.0, 0.58, 1.0")),!0,!1),de(()=>pe(s,"stroke",e.secondary||"#FCFCFC")),n})()};var BT=F('<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 KT=e=>{const t=e.primary||"#FF3B30";return(()=>{var n=BT(),s=n.firstChild,r=s.firstChild,o=s.nextSibling,a=o.firstChild;return p(n,y(pS,{fill:t}),s),p(n,y(yS,{fill:t}),s),Qs(r,Se(()=>kd("0.0, 0.0, 0.58, 1.0")),!0,!1),Qs(a,Se(()=>kd("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&&pe(s,"stroke",i.e=c),l!==i.t&&pe(o,"fill",i.t=l),i},{e:void 0,t:void 0}),n})()};var VT=F('<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 jT=e=>(()=>{var t=VT(),n=t.firstChild,s=n.nextSibling;return de(r=>{var o=e.primary||"#E5E7EB",a=e.secondary||"#4b5563";return o!==r.e&&pe(n,"stroke",r.e=o),a!==r.t&&pe(s,"stroke",r.t=a),r},{e:void 0,t:void 0}),t})();function qT(e){return(...t)=>{for(const n of e)n&&n(...t)}}const ge=e=>typeof e=="function"&&!e.length?e():e,zv=e=>Array.isArray(e)?e:e?[e]:[];function zT(e,...t){return typeof e=="function"?e(...t):e}const WT=nt;function HT(e,t,n,s){return e.addEventListener(t,n,s),WT(e.removeEventListener.bind(e,t,n,s))}function GT(e,t,n,s){const r=()=>{zv(ge(e)).forEach(o=>{o&&zv(ge(t)).forEach(a=>HT(o,a,n,s))})};typeof e=="function"?qe(r):de(r)}const Zf=Symbol("fallback");function Wv(e){for(const t of e)t.dispose()}function ZT(e,t,n,s={}){const r=new Map;return nt(()=>Wv(r.values())),()=>{const a=e()||[];return a[gT],zi(()=>{var d,u;if(!a.length)return Wv(r.values()),r.clear(),s.fallback?[xc(h=>(r.set(Zf,{dispose:h}),s.fallback()))]:[];const i=new Array(a.length),c=r.get(Zf);if(!r.size||c){c==null||c.dispose(),r.delete(Zf);for(let f=0;f<a.length;f++){const h=a[f],m=t(h,f);o(i,h,f,m)}return i}const l=new Set(r.keys());for(let f=0;f<a.length;f++){const h=a[f],m=t(h,f);l.delete(m);const w=r.get(m);w?(i[f]=w.mapped,(d=w.setIndex)==null||d.call(w,f),w.setItem(()=>h)):o(i,h,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){xc(d=>{const[u,f]=L(i),h={setItem:f,dispose:d};if(n.length>1){const[m,w]=L(c);h.setIndex=w,h.mapped=n(u,m)}else h.mapped=n(u);r.set(l,h),a[c]=h.mapped})}}function JT(e){const{by:t}=e;return $e(ZT(()=>e.each,typeof t=="function"?t:n=>n[t],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}const YT=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Hv(e){const t={};let n;for(;n=YT.exec(e);)t[n[1]]=n[2];return t}function Qc(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Hv(e)}else typeof t=="string"&&(t=Hv(t));return{...e,...t}}function Mn(...e){return qT(e)}function wW(e,t,n=-1){return n in e?[...e.slice(0,n),t,...e.slice(n)]:[...e,t]}function Gv(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function QT(e){return typeof e=="number"}function bi(e){return Object.prototype.toString.call(e)==="[object String]"}function xu(e){return typeof e=="function"}function Ea(e){return t=>`${e()}-${t}`}function pr(e,t){return e?e===t||e.contains(t):!1}function Ya(e,t=!1){const{activeElement:n}=xr(e);if(!(n!=null&&n.nodeName))return null;if(vS(n)&&n.contentDocument)return Ya(n.contentDocument.body,t);if(t){const s=n.getAttribute("aria-activedescendant");if(s){const r=xr(n).getElementById(s);if(r)return r}}return n}function XT(e){return xr(e).defaultView||window}function xr(e){return e?e.ownerDocument||e:document}function vS(e){return e.tagName==="IFRAME"}var qm=(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))(qm||{});function wS(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 zm(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 Xc(){return zm(/^Mac/i)}function eM(){return zm(/^iPhone/i)}function tM(){return zm(/^iPad/i)||Xc()&&navigator.maxTouchPoints>1}function nM(){return eM()||tM()}function sM(){return Xc()||nM()}function rM(){return wS(/AppleWebKit/i)&&!oM()}function oM(){return wS(/Chrome/i)}function Zt(e,t){return t&&(xu(t)?t(e):t[0](t[1],e)),e==null?void 0:e.defaultPrevented}function ls(e){return t=>{for(const n of e)Zt(t,n)}}function iM(e){return Xc()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function xn(e){if(e)if(aM())e.focus({preventScroll:!0});else{const t=cM(e);e.focus(),lM(t)}}var Pl=null;function aM(){if(Pl==null){Pl=!1;try{document.createElement("div").focus({get preventScroll(){return Pl=!0,!0}})}catch{}}return Pl}function cM(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 lM(e){for(const{element:t,scrollTop:n,scrollLeft:s}of e)t.scrollTop=n,t.scrollLeft=s}var bS=["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'])"],dM=[...bS,'[tabindex]:not([tabindex="-1"]):not([disabled])'],Wm=`${bS.join(":not([hidden]),")},[tabindex]:not([disabled]):not([hidden])`,uM=dM.join(':not([hidden]):not([tabindex="-1"]),');function SS(e,t){const s=Array.from(e.querySelectorAll(Wm)).filter(Zv);return t&&Zv(e)&&s.unshift(e),s.forEach((r,o)=>{if(vS(r)&&r.contentDocument){const a=r.contentDocument.body,i=SS(a,!1);s.splice(o,1,...i)}}),s}function Zv(e){return kS(e)&&!fM(e)}function kS(e){return e.matches(Wm)&&Hm(e)}function fM(e){return Number.parseInt(e.getAttribute("tabindex")||"0",10)<0}function Hm(e,t){return e.nodeName!=="#comment"&&gM(e)&&hM(e,t)&&(!e.parentElement||Hm(e.parentElement,e))}function gM(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 hM(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function mM(e,t,n){const s=t!=null&&t.tabbable?uM:Wm,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)&&Hm(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 Jv(e){let t=e;for(;t&&!pM(t);)t=t.parentElement;return t||document.scrollingElement||document.documentElement}function pM(e){const t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function yM(){}function bW(e){return[e.clientX,e.clientY]}function SW(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],[,h]=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>h&&(r=!r):r=!r)}}else if(d<f){if(s>d&&s<=f){if(m===0)return!0;m<0&&(s===f?s<h&&(r=!r):r=!r)}}else if(s===d&&(n>=u&&n<=l||n>=l&&n<=u))return!0}return r}function Dt(e,t){return Se(e,t)}var Ka=new Map,Yv=new Set;function Qv(){if(typeof window>"u")return;const e=n=>{if(!n.target)return;let s=Ka.get(n.target);s||(s=new Set,Ka.set(n.target,s),n.target.addEventListener("transitioncancel",t)),s.add(n.propertyName)},t=n=>{if(!n.target)return;const s=Ka.get(n.target);if(s&&(s.delete(n.propertyName),s.size===0&&(n.target.removeEventListener("transitioncancel",t),Ka.delete(n.target)),Ka.size===0)){for(const r of Yv)r();Yv.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?Qv():document.addEventListener("DOMContentLoaded",Qv));function Hg(e,t){const n=Xv(e,t,"left"),s=Xv(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 Xv(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 kW(e,t){var n,s;if(document.contains(e)){const r=document.scrollingElement||document.documentElement;if(window.getComputedStyle(r).overflow==="hidden"){let a=Jv(e);for(;e&&a&&e!==r&&a!==r;)Hg(a,e),e=a,a=Jv(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 $u={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"},xd="data-kb-top-layer",xS,Gg=!1,$r=[];function $c(e){return $r.findIndex(t=>t.node===e)}function vM(e){return $r[$c(e)]}function wM(e){return $r[$r.length-1].node===e}function $S(){return $r.filter(e=>e.isPointerBlocking)}function bM(){return[...$S()].slice(-1)[0]}function Gm(){return $S().length>0}function _S(e){var n;const t=$c((n=bM())==null?void 0:n.node);return $c(e)<t}function SM(e){$r.push(e)}function kM(e){const t=$c(e);t<0||$r.splice(t,1)}function xM(){for(const{node:e}of $r)e.style.pointerEvents=_S(e)?"none":"auto"}function $M(e){if(Gm()&&!Gg){const t=xr(e);xS=document.body.style.pointerEvents,t.body.style.pointerEvents="none",Gg=!0}}function _M(e){if(Gm())return;const t=xr(e);t.body.style.pointerEvents=xS,t.body.style.length===0&&t.body.removeAttribute("style"),Gg=!1}var Zn={layers:$r,isTopMostLayer:wM,hasPointerBlockingLayer:Gm,isBelowPointerBlockingLayer:_S,addLayer:SM,removeLayer:kM,indexOf:$c,find:vM,assignPointerEventToLayers:xM,disableBodyPointerEvents:$M,restoreBodyPointerEvents:_M},Jf="focusScope.autoFocusOnMount",Yf="focusScope.autoFocusOnUnmount",ew={bubbles:!1,cancelable:!0},tw={stack:[],active(){return this.stack[0]},add(e){var t;e!==this.active()&&((t=this.active())==null||t.pause()),this.stack=Gv(this.stack,e),this.stack.unshift(e)},remove(e){var t;this.stack=Gv(this.stack,e),(t=this.active())==null||t.resume()}};function CS(e,t){const[n,s]=L(!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=()=>xr(t()),l=()=>{const m=c().createElement("span");return m.setAttribute("data-focus-trap",""),m.tabIndex=0,Object.assign(m.style,$u),m},d=()=>{const m=t();return m?SS(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},h=()=>{const m=t();if(!m)return!1;const w=Ya(m);return!w||pr(m,w)?!1:kS(w)};qe(()=>{const m=t();if(!m)return;tw.add(r);const w=Ya(m);if(!pr(m,w)){const b=new CustomEvent(Jf,ew);m.addEventListener(Jf,a),m.dispatchEvent(b),b.defaultPrevented||setTimeout(()=>{xn(u()),Ya(m)===w&&xn(m)},0)}nt(()=>{m.removeEventListener(Jf,a),setTimeout(()=>{const b=new CustomEvent(Yf,ew);h()&&b.preventDefault(),m.addEventListener(Yf,i),m.dispatchEvent(b),b.defaultPrevented||xn(w??c().body),m.removeEventListener(Yf,i),tw.remove(r)},0)})}),qe(()=>{const m=t();if(!m||!ge(e.trapFocus)||n())return;const w=b=>{const v=b.target;v!=null&&v.closest(`[${xd}]`)||(pr(m,v)?o=v:xn(o))},S=b=>{const k=b.relatedTarget??Ya(m);k!=null&&k.closest(`[${xd}]`)||pr(m,k)||xn(o)};c().addEventListener("focusin",w),c().addEventListener("focusout",S),nt(()=>{c().removeEventListener("focusin",w),c().removeEventListener("focusout",S)})}),qe(()=>{const m=t();if(!m||!ge(e.trapFocus)||n())return;const w=l();m.insertAdjacentElement("afterbegin",w);const S=l();m.insertAdjacentElement("beforeend",S);function b(k){const $=u(),C=f();k.relatedTarget===$?xn(C):xn($)}w.addEventListener("focusin",b),S.addEventListener("focusin",b);const v=new MutationObserver(k=>{for(const $ of k)$.previousSibling===S&&(S.remove(),m.insertAdjacentElement("beforeend",S)),$.nextSibling===w&&(w.remove(),m.insertAdjacentElement("afterbegin",w))});v.observe(m,{childList:!0,subtree:!1}),nt(()=>{w.removeEventListener("focusin",b),S.removeEventListener("focusin",b),w.remove(),S.remove(),v.disconnect()})})}var ES=7e3,Qf=null,CM="data-live-announcer";function xW(e,t="assertive",n=ES){Qf||(Qf=new EM),Qf.announce(e,t,n)}var EM=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,$u),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=ES){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 TS(e){qe(()=>{ge(e.isDisabled)||nt(TM(ge(e.targets),ge(e.root)))})}var Va=new WeakMap,is=[];function TM(e,t=document.body){const n=new Set(e),s=new Set,r=c=>{for(const f of c.querySelectorAll(`[${CM}], [${xd}]`))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 h of n)if(f.contains(h))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=Va.get(c)??0;c.getAttribute("aria-hidden")==="true"&&l===0||(l===0&&c.setAttribute("aria-hidden","true"),s.add(c),Va.set(c,l+1))};is.length&&is[is.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 is.push(i),()=>{a.disconnect();for(const c of s){const l=Va.get(c);if(l==null)return;l===1?(c.removeAttribute("aria-hidden"),Va.delete(c)):Va.set(c,l-1)}i===is[is.length-1]?(is.pop(),is.length&&is[is.length-1].observe()):is.splice(is.indexOf(i),1)}}var nw="interactOutside.pointerDownOutside",sw="interactOutside.focusOutside";function MM(e,t){let n,s=yM;const r=()=>xr(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 h;const f=u.target;return!(f instanceof Element)||f.closest(`[${xd}]`)||!pr(r(),f)||pr(t(),f)?!1:!((h=e.shouldExcludeElement)!=null&&h.call(e,f))},l=u=>{function f(){const h=t(),m=u.target;if(!h||!m||!c(u))return;const w=ls([o,i]);m.addEventListener(nw,w,{once:!0});const S=new CustomEvent(nw,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:u.button===2||iM(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(),h=u.target;if(!f||!h||!c(u))return;const m=ls([a,i]);h.addEventListener(sw,m,{once:!0});const w=new CustomEvent(sw,{bubbles:!1,cancelable:!0,detail:{originalEvent:u,isContextMenu:!1}});h.dispatchEvent(w)};qe(()=>{ge(e.isDisabled)||(n=window.setTimeout(()=>{r().addEventListener("pointerdown",l,!0)},0),r().addEventListener("focusin",d,!0),nt(()=>{window.clearTimeout(n),r().removeEventListener("click",s),r().removeEventListener("pointerdown",l,!0),r().removeEventListener("focusin",d,!0)}))})}function AM(e){const t=n=>{var s;n.key===qm.Escape&&((s=e.onEscapeKeyDown)==null||s.call(e,n))};qe(()=>{var s;if(ge(e.isDisabled))return;const n=((s=e.ownerDocument)==null?void 0:s.call(e))??xr();n.addEventListener("keydown",t),nt(()=>{n.removeEventListener("keydown",t)})})}function zt(e){const[t,n]=Et(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return y(Bm,Se(n,{get component(){return t.as}}))}var MS=Ir();function DM(){return Lr(MS)}function AS(e){let t;const n=DM(),[s,r]=Et(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()}};MM({shouldExcludeElement:u=>{var f;return t?((f=s.excludedElements)==null?void 0:f.some(h=>pr(h(),u)))||[...o].some(h=>pr(h,u)):!1},onPointerDownOutside:u=>{var f,h,m;!t||Zn.isBelowPointerBlockingLayer(t)||!s.bypassTopMostLayerCheck&&!Zn.isTopMostLayer(t)||((f=s.onPointerDownOutside)==null||f.call(s,u),(h=s.onInteractOutside)==null||h.call(s,u),u.defaultPrevented||(m=s.onDismiss)==null||m.call(s))},onFocusOutside:u=>{var f,h,m;(f=s.onFocusOutside)==null||f.call(s,u),(h=s.onInteractOutside)==null||h.call(s,u),u.defaultPrevented||(m=s.onDismiss)==null||m.call(s)}},()=>t),AM({ownerDocument:()=>xr(t),onEscapeKeyDown:u=>{var f;!t||!Zn.isTopMostLayer(t)||((f=s.onEscapeKeyDown)==null||f.call(s,u),!u.defaultPrevented&&s.onDismiss&&(u.preventDefault(),s.onDismiss()))}}),Ns(()=>{if(!t)return;Zn.addLayer({node:t,isPointerBlocking:s.disableOutsidePointerEvents,dismiss:s.onDismiss});const u=n==null?void 0:n.registerNestedLayer(t);Zn.assignPointerEventToLayers(),Zn.disableBodyPointerEvents(t),nt(()=>{t&&(Zn.removeLayer(t),u==null||u(),Zn.assignPointerEventToLayers(),Zn.restoreBodyPointerEvents(t))})}),qe(ei([()=>t,()=>s.disableOutsidePointerEvents],([u,f])=>{if(!u)return;const h=Zn.find(u);h&&h.isPointerBlocking!==f&&(h.isPointerBlocking=f,Zn.assignPointerEventToLayers()),f&&Zn.disableBodyPointerEvents(u),nt(()=>{Zn.restoreBodyPointerEvents(u)})},{defer:!0}));const d={registerNestedLayer:a};return y(MS.Provider,{value:d,get children(){return y(zt,Se({as:"div",ref(u){var f=Mn(h=>t=h,s.ref);typeof f=="function"&&f(u)}},r))}})}function Zm(e){var a;const[t,n]=L((a=e.defaultValue)==null?void 0:a.call(e)),s=$e(()=>{var i;return((i=e.value)==null?void 0:i.call(e))!==void 0}),r=$e(()=>{var i;return s()?(i=e.value)==null?void 0:i.call(e):t()});return[r,i=>{zi(()=>{var l;const c=zT(i,r());return Object.is(c,r())||(s()||n(c),(l=e.onChange)==null||l.call(e,c)),c})}]}function DS(e){const[t,n]=Zm(e);return[()=>t()??!1,n]}function $W(e){const[t,n]=Zm(e);return[()=>t()??[],n]}function PS(e={}){const[t,n]=DS({value:()=>ge(e.open),defaultValue:()=>!!ge(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 OS(e,t){const[n,s]=L(rw(t==null?void 0:t()));return qe(()=>{var r;s(((r=e())==null?void 0:r.tagName.toLowerCase())||rw(t==null?void 0:t()))}),n}function rw(e){return bi(e)?e:void 0}var PM=Object.defineProperty,el=(e,t)=>{for(var n in t)PM(e,n,{get:t[n],enumerable:!0})},OM={};el(OM,{Button:()=>LM,Root:()=>tl});var RM=["button","color","file","image","reset","submit"];function IM(e){const t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?RM.indexOf(e.type)!==-1:!1}function tl(e){let t;const n=Dt({type:"button"},e),[s,r]=Et(n,["ref","type","disabled"]),o=OS(()=>t,()=>"button"),a=$e(()=>{const l=o();return l==null?!1:IM({tagName:l,type:s.type})}),i=$e(()=>o()==="input"),c=$e(()=>o()==="a"&&(t==null?void 0:t.getAttribute("href"))!=null);return y(zt,Se({as:"button",ref(l){var d=Mn(u=>t=u,s.ref);typeof d=="function"&&d(l)},get type(){return _e(()=>!!(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 _e(()=>!!(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 LM=tl;function ds(e){return t=>(e(t),()=>e(void 0))}var kn=e=>typeof e=="function"?e():e,Zg=(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},Ol=new Map,FM=e=>{qe(()=>{const t=kn(e.style)??{},n=kn(e.properties)??[],s={};for(const o in t)s[o]=e.element.style[o];const r=Ol.get(e.key);r?r.activeCount++:Ol.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);nt(()=>{var a;const o=Ol.get(e.key);if(o){if(o.activeCount!==1){o.activeCount--;return}Ol.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)}})})},ow=FM,NM=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},UM=(e,t)=>{const n=getComputedStyle(e),s=t==="x"?n.overflowX:n.overflowY;return s==="auto"||s==="scroll"||e.tagName==="HTML"&&s==="visible"},BM=(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]=NM(r,t),u=d-c-s*l;(l!==0||u!==0)&&UM(r,t)&&(o+=u,a+=l),r===(n??document.documentElement)?i=!0:r=r._$host??r.parentElement}while(r&&!i);return[o,a]},[iw,aw]=L([]),KM=e=>iw().indexOf(e)===iw().length-1,VM=e=>{const t=Se({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=ti();let s=[0,0],r=null,o=null;qe(()=>{kn(t.enabled)&&(aw(l=>[...l,n]),nt(()=>{aw(l=>l.filter(d=>d!==n))}))}),qe(()=>{if(!kn(t.enabled)||!kn(t.hideScrollbar))return;const{body:l}=document,d=window.innerWidth-l.offsetWidth;if(kn(t.preventScrollbarShift)){const u={overflow:"hidden"},f=[];d>0&&(kn(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 h=window.scrollY,m=window.scrollX;ow({key:"prevent-scroll",element:l,style:u,properties:f,cleanup:()=>{kn(t.restoreScrollPosition)&&d>0&&window.scrollTo(m,h)}})}else ow({key:"prevent-scroll",element:l,style:{overflow:"hidden"}})}),qe(()=>{!KM(n)||!kn(t.enabled)||(document.addEventListener("wheel",i,{passive:!1}),document.addEventListener("touchstart",a,{passive:!1}),document.addEventListener("touchmove",c,{passive:!1}),nt(()=>{document.removeEventListener("wheel",i),document.removeEventListener("touchstart",a),document.removeEventListener("touchmove",c)}))});const a=l=>{s=cw(l),r=null,o=null},i=l=>{const d=l.target,u=kn(t.element),f=jM(l),h=Math.abs(f[0])>Math.abs(f[1])?"x":"y",m=h==="x"?f[0]:f[1],w=lw(d,h,m,u);let S;u&&Zg(u,d)?S=!w:S=!0,S&&l.cancelable&&l.preventDefault()},c=l=>{const d=kn(t.element),u=l.target;let f;if(l.touches.length===2)f=!kn(t.allowPinchZoom);else{if(r==null||o===null){const h=cw(l).map((w,S)=>s[S]-w),m=Math.abs(h[0])>Math.abs(h[1])?"x":"y";r=m,o=m==="x"?h[0]:h[1]}if(u.type==="range")f=!1;else{const h=lw(u,r,o,d);d&&Zg(d,u)?f=!h:f=!0}}f&&l.cancelable&&l.preventDefault()}},jM=e=>[e.deltaX,e.deltaY],cw=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],lw=(e,t,n,s)=>{const r=s!==null&&Zg(s,e),[o,a]=BM(e,t,r?s:void 0);return!(n>0&&Math.abs(o)<=1||n<0&&Math.abs(a)<1)},qM=VM,RS=qM,zM=e=>{const t=$e(()=>{const a=kn(e.element);if(a)return getComputedStyle(a)}),n=()=>{var a;return((a=t())==null?void 0:a.animationName)??"none"},[s,r]=L(kn(e.show)?"present":"hidden");let o="none";return qe(a=>{const i=kn(e.show);return zi(()=>{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}),qe(()=>{const a=kn(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),nt(()=>{a.removeEventListener("animationstart",i),a.removeEventListener("animationcancel",c),a.removeEventListener("animationend",c)})}),{present:()=>s()==="present"||s()==="hiding",state:s,setState:r}},WM=zM,Jg=WM,HM={};el(HM,{CloseButton:()=>LS,Content:()=>FS,Description:()=>NS,Dialog:()=>_t,Overlay:()=>US,Portal:()=>BS,Root:()=>KS,Title:()=>VS,Trigger:()=>jS,useDialogContext:()=>vo});var IS=Ir();function vo(){const e=Lr(IS);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function LS(e){const t=vo(),[n,s]=Et(e,["aria-label","onClick"]);return y(tl,Se({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:o=>{Zt(o,n.onClick),t.close()}},s))}function FS(e){let t;const n=vo(),s=Dt({id:n.generateId("content")},e),[r,o]=Et(s,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]);let a=!1,i=!1;const c=f=>{var h;(h=r.onPointerDownOutside)==null||h.call(r,f),n.modal()&&f.detail.isContextMenu&&f.preventDefault()},l=f=>{var h;(h=r.onFocusOutside)==null||h.call(r,f),n.modal()&&f.preventDefault()},d=f=>{var h;(h=r.onInteractOutside)==null||h.call(r,f),!n.modal()&&(f.defaultPrevented||(a=!0,f.detail.originalEvent.type==="pointerdown"&&(i=!0)),pr(n.triggerRef(),f.target)&&f.preventDefault(),f.detail.originalEvent.type==="focusin"&&i&&f.preventDefault())},u=f=>{var h;(h=r.onCloseAutoFocus)==null||h.call(r,f),n.modal()?(f.preventDefault(),xn(n.triggerRef())):(f.defaultPrevented||(a||xn(n.triggerRef()),f.preventDefault()),a=!1,i=!1)};return TS({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),RS({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),CS({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:r.onOpenAutoFocus,onUnmountAutoFocus:u},()=>t),qe(()=>nt(n.registerContentId(o.id))),y(Q,{get when(){return n.contentPresent()},get children(){return y(AS,Se({ref(f){var h=Mn(m=>{n.setContentRef(m),t=m},r.ref);typeof h=="function"&&h(f)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return _e(()=>!!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 NS(e){const t=vo(),n=Dt({id:t.generateId("description")},e),[s,r]=Et(n,["id"]);return qe(()=>nt(t.registerDescriptionId(s.id))),y(zt,Se({as:"p",get id(){return s.id}},r))}function US(e){const t=vo(),[n,s]=Et(e,["ref","style","onPointerDown"]),r=o=>{Zt(o,n.onPointerDown),o.target===o.currentTarget&&o.preventDefault()};return y(Q,{get when(){return t.overlayPresent()},get children(){return y(zt,Se({as:"div",ref(o){var a=Mn(t.setOverlayRef,n.ref);typeof a=="function"&&a(o)},get style(){return Qc({"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 BS(e){const t=vo();return y(Q,{get when(){return t.contentPresent()||t.overlayPresent()},get children(){return y(Km,e)}})}var dw={dismiss:"Dismiss"};function KS(e){const t=`dialog-${ti()}`,n=Dt({id:t,modal:!0,translations:dw},e),[s,r]=L(),[o,a]=L(),[i,c]=L(),[l,d]=L(),[u,f]=L(),[h,m]=L(),w=PS({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:$=>{var C;return(C=n.onOpenChange)==null?void 0:C.call(n,$)}}),S=()=>n.forceMount||w.isOpen(),{present:b}=Jg({show:S,element:()=>l()??null}),{present:v}=Jg({show:S,element:()=>u()??null}),k={translations:()=>n.translations??dw,isOpen:w.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??k.modal(),contentId:s,titleId:o,descriptionId:i,triggerRef:h,overlayRef:l,setOverlayRef:d,contentRef:u,setContentRef:f,overlayPresent:b,contentPresent:v,close:w.close,toggle:w.toggle,setTriggerRef:m,generateId:Ea(()=>n.id),registerContentId:ds(r),registerTitleId:ds(a),registerDescriptionId:ds(c)};return y(IS.Provider,{value:k,get children(){return n.children}})}function VS(e){const t=vo(),n=Dt({id:t.generateId("title")},e),[s,r]=Et(n,["id"]);return qe(()=>nt(t.registerTitleId(s.id))),y(zt,Se({as:"h2",get id(){return s.id}},r))}function jS(e){const t=vo(),[n,s]=Et(e,["ref","onClick"]);return y(tl,Se({ref(o){var a=Mn(t.setTriggerRef,n.ref);typeof a=="function"&&a(o)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return _e(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:o=>{Zt(o,n.onClick),t.toggle()}},s))}var _t=Object.assign(KS,{CloseButton:LS,Content:FS,Description:NS,Overlay:US,Portal:BS,Title:VS,Trigger:jS});const[ld,_u]=L(null);function Cs(e,t){_u({type:"alert",message:e,...t})}function Wi(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(s=>{_u({type:"confirm",message:e,...t,resolve:s})})}function GM(e,t){const n=typeof document<"u"?document.activeElement:null;return n==null||n.blur(),new Promise(s=>{_u({type:"prompt",message:e,...t,resolvePrompt:s})})}function Xf(){_u(null)}var ZM=F('<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">'),JM=F('<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>'),YM=F('<div class="mt-6 flex justify-end gap-3"><button type=button class=button-primary>'),QM=F('<p class="mt-2 text-secondary">'),XM=F("<button type=button class=button-secondary>");const e2={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 Rl(e,t,n){var r,o,a,i,c,l,d,u;const s=t??ld();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),Xf();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)),Xf();return}e&&((u=s==null?void 0:s.onConfirm)==null||u.call(s)),Xf()}const t2=()=>{const{t:e}=kt();let t,n;return qe(()=>{const s=ld();!s||Wf.required()||queueMicrotask(()=>{if(!(Wf.required()||ld()!==s)){if(s.type==="prompt"){n==null||n.focus(),n==null||n.select();return}t==null||t.focus()}})}),y(Q,{get when(){return ld()},keyed:!0,children:s=>{const r=s.variant??"info",o=e2[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,h]=L(s.inputDefaultValue??"");return y(_t,{get open(){return!Wf.required()},modal:!0,onOpenChange:m=>{!m&&s.dismissible!==!1&&Rl(!1,s)},get children(){return y(_t.Portal,{get children(){return[y(_t.Overlay,{class:"modal-overlay z-[60]"}),y(_t.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=ZM(),w=m.firstChild,S=w.nextSibling;return p(w,()=>o.symbol),p(S,y(_t.Title,{class:"text-lg font-semibold text-primary",children:i}),null),p(S,y(_t.Description,{class:"text-sm text-secondary mt-1 whitespace-pre-line break-words",get children(){return[_e(()=>s.message),_e(()=>_e(()=>!!s.detail)()&&(()=>{var b=QM();return p(b,()=>s.detail),b})())]}}),null),de(b=>{var v=o.badgeBg,k=o.badgeBorder,$=o.badgeText;return v!==b.e&&Hf(w,"background-color",b.e=v),k!==b.t&&Hf(w,"border-color",b.t=k),$!==b.a&&Hf(w,"color",b.a=$),b},{e:void 0,t:void 0,a:void 0}),m})(),y(Q,{when:l,get children(){var m=JM(),w=m.firstChild,S=w.nextSibling;return p(w,()=>s.inputLabel||e("alertDialog.prompt.inputLabel")),S.$$keydown=b=>{b.key==="Enter"&&(b.preventDefault(),Rl(!0,s,f()))},S.$$input=b=>h(b.currentTarget.value),Xs(b=>{n=b},S),pe(S,"spellcheck",!1),de(()=>pe(S,"placeholder",s.inputPlaceholder||"")),de(()=>S.value=f()),m}}),(()=>{var m=YM(),w=m.firstChild;return p(m,(c||l)&&(()=>{var S=XM();return S.$$click=()=>Rl(!1,s),p(S,u),S})(),w),w.$$click=()=>Rl(!0,s,f()),Xs(S=>{t=S},w),p(w,d),m})()]}})]}})}})}})};Ht(["input","keydown","click"]);function n2(e,t,n){if(e.has(t))return e;const s=new Map(e);return s.set(t,n),s}function s2(e,t){return e==="disconnected"||e==="error"?e:t!=="connected"?"connecting":e}const _o=Lt("sse"),[uw,fw]=L(new Map),[r2,o2]=L("connecting");class i2{constructor(){_o.info("sseManager initialized: listening for SSE disconnect and reconnect"),fs.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)}}),fs.on("instance.event",t=>{const n=t;this.updateConnectionStatus(n.instanceId,"connected"),this.handleEvent(n.instanceId,n.event)}),fs.onTransportStatus(t=>{_o.info("SSE transport status changed",{status:t}),o2(t)})}seedStatus(t,n){this.updateConnectionStatus(t,n)}seedStatusIfMissing(t,n){fw(s=>n2(s,t,n))}handleEvent(t,n){var s,r,o,a,i,c,l,d,u,f,h,m,w,S,b,v;if(!n||typeof n!="object"||typeof n.type!="string"){_o.warn("Dropping malformed event",n);return}switch(_o.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":(h=this.onPermissionReplied)==null||h.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($=>{_o.warn("Failed to handle worktree ready event",{instanceId:t,error:$})})}catch(k){_o.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=>_o.warn("Failed to refresh native worktrees",k));break;default:(v=this.onNativeSessionEvent)==null||v.call(this,t,n)}}updateConnectionStatus(t,n){fw(s=>{if(s.get(t)===n)return s;const r=new Map(s);return r.set(t,n),r})}getStatus(t){return s2(uw().get(t)??null,r2())}getStatuses(){return uw()}}const ln=new i2,[er,Cu]=L(),[Yg,Hi]=L(!1),[ni,Qg]=L(!1),[Xg,_c]=L(!1),[eh,$d]=L(),[Qa,th]=L(),[nh,sh]=L(!1),[rh,Uo]=L();let Jn=0,gw=-1,Mo;const[Jm,Ym]=L(),qS=()=>!!Jm();function fc(e=er()){return(e==null?void 0:e.serviceState)==="ready"||(e==null?void 0:e.serviceState)==="restart_available"}async function zS(){if(!fc()||ni())return;const e=Jm();Ym(void 0),Hi(!1),await(e==null?void 0:e())}function oh(e=er()){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 Qm(e){e&&Ym(()=>e),Uo(void 0),Hi(!0),Gs()}function a2(){ni()||gw===Jn||(gw=Jn,Qm())}function WS(){Jn++,Mo=void 0,Cu(void 0),Uo(void 0),Gs()}function Gs(e=!1,t=!1){if(ni()&&!e)return Promise.resolve();if(Mo)return Mo;const n=Jn;sh(!0),t&&Uo(void 0);const s=ft.fetchOpenCodeUpdateStatus().then(r=>{n===Jn&&(Cu(r),_c(!1),$d(void 0),t&&Uo("checked"))}).catch(()=>{n===Jn&&_c(!0)}).finally(()=>{Mo===s&&(Mo=void 0,sh(!1))});return Mo=s,s}async function Xa(e){var n,s;if(ni())return;const t=++Jn;Mo=void 0,Qg(!0),th(e),Uo(void 0),_c(!1),$d(void 0);try{if(e==="install"&&await ft.updateOpenCode(),t!==Jn||(await Gs(!0),t!==Jn)||e!=="restart"&&(((n=er())==null?void 0:n.serviceState)==="restart_required"||((s=er())==null?void 0:s.serviceState)==="incompatible"))return;const r=e==="reload"?await ft.reloadOpenCodeConfiguration():await ft.startOpenCode(e==="restart");if(t!==Jn)return;if(Cu(r),r.state==="ready"&&(r.serviceState==="ready"||r.serviceState==="restart_available")){const o=Jm();Ym(void 0),e==="reload"&&Uo("reloaded"),o&&r.serviceState==="ready"&&Hi(!1),await(o==null?void 0:o())}}catch(r){if(t===Jn){if(await Gs(!0),t!==Jn)return;_c(!0),r instanceof Error&&(r.message==="installation_busy"||r.message==="installation_in_use")&&$d(r.message)}}finally{Qg(!1),th(void 0),t!==Jn&&Gs()}}const c2=Object.freeze(Object.defineProperty({__proto__:null,canContinueOpenCodeSetup:qS,continueOpenCodeSetup:zS,invalidateOpenCodeSetup:WS,isOpenCodeConnected:fc,needsOpenCodeSetup:oh,openCodeInstallationError:eh,openCodeSetupAction:Qa,openCodeSetupBusy:ni,openCodeSetupChecking:nh,openCodeSetupError:Xg,openCodeSetupFeedback:rh,openCodeSetupOpen:Yg,openCodeSetupStatus:er,openOpenCodeSetup:Qm,refreshOpenCodeSetup:Gs,reportOpenCodeSetupRequired:a2,runOpenCodeSetup:Xa,setOpenCodeInstallationError:$d,setOpenCodeSetupAction:th,setOpenCodeSetupBusy:Qg,setOpenCodeSetupChecking:sh,setOpenCodeSetupError:_c,setOpenCodeSetupFeedback:Uo,setOpenCodeSetupOpen:Hi,setOpenCodeSetupStatus:Cu},Symbol.toStringTag,{value:"Module"}));var l2=F("<p class=settings-error-message role=alert>"),Co=F("<p role=status>"),d2=F("<div class=opencode-setup-panel><div class=settings-info-actions><button type=button class=settings-pill-button>"),u2=F("<p class=settings-toggle-title role=status>"),f2=F("<div class=settings-info-grid><div class=settings-info-row><span></span><span></span></div><div class=settings-info-row><span></span><span>"),g2=F('<p class="settings-toggle-caption break-all">'),Il=F("<p class=settings-toggle-caption>"),hw=F("<p role=alert>"),h2=F("<p>"),Ll=F("<button type=button class=settings-pill-button>"),m2=F("<div class=settings-info-actions>"),p2=F("<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>"),y2=F("<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 HS(e={}){const{t}=kt(),n=()=>ni()||nh();return(()=>{var s=d2(),r=s.firstChild,o=r.firstChild;return p(s,y(Q,{get when(){return er()},get fallback(){return(()=>{var a=Co();return p(a,()=>t(Xg()?"settings.opencode.update.checkFailed":"settings.opencode.update.checking")),a})()},children:a=>[(()=>{var i=u2();return p(i,()=>t(fc()?"settings.opencode.setup.connected":a().state==="ready"?"settings.opencode.setup.disconnected":`settings.opencode.setup.${a().state}`)),i})(),(()=>{var i=f2(),c=i.firstChild,l=c.firstChild,d=l.nextSibling,u=c.nextSibling,f=u.firstChild,h=f.nextSibling;return p(l,()=>t("settings.opencode.update.installed")),p(d,()=>a().currentVersion??"—"),p(f,()=>t("settings.opencode.setup.daemon")),p(h,()=>a().daemonVersion??"—"),i})(),(()=>{var i=g2();return p(i,()=>a().binaryPath),i})(),y(Q,{get when(){return a().installationSource},children:i=>(()=>{var c=Il();return p(c,()=>t(`settings.opencode.setup.source.${i()}`)),c})()}),y(Q,{get when(){return _e(()=>!!a().updateAvailable)()&&a().latestVersion},get children(){var i=Co();return p(i,()=>t("settings.opencode.update.available",{version:a().latestVersion??""})),i}}),y(Q,{get when(){return _e(()=>!!(a().updateAvailable===!1&&a().latestVersion))()&&!a().checkError},get children(){var i=Co();return p(i,()=>t("settings.opencode.update.upToDate")),i}}),y(Q,{get when(){return a().target==="wsl"},get children(){var i=Il();return p(i,()=>t("settings.opencode.setup.wsl")),i}}),y(Q,{get when(){return a().serviceState==="restart_required"||a().serviceState==="restart_available"},get children(){var i=Co();return p(i,()=>t(a().serviceState==="restart_required"?"settings.opencode.setup.restartRequired":"settings.opencode.setup.restartAvailable")),i}}),y(Q,{get when(){return a().serviceState==="error"},get children(){var i=hw();return p(i,()=>t("settings.opencode.setup.serviceError")),i}}),y(Q,{get when(){return a().checkError},get children(){var i=Co();return p(i,()=>t("settings.opencode.update.checkFailed")),i}}),y(Q,{get when(){return _e(()=>!a().canUpgrade)()&&(a().updateAvailable||a().state==="missing"||a().state==="update_required"||a().serviceState==="incompatible")},get children(){var i=h2();return p(i,()=>t("settings.opencode.setup.manual")),i}}),y(Q,{get when(){return _e(()=>!!(a().daemonVersion||a().currentVersion))()&&a().versionAssessment==="untested"},get children(){var i=Il();return p(i,()=>t("settings.opencode.setup.untested",{version:a().daemonVersion??a().currentVersion??""})),i}}),(()=>{var i=m2();return p(i,y(Q,{get when(){return a().canUpgrade},get children(){var c=Ll();return c.$$click=()=>void Xa("install"),p(c,(()=>{var l=_e(()=>Qa()==="install");return()=>l()?t("settings.opencode.update.updating"):_e(()=>!!a().needsSharedInstallation)()?t("settings.opencode.setup.sharedInstall"):_e(()=>a().state==="missing")()?t("settings.opencode.setup.install"):t("settings.opencode.update.action",{version:a().latestVersion??""})})()),de(()=>c.disabled=n()),c}}),null),p(i,y(Q,{get when(){return _e(()=>a().state==="ready"&&!fc()&&a().serviceState!=="restart_required")()&&a().serviceState!=="incompatible"},get children(){var c=Ll();return c.$$click=()=>void Xa("start"),p(c,()=>t("settings.opencode.setup.connect")),de(()=>c.disabled=n()),c}}),null),p(i,y(Q,{get when(){return _e(()=>!!fc())()&&qS()},get children(){var c=Ll();return c.$$click=()=>void zS(),p(c,()=>t("settings.opencode.setup.continue")),de(()=>c.disabled=n()),c}}),null),p(i,y(Q,{get when(){return a().canRestart},get children(){var c=Ll();return c.$$click=()=>void Xa("restart"),p(c,()=>t("settings.opencode.setup.restart")),de(()=>c.disabled=n()),c}}),null),i})(),y(Q,{get when(){return _e(()=>!!a().canUpgrade)()&&(a().state==="missing"||a().needsSharedInstallation)},get children(){var i=Il();return p(i,()=>t("settings.opencode.setup.sharedInstallDescription")),i}})]}),r),p(s,y(Q,{get when(){return Xg()},get children(){var a=l2();return p(a,()=>t(eh()?`settings.opencode.setup.${eh()}`:"settings.opencode.setup.actionFailed")),a}}),r),p(s,y(Q,{get when(){return Qa()},get children(){var a=Co();return p(a,()=>t(Qa()==="install"?"settings.opencode.update.updating":`settings.opencode.setup.progress.${Qa()}`)),a}}),r),p(s,y(Q,{get when(){return rh()},get children(){var a=Co();return p(a,()=>t(`settings.opencode.setup.${rh()}`)),a}}),r),o.$$click=()=>void Gs(!1,!0),p(o,()=>t(nh()?"settings.opencode.update.checking":"settings.opencode.setup.check")),p(s,()=>e.children,null),p(s,y(Q,{get when(){return er()},children:a=>[(()=>{var i=p2(),c=i.firstChild,l=c.nextSibling,d=l.firstChild,u=d.firstChild,f=u.nextSibling,h=d.nextSibling,m=h.firstChild,w=m.nextSibling,S=l.nextSibling;return p(c,()=>t("settings.opencode.setup.diagnostics")),p(u,()=>t("settings.opencode.setup.minimum")),p(f,()=>a().minimumVersion),p(m,()=>t("settings.opencode.setup.recommended")),p(w,()=>a().recommendedVersion),p(S,()=>t("settings.opencode.setup.minimumReason",{version:a().minimumVersion})),p(i,y(Q,{get when(){return _e(()=>!!a().incompatibilityReason)()&&a().incompatibilityReason!=="step_timestamp"},get children(){var b=hw();return p(b,()=>t(`settings.opencode.setup.${a().incompatibilityReason}`)),b}}),null),i})(),y(Q,{get when(){return a().canReload},get children(){var i=y2(),c=i.firstChild,l=c.nextSibling,d=l.nextSibling,u=d.firstChild;return p(c,()=>t("settings.opencode.setup.troubleshooting")),p(l,()=>t("settings.opencode.setup.reloadDescription")),u.$$click=()=>void Xa("reload"),p(u,()=>t("settings.opencode.setup.reload")),de(()=>u.disabled=n()),i}})]}),null),de(a=>{var i=n(),c=n();return i!==a.e&&pe(s,"aria-busy",a.e=i),c!==a.t&&(o.disabled=a.t=c),a},{e:void 0,t:void 0}),s})()}Ht(["click"]);const yi={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 v2=F("<svg>");const w2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ye=e=>{const[t,n]=Et(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var s=v2();return Qs(s,Se(yi,{get width(){return t.size??yi.width},get height(){return t.size??yi.height},get stroke(){return t.color??yi.stroke},get"stroke-width"(){return _e(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??yi["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??yi["stroke-width"])},get class(){return`lucide lucide-${w2((t==null?void 0:t.name)??"icon")} ${t.class!=null?t.class:""}`}},n),!0,!0),p(s,y(Ut,{get each(){return t.iconNode},children:([r,o])=>y(Bm,Se({component:r},o))})),s})()},b2=[["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"}]],S2=e=>y(Ye,Se(e,{name:"AlertCircle",iconNode:b2})),k2=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],x2=e=>y(Ye,Se(e,{name:"ArrowLeft",iconNode:k2})),$2=[["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"}]],_2=e=>y(Ye,Se(e,{name:"ArrowRightSquare",iconNode:$2})),C2=[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]],E2=e=>y(Ye,Se(e,{name:"ArrowUpLeft",iconNode:C2})),T2=[["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"}]],GS=e=>y(Ye,Se(e,{name:"Bell",iconNode:T2})),M2=[["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"}]],A2=e=>y(Ye,Se(e,{name:"BookOpen",iconNode:M2})),D2=[["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"}]],P2=e=>y(Ye,Se(e,{name:"Brain",iconNode:D2})),O2=[["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"}]],R2=e=>y(Ye,Se(e,{name:"CheckSquare",iconNode:O2})),I2=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ZS=e=>y(Ye,Se(e,{name:"Check",iconNode:I2})),L2=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],tr=e=>y(Ye,Se(e,{name:"ChevronDown",iconNode:L2})),F2=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],N2=e=>y(Ye,Se(e,{name:"ChevronRight",iconNode:F2})),U2=[["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"}]],B2=e=>y(Ye,Se(e,{name:"ClipboardCheck",iconNode:U2})),K2=[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]],V2=e=>y(Ye,Se(e,{name:"Code",iconNode:K2})),j2=[["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"}]],q2=e=>y(Ye,Se(e,{name:"Coins",iconNode:j2})),z2=[["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"}]],Oi=e=>y(Ye,Se(e,{name:"ExternalLink",iconNode:z2})),W2=[["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"}]],H2=e=>y(Ye,Se(e,{name:"FileCog",iconNode:W2})),G2=[["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"}]],Z2=e=>y(Ye,Se(e,{name:"FileEdit",iconNode:G2})),J2=[["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"}]],Y2=e=>y(Ye,Se(e,{name:"File",iconNode:J2})),Q2=[["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"}]],X2=e=>y(Ye,Se(e,{name:"FolderOpen",iconNode:Q2})),eA=[["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"}]],tA=e=>y(Ye,Se(e,{name:"FolderPlus",iconNode:eA})),nA=[["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"}]],sA=e=>y(Ye,Se(e,{name:"Folder",iconNode:nA})),rA=[["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"}]],Bo=e=>y(Ye,Se(e,{name:"Globe",iconNode:rA})),oA=[["path",{d:"M22 10v6M2 10l10-5 10 5-10 5z",key:"1ef52a"}],["path",{d:"M6 12v5c3 3 9 3 12 0v-5",key:"1f75yj"}]],iA=e=>y(Ye,Se(e,{name:"GraduationCap",iconNode:oA})),aA=[["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"}]],cA=e=>y(Ye,Se(e,{name:"HelpCircle",iconNode:aA})),lA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Xm=e=>y(Ye,Se(e,{name:"Info",iconNode:lA})),dA=[["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"}]],uA=e=>y(Ye,Se(e,{name:"KeyRound",iconNode:dA})),fA=[["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"}]],mw=e=>y(Ye,Se(e,{name:"Key",iconNode:fA})),gA=[["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"}]],hA=e=>y(Ye,Se(e,{name:"Languages",iconNode:gA})),mA=[["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"}]],pA=e=>y(Ye,Se(e,{name:"LayoutGrid",iconNode:mA})),yA=[["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"}]],dd=e=>y(Ye,Se(e,{name:"Link2",iconNode:yA})),vA=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Nn=e=>y(Ye,Se(e,{name:"Loader2",iconNode:vA})),wA=[["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"}]],bA=e=>y(Ye,Se(e,{name:"LogIn",iconNode:wA})),SA=[["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"}]],kA=e=>y(Ye,Se(e,{name:"Maximize2",iconNode:SA})),xA=[["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"}]],$A=e=>y(Ye,Se(e,{name:"MessageSquare",iconNode:xA})),_A=[["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"}]],eg=e=>y(Ye,Se(e,{name:"Mic",iconNode:_A})),CA=[["path",{d:"M5 12h14",key:"1ays0h"}]],EA=e=>y(Ye,Se(e,{name:"Minus",iconNode:CA})),TA=[["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"}]],MA=e=>y(Ye,Se(e,{name:"MonitorUp",iconNode:TA})),AA=[["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"}]],DA=e=>y(Ye,Se(e,{name:"Network",iconNode:AA})),PA=[["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"}]],OA=e=>y(Ye,Se(e,{name:"Paperclip",iconNode:PA})),RA=[["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"}]],IA=e=>y(Ye,Se(e,{name:"Pencil",iconNode:RA})),LA=[["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"}]],JS=e=>y(Ye,Se(e,{name:"PlugZap",iconNode:LA})),FA=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Eu=e=>y(Ye,Se(e,{name:"Plus",iconNode:FA})),NA=[["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"}]],_d=e=>y(Ye,Se(e,{name:"RefreshCw",iconNode:NA})),UA=[["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"}]],BA=e=>y(Ye,Se(e,{name:"Save",iconNode:UA})),KA=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],pw=e=>y(Ye,Se(e,{name:"Search",iconNode:KA})),VA=[["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"}]],Fl=e=>y(Ye,Se(e,{name:"Settings",iconNode:VA})),jA=[["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"}]],yw=e=>y(Ye,Se(e,{name:"ShieldOff",iconNode:jA})),qA=[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}]],Cd=e=>y(Ye,Se(e,{name:"Shield",iconNode:qA})),zA=[["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"}]],WA=e=>y(Ye,Se(e,{name:"SlidersHorizontal",iconNode:zA})),HA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],vw=e=>y(Ye,Se(e,{name:"Square",iconNode:HA})),GA=[["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"}]],ZA=e=>y(Ye,Se(e,{name:"Stethoscope",iconNode:GA})),JA=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],ep=e=>y(Ye,Se(e,{name:"Terminal",iconNode:JA})),YA=[["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"}]],Tu=e=>y(Ye,Se(e,{name:"Trash2",iconNode:YA})),QA=[["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"}]],ih=e=>y(Ye,Se(e,{name:"Volume2",iconNode:QA})),XA=[["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"}]],eD=e=>y(Ye,Se(e,{name:"Wifi",iconNode:XA})),tD=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ko=e=>y(Ye,Se(e,{name:"X",iconNode:tD})),ww="__drives__",ah="opencode_v2_required",nD="session_environment_failed";var sD=F('<button type=button class="selector-button selector-button-secondary directory-browser-select directory-browser-new-folder"><span class="inline-flex items-center gap-2">'),rD=F('<div class=directory-browser-current><span class=directory-browser-current-label></span><input type=text class="selector-input directory-browser-current-path"><button type=button class="selector-button selector-button-secondary directory-browser-open-path"><span>'),oD=F('<div class="panel-list panel-list--fill flex-1 min-h-0 overflow-auto directory-browser-list"role=listbox>'),iD=F('<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">'),aD=F("<div class=directory-browser-loading><span>"),bw=F('<div class="panel-empty-state flex-1">'),cD=F("<span class=text-red-500>"),lD=F('<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>'),dD=F('<button type=button class="selector-button selector-button-secondary directory-browser-select">');function ja(e){if(!e||e==="."||e==="./")return".";if(e===ww)return ww;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 YS(e){return e.startsWith("/")||/^[a-zA-Z]:/.test(e)||e.startsWith("\\\\")}function QS(e,t){if(!e)return t;if(!t||t==="."||t==="./")return e;if(YS(t))return t;const n=e.includes("\\")?"\\":"/",s=e.endsWith(n)?e:`${e}${n}`,r=t.replace(/[\\/]+/g,n).replace(/^[\\/]+/,"");return`${s}${r}`}function Nl(e){return!e||e.pathKind==="drives"?"":e.pathKind==="relative"?QS(e.rootPath,e.currentPath):e.displayPath}const uD=e=>{const{t}=kt(),[n,s]=L(""),[r,o]=L(!1),[a,i]=L(null),[c,l]=L(""),[d,u]=L(!1),[f,h]=L(!1),[m,w]=L(new Map),[S,b]=L(new Set),[v,k]=L(null),[$,C]=L(null),T=new Map,D=new Map;let R=0;function q(){s(""),w(new Map),b(new Set),k(null),C(null),l(""),u(!1),T.clear(),D.clear(),i(null)}qe(()=>{if(!e.open)return;q(),re();const O=g=>{g.key==="Escape"&&(g.preventDefault(),e.onClose())};window.addEventListener("keydown",O),nt(()=>{window.removeEventListener("keydown",O)})});async function re(){var O;o(!0);try{const g=(O=e.initialPath)==null?void 0:O.trim();if(g){if(await U(g))return;i(null)}await U(void 0)}finally{o(!1)}}function ee(O){const g=ja(O.currentPath);k(g),C(O),s(O.rootPath)}async function W(O){const g=O?ja(O):void 0;if(g){const A=T.get(g);if(A)return A;const E=D.get(g);if(E)return E}const x=(async()=>{g&&b(B=>{const oe=new Set(B);return oe.add(g),oe});const A=await ft.listFileSystem(O,{includeFiles:e.mode==="files"}),E=ja(A.metadata.currentPath),H=A.entries.filter(B=>e.mode==="files"||B.type==="directory").sort((B,oe)=>{const Ae=B.type==="directory"?0:1,we=oe.type==="directory"?0:1;return Ae!==we?Ae-we:B.name.localeCompare(oe.name)});return w(B=>{const oe=new Map(B);return oe.set(E,H),oe}),T.set(E,A.metadata),b(B=>{const oe=new Set(B);return g&&oe.delete(g),oe.delete(E),oe}),A.metadata})().catch(A=>{throw g&&b(E=>{const H=new Set(E);return H.delete(g),H}),A}).finally(()=>{g&&D.delete(g)});return g&&D.set(g,x),x}async function U(O){const g=++R;i(null);try{const x=await W(O);return g!==R?null:(ee(x),x)}catch(x){if(g!==R)return null;const A=x instanceof Error?x.message:t("directoryBrowser.load.errorFallback");return i(A),null}}const J=$e(()=>{const O=[],g=$();g!=null&&g.parentPath&&O.push({type:"up",path:g.parentPath});const x=v();if(!x)return O;const A=m().get(x)??[];for(const E of A)O.push({type:"entry",entry:E});return O});function le(O){u(!1),U(O)}function z(){var g;const O=(g=$())==null?void 0:g.parentPath;O&&(u(!1),U(O))}const M=$e(()=>Nl($()));qe(()=>{const O=M();d()||l(O)});const N=$e(()=>!!M()),ce=$e(()=>c().trim().length>0);async function fe(){const O=c().trim();if(!O)return;const g=await U(O);g&&(u(!1),l(Nl(g)))}async function Re(){const O=c().trim(),g=O&&O!==M()?await U(O):$();if(!g)return;u(!1);const x=Nl(g);x&&e.mode!=="files"&&(l(x),e.onSelect(x))}function be(O){const g=O.absolutePath?O.absolutePath:YS(O.path)?O.path:QS(n(),O.path);e.onSelect(g,O)}async function ye(){var A;if(f())return;const O=c().trim(),g=O&&O!==M()?await U(O):$();if(!g||g.pathKind==="drives")return;u(!1),l(Nl(g));const x=((A=await GM(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:A.trim())??"";if(x){if(x==="."||x===".."||x.startsWith("~")||x.includes("/")||x.includes("\\")){Cs(t("directoryBrowser.createFolder.invalidNameMessage"),{variant:"warning",detail:t("directoryBrowser.createFolder.invalidNameDetail")});return}h(!0);try{const E=ja(g.currentPath);T.delete(E),D.delete(E),w(B=>{const oe=new Map(B);return oe.delete(E),oe});const H=await ft.createFileSystemFolder(g.currentPath,x);await U(H.path)}catch(E){const H=E instanceof Error?E.message:t("directoryBrowser.createFolder.errorFallback");Cs(H,{variant:"error",title:t("directoryBrowser.createFolder.errorFallback")})}finally{h(!1)}}}function Ce(O){return S().has(ja(O))}function je(O){O.target===O.currentTarget&&e.onClose()}return y(Q,{get when(){return e.open},get children(){var O=iD(),g=O.firstChild,x=g.firstChild,A=x.firstChild,E=A.firstChild,H=E.firstChild,B=H.nextSibling,oe=E.nextSibling,Ae=A.nextSibling;return O.$$click=je,p(H,()=>e.title),p(B,()=>e.description||t("directoryBrowser.defaultDescription")),cS(oe,"click",e.onClose,!0),p(oe,y(Ko,{class:"w-5 h-5"})),p(Ae,y(Q,{get when(){return n()},get children(){var we=rD(),he=we.firstChild,Ee=he.nextSibling,Ge=Ee.nextSibling,Xe=Ge.firstChild;return p(he,()=>t("directoryBrowser.currentFolder")),Ee.$$keydown=se=>{se.key==="Enter"&&(se.preventDefault(),fe())},Ee.$$input=se=>{l(se.currentTarget.value),u(!0)},pe(Ee,"spellcheck",!1),p(we,y(Q,{get when(){return e.mode!=="files"},get children(){var se=sD(),V=se.firstChild;return se.$$click=()=>void ye(),p(V,y(tA,{class:"w-4 h-4"}),null),p(V,(()=>{var Y=_e(()=>!!f());return()=>Y()?t("directoryBrowser.creating"):t("directoryBrowser.newFolder")})(),null),de(()=>se.disabled=!N()||f()),se}}),Ge),Ge.$$click=()=>void Re(),p(Ge,y(_2,{class:"w-4 h-4"}),Xe),p(Xe,()=>t("directoryBrowser.openCurrent")),de(se=>{var V=t("directoryBrowser.currentFolder.inputPlaceholder"),Y=t("directoryBrowser.currentFolder.inputAriaLabel"),Oe=!N()&&!ce()||f(),ve=t("directoryBrowser.openCurrent"),Ie=t("directoryBrowser.openCurrent");return V!==se.e&&pe(Ee,"placeholder",se.e=V),Y!==se.t&&pe(Ee,"aria-label",se.t=Y),Oe!==se.a&&(Ge.disabled=se.a=Oe),ve!==se.o&&pe(Ge,"title",se.o=ve),Ie!==se.i&&pe(Ge,"aria-label",se.i=Ie),se},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),de(()=>Ee.value=c()),we}}),null),p(Ae,y(Q,{get when(){return _e(()=>!r())()&&!a()},get fallback(){return(()=>{var we=bw();return p(we,y(Q,{get when(){return r()},get fallback(){return(()=>{var he=cD();return p(he,a),he})()},get children(){var he=aD(),Ee=he.firstChild;return p(he,y(Nn,{class:"w-5 h-5 animate-spin"}),Ee),p(Ee,()=>t("directoryBrowser.loadingFolders")),he}})),we})()},get children(){return y(Q,{get when(){return J().length>0},get fallback(){return(()=>{var we=bw();return p(we,()=>t("directoryBrowser.noFolders")),we})()},get children(){var we=oD();return p(we,y(Ut,{get each(){return J()},children:he=>{const Ee=he.type==="entry",Ge=Ee&&he.entry.type==="directory",Xe=Ee&&(e.mode==="files"?he.entry.type==="file":he.entry.type==="directory"),se=Ee?he.entry.name||he.entry.path:t("directoryBrowser.upOneLevel"),V=()=>{if(!Ee){z();return}if(he.entry.type==="directory"){le(he.entry.path);return}be(he.entry)};return(()=>{var Y=lD(),Oe=Y.firstChild,ve=Oe.firstChild,Ie=ve.firstChild,Le=Ie.nextSibling,ze=Le.firstChild;return ve.$$click=V,p(Ie,y(Q,{when:!Ge,get fallback(){return y(sA,{class:"w-4 h-4"})},get children(){return y(Q,{when:Ee,get fallback(){return y(E2,{class:"w-4 h-4"})},get children(){return y(Y2,{class:"w-4 h-4"})}})}})),p(ze,se),p(ve,y(Q,{get when(){return Ge&&Ee&&Ce(he.entry.path)},get children(){return y(Nn,{class:"directory-browser-row-spinner animate-spin"})}}),null),p(Oe,Xe?(()=>{var Ne=dD();return Ne.$$click=Je=>{Je.stopPropagation(),Ee&&be(he.entry)},p(Ne,()=>t("directoryBrowser.select")),Ne})():null,null),Y})()}})),we}})}}),null),de(()=>pe(oe,"aria-label",t("directoryBrowser.close"))),O}})};Ht(["click","input","keydown"]);const fD=Lt("actions");function gD(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 hD(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=gD(n);return e.multiple?s:s[0]??null}catch(n){return fD.error("[native] electron dialog failed",n),null}}async function mD(e={}){return typeof e=="object"&&Object.freeze(e),await vs("plugin:dialog|open",{options:e})}const pD=Lt("actions");async function yD(e){var t;if(typeof window>"u")return null;try{const n=await mD({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 pD.error("[native] tauri dialog failed",n),null}}function vD(){return En()?hD:bn()?yD:null}function wD(){return jE()}async function XS(e){const t=vD();return t?t(e):null}async function _W(e){const t=await XS({mode:"directory",...e??{}});return Array.isArray(t)?t[0]??null:t}async function bD(e){const t=await XS({mode:"file",...e??{}});return Array.isArray(t)?t[0]??null:t}var SD=F('<div class="selector-loading text-xs"><span>'),kD=F("<div class=selector-validation-error><div class=selector-validation-error-content><span class=selector-validation-error-text>"),xD=F('<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">'),$D=F('<div class="text-xs font-mono truncate pl-6 text-muted">'),_D=F("<span class=selector-badge-version>"),tg=F("<span class=selector-badge-time>"),CD=F('<button type=button class="p-2 text-muted hover:text-primary">'),ED=F('<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 TD=Lt("actions"),MD=e=>{const{t}=kt(),{opencodeBinaries:n,addOpenCodeBinary:s,removeOpenCodeBinary:r,serverSettings:o}=Tn(),[a,i]=L(""),[c,l]=L(!1),[d,u]=L(null),[f,h]=L(new Map),[m,w]=L(new Set),[S,b]=L(!1),v=()=>n(),k=()=>o().opencodeBinary,$=$e(()=>v().filter(M=>M.path!=="opencode"&&M.path!=="opencode2")),C=$e(()=>[{path:"opencode2",isDefault:!0},...$()]),T=()=>e.selectedBinary||"opencode2";qe(()=>{if(!e.selectedBinary&&k())e.onBinaryChange(k());else if(!e.selectedBinary){const M=v()[0];M&&e.onBinaryChange(M.path)}}),qe(()=>{const M=new Map(f());let N=!1;v().forEach(ce=>{ce.version&&!M.has(ce.path)&&(M.set(ce.path,ce.version),N=!0)}),N&&h(M)}),qe(()=>{if(!e.isVisible)return;const M=f(),N=["opencode2",...$().map(ce=>ce.path)].filter(ce=>!M.has(ce));N.length!==0&&setTimeout(()=>{N.forEach(ce=>{D(ce).catch(fe=>TD.error("Failed to validate binary",{path:ce,error:fe}))})},0)}),nt(()=>{w(new Set),l(!1)});async function D(M){if(m().has(M))return{valid:!1,error:t("opencodeBinarySelector.validation.alreadyValidating")};try{w(fe=>new Set(fe).add(M)),l(!0),u(null);const N=await ft.validateBinary(M),ce=N.errorCode===ah?{...N,error:t("opencodeBinarySelector.validation.v2Required")}:N;if(ce.valid&&ce.version){const fe=new Map(f());fe.set(M,ce.version),h(fe)}return ce}catch(N){return{valid:!1,error:N instanceof Error?N.message:String(N)}}finally{w(N=>{const ce=new Set(N);return ce.delete(M),ce.size===0&&l(!1),ce})}}async function R(){if(!e.disabled){if(u(null),wD()){const M=await bD({title:t("opencodeBinarySelector.dialog.title")});M&&(i(M),q(M));return}b(!0)}}async function q(M){const N=await D(M);N.valid?(s(M,N.version),e.onBinaryChange(M),i(""),u(null)):u(N.error||t("opencodeBinarySelector.validation.invalidBinary"))}function re(M){b(!1),i(M),q(M)}async function ee(){const M=a().trim();M&&await q(M)}function W(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 J(M){if(!M)return"";const N=Math.floor((Date.now()-M)/1e3),ce=Math.floor(N/60),fe=Math.floor(ce/60),Re=Math.floor(fe/24);return Re>0?t("time.relative.daysAgoShort",{count:Re}):fe>0?t("time.relative.hoursAgoShort",{count:fe}):ce>0?t("time.relative.minutesAgoShort",{count:ce}):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 z=M=>m().has(M);return[(()=>{var M=xD(),N=M.firstChild,ce=N.firstChild,fe=ce.firstChild,Re=fe.nextSibling,be=N.nextSibling,ye=be.firstChild,Ce=ye.firstChild,je=Ce.nextSibling,O=ye.nextSibling,g=be.nextSibling;return p(fe,()=>t("opencodeBinarySelector.title")),p(Re,()=>t("opencodeBinarySelector.subtitle")),p(N,y(Q,{get when(){return c()},get children(){var x=SD(),A=x.firstChild;return p(x,y(Nn,{class:"selector-loading-spinner"}),A),p(A,()=>t("opencodeBinarySelector.status.checkingVersions")),x}}),null),Ce.$$keydown=x=>{x.key==="Enter"&&(x.preventDefault(),ee())},Ce.$$input=x=>i(x.currentTarget.value),je.$$click=ee,p(je,y(Eu,{class:"w-4 h-4"}),null),p(je,()=>t("opencodeBinarySelector.actions.add"),null),O.$$click=()=>void R(),p(O,y(X2,{class:"w-4 h-4"}),null),p(O,()=>t("opencodeBinarySelector.actions.browse"),null),p(be,y(Q,{get when(){return d()},get children(){var x=kD(),A=x.firstChild,E=A.firstChild;return p(A,y(S2,{class:"selector-validation-error-icon"}),E),p(E,d),x}}),null),p(g,y(Ut,{get each(){return C()},children:x=>{const A=x.isDefault,E=()=>(A?e.defaultVersion:void 0)??f().get(x.path)??x.version;return(()=>{var H=ED(),B=H.firstChild,oe=B.firstChild,Ae=oe.firstChild,we=Ae.firstChild,he=Ae.nextSibling;return B.$$click=()=>W(x.path),p(Ae,y(ZS,{get class(){return`w-4 h-4 transition-opacity ${T()===x.path?"opacity-100":"opacity-0"}`}}),we),p(we,()=>le(x.path)),p(oe,y(Q,{when:!A,get children(){var Ee=$D();return p(Ee,()=>x.path),Ee}}),he),p(he,y(Q,{get when(){return E()},get children(){var Ee=_D();return p(Ee,()=>t("opencodeBinarySelector.versionLabel",{version:E()})),Ee}}),null),p(he,y(Q,{get when(){return z(x.path)},get children(){var Ee=tg();return p(Ee,()=>t("opencodeBinarySelector.status.checking")),Ee}}),null),p(he,y(Q,{get when(){return!A&&x.lastUsed},get children(){var Ee=tg();return p(Ee,()=>J(x.lastUsed)),Ee}}),null),p(he,y(Q,{when:A,get children(){var Ee=tg();return p(Ee,()=>t("opencodeBinarySelector.badge.systemPath")),Ee}}),null),p(H,y(Q,{when:!A,get children(){var Ee=CD();return Ee.$$click=Ge=>U(x.path,Ge),p(Ee,y(Tu,{class:"w-3.5 h-3.5"})),de(Ge=>{var Xe=e.disabled,se=t("opencodeBinarySelector.actions.removeTitle");return Xe!==Ge.e&&(Ee.disabled=Ge.e=Xe),se!==Ge.t&&pe(Ee,"title",Ge.t=se),Ge},{e:void 0,t:void 0}),Ee}}),null),de(Ee=>{var Ge=T()===x.path,Xe=e.disabled;return Ge!==Ee.e&&H.classList.toggle("panel-list-item-highlight",Ee.e=Ge),Xe!==Ee.t&&(B.disabled=Ee.t=Xe),Ee},{e:void 0,t:void 0}),H})()}})),de(x=>{var A=e.disabled,E=t("opencodeBinarySelector.customPath.placeholder",{name:"opencode2"}),H=e.disabled||!a().trim(),B=e.disabled;return A!==x.e&&(Ce.disabled=x.e=A),E!==x.t&&pe(Ce,"placeholder",x.t=E),H!==x.a&&(je.disabled=x.a=H),B!==x.o&&(O.disabled=x.o=B),x},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>Ce.value=a()),M})(),y(uD,{get open(){return S()},mode:"files",get title(){return t("opencodeBinarySelector.dialog.title")},get description(){return t("opencodeBinarySelector.dialog.description")},onClose:()=>b(!1),onSelect:re})]};Ht(["input","keydown","click"]);var AD=F('<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 ek(){const{t:e}=kt(),{serverSettings:t,updateLastUsedBinary:n}=Tn();return(()=>{var s=AD(),r=s.firstChild,o=r.firstChild,a=o.firstChild,i=a.firstChild,c=i.nextSibling,l=o.nextSibling;return p(o,y(ep,{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(MD,{get selectedBinary(){return t().opencodeBinary||"opencode2"},get defaultVersion(){var d;return _e(()=>{var u;return!!((u=er())!=null&&u.installationSource)})()?((d=er())==null?void 0:d.currentVersion)??void 0:void 0},onBinaryChange:n,get disabled(){return ni()},isVisible:!0}),null),s})()}var DD=F('<div class="fixed bottom-4 right-4 z-50 border border-base bg-surface-secondary p-3"role=status><button class=selector-button>'),PD=F("<header class=window-header>"),OD=F("<div class=window-body>"),RD=F('<div class="fixed inset-0 z-50 flex items-center justify-center p-4">');function ID(e={}){const{t}=kt(),{serverSettings:n}=Tn();qe(()=>{n().opencodeBinary,zi(WS)}),qe(()=>{ln.getStatuses(),zi(()=>{document.hidden||Gs()})});let s="";return qe(()=>{if(e.automatic===!1)return;const r=er();if(!r||!oh(r)){s="";return}const o=`${r.binaryPath}:${r.state}:${r.daemonVersion??""}`;s!==o&&(s=o,Hi(!0))}),Ns(()=>{const r=()=>{document.hidden||Gs()};window.addEventListener("focus",r),document.addEventListener("visibilitychange",r),nt(()=>{window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",r)})}),[y(Q,{get when(){return _e(()=>!!(e.automatic!==!1&&oh()))()&&!Yg()},get children(){return y(Km,{get children(){var r=DD(),o=r.firstChild;return o.$$click=()=>Qm(),p(o,()=>t("settings.opencode.setup.required")),r}})}}),y(_t,{get open(){return Yg()},onOpenChange:Hi,get children(){return y(_t.Portal,{get children(){return[y(_t.Overlay,{class:"modal-overlay"}),(()=>{var r=RD();return p(r,y(_t.Content,{class:"modal-surface w-full max-w-2xl max-h-[85vh] overflow-auto",get children(){return[(()=>{var o=PD();return p(o,y(_t.Title,{class:"window-title",get children(){return t("settings.opencode.setup.required")}}),null),p(o,y(_t.CloseButton,{class:"window-action",get"aria-label"(){return t("app.launchError.close")},get children(){return t("app.launchError.close")}}),null),o})(),(()=>{var o=OD();return p(o,y(HS,{get children(){return y(ek,{})}})),o})()]}})),r})()]}})}})]}Ht(["click"]);function tk(e){let t=e.startIndex??0;const n=e.startLevel??0,s=[],r=c=>{if(c==null)return"";const l=e.getKey??"key",d=bi(l)?c[l]:l(c);return d!=null?String(d):""},o=c=>{if(c==null)return"";const l=e.getTextValue??"textValue",d=bi(l)?c[l]:l(c);return d!=null?String(d):""},a=c=>{if(c==null)return!1;const l=e.getDisabled??"disabled";return(bi(l)?c[l]:l(c))??!1},i=c=>{var l;if(c!=null)return bi(e.getSectionChildren)?c[e.getSectionChildren]:(l=e.getSectionChildren)==null?void 0:l.call(e,c)};for(const c of e.dataSource){if(bi(c)||QT(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=tk({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 LD(e,t=[]){return $e(()=>{const n=tk({dataSource:ge(e.dataSource),getKey:ge(e.getKey),getTextValue:ge(e.getTextValue),getDisabled:ge(e.getDisabled),getSectionChildren:ge(e.getSectionChildren)});for(let s=0;s<t.length;s++)t[s]();return e.factory(n)})}var FD=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),ND=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function UD(e){if(Intl.Locale){const n=new Intl.Locale(e).maximize().script??"";return FD.has(n)}const t=e.split("-")[0];return ND.has(t)}function BD(e){return UD(e)?"rtl":"ltr"}function nk(){let e=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:BD(e)}}var ch=nk(),ec=new Set;function Sw(){ch=nk();for(const e of ec)e(ch)}function KD(){const[e,t]=L(ch),n=$e(()=>e());return Ns(()=>{ec.size===0&&window.addEventListener("languagechange",Sw),ec.add(t),nt(()=>{ec.delete(t),ec.size===0&&window.removeEventListener("languagechange",Sw)})}),{locale:()=>n().locale,direction:()=>n().direction}}var VD=Ir();function tp(){const e=KD();return Lr(VD)||e}var ng=new Map;function np(e){const{locale:t}=tp(),n=$e(()=>t()+(e?Object.entries(e).sort((s,r)=>s[0]<r[0]?-1:1).join():""));return $e(()=>{const s=n();let r;return ng.has(s)&&(r=ng.get(s)),r||(r=new Intl.Collator(t(),e),ng.set(s,r)),r})}function CW(e){const t=np({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 zs=class sk extends Set{constructor(n,s,r){super(n);ae(this,"anchorKey");ae(this,"currentKey");n instanceof sk?(this.anchorKey=s||n.anchorKey,this.currentKey=r||n.currentKey):(this.anchorKey=s,this.currentKey=r)}};function jD(e){const[t,n]=Zm(e);return[()=>t()??new zs,n]}function rk(e){return sM()?e.altKey:e.ctrlKey}function Si(e){return Xc()?e.metaKey:e.ctrlKey}function kw(e){return new zs(e)}function ok(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function qD(e){const t=Dt({selectionMode:"none",selectionBehavior:"toggle"},e),[n,s]=L(!1),[r,o]=L(),a=$e(()=>{const w=ge(t.selectedKeys);return w!=null?kw(w):w}),i=$e(()=>{const w=ge(t.defaultSelectedKeys);return w!=null?kw(w):new zs}),[c,l]=jD({value:a,defaultValue:i,onChange:w=>{var S;return(S=t.onSelectionChange)==null?void 0:S.call(t,w)}}),[d,u]=L(ge(t.selectionBehavior)),f=()=>ge(t.selectionMode),h=()=>ge(t.disallowEmptySelection)??!1,m=w=>{(ge(t.allowDuplicateSelectionEvents)||!ok(w,c()))&&l(w)};return qe(()=>{const w=c();ge(t.selectionBehavior)==="replace"&&d()==="toggle"&&typeof w=="object"&&w.size===0&&u("replace")}),qe(()=>{u(ge(t.selectionBehavior)??"toggle")}),{selectionMode:f,disallowEmptySelection:h,selectionBehavior:d,setSelectionBehavior:u,isFocused:n,setFocused:s,focusedKey:r,setFocusedKey:o,selectedKeys:c,setSelectedKeys:m}}function ik(e){const[t,n]=L(""),[s,r]=L(-1);return{typeSelectHandlers:{onKeyDown:a=>{var f;if(ge(e.isDisabled))return;const i=ge(e.keyboardDelegate),c=ge(e.selectionManager);if(!i.getKeyForSearch)return;const l=zD(a.key);if(!l||a.ctrlKey||a.metaKey)return;l===" "&&t().trim().length>0&&(a.preventDefault(),a.stopPropagation());let d=n(h=>h+l),u=i.getKeyForSearch(d,c.focusedKey())??i.getKeyForSearch(d);u==null&&WD(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 zD(e){return e.length===1||!/^[A-Z]/i.test(e)?e:""}function WD(e){return e.split("").every(t=>t===e[0])}function HD(e,t,n){const r=Se({selectOnFocus:()=>ge(e.selectionManager).selectionBehavior()==="replace"},e),o=()=>(n==null?void 0:n())??t(),{direction:a}=tp();let i={top:0,left:0};GT(()=>ge(r.isVirtualized)?void 0:o(),"scroll",()=>{const S=o();S&&(i={top:S.scrollTop,left:S.scrollLeft})});const{typeSelectHandlers:c}=ik({isDisabled:()=>ge(r.disallowTypeAhead),keyboardDelegate:()=>ge(r.keyboardDelegate),selectionManager:()=>ge(r.selectionManager)}),l=()=>ge(r.orientation)??"vertical",d=S=>{var R,q,re,ee,W,U,J,le;Zt(S,c.onKeyDown),S.altKey&&S.key==="Tab"&&S.preventDefault();const b=t();if(!(b!=null&&b.contains(S.target)))return;const v=ge(r.selectionManager),k=ge(r.selectOnFocus),$=z=>{z!=null&&(v.setFocusedKey(z),S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(z):k&&!rk(S)&&v.replaceSelection(z))},C=ge(r.keyboardDelegate),T=ge(r.shouldFocusWrap),D=v.focusedKey();switch(S.key){case(l()==="vertical"?"ArrowDown":"ArrowRight"):{if(C.getKeyBelow){S.preventDefault();let z;D!=null?z=C.getKeyBelow(D):z=(R=C.getFirstKey)==null?void 0:R.call(C),z==null&&T&&(z=(q=C.getFirstKey)==null?void 0:q.call(C,D)),$(z)}break}case(l()==="vertical"?"ArrowUp":"ArrowLeft"):{if(C.getKeyAbove){S.preventDefault();let z;D!=null?z=C.getKeyAbove(D):z=(re=C.getLastKey)==null?void 0:re.call(C),z==null&&T&&(z=(ee=C.getLastKey)==null?void 0:ee.call(C,D)),$(z)}break}case(l()==="vertical"?"ArrowLeft":"ArrowUp"):{if(C.getKeyLeftOf){S.preventDefault();const z=a()==="rtl";let M;D!=null?M=C.getKeyLeftOf(D):M=z?(W=C.getFirstKey)==null?void 0:W.call(C):(U=C.getLastKey)==null?void 0:U.call(C),$(M)}break}case(l()==="vertical"?"ArrowRight":"ArrowDown"):{if(C.getKeyRightOf){S.preventDefault();const z=a()==="rtl";let M;D!=null?M=C.getKeyRightOf(D):M=z?(J=C.getLastKey)==null?void 0:J.call(C):(le=C.getFirstKey)==null?void 0:le.call(C),$(M)}break}case"Home":if(C.getFirstKey){S.preventDefault();const z=C.getFirstKey(D,Si(S));z!=null&&(v.setFocusedKey(z),Si(S)&&S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(z):k&&v.replaceSelection(z))}break;case"End":if(C.getLastKey){S.preventDefault();const z=C.getLastKey(D,Si(S));z!=null&&(v.setFocusedKey(z),Si(S)&&S.shiftKey&&v.selectionMode()==="multiple"?v.extendSelection(z):k&&v.replaceSelection(z))}break;case"PageDown":if(C.getKeyPageBelow&&D!=null){S.preventDefault();const z=C.getKeyPageBelow(D);$(z)}break;case"PageUp":if(C.getKeyPageAbove&&D!=null){S.preventDefault();const z=C.getKeyPageAbove(D);$(z)}break;case"a":Si(S)&&v.selectionMode()==="multiple"&&ge(r.disallowSelectAll)!==!0&&(S.preventDefault(),v.selectAll());break;case"Escape":S.defaultPrevented||(S.preventDefault(),ge(r.disallowEmptySelection)||v.clearSelection());break;case"Tab":if(!ge(r.allowsTabNavigation)){if(S.shiftKey)b.focus();else{const z=mM(b,{tabbable:!0});let M,N;do N=z.lastChild(),N&&(M=N);while(N);M&&!M.contains(document.activeElement)&&xn(M)}break}}},u=S=>{var $,C;const b=ge(r.selectionManager),v=ge(r.keyboardDelegate),k=ge(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=R=>{R!=null&&(b.setFocusedKey(R),k&&b.replaceSelection(R))},D=S.relatedTarget;D&&S.currentTarget.compareDocumentPosition(D)&Node.DOCUMENT_POSITION_FOLLOWING?T(b.lastSelectedKey()??(($=v.getLastKey)==null?void 0:$.call(v))):T(b.firstSelectedKey()??((C=v.getFirstKey)==null?void 0:C.call(v)))}else if(!ge(r.isVirtualized)){const T=o();if(T){T.scrollTop=i.top,T.scrollLeft=i.left;const D=T.querySelector(`[data-key="${b.focusedKey()}"]`);D&&(xn(D),Hg(T,D))}}}},f=S=>{const b=ge(r.selectionManager);S.currentTarget.contains(S.relatedTarget)||b.setFocused(!1)},h=S=>{o()===S.target&&S.preventDefault()},m=()=>{var T,D;const S=ge(r.autoFocus);if(!S)return;const b=ge(r.selectionManager),v=ge(r.keyboardDelegate);let k;S==="first"&&(k=(T=v.getFirstKey)==null?void 0:T.call(v)),S==="last"&&(k=(D=v.getLastKey)==null?void 0:D.call(v));const $=b.selectedKeys();$.size&&(k=$.values().next().value),b.setFocused(!0),b.setFocusedKey(k);const C=t();C&&k==null&&!ge(r.shouldUseVirtualFocus)&&xn(C)};return Ns(()=>{r.deferAutoFocus?setTimeout(m,0):m()}),qe(ei([o,()=>ge(r.isVirtualized),()=>ge(r.selectionManager).focusedKey()],S=>{var $;const[b,v,k]=S;if(v)k&&(($=r.scrollToKey)==null||$.call(r,k));else if(k&&b){const C=b.querySelector(`[data-key="${k}"]`);C&&Hg(b,C)}})),{tabIndex:$e(()=>{if(!ge(r.shouldUseVirtualFocus))return ge(r.selectionManager).focusedKey()==null?0:-1}),onKeyDown:d,onMouseDown:h,onFocusIn:u,onFocusOut:f}}function GD(e,t){const n=()=>ge(e.selectionManager),s=()=>ge(e.key),r=()=>ge(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"||Si(v)||"pointerType"in v&&v.pointerType==="touch"?n().toggleSelection(s()):n().replaceSelection(s()))},a=()=>n().isSelected(s()),i=()=>ge(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&&!ge(e.shouldSelectOnPressUp)&&o(v))},u=v=>{c()&&v.pointerType==="mouse"&&v.button===0&&ge(e.shouldSelectOnPressUp)&&ge(e.allowsDifferentPressOrigin)&&o(v)},f=v=>{c()&&(ge(e.shouldSelectOnPressUp)&&!ge(e.allowsDifferentPressOrigin)||l!=="mouse")&&o(v)},h=v=>{!c()||!["Enter"," "].includes(v.key)||(rk(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=$e(()=>{if(!(r()||i()))return s()===n().focusedKey()?0:-1}),b=$e(()=>ge(e.virtualized)?void 0:s());return qe(ei([t,s,r,()=>n().focusedKey(),()=>n().isFocused()],([v,k,$,C,T])=>{v&&k===C&&T&&!$&&document.activeElement!==v&&(e.focus?e.focus():xn(v))})),{isSelected:a,isDisabled:i,allowsSelection:c,tabIndex:S,dataKey:b,onPointerDown:d,onPointerUp:u,onClick:f,onKeyDown:h,onMouseDown:m,onFocus:w}}var ZD=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 zs(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 zs(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 zs([t],t,t):new zs;this.state.setSelectedKeys(n)}setSelectedKeys(e){if(this.selectionMode()==="none")return;const t=new zs;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 zs)}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}},xw=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 ak(e){const t=qD(e),s=LD({dataSource:()=>ge(e.dataSource),getKey:()=>ge(e.getKey),getTextValue:()=>ge(e.getTextValue),getDisabled:()=>ge(e.getDisabled),getSectionChildren:()=>ge(e.getSectionChildren),factory:o=>e.filter?new xw(e.filter(o)):new xw(o)},[()=>e.filter]),r=new ZD(s,t);return uS(()=>{const o=t.focusedKey();o!=null&&!s().getItem(o)&&t.setFocusedKey(void 0)}),{collection:s,selectionManager:()=>r}}var ck=["id","name","validationState","required","disabled","readOnly"];function lk(e){const t=`form-control-${ti()}`,n=Dt({id:t},e),[s,r]=L(),[o,a]=L(),[i,c]=L(),[l,d]=L(),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,h=$e(()=>({"data-valid":ge(n.validationState)==="valid"?"":void 0,"data-invalid":ge(n.validationState)==="invalid"?"":void 0,"data-required":ge(n.required)?"":void 0,"data-disabled":ge(n.disabled)?"":void 0,"data-readonly":ge(n.readOnly)?"":void 0}));return{formControlContext:{name:()=>ge(n.name)??ge(n.id),dataset:h,validationState:()=>ge(n.validationState),isRequired:()=>ge(n.required),isDisabled:()=>ge(n.disabled),isReadOnly:()=>ge(n.readOnly),labelId:s,fieldId:o,descriptionId:i,errorMessageId:l,getAriaLabelledBy:u,getAriaDescribedBy:f,generateId:Ea(()=>ge(n.id)),registerLabel:ds(r),registerField:ds(a),registerDescription:ds(c),registerErrorMessage:ds(d)}}}var sp=Ir();function or(){const e=Lr(sp);if(e===void 0)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function rp(e){const t=or(),n=Dt({id:t.generateId("description")},e);return qe(()=>nt(t.registerDescription(n.id))),y(zt,Se({as:"div"},()=>t.dataset(),n))}var JD=F("<option>"),YD=F("<div aria-hidden=true><input type=text style=font-size:16px><select tabindex=-1><option>");function QD(e){let t;const[n,s]=Et(e,["ref","onChange","collection","selectionManager","isOpen","isMultiple","isVirtualized","focusTrigger"]),r=or(),[o,a]=L(!1),i=c=>{const l=n.collection.getItem(c);return y(Q,{get when(){return(l==null?void 0:l.type)==="item"},get children(){var d=JD();return d.value=c,p(d,()=>l==null?void 0:l.textValue),de(()=>d.selected=n.selectionManager.isSelected(c)),d}})};return qe(ei(()=>n.selectionManager.selectedKeys(),(c,l)=>{l&&ok(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=YD(),l=c.firstChild,d=l.nextSibling;d.firstChild,l.addEventListener("focus",()=>n.focusTrigger()),d.addEventListener("change",f=>{Zt(f,n.onChange),o()||n.selectionManager.setSelectedKeys(new Set([f.target.value])),a(!1)});var u=Mn(f=>t=f,n.ref);return typeof u=="function"&&Xs(u,d),Qs(d,Se({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(Q,{get when(){return n.isVirtualized},get fallback(){return y(Ut,{get each(){return[...n.collection.getKeys()]},children:i})},get children(){return y(Ut,{get each(){return[...n.selectionManager.selectedKeys()]},children:i})}}),null),de(f=>{var h=$u,m=n.selectionManager.isFocused()||n.isOpen?-1:0,w=r.isRequired(),S=r.isDisabled(),b=r.isReadOnly();return f.e=hr(c,h,f.e),m!==f.t&&pe(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 $w=new WeakMap;function XD(e){let t=$w.get(e);if(t!=null)return t;t=0;for(const n of e)n.type==="item"&&t++;return $w.set(e,t),t}var dk=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 eP(e,t,n){const s=np({usage:"search",sensitivity:"base"}),r=$e(()=>{const o=ge(e.keyboardDelegate);return o||new dk(e.collection,t,s)});return HD({selectionManager:()=>ge(e.selectionManager),keyboardDelegate:r,autoFocus:()=>ge(e.autoFocus),deferAutoFocus:()=>ge(e.deferAutoFocus),shouldFocusWrap:()=>ge(e.shouldFocusWrap),disallowEmptySelection:()=>ge(e.disallowEmptySelection),selectOnFocus:()=>ge(e.selectOnFocus),disallowTypeAhead:()=>ge(e.disallowTypeAhead),shouldUseVirtualFocus:()=>ge(e.shouldUseVirtualFocus),allowsTabNavigation:()=>ge(e.allowsTabNavigation),isVirtualized:()=>ge(e.isVirtualized),scrollToKey:o=>{var a;return(a=ge(e.scrollToKey))==null?void 0:a(o)},orientation:()=>ge(e.orientation)},t,n)}var tP={};el(tP,{Item:()=>Mu,ItemDescription:()=>Au,ItemIndicator:()=>Du,ItemLabel:()=>Pu,Listbox:()=>nP,Root:()=>ip,Section:()=>Ou,useListboxContext:()=>fk});var uk=Ir();function fk(){const e=Lr(uk);if(e===void 0)throw new Error("[kobalte]: `useListboxContext` must be used within a `Listbox` component");return e}var gk=Ir();function op(){const e=Lr(gk);if(e===void 0)throw new Error("[kobalte]: `useListboxItemContext` must be used within a `Listbox.Item` component");return e}function Mu(e){let t;const n=fk(),s=`${n.generateId("item")}-${ti()}`,r=Dt({id:s},e),[o,a]=Et(r,["ref","item","aria-label","aria-labelledby","aria-describedby","onPointerMove","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[i,c]=L(),[l,d]=L(),u=()=>n.listState().selectionManager(),f=()=>u().focusedKey()===o.item.key,h=GD({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 h.isSelected()},w=$e(()=>!(Xc()&&rM())),S=()=>w()?o["aria-label"]:void 0,b=()=>w()?i():void 0,v=()=>w()?l():void 0,k=()=>{var q;if(!n.isVirtualized())return;const R=(q=n.listState().collection().getItem(o.item.key))==null?void 0:q.index;return R!=null?R+1:void 0},$=()=>{if(n.isVirtualized())return XD(n.listState().collection())},C=R=>{Zt(R,o.onPointerMove),R.pointerType==="mouse"&&!h.isDisabled()&&n.shouldFocusOnHover()&&(xn(R.currentTarget),u().setFocused(!0),u().setFocusedKey(o.item.key))},T=$e(()=>({"data-disabled":h.isDisabled()?"":void 0,"data-selected":h.isSelected()?"":void 0,"data-highlighted":f()?"":void 0})),D={isSelected:h.isSelected,dataset:T,generateId:Ea(()=>a.id),registerLabelId:ds(c),registerDescriptionId:ds(d)};return y(gk.Provider,{value:D,get children(){return y(zt,Se({as:"li",ref(R){var q=Mn(re=>t=re,o.ref);typeof q=="function"&&q(R)},role:"option",get tabIndex(){return h.tabIndex()},get"aria-disabled"(){return h.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 $()},get"data-key"(){return h.dataKey()},get onPointerDown(){return ls([o.onPointerDown,h.onPointerDown])},get onPointerUp(){return ls([o.onPointerUp,h.onPointerUp])},get onClick(){return ls([o.onClick,h.onClick])},get onKeyDown(){return ls([o.onKeyDown,h.onKeyDown])},get onMouseDown(){return ls([o.onMouseDown,h.onMouseDown])},get onFocus(){return ls([o.onFocus,h.onFocus])},onPointerMove:C},T,a))}})}function Au(e){const t=op(),n=Dt({id:t.generateId("description")},e);return qe(()=>nt(t.registerDescriptionId(n.id))),y(zt,Se({as:"div"},()=>t.dataset(),n))}function Du(e){const t=op(),n=Dt({id:t.generateId("indicator")},e),[s,r]=Et(n,["forceMount"]);return y(Q,{get when(){return s.forceMount||t.isSelected()},get children(){return y(zt,Se({as:"div","aria-hidden":"true"},()=>t.dataset(),r))}})}function Pu(e){const t=op(),n=Dt({id:t.generateId("label")},e);return qe(()=>nt(t.registerLabelId(n.id))),y(zt,Se({as:"div"},()=>t.dataset(),n))}function ip(e){let t;const n=`listbox-${ti()}`,s=Dt({id:n,selectionMode:"single",virtualized:!1},e),[r,o]=Et(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=$e(()=>r.state?r.state:ak({selectedKeys:()=>r.value,defaultSelectedKeys:()=>r.defaultValue,onSelectionChange:r.onChange,allowDuplicateSelectionEvents:()=>ge(r.allowDuplicateSelectionEvents),disallowEmptySelection:()=>ge(r.disallowEmptySelection),selectionBehavior:()=>ge(r.selectionBehavior),selectionMode:()=>ge(r.selectionMode),dataSource:()=>r.options??[],getKey:()=>r.optionValue,getTextValue:()=>r.optionTextValue,getDisabled:()=>r.optionDisabled,getSectionChildren:()=>r.optionGroupChildren})),i=eP({selectionManager:()=>a().selectionManager(),collection:()=>a().collection(),autoFocus:()=>ge(r.autoFocus),shouldFocusWrap:()=>ge(r.shouldFocusWrap),keyboardDelegate:()=>r.keyboardDelegate,disallowEmptySelection:()=>ge(r.disallowEmptySelection),selectOnFocus:()=>ge(r.selectOnFocus),disallowTypeAhead:()=>ge(r.disallowTypeAhead),shouldUseVirtualFocus:()=>ge(r.shouldUseVirtualFocus),allowsTabNavigation:()=>ge(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:Ea(()=>o.id),shouldUseVirtualFocus:()=>s.shouldUseVirtualFocus,shouldSelectOnPressUp:()=>s.shouldSelectOnPressUp,shouldFocusOnHover:()=>s.shouldFocusOnHover,isVirtualized:()=>r.virtualized};return y(uk.Provider,{value:c,get children(){return y(zt,Se({as:"ul",ref(l){var d=Mn(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 ls([r.onKeyDown,i.onKeyDown])},get onMouseDown(){return ls([r.onMouseDown,i.onMouseDown])},get onFocusIn(){return ls([r.onFocusIn,i.onFocusIn])},get onFocusOut(){return ls([r.onFocusOut,i.onFocusOut])}},o,{get children(){return y(Q,{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(JT,{get each(){return[...a().collection()]},by:"key",children:l=>y(dS,{get children(){return[y(_i,{get when(){return l().type==="section"},get children(){var d;return(d=r.renderSection)==null?void 0:d.call(r,l())}}),y(_i,{get when(){return l().type==="item"},get children(){var d;return(d=r.renderItem)==null?void 0:d.call(r,l())}})]}})})}})}}))}})}function Ou(e){return y(zt,Se({as:"li",role:"presentation"},e))}var nP=Object.assign(ip,{Item:Mu,ItemDescription:Au,ItemIndicator:Du,ItemLabel:Pu,Section:Ou});const sP=["top","right","bottom","left"],so=Math.min,Yn=Math.max,Ed=Math.round,Ul=Math.floor,Zs=e=>({x:e,y:e}),rP={left:"right",right:"left",bottom:"top",top:"bottom"},oP={start:"end",end:"start"};function lh(e,t,n){return Yn(e,so(t,n))}function si(e,t){return typeof e=="function"?e(t):e}function ro(e){return e.split("-")[0]}function Ta(e){return e.split("-")[1]}function hk(e){return e==="x"?"y":"x"}function ap(e){return e==="y"?"height":"width"}const iP=new Set(["top","bottom"]);function yr(e){return iP.has(ro(e))?"y":"x"}function cp(e){return hk(yr(e))}function aP(e,t,n){n===void 0&&(n=!1);const s=Ta(e),r=cp(e),o=ap(r);let a=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Td(a)),[a,Td(a)]}function cP(e){const t=Td(e);return[dh(e),t,dh(t)]}function dh(e){return e.replace(/start|end/g,t=>oP[t])}const _w=["left","right"],Cw=["right","left"],lP=["top","bottom"],dP=["bottom","top"];function uP(e,t,n){switch(e){case"top":case"bottom":return n?t?Cw:_w:t?_w:Cw;case"left":case"right":return t?lP:dP;default:return[]}}function fP(e,t,n,s){const r=Ta(e);let o=uP(ro(e),n==="start",s);return r&&(o=o.map(a=>a+"-"+r),t&&(o=o.concat(o.map(dh)))),o}function Td(e){return e.replace(/left|right|bottom|top/g,t=>rP[t])}function gP(e){return{top:0,right:0,bottom:0,left:0,...e}}function mk(e){return typeof e!="number"?gP(e):{top:e,right:e,bottom:e,left:e}}function Md(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 Ew(e,t,n){let{reference:s,floating:r}=e;const o=yr(t),a=cp(t),i=ap(a),c=ro(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 h;switch(c){case"top":h={x:d,y:s.y-r.height};break;case"bottom":h={x:d,y:s.y+s.height};break;case"right":h={x:s.x+s.width,y:u};break;case"left":h={x:s.x-r.width,y:u};break;default:h={x:s.x,y:s.y}}switch(Ta(t)){case"start":h[a]-=f*(n&&l?-1:1);break;case"end":h[a]+=f*(n&&l?-1:1);break}return h}const hP=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}=Ew(l,s,c),f=s,h={},m=0;for(let w=0;w<i.length;w++){const{name:S,fn:b}=i[w],{x:v,y:k,data:$,reset:C}=await b({x:d,y:u,initialPlacement:s,placement:f,strategy:r,middlewareData:h,rects:l,platform:a,elements:{reference:e,floating:t}});d=v??d,u=k??u,h={...h,[S]:{...h[S],...$}},C&&m<=50&&(m++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(l=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:r}):C.rects),{x:d,y:u}=Ew(l,f,c)),w=-1)}return{x:d,y:u,placement:f,strategy:r,middlewareData:h}};async function Cc(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:h=0}=si(t,e),m=mk(h),S=i[f?u==="floating"?"reference":"floating":u],b=Md(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)),$=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},C=Md(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:v,offsetParent:k,strategy:c}):v);return{top:(b.top-C.top+m.top)/$.y,bottom:(C.bottom-b.bottom+m.bottom)/$.y,left:(b.left-C.left+m.left)/$.x,right:(C.right-b.right+m.right)/$.x}}const mP=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}=si(e,t)||{};if(l==null)return{};const u=mk(d),f={x:n,y:s},h=cp(r),m=ap(h),w=await a.getDimensions(l),S=h==="y",b=S?"top":"left",v=S?"bottom":"right",k=S?"clientHeight":"clientWidth",$=o.reference[m]+o.reference[h]-f[h]-o.floating[m],C=f[h]-o.reference[h],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l));let D=T?T[k]:0;(!D||!await(a.isElement==null?void 0:a.isElement(T)))&&(D=i.floating[k]||o.floating[m]);const R=$/2-C/2,q=D/2-w[m]/2-1,re=so(u[b],q),ee=so(u[v],q),W=re,U=D-w[m]-ee,J=D/2-w[m]/2+R,le=lh(W,J,U),z=!c.arrow&&Ta(r)!=null&&J!==le&&o.reference[m]/2-(J<W?re:ee)-w[m]/2<0,M=z?J<W?J-W:J-U:0;return{[h]:f[h]+M,data:{[h]:le,centerOffset:J-le-M,...z&&{alignmentOffset:M}},reset:z}}}),pP=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:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:w=!0,...S}=si(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const b=ro(r),v=yr(i),k=ro(i)===i,$=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=f||(k||!w?[Td(i)]:cP(i)),T=m!=="none";!f&&T&&C.push(...fP(i,w,m,$));const D=[i,...C],R=await Cc(t,S),q=[];let re=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&q.push(R[b]),u){const J=aP(r,a,$);q.push(R[J[0]],R[J[1]])}if(re=[...re,{placement:r,overflows:q}],!q.every(J=>J<=0)){var ee,W;const J=(((ee=o.flip)==null?void 0:ee.index)||0)+1,le=D[J];if(le&&(!(u==="alignment"?v!==yr(le):!1)||re.every(N=>yr(N.placement)===v?N.overflows[0]>0:!0)))return{data:{index:J,overflows:re},reset:{placement:le}};let z=(W=re.filter(M=>M.overflows[0]<=0).sort((M,N)=>M.overflows[1]-N.overflows[1])[0])==null?void 0:W.placement;if(!z)switch(h){case"bestFit":{var U;const M=(U=re.filter(N=>{if(T){const ce=yr(N.placement);return ce===v||ce==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(ce=>ce>0).reduce((ce,fe)=>ce+fe,0)]).sort((N,ce)=>N[1]-ce[1])[0])==null?void 0:U[0];M&&(z=M);break}case"initialPlacement":z=i;break}if(r!==z)return{reset:{placement:z}}}return{}}}};function Tw(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Mw(e){return sP.some(t=>e[t]>=0)}const yP=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:s="referenceHidden",...r}=si(e,t);switch(s){case"referenceHidden":{const o=await Cc(t,{...r,elementContext:"reference"}),a=Tw(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Mw(a)}}}case"escaped":{const o=await Cc(t,{...r,altBoundary:!0}),a=Tw(o,n.floating);return{data:{escapedOffsets:a,escaped:Mw(a)}}}default:return{}}}}},vP=new Set(["left","top"]);async function wP(e,t){const{placement:n,platform:s,elements:r}=e,o=await(s.isRTL==null?void 0:s.isRTL(r.floating)),a=ro(n),i=Ta(n),c=yr(n)==="y",l=vP.has(a)?-1:1,d=o&&c?-1:1,u=si(t,e);let{mainAxis:f,crossAxis:h,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"&&(h=i==="end"?m*-1:m),c?{x:h*d,y:f*l}:{x:f*l,y:h*d}}const bP=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 wP(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}}}}},SP=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}=si(e,t),l={x:n,y:s},d=await Cc(t,c),u=yr(ro(r)),f=hk(u);let h=l[f],m=l[u];if(o){const S=f==="y"?"top":"left",b=f==="y"?"bottom":"right",v=h+d[S],k=h-d[b];h=lh(v,h,k)}if(a){const S=u==="y"?"top":"left",b=u==="y"?"bottom":"right",v=m+d[S],k=m-d[b];m=lh(v,m,k)}const w=i.fn({...t,[f]:h,[u]:m});return{...w,data:{x:w.x-n,y:w.y-s,enabled:{[f]:o,[u]:a}}}}}},kP=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}=si(e,t),d=await Cc(t,l),u=ro(r),f=Ta(r),h=yr(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,$=so(w-d[S],v),C=so(m-d[b],k),T=!t.middlewareData.shift;let D=$,R=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=k),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(D=v),T&&!f){const re=Yn(d.left,0),ee=Yn(d.right,0),W=Yn(d.top,0),U=Yn(d.bottom,0);h?R=m-2*(re!==0||ee!==0?re+ee:Yn(d.left,d.right)):D=w-2*(W!==0||U!==0?W+U:Yn(d.top,d.bottom))}await c({...t,availableWidth:R,availableHeight:D});const q=await a.getDimensions(i.floating);return m!==q.width||w!==q.height?{reset:{rects:!0}}:{}}}};function Ru(){return typeof window<"u"}function Ma(e){return pk(e)?(e.nodeName||"").toLowerCase():"#document"}function es(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ir(e){var t;return(t=(pk(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function pk(e){return Ru()?e instanceof Node||e instanceof es(e).Node:!1}function As(e){return Ru()?e instanceof Element||e instanceof es(e).Element:!1}function nr(e){return Ru()?e instanceof HTMLElement||e instanceof es(e).HTMLElement:!1}function Aw(e){return!Ru()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof es(e).ShadowRoot}const xP=new Set(["inline","contents"]);function nl(e){const{overflow:t,overflowX:n,overflowY:s,display:r}=Ds(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!xP.has(r)}const $P=new Set(["table","td","th"]);function _P(e){return $P.has(Ma(e))}const CP=[":popover-open",":modal"];function Iu(e){return CP.some(t=>{try{return e.matches(t)}catch{return!1}})}const EP=["transform","translate","scale","rotate","perspective"],TP=["transform","translate","scale","rotate","perspective","filter"],MP=["paint","layout","strict","content"];function lp(e){const t=dp(),n=As(e)?Ds(e):e;return EP.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)||TP.some(s=>(n.willChange||"").includes(s))||MP.some(s=>(n.contain||"").includes(s))}function AP(e){let t=oo(e);for(;nr(t)&&!Gi(t);){if(lp(t))return t;if(Iu(t))return null;t=oo(t)}return null}function dp(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const DP=new Set(["html","body","#document"]);function Gi(e){return DP.has(Ma(e))}function Ds(e){return es(e).getComputedStyle(e)}function Lu(e){return As(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function oo(e){if(Ma(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Aw(e)&&e.host||ir(e);return Aw(t)?t.host:t}function yk(e){const t=oo(e);return Gi(t)?e.ownerDocument?e.ownerDocument.body:e.body:nr(t)&&nl(t)?t:yk(t)}function Ec(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=yk(e),o=r===((s=e.ownerDocument)==null?void 0:s.body),a=es(r);if(o){const i=uh(a);return t.concat(a,a.visualViewport||[],nl(r)?r:[],i&&n?Ec(i):[])}return t.concat(r,Ec(r,[],n))}function uh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vk(e){const t=Ds(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const r=nr(e),o=r?e.offsetWidth:n,a=r?e.offsetHeight:s,i=Ed(n)!==o||Ed(s)!==a;return i&&(n=o,s=a),{width:n,height:s,$:i}}function up(e){return As(e)?e:e.contextElement}function Ri(e){const t=up(e);if(!nr(t))return Zs(1);const n=t.getBoundingClientRect(),{width:s,height:r,$:o}=vk(t);let a=(o?Ed(n.width):n.width)/s,i=(o?Ed(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const PP=Zs(0);function wk(e){const t=es(e);return!dp()||!t.visualViewport?PP:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function OP(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==es(e)?!1:t}function Vo(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=up(e);let a=Zs(1);t&&(s?As(s)&&(a=Ri(s)):a=Ri(e));const i=OP(o,n,s)?wk(o):Zs(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=es(o),h=s&&As(s)?es(s):s;let m=f,w=uh(m);for(;w&&s&&h!==m;){const S=Ri(w),b=w.getBoundingClientRect(),v=Ds(w),k=b.left+(w.clientLeft+parseFloat(v.paddingLeft))*S.x,$=b.top+(w.clientTop+parseFloat(v.paddingTop))*S.y;c*=S.x,l*=S.y,d*=S.x,u*=S.y,c+=k,l+=$,m=es(w),w=uh(m)}}return Md({width:d,height:u,x:c,y:l})}function Fu(e,t){const n=Lu(e).scrollLeft;return t?t.left+n:Vo(ir(e)).left+n}function bk(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Fu(e,n),r=n.top+t.scrollTop;return{x:s,y:r}}function RP(e){let{elements:t,rect:n,offsetParent:s,strategy:r}=e;const o=r==="fixed",a=ir(s),i=t?Iu(t.floating):!1;if(s===a||i&&o)return n;let c={scrollLeft:0,scrollTop:0},l=Zs(1);const d=Zs(0),u=nr(s);if((u||!u&&!o)&&((Ma(s)!=="body"||nl(a))&&(c=Lu(s)),nr(s))){const h=Vo(s);l=Ri(s),d.x=h.x+s.clientLeft,d.y=h.y+s.clientTop}const f=a&&!u&&!o?bk(a,c):Zs(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 IP(e){return Array.from(e.getClientRects())}function LP(e){const t=ir(e),n=Lu(e),s=e.ownerDocument.body,r=Yn(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),o=Yn(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+Fu(e);const i=-n.scrollTop;return Ds(s).direction==="rtl"&&(a+=Yn(t.clientWidth,s.clientWidth)-r),{width:r,height:o,x:a,y:i}}const Dw=25;function FP(e,t){const n=es(e),s=ir(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=dp();(!d||d&&t==="fixed")&&(i=r.offsetLeft,c=r.offsetTop)}const l=Fu(s);if(l<=0){const d=s.ownerDocument,u=d.body,f=getComputedStyle(u),h=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(s.clientWidth-u.clientWidth-h);m<=Dw&&(o-=m)}else l<=Dw&&(o+=l);return{width:o,height:a,x:i,y:c}}const NP=new Set(["absolute","fixed"]);function UP(e,t){const n=Vo(e,!0,t==="fixed"),s=n.top+e.clientTop,r=n.left+e.clientLeft,o=nr(e)?Ri(e):Zs(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 Pw(e,t,n){let s;if(t==="viewport")s=FP(e,n);else if(t==="document")s=LP(ir(e));else if(As(t))s=UP(t,n);else{const r=wk(e);s={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Md(s)}function Sk(e,t){const n=oo(e);return n===t||!As(n)||Gi(n)?!1:Ds(n).position==="fixed"||Sk(n,t)}function BP(e,t){const n=t.get(e);if(n)return n;let s=Ec(e,[],!1).filter(i=>As(i)&&Ma(i)!=="body"),r=null;const o=Ds(e).position==="fixed";let a=o?oo(e):e;for(;As(a)&&!Gi(a);){const i=Ds(a),c=lp(a);!c&&i.position==="fixed"&&(r=null),(o?!c&&!r:!c&&i.position==="static"&&!!r&&NP.has(r.position)||nl(a)&&!c&&Sk(e,a))?s=s.filter(d=>d!==a):r=i,a=oo(a)}return t.set(e,s),s}function KP(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const a=[...n==="clippingAncestors"?Iu(t)?[]:BP(t,this._c):[].concat(n),s],i=a[0],c=a.reduce((l,d)=>{const u=Pw(t,d,r);return l.top=Yn(u.top,l.top),l.right=so(u.right,l.right),l.bottom=so(u.bottom,l.bottom),l.left=Yn(u.left,l.left),l},Pw(t,i,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function VP(e){const{width:t,height:n}=vk(e);return{width:t,height:n}}function jP(e,t,n){const s=nr(t),r=ir(t),o=n==="fixed",a=Vo(e,!0,o,t);let i={scrollLeft:0,scrollTop:0};const c=Zs(0);function l(){c.x=Fu(r)}if(s||!s&&!o)if((Ma(t)!=="body"||nl(r))&&(i=Lu(t)),s){const h=Vo(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else r&&l();o&&!s&&r&&l();const d=r&&!s&&!o?bk(r,i):Zs(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 sg(e){return Ds(e).position==="static"}function Ow(e,t){if(!nr(e)||Ds(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ir(e)===n&&(n=n.ownerDocument.body),n}function kk(e,t){const n=es(e);if(Iu(e))return n;if(!nr(e)){let r=oo(e);for(;r&&!Gi(r);){if(As(r)&&!sg(r))return r;r=oo(r)}return n}let s=Ow(e,t);for(;s&&_P(s)&&sg(s);)s=Ow(s,t);return s&&Gi(s)&&sg(s)&&!lp(s)?n:s||AP(e)||n}const qP=async function(e){const t=this.getOffsetParent||kk,n=this.getDimensions,s=await n(e.floating);return{reference:jP(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function zP(e){return Ds(e).direction==="rtl"}const xk={convertOffsetParentRelativeRectToViewportRelativeRect:RP,getDocumentElement:ir,getClippingRect:KP,getOffsetParent:kk,getElementRects:qP,getClientRects:IP,getDimensions:VP,getScale:Ri,isElement:As,isRTL:zP};function $k(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function WP(e,t){let n=null,s;const r=ir(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:h}=l;if(i||t(),!f||!h)return;const m=Ul(u),w=Ul(r.clientWidth-(d+f)),S=Ul(r.clientHeight-(u+h)),b=Ul(d),k={rootMargin:-m+"px "+-w+"px "+-S+"px "+-b+"px",threshold:Yn(0,so(1,c))||1};let $=!0;function C(T){const D=T[0].intersectionRatio;if(D!==c){if(!$)return a();D?a(!1,D):s=setTimeout(()=>{a(!1,1e-7)},1e3)}D===1&&!$k(l,e.getBoundingClientRect())&&a(),$=!1}try{n=new IntersectionObserver(C,{...k,root:r.ownerDocument})}catch{n=new IntersectionObserver(C,k)}n.observe(e)}return a(!0),o}function HP(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=up(e),d=r||o?[...l?Ec(l):[],...Ec(t)]:[];d.forEach(b=>{r&&b.addEventListener("scroll",n,{passive:!0}),o&&b.addEventListener("resize",n)});const u=l&&i?WP(l,n):null;let f=-1,h=null;a&&(h=new ResizeObserver(b=>{let[v]=b;v&&v.target===l&&h&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var k;(k=h)==null||k.observe(t)})),n()}),l&&!c&&h.observe(l),h.observe(t));let m,w=c?Vo(e):null;c&&S();function S(){const b=Vo(e);w&&!$k(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=h)==null||b.disconnect(),h=null,c&&cancelAnimationFrame(m)}}const GP=bP,ZP=SP,JP=pP,YP=kP,QP=yP,XP=mP,e4=(e,t,n)=>{const s=new Map,r={platform:xk,...n},o={...r.platform,_c:s};return hP(e,t,{...r,platform:o})};var t4=F('<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>'),fp=Ir();function gp(){const e=Lr(fp);if(e===void 0)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var fh=30,Rw=fh/2,n4={top:180,right:-90,bottom:0,left:90};function hp(e){const t=gp(),n=Dt({size:fh},e),[s,r]=Et(n,["ref","style","size"]),o=()=>t.currentPlacement().split("-")[0],a=s4(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*(fh/s.size),u=()=>`rotate(${n4[o()]} ${Rw} ${Rw}) translate(0 2)`;return y(zt,Se({as:"div",ref(f){var h=Mn(t.setArrowRef,s.ref);typeof h=="function"&&h(f)},"aria-hidden":"true",get style(){return Qc({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=t4(),h=f.firstChild,m=h.firstChild;return m.nextSibling,de(()=>pe(h,"transform",u())),f}}))}function s4(e){const[t,n]=L();return qe(()=>{const s=e();s&&n(XT(s).getComputedStyle(s))}),t}function r4(e){const t=gp(),[n,s]=Et(e,["ref","style"]);return y(zt,Se({as:"div",ref(r){var o=Mn(t.setPositionerRef,n.ref);typeof o=="function"&&o(r)},"data-popper-positioner":"",get style(){return Qc({position:"absolute",top:0,left:0,"min-width":"max-content"},n.style)}},s))}function Iw(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 o4(e,t){return{contextElement:e,getBoundingClientRect:()=>{const s=t(e);return s?Iw(s):e?e.getBoundingClientRect():Iw()}}}function i4(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var a4={top:"bottom",right:"left",bottom:"top",left:"right"};function c4(e,t){const[n,s]=e.split("-"),r=a4[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 l4(e){const t=Dt({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]=L(),[r,o]=L(),[a,i]=L(t.placement),c=()=>{var f;return o4((f=t.anchorRef)==null?void 0:f.call(t),t.getAnchorRect)},{direction:l}=tp();async function d(){var T,D;const f=c(),h=n(),m=r();if(!f||!h)return;const w=((m==null?void 0:m.clientHeight)||0)/2,S=typeof t.gutter=="number"?t.gutter+w:t.gutter??w;h.style.setProperty("--kb-popper-content-overflow-padding",`${t.overflowPadding}px`),f.getBoundingClientRect();const b=[GP(({placement:R})=>{const q=!!R.split("-")[1];return{mainAxis:S,crossAxis:q?void 0:t.shift,alignmentAxis:t.shift}})];if(t.flip!==!1){const R=typeof t.flip=="string"?t.flip.split(" "):void 0;if(R!==void 0&&!R.every(i4))throw new Error("`flip` expects a spaced-delimited list of placements");b.push(JP({padding:t.overflowPadding,fallbackPlacements:R}))}(t.slide||t.overlap)&&b.push(ZP({mainAxis:t.slide,crossAxis:t.overlap,padding:t.overflowPadding})),b.push(YP({padding:t.overflowPadding,apply({availableWidth:R,availableHeight:q,rects:re}){const ee=Math.round(re.reference.width);R=Math.floor(R),q=Math.floor(q),h.style.setProperty("--kb-popper-anchor-width",`${ee}px`),h.style.setProperty("--kb-popper-content-available-width",`${R}px`),h.style.setProperty("--kb-popper-content-available-height",`${q}px`),t.sameWidth&&(h.style.width=`${ee}px`),t.fitViewport&&(h.style.maxWidth=`${R}px`,h.style.maxHeight=`${q}px`)}})),t.hideWhenDetached&&b.push(QP({padding:t.detachedPadding})),m&&b.push(XP({element:m,padding:t.arrowPadding}));const v=await e4(f,h,{placement:t.placement,strategy:"absolute",middleware:b,platform:{...xk,isRTL:()=>l()==="rtl"}});if(i(v.placement),(T=t.onCurrentPlacementChange)==null||T.call(t,v.placement),!h)return;h.style.setProperty("--kb-popper-content-transform-origin",c4(v.placement,l()));const k=Math.round(v.x),$=Math.round(v.y);let C;if(t.hideWhenDetached&&(C=(D=v.middlewareData.hide)!=null&&D.referenceHidden?"hidden":"visible"),Object.assign(h.style,{top:"0",left:"0",transform:`translate3d(${k}px, ${$}px, 0)`,visibility:C}),m&&v.middlewareData.arrow){const{x:R,y:q}=v.middlewareData.arrow,re=v.placement.split("-")[0];Object.assign(m.style,{left:R!=null?`${R}px`:"",top:q!=null?`${q}px`:"",[re]:"100%"})}}qe(()=>{const f=c(),h=n();if(!f||!h)return;const m=HP(f,h,d,{elementResize:typeof ResizeObserver=="function"});nt(m)}),qe(()=>{var m;const f=n(),h=(m=t.contentRef)==null?void 0:m.call(t);!f||!h||queueMicrotask(()=>{f.style.zIndex=getComputedStyle(h).zIndex})});const u={currentPlacement:a,contentRef:()=>{var f;return(f=t.contentRef)==null?void 0:f.call(t)},setPositionerRef:s,setArrowRef:o};return y(fp.Provider,{value:u,get children(){return t.children}})}var _k=Object.assign(l4,{Arrow:hp,Context:fp,usePopperContext:gp,Positioner:r4}),Ck=["id","aria-label","aria-labelledby","aria-describedby"];function Ek(e){const t=or(),n=Dt({id:t.generateId("field")},e);return qe(()=>nt(t.registerField(ge(n.id)))),{fieldProps:{id:()=>ge(n.id),ariaLabel:()=>ge(n["aria-label"]),ariaLabelledBy:()=>t.getAriaLabelledBy(ge(n.id),ge(n["aria-label"]),ge(n["aria-labelledby"])),ariaDescribedBy:()=>t.getAriaDescribedBy(ge(n["aria-describedby"]))}}}function Tk(e){let t;const n=or(),s=Dt({id:n.generateId("label")},e),[r,o]=Et(s,["ref"]),a=OS(()=>t,()=>"label");return qe(()=>nt(n.registerLabel(o.id))),y(zt,Se({as:"label",ref(i){var c=Mn(l=>t=l,r.ref);typeof c=="function"&&c(i)},get for(){return _e(()=>a()==="label")()?n.fieldId():void 0}},()=>n.dataset(),o))}function Mk(e,t){qe(ei(e,n=>{if(n==null)return;const s=d4(n);s!=null&&(s.addEventListener("reset",t,{passive:!0}),nt(()=>{s.removeEventListener("reset",t)}))}))}function d4(e){return u4(e)?e.form:e.closest("form")}function u4(e){return e.matches("textarea, input, select, button")}function mp(e){const t=or(),n=Dt({id:t.generateId("error-message")},e),[s,r]=Et(n,["forceMount"]),o=()=>t.validationState()==="invalid";return qe(()=>{o()&&nt(t.registerErrorMessage(r.id))}),y(Q,{get when(){return s.forceMount||o()},get children(){return y(zt,Se({as:"div"},()=>t.dataset(),r))}})}var f4={};el(f4,{Arrow:()=>hp,Content:()=>Dk,Description:()=>rp,ErrorMessage:()=>mp,HiddenSelect:()=>Pk,Icon:()=>Ok,Item:()=>Mu,ItemDescription:()=>Au,ItemIndicator:()=>Du,ItemLabel:()=>Pu,Label:()=>Rk,Listbox:()=>Ik,Portal:()=>Lk,Root:()=>Fk,Section:()=>Ou,Select:()=>Te,Trigger:()=>Nk,Value:()=>Uk,useSelectContext:()=>Fr});var Ak=Ir();function Fr(){const e=Lr(Ak);if(e===void 0)throw new Error("[kobalte]: `useSelectContext` must be used within a `Select` component");return e}function Dk(e){let t;const n=Fr(),[s,r]=Et(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 TS({isDisabled:()=>!(n.isOpen()&&n.isModal()),targets:()=>t?[t]:[]}),RS({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),CS({trapFocus:()=>n.isOpen()&&n.isModal(),onMountAutoFocus:i=>{i.preventDefault()},onUnmountAutoFocus:i=>{var c;(c=s.onCloseAutoFocus)==null||c.call(s,i),i.defaultPrevented||(xn(n.triggerRef()),i.preventDefault())}},()=>t),y(Q,{get when(){return n.contentPresent()},get children(){return y(_k.Positioner,{get children(){return y(AS,Se({ref(i){var c=Mn(l=>{n.setContentRef(l),t=l},s.ref);typeof c=="function"&&c(i)},get disableOutsidePointerEvents(){return _e(()=>!!n.isModal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get style(){return Qc({"--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 Pk(e){const t=Fr();return y(QD,Se({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 Ok(e){const t=Fr(),n=Dt({children:"▼"},e);return y(zt,Se({as:"span","aria-hidden":"true"},()=>t.dataset(),n))}function Rk(e){const t=Fr(),[n,s]=Et(e,["onClick"]);return y(Tk,Se({as:"span",onClick:o=>{var a;Zt(o,n.onClick),t.isDisabled()||(a=t.triggerRef())==null||a.focus()}},s))}function Ik(e){const t=Fr(),n=Dt({id:t.generateId("listbox")},e),[s,r]=Et(n,["ref","id","onKeyDown"]);return qe(()=>nt(t.registerListboxId(s.id))),y(ip,Se({ref(a){var i=Mn(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=>{Zt(a,s.onKeyDown),a.key==="Escape"&&a.preventDefault()}},r))}function Lk(e){const t=Fr();return y(Q,{get when(){return t.contentPresent()},get children(){return y(Km,e)}})}function g4(e){const t=`select-${ti()}`,n=Dt({id:t,selectionMode:"single",disallowEmptySelection:!1,closeOnSelection:e.selectionMode==="single",allowDuplicateSelectionEvents:!0,gutter:8,sameWidth:!0,modal:!1},e),[s,r,o,a]=Et(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"],ck),[i,c]=L(),[l,d]=L(),[u,f]=L(),[h,m]=L(),[w,S]=L(),[b,v]=L(),[k,$]=L(),[C,T]=L(!0),D=g=>{const x=s.optionValue;return x==null?String(g):String(xu(x)?x(g):g[x])},R=$e(()=>{const g=s.optionGroupChildren;return g==null?s.options:s.options.flatMap(x=>x[g]??x)}),q=$e(()=>R().map(g=>D(g))),re=g=>[...g].map(x=>R().find(A=>D(A)===x)).filter(x=>x!=null),ee=PS({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:g=>{var x;return(x=s.onOpenChange)==null?void 0:x.call(s,g)}}),W=ak({selectedKeys:()=>s.value!=null?s.value.map(D):s.value,defaultSelectedKeys:()=>s.defaultValue!=null?s.defaultValue.map(D):s.defaultValue,onSelectionChange:g=>{var x;(x=s.onChange)==null||x.call(s,re(g)),s.closeOnSelection&&N()},allowDuplicateSelectionEvents:()=>ge(s.allowDuplicateSelectionEvents),disallowEmptySelection:()=>ge(s.disallowEmptySelection),selectionBehavior:()=>ge(s.selectionBehavior),selectionMode:()=>s.selectionMode,dataSource:()=>s.options??[],getKey:()=>s.optionValue,getTextValue:()=>s.optionTextValue,getDisabled:()=>s.optionDisabled,getSectionChildren:()=>s.optionGroupChildren}),U=$e(()=>re(W.selectionManager().selectedKeys())),J=g=>{W.selectionManager().toggleSelection(D(g))},{present:le}=Jg({show:()=>s.forceMount||ee.isOpen(),element:()=>w()??null}),z=()=>{const g=b();g&&xn(g)},M=g=>{if(s.options.length<=0)return;T(g),ee.open();let x=W.selectionManager().firstSelectedKey();x==null&&(g==="first"?x=W.collection().getFirstKey():g==="last"&&(x=W.collection().getLastKey())),z(),W.selectionManager().setFocused(!0),W.selectionManager().setFocusedKey(x)},N=()=>{ee.close(),W.selectionManager().setFocused(!1),W.selectionManager().setFocusedKey(void 0)},ce=g=>{ee.isOpen()?N():M(g)},{formControlContext:fe}=lk(o);Mk(h,()=>{const g=s.defaultValue?[...s.defaultValue].map(D):new zs;W.selectionManager().setSelectedKeys(g)});const Re=np({usage:"search",sensitivity:"base"}),be=$e(()=>{const g=ge(s.keyboardDelegate);return g||new dk(W.collection,void 0,Re)}),ye=g=>{var x;return(x=s.itemComponent)==null?void 0:x.call(s,{item:g})},Ce=g=>{var x;return(x=s.sectionComponent)==null?void 0:x.call(s,{section:g})};qe(ei([q],([g])=>{const A=[...W.selectionManager().selectedKeys()].filter(E=>g.includes(E));W.selectionManager().setSelectedKeys(A)},{defer:!0}));const je=$e(()=>({"data-expanded":ee.isOpen()?"":void 0,"data-closed":ee.isOpen()?void 0:""})),O={dataset:je,isOpen:ee.isOpen,isDisabled:()=>fe.isDisabled()??!1,isMultiple:()=>ge(s.selectionMode)==="multiple",isVirtualized:()=>s.virtualized??!1,isModal:()=>s.modal??!1,preventScroll:()=>s.preventScroll??O.isModal(),disallowTypeAhead:()=>s.disallowTypeAhead??!1,shouldFocusWrap:()=>s.shouldFocusWrap??!1,selectedOptions:U,contentPresent:le,autoFocus:C,triggerRef:h,listState:()=>W,keyboardDelegate:be,triggerId:i,valueId:l,listboxId:u,listboxAriaLabelledBy:k,setListboxAriaLabelledBy:$,setTriggerRef:m,setContentRef:S,setListboxRef:v,open:M,close:N,toggle:ce,placeholder:()=>s.placeholder,renderItem:ye,renderSection:Ce,removeOptionFromSelection:J,generateId:Ea(()=>ge(o.id)),registerTriggerId:ds(c),registerValueId:ds(d),registerListboxId:ds(f)};return y(sp.Provider,{value:fe,get children(){return y(Ak.Provider,{value:O,get children(){return y(_k,Se({anchorRef:h,contentRef:w},r,{get children(){return y(zt,Se({as:"div",role:"group",get id(){return ge(o.id)}},()=>fe.dataset(),je,a))}}))}})}})}function Fk(e){const[t,n]=Et(e,["value","defaultValue","onChange","multiple"]),s=$e(()=>t.value!=null?t.multiple?t.value:[t.value]:t.value),r=$e(()=>t.defaultValue!=null?t.multiple?t.defaultValue:[t.defaultValue]:t.defaultValue);return y(g4,Se({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 Nk(e){const t=or(),n=Fr(),s=Dt({id:n.generateId("trigger")},e),[r,o,a]=Et(s,["ref","disabled","onPointerDown","onClick","onKeyDown","onFocus","onBlur"],Ck),i=()=>n.listState().selectionManager(),c=()=>n.keyboardDelegate(),l=()=>r.disabled||n.isDisabled(),{fieldProps:d}=Ek(o),{typeSelectHandlers:u}=ik({keyboardDelegate:c,selectionManager:i,onTypeSelect:v=>i().select(v)}),f=()=>[n.listboxAriaLabelledBy(),n.valueId()].filter(Boolean).join(" ")||void 0,h=v=>{Zt(v,r.onPointerDown),v.currentTarget.dataset.pointerType=v.pointerType,!l()&&v.pointerType!=="touch"&&v.button===0&&(v.preventDefault(),n.toggle(!0))},m=v=>{Zt(v,r.onClick),!l()&&v.currentTarget.dataset.pointerType==="touch"&&n.toggle(!0)},w=v=>{var k,$,C,T,D,R,q,re;if(Zt(v,r.onKeyDown),!l())switch(Zt(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 ee=i().firstSelectedKey(),W=ee!=null?($=(k=c()).getKeyAbove)==null?void 0:$.call(k,ee):(T=(C=c()).getFirstKey)==null?void 0:T.call(C);W!=null&&i().select(W);break}case"ArrowRight":{if(v.preventDefault(),n.isMultiple())return;const ee=i().firstSelectedKey(),W=ee!=null?(R=(D=c()).getKeyBelow)==null?void 0:R.call(D,ee):(re=(q=c()).getFirstKey)==null?void 0:re.call(q);W!=null&&i().select(W);break}}},S=v=>{Zt(v,r.onFocus),!i().isFocused()&&i().setFocused(!0)},b=v=>{Zt(v,r.onBlur),!n.isOpen()&&i().setFocused(!1)};return qe(()=>nt(n.registerTriggerId(d.id()))),qe(()=>{n.setListboxAriaLabelledBy([d.ariaLabelledBy(),d.ariaLabel()&&!d.ariaLabelledBy()?d.id():null].filter(Boolean).join(" ")||void 0)}),y(tl,Se({ref(v){var k=Mn(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 _e(()=>!!n.isOpen())()?n.listboxId():void 0},get"aria-label"(){return d.ariaLabel()},get"aria-labelledby"(){return f()},get"aria-describedby"(){return d.ariaDescribedBy()},onPointerDown:h,onClick:m,onKeyDown:w,onFocus:S,onBlur:b},()=>n.dataset(),()=>t.dataset(),a))}function Uk(e){const t=or(),n=Fr(),s=Dt({id:n.generateId("value")},e),[r,o]=Et(s,["id","children"]),a=()=>n.listState().selectionManager(),i=()=>{const c=a().selectedKeys();return c.size===1&&c.has("")?!0:a().isEmpty()};return qe(()=>nt(n.registerValueId(r.id))),y(zt,Se({as:"span",get id(){return r.id},get"data-placeholder-shown"(){return i()?"":void 0}},()=>t.dataset(),o,{get children(){return y(Q,{get when(){return!i()},get fallback(){return n.placeholder()},get children(){return y(h4,{state:{selectedOption:()=>n.selectedOptions()[0],selectedOptions:()=>n.selectedOptions(),remove:c=>n.removeOptionFromSelection(c),clear:()=>a().clearSelection()},get children(){return r.children}})}})}}))}function h4(e){const t=fS(()=>{const n=e.children;return xu(n)?n(e.state):n});return _e(t)}var Te=Object.assign(Fk,{Arrow:hp,Content:Dk,Description:rp,ErrorMessage:mp,HiddenSelect:Pk,Icon:Ok,Item:Mu,ItemDescription:Au,ItemIndicator:Du,ItemLabel:Pu,Label:Rk,Listbox:Ik,Portal:Lk,Section:Ou,Trigger:Nk,Value:Uk});const Lw="@media ";function m4(e){let t=typeof e=="function"?e(HE()):e;t.startsWith(Lw)&&(t=t.slice(Lw.length));const n=window.matchMedia(t),[s,r]=L(n.matches),o=a=>r(a.matches);return n.addEventListener?n.addEventListener("change",o):n.addListener(o),nt(()=>n.removeEventListener("change",o)),s}const gh=new Set(["general","chat","notifications","speech","remote","opencode","providers","sidecars","config-files","advanced","info"]);function Ad(e){if(typeof e=="string")return gh.has(e)?{section:e}:null;if(!e||typeof e!="object")return null;const t=e;if(!gh.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 p4(e){const t=new URL(e).searchParams,n=t.get("preferences");if(!n||!gh.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 y4(e,t=!1,n=!1){var s;if(mn.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(mn.host==="tauri"){await vs("open_preferences_window",{request:e,toggle:t,resume:n});return}throw new Error("Native Preferences is unavailable")}async function v4(){var e,t;En()?await((t=(e=window.electronAPI)==null?void 0:e.preferencesReady)==null?void 0:t.call(e)):bn()&&await vs("preferences_window_ready")}async function w4(e,t){var n,s;En()?await((s=(n=window.electronAPI)==null?void 0:n.acceptPreferencesRequest)==null?void 0:s.call(n,e)):bn()&&await vs("preferences_accept_request",{request:e,generation:t})}async function b4(e){return En()?(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__}):bn()?Su("client-state:flush-requested",t=>{e(t.payload.generation).catch(n=>Lt("actions").warn("Preferences shutdown flush failed",n))}):()=>{}}async function S4(){var t;const e=p4(window.location.href);if(En()){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 Ad(s)??e??{section:"general"}}if(bn()){const n=await vs("preferences_get_request");return Ad(n)??e??{section:"general"}}return e??{section:"general"}}async function k4(e){var t,n;return En()?((n=(t=window.electronAPI)==null?void 0:t.onPreferencesSection)==null?void 0:n.call(t,s=>{const r=Ad(s);r&&e(r)}))??(()=>{}):bn()?await Su("preferences:section",s=>{const r=Ad(s.payload);r&&e(r)}):()=>{}}async function x4(e){var t,n;return En()?((n=(t=window.electronAPI)==null?void 0:t.onPreferencesCloseRequested)==null?void 0:n.call(t,e))??(()=>{}):bn()?await Su("preferences:close-requested",e):()=>{}}async function $4(e){var n,s;const t=r=>{r&&typeof r=="object"&&Number.isSafeInteger(r.id)&&e(r.id)};return En()?((s=(n=window.electronAPI)==null?void 0:n.onPreferencesTransitionRequested)==null?void 0:s.call(n,t))??(()=>{}):bn()?await Su("preferences:transition-requested",r=>t(r.payload)):()=>{}}async function _4(e,t){var n,s;En()?await((s=(n=window.electronAPI)==null?void 0:n.resolvePreferencesTransition)==null?void 0:s.call(n,e,t)):bn()&&await vs("preferences_resolve_transition",{id:e,approved:t})}const hh=new Set;let Fw=Promise.resolve();function Bk(e){return hh.add(e),()=>hh.delete(e)}function Ii(){const e=Fw.then(async()=>{for(const t of Array.from(hh))if(!await t())return!1;return!0});return Fw=e.then(()=>{},()=>{}),e}const[Kk,mh]=L(!1),[vi,pp]=L("general"),C4=Lt("actions");async function Vk(e,t=!1){if(t&&Kk()){await Ii()&&mh(!1);return}if(e&&pp(e),(mn.host==="electron"||mn.host==="tauri")&&mn.windowContext==="local")try{const{activeInstanceId:n}=await ts(async()=>{const{activeInstanceId:o}=await Promise.resolve().then(()=>V6);return{activeInstanceId:o}},void 0),s=n()??void 0,r={section:e??"general",instanceId:s};if(s){const{getActiveCatalogLocation:o}=await ts(async()=>{const{getActiveCatalogLocation:a}=await Promise.resolve().then(()=>cq);return{getActiveCatalogLocation:a}},void 0);r.location=o(s)}await y4(r,t,e===void 0);return}catch(n){C4.warn("Native Preferences failed; opening settings in this window",n)}mh(!0)}const EW=e=>Vk(e,!0);function E4(){mh(!1)}function as(e){return ke(e).split(",").map(t=>t.trim()).filter(Boolean)}function Vr(e,t,n){e()!==n&&t()}function ph(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 yp(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}Vr(()=>!!(t().showKeyboardShortcutHints??!1),e.toggleKeyboardShortcutHints,s)},disabled:()=>Wg()},{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}Vr(()=>!!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}Vr(()=>!!(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}Vr(()=>!!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:ph,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}Vr(()=>!!(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}Vr(()=>!!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})}},...Fm()&&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}Vr(()=>!!(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}Vr(()=>!!t().promptSubmitOnEnter,e.togglePromptSubmitOnEnter,s)}}]}function T4(e){return[{id:"prompt-submit-shortcut",label:()=>e.preferences().promptSubmitOnEnter?ke("commands.promptSubmitShortcut.label.swapped"):ke("commands.promptSubmitShortcut.label.default"),description:()=>ke("commands.promptSubmitShortcut.description"),category:"Input & Focus",keywords:()=>as("commands.promptSubmitShortcut.keywords"),action:e.togglePromptSubmitOnEnter},{id:"thinking",label:()=>ke(e.preferences().showThinkingBlocks?"commands.thinkingBlocks.label.hide":"commands.thinkingBlocks.label.show"),description:()=>ke("commands.thinkingBlocks.description"),category:"System",keywords:()=>["/thinking",...as("commands.thinkingBlocks.keywords")],action:e.toggleShowThinkingBlocks},{id:"timeline-tools",label:()=>ke(e.preferences().showTimelineTools?"commands.timelineToolCalls.label.hide":"commands.timelineToolCalls.label.show"),description:()=>ke("commands.timelineToolCalls.description"),category:"System",keywords:()=>as("commands.timelineToolCalls.keywords"),action:e.toggleShowTimelineTools},{id:"keyboard-shortcut-hints",label:()=>ke(e.preferences().showKeyboardShortcutHints?"commands.keyboardShortcutHints.label.hide":"commands.keyboardShortcutHints.label.show"),description:()=>ke(Wg()?"commands.keyboardShortcutHints.description.disabledWeb":"commands.keyboardShortcutHints.description"),category:"System",keywords:()=>as("commands.keyboardShortcutHints.keywords"),disabled:()=>Wg(),action:e.toggleKeyboardShortcutHints},{id:"thinking-default-visibility",label:()=>{const n=(e.preferences().thinkingBlocksExpansion??"expanded")==="expanded"?ke("commands.common.expanded"):ke("commands.common.collapsed");return ke("commands.thinkingBlocksDefault.label",{state:n})},description:()=>ke("commands.thinkingBlocksDefault.description"),category:"System",keywords:()=>["/thinking",...as("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"?"✓ ":""}${ke("commands.diffViewSplit.label")}`,description:()=>ke("commands.diffViewSplit.description"),category:"System",keywords:()=>as("commands.diffViewSplit.keywords"),action:()=>e.setDiffViewMode("split")},{id:"diff-view-unified",label:()=>`${(e.preferences().diffViewMode||"split")==="unified"?"✓ ":""}${ke("commands.diffViewUnified.label")}`,description:()=>ke("commands.diffViewUnified.description"),category:"System",keywords:()=>as("commands.diffViewUnified.keywords"),action:()=>e.setDiffViewMode("unified")},{id:"tool-output-default-visibility",label:()=>{const t=ph(e.preferences()),n=t==="expanded"?ke("commands.common.expanded"):t==="collapsed"?ke("commands.common.collapsed"):ke("commands.common.hidden");return ke("commands.toolOutputsDefault.label",{state:n})},description:()=>ke("commands.toolOutputsDefault.description"),category:"System",keywords:()=>as("commands.toolOutputsDefault.keywords"),action:()=>{const t=ph(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"?ke("commands.common.expanded"):t==="collapsed"?ke("commands.common.collapsed"):ke("commands.common.hidden");return ke("commands.diagnosticsDefault.label",{state:n})},description:()=>ke("commands.diagnosticsDefault.description"),category:"System",keywords:()=>as("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"?ke("commands.common.expanded"):t==="collapsed"?ke("commands.common.collapsed"):ke("commands.common.hidden");return ke("commands.toolInputsVisibility.label",{state:n})},description:()=>ke("commands.toolInputsVisibility.description"),category:"System",keywords:()=>as("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?ke("commands.common.visible"):ke("commands.common.hidden");return ke("commands.tokenUsageDisplay.label",{state:n})},description:()=>ke("commands.tokenUsageDisplay.description"),category:"System",keywords:()=>as("commands.tokenUsageDisplay.keywords"),action:e.toggleUsageMetrics},{id:"auto-cleanup-blank-sessions",label:()=>{const n=e.preferences().autoCleanupBlankSessions?ke("commands.common.enabled"):ke("commands.common.disabled");return ke("commands.autoCleanupBlankSessions.label",{state:n})},description:()=>ke("commands.autoCleanupBlankSessions.description"),category:"System",keywords:()=>as("commands.autoCleanupBlankSessions.keywords"),action:e.toggleAutoCleanupBlankSessions}]}function TW(e,t){T4(t).forEach(s=>e(s))}var M4=F('<div class="flex-1 min-w-0">'),A4=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const rg=[{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"}],D4=()=>{const{t:e,locale:t}=kt(),{updatePreferences:n}=Tn(),s=()=>rg.find(r=>r.value===t())??rg[0];return y(Te,{get value(){return s()},onChange:r=>{!r||r.value===t()||n({locale:r.value})},options:rg,optionValue:"value",optionTextValue:"label",itemComponent:r=>y(Te.Item,{get item(){return r.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return r.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger",get"aria-label"(){return e("folderSelection.language.ariaLabel")},get title(){return e("folderSelection.language.ariaLabel")},get children(){return[y(hA,{class:"w-4 h-4 icon-muted","aria-hidden":"true"}),(()=>{var r=M4();return p(r,y(Te.Value,{children:o=>(()=>{var a=A4();return p(a,()=>{var i;return(i=o.selectedOption())==null?void 0:i.label}),a})()})),r})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover min-w-[180px]",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})};var Nw=F('<div class="flex-1 min-w-0">'),Uw=F("<div><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>"),Bw=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const vp=e=>{const{t}=kt(),[n,s]=L(new Map),r=(i,c)=>{s(l=>{const d=new Map(l);return d.set(i,c),d})};qe(()=>{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=$e(()=>{var f;return!!((f=c.disabled)!=null&&f.call(c))});if(c.kind==="toggle"){const f=$e(()=>[{value:"true",label:t("settings.common.enabled")},{value:"false",label:t("settings.common.disabled")}]),h=$e(()=>f().find(m=>m.value===String(!!o(c))));return(()=>{var m=Uw(),w=m.firstChild,S=w.firstChild,b=S.nextSibling;return p(S,()=>t(c.titleKey)),p(b,()=>t(c.subtitleKey)),p(m,y(Te,{get value(){return h()},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(Te.Item,{get item(){return v.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return v.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger",get"aria-label"(){return t(c.titleKey)},get children(){return[(()=>{var v=Nw();return p(v,y(Te.Value,{children:k=>(()=>{var $=Bw();return p($,()=>{var C;return(C=k.selectedOption())==null?void 0:C.label}),$})()})),v})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),null),de(()=>_s(m,`settings-toggle-row ${l()?"opacity-60":""}`)),m})()}const d=$e(()=>c.options.map(f=>({value:String(f.value),label:t(f.labelKey)}))),u=$e(()=>d().find(f=>f.value===String(o(c)??"")));return(()=>{var f=Uw(),h=f.firstChild,m=h.firstChild,w=m.nextSibling;return p(m,()=>t(c.titleKey)),p(w,()=>t(c.subtitleKey)),p(f,y(Te,{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(Te.Item,{get item(){return S.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return S.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger",get"aria-label"(){return t(c.titleKey)},get children(){return[(()=>{var S=Nw();return p(S,y(Te.Value,{children:b=>(()=>{var v=Bw();return p(v,()=>{var k;return(k=b.selectedOption())==null?void 0:k.label}),v})()})),S})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),null),de(()=>_s(f,`settings-toggle-row ${l()?"opacity-60":""}`)),f})()};return y(Ut,{get each(){return e.settings()},children:i=>y(a,{setting:i})})};var og=F('<button type=button class="selector-button selector-button-secondary">'),P4=F('<button type=button class="selector-button selector-button-primary">'),O4=F("<label class=theme-scheme-name-editor><span></span><input class=selector-input maxlength=80>"),R4=F("<p class=theme-scheme-warning role=alert>"),I4=F('<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>'),L4=F("<button type=button class=theme-scheme-appearance-option>"),F4=F("<option>"),N4=F("<div class=theme-scheme-swatches>"),U4=F("<label class=theme-scheme-swatch><input type=color>");const Kw=[{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"}],B4=()=>{const{t:e}=kt(),t=Tn(),n=GE(),[s,r]=L({...Bv}),[o,a]=L("dark"),[i,c]=L("dark"),l=()=>t.getAppearancePalette(i()),d=()=>t.getAppearancePresetId(i()),[u,f]=L(""),[h,m]=L(e("settings.appearance.colorScheme.option.custom")),[w,S]=L(""),[b,v]=L(!1),[k,$]=L(!1),[C,T]=L(!1),[D,R]=L(!1),[q,re]=L(),[ee,W]=L(!1),U=$e(()=>[...ZE.filter(E=>E.id!=="system"&&(E.id!=="custom"||!JE(t.customColorSchemePreference().colors)||t.customColorSchemePreference().appearance==="light"||l().id==="custom"&&!d())).map(E=>{const H=E.id==="custom"&&l().id==="custom"&&!d(),B=E.id==="light"?YE:E.colors??Bv,oe=E.id==="system"?void 0:E.id==="custom"?H?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"?(H?l():t.customColorSchemePreference()).appearance==="light"?"light":"dark":E.appearance==="light"?"light":"dark",colors:oe??B,originalColors:B}}),...Object.entries(t.colorSchemePresets()).map(([E,H])=>({key:`preset:${E}`,presetId:E,name:H.name,description:e("settings.appearance.colorScheme.description.custom"),appearance:H.appearance,colors:H.colors,originalColors:H.colors}))]),J=$e(()=>d()?`preset:${d()}`:`builtin:${l().id}`),le=$e(()=>U().filter(E=>E.id!=="system"&&E.appearance===i())),z=$e(()=>U().find(E=>E.key===u())),M=$e(()=>QE(s())),N=$e(()=>{const E=z();return E!=null&&E.id?E.id==="custom"?Kw.some(H=>E.colors[H.key]!==E.originalColors[H.key]):!!t.colorSchemeOverrides()[E.id]:!1});qe(()=>{if(!t.isLoaded()||k()||C())return;const E=U().find(H=>H.key===J());E&&(f(E.key),m(E.name),a(E.appearance),r({...E.colors}))}),qe(()=>{const E=n.isDark()?"dark":"light";!k()&&!C()&&c(E)});const ce=async()=>!k()||Wi(e("settings.configFiles.confirmDiscard.message"),{variant:"warning",confirmLabel:e("settings.configFiles.confirmDiscard.confirmLabel"),cancelLabel:e("settings.configFiles.confirmDiscard.cancelLabel"),dismissible:!1}),fe=Bk(ce);nt(fe);const Re=async E=>{if(!(C()||u()===E.key||!await ce())){T(!0),$(!1),v(!1),W(!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"?$i({id:"custom",appearance:E.appearance,colors:E.colors}):$i(E.id))}catch{W(!0)}finally{T(!1)}}},be=async(E,H,B)=>{if(C()||u()!==E.key&&!await ce())return!1;const oe=u()===E.key?s():E.colors;return f(E.key),m(E.name),a(E.appearance),r({...oe,[H]:B.toUpperCase()}),$(!0),W(!1),!0},ye=async()=>{const E=z();if(E!=null&&E.id){T(!0),W(!1);try{E.id==="custom"?await t.setColorSchemePreference($i({id:"custom",appearance:E.appearance,colors:E.originalColors})):await t.resetColorSchemeOverride(E.id),r({...E.originalColors}),a(E.appearance),$(!1)}catch{W(!0)}finally{T(!1)}}},Ce=()=>{const E=Kv(h(),Object.values(t.colorSchemePresets()).map(H=>H.name));S(E),v(!0),$(!0),W(!1)},je=async()=>{if(!k()||!M())return;const E=z();if(!E)return;const H=b()?void 0:E.presetId,B=b()?w().trim():H?E.name:Kv(h(),Object.values(t.colorSchemePresets()).map(oe=>oe.name));if(B){T(!0),W(!1);try{if(!b()&&E.id){E.id==="custom"?await t.setColorSchemePreference($i({id:"custom",appearance:E.appearance,colors:s()})):await t.saveColorSchemeOverride(E.id,E.appearance,s()),$(!1);return}const oe=await t.saveColorSchemePreset(B,o(),s(),H);f(`preset:${oe}`),m(B),v(!1),$(!1)}catch{W(!0)}finally{T(!1)}}},O=async E=>{if(!(!E.presetId||!await Wi(e("settings.appearance.colorScheme.custom.deleteConfirm",{name:E.name}),{variant:"warning",confirmLabel:e("settings.appearance.colorScheme.custom.delete"),dismissible:!1}))){T(!0),W(!1);try{await t.deleteColorSchemePreset(E.presetId);const B=U().find(oe=>oe.key===J())??U().find(oe=>oe.appearance===i());f(B.key),m(B.name),a(B.appearance),c(B.appearance),r({...B.colors}),v(!1),$(!1)}catch{W(!0)}finally{T(!1)}}},g=async E=>{if(!(C()||!await ce())){T(!0),W(!1);try{await t.setThemePreference(E),$(!1),v(!1)}catch{W(!0)}finally{T(!1)}}},x=async E=>{if(re(E),!D()){R(!0);try{for(;q();){const H=q();await Re(H),q()===H&&re(void 0)}}finally{R(!1)}}},A=E=>u()===E.key?s():E.colors;return(()=>{var E=I4(),H=E.firstChild,B=H.firstChild,oe=B.nextSibling,Ae=H.nextSibling,we=Ae.firstChild,he=we.firstChild,Ee=he.nextSibling,Ge=we.nextSibling,Xe=Ge.nextSibling,se=Xe.firstChild,V=se.nextSibling;return p(B,()=>e("settings.appearance.colorScheme.title")),p(oe,()=>e("settings.scope.device")),p(he,()=>e("settings.appearance.palette.mode")),p(Ee,y(Ut,{each:["system","dark","light"],children:Y=>(()=>{var Oe=L4();return Oe.$$click=()=>void g(Y),p(Oe,()=>e(Y==="system"?"settings.appearance.palette.auto":`settings.appearance.colorScheme.custom.appearance.${Y}`)),de(ve=>{var Ie=C(),Le=t.themePreference()===Y?"true":"false",ze=t.themePreference()===Y;return Ie!==ve.e&&(Oe.disabled=ve.e=Ie),Le!==ve.t&&pe(Oe,"data-selected",ve.t=Le),ze!==ve.a&&pe(Oe,"aria-pressed",ve.a=ze),ve},{e:void 0,t:void 0,a:void 0}),Oe})()})),p(Ge,()=>e("settings.appearance.palette.independent")),se.addEventListener("change",Y=>{const Oe=Y.currentTarget,ve=U().find(Ie=>Ie.key===Oe.value);ve&&x(ve)}),p(se,y(Ut,{get each(){return le()},children:Y=>(()=>{var Oe=F4();return p(Oe,()=>Y.name),de(()=>{var ve;return Oe.selected=(((ve=q())==null?void 0:ve.key)??u())===Y.key}),de(()=>Oe.value=Y.key),Oe})()})),p(Xe,y(Q,{get when(){return z()},keyed:!0,children:Y=>(()=>{var Oe=N4();return p(Oe,y(Ut,{each:Kw,children:ve=>{const Ie=()=>A(Y)[ve.key],Le=()=>e(ve.labelKey);return(()=>{var ze=U4(),Ne=ze.firstChild;return Ne.$$input=Je=>{const ot=Je.currentTarget;be(Y,ve.key,ot.value).then(gt=>{gt||(ot.value=Ie())})},de(Je=>{var ot=Le(),gt=C(),_=`${Y.name} · ${Le()} · ${Ie()}`;return ot!==Je.e&&pe(ze,"title",Je.e=ot),gt!==Je.t&&(Ne.disabled=Je.t=gt),_!==Je.a&&pe(Ne,"aria-label",Je.a=_),Je},{e:void 0,t:void 0,a:void 0}),de(()=>Ne.value=Ie()),ze})()}})),Oe})()}),V),p(V,y(Q,{get when(){var Y;return(Y=z())==null?void 0:Y.presetId},get children(){var Y=og();return Y.$$click=()=>void O(z()),p(Y,()=>e("settings.appearance.colorScheme.custom.delete")),de(()=>Y.disabled=b()||C()),Y}}),null),p(V,y(Q,{get when(){return N()},get children(){var Y=og();return Y.$$click=()=>void ye(),p(Y,()=>e("settings.appearance.colorScheme.custom.reset")),de(()=>Y.disabled=b()||C()),Y}}),null),p(V,y(Q,{get when(){return!b()},get children(){var Y=og();return Y.$$click=Ce,p(Y,()=>e("settings.appearance.colorScheme.custom.new")),de(()=>Y.disabled=C()),Y}}),null),p(V,y(Q,{get when(){return k()},get children(){var Y=P4();return Y.$$click=()=>void je(),p(Y,()=>e("settings.appearance.colorScheme.custom.save")),de(()=>Y.disabled=!M()||C()||b()&&!w().trim()),Y}}),null),p(Ae,y(Q,{get when(){return b()},get children(){var Y=O4(),Oe=Y.firstChild,ve=Oe.nextSibling;return p(Oe,()=>e("settings.appearance.colorScheme.custom.name")),ve.$$input=Ie=>S(Ie.currentTarget.value),de(()=>ve.value=w()),Y}}),null),p(Ae,y(Q,{get when(){return ee()},get children(){var Y=R4();return p(Y,()=>e("settings.appearance.colorScheme.custom.saveError")),Y}}),null),de(Y=>{var Oe=e("settings.appearance.palette.mode"),ve=C()&&!D(),Ie=D(),Le=e("settings.appearance.colorScheme.title");return Oe!==Y.e&&pe(Ee,"aria-label",Y.e=Oe),ve!==Y.t&&(se.disabled=Y.t=ve),Ie!==Y.a&&pe(se,"aria-busy",Y.a=Ie),Le!==Y.o&&pe(se,"aria-label",Y.o=Le),Y},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>{var Y,Oe;return se.value=((Y=q())==null?void 0:Y.key)??((Oe=z())==null?void 0:Oe.key)??""}),E})()};Ht(["click","input"]);var K4=F("<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 V4=gS(()=>ts(()=>import("./startup-state-settings-card-DMFtdRoa.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.StartupStateSettingsCard}))),Vw=e=>{const{t}=kt(),n=Tn(),s=$e(()=>yp(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=K4(),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(D4,{}),null),p(r,y(B4,{}),u),p(r,y(Q,{get when(){return e.showStartupState!==!1},get children(){return y(V4,{})}}),u),p(f,y(vp,{settings:s,get preferences(){return n.preferences}})),r})()},sl="other",Dd={minimal:"collapsed",balanced:"collapsed",detailed:"expanded",everything:"expanded"},ct="expanded",Mt="collapsed";const Nu=[{tool:"bash",label:"shell",aliases:["shell"],configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"read",label:"read",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:Mt,everything:ct}},{tool:"write",label:"write",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"edit",label:"edit",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"patch",label:"patch",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"apply_patch",label:"apply_patch",configurable:!1,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"webfetch",label:"webfetch",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}},{tool:"websearch",label:"websearch",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}},{tool:"glob",label:"glob",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}},{tool:"grep",label:"grep",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}},{tool:"todowrite",label:"todowrite",configurable:!1,expansionPresets:{minimal:ct,balanced:ct,detailed:ct,everything:ct}},{tool:"task",label:"subagent",aliases:["subagent"],configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"execute",label:"execute",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"skill",label:"skill",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:Mt,everything:ct}},{tool:"question",label:"question",configurable:!0,expansionPresets:{minimal:Mt,balanced:ct,detailed:ct,everything:ct}},{tool:"invalid",label:"invalid",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:Mt,everything:ct}},{tool:sl,label:"Other tools",labelKey:"settings.behavior.expansionDefaults.otherTools",configurable:!0,expansionPresets:{minimal:Mt,balanced:Mt,detailed:ct,everything:ct}}],jk=Nu.find(e=>e.tool===sl),j4=Nu.reduce((e,t)=>{var n;return e[t.tool]=t,(n=t.aliases)==null||n.forEach(s=>{e[s]=t}),e},{});function qk(e){return j4[e]??jk}function MW(e){return qk(e).tool}function q4(){return Nu}function zk(){return Nu.filter(e=>e.configurable)}function z4(e){const t={};for(const n of zk())t[n.tool]=n.expansionPresets[e];return t}function wp(e,t){const n=qk(t),s=e.toolCallExpansionDefaults,r=s.preset==="custom"?void 0:n.expansionPresets[s.preset],o=s.preset==="custom"?void 0:jk.expansionPresets[s.preset];return s.tools[n.tool]??r??s.tools[sl]??o??e.toolOutputExpansion??"expanded"}function AW(e,t){return wp(e,t)==="expanded"}function DW(e){const t=e.toolCallExpansionDefaults;return(t.thinking??(t.preset==="custom"?void 0:Dd[t.preset])??e.thinkingBlocksExpansion??"expanded")==="expanded"}const jw={thinking:P2,diagnostics:ZA,inputs:bA,usage:q2,system:Xm,bash:ep,read:A2,write:Z2,edit:IA,patch:OA,apply_patch:dd,webfetch:Bo,glob:pw,grep:pw,todowrite:B2,task:R2,execute:V2,websearch:Bo,skill:iA,question:cA,invalid:Ko,other:pA},W4={"apply-patch":"apply_patch",shell:"bash",subagent:"task",terminal:"bash",todo:"todowrite",todo_write:"todowrite",web_fetch:"webfetch"};function H4(e){const t=(e==null?void 0:e.trim().toLowerCase().replace(/^opencode_/,""))??"",n=W4[t]??t;return jw[n]??jw.other}function G4(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")},...zk().map(t=>({kind:"tool",key:t.tool,label:t.labelKey?e(t.labelKey):t.label}))]}function Wk(e){const t=e.toolCallExpansionDefaults;return t.thinking??(t.preset==="custom"?void 0:Dd[t.preset])??e.thinkingBlocksExpansion??"expanded"}function qw(e,t){switch(t.kind){case"thinking":return e.showThinkingBlocks?Wk(e):"hidden";case"tool":return wp(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 Z4(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(q4().map(o=>[o.tool,wp(e,o.tool)]));t.kind==="tool"&&(s[t.key]=n);const r=t.kind==="thinking"&&n!=="hidden"?n:Wk(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===sl&&n!=="hidden"?n:e.toolOutputExpansion}}var J4=F("<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>"),Y4=F("<button type=button class=settings-expansion-preset><span class=settings-expansion-preset-title></span><span class=settings-expansion-preset-copy>"),Q4=F('<div class="flex-1 min-w-0">'),X4=F('<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>'),eO=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const tO=["minimal","balanced","detailed","everything"],zw={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"}},nO=()=>{const{t:e}=kt(),{preferences:t,updatePreferences:n}=Tn(),s=$e(()=>[{value:"hidden",label:e("commands.common.hidden")},{value:"collapsed",label:e("commands.common.collapsed")},{value:"expanded",label:e("commands.common.expanded")}]),r=$e(()=>G4(e)),o=()=>qw(t(),{kind:"thinking",key:"thinking"}),a=$e(()=>{const f=t(),h=f.toolCallExpansionDefaults.preset;if(h==="custom")return h;const m=zw[h],w=m.showThinkingBlocks?Dd[h]:"hidden";return o()===w&&f.diagnosticsExpansion===m.diagnosticsExpansion&&f.systemMessagesVisibility===m.systemMessagesVisibility&&f.toolInputsVisibility===m.toolInputsVisibility&&f.showUsageMetrics===m.showUsageMetrics&&f.usageMetricsExpansion===m.usageMetricsExpansion?h:"custom"}),i=f=>{const h=z4(f),m=Dd[f];n({...zw[f],toolCallExpansionDefaults:{preset:f,thinking:m,tools:h},thinkingBlocksExpansion:m,toolOutputExpansion:h[sl]==="expanded"?"expanded":"collapsed"})},c=(f,h)=>{n(Z4(t(),f,h))},l=f=>qw(t(),f),d=f=>s().find(h=>h.value===f),u=f=>e(`settings.behavior.expansionPreset.${f}.title`);return(()=>{var f=J4(),h=f.firstChild,m=h.firstChild,w=m.firstChild,S=w.firstChild,b=S.nextSibling,v=w.nextSibling,k=m.nextSibling,$=k.nextSibling,C=$.firstChild,T=C.firstChild,D=T.nextSibling;return p(S,()=>e("settings.behavior.expansionPresets.ariaLabel")),p(b,()=>e("settings.appearance.behavior.subtitle")),p(v,()=>u(a())),p(k,y(Ut,{each:tO,children:R=>(()=>{var q=Y4(),re=q.firstChild,ee=re.nextSibling;return q.$$click=()=>i(R),p(re,()=>u(R)),p(ee,()=>e(`settings.behavior.expansionPreset.${R}.description`)),de(()=>pe(q,"data-selected",a()===R?"true":"false")),q})()})),p(T,()=>e("settings.behavior.expansionDefaults.itemColumn")),p(D,()=>e("settings.behavior.expansionDefaults.stateColumn")),p($,y(Ut,{get each(){return r()},children:R=>{const q=$e(()=>d(l(R)));return(()=>{var re=X4(),ee=re.firstChild,W=ee.firstChild,U=ee.nextSibling;return p(ee,y(Bm,{get component(){return H4(R.key)},class:"w-4 h-4 shrink-0 text-secondary","aria-hidden":"true"}),W),p(W,()=>R.label),p(U,y(Te,{get value(){return q()},onChange:J=>J&&c(R,J.value),get options(){return s()},optionValue:"value",optionTextValue:"label",itemComponent:J=>y(Te.Item,{get item(){return J.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return J.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger settings-expansion-select",get"aria-label"(){return e("settings.behavior.expansionDefaults.rowAriaLabel",{item:R.label})},get children(){return[(()=>{var J=Q4();return p(J,y(Te.Value,{children:le=>(()=>{var z=eO();return p(z,()=>{var M;return(M=le.selectedOption())==null?void 0:M.label}),z})()})),J})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})),re})()}}),null),de(R=>{var q=e("settings.behavior.expansionPresets.ariaLabel"),re=e("settings.behavior.expansionDefaults.title");return q!==R.e&&pe(k,"aria-label",R.e=q),re!==R.t&&pe($,"aria-label",R.t=re),R},{e:void 0,t:void 0}),f})()};Ht(["click"]);const jr=Lt("actions");async function sO(e){try{if(typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),jr.info("Copied text using Clipboard API"),!0}catch(s){jr.warn("Clipboard API failed, trying fallback:",s)}let t;const n=typeof document<"u"?document.activeElement:null;try{return typeof document>"u"?(jr.error("Document not available for clipboard fallback"),!1):(t=document.createElement("textarea"),t.value=e,t.readOnly=!0,t.style.position="fixed",t.style.left="-9999px",t.style.top="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy")?(jr.info("Copied text using execCommand fallback"),!0):(jr.error("execCommand copy failed"),!1))}catch(s){return jr.error("Clipboard fallback failed:",s),!1}finally{try{t==null||t.remove()}catch(s){jr.warn("Failed to remove clipboard fallback element:",s)}try{n==null||n.focus()}catch(s){jr.warn("Failed to restore focus after clipboard fallback:",s)}}}let ig=null,qa=null;async function Ww(e=!1){if(ig&&!e)return ig;if(qa)return qa;const t=ft.fetchServerMeta().then(n=>(ig=n,n));qa=t;try{return await t}finally{qa===t&&(qa=null)}}function yh(e){return Hk(e.host)?"all":e.listeningMode==="all"?"specific":e.listeningMode}function vh(e){if(Hk(e.host))return e.addresses;const t=wh(e.host);return e.addresses.filter(n=>wh(n.ip)===t)}function Hk(e){const t=wh(e);return t==="0.0.0.0"?!0:t.includes(":")&&t.split(":").every(n=>n===""||/^0+$/.test(n))}function wh(e){const t=e.trim().toLowerCase();return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}function Hw(e,t,n,s,r=new Date){var c,l;const o=e?vh(e):[],a=e?s.modes[yh(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 rO=F("<div class=settings-card-message role=status aria-live=polite>"),Gw=F("<div class=settings-error-message role=alert>"),oO=F('<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>'),iO=F('<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>'),aO=F("<h4 class=settings-card-title>"),cO=F("<dl class=settings-info-grid>"),lO=F("<p class=settings-help-text>"),dO=F("<div class=settings-info-actions><button type=button class=settings-pill-button>"),uO=F('<div class=settings-info-row><dt class=settings-info-label></dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),fO=F("<div class=settings-card-message>"),gO=F('<div class=settings-info-row><dt class=settings-info-label> · </dt><dd class="settings-info-value settings-info-value-muted"dir=ltr>'),hO=F('<a target=_blank rel="noopener noreferrer"class=settings-pill-button>'),mO=F("<div class=settings-info-toast role=status aria-live=polite>");function Gk(){return navigator.userAgentData}function pO(){if(typeof navigator>"u")return"Unknown";const e=Gk();if(e!=null&&e.platform){const r=Zw(navigator.userAgent);return r?`${e.platform} ${r}`:e.platform}const t=navigator.userAgent,n=navigator.platform;if(!n)return"Unknown";const s=Zw(t);return s&&!n.includes(s)?`${n} ${s}`:n}function Zw(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 yO(){try{const e=Gk();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 vO(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 Jw(e){return e.replace(/^v/,"").split("-")[0]}function wO(e,t){const n=Jw(e).split(".").map(Number),s=Jw(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 bO=()=>{const{t:e}=kt(),[t,n]=L(!1),[s,{mutate:r}]=hS(async()=>{n(!1);try{return await Ww()}catch{return n(!0),null}}),[o,a]=L(null),[i,c]=L(null);qe(()=>{yO().then(k=>{k&&c(k)})});const l=$e(()=>{const k=s();return k!=null&&k.update?k.update:null}),d=$e(()=>{var k;return((k=s())==null?void 0:k.support)??null}),u=$e(()=>({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=$e(()=>{var $;const k=l();return k!=null&&k.version?k.version:(($=d())==null?void 0:$.latestServerVersion)??null}),h=$e(()=>{var D,R;let k=null;const $=l();if($!=null&&$.url?k=$.url:(D=d())!=null&&D.latestServerUrl&&(k=d().latestServerUrl??null),!k)return{url:null,show:!1};if($!=null&&$.url)return{url:k,show:!0};const C=(R=s())==null?void 0:R.serverVersion,T=f();return!C||!T?{url:null,show:!1}:{url:k,show:wO(C,T)!==!1}});let m;qe(()=>{o()&&(clearTimeout(m),m=setTimeout(()=>a(null),2500))}),nt(()=>clearTimeout(m));const w=async()=>{n(!1);try{const k=await Ww(!0);r(k)}catch{n(!0)}},S=$e(()=>{const k=pO(),$=i();return $?`${k} (${$})`:k}),b=async()=>{const k=Hw(s()??null,S(),mn,u()),$=await sO(k);a($?"success":"error")},v=()=>{const k=Hw(s()??null,S(),mn,u()),$=new Date().toISOString().replace(/[:.]/g,"-");vO(`codenomad-diagnostics-${$}.txt`,k)};return(()=>{var k=oO(),$=k.firstChild,C=$.firstChild,T=C.firstChild,D=T.firstChild,R=D.firstChild,q=R.nextSibling,re=C.nextSibling,ee=re.firstChild,W=ee.firstChild,U=W.nextSibling,J=ee.nextSibling,le=J.firstChild,z=le.nextSibling,M=J.nextSibling,N=M.firstChild,ce=N.nextSibling,fe=M.nextSibling,Re=fe.firstChild,be=Re.nextSibling,ye=fe.nextSibling,Ce=ye.firstChild,je=Ce.nextSibling,O=$.nextSibling,g=O.firstChild,x=g.firstChild,A=x.firstChild,E=A.firstChild,H=E.nextSibling,B=O.nextSibling,oe=B.firstChild,Ae=oe.firstChild,we=Ae.firstChild,he=we.nextSibling,Ee=oe.nextSibling,Ge=Ee.firstChild,Xe=Ge.firstChild,se=Xe.nextSibling,V=Ge.nextSibling,Y=V.firstChild,Oe=Y.nextSibling,ve=Ee.nextSibling,Ie=ve.firstChild,Le=B.nextSibling,ze=Le.firstChild,Ne=ze.firstChild,Je=Ne.firstChild,ot=Je.nextSibling,gt=ze.nextSibling,_=gt.nextSibling,P=_.firstChild,j=P.nextSibling;return p(T,y(Xm,{class:"settings-card-heading-icon"}),D),p(R,()=>e("settings.section.info.title")),p(q,()=>e("settings.section.info.subtitle")),p(W,()=>e("settings.info.version.ui")),p(U,()=>{var K,I;return((I=(K=s())==null?void 0:K.ui)==null?void 0:I.version)??"—"}),p(le,()=>e("settings.info.version.uiSource")),p(z,()=>{var K,I;return((I=(K=s())==null?void 0:K.ui)==null?void 0:I.source)??"—"}),p(N,()=>e("settings.info.runtime.type")),p(ce,()=>mn.host),p(Re,()=>e("settings.info.runtime.platform")),p(be,()=>mn.platform),p(Ce,()=>e("settings.info.runtime.os")),p(je,S),p(x,y(DA,{class:"settings-card-heading-icon"}),A),p(E,()=>e("settings.info.connectivity.title")),p(H,()=>e("settings.info.connectivity.subtitle")),p(O,y(Q,{get when(){return s.loading},get children(){var K=rO();return p(K,()=>e("remoteAccess.addresses.loading")),K}}),null),p(O,y(Q,{get when(){return t()},get children(){var K=Gw();return p(K,()=>e("settings.info.connectivity.loadFailed")),K}}),null),p(O,y(Q,{get when(){return s()},children:K=>[(()=>{var I=iO(),Z=I.firstChild,xe=Z.firstChild,De=xe.nextSibling,Qe=Z.nextSibling,et=Qe.firstChild,Tt=et.nextSibling,He=Qe.nextSibling,yt=He.firstChild,Qt=yt.nextSibling,Ot=He.nextSibling,Dn=Ot.firstChild,Wn=Dn.nextSibling,Hn=Ot.nextSibling,Gn=Hn.firstChild,dr=Gn.nextSibling;return p(xe,()=>e("settings.info.version.server")),p(De,()=>K().serverVersion??"—"),p(et,()=>e("remoteAccess.sections.listeningMode.label")),p(Tt,()=>e(yh(K())==="specific"?"settings.info.connectivity.mode.specific":yh(K())==="all"?"settings.info.connectivity.mode.all":"settings.info.connectivity.mode.local")),p(yt,()=>e("settings.info.connectivity.host")),p(Qt,()=>K().host),p(Dn,()=>e("settings.info.connectivity.localListener")),p(Wn,()=>K().localUrl),p(I,y(Q,{get when(){return K().remoteUrl},children:mi=>(()=>{var ur=uO(),js=ur.firstChild,pi=js.nextSibling;return p(js,()=>e("settings.info.connectivity.remoteListener")),p(pi,mi),ur})()}),Hn),p(Gn,()=>e("settings.info.server.root")),p(dr,()=>K().workspaceRoot),I})(),(()=>{var I=aO();return p(I,()=>e("remoteAccess.sections.addresses.label")),I})(),y(Q,{get when(){return vh(K()).length>0},get fallback(){return(()=>{var I=fO();return p(I,()=>e("remoteAccess.addresses.none")),I})()},get children(){var I=cO();return p(I,y(Ut,{get each(){return vh(K())},children:Z=>(()=>{var xe=gO(),De=xe.firstChild,Qe=De.firstChild,et=De.nextSibling;return p(De,()=>Z.family.toUpperCase(),Qe),p(De,()=>e(Z.scope==="external"?"remoteAccess.address.scope.network":Z.scope==="internal"?"remoteAccess.address.scope.internal":"remoteAccess.address.scope.loopback"),null),p(et,()=>Z.remoteUrl),xe})()})),I}}),(()=>{var I=lO();return p(I,()=>e("settings.info.connectivity.disclaimer")),I})(),y(Q,{get when(){return qi()},get children(){var I=dO(),Z=I.firstChild;return Z.$$click=()=>Vk("remote"),p(Z,()=>e("settings.nav.remote")),I}})]}),null),p(we,()=>e("settings.info.updates.title")),p(he,()=>e("settings.info.updates.subtitle")),p(Xe,()=>e("settings.info.version.server")),p(se,()=>{var K;return((K=s())==null?void 0:K.serverVersion)??"—"}),p(Y,()=>e("settings.info.updates.latest")),p(Oe,()=>f()??"—"),p(ve,(()=>{var K=_e(()=>!!h().show);return()=>K()&&(()=>{var I=hO();return p(I,()=>e("settings.info.updates.download")),de(()=>pe(I,"href",h().url)),I})()})(),Ie),Ie.$$click=w,p(Ie,()=>e("settings.info.updates.refresh")),p(Je,()=>e("settings.info.diagnostics.title")),p(ot,()=>e("settings.info.diagnostics.subtitle")),p(gt,()=>e("settings.info.diagnostics.privacy")),P.$$click=b,p(P,()=>e("settings.info.diagnostics.copy")),j.$$click=v,p(j,()=>e("settings.info.diagnostics.download")),p(Le,(()=>{var K=_e(()=>o()==="success");return()=>K()&&(()=>{var I=mO();return p(I,()=>e("settings.info.diagnostics.copied")),I})()})(),null),p(Le,(()=>{var K=_e(()=>o()==="error");return()=>K()&&(()=>{var I=Gw();return p(I,()=>e("settings.info.diagnostics.copyFailed")),I})()})(),null),de(()=>Ie.disabled=s.loading),k})()};Ht(["click"]);var SO=F('<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>'),kO=F("<p>"),xO=F('<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 Yw=50;let gs=[];const bh=new Set,[$O,_O]=L(0);function PW(){return $O}function rl(){_O(gs.filter(e=>!e.read).length)}function ol(){const e=[...gs];bh.forEach(t=>{try{t(e)}catch(n){console.error("[notifications] subscriber error:",n)}})}function CO(){return`toast_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function EO(){gs.length>Yw&&(gs=gs.slice(0,Yw))}function TO(e){const t={...e,id:CO(),createdAt:Date.now(),read:!1};return gs.unshift(t),EO(),rl(),ol(),t.id}function OW(){gs=[],rl(),ol()}function RW(e){const t=gs.find(n=>n.id===e);t&&!t.read&&(t.read=!0,rl(),ol())}function IW(){let e=!1;gs.forEach(t=>{t.read||(t.read=!0,e=!0)}),e&&(rl(),ol())}function LW(e){const t=gs.findIndex(n=>n.id===e);t!==-1&&(gs.splice(t,1),rl(),ol())}function FW(e){return bh.add(e),e([...gs]),()=>{bh.delete(e)}}async function Qw(e){if(!(typeof window>"u")){try{if(bn()){const{openUrl:t}=await ts(async()=>{const{openUrl:n}=await import("./index-DTGOXoDH.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),Rn.error(ke("toastHistory.openLinkError"))}}}async function MO(e){if(!e.onClick){await Qw(e.href);return}try{await e.onClick()}catch(t){console.warn("[notifications] action failed; opening fallback link",t),await Qw(e.href)}}const AO={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 Fn(e){const t=AO[e.variant],n=e.duration??1e4;TO({title:e.title,message:e.message,variant:e.variant,action:e.action});const s=Rn.custom(()=>(()=>{var r=SO(),o=r.firstChild,a=o.nextSibling,i=a.firstChild,c=i.nextSibling,l=c.firstChild;return o.$$click=()=>Rn.dismiss(s),p(c,(()=>{var d=_e(()=>!!e.title);return()=>d()&&(()=>{var u=kO();return p(u,()=>e.title),de(()=>_s(u,`break-words ${t.headline} font-semibold`)),u})()})(),l),p(l,()=>e.message),p(c,(()=>{var d=_e(()=>!!e.action);return()=>d()&&(()=>{var u=xO();return u.$$click=()=>void MO(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=ke("toastHistory.close"),h=ke("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&&_s(r,d.e=u),f!==d.t&&pe(o,"aria-label",d.t=f),h!==d.a&&pe(o,"title",d.a=h),m!==d.o&&_s(i,d.o=m),w!==d.i&&_s(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:()=>Rn.dismiss(s)}}Ht(["click"]);const Uu=Lt("actions");function Bu(){return typeof window<"u"&&typeof window.Notification<"u"}function bp(){if(!Bu())return"unsupported";const e=window.Notification.permission;return e==="granted"?"granted":e==="denied"?"denied":"default"}async function DO(){if(!Bu())return"unsupported";try{const e=await window.Notification.requestPermission();return e==="granted"?"granted":e==="denied"?"denied":"default"}catch(e){return Uu.warn("[os-notifications] requestPermission failed",e),bp()}}async function PO(e){if(!Bu())throw new Error("Web notifications not supported");if(bp()!=="granted")throw new Error("Web notification permission not granted");new window.Notification(e.title,{body:e.body})}function Sp(){if(typeof window>"u")return!1;const e=window.electronAPI;return!!(e&&typeof e.showNotification=="function")}function NW(){return typeof window>"u"?!1:En()?Sp():bn()?!0:Bu()}async function OO(e){const t=window.electronAPI;if(!t||typeof t.showNotification!="function")throw new Error("Electron notification bridge unavailable");await t.showNotification(e)}async function kp(){try{return await ts(()=>import("./index-Cgp1TEtC.js"),__vite__mapDeps([10,6,2,3,4,5,1,7]))}catch(e){return Uu.info("[os-notifications] tauri notification plugin not available",e),null}}async function Zk(){const e=await kp();if(!e)return"unsupported";try{return await e.isPermissionGranted()?"granted":"default"}catch(t){return Uu.warn("[os-notifications] failed to check tauri notification permission",t),"default"}}async function RO(){const e=await kp();if(!e)return"unsupported";try{const t=await e.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"default"}catch(t){return Uu.warn("[os-notifications] failed to request tauri notification permission",t),await Zk()}}async function IO(e){const t=await kp();if(!t)throw new Error("Tauri notification plugin unavailable");await t.sendNotification({title:e.title,body:e.body})}async function LO(){if(typeof window>"u")return{supported:!1,permission:"unsupported",info:"Not available in this environment."};if(En())return Sp()?{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(bn()){const n=await Zk(),s=n!=="unsupported";return{supported:s,permission:n,info:s?void 0:"Tauri notification support is not available in this build."}}const e=bp(),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 Xw(){return typeof window>"u"?"unsupported":En()?Sp()?"granted":"unsupported":bn()?await RO():await DO()}async function FO(e){if(!(typeof window>"u")){if(En()){await OO(e);return}if(bn()){await IO(e);return}await PO(e)}}var NO=F('<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">'),eb=F("<div class=settings-inline-note>"),UO=F("<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 BO(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 KO=()=>{const{t:e}=kt(),{preferences:t,updatePreferences:n}=Tn(),[s,{refetch:r}]=hS(()=>LO());qe(()=>{r()});const o=async d=>{if(!d){n({osNotificationsEnabled:!1});return}const u=s();if(u&&!u.supported){Fn({title:e("settings.section.notifications.title"),message:u.info??e("settings.notifications.messages.unsupportedEnvironment"),variant:"warning"}),n({osNotificationsEnabled:!1});return}const f=await Xw();if(f!=="granted"){Fn({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){Fn({title:e("settings.section.notifications.title"),message:d.info??e("settings.notifications.messages.unsupportedGeneral"),variant:"warning"});return}const u=await Xw();if(u==="granted"){Fn({title:e("settings.section.notifications.title"),message:e("settings.notifications.messages.permissionGranted"),variant:"success",duration:6e3}),r();return}Fn({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 BO(((d=s())==null?void 0:d.permission)??"unsupported",e)},l=()=>{var d;return(d=s())==null?void 0:d.info};return(()=>{var d=UO(),u=d.firstChild,f=u.firstChild,h=f.firstChild,m=h.firstChild,w=m.firstChild,S=w.nextSibling,b=h.nextSibling,v=f.nextSibling,k=v.firstChild,$=k.firstChild,C=$.firstChild,T=C.nextSibling,D=$.nextSibling,R=D.firstChild,q=R.nextSibling,re=k.nextSibling,ee=re.firstChild,W=ee.firstChild,U=W.nextSibling,J=ee.nextSibling,le=J.firstChild,z=le.nextSibling,M=u.nextSibling,N=M.firstChild,ce=N.firstChild,fe=ce.firstChild,Re=fe.nextSibling,be=ce.nextSibling,ye=N.nextSibling,Ce=ye.firstChild,je=Ce.firstChild,O=je.firstChild,g=je.nextSibling,x=g.firstChild,A=x.nextSibling,E=Ce.nextSibling,H=E.firstChild,B=H.firstChild,oe=H.nextSibling,Ae=oe.firstChild,we=Ae.nextSibling;return p(h,y(GS,{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(C,()=>e("settings.notifications.enable.title")),p(T,()=>e("settings.notifications.enable.permission",{permission:c()})),R.addEventListener("change",he=>void o(he.currentTarget.checked)),p(q,()=>e("settings.common.enabled")),p(v,y(Q,{get when(){var he;return _e(()=>!!i())()&&(((he=s())==null?void 0:he.permission)??"unsupported")!=="granted"},get children(){var he=NO(),Ee=he.firstChild,Ge=Ee.firstChild,Xe=Ge.nextSibling,se=Ee.nextSibling;return p(Ge,()=>e("settings.notifications.requestPermission.title")),p(Xe,()=>e("settings.notifications.requestPermission.subtitle")),se.$$click=()=>void a(),p(se,()=>e("settings.notifications.requestPermission.action")),he}}),re),p(W,()=>e("settings.notifications.allowVisible.title")),p(U,()=>e("settings.notifications.allowVisible.subtitle")),le.addEventListener("change",he=>n({osNotificationsAllowWhenVisible:he.currentTarget.checked})),p(z,()=>e("settings.common.enabled")),p(v,y(Q,{get when(){return!!l()},get children(){var he=eb();return p(he,l),he}}),null),p(v,y(Q,{get when(){return _e(()=>!i())()&&s.state==="ready"},get children(){var he=eb();return p(he,()=>e("settings.notifications.unsupportedNote")),he}}),null),p(fe,()=>e("settings.notifications.events.title")),p(Re,()=>e("settings.notifications.events.subtitle")),p(be,()=>e("settings.scope.device")),p(O,()=>e("settings.notifications.events.needsInput")),x.addEventListener("change",he=>n({notifyOnNeedsInput:he.currentTarget.checked})),p(A,()=>e("settings.common.enabled")),p(B,()=>e("settings.notifications.events.idle")),Ae.addEventListener("change",he=>n({notifyOnIdle:he.currentTarget.checked})),p(we,()=>e("settings.common.enabled")),de(he=>{var Ee=!i()&&s.state==="ready",Ge=!t().osNotificationsEnabled,Xe=!t().osNotificationsEnabled,se=!t().osNotificationsEnabled;return Ee!==he.e&&(R.disabled=he.e=Ee),Ge!==he.t&&(le.disabled=he.t=Ge),Xe!==he.a&&(x.disabled=he.a=Xe),se!==he.o&&(Ae.disabled=he.o=se),he},{e:void 0,t:void 0,a:void 0,o:void 0}),de(()=>R.checked=!!t().osNotificationsEnabled),de(()=>le.checked=!!t().osNotificationsAllowWhenVisible),de(()=>x.checked=!!t().notifyOnNeedsInput),de(()=>Ae.checked=!!t().notifyOnIdle),d})()};Ht(["click"]);function tb(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 Jk(e){return e==="wav"?"audio/wav":e==="opus"?VO(e):e==="aac"?"audio/aac":"audio/mpeg"}function Yk(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 VO(e){const t=Yk(e);return typeof MediaSource>"u"?t[0]:t.find(n=>MediaSource.isTypeSupported(n))??t[0]}function Tc(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"||!Yk(e.ttsFormat).some(n=>MediaSource.isTypeSupported(n))?{available:!1,reason:"browser-streaming-unavailable"}:{available:!0}:{available:!1,reason:"provider-streaming-unavailable"}}const Sh=new Map;let gn=null;function jO(e){var t;(t=Sh.get(e))==null||t()}function kh(e){if(!gn||e&&gn.ownerId!==e)return;const t=gn;gn=null,t.stop()}function nb(e,t){if((gn==null?void 0:gn.ownerId)===e){gn={ownerId:e,stop:t};return}kh(),gn={ownerId:e,stop:t}}function qO(e){const{t}=kt(),{serverSettings:n}=Tn(),[s,r]=L("idle");let o=0,a=null,i=null,c=null;qe(()=>{kc()});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")};Sh.set(e.id(),d),nt(()=>{Sh.delete(e.id()),kh(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))??{}}},h=()=>{const k=Jr();return!u()||!(k!=null&&k.available)||!(k!=null&&k.ttsConfigured)||!(k!=null&&k.supportsTts)?!1:Tc({playbackMode:f().playbackMode,ttsFormat:f().ttsFormat,capabilities:k}).available},m=()=>{(gn==null?void 0:gn.ownerId)===e.id()&&(gn=null),d()},w=async()=>{const k=e.id(),$=e.text().trim();if(!$||s()==="loading"||s()==="playing")return;if(!u()){Cs(t("messageItem.actions.speak.error.unsupported"),{title:t("messageItem.actions.speak.error.title"),variant:"error"});return}const C=await kc()??Jr();if(!(C!=null&&C.available)||!(C!=null&&C.ttsConfigured)||!(C!=null&&C.supportsTts)){Cs(t("messageItem.actions.speak.error.unavailable"),{title:t("messageItem.actions.speak.error.title"),variant:"error"});return}const T=Tc({playbackMode:f().playbackMode,ttsFormat:f().ttsFormat,capabilities:C});if(!T.available){const re=T.reason==="provider-streaming-unavailable"?"settings.speech.compatibility.streamingUnavailable":T.reason==="browser-streaming-unavailable"?"settings.speech.compatibility.browserStreamingUnavailable":"messageItem.actions.speak.error.unsupported";Cs(t("messageItem.actions.speak.error.unavailable"),{title:t("messageItem.actions.speak.error.title"),detail:t(re),variant:"error"});return}o+=1;const D=o;kh(),l(),r("loading");const R=f(),q=R.ttsFormat;try{R.playbackMode==="streaming"?await b(k,D,$,q):await S(k,D,$,q)}catch(re){if(D!==o)return;d(),Cs(t("messageItem.actions.speak.error.generate"),{title:t("messageItem.actions.speak.error.title"),detail:re instanceof Error?re.message:String(re),variant:"error"})}};async function S(k,$,C,T){const D=await ft.synthesizeSpeech({text:C,format:T});if($!==o)return;const R=GO(D.audioBase64,D.mimeType),q=new Audio(R);i=R,a=q,sb(k,q),nb(k,()=>{l(),r("idle")}),r("playing"),await q.play()}async function b(k,$,C,T){if(typeof MediaSource>"u")throw new Error("MediaSource is not available in this browser.");const D=new AbortController;c=D;const R=await ft.synthesizeSpeechStream({text:C,format:T},D.signal),q=R.headers.get("content-type")||Jk(T);if(!MediaSource.isTypeSupported(q))throw new Error(`Streaming playback is not supported for ${q}.`);const re=R.body;if(!re)throw new Error("Speech stream did not include a response body.");const ee=new MediaSource,W=URL.createObjectURL(ee),U=new Audio(W);i=W,a=U,sb(k,U),nb(k,()=>{l(),r("idle")}),await new Promise((J,le)=>{const z=()=>{ee.removeEventListener("sourceopen",z),zO({mediaSource:ee,stream:re,mimeType:q,audioElement:U,onPlayable:async()=>{if($===o){s()!=="playing"&&r("playing");try{await U.play()}catch(M){le(M)}}},onComplete:J,onError:le})};ee.addEventListener("sourceopen",z,{once:!0}),U.addEventListener("error",()=>le(new Error("Unable to play streamed speech.")),{once:!0})})}return{state:s,canUseSpeech:h,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 sb(e,t){const n=()=>{(gn==null?void 0:gn.ownerId)===e&&(gn=null),jO(e)};t.addEventListener("ended",n,{once:!0}),t.addEventListener("error",n,{once:!0})}async function zO(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 WO(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 HO(t);e.mediaSource.readyState==="open"&&e.mediaSource.endOfStream(),e.onComplete()}catch(t){e.onError(t)}}function WO(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 HO(e){return new Promise(t=>{e.addEventListener("updateend",()=>t(),{once:!0})})}function GO(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 ZO(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 JO(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 rb(e){e==null||e.getTracks().forEach(t=>t.stop())}function YO(){const{t:e}=kt(),[t,n]=L("idle"),[s,r]=L(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=Jr();return!!(d()&&(v!=null&&v.available)&&(v!=null&&v.sttConfigured)&&(v!=null&&v.supportsStt))},f=()=>{rb(a),a=null},h=()=>{o&&o.state!=="inactive"&&o.stop(),o=null,f(),i=[]};nt(()=>{l=!0,c+=1,h()});const m=async()=>{var k,$;if(!d()){Cs(e("promptInput.voiceInput.error.unsupported"),{title:e("promptInput.voiceInput.error.title"),variant:"error"});return}const v=++c;n("requesting"),r(null);try{if(En()){const D=await(($=(k=window.electronAPI)==null?void 0:k.requestMicrophoneAccess)==null?void 0:$.call(k));if(D&&!D.granted)throw new Error(e("promptInput.voiceInput.error.permissionDenied"))}const C=await navigator.mediaDevices.getUserMedia({audio:!0});if(v!==c||l){rb(C);return}i=[],a=C;const T=JO(C);o=T,T.addEventListener("dataavailable",D=>{D.data.size>0&&v===c&&i.push(D.data)}),T.addEventListener("error",()=>{v===c&&(h(),n("idle"))}),T.addEventListener("stop",()=>{v===c&&S(v)}),n("recording"),T.start()}catch(C){if(v!==c)return;h(),n("idle"),Cs(e("promptInput.voiceInput.error.permission"),{title:e("promptInput.voiceInput.error.title"),detail:C instanceof Error?C.message:String(C),variant:"error"})}},w=()=>{!o||t()!=="recording"||(o.stop(),f(),n("transcribing"))},S=async v=>{var T;const k=i;i=[];const $=o;if(o=null,v!==c||k.length===0){v===c&&n("idle");return}const C=($==null?void 0:$.mimeType)||((T=k[0])==null?void 0:T.type)||"audio/webm";try{const D=new Blob(k,{type:C}),R=await ft.transcribeAudio({audioBase64:await ZO(D),mimeType:C});v===c&&r(R.text.trim()||e("settings.speech.testInput.empty"))}catch(D){v===c&&Cs(e("promptInput.voiceInput.error.transcribe"),{title:e("promptInput.voiceInput.error.title"),detail:D instanceof Error?D.message:String(D),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 QO=F('<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>'),ag=F('<button type=button class="selector-button selector-button-secondary w-auto whitespace-nowrap">'),XO=F("<div class=settings-inline-note> "),ob=F("<div class=settings-card-section-header><h4 class=settings-card-section-title>"),cg=F("<div class=settings-inline-note>"),eR=F('<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>'),tR=F("<span class=settings-inline-note>"),nR=F('<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">'),sR=F('<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">'),rR=F("<option>");const oR=Lt("actions");function ib(e,t){const n=e[t];return{apiKey:"",baseUrl:n.baseUrl??"",model:n.model}}function lg(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:ib(e,"stt"),tts:ib(e,"tts")}}function ab(e,t){return e.apiKey===t.apiKey&&e.baseUrl===t.baseUrl&&e.model===t.model}function iR(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&&ab(e.stt,t.stt)&&ab(e.tts,t.tts)}const aR=()=>{const{t:e}=kt(),{serverSettings:t,updateSpeechSettings:n}=Tn(),s=lg(t().speech),[r,o]=L(!1),[a,i]=L("saved"),[c,l]=L(s),[d,u]=L(!1),[f,h]=L(!1),[m,w]=L(!1),[S,b]=L(!1),[v,k]=L(!1),[$,C]=L(!1),T=qO({id:()=>"settings-speech-test",text:()=>e("settings.speech.testPlayback.sample"),settingsOverride:()=>({playbackMode:c().playbackMode,ttsFormat:c().ttsFormat})}),D=YO();qe(()=>{const M=t().speech,N=lg(M);if(!r()&&!J()){const ce=Gf()?N:{...N,separateProviders:!1};iR(c(),ce)||l(ce),d()&&u(!1),f()&&h(!1),m()&&w(!1),S()&&b(!1),v()&&k(!1),$()&&C(!1)}}),qe(()=>{kc()});const R=()=>{if(XE())return e("settings.speech.status.loading");if(eT())return e("settings.speech.status.error");const M=Jr();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")},q=(M,N)=>{i("idle"),M==="apiKey"&&(u(!0),h(!1)),l(ce=>({...ce,[M]:N}))},re=(M,N,ce)=>{i("idle"),N==="apiKey"&&(M==="stt"?(w(!0),b(!1)):(k(!0),C(!1))),l(fe=>({...fe,[M]:{...fe[M],[N]:ce}}))},ee=$e(()=>f()||c().apiKey.trim().length>0),W=$e(()=>Tc({playbackMode:c().playbackMode,ttsFormat:c().ttsFormat,capabilities:Jr()})),U=$e(()=>{const M=Jr();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"&&!W().available?e("settings.speech.compatibility.browserStreamingUnavailable"):e("settings.speech.compatibility.runtimeNote")}),J=$e(()=>{const M=t().speech,N=c();if(N.separateProviders!==M.separateProviders)return!0;if(N.separateProviders){const ce=M.stt,fe=M.tts,Re=S()||N.stt.apiKey.trim().length>0||(N.stt.baseUrl||"")!==(ce.baseUrl||"")||N.stt.model!==ce.model,be=$()||N.tts.apiKey.trim().length>0||(N.tts.baseUrl||"")!==(fe.baseUrl||"")||N.tts.model!==fe.model||N.ttsVoice!==M.ttsVoice||N.playbackMode!==M.playbackMode||N.ttsFormat!==M.ttsFormat;return Re||be}return ee()||(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 z(){if(!J()||r())return;const M=c(),N=t().speech;o(!0),i("idle");try{if(M.separateProviders)await n({separateProviders:!0,stt:tb(S(),M.stt.apiKey,M.stt.baseUrl,M.stt.model,N.stt.baseUrl,N.sttModel),tts:tb($(),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 ce=M.apiKey.trim(),fe=(M.baseUrl.trim()||"")!==(N.baseUrl||"");await n({separateProviders:!1,...f()?{apiKey:null}:ce?{apiKey:ce}:fe?{apiKey:null}:{},...fe?{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 kc(!0),l(lg(t().speech)),u(!1),h(!1),w(!1),b(!1),k(!1),C(!1),i("saved")}catch(ce){oR.error("Failed to save speech settings",ce),i("error")}finally{o(!1)}}return(()=>{var M=eR(),N=M.firstChild,ce=N.firstChild,fe=ce.firstChild,Re=fe.firstChild,be=Re.nextSibling,ye=ce.nextSibling,Ce=N.nextSibling,je=Ce.firstChild,O=je.firstChild,g=O.firstChild,x=g.nextSibling,A=O.nextSibling,E=A.firstChild,H=E.nextSibling,B=H.nextSibling,oe=B.nextSibling,Ae=oe.firstChild,we=oe.nextSibling,he=we.firstChild,Ee=we.nextSibling,Ge=je.nextSibling,Xe=Ge.nextSibling;return p(ce,y(ih,{class:"settings-card-heading-icon"}),fe),p(Re,()=>e("settings.speech.title")),p(be,()=>e("settings.speech.subtitle")),p(ye,()=>e("settings.scope.server")),p(g,()=>e("settings.speech.provider.title")),p(x,()=>e("settings.speech.provider.subtitle")),p(E,()=>e("settings.speech.provider.openaiCompatible")),p(H,R),p(B,le),oe.$$click=()=>void D.toggle(),p(oe,y(Q,{get when(){return D.isTranscribing()||D.state()==="requesting"},get fallback(){return y(Q,{get when(){return D.isRecording()},get fallback(){return y(eg,{class:"w-3.5 h-3.5","aria-hidden":"true"})},get children(){return y(vw,{class:"w-3.5 h-3.5","aria-hidden":"true"})}})},get children(){return y(Nn,{class:"w-3.5 h-3.5 animate-spin","aria-hidden":"true"})}}),Ae),p(Ae,()=>D.buttonTitle()),p(A,y(Q,{get when(){return D.result()},children:se=>(()=>{var V=tR();return p(V,(()=>{var Y=_e(()=>se().length>40);return()=>Y()?`${se().slice(0,40)}…`:se()})()),de(()=>pe(V,"title",se())),V})()}),we),we.$$click=()=>void T.toggle(),p(we,y(Q,{get when(){return T.isLoading()},get fallback(){return y(Q,{get when(){return T.isPlaying()},get fallback(){return y(ih,{class:"w-3.5 h-3.5","aria-hidden":"true"})},get children(){return y(vw,{class:"w-3.5 h-3.5","aria-hidden":"true"})}})},get children(){return y(Nn,{class:"w-3.5 h-3.5 animate-spin","aria-hidden":"true"})}}),he),p(he,(()=>{var se=_e(()=>!!T.isPlaying());return()=>se()?e("settings.speech.testPlayback.stop"):_e(()=>!!T.isLoading())()?e("settings.speech.testPlayback.generating"):e("settings.speech.testPlayback.action")})()),Ee.$$click=()=>void z(),p(Ee,(()=>{var se=_e(()=>!!r());return()=>se()?e("settings.speech.save.saving"):e("settings.speech.save.action")})()),p(Ce,y(Q,{get when(){return Gf()},get children(){var se=QO(),V=se.firstChild,Y=V.firstChild,Oe=Y.nextSibling,ve=V.nextSibling,Ie=ve.firstChild,Le=Ie.nextSibling;return p(Y,()=>e("settings.speech.separateProviders.title")),p(Oe,()=>e("settings.speech.separateProviders.subtitle")),Ie.addEventListener("change",ze=>{i("idle"),l(Ne=>({...Ne,separateProviders:ze.currentTarget.checked}))}),p(Le,()=>e("settings.common.enabled")),de(()=>Ie.disabled=r()),de(()=>Ie.checked=c().separateProviders),se}}),Ge),p(Ce,y(Q,{get when(){return!c().separateProviders},get children(){return[y(cs,{get label(){return e("settings.speech.apiKey.title")},get caption(){return e("settings.speech.apiKey.subtitle")},get value(){return c().apiKey},onInput:se=>q("apiKey",se),type:"password",get placeholder(){return _e(()=>!!t().speech.hasApiKey)()?e("settings.speech.apiKey.placeholder"):void 0}}),y(Q,{get when(){return _e(()=>!!(t().speech.hasApiKey&&!d()))()&&c().apiKey.length===0},get children(){var se=XO(),V=se.firstChild;return p(se,(()=>{var Y=_e(()=>!!f());return()=>Y()?e("settings.speech.apiKey.clearPending"):e("settings.speech.apiKey.storedNote")})(),V),p(se,y(Q,{get when(){return!f()},get children(){var Y=ag();return Y.$$click=()=>{h(!0),i("idle")},p(Y,()=>e("settings.speech.apiKey.clearAction")),Y}}),null),se}}),y(cs,{get label(){return e("settings.speech.baseUrl.title")},get caption(){return e("settings.speech.baseUrl.subtitle")},get value(){return c().baseUrl},onInput:se=>q("baseUrl",se),get placeholder(){return e("settings.speech.baseUrl.placeholder")}}),y(cs,{get label(){return e("settings.speech.sttModel.title")},get caption(){return e("settings.speech.sttModel.subtitle")},get value(){return c().sttModel},onInput:se=>q("sttModel",se)}),y(cs,{get label(){return e("settings.speech.ttsModel.title")},get caption(){return e("settings.speech.ttsModel.subtitle")},get value(){return c().ttsModel},onInput:se=>q("ttsModel",se)}),y(cs,{get label(){return e("settings.speech.ttsVoice.title")},get caption(){return e("settings.speech.ttsVoice.subtitle")},get value(){return c().ttsVoice},onInput:se=>q("ttsVoice",se),get icon(){return y(eg,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"})}})]}}),Ge),p(Ce,y(Q,{get when(){return _e(()=>!!c().separateProviders)()&&Gf()},get children(){return[(()=>{var se=ob(),V=se.firstChild;return p(V,()=>e("settings.speech.stt.section.title")),se})(),y(cs,{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:se=>re("stt","apiKey",se),type:"password",get placeholder(){return _e(()=>!!(t().speech.stt.hasApiKey||t().speech.hasApiKey))()?e("settings.speech.stt.apiKey.placeholder"):void 0}}),y(Q,{get when(){return _e(()=>!!((t().speech.stt.hasApiKey||t().speech.hasApiKey)&&!m()))()&&c().stt.apiKey.length===0},get children(){var se=cg();return p(se,y(Q,{get when(){return t().speech.stt.hasApiKey},get fallback(){return e("settings.speech.stt.apiKey.usingShared")},get children(){return[_e(()=>_e(()=>!!S())()?e("settings.speech.stt.apiKey.clearPending"):e("settings.speech.stt.apiKey.storedNote"))," ",y(Q,{get when(){return!S()},get children(){var V=ag();return V.$$click=()=>{b(!0),i("idle")},p(V,()=>e("settings.speech.stt.apiKey.clearAction")),V}})]}})),se}}),y(cs,{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:se=>re("stt","baseUrl",se),get placeholder(){return e("settings.speech.stt.baseUrl.placeholder")}}),y(cs,{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:se=>re("stt","model",se)}),(()=>{var se=ob(),V=se.firstChild;return p(V,()=>e("settings.speech.tts.section.title")),se})(),y(cs,{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:se=>re("tts","apiKey",se),type:"password",get placeholder(){return _e(()=>!!(t().speech.tts.hasApiKey||t().speech.hasApiKey))()?e("settings.speech.tts.apiKey.placeholder"):void 0}}),y(Q,{get when(){return _e(()=>!!((t().speech.tts.hasApiKey||t().speech.hasApiKey)&&!v()))()&&c().tts.apiKey.length===0},get children(){var se=cg();return p(se,y(Q,{get when(){return t().speech.tts.hasApiKey},get fallback(){return e("settings.speech.tts.apiKey.usingShared")},get children(){return[_e(()=>_e(()=>!!$())()?e("settings.speech.tts.apiKey.clearPending"):e("settings.speech.tts.apiKey.storedNote"))," ",y(Q,{get when(){return!$()},get children(){var V=ag();return V.$$click=()=>{C(!0),i("idle")},p(V,()=>e("settings.speech.tts.apiKey.clearAction")),V}})]}})),se}}),y(cs,{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:se=>re("tts","baseUrl",se),get placeholder(){return e("settings.speech.tts.baseUrl.placeholder")}}),y(cs,{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:se=>re("tts","model",se)}),y(cs,{get label(){return e("settings.speech.ttsVoice.title")},get caption(){return e("settings.speech.ttsVoice.subtitle")},get value(){return c().ttsVoice},onInput:se=>q("ttsVoice",se),get icon(){return y(eg,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"})}})]}}),Ge),p(Ce,y(cb,{get label(){return e("settings.speech.playbackMode.title")},get caption(){return e("settings.speech.playbackMode.subtitle")},get value(){return c().playbackMode},onInput:se=>q("playbackMode",se),get options(){return[{value:"streaming",label:e("settings.speech.playbackMode.streaming")},{value:"buffered",label:e("settings.speech.playbackMode.buffered")}]}}),Ge),p(Ce,y(cb,{get label(){return e("settings.speech.ttsFormat.title")},get caption(){return e("settings.speech.ttsFormat.subtitle")},get value(){return c().ttsFormat},onInput:se=>q("ttsFormat",se),options:[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"opus",label:"Opus"},{value:"aac",label:"AAC"}]}),Ge),p(Ge,()=>e("settings.speech.help")),p(Ce,y(Q,{get when(){return U()},children:se=>(()=>{var V=cg();return p(V,se),V})()}),Xe),p(Xe,()=>e("settings.speech.testPlayback.note")),de(se=>{var V=r()&&D.state()!=="recording"||D.state()==="requesting"||D.state()==="transcribing"||D.state()==="idle"&&!D.canUseTranscription(),Y=D.buttonTitle(),Oe=D.buttonTitle(),ve=r(),Ie=T.buttonTitle(),Le=T.buttonTitle(),ze=!J()||r();return V!==se.e&&(oe.disabled=se.e=V),Y!==se.t&&pe(oe,"title",se.t=Y),Oe!==se.a&&pe(oe,"aria-label",se.a=Oe),ve!==se.o&&(we.disabled=se.o=ve),Ie!==se.i&&pe(we,"title",se.i=Ie),Le!==se.n&&pe(we,"aria-label",se.n=Le),ze!==se.s&&(Ee.disabled=se.s=ze),se},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),M})()},cs=e=>(()=>{var t=nR(),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&&pe(a,"type",i.e=c),l!==i.t&&pe(a,"placeholder",i.t=l),i},{e:void 0,t:void 0}),de(()=>a.value=e.value),t})(),cb=e=>(()=>{var t=sR(),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(Ut,{get each(){return e.options},children:i=>(()=>{var c=rR();return p(c,()=>i.label),de(()=>c.value=i.value),c})()})),de(()=>a.value=e.value),t})();Ht(["click","input"]);var cR=F("<div class=settings-section-stack><div class=settings-card><div class=settings-stack>");const lR=()=>{const e=Tn(),t=$e(()=>yp(e).filter(n=>n.id==="behavior.promptVoiceInput"));return(()=>{var n=cR(),s=n.firstChild,r=s.firstChild;return p(r,y(vp,{settings:t,get preferences(){return e.preferences}})),p(n,y(aR,{}),null),n})()};function Qk(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 dR(e){return(e==null?void 0:e.id)??""}function Zi(e){return e==null?void 0:e.sessionID}function uR(e){var t;return(t=e==null?void 0:e.source)==null?void 0:t.messageID}function fR(e){var t;return(t=e==null?void 0:e.source)==null?void 0:t.id}function Xk(e){return(e==null?void 0:e.action)??"permission"}function gR(e){return(e==null?void 0:e.resources.filter(t=>typeof t=="string"))??[]}function UW(e){const t=Xk(e),n=gR(e);return n.length>0?`${t}: ${n.join(", ")}`:t}function hR(e){return e==null?void 0:e.requestID}var mR=Object.defineProperty,pR=e=>e;function yR(e,t){this[e]=pR.bind(null,t)}var xp=(e,t)=>{for(var n in t)mR(e,n,{get:t[n],enumerable:!0,configurable:!0,set:yR.bind(t,n)})},lb={};xp(lb,{SharedEvents:()=>lb,make:()=>ex});function ex(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(h)&&!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 h={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(h),d.connected&&h.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 $s extends Error{constructor(n,s){super(n,s);ae(this,"reason");ae(this,"name","ClientError");this.reason=n}}var vR={};xp(vR,{make:()=>tx});var wR=16*1024*1024;function tx(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,h]of Object.entries(i.query??{}))xh(d.searchParams,f,h);const u=new Headers(e.headers);for(const[f,h]of Object.entries(i.headers??{}))h!=null&&u.set(f,String(h));for(const[f,h]of new Headers(c==null?void 0:c.headers))u.set(f,h);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 $s("Transport",{cause:l})}},r=async(i,c)=>{var l;if(c.declaredStatuses.includes(i.status))throw SR(await db(i));try{await((l=i.body)==null?void 0:l.cancel())}catch{}throw new $s("UnexpectedStatus",{cause:{status: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 db(l)},a=(i,c)=>({async*[Symbol.asyncIterator](){var h,m;const l=await s(i,c);if(l.status!==i.successStatus&&await r(l,i),!nx(l,"text/event-stream")){try{await((h=l.body)==null?void 0:h.cancel())}catch{}throw new $s("UnsupportedContentType")}if(l.body===null)throw new $s("MalformedResponse");const d=l.body.getReader(),u=new TextDecoder;let f="";try{for(;;){let w;try{w=await d.read()}catch(v){throw new $s("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>wR)throw new $s("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 KE=Object.defineProperty;var VE=(e,t,n)=>t in e?KE(e,t,{enumerable:!0,config
11
11
  `).flatMap($=>$.startsWith("data:")?[$.slice(5).trimStart()]:[]).join(`
12
12
  `);if(k!=="")try{yield JSON.parse(k)}catch($){throw new $s("MalformedResponse",{cause:$})}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/${bR(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 bR(e){return e.split("/").map(encodeURIComponent).join("/")}function xh(e,t,n){if(n!==void 0){if(n===null){e.append(t,"null");return}if(Array.isArray(n)){for(const s of n)xh(e,t,s);return}if(typeof n=="object"){for(const[s,r]of Object.entries(n))xh(e,`${t}[${s}]`,r);return}e.append(t,String(n))}}async function db(e){var n,s;if(!nx(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 $s("UnsupportedContentType")}let t;try{t=await e.text()}catch(r){throw new $s("Transport",{cause:r})}if(t==="")throw new $s("MalformedResponse");try{return JSON.parse(t)}catch(r){throw new $s("MalformedResponse",{cause:r})}}function SR(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 nx(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 kR=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="SessionNotFoundError",xR=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="SessionBusyError",$R=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="FormNotFoundError",_R=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="FormAlreadySettledError",CR=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="PermissionNotFoundError",ER=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="RpcError",TR=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="RpcInternalError";function MR(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=AR(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!ER(i)&&!TR(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 AR(e,t){return`rpc.${e.id}.${t}`}var $h={};xp($h,{OpenCode:()=>$h,make:()=>DR});function DR(e){const t=tx(e),n=ex((s,r)=>t.event.subscribe({signal:s,onActivity:r}));return{...t,rpc:Object.assign(MR(t,n),t.rpc),event:n}}class PR{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 $p=new PR(2);async function Ku(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=xc(c=>(uS(()=>{e()&&!a&&s.abort(r)}),c));try{return await $p.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 OR{constructor(){this.clients=new Map}key(t,n){return`${t}:${rx(n)}`}createClient(t,n,s=()=>!1){const r=this.key(t,n),o=this.clients.get(r);if(o)return o;const a=sx(n),i=$h.make({baseUrl:a,fetch:RR(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 sx(e,t=tT){const n=rx(e);return`${IR(t??"")}${n}/`}function RR(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 nT(n,{...s,credentials:(s==null?void 0:s.credentials)??"include"});if(l.status===426){const{reportOpenCodeSetupRequired:d}=await ts(async()=>{const{reportOpenCodeSetupRequired:u}=await Promise.resolve().then(()=>c2);return{reportOpenCodeSetupRequired:u}},void 0);d()}if(l.status===502){const d=await l.clone().json().catch(()=>{});if((d==null?void 0:d.error)===nD){const{tGlobal:u}=await ts(async()=>{const{tGlobal:f}=await import("./index-DFCjhysu.js").then(h=>h.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)?Ku(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)?$p.run((s==null?void 0:s.signal)??(n instanceof Request?n.signal:new AbortController().signal),i):i()}}function rx(e){return(e.startsWith("/")?e:`/${e}`).replace(/\/+/g,"/").replace(/\/+$/,"")}function IR(e){return e.replace(/\/+$/,"")}const Ji=new OR;function _p(e,t,n,s=Date.now()){return t!=="idle"?null:e&&e!=="idle"?s:n??null}function LR(e){return!e||e.type==="idle"?"idle":"working"}function FR(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 NR(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 ox(e){return!e.hidden&&e.mode!=="subagent"}function UR(e,t){return e.find(n=>n.id===t)}function BR(e,t){const n=UR(e,t);if(n)return n.id;const s=e.filter(r=>r.name===t);return s.length===1?s[0].id:t}function BW(e,t,n){if(!n)return e.filter(ox);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 KR(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 h=await e.session.fork({sessionID:t,...o?{before:o}:{}});if(r(),!o&&(((c=h.fork)==null?void 0:c.boundary.type)!=="through"||h.fork.boundary.messageID!==n))throw await e.session.remove({sessionID:h.id}),new Error("Session changed while forking; please try again");return h}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 bt;(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})(bt||(bt={}));var ub;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(ub||(ub={}));const We=bt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zr=e=>{switch(typeof e){case"undefined":return We.undefined;case"string":return We.string;case"number":return Number.isNaN(e)?We.nan:We.number;case"boolean":return We.boolean;case"function":return We.function;case"bigint":return We.bigint;case"symbol":return We.symbol;case"object":return Array.isArray(e)?We.array:e===null?We.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?We.promise:typeof Map<"u"&&e instanceof Map?We.map:typeof Set<"u"&&e instanceof Set?We.set:typeof Date<"u"&&e instanceof Date?We.date:We.object;default:return We.unknown}},Me=bt.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 _r 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 _r))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,bt.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()}}_r.create=e=>new _r(e);const _h=(e,t)=>{let n;switch(e.code){case Me.invalid_type:e.received===We.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Me.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,bt.jsonStringifyReplacer)}`;break;case Me.unrecognized_keys:n=`Unrecognized key(s) in object: ${bt.joinValues(e.keys,", ")}`;break;case Me.invalid_union:n="Invalid input";break;case Me.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${bt.joinValues(e.options)}`;break;case Me.invalid_enum_value:n=`Invalid enum value. Expected ${bt.joinValues(e.options)}, received '${e.received}'`;break;case Me.invalid_arguments:n="Invalid function arguments";break;case Me.invalid_return_type:n="Invalid function return type";break;case Me.invalid_date:n="Invalid date";break;case Me.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}"`:bt.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Me.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 Me.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 Me.custom:n="Invalid input";break;case Me.invalid_intersection_types:n="Intersection results could not be merged";break;case Me.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Me.not_finite:n="Number must be finite";break;default:n=t.defaultError,bt.assertNever(e)}return{message:n}};let VR=_h;function jR(){return VR}const qR=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 Ke(e,t){const n=jR(),s=qR({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===_h?void 0:_h].filter(r=>!!r)});e.common.issues.push(s)}class ns{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 tt;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 ns.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 tt;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 tt=Object.freeze({status:"aborted"}),tc=e=>({status:"dirty",value:e}),Ss=e=>({status:"valid",value:e}),fb=e=>e.status==="aborted",gb=e=>e.status==="dirty",Yi=e=>e.status==="valid",Pd=e=>typeof Promise<"u"&&e instanceof Promise;var Ze;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ze||(Ze={}));class io{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 hb=(e,t)=>{if(Yi(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 _r(e.common.issues);return this._error=n,this._error}}};function ut(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 wt{get description(){return this._def.description}_getType(t){return zr(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:zr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ns,ctx:{common:t.parent.common,data:t.data,parsedType:zr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Pd(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:zr(t)},r=this._parseSync({data:t,path:s.path,parent:s});return hb(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:zr(t)};if(!this["~standard"].async)try{const o=this._parseSync({data:t,path:[],parent:n});return Yi(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=>Yi(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:zr(t)},r=this._parse({data:t,path:s.path,parent:s}),o=await(Pd(r)?r:Promise.resolve(r));return hb(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:Me.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 zo({schema:this,typeName:rt.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 vr.create(this,this._def)}nullable(){return Wo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Js.create(this)}promise(){return Fd.create(this,this._def)}or(t){return Rd.create([this,t],this._def)}and(t){return Id.create(this,t,this._def)}transform(t){return new zo({...ut(this._def),schema:this,typeName:rt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Nd({...ut(this._def),innerType:this,defaultValue:n,typeName:rt.ZodDefault})}brand(){return new lx({typeName:rt.ZodBranded,type:this,...ut(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Ud({...ut(this._def),innerType:this,catchValue:n,typeName:rt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ep.create(this,t)}readonly(){return Bd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const zR=/^c[^\s-]{8,}$/i,WR=/^[0-9a-z]+$/,HR=/^[0-9A-HJKMNP-TV-Z]{26}$/i,GR=/^[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,ZR=/^[a-z0-9_-]{21}$/i,JR=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,YR=/^[-+]?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)?)??$/,QR=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,XR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let dg;const eI=/^(?:(?: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])$/,tI=/^(?:(?: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])$/,nI=/^(([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]))$/,sI=/^(([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])$/,rI=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,oI=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ix="((\\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])))",iI=new RegExp(`^${ix}$`);function ax(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 aI(e){return new RegExp(`^${ax(e)}$`)}function cI(e){let t=`${ix}T${ax(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 lI(e,t){return!!((t==="v4"||!t)&&eI.test(e)||(t==="v6"||!t)&&nI.test(e))}function dI(e,t){if(!JR.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 uI(e,t){return!!((t==="v4"||!t)&&tI.test(e)||(t==="v6"||!t)&&sI.test(e))}class Hr extends wt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==We.string){const o=this._getOrReturnCtx(t);return Ke(o,{code:Me.invalid_type,expected:We.string,received:o.parsedType}),tt}const s=new ns;let r;for(const o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.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),Ke(r,{code:Me.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?Ke(r,{code:Me.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):i&&Ke(r,{code:Me.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if(o.kind==="email")QR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"email",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="emoji")dg||(dg=new RegExp(XR,"u")),dg.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"emoji",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="uuid")GR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"uuid",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="nanoid")ZR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"nanoid",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid")zR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"cuid",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid2")WR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"cuid2",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="ulid")HR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"ulid",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),Ke(r,{validation:"url",code:Me.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),Ke(r,{validation:"regex",code:Me.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),Ke(r,{code:Me.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),Ke(r,{code:Me.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):o.kind==="datetime"?cI(o).test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.invalid_string,validation:"datetime",message:o.message}),s.dirty()):o.kind==="date"?iI.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.invalid_string,validation:"date",message:o.message}),s.dirty()):o.kind==="time"?aI(o).test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.invalid_string,validation:"time",message:o.message}),s.dirty()):o.kind==="duration"?YR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"duration",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="ip"?lI(t.data,o.version)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"ip",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="jwt"?dI(t.data,o.alg)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"jwt",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="cidr"?uI(t.data,o.version)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"cidr",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="base64"?rI.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"base64",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="base64url"?oI.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"base64url",code:Me.invalid_string,message:o.message}),s.dirty()):bt.assertNever(o);return{status:s.value,value:t.data}}_regex(t,n,s){return this.refinement(r=>t.test(r),{validation:n,code:Me.invalid_string,...Ze.errToObj(s)})}_addCheck(t){return new Hr({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ze.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ze.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ze.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ze.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ze.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ze.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ze.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ze.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ze.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ze.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ze.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ze.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ze.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,...Ze.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,...Ze.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Ze.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Ze.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Ze.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Ze.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Ze.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Ze.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Ze.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Ze.errToObj(n)})}nonempty(t){return this.min(1,Ze.errToObj(t))}trim(){return new Hr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Hr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Hr({...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}}Hr.create=e=>new Hr({checks:[],typeName:rt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...ut(e)});function fI(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 Qi extends wt{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)!==We.number){const o=this._getOrReturnCtx(t);return Ke(o,{code:Me.invalid_type,expected:We.number,received:o.parsedType}),tt}let s;const r=new ns;for(const o of this._def.checks)o.kind==="int"?bt.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),Ke(s,{code:Me.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),Ke(s,{code:Me.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),Ke(s,{code:Me.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="multipleOf"?fI(t.data,o.value)!==0&&(s=this._getOrReturnCtx(t,s),Ke(s,{code:Me.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),Ke(s,{code:Me.not_finite,message:o.message}),r.dirty()):bt.assertNever(o);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Ze.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ze.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ze.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ze.toString(n))}setLimit(t,n,s,r){return new Qi({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:Ze.toString(r)}]})}_addCheck(t){return new Qi({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ze.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ze.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ze.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ze.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ze.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ze.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Ze.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ze.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ze.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"&&bt.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)}}Qi.create=e=>new Qi({checks:[],typeName:rt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...ut(e)});class Mc extends wt{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)!==We.bigint)return this._getInvalidInput(t);let s;const r=new ns;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),Ke(s,{code:Me.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),Ke(s,{code:Me.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),Ke(s,{code:Me.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):bt.assertNever(o);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Ke(n,{code:Me.invalid_type,expected:We.bigint,received:n.parsedType}),tt}gte(t,n){return this.setLimit("min",t,!0,Ze.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ze.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ze.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ze.toString(n))}setLimit(t,n,s,r){return new Mc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:Ze.toString(r)}]})}_addCheck(t){return new Mc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ze.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ze.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ze.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ze.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ze.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}}Mc.create=e=>new Mc({checks:[],typeName:rt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...ut(e)});class Ch extends wt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==We.boolean){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.boolean,received:s.parsedType}),tt}return Ss(t.data)}}Ch.create=e=>new Ch({typeName:rt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...ut(e)});class Od extends wt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==We.date){const o=this._getOrReturnCtx(t);return Ke(o,{code:Me.invalid_type,expected:We.date,received:o.parsedType}),tt}if(Number.isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return Ke(o,{code:Me.invalid_date}),tt}const s=new ns;let r;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.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),Ke(r,{code:Me.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),s.dirty()):bt.assertNever(o);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Od({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Ze.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Ze.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}}Od.create=e=>new Od({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:rt.ZodDate,...ut(e)});class mb extends wt{_parse(t){if(this._getType(t)!==We.symbol){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.symbol,received:s.parsedType}),tt}return Ss(t.data)}}mb.create=e=>new mb({typeName:rt.ZodSymbol,...ut(e)});class Eh extends wt{_parse(t){if(this._getType(t)!==We.undefined){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.undefined,received:s.parsedType}),tt}return Ss(t.data)}}Eh.create=e=>new Eh({typeName:rt.ZodUndefined,...ut(e)});class Th extends wt{_parse(t){if(this._getType(t)!==We.null){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.null,received:s.parsedType}),tt}return Ss(t.data)}}Th.create=e=>new Th({typeName:rt.ZodNull,...ut(e)});class pb extends wt{constructor(){super(...arguments),this._any=!0}_parse(t){return Ss(t.data)}}pb.create=e=>new pb({typeName:rt.ZodAny,...ut(e)});class yb extends wt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ss(t.data)}}yb.create=e=>new yb({typeName:rt.ZodUnknown,...ut(e)});class ao extends wt{_parse(t){const n=this._getOrReturnCtx(t);return Ke(n,{code:Me.invalid_type,expected:We.never,received:n.parsedType}),tt}}ao.create=e=>new ao({typeName:rt.ZodNever,...ut(e)});class vb extends wt{_parse(t){if(this._getType(t)!==We.undefined){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.void,received:s.parsedType}),tt}return Ss(t.data)}}vb.create=e=>new vb({typeName:rt.ZodVoid,...ut(e)});class Js extends wt{_parse(t){const{ctx:n,status:s}=this._processInputParams(t),r=this._def;if(n.parsedType!==We.array)return Ke(n,{code:Me.invalid_type,expected:We.array,received:n.parsedType}),tt;if(r.exactLength!==null){const a=n.data.length>r.exactLength.value,i=n.data.length<r.exactLength.value;(a||i)&&(Ke(n,{code:a?Me.too_big:Me.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&&(Ke(n,{code:Me.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&&(Ke(n,{code:Me.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 io(n,a,n.path,i)))).then(a=>ns.mergeArray(s,a));const o=[...n.data].map((a,i)=>r.type._parseSync(new io(n,a,n.path,i)));return ns.mergeArray(s,o)}get element(){return this._def.type}min(t,n){return new Js({...this._def,minLength:{value:t,message:Ze.toString(n)}})}max(t,n){return new Js({...this._def,maxLength:{value:t,message:Ze.toString(n)}})}length(t,n){return new Js({...this._def,exactLength:{value:t,message:Ze.toString(n)}})}nonempty(t){return this.min(1,t)}}Js.create=(e,t)=>new Js({type:e,minLength:null,maxLength:null,exactLength:null,typeName:rt.ZodArray,...ut(t)});function ki(e){if(e instanceof Xt){const t={};for(const n in e.shape){const s=e.shape[n];t[n]=vr.create(ki(s))}return new Xt({...e._def,shape:()=>t})}else return e instanceof Js?new Js({...e._def,type:ki(e.element)}):e instanceof vr?vr.create(ki(e.unwrap())):e instanceof Wo?Wo.create(ki(e.unwrap())):e instanceof jo?jo.create(e.items.map(t=>ki(t))):e}class Xt extends wt{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=bt.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==We.object){const l=this._getOrReturnCtx(t);return Ke(l,{code:Me.invalid_type,expected:We.object,received:l.parsedType}),tt}const{status:s,ctx:r}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof ao&&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 io(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof ao){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&&(Ke(r,{code:Me.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 io(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=>ns.mergeObjectSync(s,l)):ns.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(t){return Ze.errToObj,new Xt({...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:Ze.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Xt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Xt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:rt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Xt({...this._def,catchall:t})}pick(t){const n={};for(const s of bt.objectKeys(t))t[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new Xt({...this._def,shape:()=>n})}omit(t){const n={};for(const s of bt.objectKeys(this.shape))t[s]||(n[s]=this.shape[s]);return new Xt({...this._def,shape:()=>n})}deepPartial(){return ki(this)}partial(t){const n={};for(const s of bt.objectKeys(this.shape)){const r=this.shape[s];t&&!t[s]?n[s]=r:n[s]=r.optional()}return new Xt({...this._def,shape:()=>n})}required(t){const n={};for(const s of bt.objectKeys(this.shape))if(t&&!t[s])n[s]=this.shape[s];else{let o=this.shape[s];for(;o instanceof vr;)o=o._def.innerType;n[s]=o}return new Xt({...this._def,shape:()=>n})}keyof(){return cx(bt.objectKeys(this.shape))}}Xt.create=(e,t)=>new Xt({shape:()=>e,unknownKeys:"strip",catchall:ao.create(),typeName:rt.ZodObject,...ut(t)});Xt.strictCreate=(e,t)=>new Xt({shape:()=>e,unknownKeys:"strict",catchall:ao.create(),typeName:rt.ZodObject,...ut(t)});Xt.lazycreate=(e,t)=>new Xt({shape:e,unknownKeys:"strip",catchall:ao.create(),typeName:rt.ZodObject,...ut(t)});class Rd extends wt{_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 _r(i.ctx.common.issues));return Ke(n,{code:Me.invalid_union,unionErrors:a}),tt}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 _r(c));return Ke(n,{code:Me.invalid_union,unionErrors:i}),tt}}get options(){return this._def.options}}Rd.create=(e,t)=>new Rd({options:e,typeName:rt.ZodUnion,...ut(t)});const fr=e=>e instanceof Ah?fr(e.schema):e instanceof zo?fr(e.innerType()):e instanceof Ld?[e.value]:e instanceof qo?e.options:e instanceof Dh?bt.objectValues(e.enum):e instanceof Nd?fr(e._def.innerType):e instanceof Eh?[void 0]:e instanceof Th?[null]:e instanceof vr?[void 0,...fr(e.unwrap())]:e instanceof Wo?[null,...fr(e.unwrap())]:e instanceof lx||e instanceof Bd?fr(e.unwrap()):e instanceof Ud?fr(e._def.innerType):[];class Cp extends wt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==We.object)return Ke(n,{code:Me.invalid_type,expected:We.object,received:n.parsedType}),tt;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}):(Ke(n,{code:Me.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),tt)}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=fr(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 Cp({typeName:rt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:r,...ut(s)})}}function Mh(e,t){const n=zr(e),s=zr(t);if(e===t)return{valid:!0,data:e};if(n===We.object&&s===We.object){const r=bt.objectKeys(t),o=bt.objectKeys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of o){const c=Mh(e[i],t[i]);if(!c.valid)return{valid:!1};a[i]=c.data}return{valid:!0,data:a}}else if(n===We.array&&s===We.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=Mh(a,i);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===We.date&&s===We.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Id extends wt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t),r=(o,a)=>{if(fb(o)||fb(a))return tt;const i=Mh(o.value,a.value);return i.valid?((gb(o)||gb(a))&&n.dirty(),{status:n.value,value:i.data}):(Ke(s,{code:Me.invalid_intersection_types}),tt)};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}))}}Id.create=(e,t,n)=>new Id({left:e,right:t,typeName:rt.ZodIntersection,...ut(n)});class jo extends wt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==We.array)return Ke(s,{code:Me.invalid_type,expected:We.array,received:s.parsedType}),tt;if(s.data.length<this._def.items.length)return Ke(s,{code:Me.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),tt;!this._def.rest&&s.data.length>this._def.items.length&&(Ke(s,{code:Me.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 io(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(o).then(a=>ns.mergeArray(n,a)):ns.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new jo({...this._def,rest:t})}}jo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jo({items:e,typeName:rt.ZodTuple,rest:null,...ut(t)})};class wb extends wt{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!==We.map)return Ke(s,{code:Me.invalid_type,expected:We.map,received:s.parsedType}),tt;const r=this._def.keyType,o=this._def.valueType,a=[...s.data.entries()].map(([i,c],l)=>({key:r._parse(new io(s,i,s.path,[l,"key"])),value:o._parse(new io(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 tt;(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 tt;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),i.set(l.value,d.value)}return{status:n.value,value:i}}}}wb.create=(e,t,n)=>new wb({valueType:t,keyType:e,typeName:rt.ZodMap,...ut(n)});class Ac extends wt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==We.set)return Ke(s,{code:Me.invalid_type,expected:We.set,received:s.parsedType}),tt;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(Ke(s,{code:Me.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&&(Ke(s,{code:Me.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 tt;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 io(s,c,s.path,l)));return s.common.async?Promise.all(i).then(c=>a(c)):a(i)}min(t,n){return new Ac({...this._def,minSize:{value:t,message:Ze.toString(n)}})}max(t,n){return new Ac({...this._def,maxSize:{value:t,message:Ze.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Ac.create=(e,t)=>new Ac({valueType:e,minSize:null,maxSize:null,typeName:rt.ZodSet,...ut(t)});class Ah extends wt{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})}}Ah.create=(e,t)=>new Ah({getter:e,typeName:rt.ZodLazy,...ut(t)});class Ld extends wt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Ke(n,{received:n.data,code:Me.invalid_literal,expected:this._def.value}),tt}return{status:"valid",value:t.data}}get value(){return this._def.value}}Ld.create=(e,t)=>new Ld({value:e,typeName:rt.ZodLiteral,...ut(t)});function cx(e,t){return new qo({values:e,typeName:rt.ZodEnum,...ut(t)})}class qo extends wt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),s=this._def.values;return Ke(n,{expected:bt.joinValues(s),received:n.parsedType,code:Me.invalid_type}),tt}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 Ke(n,{received:n.data,code:Me.invalid_enum_value,options:s}),tt}return Ss(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 qo.create(t,{...this._def,...n})}exclude(t,n=this._def){return qo.create(this.options.filter(s=>!t.includes(s)),{...this._def,...n})}}qo.create=cx;class Dh extends wt{_parse(t){const n=bt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==We.string&&s.parsedType!==We.number){const r=bt.objectValues(n);return Ke(s,{expected:bt.joinValues(r),received:s.parsedType,code:Me.invalid_type}),tt}if(this._cache||(this._cache=new Set(bt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=bt.objectValues(n);return Ke(s,{received:s.data,code:Me.invalid_enum_value,options:r}),tt}return Ss(t.data)}get enum(){return this._def.values}}Dh.create=(e,t)=>new Dh({values:e,typeName:rt.ZodNativeEnum,...ut(t)});class Fd extends wt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==We.promise&&n.common.async===!1)return Ke(n,{code:Me.invalid_type,expected:We.promise,received:n.parsedType}),tt;const s=n.parsedType===We.promise?n.data:Promise.resolve(n.data);return Ss(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Fd.create=(e,t)=>new Fd({type:e,typeName:rt.ZodPromise,...ut(t)});class zo extends wt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===rt.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=>{Ke(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 tt;const c=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return c.status==="aborted"?tt:c.status==="dirty"||n.value==="dirty"?tc(c.value):c});{if(n.value==="aborted")return tt;const i=this._def.schema._parseSync({data:a,path:s.path,parent:s});return i.status==="aborted"?tt:i.status==="dirty"||n.value==="dirty"?tc(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"?tt:(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"?tt:(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(!Yi(a))return tt;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=>Yi(a)?Promise.resolve(r.transform(a.value,o)).then(i=>({status:n.value,value:i})):tt);bt.assertNever(r)}}zo.create=(e,t,n)=>new zo({schema:e,typeName:rt.ZodEffects,effect:t,...ut(n)});zo.createWithPreprocess=(e,t,n)=>new zo({schema:t,effect:{type:"preprocess",transform:e},typeName:rt.ZodEffects,...ut(n)});class vr extends wt{_parse(t){return this._getType(t)===We.undefined?Ss(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}vr.create=(e,t)=>new vr({innerType:e,typeName:rt.ZodOptional,...ut(t)});class Wo extends wt{_parse(t){return this._getType(t)===We.null?Ss(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Wo.create=(e,t)=>new Wo({innerType:e,typeName:rt.ZodNullable,...ut(t)});class Nd extends wt{_parse(t){const{ctx:n}=this._processInputParams(t);let s=n.data;return n.parsedType===We.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Nd.create=(e,t)=>new Nd({innerType:e,typeName:rt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ut(t)});class Ud extends wt{_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 Pd(r)?r.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new _r(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new _r(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ud.create=(e,t)=>new Ud({innerType:e,typeName:rt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ut(t)});class bb extends wt{_parse(t){if(this._getType(t)!==We.nan){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.nan,received:s.parsedType}),tt}return{status:"valid",value:t.data}}}bb.create=e=>new bb({typeName:rt.ZodNaN,...ut(e)});class lx extends wt{_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 Ep extends wt{_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"?tt:o.status==="dirty"?(n.dirty(),tc(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"?tt: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 Ep({in:t,out:n,typeName:rt.ZodPipeline})}}class Bd extends wt{_parse(t){const n=this._def.innerType._parse(t),s=r=>(Yi(r)&&(r.value=Object.freeze(r.value)),r);return Pd(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}Bd.create=(e,t)=>new Bd({innerType:e,typeName:rt.ZodReadonly,...ut(t)});var rt;(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"})(rt||(rt={}));const Ps=Hr.create,Un=Qi.create,Tp=Ch.create;ao.create;const co=Js.create,qt=Xt.create,il=Rd.create,gI=Cp.create;Id.create;jo.create;const Qn=Ld.create,Mp=qo.create;Fd.create;vr.create;Wo.create;const hI="codenomad.session-pruning",mI=`rpc.${hI}.pruned`,Ph=Ps().min(1).max(256),Ap=qt({sessionID:Ph,messageID:Ph}).strict();Ap.extend({revision:Ps().regex(/^[a-f0-9]{64}$/)}).strict();Ap.extend({revision:Ps().regex(/^[a-f0-9]{64}$/),indexes:co(Un().int().min(0).max(1e5)).min(1).max(100001).refine(e=>new Set(e).size===e.length)}).strict();const al=qt({status:Qn("blocked"),reason:Mp(["unavailable","maintenance_required","conflict","not_deletable","unsupported_storage"])}).strict();il([qt({status:Qn("pruned"),messageID:Ph,revision:Ps().regex(/^[a-f0-9]{64}$/),removedCount:Un().int().positive()}).strict(),al]);il([qt({status:Qn("preview"),revision:Ps().regex(/^[a-f0-9]{64}$/),liveMutation:Tp(),parts:co(qt({index:Un().int().nonnegative(),type:Mp(["tool","reasoning"]),bytes:Un().int().nonnegative()}))}).strict(),al]);const pI=Ap.extend({revision:Ps().regex(/^[a-f0-9]{64}$/)}).strict(),Ys=Ps().min(1).max(256),gc=gI("kind",[qt({kind:Qn("latest")}).strict(),qt({kind:Qn("oldest")}).strict(),qt({kind:Qn("around"),messageID:Ys}).strict(),qt({kind:Qn("before"),messageID:Ys}).strict(),qt({kind:Qn("after"),messageID:Ys}).strict()]);qt({sessionID:Ys,target:gc}).strict();const dx=qt({after:Un().int().nonnegative(),through:Un().int().nonnegative()}).strict(),ux=qt({after:Un().int().min(-1),through:Un().int().nonnegative(),digest:Ps().regex(/^[a-f0-9]{64}$/)}).strict();qt({sessionID:Ys,cursor:dx.optional(),after:Un().int().min(-1).optional(),known:co(ux).max(512).optional()}).strict();const fx=Mp(["user","assistant","system","synthetic","skill","shell","compaction","idle","agent-switched","model-switched","location-switched"]),yI=qt({id:Ys,seq:Un().int().nonnegative(),type:fx,tools:Un().int().nonnegative(),reasoning:Un().int().nonnegative(),toolName:Ps().max(256).optional()}).strict();il([al,qt({status:Qn("outline"),entries:co(yI).max(16384),total:Un().int().nonnegative(),cursor:dx.nullable(),checkpoints:co(ux.extend({changed:Tp()})).max(512)}).strict()]);qt({sessionID:Ys,messageIDs:co(Ys).min(1).max(12)}).strict();il([al,qt({status:Qn("previews"),entries:co(qt({id:Ys,text:Ps().max(4096),tools:Ps().max(4096)}).strict()).max(12)}).strict()]);il([al,qt({status:Qn("blocked"),reason:Qn("anchor_missing")}).strict(),qt({status:Qn("window"),messages:co(qt({id:Ys,type:fx,time:qt({created:Un()}).passthrough()}).passthrough()).max(200),older:gc.nullable(),newer:gc.nullable(),resume:gc,latest:Tp()}).strict()]);const Oh="codenomad:history-window:1:";class gx extends Error{constructor(){super(ke("session.pruning.conflict"))}}const ud=e=>Oh+encodeURIComponent(JSON.stringify(e));function vI(e){if(e!=null&&e.startsWith(Oh))return gc.parse(JSON.parse(decodeURIComponent(e.slice(Oh.length))))}async function wI(e,t,n,s){const r=await ft.fetchHistoryWindow(e,t,n,s);if(s==null||s.throwIfAborted(),r.status!=="window")throw r.reason==="anchor_missing"?new gx:new Error(ke(`session.pruning.${r.reason}`));return{response:{data:r.messages,cursor:{}},window:{kind:r.latest?"latest":"history",resumeCursor:ud(r.resume),olderCursor:r.older?ud(r.older):void 0,newerCursors:[r.newer?ud(r.newer):null]}}}const hx=200;function Os(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 bI(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:hx}}const Xi=Lt("api"),[Kd,Sb]=L(new Map),[Rh,kb]=L(new Map),Ci=new Map,Bl=new Set,Kl=new Map,Vl=new Map,[SI,xb]=L(new Map),Ih=new Map;async function mx(e,t){const n=Ci.get(e);if(n)return t||Bl.add(e),n;const s=async o=>{try{const a=await Ku(()=>bs()===e,new AbortController().signal,()=>ft.fetchWorktrees(e));a.defaultDirectory?Ih.set(e,a.defaultDirectory):Ih.delete(e),Sb(i=>{const c=new Map(i);return c.set(e,a.worktrees??[]),c}),kb(i=>{const c=new Map(i);return c.set(e,typeof a.isGitRepo=="boolean"?a.isGitRepo:null),c})}catch(a){if(Xi.warn(o?"Failed to load worktrees":"Failed to reload worktrees",{instanceId:e,error:a}),!o)throw a;Sb(i=>{const c=new Map(i);return c.set(e,[]),c}),kb(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{Bl.delete(e);try{await s(o)}catch(a){if(!Bl.has(e))throw a}o=!1}while(Bl.has(e))});Ci.set(e,r),await r.finally(()=>{Ci.get(e)===r&&Ci.delete(e)})}async function Li(e){if(!e||Kd().has(e)&&Rh().has(e))return;const t=Ci.get(e);t&&(await t,Kd().has(e)&&Rh().has(e))||await mx(e,!0)}async function ri(e){e&&await mx(e,!1)}fs.on("workspace.worktreesChanged",e=>{if(e.type!=="workspace.worktreesChanged")return;const t=e.workspaceId;!Kd().has(t)&&!Ci.has(t)||ri(t).catch(n=>Xi.warn("Failed to receive refreshed worktrees",{instanceId:t,error:n}))});async function kI(e,t,n=ri){var o;if(!e)return;Xi.info("OpenCode worktree ready",{instanceId:e,directory:t.directory,name:(o=t.properties)==null?void 0:o.name});const s=Kl.get(e),r=((s==null?void 0:s.catch(()=>{}))??Promise.resolve()).then(async()=>{await n(e)});Kl.set(e,r),await r.finally(()=>{Kl.get(e)===r&&Kl.delete(e)})}function ug(e){return Rh().get(e)??null}function Io(e){return lo(e).find(t=>t.slug==="root"&&t.directoryOnly)}async function KW(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 ft.createWorktree(e,{slug:s,fromSlug:n})}async function VW(e,t,n,s=r=>ts(async()=>{const{fetchSessions:o}=await Promise.resolve().then(()=>M1);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 ft.deleteWorktree(e,r,n)}catch(l){o=l}const a=[()=>ri(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"&&Xi.warn("Failed to refresh after worktree deletion",{instanceId:e,slug:r,error:d.reason})}if(o)throw o}function lo(e){return Kd().get(e)??[]}function Dp(e,t){return(t??"").trim()||"root"}function jW(e){return Dp(e,"root")}function px(e,t){var n;return((n=ya(e,t))==null?void 0:n.id)??t}function Vd(e){return Os(e)}function xI(e,t){var r,o,a;const n=(o=(r=Fe().get(e))==null?void 0:r.get(t))==null?void 0:o.location.directory,s=n&&((a=lo(e).find(i=>Vd(i.serviceDirectory??i.directory)===Vd(n)))==null?void 0:a.slug);return s?Dp(e,s):"root"}function qW(e,t){return xI(e,t)}function $b(e){return Ih.get(e)}function zW(e,t){return SI().get(`${e}:${px(e,t)}`)}async function WW(e,t,n,s={}){var m,w;await Li(e);const r=px(e,t),o=Dp(e,n),a=lo(e).find(S=>S.slug===o);if(!a)throw new Error(`Worktree not found: ${o}`);const i=(w=(m=Fe().get(e))==null?void 0:m.get(r))==null?void 0:w.location.directory,c=a.serviceDirectory??a.directory;if(i&&Vd(i)===Vd(c))return;const l=`${e}:${r}`,d=Vl.get(l),u=s.moveFamily??((S,b,v)=>ft.moveSessionFamily(S,b,{worktreeSlug:v})),f=s.refreshSessions??(S=>ts(async()=>{const{fetchSessions:b}=await Promise.resolve().then(()=>M1);return{fetchSessions:b}},void 0).then(({fetchSessions:b})=>b(S,{reset:!0,strictStatus:!0}))),h=((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=>{Xi.warn("Failed to refresh sessions after family move",{instanceId:e,rootSessionId:r,error:b})})}if(S)throw Xi.warn("Failed to move session family",{instanceId:e,rootSessionId:r,error:S}),Fn({message:ke("sessionList.worktreeMove.error"),variant:"error"}),S});Vl.set(l,h),xb(S=>new Map(S).set(l,o)),await h.finally(()=>{Vl.get(l)===h&&(Vl.delete(l),xb(S=>{const b=new Map(S);return b.delete(l),b}))})}function _b(e,t,n){const s=new Set([t,...n.flatMap(i=>[i.directory,i.serviceDirectory??i.directory])].map(Os).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(Os(i.location.directory))).map(o));return e.filter(i=>a.has(o(i)))}const[Pp,yx]=L(new Map),Op=(e,t)=>`${e}:${t}`;function cl(e,t,n){const s=Op(e,t);yx(r=>{const o=new Map(r);return n?o.set(s,n):o.delete(s),o})}function Rp(e,t){var n;return((n=Pp().get(Op(e,t)))==null?void 0:n.values)??[]}function vx(e){const t=`${e}:`;return[...Pp()].filter(([n])=>n.startsWith(t)).map(([n,s])=>[n.slice(t.length),s])}function HW(e){return e?Object.fromEntries(vx(e).filter(([,t])=>t.values.length>0).map(([t,n])=>[t,[...n.values]])):{}}function GW(e){return e?new Set(vx(e).filter(([,t])=>t.authoritative).map(([t])=>t)):new Set}function ZW(e,t,n){cl(e,t,{values:[...Rp(e,t),n],authoritative:!0})}function JW(e,t,n){cl(e,t,{values:Rp(e,t).filter(s=>s.id!==n),authoritative:!0})}function YW(e,t){cl(e,t,{values:[],authoritative:!0})}function $I(e,t){cl(e,t)}function QW(e,t,n){var s;cl(e,t,{values:[...n],authoritative:((s=Pp().get(Op(e,t)))==null?void 0:s.authoritative)??!1})}function _I(e,t=!1){if(!e)return;const n=`${e}:`;yx(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 CI(e){return`/workspaces/${encodeURIComponent(e)}/instance`}function pt(e){return Ji.createClient(e,CI(e),()=>bs()===e)}function EI(e){return e?{directory:e}:{}}function wo(e){return e.directory?{directory:e.directory}:{}}function Vu(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 Es(e){return JSON.stringify([e.directory,Vu(e)])}function Nt(e,t){var s;if(!e)return;const n=Vu(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 TI(e,t){var r;const n=[EI(e)],s=new Set(n.map(Es));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=Es(i);s.has(c)||(s.add(c),n.push(i))}return n}const hc=32e3;function $n(e){var r,o;const t=Ue().get(e),n=jn().get(e);return(n&&n!=="info"?(o=(r=Fe().get(e))==null?void 0:r.get(n))==null?void 0:o.location:void 0)??{directory:(t==null?void 0:t.folder)??""}}function ea(e,t){if(!(t!=null&&t.providerId)||!t.modelId)return!1;const s=(gi().get(e)||[]).find(r=>r.id===t.providerId);return s?s.models.some(r=>r.id===t.modelId):!1}function MI(e){const t=rT().models.recents??[];for(const n of t)if(ea(e,n))return n}async function ju(e,t){const n=gi().get(e)||[],s=Ky().get(e)||[],r=t?BR(s,t):"";if(r){const a=s.find(c=>c.id===r);if(a&&a.model&&ea(e,a.model))return{providerId:a.model.providerId,modelId:a.model.modelId};const i=await sT(e,r);if(ea(e,i))return i}const o=MI(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=Ue().get(e);if(a!=null&&a.client){const i=await pt(e).model.default({location:wo($n(e))},Nt($n(e))).catch(()=>null);if(i!=null&&i.data)return{providerId:i.data.providerID,modelId:i.data.id}}}return{providerId:"",modelId:""}}const AI={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 XW(e){var n;if(!e)return;const t=(n=e.split(".").pop())==null?void 0:n.toLowerCase();return t?AI[t]:void 0}function Fi(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 e7(e){const t={"&":"&amp;","<":"&lt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<"']/g,n=>t[n])}function fd(e){if(typeof e=="string")return Fi(e);if(e&&typeof e=="object"){const t={...e};return typeof t.text=="string"&&(t.text=Fi(t.text)),typeof t.value=="string"&&(t.value=Fi(t.value)),Array.isArray(t.content)&&(t.content=t.content.map(n=>fd(n))),t}return e}function jl(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=Fi(t.text);else if(t.text&&typeof t.text=="object"){const n={...t.text};typeof n.value=="string"&&(n.value=Fi(n.value)),Array.isArray(n.content)&&(n.content=n.content.map(s=>fd(s))),typeof n.text=="string"&&(n.text=Fi(n.text)),t.text=n}if(Array.isArray(t.content)&&(t.content=t.content.map(n=>fd(n))),t.thinking&&typeof t.thinking=="object"){const n={...t.thinking};Array.isArray(n.content)&&(n.content=n.content.map(s=>fd(s))),t.thinking=n}return t}function Cb(e){return{...e,name:e.type==="aborted"?"MessageAbortedError":e.type,data:{message:e.message}}}function DI(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 PI(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/${bR(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 bR(e){return e.split("/").map(encodeURIComponent).join("/")}function xh(e,t,n){if(n!==void 0){if(n===null){e.append(t,"null");return}if(Array.isArray(n)){for(const s of n)xh(e,t,s);return}if(typeof n=="object"){for(const[s,r]of Object.entries(n))xh(e,`${t}[${s}]`,r);return}e.append(t,String(n))}}async function db(e){var n,s;if(!nx(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 $s("UnsupportedContentType")}let t;try{t=await e.text()}catch(r){throw new $s("Transport",{cause:r})}if(t==="")throw new $s("MalformedResponse");try{return JSON.parse(t)}catch(r){throw new $s("MalformedResponse",{cause:r})}}function SR(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 nx(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 kR=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="SessionNotFoundError",xR=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="SessionBusyError",$R=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="FormNotFoundError",_R=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="FormAlreadySettledError",CR=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="PermissionNotFoundError",ER=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="RpcError",TR=e=>typeof e=="object"&&e!==null&&"_tag"in e&&e._tag==="RpcInternalError";function MR(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=AR(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!ER(i)&&!TR(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 AR(e,t){return`rpc.${e.id}.${t}`}var $h={};xp($h,{OpenCode:()=>$h,make:()=>DR});function DR(e){const t=tx(e),n=ex((s,r)=>t.event.subscribe({signal:s,onActivity:r}));return{...t,rpc:Object.assign(MR(t,n),t.rpc),event:n}}class PR{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 $p=new PR(2);async function Ku(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=xc(c=>(uS(()=>{e()&&!a&&s.abort(r)}),c));try{return await $p.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 OR{constructor(){this.clients=new Map}key(t,n){return`${t}:${rx(n)}`}createClient(t,n,s=()=>!1){const r=this.key(t,n),o=this.clients.get(r);if(o)return o;const a=sx(n),i=$h.make({baseUrl:a,fetch:RR(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 sx(e,t=tT){const n=rx(e);return`${IR(t??"")}${n}/`}function RR(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 nT(n,{...s,credentials:(s==null?void 0:s.credentials)??"include"});if(l.status===426){const{reportOpenCodeSetupRequired:d}=await ts(async()=>{const{reportOpenCodeSetupRequired:u}=await Promise.resolve().then(()=>c2);return{reportOpenCodeSetupRequired:u}},void 0);d()}if(l.status===502){const d=await l.clone().json().catch(()=>{});if((d==null?void 0:d.error)===nD){const{tGlobal:u}=await ts(async()=>{const{tGlobal:f}=await import("./index-DwKq8v48.js").then(h=>h.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)?Ku(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)?$p.run((s==null?void 0:s.signal)??(n instanceof Request?n.signal:new AbortController().signal),i):i()}}function rx(e){return(e.startsWith("/")?e:`/${e}`).replace(/\/+/g,"/").replace(/\/+$/,"")}function IR(e){return e.replace(/\/+$/,"")}const Ji=new OR;function _p(e,t,n,s=Date.now()){return t!=="idle"?null:e&&e!=="idle"?s:n??null}function LR(e){return!e||e.type==="idle"?"idle":"working"}function FR(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 NR(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 ox(e){return!e.hidden&&e.mode!=="subagent"}function UR(e,t){return e.find(n=>n.id===t)}function BR(e,t){const n=UR(e,t);if(n)return n.id;const s=e.filter(r=>r.name===t);return s.length===1?s[0].id:t}function BW(e,t,n){if(!n)return e.filter(ox);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 KR(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 h=await e.session.fork({sessionID:t,...o?{before:o}:{}});if(r(),!o&&(((c=h.fork)==null?void 0:c.boundary.type)!=="through"||h.fork.boundary.messageID!==n))throw await e.session.remove({sessionID:h.id}),new Error("Session changed while forking; please try again");return h}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 bt;(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})(bt||(bt={}));var ub;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(ub||(ub={}));const We=bt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zr=e=>{switch(typeof e){case"undefined":return We.undefined;case"string":return We.string;case"number":return Number.isNaN(e)?We.nan:We.number;case"boolean":return We.boolean;case"function":return We.function;case"bigint":return We.bigint;case"symbol":return We.symbol;case"object":return Array.isArray(e)?We.array:e===null?We.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?We.promise:typeof Map<"u"&&e instanceof Map?We.map:typeof Set<"u"&&e instanceof Set?We.set:typeof Date<"u"&&e instanceof Date?We.date:We.object;default:return We.unknown}},Me=bt.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 _r 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 _r))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,bt.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()}}_r.create=e=>new _r(e);const _h=(e,t)=>{let n;switch(e.code){case Me.invalid_type:e.received===We.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Me.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,bt.jsonStringifyReplacer)}`;break;case Me.unrecognized_keys:n=`Unrecognized key(s) in object: ${bt.joinValues(e.keys,", ")}`;break;case Me.invalid_union:n="Invalid input";break;case Me.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${bt.joinValues(e.options)}`;break;case Me.invalid_enum_value:n=`Invalid enum value. Expected ${bt.joinValues(e.options)}, received '${e.received}'`;break;case Me.invalid_arguments:n="Invalid function arguments";break;case Me.invalid_return_type:n="Invalid function return type";break;case Me.invalid_date:n="Invalid date";break;case Me.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}"`:bt.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Me.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 Me.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 Me.custom:n="Invalid input";break;case Me.invalid_intersection_types:n="Intersection results could not be merged";break;case Me.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Me.not_finite:n="Number must be finite";break;default:n=t.defaultError,bt.assertNever(e)}return{message:n}};let VR=_h;function jR(){return VR}const qR=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 Ke(e,t){const n=jR(),s=qR({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===_h?void 0:_h].filter(r=>!!r)});e.common.issues.push(s)}class ns{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 tt;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 ns.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 tt;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 tt=Object.freeze({status:"aborted"}),tc=e=>({status:"dirty",value:e}),Ss=e=>({status:"valid",value:e}),fb=e=>e.status==="aborted",gb=e=>e.status==="dirty",Yi=e=>e.status==="valid",Pd=e=>typeof Promise<"u"&&e instanceof Promise;var Ze;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ze||(Ze={}));class io{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 hb=(e,t)=>{if(Yi(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 _r(e.common.issues);return this._error=n,this._error}}};function ut(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 wt{get description(){return this._def.description}_getType(t){return zr(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:zr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ns,ctx:{common:t.parent.common,data:t.data,parsedType:zr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Pd(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:zr(t)},r=this._parseSync({data:t,path:s.path,parent:s});return hb(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:zr(t)};if(!this["~standard"].async)try{const o=this._parseSync({data:t,path:[],parent:n});return Yi(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=>Yi(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:zr(t)},r=this._parse({data:t,path:s.path,parent:s}),o=await(Pd(r)?r:Promise.resolve(r));return hb(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:Me.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 zo({schema:this,typeName:rt.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 vr.create(this,this._def)}nullable(){return Wo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Js.create(this)}promise(){return Fd.create(this,this._def)}or(t){return Rd.create([this,t],this._def)}and(t){return Id.create(this,t,this._def)}transform(t){return new zo({...ut(this._def),schema:this,typeName:rt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Nd({...ut(this._def),innerType:this,defaultValue:n,typeName:rt.ZodDefault})}brand(){return new lx({typeName:rt.ZodBranded,type:this,...ut(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Ud({...ut(this._def),innerType:this,catchValue:n,typeName:rt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ep.create(this,t)}readonly(){return Bd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const zR=/^c[^\s-]{8,}$/i,WR=/^[0-9a-z]+$/,HR=/^[0-9A-HJKMNP-TV-Z]{26}$/i,GR=/^[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,ZR=/^[a-z0-9_-]{21}$/i,JR=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,YR=/^[-+]?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)?)??$/,QR=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,XR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let dg;const eI=/^(?:(?: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])$/,tI=/^(?:(?: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])$/,nI=/^(([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]))$/,sI=/^(([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])$/,rI=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,oI=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ix="((\\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])))",iI=new RegExp(`^${ix}$`);function ax(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 aI(e){return new RegExp(`^${ax(e)}$`)}function cI(e){let t=`${ix}T${ax(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 lI(e,t){return!!((t==="v4"||!t)&&eI.test(e)||(t==="v6"||!t)&&nI.test(e))}function dI(e,t){if(!JR.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 uI(e,t){return!!((t==="v4"||!t)&&tI.test(e)||(t==="v6"||!t)&&sI.test(e))}class Hr extends wt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==We.string){const o=this._getOrReturnCtx(t);return Ke(o,{code:Me.invalid_type,expected:We.string,received:o.parsedType}),tt}const s=new ns;let r;for(const o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.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),Ke(r,{code:Me.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?Ke(r,{code:Me.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):i&&Ke(r,{code:Me.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if(o.kind==="email")QR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"email",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="emoji")dg||(dg=new RegExp(XR,"u")),dg.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"emoji",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="uuid")GR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"uuid",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="nanoid")ZR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"nanoid",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid")zR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"cuid",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid2")WR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"cuid2",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="ulid")HR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"ulid",code:Me.invalid_string,message:o.message}),s.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),Ke(r,{validation:"url",code:Me.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),Ke(r,{validation:"regex",code:Me.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),Ke(r,{code:Me.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),Ke(r,{code:Me.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):o.kind==="datetime"?cI(o).test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.invalid_string,validation:"datetime",message:o.message}),s.dirty()):o.kind==="date"?iI.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.invalid_string,validation:"date",message:o.message}),s.dirty()):o.kind==="time"?aI(o).test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.invalid_string,validation:"time",message:o.message}),s.dirty()):o.kind==="duration"?YR.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"duration",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="ip"?lI(t.data,o.version)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"ip",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="jwt"?dI(t.data,o.alg)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"jwt",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="cidr"?uI(t.data,o.version)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"cidr",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="base64"?rI.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"base64",code:Me.invalid_string,message:o.message}),s.dirty()):o.kind==="base64url"?oI.test(t.data)||(r=this._getOrReturnCtx(t,r),Ke(r,{validation:"base64url",code:Me.invalid_string,message:o.message}),s.dirty()):bt.assertNever(o);return{status:s.value,value:t.data}}_regex(t,n,s){return this.refinement(r=>t.test(r),{validation:n,code:Me.invalid_string,...Ze.errToObj(s)})}_addCheck(t){return new Hr({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ze.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ze.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ze.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ze.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ze.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ze.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ze.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ze.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ze.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ze.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ze.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ze.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ze.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,...Ze.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,...Ze.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Ze.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Ze.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Ze.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Ze.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Ze.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Ze.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Ze.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Ze.errToObj(n)})}nonempty(t){return this.min(1,Ze.errToObj(t))}trim(){return new Hr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Hr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Hr({...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}}Hr.create=e=>new Hr({checks:[],typeName:rt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...ut(e)});function fI(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 Qi extends wt{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)!==We.number){const o=this._getOrReturnCtx(t);return Ke(o,{code:Me.invalid_type,expected:We.number,received:o.parsedType}),tt}let s;const r=new ns;for(const o of this._def.checks)o.kind==="int"?bt.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),Ke(s,{code:Me.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),Ke(s,{code:Me.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),Ke(s,{code:Me.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="multipleOf"?fI(t.data,o.value)!==0&&(s=this._getOrReturnCtx(t,s),Ke(s,{code:Me.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),Ke(s,{code:Me.not_finite,message:o.message}),r.dirty()):bt.assertNever(o);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Ze.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ze.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ze.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ze.toString(n))}setLimit(t,n,s,r){return new Qi({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:Ze.toString(r)}]})}_addCheck(t){return new Qi({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ze.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ze.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ze.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ze.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ze.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ze.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Ze.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ze.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ze.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"&&bt.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)}}Qi.create=e=>new Qi({checks:[],typeName:rt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...ut(e)});class Mc extends wt{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)!==We.bigint)return this._getInvalidInput(t);let s;const r=new ns;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),Ke(s,{code:Me.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),Ke(s,{code:Me.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),Ke(s,{code:Me.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):bt.assertNever(o);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Ke(n,{code:Me.invalid_type,expected:We.bigint,received:n.parsedType}),tt}gte(t,n){return this.setLimit("min",t,!0,Ze.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ze.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ze.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ze.toString(n))}setLimit(t,n,s,r){return new Mc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:Ze.toString(r)}]})}_addCheck(t){return new Mc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ze.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ze.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ze.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ze.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ze.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}}Mc.create=e=>new Mc({checks:[],typeName:rt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...ut(e)});class Ch extends wt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==We.boolean){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.boolean,received:s.parsedType}),tt}return Ss(t.data)}}Ch.create=e=>new Ch({typeName:rt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...ut(e)});class Od extends wt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==We.date){const o=this._getOrReturnCtx(t);return Ke(o,{code:Me.invalid_type,expected:We.date,received:o.parsedType}),tt}if(Number.isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return Ke(o,{code:Me.invalid_date}),tt}const s=new ns;let r;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(r=this._getOrReturnCtx(t,r),Ke(r,{code:Me.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),Ke(r,{code:Me.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),s.dirty()):bt.assertNever(o);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Od({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Ze.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Ze.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}}Od.create=e=>new Od({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:rt.ZodDate,...ut(e)});class mb extends wt{_parse(t){if(this._getType(t)!==We.symbol){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.symbol,received:s.parsedType}),tt}return Ss(t.data)}}mb.create=e=>new mb({typeName:rt.ZodSymbol,...ut(e)});class Eh extends wt{_parse(t){if(this._getType(t)!==We.undefined){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.undefined,received:s.parsedType}),tt}return Ss(t.data)}}Eh.create=e=>new Eh({typeName:rt.ZodUndefined,...ut(e)});class Th extends wt{_parse(t){if(this._getType(t)!==We.null){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.null,received:s.parsedType}),tt}return Ss(t.data)}}Th.create=e=>new Th({typeName:rt.ZodNull,...ut(e)});class pb extends wt{constructor(){super(...arguments),this._any=!0}_parse(t){return Ss(t.data)}}pb.create=e=>new pb({typeName:rt.ZodAny,...ut(e)});class yb extends wt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ss(t.data)}}yb.create=e=>new yb({typeName:rt.ZodUnknown,...ut(e)});class ao extends wt{_parse(t){const n=this._getOrReturnCtx(t);return Ke(n,{code:Me.invalid_type,expected:We.never,received:n.parsedType}),tt}}ao.create=e=>new ao({typeName:rt.ZodNever,...ut(e)});class vb extends wt{_parse(t){if(this._getType(t)!==We.undefined){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.void,received:s.parsedType}),tt}return Ss(t.data)}}vb.create=e=>new vb({typeName:rt.ZodVoid,...ut(e)});class Js extends wt{_parse(t){const{ctx:n,status:s}=this._processInputParams(t),r=this._def;if(n.parsedType!==We.array)return Ke(n,{code:Me.invalid_type,expected:We.array,received:n.parsedType}),tt;if(r.exactLength!==null){const a=n.data.length>r.exactLength.value,i=n.data.length<r.exactLength.value;(a||i)&&(Ke(n,{code:a?Me.too_big:Me.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&&(Ke(n,{code:Me.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&&(Ke(n,{code:Me.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 io(n,a,n.path,i)))).then(a=>ns.mergeArray(s,a));const o=[...n.data].map((a,i)=>r.type._parseSync(new io(n,a,n.path,i)));return ns.mergeArray(s,o)}get element(){return this._def.type}min(t,n){return new Js({...this._def,minLength:{value:t,message:Ze.toString(n)}})}max(t,n){return new Js({...this._def,maxLength:{value:t,message:Ze.toString(n)}})}length(t,n){return new Js({...this._def,exactLength:{value:t,message:Ze.toString(n)}})}nonempty(t){return this.min(1,t)}}Js.create=(e,t)=>new Js({type:e,minLength:null,maxLength:null,exactLength:null,typeName:rt.ZodArray,...ut(t)});function ki(e){if(e instanceof Xt){const t={};for(const n in e.shape){const s=e.shape[n];t[n]=vr.create(ki(s))}return new Xt({...e._def,shape:()=>t})}else return e instanceof Js?new Js({...e._def,type:ki(e.element)}):e instanceof vr?vr.create(ki(e.unwrap())):e instanceof Wo?Wo.create(ki(e.unwrap())):e instanceof jo?jo.create(e.items.map(t=>ki(t))):e}class Xt extends wt{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=bt.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==We.object){const l=this._getOrReturnCtx(t);return Ke(l,{code:Me.invalid_type,expected:We.object,received:l.parsedType}),tt}const{status:s,ctx:r}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof ao&&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 io(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof ao){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&&(Ke(r,{code:Me.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 io(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=>ns.mergeObjectSync(s,l)):ns.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(t){return Ze.errToObj,new Xt({...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:Ze.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Xt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Xt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:rt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Xt({...this._def,catchall:t})}pick(t){const n={};for(const s of bt.objectKeys(t))t[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new Xt({...this._def,shape:()=>n})}omit(t){const n={};for(const s of bt.objectKeys(this.shape))t[s]||(n[s]=this.shape[s]);return new Xt({...this._def,shape:()=>n})}deepPartial(){return ki(this)}partial(t){const n={};for(const s of bt.objectKeys(this.shape)){const r=this.shape[s];t&&!t[s]?n[s]=r:n[s]=r.optional()}return new Xt({...this._def,shape:()=>n})}required(t){const n={};for(const s of bt.objectKeys(this.shape))if(t&&!t[s])n[s]=this.shape[s];else{let o=this.shape[s];for(;o instanceof vr;)o=o._def.innerType;n[s]=o}return new Xt({...this._def,shape:()=>n})}keyof(){return cx(bt.objectKeys(this.shape))}}Xt.create=(e,t)=>new Xt({shape:()=>e,unknownKeys:"strip",catchall:ao.create(),typeName:rt.ZodObject,...ut(t)});Xt.strictCreate=(e,t)=>new Xt({shape:()=>e,unknownKeys:"strict",catchall:ao.create(),typeName:rt.ZodObject,...ut(t)});Xt.lazycreate=(e,t)=>new Xt({shape:e,unknownKeys:"strip",catchall:ao.create(),typeName:rt.ZodObject,...ut(t)});class Rd extends wt{_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 _r(i.ctx.common.issues));return Ke(n,{code:Me.invalid_union,unionErrors:a}),tt}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 _r(c));return Ke(n,{code:Me.invalid_union,unionErrors:i}),tt}}get options(){return this._def.options}}Rd.create=(e,t)=>new Rd({options:e,typeName:rt.ZodUnion,...ut(t)});const fr=e=>e instanceof Ah?fr(e.schema):e instanceof zo?fr(e.innerType()):e instanceof Ld?[e.value]:e instanceof qo?e.options:e instanceof Dh?bt.objectValues(e.enum):e instanceof Nd?fr(e._def.innerType):e instanceof Eh?[void 0]:e instanceof Th?[null]:e instanceof vr?[void 0,...fr(e.unwrap())]:e instanceof Wo?[null,...fr(e.unwrap())]:e instanceof lx||e instanceof Bd?fr(e.unwrap()):e instanceof Ud?fr(e._def.innerType):[];class Cp extends wt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==We.object)return Ke(n,{code:Me.invalid_type,expected:We.object,received:n.parsedType}),tt;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}):(Ke(n,{code:Me.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),tt)}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=fr(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 Cp({typeName:rt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:r,...ut(s)})}}function Mh(e,t){const n=zr(e),s=zr(t);if(e===t)return{valid:!0,data:e};if(n===We.object&&s===We.object){const r=bt.objectKeys(t),o=bt.objectKeys(e).filter(i=>r.indexOf(i)!==-1),a={...e,...t};for(const i of o){const c=Mh(e[i],t[i]);if(!c.valid)return{valid:!1};a[i]=c.data}return{valid:!0,data:a}}else if(n===We.array&&s===We.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=Mh(a,i);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===We.date&&s===We.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Id extends wt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t),r=(o,a)=>{if(fb(o)||fb(a))return tt;const i=Mh(o.value,a.value);return i.valid?((gb(o)||gb(a))&&n.dirty(),{status:n.value,value:i.data}):(Ke(s,{code:Me.invalid_intersection_types}),tt)};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}))}}Id.create=(e,t,n)=>new Id({left:e,right:t,typeName:rt.ZodIntersection,...ut(n)});class jo extends wt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==We.array)return Ke(s,{code:Me.invalid_type,expected:We.array,received:s.parsedType}),tt;if(s.data.length<this._def.items.length)return Ke(s,{code:Me.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),tt;!this._def.rest&&s.data.length>this._def.items.length&&(Ke(s,{code:Me.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 io(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(o).then(a=>ns.mergeArray(n,a)):ns.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new jo({...this._def,rest:t})}}jo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jo({items:e,typeName:rt.ZodTuple,rest:null,...ut(t)})};class wb extends wt{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!==We.map)return Ke(s,{code:Me.invalid_type,expected:We.map,received:s.parsedType}),tt;const r=this._def.keyType,o=this._def.valueType,a=[...s.data.entries()].map(([i,c],l)=>({key:r._parse(new io(s,i,s.path,[l,"key"])),value:o._parse(new io(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 tt;(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 tt;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),i.set(l.value,d.value)}return{status:n.value,value:i}}}}wb.create=(e,t,n)=>new wb({valueType:t,keyType:e,typeName:rt.ZodMap,...ut(n)});class Ac extends wt{_parse(t){const{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==We.set)return Ke(s,{code:Me.invalid_type,expected:We.set,received:s.parsedType}),tt;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(Ke(s,{code:Me.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&&(Ke(s,{code:Me.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 tt;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 io(s,c,s.path,l)));return s.common.async?Promise.all(i).then(c=>a(c)):a(i)}min(t,n){return new Ac({...this._def,minSize:{value:t,message:Ze.toString(n)}})}max(t,n){return new Ac({...this._def,maxSize:{value:t,message:Ze.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Ac.create=(e,t)=>new Ac({valueType:e,minSize:null,maxSize:null,typeName:rt.ZodSet,...ut(t)});class Ah extends wt{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})}}Ah.create=(e,t)=>new Ah({getter:e,typeName:rt.ZodLazy,...ut(t)});class Ld extends wt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Ke(n,{received:n.data,code:Me.invalid_literal,expected:this._def.value}),tt}return{status:"valid",value:t.data}}get value(){return this._def.value}}Ld.create=(e,t)=>new Ld({value:e,typeName:rt.ZodLiteral,...ut(t)});function cx(e,t){return new qo({values:e,typeName:rt.ZodEnum,...ut(t)})}class qo extends wt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),s=this._def.values;return Ke(n,{expected:bt.joinValues(s),received:n.parsedType,code:Me.invalid_type}),tt}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 Ke(n,{received:n.data,code:Me.invalid_enum_value,options:s}),tt}return Ss(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 qo.create(t,{...this._def,...n})}exclude(t,n=this._def){return qo.create(this.options.filter(s=>!t.includes(s)),{...this._def,...n})}}qo.create=cx;class Dh extends wt{_parse(t){const n=bt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==We.string&&s.parsedType!==We.number){const r=bt.objectValues(n);return Ke(s,{expected:bt.joinValues(r),received:s.parsedType,code:Me.invalid_type}),tt}if(this._cache||(this._cache=new Set(bt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=bt.objectValues(n);return Ke(s,{received:s.data,code:Me.invalid_enum_value,options:r}),tt}return Ss(t.data)}get enum(){return this._def.values}}Dh.create=(e,t)=>new Dh({values:e,typeName:rt.ZodNativeEnum,...ut(t)});class Fd extends wt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==We.promise&&n.common.async===!1)return Ke(n,{code:Me.invalid_type,expected:We.promise,received:n.parsedType}),tt;const s=n.parsedType===We.promise?n.data:Promise.resolve(n.data);return Ss(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Fd.create=(e,t)=>new Fd({type:e,typeName:rt.ZodPromise,...ut(t)});class zo extends wt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===rt.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=>{Ke(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 tt;const c=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return c.status==="aborted"?tt:c.status==="dirty"||n.value==="dirty"?tc(c.value):c});{if(n.value==="aborted")return tt;const i=this._def.schema._parseSync({data:a,path:s.path,parent:s});return i.status==="aborted"?tt:i.status==="dirty"||n.value==="dirty"?tc(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"?tt:(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"?tt:(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(!Yi(a))return tt;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=>Yi(a)?Promise.resolve(r.transform(a.value,o)).then(i=>({status:n.value,value:i})):tt);bt.assertNever(r)}}zo.create=(e,t,n)=>new zo({schema:e,typeName:rt.ZodEffects,effect:t,...ut(n)});zo.createWithPreprocess=(e,t,n)=>new zo({schema:t,effect:{type:"preprocess",transform:e},typeName:rt.ZodEffects,...ut(n)});class vr extends wt{_parse(t){return this._getType(t)===We.undefined?Ss(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}vr.create=(e,t)=>new vr({innerType:e,typeName:rt.ZodOptional,...ut(t)});class Wo extends wt{_parse(t){return this._getType(t)===We.null?Ss(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Wo.create=(e,t)=>new Wo({innerType:e,typeName:rt.ZodNullable,...ut(t)});class Nd extends wt{_parse(t){const{ctx:n}=this._processInputParams(t);let s=n.data;return n.parsedType===We.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Nd.create=(e,t)=>new Nd({innerType:e,typeName:rt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ut(t)});class Ud extends wt{_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 Pd(r)?r.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new _r(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new _r(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ud.create=(e,t)=>new Ud({innerType:e,typeName:rt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ut(t)});class bb extends wt{_parse(t){if(this._getType(t)!==We.nan){const s=this._getOrReturnCtx(t);return Ke(s,{code:Me.invalid_type,expected:We.nan,received:s.parsedType}),tt}return{status:"valid",value:t.data}}}bb.create=e=>new bb({typeName:rt.ZodNaN,...ut(e)});class lx extends wt{_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 Ep extends wt{_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"?tt:o.status==="dirty"?(n.dirty(),tc(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"?tt: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 Ep({in:t,out:n,typeName:rt.ZodPipeline})}}class Bd extends wt{_parse(t){const n=this._def.innerType._parse(t),s=r=>(Yi(r)&&(r.value=Object.freeze(r.value)),r);return Pd(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}Bd.create=(e,t)=>new Bd({innerType:e,typeName:rt.ZodReadonly,...ut(t)});var rt;(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"})(rt||(rt={}));const Ps=Hr.create,Un=Qi.create,Tp=Ch.create;ao.create;const co=Js.create,qt=Xt.create,il=Rd.create,gI=Cp.create;Id.create;jo.create;const Qn=Ld.create,Mp=qo.create;Fd.create;vr.create;Wo.create;const hI="codenomad.session-pruning",mI=`rpc.${hI}.pruned`,Ph=Ps().min(1).max(256),Ap=qt({sessionID:Ph,messageID:Ph}).strict();Ap.extend({revision:Ps().regex(/^[a-f0-9]{64}$/)}).strict();Ap.extend({revision:Ps().regex(/^[a-f0-9]{64}$/),indexes:co(Un().int().min(0).max(1e5)).min(1).max(100001).refine(e=>new Set(e).size===e.length)}).strict();const al=qt({status:Qn("blocked"),reason:Mp(["unavailable","maintenance_required","conflict","not_deletable","unsupported_storage"])}).strict();il([qt({status:Qn("pruned"),messageID:Ph,revision:Ps().regex(/^[a-f0-9]{64}$/),removedCount:Un().int().positive()}).strict(),al]);il([qt({status:Qn("preview"),revision:Ps().regex(/^[a-f0-9]{64}$/),liveMutation:Tp(),parts:co(qt({index:Un().int().nonnegative(),type:Mp(["tool","reasoning"]),bytes:Un().int().nonnegative()}))}).strict(),al]);const pI=Ap.extend({revision:Ps().regex(/^[a-f0-9]{64}$/)}).strict(),Ys=Ps().min(1).max(256),gc=gI("kind",[qt({kind:Qn("latest")}).strict(),qt({kind:Qn("oldest")}).strict(),qt({kind:Qn("around"),messageID:Ys}).strict(),qt({kind:Qn("before"),messageID:Ys}).strict(),qt({kind:Qn("after"),messageID:Ys}).strict()]);qt({sessionID:Ys,target:gc}).strict();const dx=qt({after:Un().int().nonnegative(),through:Un().int().nonnegative()}).strict(),ux=qt({after:Un().int().min(-1),through:Un().int().nonnegative(),digest:Ps().regex(/^[a-f0-9]{64}$/)}).strict();qt({sessionID:Ys,cursor:dx.optional(),after:Un().int().min(-1).optional(),known:co(ux).max(512).optional()}).strict();const fx=Mp(["user","assistant","system","synthetic","skill","shell","compaction","idle","agent-switched","model-switched","location-switched"]),yI=qt({id:Ys,seq:Un().int().nonnegative(),type:fx,tools:Un().int().nonnegative(),reasoning:Un().int().nonnegative(),toolName:Ps().max(256).optional()}).strict();il([al,qt({status:Qn("outline"),entries:co(yI).max(16384),total:Un().int().nonnegative(),cursor:dx.nullable(),checkpoints:co(ux.extend({changed:Tp()})).max(512)}).strict()]);qt({sessionID:Ys,messageIDs:co(Ys).min(1).max(12)}).strict();il([al,qt({status:Qn("previews"),entries:co(qt({id:Ys,text:Ps().max(4096),tools:Ps().max(4096)}).strict()).max(12)}).strict()]);il([al,qt({status:Qn("blocked"),reason:Qn("anchor_missing")}).strict(),qt({status:Qn("window"),messages:co(qt({id:Ys,type:fx,time:qt({created:Un()}).passthrough()}).passthrough()).max(200),older:gc.nullable(),newer:gc.nullable(),resume:gc,latest:Tp()}).strict()]);const Oh="codenomad:history-window:1:";class gx extends Error{constructor(){super(ke("session.pruning.conflict"))}}const ud=e=>Oh+encodeURIComponent(JSON.stringify(e));function vI(e){if(e!=null&&e.startsWith(Oh))return gc.parse(JSON.parse(decodeURIComponent(e.slice(Oh.length))))}async function wI(e,t,n,s){const r=await ft.fetchHistoryWindow(e,t,n,s);if(s==null||s.throwIfAborted(),r.status!=="window")throw r.reason==="anchor_missing"?new gx:new Error(ke(`session.pruning.${r.reason}`));return{response:{data:r.messages,cursor:{}},window:{kind:r.latest?"latest":"history",resumeCursor:ud(r.resume),olderCursor:r.older?ud(r.older):void 0,newerCursors:[r.newer?ud(r.newer):null]}}}const hx=200;function Os(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 bI(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:hx}}const Xi=Lt("api"),[Kd,Sb]=L(new Map),[Rh,kb]=L(new Map),Ci=new Map,Bl=new Set,Kl=new Map,Vl=new Map,[SI,xb]=L(new Map),Ih=new Map;async function mx(e,t){const n=Ci.get(e);if(n)return t||Bl.add(e),n;const s=async o=>{try{const a=await Ku(()=>bs()===e,new AbortController().signal,()=>ft.fetchWorktrees(e));a.defaultDirectory?Ih.set(e,a.defaultDirectory):Ih.delete(e),Sb(i=>{const c=new Map(i);return c.set(e,a.worktrees??[]),c}),kb(i=>{const c=new Map(i);return c.set(e,typeof a.isGitRepo=="boolean"?a.isGitRepo:null),c})}catch(a){if(Xi.warn(o?"Failed to load worktrees":"Failed to reload worktrees",{instanceId:e,error:a}),!o)throw a;Sb(i=>{const c=new Map(i);return c.set(e,[]),c}),kb(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{Bl.delete(e);try{await s(o)}catch(a){if(!Bl.has(e))throw a}o=!1}while(Bl.has(e))});Ci.set(e,r),await r.finally(()=>{Ci.get(e)===r&&Ci.delete(e)})}async function Li(e){if(!e||Kd().has(e)&&Rh().has(e))return;const t=Ci.get(e);t&&(await t,Kd().has(e)&&Rh().has(e))||await mx(e,!0)}async function ri(e){e&&await mx(e,!1)}fs.on("workspace.worktreesChanged",e=>{if(e.type!=="workspace.worktreesChanged")return;const t=e.workspaceId;!Kd().has(t)&&!Ci.has(t)||ri(t).catch(n=>Xi.warn("Failed to receive refreshed worktrees",{instanceId:t,error:n}))});async function kI(e,t,n=ri){var o;if(!e)return;Xi.info("OpenCode worktree ready",{instanceId:e,directory:t.directory,name:(o=t.properties)==null?void 0:o.name});const s=Kl.get(e),r=((s==null?void 0:s.catch(()=>{}))??Promise.resolve()).then(async()=>{await n(e)});Kl.set(e,r),await r.finally(()=>{Kl.get(e)===r&&Kl.delete(e)})}function ug(e){return Rh().get(e)??null}function Io(e){return lo(e).find(t=>t.slug==="root"&&t.directoryOnly)}async function KW(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 ft.createWorktree(e,{slug:s,fromSlug:n})}async function VW(e,t,n,s=r=>ts(async()=>{const{fetchSessions:o}=await Promise.resolve().then(()=>M1);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 ft.deleteWorktree(e,r,n)}catch(l){o=l}const a=[()=>ri(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"&&Xi.warn("Failed to refresh after worktree deletion",{instanceId:e,slug:r,error:d.reason})}if(o)throw o}function lo(e){return Kd().get(e)??[]}function Dp(e,t){return(t??"").trim()||"root"}function jW(e){return Dp(e,"root")}function px(e,t){var n;return((n=ya(e,t))==null?void 0:n.id)??t}function Vd(e){return Os(e)}function xI(e,t){var r,o,a;const n=(o=(r=Fe().get(e))==null?void 0:r.get(t))==null?void 0:o.location.directory,s=n&&((a=lo(e).find(i=>Vd(i.serviceDirectory??i.directory)===Vd(n)))==null?void 0:a.slug);return s?Dp(e,s):"root"}function qW(e,t){return xI(e,t)}function $b(e){return Ih.get(e)}function zW(e,t){return SI().get(`${e}:${px(e,t)}`)}async function WW(e,t,n,s={}){var m,w;await Li(e);const r=px(e,t),o=Dp(e,n),a=lo(e).find(S=>S.slug===o);if(!a)throw new Error(`Worktree not found: ${o}`);const i=(w=(m=Fe().get(e))==null?void 0:m.get(r))==null?void 0:w.location.directory,c=a.serviceDirectory??a.directory;if(i&&Vd(i)===Vd(c))return;const l=`${e}:${r}`,d=Vl.get(l),u=s.moveFamily??((S,b,v)=>ft.moveSessionFamily(S,b,{worktreeSlug:v})),f=s.refreshSessions??(S=>ts(async()=>{const{fetchSessions:b}=await Promise.resolve().then(()=>M1);return{fetchSessions:b}},void 0).then(({fetchSessions:b})=>b(S,{reset:!0,strictStatus:!0}))),h=((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=>{Xi.warn("Failed to refresh sessions after family move",{instanceId:e,rootSessionId:r,error:b})})}if(S)throw Xi.warn("Failed to move session family",{instanceId:e,rootSessionId:r,error:S}),Fn({message:ke("sessionList.worktreeMove.error"),variant:"error"}),S});Vl.set(l,h),xb(S=>new Map(S).set(l,o)),await h.finally(()=>{Vl.get(l)===h&&(Vl.delete(l),xb(S=>{const b=new Map(S);return b.delete(l),b}))})}function _b(e,t,n){const s=new Set([t,...n.flatMap(i=>[i.directory,i.serviceDirectory??i.directory])].map(Os).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(Os(i.location.directory))).map(o));return e.filter(i=>a.has(o(i)))}const[Pp,yx]=L(new Map),Op=(e,t)=>`${e}:${t}`;function cl(e,t,n){const s=Op(e,t);yx(r=>{const o=new Map(r);return n?o.set(s,n):o.delete(s),o})}function Rp(e,t){var n;return((n=Pp().get(Op(e,t)))==null?void 0:n.values)??[]}function vx(e){const t=`${e}:`;return[...Pp()].filter(([n])=>n.startsWith(t)).map(([n,s])=>[n.slice(t.length),s])}function HW(e){return e?Object.fromEntries(vx(e).filter(([,t])=>t.values.length>0).map(([t,n])=>[t,[...n.values]])):{}}function GW(e){return e?new Set(vx(e).filter(([,t])=>t.authoritative).map(([t])=>t)):new Set}function ZW(e,t,n){cl(e,t,{values:[...Rp(e,t),n],authoritative:!0})}function JW(e,t,n){cl(e,t,{values:Rp(e,t).filter(s=>s.id!==n),authoritative:!0})}function YW(e,t){cl(e,t,{values:[],authoritative:!0})}function $I(e,t){cl(e,t)}function QW(e,t,n){var s;cl(e,t,{values:[...n],authoritative:((s=Pp().get(Op(e,t)))==null?void 0:s.authoritative)??!1})}function _I(e,t=!1){if(!e)return;const n=`${e}:`;yx(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 CI(e){return`/workspaces/${encodeURIComponent(e)}/instance`}function pt(e){return Ji.createClient(e,CI(e),()=>bs()===e)}function EI(e){return e?{directory:e}:{}}function wo(e){return e.directory?{directory:e.directory}:{}}function Vu(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 Es(e){return JSON.stringify([e.directory,Vu(e)])}function Nt(e,t){var s;if(!e)return;const n=Vu(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 TI(e,t){var r;const n=[EI(e)],s=new Set(n.map(Es));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=Es(i);s.has(c)||(s.add(c),n.push(i))}return n}const hc=32e3;function $n(e){var r,o;const t=Ue().get(e),n=jn().get(e);return(n&&n!=="info"?(o=(r=Fe().get(e))==null?void 0:r.get(n))==null?void 0:o.location:void 0)??{directory:(t==null?void 0:t.folder)??""}}function ea(e,t){if(!(t!=null&&t.providerId)||!t.modelId)return!1;const s=(gi().get(e)||[]).find(r=>r.id===t.providerId);return s?s.models.some(r=>r.id===t.modelId):!1}function MI(e){const t=rT().models.recents??[];for(const n of t)if(ea(e,n))return n}async function ju(e,t){const n=gi().get(e)||[],s=Ky().get(e)||[],r=t?BR(s,t):"";if(r){const a=s.find(c=>c.id===r);if(a&&a.model&&ea(e,a.model))return{providerId:a.model.providerId,modelId:a.model.modelId};const i=await sT(e,r);if(ea(e,i))return i}const o=MI(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=Ue().get(e);if(a!=null&&a.client){const i=await pt(e).model.default({location:wo($n(e))},Nt($n(e))).catch(()=>null);if(i!=null&&i.data)return{providerId:i.data.providerID,modelId:i.data.id}}}return{providerId:"",modelId:""}}const AI={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 XW(e){var n;if(!e)return;const t=(n=e.split(".").pop())==null?void 0:n.toLowerCase();return t?AI[t]:void 0}function Fi(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 e7(e){const t={"&":"&amp;","<":"&lt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<"']/g,n=>t[n])}function fd(e){if(typeof e=="string")return Fi(e);if(e&&typeof e=="object"){const t={...e};return typeof t.text=="string"&&(t.text=Fi(t.text)),typeof t.value=="string"&&(t.value=Fi(t.value)),Array.isArray(t.content)&&(t.content=t.content.map(n=>fd(n))),t}return e}function jl(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=Fi(t.text);else if(t.text&&typeof t.text=="object"){const n={...t.text};typeof n.value=="string"&&(n.value=Fi(n.value)),Array.isArray(n.content)&&(n.content=n.content.map(s=>fd(s))),typeof n.text=="string"&&(n.text=Fi(n.text)),t.text=n}if(Array.isArray(t.content)&&(t.content=t.content.map(n=>fd(n))),t.thinking&&typeof t.thinking=="object"){const n={...t.thinking};Array.isArray(n.content)&&(n.content=n.content.map(s=>fd(s))),t.thinking=n}return t}function Cb(e){return{...e,name:e.type==="aborted"?"MessageAbortedError":e.type,data:{message:e.message}}}function DI(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 PI(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}function qu(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?Cb(n.error):void 0}:{},...t.type==="compaction"&&t.status==="failed"?{error:Cb(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 jl({...d,id:`${t.id}-${d.type}-${u}`,sessionID:e,messageID:t.id});const f=d.state,h=f.status==="streaming"?{status:"pending"}:{...f,...f.status==="completed"?{output:PI(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:h}}),o.length===0&&t.error&&(o=[jl({id:`${t.id}-error`,type:"text",text:"",sessionID:e,messageID:t.id})]);else if(t.type==="user")o=[jl({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=[jl({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:DI(t),version:0}}}const Ei="codenomad:prompt-display:v3",Eb="codenomad:prompt-display:v2";let Tb=!1;const _n=new Map;function wx(){var t;const e=typeof window>"u"?"":(t=window.__CODENOMAD_WINDOW_ID__)==null?void 0:t.trim();return e?`${Ei}:${e}`:Ei}function Dc(e,t,n){return`${t}:${n}`}function OI(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 RI(e){return OI(e)?e.slice(e.indexOf(":")+1):e}function bx(){return typeof window>"u"||!window.localStorage?null:window.localStorage}function Aa(){if(Tb)return;Tb=!0;const e=bx();if(e)try{const t=wx(),n=e.getItem(t);n&&fg(JSON.parse(n),!1);const s=t!==Ei&&!n,r=s?e.getItem(Ei):null;r&&fg(JSON.parse(r),!1);const o=t===Ei||s?e.getItem(Eb):null;if(o&&fg(JSON.parse(o),!0),!r&&!o||!Da())return;r&&e.removeItem(Ei),o&&e.removeItem(Eb)}catch{_n.clear()}}function fg(e,t){for(const[n,s]of Object.entries(e))Sx(s)&&_n.set(t?RI(n):n,s)}function Da(){const e=bx();if(!e)return!1;try{return e.setItem(wx(),JSON.stringify(Object.fromEntries(_n))),!0}catch{return!1}}function Sx(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 II(e,t,n){return Aa(),_n.get(Dc(e,t,n))}function Mb(e,t,n,s){Aa();const r=Dc(e,t,n),o=_n.get(r);if(s&&Sx(s)){const a=JSON.stringify(s);if(o&&JSON.stringify(o)===a)return;_n.set(r,s)}else{if(!_n.has(r))return;_n.delete(r)}Da()}function LI(e,t,n,s){Aa();const r=Dc(e,t,n),o=_n.get(r);if(!o)return;const a=Dc(e,t,s);r!==a&&(_n.delete(r),_n.set(a,o),Da())}function gg(e,t,n){Aa(),_n.delete(Dc(e,t,n))&&Da()}function FI(e,t){Aa();const n=`${t}:`,s=`${e}:${t}:`;let r=!1;for(const o of _n.keys())(o.startsWith(n)||o.startsWith(s))&&(_n.delete(o),r=!0);r&&Da()}function NI(e,t=[]){Aa();let n=!1;for(const s of _n.keys()){const r=t.some(a=>s.startsWith(`${a}:`)),o=s.startsWith(`${e}:`);(r||o)&&(_n.delete(s),n=!0)}n&&Da()}const Pc=new Map;function kx(e,t){return`${e}:${t}`}function t7(e,t){const n=kx(e,t.id),s=Pc.get(n);if(s&&s.revision===t.revision)return s.data;const r=[];for(const a of t.partIds){const i=t.parts[a];i!=null&&i.data&&r.push({...i.data,revision:i.revision})}const o={orderedParts:r};return Pc.set(n,{revision:t.revision,data:o}),o}function n7(e){const t=`${e}:`;for(const n of Pc.keys())n.startsWith(t)&&Pc.delete(n)}function za(e,t){for(const n of t)typeof n!="string"||n.length===0||Pc.delete(kx(e,n))}function UI(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function BI(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&&UI(e.existingValue,e.incomingValue))}const KI=Lt("session");function Ab(e){return{instanceId:e,sessions:{},sessionOrder:[],messages:{},lastAssistantMessageIds:{},messageInfoVersion:{},pendingParts:{},sessionRevisions:{},permissions:{queue:[],active:null,byMessage:{}},usage:{},scrollState:{},latestTodos:{}}}function Db(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 VI=3e4;function jI(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 Lh(){return{entries:{},totalInputTokens:0,totalOutputTokens:0,totalReasoningTokens:0,totalCost:0,actualUsageTokens:0,latestMessageId:void 0}}function Pb(e,t,n){if(t.clientPromptDisplayMetadata)return t.clientPromptDisplayMetadata;const s=II(e,t.sessionId,t.id);return s||(n==null?void 0:n.clientPromptDisplayMetadata)}function xx(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 $x(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 Ob(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 Rb(e){const t=Lh();for(const n of e){const s=xx(n);s&&$x(t,s)}return t}function qI(e,t){const[n,s]=Um(Ab(e)),r="todowrite",o=new Map,a=new Set,i=new Map;function c(_){a.delete(_),i.delete(_)}function l(_){return a.has(_)}function d(_){var P;for(let j=_.length-1;j>=0;j-=1){const K=_[j];if(((P=n.messages[K])==null?void 0:P.role)==="assistant")return K}}function u(_,P){var j;_&&s("lastAssistantMessageIds",_,d(P??((j=n.sessions[_])==null?void 0:j.messageIds)??[]))}function f(_){var j,K;if(!_)return-1;const P=((j=n.sessions[_])==null?void 0:j.messageIds)??[];for(let I=P.length-1;I>=0;I--){const Z=P[I],xe=n.messages[Z];if(!(!xe||!Array.isArray(xe.partIds)||xe.partIds.length===0))for(const De of xe.partIds){const Qe=(K=xe.parts[De])==null?void 0:K.data;if((Qe==null?void 0:Qe.type)==="compaction")return I}}return-1}function h(_){if(!_||_.type!=="tool"||(typeof _.tool=="string"?_.tool:"")!==r)return!1;const j=_.state;return!j||typeof j!="object"?!1:j.status==="completed"}function m(_,P){_&&s("latestTodos",_,j=>j&&j.timestamp>P.timestamp?j:P)}function w(_){if(!(!_||!Array.isArray(_.partIds)||_.partIds.length===0))for(let P=_.partIds.length-1;P>=0;P-=1){const j=_.partIds[P],K=_.parts[j];if(K&&h(K.data)){const I=typeof _.updatedAt=="number"?_.updatedAt:Date.now();m(_.sessionId,{messageId:_.id,partId:j,timestamp:I});break}}}function S(_){s("latestTodos",_,void 0)}function b(_){var K;const P=n.latestTodos[_];return P&&(((K=n.sessions[_])==null?void 0:K.messageIds)??[]).indexOf(P.messageId)>f(_)?P:void 0}function v(_){_&&s("sessionRevisions",_,(P=0)=>P+1)}function k(_){return n.sessionRevisions[_]??0}function $(_){return n.lastAssistantMessageIds[_]}function C(_,P){s("usage",_,j=>{const K=j?{...j,entries:{...j.entries}}:Lh();return P(K),K})}function T(_){if(!_||typeof _.sessionID!="string")return;const P=typeof _.id=="string"?_.id:void 0;P&&C(_.sessionID,j=>{Ob(j,P);const K=xx(_);K&&$x(j,K)})}function D(_,P){const j=Rb(P);s("usage",_,j)}function R(_){return n.usage[_]}function q(_){const P=n.sessions[_];if(P)return P;const j=Date.now(),K={id:_,createdAt:j,updatedAt:j,messageIds:[]};return s("sessions",_,K),s("sessionOrder",I=>I.includes(_)?I:[...I,_]),K}function re(_){const P=q(_.id),j=[...P.messageIds],K=Array.isArray(_.messageIds)?_.messageIds:P.messageIds;s("sessions",_.id,{...P,title:_.title??P.title,parentId:_.parentId??P.parentId??null,updatedAt:Date.now(),messageIds:K,revert:_.revert!==void 0?_.revert:P.revert??null}),Array.isArray(_.messageIds)&&!jI(j,K)&&(u(_.id,K),v(_.id))}function ee(_,P,j,K){if(!_||!P||_.length!==j.length)return!0;for(let I=0;I<j.length;I++)if(_[I]!==j[I])return!0;for(const I of j){const Z=P[I],xe=K[I];if(Z!==xe&&(!Z||!xe||JSON.stringify(Z.data)!==JSON.stringify(xe.data)))return!0}return!1}function W(_,P,j,K){var te,ie,Pe;if(!Array.isArray(P)||P.length===0)return;q(_);const I=new Set,Z=(ie=(te=n.sessions[_])==null?void 0:te.revert)==null?void 0:ie.messageID,xe=P.filter(ne=>Z&&ne.id>=Z||I.has(ne.id)?!1:(I.add(ne.id),!0)),De=xe.map(ne=>ne.id),Qe=new Set(De),et=new Set(xe.filter(ne=>ne.parts!==void 0).map(ne=>ne.id)),Tt=((Pe=n.sessions[_])==null?void 0:Pe.messageIds)??[],He=[],yt=[];for(const ne of Tt){if(Qe.has(ne))continue;n.messages[ne]&&l(ne)?He.push(ne):yt.push(ne)}const Ot=[...K!=null&&K.preserveOmitted?yt:[],...De,...He],Dn={},Wn=Date.now();xe.forEach(ne=>{const me=ye(ne.id,ne.parts),Be=n.messages[ne.id],lt=me?ee(Be==null?void 0:Be.partIds,Be==null?void 0:Be.parts,me.ids,me.map):!1,it=Be?Be.status!==ne.status:!0,Ve=!!(ne.bumpRevision||lt||it),at=Pb(e,ne,Be);Dn[ne.id]={id:ne.id,sessionId:ne.sessionId,role:ne.role,status:ne.status,createdAt:ne.createdAt??(Be==null?void 0:Be.createdAt)??Wn,updatedAt:ne.updatedAt??Wn,isEphemeral:ne.isEphemeral??(Be==null?void 0:Be.isEphemeral)??!1,clientPromptDisplayMetadata:at,revision:Be?Be.revision+(Ve?1:0):0,partIds:me?me.ids:(Be==null?void 0:Be.partIds)??[],parts:me?me.map:(Be==null?void 0:Be.parts)??{}},Mb(e,ne.sessionId,ne.id,at)});const Hn=ne=>!Z||ne.id<Z,Gn=j?Array.from(j).filter(Hn):void 0,dr=K!=null&&K.preserveOmitted&&Gn?new Map([...Array.from(o.values()).filter(ne=>ne.sessionID===_&&Hn(ne)).map(ne=>[ne.id,ne]),...Gn.map(ne=>[ne.id,ne])]).values():Gn,mi=dr?Rb(dr):n.usage[_],ur={...n.messages},js={...n.messageInfoVersion},pi={...n.pendingParts},Ba={...n.permissions.byMessage};if(Object.entries(Dn).forEach(([ne,me])=>{ur[ne]=me}),!(K!=null&&K.preserveOmitted)&&yt.length>0&&(yt.forEach(ne=>{o.delete(ne),c(ne),gg(e,_,ne),delete ur[ne],delete js[ne],delete pi[ne],delete Ba[ne]}),za(e,yt)),(K==null?void 0:K.confirmPending)!==!1&&De.forEach(ne=>{a.delete(ne),et.has(ne)&&i.delete(ne)}),Gn)for(const ne of Gn){const me=ne.id;if(!Qe.has(me))continue;const Be=o.get(me),lt=!Be||JSON.stringify(Be)!==JSON.stringify(ne);if(o.set(me,ne),lt){const it=js[me]??0;js[me]=it+1}}nn(()=>{s("messages",()=>ur),s("messageInfoVersion",()=>js),s("pendingParts",()=>pi),s("permissions","byMessage",()=>Ba),!(K!=null&&K.preserveOmitted)&&yt.length>0&&(s("messages",St(ne=>{yt.forEach(me=>{delete ne[me]})})),s("messageInfoVersion",St(ne=>{yt.forEach(me=>{delete ne[me]})})),s("pendingParts",St(ne=>{yt.forEach(me=>{delete ne[me]})})),s("permissions",St(ne=>{const me=new Set(yt);yt.forEach(Be=>{delete ne.byMessage[Be]}),ne.queue=ne.queue.filter(Be=>!Be.messageId||!me.has(Be.messageId)),ne.active=ne.queue[0]??null}))),mi&&s("usage",_,mi),s("sessions",_,ne=>({...ne,messageIds:Ot,updatedAt:Date.now()})),u(_,Ot),S(_),Ot.forEach(ne=>{w(ur[ne])}),v(_)})}function U(_,P,j){var I;const K=(((I=n.sessions[_])==null?void 0:I.messageIds)??[]).filter(Z=>{var xe;return!j.has(Z)||P.has(Z)||((xe=n.messages[Z])==null?void 0:xe.revision)!==j.get(Z)});if(K.length===0){Re(_);return}W(_,K.flatMap(Z=>{const xe=n.messages[Z];return xe?[{id:xe.id,sessionId:xe.sessionId,role:xe.role,status:xe.status,createdAt:xe.createdAt,updatedAt:xe.updatedAt,isEphemeral:xe.isEphemeral,parts:xe.partIds.flatMap(De=>{var Qe;return((Qe=xe.parts[De])==null?void 0:Qe.data)??[]}),bumpRevision:!1}]:[]}),K.flatMap(Z=>o.get(Z)??[]))}function J(_){if(!_)return;a.add(_);const P=n.messages[_];i.set(_,new Set((P==null?void 0:P.partIds)??[]))}function le(_,P){const j=n.messages[_];!j||j.status!=="sending"&&!(P==="error"&&j.status==="sent")||(s("messages",_,St(K=>{K.status=P,K.isEphemeral=P==="error",K.updatedAt=Date.now(),K.revision+=1})),v(j.sessionId))}function z(_){le(_,"sent")}function M(_,P){const j=i.get(_);a.delete(_),P!=null&&P.clearOptimisticParts&&i.delete(_);const K=n.messages[_];if(!K)return;const I=P!=null&&P.clearOptimisticParts&&K.role==="user"?K.partIds.filter(De=>j==null?void 0:j.has(De)):[],Z=K.role==="user"&&(K.status==="sending"||K.status==="error");(K.isEphemeral||I.length>0||Z)&&(s("messages",_,St(De=>{if(De.isEphemeral=!1,Z&&(De.status="sent"),I.length>0){const Qe=new Set(I);De.partIds=De.partIds.filter(et=>!Qe.has(et)),I.forEach(et=>{delete De.parts[et]})}De.updatedAt=Date.now(),De.revision+=1})),v(K.sessionId))}function N(_){a.has(_)&&(a.delete(_),le(_,"error"))}function ce(_){var P;for(const j of Array.from(a))((P=n.messages[j])==null?void 0:P.sessionId)===_&&N(j)}function fe(_){for(const P of Array.from(a)){const j=n.messages[P];(j==null?void 0:j.sessionId)===_&&j.status==="sent"&&a.delete(P)}}function Re(_){const P=n.sessions[_];if(!P)return;const j=P.messageIds??[],K=[],I=[];for(const Z of j)n.messages[Z]&&l(Z)?K.push(Z):I.push(Z);I.length!==0&&(I.forEach(Z=>{o.delete(Z),c(Z),gg(e,_,Z)}),za(e,I),nn(()=>{s("messages",St(Z=>{I.forEach(xe=>{delete Z[xe]})})),s("messageInfoVersion",St(Z=>{I.forEach(xe=>{delete Z[xe]})})),s("pendingParts",St(Z=>{I.forEach(xe=>{delete Z[xe]})})),s("permissions",St(Z=>{const xe=new Set(I);I.forEach(De=>{delete Z.byMessage[De]}),Z.queue=Z.queue.filter(De=>!De.messageId||!xe.has(De.messageId)),Z.active=Z.queue[0]??null})),s("usage",_,Lh()),s("latestTodos",_,void 0),s("sessions",_,Z=>({...Z,messageIds:K,updatedAt:Date.now()})),u(_,K),v(_)}))}function be(_,P){q(_),s("sessions",_,"messageIds",(j=[])=>j.includes(P)?j:[...j,P])}function ye(_,P){if(!P)return null;const j={},K=[],I=new Set;return P.forEach((Z,xe)=>{const De=Db(_,Z,xe),Qe=Z;j[De]={id:De,data:Qe,revision:0},I.has(De)||(I.add(De),K.push(De))}),{map:j,ids:K}}function Ce(_){const P=ye(_.id,_.parts),j=!!(_.bumpRevision||P),K=Date.now();let I;s("messages",_.id,Z=>{const xe=Z?Z.revision+(j?1:0):0,De=Pb(e,_,Z),Qe={id:_.id,sessionId:_.sessionId,role:_.role,status:_.status,createdAt:_.createdAt??(Z==null?void 0:Z.createdAt)??K,updatedAt:_.updatedAt??K,isEphemeral:_.isEphemeral??(Z==null?void 0:Z.isEphemeral)??!1,clientPromptDisplayMetadata:De,revision:xe,partIds:P?P.ids:(Z==null?void 0:Z.partIds)??[],parts:P?P.map:(Z==null?void 0:Z.parts)??{}};return Mb(e,_.sessionId,_.id,De),I=Qe,Qe}),I&&w(I),I&&!(I.isEphemeral&&I.status==="sending")&&a.delete(_.id),be(_.sessionId,_.id),B(_.id),u(_.sessionId),v(_.sessionId)}function je(_){s("pendingParts",_.messageId,(P=[])=>[...P,_])}function O(_){s("pendingParts",P=>{if(!P[_])return P;const j={...P};return delete j[_],j})}function g(_,P,j){if(!_||!P||j.type!=="tool")return;const K=j.callID??j.callId??j.toolCallID??j.toolCallId??j.id??void 0;K&&s("permissions","byMessage",_,St(I=>{var xe,De,Qe,et;if(!I)return;const Z=I[P];for(const[Tt,He]of Object.entries(I))if(!(!He||He.partId||(((xe=He.permission.tool)==null?void 0:xe.callID)??((De=He.permission.tool)==null?void 0:De.callId)??He.permission.callID??He.permission.callId??He.permission.toolCallID??He.permission.toolCallId??((Qe=He.permission.metadata)==null?void 0:Qe.callID)??((et=He.permission.metadata)==null?void 0:et.callId)??void 0)!==K)){(!Z||Z.permission.id===He.permission.id)&&(He.partId=P,I[P]=He,delete I[Tt]);break}}))}function x(_){const P=n.messages[_.messageId];if(!P){je({messageId:_.messageId,part:_.part,receivedAt:Date.now()});return}const j=Db(_.messageId,_.part,P.partIds.length),K=_.part;s("messages",_.messageId,St(I=>{I.partIds.includes(j)||(I.partIds=[...I.partIds,j]);const Z=I.parts[j],xe=Z?Z.revision+1:K.version??0;I.parts[j]={id:j,data:K,revision:xe},I.updatedAt=Date.now(),(_.bumpRevision??!0)&&(I.revision+=1)})),g(_.messageId,j,K),h(K)&&m(P.sessionId,{messageId:_.messageId,partId:j,timestamp:Date.now()}),v(P.sessionId)}function A(_){if(!(_!=null&&_.messageId)||!_.partId||!_.field||typeof _.delta!="string")return;const P=n.messages[_.messageId];if(!P)return;let j=!1;s("messages",_.messageId,St(K=>{const I=K.parts[_.partId];if(!(I!=null&&I.data))return;const Z=I.data,xe=Z==null?void 0:Z[_.field];(typeof xe=="string"||xe===void 0||xe===null)&&(Z[_.field]=`${xe??""}${_.delta}`,j=!0),j&&(I.revision+=1,K.updatedAt=Date.now(),(_.bumpRevision??!0)&&(K.revision+=1))})),j&&(_.bumpSessionRevision??!0)&&v(P.sessionId)}function E(_,P){if(!_)return;c(_);const j=n.messages[_],K=new Set;j!=null&&j.sessionId&&gg(e,j.sessionId,_),j!=null&&j.sessionId?K.add(j.sessionId):Object.values(n.sessions).forEach(I=>{I.messageIds.includes(_)&&K.add(I.id)}),!K.size&&P&&K.add(P),za(e,[_]),nn(()=>{K.forEach(I=>{s("sessions",I,"messageIds",(Z=[])=>Z.filter(xe=>xe!==_))}),s("messages",St(I=>{delete I[_]})),s("messageInfoVersion",St(I=>{delete I[_]})),o.delete(_),s("pendingParts",St(I=>{delete I[_]})),s("permissions","byMessage",St(I=>{delete I[_]})),K.forEach(I=>{var Z;C(I,xe=>Ob(xe,_)),((Z=n.latestTodos[I])==null?void 0:Z.messageId)===_&&S(I),u(I),v(I)})})}function H(_,P,j){if(!_||!P)return;const K=n.messages[_];if(!K){j&&v(j);return}za(e,[_]),nn(()=>{s("messages",_,St(I=>{!I.parts[P]&&!I.partIds.includes(P)||(I.partIds=I.partIds.filter(Z=>Z!==P),delete I.parts[P],I.updatedAt=Date.now(),I.revision+=1)})),s("permissions","byMessage",_,I=>{if(!I||!I[P])return I;const Z={...I};return delete Z[P],Z}),v(K.sessionId)})}function B(_){const P=n.pendingParts[_];if(!P||P.length===0)return;const j=Date.now(),K=P.filter(I=>j-I.receivedAt<=VI);if(K.length===0){O(_);return}K.forEach(I=>x({messageId:_,part:I.part})),O(_)}function oe(_){if(_.oldId===_.newId)return;const P=n.messages[_.oldId];if(!P)return;if(LI(e,P.sessionId,_.oldId,_.newId),a.has(_.oldId)&&P.isEphemeral&&P.status==="sending"){const De=i.get(_.oldId);c(_.oldId),a.add(_.newId),De&&i.set(_.newId,De)}const j={...P,id:_.newId,isEphemeral:!1,updatedAt:Date.now(),partIds:_.clearParts?[]:P.partIds,parts:_.clearParts?{}:P.parts};s("messages",_.newId,j),s("messages",St(De=>{delete De[_.oldId]}));const K=new Set;Object.values(n.sessions).forEach(De=>{const Qe=De.messageIds.indexOf(_.oldId);Qe!==-1&&(s("sessions",De.id,"messageIds",et=>{const Tt=[...et];return Tt[Qe]=_.newId,Tt}),K.add(De.id))}),K.forEach(De=>{u(De),v(De)});const I=o.get(_.oldId);if(I){o.set(_.newId,I),o.delete(_.oldId);const De=n.messageInfoVersion[_.oldId]??0;s("messageInfoVersion",_.newId,De),s("messageInfoVersion",Qe=>{const et={...Qe};return delete et[_.oldId],et})}const Z=n.permissions.byMessage[_.oldId];Z&&(s("permissions","byMessage",_.newId,Z),s("permissions",De=>{const Qe={...De},et={...Qe.byMessage};return delete et[_.oldId],Qe.byMessage=et,Qe}));const xe=n.pendingParts[_.oldId];xe&&s("pendingParts",_.newId,xe),O(_.oldId),w(j)}function Ae(_,P){if(!_)return;o.set(_,P);const j=(n.messageInfoVersion[_]??0)+1;s("messageInfoVersion",_,j),T(P)}function we(_){return n.messageInfoVersion[_],o.get(_)}function he(_){const P=n.permissions.queue.find(j=>j.permission.id===_.permission.id);return P?{..._,permission:Qk(P.permission,_.permission),messageId:_.messageId??P.messageId,partId:_.partId??P.partId,enqueuedAt:Math.min(P.enqueuedAt,_.enqueuedAt)}:_}function Ee(_){var De,Qe,et,Tt;const P=he(_),j=P.messageId??"__global__",K=P.partId??((De=P.permission)==null?void 0:De.id)??"__global__",I=n.permissions.queue.find(He=>He.permission.id===P.permission.id),Z=(Qe=n.permissions.byMessage[j])==null?void 0:Qe[K],xe=(et=n.permissions.queue[0])==null?void 0:et.permission.id;BI({existing:I,existingAtLocationId:Z==null?void 0:Z.permission.id,expectedActiveId:xe,activeId:(Tt=n.permissions.active)==null?void 0:Tt.permission.id,incomingId:P.permission.id,incomingMessageId:P.messageId,incomingPartId:P.partId,incomingEnqueuedAt:P.enqueuedAt,existingValue:I==null?void 0:I.permission,incomingValue:P.permission})||s("permissions",St(He=>{Object.keys(He.byMessage).forEach(Qt=>{const Ot=He.byMessage[Qt];Object.keys(Ot).forEach(Dn=>{Ot[Dn].permission.id===P.permission.id&&delete Ot[Dn]}),Object.keys(Ot).length===0&&delete He.byMessage[Qt]}),He.byMessage[j]=He.byMessage[j]??{},He.byMessage[j][K]=P;const yt=He.queue.findIndex(Qt=>Qt.permission.id===P.permission.id);yt===-1?He.queue.push(P):He.queue[yt]=P,He.queue.sort((Qt,Ot)=>Qt.enqueuedAt-Ot.enqueuedAt),He.active=He.queue[0]??null}))}function Ge(_){s("permissions",St(P=>{var j;P.queue=P.queue.filter(K=>K.permission.id!==_),((j=P.active)==null?void 0:j.permission.id)===_&&(P.active=P.queue[0]??null),Object.keys(P.byMessage).forEach(K=>{const I=P.byMessage[K];Object.keys(I).forEach(Z=>{I[Z].permission.id===_&&delete I[Z]}),Object.keys(I).length===0&&delete P.byMessage[K]})}))}function Xe(_,P){var xe,De;const j=_??"__global__",K=P??"__global__",I=(xe=n.permissions.byMessage[j])==null?void 0:xe[K];if(!I)return null;const Z=((De=n.permissions.active)==null?void 0:De.permission.id)===I.permission.id;return{entry:I,active:Z}}function se(_,P){const j=n.sessions[_];if(!j)return;const K=j.messageIds.findIndex(Z=>Z>=P);if(K===-1)return;const I=j.messageIds.slice(K);I.length!==0&&nn(()=>{I.forEach(Z=>E(Z,_))})}function V(_,P){_&&(q(_),P!=null&&P.messageID&&se(_,P.messageID),s("sessions",_,"revert",P??null))}function Y(_){var P;return((P=n.sessions[_])==null?void 0:P.revert)??null}function Oe(_,P){return`${_}:${P}`}function ve(_,P,j){var Z;const K=Oe(_,P),I={...j,updatedAt:Date.now()};s("scrollState",K,I),(Z=t==null?void 0:t.onScrollSnapshotChanged)==null||Z.call(t,e,_,P,I)}function Ie(_,P,j){const K=Oe(_,P);s("scrollState",K,j)}function Le(_,P){const j=Oe(_,P);return n.scrollState[j]}function ze(_,P){q(_);const j={kind:P.kind,newerCursors:[...P.newerCursors]};P.resumeCursor!==void 0&&(j.resumeCursor=P.resumeCursor),P.olderCursor!==void 0&&(j.olderCursor=P.olderCursor),s("sessions",_,St(K=>{K.messageWindow=j}))}function Ne(_){var P;return(P=n.sessions[_])==null?void 0:P.messageWindow}function Je(_,P){var K;if(!_)return;FI(e,_);const j=Object.values(n.messages).filter(I=>I.sessionId===_).map(I=>I.id);KI.info("Clearing session data",{instanceId:e,sessionId:_,messageCount:j.length}),za(e,j),j.forEach(I=>c(I)),nn(()=>{s("messages",I=>{const Z={...I};return j.forEach(xe=>delete Z[xe]),Z}),s("messageInfoVersion",I=>{const Z={...I};return j.forEach(xe=>delete Z[xe]),Z}),j.forEach(I=>o.delete(I)),s("pendingParts",I=>{const Z={...I};return j.forEach(xe=>{Z[xe]&&delete Z[xe]}),Z}),s("permissions","byMessage",I=>{const Z={...I};return j.forEach(xe=>{Z[xe]&&delete Z[xe]}),Z}),s("usage",I=>{const Z={...I};return delete Z[_],Z}),s("sessionRevisions",I=>{const Z={...I};return delete Z[_],Z}),s("lastAssistantMessageIds",I=>{const Z={...I};return delete Z[_],Z}),P!=null&&P.preserveScroll||s("scrollState",I=>{const Z={...I},xe=`${_}:`;return Object.keys(Z).forEach(De=>{De.startsWith(xe)&&delete Z[De]}),Z}),s("sessions",_,I=>I&&{...I,messageIds:[]}),s("sessions",I=>{const Z={...I};return delete Z[_],Z}),s("sessionOrder",I=>I.filter(Z=>Z!==_))}),S(_),(P==null?void 0:P.notify)!==!1&&((K=t==null?void 0:t.onSessionCleared)==null||K.call(t,e,_))}function ot(){NI(e,Object.keys(n.sessions)),o.clear(),a.clear(),i.clear(),s(gr(Ab(e)))}function gt(){s("scrollState",gr({}))}return{instanceId:e,state:n,setState:s,addOrUpdateSession:re,hydrateMessages:W,reconcileEmptyAuthoritativeSnapshot:Re,reconcileAuthoritativeMessageIds:U,markSendPending:J,acceptSend:z,confirmServerMessage:M,failSend:N,failPendingSends:ce,retirePendingSends:fe,upsertMessage:Ce,applyPartUpdate:x,applyPartDelta:A,removeMessage:E,removeMessagePart:H,bufferPendingPart:je,flushPendingParts:B,replaceMessageId:oe,setMessageInfo:Ae,getMessageInfo:we,upsertPermission:Ee,removePermission:Ge,getPermissionState:Xe,setSessionRevert:V,getSessionRevert:Y,rebuildUsage:D,getSessionUsage:R,setScrollSnapshot:ve,restoreScrollSnapshot:Ie,getScrollSnapshot:Le,setMessageWindow:ze,getMessageWindow:Ne,getSessionRevision:k,getSessionMessageIds:_=>{var P;return((P=n.sessions[_])==null?void 0:P.messageIds)??[]},getLastAssistantMessageId:$,getLastCompactionMessageIndex:f,getMessage:_=>n.messages[_],getLatestTodoSnapshot:b,clearSession:Je,clearScrollSnapshots:gt,clearInstance:ot}}const zI="GLOBAL",wr=new Map;function Cr(e){return e&&e.length>0?e:zI}function Fh(e,t){const n=Cr(e.instanceId),s=Cr(e.sessionId);let r=wr.get(n);if(!r){if(!t)return;r=new Map,wr.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 _x(e,t,n){const s=wr.get(e);if(!s)return;const r=s.get(t);if(!r){s.size===0&&wr.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&&wr.delete(e)}function s7(e,t){const n=Cr(e.instanceId),s=Cr(e.sessionId);if(t===void 0){const o=Fh(e,!1);o==null||o.delete(e.cacheId),_x(n,s,e.scope);return}const r=Fh(e,!0);r==null||r.set(e.cacheId,{version:e.version,value:t})}function r7(e){const t=Fh(e,!1),n=t==null?void 0:t.get(e.cacheId);if(!(!n||n.version!==e.version))return n.value}function o7(e){const t=Cr(e.instanceId),n=Cr(e.sessionId),s=wr.get(t);if(!s)return;const r=s.get(n);r&&(r.delete(e.scope),_x(t,n))}function WI(e,t){const n=Cr(e),s=Cr(t),r=wr.get(n);r&&(r.delete(s),r.size===0&&wr.delete(n))}function jd(e){const t=Cr(e);wr.delete(t)}const hg=Lt("session");class HI{constructor(){this.stores=new Map,this.teardownHandlers=new Set,this.sessionClearHandlers=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??qI(t,{onSessionCleared:(o,a)=>this.notifySessionCleared(o,a),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){for(const s of this.sessionClearHandlers)try{s(t,n)}catch(r){hg.error("Failed to run session clear handler",r)}}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){hg.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(),jd(t),this.notifyInstanceDestroyed(t),this.stores.delete(t),this.scrollSnapshotSeeds.delete(t)}clearAll(){for(const[t,n]of this.stores.entries())n.clearInstance(),jd(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){hg.error("Failed to run message store teardown handler",s)}}}const Bt=new HI;function GI(e){if(e!=null&&e.latestMessageId)return e.entries[e.latestMessageId]}function Ib(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 ta(e,t){var ee,W,U,J,le,z;const n=Fe().get(e);if(!n)return;const s=n.get(t);if(!s)return;const r=Bt.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=GI(o);f==null||f.hasContextUsage;const h=(ee=bl().get(e))==null?void 0:ee.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=(h==null?void 0:h.actualUsageTokens)??0)):!a&&h&&(i=h.inputTokens,c=h.outputTokens,l=h.reasoningTokens,d=h.cost,u=h.actualUsageTokens);const b=gi().get(e)||[],v=s.model,k=v==null?void 0:v.providerId,$=v==null?void 0:v.modelId,C=f!=null&&f.messageId?r.getMessageInfo(f.messageId):void 0,T=(C==null?void 0:C.providerID)||(C==null?void 0:C.providerId)||"",D=(C==null?void 0:C.modelID)||(C==null?void 0:C.modelId)||"",R=Ib(b,k,$)??Ib(b,T,D);let q=hc,re=null;if(R){m=((W=R.limit)==null?void 0:W.context)??0;const M=(U=R.limit)==null?void 0:U.input;typeof M=="number"&&M>0&&(re=M);const N=(J=R.limit)==null?void 0:J.output;typeof N=="number"&&N>0&&(q=Math.min(N,hc)),(((le=R.cost)==null?void 0:le.input)??0)===0&&(((z=R.cost)==null?void 0:z.output)??0)===0&&(S=!0)}if(m===0&&h&&(m=h.contextWindow),q=Math.min(q,hc),h){const M=h.contextWindow,N=h.contextAvailableTokens??null;m!==M?w=null:w=N,a&&S||(S=h.isSubscriptionModel)}re!==null?w=re:m>0?w=m:w=null,Cf(M=>{const N=new Map(M),ce=new Map(M.get(e));return ce.set(t,{cost:d,contextWindow:m,isSubscriptionModel:S,inputTokens:i,outputTokens:c,reasoningTokens:l,actualUsageTokens:u,modelOutputLimit:q,contextAvailableTokens:w}),N.set(e,ce),N}),JV(e,t)}const ZI=(e,t)=>e===t;function JI(e){switch(e){case"sending":case"sent":case"streaming":case"complete":case"error":return e;default:return"complete"}}function Cx(e,t,n,s,r,o=!1,a=!0){if(!t||!Array.isArray(n))return!1;const i=Bt.getOrCreate(e);if(r!==void 0&&!ZI(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:JI(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 Ex(e){return uR(e)}function YI(e){const t=e.metadata||{};return e.partID||e.partId||t.partID||t.partId||void 0}function Tx(e){return fR(e)}function Mx(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 Ax(e,t){if(!t)return;const n=Bt.getOrCreate(e),s=Ex(t);let r=YI(t);if(!r){const o=Tx(t);r=Mx(n,s,o)}n.upsertPermission({permission:t,messageId:s,partId:r,enqueuedAt:Date.now()})}function QI(e,t){const n=Bt.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=Zi(o);if(t&&a&&a!==t)continue;const i=r.messageId??Ex(o),c=Tx(o),l=Mx(n,i,c);r.partId&&i&&n.getPermissionState(i,r.partId)&&(!l||l===r.partId)||l&&n.upsertPermission({...r,messageId:i,partId:l})}}function zu(e,t){if(!t)return;Bt.getOrCreate(e).removePermission(t)}function Lb(e,t,n){if(!t)return;Bt.getOrCreate(e).removeMessage(t,n)}function XI(e,t,n){if(!t)return;Bt.getOrCreate(e).setSessionRevert(t,n??null)}const Nh=200,Dx=32;function Oc(){return{kind:"latest",newerCursors:[]}}function Px(e){return!e||e.kind==="latest"}function Ox(e){const t=sL(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 eL(e){if(!e.olderCursor)return null;const t=e.kind==="latest"?null:e.resumeCursor??null,n=[...e.newerCursors,t],s=Uh(e.newerCursors)||n.length>Dx,r=Uh(n)?n.slice(2):n;return{cursor:e.olderCursor,next:{kind:"history",resumeCursor:e.olderCursor,newerCursors:s?[null,null,...r.slice(-30)]:n}}}function tL(e){if(e.kind!=="history")return null;if(Uh(e.newerCursors)&&e.newerCursors.length===2&&e.resumeCursor)return{next:e,seekNewer:e.resumeCursor};if(e.newerCursors.length===0)return{next:Oc()};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 Fb(e,t){return{...e,olderCursor:t}}function nL(e){return{windowIsLatest:e.kind==="latest",windowCursor:e.resumeCursor,newerCursors:e.newerCursors}}function sL(e){return e!=null&&e.length?e.slice(-Dx):[]}function Uh(e){return e[0]===null&&e[1]===null}function qd(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[rL,Rx]=L(new Map),Bh=new Map;function Yr(e){return rL().get(e)}function oL(e,t){Rx(n=>{const s=new Map(n);return s.delete(e),s})}function Ix(e,t){Rx(n=>{const s=new Map(n),r=s.get(e)??{};return s.set(e,{...r,...t}),s})}function Ip(e){Bh.set(e,(Bh.get(e)??0)+1),oL(e)}function zd(e){return Bh.get(e)??0}function iL(e,t,n){return t==="working"||t==="compacting"?null:e==="interrupted"||n?"interrupted":"pending"}function Lx(e,t){return t==="working"||t==="compacting"?null:e==="pending"?"interrupted":e??null}function i7(e,t){return e==="working"||e==="compacting"||t==="pending"?"working":t==="interrupted"?"interrupted":null}function Ni(e,t,n,s=!1){if(s||t&&!n)return null;if(!n)return e;if(n===t)return n.generationAdmissionToken===void 0?e:{...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 r}const[aL,Fx]=L(new Map),Kh=new Map;let cL=0;async function Nx(e,t,n){const s=++cL;Kh.set(e,s);let r;try{r=await t.command.list(n?{location:wo(n)}:void 0,Nt(n)).then(o=>o.data)}catch{return!1}return Kh.get(e)!==s?!1:(Fx(o=>{const a=new Map(o);return a.set(e,r),a}),!0)}function a7(e){return aL().get(e)??[]}function Lp(e){Kh.delete(e),Fx(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n})}const Nr=(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}}},lL={pipe(){return Nr(this,arguments)}},Wu=function(){function e(){}return e.prototype=lL,e}(),Kt=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)}}}},Lo=e=>e,dL=e=>()=>e,Ux=dL(void 0),uL=Ux;function Pa(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 ll(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 Vh=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},jh=new WeakSet;function Bx(e){return typeof e=="string"}function Kx(e){return typeof e=="number"}function fL(e){return typeof e=="boolean"}function gL(e){return typeof e=="symbol"}function Vx(e){return Bx(e)||Kx(e)||gL(e)}function Fp(e){return typeof e=="function"}function hL(e){return e!==void 0}function mL(e){return e!=null}function jx(e){return!0}function qh(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zh(e){return typeof e=="object"&&e!==null||Fp(e)}const An=Kt(2,(e,t)=>zh(e)&&t in e);function pL(e){return e instanceof Error}const Us="~effect/interfaces/Hash",vn=e=>{switch(typeof e){case"number":return Gu(e);case"bigint":return sn(e.toString(10));case"boolean":return sn(String(e));case"symbol":return sn(String(e));case"string":return sn(e);case"undefined":return sn("undefined");case"function":case"object":{if(e===null)return sn("null");if(e instanceof Date)return Number.isNaN(e.getTime())?sn("Invalid Date"):sn(e.toISOString());if(e instanceof RegExp)return sn(e.toString());{if(jh.has(e))return Wh(e);if(pg.has(e))return pg.get(e);const t=kL(e,()=>yL(e)?e[Us]():typeof e=="function"?Wh(e):e instanceof DataView?Hh(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?Hh(e):e instanceof Map?bL(e):e instanceof Set?SL(e):wL(e));return pg.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`)}},Wh=e=>(mg.has(e)||mg.set(e,Gu(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),mg.get(e)),Er=Kt(2,(e,t)=>e*53^t),Hu=e=>e&3221225471|e>>>1&1073741824,yL=e=>An(e,Us),Gu=e=>{if(e!==e)return sn("NaN");if(e===1/0)return sn("Infinity");if(e===-1/0)return sn("-Infinity");let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Hu(t)},sn=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Hu(t)},vL=(e,t)=>{let n=12289;for(const s of t)n^=Er(vn(s),vn(e[s]));return Hu(n)},wL=e=>vL(e,Vh(e)),Np=(e,t)=>n=>{let s=e;for(const r of n)s^=t(r);return Hu(s)},Hh=Np(6151,vn),bL=Np(sn("Map"),([e,t])=>Er(vn(e),vn(t))),SL=Np(sn("Set"),vn),mg=new WeakMap,pg=new WeakMap,yg=new WeakSet;function kL(e,t){if(yg.has(e))return sn("[Circular]");yg.add(e);const n=t();return yg.delete(e),n}const Bs="~effect/interfaces/Equal";function ws(){return arguments.length===1?e=>Ho(e,arguments[0]):Ho(arguments[0],arguments[1])}function Ho(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"||jh.has(e)||jh.has(t)?!1:_L(e,t,$L)}function xL(e,t,n){const s=vg.has(e),r=wg.has(t);if(s&&r)return!0;if(s||r)return!1;vg.add(e),wg.add(t);const o=n();return vg.delete(e),wg.delete(t),o}const vg=new WeakSet,wg=new WeakSet;function $L(e,t){if(vn(e)!==vn(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=Ub(e),s=Ub(t);if(n!==s)return!1;const r=n&&s;return typeof e=="function"&&!r?!1:xL(e,t,()=>{if(r)return e[Bs](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:CL(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 Nb(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(a.buffer,a.byteOffset,a.byteLength))}return Nb(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:ML(e,t);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:DL(e,t)}return EL(e,t)})}function _L(e,t,n){let s=ql.get(e);if(!s)s=new WeakMap,ql.set(e,s);else if(s.has(t))return s.get(t);const r=n(e,t);s.set(t,r);let o=ql.get(t);return o||(o=new WeakMap,ql.set(t,o)),o.set(e,r),r}const ql=new WeakMap;function CL(e,t){for(let n=0;n<e.length;n++)if(!Ho(e[n],t[n]))return!1;return!0}function Nb(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 EL(e,t){const n=Vh(e),s=Vh(t);if(n.size!==s.size)return!1;for(const r of n)if(!s.has(r)||!Ho(e[r],t[r]))return!1;return!0}function TL(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 ML=TL(Ho,Ho);function AL(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 DL=AL(Ho),Ub=e=>An(e,Bs),nc=e=>(t,n)=>t===n||e(t,n),PL=(e,t)=>e===t,OL=()=>PL,qx=e=>e.length>0;function Ws(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function zx(e,t){for(const n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&Ws(e,n,t[n])}const Zu=Symbol.for("~effect/Redactable"),RL=e=>An(e,Zu);function Gh(e){return RL(e)?Wx(e):e}function Wx(e){var t;return e[Zu](((t=globalThis[mc])==null?void 0:t.context)??IL)}const mc="~effect/Fiber/currentFiber",Bb=new Map,IL={"~effect/Context":{},base:Bb,depth:0,mapUnsafe:Bb,pipe(){return Nr(this,arguments)}};function Rt(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 LL;s.add(l);let u;if(Zu in l)u=c(Wx(l),d);else if(Array.isArray(l))u=!r||l.length<=1?`[${l.map(f=>c(f,d)).join(",")}]`:`[
16
16
  ${o(d+1)}${l.map(f=>c(f,d+1)).join(`,
17
17
  `+o(d+1))}
@@ -31,12 +31,12 @@ ${o(d)}}`;u=a(l,h)}}return s.delete(l),u}return String(l)}return c(e,0)}const LL
31
31
  `)})}const Gr=Lt("actions"),Ql=new Map,Xl=new Map;function vC(e,t,n){const s=`${e}:${t}`,o=(Xl.get(s)??Promise.resolve()).catch(()=>{}).then(n).finally(()=>{Xl.get(s)===o&&Xl.delete(s)});return Xl.set(s,o),o}function ov(e,t,n,s){return vC(e,t,async()=>{const r=(s==null?void 0:s.optimisticGeneration)===!1?void 0:Y1(e,t);try{const o=await n();return r==null||r.complete(),o}catch(o){throw r==null||r.rollback(),o}})}function q7(e,t,n){var r;const s=(r=Ue().get(e))==null?void 0:r.client;return vC(e,t,async()=>{const o=()=>{var l,d;if(!s||((l=Ue().get(e))==null?void 0:l.client)!==s||!((d=Fe().get(e))!=null&&d.has(t)))throw new Error("Instance not ready")};o();const a=pt(e),i={sessionID:t,messageID:n},c={signal:AbortSignal.timeout(15e3)};try{await a.session.revert.stage(i,c)}catch(l){if(!xR(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 wC(e,t,n,s){const r=`${e}:${t}:${n}`,a=(Ql.get(r)??Promise.resolve()).catch(()=>{}).then(s).finally(()=>{Ql.get(r)===a&&Ql.delete(r)});return Ql.set(r,a),a}function Pj(e,t){if(!t.providerId||!t.modelId)return[];const s=(gi().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 Oj(e,t){const n=iT(t);if(!n)return;const s=Pj(e,t);if(s.length!==0)return s.includes(n)?n:void 0}function iv(e,t){const n={providerID:t.providerId,id:t.modelId},s=Oj(e,t);return s&&(n.variant=s),n}function Rj(e,t){const n=`@${t}`,s=e.indexOf(n);return s<0?void 0:{start:s,end:s+n.length,text:n}}const Ij=26,ed="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";let T0=0,Pg=0;function Lj(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+=ed[s[r]%ed.length]}else for(let s=0;s<e;s++){const r=Math.floor(Math.random()*ed.length);t+=ed[r]}return t}function td(e){const t=Date.now();t!==T0&&(T0=t,Pg=0),Pg++;const n=(BigInt(t)<<BigInt(12))+BigInt(Pg),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=Lj(Ij-12);return`${e}_${r}${o}`}async function Fj(e,t,n,s=[],r={}){var T,D,R,q,re,ee,W,U;const o=Ue().get(e);if(!o||!o.client)throw new Error("Instance not ready");const a=Fe().get(e);if(!(a==null?void 0:a.get(t)))throw new Error("Session not found");const c=td("msg"),l=td("prt"),d=ij(n,s),u=(D=(T=r.restoredPayload)==null?void 0:T.metadata)==null?void 0:D.displayText;typeof u=="string"&&((R=r.restoredPayload)!=null&&R.text.startsWith(u))&&(d.promptToSend+=r.restoredPayload.text.slice(u.length));const f=[{id:l,type:"text",text:d.promptToSend,renderCache:void 0}],h=[],m=[],w=J=>{if(!J)return;const le=n.indexOf(J.text);return le<0?void 0:{text:J.text,start:le,end:le+J.text.length}},S=[...((q=r.restoredPayload)==null?void 0:q.files)??[]];if(s.length>0)for(const J of s){const le=J.source;if(le.type==="file"){const z=td("prt"),M=S.findIndex(fe=>(fe.source.type==="uri"?fe.source.uri:`data:${fe.mime};base64,${fe.data}`)===J.url),N=M<0?void 0:S.splice(M,1)[0],ce=w(N==null?void 0:N.mention);h.push({uri:J.url,name:J.filename,...N!=null&&N.description?{description:N.description}:{},...ce?{mention:ce}:{}}),f.push({id:z,type:"file",url:J.url,mime:le.mime,filename:J.filename,synthetic:!0})}else if(le.type==="agent"){const z=Rj(d.promptToSend,le.name)??w((W=(ee=(re=r.restoredPayload)==null?void 0:re.agents)==null?void 0:ee.find(M=>M.name===le.name))==null?void 0:W.mention);m.some(M=>M.name===le.name)||m.push({name:le.name,...z?{mention:z}:{}})}else if(le.type==="text"){const z=J.display,M=le.value,N=typeof z=="string"&&/^pasted #\d+/.test(z),ce=typeof z=="string"&&/^path:/.test(z);if(N||ce||typeof M!="string")continue;const fe=td("prt");d.promptToSend+=`
32
32
 
33
33
  ${M}`,f.push({id:fe,type:"text",text:M,renderCache:void 0})}}const b=Bt.getOrCreate(e),v=Date.now();yj(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.markSendPending(c)),Yt(e,t,()=>{});const $={id:c,text:d.promptToSend,...h.length>0?{files:h}:{},...m.length>0?{agents:m}:{},...(U=r.restoredPayload)!=null&&U.skills?{skills:r.restoredPayload.skills.flatMap(J=>{const le=w(J.mention);return J.mention&&!le?[]:[{id:J.id,...le?{mention:le}:{}}]})}:{},...r.restoredPayload?{metadata:{...r.restoredPayload.metadata,displayText:n}}:{},...r.delivery?{delivery:r.delivery}:{},...r.delivery==="queue"?{resume:!1}:{}};Gr.info("sendMessage",{instanceId:e,sessionId:t,requestBody:$});let C=c;try{Gr.info("session.prompt",{instanceId:e,sessionId:t,requestBody:$}),await ov(e,t,async()=>{var N;const J=Ue().get(e),le=(N=Fe().get(e))==null?void 0:N.get(t);if(!(J!=null&&J.client))throw new Error("Instance not ready");if(!le)throw new Error("Session not found");const z=pt(e);await rv(z,e,t),r.delivery!=="queue"&&(le.agent&&await z.session.switchAgent({sessionID:t,agent:le.agent}),le.model.providerId&&le.model.modelId&&await z.session.switchModel({sessionID:t,model:iv(e,le.model)}));const M=await z.session.prompt({sessionID:t,...$});C=(M==null?void 0:M.id)||c,k&&C!==c&&b.replaceMessageId({oldId:c,newId:C}),k&&b.acceptSend(C)})}catch(J){throw k&&b.failSend(c),Gr.error("Failed to send prompt",J),J}return C}async function Nj(e,t,n,s){var a;const r=Ue().get(e);if(!r||!r.client)throw new Error("Instance not ready");if(!((a=Fe().get(e))==null?void 0:a.get(t)))throw new Error("Session not found");await ov(e,t,async()=>{var c,l;if(!((c=Ue().get(e))!=null&&c.client))throw new Error("Instance not ready");if(!((l=Fe().get(e))!=null&&l.has(t)))throw new Error("Session not found");const i=pt(e);await rv(i,e,t),await i.session.command({sessionID:t,name:n,text:s,delivery:"steer"})},{optimisticGeneration:!1})}async function Uj(e,t,n){var o;const s=Ue().get(e);if(!s||!s.client)throw new Error("Instance not ready");if(!((o=Fe().get(e))==null?void 0:o.get(t)))throw new Error("Session not found");await ov(e,t,async()=>{var i,c;if(!((i=Ue().get(e))!=null&&i.client))throw new Error("Instance not ready");if(!((c=Fe().get(e))!=null&&c.has(t)))throw new Error("Session not found");const a=pt(e);await rv(a,e,t),await a.session.shell({sessionID:t,command:n})})}async function Bj(e,t){const n=Ue().get(e);if(!n||!n.client)throw new Error("Instance not ready");const s=pt(e);Gr.info("abortSession",{instanceId:e,sessionId:t});try{const o=[...Yy(e,t).filter(a=>Pf(e,a.id)).map(a=>a.id),t];Gr.info("session.interrupt",{instanceId:e,sessionIds:o}),await Promise.all(o.map(a=>s.session.interrupt({sessionID:a}))),Gr.info("abortSession complete",{instanceId:e,sessionId:t})}catch(r){throw Gr.error("Failed to abort session",r),r}}async function Kj(e,t,n){const s=Fe().get(e),r=s==null?void 0:s.get(t);if(!r)throw new Error("Session not found");const o=await ju(e,n),a=ea(e,o),i=r.agent,c=r.model;Yt(e,t,l=>{l.agent=n,a&&(l.model=o)});try{Pf(e,t)||(await pt(e).session.switchAgent({sessionID:t,agent:n}),a&&await pt(e).session.switchModel({sessionID:t,model:iv(e,o)}))}catch(l){throw Yt(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 Vm(e,n,o),a&&ta(e,t)}async function Vj(e,t,n){const s=Fe().get(e),r=s==null?void 0:s.get(t);if(!r)throw new Error("Session not found");if(!ea(e,n)){Gr.warn("Invalid model selection",n);return}Yt(e,t,a=>{a.model=n});const o=iv(e,n);try{Pf(e,t)||await pt(e).session.switchModel({sessionID:t,model:o})}catch(a){throw Yt(e,t,i=>{if(i.model.providerId!==n.providerId||i.model.modelId!==n.modelId)return!1;i.model=r.model}),a}r.agent&&await Vm(e,r.agent,n),oT(n),ta(e,t)}async function jj(e,t,n){var i;const s=Ue().get(e);if(!s||!s.client)throw new Error("Instance not ready");const r=pt(e);if(!((i=Fe().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}),Yt(e,t,c=>{c.title=a;const l={...c.time??{}};l.updated=Date.now(),c.time=l})}function bC(e,t,n){const{message:s,info:r}=qu(t,n),o=Bt.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 Og(e){if((e==null?void 0:e.type)==="tool")return Cm({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 Cm(a)}async function SC(e,t,n,s){const r=Bt.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:Og((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(ke("session.pruning.not_deletable"));const a=r.partIds.map(i=>{var c;return Og((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(ke("session.pruning.conflict"));return wC(e,t,n,async()=>{const c=await pt(e).session.message.get({sessionID:t,messageID:n});if(c.type!=="assistant"||!c.time.completed)throw new Error(ke("session.pruning.not_deletable"));const l=qu(t,c).message.parts.map(Og),d=new Set(o.map(u=>{const f=l.flatMap((h,m)=>h===u.identity?[m]:[]);return f.length===1?f[0]:-1}));if(d.has(-1))throw new Error(ke("session.pruning.conflict"));await hC(e,t,c,[...d],u=>bC(e,t,u))})}async function z7(e,t,n,s){await SC(e,t,n,[s])}async function qj(e,t,n,s){if(s){await SC(e,t,n,s);return}await wC(e,t,n,async()=>{const o=await pt(e).session.message.get({sessionID:t,messageID:n});if(o.type!=="assistant"||!o.time.completed)throw new Error(ke("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 hC(e,t,o,i,c=>bC(e,t,c))})}async function W7(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 qj(e,t,r,o)}async function zj(e,t){await pt(e).session.background({sessionID:t})}const yn=Lt("sse"),nd=new Map,gu=new Map;let sd=null;const Rg=new Map;function va(e,t){const n=`${e}\0${t}`,s=(gu.get(n)??0)+1;return gu.set(n,s),s}function Wj(e,t,n){return gu.get(`${e}\0${t}`)===n}function kC(e,t){const n=Bt.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)vj(e,r.parts[a].data,o)}function Hj(e,t){var s,r,o,a,i,c,l,d,u,f,h,m;if(lj(e,t))return;switch(t.type){case"form.created":case"form.replied":case"form.cancelled":return;case"session.renamed":(s=Fe().get(e))!=null&&s.has(t.data.sessionID)||oc(e,t.data.sessionID,(r=t.location)==null?void 0:r.directory),Yt(e,t.data.sessionID,w=>{w.title=t.data.title});return;case"session.agent.selected":(o=Fe().get(e))!=null&&o.has(t.data.sessionID)||oc(e,t.data.sessionID,(a=t.location)==null?void 0:a.directory),Yt(e,t.data.sessionID,w=>{w.agent=t.data.agent});return;case"session.model.selected":(i=Fe().get(e))!=null&&i.has(t.data.sessionID)||oc(e,t.data.sessionID,(c=t.location)==null?void 0:c.directory),Yt(e,t.data.sessionID,w=>{w.model={providerId:t.data.model.providerID,modelId:t.data.model.id}});return;case"session.usage.updated":Yt(e,t.data.sessionID,w=>{w.cost=t.data.cost,w.tokens=t.data.tokens}),ta(e,t.data.sessionID);return;case"session.moved":Zj(e,t.data);return;case"session.forked":oc(e,t.data.sessionID,(l=t.location)==null?void 0:l.directory);return;case"session.compaction.started":va(e,t.data.sessionID),Xo(e,t.data.sessionID,"compacting",(d=t.location)==null?void 0:d.directory);return;case"session.compaction.failed":pd(e,t.data.sessionID,{failed:!0,directory:(u=t.location)==null?void 0:u.directory});return;case"session.execution.interrupted":pd(e,t.data.sessionID,{failed:!0,interrupted:!0,refreshMessages:!0,directory:(f=t.location)==null?void 0:f.directory});return;case"session.execution.succeeded":pd(e,t.data.sessionID,{failed:!1,directory:(h=t.location)==null?void 0:h.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."))&&(va(e,n),Xo(e,n,"working",(m=t.location)==null?void 0:m.directory))}async function pd(e,t,n){var o;const s=va(e,t);let r=null;try{r=await pt(e).session.active()}catch(a){yn.warn("Failed to reconcile terminal session state",{instanceId:e,sessionId:t,error:a})}if(Wj(e,t,s)){if(r&&Object.prototype.hasOwnProperty.call(r,t)){Yt(e,t,i=>{i.generationRecovery=null}),((o=Fe().get(e))==null?void 0:o.get(t))?pa(e,t,"working",{force:!0}):Xo(e,t,"working",n.directory);return}n.interrupted&&Yt(e,t,a=>{a.generationRecovery="interrupted"}),Gj(e,t,n.failed,n.directory),av(e,t,n.refreshMessages)}}function av(e,t,n=!1){const s=Bt.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)&&sr(e,t,{force:!0}).catch(o=>{yn.warn("Failed to refresh settled session messages",{instanceId:e,sessionId:t,error:o})})}function Gj(e,t,n,s){var o;((o=Fe().get(e))==null?void 0:o.get(t))?pa(e,t,"idle",{force:!0}):Xo(e,t,"idle"),n&&Bt.getOrCreate(e).failPendingSends(t),kC(e,t)}function Zj(e,t){const{sessionID:n,location:s}=t,r=Os(s.directory),o=Array.from(Ue().values()).flatMap(c=>[c.folder,...lo(c.id).flatMap(d=>[d.directory,d.serviceDirectory])].some(d=>Os(d)===r)?[c.id]:[]),a=o.includes(e);a&&(Yt(e,n,c=>{c.location=s,c.projectID=t.projectID,c.subpath=t.subpath}),jn().get(e)===n&&fa(e).catch(c=>{yn.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=Rg.get(c);l&&clearTimeout(l),Rg.set(c,setTimeout(()=>{Rg.delete(c),ri(c).catch(d=>{yn.warn("Failed to refresh moved-session worktrees",{instanceId:c,error:d})}).then(()=>fi(c,{reset:!0})).then(()=>jn().get(c)?fa(c):void 0).catch(d=>{yn.warn("Failed to reconcile moved sessions",{instanceId:c,error:d})})},100))}}function Jj(e){if(typeof document>"u")return!1;const t=lS();return!t.osNotificationsEnabled||!t.osNotificationsAllowWhenVisible&&document.visibilityState==="visible"?!1:e==="needsInput"?!!t.notifyOnNeedsInput:e==="idle"?!!t.notifyOnIdle:!1}function Yj(e,t){var s;const n=(s=Fe().get(e))==null?void 0:s.get(t);return n?n.parentId!==null&&n.parentId!==void 0:null}function cv(e,t,n){if(!Jj(e))return!1;if(!n)return!0;const s=Yj(t,n);return!(s===null||s)}function Of(e){var n;const t=((n=Ue().get(e))==null?void 0:n.folder)??e;return t.split(/[\\/]/).filter(Boolean).pop()??t}function lv(e,t){var r,o;if(!t)return"";const n=(r=Fe().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 dv(e){FO(e).catch(t=>{yn.warn("Failed to send OS notification",t)})}queueMicrotask(()=>{lE((e,t)=>{cv("needsInput",e,t.sessionID)&&dv({title:Of(e),body:ke("settings.notifications.events.needsInput")})})});const Qj=new Set(["info","success","warning","error"]);async function oc(e,t,n){const s=Ue().get(e);if(!(s!=null&&s.client))return null;const r=pt(e);try{const o=await r.session.get({sessionID:t}),a=NR(o,e);let i,c=!1;Cn(d=>{const u=new Map(d),f=new Map(d.get(e)),h=f.get(t),m=(h==null?void 0:h.status)==="compacting",w={...a,agent:(h==null?void 0:h.agent)??a.agent,model:(h==null?void 0:h.model)??a.model,status:m?"compacting":a.status,retry:m?null:a.retry,idleSince:_p(h==null?void 0:h.status,m?"compacting":a.status,h==null?void 0:h.idleSince),pendingPermission:(h==null?void 0:h.pendingPermission)??a.pendingPermission,pendingForm:(h==null?void 0:h.pendingForm)??!1,runtimeStatusKnown:m||(h==null?void 0:h.runtimeStatusKnown)||!1},S=Ni(w,h,h,Fs(e).has(t));return S?(f.set(t,S),u.set(e,f),i=f,S.parentId&&S.status==="working"&&((h==null?void 0:h.status)??"idle")!=="working"&&(c=!0),u):d}),mo(e,i),rr(e);const l=i==null?void 0:i.get(t);return l&&!l.parentId&&kl(e,t),c&&Df(e,t),a}catch(o){return yn.error("Failed to fetch session info",o),null}}function Xo(e,t,n,s,r){var d;if((d=Fe().get(e))==null?void 0:d.get(t)){pa(e,t,n,{retry:r});return}const a=`${e}:${t}`,i=nd.get(a);if(i){i.status=n,i.retry=r;return}const c={status:n,retry:r},l=(async()=>{await oc(e,t)&&pa(e,t,c.status,{retry:c.retry})})();nd.set(a,c),l.finally(()=>{nd.get(a)===c&&nd.delete(a)})}function Xj(e,t){var o;if(t.type!=="session.created"){const a=t.type==="session.revert.staged"?t.data.revert:null;if(XI(e,t.data.sessionID,a),Yt(e,t.data.sessionID,i=>{i.revert=a??void 0}),t.type==="session.revert.cleared"){const i=t.data.sessionID;Ls(e,i),jn().get(e)===i&&sr(e,i,{force:!0}).catch(c=>{yn.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(Fs(e).has(n.id))return;const r=(Fe().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;Cn(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}),mo(e,c)}else{const a={id:n.id,instanceId:e,title:n.title||ke("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=Ue().get(e))==null?void 0:o.folder)??""},time:n.time?{...n.time}:{created:Date.now(),updated:Date.now()}};let i;Cn(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}),mo(e,i),a.parentId||kl(e,a.id),yn.info(`[SSE] New session created: ${n.id}`,a)}rr(e)}function eq(e,t){var s;const n=(s=t.data)==null?void 0:s.sessionID;n&&(yn.info(`[SSE] Session deleted: ${n}`),gu.delete(`${e}\0${n}`),vf(e,n))}function tq(e,t){var s;const n=t.data.sessionID;if(n){if(va(e,n),cv("idle",e,n)){const r=Of(e),o=lv(e,n),a=o?`Session "${o}" is idle`:"Session is idle";dv({title:r,body:a})}Xo(e,n,"idle",(s=t.location)==null?void 0:s.directory),av(e,n),kC(e,n),yn.info(`[SSE] Session idle: ${n}`)}}function nq(e,t){var a;const n=t.data.sessionID;if(!n)return;va(e,n);const s=t.data.status,r=LR(s),o=FR(s);if(Xo(e,n,r,(a=t.location)==null?void 0:a.directory,o),r==="idle"&&av(e,n),o){const i=Math.max(0,Math.round((o.next-Date.now())/1e3)),c=i>0?ke("sessionList.status.retryingIn",{seconds:String(i)}):ke("sessionList.status.retrying"),l=lv(e,n);sd==null||sd.dismiss(),sd=Fn({title:l||Of(e),message:ke("sessionList.status.retryToast",{countdown:c,message:o.message,attempt:String(o.attempt)}),variant:"error",duration:7e3})}yn.info(`[SSE] Session status updated: ${n}`,{status:r})}function sq(e,t){var d,u,f,h;const n=t.data.sessionID;if(!n)return;yn.info(`[SSE] Session compacted: ${n}`),va(e,n),((d=Fe().get(e))==null?void 0:d.get(n))?pa(e,n,"working",{force:!0}):Xo(e,n,"working",(u=t.location)==null?void 0:u.directory);const r=Fe().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=((h=Ue().get(e))==null?void 0:h.folder)??e,c=i.split(/[\\/]/).filter(Boolean).pop()??i,l=a?`"${a}"`:n;Fn({title:c,message:ke("sessionEvents.sessionCompactedToast",{label:l}),variant:"info",duration:1e4})}function rq(e,t){var o;const n=t.data.error,s=t.data.sessionID;s&&pd(e,s,{failed:!0,directory:(o=t.location)==null?void 0:o.directory}),yn.error("[SSE] Session error:",n);let r=ke("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)),Cs(ke("sessionEvents.sessionError.message",{message:r}),{title:ke("sessionEvents.sessionError.title"),variant:"error"})}function oq(e,t){const n=t.data;if(!n||typeof n.message!="string"||typeof n.variant!="string"||!n.message.trim())return;const s=Qj.has(n.variant)?n.variant:"info";Fn({title:typeof n.title=="string"?n.title:void 0,message:n.message,variant:s,duration:typeof n.duration=="number"?n.duration:void 0})}function iq(e,t){const n=t.data;if(!n)return;const s=dR(n);if(!s)return;if(If(e,s)){yn.info(`[SSE] Ignoring stale permission request after local reply: ${s}`);return}yn.info(`[SSE] Permission request: ${s} (${Xk(n)})`);const r=Zi(n);if(cv("needsInput",e,r)){const o=Of(e),a=lv(e,r),i=a?`Session "${a}" needs permission`:"Session needs permission";dv({title:o,body:i})}}function aq(e,t){const n=hR(t.data);n&&(yn.info(`[SSE] Permission replied: ${n}`),Rf(e,n))}ln.onNativeSessionEvent=Hj;ln.onSessionUpdate=Xj;ln.onSessionCompacted=sq;ln.onSessionDeleted=eq;ln.onSessionError=rq;ln.onSessionIdle=tq;ln.onSessionStatus=nq;ln.onTuiToast=oq;ln.onPermissionUpdated=iq;ln.onPermissionReplied=aq;ln.onWorktreeReady=kI;ln.onWorktreeUpdated=async e=>{await ri(e),await fi(e,{reset:!0})};const cq=Object.freeze(Object.defineProperty({__proto__:null,abortSession:Bj,activeParentSessionId:By,activeSessionId:jn,agents:Ky,backgroundSession:zj,beginSessionGenerationAdmission:Y1,cancelSessionGenerationAdmissions:Sf,clearActiveParentSession:X1,clearActiveSession:eC,clearInstanceDeletedSessionAuthority:W1,clearInstanceDraftPromptValues:G1,clearInstanceDraftPrompts:Z1,clearInstanceSessionExpansionState:aC,clearInstanceSessionSelection:tC,clearSessionCatalogState:pf,clearSessionDraftPrompt:H1,clearSessionListRequestState:vl,clearSessionSearch:B1,createSession:w1,deleteSession:yf,ensureSessionAncestorsExpanded:Df,executeCustomCommand:Nj,expandedSessions:jy,fetchAgents:wf,fetchProviders:ha,fetchSessions:fi,forkSession:b1,getActiveCatalogLocation:$n,getActiveSession:nC,getAuthoritativeDraftSessionIdsForInstance:DV,getAuthoritativeSessionExpansionIdsForInstance:z1,getAuthoritativelyDeletedSessionIdsForInstance:Fs,getChildSessions:Jy,getDefaultModel:ju,getDescendantSessions:Yy,getMessageNextCursor:E1,getSessionDraftPrompt:V1,getSessionDraftPromptsForInstance:AV,getSessionFamily:rC,getSessionHasMore:km,getSessionInfo:GV,getSessionListError:HV,getSessionMessagesLoadError:cC,getSessionRoot:ya,getSessionSearchQuery:wV,getSessionSearchSessions:BV,getSessionThreads:oC,getSessions:sC,getThreadTotals:ZV,getVisibleSessionIds:qV,hasAuthoritativeSessionSelection:Hy,hasMoreMessages:C1,hydrateActiveSessionSelection:NV,hydrateRestoredSessionChain:Iy,hydrateSessionDraftPrompt:TV,hydrateSessionExpansion:KV,hydrateSessionGenerationRecovery:FV,hydrateSessionIdleMarkers:LV,isLatestMessageWindow:T1,isSessionBusy:Pf,isSessionExpanded:iC,isSessionMessagesLoading:WV,isSessionSearchLoading:bV,loadAllSessions:y1,loadLatestMessageWindow:x1,loadMessageAnchor:_1,loadMessages:sr,loadMoreMessages:S1,loadMoreSessions:Ly,loadNewerMessageWindow:k1,loadOldestMessageWindow:$1,loading:xf,markSessionIdleSeen:IV,onSessionDraftHydrated:MV,providers:gi,refreshSessionCatalog:fa,renameSession:jj,resetSessionPagination:U1,runShellCommand:Uj,searchSessions:v1,sendMessage:Fj,sessionInfoByInstance:bl,sessions:Fe,setActiveParentSession:Q1,setActiveSession:Zy,setActiveSessionFromList:zV,setSessionDraftPrompt:EV,setSessionExpanded:Qy,setSessionStatus:pa,toggleSessionExpanded:VV,updateSessionAgent:Kj,updateSessionModel:Vj},Symbol.toStringTag,{value:"Module"}));function wa(e){const n=/^(?:[A-Za-z]:[/\\]|[/\\]{2})/.test(e)?e.replace(/\\/g,"/").toLowerCase():e;return n==="/"||/^[a-z]:\/$/.test(n)?n:n.replace(/\/+$/,"")}function lq(e,t,n){return[...e].filter(s=>!t.has(s)&&!n(s))}function H7(e,t){const n=new Map;for(const o of t){if(o.status==="stopped"||o.status==="error")continue;const a=wa(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=wa(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 G7(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 Z7(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 J7(e,t){return(Number.isInteger(t)&&t>=0?e[t]:null)||e.find(s=>!!s)||null}function Y7(e,t,n){return!!(e&&t&&n)}function dq(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","metadata"];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 uq{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[Q7,fq]=L(!1),[X7,eH]=L(null),[tH,nH]=L(!1),[sH,rH]=L(!1),[oH,iH]=L([]),[aH,cH]=L(new Map),ba=new Map;function gq(e,t,n){const s=ba.get(e);if(s){for(const[r,o]of s)!t.has(r)&&n>=o&&s.delete(r);s.size===0&&ba.delete(e)}}function Rf(e,t,n=Date.now()){if(!t)return;let s=ba.get(e);s||(s=new Map,ba.set(e,s)),s.set(t,n)}function If(e,t){const n=ba.get(e);return n?n.has(t):!1}function hq(e){ba.delete(e)}const Sa=new Map;function uv(e,t,n=Date.now()){const s=Sa.get(e)??new Map;s.set(t,n),Sa.set(e,s)}function xC(e,t){var n;return((n=Sa.get(e))==null?void 0:n.has(t))??!1}function mq(e,t,n){const s=Sa.get(e);if(s){for(const[r,o]of s)!t.has(r)&&n>=o&&s.delete(r);s.size||Sa.delete(e)}}function pq(e){Sa.delete(e)}let $C=(e,t)=>t;function yq(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 vq(e){$C=e}function _C(e,t){return`${e}:${$C(e,t)}`}const[wq,CC]=L(new Map);function EC(e,t){return wq().get(_C(e,t))??!1}function zc(e,t,n){CC(s=>{const r=_C(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 bq(e,t){const n=!EC(e,t);return zc(e,t,n),n}function TC(e){CC(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 Sq(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=kq(o,n);if(a)return a;o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"&&(r=o.error)}catch{}return s&&(r===ah||r.startsWith(`${ah}:`))?s:r}function kq(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(`
34
- `)}function xq(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[lH,MC]=L(null),M0=new Map;function $q(e){MC(e)}function dH(){MC(null)}function _q(e){const t=e.id,n=e.error,s=Sq(n,ke("app.launchError.fallbackMessage"),ke("app.launchError.invalidConfig"),ke("opencodeBinarySelector.validation.v2Required")),r=M0.get(t);if(r&&r===s)return;M0.set(t,s);const o=(e.binaryLabel||e.binaryId||"opencode2").trim()||"opencode2",a=xq(s);$q({source:"workspace",instanceId:t,message:s,binaryPath:o,missingBinary:a})}const Em=Lt("session"),Za=new Map,Ja=new Map;function Cq(e){return Es(e)}function AC(e,t){var s;if(!e)return!1;const n=(s=e.mcpStatus)==null?void 0:s.location;return!!(n&&Es(n)===Es(t))}function Eq(e,t){return!e||e.project===void 0||e.mcpStatus===void 0||e.plugins===void 0?!1:!t||AC(e,t)}function DC(e,t){const n=e.client;if(!n)return Em.warn("[metadata] Skipping fetch; client missing",{instanceId:e.id}),Promise.resolve();const s=(t==null?void 0:t.location)??{directory:e.folder},r=Cq(s),o=Yr(e.id)??e.metadata;if(!(t!=null&&t.force)&&Eq(o,s))return Promise.resolve();const a=zd(e.id),i=Za.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=wo(s),[u,f,h,m]=await Promise.allSettled([PC(e,t),n.project.list(),n.mcp.list({location:d},Nt(s)),n.plugin.list({location:d},Nt(s))]),w=(l=Yr(e.id))==null?void 0:l.project,S=w&&f.status==="fulfilled"?f.value.find($=>$.id===w.id):void 0,b=m.status==="fulfilled"?m.value.data.flatMap($=>{var T;return(((T=$.state)==null?void 0:T.status)??$.status)==="active"&&typeof $.id=="string"&&!$.id.startsWith("opencode.")?[$.id]:[]}):void 0,v=Yr(e.id)??o,k={...v??{}};if(v&&!AC(v,s)&&(k.mcpStatus=void 0,k.plugins=void 0),u.status==="fulfilled"&&w&&(S!=null&&S.vcs)&&(k.project={...w,vcs:S.vcs}),h.status==="fulfilled"&&(k.mcpStatus=h.value),m.status==="fulfilled"&&(k.plugins=b??[]),!(k!=null&&k.version)&&e.binaryVersion&&(k.version=e.binaryVersion),Za.get(e.id)!==c||zd(e.id)!==a)return;Ix(e.id,k)}catch(d){Em.error("Failed to load instance metadata",d)}finally{Za.get(e.id)===c&&Za.delete(e.id)}})(),Za.set(e.id,c),c.promise}function PC(e,t){const n=e.client;if(!n)return Promise.resolve();const s=Yr(e.id)??e.metadata;if(!(t!=null&&t.force)&&s&&"project"in s)return Promise.resolve();const r=zd(e.id),o=Ja.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=>{Ja.get(e.id)!==a||zd(e.id)!==r||Ix(e.id,{project:i.project,...!(s!=null&&s.version)&&e.binaryVersion?{version:e.binaryVersion}:{}})}).catch(i=>Em.warn("Failed to load project metadata",{instanceId:e.id,error:i})).finally(()=>{Ja.get(e.id)===a&&Ja.delete(e.id)}),Ja.set(e.id,a),a.promise}const[Tq,fv]=L(new Map);function Br(e){return Tq().get(e)??[]}function Mq(e,t){fv(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 Aq(e,t){fv(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 Dq(e,t){fv(n=>{const s=new Map(n);return t.length?s.set(e,[...t]):s.delete(e),s})}function Pq(e){Dq(e,[])}function OC(e){var t;if(!(e.sessionID!=="global"||!e.location))return{headers:{"x-opencode-directory":encodeURIComponent(e.location.directory),...(t=Nt(e.location))==null?void 0:t.headers}}}const[Oq,Rq]=L(new Map);function Iq(e){Rq(t=>{const n=new Map(t);return n.set(e,(n.get(e)??0)+1),n})}function uH(e){return Oq().get(e)??0}function fH(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[gH,RC]=L(new Set),Tm=new Set;function hH(e){RC(t=>t.has(e)?t:new Set(t).add(e))}function Lq(e){RC(t=>{if(!t.has(e))return t;const n=new Set(t);return n.delete(e),n})}function mH(e){return Tm.add(e),()=>Tm.delete(e)}function Fq(e){for(const t of Tm)t(e)}async function Nq(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 Mm=new Set;function pH(e){return Mm.add(e),()=>Mm.delete(e)}function Am(e){for(const t of Mm)t(e)}class Uq extends Error{constructor(t){super(t),this.name="RestoreTimeoutError"}}function Bi(e){if(e.reason instanceof Error)return e.reason;const t=new Error("Restore operation was aborted");return t.name="AbortError",t}function Bq(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=Bi(t.signal);r.abort(u),a(()=>s(u))},c=t.timeoutMs===void 0?void 0:setTimeout(()=>{const u=new Uq(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 Kq=[250,1e3,2e3];class Vq{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??Kq;let o=0;try{await jm(()=>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 jq{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 qq(e){try{await e}catch{}}function zq(e){return jm(()=>ft.cancelWorkspaceCreation(e),{maxAttempts:4,initialDelayMs:250,maxDelayMs:2e3,backoffMultiplier:4})}const A0=e=>e==="error"||e==="stopped"?3:e==="ready"?2:1;function D0(e,t){const n=A0(t.status)-A0(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 Wq{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:wa(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?D0(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=wa(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?D0(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 Hq{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 It=Lt("api");vq((e,t)=>{const n=Fe().get(e);return n?yq(t,s=>n.get(s)):t});fs.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"||(It.info(`[SSE] Yolo state changed: ${t}:${n} -> ${s}`),zc(t,n,s))});fs.on("yolo.autoAccepted",e=>{if(e.type!=="yolo.autoAccepted")return;const{instanceId:t,permissionId:n}=e;typeof t!="string"||typeof n!="string"||(Rf(t,n),Cl(t,n),zu(t,n))});const[Ue,gv]=L(new Map),[bs,IC]=L(null),[LC,Lf]=L(new Map),[Gq,hv]=L(new Map),Zq=250,No=new Map;function FC(e,t){return`${e}\0${t}`}function Jq(e,t,n){const s=FC(e,t),r=No.get(s);if(r){r.project=n;return}const o={project:n,timeout:setTimeout(()=>{No.delete(s),o.project()},Zq)};No.set(s,o)}function Yq(e,t){const n=FC(e,t),s=No.get(n);s&&(clearTimeout(s.timeout),No.delete(n))}function mv(e){const t=`${e}\0`;for(const[n,s]of No)n.startsWith(t)&&(clearTimeout(s.timeout),No.delete(n))}const[NC,pv]=L(new Map),[Qq,UC]=L(new Map),Ff=new Map,Nf=new Map;function Ki(e){if(e){if(typeof e=="string")return Es({directory:wa(e)});if(e.directory)return Es({...e,directory:wa(e.directory)})}}function BC(e,t,n,s){const r=Ki(s);if(!r)return;const o=e.get(t)??new Map;o.set(n,r),e.set(t,o)}function KC(e,t,n){const s=e.get(t);s&&(s.delete(n),s.size||e.delete(t))}class VC{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 Ln=new VC,no=new VC,[Xq,e6]=L(new Map);function yv(){const e=Array.from(Ue().values()).some(t=>t.status==="ready");fq(e)}const[vv,wv]=L(null),t6=1e3,rd=new Map,od=new Map,bv=new Map,Sv=new Map,jC=new Map,yd=new Map,ka=new Map,po=new Map,Wc=new Map,qs=new Map,ic=new Map,ac=new Map,kv=new Error("Pending request sync was superseded");let n6=0;async function xv(e,t,n=!0){const s=new AbortController,r=ac.get(e)??new Set;r.add(s),ac.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?$p.run(s.signal,o):o())}finally{r.delete(s),!r.size&&ac.get(e)===r&&ac.delete(e)}}function hu(e){for(const t of ac.get(e)??[])t.abort()}async function qC(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 Ts(e,t){e.set(t,(e.get(t)??0)+1)}function Hc(e){Ts(yd,e),Ts(ka,e),Ts(po,e)}const mr=new Hq,rn=new Vq({discardWorkspace:e=>e.requestId?ft.cancelWorkspaceCreation(e.requestId):Promise.reject(new Error(`Restore workspace ${e.id} has no creation request`)),restoreWorkspace:e=>{mr.markMutation(e.id),Vi(e)},onPermanentFailure:(e,t)=>{It.error("Failed to cancel restore workspace ownership; restored it to the UI",{workspaceId:e.id,error:t})}});let P0=0;const Wr=new Wq,s6=new jq(async e=>{await qq(bv.get(e));const t=Ue().get(e);if(!(t!=null&&t.client)||t.status!=="ready")return;let n;try{await fi(e,{reset:!0})}catch(o){n=o}if(await Promise.all([ri(e),_l(e),$v(e),WC(e)]),n)throw n;const s=$f().get(e)??new Set;for(const o of s)Ls(e,o);const r=jn().get(e);r&&s.has(r)&&await sr(e,r,{force:!0}),rr(e)},(e,t)=>{It.warn("Failed to resync sessions after instance connection",{instanceId:e,error:t})}),zC=new uq;function r6(e){s6.request(e)}async function WC(e){const t=Ue().get(e);if(!(t!=null&&t.client)||t.status!=="ready")return;const n=$f().get(e)??new Set;await Promise.all(Array.from(n,async s=>{var o,a;const r=((a=(o=Fe().get(e))==null?void 0:o.get(s))==null?void 0:a.location.directory)??t.folder;try{await CK(e,s,r)}catch(i){It.warn("Failed to resync session inbox after connection",{instanceId:e,sessionId:s,error:i})}}))}const o6=["agents","providers","commands","metadata","filesystem"],cc=new Map;function $v(e,t=o6){const n=cc.get(e);if(n){for(const a of t)n.pending.add(a);return n.promise}const s=Ue().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")&&Iq(e);const i=[],c=$n(e);a.has("agents")&&i.push(wf(e,c,!0)),a.has("providers")&&i.push(ha(e,c,!0)),a.has("commands")&&i.push(Nx(e,r,c)),a.has("metadata")&&i.push(DC(s,{force:!0,location:c})),await Promise.all(i)}while(o.pending.size)})().finally(()=>{cc.get(e)===o&&cc.delete(e)}),cc.set(e,o),o.promise}fs.on("instance.eventStatus",e=>{var n;if(e.type!=="instance.eventStatus")return;const t=zC.observe(e.instanceId,e.status,e.reason);e.status==="connected"&&(((n=vv())==null?void 0:n.id)===e.instanceId&&wv(null),t&&r6(e.instanceId))});function i6(){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?`restore-${globalThis.crypto.randomUUID()}`:(P0+=1,`restore-${Date.now().toString(36)}-${P0.toString(36)}`)}const mu=new Map;function Gc(e,t){const n=mu.get(e);if(n){mu.delete(e);for(const s of n)t?s.reject(t):s.resolve()}}function rr(e){RV(e,new Set(Ln.sessionIds(e)),new Set(no.sessionIds(e)))}function a6(e,t){const n=Ue().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)??ku().environmentVariables??{}}}function Vi(e,t){const n=a6(e,t);Ue().has(e.id)?Zc(e.id,n):tE(n),e.status==="ready"?(c6(e),Gc(e.id)):(e.status==="error"||e.status==="stopped")&&Gc(e.id,new Error(e.error||`Workspace ${e.id} did not become ready`))}function c6(e){const t=Ue().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&&Zc(e.id,{port:n});return}t.client&&(Ji.destroyClientsForInstance(e.id),Py(e.id));const r=Ji.createClient(e.id,s,()=>bs()===e.id);Zc(e.id,{client:r,port:n??0,proxyPath:s,status:"ready"}),ln.seedStatusIfMissing(e.id,"connecting");const o=GC(e.id);Sv.set(e.id,o.sessions),jC.set(e.id,o.workspaceMetadata);const a=ZC(e.id,{propagateErrors:!0,sessionHydration:o.sessions,workspaceMetadataHydration:o.workspaceMetadata});bv.set(e.id,a),a.catch(i=>{It.error("Failed to hydrate instance data",i)})}function _v(e){const t=Ue().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=mu.get(e)??new Set;o.add(r),mu.set(e,o);const a=Ue().get(e);(a==null?void 0:a.status)==="ready"&&a.client?Gc(e):((a==null?void 0:a.status)==="error"||(a==null?void 0:a.status)==="stopped")&&Gc(e,new Error(a.error||`Workspace ${e} did not become ready`))})}async function l6(e){await _v(e),await Sv.get(e)}function Cv(e){const t=Ue().get(e);t&&(t.client&&Ji.destroyClientsForInstance(e),Py(e),ln.seedStatus(e,"disconnected"))}function HC(e,t){var n;return TI(t,[$n(e),...lo(e),...Array.from(((n=Fe().get(e))==null?void 0:n.values())??[]).map(s=>s.location),...Br(e).flatMap(s=>s.location?[s.location]:[])])}async function d6(e,t=!1,n=()=>!0){var o,a,i;const s=Ue().get(e);if(!(s!=null&&s.client))return;const r=ka.get(e)??0;try{const c=Date.now(),l=[],d=HC(e,s.folder),u=new Set,f=await qC(d,n,async v=>{const k=await xv(e,$=>s.client.permission.request.list({location:wo(v)},{...Nt(v),signal:$}));return{location:v,response:k}}),h=[];for(const v of f){if(v.status==="rejected"){h.push(v.reason);continue}const{location:k,response:$}=v.value;It.info("permission.request.list",{instanceId:e,location:k,resolvedLocation:$.location});const C={directory:$.location.directory||k.directory,workspaceID:Vu($.location)},T=Ki(C);T&&(u.add(T),l.push(...$.data.map(D=>({request:D,location:C,key:T}))))}const m=new Set(l.map(({request:v})=>v.id));if(!n()||(ka.get(e)??0)!==r){if(t)throw kv;return}h.length||gq(e,m,c);const w=l.filter(({request:v})=>!If(e,v.id)),S=new Set(w.map(({request:v})=>v.id)),b=xo(e);for(const v of b){const k=((o=Ff.get(e))==null?void 0:o.get(v.id))??Ki((i=(a=Fe().get(e))==null?void 0:a.get(Zi(v)??""))==null?void 0:i.location);!S.has(v.id)&&k&&u.has(k)&&(Cl(e,v.id),zu(e,v.id))}for(const{request:v,location:k}of w){const $=Ev(e,v,k)??v;Ax(e,$)}if(rr(e),h.length&&(It.warn("Pending permission scan was partial",{instanceId:e,failedLocations:h.length}),t))throw h[0]}catch(c){if(It.warn("Failed to sync pending permissions",{instanceId:e,error:c}),t)throw c}}async function u6(e,t=!1,n=()=>!0){var o,a,i;const s=Ue().get(e);if(!(s!=null&&s.client))return;const r=po.get(e)??0;try{const c=Date.now(),l=[],d=HC(e,s.folder),u=new Set,f=await qC(d,n,async b=>{const v=await xv(e,k=>s.client.form.list({location:wo(b)},{...Nt(b),signal:k}));return{location:b,response:v}}),h=[];for(const b of f){if(b.status==="rejected"){h.push(b.reason);continue}const{location:v,response:k}=b.value,$={directory:k.location.directory||v.directory,workspaceID:Vu(k.location)},C=Ki($);C&&(u.add(C),l.push(...k.data.map(T=>({form:T.sessionID==="global"?{...T,location:k.location}:T,location:$,key:C}))))}if(!n()||(po.get(e)??0)!==r){if(t)throw kv;return}const m=new Set(l.map(({form:b})=>b.id));h.length||mq(e,m,c);const w=l.filter(({form:b})=>!xC(e,b.id)),S=new Set(w.map(({form:b})=>b.id));for(const b of Br(e)){const v=((o=Nf.get(e))==null?void 0:o.get(b.id))??Ki(b.location)??Ki((i=(a=Fe().get(e))==null?void 0:a.get(b.sessionID))==null?void 0:i.location);!S.has(b.id)&&v&&u.has(v)&&El(e,b.id)}for(const{form:b,location:v}of w)Mv(e,b,v);if(rr(e),h.length&&(It.warn("Pending form scan was partial",{instanceId:e,failedLocations:h.length}),t))throw h[0]}catch(c){if(It.warn("Failed to sync pending forms",{instanceId:e,error:c}),t)throw c}}async function f6(e,t,n){for(let s=0;s<3&&!n.cancelled;s+=1){const r=(yd.get(e)??0)+1;yd.set(e,r);const o=()=>!n.cancelled&&yd.get(e)===r&&Wc.get(e)===t;try{await Promise.all([d6(e,!0,o),u6(e,!0,o)]);return}catch(a){if(a!==kv)throw a}}if(!n.cancelled&&Wc.get(e)===t)throw new Error("Pending request sync did not stabilize")}function _l(e,t){const n=Wc.get(e);if(n===void 0)return Promise.resolve();const s=qs.get(e);if((s==null?void 0:s.generation)===n)return t==null||t(()=>{var a;((a=qs.get(e))==null?void 0:a.token)===s.token&&(s.token.cancelled=!0,hu(e),Hc(e),qs.delete(e))}),s.promise;const r={cancelled:!1},o=f6(e,n,r).finally(()=>{var a;((a=qs.get(e))==null?void 0:a.promise)===o&&qs.delete(e)});return qs.set(e,{generation:n,token:r,promise:o}),t==null||t(()=>{var a;((a=qs.get(e))==null?void 0:a.token)===r&&(r.cancelled=!0,hu(e),Hc(e),qs.delete(e))}),o}function Uf(e){const t=qs.get(e);t&&(t.token.cancelled=!0),hu(e),qs.delete(e),Hc(e),_l(e).catch(n=>{It.warn("Failed to reconcile pending requests after an ambiguous mutation",{instanceId:e,error:n})})}async function g6(e){const t=Fe().get(e),n=Array.from((t==null?void 0:t.values())??[]).some(r=>r.status==="working"||r.status==="compacting");let s;if(n||xo(e).length||Br(e).length)try{await xv(e,r=>m1(e,r),!1)}catch(r){s=r}if(await _l(e),rr(e),s)throw s}function h6(e){const t=ic.get(e);if(t)return t;const n=g6(e).finally(()=>{ic.get(e)===n&&ic.delete(e)});return ic.set(e,n),n}function GC(e,t=!1){const n=t?ri(e):Li(e),s=Promise.resolve().then(async()=>{const a=Ue().get(e);a!=null&&a.client&&await PC(a,{force:t}).catch(i=>{It.warn("Failed to load project metadata before session hydration",{instanceId:e,error:i})})}),r=Promise.all([n,s]).then(()=>{});r.catch(a=>It.warn("Failed to hydrate workspace metadata",{instanceId:e,error:a}));const o=Promise.resolve().then(async()=>{U1(e),await fi(e,{projectMetadata:s}).catch(a=>{It.error("Failed to hydrate sessions",{instanceId:e,error:a})})});return o.then(async()=>{const a=Ue().get(e);a!=null&&a.client&&await DC(a,{force:t,location:$n(e)})}).catch(a=>It.warn("Failed to load supplemental instance metadata",{instanceId:e,error:a})),{sessions:o,workspaceMetadata:r}}async function ZC(e,t){try{const n=t!=null&&t.sessionHydration?{sessions:t.sessionHydration,workspaceMetadata:t.workspaceMetadataHydration??Promise.resolve()}:GC(e,t==null?void 0:t.force);await Promise.all([n.sessions,n.workspaceMetadata,fa(e,t==null?void 0:t.force)]),await aT(e),await _l(e)}catch(n){if(It.error("Failed to fetch initial data",n),t!=null&&t.propagateErrors)throw n}}async function m6(e){const t=Ue().get(e);if(!(t!=null&&t.proxyPath))throw new Error("Instance not ready");const n=sx(t.proxyPath),s=new URL("instance/dispose",n),r=await fetch(s.toString(),{method:"POST",credentials:"include",headers:{Accept:"application/json"}});if(!r.ok){const i=await r.text().catch(()=>"");throw new Error(i||`Dispose request failed with ${r.status}`)}if((r.headers.get("content-type")??"").includes("application/json")){const i=await r.json().catch(()=>{});return typeof i=="boolean"?i:i&&typeof i=="object"&&"data"in i?!!i.data:!!i}const a=await r.text().catch(()=>"");return a.trim()==="true"?!0:a.trim()==="false"?!1:!!a}function JC(e){jd(e),Lp(e),Ip(e),Tv(e),dE(e)}async function vd(e,t){if(od.has(e))return od.get(e);const n=(async()=>{const s=Ue().get(e);s!=null&&s.client&&(It.info("Rehydrating instance",{instanceId:e,reason:t==null?void 0:t.reason}),JC(e),await ZC(e,{force:!0}))})().finally(()=>{od.delete(e)});return od.set(e,n),n}async function p6(e){if(rd.has(e))return rd.get(e);const t=(async()=>{const n=await m6(e);return n&&await vd(e,{reason:"disposed"}),n})().finally(()=>{rd.delete(e)});return rd.set(e,t),t}async function YC(){if(!Nm())return;const e=mr.begin(),t=new Set(Ue().keys());try{const n=await ft.fetchWorkspaces();if(!mr.isCurrent(e))return;const s=new Set(n.map(({id:o})=>o));for(const o of n)if(mr.allows(e,o.id)&&(rn.trackPendingRequest(o),!Wr.deferRefreshWorkspace(o))){if(rn.owns(o.id)){rn.track(o);continue}Vi(o)}const r=[...t].filter(o=>mr.allows(e,o));for(const o of lq(r,s,a=>rn.owns(a)))Cv(o),Bf(o,{authoritative:!1})}finally{mr.complete(e)}}const QC=async function(){try{return await YC(),{}}catch(t){return It.error("Failed to load workspaces",t),{error:t}}}();let pu=QC;const Dm=new Set;function y6(e){pu=e,Dm.forEach(t=>t())}function v6(e,t){return pu!==e?Promise.resolve():new Promise((n,s)=>{const r=()=>{Dm.delete(o),t==null||t.removeEventListener("abort",a)},o=()=>{r(),n()},a=()=>{r(),s(t==null?void 0:t.reason)};Dm.add(o),t==null||t.addEventListener("abort",a,{once:!0}),pu!==e&&o()})}fs.onOpen(()=>{y6(YC().then(()=>({}),e=>(It.warn("Failed to reconcile workspaces after event reconnect",e),{error:e})))});async function w6(e){await Nq(QC,()=>pu,v6,e)}fs.on("*",e=>b6(e));function b6(e){if(!Nm())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"&&mr.markMutation(t),!("workspace"in e&&(rn.trackPendingRequest(e.workspace),Wr.deferWorkspace(e.workspace)))&&!(e.type==="workspace.stopped"&&Wr.deferStopped(e.workspaceId,e.reason))&&!(t&&rn.shouldIgnoreEvent(t)))switch(e.type){case"workspace.created":Vi(e.workspace);break;case"workspace.started":Vi(e.workspace);break;case"workspace.error":Vi(e.workspace),_q(e.workspace),TC(e.workspace.id),cE(e.workspace.id);break;case"workspace.stopped":Fq(e.workspaceId),rn.release(e.workspaceId),Cv(e.workspaceId),Bf(e.workspaceId,{authoritative:e.reason==="deleted"});break;case"workspace.log":S6(e.entry);break}}function S6(e){const t={timestamp:new Date(e.timestamp).getTime(),level:e.level??"info",message:e.message};oE(e.workspaceId,t)}function k6(e){Lf(t=>{if(t.has(e))return t;const n=new Map(t);return n.set(e,[]),n})}function XC(e){hv(t=>{if(t.has(e))return t;const n=new Map(t);return n.set(e,!1),n})}function x6(e){Lf(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),hv(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n})}function $6(e){return LC().get(e)??[]}function eE(e){return Gq().get(e)??!1}function _6(e,t){XC(e),hv(n=>{const s=new Map(n);return s.set(e,t),s}),t||iE(e)}function tE(e){const t=Array.from(Ue().values()).filter(n=>yo(n.folder)===yo(e.folder)).length;Wc.set(e.id,++n6),gv(n=>{const s=new Map(n);return s.set(e.id,e),s}),k6(e.id),XC(e.id),Am({type:"opened",instanceId:e.id,folder:e.folder,occurrence:t}),yv()}function Zc(e,t){var s;const n=Ue().get(e);if(t.client!==void 0&&(n!=null&&n.client)&&t.client!==n.client){vl(e),pf(e),Lp(e),Ip(e),mv(e),cc.delete(e);for(const r of((s=Fe().get(e))==null?void 0:s.keys())??[])Ls(e,r)}gv(r=>{const o=new Map(r),a=o.get(e);return a&&o.set(e,{...a,...t}),o}),yv()}function Bf(e,t={}){const n=Ue().get(e),s=n?Array.from(Ue().values()).filter(o=>yo(o.folder)===yo(n.folder)).findIndex(o=>o.id===e):-1;n&&s>=0&&t.authoritative===!1&&Am({type:"unavailable",instanceId:e,folder:n.folder,occurrence:s}),Lq(e),zC.clear(e);let r=null;gv(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),bs()===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}),x6(e),Lp(e),Tv(e),hq(e),pq(e),dE(e),Ip(e),mv(e),TC(e),cE(e),bv.delete(e),Sv.delete(e),jC.delete(e),Hc(e),hu(e),ic.delete(e),Wc.delete(e),Gc(e,new Error(`Workspace ${e} was removed before it became ready`)),bs()===e&&IC(r),jd(e),Bt.unregisterInstance(e),Z1(e),vl(e),pf(e),_I(e),W1(e),aC(e),tC(e),n&&s>=0&&t.authoritative!==!1&&Am({type:"removed",instanceId:e,folder:n.folder,occurrence:s}),yv()}function nE(e){mr.markMutation(e),Ue().has(e)&&(Cv(e),Bf(e,{authoritative:!1}))}function wd(e){return e.reused!==!0&&nE(e.id),rn.discardCreated(e,{retainTombstone:e.reused!==!0})}async function sE(e,t){await rn.releaseAfter(e,()=>jm(()=>ft.releaseWorkspaceCreation(e,t),{maxAttempts:4,initialDelayMs:250,maxDelayMs:2e3,backoffMultiplier:4}))}async function rE(e,t){await zq(t)}function C6(e){const t=rn.get(e);t!=null&&t.requestId&&sE(e,t.requestId).catch(n=>{It.warn("Failed to transfer restore workspace creation ownership to the user",{instanceId:e,error:n})})}async function O0(e,t){if(t.status==="stopped"){rn.release(e.id),nE(e.id);return}await wd(e)}async function E6(e,t,n){var l,d,u,f,h,m,w,S,b;const s=n!=null&&n.signal?i6():void 0;s&&rn.beginRequest(s);const r=s&&(n!=null&&n.waitForCreateCommit)?Wr.begin(s,n.waitForCreateCommit(),e):void 0;let o=null,a=!1,i=!1;const c=()=>{if(!s)return;const v=rn.quarantineRequest(s);o??(o=v?v.then(()=>!0):rE(void 0,s).then(()=>!0,k=>(It.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 Bi(n.signal);const v=await ft.createWorkspace({path:e,name:t,requestId:s},{signal:n==null?void 0:n.signal});a=!0;const k=v.reused===!0;if(s&&Wr.bindResponse(s,v.id),(u=n==null?void 0:n.signal)!=null&&u.aborted)throw v.requestId&&await wd(v),Bi(n.signal);if(n!=null&&n.signal&&v.requestId){const R=s?Wr.resolve(s,v).workspace:v;rn.track({...R,requestId:R.requestId??v.requestId,...k?{reused:!0}:{}})}else n!=null&&n.signal||rn.releaseTombstoneForUserCreate(v.id);if(r&&await r.wait,(f=n==null?void 0:n.signal)!=null&&f.aborted)throw v.requestId&&await wd(v),Bi(n.signal);const $=s?Wr.resolve(s,v):{workspace:v},C={...$.workspace,requestId:$.workspace.requestId??v.requestId,...k?{reused:!0}:{}};s&&rn.track(C);const T=$.terminal??(C.status==="error"||C.status==="stopped"?{status:C.status,message:C.error}:void 0);if(T)throw i=!0,await O0(C,T),new Error(T.message||`Restore-created workspace ${v.id} ${T.status}`);const D=rn.shouldIgnoreEvent(v.id)||((h=n==null?void 0:n.shouldCreateCommit)==null?void 0:h.call(n))===!1;if(D||(mr.markMutation(v.id),(m=n==null?void 0:n.onBeforeCreateCommit)==null||m.call(n,v.id),Vi(C,k?void 0:t),(w=n==null?void 0:n.onCreateCommit)==null||w.call(n,v.id)),D)throw v.requestId&&await wd(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 O0(r.workspace,r.terminal)),(S=n==null?void 0:n.signal)!=null&&S.aborted||It.error("Failed to create workspace",v),v}finally{if((b=n==null?void 0:n.signal)==null||b.removeEventListener("abort",c),s){Wr.end(s);const v=o;a||!v?rn.finishRequest(s):v.then(k=>{k&&rn.finishRequest(s)})}}}function yo(e){const t=e.replace(/[\\/]+$/,"");return/^(?:[A-Za-z]:[\\/]|[\\/]{2})/.test(t)?t.replace(/\\/g,"/").toLowerCase():t}function T6(e){if(!e)return null;const t=yo(e),n=Array.from(Ue().values()).filter(r=>r.status==="stopped"?!1:yo(r.folder)===t);if(n.length===0)return null;const s=bs();return n.find(r=>r.id===s)??n.find(r=>r.status==="ready")??n[0]??null}function M6(e,t){const n=t.trim();if(!e||!n)return;const s=yo(e);for(const r of Ue().values())r.status!=="stopped"&&yo(r.folder)===s&&Zc(r.id,{projectName:n})}const Ig=new Map;function A6(e){if(!Ue().get(e))return Promise.resolve();const n=Ig.get(e);if(n)return n;const s=ft.deleteWorkspace(e).catch(r=>{It.error("Failed to stop workspace",r);try{Fn({message:ke("app.stopInstance.toast.error"),variant:"error"})}finally{throw r}}).finally(()=>{Ig.delete(e)});return Ig.set(e,s),s}function D6(){const e=bs();return e&&Ue().get(e)||null}function oE(e,t){eE(e)&&Lf(n=>{const s=new Map(n),r=s.get(e)??[],o=r.length>=t6?[...r.slice(1),t]:[...r,t];return s.set(e,o),s})}function iE(e){Lf(t=>{if(!t.has(e))return t;const n=new Map(t);return n.set(e,[]),n})}function xo(e){const t=NC().get(e);return t||[]}function P6(e){return xo(e).length}function O6(e,t){const s=xo(e).find(r=>r.id===t);return s?Ln.ensureEnqueuedAt(s):Ln.enqueuedAtFor(t)}function R6(e){const t=xo(e),n=Br(e),s=[];t[0]&&s.push({kind:"permission",id:t[0].id,enqueuedAt:Ln.ensureEnqueuedAt(t[0])}),n[0]&&s.push({kind:"form",id:n[0].id,enqueuedAt:no.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 I6(e,t){e6(n=>{const s=new Map(n);return t?s.set(e,t):s.set(e,null),s}),UC(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 Ua(e){I6(e,R6(e))}function Ev(e,t,n){Ts(ka,e),BC(Ff,e,t.id,n);let s=!1,r=!1,o,a=t;if(pv(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=Qk(o,t);const m=u.slice();return m[f]=a,d.set(e,m.sort((w,S)=>Ln.ensureEnqueuedAt(w)-Ln.ensureEnqueuedAt(S))),r=!0,d}Ln.ensureEnqueuedAt(a);const h=[...u,a].sort((m,w)=>Ln.ensureEnqueuedAt(m)-Ln.ensureEnqueuedAt(w));return d.set(e,h),s=!0,d}),!s&&!r)return;Ua(e);const i=o?Zi(o):void 0,c=Zi(a);if(i&&i!==c){const l=Ln.decrement(e,i);uu(e,i,l>0)}return c&&((s||i!==c)&&Ln.increment(e,c),uu(e,c,!0)),a}function Cl(e,t){Ts(ka,e),KC(Ff,e,t);let n=null;pv(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}),Ua(e),Ln.remove(e,t);const s=n;if(s){const r=Zi(s);if(r){const o=Ln.decrement(e,r);uu(e,r,o>0)}}}function L6(e,t){const n=EC(e,t);bq(e,t),ft.toggleYolo(e,t).then(s=>{zc(e,t,s.enabled)}).catch(s=>{It.warn("Failed to toggle Yolo on server",{instanceId:e,sessionId:t,error:s}),zc(e,t,n)})}const ji=new Set;function aE(e,t){if(!e||!t||t==="info")return;const n=`${e}:${t}`;ji.has(n)||(ji.add(n),ft.getYoloState(e,t).then(s=>{zc(e,t,s.enabled)}).catch(s=>{ji.delete(n),It.warn("Failed to sync Yolo state",{instanceId:e,sessionId:t,error:s})}))}fs.onOpen(()=>{ji.clear()});function cE(e){const t=`${e}:`;for(const n of Array.from(ji))n.startsWith(t)&&ji.delete(n)}function Tv(e){Ts(ka,e),Ff.delete(e),Ln.clear(e,xo(e),t=>{uu(e,t,!1)}),pv(t=>{const n=new Map(t);return n.delete(e),n}),UC(t=>{const n=new Map(t);return n.delete(e),n}),Ua(e)}async function F6(e,t,n,s,r){const o=Ue().get(e);if(!(o!=null&&o.client))throw new Error("Instance not ready");try{const a=xo(e).find(i=>i.id===n);if(!a)throw new Error(`Permission request not found: ${n}`);await pt(e).permission.reply({sessionID:a.sessionID,requestID:n,decision:s,...r?{message:r}:{}}),Rf(e,n),Cl(e,n),zu(e,n)}catch(a){throw It.error("Failed to send permission response",a),Uf(e),a}}async function N6(e,t,n){const s=Br(e).find(r=>r.id===t);if(!s)throw new Error(`Form request not found: ${t}`);Ts(po,e);try{await pt(e).session.form.reply({sessionID:s.sessionID,formID:s.id,answer:n},OC(s)),uv(e,s.id),El(e,s.id)}catch(r){throw Uf(e),r}}let bd;function lE(e){bd=e}function Mv(e,t,n){Ts(po,e),BC(Nf,e,t.id,n??t.location);const s=Br(e).find(r=>r.id===t.id);if(Mq(e,t),no.ensureEnqueuedAt(t),s!=null&&s.sessionID&&s.sessionID!==t.sessionID){const r=no.decrement(e,s.sessionID);fu(e,s.sessionID,r>0)}return(!s||s.sessionID!==t.sessionID)&&no.increment(e,t.sessionID),fu(e,t.sessionID,!0),Ua(e),s||bd==null||bd(e,t),s?void 0:t}function El(e,t){Ts(po,e),KC(Nf,e,t);const n=Br(e).find(s=>s.id===t);if(Aq(e,t),no.remove(e,t),n){const s=no.decrement(e,n.sessionID);fu(e,n.sessionID,s>0)}Ua(e)}function dE(e){Ts(po,e),Nf.delete(e),no.clear(e,Br(e),t=>{fu(e,t,!1)}),Pq(e),Ua(e)}async function U6(e,t){const n=Br(e).find(s=>s.id===t);if(!n)throw new Error(`Form request not found: ${t}`);Ts(po,e);try{await pt(e).session.form.cancel({sessionID:n.sessionID,formID:n.id},OC(n)),uv(e,n.id),El(e,n.id)}catch(s){throw Uf(e),s}}const B6=new Set(["session.step.ended","session.step.failed"]);function uE(e,t){var l,d,u,f;const n=Ue().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"&&mv(e),s&&(t.type==="session.compaction.ended"||t.type==="session.compaction.failed")&&Yq(e,s);const o=(h,m=!0,w=!1)=>{var S;if(s&&t.type.startsWith("session.")&&jn().get(e)!==s&&((S=$f().get(e))!=null&&S.has(s))&&Ls(e,s),r&&!w){s&&Jq(e,s,()=>o(h,m,!0));return}s&&(w||t.type.startsWith("session."))&&jn().get(e)===s&&Px(Bt.getOrCreate(e).getMessageWindow(s))&&(EK(e,s,h,m,w||t.type!=="session.inbox.enqueued"),(w||B6.has(t.type))&&ta(e,s))},a=(h,m=!0)=>{if(o(h,m),s&&t.type==="session.inbox.cancelled"&&Lb(e,t.data.inboxID,s),s&&t.type==="session.revert.committed")for(const w of Bt.getOrCreate(e).getSessionMessageIds(s))w>=t.data.to&&Lb(e,w,s)},i=_K(e,n.folder,t,a,h=>{o(h,!1,!0),Uf(e)});if(a(i),s&&(t.type==="permission.asked"||t.type==="permission.replied")){const h=i.session.permission.list(s)??[],m=(t.type==="permission.asked"?[t.data,...h.filter(S=>S.id!==t.data.id)]:h).filter(S=>!If(e,S.id)),w=t.location??((d=(l=Fe().get(e))==null?void 0:l.get(s))==null?void 0:d.location);for(const S of m){const b=Ev(e,S,w)??S;Ax(e,b)}t.type==="permission.replied"&&(Cl(e,t.data.requestID),zu(e,t.data.requestID))}if(s&&t.type.startsWith("form.")){const h=i.session.form.list(s,s==="global"?t.location:void 0)??[],m=t.type==="form.created"?[t.data.form,...h.filter(S=>S.id!==t.data.form.id)]:h,w=t.location??((f=(u=Fe().get(e))==null?void 0:u.get(s))==null?void 0:f.location);for(const S of m)xC(e,S.id)||Mv(e,S,w);(t.type==="form.replied"||t.type==="form.cancelled")&&(uv(e,t.data.id),El(e,t.data.id))}const c=dq(t.type);c.length&&$v(e,c)}ln.onInvalidation=uE;ln.onConnectionLost=(e,t)=>{const n=Ue().get(e);n&&wv({id:e,folder:n.folder,reason:t})};ln.onInstanceDisposed=(e,t)=>{var r;const n=(r=t==null?void 0:t.properties)==null?void 0:r.directory;if(!n){vd(e,{reason:"disposed"});return}const s=[];for(const o of Ue().values())o.folder===n&&s.push(o.id);if(s.length===0){vd(e,{reason:"disposed"});return}for(const o of s)vd(o,{reason:"disposed"})};async function K6(){vv()&&wv(null)}const V6=Object.freeze(Object.defineProperty({__proto__:null,acknowledgeDisconnectedInstance:K6,activeInstanceId:bs,activeInterruption:Xq,activePermissionId:Qq,addInstance:tE,addLog:oE,addPendingForm:Mv,addPermissionToQueue:Ev,cancelRestoreCreationRequest:rE,claimRestoreCreatedInstanceForUser:C6,clearLogs:iE,clearPermissionQueue:Tv,clearReloadableInstanceState:JC,createInstance:E6,disconnectedInstance:vv,disposeInstance:p6,ensureYoloStateSynced:aE,getActiveInstance:D6,getExistingInstanceForFolder:T6,getInstanceLogs:$6,getPermissionEnqueuedAtForInstance:O6,getPermissionQueue:xo,getPermissionQueueLength:P6,handleInstanceInvalidation:uE,hasRepliedPermission:If,instanceLogs:LC,instances:Ue,invalidatePendingRequestSync:Hc,isInstanceLogStreaming:eE,markPermissionReplied:Rf,permissionQueues:NC,reconcilePendingRequestLiveness:h6,reconcilePendingSessionIndicators:rr,refreshVolatileInstanceState:$v,releaseRestoreCreatedInstance:sE,removeInstance:Bf,removePendingForm:El,removePermissionFromQueue:Cl,sendFormCancel:U6,sendFormReply:N6,sendPermissionResponse:F6,setActiveInstanceId:IC,setInstanceLogStreaming:_6,setPendingFormAddedHandler:lE,stopInstance:A6,syncLoadedSessionInboxes:WC,syncPendingRequests:_l,togglePermissionAutoAcceptForSession:L6,updateInstance:Zc,updateProjectNameForFolder:M6,waitForInitialWorkspaceLoad:w6,waitForInstanceInitialSessionHydration:l6,waitForInstanceReady:_v},Symbol.toStringTag,{value:"Module"}));async function j6(e,t="ui"){if(typeof window>"u")return!1;if(Fm())try{const{openUrl:n}=await ts(async()=>{const{openUrl:s}=await import("./index-CHztP7Qx.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 fE(e,t){return(e.type==="external"||!e.hidden)&&gE(e,t)}function gE(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 q6(e,t){return Object.fromEntries(e.flatMap(n=>{if(n.type==="external"||!gE(n,t))return[];const s=t[n.key]??(n.hidden?n.default:void 0);return s===void 0?[]:[[n.key,s]]}))}function Pm(e){try{const t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}const Lg={type:"key",label:""};function z6(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 id(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 R0(e){const t={};for(const n of e??[])n.type!=="external"&&n.default!==void 0&&(t[n.key]=n.default);return t}function I0(e,t){if(e)return q6(e,t)}function W6(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||!z6(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 H6(e){const t=e;return(t==null?void 0:t.name)==="AbortError"||(t==null?void 0:t.message)==="This operation was aborted"}var G6=F("<div class=providers-form-stack>"),Z6=F("<label class=settings-form-label>"),L0=F("<span class=settings-toggle-caption>"),J6=F("<input class=providers-input>"),Y6=F("<datalist>"),Q6=F('<div class="flex-1 min-w-0">'),X6=F("<input type=number class=providers-input>"),F0=F("<label class=settings-checkbox-toggle><input type=checkbox><span>"),e8=F("<input type=text class=providers-input>"),t8=F("<div class=providers-multiselect>"),n8=F("<div class=providers-field>"),s8=F('<div class=providers-field><a target=_blank rel="noopener noreferrer"class="selector-button selector-button-secondary providers-oauth-link">'),r8=F("<option>"),o8=F("<span class=providers-select-hint>"),i8=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const a8=e=>{const{t}=kt(),n=$e(()=>(e.fields??[]).filter(d=>fE(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 h=new Set(o(d));f?h.add(u):h.delete(u),e.onAnswer(d.key,[...h])},l=(d,u)=>{const f=new Set(d.options.map(w=>w.value)),h=o(d).filter(w=>f.has(w)),m=u.split(",").map(w=>w.trim()).filter(Boolean);e.onAnswer(d.key,[...h,...m])};return(()=>{var d=G6();return p(d,y(Ut,{get each(){return n()},children:u=>y(Q,{get when(){return u.type!=="external"},get fallback(){return y(Q,{get when(){return _e(()=>u.type==="external")()&&Pm(u.url)},get children(){var f=s8(),h=f.firstChild;return p(h,y(Oi,{class:"w-4 h-4"}),null),p(h,()=>s(u),null),p(f,y(Q,{get when(){return u.description},get children(){var m=L0();return p(m,()=>u.description),m}}),null),de(()=>pe(h,"href",u.type==="external"?u.url:void 0)),f}})},get children(){var f=n8();return p(f,y(Q,{get when(){return u.type!=="boolean"},get children(){var h=Z6();return p(h,()=>s(u)),de(()=>pe(h,"for",`provider-field-${u.key}`)),h}}),null),p(f,y(Q,{get when(){return u.description},get children(){var h=L0();return p(h,()=>u.description),h}}),null),p(f,y(Q,{get when(){return _e(()=>u.type==="string")()&&(!u.options||u.custom)},get children(){return[(()=>{var h=J6();return h.$$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,$=u.type==="string"?u.maxLength:void 0,C=u.type==="string"?u.pattern:void 0,T=u.type==="string"&&u.options?`provider-options-${u.key}`:void 0,D=e.disabled;return w!==m.e&&pe(h,"id",m.e=w),S!==m.t&&pe(h,"type",m.t=S),b!==m.a&&pe(h,"placeholder",m.a=b),v!==m.o&&(h.required=m.o=v),k!==m.i&&pe(h,"minlength",m.i=k),$!==m.n&&pe(h,"maxlength",m.n=$),C!==m.s&&pe(h,"pattern",m.s=C),T!==m.h&&pe(h,"list",m.h=T),D!==m.r&&(h.disabled=m.r=D),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(()=>h.value=typeof r(u)=="string"?r(u):""),h})(),y(Q,{get when(){return _e(()=>u.type==="string")()&&u.options},get children(){var h=Y6();return p(h,y(Ut,{get each(){return _e(()=>u.type==="string")()?u.options:[]},children:m=>(()=>{var w=r8();return p(w,()=>m.label),de(()=>w.value=m.value),w})()})),de(()=>pe(h,"id",`provider-options-${u.key}`)),h}})]}}),null),p(f,y(Q,{get when(){return _e(()=>!!(u.type==="string"&&u.options))()&&!u.custom},get children(){return y(Te,{get value(){var h;return _e(()=>u.type==="string")()?(h=u.options)==null?void 0:h.find(m=>m.value===r(u)):void 0},onChange:h=>e.onAnswer(u.key,h==null?void 0:h.value),get options(){return _e(()=>u.type==="string")()?u.options??[]:[]},optionValue:"value",optionTextValue:"label",get disabled(){return e.disabled},itemComponent:h=>y(Te.Item,{get item(){return h.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return[_e(()=>h.item.rawValue.label),y(Q,{get when(){return h.item.rawValue.description},get children(){var m=o8();return p(m,()=>h.item.rawValue.description),m}})]}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger providers-prompt-trigger",get"aria-label"(){return s(u)},get children(){return[(()=>{var h=Q6();return p(h,y(Te.Value,{children:m=>(()=>{var w=i8();return p(w,()=>{var S;return((S=m.selectedOption())==null?void 0:S.label)??t("settings.providers.prompt.selectPlaceholder")}),w})()})),h})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})}}),null),p(f,y(Q,{get when(){return u.type==="number"||u.type==="integer"},get children(){var h=X6();return h.$$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,$=e.disabled;return w!==m.e&&pe(h,"id",m.e=w),S!==m.t&&pe(h,"min",m.t=S),b!==m.a&&pe(h,"max",m.a=b),v!==m.o&&pe(h,"step",m.o=v),k!==m.i&&(h.required=m.i=k),$!==m.n&&(h.disabled=m.n=$),m},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),de(()=>h.value=typeof r(u)=="number"?r(u):""),h}}),null),p(f,y(Q,{get when(){return u.type==="boolean"},get children(){var h=F0(),m=h.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),h}}),null),p(f,y(Q,{get when(){return u.type==="multiselect"},get children(){var h=t8();return p(h,y(Ut,{get each(){return _e(()=>u.type==="multiselect")()?u.options:[]},children:m=>(()=>{var w=F0(),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(h,y(Q,{get when(){return _e(()=>u.type==="multiselect")()&&u.custom},get children(){var m=e8();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&&pe(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),h}}),null),f}})})),d})()};Ht(["input"]);function c8(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 l8(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 d8=F("<p class=settings-error-message role=alert>"),u8=F("<div class=provider-model-visibility-list role=list>"),f8=F('<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">'),g8=F("<p class=settings-card-message role=status>"),h8=F("<label class=provider-model-visibility-item role=listitem><input type=checkbox><span><strong></strong><small dir=ltr>");const m8=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"})||e.id.localeCompare(t.id,void 0,{sensitivity:"base"}),p8=e=>{const{t}=kt(),{getProviderModelVisibilityPreference:n,providerModelVisibilitySaveFailed:s,setProviderModelVisibility:r}=Tn(),[o,a]=L("");let i;const c=$e(()=>[...e.models].sort(m8)),l=$e(()=>new Set(c().filter(m=>n(m.providerId).hiddenModelIds.includes(m.id)).map(m=>`${m.providerId}\0${m.id}`))),d=$e(()=>c().filter(m=>!l().has(`${m.providerId}\0${m.id}`)).length),u=$e(()=>{const m=o().trim().toLocaleLowerCase();return m?c().filter(w=>w.name.toLocaleLowerCase().includes(m)||w.id.toLocaleLowerCase().includes(m)):c()});qe(ei(()=>e.providerId,()=>a(""))),Ns(()=>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(()=>{})},h=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($=>!b.includes($)):Array.from(new Set([...v,...b]));r(S,{hiddenModelIds:k}).catch(()=>{})}};return(()=>{var m=f8(),w=m.firstChild,S=w.firstChild,b=S.nextSibling,v=b.firstChild,k=v.nextSibling,$=w.nextSibling,C=$.firstChild,T=C.nextSibling,D=T.nextSibling,R=D.nextSibling,q=R.nextSibling;cS(S,"click",e.onBack,!0),p(S,y(x2,{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(C,()=>t("settings.providers.modelVisibility.search.label")),T.$$input=ee=>a(ee.currentTarget.value);var re=i;return typeof re=="function"?Xs(re,T):i=T,p(D,()=>t("settings.providers.modelVisibility.count.visible",{visible:d(),total:c().length})),R.$$click=()=>h(!0),p(R,()=>t("settings.providers.modelVisibility.actions.showAll")),q.$$click=()=>h(!1),p(q,()=>t("settings.providers.modelVisibility.actions.hideAll")),p(m,y(Q,{get when(){return c().some(ee=>s(ee.providerId))},get children(){var ee=d8();return p(ee,()=>t("settings.providers.modelVisibility.save.failed")),ee}}),null),p(m,y(Q,{get when(){return u().length>0},get fallback(){return(()=>{var ee=g8();return p(ee,()=>t("settings.providers.modelVisibility.list.empty")),ee})()},get children(){var ee=u8();return p(ee,y(Ut,{get each(){return u()},children:W=>(()=>{var U=h8(),J=U.firstChild,le=J.nextSibling,z=le.firstChild,M=z.nextSibling;return J.addEventListener("change",N=>f(W,N.currentTarget.checked)),p(z,()=>W.name||W.id),p(M,()=>W.id),de(()=>J.checked=!l().has(`${W.providerId}\0${W.id}`)),U})()})),de(()=>pe(ee,"aria-label",t("settings.providers.modelVisibility.list.label",{provider:e.providerName}))),ee}}),null),de(()=>pe(T,"placeholder",t("settings.providers.modelVisibility.search.placeholder"))),de(()=>T.value=o()),m})()};Ht(["click","input"]);var y8=F('<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">'),Fg=F("<div class=settings-card-message role=status>"),N0=F('<div class="flex-1 min-w-0">'),v8=F('<div class=providers-connect-bar><button type=button class="selector-button selector-button-primary"></button><button type=button class=settings-pill-button>'),U0=F("<div class=settings-error-message role=alert>"),w8=F('<div class="settings-toggle-row settings-toggle-row-compact providers-method-row"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>'),b8=F("<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>"),S8=F("<div class=providers-form-stack><div class=settings-card-message role=status></div><div class=providers-command-preview dir=ltr>"),k8=F("<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>"),x8=F('<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">'),$8=F('<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">'),_8=F("<div class=settings-card-message role=alert>"),C8=F("<div class=providers-success-card role=status><span>"),B0=F('<button type=button class="selector-button selector-button-primary">'),E8=F('<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>'),T8=F("<section class=providers-list-section><h3 class=settings-card-title>"),M8=F("<div class=providers-manager-body>"),A8=F("<div class=selector-option-content><div class=selector-option-description><span dir=ltr></span><span> • </span><span></span><span> • </span><span>"),D8=F("<span class=selector-trigger-secondary dir=ltr> • "),P8=F('<div class="selector-trigger-label selector-trigger-label--stacked flex-1 min-w-0"><span class="selector-trigger-primary selector-trigger-primary--align-left">'),O8=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">'),R8=F("<div class=providers-loading-row role=status><span>"),I8=F("<div class=providers-grid>"),L8=F("<bdi dir=ltr>"),F8=F("<span aria-hidden=true> • "),N8=F('<button type=button class="selector-button selector-button-secondary providers-disconnect-button">'),U8=F('<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">'),B8=F('<div class="providers-manager-modal providers-manager-embedded">');const K8=e=>{const{t}=kt(),[n,s]=L({}),[r,o]=L([]),[a,i]=L(null),[c,l]=L(null),[d,u]=L(null),f=new Map;let h=null;const[m,w]=L(0),[S,b]=L(""),[v,k]=L({}),[$,C]=L(null),[T,D]=L(null),[R,q]=L(null),[re,ee]=L(""),[W,U]=L("idle"),[J,le]=L(!1),[z,M]=L(null),[N,ce]=L(null),[fe,Re]=L(!1),[be,ye]=L(!1);let Ce=null,je=null,O=0,g=0,x=null,A=null,E=null,H=null,B;const oe=$e(()=>Ue().get(e.instanceId)??null),Ae=$e(()=>{if(e.instanceId&&e.location)return pt(e.instanceId);const te=oe();return(te==null?void 0:te.status)==="ready"?te.client??null:null}),we=()=>e.location?{...e.location}:{...$n(e.instanceId)},he=te=>wo(te),Ee=te=>{const ie=we();return Es(ie)===Es(te)},Ge=$e(()=>{const te=new Map;for(const ie of r())te.set(ie.id,ie.name||ie.id);return te}),Xe=$e(()=>r().sort((te,ie)=>te.id.localeCompare(ie.id,void 0,{sensitivity:"base"})).map(te=>({id:te.id,name:Ge().get(te.id)??te.id,modelCount:te.modelCount,connectionSummary:js(te.id),canConnect:te.canConnect}))),se=$e(()=>r().filter(te=>te.source!=="unknown")),V=$e(()=>se().find(te=>te.id===d())??null),Y=te=>te.source==="env"?"not-disconnectable":te.credentialIds.length>0?"credential-remove":"unknown",Oe=te=>{const ie=Y(te);return te.source==="config"?t("settings.providers.source.config"):ie==="not-disconnectable"?t("settings.providers.source.env"):te.source==="api"?t("settings.providers.source.api"):te.source==="custom"?t("settings.providers.source.custom"):t("settings.providers.source.unknown")},ve=$e(()=>Xe().find(te=>te.id===a())??Xe()[0]??null),Ie=$e(()=>{const te=c();return te?Ge().get(te)??te:""}),Le=$e(()=>{const te=c();if(!te)return[Lg];const ie=n()[te];return ie&&ie.length>0?ie:[Lg]}),ze=$e(()=>Le().map((te,ie)=>({value:String(ie),label:te.label||(te.type==="oauth"?t("settings.providers.method.oauth"):te.type==="command"?t("settings.providers.method.command"):t("settings.providers.method.api")),method:te,index:ie}))),Ne=$e(()=>ze().find(te=>te.index===m())??ze()[0]),Je=$e(()=>{var te;return((te=Ne())==null?void 0:te.method)??Lg}),ot=$e(()=>{const te=Je();return te.type==="command"?void 0:te.form}),gt=$e(()=>{const te=Je();return te.type==="command"?te:void 0}),_=$e(()=>{if(!c()||W()==="authorizing"||W()==="waiting"||W()==="success")return!1;const te=Je();return te.type==="key"&&S().trim().length===0?!1:(te.type==="command"?[]:te.form??[]).filter(ie=>fE(ie,v())).every(ie=>W6(ie,v()))});function P(te){var ie;te||et(null),(ie=e.onOpenChange)==null||ie.call(e,te)}function j(){return!Fm()&&typeof window<"u"}function K(){if(!j())return null;let te=null;try{return te=window.open("","_blank"),te&&te.document&&(te.opener=null,te.document.title=t("settings.providers.oauth.popup.loadingTitle"),te.document.body.innerHTML=`<div style="font-family: sans-serif; padding: 24px; color: #111;">${t("settings.providers.oauth.popup.loadingBody")}</div>`),te}catch{return te==null||te.close(),null}}async function I(te,ie){if(!Pm(te))return ie!=null&&ie.popup&&!ie.popup.closed&&ie.popup.close(),!1;if(ie!=null&&ie.sameTab&&typeof window<"u")return window.location.assign(te),!0;const Pe=ie==null?void 0:ie.popup;if(Pe&&!Pe.closed)try{return Pe.location.href=te,!0}catch{}return await j6(te,"provider-auth")}async function Z(){var ie,Pe;const te=(ie=$())==null?void 0:ie.url;if(!(!te||typeof navigator>"u"||!((Pe=navigator.clipboard)!=null&&Pe.writeText)))try{await navigator.clipboard.writeText(te),ye(!0),setTimeout(()=>ye(!1),1500)}catch{ye(!1)}}qe(()=>{const te=++O;if(!e.embedded&&!e.open){A=null,E=null,H=null,Qe();return}const ie=e.instanceId,Pe=Ae();if(!Pe){A=null,E=null,H=null,Qe();return}const ne=we(),me=Es(ne);A===ie&&E===Pe&&H===me||(Qe(),A=ie,E=Pe,H=me,xe(Pe,te,ne))}),qe(()=>{W()==="code"&&queueMicrotask(()=>B==null?void 0:B.focus())}),nt(()=>{O+=1,De()});async function xe(te,ie,Pe){const ne=()=>ie===O&&Ae()===te&&Ee(Pe);le(!0),M(null);try{const me={location:he(Pe)},[Be,lt,it]=await Promise.all([te.provider.list(me,Nt(Pe)),te.model.list(me,Nt(Pe)),te.integration.list(me,Nt(Pe))]);if(!ne())return;const Ve=l8(Be.data,lt.data,it.data).map(st=>({...st,models:c8(st.id,Be.data,lt.data)})),at=Object.fromEntries(it.data.map(st=>[st.id,st.methods.filter(vt=>vt.type!=="env")]));o(Ve),s(at),i(st=>{var vt,mt;return st??((vt=Ve[0])==null?void 0:vt.id)??((mt=it.data[0])==null?void 0:mt.id)??null})}catch(me){if(!ne())return;M(id(me,t("settings.providers.errors.loadFailed")))}finally{ne()&&le(!1)}}function De(){g+=1,x=null,Ce==null||Ce.abort(),Ce=null,je&&!je.closed&&je.close(),je=null}function Qe(){et(null),s({}),o([]),i(null),u(null),M(null),le(!1)}function et(te=null){var Pe,ne;if(te&&!((Pe=n()[te])!=null&&Pe.length))return;De(),l(te),w(0),b("");const ie=te?(ne=n()[te])==null?void 0:ne[0]:void 0;k(R0((ie==null?void 0:ie.type)==="command"||ie==null?void 0:ie.form)),C(null),D(null),q(null),ee(""),U(te?"prompts":"idle"),ce(null),Re(!1),ye(!1)}function Tt(te,ie){k(Pe=>{const ne={...Pe};return ie===void 0?delete ne[te]:ne[te]=ie,ne})}function He(te,ie,Pe){return te===g&&e.instanceId===ie&&Ae()===Pe}async function yt(te,ie,Pe,ne){He(Pe,ie,te)&&(e.location||await ha(ie,ne,!0).catch(()=>{}),He(Pe,ie,te)&&await xe(te,++O,we()).catch(()=>{}))}async function Qt(){const te=Ae(),ie=e.instanceId;if(!te)return;const Pe=we();le(!0),e.location||await ha(ie,Pe,!0).catch(()=>{}),!(Ae()!==te||e.instanceId!==ie)&&await xe(te,++O,Pe)}function Ot(){u(null),queueMicrotask(()=>{var te;h&&((te=f.get(h))==null||te.focus())})}async function Dn(te,ie,Pe,ne,me){await ie.integration.connect.key({integrationID:te,key:S().trim(),answer:I0(ot(),v()),location:he(me)},Nt(me)),He(ne,Pe,ie)&&(await yt(ie,Pe,ne,me),He(ne,Pe,ie)&&et(null))}async function Wn(te,ie,Pe,ne,me){const Be=Je();if(Be.type!=="oauth")throw new Error(t("settings.providers.errors.noAuthorization"));const lt=await ie.integration.oauth.connect({integrationID:te,methodID:Be.id,answer:I0(ot(),v()),location:he(me)},Nt(me));if(!He(ne,Pe,ie))return;const it=lt.data;if(!it)throw new Error(t("settings.providers.errors.noAuthorization"));const Ve={attemptID:it.attemptID,url:it.url,instructions:it.instructions,method:it.mode};C(Ve);const at=await I(it.url,{popup:je});if(He(ne,Pe,ie)){if(je=null,Re(!at),it.mode==="code"){U("code");return}for(U("waiting"),Ce=new AbortController;;){const st=await ie.integration.oauth.status({integrationID:te,attemptID:it.attemptID,location:he(me)},{...Nt(me),signal:Ce.signal});if(st.data.status==="complete")break;if(st.data.status==="failed")throw new Error(st.data.message);if(st.data.status==="expired")throw new Error(t("settings.providers.errors.authorizationFailed"));await new Promise(vt=>setTimeout(vt,1e3))}He(ne,Pe,ie)&&(Ce=null,await yt(ie,Pe,ne,me),He(ne,Pe,ie)&&et(null))}}async function Hn(te,ie,Pe,ne,me){const Be=Je();if(Be.type!=="command")throw new Error(t("settings.providers.errors.noAuthorization"));const lt=await ie.integration.command.connect({integrationID:te,methodID:Be.id,location:he(me)},Nt(me));if(!He(ne,Pe,ie))return;const it=lt.data.attemptID;for(D(it),q(null),U("waiting"),Ce=new AbortController;;){const Ve=await ie.integration.command.status({integrationID:te,attemptID:it,location:he(me)},{...Nt(me),signal:Ce.signal});if(Ve.data.status==="complete")break;if(Ve.data.status==="failed")throw new Error(Ve.data.message);if(Ve.data.status==="expired")throw new Error(t("settings.providers.errors.authorizationFailed"));q(Ve.data.message??null),await new Promise(at=>setTimeout(at,1e3))}He(ne,Pe,ie)&&(Ce=null,await yt(ie,Pe,ne,me),He(ne,Pe,ie)&&et(null))}async function Gn(){const te=c(),ie=Ae();if(!te||!ie||!_())return;const Pe=e.instanceId,ne=we(),me=++g;x=ne,U("authorizing"),ce(null);try{if(Je().type==="key"){await Dn(te,ie,Pe,me,ne);return}if(Je().type==="command"){await Hn(te,ie,Pe,me,ne);return}je=K(),Re(j()&&je===null),await Wn(te,ie,Pe,me,ne)}catch(Be){if(!He(me,Pe,ie))return;if(je&&!je.closed&&je.close(),je=null,H6(Be)){U("prompts");return}ce(id(Be,t("settings.providers.errors.authorizationFailed"))),U("error")}}async function dr(){var Be;const te=c(),ie=Ae();if(!te||!ie||!re().trim())return;const Pe=e.instanceId,ne=x;if(!ne)return;const me=++g;U("authorizing"),ce(null);try{const lt=(Be=$())==null?void 0:Be.attemptID;if(!lt)throw new Error(t("settings.providers.errors.noAuthorization"));if(await ie.integration.oauth.complete({integrationID:te,attemptID:lt,code:re().trim(),location:he(ne)},Nt(ne)),!He(me,Pe,ie))return;await yt(ie,Pe,me,ne),He(me,Pe,ie)&&et(null)}catch(lt){if(!He(me,Pe,ie))return;ce(id(lt,t("settings.providers.errors.authorizationFailed"))),U("code")}}async function mi(te){const ie=Ae(),Pe=r().find(lt=>lt.id===te);if(!ie||!Pe)return;const ne=e.instanceId,me=we();De();const Be=++g;ce(null),U("authorizing");try{const lt=Y(Pe);if(lt==="not-disconnectable"){ce(t("settings.providers.errors.envDisconnectUnavailable")),U("error");return}if(lt!=="credential-remove"||(await Promise.all(Pe.credentialIds.map(it=>ie.credential.remove({credentialID:it},Nt(me,{includeDirectory:!0})))),!He(Be,ne,ie)))return;await yt(ie,ne,Be,me),He(Be,ne,ie)&&et(null)}catch(lt){if(!He(Be,ne,ie))return;ce(id(lt,t("settings.providers.errors.removeFailed"))),U("idle")}}function ur(){var Be;const te=c(),ie=(Be=$())==null?void 0:Be.attemptID,Pe=T(),ne=Ae();e.instanceId;const me=x;te&&ie&&ne&&me&&ne.integration.oauth.cancel({integrationID:te,attemptID:ie,location:he(me)},Nt(me)).catch(()=>{}),te&&Pe&&ne&&me&&ne.integration.command.cancel({integrationID:te,attemptID:Pe,location:he(me)},Nt(me)).catch(()=>{}),De(),U("prompts"),C(null),D(null),q(null),ce(null)}function js(te){var ne;const ie=n()[te];if(!ie||ie.length===0){const me=((ne=r().find(Be=>Be.id===te))==null?void 0:ne.source)??"unknown";return t(`settings.providers.source.${me}`)}const Pe=new Set(ie.map(me=>me.type));return Pe.size>1?t("settings.providers.method.mixed"):Pe.has("oauth")?t("settings.providers.method.oauth"):Pe.has("command")?t("settings.providers.method.command"):t("settings.providers.method.api")}function pi(te){const ie=te.modelCount===1?t("settings.providers.models.one",{count:te.modelCount}):t("settings.providers.models.other",{count:te.modelCount});return[...new Set([js(te.id),Oe(te),ie].filter(Boolean))].join(" • ")}const Ba=()=>[y(Q,{get when(){return!e.embedded},get children(){var te=y8(),ie=te.firstChild,Pe=ie.firstChild,ne=Pe.firstChild,me=ie.nextSibling;return p(ie,y(JS,{class:"settings-card-heading-icon"}),Pe),p(Pe,y(_t.Title,{class:"providers-manager-title",get children(){return t("settings.providers.title")}}),ne),p(ne,()=>t("settings.providers.subtitle")),me.$$click=()=>P(!1),p(me,y(Ko,{class:"w-4 h-4"})),de(()=>pe(me,"aria-label",t("settings.close"))),te}}),(()=>{var te=M8();return p(te,y(Q,{get when(){return!Ae()},get children(){var ie=Fg();return p(ie,()=>t("settings.providers.empty.noInstance")),ie}}),null),p(te,y(Q,{get when(){return Ae()},get children(){return[(()=>{var ie=v8(),Pe=ie.firstChild,ne=Pe.nextSibling;return p(ie,y(Te,{get value(){return ve()},onChange:me=>me&&i(me.id),get options(){return Xe()},optionValue:"id",optionTextValue:"name",itemComponent:me=>y(Te.Item,{get item(){return me.item},class:"selector-option selector-option--multiline",get children(){var Be=A8(),lt=Be.firstChild,it=lt.firstChild,Ve=it.nextSibling,at=Ve.nextSibling,st=at.nextSibling,vt=st.nextSibling;return p(Be,y(Te.ItemLabel,{class:"selector-option-label",get children(){return me.item.rawValue.name}}),lt),p(it,()=>me.item.rawValue.id),p(at,(()=>{var mt=_e(()=>me.item.rawValue.modelCount===1);return()=>mt()?t("settings.providers.models.one",{count:me.item.rawValue.modelCount}):t("settings.providers.models.other",{count:me.item.rawValue.modelCount})})()),p(vt,()=>me.item.rawValue.connectionSummary),Be}}),get children(){return[y(Te.Trigger,{class:"selector-trigger providers-connect-select",get"aria-label"(){return t("settings.providers.selectProvider")},get children(){return[(()=>{var me=N0();return p(me,y(Te.Value,{children:Be=>(()=>{var lt=P8(),it=lt.firstChild;return p(it,()=>{var Ve;return((Ve=Be.selectedOption())==null?void 0:Ve.name)??t("settings.providers.selectProvider")}),p(lt,y(Q,{get when(){return Be.selectedOption()},get children(){var Ve=D8(),at=Ve.firstChild;return p(Ve,()=>{var st;return(st=Be.selectedOption())==null?void 0:st.id},at),p(Ve,()=>{var st;return(st=Be.selectedOption())==null?void 0:st.connectionSummary},null),Ve}}),null),lt})()})),me})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),Pe),Pe.$$click=()=>{var me;return et(((me=ve())==null?void 0:me.id)??null)},p(Pe,()=>t("settings.providers.actions.connect")),ne.$$click=()=>void Qt(),p(ne,y(_d,{get class(){return J()?"providers-spin-icon":"providers-button-icon"}}),null),p(ne,()=>t("settings.providers.refresh"),null),de(me=>{var it;var Be=!((it=ve())!=null&&it.canConnect),lt=J();return Be!==me.e&&(Pe.disabled=me.e=Be),lt!==me.t&&(ne.disabled=me.t=lt),me},{e:void 0,t:void 0}),ie})(),y(Q,{get when(){return z()},get children(){var ie=U0();return p(ie,z),ie}}),y(Q,{get when(){return N()},get children(){var ie=U0();return p(ie,N),ie}}),y(Q,{get when(){return c()},get children(){var ie=E8(),Pe=ie.firstChild,ne=Pe.firstChild,me=ne.firstChild,Be=me.nextSibling,lt=ne.nextSibling,it=Pe.nextSibling;return p(me,()=>t("settings.providers.auth.title",{provider:Ie()})),p(Be,()=>t("settings.providers.auth.subtitle")),lt.$$click=()=>et(null),p(lt,y(Ko,{class:"w-4 h-4"})),p(ie,y(Q,{get when(){return ze().length>1},get children(){var Ve=w8(),at=Ve.firstChild,st=at.firstChild,vt=st.nextSibling;return p(st,()=>t("settings.providers.method.title")),p(vt,()=>t("settings.providers.method.subtitle")),p(Ve,y(Te,{get value(){return Ne()},onChange:mt=>{mt&&(w(mt.index),k(R0(mt.method.type==="command"?void 0:mt.method.form)),b(""),C(null),ee(""),U("prompts"),ce(null))},get options(){return ze()},optionValue:"value",optionTextValue:"label",get disabled(){return _e(()=>W()!=="prompts")()&&W()!=="error"},itemComponent:mt=>y(Te.Item,{get item(){return mt.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return mt.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger providers-method-trigger",get"aria-label"(){return t("settings.providers.method.title")},get children(){return[(()=>{var mt=N0();return p(mt,y(Te.Value,{children:Pn=>(()=>{var On=O8();return p(On,()=>{var Nv;return(Nv=Pn.selectedOption())==null?void 0:Nv.label}),On})()})),mt})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),null),Ve}}),it),p(ie,y(Q,{get when(){return Je().type==="key"},get children(){var Ve=b8(),at=Ve.firstChild,st=at.firstChild,vt=st.nextSibling,mt=vt.firstChild;return p(st,()=>t("settings.providers.apiKey.label")),p(vt,y(uA,{class:"providers-input-icon"}),mt),mt.$$input=Pn=>b(Pn.currentTarget.value),de(()=>pe(mt,"placeholder",t("settings.providers.apiKey.placeholder"))),de(()=>mt.value=S()),Ve}}),it),p(ie,y(Q,{get when(){return ot()},get children(){return y(a8,{get fields(){return ot()},get answer(){return v()},get disabled(){return _e(()=>W()!=="prompts")()&&W()!=="error"},onAnswer:Tt})}}),it),p(ie,y(Q,{get when(){return _e(()=>Je().type==="oauth"&&!ot())()&&(W()==="prompts"||W()==="error"||W()==="authorizing")},get children(){var Ve=Fg();return p(Ve,()=>t("settings.providers.oauth.noPrompts")),Ve}}),it),p(ie,y(Q,{get when(){return _e(()=>Je().type==="command")()&&(W()==="prompts"||W()==="error"||W()==="authorizing")},get children(){var Ve=S8(),at=Ve.firstChild,st=at.nextSibling;return p(at,()=>t("settings.providers.command.description")),p(st,()=>{var vt;return(vt=gt())==null?void 0:vt.command.join(" ")}),Ve}}),it),p(ie,y(Q,{get when(){return W()==="code"},get children(){var Ve=k8(),at=Ve.firstChild,st=at.firstChild,vt=at.nextSibling,mt=vt.firstChild,Pn=mt.nextSibling;return p(at,y(Oi,{class:"providers-instructions-icon"}),st),p(st,()=>{var On;return((On=$())==null?void 0:On.instructions)||t("settings.providers.oauth.enterCode")}),p(mt,()=>t("settings.providers.oauth.codeLabel")),Pn.$$input=On=>ee(On.currentTarget.value),Xs(On=>{B=On},Pn),de(()=>pe(Pn,"placeholder",t("settings.providers.oauth.codePlaceholder"))),de(()=>Pn.value=re()),Ve}}),it),p(ie,y(Q,{get when(){return W()==="waiting"},get children(){var Ve=x8(),at=Ve.firstChild,st=at.firstChild,vt=st.nextSibling,mt=at.nextSibling;return p(Ve,y(Nn,{class:"providers-spin-icon"}),at),p(st,(()=>{var Pn=_e(()=>Je().type==="command");return()=>Pn()?t("settings.providers.command.waitingTitle"):t("settings.providers.oauth.waitingTitle")})()),p(vt,(()=>{var Pn=_e(()=>Je().type==="command");return()=>{var On;return Pn()?R()??t("settings.providers.command.waitingMessage"):(On=$())==null?void 0:On.instructions}})()),mt.$$click=ur,p(mt,()=>t("settings.providers.oauth.cancelWait")),Ve}}),it),p(ie,y(Q,{get when(){return _e(()=>!!($()&&Pm($().url)))()&&(W()==="code"||W()==="waiting")},get children(){var Ve=$8(),at=Ve.firstChild,st=at.nextSibling,vt=st.nextSibling;return p(at,y(Oi,{class:"w-4 h-4"}),null),p(at,()=>t("settings.providers.oauth.openPage"),null),st.$$click=()=>void I($().url,{sameTab:!0}),p(st,()=>t("settings.providers.oauth.openHere")),vt.$$click=()=>void Z(),p(vt,(()=>{var mt=_e(()=>!!be());return()=>mt()?t("settings.providers.oauth.linkCopied"):t("settings.providers.oauth.copyLink")})()),de(()=>{var mt;return pe(at,"href",(mt=$())==null?void 0:mt.url)}),Ve}}),it),p(ie,y(Q,{get when(){return _e(()=>!!fe())()&&$()},get children(){var Ve=_8();return p(Ve,()=>t("settings.providers.oauth.popupBlocked")),Ve}}),it),p(ie,y(Q,{get when(){return W()==="success"},get children(){var Ve=C8(),at=Ve.firstChild;return p(Ve,y(ZS,{class:"providers-success-icon"}),at),p(at,()=>t("settings.providers.success")),Ve}}),it),p(it,y(Q,{get when(){return W()==="code"},get fallback(){return(()=>{var Ve=B0();return Ve.$$click=()=>void Gn(),p(Ve,y(Q,{get when(){return W()==="authorizing"},get fallback(){return t("settings.providers.actions.continue")},get children(){return[y(Nn,{class:"providers-spin-icon"}),_e(()=>t("settings.providers.actions.working"))]}})),de(()=>Ve.disabled=!_()),Ve})()},get children(){var Ve=B0();return Ve.$$click=()=>void dr(),p(Ve,()=>t("settings.providers.oauth.submitCode")),de(()=>Ve.disabled=!re().trim()),Ve}})),de(Ve=>{var at=t("settings.providers.actions.close"),st=t("settings.providers.actions.close");return at!==Ve.e&&pe(lt,"aria-label",Ve.e=at),st!==Ve.t&&pe(lt,"title",Ve.t=st),Ve},{e:void 0,t:void 0}),ie}}),(()=>{var ie=T8(),Pe=ie.firstChild;return p(Pe,()=>t("settings.providers.configured.title")),p(ie,y(Q,{get when(){return V()},get fallback(){return[y(Q,{get when(){return J()},get children(){var ne=R8(),me=ne.firstChild;return p(ne,y(Nn,{class:"providers-spin-icon"}),me),p(me,()=>t("settings.providers.loading")),ne}}),y(Q,{get when(){return _e(()=>!J())()&&se().length===0},get children(){var ne=Fg();return p(ne,()=>t("settings.providers.empty.noConfiguredProviders")),ne}}),(()=>{var ne=I8();return p(ne,y(Ut,{get each(){return se()},children:me=>(()=>{var Be=U8(),lt=Be.firstChild,it=lt.firstChild,Ve=it.nextSibling,at=lt.nextSibling,st=at.firstChild;return p(it,()=>me.name||me.id),p(Ve,y(Q,{get when(){return _e(()=>!!me.name)()&&me.name!==me.id},get children(){return[(()=>{var vt=L8();return p(vt,()=>me.id),vt})(),F8()]}}),null),p(Ve,()=>pi(me),null),st.$$click=()=>{h=me.id,u(me.id)},Xs(vt=>f.set(me.id,vt),st),p(st,()=>t("settings.providers.actions.manageModels")),p(at,y(Q,{get when(){return Y(me)==="credential-remove"},get children(){var vt=N8();return vt.$$click=()=>void mi(me.id),p(vt,()=>t("settings.providers.actions.disconnect")),de(mt=>{var Pn=W()!=="idle",On=t("settings.providers.actions.disconnect");return Pn!==mt.e&&(vt.disabled=mt.e=Pn),On!==mt.t&&pe(vt,"title",mt.t=On),mt},{e:void 0,t:void 0}),vt}}),null),Be})()})),ne})()]},children:ne=>y(p8,{get providerId(){return ne().id},get providerName(){return ne().name||ne().id},get models(){return ne().models},onBack:Ot})}),null),ie})()]}}),null),te})()];return e.embedded?(()=>{var te=B8();return p(te,Ba),te})():y(_t,{get open(){return!!e.open},onOpenChange:P,get children(){return y(_t.Portal,{get children(){return[y(_t.Overlay,{class:"modal-overlay"}),y(_t.Content,{class:"modal-surface providers-manager-modal",get children(){return Ba()}})]}})}})};Ht(["click","input"]);const V8=e=>y(K8,{get instanceId(){return e.instanceId??bs()??""},get location(){return e.location},embedded:!0});var j8=F('<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 q8=()=>{const{t:e}=kt();return Ns(()=>void Gs()),(()=>{var t=j8(),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(HS,{})),t})()};var z8=F('<div class="flex-1 min-w-0">'),W8=F('<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>'),H8=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const G8=()=>{const{t:e}=kt(),{serverSettings:t,updateLogLevel:n}=Tn(),s=$e(()=>[{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=$e(()=>s().find(o=>o.value===t().logLevel)??s()[0]);return(()=>{var o=W8(),a=o.firstChild,i=a.firstChild,c=i.firstChild,l=c.firstChild,d=l.nextSibling,u=c.nextSibling,f=i.nextSibling,h=f.firstChild,m=h.firstChild,w=m.firstChild,S=w.nextSibling;return p(o,y(ek,{}),a),p(o,y(q8,{}),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(h,y(Te,{get value(){return r()},onChange:b=>b&&n(b.value),get options(){return s()},optionValue:"value",optionTextValue:"label",itemComponent:b=>y(Te.Item,{get item(){return b.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return b.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger",get"aria-label"(){return e("settings.opencode.logLevel.title")},get children(){return[(()=>{var b=z8();return p(b,y(Te.Value,{children:v=>(()=>{var k=H8();return p(k,()=>{var $;return($=v.selectedOption())==null?void 0:$.label}),k})()})),b})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),null),o})()};var Z8=F("<div class=space-y-2>"),J8=F('<div class="text-xs text-muted text-center py-2">'),Y8=F('<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">'),Q8=F('<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 X8=e=>{const{t}=kt(),{serverSettings:n,addEnvironmentVariable:s,removeEnvironmentVariable:r,updateEnvironmentVariables:o,isSecureEnvVar:a,toggleSecureEnvVar:i}=Tn(),[c,l]=L(n().environmentVariables||{}),[d,u]=L(""),[f,h]=L(""),[m,w]=L(!0),S=()=>Object.entries(c());function b(){const T=d().trim(),D=f().trim();T&&(s(T,D,m()),l({...c(),[T]:D}),u(""),h(""),w(!0))}function v(T){r(T);const{[T]:D,...R}=c();l(R)}function k(T,D){const R={...c(),[T]:D};l(R),o(R)}function $(T){i(T)}function C(T){T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),b())}return(()=>{var T=Y8(),D=T.firstChild,R=D.firstChild,q=R.nextSibling,re=D.nextSibling,ee=re.firstChild,W=ee.firstChild,U=W.nextSibling,J=ee.nextSibling,le=J.nextSibling,z=re.nextSibling;return p(D,y(Bo,{class:"w-4 h-4 icon-muted"}),R),p(R,()=>t("envEditor.title")),p(q,(()=>{var M=_e(()=>S().length===1);return()=>M()?t("envEditor.count.one",{count:S().length}):t("envEditor.count.other",{count:S().length})})()),p(T,y(Q,{get when(){return S().length>0},get children(){var M=Z8();return p(M,y(Ut,{get each(){return S()},children:([N,ce])=>(()=>{var fe=Q8(),Re=fe.firstChild,be=Re.firstChild,ye=be.nextSibling,Ce=Re.nextSibling,je=Ce.nextSibling;return p(Re,y(mw,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),be),be.value=N,ye.$$input=O=>k(N,O.currentTarget.value),ye.value=ce,Ce.$$click=()=>$(N),p(Ce,(()=>{var O=_e(()=>!!a(N));return()=>O()?y(Cd,{class:"w-3.5 h-3.5"}):y(yw,{class:"w-3.5 h-3.5"})})()),je.$$click=()=>v(N),p(je,y(Tu,{class:"w-3.5 h-3.5"})),de(O=>{var g=e.disabled,x=t("envEditor.fields.name.placeholder"),A=t("envEditor.fields.name.readOnlyTitle"),E=a(N)?"password":"text",H=e.disabled,B=t("envEditor.fields.value.placeholder"),oe=a(N)?"new-password":"off",Ae=a(N)?!1:void 0,we=a(N)?"off":void 0,he=e.disabled,Ee=`p-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${a(N)?"icon-accent-hover text-accent":"icon-muted icon-accent-hover"}`,Ge=a(N)?t("envEditor.fields.secure.enabled"):t("envEditor.fields.secure.disabled"),Xe=e.disabled,se=t("envEditor.actions.remove.title");return g!==O.e&&(be.disabled=O.e=g),x!==O.t&&pe(be,"placeholder",O.t=x),A!==O.a&&pe(be,"title",O.a=A),E!==O.o&&pe(ye,"type",O.o=E),H!==O.i&&(ye.disabled=O.i=H),B!==O.n&&pe(ye,"placeholder",O.n=B),oe!==O.s&&pe(ye,"autocomplete",O.s=oe),Ae!==O.h&&pe(ye,"spellcheck",O.h=Ae),we!==O.r&&pe(ye,"autocapitalize",O.r=we),he!==O.d&&(Ce.disabled=O.d=he),Ee!==O.l&&_s(Ce,O.l=Ee),Ge!==O.u&&pe(Ce,"title",O.u=Ge),Xe!==O.c&&(je.disabled=O.c=Xe),se!==O.w&&pe(je,"title",O.w=se),O},{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}),fe})()})),M}}),re),p(ee,y(mw,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),W),W.addEventListener("keypress",C),W.$$input=M=>u(M.currentTarget.value),U.addEventListener("keypress",C),U.$$input=M=>h(M.currentTarget.value),J.$$click=()=>w(!m()),p(J,(()=>{var M=_e(()=>!!m());return()=>M()?y(Cd,{class:"w-3.5 h-3.5"}):y(yw,{class:"w-3.5 h-3.5"})})()),le.$$click=b,p(le,y(Eu,{class:"w-3.5 h-3.5"})),p(T,y(Q,{get when(){return S().length===0},get children(){var M=J8();return p(M,()=>t("envEditor.empty")),M}}),z),p(z,()=>t("envEditor.help")),de(M=>{var N=e.disabled,ce=t("envEditor.fields.name.placeholder"),fe=m()?"password":"text",Re=e.disabled,be=t("envEditor.fields.value.placeholder"),ye=e.disabled,Ce=`p-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${m()?"icon-accent-hover text-accent":"icon-muted icon-accent-hover"}`,je=m()?t("envEditor.fields.secure.enabled"):t("envEditor.fields.secure.disabled"),O=e.disabled||!d().trim(),g=t("envEditor.actions.add.title");return N!==M.e&&(W.disabled=M.e=N),ce!==M.t&&pe(W,"placeholder",M.t=ce),fe!==M.a&&pe(U,"type",M.a=fe),Re!==M.o&&(U.disabled=M.o=Re),be!==M.i&&pe(U,"placeholder",M.i=be),ye!==M.n&&(J.disabled=M.n=ye),Ce!==M.s&&_s(J,M.s=Ce),je!==M.h&&pe(J,"title",M.h=je),O!==M.r&&(le.disabled=M.r=O),g!==M.d&&pe(le,"title",M.d=g),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(()=>W.value=d()),de(()=>U.value=f()),T})()};Ht(["input","click"]);var e9=F('<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 t9=()=>{const{t:e}=kt(),t=Tn(),n=$e(()=>[...yp(t).filter(s=>s.id==="behavior.autoCleanupBlankSessions"||s.id==="behavior.keepUnseenSubagentIdleStatus"||s.id==="behavior.focusExistingWindowOnSecondLaunch"&&qE()||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=e9(),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(X8,{}),null),p(u,y(vp,{settings:n,get preferences(){return t.preferences}})),s})()};var n9=F("<div class=config-files-selector-value>"),s9=F('<span class="config-files-state config-files-state-inline">'),r9=F('<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">'),o9=F('<div class=selector-option-content><div class="selector-option-description config-files-selector-path">'),i9=F('<span class=config-files-selector-value-inner><span class="selector-trigger-primary selector-trigger-primary--align-left">'),a9=F('<span class="selector-trigger-secondary config-files-selector-path">'),c9=F("<div class=settings-error-message>"),K0=F("<div class=config-files-editor-empty>"),l9=F('<div class="file-viewer-content file-viewer-content--monaco config-files-editor-content">');const d9=gS(()=>ts(()=>import("./monaco-viewer-BtzCmjFO.js").then(e=>e.as),__vite__mapDeps([1,2,3,4,5])).then(e=>({default:e.MonacoFileViewer}))),u9=()=>{const{t:e}=kt(),[t,n]=L([]),[s,r]=L(null),[o,a]=L(""),[i,c]=L(""),[l,d]=L(null),[u,f]=L(!1),[h,m]=L(!1),[w,S]=L(!1),[b,v]=L(null);let k=0;const $=$e(()=>t().find(U=>U.id===s())??null),C=$e(()=>o()!==i()),T=async U=>{const J=++k;m(!0),v(null);try{const le=await ft.readConfigFile(U.id);if(J!==k)return;r(U.id),a(le.contents),c(le.contents),d(le.exists)}catch(le){if(J!==k)return;v(le instanceof Error?le.message:e("settings.configFiles.errors.loadContent")),a(""),c(""),d(null)}finally{J===k&&m(!1)}},D=async()=>C()?Wi(e("settings.configFiles.confirmDiscard.message"),{variant:"warning",confirmLabel:e("settings.configFiles.confirmDiscard.confirmLabel"),cancelLabel:e("settings.configFiles.confirmDiscard.cancelLabel"),dismissible:!1}):!0,R=async()=>{f(!0),v(null);try{const U=await ft.listConfigFiles();n(U);const J=U[0];J&&await T(J)}catch(U){v(U instanceof Error?U.message:e("settings.configFiles.errors.loadList"))}finally{f(!1)}},q=async U=>{!U||U.id===s()||!await D()||await T(U)},re=async()=>{const U=$();!U||!await D()||await T(U)},ee=async()=>{const U=$();if(!U)return;const J=o();S(!0),v(null);try{await ft.writeConfigFile(U.id,J),o()===J&&c(J),d(!0),Fn({message:e("settings.configFiles.toast.saveSuccess"),variant:"success"})}catch(le){v(le instanceof Error?le.message:e("settings.configFiles.errors.save")),Fn({message:e("settings.configFiles.toast.saveError"),variant:"error"})}finally{S(!1)}};Ns(()=>{R()});const W=Bk(D);return nt(W),(()=>{var U=r9(),J=U.firstChild,le=J.nextSibling,z=le.firstChild,M=z.firstChild,N=M.nextSibling,ce=N.firstChild,fe=ce.nextSibling,Re=z.nextSibling;return p(J,()=>e("settings.configFiles.title")),p(M,y(Te,{get value(){return $()??void 0},onChange:be=>void q(be),get options(){return t()},optionValue:"id",optionTextValue:"label",get disabled(){return u()||t().length===0},itemComponent:be=>y(Te.Item,{get item(){return be.item},class:"selector-option",get children(){var ye=o9(),Ce=ye.firstChild;return p(ye,y(Te.ItemLabel,{class:"selector-option-label",get children(){return be.item.rawValue.label}}),Ce),p(Ce,()=>be.item.rawValue.path),ye}}),get children(){return[y(Te.Trigger,{class:"selector-trigger config-files-selector-trigger",get"aria-label"(){return e("settings.configFiles.selector.label")},get children(){return[(()=>{var be=n9();return p(be,y(Te.Value,{children:ye=>(()=>{var Ce=i9(),je=Ce.firstChild;return p(je,()=>{var O;return((O=ye.selectedOption())==null?void 0:O.label)??e("settings.configFiles.selector.placeholder")}),p(Ce,y(Q,{get when(){return ye.selectedOption()},children:O=>(()=>{var g=a9();return p(g,()=>O().path),g})()}),null),Ce})()})),be})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})),p(N,y(Q,{get when(){return _e(()=>!!$())()&&(C()||l()===!1)},get children(){var be=s9();return p(be,(()=>{var ye=_e(()=>!!C());return()=>ye()?e("settings.configFiles.state.unsaved"):e("settings.configFiles.state.notCreated")})()),be}}),ce),ce.$$click=()=>void ee(),p(ce,y(Q,{get when(){return w()},get fallback(){return y(BA,{class:"h-4 w-4"})},get children(){return y(_d,{class:"h-4 w-4 animate-spin"})}})),fe.$$click=()=>void re(),p(fe,y(_d,{get class(){return`h-4 w-4${h()?" animate-spin":""}`}})),p(le,y(Q,{get when(){return b()},children:be=>(()=>{var ye=c9();return p(ye,be),ye})()}),Re),p(Re,y(Q,{get when(){return _e(()=>!u()&&!h())()&&$()},get fallback(){return(()=>{var be=K0();return p(be,(()=>{var ye=_e(()=>!!(u()||h()));return()=>ye()?e("instanceInfo.loading"):e("settings.configFiles.empty")})()),be})()},children:be=>(()=>{var ye=l9();return p(ye,y(hT,{get fallback(){return(()=>{var Ce=K0();return p(Ce,()=>e("instanceInfo.loading")),Ce})()},get children(){return y(d9,{scopeKey:"settings-config-files",get path(){return be().path},get content(){return o()},wordWrap:"off",compactGutter:!0,onSave:()=>void ee(),onContentChange:Ce=>a(Ce)})}})),ye})()})),de(be=>{var ye=e("settings.configFiles.actions.save"),Ce=e("settings.configFiles.actions.save"),je=!$()||w()||h()||!C(),O=e("settings.configFiles.actions.reload"),g=e("settings.configFiles.actions.reload"),x=!$()||h()||w();return ye!==be.e&&pe(ce,"title",be.e=ye),Ce!==be.t&&pe(ce,"aria-label",be.t=Ce),je!==be.a&&(ce.disabled=be.a=je),O!==be.o&&pe(fe,"title",be.o=O),g!==be.i&&pe(fe,"aria-label",be.i=g),x!==be.n&&(fe.disabled=be.n=x),be},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),U})()};Ht(["click"]);function f9(e={}){const[t,n]=DS({value:()=>ge(e.isSelected),defaultValue:()=>!!ge(e.defaultIsSelected),onChange:o=>{var a;return(a=e.onSelectedChange)==null?void 0:a.call(e,o)}});return{isSelected:t,setIsSelected:o=>{!ge(e.isReadOnly)&&!ge(e.isDisabled)&&n(o)},toggle:()=>{!ge(e.isReadOnly)&&!ge(e.isDisabled)&&n(!t())}}}var g9={};el(g9,{Control:()=>mE,Description:()=>pE,ErrorMessage:()=>yE,Input:()=>vE,Label:()=>wE,Root:()=>bE,Switch:()=>lc,Thumb:()=>SE,useSwitchContext:()=>hi});var hE=Ir();function hi(){const e=Lr(hE);if(e===void 0)throw new Error("[kobalte]: `useSwitchContext` must be used within a `Switch` component");return e}function mE(e){const t=or(),n=hi(),s=Dt({id:n.generateId("control")},e),[r,o]=Et(s,["onClick","onKeyDown"]);return y(zt,Se({as:"div",onClick:c=>{var l;Zt(c,r.onClick),n.toggle(),(l=n.inputRef())==null||l.focus()},onKeyDown:c=>{var l;Zt(c,r.onKeyDown),c.key===qm.Space&&(n.toggle(),(l=n.inputRef())==null||l.focus())}},()=>t.dataset(),()=>n.dataset(),o))}function pE(e){const t=hi();return y(rp,Se(()=>t.dataset(),e))}function yE(e){const t=hi();return y(mp,Se(()=>t.dataset(),e))}function vE(e){const t=or(),n=hi(),s=Dt({id:n.generateId("input")},e),[r,o,a]=Et(s,["ref","style","onChange","onFocus","onBlur"],Ck),{fieldProps:i}=Ek(o);return y(zt,Se({as:"input",ref(u){var f=Mn(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 Qc({...$u},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=>{Zt(u,r.onChange),u.stopPropagation();const f=u.target;n.setIsChecked(f.checked),f.checked=n.checked()},onFocus:u=>{Zt(u,r.onFocus),n.setIsFocused(!0)},onBlur:u=>{Zt(u,r.onBlur),n.setIsFocused(!1)}},()=>t.dataset(),()=>n.dataset(),a))}function wE(e){const t=hi();return y(Tk,Se(()=>t.dataset(),e))}function bE(e){let t;const n=`switch-${ti()}`,s=Dt({value:"on",id:n},e),[r,o,a]=Et(s,["ref","children","value","checked","defaultChecked","onChange","onPointerDown"],ck),[i,c]=L(),[l,d]=L(!1),{formControlContext:u}=lk(o),f=f9({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()});Mk(()=>t,()=>f.setIsSelected(r.defaultChecked??!1));const h=S=>{Zt(S,r.onPointerDown),l()&&S.preventDefault()},m=$e(()=>({"data-checked":f.isSelected()?"":void 0})),w={value:()=>r.value,dataset:m,checked:()=>f.isSelected(),inputRef:i,generateId:Ea(()=>ge(o.id)),toggle:()=>f.toggle(),setIsChecked:S=>f.setIsSelected(S),setIsFocused:d,setInputRef:c};return y(sp.Provider,{value:u,get children(){return y(hE.Provider,{value:w,get children(){return y(zt,Se({as:"div",ref(S){var b=Mn(v=>t=v,r.ref);typeof b=="function"&&b(S)},role:"group",get id(){return ge(o.id)},onPointerDown:h},()=>u.dataset(),m,a,{get children(){return y(h9,{state:w,get children(){return r.children}})}}))}})}})}function h9(e){const t=fS(()=>{const n=e.children;return xu(n)?n(e.state):n});return _e(t)}function SE(e){const t=or(),n=hi(),s=Dt({id:n.generateId("thumb")},e);return y(zt,Se({as:"div"},()=>t.dataset(),()=>n.dataset(),s))}var lc=Object.assign(bE,{Control:mE,Description:pE,ErrorMessage:yE,Input:vE,Label:wE,Thumb:SE}),m9=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},kE={},os={};let Av;const p9=[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];os.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};os.getSymbolTotalCodewords=function(t){return p9[t]};os.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};os.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Av=t};os.isKanjiModeEnabled=function(){return typeof Av<"u"};os.toSJIS=function(t){return Av(t)};var Kf={};(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}}})(Kf);function xE(){this.buffer=[],this.length=0}xE.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 y9=xE;function Tl(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)}Tl.prototype.set=function(e,t,n,s){const r=e*this.size+t;this.data[r]=n,s&&(this.reservedBit[r]=!0)};Tl.prototype.get=function(e,t){return this.data[e*this.size+t]};Tl.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Tl.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var v9=Tl,$E={};(function(e){const t=os.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}})($E);var _E={};const w9=os.getSymbolSize,V0=7;_E.getPositions=function(t){const n=w9(t);return[[0,0],[n-V0,0],[0,n-V0]]};var CE={};(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 h=r.get(u,f);h===l?i++:(i>=5&&(a+=t.N1+(i-5)),l=h,i=1),h=r.get(f,u),h===d?c++:(c>=5&&(a+=t.N1+(c-5)),d=h,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}})(CE);var Vf={};const Zr=Kf,ad=[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];Vf.getBlocksCount=function(t,n){switch(n){case Zr.L:return ad[(t-1)*4+0];case Zr.M:return ad[(t-1)*4+1];case Zr.Q:return ad[(t-1)*4+2];case Zr.H:return ad[(t-1)*4+3];default:return}};Vf.getTotalCodewordsCount=function(t,n){switch(n){case Zr.L:return cd[(t-1)*4+0];case Zr.M:return cd[(t-1)*4+1];case Zr.Q:return cd[(t-1)*4+2];case Zr.H:return cd[(t-1)*4+3];default:return}};var EE={},jf={};const Sc=new Uint8Array(512),yu=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Sc[n]=t,yu[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Sc[n]=Sc[n-255]})();jf.log=function(t){if(t<1)throw new Error("log("+t+")");return yu[t]};jf.exp=function(t){return Sc[t]};jf.mul=function(t,n){return t===0||n===0?0:Sc[yu[t]+yu[n]]};(function(e){const t=jf;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}})(EE);const TE=EE;function Dv(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Dv.prototype.initialize=function(t){this.degree=t,this.genPoly=TE.generateECPolynomial(this.degree)};Dv.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=TE.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 b9=Dv,ME={},$o={},Pv={};Pv.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var lr={};const AE="[0-9]+",S9="[A-Z $%*+\\-./:]+";let Jc="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Jc=Jc.replace(/u/g,"\\u");const k9="(?:(?![A-Z0-9 $%*+\\-./:]|"+Jc+`)(?:.|[\r
34
+ `)}function xq(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[lH,MC]=L(null),M0=new Map;function $q(e){MC(e)}function dH(){MC(null)}function _q(e){const t=e.id,n=e.error,s=Sq(n,ke("app.launchError.fallbackMessage"),ke("app.launchError.invalidConfig"),ke("opencodeBinarySelector.validation.v2Required")),r=M0.get(t);if(r&&r===s)return;M0.set(t,s);const o=(e.binaryLabel||e.binaryId||"opencode2").trim()||"opencode2",a=xq(s);$q({source:"workspace",instanceId:t,message:s,binaryPath:o,missingBinary:a})}const Em=Lt("session"),Za=new Map,Ja=new Map;function Cq(e){return Es(e)}function AC(e,t){var s;if(!e)return!1;const n=(s=e.mcpStatus)==null?void 0:s.location;return!!(n&&Es(n)===Es(t))}function Eq(e,t){return!e||e.project===void 0||e.mcpStatus===void 0||e.plugins===void 0?!1:!t||AC(e,t)}function DC(e,t){const n=e.client;if(!n)return Em.warn("[metadata] Skipping fetch; client missing",{instanceId:e.id}),Promise.resolve();const s=(t==null?void 0:t.location)??{directory:e.folder},r=Cq(s),o=Yr(e.id)??e.metadata;if(!(t!=null&&t.force)&&Eq(o,s))return Promise.resolve();const a=zd(e.id),i=Za.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=wo(s),[u,f,h,m]=await Promise.allSettled([PC(e,t),n.project.list(),n.mcp.list({location:d},Nt(s)),n.plugin.list({location:d},Nt(s))]),w=(l=Yr(e.id))==null?void 0:l.project,S=w&&f.status==="fulfilled"?f.value.find($=>$.id===w.id):void 0,b=m.status==="fulfilled"?m.value.data.flatMap($=>{var T;return(((T=$.state)==null?void 0:T.status)??$.status)==="active"&&typeof $.id=="string"&&!$.id.startsWith("opencode.")?[$.id]:[]}):void 0,v=Yr(e.id)??o,k={...v??{}};if(v&&!AC(v,s)&&(k.mcpStatus=void 0,k.plugins=void 0),u.status==="fulfilled"&&w&&(S!=null&&S.vcs)&&(k.project={...w,vcs:S.vcs}),h.status==="fulfilled"&&(k.mcpStatus=h.value),m.status==="fulfilled"&&(k.plugins=b??[]),!(k!=null&&k.version)&&e.binaryVersion&&(k.version=e.binaryVersion),Za.get(e.id)!==c||zd(e.id)!==a)return;Ix(e.id,k)}catch(d){Em.error("Failed to load instance metadata",d)}finally{Za.get(e.id)===c&&Za.delete(e.id)}})(),Za.set(e.id,c),c.promise}function PC(e,t){const n=e.client;if(!n)return Promise.resolve();const s=Yr(e.id)??e.metadata;if(!(t!=null&&t.force)&&s&&"project"in s)return Promise.resolve();const r=zd(e.id),o=Ja.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=>{Ja.get(e.id)!==a||zd(e.id)!==r||Ix(e.id,{project:i.project,...!(s!=null&&s.version)&&e.binaryVersion?{version:e.binaryVersion}:{}})}).catch(i=>Em.warn("Failed to load project metadata",{instanceId:e.id,error:i})).finally(()=>{Ja.get(e.id)===a&&Ja.delete(e.id)}),Ja.set(e.id,a),a.promise}const[Tq,fv]=L(new Map);function Br(e){return Tq().get(e)??[]}function Mq(e,t){fv(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 Aq(e,t){fv(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 Dq(e,t){fv(n=>{const s=new Map(n);return t.length?s.set(e,[...t]):s.delete(e),s})}function Pq(e){Dq(e,[])}function OC(e){var t;if(!(e.sessionID!=="global"||!e.location))return{headers:{"x-opencode-directory":encodeURIComponent(e.location.directory),...(t=Nt(e.location))==null?void 0:t.headers}}}const[Oq,Rq]=L(new Map);function Iq(e){Rq(t=>{const n=new Map(t);return n.set(e,(n.get(e)??0)+1),n})}function uH(e){return Oq().get(e)??0}function fH(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[gH,RC]=L(new Set),Tm=new Set;function hH(e){RC(t=>t.has(e)?t:new Set(t).add(e))}function Lq(e){RC(t=>{if(!t.has(e))return t;const n=new Set(t);return n.delete(e),n})}function mH(e){return Tm.add(e),()=>Tm.delete(e)}function Fq(e){for(const t of Tm)t(e)}async function Nq(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 Mm=new Set;function pH(e){return Mm.add(e),()=>Mm.delete(e)}function Am(e){for(const t of Mm)t(e)}class Uq extends Error{constructor(t){super(t),this.name="RestoreTimeoutError"}}function Bi(e){if(e.reason instanceof Error)return e.reason;const t=new Error("Restore operation was aborted");return t.name="AbortError",t}function Bq(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=Bi(t.signal);r.abort(u),a(()=>s(u))},c=t.timeoutMs===void 0?void 0:setTimeout(()=>{const u=new Uq(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 Kq=[250,1e3,2e3];class Vq{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??Kq;let o=0;try{await jm(()=>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 jq{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 qq(e){try{await e}catch{}}function zq(e){return jm(()=>ft.cancelWorkspaceCreation(e),{maxAttempts:4,initialDelayMs:250,maxDelayMs:2e3,backoffMultiplier:4})}const A0=e=>e==="error"||e==="stopped"?3:e==="ready"?2:1;function D0(e,t){const n=A0(t.status)-A0(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 Wq{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:wa(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?D0(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=wa(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?D0(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 Hq{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 It=Lt("api");vq((e,t)=>{const n=Fe().get(e);return n?yq(t,s=>n.get(s)):t});fs.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"||(It.info(`[SSE] Yolo state changed: ${t}:${n} -> ${s}`),zc(t,n,s))});fs.on("yolo.autoAccepted",e=>{if(e.type!=="yolo.autoAccepted")return;const{instanceId:t,permissionId:n}=e;typeof t!="string"||typeof n!="string"||(Rf(t,n),Cl(t,n),zu(t,n))});const[Ue,gv]=L(new Map),[bs,IC]=L(null),[LC,Lf]=L(new Map),[Gq,hv]=L(new Map),Zq=250,No=new Map;function FC(e,t){return`${e}\0${t}`}function Jq(e,t,n){const s=FC(e,t),r=No.get(s);if(r){r.project=n;return}const o={project:n,timeout:setTimeout(()=>{No.delete(s),o.project()},Zq)};No.set(s,o)}function Yq(e,t){const n=FC(e,t),s=No.get(n);s&&(clearTimeout(s.timeout),No.delete(n))}function mv(e){const t=`${e}\0`;for(const[n,s]of No)n.startsWith(t)&&(clearTimeout(s.timeout),No.delete(n))}const[NC,pv]=L(new Map),[Qq,UC]=L(new Map),Ff=new Map,Nf=new Map;function Ki(e){if(e){if(typeof e=="string")return Es({directory:wa(e)});if(e.directory)return Es({...e,directory:wa(e.directory)})}}function BC(e,t,n,s){const r=Ki(s);if(!r)return;const o=e.get(t)??new Map;o.set(n,r),e.set(t,o)}function KC(e,t,n){const s=e.get(t);s&&(s.delete(n),s.size||e.delete(t))}class VC{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 Ln=new VC,no=new VC,[Xq,e6]=L(new Map);function yv(){const e=Array.from(Ue().values()).some(t=>t.status==="ready");fq(e)}const[vv,wv]=L(null),t6=1e3,rd=new Map,od=new Map,bv=new Map,Sv=new Map,jC=new Map,yd=new Map,ka=new Map,po=new Map,Wc=new Map,qs=new Map,ic=new Map,ac=new Map,kv=new Error("Pending request sync was superseded");let n6=0;async function xv(e,t,n=!0){const s=new AbortController,r=ac.get(e)??new Set;r.add(s),ac.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?$p.run(s.signal,o):o())}finally{r.delete(s),!r.size&&ac.get(e)===r&&ac.delete(e)}}function hu(e){for(const t of ac.get(e)??[])t.abort()}async function qC(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 Ts(e,t){e.set(t,(e.get(t)??0)+1)}function Hc(e){Ts(yd,e),Ts(ka,e),Ts(po,e)}const mr=new Hq,rn=new Vq({discardWorkspace:e=>e.requestId?ft.cancelWorkspaceCreation(e.requestId):Promise.reject(new Error(`Restore workspace ${e.id} has no creation request`)),restoreWorkspace:e=>{mr.markMutation(e.id),Vi(e)},onPermanentFailure:(e,t)=>{It.error("Failed to cancel restore workspace ownership; restored it to the UI",{workspaceId:e.id,error:t})}});let P0=0;const Wr=new Wq,s6=new jq(async e=>{await qq(bv.get(e));const t=Ue().get(e);if(!(t!=null&&t.client)||t.status!=="ready")return;let n;try{await fi(e,{reset:!0})}catch(o){n=o}if(await Promise.all([ri(e),_l(e),$v(e),WC(e)]),n)throw n;const s=$f().get(e)??new Set;for(const o of s)Ls(e,o);const r=jn().get(e);r&&s.has(r)&&await sr(e,r,{force:!0}),rr(e)},(e,t)=>{It.warn("Failed to resync sessions after instance connection",{instanceId:e,error:t})}),zC=new uq;function r6(e){s6.request(e)}async function WC(e){const t=Ue().get(e);if(!(t!=null&&t.client)||t.status!=="ready")return;const n=$f().get(e)??new Set;await Promise.all(Array.from(n,async s=>{var o,a;const r=((a=(o=Fe().get(e))==null?void 0:o.get(s))==null?void 0:a.location.directory)??t.folder;try{await CK(e,s,r)}catch(i){It.warn("Failed to resync session inbox after connection",{instanceId:e,sessionId:s,error:i})}}))}const o6=["agents","providers","commands","metadata","filesystem"],cc=new Map;function $v(e,t=o6){const n=cc.get(e);if(n){for(const a of t)n.pending.add(a);return n.promise}const s=Ue().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")&&Iq(e);const i=[],c=$n(e);a.has("agents")&&i.push(wf(e,c,!0)),a.has("providers")&&i.push(ha(e,c,!0)),a.has("commands")&&i.push(Nx(e,r,c)),a.has("metadata")&&i.push(DC(s,{force:!0,location:c})),await Promise.all(i)}while(o.pending.size)})().finally(()=>{cc.get(e)===o&&cc.delete(e)}),cc.set(e,o),o.promise}fs.on("instance.eventStatus",e=>{var n;if(e.type!=="instance.eventStatus")return;const t=zC.observe(e.instanceId,e.status,e.reason);e.status==="connected"&&(((n=vv())==null?void 0:n.id)===e.instanceId&&wv(null),t&&r6(e.instanceId))});function i6(){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?`restore-${globalThis.crypto.randomUUID()}`:(P0+=1,`restore-${Date.now().toString(36)}-${P0.toString(36)}`)}const mu=new Map;function Gc(e,t){const n=mu.get(e);if(n){mu.delete(e);for(const s of n)t?s.reject(t):s.resolve()}}function rr(e){RV(e,new Set(Ln.sessionIds(e)),new Set(no.sessionIds(e)))}function a6(e,t){const n=Ue().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)??ku().environmentVariables??{}}}function Vi(e,t){const n=a6(e,t);Ue().has(e.id)?Zc(e.id,n):tE(n),e.status==="ready"?(c6(e),Gc(e.id)):(e.status==="error"||e.status==="stopped")&&Gc(e.id,new Error(e.error||`Workspace ${e.id} did not become ready`))}function c6(e){const t=Ue().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&&Zc(e.id,{port:n});return}t.client&&(Ji.destroyClientsForInstance(e.id),Py(e.id));const r=Ji.createClient(e.id,s,()=>bs()===e.id);Zc(e.id,{client:r,port:n??0,proxyPath:s,status:"ready"}),ln.seedStatusIfMissing(e.id,"connecting");const o=GC(e.id);Sv.set(e.id,o.sessions),jC.set(e.id,o.workspaceMetadata);const a=ZC(e.id,{propagateErrors:!0,sessionHydration:o.sessions,workspaceMetadataHydration:o.workspaceMetadata});bv.set(e.id,a),a.catch(i=>{It.error("Failed to hydrate instance data",i)})}function _v(e){const t=Ue().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=mu.get(e)??new Set;o.add(r),mu.set(e,o);const a=Ue().get(e);(a==null?void 0:a.status)==="ready"&&a.client?Gc(e):((a==null?void 0:a.status)==="error"||(a==null?void 0:a.status)==="stopped")&&Gc(e,new Error(a.error||`Workspace ${e} did not become ready`))})}async function l6(e){await _v(e),await Sv.get(e)}function Cv(e){const t=Ue().get(e);t&&(t.client&&Ji.destroyClientsForInstance(e),Py(e),ln.seedStatus(e,"disconnected"))}function HC(e,t){var n;return TI(t,[$n(e),...lo(e),...Array.from(((n=Fe().get(e))==null?void 0:n.values())??[]).map(s=>s.location),...Br(e).flatMap(s=>s.location?[s.location]:[])])}async function d6(e,t=!1,n=()=>!0){var o,a,i;const s=Ue().get(e);if(!(s!=null&&s.client))return;const r=ka.get(e)??0;try{const c=Date.now(),l=[],d=HC(e,s.folder),u=new Set,f=await qC(d,n,async v=>{const k=await xv(e,$=>s.client.permission.request.list({location:wo(v)},{...Nt(v),signal:$}));return{location:v,response:k}}),h=[];for(const v of f){if(v.status==="rejected"){h.push(v.reason);continue}const{location:k,response:$}=v.value;It.info("permission.request.list",{instanceId:e,location:k,resolvedLocation:$.location});const C={directory:$.location.directory||k.directory,workspaceID:Vu($.location)},T=Ki(C);T&&(u.add(T),l.push(...$.data.map(D=>({request:D,location:C,key:T}))))}const m=new Set(l.map(({request:v})=>v.id));if(!n()||(ka.get(e)??0)!==r){if(t)throw kv;return}h.length||gq(e,m,c);const w=l.filter(({request:v})=>!If(e,v.id)),S=new Set(w.map(({request:v})=>v.id)),b=xo(e);for(const v of b){const k=((o=Ff.get(e))==null?void 0:o.get(v.id))??Ki((i=(a=Fe().get(e))==null?void 0:a.get(Zi(v)??""))==null?void 0:i.location);!S.has(v.id)&&k&&u.has(k)&&(Cl(e,v.id),zu(e,v.id))}for(const{request:v,location:k}of w){const $=Ev(e,v,k)??v;Ax(e,$)}if(rr(e),h.length&&(It.warn("Pending permission scan was partial",{instanceId:e,failedLocations:h.length}),t))throw h[0]}catch(c){if(It.warn("Failed to sync pending permissions",{instanceId:e,error:c}),t)throw c}}async function u6(e,t=!1,n=()=>!0){var o,a,i;const s=Ue().get(e);if(!(s!=null&&s.client))return;const r=po.get(e)??0;try{const c=Date.now(),l=[],d=HC(e,s.folder),u=new Set,f=await qC(d,n,async b=>{const v=await xv(e,k=>s.client.form.list({location:wo(b)},{...Nt(b),signal:k}));return{location:b,response:v}}),h=[];for(const b of f){if(b.status==="rejected"){h.push(b.reason);continue}const{location:v,response:k}=b.value,$={directory:k.location.directory||v.directory,workspaceID:Vu(k.location)},C=Ki($);C&&(u.add(C),l.push(...k.data.map(T=>({form:T.sessionID==="global"?{...T,location:k.location}:T,location:$,key:C}))))}if(!n()||(po.get(e)??0)!==r){if(t)throw kv;return}const m=new Set(l.map(({form:b})=>b.id));h.length||mq(e,m,c);const w=l.filter(({form:b})=>!xC(e,b.id)),S=new Set(w.map(({form:b})=>b.id));for(const b of Br(e)){const v=((o=Nf.get(e))==null?void 0:o.get(b.id))??Ki(b.location)??Ki((i=(a=Fe().get(e))==null?void 0:a.get(b.sessionID))==null?void 0:i.location);!S.has(b.id)&&v&&u.has(v)&&El(e,b.id)}for(const{form:b,location:v}of w)Mv(e,b,v);if(rr(e),h.length&&(It.warn("Pending form scan was partial",{instanceId:e,failedLocations:h.length}),t))throw h[0]}catch(c){if(It.warn("Failed to sync pending forms",{instanceId:e,error:c}),t)throw c}}async function f6(e,t,n){for(let s=0;s<3&&!n.cancelled;s+=1){const r=(yd.get(e)??0)+1;yd.set(e,r);const o=()=>!n.cancelled&&yd.get(e)===r&&Wc.get(e)===t;try{await Promise.all([d6(e,!0,o),u6(e,!0,o)]);return}catch(a){if(a!==kv)throw a}}if(!n.cancelled&&Wc.get(e)===t)throw new Error("Pending request sync did not stabilize")}function _l(e,t){const n=Wc.get(e);if(n===void 0)return Promise.resolve();const s=qs.get(e);if((s==null?void 0:s.generation)===n)return t==null||t(()=>{var a;((a=qs.get(e))==null?void 0:a.token)===s.token&&(s.token.cancelled=!0,hu(e),Hc(e),qs.delete(e))}),s.promise;const r={cancelled:!1},o=f6(e,n,r).finally(()=>{var a;((a=qs.get(e))==null?void 0:a.promise)===o&&qs.delete(e)});return qs.set(e,{generation:n,token:r,promise:o}),t==null||t(()=>{var a;((a=qs.get(e))==null?void 0:a.token)===r&&(r.cancelled=!0,hu(e),Hc(e),qs.delete(e))}),o}function Uf(e){const t=qs.get(e);t&&(t.token.cancelled=!0),hu(e),qs.delete(e),Hc(e),_l(e).catch(n=>{It.warn("Failed to reconcile pending requests after an ambiguous mutation",{instanceId:e,error:n})})}async function g6(e){const t=Fe().get(e),n=Array.from((t==null?void 0:t.values())??[]).some(r=>r.status==="working"||r.status==="compacting");let s;if(n||xo(e).length||Br(e).length)try{await xv(e,r=>m1(e,r),!1)}catch(r){s=r}if(await _l(e),rr(e),s)throw s}function h6(e){const t=ic.get(e);if(t)return t;const n=g6(e).finally(()=>{ic.get(e)===n&&ic.delete(e)});return ic.set(e,n),n}function GC(e,t=!1){const n=t?ri(e):Li(e),s=Promise.resolve().then(async()=>{const a=Ue().get(e);a!=null&&a.client&&await PC(a,{force:t}).catch(i=>{It.warn("Failed to load project metadata before session hydration",{instanceId:e,error:i})})}),r=Promise.all([n,s]).then(()=>{});r.catch(a=>It.warn("Failed to hydrate workspace metadata",{instanceId:e,error:a}));const o=Promise.resolve().then(async()=>{U1(e),await fi(e,{projectMetadata:s}).catch(a=>{It.error("Failed to hydrate sessions",{instanceId:e,error:a})})});return o.then(async()=>{const a=Ue().get(e);a!=null&&a.client&&await DC(a,{force:t,location:$n(e)})}).catch(a=>It.warn("Failed to load supplemental instance metadata",{instanceId:e,error:a})),{sessions:o,workspaceMetadata:r}}async function ZC(e,t){try{const n=t!=null&&t.sessionHydration?{sessions:t.sessionHydration,workspaceMetadata:t.workspaceMetadataHydration??Promise.resolve()}:GC(e,t==null?void 0:t.force);await Promise.all([n.sessions,n.workspaceMetadata,fa(e,t==null?void 0:t.force)]),await aT(e),await _l(e)}catch(n){if(It.error("Failed to fetch initial data",n),t!=null&&t.propagateErrors)throw n}}async function m6(e){const t=Ue().get(e);if(!(t!=null&&t.proxyPath))throw new Error("Instance not ready");const n=sx(t.proxyPath),s=new URL("instance/dispose",n),r=await fetch(s.toString(),{method:"POST",credentials:"include",headers:{Accept:"application/json"}});if(!r.ok){const i=await r.text().catch(()=>"");throw new Error(i||`Dispose request failed with ${r.status}`)}if((r.headers.get("content-type")??"").includes("application/json")){const i=await r.json().catch(()=>{});return typeof i=="boolean"?i:i&&typeof i=="object"&&"data"in i?!!i.data:!!i}const a=await r.text().catch(()=>"");return a.trim()==="true"?!0:a.trim()==="false"?!1:!!a}function JC(e){jd(e),Lp(e),Ip(e),Tv(e),dE(e)}async function vd(e,t){if(od.has(e))return od.get(e);const n=(async()=>{const s=Ue().get(e);s!=null&&s.client&&(It.info("Rehydrating instance",{instanceId:e,reason:t==null?void 0:t.reason}),JC(e),await ZC(e,{force:!0}))})().finally(()=>{od.delete(e)});return od.set(e,n),n}async function p6(e){if(rd.has(e))return rd.get(e);const t=(async()=>{const n=await m6(e);return n&&await vd(e,{reason:"disposed"}),n})().finally(()=>{rd.delete(e)});return rd.set(e,t),t}async function YC(){if(!Nm())return;const e=mr.begin(),t=new Set(Ue().keys());try{const n=await ft.fetchWorkspaces();if(!mr.isCurrent(e))return;const s=new Set(n.map(({id:o})=>o));for(const o of n)if(mr.allows(e,o.id)&&(rn.trackPendingRequest(o),!Wr.deferRefreshWorkspace(o))){if(rn.owns(o.id)){rn.track(o);continue}Vi(o)}const r=[...t].filter(o=>mr.allows(e,o));for(const o of lq(r,s,a=>rn.owns(a)))Cv(o),Bf(o,{authoritative:!1})}finally{mr.complete(e)}}const QC=async function(){try{return await YC(),{}}catch(t){return It.error("Failed to load workspaces",t),{error:t}}}();let pu=QC;const Dm=new Set;function y6(e){pu=e,Dm.forEach(t=>t())}function v6(e,t){return pu!==e?Promise.resolve():new Promise((n,s)=>{const r=()=>{Dm.delete(o),t==null||t.removeEventListener("abort",a)},o=()=>{r(),n()},a=()=>{r(),s(t==null?void 0:t.reason)};Dm.add(o),t==null||t.addEventListener("abort",a,{once:!0}),pu!==e&&o()})}fs.onOpen(()=>{y6(YC().then(()=>({}),e=>(It.warn("Failed to reconcile workspaces after event reconnect",e),{error:e})))});async function w6(e){await Nq(QC,()=>pu,v6,e)}fs.on("*",e=>b6(e));function b6(e){if(!Nm())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"&&mr.markMutation(t),!("workspace"in e&&(rn.trackPendingRequest(e.workspace),Wr.deferWorkspace(e.workspace)))&&!(e.type==="workspace.stopped"&&Wr.deferStopped(e.workspaceId,e.reason))&&!(t&&rn.shouldIgnoreEvent(t)))switch(e.type){case"workspace.created":Vi(e.workspace);break;case"workspace.started":Vi(e.workspace);break;case"workspace.error":Vi(e.workspace),_q(e.workspace),TC(e.workspace.id),cE(e.workspace.id);break;case"workspace.stopped":Fq(e.workspaceId),rn.release(e.workspaceId),Cv(e.workspaceId),Bf(e.workspaceId,{authoritative:e.reason==="deleted"});break;case"workspace.log":S6(e.entry);break}}function S6(e){const t={timestamp:new Date(e.timestamp).getTime(),level:e.level??"info",message:e.message};oE(e.workspaceId,t)}function k6(e){Lf(t=>{if(t.has(e))return t;const n=new Map(t);return n.set(e,[]),n})}function XC(e){hv(t=>{if(t.has(e))return t;const n=new Map(t);return n.set(e,!1),n})}function x6(e){Lf(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),hv(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n})}function $6(e){return LC().get(e)??[]}function eE(e){return Gq().get(e)??!1}function _6(e,t){XC(e),hv(n=>{const s=new Map(n);return s.set(e,t),s}),t||iE(e)}function tE(e){const t=Array.from(Ue().values()).filter(n=>yo(n.folder)===yo(e.folder)).length;Wc.set(e.id,++n6),gv(n=>{const s=new Map(n);return s.set(e.id,e),s}),k6(e.id),XC(e.id),Am({type:"opened",instanceId:e.id,folder:e.folder,occurrence:t}),yv()}function Zc(e,t){var s;const n=Ue().get(e);if(t.client!==void 0&&(n!=null&&n.client)&&t.client!==n.client){vl(e),pf(e),Lp(e),Ip(e),mv(e),cc.delete(e);for(const r of((s=Fe().get(e))==null?void 0:s.keys())??[])Ls(e,r)}gv(r=>{const o=new Map(r),a=o.get(e);return a&&o.set(e,{...a,...t}),o}),yv()}function Bf(e,t={}){const n=Ue().get(e),s=n?Array.from(Ue().values()).filter(o=>yo(o.folder)===yo(n.folder)).findIndex(o=>o.id===e):-1;n&&s>=0&&t.authoritative===!1&&Am({type:"unavailable",instanceId:e,folder:n.folder,occurrence:s}),Lq(e),zC.clear(e);let r=null;gv(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),bs()===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}),x6(e),Lp(e),Tv(e),hq(e),pq(e),dE(e),Ip(e),mv(e),TC(e),cE(e),bv.delete(e),Sv.delete(e),jC.delete(e),Hc(e),hu(e),ic.delete(e),Wc.delete(e),Gc(e,new Error(`Workspace ${e} was removed before it became ready`)),bs()===e&&IC(r),jd(e),Bt.unregisterInstance(e),Z1(e),vl(e),pf(e),_I(e),W1(e),aC(e),tC(e),n&&s>=0&&t.authoritative!==!1&&Am({type:"removed",instanceId:e,folder:n.folder,occurrence:s}),yv()}function nE(e){mr.markMutation(e),Ue().has(e)&&(Cv(e),Bf(e,{authoritative:!1}))}function wd(e){return e.reused!==!0&&nE(e.id),rn.discardCreated(e,{retainTombstone:e.reused!==!0})}async function sE(e,t){await rn.releaseAfter(e,()=>jm(()=>ft.releaseWorkspaceCreation(e,t),{maxAttempts:4,initialDelayMs:250,maxDelayMs:2e3,backoffMultiplier:4}))}async function rE(e,t){await zq(t)}function C6(e){const t=rn.get(e);t!=null&&t.requestId&&sE(e,t.requestId).catch(n=>{It.warn("Failed to transfer restore workspace creation ownership to the user",{instanceId:e,error:n})})}async function O0(e,t){if(t.status==="stopped"){rn.release(e.id),nE(e.id);return}await wd(e)}async function E6(e,t,n){var l,d,u,f,h,m,w,S,b;const s=n!=null&&n.signal?i6():void 0;s&&rn.beginRequest(s);const r=s&&(n!=null&&n.waitForCreateCommit)?Wr.begin(s,n.waitForCreateCommit(),e):void 0;let o=null,a=!1,i=!1;const c=()=>{if(!s)return;const v=rn.quarantineRequest(s);o??(o=v?v.then(()=>!0):rE(void 0,s).then(()=>!0,k=>(It.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 Bi(n.signal);const v=await ft.createWorkspace({path:e,name:t,requestId:s},{signal:n==null?void 0:n.signal});a=!0;const k=v.reused===!0;if(s&&Wr.bindResponse(s,v.id),(u=n==null?void 0:n.signal)!=null&&u.aborted)throw v.requestId&&await wd(v),Bi(n.signal);if(n!=null&&n.signal&&v.requestId){const R=s?Wr.resolve(s,v).workspace:v;rn.track({...R,requestId:R.requestId??v.requestId,...k?{reused:!0}:{}})}else n!=null&&n.signal||rn.releaseTombstoneForUserCreate(v.id);if(r&&await r.wait,(f=n==null?void 0:n.signal)!=null&&f.aborted)throw v.requestId&&await wd(v),Bi(n.signal);const $=s?Wr.resolve(s,v):{workspace:v},C={...$.workspace,requestId:$.workspace.requestId??v.requestId,...k?{reused:!0}:{}};s&&rn.track(C);const T=$.terminal??(C.status==="error"||C.status==="stopped"?{status:C.status,message:C.error}:void 0);if(T)throw i=!0,await O0(C,T),new Error(T.message||`Restore-created workspace ${v.id} ${T.status}`);const D=rn.shouldIgnoreEvent(v.id)||((h=n==null?void 0:n.shouldCreateCommit)==null?void 0:h.call(n))===!1;if(D||(mr.markMutation(v.id),(m=n==null?void 0:n.onBeforeCreateCommit)==null||m.call(n,v.id),Vi(C,k?void 0:t),(w=n==null?void 0:n.onCreateCommit)==null||w.call(n,v.id)),D)throw v.requestId&&await wd(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 O0(r.workspace,r.terminal)),(S=n==null?void 0:n.signal)!=null&&S.aborted||It.error("Failed to create workspace",v),v}finally{if((b=n==null?void 0:n.signal)==null||b.removeEventListener("abort",c),s){Wr.end(s);const v=o;a||!v?rn.finishRequest(s):v.then(k=>{k&&rn.finishRequest(s)})}}}function yo(e){const t=e.replace(/[\\/]+$/,"");return/^(?:[A-Za-z]:[\\/]|[\\/]{2})/.test(t)?t.replace(/\\/g,"/").toLowerCase():t}function T6(e){if(!e)return null;const t=yo(e),n=Array.from(Ue().values()).filter(r=>r.status==="stopped"?!1:yo(r.folder)===t);if(n.length===0)return null;const s=bs();return n.find(r=>r.id===s)??n.find(r=>r.status==="ready")??n[0]??null}function M6(e,t){const n=t.trim();if(!e||!n)return;const s=yo(e);for(const r of Ue().values())r.status!=="stopped"&&yo(r.folder)===s&&Zc(r.id,{projectName:n})}const Ig=new Map;function A6(e){if(!Ue().get(e))return Promise.resolve();const n=Ig.get(e);if(n)return n;const s=ft.deleteWorkspace(e).catch(r=>{It.error("Failed to stop workspace",r);try{Fn({message:ke("app.stopInstance.toast.error"),variant:"error"})}finally{throw r}}).finally(()=>{Ig.delete(e)});return Ig.set(e,s),s}function D6(){const e=bs();return e&&Ue().get(e)||null}function oE(e,t){eE(e)&&Lf(n=>{const s=new Map(n),r=s.get(e)??[],o=r.length>=t6?[...r.slice(1),t]:[...r,t];return s.set(e,o),s})}function iE(e){Lf(t=>{if(!t.has(e))return t;const n=new Map(t);return n.set(e,[]),n})}function xo(e){const t=NC().get(e);return t||[]}function P6(e){return xo(e).length}function O6(e,t){const s=xo(e).find(r=>r.id===t);return s?Ln.ensureEnqueuedAt(s):Ln.enqueuedAtFor(t)}function R6(e){const t=xo(e),n=Br(e),s=[];t[0]&&s.push({kind:"permission",id:t[0].id,enqueuedAt:Ln.ensureEnqueuedAt(t[0])}),n[0]&&s.push({kind:"form",id:n[0].id,enqueuedAt:no.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 I6(e,t){e6(n=>{const s=new Map(n);return t?s.set(e,t):s.set(e,null),s}),UC(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 Ua(e){I6(e,R6(e))}function Ev(e,t,n){Ts(ka,e),BC(Ff,e,t.id,n);let s=!1,r=!1,o,a=t;if(pv(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=Qk(o,t);const m=u.slice();return m[f]=a,d.set(e,m.sort((w,S)=>Ln.ensureEnqueuedAt(w)-Ln.ensureEnqueuedAt(S))),r=!0,d}Ln.ensureEnqueuedAt(a);const h=[...u,a].sort((m,w)=>Ln.ensureEnqueuedAt(m)-Ln.ensureEnqueuedAt(w));return d.set(e,h),s=!0,d}),!s&&!r)return;Ua(e);const i=o?Zi(o):void 0,c=Zi(a);if(i&&i!==c){const l=Ln.decrement(e,i);uu(e,i,l>0)}return c&&((s||i!==c)&&Ln.increment(e,c),uu(e,c,!0)),a}function Cl(e,t){Ts(ka,e),KC(Ff,e,t);let n=null;pv(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}),Ua(e),Ln.remove(e,t);const s=n;if(s){const r=Zi(s);if(r){const o=Ln.decrement(e,r);uu(e,r,o>0)}}}function L6(e,t){const n=EC(e,t);bq(e,t),ft.toggleYolo(e,t).then(s=>{zc(e,t,s.enabled)}).catch(s=>{It.warn("Failed to toggle Yolo on server",{instanceId:e,sessionId:t,error:s}),zc(e,t,n)})}const ji=new Set;function aE(e,t){if(!e||!t||t==="info")return;const n=`${e}:${t}`;ji.has(n)||(ji.add(n),ft.getYoloState(e,t).then(s=>{zc(e,t,s.enabled)}).catch(s=>{ji.delete(n),It.warn("Failed to sync Yolo state",{instanceId:e,sessionId:t,error:s})}))}fs.onOpen(()=>{ji.clear()});function cE(e){const t=`${e}:`;for(const n of Array.from(ji))n.startsWith(t)&&ji.delete(n)}function Tv(e){Ts(ka,e),Ff.delete(e),Ln.clear(e,xo(e),t=>{uu(e,t,!1)}),pv(t=>{const n=new Map(t);return n.delete(e),n}),UC(t=>{const n=new Map(t);return n.delete(e),n}),Ua(e)}async function F6(e,t,n,s,r){const o=Ue().get(e);if(!(o!=null&&o.client))throw new Error("Instance not ready");try{const a=xo(e).find(i=>i.id===n);if(!a)throw new Error(`Permission request not found: ${n}`);await pt(e).permission.reply({sessionID:a.sessionID,requestID:n,decision:s,...r?{message:r}:{}}),Rf(e,n),Cl(e,n),zu(e,n)}catch(a){throw It.error("Failed to send permission response",a),Uf(e),a}}async function N6(e,t,n){const s=Br(e).find(r=>r.id===t);if(!s)throw new Error(`Form request not found: ${t}`);Ts(po,e);try{await pt(e).session.form.reply({sessionID:s.sessionID,formID:s.id,answer:n},OC(s)),uv(e,s.id),El(e,s.id)}catch(r){throw Uf(e),r}}let bd;function lE(e){bd=e}function Mv(e,t,n){Ts(po,e),BC(Nf,e,t.id,n??t.location);const s=Br(e).find(r=>r.id===t.id);if(Mq(e,t),no.ensureEnqueuedAt(t),s!=null&&s.sessionID&&s.sessionID!==t.sessionID){const r=no.decrement(e,s.sessionID);fu(e,s.sessionID,r>0)}return(!s||s.sessionID!==t.sessionID)&&no.increment(e,t.sessionID),fu(e,t.sessionID,!0),Ua(e),s||bd==null||bd(e,t),s?void 0:t}function El(e,t){Ts(po,e),KC(Nf,e,t);const n=Br(e).find(s=>s.id===t);if(Aq(e,t),no.remove(e,t),n){const s=no.decrement(e,n.sessionID);fu(e,n.sessionID,s>0)}Ua(e)}function dE(e){Ts(po,e),Nf.delete(e),no.clear(e,Br(e),t=>{fu(e,t,!1)}),Pq(e),Ua(e)}async function U6(e,t){const n=Br(e).find(s=>s.id===t);if(!n)throw new Error(`Form request not found: ${t}`);Ts(po,e);try{await pt(e).session.form.cancel({sessionID:n.sessionID,formID:n.id},OC(n)),uv(e,n.id),El(e,n.id)}catch(s){throw Uf(e),s}}const B6=new Set(["session.step.ended","session.step.failed"]);function uE(e,t){var l,d,u,f;const n=Ue().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"&&mv(e),s&&(t.type==="session.compaction.ended"||t.type==="session.compaction.failed")&&Yq(e,s);const o=(h,m=!0,w=!1)=>{var S;if(s&&t.type.startsWith("session.")&&jn().get(e)!==s&&((S=$f().get(e))!=null&&S.has(s))&&Ls(e,s),r&&!w){s&&Jq(e,s,()=>o(h,m,!0));return}s&&(w||t.type.startsWith("session."))&&jn().get(e)===s&&Px(Bt.getOrCreate(e).getMessageWindow(s))&&(EK(e,s,h,m,w||t.type!=="session.inbox.enqueued"),(w||B6.has(t.type))&&ta(e,s))},a=(h,m=!0)=>{if(o(h,m),s&&t.type==="session.inbox.cancelled"&&Lb(e,t.data.inboxID,s),s&&t.type==="session.revert.committed")for(const w of Bt.getOrCreate(e).getSessionMessageIds(s))w>=t.data.to&&Lb(e,w,s)},i=_K(e,n.folder,t,a,h=>{o(h,!1,!0),Uf(e)});if(a(i),s&&(t.type==="permission.asked"||t.type==="permission.replied")){const h=i.session.permission.list(s)??[],m=(t.type==="permission.asked"?[t.data,...h.filter(S=>S.id!==t.data.id)]:h).filter(S=>!If(e,S.id)),w=t.location??((d=(l=Fe().get(e))==null?void 0:l.get(s))==null?void 0:d.location);for(const S of m){const b=Ev(e,S,w)??S;Ax(e,b)}t.type==="permission.replied"&&(Cl(e,t.data.requestID),zu(e,t.data.requestID))}if(s&&t.type.startsWith("form.")){const h=i.session.form.list(s,s==="global"?t.location:void 0)??[],m=t.type==="form.created"?[t.data.form,...h.filter(S=>S.id!==t.data.form.id)]:h,w=t.location??((f=(u=Fe().get(e))==null?void 0:u.get(s))==null?void 0:f.location);for(const S of m)xC(e,S.id)||Mv(e,S,w);(t.type==="form.replied"||t.type==="form.cancelled")&&(uv(e,t.data.id),El(e,t.data.id))}const c=dq(t.type);c.length&&$v(e,c)}ln.onInvalidation=uE;ln.onConnectionLost=(e,t)=>{const n=Ue().get(e);n&&wv({id:e,folder:n.folder,reason:t})};ln.onInstanceDisposed=(e,t)=>{var r;const n=(r=t==null?void 0:t.properties)==null?void 0:r.directory;if(!n){vd(e,{reason:"disposed"});return}const s=[];for(const o of Ue().values())o.folder===n&&s.push(o.id);if(s.length===0){vd(e,{reason:"disposed"});return}for(const o of s)vd(o,{reason:"disposed"})};async function K6(){vv()&&wv(null)}const V6=Object.freeze(Object.defineProperty({__proto__:null,acknowledgeDisconnectedInstance:K6,activeInstanceId:bs,activeInterruption:Xq,activePermissionId:Qq,addInstance:tE,addLog:oE,addPendingForm:Mv,addPermissionToQueue:Ev,cancelRestoreCreationRequest:rE,claimRestoreCreatedInstanceForUser:C6,clearLogs:iE,clearPermissionQueue:Tv,clearReloadableInstanceState:JC,createInstance:E6,disconnectedInstance:vv,disposeInstance:p6,ensureYoloStateSynced:aE,getActiveInstance:D6,getExistingInstanceForFolder:T6,getInstanceLogs:$6,getPermissionEnqueuedAtForInstance:O6,getPermissionQueue:xo,getPermissionQueueLength:P6,handleInstanceInvalidation:uE,hasRepliedPermission:If,instanceLogs:LC,instances:Ue,invalidatePendingRequestSync:Hc,isInstanceLogStreaming:eE,markPermissionReplied:Rf,permissionQueues:NC,reconcilePendingRequestLiveness:h6,reconcilePendingSessionIndicators:rr,refreshVolatileInstanceState:$v,releaseRestoreCreatedInstance:sE,removeInstance:Bf,removePendingForm:El,removePermissionFromQueue:Cl,sendFormCancel:U6,sendFormReply:N6,sendPermissionResponse:F6,setActiveInstanceId:IC,setInstanceLogStreaming:_6,setPendingFormAddedHandler:lE,stopInstance:A6,syncLoadedSessionInboxes:WC,syncPendingRequests:_l,togglePermissionAutoAcceptForSession:L6,updateInstance:Zc,updateProjectNameForFolder:M6,waitForInitialWorkspaceLoad:w6,waitForInstanceInitialSessionHydration:l6,waitForInstanceReady:_v},Symbol.toStringTag,{value:"Module"}));async function j6(e,t="ui"){if(typeof window>"u")return!1;if(Fm())try{const{openUrl:n}=await ts(async()=>{const{openUrl:s}=await import("./index-DTGOXoDH.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 fE(e,t){return(e.type==="external"||!e.hidden)&&gE(e,t)}function gE(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 q6(e,t){return Object.fromEntries(e.flatMap(n=>{if(n.type==="external"||!gE(n,t))return[];const s=t[n.key]??(n.hidden?n.default:void 0);return s===void 0?[]:[[n.key,s]]}))}function Pm(e){try{const t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}const Lg={type:"key",label:""};function z6(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 id(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 R0(e){const t={};for(const n of e??[])n.type!=="external"&&n.default!==void 0&&(t[n.key]=n.default);return t}function I0(e,t){if(e)return q6(e,t)}function W6(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||!z6(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 H6(e){const t=e;return(t==null?void 0:t.name)==="AbortError"||(t==null?void 0:t.message)==="This operation was aborted"}var G6=F("<div class=providers-form-stack>"),Z6=F("<label class=settings-form-label>"),L0=F("<span class=settings-toggle-caption>"),J6=F("<input class=providers-input>"),Y6=F("<datalist>"),Q6=F('<div class="flex-1 min-w-0">'),X6=F("<input type=number class=providers-input>"),F0=F("<label class=settings-checkbox-toggle><input type=checkbox><span>"),e8=F("<input type=text class=providers-input>"),t8=F("<div class=providers-multiselect>"),n8=F("<div class=providers-field>"),s8=F('<div class=providers-field><a target=_blank rel="noopener noreferrer"class="selector-button selector-button-secondary providers-oauth-link">'),r8=F("<option>"),o8=F("<span class=providers-select-hint>"),i8=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const a8=e=>{const{t}=kt(),n=$e(()=>(e.fields??[]).filter(d=>fE(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 h=new Set(o(d));f?h.add(u):h.delete(u),e.onAnswer(d.key,[...h])},l=(d,u)=>{const f=new Set(d.options.map(w=>w.value)),h=o(d).filter(w=>f.has(w)),m=u.split(",").map(w=>w.trim()).filter(Boolean);e.onAnswer(d.key,[...h,...m])};return(()=>{var d=G6();return p(d,y(Ut,{get each(){return n()},children:u=>y(Q,{get when(){return u.type!=="external"},get fallback(){return y(Q,{get when(){return _e(()=>u.type==="external")()&&Pm(u.url)},get children(){var f=s8(),h=f.firstChild;return p(h,y(Oi,{class:"w-4 h-4"}),null),p(h,()=>s(u),null),p(f,y(Q,{get when(){return u.description},get children(){var m=L0();return p(m,()=>u.description),m}}),null),de(()=>pe(h,"href",u.type==="external"?u.url:void 0)),f}})},get children(){var f=n8();return p(f,y(Q,{get when(){return u.type!=="boolean"},get children(){var h=Z6();return p(h,()=>s(u)),de(()=>pe(h,"for",`provider-field-${u.key}`)),h}}),null),p(f,y(Q,{get when(){return u.description},get children(){var h=L0();return p(h,()=>u.description),h}}),null),p(f,y(Q,{get when(){return _e(()=>u.type==="string")()&&(!u.options||u.custom)},get children(){return[(()=>{var h=J6();return h.$$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,$=u.type==="string"?u.maxLength:void 0,C=u.type==="string"?u.pattern:void 0,T=u.type==="string"&&u.options?`provider-options-${u.key}`:void 0,D=e.disabled;return w!==m.e&&pe(h,"id",m.e=w),S!==m.t&&pe(h,"type",m.t=S),b!==m.a&&pe(h,"placeholder",m.a=b),v!==m.o&&(h.required=m.o=v),k!==m.i&&pe(h,"minlength",m.i=k),$!==m.n&&pe(h,"maxlength",m.n=$),C!==m.s&&pe(h,"pattern",m.s=C),T!==m.h&&pe(h,"list",m.h=T),D!==m.r&&(h.disabled=m.r=D),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(()=>h.value=typeof r(u)=="string"?r(u):""),h})(),y(Q,{get when(){return _e(()=>u.type==="string")()&&u.options},get children(){var h=Y6();return p(h,y(Ut,{get each(){return _e(()=>u.type==="string")()?u.options:[]},children:m=>(()=>{var w=r8();return p(w,()=>m.label),de(()=>w.value=m.value),w})()})),de(()=>pe(h,"id",`provider-options-${u.key}`)),h}})]}}),null),p(f,y(Q,{get when(){return _e(()=>!!(u.type==="string"&&u.options))()&&!u.custom},get children(){return y(Te,{get value(){var h;return _e(()=>u.type==="string")()?(h=u.options)==null?void 0:h.find(m=>m.value===r(u)):void 0},onChange:h=>e.onAnswer(u.key,h==null?void 0:h.value),get options(){return _e(()=>u.type==="string")()?u.options??[]:[]},optionValue:"value",optionTextValue:"label",get disabled(){return e.disabled},itemComponent:h=>y(Te.Item,{get item(){return h.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return[_e(()=>h.item.rawValue.label),y(Q,{get when(){return h.item.rawValue.description},get children(){var m=o8();return p(m,()=>h.item.rawValue.description),m}})]}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger providers-prompt-trigger",get"aria-label"(){return s(u)},get children(){return[(()=>{var h=Q6();return p(h,y(Te.Value,{children:m=>(()=>{var w=i8();return p(w,()=>{var S;return((S=m.selectedOption())==null?void 0:S.label)??t("settings.providers.prompt.selectPlaceholder")}),w})()})),h})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})}}),null),p(f,y(Q,{get when(){return u.type==="number"||u.type==="integer"},get children(){var h=X6();return h.$$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,$=e.disabled;return w!==m.e&&pe(h,"id",m.e=w),S!==m.t&&pe(h,"min",m.t=S),b!==m.a&&pe(h,"max",m.a=b),v!==m.o&&pe(h,"step",m.o=v),k!==m.i&&(h.required=m.i=k),$!==m.n&&(h.disabled=m.n=$),m},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),de(()=>h.value=typeof r(u)=="number"?r(u):""),h}}),null),p(f,y(Q,{get when(){return u.type==="boolean"},get children(){var h=F0(),m=h.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),h}}),null),p(f,y(Q,{get when(){return u.type==="multiselect"},get children(){var h=t8();return p(h,y(Ut,{get each(){return _e(()=>u.type==="multiselect")()?u.options:[]},children:m=>(()=>{var w=F0(),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(h,y(Q,{get when(){return _e(()=>u.type==="multiselect")()&&u.custom},get children(){var m=e8();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&&pe(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),h}}),null),f}})})),d})()};Ht(["input"]);function c8(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 l8(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 d8=F("<p class=settings-error-message role=alert>"),u8=F("<div class=provider-model-visibility-list role=list>"),f8=F('<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">'),g8=F("<p class=settings-card-message role=status>"),h8=F("<label class=provider-model-visibility-item role=listitem><input type=checkbox><span><strong></strong><small dir=ltr>");const m8=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"})||e.id.localeCompare(t.id,void 0,{sensitivity:"base"}),p8=e=>{const{t}=kt(),{getProviderModelVisibilityPreference:n,providerModelVisibilitySaveFailed:s,setProviderModelVisibility:r}=Tn(),[o,a]=L("");let i;const c=$e(()=>[...e.models].sort(m8)),l=$e(()=>new Set(c().filter(m=>n(m.providerId).hiddenModelIds.includes(m.id)).map(m=>`${m.providerId}\0${m.id}`))),d=$e(()=>c().filter(m=>!l().has(`${m.providerId}\0${m.id}`)).length),u=$e(()=>{const m=o().trim().toLocaleLowerCase();return m?c().filter(w=>w.name.toLocaleLowerCase().includes(m)||w.id.toLocaleLowerCase().includes(m)):c()});qe(ei(()=>e.providerId,()=>a(""))),Ns(()=>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(()=>{})},h=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($=>!b.includes($)):Array.from(new Set([...v,...b]));r(S,{hiddenModelIds:k}).catch(()=>{})}};return(()=>{var m=f8(),w=m.firstChild,S=w.firstChild,b=S.nextSibling,v=b.firstChild,k=v.nextSibling,$=w.nextSibling,C=$.firstChild,T=C.nextSibling,D=T.nextSibling,R=D.nextSibling,q=R.nextSibling;cS(S,"click",e.onBack,!0),p(S,y(x2,{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(C,()=>t("settings.providers.modelVisibility.search.label")),T.$$input=ee=>a(ee.currentTarget.value);var re=i;return typeof re=="function"?Xs(re,T):i=T,p(D,()=>t("settings.providers.modelVisibility.count.visible",{visible:d(),total:c().length})),R.$$click=()=>h(!0),p(R,()=>t("settings.providers.modelVisibility.actions.showAll")),q.$$click=()=>h(!1),p(q,()=>t("settings.providers.modelVisibility.actions.hideAll")),p(m,y(Q,{get when(){return c().some(ee=>s(ee.providerId))},get children(){var ee=d8();return p(ee,()=>t("settings.providers.modelVisibility.save.failed")),ee}}),null),p(m,y(Q,{get when(){return u().length>0},get fallback(){return(()=>{var ee=g8();return p(ee,()=>t("settings.providers.modelVisibility.list.empty")),ee})()},get children(){var ee=u8();return p(ee,y(Ut,{get each(){return u()},children:W=>(()=>{var U=h8(),J=U.firstChild,le=J.nextSibling,z=le.firstChild,M=z.nextSibling;return J.addEventListener("change",N=>f(W,N.currentTarget.checked)),p(z,()=>W.name||W.id),p(M,()=>W.id),de(()=>J.checked=!l().has(`${W.providerId}\0${W.id}`)),U})()})),de(()=>pe(ee,"aria-label",t("settings.providers.modelVisibility.list.label",{provider:e.providerName}))),ee}}),null),de(()=>pe(T,"placeholder",t("settings.providers.modelVisibility.search.placeholder"))),de(()=>T.value=o()),m})()};Ht(["click","input"]);var y8=F('<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">'),Fg=F("<div class=settings-card-message role=status>"),N0=F('<div class="flex-1 min-w-0">'),v8=F('<div class=providers-connect-bar><button type=button class="selector-button selector-button-primary"></button><button type=button class=settings-pill-button>'),U0=F("<div class=settings-error-message role=alert>"),w8=F('<div class="settings-toggle-row settings-toggle-row-compact providers-method-row"><div><div class=settings-toggle-title></div><div class=settings-toggle-caption>'),b8=F("<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>"),S8=F("<div class=providers-form-stack><div class=settings-card-message role=status></div><div class=providers-command-preview dir=ltr>"),k8=F("<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>"),x8=F('<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">'),$8=F('<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">'),_8=F("<div class=settings-card-message role=alert>"),C8=F("<div class=providers-success-card role=status><span>"),B0=F('<button type=button class="selector-button selector-button-primary">'),E8=F('<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>'),T8=F("<section class=providers-list-section><h3 class=settings-card-title>"),M8=F("<div class=providers-manager-body>"),A8=F("<div class=selector-option-content><div class=selector-option-description><span dir=ltr></span><span> • </span><span></span><span> • </span><span>"),D8=F("<span class=selector-trigger-secondary dir=ltr> • "),P8=F('<div class="selector-trigger-label selector-trigger-label--stacked flex-1 min-w-0"><span class="selector-trigger-primary selector-trigger-primary--align-left">'),O8=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">'),R8=F("<div class=providers-loading-row role=status><span>"),I8=F("<div class=providers-grid>"),L8=F("<bdi dir=ltr>"),F8=F("<span aria-hidden=true> • "),N8=F('<button type=button class="selector-button selector-button-secondary providers-disconnect-button">'),U8=F('<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">'),B8=F('<div class="providers-manager-modal providers-manager-embedded">');const K8=e=>{const{t}=kt(),[n,s]=L({}),[r,o]=L([]),[a,i]=L(null),[c,l]=L(null),[d,u]=L(null),f=new Map;let h=null;const[m,w]=L(0),[S,b]=L(""),[v,k]=L({}),[$,C]=L(null),[T,D]=L(null),[R,q]=L(null),[re,ee]=L(""),[W,U]=L("idle"),[J,le]=L(!1),[z,M]=L(null),[N,ce]=L(null),[fe,Re]=L(!1),[be,ye]=L(!1);let Ce=null,je=null,O=0,g=0,x=null,A=null,E=null,H=null,B;const oe=$e(()=>Ue().get(e.instanceId)??null),Ae=$e(()=>{if(e.instanceId&&e.location)return pt(e.instanceId);const te=oe();return(te==null?void 0:te.status)==="ready"?te.client??null:null}),we=()=>e.location?{...e.location}:{...$n(e.instanceId)},he=te=>wo(te),Ee=te=>{const ie=we();return Es(ie)===Es(te)},Ge=$e(()=>{const te=new Map;for(const ie of r())te.set(ie.id,ie.name||ie.id);return te}),Xe=$e(()=>r().sort((te,ie)=>te.id.localeCompare(ie.id,void 0,{sensitivity:"base"})).map(te=>({id:te.id,name:Ge().get(te.id)??te.id,modelCount:te.modelCount,connectionSummary:js(te.id),canConnect:te.canConnect}))),se=$e(()=>r().filter(te=>te.source!=="unknown")),V=$e(()=>se().find(te=>te.id===d())??null),Y=te=>te.source==="env"?"not-disconnectable":te.credentialIds.length>0?"credential-remove":"unknown",Oe=te=>{const ie=Y(te);return te.source==="config"?t("settings.providers.source.config"):ie==="not-disconnectable"?t("settings.providers.source.env"):te.source==="api"?t("settings.providers.source.api"):te.source==="custom"?t("settings.providers.source.custom"):t("settings.providers.source.unknown")},ve=$e(()=>Xe().find(te=>te.id===a())??Xe()[0]??null),Ie=$e(()=>{const te=c();return te?Ge().get(te)??te:""}),Le=$e(()=>{const te=c();if(!te)return[Lg];const ie=n()[te];return ie&&ie.length>0?ie:[Lg]}),ze=$e(()=>Le().map((te,ie)=>({value:String(ie),label:te.label||(te.type==="oauth"?t("settings.providers.method.oauth"):te.type==="command"?t("settings.providers.method.command"):t("settings.providers.method.api")),method:te,index:ie}))),Ne=$e(()=>ze().find(te=>te.index===m())??ze()[0]),Je=$e(()=>{var te;return((te=Ne())==null?void 0:te.method)??Lg}),ot=$e(()=>{const te=Je();return te.type==="command"?void 0:te.form}),gt=$e(()=>{const te=Je();return te.type==="command"?te:void 0}),_=$e(()=>{if(!c()||W()==="authorizing"||W()==="waiting"||W()==="success")return!1;const te=Je();return te.type==="key"&&S().trim().length===0?!1:(te.type==="command"?[]:te.form??[]).filter(ie=>fE(ie,v())).every(ie=>W6(ie,v()))});function P(te){var ie;te||et(null),(ie=e.onOpenChange)==null||ie.call(e,te)}function j(){return!Fm()&&typeof window<"u"}function K(){if(!j())return null;let te=null;try{return te=window.open("","_blank"),te&&te.document&&(te.opener=null,te.document.title=t("settings.providers.oauth.popup.loadingTitle"),te.document.body.innerHTML=`<div style="font-family: sans-serif; padding: 24px; color: #111;">${t("settings.providers.oauth.popup.loadingBody")}</div>`),te}catch{return te==null||te.close(),null}}async function I(te,ie){if(!Pm(te))return ie!=null&&ie.popup&&!ie.popup.closed&&ie.popup.close(),!1;if(ie!=null&&ie.sameTab&&typeof window<"u")return window.location.assign(te),!0;const Pe=ie==null?void 0:ie.popup;if(Pe&&!Pe.closed)try{return Pe.location.href=te,!0}catch{}return await j6(te,"provider-auth")}async function Z(){var ie,Pe;const te=(ie=$())==null?void 0:ie.url;if(!(!te||typeof navigator>"u"||!((Pe=navigator.clipboard)!=null&&Pe.writeText)))try{await navigator.clipboard.writeText(te),ye(!0),setTimeout(()=>ye(!1),1500)}catch{ye(!1)}}qe(()=>{const te=++O;if(!e.embedded&&!e.open){A=null,E=null,H=null,Qe();return}const ie=e.instanceId,Pe=Ae();if(!Pe){A=null,E=null,H=null,Qe();return}const ne=we(),me=Es(ne);A===ie&&E===Pe&&H===me||(Qe(),A=ie,E=Pe,H=me,xe(Pe,te,ne))}),qe(()=>{W()==="code"&&queueMicrotask(()=>B==null?void 0:B.focus())}),nt(()=>{O+=1,De()});async function xe(te,ie,Pe){const ne=()=>ie===O&&Ae()===te&&Ee(Pe);le(!0),M(null);try{const me={location:he(Pe)},[Be,lt,it]=await Promise.all([te.provider.list(me,Nt(Pe)),te.model.list(me,Nt(Pe)),te.integration.list(me,Nt(Pe))]);if(!ne())return;const Ve=l8(Be.data,lt.data,it.data).map(st=>({...st,models:c8(st.id,Be.data,lt.data)})),at=Object.fromEntries(it.data.map(st=>[st.id,st.methods.filter(vt=>vt.type!=="env")]));o(Ve),s(at),i(st=>{var vt,mt;return st??((vt=Ve[0])==null?void 0:vt.id)??((mt=it.data[0])==null?void 0:mt.id)??null})}catch(me){if(!ne())return;M(id(me,t("settings.providers.errors.loadFailed")))}finally{ne()&&le(!1)}}function De(){g+=1,x=null,Ce==null||Ce.abort(),Ce=null,je&&!je.closed&&je.close(),je=null}function Qe(){et(null),s({}),o([]),i(null),u(null),M(null),le(!1)}function et(te=null){var Pe,ne;if(te&&!((Pe=n()[te])!=null&&Pe.length))return;De(),l(te),w(0),b("");const ie=te?(ne=n()[te])==null?void 0:ne[0]:void 0;k(R0((ie==null?void 0:ie.type)==="command"||ie==null?void 0:ie.form)),C(null),D(null),q(null),ee(""),U(te?"prompts":"idle"),ce(null),Re(!1),ye(!1)}function Tt(te,ie){k(Pe=>{const ne={...Pe};return ie===void 0?delete ne[te]:ne[te]=ie,ne})}function He(te,ie,Pe){return te===g&&e.instanceId===ie&&Ae()===Pe}async function yt(te,ie,Pe,ne){He(Pe,ie,te)&&(e.location||await ha(ie,ne,!0).catch(()=>{}),He(Pe,ie,te)&&await xe(te,++O,we()).catch(()=>{}))}async function Qt(){const te=Ae(),ie=e.instanceId;if(!te)return;const Pe=we();le(!0),e.location||await ha(ie,Pe,!0).catch(()=>{}),!(Ae()!==te||e.instanceId!==ie)&&await xe(te,++O,Pe)}function Ot(){u(null),queueMicrotask(()=>{var te;h&&((te=f.get(h))==null||te.focus())})}async function Dn(te,ie,Pe,ne,me){await ie.integration.connect.key({integrationID:te,key:S().trim(),answer:I0(ot(),v()),location:he(me)},Nt(me)),He(ne,Pe,ie)&&(await yt(ie,Pe,ne,me),He(ne,Pe,ie)&&et(null))}async function Wn(te,ie,Pe,ne,me){const Be=Je();if(Be.type!=="oauth")throw new Error(t("settings.providers.errors.noAuthorization"));const lt=await ie.integration.oauth.connect({integrationID:te,methodID:Be.id,answer:I0(ot(),v()),location:he(me)},Nt(me));if(!He(ne,Pe,ie))return;const it=lt.data;if(!it)throw new Error(t("settings.providers.errors.noAuthorization"));const Ve={attemptID:it.attemptID,url:it.url,instructions:it.instructions,method:it.mode};C(Ve);const at=await I(it.url,{popup:je});if(He(ne,Pe,ie)){if(je=null,Re(!at),it.mode==="code"){U("code");return}for(U("waiting"),Ce=new AbortController;;){const st=await ie.integration.oauth.status({integrationID:te,attemptID:it.attemptID,location:he(me)},{...Nt(me),signal:Ce.signal});if(st.data.status==="complete")break;if(st.data.status==="failed")throw new Error(st.data.message);if(st.data.status==="expired")throw new Error(t("settings.providers.errors.authorizationFailed"));await new Promise(vt=>setTimeout(vt,1e3))}He(ne,Pe,ie)&&(Ce=null,await yt(ie,Pe,ne,me),He(ne,Pe,ie)&&et(null))}}async function Hn(te,ie,Pe,ne,me){const Be=Je();if(Be.type!=="command")throw new Error(t("settings.providers.errors.noAuthorization"));const lt=await ie.integration.command.connect({integrationID:te,methodID:Be.id,location:he(me)},Nt(me));if(!He(ne,Pe,ie))return;const it=lt.data.attemptID;for(D(it),q(null),U("waiting"),Ce=new AbortController;;){const Ve=await ie.integration.command.status({integrationID:te,attemptID:it,location:he(me)},{...Nt(me),signal:Ce.signal});if(Ve.data.status==="complete")break;if(Ve.data.status==="failed")throw new Error(Ve.data.message);if(Ve.data.status==="expired")throw new Error(t("settings.providers.errors.authorizationFailed"));q(Ve.data.message??null),await new Promise(at=>setTimeout(at,1e3))}He(ne,Pe,ie)&&(Ce=null,await yt(ie,Pe,ne,me),He(ne,Pe,ie)&&et(null))}async function Gn(){const te=c(),ie=Ae();if(!te||!ie||!_())return;const Pe=e.instanceId,ne=we(),me=++g;x=ne,U("authorizing"),ce(null);try{if(Je().type==="key"){await Dn(te,ie,Pe,me,ne);return}if(Je().type==="command"){await Hn(te,ie,Pe,me,ne);return}je=K(),Re(j()&&je===null),await Wn(te,ie,Pe,me,ne)}catch(Be){if(!He(me,Pe,ie))return;if(je&&!je.closed&&je.close(),je=null,H6(Be)){U("prompts");return}ce(id(Be,t("settings.providers.errors.authorizationFailed"))),U("error")}}async function dr(){var Be;const te=c(),ie=Ae();if(!te||!ie||!re().trim())return;const Pe=e.instanceId,ne=x;if(!ne)return;const me=++g;U("authorizing"),ce(null);try{const lt=(Be=$())==null?void 0:Be.attemptID;if(!lt)throw new Error(t("settings.providers.errors.noAuthorization"));if(await ie.integration.oauth.complete({integrationID:te,attemptID:lt,code:re().trim(),location:he(ne)},Nt(ne)),!He(me,Pe,ie))return;await yt(ie,Pe,me,ne),He(me,Pe,ie)&&et(null)}catch(lt){if(!He(me,Pe,ie))return;ce(id(lt,t("settings.providers.errors.authorizationFailed"))),U("code")}}async function mi(te){const ie=Ae(),Pe=r().find(lt=>lt.id===te);if(!ie||!Pe)return;const ne=e.instanceId,me=we();De();const Be=++g;ce(null),U("authorizing");try{const lt=Y(Pe);if(lt==="not-disconnectable"){ce(t("settings.providers.errors.envDisconnectUnavailable")),U("error");return}if(lt!=="credential-remove"||(await Promise.all(Pe.credentialIds.map(it=>ie.credential.remove({credentialID:it},Nt(me,{includeDirectory:!0})))),!He(Be,ne,ie)))return;await yt(ie,ne,Be,me),He(Be,ne,ie)&&et(null)}catch(lt){if(!He(Be,ne,ie))return;ce(id(lt,t("settings.providers.errors.removeFailed"))),U("idle")}}function ur(){var Be;const te=c(),ie=(Be=$())==null?void 0:Be.attemptID,Pe=T(),ne=Ae();e.instanceId;const me=x;te&&ie&&ne&&me&&ne.integration.oauth.cancel({integrationID:te,attemptID:ie,location:he(me)},Nt(me)).catch(()=>{}),te&&Pe&&ne&&me&&ne.integration.command.cancel({integrationID:te,attemptID:Pe,location:he(me)},Nt(me)).catch(()=>{}),De(),U("prompts"),C(null),D(null),q(null),ce(null)}function js(te){var ne;const ie=n()[te];if(!ie||ie.length===0){const me=((ne=r().find(Be=>Be.id===te))==null?void 0:ne.source)??"unknown";return t(`settings.providers.source.${me}`)}const Pe=new Set(ie.map(me=>me.type));return Pe.size>1?t("settings.providers.method.mixed"):Pe.has("oauth")?t("settings.providers.method.oauth"):Pe.has("command")?t("settings.providers.method.command"):t("settings.providers.method.api")}function pi(te){const ie=te.modelCount===1?t("settings.providers.models.one",{count:te.modelCount}):t("settings.providers.models.other",{count:te.modelCount});return[...new Set([js(te.id),Oe(te),ie].filter(Boolean))].join(" • ")}const Ba=()=>[y(Q,{get when(){return!e.embedded},get children(){var te=y8(),ie=te.firstChild,Pe=ie.firstChild,ne=Pe.firstChild,me=ie.nextSibling;return p(ie,y(JS,{class:"settings-card-heading-icon"}),Pe),p(Pe,y(_t.Title,{class:"providers-manager-title",get children(){return t("settings.providers.title")}}),ne),p(ne,()=>t("settings.providers.subtitle")),me.$$click=()=>P(!1),p(me,y(Ko,{class:"w-4 h-4"})),de(()=>pe(me,"aria-label",t("settings.close"))),te}}),(()=>{var te=M8();return p(te,y(Q,{get when(){return!Ae()},get children(){var ie=Fg();return p(ie,()=>t("settings.providers.empty.noInstance")),ie}}),null),p(te,y(Q,{get when(){return Ae()},get children(){return[(()=>{var ie=v8(),Pe=ie.firstChild,ne=Pe.nextSibling;return p(ie,y(Te,{get value(){return ve()},onChange:me=>me&&i(me.id),get options(){return Xe()},optionValue:"id",optionTextValue:"name",itemComponent:me=>y(Te.Item,{get item(){return me.item},class:"selector-option selector-option--multiline",get children(){var Be=A8(),lt=Be.firstChild,it=lt.firstChild,Ve=it.nextSibling,at=Ve.nextSibling,st=at.nextSibling,vt=st.nextSibling;return p(Be,y(Te.ItemLabel,{class:"selector-option-label",get children(){return me.item.rawValue.name}}),lt),p(it,()=>me.item.rawValue.id),p(at,(()=>{var mt=_e(()=>me.item.rawValue.modelCount===1);return()=>mt()?t("settings.providers.models.one",{count:me.item.rawValue.modelCount}):t("settings.providers.models.other",{count:me.item.rawValue.modelCount})})()),p(vt,()=>me.item.rawValue.connectionSummary),Be}}),get children(){return[y(Te.Trigger,{class:"selector-trigger providers-connect-select",get"aria-label"(){return t("settings.providers.selectProvider")},get children(){return[(()=>{var me=N0();return p(me,y(Te.Value,{children:Be=>(()=>{var lt=P8(),it=lt.firstChild;return p(it,()=>{var Ve;return((Ve=Be.selectedOption())==null?void 0:Ve.name)??t("settings.providers.selectProvider")}),p(lt,y(Q,{get when(){return Be.selectedOption()},get children(){var Ve=D8(),at=Ve.firstChild;return p(Ve,()=>{var st;return(st=Be.selectedOption())==null?void 0:st.id},at),p(Ve,()=>{var st;return(st=Be.selectedOption())==null?void 0:st.connectionSummary},null),Ve}}),null),lt})()})),me})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),Pe),Pe.$$click=()=>{var me;return et(((me=ve())==null?void 0:me.id)??null)},p(Pe,()=>t("settings.providers.actions.connect")),ne.$$click=()=>void Qt(),p(ne,y(_d,{get class(){return J()?"providers-spin-icon":"providers-button-icon"}}),null),p(ne,()=>t("settings.providers.refresh"),null),de(me=>{var it;var Be=!((it=ve())!=null&&it.canConnect),lt=J();return Be!==me.e&&(Pe.disabled=me.e=Be),lt!==me.t&&(ne.disabled=me.t=lt),me},{e:void 0,t:void 0}),ie})(),y(Q,{get when(){return z()},get children(){var ie=U0();return p(ie,z),ie}}),y(Q,{get when(){return N()},get children(){var ie=U0();return p(ie,N),ie}}),y(Q,{get when(){return c()},get children(){var ie=E8(),Pe=ie.firstChild,ne=Pe.firstChild,me=ne.firstChild,Be=me.nextSibling,lt=ne.nextSibling,it=Pe.nextSibling;return p(me,()=>t("settings.providers.auth.title",{provider:Ie()})),p(Be,()=>t("settings.providers.auth.subtitle")),lt.$$click=()=>et(null),p(lt,y(Ko,{class:"w-4 h-4"})),p(ie,y(Q,{get when(){return ze().length>1},get children(){var Ve=w8(),at=Ve.firstChild,st=at.firstChild,vt=st.nextSibling;return p(st,()=>t("settings.providers.method.title")),p(vt,()=>t("settings.providers.method.subtitle")),p(Ve,y(Te,{get value(){return Ne()},onChange:mt=>{mt&&(w(mt.index),k(R0(mt.method.type==="command"?void 0:mt.method.form)),b(""),C(null),ee(""),U("prompts"),ce(null))},get options(){return ze()},optionValue:"value",optionTextValue:"label",get disabled(){return _e(()=>W()!=="prompts")()&&W()!=="error"},itemComponent:mt=>y(Te.Item,{get item(){return mt.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return mt.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger providers-method-trigger",get"aria-label"(){return t("settings.providers.method.title")},get children(){return[(()=>{var mt=N0();return p(mt,y(Te.Value,{children:Pn=>(()=>{var On=O8();return p(On,()=>{var Nv;return(Nv=Pn.selectedOption())==null?void 0:Nv.label}),On})()})),mt})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),null),Ve}}),it),p(ie,y(Q,{get when(){return Je().type==="key"},get children(){var Ve=b8(),at=Ve.firstChild,st=at.firstChild,vt=st.nextSibling,mt=vt.firstChild;return p(st,()=>t("settings.providers.apiKey.label")),p(vt,y(uA,{class:"providers-input-icon"}),mt),mt.$$input=Pn=>b(Pn.currentTarget.value),de(()=>pe(mt,"placeholder",t("settings.providers.apiKey.placeholder"))),de(()=>mt.value=S()),Ve}}),it),p(ie,y(Q,{get when(){return ot()},get children(){return y(a8,{get fields(){return ot()},get answer(){return v()},get disabled(){return _e(()=>W()!=="prompts")()&&W()!=="error"},onAnswer:Tt})}}),it),p(ie,y(Q,{get when(){return _e(()=>Je().type==="oauth"&&!ot())()&&(W()==="prompts"||W()==="error"||W()==="authorizing")},get children(){var Ve=Fg();return p(Ve,()=>t("settings.providers.oauth.noPrompts")),Ve}}),it),p(ie,y(Q,{get when(){return _e(()=>Je().type==="command")()&&(W()==="prompts"||W()==="error"||W()==="authorizing")},get children(){var Ve=S8(),at=Ve.firstChild,st=at.nextSibling;return p(at,()=>t("settings.providers.command.description")),p(st,()=>{var vt;return(vt=gt())==null?void 0:vt.command.join(" ")}),Ve}}),it),p(ie,y(Q,{get when(){return W()==="code"},get children(){var Ve=k8(),at=Ve.firstChild,st=at.firstChild,vt=at.nextSibling,mt=vt.firstChild,Pn=mt.nextSibling;return p(at,y(Oi,{class:"providers-instructions-icon"}),st),p(st,()=>{var On;return((On=$())==null?void 0:On.instructions)||t("settings.providers.oauth.enterCode")}),p(mt,()=>t("settings.providers.oauth.codeLabel")),Pn.$$input=On=>ee(On.currentTarget.value),Xs(On=>{B=On},Pn),de(()=>pe(Pn,"placeholder",t("settings.providers.oauth.codePlaceholder"))),de(()=>Pn.value=re()),Ve}}),it),p(ie,y(Q,{get when(){return W()==="waiting"},get children(){var Ve=x8(),at=Ve.firstChild,st=at.firstChild,vt=st.nextSibling,mt=at.nextSibling;return p(Ve,y(Nn,{class:"providers-spin-icon"}),at),p(st,(()=>{var Pn=_e(()=>Je().type==="command");return()=>Pn()?t("settings.providers.command.waitingTitle"):t("settings.providers.oauth.waitingTitle")})()),p(vt,(()=>{var Pn=_e(()=>Je().type==="command");return()=>{var On;return Pn()?R()??t("settings.providers.command.waitingMessage"):(On=$())==null?void 0:On.instructions}})()),mt.$$click=ur,p(mt,()=>t("settings.providers.oauth.cancelWait")),Ve}}),it),p(ie,y(Q,{get when(){return _e(()=>!!($()&&Pm($().url)))()&&(W()==="code"||W()==="waiting")},get children(){var Ve=$8(),at=Ve.firstChild,st=at.nextSibling,vt=st.nextSibling;return p(at,y(Oi,{class:"w-4 h-4"}),null),p(at,()=>t("settings.providers.oauth.openPage"),null),st.$$click=()=>void I($().url,{sameTab:!0}),p(st,()=>t("settings.providers.oauth.openHere")),vt.$$click=()=>void Z(),p(vt,(()=>{var mt=_e(()=>!!be());return()=>mt()?t("settings.providers.oauth.linkCopied"):t("settings.providers.oauth.copyLink")})()),de(()=>{var mt;return pe(at,"href",(mt=$())==null?void 0:mt.url)}),Ve}}),it),p(ie,y(Q,{get when(){return _e(()=>!!fe())()&&$()},get children(){var Ve=_8();return p(Ve,()=>t("settings.providers.oauth.popupBlocked")),Ve}}),it),p(ie,y(Q,{get when(){return W()==="success"},get children(){var Ve=C8(),at=Ve.firstChild;return p(Ve,y(ZS,{class:"providers-success-icon"}),at),p(at,()=>t("settings.providers.success")),Ve}}),it),p(it,y(Q,{get when(){return W()==="code"},get fallback(){return(()=>{var Ve=B0();return Ve.$$click=()=>void Gn(),p(Ve,y(Q,{get when(){return W()==="authorizing"},get fallback(){return t("settings.providers.actions.continue")},get children(){return[y(Nn,{class:"providers-spin-icon"}),_e(()=>t("settings.providers.actions.working"))]}})),de(()=>Ve.disabled=!_()),Ve})()},get children(){var Ve=B0();return Ve.$$click=()=>void dr(),p(Ve,()=>t("settings.providers.oauth.submitCode")),de(()=>Ve.disabled=!re().trim()),Ve}})),de(Ve=>{var at=t("settings.providers.actions.close"),st=t("settings.providers.actions.close");return at!==Ve.e&&pe(lt,"aria-label",Ve.e=at),st!==Ve.t&&pe(lt,"title",Ve.t=st),Ve},{e:void 0,t:void 0}),ie}}),(()=>{var ie=T8(),Pe=ie.firstChild;return p(Pe,()=>t("settings.providers.configured.title")),p(ie,y(Q,{get when(){return V()},get fallback(){return[y(Q,{get when(){return J()},get children(){var ne=R8(),me=ne.firstChild;return p(ne,y(Nn,{class:"providers-spin-icon"}),me),p(me,()=>t("settings.providers.loading")),ne}}),y(Q,{get when(){return _e(()=>!J())()&&se().length===0},get children(){var ne=Fg();return p(ne,()=>t("settings.providers.empty.noConfiguredProviders")),ne}}),(()=>{var ne=I8();return p(ne,y(Ut,{get each(){return se()},children:me=>(()=>{var Be=U8(),lt=Be.firstChild,it=lt.firstChild,Ve=it.nextSibling,at=lt.nextSibling,st=at.firstChild;return p(it,()=>me.name||me.id),p(Ve,y(Q,{get when(){return _e(()=>!!me.name)()&&me.name!==me.id},get children(){return[(()=>{var vt=L8();return p(vt,()=>me.id),vt})(),F8()]}}),null),p(Ve,()=>pi(me),null),st.$$click=()=>{h=me.id,u(me.id)},Xs(vt=>f.set(me.id,vt),st),p(st,()=>t("settings.providers.actions.manageModels")),p(at,y(Q,{get when(){return Y(me)==="credential-remove"},get children(){var vt=N8();return vt.$$click=()=>void mi(me.id),p(vt,()=>t("settings.providers.actions.disconnect")),de(mt=>{var Pn=W()!=="idle",On=t("settings.providers.actions.disconnect");return Pn!==mt.e&&(vt.disabled=mt.e=Pn),On!==mt.t&&pe(vt,"title",mt.t=On),mt},{e:void 0,t:void 0}),vt}}),null),Be})()})),ne})()]},children:ne=>y(p8,{get providerId(){return ne().id},get providerName(){return ne().name||ne().id},get models(){return ne().models},onBack:Ot})}),null),ie})()]}}),null),te})()];return e.embedded?(()=>{var te=B8();return p(te,Ba),te})():y(_t,{get open(){return!!e.open},onOpenChange:P,get children(){return y(_t.Portal,{get children(){return[y(_t.Overlay,{class:"modal-overlay"}),y(_t.Content,{class:"modal-surface providers-manager-modal",get children(){return Ba()}})]}})}})};Ht(["click","input"]);const V8=e=>y(K8,{get instanceId(){return e.instanceId??bs()??""},get location(){return e.location},embedded:!0});var j8=F('<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 q8=()=>{const{t:e}=kt();return Ns(()=>void Gs()),(()=>{var t=j8(),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(HS,{})),t})()};var z8=F('<div class="flex-1 min-w-0">'),W8=F('<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>'),H8=F('<span class="selector-trigger-primary selector-trigger-primary--align-left">');const G8=()=>{const{t:e}=kt(),{serverSettings:t,updateLogLevel:n}=Tn(),s=$e(()=>[{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=$e(()=>s().find(o=>o.value===t().logLevel)??s()[0]);return(()=>{var o=W8(),a=o.firstChild,i=a.firstChild,c=i.firstChild,l=c.firstChild,d=l.nextSibling,u=c.nextSibling,f=i.nextSibling,h=f.firstChild,m=h.firstChild,w=m.firstChild,S=w.nextSibling;return p(o,y(ek,{}),a),p(o,y(q8,{}),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(h,y(Te,{get value(){return r()},onChange:b=>b&&n(b.value),get options(){return s()},optionValue:"value",optionTextValue:"label",itemComponent:b=>y(Te.Item,{get item(){return b.item},class:"selector-option",get children(){return y(Te.ItemLabel,{class:"selector-option-label",get children(){return b.item.rawValue.label}})}}),get children(){return[y(Te.Trigger,{class:"selector-trigger",get"aria-label"(){return e("settings.opencode.logLevel.title")},get children(){return[(()=>{var b=z8();return p(b,y(Te.Value,{children:v=>(()=>{var k=H8();return p(k,()=>{var $;return($=v.selectedOption())==null?void 0:$.label}),k})()})),b})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}}),null),o})()};var Z8=F("<div class=space-y-2>"),J8=F('<div class="text-xs text-muted text-center py-2">'),Y8=F('<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">'),Q8=F('<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 X8=e=>{const{t}=kt(),{serverSettings:n,addEnvironmentVariable:s,removeEnvironmentVariable:r,updateEnvironmentVariables:o,isSecureEnvVar:a,toggleSecureEnvVar:i}=Tn(),[c,l]=L(n().environmentVariables||{}),[d,u]=L(""),[f,h]=L(""),[m,w]=L(!0),S=()=>Object.entries(c());function b(){const T=d().trim(),D=f().trim();T&&(s(T,D,m()),l({...c(),[T]:D}),u(""),h(""),w(!0))}function v(T){r(T);const{[T]:D,...R}=c();l(R)}function k(T,D){const R={...c(),[T]:D};l(R),o(R)}function $(T){i(T)}function C(T){T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),b())}return(()=>{var T=Y8(),D=T.firstChild,R=D.firstChild,q=R.nextSibling,re=D.nextSibling,ee=re.firstChild,W=ee.firstChild,U=W.nextSibling,J=ee.nextSibling,le=J.nextSibling,z=re.nextSibling;return p(D,y(Bo,{class:"w-4 h-4 icon-muted"}),R),p(R,()=>t("envEditor.title")),p(q,(()=>{var M=_e(()=>S().length===1);return()=>M()?t("envEditor.count.one",{count:S().length}):t("envEditor.count.other",{count:S().length})})()),p(T,y(Q,{get when(){return S().length>0},get children(){var M=Z8();return p(M,y(Ut,{get each(){return S()},children:([N,ce])=>(()=>{var fe=Q8(),Re=fe.firstChild,be=Re.firstChild,ye=be.nextSibling,Ce=Re.nextSibling,je=Ce.nextSibling;return p(Re,y(mw,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),be),be.value=N,ye.$$input=O=>k(N,O.currentTarget.value),ye.value=ce,Ce.$$click=()=>$(N),p(Ce,(()=>{var O=_e(()=>!!a(N));return()=>O()?y(Cd,{class:"w-3.5 h-3.5"}):y(yw,{class:"w-3.5 h-3.5"})})()),je.$$click=()=>v(N),p(je,y(Tu,{class:"w-3.5 h-3.5"})),de(O=>{var g=e.disabled,x=t("envEditor.fields.name.placeholder"),A=t("envEditor.fields.name.readOnlyTitle"),E=a(N)?"password":"text",H=e.disabled,B=t("envEditor.fields.value.placeholder"),oe=a(N)?"new-password":"off",Ae=a(N)?!1:void 0,we=a(N)?"off":void 0,he=e.disabled,Ee=`p-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${a(N)?"icon-accent-hover text-accent":"icon-muted icon-accent-hover"}`,Ge=a(N)?t("envEditor.fields.secure.enabled"):t("envEditor.fields.secure.disabled"),Xe=e.disabled,se=t("envEditor.actions.remove.title");return g!==O.e&&(be.disabled=O.e=g),x!==O.t&&pe(be,"placeholder",O.t=x),A!==O.a&&pe(be,"title",O.a=A),E!==O.o&&pe(ye,"type",O.o=E),H!==O.i&&(ye.disabled=O.i=H),B!==O.n&&pe(ye,"placeholder",O.n=B),oe!==O.s&&pe(ye,"autocomplete",O.s=oe),Ae!==O.h&&pe(ye,"spellcheck",O.h=Ae),we!==O.r&&pe(ye,"autocapitalize",O.r=we),he!==O.d&&(Ce.disabled=O.d=he),Ee!==O.l&&_s(Ce,O.l=Ee),Ge!==O.u&&pe(Ce,"title",O.u=Ge),Xe!==O.c&&(je.disabled=O.c=Xe),se!==O.w&&pe(je,"title",O.w=se),O},{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}),fe})()})),M}}),re),p(ee,y(mw,{class:"w-3.5 h-3.5 icon-muted flex-shrink-0"}),W),W.addEventListener("keypress",C),W.$$input=M=>u(M.currentTarget.value),U.addEventListener("keypress",C),U.$$input=M=>h(M.currentTarget.value),J.$$click=()=>w(!m()),p(J,(()=>{var M=_e(()=>!!m());return()=>M()?y(Cd,{class:"w-3.5 h-3.5"}):y(yw,{class:"w-3.5 h-3.5"})})()),le.$$click=b,p(le,y(Eu,{class:"w-3.5 h-3.5"})),p(T,y(Q,{get when(){return S().length===0},get children(){var M=J8();return p(M,()=>t("envEditor.empty")),M}}),z),p(z,()=>t("envEditor.help")),de(M=>{var N=e.disabled,ce=t("envEditor.fields.name.placeholder"),fe=m()?"password":"text",Re=e.disabled,be=t("envEditor.fields.value.placeholder"),ye=e.disabled,Ce=`p-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${m()?"icon-accent-hover text-accent":"icon-muted icon-accent-hover"}`,je=m()?t("envEditor.fields.secure.enabled"):t("envEditor.fields.secure.disabled"),O=e.disabled||!d().trim(),g=t("envEditor.actions.add.title");return N!==M.e&&(W.disabled=M.e=N),ce!==M.t&&pe(W,"placeholder",M.t=ce),fe!==M.a&&pe(U,"type",M.a=fe),Re!==M.o&&(U.disabled=M.o=Re),be!==M.i&&pe(U,"placeholder",M.i=be),ye!==M.n&&(J.disabled=M.n=ye),Ce!==M.s&&_s(J,M.s=Ce),je!==M.h&&pe(J,"title",M.h=je),O!==M.r&&(le.disabled=M.r=O),g!==M.d&&pe(le,"title",M.d=g),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(()=>W.value=d()),de(()=>U.value=f()),T})()};Ht(["input","click"]);var e9=F('<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 t9=()=>{const{t:e}=kt(),t=Tn(),n=$e(()=>[...yp(t).filter(s=>s.id==="behavior.autoCleanupBlankSessions"||s.id==="behavior.keepUnseenSubagentIdleStatus"||s.id==="behavior.focusExistingWindowOnSecondLaunch"&&qE()||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=e9(),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(X8,{}),null),p(u,y(vp,{settings:n,get preferences(){return t.preferences}})),s})()};var n9=F("<div class=config-files-selector-value>"),s9=F('<span class="config-files-state config-files-state-inline">'),r9=F('<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">'),o9=F('<div class=selector-option-content><div class="selector-option-description config-files-selector-path">'),i9=F('<span class=config-files-selector-value-inner><span class="selector-trigger-primary selector-trigger-primary--align-left">'),a9=F('<span class="selector-trigger-secondary config-files-selector-path">'),c9=F("<div class=settings-error-message>"),K0=F("<div class=config-files-editor-empty>"),l9=F('<div class="file-viewer-content file-viewer-content--monaco config-files-editor-content">');const d9=gS(()=>ts(()=>import("./monaco-viewer-BtzCmjFO.js").then(e=>e.as),__vite__mapDeps([1,2,3,4,5])).then(e=>({default:e.MonacoFileViewer}))),u9=()=>{const{t:e}=kt(),[t,n]=L([]),[s,r]=L(null),[o,a]=L(""),[i,c]=L(""),[l,d]=L(null),[u,f]=L(!1),[h,m]=L(!1),[w,S]=L(!1),[b,v]=L(null);let k=0;const $=$e(()=>t().find(U=>U.id===s())??null),C=$e(()=>o()!==i()),T=async U=>{const J=++k;m(!0),v(null);try{const le=await ft.readConfigFile(U.id);if(J!==k)return;r(U.id),a(le.contents),c(le.contents),d(le.exists)}catch(le){if(J!==k)return;v(le instanceof Error?le.message:e("settings.configFiles.errors.loadContent")),a(""),c(""),d(null)}finally{J===k&&m(!1)}},D=async()=>C()?Wi(e("settings.configFiles.confirmDiscard.message"),{variant:"warning",confirmLabel:e("settings.configFiles.confirmDiscard.confirmLabel"),cancelLabel:e("settings.configFiles.confirmDiscard.cancelLabel"),dismissible:!1}):!0,R=async()=>{f(!0),v(null);try{const U=await ft.listConfigFiles();n(U);const J=U[0];J&&await T(J)}catch(U){v(U instanceof Error?U.message:e("settings.configFiles.errors.loadList"))}finally{f(!1)}},q=async U=>{!U||U.id===s()||!await D()||await T(U)},re=async()=>{const U=$();!U||!await D()||await T(U)},ee=async()=>{const U=$();if(!U)return;const J=o();S(!0),v(null);try{await ft.writeConfigFile(U.id,J),o()===J&&c(J),d(!0),Fn({message:e("settings.configFiles.toast.saveSuccess"),variant:"success"})}catch(le){v(le instanceof Error?le.message:e("settings.configFiles.errors.save")),Fn({message:e("settings.configFiles.toast.saveError"),variant:"error"})}finally{S(!1)}};Ns(()=>{R()});const W=Bk(D);return nt(W),(()=>{var U=r9(),J=U.firstChild,le=J.nextSibling,z=le.firstChild,M=z.firstChild,N=M.nextSibling,ce=N.firstChild,fe=ce.nextSibling,Re=z.nextSibling;return p(J,()=>e("settings.configFiles.title")),p(M,y(Te,{get value(){return $()??void 0},onChange:be=>void q(be),get options(){return t()},optionValue:"id",optionTextValue:"label",get disabled(){return u()||t().length===0},itemComponent:be=>y(Te.Item,{get item(){return be.item},class:"selector-option",get children(){var ye=o9(),Ce=ye.firstChild;return p(ye,y(Te.ItemLabel,{class:"selector-option-label",get children(){return be.item.rawValue.label}}),Ce),p(Ce,()=>be.item.rawValue.path),ye}}),get children(){return[y(Te.Trigger,{class:"selector-trigger config-files-selector-trigger",get"aria-label"(){return e("settings.configFiles.selector.label")},get children(){return[(()=>{var be=n9();return p(be,y(Te.Value,{children:ye=>(()=>{var Ce=i9(),je=Ce.firstChild;return p(je,()=>{var O;return((O=ye.selectedOption())==null?void 0:O.label)??e("settings.configFiles.selector.placeholder")}),p(Ce,y(Q,{get when(){return ye.selectedOption()},children:O=>(()=>{var g=a9();return p(g,()=>O().path),g})()}),null),Ce})()})),be})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})),p(N,y(Q,{get when(){return _e(()=>!!$())()&&(C()||l()===!1)},get children(){var be=s9();return p(be,(()=>{var ye=_e(()=>!!C());return()=>ye()?e("settings.configFiles.state.unsaved"):e("settings.configFiles.state.notCreated")})()),be}}),ce),ce.$$click=()=>void ee(),p(ce,y(Q,{get when(){return w()},get fallback(){return y(BA,{class:"h-4 w-4"})},get children(){return y(_d,{class:"h-4 w-4 animate-spin"})}})),fe.$$click=()=>void re(),p(fe,y(_d,{get class(){return`h-4 w-4${h()?" animate-spin":""}`}})),p(le,y(Q,{get when(){return b()},children:be=>(()=>{var ye=c9();return p(ye,be),ye})()}),Re),p(Re,y(Q,{get when(){return _e(()=>!u()&&!h())()&&$()},get fallback(){return(()=>{var be=K0();return p(be,(()=>{var ye=_e(()=>!!(u()||h()));return()=>ye()?e("instanceInfo.loading"):e("settings.configFiles.empty")})()),be})()},children:be=>(()=>{var ye=l9();return p(ye,y(hT,{get fallback(){return(()=>{var Ce=K0();return p(Ce,()=>e("instanceInfo.loading")),Ce})()},get children(){return y(d9,{scopeKey:"settings-config-files",get path(){return be().path},get content(){return o()},wordWrap:"off",compactGutter:!0,onSave:()=>void ee(),onContentChange:Ce=>a(Ce)})}})),ye})()})),de(be=>{var ye=e("settings.configFiles.actions.save"),Ce=e("settings.configFiles.actions.save"),je=!$()||w()||h()||!C(),O=e("settings.configFiles.actions.reload"),g=e("settings.configFiles.actions.reload"),x=!$()||h()||w();return ye!==be.e&&pe(ce,"title",be.e=ye),Ce!==be.t&&pe(ce,"aria-label",be.t=Ce),je!==be.a&&(ce.disabled=be.a=je),O!==be.o&&pe(fe,"title",be.o=O),g!==be.i&&pe(fe,"aria-label",be.i=g),x!==be.n&&(fe.disabled=be.n=x),be},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),U})()};Ht(["click"]);function f9(e={}){const[t,n]=DS({value:()=>ge(e.isSelected),defaultValue:()=>!!ge(e.defaultIsSelected),onChange:o=>{var a;return(a=e.onSelectedChange)==null?void 0:a.call(e,o)}});return{isSelected:t,setIsSelected:o=>{!ge(e.isReadOnly)&&!ge(e.isDisabled)&&n(o)},toggle:()=>{!ge(e.isReadOnly)&&!ge(e.isDisabled)&&n(!t())}}}var g9={};el(g9,{Control:()=>mE,Description:()=>pE,ErrorMessage:()=>yE,Input:()=>vE,Label:()=>wE,Root:()=>bE,Switch:()=>lc,Thumb:()=>SE,useSwitchContext:()=>hi});var hE=Ir();function hi(){const e=Lr(hE);if(e===void 0)throw new Error("[kobalte]: `useSwitchContext` must be used within a `Switch` component");return e}function mE(e){const t=or(),n=hi(),s=Dt({id:n.generateId("control")},e),[r,o]=Et(s,["onClick","onKeyDown"]);return y(zt,Se({as:"div",onClick:c=>{var l;Zt(c,r.onClick),n.toggle(),(l=n.inputRef())==null||l.focus()},onKeyDown:c=>{var l;Zt(c,r.onKeyDown),c.key===qm.Space&&(n.toggle(),(l=n.inputRef())==null||l.focus())}},()=>t.dataset(),()=>n.dataset(),o))}function pE(e){const t=hi();return y(rp,Se(()=>t.dataset(),e))}function yE(e){const t=hi();return y(mp,Se(()=>t.dataset(),e))}function vE(e){const t=or(),n=hi(),s=Dt({id:n.generateId("input")},e),[r,o,a]=Et(s,["ref","style","onChange","onFocus","onBlur"],Ck),{fieldProps:i}=Ek(o);return y(zt,Se({as:"input",ref(u){var f=Mn(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 Qc({...$u},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=>{Zt(u,r.onChange),u.stopPropagation();const f=u.target;n.setIsChecked(f.checked),f.checked=n.checked()},onFocus:u=>{Zt(u,r.onFocus),n.setIsFocused(!0)},onBlur:u=>{Zt(u,r.onBlur),n.setIsFocused(!1)}},()=>t.dataset(),()=>n.dataset(),a))}function wE(e){const t=hi();return y(Tk,Se(()=>t.dataset(),e))}function bE(e){let t;const n=`switch-${ti()}`,s=Dt({value:"on",id:n},e),[r,o,a]=Et(s,["ref","children","value","checked","defaultChecked","onChange","onPointerDown"],ck),[i,c]=L(),[l,d]=L(!1),{formControlContext:u}=lk(o),f=f9({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()});Mk(()=>t,()=>f.setIsSelected(r.defaultChecked??!1));const h=S=>{Zt(S,r.onPointerDown),l()&&S.preventDefault()},m=$e(()=>({"data-checked":f.isSelected()?"":void 0})),w={value:()=>r.value,dataset:m,checked:()=>f.isSelected(),inputRef:i,generateId:Ea(()=>ge(o.id)),toggle:()=>f.toggle(),setIsChecked:S=>f.setIsSelected(S),setIsFocused:d,setInputRef:c};return y(sp.Provider,{value:u,get children(){return y(hE.Provider,{value:w,get children(){return y(zt,Se({as:"div",ref(S){var b=Mn(v=>t=v,r.ref);typeof b=="function"&&b(S)},role:"group",get id(){return ge(o.id)},onPointerDown:h},()=>u.dataset(),m,a,{get children(){return y(h9,{state:w,get children(){return r.children}})}}))}})}})}function h9(e){const t=fS(()=>{const n=e.children;return xu(n)?n(e.state):n});return _e(t)}function SE(e){const t=or(),n=hi(),s=Dt({id:n.generateId("thumb")},e);return y(zt,Se({as:"div"},()=>t.dataset(),()=>n.dataset(),s))}var lc=Object.assign(bE,{Control:mE,Description:pE,ErrorMessage:yE,Input:vE,Label:wE,Thumb:SE}),m9=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},kE={},os={};let Av;const p9=[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];os.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};os.getSymbolTotalCodewords=function(t){return p9[t]};os.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};os.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Av=t};os.isKanjiModeEnabled=function(){return typeof Av<"u"};os.toSJIS=function(t){return Av(t)};var Kf={};(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}}})(Kf);function xE(){this.buffer=[],this.length=0}xE.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 y9=xE;function Tl(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)}Tl.prototype.set=function(e,t,n,s){const r=e*this.size+t;this.data[r]=n,s&&(this.reservedBit[r]=!0)};Tl.prototype.get=function(e,t){return this.data[e*this.size+t]};Tl.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Tl.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var v9=Tl,$E={};(function(e){const t=os.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}})($E);var _E={};const w9=os.getSymbolSize,V0=7;_E.getPositions=function(t){const n=w9(t);return[[0,0],[n-V0,0],[0,n-V0]]};var CE={};(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 h=r.get(u,f);h===l?i++:(i>=5&&(a+=t.N1+(i-5)),l=h,i=1),h=r.get(f,u),h===d?c++:(c>=5&&(a+=t.N1+(c-5)),d=h,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}})(CE);var Vf={};const Zr=Kf,ad=[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];Vf.getBlocksCount=function(t,n){switch(n){case Zr.L:return ad[(t-1)*4+0];case Zr.M:return ad[(t-1)*4+1];case Zr.Q:return ad[(t-1)*4+2];case Zr.H:return ad[(t-1)*4+3];default:return}};Vf.getTotalCodewordsCount=function(t,n){switch(n){case Zr.L:return cd[(t-1)*4+0];case Zr.M:return cd[(t-1)*4+1];case Zr.Q:return cd[(t-1)*4+2];case Zr.H:return cd[(t-1)*4+3];default:return}};var EE={},jf={};const Sc=new Uint8Array(512),yu=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Sc[n]=t,yu[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Sc[n]=Sc[n-255]})();jf.log=function(t){if(t<1)throw new Error("log("+t+")");return yu[t]};jf.exp=function(t){return Sc[t]};jf.mul=function(t,n){return t===0||n===0?0:Sc[yu[t]+yu[n]]};(function(e){const t=jf;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}})(EE);const TE=EE;function Dv(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Dv.prototype.initialize=function(t){this.degree=t,this.genPoly=TE.generateECPolynomial(this.degree)};Dv.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=TE.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 b9=Dv,ME={},$o={},Pv={};Pv.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var lr={};const AE="[0-9]+",S9="[A-Z $%*+\\-./:]+";let Jc="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Jc=Jc.replace(/u/g,"\\u");const k9="(?:(?![A-Z0-9 $%*+\\-./:]|"+Jc+`)(?:.|[\r
35
35
  ]))+`;lr.KANJI=new RegExp(Jc,"g");lr.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");lr.BYTE=new RegExp(k9,"g");lr.NUMERIC=new RegExp(AE,"g");lr.ALPHANUMERIC=new RegExp(S9,"g");const x9=new RegExp("^"+Jc+"$"),$9=new RegExp("^"+AE+"$"),_9=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");lr.testKanji=function(t){return x9.test(t)};lr.testNumeric=function(t){return $9.test(t)};lr.testAlphanumeric=function(t){return _9.test(t)};(function(e){const t=Pv,n=lr;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}}})($o);(function(e){const t=os,n=Vf,s=Kf,r=$o,o=Pv,a=7973,i=t.getBCHDigit(a);function c(f,h,m){for(let w=1;w<=40;w++)if(h<=e.getCapacity(w,m,f))return w}function l(f,h){return r.getCharCountIndicator(f,h)+4}function d(f,h){let m=0;return f.forEach(function(w){const S=l(w.mode,h);m+=S+w.getBitsLength()}),m}function u(f,h){for(let m=1;m<=40;m++)if(d(f,m)<=e.getCapacity(m,h,r.MIXED))return m}e.from=function(h,m){return o.isValid(h)?parseInt(h,10):m},e.getCapacity=function(h,m,w){if(!o.isValid(h))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=r.BYTE);const S=t.getSymbolTotalCodewords(h),b=n.getTotalCodewordsCount(h,m),v=(S-b)*8;if(w===r.MIXED)return v;const k=v-l(w,h);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(h,m){let w;const S=s.from(m,s.M);if(Array.isArray(h)){if(h.length>1)return u(h,S);if(h.length===0)return 1;w=h[0]}else w=h;return c(w.mode,w.getLength(),S)},e.getEncodedBits=function(h){if(!o.isValid(h)||h<7)throw new Error("Invalid QR Code version");let m=h<<12;for(;t.getBCHDigit(m)-i>=0;)m^=a<<t.getBCHDigit(m)-i;return h<<12|m}})(ME);var DE={};const Om=os,PE=1335,C9=21522,j0=Om.getBCHDigit(PE);DE.getEncodedBits=function(t,n){const s=t.bit<<3|n;let r=s<<10;for(;Om.getBCHDigit(r)-j0>=0;)r^=PE<<Om.getBCHDigit(r)-j0;return(s<<10|r)^C9};var OE={};const E9=$o;function xa(e){this.mode=E9.NUMERIC,this.data=e.toString()}xa.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};xa.prototype.getLength=function(){return this.data.length};xa.prototype.getBitsLength=function(){return xa.getBitsLength(this.data.length)};xa.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 T9=xa;const M9=$o,Ng=["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 $a(e){this.mode=M9.ALPHANUMERIC,this.data=e}$a.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};$a.prototype.getLength=function(){return this.data.length};$a.prototype.getBitsLength=function(){return $a.getBitsLength(this.data.length)};$a.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let s=Ng.indexOf(this.data[n])*45;s+=Ng.indexOf(this.data[n+1]),t.put(s,11)}this.data.length%2&&t.put(Ng.indexOf(this.data[n]),6)};var A9=$a;const D9=$o;function _a(e){this.mode=D9.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}_a.getBitsLength=function(t){return t*8};_a.prototype.getLength=function(){return this.data.length};_a.prototype.getBitsLength=function(){return _a.getBitsLength(this.data.length)};_a.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var P9=_a;const O9=$o,R9=os;function Ca(e){this.mode=O9.KANJI,this.data=e}Ca.getBitsLength=function(t){return t*13};Ca.prototype.getLength=function(){return this.data.length};Ca.prototype.getBitsLength=function(){return Ca.getBitsLength(this.data.length)};Ca.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=R9.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]+`
36
36
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var I9=Ca,RE={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,h,m,w,S;!i.empty();){c=i.pop(),l=c.value,u=c.cost,f=n[l]||{};for(d in f)f.hasOwnProperty(d)&&(h=f[d],m=u+h,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})(RE);var L9=RE.exports;(function(e){const t=$o,n=T9,s=A9,r=P9,o=I9,a=lr,i=os,c=L9;function l(b){return unescape(encodeURIComponent(b)).length}function d(b,v,k){const $=[];let C;for(;(C=b.exec(k))!==null;)$.push({data:C[0],index:C.index,mode:v,length:C[0].length});return $}function u(b){const v=d(a.NUMERIC,t.NUMERIC,b),k=d(a.ALPHANUMERIC,t.ALPHANUMERIC,b);let $,C;return i.isKanjiModeEnabled()?($=d(a.BYTE,t.BYTE,b),C=d(a.KANJI,t.KANJI,b)):($=d(a.BYTE_KANJI,t.BYTE,b),C=[]),v.concat(k,$,C).sort(function(D,R){return D.index-R.index}).map(function(D){return{data:D.data,mode:D.mode,length:D.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 h(b){return b.reduce(function(v,k){const $=v.length-1>=0?v[v.length-1]:null;return $&&$.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 $=b[k];switch($.mode){case t.NUMERIC:v.push([$,{data:$.data,mode:t.ALPHANUMERIC,length:$.length},{data:$.data,mode:t.BYTE,length:$.length}]);break;case t.ALPHANUMERIC:v.push([$,{data:$.data,mode:t.BYTE,length:$.length}]);break;case t.KANJI:v.push([$,{data:$.data,mode:t.BYTE,length:l($.data)}]);break;case t.BYTE:v.push([{data:$.data,mode:t.BYTE,length:l($.data)}])}}return v}function w(b,v){const k={},$={start:{}};let C=["start"];for(let T=0;T<b.length;T++){const D=b[T],R=[];for(let q=0;q<D.length;q++){const re=D[q],ee=""+T+q;R.push(ee),k[ee]={node:re,lastCount:0},$[ee]={};for(let W=0;W<C.length;W++){const U=C[W];k[U]&&k[U].node.mode===re.mode?($[U][ee]=f(k[U].lastCount+re.length,re.mode)-f(k[U].lastCount,re.mode),k[U].lastCount+=re.length):(k[U]&&(k[U].lastCount=re.length),$[U][ee]=f(re.length,re.mode)+4+t.getCharCountIndicator(re.mode,v))}}C=R}for(let T=0;T<C.length;T++)$[C[T]].end=0;return{map:$,table:k}}function S(b,v){let k;const $=t.getBestModeForData(b);if(k=t.from(v,$),k!==t.BYTE&&k.bit<$.bit)throw new Error('"'+b+'" cannot be encoded with mode '+t.toString(k)+`.
37
37
  Suggested mode is: `+t.toString($));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,$){return typeof $=="string"?k.push(S($,null)):$.data&&k.push(S($.data,$.mode)),k},[])},e.fromString=function(v,k){const $=u(v,i.isKanjiModeEnabled()),C=m($),T=w(C,k),D=c.find_path(T.map,"start","end"),R=[];for(let q=1;q<D.length-1;q++)R.push(T.table[D[q]].node);return e.fromArray(h(R))},e.rawSplit=function(v){return e.fromArray(u(v,i.isKanjiModeEnabled()))}})(OE);const qf=os,Ug=Kf,F9=y9,N9=v9,U9=$E,B9=_E,Rm=CE,Im=Vf,K9=b9,vu=ME,V9=DE,j9=$o,Bg=OE;function q9(e,t){const n=e.size,s=B9.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 z9(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 W9(e,t){const n=U9.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 H9(e,t){const n=e.size,s=vu.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 Kg(e,t,n){const s=e.size,r=V9.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 G9(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 Z9(e,t,n){const s=new F9;n.forEach(function(c){s.put(c.mode.bit,4),s.put(c.getLength(),j9.getCharCountIndicator(c.mode,e)),c.write(s)});const r=qf.getSymbolTotalCodewords(e),o=Im.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 J9(s,e,t)}function J9(e,t,n){const s=qf.getSymbolTotalCodewords(t),r=Im.getTotalCodewordsCount(t,n),o=s-r,a=Im.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,h=new K9(f);let m=0;const w=new Array(a),S=new Array(a);let b=0;const v=new Uint8Array(e.buffer);for(let D=0;D<a;D++){const R=D<c?d:u;w[D]=v.slice(m,m+R),S[D]=h.encode(w[D]),m+=R,b=Math.max(b,R)}const k=new Uint8Array(s);let $=0,C,T;for(C=0;C<b;C++)for(T=0;T<a;T++)C<w[T].length&&(k[$++]=w[T][C]);for(C=0;C<f;C++)for(T=0;T<a;T++)k[$++]=S[T][C];return k}function Y9(e,t,n,s){let r;if(Array.isArray(e))r=Bg.fromArray(e);else if(typeof e=="string"){let l=t;if(!l){const d=Bg.rawSplit(e);l=vu.getBestVersionForData(d,n)}r=Bg.fromString(e,l||40)}else throw new Error("Invalid data");const o=vu.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(`
38
38
  The chosen QR Code version cannot contain this amount of data.
39
39
  Minimum version required to store current data is: `+o+`.
40
40
  `);const a=Z9(t,n,r),i=qf.getSymbolSize(t),c=new N9(i);return q9(c,t),z9(c),W9(c,t),Kg(c,n,0),t>=7&&H9(c,t),G9(c,a),isNaN(s)&&(s=Rm.getBestMask(c,Kg.bind(null,c,n))),Rm.applyMask(s,c),Kg(c,n,s),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:s,segments:r}}kE.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let s=Ug.M,r,o;return typeof n<"u"&&(s=Ug.from(n.errorCorrectionLevel,Ug.M),r=vu.from(n.version),o=Rm.from(n.maskPattern),n.toSJISFunc&&qf.setToSJISFunction(n.toSJISFunc)),Y9(t,r,s,o)};var IE={},Ov={};(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 h=0;h<l;h++){let m=(f*l+h)*4,w=o.color.light;if(f>=d&&h>=d&&f<l-d&&h<l-d){const S=Math.floor((f-d)/c),b=Math.floor((h-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}}})(Ov);(function(e){const t=Ov;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)}})(IE);var LE={};const Q9=Ov;function q0(e,t){const n=e.a/255,s=t+'="'+e.hex+'"';return n<1?s+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':s}function Vg(e,t,n){let s=e+t;return typeof n<"u"&&(s+=" "+n),s}function X9(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?Vg("M",c+n,.5+l+n):Vg("m",r,0),r=0,o=!1),c+1<t&&e[i+1]||(s+=Vg("h",a),a=0)):r++}return s}LE.render=function(t,n,s){const r=Q9.getOptions(n),o=t.modules.size,a=t.modules.data,i=o+r.margin*2,c=r.color.light.a?"<path "+q0(r.color.light,"fill")+' d="M0 0h'+i+"v"+i+'H0z"/>':"",l="<path "+q0(r.color.dark,"stroke")+' d="'+X9(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>
41
- `;return typeof s=="function"&&s(null,f),f};const ez=m9,Lm=kE,FE=IE,tz=LE;function Rv(e,t,n,s,r){const o=[].slice.call(arguments,1),a=o.length,i=typeof o[a-1]=="function";if(!i&&!ez())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=Lm.create(n,s);c(e(d,t,s))}catch(d){l(d)}})}try{const c=Lm.create(n,s);r(null,e(c,t,s))}catch(c){r(c)}}Lm.create;Rv.bind(null,FE.render);var nz=Rv.bind(null,FE.renderToDataURL);Rv.bind(null,function(e,t,n){return tz.render(e,n)});const sz=Lt("actions");async function rz(){var e,t;if(!zE())return!1;try{if(En()){const n=window.electronAPI;return n!=null&&n.restartCli?(await n.restartCli(),!0):!1}if(bn())return typeof((t=(e=window.__TAURI__)==null?void 0:e.core)==null?void 0:t.invoke)=="function"?(await vs("cli_restart"),!0):!1}catch(n){return sz.error("Failed to restart CLI",n),!1}return!1}function oz(e){const t=e.filter(n=>n.scope!=="loopback");return{recommended:t[0]??null,hidden:t.slice(1)}}var iz=F("<span class=remote-toggle-state>"),az=F("<div class=remote-toggle-copy><span class=remote-toggle-title></span><span class=remote-toggle-caption>"),z0=F('<div class=settings-form-group><label class=settings-form-label></label><input class="selector-input w-full"type=password>'),cz=F("<div class=settings-password-actions><button class=settings-pill-button type=button>"),lz=F("<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>"),dz=F("<div class=remote-address-disclosure-content>"),uz=F("<div class=remote-address-disclosure><button class=remote-address-disclosure-trigger type=button><span class=remote-address-disclosure-label>"),fz=F("<div class=remote-address-list>"),gz=F('<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">'),hz=F("<div class=settings-card-message>"),mz=F("<div class=settings-error-message>"),W0=F("<div class=remote-card>"),pz=F("<div class=remote-error>"),jg=F("<div class=remote-qr>"),yz=F("<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>"),qg=F("<img class=remote-qr-img>"),H0=F("<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 G0=Lt("actions"),vz=()=>{const{t:e}=kt(),[t,n]=L(null),[s,r]=L(null),[o,a]=L(!1),[i,c]=L(!1),[l,d]=L({}),[u,f]=L(null),[h,m]=L(null),[w,S]=L(!1),[b,v]=L(""),[k,$]=L(""),[C,T]=L(null),[D,R]=L(!1),[q,re]=L(!1),ee=$e(()=>{var fe;return((fe=t())==null?void 0:fe.addresses)??[]}),W=$e(()=>{var fe;return((fe=t())==null?void 0:fe.listeningMode)??ku().listeningMode}),U=$e(()=>W()==="all"),J=$e(()=>{const fe=ee();return U()?oz(fe):{recommended:null,hidden:[]}}),le=async()=>{a(!0),m(null),T(null);try{const[fe,Re]=await Promise.all([ft.fetchServerMeta(),ft.fetchAuthStatus()]);n(fe),r(Re),re(!1)}catch(fe){m(fe instanceof Error?fe.message:String(fe))}finally{a(!1)}};Ns(()=>{le()});const z=async fe=>{if(u()===fe){f(null);return}if(f(fe),!l()[fe])try{const Re=await nz(fe,{margin:1,scale:4});d(be=>({...be,[fe]:Re}))}catch(Re){G0.error("Failed to generate QR code",Re)}},M=async fe=>{const Re=fe?"all":"local";if(!(Re===W()||i()||!await Wi(e("remoteAccess.listeningMode.restartConfirm.message"),{title:e(fe?"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 cT(Re),await rz()?n(Ce=>Ce&&{...Ce,listeningMode:Re}):m(e("remoteAccess.restart.errorManual"))}catch(ye){m(ye instanceof Error?ye.message:String(ye))}finally{c(!1)}le()}},N=fe=>{try{window.open(fe,"_blank","noopener,noreferrer")}catch(Re){G0.error("Failed to open URL",Re)}},ce=async()=>{T(null);const fe=b(),Re=k();if(fe.trim().length<8){T(e("remoteAccess.password.error.tooShort"));return}if(fe!==Re){T(e("remoteAccess.password.error.mismatch"));return}R(!0);try{const be=await ft.setServerPassword(fe);r({authenticated:!0,username:be.username,passwordUserProvided:be.passwordUserProvided}),v(""),$(""),S(!1)}catch(be){T(be instanceof Error?be.message:String(be))}finally{R(!1)}};return(()=>{var fe=gz(),Re=fe.firstChild,be=Re.firstChild,ye=be.firstChild,Ce=ye.firstChild,je=Ce.firstChild,O=je.nextSibling,g=ye.nextSibling,x=g.firstChild,A=x.nextSibling,E=A.firstChild,H=be.nextSibling,B=Re.nextSibling,oe=B.firstChild,Ae=oe.firstChild,we=Ae.firstChild,he=we.firstChild,Ee=he.nextSibling,Ge=Ae.nextSibling,Xe=B.nextSibling,se=Xe.firstChild,V=se.firstChild,Y=V.firstChild,Oe=Y.firstChild,ve=Oe.nextSibling,Ie=V.nextSibling;return p(ye,y(Cd,{class:"settings-card-heading-icon"}),Ce),p(je,()=>e("remoteAccess.sections.listeningMode.label")),p(O,()=>e("remoteAccess.sections.listeningMode.help")),p(x,()=>e("settings.scope.server")),A.$$click=()=>void le(),p(A,y(_d,{get class(){return`w-4 h-4 ${o()?"remote-spin":""}`}}),E),p(E,()=>e("remoteAccess.refresh")),p(Re,y(lc,{class:"remote-toggle",get checked(){return U()},onChange:Le=>void M(Le),get disabled(){return o()||i()},get children(){return[y(lc.Input,{}),y(lc.Control,{class:"remote-toggle-switch",get"data-checked"(){return U()},get children(){return[(()=>{var Le=iz();return p(Le,(()=>{var ze=_e(()=>!!U());return()=>ze()?e("remoteAccess.toggle.on"):e("remoteAccess.toggle.off")})()),Le})(),y(lc.Thumb,{class:"remote-toggle-thumb"})]}}),(()=>{var Le=az(),ze=Le.firstChild,Ne=ze.nextSibling;return p(ze,()=>e("remoteAccess.toggle.title")),p(Ne,(()=>{var Je=_e(()=>!!U());return()=>Je()?e("remoteAccess.toggle.caption.all"):e("remoteAccess.toggle.caption.local")})()),Le})()]}}),H),p(H,()=>e("remoteAccess.toggle.note")),p(Ae,y(Cd,{class:"settings-card-heading-icon"}),we),p(he,()=>e("remoteAccess.sections.serverPassword.label")),p(Ee,()=>e("remoteAccess.sections.serverPassword.help")),p(Ge,()=>e("settings.scope.server")),p(B,y(Q,{get when(){return _e(()=>!!s())()&&s().authenticated},get fallback(){return(()=>{var Le=hz();return p(Le,()=>e("remoteAccess.authStatus.unavailable")),Le})()},get children(){var Le=lz(),ze=Le.firstChild,Ne=ze.firstChild,Je=Ne.firstChild,ot=Je.nextSibling,gt=Ne.nextSibling,_=gt.firstChild;return p(Je,()=>e("remoteAccess.username",{username:s().username??"codenomad"})),p(ot,(()=>{var P=_e(()=>!!s().passwordUserProvided);return()=>P()?e("remoteAccess.password.status.set"):e("remoteAccess.password.status.unset")})()),_.$$click=()=>{S(!w()),T(null)},p(_,(()=>{var P=_e(()=>!!w());return()=>P()?e("remoteAccess.password.actions.cancel"):_e(()=>!!s().passwordUserProvided)()?e("remoteAccess.password.actions.change"):e("remoteAccess.password.actions.set")})()),p(Le,y(Q,{get when(){return w()},get children(){return[(()=>{var P=z0(),j=P.firstChild,K=j.nextSibling;return p(j,()=>e("remoteAccess.password.form.newPassword")),K.$$input=I=>v(I.currentTarget.value),de(()=>pe(K,"placeholder",e("remoteAccess.password.form.placeholder"))),de(()=>K.value=b()),P})(),(()=>{var P=z0(),j=P.firstChild,K=j.nextSibling;return p(j,()=>e("remoteAccess.password.form.confirmPassword")),K.$$input=I=>$(I.currentTarget.value),de(()=>K.value=k()),P})(),y(Q,{get when(){return C()},children:P=>(()=>{var j=mz();return p(j,P),j})()}),(()=>{var P=cz(),j=P.firstChild;return j.$$click=()=>void ce(),p(j,(()=>{var K=_e(()=>!!D());return()=>K()?e("remoteAccess.password.save.saving"):e("remoteAccess.password.save.label")})()),de(()=>j.disabled=D()),P})()]}}),null),Le}}),null),p(V,y(eD,{class:"settings-card-heading-icon"}),Y),p(Oe,()=>e("remoteAccess.sections.addresses.label")),p(ve,()=>e("remoteAccess.sections.addresses.help")),p(Ie,()=>e("settings.scope.server")),p(Xe,y(Q,{get when(){return!o()},get fallback(){return(()=>{var Le=W0();return p(Le,()=>e("remoteAccess.addresses.loading")),Le})()},get children(){return y(Q,{get when(){return!h()},get fallback(){return(()=>{var Le=pz();return p(Le,h),Le})()},get children(){return y(Q,{get when(){var Le;return!!J().recommended||((Le=t())==null?void 0:Le.localUrl)},get fallback(){return(()=>{var Le=W0();return p(Le,()=>e("remoteAccess.addresses.none")),Le})()},get children(){var Le=fz();return p(Le,y(Q,{get when(){var ze;return(ze=t())==null?void 0:ze.localUrl},children:ze=>{const Ne=()=>ze(),Je=()=>u()===Ne(),ot=()=>l()[Ne()];return(()=>{var gt=yz(),_=gt.firstChild,P=_.firstChild,j=P.firstChild,K=j.nextSibling,I=P.nextSibling,Z=I.firstChild,xe=Z.nextSibling;return p(j,Ne),p(K,()=>e("remoteAccess.address.scope.loopback")),Z.$$click=()=>N(Ne()),p(Z,y(Oi,{class:"remote-icon"}),null),p(Z,()=>e("remoteAccess.address.open"),null),xe.$$click=()=>void z(Ne()),p(xe,y(dd,{class:"remote-icon"}),null),p(xe,(()=>{var De=_e(()=>!!Je());return()=>De()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(gt,y(Q,{get when(){return Je()},get children(){var De=jg();return p(De,y(Q,{get when(){return ot()},get fallback(){return y(Nn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:Qe=>(()=>{var et=qg();return de(Tt=>{var He=Qe(),yt=e("remoteAccess.address.qrAlt",{url:Ne()});return He!==Tt.e&&pe(et,"src",Tt.e=He),yt!==Tt.t&&pe(et,"alt",Tt.t=yt),Tt},{e:void 0,t:void 0}),et})()})),De}}),null),de(()=>pe(xe,"aria-expanded",Je())),gt})()}}),null),p(Le,y(Q,{get when(){return J().recommended},children:ze=>{const Ne=ze(),Je=Ne.remoteUrl,ot=()=>u()===Je,gt=()=>l()[Je],_=()=>Ne.scope==="external"?e("remoteAccess.address.scope.network"):Ne.scope==="loopback"?e("remoteAccess.address.scope.loopback"):e("remoteAccess.address.scope.internal");return(()=>{var P=H0(),j=P.firstChild,K=j.firstChild,I=K.firstChild,Z=I.nextSibling,xe=Z.firstChild,De=xe.nextSibling;De.nextSibling;var Qe=K.nextSibling,et=Qe.firstChild,Tt=et.nextSibling;return p(I,Je),p(Z,()=>Ne.family.toUpperCase(),xe),p(Z,_,De),p(Z,()=>Ne.ip,null),et.$$click=()=>N(Je),p(et,y(Oi,{class:"remote-icon"}),null),p(et,()=>e("remoteAccess.address.open"),null),Tt.$$click=()=>void z(Je),p(Tt,y(dd,{class:"remote-icon"}),null),p(Tt,(()=>{var He=_e(()=>!!ot());return()=>He()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(P,y(Q,{get when(){return ot()},get children(){var He=jg();return p(He,y(Q,{get when(){return gt()},get fallback(){return y(Nn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:yt=>(()=>{var Qt=qg();return de(Ot=>{var Dn=yt(),Wn=e("remoteAccess.address.qrAlt",{url:Je});return Dn!==Ot.e&&pe(Qt,"src",Ot.e=Dn),Wn!==Ot.t&&pe(Qt,"alt",Ot.t=Wn),Ot},{e:void 0,t:void 0}),Qt})()})),He}}),null),de(()=>pe(Tt,"aria-expanded",ot())),P})()}}),null),p(Le,y(Q,{get when(){return J().hidden.length>0},get children(){var ze=uz(),Ne=ze.firstChild,Je=Ne.firstChild;return Ne.$$click=()=>re(!q()),p(Je,(()=>{var ot=_e(()=>!!q());return()=>ot()?e("remoteAccess.addresses.actions.hideOther"):e("remoteAccess.addresses.actions.showOther",{count:String(J().hidden.length)})})()),p(Ne,y(N2,{class:"remote-address-disclosure-chevron disclosure-chevron"}),null),p(ze,y(Q,{get when(){return q()},get children(){var ot=dz();return p(ot,y(Ut,{get each(){return J().hidden},children:gt=>{const _=gt.remoteUrl,P=()=>u()===_,j=()=>l()[_],K=()=>gt.scope==="external"?e("remoteAccess.address.scope.network"):gt.scope==="loopback"?e("remoteAccess.address.scope.loopback"):e("remoteAccess.address.scope.internal");return(()=>{var I=H0(),Z=I.firstChild,xe=Z.firstChild,De=xe.firstChild,Qe=De.nextSibling,et=Qe.firstChild,Tt=et.nextSibling;Tt.nextSibling;var He=xe.nextSibling,yt=He.firstChild,Qt=yt.nextSibling;return p(De,_),p(Qe,()=>gt.family.toUpperCase(),et),p(Qe,K,Tt),p(Qe,()=>gt.ip,null),yt.$$click=()=>N(_),p(yt,y(Oi,{class:"remote-icon"}),null),p(yt,()=>e("remoteAccess.address.open"),null),Qt.$$click=()=>void z(_),p(Qt,y(dd,{class:"remote-icon"}),null),p(Qt,(()=>{var Ot=_e(()=>!!P());return()=>Ot()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(I,y(Q,{get when(){return P()},get children(){var Ot=jg();return p(Ot,y(Q,{get when(){return j()},get fallback(){return y(Nn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:Dn=>(()=>{var Wn=qg();return de(Hn=>{var Gn=Dn(),dr=e("remoteAccess.address.qrAlt",{url:_});return Gn!==Hn.e&&pe(Wn,"src",Hn.e=Gn),dr!==Hn.t&&pe(Wn,"alt",Hn.t=dr),Hn},{e:void 0,t:void 0}),Wn})()})),Ot}}),null),de(()=>pe(Qt,"aria-expanded",P())),I})()}})),ot}}),null),de(ot=>{var gt=q(),_=q();return gt!==ot.e&&pe(ze,"data-expanded",ot.e=gt),_!==ot.t&&pe(Ne,"aria-expanded",ot.t=_),ot},{e:void 0,t:void 0}),ze}}),null),Le}})}})}}),null),de(()=>A.disabled=o()),fe})()};Ht(["click","input"]);async function wz(e,t,n){if(!qi())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(En()){const r=window.electronAPI;if(typeof(r==null?void 0:r.openRemoteWindow)=="function"){await r.openRemoteWindow(s);return}}if(bn()){if(n!==void 0&&(t??e.baseUrl).startsWith("https://")&&await vs("needs_local_certificate_install")&&!await Wi(ke("folderSelection.servers.certificateInstall.confirmMessage"),{title:ke("folderSelection.servers.certificateInstall.title"),variant:"warning",confirmLabel:ke("folderSelection.servers.certificateInstall.confirmLabel"),cancelLabel:ke("folderSelection.servers.certificateInstall.cancelLabel")}))throw new Error(ke("folderSelection.servers.certificateInstall.cancelled"));await vs("open_remote_window",{payload:s});return}window.open(e.baseUrl,"_blank","noopener,noreferrer")}function bz(){const{t:e}=kt(),{remoteServers:t,saveRemoteServerProfile:n,markRemoteServerConnected:s,removeRemoteServerProfile:r}=Tn(),[o,a]=L(null),i=async(l,d)=>{if(d&&!qi())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 h=await ft.probeRemoteServer({baseUrl:f,skipTlsVerify:l.skipTlsVerify});if(!h.ok)throw new Error(h.error||e("folderSelection.servers.dialog.errorConnect"));const m=await n({id:l.id,name:u,baseUrl:h.normalizedUrl,skipTlsVerify:l.skipTlsVerify});if(d){const w=bn()&&m.skipTlsVerify&&m.baseUrl.startsWith("https://")?await ft.createRemoteProxySession({baseUrl:m.baseUrl,skipTlsVerify:!0}):void 0;try{await wz(m,w==null?void 0:w.windowUrl,w==null?void 0:w.sessionId)}catch(S){throw w&&ft.deleteRemoteProxySession(w.sessionId).catch(()=>{}),S}await s(m.id)}return m};return{remoteServers:t,connectingServerId:o,saveServer:i,connectSavedServer:async l=>{if(!qi()||o())return;const d=t().find(u=>u.id===l);if(d){a(l);try{await i(d,!0)}catch(u){Cs(u instanceof Error?u.message:String(u),{title:e("folderSelection.servers.errorTitle"),variant:"warning"})}finally{a(null)}}},removeRemoteServerProfile:r}}var Sz=F("<div>"),Z0=F('<label class="flex flex-col gap-2 text-sm text-secondary"><span></span><input class="selector-input w-full">'),kz=F('<label class="flex items-start gap-3 text-sm text-secondary"><input type=checkbox><span>'),xz=F('<span class="inline-flex items-center gap-2">'),$z=F('<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">'),_z=F('<div class="fixed inset-0 z-[1300] flex items-center justify-center p-4">'),Cz=F('<p class="text-sm text-red-500 break-words">'),Ez=F("<span>");const Tz=e=>{const{t}=kt(),[n,s]=L(""),[r,o]=L(""),[a,i]=L(!1),[c,l]=L(null),[d,u]=L(!1);qe(()=>{e.open&&(s(""),o(""),i(!1),l(null))});const f=async h=>{if(!d()){u(!0),l(null);try{await e.onSubmit({name:n(),baseUrl:r(),skipTlsVerify:a()},h),e.onOpenChange(!1)}catch(m){l(m instanceof Error?m.message:String(m))}finally{u(!1)}}};return y(_t,{get open(){return e.open},get onOpenChange(){return e.onOpenChange},get children(){return y(_t.Portal,{get children(){return[y(_t.Overlay,{class:"modal-overlay"}),(()=>{var h=_z();return p(h,y(_t.Content,{class:"modal-surface w-full max-w-lg p-6 flex flex-col gap-5",tabIndex:-1,get children(){return[(()=>{var m=Sz();return p(m,y(_t.Title,{class:"text-xl font-semibold text-primary",get children(){return t("folderSelection.servers.dialog.title")}}),null),p(m,y(_t.Description,{class:"text-sm text-secondary mt-2",get children(){return t("folderSelection.servers.dialog.description")}}),null),m})(),(()=>{var m=Z0(),w=m.firstChild,S=w.nextSibling;return p(w,()=>t("folderSelection.servers.dialog.name")),S.$$input=b=>s(b.currentTarget.value),de(()=>pe(S,"placeholder",t("folderSelection.servers.dialog.namePlaceholder"))),de(()=>S.value=n()),m})(),(()=>{var m=Z0(),w=m.firstChild,S=w.nextSibling;return p(w,()=>t("folderSelection.servers.dialog.url")),S.$$input=b=>o(b.currentTarget.value),de(()=>pe(S,"placeholder",t("folderSelection.servers.dialog.urlPlaceholder"))),de(()=>S.value=r()),m})(),(()=>{var m=kz(),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(Q,{get when(){return c()},children:m=>(()=>{var w=Cz();return p(w,m),w})()}),(()=>{var m=$z(),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(Q,{get when(){return d()},get fallback(){return(()=>{var v=Ez();return p(v,()=>t("folderSelection.servers.dialog.connect")),v})()},get children(){var v=xz();return p(v,y(Nn,{class:"w-4 h-4 animate-spin"}),null),p(v,()=>t("folderSelection.servers.dialog.connecting"),null),v}})),de(v=>{var k=d(),$=d();return k!==v.e&&(S.disabled=v.e=k),$!==v.t&&(b.disabled=v.t=$),v},{e:void 0,t:void 0}),m})()]}})),h})()]}})}})};Ht(["input","click"]);var Mz=F('<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>'),Az=F("<div class=settings-card-message>"),Dz=F('<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 Pz=()=>{const{t:e}=kt(),{remoteServers:t,connectingServerId:n,saveServer:s,connectSavedServer:r,removeRemoteServerProfile:o}=bz(),[a,i]=L(!1);return[(()=>{var c=Mz(),l=c.firstChild,d=l.firstChild,u=d.firstChild,f=u.firstChild,h=f.nextSibling,m=d.nextSibling,w=m.firstChild,S=l.nextSibling;return p(d,y(Bo,{class:"settings-card-heading-icon"}),u),p(f,()=>e("folderSelection.tabs.servers")),p(h,()=>e("folderSelection.servers.empty.description")),m.$$click=()=>i(!0),p(m,y(Eu,{class:"w-4 h-4"}),w),p(w,()=>e("folderSelection.actions.connectButton")),p(S,y(Q,{get when(){return t().length>0},get fallback(){return(()=>{var b=Az();return p(b,()=>e("folderSelection.servers.empty.title")),b})()},get children(){return y(Ut,{get each(){return t()},children:b=>(()=>{var v=Dz(),k=v.firstChild,$=k.firstChild,C=$.nextSibling,T=k.nextSibling,D=T.firstChild,R=D.nextSibling;return p($,()=>b.name),p(C,()=>b.baseUrl),D.$$click=()=>void r(b.id),p(D,y(Q,{get when(){return n()===b.id},get fallback(){return y(Bo,{class:"w-4 h-4"})},get children(){return y(Nn,{class:"w-4 h-4 animate-spin"})}})),R.$$click=()=>o(b.id),p(R,y(Tu,{class:"w-4 h-4"})),de(q=>{var re=!!n(),ee=`${e("folderSelection.servers.dialog.connect")}: ${b.name}`,W=`${e("folderSelection.servers.dialog.connect")}: ${b.name}`,U=`${e("folderSelection.servers.remove")}: ${b.name}`,J=`${e("folderSelection.servers.remove")}: ${b.name}`;return re!==q.e&&(D.disabled=q.e=re),ee!==q.t&&pe(D,"aria-label",q.t=ee),W!==q.a&&pe(D,"title",q.a=W),U!==q.o&&pe(R,"title",q.o=U),J!==q.i&&pe(R,"aria-label",q.i=J),q},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),v})()})}})),c})(),y(Tz,{get open(){return a()},onOpenChange:i,onSubmit:s})]};Ht(["click"]);const Oz=Lt("api");function wu(e){return`/sidecars/${encodeURIComponent(e)}/`}const[NE,Iv]=L(new Map),[Rz,zf]=L([]),[Lv,Fv]=L(null),[Iz,zg]=L(!1);let Eo=null,Lz=0;class Fz extends Error{constructor(t){super(t),this.name="SidecarNotFoundError"}}async function UE(e){if(!Eo){zg(!0);const n=ft.fetchSidecars().then(s=>{Iv(new Map(s.sidecars.map(r=>[r.id,r])))});Eo=n,n.then(()=>{zg(!1),Eo===n&&(Eo=null)},s=>{Oz.error("Failed to load SideCars",s),zg(!1),Eo===n&&(Eo=null)})}const t=Eo;if(e!=null&&e.propagateErrors)return t;await t.catch(()=>{})}function Nz(e){Iv(t=>{const n=new Map(t);return n.set(e.id,e),n}),zf(t=>t.map(n=>n.sidecarId===e.id?{...n,name:e.name,port:e.port,prefixMode:e.prefixMode,proxyBasePath:wu(e.id).replace(/\/$/,""),shellUrl:wu(e.id)}:n))}function Uz(e){Iv(t=>{const n=new Map(t);return n.delete(e),n}),zf(t=>{var s;const n=t.filter(r=>r.sidecarId!==e);return n.some(r=>r.token===Lv())||Fv(((s=n[0])==null?void 0:s.token)??null),n})}fs.on("sidecar.updated",e=>{e.type==="sidecar.updated"&&Nz(e.sidecar)});fs.on("sidecar.removed",e=>{e.type==="sidecar.removed"&&Uz(e.sidecarId)});async function yH(e,t){var o,a;if((o=t==null?void 0:t.signal)!=null&&o.aborted)throw Bi(t.signal);await Bq(()=>UE({propagateErrors:t==null?void 0:t.propagateLoadErrors}),{signal:t==null?void 0:t.signal});const n=NE().get(e);if(!n)throw new Fz(ke("sidecars.open.notFound"));if(n.status!=="running")throw new Error(ke("sidecars.open.notRunning"));const r={token:`${e}:${Date.now().toString(36)}:${(Lz++).toString(36)}`,sidecarId:e,name:n.name,port:n.port,prefixMode:n.prefixMode,proxyBasePath:wu(e).replace(/\/$/,""),shellUrl:wu(e)};if((a=t==null?void 0:t.signal)!=null&&a.aborted)throw Bi(t.signal);return zf(i=>[...i,r]),((t==null?void 0:t.activate)??!0)&&Fv(r.token),r}function vH(e){zf(t=>{const n=t.findIndex(r=>r.token===e);if(n<0)return t;const s=t.filter(r=>r.token!==e);if(Lv()===e){const r=s[n-1]??s[n]??null;Fv((r==null?void 0:r.token)??null)}return s})}$e(()=>Rz().find(e=>e.token===Lv())??null);var J0=F('<div class="text-sm text-red-500">'),Bz=F('<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>'),Y0=F("<div class=settings-card-message>"),Kz=F('<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 Vz(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")}const jz=()=>{const{t:e}=kt(),[t,n]=L(""),[s,r]=L("3000"),[o,a]=L(!1),[i,c]=L("strip"),[l,d]=L(null),[u,f]=L(!1),[h,m]=L(null),[w,S]=L(null);Ns(()=>{UE()});const b=$e(()=>Array.from(NE().values()).sort((C,T)=>C.name.localeCompare(T.name))),v=$e(()=>Vz(t())||"your-sidecar");async function k(){const C=t().trim(),T=Number(s());if(!C||!Number.isInteger(T)||T<=0||T>65535){m(e("sidecars.form.validation"));return}f(!0),m(null);try{await ft.createSidecar({kind:"port",name:C,port:T,insecure:o(),prefixMode:i()}),n(""),r("3000"),a(!1),c("strip")}catch(D){m(D instanceof Error?D.message:String(D))}finally{f(!1)}}async function $(C){d(C),S(null);try{await ft.deleteSidecar(C)}catch(T){S(T instanceof Error?T.message:String(T))}finally{d(null)}}return(()=>{var C=Bz(),T=C.firstChild,D=T.firstChild,R=D.firstChild,q=R.firstChild,re=q.firstChild,ee=re.nextSibling,W=R.nextSibling,U=D.nextSibling,J=U.firstChild,le=J.firstChild,z=le.firstChild,M=z.nextSibling,N=M.firstChild,ce=N.nextSibling;ce.firstChild;var fe=le.nextSibling,Re=J.nextSibling,be=Re.firstChild,ye=be.firstChild,Ce=be.nextSibling,je=Re.nextSibling,O=je.firstChild,g=O.firstChild,x=g.nextSibling,A=O.nextSibling,E=A.firstChild,H=E.nextSibling,B=je.nextSibling,oe=B.firstChild,Ae=oe.firstChild,we=Ae.nextSibling,he=oe.nextSibling,Ee=he.firstChild,Ge=Ee.nextSibling,Xe=B.nextSibling,se=Xe.firstChild,V=se.firstChild,Y=T.nextSibling,Oe=Y.firstChild,ve=Oe.firstChild,Ie=ve.firstChild,Le=Ie.nextSibling,ze=Oe.nextSibling;return p(R,y(Bo,{class:"settings-card-heading-icon"}),q),p(re,()=>e("settings.section.sidecars.title")),p(ee,()=>e("settings.section.sidecars.subtitle")),p(W,()=>e("settings.scope.server")),p(z,()=>e("sidecars.form.name")),p(M,()=>e("sidecars.basePath"),N),p(ce,v,null),fe.$$input=Ne=>{m(null),n(Ne.currentTarget.value)},p(ye,()=>e("sidecars.form.port")),Ce.$$input=Ne=>{m(null),r(Ne.currentTarget.value)},p(g,()=>e("sidecars.form.protocol")),p(x,()=>e("sidecars.form.protocol.help")),A.addEventListener("change",Ne=>a(Ne.currentTarget.value==="http")),p(E,()=>e("sidecars.form.protocol.https")),p(H,()=>e("sidecars.form.protocol.http")),p(Ae,()=>e("sidecars.form.prefixMode")),p(we,()=>e("sidecars.form.prefixMode.help")),he.addEventListener("change",Ne=>c(Ne.currentTarget.value)),p(Ee,()=>e("sidecars.form.prefixMode.strip")),p(Ge,()=>e("sidecars.form.prefixMode.preserve")),p(U,y(Q,{get when(){return h()},get children(){var Ne=J0();return p(Ne,h),Ne}}),Xe),se.$$click=()=>void k(),p(se,y(Q,{get when(){return u()},get fallback(){return y(Eu,{class:"w-4 h-4"})},get children(){return y(Nn,{class:"w-4 h-4 animate-spin"})}}),V),p(V,()=>e("sidecars.form.add")),p(Ie,()=>e("sidecars.settings.listTitle")),p(Le,()=>e("sidecars.settings.listSubtitle")),p(ze,y(Q,{get when(){return w()},get children(){var Ne=J0();return p(Ne,w),Ne}}),null),p(ze,y(Q,{get when(){return!Iz()},get fallback(){return(()=>{var Ne=Y0();return p(Ne,()=>e("sidecars.picker.loading")),Ne})()},get children(){return y(Q,{get when(){return b().length>0},get fallback(){return(()=>{var Ne=Y0();return p(Ne,()=>e("sidecars.settings.empty")),Ne})()},get children(){return y(Ut,{get each(){return b()},children:Ne=>(()=>{var Je=Kz(),ot=Je.firstChild,gt=ot.firstChild,_=gt.nextSibling,P=_.firstChild,j=P.nextSibling;j.nextSibling;var K=_.nextSibling,I=K.firstChild,Z=I.nextSibling;Z.firstChild,Z.nextSibling;var xe=ot.nextSibling,De=xe.firstChild,Qe=De.nextSibling;return p(gt,()=>Ne.name),p(_,()=>e("sidecars.kind.port"),P),p(_,()=>Ne.insecure?"http":"https",j),p(_,()=>Ne.port,null),p(K,()=>e("sidecars.basePath"),I),p(Z,()=>Ne.id,null),p(K,()=>e(`sidecars.form.prefixMode.${Ne.prefixMode}`),null),p(De,()=>e(`sidecars.status.${Ne.status}`)),Qe.$$click=()=>void $(Ne.id),p(Qe,y(Tu,{class:"w-4 h-4"})),de(()=>Qe.disabled=l()===Ne.id),Je})()})}})}}),null),de(()=>se.disabled=u()),de(()=>fe.value=t()),de(()=>Ce.value=s()),de(()=>A.value=o()?"http":"https"),de(()=>he.value=i()),C})()};Ht(["input","click"]);async function dc(e){if(mn.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}mn.host==="tauri"&&await vs("window_control",{action:e})}async function qz(){mn.host==="tauri"&&await vs("window_control",{action:"drag"})}async function zz(e,t){var r;const n=t.getBoundingClientRect(),s={x:n.left,y:n.bottom};if(mn.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 mn.host==="tauri"&&await vs("popup_titlebar_menu",{menu:e,...s})}var Wz=F("<nav class=native-titlebar-menu data-titlebar-interactive>"),Hz=F('<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>'),Gz=F("<button type=button class=native-titlebar-menu-button>");const Zz=["file","edit","view","window","help"],Jz=e=>{const{t}=kt(),n=()=>e.onClose?e.onClose():dc("close");return(()=>{var s=Hz(),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]")||dc("maximize")},s.$$pointerdown=u=>{u.button===0&&!u.target.closest("[data-titlebar-interactive]")&&qz()},p(o,()=>e.title),p(s,y(Q,{get when(){return e.menus},get children(){var u=Wz();return p(u,y(Ut,{each:Zz,children:f=>(()=>{var h=Gz();return h.$$click=m=>void zz(f,m.currentTarget),p(h,()=>t(`window.menu.${f}`)),h})()})),de(()=>pe(u,"aria-label",t("window.menu.ariaLabel"))),u}}),a),c.$$click=()=>void dc("minimize"),p(c,y(EA,{"aria-hidden":"true"})),l.$$click=()=>void dc("maximize"),p(l,y(kA,{"aria-hidden":"true"})),d.$$click=()=>void n(),p(d,y(Ko,{"aria-hidden":"true"})),de(u=>{var f=t("window.controls.minimize"),h=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&&pe(c,"aria-label",u.e=f),h!==u.t&&pe(c,"title",u.t=h),m!==u.a&&pe(l,"aria-label",u.a=m),w!==u.o&&pe(l,"title",u.o=w),S!==u.i&&pe(d,"aria-label",u.i=S),b!==u.n&&pe(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})()};Ht(["pointerdown","dblclick","click"]);function Yz(e,t,n){qe(()=>{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=h=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(h.key)&&l()},u=()=>{o||n(Math.round(r.scrollTop))},f=new ResizeObserver(c);f.observe(r);for(const h of r.children)f.observe(h);r.addEventListener("scroll",u),r.addEventListener("wheel",l,{passive:!0}),r.addEventListener("pointerdown",l),r.addEventListener("keydown",d),c(),nt(()=>{f.disconnect(),cancelAnimationFrame(a),r.removeEventListener("scroll",u),r.removeEventListener("wheel",l),r.removeEventListener("pointerdown",l),r.removeEventListener("keydown",d)})})}var Qz=F("<div class=settings-section-stack>"),Xz=F("<h1 class=sr-only>"),eW=F('<div class="flex-1 min-w-0">'),tW=F('<button type=button class="window-icon-button settings-screen-close settings-screen-compact-close">'),nW=F('<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>'),sW=F('<button type=button class="window-icon-button settings-screen-close">'),rW=F('<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">'),oW=F('<span class=settings-section-selector-value><span class="selector-trigger-primary selector-trigger-primary--align-left">'),iW=F("<button type=button class=settings-nav-button><span>"),aW=F('<div class=settings-window-root><div class="modal-surface window-shell settings-screen-shell">'),cW=F("<div class=settings-screen-frame>");const lW=e=>{const{t}=kt(),n=m4("(max-width: 640px)"),s=$e(()=>{const b=[{id:"general",icon:WA,label:t("settings.nav.general")},{id:"chat",icon:$A,label:t("settings.nav.chat")},{id:"notifications",icon:GS,label:t("settings.nav.notifications")},{id:"speech",icon:ih,label:t("settings.nav.speech")},{id:"opencode",icon:ep,label:t("settings.nav.opencode")},{id:"providers",icon:JS,label:t("settings.nav.providers")},{id:"sidecars",icon:Bo,label:t("settings.nav.sidecars")},{id:"config-files",icon:H2,label:t("settings.nav.configFiles")},{id:"advanced",icon:Fl,label:t("settings.nav.advanced")},{id:"info",icon:Xm,label:t("settings.nav.info")}];return(e.standalone||qi())&&b.splice(4,0,{id:"remote",icon:MA,label:t("settings.nav.remote")}),b}),r=$e(()=>s().find(b=>b.id===vi())??s()[0]),o=()=>{switch(vi()){case"chat":return y(nO,{});case"notifications":return y(KO,{});case"speech":return y(lR,{});case"remote":return e.standalone||qi()?(()=>{var b=Qz();return p(b,y(vz,{}),null),p(b,y(Pz,{}),null),b})():y(Vw,{showStartupState:!0});case"opencode":return y(G8,{});case"providers":return y(V8,{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(jz,{});case"config-files":return y(u9,{});case"advanced":return y(t9,{});case"info":return y(bO,{});case"general":default:return y(Vw,{get showStartupState(){return!e.standalone}})}},a=async b=>{var v;b!==vi()&&await Ii()&&(await((v=e.onSectionChange)==null?void 0:v.call(e,b)),pp(b),u==null||u.scrollTo({top:0}))},i=async()=>{await Ii()&&(e.onClose?await e.onClose():E4())},[c,l]=L({x:0,y:0});qe(()=>{n()&&l({x:0,y:0})});let d,u;Yz(()=>u,()=>(vi(),e.scrollPosition),b=>{var v;return(v=e.onScrollPositionChange)==null?void 0:v.call(e,b)});let f;const h=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(Q,{get when(){return e.standalone},get children(){var b=Xz();return p(b,()=>t("settings.title")),b}}),(()=>{var b=nW(),v=b.firstChild,k=v.firstChild,$=k.nextSibling,C=v.nextSibling,T=C.firstChild,D=T.firstChild,R=D.nextSibling,q=R.firstChild,re=C.nextSibling;return p(k,y(Fl,{class:"settings-screen-nav-icon"})),p($,y(Te,{get value(){return r()},onChange:ee=>ee&&void a(ee.id),get options(){return s()},optionValue:"id",optionTextValue:"label",itemComponent:ee=>{const W=ee.item.rawValue.icon;return y(Te.Item,{get item(){return ee.item},class:"selector-option settings-section-selector-option",get children(){return[y(W,{class:"settings-section-selector-option-icon"}),y(Te.ItemLabel,{class:"selector-option-label",get children(){return ee.item.rawValue.label}})]}})},get children(){return[y(Te.Trigger,{class:"selector-trigger settings-section-selector-trigger",get"aria-label"(){return t("settings.navigationAriaLabel")},get children(){return[(()=>{var ee=eW();return p(ee,y(Te.Value,{children:W=>{const U=W.selectedOption(),J=(U==null?void 0:U.icon)??Fl;return(()=>{var le=oW(),z=le.firstChild;return p(le,y(J,{class:"settings-section-selector-value-icon"}),z),p(z,()=>U==null?void 0:U.label),le})()}})),ee})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover settings-section-selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})),p(v,y(Q,{get when(){return!e.standalone},get children(){var ee=tW();return ee.$$click=()=>void i(),p(ee,y(Ko,{class:"w-4 h-4"})),de(W=>{var U=t("settings.close"),J=t("settings.close");return U!==W.e&&pe(ee,"aria-label",W.e=U),J!==W.t&&pe(ee,"title",W.t=J),W},{e:void 0,t:void 0}),ee}}),null),C.addEventListener("pointercancel",w),C.$$pointerup=w,C.$$pointermove=m,C.$$pointerdown=h,p(D,y(Fl,{class:"settings-screen-nav-icon"})),p(q,()=>t("settings.title")),p(re,y(Ut,{get each(){return s()},children:ee=>{const W=ee.icon;return(()=>{var U=iW(),J=U.firstChild;return U.$$click=()=>void a(ee.id),p(U,y(W,{class:"settings-nav-button-icon"}),J),p(J,()=>ee.label),de(le=>{var z=vi()===ee.id?"true":"false",M=vi()===ee.id?"page":void 0;return z!==le.e&&pe(U,"data-selected",le.e=z),M!==le.t&&pe(U,"aria-current",le.t=M),le},{e:void 0,t:void 0}),U})()}})),de(()=>pe(re,"aria-label",t("settings.navigationAriaLabel"))),b})(),(()=>{var b=rW(),v=b.firstChild,k=v.firstChild,$=k.firstChild,C=$.nextSibling,T=v.nextSibling;v.addEventListener("pointercancel",w),v.$$pointerup=w,v.$$pointermove=m,v.$$pointerdown=h,p($,()=>t("settings.content.eyebrow")),p(C,()=>{var R;return(R=r())==null?void 0:R.label}),p(v,y(Q,{get when(){return!e.standalone},get children(){var R=sW();return R.$$click=()=>void i(),p(R,y(Ko,{class:"w-4 h-4"})),de(q=>{var re=t("settings.close"),ee=t("settings.close");return re!==q.e&&pe(R,"aria-label",q.e=re),ee!==q.t&&pe(R,"title",q.t=ee),q},{e:void 0,t:void 0}),R}}),null);var D=u;return typeof D=="function"?Xs(D,T):u=T,p(T,o),b})()];return e.standalone?(()=>{var b=aW(),v=b.firstChild;p(b,y(Jz,{get title(){return t("settings.title")},onClose:i}),v);var k=d;return typeof k=="function"?Xs(k,v):d=v,p(v,S),b})():y(_t,{get modal(){return n()},get preventScroll(){return n()},get open(){return Kk()},onOpenChange:b=>!b&&void i(),get children(){return y(_t.Portal,{get children(){var b=cW();return p(b,y(_t.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(_t.Title,{class:"sr-only",get children(){return t("settings.title")}}),_e(()=>S())]}})),b}})}})};Ht(["click","pointerdown","pointermove","pointerup"]);const dW=()=>{const[e,t]=L({section:"general"}),n=[];let s=Promise.resolve(),r,o=0,a,i=Promise.resolve();const c=(h,m)=>(i=i.catch(()=>{}).then(()=>w4(h(),m)),i),l=h=>(clearTimeout(a),a=void 0,c(()=>({...e(),scrollTop:o}),h)),d=async h=>{await s.catch(()=>{}),await l(h)},u=async(h,m=!0)=>{if(m&&!await Ii())return;clearTimeout(a),m&&await c(()=>h);const w=e().instanceId;w&&w!==h.instanceId&&Ji.destroyClientsForInstance(w),o=h.scrollTop??0,nn(()=>{t(h),pp(h.section)})},f=async(h=!0)=>r||(r=(async()=>{(!h||await Ii())&&(await d(),await dc("close"))})().finally(()=>{r=void 0}),r);return Ns(()=>{let h=!0,m=!1,w=!1,S=!1,b=!1,v=!1;(async()=>{try{const k=await k4($=>{m=!0,h&&(s=s.catch(()=>{}).then(()=>u($)))});if(!h)return k();n.push(k),w=!0}catch{}try{const k=await S4();h&&!m&&await u(k,!1)}catch{}try{const k=await x4(()=>void f());if(!h)return k();n.push(k),S=!0}catch{}try{const k=await $4($=>{s=s.catch(()=>{}).then(async()=>{const C=await Ii();C&&await l(),await _4($,C)})});if(!h)return k();n.push(k),b=!0}catch{}try{const k=await b4(d);if(!h)return k();n.push(k),v=!0}catch{}w&&S&&b&&v&&await v4()})(),nt(()=>{h=!1,clearTimeout(a),n.splice(0).forEach($=>$());const k=e().instanceId;k&&Ji.destroyClientsForInstance(k)})}),[y(lW,{standalone:!0,get providerContext(){return{instanceId:e().instanceId,location:e().location}},get scrollPosition(){return e()},onScrollPositionChange:h=>{o=h,clearTimeout(a),a=setTimeout(()=>{l().catch(()=>{})},150)},onSectionChange:async h=>{clearTimeout(a);const m={...e(),section:h,scrollTop:0};await c(()=>m),o=0,t(m)},onClose:()=>f(!1)}),y(t2,{}),y(ID,{automatic:!1}),y(DT,{position:"top-right",gutter:16,toastOptions:{duration:8e3,className:"bg-transparent border-none shadow-none p-0"}})]},BE=document.getElementById("root");if(!BE)throw new Error("Root element not found");const uW=BE;typeof document<"u"&&(document.documentElement.dataset.runtimeHost=mn.host,document.documentElement.dataset.runtimePlatform=mn.platform);async function fW(){var t;let e=dW;if(Nm(mn)){const[{initializeClientState:n},s]=await Promise.all([ts(()=>import("./client-state-LGeRE6k3.js").then(r=>r.j),__vite__mapDeps([8,2,3,4,5,6,1,7])),ts(()=>import("./App-DHe1TgnC.js").then(r=>r.N),__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([Vv.loadConfigOwner("ui"),Vv.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;jv($i(o,r),{systemDark:window.matchMedia("(prefers-color-scheme: dark)").matches}),await Uv(a)}catch{jv($i("system"),{systemDark:window.matchMedia("(prefers-color-scheme: dark)").matches}),await Uv()}lT(()=>y(fT,{get children(){return y(dT,{get children(){return y(WE,{get children(){return y(uT,{get children(){return y(e,{})}})}})}})}}),uW)}fW();export{p6 as $,RW as A,GS as B,N2 as C,_t as D,Oi as E,sA as F,Bo as G,LW as H,Ye as I,NW as J,Eu as K,D4 as L,MA as M,EW as N,PW as O,IA as P,Ue as Q,Tz as R,Fl as S,Tu as T,Yr as U,$n as V,Eq as W,Ko as X,l6 as Y,DC as Z,Wi as _,Fn as a,RS as a$,$6 as a0,eE as a1,x2 as a2,_6 as a3,iE as a4,P6 as a5,Br as a6,fE as a7,Pm as a8,q6 as a9,xr as aA,wW as aB,ge as aC,tp as aD,OS as aE,Mn as aF,tl as aG,GD as aH,ls as aI,zt as aJ,Zm as aK,ds as aL,Ea as aM,f9 as aN,PS as aO,Zt as aP,kW as aQ,xn as aR,pr as aS,eP as aT,CS as aU,_k as aV,AS as aW,Qc as aX,Jg as aY,ak as aZ,TS as a_,xo as aa,Xq as ab,O6 as ac,Zi as ad,Bt as ae,jn as af,U6 as ag,N6 as ah,UW as ai,Xk as aj,uR as ak,fR as al,Fe as am,Df as an,zV as ao,sr as ap,F6 as aq,jd as ar,WI as as,o7 as at,s7 as au,r7 as av,sO as aw,K7 as ax,$W as ay,Dt as az,Ww as b,OA as b$,Gv as b0,SW as b1,el as b2,hp as b3,ih as b4,qO as b5,qj as b6,Xm as b7,Rz as b8,gH as b9,pw as bA,tr as bB,Px as bC,nL as bD,sv as bE,oj as bF,MV as bG,V1 as bH,H1 as bI,EV as bJ,Rp as bK,JW as bL,ZW as bM,ZO as bN,rb as bO,JO as bP,qd as bQ,a7 as bR,Ky as bS,D6 as bT,B7 as bU,YW as bV,Nj as bW,eg as bX,Fo as bY,j7 as bZ,V7 as b_,IC as ba,Fv as bb,hH as bc,C6 as bd,Lv as be,bs as bf,Lq as bg,wa as bh,Am as bi,mH as bj,t7 as bk,zj as bl,W7 as bm,z7 as bn,n7 as bo,da as bp,H4 as bq,pt as br,ou as bs,MW as bt,XW as bu,wp as bv,DW as bw,gx as bx,RK as by,OK as bz,bz as c,jj as c$,pC as c0,or as c1,ip as c2,Ck as c3,Ek as c4,QD as c5,CW as c6,ck as c7,lk as c8,Mk as c9,ug as cA,Io as cB,lo as cC,Te as cD,ri as cE,KW as cF,WW as cG,VW as cH,_d as cI,GM as cJ,WV as cK,cC as cL,Pf as cM,nj as cN,E7 as cO,R7 as cP,IV as cQ,I7 as cR,ej as cS,_1 as cT,$1 as cU,x1 as cV,k1 as cW,S1 as cX,E1 as cY,C1 as cZ,b1 as c_,dk as ca,HD as cb,sM as cc,xW as cd,XD as ce,sp as cf,xu as cg,zs as ch,Ou as ci,Tk as cj,Pu as ck,Du as cl,Au as cm,Mu as cn,mp as co,rp as cp,BW as cq,UR as cr,wf as cs,gi as ct,ha as cu,JS as cv,K8 as cw,px as cx,xI as cy,zW as cz,Vk as d,QV as d$,q7 as d0,CK as d1,Bj as d2,Uj as d3,T1 as d4,Fj as d5,yj as d6,_v as d7,G4 as d8,qw as d9,N7 as dA,tv as dB,qV as dC,iC as dD,uH as dE,fH as dF,$p as dG,Iq as dH,qW as dI,jW as dJ,Ls as dK,oC as dL,By as dM,rC as dN,GV as dO,Zy as dP,EC as dQ,ju as dR,ln as dS,kA as dT,X1 as dU,w1 as dV,Vj as dW,Q1 as dX,NE as dY,UE as dZ,Iz as d_,Z4 as da,Os as db,km as dc,xf as dd,HV as de,y1 as df,Ly as dg,B1 as dh,v1 as di,wV as dj,bV as dk,GK as dl,BV as dm,QK as dn,T7 as dp,M7 as dq,R2 as dr,vw as ds,VV as dt,A7 as du,yf as dv,fi as dw,F7 as dx,YK as dy,O7 as dz,T6 as e,AW as e$,sC as e0,TW as e1,DV as e2,GW as e3,TV as e4,QW as e5,Bi as e6,Iy as e7,G7 as e8,Hy as e9,ID as eA,vv as eB,lH as eC,Jz as eD,tH as eE,dH as eF,lW as eG,t2 as eH,DT as eI,K6 as eJ,nH as eK,Sq as eL,xq as eM,Qm as eN,$q as eO,vH as eP,Kj as eQ,ya as eR,h6 as eS,_l as eT,$v as eU,WC as eV,rr as eW,$f as eX,A6 as eY,e7 as eZ,qk as e_,NV as ea,Z7 as eb,LV as ec,FV as ed,du as ee,KV as ef,D7 as eg,pH as eh,jy as ei,AV as ej,HW as ek,z1 as el,Fs as em,i7 as en,Y7 as eo,rH as ep,Bq as eq,J7 as er,w6 as es,H7 as et,yH as eu,Fz as ev,E6 as ew,sE as ex,qq as ey,P7 as ez,Nn as f,_2 as f0,ZS as f1,XT as f2,bW as f3,Jy as f4,ZV as f5,Nt as f6,L6 as f7,Fi as f8,BA as f9,cn as g,Q7 as h,tA as i,uD as j,wD as k,_W as l,Kk as m,M6 as n,j6 as o,Cs as p,U7 as q,_0 as r,sH as s,L7 as t,m4 as u,X2 as v,FW as w,MO as x,IW as y,OW as z};
42
- //# sourceMappingURL=main-UjL26F9i.js.map
41
+ `;return typeof s=="function"&&s(null,f),f};const ez=m9,Lm=kE,FE=IE,tz=LE;function Rv(e,t,n,s,r){const o=[].slice.call(arguments,1),a=o.length,i=typeof o[a-1]=="function";if(!i&&!ez())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=Lm.create(n,s);c(e(d,t,s))}catch(d){l(d)}})}try{const c=Lm.create(n,s);r(null,e(c,t,s))}catch(c){r(c)}}Lm.create;Rv.bind(null,FE.render);var nz=Rv.bind(null,FE.renderToDataURL);Rv.bind(null,function(e,t,n){return tz.render(e,n)});const sz=Lt("actions");async function rz(){var e,t;if(!zE())return!1;try{if(En()){const n=window.electronAPI;return n!=null&&n.restartCli?(await n.restartCli(),!0):!1}if(bn())return typeof((t=(e=window.__TAURI__)==null?void 0:e.core)==null?void 0:t.invoke)=="function"?(await vs("cli_restart"),!0):!1}catch(n){return sz.error("Failed to restart CLI",n),!1}return!1}function oz(e){const t=e.filter(n=>n.scope!=="loopback");return{recommended:t[0]??null,hidden:t.slice(1)}}var iz=F("<span class=remote-toggle-state>"),az=F("<div class=remote-toggle-copy><span class=remote-toggle-title></span><span class=remote-toggle-caption>"),z0=F('<div class=settings-form-group><label class=settings-form-label></label><input class="selector-input w-full"type=password>'),cz=F("<div class=settings-password-actions><button class=settings-pill-button type=button>"),lz=F("<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>"),dz=F("<div class=remote-address-disclosure-content>"),uz=F("<div class=remote-address-disclosure><button class=remote-address-disclosure-trigger type=button><span class=remote-address-disclosure-label>"),fz=F("<div class=remote-address-list>"),gz=F('<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">'),hz=F("<div class=settings-card-message>"),mz=F("<div class=settings-error-message>"),W0=F("<div class=remote-card>"),pz=F("<div class=remote-error>"),jg=F("<div class=remote-qr>"),yz=F("<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>"),qg=F("<img class=remote-qr-img>"),H0=F("<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 G0=Lt("actions"),vz=()=>{const{t:e}=kt(),[t,n]=L(null),[s,r]=L(null),[o,a]=L(!1),[i,c]=L(!1),[l,d]=L({}),[u,f]=L(null),[h,m]=L(null),[w,S]=L(!1),[b,v]=L(""),[k,$]=L(""),[C,T]=L(null),[D,R]=L(!1),[q,re]=L(!1),ee=$e(()=>{var fe;return((fe=t())==null?void 0:fe.addresses)??[]}),W=$e(()=>{var fe;return((fe=t())==null?void 0:fe.listeningMode)??ku().listeningMode}),U=$e(()=>W()==="all"),J=$e(()=>{const fe=ee();return U()?oz(fe):{recommended:null,hidden:[]}}),le=async()=>{a(!0),m(null),T(null);try{const[fe,Re]=await Promise.all([ft.fetchServerMeta(),ft.fetchAuthStatus()]);n(fe),r(Re),re(!1)}catch(fe){m(fe instanceof Error?fe.message:String(fe))}finally{a(!1)}};Ns(()=>{le()});const z=async fe=>{if(u()===fe){f(null);return}if(f(fe),!l()[fe])try{const Re=await nz(fe,{margin:1,scale:4});d(be=>({...be,[fe]:Re}))}catch(Re){G0.error("Failed to generate QR code",Re)}},M=async fe=>{const Re=fe?"all":"local";if(!(Re===W()||i()||!await Wi(e("remoteAccess.listeningMode.restartConfirm.message"),{title:e(fe?"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 cT(Re),await rz()?n(Ce=>Ce&&{...Ce,listeningMode:Re}):m(e("remoteAccess.restart.errorManual"))}catch(ye){m(ye instanceof Error?ye.message:String(ye))}finally{c(!1)}le()}},N=fe=>{try{window.open(fe,"_blank","noopener,noreferrer")}catch(Re){G0.error("Failed to open URL",Re)}},ce=async()=>{T(null);const fe=b(),Re=k();if(fe.trim().length<8){T(e("remoteAccess.password.error.tooShort"));return}if(fe!==Re){T(e("remoteAccess.password.error.mismatch"));return}R(!0);try{const be=await ft.setServerPassword(fe);r({authenticated:!0,username:be.username,passwordUserProvided:be.passwordUserProvided}),v(""),$(""),S(!1)}catch(be){T(be instanceof Error?be.message:String(be))}finally{R(!1)}};return(()=>{var fe=gz(),Re=fe.firstChild,be=Re.firstChild,ye=be.firstChild,Ce=ye.firstChild,je=Ce.firstChild,O=je.nextSibling,g=ye.nextSibling,x=g.firstChild,A=x.nextSibling,E=A.firstChild,H=be.nextSibling,B=Re.nextSibling,oe=B.firstChild,Ae=oe.firstChild,we=Ae.firstChild,he=we.firstChild,Ee=he.nextSibling,Ge=Ae.nextSibling,Xe=B.nextSibling,se=Xe.firstChild,V=se.firstChild,Y=V.firstChild,Oe=Y.firstChild,ve=Oe.nextSibling,Ie=V.nextSibling;return p(ye,y(Cd,{class:"settings-card-heading-icon"}),Ce),p(je,()=>e("remoteAccess.sections.listeningMode.label")),p(O,()=>e("remoteAccess.sections.listeningMode.help")),p(x,()=>e("settings.scope.server")),A.$$click=()=>void le(),p(A,y(_d,{get class(){return`w-4 h-4 ${o()?"remote-spin":""}`}}),E),p(E,()=>e("remoteAccess.refresh")),p(Re,y(lc,{class:"remote-toggle",get checked(){return U()},onChange:Le=>void M(Le),get disabled(){return o()||i()},get children(){return[y(lc.Input,{}),y(lc.Control,{class:"remote-toggle-switch",get"data-checked"(){return U()},get children(){return[(()=>{var Le=iz();return p(Le,(()=>{var ze=_e(()=>!!U());return()=>ze()?e("remoteAccess.toggle.on"):e("remoteAccess.toggle.off")})()),Le})(),y(lc.Thumb,{class:"remote-toggle-thumb"})]}}),(()=>{var Le=az(),ze=Le.firstChild,Ne=ze.nextSibling;return p(ze,()=>e("remoteAccess.toggle.title")),p(Ne,(()=>{var Je=_e(()=>!!U());return()=>Je()?e("remoteAccess.toggle.caption.all"):e("remoteAccess.toggle.caption.local")})()),Le})()]}}),H),p(H,()=>e("remoteAccess.toggle.note")),p(Ae,y(Cd,{class:"settings-card-heading-icon"}),we),p(he,()=>e("remoteAccess.sections.serverPassword.label")),p(Ee,()=>e("remoteAccess.sections.serverPassword.help")),p(Ge,()=>e("settings.scope.server")),p(B,y(Q,{get when(){return _e(()=>!!s())()&&s().authenticated},get fallback(){return(()=>{var Le=hz();return p(Le,()=>e("remoteAccess.authStatus.unavailable")),Le})()},get children(){var Le=lz(),ze=Le.firstChild,Ne=ze.firstChild,Je=Ne.firstChild,ot=Je.nextSibling,gt=Ne.nextSibling,_=gt.firstChild;return p(Je,()=>e("remoteAccess.username",{username:s().username??"codenomad"})),p(ot,(()=>{var P=_e(()=>!!s().passwordUserProvided);return()=>P()?e("remoteAccess.password.status.set"):e("remoteAccess.password.status.unset")})()),_.$$click=()=>{S(!w()),T(null)},p(_,(()=>{var P=_e(()=>!!w());return()=>P()?e("remoteAccess.password.actions.cancel"):_e(()=>!!s().passwordUserProvided)()?e("remoteAccess.password.actions.change"):e("remoteAccess.password.actions.set")})()),p(Le,y(Q,{get when(){return w()},get children(){return[(()=>{var P=z0(),j=P.firstChild,K=j.nextSibling;return p(j,()=>e("remoteAccess.password.form.newPassword")),K.$$input=I=>v(I.currentTarget.value),de(()=>pe(K,"placeholder",e("remoteAccess.password.form.placeholder"))),de(()=>K.value=b()),P})(),(()=>{var P=z0(),j=P.firstChild,K=j.nextSibling;return p(j,()=>e("remoteAccess.password.form.confirmPassword")),K.$$input=I=>$(I.currentTarget.value),de(()=>K.value=k()),P})(),y(Q,{get when(){return C()},children:P=>(()=>{var j=mz();return p(j,P),j})()}),(()=>{var P=cz(),j=P.firstChild;return j.$$click=()=>void ce(),p(j,(()=>{var K=_e(()=>!!D());return()=>K()?e("remoteAccess.password.save.saving"):e("remoteAccess.password.save.label")})()),de(()=>j.disabled=D()),P})()]}}),null),Le}}),null),p(V,y(eD,{class:"settings-card-heading-icon"}),Y),p(Oe,()=>e("remoteAccess.sections.addresses.label")),p(ve,()=>e("remoteAccess.sections.addresses.help")),p(Ie,()=>e("settings.scope.server")),p(Xe,y(Q,{get when(){return!o()},get fallback(){return(()=>{var Le=W0();return p(Le,()=>e("remoteAccess.addresses.loading")),Le})()},get children(){return y(Q,{get when(){return!h()},get fallback(){return(()=>{var Le=pz();return p(Le,h),Le})()},get children(){return y(Q,{get when(){var Le;return!!J().recommended||((Le=t())==null?void 0:Le.localUrl)},get fallback(){return(()=>{var Le=W0();return p(Le,()=>e("remoteAccess.addresses.none")),Le})()},get children(){var Le=fz();return p(Le,y(Q,{get when(){var ze;return(ze=t())==null?void 0:ze.localUrl},children:ze=>{const Ne=()=>ze(),Je=()=>u()===Ne(),ot=()=>l()[Ne()];return(()=>{var gt=yz(),_=gt.firstChild,P=_.firstChild,j=P.firstChild,K=j.nextSibling,I=P.nextSibling,Z=I.firstChild,xe=Z.nextSibling;return p(j,Ne),p(K,()=>e("remoteAccess.address.scope.loopback")),Z.$$click=()=>N(Ne()),p(Z,y(Oi,{class:"remote-icon"}),null),p(Z,()=>e("remoteAccess.address.open"),null),xe.$$click=()=>void z(Ne()),p(xe,y(dd,{class:"remote-icon"}),null),p(xe,(()=>{var De=_e(()=>!!Je());return()=>De()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(gt,y(Q,{get when(){return Je()},get children(){var De=jg();return p(De,y(Q,{get when(){return ot()},get fallback(){return y(Nn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:Qe=>(()=>{var et=qg();return de(Tt=>{var He=Qe(),yt=e("remoteAccess.address.qrAlt",{url:Ne()});return He!==Tt.e&&pe(et,"src",Tt.e=He),yt!==Tt.t&&pe(et,"alt",Tt.t=yt),Tt},{e:void 0,t:void 0}),et})()})),De}}),null),de(()=>pe(xe,"aria-expanded",Je())),gt})()}}),null),p(Le,y(Q,{get when(){return J().recommended},children:ze=>{const Ne=ze(),Je=Ne.remoteUrl,ot=()=>u()===Je,gt=()=>l()[Je],_=()=>Ne.scope==="external"?e("remoteAccess.address.scope.network"):Ne.scope==="loopback"?e("remoteAccess.address.scope.loopback"):e("remoteAccess.address.scope.internal");return(()=>{var P=H0(),j=P.firstChild,K=j.firstChild,I=K.firstChild,Z=I.nextSibling,xe=Z.firstChild,De=xe.nextSibling;De.nextSibling;var Qe=K.nextSibling,et=Qe.firstChild,Tt=et.nextSibling;return p(I,Je),p(Z,()=>Ne.family.toUpperCase(),xe),p(Z,_,De),p(Z,()=>Ne.ip,null),et.$$click=()=>N(Je),p(et,y(Oi,{class:"remote-icon"}),null),p(et,()=>e("remoteAccess.address.open"),null),Tt.$$click=()=>void z(Je),p(Tt,y(dd,{class:"remote-icon"}),null),p(Tt,(()=>{var He=_e(()=>!!ot());return()=>He()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(P,y(Q,{get when(){return ot()},get children(){var He=jg();return p(He,y(Q,{get when(){return gt()},get fallback(){return y(Nn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:yt=>(()=>{var Qt=qg();return de(Ot=>{var Dn=yt(),Wn=e("remoteAccess.address.qrAlt",{url:Je});return Dn!==Ot.e&&pe(Qt,"src",Ot.e=Dn),Wn!==Ot.t&&pe(Qt,"alt",Ot.t=Wn),Ot},{e:void 0,t:void 0}),Qt})()})),He}}),null),de(()=>pe(Tt,"aria-expanded",ot())),P})()}}),null),p(Le,y(Q,{get when(){return J().hidden.length>0},get children(){var ze=uz(),Ne=ze.firstChild,Je=Ne.firstChild;return Ne.$$click=()=>re(!q()),p(Je,(()=>{var ot=_e(()=>!!q());return()=>ot()?e("remoteAccess.addresses.actions.hideOther"):e("remoteAccess.addresses.actions.showOther",{count:String(J().hidden.length)})})()),p(Ne,y(N2,{class:"remote-address-disclosure-chevron disclosure-chevron"}),null),p(ze,y(Q,{get when(){return q()},get children(){var ot=dz();return p(ot,y(Ut,{get each(){return J().hidden},children:gt=>{const _=gt.remoteUrl,P=()=>u()===_,j=()=>l()[_],K=()=>gt.scope==="external"?e("remoteAccess.address.scope.network"):gt.scope==="loopback"?e("remoteAccess.address.scope.loopback"):e("remoteAccess.address.scope.internal");return(()=>{var I=H0(),Z=I.firstChild,xe=Z.firstChild,De=xe.firstChild,Qe=De.nextSibling,et=Qe.firstChild,Tt=et.nextSibling;Tt.nextSibling;var He=xe.nextSibling,yt=He.firstChild,Qt=yt.nextSibling;return p(De,_),p(Qe,()=>gt.family.toUpperCase(),et),p(Qe,K,Tt),p(Qe,()=>gt.ip,null),yt.$$click=()=>N(_),p(yt,y(Oi,{class:"remote-icon"}),null),p(yt,()=>e("remoteAccess.address.open"),null),Qt.$$click=()=>void z(_),p(Qt,y(dd,{class:"remote-icon"}),null),p(Qt,(()=>{var Ot=_e(()=>!!P());return()=>Ot()?e("remoteAccess.address.hideQr"):e("remoteAccess.address.showQr")})(),null),p(I,y(Q,{get when(){return P()},get children(){var Ot=jg();return p(Ot,y(Q,{get when(){return j()},get fallback(){return y(Nn,{class:"remote-icon remote-spin","aria-hidden":"true"})},children:Dn=>(()=>{var Wn=qg();return de(Hn=>{var Gn=Dn(),dr=e("remoteAccess.address.qrAlt",{url:_});return Gn!==Hn.e&&pe(Wn,"src",Hn.e=Gn),dr!==Hn.t&&pe(Wn,"alt",Hn.t=dr),Hn},{e:void 0,t:void 0}),Wn})()})),Ot}}),null),de(()=>pe(Qt,"aria-expanded",P())),I})()}})),ot}}),null),de(ot=>{var gt=q(),_=q();return gt!==ot.e&&pe(ze,"data-expanded",ot.e=gt),_!==ot.t&&pe(Ne,"aria-expanded",ot.t=_),ot},{e:void 0,t:void 0}),ze}}),null),Le}})}})}}),null),de(()=>A.disabled=o()),fe})()};Ht(["click","input"]);async function wz(e,t,n){if(!qi())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(En()){const r=window.electronAPI;if(typeof(r==null?void 0:r.openRemoteWindow)=="function"){await r.openRemoteWindow(s);return}}if(bn()){if(n!==void 0&&(t??e.baseUrl).startsWith("https://")&&await vs("needs_local_certificate_install")&&!await Wi(ke("folderSelection.servers.certificateInstall.confirmMessage"),{title:ke("folderSelection.servers.certificateInstall.title"),variant:"warning",confirmLabel:ke("folderSelection.servers.certificateInstall.confirmLabel"),cancelLabel:ke("folderSelection.servers.certificateInstall.cancelLabel")}))throw new Error(ke("folderSelection.servers.certificateInstall.cancelled"));await vs("open_remote_window",{payload:s});return}window.open(e.baseUrl,"_blank","noopener,noreferrer")}function bz(){const{t:e}=kt(),{remoteServers:t,saveRemoteServerProfile:n,markRemoteServerConnected:s,removeRemoteServerProfile:r}=Tn(),[o,a]=L(null),i=async(l,d)=>{if(d&&!qi())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 h=await ft.probeRemoteServer({baseUrl:f,skipTlsVerify:l.skipTlsVerify});if(!h.ok)throw new Error(h.error||e("folderSelection.servers.dialog.errorConnect"));const m=await n({id:l.id,name:u,baseUrl:h.normalizedUrl,skipTlsVerify:l.skipTlsVerify});if(d){const w=bn()&&m.skipTlsVerify&&m.baseUrl.startsWith("https://")?await ft.createRemoteProxySession({baseUrl:m.baseUrl,skipTlsVerify:!0}):void 0;try{await wz(m,w==null?void 0:w.windowUrl,w==null?void 0:w.sessionId)}catch(S){throw w&&ft.deleteRemoteProxySession(w.sessionId).catch(()=>{}),S}await s(m.id)}return m};return{remoteServers:t,connectingServerId:o,saveServer:i,connectSavedServer:async l=>{if(!qi()||o())return;const d=t().find(u=>u.id===l);if(d){a(l);try{await i(d,!0)}catch(u){Cs(u instanceof Error?u.message:String(u),{title:e("folderSelection.servers.errorTitle"),variant:"warning"})}finally{a(null)}}},removeRemoteServerProfile:r}}var Sz=F("<div>"),Z0=F('<label class="flex flex-col gap-2 text-sm text-secondary"><span></span><input class="selector-input w-full">'),kz=F('<label class="flex items-start gap-3 text-sm text-secondary"><input type=checkbox><span>'),xz=F('<span class="inline-flex items-center gap-2">'),$z=F('<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">'),_z=F('<div class="fixed inset-0 z-[1300] flex items-center justify-center p-4">'),Cz=F('<p class="text-sm text-red-500 break-words">'),Ez=F("<span>");const Tz=e=>{const{t}=kt(),[n,s]=L(""),[r,o]=L(""),[a,i]=L(!1),[c,l]=L(null),[d,u]=L(!1);qe(()=>{e.open&&(s(""),o(""),i(!1),l(null))});const f=async h=>{if(!d()){u(!0),l(null);try{await e.onSubmit({name:n(),baseUrl:r(),skipTlsVerify:a()},h),e.onOpenChange(!1)}catch(m){l(m instanceof Error?m.message:String(m))}finally{u(!1)}}};return y(_t,{get open(){return e.open},get onOpenChange(){return e.onOpenChange},get children(){return y(_t.Portal,{get children(){return[y(_t.Overlay,{class:"modal-overlay"}),(()=>{var h=_z();return p(h,y(_t.Content,{class:"modal-surface w-full max-w-lg p-6 flex flex-col gap-5",tabIndex:-1,get children(){return[(()=>{var m=Sz();return p(m,y(_t.Title,{class:"text-xl font-semibold text-primary",get children(){return t("folderSelection.servers.dialog.title")}}),null),p(m,y(_t.Description,{class:"text-sm text-secondary mt-2",get children(){return t("folderSelection.servers.dialog.description")}}),null),m})(),(()=>{var m=Z0(),w=m.firstChild,S=w.nextSibling;return p(w,()=>t("folderSelection.servers.dialog.name")),S.$$input=b=>s(b.currentTarget.value),de(()=>pe(S,"placeholder",t("folderSelection.servers.dialog.namePlaceholder"))),de(()=>S.value=n()),m})(),(()=>{var m=Z0(),w=m.firstChild,S=w.nextSibling;return p(w,()=>t("folderSelection.servers.dialog.url")),S.$$input=b=>o(b.currentTarget.value),de(()=>pe(S,"placeholder",t("folderSelection.servers.dialog.urlPlaceholder"))),de(()=>S.value=r()),m})(),(()=>{var m=kz(),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(Q,{get when(){return c()},children:m=>(()=>{var w=Cz();return p(w,m),w})()}),(()=>{var m=$z(),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(Q,{get when(){return d()},get fallback(){return(()=>{var v=Ez();return p(v,()=>t("folderSelection.servers.dialog.connect")),v})()},get children(){var v=xz();return p(v,y(Nn,{class:"w-4 h-4 animate-spin"}),null),p(v,()=>t("folderSelection.servers.dialog.connecting"),null),v}})),de(v=>{var k=d(),$=d();return k!==v.e&&(S.disabled=v.e=k),$!==v.t&&(b.disabled=v.t=$),v},{e:void 0,t:void 0}),m})()]}})),h})()]}})}})};Ht(["input","click"]);var Mz=F('<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>'),Az=F("<div class=settings-card-message>"),Dz=F('<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 Pz=()=>{const{t:e}=kt(),{remoteServers:t,connectingServerId:n,saveServer:s,connectSavedServer:r,removeRemoteServerProfile:o}=bz(),[a,i]=L(!1);return[(()=>{var c=Mz(),l=c.firstChild,d=l.firstChild,u=d.firstChild,f=u.firstChild,h=f.nextSibling,m=d.nextSibling,w=m.firstChild,S=l.nextSibling;return p(d,y(Bo,{class:"settings-card-heading-icon"}),u),p(f,()=>e("folderSelection.tabs.servers")),p(h,()=>e("folderSelection.servers.empty.description")),m.$$click=()=>i(!0),p(m,y(Eu,{class:"w-4 h-4"}),w),p(w,()=>e("folderSelection.actions.connectButton")),p(S,y(Q,{get when(){return t().length>0},get fallback(){return(()=>{var b=Az();return p(b,()=>e("folderSelection.servers.empty.title")),b})()},get children(){return y(Ut,{get each(){return t()},children:b=>(()=>{var v=Dz(),k=v.firstChild,$=k.firstChild,C=$.nextSibling,T=k.nextSibling,D=T.firstChild,R=D.nextSibling;return p($,()=>b.name),p(C,()=>b.baseUrl),D.$$click=()=>void r(b.id),p(D,y(Q,{get when(){return n()===b.id},get fallback(){return y(Bo,{class:"w-4 h-4"})},get children(){return y(Nn,{class:"w-4 h-4 animate-spin"})}})),R.$$click=()=>o(b.id),p(R,y(Tu,{class:"w-4 h-4"})),de(q=>{var re=!!n(),ee=`${e("folderSelection.servers.dialog.connect")}: ${b.name}`,W=`${e("folderSelection.servers.dialog.connect")}: ${b.name}`,U=`${e("folderSelection.servers.remove")}: ${b.name}`,J=`${e("folderSelection.servers.remove")}: ${b.name}`;return re!==q.e&&(D.disabled=q.e=re),ee!==q.t&&pe(D,"aria-label",q.t=ee),W!==q.a&&pe(D,"title",q.a=W),U!==q.o&&pe(R,"title",q.o=U),J!==q.i&&pe(R,"aria-label",q.i=J),q},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),v})()})}})),c})(),y(Tz,{get open(){return a()},onOpenChange:i,onSubmit:s})]};Ht(["click"]);const Oz=Lt("api");function wu(e){return`/sidecars/${encodeURIComponent(e)}/`}const[NE,Iv]=L(new Map),[Rz,zf]=L([]),[Lv,Fv]=L(null),[Iz,zg]=L(!1);let Eo=null,Lz=0;class Fz extends Error{constructor(t){super(t),this.name="SidecarNotFoundError"}}async function UE(e){if(!Eo){zg(!0);const n=ft.fetchSidecars().then(s=>{Iv(new Map(s.sidecars.map(r=>[r.id,r])))});Eo=n,n.then(()=>{zg(!1),Eo===n&&(Eo=null)},s=>{Oz.error("Failed to load SideCars",s),zg(!1),Eo===n&&(Eo=null)})}const t=Eo;if(e!=null&&e.propagateErrors)return t;await t.catch(()=>{})}function Nz(e){Iv(t=>{const n=new Map(t);return n.set(e.id,e),n}),zf(t=>t.map(n=>n.sidecarId===e.id?{...n,name:e.name,port:e.port,prefixMode:e.prefixMode,proxyBasePath:wu(e.id).replace(/\/$/,""),shellUrl:wu(e.id)}:n))}function Uz(e){Iv(t=>{const n=new Map(t);return n.delete(e),n}),zf(t=>{var s;const n=t.filter(r=>r.sidecarId!==e);return n.some(r=>r.token===Lv())||Fv(((s=n[0])==null?void 0:s.token)??null),n})}fs.on("sidecar.updated",e=>{e.type==="sidecar.updated"&&Nz(e.sidecar)});fs.on("sidecar.removed",e=>{e.type==="sidecar.removed"&&Uz(e.sidecarId)});async function yH(e,t){var o,a;if((o=t==null?void 0:t.signal)!=null&&o.aborted)throw Bi(t.signal);await Bq(()=>UE({propagateErrors:t==null?void 0:t.propagateLoadErrors}),{signal:t==null?void 0:t.signal});const n=NE().get(e);if(!n)throw new Fz(ke("sidecars.open.notFound"));if(n.status!=="running")throw new Error(ke("sidecars.open.notRunning"));const r={token:`${e}:${Date.now().toString(36)}:${(Lz++).toString(36)}`,sidecarId:e,name:n.name,port:n.port,prefixMode:n.prefixMode,proxyBasePath:wu(e).replace(/\/$/,""),shellUrl:wu(e)};if((a=t==null?void 0:t.signal)!=null&&a.aborted)throw Bi(t.signal);return zf(i=>[...i,r]),((t==null?void 0:t.activate)??!0)&&Fv(r.token),r}function vH(e){zf(t=>{const n=t.findIndex(r=>r.token===e);if(n<0)return t;const s=t.filter(r=>r.token!==e);if(Lv()===e){const r=s[n-1]??s[n]??null;Fv((r==null?void 0:r.token)??null)}return s})}$e(()=>Rz().find(e=>e.token===Lv())??null);var J0=F('<div class="text-sm text-red-500">'),Bz=F('<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>'),Y0=F("<div class=settings-card-message>"),Kz=F('<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 Vz(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")}const jz=()=>{const{t:e}=kt(),[t,n]=L(""),[s,r]=L("3000"),[o,a]=L(!1),[i,c]=L("strip"),[l,d]=L(null),[u,f]=L(!1),[h,m]=L(null),[w,S]=L(null);Ns(()=>{UE()});const b=$e(()=>Array.from(NE().values()).sort((C,T)=>C.name.localeCompare(T.name))),v=$e(()=>Vz(t())||"your-sidecar");async function k(){const C=t().trim(),T=Number(s());if(!C||!Number.isInteger(T)||T<=0||T>65535){m(e("sidecars.form.validation"));return}f(!0),m(null);try{await ft.createSidecar({kind:"port",name:C,port:T,insecure:o(),prefixMode:i()}),n(""),r("3000"),a(!1),c("strip")}catch(D){m(D instanceof Error?D.message:String(D))}finally{f(!1)}}async function $(C){d(C),S(null);try{await ft.deleteSidecar(C)}catch(T){S(T instanceof Error?T.message:String(T))}finally{d(null)}}return(()=>{var C=Bz(),T=C.firstChild,D=T.firstChild,R=D.firstChild,q=R.firstChild,re=q.firstChild,ee=re.nextSibling,W=R.nextSibling,U=D.nextSibling,J=U.firstChild,le=J.firstChild,z=le.firstChild,M=z.nextSibling,N=M.firstChild,ce=N.nextSibling;ce.firstChild;var fe=le.nextSibling,Re=J.nextSibling,be=Re.firstChild,ye=be.firstChild,Ce=be.nextSibling,je=Re.nextSibling,O=je.firstChild,g=O.firstChild,x=g.nextSibling,A=O.nextSibling,E=A.firstChild,H=E.nextSibling,B=je.nextSibling,oe=B.firstChild,Ae=oe.firstChild,we=Ae.nextSibling,he=oe.nextSibling,Ee=he.firstChild,Ge=Ee.nextSibling,Xe=B.nextSibling,se=Xe.firstChild,V=se.firstChild,Y=T.nextSibling,Oe=Y.firstChild,ve=Oe.firstChild,Ie=ve.firstChild,Le=Ie.nextSibling,ze=Oe.nextSibling;return p(R,y(Bo,{class:"settings-card-heading-icon"}),q),p(re,()=>e("settings.section.sidecars.title")),p(ee,()=>e("settings.section.sidecars.subtitle")),p(W,()=>e("settings.scope.server")),p(z,()=>e("sidecars.form.name")),p(M,()=>e("sidecars.basePath"),N),p(ce,v,null),fe.$$input=Ne=>{m(null),n(Ne.currentTarget.value)},p(ye,()=>e("sidecars.form.port")),Ce.$$input=Ne=>{m(null),r(Ne.currentTarget.value)},p(g,()=>e("sidecars.form.protocol")),p(x,()=>e("sidecars.form.protocol.help")),A.addEventListener("change",Ne=>a(Ne.currentTarget.value==="http")),p(E,()=>e("sidecars.form.protocol.https")),p(H,()=>e("sidecars.form.protocol.http")),p(Ae,()=>e("sidecars.form.prefixMode")),p(we,()=>e("sidecars.form.prefixMode.help")),he.addEventListener("change",Ne=>c(Ne.currentTarget.value)),p(Ee,()=>e("sidecars.form.prefixMode.strip")),p(Ge,()=>e("sidecars.form.prefixMode.preserve")),p(U,y(Q,{get when(){return h()},get children(){var Ne=J0();return p(Ne,h),Ne}}),Xe),se.$$click=()=>void k(),p(se,y(Q,{get when(){return u()},get fallback(){return y(Eu,{class:"w-4 h-4"})},get children(){return y(Nn,{class:"w-4 h-4 animate-spin"})}}),V),p(V,()=>e("sidecars.form.add")),p(Ie,()=>e("sidecars.settings.listTitle")),p(Le,()=>e("sidecars.settings.listSubtitle")),p(ze,y(Q,{get when(){return w()},get children(){var Ne=J0();return p(Ne,w),Ne}}),null),p(ze,y(Q,{get when(){return!Iz()},get fallback(){return(()=>{var Ne=Y0();return p(Ne,()=>e("sidecars.picker.loading")),Ne})()},get children(){return y(Q,{get when(){return b().length>0},get fallback(){return(()=>{var Ne=Y0();return p(Ne,()=>e("sidecars.settings.empty")),Ne})()},get children(){return y(Ut,{get each(){return b()},children:Ne=>(()=>{var Je=Kz(),ot=Je.firstChild,gt=ot.firstChild,_=gt.nextSibling,P=_.firstChild,j=P.nextSibling;j.nextSibling;var K=_.nextSibling,I=K.firstChild,Z=I.nextSibling;Z.firstChild,Z.nextSibling;var xe=ot.nextSibling,De=xe.firstChild,Qe=De.nextSibling;return p(gt,()=>Ne.name),p(_,()=>e("sidecars.kind.port"),P),p(_,()=>Ne.insecure?"http":"https",j),p(_,()=>Ne.port,null),p(K,()=>e("sidecars.basePath"),I),p(Z,()=>Ne.id,null),p(K,()=>e(`sidecars.form.prefixMode.${Ne.prefixMode}`),null),p(De,()=>e(`sidecars.status.${Ne.status}`)),Qe.$$click=()=>void $(Ne.id),p(Qe,y(Tu,{class:"w-4 h-4"})),de(()=>Qe.disabled=l()===Ne.id),Je})()})}})}}),null),de(()=>se.disabled=u()),de(()=>fe.value=t()),de(()=>Ce.value=s()),de(()=>A.value=o()?"http":"https"),de(()=>he.value=i()),C})()};Ht(["input","click"]);async function dc(e){if(mn.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}mn.host==="tauri"&&await vs("window_control",{action:e})}async function qz(){mn.host==="tauri"&&await vs("window_control",{action:"drag"})}async function zz(e,t){var r;const n=t.getBoundingClientRect(),s={x:n.left,y:n.bottom};if(mn.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 mn.host==="tauri"&&await vs("popup_titlebar_menu",{menu:e,...s})}var Wz=F("<nav class=native-titlebar-menu data-titlebar-interactive>"),Hz=F('<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>'),Gz=F("<button type=button class=native-titlebar-menu-button>");const Zz=["file","edit","view","window","help"],Jz=e=>{const{t}=kt(),n=()=>e.onClose?e.onClose():dc("close");return(()=>{var s=Hz(),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]")||dc("maximize")},s.$$pointerdown=u=>{u.button===0&&!u.target.closest("[data-titlebar-interactive]")&&qz()},p(o,()=>e.title),p(s,y(Q,{get when(){return e.menus},get children(){var u=Wz();return p(u,y(Ut,{each:Zz,children:f=>(()=>{var h=Gz();return h.$$click=m=>void zz(f,m.currentTarget),p(h,()=>t(`window.menu.${f}`)),h})()})),de(()=>pe(u,"aria-label",t("window.menu.ariaLabel"))),u}}),a),c.$$click=()=>void dc("minimize"),p(c,y(EA,{"aria-hidden":"true"})),l.$$click=()=>void dc("maximize"),p(l,y(kA,{"aria-hidden":"true"})),d.$$click=()=>void n(),p(d,y(Ko,{"aria-hidden":"true"})),de(u=>{var f=t("window.controls.minimize"),h=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&&pe(c,"aria-label",u.e=f),h!==u.t&&pe(c,"title",u.t=h),m!==u.a&&pe(l,"aria-label",u.a=m),w!==u.o&&pe(l,"title",u.o=w),S!==u.i&&pe(d,"aria-label",u.i=S),b!==u.n&&pe(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})()};Ht(["pointerdown","dblclick","click"]);function Yz(e,t,n){qe(()=>{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=h=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(h.key)&&l()},u=()=>{o||n(Math.round(r.scrollTop))},f=new ResizeObserver(c);f.observe(r);for(const h of r.children)f.observe(h);r.addEventListener("scroll",u),r.addEventListener("wheel",l,{passive:!0}),r.addEventListener("pointerdown",l),r.addEventListener("keydown",d),c(),nt(()=>{f.disconnect(),cancelAnimationFrame(a),r.removeEventListener("scroll",u),r.removeEventListener("wheel",l),r.removeEventListener("pointerdown",l),r.removeEventListener("keydown",d)})})}var Qz=F("<div class=settings-section-stack>"),Xz=F("<h1 class=sr-only>"),eW=F('<div class="flex-1 min-w-0">'),tW=F('<button type=button class="window-icon-button settings-screen-close settings-screen-compact-close">'),nW=F('<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>'),sW=F('<button type=button class="window-icon-button settings-screen-close">'),rW=F('<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">'),oW=F('<span class=settings-section-selector-value><span class="selector-trigger-primary selector-trigger-primary--align-left">'),iW=F("<button type=button class=settings-nav-button><span>"),aW=F('<div class=settings-window-root><div class="modal-surface window-shell settings-screen-shell">'),cW=F("<div class=settings-screen-frame>");const lW=e=>{const{t}=kt(),n=m4("(max-width: 640px)"),s=$e(()=>{const b=[{id:"general",icon:WA,label:t("settings.nav.general")},{id:"chat",icon:$A,label:t("settings.nav.chat")},{id:"notifications",icon:GS,label:t("settings.nav.notifications")},{id:"speech",icon:ih,label:t("settings.nav.speech")},{id:"opencode",icon:ep,label:t("settings.nav.opencode")},{id:"providers",icon:JS,label:t("settings.nav.providers")},{id:"sidecars",icon:Bo,label:t("settings.nav.sidecars")},{id:"config-files",icon:H2,label:t("settings.nav.configFiles")},{id:"advanced",icon:Fl,label:t("settings.nav.advanced")},{id:"info",icon:Xm,label:t("settings.nav.info")}];return(e.standalone||qi())&&b.splice(4,0,{id:"remote",icon:MA,label:t("settings.nav.remote")}),b}),r=$e(()=>s().find(b=>b.id===vi())??s()[0]),o=()=>{switch(vi()){case"chat":return y(nO,{});case"notifications":return y(KO,{});case"speech":return y(lR,{});case"remote":return e.standalone||qi()?(()=>{var b=Qz();return p(b,y(vz,{}),null),p(b,y(Pz,{}),null),b})():y(Vw,{showStartupState:!0});case"opencode":return y(G8,{});case"providers":return y(V8,{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(jz,{});case"config-files":return y(u9,{});case"advanced":return y(t9,{});case"info":return y(bO,{});case"general":default:return y(Vw,{get showStartupState(){return!e.standalone}})}},a=async b=>{var v;b!==vi()&&await Ii()&&(await((v=e.onSectionChange)==null?void 0:v.call(e,b)),pp(b),u==null||u.scrollTo({top:0}))},i=async()=>{await Ii()&&(e.onClose?await e.onClose():E4())},[c,l]=L({x:0,y:0});qe(()=>{n()&&l({x:0,y:0})});let d,u;Yz(()=>u,()=>(vi(),e.scrollPosition),b=>{var v;return(v=e.onScrollPositionChange)==null?void 0:v.call(e,b)});let f;const h=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(Q,{get when(){return e.standalone},get children(){var b=Xz();return p(b,()=>t("settings.title")),b}}),(()=>{var b=nW(),v=b.firstChild,k=v.firstChild,$=k.nextSibling,C=v.nextSibling,T=C.firstChild,D=T.firstChild,R=D.nextSibling,q=R.firstChild,re=C.nextSibling;return p(k,y(Fl,{class:"settings-screen-nav-icon"})),p($,y(Te,{get value(){return r()},onChange:ee=>ee&&void a(ee.id),get options(){return s()},optionValue:"id",optionTextValue:"label",itemComponent:ee=>{const W=ee.item.rawValue.icon;return y(Te.Item,{get item(){return ee.item},class:"selector-option settings-section-selector-option",get children(){return[y(W,{class:"settings-section-selector-option-icon"}),y(Te.ItemLabel,{class:"selector-option-label",get children(){return ee.item.rawValue.label}})]}})},get children(){return[y(Te.Trigger,{class:"selector-trigger settings-section-selector-trigger",get"aria-label"(){return t("settings.navigationAriaLabel")},get children(){return[(()=>{var ee=eW();return p(ee,y(Te.Value,{children:W=>{const U=W.selectedOption(),J=(U==null?void 0:U.icon)??Fl;return(()=>{var le=oW(),z=le.firstChild;return p(le,y(J,{class:"settings-section-selector-value-icon"}),z),p(z,()=>U==null?void 0:U.label),le})()}})),ee})(),y(Te.Icon,{class:"selector-trigger-icon",get children(){return y(tr,{class:"w-3 h-3"})}})]}}),y(Te.Portal,{get children(){return y(Te.Content,{class:"selector-popover settings-section-selector-popover",get children(){return y(Te.Listbox,{class:"selector-listbox"})}})}})]}})),p(v,y(Q,{get when(){return!e.standalone},get children(){var ee=tW();return ee.$$click=()=>void i(),p(ee,y(Ko,{class:"w-4 h-4"})),de(W=>{var U=t("settings.close"),J=t("settings.close");return U!==W.e&&pe(ee,"aria-label",W.e=U),J!==W.t&&pe(ee,"title",W.t=J),W},{e:void 0,t:void 0}),ee}}),null),C.addEventListener("pointercancel",w),C.$$pointerup=w,C.$$pointermove=m,C.$$pointerdown=h,p(D,y(Fl,{class:"settings-screen-nav-icon"})),p(q,()=>t("settings.title")),p(re,y(Ut,{get each(){return s()},children:ee=>{const W=ee.icon;return(()=>{var U=iW(),J=U.firstChild;return U.$$click=()=>void a(ee.id),p(U,y(W,{class:"settings-nav-button-icon"}),J),p(J,()=>ee.label),de(le=>{var z=vi()===ee.id?"true":"false",M=vi()===ee.id?"page":void 0;return z!==le.e&&pe(U,"data-selected",le.e=z),M!==le.t&&pe(U,"aria-current",le.t=M),le},{e:void 0,t:void 0}),U})()}})),de(()=>pe(re,"aria-label",t("settings.navigationAriaLabel"))),b})(),(()=>{var b=rW(),v=b.firstChild,k=v.firstChild,$=k.firstChild,C=$.nextSibling,T=v.nextSibling;v.addEventListener("pointercancel",w),v.$$pointerup=w,v.$$pointermove=m,v.$$pointerdown=h,p($,()=>t("settings.content.eyebrow")),p(C,()=>{var R;return(R=r())==null?void 0:R.label}),p(v,y(Q,{get when(){return!e.standalone},get children(){var R=sW();return R.$$click=()=>void i(),p(R,y(Ko,{class:"w-4 h-4"})),de(q=>{var re=t("settings.close"),ee=t("settings.close");return re!==q.e&&pe(R,"aria-label",q.e=re),ee!==q.t&&pe(R,"title",q.t=ee),q},{e:void 0,t:void 0}),R}}),null);var D=u;return typeof D=="function"?Xs(D,T):u=T,p(T,o),b})()];return e.standalone?(()=>{var b=aW(),v=b.firstChild;p(b,y(Jz,{get title(){return t("settings.title")},onClose:i}),v);var k=d;return typeof k=="function"?Xs(k,v):d=v,p(v,S),b})():y(_t,{get modal(){return n()},get preventScroll(){return n()},get open(){return Kk()},onOpenChange:b=>!b&&void i(),get children(){return y(_t.Portal,{get children(){var b=cW();return p(b,y(_t.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(_t.Title,{class:"sr-only",get children(){return t("settings.title")}}),_e(()=>S())]}})),b}})}})};Ht(["click","pointerdown","pointermove","pointerup"]);const dW=()=>{const[e,t]=L({section:"general"}),n=[];let s=Promise.resolve(),r,o=0,a,i=Promise.resolve();const c=(h,m)=>(i=i.catch(()=>{}).then(()=>w4(h(),m)),i),l=h=>(clearTimeout(a),a=void 0,c(()=>({...e(),scrollTop:o}),h)),d=async h=>{await s.catch(()=>{}),await l(h)},u=async(h,m=!0)=>{if(m&&!await Ii())return;clearTimeout(a),m&&await c(()=>h);const w=e().instanceId;w&&w!==h.instanceId&&Ji.destroyClientsForInstance(w),o=h.scrollTop??0,nn(()=>{t(h),pp(h.section)})},f=async(h=!0)=>r||(r=(async()=>{(!h||await Ii())&&(await d(),await dc("close"))})().finally(()=>{r=void 0}),r);return Ns(()=>{let h=!0,m=!1,w=!1,S=!1,b=!1,v=!1;(async()=>{try{const k=await k4($=>{m=!0,h&&(s=s.catch(()=>{}).then(()=>u($)))});if(!h)return k();n.push(k),w=!0}catch{}try{const k=await S4();h&&!m&&await u(k,!1)}catch{}try{const k=await x4(()=>void f());if(!h)return k();n.push(k),S=!0}catch{}try{const k=await $4($=>{s=s.catch(()=>{}).then(async()=>{const C=await Ii();C&&await l(),await _4($,C)})});if(!h)return k();n.push(k),b=!0}catch{}try{const k=await b4(d);if(!h)return k();n.push(k),v=!0}catch{}w&&S&&b&&v&&await v4()})(),nt(()=>{h=!1,clearTimeout(a),n.splice(0).forEach($=>$());const k=e().instanceId;k&&Ji.destroyClientsForInstance(k)})}),[y(lW,{standalone:!0,get providerContext(){return{instanceId:e().instanceId,location:e().location}},get scrollPosition(){return e()},onScrollPositionChange:h=>{o=h,clearTimeout(a),a=setTimeout(()=>{l().catch(()=>{})},150)},onSectionChange:async h=>{clearTimeout(a);const m={...e(),section:h,scrollTop:0};await c(()=>m),o=0,t(m)},onClose:()=>f(!1)}),y(t2,{}),y(ID,{automatic:!1}),y(DT,{position:"top-right",gutter:16,toastOptions:{duration:8e3,className:"bg-transparent border-none shadow-none p-0"}})]},BE=document.getElementById("root");if(!BE)throw new Error("Root element not found");const uW=BE;typeof document<"u"&&(document.documentElement.dataset.runtimeHost=mn.host,document.documentElement.dataset.runtimePlatform=mn.platform);async function fW(){var t;let e=dW;if(Nm(mn)){const[{initializeClientState:n},s]=await Promise.all([ts(()=>import("./client-state-DTQzqBPJ.js").then(r=>r.j),__vite__mapDeps([8,2,3,4,5,6,1,7])),ts(()=>import("./App-DXfroBn-.js").then(r=>r.N),__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([Vv.loadConfigOwner("ui"),Vv.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;jv($i(o,r),{systemDark:window.matchMedia("(prefers-color-scheme: dark)").matches}),await Uv(a)}catch{jv($i("system"),{systemDark:window.matchMedia("(prefers-color-scheme: dark)").matches}),await Uv()}lT(()=>y(fT,{get children(){return y(dT,{get children(){return y(WE,{get children(){return y(uT,{get children(){return y(e,{})}})}})}})}}),uW)}fW();export{p6 as $,RW as A,GS as B,N2 as C,_t as D,Oi as E,sA as F,Bo as G,LW as H,Ye as I,NW as J,Eu as K,D4 as L,MA as M,EW as N,PW as O,IA as P,Ue as Q,Tz as R,Fl as S,Tu as T,Yr as U,$n as V,Eq as W,Ko as X,l6 as Y,DC as Z,Wi as _,Fn as a,RS as a$,$6 as a0,eE as a1,x2 as a2,_6 as a3,iE as a4,P6 as a5,Br as a6,fE as a7,Pm as a8,q6 as a9,xr as aA,wW as aB,ge as aC,tp as aD,OS as aE,Mn as aF,tl as aG,GD as aH,ls as aI,zt as aJ,Zm as aK,ds as aL,Ea as aM,f9 as aN,PS as aO,Zt as aP,kW as aQ,xn as aR,pr as aS,eP as aT,CS as aU,_k as aV,AS as aW,Qc as aX,Jg as aY,ak as aZ,TS as a_,xo as aa,Xq as ab,O6 as ac,Zi as ad,Bt as ae,jn as af,U6 as ag,N6 as ah,UW as ai,Xk as aj,uR as ak,fR as al,Fe as am,Df as an,zV as ao,sr as ap,F6 as aq,jd as ar,WI as as,o7 as at,s7 as au,r7 as av,sO as aw,K7 as ax,$W as ay,Dt as az,Ww as b,OA as b$,Gv as b0,SW as b1,el as b2,hp as b3,ih as b4,qO as b5,qj as b6,Xm as b7,Rz as b8,gH as b9,pw as bA,tr as bB,Px as bC,nL as bD,sv as bE,oj as bF,MV as bG,V1 as bH,H1 as bI,EV as bJ,Rp as bK,JW as bL,ZW as bM,ZO as bN,rb as bO,JO as bP,qd as bQ,a7 as bR,Ky as bS,D6 as bT,B7 as bU,YW as bV,Nj as bW,eg as bX,Fo as bY,j7 as bZ,V7 as b_,IC as ba,Fv as bb,hH as bc,C6 as bd,Lv as be,bs as bf,Lq as bg,wa as bh,Am as bi,mH as bj,t7 as bk,zj as bl,W7 as bm,z7 as bn,n7 as bo,da as bp,H4 as bq,pt as br,ou as bs,MW as bt,XW as bu,wp as bv,DW as bw,gx as bx,RK as by,OK as bz,bz as c,jj as c$,pC as c0,or as c1,ip as c2,Ck as c3,Ek as c4,QD as c5,CW as c6,ck as c7,lk as c8,Mk as c9,ug as cA,Io as cB,lo as cC,Te as cD,ri as cE,KW as cF,WW as cG,VW as cH,_d as cI,GM as cJ,WV as cK,cC as cL,Pf as cM,nj as cN,E7 as cO,R7 as cP,IV as cQ,I7 as cR,ej as cS,_1 as cT,$1 as cU,x1 as cV,k1 as cW,S1 as cX,E1 as cY,C1 as cZ,b1 as c_,dk as ca,HD as cb,sM as cc,xW as cd,XD as ce,sp as cf,xu as cg,zs as ch,Ou as ci,Tk as cj,Pu as ck,Du as cl,Au as cm,Mu as cn,mp as co,rp as cp,BW as cq,UR as cr,wf as cs,gi as ct,ha as cu,JS as cv,K8 as cw,px as cx,xI as cy,zW as cz,Vk as d,QV as d$,q7 as d0,CK as d1,Bj as d2,Uj as d3,T1 as d4,Fj as d5,yj as d6,_v as d7,G4 as d8,qw as d9,N7 as dA,tv as dB,qV as dC,iC as dD,uH as dE,fH as dF,$p as dG,Iq as dH,qW as dI,jW as dJ,Ls as dK,oC as dL,By as dM,rC as dN,GV as dO,Zy as dP,EC as dQ,ju as dR,ln as dS,kA as dT,X1 as dU,w1 as dV,Vj as dW,Q1 as dX,NE as dY,UE as dZ,Iz as d_,Z4 as da,Os as db,km as dc,xf as dd,HV as de,y1 as df,Ly as dg,B1 as dh,v1 as di,wV as dj,bV as dk,GK as dl,BV as dm,QK as dn,T7 as dp,M7 as dq,R2 as dr,vw as ds,VV as dt,A7 as du,yf as dv,fi as dw,F7 as dx,YK as dy,O7 as dz,T6 as e,AW as e$,sC as e0,TW as e1,DV as e2,GW as e3,TV as e4,QW as e5,Bi as e6,Iy as e7,G7 as e8,Hy as e9,ID as eA,vv as eB,lH as eC,Jz as eD,tH as eE,dH as eF,lW as eG,t2 as eH,DT as eI,K6 as eJ,nH as eK,Sq as eL,xq as eM,Qm as eN,$q as eO,vH as eP,Kj as eQ,ya as eR,h6 as eS,_l as eT,$v as eU,WC as eV,rr as eW,$f as eX,A6 as eY,e7 as eZ,qk as e_,NV as ea,Z7 as eb,LV as ec,FV as ed,du as ee,KV as ef,D7 as eg,pH as eh,jy as ei,AV as ej,HW as ek,z1 as el,Fs as em,i7 as en,Y7 as eo,rH as ep,Bq as eq,J7 as er,w6 as es,H7 as et,yH as eu,Fz as ev,E6 as ew,sE as ex,qq as ey,P7 as ez,Nn as f,_2 as f0,ZS as f1,XT as f2,bW as f3,Jy as f4,ZV as f5,Nt as f6,L6 as f7,Fi as f8,BA as f9,cn as g,Q7 as h,tA as i,uD as j,wD as k,_W as l,Kk as m,M6 as n,j6 as o,Cs as p,U7 as q,_0 as r,sH as s,L7 as t,m4 as u,X2 as v,FW as w,MO as x,IW as y,OW as z};
42
+ //# sourceMappingURL=main-Cv7E0c7r.js.map