@neuralnomads/codenomad-dev 0.20.0-dev-20260922-e68ac524 → 0.20.0-dev-20260922-0a31a8b3

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 (112) hide show
  1. package/dist/opencode/compatibility/location.js +11 -0
  2. package/dist/opencode/compatibility/location.js.map +1 -1
  3. package/dist/opencode/compatibility/location.test.js +21 -0
  4. package/dist/opencode/compatibility/location.test.js.map +1 -1
  5. package/dist/server/__tests__/instance-proxy.test.js +27 -0
  6. package/dist/server/__tests__/instance-proxy.test.js.map +1 -1
  7. package/dist/server/http-server.js +1 -0
  8. package/dist/server/http-server.js.map +1 -1
  9. package/dist/workspaces/__tests__/git-common-directory.test.js +11 -0
  10. package/dist/workspaces/__tests__/git-common-directory.test.js.map +1 -1
  11. package/dist/workspaces/git-process.js +16 -6
  12. package/dist/workspaces/git-process.js.map +1 -1
  13. package/dist/workspaces/git-status.js +32 -38
  14. package/dist/workspaces/git-status.js.map +1 -1
  15. package/dist/workspaces/git-status.test.js +28 -1
  16. package/dist/workspaces/git-status.test.js.map +1 -1
  17. package/package.json +1 -1
  18. package/public/assets/App-CkXPZUpS.js +51 -0
  19. package/public/assets/App-CkXPZUpS.js.map +1 -0
  20. package/public/assets/{FilesTab-CznSFRW_.js → FilesTab-C4o3_OHJ.js} +3 -3
  21. package/public/assets/{FilesTab-CznSFRW_.js.map → FilesTab-C4o3_OHJ.js.map} +1 -1
  22. package/public/assets/{GitChangesTab-DLtyzpX0.js → GitChangesTab-ClsL5QrZ.js} +3 -3
  23. package/public/assets/{GitChangesTab-DLtyzpX0.js.map → GitChangesTab-ClsL5QrZ.js.map} +1 -1
  24. package/public/assets/{SplitFilePanel-BHkyIER4.js → SplitFilePanel-C_dI-kjb.js} +2 -2
  25. package/public/assets/{SplitFilePanel-BHkyIER4.js.map → SplitFilePanel-C_dI-kjb.js.map} +1 -1
  26. package/public/assets/{StatusTab-BB3L4UEF.js → StatusTab-_gvxV-qq.js} +2 -2
  27. package/public/assets/{StatusTab-BB3L4UEF.js.map → StatusTab-_gvxV-qq.js.map} +1 -1
  28. package/public/assets/{align-justify-BGcr8Y3G.js → align-justify-CboH-c3n.js} +2 -2
  29. package/public/assets/{align-justify-BGcr8Y3G.js.map → align-justify-CboH-c3n.js.map} +1 -1
  30. package/public/assets/{bundle-full-CwHbX2Tz.js → bundle-full-CL2fEEcE.js} +2 -2
  31. package/public/assets/{bundle-full-CwHbX2Tz.js.map → bundle-full-CL2fEEcE.js.map} +1 -1
  32. package/public/assets/{client-state-CjVIIkWh.js → client-state-BB0go4Xe.js} +2 -2
  33. package/public/assets/{client-state-CjVIIkWh.js.map → client-state-BB0go4Xe.js.map} +1 -1
  34. package/public/assets/{diff-viewer-FNBCogHl.js → diff-viewer-C-B3vwne.js} +2 -2
  35. package/public/assets/{diff-viewer-FNBCogHl.js.map → diff-viewer-C-B3vwne.js.map} +1 -1
  36. package/public/assets/index-4LEntpq0.js +2 -0
  37. package/public/assets/index-4LEntpq0.js.map +1 -0
  38. package/public/assets/index-4mzZPz2j.css +1 -0
  39. package/public/assets/index-B2wje_CF.js +2 -0
  40. package/public/assets/index-B2wje_CF.js.map +1 -0
  41. package/public/assets/index-BDbkD8FO.js +2 -0
  42. package/public/assets/index-BDbkD8FO.js.map +1 -0
  43. package/public/assets/index-BbUJLdzG.js +2 -0
  44. package/public/assets/index-BbUJLdzG.js.map +1 -0
  45. package/public/assets/index-Bdh_-CtJ.js +2 -0
  46. package/public/assets/index-Bdh_-CtJ.js.map +1 -0
  47. package/public/assets/index-C9Jqb-tF.js +2 -0
  48. package/public/assets/index-C9Jqb-tF.js.map +1 -0
  49. package/public/assets/index-CIT8ANJK.js +3 -0
  50. package/public/assets/index-CIT8ANJK.js.map +1 -0
  51. package/public/assets/index-CheaKG9m.js +2 -0
  52. package/public/assets/{index-C2jBtFkI.js.map → index-CheaKG9m.js.map} +1 -1
  53. package/public/assets/index-DbnGqvtc.js +2 -0
  54. package/public/assets/index-DbnGqvtc.js.map +1 -0
  55. package/public/assets/index-DhOvQD1j.js +2 -0
  56. package/public/assets/index-DhOvQD1j.js.map +1 -0
  57. package/public/assets/{index-CLgpBTF6.js → index-DrTKEExa.js} +2 -2
  58. package/public/assets/{index-CLgpBTF6.js.map → index-DrTKEExa.js.map} +1 -1
  59. package/public/assets/index-Gk3Kwcb2.js +2 -0
  60. package/public/assets/index-Gk3Kwcb2.js.map +1 -0
  61. package/public/assets/{loading-D8BcUQaM.js → loading-Cs2CSqHx.js} +2 -2
  62. package/public/assets/{loading-D8BcUQaM.js.map → loading-Cs2CSqHx.js.map} +1 -1
  63. package/public/assets/main-DAwgVcRN.js +42 -0
  64. package/public/assets/main-DAwgVcRN.js.map +1 -0
  65. package/public/assets/{markdown-CRPEbAqL.js → markdown-DheZTu4V.js} +4 -4
  66. package/public/assets/{markdown-CRPEbAqL.js.map → markdown-DheZTu4V.js.map} +1 -1
  67. package/public/assets/monaco-viewer-BtzCmjFO.js +27 -0
  68. package/public/assets/monaco-viewer-BtzCmjFO.js.map +1 -0
  69. package/public/assets/{startup-state-settings-card-CHqS2Pmg.js → startup-state-settings-card-CmMXcnR-.js} +2 -2
  70. package/public/assets/{startup-state-settings-card-CHqS2Pmg.js.map → startup-state-settings-card-CmMXcnR-.js.map} +1 -1
  71. package/public/assets/{terminal-square-DhmNJqNG.js → terminal-square-ypyAq6Ni.js} +2 -2
  72. package/public/assets/{terminal-square-DhmNJqNG.js.map → terminal-square-ypyAq6Ni.js.map} +1 -1
  73. package/public/assets/{todo-DXJ5kP_Z.js → todo-Cgy3-kyM.js} +2 -2
  74. package/public/assets/{todo-DXJ5kP_Z.js.map → todo-Cgy3-kyM.js.map} +1 -1
  75. package/public/assets/{tool-call-Bjo9DalZ.js → tool-call-0UMa6igS.js} +17 -17
  76. package/public/assets/{tool-call-Bjo9DalZ.js.map → tool-call-0UMa6igS.js.map} +1 -1
  77. package/public/assets/{unified-picker-CxrTM_tY.js → unified-picker-C-lhbMQ0.js} +2 -2
  78. package/public/assets/{unified-picker-CxrTM_tY.js.map → unified-picker-C-lhbMQ0.js.map} +1 -1
  79. package/public/assets/{wrap-text-BznZeD4J.js → wrap-text-BjODGwnM.js} +2 -2
  80. package/public/assets/{wrap-text-BznZeD4J.js.map → wrap-text-BjODGwnM.js.map} +1 -1
  81. package/public/index.html +4 -4
  82. package/public/loading.html +4 -4
  83. package/public/sw.js +1 -1
  84. package/public/sw.js.map +1 -1
  85. package/public/assets/App-BSkmbNUC.js +0 -51
  86. package/public/assets/App-BSkmbNUC.js.map +0 -1
  87. package/public/assets/index-AeE49W2c.js +0 -2
  88. package/public/assets/index-AeE49W2c.js.map +0 -1
  89. package/public/assets/index-B875QQLi.js +0 -2
  90. package/public/assets/index-B875QQLi.js.map +0 -1
  91. package/public/assets/index-BhInW6hR.js +0 -3
  92. package/public/assets/index-BhInW6hR.js.map +0 -1
  93. package/public/assets/index-C2jBtFkI.js +0 -2
  94. package/public/assets/index-C8zCyB6Z.js +0 -2
  95. package/public/assets/index-C8zCyB6Z.js.map +0 -1
  96. package/public/assets/index-C9vJvaFa.js +0 -2
  97. package/public/assets/index-C9vJvaFa.js.map +0 -1
  98. package/public/assets/index-CLdQSSfU.js +0 -2
  99. package/public/assets/index-CLdQSSfU.js.map +0 -1
  100. package/public/assets/index-CaYFZAN4.js +0 -2
  101. package/public/assets/index-CaYFZAN4.js.map +0 -1
  102. package/public/assets/index-ChudAs0f.js +0 -2
  103. package/public/assets/index-ChudAs0f.js.map +0 -1
  104. package/public/assets/index-D292-iMl.js +0 -2
  105. package/public/assets/index-D292-iMl.js.map +0 -1
  106. package/public/assets/index-DYBqUC9X.css +0 -1
  107. package/public/assets/index-Dk3HFhZs.js +0 -2
  108. package/public/assets/index-Dk3HFhZs.js.map +0 -1
  109. package/public/assets/main-DRbjgAo8.js +0 -42
  110. package/public/assets/main-DRbjgAo8.js.map +0 -1
  111. package/public/assets/monaco-viewer-CG0aPZ-r.js +0 -27
  112. package/public/assets/monaco-viewer-CG0aPZ-r.js.map +0 -1
@@ -1,27 +0,0 @@
1
- var Ko=Object.defineProperty;var zo=(e,t,n)=>t in e?Ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var At=(e,t,n)=>zo(e,typeof t!="symbol"?t+"":t,n);import{c as F,a as me,b as Ar,d as G,r as Ho,e as M,o as ue,u as at,s as Vt,f as L,g as jn,$ as W,h as xe,i as Tt,j as ct,k as pe,l as qe,m as ft,n as Mn,p as vr,q as Go,t as Jo,v as qo,S as Yo}from"./git-diff-vendor-CT8HfOQw.js";import{g as Xo}from"./fast-diff-vendor-DgdwVvTQ.js";const Zo=["allowfullscreen","async","alpha","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected","adauctionheaders","browsingtopics","credentialless","defaultchecked","defaultmuted","defaultselected","defer","disablepictureinpicture","disableremoteplayback","preservespitch","shadowrootclonable","shadowrootcustomelementregistry","shadowrootdelegatesfocus","shadowrootserializable","sharedstoragewritable"],Qo=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline","adAuctionHeaders","allowFullscreen","browsingTopics","defaultChecked","defaultMuted","defaultSelected","disablePictureInPicture","disableRemotePlayback","preservesPitch","shadowRootClonable","shadowRootCustomElementRegistry","shadowRootDelegatesFocus","shadowRootSerializable","sharedStorageWritable",...Zo]),es=new Set(["innerHTML","textContent","innerText","children"]),ts=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ns=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1},adauctionheaders:{$:"adAuctionHeaders",IFRAME:1},allowfullscreen:{$:"allowFullscreen",IFRAME:1},browsingtopics:{$:"browsingTopics",IMG:1},defaultchecked:{$:"defaultChecked",INPUT:1},defaultmuted:{$:"defaultMuted",AUDIO:1,VIDEO:1},defaultselected:{$:"defaultSelected",OPTION:1},disablepictureinpicture:{$:"disablePictureInPicture",VIDEO:1},disableremoteplayback:{$:"disableRemotePlayback",AUDIO:1,VIDEO:1},preservespitch:{$:"preservesPitch",AUDIO:1,VIDEO:1},shadowrootclonable:{$:"shadowRootClonable",TEMPLATE:1},shadowrootdelegatesfocus:{$:"shadowRootDelegatesFocus",TEMPLATE:1},shadowrootserializable:{$:"shadowRootSerializable",TEMPLATE:1},sharedstoragewritable:{$:"sharedStorageWritable",IFRAME:1,IMG:1}});function rs(e,t){const n=ns[e];return typeof n=="object"?n[t]?n.$:void 0:n}const os=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),xr=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),ss={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},is=e=>F(()=>e());function as(e,t,n){let r=n.length,o=t.length,s=r,i=0,a=0,c=t[o-1].nextSibling,u=null;for(;i<o||a<s;){if(t[i]===n[a]){i++,a++;continue}for(;t[o-1]===n[s-1];)o--,s--;if(o===i){const l=s<r?a?n[a-1].nextSibling:n[s-a]:c;for(;a<s;)e.insertBefore(n[a++],l)}else if(s===a)for(;i<o;)(!u||!u.has(t[i]))&&t[i].remove(),i++;else if(t[i]===n[s-1]&&n[a]===t[o-1]){const l=t[--o].nextSibling;e.insertBefore(n[a++],t[i++].nextSibling),e.insertBefore(n[--s],l),t[o]=n[s]}else{if(!u){u=new Map;let d=a;for(;d<s;)u.set(n[d],d++)}const l=u.get(t[i]);if(l!=null)if(a<l&&l<s){let d=i,f=1,g;for(;++d<o&&d<s&&!((g=u.get(t[d]))==null||g!==l+f);)f++;if(f>l-a){const b=t[i];for(;a<l;)e.insertBefore(n[a++],b)}else e.replaceChild(n[a++],t[i++])}else i++;else t[i++].remove()}}}const Wn="_$DX_DELEGATE";function bu(e,t,n,r={}){let o;return Ar(s=>{o=s,t===document?e():kt(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{o(),t.textContent=""}}function Fn(e,t,n,r){let o;const s=()=>{const a=r?document.createElementNS("http://www.w3.org/1998/Math/MathML","template"):document.createElement("template");return a.innerHTML=e,n?a.content.firstChild.firstChild:r?a.firstChild:a.content.firstChild},i=t?()=>at(()=>document.importNode(o||(o=s()),!0)):()=>(o||(o=s())).cloneNode(!0);return i.cloneNode=i,i}function Er(e,t=window.document){const n=t[Wn]||(t[Wn]=new Set);for(let r=0,o=e.length;r<o;r++){const s=e[r];n.has(s)||(n.add(s),t.addEventListener(s,ps))}}function lt(e,t,n){Fe(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function cs(e,t,n,r){Fe(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function ls(e,t,n){Fe(e)||(n?e.setAttribute(t,""):e.removeAttribute(t))}function us(e,t){Fe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function ds(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const o=n[0];e.addEventListener(t,n[0]=s=>o.call(e,n[1],s))}else e.addEventListener(t,n,typeof n!="function"&&n)}function fs(e,t,n={}){const r=Object.keys(t||{}),o=Object.keys(n);let s,i;for(s=0,i=o.length;s<i;s++){const a=o[s];!a||a==="undefined"||t[a]||(Kn(e,a,!1),delete n[a])}for(s=0,i=r.length;s<i;s++){const a=r[s],c=!!t[a];!a||a==="undefined"||n[a]===c||!c||(Kn(e,a,!0),n[a]=c)}return n}function hs(e,t,n){if(!t)return n?lt(e,"style"):t;const r=e.style;if(typeof t=="string")return r.cssText=t;typeof n=="string"&&(r.cssText=n=void 0),n||(n={}),t||(t={});let o,s;for(s in n)t[s]==null&&r.removeProperty(s),delete n[s];for(s in t)o=t[s],o!==n[s]&&(r.setProperty(s,o),n[s]=o);return n}function Vn(e,t,n){n!=null?e.style.setProperty(t,n):e.style.removeProperty(t)}function Or(e,t={},n,r){const o={};return r||me(()=>o.children=ut(e,t.children,o.children)),me(()=>typeof t.ref=="function"&&Dn(t.ref,e)),me(()=>gs(e,t,n,!0,o,!0)),o}function Dn(e,t,n){return at(()=>e(t,n))}function kt(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!="function")return ut(e,t,r,n);me(o=>ut(e,t(),o,n),r)}function gs(e,t,n,r,o={},s=!1){t||(t={});for(const i in o)if(!(i in t)){if(i==="children")continue;o[i]=zn(e,i,null,o[i],n,s,t)}for(const i in t){if(i==="children")continue;const a=t[i];o[i]=zn(e,i,a,o[i],n,s,t)}}function Pr(e){let t,n;return!Fe()||!(t=L.registry.get(n=ys()))?e():(L.completed&&L.completed.add(t),L.registry.delete(n),t)}function Fe(e){return!!L.context&&!L.done&&(!e||e.isConnected)}function ms(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Kn(e,t,n){const r=t.trim().split(/\s+/);for(let o=0,s=r.length;o<s;o++)e.classList.toggle(r[o],n)}function zn(e,t,n,r,o,s,i){let a,c,u,l,d;if(t==="style")return hs(e,n,r);if(t==="classList")return fs(e,n,r);if(n===r)return r;if(t==="ref")s||n(e);else if(t.slice(0,3)==="on:"){const f=t.slice(3);r&&e.removeEventListener(f,r,typeof r!="function"&&r),n&&e.addEventListener(f,n,typeof n!="function"&&n)}else if(t.slice(0,10)==="oncapture:"){const f=t.slice(10);r&&e.removeEventListener(f,r,!0),n&&e.addEventListener(f,n,!0)}else if(t.slice(0,2)==="on"){const f=t.slice(2).toLowerCase(),g=os.has(f);if(!g&&r){const b=Array.isArray(r)?r[0]:r;e.removeEventListener(f,b)}(g||n)&&(ds(e,f,n,g),g&&Er([f]))}else if(t.slice(0,5)==="attr:")lt(e,t.slice(5),n);else if(t.slice(0,5)==="bool:")ls(e,t.slice(5),n);else if((d=t.slice(0,5)==="prop:")||(u=es.has(t))||!o&&((l=rs(t,e.tagName))||(c=Qo.has(t)))||(a=e.nodeName.includes("-")||"is"in i)){if(d)t=t.slice(5),c=!0;else if(Fe(e))return n;t==="class"||t==="className"?us(e,n):a&&!c&&!u?e[ms(t)]=n:e[l||t]=n}else{const f=o&&t.indexOf(":")>-1&&ss[t.split(":")[0]];f?cs(e,f,t,n):lt(e,ts[t]||t,n)}return n}function ps(e){if(L.registry&&L.events&&L.events.find(([c,u])=>u===e))return;let t=e.target;const n=`$$${e.type}`,r=e.target,o=e.currentTarget,s=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[n];if(c&&!t.disabled){const u=t[`${n}Data`];if(u!==void 0?c.call(t,u,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&s(t.host),!0},a=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),L.registry&&!L.done&&(L.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();s(c[0]);for(let u=0;u<c.length-2&&(t=c[u],!!i());u++){if(t._$host){t=t._$host,a();break}if(t.parentNode===o)break}}else a();s(r)}function ut(e,t,n,r,o){const s=Fe(e);if(s){!n&&(n=[...e.childNodes]);let c=[];for(let u=0;u<n.length;u++){const l=n[u];l.nodeType===8&&l.data.slice(0,2)==="!$"?l.remove():c.push(l)}n=c}for(;typeof n=="function";)n=n();if(t===n)return n;const i=typeof t,a=r!==void 0;if(e=a&&n[0]&&n[0].parentNode||e,i==="string"||i==="number"){if(s||i==="number"&&(t=t.toString(),t===n))return n;if(a){let c=n[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),n=ke(e,n,r,c)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||i==="boolean"){if(s)return n;n=ke(e,n,r)}else{if(i==="function")return me(()=>{let c=t();for(;typeof c=="function";)c=c();n=ut(e,c,n,r)}),()=>n;if(Array.isArray(t)){const c=[],u=n&&Array.isArray(n);if(fn(c,t,n,o))return me(()=>n=ut(e,c,n,r,!0)),()=>n;if(s){if(!c.length)return n;if(r===void 0)return n=[...e.childNodes];let l=c[0];if(l.parentNode!==e)return n;const d=[l];for(;(l=l.nextSibling)!==r;)d.push(l);return n=d}if(c.length===0){if(n=ke(e,n,r),a)return n}else u?n.length===0?Hn(e,c,r):as(e,n,c):(n&&ke(e),Hn(e,c));n=c}else if(t.nodeType){if(s&&t.parentNode)return n=a?[t]:t;if(Array.isArray(n)){if(a)return n=ke(e,n,r,t);ke(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function fn(e,t,n,r){let o=!1;for(let s=0,i=t.length;s<i;s++){let a=t[s],c=n&&n[e.length],u;if(!(a==null||a===!0||a===!1))if((u=typeof a)=="object"&&a.nodeType)e.push(a);else if(Array.isArray(a))o=fn(e,a,c)||o;else if(u==="function")if(r){for(;typeof a=="function";)a=a();o=fn(e,Array.isArray(a)?a:[a],Array.isArray(c)?c:[c])||o}else e.push(a),o=!0;else{const l=String(a);c&&c.nodeType===3&&c.data===l?e.push(c):e.push(document.createTextNode(l))}}return o}function Hn(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function ke(e,t,n,r){if(n===void 0)return e.textContent="";const o=r||document.createTextNode("");if(t.length){let s=!1;for(let i=t.length-1;i>=0;i--){const a=t[i];if(o!==a){const c=a.parentNode===e;!s&&!i?c?e.replaceChild(o,a):e.insertBefore(o,n):c&&a.remove()}else s=!0}}else e.insertBefore(o,n);return[o]}function ys(){return L.getNextContextId()}const bs="http://www.w3.org/2000/svg";function Mr(e,t=!1,n=void 0){return t?document.createElementNS(bs,e):document.createElement(e,{is:n})}function Cu(e){const{useShadow:t}=e,n=document.createTextNode(""),r=()=>e.mount||document.body,o=jn();let s,i=!!L.context;return G(()=>{i&&(jn().user=i=!1),s||(s=Ho(o,()=>F(()=>e.children)));const a=r();if(a instanceof HTMLHeadElement){const[c,u]=M(!1),l=()=>u(!0);Ar(d=>kt(a,()=>c()?d():s(),null)),ue(l)}else{const c=Mr(e.isSVG?"g":"div",e.isSVG),u=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),kt(u,s),a.appendChild(c),e.ref&&e.ref(c),ue(()=>a.removeChild(c))}},void 0,{render:!i}),n}function Cs(e,t){const n=F(e);return F(()=>{const r=n();switch(typeof r){case"function":return at(()=>r(t));case"string":const o=xr.has(r),s=L.context?Pr():Mr(r,o,at(()=>t.is));return Or(s,t,o),s}})}function Su(e){const[,t]=Vt(e,["component"]);return Cs(()=>e.component,t)}const Ke=Symbol("store-raw"),ce=Symbol("store-node"),Y=Symbol("store-has"),Fr=Symbol("store-self");function Dr(e){let t=e[W];if(!t&&(Object.defineProperty(e,W,{value:t=new Proxy(e,ws)}),!Array.isArray(e))){const n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e);for(let o=0,s=n.length;o<s;o++){const i=n[o];r[i].get&&Object.defineProperty(e,i,{enumerable:r[i].enumerable,get:r[i].get.bind(t)})}}return t}function ne(e){let t;return e!=null&&typeof e=="object"&&(e[W]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function de(e,t=new Set){let n,r,o,s;if(n=e!=null&&e[Ke])return n;if(!ne(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let i=0,a=e.length;i<a;i++)o=e[i],(r=de(o,t))!==o&&(e[i]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const i=Object.keys(e),a=Object.getOwnPropertyDescriptors(e);for(let c=0,u=i.length;c<u;c++)s=i[c],!a[s].get&&(o=e[s],(r=de(o,t))!==o&&(e[s]=r))}return e}function ze(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Ee(e,t,n){if(e[t])return e[t];const[r,o]=M(n,{equals:!1,internal:!0});return r.$=o,e[t]=r}function Ss(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===W||t===ce||(delete n.value,delete n.writable,n.get=()=>e[W][t]),n}function Tn(e){ct()&&Ee(ze(e,ce),Fr)()}function Tr(e){return Tn(e),Reflect.ownKeys(e)}const ws={get(e,t,n){if(t===Ke)return e;if(t===W)return n;if(t===Tt)return Tn(e),n;const r=ze(e,ce),o=r[t];let s=o?o():e[t];if(t===ce||t===Y||t==="__proto__")return s;if(!o){const i=Object.getOwnPropertyDescriptor(e,t);ct()&&(typeof s!="function"||e.hasOwnProperty(t))&&!(i&&i.get)&&(s=Ee(r,t,s)())}return ne(s)?Dr(s):s},has(e,t){return t===Ke||t===W||t===Tt||t===ce||t===Y||t==="__proto__"?!0:(ct()&&Ee(ze(e,Y),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Tr,getOwnPropertyDescriptor:Ss};function N(e,t,n,r=!1){if(!r&&e[t]===n)return;const o=e[t],s=e.length;n===void 0?(delete e[t],e[Y]&&e[Y][t]&&o!==void 0&&e[Y][t].$()):(e[t]=n,e[Y]&&e[Y][t]&&o===void 0&&e[Y][t].$());let i=ze(e,ce),a;if((a=Ee(i,t,o))&&a.$(()=>n),Array.isArray(e)&&e.length!==s){for(let c=e.length;c<s;c++)(a=i[c])&&a.$();(a=Ee(i,"length",s))&&a.$(e.length)}(a=i[Fr])&&a.$()}function kr(e,t){const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const o=n[r];N(e,o,t[o])}}function As(e,t){if(typeof t=="function"&&(t=t(e)),t=de(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){const o=t[n];e[n]!==o&&N(e,n,o)}N(e,"length",r)}else kr(e,t)}function nt(e,t,n=[]){let r,o=e;if(t.length>1){r=t.shift();const i=typeof r,a=Array.isArray(e);if(Array.isArray(r)){for(let c=0;c<r.length;c++)nt(e,[r[c]].concat(t),n);return}else if(a&&i==="function"){for(let c=0;c<e.length;c++)r(e[c],c)&&nt(e,[c].concat(t),n);return}else if(a&&i==="object"){const{from:c=0,to:u=e.length-1,by:l=1}=r;for(let d=c;d<=u;d+=l)nt(e,[d].concat(t),n);return}else if(t.length>1){nt(e[r],t,[r].concat(n));return}o=e[r],n=[r].concat(n)}let s=t[0];typeof s=="function"&&(s=s(o,n),s===o)||r===void 0&&s==null||(s=de(s),r===void 0||ne(o)&&ne(s)&&!Array.isArray(s)?kr(o,s):N(e,r,s))}function wu(...[e,t]){const n=de(e||{}),r=Array.isArray(n),o=Dr(n);function s(...i){xe(()=>{r&&i.length===1?As(n,i[0]):nt(n,i)})}return[o,s]}function vs(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===W||t===ce||(delete n.value,delete n.writable,n.get=()=>e[W][t],n.set=r=>e[W][t]=r),n}const xs={get(e,t,n){if(t===Ke)return e;if(t===W)return n;if(t===Tt)return Tn(e),n;const r=ze(e,ce),o=r[t];let s=o?o():e[t];if(t===ce||t===Y||t==="__proto__")return s;if(!o){const i=Object.getOwnPropertyDescriptor(e,t),a=typeof s=="function";if(ct()&&(!a||e.hasOwnProperty(t))&&!(i&&i.get))s=Ee(r,t,s)();else if(s!=null&&a&&s===Array.prototype[t])return(...c)=>xe(()=>Array.prototype[t].apply(n,c))}return ne(s)?$r(s):s},has(e,t){return t===Ke||t===W||t===Tt||t===ce||t===Y||t==="__proto__"?!0:(ct()&&Ee(ze(e,Y),t)(),t in e)},set(e,t,n){return xe(()=>N(e,t,de(n))),!0},deleteProperty(e,t){return xe(()=>N(e,t,void 0,!0)),!0},ownKeys:Tr,getOwnPropertyDescriptor:vs};function $r(e){let t=e[W];if(!t){Object.defineProperty(e,W,{value:t=new Proxy(e,xs)});const n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),o=Object.getPrototypeOf(e),s=o!==null&&e!==null&&typeof e=="object"&&!Array.isArray(e)&&o!==Object.prototype;if(s){let i=o;for(;i!=null;){const a=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(a)),Object.assign(r,a),i=Object.getPrototypeOf(i)}}for(let i=0,a=n.length;i<a;i++){const c=n[i];if(!(s&&c==="constructor")){if(r[c].get){const u=r[c].get.bind(t);Object.defineProperty(e,c,{get:u,configurable:!0})}if(r[c].set){const u=r[c].set;Object.defineProperty(e,c,{set:d=>xe(()=>u.call(t,d)),configurable:!0})}}}}return t}function Es(e,t){const n=de(e||{});return $r(n)}const hn=Symbol("store-root");function Le(e,t,n,r,o){const s=t[n];if(e===s)return;const i=Array.isArray(e);if(n!==hn&&(!ne(e)||!ne(s)||i!==Array.isArray(s)||o&&e[o]!==s[o])){N(t,n,e);return}if(i){if(e.length&&s.length&&(!r||o&&e[0]&&e[0][o]!=null)){let u,l,d,f,g,b,S,w;for(d=0,f=Math.min(s.length,e.length);d<f&&(s[d]===e[d]||o&&s[d]&&e[d]&&s[d][o]&&s[d][o]===e[d][o]);d++)Le(e[d],s,d,r,o);const y=new Array(e.length),$=new Map;for(f=s.length-1,g=e.length-1;f>=d&&g>=d&&(s[f]===e[g]||o&&s[f]&&e[g]&&s[f][o]&&s[f][o]===e[g][o]);f--,g--)y[g]=s[f];if(d>g||d>f){for(l=d;l<=g;l++)N(s,l,e[l]);for(;l<e.length;l++)N(s,l,y[l]),Le(e[l],s,l,r,o);s.length>e.length&&N(s,"length",e.length);return}for(S=new Array(g+1),l=g;l>=d;l--)b=e[l],w=o&&b?b[o]:b,u=$.get(w),S[l]=u===void 0?-1:u,$.set(w,l);for(u=d;u<=f;u++)b=s[u],w=o&&b?b[o]:b,l=$.get(w),l!==void 0&&l!==-1&&(y[l]=s[u],l=S[l],$.set(w,l));for(l=d;l<e.length;l++)l in y?(N(s,l,y[l]),Le(e[l],s,l,r,o)):N(s,l,e[l])}else for(let u=0,l=e.length;u<l;u++)Le(e[u],s,u,r,o);s.length>e.length&&N(s,"length",e.length);return}const a=Object.keys(e);for(let u=0,l=a.length;u<l;u++)Le(e[a[u]],s,a[u],r,o);const c=Object.keys(s);for(let u=0,l=c.length;u<l;u++)e[c[u]]===void 0&&N(s,c[u],void 0)}function Au(e,t={}){const{merge:n,key:r="id"}=t,o=de(e);return s=>{if(!ne(s)||!ne(o))return o;const i=Le(o,{[hn]:s},hn,n,r);return i===void 0?s:i}}const $t=new WeakMap,Ir={get(e,t){if(t===Ke)return e;const n=e[t];let r;return ne(n)?$t.get(n)||($t.set(n,r=new Proxy(n,Ir)),r):n},set(e,t,n){return N(e,t,de(n)),!0},deleteProperty(e,t){return N(e,t,void 0,!0),!0}};function vu(e){return t=>{if(ne(t)){let n;(n=$t.get(t))||$t.set(t,n=new Proxy(t,Ir)),e(n)}return t}}const Os="codenomad.client-id",Ps="codenomad.connection-id";let vt=null,xt=null;function Br(){return{clientId:Ms(),connectionId:Fs()}}function Ms(){return vt||(vt=Lr(Os,window.localStorage),vt)}function Fs(){var t;const e=(t=window.__CODENOMAD_WINDOW_ID__)==null?void 0:t.trim();return e||xt||(xt=Lr(Ps,window.sessionStorage),xt)}function Lr(e,t){if(typeof window>"u")return Qt();try{const r=t.getItem(e);if(r&&r.trim())return r.trim()}catch{return Qt()}const n=Qt();try{t.setItem(e,n)}catch{}return n}function Qt(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var gn={exports:{}},en,Gn;function Ds(){if(Gn)return en;Gn=1;var e=1e3,t=e*60,n=t*60,r=n*24,o=r*7,s=r*365.25;en=function(l,d){d=d||{};var f=typeof l;if(f==="string"&&l.length>0)return i(l);if(f==="number"&&isFinite(l))return d.long?c(l):a(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function i(l){if(l=String(l),!(l.length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(d){var f=parseFloat(d[1]),g=(d[2]||"ms").toLowerCase();switch(g){case"years":case"year":case"yrs":case"yr":case"y":return f*s;case"weeks":case"week":case"w":return f*o;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*n;case"minutes":case"minute":case"mins":case"min":case"m":return f*t;case"seconds":case"second":case"secs":case"sec":case"s":return f*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function a(l){var d=Math.abs(l);return d>=r?Math.round(l/r)+"d":d>=n?Math.round(l/n)+"h":d>=t?Math.round(l/t)+"m":d>=e?Math.round(l/e)+"s":l+"ms"}function c(l){var d=Math.abs(l);return d>=r?u(l,d,r,"day"):d>=n?u(l,d,n,"hour"):d>=t?u(l,d,t,"minute"):d>=e?u(l,d,e,"second"):l+" ms"}function u(l,d,f,g){var b=d>=f*1.5;return Math.round(l/f)+" "+g+(b?"s":"")}return en}function Ts(e){n.debug=n,n.default=n,n.coerce=c,n.disable=i,n.enable=o,n.enabled=a,n.humanize=Ds(),n.destroy=u,Object.keys(e).forEach(l=>{n[l]=e[l]}),n.names=[],n.skips=[],n.formatters={};function t(l){let d=0;for(let f=0;f<l.length;f++)d=(d<<5)-d+l.charCodeAt(f),d|=0;return n.colors[Math.abs(d)%n.colors.length]}n.selectColor=t;function n(l){let d,f=null,g,b;function S(...w){if(!S.enabled)return;const y=S,$=Number(new Date),R=$-(d||$);y.diff=R,y.prev=d,y.curr=$,d=$,w[0]=n.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let Z=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(K,m)=>{if(K==="%%")return"%";Z++;const C=n.formatters[m];if(typeof C=="function"){const O=w[Z];K=C.call(y,O),w.splice(Z,1),Z--}return K}),n.formatArgs.call(y,w),(y.log||n.log).apply(y,w)}return S.namespace=l,S.useColors=n.useColors(),S.color=n.selectColor(l),S.extend=r,S.destroy=n.destroy,Object.defineProperty(S,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(g!==n.namespaces&&(g=n.namespaces,b=n.enabled(l)),b),set:w=>{f=w}}),typeof n.init=="function"&&n.init(S),S}function r(l,d){const f=n(this.namespace+(typeof d>"u"?":":d)+l);return f.log=this.log,f}function o(l){n.save(l),n.namespaces=l,n.names=[],n.skips=[];const d=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const f of d)f[0]==="-"?n.skips.push(f.slice(1)):n.names.push(f)}function s(l,d){let f=0,g=0,b=-1,S=0;for(;f<l.length;)if(g<d.length&&(d[g]===l[f]||d[g]==="*"))d[g]==="*"?(b=g,S=f,g++):(f++,g++);else if(b!==-1)g=b+1,S++,f=S;else return!1;for(;g<d.length&&d[g]==="*";)g++;return g===d.length}function i(){const l=[...n.names,...n.skips.map(d=>"-"+d)].join(",");return n.enable(""),l}function a(l){for(const d of n.skips)if(s(l,d))return!1;for(const d of n.names)if(s(l,d))return!0;return!1}function c(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var ks=Ts;(function(e,t){var n={};t.formatArgs=o,t.save=s,t.load=i,t.useColors=r,t.storage=a(),t.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;u.splice(1,0,l,"color: inherit");let d=0,f=0;u[0].replace(/%[a-zA-Z%]/g,g=>{g!=="%%"&&(d++,g==="%c"&&(f=d))}),u.splice(f,0,l)}t.log=console.debug||console.log||(()=>{});function s(u){try{u?t.storage.setItem("debug",u):t.storage.removeItem("debug")}catch{}}function i(){let u;try{u=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!u&&typeof process<"u"&&"env"in process&&(u=n.DEBUG),u}function a(){try{return localStorage}catch{}}e.exports=ks(t);const{formatters:c}=e.exports;c.j=function(u){try{return JSON.stringify(u)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}})(gn,gn.exports);var $s=gn.exports;const mn=Xo($s),Ye=["sse","api","session","actions","foreground-refresh"],Rr="opencode:logger:namespaces",tn=new Map,re=new Set,ae=typeof globalThis<"u"?globalThis.console:void 0;function ht(){re.size===0?mn.disable():mn.enable(Array.from(re).join(","))}function Kt(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{window.localStorage.setItem(Rr,JSON.stringify(Array.from(re)))}catch(t){(e=ae==null?void 0:ae.warn)==null||e.call(ae,"Failed to persist logger namespaces",t)}}function Is(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{const t=window.localStorage.getItem(Rr);if(!t)return;const n=JSON.parse(t);if(!Array.isArray(n))return;for(const r of n)Ye.includes(r)&&re.add(r)}catch(t){(e=ae==null?void 0:ae.warn)==null||e.call(ae,"Failed to hydrate logger namespaces",t)}}Is();ht();function Bs(e){const n=mn(e),r=(o,s)=>{n(o,...s)};return{log:(...o)=>n(...o),info:(...o)=>n(...o),warn:(...o)=>r("[warn]",o),error:(...o)=>r("[error]",o)}}function De(e){if(!Ye.includes(e))throw new Error(`Unknown logger namespace: ${e}`);return tn.has(e)||tn.set(e,Bs(e)),tn.get(e)}function Ls(){return Ye.map(e=>({name:e,enabled:re.has(e)}))}function Rs(e){if(!Ye.includes(e))throw new Error(`Unknown logger namespace: ${e}`);re.has(e)||(re.add(e),Kt(),ht())}function Ns(e){if(!Ye.includes(e))throw new Error(`Unknown logger namespace: ${e}`);re.has(e)&&(re.delete(e),Kt(),ht())}function Us(){re.clear(),Kt(),ht()}function _s(){Ye.forEach(e=>re.add(e)),Kt(),ht()}const js={listLoggerNamespaces:Ls,enableLogger:Rs,disableLogger:Ns,enableAllLoggers:_s,disableAllLoggers:Us};function Ws(){typeof window>"u"||(window.codenomadLogger=js)}Ws();function Vs(e,t){let n=!1;e.onmessage=o=>{try{const s=JSON.parse(o.data);t.onEvent(s)}catch(s){t.logger.error("Failed to parse event",s)}};const r=o=>{var s;n||(n=!0,t.logger.warn(o),(s=t.onError)==null||s.call(t))};e.onerror=()=>{r("EventSource error, closing stream")},e.onclose=()=>{r("EventSource closed")},e.addEventListener("close",()=>{r("EventSource closed")}),e.addEventListener("codenomad.client.ping",o=>{var s;try{const i=o.data?JSON.parse(o.data):{};(s=t.onPing)==null||s.call(t,i)}catch(i){t.logger.error("Failed to parse ping event",i)}})}class Nr extends Error{constructor(t,n,r){super(t),this.status=n,this.retryAfter=r}}async function Ks(e,t){for(;;){t.throwIfAborted();try{return await e()}catch(n){if(!(n instanceof Nr)||n.status!==503||!n.retryAfter)throw n;const r=Number(n.retryAfter);if(!Number.isFinite(r)||r<0)throw n;const o=Math.min(3e4,Math.max(1e3,r*1e3));await new Promise((s,i)=>{t.throwIfAborted();const c=setTimeout(()=>{t.removeEventListener("abort",u),s()},o),u=()=>{clearTimeout(c),t.removeEventListener("abort",u),i(t.reason)};t.addEventListener("abort",u,{once:!0})})}}}const nn={};var wr;const zs=typeof window<"u"?(wr=window.location)==null?void 0:wr.origin:void 0,Hs=typeof window<"u"?window.__CODENOMAD_API_BASE__??zs:void 0,Gs=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",He=(nn==null?void 0:nn.VITE_CODENOMAD_API_BASE)??Hs,rn=Js(He,Gs),xu=He;function Js(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(e){const n=t.startsWith("/")?t:`/${t}`;return`${e}${n}`}return t}const Jn=De("api"),qn=De("sse");function Ur(e){const t={};if(!e)return t;if(e instanceof Headers)return e.forEach((n,r)=>{t[r]=n}),t;if(Array.isArray(e)){for(const[n,r]of e)t[n]=r;return t}return{...e}}function ve(e,t){if(t){Jn.info(e,t);return}Jn.info(e)}async function _r(e){const t=await e.text();if(!t)return`Request failed with ${e.status}`;try{const n=JSON.parse(t);if(typeof(n==null?void 0:n.error)=="string"&&n.error.trim())return n.error;if(typeof(n==null?void 0:n.message)=="string"&&n.message.trim())return n.message}catch{}return t}async function p(e,t){const n=He?new URL(e,He).toString():e,r=Ur(t==null?void 0:t.headers);(t==null?void 0:t.body)!==void 0&&(r["Content-Type"]="application/json");const o=((t==null?void 0:t.method)??"GET").toUpperCase(),s=Date.now();ve(`${o} ${e}`);try{const i=await fetch(n,{...t,headers:r,credentials:(t==null?void 0:t.credentials)??"include"});if(!i.ok){const c=await _r(i);throw ve(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s,error:c}),new Nr(c||`Request failed with ${i.status}`,i.status,i.headers.get("Retry-After"))}const a=Date.now()-s;return ve(`${o} ${e} -> ${i.status}`,{durationMs:a}),i.status===204?void 0:await i.json()}catch(i){throw ve(`${o} ${e} failed`,{durationMs:Date.now()-s,error:i}),i}}async function qs(e,t){const n=He?new URL(e,He).toString():e,r=Ur(t==null?void 0:t.headers);(t==null?void 0:t.body)!==void 0&&!r["Content-Type"]&&(r["Content-Type"]="application/json");const o=((t==null?void 0:t.method)??"GET").toUpperCase(),s=Date.now();ve(`${o} ${e}`);const i=await fetch(n,{...t,headers:r,credentials:(t==null?void 0:t.credentials)??"include"});if(!i.ok){const a=await _r(i);throw ve(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s,error:a}),new Error(a||`Request failed with ${i.status}`)}return ve(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s}),i}const ie={fetchHistoryWindow(e,t,n,r){return p(`/api/workspaces/${encodeURIComponent(e)}/session-history/window`,{method:"POST",body:JSON.stringify({sessionID:t,target:n}),signal:r})},fetchSessionOutline(e,t,n,r,o,s){return p(`/api/workspaces/${encodeURIComponent(e)}/session-history/outline`,{method:"POST",body:JSON.stringify({sessionID:t,cursor:n,after:o,known:s}),signal:r})},fetchOutlinePreviews(e,t,n,r){return p(`/api/workspaces/${encodeURIComponent(e)}/session-history/outlinePreview`,{method:"POST",body:JSON.stringify({sessionID:t,messageIDs:n}),signal:r})},querySessionHistory(e,t,n){return p(`/api/workspaces/${encodeURIComponent(e)}/session-history/query`,{method:"POST",body:JSON.stringify(t),signal:n})},pruneSessionHistory(e,t,n){return p(`/api/workspaces/${encodeURIComponent(e)}/session-history/prune`,{method:"POST",body:JSON.stringify(t),signal:n})},pruneSessionMessage(e,t){return p(`/api/workspaces/${encodeURIComponent(e)}/session-pruning/prune`,{method:"POST",body:JSON.stringify(t)})},fetchWorkspaces(){return p("/api/workspaces")},fetchProviderUsage(e,t){const n=new URLSearchParams;t&&n.set("modelId",t);const r=n.toString();return p(`/api/usage/${encodeURIComponent(e)}${r?`?${r}`:""}`)},fetchWorktrees(e){return p(`/api/workspaces/${encodeURIComponent(e)}/worktrees`)},createWorktree(e,t){return p(`/api/workspaces/${encodeURIComponent(e)}/worktrees`,{method:"POST",body:JSON.stringify(t)})},deleteWorktree(e,t,n){const r=new URLSearchParams;n!=null&&n.force&&r.set("force","true");const o=r.toString()?`?${r.toString()}`:"";return p(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}${o}`,{method:"DELETE"})},moveSessionFamily(e,t,n){return p(`/api/workspaces/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/worktree`,{method:"POST",body:JSON.stringify(n)})},createWorkspace(e,t){return p("/api/workspaces",{method:"POST",body:JSON.stringify(e),signal:t==null?void 0:t.signal})},cancelWorkspaceCreation(e){return p("/api/workspaces/creation/cancel",{method:"POST",body:JSON.stringify({requestId:e})})},releaseWorkspaceCreation(e,t){return p(`/api/workspaces/${encodeURIComponent(e)}/creation/release`,{method:"POST",body:JSON.stringify({requestId:t})})},fetchSidecars(){return p("/api/sidecars")},createSidecar(e){return p("/api/sidecars",{method:"POST",body:JSON.stringify(e)})},updateSidecar(e,t){return p(`/api/sidecars/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteSidecar(e){return p(`/api/sidecars/${encodeURIComponent(e)}`,{method:"DELETE"})},createPreview(e){return p("/api/previews",{method:"POST",body:JSON.stringify(e)})},deletePreview(e){return p(`/api/previews/${encodeURIComponent(e)}`,{method:"DELETE"})},fetchServerMeta(){return p("/api/meta")},probeRemoteServer(e){return p("/api/remote-servers/probe",{method:"POST",body:JSON.stringify(e)})},createRemoteProxySession(e){return p("/api/remote-proxy/sessions",{method:"POST",body:JSON.stringify(e)})},deleteRemoteProxySession(e){return p(`/api/remote-proxy/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})},fetchAuthStatus(){return p("/api/auth/status")},listConfigFiles(){return p("/api/config-files")},readConfigFile(e){return p(`/api/config-files/${encodeURIComponent(e)}/content`)},writeConfigFile(e,t){const n={contents:t};return p(`/api/config-files/${encodeURIComponent(e)}/content`,{method:"PUT",body:JSON.stringify(n)})},setServerPassword(e){return p("/api/auth/password",{method:"POST",body:JSON.stringify({password:e})})},deleteWorkspace(e){return p(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},cloneWorkspaceRepository(e){return p("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return p(`/api/workspaces/${encodeURIComponent(e)}/files?${n.toString()}`)},searchWorkspaceFiles(e,t,n){const r=t.trim();if(!r)return Promise.resolve([]);const o=new URLSearchParams({q:r});n!=null&&n.limit&&o.set("limit",String(n.limit)),n!=null&&n.type&&o.set("type",n.type);const s=()=>p(`/api/workspaces/${encodeURIComponent(e)}/files/search?${o.toString()}`,{signal:n==null?void 0:n.signal});return n!=null&&n.signal?Ks(s,n.signal):s()},readWorkspaceFile(e,t,n){const r=new URLSearchParams({path:t});return n!=null&&n.encoding&&r.set("encoding",n.encoding),p(`/api/workspaces/${encodeURIComponent(e)}/files/content?${r.toString()}`)},writeWorkspaceFile(e,t,n,r){const o=new URLSearchParams({path:t});return r!=null&&r.worktree&&r.worktree!=="root"&&o.set("worktree",r.worktree),p(`/api/workspaces/${encodeURIComponent(e)}/files/content?${o.toString()}`,{method:"PUT",body:JSON.stringify({contents:n})})},fetchWorktreeGitStatus(e,t){return p(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-status`)},fetchWorktreeGitDiff(e,t,n){const r=new URLSearchParams({path:n.path,scope:n.scope});return n.originalPath&&r.set("originalPath",n.originalPath),p(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-diff?${r.toString()}`)},stageWorktreeGitPaths(e,t,n){return p(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-stage`,{method:"POST",body:JSON.stringify(n)})},unstageWorktreeGitPaths(e,t,n){return p(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-unstage`,{method:"POST",body:JSON.stringify(n)})},commitWorktreeGitChanges(e,t,n){return p(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-commit`,{method:"POST",body:JSON.stringify(n)})},fetchConfigOwner(e){return p(`/api/storage/config/${encodeURIComponent(e)}`)},patchConfigOwner(e,t){return p(`/api/storage/config/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t??{})})},fetchStateOwner(e){return p(`/api/storage/state/${encodeURIComponent(e)}`)},patchStateOwner(e,t){return p(`/api/storage/state/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t??{})})},validateBinary(e){return p("/api/storage/binaries/validate",{method:"POST",body:JSON.stringify({path:e})})},fetchOpenCodeUpdateStatus(){return p("/api/opencode/update")},updateOpenCode(){return p("/api/opencode/update",{method:"POST"})},startOpenCode(e=!1){return p("/api/opencode/service",{method:"POST",body:JSON.stringify({restart:e})})},reloadOpenCodeConfiguration(){return p("/api/opencode/service",{method:"POST",body:JSON.stringify({reload:!0})})},fetchSpeechCapabilities(){return p("/api/speech/capabilities")},transcribeAudio(e){return p("/api/speech/transcribe",{method:"POST",body:JSON.stringify(e)})},synthesizeSpeech(e){return p("/api/speech/synthesize",{method:"POST",body:JSON.stringify(e)})},synthesizeSpeechStream(e,t){return qs("/api/speech/synthesize/stream",{method:"POST",body:JSON.stringify(e),signal:t})},listFileSystem(e,t){const n=new URLSearchParams;e&&e!=="."&&n.set("path",e),(t==null?void 0:t.includeFiles)!==void 0&&n.set("includeFiles",String(t.includeFiles));const r=n.toString();return p(r?`/api/filesystem?${r}`:"/api/filesystem")},createFileSystemFolder(e,t){return p("/api/filesystem/folders",{method:"POST",body:JSON.stringify({parentPath:e,name:t})})},readFileSystemFile(e,t){const n=new URLSearchParams({path:e});return t!=null&&t.encoding&&n.set("encoding",t.encoding),p(`/api/filesystem/files/content?${n.toString()}`)},readInstanceData(e){return p(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return p(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return p(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},getYoloState(e,t){return p(`/workspaces/${encodeURIComponent(e)}/yolo/sessions/${encodeURIComponent(t)}`)},toggleYolo(e,t){return p(`/workspaces/${encodeURIComponent(e)}/yolo/sessions/${encodeURIComponent(t)}/toggle`,{method:"POST"})},sendClientConnectionPong(e,t){const n={method:"POST",body:JSON.stringify(e)};return t&&(n.signal=t),p("/api/client-connections/pong",n)},connectEvents(e,t,n){const r=Br(),o=Ys(r);qn.info(`Connecting to ${o}`);const s=new EventSource(o,{withCredentials:!0});return Vs(s,{onEvent:e,onError:t,onPing:n,logger:qn}),s}};function Ys(e){const t=new URL(rn,typeof window<"u"?window.location.origin:"http://localhost");return t.searchParams.set("clientId",e.clientId),t.searchParams.set("connectionId",e.connectionId),rn.startsWith("http://")||rn.startsWith("https://")?t.toString():`${t.pathname}${t.search}`}async function Xs(e){const t=()=>{var r,o;(r=e.onStatus)==null||r.call(e,"disconnected"),(o=e.onError)==null||o.call(e)},n=ie.connectEvents(r=>{e.onBatch([r])},t,e.onPing);return n.onopen=()=>{var r,o;(r=e.onStatus)==null||r.call(e,"connected"),(o=e.onOpen)==null||o.call(e)},{disconnect(){n.close()}}}async function Zs(e,t={}){const{maxAttempts:n=3,initialDelayMs:r=100,maxDelayMs:o=5e3,backoffMultiplier:s=2,timeoutMs:i,shouldRetry:a=()=>!0,wait:c=d=>new Promise(f=>setTimeout(f,d))}=t;let u=null,l=r;for(let d=1;d<=n;d++)try{if(i){const f=new AbortController,g=setTimeout(()=>f.abort(),i);try{const b=await e(f.signal);return clearTimeout(g),b}catch(b){throw clearTimeout(g),b}}return await e()}catch(f){const g=f instanceof Error?f:new Error(String(f));if(u=g,d<n&&a(g,d))await c(l),l=Math.min(l*s,o);else throw g}throw u||new Error("Failed after retries")}function Qs(e){return!!(e.name==="AbortError"||e.name==="TimeoutError"||e.message.includes("Failed to fetch")||e.message.includes("NetworkError")||e.message.includes("timeout"))}const on=1e3,ei=1e4,pn=De("sse");function $e(e,t){if(t){pn.info(e,t);return}pn.info(e)}class ti{constructor(){this.handlers=new Map,this.openHandlers=new Set,this.statusHandlers=new Set,this.connection=null,this.connectGeneration=0,this.retryDelay=on,this.retryTimer=null,this.connect()}async connect(){const t=++this.connectGeneration;this.clearReconnectTimer(),this.connection&&(this.emitTransportStatus("disconnected"),this.connection.disconnect(),this.connection=null),$e("Connecting to backend events stream");try{const n=await Xs({onBatch:r=>{t===this.connectGeneration&&this.dispatchBatch(r)},onError:()=>{t===this.connectGeneration&&this.scheduleReconnect()},onStatus:r=>{t===this.connectGeneration&&this.emitTransportStatus(r)},onOpen:()=>{t===this.connectGeneration&&($e("Events stream connected"),this.retryDelay=on,this.openHandlers.forEach(r=>r()))},onPing:r=>{if(t!==this.connectGeneration)return;const s={...Br(),pingTs:r.ts};Zs(i=>ie.sendClientConnectionPong(s,i),{maxAttempts:3,initialDelayMs:100,maxDelayMs:2e3,timeoutMs:1e4,shouldRetry:i=>Qs(i)}).catch(i=>{pn.warn("Failed to send client connection pong after retries",i)})}});if(t!==this.connectGeneration){n.disconnect();return}this.connection=n}catch(n){if(t!==this.connectGeneration)return;$e("Events stream failed to connect, scheduling reconnect",{error:n instanceof Error?n.message:String(n)}),this.scheduleReconnect()}}scheduleReconnect(){this.retryTimer||(this.connectGeneration+=1,this.connection&&(this.connection.disconnect(),this.connection=null),this.emitTransportStatus("disconnected"),$e("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.retryDelay=Math.min(this.retryDelay*2,ei),this.connect()},this.retryDelay))}clearReconnectTimer(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}dispatch(t){var n,r;(n=this.handlers.get("*"))==null||n.forEach(o=>o(t)),(r=this.handlers.get(t.type))==null||r.forEach(o=>o(t))}dispatchBatch(t){t.length!==0&&($e("event batch",{size:t.length}),xe(()=>{for(const n of t)this.dispatch(n)}))}emitTransportStatus(t){this.statusHandlers.forEach(n=>n(t))}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set);const r=this.handlers.get(t);return r.add(n),()=>r.delete(n)}onOpen(t){return this.openHandlers.add(t),()=>this.openHandlers.delete(t)}onTransportStatus(t){return this.statusHandlers.add(t),()=>this.statusHandlers.delete(t)}restart(t="manual restart"){this.retryDelay=on,this.clearReconnectTimer(),this.connection&&(this.emitTransportStatus("disconnected"),this.connection.disconnect(),this.connection=null),$e("Restarting backend events stream",{reason:t}),this.connect()}}const sn=new ti,ni=De("actions"),Yn={messageHistory:[],agentModelSelections:{}};function Xn(e,t){if(e===t)return!0;if(typeof e=="object"&&e!==null&&typeof t=="object"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){ni.warn("Failed to compare config objects",n)}return!1}class ri{constructor(){this.configOwnerCache=new Map,this.stateOwnerCache=new Map,this.configOwnerLoadPromises=new Map,this.stateOwnerLoadPromises=new Map,this.configOwnerListeners=new Map,this.stateOwnerListeners=new Map,this.instanceDataCache=new Map,this.instanceDataListeners=new Map,this.instanceLoadPromises=new Map,this.pendingWrites=new Set,sn.on("storage.configChanged",t=>{t.type==="storage.configChanged"&&this.setOwnerCache("config",t.owner,t.value)}),sn.on("storage.stateChanged",t=>{t.type==="storage.stateChanged"&&this.setOwnerCache("state",t.owner,t.value)}),sn.on("instance.dataChanged",t=>{t.type==="instance.dataChanged"&&this.setInstanceDataCache(t.instanceId,t.data)})}async loadConfigOwner(t){const n=this.configOwnerCache.get(t);if(n)return n;if(!this.configOwnerLoadPromises.has(t)){const r=ie.fetchConfigOwner(t).then(o=>(this.setOwnerCache("config",t,o),o)).finally(()=>{this.configOwnerLoadPromises.delete(t)});this.configOwnerLoadPromises.set(t,r)}return this.configOwnerLoadPromises.get(t)}patchConfigOwner(t,n){return this.trackWrite(ie.patchConfigOwner(t,n).then(r=>(this.setOwnerCache("config",t,r),r)))}async loadStateOwner(t){const n=this.stateOwnerCache.get(t);if(n)return n;if(!this.stateOwnerLoadPromises.has(t)){const r=ie.fetchStateOwner(t).then(o=>(this.setOwnerCache("state",t,o),o)).finally(()=>{this.stateOwnerLoadPromises.delete(t)});this.stateOwnerLoadPromises.set(t,r)}return this.stateOwnerLoadPromises.get(t)}patchStateOwner(t,n){return this.trackWrite(ie.patchStateOwner(t,n).then(r=>(this.setOwnerCache("state",t,r),r)))}async loadInstanceData(t){const n=this.instanceDataCache.get(t);if(n)return n;if(!this.instanceLoadPromises.has(t)){const r=ie.readInstanceData(t).then(o=>{const s=this.normalizeInstanceData(o);return this.setInstanceDataCache(t,s),s}).finally(()=>{this.instanceLoadPromises.delete(t)});this.instanceLoadPromises.set(t,r)}return this.instanceLoadPromises.get(t)}saveInstanceData(t,n){const r=this.normalizeInstanceData(n);return this.trackWrite(ie.writeInstanceData(t,r).then(()=>{this.setInstanceDataCache(t,r)}))}deleteInstanceData(t){return this.trackWrite(ie.deleteInstanceData(t).then(()=>{this.setInstanceDataCache(t,Yn)}))}async flushWrites(){for(;this.pendingWrites.size>0;)await Promise.allSettled(this.pendingWrites)}onConfigOwnerChanged(t,n){this.configOwnerListeners.has(t)||this.configOwnerListeners.set(t,new Set);const r=this.configOwnerListeners.get(t);r.add(n);const o=this.configOwnerCache.get(t);return o&&n(o),()=>{r.delete(n),r.size===0&&this.configOwnerListeners.delete(t)}}onStateOwnerChanged(t,n){this.stateOwnerListeners.has(t)||this.stateOwnerListeners.set(t,new Set);const r=this.stateOwnerListeners.get(t);r.add(n);const o=this.stateOwnerCache.get(t);return o&&n(o),()=>{r.delete(n),r.size===0&&this.stateOwnerListeners.delete(t)}}onInstanceDataChanged(t,n){this.instanceDataListeners.has(t)||this.instanceDataListeners.set(t,new Set);const r=this.instanceDataListeners.get(t);r.add(n);const o=this.instanceDataCache.get(t);return o&&n(o),()=>{r.delete(n),r.size===0&&this.instanceDataListeners.delete(t)}}setOwnerCache(t,n,r){if(n==="*"){t==="config"?this.configOwnerCache.clear():this.stateOwnerCache.clear();return}const o=t==="config"?this.configOwnerCache:this.stateOwnerCache,s=t==="config"?this.configOwnerListeners:this.stateOwnerListeners,i=o.get(n);if(i&&Xn(i,r)){o.set(n,r);return}o.set(n,r);const a=s.get(n);if(a)for(const c of a)c(r)}trackWrite(t){return this.pendingWrites.add(t),t.finally(()=>this.pendingWrites.delete(t)).catch(()=>{}),t}normalizeInstanceData(t){const n=t??Yn,r=Array.isArray(n.messageHistory)?[...n.messageHistory]:[],o={...n.agentModelSelections??{}};return{...n,messageHistory:r,agentModelSelections:o}}setInstanceDataCache(t,n){const r=this.normalizeInstanceData(n),o=this.instanceDataCache.get(t);if(o&&Xn(o,r)){this.instanceDataCache.set(t,r);return}this.instanceDataCache.set(t,r),this.notifyInstanceDataChanged(t,r)}notifyInstanceDataChanged(t,n){const r=this.instanceDataListeners.get(t);if(r)for(const o of r)o(n)}}const te=new ri,jr=De("api"),zt={messageHistory:[],agentModelSelections:{}},[kn,Wr]=M(new Map),Et=new Map,Ge=new Map;function Vr(e){const t=e??zt;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function Zn(e){if(Ge.has(e))return;const t=te.onInstanceDataChanged(e,n=>{It(e,n)});Ge.set(e,t)}function oi(e){const t=Ge.get(e);t&&(t(),Ge.delete(e))}function It(e,t){Wr(n=>{const r=new Map(n);return r.set(e,Vr(t)),r})}async function Ht(e){if(!e||kn().has(e))return;if(Et.has(e)){await Et.get(e);return}const t=te.loadInstanceData(e).then(n=>{It(e,n),Zn(e)}).catch(n=>{jr.warn("Failed to load instance data",n),It(e,zt),Zn(e)}).finally(()=>{Et.delete(e)});Et.set(e,t),await t}async function Kr(e,t){if(!e)return;await Ht(e);const n=kn().get(e)??zt,r=Vr(n);t(r);try{await te.saveInstanceData(e,r)}catch(o){jr.warn("Failed to persist instance data",o)}It(e,r)}function zr(e){return kn().get(e)??zt}function si(e){Wr(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),oi(e)}const ii=qe(),ai={getInstanceConfig:zr,ensureInstanceConfig:Ht,updateInstanceConfig:Kr,clearInstanceConfig:si},Eu=e=>(ue(()=>{for(const t of Ge.values())t();Ge.clear()}),pe(ii.Provider,{value:ai,get children(){return e.children}})),ci=De("api");function li(e){const t=e;return t.sttConfigured===void 0&&(t.sttConfigured=t.configured),t.ttsConfigured===void 0&&(t.ttsConfigured=t.configured),t.separateProviders===void 0&&(t.separateProviders=!1),t}const[Qn,yn]=M(null),[Ou,er]=M(!1),[Pu,Dt]=M(null),[Mu,Hr]=M(!1);let Qe=null;async function ui(e=!1){return!e&&Qn()?Qn():Qe||(er(!0),Dt(null),Qe=ie.fetchSpeechCapabilities().then(t=>{Hr("separateProviders"in t);const r=li(t);return yn(r),Dt(null),r}).catch(t=>(ci.error("Failed to load speech capabilities",t),yn(null),Dt(t instanceof Error?t.message:String(t)),null)).finally(()=>{er(!1),Qe=null}),Qe)}function di(){yn(null),Dt(null),Hr(!1)}function fi(e){var n,r,o,s,i,a;const t={};e.separateProviders!==void 0&&(t.separateProviders=e.separateProviders),e.apiKey!==void 0&&(t.apiKey=e.apiKey),e.baseUrl!==void 0&&(t.baseUrl=((n=e.baseUrl)==null?void 0:n.trim())||null),e.sttModel!==void 0&&(t.sttModel=((r=e.sttModel)==null?void 0:r.trim())||null),e.ttsModel!==void 0&&(t.ttsModel=((o=e.ttsModel)==null?void 0:o.trim())||null),e.ttsVoice!==void 0&&(t.ttsVoice=((s=e.ttsVoice)==null?void 0:s.trim())||null),e.playbackMode!==void 0&&(t.playbackMode=e.playbackMode),e.ttsFormat!==void 0&&(t.ttsFormat=e.ttsFormat);for(const c of["stt","tts"]){const u=e[c];if(u){const l={};u.apiKey!==void 0&&(l.apiKey=u.apiKey),u.baseUrl!==void 0&&(l.baseUrl=((i=u.baseUrl)==null?void 0:i.trim())||null),u.model!==void 0&&(l.model=((a=u.model)==null?void 0:a.trim())||null),Object.keys(l).length>0&&(t[c]=l)}}return t}const hi=["porcelain","dawn","parchment","linen","iris","sage-light","mist","slate","clay","sage"],Re={userAccent:"#79BCE0",agentAccent:"#D89DBD",compactionAccent:"#AC9DDD"},Gr={userAccent:"#24688B",agentAccent:"#93466F",compactionAccent:"#67529B"};function oe(e,t,n,r){return{id:e,appearance:n,editable:!1,labelKey:`settings.appearance.palette.${t}`,descriptionKey:`settings.appearance.palette.${t}.description`,colors:{...n==="dark"?Re:Gr,...r}}}const $n=[oe("porcelain","mist","light",{surfaceBase:"#CFD1D4",surfaceSecondary:"#E1E3E5",surfaceMuted:"#BDC1C6",borderBase:"#A9AEB6",textPrimary:"#3D4148",textMuted:"#484E58",accentPrimary:"#665BA3",statusSuccess:"#426F49",statusWarning:"#81641D",statusError:"#AC4547",yoloAccent:"#665BA3",compactionAccent:"#A07AFF"}),oe("mist","mist","dark",{surfaceBase:"#282C33",surfaceSecondary:"#343A44",surfaceMuted:"#404754",borderBase:"#525B69",textPrimary:"#CED2DA",textMuted:"#ADB5C3",accentPrimary:"#D0ED9C",statusSuccess:"#81C1A8",statusWarning:"#DEC184",statusError:"#E8987D",yoloAccent:"#B8BEAC"}),oe("dawn","slate","light",{surfaceBase:"#BCD2E5",surfaceSecondary:"#CFE2F1",surfaceMuted:"#A5BFD4",borderBase:"#92AEC4",textPrimary:"#35424D",textMuted:"#3F4D59",accentPrimary:"#7F69E2",statusSuccess:"#4B733C",statusWarning:"#805C20",statusError:"#AB4849",yoloAccent:"#6B609A"}),oe("slate","slate","dark",{surfaceBase:"#272F40",surfaceSecondary:"#333E52",surfaceMuted:"#404E65",borderBase:"#53647C",textPrimary:"#C9D1DF",textMuted:"#9DB5D2",accentPrimary:"#C6B58C",statusSuccess:"#A5BD86",statusWarning:"#E0B778",statusError:"#E58D8A",yoloAccent:"#C6B58C"}),oe("parchment","clay","light",{surfaceBase:"#D5C09E",surfaceSecondary:"#E2CEB0",surfaceMuted:"#CFB994",borderBase:"#AC906A",textPrimary:"#3D352B",textMuted:"#4D4235",accentPrimary:"#A9BA45",statusSuccess:"#496C42",statusWarning:"#7B551B",statusError:"#A33D36",yoloAccent:"#5F682F"}),oe("clay","clay","dark",{surfaceBase:"#32302F",surfaceSecondary:"#41403E",surfaceMuted:"#55524E",borderBase:"#645C50",textPrimary:"#D8CBB3",textMuted:"#C6B9A5",accentPrimary:"#87BC5C",statusSuccess:"#B9BF69",statusWarning:"#D8B574",statusError:"#E39380",yoloAccent:"#B8BA86",compactionAccent:"#AA91FD"}),oe("linen","linen","light",{surfaceBase:"#E6E0CE",surfaceSecondary:"#F0EAD9",surfaceMuted:"#D8D1BD",borderBase:"#BDB6A2",textPrimary:"#3B494C",textMuted:"#4D5A5C",accentPrimary:"#9D8325",statusSuccess:"#699245",statusWarning:"#835B1E",statusError:"#AF4740",yoloAccent:"#776524"}),oe("iris","iris","light",{surfaceBase:"#E0D4E5",surfaceSecondary:"#EDDFEF",surfaceMuted:"#CDBCD6",borderBase:"#B39DBF",textPrimary:"#42394F",textMuted:"#534961",accentPrimary:"#6B7CFF",statusSuccess:"#477343",statusWarning:"#825B20",statusError:"#AD424D",yoloAccent:"#776026"}),oe("sage-light","sage","light",{surfaceBase:"#CBD8C1",surfaceSecondary:"#DCE6D2",surfaceMuted:"#B8C8AC",borderBase:"#9BAF8D",textPrimary:"#374532",textMuted:"#44543B",accentPrimary:"#6C7FCB",statusSuccess:"#496E3C",statusWarning:"#80591D",statusError:"#A9453E",yoloAccent:"#756126"}),oe("sage","sage","dark",{surfaceBase:"#2D3530",surfaceSecondary:"#39463D",surfaceMuted:"#47564A",borderBase:"#5A6A5C",textPrimary:"#D2D5C2",textMuted:"#C0CAB5",accentPrimary:"#CCC092",statusSuccess:"#81C182",statusWarning:"#DBBC7F",statusError:"#E8987D",yoloAccent:"#CCC092"})],gi=$n.find(e=>e.id==="porcelain").colors,mi=$n.find(e=>e.id==="mist").colors;function pi(e){return{...e.surfaceMuted==="#F8FAFC"?{"--message-assistant-bg":"#F8F8F8","--message-tool-bg":"#F8F8F8",...e.surfaceBase==="#FFFFFF"?{"--surface-code":"#F1F5F9"}:{}}:{},...e.textMuted==="#475569"?{"--text-secondary":"#334155"}:{},...e.accentPrimary==="#0066FF"?{"--accent-hover":"#0052CC"}:{}}}function yi(e){return{...e.userAccent==="#2196F3"&&e.surfaceBase==="#1A1A1A"&&e.surfaceSecondary==="#2A2A2A"?{"--message-user-bg":"#202734"}:{},...e.accentPrimary==="#0080FF"?{"--accent-hover":"#0066CC"}:{},...e.borderBase==="#3A3A3A"&&e.textMuted==="#999999"?{"--message-tool-border":"#ADB5BD","--border-secondary":"#3A3A3A","--border-muted":"#3A3A3A","--border-strong":"#3A3A3A"}:{}}}const Jr=["system","light",...hi,"classic","basalt","fjord","lichen","velvet","ember","custom"],qr=["surfaceBase","surfaceSecondary","surfaceMuted","borderBase","textPrimary","textMuted","accentPrimary","statusSuccess","statusWarning","statusError","userAccent","agentAccent","compactionAccent","yoloAccent"],bi=qr.slice(0,10),Yr={userAccent:"#42A5F5",agentAccent:"#D97706",compactionAccent:"#C084FC",yoloAccent:"#8FA8FF"},dt={surfaceBase:"#17181A",surfaceSecondary:"#202226",surfaceMuted:"#292C31",borderBase:"#3B3F46",textPrimary:"#F0F1F3",textMuted:"#B2B6BE",accentPrimary:"#8FA8FF",statusSuccess:"#72C497",statusWarning:"#D8B36A",statusError:"#E28181",...Yr},Ci={surfaceBase:"#FFFFFF",surfaceSecondary:"#F5F5F5",surfaceMuted:"#F8FAFC",borderBase:"#E0E0E0",textPrimary:"#111827",textMuted:"#475569",accentPrimary:"#0066FF",statusSuccess:"#237A43",statusWarning:"#9A6700",statusError:"#C62828",...Gr,yoloAccent:"#0066FF"},Si=gi,wi=mi,Ai=[{id:"system",labelKey:"settings.appearance.colorScheme.option.system",descriptionKey:"settings.appearance.colorScheme.description.system",appearance:"system",editable:!1},{id:"light",labelKey:"settings.appearance.colorScheme.option.codeNomadClassic",descriptionKey:"settings.appearance.colorScheme.description.light",appearance:"light",editable:!1,colors:Ci},{id:"classic",labelKey:"settings.appearance.colorScheme.option.codeNomadClassic",descriptionKey:"settings.appearance.colorScheme.description.codeNomadClassic",appearance:"dark",editable:!1,colors:{surfaceBase:"#1A1A1A",surfaceSecondary:"#2A2A2A",surfaceMuted:"#212529",borderBase:"#3A3A3A",textPrimary:"#CFD4DC",textMuted:"#999999",accentPrimary:"#4D7AFE",statusSuccess:"#4CAF50",statusWarning:"#FF9800",statusError:"#F44336",userAccent:"#2196F3",agentAccent:"#D97706",compactionAccent:"#C084FC",yoloAccent:"#0080FF"}},...$n,{id:"basalt",labelKey:"settings.appearance.colorScheme.option.basalt",descriptionKey:"settings.appearance.colorScheme.description.basalt",appearance:"dark",editable:!1,colors:{...dt,...Re,userAccent:"#88EEFB"}},{id:"fjord",labelKey:"settings.appearance.colorScheme.option.fjord",descriptionKey:"settings.appearance.colorScheme.description.fjord",appearance:"dark",editable:!1,colors:{surfaceBase:"#131A1F",surfaceSecondary:"#1B252C",surfaceMuted:"#243139",borderBase:"#354650",textPrimary:"#E7EEF1",textMuted:"#A8B8BF",accentPrimary:"#67C9BA",statusSuccess:"#8FC473",statusWarning:"#D8B36A",statusError:"#E28181",...Re,yoloAccent:"#67C9BA"}},{id:"lichen",labelKey:"settings.appearance.colorScheme.option.lichen",descriptionKey:"settings.appearance.colorScheme.description.lichen",appearance:"dark",editable:!1,colors:{surfaceBase:"#181A15",surfaceSecondary:"#22251D",surfaceMuted:"#2C3025",borderBase:"#41473A",textPrimary:"#ECEEE8",textMuted:"#B2B8A7",accentPrimary:"#A9C47F",statusSuccess:"#77C49A",statusWarning:"#D6B36D",statusError:"#DF8580",...Re,yoloAccent:"#A9C47F"}},{id:"velvet",labelKey:"settings.appearance.colorScheme.option.velvet",descriptionKey:"settings.appearance.colorScheme.description.velvet",appearance:"dark",editable:!1,colors:{surfaceBase:"#160F16",surfaceSecondary:"#211721",surfaceMuted:"#2B1E2B",borderBase:"#443044",textPrimary:"#F1EAF0",textMuted:"#BAAAB7",accentPrimary:"#E5A77D",statusSuccess:"#78C59A",statusWarning:"#DDB46F",statusError:"#E28787",...Re,yoloAccent:"#E5A77D"}},{id:"ember",labelKey:"settings.appearance.colorScheme.option.ember",descriptionKey:"settings.appearance.colorScheme.description.ember",appearance:"dark",editable:!1,colors:{surfaceBase:"#1B1714",surfaceSecondary:"#27211D",surfaceMuted:"#312923",borderBase:"#493D34",textPrimary:"#F1ECE7",textMuted:"#BDB1A6",accentPrimary:"#D99254",statusSuccess:"#78C296",statusWarning:"#D8AE62",statusError:"#DE817A",...Re,yoloAccent:"#D79A66"}},{id:"custom",labelKey:"settings.appearance.colorScheme.option.custom",descriptionKey:"settings.appearance.colorScheme.description.custom",appearance:"dark",editable:!0,colors:dt}],tr=Object.fromEntries(Ai.map(e=>[e.id,e])),Ae=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Bt=e=>typeof e=="string"&&/^#[0-9A-F]{6}$/.test(e);function gt(e){return Ae(e)&&qr.every(t=>Bt(e[t]))}function nr(e){if(gt(e))return{...e};if(!(!Ae(e)||!bi.every(t=>Bt(e[t]))))return{...e,...Yr}}const vi=e=>({...e});function Ie(e,t,n=tr[e].appearance){const r=tr[e];return{id:e,appearance:n,...t||r.colors?{colors:vi(t??r.colors)}:{}}}function U(e,t){const n=typeof e=="string"?e:Ae(e)?e.id:void 0;if(typeof n=="string"&&Jr.includes(n)){const r=n;if(r!=="custom"){const i=Ae(e)?nr(e.colors):void 0;if(r==="system"&&i){const a=Ae(e)&&(e.appearance==="light"||e.appearance==="dark")?e.appearance:bn(i.surfaceBase)>.4?"light":"dark";return Ie("custom",i,a)}return Ie(r,i)}const o=Ae(e)?nr(e.colors)??dt:dt,s=Ae(e)&&e.appearance==="light"?"light":"dark";return Ie("custom",o,s)}return Ie(t==="light"?"light":t==="dark"?"classic":"system")}function Xr(e){const t=U(e);return{...t,colors:t.colors?{...t.colors}:null}}const ye=(e,t)=>Number.parseInt(e.slice(t,t+2),16),bn=e=>{const t=n=>{const r=n/255;return r<=.04045?r/12.92:((r+.055)/1.055)**2.4};return .2126*t(ye(e,1))+.7152*t(ye(e,3))+.0722*t(ye(e,5))};function rr(e,t){if(!Bt(e)||!Bt(t))return 0;const[n,r]=[bn(e),bn(t)].sort((o,s)=>s-o);return(n+.05)/(r+.05)}const se=(e,t,n)=>`#${[1,3,5].map(o=>Math.round(ye(e,o)*n+ye(t,o)*(1-n))).map(o=>o.toString(16).padStart(2,"0")).join("").toUpperCase()}`,B=(e,t)=>`rgba(${ye(e,1)}, ${ye(e,3)}, ${ye(e,5)}, ${t})`,xi=e=>rr("#000000",e)>=rr("#FFFFFF",e)?"#000000":"#FFFFFF",Ei=["--surface-base","--surface-primary","--surface-secondary","--surface-muted","--surface-code","--surface-hover","--border-base","--border-secondary","--border-muted","--border-strong","--border-critical","--text-primary","--text-secondary","--text-muted","--text-inverted","--text-on-accent","--accent-primary","--accent-hover","--focus-ring-color","--focus-ring-offset","--list-item-highlight-bg","--list-item-highlight-bg-solid","--list-item-highlight-border","--attachment-chip-bg","--attachment-chip-text","--attachment-chip-ring","--badge-neutral-bg","--badge-neutral-text","--env-vars-bg","--env-vars-border","--env-vars-text","--dropdown-highlight-bg","--selection-highlight-bg","--selection-highlight-strong-bg","--status-success","--status-warning","--status-error","--status-success-bg","--status-warning-bg","--status-error-bg","--status-success-ring","--status-warning-ring","--status-error-ring","--status-ready-fg","--status-ready-bg","--status-starting-fg","--status-starting-bg","--status-error-fg","--message-user-bg","--message-user-border","--message-assistant-bg","--message-assistant-border","--message-tool-bg","--message-tool-border","--session-status-compacting-fg","--session-status-compacting-bg","--session-yolo-accent","--tab-active-bg","--tab-active-hover-bg","--tab-active-text","--tab-inactive-bg","--tab-inactive-hover-bg","--tab-inactive-text","--tab-rail-bg","--tab-border","--new-tab-bg","--new-tab-hover-bg","--new-tab-text"];function Oi(e,t){const n=xi(e.accentPrimary),r=e.textMuted;return{"--surface-base":e.surfaceBase,"--surface-primary":e.surfaceBase,"--surface-secondary":e.surfaceSecondary,"--surface-muted":e.surfaceMuted,"--surface-code":e.surfaceBase,"--surface-hover":se(e.textPrimary,e.surfaceSecondary,.04),"--border-base":e.borderBase,"--border-secondary":se(e.borderBase,e.surfaceSecondary,.72),"--border-muted":se(e.borderBase,e.surfaceSecondary,.5),"--border-strong":se(e.textPrimary,e.borderBase,.3),"--border-critical":e.statusError,"--text-primary":e.textPrimary,"--text-secondary":e.textMuted,"--text-muted":e.textMuted,"--text-inverted":n,"--text-on-accent":n,"--accent-primary":e.accentPrimary,"--accent-hover":se(t?"#FFFFFF":"#000000",e.accentPrimary,t?.14:.18),"--focus-ring-color":e.accentPrimary,"--focus-ring-offset":e.surfaceBase,"--list-item-highlight-bg":B(r,t?.2:.12),"--list-item-highlight-bg-solid":se(r,e.surfaceSecondary,t?.22:.12),"--list-item-highlight-border":B(r,t?.4:.25),"--attachment-chip-bg":B(e.accentPrimary,.1),"--attachment-chip-text":e.accentPrimary,"--attachment-chip-ring":B(e.accentPrimary,t?.2:.1),"--badge-neutral-bg":B(e.accentPrimary,t?.15:.05),"--badge-neutral-text":e.accentPrimary,"--env-vars-bg":B(e.accentPrimary,t?.2:.1),"--env-vars-border":B(e.accentPrimary,t?.3:.2),"--env-vars-text":e.accentPrimary,"--dropdown-highlight-bg":B(r,t?.2:.12),"--selection-highlight-bg":B(r,t?.22:.16),"--selection-highlight-strong-bg":B(r,t?.32:.24),"--status-success":e.statusSuccess,"--status-warning":e.statusWarning,"--status-error":e.statusError,"--status-success-bg":B(e.statusSuccess,.16),"--status-warning-bg":B(e.statusWarning,.16),"--status-error-bg":B(e.statusError,.16),"--status-success-ring":B(e.statusSuccess,.42),"--status-warning-ring":B(e.statusWarning,.42),"--status-error-ring":B(e.statusError,.42),"--status-ready-fg":e.statusSuccess,"--status-ready-bg":B(e.statusSuccess,.16),"--status-starting-fg":e.statusWarning,"--status-starting-bg":B(e.statusWarning,.16),"--status-error-fg":e.statusError,"--message-user-bg":se(e.userAccent,e.surfaceSecondary,t?.05:.06),"--message-user-border":e.userAccent,"--message-assistant-bg":e.surfaceMuted,"--message-assistant-border":e.agentAccent,"--message-tool-bg":e.surfaceMuted,"--message-tool-border":se(e.textMuted,e.borderBase,.28),"--session-status-compacting-fg":e.compactionAccent,"--session-status-compacting-bg":B(e.compactionAccent,t?.28:.18),"--session-yolo-accent":e.accentPrimary,"--tab-active-bg":e.surfaceBase,"--tab-active-hover-bg":se(e.textPrimary,e.surfaceBase,.04),"--tab-active-text":e.textPrimary,"--tab-inactive-bg":e.surfaceSecondary,"--tab-inactive-hover-bg":se(e.textPrimary,e.surfaceSecondary,.04),"--tab-inactive-text":e.textMuted,"--tab-rail-bg":e.surfaceSecondary,"--tab-border":e.borderBase,"--new-tab-bg":e.surfaceSecondary,"--new-tab-hover-bg":e.surfaceMuted,"--new-tab-text":e.textMuted}}function Pi(e,t={}){const n=e.appearance==="dark"||e.appearance==="system"&&!!t.systemDark,r=t.target??(typeof document>"u"?void 0:document.documentElement);if(!r)return n;for(const s of Ei)r.style.removeProperty(s);r.dataset.colorScheme=e.id,e.appearance==="system"?r.removeAttribute("data-theme"):r.setAttribute("data-theme",n?"dark":"light");const o=e.id==="system"?e.colors??(n?wi:Si):e.colors;if(o){for(const[s,i]of Object.entries(Oi(o,n)))r.style.setProperty(s,i);if(e.id==="light")for(const[s,i]of Object.entries(pi(o)))r.style.setProperty(s,i);if(e.id==="classic")for(const[s,i]of Object.entries(yi(o)))r.style.setProperty(s,i)}return n}const or=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function Mi(e,t,n){const r=or(e),o=s=>{const i=or(r[s]),a=U(i.scheme);return a.appearance===s?{scheme:a,presetId:typeof i.presetId=="string"?i.presetId:null}:t.appearance===s?{scheme:t,presetId:n??null}:{scheme:U(s==="light"?"porcelain":"mist"),presetId:null}};return{mode:r.mode==="light"||r.mode==="dark"||r.mode==="system"?r.mode:t.appearance,light:o("light"),dark:o("dark")}}function Fi(e,t){return e==="system"?t?"dark":"light":e}function Di(e,t,n=null){return t.appearance==="system"?{...e,mode:"system"}:{...e,[t.appearance]:{scheme:t,presetId:n}}}const Zr=50;function Ti(e){return!!(e&&Object.entries(dt).every(([t,n])=>e[t]===n))}const Cn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ki(e){if(!Cn(e))return{};const t={};for(const[n,r]of Object.entries(e).slice(0,Zr)){if(!n||n.length>128||!Cn(r))continue;const o=typeof r.name=="string"?r.name.trim().slice(0,80):"",s=r.appearance==="light"?"light":r.appearance==="dark"?"dark":void 0;!o||!s||!gt(r.colors)||(t[n]={name:o,appearance:s,colors:{...r.colors}})}return t}function $i(e){if(!Cn(e))return{};const t={};for(const[n,r]of Object.entries(e))n==="custom"||!Jr.includes(n)||!gt(r)||(t[n]={...r});return t}function Fu(e,t){var a;const n=e.trim()||"Custom",r=/^(.*?)(?:\s+(\d+))?$/.exec(n),o=((a=r==null?void 0:r[1])==null?void 0:a.trim())||n;let s=r!=null&&r[2]?Number(r[2])+1:2;const i=new Set(t.map(c=>c.trim().toLocaleLowerCase()));for(;i.has(`${o} ${s}`.toLocaleLowerCase());)s+=1;return`${o} ${s}`}function Ii(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`palette-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Gt(e){if(!e||typeof e!="object"||Array.isArray(e))return{hiddenModelIds:[]};const t=e.hiddenModelIds;return Array.isArray(t)?{hiddenModelIds:Array.from(new Set(t.filter(n=>typeof n=="string"&&n.length>0)))}:{hiddenModelIds:[]}}function Bi(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e))n&&(t[n]=Gt(r));return t}function Du(e,t){return!Gt(e).hiddenModelIds.includes(t)}function Tu(e,t){return e&&t.some(n=>n.key===e.key)?e:void 0}const x=De("actions"),Li=20,Ri=5,Ni=50,Ui={preset:"balanced"},T={showThinkingBlocks:!1,showKeyboardShortcutHints:!1,thinkingBlocksExpansion:"collapsed",showMessageTimeline:!0,showTimelineTools:!1,holdLongAssistantReplies:!0,promptSubmitOnEnter:!0,followUpBehavior:"steer",showPromptVoiceInput:!0,diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded",toolInputsVisibility:"collapsed",showUsageMetrics:!0,showProviderUsageCreditBalance:!1,autoCleanupBlankSessions:!0,keepUnseenSubagentIdleStatus:!0,osNotificationsEnabled:!1,osNotificationsAllowWhenVisible:!1,notifyOnNeedsInput:!0,notifyOnIdle:!0};function Sn(e,t){return e==="expanded"||e==="collapsed"?e:t}function sr(e,t){return e==="hidden"||e==="expanded"||e==="collapsed"?e:t}function _i(e){return e==="minimal"||e==="balanced"||e==="detailed"||e==="everything"||e==="custom"?e:Ui.preset}function ji(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e))n&&(r==="hidden"||r==="expanded"||r==="collapsed")&&(t[n]=r);return t}function Wi(e,t){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,r=Sn(t.thinkingBlocksExpansion,"collapsed");return{preset:_i(n==null?void 0:n.preset),thinking:Sn(n==null?void 0:n.thinking,r),tools:ji(n==null?void 0:n.tools)}}const Be={provider:"openai-compatible",sttModel:"gpt-4o-mini-transcribe",ttsModel:"gpt-4o-mini-tts",ttsVoice:"alloy",playbackMode:"streaming",ttsFormat:"mp3"};function Qr(e){const t=e??{},n=Wi(t.toolCallExpansionDefaults,t),r=n.preset==="minimal"||n.preset==="balanced"?"collapsed":"expanded";return{showThinkingBlocks:t.showThinkingBlocks??T.showThinkingBlocks,showKeyboardShortcutHints:t.showKeyboardShortcutHints??T.showKeyboardShortcutHints,thinkingBlocksExpansion:t.thinkingBlocksExpansion??T.thinkingBlocksExpansion,showMessageTimeline:t.showMessageTimeline??T.showMessageTimeline,showTimelineTools:t.showTimelineTools??T.showTimelineTools,holdLongAssistantReplies:t.holdLongAssistantReplies??T.holdLongAssistantReplies,promptSubmitOnEnter:t.promptSubmitOnEnter??T.promptSubmitOnEnter,followUpBehavior:t.followUpBehavior==="queue"||t.followUpBehavior==="steer"?t.followUpBehavior:T.followUpBehavior,showPromptVoiceInput:t.showPromptVoiceInput??T.showPromptVoiceInput,locale:t.locale??T.locale,diffViewMode:t.diffViewMode??T.diffViewMode,toolCallExpansionDefaults:n,toolOutputExpansion:t.toolOutputExpansion??T.toolOutputExpansion,diagnosticsExpansion:sr(t.diagnosticsExpansion,T.diagnosticsExpansion),systemMessagesVisibility:sr(t.systemMessagesVisibility,"hidden"),toolInputsVisibility:t.toolInputsVisibility==="hidden"||t.toolInputsVisibility==="collapsed"||t.toolInputsVisibility==="expanded"?t.toolInputsVisibility:T.toolInputsVisibility,showUsageMetrics:t.showUsageMetrics??T.showUsageMetrics,usageMetricsExpansion:Sn(t.usageMetricsExpansion,r),showProviderUsageCreditBalance:t.showProviderUsageCreditBalance??T.showProviderUsageCreditBalance,autoCleanupBlankSessions:t.autoCleanupBlankSessions??T.autoCleanupBlankSessions,keepUnseenSubagentIdleStatus:t.keepUnseenSubagentIdleStatus??T.keepUnseenSubagentIdleStatus,focusExistingWindowOnSecondLaunch:t.focusExistingWindowOnSecondLaunch===!0,modelVisibility:Bi(t.modelVisibility),osNotificationsEnabled:t.osNotificationsEnabled??T.osNotificationsEnabled,osNotificationsAllowWhenVisible:t.osNotificationsAllowWhenVisible??T.osNotificationsAllowWhenVisible,notifyOnNeedsInput:t.notifyOnNeedsInput??T.notifyOnNeedsInput,notifyOnIdle:t.notifyOnIdle??T.notifyOnIdle}}function eo(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function Vi(e){var o,s,i,a,c,u,l,d,f,g;const t=e??{},n=typeof t.sttModel=="string"&&t.sttModel.trim()?t.sttModel.trim():Be.sttModel,r=typeof t.ttsModel=="string"&&t.ttsModel.trim()?t.ttsModel.trim():Be.ttsModel;return{provider:t.provider==="openai-compatible"?t.provider:Be.provider,apiKey:typeof t.apiKey=="string"&&t.apiKey.trim()?t.apiKey.trim():void 0,hasApiKey:t.hasApiKey===!0||typeof t.apiKey=="string"&&t.apiKey.trim().length>0,baseUrl:typeof t.baseUrl=="string"&&t.baseUrl.trim()?t.baseUrl.trim():void 0,sttModel:n,ttsModel:r,ttsVoice:typeof t.ttsVoice=="string"&&t.ttsVoice.trim()?t.ttsVoice.trim():Be.ttsVoice,playbackMode:t.playbackMode==="buffered"||t.playbackMode==="streaming"?t.playbackMode:Be.playbackMode,ttsFormat:t.ttsFormat==="wav"||t.ttsFormat==="opus"||t.ttsFormat==="aac"||t.ttsFormat==="mp3"?t.ttsFormat:Be.ttsFormat,separateProviders:t.separateProviders===!0,stt:{apiKey:typeof((o=t.stt)==null?void 0:o.apiKey)=="string"&&t.stt.apiKey.trim()?t.stt.apiKey.trim():void 0,hasApiKey:((s=t.stt)==null?void 0:s.hasApiKey)===!0||typeof((i=t.stt)==null?void 0:i.apiKey)=="string"&&t.stt.apiKey.trim().length>0,baseUrl:typeof((a=t.stt)==null?void 0:a.baseUrl)=="string"&&t.stt.baseUrl.trim()?t.stt.baseUrl.trim():void 0,model:typeof((c=t.stt)==null?void 0:c.model)=="string"&&t.stt.model.trim()?t.stt.model.trim():n},tts:{apiKey:typeof((u=t.tts)==null?void 0:u.apiKey)=="string"&&t.tts.apiKey.trim()?t.tts.apiKey.trim():void 0,hasApiKey:((l=t.tts)==null?void 0:l.hasApiKey)===!0||typeof((d=t.tts)==null?void 0:d.apiKey)=="string"&&t.tts.apiKey.trim().length>0,baseUrl:typeof((f=t.tts)==null?void 0:f.baseUrl)=="string"&&t.tts.baseUrl.trim()?t.tts.baseUrl.trim():void 0,model:typeof((g=t.tts)==null?void 0:g.model)=="string"&&t.tts.model.trim()?t.tts.model.trim():r}}}function et(e,t){if(!Array.isArray(e))return[];const n=[];for(const r of e){const o=t(r);o&&n.push(o)}return n}function Ki(e){var n,r,o;const t=e??{};return{recentFolders:et(t.recentFolders,s=>{if(!s||typeof s!="object")return null;const i=s.path,a=s.lastAccessed,c=s.projectName;if(typeof i!="string")return null;const u=typeof a=="number"?a:Date.now();return{path:i,lastAccessed:u,...typeof c=="string"&&c.trim()?{projectName:c.trim()}:{}}}),opencodeBinaries:et(t.opencodeBinaries,s=>{if(!s||typeof s!="object")return null;const i=s.path;if(typeof i!="string")return null;const a=typeof s.lastUsed=="number"?s.lastUsed:Date.now(),c=typeof s.version=="string"?s.version:void 0,u=typeof s.label=="string"?s.label:void 0;return{path:i,version:c,label:u,lastUsed:a}}),remoteServers:et(t.remoteServers,s=>{if(!s||typeof s!="object")return null;const i=typeof s.id=="string"?s.id.trim():"",a=typeof s.name=="string"?s.name.trim():"",c=typeof s.baseUrl=="string"?s.baseUrl.trim():"";if(!i||!a||!c)return null;const u=typeof s.createdAt=="string"?s.createdAt:new Date().toISOString(),l=typeof s.updatedAt=="string"?s.updatedAt:u,d=typeof s.lastConnectedAt=="string"?s.lastConnectedAt:void 0;return{id:i,name:a,baseUrl:c,skipTlsVerify:!!s.skipTlsVerify,createdAt:u,updatedAt:l,lastConnectedAt:d}}).sort((s,i)=>{const a=s.lastConnectedAt??s.updatedAt;return(i.lastConnectedAt??i.updatedAt).localeCompare(a)}),models:{recents:et((n=t.models)==null?void 0:n.recents,s=>{if(!s||typeof s!="object")return null;const i=s.providerId,a=s.modelId;return typeof i!="string"||typeof a!="string"?null:{providerId:i,modelId:a}}),favorites:et((r=t.models)==null?void 0:r.favorites,s=>{if(!s||typeof s!="object")return null;const i=s.providerId,a=s.modelId;return typeof i!="string"||typeof a!="string"?null:{providerId:i,modelId:a}}),thinkingSelections:eo((o=t.models)==null?void 0:o.thinkingSelections)}}}function zi(e){const t=e??{},n=t.listeningMode==="all"?"all":"local",r=t.logLevel==="INFO"||t.logLevel==="WARN"||t.logLevel==="ERROR"||t.logLevel==="DEBUG"?t.logLevel:"DEBUG",o=typeof t.opencodeBinary=="string"&&t.opencodeBinary.trim()&&t.opencodeBinary!=="opencode"?t.opencodeBinary:"opencode2",s=eo(t.environmentVariables),i=Hi(t.secureEnvVars),a=Vi(t.speech);return{listeningMode:n,logLevel:r,opencodeBinary:o,environmentVariables:s,secureEnvVars:i,speech:a}}function Hi(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function to(e){return`${e.providerId}/${e.modelId}`}function no(e,t,n){const r=new Set([e,n].filter(c=>!!c)),o=n?t.find(c=>c.path===n):void 0,s=t.find(c=>c.path===e),i=(o==null?void 0:o.projectName)??(s==null?void 0:s.projectName),a=t.filter(c=>!r.has(c.path));return a.unshift({path:e,lastAccessed:Date.now(),...i?{projectName:i}:{}}),a.slice(0,Li)}function ro(e,t,n){if(e==="opencode"||e==="opencode2")return n;const r=Date.now(),o=n.find(i=>i.path===e);if(o){const i={...o,lastUsed:r,version:t??o.version},a=n.filter(c=>c.path!==e);return[i,...a]}return[t?{path:e,version:t,lastUsed:r}:{path:e,lastUsed:r},...n].slice(0,10)}function Gi(e,t){const n=e.id?t.find(o=>o.id===e.id):void 0,r=new Date().toISOString();return{id:(n==null?void 0:n.id)??e.id??Ji(),name:e.name.trim(),baseUrl:e.baseUrl.trim(),skipTlsVerify:!!e.skipTlsVerify,createdAt:(n==null?void 0:n.createdAt)??r,updatedAt:r,lastConnectedAt:n==null?void 0:n.lastConnectedAt}}function oo(e,t){const n=t.filter(r=>r.id!==e.id);return[e,...n].sort((r,o)=>{const s=r.lastConnectedAt??r.updatedAt;return(o.lastConnectedAt??o.updatedAt).localeCompare(s)})}function Ji(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`remote-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}const[mt,Lt]=M({}),[qi,Rt]=M({}),[fe,Nt]=M({}),[so,st]=M(!1),Yi=F(()=>Qr(mt().settings)),Xi=F(()=>fe().theme??mt().theme??"system"),In=F(()=>$i(fe().colorSchemeOverrides)),Bn=F(()=>{const e=U(fe().colorScheme??mt().colorScheme,Xi());if(e.id==="custom")return e.appearance==="dark"&&!fe().activeColorSchemePresetId&&Ti(e.colors)?U("basalt"):e;if(e.id==="system")return e;const t=In()[e.id];return t?U({...e,colors:t}):e}),Zi=F(()=>{const e=fe(),t=mt(),n=e.customColorScheme??t.customColorScheme??(Bn().id==="custom"&&!e.activeColorSchemePresetId?e.colorScheme??t.colorScheme:void 0),r=typeof n=="object"&&n!==null&&!Array.isArray(n)?{...n,id:"custom"}:{id:"custom"};return U(r)}),be=F(()=>ki(fe().colorSchemePresets)),Ln=F(()=>{const e=fe().activeColorSchemePresetId;return typeof e=="string"&&be()[e]?e:void 0}),Xe=F(()=>Mi(fe().appearancePreferences,Bn(),Ln())),io=F(()=>Xe().mode);function ao(e){const t=Xe()[e],n=t.presetId?be()[t.presetId]:void 0;if((n==null?void 0:n.appearance)===e)return U({id:"custom",...n});const r=t.scheme,o=r.id!=="custom"&&r.id!=="system"?In()[r.id]:void 0;return o?U({...r,colors:o}):r}function Qi(e){var n;const t=Xe()[e].presetId;return t&&((n=be()[t])==null?void 0:n.appearance)===e?t:void 0}const Oe=F(()=>zi(qi())),le=F(()=>Ki(fe())),_=Yi,pt=F(()=>le().recentFolders),Jt=F(()=>le().opencodeBinaries),Je=F(()=>le().remoteServers);let Ot=null;async function qt(){so()||(Ot||(Ot=Promise.all([te.loadConfigOwner("ui"),te.loadConfigOwner("server"),te.loadStateOwner("ui")]).then(([e,t,n])=>{Lt(e),Rt(t),Nt(n),st(!0)}).catch(e=>{x.error("Failed to load settings",e),Lt({}),Rt({}),Nt({}),st(!0)}).finally(()=>{Ot=null})),await Ot)}async function X(e,t){await qt();const n=await te.patchConfigOwner(e,t);e==="ui"&&Lt(n),e==="server"&&Rt(n)}async function k(e,t){await qt();const n=await te.patchStateOwner(e,t);Nt(n)}function J(e){const t=mt(),n=Qr({...t.settings??{},...e}),r={settings:Object.fromEntries(Object.keys(e).map(o=>[o,n[o]]))};return X("ui",r).then(()=>!0,o=>(x.error("Failed to patch ui settings",o),!1))}function co(e){return J(e)}const tt=new Map;let ir=Promise.resolve();const[ea,an]=M(new Map),[ta,ar]=M(new Set);function na(e){return ea().get(e)??Gt(_().modelVisibility[e])}function ra(e){return ta().has(e)}async function oa(e,t){if(!e)return;const n=Gt(t);an(s=>new Map(s).set(e,n)),ar(s=>{const i=new Set(s);return i.delete(e),i});const o=ir.catch(()=>{}).then(()=>X("ui",{settings:{modelVisibility:{[e]:n}}}));ir=o,tt.set(e,o),o.then(()=>{tt.get(e)===o&&(tt.delete(e),an(s=>{const i=new Map(s);return i.delete(e),i}))},s=>{x.error("Failed to update provider model visibility",s),tt.get(e)===o&&(tt.delete(e),an(i=>{const a=new Map(i);return a.delete(e),a}),ar(i=>new Set(i).add(e)))}),await o}function sa(e){const t=V.then(()=>k("ui",{appearancePreferences:{...Xe(),mode:e},theme:e}));return V=t.then(()=>{},()=>{}),t}let V=Promise.resolve();function yt(e,t=null){return{appearancePreferences:Di(Xe(),e,t),theme:e.appearance==="system"?"system":io()}}function lo(e){const t=U(e),r={theme:t.appearance==="system"?"system":t.appearance,colorScheme:Xr(t),...t.id==="custom"?{customColorScheme:t}:{},activeColorSchemePresetId:null},o=V.then(()=>k("ui",{...r,...yt(t)}));return V=o.then(()=>{},()=>{}),o.then(()=>{}).catch(s=>{throw x.error("Failed to set color scheme",s),s})}function ia(e){const t=be()[e];if(!t)return Promise.resolve();const n=U({id:"custom",appearance:t.appearance,colors:t.colors}),r=V.then(()=>k("ui",{colorScheme:n,activeColorSchemePresetId:e,...yt(n,e)}));return V=r.then(()=>{},()=>{}),r.then(()=>{})}function aa(e,t,n){if(!gt(n))return Promise.reject(new Error("Invalid color scheme override"));if(e==="system")return lo(U({id:"custom",appearance:t,colors:n}));const r=U({id:e,appearance:t,colors:n}),o=V.then(()=>k("ui",{colorScheme:r,colorSchemeOverrides:{[e]:{...n}},activeColorSchemePresetId:null,...yt(r)}));return V=o.then(()=>{},()=>{}),o.then(()=>{})}function ca(e){const t=U(e),n=V.then(()=>k("ui",{colorScheme:Xr(t),colorSchemeOverrides:{[e]:null},activeColorSchemePresetId:null,...yt(t)}));return V=n.then(()=>{},()=>{}),n.then(()=>{})}function la(e,t,n,r){const o=e.trim().slice(0,80);if(!o||!gt(n))return Promise.reject(new Error("Invalid color scheme preset"));if(!r&&Object.keys(be()).length>=Zr)return Promise.reject(new Error("Color scheme preset limit reached"));if(r&&!be()[r])return Promise.reject(new Error("Unknown color scheme preset"));const s=r??Ii(),i=U({id:"custom",appearance:t,colors:n}),a=V.then(()=>k("ui",{colorScheme:i,colorSchemePresets:{[s]:{name:o,appearance:t,colors:{...n}}},activeColorSchemePresetId:s,...yt(i,s)}));return V=a.then(()=>{},()=>{}),a.then(()=>s)}function ua(e){if(!be()[e])return Promise.resolve();const t=V.then(()=>k("ui",{colorSchemePresets:{[e]:null},appearancePreferences:Object.fromEntries(["light","dark"].filter(n=>Xe()[n].presetId===e).map(n=>[n,{scheme:ao(n),presetId:null}])),...Ln()===e?{activeColorSchemePresetId:null}:{}}));return V=t.then(()=>{},()=>{}),t.then(()=>{})}async function da(e){Oe().listeningMode!==e&&await X("server",{listeningMode:e})}function uo(e){X("server",{environmentVariables:e}).catch(t=>x.error("Failed to update environment variables",t))}function fa(e,t,n=!0){const r=Oe().environmentVariables;uo({...r,[e]:t});const o=Oe().secureEnvVars,s=e.toUpperCase(),i=o.some(a=>a.toUpperCase()===s);if(n){if(!i){const a=[...o,e];X("server",{secureEnvVars:a}).catch(c=>x.error("Failed to add secure env var",c))}}else if(i){const a=o.filter(c=>c.toUpperCase()!==s);X("server",{secureEnvVars:a}).catch(c=>x.error("Failed to remove secure env var",c))}}function ha(e){X("server",{environmentVariables:{[e]:null}}).catch(t=>x.error("Failed to remove environment variable",t))}function ga(e){return Oe().secureEnvVars.some(n=>n.toUpperCase()===e.toUpperCase())}function ma(e){const t=Oe().secureEnvVars,n=e.toUpperCase(),o=t.some(s=>s.toUpperCase()===n)?t.filter(s=>s.toUpperCase()!==n):[...t,e];X("server",{secureEnvVars:o}).catch(s=>x.error("Failed to update secure env vars",s))}function pa(e){const t=e&&e.trim().length>0?e:"opencode2";X("server",{opencodeBinary:t}).catch(r=>x.error("Failed to set default binary",r));const n=ro(t,void 0,Jt());k("ui",{opencodeBinaries:n}).catch(r=>x.error("Failed to update binary list",r))}function ya(e){X("server",{logLevel:e??"DEBUG"}).catch(n=>x.error("Failed to set log level",n))}async function ba(e){const t=fi(e);try{await X("server",{speech:t})}catch(n){throw x.error("Failed to update speech settings",n),n}}function Ca(e,t){const n=ro(e,t,Jt());k("ui",{opencodeBinaries:n}).catch(r=>x.error("Failed to add binary",r))}function Sa(e){const t=Jt().filter(n=>n.path!==e);k("ui",{opencodeBinaries:t}).catch(n=>x.error("Failed to remove binary",n)),Oe().opencodeBinary===e&&X("server",{opencodeBinary:"opencode2"}).catch(n=>x.error("Failed to reset default binary",n))}function wa(e){const t=no(e,pt());k("ui",{recentFolders:t}).catch(n=>x.error("Failed to add recent folder",n))}function Aa(e){const t=pt().filter(n=>n.path!==e);k("ui",{recentFolders:t}).catch(n=>x.error("Failed to remove recent folder",n))}async function va(e,t){const n=t.trim();if(!e||!n)return;const r=pt().map(o=>o.path===e?{...o,projectName:n}:o);try{await k("ui",{recentFolders:r})}catch(o){throw x.error("Failed to rename recent folder",o),o}}async function xa(e){const t=Gi(e,Je());return await k("ui",{remoteServers:oo(t,Je())}),t}async function Ea(e){const t=Je().find(o=>o.id===e);if(!t)return;const n=new Date().toISOString(),r={...t,updatedAt:n,lastConnectedAt:n};await k("ui",{remoteServers:oo(r,Je())})}function Oa(e){const t=Je().filter(n=>n.id!==e);k("ui",{remoteServers:t}).catch(n=>x.error("Failed to remove remote server",n))}function Pa(e,t){const n=no(e,pt(),t);k("ui",{recentFolders:n}).catch(r=>x.error("Failed to update ui state on launch",r))}function Ma(e){if(!e.providerId||!e.modelId)return;const n=le().models.recents.filter(o=>o.providerId!==e.providerId||o.modelId!==e.modelId),r=[e,...n].slice(0,Ri);k("ui",{models:{recents:r}}).catch(o=>x.error("Failed to update model recents",o))}function Fa(e){return!e.providerId||!e.modelId?!1:le().models.favorites.some(t=>t.providerId===e.providerId&&t.modelId===e.modelId)}function Da(e){if(!e.providerId||!e.modelId)return;const t=le().models.favorites,r=t.some(o=>o.providerId===e.providerId&&o.modelId===e.modelId)?t.filter(o=>o.providerId!==e.providerId||o.modelId!==e.modelId):[e,...t.filter(o=>o.providerId!==e.providerId||o.modelId!==e.modelId)].slice(0,Ni);k("ui",{models:{favorites:r}}).catch(o=>x.error("Failed to update model favorites",o))}function Ta(e){if(!(!e.providerId||!e.modelId))return le().models.thinkingSelections[to(e)]}function ka(e,t){if(!e.providerId||!e.modelId)return;const n=to(e);if(le().models.thinkingSelections[n]===t)return;const o={...le().models.thinkingSelections};t?o[n]=t:delete o[n],k("ui",{models:{thinkingSelections:o}}).catch(s=>x.error("Failed to update thinking selection",s))}function $a(e){_().diffViewMode!==e&&J({diffViewMode:e})}function Ia(e){const t=_();t.toolCallExpansionDefaults.tools.other!==e&&J({toolOutputExpansion:e==="hidden"?t.toolOutputExpansion:e,toolCallExpansionDefaults:{...t.toolCallExpansionDefaults,preset:"custom",tools:{...t.toolCallExpansionDefaults.tools,other:e}}})}function Ba(e){_().diagnosticsExpansion!==e&&J({diagnosticsExpansion:e})}function La(e){_().toolInputsVisibility!==e&&J({toolInputsVisibility:e})}function Ra(e){const t=_();t.thinkingBlocksExpansion===e&&t.toolCallExpansionDefaults.thinking===e||J({thinkingBlocksExpansion:e,toolCallExpansionDefaults:{...t.toolCallExpansionDefaults,preset:"custom",thinking:e}})}function Na(){J({showThinkingBlocks:!_().showThinkingBlocks})}function Ua(){co({showKeyboardShortcutHints:!_().showKeyboardShortcutHints})}function _a(){J({showTimelineTools:!_().showTimelineTools})}function ja(){J({showMessageTimeline:!(_().showMessageTimeline??!0)})}function Wa(){J({showUsageMetrics:!_().showUsageMetrics})}function Va(){J({promptSubmitOnEnter:!_().promptSubmitOnEnter})}function Ka(){J({showPromptVoiceInput:!_().showPromptVoiceInput})}function za(){const e=!_().autoCleanupBlankSessions;x.info("toggle auto cleanup",{value:e}),J({autoCleanupBlankSessions:e})}async function Ha(e,t,n){!e||!t||!n.providerId||!n.modelId||(await Ht(e),await Kr(e,r=>{const o={...r.agentModelSelections??{}},s=o[t];s&&s.providerId===n.providerId&&s.modelId===n.modelId||(o[t]=n,r.agentModelSelections=o)}))}async function Ga(e,t){return!e||!t?void 0:(await Ht(e),(zr(e).agentModelSelections??{})[t])}qt().catch(e=>{x.error("Failed to initialize settings",e)});const fo=qe(),Ja={isLoaded:so,preferences:_,updatePreferences:co,setProviderModelVisibility:oa,getProviderModelVisibilityPreference:na,providerModelVisibilitySaveFailed:ra,themePreference:io,setThemePreference:sa,colorSchemePreference:Bn,getAppearancePalette:ao,getAppearancePresetId:Qi,customColorSchemePreference:Zi,colorSchemeOverrides:In,colorSchemePresets:be,activeColorSchemePresetId:Ln,setColorSchemePreference:lo,selectColorSchemePreset:ia,saveColorSchemeOverride:aa,resetColorSchemeOverride:ca,saveColorSchemePreset:la,deleteColorSchemePreset:ua,serverSettings:Oe,setListeningMode:da,updateEnvironmentVariables:uo,addEnvironmentVariable:fa,removeEnvironmentVariable:ha,isSecureEnvVar:ga,toggleSecureEnvVar:ma,updateLastUsedBinary:pa,updateLogLevel:ya,updateSpeechSettings:ba,recentFolders:pt,opencodeBinaries:Jt,remoteServers:Je,uiState:le,addRecentFolder:wa,removeRecentFolder:Aa,renameRecentFolderProject:va,addOpenCodeBinary:Ca,removeOpenCodeBinary:Sa,saveRemoteServerProfile:xa,markRemoteServerConnected:Ea,removeRemoteServerProfile:Oa,recordWorkspaceLaunch:Pa,addRecentModelPreference:Ma,isFavoriteModelPreference:Fa,toggleFavoriteModelPreference:Da,getModelThinkingSelection:Ta,setModelThinkingSelection:ka,toggleShowThinkingBlocks:Na,toggleKeyboardShortcutHints:Ua,toggleShowMessageTimeline:ja,toggleShowTimelineTools:_a,toggleUsageMetrics:Wa,toggleAutoCleanupBlankSessions:za,togglePromptSubmitOnEnter:Va,toggleShowPromptVoiceInput:Ka,setDiffViewMode:$a,setToolOutputExpansion:Ia,setDiagnosticsExpansion:Ba,setThinkingBlocksExpansion:Ra,setToolInputsVisibility:La,setAgentModelPreference:Ha,getAgentModelPreference:Ga},ku=e=>(Mn(()=>{qt().catch(o=>{x.error("Failed to initialize settings",o)});const t=te.onConfigOwnerChanged("ui",o=>{Lt(o),st(!0)}),n=te.onConfigOwnerChanged("server",o=>{Rt(o),st(!0),di(),ui(!0)}),r=te.onStateOwnerChanged("ui",o=>{Nt(o),st(!0)});return()=>{t(),n(),r()}}),pe(fo.Provider,{value:Ja,get children(){return e.children}}));function qa(){const e=ft(fo);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}function Rn(e,t=0,n=1){return Math.min(Math.max(t,e),n)}function Ya(e){e=e.substr(1);const t=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(t);return n&&n[0].length===1&&(n=n.map(r=>r+r)),n?`rgb${n.length===4?"a":""}(${n.map((r,o)=>o<3?parseInt(r,16):Math.round(parseInt(r,16)/255*1e3)/1e3).join(", ")})`:""}function Pe(e){if(typeof e!="string")return e;if(e.charAt(0)==="#")return Pe(Ya(e));const t=e.indexOf("("),n=e.substring(0,t);if(["rgb","rgba","hsl","hsla","color"].indexOf(n)===-1)throw new Error("MUI: Unsupported `%s` color.\nThe following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). "+e);const r=e.substring(t+1,e.length-1);let o,s;if(n==="color"){if(o=r.split(" "),s=o.shift(),o.length===4&&o[3].charAt(0)==="/"&&(o[3]=o[3].substr(1)),["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(s)===-1)throw new Error("MUI: unsupported `%s` color space.\nThe following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020. "+s)}else o=r.split(",");return{type:n,values:o.map(i=>parseFloat(i)),colorSpace:s}}function Yt(e){const{type:t,colorSpace:n}=e,{values:r}=e;let o;return t.indexOf("rgb")!==-1?o=r.map((s,i)=>i<3?parseInt(s.toString(),10):s).join(","):t.indexOf("hsl")!==-1&&(o=r.map((s,i)=>i===1||i===2?`${s}%`:s).join(",")),t.indexOf("color")!==-1?o=`${n} ${r.join(" ")}`:o=`${r.join(", ")}`,`${t}(${o})`}function Xa(e){const t=Pe(e),{values:n}=t,r=n[0],o=n[1]/100,s=n[2]/100,i=o*Math.min(s,1-s),a=(l,d=(l+r/30)%12)=>s-i*Math.max(Math.min(d-3,9-d,1),-1);let c="rgb";const u=[Math.round(a(0)*255),Math.round(a(8)*255),Math.round(a(4)*255)];return t.type==="hsla"&&(c+="a",u.push(n[3])),Yt({type:c,values:u})}function cr(e){const{type:t,values:n}=Pe(e);let r=t==="hsl"?Pe(Xa(e)).values:n;return r=r.map(o=>(t!=="color"&&(o/=255),o<=.03928?o/12.92:((o+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function Za(e,t){const n=cr(e),r=cr(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function $u(e,t){let{type:n,values:r}=Pe(e);return t=Rn(t),(n==="rgb"||n==="hsl")&&(n+="a"),n==="color"?r[3]=`/${t}`:r[3]=t,Yt({type:n,values:r})}function Qa(e,t){const n=Pe(e);if(t=Rn(t),n.type.indexOf("hsl")!==-1)n.values[2]*=1-t;else if(n.type.indexOf("rgb")!==-1||n.type.indexOf("color")!==-1)for(let r=0;r<3;r+=1)n.values[r]*=1-t;return Yt(n)}function ec(e,t){const n=Pe(e);if(t=Rn(t),n.type.indexOf("hsl")!==-1)n.values[2]+=(100-n.values[2])*t;else if(n.type.indexOf("rgb")!==-1)for(let r=0;r<3;r+=1)n.values[r]+=(255-n.values[r])*t;else if(n.type.indexOf("color")!==-1)for(let r=0;r<3;r+=1)n.values[r]+=(1-n.values[r])*t;return Yt(n)}const tc={xs:0,sm:600,md:900,lg:1200,xl:1536};function nc(e,t,n){const r=e.theme||{};if(Array.isArray(t)){const s=r.breakpoints;return t.reduce((i,a,c)=>(i={...i,...s.up(s.keys[c],n(t[c]))},i),{})}if(typeof t=="object"){const s=r.breakpoints;return Object.keys(t).reduce((a,c)=>{if(Object.keys(s.values||tc).indexOf(c)!==-1)a={...a,...s.up(c,n(t[c],c))};else{const u=c;a[u]=t[u]}return a},{})}return n(t)}const rc={cleanupStyles:!0},oc=qe(rc),Me={black:"#000",white:"#fff"},Ue={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},_e={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},je={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},We={300:"#4fc3f7",400:"#29b6f6",700:"#0288d1",800:"#0277bd",900:"#01579b"},Ve={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"},it={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},sc={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"};function rt(e){return e!==null&&typeof e=="object"&&e.constructor===Object}function ic(e,t){for(const n of t){const r=e[n];delete e[n],e[n]=r}}function Nn(e,t,n={clone:!0}){const r=n.clone?{...e}:e,o=n.sortKeys?[]:void 0;return rt(e)&&rt(t)&&(Object.keys(t).forEach(s=>{if(s==="__proto__")return;o&&o.push(s);let i,a;rt(i=t[s])&&s in e&&rt(a=e[s])?r[s]=Nn(a,i,n):i!==void 0&&(r[s]=i)}),o&&ic(r,o)),r}function wn(e){if(Array.isArray(e)){const t=[];for(const n of e)t.push(wn(n));return t}else if(rt(e)){const t={};for(const n in e)n!=="__proto__"&&(t[n]=wn(e[n]));return t}else return e}function bt(e,...t){for(const n of t)Nn(e,wn(n),{clone:!1});return e}const ac=()=>({text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:Me.white,default:Me.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}),cc={primary:{main:je[700],light:je[400],dark:je[800]},secondary:{main:_e[500],light:_e[300],dark:_e[700]},error:{main:Ue[700],light:Ue[400],dark:Ue[800]},info:{main:We[700],light:We[800],dark:We[900]},success:{main:Ve[800],light:Ve[500],dark:Ve[900]},warning:{main:"#ED6C02",light:it[500],dark:it[900]}},lc=()=>({text:{primary:Me.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:Me.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}}),uc={primary:{main:je[200],light:je[50],dark:je[400]},secondary:{main:_e[200],light:_e[50],dark:_e[400]},error:{main:Ue[500],light:Ue[300],dark:Ue[700]},info:{main:We[400],light:We[300],dark:We[700]},success:{main:Ve[400],light:Ve[300],dark:Ve[700]},warning:{main:it[400],light:it[300],dark:it[700]}},dc={light:ac,dark:lc};function ho(e,t){return Za(e,Me.white)>=t?Me.white:"rgba(0, 0, 0, 0.87)"}function lr(e,t,n,r){const o=typeof r=="number"?r:r.light,s=typeof r=="number"?r*1.5:r.dark;e[t]||(e.hasOwnProperty(n)?e[t]=e[n]:t==="light"?e.light=ec(e.main,o):t==="dark"&&(e.dark=Qa(e.main,s)))}function fc(e){const t={...e.color},n=e.mainShade??500;return!e.color.main&&e.color[n]&&(t.main=e.color[n]),lr(t,"light",e.lightShade??300,e.tonalOffset),lr(t,"dark",e.darkShade??700,e.tonalOffset),t.contrastText||(t.contrastText=ho(t.main,e.contrastThreshold)),t}const hc=()=>({mode:"light",tonalOffset:.2,contrastThreshold:3,grey:sc,common:Me});function gc(e){const t=["error","info","primary","secondary","success","warning"],n=hc(),r={...bt({},n,dc[(e==null?void 0:e.mode)??n.mode](),e),isColorName(s){return t.includes(s)},getColorObject(s){return r[s]},getColor(s){return r.mode==="light"?r[s].light:r[s].dark},augmentColor(s){return fc({...s,tonalOffset:r.tonalOffset,contrastThreshold:r.contrastThreshold})},getContrastText(s){return ho(s,r.contrastThreshold)}},o=s=>r.mode==="light"?cc[s]:uc[s];return r.primary=r.augmentColor({color:r.primary||o("primary")}),r.secondary=r.augmentColor({color:r.secondary||o("secondary"),mainShade:"A400",lightShade:"A200",darkShade:"A700"}),r.error=r.augmentColor({color:r.error||o("error")}),r.warning=r.augmentColor({color:r.warning||o("warning")}),r.info=r.augmentColor({color:r.info||o("info")}),r.success=r.augmentColor({color:r.success||o("success")}),r}const mc={};function pc(e){return{...bt({},mc,e??{})}}function yc(e,t=void 0,n={}){return{toolbar:{minHeight:56,[`${e.up("xs")} and (orientation: landscape)`]:{minHeight:48},[e.up("sm")]:{minHeight:64}},...n}}const cn={},bc=.2,Cc=.14,Sc=.12;function P(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${bc})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Cc})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Sc})`].join(",")}const wc=[()=>"none",()=>P(0,2,1,-1,0,1,1,0,0,1,3,0),()=>P(0,3,1,-2,0,2,2,0,0,1,5,0),()=>P(0,3,3,-2,0,3,4,0,0,1,8,0),()=>P(0,2,4,-1,0,4,5,0,0,1,10,0),()=>P(0,3,5,-1,0,5,8,0,0,1,14,0),()=>P(0,3,5,-1,0,6,10,0,0,1,18,0),()=>P(0,4,5,-2,0,7,10,1,0,2,16,1),()=>P(0,5,5,-3,0,8,10,1,0,3,14,2),()=>P(0,5,6,-3,0,9,12,1,0,3,16,2),()=>P(0,6,6,-3,0,10,14,1,0,4,18,3),()=>P(0,6,7,-4,0,11,15,1,0,4,20,3),()=>P(0,7,8,-4,0,12,17,2,0,5,22,4),()=>P(0,7,8,-4,0,13,19,2,0,5,24,4),()=>P(0,7,9,-4,0,14,21,2,0,5,26,4),()=>P(0,8,9,-5,0,15,22,2,0,6,28,5),()=>P(0,8,10,-5,0,16,24,2,0,6,30,5),()=>P(0,8,11,-5,0,17,26,2,0,6,32,5),()=>P(0,9,11,-5,0,18,28,2,0,7,34,6),()=>P(0,9,12,-6,0,19,29,2,0,7,36,6),()=>P(0,10,13,-6,0,20,31,3,0,8,38,7),()=>P(0,10,13,-6,0,21,33,3,0,8,40,7),()=>P(0,10,14,-6,0,22,35,3,0,8,42,7),()=>P(0,11,14,-7,0,23,36,3,0,9,44,8),()=>P(0,11,15,-7,0,24,38,3,0,9,46,8)];function Ac(){return new Proxy([],{get:(e,t)=>typeof t!="string"||isNaN(Number(t))?e[t]:t in cn?cn[t]:cn[t]=wc[t]()})}const vc={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},xc={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function ur(e){return`${Math.round(e)}ms`}function Ec(e){if(!e)return 0;const t=e/36;return Math.round((4+15*t**.25+t/5)*10)}function Oc(e){const t={...vc,...e.easing},n={...xc,...e.duration};return{getAutoHeightDuration:Ec,create:(o=["all"],s={})=>{const{duration:i=n.standard,easing:a=t.easeInOut,delay:c=0,...u}=s;return(Array.isArray(o)?o:[o]).map(l=>`${l} ${typeof i=="string"?i:ur(i)} ${a} ${typeof c=="string"?c:ur(c)}`).join(",")},...e,easing:t,duration:n}}const z={light:300,regular:400,medium:500},Pt={fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif',fontSize:14,htmlFontSize:16,h1:{},h2:{},h3:{},h4:{},h5:{},h6:{},subtitle1:{},subtitle2:{},body1:{},body2:{},button:{},caption:{},overline:{},fontWeightLight:300,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:700};function Pc(e){return Math.round(e*1e5)/1e5}function H(e,t,n,r,o,s){return{fontFamily:e.fontFamily,fontWeight:t,fontSize:e.pxToRem(n),lineHeight:`${r}`,letterSpacing:`${Pc(o/n)}em`,...s?{textTransform:"uppercase"}:{}}}function Mc(e={}){const t={fontFamily:e.fontFamily??Pt.fontFamily,fontSize:e.fontSize??Pt.fontSize,htmlFontSize:(e==null?void 0:e.htmlFontSize)??Pt.htmlFontSize,pxToRem:n=>{const r=t.fontSize/14;return`${n/t.htmlFontSize*r}rem`}};return bt(Pt,t,{h1:H(t,z.light,96,1.167,-1.5),h2:H(t,z.light,60,1.2,-.5),h3:H(t,z.regular,48,1.167,0),h4:H(t,z.regular,34,1.235,.25),h5:H(t,z.regular,24,1.334,0),h6:H(t,z.medium,20,1.6,.15),subtitle1:H(t,z.regular,16,1.75,.15),subtitle2:H(t,z.medium,14,1.57,.1),body1:H(t,z.regular,16,1.5,.15),body2:H(t,z.regular,14,1.43,.15),button:H(t,z.medium,14,1.75,.4,!0),caption:H(t,z.regular,12,1.66,.4),overline:H(t,z.regular,12,2.66,1,!0)},e)}const Fc={mobileStepper:1e3,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Dc(e){return{...bt({},Fc,e)}}function ln(e,t,n="px"){let r;if(e==="up")r=`(min-width:${t}${n})`;else if(e==="down")r=`(max-width:${t}${n})`;else if(e==="between"){const[o,s]=t;r=`(max-width:${o}${n}) and (min-width:${s}${n})`}else throw new Error(`Invalid comparator: ${e}`);return`@media ${r}`}const Tc={columns:12,keys:["xs","sm","md","lg","xl"],values:{xs:0,sm:600,md:900,lg:1200,xl:1536},unit:"px"};function go(e){const t={...Tc,...e??{},up:(n,r)=>{const o=ln("up",t.resolve(n));return r?{[o]:r}:o},down:(n,r)=>{const o=ln("down",t.resolve(n));return r?{[o]:r}:o},between:(n,r)=>{const o=ln("between",[t.resolve(n[0]),t.resolve(n[1])]);return r?{[o]:r}:o},resolve:n=>typeof n=="number"?n:t.values[n]};return t}function mo(e){return typeof e=="function"?e:(...n)=>n.map(r=>typeof r=="number"?`${r*(e??8)}px`:r).join(" ")}const kc={borderRadius:4};function po(e){return{...bt({},kc,e)}}function yo(e={}){const t={direction:"ltr",...e};function n(r,o){const s=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,...typeof s=="function"?{get:s}:{value:o({[r]:s})}})}return n("breakpoints",r=>go(r.breakpoints)),n("components",r=>pc(r.components)),n("palette",r=>gc(r.palette)),n("shape",r=>po(r.shape)),n("spacing",r=>mo(r.spacing)),n("typography",r=>Mc(r.typography)),n("shadows",()=>Ac()),n("transitions",()=>Oc({})),n("zIndex",r=>Dc(r.zIndex)),n("mixins",()=>yc(t.breakpoints)),t}function bo(e){let t;return function(){return t||(t=e()),t}}const $c=bo(yo);let Co;Co=qe({});const Xt=Co;function Ic(e){return{direction:"ltr",shadows:void 0,transitions:void 0,components:void 0,palette:void 0,typography:void 0,zIndex:void 0,mixins:void 0,...e,breakpoints:go(e==null?void 0:e.breakpoints),shape:po(e==null?void 0:e.shape),spacing:mo(e==null?void 0:e.spacing)}}const Bc=bo(Ic);function Lc(e){for(const t in e)return!1;return!0}function Un(e=Bc,t=Xt){const n=ft(t);if(typeof n=="function")return new Proxy({},{get:(r,o)=>n()[o]});if(Lc(n)&&e)return typeof e=="function"?e():e;if(!n)throw new Error("Theme is not defined");return n}function So(e=$c){return Un(e,Xt)}function Rc(e){return Un(e,Xt)}function Nc(e){var s,i;const t=[],n=typeof e.propDefaults=="function"?e.propDefaults({set:a=>a,inProps:e.props}):e.propDefaults,o=(i=(s=Rc().components)==null?void 0:s[e.name])==null?void 0:i.defaultProps;return n&&t.push(n),o&&t.push(o),t.length?vr(...t,e.props):e.props}function Uc(e){return pe(Xt.Provider,{get value(){return e.theme},get children(){return e.children}})}function _c(e,t=!1){return t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}function jc(e,t){switch(typeof e){case"function":return Object.assign(e,{[Go]:!0}),at(()=>e(t));case"string":const n=xr.has(e),r=L.context?Pr():_c(e,n);return Or(r,t,n),r}}function wo(e,t){const n=F(e);return F(()=>jc(n(),t))}function Iu(e){const[t,n]=Vt(e,["$component"]);return wo(()=>t.$component,n)}function Wc(e){const t=e.reduce((n,r)=>("name"in r&&(n[`--${r.name}`]="0"),Nn(n,r,{clone:!1,sortKeys:!0}),n),{});return delete t.name,t}function Ao(e){return e.startsWith("--")}function Vc(e){return e.startsWith("__")}function vo(e){return/[^a-z-]/i.test(e)&&!Ao(e)}function xo(e){return e.startsWith("@global")}function An(e){return e.startsWith("@media")}function Eo(e){return e.startsWith("@keyframes")}function dr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function fr(e,t,n=[],r={}){const o=e.split(",").map(s=>(s=s.trim(),s.includes("&")?s:`& ${s}`));return Ut(t,(n.length?n:[""]).flatMap(s=>o.map(i=>i.replace(/&/g,s).trim())),{...r})}function hr(e,t){if(!t)return dr(e);let n=t.get(e);return n||(t.set(e,n=dr(e)),n)}function Ut(e,t=[],n={}){const r=[],o=[];for(let i in e){const a=e[i];if(!Vc(i))if(xo(i))for(const c in a)o.push(...fr(c,a[c],[],n));else if(An(i))o.push(...Ut(a,t,{...n,sublevel:!0}).map(c=>`${i} {
2
- ${c}
3
- }`));else if(Ao(i))a!=null&&r.push(`${i}: ${a};`);else if(Eo(i)){const c=[];for(const u in a)c.push(...Ut(a[u],[/^\d+$/.test(u)?`${u}%`:u],{...n,sublevel:!0}));o.push(`${i} {
4
- ${c.join(`
5
- `)}
6
- }`)}else if(vo(i))o.push(...fr(i,a,t,n));else if(n.extraProperties&&i in n.extraProperties){const c=n.extraProperties[i](a);for(const u in c){const l=c[u],d=n.onPropertyValue?n.onPropertyValue(u,l):l;d!=null&&r.push(`${hr(u,n.propertyNameCache)}: ${d};`)}}else{i=hr(i,n.propertyNameCache);const c=n.onPropertyValue?n.onPropertyValue(i,a):a;c!=null&&r.push(`${i}: ${c};`)}}const s=i=>{const a=" ".repeat(i);return`${a}${r.join(`
7
- ${a}`)}`};if(t.length){const i=n.sublevel?" ":"",a=i+t.join(`,
8
- ${i}`);return[...r.length?[`${a} {
9
- ${s(n.sublevel?2:1)}
10
- ${i}}`]:[],...o]}else return[...r.length?[s(0)]:[],...o]}function Kc(e){return e?Array.isArray(e)?e:[e]:[]}function zc(e){return typeof e=="function"&&(e=e()),e}class Hc{constructor(){At(this,"ids",new Map);At(this,"rules",new Map);At(this,"propertyNames",new Map)}create(t,n,r){let o=this.rules.get(n);if(o)return o;let s=this.ids.get(r);return typeof s=="number"&&(this.ids.set(r,++s),r+=`_${s}`),o=Oo(t,n,r),this.save(o,n),o}save(t,n){this.ids.set(t.id,0),this.rules.set(n,t)}delete(t){this.ids.delete(t.id),this.rules.delete(t.rules)}}function Oo(e,t,n){return{id:n,name:e,className:`${e}-${n}`,rules:t.replaceAll("$id",`${n}`)}}function Gc(e){var s,i;const t=`${e.name}-$id`,n=Kc(zc(e.props)),r=(s=e.cache)==null?void 0:s.propertyNames,o=n.map(a=>typeof a=="string"?`.${t} {
11
- ${a}
12
- }`:Ut(a,[`.${t}`],{extraProperties:e.extraProperties,propertyNameCache:r}).join(`
13
- `)).join(`
14
- `);return((i=e.cache)==null?void 0:i.create(e.name,o,e.componentId))||Oo(e.name,o,e.componentId)}function Po(e,t){"styleSheet"in e?e.styleSheet.cssText=t:(e.innerText="",e.appendChild(document.createTextNode(t)))}function Jc(e,t){for(const n in t){const r=t[n];r!==void 0&&(r===null?e.removeAttribute(n):e.setAttribute(n,r))}}function qc(e,t){const n=document.createElement("style");return n.type="text/css",t&&Jc(n,t),Po(n,e),n}function vn(e){let t=Number(e.getAttribute("data-uses"));t++,e.setAttribute("data-uses",t.toString())}const gr="suid-injectFirst";function Yc(e,t,n){Array.isArray(e)&&(e=e.join(`
15
- `));const r=t==null?void 0:t.id,o=document.head||document.getElementsByTagName("head")[0],s=r&&document.getElementById(r);if(s&&s instanceof HTMLStyleElement)return Po(s,e),vn(s),s;{s&&s.remove();const i=qc(e,t);if(vn(i),n){let a=o.querySelector(`#${gr}`);a||(a=document.createElement("style"),a.setAttribute("id",gr),o.prepend(a)),o.insertBefore(i,a)}else o.appendChild(i);return i}}function Xc(e,t="css-"){if(typeof e=="string")return document.getElementById(e);const n=[...e.classList].find(r=>r.startsWith(t));if(n)return document.getElementById(n.slice(t.length))}function mr(e,t=!0){let n=Number(e.getAttribute("data-uses"));n--,n<=0?t?e.remove():e.setAttribute("data-uses","0"):e.setAttribute("data-uses",n.toString())}function Bu(e){if(typeof e!="string")throw new Error("MUI: `capitalize(string)` expects a string argument.");return e.charAt(0).toUpperCase()+e.slice(1)}function Lu(e,t=166){let n;function r(...o){const s=()=>{e.apply(null,o)};clearTimeout(n),n=setTimeout(s,t)}return r.clear=()=>{clearTimeout(n)},r}function Ru(e){const t=e.documentElement.clientWidth;return Math.abs(window.innerWidth-t)}function Zc(e){return e&&e.ownerDocument||document}function Nu(e){return Zc(e).defaultView||window}function Mo(){return Math.random().toString(36).substring(2,15).slice(0,8)}let Zt=!0,xn=!1,pr;const Qc={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function el(e){const{type:t,tagName:n}=e;return!!(n==="INPUT"&&Qc[t]&&!e.readOnly||n==="TEXTAREA"&&!e.readOnly||e.isContentEditable)}function tl(e){e.metaKey||e.altKey||e.ctrlKey||(Zt=!0)}function un(){Zt=!1}function nl(){this.visibilityState==="hidden"&&xn&&(Zt=!0)}function rl(e){e.addEventListener("keydown",tl,!0),e.addEventListener("mousedown",un,!0),e.addEventListener("pointerdown",un,!0),e.addEventListener("touchstart",un,!0),e.addEventListener("visibilitychange",nl,!0)}function ol(e){const{target:t}=e;try{return t.matches(":focus-visible")}catch{}return Zt||el(t)}function Uu(){const e=s=>{s!=null&&rl(s.ownerDocument)},[t,n]=M(!1);function r(){return t()?(xn=!0,window.clearTimeout(pr),pr=window.setTimeout(()=>{xn=!1},100),n(!1),!0):!1}function o(s){return ol(s)?(n(!0),!0):!1}return{isFocusVisibleRef:{get current(){return t()}},onFocus:o,onBlur:r,ref:e}}const sl=new Hc;function il(e){return e?Array.isArray(e)?e.flat(1/0).filter(t=>!!t):[e]:[]}function al(){if(!L.context)return Mo();const e=Jo().replaceAll("-",""),t=9,n=Math.ceil(e.length/t),r=[];for(let o=1;o<=n;++o){const s=(o-1)*t,i=Number(e.slice(s,s+t));r.push(i.toString(32))}return r.join("-")}function Fo(e){const t=ft(oc),[n,r]=M(""),o=al();let s,i=!1;return me(a=>{var l;const c=e();let u;if(c){const d=Wc(il(c));i="@global"in d,u=Gc({name:"css",props:d,cache:sl,componentId:o}),s=Xc(u.id),s?vn(s):s=Yc(u.rules,{id:u.id,nonce:(l=t.cache)==null?void 0:l.nonce},t.injectFirst),a!=null&&a.styleElement&&mr(a.styleElement)}return typeof(u==null?void 0:u.className)=="string"?r(u.className):r(""),{className:u==null?void 0:u.className,styleElement:s}},void 0),ue(()=>{s&&mr(s,t.cleanupStyles??i)}),n}function Ne(e,t,n={}){for(const r in e){const o=e[r];if(xo(r))n[r]=Ne(o,t);else if(An(r))n[r]=Ne(o,t);else if(Eo(r)){n[r]={};for(const s in o)n[r][s]=Ne(o[s],t)}else if(vo(r))n[r]=Ne(o,t);else{const s=t(r,o);if(s)for(const i in s)n[i]=An(i)?{...n[i],...s[i]}:s[i];else n[r]=o}}return n}const cl=new Set(["animationIterationCount","borderImageOutset","borderImageSlice","borderImageWidth","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","columns","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","gridRow","gridRowEnd","gridRowSpan","gridRowStart","gridColumn","gridColumnEnd","gridColumnSpan","gridColumnStart","msGridRow","msGridRowSpan","msGridColumn","msGridColumnSpan","fontWeight","lineHeight","opacity","order","orphans","tabSize","widows","zIndex","zoom","WebkitLineClamp","fillOpacity","floodOpacity","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth"]);function Do(e,t){if(typeof t=="number")return{[e]:cl.has(e)?t.toString():`${t}px`}}function yr(e,t={}){return Ne(e,Do,t)}function _t(e,t,n){if(typeof n!="string")return n;const r=n.split(".");let o=e[t];for(let s=0;s<r.length&&(o=o==null?void 0:o[r[s]],!!o);s++);return o??n}function ll(e,t){return t.split(".").reduce((n,r)=>n&&n[r]?n[r]:null,e)}function ul(e,t,n,r){const o=ll(e,t)||n;return typeof o=="number"?s=>typeof s=="string"?s:o*s:Array.isArray(o)?s=>typeof s=="string"?s:o[s]:typeof o=="function"?o:()=>{}}const he={x:["Left","Right"],y:["Top","Bottom"]};function To(e){return typeof e=="number"?`${e}px`:e}function ko(e,t){return(n,r)=>t(e,n,r)}function h(e,t){return t?(n,r)=>({[e]:t(e,n,r)}):n=>({[e]:n})}function ot(e){return h(e,(t,n)=>To(n))}function q(e,t,n){const r=t.map(o=>`${e}${o}`);return n?(o,s)=>r.reduce((i,a)=>(i[a]=n(a,o,s),i),{}):o=>r.reduce((s,i)=>(s[i]=o,s),{})}function dl(){return{...fl(),...hl(),...gl(),...ml(),...pl(),...yl(),...bl(),...Sl(),...Cl()}}function fl(){return{displayPrint:ko("displayPrint",(e,t)=>({"@media print":{display:t}})),displayRaw:h("display"),overflow:h("overflow"),textOverflow:h("textOverflow"),visibility:h("visibility"),whiteSpace:h("whiteSpace")}}function hl(){return{flexBasis:h("flexBasis"),flexDirection:h("flexDirection"),flexWrap:h("flexWrap"),justifyContent:h("justifyContent"),alignItems:h("alignItems"),alignContent:h("alignContent"),order:h("order"),flex:h("flex"),flexGrow:h("flexGrow"),flexShrink:h("flexShrink"),alignSelf:h("alignSelf"),justifyItems:h("justifyItems"),justifySelf:h("justifySelf")}}function gl(){const e=(t,n,r)=>ul(r,"spacing",8)(n);return{gap:h("gap",e),columnGap:h("columnGap",e),rowGap:h("rowGap",e),gridColumn:h("gridColumn"),gridRow:h("gridRow"),gridAutoFlow:h("gridAutoFlow"),gridAutoColumns:h("gridAutoColumns"),gridAutoRows:h("gridAutoRows"),gridTemplateColumns:h("gridTemplateColumns"),gridTemplateRows:h("gridTemplateRows"),gridTemplateAreas:h("gridTemplateAreas"),gridArea:h("gridArea")}}function ml(){return{position:h("position"),zIndex:h("zIndex",(e,t,n)=>{var r;return((r=n.zIndex)==null?void 0:r[e])??t}),top:ot("top"),right:ot("right"),bottom:ot("bottom"),left:ot("left")}}function pl(){const e=(t,n,r)=>_t(r,"palette",n);return{color:h("color",e),bgcolor:h("backgroundColor",e),backgroundColor:h("backgroundColor",e)}}function yl(){const e=(t,n,r)=>(t==="maxWidth"&&(n=r.breakpoints.values[t]??n),typeof n=="number"&&(n=n>0&&n<=1?`${n*100}%`:`${n}px`),n);return{width:h("width",e),maxWidth:h("maxWidth",e),minWidth:h("minWidth",e),height:h("height",e),maxHeight:h("maxHeight",e),minHeight:h("minHeight",e),boxSizing:h("boxSizing",e)}}function bl(){const e=(n,r)=>typeof r=="number"?`${r}px solid`:r,t=(n,r,o)=>_t(o,"palette",r);return{border:h("border",e),borderTop:h("borderTop",e),borderRight:h("borderRight",e),borderBottom:h("borderBottom",e),borderLeft:h("borderLeft",e),borderColor:h("borderColor",t),borderTopColor:h("borderTopColor",t),borderRightColor:h("borderRightColor",t),borderBottomColor:h("borderBottomColor",t),borderLeftColor:h("borderLeftColor",t),borderRadius:h("borderRadius",(n,r,o)=>typeof r=="number"?`${o.shape.borderRadius*r}px`:r)}}function Cl(){const e=(t,n,r)=>_t(r,"typography",n);return{typography:ko("typography",(t,n,r)=>_t(r,"typography",n)),fontFamily:h("fontFamily",e),fontSize:h("fontSize",(t,n,r)=>To(e(t,n,r))),fontStyle:h("fontStyle",e),fontWeight:h("fontWeight",e),letterSpacing:ot("letterSpacing"),lineHeight:h("lineHeight"),textAlign:h("textAlign"),textTransform:h("textTransform")}}function Sl(){const e=(r,o,s)=>s.spacing(o),t="margin",n="padding";return{m:h(t,e),mt:h("marginTop",e),mr:h("marginRight",e),mb:h("marginBottom",e),ml:h("marginLeft",e),mx:q(t,he.x,e),my:q(t,he.y,e),margin:h(t,e),marginTop:h("marginTop",e),marginRight:h("marginRight",e),marginBottom:h("marginBottom",e),marginLeft:h("marginLeft",e),marginX:q(t,he.x,e),marginY:q(t,he.y,e),marginInline:q(t,["Inline","InlineStart"],e),marginInlineStart:h("marginInlineStart",e),marginInlineEnd:h("marginInlineEnd",e),marginBlock:q(t,["BlockStart","BlockEnd"],e),marginBlockStart:h("marginBlockStart",e),marginBlockEnd:h("marginBlockEnd",e),p:h(n,e),pt:h("paddingTop",e),pr:h("paddingRight",e),pb:h("paddingBottom",e),pl:h("paddingLeft",e),px:q(n,he.x,e),py:q(n,he.y,e),padding:h(n,e),paddingTop:h("paddingTop",e),paddingRight:h("paddingRight",e),paddingBottom:h("paddingBottom",e),paddingLeft:h("paddingLeft",e),paddingX:q(n,he.x,e),paddingY:q(n,he.y,e),paddingInline:q(n,["Inline","InlineStart"],e),paddingInlineStart:h("paddingInlineStart",e),paddingInlineEnd:h("paddingInlineEnd",e),paddingBlock:q(n,["BlockStart","BlockEnd"],e),paddingBlockStart:h("paddingBlockStart",e),paddingBlockEnd:h("paddingBlockEnd",e)}}const _n=dl(),_u=Object.keys(_n);function wl(e,t,n){return _n[e](t,n)}function br(e,t,n){return e in _n?wl(e,t,n):Do(e,t)}function Al(e,t){return Ne(e,(n,r)=>{if(typeof r=="function"&&(r=r(t)),r==null)return r;if(typeof r=="object"){const o={};for(const s of t.breakpoints.keys)o[t.breakpoints.up(s)]={};return Object.assign(o,nc({theme:t},r,s=>br(n,s,t)??{[n]:s}))}else return br(n,r,t)})}function $o(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=$o(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function vl(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=$o(e))&&(r&&(r+=" "),r+=t);return r}const Io=["ownerState","theme","sx","as"];function xl(e,t){var n,r;return(r=(n=t.components)==null?void 0:n[e])==null?void 0:r.styleOverrides}function El(e,t,n,r,o={}){return F(()=>{const s=e(),i=xl(o.name,s),a=r.ownerState,c=n.reduce((l,d)=>{let f;return typeof d=="function"?f=d({ownerState:a,theme:s,get sx(){return r.sx},get as(){return r.as},props:r}):d&&(f=d),f&&l.push(yr(f,{name:t,__resolved:!0})),l},[]);let u=[];return o.overridesResolver&&typeof o.overridesResolver=="function"&&i&&(u=o.overridesResolver(r,i).map(l=>l?yr(l,{}):null).filter(Boolean)),c.concat(u)})}function Bo(e,t){e.__suid=t}function Cr(e){if(typeof e=="function")return e.__suid}function Ol(e){return function(n,r={}){let o,s;if(r.name){const a=r.slot||"Root";s=o=`${r.name}-${a.slice(0,1).toLowerCase()+a.slice(1)}`}else s=`styled-${Mo()}`,o="css";const i=Cr(n);return function(...a){function c(u){let l;const d=()=>{const R=u.theme;return R||l||(l=e&&e.onUseTheme?e.onUseTheme():Un())},[,f]=Vt(u,r.skipProps||Io),g=El(d,o,a,u,r),b=()=>{const R=u.sx;return R?Array.isArray(R)?R:[R]:[]},S=()=>{if(i)return n;const R=u.as;return R||n},w=i?()=>i:F(()=>Cr(S())),y=r.skipSx?()=>g():()=>{const R=d();return[...g(),...b().map(Z=>Z.__resolved?Z:Al(Z,R))]},$=Fo(()=>w()?void 0:y());return wo(S,vr(f,{get children(){return u.children},get component(){return w()?u.component:null},get as(){return i?u.as:void 0},get sx(){return w()?y():void 0},get ownerState(){return w()==="system"?u.ownerState:void 0},get class(){return vl([...new Set([u.class,s,$()])])}}))}return Bo(c,"system"),s&&(c.toString=()=>`.${s}`),c}}}const ju=[...Io,"classes"],Wu=Ol({onUseTheme:()=>So()});function Pl(e,t,n){const r={};return Object.keys(e).forEach(o=>{r[o]=e[o].reduce((s,i)=>(i&&(n&&n[i]&&s.push(n[i]),s.push(t(i))),s),[]).join(" ")}),r}const Ml=Symbol("solid-inspect"),Fl=qe();function Dl(e){function t(n){var r;return(r=ft(Fl))!=null&&r.enabled?{Component:t,props:n,$INSPECT:Ml}:e(n)}return Object.defineProperty(t,"name",{value:e.name}),t.toString=e.toString,t}function Lo(){return function(e){function t(a){const c=!!e.slotClasses,u=()=>{if(!e.slotClasses)throw new Error("'slotClasses' option is not defined");if(!e.utilityClass)throw new Error("'utilityClass' option is not defined");return Pl(e.slotClasses(a),e.utilityClass,a.classes??"")},l=Es({});return c&&qo(()=>{const d=u();xe(()=>{for(const f in d)l[f]=d[f]})}),l}function n(a){const[c,u]=Vt(a,e.selfPropNames);return{allProps:a,props:c,otherProps:u}}function r(a){return Nc({propDefaults:a.propDefaults||e.propDefaults,props:a.props,name:e.name})}function o(a){const c=r({props:a});return n(c)}function s(a,c=!0){return a=Dl(a),a.toString=()=>`.${e.name}-root`,c&&Bo(a,"base"),a}function i(a){const c=s(function(l){const{allProps:d,otherProps:f,props:g}=o(l),b=e.autoCallUseClasses??!0?t(d):{};return a({allProps:d,otherProps:f,props:g,classes:b})});return Object.defineProperty(c,"name",{value:a.name}),c}return{name:e.name,selfPropNames:e.selfPropNames,component:i,defineComponent:s,useClasses:t,useThemeProps:r,useProps:o,splitInProps:n}}}const Tl=Lo()({name:"MuiGlobalStyles",selfPropNames:["styles"]}),kl=Tl.component(function({props:t}){return Fo(()=>({"@global":t.styles||{}})),[]}),$l=Lo()({name:"MuiCssBaseline",selfPropNames:["children","enableColorScheme"],propDefaults:({set:e})=>e({enableColorScheme:!1})}),Il=(e,t)=>({WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",boxSizing:"border-box",WebkitTextSizeAdjust:"100%",...t&&{colorScheme:e.palette.mode}}),Bl=e=>({color:e.palette.text.primary,...e.typography.body1,backgroundColor:e.palette.background.default,"@media print":{backgroundColor:e.palette.common.white}}),Ll=(e,t=!1)=>({html:Il(e,t),"*, *::before, *::after":{boxSizing:"inherit"},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...Bl(e),"&::backdrop":{backgroundColor:e.palette.background.default}}}),Rl=$l.component(function({props:t}){const n=So();return pe(kl,{get styles(){return Ll(n,t.enableColorScheme)}})}),Ro=qe(),Nl={backgroundDefault:"#ffffff",backgroundPaper:"#f5f5f5",primary:"#0066ff",primaryContrast:"#ffffff",textPrimary:"#1a1a1a",textSecondary:"#666666",divider:"#e0e0e0"},Ul={backgroundDefault:"#1a1a1a",backgroundPaper:"#2a2a2a",primary:"#0080ff",primaryContrast:"#1a1a1a",textPrimary:"#cfd4dc",textSecondary:"#999999",divider:"#3a3a3a"},we=(e,t,n)=>{if(!n)return t;const r=n.getPropertyValue(e);return r&&r.trim()||t},_l=e=>{const t=e?Ul:Nl,n=typeof window<"u"?getComputedStyle(document.documentElement):null;return{backgroundDefault:we("--surface-base",t.backgroundDefault,n),backgroundPaper:we("--surface-secondary",t.backgroundPaper,n),primary:we("--accent-primary",t.primary,n),primaryContrast:we("--text-on-accent",t.primaryContrast,n),textPrimary:we("--text-primary",t.textPrimary,n),textSecondary:we("--text-secondary",t.textSecondary,n),divider:we("--border-base",t.divider,n)}};function Vu(e){const t=typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)"):null,n=qa(),[r,o]=M((t==null?void 0:t.matches)??!1),[s,i]=M(!0),[a,c]=M(0),u=()=>n.themePreference(),l=()=>n.getAppearancePalette(Fi(u(),r())),d=()=>{const y=Pi(l(),{systemDark:t==null?void 0:t.matches});i(y),typeof window<"u"?requestAnimationFrame(()=>c($=>$+1)):c($=>$+1)};G(()=>{d()});const f=y=>o(y.matches);t==null||t.addEventListener("change",f),ue(()=>t==null?void 0:t.removeEventListener("change",f));const g=y=>{n.setColorSchemePreference(U(y))},b=y=>{n.setThemePreference(y)},S=()=>{const y=u();b(y==="system"?"light":y==="light"?"dark":"system")},w=F(()=>{a();const y=_l(s());return yo({palette:{mode:s()?"dark":"light",primary:{main:y.primary,contrastText:y.primaryContrast},secondary:{main:y.primary},background:{default:y.backgroundDefault,paper:y.backgroundPaper},text:{primary:y.textPrimary,secondary:y.textSecondary},divider:y.divider},typography:{fontFamily:"var(--font-family-sans)"},shape:{borderRadius:0},components:{MuiIconButton:{styleOverrides:{root:{color:"inherit",borderRadius:0,padding:"6px","&.Mui-disabled":{color:"var(--text-muted)",opacity:.55}}}},MuiDrawer:{styleOverrides:{paper:{backgroundColor:"var(--surface-secondary)",color:"var(--text-primary)"}}},MuiAppBar:{styleOverrides:{root:{backgroundColor:"var(--surface-secondary)",color:"var(--text-primary)",boxShadow:"none",borderBottom:"1px solid var(--border-base)",zIndex:10}}},MuiToolbar:{styleOverrides:{root:{minHeight:"40px"}}}}})});return pe(Ro.Provider,{value:{isDark:s,themeMode:u,setThemeMode:b,cycleThemeMode:S,colorScheme:l,setColorScheme:g},get children(){return pe(Uc,{get theme(){return w()},get children(){return[pe(Rl,{}),is(()=>e.children)]}})}})}function No(){const e=ft(Ro);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}const jl="0.52.2",En=`https://cdn.jsdelivr.net/npm/monaco-editor@${jl}/min/vs`,ee="/monaco/vs";let Mt=null;function Wl(e,t){return new Promise((n,r)=>{const o=setTimeout(()=>r(new Error("timeout")),t);e.then(s=>{clearTimeout(o),n(s)}).catch(s=>{clearTimeout(o),r(s)})})}async function Vl(){if(typeof fetch>"u")return!1;try{const e=new AbortController,t=fetch(`${En}/loader.js`,{method:"HEAD",signal:e.signal}),n=await Wl(t,1200);return e.abort(),n.ok}catch{return!1}}function Kl(){return typeof document>"u"||document.querySelector('script[data-monaco-loader="true"]')?Promise.resolve():new Promise((t,n)=>{const r=document.createElement("script");r.dataset.monacoLoader="true",r.src=`${ee}/loader.js`,r.async=!0,r.onload=()=>t(),r.onerror=()=>n(new Error("Failed to load Monaco AMD loader")),document.head.appendChild(r)})}function zl(){if(typeof document>"u"||document.querySelector('link[data-monaco-editor-css="true"]'))return;const t=document.createElement("link");t.rel="stylesheet",t.href=`${ee}/editor/editor.main.css`,t.dataset.monacoEditorCss="true",document.head.appendChild(t)}function Hl(){const e=globalThis,t=e.MonacoEnvironment??{},n="/monaco.worker.js";e.MonacoEnvironment={...t,getWorkerUrl(r,o){return n}}}function Uo(){const e=globalThis.require;if(!e)throw new Error("Monaco AMD loader is not available");return e}function Gl(){const t=Uo().config;if(!t)throw new Error("require.config is not available");return t}function On(e){const t=Uo();return new Promise((n,r)=>{t(e,(...o)=>n(o),o=>r(o))})}function Jl(e){const t=String(e||"plaintext");return!t||t==="plaintext"?null:t==="typescript"||t==="javascript"?"vs/language/typescript/monaco.contribution":t==="json"?"vs/language/json/monaco.contribution":t==="css"||t==="scss"||t==="less"?"vs/language/css/monaco.contribution":t==="html"?"vs/language/html/monaco.contribution":t==="toml"?"vs/basic-languages/toml/toml":`vs/basic-languages/${t}/${t}`}const Sr=new Set,dn=new Map;async function _o(e){const t=Jl(e);if(!t||Sr.has(t))return;const n=dn.get(t);if(n)return n;const r=(async()=>{let o=!1;try{await On([t]),o=!0}catch{}finally{o&&Sr.add(t),dn.delete(t)}})();return dn.set(t,r),r}async function jo(){return Mt||(Mt=(async()=>{await Kl(),Hl(),zl();const e=await Vl(),t=Gl(),n={vs:ee};e&&(n["vs/basic-languages"]=`${En}/basic-languages`,n["vs/language"]=`${En}/language`,n["vs/basic-languages/python"]=`${ee}/basic-languages/python`,n["vs/basic-languages/markdown"]=`${ee}/basic-languages/markdown`,n["vs/basic-languages/cpp"]=`${ee}/basic-languages/cpp`,n["vs/basic-languages/kotlin"]=`${ee}/basic-languages/kotlin`,n["vs/language/typescript"]=`${ee}/language/typescript`,n["vs/language/html"]=`${ee}/language/html`,n["vs/language/json"]=`${ee}/language/json`,n["vs/language/css"]=`${ee}/language/css`),t({paths:n,ignoreDuplicateModules:["vs/editor/editor.main"]});const[r]=await On(["vs/editor/editor.main"]);return await On(["vs/basic-languages/monaco.contribution"]).catch(()=>[]),globalThis.monaco??r})(),Mt)}const ql=5,ge=new Map;function Yl(e,t){ge.delete(e),ge.set(e,t)}function Xl(){for(;ge.size>ql;){const e=ge.keys().next().value;if(!e)return;const t=ge.get(e);ge.delete(e);try{t==null||t.model.dispose()}catch{}}}function Pn(e){const t=ge.get(e.cacheKey);if(t)return Yl(e.cacheKey,t),t.model.getValue()!==e.value&&t.model.setValue(e.value),t.model;const n=e.monaco.Uri.parse(`opencode://model/${encodeURIComponent(e.cacheKey)}`),r=e.monaco.editor.createModel(e.value,"plaintext",n),o={model:r};return ge.set(e.cacheKey,o),Xl(),r}let Ft=null;function Zl(e){var o;if(Ft)return Ft;const t=new Map,n=new Map,r=typeof((o=e==null?void 0:e.languages)==null?void 0:o.getLanguages)=="function"?e.languages.getLanguages():[];if(Array.isArray(r))for(const s of r){const i=typeof(s==null?void 0:s.id)=="string"?s.id:null;if(!i)continue;const a=Array.isArray(s==null?void 0:s.filenames)?s.filenames:[];for(const u of a)typeof u=="string"&&(t.has(u)||t.set(u,i));const c=Array.isArray(s==null?void 0:s.extensions)?s.extensions:[];for(const u of c)typeof u=="string"&&(n.has(u)||n.set(u,i))}return Ft={fileNameToId:t,extToId:n},Ft}function Ql(e){return e===".gitignore"||e===".gitattributes"||e===".gitmodules"||e==="Makefile"||e.startsWith("Makefile.")?"shell":null}function Wo(e,t){const n=String(t||"").trim(),r=n.split("/").pop()||n,o=Ql(r);if(o)return o;const s=Zl(e),i=s.fileNameToId.get(r);if(i)return i;const a=r.lastIndexOf(".");if(a>0){const c=r.slice(a),u=s.extToId.get(c);if(u)return u}return"plaintext"}var eu=Fn("<div class=monaco-viewer>");function tu(e){const{isDark:t}=No();let n,r=null,o=null;const[s,i]=M(!1),a=()=>{try{r==null||r.setModel(null)}catch{}try{r==null||r.dispose()}catch{}r=null},c=()=>{!r||!e.onSave||e.onSave(r.getValue())},u=l=>{if(!e.compactGutter)return 5;const d=l.split(/\r\n|\r|\n/).length;return Math.max(3,String(d).length+1)};return Mn(()=>{let l=!1;(async()=>(o=await jo(),!l&&(!n||!o||(o.editor.setTheme(t()?"vs-dark":"vs"),r=o.editor.create(n,{value:"",language:"plaintext",readOnly:!1,automaticLayout:!0,lineNumbers:"on",lineNumbersMinChars:u(e.content),glyphMargin:!1,folding:!e.compactGutter,lineDecorationsWidth:e.compactGutter?8:10,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",renderWhitespace:"selection",fontSize:13}),r.addCommand(o.KeyMod.CtrlCmd|o.KeyCode.KeyS,c),r.onDidChangeModelContent(()=>{e.onContentChange&&e.onContentChange(r.getValue())}),i(!0)))))(),ue(()=>{l=!0,i(!1),a()})}),G(()=>{!s()||!o||!r||o.editor.setTheme(t()?"vs-dark":"vs")}),G(()=>{!s()||!r||r.updateOptions({wordWrap:e.wordWrap==="on"?"on":"off"})}),G(()=>{!s()||!r||r.updateOptions({lineNumbersMinChars:u(e.content),folding:!e.compactGutter,lineDecorationsWidth:e.compactGutter?8:10})}),G(()=>{if(!s()||!o||!r)return;const l=Wo(o,e.path),d=`${e.scopeKey}:file:${e.path}`,f=Pn({monaco:o,cacheKey:d,value:e.content});r.setModel(f),_o(l).then(()=>{try{o.editor.setModelLanguage(f,l)}catch{}})}),(()=>{var l=eu(),d=n;return typeof d=="function"?Dn(d,l):n=l,l})()}const Ku=Object.freeze(Object.defineProperty({__proto__:null,MonacoFileViewer:tu},Symbol.toStringTag,{value:"Module"})),nu=/(^|\n)@@/m,ru=/(^|\n)(diff --git |--- |\+\+\+)/,ou=/^\*\*\* (Begin|End) Patch/,su=/^\*\*\* Update File: (.+)$/,iu=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function au(e){const t=e.trim();if(!t.startsWith("```"))return t;const n=t.split(`
16
- `);return n.length<2?"":n[n.length-1].startsWith("```")?n.slice(1,-1).join(`
17
- `):t}function cu(e){var s;if(!e)return"";const n=au(e.replace(/\r\n/g,`
18
- `)).split(`
19
- `).map(i=>i.replace(/\s+$/u,""));let r=null;const o=[];for(const i of n){if(!i||ou.test(i))continue;const a=i.match(su);if(a){r=((s=a[1])==null?void 0:s.trim())||null;continue}o.push(i)}return r&&!ru.test(o.join(`
20
- `))&&(o.unshift(`+++ b/${r}`),o.unshift(`--- a/${r}`)),o.join(`
21
- `).trim()}function zu(e){if(!e)return!1;const t=cu(e);return t?nu.test(t):!1}function lu(e){if(!e||e.trim().length===0)return{before:"",after:""};const t=e.replace(/\r\n/g,`
22
- `).split(`
23
- `),n=[],r=[];for(const o of t)o.startsWith("---")||o.startsWith("+++")||o.startsWith("diff --git")||iu.test(o)||(o.startsWith("-")&&!o.startsWith("---")?n.push(o.slice(1)):o.startsWith("+")&&!o.startsWith("+++")?r.push(o.slice(1)):o.startsWith(" ")?(n.push(o.slice(1)),r.push(o.slice(1))):o===""?(n.push(""),r.push("")):(n.push(o),r.push(o)));for(;n.length>0&&n[n.length-1]==="";)n.pop();for(;r.length>0&&r[r.length-1]==="";)r.pop();return{before:n.join(`
24
- `),after:r.join(`
25
- `)}}var uu=Fn("<div class=monaco-viewer><div class=git-change-context-overlay>"),du=Fn("<div class=git-change-context-widget-host><button type=button class=git-change-context-widget>+");function jt(e){return e?e.split(`
26
- `).length:1}function Wt(e){return String(Math.max(1,e)).length}function fu(e){const t=jt(e.before),n=jt(e.after),r=Wt(t),o=Wt(n),s=Math.max(r,o),i=Math.max(0,s-2),a=Math.max(2,r),c=Math.max(2,o),u=Math.max(0,s-3);return{diffEditorLineNumbersMinChars:Math.max(a,c),originalLineNumbersMinChars:a,modifiedLineNumbersMinChars:c,lineDecorationsWidth:6+i*2+u*2}}function hu(e){const t=jt(e.before),n=jt(e.after),r=Wt(t),o=Wt(n),s=Math.max(r,o),i=Math.max(0,s-2),a=Math.max(2,r),c=Math.max(2,o),u=Math.max(0,s-3);return{diffEditorLineNumbersMinChars:Math.max(a,c),originalLineNumbersMinChars:a,modifiedLineNumbersMinChars:c,lineDecorationsWidth:8+i*2+u}}function gu(e){const{isDark:t}=No();let n,r=null,o=null,s=null;const[i,a]=M(!1),[c,u]=M(null),[l,d]=M(null),[f,g]=M(!1),[b,S]=M(null),w=F(()=>e.patch!==void 0&&e.patch!==null?lu(e.patch):{before:e.before??"",after:e.after??""}),y=()=>{try{r==null||r.setModel(null)}catch{}try{r==null||r.dispose()}catch{}r=null},$=()=>{n&&(n.style.removeProperty("--split-original-line-number-width"),n.style.removeProperty("--split-original-delete-sign-left"),n.style.removeProperty("--split-original-gutter-width"))},R=m=>{if(n){if(s!==null&&typeof window<"u"&&(window.cancelAnimationFrame(s),s=null),m.viewMode!=="split"||typeof window>"u"){$();return}s=window.requestAnimationFrame(()=>{if(s=null,!n)return;const C=n.querySelector(".editor.original .line-numbers"),O=(C==null?void 0:C.getBoundingClientRect().width)??0,v=O>0?O:Math.max(12,m.originalLineNumbersMinChars*6);n.style.setProperty("--split-original-line-number-width",`${v}px`),n.style.setProperty("--split-original-delete-sign-left",`${v}px`),n.style.setProperty("--split-original-gutter-width",`${v+m.lineDecorationsWidth}px`)})}},Z=()=>{var m;return((m=r==null?void 0:r.getModifiedEditor)==null?void 0:m.call(r))??null},Ct=()=>{const m=l();if(m)return m;if(f()&&c())return{startLine:c(),endLine:c()};const C=c();return C?{startLine:C,endLine:C}:null},K=()=>{var v,E,D,A;const m=Z(),C=n;if(!m||!C)return;const O=Ct();if(!O){S(null);return}try{const I=(v=m.getDomNode)==null?void 0:v.call(m);if(!I){S(null);return}const j=I.querySelector(".margin"),Q=I.querySelector(".monaco-scrollable-element.editor-scrollable"),Ce=((E=m.getTopForLineNumber)==null?void 0:E.call(m,O.startLine))??0,Te=((D=m.getScrollTop)==null?void 0:D.call(m))??0,St=Number(((A=m.getOption)==null?void 0:A.call(m,o.editor.EditorOption.lineHeight))??18),Ze=I.getBoundingClientRect(),Se=C.getBoundingClientRect(),wt=Ze.left-Se.left+((j==null?void 0:j.offsetWidth)??(Q==null?void 0:Q.offsetLeft)??0),Vo=Ze.top-Se.top+(Ce-Te)+St/2;S({top:Vo,left:wt})}catch{S(null)}};return Mn(()=>{let m=!1;(async()=>(o=await jo(),!m&&(!n||!o||(o.editor.setTheme(t()?"vs-dark":"vs"),r=o.editor.createDiffEditor(n,{readOnly:!0,automaticLayout:!0,renderSideBySide:!0,renderSideBySideInlineBreakpoint:0,renderMarginRevertIcon:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,renderWhitespace:"selection",fontSize:13,wordWrap:e.wordWrap==="on"?"on":"off",glyphMargin:!1,folding:!1,lineNumbersMinChars:4,lineDecorationsWidth:12,diffAlgorithm:"legacy",maxComputationTime:1e4}),a(!0),K()))))(),ue(()=>{m=!0,s!==null&&typeof window<"u"&&(window.cancelAnimationFrame(s),s=null),$(),a(!1),y()})}),G(()=>{!i()||!o||!r||o.editor.setTheme(t()?"vs-dark":"vs")}),G(()=>{n&&(n.dataset.viewMode=e.viewMode==="split"?"split":"unified")}),G(()=>{var O;if(!i()||!o||!r)return;const m=(O=r.getModifiedEditor)==null?void 0:O.call(r);if(!(m!=null&&m.onDidChangeCursorSelection))return;const C=m.onDidChangeCursorSelection(v=>{var D;const E=v==null?void 0:v.selection;if(!E||(D=E.isEmpty)!=null&&D.call(E)){d(null),K();return}d({startLine:Math.min(E.startLineNumber,E.endLineNumber),endLine:Math.max(E.startLineNumber,E.endLineNumber)}),K()});ue(()=>{var v;try{(v=C==null?void 0:C.dispose)==null||v.call(C)}catch{}})}),G(()=>{var E;if(!i()||!o||!r)return;const m=Z();if(!(m!=null&&m.onMouseMove)||!(m!=null&&m.onMouseLeave)||!(m!=null&&m.onMouseDown))return;const C=m.onMouseMove(D=>{var I,j;const A=(j=(I=D==null?void 0:D.target)==null?void 0:I.position)==null?void 0:j.lineNumber;u(typeof A=="number"?A:null),K()}),O=m.onMouseLeave(()=>{f()||u(null),K()}),v=(E=m.onDidScrollChange)==null?void 0:E.call(m,()=>{K()});ue(()=>{var D,A,I;try{(D=C==null?void 0:C.dispose)==null||D.call(C),(A=O==null?void 0:O.dispose)==null||A.call(O),(I=v==null?void 0:v.dispose)==null||I.call(v)}catch{}})}),G(()=>{if(!i()||!o||!r)return;Ct()||S(null),K()}),G(()=>{var Ce,Te,St,Ze,Se,wt;if(!i()||!o||!r)return;const m=e.viewMode==="unified"?"unified":"split",C=e.contextMode==="collapsed"?"collapsed":"expanded",O=e.wordWrap==="on"?"on":"off",{before:v,after:E}=w(),D=m==="unified"?fu({before:v,after:E}):hu({before:v,after:E}),{diffEditorLineNumbersMinChars:A,originalLineNumbersMinChars:I,modifiedLineNumbersMinChars:j,lineDecorationsWidth:Q}=D;r.updateOptions({renderSideBySide:m==="split",renderSideBySideInlineBreakpoint:0,renderIndicators:!0,lineNumbersMinChars:A,lineDecorationsWidth:Q,hideUnchangedRegions:C==="collapsed"?{enabled:!0}:{enabled:!1},wordWrap:O});try{(St=(Te=(Ce=r.getOriginalEditor)==null?void 0:Ce.call(r))==null?void 0:Te.updateOptions)==null||St.call(Te,{wordWrap:O,lineNumbersMinChars:I,lineDecorationsWidth:Q})}catch{}try{(wt=(Se=(Ze=r.getModifiedEditor)==null?void 0:Ze.call(r))==null?void 0:Se.updateOptions)==null||wt.call(Se,{wordWrap:O,lineNumbersMinChars:j,lineDecorationsWidth:Q})}catch{}R({viewMode:m,originalLineNumbersMinChars:I,lineDecorationsWidth:Q})}),G(()=>{if(!i()||!o||!r)return;const m=Wo(o,e.path),{before:C,after:O}=w(),v=`${e.scopeKey}:diff:${e.path}:before`,E=`${e.scopeKey}:diff:${e.path}:after`,D=Pn({monaco:o,cacheKey:v,value:C}),A=Pn({monaco:o,cacheKey:E,value:O});r.setModel({original:D,modified:A}),_o(m).then(()=>{try{o.editor.setModelLanguage(D,m),o.editor.setModelLanguage(A,m)}catch{}})}),(()=>{var m=uu(),C=m.firstChild,O=n;return typeof O=="function"?Dn(O,m):n=m,kt(C,pe(Yo,{get when(){return b()},children:v=>(()=>{var E=du(),D=E.firstChild;return E.addEventListener("mouseleave",()=>{g(!1),K()}),E.addEventListener("mouseenter",()=>{g(!0),K()}),D.$$click=A=>{var j;A.preventDefault(),A.stopPropagation();const I=Ct();I&&((j=e.onRequestInsertContext)==null||j.call(e,I))},D.$$mousedown=A=>{A.preventDefault(),A.stopPropagation()},me(A=>{var I=`${v().top}px`,j=`${v().left}px`,Q=e.insertContextLabel??"Add git change context to prompt",Ce=e.insertContextLabel??"Add git change context to prompt";return I!==A.e&&Vn(E,"top",A.e=I),j!==A.t&&Vn(E,"left",A.t=j),Q!==A.a&&lt(D,"aria-label",A.a=Q),Ce!==A.o&&lt(D,"title",A.o=Ce),A},{e:void 0,t:void 0,a:void 0,o:void 0}),E})()})),m})()}Er(["mousedown","click"]);const Hu=Object.freeze(Object.defineProperty({__proto__:null,MonacoDiffViewer:gu},Symbol.toStringTag,{value:"Module"}));export{vl as $,Mu as A,Ai as B,Ou as C,Su as D,Pu as E,xu as F,Ga as G,le as H,Au as I,Ha as J,_ as K,Ci as L,Oe as M,Ma as N,Ta as O,Cu as P,Zs as Q,Ht as R,da as S,te as T,Pi as U,bu as V,Eu as W,Vu as X,ku as Y,fs as Z,Lo as _,us as a,Wu as a0,$u as a1,Bu as a2,_u as a3,Ol as a4,Io as a5,Iu as a6,Ru as a7,Zc as a8,Nu as a9,Lu as aa,ju as ab,Es as ac,Uu as ad,ec as ae,Qa as af,zu as ag,zr as ah,Kr as ai,Du as aj,na as ak,Tu as al,Da as am,ka as an,de as ao,cu as ap,Ku as aq,Hu as ar,Or as b,wu as c,lt as d,Er as e,Vn as f,De as g,sn as h,kt as i,ie as j,ds as k,qa as l,is as m,So as n,No as o,vu as p,dt as q,Ti as r,hs as s,Fn as t,Dn as u,gt as v,U as w,Fu as x,ui as y,Qn as z};
27
- //# sourceMappingURL=monaco-viewer-CG0aPZ-r.js.map