wherever-dev 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +98 -2
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +8 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/session-pool.d.ts +68 -2
- package/dist/session-pool.d.ts.map +1 -1
- package/dist/session-pool.js +361 -13
- package/dist/session-pool.js.map +1 -1
- package/dist/session-types.d.ts +17 -0
- package/dist/session-types.d.ts.map +1 -1
- package/package.json +1 -1
- package/public/_app/immutable/assets/0.CgLKPJWX.css +1 -0
- package/public/_app/immutable/chunks/CEg8tgYI.js +2 -0
- package/public/_app/immutable/chunks/{D_-ITvkp.js.map → CEg8tgYI.js.map} +1 -1
- package/public/_app/immutable/chunks/{DRkv8Frb.js → CTVuBuYH.js} +2 -2
- package/public/_app/immutable/chunks/{DRkv8Frb.js.map → CTVuBuYH.js.map} +1 -1
- package/public/_app/immutable/chunks/{Bd0XWRPL.js → DBDAFnY6.js} +2 -2
- package/public/_app/immutable/chunks/{Bd0XWRPL.js.map → DBDAFnY6.js.map} +1 -1
- package/public/_app/immutable/chunks/MtE7VtNZ.js +2 -0
- package/public/_app/immutable/chunks/{BmiXjuDY.js.map → MtE7VtNZ.js.map} +1 -1
- package/public/_app/immutable/chunks/S778j9fy.js +2 -0
- package/public/_app/immutable/chunks/{6X7J6WvW.js.map → S778j9fy.js.map} +1 -1
- package/public/_app/immutable/chunks/vMsF8lo6.js +3 -0
- package/public/_app/immutable/chunks/{Db42-KyD.js.map → vMsF8lo6.js.map} +1 -1
- package/public/_app/immutable/chunks/{Bx-JhvcJ.js → ylfInSZr.js} +2 -2
- package/public/_app/immutable/chunks/{Bx-JhvcJ.js.map → ylfInSZr.js.map} +1 -1
- package/public/_app/immutable/entry/app.CklFlIiC.js +3 -0
- package/public/_app/immutable/entry/{app.BCW_w5jE.js.map → app.CklFlIiC.js.map} +1 -1
- package/public/_app/immutable/entry/start.sF1k4jCY.js +2 -0
- package/public/_app/immutable/entry/start.sF1k4jCY.js.map +1 -0
- package/public/_app/immutable/nodes/{0.DzrPFEHh.js → 0.BEHRw2jv.js} +3 -3
- package/public/_app/immutable/nodes/{0.DzrPFEHh.js.map → 0.BEHRw2jv.js.map} +1 -1
- package/public/_app/immutable/nodes/1.2gk2c-6t.js +2 -0
- package/public/_app/immutable/nodes/{1.BiDjgup0.js.map → 1.2gk2c-6t.js.map} +1 -1
- package/public/_app/immutable/nodes/2.Dto-NrSs.js +82 -0
- package/public/_app/immutable/nodes/2.Dto-NrSs.js.map +1 -0
- package/public/_app/version.json +1 -1
- package/public/index.html +15 -15
- package/public/pwa/maskable-192.png +0 -0
- package/public/pwa/maskable-512.png +0 -0
- package/public/service-worker.js +1 -1
- package/public/_app/immutable/assets/0.q9wI9TO7.css +0 -1
- package/public/_app/immutable/chunks/6X7J6WvW.js +0 -2
- package/public/_app/immutable/chunks/BmiXjuDY.js +0 -2
- package/public/_app/immutable/chunks/D_-ITvkp.js +0 -2
- package/public/_app/immutable/chunks/Db42-KyD.js +0 -3
- package/public/_app/immutable/entry/app.BCW_w5jE.js +0 -3
- package/public/_app/immutable/entry/start.B21iffdh.js +0 -2
- package/public/_app/immutable/entry/start.B21iffdh.js.map +0 -1
- package/public/_app/immutable/nodes/1.BiDjgup0.js +0 -2
- package/public/_app/immutable/nodes/2.0Tnfs-pB.js +0 -25
- package/public/_app/immutable/nodes/2.0Tnfs-pB.js.map +0 -1
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{a as u,c as wr,f as b,d as ar,b as E,e as Jt,s as V,t as Rt}from"../chunks/Db42-KyD.js";import{_ as Pn,Q as Un,U as On,H as Ln,ap as Kt,d as Nn,ak as sn,b0 as ln,a$ as dn,ao as Hn,aj as jn,C as cn,aC as Dr,a0 as Vt,aa as Bn,ax as Wn,aW as Gn,aw as vn,ba as bn,bc as zn,bd as pn,aR as Zr,aO as un,aN as Qt,aK as Zt,ad as kt,b3 as i,ag as e,bb as A,a3 as Vn,be as X,$ as qn,af as yr,bi as vr,a6 as Tt,aI as kr,aX as l,V as a,aS as n,aG as Oe,b6 as F,aM as Ht,bf as it,bg as Jn,aQ as Kn}from"../chunks/D_-ITvkp.js";import{i as w,s as br,a as De,p as Rr}from"../chunks/BmiXjuDY.js";import{a as Qn,b as _e,r as Me,c as zr,e as Ft,i as Wt,d as Zn}from"../chunks/6X7J6WvW.js";import{_ as Xn,b as Gt}from"../chunks/Bx-JhvcJ.js";import{v as Yn}from"../chunks/Bd0XWRPL.js";import{p as ea}from"../chunks/DRkv8Frb.js";function ta(r,t){let f=null,s=Kt;var d;if(Kt){f=Hn;for(var v=jn(document.head);v!==null&&(v.nodeType!==Nn||v.data!==r);)v=sn(v);if(v===null)ln(!1);else{var p=sn(v);v.remove(),dn(p)}}Kt||(d=document.head.appendChild(Pn()));try{Un(()=>{var x=On(()=>t(d));x.f|=Ln})}finally{s&&(ln(!0),dn(f))}}function xn(r){var t,f,s="";if(typeof r=="string"||typeof r=="number")s+=r;else if(typeof r=="object")if(Array.isArray(r)){var d=r.length;for(t=0;t<d;t++)r[t]&&(f=xn(r[t]))&&(s&&(s+=" "),s+=f)}else for(f in r)r[f]&&(s&&(s+=" "),s+=f);return s}function ra(){for(var r,t,f=0,s="",d=arguments.length;f<d;f++)(r=arguments[f])&&(t=xn(r))&&(s&&(s+=" "),s+=t);return s}function na(r){return typeof r=="object"?ra(r):r??""}function aa(r,t,f){var s=r==null?"":""+r;return s===""?null:s}function gt(r,t,f,s,d,v){var p=r[cn];if(Kt||p!==f||p===void 0){var x=aa(f);(!Kt||x!==r.getAttribute("class"))&&(x==null?r.removeAttribute("class"):t?r.className=x:r.setAttribute("class",x)),r[cn]=f}return v}function Xr(r,t,f=!1){if(r.multiple){if(t==null)return;if(!Wn(t))return Gn();for(var s of r.options)s.selected=t.includes(gr(s));return}for(s of r.options){var d=gr(s);if(vn(d,t)){s.selected=!0;return}}(!f||t!==void 0)&&(r.selectedIndex=-1)}function hn(r){var t=new MutationObserver(()=>{Xr(r,r.__value)});t.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),bn(()=>{t.disconnect()})}function Ar(r,t,f=t){var s=new WeakSet,d=!0;Dr(r,"change",v=>{var p=v?"[selected]":":checked",x;if(r.multiple)x=[].map.call(r.querySelectorAll(p),gr);else{var G=r.querySelector(p)??r.querySelector("option:not([disabled])");x=G&&gr(G)}f(x),r.__value=x,Vt!==null&&s.add(Vt)}),Bn(()=>{var v=t();if(r===document.activeElement){var p=Vt;if(s.has(p))return}if(Xr(r,v,d),d&&v===void 0){var x=r.querySelector(":checked");x!==null&&(v=gr(x),f(v))}r.__value=v,d=!1}),hn(r)}function gr(r){return"__value"in r?r.__value:r.value}function zt(r,t,f=t){var s=new WeakSet;Dr(r,"input",async d=>{var v=d?r.defaultValue:r.value;if(v=Nr(r)?Hr(v):v,f(v),Vt!==null&&s.add(Vt),await zn(),v!==(v=t())){var p=r.selectionStart,x=r.selectionEnd,G=r.value.length;if(r.value=v??"",x!==null){var R=r.value.length;p===x&&x===G&&R>G?(r.selectionStart=R,r.selectionEnd=R):(r.selectionStart=p,r.selectionEnd=Math.min(x,R))}}}),(Kt&&r.defaultValue!==r.value||pn(t)==null&&r.value)&&(f(Nr(r)?Hr(r.value):r.value),Vt!==null&&s.add(Vt)),Zr(()=>{var d=t();if(r===document.activeElement){var v=Vt;if(s.has(v))return}Nr(r)&&d===Hr(r.value)||r.type==="date"&&!d&&!r.value||d!==r.value&&(r.value=d??"")})}const Lr=new Set;function qt(r,t,f,s,d=s){var v=f.getAttribute("type")==="checkbox",p=r;let x=!1;if(t!==null)for(var G of t)p=p[G]??=[];p.push(f),Dr(f,"change",()=>{var R=f.__value;v&&(R=fn(p,R,f.checked)),d(R)},()=>d(v?[]:null)),Zr(()=>{var R=s();if(Kt&&f.defaultChecked!==f.checked){x=!0;return}v?(R=R||[],f.checked=R.includes(f.__value)):f.checked=vn(f.__value,R)}),bn(()=>{var R=p.indexOf(f);R!==-1&&p.splice(R,1)}),Lr.has(p)||(Lr.add(p),un(()=>{p.sort((R,Y)=>R.compareDocumentPosition(Y)===4?-1:1),Lr.delete(p)})),un(()=>{if(x){var R;if(v)R=fn(p,R,f.checked);else{var Y=p.find(fe=>fe.checked);R=Y?.__value}d(R)}})}function Ot(r,t,f=t){Dr(r,"change",s=>{var d=s?r.defaultChecked:r.checked;f(d)}),(Kt&&r.defaultChecked!==r.checked||pn(t)==null)&&f(r.checked),Zr(()=>{var s=t();r.checked=!!s})}function fn(r,t,f){for(var s=new Set,d=0;d<r.length;d+=1)r[d].checked&&s.add(r[d].__value);return f||s.delete(t),Array.from(s)}function Nr(r){var t=r.type;return t==="number"||t==="range"}function Hr(r){return r===""?null:+r}const oa=!1,sa=!0,bi=Object.freeze(Object.defineProperty({__proto__:null,prerender:sa,ssr:oa},Symbol.toStringTag,{value:"Module"})),jr="Wherever",ia="Create & maintain apps from wherever with a beautiful remote workspace.",Br="https://localhost",la="#000000",da="black-translucent";function ir(r,t){return Qn(r)}var ca=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 ua(r,t){Qt(t,!0);const f=Br.endsWith("/")?Br.slice(0,-1):Br,s=f+"/preview.png";let d=X(()=>t.home||!1),v=X(()=>({type:t.type||"website",title:t.title||jr,description:t.description||ia,image:t.image||s,url:`${f}${ea.url.pathname}`}));ta("13n5pl5",p=>{var x=ca(),G=kt(x),R=i(G,2),Y=i(R,2);{var fe=Ve=>{var se=wr(),je=kt(se);w(je,Xe=>{}),u(Ve,se)};w(Y,Ve=>{e(d)&&Ve(fe)})}var M=i(Y,2),j=i(M,2),L=i(j,2),ee=i(L,2),Ee=i(ee,2),Ie=i(Ee,4),ne=i(Ie,2),Pe=i(ne,2),we=i(Pe,2),B=i(we,2),at=i(B,2),pe=i(at,2),ye=i(pe,2),ie=i(ye,2),Ke=i(ie,4),Se=i(Ke,4),rt=i(Se,2),q=i(rt,2);A((Ve,se,je,Xe)=>{_e(G,"content",e(v).title),_e(R,"content",e(v).description),_e(M,"content",e(v).type),_e(j,"content",e(v).url),_e(L,"content",e(v).title),_e(ee,"content",e(v).description),_e(Ee,"content",e(v).image),_e(Ie,"content",e(v).url),_e(ne,"content",e(v).title),_e(Pe,"content",e(v).description),_e(we,"content",e(v).image),_e(B,"href",Ve),_e(at,"href",se),_e(pe,"href",je),_e(ye,"href",Xe),_e(ie,"content",la),_e(Ke,"content",jr),_e(Se,"content",da),_e(rt,"content",jr),_e(q,"content",Yn)},[()=>ir("/pwa/favicon.png"),()=>ir("/pwa/favicon.ico"),()=>ir("/pwa/apple-touch-icon.png"),()=>ir("/pwa/manifest.webmanifest")]),Vn(()=>{qn.title=e(v).title??""}),u(p,x)}),Zt()}function Mr(){}function fa(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function va(r,...t){if(r==null)return Mr;const f=r.subscribe(...t);return f.unsubscribe?()=>f.unsubscribe():f}function xr(r){let t;return va(r,f=>t=f)(),t}var sr=[];function ba(r,t=Mr){let f;const s=new Set;function d(x){if(fa(r,x)&&(r=x,f)){const G=!sr.length;for(const R of s)R[1](),sr.push(R,r);if(G){for(let R=0;R<sr.length;R+=2)sr[R][0](sr[R+1]);sr.length=0}}}function v(x){d(x(r))}function p(x,G=Mr){const R=[x,G];return s.add(R),s.size===1&&(f=t(d)||Mr),x(r),()=>{s.delete(R),s.size===0&&(f(),f=null)}}return{set:d,update:v,subscribe:p}}const Wr={connected:!1,connecting:!1,creatingSession:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,conflict:null,isInterrupted:!1,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1};class pa{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;isInitialConnect=!0;listeners=new Set;pendingUploads=new Map;constructor(t){this.config={secure:!0,...t},this.stateStore=ba({...Wr,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(t){t&&(this.config={...this.config,...t}),this.disconnect(!1),this.stateStore.update(M=>({...Wr,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools}));const f=this.config.secure?"wss":"ws",s=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,d=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",v=`${f}://${s}:${this.config.port}/ws${d}`,p=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!p){this.stateStore.update(M=>({...M,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const M=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=M?new p(v,M):new p(v)}catch(M){this.stateStore.update(j=>({...j,connecting:!1,error:`Failed to connect: ${M}`})),this.scheduleReconnect();return}const x=this.ws,G=()=>{this.ws===x&&(this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.stateStore.update(M=>({...M,connected:!0,connecting:!1,error:null})))},R=M=>{if(this.ws===x)try{const j=typeof M.data=="string"?M.data:M.data.toString(),L=JSON.parse(j);this.handleMessage(L)}catch(j){console.error("Failed to parse WebSocket message:",j)}},Y=()=>{this.ws===x&&(this.ws=null,this.stateStore.update(M=>({...M,connected:!1,connecting:!1})),this.scheduleReconnect())},fe=M=>{this.ws===x&&this.stateStore.update(j=>({...j,error:j.error||"Connection error occurred"}))};typeof x.addEventListener=="function"?(x.addEventListener("open",G),x.addEventListener("message",R),x.addEventListener("close",Y),x.addEventListener("error",fe)):typeof x.on=="function"&&(x.on("open",G),x.on("message",M=>R({data:M})),x.on("close",Y),x.on("error",fe))}disconnect(t=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws){try{typeof this.ws.removeAllListeners=="function"&&this.ws.removeAllListeners(),this.ws.close()}catch{}this.ws=null}t&&this.stateStore.set({...Wr,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),this.stateStore.update(t=>({...t,connecting:!0,error:"Reconnecting..."})),this.connect()},this.reconnectDelay))}handleMessage(t){for(const f of this.listeners)try{f(t)}catch(s){console.error("Error in message listener:",s)}switch(t.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:t.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(t.uploadId);s&&(s.resolve({savedPath:t.savedPath,filename:t.filename}),this.pendingUploads.delete(t.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(t.uploadId);s&&(s.reject(new Error(t.error)),this.pendingUploads.delete(t.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 d=[...s.messages].reverse().find(v=>v.role==="thinking"&&v.isStreaming);if(!d){const v={id:this.generateId(),role:"thinking",content:t.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,v]}}return{...s,messages:s.messages.map(v=>v.id===d.id?{...v,content:v.content+t.delta,isStreaming:!0}:v)}});break;case"message_update":this.stateStore.update(s=>{let d=[...s.messages].reverse().find(v=>v.role==="assistant"&&v.isStreaming);if(!d){const v={id:this.generateId(),role:"assistant",content:t.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,v]}}return{...s,messages:s.messages.map(v=>v.id===d.id?{...v,content:v.content+t.delta,isStreaming:!0}:v)}});break;case"message_end":this.stateStore.update(s=>{let d=s.messages;const v=[...d].reverse().find(x=>x.role==="thinking"&&x.isStreaming);v&&(d=d.map(x=>x.id===v.id?{...x,isStreaming:!1}:x));const p=[...d].reverse().find(x=>x.role==="assistant"&&x.isStreaming);if(p)d=d.map(x=>x.id===p.id?{...x,content:t.content||x.content,isStreaming:!1}:x);else if(t.content){const x=[...d].reverse().find(R=>R.role==="user");t.role==="user"&&x&&x.content===t.content||(d=[...d,{id:this.generateId(),role:t.role||"assistant",content:t.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:d}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{this.stateStore.update(s=>({...s,isStreaming:!1,messages:s.messages.map(d=>d.isStreaming?{...d,isStreaming:!1}:d)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const f=t.args?Object.entries(t.args).filter(([s,d])=>d!==void 0&&d!=="").map(([s,d])=>`${s}=${JSON.stringify(d)}`).join(" "):"";this.stateStore.update(s=>{const d=s.messages.map(p=>p.isStreaming&&(p.role==="assistant"||p.role==="thinking")?{...p,isStreaming:!1}:p),v={id:this.generateId(),role:"tool",content:f?`$ ${t.toolName} ${f}`:`$ ${t.toolName}`,timestamp:Date.now(),isStreaming:!0,toolName:t.toolName,toolArgs:f,toolOutput:""};return{...s,messages:[...d,v]}});break;case"tool_update":{this.stateStore.update(s=>{const d=[...s.messages].reverse().find(v=>v.role==="tool"&&v.toolName===t.toolName&&v.isStreaming);return d?{...s,messages:s.messages.map(v=>v.id===d.id?{...v,content:v.content.includes(`
|
|
2
|
-
`)?v.content+t.delta:`${v.content}
|
|
3
|
-
${t.delta}`,toolOutput:`${v.toolOutput}${t.delta}`}:v)}:s});break}case"tool_end":{const s=t.result?`${t.result}`:"";this.stateStore.update(d=>{const v=[...d.messages].reverse().find(p=>p.role==="tool"&&p.toolName===t.toolName&&!p.content.startsWith("Tool error:"));if(v){const p=t.isError?"Error: ":"";return{...d,messages:d.messages.map(x=>x.id===v.id?{...x,content:`${p}${x.content}
|
|
4
|
-
${s}`,isStreaming:!1,isError:t.isError,toolOutput:s}:x)}}else{const p=t.isError?`Tool error: ${t.toolName}
|
|
5
|
-
${s}`:`${t.toolName}
|
|
6
|
-
${s}`,x={id:this.generateId(),role:"tool",content:p,timestamp:Date.now(),isStreaming:!1,toolName:t.toolName,toolArgs:"",toolOutput:s,isError:t.isError};return{...d,messages:[...d.messages,x]}}});break}case"aborted":this.stateStore.update(s=>({...s,isStreaming:!1,messages:s.messages.map(d=>d.isStreaming?{...d,isStreaming:!1}:d)}));break;case"session_created":this.stateStore.update(s=>({...s,session:t.sessionFile,sessionId:t.sessionId,activeSessionFile:t.sessionFile,activeCwd:t.cwd,activeModel:t.model,isStreaming:t.isStreaming??!1,creatingSession:!1}));break;case"session_destroyed":this.stateStore.update(s=>s.sessionId===t.sessionId?{...s,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null}:s);break;case"session_error":this.stateStore.update(s=>({...s,sessionError:t.error,isStreaming:!1,creatingSession:!1}));break;case"session_conflict":this.stateStore.update(s=>({...s,conflict:{targetSessionId:t.sessionId,conflictingSessionId:t.conflictingSession,conflictingCwd:t.conflictingCwd},creatingSession:!1}));break;case"session_interrupted":this.stateStore.update(s=>({...s,isInterrupted:!0,readOnly:!0,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,creatingSession:!1}));break;case"message_history":this.stateStore.update(s=>{const d=this.mapHistory(t.messages,t.sessionId,s.isStreaming),v=typeof t.totalCount=="number"?t.totalCount:d.length,p=typeof t.offset=="number"?t.offset:0;return{...s,messages:d,historyTotalCount:v,historyOffset:p,loadingMoreHistory:!1}});break;case"message_history_prepend":this.stateStore.update(s=>{const d=this.mapHistory(t.messages,t.sessionId,!1),v=typeof t.offset=="number"?t.offset:0;return d.length===0?{...s,loadingMoreHistory:!1,historyOffset:v}:{...s,messages:[...d,...s.messages],historyOffset:v,loadingMoreHistory:!1}});break;case"model_changed":this.stateStore.update(s=>({...s,activeModel:t.model}));break}}mapHistory(t,f,s){const d=[],v={};for(const p of t)if(p.role==="tool_call"){const x=p.toolName||"unknown";v[x]||(v[x]=[]),v[x].push(p.content||"")}else if(p.role==="tool_result"){const x=p.toolName||"unknown",G=v[x]&&v[x].length>0?v[x].shift():"";d.push({id:this.generateId(),role:"tool",content:G?`$ ${x} ${G}
|
|
7
|
-
${p.content}`:`$ ${x}
|
|
8
|
-
${p.content}`,timestamp:p.timestamp,isStreaming:!1,toolName:x,toolArgs:G,toolOutput:p.content,isError:p.isError,sessionId:f})}else d.push({id:this.generateId(),role:p.role,content:p.content,timestamp:p.timestamp,isStreaming:!1,toolName:p.toolName,sessionId:f});for(const[p,x]of Object.entries(v))for(const G of x)d.push({id:this.generateId(),role:"tool",content:G?`$ ${p} ${G}`:`$ ${p}`,timestamp:d.length>0?d[d.length-1].timestamp+1:Date.now(),isStreaming:s,toolName:p,toolArgs:G,toolOutput:"",sessionId:f});if(s&&d.length>0){const p=d.length-1,x=d[p];(x.role==="assistant"||x.role==="thinking")&&(d[p]={...x,isStreaming:!0})}return d}loadMoreHistory(){const t=xr(this.stateStore);t.sessionId&&(t.loadingMoreHistory||t.historyOffset<=0||(this.stateStore.update(f=>({...f,loadingMoreHistory:!0})),this.send({type:"history_load_more",sessionId:t.sessionId,beforeOffset:t.historyOffset})))}send(t){this.ws&&this.ws.readyState===1&&this.ws.send(JSON.stringify(t))}sendMessage(t){const f=xr(this.stateStore);if(!f.sessionId)return;this.stateStore.update(d=>({...d,sessionError:null}));const s={id:this.generateId(),role:"user",content:t,timestamp:Date.now(),isStreaming:!1,sessionId:f.sessionId};this.stateStore.update(d=>({...d,messages:[...d.messages,s]})),this.send({type:"message",message:t,sessionId:f.sessionId})}abort(){const t=xr(this.stateStore);t.sessionId&&this.send({type:"abort",sessionId:t.sessionId})}joinSession(t,f,s){this.stateStore.update(d=>({...d,conflict:null,sessionError:null})),this.send({type:"session_load",sessionFile:t,cwd:f,model:s})}createSession(t,f,s,d,v){this.stateStore.update(p=>({...p,conflict:null,sessionError:null,creatingSession:!0})),this.send({type:"session_new",cwd:t,model:f,gitInit:s,createRemote:d,repoVisibility:v})}leaveSession(){const t=xr(this.stateStore);t.sessionId&&(this.send({type:"session_leave",sessionId:t.sessionId}),this.stateStore.update(f=>({...f,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,creatingSession:!1})))}resolveConflict(t,f){const s=xr(this.stateStore);s.conflict&&(this.send({type:"session_resolve_conflict",action:t,sessionId:s.conflict.targetSessionId,cwd:f||s.conflict.conflictingCwd}),this.stateStore.update(d=>({...d,conflict:null,readOnly:t==="read_only"})))}ping(){this.send({type:"ping"})}clearMessages(){this.stateStore.update(t=>({...t,messages:[]}))}dismissSessionError(){this.stateStore.update(t=>({...t,sessionError:null}))}changeModel(t){this.send({type:"model_change",model:t})}setConfig(t){this.config={...this.config,...t},this.stateStore.update(f=>{const s={...f};return t.hideThinking!==void 0&&(s.hideThinking=!!t.hideThinking),t.hideTools!==void 0&&(s.hideTools=!!t.hideTools),s})}onMessage(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}uploadFileViaWebSocket(t,f,s){return new Promise((d,v)=>{const p=this.generateId();this.pendingUploads.set(p,{resolve:d,reject:v}),this.send({type:"file_upload",uploadId:p,sessionId:t,filename:f,data:s})})}generateId(){return Math.random().toString(36).substring(2)+Date.now().toString(36)}getIsConnected(){return this.ws&&this.ws.readyState===1}}const lr=vr({folders:[],activeSessions:[],currentSession:null,loading:!1}),cr=vr({models:[],loading:!1});function Xt(){const r=localStorage.getItem("wherever-config"),t=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost";if(r){const f=JSON.parse(r),s=window.location.protocol==="https:"?"https:":"http:";let d=f.host||t;return(d==="localhost"||d==="127.0.0.1")&&t&&t!=="localhost"&&t!=="127.0.0.1"&&(d=t),d=d.startsWith("http")?d.replace(/^wss?:\/\//,""):d,`${s}//${d}:${f.port||31415}`}return`${window.location.protocol}//${window.location.host}`}let Er=null,Gr=[];function dr(){Er&&clearTimeout(Er),lr.update(t=>({...t,loading:!0}));const r=new Promise(t=>{Gr.push(t)});return Er=setTimeout(async()=>{Er=null;const t=[...Gr];Gr=[];try{const f=Xt(),s=Yt(),d=`${f}/sessions${s?`?token=${encodeURIComponent(s)}`:""}`,v=await fetch(d);if(!v.ok)throw new Error(`HTTP ${v.status}`);const p=await v.json();lr.set({folders:p.folders||[],activeSessions:(p.activeSessions||[]).map(x=>x.sessionFile),currentSession:yr(lr).currentSession,loading:!1})}catch(f){lr.update(s=>({...s,loading:!1})),console.error("Failed to fetch sessions:",f)}finally{for(const f of t)f()}},100),r}async function xa(){cr.update(r=>({...r,loading:!0}));try{const r=Xt(),t=Yt(),f=`${r}/models${t?`?token=${encodeURIComponent(t)}`:""}`,s=await fetch(f);if(!s.ok)throw new Error(`HTTP ${s.status}`);const d=await s.json();cr.set({models:d.models||[],loading:!1})}catch(r){cr.update(t=>({...t,loading:!1})),console.error("Failed to fetch models:",r)}}function Yt(){try{const r=localStorage.getItem("wherever-config");if(r)return JSON.parse(r).token||""}catch{}return""}const Yr=vr(!1),mn=vr("websocket"),en=vr(null),gn=vr(!1);async function _n(r){if(!r.trim())return null;try{const t=Xt(),f=Yt(),s=`${t}/check-path?path=${encodeURIComponent(r)}${f?`&token=${encodeURIComponent(f)}`:""}`,d=await fetch(s);if(!d.ok)throw new Error(`HTTP ${d.status}`);return await d.json()}catch(t){return console.error("Failed to check path:",t),null}}async function Fr(r){try{const t=Xt(),f=Yt(),s=`${t}/autocomplete-path?path=${encodeURIComponent(r)}${f?`&token=${encodeURIComponent(f)}`:""}`,d=await fetch(s);if(!d.ok)throw new Error(`HTTP ${d.status}`);return(await d.json()).completions||[]}catch(t){return console.error("Failed to autocomplete path:",t),[]}}async function ha(){try{const r=Xt(),t=Yt(),f=`${r}/config${t?`?token=${encodeURIComponent(t)}`:""}`,s=await fetch(f);if(!s.ok)throw new Error(`HTTP ${s.status}`);const d=await s.json();Yr.set(!!d.gitInitDefault),mn.set(d.uploadMethod||"websocket"),en.set(d.searchFolder||null),gn.set(!!d.searchCreateRemote)}catch(r){console.error("Failed to fetch config:",r)}}function _r(r){lr.update(t=>({...t,currentSession:r}))}function ma(){try{const r=localStorage.getItem("wherever-config");if(r)return JSON.parse(r)}catch{}return null}function tn(r){localStorage.setItem("wherever-config",JSON.stringify(r))}function Sr(){const r=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",t=ma();return t?(!t.host||t.host==="localhost"||t.host==="127.0.0.1")&&r&&r!=="localhost"&&r!=="127.0.0.1"?{hideThinking:!1,hideTools:!1,...t,host:r}:(t.host||(t.host=r),{hideThinking:!1,hideTools:!1,...t}):{host:r,port:31415,token:"",hideThinking:!1,hideTools:!1}}const hr=Sr(),lt=new pa({host:hr.host,port:hr.port,token:hr.token,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!hr.hideThinking,hideTools:!!hr.hideTools}),rn=lt.stateStore;let mr=null;lt.onMessage(r=>{switch(r.type){case"session_created":if(_r(r.sessionFile),mr!==null){const f=mr;mr=null,queueMicrotask(()=>lt.sendMessage(f))}break;case"session_error":mr=null;break;case"session_destroyed":yr(rn).sessionId===r.sessionId&&_r(null);break;case"sessions_updated":dr();break;case"session_interrupted":_r(null);break}});function rr(){const r=Sr();tn(r);const t=typeof window<"u"&&window.location&&window.location.protocol==="https:";lt.connect({host:r.host,port:r.port,token:r.token,secure:t,hideThinking:!!r.hideThinking,hideTools:!!r.hideTools})}function ur(){lt.disconnect(!0),_r(null)}function Vr(r){lt.sendMessage(r)}function wn(){lt.abort()}function fr(r,t,f){lt.joinSession(r,t,f)}function jt(r,t,f,s,d){lt.createSession(r,t,f,s,d)}function yn(r){const t=r.trim();if(!t)return!1;const f=yr(en);if(!f)return!1;const s=yr(gn);return mr=t,lt.createSession(f,void 0,s,s,s?"private":void 0),!0}function Mt(){lt.leaveSession(),_r(null)}function kn(){lt.loadMoreHistory()}function qr(r,t){lt.resolveConflict(r,t)}function ga(){lt.ping()}function Sn(){lt.clearMessages()}function Jr(r){tn(r),lt.setConfig(r)}function Kr(r){const f={...Sr(),...r};tn(f),lt.setConfig(f)}function nr(){lt.dismissSessionError()}function Cn(r){lt.changeModel(r)}const _t=Tt(rn,r=>r),Cr=Tt(_t,r=>r.connected),nn=Tt(_t,r=>r.isStreaming),Tn=Tt(_t,r=>r.messages),_a=Tt(_t,r=>r.error),wa=Tt(_t,r=>r.session),$n=Tt(_t,r=>r.conflict),In=Tt(_t,r=>r.isInterrupted),an=Tt(_t,r=>r.sessionError),on=Tt(_t,r=>r.readOnly),Tr=Tt(_t,r=>({sessionFile:r.activeSessionFile,cwd:r.activeCwd,model:r.activeModel,sessionId:r.sessionId})),En=Tt(_t,r=>r.creatingSession),Rn=Tt(_t,r=>r.historyOffset>0),Mn=Tt(_t,r=>r.loadingMoreHistory);async function ya(r,t){const f=Xt(),s=Yt(),d=`${f}/session/upload?sessionId=${encodeURIComponent(r)}&filename=${encodeURIComponent(t.name)}${s?`&token=${encodeURIComponent(s)}`:""}`,v=await t.arrayBuffer(),p=await fetch(d,{method:"POST",headers:{"Content-Type":"text/plain"},body:v});if(!p.ok){const x=await p.json().catch(()=>({}));throw new Error(x.error||`Upload failed with status ${p.status}`)}return await p.json()}function ka(r,t){return new Promise((f,s)=>{try{const d=new FileReader;d.onload=()=>{try{const p=d.result.split(",")[1]||"";lt.uploadFileViaWebSocket(r,t.name,p).then(f).catch(s)}catch(v){s(new Error(`Failed to process file data: ${v.message}`))}},d.onerror=()=>{s(new Error("Failed to read file contents"))},d.readAsDataURL(t)}catch(d){s(d)}})}async function An(r,t){return yr(mn)==="post"?ya(r,t):ka(r,t)}async function Qr(r){try{const t=Xt(),f=Yt(),s=`${t}/session/delete${f?`?token=${encodeURIComponent(f)}`:""}`,d=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionFile:r})});if(!d.ok){const v=await d.json().catch(()=>({}));throw new Error(v.error||`Delete failed with status ${d.status}`)}}catch(t){throw console.error("Failed to delete session:",t),t}}const Sa=Object.freeze(Object.defineProperty({__proto__:null,abort:wn,activeSessionInfo:Tr,changeModel:Cn,clearMessages:Sn,client:lt,conflict:$n,connect:rr,connectionError:_a,createSession:jt,currentSession:wa,deleteSession:Qr,disconnect:ur,dismissSessionError:nr,getConfig:Sr,hasMoreHistory:Rn,isConnected:Cr,isCreatingSession:En,isInterrupted:In,isLoadingMoreHistory:Mn,isReadOnly:on,isStreaming:nn,joinSession:fr,leaveSession:Mt,loadMoreHistory:kn,messages:Tn,piState:_t,ping:ga,resolveConflict:qr,runSearch:yn,sendMessage:Vr,sessionError:an,setConfig:Jr,state:rn,updateConfig:Kr,uploadFile:An},Symbol.toStringTag,{value:"Module"}));var Ca=b('<button class="flex-1 rounded bg-rose-500 px-4 py-2 text-sm text-white transition-colors hover:bg-rose-600">Disconnect</button>'),Ta=b('<button class="flex-1 rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-4 py-2 text-sm text-white transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:from-brand-surface-3 disabled:to-brand-surface-3"></button>'),$a=b('<div class="border-b border-brand-border p-4"><div class="space-y-3"><div><label for="pi-host" class="mb-1 block text-xs text-brand-text-muted">Host</label> <input id="pi-host" type="text" placeholder="localhost" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div><label for="pi-port" class="mb-1 block text-xs text-brand-text-muted">Port</label> <input id="pi-port" type="number" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div><label for="pi-token" class="mb-1 block text-xs text-brand-text-muted">Token (optional)</label> <input id="pi-token" type="password" placeholder="Authentication token" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div class="flex items-center gap-2 py-1"><input id="pi-hide-thinking" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0"/> <label for="pi-hide-thinking" class="cursor-pointer text-xs text-brand-text select-none">Hide thinking steps</label></div> <div class="flex items-center gap-2 py-1"><input id="pi-hide-tools" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0"/> <label for="pi-hide-tools" class="cursor-pointer text-xs text-brand-text select-none">Hide tool calls</label></div> <div class="flex gap-2"><!></div></div></div>');function Ia(r,t){Qt(t,!0);const f=()=>De(Cr,"$isConnected",s),[s,d]=br();let v=F(""),p=F(0),x=F(""),G=F(!1),R=F(!1),Y=!1,fe=X(f);kr(()=>{const se=Sr();l(v,se.host,!0),l(p,se.port,!0),l(x,se.token||"",!0),l(G,!!se.hideThinking),l(R,!!se.hideTools)});function M(){Jr({host:e(v),port:e(p),token:e(x),hideThinking:e(G),hideTools:e(R)})}function j(){Jr({host:e(v),port:e(p),token:e(x),hideThinking:e(G),hideTools:e(R)}),ur(),setTimeout(()=>rr(),100)}function L(){ur()}var ee=$a(),Ee=a(ee),Ie=a(Ee),ne=i(a(Ie),2);Me(ne),n(Ie);var Pe=i(Ie,2),we=i(a(Pe),2);Me(we),n(Pe);var B=i(Pe,2),at=i(a(B),2);Me(at),n(B);var pe=i(B,2),ye=a(pe);Me(ye),Oe(2),n(pe);var ie=i(pe,2),Ke=a(ie);Me(Ke),Oe(2),n(ie);var Se=i(ie,2),rt=a(Se);{var q=se=>{var je=Ca();E("click",je,L),u(se,je)},Ve=se=>{var je=Ta();je.disabled=Y,je.textContent="Connect",E("click",je,j),u(se,je)};w(rt,se=>{e(fe)?se(q):se(Ve,-1)})}n(Se),n(Ee),n(ee),zt(ne,()=>e(v),se=>l(v,se)),zt(we,()=>e(p),se=>l(p,se)),zt(at,()=>e(x),se=>l(x,se)),E("change",ye,M),Ot(ye,()=>e(G),se=>l(G,se)),E("change",Ke,M),Ot(Ke,()=>e(R),se=>l(R,se)),u(r,ee),Zt(),d()}ar(["change","click"]);var Ea=b('<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="text-center"><div class="mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <p class="text-base font-medium text-brand-text">Connecting to Wherever Server...</p> <p class="mt-1 text-xs text-brand-text-muted">Establishing secure connection to your agent</p></div></div>'),Ra=b('<p class="mt-3 max-h-24 overflow-y-auto rounded bg-brand-surface-3 p-2 font-mono text-xs text-rose-300/80"> </p>'),Ma=b(`<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="w-full max-w-md rounded-lg border border-red-500/30 bg-red-500/10 p-6 text-center text-brand-text"><div class="mb-3 text-4xl">⚠️</div> <h3 class="text-lg font-bold text-rose-400">Not Connected to Server</h3> <p class="mt-2 text-sm text-brand-text-muted">We couldn't connect to the Wherever Server. Please verify the server
|
|
9
|
-
is running and check your connection settings in the sidebar.</p> <!> <button class="mt-5 rounded bg-brand-surface-2 px-4 py-2 text-sm font-semibold text-brand-text transition-colors hover:bg-brand-surface-3">Retry Connection</button></div></div>`),Aa=b('<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="text-center"><div class="mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <p class="text-base font-medium text-brand-text">Loading session...</p> <p class="mt-1 text-xs text-brand-text-muted">Retrieving workspace session history</p></div></div>'),Fa=b('<button type="button" class="block w-full px-3 py-1.5 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"> </button>'),Da=b('<div class="absolute right-0 left-0 z-50 mt-1 max-h-48 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl"></div>'),Pa=b('<span class="ml-1 font-medium text-emerald-400">(Git repo detected)</span>'),Ua=b('<span class="mt-1.5 block text-xs font-medium text-yellow-400">📁 Folder already exists. Joining will create a session in it. <!></span>'),Oa=b('<span class="mt-1 block text-[10px] text-brand-text-muted">Relative paths are created inside your home folder.</span>'),La=b("<option> </option>"),Na=b('<select id="main-model-select" class="w-full rounded border border-brand-border bg-brand-surface-3 px-3 py-2 text-sm text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Ha=b('<input id="main-model-select" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-surface-3 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/>'),ja=b('<div class="flex items-center gap-4 pl-6 text-xs text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="main-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.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="main-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),Ba=b('<div class="space-y-1.5 pt-1"><div class="flex items-center gap-2"><input id="main-create-remote" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="main-create-remote" class="cursor-pointer text-sm text-brand-text select-none"> </label></div> <!></div>'),Wa=b('<div class="flex items-center gap-2 pt-1"><input id="main-git-init" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="main-git-init" class="cursor-pointer text-sm text-brand-text select-none">Initialize Git repository</label></div>'),Ga=b(`<div class="flex flex-1 items-center justify-center p-6"><div class="w-full max-w-md rounded-lg border border-brand-border bg-brand-surface/40 p-6 text-brand-text"><div class="mb-5 text-center"><div class="mb-3 flex justify-center"><img alt="Wherever" class="h-16 w-16"/></div> <h2 class="mb-1 text-2xl font-bold"><span class="gradient-text">Wherever</span></h2> <h3 class="text-sm font-semibold text-brand-text">Create a New Session</h3> <p class="mt-1 text-xs text-brand-text-muted">Start a coding session in any folder on your machine, or use the
|
|
10
|
-
sidebar to open an existing session.</p></div> <form class="space-y-4"><div><label class="mb-1 block text-xs font-bold tracking-wider text-brand-text-muted uppercase" for="main-folder-path">Folder Path</label> <div class="relative"><input id="main-folder-path" type="text" autocomplete="off" spellcheck="false" placeholder="e.g. ~/projects/my-new-app"/> <!></div> <!></div> <div><label class="mb-1 block text-xs font-bold tracking-wider text-brand-text-muted uppercase" for="main-model-select">Model</label> <!></div> <!> <!> <button type="submit" class="w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-2.5 text-sm font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50">Create & Start Session</button></form></div></div>`),za=b('<div class="flex flex-1 items-center justify-center text-brand-text-muted"><div class="text-center"><div class="mb-4 text-4xl">💬</div> <p class="mb-2 text-lg font-medium text-brand-text">New Session Started</p> <p class="text-sm">Type a message below to start building</p></div></div>'),Va=b('<div class="flex justify-center pb-2"><button class="rounded border border-brand-border bg-brand-surface-2 px-3 py-1.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50"><!></button></div>'),qa=b('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent is thinking...</span></div>'),Ja=b('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent working...</span></div>'),Ka=b('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent is thinking...</span></div>'),Qa=b('<div class="mb-1 flex items-center gap-1.5 text-[10px] font-bold tracking-wider text-brand-cyan uppercase select-none"><span class="inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-brand-cyan"></span> <span>Thinking</span></div>'),Za=b('<div class="flex flex-col gap-1"><!> <div class="font-mono text-sm whitespace-pre-wrap"> </div></div>'),Xa=b('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-amber-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Running tool: <span class="rounded bg-brand-surface-3 px-1 py-0.5 font-mono text-xs font-semibold"> </span>...</span></div>'),Ya=b('<span class="inline-block animate-spin font-bold text-amber-400">⚡</span>'),eo=b('<span class="font-bold text-rose-400" title="Failed">❌</span>'),to=b('<span class="font-bold text-emerald-400" title="Succeeded">✅</span>'),ro=b('<span class="max-w-[180px] truncate font-mono text-xs text-brand-text-muted sm:max-w-[300px] md:max-w-[450px]"> </span>'),no=b('Collapse <span class="text-[10px]">▲</span>',1),ao=b('Expand <span class="text-[10px]">▼</span>',1),oo=b('<div class="flex flex-col gap-1"><span class="font-sans text-[10px] font-bold tracking-wider text-brand-text-muted uppercase">Arguments</span> <pre class="max-h-40 overflow-x-auto rounded border border-brand-border/30 bg-brand-dark/60 p-1.5 font-mono text-[11px] whitespace-pre-wrap text-amber-400"> </pre></div>'),so=b('<pre class="max-h-96 overflow-x-auto rounded border border-brand-border/40 bg-brand-dark/60 p-2 font-mono text-xs whitespace-pre-wrap text-brand-text"> </pre>'),io=b('<div class="animate-pulse p-1 text-xs text-brand-text-muted italic">Running and waiting for output...</div>'),lo=b('<div class="p-1 text-xs text-brand-text-muted italic">No output returned</div>'),co=b('<div class="mt-2 flex flex-col gap-3 overflow-hidden border-t border-brand-border/40 pt-2"><!> <div class="flex flex-col gap-1"><span class="font-sans text-[10px] font-bold tracking-wider text-brand-text-muted uppercase">Output</span> <!></div></div>'),uo=b('<div class="flex max-w-full min-w-[280px] flex-col sm:min-w-[400px] md:min-w-[550px]"><button class="flex w-full items-center justify-between gap-3 rounded p-1 text-left transition-colors hover:bg-brand-surface-3/30 focus:outline-none"><div class="flex flex-1 items-center gap-2 overflow-hidden"><!> <span class="font-mono text-sm font-bold text-brand-text"> </span> <!></div> <div class="flex shrink-0 items-center gap-1 font-sans text-xs font-medium whitespace-nowrap text-brand-text-muted select-none hover:text-brand-text"><!></div></button> <!></div>'),fo=b('<pre class="font-sans text-sm leading-relaxed whitespace-pre-wrap"> </pre>'),vo=b('<span class="text-brand-text-muted italic"> </span>'),bo=b('<span class="ml-1 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan"></span>'),po=b('<div class="flex items-center gap-1.5 rounded bg-brand-blue/20 px-2 py-1 font-mono text-xs text-brand-text select-all"><span>📎</span> <span class="truncate"> </span></div>'),xo=b('<div class="mt-2 flex flex-col gap-1 border-t border-brand-blue/20 pt-2"></div>'),ho=b('<div class="text-sm leading-relaxed whitespace-pre-wrap"><!> <!></div> <!>',1),mo=b("<div> </div>"),go=b("<div><div><!> <!></div></div>"),_o=b('<div class="flex-1 space-y-4 overflow-y-auto overscroll-y-contain p-4"><!> <!></div>'),wo=b('<span class="ml-1 text-xs text-brand-text-muted">(already a Git repository)</span>'),yo=b('<span class="ml-1 text-xs font-medium text-yellow-500">(folder not empty)</span>'),ko=b('<div class="flex items-center gap-4 pl-6 text-xs text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="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.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),So=b('<div class="space-y-1.5"><div class="flex items-center gap-2"><input id="modal-create-remote" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> <label for="modal-create-remote" class="cursor-pointer text-sm text-brand-text select-none"> </label></div> <!></div>'),Co=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-full max-w-sm rounded-lg border border-brand-border bg-brand-surface-2 p-6 text-brand-text"><h3 class="mb-2 text-base font-bold text-brand-text">Folder Already Exists</h3> <p class="mb-4 text-sm text-brand-text-muted">The folder <span class="font-mono text-xs text-brand-text"> </span> already exists. Do you want to initialize a Git repository in it?</p> <div class="mb-6 flex flex-col gap-3.5"><div class="flex items-center gap-2"><input id="modal-git-init" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50"/> <label for="modal-git-init" class="cursor-pointer text-sm text-brand-text select-none disabled:opacity-50">Initialize Git repository <!></label></div> <!></div> <div class="flex justify-end gap-2.5"><button type="button" class="rounded bg-brand-surface-3 px-3.5 py-1.5 text-xs font-semibold 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.5 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Confirm & Create</button></div></div></div>'),To=b('<div class="flex flex-1 flex-col overflow-hidden bg-brand-dark"><!> <div class="flex items-center justify-between border-t border-brand-border p-2"><div class="flex items-center gap-4"><label class="flex cursor-pointer items-center gap-1.5 text-xs text-brand-text-muted select-none hover:text-brand-text"><input type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Hide Thinking</label> <label class="flex cursor-pointer items-center gap-1.5 text-xs text-brand-text-muted select-none hover:text-brand-text"><input type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Hide Tools</label></div> <button class="rounded bg-rose-500 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-rose-600 disabled:cursor-not-allowed disabled:opacity-50" title="Abort">Abort</button></div> <!></div>');function $o(r,t){Qt(t,!0);const f=()=>De(_t,"$piState",Y),s=()=>De(cr,"$availableModels",Y),d=()=>De(Yr,"$gitInitDefaultStore",Y),v=()=>De(Tr,"$activeSessionInfo",Y),p=()=>De(Tn,"$messages",Y),x=()=>De(nn,"$isStreaming",Y),G=()=>De(Rn,"$hasMoreHistory",Y),R=()=>De(Mn,"$isLoadingMoreHistory",Y),[Y,fe]=br(),M=[];function j(o){if(!o)return{cleanContent:"",attachments:[]};const c=o.split(`
|
|
11
|
-
`),h=/^\[Uploaded file: (.+)\]$/,m=[],k=[];for(const g of c){const oe=g.match(h);oe?k.push(oe[1]):m.push(g)}let O=m.join(`
|
|
12
|
-
`).trim();return O==="I have uploaded the following file(s) for you:"&&(O=""),{cleanContent:O,attachments:k}}let L=F(""),ee=F(Ht([])),Ee=F(!1),Ie=F(null),ne=F(null),Pe="",we=F(""),B=F(!1),at=F(null),pe=F(!0),ye=F("private"),ie=F(!1),Ke=X(f),Se=X(s),rt=X(d);it(()=>{e(at)===null&&l(B,e(rt),!0)});let q=F(Ht({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),Ve=X(()=>e(q).exists!==!0&&e(q).matchingRule&&e(pe)),se=null;async function je(o,c=!1){if(se&&clearTimeout(se),o===Pe&&!c)return;if(Pe=o,!o.trim()){l(q,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const m=async()=>{const k=await Fr("");l(ee,k||[],!0)};c?await m():se=setTimeout(m,300);return}const h=async()=>{const[m,k]=await Promise.all([_n(o),Fr(o)]);l(ee,k||[],!0),m?(l(q,{exists:m.exists,isGit:m.isGit,resolvedPath:m.resolvedPath,matchingRule:m.matchingRule||null},!0),m.exists||(l(B,e(at)!==null?e(at):e(rt),!0),l(pe,!0),m.matchingRule&&l(ye,m.matchingRule.visibility,!0))):l(q,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};c?await h():se=setTimeout(h,300)}it(()=>{const o=e(L);je(o,!1)}),it(()=>{if(e(Se).models.length>0&&!e(we)){const o=e(Se).models.find(c=>c.isDefault);o?l(we,`${o.provider}:${o.modelId}`):l(we,`${e(Se).models[0].provider}:${e(Se).models[0].modelId}`)}});function Xe(){e(L).trim()&&(e(q).exists===!0?(l(B,!1),l(pe,!1),e(q).matchingRule&&l(ye,e(q).matchingRule.visibility,!0),l(ie,!0)):jt(e(L).trim(),e(we)||void 0,e(B),e(q).matchingRule?e(pe):void 0,e(q).matchingRule?e(ye):void 0))}let Ce=F(void 0),dt=X(v),ot=F(!0),ht=F(!1),Ye=Ht({});function st(o,c){Ye[o]=!c}function St(o){if(!o)return null;const c=o.trim();if(!c)return null;if(c.startsWith("{"))try{return JSON.parse(c)}catch{}const h={},m=/([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+))/g;let k;for(;(k=m.exec(c))!==null;){const O=k[1],g=k[2]!==void 0?k[2]:k[3]!==void 0?k[3]:k[4];h[O]=g}return Object.keys(h).length>0?h:null}function $t(o,c,h){if(!c)return h?h.trim():"";const m=o.toLowerCase();if(["read","write","edit","ls"].includes(m)){const O=c.path||c.filepath||c.file;if(O)return String(O)}if(m==="bash"){const O=c.command||c.cmd;if(O){const g=String(O).replace(/\s+/g," ").trim();return g.length>50?g.slice(0,47)+"...":g}}if(m==="grep"){const O=c.pattern,g=c.path;if(O)return g?`"${O}" in ${g}`:`"${O}"`}if(m==="find"){const O=c.pattern||c.path;if(O)return String(O)}const k=c.path||c.filepath||c.file||c.name||c.query;return k?String(k):Object.entries(c).filter(([O,g])=>g!==void 0&&g!=="").map(([O,g])=>`${O}=${typeof g=="object"?JSON.stringify(g):g}`).join(" ")}function le(o,c){return o?JSON.stringify(o,null,2):c?c.trim():""}function J(o){let c=o.toolName||"tool",h=o.toolArgs!==void 0?o.toolArgs:"",m=o.toolOutput!==void 0?o.toolOutput:"",k=!!o.isError;if(!h&&!m&&o.content){let N=o.content||"";N.startsWith("Error: ")?(k=!0,N=N.slice(7)):N.startsWith("Tool error: ")&&(k=!0,N=N.slice(12));const H=N.indexOf(`
|
|
13
|
-
`),Le=H!==-1?N.slice(0,H):N;m=H!==-1?N.slice(H+1):"";let ge=Le.trim();ge.startsWith("$ ")&&(ge=ge.slice(2));const Re=ge.indexOf(" ");c=o.toolName||(Re!==-1?ge.slice(0,Re):ge)||"tool",h=Re!==-1?ge.slice(Re+1):""}const O=St(h),g=$t(c,O,h),oe=le(O,h);return{toolName:c,smartTitleArgs:g,fullArgs:oe,toolOutput:m,isError:k}}function ke(o){return o.scrollHeight-o.scrollTop-o.clientHeight<=20}function Te(){e(Ce)&&l(ot,ke(e(Ce)),!0)}function Qe(){e(Ce)&&(e(Ce).scrollTop=e(Ce).scrollHeight)}function y(){(e(ot)||e(ht))&&(Qe(),l(ht,!1))}kr(Qe),it(()=>{if(e(Ce))return e(Ce).addEventListener("scroll",Te),()=>{e(Ce)&&e(Ce).removeEventListener("scroll",Te)}});let $=F(null);it(()=>{const o=e(dt).sessionFile;o!==e($)&&(l($,o,!0),l(ht,!0),setTimeout(Qe,50))});let C=X(()=>{const o=p().filter(h=>h.role==="thinking"&&f().hideThinking?!1:h.role==="tool"&&f().hideTools?xe(h)||!!h.isStreaming:h.role!=="assistant"&&h.role!=="thinking"||h.isStreaming||h.content.trim()!==""),c=o.some(h=>h.isStreaming);if(e(U)&&!c){const h=p().some(m=>m.role==="thinking"&&m.isStreaming);o.push({id:"fallback-loader-message-id",role:"thinking",content:h?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return o}),U=X(x);Jn(()=>{const o=e(C)[e(C).length-1];o&&`${e(C).length}${o.content.length}`,e(Ce)&&l(ot,ke(e(Ce)),!0)}),it(()=>{const o=e(C)[e(C).length-1];o&&`${e(C).length}${o.content.length}`,y()});function de(o){return new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function xe(o){const c=p(),h=c.findIndex(m=>m.id===o.id);if(h===-1)return!1;for(let m=h-1;m>=0;m--)if(c[m].role==="user"){const k=c[m].content?c[m].content.trim():"";return k.startsWith("!")||k.startsWith("!!")}return!1}function ae(o,c){return xe(o)}function Ze(){l(ht,!0),setTimeout(Qe,0)}let ct=X(G),nt=X(R),ve=F(null);function me(){!e(Ce)||e(nt)||!e(ct)||(l(ve,e(Ce).scrollHeight-e(Ce).scrollTop),kn())}it(()=>{if(p().length,e(ve)!==null&&e(Ce)){const o=e(ve);l(ve,null),requestAnimationFrame(()=>{e(Ce)&&(e(Ce).scrollTop=e(Ce).scrollHeight-o)})}});var ut={forceScrollToBottom:Ze},vt=To(),Ct=a(vt);{var It=o=>{var c=Ea();u(o,c)},At=o=>{var c=Ma(),h=a(c),m=i(a(h),6);{var k=g=>{var oe=Ra(),N=a(oe,!0);n(oe),A(()=>V(N,e(Ke).error)),u(g,oe)};w(m,g=>{e(Ke).error&&g(k)})}var O=i(m,2);n(h),n(c),E("click",O,()=>{Xn(()=>Promise.resolve().then(()=>Sa),void 0,import.meta.url).then(g=>g.connect())}),u(o,c)},bt=o=>{var c=Aa();u(o,c)},ce=o=>{var c=Ga(),h=a(c),m=a(h),k=a(m),O=a(k);n(k),Oe(6),n(m);var g=i(m,2),oe=a(g),N=i(a(oe),2),H=a(N);Me(H),Gt(H,T=>l(Ie,T),()=>e(Ie));var Le=i(H,2);{var ge=T=>{var K=Da();Ft(K,21,()=>e(ee),Wt,(Q,z)=>{var S=Fa(),W=a(S,!0);n(S),A(()=>V(W,e(z))),E("click",S,()=>{l(L,e(z),!0),je(e(z),!0),e(Ie)?.focus()}),u(Q,S)}),n(K),u(T,K)};w(Le,T=>{e(Ee)&&e(ee).length>0&&T(ge)})}n(N),Gt(N,T=>l(ne,T),()=>e(ne));var Re=i(N,2);{var Fe=T=>{var K=Ua(),Q=i(a(K));{var z=S=>{var W=Pa();u(S,W)};w(Q,S=>{e(q).isGit&&S(z)})}n(K),u(T,K)},Je=T=>{var K=Oa();u(T,K)};w(Re,T=>{e(q).exists===!0?T(Fe):T(Je,-1)})}n(oe);var Be=i(oe,2),te=i(a(Be),2);{var Z=T=>{var K=Na();Ft(K,21,()=>e(Se).models,Wt,(Q,z)=>{var S=La(),W=a(S);n(S);var Ue={};A(()=>{V(W,`${e(z).label??""}${e(z).isDefault?" (default)":""}`),Ue!==(Ue=`${e(z).provider}:${e(z).modelId}`)&&(S.value=S.__value=`${e(z).provider}:${e(z).modelId}`)}),u(Q,S)}),n(K),Ar(K,()=>e(we),Q=>l(we,Q)),u(T,K)},_=T=>{var K=Ha();Me(K),zt(K,()=>e(we),Q=>l(we,Q)),u(T,K)};w(te,T=>{e(Se).models.length>0?T(Z):T(_,-1)})}n(Be);var D=i(Be,2);{var he=T=>{var K=Ba(),Q=a(K),z=a(Q);Me(z);var S=i(z,2),W=a(S);n(S),n(Q);var Ue=i(Q,2);{var Ne=We=>{var Dt=ja(),Pt=i(a(Dt),2),Lt=a(Pt);Me(Lt),Lt.value=Lt.__value="private",Oe(),n(Pt);var er=i(Pt,2),Bt=a(er);Me(Bt),Bt.value=Bt.__value="public",Oe(),n(er),n(Dt),qt(M,[],Lt,()=>e(ye),tr=>l(ye,tr)),qt(M,[],Bt,()=>e(ye),tr=>l(ye,tr)),u(We,Dt)};w(Ue,We=>{e(pe)&&We(Ne)})}n(K),A(()=>V(W,`Create remote ${e(q).matchingRule.provider??""} repository`)),Ot(z,()=>e(pe),We=>l(pe,We)),u(T,K)};w(D,T=>{e(q).exists!==!0&&e(q).matchingRule&&T(he)})}var ue=i(D,2);{var be=T=>{var K=Wa(),Q=a(K);Me(Q),Oe(2),n(K),E("change",Q,z=>{l(at,z.currentTarget.checked,!0)}),Ot(Q,()=>e(B),z=>l(B,z)),u(T,K)};w(ue,T=>{e(q).exists!==!0&&(!e(q).matchingRule||!e(pe))&&T(be)})}var re=i(ue,2);n(g),n(h),n(c),A((T,K)=>{_e(O,"src",T),gt(H,1,`w-full rounded border px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none ${e(Ve)?"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-surface-3 focus:border-brand-blue"}`),re.disabled=K},[()=>ir("/logo.svg"),()=>!e(L).trim()]),Jt("submit",g,T=>{T.preventDefault(),Xe()}),Jt("focus",H,()=>{l(Ee,!0),je(e(L),!0)}),Jt("blur",H,T=>{e(ne)&&e(ne).contains(T.relatedTarget)||l(Ee,!1)}),E("keydown",H,T=>{T.key==="Escape"&&l(Ee,!1)}),zt(H,()=>e(L),T=>l(L,T)),u(o,c)},Ae=o=>{var c=za();u(o,c)},mt=o=>{var c=_o(),h=a(c);{var m=O=>{var g=Va(),oe=a(g),N=a(oe);{var H=ge=>{var Re=Rt("Loading older messages...");u(ge,Re)},Le=ge=>{var Re=Rt("Load older messages");u(ge,Re)};w(N,ge=>{e(nt)?ge(H):ge(Le,-1)})}n(oe),n(g),A(()=>oe.disabled=e(nt)),E("click",oe,me),u(O,g)};w(h,O=>{e(ct)&&O(m)})}var k=i(h,2);Ft(k,17,()=>e(C),O=>O.id,(O,g)=>{var oe=go(),N=a(oe),H=a(N);{var Le=te=>{var Z=wr(),_=kt(Z);{var D=re=>{var T=qa();u(re,T)},he=re=>{var T=Ja();u(re,T)},ue=re=>{var T=Ka();u(re,T)},be=re=>{var T=Za(),K=a(T);{var Q=W=>{var Ue=Qa();u(W,Ue)};w(K,W=>{e(g).isStreaming&&W(Q)})}var z=i(K,2),S=a(z,!0);n(z),n(T),A(()=>V(S,e(g).content)),u(re,T)};w(_,re=>{e(g).content==="FALLBACK_THINKING_LOADER"?re(D):e(g).content==="FALLBACK_LOADER"?re(he,1):f().hideThinking?re(ue,2):re(be,-1)})}u(te,Z)},ge=te=>{var Z=wr(),_=kt(Z);{var D=be=>{var re=Xa(),T=i(a(re),2),K=i(a(T)),Q=a(K,!0);n(K),Oe(),n(T),n(re),A(()=>V(Q,e(g).toolName||"agent")),u(be,re)},he=X(()=>f().hideTools&&!xe(e(g))),ue=be=>{const re=X(()=>J(e(g))),T=X(()=>Ye[e(g).id]!==void 0?Ye[e(g).id]:ae(e(g),e(C)));var K=uo(),Q=a(K),z=a(Q),S=a(z);{var W=ze=>{var ft=Ya();u(ze,ft)},Ue=ze=>{var ft=eo();u(ze,ft)},Ne=ze=>{var ft=to();u(ze,ft)};w(S,ze=>{e(g).isStreaming?ze(W):e(re).isError?ze(Ue,1):ze(Ne,-1)})}var We=i(S,2),Dt=a(We,!0);n(We);var Pt=i(We,2);{var Lt=ze=>{var ft=ro(),or=a(ft,!0);n(ft),A(()=>{_e(ft,"title",e(re).smartTitleArgs),V(or,e(re).smartTitleArgs)}),u(ze,ft)};w(Pt,ze=>{e(re).smartTitleArgs&&ze(Lt)})}n(z);var er=i(z,2),Bt=a(er);{var tr=ze=>{var ft=no();Oe(),u(ze,ft)},Pr=ze=>{var ft=ao();Oe(),u(ze,ft)};w(Bt,ze=>{e(T)?ze(tr):ze(Pr,-1)})}n(er),n(Q);var Ur=i(Q,2);{var $r=ze=>{var ft=co(),or=a(ft);{var He=Et=>{var Ut=oo(),Ir=i(a(Ut),2),Dn=a(Ir,!0);n(Ir),n(Ut),A(()=>V(Dn,e(re).fullArgs)),u(Et,Ut)};w(or,Et=>{e(re).fullArgs&&e(re).fullArgs!=="{}"&&Et(He)})}var xt=i(or,2),Nt=i(a(xt),2);{var Or=Et=>{var Ut=so(),Ir=a(Ut,!0);n(Ut),A(()=>V(Ir,e(re).toolOutput)),u(Et,Ut)},pr=Et=>{var Ut=io();u(Et,Ut)},Fn=Et=>{var Ut=lo();u(Et,Ut)};w(Nt,Et=>{e(re).toolOutput?Et(Or):e(g).isStreaming?Et(pr,1):Et(Fn,-1)})}n(xt),n(ft),u(ze,ft)};w(Ur,ze=>{e(T)&&ze($r)})}n(K),A(()=>V(Dt,e(re).toolName)),E("click",Q,()=>st(e(g).id,e(T))),u(be,K)};w(_,be=>{e(he)?be(D):be(ue,-1)})}u(te,Z)},Re=te=>{var Z=fo(),_=a(Z,!0);n(Z),A(()=>V(_,e(g).content)),u(te,Z)},Fe=te=>{const Z=X(()=>j(e(g).content));var _=ho(),D=kt(_),he=a(D);{var ue=S=>{var W=Rt();A(()=>V(W,e(Z).cleanContent)),u(S,W)},be=S=>{var W=vo(),Ue=a(W);n(W),A(()=>V(Ue,`Shared file${e(Z).attachments.length>1?"s":""} with agent:`)),u(S,W)},re=S=>{var W=Rt();A(()=>V(W,e(g).content||(e(g).isStreaming?"Thinking...":""))),u(S,W)};w(he,S=>{e(Z).cleanContent?S(ue):e(Z).attachments.length>0?S(be,1):S(re,-1)})}var T=i(he,2);{var K=S=>{var W=bo();u(S,W)};w(T,S=>{e(g).isStreaming&&e(U)&&S(K)})}n(D);var Q=i(D,2);{var z=S=>{var W=xo();Ft(W,21,()=>e(Z).attachments,Wt,(Ue,Ne)=>{var We=po(),Dt=i(a(We),2),Pt=a(Dt,!0);n(Dt),n(We),A(()=>{_e(Dt,"title",e(Ne)),V(Pt,e(Ne))}),u(Ue,We)}),n(W),u(S,W)};w(Q,S=>{e(Z).attachments.length>0&&S(z)})}u(te,_)};w(H,te=>{e(g).role==="thinking"?te(Le):e(g).role==="tool"?te(ge,1):e(g).role==="assistant"&&e(g).content!==""?te(Re,2):te(Fe,-1)})}var Je=i(H,2);{var Be=te=>{var Z=mo(),_=a(Z,!0);n(Z),A(D=>{gt(Z,1,`mt-1 text-xs opacity-50 ${e(g).role==="user"?"text-brand-text-muted":e(g).role==="assistant"?"text-brand-purple":"text-brand-text-muted"}`),V(_,D)},[()=>de(e(g).timestamp)]),u(te,Z)};w(Je,te=>{e(g).role!=="thinking"&&e(g).role!=="tool"&&te(Be)})}n(N),n(oe),A(te=>{gt(oe,1,`flex ${e(g).role==="user"?"justify-end":"justify-start"}`),gt(N,1,`max-w-[85%] rounded-lg px-4 py-3 ${te??""}`)},[()=>e(g).role==="user"?"bg-brand-blue/80 text-brand-text":e(g).role==="thinking"?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":e(g).role==="tool"?f().hideTools&&!xe(e(g))?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":`border-l-2 bg-brand-surface-2 font-mono text-sm text-brand-text ${e(g).isStreaming?"border-amber-400":e(g).isError?"border-rose-400":"border-emerald-400"}`:e(g).role==="assistant"?"border-l-2 border-brand-purple bg-brand-purple/10 text-brand-text":e(g).content===""&&e(g).isStreaming?"bg-brand-surface-3 text-brand-text-muted italic":"bg-brand-surface-2 text-brand-text"]),u(O,oe)}),n(c),Gt(c,O=>l(Ce,O),()=>e(Ce)),u(o,c)};w(Ct,o=>{e(Ke).connecting?o(It):e(Ke).connected?!e(dt).sessionFile&&typeof window<"u"&&window.location.hash?o(bt,2):e(dt).sessionFile?e(C).length===0?o(Ae,4):o(mt,-1):o(ce,3):o(At,1)})}var Ge=i(Ct,2),pt=a(Ge),wt=a(pt),qe=a(wt);Me(qe),Oe(),n(wt);var yt=i(wt,2),I=a(yt);Me(I),Oe(),n(yt),n(pt);var P=i(pt,2);n(Ge);var $e=i(Ge,2);{var et=o=>{var c=Co(),h=a(c),m=i(a(h),2),k=i(a(m)),O=a(k,!0);n(k),Oe(),n(m);var g=i(m,2),oe=a(g),N=a(oe);Me(N);var H=i(N,2),Le=i(a(H));{var ge=_=>{var D=wo();u(_,D)},Re=_=>{var D=yo();u(_,D)};w(Le,_=>{e(q).isGit?_(ge):_(Re,-1)})}n(H),n(oe);var Fe=i(oe,2);{var Je=_=>{var D=So(),he=a(D),ue=a(he);Me(ue);var be=i(ue,2),re=a(be);n(be),n(he);var T=i(he,2);{var K=Q=>{var z=ko(),S=i(a(z),2),W=a(S);Me(W),W.value=W.__value="private",Oe(),n(S);var Ue=i(S,2),Ne=a(Ue);Me(Ne),Ne.value=Ne.__value="public",Oe(),n(Ue),n(z),qt(M,[],W,()=>e(ye),We=>l(ye,We)),qt(M,[],Ne,()=>e(ye),We=>l(ye,We)),u(Q,z)};w(T,Q=>{e(pe)&&Q(K)})}n(D),A(()=>V(re,`Create remote ${e(q).matchingRule.provider??""} repository`)),Ot(ue,()=>e(pe),Q=>l(pe,Q)),u(_,D)};w(Fe,_=>{e(q).matchingRule&&_(Je)})}n(g);var Be=i(g,2),te=a(Be),Z=i(te,2);n(Be),n(h),n(c),A(()=>{V(O,e(L)),N.disabled=e(q).isGit}),Ot(N,()=>e(B),_=>l(B,_)),E("click",te,()=>l(ie,!1)),E("click",Z,()=>{l(ie,!1),jt(e(L).trim(),e(we)||void 0,e(B),e(q).matchingRule?e(pe):void 0,e(q).matchingRule?e(ye):void 0)}),u(o,c)};w($e,o=>{e(ie)&&o(et)})}n(vt),A(()=>{zr(qe,f().hideThinking),zr(I,f().hideTools),P.disabled=!e(U)}),E("change",qe,o=>Kr({hideThinking:o.currentTarget.checked})),E("change",I,o=>Kr({hideTools:o.currentTarget.checked})),E("click",P,function(...o){wn?.apply(this,o)}),u(r,vt);var tt=Zt(ut);return fe(),tt}ar(["click","keydown","change"]);var Io=b("<option> </option>"),Eo=b('<div class="mb-3.5"><label for="speech-locale" class="mb-1 block font-medium text-gray-400">Accent / Locale</label> <select id="speech-locale" class="w-full rounded border border-gray-600 bg-gray-950 px-2 py-1.5 text-white focus:border-blue-500 focus:outline-none"></select></div>'),Ro=b('<div class="mt-2 rounded border border-red-900/40 bg-red-950/40 p-2 leading-normal text-red-400"> </div>'),Mo=b(`<div class="fixed inset-0 z-40"></div> <div class="absolute right-0 bottom-14 z-50 w-64 rounded-lg border border-gray-600 bg-gray-800 p-4 text-xs text-white shadow-xl"><h4 class="mb-3 border-b border-gray-700 pb-1.5 font-semibold text-gray-300">Speech Settings</h4> <div class="mb-3.5"><span class="mb-1 block font-medium text-gray-400">Speech-to-Text Engine</span> <div class="flex gap-2"><button type="button">On-Device</button> <button type="button">Cloud AI</button></div> <p class="mt-1 text-[10px] leading-relaxed text-gray-400"> </p></div> <!> <div class="mb-2"><label class="flex cursor-pointer items-center gap-2 py-1"><input type="checkbox" class="rounded border-gray-600 bg-gray-950 text-blue-600 focus:ring-0 focus:ring-offset-0"/> <span class="font-medium text-gray-300">Direct Send (Auto-dispatch)</span></label> <p class="pl-6 text-[10px] leading-relaxed text-gray-400">When enabled, releasing or stopping the microphone immediately sends
|
|
14
|
-
the message.</p></div> <!></div>`,1),Ao=b('<div class="relative flex shrink-0 items-center gap-1 select-none"><button type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-5 w-5"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" x2="12" y1="19" y2="22"></line></svg></button> <button type="button" class="flex h-[48px] w-[28px] items-center justify-center rounded-lg border border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white disabled:cursor-not-allowed disabled:opacity-40" title="Speech Settings"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg></button> <!></div>');function Fo(r,t){Qt(t,!0);let f=Rr(t,"text",15);const s=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null,d=!!s;let v=F(!1),p=F(!1),x=F(!1),G=F(!1),R=F(!1),Y=F("en-US"),fe=F("browser"),M=F(null),j=F(null),L=null,ee=null,Ee=null,Ie=null,ne=null,Pe=[],we="",B=!1;const at=[{code:"en-US",label:"English (US)"},{code:"en-GB",label:"English (UK)"},{code:"en-IN",label:"English (India)"},{code:"en-AU",label:"English (Australia)"},{code:"en-CA",label:"English (Canada)"},{code:"en-ZA",label:"English (South Africa)"}];kr(()=>{const y=localStorage.getItem("wherever-speech-direct-send");y!==null&&l(R,y==="true");const $=localStorage.getItem("wherever-speech-locale");$!==null&&l(Y,$,!0);const C=localStorage.getItem("wherever-speech-engine");return C!==null?l(fe,C,!0):d||l(fe,"cloud"),()=>{if(L)try{L.abort()}catch{}if(Ie)try{Ie.disconnect()}catch{}if(Ee)try{Ee.disconnect()}catch{}if(ne)try{ne.getTracks().forEach(U=>U.stop())}catch{}if(ee)try{ee.close()}catch{}e(j)&&clearTimeout(e(j))}});function pe(){localStorage.setItem("wherever-speech-direct-send",String(e(R))),localStorage.setItem("wherever-speech-locale",e(Y)),localStorage.setItem("wherever-speech-engine",e(fe))}function ye(){const y=localStorage.getItem("wherever-config");if(y){const $=JSON.parse(y),C=window.location.protocol==="https:"?"https:":"http:",U=$.host.startsWith("http")?$.host.replace(/^wss?:\/\//,""):$.host;return`${C}//${U}:${$.port}`}return`${window.location.protocol}//${window.location.host}`}function ie(){try{const y=localStorage.getItem("wherever-config");if(y)return JSON.parse(y).token||""}catch{}return""}function Ke(){try{const y=window.AudioContext||window.webkitAudioContext;if(!y)return;const $=new y,C=$.createOscillator(),U=$.createGain();C.type="sine",C.frequency.setValueAtTime(400,$.currentTime),U.gain.setValueAtTime(.08,$.currentTime),U.gain.exponentialRampToValueAtTime(.001,$.currentTime+.12),C.connect(U),U.connect($.destination),C.start(),C.stop($.currentTime+.12)}catch(y){console.warn("Could not play audio beep feedback:",y)}}function Se(y,$,C){if($===C)return y;const U=$/C,de=Math.round(y.length/U),xe=new Float32Array(de);let ae=0,Ze=0;for(;ae<xe.length;){const ct=Math.round((ae+1)*U);let nt=0,ve=0;for(let me=Ze;me<ct&&me<y.length;me++)nt+=y[me],ve++;xe[ae]=ve>0?nt/ve:0,ae++,Ze=ct}return xe}function rt(){if(d)try{L=new s,L.continuous=!0,L.interimResults=!0,L.lang=e(Y),L.onstart=()=>{l(v,!0),l(p,!1),Ke()},L.onresult=y=>{let $="",C="";for(let de=y.resultIndex;de<y.results.length;++de){const xe=y.results[de];xe.isFinal?$+=xe[0].transcript:C+=xe[0].transcript}const U=($+C).trim();U&&(B=!0,f(we+(we?" ":"")+U))},L.onerror=y=>{console.error("Browser speech recognition error:",y.error),y.error!=="no-speech"&&l(M,`Error: ${y.error}`),q()},L.onend=()=>{l(v,!1),e(R)&&B&&t.onSend&&setTimeout(()=>{f().trim()&&t.onSend()},50)},L.start(),navigator.vibrate&&navigator.vibrate(40)}catch(y){console.error("Failed to start browser speech recognition:",y),l(M,"Failed to start browser recording"),l(v,!1)}}function q(){if(L)try{L.stop()}catch{}l(v,!1)}async function Ve(){try{const y=await navigator.mediaDevices.getUserMedia({audio:!0});ne=y,Pe=[];const $=window.AudioContext||window.webkitAudioContext;ee=new $,Ee=ee.createMediaStreamSource(y),Ie=ee.createScriptProcessor(4096,1,1),Ie.onaudioprocess=C=>{const U=C.inputBuffer.getChannelData(0);Pe.push(new Float32Array(U))},Ee.connect(Ie),Ie.connect(ee.destination),l(v,!0),l(p,!1),Ke(),navigator.vibrate&&navigator.vibrate(40)}catch(y){console.error("Failed to start cloud audio recording:",y),l(M,y.message||"Microphone access denied",!0),l(v,!1),l(p,!1)}}function se(){if(e(v)){if(l(v,!1),l(p,!0),Ie){try{Ie.disconnect()}catch{}Ie.onaudioprocess=null}if(Ee)try{Ee.disconnect()}catch{}if(ne)try{ne.getTracks().forEach(y=>y.stop())}catch{}je()}}async function je(){try{if(Pe.length===0){l(p,!1);return}l(M,null);let y=0;for(const vt of Pe)y+=vt.length;const $=new Float32Array(y);let C=0;for(const vt of Pe)$.set(vt,C),C+=vt.length;const U=ee?ee.sampleRate:48e3,de=16e3,xe=Se($,U,de),ae=Ye(xe,1,de,1,16),Ze=new Blob([ae],{type:"audio/wav"}),ct=ye(),nt=ie(),ve=`${ct}/session/transcribe${nt?`?token=${encodeURIComponent(nt)}`:""}`,me=await fetch(ve,{method:"POST",body:Ze,headers:{"Content-Type":"application/octet-stream"}}),ut=await me.json();if(!me.ok)throw new Error(ut.error||`HTTP ${me.status}`);ut.text&&ut.text.trim()&&(B=!0,f(we+(we?" ":"")+ut.text.trim()),e(R)&&t.onSend&&setTimeout(()=>{f().trim()&&t.onSend()},50))}catch(y){console.error("Cloud transcription request failed:",y),l(M,y.message||"Cloud API failed",!0)}finally{if(l(p,!1),ee){try{ee.close()}catch{}ee=null}}}function Xe(){t.disabled||e(v)||e(p)||(l(M,null),B=!1,we=f(),e(fe)==="cloud"?Ve():rt())}function Ce(){e(fe)==="cloud"?se():q()}function dt(y){if(y.button===0&&!t.disabled){if(y.preventDefault(),e(v)){Ce();return}l(x,!1),l(j,setTimeout(()=>{l(x,!0),Xe()},350),!0)}}function ot(y){e(j)&&(clearTimeout(e(j)),l(j,null)),e(x)?(l(x,!1),Ce()):e(v)||Xe()}function ht(){e(j)&&(clearTimeout(e(j)),l(j,null)),e(x)&&(l(x,!1),Ce())}function Ye(y,$,C,U,de){const xe=new ArrayBuffer(44+y.length*2),ae=new DataView(xe);return St(ae,0,"RIFF"),ae.setUint32(4,36+y.length*2,!0),St(ae,8,"WAVE"),St(ae,12,"fmt "),ae.setUint32(16,16,!0),ae.setUint16(20,U,!0),ae.setUint16(22,$,!0),ae.setUint32(24,C,!0),ae.setUint32(28,C*$*(de/8),!0),ae.setUint16(32,$*(de/8),!0),ae.setUint16(34,de,!0),St(ae,36,"data"),ae.setUint32(40,y.length*2,!0),st(ae,44,y),xe}function st(y,$,C){for(let U=0;U<C.length;U++,$+=2){let de=Math.max(-1,Math.min(1,C[U]));y.setInt16($,de<0?de*32768:de*32767,!0)}}function St(y,$,C){for(let U=0;U<C.length;U++)y.setUint8($+U,C.charCodeAt(U))}var $t=Ao(),le=a($t),J=i(le,2),ke=a(J);n(J);var Te=i(J,2);{var Qe=y=>{var $=Mo(),C=kt($),U=i(C,2),de=i(a(U),2),xe=i(a(de),2),ae=a(xe),Ze=i(ae,2);n(xe);var ct=i(xe,2),nt=a(ct,!0);n(ct),n(de);var ve=i(de,2);{var me=bt=>{var ce=Eo(),Ae=i(a(ce),2);Ft(Ae,21,()=>at,Wt,(mt,Ge)=>{var pt=Io(),wt=a(pt,!0);n(pt);var qe={};A(()=>{V(wt,e(Ge).label),qe!==(qe=e(Ge).code)&&(pt.value=(pt.__value=e(Ge).code)??"")}),u(mt,pt)}),n(Ae),n(ce),E("change",Ae,pe),Ar(Ae,()=>e(Y),mt=>l(Y,mt)),u(bt,ce)};w(ve,bt=>{e(fe)==="browser"&&bt(me)})}var ut=i(ve,2),vt=a(ut),Ct=a(vt);Me(Ct),Oe(2),n(vt),Oe(2),n(ut);var It=i(ut,2);{var At=bt=>{var ce=Ro(),Ae=a(ce,!0);n(ce),A(()=>V(Ae,e(M))),u(bt,ce)};w(It,bt=>{e(M)&&bt(At)})}n(U),A(()=>{ae.disabled=!d,gt(ae,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40
|
|
15
|
-
${e(fe)==="browser"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),gt(Ze,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors
|
|
16
|
-
${e(fe)==="cloud"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),V(nt,e(fe)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),E("click",C,()=>l(G,!1)),E("click",ae,()=>{l(fe,"browser"),pe()}),E("click",Ze,()=>{l(fe,"cloud"),pe()}),E("change",Ct,pe),Ot(Ct,()=>e(R),bt=>l(R,bt)),u(y,$)};w(Te,y=>{e(G)&&y(Qe)})}n($t),A(()=>{le.disabled=t.disabled&&!e(v)&&!e(p)||e(p),gt(le,1,`flex h-[48px] w-[48px] items-center justify-center rounded-lg border transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-40
|
|
17
|
-
${e(v)?"animate-pulse border-red-500 bg-red-600 text-white":e(p)?"cursor-wait border-amber-500 bg-amber-600 text-white":"border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white"}`),_e(le,"title",e(v)?"Recording (release/tap to stop)...":e(p)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),J.disabled=t.disabled&&!e(v)&&!e(p)||e(p),gt(ke,0,`h-4 w-4 transition-transform duration-200 ${e(G)?"rotate-45 text-white":""}`)}),E("pointerdown",le,dt),E("pointerup",le,ot),Jt("pointercancel",le,ht),E("click",J,()=>l(G,!e(G))),u(r,$t),Zt()}ar(["pointerdown","pointerup","click","change"]);var Do=b('<span class="inline-block h-1.5 w-1.5 animate-ping rounded-full bg-amber-400"></span> <span>Connecting to remote server...</span>',1),Po=b('<span class="text-rose-400">⚠️</span> <span class="text-rose-400/80"> </span>',1),Uo=b('<span class="inline-block h-1.5 w-1.5 rounded-full bg-brand-surface-3"></span> <span>Disconnected from remote server</span>',1),Oo=b('<div class="mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none"><!></div>'),Lo=b('<div class="flex items-center"><button type="button" class="flex w-full items-center justify-between rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-2.5 text-sm text-brand-text-muted transition-all hover:bg-brand-surface-3 hover:text-brand-text"><span class="flex items-center gap-2"><span> </span> <span><!></span></span> <span class="rounded bg-brand-surface-3 px-2 py-1 text-xs font-medium text-brand-text transition-colors hover:bg-brand-surface-2">Expand ▲</span></button></div>'),No=b('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span>'),Ho=b('<a target="_blank" class="ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80">[Test Link]</a>'),jo=b('<span class="flex items-center gap-1 text-[10px] font-medium text-rose-400"><span class="max-w-[120px] truncate"> </span> <!></span>'),Bo=b('<span class="text-emerald-400">✓</span>'),Wo=b('<div class="flex items-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-xs"><span class="max-w-[150px] truncate font-medium text-brand-text"> </span> <!> <button type="button" class="ml-1 font-bold text-brand-text-muted hover:text-brand-text">×</button></div>'),Go=b('<div class="mb-3 flex flex-wrap gap-2"></div>'),zo=b('<button type="button" class="flex h-[40px] w-full items-center justify-center rounded-lg border border-brand-border bg-brand-surface-2 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50" title="Attach file (image or document)">📎</button> <input type="file" multiple="" class="hidden"/>',1),Vo=b('<button type="button" class="flex h-[40px] w-full items-center justify-center rounded-lg bg-amber-500 text-xs font-medium text-brand-text transition-colors hover:bg-amber-600">Unqueue</button>'),qo=b('<button type="submit" class="flex h-[40px] w-full items-center justify-center rounded-lg bg-gradient-to-r from-brand-cyan to-brand-blue text-xs font-medium text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:bg-brand-surface-3 disabled:from-brand-surface-3 disabled:to-brand-surface-3 disabled:opacity-50"><!></button>'),Jo=b('<span class="hidden font-mono opacity-60 sm:inline">Shift+Enter to send</span>'),Ko=b('<!> <form class="flex items-stretch gap-3"><div class="min-w-0 flex-1"><textarea></textarea></div> <div class="flex w-[80px] shrink-0 flex-col justify-end gap-2"><!> <div class="flex w-full justify-center"><!></div> <!></div></form> <div class="mt-2 flex items-center justify-between px-1 text-[11px] text-brand-text-muted select-none"><label class="flex cursor-pointer items-center gap-1.5 hover:text-brand-text"><input type="checkbox" class="rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-0 focus:ring-offset-0"/> <span>Press Enter to send</span></label> <div class="flex items-center gap-3"><button type="button" class="rounded bg-brand-surface-3/50 px-2 py-0.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text">Collapse ▽</button> <!></div></div>',1),Qo=b('<div class="border-t border-brand-border p-4"><!> <!></div>');function Zo(r,t){Qt(t,!0);const f=()=>De(nn,"$isStreaming",x),s=()=>De(on,"$isReadOnly",x),d=()=>De(Tr,"$activeSessionInfo",x),v=()=>De(Cr,"$isConnected",x),p=()=>De(_t,"$piState",x),[x,G]=br();let R=Rr(t,"showAttach",3,!0),Y=Rr(t,"searchMode",3,!1),fe=Rr(t,"searchConfigured",3,!1),M=F(""),j=F(!0),L=F(null),ee=F(null),Ee=F(!1),Ie=F(void 0),ne=F(Ht([])),Pe=X(f),we=X(s),B=X(d),at=X(v),pe=X(p),ye=X(()=>Y()?t.disabled||!e(at)||!fe():t.disabled||e(we)||!e(B).sessionId||!!e(L)),ie=X(()=>e(ne).some(J=>J.uploading)),Ke=X(()=>!e(ye)&&!e(ie)&&(e(M).trim().length>0||e(ne).length>0)),Se=F(void 0);kr(()=>{const J=localStorage.getItem("wherever-enter-to-send");J!==null&&l(j,J==="true")});function rt(){e(Ee)&&l(Ee,!1),e(Se)?.focus()}function q(){l(j,!e(j)),localStorage.setItem("wherever-enter-to-send",String(e(j)))}it(()=>{e(Se)&&(e(M),e(Se).style.height="auto",e(Se).style.height=`${e(Se).scrollHeight}px`)}),it(()=>{!e(ye)&&e(Se)&&e(Se).focus()}),it(()=>{e(L)&&l(M,e(L),!0)}),it(()=>{!e(Pe)&&e(L)&&(Vr(e(L)),l(M,""),l(L,null),l(ee,null),t.onSend?.())});function Ve(){const J=e(ee)??e(L)??"";l(L,null),l(ee,null),l(M,J,!0),setTimeout(()=>{e(Se)?.focus(),e(Se)&&(e(Se).selectionStart=e(Se).selectionEnd=e(M).length)},0)}async function se(J){const ke=J.target;if(!ke.files)return;const Te=Array.from(ke.files);ke.value="";const Qe=e(ne).length;l(ne,[...e(ne),...Te.map(y=>({name:y.name,uploading:!0}))],!0);for(let y=0;y<Te.length;y++){const $=Te[y],C=Qe+y;try{if(!e(B).sessionId)throw new Error("No active session");const U=await An(e(B).sessionId,$);l(ne,e(ne).map((de,xe)=>xe===C?{name:$.name,path:U.savedPath,uploading:!1}:de),!0)}catch(U){const de=U.message||"Failed to upload";console.error("File upload error details:",U);let xe="";try{const ae=Xt(),Ze=Yt();xe=`${ae}/health${Ze?`?token=${encodeURIComponent(Ze)}`:""}`}catch{}l(ne,e(ne).map((ae,Ze)=>Ze===C?{name:$.name,error:de,url:xe,uploading:!1}:ae),!0)}}}function je(J){l(ne,e(ne).filter((ke,Te)=>Te!==J),!0)}function Xe(){const J=e(M).trim();if(Y()){if(!J||e(ye))return;t.onSubmit?.(J),l(M,""),t.onSend?.();return}if(!J&&e(ne).length===0)return;let ke=J;if(e(ne).length>0){const Te=e(ne).filter(Qe=>Qe.path);if(Te.length>0){const Qe=Te.map(y=>`[Uploaded file: ${y.path}]`).join(`
|
|
18
|
-
`);ke?ke+=`
|
|
19
|
-
|
|
20
|
-
`+Qe:ke=`I have uploaded the following file(s) for you:
|
|
21
|
-
${Qe}`}}if(J.startsWith("/")&&e(ne).length===0){const Te=J.toLowerCase();if(Te==="/new"||Te==="/reset"){if(e(B).cwd){jt(e(B).cwd,e(B).model||void 0),l(M,""),l(L,null);return}}else if(Te==="/clear"){Sn(),l(M,""),l(L,null);return}else if(Te==="/leave"||Te==="/exit"){Mt(),l(M,""),l(L,null);return}}e(Pe)?(l(L,ke,!0),l(ee,ke,!0),l(ne,[],!0)):(Vr(ke),l(M,""),l(ne,[],!0),t.onSend?.())}function Ce(J){J.key==="Enter"&&(e(j)?J.shiftKey||(J.preventDefault(),Xe()):J.shiftKey&&(J.preventDefault(),Xe()))}var dt={focusInput:rt},ot=Qo(),ht=a(ot);{var Ye=J=>{var ke=Oo(),Te=a(ke);{var Qe=C=>{var U=Do();Oe(2),u(C,U)},y=C=>{var U=Po(),de=i(kt(U),2),xe=a(de,!0);n(de),A(()=>V(xe,e(pe).error)),u(C,U)},$=C=>{var U=Uo();Oe(2),u(C,U)};w(Te,C=>{e(pe).connecting?C(Qe):e(pe).error?C(y,1):e(at)||C($,2)})}n(ke),u(J,ke)};w(ht,J=>{(!e(at)||e(pe).connecting||e(pe).error)&&J(Ye)})}var st=i(ht,2);{var St=J=>{var ke=Lo(),Te=a(ke),Qe=a(Te),y=a(Qe),$=a(y,!0);n(y);var C=i(y,2),U=a(C);{var de=ve=>{var me=Rt();A(()=>V(me,t.placeholder??"Search the web...")),u(ve,me)},xe=ve=>{var me=Rt("Message is queued...");u(ve,me)},ae=ve=>{var me=Rt("Agent is working (click to type next)...");u(ve,me)},Ze=ve=>{var me=Rt("Read-only mode");u(ve,me)},ct=ve=>{var me=Rt("Select a session first...");u(ve,me)},nt=ve=>{var me=Rt("Tap to type a message...");u(ve,me)};w(U,ve=>{Y()?ve(de):e(L)?ve(xe,1):e(Pe)?ve(ae,2):e(we)?ve(Ze,3):e(B).sessionId?ve(nt,-1):ve(ct,4)})}n(C),n(Qe),Oe(2),n(Te),n(ke),A(()=>V($,Y()?"🔍":"💬")),E("click",Te,()=>{l(Ee,!1),setTimeout(()=>e(Se)?.focus(),50)}),u(J,ke)},$t=J=>{var ke=Ko(),Te=kt(ke);{var Qe=ce=>{var Ae=Go();Ft(Ae,21,()=>e(ne),Wt,(mt,Ge,pt)=>{var wt=Wo(),qe=a(wt),yt=a(qe,!0);n(qe);var I=i(qe,2);{var P=o=>{var c=No();u(o,c)},$e=o=>{var c=jo(),h=a(c),m=a(h);n(h);var k=i(h,2);{var O=g=>{var oe=Ho();A(()=>_e(oe,"href",e(Ge).url)),u(g,oe)};w(k,g=>{e(Ge).url&&g(O)})}n(c),A(()=>{_e(c,"title",e(Ge).error),V(m,`⚠️ ${e(Ge).error??""}`)}),u(o,c)},et=o=>{var c=Bo();u(o,c)};w(I,o=>{e(Ge).uploading?o(P):e(Ge).error?o($e,1):o(et,-1)})}var tt=i(I,2);n(wt),A(()=>{_e(qe,"title",e(Ge).name),V(yt,e(Ge).name)}),E("click",tt,()=>je(pt)),u(mt,wt)}),n(Ae),u(ce,Ae)};w(Te,ce=>{e(ne).length>0&&ce(Qe)})}var y=i(Te,2),$=a(y),C=a($);Kn(C),_e(C,"rows",1),Gt(C,ce=>l(Se,ce),()=>e(Se)),n($);var U=i($,2),de=a(U);{var xe=ce=>{var Ae=zo(),mt=kt(Ae),Ge=i(mt,2);Gt(Ge,pt=>l(Ie,pt),()=>e(Ie)),A(()=>mt.disabled=e(ye)),E("click",mt,()=>e(Ie)?.click()),E("change",Ge,se),u(ce,Ae)};w(de,ce=>{R()&&!Y()&&ce(xe)})}var ae=i(de,2),Ze=a(ae);Fo(Ze,{get disabled(){return e(ye)},onSend:Xe,get text(){return e(M)},set text(ce){l(M,ce,!0)}}),n(ae);var ct=i(ae,2);{var nt=ce=>{var Ae=Vo();E("click",Ae,Ve),u(ce,Ae)},ve=ce=>{var Ae=qo(),mt=a(Ae);{var Ge=qe=>{var yt=Rt();A(()=>V(yt,t.submitLabel??"Search")),u(qe,yt)},pt=qe=>{var yt=Rt("Queue");u(qe,yt)},wt=qe=>{var yt=Rt("Send");u(qe,yt)};w(mt,qe=>{Y()?qe(Ge):e(Pe)?qe(pt,1):qe(wt,-1)})}n(Ae),A(()=>Ae.disabled=!e(Ke)),u(ce,Ae)};w(ct,ce=>{e(L)?ce(nt):ce(ve,-1)})}n(U),n(y);var me=i(y,2),ut=a(me),vt=a(ut);Me(vt),Oe(2),n(ut);var Ct=i(ut,2),It=a(Ct),At=i(It,2);{var bt=ce=>{var Ae=Jo();u(ce,Ae)};w(At,ce=>{e(j)||ce(bt)})}n(Ct),n(me),A(()=>{C.disabled=e(ye),_e(C,"placeholder",Y()?t.placeholder??"Search the web...":e(Pe)?"Agent is working (type next message...)":e(we)?"Read-only mode":e(B).sessionId?"Type a message...":"Select a session first..."),gt(C,1,`h-full max-h-48 min-h-[120px] w-full resize-none overflow-y-auto rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-3 leading-relaxed placeholder-brand-text-muted focus:border-brand-blue focus:outline-none disabled:opacity-50 ${e(L)?"text-brand-text-muted italic":"text-brand-text"}`),zr(vt,e(j))}),Jt("submit",y,ce=>{ce.preventDefault(),Xe()}),E("keydown",C,Ce),zt(C,()=>e(M),ce=>l(M,ce)),E("change",vt,q),E("click",It,()=>l(Ee,!0)),u(J,ke)};w(st,J=>{e(Ee)?J(St):J($t,-1)})}n(ot),u(r,ot);var le=Zt(dt);return G(),le}ar(["click","keydown","change"]);var Xo=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>'),Yo=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>'),es=b('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),ts=b('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),rs=b("<option> </option>"),ns=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>'),as=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"/>'),os=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>'),ss=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>'),is=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>'),ls=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>'),ds=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>'),cs=b('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),us=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>'),fs=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>'),vs=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),bs=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),ps=b('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),xs=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>'),hs=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>'),ms=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 class="flex-shrink-0"><!></div></div>'),gs=b('<div class="px-3 pb-2"><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> <!></div>'),_s=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>'),ws=b("<option> </option>"),ys=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>'),ks=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"/>'),Ss=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>'),Cs=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>'),Ts=b('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),$s=b('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),Is=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>'),Es=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>'),Rs=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>'),Ms=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 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> <!></div></div> <!> <!> <!>',1);function As(r,t){Qt(t,!0);const f=()=>De(lr,"$sessionFolders",G),s=()=>De(Tr,"$activeSessionInfo",G),d=()=>De(Cr,"$isConnected",G),v=()=>De(cr,"$availableModels",G),p=()=>De(Yr,"$gitInitDefaultStore",G),x=()=>De(an,"$sessionError",G),[G,R]=br(),Y=[];let fe=X(()=>f().folders),M=X(()=>f().loading),j=X(()=>s().sessionFile),L=X(d),ee=X(()=>v().models),Ee=Ht({}),Ie=F(Ht({})),ne=F(null),Pe=F(null),we=F(""),B=F(Ht([]));it(()=>{e(L)&&(dr(),xa(),ha())});function at(o,c,h){if(!h)return!0;const m=h.toLowerCase();return(o.name||"").toLowerCase().includes(m)||o.firstMessage.toLowerCase().includes(m)||c.toLowerCase().includes(m)}it(()=>{const o=e(we),c=e(fe);o?l(B,c.map(h=>({...h,sessions:h.sessions.filter(m=>at(m,h.name,o))})).filter(h=>h.sessions.length>0),!0):(l(B,c,!0),l(Ie,{},!0))});function pe(o){return e(we)?e(Ie)[o]!==void 0?e(Ie)[o]:!0:!!Ee[o]}function ye(o){e(we)?e(Ie)[o]=!pe(o):Ee[o]=!pe(o)}async function ie(o){try{e(j)===o&&(typeof window<"u"&&(window.location.hash=""),Mt()),await Qr(o),e(ne)===o&&l(ne,null),dr()}catch(c){console.error("Failed to delete session:",c)}}async function Ke(o){try{const c=o.sessions.map(h=>h.path);e(j)&&c.includes(e(j))&&(typeof window<"u"&&(window.location.hash=""),Mt()),await Promise.all(o.sessions.map(h=>Qr(h.path))),e(Pe)===o.path&&l(Pe,null),dr()}catch(c){console.error("Failed to delete all sessions of folder:",c)}}function Se(o){e(j)!==o&&(nr(),e(j)?(Mt(),setTimeout(()=>{fr(o)},100)):fr(o))}let rt=F(!1),q=F(""),Ve=F(Ht([])),se=F(!1),je=F(null),Xe=F(null),Ce="",dt=F(""),ot=F(!1),ht=F(null),Ye=F(!0),st=F("private"),St=F(!1),$t=X(p);it(()=>{e(ht)===null&&l(ot,e($t),!0)});let le=F(Ht({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),J=X(()=>e(le).exists!==!0&&e(le).matchingRule&&e(Ye)),ke=null;async function Te(o,c=!1){if(ke&&clearTimeout(ke),o===Ce&&!c)return;if(Ce=o,!o.trim()){l(le,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const m=async()=>{const k=await Fr("");l(Ve,k||[],!0)};c?await m():ke=setTimeout(m,300);return}const h=async()=>{const[m,k]=await Promise.all([_n(o),Fr(o)]);l(Ve,k||[],!0),m?(l(le,{exists:m.exists,isGit:m.isGit,resolvedPath:m.resolvedPath,matchingRule:m.matchingRule||null},!0),m.exists||(l(ot,e(ht)!==null?e(ht):e($t),!0),l(Ye,!0),m.matchingRule&&l(st,m.matchingRule.visibility,!0))):l(le,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};c?await h():ke=setTimeout(h,300)}it(()=>{const o=e(q);Te(o,!1)}),it(()=>{if(e(ee).length>0&&!e(dt)){const o=e(ee).find(c=>c.isDefault);o?l(dt,`${o.provider}:${o.modelId}`):l(dt,`${e(ee)[0].provider}:${e(ee)[0].modelId}`)}});function Qe(){if(e(q).trim())if(e(le).exists===!0)l(ot,!1),l(Ye,!1),e(le).matchingRule&&l(st,e(le).matchingRule.visibility,!0),l(St,!0);else{nr();const o=e(q).trim(),c=e(dt)||void 0,h=e(ot),m=e(le).matchingRule?e(Ye):void 0,k=e(le).matchingRule?e(st):void 0;l(q,""),l(rt,!1),e(j)?(Mt(),setTimeout(()=>{jt(o,c,h,m,k)},100)):jt(o,c,h,m,k)}}function y(){l(St,!1),nr();const o=e(q).trim(),c=e(dt)||void 0,h=e(ot),m=e(le).matchingRule?e(Ye):void 0,k=e(le).matchingRule?e(st):void 0;l(q,""),l(rt,!1),e(j)?(Mt(),setTimeout(()=>{jt(o,c,h,m,k)},100)):jt(o,c,h,m,k)}let $=F(Ht({open:!1,folderPath:"",selected:""}));function C(o){const c=e(ee).find(h=>h.isDefault);l($,{open:!0,folderPath:o,selected:c?`${c.provider}:${c.modelId}`:""},!0)}function U(){e($).open=!1}function de(){if(!e($).open)return;nr();const o=e($).folderPath,c=e($).selected||void 0;U(),e(j)?(Mt(),setTimeout(()=>{jt(o,c)},100)):jt(o,c)}function xe(o){const c=Date.now()-new Date(o).getTime(),h=Math.floor(c/6e4);if(h<1)return"just now";if(h<60)return`${h}m ago`;const m=Math.floor(h/60);return m<24?`${m}h ago`:`${Math.floor(m/24)}d ago`}function ae(o,c=40){return o.length>c?o.slice(0,c)+"...":o}var Ze=Ms(),ct=kt(Ze),nt=a(ct),ve=a(nt),me=a(ve);Me(me);var ut=i(me,2),vt=a(ut);n(ut),n(ve),n(nt);var Ct=i(nt,2),It=a(Ct),At=a(It),bt=a(At),ce=a(bt,!0);n(bt),n(At);var Ae=i(At,2);{var mt=o=>{var c=ls(),h=a(c),m=i(a(h),2),k=a(m);Me(k),Gt(k,_=>l(je,_),()=>e(je));var O=i(k,2);{var g=_=>{var D=Yo();Ft(D,21,()=>e(Ve),Wt,(he,ue)=>{var be=Xo(),re=a(be,!0);n(be),A(()=>V(re,e(ue))),E("click",be,()=>{l(q,e(ue),!0),Te(e(ue),!0),e(je)?.focus()}),u(he,be)}),n(D),u(_,D)};w(O,_=>{e(se)&&e(Ve).length>0&&_(g)})}n(m),Gt(m,_=>l(Xe,_),()=>e(Xe));var oe=i(m,2);{var N=_=>{var D=ts(),he=i(a(D));{var ue=be=>{var re=es();u(be,re)};w(he,be=>{e(le).isGit&&be(ue)})}n(D),u(_,D)};w(oe,_=>{e(le).exists===!0&&_(N)})}n(h);var H=i(h,2),Le=i(a(H),2);{var ge=_=>{var D=ns();Ft(D,21,()=>e(ee),Wt,(he,ue)=>{var be=rs(),re=a(be);n(be);var T={};A(()=>{V(re,`${e(ue).label??""}${e(ue).isDefault?" (default)":""}`),T!==(T=`${e(ue).provider}:${e(ue).modelId}`)&&(be.value=be.__value=`${e(ue).provider}:${e(ue).modelId}`)}),u(he,be)}),n(D),Ar(D,()=>e(dt),he=>l(dt,he)),u(_,D)},Re=_=>{var D=as();Me(D),zt(D,()=>e(dt),he=>l(dt,he)),u(_,D)};w(Le,_=>{e(ee).length>0?_(ge):_(Re,-1)})}n(H);var Fe=i(H,2);{var Je=_=>{var D=ss(),he=a(D),ue=a(he);Me(ue);var be=i(ue,2),re=a(be);n(be),n(he);var T=i(he,2);{var K=Q=>{var z=os(),S=i(a(z),2),W=a(S);Me(W),W.value=W.__value="private",Oe(),n(S);var Ue=i(S,2),Ne=a(Ue);Me(Ne),Ne.value=Ne.__value="public",Oe(),n(Ue),n(z),qt(Y,[],W,()=>e(st),We=>l(st,We)),qt(Y,[],Ne,()=>e(st),We=>l(st,We)),u(Q,z)};w(T,Q=>{e(Ye)&&Q(K)})}n(D),A(()=>V(re,`Create remote ${e(le).matchingRule.provider??""} repository`)),Ot(ue,()=>e(Ye),Q=>l(Ye,Q)),u(_,D)};w(Fe,_=>{e(le).exists!==!0&&e(le).matchingRule&&_(Je)})}var Be=i(Fe,2);{var te=_=>{var D=is(),he=a(D);Me(he),Oe(2),n(D),E("change",he,ue=>{l(ht,ue.currentTarget.checked,!0)}),Ot(he,()=>e(ot),ue=>l(ot,ue)),u(_,D)};w(Be,_=>{e(le).exists!==!0&&(!e(le).matchingRule||!e(Ye))&&_(te)})}var Z=i(Be,2);n(c),A(_=>{gt(k,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 ${e(J)?"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"}`),Z.disabled=_},[()=>!e(q).trim()]),Jt("submit",c,_=>{_.preventDefault(),Qe()}),Jt("focus",k,()=>{l(se,!0),Te(e(q),!0)}),Jt("blur",k,_=>{e(Xe)&&e(Xe).contains(_.relatedTarget)||l(se,!1)}),E("keydown",k,_=>{_.key==="Escape"&&l(se,!1)}),zt(k,()=>e(q),_=>l(q,_)),u(o,c)};w(Ae,o=>{e(rt)&&o(mt)})}n(It);var Ge=i(It,2);{var pt=o=>{var c=ds();u(o,c)},wt=o=>{var c=cs(),h=a(c,!0);n(c),A(()=>V(h,e(we)?"No sessions match your filter":"No sessions found")),u(o,c)},qe=o=>{var c=wr(),h=kt(c);Ft(h,17,()=>e(B),m=>m.path,(m,k)=>{var O=_s(),g=a(O),oe=a(g),N=i(oe,2),H=a(N),Le=a(H,!0);n(H);var ge=i(H,2),Re=a(ge,!0);n(ge),n(N);var Fe=i(N,2),Je=a(Fe,!0);n(Fe),n(g);var Be=i(g,2);{var te=_=>{var D=gs(),he=a(D),ue=a(he),be=i(ue,2),re=a(be);{var T=z=>{var S=us(),W=a(S),Ue=i(W,2);n(S),E("click",W,Ne=>{Ne.stopPropagation(),Ke(e(k))}),E("click",Ue,Ne=>{Ne.stopPropagation(),l(Pe,null)}),u(z,S)},K=z=>{var S=fs();E("click",S,W=>{W.stopPropagation(),l(Pe,e(k).path,!0)}),u(z,S)};w(re,z=>{e(Pe)===e(k).path?z(T):z(K,-1)})}n(be),n(he);var Q=i(he,2);Ft(Q,17,()=>e(k).sessions,z=>z.path,(z,S)=>{var W=ms(),Ue=a(W),Ne=a(Ue);{var We=He=>{var xt=vs();u(He,xt)},Dt=He=>{var xt=bs();u(He,xt)};w(Ne,He=>{e(S).isActive?He(We):He(Dt,-1)})}var Pt=i(Ne,2),Lt=a(Pt),er=a(Lt,!0);n(Lt);var Bt=i(Lt,2),tr=a(Bt);n(Bt),n(Pt);var Pr=i(Pt,2);{var Ur=He=>{var xt=ps(),Nt=a(xt,!0);n(xt),A(()=>V(Nt,e(S).clientCount)),u(He,xt)};w(Pr,He=>{e(S).clientCount>0&&He(Ur)})}n(Ue);var $r=i(Ue,2),ze=a($r);{var ft=He=>{var xt=xs(),Nt=a(xt),Or=i(Nt,2);n(xt),E("click",Nt,pr=>{pr.stopPropagation(),ie(e(S).path)}),E("click",Or,pr=>{pr.stopPropagation(),l(ne,null)}),u(He,xt)},or=He=>{var xt=hs();E("click",xt,Nt=>{Nt.stopPropagation(),l(ne,e(S).path,!0)}),u(He,xt)};w(ze,He=>{e(ne)===e(S).path?He(ft):He(or,-1)})}n($r),n(W),A((He,xt,Nt)=>{gt(W,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 ${e(j)===e(S).path?"bg-brand-surface-3":""}`),_e(Ue,"href",`#${He??""}`),V(er,xt),V(tr,`${Nt??""} · ${e(S).messageCount??""}
|
|
22
|
-
msgs`)},[()=>encodeURIComponent(e(S).id),()=>e(S).name||ae(e(S).firstMessage)||"Empty session",()=>xe(e(S).modified)]),E("click",Ue,He=>{He.button===0&&!He.ctrlKey&&!He.metaKey&&!He.altKey&&!He.shiftKey&&(He.preventDefault(),Se(e(S).path))}),u(z,W)}),n(D),E("click",ue,()=>C(e(k).path)),u(_,D)},Z=X(()=>pe(e(k).path));w(Be,_=>{e(Z)&&_(te)})}n(O),A(_=>{gt(oe,1,`text-xs text-brand-text-muted transition-transform ${_??""}`),V(Le,e(k).name),V(Re,e(k).path),V(Je,e(k).sessions.length)},[()=>pe(e(k).path)?"rotate-90":""]),E("click",g,()=>ye(e(k).path)),u(m,O)}),u(o,c)};w(Ge,o=>{e(M)&&e(B).length===0?o(pt):e(B).length===0?o(wt,1):o(qe,-1)})}n(Ct),n(ct);var yt=i(ct,2);{var I=o=>{var c=Ss(),h=a(c),m=i(a(h),2),k=i(a(m),2),O=a(k,!0);n(k),n(m);var g=i(m,2),oe=i(a(g),2);{var N=Fe=>{var Je=ys();Ft(Je,21,()=>e(ee),Wt,(Be,te)=>{var Z=ws(),_=a(Z);n(Z);var D={};A(()=>{V(_,`${e(te).label??""}${e(te).isDefault?" (default)":""}`),D!==(D=`${e(te).provider}:${e(te).modelId}`)&&(Z.value=Z.__value=`${e(te).provider}:${e(te).modelId}`)}),u(Be,Z)}),n(Je),Ar(Je,()=>e($).selected,Be=>e($).selected=Be),u(Fe,Je)},H=Fe=>{var Je=ks();Me(Je),zt(Je,()=>e($).selected,Be=>e($).selected=Be),u(Fe,Je)};w(oe,Fe=>{e(ee).length>0?Fe(N):Fe(H,-1)})}n(g);var Le=i(g,2),ge=a(Le),Re=i(ge,2);n(Le),n(h),n(c),A(()=>V(O,e($).folderPath)),E("click",c,U),E("click",h,Fe=>Fe.stopPropagation()),E("click",ge,U),E("click",Re,de),u(o,c)};w(yt,o=>{e($).open&&o(I)})}var P=i(yt,2);{var $e=o=>{var c=Cs(),h=a(c),m=a(h,!0);n(h);var k=i(h,2);n(c),A(()=>V(m,x())),E("click",k,()=>nr()),u(o,c)};w(P,o=>{x()&&o($e)})}var et=i(P,2);{var tt=o=>{var c=Rs(),h=a(c),m=i(a(h),2),k=i(a(m)),O=a(k,!0);n(k),Oe(),n(m);var g=i(m,2),oe=a(g),N=a(oe);Me(N);var H=i(N,2),Le=i(a(H));{var ge=_=>{var D=Ts();u(_,D)},Re=_=>{var D=$s();u(_,D)};w(Le,_=>{e(le).isGit?_(ge):_(Re,-1)})}n(H),n(oe);var Fe=i(oe,2);{var Je=_=>{var D=Es(),he=a(D),ue=a(he);Me(ue);var be=i(ue,2),re=a(be);n(be),n(he);var T=i(he,2);{var K=Q=>{var z=Is(),S=i(a(z),2),W=a(S);Me(W),W.value=W.__value="private",Oe(),n(S);var Ue=i(S,2),Ne=a(Ue);Me(Ne),Ne.value=Ne.__value="public",Oe(),n(Ue),n(z),qt(Y,[],W,()=>e(st),We=>l(st,We)),qt(Y,[],Ne,()=>e(st),We=>l(st,We)),u(Q,z)};w(T,Q=>{e(Ye)&&Q(K)})}n(D),A(()=>V(re,`Create remote ${e(le).matchingRule.provider??""} repository`)),Ot(ue,()=>e(Ye),Q=>l(Ye,Q)),u(_,D)};w(Fe,_=>{e(le).matchingRule&&_(Je)})}n(g);var Be=i(g,2),te=a(Be),Z=i(te,2);n(Be),n(h),n(c),A(()=>{V(O,e(q)),N.disabled=e(le).isGit}),Ot(N,()=>e(ot),_=>l(ot,_)),E("click",te,()=>l(St,!1)),E("click",Z,y),u(o,c)};w(et,o=>{e(St)&&o(tt)})}A(()=>{Zn(me,e(we)),gt(vt,1,na(e(M)?"animate-spin":"")),V(ce,e(rt)?"▼ Close Create Session":"✚ Create New Session")}),E("input",me,o=>l(we,o.currentTarget.value,!0)),E("click",ut,()=>dr()),E("click",At,()=>l(rt,!e(rt))),u(r,Ze),Zt(),R()}ar(["input","click","keydown","change"]);var Fs=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">Session Conflict</h2> <p class="mb-6 text-sm text-brand-text-muted">Another client is active on a session in folder <span class="font-mono text-xs text-brand-text"> </span>. What would you like to do?</p> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Read Only</button> <button class="flex-1 rounded-lg bg-rose-500 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-rose-600">Take Over</button></div> <p class="mt-4 text-xs text-brand-text-muted"><strong class="text-brand-text">Read Only:</strong> Observe the session
|
|
23
|
-
live but cannot send messages.<br/> <strong class="text-brand-text">Take Over:</strong> Interrupt the other client
|
|
24
|
-
and gain control.</p></div></div>`);function Ds(r,t){Qt(t,!0);const f=()=>De($n,"$conflict",s),[s,d]=br();let v=X(f);var p=wr(),x=kt(p);{var G=R=>{var Y=Fs(),fe=a(Y),M=i(a(fe),2),j=i(a(M)),L=a(j,!0);n(j),Oe(),n(M);var ee=i(M,2),Ee=a(ee),Ie=i(Ee,2);n(ee),Oe(2),n(fe),n(Y),A(()=>V(L,e(v).conflictingCwd)),E("click",Ee,()=>qr("read_only")),E("click",Ie,()=>qr("take_over")),u(R,Y)};w(x,R=>{e(v)&&R(G)})}u(r,p),Zt(),d()}ar(["click"]);var Ps=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>'),Us=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),Os=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),Ls=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>'),Ns=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),Hs=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),js=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>'),Bs=b('<div class="mt-2 text-xs text-rose-400"> </div>'),Ws=b('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span></div> <!> <!></div> <div class="flex-1 overflow-hidden"><!></div>',1),Gs=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>'),zs=b('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Vs=b('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),qs=b('<span class="text-sm text-brand-text-muted">Not connected</span>'),Js=b('<div class="flex min-w-0 items-center gap-2"><!></div>'),Ks=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>'),Qs=b("<option> </option>"),Zs=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>'),Xs=b('<span class="truncate text-brand-text-muted"> </span>'),Ys=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>'),ei=b('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),ti=b('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),ri=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>'),ni=b('<div class="flex items-center justify-between border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-rose-400"><span> </span> <button class="ml-2 text-rose-300 hover:text-rose-200">X</button></div>'),ai=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: another session is active in this folder</div>'),oi=b('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),si=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="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 pi(r,t){Qt(t,!0);const f=()=>De(Cr,"$isConnected",fe),s=()=>De(In,"$isInterrupted",fe),d=()=>De(an,"$sessionError",fe),v=()=>De(on,"$isReadOnly",fe),p=()=>De(Tr,"$activeSessionInfo",fe),x=()=>De(_t,"$piState",fe),G=()=>De(cr,"$availableModels",fe),R=()=>De(En,"$isCreatingSession",fe),Y=()=>De(en,"$searchFolderStore",fe),[fe,M]=br();let j=F(!1),L=F(!1),ee;kr(()=>{setTimeout(()=>rr(),200);const I=()=>{if(e(B)){const o=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";o&&o!==e(Ve)?e(Ve)?(Mt(),setTimeout(()=>fr(o),100)):fr(o):!o&&e(Ve)&&Mt()}};window.addEventListener("hashchange",I);let P=null;const $e=8e3,et=()=>{document.visibilityState==="hidden"?(P&&clearTimeout(P),P=setTimeout(()=>{P=null,document.visibilityState==="hidden"&&e(B)&&ur()},$e)):(P&&(clearTimeout(P),P=null),e(B)||rr())},tt=o=>{P&&(clearTimeout(P),P=null),document.visibilityState!=="hidden"&&!e(B)&&rr()};return document.addEventListener("visibilitychange",et),window.addEventListener("pageshow",tt),()=>{window.removeEventListener("hashchange",I),document.removeEventListener("visibilitychange",et),window.removeEventListener("pageshow",tt),P&&clearTimeout(P)}});function Ee(){rr()}function Ie(){Mt(),ur()}function ne(){ur(),setTimeout(()=>rr(),100)}function Pe(){dr()}function we(){typeof window<"u"&&(window.location.hash=""),Mt(),l(j,!1)}let B=X(f),at=X(s),pe=X(d),ye=X(v),ie=X(p),Ke=X(x),Se=X(()=>G().models),rt=F(!1),q=F(!1),Ve=X(()=>e(ie).sessionId);it(()=>{typeof window<"u"&&e(B)&&(e(Ve)?(window.location.hash=encodeURIComponent(e(Ve)),l(q,!0)):e(q)&&(l(q,!1),window.location.hash&&(window.location.hash="")))}),it(()=>{if(e(B)&&typeof window<"u"&&window.location.hash&&!e(rt)){const I=decodeURIComponent(window.location.hash.slice(1));I&&(l(rt,!0),setTimeout(()=>{fr(I)},300))}}),it(()=>{e(B)||(l(rt,!1),l(q,!1))}),it(()=>{e(Ve)&&l(j,!1)});let se=X(R),je=X(Y),Xe=F(void 0),Ce=X(()=>e(B)&&!!e(je)&&!e(ie).sessionFile),dt=F(!1);it(()=>{e(Ce)&&!e(dt)&&e(Xe)&&(l(dt,!0),e(Xe).focusInput())});function ot(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),Mt(),e(Xe)?.focusInput()}var ht=si(),Ye=kt(ht);ua(Ye,{title:"Wherever",description:"Create & maintain apps from wherever"});var st=i(Ye,2);{var St=I=>{var P=Ps();u(I,P)};w(st,I=>{e(se)&&I(St)})}var $t=i(st,2),le=a($t),J=a(le),ke=a(J),Te=a(ke);{var Qe=I=>{var P=Us(),$e=i(kt(P),2);E("click",$e,()=>l(L,!1)),u(I,P)},y=I=>{var P=Os(),$e=kt(P),et=a($e);Oe(2),n($e);var tt=i($e,2),o=a(tt),c=i(o,2);n(tt),A(h=>_e(et,"src",h),[()=>ir("/logo.svg")]),E("click",$e,we),E("click",o,()=>l(L,!0)),E("click",c,()=>l(j,!1)),u(I,P)};w(Te,I=>{e(L)?I(Qe):I(y,-1)})}n(ke),n(J);var $=i(J,2);{var C=I=>{var P=Ls(),$e=a(P);{let m=X(()=>(e(Ke).connected,"localhost"));Ia($e,{get host(){return e(m)},port:31415,token:"",onConnected:Ee})}var et=i($e,2),tt=i(a(et),2),o=a(tt),c=i(o,2),h=i(c,2);n(tt),n(et),n(P),E("click",o,Pe),E("click",c,ne),E("click",h,Ie),u(I,P)},U=I=>{var P=Ws(),$e=kt(P),et=a($e),tt=a(et),o=i(tt,2),c=a(o,!0);n(o),n(et);var h=i(et,2);{var m=N=>{var H=js(),Le=a(H);{var ge=te=>{var Z=Ns(),_=a(Z);n(Z),A(D=>{_e(Z,"title",e(ie).cwd),V(_,`📁 ${D??""}`)},[()=>e(ie).cwd.split("/").pop()||e(ie).cwd]),u(te,Z)};w(Le,te=>{e(ie).cwd&&te(ge)})}var Re=i(Le,2);{var Fe=te=>{var Z=Hs(),_=a(Z);n(Z),A(()=>{_e(Z,"title",e(ie).model),V(_,`🤖 ${e(ie).model??""}`)}),u(te,Z)};w(Re,te=>{e(ie).model&&te(Fe)})}var Je=i(Re,2),Be=a(Je);n(Je),n(H),E("click",Be,we),u(N,H)};w(h,N=>{e(ie).sessionFile&&N(m)})}var k=i(h,2);{var O=N=>{var H=Bs(),Le=a(H,!0);n(H),A(()=>V(Le,e(Ke).error)),u(N,H)};w(k,N=>{e(Ke).error&&!e(B)&&N(O)})}n($e);var g=i($e,2),oe=a(g);As(oe,{}),n(g),A(()=>{gt(tt,1,`h-2.5 w-2.5 rounded-full ${e(B)?"bg-emerald-500":"bg-rose-500"}`),gt(o,1,`text-sm ${e(B)?"text-emerald-400":"text-rose-400"}`),V(c,e(B)?"Connected":"Disconnected")}),u(I,P)};w($,I=>{e(L)?I(C):I(U,-1)})}n(le);var de=i(le,2),xe=a(de),ae=a(xe),Ze=i(ae,2);{var ct=I=>{var P=Gs();E("click",P,ot),u(I,P)};w(Ze,I=>{e(B)&&e(je)&&e(ie).sessionFile&&I(ct)})}var nt=i(Ze,2);{var ve=I=>{var P=Js(),$e=a(P);{var et=c=>{var h=zs();u(c,h)},tt=c=>{var h=Vs();u(c,h)},o=c=>{var h=qs();u(c,h)};w($e,c=>{e(B)&&e(Ce)?c(et):e(B)?c(tt,1):c(o,-1)})}n(P),u(I,P)};w(nt,I=>{(!e(B)||!e(ie).sessionFile)&&I(ve)})}var me=i(nt,2);{var ut=I=>{var P=ei(),$e=a(P);{var et=c=>{var h=Ks(),m=i(a(h),2),k=a(m,!0);n(m),n(h),A(O=>{_e(m,"title",e(ie).cwd),V(k,O)},[()=>e(ie).cwd.split("/").pop()||e(ie).cwd]),u(c,h)};w($e,c=>{e(ie).cwd&&c(et)})}var tt=i($e,2);{var o=c=>{var h=Ys(),m=a(h),k=i(a(m),2);n(m);var O=i(m,2);{var g=N=>{var H=Zs();Ft(H,21,()=>e(Se),Wt,(ge,Re)=>{var Fe=Qs(),Je=a(Fe,!0);n(Fe);var Be={};A(()=>{V(Je,e(Re).label),Be!==(Be=`${e(Re).provider}:${e(Re).modelId}`)&&(Fe.value=Fe.__value=`${e(Re).provider}:${e(Re).modelId}`)}),u(ge,Fe)}),n(H);var Le;hn(H),A(()=>{Le!==(Le=e(ie).model)&&(H.value=(H.__value=e(ie).model)??"",Xr(H,e(ie).model))}),E("input",H,ge=>Cn(ge.currentTarget.value)),u(N,H)},oe=N=>{var H=Xs(),Le=a(H,!0);n(H),A(()=>{_e(H,"title",e(ie).model),V(Le,e(ie).model)}),u(N,H)};w(O,N=>{e(Se).length>0&&!e(ye)?N(g):N(oe,-1)})}n(h),A(()=>{gt(k,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${e(Ke).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),_e(k,"title",e(Ke).isStreaming?"Agent working...":"Ready")}),u(c,h)};w(tt,c=>{e(ie).model&&c(o)})}n(P),u(I,P)};w(me,I=>{e(ie).sessionFile&&I(ut)})}var vt=i(me,2);{var Ct=I=>{var P=ti();u(I,P)};w(vt,I=>{e(ye)&&I(Ct)})}n(xe);var It=i(xe,2);{var At=I=>{var P=ri();u(I,P)};w(It,I=>{e(at)&&I(At)})}var bt=i(It,2);{var ce=I=>{var P=ni(),$e=a(P),et=a($e,!0);n($e);var tt=i($e,2);n(P),A(()=>V(et,e(pe))),E("click",tt,()=>nr()),u(I,P)};w(bt,I=>{e(pe)&&I(ce)})}var Ae=i(bt,2);{var mt=I=>{var P=ai();u(I,P)};w(Ae,I=>{e(ye)&&!e(at)&&I(mt)})}var Ge=i(Ae,2);Gt($o(Ge,{onMessageSent:()=>{}}),I=>ee=I,()=>ee);var pt=i(Ge,2);{let I=X(()=>!!e(je)),P=X(()=>e(Ce)?!e(B):!e(B)||e(ye)||!e(ie).sessionFile);Gt(Zo(pt,{get searchMode(){return e(Ce)},get searchConfigured(){return e(I)},onSubmit:$e=>yn($e),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return e(P)},onSend:()=>ee?.forceScrollToBottom()}),$e=>l(Xe,$e,!0),()=>e(Xe))}n(de);var wt=i(de,2);Ds(wt,{});var qe=i(wt,2);{var yt=I=>{var P=oi();E("click",P,()=>l(j,!1)),u(I,P)};w(qe,I=>{e(j)&&I(yt)})}n($t),A(()=>gt(le,1,`${e(j)?"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`)),E("click",ae,()=>l(j,!e(j))),u(r,ht),Zt(),M()}ar(["click","input"]);export{pi as component,bi as universal};
|
|
25
|
-
//# sourceMappingURL=2.0Tnfs-pB.js.map
|