wherever-dev 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/session-pool.d.ts +25 -3
  2. package/dist/session-pool.d.ts.map +1 -1
  3. package/dist/session-pool.js +49 -5
  4. package/dist/session-pool.js.map +1 -1
  5. package/package.json +3 -3
  6. package/public/_app/immutable/chunks/{BKllHISW.js → BjCiLgSk.js} +2 -2
  7. package/public/_app/immutable/chunks/{BKllHISW.js.map → BjCiLgSk.js.map} +1 -1
  8. package/public/_app/immutable/chunks/{BmVuM2Y1.js → DVBwLY30.js} +2 -2
  9. package/public/_app/immutable/chunks/{BmVuM2Y1.js.map → DVBwLY30.js.map} +1 -1
  10. package/public/_app/immutable/chunks/{C2DN7QTd.js → hZZHHBcZ.js} +2 -2
  11. package/public/_app/immutable/chunks/{C2DN7QTd.js.map → hZZHHBcZ.js.map} +1 -1
  12. package/public/_app/immutable/entry/{app.C7mkeSFC.js → app.CbtUyz23.js} +3 -3
  13. package/public/_app/immutable/entry/{app.C7mkeSFC.js.map → app.CbtUyz23.js.map} +1 -1
  14. package/public/_app/immutable/entry/start.DUrKnLFM.js +2 -0
  15. package/public/_app/immutable/entry/start.DUrKnLFM.js.map +1 -0
  16. package/public/_app/immutable/nodes/{0.DKCWYVkQ.js → 0.9pbC6lHm.js} +2 -2
  17. package/public/_app/immutable/nodes/{0.DKCWYVkQ.js.map → 0.9pbC6lHm.js.map} +1 -1
  18. package/public/_app/immutable/nodes/{1.DvX6nGK9.js → 1.s4Y7xjL3.js} +2 -2
  19. package/public/_app/immutable/nodes/{1.DvX6nGK9.js.map → 1.s4Y7xjL3.js.map} +1 -1
  20. package/public/_app/immutable/nodes/{2.Z4jvbTfo.js → 2.jv_uwe0e.js} +2 -2
  21. package/public/_app/immutable/nodes/{2.Z4jvbTfo.js.map → 2.jv_uwe0e.js.map} +1 -1
  22. package/public/_app/version.json +1 -1
  23. package/public/index.html +10 -10
  24. package/public/service-worker.js +1 -1
  25. package/public/_app/immutable/entry/start.QqipYq-r.js +0 -2
  26. package/public/_app/immutable/entry/start.QqipYq-r.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{b as Ur,a as h,c as Jn,g as m,d as Wn,e as G,f as Nn,s as ie,t as cn}from"../chunks/vMsF8lo6.js";import{ar as fn,b2 as Ir,al as Kn,be as q,ap as zs,M as to,aS as no,aq as Qr,d as ha,am as Jr,at as ro,n as so,a0 as ao,u as oo,t as io,a1 as lo,V as co,W as uo,H as fo,b3 as Us,C as Hs,aE as Nr,a2 as Mn,ac as po,az as ho,aZ as bo,ay as ba,bd as va,bf as vo,bg as vs,aU as gs,aQ as Bs,aP as Pn,aM as Fn,af as Ht,b6 as f,ai as t,a5 as go,bh as le,$ as mo,bl as jn,ah as nr,a8 as Yt,aK as yr,a_ as p,X as u,aV as d,aI as ot,b9 as Y,aO as yn,bi as Ct,bj as xo,aT as _o}from"../chunks/CEg8tgYI.js";import{i as E,s as rr,a as Ve,p as br}from"../chunks/MtE7VtNZ.js";import{a as yo,b as qe,r as rt,c as es,e as un,i as An,d as wo}from"../chunks/BmVuM2Y1.js";import{_ as ko,b as En}from"../chunks/ylfInSZr.js";import{v as ga}from"../chunks/BKllHISW.js";import{p as So}from"../chunks/C2DN7QTd.js";function To(n,e,r=!1,s=!1,a=!1,o=!1){var i=n,c="";if(r){var x=n;fn&&(i=Ir(Kn(x)))}q(()=>{var g=to;if(c===(c=e()??"")){fn&&zs();return}if(r&&!fn){g.nodes=null,x.innerHTML=c,c!==""&&Ur(Kn(x),x.lastChild);return}if(g.nodes!==null&&(no(g.nodes.start,g.nodes.end),g.nodes=null),c!==""){if(fn){Qr.data;for(var I=zs(),D=I;I!==null&&(I.nodeType!==ha||I.data!=="");)D=I,I=Jr(I);if(I===null)throw ro(),so;Ur(Qr,D),i=Ir(I);return}var $=s?oo:a?io:void 0,R=ao(s?"svg":a?"math":"template",$);R.innerHTML=c;var C=s||a?R:R.content;if(Ur(Kn(C),C.lastChild),s||a)for(;Kn(C);)i.before(Kn(C));else i.before(C)}})}function Ao(n,e){let r=null,s=fn;var a;if(fn){r=Qr;for(var o=Kn(document.head);o!==null&&(o.nodeType!==ha||o.data!==n);)o=Jr(o);if(o===null)Us(!1);else{var i=Jr(o);o.remove(),Ir(i)}}fn||(a=document.head.appendChild(lo()));try{co(()=>{var c=uo(()=>e(a));c.f|=fo})}finally{s&&(Us(!0),Ir(r))}}function ma(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var a=n.length;for(e=0;e<a;e++)n[e]&&(r=ma(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Eo(){for(var n,e,r=0,s="",a=arguments.length;r<a;r++)(n=arguments[r])&&(e=ma(n))&&(s&&(s+=" "),s+=e);return s}function Ro(n){return typeof n=="object"?Eo(n):n??""}function Co(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function jt(n,e,r,s,a,o){var i=n[Hs];if(fn||i!==r||i===void 0){var c=Co(r);(!fn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[Hs]=r}return o}function ms(n,e,r=!1){if(n.multiple){if(e==null)return;if(!ho(e))return bo();for(var s of n.options)s.selected=e.includes(vr(s));return}for(s of n.options){var a=vr(s);if(ba(a,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function xa(n){var e=new MutationObserver(()=>{ms(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),va(()=>{e.disconnect()})}function $r(n,e,r=e){var s=new WeakSet,a=!0;Nr(n,"change",o=>{var i=o?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(i),vr);else{var x=n.querySelector(i)??n.querySelector("option:not([disabled])");c=x&&vr(x)}r(c),n.__value=c,Mn!==null&&s.add(Mn)}),po(()=>{var o=e();if(n===document.activeElement){var i=Mn;if(s.has(i))return}if(ms(n,o,a),a&&o===void 0){var c=n.querySelector(":checked");c!==null&&(o=vr(c),r(o))}n.__value=o,a=!1}),xa(n)}function vr(n){return"__value"in n?n.__value:n.value}function Rn(n,e,r=e){var s=new WeakSet;Nr(n,"input",async a=>{var o=a?n.defaultValue:n.value;if(o=Br(n)?Gr(o):o,r(o),Mn!==null&&s.add(Mn),await vo(),o!==(o=e())){var i=n.selectionStart,c=n.selectionEnd,x=n.value.length;if(n.value=o??"",c!==null){var g=n.value.length;i===c&&c===x&&g>x?(n.selectionStart=g,n.selectionEnd=g):(n.selectionStart=i,n.selectionEnd=Math.min(c,g))}}}),(fn&&n.defaultValue!==n.value||vs(e)==null&&n.value)&&(r(Br(n)?Gr(n.value):n.value),Mn!==null&&s.add(Mn)),gs(()=>{var a=e();if(n===document.activeElement){var o=Mn;if(s.has(o))return}Br(n)&&a===Gr(n.value)||n.type==="date"&&!a&&!n.value||a!==n.value&&(n.value=a??"")})}const Hr=new Set;function Dn(n,e,r,s,a=s){var o=r.getAttribute("type")==="checkbox",i=n;let c=!1;if(e!==null)for(var x of e)i=i[x]??=[];i.push(r),Nr(r,"change",()=>{var g=r.__value;o&&(g=Gs(i,g,r.checked)),a(g)},()=>a(o?[]:null)),gs(()=>{var g=s();if(fn&&r.defaultChecked!==r.checked){c=!0;return}o?(g=g||[],r.checked=g.includes(r.__value)):r.checked=ba(r.__value,g)}),va(()=>{var g=i.indexOf(r);g!==-1&&i.splice(g,1)}),Hr.has(i)||(Hr.add(i),Bs(()=>{i.sort((g,I)=>g.compareDocumentPosition(I)===4?-1:1),Hr.delete(i)})),Bs(()=>{if(c){var g;if(o)g=Gs(i,g,r.checked);else{var I=i.find(D=>D.checked);g=I?.__value}a(g)}})}function bn(n,e,r=e){Nr(n,"change",s=>{var a=s?n.defaultChecked:n.checked;r(a)}),(fn&&n.defaultChecked!==n.checked||vs(e)==null)&&r(n.checked),gs(()=>{var s=e();n.checked=!!s})}function Gs(n,e,r){for(var s=new Set,a=0;a<n.length;a+=1)n[a].checked&&s.add(n[a].__value);return r||s.delete(e),Array.from(s)}function Br(n){var e=n.type;return e==="number"||e==="range"}function Gr(n){return n===""?null:+n}const Io=!1,$o=!0,pu=Object.freeze(Object.defineProperty({__proto__:null,prerender:$o,ssr:Io},Symbol.toStringTag,{value:"Module"})),Wr="Wherever",Lo="Create & maintain apps from wherever with a beautiful remote workspace.",jr="https://localhost",Mo="#000000",Oo="black-translucent";function Qn(n,e){return yo(n)}var Do=m('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function No(n,e){Pn(e,!0);const r=jr.endsWith("/")?jr.slice(0,-1):jr,s=r+"/preview.png";let a=le(()=>e.home||!1),o=le(()=>({type:e.type||"website",title:e.title||Wr,description:e.description||Lo,image:e.image||s,url:`${r}${So.url.pathname}`}));Ao("13n5pl5",i=>{var c=Do(),x=Ht(c),g=f(x,2),I=f(g,2);{var D=ue=>{var ct=Jn(),wt=Ht(ct);E(wt,Ee=>{}),h(ue,ct)};E(I,ue=>{t(a)&&ue(D)})}var $=f(I,2),R=f($,2),C=f(R,2),ae=f(C,2),Le=f(ae,2),Ce=f(Le,4),ce=f(Ce,2),Fe=f(ce,2),Ie=f(Fe,2),De=f(Ie,2),pe=f(De,2),$e=f(pe,2),_e=f($e,2),Ye=f(_e,2),We=f(Ye,4),Me=f(We,4),ze=f(Me,2),tt=f(ze,2);q((ue,ct,wt,Ee)=>{qe(x,"content",t(o).title),qe(g,"content",t(o).description),qe($,"content",t(o).type),qe(R,"content",t(o).url),qe(C,"content",t(o).title),qe(ae,"content",t(o).description),qe(Le,"content",t(o).image),qe(Ce,"content",t(o).url),qe(ce,"content",t(o).title),qe(Fe,"content",t(o).description),qe(Ie,"content",t(o).image),qe(De,"href",ue),qe(pe,"href",ct),qe($e,"href",wt),qe(_e,"href",Ee),qe(Ye,"content",Mo),qe(We,"content",Wr),qe(Me,"content",Oo),qe(ze,"content",Wr),qe(tt,"content",ga)},[()=>Qn("/pwa/favicon.png"),()=>Qn("/pwa/favicon.ico"),()=>Qn("/pwa/apple-touch-icon.png"),()=>Qn("/pwa/manifest.webmanifest")]),go(()=>{mo.title=t(o).title??""}),h(i,c)}),Fn()}function Rr(){}function Po(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Fo(n,...e){if(n==null)return Rr;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function gn(n){let e;return Fo(n,r=>e=r)(),e}var Yn=[];function zo(n,e=Rr){let r;const s=new Set;function a(c){if(Po(n,c)&&(n=c,r)){const x=!Yn.length;for(const g of s)g[1](),Yn.push(g,n);if(x){for(let g=0;g<Yn.length;g+=2)Yn[g][0](Yn[g+1]);Yn.length=0}}}function o(c){a(c(n))}function i(c,x=Rr){const g=[c,x];return s.add(g),s.size===1&&(r=e(a)||Rr),c(n),()=>{s.delete(g),s.size===0&&(r(),r=null)}}return{set:a,update:o,subscribe:i}}const qr={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,conflict:null,isInterrupted:!1,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};class Un{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;constructor(e){this.config={secure:!0,...e},this.stateStore=zo({...qr,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(R=>r?{...R,connecting:!0,error:null}:{...qr,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",a=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,o=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",i=`${s}://${a}:${this.config.port}/ws${o}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(R=>({...R,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const R=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=R?new c(i,R):new c(i)}catch(R){this.stateStore.update(C=>({...C,connecting:!1,error:`Failed to connect: ${R}`})),this.scheduleReconnect();return}const x=this.ws,g=()=>{if(this.ws===x)if(this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(R=>({...R,connected:!0,connecting:!1,error:null})),this.resumeSessionFile){const R=this.resumeSessionFile,C=this.resumeCwd,ae=this.resumeModel;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.send({type:"session_load",sessionFile:R,cwd:C,model:ae}),this.armLoadWatchdog()}else this.stateStore.update(R=>R.resyncing?{...R,resyncing:!1}:R)},I=R=>{if(this.ws===x){this.lastInboundAt=Date.now();try{const C=typeof R.data=="string"?R.data:R.data.toString(),ae=JSON.parse(C);this.handleMessage(ae)}catch(C){console.error("Failed to parse WebSocket message:",C)}}},D=()=>{this.ws===x&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(R=>({...R,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1})),this.scheduleReconnect())},$=R=>{this.ws===x&&this.stateStore.update(C=>({...C,error:C.error||"Connection error occurred"}))};typeof x.addEventListener=="function"?(x.addEventListener("open",g),x.addEventListener("message",I),x.addEventListener("close",D),x.addEventListener("error",$)):typeof x.on=="function"&&(x.on("open",g),x.on("message",R=>I({data:R})),x.on("close",D),x.on("error",$))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.ws){try{typeof this.ws.removeAllListeners=="function"&&this.ws.removeAllListeners(),this.ws.close()}catch{}this.ws=null}e&&this.stateStore.set({...qr,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}suspend(){const e=gn(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=gn(this.stateStore);e.connected||e.connecting||(this.resumeSessionFile&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,Un.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,a=gn(this.stateStore).isStreaming,o=a?Un.TURN_STALL_MS:Un.STALE_SOCKET_MS;if(s<o)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${o}ms, ${a?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const i=this.ws;this.ws=null;try{typeof i.terminate=="function"?i.terminate():typeof i.close=="function"&&i.close()}catch{}this.stateStore.update(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:a?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,Un.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=gn(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},Un.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),this.stateStore.update(e=>({...e,connecting:!0,error:"Reconnecting..."})),this.connect()},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let a=[...s.messages].reverse().find(o=>o.role==="thinking"&&o.isStreaming);if(!a){const o={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,o]}}return{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content+e.delta,isStreaming:!0}:o)}});break;case"message_update":this.stateStore.update(s=>{let a=[...s.messages].reverse().find(o=>o.role==="assistant"&&o.isStreaming);if(!a){const o={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,o]}}return{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content+e.delta,isStreaming:!0}:o)}});break;case"message_end":this.stateStore.update(s=>{let a=s.messages;const o=[...a].reverse().find(c=>c.role==="thinking"&&c.isStreaming);o&&(a=a.map(c=>c.id===o.id?{...c,isStreaming:!1}:c));const i=[...a].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(i)a=a.map(c=>c.id===i.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){const c=[...a].reverse().find(g=>g.role==="user");e.role==="user"&&c&&c.content===e.content||(a=[...a,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:a}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{this.stateStore.update(s=>({...s,isStreaming:!1,messages:s.messages.map(a=>a.isStreaming?{...a,isStreaming:!1}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,a])=>a!==void 0&&a!=="").map(([s,a])=>`${s}=${JSON.stringify(a)}`).join(" "):"";this.stateStore.update(s=>{const a=s.messages.map(i=>i.isStreaming&&(i.role==="assistant"||i.role==="thinking")?{...i,isStreaming:!1}:i),o={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:Date.now(),isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:""};return{...s,messages:[...a,o]}});break;case"tool_update":{this.stateStore.update(s=>{const a=[...s.messages].reverse().find(o=>o.role==="tool"&&o.toolName===e.toolName&&o.isStreaming);return a?{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content.includes(`
1
+ import{b as Ur,a as h,c as Jn,g as m,d as Wn,e as G,f as Nn,s as ie,t as cn}from"../chunks/vMsF8lo6.js";import{ar as fn,b2 as Ir,al as Kn,be as q,ap as zs,M as to,aS as no,aq as Qr,d as ha,am as Jr,at as ro,n as so,a0 as ao,u as oo,t as io,a1 as lo,V as co,W as uo,H as fo,b3 as Us,C as Hs,aE as Nr,a2 as Mn,ac as po,az as ho,aZ as bo,ay as ba,bd as va,bf as vo,bg as vs,aU as gs,aQ as Bs,aP as Pn,aM as Fn,af as Ht,b6 as f,ai as t,a5 as go,bh as le,$ as mo,bl as jn,ah as nr,a8 as Yt,aK as yr,a_ as p,X as u,aV as d,aI as ot,b9 as Y,aO as yn,bi as Ct,bj as xo,aT as _o}from"../chunks/CEg8tgYI.js";import{i as E,s as rr,a as Ve,p as br}from"../chunks/MtE7VtNZ.js";import{a as yo,b as qe,r as rt,c as es,e as un,i as An,d as wo}from"../chunks/DVBwLY30.js";import{_ as ko,b as En}from"../chunks/ylfInSZr.js";import{v as ga}from"../chunks/BjCiLgSk.js";import{p as So}from"../chunks/hZZHHBcZ.js";function To(n,e,r=!1,s=!1,a=!1,o=!1){var i=n,c="";if(r){var x=n;fn&&(i=Ir(Kn(x)))}q(()=>{var g=to;if(c===(c=e()??"")){fn&&zs();return}if(r&&!fn){g.nodes=null,x.innerHTML=c,c!==""&&Ur(Kn(x),x.lastChild);return}if(g.nodes!==null&&(no(g.nodes.start,g.nodes.end),g.nodes=null),c!==""){if(fn){Qr.data;for(var I=zs(),D=I;I!==null&&(I.nodeType!==ha||I.data!=="");)D=I,I=Jr(I);if(I===null)throw ro(),so;Ur(Qr,D),i=Ir(I);return}var $=s?oo:a?io:void 0,R=ao(s?"svg":a?"math":"template",$);R.innerHTML=c;var C=s||a?R:R.content;if(Ur(Kn(C),C.lastChild),s||a)for(;Kn(C);)i.before(Kn(C));else i.before(C)}})}function Ao(n,e){let r=null,s=fn;var a;if(fn){r=Qr;for(var o=Kn(document.head);o!==null&&(o.nodeType!==ha||o.data!==n);)o=Jr(o);if(o===null)Us(!1);else{var i=Jr(o);o.remove(),Ir(i)}}fn||(a=document.head.appendChild(lo()));try{co(()=>{var c=uo(()=>e(a));c.f|=fo})}finally{s&&(Us(!0),Ir(r))}}function ma(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var a=n.length;for(e=0;e<a;e++)n[e]&&(r=ma(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Eo(){for(var n,e,r=0,s="",a=arguments.length;r<a;r++)(n=arguments[r])&&(e=ma(n))&&(s&&(s+=" "),s+=e);return s}function Ro(n){return typeof n=="object"?Eo(n):n??""}function Co(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function jt(n,e,r,s,a,o){var i=n[Hs];if(fn||i!==r||i===void 0){var c=Co(r);(!fn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[Hs]=r}return o}function ms(n,e,r=!1){if(n.multiple){if(e==null)return;if(!ho(e))return bo();for(var s of n.options)s.selected=e.includes(vr(s));return}for(s of n.options){var a=vr(s);if(ba(a,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function xa(n){var e=new MutationObserver(()=>{ms(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),va(()=>{e.disconnect()})}function $r(n,e,r=e){var s=new WeakSet,a=!0;Nr(n,"change",o=>{var i=o?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(i),vr);else{var x=n.querySelector(i)??n.querySelector("option:not([disabled])");c=x&&vr(x)}r(c),n.__value=c,Mn!==null&&s.add(Mn)}),po(()=>{var o=e();if(n===document.activeElement){var i=Mn;if(s.has(i))return}if(ms(n,o,a),a&&o===void 0){var c=n.querySelector(":checked");c!==null&&(o=vr(c),r(o))}n.__value=o,a=!1}),xa(n)}function vr(n){return"__value"in n?n.__value:n.value}function Rn(n,e,r=e){var s=new WeakSet;Nr(n,"input",async a=>{var o=a?n.defaultValue:n.value;if(o=Br(n)?Gr(o):o,r(o),Mn!==null&&s.add(Mn),await vo(),o!==(o=e())){var i=n.selectionStart,c=n.selectionEnd,x=n.value.length;if(n.value=o??"",c!==null){var g=n.value.length;i===c&&c===x&&g>x?(n.selectionStart=g,n.selectionEnd=g):(n.selectionStart=i,n.selectionEnd=Math.min(c,g))}}}),(fn&&n.defaultValue!==n.value||vs(e)==null&&n.value)&&(r(Br(n)?Gr(n.value):n.value),Mn!==null&&s.add(Mn)),gs(()=>{var a=e();if(n===document.activeElement){var o=Mn;if(s.has(o))return}Br(n)&&a===Gr(n.value)||n.type==="date"&&!a&&!n.value||a!==n.value&&(n.value=a??"")})}const Hr=new Set;function Dn(n,e,r,s,a=s){var o=r.getAttribute("type")==="checkbox",i=n;let c=!1;if(e!==null)for(var x of e)i=i[x]??=[];i.push(r),Nr(r,"change",()=>{var g=r.__value;o&&(g=Gs(i,g,r.checked)),a(g)},()=>a(o?[]:null)),gs(()=>{var g=s();if(fn&&r.defaultChecked!==r.checked){c=!0;return}o?(g=g||[],r.checked=g.includes(r.__value)):r.checked=ba(r.__value,g)}),va(()=>{var g=i.indexOf(r);g!==-1&&i.splice(g,1)}),Hr.has(i)||(Hr.add(i),Bs(()=>{i.sort((g,I)=>g.compareDocumentPosition(I)===4?-1:1),Hr.delete(i)})),Bs(()=>{if(c){var g;if(o)g=Gs(i,g,r.checked);else{var I=i.find(D=>D.checked);g=I?.__value}a(g)}})}function bn(n,e,r=e){Nr(n,"change",s=>{var a=s?n.defaultChecked:n.checked;r(a)}),(fn&&n.defaultChecked!==n.checked||vs(e)==null)&&r(n.checked),gs(()=>{var s=e();n.checked=!!s})}function Gs(n,e,r){for(var s=new Set,a=0;a<n.length;a+=1)n[a].checked&&s.add(n[a].__value);return r||s.delete(e),Array.from(s)}function Br(n){var e=n.type;return e==="number"||e==="range"}function Gr(n){return n===""?null:+n}const Io=!1,$o=!0,pu=Object.freeze(Object.defineProperty({__proto__:null,prerender:$o,ssr:Io},Symbol.toStringTag,{value:"Module"})),Wr="Wherever",Lo="Create & maintain apps from wherever with a beautiful remote workspace.",jr="https://localhost",Mo="#000000",Oo="black-translucent";function Qn(n,e){return yo(n)}var Do=m('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function No(n,e){Pn(e,!0);const r=jr.endsWith("/")?jr.slice(0,-1):jr,s=r+"/preview.png";let a=le(()=>e.home||!1),o=le(()=>({type:e.type||"website",title:e.title||Wr,description:e.description||Lo,image:e.image||s,url:`${r}${So.url.pathname}`}));Ao("13n5pl5",i=>{var c=Do(),x=Ht(c),g=f(x,2),I=f(g,2);{var D=ue=>{var ct=Jn(),wt=Ht(ct);E(wt,Ee=>{}),h(ue,ct)};E(I,ue=>{t(a)&&ue(D)})}var $=f(I,2),R=f($,2),C=f(R,2),ae=f(C,2),Le=f(ae,2),Ce=f(Le,4),ce=f(Ce,2),Fe=f(ce,2),Ie=f(Fe,2),De=f(Ie,2),pe=f(De,2),$e=f(pe,2),_e=f($e,2),Ye=f(_e,2),We=f(Ye,4),Me=f(We,4),ze=f(Me,2),tt=f(ze,2);q((ue,ct,wt,Ee)=>{qe(x,"content",t(o).title),qe(g,"content",t(o).description),qe($,"content",t(o).type),qe(R,"content",t(o).url),qe(C,"content",t(o).title),qe(ae,"content",t(o).description),qe(Le,"content",t(o).image),qe(Ce,"content",t(o).url),qe(ce,"content",t(o).title),qe(Fe,"content",t(o).description),qe(Ie,"content",t(o).image),qe(De,"href",ue),qe(pe,"href",ct),qe($e,"href",wt),qe(_e,"href",Ee),qe(Ye,"content",Mo),qe(We,"content",Wr),qe(Me,"content",Oo),qe(ze,"content",Wr),qe(tt,"content",ga)},[()=>Qn("/pwa/favicon.png"),()=>Qn("/pwa/favicon.ico"),()=>Qn("/pwa/apple-touch-icon.png"),()=>Qn("/pwa/manifest.webmanifest")]),go(()=>{mo.title=t(o).title??""}),h(i,c)}),Fn()}function Rr(){}function Po(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Fo(n,...e){if(n==null)return Rr;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function gn(n){let e;return Fo(n,r=>e=r)(),e}var Yn=[];function zo(n,e=Rr){let r;const s=new Set;function a(c){if(Po(n,c)&&(n=c,r)){const x=!Yn.length;for(const g of s)g[1](),Yn.push(g,n);if(x){for(let g=0;g<Yn.length;g+=2)Yn[g][0](Yn[g+1]);Yn.length=0}}}function o(c){a(c(n))}function i(c,x=Rr){const g=[c,x];return s.add(g),s.size===1&&(r=e(a)||Rr),c(n),()=>{s.delete(g),s.size===0&&(r(),r=null)}}return{set:a,update:o,subscribe:i}}const qr={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,conflict:null,isInterrupted:!1,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};class Un{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;constructor(e){this.config={secure:!0,...e},this.stateStore=zo({...qr,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(R=>r?{...R,connecting:!0,error:null}:{...qr,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",a=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,o=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",i=`${s}://${a}:${this.config.port}/ws${o}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(R=>({...R,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const R=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=R?new c(i,R):new c(i)}catch(R){this.stateStore.update(C=>({...C,connecting:!1,error:`Failed to connect: ${R}`})),this.scheduleReconnect();return}const x=this.ws,g=()=>{if(this.ws===x)if(this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(R=>({...R,connected:!0,connecting:!1,error:null})),this.resumeSessionFile){const R=this.resumeSessionFile,C=this.resumeCwd,ae=this.resumeModel;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.send({type:"session_load",sessionFile:R,cwd:C,model:ae}),this.armLoadWatchdog()}else this.stateStore.update(R=>R.resyncing?{...R,resyncing:!1}:R)},I=R=>{if(this.ws===x){this.lastInboundAt=Date.now();try{const C=typeof R.data=="string"?R.data:R.data.toString(),ae=JSON.parse(C);this.handleMessage(ae)}catch(C){console.error("Failed to parse WebSocket message:",C)}}},D=()=>{this.ws===x&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(R=>({...R,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1})),this.scheduleReconnect())},$=R=>{this.ws===x&&this.stateStore.update(C=>({...C,error:C.error||"Connection error occurred"}))};typeof x.addEventListener=="function"?(x.addEventListener("open",g),x.addEventListener("message",I),x.addEventListener("close",D),x.addEventListener("error",$)):typeof x.on=="function"&&(x.on("open",g),x.on("message",R=>I({data:R})),x.on("close",D),x.on("error",$))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.ws){try{typeof this.ws.removeAllListeners=="function"&&this.ws.removeAllListeners(),this.ws.close()}catch{}this.ws=null}e&&this.stateStore.set({...qr,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}suspend(){const e=gn(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=gn(this.stateStore);e.connected||e.connecting||(this.resumeSessionFile&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,Un.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,a=gn(this.stateStore).isStreaming,o=a?Un.TURN_STALL_MS:Un.STALE_SOCKET_MS;if(s<o)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${o}ms, ${a?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const i=this.ws;this.ws=null;try{typeof i.terminate=="function"?i.terminate():typeof i.close=="function"&&i.close()}catch{}this.stateStore.update(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:a?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,Un.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=gn(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},Un.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),this.stateStore.update(e=>({...e,connecting:!0,error:"Reconnecting..."})),this.connect()},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let a=[...s.messages].reverse().find(o=>o.role==="thinking"&&o.isStreaming);if(!a){const o={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,o]}}return{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content+e.delta,isStreaming:!0}:o)}});break;case"message_update":this.stateStore.update(s=>{let a=[...s.messages].reverse().find(o=>o.role==="assistant"&&o.isStreaming);if(!a){const o={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,o]}}return{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content+e.delta,isStreaming:!0}:o)}});break;case"message_end":this.stateStore.update(s=>{let a=s.messages;const o=[...a].reverse().find(c=>c.role==="thinking"&&c.isStreaming);o&&(a=a.map(c=>c.id===o.id?{...c,isStreaming:!1}:c));const i=[...a].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(i)a=a.map(c=>c.id===i.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){const c=[...a].reverse().find(g=>g.role==="user");e.role==="user"&&c&&c.content===e.content||(a=[...a,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:a}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{this.stateStore.update(s=>({...s,isStreaming:!1,messages:s.messages.map(a=>a.isStreaming?{...a,isStreaming:!1}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,a])=>a!==void 0&&a!=="").map(([s,a])=>`${s}=${JSON.stringify(a)}`).join(" "):"";this.stateStore.update(s=>{const a=s.messages.map(i=>i.isStreaming&&(i.role==="assistant"||i.role==="thinking")?{...i,isStreaming:!1}:i),o={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:Date.now(),isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:""};return{...s,messages:[...a,o]}});break;case"tool_update":{this.stateStore.update(s=>{const a=[...s.messages].reverse().find(o=>o.role==="tool"&&o.toolName===e.toolName&&o.isStreaming);return a?{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content.includes(`
2
2
  `)?o.content+e.delta:`${o.content}
3
3
  ${e.delta}`,toolOutput:`${o.toolOutput}${e.delta}`}:o)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"";this.stateStore.update(a=>{const o=[...a.messages].reverse().find(i=>i.role==="tool"&&i.toolName===e.toolName&&!i.content.startsWith("Tool error:"));if(o){const i=e.isError?"Error: ":"";return{...a,messages:a.messages.map(c=>c.id===o.id?{...c,content:`${i}${c.content}
4
4
  ${s}`,isStreaming:!1,isError:e.isError,toolOutput:s}:c)}}else{const i=e.isError?`Tool error: ${e.toolName}
@@ -79,4 +79,4 @@ ${A}`}}if(Z.startsWith("/")&&t(ce).length===0){const P=Z.toLowerCase();if(P==="/
79
79
  msgs`)},[()=>encodeURIComponent(t(he).id),()=>t(he).name||Re(t(he).firstMessage)||"Empty session",()=>pt(t(he).modified)]),G("click",H,ke=>{ke.button===0&&!ke.ctrlKey&&!ke.metaKey&&!ke.altKey&&!ke.shiftKey&&(ke.preventDefault(),me(t(he).path))}),h(Ue,U)}),d(Ne),h(ve,Ne)},nt=le(()=>ue(t(j).path));E(W,ve=>{t(nt)&&ve(de)})}d(Se),q(ve=>{jt(_,1,`text-xs text-brand-text-muted transition-transform ${ve??""}`),ie(z,t(j).name),ie(V,t(j).path),ie(be,t(j).sessions.length)},[()=>ue(t(j).path)?"rotate-90":""]),G("click",ye,()=>ct(t(j).path)),h(F,Se)}),h(b,S)};E(xt,b=>{t(Le)&&t(ze).length===0?b(en):t(ze).length===0?b(Zt,1):b(vt,-1)})}d(Ae),d(Bt);var _t=f(Bt,2);{var sn=b=>{var S=xd(),M=u(S),F=f(u(M),2),j=f(u(F),2),Se=u(j,!0);d(j),d(F);var ye=f(F,2),_=f(u(ye),2);{var w=k=>{var be=gd();un(be,21,()=>t(pe),An,(W,de)=>{var nt=vd(),ve=u(nt);d(nt);var Ne={};q(()=>{ie(ve,`${t(de).label??""}${t(de).isDefault?" (default)":""}`),Ne!==(Ne=`${t(de).provider}:${t(de).modelId}`)&&(nt.value=nt.__value=`${t(de).provider}:${t(de).modelId}`)}),h(W,nt)}),d(be),$r(be,()=>t(Be).selected,W=>t(Be).selected=W),h(k,be)},B=k=>{var be=md();rt(be),Rn(be,()=>t(Be).selected,W=>t(Be).selected=W),h(k,be)};E(_,k=>{t(pe).length>0?k(w):k(B,-1)})}d(ye);var z=f(ye,2),re=u(z),V=f(re,2);d(z),d(M),d(S),q(()=>ie(Se,t(Be).folderPath)),G("click",S,Ge),G("click",M,k=>k.stopPropagation()),G("click",re,Ge),G("click",V,gt),h(b,S)};E(_t,b=>{t(Be).open&&b(sn)})}var an=f(_t,2);{var dn=b=>{var S=_d(),M=u(S),F=u(M,!0);d(M);var j=f(M,2);d(S),q(()=>ie(F,I())),G("click",j,()=>Bn()),h(b,S)};E(an,b=>{I()&&b(dn)})}var ln=f(an,2);{var N=b=>{var S=Td(),M=u(S),F=f(u(M),2),j=f(u(F)),Se=u(j,!0);d(j),ot(),d(F);var ye=f(F,2),_=u(ye),w=u(_);rt(w);var B=f(w,2),z=f(u(B));{var re=ve=>{var Ne=yd();h(ve,Ne)},V=ve=>{var Ne=wd();h(ve,Ne)};E(z,ve=>{t(A).isGit?ve(re):ve(V,-1)})}d(B),d(_);var k=f(_,2);{var be=ve=>{var Ne=Sd(),Pe=u(Ne),at=u(Pe);rt(at);var Rt=f(at,2),Ue=u(Rt);d(Rt),d(Pe);var he=f(Pe,2);{var U=H=>{var Te=kd(),X=f(u(Te),2),te=u(X);rt(te),te.value=te.__value="private",ot(),d(X);var J=f(X,2),L=u(J);rt(L),L.value=L.__value="public",ot(),d(J),d(Te),Dn(R,[],te,()=>t(Z),se=>p(Z,se)),Dn(R,[],L,()=>t(Z),se=>p(Z,se)),h(H,Te)};E(he,H=>{t(It)&&H(U)})}d(Ne),q(()=>ie(Ue,`Create remote ${t(A).matchingRule.provider??""} repository`)),bn(at,()=>t(It),H=>p(It,H)),h(ve,Ne)};E(k,ve=>{t(A).matchingRule&&ve(be)})}d(ye);var W=f(ye,2),de=u(W),nt=f(de,2);d(W),d(M),d(S),q(()=>{ie(Se,t(dt)),w.disabled=t(A).isGit}),bn(w,()=>t(ft),ve=>p(ft,ve)),G("click",de,()=>p(y,!1)),G("click",nt,Ze),h(b,S)};E(ln,b=>{t(y)&&b(N)})}q(()=>{wo(mt,t(Me)),jt(Gt,1,Ro(t(Le)?"animate-spin":""))}),G("input",mt,b=>p(Me,b.currentTarget.value,!0)),G("click",Et,()=>Ce()),h(n,Ke),Fn(),$()}Wn(["input","click","keydown","change"]);var Ed=m(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60"><div class="mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl"><h2 class="mb-2 text-lg font-bold text-brand-text">Session Conflict</h2> <p class="mb-6 text-sm text-brand-text-muted">Another client is active on a session in folder <span class="font-mono text-xs text-brand-text"> </span>. What would you like to do?</p> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Read Only</button> <button class="flex-1 rounded-lg bg-rose-500 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-rose-600">Take Over</button></div> <p class="mt-4 text-xs text-brand-text-muted"><strong class="text-brand-text">Read Only:</strong> Observe the session
80
80
  live but cannot send messages.<br/> <strong class="text-brand-text">Take Over:</strong> Interrupt the other client
81
81
  and gain control.</p></div></div>`);function Rd(n,e){Pn(e,!0);const r=()=>Ve(Oa,"$conflict",s),[s,a]=rr();let o=le(r);var i=Jn(),c=Ht(i);{var x=g=>{var I=Ed(),D=u(I),$=f(u(D),2),R=f(u($)),C=u(R,!0);d(R),ot(),d($);var ae=f($,2),Le=u(ae),Ce=f(Le,2);d(ae),ot(2),d(D),d(I),q(()=>ie(C,t(o).conflictingCwd)),G("click",Le,()=>is("read_only")),G("click",Ce,()=>is("take_over")),h(g,I)};E(c,g=>{t(o)&&g(x)})}h(n,i),Fn(),a()}Wn(["click"]);var Cd=m('<div class="fixed inset-0 z-[100] flex items-center justify-center bg-brand-dark/60 backdrop-blur-sm"><div class="flex flex-col items-center gap-4"><div class="h-12 w-12 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <span class="text-lg font-bold text-brand-text">Creating session...</span></div></div>'),Id=m('<span class="text-lg font-bold text-brand-text">Connection Settings</span> <button class="rounded px-2 py-1 text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-2 hover:text-brand-blue">◀ Back</button>',1),$d=m('<button class="flex items-center gap-2 text-left" title="Show Main Screen / New Session"><img alt="Wherever" class="h-6 w-6"/> <span class="gradient-text text-lg font-bold">Wherever</span></button> <div class="flex items-center gap-2"><button class="flex items-center gap-1 rounded border border-brand-border px-1.5 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-2 hover:text-brand-text" title="Connection Settings">⚙️ Config</button> <button class="text-brand-text-muted hover:text-brand-text md:hidden">X</button></div>',1),Ld=m('<div class="flex-1 overflow-y-auto"><!> <div class="mt-2 border-t border-brand-border p-4"><h3 class="mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase">Server Control</h3> <div class="space-y-2"><button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Refresh Session List</span> <span>🔄</span></button> <button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Reconnect WebSocket</span> <span>🔌</span></button> <button class="flex w-full items-center justify-between rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-left text-sm text-rose-400 transition-colors hover:bg-red-500/20 hover:text-rose-300"><span>Disconnect Server</span> <span>🛑</span></button></div></div></div>'),Md=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),Od=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),Dd=m('<div class="mt-2 space-y-1"><!> <!> <div class="pt-1.5"><button class="w-full rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-center text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Show Main Screen (Clear URL Hash)">Close Session</button></div></div>'),Nd=m('<div class="mt-2 text-xs text-rose-400"> </div>'),Pd=m('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-brand-text" title="View read-only sessions (e.g. autonomous agent fleets)"><span>👁️</span> <span>Read-only sessions</span> <span class="ml-auto">→</span></button>'),Fd=m('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/50" title="Back to your sessions"><span>←</span> <span>Back to sessions</span></button>'),zd=m('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span> <span class="ml-auto font-mono text-xs text-brand-text-muted" title="App build version"> </span></div> <!> <!></div> <div class="border-b border-brand-border/50 px-2 py-1.5"><!></div> <div class="flex-1 overflow-hidden"><!></div>',1),Ud=m('<button type="button" class="flex flex-shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-sm text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Search the web" aria-label="Search the web">🔍</button>'),Hd=m('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Bd=m('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Gd=m('<span class="text-sm text-brand-text-muted">Not connected</span>'),Wd=m('<div class="flex min-w-0 items-center gap-2"><!></div>'),jd=m('<div class="flex min-w-0 items-center gap-1.5 text-xs text-brand-text-muted"><span class="flex-shrink-0">📁</span> <span class="truncate"> </span></div>'),qd=m("<option> </option>"),Vd=m('<select class="max-w-48 truncate rounded border border-brand-border bg-brand-surface-2 px-1.5 py-0.5 text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Yd=m('<span class="truncate text-brand-text-muted"> </span>'),Zd=m('<div class="flex min-w-0 items-center gap-1.5 text-xs"><span class="relative flex flex-shrink-0 items-center justify-center text-sm"><span>🤖</span> <span></span></span> <!></div>'),Kd=m('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Xd=m('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Qd=m('<div class="border border-red-500/30 bg-red-500/10 px-4 py-2 text-center text-sm text-rose-400">Your session was interrupted — another client took over.</div>'),Jd=m('<div class="flex items-start justify-between gap-2 border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-rose-400"><span class="max-h-24 min-w-0 flex-1 overflow-y-auto break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss error" class="flex-shrink-0 text-rose-300 hover:text-rose-200">X</button></div>'),eu=m('<div class="border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-center text-sm text-yellow-400">Read-only: this session cannot be driven from here</div>'),tu=m('<div class="border-t border-brand-border bg-brand-surface px-4 py-3 text-center text-xs text-brand-text-muted">👁️ Read-only session, observing only, no input.</div>'),nu=m('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Reconnecting and syncing session...</span></div>'),ru=m("<!> <!>",1),su=m('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),au=m('<!> <!> <div class="fixed inset-0 flex overflow-hidden overscroll-none bg-brand-dark text-brand-text"><div><div class="border-b border-brand-border bg-brand-surface-2/20 p-4"><div class="flex items-center justify-between"><!></div></div> <!></div> <div class="flex min-w-0 flex-1 flex-col"><div class="app-chrome flex items-center gap-3 border-b border-brand-border bg-brand-surface p-3"><button class="p-1 text-brand-text-muted hover:text-brand-text md:hidden">=</button> <!> <!> <!> <!></div> <!> <!> <!> <!> <!></div> <!> <!></div>',1);function hu(n,e){Pn(e,!0);const r=()=>Ve(kr,"$isConnected",R),s=()=>Ve(Cs,"$isResyncing",R),a=()=>Ve(Pr,"$isLoadingSession",R),o=()=>Ve(Da,"$isInterrupted",R),i=()=>Ve(Es,"$sessionError",R),c=()=>Ve(Rs,"$isReadOnly",R),x=()=>Ve(Sr,"$activeSessionInfo",R),g=()=>Ve(Ot,"$piState",R),I=()=>Ve(tr,"$availableModels",R),D=()=>Ve(Na,"$isCreatingSession",R),$=()=>Ve(_s,"$searchFolderStore",R),[R,C]=rr();let ae=Y(!1),Le=Y("main"),Ce=Y(!1),ce;yr(()=>{setTimeout(()=>Hn(),200);const N=()=>{if(t(_e)){const j=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";j&&j!==t(me)?Ts(j):!j&&t(me)&&hn()}};window.addEventListener("hashchange",N);let b=null;const S=8e3,M=()=>{if(document.visibilityState==="hidden"){if(Aa())return;b&&clearTimeout(b),b=setTimeout(()=>{b=null,document.visibilityState==="hidden"&&t(_e)&&Sa()},S)}else Ss(),b&&(clearTimeout(b),b=null),t(_e)||(as()?ss():Hn())},F=j=>{b&&(clearTimeout(b),b=null),document.visibilityState!=="hidden"&&!t(_e)&&(as()?ss():Hn())};return document.addEventListener("visibilitychange",M),window.addEventListener("pageshow",F),()=>{window.removeEventListener("hashchange",N),document.removeEventListener("visibilitychange",M),window.removeEventListener("pageshow",F),b&&clearTimeout(b)}});function Fe(){Hn()}function Ie(){hn(),_r()}function De(){_r(),setTimeout(()=>Hn(),100)}function pe(){gr()}function $e(){typeof window<"u"&&(window.location.hash=""),hn(),p(ae,!1)}let _e=le(r),Ye=le(s),We=le(a),Me=le(o),ze=le(i),tt=le(c),ue=le(x),ct=le(g),wt=le(()=>I().models),Ee=Y(!1),me=le(()=>t(ue).sessionId);Ct(()=>{typeof window<"u"&&t(_e)&&(t(me)?(window.location.hash=encodeURIComponent(t(me)),p(Ee,!0)):t(Ee)&&(p(Ee,!1),window.location.hash&&(window.location.hash="")))});let Nt=null;Ct(()=>{if(!t(_e)||typeof window>"u"||!window.location.hash)return;const N=decodeURIComponent(window.location.hash.slice(1));N&&(t(me)===N||t(We)||t(Ye)||Nt||(Nt=setTimeout(()=>{Nt=null,!(t(me)===N||t(We)||t(Ye))&&Ra(N)},300)))}),Ct(()=>{t(_e)||p(Ee,!1)}),Ct(()=>{(t(me)||t(We)||t(Ye))&&p(ae,!1)});let dt=le(D),He=le($),Pt=Y(void 0),je=le(()=>t(_e)&&!!t(He)&&!t(ue).sessionFile),$t=Y(!1);Ct(()=>{t(je)&&!t($t)&&t(Pt)&&(p($t,!0),t(Pt).focusInput())});function Jt(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),hn(),t(Pt)?.focusInput()}var ut=au(),ft=Ht(ut);No(ft,{title:"Wherever",description:"Create & maintain apps from wherever"});var Ft=f(ft,2);{var It=N=>{var b=Cd();h(N,b)};E(Ft,N=>{t(dt)&&N(It)})}var Z=f(Ft,2),y=u(Z),P=u(y),A=u(P),Q=u(A);{var K=N=>{var b=Id(),S=f(Ht(b),2);G("click",S,()=>p(Ce,!1)),h(N,b)},ee=N=>{var b=$d(),S=Ht(b),M=u(S);ot(2),d(S);var F=f(S,2),j=u(F),Se=f(j,2);d(F),q(ye=>qe(M,"src",ye),[()=>Qn("/logo.svg")]),G("click",S,$e),G("click",j,()=>p(Ce,!0)),G("click",Se,()=>p(ae,!1)),h(N,b)};E(Q,N=>{t(Ce)?N(K):N(ee,-1)})}d(A),d(P);var fe=f(P,2);{var Ze=N=>{var b=Ld(),S=u(b);{let _=le(()=>(t(ct).connected,"localhost"));ni(S,{get host(){return t(_)},port:31415,token:"",onConnected:Fe})}var M=f(S,2),F=f(u(M),2),j=u(F),Se=f(j,2),ye=f(Se,2);d(F),d(M),d(b),G("click",j,pe),G("click",Se,De),G("click",ye,Ie),h(N,b)},Be=N=>{var b=zd(),S=Ht(b),M=u(S),F=u(M),j=f(F,2),Se=u(j,!0);d(j);var ye=f(j,2),_=u(ye);d(ye),d(M);var w=f(M,2);{var B=Pe=>{var at=Dd(),Rt=u(at);{var Ue=X=>{var te=Md(),J=u(te);d(te),q(L=>{qe(te,"title",t(ue).cwd),ie(J,`📁 ${L??""}`)},[()=>t(ue).cwd.split("/").pop()||t(ue).cwd]),h(X,te)};E(Rt,X=>{t(ue).cwd&&X(Ue)})}var he=f(Rt,2);{var U=X=>{var te=Od(),J=u(te);d(te),q(()=>{qe(te,"title",t(ue).model),ie(J,`🤖 ${t(ue).model??""}`)}),h(X,te)};E(he,X=>{t(ue).model&&X(U)})}var H=f(he,2),Te=u(H);d(H),d(at),G("click",Te,$e),h(Pe,at)};E(w,Pe=>{t(ue).sessionFile&&Pe(B)})}var z=f(w,2);{var re=Pe=>{var at=Nd(),Rt=u(at,!0);d(at),q(()=>ie(Rt,t(ct).error)),h(Pe,at)};E(z,Pe=>{t(ct).error&&!t(_e)&&Pe(re)})}d(S);var V=f(S,2),k=u(V);{var be=Pe=>{var at=Pd();G("click",at,()=>{p(Le,"readonly"),_a()}),h(Pe,at)},W=Pe=>{var at=Fd();G("click",at,()=>p(Le,"main")),h(Pe,at)};E(k,Pe=>{t(Le)==="main"?Pe(be):Pe(W,-1)})}d(V);var de=f(V,2),nt=u(de);{var ve=Pe=>{pa(Pe,{readOnly:!0})},Ne=Pe=>{pa(Pe,{})};E(nt,Pe=>{t(Le)==="readonly"?Pe(ve):Pe(Ne,-1)})}d(de),q(()=>{jt(F,1,`h-2.5 w-2.5 rounded-full ${t(_e)?"bg-emerald-500":"bg-rose-500"}`),jt(j,1,`text-sm ${t(_e)?"text-emerald-400":"text-rose-400"}`),ie(Se,t(_e)?"Connected":"Disconnected"),ie(_,`v${ga}`)}),h(N,b)};E(fe,N=>{t(Ce)?N(Ze):N(Be,-1)})}d(y);var st=f(y,2),Ge=u(st),gt=u(Ge),pt=f(gt,2);{var Re=N=>{var b=Ud();G("click",b,Jt),h(N,b)};E(pt,N=>{t(_e)&&t(He)&&t(ue).sessionFile&&N(Re)})}var Ke=f(pt,2);{var Bt=N=>{var b=Wd(),S=u(b);{var M=Se=>{var ye=Hd();h(Se,ye)},F=Se=>{var ye=Bd();h(Se,ye)},j=Se=>{var ye=Gd();h(Se,ye)};E(S,Se=>{t(_e)&&t(je)?Se(M):t(_e)?Se(F,1):Se(j,-1)})}d(b),h(N,b)};E(Ke,N=>{(!t(_e)||!t(ue).sessionFile)&&N(Bt)})}var Dt=f(Ke,2);{var kt=N=>{var b=Kd(),S=u(b);{var M=Se=>{var ye=jd(),_=f(u(ye),2),w=u(_,!0);d(_),d(ye),q(B=>{qe(_,"title",t(ue).cwd),ie(w,B)},[()=>t(ue).cwd.split("/").pop()||t(ue).cwd]),h(Se,ye)};E(S,Se=>{t(ue).cwd&&Se(M)})}var F=f(S,2);{var j=Se=>{var ye=Zd(),_=u(ye),w=f(u(_),2);d(_);var B=f(_,2);{var z=V=>{var k=Vd();un(k,21,()=>t(wt),An,(W,de)=>{var nt=qd(),ve=u(nt,!0);d(nt);var Ne={};q(()=>{ie(ve,t(de).label),Ne!==(Ne=`${t(de).provider}:${t(de).modelId}`)&&(nt.value=nt.__value=`${t(de).provider}:${t(de).modelId}`)}),h(W,nt)}),d(k);var be;xa(k),q(()=>{be!==(be=t(ue).model)&&(k.value=(k.__value=t(ue).model)??"",ms(k,t(ue).model))}),G("input",k,W=>La(W.currentTarget.value)),h(V,k)},re=V=>{var k=Yd(),be=u(k,!0);d(k),q(()=>{qe(k,"title",t(ue).model),ie(be,t(ue).model)}),h(V,k)};E(B,V=>{t(wt).length>0&&!t(tt)?V(z):V(re,-1)})}d(ye),q(()=>{jt(w,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(ct).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),qe(w,"title",t(ct).isStreaming?"Agent working...":"Ready")}),h(Se,ye)};E(F,Se=>{t(ue).model&&Se(j)})}d(b),h(N,b)};E(Dt,N=>{t(ue).sessionFile&&N(kt)})}var mt=f(Dt,2);{var Et=N=>{var b=Xd();h(N,b)};E(mt,N=>{t(tt)&&N(Et)})}d(Ge);var Gt=f(Ge,2);{var Ae=N=>{var b=Qd();h(N,b)};E(Gt,N=>{t(Me)&&N(Ae)})}var Qe=f(Gt,2);{var zt=N=>{var b=Jd(),S=u(b),M=u(S,!0);d(S);var F=f(S,2);d(b),q(()=>ie(M,t(ze))),G("click",F,()=>Bn()),h(N,b)};E(Qe,N=>{t(ze)&&N(zt)})}var xt=f(Qe,2);{var en=N=>{var b=eu();h(N,b)};E(xt,N=>{t(tt)&&!t(Me)&&N(en)})}var Zt=f(xt,2);En(xc(Zt,{onMessageSent:()=>{}}),N=>ce=N,()=>ce);var vt=f(Zt,2);{var _t=N=>{var b=tu();h(N,b)},sn=N=>{var b=ru(),S=Ht(b);{var M=j=>{var Se=nu();h(j,Se)};E(S,j=>{t(ue).sessionFile&&(t(Ye)||!t(_e))&&j(M)})}var F=f(S,2);{let j=le(()=>!!t(He)),Se=le(()=>t(je)?!t(_e):!t(_e)||t(tt)||!t(ue).sessionFile||t(Ye));En(Gc(F,{get searchMode(){return t(je)},get searchConfigured(){return t(j)},onSubmit:ye=>Ca(ye),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(Se)},onSend:()=>ce?.forceScrollToBottom()}),ye=>p(Pt,ye,!0),()=>t(Pt))}h(N,b)};E(vt,N=>{t(tt)&&t(ue).sessionFile?N(_t):N(sn,-1)})}d(st);var an=f(st,2);Rd(an,{});var dn=f(an,2);{var ln=N=>{var b=su();G("click",b,()=>p(ae,!1)),h(N,b)};E(dn,N=>{t(ae)&&N(ln)})}d(Z),q(()=>jt(y,1,`app-chrome ${t(ae)?"translate-x-0":"-translate-x-full"} fixed z-20 flex h-full w-72 flex-col border-r border-brand-border bg-brand-surface transition-transform duration-200 md:relative md:translate-x-0`)),G("click",gt,()=>p(ae,!t(ae))),h(n,ut),Fn(),C()}Wn(["click","input"]);export{hu as component,pu as universal};
82
- //# sourceMappingURL=2.Z4jvbTfo.js.map
82
+ //# sourceMappingURL=2.jv_uwe0e.js.map