wherever-dev 0.8.0 → 0.8.1
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/package.json +1 -1
- package/public/_app/immutable/chunks/{3IRml1wh.js → BwgARz4Y.js} +2 -2
- package/public/_app/immutable/chunks/{3IRml1wh.js.map → BwgARz4Y.js.map} +1 -1
- package/public/_app/immutable/chunks/{Ct_S3Bfg.js → CF6_JXZX.js} +2 -2
- package/public/_app/immutable/chunks/{Ct_S3Bfg.js.map → CF6_JXZX.js.map} +1 -1
- package/public/_app/immutable/chunks/{D_TsCsac.js → DDWjp2hV.js} +2 -2
- package/public/_app/immutable/chunks/{D_TsCsac.js.map → DDWjp2hV.js.map} +1 -1
- package/public/_app/immutable/entry/{app.CZ9WZPGp.js → app.DFLSzTKw.js} +3 -3
- package/public/_app/immutable/entry/{app.CZ9WZPGp.js.map → app.DFLSzTKw.js.map} +1 -1
- package/public/_app/immutable/entry/start.Dr68fjDA.js +2 -0
- package/public/_app/immutable/entry/start.Dr68fjDA.js.map +1 -0
- package/public/_app/immutable/nodes/{0.7JV3G2dC.js → 0.BRaTu691.js} +2 -2
- package/public/_app/immutable/nodes/{0.7JV3G2dC.js.map → 0.BRaTu691.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.DnFc1JxV.js → 1.B-xVa06Z.js} +2 -2
- package/public/_app/immutable/nodes/{1.DnFc1JxV.js.map → 1.B-xVa06Z.js.map} +1 -1
- package/public/_app/immutable/nodes/{2.B3yox2Vj.js → 2.DTWm0M0B.js} +26 -26
- package/public/_app/immutable/nodes/2.DTWm0M0B.js.map +1 -0
- package/public/_app/version.json +1 -1
- package/public/index.html +10 -10
- package/public/service-worker.js +1 -1
- package/public/_app/immutable/entry/start.BWyZYAxI.js +0 -2
- package/public/_app/immutable/entry/start.BWyZYAxI.js.map +0 -1
- package/public/_app/immutable/nodes/2.B3yox2Vj.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as us,a as h,c as Un,g as m,d as or,e as W,f as sr,s as J,t as kn}from"../chunks/vMsF8lo6.js";import{ar as Tn,b2 as Xr,al as mr,be as H,ap as po,M as ci,aS as di,aq as ks,d as Vo,am as Ts,at as ui,n as fi,a0 as pi,u as hi,t as bi,a1 as vi,V as gi,W as mi,H as xi,b3 as ho,C as bo,aE as ns,a2 as tr,ac as _i,az as yi,aZ as wi,ay as Ko,bd as Yo,bf as Si,bg as zs,aU as Bs,aQ as vo,aP as Zn,aM as Xn,af as Ot,b6 as f,ai as t,a5 as ki,bh as V,$ as Ti,bl as Dn,ah as Hn,a8 as Wt,aK as zr,a_ as p,X as u,aV as d,aI as tt,b9 as q,aO as Cn,bi as Rt,bj as Ai,aT as Ei}from"../chunks/CEg8tgYI.js";import{i as E,s as hr,a as $e,p as dr}from"../chunks/MtE7VtNZ.js";import{a as Ci,b as ye,r as nt,c as Zo,e as gn,i as Rn,d as Ii}from"../chunks/D_TsCsac.js";import{_ as Ri,b as Bn}from"../chunks/ylfInSZr.js";import{v as Xo}from"../chunks/Ct_S3Bfg.js";import{p as $i}from"../chunks/3IRml1wh.js";function go(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var x=n;Tn&&(l=Xr(mr(x)))}H(()=>{var v=ci;if(c===(c=e()??"")){Tn&&po();return}if(r&&!Tn){v.nodes=null,x.innerHTML=c,c!==""&&us(mr(x),x.lastChild);return}if(v.nodes!==null&&(di(v.nodes.start,v.nodes.end),v.nodes=null),c!==""){if(Tn){ks.data;for(var g=po(),I=g;g!==null&&(g.nodeType!==Vo||g.data!=="");)I=g,g=Ts(g);if(g===null)throw ui(),fi;us(ks,I),l=Xr(g);return}var L=s?hi:o?bi:void 0,O=pi(s?"svg":o?"math":"template",L);O.innerHTML=c;var T=s||o?O:O.content;if(us(mr(T),T.lastChild),s||o)for(;mr(T);)l.before(mr(T));else l.before(T)}})}function Mi(n,e){let r=null,s=Tn;var o;if(Tn){r=ks;for(var a=mr(document.head);a!==null&&(a.nodeType!==Vo||a.data!==n);)a=Ts(a);if(a===null)ho(!1);else{var l=Ts(a);a.remove(),Xr(l)}}Tn||(o=document.head.appendChild(vi()));try{gi(()=>{var c=mi(()=>e(o));c.f|=xi})}finally{s&&(ho(!0),Xr(r))}}function Qo(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=Qo(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Di(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=Qo(n))&&(s&&(s+=" "),s+=e);return s}function Pi(n){return typeof n=="object"?Di(n):n??""}function Li(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function rn(n,e,r,s,o,a){var l=n[bo];if(Tn||l!==r||l===void 0){var c=Li(r);(!Tn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[bo]=r}return a}function Hs(n,e,r=!1){if(n.multiple){if(e==null)return;if(!yi(e))return wi();for(var s of n.options)s.selected=e.includes(Pr(s));return}for(s of n.options){var o=Pr(s);if(Ko(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function Jo(n){var e=new MutationObserver(()=>{Hs(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Yo(()=>{e.disconnect()})}function Fr(n,e,r=e){var s=new WeakSet,o=!0;ns(n,"change",a=>{var l=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(l),Pr);else{var x=n.querySelector(l)??n.querySelector("option:not([disabled])");c=x&&Pr(x)}r(c),n.__value=c,tr!==null&&s.add(tr)}),_i(()=>{var a=e();if(n===document.activeElement){var l=tr;if(s.has(l))return}if(Hs(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=Pr(c),r(a))}n.__value=a,o=!1}),Jo(n)}function Pr(n){return"__value"in n?n.__value:n.value}function $n(n,e,r=e){var s=new WeakSet;ns(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=ps(n)?hs(a):a,r(a),tr!==null&&s.add(tr),await Si(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,x=n.value.length;if(n.value=a??"",c!==null){var v=n.value.length;l===c&&c===x&&v>x?(n.selectionStart=v,n.selectionEnd=v):(n.selectionStart=l,n.selectionEnd=Math.min(c,v))}}}),(Tn&&n.defaultValue!==n.value||zs(e)==null&&n.value)&&(r(ps(n)?hs(n.value):n.value),tr!==null&&s.add(tr)),Bs(()=>{var o=e();if(n===document.activeElement){var a=tr;if(s.has(a))return}ps(n)&&o===hs(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const fs=new Set;function rr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",l=n;let c=!1;if(e!==null)for(var x of e)l=l[x]??=[];l.push(r),ns(r,"change",()=>{var v=r.__value;a&&(v=mo(l,v,r.checked)),o(v)},()=>o(a?[]:null)),Bs(()=>{var v=s();if(Tn&&r.defaultChecked!==r.checked){c=!0;return}a?(v=v||[],r.checked=v.includes(r.__value)):r.checked=Ko(r.__value,v)}),Yo(()=>{var v=l.indexOf(r);v!==-1&&l.splice(v,1)}),fs.has(l)||(fs.add(l),vo(()=>{l.sort((v,g)=>v.compareDocumentPosition(g)===4?-1:1),fs.delete(l)})),vo(()=>{if(c){var v;if(a)v=mo(l,v,r.checked);else{var g=l.find(I=>I.checked);v=g?.__value}o(v)}})}function Mn(n,e,r=e){ns(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(Tn&&n.defaultChecked!==n.checked||zs(e)==null)&&r(n.checked),Bs(()=>{var s=e();n.checked=!!s})}function mo(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function ps(n){var e=n.type;return e==="number"||e==="range"}function hs(n){return n===""?null:+n}const Oi=!1,Ni=!0,tp=Object.freeze(Object.defineProperty({__proto__:null,prerender:Ni,ssr:Oi},Symbol.toStringTag,{value:"Module"})),bs="Wherever",Fi="Create & maintain apps from wherever with a beautiful remote workspace.",vs="https://localhost",Ui="#000000",zi="black-translucent";function _r(n,e){return Ci(n)}var Bi=m('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function Hi(n,e){Zn(e,!0);const r=vs.endsWith("/")?vs.slice(0,-1):vs,s=r+"/preview.png";let o=V(()=>e.home||!1),a=V(()=>({type:e.type||"website",title:e.title||bs,description:e.description||Fi,image:e.image||s,url:`${r}${$i.url.pathname}`}));Mi("13n5pl5",l=>{var c=Bi(),x=Ot(c),v=f(x,2),g=f(v,2);{var I=Ge=>{var st=Un(),yt=Ot(st);E(yt,ot=>{}),h(Ge,st)};E(g,Ge=>{t(o)&&Ge(I)})}var L=f(g,2),O=f(L,2),T=f(O,2),G=f(T,2),ee=f(G,2),ue=f(ee,4),re=f(ue,2),Ve=f(re,2),Se=f(Ve,2),Re=f(Se,2),xe=f(Re,2),Le=f(xe,2),Me=f(Le,2),Et=f(Me,2),rt=f(Et,4),be=f(rt,4),Ye=f(be,2),Gt=f(Ye,2);H((Ge,st,yt,ot)=>{ye(x,"content",t(a).title),ye(v,"content",t(a).description),ye(L,"content",t(a).type),ye(O,"content",t(a).url),ye(T,"content",t(a).title),ye(G,"content",t(a).description),ye(ee,"content",t(a).image),ye(ue,"content",t(a).url),ye(re,"content",t(a).title),ye(Ve,"content",t(a).description),ye(Se,"content",t(a).image),ye(Re,"href",Ge),ye(xe,"href",st),ye(Le,"href",yt),ye(Me,"href",ot),ye(Et,"content",Ui),ye(rt,"content",bs),ye(be,"content",zi),ye(Ye,"content",bs),ye(Gt,"content",Xo)},[()=>_r("/pwa/favicon.png"),()=>_r("/pwa/favicon.ico"),()=>_r("/pwa/apple-touch-icon.png"),()=>_r("/pwa/manifest.webmanifest")]),ki(()=>{Ti.title=t(a).title??""}),h(l,c)}),Xn()}let Sr=null;function Wi(){if(typeof window>"u")return null;try{if(!Sr){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;Sr=new n}return Sr.state==="suspended"&&Sr.resume().catch(()=>{}),Sr}catch{return null}}function xo(n,e,r,s,o){const a=n.createOscillator(),l=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+c),l.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(l),l.connect(n.destination),a.start(r),a.stop(r+s+.02)}const _o=new Map;function Gi(n){if(typeof Audio>"u")return!1;try{let e=_o.get(n);e||(e=new Audio(n),e.preload="auto",_o.set(n,e));try{e.currentTime=0}catch{}const r=e.play();return r&&typeof r.catch=="function"&&r.catch(()=>{}),!0}catch{return!1}}function ea(n){if(n&&n.trim()&&Gi(n.trim()))return;const e=Wi();if(e)try{const r=e.currentTime;xo(e,1046.5,r,.16,.12),xo(e,1396.9,r+.13,.22,.12)}catch{}}function Kr(){}function ji(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function qi(n,...e){if(n==null)return Kr;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Qt(n){let e;return qi(n,r=>e=r)(),e}var vr=[];function Vi(n,e=Kr){let r;const s=new Set;function o(c){if(ji(n,c)&&(n=c,r)){const x=!vr.length;for(const v of s)v[1](),vr.push(v,n);if(x){for(let v=0;v<vr.length;v+=2)vr[v][0](vr[v+1]);vr.length=0}}}function a(c){o(c(n))}function l(c,x=Kr){const v=[c,x];return s.add(v),s.size===1&&(r=e(o)||Kr),c(n),()=>{s.delete(v),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:l}}const gs={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,conflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};class Fn{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=Vi({...gs,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(O=>r?{...O,connecting:!0,error:null}:{...gs,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",l=`${s}://${o}:${this.config.port}/ws${a}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(O=>({...O,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const O=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=O?new c(l,O):new c(l)}catch(O){this.stateStore.update(T=>({...T,connecting:!1,error:`Failed to connect: ${O}`})),this.scheduleReconnect();return}const x=this.ws,v=()=>{if(this.ws!==x)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(ue=>({...ue,connected:!0,connecting:!1,error:null}));const O=Qt(this.stateStore),T=this.resumeSessionFile??O.activeSessionFile,G=this.resumeSessionFile!=null?this.resumeCwd:O.activeCwd??void 0,ee=this.resumeSessionFile!=null?this.resumeModel:O.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,T?(this.stateStore.update(ue=>ue.resyncing?ue:{...ue,resyncing:!0}),this.send({type:"session_load",sessionFile:T,cwd:G,model:ee}),this.armLoadWatchdog()):this.stateStore.update(ue=>ue.resyncing?{...ue,resyncing:!1}:ue)},g=O=>{if(this.ws===x){this.lastInboundAt=Date.now();try{const T=typeof O.data=="string"?O.data:O.data.toString(),G=JSON.parse(T);this.handleMessage(G)}catch(T){console.error("Failed to parse WebSocket message:",T)}}},I=()=>{this.ws===x&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(O=>({...O,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:O.activeSessionFile?!0:O.resyncing})),this.scheduleReconnect())},L=O=>{this.ws===x&&this.stateStore.update(T=>({...T,error:T.error||"Connection error occurred"}))};typeof x.addEventListener=="function"?(x.addEventListener("open",v),x.addEventListener("message",g),x.addEventListener("close",I),x.addEventListener("error",L)):typeof x.on=="function"&&(x.on("open",v),x.on("message",O=>g({data:O})),x.on("close",I),x.on("error",L))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...gs,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=Qt(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=Qt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Qt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,Fn.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=Qt(this.stateStore).isStreaming,a=o?Fn.TURN_STALL_MS:Fn.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const l=this.ws;this.ws=null;try{typeof l.terminate=="function"?l.terminate():typeof l.close=="function"&&l.close()}catch{}this.stateStore.update(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,Fn.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=Qt(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},Fn.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Qt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},Fn.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`);const e=!!Qt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_conflict":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(c=>c.role==="thinking"&&c.isStreaming);a&&(o=o.map(c=>c.id===a.id?{...c,isStreaming:!1}:c));const l=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(l)o=o.map(c=>c.id===l.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Qt(this.stateStore);const c=[...o].reverse().find(v=>v.role==="user");e.role==="user"&&c&&c.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(c=>c.isStreaming&&(c.role==="assistant"||c.role==="thinking")?{...c,isStreaming:!1}:c),a=Date.now(),l={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...e.forceCommand?{forceCommand:!0}:{}};return{...s,messages:[...o,l]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
|
|
1
|
+
import{b as us,a as h,c as Un,g as m,d as or,e as W,f as sr,s as J,t as kn}from"../chunks/vMsF8lo6.js";import{ar as Tn,b2 as Xr,al as mr,be as H,ap as bo,M as ui,aS as fi,aq as As,d as Yo,am as Es,at as pi,n as hi,a0 as bi,u as vi,t as gi,a1 as mi,V as xi,W as _i,H as yi,b3 as vo,C as go,aE as ns,a2 as tr,ac as wi,az as Si,aZ as ki,ay as Zo,bd as Xo,bf as Ti,bg as Hs,aU as Ws,aQ as mo,aP as Zn,aM as Xn,af as Ot,b6 as f,ai as t,a5 as Ai,bh as V,$ as Ei,bl as Dn,ah as Hn,a8 as Wt,aK as zr,a_ as p,X as u,aV as d,aI as tt,b9 as q,aO as Cn,bi as Rt,bj as Ci,aT as Ii}from"../chunks/CEg8tgYI.js";import{i as E,s as hr,a as $e,p as dr}from"../chunks/MtE7VtNZ.js";import{a as Ri,b as ye,r as nt,c as Qo,e as gn,i as Rn,d as $i}from"../chunks/DDWjp2hV.js";import{_ as Mi,b as Bn}from"../chunks/ylfInSZr.js";import{v as Jo}from"../chunks/CF6_JXZX.js";import{p as Di}from"../chunks/BwgARz4Y.js";function xo(n,e,r=!1,s=!1,o=!1,a=!1){var l=n,c="";if(r){var x=n;Tn&&(l=Xr(mr(x)))}H(()=>{var v=ui;if(c===(c=e()??"")){Tn&&bo();return}if(r&&!Tn){v.nodes=null,x.innerHTML=c,c!==""&&us(mr(x),x.lastChild);return}if(v.nodes!==null&&(fi(v.nodes.start,v.nodes.end),v.nodes=null),c!==""){if(Tn){As.data;for(var g=bo(),I=g;g!==null&&(g.nodeType!==Yo||g.data!=="");)I=g,g=Es(g);if(g===null)throw pi(),hi;us(As,I),l=Xr(g);return}var L=s?vi:o?gi:void 0,O=bi(s?"svg":o?"math":"template",L);O.innerHTML=c;var T=s||o?O:O.content;if(us(mr(T),T.lastChild),s||o)for(;mr(T);)l.before(mr(T));else l.before(T)}})}function Pi(n,e){let r=null,s=Tn;var o;if(Tn){r=As;for(var a=mr(document.head);a!==null&&(a.nodeType!==Yo||a.data!==n);)a=Es(a);if(a===null)vo(!1);else{var l=Es(a);a.remove(),Xr(l)}}Tn||(o=document.head.appendChild(mi()));try{xi(()=>{var c=_i(()=>e(o));c.f|=yi})}finally{s&&(vo(!0),Xr(r))}}function ea(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=ea(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Li(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=ea(n))&&(s&&(s+=" "),s+=e);return s}function Oi(n){return typeof n=="object"?Li(n):n??""}function Ni(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function rn(n,e,r,s,o,a){var l=n[go];if(Tn||l!==r||l===void 0){var c=Ni(r);(!Tn||c!==n.getAttribute("class"))&&(c==null?n.removeAttribute("class"):e?n.className=c:n.setAttribute("class",c)),n[go]=r}return a}function Gs(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Si(e))return ki();for(var s of n.options)s.selected=e.includes(Pr(s));return}for(s of n.options){var o=Pr(s);if(Zo(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function ta(n){var e=new MutationObserver(()=>{Gs(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Xo(()=>{e.disconnect()})}function Fr(n,e,r=e){var s=new WeakSet,o=!0;ns(n,"change",a=>{var l=a?"[selected]":":checked",c;if(n.multiple)c=[].map.call(n.querySelectorAll(l),Pr);else{var x=n.querySelector(l)??n.querySelector("option:not([disabled])");c=x&&Pr(x)}r(c),n.__value=c,tr!==null&&s.add(tr)}),wi(()=>{var a=e();if(n===document.activeElement){var l=tr;if(s.has(l))return}if(Gs(n,a,o),o&&a===void 0){var c=n.querySelector(":checked");c!==null&&(a=Pr(c),r(a))}n.__value=a,o=!1}),ta(n)}function Pr(n){return"__value"in n?n.__value:n.value}function $n(n,e,r=e){var s=new WeakSet;ns(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=ps(n)?hs(a):a,r(a),tr!==null&&s.add(tr),await Ti(),a!==(a=e())){var l=n.selectionStart,c=n.selectionEnd,x=n.value.length;if(n.value=a??"",c!==null){var v=n.value.length;l===c&&c===x&&v>x?(n.selectionStart=v,n.selectionEnd=v):(n.selectionStart=l,n.selectionEnd=Math.min(c,v))}}}),(Tn&&n.defaultValue!==n.value||Hs(e)==null&&n.value)&&(r(ps(n)?hs(n.value):n.value),tr!==null&&s.add(tr)),Ws(()=>{var o=e();if(n===document.activeElement){var a=tr;if(s.has(a))return}ps(n)&&o===hs(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const fs=new Set;function rr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",l=n;let c=!1;if(e!==null)for(var x of e)l=l[x]??=[];l.push(r),ns(r,"change",()=>{var v=r.__value;a&&(v=_o(l,v,r.checked)),o(v)},()=>o(a?[]:null)),Ws(()=>{var v=s();if(Tn&&r.defaultChecked!==r.checked){c=!0;return}a?(v=v||[],r.checked=v.includes(r.__value)):r.checked=Zo(r.__value,v)}),Xo(()=>{var v=l.indexOf(r);v!==-1&&l.splice(v,1)}),fs.has(l)||(fs.add(l),mo(()=>{l.sort((v,g)=>v.compareDocumentPosition(g)===4?-1:1),fs.delete(l)})),mo(()=>{if(c){var v;if(a)v=_o(l,v,r.checked);else{var g=l.find(I=>I.checked);v=g?.__value}o(v)}})}function Mn(n,e,r=e){ns(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(Tn&&n.defaultChecked!==n.checked||Hs(e)==null)&&r(n.checked),Ws(()=>{var s=e();n.checked=!!s})}function _o(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function ps(n){var e=n.type;return e==="number"||e==="range"}function hs(n){return n===""?null:+n}const Fi=!1,Ui=!0,rp=Object.freeze(Object.defineProperty({__proto__:null,prerender:Ui,ssr:Fi},Symbol.toStringTag,{value:"Module"})),bs="Wherever",zi="Create & maintain apps from wherever with a beautiful remote workspace.",vs="https://localhost",Bi="#000000",Hi="black-translucent";function _r(n,e){return Ri(n)}var Wi=m('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function Gi(n,e){Zn(e,!0);const r=vs.endsWith("/")?vs.slice(0,-1):vs,s=r+"/preview.png";let o=V(()=>e.home||!1),a=V(()=>({type:e.type||"website",title:e.title||bs,description:e.description||zi,image:e.image||s,url:`${r}${Di.url.pathname}`}));Pi("13n5pl5",l=>{var c=Wi(),x=Ot(c),v=f(x,2),g=f(v,2);{var I=Ge=>{var st=Un(),yt=Ot(st);E(yt,ot=>{}),h(Ge,st)};E(g,Ge=>{t(o)&&Ge(I)})}var L=f(g,2),O=f(L,2),T=f(O,2),G=f(T,2),ee=f(G,2),ue=f(ee,4),re=f(ue,2),Ve=f(re,2),Se=f(Ve,2),Re=f(Se,2),xe=f(Re,2),Le=f(xe,2),Me=f(Le,2),Et=f(Me,2),rt=f(Et,4),be=f(rt,4),Ye=f(be,2),Gt=f(Ye,2);H((Ge,st,yt,ot)=>{ye(x,"content",t(a).title),ye(v,"content",t(a).description),ye(L,"content",t(a).type),ye(O,"content",t(a).url),ye(T,"content",t(a).title),ye(G,"content",t(a).description),ye(ee,"content",t(a).image),ye(ue,"content",t(a).url),ye(re,"content",t(a).title),ye(Ve,"content",t(a).description),ye(Se,"content",t(a).image),ye(Re,"href",Ge),ye(xe,"href",st),ye(Le,"href",yt),ye(Me,"href",ot),ye(Et,"content",Bi),ye(rt,"content",bs),ye(be,"content",Hi),ye(Ye,"content",bs),ye(Gt,"content",Jo)},[()=>_r("/pwa/favicon.png"),()=>_r("/pwa/favicon.ico"),()=>_r("/pwa/apple-touch-icon.png"),()=>_r("/pwa/manifest.webmanifest")]),Ai(()=>{Ei.title=t(a).title??""}),h(l,c)}),Xn()}let Sr=null;function ji(){if(typeof window>"u")return null;try{if(!Sr){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;Sr=new n}return Sr.state==="suspended"&&Sr.resume().catch(()=>{}),Sr}catch{return null}}function yo(n,e,r,s,o){const a=n.createOscillator(),l=n.createGain();a.type="sine",a.frequency.value=e;const c=.015;l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+c),l.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(l),l.connect(n.destination),a.start(r),a.stop(r+s+.02)}const wo=new Map;function qi(n){if(typeof Audio>"u")return!1;try{let e=wo.get(n);e||(e=new Audio(n),e.preload="auto",wo.set(n,e));try{e.currentTime=0}catch{}const r=e.play();return r&&typeof r.catch=="function"&&r.catch(()=>{}),!0}catch{return!1}}function na(n){if(n&&n.trim()&&qi(n.trim()))return;const e=ji();if(e)try{const r=e.currentTime;yo(e,1046.5,r,.16,.12),yo(e,1396.9,r+.13,.22,.12)}catch{}}function Kr(){}function Vi(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Ki(n,...e){if(n==null)return Kr;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Qt(n){let e;return Ki(n,r=>e=r)(),e}var vr=[];function Yi(n,e=Kr){let r;const s=new Set;function o(c){if(Vi(n,c)&&(n=c,r)){const x=!vr.length;for(const v of s)v[1](),vr.push(v,n);if(x){for(let v=0;v<vr.length;v+=2)vr[v][0](vr[v+1]);vr.length=0}}}function a(c){o(c(n))}function l(c,x=Kr){const v=[c,x];return s.add(v),s.size===1&&(r=e(o)||Kr),c(n),()=>{s.delete(v),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:l}}const gs={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,conflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null};class Fn{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=Yi({...gs,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(O=>r?{...O,connecting:!0,error:null}:{...gs,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",l=`${s}://${o}:${this.config.port}/ws${a}`,c=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!c){this.stateStore.update(O=>({...O,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const O=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=O?new c(l,O):new c(l)}catch(O){this.stateStore.update(T=>({...T,connecting:!1,error:`Failed to connect: ${O}`})),this.scheduleReconnect();return}const x=this.ws,v=()=>{if(this.ws!==x)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(ue=>({...ue,connected:!0,connecting:!1,error:null}));const O=Qt(this.stateStore),T=this.resumeSessionFile??O.activeSessionFile,G=this.resumeSessionFile!=null?this.resumeCwd:O.activeCwd??void 0,ee=this.resumeSessionFile!=null?this.resumeModel:O.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,T?(this.stateStore.update(ue=>ue.resyncing?ue:{...ue,resyncing:!0}),this.send({type:"session_load",sessionFile:T,cwd:G,model:ee}),this.armLoadWatchdog()):this.stateStore.update(ue=>ue.resyncing?{...ue,resyncing:!1}:ue)},g=O=>{if(this.ws===x){this.lastInboundAt=Date.now();try{const T=typeof O.data=="string"?O.data:O.data.toString(),G=JSON.parse(T);this.handleMessage(G)}catch(T){console.error("Failed to parse WebSocket message:",T)}}},I=()=>{this.ws===x&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(O=>({...O,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:O.activeSessionFile?!0:O.resyncing})),this.scheduleReconnect())},L=O=>{this.ws===x&&this.stateStore.update(T=>({...T,error:T.error||"Connection error occurred"}))};typeof x.addEventListener=="function"?(x.addEventListener("open",v),x.addEventListener("message",g),x.addEventListener("close",I),x.addEventListener("error",L)):typeof x.on=="function"&&(x.on("open",v),x.on("message",O=>g({data:O})),x.on("close",I),x.on("error",L))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...gs,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=Qt(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=Qt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Qt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,Fn.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=Qt(this.stateStore).isStreaming,a=o?Fn.TURN_STALL_MS:Fn.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const l=this.ws;this.ws=null;try{typeof l.terminate=="function"?l.terminate():typeof l.close=="function"&&l.close()}catch{}this.stateStore.update(c=>({...c,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":c.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,Fn.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=Qt(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},Fn.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Qt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},Fn.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`);const e=!!Qt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":case"session_error":case"session_conflict":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_conflict":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(c=>c.role==="thinking"&&c.isStreaming);a&&(o=o.map(c=>c.id===a.id?{...c,isStreaming:!1}:c));const l=[...o].reverse().find(c=>c.role==="assistant"&&c.isStreaming);if(l)o=o.map(c=>c.id===l.id?{...c,content:e.content||c.content,isStreaming:!1}:c);else if(e.content){if(e.role==="user"&&this.confirmDeliveredByContent(e.content))return Qt(this.stateStore);const c=[...o].reverse().find(v=>v.role==="user");e.role==="user"&&c&&c.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(c=>c.isStreaming&&(c.role==="assistant"||c.role==="thinking")?{...c,isStreaming:!1}:c),a=Date.now(),l={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...e.forceCommand?{forceCommand:!0}:{}};return{...s,messages:[...o,l]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
|
|
2
2
|
`)?a.content+e.delta:`${a.content}
|
|
3
3
|
${e.delta}`,toolOutput:`${a.toolOutput}${e.delta}`}:a)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"",o=!!e.isError&&this.isAbortedToolResult(s),a=!!e.isError&&!o,l=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(c=>{const x=c.messages.find(g=>g.role==="tool"&&g.toolName===e.toolName&&g.isStreaming)??[...c.messages].reverse().find(g=>g.role==="tool"&&g.toolName===e.toolName&&!g.content.startsWith("Tool error:")),v=Date.now();if(x){const g=a?"Error: ":"";return{...c,messages:c.messages.map(I=>I.id===x.id?{...I,content:`${g}${I.content}
|
|
4
4
|
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...l?{images:l}:{},endedAt:v}:I)}}else{const g=a?`Tool error: ${e.toolName}
|
|
@@ -7,11 +7,11 @@ ${s}`,I={id:this.generateId(),role:"tool",content:g,timestamp:v,isStreaming:!1,t
|
|
|
7
7
|
`),s=(r[r.length-1]||"").trim();return/^(command|operation)?\s*aborted$/i.test(s)}mapHistory(e,r,s){const o=[],a={},l={},c=(g,I)=>{const L=a[g];if(!L)return;const O=L.indexOf(I);O!==-1&&L.splice(O,1)};for(const g of e)if(g.role==="tool_call"){const I=g.toolName||"unknown",L=g.content||"",O=o.length;o.push({id:this.generateId(),role:"tool",content:L?`$ ${I} ${L}`:`$ ${I}`,timestamp:g.timestamp,isStreaming:!1,toolName:I,toolArgs:L,toolOutput:"",sessionId:r,...Number.isFinite(g.timestamp)?{startedAt:g.timestamp}:{},...g.forceCommand?{forceCommand:!0}:{}}),a[I]||(a[I]=[]),a[I].push(O),typeof g.toolCallId=="string"&&g.toolCallId&&(l[g.toolCallId]=O)}else if(g.role==="tool_result"){const I=g.toolName||"unknown";let L;if(typeof g.toolCallId=="string"&&g.toolCallId&&l[g.toolCallId]!==void 0)L=l[g.toolCallId],delete l[g.toolCallId],c(I,L);else if(a[I]&&a[I].length>0){L=a[I].shift();for(const[G,ee]of Object.entries(l))ee===L&&delete l[G]}const O=g.isError&&!this.isAbortedToolResult(g.content),T=!!g.isError&&this.isAbortedToolResult(g.content);if(L!==void 0){const G=o[L],ee=G.toolArgs||"",ue=G.startedAt;o[L]={...G,content:ee?`$ ${I} ${ee}
|
|
8
8
|
${g.content}`:`$ ${I}
|
|
9
9
|
${g.content}`,isStreaming:!1,toolOutput:g.content,...Array.isArray(g.images)&&g.images.length>0?{images:g.images}:{},isError:O,interrupted:T,timestamp:g.timestamp,...ue!==void 0&&Number.isFinite(ue)&&Number.isFinite(g.timestamp)&&g.timestamp>=ue?{endedAt:g.timestamp}:{}}}else o.push({id:this.generateId(),role:"tool",content:`$ ${I}
|
|
10
|
-
${g.content}`,timestamp:g.timestamp,isStreaming:!1,toolName:I,toolArgs:"",toolOutput:g.content,...Array.isArray(g.images)&&g.images.length>0?{images:g.images}:{},isError:O,interrupted:T,sessionId:r})}else o.push({id:this.generateId(),role:g.role,content:g.content,timestamp:g.timestamp,isStreaming:!1,toolName:g.toolName,sessionId:r});const x=[];for(const g of Object.values(a))x.push(...g);x.sort((g,I)=>g-I);const v=s&&x.length>0?x[x.length-1]:-1;for(const g of x)g===v?o[g]={...o[g],isStreaming:!0}:o[g]={...o[g],interrupted:!0};if(s&&o.length>0){const g=o.length-1,I=o[g];(I.role==="assistant"||I.role==="thinking")&&(o[g]={...I,isStreaming:!0})}return o}loadMoreHistory(){const e=Qt(this.stateStore);e.sessionId&&(e.loadingMoreHistory||e.historyOffset<=0||(this.stateStore.update(r=>({...r,loadingMoreHistory:!0})),this.send({type:"history_load_more",sessionId:e.sessionId,beforeOffset:e.historyOffset})))}send(e){if(this.ws&&this.ws.readyState===1)try{return this.ws.send(JSON.stringify(e)),!0}catch{return!1}return!1}sendMessage(e){const r=Qt(this.stateStore);if(!r.sessionId)return!1;if(r.agentPending)return this.stateStore.update(a=>({...a,sessionError:a.sessionError??"Preparing the session agent; please wait a moment, then resend."})),!1;if(!this.getIsConnected())return this.stateStore.update(a=>({...a,sessionError:"Not connected to the relay; your message was not sent. Reconnecting, then please resend."})),!this.ws&&!this.reconnectTimer&&this.scheduleReconnect(),!1;if(!this.send({type:"message",message:e,sessionId:r.sessionId}))return this.stateStore.update(a=>({...a,sessionError:"Message failed to send (connection dropped). Please resend once reconnected."})),!1;if(e.trimStart().startsWith("!"))return this.stateStore.update(a=>({...a,sessionError:null})),!0;const o={id:this.generateId(),role:"user",content:e,timestamp:Date.now(),isStreaming:!1,sessionId:r.sessionId,delivery:"sending"};return this.stateStore.update(a=>({...a,sessionError:null,messages:[...a.messages,o]})),this.armConfirm(o.id),this.persistPending(r.sessionId),!0}pendingKey(e){return Fn.PENDING_PREFIX+e}persistPending(e){if(!e||typeof localStorage>"u")return;const r=Qt(this.stateStore).messages.filter(s=>s.role==="user"&&s.delivery!==void 0);try{r.length===0?localStorage.removeItem(this.pendingKey(e)):localStorage.setItem(this.pendingKey(e),JSON.stringify(r.map(s=>({id:s.id,content:s.content,timestamp:s.timestamp,delivery:"failed"}))))}catch{}}loadPersistedPending(e){if(typeof localStorage>"u")return[];try{const r=localStorage.getItem(this.pendingKey(e));if(!r)return[];const s=JSON.parse(r);return Array.isArray(s)?s.filter(o=>o&&typeof o.content=="string").map(o=>({id:typeof o.id=="string"?o.id:this.generateId(),role:"user",content:o.content,timestamp:typeof o.timestamp=="number"?o.timestamp:Date.now(),isStreaming:!1,sessionId:e,delivery:"failed"})):[]}catch{return[]}}armConfirm(e){if(this.clearConfirm(e),typeof setTimeout!="function")return;const r=setTimeout(()=>{this.confirmTimers.delete(e);let s=null;this.stateStore.update(o=>{const a=o.messages.find(l=>l.id===e);return!a||a.delivery!=="sending"?o:(s=o.sessionId,{...o,messages:o.messages.map(l=>l.id===e?{...l,delivery:"failed"}:l)})}),s&&this.persistPending(s)},Fn.CONFIRM_MS);r&&typeof r.unref=="function"&&r.unref(),this.confirmTimers.set(e,r)}clearConfirm(e){const r=this.confirmTimers.get(e);r&&(clearTimeout(r),this.confirmTimers.delete(e))}confirmDeliveredByContent(e){let r=null,s=null;return this.stateStore.update(o=>{const a=o.messages.find(l=>l.role==="user"&&l.delivery!==void 0&&l.content===e);return a?(r=a.id,s=o.sessionId,{...o,messages:o.messages.map(l=>l.id===a.id?{...l,delivery:void 0}:l)}):o}),r?(this.clearConfirm(r),this.persistPending(s),!0):!1}resendMessage(e){const r=Qt(this.stateStore),s=r.messages.find(a=>a.id===e&&a.role==="user");return!s||!r.sessionId?!1:this.getIsConnected()?this.send({type:"message",message:s.content,sessionId:r.sessionId})?(this.stateStore.update(a=>({...a,sessionError:null,messages:a.messages.map(l=>l.id===e?{...l,delivery:"sending",timestamp:Date.now()}:l)})),this.armConfirm(e),this.persistPending(r.sessionId),!0):!1:(!this.ws&&!this.reconnectTimer&&this.scheduleReconnect(),!1)}discardMessage(e){let r=null;this.clearConfirm(e),this.stateStore.update(s=>(r=s.sessionId,{...s,messages:s.messages.filter(o=>o.id!==e)})),r&&this.persistPending(r)}abort(){const e=Qt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}joinSession(e,r,s){this.stateStore.update(o=>({...o,conflict:null,sessionError:null,loadingSession:!0,agentPending:!1})),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog()}switchSession(e,r,s){const o=Qt(this.stateStore);o.activeSessionFile===e&&!o.loadingSession&&!o.resyncing||(o.sessionId&&this.send({type:"session_leave",sessionId:o.sessionId}),this.stateStore.update(a=>({...a,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,conflict:null,sessionError:null,notice:null,sudoPrompt:null,creatingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null,loadingSession:!0})),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.clearCreateWatchdog(),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog())}createSession(e,r,s,o,a){this.stateStore.update(l=>({...l,conflict:null,sessionError:null,creatingSession:!0,loadingSession:!1})),this.send({type:"session_new",cwd:e,model:r,gitInit:s,createRemote:o,repoVisibility:a}),this.armCreateWatchdog()}leaveSession(){const e=Qt(this.stateStore);if(this.clearCreateWatchdog(),!e.sessionId){e.creatingSession&&this.stateStore.update(r=>({...r,creatingSession:!1}));return}this.send({type:"session_leave",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,notice:null,sudoPrompt:null,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null})),this.clearLoadWatchdog(),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0}resolveConflict(e,r){const s=Qt(this.stateStore);s.conflict&&(this.send({type:"session_resolve_conflict",action:e,sessionId:s.conflict.targetSessionId,cwd:r||s.conflict.conflictingCwd}),this.stateStore.update(o=>({...o,conflict:null,readOnly:e==="read_only"})))}ping(){this.send({type:"ping"})}clearMessages(){this.stateStore.update(e=>({...e,messages:[]}))}dismissSessionError(){this.stateStore.update(e=>({...e,sessionError:null}))}dismissNotice(){this.stateStore.update(e=>({...e,notice:null}))}sendSudoPassword(e){const s=Qt(this.stateStore).sudoPrompt;s&&(this.send({type:"bash_sudo_password",sessionId:s.sessionId,promptId:s.promptId,password:e}),this.stateStore.update(o=>({...o,sudoPrompt:null})))}cancelSudoPrompt(){const r=Qt(this.stateStore).sudoPrompt;this.stateStore.update(s=>({...s,sudoPrompt:null})),r&&this.send({type:"bash_sudo_cancel",sessionId:r.sessionId,promptId:r.promptId})}changeModel(e){this.send({type:"model_change",model:e})}setConfig(e){this.config={...this.config,...e},this.stateStore.update(r=>{const s={...r};return e.hideThinking!==void 0&&(s.hideThinking=!!e.hideThinking),e.hideTools!==void 0&&(s.hideTools=!!e.hideTools),s})}onMessage(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}uploadFileViaWebSocket(e,r,s){return new Promise((o,a)=>{const l=this.generateId();this.pendingUploads.set(l,{resolve:o,reject:a}),this.send({type:"file_upload",uploadId:l,sessionId:e,filename:r,data:s})})}generateId(){return Math.random().toString(36).substring(2)+Date.now().toString(36)}getIsConnected(){return this.ws&&this.ws.readyState===1}}const yr=Dn({folders:[],activeSessions:[],currentSession:null,loading:!1}),wr=Dn({models:[],loading:!1}),$r=Dn({folders:[],activeSessions:[],currentSession:null,loading:!1});function Wn(){const n=localStorage.getItem("wherever-config"),e=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost";if(n){const r=JSON.parse(n),s=window.location.protocol==="https:"?"https:":"http:";let o=r.host||e;return(o==="localhost"||o==="127.0.0.1")&&e&&e!=="localhost"&&e!=="127.0.0.1"&&(o=e),o=o.startsWith("http")?o.replace(/^wss?:\/\//,""):o,`${s}//${o}:${r.port||31415}`}return`${window.location.protocol}//${window.location.host}`}let kr=null,As=[],Es=!1,Cs=!1,yo=0;const Ki=150,Yi=1e3;async function wo(){Es=!0;try{const n=Wn(),e=Gn(),r=`${n}/sessions${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();yr.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Hn(yr).currentSession,loading:!1})}catch(n){yr.update(e=>({...e,loading:!1})),console.error("Failed to fetch sessions:",n)}finally{Es=!1}}function Lr(){yr.update(r=>({...r,loading:!0}));const n=new Promise(r=>{As.push(r)});if(Es)return Cs=!0,n;const e=Date.now();if(!kr)yo=e;else if(clearTimeout(kr),e-yo>=Yi)return kr=null,So(),n;return kr=setTimeout(()=>{kr=null,So()},Ki),n}async function So(){const n=[...As];As=[];try{for(await wo();Cs;)Cs=!1,await wo()}finally{for(const e of n)e()}}async function ta(){$r.update(n=>({...n,loading:!0}));try{const n=Wn(),e=Gn(),r=`${n}/sessions?view=readonly${e?`&token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();$r.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Hn($r).currentSession,loading:!1})}catch(n){$r.update(e=>({...e,loading:!1})),console.error("Failed to fetch read-only sessions:",n)}}async function Zi(){wr.update(n=>({...n,loading:!0}));try{const n=Wn(),e=Gn(),r=`${n}/models${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();wr.set({models:o.models||[],loading:!1})}catch(n){wr.update(e=>({...e,loading:!1})),console.error("Failed to fetch models:",n)}}function Gn(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n).token||""}catch{}return""}const Ws=Dn(!1),na=Dn("websocket"),Gs=Dn(null),ra=Dn(!1),sa=Dn(null);async function oa(n){if(!n.trim())return null;try{const e=Wn(),r=Gn(),s=`${e}/check-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}catch(e){return console.error("Failed to check path:",e),null}}async function Qr(n){try{const e=Wn(),r=Gn(),s=`${e}/autocomplete-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return(await o.json()).completions||[]}catch(e){return console.error("Failed to autocomplete path:",e),[]}}async function Xi(){try{const n=Wn(),e=Gn(),r=`${n}/config${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();Ws.set(!!o.gitInitDefault),na.set(o.uploadMethod||"websocket"),Gs.set(o.searchFolder||null),ra.set(!!o.searchCreateRemote),sa.set(o.searchDefaultModel||null)}catch(n){console.error("Failed to fetch config:",n)}}function Or(n){yr.update(e=>({...e,currentSession:n}))}function Qi(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n)}catch{}return null}function Br(n){localStorage.setItem("wherever-config",JSON.stringify(n))}function Qn(){const n=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",e=Qi();return e?(!e.host||e.host==="localhost"||e.host==="127.0.0.1")&&n&&n!=="localhost"&&n!=="127.0.0.1"?{hideThinking:!1,hideTools:!1,...e,host:n}:(e.host||(e.host=n),{hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:"",...e}):{host:n,port:31415,token:"",hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:""}}const rs=Dn(!!Qn().beepDefault),aa="wherever-beep-overrides";function Ji(){try{const n=localStorage.getItem(aa);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function el(n){try{localStorage.setItem(aa,JSON.stringify(n))}catch{}}const ia=Dn(typeof localStorage<"u"?Ji():{}),js=Dn("");function tl(){return Hn(rs)}function la(){const n=Qn().beepSoundUrl;return typeof n=="string"?n:""}function nl(n){const e=Qn();Br({...e,beepSoundUrl:n})}const qs=Wt([js,ia],([n,e])=>n&&n in e?e[n]:void 0),Vs=Wt([qs,rs],([n,e])=>n===void 0?e:n);function rl(n){const e=Qn();Br({...e,beepDefault:n}),rs.set(n)}function Yr(n){const e=Hn(js);e&&ia.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,el(s),s})}function ca(n){js.set(n??"")}const Tr=Qn(),lt=new Fn({host:Tr.host,port:Tr.port,token:Tr.token,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!Tr.hideThinking,hideTools:!!Tr.hideTools}),ss=lt.stateStore;let ms=!1,ko=null;ss.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==ko){ko=e,ca(e),ms=n.isStreaming;return}ms&&!n.isStreaming&&e&&Hn(Vs)&&ea(la()),ms=n.isStreaming});let Mr=null;lt.onMessage(n=>{switch(n.type){case"session_created":if(Or(n.sessionFile),Mr!==null){const r=Mr;Mr=null,queueMicrotask(()=>lt.sendMessage(r))}break;case"session_error":Mr=null;break;case"session_destroyed":Hn(ss).sessionId===n.sessionId&&Or(null);break;case"sessions_updated":Lr();break;case"session_interrupted":Or(null);break}});function ur(){const n=Qn();Br(n);const e=typeof window<"u"&&window.location&&window.location.protocol==="https:";lt.connect({host:n.host,port:n.port,token:n.token,secure:e,hideThinking:!!n.hideThinking,hideTools:!!n.hideTools})}function Ur(){lt.disconnect(!0),Or(null)}function da(){lt.suspend()}function Is(){lt.resume()}function sl(){return lt.hasSuspendedSession()}function Rs(){return lt.hasActiveSession()}let Ks=0;const ol=300*1e3;function ua(){Ks=Date.now()+ol}function Ys(){Ks=0}function fa(){return Date.now()<Ks}function $s(n){return lt.sendMessage(n)}function pa(n){return lt.resendMessage(n)}function ha(n){lt.discardMessage(n)}function ba(){lt.abort()}function va(n,e,r){lt.joinSession(n,e,r)}function Zs(n,e,r){lt.switchSession(n,e,r)}function zn(n,e,r,s,o){lt.createSession(n,e,r,s,o)}function ga(n,e){const r=n.trim();if(!r)return!1;const s=Hn(Gs);if(!s)return!1;const o=Hn(ra);return Mr=r,lt.createSession(s,e||void 0,o,o,o?"private":void 0),!0}function In(){lt.leaveSession(),Or(null)}function ma(){lt.loadMoreHistory()}function Ms(n,e){lt.resolveConflict(n,e)}function al(){lt.ping()}function xa(){lt.clearMessages()}function Ds(n){Br(n);const{host:e,port:r,token:s,hideThinking:o,hideTools:a}=n;lt.setConfig({host:e,port:r,token:s,hideThinking:o,hideTools:a}),n.beepDefault!==void 0&&rs.set(!!n.beepDefault)}function _a(n){const r={...Qn(),...n};Br(r),lt.setConfig(r)}function fr(){lt.dismissSessionError()}function ya(){lt.dismissNotice()}function wa(n){lt.sendSudoPassword(n)}function Sa(){lt.cancelSudoPrompt()}function ka(n){lt.changeModel(n)}const $t=Wt(ss,n=>n),Hr=Wt($t,n=>n.connected),Xs=Wt($t,n=>n.isStreaming),Ta=Wt($t,n=>n.messages),il=Wt($t,n=>n.error),ll=Wt($t,n=>n.session),Aa=Wt($t,n=>n.conflict),Ea=Wt($t,n=>n.isInterrupted),Qs=Wt($t,n=>n.sessionError),Ca=Wt($t,n=>n.notice),Ia=Wt($t,n=>n.sudoPrompt),os=Wt($t,n=>n.readOnly),Wr=Wt($t,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),cl=Wt($t,n=>n.contextUsage),Ra=Wt($t,n=>n.creatingSession),as=Wt($t,n=>n.loadingSession),Js=Wt($t,n=>n.resyncing),$a=Wt($t,n=>n.agentPending),Ma=Wt($t,n=>n.historyOffset>0),Da=Wt($t,n=>n.loadingMoreHistory);async function dl(n,e){const r=Wn(),s=Gn(),o=`${r}/session/upload?sessionId=${encodeURIComponent(n)}&filename=${encodeURIComponent(e.name)}${s?`&token=${encodeURIComponent(s)}`:""}`,a=await e.arrayBuffer(),l=await fetch(o,{method:"POST",headers:{"Content-Type":"text/plain"},body:a});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||`Upload failed with status ${l.status}`)}return await l.json()}function ul(n,e){return new Promise((r,s)=>{try{const o=new FileReader;o.onload=()=>{try{const l=o.result.split(",")[1]||"";lt.uploadFileViaWebSocket(n,e.name,l).then(r).catch(s)}catch(a){s(new Error(`Failed to process file data: ${a.message}`))}},o.onerror=()=>{s(new Error("Failed to read file contents"))},o.readAsDataURL(e)}catch(o){s(o)}})}function Pa(n){const r=Hn($t).sessionId;if(!r)return null;const s=Wn(),o=Gn();return`${s}/session/download?sessionId=${encodeURIComponent(r)}&path=${encodeURIComponent(n)}`+(o?`&token=${encodeURIComponent(o)}`:"")}async function La(n,e){return Hn(na)==="post"?dl(n,e):ul(n,e)}async function Ps(n){try{const e=Wn(),r=Gn(),s=`${e}/session/delete${r?`?token=${encodeURIComponent(r)}`:""}`,o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionFile:n})});if(!o.ok){const a=await o.json().catch(()=>({}));throw new Error(a.error||`Delete failed with status ${o.status}`)}}catch(e){throw console.error("Failed to delete session:",e),e}}const fl=Object.freeze(Object.defineProperty({__proto__:null,abort:ba,activeSessionInfo:Wr,beepEnabled:Vs,beepSessionOverride:qs,beginFilePicker:ua,cancelSudoPrompt:Sa,changeModel:ka,clearMessages:xa,client:lt,conflict:Aa,connect:ur,connectionError:il,contextUsage:cl,createSession:zn,currentSession:ll,deleteSession:Ps,discardMessage:ha,disconnect:Ur,dismissNotice:ya,dismissSessionError:fr,downloadFileUrl:Pa,endFilePicker:Ys,getBeepDefault:tl,getBeepSoundUrl:la,getConfig:Qn,hasActiveSession:Rs,hasMoreHistory:Ma,hasSuspendedSession:sl,isAgentPending:$a,isConnected:Hr,isCreatingSession:Ra,isFilePickerActive:fa,isInterrupted:Ea,isLoadingMoreHistory:Da,isLoadingSession:as,isReadOnly:os,isResyncing:Js,isStreaming:Xs,joinSession:va,leaveSession:In,loadMoreHistory:ma,messages:Ta,piState:$t,ping:al,resendMessage:pa,resolveConflict:Ms,resume:Is,runSearch:ga,sendMessage:$s,sendSudoPassword:wa,sessionError:Qs,sessionNotice:Ca,setBeepDefault:rl,setBeepSessionKey:ca,setBeepSessionOverride:Yr,setBeepSoundUrl:nl,setConfig:Ds,state:ss,sudoPrompt:Ia,suspend:da,switchSession:Zs,updateConfig:_a,uploadFile:La},Symbol.toStringTag,{value:"Module"}));var pl=m('<button class="flex-1 rounded bg-rose-500 px-4 py-2 text-sm text-white transition-colors hover:bg-rose-600">Disconnect</button>'),hl=m('<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>'),bl=m('<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-beep-default" 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-beep-default" class="cursor-pointer text-xs text-brand-text select-none">Beep when the agent is waiting (default for new sessions)</label></div> <div><label for="pi-beep-sound" class="mb-1 block text-xs text-brand-text-muted">Beep sound URL (optional, blank = built-in chime)</label> <div class="flex gap-2"><input id="pi-beep-sound" type="text" placeholder="/sounds/complete.mp3 or https://..." 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"/> <button type="button" title="Play the beep to test it" class="flex-shrink-0 rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3">Test</button></div></div> <div class="flex gap-2"><!></div> <button title="Reload the page" class="flex w-full items-center justify-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-4 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3"><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-4 w-4" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg> Reload</button></div></div>');function vl(n,e){Zn(e,!0);const r=()=>$e(Hr,"$isConnected",s),[s,o]=hr();let a=q(""),l=q(0),c=q(""),x=q(!1),v=q(!1),g=q(""),I=!1,L=V(r);zr(()=>{const K=Qn();p(a,K.host,!0),p(l,K.port,!0),p(c,K.token||"",!0),p(x,!!K.hideThinking),p(v,!!K.beepDefault),p(g,K.beepSoundUrl||"",!0)});function O(){ea(t(g).trim()||void 0)}function T(){Ds({host:t(a),port:t(l),token:t(c),hideThinking:t(x),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(g).trim()})}function G(){Ds({host:t(a),port:t(l),token:t(c),hideThinking:t(x),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(g).trim()}),Ur(),setTimeout(()=>ur(),100)}function ee(){Ur()}function ue(){window.location.reload()}var re=bl(),Ve=u(re),Se=u(Ve),Re=f(u(Se),2);nt(Re),d(Se);var xe=f(Se,2),Le=f(u(xe),2);nt(Le),d(xe);var Me=f(xe,2),Et=f(u(Me),2);nt(Et),d(Me);var rt=f(Me,2),be=u(rt);nt(be),tt(2),d(rt);var Ye=f(rt,2),Gt=u(Ye);nt(Gt),tt(2),d(Ye);var Ge=f(Ye,2),st=f(u(Ge),2),yt=u(st);nt(yt);var ot=f(yt,2);d(st),d(Ge);var et=f(Ge,2),we=u(et);{var at=K=>{var mt=pl();W("click",mt,ee),h(K,mt)},Ie=K=>{var mt=hl();mt.disabled=I,mt.textContent="Connect",W("click",mt,G),h(K,mt)};E(we,K=>{t(L)?K(at):K(Ie,-1)})}d(et);var Nt=f(et,2);d(Ve),d(re),$n(Re,()=>t(a),K=>p(a,K)),$n(Le,()=>t(l),K=>p(l,K)),$n(Et,()=>t(c),K=>p(c,K)),W("change",be,T),Mn(be,()=>t(x),K=>p(x,K)),W("change",Gt,T),Mn(Gt,()=>t(v),K=>p(v,K)),W("change",yt,T),$n(yt,()=>t(g),K=>p(g,K)),W("click",ot,O),W("click",Nt,ue),h(n,re),Xn(),o()}or(["change","click"]);function eo(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var br=eo();function Oa(n){br=n}var Nr={exec:()=>null};function ft(n,e=""){let r=typeof n=="string"?n:n.source;const s={replace:(o,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(vn.caret,"$1"),r=r.replace(o,l),s},getRegex:()=>new RegExp(r,e)};return s}var vn={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},gl=/^(?:[ \t]*(?:\n|$))+/,ml=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,xl=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,_l=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,to=/(?:[*+-]|\d{1,9}[.)])/,Na=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Fa=ft(Na).replace(/bull/g,to).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),yl=ft(Na).replace(/bull/g,to).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),no=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,wl=/^[^\n]+/,ro=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Sl=ft(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ro).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),kl=ft(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,to).getRegex(),is="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",so=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Tl=ft("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",so).replace("tag",is).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ua=ft(no).replace("hr",Gr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex(),Al=ft(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ua).getRegex(),oo={blockquote:Al,code:ml,def:Sl,fences:xl,heading:_l,hr:Gr,html:Tl,lheading:Fa,list:kl,newline:gl,paragraph:Ua,table:Nr,text:wl},To=ft("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex(),El={...oo,lheading:yl,table:To,paragraph:ft(no).replace("hr",Gr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",To).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex()},Cl={...oo,html:ft(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",so).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Nr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ft(no).replace("hr",Gr).replace("heading",` *#{1,6} *[^
|
|
11
|
-
]`).replace("lheading",
|
|
10
|
+
${g.content}`,timestamp:g.timestamp,isStreaming:!1,toolName:I,toolArgs:"",toolOutput:g.content,...Array.isArray(g.images)&&g.images.length>0?{images:g.images}:{},isError:O,interrupted:T,sessionId:r})}else o.push({id:this.generateId(),role:g.role,content:g.content,timestamp:g.timestamp,isStreaming:!1,toolName:g.toolName,sessionId:r});const x=[];for(const g of Object.values(a))x.push(...g);x.sort((g,I)=>g-I);const v=s&&x.length>0?x[x.length-1]:-1;for(const g of x)g===v?o[g]={...o[g],isStreaming:!0}:o[g]={...o[g],interrupted:!0};if(s&&o.length>0){const g=o.length-1,I=o[g];(I.role==="assistant"||I.role==="thinking")&&(o[g]={...I,isStreaming:!0})}return o}loadMoreHistory(){const e=Qt(this.stateStore);e.sessionId&&(e.loadingMoreHistory||e.historyOffset<=0||(this.stateStore.update(r=>({...r,loadingMoreHistory:!0})),this.send({type:"history_load_more",sessionId:e.sessionId,beforeOffset:e.historyOffset})))}send(e){if(this.ws&&this.ws.readyState===1)try{return this.ws.send(JSON.stringify(e)),!0}catch{return!1}return!1}sendMessage(e){const r=Qt(this.stateStore);if(!r.sessionId)return!1;if(r.agentPending)return this.stateStore.update(a=>({...a,sessionError:a.sessionError??"Preparing the session agent; please wait a moment, then resend."})),!1;if(!this.getIsConnected())return this.stateStore.update(a=>({...a,sessionError:"Not connected to the relay; your message was not sent. Reconnecting, then please resend."})),!this.ws&&!this.reconnectTimer&&this.scheduleReconnect(),!1;if(!this.send({type:"message",message:e,sessionId:r.sessionId}))return this.stateStore.update(a=>({...a,sessionError:"Message failed to send (connection dropped). Please resend once reconnected."})),!1;if(e.trimStart().startsWith("!"))return this.stateStore.update(a=>({...a,sessionError:null})),!0;const o={id:this.generateId(),role:"user",content:e,timestamp:Date.now(),isStreaming:!1,sessionId:r.sessionId,delivery:"sending"};return this.stateStore.update(a=>({...a,sessionError:null,messages:[...a.messages,o]})),this.armConfirm(o.id),this.persistPending(r.sessionId),!0}pendingKey(e){return Fn.PENDING_PREFIX+e}persistPending(e){if(!e||typeof localStorage>"u")return;const r=Qt(this.stateStore).messages.filter(s=>s.role==="user"&&s.delivery!==void 0);try{r.length===0?localStorage.removeItem(this.pendingKey(e)):localStorage.setItem(this.pendingKey(e),JSON.stringify(r.map(s=>({id:s.id,content:s.content,timestamp:s.timestamp,delivery:"failed"}))))}catch{}}loadPersistedPending(e){if(typeof localStorage>"u")return[];try{const r=localStorage.getItem(this.pendingKey(e));if(!r)return[];const s=JSON.parse(r);return Array.isArray(s)?s.filter(o=>o&&typeof o.content=="string").map(o=>({id:typeof o.id=="string"?o.id:this.generateId(),role:"user",content:o.content,timestamp:typeof o.timestamp=="number"?o.timestamp:Date.now(),isStreaming:!1,sessionId:e,delivery:"failed"})):[]}catch{return[]}}armConfirm(e){if(this.clearConfirm(e),typeof setTimeout!="function")return;const r=setTimeout(()=>{this.confirmTimers.delete(e);let s=null;this.stateStore.update(o=>{const a=o.messages.find(l=>l.id===e);return!a||a.delivery!=="sending"?o:(s=o.sessionId,{...o,messages:o.messages.map(l=>l.id===e?{...l,delivery:"failed"}:l)})}),s&&this.persistPending(s)},Fn.CONFIRM_MS);r&&typeof r.unref=="function"&&r.unref(),this.confirmTimers.set(e,r)}clearConfirm(e){const r=this.confirmTimers.get(e);r&&(clearTimeout(r),this.confirmTimers.delete(e))}confirmDeliveredByContent(e){let r=null,s=null;return this.stateStore.update(o=>{const a=o.messages.find(l=>l.role==="user"&&l.delivery!==void 0&&l.content===e);return a?(r=a.id,s=o.sessionId,{...o,messages:o.messages.map(l=>l.id===a.id?{...l,delivery:void 0}:l)}):o}),r?(this.clearConfirm(r),this.persistPending(s),!0):!1}resendMessage(e){const r=Qt(this.stateStore),s=r.messages.find(a=>a.id===e&&a.role==="user");return!s||!r.sessionId?!1:this.getIsConnected()?this.send({type:"message",message:s.content,sessionId:r.sessionId})?(this.stateStore.update(a=>({...a,sessionError:null,messages:a.messages.map(l=>l.id===e?{...l,delivery:"sending",timestamp:Date.now()}:l)})),this.armConfirm(e),this.persistPending(r.sessionId),!0):!1:(!this.ws&&!this.reconnectTimer&&this.scheduleReconnect(),!1)}discardMessage(e){let r=null;this.clearConfirm(e),this.stateStore.update(s=>(r=s.sessionId,{...s,messages:s.messages.filter(o=>o.id!==e)})),r&&this.persistPending(r)}abort(){const e=Qt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}joinSession(e,r,s){this.stateStore.update(o=>({...o,conflict:null,sessionError:null,loadingSession:!0,agentPending:!1})),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog()}switchSession(e,r,s){const o=Qt(this.stateStore);o.activeSessionFile===e&&!o.loadingSession&&!o.resyncing||(o.sessionId&&this.send({type:"session_leave",sessionId:o.sessionId}),this.stateStore.update(a=>({...a,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,conflict:null,sessionError:null,notice:null,sudoPrompt:null,creatingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null,loadingSession:!0})),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.clearCreateWatchdog(),this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog())}createSession(e,r,s,o,a){this.stateStore.update(l=>({...l,conflict:null,sessionError:null,creatingSession:!0,loadingSession:!1})),this.send({type:"session_new",cwd:e,model:r,gitInit:s,createRemote:o,repoVisibility:a}),this.armCreateWatchdog()}leaveSession(){const e=Qt(this.stateStore);if(this.clearCreateWatchdog(),!e.sessionId){e.creatingSession&&this.stateStore.update(r=>({...r,creatingSession:!1}));return}this.send({type:"session_leave",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,notice:null,sudoPrompt:null,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null})),this.clearLoadWatchdog(),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0}resolveConflict(e,r){const s=Qt(this.stateStore);s.conflict&&(this.send({type:"session_resolve_conflict",action:e,sessionId:s.conflict.targetSessionId,cwd:r||s.conflict.conflictingCwd}),this.stateStore.update(o=>({...o,conflict:null,readOnly:e==="read_only"})))}ping(){this.send({type:"ping"})}clearMessages(){this.stateStore.update(e=>({...e,messages:[]}))}dismissSessionError(){this.stateStore.update(e=>({...e,sessionError:null}))}dismissNotice(){this.stateStore.update(e=>({...e,notice:null}))}sendSudoPassword(e){const s=Qt(this.stateStore).sudoPrompt;s&&(this.send({type:"bash_sudo_password",sessionId:s.sessionId,promptId:s.promptId,password:e}),this.stateStore.update(o=>({...o,sudoPrompt:null})))}cancelSudoPrompt(){const r=Qt(this.stateStore).sudoPrompt;this.stateStore.update(s=>({...s,sudoPrompt:null})),r&&this.send({type:"bash_sudo_cancel",sessionId:r.sessionId,promptId:r.promptId})}changeModel(e){this.send({type:"model_change",model:e})}setConfig(e){this.config={...this.config,...e},this.stateStore.update(r=>{const s={...r};return e.hideThinking!==void 0&&(s.hideThinking=!!e.hideThinking),e.hideTools!==void 0&&(s.hideTools=!!e.hideTools),s})}onMessage(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}uploadFileViaWebSocket(e,r,s){return new Promise((o,a)=>{const l=this.generateId();this.pendingUploads.set(l,{resolve:o,reject:a}),this.send({type:"file_upload",uploadId:l,sessionId:e,filename:r,data:s})})}generateId(){return Math.random().toString(36).substring(2)+Date.now().toString(36)}getIsConnected(){return this.ws&&this.ws.readyState===1}}const yr=Dn({folders:[],activeSessions:[],currentSession:null,loading:!1}),wr=Dn({models:[],loading:!1}),$r=Dn({folders:[],activeSessions:[],currentSession:null,loading:!1});function ms(){if(typeof window<"u"&&window.location){const n=window.location;if(n.port)return Number(n.port);if(n.protocol==="https:")return 443;if(n.protocol==="http:")return 80}return 31415}function Wn(){const n=localStorage.getItem("wherever-config"),e=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost";if(n){const r=JSON.parse(n),s=window.location.protocol==="https:"?"https:":"http:";let o=r.host||e;(o==="localhost"||o==="127.0.0.1")&&e&&e!=="localhost"&&e!=="127.0.0.1"&&(o=e),o=o.startsWith("http")?o.replace(/^wss?:\/\//,""):o;let a=r.port;return(a===31415||a===void 0)&&ms()!==31415&&(a=ms()),`${s}//${o}:${a||ms()}`}return`${window.location.protocol}//${window.location.host}`}let kr=null,Cs=[],Is=!1,Rs=!1,So=0;const Zi=150,Xi=1e3;async function ko(){Is=!0;try{const n=Wn(),e=Gn(),r=`${n}/sessions${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();yr.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Hn(yr).currentSession,loading:!1})}catch(n){yr.update(e=>({...e,loading:!1})),console.error("Failed to fetch sessions:",n)}finally{Is=!1}}function Lr(){yr.update(r=>({...r,loading:!0}));const n=new Promise(r=>{Cs.push(r)});if(Is)return Rs=!0,n;const e=Date.now();if(!kr)So=e;else if(clearTimeout(kr),e-So>=Xi)return kr=null,To(),n;return kr=setTimeout(()=>{kr=null,To()},Zi),n}async function To(){const n=[...Cs];Cs=[];try{for(await ko();Rs;)Rs=!1,await ko()}finally{for(const e of n)e()}}async function ra(){$r.update(n=>({...n,loading:!0}));try{const n=Wn(),e=Gn(),r=`${n}/sessions?view=readonly${e?`&token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();$r.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:Hn($r).currentSession,loading:!1})}catch(n){$r.update(e=>({...e,loading:!1})),console.error("Failed to fetch read-only sessions:",n)}}async function Qi(){wr.update(n=>({...n,loading:!0}));try{const n=Wn(),e=Gn(),r=`${n}/models${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();wr.set({models:o.models||[],loading:!1})}catch(n){wr.update(e=>({...e,loading:!1})),console.error("Failed to fetch models:",n)}}function Gn(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n).token||""}catch{}return""}const js=Dn(!1),sa=Dn("websocket"),qs=Dn(null),oa=Dn(!1),aa=Dn(null);async function ia(n){if(!n.trim())return null;try{const e=Wn(),r=Gn(),s=`${e}/check-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}catch(e){return console.error("Failed to check path:",e),null}}async function Qr(n){try{const e=Wn(),r=Gn(),s=`${e}/autocomplete-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return(await o.json()).completions||[]}catch(e){return console.error("Failed to autocomplete path:",e),[]}}async function Ji(){try{const n=Wn(),e=Gn(),r=`${n}/config${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();js.set(!!o.gitInitDefault),sa.set(o.uploadMethod||"websocket"),qs.set(o.searchFolder||null),oa.set(!!o.searchCreateRemote),aa.set(o.searchDefaultModel||null)}catch(n){console.error("Failed to fetch config:",n)}}function Or(n){yr.update(e=>({...e,currentSession:n}))}function el(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n)}catch{}return null}function Br(n){localStorage.setItem("wherever-config",JSON.stringify(n))}function xs(){if(typeof window<"u"&&window.location){const n=window.location;if(n.port)return Number(n.port);if(n.protocol==="https:")return 443;if(n.protocol==="http:")return 80}return 31415}function Qn(){const n=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",e=el();return e?((e.port===31415||e.port===void 0)&&xs()!==31415&&(e.port=xs()),(!e.host||e.host==="localhost"||e.host==="127.0.0.1")&&n&&n!=="localhost"&&n!=="127.0.0.1"?{hideThinking:!1,hideTools:!1,...e,host:n}:(e.host||(e.host=n),{hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:"",...e})):{host:n,port:xs(),token:"",hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:""}}const rs=Dn(!!Qn().beepDefault),la="wherever-beep-overrides";function tl(){try{const n=localStorage.getItem(la);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function nl(n){try{localStorage.setItem(la,JSON.stringify(n))}catch{}}const ca=Dn(typeof localStorage<"u"?tl():{}),Vs=Dn("");function rl(){return Hn(rs)}function da(){const n=Qn().beepSoundUrl;return typeof n=="string"?n:""}function sl(n){const e=Qn();Br({...e,beepSoundUrl:n})}const Ks=Wt([Vs,ca],([n,e])=>n&&n in e?e[n]:void 0),Ys=Wt([Ks,rs],([n,e])=>n===void 0?e:n);function ol(n){const e=Qn();Br({...e,beepDefault:n}),rs.set(n)}function Yr(n){const e=Hn(Vs);e&&ca.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,nl(s),s})}function ua(n){Vs.set(n??"")}const Tr=Qn(),lt=new Fn({host:Tr.host,port:Tr.port,token:Tr.token,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!Tr.hideThinking,hideTools:!!Tr.hideTools}),ss=lt.stateStore;let _s=!1,Ao=null;ss.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==Ao){Ao=e,ua(e),_s=n.isStreaming;return}_s&&!n.isStreaming&&e&&Hn(Ys)&&na(da()),_s=n.isStreaming});let Mr=null;lt.onMessage(n=>{switch(n.type){case"session_created":if(Or(n.sessionFile),Mr!==null){const r=Mr;Mr=null,queueMicrotask(()=>lt.sendMessage(r))}break;case"session_error":Mr=null;break;case"session_destroyed":Hn(ss).sessionId===n.sessionId&&Or(null);break;case"sessions_updated":Lr();break;case"session_interrupted":Or(null);break}});function ur(){const n=Qn();Br(n);const e=typeof window<"u"&&window.location&&window.location.protocol==="https:";lt.connect({host:n.host,port:n.port,token:n.token,secure:e,hideThinking:!!n.hideThinking,hideTools:!!n.hideTools})}function Ur(){lt.disconnect(!0),Or(null)}function fa(){lt.suspend()}function $s(){lt.resume()}function al(){return lt.hasSuspendedSession()}function Ms(){return lt.hasActiveSession()}let Zs=0;const il=300*1e3;function pa(){Zs=Date.now()+il}function Xs(){Zs=0}function ha(){return Date.now()<Zs}function Ds(n){return lt.sendMessage(n)}function ba(n){return lt.resendMessage(n)}function va(n){lt.discardMessage(n)}function ga(){lt.abort()}function ma(n,e,r){lt.joinSession(n,e,r)}function Qs(n,e,r){lt.switchSession(n,e,r)}function zn(n,e,r,s,o){lt.createSession(n,e,r,s,o)}function xa(n,e){const r=n.trim();if(!r)return!1;const s=Hn(qs);if(!s)return!1;const o=Hn(oa);return Mr=r,lt.createSession(s,e||void 0,o,o,o?"private":void 0),!0}function In(){lt.leaveSession(),Or(null)}function _a(){lt.loadMoreHistory()}function Ps(n,e){lt.resolveConflict(n,e)}function ll(){lt.ping()}function ya(){lt.clearMessages()}function Ls(n){Br(n);const{host:e,port:r,token:s,hideThinking:o,hideTools:a}=n;lt.setConfig({host:e,port:r,token:s,hideThinking:o,hideTools:a}),n.beepDefault!==void 0&&rs.set(!!n.beepDefault)}function wa(n){const r={...Qn(),...n};Br(r),lt.setConfig(r)}function fr(){lt.dismissSessionError()}function Sa(){lt.dismissNotice()}function ka(n){lt.sendSudoPassword(n)}function Ta(){lt.cancelSudoPrompt()}function Aa(n){lt.changeModel(n)}const $t=Wt(ss,n=>n),Hr=Wt($t,n=>n.connected),Js=Wt($t,n=>n.isStreaming),Ea=Wt($t,n=>n.messages),cl=Wt($t,n=>n.error),dl=Wt($t,n=>n.session),Ca=Wt($t,n=>n.conflict),Ia=Wt($t,n=>n.isInterrupted),eo=Wt($t,n=>n.sessionError),Ra=Wt($t,n=>n.notice),$a=Wt($t,n=>n.sudoPrompt),os=Wt($t,n=>n.readOnly),Wr=Wt($t,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),ul=Wt($t,n=>n.contextUsage),Ma=Wt($t,n=>n.creatingSession),as=Wt($t,n=>n.loadingSession),to=Wt($t,n=>n.resyncing),Da=Wt($t,n=>n.agentPending),Pa=Wt($t,n=>n.historyOffset>0),La=Wt($t,n=>n.loadingMoreHistory);async function fl(n,e){const r=Wn(),s=Gn(),o=`${r}/session/upload?sessionId=${encodeURIComponent(n)}&filename=${encodeURIComponent(e.name)}${s?`&token=${encodeURIComponent(s)}`:""}`,a=await e.arrayBuffer(),l=await fetch(o,{method:"POST",headers:{"Content-Type":"text/plain"},body:a});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||`Upload failed with status ${l.status}`)}return await l.json()}function pl(n,e){return new Promise((r,s)=>{try{const o=new FileReader;o.onload=()=>{try{const l=o.result.split(",")[1]||"";lt.uploadFileViaWebSocket(n,e.name,l).then(r).catch(s)}catch(a){s(new Error(`Failed to process file data: ${a.message}`))}},o.onerror=()=>{s(new Error("Failed to read file contents"))},o.readAsDataURL(e)}catch(o){s(o)}})}function Oa(n){const r=Hn($t).sessionId;if(!r)return null;const s=Wn(),o=Gn();return`${s}/session/download?sessionId=${encodeURIComponent(r)}&path=${encodeURIComponent(n)}`+(o?`&token=${encodeURIComponent(o)}`:"")}async function Na(n,e){return Hn(sa)==="post"?fl(n,e):pl(n,e)}async function Os(n){try{const e=Wn(),r=Gn(),s=`${e}/session/delete${r?`?token=${encodeURIComponent(r)}`:""}`,o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionFile:n})});if(!o.ok){const a=await o.json().catch(()=>({}));throw new Error(a.error||`Delete failed with status ${o.status}`)}}catch(e){throw console.error("Failed to delete session:",e),e}}const hl=Object.freeze(Object.defineProperty({__proto__:null,abort:ga,activeSessionInfo:Wr,beepEnabled:Ys,beepSessionOverride:Ks,beginFilePicker:pa,cancelSudoPrompt:Ta,changeModel:Aa,clearMessages:ya,client:lt,conflict:Ca,connect:ur,connectionError:cl,contextUsage:ul,createSession:zn,currentSession:dl,deleteSession:Os,discardMessage:va,disconnect:Ur,dismissNotice:Sa,dismissSessionError:fr,downloadFileUrl:Oa,endFilePicker:Xs,getBeepDefault:rl,getBeepSoundUrl:da,getConfig:Qn,hasActiveSession:Ms,hasMoreHistory:Pa,hasSuspendedSession:al,isAgentPending:Da,isConnected:Hr,isCreatingSession:Ma,isFilePickerActive:ha,isInterrupted:Ia,isLoadingMoreHistory:La,isLoadingSession:as,isReadOnly:os,isResyncing:to,isStreaming:Js,joinSession:ma,leaveSession:In,loadMoreHistory:_a,messages:Ea,piState:$t,ping:ll,resendMessage:ba,resolveConflict:Ps,resume:$s,runSearch:xa,sendMessage:Ds,sendSudoPassword:ka,sessionError:eo,sessionNotice:Ra,setBeepDefault:ol,setBeepSessionKey:ua,setBeepSessionOverride:Yr,setBeepSoundUrl:sl,setConfig:Ls,state:ss,sudoPrompt:$a,suspend:fa,switchSession:Qs,updateConfig:wa,uploadFile:Na},Symbol.toStringTag,{value:"Module"}));var bl=m('<button class="flex-1 rounded bg-rose-500 px-4 py-2 text-sm text-white transition-colors hover:bg-rose-600">Disconnect</button>'),vl=m('<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>'),gl=m('<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-beep-default" 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-beep-default" class="cursor-pointer text-xs text-brand-text select-none">Beep when the agent is waiting (default for new sessions)</label></div> <div><label for="pi-beep-sound" class="mb-1 block text-xs text-brand-text-muted">Beep sound URL (optional, blank = built-in chime)</label> <div class="flex gap-2"><input id="pi-beep-sound" type="text" placeholder="/sounds/complete.mp3 or https://..." 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"/> <button type="button" title="Play the beep to test it" class="flex-shrink-0 rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3">Test</button></div></div> <div class="flex gap-2"><!></div> <button title="Reload the page" class="flex w-full items-center justify-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-4 py-2 text-sm text-brand-text transition-colors hover:bg-brand-surface-3"><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-4 w-4" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg> Reload</button></div></div>');function ml(n,e){Zn(e,!0);const r=()=>$e(Hr,"$isConnected",s),[s,o]=hr();let a=q(""),l=q(0),c=q(""),x=q(!1),v=q(!1),g=q(""),I=!1,L=V(r);zr(()=>{const K=Qn();p(a,K.host,!0),p(l,K.port,!0),p(c,K.token||"",!0),p(x,!!K.hideThinking),p(v,!!K.beepDefault),p(g,K.beepSoundUrl||"",!0)});function O(){na(t(g).trim()||void 0)}function T(){Ls({host:t(a),port:t(l),token:t(c),hideThinking:t(x),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(g).trim()})}function G(){Ls({host:t(a),port:t(l),token:t(c),hideThinking:t(x),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(g).trim()}),Ur(),setTimeout(()=>ur(),100)}function ee(){Ur()}function ue(){window.location.reload()}var re=gl(),Ve=u(re),Se=u(Ve),Re=f(u(Se),2);nt(Re),d(Se);var xe=f(Se,2),Le=f(u(xe),2);nt(Le),d(xe);var Me=f(xe,2),Et=f(u(Me),2);nt(Et),d(Me);var rt=f(Me,2),be=u(rt);nt(be),tt(2),d(rt);var Ye=f(rt,2),Gt=u(Ye);nt(Gt),tt(2),d(Ye);var Ge=f(Ye,2),st=f(u(Ge),2),yt=u(st);nt(yt);var ot=f(yt,2);d(st),d(Ge);var et=f(Ge,2),we=u(et);{var at=K=>{var mt=bl();W("click",mt,ee),h(K,mt)},Ie=K=>{var mt=vl();mt.disabled=I,mt.textContent="Connect",W("click",mt,G),h(K,mt)};E(we,K=>{t(L)?K(at):K(Ie,-1)})}d(et);var Nt=f(et,2);d(Ve),d(re),$n(Re,()=>t(a),K=>p(a,K)),$n(Le,()=>t(l),K=>p(l,K)),$n(Et,()=>t(c),K=>p(c,K)),W("change",be,T),Mn(be,()=>t(x),K=>p(x,K)),W("change",Gt,T),Mn(Gt,()=>t(v),K=>p(v,K)),W("change",yt,T),$n(yt,()=>t(g),K=>p(g,K)),W("click",ot,O),W("click",Nt,ue),h(n,re),Xn(),o()}or(["change","click"]);function no(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var br=no();function Fa(n){br=n}var Nr={exec:()=>null};function ft(n,e=""){let r=typeof n=="string"?n:n.source;const s={replace:(o,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(vn.caret,"$1"),r=r.replace(o,l),s},getRegex:()=>new RegExp(r,e)};return s}var vn={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},xl=/^(?:[ \t]*(?:\n|$))+/,_l=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,yl=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,wl=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ro=/(?:[*+-]|\d{1,9}[.)])/,Ua=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,za=ft(Ua).replace(/bull/g,ro).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Sl=ft(Ua).replace(/bull/g,ro).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),so=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,kl=/^[^\n]+/,oo=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Tl=ft(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",oo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Al=ft(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ro).getRegex(),is="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ao=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,El=ft("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ao).replace("tag",is).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ba=ft(so).replace("hr",Gr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex(),Cl=ft(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ba).getRegex(),io={blockquote:Cl,code:_l,def:Tl,fences:yl,heading:wl,hr:Gr,html:El,lheading:za,list:Al,newline:xl,paragraph:Ba,table:Nr,text:kl},Eo=ft("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex(),Il={...io,lheading:Sl,table:Eo,paragraph:ft(so).replace("hr",Gr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Eo).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex()},Rl={...io,html:ft(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ao).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Nr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ft(so).replace("hr",Gr).replace("heading",` *#{1,6} *[^
|
|
11
|
+
]`).replace("lheading",za).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},$l=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ml=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ha=/^( {2,}|\\)\n(?!\s*$)/,Dl=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ls=/[\p{P}\p{S}]/u,lo=/[\s\p{P}\p{S}]/u,Wa=/[^\s\p{P}\p{S}]/u,Pl=ft(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,lo).getRegex(),Ga=/(?!~)[\p{P}\p{S}]/u,Ll=/(?!~)[\s\p{P}\p{S}]/u,Ol=/(?:[^\s\p{P}\p{S}]|~)/u,Nl=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ja=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Fl=ft(ja,"u").replace(/punct/g,ls).getRegex(),Ul=ft(ja,"u").replace(/punct/g,Ga).getRegex(),qa="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",zl=ft(qa,"gu").replace(/notPunctSpace/g,Wa).replace(/punctSpace/g,lo).replace(/punct/g,ls).getRegex(),Bl=ft(qa,"gu").replace(/notPunctSpace/g,Ol).replace(/punctSpace/g,Ll).replace(/punct/g,Ga).getRegex(),Hl=ft("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Wa).replace(/punctSpace/g,lo).replace(/punct/g,ls).getRegex(),Wl=ft(/\\(punct)/,"gu").replace(/punct/g,ls).getRegex(),Gl=ft(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),jl=ft(ao).replace("(?:-->|$)","-->").getRegex(),ql=ft("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",jl).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Jr=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Vl=ft(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Jr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Va=ft(/^!?\[(label)\]\[(ref)\]/).replace("label",Jr).replace("ref",oo).getRegex(),Ka=ft(/^!?\[(ref)\](?:\[\])?/).replace("ref",oo).getRegex(),Kl=ft("reflink|nolink(?!\\()","g").replace("reflink",Va).replace("nolink",Ka).getRegex(),co={_backpedal:Nr,anyPunctuation:Wl,autolink:Gl,blockSkip:Nl,br:Ha,code:Ml,del:Nr,emStrongLDelim:Fl,emStrongRDelimAst:zl,emStrongRDelimUnd:Hl,escape:$l,link:Vl,nolink:Ka,punctuation:Pl,reflink:Va,reflinkSearch:Kl,tag:ql,text:Dl,url:Nr},Yl={...co,link:ft(/^!?\[(label)\]\((.*?)\)/).replace("label",Jr).getRegex(),reflink:ft(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Jr).getRegex()},Ns={...co,emStrongRDelimAst:Bl,emStrongLDelim:Ul,url:ft(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Zl={...Ns,br:ft(Ha).replace("{2,}","*").getRegex(),text:ft(Ns.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},qr={normal:io,gfm:Il,pedantic:Rl},Ar={normal:co,gfm:Ns,breaks:Zl,pedantic:Yl},Xl={"&":"&","<":"<",">":">",'"':""","'":"'"},Co=n=>Xl[n];function On(n,e){if(e){if(vn.escapeTest.test(n))return n.replace(vn.escapeReplace,Co)}else if(vn.escapeTestNoEncode.test(n))return n.replace(vn.escapeReplaceNoEncode,Co);return n}function Io(n){try{n=encodeURI(n).replace(vn.percentDecode,"%")}catch{return null}return n}function Ro(n,e){const r=n.replace(vn.findPipe,(a,l,c)=>{let x=!1,v=l;for(;--v>=0&&c[v]==="\\";)x=!x;return x?"|":" |"}),s=r.split(vn.splitPipe);let o=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;o<s.length;o++)s[o]=s[o].trim().replace(vn.slashPipe,"|");return s}function Er(n,e,r){const s=n.length;if(s===0)return"";let o=0;for(;o<s&&n.charAt(s-o-1)===e;)o++;return n.slice(0,s-o)}function Ql(n,e){if(n.indexOf(e[1])===-1)return-1;let r=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])r++;else if(n[s]===e[1]&&(r--,r<0))return s;return r>0?-2:-1}function $o(n,e,r,s,o){const a=e.href,l=e.title||null,c=n[1].replace(o.other.outputLinkReplace,"$1");s.state.inLink=!0;const x={type:n[0].charAt(0)==="!"?"image":"link",raw:r,href:a,title:l,text:c,tokens:s.inlineTokens(c)};return s.state.inLink=!1,x}function Jl(n,e,r){const s=n.match(r.other.indentCodeCompensation);if(s===null)return e;const o=s[1];return e.split(`
|
|
12
12
|
`).map(a=>{const l=a.match(r.other.beginningSpace);if(l===null)return a;const[c]=l;return c.length>=o.length?a.slice(o.length):a}).join(`
|
|
13
13
|
`)}var es=class{options;rules;lexer;constructor(n){this.options=n||br}space(n){const e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){const e=this.rules.block.code.exec(n);if(e){const r=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Er(r,`
|
|
14
|
-
`)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const r=e[0],s=
|
|
14
|
+
`)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const r=e[0],s=Jl(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(n){const e=this.rules.block.heading.exec(n);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){const s=Er(r,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(r=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(n){const e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:Er(e[0],`
|
|
15
15
|
`)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let r=Er(e[0],`
|
|
16
16
|
`).split(`
|
|
17
17
|
`),s="",o="";const a=[];for(;r.length>0;){let l=!1;const c=[];let x;for(x=0;x<r.length;x++)if(this.rules.other.blockquoteStart.test(r[x]))c.push(r[x]),l=!0;else if(!l)c.push(r[x]);else break;r=r.slice(x);const v=c.join(`
|
|
@@ -30,9 +30,9 @@ ${g}`:g;const I=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
|
|
|
30
30
|
`,1)[0];let Le;if(L=xe,this.options.pedantic?(L=L.replace(this.rules.other.listReplaceNesting," "),Le=L):Le=L.replace(this.rules.other.tabCharGlobal," "),Ve.test(L)||Se.test(L)||Re.test(L)||ue.test(L)||re.test(L))break;if(Le.search(this.rules.other.nonSpaceChar)>=T||!L.trim())g+=`
|
|
31
31
|
`+Le.slice(T);else{if(O||I.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Ve.test(I)||Se.test(I)||re.test(I))break;g+=`
|
|
32
32
|
`+L}!O&&!L.trim()&&(O=!0),v+=xe+`
|
|
33
|
-
`,n=n.substring(xe.length+1),I=Le.slice(T)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(v)&&(l=!0));let G=null,ee;this.options.gfm&&(G=this.rules.other.listIsTask.exec(g),G&&(ee=G[0]!=="[ ] ",g=g.replace(this.rules.other.listReplaceTask,""))),o.items.push({type:"list_item",raw:v,task:!!G,checked:ee,loose:!1,text:g,tokens:[]}),o.raw+=v}const c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let x=0;x<o.items.length;x++)if(this.lexer.state.top=!1,o.items[x].tokens=this.lexer.blockTokens(o.items[x].text,[]),!o.loose){const v=o.items[x].tokens.filter(I=>I.type==="space"),g=v.length>0&&v.some(I=>this.rules.other.anyLine.test(I.raw));o.loose=g}if(o.loose)for(let x=0;x<o.items.length;x++)o.items[x].loose=!0;return o}}html(n){const e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){const e=this.rules.block.def.exec(n);if(e){const r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:e[0],href:s,title:o}}}table(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const r=
|
|
34
|
-
`):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const l of s)this.rules.other.tableAlignRight.test(l)?a.align.push("right"):this.rules.other.tableAlignCenter.test(l)?a.align.push("center"):this.rules.other.tableAlignLeft.test(l)?a.align.push("left"):a.align.push(null);for(let l=0;l<r.length;l++)a.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:a.align[l]});for(const l of o)a.rows.push(
|
|
35
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(n){const e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){const e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){const e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){const e=this.rules.inline.link.exec(n);if(e){const r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const a=Er(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{const a=
|
|
33
|
+
`,n=n.substring(xe.length+1),I=Le.slice(T)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(v)&&(l=!0));let G=null,ee;this.options.gfm&&(G=this.rules.other.listIsTask.exec(g),G&&(ee=G[0]!=="[ ] ",g=g.replace(this.rules.other.listReplaceTask,""))),o.items.push({type:"list_item",raw:v,task:!!G,checked:ee,loose:!1,text:g,tokens:[]}),o.raw+=v}const c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let x=0;x<o.items.length;x++)if(this.lexer.state.top=!1,o.items[x].tokens=this.lexer.blockTokens(o.items[x].text,[]),!o.loose){const v=o.items[x].tokens.filter(I=>I.type==="space"),g=v.length>0&&v.some(I=>this.rules.other.anyLine.test(I.raw));o.loose=g}if(o.loose)for(let x=0;x<o.items.length;x++)o.items[x].loose=!0;return o}}html(n){const e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){const e=this.rules.block.def.exec(n);if(e){const r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:e[0],href:s,title:o}}}table(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const r=Ro(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
34
|
+
`):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const l of s)this.rules.other.tableAlignRight.test(l)?a.align.push("right"):this.rules.other.tableAlignCenter.test(l)?a.align.push("center"):this.rules.other.tableAlignLeft.test(l)?a.align.push("left"):a.align.push(null);for(let l=0;l<r.length;l++)a.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:a.align[l]});for(const l of o)a.rows.push(Ro(l,a.header.length).map((c,x)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[x]})));return a}}lheading(n){const e=this.rules.block.lheading.exec(n);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(n){const e=this.rules.block.paragraph.exec(n);if(e){const r=e[1].charAt(e[1].length-1)===`
|
|
35
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(n){const e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){const e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){const e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){const e=this.rules.inline.link.exec(n);if(e){const r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const a=Er(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{const a=Ql(e[2],"()");if(a===-2)return;if(a>-1){const c=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,c).trim(),e[3]=""}}let s=e[2],o="";if(this.options.pedantic){const a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],o=a[3])}else o=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?s=s.slice(1):s=s.slice(1,-1)),$o(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){const s=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[s.toLowerCase()];if(!o){const a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return $o(r,o,r[0],this.lexer,this.rules)}}emStrong(n,e,r=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!s||s[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const a=[...s[0]].length-1;let l,c,x=a,v=0;const g=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(g.lastIndex=0,e=e.slice(-1*n.length+a);(s=g.exec(e))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(c=[...l].length,s[3]||s[4]){x+=c;continue}else if((s[5]||s[6])&&a%3&&!((a+c)%3)){v+=c;continue}if(x-=c,x>0)continue;c=Math.min(c,c+x+v);const I=[...s[0]][0].length,L=n.slice(0,a+s.index+I+c);if(Math.min(a,c)%2){const T=L.slice(1,-1);return{type:"em",raw:L,text:T,tokens:this.lexer.inlineTokens(T)}}const O=L.slice(2,-2);return{type:"strong",raw:L,text:O,tokens:this.lexer.inlineTokens(O)}}}}codespan(n){const e=this.rules.inline.code.exec(n);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," ");const s=this.rules.other.nonSpaceChar.test(r),o=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return s&&o&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(n){const e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){const e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){const e=this.rules.inline.autolink.exec(n);if(e){let r,s;return e[2]==="@"?(r=e[1],s="mailto:"+r):(r=e[1],s=r),{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let r,s;if(e[2]==="@")r=e[0],s="mailto:"+r;else{let o;do o=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(o!==e[0]);r=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){const e=this.rules.inline.text.exec(n);if(e){const r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},Kn=class Fs{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||br,this.options.tokenizer=this.options.tokenizer||new es,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const r={other:vn,block:qr.normal,inline:Ar.normal};this.options.pedantic?(r.block=qr.pedantic,r.inline=Ar.pedantic):this.options.gfm&&(r.block=qr.gfm,this.options.breaks?r.inline=Ar.breaks:r.inline=Ar.gfm),this.tokenizer.rules=r}static get rules(){return{block:qr,inline:Ar}}static lex(e,r){return new Fs(r).lex(e)}static lexInline(e,r){return new Fs(r).inlineTokens(e)}lex(e){e=e.replace(vn.carriageReturn,`
|
|
36
36
|
`),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){const s=this.inlineQueue[r];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],s=!1){for(this.options.pedantic&&(e=e.replace(vn.tabCharGlobal," ").replace(vn.spaceLine,""));e;){let o;if(this.options.extensions?.block?.some(l=>(o=l.call({lexer:this},e,r))?(e=e.substring(o.raw.length),r.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);const l=r.at(-1);o.raw.length===1&&l!==void 0?l.raw+=`
|
|
37
37
|
`:r.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);const l=r.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=`
|
|
38
38
|
`+o.raw,l.text+=`
|
|
@@ -60,30 +60,30 @@ ${this.parser.parse(n)}</blockquote>
|
|
|
60
60
|
`}tablerow({text:n}){return`<tr>
|
|
61
61
|
${n}</tr>
|
|
62
62
|
`}tablecell(n){const e=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+`</${r}>
|
|
63
|
-
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${On(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:r}){const s=this.parser.parseInline(r),o=
|
|
64
|
-
`+this.renderer.text(c);r?s+=this.renderer.paragraph({type:"paragraph",raw:x,text:x,tokens:[{type:"text",raw:x,text:x,escaped:!0}]}):s+=x;continue}default:{const c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}parseInline(e,r=this.renderer){let s="";for(let o=0;o<e.length;o++){const a=e[o];if(this.options.extensions?.renderers?.[a.type]){const c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=c||"";continue}}const l=a;switch(l.type){case"escape":{s+=r.text(l);break}case"html":{s+=r.html(l);break}case"link":{s+=r.link(l);break}case"image":{s+=r.image(l);break}case"strong":{s+=r.strong(l);break}case"em":{s+=r.em(l);break}case"codespan":{s+=r.codespan(l);break}case"br":{s+=r.br(l);break}case"del":{s+=r.del(l);break}case"text":{s+=r.text(l);break}default:{const c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},Zr=class{options;block;constructor(n){this.options=n||br}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Kn.lex:Kn.lexInline}provideParser(){return this.block?Yn.parse:Yn.parseInline}},
|
|
65
|
-
Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+On(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},pr=new
|
|
66
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nc(n,e){return Jl(n)||ec(n,e)||rc(n,e)||tc()}function rc(n,e){if(n){if(typeof n=="string")return Ro(n,e);var r={}.toString.call(n).slice(8,-1);return r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set"?Array.from(n):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ro(n,e):void 0}}const Va=Object.entries,$o=Object.setPrototypeOf,sc=Object.isFrozen,oc=Object.getPrototypeOf,ac=Object.getOwnPropertyDescriptor;let cn=Object.freeze,dn=Object.seal,xr=Object.create,Ka=typeof Reflect<"u"&&Reflect,Fs=Ka.apply,Us=Ka.construct;cn||(cn=function(e){return e});dn||(dn=function(e){return e});Fs||(Fs=function(e,r){for(var s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];return e.apply(r,o)});Us||(Us=function(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return new e(...s)});const Cr=Jt(Array.prototype.forEach),ic=Jt(Array.prototype.lastIndexOf),Mo=Jt(Array.prototype.pop),gr=Jt(Array.prototype.push),lc=Jt(Array.prototype.splice),nr=Array.isArray,Dr=Jt(String.prototype.toLowerCase),xs=Jt(String.prototype.toString),Do=Jt(String.prototype.match),Ir=Jt(String.prototype.replace),Po=Jt(String.prototype.indexOf),cc=Jt(String.prototype.trim),dc=Jt(Number.prototype.toString),uc=Jt(Boolean.prototype.toString),Lo=typeof BigInt>"u"?null:Jt(BigInt.prototype.toString),Oo=typeof Symbol>"u"?null:Jt(Symbol.prototype.toString),on=Jt(Object.prototype.hasOwnProperty),Rr=Jt(Object.prototype.toString),ln=Jt(RegExp.prototype.test),cr=fc(TypeError);function Jt(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return Fs(n,e,s)}}function fc(n){return function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return Us(n,r)}}function Qe(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Dr;if($o&&$o(n,null),!nr(e))return n;let s=e.length;for(;s--;){let o=e[s];if(typeof o=="string"){const a=r(o);a!==o&&(sc(e)||(e[s]=a),o=a)}n[o]=!0}return n}function pc(n){for(let e=0;e<n.length;e++)on(n,e)||(n[e]=null);return n}function bn(n){const e=xr(null);for(const s of Va(n)){var r=nc(s,2);const o=r[0],a=r[1];on(n,o)&&(nr(a)?e[o]=pc(a):a&&typeof a=="object"&&a.constructor===Object?e[o]=bn(a):e[o]=a)}return e}function hc(n){switch(typeof n){case"string":return n;case"number":return dc(n);case"boolean":return uc(n);case"bigint":return Lo?Lo(n):"0";case"symbol":return Oo?Oo(n):"Symbol()";case"undefined":return Rr(n);case"function":case"object":{if(n===null)return Rr(n);const e=n,r=Nn(e,"toString");if(typeof r=="function"){const s=r(e);return typeof s=="string"?s:Rr(s)}return Rr(n)}default:return Rr(n)}}function Nn(n,e){for(;n!==null;){const s=ac(n,e);if(s){if(s.get)return Jt(s.get);if(typeof s.value=="function")return Jt(s.value)}n=oc(n)}function r(){return null}return r}function bc(n){try{return ln(n,""),!0}catch{return!1}}const No=cn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),_s=cn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ys=cn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),vc=cn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ws=cn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),gc=cn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fo=cn(["#text"]),Uo=cn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ss=cn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),zo=cn(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Vr=cn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),mc=dn(/{{[\w\W]*|^[\w\W]*}}/g),xc=dn(/<%[\w\W]*|^[\w\W]*%>/g),_c=dn(/\${[\w\W]*/g),yc=dn(/^data-[\-\w.\u00B7-\uFFFF]+$/),wc=dn(/^aria-[\-\w]+$/),Bo=dn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Sc=dn(/^(?:\w+script|data):/i),kc=dn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Tc=dn(/^html$/i),Ac=dn(/^[a-z][.\w]*(-[.\w]+)+$/i),Ho=dn(/<[/\w!]/g),Ec=dn(/<[/\w]/g),Cc=dn(/<\/no(script|embed|frames)/i),Ic=dn(/\/>/i),Ln={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Rc=function(){return typeof window>"u"?null:window},$c=function(e,r){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(s=r.getAttribute(o));const a="dompurify"+(s?"#"+s:"");try{return e.createPolicy(a,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Wo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},er=function(e,r,s,o){return on(e,r)&&nr(e[r])?Qe(o.base?bn(o.base):{},e[r],o.transform):s};function Ya(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Rc();const e=S=>Ya(S);if(e.version="3.4.11",e.removed=[],!n||!n.document||n.document.nodeType!==Ln.document||!n.Element)return e.isSupported=!1,e;let r=n.document;const s=r,o=s.currentScript;n.DocumentFragment;const a=n.HTMLTemplateElement,l=n.Node,c=n.Element,x=n.NodeFilter,v=n.NamedNodeMap;v===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const g=n.DOMParser,I=n.trustedTypes,L=c.prototype,O=Nn(L,"cloneNode"),T=Nn(L,"remove"),G=Nn(L,"nextSibling"),ee=Nn(L,"childNodes"),ue=Nn(L,"parentNode"),re=Nn(L,"shadowRoot"),Ve=Nn(L,"attributes"),Se=l&&l.prototype?Nn(l.prototype,"nodeType"):null,Re=l&&l.prototype?Nn(l.prototype,"nodeName"):null;if(typeof a=="function"){const S=r.createElement("template");S.content&&S.content.ownerDocument&&(r=S.content.ownerDocument)}let xe,Le="",Me,Et=!1,rt=0;const be=function(){if(rt>0)throw cr('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ye=function(i){be(),rt++;try{return xe.createHTML(i)}finally{rt--}},Gt=function(i){be(),rt++;try{return xe.createScriptURL(i)}finally{rt--}},Ge=function(){return Et||(Me=$c(I,o),Et=!0),Me},st=r,yt=st.implementation,ot=st.createNodeIterator,et=st.createDocumentFragment,we=st.getElementsByTagName,at=s.importNode;let Ie=Wo();e.isSupported=typeof Va=="function"&&typeof ue=="function"&&yt&&yt.createHTMLDocument!==void 0;const Nt=mc,K=xc,mt=_c,an=yc,pt=wc,xt=Sc,Oe=kc,Z=Ac;let _e=Bo,k=null;const te=Qe({},[...No,..._s,...ys,...ws,...Fo]);let C=null;const oe=Qe({},[...Uo,...Ss,...zo,...Vr]);let z=Object.seal(xr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ve=null,fe=null;const Ze=Object.seal(xr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ue=!0,vt=!0,wt=!1,je=!0,ze=!1,Ft=!0,jt=!1,Ut=!1,hn=null,St=null,_t=!1,kt=!1,gt=!1,Kt=!1,Yt=!0,wn=!1;const ke="user-content-";let ht=!0,Mt=!1,Tt={},At=null;const Zt=Qe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let en=null;const mn=Qe({},["audio","video","img","source","image","track"]);let un=null;const xn=Qe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),P="http://www.w3.org/1998/Math/MathML",j="http://www.w3.org/2000/svg",Y="http://www.w3.org/1999/xhtml";let Q=Y,Te=!1,qt=null;const Dt=Qe({},[P,j,Y],xs),zt=cn(["mi","mo","mn","ms","mtext"]);let Ct=Qe({},zt);const Pt=cn(["annotation-xml"]);let $=Qe({},Pt);const N=Qe({},["title","style","font","a","script"]);let ge=null;const Ae=["application/xhtml+xml","text/html"],Ne="text/html";let ae=null,ce=null;const De=r.createElement("form"),Ee=function(i){return i instanceof RegExp||i instanceof Function},ct=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ce&&ce===i)return;(!i||typeof i!="object")&&(i={}),i=bn(i),ge=Ae.indexOf(i.PARSER_MEDIA_TYPE)===-1?Ne:i.PARSER_MEDIA_TYPE,ae=ge==="application/xhtml+xml"?xs:Dr,k=er(i,"ALLOWED_TAGS",te,{transform:ae}),C=er(i,"ALLOWED_ATTR",oe,{transform:ae}),qt=er(i,"ALLOWED_NAMESPACES",Dt,{transform:xs}),un=er(i,"ADD_URI_SAFE_ATTR",xn,{transform:ae,base:xn}),en=er(i,"ADD_DATA_URI_TAGS",mn,{transform:ae,base:mn}),At=er(i,"FORBID_CONTENTS",Zt,{transform:ae}),ve=er(i,"FORBID_TAGS",bn({}),{transform:ae}),fe=er(i,"FORBID_ATTR",bn({}),{transform:ae}),Tt=on(i,"USE_PROFILES")?i.USE_PROFILES&&typeof i.USE_PROFILES=="object"?bn(i.USE_PROFILES):i.USE_PROFILES:!1,Ue=i.ALLOW_ARIA_ATTR!==!1,vt=i.ALLOW_DATA_ATTR!==!1,wt=i.ALLOW_UNKNOWN_PROTOCOLS||!1,je=i.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ze=i.SAFE_FOR_TEMPLATES||!1,Ft=i.SAFE_FOR_XML!==!1,jt=i.WHOLE_DOCUMENT||!1,kt=i.RETURN_DOM||!1,gt=i.RETURN_DOM_FRAGMENT||!1,Kt=i.RETURN_TRUSTED_TYPE||!1,_t=i.FORCE_BODY||!1,Yt=i.SANITIZE_DOM!==!1,wn=i.SANITIZE_NAMED_PROPS||!1,ht=i.KEEP_CONTENT!==!1,Mt=i.IN_PLACE||!1,_e=bc(i.ALLOWED_URI_REGEXP)?i.ALLOWED_URI_REGEXP:Bo,Q=typeof i.NAMESPACE=="string"?i.NAMESPACE:Y,Ct=on(i,"MATHML_TEXT_INTEGRATION_POINTS")&&i.MATHML_TEXT_INTEGRATION_POINTS&&typeof i.MATHML_TEXT_INTEGRATION_POINTS=="object"?bn(i.MATHML_TEXT_INTEGRATION_POINTS):Qe({},zt),$=on(i,"HTML_INTEGRATION_POINTS")&&i.HTML_INTEGRATION_POINTS&&typeof i.HTML_INTEGRATION_POINTS=="object"?bn(i.HTML_INTEGRATION_POINTS):Qe({},Pt);const b=on(i,"CUSTOM_ELEMENT_HANDLING")&&i.CUSTOM_ELEMENT_HANDLING&&typeof i.CUSTOM_ELEMENT_HANDLING=="object"?bn(i.CUSTOM_ELEMENT_HANDLING):xr(null);if(z=xr(null),on(b,"tagNameCheck")&&Ee(b.tagNameCheck)&&(z.tagNameCheck=b.tagNameCheck),on(b,"attributeNameCheck")&&Ee(b.attributeNameCheck)&&(z.attributeNameCheck=b.attributeNameCheck),on(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),dn(z),ze&&(vt=!1),gt&&(kt=!0),Tt&&(k=Qe({},Fo),C=xr(null),Tt.html===!0&&(Qe(k,No),Qe(C,Uo)),Tt.svg===!0&&(Qe(k,_s),Qe(C,Ss),Qe(C,Vr)),Tt.svgFilters===!0&&(Qe(k,ys),Qe(C,Ss),Qe(C,Vr)),Tt.mathMl===!0&&(Qe(k,ws),Qe(C,zo),Qe(C,Vr))),Ze.tagCheck=null,Ze.attributeCheck=null,on(i,"ADD_TAGS")&&(typeof i.ADD_TAGS=="function"?Ze.tagCheck=i.ADD_TAGS:nr(i.ADD_TAGS)&&(k===te&&(k=bn(k)),Qe(k,i.ADD_TAGS,ae))),on(i,"ADD_ATTR")&&(typeof i.ADD_ATTR=="function"?Ze.attributeCheck=i.ADD_ATTR:nr(i.ADD_ATTR)&&(C===oe&&(C=bn(C)),Qe(C,i.ADD_ATTR,ae))),on(i,"ADD_URI_SAFE_ATTR")&&nr(i.ADD_URI_SAFE_ATTR)&&Qe(un,i.ADD_URI_SAFE_ATTR,ae),on(i,"FORBID_CONTENTS")&&nr(i.FORBID_CONTENTS)&&(At===Zt&&(At=bn(At)),Qe(At,i.FORBID_CONTENTS,ae)),on(i,"ADD_FORBID_CONTENTS")&&nr(i.ADD_FORBID_CONTENTS)&&(At===Zt&&(At=bn(At)),Qe(At,i.ADD_FORBID_CONTENTS,ae)),ht&&(k["#text"]=!0),jt&&Qe(k,["html","head","body"]),k.table&&(Qe(k,["tbody"]),delete ve.tbody),i.TRUSTED_TYPES_POLICY){if(typeof i.TRUSTED_TYPES_POLICY.createHTML!="function")throw cr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof i.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const R=xe;xe=i.TRUSTED_TYPES_POLICY;try{Le=Ye("")}catch(F){throw xe=R,F}}else i.TRUSTED_TYPES_POLICY===null?(xe=void 0,Le=""):(xe===void 0&&(xe=Ge()),xe&&typeof Le=="string"&&(Le=Ye("")));cn&&cn(i),ce=i},Xt=Qe({},[..._s,...ys,...vc]),fn=Qe({},[...ws,...gc]),y=function(i,b,R){return b.namespaceURI===Y?i==="svg":b.namespaceURI===P?i==="svg"&&(R==="annotation-xml"||Ct[R]):!!Xt[i]},w=function(i,b,R){return b.namespaceURI===Y?i==="math":b.namespaceURI===j?i==="math"&&$[R]:!!fn[i]},M=function(i,b,R){return b.namespaceURI===j&&!$[R]||b.namespaceURI===P&&!Ct[R]?!1:!fn[i]&&(N[i]||!Xt[i])},A=function(i){let b=ue(i);(!b||!b.tagName)&&(b={namespaceURI:Q,tagName:"template"});const R=Dr(i.tagName),F=Dr(b.tagName);return qt[i.namespaceURI]?i.namespaceURI===j?y(R,b,F):i.namespaceURI===P?w(R,b,F):i.namespaceURI===Y?M(R,b,F):!!(ge==="application/xhtml+xml"&&qt[i.namespaceURI]):!1},D=function(i){gr(e.removed,{element:i});try{ue(i).removeChild(i)}catch{if(T(i),!ue(i))throw cr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},U=function(i){const b=ee(i);if(b){const F=[];Cr(b,le=>{gr(F,le)}),Cr(F,le=>{try{T(le)}catch{}})}const R=Ve(i);if(R)for(let F=R.length-1;F>=0;--F){const le=R[F],he=le&&le.name;if(typeof he=="string")try{i.removeAttribute(he)}catch{}}},_=function(i,b){try{gr(e.removed,{attribute:b.getAttributeNode(i),from:b})}catch{gr(e.removed,{attribute:null,from:b})}if(b.removeAttribute(i),i==="is")if(kt||gt)try{D(b)}catch{}else try{b.setAttribute(i,"")}catch{}},ie=function(i){const b=Ve(i);if(b)for(let R=b.length-1;R>=0;--R){const F=b[R],le=F&&F.name;if(!(typeof le!="string"||C[ae(le)]))try{i.removeAttribute(le)}catch{}}},de=function(i){const b=[i];for(;b.length>0;){const R=b.pop();(Se?Se(R):R.nodeType)===Ln.element&&ie(R);const le=ee(R);if(le)for(let he=le.length-1;he>=0;--he)b.push(le[he])}},X=function(i){let b=null,R=null;if(_t)i="<remove></remove>"+i;else{const he=Do(i,/^[\r\n\t ]+/);R=he&&he[0]}ge==="application/xhtml+xml"&&Q===Y&&(i='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+i+"</body></html>");const F=xe?Ye(i):i;if(Q===Y)try{b=new g().parseFromString(F,ge)}catch{}if(!b||!b.documentElement){b=yt.createDocument(Q,"template",null);try{b.documentElement.innerHTML=Te?Le:F}catch{}}const le=b.body||b.documentElement;return i&&R&&le.insertBefore(r.createTextNode(R),le.childNodes[0]||null),Q===Y?we.call(b,jt?"html":"body")[0]:jt?b.documentElement:le},Be=function(i){return ot.call(i.ownerDocument||i,i,x.SHOW_ELEMENT|x.SHOW_COMMENT|x.SHOW_TEXT|x.SHOW_PROCESSING_INSTRUCTION|x.SHOW_CDATA_SECTION,null)},Fe=function(i){return i=Ir(i,Nt," "),i=Ir(i,K," "),i=Ir(i,mt," "),i},dt=function(i){var b;i.normalize();const R=ot.call(i.ownerDocument||i,i,x.SHOW_TEXT|x.SHOW_COMMENT|x.SHOW_CDATA_SECTION|x.SHOW_PROCESSING_INSTRUCTION,null);let F=R.nextNode();for(;F;)F.data=Fe(F.data),F=R.nextNode();const le=(b=i.querySelectorAll)===null||b===void 0?void 0:b.call(i,"template");le&&Cr(le,he=>{Vt(he.content)&&dt(he.content)})},tn=function(i){const b=Re?Re(i):null;return typeof b!="string"||ae(b)!=="form"?!1:typeof i.nodeName!="string"||typeof i.textContent!="string"||typeof i.removeChild!="function"||i.attributes!==Ve(i)||typeof i.removeAttribute!="function"||typeof i.setAttribute!="function"||typeof i.namespaceURI!="string"||typeof i.insertBefore!="function"||typeof i.hasChildNodes!="function"||i.nodeType!==Se(i)||i.childNodes!==ee(i)},Vt=function(i){if(!Se||typeof i!="object"||i===null)return!1;try{return Se(i)===Ln.documentFragment}catch{return!1}},Bt=function(i){if(!Se||typeof i!="object"||i===null)return!1;try{return typeof Se(i)=="number"}catch{return!1}};function Pe(S,i,b){S.length!==0&&Cr(S,R=>{R.call(e,i,b,ce)})}const se=function(i,b){return!!(Ft&&i.hasChildNodes()&&!Bt(i.firstElementChild)&&ln(Ho,i.textContent)&&ln(Ho,i.innerHTML)||Ft&&i.namespaceURI===Y&&b==="style"&&Bt(i.firstElementChild)||i.nodeType===Ln.processingInstruction||Ft&&i.nodeType===Ln.comment&&ln(Ec,i.data))},pe=function(i,b){if(!ve[b]&&Xe(b)&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,b)||z.tagNameCheck instanceof Function&&z.tagNameCheck(b)))return!1;if(ht&&!At[b]){const R=ue(i),F=ee(i);if(F&&R){const le=F.length;for(let he=le-1;he>=0;--he){const qe=Mt?F[he]:O(F[he],!0);R.insertBefore(qe,G(i))}}}return D(i),!0},Ke=function(i){if(Pe(Ie.beforeSanitizeElements,i,null),tn(i))return D(i),!0;const b=ae(Re?Re(i):i.nodeName);if(Pe(Ie.uponSanitizeElement,i,{tagName:b,allowedTags:k}),se(i,b))return D(i),!0;if(ve[b]||!(Ze.tagCheck instanceof Function&&Ze.tagCheck(b))&&!k[b])return pe(i,b);if((Se?Se(i):i.nodeType)===Ln.element&&!A(i)||(b==="noscript"||b==="noembed"||b==="noframes")&&ln(Cc,i.innerHTML))return D(i),!0;if(ze&&i.nodeType===Ln.text){const F=Fe(i.textContent);i.textContent!==F&&(gr(e.removed,{element:i.cloneNode()}),i.textContent=F)}return Pe(Ie.afterSanitizeElements,i,null),!1},Lt=function(i,b,R){if(fe[b]||Yt&&(b==="id"||b==="name")&&(R in r||R in De))return!1;const F=C[b]||Ze.attributeCheck instanceof Function&&Ze.attributeCheck(b,i);if(!(vt&&ln(an,b))){if(!(Ue&&ln(pt,b))){if(F){if(!un[b]){if(!ln(_e,Ir(R,Oe,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&i!=="script"&&Po(R,"data:")===0&&en[i])){if(!(wt&&!ln(xt,Ir(R,Oe,"")))){if(R)return!1}}}}}else if(!(Xe(i)&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,i)||z.tagNameCheck instanceof Function&&z.tagNameCheck(i))&&(z.attributeNameCheck instanceof RegExp&&ln(z.attributeNameCheck,b)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(b,i))||b==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,R)||z.tagNameCheck instanceof Function&&z.tagNameCheck(R))))return!1}}return!0},It=Qe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Xe=function(i){return!It[Dr(i)]&&ln(Z,i)},me=function(i,b,R,F){if(xe&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!R)switch(I.getAttributeType(i,b)){case"TrustedHTML":return Ye(F);case"TrustedScriptURL":return Gt(F)}return F},B=function(i,b,R,F){try{R?i.setAttributeNS(R,b,F):i.setAttribute(b,F),tn(i)?D(i):Mo(e.removed)}catch{_(b,i)}},ne=function(i){Pe(Ie.beforeSanitizeAttributes,i,null);const b=i.attributes;if(!b||tn(i))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:C,forceKeepAttr:void 0};let F=b.length;const le=ae(i.nodeName);for(;F--;){const he=b[F],qe=he.name,bt=he.namespaceURI,Ht=he.value,nn=ae(qe),ar=Ht;let ut=qe==="value"?ar:cc(ar);if(R.attrName=nn,R.attrValue=ut,R.keepAttr=!0,R.forceKeepAttr=void 0,Pe(Ie.uponSanitizeAttribute,i,R),ut=R.attrValue,wn&&(nn==="id"||nn==="name")&&Po(ut,ke)!==0&&(_(qe,i),ut=ke+ut),Ft&&ln(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ut)){_(qe,i);continue}if(nn==="attributename"&&Do(ut,"href")){_(qe,i);continue}if(!R.forceKeepAttr){if(!R.keepAttr){_(qe,i);continue}if(!je&&ln(Ic,ut)){_(qe,i);continue}if(ze&&(ut=Fe(ut)),!Lt(le,nn,ut)){_(qe,i);continue}ut=me(le,nn,bt,ut),ut!==ar&&B(i,qe,bt,ut)}}Pe(Ie.afterSanitizeAttributes,i,null)},Ce=function(i){let b=null;const R=Be(i);for(Pe(Ie.beforeSanitizeShadowDOM,i,null);b=R.nextNode();)if(Pe(Ie.uponSanitizeShadowNode,b,null),Ke(b),ne(b),Vt(b.content)&&Ce(b.content),(Se?Se(b):b.nodeType)===Ln.element){const le=re(b);Vt(le)&&(He(le),Ce(le))}Pe(Ie.afterSanitizeShadowDOM,i,null)},He=function(i){const b=[{node:i,shadow:null}];for(;b.length>0;){const R=b.pop();if(R.shadow){Ce(R.shadow);continue}const F=R.node,he=(Se?Se(F):F.nodeType)===Ln.element,qe=ee(F);if(qe)for(let bt=qe.length-1;bt>=0;--bt)b.push({node:qe[bt],shadow:null});if(he){const bt=Re?Re(F):null;if(typeof bt=="string"&&ae(bt)==="template"){const Ht=F.content;Vt(Ht)&&b.push({node:Ht,shadow:null})}}if(he){const bt=re(F);Vt(bt)&&b.push({node:null,shadow:bt},{node:bt,shadow:null})}}};return e.sanitize=function(S){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,R=null,F=null,le=null;if(Te=!S,Te&&(S="<!-->"),typeof S!="string"&&!Bt(S)&&(S=hc(S),typeof S!="string"))throw cr("dirty is not a string, aborting");if(!e.isSupported)return S;Ut?(k=hn,C=St):ct(i),(Ie.uponSanitizeElement.length>0||Ie.uponSanitizeAttribute.length>0)&&(k=bn(k)),Ie.uponSanitizeAttribute.length>0&&(C=bn(C)),e.removed=[];const he=Mt&&typeof S!="string"&&Bt(S);if(he){const Ht=Re?Re(S):S.nodeName;if(typeof Ht=="string"){const nn=ae(Ht);if(!k[nn]||ve[nn])throw cr("root node is forbidden and cannot be sanitized in-place")}if(tn(S))throw cr("root node is clobbered and cannot be sanitized in-place");try{He(S)}catch(nn){throw U(S),nn}}else if(Bt(S))b=X("<!---->"),R=b.ownerDocument.importNode(S,!0),R.nodeType===Ln.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?b=R:b.appendChild(R),He(R);else{if(!kt&&!ze&&!jt&&S.indexOf("<")===-1)return xe&&Kt?Ye(S):S;if(b=X(S),!b)return kt?null:Kt?Le:""}b&&_t&&D(b.firstChild);const qe=Be(he?S:b);try{for(;F=qe.nextNode();)Ke(F),ne(F),Vt(F.content)&&Ce(F.content)}catch(Ht){throw he&&U(S),Ht}if(he)return Cr(e.removed,Ht=>{Ht.element&&de(Ht.element)}),ze&&dt(S),S;if(kt){if(ze&&dt(b),gt)for(le=et.call(b.ownerDocument);b.firstChild;)le.appendChild(b.firstChild);else le=b;return(C.shadowroot||C.shadowrootmode)&&(le=at.call(s,le,!0)),le}let bt=jt?b.outerHTML:b.innerHTML;return jt&&k["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&ln(Tc,b.ownerDocument.doctype.name)&&(bt="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
67
|
-
`+bt),ze&&(bt=Fe(bt)),xe&&Kt?Ye(bt):bt},e.setConfig=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ct(S),Ut=!0,hn=k,St=C},e.clearConfig=function(){ce=null,Ut=!1,hn=null,St=null,xe=Me,Le=""},e.isValidAttribute=function(S,i,b){ce||ct({});const R=ae(S),F=ae(i);return Lt(R,F,b)},e.addHook=function(S,i){typeof i=="function"&&on(Ie,S)&&gr(Ie[S],i)},e.removeHook=function(S,i){if(on(Ie,S)){if(i!==void 0){const b=
|
|
68
|
-
`).filter(I=>I.trim()!==""),l=a.length>1,c=`<pre><code>${Vn(e)}</code></pre>`;if(!l)return c;let v=a[0]??"";return v.length>
|
|
69
|
-
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>`),
|
|
70
|
-
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>`),
|
|
63
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${On(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:r}){const s=this.parser.parseInline(r),o=Io(n);if(o===null)return s;n=o;let a='<a href="'+n+'"';return e&&(a+=' title="'+On(e)+'"'),a+=">"+s+"</a>",a}image({href:n,title:e,text:r,tokens:s}){s&&(r=this.parser.parseInline(s,this.parser.textRenderer));const o=Io(n);if(o===null)return On(r);n=o;let a=`<img src="${n}" alt="${r}"`;return e&&(a+=` title="${On(e)}"`),a+=">",a}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:On(n.text)}},uo=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}},Yn=class Us{options;renderer;textRenderer;constructor(e){this.options=e||br,this.options.renderer=this.options.renderer||new ts,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new uo}static parse(e,r){return new Us(r).parse(e)}static parseInline(e,r){return new Us(r).parseInline(e)}parse(e,r=!0){let s="";for(let o=0;o<e.length;o++){const a=e[o];if(this.options.extensions?.renderers?.[a.type]){const c=a,x=this.options.extensions.renderers[c.type].call({parser:this},c);if(x!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(c.type)){s+=x||"";continue}}const l=a;switch(l.type){case"space":{s+=this.renderer.space(l);continue}case"hr":{s+=this.renderer.hr(l);continue}case"heading":{s+=this.renderer.heading(l);continue}case"code":{s+=this.renderer.code(l);continue}case"table":{s+=this.renderer.table(l);continue}case"blockquote":{s+=this.renderer.blockquote(l);continue}case"list":{s+=this.renderer.list(l);continue}case"html":{s+=this.renderer.html(l);continue}case"paragraph":{s+=this.renderer.paragraph(l);continue}case"text":{let c=l,x=this.renderer.text(c);for(;o+1<e.length&&e[o+1].type==="text";)c=e[++o],x+=`
|
|
64
|
+
`+this.renderer.text(c);r?s+=this.renderer.paragraph({type:"paragraph",raw:x,text:x,tokens:[{type:"text",raw:x,text:x,escaped:!0}]}):s+=x;continue}default:{const c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}parseInline(e,r=this.renderer){let s="";for(let o=0;o<e.length;o++){const a=e[o];if(this.options.extensions?.renderers?.[a.type]){const c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=c||"";continue}}const l=a;switch(l.type){case"escape":{s+=r.text(l);break}case"html":{s+=r.html(l);break}case"link":{s+=r.link(l);break}case"image":{s+=r.image(l);break}case"strong":{s+=r.strong(l);break}case"em":{s+=r.em(l);break}case"codespan":{s+=r.codespan(l);break}case"br":{s+=r.br(l);break}case"del":{s+=r.del(l);break}case"text":{s+=r.text(l);break}default:{const c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},Zr=class{options;block;constructor(n){this.options=n||br}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Kn.lex:Kn.lexInline}provideParser(){return this.block?Yn.parse:Yn.parseInline}},ec=class{defaults=no();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Yn;Renderer=ts;TextRenderer=uo;Lexer=Kn;Tokenizer=es;Hooks=Zr;constructor(...n){this.use(...n)}walkTokens(n,e){let r=[];for(const s of n)switch(r=r.concat(e.call(this,s)),s.type){case"table":{const o=s;for(const a of o.header)r=r.concat(this.walkTokens(a.tokens,e));for(const a of o.rows)for(const l of a)r=r.concat(this.walkTokens(l.tokens,e));break}case"list":{const o=s;r=r.concat(this.walkTokens(o.items,e));break}default:{const o=s;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{const l=o[a].flat(1/0);r=r.concat(this.walkTokens(l,e))}):o.tokens&&(r=r.concat(this.walkTokens(o.tokens,e)))}}return r}use(...n){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(r=>{const s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){const a=e.renderers[o.name];a?e.renderers[o.name]=function(...l){let c=o.renderer.apply(this,l);return c===!1&&(c=a.apply(this,l)),c}:e.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=e[o.level];a?a.unshift(o.tokenizer):e[o.level]=[o.tokenizer],o.start&&(o.level==="block"?e.startBlock?e.startBlock.push(o.start):e.startBlock=[o.start]:o.level==="inline"&&(e.startInline?e.startInline.push(o.start):e.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(e.childTokens[o.name]=o.childTokens)}),s.extensions=e),r.renderer){const o=this.defaults.renderer||new ts(this.defaults);for(const a in r.renderer){if(!(a in o))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const l=a,c=r.renderer[l],x=o[l];o[l]=(...v)=>{let g=c.apply(o,v);return g===!1&&(g=x.apply(o,v)),g||""}}s.renderer=o}if(r.tokenizer){const o=this.defaults.tokenizer||new es(this.defaults);for(const a in r.tokenizer){if(!(a in o))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const l=a,c=r.tokenizer[l],x=o[l];o[l]=(...v)=>{let g=c.apply(o,v);return g===!1&&(g=x.apply(o,v)),g}}s.tokenizer=o}if(r.hooks){const o=this.defaults.hooks||new Zr;for(const a in r.hooks){if(!(a in o))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const l=a,c=r.hooks[l],x=o[l];Zr.passThroughHooks.has(a)?o[l]=v=>{if(this.defaults.async)return Promise.resolve(c.call(o,v)).then(I=>x.call(o,I));const g=c.call(o,v);return x.call(o,g)}:o[l]=(...v)=>{let g=c.apply(o,v);return g===!1&&(g=x.apply(o,v)),g}}s.hooks=o}if(r.walkTokens){const o=this.defaults.walkTokens,a=r.walkTokens;s.walkTokens=function(l){let c=[];return c.push(a.call(this,l)),o&&(c=c.concat(o.call(this,l))),c}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return Kn.lex(n,e??this.defaults)}parser(n,e){return Yn.parse(n,e??this.defaults)}parseMarkdown(n){return(r,s)=>{const o={...s},a={...this.defaults,...o},l=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&o.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=n);const c=a.hooks?a.hooks.provideLexer():n?Kn.lex:Kn.lexInline,x=a.hooks?a.hooks.provideParser():n?Yn.parse:Yn.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(r):r).then(v=>c(v,a)).then(v=>a.hooks?a.hooks.processAllTokens(v):v).then(v=>a.walkTokens?Promise.all(this.walkTokens(v,a.walkTokens)).then(()=>v):v).then(v=>x(v,a)).then(v=>a.hooks?a.hooks.postprocess(v):v).catch(l);try{a.hooks&&(r=a.hooks.preprocess(r));let v=c(r,a);a.hooks&&(v=a.hooks.processAllTokens(v)),a.walkTokens&&this.walkTokens(v,a.walkTokens);let g=x(v,a);return a.hooks&&(g=a.hooks.postprocess(g)),g}catch(v){return l(v)}}}onError(n,e){return r=>{if(r.message+=`
|
|
65
|
+
Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+On(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},pr=new ec;function it(n,e){return pr.parse(n,e)}it.options=it.setOptions=function(n){return pr.setOptions(n),it.defaults=pr.defaults,Fa(it.defaults),it};it.getDefaults=no;it.defaults=br;it.use=function(...n){return pr.use(...n),it.defaults=pr.defaults,Fa(it.defaults),it};it.walkTokens=function(n,e){return pr.walkTokens(n,e)};it.parseInline=pr.parseInline;it.Parser=Yn;it.parser=Yn.parse;it.Renderer=ts;it.TextRenderer=uo;it.Lexer=Kn;it.lexer=Kn.lex;it.Tokenizer=es;it.Hooks=Zr;it.parse=it;it.options;it.setOptions;it.use;it.walkTokens;it.parseInline;Yn.parse;Kn.lex;function Mo(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,s=Array(e);r<e;r++)s[r]=n[r];return s}function tc(n){if(Array.isArray(n))return n}function nc(n,e){var r=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var s,o,a,l,c=[],x=!0,v=!1;try{if(a=(r=r.call(n)).next,e!==0)for(;!(x=(s=a.call(r)).done)&&(c.push(s.value),c.length!==e);x=!0);}catch(g){v=!0,o=g}finally{try{if(!x&&r.return!=null&&(l=r.return(),Object(l)!==l))return}finally{if(v)throw o}}return c}}function rc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
66
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sc(n,e){return tc(n)||nc(n,e)||oc(n,e)||rc()}function oc(n,e){if(n){if(typeof n=="string")return Mo(n,e);var r={}.toString.call(n).slice(8,-1);return r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set"?Array.from(n):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mo(n,e):void 0}}const Ya=Object.entries,Do=Object.setPrototypeOf,ac=Object.isFrozen,ic=Object.getPrototypeOf,lc=Object.getOwnPropertyDescriptor;let cn=Object.freeze,dn=Object.seal,xr=Object.create,Za=typeof Reflect<"u"&&Reflect,zs=Za.apply,Bs=Za.construct;cn||(cn=function(e){return e});dn||(dn=function(e){return e});zs||(zs=function(e,r){for(var s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];return e.apply(r,o)});Bs||(Bs=function(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return new e(...s)});const Cr=Jt(Array.prototype.forEach),cc=Jt(Array.prototype.lastIndexOf),Po=Jt(Array.prototype.pop),gr=Jt(Array.prototype.push),dc=Jt(Array.prototype.splice),nr=Array.isArray,Dr=Jt(String.prototype.toLowerCase),ys=Jt(String.prototype.toString),Lo=Jt(String.prototype.match),Ir=Jt(String.prototype.replace),Oo=Jt(String.prototype.indexOf),uc=Jt(String.prototype.trim),fc=Jt(Number.prototype.toString),pc=Jt(Boolean.prototype.toString),No=typeof BigInt>"u"?null:Jt(BigInt.prototype.toString),Fo=typeof Symbol>"u"?null:Jt(Symbol.prototype.toString),on=Jt(Object.prototype.hasOwnProperty),Rr=Jt(Object.prototype.toString),ln=Jt(RegExp.prototype.test),cr=hc(TypeError);function Jt(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return zs(n,e,s)}}function hc(n){return function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return Bs(n,r)}}function Qe(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Dr;if(Do&&Do(n,null),!nr(e))return n;let s=e.length;for(;s--;){let o=e[s];if(typeof o=="string"){const a=r(o);a!==o&&(ac(e)||(e[s]=a),o=a)}n[o]=!0}return n}function bc(n){for(let e=0;e<n.length;e++)on(n,e)||(n[e]=null);return n}function bn(n){const e=xr(null);for(const s of Ya(n)){var r=sc(s,2);const o=r[0],a=r[1];on(n,o)&&(nr(a)?e[o]=bc(a):a&&typeof a=="object"&&a.constructor===Object?e[o]=bn(a):e[o]=a)}return e}function vc(n){switch(typeof n){case"string":return n;case"number":return fc(n);case"boolean":return pc(n);case"bigint":return No?No(n):"0";case"symbol":return Fo?Fo(n):"Symbol()";case"undefined":return Rr(n);case"function":case"object":{if(n===null)return Rr(n);const e=n,r=Nn(e,"toString");if(typeof r=="function"){const s=r(e);return typeof s=="string"?s:Rr(s)}return Rr(n)}default:return Rr(n)}}function Nn(n,e){for(;n!==null;){const s=lc(n,e);if(s){if(s.get)return Jt(s.get);if(typeof s.value=="function")return Jt(s.value)}n=ic(n)}function r(){return null}return r}function gc(n){try{return ln(n,""),!0}catch{return!1}}const Uo=cn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ws=cn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ss=cn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),mc=cn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ks=cn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),xc=cn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zo=cn(["#text"]),Bo=cn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ts=cn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ho=cn(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Vr=cn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),_c=dn(/{{[\w\W]*|^[\w\W]*}}/g),yc=dn(/<%[\w\W]*|^[\w\W]*%>/g),wc=dn(/\${[\w\W]*/g),Sc=dn(/^data-[\-\w.\u00B7-\uFFFF]+$/),kc=dn(/^aria-[\-\w]+$/),Wo=dn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Tc=dn(/^(?:\w+script|data):/i),Ac=dn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ec=dn(/^html$/i),Cc=dn(/^[a-z][.\w]*(-[.\w]+)+$/i),Go=dn(/<[/\w!]/g),Ic=dn(/<[/\w]/g),Rc=dn(/<\/no(script|embed|frames)/i),$c=dn(/\/>/i),Ln={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Mc=function(){return typeof window>"u"?null:window},Dc=function(e,r){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(s=r.getAttribute(o));const a="dompurify"+(s?"#"+s:"");try{return e.createPolicy(a,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},jo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},er=function(e,r,s,o){return on(e,r)&&nr(e[r])?Qe(o.base?bn(o.base):{},e[r],o.transform):s};function Xa(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Mc();const e=S=>Xa(S);if(e.version="3.4.11",e.removed=[],!n||!n.document||n.document.nodeType!==Ln.document||!n.Element)return e.isSupported=!1,e;let r=n.document;const s=r,o=s.currentScript;n.DocumentFragment;const a=n.HTMLTemplateElement,l=n.Node,c=n.Element,x=n.NodeFilter,v=n.NamedNodeMap;v===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const g=n.DOMParser,I=n.trustedTypes,L=c.prototype,O=Nn(L,"cloneNode"),T=Nn(L,"remove"),G=Nn(L,"nextSibling"),ee=Nn(L,"childNodes"),ue=Nn(L,"parentNode"),re=Nn(L,"shadowRoot"),Ve=Nn(L,"attributes"),Se=l&&l.prototype?Nn(l.prototype,"nodeType"):null,Re=l&&l.prototype?Nn(l.prototype,"nodeName"):null;if(typeof a=="function"){const S=r.createElement("template");S.content&&S.content.ownerDocument&&(r=S.content.ownerDocument)}let xe,Le="",Me,Et=!1,rt=0;const be=function(){if(rt>0)throw cr('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ye=function(i){be(),rt++;try{return xe.createHTML(i)}finally{rt--}},Gt=function(i){be(),rt++;try{return xe.createScriptURL(i)}finally{rt--}},Ge=function(){return Et||(Me=Dc(I,o),Et=!0),Me},st=r,yt=st.implementation,ot=st.createNodeIterator,et=st.createDocumentFragment,we=st.getElementsByTagName,at=s.importNode;let Ie=jo();e.isSupported=typeof Ya=="function"&&typeof ue=="function"&&yt&&yt.createHTMLDocument!==void 0;const Nt=_c,K=yc,mt=wc,an=Sc,pt=kc,xt=Tc,Oe=Ac,Z=Cc;let _e=Wo,k=null;const te=Qe({},[...Uo,...ws,...Ss,...ks,...zo]);let C=null;const oe=Qe({},[...Bo,...Ts,...Ho,...Vr]);let z=Object.seal(xr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ve=null,fe=null;const Ze=Object.seal(xr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ue=!0,vt=!0,wt=!1,je=!0,ze=!1,Ft=!0,jt=!1,Ut=!1,hn=null,St=null,_t=!1,kt=!1,gt=!1,Kt=!1,Yt=!0,wn=!1;const ke="user-content-";let ht=!0,Mt=!1,Tt={},At=null;const Zt=Qe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let en=null;const mn=Qe({},["audio","video","img","source","image","track"]);let un=null;const xn=Qe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),P="http://www.w3.org/1998/Math/MathML",j="http://www.w3.org/2000/svg",Y="http://www.w3.org/1999/xhtml";let Q=Y,Te=!1,qt=null;const Dt=Qe({},[P,j,Y],ys),zt=cn(["mi","mo","mn","ms","mtext"]);let Ct=Qe({},zt);const Pt=cn(["annotation-xml"]);let $=Qe({},Pt);const N=Qe({},["title","style","font","a","script"]);let ge=null;const Ae=["application/xhtml+xml","text/html"],Ne="text/html";let ae=null,ce=null;const De=r.createElement("form"),Ee=function(i){return i instanceof RegExp||i instanceof Function},ct=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ce&&ce===i)return;(!i||typeof i!="object")&&(i={}),i=bn(i),ge=Ae.indexOf(i.PARSER_MEDIA_TYPE)===-1?Ne:i.PARSER_MEDIA_TYPE,ae=ge==="application/xhtml+xml"?ys:Dr,k=er(i,"ALLOWED_TAGS",te,{transform:ae}),C=er(i,"ALLOWED_ATTR",oe,{transform:ae}),qt=er(i,"ALLOWED_NAMESPACES",Dt,{transform:ys}),un=er(i,"ADD_URI_SAFE_ATTR",xn,{transform:ae,base:xn}),en=er(i,"ADD_DATA_URI_TAGS",mn,{transform:ae,base:mn}),At=er(i,"FORBID_CONTENTS",Zt,{transform:ae}),ve=er(i,"FORBID_TAGS",bn({}),{transform:ae}),fe=er(i,"FORBID_ATTR",bn({}),{transform:ae}),Tt=on(i,"USE_PROFILES")?i.USE_PROFILES&&typeof i.USE_PROFILES=="object"?bn(i.USE_PROFILES):i.USE_PROFILES:!1,Ue=i.ALLOW_ARIA_ATTR!==!1,vt=i.ALLOW_DATA_ATTR!==!1,wt=i.ALLOW_UNKNOWN_PROTOCOLS||!1,je=i.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ze=i.SAFE_FOR_TEMPLATES||!1,Ft=i.SAFE_FOR_XML!==!1,jt=i.WHOLE_DOCUMENT||!1,kt=i.RETURN_DOM||!1,gt=i.RETURN_DOM_FRAGMENT||!1,Kt=i.RETURN_TRUSTED_TYPE||!1,_t=i.FORCE_BODY||!1,Yt=i.SANITIZE_DOM!==!1,wn=i.SANITIZE_NAMED_PROPS||!1,ht=i.KEEP_CONTENT!==!1,Mt=i.IN_PLACE||!1,_e=gc(i.ALLOWED_URI_REGEXP)?i.ALLOWED_URI_REGEXP:Wo,Q=typeof i.NAMESPACE=="string"?i.NAMESPACE:Y,Ct=on(i,"MATHML_TEXT_INTEGRATION_POINTS")&&i.MATHML_TEXT_INTEGRATION_POINTS&&typeof i.MATHML_TEXT_INTEGRATION_POINTS=="object"?bn(i.MATHML_TEXT_INTEGRATION_POINTS):Qe({},zt),$=on(i,"HTML_INTEGRATION_POINTS")&&i.HTML_INTEGRATION_POINTS&&typeof i.HTML_INTEGRATION_POINTS=="object"?bn(i.HTML_INTEGRATION_POINTS):Qe({},Pt);const b=on(i,"CUSTOM_ELEMENT_HANDLING")&&i.CUSTOM_ELEMENT_HANDLING&&typeof i.CUSTOM_ELEMENT_HANDLING=="object"?bn(i.CUSTOM_ELEMENT_HANDLING):xr(null);if(z=xr(null),on(b,"tagNameCheck")&&Ee(b.tagNameCheck)&&(z.tagNameCheck=b.tagNameCheck),on(b,"attributeNameCheck")&&Ee(b.attributeNameCheck)&&(z.attributeNameCheck=b.attributeNameCheck),on(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),dn(z),ze&&(vt=!1),gt&&(kt=!0),Tt&&(k=Qe({},zo),C=xr(null),Tt.html===!0&&(Qe(k,Uo),Qe(C,Bo)),Tt.svg===!0&&(Qe(k,ws),Qe(C,Ts),Qe(C,Vr)),Tt.svgFilters===!0&&(Qe(k,Ss),Qe(C,Ts),Qe(C,Vr)),Tt.mathMl===!0&&(Qe(k,ks),Qe(C,Ho),Qe(C,Vr))),Ze.tagCheck=null,Ze.attributeCheck=null,on(i,"ADD_TAGS")&&(typeof i.ADD_TAGS=="function"?Ze.tagCheck=i.ADD_TAGS:nr(i.ADD_TAGS)&&(k===te&&(k=bn(k)),Qe(k,i.ADD_TAGS,ae))),on(i,"ADD_ATTR")&&(typeof i.ADD_ATTR=="function"?Ze.attributeCheck=i.ADD_ATTR:nr(i.ADD_ATTR)&&(C===oe&&(C=bn(C)),Qe(C,i.ADD_ATTR,ae))),on(i,"ADD_URI_SAFE_ATTR")&&nr(i.ADD_URI_SAFE_ATTR)&&Qe(un,i.ADD_URI_SAFE_ATTR,ae),on(i,"FORBID_CONTENTS")&&nr(i.FORBID_CONTENTS)&&(At===Zt&&(At=bn(At)),Qe(At,i.FORBID_CONTENTS,ae)),on(i,"ADD_FORBID_CONTENTS")&&nr(i.ADD_FORBID_CONTENTS)&&(At===Zt&&(At=bn(At)),Qe(At,i.ADD_FORBID_CONTENTS,ae)),ht&&(k["#text"]=!0),jt&&Qe(k,["html","head","body"]),k.table&&(Qe(k,["tbody"]),delete ve.tbody),i.TRUSTED_TYPES_POLICY){if(typeof i.TRUSTED_TYPES_POLICY.createHTML!="function")throw cr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof i.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const R=xe;xe=i.TRUSTED_TYPES_POLICY;try{Le=Ye("")}catch(F){throw xe=R,F}}else i.TRUSTED_TYPES_POLICY===null?(xe=void 0,Le=""):(xe===void 0&&(xe=Ge()),xe&&typeof Le=="string"&&(Le=Ye("")));cn&&cn(i),ce=i},Xt=Qe({},[...ws,...Ss,...mc]),fn=Qe({},[...ks,...xc]),y=function(i,b,R){return b.namespaceURI===Y?i==="svg":b.namespaceURI===P?i==="svg"&&(R==="annotation-xml"||Ct[R]):!!Xt[i]},w=function(i,b,R){return b.namespaceURI===Y?i==="math":b.namespaceURI===j?i==="math"&&$[R]:!!fn[i]},M=function(i,b,R){return b.namespaceURI===j&&!$[R]||b.namespaceURI===P&&!Ct[R]?!1:!fn[i]&&(N[i]||!Xt[i])},A=function(i){let b=ue(i);(!b||!b.tagName)&&(b={namespaceURI:Q,tagName:"template"});const R=Dr(i.tagName),F=Dr(b.tagName);return qt[i.namespaceURI]?i.namespaceURI===j?y(R,b,F):i.namespaceURI===P?w(R,b,F):i.namespaceURI===Y?M(R,b,F):!!(ge==="application/xhtml+xml"&&qt[i.namespaceURI]):!1},D=function(i){gr(e.removed,{element:i});try{ue(i).removeChild(i)}catch{if(T(i),!ue(i))throw cr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},U=function(i){const b=ee(i);if(b){const F=[];Cr(b,le=>{gr(F,le)}),Cr(F,le=>{try{T(le)}catch{}})}const R=Ve(i);if(R)for(let F=R.length-1;F>=0;--F){const le=R[F],he=le&&le.name;if(typeof he=="string")try{i.removeAttribute(he)}catch{}}},_=function(i,b){try{gr(e.removed,{attribute:b.getAttributeNode(i),from:b})}catch{gr(e.removed,{attribute:null,from:b})}if(b.removeAttribute(i),i==="is")if(kt||gt)try{D(b)}catch{}else try{b.setAttribute(i,"")}catch{}},ie=function(i){const b=Ve(i);if(b)for(let R=b.length-1;R>=0;--R){const F=b[R],le=F&&F.name;if(!(typeof le!="string"||C[ae(le)]))try{i.removeAttribute(le)}catch{}}},de=function(i){const b=[i];for(;b.length>0;){const R=b.pop();(Se?Se(R):R.nodeType)===Ln.element&&ie(R);const le=ee(R);if(le)for(let he=le.length-1;he>=0;--he)b.push(le[he])}},X=function(i){let b=null,R=null;if(_t)i="<remove></remove>"+i;else{const he=Lo(i,/^[\r\n\t ]+/);R=he&&he[0]}ge==="application/xhtml+xml"&&Q===Y&&(i='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+i+"</body></html>");const F=xe?Ye(i):i;if(Q===Y)try{b=new g().parseFromString(F,ge)}catch{}if(!b||!b.documentElement){b=yt.createDocument(Q,"template",null);try{b.documentElement.innerHTML=Te?Le:F}catch{}}const le=b.body||b.documentElement;return i&&R&&le.insertBefore(r.createTextNode(R),le.childNodes[0]||null),Q===Y?we.call(b,jt?"html":"body")[0]:jt?b.documentElement:le},Be=function(i){return ot.call(i.ownerDocument||i,i,x.SHOW_ELEMENT|x.SHOW_COMMENT|x.SHOW_TEXT|x.SHOW_PROCESSING_INSTRUCTION|x.SHOW_CDATA_SECTION,null)},Fe=function(i){return i=Ir(i,Nt," "),i=Ir(i,K," "),i=Ir(i,mt," "),i},dt=function(i){var b;i.normalize();const R=ot.call(i.ownerDocument||i,i,x.SHOW_TEXT|x.SHOW_COMMENT|x.SHOW_CDATA_SECTION|x.SHOW_PROCESSING_INSTRUCTION,null);let F=R.nextNode();for(;F;)F.data=Fe(F.data),F=R.nextNode();const le=(b=i.querySelectorAll)===null||b===void 0?void 0:b.call(i,"template");le&&Cr(le,he=>{Vt(he.content)&&dt(he.content)})},tn=function(i){const b=Re?Re(i):null;return typeof b!="string"||ae(b)!=="form"?!1:typeof i.nodeName!="string"||typeof i.textContent!="string"||typeof i.removeChild!="function"||i.attributes!==Ve(i)||typeof i.removeAttribute!="function"||typeof i.setAttribute!="function"||typeof i.namespaceURI!="string"||typeof i.insertBefore!="function"||typeof i.hasChildNodes!="function"||i.nodeType!==Se(i)||i.childNodes!==ee(i)},Vt=function(i){if(!Se||typeof i!="object"||i===null)return!1;try{return Se(i)===Ln.documentFragment}catch{return!1}},Bt=function(i){if(!Se||typeof i!="object"||i===null)return!1;try{return typeof Se(i)=="number"}catch{return!1}};function Pe(S,i,b){S.length!==0&&Cr(S,R=>{R.call(e,i,b,ce)})}const se=function(i,b){return!!(Ft&&i.hasChildNodes()&&!Bt(i.firstElementChild)&&ln(Go,i.textContent)&&ln(Go,i.innerHTML)||Ft&&i.namespaceURI===Y&&b==="style"&&Bt(i.firstElementChild)||i.nodeType===Ln.processingInstruction||Ft&&i.nodeType===Ln.comment&&ln(Ic,i.data))},pe=function(i,b){if(!ve[b]&&Xe(b)&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,b)||z.tagNameCheck instanceof Function&&z.tagNameCheck(b)))return!1;if(ht&&!At[b]){const R=ue(i),F=ee(i);if(F&&R){const le=F.length;for(let he=le-1;he>=0;--he){const qe=Mt?F[he]:O(F[he],!0);R.insertBefore(qe,G(i))}}}return D(i),!0},Ke=function(i){if(Pe(Ie.beforeSanitizeElements,i,null),tn(i))return D(i),!0;const b=ae(Re?Re(i):i.nodeName);if(Pe(Ie.uponSanitizeElement,i,{tagName:b,allowedTags:k}),se(i,b))return D(i),!0;if(ve[b]||!(Ze.tagCheck instanceof Function&&Ze.tagCheck(b))&&!k[b])return pe(i,b);if((Se?Se(i):i.nodeType)===Ln.element&&!A(i)||(b==="noscript"||b==="noembed"||b==="noframes")&&ln(Rc,i.innerHTML))return D(i),!0;if(ze&&i.nodeType===Ln.text){const F=Fe(i.textContent);i.textContent!==F&&(gr(e.removed,{element:i.cloneNode()}),i.textContent=F)}return Pe(Ie.afterSanitizeElements,i,null),!1},Lt=function(i,b,R){if(fe[b]||Yt&&(b==="id"||b==="name")&&(R in r||R in De))return!1;const F=C[b]||Ze.attributeCheck instanceof Function&&Ze.attributeCheck(b,i);if(!(vt&&ln(an,b))){if(!(Ue&&ln(pt,b))){if(F){if(!un[b]){if(!ln(_e,Ir(R,Oe,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&i!=="script"&&Oo(R,"data:")===0&&en[i])){if(!(wt&&!ln(xt,Ir(R,Oe,"")))){if(R)return!1}}}}}else if(!(Xe(i)&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,i)||z.tagNameCheck instanceof Function&&z.tagNameCheck(i))&&(z.attributeNameCheck instanceof RegExp&&ln(z.attributeNameCheck,b)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(b,i))||b==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&ln(z.tagNameCheck,R)||z.tagNameCheck instanceof Function&&z.tagNameCheck(R))))return!1}}return!0},It=Qe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Xe=function(i){return!It[Dr(i)]&&ln(Z,i)},me=function(i,b,R,F){if(xe&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!R)switch(I.getAttributeType(i,b)){case"TrustedHTML":return Ye(F);case"TrustedScriptURL":return Gt(F)}return F},B=function(i,b,R,F){try{R?i.setAttributeNS(R,b,F):i.setAttribute(b,F),tn(i)?D(i):Po(e.removed)}catch{_(b,i)}},ne=function(i){Pe(Ie.beforeSanitizeAttributes,i,null);const b=i.attributes;if(!b||tn(i))return;const R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:C,forceKeepAttr:void 0};let F=b.length;const le=ae(i.nodeName);for(;F--;){const he=b[F],qe=he.name,bt=he.namespaceURI,Ht=he.value,nn=ae(qe),ar=Ht;let ut=qe==="value"?ar:uc(ar);if(R.attrName=nn,R.attrValue=ut,R.keepAttr=!0,R.forceKeepAttr=void 0,Pe(Ie.uponSanitizeAttribute,i,R),ut=R.attrValue,wn&&(nn==="id"||nn==="name")&&Oo(ut,ke)!==0&&(_(qe,i),ut=ke+ut),Ft&&ln(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ut)){_(qe,i);continue}if(nn==="attributename"&&Lo(ut,"href")){_(qe,i);continue}if(!R.forceKeepAttr){if(!R.keepAttr){_(qe,i);continue}if(!je&&ln($c,ut)){_(qe,i);continue}if(ze&&(ut=Fe(ut)),!Lt(le,nn,ut)){_(qe,i);continue}ut=me(le,nn,bt,ut),ut!==ar&&B(i,qe,bt,ut)}}Pe(Ie.afterSanitizeAttributes,i,null)},Ce=function(i){let b=null;const R=Be(i);for(Pe(Ie.beforeSanitizeShadowDOM,i,null);b=R.nextNode();)if(Pe(Ie.uponSanitizeShadowNode,b,null),Ke(b),ne(b),Vt(b.content)&&Ce(b.content),(Se?Se(b):b.nodeType)===Ln.element){const le=re(b);Vt(le)&&(He(le),Ce(le))}Pe(Ie.afterSanitizeShadowDOM,i,null)},He=function(i){const b=[{node:i,shadow:null}];for(;b.length>0;){const R=b.pop();if(R.shadow){Ce(R.shadow);continue}const F=R.node,he=(Se?Se(F):F.nodeType)===Ln.element,qe=ee(F);if(qe)for(let bt=qe.length-1;bt>=0;--bt)b.push({node:qe[bt],shadow:null});if(he){const bt=Re?Re(F):null;if(typeof bt=="string"&&ae(bt)==="template"){const Ht=F.content;Vt(Ht)&&b.push({node:Ht,shadow:null})}}if(he){const bt=re(F);Vt(bt)&&b.push({node:null,shadow:bt},{node:bt,shadow:null})}}};return e.sanitize=function(S){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,R=null,F=null,le=null;if(Te=!S,Te&&(S="<!-->"),typeof S!="string"&&!Bt(S)&&(S=vc(S),typeof S!="string"))throw cr("dirty is not a string, aborting");if(!e.isSupported)return S;Ut?(k=hn,C=St):ct(i),(Ie.uponSanitizeElement.length>0||Ie.uponSanitizeAttribute.length>0)&&(k=bn(k)),Ie.uponSanitizeAttribute.length>0&&(C=bn(C)),e.removed=[];const he=Mt&&typeof S!="string"&&Bt(S);if(he){const Ht=Re?Re(S):S.nodeName;if(typeof Ht=="string"){const nn=ae(Ht);if(!k[nn]||ve[nn])throw cr("root node is forbidden and cannot be sanitized in-place")}if(tn(S))throw cr("root node is clobbered and cannot be sanitized in-place");try{He(S)}catch(nn){throw U(S),nn}}else if(Bt(S))b=X("<!---->"),R=b.ownerDocument.importNode(S,!0),R.nodeType===Ln.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?b=R:b.appendChild(R),He(R);else{if(!kt&&!ze&&!jt&&S.indexOf("<")===-1)return xe&&Kt?Ye(S):S;if(b=X(S),!b)return kt?null:Kt?Le:""}b&&_t&&D(b.firstChild);const qe=Be(he?S:b);try{for(;F=qe.nextNode();)Ke(F),ne(F),Vt(F.content)&&Ce(F.content)}catch(Ht){throw he&&U(S),Ht}if(he)return Cr(e.removed,Ht=>{Ht.element&&de(Ht.element)}),ze&&dt(S),S;if(kt){if(ze&&dt(b),gt)for(le=et.call(b.ownerDocument);b.firstChild;)le.appendChild(b.firstChild);else le=b;return(C.shadowroot||C.shadowrootmode)&&(le=at.call(s,le,!0)),le}let bt=jt?b.outerHTML:b.innerHTML;return jt&&k["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&ln(Ec,b.ownerDocument.doctype.name)&&(bt="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
67
|
+
`+bt),ze&&(bt=Fe(bt)),xe&&Kt?Ye(bt):bt},e.setConfig=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ct(S),Ut=!0,hn=k,St=C},e.clearConfig=function(){ce=null,Ut=!1,hn=null,St=null,xe=Me,Le=""},e.isValidAttribute=function(S,i,b){ce||ct({});const R=ae(S),F=ae(i);return Lt(R,F,b)},e.addHook=function(S,i){typeof i=="function"&&on(Ie,S)&&gr(Ie[S],i)},e.removeHook=function(S,i){if(on(Ie,S)){if(i!==void 0){const b=cc(Ie[S],i);return b===-1?void 0:dc(Ie[S],b,1)[0]}return Po(Ie[S])}},e.removeHooks=function(S){on(Ie,S)&&(Ie[S]=[])},e.removeAllHooks=function(){Ie=jo()},e}var fo=Xa();it.setOptions({gfm:!0,breaks:!0});const qo=80;function Vn(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Pc={code(n){const{text:e,lang:r}=n,s=(r??"").trim().split(/\s+/)[0]??"",a=e.split(`
|
|
68
|
+
`).filter(I=>I.trim()!==""),l=a.length>1,c=`<pre><code>${Vn(e)}</code></pre>`;if(!l)return c;let v=a[0]??"";return v.length>qo?v=v.slice(0,qo)+"…":a.length>1&&(v+=" …"),`<details class="code-collapsible"><summary>${s?`<span class="code-lang">${Vn(s)}</span> ${Vn(v)}`:Vn(v)}</summary>${c}</details>`}};it.use({renderer:Pc});let Vo=!1;function Qa(){Vo||typeof window>"u"||(Vo=!0,fo.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))}))}function Lc(n){if(!n)return"";const e=it.parse(n,{async:!1});return typeof window>"u"?"":(Qa(),fo.sanitize(e,{ADD_ATTR:["target","rel"],ADD_TAGS:["details","summary"]}))}const Oc=/\b(https?:\/\/[^\s<]+|www\.[^\s<]+)/gi;function Nc(n){if(!n||typeof window>"u")return"";let e="",r=0;for(const s of n.matchAll(Oc)){const o=s.index??0;e+=Vn(n.slice(r,o));let a=s[0],l="";const c=a.match(/[.,;:!?)\]}'"]+$/);c&&(l=c[0],a=a.slice(0,a.length-l.length));const x=a.startsWith("www.")?`https://${a}`:a;e+=`<a href="${Vn(x)}">${Vn(a)}</a>`,e+=Vn(l),r=o+s[0].length}return e+=Vn(n.slice(r)),Qa(),fo.sanitize(e,{ADD_ATTR:["target","rel"]})}var Fc=m('<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>'),Uc=m('<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>'),zc=m(`<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
|
|
69
|
+
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>`),Bc=m('<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>'),Hc=m('<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>'),Wc=m('<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>'),Gc=m('<span class="ml-1 font-medium text-emerald-400">(Git repo detected)</span>'),jc=m('<span class="mt-1.5 block text-xs font-medium text-yellow-400">📁 Folder already exists. Joining will create a session in it. <!></span>'),qc=m('<span class="mt-1 block text-[10px] text-brand-text-muted">Relative paths are created inside your home folder.</span>'),Vc=m("<option> </option>"),Kc=m('<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>'),Yc=m('<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"/>'),Zc=m('<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>'),Xc=m('<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>'),Qc=m('<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>'),Jc=m(`<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
|
|
70
|
+
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>`),ed=m('<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>'),td=m('<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>'),nd=m('<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>'),rd=m('<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>'),sd=m('<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>'),od=m('<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>'),ad=m('<div class="flex flex-col gap-1"><!> <div class="font-mono text-sm whitespace-pre-wrap"> </div></div>'),id=m('<span class="font-mono text-xs text-brand-text-muted tabular-nums"> </span>'),ld=m('<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>'),cd=m('<div class="flex items-center gap-3 rounded-lg border border-brand-border bg-brand-surface-2 px-3 py-2.5 text-brand-text-muted"><span class="animate-pulse text-2xl leading-none">📎</span> <span class="truncate text-sm">Attaching file…</span></div>'),dd=m('<span class="text-xs break-words text-brand-text-muted"> </span>'),ud=m('<div class="flex items-start gap-3 rounded-lg border border-rose-400/40 bg-rose-400/10 px-3 py-2.5 text-brand-text"><span class="text-2xl leading-none">📎</span> <span class="flex min-w-0 flex-1 flex-col gap-0.5"><span class="text-sm font-semibold text-rose-300">Could not attach file</span> <!></span></div>'),fd=m('<a class="flex items-center gap-3 rounded-lg border border-brand-cyan/40 bg-brand-cyan/10 px-3 py-2.5 text-brand-text no-underline transition-colors hover:bg-brand-cyan/20"><span class="text-2xl leading-none">📎</span> <span class="flex min-w-0 flex-1 flex-col"><span class="truncate text-sm font-semibold"> </span> <span class="truncate text-xs text-brand-text-muted"> </span></span> <span class="flex shrink-0 items-center gap-1 rounded-md bg-brand-cyan/20 px-2.5 py-1 text-xs font-medium text-brand-cyan">⬇️ Download</span></a>'),pd=m('<div class="flex items-center gap-3 rounded-lg border border-brand-border bg-brand-surface-2 px-3 py-2.5 text-brand-text-muted"><span class="text-2xl leading-none">📎</span> <span class="flex min-w-0 flex-1 flex-col"><span class="truncate text-sm font-semibold"> </span> <span class="truncate text-xs">No active session to download from</span></span></div>'),hd=m('<div class="flex max-w-full min-w-[240px] flex-col"><!></div>'),bd=m('<span class="inline-block animate-spin font-bold text-amber-400">⚡</span>'),vd=m('<span class="font-bold text-rose-400" title="Failed">❌</span>'),gd=m('<span class="font-bold text-brand-text-muted" title="Interrupted, no result (the running tool was stopped, e.g. by a CLI takeover)">⊘</span>'),md=m('<span class="font-bold text-emerald-400" title="Succeeded">✅</span>'),xd=m('<span class="max-w-[180px] truncate font-mono text-xs text-brand-text-muted sm:max-w-[300px] md:max-w-[450px]"> </span>'),_d=m("<span> </span>"),yd=m('Collapse <span class="text-[10px]">▲</span>',1),wd=m('Expand <span class="text-[10px]">▼</span>',1),Sd=m('<a class="flex shrink-0 items-center gap-1 rounded px-1.5 py-1 text-xs text-brand-cyan transition-colors hover:bg-brand-cyan/15"><span class="text-sm">⬇️</span></a>'),kd=m('<span class="shrink-0 px-1.5 py-1 text-xs text-brand-text-muted opacity-40" title="No active session to download from">⬇️</span>'),Td=m('<a target="_blank" rel="noopener noreferrer" class="block"><img alt="Tool output" class="max-h-96 max-w-full rounded border border-brand-border/40 bg-brand-dark/60 object-contain"/></a>'),Ad=m('<div class="mt-2 flex flex-col gap-1"><div class="flex flex-wrap gap-2"></div></div>'),Ed=m('<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>'),Cd=m('<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>'),Id=m('<div class="animate-pulse p-1 text-xs text-brand-text-muted italic">Running and waiting for output...</div>'),Rd=m(`<div class="p-1 text-xs text-brand-text-muted italic">Interrupted before a result was returned (the
|
|
71
71
|
running tool was stopped, e.g. by a CLI takeover).
|
|
72
|
-
Its outcome is unknown.</div>`)
|
|
72
|
+
Its outcome is unknown.</div>`),$d=m('<div class="p-1 text-xs text-brand-text-muted italic">No output returned</div>'),Md=m('<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>'),Dd=m('<div class="flex max-w-full min-w-[280px] flex-col sm:min-w-[400px] md:min-w-[550px]"><div class="flex w-full items-center gap-1"><button class="flex min-w-0 flex-1 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> <!> <!></div>'),Pd=m('<pre class="chat-selectable font-sans text-sm leading-relaxed whitespace-pre-wrap"> <span class="ml-0.5 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan align-text-bottom"></span></pre>'),Ld=m('<div class="chat-selectable markdown-body text-sm leading-relaxed"></div>'),Od=m("<span></span>"),Nd=m('<span class="text-brand-text-muted italic"> </span>'),Fd=m('<span class="ml-1 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan"></span>'),Ud=m('<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>'),zd=m('<div class="mt-2 flex flex-col gap-1 border-t border-brand-blue/20 pt-2"></div>'),Bd=m('<div class="chat-selectable text-sm leading-relaxed whitespace-pre-wrap"><!> <!></div> <!>',1),Hd=m('<span title="Sending, awaiting confirmation">Sending...</span> <span>·</span>',1),Wd=m('<div class="mt-1.5 flex flex-wrap items-center justify-end gap-2 text-xs"><span class="font-medium text-amber-400">⚠️ Not delivered</span> <button type="button" class="rounded bg-brand-blue/80 px-2 py-0.5 font-medium text-brand-text transition-colors hover:bg-brand-blue">Retry</button> <button type="button" class="rounded bg-brand-surface-3 px-2 py-0.5 font-medium text-brand-text-muted transition-colors hover:text-brand-text">Discard</button></div>'),Gd=m("<div><!> </div> <!>",1),jd=m("<div><div><!> <!></div></div>"),qd=m('<div class="flex-1 space-y-4 overflow-y-auto overscroll-y-contain p-4"><!> <!></div>'),Vd=m('<button type="button" aria-label="Cycle waiting-for-human beep for this session"><span> </span> <span> </span></button>'),Kd=m('<div class="flex items-center gap-1 text-xs text-brand-text-muted"><span class="flex-shrink-0">🧠</span> <span class="whitespace-nowrap tabular-nums"> </span></div>'),Yd=m('<span class="ml-1 text-xs text-brand-text-muted">(already a Git repository)</span>'),Zd=m('<span class="ml-1 text-xs font-medium text-yellow-500">(folder not empty)</span>'),Xd=m('<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>'),Qd=m('<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>'),Jd=m('<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>'),eu=m('<div class="flex flex-1 flex-col overflow-hidden bg-brand-dark"><!> <div class="app-chrome flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-brand-border p-2"><div class="flex flex-wrap items-center gap-x-4 gap-y-2"><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> <!> <!></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 tu(n,e){Zn(e,!0);const r=()=>$e($t,"$piState",T),s=()=>$e(wr,"$availableModels",T),o=()=>$e(js,"$gitInitDefaultStore",T),a=()=>$e(Wr,"$activeSessionInfo",T),l=()=>$e(as,"$isLoadingSession",T),c=()=>$e(Ks,"$beepSessionOverride",T),x=()=>$e(Ys,"$beepEnabled",T),v=()=>$e(Ea,"$messages",T),g=()=>$e(Js,"$isStreaming",T),I=()=>$e(Pa,"$hasMoreHistory",T),L=()=>$e(La,"$isLoadingMoreHistory",T),O=()=>$e(os,"$isReadOnly",T),[T,G]=hr(),ee=[],ue=new Map;function re(y,w){const M=`${y}:${w.length}`;let A=ue.get(M);return A===void 0&&(A=Lc(w),ue.set(M,A)),A}const Ve=new Map;function Se(y){let w=Ve.get(y);return w===void 0&&(w=Nc(y),Ve.set(y,w)),w}function Re(y){if(y>=1e6){const w=y/1e6;return(w>=10?Math.round(w).toString():w.toFixed(1))+"M"}return y>=1e3?Math.round(y/1e3)+"K":String(y)}let xe=V(()=>{const y=r().contextUsage;if(!y||!y.contextWindow)return null;const w=Re(y.contextWindow);return y.percent==null?`– / ${w}`:`${y.percent.toFixed(1)}% / ${w}`});function Le(y){if(!y)return{cleanContent:"",attachments:[]};const w=y.split(`
|
|
73
73
|
`),M=/^\[Uploaded file: (.+)\]$/,A=[],D=[];for(const _ of w){const ie=_.match(M);ie?D.push(ie[1]):A.push(_)}let U=A.join(`
|
|
74
|
-
`).trim();return U==="I have uploaded the following file(s) for you:"&&(U=""),{cleanContent:U,attachments:D}}let Me=q(""),Et=q(Cn([])),rt=q(!1),be=q(null),Ye=q(null),Gt="",Ge=q(""),st=q(!1),yt=q(null),ot=q(!0),et=q("private"),we=q(!1),at=V(r),Ie=V(s),Nt=V(o);Rt(()=>{t(yt)===null&&p(st,t(Nt),!0)});let K=q(Cn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),mt=V(()=>t(K).exists!==!0&&t(K).matchingRule&&t(ot)),an=null;async function pt(y,w=!1){if(an&&clearTimeout(an),y===Gt&&!w)return;if(Gt=y,!y.trim()){p(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const A=async()=>{const D=await Qr("");p(Et,D||[],!0)};w?await A():an=setTimeout(A,300);return}const M=async()=>{const[A,D]=await Promise.all([
|
|
75
|
-
`),Be=X!==-1?de.slice(0,X):de;A=X!==-1?de.slice(X+1):"";let Fe=Be.trim();Fe.startsWith("$ ")&&(Fe=Fe.slice(2));const dt=Fe.indexOf(" ");w=y.toolName||(dt!==-1?Fe.slice(0,dt):Fe)||"tool",M=dt!==-1?Fe.slice(dt+1):""}const U=Ue(M),_=vt(w,U,M),ie=wt(U,M);return{toolName:w,smartTitleArgs:_,fullArgs:ie,toolOutput:A,isError:D,interrupted:!!y.interrupted,downloadPath:ze(w,U,D)}}function ze(y,w,M){if(M||!w)return null;const A=(y||"").toLowerCase();if(!["attach_file","read","write","edit"].includes(A))return null;const D=w.path||w.filepath||w.file;return!D||typeof D!="string"?null:D.trim()||null}function Ft(y){return y.scrollHeight-y.scrollTop-y.clientHeight<=20}function jt(){t(Oe)&&p(z,Ft(t(Oe)),!0)}function Ut(){t(Oe)&&(t(Oe).scrollTop=t(Oe).scrollHeight)}function hn(){(t(z)||t(ve))&&(Ut(),p(ve,!1))}zr(Ut),Rt(()=>{if(t(Oe))return t(Oe).addEventListener("scroll",jt),()=>{t(Oe)&&t(Oe).removeEventListener("scroll",jt)}});let St=q(null),_t=q(!1);function kt(){p(ve,!0),Ut(),requestAnimationFrame(()=>{Ut(),requestAnimationFrame(Ut)}),setTimeout(Ut,60),setTimeout(Ut,150)}Rt(()=>{const y=t(Z).sessionFile;y!==t(St)&&(p(St,y,!0),p(ve,!0));const w=t(_e);t(_t)&&!w&&kt(),p(_t,w,!0)});let gt=V(()=>{const y=v().filter(M=>M.role==="thinking"&&r().hideThinking?!1:M.role==="tool"&&r().hideTools&&M.toolName!=="attach_file"?Mt(M)||!!M.isStreaming:M.role!=="assistant"&&M.role!=="thinking"||M.isStreaming||M.content.trim()!==""),w=y.some(M=>M.isStreaming);if(t(Kt)&&!w){const M=v().some(A=>A.role==="thinking"&&A.isStreaming);y.push({id:"fallback-loader-message-id",role:"thinking",content:M?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return y}),Kt=V(g),Yt=q(Cn(Date.now())),wn=V(()=>t(gt).some(y=>y.role==="tool"&&y.isStreaming));Rt(()=>{if(!t(wn))return;p(Yt,Date.now(),!0);const y=setInterval(()=>p(Yt,Date.now(),!0),100);return()=>clearInterval(y)});function ke(y){if(y.startedAt===void 0)return null;const w=y.endedAt??(y.isStreaming?t(Yt):void 0);return w===void 0?null:`${(Math.max(0,w-y.startedAt)/1e3).toFixed(1)}s`}
|
|
76
|
-
${lr??""}`)},[()=>ke(t(_))]),h(We,Je)},
|
|
77
|
-
the message.</p></div> <!></div>`,1),
|
|
74
|
+
`).trim();return U==="I have uploaded the following file(s) for you:"&&(U=""),{cleanContent:U,attachments:D}}let Me=q(""),Et=q(Cn([])),rt=q(!1),be=q(null),Ye=q(null),Gt="",Ge=q(""),st=q(!1),yt=q(null),ot=q(!0),et=q("private"),we=q(!1),at=V(r),Ie=V(s),Nt=V(o);Rt(()=>{t(yt)===null&&p(st,t(Nt),!0)});let K=q(Cn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),mt=V(()=>t(K).exists!==!0&&t(K).matchingRule&&t(ot)),an=null;async function pt(y,w=!1){if(an&&clearTimeout(an),y===Gt&&!w)return;if(Gt=y,!y.trim()){p(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const A=async()=>{const D=await Qr("");p(Et,D||[],!0)};w?await A():an=setTimeout(A,300);return}const M=async()=>{const[A,D]=await Promise.all([ia(y),Qr(y)]);p(Et,D||[],!0),A?(p(K,{exists:A.exists,isGit:A.isGit,resolvedPath:A.resolvedPath,matchingRule:A.matchingRule||null},!0),A.exists||(p(st,t(yt)!==null?t(yt):t(Nt),!0),p(ot,!0),A.matchingRule&&p(et,A.matchingRule.visibility,!0))):p(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};w?await M():an=setTimeout(M,300)}Rt(()=>{const y=t(Me);pt(y,!1)}),Rt(()=>{if(t(Ie).models.length>0&&!t(Ge)){const y=t(Ie).models.find(w=>w.isDefault);y?p(Ge,`${y.provider}:${y.modelId}`):p(Ge,`${t(Ie).models[0].provider}:${t(Ie).models[0].modelId}`)}});function xt(){t(Me).trim()&&(t(K).exists===!0?(p(st,!1),p(ot,!1),t(K).matchingRule&&p(et,t(K).matchingRule.visibility,!0),p(we,!0)):zn(t(Me).trim(),t(Ge)||void 0,t(st),t(K).matchingRule?t(ot):void 0,t(K).matchingRule?t(et):void 0))}let Oe=q(void 0),Z=V(a),_e=V(l),k=V(c),te=V(x);function C(){t(k)===void 0?Yr(!0):t(k)===!0?Yr(!1):Yr(void 0)}let oe=V(()=>!!t(Z).sessionFile),z=q(!0),ve=q(!1),fe=Cn({});function Ze(y,w){fe[y]=!w}function Ue(y){if(!y)return null;const w=y.trim();if(!w)return null;if(w.startsWith("{"))try{return JSON.parse(w)}catch{}const M={},A=/([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+))/g;let D;for(;(D=A.exec(w))!==null;){const U=D[1],_=D[2]!==void 0?D[2]:D[3]!==void 0?D[3]:D[4];M[U]=_}return Object.keys(M).length>0?M:null}function vt(y,w,M){if(!w)return M?M.trim():"";const A=y.toLowerCase();if(["read","write","edit","ls"].includes(A)){const U=w.path||w.filepath||w.file;if(U)return String(U)}if(A==="bash"){const U=w.command||w.cmd;if(U){const _=String(U).replace(/\s+/g," ").trim();return _.length>50?_.slice(0,47)+"...":_}}if(A==="grep"){const U=w.pattern,_=w.path;if(U)return _?`"${U}" in ${_}`:`"${U}"`}if(A==="find"){const U=w.pattern||w.path;if(U)return String(U)}const D=w.path||w.filepath||w.file||w.name||w.query;return D?String(D):Object.entries(w).filter(([U,_])=>_!==void 0&&_!=="").map(([U,_])=>`${U}=${typeof _=="object"?JSON.stringify(_):_}`).join(" ")}function wt(y,w){return y?JSON.stringify(y,null,2):w?w.trim():""}function je(y){let w=y.toolName||"tool",M=y.toolArgs!==void 0?y.toolArgs:"",A=y.toolOutput!==void 0?y.toolOutput:"",D=!!y.isError;if(!M&&!A&&y.content){let de=y.content||"";de.startsWith("Error: ")?(D=!0,de=de.slice(7)):de.startsWith("Tool error: ")&&(D=!0,de=de.slice(12));const X=de.indexOf(`
|
|
75
|
+
`),Be=X!==-1?de.slice(0,X):de;A=X!==-1?de.slice(X+1):"";let Fe=Be.trim();Fe.startsWith("$ ")&&(Fe=Fe.slice(2));const dt=Fe.indexOf(" ");w=y.toolName||(dt!==-1?Fe.slice(0,dt):Fe)||"tool",M=dt!==-1?Fe.slice(dt+1):""}const U=Ue(M),_=vt(w,U,M),ie=wt(U,M);return{toolName:w,smartTitleArgs:_,fullArgs:ie,toolOutput:A,isError:D,interrupted:!!y.interrupted,downloadPath:ze(w,U,D)}}function ze(y,w,M){if(M||!w)return null;const A=(y||"").toLowerCase();if(!["attach_file","read","write","edit"].includes(A))return null;const D=w.path||w.filepath||w.file;return!D||typeof D!="string"?null:D.trim()||null}function Ft(y){return y.scrollHeight-y.scrollTop-y.clientHeight<=20}function jt(){t(Oe)&&p(z,Ft(t(Oe)),!0)}function Ut(){t(Oe)&&(t(Oe).scrollTop=t(Oe).scrollHeight)}function hn(){(t(z)||t(ve))&&(Ut(),p(ve,!1))}zr(Ut),Rt(()=>{if(t(Oe))return t(Oe).addEventListener("scroll",jt),()=>{t(Oe)&&t(Oe).removeEventListener("scroll",jt)}});let St=q(null),_t=q(!1);function kt(){p(ve,!0),Ut(),requestAnimationFrame(()=>{Ut(),requestAnimationFrame(Ut)}),setTimeout(Ut,60),setTimeout(Ut,150)}Rt(()=>{const y=t(Z).sessionFile;y!==t(St)&&(p(St,y,!0),p(ve,!0));const w=t(_e);t(_t)&&!w&&kt(),p(_t,w,!0)});let gt=V(()=>{const y=v().filter(M=>M.role==="thinking"&&r().hideThinking?!1:M.role==="tool"&&r().hideTools&&M.toolName!=="attach_file"?Mt(M)||!!M.isStreaming:M.role!=="assistant"&&M.role!=="thinking"||M.isStreaming||M.content.trim()!==""),w=y.some(M=>M.isStreaming);if(t(Kt)&&!w){const M=v().some(A=>A.role==="thinking"&&A.isStreaming);y.push({id:"fallback-loader-message-id",role:"thinking",content:M?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return y}),Kt=V(g),Yt=q(Cn(Date.now())),wn=V(()=>t(gt).some(y=>y.role==="tool"&&y.isStreaming));Rt(()=>{if(!t(wn))return;p(Yt,Date.now(),!0);const y=setInterval(()=>p(Yt,Date.now(),!0),100);return()=>clearInterval(y)});function ke(y){if(y.startedAt===void 0)return null;const w=y.endedAt??(y.isStreaming?t(Yt):void 0);return w===void 0?null:`${(Math.max(0,w-y.startedAt)/1e3).toFixed(1)}s`}Ci(()=>{const y=t(gt)[t(gt).length-1];y&&`${t(gt).length}${y.content.length}`,t(Oe)&&p(z,Ft(t(Oe)),!0)}),Rt(()=>{const y=t(gt)[t(gt).length-1];y&&`${t(gt).length}${y.content.length}`,hn()});function ht(y){return new Date(y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Mt(y){return y.role==="tool"&&y.forceCommand===!0}function Tt(y,w){return Mt(y)}function At(){p(ve,!0),setTimeout(Ut,0)}let Zt=V(I),en=V(L);const mn=64;let un=q(null),xn=q(null);function P(){!t(Oe)||t(en)||!t(Zt)||(p(un,t(gt)[0]?.id??null,!0),p(xn,t(Oe).scrollHeight-t(Oe).scrollTop),_a())}Rt(()=>{if(v().length,(t(un)!==null||t(xn)!==null)&&t(Oe)){const y=t(un),w=t(xn);p(un,null),p(xn,null),requestAnimationFrame(()=>{if(!t(Oe))return;const M=y?t(Oe).querySelector(`[data-msg-id="${CSS.escape(y)}"]`):null;if(M){const A=M.getBoundingClientRect().top-t(Oe).getBoundingClientRect().top;t(Oe).scrollTop=Math.max(0,t(Oe).scrollTop+A-mn)}else w!==null&&(t(Oe).scrollTop=t(Oe).scrollHeight-w)})}});var j={forceScrollToBottom:At},Y=eu(),Q=u(Y);{var Te=y=>{var w=Fc();h(y,w)},qt=y=>{var w=zc(),M=u(w),A=f(u(M),6);{var D=_=>{var ie=Uc(),de=u(ie,!0);d(ie),H(()=>J(de,t(at).error)),h(_,ie)};E(A,_=>{t(at).error&&_(D)})}var U=f(A,2);d(M),d(w),W("click",U,()=>{Mi(()=>Promise.resolve().then(()=>hl),void 0,import.meta.url).then(_=>_.connect())}),h(y,w)},Dt=y=>{var w=Bc();h(y,w)},zt=y=>{var w=Jc(),M=u(w),A=u(M),D=u(A),U=u(D);d(D),tt(6),d(A);var _=f(A,2),ie=u(_),de=f(u(ie),2),X=u(de);nt(X),Bn(X,B=>p(be,B),()=>t(be));var Be=f(X,2);{var Fe=B=>{var ne=Wc();gn(ne,21,()=>t(Et),Rn,(Ce,He)=>{var S=Hc(),i=u(S,!0);d(S),H(()=>J(i,t(He))),W("click",S,()=>{p(Me,t(He),!0),pt(t(He),!0),t(be)?.focus()}),h(Ce,S)}),d(ne),h(B,ne)};E(Be,B=>{t(rt)&&t(Et).length>0&&B(Fe)})}d(de),Bn(de,B=>p(Ye,B),()=>t(Ye));var dt=f(de,2);{var tn=B=>{var ne=jc(),Ce=f(u(ne));{var He=S=>{var i=Gc();h(S,i)};E(Ce,S=>{t(K).isGit&&S(He)})}d(ne),h(B,ne)},Vt=B=>{var ne=qc();h(B,ne)};E(dt,B=>{t(K).exists===!0?B(tn):B(Vt,-1)})}d(ie);var Bt=f(ie,2),Pe=f(u(Bt),2);{var se=B=>{var ne=Kc();gn(ne,21,()=>t(Ie).models,Rn,(Ce,He)=>{var S=Vc(),i=u(S);d(S);var b={};H(()=>{J(i,`${t(He).label??""}${t(He).isDefault?" (default)":""}`),b!==(b=`${t(He).provider}:${t(He).modelId}`)&&(S.value=S.__value=`${t(He).provider}:${t(He).modelId}`)}),h(Ce,S)}),d(ne),Fr(ne,()=>t(Ge),Ce=>p(Ge,Ce)),h(B,ne)},pe=B=>{var ne=Yc();nt(ne),$n(ne,()=>t(Ge),Ce=>p(Ge,Ce)),h(B,ne)};E(Pe,B=>{t(Ie).models.length>0?B(se):B(pe,-1)})}d(Bt);var Ke=f(Bt,2);{var Lt=B=>{var ne=Xc(),Ce=u(ne),He=u(Ce);nt(He);var S=f(He,2),i=u(S);d(S),d(Ce);var b=f(Ce,2);{var R=F=>{var le=Zc(),he=f(u(le),2),qe=u(he);nt(qe),qe.value=qe.__value="private",tt(),d(he);var bt=f(he,2),Ht=u(bt);nt(Ht),Ht.value=Ht.__value="public",tt(),d(bt),d(le),rr(ee,[],qe,()=>t(et),nn=>p(et,nn)),rr(ee,[],Ht,()=>t(et),nn=>p(et,nn)),h(F,le)};E(b,F=>{t(ot)&&F(R)})}d(ne),H(()=>J(i,`Create remote ${t(K).matchingRule.provider??""} repository`)),Mn(He,()=>t(ot),F=>p(ot,F)),h(B,ne)};E(Ke,B=>{t(K).exists!==!0&&t(K).matchingRule&&B(Lt)})}var It=f(Ke,2);{var Xe=B=>{var ne=Qc(),Ce=u(ne);nt(Ce),tt(2),d(ne),W("change",Ce,He=>{p(yt,He.currentTarget.checked,!0)}),Mn(Ce,()=>t(st),He=>p(st,He)),h(B,ne)};E(It,B=>{t(K).exists!==!0&&(!t(K).matchingRule||!t(ot))&&B(Xe)})}var me=f(It,2);d(_),d(M),d(w),H((B,ne)=>{ye(U,"src",B),rn(X,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 ${t(mt)?"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"}`),me.disabled=ne},[()=>_r("/logo.svg"),()=>!t(Me).trim()]),sr("submit",_,B=>{B.preventDefault(),xt()}),sr("focus",X,()=>{p(rt,!0),pt(t(Me),!0)}),sr("blur",X,B=>{t(Ye)&&t(Ye).contains(B.relatedTarget)||p(rt,!1)}),W("keydown",X,B=>{B.key==="Escape"&&p(rt,!1)}),$n(X,()=>t(Me),B=>p(Me,B)),h(y,w)},Ct=y=>{var w=ed();h(y,w)},Pt=y=>{var w=qd(),M=u(w);{var A=U=>{var _=td(),ie=u(_),de=u(ie);{var X=Fe=>{var dt=kn("Loading older messages...");h(Fe,dt)},Be=Fe=>{var dt=kn("Load older messages");h(Fe,dt)};E(de,Fe=>{t(en)?Fe(X):Fe(Be,-1)})}d(ie),d(_),H(()=>ie.disabled=t(en)),W("click",ie,P),h(U,_)};E(M,U=>{t(Zt)&&U(A)})}var D=f(M,2);gn(D,17,()=>t(gt),U=>U.id,(U,_)=>{var ie=jd(),de=u(ie),X=u(de);{var Be=Pe=>{var se=Un(),pe=Ot(se);{var Ke=me=>{var B=nd();h(me,B)},Lt=me=>{var B=rd();h(me,B)},It=me=>{var B=sd();h(me,B)},Xe=me=>{var B=ad(),ne=u(B);{var Ce=i=>{var b=od();h(i,b)};E(ne,i=>{t(_).isStreaming&&i(Ce)})}var He=f(ne,2),S=u(He,!0);d(He),d(B),H(()=>J(S,t(_).content)),h(me,B)};E(pe,me=>{t(_).content==="FALLBACK_THINKING_LOADER"?me(Ke):t(_).content==="FALLBACK_LOADER"?me(Lt,1):r().hideThinking?me(It,2):me(Xe,-1)})}h(Pe,se)},Fe=Pe=>{var se=Un(),pe=Ot(se);{var Ke=Xe=>{var me=ld(),B=f(u(me),2),ne=f(u(B)),Ce=u(ne,!0);d(ne),tt(),d(B);var He=f(B,2);{var S=b=>{var R=id(),F=u(R,!0);d(R),H(le=>J(F,le),[()=>ke(t(_))]),h(b,R)},i=V(()=>ke(t(_)));E(He,b=>{t(i)&&b(S)})}d(me),H(()=>J(Ce,t(_).toolName||"agent")),h(Xe,me)},Lt=V(()=>r().hideTools&&t(_).toolName!=="attach_file"&&!Mt(t(_))),It=Xe=>{const me=V(()=>je(t(_))),B=V(()=>fe[t(_).id]!==void 0?fe[t(_).id]:Tt(t(_),t(gt))),ne=V(()=>t(me).downloadPath),Ce=V(()=>t(ne)?Oa(t(ne)):null),He=V(()=>t(me).toolName==="attach_file");var S=Un(),i=Ot(S);{var b=F=>{const le=V(()=>t(ne)?t(ne).split("/").pop()||t(ne):"");var he=hd(),qe=u(he);{var bt=ut=>{var sn=cd();h(ut,sn)},Ht=ut=>{var sn=ud(),Sn=f(u(sn),2),Pn=f(u(Sn),2);{var Jn=jn=>{var ir=dd(),cs=u(ir,!0);d(ir),H(()=>J(cs,t(me).toolOutput)),h(jn,ir)};E(Pn,jn=>{t(me).toolOutput&&jn(Jn)})}d(Sn),d(sn),h(ut,sn)},nn=ut=>{var sn=fd(),Sn=f(u(sn),2),Pn=u(Sn),Jn=u(Pn,!0);d(Pn);var jn=f(Pn,2),ir=u(jn,!0);d(jn),d(Sn),tt(2),d(sn),H(()=>{ye(sn,"href",t(Ce)),ye(sn,"download",t(le)),ye(sn,"title",`Download ${t(ne)}`),J(Jn,t(le)),ye(jn,"title",t(ne)),J(ir,t(ne))}),h(ut,sn)},ar=ut=>{var sn=pd(),Sn=f(u(sn),2),Pn=u(Sn),Jn=u(Pn,!0);d(Pn),tt(2),d(Sn),d(sn),H(()=>J(Jn,t(le))),h(ut,sn)};E(qe,ut=>{t(_).isStreaming?ut(bt):t(me).isError?ut(Ht,1):t(Ce)?ut(nn,2):ut(ar,-1)})}d(he),h(F,he)},R=F=>{var le=Dd(),he=u(le),qe=u(he),bt=u(qe),Ht=u(bt);{var nn=We=>{var Je=bd();h(We,Je)},ar=We=>{var Je=vd();h(We,Je)},ut=We=>{var Je=gd();h(We,Je)},sn=We=>{var Je=md();h(We,Je)};E(Ht,We=>{t(_).isStreaming?We(nn):t(me).isError?We(ar,1):t(me).interrupted?We(ut,2):We(sn,-1)})}var Sn=f(Ht,2),Pn=u(Sn,!0);d(Sn);var Jn=f(Sn,2);{var jn=We=>{var Je=xd(),An=u(Je,!0);d(Je),H(()=>{ye(Je,"title",t(me).smartTitleArgs),J(An,t(me).smartTitleArgs)}),h(We,Je)};E(Jn,We=>{t(me).smartTitleArgs&&We(jn)})}var ir=f(Jn,2);{var cs=We=>{var Je=_d(),An=u(Je);d(Je),H(lr=>{rn(Je,1,`shrink-0 font-mono text-xs tabular-nums ${t(_).isStreaming?"text-amber-400":"text-brand-text-muted"}`),ye(Je,"title",t(_).isStreaming?"Elapsed time":"Time taken"),J(An,`${t(_).isStreaming?"Elapsed":"Took"}
|
|
76
|
+
${lr??""}`)},[()=>ke(t(_))]),h(We,Je)},Ja=V(()=>ke(t(_)));E(ir,We=>{t(Ja)&&We(cs)})}d(bt);var po=f(bt,2),ei=u(po);{var ti=We=>{var Je=yd();tt(),h(We,Je)},ni=We=>{var Je=wd();tt(),h(We,Je)};E(ei,We=>{t(B)?We(ti):We(ni,-1)})}d(po),d(qe);var ri=f(qe,2);{var si=We=>{var Je=Un(),An=Ot(Je);{var lr=_n=>{var En=Sd();H(ds=>{ye(En,"href",t(Ce)),ye(En,"download",ds),ye(En,"title",`Download ${t(ne)}`),ye(En,"aria-label",`Download ${t(ne)}`)},[()=>t(ne).split("/").pop()||""]),h(_n,En)},qn=_n=>{var En=kd();h(_n,En)};E(An,_n=>{t(Ce)?_n(lr):_n(qn,-1)})}h(We,Je)};E(ri,We=>{t(ne)&&We(si)})}d(he);var ho=f(he,2);{var oi=We=>{var Je=Ad(),An=u(Je);gn(An,21,()=>t(_).images,Rn,(lr,qn)=>{var _n=Td(),En=u(_n);d(_n),H(()=>{ye(_n,"href",`data:${t(qn).mimeType};base64,${t(qn).data}`),ye(En,"src",`data:${t(qn).mimeType};base64,${t(qn).data}`)}),h(lr,_n)}),d(An),d(Je),h(We,Je)};E(ho,We=>{t(_).images&&t(_).images.length>0&&We(oi)})}var ai=f(ho,2);{var ii=We=>{var Je=Md(),An=u(Je);{var lr=pn=>{var yn=Ed(),jr=f(u(yn),2),di=u(jr,!0);d(jr),d(yn),H(()=>J(di,t(me).fullArgs)),h(pn,yn)};E(An,pn=>{t(me).fullArgs&&t(me).fullArgs!=="{}"&&pn(lr)})}var qn=f(An,2),_n=f(u(qn),2);{var En=pn=>{var yn=Cd(),jr=u(yn,!0);d(yn),H(()=>J(jr,t(me).toolOutput)),h(pn,yn)},ds=pn=>{var yn=Id();h(pn,yn)},li=pn=>{var yn=Rd();h(pn,yn)},ci=pn=>{var yn=$d();h(pn,yn)};E(_n,pn=>{t(me).toolOutput?pn(En):t(_).isStreaming?pn(ds,1):t(me).interrupted?pn(li,2):pn(ci,-1)})}d(qn),d(Je),h(We,Je)};E(ai,We=>{t(B)&&We(ii)})}d(le),H(()=>J(Pn,t(me).toolName)),W("click",qe,()=>Ze(t(_).id,t(B))),h(F,le)};E(i,F=>{t(He)?F(b):F(R,-1)})}h(Xe,S)};E(pe,Xe=>{t(Lt)?Xe(Ke):Xe(It,-1)})}h(Pe,se)},dt=Pe=>{var se=Un(),pe=Ot(se);{var Ke=It=>{var Xe=Pd(),me=u(Xe,!0);tt(),d(Xe),H(()=>J(me,t(_).content)),h(It,Xe)},Lt=It=>{var Xe=Ld();xo(Xe,()=>re(t(_).id,t(_).content),!0),d(Xe),h(It,Xe)};E(pe,It=>{t(_).isStreaming?It(Ke):It(Lt,-1)})}h(Pe,se)},tn=Pe=>{const se=V(()=>Le(t(_).content));var pe=Bd(),Ke=Ot(pe),Lt=u(Ke);{var It=S=>{const i=V(()=>Se(t(se).cleanContent));var b=Un(),R=Ot(b);{var F=he=>{var qe=Od();xo(qe,()=>t(i),!0),d(qe),h(he,qe)},le=he=>{var qe=kn();H(()=>J(qe,t(se).cleanContent)),h(he,qe)};E(R,he=>{t(i)?he(F):he(le,-1)})}h(S,b)},Xe=S=>{var i=Nd(),b=u(i);d(i),H(()=>J(b,`Shared file${t(se).attachments.length>1?"s":""} with agent:`)),h(S,i)},me=S=>{var i=kn();H(()=>J(i,t(_).content||(t(_).isStreaming?"Thinking...":""))),h(S,i)};E(Lt,S=>{t(se).cleanContent?S(It):t(se).attachments.length>0?S(Xe,1):S(me,-1)})}var B=f(Lt,2);{var ne=S=>{var i=Fd();h(S,i)};E(B,S=>{t(_).isStreaming&&t(Kt)&&S(ne)})}d(Ke);var Ce=f(Ke,2);{var He=S=>{var i=zd();gn(i,21,()=>t(se).attachments,Rn,(b,R)=>{var F=Ud(),le=f(u(F),2),he=u(le,!0);d(le),d(F),H(()=>{ye(le,"title",t(R)),J(he,t(R))}),h(b,F)}),d(i),h(S,i)};E(Ce,S=>{t(se).attachments.length>0&&S(He)})}h(Pe,pe)};E(X,Pe=>{t(_).role==="thinking"?Pe(Be):t(_).role==="tool"?Pe(Fe,1):t(_).role==="assistant"&&t(_).content!==""?Pe(dt,2):Pe(tn,-1)})}var Vt=f(X,2);{var Bt=Pe=>{var se=Gd(),pe=Ot(se),Ke=u(pe);{var Lt=B=>{var ne=Hd();tt(2),h(B,ne)};E(Ke,B=>{t(_).role==="user"&&t(_).delivery==="sending"&&B(Lt)})}var It=f(Ke);d(pe);var Xe=f(pe,2);{var me=B=>{var ne=Wd(),Ce=f(u(ne),2),He=f(Ce,2);d(ne),W("click",Ce,()=>ba(t(_).id)),W("click",He,()=>va(t(_).id)),h(B,ne)};E(Xe,B=>{t(_).role==="user"&&t(_).delivery==="failed"&&B(me)})}H(B=>{rn(pe,1,`mt-1 flex items-center gap-1.5 text-xs opacity-50 ${t(_).role==="user"?"justify-end text-brand-text-muted":t(_).role==="assistant"?"text-brand-purple":"text-brand-text-muted"}`),J(It,` ${B??""}`)},[()=>ht(t(_).timestamp)]),h(Pe,se)};E(Vt,Pe=>{t(_).role!=="thinking"&&t(_).role!=="tool"&&Pe(Bt)})}d(de),d(ie),H(Pe=>{ye(ie,"data-msg-id",t(_).id),rn(ie,1,`flex ${t(_).role==="user"?"justify-end":"justify-start"}`),rn(de,1,`max-w-[85%] rounded-lg px-4 py-3 ${Pe??""}`)},[()=>t(_).role==="user"?"bg-brand-blue/80 text-brand-text":t(_).role==="thinking"?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":t(_).role==="tool"&&t(_).toolName==="attach_file"?"bg-transparent p-0 text-brand-text":t(_).role==="tool"?r().hideTools&&!Mt(t(_))?"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 ${t(_).isStreaming?"border-amber-400":t(_).isError?"border-rose-400":t(_).interrupted?"border-brand-border":"border-emerald-400"}`:t(_).role==="assistant"?"border-l-2 border-brand-purple bg-brand-purple/10 text-brand-text":t(_).content===""&&t(_).isStreaming?"bg-brand-surface-3 text-brand-text-muted italic":"bg-brand-surface-2 text-brand-text"]),h(U,ie)}),d(w),Bn(w,U=>p(Oe,U),()=>t(Oe)),h(y,w)};E(Q,y=>{t(at).connecting&&!t(oe)?y(Te):!t(at).connected&&!t(oe)?y(qt,1):!t(oe)&&(t(_e)||typeof window<"u"&&window.location.hash)?y(Dt,2):t(Z).sessionFile?t(gt).length===0?y(Ct,4):y(Pt,-1):y(zt,3)})}var $=f(Q,2),N=u($),ge=u(N),Ae=u(ge);nt(Ae),tt(),d(ge);var Ne=f(ge,2);{var ae=y=>{var w=Vd(),M=u(w),A=u(M,!0);d(M);var D=f(M,2),U=u(D,!0);d(D),d(w),H(()=>{rn(w,1,`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text ${t(k)===void 0?"text-brand-text-muted":"text-brand-blue"}`),ye(w,"title",t(k)===void 0?`Beep when the agent is waiting: following the default (${t(te)?"on":"off"}). Click to set On for this session.`:t(k)===!0?"Beep when the agent is waiting: ON for this session. Click to set Off.":"Beep when the agent is waiting: OFF for this session. Click to follow the default."),J(A,t(te)?"🔔":"🔕"),J(U,t(k)===void 0?`Beep: Default (${t(te)?"on":"off"})`:t(k)?"Beep: On":"Beep: Off")}),W("click",w,C),h(y,w)};E(Ne,y=>{t(Z).sessionFile&&!O()&&y(ae)})}var ce=f(Ne,2);{var De=y=>{var w=Kd(),M=f(u(w),2),A=u(M,!0);d(M),d(w),H(D=>{ye(w,"title",D),J(A,t(xe))},[()=>r().contextUsage?.tokens!=null?`${r().contextUsage.tokens.toLocaleString()} context tokens of ${r().contextUsage.contextWindow.toLocaleString()}`:"Context window size"]),h(y,w)};E(ce,y=>{t(xe)&&y(De)})}d(N);var Ee=f(N,2);d($);var ct=f($,2);{var Xt=y=>{var w=Jd(),M=u(w),A=f(u(M),2),D=f(u(A)),U=u(D,!0);d(D),tt(),d(A);var _=f(A,2),ie=u(_),de=u(ie);nt(de);var X=f(de,2),Be=f(u(X));{var Fe=pe=>{var Ke=Yd();h(pe,Ke)},dt=pe=>{var Ke=Zd();h(pe,Ke)};E(Be,pe=>{t(K).isGit?pe(Fe):pe(dt,-1)})}d(X),d(ie);var tn=f(ie,2);{var Vt=pe=>{var Ke=Qd(),Lt=u(Ke),It=u(Lt);nt(It);var Xe=f(It,2),me=u(Xe);d(Xe),d(Lt);var B=f(Lt,2);{var ne=Ce=>{var He=Xd(),S=f(u(He),2),i=u(S);nt(i),i.value=i.__value="private",tt(),d(S);var b=f(S,2),R=u(b);nt(R),R.value=R.__value="public",tt(),d(b),d(He),rr(ee,[],i,()=>t(et),F=>p(et,F)),rr(ee,[],R,()=>t(et),F=>p(et,F)),h(Ce,He)};E(B,Ce=>{t(ot)&&Ce(ne)})}d(Ke),H(()=>J(me,`Create remote ${t(K).matchingRule.provider??""} repository`)),Mn(It,()=>t(ot),Ce=>p(ot,Ce)),h(pe,Ke)};E(tn,pe=>{t(K).matchingRule&&pe(Vt)})}d(_);var Bt=f(_,2),Pe=u(Bt),se=f(Pe,2);d(Bt),d(M),d(w),H(()=>{J(U,t(Me)),de.disabled=t(K).isGit}),Mn(de,()=>t(st),pe=>p(st,pe)),W("click",Pe,()=>p(we,!1)),W("click",se,()=>{p(we,!1),zn(t(Me).trim(),t(Ge)||void 0,t(st),t(K).matchingRule?t(ot):void 0,t(K).matchingRule?t(et):void 0)}),h(y,w)};E(ct,y=>{t(we)&&y(Xt)})}d(Y),H(()=>{Qo(Ae,r().hideThinking),Ee.disabled=!t(Kt)}),W("change",Ae,y=>wa({hideThinking:y.currentTarget.checked})),W("click",Ee,function(...y){ga?.apply(this,y)}),h(n,Y);var fn=Xn(j);return G(),fn}or(["click","keydown","change"]);function nu(n,e){return n.hasSession?n.readOnly?{action:"blocked",reason:"read-only"}:n.connected?n.agentPending?{action:"blocked",reason:"agent-pending"}:{action:"send",deliverAs:"steer"}:{action:"blocked",reason:"disconnected"}:{action:"blocked",reason:"no-session"}}var ru=m("<option> </option>"),su=m('<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>'),ou=m('<div class="mt-2 rounded border border-red-900/40 bg-red-950/40 p-2 leading-normal text-red-400"> </div>'),au=m(`<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
|
|
77
|
+
the message.</p></div> <!></div>`,1),iu=m('<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 lu(n,e){Zn(e,!0);let r=dr(e,"text",15);const s=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null,o=!!s;let a=q(!1),l=q(!1),c=q(!1),x=q(!1),v=q(!1),g=q("en-US"),I=q("browser"),L=q(null),O=q(null),T=null,G=null,ee=null,ue=null,re=null,Ve=[],Se="",Re=!1;const xe=[{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)"}];zr(()=>{const k=localStorage.getItem("wherever-speech-direct-send");k!==null&&p(v,k==="true");const te=localStorage.getItem("wherever-speech-locale");te!==null&&p(g,te,!0);const C=localStorage.getItem("wherever-speech-engine");return C!==null?p(I,C,!0):o||p(I,"cloud"),()=>{if(T)try{T.abort()}catch{}if(ue)try{ue.disconnect()}catch{}if(ee)try{ee.disconnect()}catch{}if(re)try{re.getTracks().forEach(oe=>oe.stop())}catch{}if(G)try{G.close()}catch{}t(O)&&clearTimeout(t(O))}});function Le(){localStorage.setItem("wherever-speech-direct-send",String(t(v))),localStorage.setItem("wherever-speech-locale",t(g)),localStorage.setItem("wherever-speech-engine",t(I))}function Me(){const k=localStorage.getItem("wherever-config");if(k){const te=JSON.parse(k),C=window.location.protocol==="https:"?"https:":"http:",oe=te.host.startsWith("http")?te.host.replace(/^wss?:\/\//,""):te.host;return`${C}//${oe}:${te.port}`}return`${window.location.protocol}//${window.location.host}`}function Et(){try{const k=localStorage.getItem("wherever-config");if(k)return JSON.parse(k).token||""}catch{}return""}function rt(){try{const k=window.AudioContext||window.webkitAudioContext;if(!k)return;const te=new k,C=te.createOscillator(),oe=te.createGain();C.type="sine",C.frequency.setValueAtTime(400,te.currentTime),oe.gain.setValueAtTime(.08,te.currentTime),oe.gain.exponentialRampToValueAtTime(.001,te.currentTime+.12),C.connect(oe),oe.connect(te.destination),C.start(),C.stop(te.currentTime+.12)}catch(k){console.warn("Could not play audio beep feedback:",k)}}function be(k,te,C){if(te===C)return k;const oe=te/C,z=Math.round(k.length/oe),ve=new Float32Array(z);let fe=0,Ze=0;for(;fe<ve.length;){const Ue=Math.round((fe+1)*oe);let vt=0,wt=0;for(let je=Ze;je<Ue&&je<k.length;je++)vt+=k[je],wt++;ve[fe]=wt>0?vt/wt:0,fe++,Ze=Ue}return ve}function Ye(){if(o)try{T=new s,T.continuous=!0,T.interimResults=!0,T.lang=t(g),T.onstart=()=>{p(a,!0),p(l,!1),rt()},T.onresult=k=>{let te="",C="";for(let z=k.resultIndex;z<k.results.length;++z){const ve=k.results[z];ve.isFinal?te+=ve[0].transcript:C+=ve[0].transcript}const oe=(te+C).trim();oe&&(Re=!0,r(Se+(Se?" ":"")+oe))},T.onerror=k=>{console.error("Browser speech recognition error:",k.error),k.error!=="no-speech"&&p(L,`Error: ${k.error}`),Gt()},T.onend=()=>{p(a,!1),t(v)&&Re&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50)},T.start(),navigator.vibrate&&navigator.vibrate(40)}catch(k){console.error("Failed to start browser speech recognition:",k),p(L,"Failed to start browser recording"),p(a,!1)}}function Gt(){if(T)try{T.stop()}catch{}p(a,!1)}async function Ge(){try{const k=await navigator.mediaDevices.getUserMedia({audio:!0});re=k,Ve=[];const te=window.AudioContext||window.webkitAudioContext;G=new te,ee=G.createMediaStreamSource(k),ue=G.createScriptProcessor(4096,1,1),ue.onaudioprocess=C=>{const oe=C.inputBuffer.getChannelData(0);Ve.push(new Float32Array(oe))},ee.connect(ue),ue.connect(G.destination),p(a,!0),p(l,!1),rt(),navigator.vibrate&&navigator.vibrate(40)}catch(k){console.error("Failed to start cloud audio recording:",k),p(L,k.message||"Microphone access denied",!0),p(a,!1),p(l,!1)}}function st(){if(t(a)){if(p(a,!1),p(l,!0),ue){try{ue.disconnect()}catch{}ue.onaudioprocess=null}if(ee)try{ee.disconnect()}catch{}if(re)try{re.getTracks().forEach(k=>k.stop())}catch{}yt()}}async function yt(){try{if(Ve.length===0){p(l,!1);return}p(L,null);let k=0;for(const Ft of Ve)k+=Ft.length;const te=new Float32Array(k);let C=0;for(const Ft of Ve)te.set(Ft,C),C+=Ft.length;const oe=G?G.sampleRate:48e3,z=16e3,ve=be(te,oe,z),fe=Nt(ve,1,z,1,16),Ze=new Blob([fe],{type:"audio/wav"}),Ue=Me(),vt=Et(),wt=`${Ue}/session/transcribe${vt?`?token=${encodeURIComponent(vt)}`:""}`,je=await fetch(wt,{method:"POST",body:Ze,headers:{"Content-Type":"application/octet-stream"}}),ze=await je.json();if(!je.ok)throw new Error(ze.error||`HTTP ${je.status}`);ze.text&&ze.text.trim()&&(Re=!0,r(Se+(Se?" ":"")+ze.text.trim()),t(v)&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50))}catch(k){console.error("Cloud transcription request failed:",k),p(L,k.message||"Cloud API failed",!0)}finally{if(p(l,!1),G){try{G.close()}catch{}G=null}}}function ot(){e.disabled||t(a)||t(l)||(p(L,null),Re=!1,Se=r(),t(I)==="cloud"?Ge():Ye())}function et(){t(I)==="cloud"?st():Gt()}function we(k){if(k.button===0&&!e.disabled){if(k.preventDefault(),t(a)){et();return}p(c,!1),p(O,setTimeout(()=>{p(c,!0),ot()},350),!0)}}function at(k){t(O)&&(clearTimeout(t(O)),p(O,null)),t(c)?(p(c,!1),et()):t(a)||ot()}function Ie(){t(O)&&(clearTimeout(t(O)),p(O,null)),t(c)&&(p(c,!1),et())}function Nt(k,te,C,oe,z){const ve=new ArrayBuffer(44+k.length*2),fe=new DataView(ve);return mt(fe,0,"RIFF"),fe.setUint32(4,36+k.length*2,!0),mt(fe,8,"WAVE"),mt(fe,12,"fmt "),fe.setUint32(16,16,!0),fe.setUint16(20,oe,!0),fe.setUint16(22,te,!0),fe.setUint32(24,C,!0),fe.setUint32(28,C*te*(z/8),!0),fe.setUint16(32,te*(z/8),!0),fe.setUint16(34,z,!0),mt(fe,36,"data"),fe.setUint32(40,k.length*2,!0),K(fe,44,k),ve}function K(k,te,C){for(let oe=0;oe<C.length;oe++,te+=2){let z=Math.max(-1,Math.min(1,C[oe]));k.setInt16(te,z<0?z*32768:z*32767,!0)}}function mt(k,te,C){for(let oe=0;oe<C.length;oe++)k.setUint8(te+oe,C.charCodeAt(oe))}var an=iu(),pt=u(an),xt=f(pt,2),Oe=u(xt);d(xt);var Z=f(xt,2);{var _e=k=>{var te=au(),C=Ot(te),oe=f(C,2),z=f(u(oe),2),ve=f(u(z),2),fe=u(ve),Ze=f(fe,2);d(ve);var Ue=f(ve,2),vt=u(Ue,!0);d(Ue),d(z);var wt=f(z,2);{var je=St=>{var _t=su(),kt=f(u(_t),2);gn(kt,21,()=>xe,Rn,(gt,Kt)=>{var Yt=ru(),wn=u(Yt,!0);d(Yt);var ke={};H(()=>{J(wn,t(Kt).label),ke!==(ke=t(Kt).code)&&(Yt.value=(Yt.__value=t(Kt).code)??"")}),h(gt,Yt)}),d(kt),d(_t),W("change",kt,Le),Fr(kt,()=>t(g),gt=>p(g,gt)),h(St,_t)};E(wt,St=>{t(I)==="browser"&&St(je)})}var ze=f(wt,2),Ft=u(ze),jt=u(Ft);nt(jt),tt(2),d(Ft),tt(2),d(ze);var Ut=f(ze,2);{var hn=St=>{var _t=ou(),kt=u(_t,!0);d(_t),H(()=>J(kt,t(L))),h(St,_t)};E(Ut,St=>{t(L)&&St(hn)})}d(oe),H(()=>{fe.disabled=!o,rn(fe,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40
|
|
78
78
|
${t(I)==="browser"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),rn(Ze,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors
|
|
79
79
|
${t(I)==="cloud"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),J(vt,t(I)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),W("click",C,()=>p(x,!1)),W("click",fe,()=>{p(I,"browser"),Le()}),W("click",Ze,()=>{p(I,"cloud"),Le()}),W("change",jt,Le),Mn(jt,()=>t(v),St=>p(v,St)),h(k,te)};E(Z,k=>{t(x)&&k(_e)})}d(an),H(()=>{pt.disabled=e.disabled&&!t(a)&&!t(l)||t(l),rn(pt,1,`flex h-[48px] w-[48px] items-center justify-center rounded-lg border transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-40
|
|
80
|
-
${t(a)?"animate-pulse border-red-500 bg-red-600 text-white":t(l)?"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"}`),ye(pt,"title",t(a)?"Recording (release/tap to stop)...":t(l)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),xt.disabled=e.disabled&&!t(a)&&!t(l)||t(l),rn(Oe,0,`h-4 w-4 transition-transform duration-200 ${t(x)?"rotate-45 text-white":""}`)}),W("pointerdown",pt,we),W("pointerup",pt,at),sr("pointercancel",pt,Ie),W("click",xt,()=>p(x,!t(x))),h(n,an),Xn()}or(["pointerdown","pointerup","click","change"]);var
|
|
80
|
+
${t(a)?"animate-pulse border-red-500 bg-red-600 text-white":t(l)?"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"}`),ye(pt,"title",t(a)?"Recording (release/tap to stop)...":t(l)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),xt.disabled=e.disabled&&!t(a)&&!t(l)||t(l),rn(Oe,0,`h-4 w-4 transition-transform duration-200 ${t(x)?"rotate-45 text-white":""}`)}),W("pointerdown",pt,we),W("pointerup",pt,at),sr("pointercancel",pt,Ie),W("click",xt,()=>p(x,!t(x))),h(n,an),Xn()}or(["pointerdown","pointerup","click","change"]);var cu=m('<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),du=m('<span class="text-rose-400">⚠️</span> <span class="text-rose-400/80"> </span>',1),uu=m('<span class="inline-block h-1.5 w-1.5 rounded-full bg-brand-surface-3"></span> <span>Disconnected from remote server</span>',1),fu=m('<div class="mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none"><!></div>'),pu=m('<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>'),hu=m('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span>'),bu=m('<a target="_blank" class="ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80">[Test Link]</a>'),vu=m('<span class="flex items-center gap-1 text-[10px] font-medium text-rose-400"><span class="max-w-[120px] truncate"> </span> <!></span>'),gu=m('<span class="text-emerald-400">✓</span>'),mu=m('<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>'),xu=m('<div class="mb-3 flex flex-wrap gap-2"></div>'),_u=m("<option> </option>"),yu=m('<div class="mb-2 flex items-center gap-2"><label for="search-model" class="text-xs font-medium text-brand-text-muted">Model</label> <select id="search-model" class="min-w-0 flex-1 rounded-lg border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text focus:border-brand-blue focus:outline-none disabled:opacity-50"></select></div>'),wu=m('<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),Su=m('<span class="hidden font-mono opacity-60 sm:inline">Shift+Enter to send</span>'),ku=m('<!> <!> <form class="flex items-stretch gap-3"><div class="min-w-0 flex-1"><textarea class="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 text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none disabled:opacity-50"></textarea></div> <div class="flex w-[80px] shrink-0 flex-col justify-end gap-2"><!> <div class="flex w-full justify-center"><!></div> <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></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),Tu=m('<div class="border-t border-brand-border p-4"><!> <!></div>');function Au(n,e){Zn(e,!0);const r=()=>$e(Js,"$isStreaming",c),s=()=>$e(os,"$isReadOnly",c),o=()=>$e(Wr,"$activeSessionInfo",c),a=()=>$e(Hr,"$isConnected",c),l=()=>$e($t,"$piState",c),[c,x]=hr();let v=dr(e,"showAttach",3,!0),g=dr(e,"searchMode",3,!1),I=dr(e,"searchConfigured",3,!1),L=dr(e,"searchModels",19,()=>[]),O=dr(e,"searchModel",15,""),T=q(""),G=q(!0),ee=q(!1),ue=q(void 0),re=q(Cn([])),Ve=V(r),Se=V(s),Re=V(o),xe=V(a),Le=V(l),Me=V(()=>g()?e.disabled||!t(xe)||!I():e.disabled||!t(xe)||t(Se)||!t(Re).sessionId),Et=V(()=>t(re).some(Z=>Z.uploading)),rt=V(()=>!t(Me)&&!t(Et)&&(t(T).trim().length>0||t(re).length>0)),be=q(void 0);const Ye="wherever-draft:";let Gt=V(()=>Ye+(t(Re).sessionId??"search")),Ge=q(null);zr(()=>{const Z=localStorage.getItem("wherever-enter-to-send");Z!==null&&p(G,Z==="true")}),Rt(()=>{const Z=t(Gt);Z!==t(Ge)&&Hs(()=>{let _e=null;if(typeof localStorage<"u")try{_e=localStorage.getItem(Z)}catch{}p(T,_e??"",!0),p(Ge,Z,!0)})}),Rt(()=>{const Z=t(T),_e=t(Gt);if(!(_e!==t(Ge)||typeof localStorage>"u"))try{Z.trim().length>0?localStorage.setItem(_e,Z):localStorage.removeItem(_e)}catch{}});function st(){t(ee)&&p(ee,!1),t(be)?.focus()}function yt(){p(G,!t(G)),localStorage.setItem("wherever-enter-to-send",String(t(G)))}Rt(()=>{t(be)&&(t(T),t(be).style.height="auto",t(be).style.height=`${t(be).scrollHeight}px`)}),Rt(()=>{!t(Me)&&t(be)&&t(be).focus()});async function ot(Z){Xs();const _e=Z.target;if(!_e.files)return;const k=Array.from(_e.files);_e.value="";const te=t(re).length;p(re,[...t(re),...k.map(C=>({name:C.name,uploading:!0}))],!0);for(let C=0;C<k.length;C++){const oe=k[C],z=te+C;try{if(!t(Re).sessionId)throw new Error("No active session");const ve=await Na(t(Re).sessionId,oe);p(re,t(re).map((fe,Ze)=>Ze===z?{name:oe.name,path:ve.savedPath,uploading:!1}:fe),!0)}catch(ve){const fe=ve.message||"Failed to upload";console.error("File upload error details:",ve);let Ze="";try{const Ue=Wn(),vt=Gn();Ze=`${Ue}/health${vt?`?token=${encodeURIComponent(vt)}`:""}`}catch{}p(re,t(re).map((Ue,vt)=>vt===z?{name:oe.name,error:fe,url:Ze,uploading:!1}:Ue),!0)}}}function et(Z){p(re,t(re).filter((_e,k)=>k!==Z),!0)}function we(){const Z=t(T).trim();if(g()){if(!Z||t(Me))return;e.onSubmit?.(Z),p(T,""),e.onSend?.();return}if(!Z&&t(re).length===0)return;let _e=Z;if(t(re).length>0){const C=t(re).filter(oe=>oe.path);if(C.length>0){const oe=C.map(z=>`[Uploaded file: ${z.path}]`).join(`
|
|
81
81
|
`);_e?_e+=`
|
|
82
82
|
|
|
83
83
|
`+oe:_e=`I have uploaded the following file(s) for you:
|
|
84
|
-
${oe}`}}if(Z.startsWith("/")&&t(re).length===0){const C=Z.toLowerCase();if(C==="/new"||C==="/reset"){if(t(Re).cwd){zn(t(Re).cwd,t(Re).model||void 0),p(T,"");return}}else if(C==="/clear"){xa(),p(T,"");return}else if(C==="/leave"||C==="/exit"){In(),p(T,"");return}}const k=eu({streaming:t(Ve),connected:t(xe),agentPending:t(Le).agentPending,readOnly:t(Se),hasSession:!!t(Re).sessionId});if(k.action!=="send"){(k.reason==="disconnected"||k.reason==="agent-pending")&&$s(_e);return}$s(_e)&&(p(T,""),p(re,[],!0),e.onSend?.())}function at(Z){Z.key==="Enter"&&(t(G)?Z.shiftKey||(Z.preventDefault(),we()):Z.shiftKey&&(Z.preventDefault(),we()))}var Ie={focusInput:st},Nt=Su(),K=u(Nt);{var mt=Z=>{var _e=du(),k=u(_e);{var te=z=>{var ve=iu();tt(2),h(z,ve)},C=z=>{var ve=lu(),fe=f(Ot(ve),2),Ze=u(fe,!0);d(fe),H(()=>J(Ze,t(Le).error)),h(z,ve)},oe=z=>{var ve=cu();tt(2),h(z,ve)};E(k,z=>{t(Le).connecting?z(te):t(Le).error?z(C,1):t(xe)||z(oe,2)})}d(_e),h(Z,_e)};E(K,Z=>{(!t(xe)||t(Le).connecting||t(Le).error)&&Z(mt)})}var an=f(K,2);{var pt=Z=>{var _e=uu(),k=u(_e),te=u(k),C=u(te),oe=u(C,!0);d(C);var z=f(C,2),ve=u(z);{var fe=je=>{var ze=kn();H(()=>J(ze,e.placeholder??"Search the web...")),h(je,ze)},Ze=je=>{var ze=kn("Agent is working, tap to Steer...");h(je,ze)},Ue=je=>{var ze=kn("Read-only mode");h(je,ze)},vt=je=>{var ze=kn("Select a session first...");h(je,ze)},wt=je=>{var ze=kn("Tap to type a message...");h(je,ze)};E(ve,je=>{g()?je(fe):t(Ve)?je(Ze,1):t(Se)?je(Ue,2):t(Re).sessionId?je(wt,-1):je(vt,3)})}d(z),d(te),tt(2),d(k),d(_e),H(()=>J(oe,g()?"🔍":"💬")),W("click",k,()=>{p(ee,!1),setTimeout(()=>t(be)?.focus(),50)}),h(Z,_e)},xt=Z=>{var _e=wu(),k=Ot(_e);{var te=ke=>{var ht=gu();gn(ht,21,()=>t(re),Rn,(Mt,Tt,At)=>{var Zt=vu(),en=u(Zt),mn=u(en,!0);d(en);var un=f(en,2);{var xn=Q=>{var Te=fu();h(Q,Te)},P=Q=>{var Te=hu(),qt=u(Te),Dt=u(qt);d(qt);var zt=f(qt,2);{var Ct=Pt=>{var $=pu();H(()=>ye($,"href",t(Tt).url)),h(Pt,$)};E(zt,Pt=>{t(Tt).url&&Pt(Ct)})}d(Te),H(()=>{ye(Te,"title",t(Tt).error),J(Dt,`⚠️ ${t(Tt).error??""}`)}),h(Q,Te)},j=Q=>{var Te=bu();h(Q,Te)};E(un,Q=>{t(Tt).uploading?Q(xn):t(Tt).error?Q(P,1):Q(j,-1)})}var Y=f(un,2);d(Zt),H(()=>{ye(en,"title",t(Tt).name),J(mn,t(Tt).name)}),W("click",Y,()=>et(At)),h(Mt,Zt)}),d(ht),h(ke,ht)};E(k,ke=>{t(re).length>0&&ke(te)})}var C=f(k,2);{var oe=ke=>{var ht=xu(),Mt=f(u(ht),2);gn(Mt,21,L,Rn,(Tt,At)=>{var Zt=mu(),en=u(Zt,!0);d(Zt);var mn={};H(()=>{J(en,t(At).label),mn!==(mn=t(At).value)&&(Zt.value=(Zt.__value=t(At).value)??"")}),h(Tt,Zt)}),d(Mt),d(ht),H(()=>Mt.disabled=t(Me)),Fr(Mt,O),h(ke,ht)};E(C,ke=>{g()&&L().length>0&&ke(oe)})}var z=f(C,2),ve=u(z),fe=u(ve);Ei(fe),ye(fe,"rows",1),Bn(fe,ke=>p(be,ke),()=>t(be)),d(ve);var Ze=f(ve,2),Ue=u(Ze);{var vt=ke=>{var ht=_u(),Mt=Ot(ht),Tt=f(Mt,2);Bn(Tt,At=>p(ue,At),()=>t(ue)),H(()=>Mt.disabled=t(Me)),W("click",Mt,()=>{ua(),t(ue)?.click()}),W("change",Tt,ot),h(ke,ht)};E(Ue,ke=>{v()&&!g()&&ke(vt)})}var wt=f(Ue,2),je=u(wt);au(je,{get disabled(){return t(Me)},onSend:we,get text(){return t(T)},set text(ke){p(T,ke,!0)}}),d(wt);var ze=f(wt,2),Ft=u(ze);{var jt=ke=>{var ht=kn();H(()=>J(ht,e.submitLabel??"Search")),h(ke,ht)},Ut=ke=>{var ht=kn("Steer");h(ke,ht)},hn=ke=>{var ht=kn("Send");h(ke,ht)};E(Ft,ke=>{g()?ke(jt):t(Ve)?ke(Ut,1):ke(hn,-1)})}d(ze),d(Ze),d(z);var St=f(z,2),_t=u(St),kt=u(_t);nt(kt),tt(2),d(_t);var gt=f(_t,2),Kt=u(gt),Yt=f(Kt,2);{var wn=ke=>{var ht=yu();h(ke,ht)};E(Yt,ke=>{t(G)||ke(wn)})}d(gt),d(St),H(()=>{fe.disabled=t(Me),ye(fe,"placeholder",g()?e.placeholder??"Search the web...":t(xe)?t(Ve)?"Agent is working, Steer to interrupt...":t(Se)?"Read-only mode":t(Re).sessionId?"Type a message...":"Select a session first...":t(Le).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),ze.disabled=!t(rt),ye(ze,"title",!g()&&t(Ve)?"Steer the agent now (injected at the next step, before the next model call)":void 0),Zo(kt,t(G))}),sr("submit",z,ke=>{ke.preventDefault(),we()}),W("keydown",fe,at),$n(fe,()=>t(T),ke=>p(T,ke)),W("change",kt,yt),W("click",Kt,()=>p(ee,!0)),h(Z,_e)};E(an,Z=>{t(ee)?Z(pt):Z(xt,-1)})}d(Nt),h(n,Nt);var Oe=Xn(Ie);return x(),Oe}or(["click","keydown","change"]);var Tu=m('<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>'),Au=m('<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>'),Eu=m('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Cu=m('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),Iu=m("<option> </option>"),Ru=m('<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>'),$u=m('<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"/>'),Mu=m('<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>'),Du=m('<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>'),Pu=m('<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>'),Lu=m('<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>'),Ou=m('<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>'),Nu=m('<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>'),Fu=m('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Uu=m('<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>'),zu=m('<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>'),Bu=m('<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>'),Hu=m('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),Wu=m('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),Gu=m('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),ju=m('<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>'),qu=m('<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>'),Vu=m('<div class="flex-shrink-0"><!></div>'),Ku=m('<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>'),Yu=m('<div class="px-3 pb-2"><!> <!></div>'),Zu=m('<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>'),Xu=m("<option> </option>"),Qu=m('<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>'),Ju=m('<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"/>'),ef=m('<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>'),tf=m('<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>'),nf=m('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),rf=m('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),sf=m('<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>'),of=m('<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>'),af=m('<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>'),lf=m('<div class="flex h-full flex-col"><div class="border-b border-brand-border/50 p-2"><div class="flex gap-1.5"><input type="text" placeholder="Filter sessions..." class="min-w-0 flex-1 rounded border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/> <button type="button" class="flex shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-1.5 py-1.5 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Refresh session list"><span>↻</span></button></div></div> <div class="flex-1 overflow-y-auto"><!> <!></div></div> <!> <!> <!>',1);function qo(n,e){Zn(e,!0);const r=()=>$e($r,"$readOnlySessionFolders",I),s=()=>$e(yr,"$sessionFolders",I),o=()=>$e(Wr,"$activeSessionInfo",I),a=()=>$e(Hr,"$isConnected",I),l=()=>$e(as,"$isLoadingSession",I),c=()=>$e(Js,"$isResyncing",I),x=()=>$e(wr,"$availableModels",I),v=()=>$e(Ws,"$gitInitDefaultStore",I),g=()=>$e(Qs,"$sessionError",I),[I,L]=hr(),O=[];let T=dr(e,"readOnly",3,!1),G=V(()=>T()?r().folders:s().folders),ee=V(()=>T()?r().loading:s().loading);function ue(){T()?ta():Lr()}let re=V(()=>o().sessionFile),Ve=V(a),Se=V(l),Re=V(c),xe=V(()=>x().models),Le=Cn({}),Me=q(Cn({})),Et=q(null),rt=q(null),be=q(""),Ye=q(Cn([]));Rt(()=>{t(Ve)&&(ue(),T()||(Zi(),Xi()))});function Gt(P,j,Y){if(!Y)return!0;const Q=Y.toLowerCase();return(P.name||"").toLowerCase().includes(Q)||P.firstMessage.toLowerCase().includes(Q)||j.toLowerCase().includes(Q)}Rt(()=>{const P=t(be),j=t(G);P?p(Ye,j.map(Y=>({...Y,sessions:Y.sessions.filter(Q=>Gt(Q,Y.name,P))})).filter(Y=>Y.sessions.length>0),!0):(p(Ye,j,!0),p(Me,{},!0))});function Ge(P){return t(be)?t(Me)[P]!==void 0?t(Me)[P]:!0:!!Le[P]}function st(P){t(be)?t(Me)[P]=!Ge(P):Le[P]=!Ge(P)}async function yt(P){try{t(re)===P&&(typeof window<"u"&&(window.location.hash=""),In()),await Ps(P),t(Et)===P&&p(Et,null),Lr()}catch(j){console.error("Failed to delete session:",j)}}async function ot(P){try{const j=P.sessions.map(Y=>Y.path);t(re)&&j.includes(t(re))&&(typeof window<"u"&&(window.location.hash=""),In()),await Promise.all(P.sessions.map(Y=>Ps(Y.path))),t(rt)===P.path&&p(rt,null),Lr()}catch(j){console.error("Failed to delete all sessions of folder:",j)}}function et(P){t(re)===P&&!t(Se)&&!t(Re)||(fr(),Zs(P))}let we=q(!1),at=q(""),Ie=q(Cn([])),Nt=q(!1),K=q(null),mt=q(null),an="",pt=q(""),xt=q(!1),Oe=q(null),Z=q(!0),_e=q("private"),k=q(!1),te=V(v);Rt(()=>{t(Oe)===null&&p(xt,t(te),!0)});let C=q(Cn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),oe=V(()=>t(C).exists!==!0&&t(C).matchingRule&&t(Z)),z=null;async function ve(P,j=!1){if(z&&clearTimeout(z),P===an&&!j)return;if(an=P,!P.trim()){p(C,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const Q=async()=>{const Te=await Qr("");p(Ie,Te||[],!0)};j?await Q():z=setTimeout(Q,300);return}const Y=async()=>{const[Q,Te]=await Promise.all([oa(P),Qr(P)]);p(Ie,Te||[],!0),Q?(p(C,{exists:Q.exists,isGit:Q.isGit,resolvedPath:Q.resolvedPath,matchingRule:Q.matchingRule||null},!0),Q.exists||(p(xt,t(Oe)!==null?t(Oe):t(te),!0),p(Z,!0),Q.matchingRule&&p(_e,Q.matchingRule.visibility,!0))):p(C,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};j?await Y():z=setTimeout(Y,300)}Rt(()=>{const P=t(at);ve(P,!1)}),Rt(()=>{if(t(xe).length>0&&!t(pt)){const P=t(xe).find(j=>j.isDefault);P?p(pt,`${P.provider}:${P.modelId}`):p(pt,`${t(xe)[0].provider}:${t(xe)[0].modelId}`)}});function fe(){if(t(at).trim())if(t(C).exists===!0)p(xt,!1),p(Z,!1),t(C).matchingRule&&p(_e,t(C).matchingRule.visibility,!0),p(k,!0);else{fr();const P=t(at).trim(),j=t(pt)||void 0,Y=t(xt),Q=t(C).matchingRule?t(Z):void 0,Te=t(C).matchingRule?t(_e):void 0;p(at,""),p(we,!1),t(re)?(In(),setTimeout(()=>{zn(P,j,Y,Q,Te)},100)):zn(P,j,Y,Q,Te)}}function Ze(){p(k,!1),fr();const P=t(at).trim(),j=t(pt)||void 0,Y=t(xt),Q=t(C).matchingRule?t(Z):void 0,Te=t(C).matchingRule?t(_e):void 0;p(at,""),p(we,!1),t(re)?(In(),setTimeout(()=>{zn(P,j,Y,Q,Te)},100)):zn(P,j,Y,Q,Te)}let Ue=q(Cn({open:!1,folderPath:"",selected:""}));function vt(P){const j=t(xe).find(Y=>Y.isDefault);p(Ue,{open:!0,folderPath:P,selected:j?`${j.provider}:${j.modelId}`:""},!0)}function wt(){t(Ue).open=!1}function je(){if(!t(Ue).open)return;fr();const P=t(Ue).folderPath,j=t(Ue).selected||void 0;wt(),t(re)?(In(),setTimeout(()=>{zn(P,j)},100)):zn(P,j)}function ze(P){const j=Date.now()-new Date(P).getTime(),Y=Math.floor(j/6e4);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;const Q=Math.floor(Y/60);return Q<24?`${Q}h ago`:`${Math.floor(Q/24)}d ago`}function Ft(P,j=40){return P.length>j?P.slice(0,j)+"...":P}var jt=lf(),Ut=Ot(jt),hn=u(Ut),St=u(hn),_t=u(St);nt(_t);var kt=f(_t,2),gt=u(kt);d(kt),d(St),d(hn);var Kt=f(hn,2),Yt=u(Kt);{var wn=P=>{var j=Ou(),Y=u(j),Q=u(Y),Te=u(Q,!0);d(Q),d(Y);var qt=f(Y,2);{var Dt=zt=>{var Ct=Lu(),Pt=u(Ct),$=f(u(Pt),2),N=u($);nt(N),Bn(N,A=>p(K,A),()=>t(K));var ge=f(N,2);{var Ae=A=>{var D=Au();gn(D,21,()=>t(Ie),Rn,(U,_)=>{var ie=Tu(),de=u(ie,!0);d(ie),H(()=>J(de,t(_))),W("click",ie,()=>{p(at,t(_),!0),ve(t(_),!0),t(K)?.focus()}),h(U,ie)}),d(D),h(A,D)};E(ge,A=>{t(Nt)&&t(Ie).length>0&&A(Ae)})}d($),Bn($,A=>p(mt,A),()=>t(mt));var Ne=f($,2);{var ae=A=>{var D=Cu(),U=f(u(D));{var _=ie=>{var de=Eu();h(ie,de)};E(U,ie=>{t(C).isGit&&ie(_)})}d(D),h(A,D)};E(Ne,A=>{t(C).exists===!0&&A(ae)})}d(Pt);var ce=f(Pt,2),De=f(u(ce),2);{var Ee=A=>{var D=Ru();gn(D,21,()=>t(xe),Rn,(U,_)=>{var ie=Iu(),de=u(ie);d(ie);var X={};H(()=>{J(de,`${t(_).label??""}${t(_).isDefault?" (default)":""}`),X!==(X=`${t(_).provider}:${t(_).modelId}`)&&(ie.value=ie.__value=`${t(_).provider}:${t(_).modelId}`)}),h(U,ie)}),d(D),Fr(D,()=>t(pt),U=>p(pt,U)),h(A,D)},ct=A=>{var D=$u();nt(D),$n(D,()=>t(pt),U=>p(pt,U)),h(A,D)};E(De,A=>{t(xe).length>0?A(Ee):A(ct,-1)})}d(ce);var Xt=f(ce,2);{var fn=A=>{var D=Du(),U=u(D),_=u(U);nt(_);var ie=f(_,2),de=u(ie);d(ie),d(U);var X=f(U,2);{var Be=Fe=>{var dt=Mu(),tn=f(u(dt),2),Vt=u(tn);nt(Vt),Vt.value=Vt.__value="private",tt(),d(tn);var Bt=f(tn,2),Pe=u(Bt);nt(Pe),Pe.value=Pe.__value="public",tt(),d(Bt),d(dt),rr(O,[],Vt,()=>t(_e),se=>p(_e,se)),rr(O,[],Pe,()=>t(_e),se=>p(_e,se)),h(Fe,dt)};E(X,Fe=>{t(Z)&&Fe(Be)})}d(D),H(()=>J(de,`Create remote ${t(C).matchingRule.provider??""} repository`)),Mn(_,()=>t(Z),Fe=>p(Z,Fe)),h(A,D)};E(Xt,A=>{t(C).exists!==!0&&t(C).matchingRule&&A(fn)})}var y=f(Xt,2);{var w=A=>{var D=Pu(),U=u(D);nt(U),tt(2),d(D),W("change",U,_=>{p(Oe,_.currentTarget.checked,!0)}),Mn(U,()=>t(xt),_=>p(xt,_)),h(A,D)};E(y,A=>{t(C).exists!==!0&&(!t(C).matchingRule||!t(Z))&&A(w)})}var M=f(y,2);d(Ct),H(A=>{rn(N,1,`w-full rounded border px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none ${t(oe)?"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"}`),M.disabled=A},[()=>!t(at).trim()]),sr("submit",Ct,A=>{A.preventDefault(),fe()}),sr("focus",N,()=>{p(Nt,!0),ve(t(at),!0)}),sr("blur",N,A=>{t(mt)&&t(mt).contains(A.relatedTarget)||p(Nt,!1)}),W("keydown",N,A=>{A.key==="Escape"&&p(Nt,!1)}),$n(N,()=>t(at),A=>p(at,A)),h(zt,Ct)};E(qt,zt=>{t(we)&&zt(Dt)})}d(j),H(()=>J(Te,t(we)?"▼ Close Create Session":"✚ Create New Session")),W("click",Y,()=>p(we,!t(we))),h(P,j)};E(Yt,P=>{T()||P(wn)})}var ke=f(Yt,2);{var ht=P=>{var j=Nu();h(P,j)},Mt=P=>{var j=Fu(),Y=u(j,!0);d(j),H(()=>J(Y,t(be)?"No sessions match your filter":"No sessions found")),h(P,j)},Tt=P=>{var j=Un(),Y=Ot(j);gn(Y,17,()=>t(Ye),Q=>Q.path,(Q,Te)=>{var qt=Zu(),Dt=u(qt),zt=u(Dt),Ct=f(zt,2),Pt=u(Ct),$=u(Pt,!0);d(Pt);var N=f(Pt,2),ge=u(N,!0);d(N),d(Ct);var Ae=f(Ct,2),Ne=u(Ae,!0);d(Ae),d(Dt);var ae=f(Dt,2);{var ce=Ee=>{var ct=Yu(),Xt=u(ct);{var fn=w=>{var M=Bu(),A=u(M),D=f(A,2),U=u(D);{var _=de=>{var X=Uu(),Be=u(X),Fe=f(Be,2);d(X),W("click",Be,dt=>{dt.stopPropagation(),ot(t(Te))}),W("click",Fe,dt=>{dt.stopPropagation(),p(rt,null)}),h(de,X)},ie=de=>{var X=zu();W("click",X,Be=>{Be.stopPropagation(),p(rt,t(Te).path,!0)}),h(de,X)};E(U,de=>{t(rt)===t(Te).path?de(_):de(ie,-1)})}d(D),d(M),W("click",A,()=>vt(t(Te).path)),h(w,M)};E(Xt,w=>{T()||w(fn)})}var y=f(Xt,2);gn(y,17,()=>t(Te).sessions,w=>w.path,(w,M)=>{var A=Ku(),D=u(A),U=u(D);{var _=se=>{var pe=Hu();h(se,pe)},ie=se=>{var pe=Wu();h(se,pe)};E(U,se=>{t(M).isActive?se(_):se(ie,-1)})}var de=f(U,2),X=u(de),Be=u(X,!0);d(X);var Fe=f(X,2),dt=u(Fe);d(Fe),d(de);var tn=f(de,2);{var Vt=se=>{var pe=Gu(),Ke=u(pe,!0);d(pe),H(()=>J(Ke,t(M).clientCount)),h(se,pe)};E(tn,se=>{t(M).clientCount>0&&se(Vt)})}d(D);var Bt=f(D,2);{var Pe=se=>{var pe=Vu(),Ke=u(pe);{var Lt=Xe=>{var me=ju(),B=u(me),ne=f(B,2);d(me),W("click",B,Ce=>{Ce.stopPropagation(),yt(t(M).path)}),W("click",ne,Ce=>{Ce.stopPropagation(),p(Et,null)}),h(Xe,me)},It=Xe=>{var me=qu();W("click",me,B=>{B.stopPropagation(),p(Et,t(M).path,!0)}),h(Xe,me)};E(Ke,Xe=>{t(Et)===t(M).path?Xe(Lt):Xe(It,-1)})}d(pe),h(se,pe)};E(Bt,se=>{T()||se(Pe)})}d(A),H((se,pe,Ke)=>{rn(A,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 ${t(re)===t(M).path?"bg-brand-surface-3":""}`),ye(D,"href",`#${se??""}`),J(Be,pe),J(dt,`${Ke??""} · ${t(M).messageCount??""}
|
|
85
|
-
msgs`)},[()=>encodeURIComponent(t(M).id),()=>t(M).name||Ft(t(M).firstMessage)||"Empty session",()=>ze(t(M).modified)]),W("click",D,se=>{se.button===0&&!se.ctrlKey&&!se.metaKey&&!se.altKey&&!se.shiftKey&&(se.preventDefault(),et(t(M).path))}),h(w,A)}),d(ct),h(Ee,ct)},De=V(()=>Ge(t(Te).path));E(ae,Ee=>{t(De)&&Ee(ce)})}d(qt),H(Ee=>{rn(zt,1,`text-xs text-brand-text-muted transition-transform ${Ee??""}`),J($,t(Te).name),J(ge,t(Te).path),J(Ne,t(Te).sessions.length)},[()=>Ge(t(Te).path)?"rotate-90":""]),W("click",Dt,()=>st(t(Te).path)),h(Q,qt)}),h(P,j)};E(ke,P=>{t(ee)&&t(Ye).length===0?P(ht):t(Ye).length===0?P(Mt,1):P(Tt,-1)})}d(Kt),d(Ut);var At=f(Ut,2);{var Zt=P=>{var j=
|
|
84
|
+
${oe}`}}if(Z.startsWith("/")&&t(re).length===0){const C=Z.toLowerCase();if(C==="/new"||C==="/reset"){if(t(Re).cwd){zn(t(Re).cwd,t(Re).model||void 0),p(T,"");return}}else if(C==="/clear"){ya(),p(T,"");return}else if(C==="/leave"||C==="/exit"){In(),p(T,"");return}}const k=nu({streaming:t(Ve),connected:t(xe),agentPending:t(Le).agentPending,readOnly:t(Se),hasSession:!!t(Re).sessionId});if(k.action!=="send"){(k.reason==="disconnected"||k.reason==="agent-pending")&&Ds(_e);return}Ds(_e)&&(p(T,""),p(re,[],!0),e.onSend?.())}function at(Z){Z.key==="Enter"&&(t(G)?Z.shiftKey||(Z.preventDefault(),we()):Z.shiftKey&&(Z.preventDefault(),we()))}var Ie={focusInput:st},Nt=Tu(),K=u(Nt);{var mt=Z=>{var _e=fu(),k=u(_e);{var te=z=>{var ve=cu();tt(2),h(z,ve)},C=z=>{var ve=du(),fe=f(Ot(ve),2),Ze=u(fe,!0);d(fe),H(()=>J(Ze,t(Le).error)),h(z,ve)},oe=z=>{var ve=uu();tt(2),h(z,ve)};E(k,z=>{t(Le).connecting?z(te):t(Le).error?z(C,1):t(xe)||z(oe,2)})}d(_e),h(Z,_e)};E(K,Z=>{(!t(xe)||t(Le).connecting||t(Le).error)&&Z(mt)})}var an=f(K,2);{var pt=Z=>{var _e=pu(),k=u(_e),te=u(k),C=u(te),oe=u(C,!0);d(C);var z=f(C,2),ve=u(z);{var fe=je=>{var ze=kn();H(()=>J(ze,e.placeholder??"Search the web...")),h(je,ze)},Ze=je=>{var ze=kn("Agent is working, tap to Steer...");h(je,ze)},Ue=je=>{var ze=kn("Read-only mode");h(je,ze)},vt=je=>{var ze=kn("Select a session first...");h(je,ze)},wt=je=>{var ze=kn("Tap to type a message...");h(je,ze)};E(ve,je=>{g()?je(fe):t(Ve)?je(Ze,1):t(Se)?je(Ue,2):t(Re).sessionId?je(wt,-1):je(vt,3)})}d(z),d(te),tt(2),d(k),d(_e),H(()=>J(oe,g()?"🔍":"💬")),W("click",k,()=>{p(ee,!1),setTimeout(()=>t(be)?.focus(),50)}),h(Z,_e)},xt=Z=>{var _e=ku(),k=Ot(_e);{var te=ke=>{var ht=xu();gn(ht,21,()=>t(re),Rn,(Mt,Tt,At)=>{var Zt=mu(),en=u(Zt),mn=u(en,!0);d(en);var un=f(en,2);{var xn=Q=>{var Te=hu();h(Q,Te)},P=Q=>{var Te=vu(),qt=u(Te),Dt=u(qt);d(qt);var zt=f(qt,2);{var Ct=Pt=>{var $=bu();H(()=>ye($,"href",t(Tt).url)),h(Pt,$)};E(zt,Pt=>{t(Tt).url&&Pt(Ct)})}d(Te),H(()=>{ye(Te,"title",t(Tt).error),J(Dt,`⚠️ ${t(Tt).error??""}`)}),h(Q,Te)},j=Q=>{var Te=gu();h(Q,Te)};E(un,Q=>{t(Tt).uploading?Q(xn):t(Tt).error?Q(P,1):Q(j,-1)})}var Y=f(un,2);d(Zt),H(()=>{ye(en,"title",t(Tt).name),J(mn,t(Tt).name)}),W("click",Y,()=>et(At)),h(Mt,Zt)}),d(ht),h(ke,ht)};E(k,ke=>{t(re).length>0&&ke(te)})}var C=f(k,2);{var oe=ke=>{var ht=yu(),Mt=f(u(ht),2);gn(Mt,21,L,Rn,(Tt,At)=>{var Zt=_u(),en=u(Zt,!0);d(Zt);var mn={};H(()=>{J(en,t(At).label),mn!==(mn=t(At).value)&&(Zt.value=(Zt.__value=t(At).value)??"")}),h(Tt,Zt)}),d(Mt),d(ht),H(()=>Mt.disabled=t(Me)),Fr(Mt,O),h(ke,ht)};E(C,ke=>{g()&&L().length>0&&ke(oe)})}var z=f(C,2),ve=u(z),fe=u(ve);Ii(fe),ye(fe,"rows",1),Bn(fe,ke=>p(be,ke),()=>t(be)),d(ve);var Ze=f(ve,2),Ue=u(Ze);{var vt=ke=>{var ht=wu(),Mt=Ot(ht),Tt=f(Mt,2);Bn(Tt,At=>p(ue,At),()=>t(ue)),H(()=>Mt.disabled=t(Me)),W("click",Mt,()=>{pa(),t(ue)?.click()}),W("change",Tt,ot),h(ke,ht)};E(Ue,ke=>{v()&&!g()&&ke(vt)})}var wt=f(Ue,2),je=u(wt);lu(je,{get disabled(){return t(Me)},onSend:we,get text(){return t(T)},set text(ke){p(T,ke,!0)}}),d(wt);var ze=f(wt,2),Ft=u(ze);{var jt=ke=>{var ht=kn();H(()=>J(ht,e.submitLabel??"Search")),h(ke,ht)},Ut=ke=>{var ht=kn("Steer");h(ke,ht)},hn=ke=>{var ht=kn("Send");h(ke,ht)};E(Ft,ke=>{g()?ke(jt):t(Ve)?ke(Ut,1):ke(hn,-1)})}d(ze),d(Ze),d(z);var St=f(z,2),_t=u(St),kt=u(_t);nt(kt),tt(2),d(_t);var gt=f(_t,2),Kt=u(gt),Yt=f(Kt,2);{var wn=ke=>{var ht=Su();h(ke,ht)};E(Yt,ke=>{t(G)||ke(wn)})}d(gt),d(St),H(()=>{fe.disabled=t(Me),ye(fe,"placeholder",g()?e.placeholder??"Search the web...":t(xe)?t(Ve)?"Agent is working, Steer to interrupt...":t(Se)?"Read-only mode":t(Re).sessionId?"Type a message...":"Select a session first...":t(Le).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),ze.disabled=!t(rt),ye(ze,"title",!g()&&t(Ve)?"Steer the agent now (injected at the next step, before the next model call)":void 0),Qo(kt,t(G))}),sr("submit",z,ke=>{ke.preventDefault(),we()}),W("keydown",fe,at),$n(fe,()=>t(T),ke=>p(T,ke)),W("change",kt,yt),W("click",Kt,()=>p(ee,!0)),h(Z,_e)};E(an,Z=>{t(ee)?Z(pt):Z(xt,-1)})}d(Nt),h(n,Nt);var Oe=Xn(Ie);return x(),Oe}or(["click","keydown","change"]);var Eu=m('<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>'),Cu=m('<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>'),Iu=m('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Ru=m('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),$u=m("<option> </option>"),Mu=m('<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>'),Du=m('<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"/>'),Pu=m('<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>'),Lu=m('<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>'),Ou=m('<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>'),Nu=m('<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>'),Fu=m('<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>'),Uu=m('<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>'),zu=m('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Bu=m('<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>'),Hu=m('<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>'),Wu=m('<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>'),Gu=m('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),ju=m('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),qu=m('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),Vu=m('<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>'),Ku=m('<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>'),Yu=m('<div class="flex-shrink-0"><!></div>'),Zu=m('<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>'),Xu=m('<div class="px-3 pb-2"><!> <!></div>'),Qu=m('<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>'),Ju=m("<option> </option>"),ef=m('<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>'),tf=m('<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"/>'),nf=m('<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>'),rf=m('<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>'),sf=m('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),of=m('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),af=m('<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>'),lf=m('<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>'),cf=m('<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>'),df=m('<div class="flex h-full flex-col"><div class="border-b border-brand-border/50 p-2"><div class="flex gap-1.5"><input type="text" placeholder="Filter sessions..." class="min-w-0 flex-1 rounded border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/> <button type="button" class="flex shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-1.5 py-1.5 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Refresh session list"><span>↻</span></button></div></div> <div class="flex-1 overflow-y-auto"><!> <!></div></div> <!> <!> <!>',1);function Ko(n,e){Zn(e,!0);const r=()=>$e($r,"$readOnlySessionFolders",I),s=()=>$e(yr,"$sessionFolders",I),o=()=>$e(Wr,"$activeSessionInfo",I),a=()=>$e(Hr,"$isConnected",I),l=()=>$e(as,"$isLoadingSession",I),c=()=>$e(to,"$isResyncing",I),x=()=>$e(wr,"$availableModels",I),v=()=>$e(js,"$gitInitDefaultStore",I),g=()=>$e(eo,"$sessionError",I),[I,L]=hr(),O=[];let T=dr(e,"readOnly",3,!1),G=V(()=>T()?r().folders:s().folders),ee=V(()=>T()?r().loading:s().loading);function ue(){T()?ra():Lr()}let re=V(()=>o().sessionFile),Ve=V(a),Se=V(l),Re=V(c),xe=V(()=>x().models),Le=Cn({}),Me=q(Cn({})),Et=q(null),rt=q(null),be=q(""),Ye=q(Cn([]));Rt(()=>{t(Ve)&&(ue(),T()||(Qi(),Ji()))});function Gt(P,j,Y){if(!Y)return!0;const Q=Y.toLowerCase();return(P.name||"").toLowerCase().includes(Q)||P.firstMessage.toLowerCase().includes(Q)||j.toLowerCase().includes(Q)}Rt(()=>{const P=t(be),j=t(G);P?p(Ye,j.map(Y=>({...Y,sessions:Y.sessions.filter(Q=>Gt(Q,Y.name,P))})).filter(Y=>Y.sessions.length>0),!0):(p(Ye,j,!0),p(Me,{},!0))});function Ge(P){return t(be)?t(Me)[P]!==void 0?t(Me)[P]:!0:!!Le[P]}function st(P){t(be)?t(Me)[P]=!Ge(P):Le[P]=!Ge(P)}async function yt(P){try{t(re)===P&&(typeof window<"u"&&(window.location.hash=""),In()),await Os(P),t(Et)===P&&p(Et,null),Lr()}catch(j){console.error("Failed to delete session:",j)}}async function ot(P){try{const j=P.sessions.map(Y=>Y.path);t(re)&&j.includes(t(re))&&(typeof window<"u"&&(window.location.hash=""),In()),await Promise.all(P.sessions.map(Y=>Os(Y.path))),t(rt)===P.path&&p(rt,null),Lr()}catch(j){console.error("Failed to delete all sessions of folder:",j)}}function et(P){t(re)===P&&!t(Se)&&!t(Re)||(fr(),Qs(P))}let we=q(!1),at=q(""),Ie=q(Cn([])),Nt=q(!1),K=q(null),mt=q(null),an="",pt=q(""),xt=q(!1),Oe=q(null),Z=q(!0),_e=q("private"),k=q(!1),te=V(v);Rt(()=>{t(Oe)===null&&p(xt,t(te),!0)});let C=q(Cn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),oe=V(()=>t(C).exists!==!0&&t(C).matchingRule&&t(Z)),z=null;async function ve(P,j=!1){if(z&&clearTimeout(z),P===an&&!j)return;if(an=P,!P.trim()){p(C,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const Q=async()=>{const Te=await Qr("");p(Ie,Te||[],!0)};j?await Q():z=setTimeout(Q,300);return}const Y=async()=>{const[Q,Te]=await Promise.all([ia(P),Qr(P)]);p(Ie,Te||[],!0),Q?(p(C,{exists:Q.exists,isGit:Q.isGit,resolvedPath:Q.resolvedPath,matchingRule:Q.matchingRule||null},!0),Q.exists||(p(xt,t(Oe)!==null?t(Oe):t(te),!0),p(Z,!0),Q.matchingRule&&p(_e,Q.matchingRule.visibility,!0))):p(C,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};j?await Y():z=setTimeout(Y,300)}Rt(()=>{const P=t(at);ve(P,!1)}),Rt(()=>{if(t(xe).length>0&&!t(pt)){const P=t(xe).find(j=>j.isDefault);P?p(pt,`${P.provider}:${P.modelId}`):p(pt,`${t(xe)[0].provider}:${t(xe)[0].modelId}`)}});function fe(){if(t(at).trim())if(t(C).exists===!0)p(xt,!1),p(Z,!1),t(C).matchingRule&&p(_e,t(C).matchingRule.visibility,!0),p(k,!0);else{fr();const P=t(at).trim(),j=t(pt)||void 0,Y=t(xt),Q=t(C).matchingRule?t(Z):void 0,Te=t(C).matchingRule?t(_e):void 0;p(at,""),p(we,!1),t(re)?(In(),setTimeout(()=>{zn(P,j,Y,Q,Te)},100)):zn(P,j,Y,Q,Te)}}function Ze(){p(k,!1),fr();const P=t(at).trim(),j=t(pt)||void 0,Y=t(xt),Q=t(C).matchingRule?t(Z):void 0,Te=t(C).matchingRule?t(_e):void 0;p(at,""),p(we,!1),t(re)?(In(),setTimeout(()=>{zn(P,j,Y,Q,Te)},100)):zn(P,j,Y,Q,Te)}let Ue=q(Cn({open:!1,folderPath:"",selected:""}));function vt(P){const j=t(xe).find(Y=>Y.isDefault);p(Ue,{open:!0,folderPath:P,selected:j?`${j.provider}:${j.modelId}`:""},!0)}function wt(){t(Ue).open=!1}function je(){if(!t(Ue).open)return;fr();const P=t(Ue).folderPath,j=t(Ue).selected||void 0;wt(),t(re)?(In(),setTimeout(()=>{zn(P,j)},100)):zn(P,j)}function ze(P){const j=Date.now()-new Date(P).getTime(),Y=Math.floor(j/6e4);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;const Q=Math.floor(Y/60);return Q<24?`${Q}h ago`:`${Math.floor(Q/24)}d ago`}function Ft(P,j=40){return P.length>j?P.slice(0,j)+"...":P}var jt=df(),Ut=Ot(jt),hn=u(Ut),St=u(hn),_t=u(St);nt(_t);var kt=f(_t,2),gt=u(kt);d(kt),d(St),d(hn);var Kt=f(hn,2),Yt=u(Kt);{var wn=P=>{var j=Fu(),Y=u(j),Q=u(Y),Te=u(Q,!0);d(Q),d(Y);var qt=f(Y,2);{var Dt=zt=>{var Ct=Nu(),Pt=u(Ct),$=f(u(Pt),2),N=u($);nt(N),Bn(N,A=>p(K,A),()=>t(K));var ge=f(N,2);{var Ae=A=>{var D=Cu();gn(D,21,()=>t(Ie),Rn,(U,_)=>{var ie=Eu(),de=u(ie,!0);d(ie),H(()=>J(de,t(_))),W("click",ie,()=>{p(at,t(_),!0),ve(t(_),!0),t(K)?.focus()}),h(U,ie)}),d(D),h(A,D)};E(ge,A=>{t(Nt)&&t(Ie).length>0&&A(Ae)})}d($),Bn($,A=>p(mt,A),()=>t(mt));var Ne=f($,2);{var ae=A=>{var D=Ru(),U=f(u(D));{var _=ie=>{var de=Iu();h(ie,de)};E(U,ie=>{t(C).isGit&&ie(_)})}d(D),h(A,D)};E(Ne,A=>{t(C).exists===!0&&A(ae)})}d(Pt);var ce=f(Pt,2),De=f(u(ce),2);{var Ee=A=>{var D=Mu();gn(D,21,()=>t(xe),Rn,(U,_)=>{var ie=$u(),de=u(ie);d(ie);var X={};H(()=>{J(de,`${t(_).label??""}${t(_).isDefault?" (default)":""}`),X!==(X=`${t(_).provider}:${t(_).modelId}`)&&(ie.value=ie.__value=`${t(_).provider}:${t(_).modelId}`)}),h(U,ie)}),d(D),Fr(D,()=>t(pt),U=>p(pt,U)),h(A,D)},ct=A=>{var D=Du();nt(D),$n(D,()=>t(pt),U=>p(pt,U)),h(A,D)};E(De,A=>{t(xe).length>0?A(Ee):A(ct,-1)})}d(ce);var Xt=f(ce,2);{var fn=A=>{var D=Lu(),U=u(D),_=u(U);nt(_);var ie=f(_,2),de=u(ie);d(ie),d(U);var X=f(U,2);{var Be=Fe=>{var dt=Pu(),tn=f(u(dt),2),Vt=u(tn);nt(Vt),Vt.value=Vt.__value="private",tt(),d(tn);var Bt=f(tn,2),Pe=u(Bt);nt(Pe),Pe.value=Pe.__value="public",tt(),d(Bt),d(dt),rr(O,[],Vt,()=>t(_e),se=>p(_e,se)),rr(O,[],Pe,()=>t(_e),se=>p(_e,se)),h(Fe,dt)};E(X,Fe=>{t(Z)&&Fe(Be)})}d(D),H(()=>J(de,`Create remote ${t(C).matchingRule.provider??""} repository`)),Mn(_,()=>t(Z),Fe=>p(Z,Fe)),h(A,D)};E(Xt,A=>{t(C).exists!==!0&&t(C).matchingRule&&A(fn)})}var y=f(Xt,2);{var w=A=>{var D=Ou(),U=u(D);nt(U),tt(2),d(D),W("change",U,_=>{p(Oe,_.currentTarget.checked,!0)}),Mn(U,()=>t(xt),_=>p(xt,_)),h(A,D)};E(y,A=>{t(C).exists!==!0&&(!t(C).matchingRule||!t(Z))&&A(w)})}var M=f(y,2);d(Ct),H(A=>{rn(N,1,`w-full rounded border px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none ${t(oe)?"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"}`),M.disabled=A},[()=>!t(at).trim()]),sr("submit",Ct,A=>{A.preventDefault(),fe()}),sr("focus",N,()=>{p(Nt,!0),ve(t(at),!0)}),sr("blur",N,A=>{t(mt)&&t(mt).contains(A.relatedTarget)||p(Nt,!1)}),W("keydown",N,A=>{A.key==="Escape"&&p(Nt,!1)}),$n(N,()=>t(at),A=>p(at,A)),h(zt,Ct)};E(qt,zt=>{t(we)&&zt(Dt)})}d(j),H(()=>J(Te,t(we)?"▼ Close Create Session":"✚ Create New Session")),W("click",Y,()=>p(we,!t(we))),h(P,j)};E(Yt,P=>{T()||P(wn)})}var ke=f(Yt,2);{var ht=P=>{var j=Uu();h(P,j)},Mt=P=>{var j=zu(),Y=u(j,!0);d(j),H(()=>J(Y,t(be)?"No sessions match your filter":"No sessions found")),h(P,j)},Tt=P=>{var j=Un(),Y=Ot(j);gn(Y,17,()=>t(Ye),Q=>Q.path,(Q,Te)=>{var qt=Qu(),Dt=u(qt),zt=u(Dt),Ct=f(zt,2),Pt=u(Ct),$=u(Pt,!0);d(Pt);var N=f(Pt,2),ge=u(N,!0);d(N),d(Ct);var Ae=f(Ct,2),Ne=u(Ae,!0);d(Ae),d(Dt);var ae=f(Dt,2);{var ce=Ee=>{var ct=Xu(),Xt=u(ct);{var fn=w=>{var M=Wu(),A=u(M),D=f(A,2),U=u(D);{var _=de=>{var X=Bu(),Be=u(X),Fe=f(Be,2);d(X),W("click",Be,dt=>{dt.stopPropagation(),ot(t(Te))}),W("click",Fe,dt=>{dt.stopPropagation(),p(rt,null)}),h(de,X)},ie=de=>{var X=Hu();W("click",X,Be=>{Be.stopPropagation(),p(rt,t(Te).path,!0)}),h(de,X)};E(U,de=>{t(rt)===t(Te).path?de(_):de(ie,-1)})}d(D),d(M),W("click",A,()=>vt(t(Te).path)),h(w,M)};E(Xt,w=>{T()||w(fn)})}var y=f(Xt,2);gn(y,17,()=>t(Te).sessions,w=>w.path,(w,M)=>{var A=Zu(),D=u(A),U=u(D);{var _=se=>{var pe=Gu();h(se,pe)},ie=se=>{var pe=ju();h(se,pe)};E(U,se=>{t(M).isActive?se(_):se(ie,-1)})}var de=f(U,2),X=u(de),Be=u(X,!0);d(X);var Fe=f(X,2),dt=u(Fe);d(Fe),d(de);var tn=f(de,2);{var Vt=se=>{var pe=qu(),Ke=u(pe,!0);d(pe),H(()=>J(Ke,t(M).clientCount)),h(se,pe)};E(tn,se=>{t(M).clientCount>0&&se(Vt)})}d(D);var Bt=f(D,2);{var Pe=se=>{var pe=Yu(),Ke=u(pe);{var Lt=Xe=>{var me=Vu(),B=u(me),ne=f(B,2);d(me),W("click",B,Ce=>{Ce.stopPropagation(),yt(t(M).path)}),W("click",ne,Ce=>{Ce.stopPropagation(),p(Et,null)}),h(Xe,me)},It=Xe=>{var me=Ku();W("click",me,B=>{B.stopPropagation(),p(Et,t(M).path,!0)}),h(Xe,me)};E(Ke,Xe=>{t(Et)===t(M).path?Xe(Lt):Xe(It,-1)})}d(pe),h(se,pe)};E(Bt,se=>{T()||se(Pe)})}d(A),H((se,pe,Ke)=>{rn(A,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 ${t(re)===t(M).path?"bg-brand-surface-3":""}`),ye(D,"href",`#${se??""}`),J(Be,pe),J(dt,`${Ke??""} · ${t(M).messageCount??""}
|
|
85
|
+
msgs`)},[()=>encodeURIComponent(t(M).id),()=>t(M).name||Ft(t(M).firstMessage)||"Empty session",()=>ze(t(M).modified)]),W("click",D,se=>{se.button===0&&!se.ctrlKey&&!se.metaKey&&!se.altKey&&!se.shiftKey&&(se.preventDefault(),et(t(M).path))}),h(w,A)}),d(ct),h(Ee,ct)},De=V(()=>Ge(t(Te).path));E(ae,Ee=>{t(De)&&Ee(ce)})}d(qt),H(Ee=>{rn(zt,1,`text-xs text-brand-text-muted transition-transform ${Ee??""}`),J($,t(Te).name),J(ge,t(Te).path),J(Ne,t(Te).sessions.length)},[()=>Ge(t(Te).path)?"rotate-90":""]),W("click",Dt,()=>st(t(Te).path)),h(Q,qt)}),h(P,j)};E(ke,P=>{t(ee)&&t(Ye).length===0?P(ht):t(Ye).length===0?P(Mt,1):P(Tt,-1)})}d(Kt),d(Ut);var At=f(Ut,2);{var Zt=P=>{var j=nf(),Y=u(j),Q=f(u(Y),2),Te=f(u(Q),2),qt=u(Te,!0);d(Te),d(Q);var Dt=f(Q,2),zt=f(u(Dt),2);{var Ct=Ae=>{var Ne=ef();gn(Ne,21,()=>t(xe),Rn,(ae,ce)=>{var De=Ju(),Ee=u(De);d(De);var ct={};H(()=>{J(Ee,`${t(ce).label??""}${t(ce).isDefault?" (default)":""}`),ct!==(ct=`${t(ce).provider}:${t(ce).modelId}`)&&(De.value=De.__value=`${t(ce).provider}:${t(ce).modelId}`)}),h(ae,De)}),d(Ne),Fr(Ne,()=>t(Ue).selected,ae=>t(Ue).selected=ae),h(Ae,Ne)},Pt=Ae=>{var Ne=tf();nt(Ne),$n(Ne,()=>t(Ue).selected,ae=>t(Ue).selected=ae),h(Ae,Ne)};E(zt,Ae=>{t(xe).length>0?Ae(Ct):Ae(Pt,-1)})}d(Dt);var $=f(Dt,2),N=u($),ge=f(N,2);d($),d(Y),d(j),H(()=>J(qt,t(Ue).folderPath)),W("click",j,wt),W("click",Y,Ae=>Ae.stopPropagation()),W("click",N,wt),W("click",ge,je),h(P,j)};E(At,P=>{t(Ue).open&&P(Zt)})}var en=f(At,2);{var mn=P=>{var j=rf(),Y=u(j),Q=u(Y,!0);d(Y);var Te=f(Y,2);d(j),H(()=>J(Q,g())),W("click",Te,()=>fr()),h(P,j)};E(en,P=>{g()&&P(mn)})}var un=f(en,2);{var xn=P=>{var j=cf(),Y=u(j),Q=f(u(Y),2),Te=f(u(Q)),qt=u(Te,!0);d(Te),tt(),d(Q);var Dt=f(Q,2),zt=u(Dt),Ct=u(zt);nt(Ct);var Pt=f(Ct,2),$=f(u(Pt));{var N=Ee=>{var ct=sf();h(Ee,ct)},ge=Ee=>{var ct=of();h(Ee,ct)};E($,Ee=>{t(C).isGit?Ee(N):Ee(ge,-1)})}d(Pt),d(zt);var Ae=f(zt,2);{var Ne=Ee=>{var ct=lf(),Xt=u(ct),fn=u(Xt);nt(fn);var y=f(fn,2),w=u(y);d(y),d(Xt);var M=f(Xt,2);{var A=D=>{var U=af(),_=f(u(U),2),ie=u(_);nt(ie),ie.value=ie.__value="private",tt(),d(_);var de=f(_,2),X=u(de);nt(X),X.value=X.__value="public",tt(),d(de),d(U),rr(O,[],ie,()=>t(_e),Be=>p(_e,Be)),rr(O,[],X,()=>t(_e),Be=>p(_e,Be)),h(D,U)};E(M,D=>{t(Z)&&D(A)})}d(ct),H(()=>J(w,`Create remote ${t(C).matchingRule.provider??""} repository`)),Mn(fn,()=>t(Z),D=>p(Z,D)),h(Ee,ct)};E(Ae,Ee=>{t(C).matchingRule&&Ee(Ne)})}d(Dt);var ae=f(Dt,2),ce=u(ae),De=f(ce,2);d(ae),d(Y),d(j),H(()=>{J(qt,t(at)),Ct.disabled=t(C).isGit}),Mn(Ct,()=>t(xt),Ee=>p(xt,Ee)),W("click",ce,()=>p(k,!1)),W("click",De,Ze),h(P,j)};E(un,P=>{t(k)&&P(xn)})}H(()=>{$i(_t,t(be)),rn(gt,1,Oi(t(ee)?"animate-spin":""))}),W("input",_t,P=>p(be,P.currentTarget.value,!0)),W("click",kt,()=>ue()),h(n,jt),Xn(),L()}or(["input","click","keydown","change"]);var uf=m(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60"><div class="mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl"><h2 class="mb-2 text-lg font-bold text-brand-text">Session Conflict</h2> <p class="mb-6 text-sm text-brand-text-muted">Another client is active on a session in folder <span class="font-mono text-xs text-brand-text"> </span>. What would you like to do?</p> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Read Only</button> <button class="flex-1 rounded-lg bg-rose-500 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-rose-600">Take Over</button></div> <p class="mt-4 text-xs text-brand-text-muted"><strong class="text-brand-text">Read Only:</strong> Observe the session
|
|
86
86
|
live but cannot send messages.<br/> <strong class="text-brand-text">Take Over:</strong> Interrupt the other client
|
|
87
|
-
and gain control.</p></div></div>`);function
|
|
88
|
-
stored.</p> <pre class="mb-4 overflow-x-auto rounded-lg bg-brand-surface-3 px-3 py-2 font-mono text-xs text-brand-text"> </pre> <input type="password" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" placeholder="Password" class="mb-4 w-full rounded-lg border border-brand-border bg-brand-surface-3 px-3 py-2.5 text-sm text-brand-text outline-none focus:border-brand-blue"/> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="flex-1 rounded-lg bg-brand-blue px-4 py-2.5 text-sm text-brand-text transition-colors hover:opacity-90">Run</button></div></div></div>`);function ff(n,e){Zn(e,!0);const r=()=>$e(Ia,"$sudoPrompt",s),[s,o]=hr();let a=V(r),l=q(""),c=q(null),x=q(null);Rt(()=>{const G=t(a)?.promptId??null;G!==t(x)&&(p(x,G,!0),p(l,""),G&&queueMicrotask(()=>t(c)?.focus()))});function v(){t(a)&&(wa(t(l)),p(l,""))}function g(){Sa(),p(l,"")}function I(G){G.key==="Enter"?(G.preventDefault(),v()):G.key==="Escape"&&(G.preventDefault(),g())}var L=Un(),O=Ot(L);{var T=G=>{var ee=uf(),ue=u(ee),re=f(u(ue),4),Ve=u(re,!0);d(re);var Se=f(re,2);nt(Se),Bn(Se,Me=>p(c,Me),()=>t(c));var Re=f(Se,2),xe=u(Re),Le=f(xe,2);d(Re),d(ue),d(ee),H(()=>J(Ve,t(a).command)),W("keydown",Se,I),$n(Se,()=>t(l),Me=>p(l,Me)),W("click",xe,g),W("click",Le,v),h(G,ee)};E(O,G=>{t(a)&&G(T)})}h(n,L),Xn(),o()}or(["keydown","click"]);function pf(n){return n.loading||n.resyncing||n.hasSessionHash}function hf(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!pf(n)}var bf=m('<div class="fixed inset-0 z-[100] flex items-center justify-center bg-brand-dark/60 backdrop-blur-sm"><div class="flex flex-col items-center gap-4"><div class="h-12 w-12 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <span class="text-lg font-bold text-brand-text">Creating session...</span></div></div>'),vf=m('<span class="text-lg font-bold text-brand-text">Connection Settings</span> <button class="rounded px-2 py-1 text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-2 hover:text-brand-blue">◀ Back</button>',1),gf=m('<button class="flex items-center gap-2 text-left" title="Show Main Screen / New Session"><img alt="Wherever" class="h-6 w-6"/> <span class="gradient-text text-lg font-bold">Wherever</span></button> <div class="flex items-center gap-2"><button class="flex items-center gap-1 rounded border border-brand-border px-1.5 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-2 hover:text-brand-text" title="Connection Settings">⚙️ Config</button> <button class="text-brand-text-muted hover:text-brand-text md:hidden">X</button></div>',1),mf=m('<div class="flex-1 overflow-y-auto"><!> <div class="mt-2 border-t border-brand-border p-4"><h3 class="mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase">Server Control</h3> <div class="space-y-2"><button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Refresh Session List</span> <span>🔄</span></button> <button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Reconnect WebSocket</span> <span>🔌</span></button> <button class="flex w-full items-center justify-between rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-left text-sm text-rose-400 transition-colors hover:bg-red-500/20 hover:text-rose-300"><span>Disconnect Server</span> <span>🛑</span></button></div></div></div>'),xf=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),_f=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),yf=m('<div class="mt-2 space-y-1"><!> <!> <div class="pt-1.5"><button class="w-full rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-center text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Show Main Screen (Clear URL Hash)">Close Session</button></div></div>'),wf=m('<div class="mt-2 text-xs text-rose-400"> </div>'),Sf=m('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-brand-text" title="View read-only sessions (e.g. autonomous agent fleets)"><span>👁️</span> <span>Read-only sessions</span> <span class="ml-auto">→</span></button>'),kf=m('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/50" title="Back to your sessions"><span>←</span> <span>Back to sessions</span></button>'),Tf=m('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span> <span class="ml-auto font-mono text-xs text-brand-text-muted" title="App build version"> </span></div> <!> <!></div> <div class="border-b border-brand-border/50 px-2 py-1.5"><!></div> <div class="flex-1 overflow-hidden"><!></div>',1),Af=m('<button type="button" class="flex flex-shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-sm text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Search the web" aria-label="Search the web">🔍</button>'),Ef=m('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Cf=m('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),If=m('<span class="text-sm text-brand-text-muted">Not connected</span>'),Rf=m('<div class="flex min-w-0 items-center gap-2"><!></div>'),$f=m('<div class="flex min-w-0 items-center gap-1.5 text-xs text-brand-text-muted"><span class="flex-shrink-0">📁</span> <span class="truncate"> </span></div>'),Mf=m("<option> </option>"),Df=m('<select class="max-w-48 truncate rounded border border-brand-border bg-brand-surface-2 px-1.5 py-0.5 text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Pf=m('<span class="truncate text-brand-text-muted"> </span>'),Lf=m('<div class="flex min-w-0 items-center gap-1.5 text-xs"><span class="relative flex flex-shrink-0 items-center justify-center text-sm"><span>🤖</span> <span></span></span> <!></div>'),Of=m('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Nf=m('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Ff=m('<div class="border border-red-500/30 bg-red-500/10 px-4 py-2 text-center text-sm text-rose-400">Your session was interrupted — another client took over.</div>'),Uf=m('<div><span class="min-w-0 flex-1 break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss notice" class="flex-shrink-0 opacity-80 hover:opacity-100">X</button></div>'),zf=m('<div class="flex items-start justify-between gap-2 border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-rose-400"><span class="max-h-24 min-w-0 flex-1 overflow-y-auto break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss error" class="flex-shrink-0 text-rose-300 hover:text-rose-200">X</button></div>'),Bf=m('<div class="border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-center text-sm text-yellow-400">Read-only: this session cannot be driven from here</div>'),Hf=m('<div class="border-t border-brand-border bg-brand-surface px-4 py-3 text-center text-xs text-brand-text-muted">👁️ Read-only session, observing only, no input.</div>'),Wf=m('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Reconnecting and syncing session...</span></div>'),Gf=m('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Preparing the session agent...</span></div>'),jf=m("<!> <!>",1),qf=m('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),Vf=m('<!> <!> <div class="fixed inset-0 flex overflow-hidden overscroll-none bg-brand-dark text-brand-text"><div><div class="border-b border-brand-border bg-brand-surface-2/20 p-4"><div class="flex items-center justify-between"><!></div></div> <!></div> <div class="flex min-w-0 flex-1 flex-col"><div class="app-chrome flex items-center gap-3 border-b border-brand-border bg-brand-surface p-3"><button class="p-1 text-brand-text-muted hover:text-brand-text md:hidden">=</button> <!> <!> <!> <!></div> <!> <!> <!> <!> <!> <!></div> <!> <!> <!></div>',1);function np(n,e){Zn(e,!0);const r=()=>$e(Hr,"$isConnected",ee),s=()=>$e(Js,"$isResyncing",ee),o=()=>$e($a,"$isAgentPending",ee),a=()=>$e(as,"$isLoadingSession",ee),l=()=>$e(Ea,"$isInterrupted",ee),c=()=>$e(Qs,"$sessionError",ee),x=()=>$e(Ca,"$sessionNotice",ee),v=()=>$e(os,"$isReadOnly",ee),g=()=>$e(Wr,"$activeSessionInfo",ee),I=()=>$e($t,"$piState",ee),L=()=>$e(wr,"$availableModels",ee),O=()=>$e(Ra,"$isCreatingSession",ee),T=()=>$e(Gs,"$searchFolderStore",ee),G=()=>$e(sa,"$searchDefaultModelStore",ee),[ee,ue]=hr();let re=q(!1),Ve=q("main"),Se=q(!1),Re;zr(()=>{setTimeout(()=>ur(),200);const $=()=>{if(t(be)){const ae=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ae&&ae!==t(K)?Zs(ae):!ae&&t(K)&&In()}};window.addEventListener("hashchange",$);let N=null;const ge=8e3,Ae=()=>{if(document.visibilityState==="hidden"){if(fa())return;N&&clearTimeout(N),N=setTimeout(()=>{N=null,document.visibilityState==="hidden"&&t(be)&&da()},ge)}else Ys(),N&&(clearTimeout(N),N=null),t(be)||(Rs()?Is():ur())},Ne=ae=>{N&&(clearTimeout(N),N=null),document.visibilityState!=="hidden"&&!t(be)&&(Rs()?Is():ur())};return document.addEventListener("visibilitychange",Ae),window.addEventListener("pageshow",Ne),()=>{window.removeEventListener("hashchange",$),document.removeEventListener("visibilitychange",Ae),window.removeEventListener("pageshow",Ne),N&&clearTimeout(N)}});function xe(){ur()}function Le(){In(),Ur()}function Me(){Ur(),setTimeout(()=>ur(),100)}function Et(){Lr()}function rt(){typeof window<"u"&&(window.location.hash=""),In(),p(re,!1)}let be=V(r),Ye=V(s),Gt=V(o),Ge=V(a),st=V(l),yt=V(c),ot=V(x),et=V(v),we=V(g),at=V(I),Ie=V(()=>L().models),Nt=q(!1),K=V(()=>t(we).sessionId);Rt(()=>{typeof window<"u"&&t(be)&&(t(K)?(window.location.hash=encodeURIComponent(t(K)),p(Nt,!0)):t(Nt)&&(p(Nt,!1),window.location.hash&&(window.location.hash="")))});let mt=null;Rt(()=>{if(!t(be)||typeof window>"u"||!window.location.hash)return;const $=decodeURIComponent(window.location.hash.slice(1));$&&(t(K)===$||t(Ge)||t(Ye)||mt||(mt=setTimeout(()=>{mt=null,!(t(K)===$||t(Ge)||t(Ye))&&va($)},300)))}),Rt(()=>{t(be)||p(Nt,!1)}),Rt(()=>{(t(K)||t(Ge)||t(Ye))&&p(re,!1)});let an=V(O),pt=V(T),xt=q(void 0),Oe=V(()=>hf({connected:t(be),searchConfigured:!!t(pt),hasSession:!!t(we).sessionFile,loading:t(Ge),resyncing:t(Ye),hasSessionHash:typeof window<"u"&&!!window.location.hash})),Z=V(()=>t(Ie).map($=>({value:`${$.provider}:${$.modelId}`,label:`${$.label}${$.isDefault?" (default)":""}`}))),_e=V(G),k=q("");Rt(()=>{if(t(Z).length===0||t(Z).some(Ae=>Ae.value===t(k)))return;const N=t(Z).find(Ae=>Ae.value===t(_e)),ge=t(Ie).find(Ae=>Ae.isDefault);p(k,N?N.value:ge?`${ge.provider}:${ge.modelId}`:t(Z)[0].value,!0)});let te=q(!1);Rt(()=>{t(Oe)&&!t(te)&&t(xt)&&(p(te,!0),t(xt).focusInput())});function C(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),In(),t(xt)?.focusInput()}var oe=Vf(),z=Ot(oe);Hi(z,{title:"Wherever",description:"Create & maintain apps from wherever"});var ve=f(z,2);{var fe=$=>{var N=bf();h($,N)};E(ve,$=>{t(an)&&$(fe)})}var Ze=f(ve,2),Ue=u(Ze),vt=u(Ue),wt=u(vt),je=u(wt);{var ze=$=>{var N=vf(),ge=f(Ot(N),2);W("click",ge,()=>p(Se,!1)),h($,N)},Ft=$=>{var N=gf(),ge=Ot(N),Ae=u(ge);tt(2),d(ge);var Ne=f(ge,2),ae=u(Ne),ce=f(ae,2);d(Ne),H(De=>ye(Ae,"src",De),[()=>_r("/logo.svg")]),W("click",ge,rt),W("click",ae,()=>p(Se,!0)),W("click",ce,()=>p(re,!1)),h($,N)};E(je,$=>{t(Se)?$(ze):$(Ft,-1)})}d(wt),d(vt);var jt=f(vt,2);{var Ut=$=>{var N=mf(),ge=u(N);{let Ee=V(()=>(t(at).connected,"localhost"));vl(ge,{get host(){return t(Ee)},port:31415,token:"",onConnected:xe})}var Ae=f(ge,2),Ne=f(u(Ae),2),ae=u(Ne),ce=f(ae,2),De=f(ce,2);d(Ne),d(Ae),d(N),W("click",ae,Et),W("click",ce,Me),W("click",De,Le),h($,N)},hn=$=>{var N=Tf(),ge=Ot(N),Ae=u(ge),Ne=u(Ae),ae=f(Ne,2),ce=u(ae,!0);d(ae);var De=f(ae,2),Ee=u(De);d(De),d(Ae);var ct=f(Ae,2);{var Xt=X=>{var Be=yf(),Fe=u(Be);{var dt=se=>{var pe=xf(),Ke=u(pe);d(pe),H(Lt=>{ye(pe,"title",t(we).cwd),J(Ke,`📁 ${Lt??""}`)},[()=>t(we).cwd.split("/").pop()||t(we).cwd]),h(se,pe)};E(Fe,se=>{t(we).cwd&&se(dt)})}var tn=f(Fe,2);{var Vt=se=>{var pe=_f(),Ke=u(pe);d(pe),H(()=>{ye(pe,"title",t(we).model),J(Ke,`🤖 ${t(we).model??""}`)}),h(se,pe)};E(tn,se=>{t(we).model&&se(Vt)})}var Bt=f(tn,2),Pe=u(Bt);d(Bt),d(Be),W("click",Pe,rt),h(X,Be)};E(ct,X=>{t(we).sessionFile&&X(Xt)})}var fn=f(ct,2);{var y=X=>{var Be=wf(),Fe=u(Be,!0);d(Be),H(()=>J(Fe,t(at).error)),h(X,Be)};E(fn,X=>{t(at).error&&!t(be)&&X(y)})}d(ge);var w=f(ge,2),M=u(w);{var A=X=>{var Be=Sf();W("click",Be,()=>{p(Ve,"readonly"),ta()}),h(X,Be)},D=X=>{var Be=kf();W("click",Be,()=>p(Ve,"main")),h(X,Be)};E(M,X=>{t(Ve)==="main"?X(A):X(D,-1)})}d(w);var U=f(w,2),_=u(U);{var ie=X=>{qo(X,{readOnly:!0})},de=X=>{qo(X,{})};E(_,X=>{t(Ve)==="readonly"?X(ie):X(de,-1)})}d(U),H(()=>{rn(Ne,1,`h-2.5 w-2.5 rounded-full ${t(be)?"bg-emerald-500":"bg-rose-500"}`),rn(ae,1,`text-sm ${t(be)?"text-emerald-400":"text-rose-400"}`),J(ce,t(be)?"Connected":"Disconnected"),J(Ee,`v${Xo}`)}),h($,N)};E(jt,$=>{t(Se)?$(Ut):$(hn,-1)})}d(Ue);var St=f(Ue,2),_t=u(St),kt=u(_t),gt=f(kt,2);{var Kt=$=>{var N=Af();W("click",N,C),h($,N)};E(gt,$=>{t(be)&&t(pt)&&t(we).sessionFile&&$(Kt)})}var Yt=f(gt,2);{var wn=$=>{var N=Rf(),ge=u(N);{var Ae=ce=>{var De=Ef();h(ce,De)},Ne=ce=>{var De=Cf();h(ce,De)},ae=ce=>{var De=If();h(ce,De)};E(ge,ce=>{t(be)&&t(Oe)?ce(Ae):t(be)?ce(Ne,1):ce(ae,-1)})}d(N),h($,N)};E(Yt,$=>{(!t(be)||!t(we).sessionFile)&&$(wn)})}var ke=f(Yt,2);{var ht=$=>{var N=Of(),ge=u(N);{var Ae=ce=>{var De=$f(),Ee=f(u(De),2),ct=u(Ee,!0);d(Ee),d(De),H(Xt=>{ye(Ee,"title",t(we).cwd),J(ct,Xt)},[()=>t(we).cwd.split("/").pop()||t(we).cwd]),h(ce,De)};E(ge,ce=>{t(we).cwd&&ce(Ae)})}var Ne=f(ge,2);{var ae=ce=>{var De=Lf(),Ee=u(De),ct=f(u(Ee),2);d(Ee);var Xt=f(Ee,2);{var fn=w=>{var M=Df();gn(M,21,()=>t(Ie),Rn,(D,U)=>{var _=Mf(),ie=u(_,!0);d(_);var de={};H(()=>{J(ie,t(U).label),de!==(de=`${t(U).provider}:${t(U).modelId}`)&&(_.value=_.__value=`${t(U).provider}:${t(U).modelId}`)}),h(D,_)}),d(M);var A;Jo(M),H(()=>{A!==(A=t(we).model)&&(M.value=(M.__value=t(we).model)??"",Hs(M,t(we).model))}),W("input",M,D=>ka(D.currentTarget.value)),h(w,M)},y=w=>{var M=Pf(),A=u(M,!0);d(M),H(()=>{ye(M,"title",t(we).model),J(A,t(we).model)}),h(w,M)};E(Xt,w=>{t(Ie).length>0&&!t(et)?w(fn):w(y,-1)})}d(De),H(()=>{rn(ct,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(at).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),ye(ct,"title",t(at).isStreaming?"Agent working...":"Ready")}),h(ce,De)};E(Ne,ce=>{t(we).model&&ce(ae)})}d(N),h($,N)};E(ke,$=>{t(we).sessionFile&&$(ht)})}var Mt=f(ke,2);{var Tt=$=>{var N=Nf();h($,N)};E(Mt,$=>{t(et)&&$(Tt)})}d(_t);var At=f(_t,2);{var Zt=$=>{var N=Ff();h($,N)};E(At,$=>{t(st)&&$(Zt)})}var en=f(At,2);{var mn=$=>{var N=Uf(),ge=u(N),Ae=u(ge,!0);d(ge);var Ne=f(ge,2);d(N),H(()=>{rn(N,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(ot).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),J(Ae,t(ot).message)}),W("click",Ne,()=>ya()),h($,N)};E(en,$=>{t(ot)&&$(mn)})}var un=f(en,2);{var xn=$=>{var N=zf(),ge=u(N),Ae=u(ge,!0);d(ge);var Ne=f(ge,2);d(N),H(()=>J(Ae,t(yt))),W("click",Ne,()=>fr()),h($,N)};E(un,$=>{t(yt)&&$(xn)})}var P=f(un,2);{var j=$=>{var N=Bf();h($,N)};E(P,$=>{t(et)&&!t(st)&&$(j)})}var Y=f(P,2);Bn(Jd(Y,{onMessageSent:()=>{}}),$=>Re=$,()=>Re);var Q=f(Y,2);{var Te=$=>{var N=Hf();h($,N)},qt=$=>{var N=jf(),ge=Ot(N);{var Ae=ce=>{var De=Wf();h(ce,De)},Ne=ce=>{var De=Gf();h(ce,De)};E(ge,ce=>{t(we).sessionFile&&(t(Ye)||!t(be))?ce(Ae):t(we).sessionFile&&t(Gt)&&ce(Ne,1)})}var ae=f(ge,2);{let ce=V(()=>!!t(pt)),De=V(()=>t(Oe)?!t(be):!t(be)||t(et)||!t(we).sessionFile||t(Ye)||t(Gt));Bn(ku(ae,{get searchMode(){return t(Oe)},get searchConfigured(){return t(ce)},get searchModels(){return t(Z)},onSubmit:Ee=>ga(Ee,t(k)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(De)},onSend:()=>Re?.forceScrollToBottom(),get searchModel(){return t(k)},set searchModel(Ee){p(k,Ee,!0)}}),Ee=>p(xt,Ee,!0),()=>t(xt))}h($,N)};E(Q,$=>{t(et)&&t(we).sessionFile?$(Te):$(qt,-1)})}d(St);var Dt=f(St,2);df(Dt,{});var zt=f(Dt,2);ff(zt,{});var Ct=f(zt,2);{var Pt=$=>{var N=qf();W("click",N,()=>p(re,!1)),h($,N)};E(Ct,$=>{t(re)&&$(Pt)})}d(Ze),H(()=>rn(Ue,1,`app-chrome ${t(re)?"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`)),W("click",kt,()=>p(re,!t(re))),h(n,oe),Xn(),ue()}or(["click","input"]);export{np as component,tp as universal};
|
|
89
|
-
//# sourceMappingURL=2.
|
|
87
|
+
and gain control.</p></div></div>`);function ff(n,e){Zn(e,!0);const r=()=>$e(Ca,"$conflict",s),[s,o]=hr();let a=V(r);var l=Un(),c=Ot(l);{var x=v=>{var g=uf(),I=u(g),L=f(u(I),2),O=f(u(L)),T=u(O,!0);d(O),tt(),d(L);var G=f(L,2),ee=u(G),ue=f(ee,2);d(G),tt(2),d(I),d(g),H(()=>J(T,t(a).conflictingCwd)),W("click",ee,()=>Ps("read_only")),W("click",ue,()=>Ps("take_over")),h(v,g)};E(c,v=>{t(a)&&v(x)})}h(n,l),Xn(),o()}or(["click"]);var pf=m(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60"><div class="mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl"><h2 class="mb-2 text-lg font-bold text-brand-text">Sudo password</h2> <p class="mb-3 text-sm text-brand-text-muted">This command needs your sudo password to run. It is used once and never
|
|
88
|
+
stored.</p> <pre class="mb-4 overflow-x-auto rounded-lg bg-brand-surface-3 px-3 py-2 font-mono text-xs text-brand-text"> </pre> <input type="password" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" placeholder="Password" class="mb-4 w-full rounded-lg border border-brand-border bg-brand-surface-3 px-3 py-2.5 text-sm text-brand-text outline-none focus:border-brand-blue"/> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="flex-1 rounded-lg bg-brand-blue px-4 py-2.5 text-sm text-brand-text transition-colors hover:opacity-90">Run</button></div></div></div>`);function hf(n,e){Zn(e,!0);const r=()=>$e($a,"$sudoPrompt",s),[s,o]=hr();let a=V(r),l=q(""),c=q(null),x=q(null);Rt(()=>{const G=t(a)?.promptId??null;G!==t(x)&&(p(x,G,!0),p(l,""),G&&queueMicrotask(()=>t(c)?.focus()))});function v(){t(a)&&(ka(t(l)),p(l,""))}function g(){Ta(),p(l,"")}function I(G){G.key==="Enter"?(G.preventDefault(),v()):G.key==="Escape"&&(G.preventDefault(),g())}var L=Un(),O=Ot(L);{var T=G=>{var ee=pf(),ue=u(ee),re=f(u(ue),4),Ve=u(re,!0);d(re);var Se=f(re,2);nt(Se),Bn(Se,Me=>p(c,Me),()=>t(c));var Re=f(Se,2),xe=u(Re),Le=f(xe,2);d(Re),d(ue),d(ee),H(()=>J(Ve,t(a).command)),W("keydown",Se,I),$n(Se,()=>t(l),Me=>p(l,Me)),W("click",xe,g),W("click",Le,v),h(G,ee)};E(O,G=>{t(a)&&G(T)})}h(n,L),Xn(),o()}or(["keydown","click"]);function bf(n){return n.loading||n.resyncing||n.hasSessionHash}function vf(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!bf(n)}var gf=m('<div class="fixed inset-0 z-[100] flex items-center justify-center bg-brand-dark/60 backdrop-blur-sm"><div class="flex flex-col items-center gap-4"><div class="h-12 w-12 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <span class="text-lg font-bold text-brand-text">Creating session...</span></div></div>'),mf=m('<span class="text-lg font-bold text-brand-text">Connection Settings</span> <button class="rounded px-2 py-1 text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-2 hover:text-brand-blue">◀ Back</button>',1),xf=m('<button class="flex items-center gap-2 text-left" title="Show Main Screen / New Session"><img alt="Wherever" class="h-6 w-6"/> <span class="gradient-text text-lg font-bold">Wherever</span></button> <div class="flex items-center gap-2"><button class="flex items-center gap-1 rounded border border-brand-border px-1.5 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-2 hover:text-brand-text" title="Connection Settings">⚙️ Config</button> <button class="text-brand-text-muted hover:text-brand-text md:hidden">X</button></div>',1),_f=m('<div class="flex-1 overflow-y-auto"><!> <div class="mt-2 border-t border-brand-border p-4"><h3 class="mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase">Server Control</h3> <div class="space-y-2"><button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Refresh Session List</span> <span>🔄</span></button> <button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Reconnect WebSocket</span> <span>🔌</span></button> <button class="flex w-full items-center justify-between rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-left text-sm text-rose-400 transition-colors hover:bg-red-500/20 hover:text-rose-300"><span>Disconnect Server</span> <span>🛑</span></button></div></div></div>'),yf=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),wf=m('<div class="truncate text-xs text-brand-text-muted"> </div>'),Sf=m('<div class="mt-2 space-y-1"><!> <!> <div class="pt-1.5"><button class="w-full rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-center text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Show Main Screen (Clear URL Hash)">Close Session</button></div></div>'),kf=m('<div class="mt-2 text-xs text-rose-400"> </div>'),Tf=m('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-brand-text" title="View read-only sessions (e.g. autonomous agent fleets)"><span>👁️</span> <span>Read-only sessions</span> <span class="ml-auto">→</span></button>'),Af=m('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/50" title="Back to your sessions"><span>←</span> <span>Back to sessions</span></button>'),Ef=m('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span> <span class="ml-auto font-mono text-xs text-brand-text-muted" title="App build version"> </span></div> <!> <!></div> <div class="border-b border-brand-border/50 px-2 py-1.5"><!></div> <div class="flex-1 overflow-hidden"><!></div>',1),Cf=m('<button type="button" class="flex flex-shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-sm text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Search the web" aria-label="Search the web">🔍</button>'),If=m('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Rf=m('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),$f=m('<span class="text-sm text-brand-text-muted">Not connected</span>'),Mf=m('<div class="flex min-w-0 items-center gap-2"><!></div>'),Df=m('<div class="flex min-w-0 items-center gap-1.5 text-xs text-brand-text-muted"><span class="flex-shrink-0">📁</span> <span class="truncate"> </span></div>'),Pf=m("<option> </option>"),Lf=m('<select class="max-w-48 truncate rounded border border-brand-border bg-brand-surface-2 px-1.5 py-0.5 text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Of=m('<span class="truncate text-brand-text-muted"> </span>'),Nf=m('<div class="flex min-w-0 items-center gap-1.5 text-xs"><span class="relative flex flex-shrink-0 items-center justify-center text-sm"><span>🤖</span> <span></span></span> <!></div>'),Ff=m('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Uf=m('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),zf=m('<div class="border border-red-500/30 bg-red-500/10 px-4 py-2 text-center text-sm text-rose-400">Your session was interrupted — another client took over.</div>'),Bf=m('<div><span class="min-w-0 flex-1 break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss notice" class="flex-shrink-0 opacity-80 hover:opacity-100">X</button></div>'),Hf=m('<div class="flex items-start justify-between gap-2 border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-rose-400"><span class="max-h-24 min-w-0 flex-1 overflow-y-auto break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss error" class="flex-shrink-0 text-rose-300 hover:text-rose-200">X</button></div>'),Wf=m('<div class="border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-center text-sm text-yellow-400">Read-only: this session cannot be driven from here</div>'),Gf=m('<div class="border-t border-brand-border bg-brand-surface px-4 py-3 text-center text-xs text-brand-text-muted">👁️ Read-only session, observing only, no input.</div>'),jf=m('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Reconnecting and syncing session...</span></div>'),qf=m('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Preparing the session agent...</span></div>'),Vf=m("<!> <!>",1),Kf=m('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),Yf=m('<!> <!> <div class="fixed inset-0 flex overflow-hidden overscroll-none bg-brand-dark text-brand-text"><div><div class="border-b border-brand-border bg-brand-surface-2/20 p-4"><div class="flex items-center justify-between"><!></div></div> <!></div> <div class="flex min-w-0 flex-1 flex-col"><div class="app-chrome flex items-center gap-3 border-b border-brand-border bg-brand-surface p-3"><button class="p-1 text-brand-text-muted hover:text-brand-text md:hidden">=</button> <!> <!> <!> <!></div> <!> <!> <!> <!> <!> <!></div> <!> <!> <!></div>',1);function sp(n,e){Zn(e,!0);const r=()=>$e(Hr,"$isConnected",ee),s=()=>$e(to,"$isResyncing",ee),o=()=>$e(Da,"$isAgentPending",ee),a=()=>$e(as,"$isLoadingSession",ee),l=()=>$e(Ia,"$isInterrupted",ee),c=()=>$e(eo,"$sessionError",ee),x=()=>$e(Ra,"$sessionNotice",ee),v=()=>$e(os,"$isReadOnly",ee),g=()=>$e(Wr,"$activeSessionInfo",ee),I=()=>$e($t,"$piState",ee),L=()=>$e(wr,"$availableModels",ee),O=()=>$e(Ma,"$isCreatingSession",ee),T=()=>$e(qs,"$searchFolderStore",ee),G=()=>$e(aa,"$searchDefaultModelStore",ee),[ee,ue]=hr();let re=q(!1),Ve=q("main"),Se=q(!1),Re;zr(()=>{setTimeout(()=>ur(),200);const $=()=>{if(t(be)){const ae=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ae&&ae!==t(K)?Qs(ae):!ae&&t(K)&&In()}};window.addEventListener("hashchange",$);let N=null;const ge=8e3,Ae=()=>{if(document.visibilityState==="hidden"){if(ha())return;N&&clearTimeout(N),N=setTimeout(()=>{N=null,document.visibilityState==="hidden"&&t(be)&&fa()},ge)}else Xs(),N&&(clearTimeout(N),N=null),t(be)||(Ms()?$s():ur())},Ne=ae=>{N&&(clearTimeout(N),N=null),document.visibilityState!=="hidden"&&!t(be)&&(Ms()?$s():ur())};return document.addEventListener("visibilitychange",Ae),window.addEventListener("pageshow",Ne),()=>{window.removeEventListener("hashchange",$),document.removeEventListener("visibilitychange",Ae),window.removeEventListener("pageshow",Ne),N&&clearTimeout(N)}});function xe(){ur()}function Le(){In(),Ur()}function Me(){Ur(),setTimeout(()=>ur(),100)}function Et(){Lr()}function rt(){typeof window<"u"&&(window.location.hash=""),In(),p(re,!1)}let be=V(r),Ye=V(s),Gt=V(o),Ge=V(a),st=V(l),yt=V(c),ot=V(x),et=V(v),we=V(g),at=V(I),Ie=V(()=>L().models),Nt=q(!1),K=V(()=>t(we).sessionId);Rt(()=>{typeof window<"u"&&t(be)&&(t(K)?(window.location.hash=encodeURIComponent(t(K)),p(Nt,!0)):t(Nt)&&(p(Nt,!1),window.location.hash&&(window.location.hash="")))});let mt=null;Rt(()=>{if(!t(be)||typeof window>"u"||!window.location.hash)return;const $=decodeURIComponent(window.location.hash.slice(1));$&&(t(K)===$||t(Ge)||t(Ye)||mt||(mt=setTimeout(()=>{mt=null,!(t(K)===$||t(Ge)||t(Ye))&&ma($)},300)))}),Rt(()=>{t(be)||p(Nt,!1)}),Rt(()=>{(t(K)||t(Ge)||t(Ye))&&p(re,!1)});let an=V(O),pt=V(T),xt=q(void 0),Oe=V(()=>vf({connected:t(be),searchConfigured:!!t(pt),hasSession:!!t(we).sessionFile,loading:t(Ge),resyncing:t(Ye),hasSessionHash:typeof window<"u"&&!!window.location.hash})),Z=V(()=>t(Ie).map($=>({value:`${$.provider}:${$.modelId}`,label:`${$.label}${$.isDefault?" (default)":""}`}))),_e=V(G),k=q("");Rt(()=>{if(t(Z).length===0||t(Z).some(Ae=>Ae.value===t(k)))return;const N=t(Z).find(Ae=>Ae.value===t(_e)),ge=t(Ie).find(Ae=>Ae.isDefault);p(k,N?N.value:ge?`${ge.provider}:${ge.modelId}`:t(Z)[0].value,!0)});let te=q(!1);Rt(()=>{t(Oe)&&!t(te)&&t(xt)&&(p(te,!0),t(xt).focusInput())});function C(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),In(),t(xt)?.focusInput()}var oe=Yf(),z=Ot(oe);Gi(z,{title:"Wherever",description:"Create & maintain apps from wherever"});var ve=f(z,2);{var fe=$=>{var N=gf();h($,N)};E(ve,$=>{t(an)&&$(fe)})}var Ze=f(ve,2),Ue=u(Ze),vt=u(Ue),wt=u(vt),je=u(wt);{var ze=$=>{var N=mf(),ge=f(Ot(N),2);W("click",ge,()=>p(Se,!1)),h($,N)},Ft=$=>{var N=xf(),ge=Ot(N),Ae=u(ge);tt(2),d(ge);var Ne=f(ge,2),ae=u(Ne),ce=f(ae,2);d(Ne),H(De=>ye(Ae,"src",De),[()=>_r("/logo.svg")]),W("click",ge,rt),W("click",ae,()=>p(Se,!0)),W("click",ce,()=>p(re,!1)),h($,N)};E(je,$=>{t(Se)?$(ze):$(Ft,-1)})}d(wt),d(vt);var jt=f(vt,2);{var Ut=$=>{var N=_f(),ge=u(N);{let Ee=V(()=>(t(at).connected,"localhost"));ml(ge,{get host(){return t(Ee)},port:31415,token:"",onConnected:xe})}var Ae=f(ge,2),Ne=f(u(Ae),2),ae=u(Ne),ce=f(ae,2),De=f(ce,2);d(Ne),d(Ae),d(N),W("click",ae,Et),W("click",ce,Me),W("click",De,Le),h($,N)},hn=$=>{var N=Ef(),ge=Ot(N),Ae=u(ge),Ne=u(Ae),ae=f(Ne,2),ce=u(ae,!0);d(ae);var De=f(ae,2),Ee=u(De);d(De),d(Ae);var ct=f(Ae,2);{var Xt=X=>{var Be=Sf(),Fe=u(Be);{var dt=se=>{var pe=yf(),Ke=u(pe);d(pe),H(Lt=>{ye(pe,"title",t(we).cwd),J(Ke,`📁 ${Lt??""}`)},[()=>t(we).cwd.split("/").pop()||t(we).cwd]),h(se,pe)};E(Fe,se=>{t(we).cwd&&se(dt)})}var tn=f(Fe,2);{var Vt=se=>{var pe=wf(),Ke=u(pe);d(pe),H(()=>{ye(pe,"title",t(we).model),J(Ke,`🤖 ${t(we).model??""}`)}),h(se,pe)};E(tn,se=>{t(we).model&&se(Vt)})}var Bt=f(tn,2),Pe=u(Bt);d(Bt),d(Be),W("click",Pe,rt),h(X,Be)};E(ct,X=>{t(we).sessionFile&&X(Xt)})}var fn=f(ct,2);{var y=X=>{var Be=kf(),Fe=u(Be,!0);d(Be),H(()=>J(Fe,t(at).error)),h(X,Be)};E(fn,X=>{t(at).error&&!t(be)&&X(y)})}d(ge);var w=f(ge,2),M=u(w);{var A=X=>{var Be=Tf();W("click",Be,()=>{p(Ve,"readonly"),ra()}),h(X,Be)},D=X=>{var Be=Af();W("click",Be,()=>p(Ve,"main")),h(X,Be)};E(M,X=>{t(Ve)==="main"?X(A):X(D,-1)})}d(w);var U=f(w,2),_=u(U);{var ie=X=>{Ko(X,{readOnly:!0})},de=X=>{Ko(X,{})};E(_,X=>{t(Ve)==="readonly"?X(ie):X(de,-1)})}d(U),H(()=>{rn(Ne,1,`h-2.5 w-2.5 rounded-full ${t(be)?"bg-emerald-500":"bg-rose-500"}`),rn(ae,1,`text-sm ${t(be)?"text-emerald-400":"text-rose-400"}`),J(ce,t(be)?"Connected":"Disconnected"),J(Ee,`v${Jo}`)}),h($,N)};E(jt,$=>{t(Se)?$(Ut):$(hn,-1)})}d(Ue);var St=f(Ue,2),_t=u(St),kt=u(_t),gt=f(kt,2);{var Kt=$=>{var N=Cf();W("click",N,C),h($,N)};E(gt,$=>{t(be)&&t(pt)&&t(we).sessionFile&&$(Kt)})}var Yt=f(gt,2);{var wn=$=>{var N=Mf(),ge=u(N);{var Ae=ce=>{var De=If();h(ce,De)},Ne=ce=>{var De=Rf();h(ce,De)},ae=ce=>{var De=$f();h(ce,De)};E(ge,ce=>{t(be)&&t(Oe)?ce(Ae):t(be)?ce(Ne,1):ce(ae,-1)})}d(N),h($,N)};E(Yt,$=>{(!t(be)||!t(we).sessionFile)&&$(wn)})}var ke=f(Yt,2);{var ht=$=>{var N=Ff(),ge=u(N);{var Ae=ce=>{var De=Df(),Ee=f(u(De),2),ct=u(Ee,!0);d(Ee),d(De),H(Xt=>{ye(Ee,"title",t(we).cwd),J(ct,Xt)},[()=>t(we).cwd.split("/").pop()||t(we).cwd]),h(ce,De)};E(ge,ce=>{t(we).cwd&&ce(Ae)})}var Ne=f(ge,2);{var ae=ce=>{var De=Nf(),Ee=u(De),ct=f(u(Ee),2);d(Ee);var Xt=f(Ee,2);{var fn=w=>{var M=Lf();gn(M,21,()=>t(Ie),Rn,(D,U)=>{var _=Pf(),ie=u(_,!0);d(_);var de={};H(()=>{J(ie,t(U).label),de!==(de=`${t(U).provider}:${t(U).modelId}`)&&(_.value=_.__value=`${t(U).provider}:${t(U).modelId}`)}),h(D,_)}),d(M);var A;ta(M),H(()=>{A!==(A=t(we).model)&&(M.value=(M.__value=t(we).model)??"",Gs(M,t(we).model))}),W("input",M,D=>Aa(D.currentTarget.value)),h(w,M)},y=w=>{var M=Of(),A=u(M,!0);d(M),H(()=>{ye(M,"title",t(we).model),J(A,t(we).model)}),h(w,M)};E(Xt,w=>{t(Ie).length>0&&!t(et)?w(fn):w(y,-1)})}d(De),H(()=>{rn(ct,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(at).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),ye(ct,"title",t(at).isStreaming?"Agent working...":"Ready")}),h(ce,De)};E(Ne,ce=>{t(we).model&&ce(ae)})}d(N),h($,N)};E(ke,$=>{t(we).sessionFile&&$(ht)})}var Mt=f(ke,2);{var Tt=$=>{var N=Uf();h($,N)};E(Mt,$=>{t(et)&&$(Tt)})}d(_t);var At=f(_t,2);{var Zt=$=>{var N=zf();h($,N)};E(At,$=>{t(st)&&$(Zt)})}var en=f(At,2);{var mn=$=>{var N=Bf(),ge=u(N),Ae=u(ge,!0);d(ge);var Ne=f(ge,2);d(N),H(()=>{rn(N,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(ot).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),J(Ae,t(ot).message)}),W("click",Ne,()=>Sa()),h($,N)};E(en,$=>{t(ot)&&$(mn)})}var un=f(en,2);{var xn=$=>{var N=Hf(),ge=u(N),Ae=u(ge,!0);d(ge);var Ne=f(ge,2);d(N),H(()=>J(Ae,t(yt))),W("click",Ne,()=>fr()),h($,N)};E(un,$=>{t(yt)&&$(xn)})}var P=f(un,2);{var j=$=>{var N=Wf();h($,N)};E(P,$=>{t(et)&&!t(st)&&$(j)})}var Y=f(P,2);Bn(tu(Y,{onMessageSent:()=>{}}),$=>Re=$,()=>Re);var Q=f(Y,2);{var Te=$=>{var N=Gf();h($,N)},qt=$=>{var N=Vf(),ge=Ot(N);{var Ae=ce=>{var De=jf();h(ce,De)},Ne=ce=>{var De=qf();h(ce,De)};E(ge,ce=>{t(we).sessionFile&&(t(Ye)||!t(be))?ce(Ae):t(we).sessionFile&&t(Gt)&&ce(Ne,1)})}var ae=f(ge,2);{let ce=V(()=>!!t(pt)),De=V(()=>t(Oe)?!t(be):!t(be)||t(et)||!t(we).sessionFile||t(Ye)||t(Gt));Bn(Au(ae,{get searchMode(){return t(Oe)},get searchConfigured(){return t(ce)},get searchModels(){return t(Z)},onSubmit:Ee=>xa(Ee,t(k)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(De)},onSend:()=>Re?.forceScrollToBottom(),get searchModel(){return t(k)},set searchModel(Ee){p(k,Ee,!0)}}),Ee=>p(xt,Ee,!0),()=>t(xt))}h($,N)};E(Q,$=>{t(et)&&t(we).sessionFile?$(Te):$(qt,-1)})}d(St);var Dt=f(St,2);ff(Dt,{});var zt=f(Dt,2);hf(zt,{});var Ct=f(zt,2);{var Pt=$=>{var N=Kf();W("click",N,()=>p(re,!1)),h($,N)};E(Ct,$=>{t(re)&&$(Pt)})}d(Ze),H(()=>rn(Ue,1,`app-chrome ${t(re)?"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`)),W("click",kt,()=>p(re,!t(re))),h(n,oe),Xn(),ue()}or(["click","input"]);export{sp as component,rp as universal};
|
|
89
|
+
//# sourceMappingURL=2.DTWm0M0B.js.map
|