@neuralnomads/codenomad-dev 0.18.0-dev-20260716-40cee071 → 0.18.0-dev-20260718-8f6aa44b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/manager.js +1 -1
- package/dist/filesystem/__tests__/search-cache.test.js +5 -5
- package/dist/filesystem/search-cache.js +1 -1
- package/dist/index.js +25 -0
- package/dist/index.test.js +40 -10
- package/dist/opencode-update/service.js +150 -0
- package/dist/opencode-update/service.test.js +107 -0
- package/dist/server/__tests__/remote-proxy.test.js +64 -56
- package/dist/server/http-server.js +7 -1
- package/dist/server/remote-proxy.js +68 -98
- package/dist/server/routes/opencode-update.js +37 -0
- package/dist/server/routes/opencode-update.test.js +34 -0
- package/dist/server/routes/remote-servers.js +1 -1
- package/dist/server/routes/workspaces.test.js +38 -0
- package/dist/server/tls.js +2 -2
- package/dist/settings/binaries.test.js +2 -7
- package/dist/shutdown.js +67 -59
- package/dist/shutdown.test.js +115 -78
- package/dist/ui/remote-ui.js +2 -2
- package/dist/usage/providers/api-key.js +3 -3
- package/dist/usage/providers/google.js +1 -1
- package/dist/usage/providers/special.js +3 -3
- package/dist/usage/service.js +1 -1
- package/dist/usage/service.test.js +1 -1
- package/dist/usage/shared.js +4 -4
- package/dist/usage/shared.test.js +1 -1
- package/dist/workspaces/__tests__/spawn.test.js +2 -2
- package/dist/workspaces/__tests__/workspace-identity.test.js +94 -286
- package/dist/workspaces/binary-path.test.js +10 -0
- package/dist/workspaces/instance-client.js +4 -3
- package/dist/workspaces/launch-cleanup.test.js +21 -25
- package/dist/workspaces/manager.js +300 -351
- package/dist/workspaces/manager.test.js +209 -237
- package/dist/workspaces/process-identity.darwin.test.js +88 -0
- package/dist/workspaces/process-identity.js +172 -149
- package/dist/workspaces/process-identity.test.js +86 -140
- package/dist/workspaces/runtime.js +261 -373
- package/dist/workspaces/runtime.test.js +222 -547
- package/package.json +1 -1
- package/public/assets/{FilesTab-BjztpSdj.js → FilesTab-B0-DlSCT.js} +2 -2
- package/public/assets/{GitChangesTab-B9XraSoR.js → GitChangesTab-CxjbNBVr.js} +2 -2
- package/public/assets/{SplitFilePanel-Cu_5-Z-E.js → SplitFilePanel-CLQb-6uX.js} +1 -1
- package/public/assets/{StatusTab-D_IE79r-.js → StatusTab-CBGAuhmp.js} +1 -1
- package/public/assets/{align-justify-BKS9gyRk.js → align-justify-s5mnjsP0.js} +1 -1
- package/public/assets/{bundle-full-CXGXXlzR.js → bundle-full-lwIMY5om.js} +1 -1
- package/public/assets/{diff-viewer-CSNOYoEB.js → diff-viewer-CDtmFe6e.js} +1 -1
- package/public/assets/index-6ABz_Izb.js +1 -0
- package/public/assets/index-BPdjM9ZI.css +1 -0
- package/public/assets/index-BQK8um1r.js +1 -0
- package/public/assets/index-BkUAI4ZY.js +1 -0
- package/public/assets/index-D8bkUvEd.js +2 -0
- package/public/assets/index-DY_sbCt9.js +1 -0
- package/public/assets/index-DhmUOdAI.js +1 -0
- package/public/assets/{index-sLe9hEfQ.js → index-DupnEKCQ.js} +1 -1
- package/public/assets/index-HhZzWWha.js +1 -0
- package/public/assets/{index-DVc4ls8c.js → index-lBAEWdAF.js} +1 -1
- package/public/assets/index-nVII4VJz.js +1 -0
- package/public/assets/index-p1Sble5V.js +1 -0
- package/public/assets/{loading-CDmt9OJU.js → loading-h8DvUqqc.js} +1 -1
- package/public/assets/main-BxUSjoWA.js +68 -0
- package/public/assets/{markdown-1ZLSxCFT.js → markdown-Djug_spc.js} +3 -3
- package/public/assets/{monaco-viewer-D6JgH76W.js → monaco-viewer-lkUcsK65.js} +2 -2
- package/public/assets/{tool-call-CyXb63LH.js → tool-call-C4YH896w.js} +3 -3
- package/public/assets/{unified-picker-DCCdSVwI.js → unified-picker-DwNZOVlY.js} +1 -1
- package/public/assets/{wrap-text-pNMdTIq3.js → wrap-text-BLVYxvcj.js} +1 -1
- package/public/index.html +4 -4
- package/public/loading.html +4 -4
- package/public/sw.js +1 -1
- package/dist/workspaces/launch-cleanup.js +0 -132
- package/public/assets/index-B3YjNCh4.js +0 -1
- package/public/assets/index-B3ZD2_SU.js +0 -1
- package/public/assets/index-Bh2ofaQo.js +0 -1
- package/public/assets/index-CM0c9xRZ.js +0 -1
- package/public/assets/index-CdDxouJl.js +0 -2
- package/public/assets/index-D06Y2cFq.js +0 -1
- package/public/assets/index-PmE51vPh.js +0 -1
- package/public/assets/index-Qj63IiSj.css +0 -1
- package/public/assets/index-VY_zwmsG.js +0 -1
- package/public/assets/index-qiiH7egV.js +0 -1
- package/public/assets/main-CTN6Wwz1.js +0 -68
|
@@ -12,7 +12,7 @@ ${a}
|
|
|
12
12
|
}`:Pt(a,[`.${t}`],{extraProperties:e.extraProperties,propertyNameCache:r}).join(`
|
|
13
13
|
`)).join(`
|
|
14
14
|
`);return((i=e.cache)==null?void 0:i.create(e.name,o,e.componentId))||Fr(e.name,o,e.componentId)}function _r(e,t){"styleSheet"in e?e.styleSheet.cssText=t:(e.innerText="",e.appendChild(document.createTextNode(t)))}function ci(e,t){for(const n in t){const r=t[n];r!==void 0&&(r===null?e.removeAttribute(n):e.setAttribute(n,r))}}function li(e,t){const n=document.createElement("style");return n.type="text/css",t&&ci(n,t),_r(n,e),n}function dn(e){let t=Number(e.getAttribute("data-uses"));t++,e.setAttribute("data-uses",t.toString())}const Vn="suid-injectFirst";function ui(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 _r(s,e),dn(s),s;{s&&s.remove();const i=li(e,t);if(dn(i),n){let a=o.querySelector(`#${Vn}`);a||(a=document.createElement("style"),a.setAttribute("id",Vn),o.prepend(a)),o.insertBefore(i,a)}else o.appendChild(i);return i}}function di(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 zn(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 Yl(e){if(typeof e!="string")throw new Error("MUI: `capitalize(string)` expects a string argument.");return e.charAt(0).toUpperCase()+e.slice(1)}function Xl(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 Zl(e){const t=e.documentElement.clientWidth;return Math.abs(window.innerWidth-t)}function fi(e){return e&&e.ownerDocument||document}function Ql(e){return fi(e).defaultView||window}function Ur(){return Math.random().toString(36).substring(2,15).slice(0,8)}let jt=!0,fn=!1,Kn;const hi={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 gi(e){const{type:t,tagName:n}=e;return!!(n==="INPUT"&&hi[t]&&!e.readOnly||n==="TEXTAREA"&&!e.readOnly||e.isContentEditable)}function mi(e){e.metaKey||e.altKey||e.ctrlKey||(jt=!0)}function Zt(){jt=!1}function pi(){this.visibilityState==="hidden"&&fn&&(jt=!0)}function yi(e){e.addEventListener("keydown",mi,!0),e.addEventListener("mousedown",Zt,!0),e.addEventListener("pointerdown",Zt,!0),e.addEventListener("touchstart",Zt,!0),e.addEventListener("visibilitychange",pi,!0)}function wi(e){const{target:t}=e;try{return t.matches(":focus-visible")}catch{}return jt||gi(t)}function eu(){const e=s=>{s!=null&&yi(s.ownerDocument)},[t,n]=$(!1);function r(){return t()?(fn=!0,window.clearTimeout(Kn),Kn=window.setTimeout(()=>{fn=!1},100),n(!1),!0):!1}function o(s){return wi(s)?(n(!0),!0):!1}return{isFocusVisibleRef:{get current(){return t()}},onFocus:o,onBlur:r,ref:e}}const bi=new ii;function Ci(e){return e?Array.isArray(e)?e.flat(1/0).filter(t=>!!t):[e]:[]}function Si(){if(!D.context)return Ur();const e=Mo().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 Br(e){const t=at(ws),[n,r]=$(""),o=Si();let s,i=!1;return de(a=>{var l;const c=e();let u;if(c){const d=ni(Ci(c));i="@global"in d,u=ai({name:"css",props:d,cache:bi,componentId:o}),s=di(u.id),s?dn(s):s=ui(u.rules,{id:u.id,nonce:(l=t.cache)==null?void 0:l.nonce},t.injectFirst),a!=null&&a.styleElement&&zn(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),fe(()=>{s&&zn(s,t.cleanupStyles??i)}),n}function Le(e,t,n={}){for(const r in e){const o=e[r];if(Nr(r))n[r]=Le(o,t);else if(un(r))n[r]=Le(o,t);else if(Rr(r)){n[r]={};for(const s in o)n[r][s]=Le(o[s],t)}else if(Lr(r))n[r]=Le(o,t);else{const s=t(r,o);if(s)for(const i in s)n[i]=un(i)?{...n[i],...s[i]}:s[i];else n[r]=o}}return n}const vi=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 Wr(e,t){if(typeof t=="number")return{[e]:vi.has(e)?t.toString():`${t}px`}}function Hn(e,t={}){return Le(e,Wr,t)}function It(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 xi(e,t){return t.split(".").reduce((n,r)=>n&&n[r]?n[r]:null,e)}function Ei(e,t,n,r){const o=xi(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 le={x:["Left","Right"],y:["Top","Bottom"]};function jr(e){return typeof e=="number"?`${e}px`:e}function Vr(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 et(e){return h(e,(t,n)=>jr(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 Oi(){return{...Ai(),...Ti(),...ki(),...$i(),...Pi(),...Ii(),...Mi(),...Li(),...Di()}}function Ai(){return{displayPrint:Vr("displayPrint",(e,t)=>({"@media print":{display:t}})),displayRaw:h("display"),overflow:h("overflow"),textOverflow:h("textOverflow"),visibility:h("visibility"),whiteSpace:h("whiteSpace")}}function Ti(){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 ki(){const e=(t,n,r)=>Ei(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 $i(){return{position:h("position"),zIndex:h("zIndex",(e,t,n)=>{var r;return((r=n.zIndex)==null?void 0:r[e])??t}),top:et("top"),right:et("right"),bottom:et("bottom"),left:et("left")}}function Pi(){const e=(t,n,r)=>It(r,"palette",n);return{color:h("color",e),bgcolor:h("backgroundColor",e),backgroundColor:h("backgroundColor",e)}}function Ii(){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 Mi(){const e=(n,r)=>typeof r=="number"?`${r}px solid`:r,t=(n,r,o)=>It(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 Di(){const e=(t,n,r)=>It(r,"typography",n);return{typography:Vr("typography",(t,n,r)=>It(r,"typography",n)),fontFamily:h("fontFamily",e),fontSize:h("fontSize",(t,n,r)=>jr(e(t,n,r))),fontStyle:h("fontStyle",e),fontWeight:h("fontWeight",e),letterSpacing:et("letterSpacing"),lineHeight:h("lineHeight"),textAlign:h("textAlign"),textTransform:h("textTransform")}}function Li(){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,le.x,e),my:q(t,le.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,le.x,e),marginY:q(t,le.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,le.x,e),py:q(n,le.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,le.x,e),paddingY:q(n,le.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 Tn=Oi(),tu=Object.keys(Tn);function Ni(e,t,n){return Tn[e](t,n)}function Gn(e,t,n){return e in Tn?Ni(e,t,n):Wr(e,t)}function Ri(e,t){return Le(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,ps({theme:t},r,s=>Gn(n,s,t)??{[n]:s}))}else return Gn(n,r,t)})}function zr(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=zr(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Fi(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=zr(e))&&(r&&(r+=" "),r+=t);return r}const Kr=["ownerState","theme","sx","as"];function _i(e,t){var n,r;return(r=(n=t.components)==null?void 0:n[e])==null?void 0:r.styleOverrides}function Ui(e,t,n,r,o={}){return L(()=>{const s=e(),i=_i(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(Hn(f,{name:t,__resolved:!0})),l},[]);let u=[];return o.overridesResolver&&typeof o.overridesResolver=="function"&&i&&(u=o.overridesResolver(r,i).map(l=>l?Hn(l,{}):null).filter(Boolean)),c.concat(u)})}function Hr(e,t){e.__suid=t}function qn(e){if(typeof e=="function")return e.__suid}function Bi(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-${Ur()}`,o="css";const i=qn(n);return function(...a){function c(u){let l;const d=()=>{const N=u.theme;return N||l||(l=e&&e.onUseTheme?e.onUseTheme():An())},[,f]=_t(u,r.skipProps||Kr),m=Ui(d,o,a,u,r),w=()=>{const N=u.sx;return N?Array.isArray(N)?N:[N]:[]},g=()=>{if(i)return n;const N=u.as;return N||n},b=i?()=>i:L(()=>qn(g())),A=r.skipSx?()=>m():()=>{const N=d();return[...m(),...w().map(X=>X.__resolved?X:Ri(X,N))]},M=Br(()=>b()?void 0:A());return Mr(g,fr(f,{get children(){return u.children},get component(){return b()?u.component:null},get as(){return i?u.as:void 0},get sx(){return b()?A():void 0},get ownerState(){return b()==="system"?u.ownerState:void 0},get class(){return Fi([...new Set([u.class,s,M()])])}}))}return Hr(c,"system"),s&&(c.toString=()=>`.${s}`),c}}}const nu=[...Kr,"classes"],ru=Bi({onUseTheme:()=>Ir()}),Wi="modulepreload",ji=function(e){return"/"+e},Jn={},Vi=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),a=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=Promise.allSettled(n.map(c=>{if(c=ji(c),c in Jn)return;Jn[c]=!0;const u=c.endsWith(".css"),l=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${l}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Wi,u||(d.as="script"),d.crossOrigin="",d.href=c,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((f,m)=>{d.addEventListener("load",f),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return o.then(i=>{for(const a of i||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},Gr="codenomad-use-tauri-native-event-transport";function qr(){var e;if(typeof window>"u")return!0;try{return((e=window.localStorage)==null?void 0:e.getItem(Gr))!=="0"}catch{return!0}}function zi(e){var t;if(!(typeof window>"u"))try{(t=window.localStorage)==null||t.setItem(Gr,e?"1":"0")}catch{}}const Ki="codenomad.client-id",Hi="codenomad.connection-id";let yt=null,wt=null;function hn(){return{clientId:Gi(),connectionId:qi()}}function Gi(){return yt||(yt=Jr(Ki,window.localStorage),yt)}function qi(){return wt||(wt=Jr(Hi,window.sessionStorage),wt)}function Jr(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,Yn;function Ji(){if(Yn)return en;Yn=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]),m=(d[2]||"ms").toLowerCase();switch(m){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,m){var w=d>=f*1.5;return Math.round(l/f)+" "+m+(w?"s":"")}return en}function Yi(e){n.debug=n,n.default=n,n.coerce=c,n.disable=i,n.enable=o,n.enabled=a,n.humanize=Ji(),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,m,w;function g(...b){if(!g.enabled)return;const A=g,M=Number(new Date),N=M-(d||M);A.diff=N,A.prev=d,A.curr=M,d=M,b[0]=n.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let X=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(W,p)=>{if(W==="%%")return"%";X++;const C=n.formatters[p];if(typeof C=="function"){const O=b[X];W=C.call(A,O),b.splice(X,1),X--}return W}),n.formatArgs.call(A,b),(A.log||n.log).apply(A,b)}return g.namespace=l,g.useColors=n.useColors(),g.color=n.selectColor(l),g.extend=r,g.destroy=n.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(m!==n.namespaces&&(m=n.namespaces,w=n.enabled(l)),w),set:b=>{f=b}}),typeof n.init=="function"&&n.init(g),g}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,m=0,w=-1,g=0;for(;f<l.length;)if(m<d.length&&(d[m]===l[f]||d[m]==="*"))d[m]==="*"?(w=m,g=f,m++):(f++,m++);else if(w!==-1)m=w+1,g++,f=g;else return!1;for(;m<d.length&&d[m]==="*";)m++;return m===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 Xi=Yi;(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,m=>{m!=="%%"&&(d++,m==="%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=Xi(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 Zi=gn.exports;const mn=No(Zi),He=["sse","api","session","actions"],Yr="opencode:logger:namespaces",tn=new Map,ne=new Set,oe=typeof globalThis<"u"?globalThis.console:void 0;function lt(){ne.size===0?mn.disable():mn.enable(Array.from(ne).join(","))}function Vt(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{window.localStorage.setItem(Yr,JSON.stringify(Array.from(ne)))}catch(t){(e=oe==null?void 0:oe.warn)==null||e.call(oe,"Failed to persist logger namespaces",t)}}function Qi(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{const t=window.localStorage.getItem(Yr);if(!t)return;const n=JSON.parse(t);if(!Array.isArray(n))return;for(const r of n)He.includes(r)&&ne.add(r)}catch(t){(e=oe==null?void 0:oe.warn)==null||e.call(oe,"Failed to hydrate logger namespaces",t)}}Qi();lt();function ea(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 ae(e){if(!He.includes(e))throw new Error(`Unknown logger namespace: ${e}`);return tn.has(e)||tn.set(e,ea(e)),tn.get(e)}function ta(){return He.map(e=>({name:e,enabled:ne.has(e)}))}function na(e){if(!He.includes(e))throw new Error(`Unknown logger namespace: ${e}`);ne.has(e)||(ne.add(e),Vt(),lt())}function ra(e){if(!He.includes(e))throw new Error(`Unknown logger namespace: ${e}`);ne.has(e)&&(ne.delete(e),Vt(),lt())}function oa(){ne.clear(),Vt(),lt()}function sa(){He.forEach(e=>ne.add(e)),Vt(),lt()}const ia={listLoggerNamespaces:ta,enableLogger:na,disableLogger:ra,enableAllLoggers:sa,disableAllLoggers:oa};function aa(){typeof window>"u"||(window.codenomadLogger=ia)}aa();function ca(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)}})}const nn={};var ur;const la=typeof window<"u"?(ur=window.location)==null?void 0:ur.origin:void 0,ua=typeof window<"u"?window.__CODENOMAD_API_BASE__??la:void 0,da=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",ge=(nn==null?void 0:nn.VITE_CODENOMAD_API_BASE)??ua,rn=fa(ge,da),ou=ge;function su(e,t){const n=encodeURIComponent(e),r=encodeURIComponent(t);return ha(`/workspaces/${n}/plugin/background-processes/${r}/stream`)}function fa(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(e){const n=t.startsWith("/")?t:`/${t}`;return`${e}${n}`}return t}function ha(e){if(e.startsWith("http://")||e.startsWith("https://")||!ge)return e;const t=e.startsWith("/")?e:`/${e}`;return`${ge}${t}`}const Xn=ae("api"),Zn=ae("sse");function Xr(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 Se(e,t){if(t){Xn.info(e,t);return}Xn.info(e)}async function Zr(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 y(e,t){const n=ge?new URL(e,ge).toString():e,r=Xr(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();Se(`${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 Zr(i);throw Se(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s,error:c}),new Error(c||`Request failed with ${i.status}`)}const a=Date.now()-s;return Se(`${o} ${e} -> ${i.status}`,{durationMs:a}),i.status===204?void 0:await i.json()}catch(i){throw Se(`${o} ${e} failed`,{durationMs:Date.now()-s,error:i}),i}}async function ga(e,t){const n=ge?new URL(e,ge).toString():e,r=Xr(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();Se(`${o} ${e}`);const i=await fetch(n,{...t,headers:r,credentials:(t==null?void 0:t.credentials)??"include"});if(!i.ok){const a=await Zr(i);throw Se(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s,error:a}),new Error(a||`Request failed with ${i.status}`)}return Se(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s}),i}const re={fetchWorkspaces(){return y("/api/workspaces")},fetchProviderUsage(e,t){const n=new URLSearchParams;t&&n.set("modelId",t);const r=n.toString();return y(`/api/usage/${encodeURIComponent(e)}${r?`?${r}`:""}`)},fetchWorktrees(e){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees`)},createWorktree(e,t){return y(`/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 y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}${o}`,{method:"DELETE"})},readWorktreeMap(e){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/map`)},writeWorktreeMap(e,t){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/map`,{method:"PUT",body:JSON.stringify(t)})},createWorkspace(e,t){return y("/api/workspaces",{method:"POST",body:JSON.stringify(e),signal:t==null?void 0:t.signal})},cancelWorkspaceCreation(e){return y("/api/workspaces/creation/cancel",{method:"POST",body:JSON.stringify({requestId:e})})},releaseWorkspaceCreation(e,t){return y(`/api/workspaces/${encodeURIComponent(e)}/creation/release`,{method:"POST",body:JSON.stringify({requestId:t})})},fetchSidecars(){return y("/api/sidecars")},createSidecar(e){return y("/api/sidecars",{method:"POST",body:JSON.stringify(e)})},updateSidecar(e,t){return y(`/api/sidecars/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteSidecar(e){return y(`/api/sidecars/${encodeURIComponent(e)}`,{method:"DELETE"})},createPreview(e){return y("/api/previews",{method:"POST",body:JSON.stringify(e)})},deletePreview(e){return y(`/api/previews/${encodeURIComponent(e)}`,{method:"DELETE"})},fetchServerMeta(){return y("/api/meta")},probeRemoteServer(e){return y("/api/remote-servers/probe",{method:"POST",body:JSON.stringify(e)})},createRemoteProxySession(e){return y("/api/remote-proxy/sessions",{method:"POST",body:JSON.stringify(e)})},deleteRemoteProxySession(e){return y(`/api/remote-proxy/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})},fetchAuthStatus(){return y("/api/auth/status")},listConfigFiles(){return y("/api/config-files")},readConfigFile(e){return y(`/api/config-files/${encodeURIComponent(e)}/content`)},writeConfigFile(e,t){const n={contents:t};return y(`/api/config-files/${encodeURIComponent(e)}/content`,{method:"PUT",body:JSON.stringify(n)})},setServerPassword(e){return y("/api/auth/password",{method:"POST",body:JSON.stringify({password:e})})},deleteWorkspace(e){return y(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},cloneWorkspaceRepository(e){return y("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return y(`/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});return n!=null&&n.limit&&o.set("limit",String(n.limit)),n!=null&&n.type&&o.set("type",n.type),y(`/api/workspaces/${encodeURIComponent(e)}/files/search?${o.toString()}`)},readWorkspaceFile(e,t,n){const r=new URLSearchParams({path:t});return n!=null&&n.encoding&&r.set("encoding",n.encoding),y(`/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),y(`/api/workspaces/${encodeURIComponent(e)}/files/content?${o.toString()}`,{method:"PUT",body:JSON.stringify({contents:n})})},fetchWorktreeGitStatus(e,t){return y(`/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),y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-diff?${r.toString()}`)},stageWorktreeGitPaths(e,t,n){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-stage`,{method:"POST",body:JSON.stringify(n)})},unstageWorktreeGitPaths(e,t,n){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-unstage`,{method:"POST",body:JSON.stringify(n)})},commitWorktreeGitChanges(e,t,n){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-commit`,{method:"POST",body:JSON.stringify(n)})},fetchConfigOwner(e){return y(`/api/storage/config/${encodeURIComponent(e)}`)},patchConfigOwner(e,t){return y(`/api/storage/config/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t??{})})},fetchStateOwner(e){return y(`/api/storage/state/${encodeURIComponent(e)}`)},patchStateOwner(e,t){return y(`/api/storage/state/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t??{})})},validateBinary(e){return y("/api/storage/binaries/validate",{method:"POST",body:JSON.stringify({path:e})})},fetchSpeechCapabilities(){return y("/api/speech/capabilities")},transcribeAudio(e){return y("/api/speech/transcribe",{method:"POST",body:JSON.stringify(e)})},synthesizeSpeech(e){return y("/api/speech/synthesize",{method:"POST",body:JSON.stringify(e)})},synthesizeSpeechStream(e,t){return ga("/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 y(r?`/api/filesystem?${r}`:"/api/filesystem")},createFileSystemFolder(e,t){return y("/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),y(`/api/filesystem/files/content?${n.toString()}`)},readInstanceData(e){return y(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return y(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return y(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},listBackgroundProcesses(e){return y(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes`)},stopBackgroundProcess(e,t){return y(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/stop`,{method:"POST"})},terminateBackgroundProcess(e,t){return y(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/terminate`,{method:"POST"})},updateVoiceMode(e,t){const n=hn();return y(`/workspaces/${encodeURIComponent(e)}/plugin/voice-mode`,{method:"POST",body:JSON.stringify({...n,enabled:t})})},getYoloState(e,t){return y(`/workspaces/${encodeURIComponent(e)}/yolo/sessions/${encodeURIComponent(t)}`)},toggleYolo(e,t){return y(`/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),y("/api/client-connections/pong",n)},fetchBackgroundProcessOutput(e,t,n){const r=new URLSearchParams;n!=null&&n.method&&r.set("method",n.method),n!=null&&n.pattern&&r.set("pattern",n.pattern),n!=null&&n.lines&&r.set("lines",String(n.lines)),(n==null?void 0:n.maxBytes)!==void 0&&r.set("maxBytes",String(n.maxBytes));const o=r.toString(),s=o?`?${o}`:"";return y(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/output${s}`)},connectEvents(e,t,n){const r=hn(),o=ma(r);Zn.info(`Connecting to ${o}`);const s=new EventSource(o,{withCredentials:!0});return ca(s,{onEvent:e,onError:t,onPing:n,logger:Zn}),s}};function ma(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}`}const pa={initialDelayMs:1e3,maxDelayMs:1e4,multiplier:2};function ya(e){return{reconnect:{...pa,...e==null?void 0:e.reconnect}}}function Qr(){if(typeof window>"u"||window.__CODENOMAD_WINDOW_CONTEXT__==="remote")return"remote";if(window.__CODENOMAD_WINDOW_CONTEXT__==="local")return"local";const e=window;return typeof e.electronAPI<"u"||typeof e.__TAURI__<"u"||typeof navigator<"u"&&/tauri/i.test(navigator.userAgent)?"local":"remote"}function zt(){if(typeof window>"u")return"web";const e=window.__CODENOMAD_RUNTIME_HOST__;if(e)return e;const t=window;return typeof t.electronAPI<"u"?"electron":typeof t.__TAURI__<"u"||typeof navigator<"u"&&/tauri/i.test(navigator.userAgent)?"tauri":"web"}function wa(){if(typeof navigator>"u")return"desktop";const e=navigator.userAgentData;if(e!=null&&e.mobile)return"mobile";const t=navigator.userAgent.toLowerCase();return/android|iphone|ipad|ipod|blackberry|mini|windows phone|mobile|silk/.test(t)?"mobile":"desktop"}const ba=ae("actions");let we=null;function Ca(){return we||(we={host:zt(),platform:wa(),windowContext:Qr()},typeof window<"u"&&ba.info(`[runtime] host=${we.host} platform=${we.platform} context=${we.windowContext}`),we)}const $e=Ca(),Sa=()=>zt()==="electron",va=()=>zt()==="tauri",iu=()=>zt()==="web",Kt=()=>Sa()||va(),Ht=()=>Qr()==="local",au=()=>Kt()&&Ht(),cu=()=>Kt()&&Ht(),lu=()=>Kt()&&Ht(),uu=()=>Kt()&&Ht();function R(e,t,n,r){if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function qe(e,t,n,r,o){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var be,J,Pe,bt;const Qn="__TAURI_TO_IPC_KEY__";function eo(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}class xa{constructor(t){be.set(this,void 0),J.set(this,0),Pe.set(this,[]),bt.set(this,void 0),qe(this,be,t||(()=>{})),this.id=eo(n=>{const r=n.index;if("end"in n){r==R(this,J,"f")?this.cleanupCallback():qe(this,bt,r);return}const o=n.message;if(r==R(this,J,"f")){for(R(this,be,"f").call(this,o),qe(this,J,R(this,J,"f")+1);R(this,J,"f")in R(this,Pe,"f");){const s=R(this,Pe,"f")[R(this,J,"f")];R(this,be,"f").call(this,s),delete R(this,Pe,"f")[R(this,J,"f")],qe(this,J,R(this,J,"f")+1)}R(this,J,"f")===R(this,bt,"f")&&this.cleanupCallback()}else R(this,Pe,"f")[r]=o})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(t){qe(this,be,t)}get onmessage(){return R(this,be,"f")}[(be=new WeakMap,J=new WeakMap,Pe=new WeakMap,bt=new WeakMap,Qn)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[Qn]()}}class er{constructor(t,n,r){this.plugin=t,this.event=n,this.channelId=r}async unregister(){return je(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function du(e,t,n){const r=new xa(n);try{return await je(`plugin:${e}|register_listener`,{event:t,handler:r}),new er(e,t,r.id)}catch{return await je(`plugin:${e}|registerListener`,{event:t,handler:r}),new er(e,t,r.id)}}async function je(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}var tr;(function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"})(tr||(tr={}));async function Ea(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await je("plugin:event|unlisten",{event:e,eventId:t})}async function Oa(e,t,n){var r;const o=typeof(n==null?void 0:n.target)=="string"?{kind:"AnyLabel",label:n.target}:(r=n==null?void 0:n.target)!==null&&r!==void 0?r:{kind:"Any"};return je("plugin:event|listen",{event:e,target:o,handler:eo(t)}).then(s=>async()=>Ea(e,s))}const Ct=ae("sse"),Aa={invoke:je,listen:Oa};function Ta(e){let t=!1;return()=>{var n;t||(t=!0,(n=e.onError)==null||n.call(e))}}function ka(e){return e==="connected"?"connected":e==="connecting"?"connecting":"disconnected"}async function $a(e,t,n=Aa){let r=!1,o=!1,s=null;const i=Ta(e),a=[],c=[],u=g=>s===g,l=g=>{var A,M;if(!g||!u(g.generation))return;o||(o=!0,(A=e.onStatus)==null||A.call(e,"connected"),(M=e.onOpen)==null||M.call(e));const b=g.events??[];b.length!==0&&e.onBatch(b)},d=g=>{var b,A;if(!(!g||!u(g.generation))){if((b=e.onStatus)==null||b.call(e,ka(g.state)),g.state==="connected"&&!o&&(o=!0,(A=e.onOpen)==null||A.call(e)),g.state==="unauthorized"?Ct.warn("Native desktop event transport is waiting for authentication",{reason:g.reason,reconnectAttempt:g.reconnectAttempt,nextDelayMs:g.nextDelayMs,stats:g.stats}):g.state==="error"?Ct.warn("Native desktop event transport reported an error",{reason:g.reason,reconnectAttempt:g.reconnectAttempt,nextDelayMs:g.nextDelayMs,statusCode:g.statusCode,stats:g.stats}):(g.state==="disconnected"||g.state==="stopped")&&g.stats&&Ct.info("Native desktop event transport stats",{state:g.state,reconnectAttempt:g.reconnectAttempt,stats:g.stats}),g.state==="stopped"){i();return}g.terminal&&i()}},f=()=>{if(s!==null){for(const g of c.splice(0,c.length))d(g);for(const g of a.splice(0,a.length))l(g)}},m=await n.listen("desktop:event-batch",g=>{if(r)return;const b=g.payload;if(b){if(s===null){a.push(b);return}l(b)}}),w=await n.listen("desktop:event-stream-status",g=>{if(r)return;const b=g.payload;if(b){if(s===null){c.push(b);return}d(b)}});try{const g=await n.invoke("desktop_events_start",{request:t});if(!(g!=null&&g.started))throw new Error((g==null?void 0:g.reason)??"desktop event transport unavailable");s=g.generation??null,f()}catch(g){throw m(),w(),g}return{disconnect(){r||(r=!0,m(),w(),n.invoke("desktop_events_stop").catch(g=>{Ct.warn("Failed to stop native desktop event transport",g)}))}}}const Je=ae("sse");async function Pa(e){const t=()=>{var r,o;(r=e.onStatus)==null||r.call(e,"disconnected"),(o=e.onError)==null||o.call(e)},n=re.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 Ia(e,t){const n=qr();if($e.host==="tauri"&&$e.windowContext==="local"&&n)try{const r=await $a(e,ya(t));return Je.info("Event transport: rust-native (desktop_event_transport)"),r}catch(r){Je.warn("Failed to start native desktop event transport, falling back to browser EventSource",r)}else $e.host==="tauri"&&$e.windowContext==="remote"?Je.info("Event transport: browser-eventsource forced for remote Tauri window"):$e.host==="tauri"&&Je.info("Event transport: browser-eventsource forced by settings");return Je.info(`Event transport: browser-eventsource (host=${$e.host})`),Pa(e)}async function Ma(e,t={}){const{maxAttempts:n=3,initialDelayMs:r=100,maxDelayMs:o=5e3,backoffMultiplier:s=2,timeoutMs:i,shouldRetry:a=()=>!0}=t;let c=null,u=r;for(let l=1;l<=n;l++)try{if(i){const d=new AbortController,f=setTimeout(()=>d.abort(),i);try{const m=await e(d.signal);return clearTimeout(f),m}catch(m){throw clearTimeout(f),m}}return await e()}catch(d){const f=d instanceof Error?d:new Error(String(d));if(c=f,l<n&&a(f,l))await new Promise(m=>setTimeout(m,u)),u=Math.min(u*s,o);else throw f}throw c||new Error("Failed after retries")}function Da(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,La=1e4,pn=ae("sse");function Ie(e,t){if(t){pn.info(e,t);return}pn.info(e)}class Na{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.connection.disconnect(),this.connection=null),Ie("Connecting to backend events stream");try{const n=await Ia({onBatch:r=>this.dispatchBatch(r),onError:()=>{t===this.connectGeneration&&this.scheduleReconnect()},onStatus:r=>{t===this.connectGeneration&&this.emitTransportStatus(r)},onOpen:()=>{t===this.connectGeneration&&(Ie("Events stream connected"),this.retryDelay=on,this.openHandlers.forEach(r=>r()))},onPing:r=>{const s={...hn(),pingTs:r.ts};Ma(i=>re.sendClientConnectionPong(s,i),{maxAttempts:3,initialDelayMs:100,maxDelayMs:2e3,timeoutMs:1e4,shouldRetry:i=>Da(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;Ie("Events stream failed to connect, scheduling reconnect",{error:n instanceof Error?n.message:String(n)}),this.scheduleReconnect()}}scheduleReconnect(){this.retryTimer||(this.connection&&(this.connection.disconnect(),this.connection=null),this.emitTransportStatus("disconnected"),Ie("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.retryDelay=Math.min(this.retryDelay*2,La),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&&(Ie("event batch",{size:t.length}),ve(()=>{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.connection.disconnect(),this.connection=null),Ie("Restarting backend events stream",{reason:t}),this.connect()}}const Ot=new Na,Ra=Object.freeze(Object.defineProperty({__proto__:null,serverEvents:Ot},Symbol.toStringTag,{value:"Module"})),Fa=ae("actions"),nr={messageHistory:[],agentModelSelections:{}};function rr(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){Fa.warn("Failed to compare config objects",n)}return!1}class _a{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,Ot.on("storage.configChanged",t=>{t.type==="storage.configChanged"&&this.setOwnerCache("config",t.owner,t.value)}),Ot.on("storage.stateChanged",t=>{t.type==="storage.stateChanged"&&this.setOwnerCache("state",t.owner,t.value)}),Ot.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=re.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)}async patchConfigOwner(t,n){const r=await re.patchConfigOwner(t,n);return 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=re.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)}async patchStateOwner(t,n){const r=await re.patchStateOwner(t,n);return 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=re.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)}async saveInstanceData(t,n){const r=this.normalizeInstanceData(n);await re.writeInstanceData(t,r),this.setInstanceDataCache(t,r)}async deleteInstanceData(t){await re.deleteInstanceData(t),this.setInstanceDataCache(t,nr)}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&&rr(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)}normalizeInstanceData(t){const n=t??nr,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&&rr(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 ee=new _a,to=ae("api"),Gt={messageHistory:[],agentModelSelections:{}},[kn,no]=$(new Map),St=new Map,Ve=new Map;function ro(e){const t=e??Gt;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function or(e){if(Ve.has(e))return;const t=ee.onInstanceDataChanged(e,n=>{Mt(e,n)});Ve.set(e,t)}function Ua(e){const t=Ve.get(e);t&&(t(),Ve.delete(e))}function Mt(e,t){no(n=>{const r=new Map(n);return r.set(e,ro(t)),r})}async function qt(e){if(!e||kn().has(e))return;if(St.has(e)){await St.get(e);return}const t=ee.loadInstanceData(e).then(n=>{Mt(e,n),or(e)}).catch(n=>{to.warn("Failed to load instance data",n),Mt(e,Gt),or(e)}).finally(()=>{St.delete(e)});St.set(e,t),await t}async function oo(e,t){if(!e)return;await qt(e);const n=kn().get(e)??Gt,r=ro(n);t(r);try{await ee.saveInstanceData(e,r)}catch(o){to.warn("Failed to persist instance data",o)}Mt(e,r)}function so(e){return kn().get(e)??Gt}function Ba(e){no(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),Ua(e)}const Wa=Ke(),ja={getInstanceConfig:so,ensureInstanceConfig:qt,updateInstanceConfig:oo,clearInstanceConfig:Ba},fu=e=>(fe(()=>{for(const t of Ve.values())t();Ve.clear()}),he(Wa.Provider,{value:ja,get children(){return e.children}})),Va=ae("api");function za(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[sr,yn]=$(null),[hu,ir]=$(!1),[gu,At]=$(null),[mu,io]=$(!1);let Ye=null;async function Ka(e=!1){return!e&&sr()?sr():Ye||(ir(!0),At(null),Ye=re.fetchSpeechCapabilities().then(t=>{io("separateProviders"in t);const r=za(t);return yn(r),At(null),r}).catch(t=>(Va.error("Failed to load speech capabilities",t),yn(null),At(t instanceof Error?t.message:String(t)),null)).finally(()=>{ir(!1),Ye=null}),Ye)}function Ha(){yn(null),At(null),io(!1)}function Ga(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 v=ae("actions"),qa=20,Ja=5,Ya=50,ao={preset:"balanced",thinking:"collapsed"},P={showThinkingBlocks:!1,showKeyboardShortcutHints:!0,thinkingBlocksExpansion:"collapsed",showMessageTimeline:!0,showTimelineTools:!0,holdLongAssistantReplies:!0,promptSubmitOnEnter:!1,showPromptVoiceInput:!0,diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded",toolInputsVisibility:"collapsed",showUsageMetrics:!0,autoCleanupBlankSessions:!0,keepUnseenSubagentIdleStatus:!1,osNotificationsEnabled:!1,osNotificationsAllowWhenVisible:!1,notifyOnNeedsInput:!0,notifyOnIdle:!0};function ar(e,t){return e==="expanded"||e==="collapsed"?e:t}function Xa(e){return e==="minimal"||e==="balanced"||e==="detailed"||e==="everything"||e==="custom"?e:ao.preset}function Za(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e))n&&(r==="expanded"||r==="collapsed")&&(t[n]=r);return t}function Qa(e,t){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,r=ar(t.thinkingBlocksExpansion,ao.thinking);return{preset:Xa(n==null?void 0:n.preset),thinking:ar(n==null?void 0:n.thinking,r),tools:Za(n==null?void 0:n.tools)}}const Me={provider:"openai-compatible",sttModel:"gpt-4o-mini-transcribe",ttsModel:"gpt-4o-mini-tts",ttsVoice:"alloy",playbackMode:"streaming",ttsFormat:"mp3"};function co(e){const t=e??{};return{showThinkingBlocks:t.showThinkingBlocks??P.showThinkingBlocks,showKeyboardShortcutHints:t.showKeyboardShortcutHints??P.showKeyboardShortcutHints,thinkingBlocksExpansion:t.thinkingBlocksExpansion??P.thinkingBlocksExpansion,showMessageTimeline:t.showMessageTimeline??P.showMessageTimeline,showTimelineTools:t.showTimelineTools??P.showTimelineTools,holdLongAssistantReplies:t.holdLongAssistantReplies??P.holdLongAssistantReplies,promptSubmitOnEnter:t.promptSubmitOnEnter??P.promptSubmitOnEnter,showPromptVoiceInput:t.showPromptVoiceInput??P.showPromptVoiceInput,locale:t.locale??P.locale,diffViewMode:t.diffViewMode??P.diffViewMode,toolCallExpansionDefaults:Qa(t.toolCallExpansionDefaults,t),toolOutputExpansion:t.toolOutputExpansion??P.toolOutputExpansion,diagnosticsExpansion:t.diagnosticsExpansion??P.diagnosticsExpansion,toolInputsVisibility:t.toolInputsVisibility==="hidden"||t.toolInputsVisibility==="collapsed"||t.toolInputsVisibility==="expanded"?t.toolInputsVisibility:P.toolInputsVisibility,showUsageMetrics:t.showUsageMetrics??P.showUsageMetrics,autoCleanupBlankSessions:t.autoCleanupBlankSessions??P.autoCleanupBlankSessions,keepUnseenSubagentIdleStatus:t.keepUnseenSubagentIdleStatus??P.keepUnseenSubagentIdleStatus,osNotificationsEnabled:t.osNotificationsEnabled??P.osNotificationsEnabled,osNotificationsAllowWhenVisible:t.osNotificationsAllowWhenVisible??P.osNotificationsAllowWhenVisible,notifyOnNeedsInput:t.notifyOnNeedsInput??P.notifyOnNeedsInput,notifyOnIdle:t.notifyOnIdle??P.notifyOnIdle}}function lo(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 ec(e){var o,s,i,a,c,u,l,d,f,m;const t=e??{},n=typeof t.sttModel=="string"&&t.sttModel.trim()?t.sttModel.trim():Me.sttModel,r=typeof t.ttsModel=="string"&&t.ttsModel.trim()?t.ttsModel.trim():Me.ttsModel;return{provider:t.provider==="openai-compatible"?t.provider:Me.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():Me.ttsVoice,playbackMode:t.playbackMode==="buffered"||t.playbackMode==="streaming"?t.playbackMode:Me.playbackMode,ttsFormat:t.ttsFormat==="wav"||t.ttsFormat==="opus"||t.ttsFormat==="aac"||t.ttsFormat==="mp3"?t.ttsFormat:Me.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((m=t.tts)==null?void 0:m.model)=="string"&&t.tts.model.trim()?t.tts.model.trim():r}}}function Xe(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 tc(e){var n,r,o;const t=e??{};return{recentFolders:Xe(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:Xe(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:Xe(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:Xe((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:Xe((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:lo((o=t.models)==null?void 0:o.thinkingSelections)}}}function nc(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",s=lo(t.environmentVariables),i=rc(t.secureEnvVars),a=ec(t.speech);return{listeningMode:n,logLevel:r,opencodeBinary:o,environmentVariables:s,secureEnvVars:i,speech:a}}function rc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function uo(e){return`${e.providerId}/${e.modelId}`}function fo(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,qa)}function $n(e,t,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 oc(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??sc(),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 ho(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 sc(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`remote-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}const[Pn,Dt]=$({}),[ic,Lt]=$({}),[ac,Nt]=$({}),[go,nt]=$(!1),[mo,cc]=$(qr()),lc=L(()=>co(Pn().settings)),po=L(()=>Pn().theme??"system"),me=L(()=>nc(ic())),ie=L(()=>tc(ac())),B=lc,ut=L(()=>ie().recentFolders),dt=L(()=>ie().opencodeBinaries),ze=L(()=>ie().remoteServers);let vt=null;async function Jt(){go()||(vt||(vt=Promise.all([ee.loadConfigOwner("ui"),ee.loadConfigOwner("server"),ee.loadStateOwner("ui")]).then(([e,t,n])=>{Dt(e),Lt(t),Nt(n),nt(!0)}).catch(e=>{v.error("Failed to load settings",e),Dt({}),Lt({}),Nt({}),nt(!0)}).finally(()=>{vt=null})),await vt)}async function K(e,t){await Jt();const n=await ee.patchConfigOwner(e,t);e==="ui"&&Dt(n),e==="server"&&Lt(n)}function uc(e){mo()!==e&&(cc(e),zi(e),Vi(async()=>{const{serverEvents:t}=await Promise.resolve().then(()=>Ra);return{serverEvents:t}},void 0).then(({serverEvents:t})=>{t.restart("desktop transport preference changed")}).catch(t=>{v.error("Failed to restart backend events stream after desktop transport preference change",t)}))}async function H(e,t){await Jt();const n=await ee.patchStateOwner(e,t);Nt(n)}function G(e){const t=Pn(),r={settings:co({...t.settings??{},...e})};K("ui",r).catch(o=>v.error("Failed to patch ui settings",o))}function yo(e){G(e)}function dc(e){po()!==e&&K("ui",{theme:e}).catch(t=>v.error("Failed to set theme",t))}async function fc(e){me().listeningMode!==e&&await K("server",{listeningMode:e})}function wo(e){K("server",{environmentVariables:e}).catch(t=>v.error("Failed to update environment variables",t))}function hc(e,t,n=!0){const r=me().environmentVariables;wo({...r,[e]:t});const o=me().secureEnvVars,s=e.toUpperCase(),i=o.some(a=>a.toUpperCase()===s);if(n){if(!i){const a=[...o,e];K("server",{secureEnvVars:a}).catch(c=>v.error("Failed to add secure env var",c))}}else if(i){const a=o.filter(c=>c.toUpperCase()!==s);K("server",{secureEnvVars:a}).catch(c=>v.error("Failed to remove secure env var",c))}}function gc(e){K("server",{environmentVariables:{[e]:null}}).catch(t=>v.error("Failed to remove environment variable",t))}function mc(e){return me().secureEnvVars.some(n=>n.toUpperCase()===e.toUpperCase())}function pc(e){const t=me().secureEnvVars,n=e.toUpperCase(),o=t.some(s=>s.toUpperCase()===n)?t.filter(s=>s.toUpperCase()!==n):[...t,e];K("server",{secureEnvVars:o}).catch(s=>v.error("Failed to update secure env vars",s))}function yc(e){const t=e&&e.trim().length>0?e:"opencode";K("server",{opencodeBinary:t}).catch(r=>v.error("Failed to set default binary",r));const n=$n(t,void 0,dt());H("ui",{opencodeBinaries:n}).catch(r=>v.error("Failed to update binary list",r))}function wc(e){K("server",{logLevel:e??"DEBUG"}).catch(n=>v.error("Failed to set log level",n))}async function bc(e){const t=Ga(e);try{await K("server",{speech:t})}catch(n){throw v.error("Failed to update speech settings",n),n}}function Cc(e,t){const n=$n(e,t,dt());H("ui",{opencodeBinaries:n}).catch(r=>v.error("Failed to add binary",r))}function Sc(e){const t=dt().filter(n=>n.path!==e);H("ui",{opencodeBinaries:t}).catch(n=>v.error("Failed to remove binary",n)),me().opencodeBinary===e&&K("server",{opencodeBinary:"opencode"}).catch(n=>v.error("Failed to reset default binary",n))}function vc(e){const t=fo(e,ut());H("ui",{recentFolders:t}).catch(n=>v.error("Failed to add recent folder",n))}function xc(e){const t=ut().filter(n=>n.path!==e);H("ui",{recentFolders:t}).catch(n=>v.error("Failed to remove recent folder",n))}async function Ec(e,t){const n=t.trim();if(!e||!n)return;const r=ut().map(o=>o.path===e?{...o,projectName:n}:o);try{await H("ui",{recentFolders:r})}catch(o){throw v.error("Failed to rename recent folder",o),o}}async function Oc(e){const t=oc(e,ze());return await H("ui",{remoteServers:ho(t,ze())}),t}async function Ac(e){const t=ze().find(o=>o.id===e);if(!t)return;const n=new Date().toISOString(),r={...t,updatedAt:n,lastConnectedAt:n};await H("ui",{remoteServers:ho(r,ze())})}function Tc(e){const t=ze().filter(n=>n.id!==e);H("ui",{remoteServers:t}).catch(n=>v.error("Failed to remove remote server",n))}function kc(e,t,n){const r=t&&t.trim().length>0?t:me().opencodeBinary,o=fo(e,ut(),n),s=$n(r,void 0,dt());H("ui",{recentFolders:o,opencodeBinaries:s}).catch(i=>v.error("Failed to update ui state on launch",i)),K("server",{opencodeBinary:r}).catch(i=>v.error("Failed to persist selected binary",i))}function $c(e){if(!e.providerId||!e.modelId)return;const n=ie().models.recents.filter(o=>o.providerId!==e.providerId||o.modelId!==e.modelId),r=[e,...n].slice(0,Ja);H("ui",{models:{recents:r}}).catch(o=>v.error("Failed to update model recents",o))}function Pc(e){return!e.providerId||!e.modelId?!1:ie().models.favorites.some(t=>t.providerId===e.providerId&&t.modelId===e.modelId)}function Ic(e){if(!e.providerId||!e.modelId)return;const t=ie().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,Ya);H("ui",{models:{favorites:r}}).catch(o=>v.error("Failed to update model favorites",o))}function Mc(e){if(!(!e.providerId||!e.modelId))return ie().models.thinkingSelections[uo(e)]}function Dc(e,t){if(!e.providerId||!e.modelId)return;const n=uo(e);if(ie().models.thinkingSelections[n]===t)return;const o={...ie().models.thinkingSelections};t?o[n]=t:delete o[n],H("ui",{models:{thinkingSelections:o}}).catch(s=>v.error("Failed to update thinking selection",s))}function Lc(e){B().diffViewMode!==e&&G({diffViewMode:e})}function Nc(e){const t=B();t.toolOutputExpansion===e&&t.toolCallExpansionDefaults.tools.other===e||G({toolOutputExpansion:e,toolCallExpansionDefaults:{...t.toolCallExpansionDefaults,preset:"custom",tools:{...t.toolCallExpansionDefaults.tools,other:e}}})}function Rc(e){B().diagnosticsExpansion!==e&&G({diagnosticsExpansion:e})}function Fc(e){B().toolInputsVisibility!==e&&G({toolInputsVisibility:e})}function _c(e){const t=B();t.thinkingBlocksExpansion===e&&t.toolCallExpansionDefaults.thinking===e||G({thinkingBlocksExpansion:e,toolCallExpansionDefaults:{...t.toolCallExpansionDefaults,preset:"custom",thinking:e}})}function Uc(){G({showThinkingBlocks:!B().showThinkingBlocks})}function Bc(){yo({showKeyboardShortcutHints:!B().showKeyboardShortcutHints})}function Wc(){G({showTimelineTools:!B().showTimelineTools})}function jc(){G({showMessageTimeline:!(B().showMessageTimeline??!0)})}function Vc(){G({showUsageMetrics:!B().showUsageMetrics})}function zc(){G({promptSubmitOnEnter:!B().promptSubmitOnEnter})}function Kc(){G({showPromptVoiceInput:!B().showPromptVoiceInput})}function Hc(){const e=!B().autoCleanupBlankSessions;v.info("toggle auto cleanup",{value:e}),G({autoCleanupBlankSessions:e})}async function Gc(e,t,n){!e||!t||!n.providerId||!n.modelId||(await qt(e),await oo(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 qc(e,t){return!e||!t?void 0:(await qt(e),(so(e).agentModelSelections??{})[t])}Jt().catch(e=>{v.error("Failed to initialize settings",e)});const bo=Ke(),Jc={isLoaded:go,preferences:B,useTauriNativeEventTransport:mo,setUseTauriNativeEventTransport:uc,updatePreferences:yo,themePreference:po,setThemePreference:dc,serverSettings:me,setListeningMode:fc,updateEnvironmentVariables:wo,addEnvironmentVariable:hc,removeEnvironmentVariable:gc,isSecureEnvVar:mc,toggleSecureEnvVar:pc,updateLastUsedBinary:yc,updateLogLevel:wc,updateSpeechSettings:bc,recentFolders:ut,opencodeBinaries:dt,remoteServers:ze,uiState:ie,addRecentFolder:vc,removeRecentFolder:xc,renameRecentFolderProject:Ec,addOpenCodeBinary:Cc,removeOpenCodeBinary:Sc,saveRemoteServerProfile:Oc,markRemoteServerConnected:Ac,removeRemoteServerProfile:Tc,recordWorkspaceLaunch:kc,addRecentModelPreference:$c,isFavoriteModelPreference:Pc,toggleFavoriteModelPreference:Ic,getModelThinkingSelection:Mc,setModelThinkingSelection:Dc,toggleShowThinkingBlocks:Uc,toggleKeyboardShortcutHints:Bc,toggleShowMessageTimeline:jc,toggleShowTimelineTools:Wc,toggleUsageMetrics:Vc,toggleAutoCleanupBlankSessions:Hc,togglePromptSubmitOnEnter:zc,toggleShowPromptVoiceInput:Kc,setDiffViewMode:Lc,setToolOutputExpansion:Nc,setDiagnosticsExpansion:Rc,setThinkingBlocksExpansion:_c,setToolInputsVisibility:Fc,setAgentModelPreference:Gc,getAgentModelPreference:qc},pu=e=>(Ut(()=>{Jt().catch(o=>{v.error("Failed to initialize settings",o)});const t=ee.onConfigOwnerChanged("ui",o=>{Dt(o),nt(!0)}),n=ee.onConfigOwnerChanged("server",o=>{Lt(o),nt(!0),Ha(),Ka(!0)}),r=ee.onStateOwnerChanged("ui",o=>{Nt(o),nt(!0)});return()=>{t(),n(),r()}}),he(bo.Provider,{value:Jc,get children(){return e.children}}));function Yc(){const e=at(bo);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}function Xc(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 Zc=Symbol("solid-inspect"),Qc=Ke();function el(e){function t(n){var r;return(r=at(Qc))!=null&&r.enabled?{Component:t,props:n,$INSPECT:Zc}:e(n)}return Object.defineProperty(t,"name",{value:e.name}),t.toString=e.toString,t}function Co(){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 Xc(e.slotClasses(a),e.utilityClass,a.classes??"")},l=ls({});return c&&Do(()=>{const d=u();ve(()=>{for(const f in d)l[f]=d[f]})}),l}function n(a){const[c,u]=_t(a,e.selfPropNames);return{allProps:a,props:c,otherProps:u}}function r(a){return Zs({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=el(a),a.toString=()=>`.${e.name}-root`,c&&Hr(a,"base"),a}function i(a){const c=s(function(l){const{allProps:d,otherProps:f,props:m}=o(l),w=e.autoCallUseClasses??!0?t(d):{};return a({allProps:d,otherProps:f,props:m,classes:w})});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=Co()({name:"MuiGlobalStyles",selfPropNames:["styles"]}),nl=tl.component(function({props:t}){return Br(()=>({"@global":t.styles||{}})),[]}),rl=Co()({name:"MuiCssBaseline",selfPropNames:["children","enableColorScheme"],propDefaults:({set:e})=>e({enableColorScheme:!1})}),ol=(e,t)=>({WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",boxSizing:"border-box",WebkitTextSizeAdjust:"100%",...t&&{colorScheme:e.palette.mode}}),sl=e=>({color:e.palette.text.primary,...e.typography.body1,backgroundColor:e.palette.background.default,"@media print":{backgroundColor:e.palette.common.white}}),il=(e,t=!1)=>({html:ol(e,t),"*, *::before, *::after":{boxSizing:"inherit"},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...sl(e),"&::backdrop":{backgroundColor:e.palette.background.default}}}),al=rl.component(function({props:t}){const n=Ir();return he(nl,{get styles(){return il(n,t.enableColorScheme)}})}),So=Ke();function cr(e){if(!(typeof document>"u")){if(e==="system"){document.documentElement.removeAttribute("data-theme");return}document.documentElement.setAttribute("data-theme",e)}}const cl={backgroundDefault:"#ffffff",backgroundPaper:"#f5f5f5",primary:"#0066ff",primaryContrast:"#ffffff",textPrimary:"#1a1a1a",textSecondary:"#666666",divider:"#e0e0e0"},ll={backgroundDefault:"#1a1a1a",backgroundPaper:"#2a2a2a",primary:"#0080ff",primaryContrast:"#1a1a1a",textPrimary:"#cfd4dc",textSecondary:"#999999",divider:"#3a3a3a"},Ce=(e,t,n)=>{if(!n)return t;const r=n.getPropertyValue(e);return r&&r.trim()||t},ul=e=>{const t=e?ll:cl,n=typeof window<"u"?getComputedStyle(document.documentElement):null;return{backgroundDefault:Ce("--surface-base",t.backgroundDefault,n),backgroundPaper:Ce("--surface-secondary",t.backgroundPaper,n),primary:Ce("--accent-primary",t.primary,n),primaryContrast:Ce("--text-inverted",t.primaryContrast,n),textPrimary:Ce("--text-primary",t.textPrimary,n),textSecondary:Ce("--text-secondary",t.textSecondary,n),divider:Ce("--border-base",t.divider,n)}};function yu(e){const t=typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)"):null,{themePreference:n,setThemePreference:r}=Yc(),[o,s]=$(!0),[i,a]=$(0),c=()=>n(),u=()=>{const w=c();return w==="dark"?!0:w==="light"?!1:(t==null?void 0:t.matches)??!1},l=()=>{const w=c(),g=u();cr(w==="system"?"system":w),s(g),typeof window<"u"?requestAnimationFrame(()=>a(b=>b+1)):a(b=>b+1)};z(()=>{l()}),Ut(()=>{if(!t)return;const w=()=>{l()};return t.addEventListener("change",w),()=>{t.removeEventListener("change",w)}});const d=w=>{r(w)},f=()=>{const w=c();d(w==="system"?"light":w==="light"?"dark":"system")},m=L(()=>{i();const w=ul(o());return kr({palette:{mode:o()?"dark":"light",primary:{main:w.primary,contrastText:w.primaryContrast},secondary:{main:w.primary},background:{default:w.backgroundDefault,paper:w.backgroundPaper},text:{primary:w.textPrimary,secondary:w.textSecondary},divider:w.divider},typography:{fontFamily:"var(--font-family-sans)"},shape:{borderRadius:8},components:{MuiIconButton:{styleOverrides:{root:{color:"inherit","&.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:"56px"}}}}})});return he(So.Provider,{value:{isDark:o,themeMode:c,setThemeMode:d,cycleThemeMode:f},get children(){return he(Qs,{get theme(){return m()},get children(){return[he(al,{}),zo(()=>e.children)]}})}})}function vo(){const e=at(So);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}const dl=/(^|\n)@@/m,fl=/(^|\n)(diff --git |--- |\+\+\+)/,hl=/^\*\*\* (Begin|End) Patch/,gl=/^\*\*\* Update File: (.+)$/,ml=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function pl(e){const t=e.trim();if(!t.startsWith("```"))return t;const n=t.split(`
|
|
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 _r(s,e),dn(s),s;{s&&s.remove();const i=li(e,t);if(dn(i),n){let a=o.querySelector(`#${Vn}`);a||(a=document.createElement("style"),a.setAttribute("id",Vn),o.prepend(a)),o.insertBefore(i,a)}else o.appendChild(i);return i}}function di(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 zn(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 Yl(e){if(typeof e!="string")throw new Error("MUI: `capitalize(string)` expects a string argument.");return e.charAt(0).toUpperCase()+e.slice(1)}function Xl(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 Zl(e){const t=e.documentElement.clientWidth;return Math.abs(window.innerWidth-t)}function fi(e){return e&&e.ownerDocument||document}function Ql(e){return fi(e).defaultView||window}function Ur(){return Math.random().toString(36).substring(2,15).slice(0,8)}let jt=!0,fn=!1,Kn;const hi={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 gi(e){const{type:t,tagName:n}=e;return!!(n==="INPUT"&&hi[t]&&!e.readOnly||n==="TEXTAREA"&&!e.readOnly||e.isContentEditable)}function mi(e){e.metaKey||e.altKey||e.ctrlKey||(jt=!0)}function Zt(){jt=!1}function pi(){this.visibilityState==="hidden"&&fn&&(jt=!0)}function yi(e){e.addEventListener("keydown",mi,!0),e.addEventListener("mousedown",Zt,!0),e.addEventListener("pointerdown",Zt,!0),e.addEventListener("touchstart",Zt,!0),e.addEventListener("visibilitychange",pi,!0)}function wi(e){const{target:t}=e;try{return t.matches(":focus-visible")}catch{}return jt||gi(t)}function eu(){const e=s=>{s!=null&&yi(s.ownerDocument)},[t,n]=$(!1);function r(){return t()?(fn=!0,window.clearTimeout(Kn),Kn=window.setTimeout(()=>{fn=!1},100),n(!1),!0):!1}function o(s){return wi(s)?(n(!0),!0):!1}return{isFocusVisibleRef:{get current(){return t()}},onFocus:o,onBlur:r,ref:e}}const bi=new ii;function Ci(e){return e?Array.isArray(e)?e.flat(1/0).filter(t=>!!t):[e]:[]}function Si(){if(!D.context)return Ur();const e=Mo().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 Br(e){const t=at(ws),[n,r]=$(""),o=Si();let s,i=!1;return de(a=>{var l;const c=e();let u;if(c){const d=ni(Ci(c));i="@global"in d,u=ai({name:"css",props:d,cache:bi,componentId:o}),s=di(u.id),s?dn(s):s=ui(u.rules,{id:u.id,nonce:(l=t.cache)==null?void 0:l.nonce},t.injectFirst),a!=null&&a.styleElement&&zn(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),fe(()=>{s&&zn(s,t.cleanupStyles??i)}),n}function Le(e,t,n={}){for(const r in e){const o=e[r];if(Nr(r))n[r]=Le(o,t);else if(un(r))n[r]=Le(o,t);else if(Rr(r)){n[r]={};for(const s in o)n[r][s]=Le(o[s],t)}else if(Lr(r))n[r]=Le(o,t);else{const s=t(r,o);if(s)for(const i in s)n[i]=un(i)?{...n[i],...s[i]}:s[i];else n[r]=o}}return n}const vi=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 Wr(e,t){if(typeof t=="number")return{[e]:vi.has(e)?t.toString():`${t}px`}}function Hn(e,t={}){return Le(e,Wr,t)}function It(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 xi(e,t){return t.split(".").reduce((n,r)=>n&&n[r]?n[r]:null,e)}function Ei(e,t,n,r){const o=xi(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 le={x:["Left","Right"],y:["Top","Bottom"]};function jr(e){return typeof e=="number"?`${e}px`:e}function Vr(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 et(e){return h(e,(t,n)=>jr(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 Oi(){return{...Ai(),...Ti(),...ki(),...$i(),...Pi(),...Ii(),...Mi(),...Li(),...Di()}}function Ai(){return{displayPrint:Vr("displayPrint",(e,t)=>({"@media print":{display:t}})),displayRaw:h("display"),overflow:h("overflow"),textOverflow:h("textOverflow"),visibility:h("visibility"),whiteSpace:h("whiteSpace")}}function Ti(){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 ki(){const e=(t,n,r)=>Ei(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 $i(){return{position:h("position"),zIndex:h("zIndex",(e,t,n)=>{var r;return((r=n.zIndex)==null?void 0:r[e])??t}),top:et("top"),right:et("right"),bottom:et("bottom"),left:et("left")}}function Pi(){const e=(t,n,r)=>It(r,"palette",n);return{color:h("color",e),bgcolor:h("backgroundColor",e),backgroundColor:h("backgroundColor",e)}}function Ii(){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 Mi(){const e=(n,r)=>typeof r=="number"?`${r}px solid`:r,t=(n,r,o)=>It(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 Di(){const e=(t,n,r)=>It(r,"typography",n);return{typography:Vr("typography",(t,n,r)=>It(r,"typography",n)),fontFamily:h("fontFamily",e),fontSize:h("fontSize",(t,n,r)=>jr(e(t,n,r))),fontStyle:h("fontStyle",e),fontWeight:h("fontWeight",e),letterSpacing:et("letterSpacing"),lineHeight:h("lineHeight"),textAlign:h("textAlign"),textTransform:h("textTransform")}}function Li(){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,le.x,e),my:q(t,le.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,le.x,e),marginY:q(t,le.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,le.x,e),py:q(n,le.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,le.x,e),paddingY:q(n,le.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 Tn=Oi(),tu=Object.keys(Tn);function Ni(e,t,n){return Tn[e](t,n)}function Gn(e,t,n){return e in Tn?Ni(e,t,n):Wr(e,t)}function Ri(e,t){return Le(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,ps({theme:t},r,s=>Gn(n,s,t)??{[n]:s}))}else return Gn(n,r,t)})}function zr(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=zr(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Fi(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=zr(e))&&(r&&(r+=" "),r+=t);return r}const Kr=["ownerState","theme","sx","as"];function _i(e,t){var n,r;return(r=(n=t.components)==null?void 0:n[e])==null?void 0:r.styleOverrides}function Ui(e,t,n,r,o={}){return L(()=>{const s=e(),i=_i(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(Hn(f,{name:t,__resolved:!0})),l},[]);let u=[];return o.overridesResolver&&typeof o.overridesResolver=="function"&&i&&(u=o.overridesResolver(r,i).map(l=>l?Hn(l,{}):null).filter(Boolean)),c.concat(u)})}function Hr(e,t){e.__suid=t}function qn(e){if(typeof e=="function")return e.__suid}function Bi(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-${Ur()}`,o="css";const i=qn(n);return function(...a){function c(u){let l;const d=()=>{const N=u.theme;return N||l||(l=e&&e.onUseTheme?e.onUseTheme():An())},[,f]=_t(u,r.skipProps||Kr),m=Ui(d,o,a,u,r),w=()=>{const N=u.sx;return N?Array.isArray(N)?N:[N]:[]},g=()=>{if(i)return n;const N=u.as;return N||n},b=i?()=>i:L(()=>qn(g())),A=r.skipSx?()=>m():()=>{const N=d();return[...m(),...w().map(X=>X.__resolved?X:Ri(X,N))]},M=Br(()=>b()?void 0:A());return Mr(g,fr(f,{get children(){return u.children},get component(){return b()?u.component:null},get as(){return i?u.as:void 0},get sx(){return b()?A():void 0},get ownerState(){return b()==="system"?u.ownerState:void 0},get class(){return Fi([...new Set([u.class,s,M()])])}}))}return Hr(c,"system"),s&&(c.toString=()=>`.${s}`),c}}}const nu=[...Kr,"classes"],ru=Bi({onUseTheme:()=>Ir()}),Wi="modulepreload",ji=function(e){return"/"+e},Jn={},Vi=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),a=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=Promise.allSettled(n.map(c=>{if(c=ji(c),c in Jn)return;Jn[c]=!0;const u=c.endsWith(".css"),l=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${l}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Wi,u||(d.as="script"),d.crossOrigin="",d.href=c,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((f,m)=>{d.addEventListener("load",f),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return o.then(i=>{for(const a of i||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},Gr="codenomad-use-tauri-native-event-transport";function qr(){var e;if(typeof window>"u")return!0;try{return((e=window.localStorage)==null?void 0:e.getItem(Gr))!=="0"}catch{return!0}}function zi(e){var t;if(!(typeof window>"u"))try{(t=window.localStorage)==null||t.setItem(Gr,e?"1":"0")}catch{}}const Ki="codenomad.client-id",Hi="codenomad.connection-id";let yt=null,wt=null;function hn(){return{clientId:Gi(),connectionId:qi()}}function Gi(){return yt||(yt=Jr(Ki,window.localStorage),yt)}function qi(){return wt||(wt=Jr(Hi,window.sessionStorage),wt)}function Jr(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,Yn;function Ji(){if(Yn)return en;Yn=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]),m=(d[2]||"ms").toLowerCase();switch(m){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,m){var w=d>=f*1.5;return Math.round(l/f)+" "+m+(w?"s":"")}return en}function Yi(e){n.debug=n,n.default=n,n.coerce=c,n.disable=i,n.enable=o,n.enabled=a,n.humanize=Ji(),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,m,w;function g(...b){if(!g.enabled)return;const A=g,M=Number(new Date),N=M-(d||M);A.diff=N,A.prev=d,A.curr=M,d=M,b[0]=n.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let X=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(W,p)=>{if(W==="%%")return"%";X++;const C=n.formatters[p];if(typeof C=="function"){const O=b[X];W=C.call(A,O),b.splice(X,1),X--}return W}),n.formatArgs.call(A,b),(A.log||n.log).apply(A,b)}return g.namespace=l,g.useColors=n.useColors(),g.color=n.selectColor(l),g.extend=r,g.destroy=n.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(m!==n.namespaces&&(m=n.namespaces,w=n.enabled(l)),w),set:b=>{f=b}}),typeof n.init=="function"&&n.init(g),g}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,m=0,w=-1,g=0;for(;f<l.length;)if(m<d.length&&(d[m]===l[f]||d[m]==="*"))d[m]==="*"?(w=m,g=f,m++):(f++,m++);else if(w!==-1)m=w+1,g++,f=g;else return!1;for(;m<d.length&&d[m]==="*";)m++;return m===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 Xi=Yi;(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,m=>{m!=="%%"&&(d++,m==="%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=Xi(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 Zi=gn.exports;const mn=No(Zi),He=["sse","api","session","actions"],Yr="opencode:logger:namespaces",tn=new Map,ne=new Set,oe=typeof globalThis<"u"?globalThis.console:void 0;function lt(){ne.size===0?mn.disable():mn.enable(Array.from(ne).join(","))}function Vt(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{window.localStorage.setItem(Yr,JSON.stringify(Array.from(ne)))}catch(t){(e=oe==null?void 0:oe.warn)==null||e.call(oe,"Failed to persist logger namespaces",t)}}function Qi(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{const t=window.localStorage.getItem(Yr);if(!t)return;const n=JSON.parse(t);if(!Array.isArray(n))return;for(const r of n)He.includes(r)&&ne.add(r)}catch(t){(e=oe==null?void 0:oe.warn)==null||e.call(oe,"Failed to hydrate logger namespaces",t)}}Qi();lt();function ea(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 ae(e){if(!He.includes(e))throw new Error(`Unknown logger namespace: ${e}`);return tn.has(e)||tn.set(e,ea(e)),tn.get(e)}function ta(){return He.map(e=>({name:e,enabled:ne.has(e)}))}function na(e){if(!He.includes(e))throw new Error(`Unknown logger namespace: ${e}`);ne.has(e)||(ne.add(e),Vt(),lt())}function ra(e){if(!He.includes(e))throw new Error(`Unknown logger namespace: ${e}`);ne.has(e)&&(ne.delete(e),Vt(),lt())}function oa(){ne.clear(),Vt(),lt()}function sa(){He.forEach(e=>ne.add(e)),Vt(),lt()}const ia={listLoggerNamespaces:ta,enableLogger:na,disableLogger:ra,enableAllLoggers:sa,disableAllLoggers:oa};function aa(){typeof window>"u"||(window.codenomadLogger=ia)}aa();function ca(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)}})}const nn={};var ur;const la=typeof window<"u"?(ur=window.location)==null?void 0:ur.origin:void 0,ua=typeof window<"u"?window.__CODENOMAD_API_BASE__??la:void 0,da=typeof window<"u"?window.__CODENOMAD_EVENTS_URL__??"/api/events":"/api/events",ge=(nn==null?void 0:nn.VITE_CODENOMAD_API_BASE)??ua,rn=fa(ge,da),ou=ge;function su(e,t){const n=encodeURIComponent(e),r=encodeURIComponent(t);return ha(`/workspaces/${n}/plugin/background-processes/${r}/stream`)}function fa(e,t){if(t.startsWith("http://")||t.startsWith("https://"))return t;if(e){const n=t.startsWith("/")?t:`/${t}`;return`${e}${n}`}return t}function ha(e){if(e.startsWith("http://")||e.startsWith("https://")||!ge)return e;const t=e.startsWith("/")?e:`/${e}`;return`${ge}${t}`}const Xn=ae("api"),Zn=ae("sse");function Xr(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 Se(e,t){if(t){Xn.info(e,t);return}Xn.info(e)}async function Zr(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 y(e,t){const n=ge?new URL(e,ge).toString():e,r=Xr(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();Se(`${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 Zr(i);throw Se(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s,error:c}),new Error(c||`Request failed with ${i.status}`)}const a=Date.now()-s;return Se(`${o} ${e} -> ${i.status}`,{durationMs:a}),i.status===204?void 0:await i.json()}catch(i){throw Se(`${o} ${e} failed`,{durationMs:Date.now()-s,error:i}),i}}async function ga(e,t){const n=ge?new URL(e,ge).toString():e,r=Xr(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();Se(`${o} ${e}`);const i=await fetch(n,{...t,headers:r,credentials:(t==null?void 0:t.credentials)??"include"});if(!i.ok){const a=await Zr(i);throw Se(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s,error:a}),new Error(a||`Request failed with ${i.status}`)}return Se(`${o} ${e} -> ${i.status}`,{durationMs:Date.now()-s}),i}const re={fetchWorkspaces(){return y("/api/workspaces")},fetchProviderUsage(e,t){const n=new URLSearchParams;t&&n.set("modelId",t);const r=n.toString();return y(`/api/usage/${encodeURIComponent(e)}${r?`?${r}`:""}`)},fetchWorktrees(e){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees`)},createWorktree(e,t){return y(`/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 y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}${o}`,{method:"DELETE"})},readWorktreeMap(e){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/map`)},writeWorktreeMap(e,t){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/map`,{method:"PUT",body:JSON.stringify(t)})},createWorkspace(e,t){return y("/api/workspaces",{method:"POST",body:JSON.stringify(e),signal:t==null?void 0:t.signal})},cancelWorkspaceCreation(e){return y("/api/workspaces/creation/cancel",{method:"POST",body:JSON.stringify({requestId:e})})},releaseWorkspaceCreation(e,t){return y(`/api/workspaces/${encodeURIComponent(e)}/creation/release`,{method:"POST",body:JSON.stringify({requestId:t})})},fetchSidecars(){return y("/api/sidecars")},createSidecar(e){return y("/api/sidecars",{method:"POST",body:JSON.stringify(e)})},updateSidecar(e,t){return y(`/api/sidecars/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteSidecar(e){return y(`/api/sidecars/${encodeURIComponent(e)}`,{method:"DELETE"})},createPreview(e){return y("/api/previews",{method:"POST",body:JSON.stringify(e)})},deletePreview(e){return y(`/api/previews/${encodeURIComponent(e)}`,{method:"DELETE"})},fetchServerMeta(){return y("/api/meta")},probeRemoteServer(e){return y("/api/remote-servers/probe",{method:"POST",body:JSON.stringify(e)})},createRemoteProxySession(e){return y("/api/remote-proxy/sessions",{method:"POST",body:JSON.stringify(e)})},deleteRemoteProxySession(e){return y(`/api/remote-proxy/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})},fetchAuthStatus(){return y("/api/auth/status")},listConfigFiles(){return y("/api/config-files")},readConfigFile(e){return y(`/api/config-files/${encodeURIComponent(e)}/content`)},writeConfigFile(e,t){const n={contents:t};return y(`/api/config-files/${encodeURIComponent(e)}/content`,{method:"PUT",body:JSON.stringify(n)})},setServerPassword(e){return y("/api/auth/password",{method:"POST",body:JSON.stringify({password:e})})},deleteWorkspace(e){return y(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})},cloneWorkspaceRepository(e){return y("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})},listWorkspaceFiles(e,t="."){const n=new URLSearchParams({path:t});return y(`/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});return n!=null&&n.limit&&o.set("limit",String(n.limit)),n!=null&&n.type&&o.set("type",n.type),y(`/api/workspaces/${encodeURIComponent(e)}/files/search?${o.toString()}`)},readWorkspaceFile(e,t,n){const r=new URLSearchParams({path:t});return n!=null&&n.encoding&&r.set("encoding",n.encoding),y(`/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),y(`/api/workspaces/${encodeURIComponent(e)}/files/content?${o.toString()}`,{method:"PUT",body:JSON.stringify({contents:n})})},fetchWorktreeGitStatus(e,t){return y(`/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),y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-diff?${r.toString()}`)},stageWorktreeGitPaths(e,t,n){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-stage`,{method:"POST",body:JSON.stringify(n)})},unstageWorktreeGitPaths(e,t,n){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-unstage`,{method:"POST",body:JSON.stringify(n)})},commitWorktreeGitChanges(e,t,n){return y(`/api/workspaces/${encodeURIComponent(e)}/worktrees/${encodeURIComponent(t)}/git-commit`,{method:"POST",body:JSON.stringify(n)})},fetchConfigOwner(e){return y(`/api/storage/config/${encodeURIComponent(e)}`)},patchConfigOwner(e,t){return y(`/api/storage/config/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t??{})})},fetchStateOwner(e){return y(`/api/storage/state/${encodeURIComponent(e)}`)},patchStateOwner(e,t){return y(`/api/storage/state/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t??{})})},validateBinary(e){return y("/api/storage/binaries/validate",{method:"POST",body:JSON.stringify({path:e})})},fetchOpenCodeUpdateStatus(){return y("/api/opencode/update")},updateOpenCode(){return y("/api/opencode/update",{method:"POST"})},fetchSpeechCapabilities(){return y("/api/speech/capabilities")},transcribeAudio(e){return y("/api/speech/transcribe",{method:"POST",body:JSON.stringify(e)})},synthesizeSpeech(e){return y("/api/speech/synthesize",{method:"POST",body:JSON.stringify(e)})},synthesizeSpeechStream(e,t){return ga("/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 y(r?`/api/filesystem?${r}`:"/api/filesystem")},createFileSystemFolder(e,t){return y("/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),y(`/api/filesystem/files/content?${n.toString()}`)},readInstanceData(e){return y(`/api/storage/instances/${encodeURIComponent(e)}`)},writeInstanceData(e,t){return y(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})},deleteInstanceData(e){return y(`/api/storage/instances/${encodeURIComponent(e)}`,{method:"DELETE"})},listBackgroundProcesses(e){return y(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes`)},stopBackgroundProcess(e,t){return y(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/stop`,{method:"POST"})},terminateBackgroundProcess(e,t){return y(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/terminate`,{method:"POST"})},updateVoiceMode(e,t){const n=hn();return y(`/workspaces/${encodeURIComponent(e)}/plugin/voice-mode`,{method:"POST",body:JSON.stringify({...n,enabled:t})})},getYoloState(e,t){return y(`/workspaces/${encodeURIComponent(e)}/yolo/sessions/${encodeURIComponent(t)}`)},toggleYolo(e,t){return y(`/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),y("/api/client-connections/pong",n)},fetchBackgroundProcessOutput(e,t,n){const r=new URLSearchParams;n!=null&&n.method&&r.set("method",n.method),n!=null&&n.pattern&&r.set("pattern",n.pattern),n!=null&&n.lines&&r.set("lines",String(n.lines)),(n==null?void 0:n.maxBytes)!==void 0&&r.set("maxBytes",String(n.maxBytes));const o=r.toString(),s=o?`?${o}`:"";return y(`/workspaces/${encodeURIComponent(e)}/plugin/background-processes/${encodeURIComponent(t)}/output${s}`)},connectEvents(e,t,n){const r=hn(),o=ma(r);Zn.info(`Connecting to ${o}`);const s=new EventSource(o,{withCredentials:!0});return ca(s,{onEvent:e,onError:t,onPing:n,logger:Zn}),s}};function ma(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}`}const pa={initialDelayMs:1e3,maxDelayMs:1e4,multiplier:2};function ya(e){return{reconnect:{...pa,...e==null?void 0:e.reconnect}}}function Qr(){if(typeof window>"u"||window.__CODENOMAD_WINDOW_CONTEXT__==="remote")return"remote";if(window.__CODENOMAD_WINDOW_CONTEXT__==="local")return"local";const e=window;return typeof e.electronAPI<"u"||typeof e.__TAURI__<"u"||typeof navigator<"u"&&/tauri/i.test(navigator.userAgent)?"local":"remote"}function zt(){if(typeof window>"u")return"web";const e=window.__CODENOMAD_RUNTIME_HOST__;if(e)return e;const t=window;return typeof t.electronAPI<"u"?"electron":typeof t.__TAURI__<"u"||typeof navigator<"u"&&/tauri/i.test(navigator.userAgent)?"tauri":"web"}function wa(){if(typeof navigator>"u")return"desktop";const e=navigator.userAgentData;if(e!=null&&e.mobile)return"mobile";const t=navigator.userAgent.toLowerCase();return/android|iphone|ipad|ipod|blackberry|mini|windows phone|mobile|silk/.test(t)?"mobile":"desktop"}const ba=ae("actions");let we=null;function Ca(){return we||(we={host:zt(),platform:wa(),windowContext:Qr()},typeof window<"u"&&ba.info(`[runtime] host=${we.host} platform=${we.platform} context=${we.windowContext}`),we)}const $e=Ca(),Sa=()=>zt()==="electron",va=()=>zt()==="tauri",iu=()=>zt()==="web",Kt=()=>Sa()||va(),Ht=()=>Qr()==="local",au=()=>Kt()&&Ht(),cu=()=>Kt()&&Ht(),lu=()=>Kt()&&Ht(),uu=()=>Kt()&&Ht();function R(e,t,n,r){if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function qe(e,t,n,r,o){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var be,J,Pe,bt;const Qn="__TAURI_TO_IPC_KEY__";function eo(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}class xa{constructor(t){be.set(this,void 0),J.set(this,0),Pe.set(this,[]),bt.set(this,void 0),qe(this,be,t||(()=>{})),this.id=eo(n=>{const r=n.index;if("end"in n){r==R(this,J,"f")?this.cleanupCallback():qe(this,bt,r);return}const o=n.message;if(r==R(this,J,"f")){for(R(this,be,"f").call(this,o),qe(this,J,R(this,J,"f")+1);R(this,J,"f")in R(this,Pe,"f");){const s=R(this,Pe,"f")[R(this,J,"f")];R(this,be,"f").call(this,s),delete R(this,Pe,"f")[R(this,J,"f")],qe(this,J,R(this,J,"f")+1)}R(this,J,"f")===R(this,bt,"f")&&this.cleanupCallback()}else R(this,Pe,"f")[r]=o})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(t){qe(this,be,t)}get onmessage(){return R(this,be,"f")}[(be=new WeakMap,J=new WeakMap,Pe=new WeakMap,bt=new WeakMap,Qn)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[Qn]()}}class er{constructor(t,n,r){this.plugin=t,this.event=n,this.channelId=r}async unregister(){return je(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function du(e,t,n){const r=new xa(n);try{return await je(`plugin:${e}|register_listener`,{event:t,handler:r}),new er(e,t,r.id)}catch{return await je(`plugin:${e}|registerListener`,{event:t,handler:r}),new er(e,t,r.id)}}async function je(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}var tr;(function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"})(tr||(tr={}));async function Ea(e,t){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,t),await je("plugin:event|unlisten",{event:e,eventId:t})}async function Oa(e,t,n){var r;const o=typeof(n==null?void 0:n.target)=="string"?{kind:"AnyLabel",label:n.target}:(r=n==null?void 0:n.target)!==null&&r!==void 0?r:{kind:"Any"};return je("plugin:event|listen",{event:e,target:o,handler:eo(t)}).then(s=>async()=>Ea(e,s))}const Ct=ae("sse"),Aa={invoke:je,listen:Oa};function Ta(e){let t=!1;return()=>{var n;t||(t=!0,(n=e.onError)==null||n.call(e))}}function ka(e){return e==="connected"?"connected":e==="connecting"?"connecting":"disconnected"}async function $a(e,t,n=Aa){let r=!1,o=!1,s=null;const i=Ta(e),a=[],c=[],u=g=>s===g,l=g=>{var A,M;if(!g||!u(g.generation))return;o||(o=!0,(A=e.onStatus)==null||A.call(e,"connected"),(M=e.onOpen)==null||M.call(e));const b=g.events??[];b.length!==0&&e.onBatch(b)},d=g=>{var b,A;if(!(!g||!u(g.generation))){if((b=e.onStatus)==null||b.call(e,ka(g.state)),g.state==="connected"&&!o&&(o=!0,(A=e.onOpen)==null||A.call(e)),g.state==="unauthorized"?Ct.warn("Native desktop event transport is waiting for authentication",{reason:g.reason,reconnectAttempt:g.reconnectAttempt,nextDelayMs:g.nextDelayMs,stats:g.stats}):g.state==="error"?Ct.warn("Native desktop event transport reported an error",{reason:g.reason,reconnectAttempt:g.reconnectAttempt,nextDelayMs:g.nextDelayMs,statusCode:g.statusCode,stats:g.stats}):(g.state==="disconnected"||g.state==="stopped")&&g.stats&&Ct.info("Native desktop event transport stats",{state:g.state,reconnectAttempt:g.reconnectAttempt,stats:g.stats}),g.state==="stopped"){i();return}g.terminal&&i()}},f=()=>{if(s!==null){for(const g of c.splice(0,c.length))d(g);for(const g of a.splice(0,a.length))l(g)}},m=await n.listen("desktop:event-batch",g=>{if(r)return;const b=g.payload;if(b){if(s===null){a.push(b);return}l(b)}}),w=await n.listen("desktop:event-stream-status",g=>{if(r)return;const b=g.payload;if(b){if(s===null){c.push(b);return}d(b)}});try{const g=await n.invoke("desktop_events_start",{request:t});if(!(g!=null&&g.started))throw new Error((g==null?void 0:g.reason)??"desktop event transport unavailable");s=g.generation??null,f()}catch(g){throw m(),w(),g}return{disconnect(){r||(r=!0,m(),w(),n.invoke("desktop_events_stop").catch(g=>{Ct.warn("Failed to stop native desktop event transport",g)}))}}}const Je=ae("sse");async function Pa(e){const t=()=>{var r,o;(r=e.onStatus)==null||r.call(e,"disconnected"),(o=e.onError)==null||o.call(e)},n=re.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 Ia(e,t){const n=qr();if($e.host==="tauri"&&$e.windowContext==="local"&&n)try{const r=await $a(e,ya(t));return Je.info("Event transport: rust-native (desktop_event_transport)"),r}catch(r){Je.warn("Failed to start native desktop event transport, falling back to browser EventSource",r)}else $e.host==="tauri"&&$e.windowContext==="remote"?Je.info("Event transport: browser-eventsource forced for remote Tauri window"):$e.host==="tauri"&&Je.info("Event transport: browser-eventsource forced by settings");return Je.info(`Event transport: browser-eventsource (host=${$e.host})`),Pa(e)}async function Ma(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,m=setTimeout(()=>f.abort(),i);try{const w=await e(f.signal);return clearTimeout(m),w}catch(w){throw clearTimeout(m),w}}return await e()}catch(f){const m=f instanceof Error?f:new Error(String(f));if(u=m,d<n&&a(m,d))await c(l),l=Math.min(l*s,o);else throw m}throw u||new Error("Failed after retries")}function Da(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,La=1e4,pn=ae("sse");function Ie(e,t){if(t){pn.info(e,t);return}pn.info(e)}class Na{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.connection.disconnect(),this.connection=null),Ie("Connecting to backend events stream");try{const n=await Ia({onBatch:r=>this.dispatchBatch(r),onError:()=>{t===this.connectGeneration&&this.scheduleReconnect()},onStatus:r=>{t===this.connectGeneration&&this.emitTransportStatus(r)},onOpen:()=>{t===this.connectGeneration&&(Ie("Events stream connected"),this.retryDelay=on,this.openHandlers.forEach(r=>r()))},onPing:r=>{const s={...hn(),pingTs:r.ts};Ma(i=>re.sendClientConnectionPong(s,i),{maxAttempts:3,initialDelayMs:100,maxDelayMs:2e3,timeoutMs:1e4,shouldRetry:i=>Da(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;Ie("Events stream failed to connect, scheduling reconnect",{error:n instanceof Error?n.message:String(n)}),this.scheduleReconnect()}}scheduleReconnect(){this.retryTimer||(this.connection&&(this.connection.disconnect(),this.connection=null),this.emitTransportStatus("disconnected"),Ie("Events stream disconnected, scheduling reconnect",{delayMs:this.retryDelay}),this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.retryDelay=Math.min(this.retryDelay*2,La),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&&(Ie("event batch",{size:t.length}),ve(()=>{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.connection.disconnect(),this.connection=null),Ie("Restarting backend events stream",{reason:t}),this.connect()}}const Ot=new Na,Ra=Object.freeze(Object.defineProperty({__proto__:null,serverEvents:Ot},Symbol.toStringTag,{value:"Module"})),Fa=ae("actions"),nr={messageHistory:[],agentModelSelections:{}};function rr(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){Fa.warn("Failed to compare config objects",n)}return!1}class _a{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,Ot.on("storage.configChanged",t=>{t.type==="storage.configChanged"&&this.setOwnerCache("config",t.owner,t.value)}),Ot.on("storage.stateChanged",t=>{t.type==="storage.stateChanged"&&this.setOwnerCache("state",t.owner,t.value)}),Ot.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=re.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)}async patchConfigOwner(t,n){const r=await re.patchConfigOwner(t,n);return 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=re.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)}async patchStateOwner(t,n){const r=await re.patchStateOwner(t,n);return 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=re.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)}async saveInstanceData(t,n){const r=this.normalizeInstanceData(n);await re.writeInstanceData(t,r),this.setInstanceDataCache(t,r)}async deleteInstanceData(t){await re.deleteInstanceData(t),this.setInstanceDataCache(t,nr)}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&&rr(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)}normalizeInstanceData(t){const n=t??nr,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&&rr(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 ee=new _a,to=ae("api"),Gt={messageHistory:[],agentModelSelections:{}},[kn,no]=$(new Map),St=new Map,Ve=new Map;function ro(e){const t=e??Gt;return{...t,messageHistory:Array.isArray(t.messageHistory)?[...t.messageHistory]:[],agentModelSelections:{...t.agentModelSelections??{}}}}function or(e){if(Ve.has(e))return;const t=ee.onInstanceDataChanged(e,n=>{Mt(e,n)});Ve.set(e,t)}function Ua(e){const t=Ve.get(e);t&&(t(),Ve.delete(e))}function Mt(e,t){no(n=>{const r=new Map(n);return r.set(e,ro(t)),r})}async function qt(e){if(!e||kn().has(e))return;if(St.has(e)){await St.get(e);return}const t=ee.loadInstanceData(e).then(n=>{Mt(e,n),or(e)}).catch(n=>{to.warn("Failed to load instance data",n),Mt(e,Gt),or(e)}).finally(()=>{St.delete(e)});St.set(e,t),await t}async function oo(e,t){if(!e)return;await qt(e);const n=kn().get(e)??Gt,r=ro(n);t(r);try{await ee.saveInstanceData(e,r)}catch(o){to.warn("Failed to persist instance data",o)}Mt(e,r)}function so(e){return kn().get(e)??Gt}function Ba(e){no(t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}),Ua(e)}const Wa=Ke(),ja={getInstanceConfig:so,ensureInstanceConfig:qt,updateInstanceConfig:oo,clearInstanceConfig:Ba},fu=e=>(fe(()=>{for(const t of Ve.values())t();Ve.clear()}),he(Wa.Provider,{value:ja,get children(){return e.children}})),Va=ae("api");function za(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[sr,yn]=$(null),[hu,ir]=$(!1),[gu,At]=$(null),[mu,io]=$(!1);let Ye=null;async function Ka(e=!1){return!e&&sr()?sr():Ye||(ir(!0),At(null),Ye=re.fetchSpeechCapabilities().then(t=>{io("separateProviders"in t);const r=za(t);return yn(r),At(null),r}).catch(t=>(Va.error("Failed to load speech capabilities",t),yn(null),At(t instanceof Error?t.message:String(t)),null)).finally(()=>{ir(!1),Ye=null}),Ye)}function Ha(){yn(null),At(null),io(!1)}function Ga(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 v=ae("actions"),qa=20,Ja=5,Ya=50,ao={preset:"balanced",thinking:"collapsed"},P={showThinkingBlocks:!1,showKeyboardShortcutHints:!0,thinkingBlocksExpansion:"collapsed",showMessageTimeline:!0,showTimelineTools:!0,holdLongAssistantReplies:!0,promptSubmitOnEnter:!1,showPromptVoiceInput:!0,diffViewMode:"split",toolOutputExpansion:"expanded",diagnosticsExpansion:"expanded",toolInputsVisibility:"collapsed",showUsageMetrics:!0,autoCleanupBlankSessions:!0,keepUnseenSubagentIdleStatus:!1,osNotificationsEnabled:!1,osNotificationsAllowWhenVisible:!1,notifyOnNeedsInput:!0,notifyOnIdle:!0};function ar(e,t){return e==="expanded"||e==="collapsed"?e:t}function Xa(e){return e==="minimal"||e==="balanced"||e==="detailed"||e==="everything"||e==="custom"?e:ao.preset}function Za(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e))n&&(r==="expanded"||r==="collapsed")&&(t[n]=r);return t}function Qa(e,t){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,r=ar(t.thinkingBlocksExpansion,ao.thinking);return{preset:Xa(n==null?void 0:n.preset),thinking:ar(n==null?void 0:n.thinking,r),tools:Za(n==null?void 0:n.tools)}}const Me={provider:"openai-compatible",sttModel:"gpt-4o-mini-transcribe",ttsModel:"gpt-4o-mini-tts",ttsVoice:"alloy",playbackMode:"streaming",ttsFormat:"mp3"};function co(e){const t=e??{};return{showThinkingBlocks:t.showThinkingBlocks??P.showThinkingBlocks,showKeyboardShortcutHints:t.showKeyboardShortcutHints??P.showKeyboardShortcutHints,thinkingBlocksExpansion:t.thinkingBlocksExpansion??P.thinkingBlocksExpansion,showMessageTimeline:t.showMessageTimeline??P.showMessageTimeline,showTimelineTools:t.showTimelineTools??P.showTimelineTools,holdLongAssistantReplies:t.holdLongAssistantReplies??P.holdLongAssistantReplies,promptSubmitOnEnter:t.promptSubmitOnEnter??P.promptSubmitOnEnter,showPromptVoiceInput:t.showPromptVoiceInput??P.showPromptVoiceInput,locale:t.locale??P.locale,diffViewMode:t.diffViewMode??P.diffViewMode,toolCallExpansionDefaults:Qa(t.toolCallExpansionDefaults,t),toolOutputExpansion:t.toolOutputExpansion??P.toolOutputExpansion,diagnosticsExpansion:t.diagnosticsExpansion??P.diagnosticsExpansion,toolInputsVisibility:t.toolInputsVisibility==="hidden"||t.toolInputsVisibility==="collapsed"||t.toolInputsVisibility==="expanded"?t.toolInputsVisibility:P.toolInputsVisibility,showUsageMetrics:t.showUsageMetrics??P.showUsageMetrics,autoCleanupBlankSessions:t.autoCleanupBlankSessions??P.autoCleanupBlankSessions,keepUnseenSubagentIdleStatus:t.keepUnseenSubagentIdleStatus??P.keepUnseenSubagentIdleStatus,osNotificationsEnabled:t.osNotificationsEnabled??P.osNotificationsEnabled,osNotificationsAllowWhenVisible:t.osNotificationsAllowWhenVisible??P.osNotificationsAllowWhenVisible,notifyOnNeedsInput:t.notifyOnNeedsInput??P.notifyOnNeedsInput,notifyOnIdle:t.notifyOnIdle??P.notifyOnIdle}}function lo(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 ec(e){var o,s,i,a,c,u,l,d,f,m;const t=e??{},n=typeof t.sttModel=="string"&&t.sttModel.trim()?t.sttModel.trim():Me.sttModel,r=typeof t.ttsModel=="string"&&t.ttsModel.trim()?t.ttsModel.trim():Me.ttsModel;return{provider:t.provider==="openai-compatible"?t.provider:Me.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():Me.ttsVoice,playbackMode:t.playbackMode==="buffered"||t.playbackMode==="streaming"?t.playbackMode:Me.playbackMode,ttsFormat:t.ttsFormat==="wav"||t.ttsFormat==="opus"||t.ttsFormat==="aac"||t.ttsFormat==="mp3"?t.ttsFormat:Me.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((m=t.tts)==null?void 0:m.model)=="string"&&t.tts.model.trim()?t.tts.model.trim():r}}}function Xe(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 tc(e){var n,r,o;const t=e??{};return{recentFolders:Xe(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:Xe(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:Xe(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:Xe((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:Xe((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:lo((o=t.models)==null?void 0:o.thinkingSelections)}}}function nc(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",s=lo(t.environmentVariables),i=rc(t.secureEnvVars),a=ec(t.speech);return{listeningMode:n,logLevel:r,opencodeBinary:o,environmentVariables:s,secureEnvVars:i,speech:a}}function rc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function uo(e){return`${e.providerId}/${e.modelId}`}function fo(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,qa)}function $n(e,t,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 oc(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??sc(),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 ho(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 sc(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`remote-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}const[Pn,Dt]=$({}),[ic,Lt]=$({}),[ac,Nt]=$({}),[go,nt]=$(!1),[mo,cc]=$(qr()),lc=L(()=>co(Pn().settings)),po=L(()=>Pn().theme??"system"),me=L(()=>nc(ic())),ie=L(()=>tc(ac())),B=lc,ut=L(()=>ie().recentFolders),dt=L(()=>ie().opencodeBinaries),ze=L(()=>ie().remoteServers);let vt=null;async function Jt(){go()||(vt||(vt=Promise.all([ee.loadConfigOwner("ui"),ee.loadConfigOwner("server"),ee.loadStateOwner("ui")]).then(([e,t,n])=>{Dt(e),Lt(t),Nt(n),nt(!0)}).catch(e=>{v.error("Failed to load settings",e),Dt({}),Lt({}),Nt({}),nt(!0)}).finally(()=>{vt=null})),await vt)}async function K(e,t){await Jt();const n=await ee.patchConfigOwner(e,t);e==="ui"&&Dt(n),e==="server"&&Lt(n)}function uc(e){mo()!==e&&(cc(e),zi(e),Vi(async()=>{const{serverEvents:t}=await Promise.resolve().then(()=>Ra);return{serverEvents:t}},void 0).then(({serverEvents:t})=>{t.restart("desktop transport preference changed")}).catch(t=>{v.error("Failed to restart backend events stream after desktop transport preference change",t)}))}async function H(e,t){await Jt();const n=await ee.patchStateOwner(e,t);Nt(n)}function G(e){const t=Pn(),r={settings:co({...t.settings??{},...e})};K("ui",r).catch(o=>v.error("Failed to patch ui settings",o))}function yo(e){G(e)}function dc(e){po()!==e&&K("ui",{theme:e}).catch(t=>v.error("Failed to set theme",t))}async function fc(e){me().listeningMode!==e&&await K("server",{listeningMode:e})}function wo(e){K("server",{environmentVariables:e}).catch(t=>v.error("Failed to update environment variables",t))}function hc(e,t,n=!0){const r=me().environmentVariables;wo({...r,[e]:t});const o=me().secureEnvVars,s=e.toUpperCase(),i=o.some(a=>a.toUpperCase()===s);if(n){if(!i){const a=[...o,e];K("server",{secureEnvVars:a}).catch(c=>v.error("Failed to add secure env var",c))}}else if(i){const a=o.filter(c=>c.toUpperCase()!==s);K("server",{secureEnvVars:a}).catch(c=>v.error("Failed to remove secure env var",c))}}function gc(e){K("server",{environmentVariables:{[e]:null}}).catch(t=>v.error("Failed to remove environment variable",t))}function mc(e){return me().secureEnvVars.some(n=>n.toUpperCase()===e.toUpperCase())}function pc(e){const t=me().secureEnvVars,n=e.toUpperCase(),o=t.some(s=>s.toUpperCase()===n)?t.filter(s=>s.toUpperCase()!==n):[...t,e];K("server",{secureEnvVars:o}).catch(s=>v.error("Failed to update secure env vars",s))}function yc(e){const t=e&&e.trim().length>0?e:"opencode";K("server",{opencodeBinary:t}).catch(r=>v.error("Failed to set default binary",r));const n=$n(t,void 0,dt());H("ui",{opencodeBinaries:n}).catch(r=>v.error("Failed to update binary list",r))}function wc(e){K("server",{logLevel:e??"DEBUG"}).catch(n=>v.error("Failed to set log level",n))}async function bc(e){const t=Ga(e);try{await K("server",{speech:t})}catch(n){throw v.error("Failed to update speech settings",n),n}}function Cc(e,t){const n=$n(e,t,dt());H("ui",{opencodeBinaries:n}).catch(r=>v.error("Failed to add binary",r))}function Sc(e){const t=dt().filter(n=>n.path!==e);H("ui",{opencodeBinaries:t}).catch(n=>v.error("Failed to remove binary",n)),me().opencodeBinary===e&&K("server",{opencodeBinary:"opencode"}).catch(n=>v.error("Failed to reset default binary",n))}function vc(e){const t=fo(e,ut());H("ui",{recentFolders:t}).catch(n=>v.error("Failed to add recent folder",n))}function xc(e){const t=ut().filter(n=>n.path!==e);H("ui",{recentFolders:t}).catch(n=>v.error("Failed to remove recent folder",n))}async function Ec(e,t){const n=t.trim();if(!e||!n)return;const r=ut().map(o=>o.path===e?{...o,projectName:n}:o);try{await H("ui",{recentFolders:r})}catch(o){throw v.error("Failed to rename recent folder",o),o}}async function Oc(e){const t=oc(e,ze());return await H("ui",{remoteServers:ho(t,ze())}),t}async function Ac(e){const t=ze().find(o=>o.id===e);if(!t)return;const n=new Date().toISOString(),r={...t,updatedAt:n,lastConnectedAt:n};await H("ui",{remoteServers:ho(r,ze())})}function Tc(e){const t=ze().filter(n=>n.id!==e);H("ui",{remoteServers:t}).catch(n=>v.error("Failed to remove remote server",n))}function kc(e,t,n){const r=t&&t.trim().length>0?t:me().opencodeBinary,o=fo(e,ut(),n),s=$n(r,void 0,dt());H("ui",{recentFolders:o,opencodeBinaries:s}).catch(i=>v.error("Failed to update ui state on launch",i)),K("server",{opencodeBinary:r}).catch(i=>v.error("Failed to persist selected binary",i))}function $c(e){if(!e.providerId||!e.modelId)return;const n=ie().models.recents.filter(o=>o.providerId!==e.providerId||o.modelId!==e.modelId),r=[e,...n].slice(0,Ja);H("ui",{models:{recents:r}}).catch(o=>v.error("Failed to update model recents",o))}function Pc(e){return!e.providerId||!e.modelId?!1:ie().models.favorites.some(t=>t.providerId===e.providerId&&t.modelId===e.modelId)}function Ic(e){if(!e.providerId||!e.modelId)return;const t=ie().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,Ya);H("ui",{models:{favorites:r}}).catch(o=>v.error("Failed to update model favorites",o))}function Mc(e){if(!(!e.providerId||!e.modelId))return ie().models.thinkingSelections[uo(e)]}function Dc(e,t){if(!e.providerId||!e.modelId)return;const n=uo(e);if(ie().models.thinkingSelections[n]===t)return;const o={...ie().models.thinkingSelections};t?o[n]=t:delete o[n],H("ui",{models:{thinkingSelections:o}}).catch(s=>v.error("Failed to update thinking selection",s))}function Lc(e){B().diffViewMode!==e&&G({diffViewMode:e})}function Nc(e){const t=B();t.toolOutputExpansion===e&&t.toolCallExpansionDefaults.tools.other===e||G({toolOutputExpansion:e,toolCallExpansionDefaults:{...t.toolCallExpansionDefaults,preset:"custom",tools:{...t.toolCallExpansionDefaults.tools,other:e}}})}function Rc(e){B().diagnosticsExpansion!==e&&G({diagnosticsExpansion:e})}function Fc(e){B().toolInputsVisibility!==e&&G({toolInputsVisibility:e})}function _c(e){const t=B();t.thinkingBlocksExpansion===e&&t.toolCallExpansionDefaults.thinking===e||G({thinkingBlocksExpansion:e,toolCallExpansionDefaults:{...t.toolCallExpansionDefaults,preset:"custom",thinking:e}})}function Uc(){G({showThinkingBlocks:!B().showThinkingBlocks})}function Bc(){yo({showKeyboardShortcutHints:!B().showKeyboardShortcutHints})}function Wc(){G({showTimelineTools:!B().showTimelineTools})}function jc(){G({showMessageTimeline:!(B().showMessageTimeline??!0)})}function Vc(){G({showUsageMetrics:!B().showUsageMetrics})}function zc(){G({promptSubmitOnEnter:!B().promptSubmitOnEnter})}function Kc(){G({showPromptVoiceInput:!B().showPromptVoiceInput})}function Hc(){const e=!B().autoCleanupBlankSessions;v.info("toggle auto cleanup",{value:e}),G({autoCleanupBlankSessions:e})}async function Gc(e,t,n){!e||!t||!n.providerId||!n.modelId||(await qt(e),await oo(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 qc(e,t){return!e||!t?void 0:(await qt(e),(so(e).agentModelSelections??{})[t])}Jt().catch(e=>{v.error("Failed to initialize settings",e)});const bo=Ke(),Jc={isLoaded:go,preferences:B,useTauriNativeEventTransport:mo,setUseTauriNativeEventTransport:uc,updatePreferences:yo,themePreference:po,setThemePreference:dc,serverSettings:me,setListeningMode:fc,updateEnvironmentVariables:wo,addEnvironmentVariable:hc,removeEnvironmentVariable:gc,isSecureEnvVar:mc,toggleSecureEnvVar:pc,updateLastUsedBinary:yc,updateLogLevel:wc,updateSpeechSettings:bc,recentFolders:ut,opencodeBinaries:dt,remoteServers:ze,uiState:ie,addRecentFolder:vc,removeRecentFolder:xc,renameRecentFolderProject:Ec,addOpenCodeBinary:Cc,removeOpenCodeBinary:Sc,saveRemoteServerProfile:Oc,markRemoteServerConnected:Ac,removeRemoteServerProfile:Tc,recordWorkspaceLaunch:kc,addRecentModelPreference:$c,isFavoriteModelPreference:Pc,toggleFavoriteModelPreference:Ic,getModelThinkingSelection:Mc,setModelThinkingSelection:Dc,toggleShowThinkingBlocks:Uc,toggleKeyboardShortcutHints:Bc,toggleShowMessageTimeline:jc,toggleShowTimelineTools:Wc,toggleUsageMetrics:Vc,toggleAutoCleanupBlankSessions:Hc,togglePromptSubmitOnEnter:zc,toggleShowPromptVoiceInput:Kc,setDiffViewMode:Lc,setToolOutputExpansion:Nc,setDiagnosticsExpansion:Rc,setThinkingBlocksExpansion:_c,setToolInputsVisibility:Fc,setAgentModelPreference:Gc,getAgentModelPreference:qc},pu=e=>(Ut(()=>{Jt().catch(o=>{v.error("Failed to initialize settings",o)});const t=ee.onConfigOwnerChanged("ui",o=>{Dt(o),nt(!0)}),n=ee.onConfigOwnerChanged("server",o=>{Lt(o),nt(!0),Ha(),Ka(!0)}),r=ee.onStateOwnerChanged("ui",o=>{Nt(o),nt(!0)});return()=>{t(),n(),r()}}),he(bo.Provider,{value:Jc,get children(){return e.children}}));function Yc(){const e=at(bo);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}function Xc(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 Zc=Symbol("solid-inspect"),Qc=Ke();function el(e){function t(n){var r;return(r=at(Qc))!=null&&r.enabled?{Component:t,props:n,$INSPECT:Zc}:e(n)}return Object.defineProperty(t,"name",{value:e.name}),t.toString=e.toString,t}function Co(){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 Xc(e.slotClasses(a),e.utilityClass,a.classes??"")},l=ls({});return c&&Do(()=>{const d=u();ve(()=>{for(const f in d)l[f]=d[f]})}),l}function n(a){const[c,u]=_t(a,e.selfPropNames);return{allProps:a,props:c,otherProps:u}}function r(a){return Zs({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=el(a),a.toString=()=>`.${e.name}-root`,c&&Hr(a,"base"),a}function i(a){const c=s(function(l){const{allProps:d,otherProps:f,props:m}=o(l),w=e.autoCallUseClasses??!0?t(d):{};return a({allProps:d,otherProps:f,props:m,classes:w})});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=Co()({name:"MuiGlobalStyles",selfPropNames:["styles"]}),nl=tl.component(function({props:t}){return Br(()=>({"@global":t.styles||{}})),[]}),rl=Co()({name:"MuiCssBaseline",selfPropNames:["children","enableColorScheme"],propDefaults:({set:e})=>e({enableColorScheme:!1})}),ol=(e,t)=>({WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",boxSizing:"border-box",WebkitTextSizeAdjust:"100%",...t&&{colorScheme:e.palette.mode}}),sl=e=>({color:e.palette.text.primary,...e.typography.body1,backgroundColor:e.palette.background.default,"@media print":{backgroundColor:e.palette.common.white}}),il=(e,t=!1)=>({html:ol(e,t),"*, *::before, *::after":{boxSizing:"inherit"},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...sl(e),"&::backdrop":{backgroundColor:e.palette.background.default}}}),al=rl.component(function({props:t}){const n=Ir();return he(nl,{get styles(){return il(n,t.enableColorScheme)}})}),So=Ke();function cr(e){if(!(typeof document>"u")){if(e==="system"){document.documentElement.removeAttribute("data-theme");return}document.documentElement.setAttribute("data-theme",e)}}const cl={backgroundDefault:"#ffffff",backgroundPaper:"#f5f5f5",primary:"#0066ff",primaryContrast:"#ffffff",textPrimary:"#1a1a1a",textSecondary:"#666666",divider:"#e0e0e0"},ll={backgroundDefault:"#1a1a1a",backgroundPaper:"#2a2a2a",primary:"#0080ff",primaryContrast:"#1a1a1a",textPrimary:"#cfd4dc",textSecondary:"#999999",divider:"#3a3a3a"},Ce=(e,t,n)=>{if(!n)return t;const r=n.getPropertyValue(e);return r&&r.trim()||t},ul=e=>{const t=e?ll:cl,n=typeof window<"u"?getComputedStyle(document.documentElement):null;return{backgroundDefault:Ce("--surface-base",t.backgroundDefault,n),backgroundPaper:Ce("--surface-secondary",t.backgroundPaper,n),primary:Ce("--accent-primary",t.primary,n),primaryContrast:Ce("--text-inverted",t.primaryContrast,n),textPrimary:Ce("--text-primary",t.textPrimary,n),textSecondary:Ce("--text-secondary",t.textSecondary,n),divider:Ce("--border-base",t.divider,n)}};function yu(e){const t=typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)"):null,{themePreference:n,setThemePreference:r}=Yc(),[o,s]=$(!0),[i,a]=$(0),c=()=>n(),u=()=>{const w=c();return w==="dark"?!0:w==="light"?!1:(t==null?void 0:t.matches)??!1},l=()=>{const w=c(),g=u();cr(w==="system"?"system":w),s(g),typeof window<"u"?requestAnimationFrame(()=>a(b=>b+1)):a(b=>b+1)};z(()=>{l()}),Ut(()=>{if(!t)return;const w=()=>{l()};return t.addEventListener("change",w),()=>{t.removeEventListener("change",w)}});const d=w=>{r(w)},f=()=>{const w=c();d(w==="system"?"light":w==="light"?"dark":"system")},m=L(()=>{i();const w=ul(o());return kr({palette:{mode:o()?"dark":"light",primary:{main:w.primary,contrastText:w.primaryContrast},secondary:{main:w.primary},background:{default:w.backgroundDefault,paper:w.backgroundPaper},text:{primary:w.textPrimary,secondary:w.textSecondary},divider:w.divider},typography:{fontFamily:"var(--font-family-sans)"},shape:{borderRadius:8},components:{MuiIconButton:{styleOverrides:{root:{color:"inherit","&.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:"56px"}}}}})});return he(So.Provider,{value:{isDark:o,themeMode:c,setThemeMode:d,cycleThemeMode:f},get children(){return he(Qs,{get theme(){return m()},get children(){return[he(al,{}),zo(()=>e.children)]}})}})}function vo(){const e=at(So);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}const dl=/(^|\n)@@/m,fl=/(^|\n)(diff --git |--- |\+\+\+)/,hl=/^\*\*\* (Begin|End) Patch/,gl=/^\*\*\* Update File: (.+)$/,ml=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function pl(e){const t=e.trim();if(!t.startsWith("```"))return t;const n=t.split(`
|
|
16
16
|
`);return n.length<2?"":n[n.length-1].startsWith("```")?n.slice(1,-1).join(`
|
|
17
17
|
`):t}function yl(e){var s;if(!e)return"";const n=pl(e.replace(/\r\n/g,`
|
|
18
18
|
`)).split(`
|
|
@@ -23,4 +23,4 @@ ${a}
|
|
|
23
23
|
`),n=[],r=[];for(const o of t)o.startsWith("---")||o.startsWith("+++")||o.startsWith("diff --git")||ml.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
24
|
`),after:r.join(`
|
|
25
25
|
`)}}const bl="0.52.2",wn=`https://cdn.jsdelivr.net/npm/monaco-editor@${bl}/min/vs`,Q="/monaco/vs";let xt=null;function Cl(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 Sl(){if(typeof fetch>"u")return!1;try{const e=new AbortController,t=fetch(`${wn}/loader.js`,{method:"HEAD",signal:e.signal}),n=await Cl(t,1200);return e.abort(),n.ok}catch{return!1}}function vl(){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=`${Q}/loader.js`,r.async=!0,r.onload=()=>t(),r.onerror=()=>n(new Error("Failed to load Monaco AMD loader")),document.head.appendChild(r)})}function xl(){if(typeof document>"u"||document.querySelector('link[data-monaco-editor-css="true"]'))return;const t=document.createElement("link");t.rel="stylesheet",t.href=`${Q}/editor/editor.main.css`,t.dataset.monacoEditorCss="true",document.head.appendChild(t)}function El(){const e=globalThis,t=e.MonacoEnvironment??{},n="/monaco.worker.js";e.MonacoEnvironment={...t,getWorkerUrl(r,o){return n}}}function xo(){const e=globalThis.require;if(!e)throw new Error("Monaco AMD loader is not available");return e}function Ol(){const t=xo().config;if(!t)throw new Error("require.config is not available");return t}function bn(e){const t=xo();return new Promise((n,r)=>{t(e,(...o)=>n(o),o=>r(o))})}function Al(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 lr=new Set,sn=new Map;async function Eo(e){const t=Al(e);if(!t||lr.has(t))return;const n=sn.get(t);if(n)return n;const r=(async()=>{let o=!1;try{await bn([t]),o=!0}catch{}finally{o&&lr.add(t),sn.delete(t)}})();return sn.set(t,r),r}async function Oo(){return xt||(xt=(async()=>{await vl(),El(),xl();const e=await Sl(),t=Ol(),n={vs:Q};e&&(n["vs/basic-languages"]=`${wn}/basic-languages`,n["vs/language"]=`${wn}/language`,n["vs/basic-languages/python"]=`${Q}/basic-languages/python`,n["vs/basic-languages/markdown"]=`${Q}/basic-languages/markdown`,n["vs/basic-languages/cpp"]=`${Q}/basic-languages/cpp`,n["vs/basic-languages/kotlin"]=`${Q}/basic-languages/kotlin`,n["vs/language/typescript"]=`${Q}/language/typescript`,n["vs/language/html"]=`${Q}/language/html`,n["vs/language/json"]=`${Q}/language/json`,n["vs/language/css"]=`${Q}/language/css`),t({paths:n,ignoreDuplicateModules:["vs/editor/editor.main"]});const[r]=await bn(["vs/editor/editor.main"]);return await bn(["vs/basic-languages/monaco.contribution"]).catch(()=>[]),globalThis.monaco??r})(),xt)}const Tl=5,ue=new Map;function kl(e,t){ue.delete(e),ue.set(e,t)}function $l(){for(;ue.size>Tl;){const e=ue.keys().next().value;if(!e)return;const t=ue.get(e);ue.delete(e);try{t==null||t.model.dispose()}catch{}}}function Cn(e){const t=ue.get(e.cacheKey);if(t)return kl(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 ue.set(e.cacheKey,o),$l(),r}let Et=null;function Pl(e){var o;if(Et)return Et;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 Et={fileNameToId:t,extToId:n},Et}function Il(e){return e===".gitignore"||e===".gitattributes"||e===".gitmodules"||e==="Makefile"||e.startsWith("Makefile.")?"shell":null}function Ao(e,t){const n=String(t||"").trim(),r=n.split("/").pop()||n,o=Il(r);if(o)return o;const s=Pl(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 Ml=Sn("<div class=monaco-viewer>");function Dl(e){const{isDark:t}=vo();let n,r=null,o=null;const[s,i]=$(!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 Ut(()=>{let l=!1;(async()=>(o=await Oo(),!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)))))(),fe(()=>{l=!0,i(!1),a()})}),z(()=>{!s()||!o||!r||o.editor.setTheme(t()?"vs-dark":"vs")}),z(()=>{!s()||!r||r.updateOptions({wordWrap:e.wordWrap==="on"?"on":"off"})}),z(()=>{!s()||!r||r.updateOptions({lineNumbersMinChars:u(e.content),folding:!e.compactGutter,lineDecorationsWidth:e.compactGutter?8:10})}),z(()=>{if(!s()||!o||!r)return;const l=Ao(o,e.path),d=`${e.scopeKey}:file:${e.path}`,f=Cn({monaco:o,cacheKey:d,value:e.content});r.setModel(f),Eo(l).then(()=>{try{o.editor.setModelLanguage(f,l)}catch{}})}),(()=>{var l=Ml(),d=n;return typeof d=="function"?vn(d,l):n=l,l})()}const bu=Object.freeze(Object.defineProperty({__proto__:null,MonacoFileViewer:Dl},Symbol.toStringTag,{value:"Module"}));var Ll=Sn("<div class=monaco-viewer><div class=git-change-context-overlay>"),Nl=Sn("<div class=git-change-context-widget-host><button type=button class=git-change-context-widget>+");function Rt(e){return e?e.split(`
|
|
26
|
-
`).length:1}function Ft(e){return String(Math.max(1,e)).length}function Rl(e){const t=Rt(e.before),n=Rt(e.after),r=Ft(t),o=Ft(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 Fl(e){const t=Rt(e.before),n=Rt(e.after),r=Ft(t),o=Ft(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 _l(e){const{isDark:t}=vo();let n,r=null,o=null,s=null;const[i,a]=$(!1),[c,u]=$(null),[l,d]=$(null),[f,m]=$(!1),[w,g]=$(null),b=L(()=>e.patch!==void 0&&e.patch!==null?wl(e.patch):{before:e.before??"",after:e.after??""}),A=()=>{try{r==null||r.setModel(null)}catch{}try{r==null||r.dispose()}catch{}r=null},M=()=>{n&&(n.style.removeProperty("--split-original-line-number-width"),n.style.removeProperty("--split-original-delete-sign-left"),n.style.removeProperty("--split-original-gutter-width"))},N=p=>{if(n){if(s!==null&&typeof window<"u"&&(window.cancelAnimationFrame(s),s=null),p.viewMode!=="split"||typeof window>"u"){M();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,x=O>0?O:Math.max(12,p.originalLineNumbersMinChars*6);n.style.setProperty("--split-original-line-number-width",`${x}px`),n.style.setProperty("--split-original-delete-sign-left",`${x}px`),n.style.setProperty("--split-original-gutter-width",`${x+p.lineDecorationsWidth}px`)})}},X=()=>{var p;return((p=r==null?void 0:r.getModifiedEditor)==null?void 0:p.call(r))??null},ft=()=>{const p=l();if(p)return p;if(f()&&c())return{startLine:c(),endLine:c()};const C=c();return C?{startLine:C,endLine:C}:null},W=()=>{var x,E,k,S;const p=X(),C=n;if(!p||!C)return;const O=ft();if(!O){g(null);return}try{const I=(x=p.getDomNode)==null?void 0:x.call(p);if(!I){g(null);return}const _=I.querySelector(".margin"),Z=I.querySelector(".monaco-scrollable-element.editor-scrollable"),pe=((E=p.getTopForLineNumber)==null?void 0:E.call(p,O.startLine))??0,Te=((k=p.getScrollTop)==null?void 0:k.call(p))??0,ht=Number(((S=p.getOption)==null?void 0:S.call(p,o.editor.EditorOption.lineHeight))??18),Ge=I.getBoundingClientRect(),ye=C.getBoundingClientRect(),gt=Ge.left-ye.left+((_==null?void 0:_.offsetWidth)??(Z==null?void 0:Z.offsetLeft)??0),To=Ge.top-ye.top+(pe-Te)+ht/2;g({top:To,left:gt})}catch{g(null)}};return Ut(()=>{let p=!1;(async()=>(o=await Oo(),!p&&(!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),W()))))(),fe(()=>{p=!0,s!==null&&typeof window<"u"&&(window.cancelAnimationFrame(s),s=null),M(),a(!1),A()})}),z(()=>{!i()||!o||!r||o.editor.setTheme(t()?"vs-dark":"vs")}),z(()=>{n&&(n.dataset.viewMode=e.viewMode==="split"?"split":"unified")}),z(()=>{var O;if(!i()||!o||!r)return;const p=(O=r.getModifiedEditor)==null?void 0:O.call(r);if(!(p!=null&&p.onDidChangeCursorSelection))return;const C=p.onDidChangeCursorSelection(x=>{var k;const E=x==null?void 0:x.selection;if(!E||(k=E.isEmpty)!=null&&k.call(E)){d(null),W();return}d({startLine:Math.min(E.startLineNumber,E.endLineNumber),endLine:Math.max(E.startLineNumber,E.endLineNumber)}),W()});fe(()=>{var x;try{(x=C==null?void 0:C.dispose)==null||x.call(C)}catch{}})}),z(()=>{var E;if(!i()||!o||!r)return;const p=X();if(!(p!=null&&p.onMouseMove)||!(p!=null&&p.onMouseLeave)||!(p!=null&&p.onMouseDown))return;const C=p.onMouseMove(k=>{var I,_;const S=(_=(I=k==null?void 0:k.target)==null?void 0:I.position)==null?void 0:_.lineNumber;u(typeof S=="number"?S:null),W()}),O=p.onMouseLeave(()=>{f()||u(null),W()}),x=(E=p.onDidScrollChange)==null?void 0:E.call(p,()=>{W()});fe(()=>{var k,S,I;try{(k=C==null?void 0:C.dispose)==null||k.call(C),(S=O==null?void 0:O.dispose)==null||S.call(O),(I=x==null?void 0:x.dispose)==null||I.call(x)}catch{}})}),z(()=>{if(!i()||!o||!r)return;ft()||g(null),W()}),z(()=>{var pe,Te,ht,Ge,ye,gt;if(!i()||!o||!r)return;const p=e.viewMode==="unified"?"unified":"split",C=e.contextMode==="collapsed"?"collapsed":"expanded",O=e.wordWrap==="on"?"on":"off",{before:x,after:E}=b(),k=p==="unified"?Rl({before:x,after:E}):Fl({before:x,after:E}),{diffEditorLineNumbersMinChars:S,originalLineNumbersMinChars:I,modifiedLineNumbersMinChars:_,lineDecorationsWidth:Z}=k;r.updateOptions({renderSideBySide:p==="split",renderSideBySideInlineBreakpoint:0,renderIndicators:!0,lineNumbersMinChars:S,lineDecorationsWidth:Z,hideUnchangedRegions:C==="collapsed"?{enabled:!0}:{enabled:!1},wordWrap:O});try{(ht=(Te=(pe=r.getOriginalEditor)==null?void 0:pe.call(r))==null?void 0:Te.updateOptions)==null||ht.call(Te,{wordWrap:O,lineNumbersMinChars:I,lineDecorationsWidth:Z})}catch{}try{(gt=(ye=(Ge=r.getModifiedEditor)==null?void 0:Ge.call(r))==null?void 0:ye.updateOptions)==null||gt.call(ye,{wordWrap:O,lineNumbersMinChars:_,lineDecorationsWidth:Z})}catch{}N({viewMode:p,originalLineNumbersMinChars:I,lineDecorationsWidth:Z})}),z(()=>{if(!i()||!o||!r)return;const p=Ao(o,e.path),{before:C,after:O}=b(),x=`${e.scopeKey}:diff:${e.path}:before`,E=`${e.scopeKey}:diff:${e.path}:after`,k=Cn({monaco:o,cacheKey:x,value:C}),S=Cn({monaco:o,cacheKey:E,value:O});r.setModel({original:k,modified:S}),Eo(p).then(()=>{try{o.editor.setModelLanguage(k,p),o.editor.setModelLanguage(S,p)}catch{}})}),(()=>{var p=Ll(),C=p.firstChild,O=n;return typeof O=="function"?vn(O,p):n=p,kt(C,he(Lo,{get when(){return w()},children:x=>(()=>{var E=Nl(),k=E.firstChild;return E.addEventListener("mouseleave",()=>{m(!1),W()}),E.addEventListener("mouseenter",()=>{m(!0),W()}),k.$$click=S=>{var _;S.preventDefault(),S.stopPropagation();const I=ft();I&&((_=e.onRequestInsertContext)==null||_.call(e,I))},k.$$mousedown=S=>{S.preventDefault(),S.stopPropagation()},de(S=>{var I=`${x().top}px`,_=`${x().left}px`,Z=e.insertContextLabel??"Add git change context to prompt",pe=e.insertContextLabel??"Add git change context to prompt";return I!==S.e&&Dn(E,"top",S.e=I),_!==S.t&&Dn(E,"left",S.t=_),Z!==S.a&&st(k,"aria-label",S.a=Z),pe!==S.o&&st(k,"title",S.o=pe),S},{e:void 0,t:void 0,a:void 0,o:void 0}),E})()})),p})()}gr(["mousedown","click"]);const Cu=Object.freeze(Object.defineProperty({__proto__:null,MonacoDiffViewer:_l},Symbol.toStringTag,{value:"Module"}));export{
|
|
26
|
+
`).length:1}function Ft(e){return String(Math.max(1,e)).length}function Rl(e){const t=Rt(e.before),n=Rt(e.after),r=Ft(t),o=Ft(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 Fl(e){const t=Rt(e.before),n=Rt(e.after),r=Ft(t),o=Ft(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 _l(e){const{isDark:t}=vo();let n,r=null,o=null,s=null;const[i,a]=$(!1),[c,u]=$(null),[l,d]=$(null),[f,m]=$(!1),[w,g]=$(null),b=L(()=>e.patch!==void 0&&e.patch!==null?wl(e.patch):{before:e.before??"",after:e.after??""}),A=()=>{try{r==null||r.setModel(null)}catch{}try{r==null||r.dispose()}catch{}r=null},M=()=>{n&&(n.style.removeProperty("--split-original-line-number-width"),n.style.removeProperty("--split-original-delete-sign-left"),n.style.removeProperty("--split-original-gutter-width"))},N=p=>{if(n){if(s!==null&&typeof window<"u"&&(window.cancelAnimationFrame(s),s=null),p.viewMode!=="split"||typeof window>"u"){M();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,x=O>0?O:Math.max(12,p.originalLineNumbersMinChars*6);n.style.setProperty("--split-original-line-number-width",`${x}px`),n.style.setProperty("--split-original-delete-sign-left",`${x}px`),n.style.setProperty("--split-original-gutter-width",`${x+p.lineDecorationsWidth}px`)})}},X=()=>{var p;return((p=r==null?void 0:r.getModifiedEditor)==null?void 0:p.call(r))??null},ft=()=>{const p=l();if(p)return p;if(f()&&c())return{startLine:c(),endLine:c()};const C=c();return C?{startLine:C,endLine:C}:null},W=()=>{var x,E,k,S;const p=X(),C=n;if(!p||!C)return;const O=ft();if(!O){g(null);return}try{const I=(x=p.getDomNode)==null?void 0:x.call(p);if(!I){g(null);return}const _=I.querySelector(".margin"),Z=I.querySelector(".monaco-scrollable-element.editor-scrollable"),pe=((E=p.getTopForLineNumber)==null?void 0:E.call(p,O.startLine))??0,Te=((k=p.getScrollTop)==null?void 0:k.call(p))??0,ht=Number(((S=p.getOption)==null?void 0:S.call(p,o.editor.EditorOption.lineHeight))??18),Ge=I.getBoundingClientRect(),ye=C.getBoundingClientRect(),gt=Ge.left-ye.left+((_==null?void 0:_.offsetWidth)??(Z==null?void 0:Z.offsetLeft)??0),To=Ge.top-ye.top+(pe-Te)+ht/2;g({top:To,left:gt})}catch{g(null)}};return Ut(()=>{let p=!1;(async()=>(o=await Oo(),!p&&(!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),W()))))(),fe(()=>{p=!0,s!==null&&typeof window<"u"&&(window.cancelAnimationFrame(s),s=null),M(),a(!1),A()})}),z(()=>{!i()||!o||!r||o.editor.setTheme(t()?"vs-dark":"vs")}),z(()=>{n&&(n.dataset.viewMode=e.viewMode==="split"?"split":"unified")}),z(()=>{var O;if(!i()||!o||!r)return;const p=(O=r.getModifiedEditor)==null?void 0:O.call(r);if(!(p!=null&&p.onDidChangeCursorSelection))return;const C=p.onDidChangeCursorSelection(x=>{var k;const E=x==null?void 0:x.selection;if(!E||(k=E.isEmpty)!=null&&k.call(E)){d(null),W();return}d({startLine:Math.min(E.startLineNumber,E.endLineNumber),endLine:Math.max(E.startLineNumber,E.endLineNumber)}),W()});fe(()=>{var x;try{(x=C==null?void 0:C.dispose)==null||x.call(C)}catch{}})}),z(()=>{var E;if(!i()||!o||!r)return;const p=X();if(!(p!=null&&p.onMouseMove)||!(p!=null&&p.onMouseLeave)||!(p!=null&&p.onMouseDown))return;const C=p.onMouseMove(k=>{var I,_;const S=(_=(I=k==null?void 0:k.target)==null?void 0:I.position)==null?void 0:_.lineNumber;u(typeof S=="number"?S:null),W()}),O=p.onMouseLeave(()=>{f()||u(null),W()}),x=(E=p.onDidScrollChange)==null?void 0:E.call(p,()=>{W()});fe(()=>{var k,S,I;try{(k=C==null?void 0:C.dispose)==null||k.call(C),(S=O==null?void 0:O.dispose)==null||S.call(O),(I=x==null?void 0:x.dispose)==null||I.call(x)}catch{}})}),z(()=>{if(!i()||!o||!r)return;ft()||g(null),W()}),z(()=>{var pe,Te,ht,Ge,ye,gt;if(!i()||!o||!r)return;const p=e.viewMode==="unified"?"unified":"split",C=e.contextMode==="collapsed"?"collapsed":"expanded",O=e.wordWrap==="on"?"on":"off",{before:x,after:E}=b(),k=p==="unified"?Rl({before:x,after:E}):Fl({before:x,after:E}),{diffEditorLineNumbersMinChars:S,originalLineNumbersMinChars:I,modifiedLineNumbersMinChars:_,lineDecorationsWidth:Z}=k;r.updateOptions({renderSideBySide:p==="split",renderSideBySideInlineBreakpoint:0,renderIndicators:!0,lineNumbersMinChars:S,lineDecorationsWidth:Z,hideUnchangedRegions:C==="collapsed"?{enabled:!0}:{enabled:!1},wordWrap:O});try{(ht=(Te=(pe=r.getOriginalEditor)==null?void 0:pe.call(r))==null?void 0:Te.updateOptions)==null||ht.call(Te,{wordWrap:O,lineNumbersMinChars:I,lineDecorationsWidth:Z})}catch{}try{(gt=(ye=(Ge=r.getModifiedEditor)==null?void 0:Ge.call(r))==null?void 0:ye.updateOptions)==null||gt.call(ye,{wordWrap:O,lineNumbersMinChars:_,lineDecorationsWidth:Z})}catch{}N({viewMode:p,originalLineNumbersMinChars:I,lineDecorationsWidth:Z})}),z(()=>{if(!i()||!o||!r)return;const p=Ao(o,e.path),{before:C,after:O}=b(),x=`${e.scopeKey}:diff:${e.path}:before`,E=`${e.scopeKey}:diff:${e.path}:after`,k=Cn({monaco:o,cacheKey:x,value:C}),S=Cn({monaco:o,cacheKey:E,value:O});r.setModel({original:k,modified:S}),Eo(p).then(()=>{try{o.editor.setModelLanguage(k,p),o.editor.setModelLanguage(S,p)}catch{}})}),(()=>{var p=Ll(),C=p.firstChild,O=n;return typeof O=="function"?vn(O,p):n=p,kt(C,he(Lo,{get when(){return w()},children:x=>(()=>{var E=Nl(),k=E.firstChild;return E.addEventListener("mouseleave",()=>{m(!1),W()}),E.addEventListener("mouseenter",()=>{m(!0),W()}),k.$$click=S=>{var _;S.preventDefault(),S.stopPropagation();const I=ft();I&&((_=e.onRequestInsertContext)==null||_.call(e,I))},k.$$mousedown=S=>{S.preventDefault(),S.stopPropagation()},de(S=>{var I=`${x().top}px`,_=`${x().left}px`,Z=e.insertContextLabel??"Add git change context to prompt",pe=e.insertContextLabel??"Add git change context to prompt";return I!==S.e&&Dn(E,"top",S.e=I),_!==S.t&&Dn(E,"left",S.t=_),Z!==S.a&&st(k,"aria-label",S.a=Z),pe!==S.o&&st(k,"title",S.o=pe),S},{e:void 0,t:void 0,a:void 0,o:void 0}),E})()})),p})()}gr(["mousedown","click"]);const Cu=Object.freeze(Object.defineProperty({__proto__:null,MonacoDiffViewer:_l},Symbol.toStringTag,{value:"Module"}));export{Zl as $,qc as A,ie as B,ou as C,zl as D,Hl as E,Gc as F,B as G,Ka as H,sr as I,me as J,$c as K,Mc as L,Ma as M,qt as N,Yc as O,Vl as P,Yo as Q,ru as R,ql as S,Co as T,Fi as U,Yl as V,tu as W,Bi as X,Kr as Y,Jl as Z,Vi as _,qo as a,fi as a0,Ql as a1,Xl as a2,nu as a3,ls as a4,eu as a5,gs as a6,hs as a7,vo as a8,wu as a9,so as aa,oo as ab,Kt as ac,su as ad,Ic as ae,Dc as af,iu as ag,lu as ah,fc as ai,mu as aj,hu as ak,gu as al,ee as am,jl as an,fu as ao,yu as ap,pu as aq,du as ar,yl as as,bu as at,Cu as au,mr as b,Kl as c,st as d,Ir as e,gr as f,Dn as g,Jo as h,kt as i,re as j,ae as k,je as l,zo as m,au as n,Sa as o,Gl as p,va as q,uu as r,Xo as s,Sn as t,vn as u,$e as v,Oa as w,Ht as x,cu as y,Ot as z};
|