wherever-dev 0.10.12 → 0.10.13

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 (29) hide show
  1. package/package.json +1 -1
  2. package/public/_app/immutable/assets/0.BLdSNDwj.css +1 -0
  3. package/public/_app/immutable/chunks/{DHIEbea_.js → 8eypMp_V.js} +2 -2
  4. package/public/_app/immutable/chunks/{DHIEbea_.js.map → 8eypMp_V.js.map} +1 -1
  5. package/public/_app/immutable/chunks/{wvFikTuW.js → CtPQjCBP.js} +2 -2
  6. package/public/_app/immutable/chunks/{wvFikTuW.js.map → CtPQjCBP.js.map} +1 -1
  7. package/public/_app/immutable/chunks/{C802ERXP.js → Dbf0zjW2.js} +2 -2
  8. package/public/_app/immutable/chunks/{C802ERXP.js.map → Dbf0zjW2.js.map} +1 -1
  9. package/public/_app/immutable/entry/{app.CDq0HLUN.js → app.BNS6jUfJ.js} +3 -3
  10. package/public/_app/immutable/entry/{app.CDq0HLUN.js.map → app.BNS6jUfJ.js.map} +1 -1
  11. package/public/_app/immutable/entry/start.CY5doj7d.js +2 -0
  12. package/public/_app/immutable/entry/start.CY5doj7d.js.map +1 -0
  13. package/public/_app/immutable/nodes/{0.BX0-WNRM.js → 0.COQnYGwL.js} +2 -2
  14. package/public/_app/immutable/nodes/{0.BX0-WNRM.js.map → 0.COQnYGwL.js.map} +1 -1
  15. package/public/_app/immutable/nodes/{1.WAaKe5sz.js → 1.irnAmVhW.js} +2 -2
  16. package/public/_app/immutable/nodes/{1.WAaKe5sz.js.map → 1.irnAmVhW.js.map} +1 -1
  17. package/public/_app/immutable/nodes/{2.q5b1Ictx.js → 2.kEWDQAI7.js} +2 -2
  18. package/public/_app/immutable/nodes/{2.q5b1Ictx.js.map → 2.kEWDQAI7.js.map} +1 -1
  19. package/public/_app/version.json +1 -1
  20. package/public/index.html +11 -11
  21. package/public/pwa/favicon-maskable-192.png +0 -0
  22. package/public/pwa/favicon-maskable-512.png +0 -0
  23. package/public/pwa/manifest.webmanifest +32 -2
  24. package/public/pwa/screenshot-desktop.png +0 -0
  25. package/public/pwa/screenshot-mobile.png +0 -0
  26. package/public/service-worker.js +1 -1
  27. package/public/_app/immutable/assets/0.CC0hR-g4.css +0 -1
  28. package/public/_app/immutable/entry/start.DVPKM4ve.js +0 -2
  29. package/public/_app/immutable/entry/start.DVPKM4ve.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{b as wo,a as h,c as Mr,g as b,d as ss,e as F,s as V,f as Dr,t as Zn,h as so}from"../chunks/itgD7vGH.js";import{as as Qn,b3 as Js,am as cs,bf as O,aq as Ma,O as Kl,aT as Yl,ar as No,d as pi,an as Fo,au as Xl,n as Zl,a1 as Ql,u as Jl,t as ec,a2 as tc,W as nc,X as rc,H as sc,b4 as $a,C as La,z as Oa,aF as oo,a3 as Hr,ad as oc,aA as ac,a_ as ic,az as hi,be as bi,bg as lc,bh as es,aV as Qo,aR as Da,aQ as qr,aN as Vr,ag as pn,b7 as f,aj as t,a6 as cc,bi as j,$ as dc,bm as Sn,ai as Dn,a9 as Yt,aL as Ns,a$ as p,Y as d,aW as l,aJ as Ke,ba as G,aP as dr,bj as Ct,bk as uc,aU as fc}from"../chunks/CRRPBe07.js";import{i as w,s as vs,a as Ae,p as Wr}from"../chunks/Dtm96ZKi.js";import{a as pc,b as Z,r as at,c as vi,e as qn,i as vr,d as hc}from"../chunks/DHIEbea_.js";import{_ as bc,b as mr}from"../chunks/CAWbdcQM.js";import{v as Vs}from"../chunks/C802ERXP.js";import{p as vc}from"../chunks/wvFikTuW.js";function Pa(n,e,r=!1,s=!1,o=!1,a=!1){var i=n,c="";if(r){var v=n;Qn&&(i=Js(cs(v)))}O(()=>{var m=Kl;if(c===(c=e()??"")){Qn&&Ma();return}if(r&&!Qn){m.nodes=null,v.innerHTML=c,c!==""&&wo(cs(v),v.lastChild);return}if(m.nodes!==null&&(Yl(m.nodes.start,m.nodes.end),m.nodes=null),c!==""){if(Qn){No.data;for(var x=Ma(),S=x;x!==null&&(x.nodeType!==pi||x.data!=="");)S=x,x=Fo(x);if(x===null)throw Xl(),Zl;wo(No,S),i=Js(x);return}var C=s?Jl:o?ec:void 0,$=Ql(s?"svg":o?"math":"template",C);$.innerHTML=c;var D=s||o?$:$.content;if(wo(cs(D),D.lastChild),s||o)for(;cs(D);)i.before(cs(D));else i.before(D)}})}function gc(n,e){let r=null,s=Qn;var o;if(Qn){r=No;for(var a=cs(document.head);a!==null&&(a.nodeType!==pi||a.data!==n);)a=Fo(a);if(a===null)$a(!1);else{var i=Fo(a);a.remove(),Js(i)}}Qn||(o=document.head.appendChild(tc()));try{nc(()=>{var c=rc(()=>e(o));c.f|=sc})}finally{s&&($a(!0),Js(r))}}function gi(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=gi(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function mc(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=gi(n))&&(s&&(s+=" "),s+=e);return s}function xc(n){return typeof n=="object"?mc(n):n??""}function _c(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function yc(n,e){return n==null?null:String(n)}function ln(n,e,r,s,o,a){var i=n[La];if(Qn||i!==r||i===void 0){var c=_c(r);(!Qn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[La]=r}return a}function wc(n,e,r,s){var o=n[Oa];if(Qn||o!==e){var a=yc(e);(!Qn||a!==n.getAttribute("style"))&&(a==null?n.removeAttribute("style"):n.style.cssText=a),n[Oa]=e}return s}function Jo(n,e,r=!1){if(n.multiple){if(e==null)return;if(!ac(e))return ic();for(var s of n.options)s.selected=e.includes(Is(s));return}for(s of n.options){var o=Is(s);if(hi(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function mi(n){var e=new MutationObserver(()=>{Jo(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),bi(()=>{e.disconnect()})}function Ds(n,e,r=e){var s=new WeakSet,o=!0;oo(n,"change",a=>{var i=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(i),Is);else{var v=n.querySelector(i)??n.querySelector("option:not([disabled])");c=v&&Is(v)}r(c),n.__value=c,Hr!==null&&s.add(Hr)}),oc(()=>{var a=e();if(n===document.activeElement){var i=Hr;if(s.has(i))return}if(Jo(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=Is(c),r(a))}n.__value=a,o=!1}),mi(n)}function Is(n){return"__value"in n?n.__value:n.value}function gr(n,e,r=e){var s=new WeakSet;oo(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=So(n)?To(a):a,r(a),Hr!==null&&s.add(Hr),await lc(),a!==(a=e())){var i=n.selectionStart,c=n.selectionEnd,v=n.value.length;if(n.value=a??"",c!==null){var m=n.value.length;i===c&&c===v&&m>v?(n.selectionStart=m,n.selectionEnd=m):(n.selectionStart=i,n.selectionEnd=Math.min(c,m))}}}),(Qn&&n.defaultValue!==n.value||es(e)==null&&n.value)&&(r(So(n)?To(n.value):n.value),Hr!==null&&s.add(Hr)),Qo(()=>{var o=e();if(n===document.activeElement){var a=Hr;if(s.has(a))return}So(n)&&o===To(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const ko=new Set;function Gr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",i=n;let c=!1;if(e!==null)for(var v of e)i=i[v]??=[];i.push(r),oo(r,"change",()=>{var m=r.__value;a&&(m=Na(i,m,r.checked)),o(m)},()=>o(a?[]:null)),Qo(()=>{var m=s();if(Qn&&r.defaultChecked!==r.checked){c=!0;return}a?(m=m||[],r.checked=m.includes(r.__value)):r.checked=hi(r.__value,m)}),bi(()=>{var m=i.indexOf(r);m!==-1&&i.splice(m,1)}),ko.has(i)||(ko.add(i),Da(()=>{i.sort((m,x)=>m.compareDocumentPosition(x)===4?-1:1),ko.delete(i)})),Da(()=>{if(c){var m;if(a)m=Na(i,m,r.checked);else{var x=i.find(S=>S.checked);m=x?.__value}o(m)}})}function Gn(n,e,r=e){oo(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(Qn&&n.defaultChecked!==n.checked||es(e)==null)&&r(n.checked),Qo(()=>{var s=e();n.checked=!!s})}function Na(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function So(n){var e=n.type;return e==="number"||e==="range"}function To(n){return n===""?null:+n}const kc=!1,Sc=!0,Jb=Object.freeze(Object.defineProperty({__proto__:null,prerender:Sc,ssr:kc},Symbol.toStringTag,{value:"Module"})),Ao="Wherever",Tc="Create & maintain apps from wherever with a beautiful remote workspace.",Ro="https://localhost",Ac="#000000",Rc="black-translucent";function us(n,e){return pc(n)}var Cc=b('<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 Ec(n,e){qr(e,!0);const r=Ro.endsWith("/")?Ro.slice(0,-1):Ro,s=r+"/preview.png";let o=j(()=>e.home||!1),a=j(()=>({type:e.type||"website",title:e.title||Ao,description:e.description||Tc,image:e.image||s,url:`${r}${vc.url.pathname}`}));gc("13n5pl5",i=>{var c=Cc(),v=pn(c),m=f(v,2),x=f(m,2);{var S=nt=>{var Mt=Mr(),vt=pn(Mt);w(vt,Jt=>{}),h(nt,Mt)};w(x,nt=>{t(o)&&nt(S)})}var C=f(x,2),$=f(C,2),D=f($,2),q=f(D,2),xe=f(q,2),J=f(xe,4),he=f(J,2),be=f(he,2),_e=f(be,2),Se=f(_e,2),ue=f(Se,2),ve=f(ue,2),wt=f(ve,2),Vt=f(wt,2),Ye=f(Vt,4),It=f(Ye,4),ge=f(It,2),ft=f(ge,2);O((nt,Mt,vt,Jt)=>{Z(v,"content",t(a).title),Z(m,"content",t(a).description),Z(C,"content",t(a).type),Z($,"content",t(a).url),Z(D,"content",t(a).title),Z(q,"content",t(a).description),Z(xe,"content",t(a).image),Z(J,"content",t(a).url),Z(he,"content",t(a).title),Z(be,"content",t(a).description),Z(_e,"content",t(a).image),Z(Se,"href",nt),Z(ue,"href",Mt),Z(ve,"href",vt),Z(wt,"href",Jt),Z(Vt,"content",Ac),Z(Ye,"content",Ao),Z(It,"content",Rc),Z(ge,"content",Ao),Z(ft,"content",Vs)},[()=>us("/pwa/favicon.png"),()=>us("/pwa/favicon.ico"),()=>us("/pwa/apple-touch-icon.png"),()=>us("/pwa/manifest.webmanifest")]),cc(()=>{dc.title=t(a).title??""}),h(i,c)}),Vr()}let gs=null;function Ic(){if(typeof window>"u")return null;try{if(!gs){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;gs=new n}return gs.state==="suspended"&&gs.resume().catch(()=>{}),gs}catch{return null}}function Fa(n,e,r,s,o){const a=n.createOscillator(),i=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(o,r+c),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(n.destination),a.start(r),a.stop(r+s+.02)}const Ua=new Map;function Mc(n){if(typeof Audio>"u")return!1;try{let e=Ua.get(n);e||(e=new Audio(n),e.preload="auto",Ua.set(n,e));try{e.currentTime=0}catch{}const r=e.play();return r&&typeof r.catch=="function"&&r.catch(()=>{}),!0}catch{return!1}}function xi(n){if(n&&n.trim()&&Mc(n.trim()))return;const e=Ic();if(e)try{const r=e.currentTime;Fa(e,1046.5,r,.16,.12),Fa(e,1396.9,r+.13,.22,.12)}catch{}}function ea(n){if(!n)return null;const e=n.trimStart(),r=e.match(/^<skill\s+name="([^"]*)"[^>]*>/);if(r){const s=e.indexOf("</skill>");return s===-1?null:{skillName:r[1],args:e.slice(s+8).trim()}}if(e.startsWith("/skill:")){const s=e.slice(7),o=s.indexOf(" "),a=o===-1?s:s.slice(0,o);if(!a)return null;const i=o===-1?"":s.slice(o+1).trim();return{skillName:a,args:i}}return null}function Ws(n){const e=ea(n);return e?`skill:${e.skillName}\0${e.args}`:null}function Ks(){}function $c(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Lc(n,...e){if(n==null)return Ks;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Kt(n){let e;return Lc(n,r=>e=r)(),e}var is=[];function Oc(n,e=Ks){let r;const s=new Set;function o(c){if($c(n,c)&&(n=c,r)){const v=!is.length;for(const m of s)m[1](),is.push(m,n);if(v){for(let m=0;m<is.length;m+=2)is[m][0](is[m+1]);is.length=0}}}function a(c){o(c(n))}function i(c,v=Ks){const m=[c,v];return s.add(m),s.size===1&&(r=e(o)||Ks),c(n),()=>{s.delete(m),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:i}}const Co={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,serverVersion:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null,pendingSteering:[],skills:[]};class hr{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;hasEverConnected=!1;static HANDSHAKE_FAIL_HINT_AFTER=2;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;pendingLoadFile=null;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=Oc({...Co,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?{...$,connecting:!0,error:null}:{...Co,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",i=`${s}://${o}:${this.config.port}/ws${a}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update($=>({...$,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const $=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=$?new c(i,$):new c(i)}catch($){this.stateStore.update(D=>({...D,connecting:!1,error:`Failed to connect: ${$}`})),this.scheduleReconnect();return}const v=this.ws,m=()=>{if(this.ws!==v)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(J=>({...J,connected:!0,connecting:!1,error:null}));const $=Kt(this.stateStore),D=this.resumeSessionFile??$.activeSessionFile,q=this.resumeSessionFile!=null?this.resumeCwd:$.activeCwd??void 0,xe=this.resumeSessionFile!=null?this.resumeModel:$.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,D?(this.stateStore.update(J=>J.resyncing?J:{...J,resyncing:!0}),this.pendingLoadFile=D,this.send({type:"session_load",sessionFile:D,cwd:q,model:xe}),this.armLoadWatchdog()):this.stateStore.update(J=>J.resyncing?{...J,resyncing:!1}:J)},x=$=>{if(this.ws===v){this.lastInboundAt=Date.now();try{const D=typeof $.data=="string"?$.data:$.data.toString(),q=JSON.parse(D);this.handleMessage(q)}catch(D){console.error("Failed to parse WebSocket message:",D)}}},S=()=>{this.ws===v&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update($=>({...$,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:$.activeSessionFile?!0:$.resyncing})),this.scheduleReconnect())},C=$=>{this.ws===v&&this.stateStore.update(D=>({...D,error:D.error||"Connection error occurred"}))};typeof v.addEventListener=="function"?(v.addEventListener("open",m),v.addEventListener("message",x),v.addEventListener("close",S),v.addEventListener("error",C)):typeof v.on=="function"&&(v.on("open",m),v.on("message",$=>x({data:$})),v.on("close",S),v.on("error",C))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...Co,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=Kt(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=Kt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Kt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,hr.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=Kt(this.stateStore).isStreaming,a=o?hr.TURN_STALL_MS:hr.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"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:o?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,hr.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=Kt(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."})))},hr.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Kt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},hr.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{if(this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),!this.hasEverConnected&&this.reconnectAttempts>=hr.HANDSHAKE_FAIL_HINT_AFTER){const r=this.config.secure?"wss":"ws";this.stateStore.update(s=>({...s,error:`Cannot connect to the wherever server: the connection is being rejected. This usually means a missing or wrong token, or a wrong host/port/scheme (currently ${r}://${this.config.host}:${this.config.port}). Check the auth token and connection settings.`}))}const e=!!Kt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},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":{const r=Kt(this.stateStore).sessionId;if(r&&e.sessionId&&e.sessionId!==r)break;this.clearLoadWatchdog();break}case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,serverVersion:e.serverVersion??null,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 o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":{const s=Array.isArray(e.steering)?[...e.steering]:[];this.stateStore.update(o=>({...o,pendingSteering:s,messages:this.withRestoredQueuedMessages(o.messages,s)}));break}case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(c=>c.role==="thinking"&&c.isStreaming);a&&(o=o.map(c=>c.id===a.id?{...c,isStreaming:!1}:c));const i=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(i)o=o.map(c=>c.id===i.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"){if(this.confirmDeliveredByContent(e.content))return Kt(this.stateStore);const S=o.find(C=>C.role==="user"&&C.restoredFromQueue&&C.content===e.content);if(S)return{...s,messages:o.map(C=>C.id===S.id?{...C,restoredFromQueue:void 0}:C)}}const c=e.role==="user"?Ws(e.content):null;if(c){const x=[...o].reverse().find(S=>S.role==="user"&&Ws(S.content)===c);if(x)return x.content!==e.content&&(o=o.map(S=>S.id===x.id?{...S,content:e.content}:S)),{...s,messages:o}}const v=[...o].reverse().find(x=>x.role==="user");e.role==="user"&&v&&v.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,pendingSteering:[],messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}: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,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(v=>v.isStreaming&&(v.role==="assistant"||v.role==="thinking")?{...v,isStreaming:!1}:v),a=Date.now(),i=!!e.forceCommand;if(i){const v=o.find(m=>m.role==="tool"&&m.optimistic&&m.isStreaming);if(v)return{...s,messages:o.map(m=>m.id===v.id?{...m,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:m)}}const c={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...i?{forceCommand:!0}:{}};return{...s,messages:[...o,c]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
1
+ import{b as wo,a as h,c as Mr,g as b,d as ss,e as F,s as V,f as Dr,t as Zn,h as so}from"../chunks/itgD7vGH.js";import{as as Qn,b3 as Js,am as cs,bf as O,aq as Ma,O as Kl,aT as Yl,ar as No,d as pi,an as Fo,au as Xl,n as Zl,a1 as Ql,u as Jl,t as ec,a2 as tc,W as nc,X as rc,H as sc,b4 as $a,C as La,z as Oa,aF as oo,a3 as Hr,ad as oc,aA as ac,a_ as ic,az as hi,be as bi,bg as lc,bh as es,aV as Qo,aR as Da,aQ as qr,aN as Vr,ag as pn,b7 as f,aj as t,a6 as cc,bi as j,$ as dc,bm as Sn,ai as Dn,a9 as Yt,aL as Ns,a$ as p,Y as d,aW as l,aJ as Ke,ba as G,aP as dr,bj as Ct,bk as uc,aU as fc}from"../chunks/CRRPBe07.js";import{i as w,s as vs,a as Ae,p as Wr}from"../chunks/Dtm96ZKi.js";import{a as pc,b as Z,r as at,c as vi,e as qn,i as vr,d as hc}from"../chunks/8eypMp_V.js";import{_ as bc,b as mr}from"../chunks/CAWbdcQM.js";import{v as Vs}from"../chunks/Dbf0zjW2.js";import{p as vc}from"../chunks/CtPQjCBP.js";function Pa(n,e,r=!1,s=!1,o=!1,a=!1){var i=n,c="";if(r){var v=n;Qn&&(i=Js(cs(v)))}O(()=>{var m=Kl;if(c===(c=e()??"")){Qn&&Ma();return}if(r&&!Qn){m.nodes=null,v.innerHTML=c,c!==""&&wo(cs(v),v.lastChild);return}if(m.nodes!==null&&(Yl(m.nodes.start,m.nodes.end),m.nodes=null),c!==""){if(Qn){No.data;for(var x=Ma(),S=x;x!==null&&(x.nodeType!==pi||x.data!=="");)S=x,x=Fo(x);if(x===null)throw Xl(),Zl;wo(No,S),i=Js(x);return}var C=s?Jl:o?ec:void 0,$=Ql(s?"svg":o?"math":"template",C);$.innerHTML=c;var D=s||o?$:$.content;if(wo(cs(D),D.lastChild),s||o)for(;cs(D);)i.before(cs(D));else i.before(D)}})}function gc(n,e){let r=null,s=Qn;var o;if(Qn){r=No;for(var a=cs(document.head);a!==null&&(a.nodeType!==pi||a.data!==n);)a=Fo(a);if(a===null)$a(!1);else{var i=Fo(a);a.remove(),Js(i)}}Qn||(o=document.head.appendChild(tc()));try{nc(()=>{var c=rc(()=>e(o));c.f|=sc})}finally{s&&($a(!0),Js(r))}}function gi(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=gi(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function mc(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=gi(n))&&(s&&(s+=" "),s+=e);return s}function xc(n){return typeof n=="object"?mc(n):n??""}function _c(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function yc(n,e){return n==null?null:String(n)}function ln(n,e,r,s,o,a){var i=n[La];if(Qn||i!==r||i===void 0){var c=_c(r);(!Qn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[La]=r}return a}function wc(n,e,r,s){var o=n[Oa];if(Qn||o!==e){var a=yc(e);(!Qn||a!==n.getAttribute("style"))&&(a==null?n.removeAttribute("style"):n.style.cssText=a),n[Oa]=e}return s}function Jo(n,e,r=!1){if(n.multiple){if(e==null)return;if(!ac(e))return ic();for(var s of n.options)s.selected=e.includes(Is(s));return}for(s of n.options){var o=Is(s);if(hi(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function mi(n){var e=new MutationObserver(()=>{Jo(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),bi(()=>{e.disconnect()})}function Ds(n,e,r=e){var s=new WeakSet,o=!0;oo(n,"change",a=>{var i=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(i),Is);else{var v=n.querySelector(i)??n.querySelector("option:not([disabled])");c=v&&Is(v)}r(c),n.__value=c,Hr!==null&&s.add(Hr)}),oc(()=>{var a=e();if(n===document.activeElement){var i=Hr;if(s.has(i))return}if(Jo(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=Is(c),r(a))}n.__value=a,o=!1}),mi(n)}function Is(n){return"__value"in n?n.__value:n.value}function gr(n,e,r=e){var s=new WeakSet;oo(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=So(n)?To(a):a,r(a),Hr!==null&&s.add(Hr),await lc(),a!==(a=e())){var i=n.selectionStart,c=n.selectionEnd,v=n.value.length;if(n.value=a??"",c!==null){var m=n.value.length;i===c&&c===v&&m>v?(n.selectionStart=m,n.selectionEnd=m):(n.selectionStart=i,n.selectionEnd=Math.min(c,m))}}}),(Qn&&n.defaultValue!==n.value||es(e)==null&&n.value)&&(r(So(n)?To(n.value):n.value),Hr!==null&&s.add(Hr)),Qo(()=>{var o=e();if(n===document.activeElement){var a=Hr;if(s.has(a))return}So(n)&&o===To(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const ko=new Set;function Gr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",i=n;let c=!1;if(e!==null)for(var v of e)i=i[v]??=[];i.push(r),oo(r,"change",()=>{var m=r.__value;a&&(m=Na(i,m,r.checked)),o(m)},()=>o(a?[]:null)),Qo(()=>{var m=s();if(Qn&&r.defaultChecked!==r.checked){c=!0;return}a?(m=m||[],r.checked=m.includes(r.__value)):r.checked=hi(r.__value,m)}),bi(()=>{var m=i.indexOf(r);m!==-1&&i.splice(m,1)}),ko.has(i)||(ko.add(i),Da(()=>{i.sort((m,x)=>m.compareDocumentPosition(x)===4?-1:1),ko.delete(i)})),Da(()=>{if(c){var m;if(a)m=Na(i,m,r.checked);else{var x=i.find(S=>S.checked);m=x?.__value}o(m)}})}function Gn(n,e,r=e){oo(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(Qn&&n.defaultChecked!==n.checked||es(e)==null)&&r(n.checked),Qo(()=>{var s=e();n.checked=!!s})}function Na(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function So(n){var e=n.type;return e==="number"||e==="range"}function To(n){return n===""?null:+n}const kc=!1,Sc=!0,Jb=Object.freeze(Object.defineProperty({__proto__:null,prerender:Sc,ssr:kc},Symbol.toStringTag,{value:"Module"})),Ao="Wherever",Tc="Create & maintain apps from wherever with a beautiful remote workspace.",Ro="https://localhost",Ac="#000000",Rc="black-translucent";function us(n,e){return pc(n)}var Cc=b('<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 Ec(n,e){qr(e,!0);const r=Ro.endsWith("/")?Ro.slice(0,-1):Ro,s=r+"/preview.png";let o=j(()=>e.home||!1),a=j(()=>({type:e.type||"website",title:e.title||Ao,description:e.description||Tc,image:e.image||s,url:`${r}${vc.url.pathname}`}));gc("13n5pl5",i=>{var c=Cc(),v=pn(c),m=f(v,2),x=f(m,2);{var S=nt=>{var Mt=Mr(),vt=pn(Mt);w(vt,Jt=>{}),h(nt,Mt)};w(x,nt=>{t(o)&&nt(S)})}var C=f(x,2),$=f(C,2),D=f($,2),q=f(D,2),xe=f(q,2),J=f(xe,4),he=f(J,2),be=f(he,2),_e=f(be,2),Se=f(_e,2),ue=f(Se,2),ve=f(ue,2),wt=f(ve,2),Vt=f(wt,2),Ye=f(Vt,4),It=f(Ye,4),ge=f(It,2),ft=f(ge,2);O((nt,Mt,vt,Jt)=>{Z(v,"content",t(a).title),Z(m,"content",t(a).description),Z(C,"content",t(a).type),Z($,"content",t(a).url),Z(D,"content",t(a).title),Z(q,"content",t(a).description),Z(xe,"content",t(a).image),Z(J,"content",t(a).url),Z(he,"content",t(a).title),Z(be,"content",t(a).description),Z(_e,"content",t(a).image),Z(Se,"href",nt),Z(ue,"href",Mt),Z(ve,"href",vt),Z(wt,"href",Jt),Z(Vt,"content",Ac),Z(Ye,"content",Ao),Z(It,"content",Rc),Z(ge,"content",Ao),Z(ft,"content",Vs)},[()=>us("/pwa/favicon.png"),()=>us("/pwa/favicon.ico"),()=>us("/pwa/apple-touch-icon.png"),()=>us("/pwa/manifest.webmanifest")]),cc(()=>{dc.title=t(a).title??""}),h(i,c)}),Vr()}let gs=null;function Ic(){if(typeof window>"u")return null;try{if(!gs){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;gs=new n}return gs.state==="suspended"&&gs.resume().catch(()=>{}),gs}catch{return null}}function Fa(n,e,r,s,o){const a=n.createOscillator(),i=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(o,r+c),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(n.destination),a.start(r),a.stop(r+s+.02)}const Ua=new Map;function Mc(n){if(typeof Audio>"u")return!1;try{let e=Ua.get(n);e||(e=new Audio(n),e.preload="auto",Ua.set(n,e));try{e.currentTime=0}catch{}const r=e.play();return r&&typeof r.catch=="function"&&r.catch(()=>{}),!0}catch{return!1}}function xi(n){if(n&&n.trim()&&Mc(n.trim()))return;const e=Ic();if(e)try{const r=e.currentTime;Fa(e,1046.5,r,.16,.12),Fa(e,1396.9,r+.13,.22,.12)}catch{}}function ea(n){if(!n)return null;const e=n.trimStart(),r=e.match(/^<skill\s+name="([^"]*)"[^>]*>/);if(r){const s=e.indexOf("</skill>");return s===-1?null:{skillName:r[1],args:e.slice(s+8).trim()}}if(e.startsWith("/skill:")){const s=e.slice(7),o=s.indexOf(" "),a=o===-1?s:s.slice(0,o);if(!a)return null;const i=o===-1?"":s.slice(o+1).trim();return{skillName:a,args:i}}return null}function Ws(n){const e=ea(n);return e?`skill:${e.skillName}\0${e.args}`:null}function Ks(){}function $c(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Lc(n,...e){if(n==null)return Ks;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Kt(n){let e;return Lc(n,r=>e=r)(),e}var is=[];function Oc(n,e=Ks){let r;const s=new Set;function o(c){if($c(n,c)&&(n=c,r)){const v=!is.length;for(const m of s)m[1](),is.push(m,n);if(v){for(let m=0;m<is.length;m+=2)is[m][0](is[m+1]);is.length=0}}}function a(c){o(c(n))}function i(c,v=Ks){const m=[c,v];return s.add(m),s.size===1&&(r=e(o)||Ks),c(n),()=>{s.delete(m),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:i}}const Co={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,serverVersion:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null,pendingSteering:[],skills:[]};class hr{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;hasEverConnected=!1;static HANDSHAKE_FAIL_HINT_AFTER=2;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;pendingLoadFile=null;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=Oc({...Co,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?{...$,connecting:!0,error:null}:{...Co,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",i=`${s}://${o}:${this.config.port}/ws${a}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update($=>({...$,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const $=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=$?new c(i,$):new c(i)}catch($){this.stateStore.update(D=>({...D,connecting:!1,error:`Failed to connect: ${$}`})),this.scheduleReconnect();return}const v=this.ws,m=()=>{if(this.ws!==v)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(J=>({...J,connected:!0,connecting:!1,error:null}));const $=Kt(this.stateStore),D=this.resumeSessionFile??$.activeSessionFile,q=this.resumeSessionFile!=null?this.resumeCwd:$.activeCwd??void 0,xe=this.resumeSessionFile!=null?this.resumeModel:$.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,D?(this.stateStore.update(J=>J.resyncing?J:{...J,resyncing:!0}),this.pendingLoadFile=D,this.send({type:"session_load",sessionFile:D,cwd:q,model:xe}),this.armLoadWatchdog()):this.stateStore.update(J=>J.resyncing?{...J,resyncing:!1}:J)},x=$=>{if(this.ws===v){this.lastInboundAt=Date.now();try{const D=typeof $.data=="string"?$.data:$.data.toString(),q=JSON.parse(D);this.handleMessage(q)}catch(D){console.error("Failed to parse WebSocket message:",D)}}},S=()=>{this.ws===v&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update($=>({...$,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:$.activeSessionFile?!0:$.resyncing})),this.scheduleReconnect())},C=$=>{this.ws===v&&this.stateStore.update(D=>({...D,error:D.error||"Connection error occurred"}))};typeof v.addEventListener=="function"?(v.addEventListener("open",m),v.addEventListener("message",x),v.addEventListener("close",S),v.addEventListener("error",C)):typeof v.on=="function"&&(v.on("open",m),v.on("message",$=>x({data:$})),v.on("close",S),v.on("error",C))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...Co,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=Kt(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=Kt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Kt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,hr.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=Kt(this.stateStore).isStreaming,a=o?hr.TURN_STALL_MS:hr.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"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:o?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,hr.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=Kt(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."})))},hr.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Kt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},hr.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{if(this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),!this.hasEverConnected&&this.reconnectAttempts>=hr.HANDSHAKE_FAIL_HINT_AFTER){const r=this.config.secure?"wss":"ws";this.stateStore.update(s=>({...s,error:`Cannot connect to the wherever server: the connection is being rejected. This usually means a missing or wrong token, or a wrong host/port/scheme (currently ${r}://${this.config.host}:${this.config.port}). Check the auth token and connection settings.`}))}const e=!!Kt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},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":{const r=Kt(this.stateStore).sessionId;if(r&&e.sessionId&&e.sessionId!==r)break;this.clearLoadWatchdog();break}case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,serverVersion:e.serverVersion??null,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 o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":{const s=Array.isArray(e.steering)?[...e.steering]:[];this.stateStore.update(o=>({...o,pendingSteering:s,messages:this.withRestoredQueuedMessages(o.messages,s)}));break}case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(c=>c.role==="thinking"&&c.isStreaming);a&&(o=o.map(c=>c.id===a.id?{...c,isStreaming:!1}:c));const i=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(i)o=o.map(c=>c.id===i.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"){if(this.confirmDeliveredByContent(e.content))return Kt(this.stateStore);const S=o.find(C=>C.role==="user"&&C.restoredFromQueue&&C.content===e.content);if(S)return{...s,messages:o.map(C=>C.id===S.id?{...C,restoredFromQueue:void 0}:C)}}const c=e.role==="user"?Ws(e.content):null;if(c){const x=[...o].reverse().find(S=>S.role==="user"&&Ws(S.content)===c);if(x)return x.content!==e.content&&(o=o.map(S=>S.id===x.id?{...S,content:e.content}:S)),{...s,messages:o}}const v=[...o].reverse().find(x=>x.role==="user");e.role==="user"&&v&&v.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,pendingSteering:[],messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}: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,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(v=>v.isStreaming&&(v.role==="assistant"||v.role==="thinking")?{...v,isStreaming:!1}:v),a=Date.now(),i=!!e.forceCommand;if(i){const v=o.find(m=>m.role==="tool"&&m.optimistic&&m.isStreaming);if(v)return{...s,messages:o.map(m=>m.id===v.id?{...m,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:m)}}const c={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...i?{forceCommand:!0}:{}};return{...s,messages:[...o,c]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
2
2
  `)?a.content+e.delta:`${a.content}
3
3
  ${e.delta}`,toolOutput:`${a.toolOutput}${e.delta}`}:a)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"",o=!!e.isError&&this.isAbortedToolResult(s),a=!!e.isError&&!o,i=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(c=>{const v=c.messages.find(x=>x.role==="tool"&&x.toolName===e.toolName&&x.isStreaming)??[...c.messages].reverse().find(x=>x.role==="tool"&&x.toolName===e.toolName&&!x.content.startsWith("Tool error:")),m=Date.now();if(v){const x=a?"Error: ":"";return{...c,messages:c.messages.map(S=>S.id===v.id?{...S,content:`${x}${S.content}
4
4
  ${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...i?{images:i}:{},endedAt:m}:S)}}else{const x=a?`Tool error: ${e.toolName}
@@ -92,4 +92,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
92
92
  ${Be}`}}if(R.startsWith("/")&&t(ve).length===0){const fe=R.toLowerCase();if(fe==="/new"||fe==="/reset"){if(t(Ye).cwd){Tr(t(Ye).cwd,t(Ye).model||void 0),p(q,"");return}}else if(fe==="/clear"){tl(),p(q,"");return}else if(fe==="/leave"||fe==="/exit"){br(),p(q,"");return}}const ye=jp({streaming:t(wt),connected:t(It),agentPending:t(ge).agentPending,readOnly:t(Vt),hasSession:!!t(Ye).sessionId});if(ye.action!=="send"){(ye.reason==="disconnected"||ye.reason==="agent-pending")&&Wo(z);return}Wo(z)&&(p(q,""),p(ve,[],!0),e.onSend?.())}function Je(R){if(t(_e)&&t(nt).length>0){if(R.key==="ArrowDown"){R.preventDefault(),p(Se,(t(Se)+1)%t(nt).length);return}if(R.key==="ArrowUp"){R.preventDefault(),p(Se,(t(Se)-1+t(nt).length)%t(nt).length);return}if(R.key==="Enter"||R.key==="Tab"){R.preventDefault();const z=t(nt)[t(Se)]??t(nt)[0];z&&Mt(z.name);return}if(R.key==="Escape"){R.preventDefault(),p(_e,!1);return}}R.key==="Enter"&&(t(xe)?R.shiftKey||(R.preventDefault(),Bt()):R.shiftKey&&(R.preventDefault(),Bt()))}var le={focusInput:en},Me=_h(),We=d(Me);{var je=R=>{var z=sh(),ye=d(z);{var oe=$e=>{var et=th();Ke(2),h($e,et)},fe=$e=>{var et=nh(),lt=f(pn(et),2),kt=d(lt,!0);l(lt),O(()=>V(kt,t(ge).error)),h($e,et)},Be=$e=>{var et=rh();Ke(2),h($e,et)};w(ye,$e=>{t(ge).connecting?$e(oe):t(ge).error?$e(fe,1):t(It)||$e(Be,2)})}l(z),h(R,z)};w(We,R=>{(!t(It)||t(ge).connecting||t(ge).error)&&R(je)})}var rt=f(We,2);{var A=R=>{var z=oh(),ye=d(z),oe=d(ye),fe=d(oe),Be=d(fe,!0);l(fe);var $e=f(fe,2),et=d($e);{var lt=Tt=>{var ct=Zn();O(()=>V(ct,e.placeholder??"Search the web...")),h(Tt,ct)},kt=Tt=>{var ct=Zn("Agent is working, tap to Steer...");h(Tt,ct)},st=Tt=>{var ct=Zn("Read-only mode");h(Tt,ct)},St=Tt=>{var ct=Zn("Select a session first...");h(Tt,ct)},tn=Tt=>{var ct=Zn("Tap to type a message...");h(Tt,ct)};w(et,Tt=>{S()?Tt(lt):t(wt)?Tt(kt,1):t(Vt)?Tt(st,2):t(Ye).sessionId?Tt(tn,-1):Tt(St,3)})}l($e),l(oe),Ke(2),l(ye),l(z),O(()=>V(Be,S()?"🔍":"💬")),F("click",ye,()=>{p(J,!1),setTimeout(()=>t(Qe)?.focus(),50)}),h(R,z)},W=R=>{var z=xh(),ye=pn(z);{var oe=T=>{var U=uh();qn(U,21,()=>t(ve),vr,(X,te,mt)=>{var Oe=dh(),me=d(Oe),Ue=d(me,!0);l(me);var Pt=f(me,2);{var bn=P=>{var ne=ah();h(P,ne)},Ge=P=>{var ne=lh(),Ce=d(ne),Le=d(Ce);l(Ce);var ee=f(Ce,2);{var pe=Te=>{var $t=ih();O(()=>Z($t,"href",t(te).url)),h(Te,$t)};w(ee,Te=>{t(te).url&&Te(pe)})}l(ne),O(()=>{Z(ne,"title",t(te).error),V(Le,`⚠️ ${t(te).error??""}`)}),h(P,ne)},E=P=>{var ne=ch();h(P,ne)};w(Pt,P=>{t(te).uploading?P(bn):t(te).error?P(Ge,1):P(E,-1)})}var L=f(Pt,2);l(Oe),O(()=>{Z(me,"title",t(te).name),V(Ue,t(te).name)}),F("click",L,()=>Rt(mt)),h(X,Oe)}),l(U),h(T,U)};w(ye,T=>{t(ve).length>0&&T(oe)})}var fe=f(ye,2);{var Be=T=>{var U=ph(),X=f(d(U),2);qn(X,21,$,vr,(te,mt)=>{var Oe=fh(),me=d(Oe,!0);l(Oe);var Ue={};O(()=>{V(me,t(mt).label),Ue!==(Ue=t(mt).value)&&(Oe.value=(Oe.__value=t(mt).value)??"")}),h(te,Oe)}),l(X),l(U),O(()=>X.disabled=t(vt)),Ds(X,D),h(T,U)};w(fe,T=>{S()&&$().length>0&&T(Be)})}var $e=f(fe,2),et=d($e),lt=d(et);{var kt=T=>{var U=vh();qn(U,23,()=>t(nt),X=>X.name,(X,te,mt)=>{var Oe=bh(),me=d(Oe),Ue=d(me),Pt=d(Ue);l(Ue);var bn=f(Ue,2);{var Ge=E=>{var L=hh(),P=d(L,!0);l(L),O(()=>V(P,t(te).description)),h(E,L)};w(bn,E=>{t(te).description&&E(Ge)})}l(me),l(Oe),O(()=>{Z(me,"aria-selected",t(mt)===t(Se)),ln(me,1,`flex w-full flex-col items-start gap-0.5 px-3 py-1.5 text-left text-sm ${t(mt)===t(Se)?"bg-brand-surface-3 text-brand-text":"text-brand-text-muted hover:bg-brand-surface-3/60"}`),V(Pt,`/${t(te).name??""}`)}),F("mousedown",me,E=>{E.preventDefault(),Mt(t(te).name)}),Dr("mouseenter",me,()=>p(Se,t(mt),!0)),h(X,Oe)}),l(U),h(T,U)};w(lt,T=>{t(_e)&&t(nt).length>0&&T(kt)})}var st=f(lt,2);fc(st),Z(st,"rows",1),mr(st,T=>p(Qe,T),()=>t(Qe)),l(et);var St=f(et,2),tn=d(St);{var Tt=T=>{var U=gh(),X=pn(U),te=f(X,2);mr(te,mt=>p(ue,mt),()=>t(ue)),O(()=>X.disabled=t(vt)),F("click",X,()=>{ji(),t(ue)?.click()}),F("change",te,Ut),h(T,U)};w(tn,T=>{x()&&!S()&&T(Tt)})}var ct=f(tn,2),kn=d(ct);mr(eh(kn,{get disabled(){return t(vt)},onSend:Bt,get text(){return t(q)},set text(T){p(q,T,!0)},get activeEngine(){return t(he)},set activeEngine(T){p(he,T,!0)}}),T=>p(be,T,!0),()=>t(be)),l(ct);var nn=f(ct,2),En=d(nn);{var gn=T=>{var U=Zn();O(()=>V(U,e.submitLabel??"Search")),h(T,U)},rn=T=>{var U=Zn("Steer");h(T,U)},cn=T=>{var U=Zn("Send");h(T,U)};w(En,T=>{S()?T(gn):t(wt)?T(rn,1):T(cn,-1)})}l(nn),l(St),l($e);var An=f($e,2),Jn=d(An),Bn=d(Jn);at(Bn),Ke(2),l(Jn);var Fn=f(Jn,2),ur=d(Fn),er=f(ur,2);{var M=T=>{var U=mh();h(T,U)};w(er,T=>{t(xe)||T(M)})}l(Fn),l(An),O(()=>{st.disabled=t(vt),Z(st,"placeholder",S()?e.placeholder??"Search the web...":t(It)?t(wt)?"Agent is working, Steer to interrupt...":t(Vt)?"Read-only mode":t(Ye).sessionId?"Type a message...":"Select a session first...":t(ge).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),nn.disabled=!t(Tn),Z(nn,"title",!S()&&t(wt)?"Steer the agent now (injected at the next step, before the next model call)":void 0),vi(Bn,t(xe))}),Dr("submit",$e,T=>{T.preventDefault(),Bt()}),F("keydown",st,Je),gr(st,()=>t(q),T=>p(q,T)),F("change",Bn,hn),F("click",ur,()=>p(J,!0)),h(R,z)};w(rt,R=>{t(J)?R(A):R(W,-1)})}l(Me),h(n,Me);var ce=Vr(le);return m(),ce}ss(["click","mousedown","keydown","change"]);var wh=b('<button type="button" class="block w-full px-2.5 py-1 text-left text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"> </button>'),kh=b('<div class="absolute right-0 left-0 z-50 mt-1 max-h-40 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl"></div>'),Sh=b('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Th=b('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),Ah=b("<option> </option>"),Rh=b('<select id="sidebar-model" class="w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Ch=b('<input id="sidebar-model" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/>'),Eh=b('<div class="flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-visibility" class="border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-visibility" class="border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),Ih=b('<div class="space-y-1 py-0.5"><div class="flex items-center gap-1.5"><input id="sidebar-create-remote" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="sidebar-create-remote" class="cursor-pointer text-xs text-brand-text select-none"> </label></div> <!></div>'),Mh=b('<div class="flex items-center gap-1.5 py-0.5"><input id="sidebar-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="sidebar-git-init" class="cursor-pointer text-xs text-brand-text select-none">Initialize Git repository</label></div>'),$h=b('<form class="space-y-2.5 border-t border-brand-border/30 bg-brand-surface/30 p-3"><div><label class="mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase" for="sidebar-folder">Folder Path</label> <div class="relative"><input id="sidebar-folder" type="text" autocomplete="off" spellcheck="false" placeholder="e.g. ~/projects/my-new-app"/> <!></div> <!></div> <div><label class="mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase" for="sidebar-model">Model</label> <!></div> <!> <!> <button type="submit" class="w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50">Create Session</button></form>'),Lh=b('<div class="border-b border-brand-border/50 bg-brand-surface/10"><button class="flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/30"><span> </span></button> <!></div>'),Oh=b('<div class="p-4 text-center text-brand-text-muted"><div class="inline-block h-4 w-4 animate-spin rounded-full border-2 border-brand-text-muted border-t-transparent"></div> <span class="ml-2 text-sm">Loading sessions...</span></div>'),Dh=b('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Ph=b('<div class="flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5"><button class="px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none" title="Confirm Delete All">Delete All?</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),Nh=b('<button class="rounded px-2 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-rose-400 focus:outline-none" title="Delete all sessions in this folder">Delete All</button>'),Fh=b('<div class="mb-1.5 flex items-center justify-between"><button class="rounded px-2 py-1 text-left text-xs text-brand-blue transition-colors hover:bg-brand-surface-3/50 hover:opacity-90">+ New Session Here</button> <div class="flex-shrink-0"><!></div></div>'),Uh=b('<span class="flex-shrink-0 text-brand-text-muted" title="Forked from the session above" aria-label="Forked session">↳</span>'),zh=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),Bh=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),Hh=b('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),Wh=b('<div class="flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5"><button class="px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none" title="Confirm Delete">❓</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),jh=b('<button class="p-1 text-xs text-brand-text-muted transition-opacity hover:text-rose-400 focus:outline-none md:opacity-0 md:group-hover:opacity-100" title="Delete session">✕</button>'),Gh=b('<div class="flex-shrink-0"><!></div>'),qh=b('<div><!> <a class="flex min-w-0 flex-1 items-center gap-2 text-left no-underline"><!> <div class="min-w-0 flex-1"><div class="truncate text-xs text-brand-text"> </div> <div class="text-xs text-brand-text-muted"> </div></div> <!></a> <!></div>'),Vh=b('<div class="px-3 pb-2"><!> <!></div>'),Kh=b('<div class="border-b border-brand-border/50"><button class="flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-brand-surface-3/50"><span>▶</span> <div class="min-w-0 flex-1"><div class="truncate text-sm font-medium text-brand-text"> </div> <div class="truncate text-[10px] text-brand-text-muted"> </div></div> <span class="text-xs text-brand-text-muted"> </span></button> <!></div>'),Yh=b("<option> </option>"),Xh=b('<select id="model-select" class="w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text"></select>'),Zh=b('<input id="model-select" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted"/>'),Qh=b('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60" role="presentation"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-6" role="dialog" tabindex="-1"><h3 class="mb-4 text-sm font-bold text-brand-text">New Session</h3> <div class="mb-4"><span class="mb-1 block text-xs text-brand-text-muted">Folder</span> <div class="truncate rounded bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text"> </div></div> <div class="mb-4"><label class="mb-1 block text-xs text-brand-text-muted" for="model-select">Model</label> <!></div> <div class="flex justify-end gap-2"><button class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Create</button></div></div></div>'),Jh=b('<div class="absolute right-0 bottom-0 left-0 flex items-center justify-between border-t border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-rose-400"><span class="truncate"> </span> <button class="ml-2 flex-shrink-0 text-rose-300 hover:text-rose-200">✕</button></div>'),eb=b('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),tb=b('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),nb=b('<div class="flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),rb=b('<div class="space-y-1"><div class="flex items-center gap-1.5"><input id="sidebar-modal-create-remote" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> <label for="sidebar-modal-create-remote" class="cursor-pointer text-xs text-brand-text select-none"> </label></div> <!></div>'),sb=b('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4" role="dialog" aria-modal="true"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-5 text-brand-text"><h3 class="mb-2 text-sm font-bold text-brand-text">Folder Already Exists</h3> <p class="mb-3 text-xs text-brand-text-muted">The folder <span class="font-mono text-[11px] break-all text-brand-text"> </span> already exists. Do you want to initialize a Git repository in it?</p> <div class="mb-4 flex flex-col gap-3"><div class="flex items-center gap-1.5"><input id="sidebar-modal-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50"/> <label for="sidebar-modal-git-init" class="cursor-pointer text-xs text-brand-text select-none disabled:opacity-50">Initialize Git repository <!></label></div> <!></div> <div class="flex justify-end gap-2"><button type="button" class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button type="button" class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Confirm & Create</button></div></div></div>'),ob=b('<div class="flex h-full flex-col"><div class="border-b border-brand-border/50 p-2"><div class="flex gap-1.5"><input type="text" placeholder="Filter sessions..." class="min-w-0 flex-1 rounded border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/> <button type="button" class="flex shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-1.5 py-1.5 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Refresh session list"><span>↻</span></button></div></div> <div class="flex-1 overflow-y-auto"><!> <!></div></div> <!> <!> <!>',1);function fi(n,e){qr(e,!0);const r=()=>Ae(As,"$readOnlySessionFolders",S),s=()=>Ae(ps,"$sessionFolders",S),o=()=>Ae(zs,"$activeSessionInfo",S),a=()=>Ae(Us,"$isConnected",S),i=()=>Ae(bo,"$isLoadingSession",S),c=()=>Ae(ba,"$isResyncing",S),v=()=>Ae(hs,"$availableModels",S),m=()=>Ae(ta,"$gitInitDefaultStore",S),x=()=>Ae(ha,"$sessionError",S),[S,C]=vs(),$=[];let D=Wr(e,"readOnly",3,!1),q=j(()=>D()?r().folders:s().folders),xe=j(()=>D()?r().loading:s().loading);function J(){D()?_i():Ms()}let he=j(()=>o().sessionFile),be=j(a),_e=j(i),Se=j(c),ue=j(()=>v().models),ve=dr({}),wt=G(dr({})),Vt=G(null),Ye=G(null),It=G(""),ge=G(dr([]));Ct(()=>{t(be)&&(J(),D()||(Hc(),jc()))});function ft(M,T,U){if(!U)return!0;const X=U.toLowerCase();return(M.name||"").toLowerCase().includes(X)||M.firstMessage.toLowerCase().includes(X)||T.toLowerCase().includes(X)}Ct(()=>{const M=t(It),T=t(q);M?p(ge,T.map(U=>({...U,sessions:U.sessions.filter(X=>ft(X,U.name,M))})).filter(U=>U.sessions.length>0),!0):(p(ge,T,!0),p(wt,{},!0))});function nt(M){return t(It)?t(wt)[M]!==void 0?t(wt)[M]:!0:!!ve[M]}function Mt(M){t(It)?t(wt)[M]=!nt(M):ve[M]=!nt(M)}async function vt(M){try{t(he)===M&&(typeof window<"u"&&(window.location.hash=""),br()),await Go(M),t(Vt)===M&&p(Vt,null),Ms()}catch(T){console.error("Failed to delete session:",T)}}async function Jt(M){try{const T=M.sessions.map(U=>U.path);t(he)&&T.includes(t(he))&&(typeof window<"u"&&(window.location.hash=""),br()),await Promise.all(M.sessions.map(U=>Go(U.path))),t(Ye)===M.path&&p(Ye,null),Ms()}catch(T){console.error("Failed to delete all sessions of folder:",T)}}function Tn(M){const T=new Map;for(const me of M)T.set(me.path,me);const U=new Map,X=[];for(const me of M){const Ue=me.parentSessionPath;Ue&&T.has(Ue)&&Ue!==me.path?(U.has(Ue)||U.set(Ue,[]),U.get(Ue).push(me)):X.push(me)}const te=[],mt=new Set,Oe=(me,Ue)=>{if(!mt.has(me.path)){mt.add(me.path),te.push({session:me,depth:Ue});for(const Pt of U.get(me.path)??[])Oe(Pt,Ue+1)}};for(const me of X)Oe(me,0);for(const me of M)mt.has(me.path)||te.push({session:me,depth:0});return te}function Qe(M){t(he)===M&&!t(_e)&&!t(Se)||(ns(),po(M))}let it=G(!1),K=G(""),Pe=G(dr([])),gt=G(!1),en=G(null),Ft=G(null),hn="",Ut=G(""),Rt=G(!1),Bt=G(null),Je=G(!0),le=G("private"),Me=G(!1),We=j(m);Ct(()=>{t(Bt)===null&&p(Rt,t(We),!0)});let je=G(dr({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),rt=j(()=>t(je).exists!==!0&&t(je).matchingRule&&t(Je)),A=null;async function W(M,T=!1){if(A&&clearTimeout(A),M===hn&&!T)return;if(hn=M,!M.trim()){p(je,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const X=async()=>{const te=await eo("");p(Pe,te||[],!0)};T?await X():A=setTimeout(X,300);return}const U=async()=>{const[X,te]=await Promise.all([Si(M),eo(M)]);p(Pe,te||[],!0),X?(p(je,{exists:X.exists,isGit:X.isGit,resolvedPath:X.resolvedPath,matchingRule:X.matchingRule||null},!0),X.exists||(p(Rt,t(Bt)!==null?t(Bt):t(We),!0),p(Je,!0),X.matchingRule&&p(le,X.matchingRule.visibility,!0))):p(je,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};T?await U():A=setTimeout(U,300)}Ct(()=>{const M=t(K);W(M,!1)}),Ct(()=>{if(t(ue).length>0&&!t(Ut)){const M=t(ue).find(T=>T.isDefault);M?p(Ut,`${M.provider}:${M.modelId}`):p(Ut,`${t(ue)[0].provider}:${t(ue)[0].modelId}`)}});function ce(){if(t(K).trim())if(t(je).exists===!0)p(Rt,!1),p(Je,!1),t(je).matchingRule&&p(le,t(je).matchingRule.visibility,!0),p(Me,!0);else{ns();const M=t(K).trim(),T=t(Ut)||void 0,U=t(Rt),X=t(je).matchingRule?t(Je):void 0,te=t(je).matchingRule?t(le):void 0;p(K,""),p(it,!1),t(he)?(br(),setTimeout(()=>{Tr(M,T,U,X,te)},100)):Tr(M,T,U,X,te)}}function R(){p(Me,!1),ns();const M=t(K).trim(),T=t(Ut)||void 0,U=t(Rt),X=t(je).matchingRule?t(Je):void 0,te=t(je).matchingRule?t(le):void 0;p(K,""),p(it,!1),t(he)?(br(),setTimeout(()=>{Tr(M,T,U,X,te)},100)):Tr(M,T,U,X,te)}let z=G(dr({open:!1,folderPath:"",selected:""}));function ye(M){const T=t(ue).find(U=>U.isDefault);p(z,{open:!0,folderPath:M,selected:T?`${T.provider}:${T.modelId}`:""},!0)}function oe(){t(z).open=!1}function fe(){if(!t(z).open)return;ns();const M=t(z).folderPath,T=t(z).selected||void 0;oe(),t(he)?(br(),setTimeout(()=>{Tr(M,T)},100)):Tr(M,T)}function Be(M){const T=Date.now()-new Date(M).getTime(),U=Math.floor(T/6e4);if(U<1)return"just now";if(U<60)return`${U}m ago`;const X=Math.floor(U/60);return X<24?`${X}h ago`:`${Math.floor(X/24)}d ago`}function $e(M,T=40){return M.length>T?M.slice(0,T)+"...":M}var et=ob(),lt=pn(et),kt=d(lt),st=d(kt),St=d(st);at(St);var tn=f(St,2),Tt=d(tn);l(tn),l(st),l(kt);var ct=f(kt,2),kn=d(ct);{var nn=M=>{var T=Lh(),U=d(T),X=d(U),te=d(X,!0);l(X),l(U);var mt=f(U,2);{var Oe=me=>{var Ue=$h(),Pt=d(Ue),bn=f(d(Pt),2),Ge=d(bn);at(Ge),mr(Ge,Y=>p(en,Y),()=>t(en));var E=f(Ge,2);{var L=Y=>{var ae=kh();qn(ae,21,()=>t(Pe),vr,(ke,qe)=>{var Xe=wh(),ot=d(Xe,!0);l(Xe),O(()=>V(ot,t(qe))),F("click",Xe,()=>{p(K,t(qe),!0),W(t(qe),!0),t(en)?.focus()}),h(ke,Xe)}),l(ae),h(Y,ae)};w(E,Y=>{t(gt)&&t(Pe).length>0&&Y(L)})}l(bn),mr(bn,Y=>p(Ft,Y),()=>t(Ft));var P=f(bn,2);{var ne=Y=>{var ae=Th(),ke=f(d(ae));{var qe=Xe=>{var ot=Sh();h(Xe,ot)};w(ke,Xe=>{t(je).isGit&&Xe(qe)})}l(ae),h(Y,ae)};w(P,Y=>{t(je).exists===!0&&Y(ne)})}l(Pt);var Ce=f(Pt,2),Le=f(d(Ce),2);{var ee=Y=>{var ae=Rh();qn(ae,21,()=>t(ue),vr,(ke,qe)=>{var Xe=Ah(),ot=d(Xe);l(Xe);var Nt={};O(()=>{V(ot,`${t(qe).label??""}${t(qe).isDefault?" (default)":""}`),Nt!==(Nt=`${t(qe).provider}:${t(qe).modelId}`)&&(Xe.value=Xe.__value=`${t(qe).provider}:${t(qe).modelId}`)}),h(ke,Xe)}),l(ae),Ds(ae,()=>t(Ut),ke=>p(Ut,ke)),h(Y,ae)},pe=Y=>{var ae=Ch();at(ae),gr(ae,()=>t(Ut),ke=>p(Ut,ke)),h(Y,ae)};w(Le,Y=>{t(ue).length>0?Y(ee):Y(pe,-1)})}l(Ce);var Te=f(Ce,2);{var $t=Y=>{var ae=Ih(),ke=d(ae),qe=d(ke);at(qe);var Xe=f(qe,2),ot=d(Xe);l(Xe),l(ke);var Nt=f(ke,2);{var Zt=Mn=>{var mn=Eh(),Ne=f(d(mn),2),pt=d(Ne);at(pt),pt.value=pt.__value="private",Ke(),l(Ne);var Gt=f(Ne,2),Kn=d(Gt);at(Kn),Kn.value=Kn.__value="public",Ke(),l(Gt),l(mn),Gr($,[],pt,()=>t(le),tr=>p(le,tr)),Gr($,[],Kn,()=>t(le),tr=>p(le,tr)),h(Mn,mn)};w(Nt,Mn=>{t(Je)&&Mn(Zt)})}l(ae),O(()=>V(ot,`Create remote ${t(je).matchingRule.provider??""} repository`)),Gn(qe,()=>t(Je),Mn=>p(Je,Mn)),h(Y,ae)};w(Te,Y=>{t(je).exists!==!0&&t(je).matchingRule&&Y($t)})}var In=f(Te,2);{var sn=Y=>{var ae=Mh(),ke=d(ae);at(ke),Ke(2),l(ae),F("change",ke,qe=>{p(Bt,qe.currentTarget.checked,!0)}),Gn(ke,()=>t(Rt),qe=>p(Rt,qe)),h(Y,ae)};w(In,Y=>{t(je).exists!==!0&&(!t(je).matchingRule||!t(Je))&&Y(sn)})}var dn=f(In,2);l(Ue),O(Y=>{ln(Ge,1,`w-full rounded border px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none ${t(rt)?"border-emerald-500/80 bg-emerald-500/10 focus:border-emerald-400 focus:ring-1 focus:ring-emerald-400/30":"border-brand-border bg-brand-dark/60 focus:border-brand-blue"}`),dn.disabled=Y},[()=>!t(K).trim()]),Dr("submit",Ue,Y=>{Y.preventDefault(),ce()}),Dr("focus",Ge,()=>{p(gt,!0),W(t(K),!0)}),Dr("blur",Ge,Y=>{t(Ft)&&t(Ft).contains(Y.relatedTarget)||p(gt,!1)}),F("keydown",Ge,Y=>{Y.key==="Escape"&&p(gt,!1)}),gr(Ge,()=>t(K),Y=>p(K,Y)),h(me,Ue)};w(mt,me=>{t(it)&&me(Oe)})}l(T),O(()=>V(te,t(it)?"▼ Close Create Session":"✚ Create New Session")),F("click",U,()=>p(it,!t(it))),h(M,T)};w(kn,M=>{D()||M(nn)})}var En=f(kn,2);{var gn=M=>{var T=Oh();h(M,T)},rn=M=>{var T=Dh(),U=d(T,!0);l(T),O(()=>V(U,t(It)?"No sessions match your filter":"No sessions found")),h(M,T)},cn=M=>{var T=Mr(),U=pn(T);qn(U,17,()=>t(ge),X=>X.path,(X,te)=>{var mt=Kh(),Oe=d(mt),me=d(Oe),Ue=f(me,2),Pt=d(Ue),bn=d(Pt,!0);l(Pt);var Ge=f(Pt,2),E=d(Ge,!0);l(Ge),l(Ue);var L=f(Ue,2),P=d(L,!0);l(L),l(Oe);var ne=f(Oe,2);{var Ce=ee=>{var pe=Vh(),Te=d(pe);{var $t=sn=>{var dn=Fh(),Y=d(dn),ae=f(Y,2),ke=d(ae);{var qe=ot=>{var Nt=Ph(),Zt=d(Nt),Mn=f(Zt,2);l(Nt),F("click",Zt,mn=>{mn.stopPropagation(),Jt(t(te))}),F("click",Mn,mn=>{mn.stopPropagation(),p(Ye,null)}),h(ot,Nt)},Xe=ot=>{var Nt=Nh();F("click",Nt,Zt=>{Zt.stopPropagation(),p(Ye,t(te).path,!0)}),h(ot,Nt)};w(ke,ot=>{t(Ye)===t(te).path?ot(qe):ot(Xe,-1)})}l(ae),l(dn),F("click",Y,()=>ye(t(te).path)),h(sn,dn)};w(Te,sn=>{D()||sn($t)})}var In=f(Te,2);qn(In,17,()=>Tn(t(te).sessions),({session:sn,depth:dn})=>sn.path,(sn,dn)=>{let Y=()=>t(dn).session,ae=()=>t(dn).depth;var ke=qh(),qe=d(ke);{var Xe=Ve=>{var Lt=Uh();h(Ve,Lt)};w(qe,Ve=>{ae()>0&&Ve(Xe)})}var ot=f(qe,2),Nt=d(ot);{var Zt=Ve=>{var Lt=zh();h(Ve,Lt)},Mn=Ve=>{var Lt=Bh();h(Ve,Lt)};w(Nt,Ve=>{Y().isActive?Ve(Zt):Ve(Mn,-1)})}var mn=f(Nt,2),Ne=d(mn),pt=d(Ne,!0);l(Ne);var Gt=f(Ne,2),Kn=d(Gt);l(Gt),l(mn);var tr=f(mn,2);{var Nr=Ve=>{var Lt=Hh(),nr=d(Lt,!0);l(Lt),O(()=>V(nr,Y().clientCount)),h(Ve,Lt)};w(tr,Ve=>{Y().clientCount>0&&Ve(Nr)})}l(ot);var Yn=f(ot,2);{var Ar=Ve=>{var Lt=Gh(),nr=d(Lt);{var Fr=rr=>{var N=Wh(),u=d(N),_=f(u,2);l(N),F("click",u,B=>{B.stopPropagation(),vt(Y().path)}),F("click",_,B=>{B.stopPropagation(),p(Vt,null)}),h(rr,N)},Ur=rr=>{var N=jh();F("click",N,u=>{u.stopPropagation(),p(Vt,Y().path,!0)}),h(rr,N)};w(nr,rr=>{t(Vt)===Y().path?rr(Fr):rr(Ur,-1)})}l(Lt),h(Ve,Lt)};w(Yn,Ve=>{D()||Ve(Ar)})}l(ke),O((Ve,Lt,nr)=>{wc(ke,ae()>0?`margin-left: ${ae()*.85}rem`:""),ln(ke,1,`group flex w-full items-center gap-2 rounded px-2 py-1.5 text-left transition-colors hover:bg-brand-surface-3/30 ${ae()>0?"border-l border-brand-border/60 pl-2":""} ${t(he)===Y().path?"bg-brand-surface-3":""}`),Z(ot,"href",`#${Ve??""}`),V(pt,Lt),V(Kn,`${nr??""} · ${Y().messageCount??""}
93
93
  msgs`)},[()=>encodeURIComponent(Y().id),()=>Y().name||$e(Y().firstMessage)||"Empty session",()=>Be(Y().modified)]),F("click",ot,Ve=>{Ve.button===0&&!Ve.ctrlKey&&!Ve.metaKey&&!Ve.altKey&&!Ve.shiftKey&&(Ve.preventDefault(),Qe(Y().path))}),h(sn,ke)}),l(pe),h(ee,pe)},Le=j(()=>nt(t(te).path));w(ne,ee=>{t(Le)&&ee(Ce)})}l(mt),O(ee=>{ln(me,1,`text-xs text-brand-text-muted transition-transform ${ee??""}`),V(bn,t(te).name),V(E,t(te).path),V(P,t(te).sessions.length)},[()=>nt(t(te).path)?"rotate-90":""]),F("click",Oe,()=>Mt(t(te).path)),h(X,mt)}),h(M,T)};w(En,M=>{t(xe)&&t(ge).length===0?M(gn):t(ge).length===0?M(rn,1):M(cn,-1)})}l(ct),l(lt);var An=f(lt,2);{var Jn=M=>{var T=Qh(),U=d(T),X=f(d(U),2),te=f(d(X),2),mt=d(te,!0);l(te),l(X);var Oe=f(X,2),me=f(d(Oe),2);{var Ue=L=>{var P=Xh();qn(P,21,()=>t(ue),vr,(ne,Ce)=>{var Le=Yh(),ee=d(Le);l(Le);var pe={};O(()=>{V(ee,`${t(Ce).label??""}${t(Ce).isDefault?" (default)":""}`),pe!==(pe=`${t(Ce).provider}:${t(Ce).modelId}`)&&(Le.value=Le.__value=`${t(Ce).provider}:${t(Ce).modelId}`)}),h(ne,Le)}),l(P),Ds(P,()=>t(z).selected,ne=>t(z).selected=ne),h(L,P)},Pt=L=>{var P=Zh();at(P),gr(P,()=>t(z).selected,ne=>t(z).selected=ne),h(L,P)};w(me,L=>{t(ue).length>0?L(Ue):L(Pt,-1)})}l(Oe);var bn=f(Oe,2),Ge=d(bn),E=f(Ge,2);l(bn),l(U),l(T),O(()=>V(mt,t(z).folderPath)),F("click",T,oe),F("click",U,L=>L.stopPropagation()),F("click",Ge,oe),F("click",E,fe),h(M,T)};w(An,M=>{t(z).open&&M(Jn)})}var Bn=f(An,2);{var Fn=M=>{var T=Jh(),U=d(T),X=d(U,!0);l(U);var te=f(U,2);l(T),O(()=>V(X,x())),F("click",te,()=>ns()),h(M,T)};w(Bn,M=>{x()&&M(Fn)})}var ur=f(Bn,2);{var er=M=>{var T=sb(),U=d(T),X=f(d(U),2),te=f(d(X)),mt=d(te,!0);l(te),Ke(),l(X);var Oe=f(X,2),me=d(Oe),Ue=d(me);at(Ue);var Pt=f(Ue,2),bn=f(d(Pt));{var Ge=ee=>{var pe=eb();h(ee,pe)},E=ee=>{var pe=tb();h(ee,pe)};w(bn,ee=>{t(je).isGit?ee(Ge):ee(E,-1)})}l(Pt),l(me);var L=f(me,2);{var P=ee=>{var pe=rb(),Te=d(pe),$t=d(Te);at($t);var In=f($t,2),sn=d(In);l(In),l(Te);var dn=f(Te,2);{var Y=ae=>{var ke=nb(),qe=f(d(ke),2),Xe=d(qe);at(Xe),Xe.value=Xe.__value="private",Ke(),l(qe);var ot=f(qe,2),Nt=d(ot);at(Nt),Nt.value=Nt.__value="public",Ke(),l(ot),l(ke),Gr($,[],Xe,()=>t(le),Zt=>p(le,Zt)),Gr($,[],Nt,()=>t(le),Zt=>p(le,Zt)),h(ae,ke)};w(dn,ae=>{t(Je)&&ae(Y)})}l(pe),O(()=>V(sn,`Create remote ${t(je).matchingRule.provider??""} repository`)),Gn($t,()=>t(Je),ae=>p(Je,ae)),h(ee,pe)};w(L,ee=>{t(je).matchingRule&&ee(P)})}l(Oe);var ne=f(Oe,2),Ce=d(ne),Le=f(Ce,2);l(ne),l(U),l(T),O(()=>{V(mt,t(K)),Ue.disabled=t(je).isGit}),Gn(Ue,()=>t(Rt),ee=>p(Rt,ee)),F("click",Ce,()=>p(Me,!1)),F("click",Le,R),h(M,T)};w(ur,M=>{t(Me)&&M(er)})}O(()=>{hc(St,t(It)),ln(Tt,1,xc(t(xe)?"animate-spin":""))}),F("input",St,M=>p(It,M.currentTarget.value,!0)),F("click",tn,()=>J()),h(n,et),Vr(),C()}ss(["input","click","keydown","change"]);var ab=b(`<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">Sudo password</h2> <p class="mb-3 text-sm text-brand-text-muted">This command needs your sudo password to run. It is used once and never
94
94
  stored.</p> <pre class="mb-4 overflow-x-auto rounded-lg bg-brand-surface-3 px-3 py-2 font-mono text-xs text-brand-text"> </pre> <input type="password" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" placeholder="Password" class="mb-4 w-full rounded-lg border border-brand-border bg-brand-surface-3 px-3 py-2.5 text-sm text-brand-text outline-none focus:border-brand-blue"/> <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">Cancel</button> <button class="flex-1 rounded-lg bg-brand-blue px-4 py-2.5 text-sm text-brand-text transition-colors hover:opacity-90">Run</button></div></div></div>`);function ib(n,e){qr(e,!0);const r=()=>Ae(fl,"$sudoPrompt",s),[s,o]=vs();let a=j(r),i=G(""),c=G(null),v=G(null);Ct(()=>{const q=t(a)?.promptId??null;q!==t(v)&&(p(v,q,!0),p(i,""),q&&queueMicrotask(()=>t(c)?.focus()))});function m(){t(a)&&(sl(t(i)),p(i,""))}function x(){ol(),p(i,"")}function S(q){q.key==="Enter"?(q.preventDefault(),m()):q.key==="Escape"&&(q.preventDefault(),x())}var C=Mr(),$=pn(C);{var D=q=>{var xe=ab(),J=d(xe),he=f(d(J),4),be=d(he,!0);l(he);var _e=f(he,2);at(_e),mr(_e,wt=>p(c,wt),()=>t(c));var Se=f(_e,2),ue=d(Se),ve=f(ue,2);l(Se),l(J),l(xe),O(()=>V(be,t(a).command)),F("keydown",_e,S),gr(_e,()=>t(i),wt=>p(i,wt)),F("click",ue,x),F("click",ve,m),h(q,xe)};w($,q=>{t(a)&&q(D)})}h(n,C),Vr(),o()}ss(["keydown","click"]);function lb(n){return n.loading||n.resyncing||n.hasSessionHash}function cb(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!lb(n)}var db=b('<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>'),ub=b('<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),fb=b('<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),pb=b('<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>'),hb=b('<span class="text-brand-text-muted/70"> </span>'),bb=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),vb=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),gb=b('<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>'),mb=b('<div class="mt-2 text-xs text-rose-400"> </div>'),xb=b('<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>'),_b=b('<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>'),yb=b('<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"> <!></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),wb=b('<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>'),kb=b('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Sb=b('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Tb=b('<span class="text-sm text-brand-text-muted">Not connected</span>'),Ab=b('<div class="flex min-w-0 items-center gap-2"><!></div>'),Rb=b('<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>'),Cb=b("<option> </option>"),Eb=b('<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>'),Ib=b('<span class="truncate text-brand-text-muted"> </span>'),Mb=b('<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>'),$b=b('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Lb=b('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Ob=b('<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>'),Db=b('<div><span class="min-w-0 flex-1 break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss notice" class="flex-shrink-0 opacity-80 hover:opacity-100">X</button></div>'),Pb=b('<button class="flex-shrink-0 rounded-md border border-yellow-500/40 bg-yellow-500/20 px-3 py-1 text-xs font-medium text-yellow-300 transition-colors hover:bg-yellow-500/30">Continue anyway</button>'),Nb=b('<div class="flex items-center justify-between gap-3 border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-sm text-yellow-400"><span class="min-w-0 flex-1 break-words">⚠️ Another client is active in this folder. <!></span> <!></div>'),Fb=b('<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>'),Ub=b('<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>'),zb=b('<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>'),Bb=b('<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>'),Hb=b('<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>Preparing the session agent...</span></div>'),Wb=b("<!> <!>",1),jb=b('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),Gb=b('<!> <!> <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 ev(n,e){qr(e,!0);const r=()=>Ae(Us,"$isConnected",J),s=()=>Ae(ba,"$isResyncing",J),o=()=>Ae(hl,"$isAgentPending",J),a=()=>Ae(bo,"$isLoadingSession",J),i=()=>Ae(cl,"$isInterrupted",J),c=()=>Ae(ha,"$sessionError",J),v=()=>Ae(ul,"$sessionNotice",J),m=()=>Ae(ll,"$folderConflict",J),x=()=>Ae(ho,"$isReadOnly",J),S=()=>Ae(zs,"$activeSessionInfo",J),C=()=>Ae(Xt,"$piState",J),$=()=>Ae(hs,"$availableModels",J),D=()=>Ae(pl,"$isCreatingSession",J),q=()=>Ae(na,"$searchFolderStore",J),xe=()=>Ae(ki,"$searchDefaultModelStore",J),[J,he]=vs();let be=G(!1),_e=G("main"),Se=G(!1),ue;Ns(()=>{setTimeout(()=>ts(),200);const E=()=>{if(t(ge)){const Le=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";Le&&Le!==t(Ft)?po(Le):!Le&&t(Ft)&&br()}};window.addEventListener("hashchange",E);let L=null;const P=8e3,ne=()=>{if(document.visibilityState==="hidden"){if(Gi())return;L&&clearTimeout(L),L=setTimeout(()=>{L=null,document.visibilityState==="hidden"&&t(ge)&&Wi()},P)}else fa(),L&&(clearTimeout(L),L=null),t(ge)||(Ho()?Bo():ts())},Ce=Le=>{L&&(clearTimeout(L),L=null),document.visibilityState!=="hidden"&&!t(ge)&&(Ho()?Bo():ts())};return document.addEventListener("visibilitychange",ne),window.addEventListener("pageshow",Ce),()=>{window.removeEventListener("hashchange",E),document.removeEventListener("visibilitychange",ne),window.removeEventListener("pageshow",Ce),L&&clearTimeout(L)}});function ve(){ts()}function wt(){br(),Ps()}function Vt(){Ps(),setTimeout(()=>ts(),100)}function Ye(){Ms()}function It(){typeof window<"u"&&(window.location.hash=""),br(),p(be,!1)}let ge=j(r),ft=j(s),nt=j(o),Mt=j(a),vt=j(i),Jt=j(c),Tn=j(v),Qe=j(m),it=j(x),K=j(S),Pe=j(C),gt=j(()=>$().models),en=G(!1),Ft=j(()=>t(K).sessionId);Ct(()=>{typeof window<"u"&&t(ge)&&(t(Ft)?(window.location.hash=encodeURIComponent(t(Ft)),p(en,!0)):t(en)&&(p(en,!1),window.location.hash&&(window.location.hash="")))});let hn=null;Ct(()=>{if(!t(ge)||typeof window>"u"||!window.location.hash)return;const E=decodeURIComponent(window.location.hash.slice(1));E&&(t(Ft)===E||t(Mt)||t(ft)||hn||(hn=setTimeout(()=>{hn=null,!(t(Ft)===E||t(Mt)||t(ft))&&Xi(E)},300)))}),Ct(()=>{t(ge)||p(en,!1)}),Ct(()=>{(t(Ft)||t(Mt)||t(ft))&&p(be,!1)});let Ut=j(D),Rt=j(q),Bt=G(void 0),Je=j(()=>cb({connected:t(ge),searchConfigured:!!t(Rt),hasSession:!!t(K).sessionFile,loading:t(Mt),resyncing:t(ft),hasSessionHash:typeof window<"u"&&!!window.location.hash})),le=j(()=>t(gt).map(E=>({value:`${E.provider}:${E.modelId}`,label:`${E.label}${E.isDefault?" (default)":""}`}))),Me=j(xe),We=G("");Ct(()=>{if(t(le).length===0||t(le).some(ne=>ne.value===t(We)))return;const L=t(le).find(ne=>ne.value===t(Me)),P=t(gt).find(ne=>ne.isDefault);p(We,L?L.value:P?`${P.provider}:${P.modelId}`:t(le)[0].value,!0)});let je=G(!1);Ct(()=>{t(Je)&&!t(je)&&t(Bt)&&(p(je,!0),t(Bt).focusInput())});function rt(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),br(),t(Bt)?.focusInput()}var A=Gb(),W=pn(A);Ec(W,{title:"Wherever",description:"Create & maintain apps from wherever"});var ce=f(W,2);{var R=E=>{var L=db();h(E,L)};w(ce,E=>{t(Ut)&&E(R)})}var z=f(ce,2),ye=d(z),oe=d(ye),fe=d(oe),Be=d(fe);{var $e=E=>{var L=ub(),P=f(pn(L),2);F("click",P,()=>p(Se,!1)),h(E,L)},et=E=>{var L=fb(),P=pn(L),ne=d(P);Ke(2),l(P);var Ce=f(P,2),Le=d(Ce),ee=f(Le,2);l(Ce),O(pe=>Z(ne,"src",pe),[()=>us("/logo.svg")]),F("click",P,It),F("click",Le,()=>p(Se,!0)),F("click",ee,()=>p(be,!1)),h(E,L)};w(Be,E=>{t(Se)?E($e):E(et,-1)})}l(fe),l(oe);var lt=f(oe,2);{var kt=E=>{var L=pb(),P=d(L);{let Te=j(()=>(t(Pe).connected,"localhost"));kd(P,{get host(){return t(Te)},port:31415,token:"",onConnected:ve})}var ne=f(P,2),Ce=f(d(ne),2),Le=d(Ce),ee=f(Le,2),pe=f(ee,2);l(Ce),l(ne),l(L),F("click",Le,Ye),F("click",ee,Vt),F("click",pe,wt),h(E,L)},st=E=>{var L=yb(),P=pn(L),ne=d(P),Ce=d(ne),Le=f(Ce,2),ee=d(Le,!0);l(Le);var pe=f(Le,2),Te=d(pe),$t=f(Te);{var In=Ne=>{var pt=hb(),Gt=d(pt);l(pt),O(()=>V(Gt,` / srv ${t(Pe).serverVersion??""}`)),h(Ne,pt)};w($t,Ne=>{t(Pe).serverVersion&&Ne(In)})}l(pe),l(ne);var sn=f(ne,2);{var dn=Ne=>{var pt=gb(),Gt=d(pt);{var Kn=Ve=>{var Lt=bb(),nr=d(Lt);l(Lt),O(Fr=>{Z(Lt,"title",t(K).cwd),V(nr,`📁 ${Fr??""}`)},[()=>t(K).cwd.split("/").pop()||t(K).cwd]),h(Ve,Lt)};w(Gt,Ve=>{t(K).cwd&&Ve(Kn)})}var tr=f(Gt,2);{var Nr=Ve=>{var Lt=vb(),nr=d(Lt);l(Lt),O(()=>{Z(Lt,"title",t(K).model),V(nr,`🤖 ${t(K).model??""}`)}),h(Ve,Lt)};w(tr,Ve=>{t(K).model&&Ve(Nr)})}var Yn=f(tr,2),Ar=d(Yn);l(Yn),l(pt),F("click",Ar,It),h(Ne,pt)};w(sn,Ne=>{t(K).sessionFile&&Ne(dn)})}var Y=f(sn,2);{var ae=Ne=>{var pt=mb(),Gt=d(pt,!0);l(pt),O(()=>V(Gt,t(Pe).error)),h(Ne,pt)};w(Y,Ne=>{t(Pe).error&&!t(ge)&&Ne(ae)})}l(P);var ke=f(P,2),qe=d(ke);{var Xe=Ne=>{var pt=xb();F("click",pt,()=>{p(_e,"readonly"),_i()}),h(Ne,pt)},ot=Ne=>{var pt=_b();F("click",pt,()=>p(_e,"main")),h(Ne,pt)};w(qe,Ne=>{t(_e)==="main"?Ne(Xe):Ne(ot,-1)})}l(ke);var Nt=f(ke,2),Zt=d(Nt);{var Mn=Ne=>{fi(Ne,{readOnly:!0})},mn=Ne=>{fi(Ne,{})};w(Zt,Ne=>{t(_e)==="readonly"?Ne(Mn):Ne(mn,-1)})}l(Nt),O(()=>{ln(Ce,1,`h-2.5 w-2.5 rounded-full ${t(ge)?"bg-emerald-500":"bg-rose-500"}`),ln(Le,1,`text-sm ${t(ge)?"text-emerald-400":"text-rose-400"}`),V(ee,t(ge)?"Connected":"Disconnected"),Z(pe,"title",t(Pe).serverVersion?`App build ${Vs} · server ${t(Pe).serverVersion}`:`App build ${Vs}`),V(Te,`v${Vs}`)}),h(E,L)};w(lt,E=>{t(Se)?E(kt):E(st,-1)})}l(ye);var St=f(ye,2),tn=d(St),Tt=d(tn),ct=f(Tt,2);{var kn=E=>{var L=wb();F("click",L,rt),h(E,L)};w(ct,E=>{t(ge)&&t(Rt)&&t(K).sessionFile&&E(kn)})}var nn=f(ct,2);{var En=E=>{var L=Ab(),P=d(L);{var ne=ee=>{var pe=kb();h(ee,pe)},Ce=ee=>{var pe=Sb();h(ee,pe)},Le=ee=>{var pe=Tb();h(ee,pe)};w(P,ee=>{t(ge)&&t(Je)?ee(ne):t(ge)?ee(Ce,1):ee(Le,-1)})}l(L),h(E,L)};w(nn,E=>{(!t(ge)||!t(K).sessionFile)&&E(En)})}var gn=f(nn,2);{var rn=E=>{var L=$b(),P=d(L);{var ne=ee=>{var pe=Rb(),Te=f(d(pe),2),$t=d(Te,!0);l(Te),l(pe),O(In=>{Z(Te,"title",t(K).cwd),V($t,In)},[()=>t(K).cwd.split("/").pop()||t(K).cwd]),h(ee,pe)};w(P,ee=>{t(K).cwd&&ee(ne)})}var Ce=f(P,2);{var Le=ee=>{var pe=Mb(),Te=d(pe),$t=f(d(Te),2);l(Te);var In=f(Te,2);{var sn=Y=>{var ae=Eb();qn(ae,21,()=>t(gt),vr,(qe,Xe)=>{var ot=Cb(),Nt=d(ot,!0);l(ot);var Zt={};O(()=>{V(Nt,t(Xe).label),Zt!==(Zt=`${t(Xe).provider}:${t(Xe).modelId}`)&&(ot.value=ot.__value=`${t(Xe).provider}:${t(Xe).modelId}`)}),h(qe,ot)}),l(ae);var ke;mi(ae),O(()=>{ke!==(ke=t(K).model)&&(ae.value=(ae.__value=t(K).model)??"",Jo(ae,t(K).model))}),F("input",ae,qe=>al(qe.currentTarget.value)),h(Y,ae)},dn=Y=>{var ae=Ib(),ke=d(ae,!0);l(ae),O(()=>{Z(ae,"title",t(K).model),V(ke,t(K).model)}),h(Y,ae)};w(In,Y=>{t(gt).length>0&&!t(it)?Y(sn):Y(dn,-1)})}l(pe),O(()=>{ln($t,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(Pe).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),Z($t,"title",t(Pe).isStreaming?"Agent working...":"Ready")}),h(ee,pe)};w(Ce,ee=>{t(K).model&&ee(Le)})}l(L),h(E,L)};w(gn,E=>{t(K).sessionFile&&E(rn)})}var cn=f(gn,2);{var An=E=>{var L=Lb();h(E,L)};w(cn,E=>{t(it)&&E(An)})}l(tn);var Jn=f(tn,2);{var Bn=E=>{var L=Ob();h(E,L)};w(Jn,E=>{t(vt)&&E(Bn)})}var Fn=f(Jn,2);{var ur=E=>{var L=Db(),P=d(L),ne=d(P,!0);l(P);var Ce=f(P,2);l(L),O(()=>{ln(L,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(Tn).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),V(ne,t(Tn).message)}),F("click",Ce,()=>rl()),h(E,L)};w(Fn,E=>{t(Tn)&&E(ur)})}var er=f(Fn,2);{var M=E=>{var L=Nb(),P=d(L),ne=f(d(P));{var Ce=Te=>{var $t=Zn("You are both working in it — changes may conflict.");h(Te,$t)},Le=Te=>{var $t=Zn("You are observing (read-only) to avoid clashing.");h(Te,$t)};w(ne,Te=>{t(Qe).continued?Te(Ce):Te(Le,-1)})}l(P);var ee=f(P,2);{var pe=Te=>{var $t=Pb();F("click",$t,()=>el()),h(Te,$t)};w(ee,Te=>{t(Qe).continued||Te(pe)})}l(L),h(E,L)};w(er,E=>{t(Qe)?.active&&E(M)})}var T=f(er,2);{var U=E=>{var L=Fb(),P=d(L),ne=d(P,!0);l(P);var Ce=f(P,2);l(L),O(()=>V(ne,t(Jt))),F("click",Ce,()=>ns()),h(E,L)};w(T,E=>{t(Jt)&&E(U)})}var X=f(T,2);{var te=E=>{var L=Ub();h(E,L)};w(X,E=>{t(it)&&!t(vt)&&E(te)})}var mt=f(X,2);mr(Wp(mt,{onMessageSent:()=>{}}),E=>ue=E,()=>ue);var Oe=f(mt,2);{var me=E=>{var L=zb();h(E,L)},Ue=E=>{var L=Wb(),P=pn(L);{var ne=ee=>{var pe=Bb();h(ee,pe)},Ce=ee=>{var pe=Hb();h(ee,pe)};w(P,ee=>{t(K).sessionFile&&(t(ft)||!t(ge))?ee(ne):t(K).sessionFile&&t(nt)&&ee(Ce,1)})}var Le=f(P,2);{let ee=j(()=>!!t(Rt)),pe=j(()=>t(Je)?!t(ge):!t(ge)||t(it)||!t(K).sessionFile||t(ft)||t(nt));mr(yh(Le,{get searchMode(){return t(Je)},get searchConfigured(){return t(ee)},get searchModels(){return t(le)},onSubmit:Te=>Qi(Te,t(We)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(pe)},onSend:()=>ue?.forceScrollToBottom(),get searchModel(){return t(We)},set searchModel(Te){p(We,Te,!0)}}),Te=>p(Bt,Te,!0),()=>t(Bt))}h(E,L)};w(Oe,E=>{t(it)&&t(K).sessionFile?E(me):E(Ue,-1)})}l(St);var Pt=f(St,2);ib(Pt,{});var bn=f(Pt,2);{var Ge=E=>{var L=jb();F("click",L,()=>p(be,!1)),h(E,L)};w(bn,E=>{t(be)&&E(Ge)})}l(z),O(()=>ln(ye,1,`app-chrome ${t(be)?"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`)),F("click",Tt,()=>p(be,!t(be))),h(n,A),Vr(),he()}ss(["click","input"]);export{ev as component,Jb as universal};
95
- //# sourceMappingURL=2.q5b1Ictx.js.map
95
+ //# sourceMappingURL=2.kEWDQAI7.js.map