wherever-dev 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/assistant-channels.d.ts +242 -0
- package/dist/assistant-channels.d.ts.map +1 -0
- package/dist/assistant-channels.js +270 -0
- package/dist/assistant-channels.js.map +1 -0
- package/dist/assistant-controller.d.ts +228 -0
- package/dist/assistant-controller.d.ts.map +1 -0
- package/dist/assistant-controller.js +314 -0
- package/dist/assistant-controller.js.map +1 -0
- package/dist/assistant-cron.d.ts +87 -0
- package/dist/assistant-cron.d.ts.map +1 -0
- package/dist/assistant-cron.js +352 -0
- package/dist/assistant-cron.js.map +1 -0
- package/dist/assistant-folder.d.ts +161 -0
- package/dist/assistant-folder.d.ts.map +1 -0
- package/dist/assistant-folder.js +333 -0
- package/dist/assistant-folder.js.map +1 -0
- package/dist/assistant-schedule.d.ts +236 -0
- package/dist/assistant-schedule.d.ts.map +1 -0
- package/dist/assistant-schedule.js +454 -0
- package/dist/assistant-schedule.js.map +1 -0
- package/dist/assistant-scheduler.d.ts +210 -0
- package/dist/assistant-scheduler.d.ts.map +1 -0
- package/dist/assistant-scheduler.js +472 -0
- package/dist/assistant-scheduler.js.map +1 -0
- package/dist/assistant-tool-text.d.ts +40 -0
- package/dist/assistant-tool-text.d.ts.map +1 -0
- package/dist/assistant-tool-text.js +102 -0
- package/dist/assistant-tool-text.js.map +1 -0
- package/dist/assistant-tools.d.ts +207 -0
- package/dist/assistant-tools.d.ts.map +1 -0
- package/dist/assistant-tools.js +390 -0
- package/dist/assistant-tools.js.map +1 -0
- package/dist/attach-file-tool.d.ts +20 -1
- package/dist/attach-file-tool.d.ts.map +1 -1
- package/dist/attach-file-tool.js +45 -3
- package/dist/attach-file-tool.js.map +1 -1
- package/dist/cli-requests.d.ts +90 -0
- package/dist/cli-requests.d.ts.map +1 -0
- package/dist/cli-requests.js +75 -0
- package/dist/cli-requests.js.map +1 -0
- package/dist/download-grants.d.ts +12 -0
- package/dist/download-grants.d.ts.map +1 -0
- package/dist/download-grants.js +76 -0
- package/dist/download-grants.js.map +1 -0
- package/dist/index.js +431 -20
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +43 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/reply-routing.d.ts +106 -0
- package/dist/reply-routing.d.ts.map +1 -0
- package/dist/reply-routing.js +174 -0
- package/dist/reply-routing.js.map +1 -0
- package/dist/session-pool.d.ts +243 -4
- package/dist/session-pool.d.ts.map +1 -1
- package/dist/session-pool.js +464 -100
- package/dist/session-pool.js.map +1 -1
- package/dist/telegram-channel.d.ts +272 -0
- package/dist/telegram-channel.d.ts.map +1 -0
- package/dist/telegram-channel.js +701 -0
- package/dist/telegram-channel.js.map +1 -0
- package/dist/telegram-files.d.ts +101 -0
- package/dist/telegram-files.d.ts.map +1 -0
- package/dist/telegram-files.js +145 -0
- package/dist/telegram-files.js.map +1 -0
- package/dist/telegram-pairing.d.ts +119 -0
- package/dist/telegram-pairing.d.ts.map +1 -0
- package/dist/telegram-pairing.js +97 -0
- package/dist/telegram-pairing.js.map +1 -0
- package/dist/telegram-replies.d.ts +94 -0
- package/dist/telegram-replies.d.ts.map +1 -0
- package/dist/telegram-replies.js +329 -0
- package/dist/telegram-replies.js.map +1 -0
- package/dist/telegram-token.d.ts +55 -0
- package/dist/telegram-token.d.ts.map +1 -0
- package/dist/telegram-token.js +86 -0
- package/dist/telegram-token.js.map +1 -0
- package/dist/web-push.d.ts +167 -0
- package/dist/web-push.d.ts.map +1 -0
- package/dist/web-push.js +387 -0
- package/dist/web-push.js.map +1 -0
- package/package.json +1 -1
- package/public/_app/immutable/assets/0.BkzT3rFr.css +1 -0
- package/public/_app/immutable/chunks/CExVgK9Z.js +2 -0
- package/public/_app/immutable/chunks/CExVgK9Z.js.map +1 -0
- package/public/_app/immutable/chunks/CkOw6fRa.js +2 -0
- package/public/_app/immutable/chunks/{idnZrCTB.js.map → CkOw6fRa.js.map} +1 -1
- package/public/_app/immutable/chunks/DyHllYtq.js +2 -0
- package/public/_app/immutable/chunks/{DJMI34rR.js.map → DyHllYtq.js.map} +1 -1
- package/public/_app/immutable/entry/{app.CF_gzWKW.js → app.D3PEFbtP.js} +3 -3
- package/public/_app/immutable/entry/{app.CF_gzWKW.js.map → app.D3PEFbtP.js.map} +1 -1
- package/public/_app/immutable/entry/start.BR00Qps5.js +2 -0
- package/public/_app/immutable/entry/start.BR00Qps5.js.map +1 -0
- package/public/_app/immutable/nodes/{0.CIIhZFWl.js → 0.DG3L8hMN.js} +3 -3
- package/public/_app/immutable/nodes/{0.CIIhZFWl.js.map → 0.DG3L8hMN.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.D4WVeMej.js → 1.BCpuoZxW.js} +2 -2
- package/public/_app/immutable/nodes/{1.D4WVeMej.js.map → 1.BCpuoZxW.js.map} +1 -1
- package/public/_app/immutable/nodes/2.D2auiZW1.js +122 -0
- package/public/_app/immutable/nodes/2.D2auiZW1.js.map +1 -0
- package/public/_app/version.json +1 -1
- package/public/index.html +11 -11
- package/public/service-worker.js +1 -1
- package/public/_app/immutable/assets/0.BKJ49K71.css +0 -1
- package/public/_app/immutable/chunks/CkzyFwPn.js +0 -2
- package/public/_app/immutable/chunks/CkzyFwPn.js.map +0 -1
- package/public/_app/immutable/chunks/DJMI34rR.js +0 -2
- package/public/_app/immutable/chunks/idnZrCTB.js +0 -2
- package/public/_app/immutable/entry/start.GpPJ13Gr.js +0 -2
- package/public/_app/immutable/entry/start.GpPJ13Gr.js.map +0 -1
- package/public/_app/immutable/nodes/2._KcrsFWH.js +0 -120
- package/public/_app/immutable/nodes/2._KcrsFWH.js.map +0 -1
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import"../chunks/DsnmJJEf.js";import{ao as er,aU as Ws,ai as Zr,b5 as E,am as za,w as Hc,G as go,aL as jc,an as Lo,b as Gi,aj as Do,ap as Gc,k as Wc,V as Kc,q as qc,p as Vc,W as Yc,J as Xc,K as Zc,H as Jc,aV as Ha,C as ja,v as Ga,aw as Qs,X as Lr,a7 as Qc,as as ed,aS as td,ar as Wi,b4 as Ki,b7 as nd,b9 as Ar,aN as na,aJ as Wa,aI as hr,aF as br,aa as Dt,a_ as f,af as t,Z as rd,y as h,Q as dr,ac as b,ba as P,$ as sd,be as vr,a3 as vn,ae as Nn,a0 as Mr,aD as ys,aT as p,M as d,aO as c,aA as pt,a1 as M,b1 as N,aH as Vn,bb as Ut,bc as od,aW as I,a9 as wr,b6 as qn,ad as eo,aC as ad,aM as id,aB as Ka}from"../chunks/CAL8yDNt.js";import{i as k,s as Ur,a as we,p as ur}from"../chunks/Cjaz9aih.js";import{u as ld,F as Y,C as hs,E as cd,m as bs,a as dd,n as ws,o as ks,I as ud,z as qi,x as fd,t as Tt,d as Ks,f as Vi,G as ra,e as sa,p as oa,h as Ln,q as pr,g as pd,j as hd,i as Yi,H as Xi,k as Zi,s as Ji,B as Qi,D as el,w as bd,l as vd,y as gd,b as md}from"../chunks/CkzyFwPn.js";import{_ as xd,b as ir}from"../chunks/BORm3wtc.js";import{v as Fs}from"../chunks/idnZrCTB.js";import{p as _d}from"../chunks/DJMI34rR.js";function qa(n,e,r=!1,s=!1,o=!1,a=!1){var i=n,u="";if(r){var m=n;er&&(i=Ws(Zr(m)))}E(()=>{var v=Hc;if(u===(u=e()??"")){er&&za();return}if(r&&!er){v.nodes=null,m.innerHTML=u,u!==""&&go(Zr(m),m.lastChild);return}if(v.nodes!==null&&(jc(v.nodes.start,v.nodes.end),v.nodes=null),u!==""){if(er){Lo.data;for(var g=za(),x=g;g!==null&&(g.nodeType!==Gi||g.data!=="");)x=g,g=Do(g);if(g===null)throw Gc(),Wc;go(Lo,x),i=Ws(g);return}var _=s?qc:o?Vc:void 0,$=Kc(s?"svg":o?"math":"template",_);$.innerHTML=u;var L=s||o?$:$.content;if(go(Zr(L),L.lastChild),s||o)for(;Zr(L);)i.before(Zr(L));else i.before(L)}})}function yd(n,e){let r=null,s=er;var o;if(er){r=Lo;for(var a=Zr(document.head);a!==null&&(a.nodeType!==Gi||a.data!==n);)a=Do(a);if(a===null)Ha(!1);else{var i=Do(a);a.remove(),Ws(i)}}er||(o=document.head.appendChild(Yc()));try{Xc(()=>{var u=Zc(()=>e(o));u.f|=Jc})}finally{s&&(Ha(!0),Ws(r))}}function tl(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=tl(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function wd(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=tl(n))&&(s&&(s+=" "),s+=e);return s}function nl(n){return typeof n=="object"?wd(n):n??""}function kd(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function Sd(n,e){return n==null?null:String(n)}function an(n,e,r,s,o,a){var i=n[ja];if(er||i!==r||i===void 0){var u=kd(r);(!er||u!==n.getAttribute("class"))&&(u==null?n.removeAttribute("class"):e?n.className=u:n.setAttribute("class",u)),n[ja]=r}return a}function aa(n,e,r,s){var o=n[Ga];if(er||o!==e){var a=Sd(e);(!er||a!==n.getAttribute("style"))&&(a==null?n.removeAttribute("style"):n.style.cssText=a),n[Ga]=e}return s}function ia(n,e,r=!1){if(n.multiple){if(e==null)return;if(!ed(e))return td();for(var s of n.options)s.selected=e.includes(vs(s));return}for(s of n.options){var o=vs(s);if(Wi(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function rl(n){var e=new MutationObserver(()=>{ia(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Ki(()=>{e.disconnect()})}function xs(n,e,r=e){var s=new WeakSet,o=!0;Qs(n,"change",a=>{var i=a?"[selected]":":checked",u;if(n.multiple)u=[].map.call(n.querySelectorAll(i),vs);else{var m=n.querySelector(i)??n.querySelector("option:not([disabled])");u=m&&vs(m)}r(u),n.__value=u,Lr!==null&&s.add(Lr)}),Qc(()=>{var a=e();if(n===document.activeElement){var i=Lr;if(s.has(i))return}if(ia(n,a,o),o&&a===void 0){var u=n.querySelector(":checked");u!==null&&(a=vs(u),r(a))}n.__value=a,o=!1}),rl(n)}function vs(n){return"__value"in n?n.__value:n.value}function ar(n,e,r=e){var s=new WeakSet;Qs(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=xo(n)?_o(a):a,r(a),Lr!==null&&s.add(Lr),await nd(),a!==(a=e())){var i=n.selectionStart,u=n.selectionEnd,m=n.value.length;if(n.value=a??"",u!==null){var v=n.value.length;i===u&&u===m&&v>m?(n.selectionStart=v,n.selectionEnd=v):(n.selectionStart=i,n.selectionEnd=Math.min(u,v))}}}),(er&&n.defaultValue!==n.value||Ar(e)==null&&n.value)&&(r(xo(n)?_o(n.value):n.value),Lr!==null&&s.add(Lr)),na(()=>{var o=e();if(n===document.activeElement){var a=Lr;if(s.has(a))return}xo(n)&&o===_o(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const mo=new Set;function Nr(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",i=n;let u=!1;if(e!==null)for(var m of e)i=i[m]??=[];i.push(r),Qs(r,"change",()=>{var v=r.__value;a&&(v=Va(i,v,r.checked)),o(v)},()=>o(a?[]:null)),na(()=>{var v=s();if(er&&r.defaultChecked!==r.checked){u=!0;return}a?(v=v||[],r.checked=v.includes(r.__value)):r.checked=Wi(r.__value,v)}),Ki(()=>{var v=i.indexOf(r);v!==-1&&i.splice(v,1)}),mo.has(i)||(mo.add(i),Wa(()=>{i.sort((v,g)=>v.compareDocumentPosition(g)===4?-1:1),mo.delete(i)})),Wa(()=>{if(u){var v;if(a)v=Va(i,v,r.checked);else{var g=i.find(x=>x.checked);v=g?.__value}o(v)}})}function Zn(n,e,r=e){Qs(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(er&&n.defaultChecked!==n.checked||Ar(e)==null)&&r(n.checked),na(()=>{var s=e();n.checked=!!s})}function Va(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 xo(n){var e=n.type;return e==="number"||e==="range"}function _o(n){return n===""?null:+n}const Td=!1,Ad=!0,lx=Object.freeze(Object.defineProperty({__proto__:null,prerender:Ad,ssr:Td},Symbol.toStringTag,{value:"Module"})),yo="Wherever",Cd="Create & maintain apps from wherever with a beautiful remote workspace.",wo="https://localhost",Ed="#000000",Rd="black-translucent";function Qr(n,e){return ld(n)}var Id=b('<meta name="title"/> <meta name="description"/> <!> <meta property="og:type"/> <meta property="og:url"/> <meta property="og:title"/> <meta property="og:description"/> <meta property="og:image"/> <meta property="twitter:card" content="summary_large_image"/> <meta property="twitter:url"/> <meta property="twitter:title"/> <meta property="twitter:description"/> <meta property="twitter:image"/> <link rel="icon" type="image/png"/> <link rel="icon" sizes="any"/> <link rel="apple-touch-icon"/> <link rel="manifest"/> <meta name="theme-color"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="application-name"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style"/> <meta name="apple-mobile-web-app-title"/> <meta name="version"/>',1);function Md(n,e){hr(e,!0);const r=wo.endsWith("/")?wo.slice(0,-1):wo,s=r+"/preview.png";let o=P(()=>e.home||!1),a=P(()=>({type:e.type||"website",title:e.title||yo,description:e.description||Cd,image:e.image||s,url:`${r}${_d.url.pathname}`}));yd("13n5pl5",i=>{var u=Id(),m=Dt(u),v=f(m,2),g=f(v,2);{var x=_t=>{var Be=dr(),nt=Dt(Be);k(nt,yt=>{}),h(_t,Be)};k(g,_t=>{t(o)&&_t(x)})}var _=f(g,2),$=f(_,2),L=f($,2),B=f(L,2),W=f(B,2),Ne=f(W,4),re=f(Ne,2),Ke=f(re,2),ve=f(Ke,2),ce=f(ve,2),K=f(ce,2),je=f(K,2),Qe=f(je,2),Ue=f(Qe,2),oe=f(Ue,4),et=f(oe,4),dt=f(et,2),ht=f(dt,2);E((_t,Be,nt,yt)=>{Y(m,"content",t(a).title),Y(v,"content",t(a).description),Y(_,"content",t(a).type),Y($,"content",t(a).url),Y(L,"content",t(a).title),Y(B,"content",t(a).description),Y(W,"content",t(a).image),Y(Ne,"content",t(a).url),Y(re,"content",t(a).title),Y(Ke,"content",t(a).description),Y(ve,"content",t(a).image),Y(ce,"href",_t),Y(K,"href",Be),Y(je,"href",nt),Y(Qe,"href",yt),Y(Ue,"content",Ed),Y(oe,"content",yo),Y(et,"content",Rd),Y(dt,"content",yo),Y(ht,"content",Fs)},[()=>Qr("/pwa/favicon.png"),()=>Qr("/pwa/favicon.ico"),()=>Qr("/pwa/apple-touch-icon.png"),()=>Qr("/pwa/manifest.webmanifest")]),rd(()=>{sd.title=t(a).title??""}),h(i,u)}),br()}let ss=null;function $d(){if(typeof window>"u")return null;try{if(!ss){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;ss=new n}return ss.state==="suspended"&&ss.resume().catch(()=>{}),ss}catch{return null}}function Ya(n,e,r,s,o){const a=n.createOscillator(),i=n.createGain();a.type="sine",a.frequency.value=e;const u=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(o,r+u),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(n.destination),a.start(r),a.stop(r+s+.02)}const Xa=new Map;function Od(n){if(typeof Audio>"u")return!1;try{let e=Xa.get(n);e||(e=new Audio(n),e.preload="auto",Xa.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 sl(n){if(n&&n.trim()&&Od(n.trim()))return;const e=$d();if(e)try{const r=e.currentTime;Ya(e,1046.5,r,.16,.12),Ya(e,1396.9,r+.13,.22,.12)}catch{}}function la(n){if(!n)return null;const e=n.trimStart(),r=e.match(/^<skill\s+name="([^"]*)"[^>]*>/);if(r){const s=e.indexOf("</skill>");return s===-1?null:{skillName:r[1],args:e.slice(s+8).trim()}}if(e.startsWith("/skill:")){const s=e.slice(7),o=s.indexOf(" "),a=o===-1?s:s.slice(0,o);if(!a)return null;const i=o===-1?"":s.slice(o+1).trim();return{skillName:a,args:i}}return null}function $s(n){const e=la(n);return e?`skill:${e.skillName}\0${e.args}`:null}function Bs(){}function Ld(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Dd(n,...e){if(n==null)return Bs;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Nt(n){let e;return Dd(n,r=>e=r)(),e}var Vr=[];function Za(n,e=Bs){let r;const s=new Set;function o(u){if(Ld(n,u)&&(n=u,r)){const m=!Vr.length;for(const v of s)v[1](),Vr.push(v,n);if(m){for(let v=0;v<Vr.length;v+=2)Vr[v][0](Vr[v+1]);Vr.length=0}}}function a(u){o(u(n))}function i(u,m=Bs){const v=[u,m];return s.add(v),s.size===1&&(r=e(o)||Bs),u(n),()=>{s.delete(v),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:i}}function Ja(){return`ck-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}const Pd="upload.v1",to=1024,Qa=64*to,Nd=1024*to,Ud=256*to,Fd=2,ei=.3,ti=3*256*to,ol="The file is no longer readable, pick it again";function Bd(n,e,r){const s=3+n.length,o=new Uint8Array(s+8+r.length);o[0]=1,o[1]=1,o[2]=n.length;for(let i=0;i<n.length;i++)o[3+i]=n.charCodeAt(i);const a=new DataView(o.buffer);return a.setUint32(s,Math.floor(e/2**32)),a.setUint32(s+4,e>>>0),o.set(r,s+8),o}function al(n){let e="";for(let r=0;r<n.length;r+=32768)e+=String.fromCharCode.apply(null,n.subarray(r,r+32768));return e}function zd(){const n=new Uint8Array(16),e=globalThis.crypto;if(e&&typeof e.getRandomValues=="function")e.getRandomValues(n);else for(let r=0;r<n.length;r++)n[r]=Math.floor(Math.random()*256);return btoa(al(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}class ts extends Error{code}function ko(n){if(n instanceof ts)return n;if(n&&n.name==="NotReadableError"){const e=new ts(ol);return e.code="not_readable",e}return new ts(`Failed to read the file: ${n&&n.message||n}`)}function ni(){const n=new ts(ol);return n.code="not_readable",n}function il(n){return n.startsWith("http")?n.replace(/^https?:\/\//,""):n}function Hd(n){let e=2166136261;for(let r=0;r<n.length;r++)e^=n.charCodeAt(r),e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")}function qs(n){return`${il(n.host)}:${n.port}#${Hd(n.token??"")}`}const So={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,serverVersion:null,piVersion:null,folderConflict:null,folderMissing:null,restore: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,historyAuthoritative:!1,serverKey:null,contextUsage:null,pendingSteering:[],skills:[]};class En{ws=null;config;clientKey;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;static MIN_RECONNECT_DELAY=2e3;reconnectDelay=En.MIN_RECONNECT_DELAY;socketStartedAt=0;maxReconnectDelay=15e3;hasEverConnected=!1;static HANDSHAKE_FAIL_HINT_AFTER=2;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;static PROBE_GRACE_MS=5e3;static VISIBLE_PROBE_GRACE_MS=2e3;static STALLED_HANDSHAKE_MS=8e3;probeTimer=null;lastLivenessTickAt=0;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;pendingLoadFile=null;socketServerKey=null;hydratedFile=null;listeners=new Set;pendingUploads=new Map;uploadsStore=Za({});socketCapabilities=null;static MAX_UPLOAD_SENDS=3;static MAX_UPLOAD_BASE64_CHARS=96*1024*1024;static MAX_LEGACY_UPLOAD_BYTES=72*1024*1024;static UPLOAD_TIMEOUT_MS=10*6e4;uploadsHeldForRejoin=!1;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.clientKey=this.config.clientKey||Ja(),this.stateStore=Za({...So,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1);const s=qs(this.config),o=Nt(this.stateStore).serverKey;o!==null&&o!==s&&(r=!1,this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.pendingLoadFile=null,this.hydratedFile=null),this.socketServerKey=s,this.stateStore.update(B=>r?{...B,connecting:!0,error:null}:{...So,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const a=this.config.secure?"wss":"ws",i=il(this.config.host),u=[];this.config.token&&u.push(`token=${encodeURIComponent(this.config.token)}`),u.push(`clientKey=${encodeURIComponent(this.clientKey)}`);const m=`${a}://${i}:${this.config.port}/ws?${u.join("&")}`,v=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!v){this.stateStore.update(B=>({...B,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}this.socketCapabilities=null,this.socketStartedAt=Date.now();try{const B=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=B?new v(m,B):new v(m)}catch(B){this.stateStore.update(W=>({...W,connecting:!1,error:`Failed to connect: ${B}`})),this.scheduleReconnect();return}const g=this.ws,x=()=>{if(this.ws!==g)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=En.MIN_RECONNECT_DELAY,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(Ke=>({...Ke,connected:!0,connecting:!1,error:null}));const B=Nt(this.stateStore),W=this.resumeSessionFile??B.activeSessionFile,Ne=this.resumeSessionFile!=null?this.resumeCwd:B.activeCwd??void 0,re=this.resumeSessionFile!=null?this.resumeModel:B.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.uploadsHeldForRejoin=!!W,W||this.rejectPendingUploads("The session was closed before the upload could be sent"),W?(this.stateStore.update(Ke=>Ke.resyncing&&!Ke.historyAuthoritative?Ke:{...Ke,resyncing:!0,historyAuthoritative:!1}),this.pendingLoadFile=W,this.send({type:"session_load",sessionFile:W,cwd:Ne,model:re}),this.armLoadWatchdog()):this.stateStore.update(Ke=>Ke.resyncing?{...Ke,resyncing:!1}:Ke)},_=B=>{if(this.ws===g){this.lastInboundAt=Date.now(),this.cancelLivenessProbe();try{const W=typeof B.data=="string"?B.data:B.data.toString(),Ne=JSON.parse(W);this.handleMessage(Ne)}catch(W){console.error("Failed to parse WebSocket message:",W)}}},$=()=>{this.ws===g&&(this.uploadsLostSocket(),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(B=>({...B,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:B.activeSessionFile?!0:B.resyncing})),this.scheduleReconnect())},L=B=>{this.ws===g&&this.stateStore.update(W=>({...W,error:W.error||"Connection error occurred"}))};typeof g.addEventListener=="function"?(g.addEventListener("open",x),g.addEventListener("message",_),g.addEventListener("close",$),g.addEventListener("error",L)):typeof g.on=="function"&&(g.on("open",x),g.on("message",B=>_({data:B})),g.on("close",$),g.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.uploadsLostSocket(),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.rejectPendingUploads("Disconnected before the upload completed"),this.uploadsHeldForRejoin=!1,this.hydratedFile=null,this.stateStore.set({...So,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=Nt(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=Nt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&this.stateStore.update(r=>({...r,resyncing:!0})),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||Nt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now(),this.lastLivenessTickAt=this.lastInboundAt;const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,En.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now(),o=s-this.lastLivenessTickAt;if(this.lastLivenessTickAt=s,o>2*En.HEARTBEAT_MS){this.startLivenessProbe("clock jump");return}const a=s-this.lastInboundAt,i=Nt(this.stateStore).isStreaming,u=i?En.TURN_STALL_MS:En.STALE_SOCKET_MS;a<u||this.startLivenessProbe(`no inbound frame for ${a}ms (threshold ${u}ms, ${i?"mid-turn":"idle"})`)};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,En.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}noteVisible(){this.reconnectDelay=En.MIN_RECONNECT_DELAY;const e=this.ws;if(e){if(e.readyState===0){Date.now()-this.socketStartedAt>En.STALLED_HANDSHAKE_MS&&(console.info("[wherever] handshake stalled; restarting it"),this.reconnectNow());return}e.readyState!==1||!this.livenessTimer||(this.lastInboundAt=Date.now(),this.lastLivenessTickAt=this.lastInboundAt,this.cancelLivenessProbe(),this.startLivenessProbe("page became visible",!0))}}startLivenessProbe(e,r=!1){const s=r?En.VISIBLE_PROBE_GRACE_MS:En.PROBE_GRACE_MS;if(this.probeTimer||!this.ws||typeof setTimeout!="function")return;const o=this.ws;try{this.ping()}catch{}const a=Date.now();this.probeTimer=setTimeout(()=>{if(this.probeTimer=null,this.ws===o){if(Date.now()-a>2*s){this.startLivenessProbe(e);return}this.tearDownStaleSocket(e,s,r)}},s),this.probeTimer&&typeof this.probeTimer.unref=="function"&&this.probeTimer.unref()}cancelLivenessProbe(){this.probeTimer&&(clearTimeout(this.probeTimer),this.probeTimer=null)}tearDownStaleSocket(e,r,s){if(!this.ws)return;const o=Nt(this.stateStore).isStreaming;console.warn(`[wherever] relay connection stale: ${e}; probe unanswered for ${r}ms; tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const a=this.ws;this.ws=null,this.uploadsLostSocket();try{typeof a.terminate=="function"?a.terminate():typeof a.close=="function"&&a.close()}catch{}this.stateStore.update(i=>({...i,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":i.sessionError,isStreaming:!1})),s?this.reconnectNow():this.scheduleReconnect()}stopLivenessWatchdog(){this.cancelLivenessProbe(),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=Nt(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.failHeldUploads("Could not rejoin the session, so the upload was not sent"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},En.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,Nt(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."})))},En.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),this.reconnectNow()},this.reconnectDelay))}reconnectNow(){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),!this.hasEverConnected&&this.reconnectAttempts>=En.HANDSHAKE_FAIL_HINT_AFTER){const r=this.config.secure?"wss":"ws";this.stateStore.update(s=>({...s,error:`Cannot connect to the wherever server: the connection is being rejected. This usually means a missing or wrong token, or a wrong host/port/scheme (currently ${r}://${this.config.host}:${this.config.port}). Check the auth token and connection settings.`}))}const e=!!Nt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":{const r=Nt(this.stateStore).sessionId;if(r&&e.sessionId&&e.sessionId!==r)break;this.clearLoadWatchdog();break}case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,serverVersion:e.serverVersion??null,piVersion:e.piVersion??null,error:null})),this.socketCapabilities=Array.isArray(e.capabilities)?e.capabilities.filter(s=>typeof s=="string"):[],this.resendPendingUploads();break;case"connection_superseded":this.clientKey=Ja();try{this.config.onClientKeyChange?.(this.clientKey)}catch(s){console.error("onClientKeyChange failed:",s)}break;case"file_uploaded":this.completeUpload(e.uploadId,{savedPath:e.savedPath,filename:e.filename});break;case"file_upload_error":this.failUpload(e.uploadId,e.error);break;case"upload_offset":this.handleUploadOffset(e);break;case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":{const s=Array.isArray(e.steering)?[...e.steering]:[];this.stateStore.update(o=>({...o,pendingSteering:s,messages:this.withRestoredQueuedMessages(o.messages,s)}));break}case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(u=>u.role==="thinking"&&u.isStreaming);a&&(o=o.map(u=>u.id===a.id?{...u,isStreaming:!1}:u));const i=[...o].reverse().find(u=>u.role==="assistant"&&u.isStreaming);if(i)o=o.map(u=>u.id===i.id?{...u,content:e.content||u.content,isStreaming:!1}:u);else if(e.content){if(e.role==="user"){if(this.confirmDeliveredByContent(e.content))return Nt(this.stateStore);const x=o.find(_=>_.role==="user"&&_.restoredFromQueue&&_.content===e.content);if(x)return{...s,messages:o.map(_=>_.id===x.id?{..._,restoredFromQueue:void 0}:_)}}const u=e.role==="user"?$s(e.content):null;if(u){const g=[...o].reverse().find(x=>x.role==="user"&&$s(x.content)===u);if(g)return g.content!==e.content&&(o=o.map(x=>x.id===g.id?{...x,content:e.content}:x)),{...s,messages:o}}const m=[...o].reverse().find(g=>g.role==="user");e.role==="user"&&m&&m.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,pendingSteering:[],messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(m=>m.isStreaming&&(m.role==="assistant"||m.role==="thinking")?{...m,isStreaming:!1}:m),a=Date.now(),i=!!e.forceCommand;if(i){const m=o.find(v=>v.role==="tool"&&v.optimistic&&v.isStreaming);if(m)return{...s,messages:o.map(v=>v.id===m.id?{...v,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:v)}}const u={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...i?{forceCommand:!0}:{}};return{...s,messages:[...o,u]}});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
|
-
`)?a.content+e.delta:`${a.content}
|
|
3
|
-
${e.delta}`,toolOutput:`${a.toolOutput}${e.delta}`}:a)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"",o=!!e.isError&&this.isAbortedToolResult(s),a=!!e.isError&&!o,i=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(u=>{const m=u.messages.find(g=>g.role==="tool"&&g.toolName===e.toolName&&g.isStreaming)??[...u.messages].reverse().find(g=>g.role==="tool"&&g.toolName===e.toolName&&!g.content.startsWith("Tool error:")),v=Date.now();if(m){const g=a?"Error: ":"";return{...u,messages:u.messages.map(x=>x.id===m.id?{...x,content:`${g}${x.content}
|
|
4
|
-
${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...i?{images:i}:{},endedAt:v}:x)}}else{const g=a?`Tool error: ${e.toolName}
|
|
5
|
-
${s}`:`${e.toolName}
|
|
6
|
-
${s}`,x={id:this.generateId(),role:"tool",content:g,timestamp:v,isStreaming:!1,toolName:e.toolName,toolArgs:"",toolOutput:s,...i?{images:i}:{},isError:a,interrupted:o,endedAt:v};return{...u,messages:[...u.messages,x]}}});break}case"aborted":{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)}));break}case"session_created":{{const s=Nt(this.stateStore),o=this.pendingLoadFile!==null&&(e.sessionFile===this.pendingLoadFile||e.sessionId===this.pendingLoadFile),a=this.pendingLoadFile===null&&s.creatingSession;if(!o&&!a)break}this.pendingLoadFile=null,this.hydratedFile=null,this.uploadsHeldForRejoin&&(this.uploadsHeldForRejoin=!1,this.failUnsentUploads("The session changed before the upload could be sent",e.sessionId),this.resendPendingUploads()),this.stateStore.update(s=>({...s,session:e.sessionFile,sessionId:e.sessionId,activeSessionFile:e.sessionFile,activeCwd:e.cwd,activeModel:e.model,serverKey:this.socketServerKey,historyAuthoritative:!1,isStreaming:e.isStreaming??!1,creatingSession:!1,readOnly:e.readOnly??!1,folderConflict:e.folderConflict?{cwd:e.cwd,active:!0,continued:!1}:null,folderMissing:e.folderMissing?{cwd:e.cwd}:null,restore:null,agentPending:e.pending===!0,contextUsage:e.contextUsage??null,skills:[]})),e.pending!==!0&&e.sessionId&&this.send({type:"skills_request",sessionId:e.sessionId});break}case"session_ready":this.stateStore.update(s=>e.sessionFile&&s.activeSessionFile&&e.sessionFile!==s.activeSessionFile?s:{...s,agentPending:!1,activeModel:e.model??s.activeModel,isStreaming:e.isStreaming??s.isStreaming,contextUsage:e.contextUsage??s.contextUsage});{const s=Nt(this.stateStore).sessionId;s&&this.send({type:"skills_request",sessionId:s})}break;case"session_reloading":this.stateStore.update(s=>s.sessionId&&e.sessionId&&s.sessionId!==e.sessionId?s:{...s,agentPending:!0});break;case"skills_list":this.stateStore.update(s=>s.sessionId&&e.sessionId&&s.sessionId!==e.sessionId?s:{...s,skills:Array.isArray(e.skills)?e.skills:[]});break;case"context_usage":this.stateStore.update(s=>({...s,contextUsage:e.contextUsage??null}));break;case"session_notice":this.stateStore.update(s=>s.sessionId&&e.sessionId&&s.sessionId!==e.sessionId?s:{...s,notice:{level:e.level,message:e.message}});break;case"bash_sudo_prompt":this.stateStore.update(s=>s.sessionId&&e.sessionId&&s.sessionId!==e.sessionId?s:{...s,sudoPrompt:{promptId:e.promptId,command:e.command,sessionId:e.sessionId}});break;case"session_destroyed":Nt(this.stateStore).sessionId===e.sessionId&&this.failHeldUploads("The session ended before the upload could be sent"),this.stateStore.update(s=>s.sessionId===e.sessionId?{...s,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,loadingSession:!1,agentPending:!1,folderMissing:null,restore:null,notice:null,sudoPrompt:null}:s);break;case"session_error":{e.sessionId||this.failHeldUploads("Could not rejoin the session, so the upload was not sent");const s=!e.sessionId&&this.hydratedFile!==null&&this.pendingLoadFile===this.hydratedFile;this.stateStore.update(o=>({...o,sessionError:e.error,isStreaming:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1})),s&&this.rejectHydration();break}case"folder_missing":this.stateStore.update(s=>s.sessionId&&e.sessionId&&s.sessionId!==e.sessionId?s:{...s,readOnly:!0,folderMissing:{cwd:e.cwd},restore:{targetPath:e.cwd,job:e.job??null,joined:!1,rejection:null}});break;case"restore_started":{const s=Nt(this.stateStore);if(s.creatingSession&&!s.restore){this.clearCreateWatchdog(),this.stateStore.update(o=>({...o,creatingSession:!1,restore:{targetPath:e.targetPath,job:e.job,joined:e.outcome==="joined",rejection:null,forSessionCreate:!0}}));break}this.stateStore.update(o=>this.withRestore(o,e.targetPath,a=>({...a,job:e.job,joined:e.outcome==="joined",rejection:null})));break}case"restore_rejected":this.stateStore.update(s=>this.withRestore(s,e.targetPath,o=>({...o,rejection:{reason:e.reason,message:e.message}})));break;case"restore_progress":case"restore_complete":{const s=Nt(this.stateStore).restore;if(e.type==="restore_complete"&&s?.forSessionCreate&&s.targetPath===e.targetPath){const o=e.job.state==="done";this.stateStore.update(a=>({...a,restore:null,creatingSession:o})),o&&this.armCreateWatchdog();break}this.stateStore.update(o=>this.withRestore(o,e.targetPath,a=>({...a,job:e.job,rejection:null})));break}case"folder_conflict":this.stateStore.update(s=>{if(!s.sessionId||s.activeCwd&&e.cwd!==s.activeCwd)return s;const o=e.readOnly??s.readOnly;return e.active?s.folderConflict?{...s,readOnly:o,folderConflict:{...s.folderConflict,cwd:e.cwd,active:!0}}:{...s,readOnly:o,folderConflict:{cwd:e.cwd,active:!0,continued:!0}}:s.folderConflict||o!==s.readOnly?{...s,folderConflict:null,readOnly:o}:s});break;case"session_interrupted":this.stateStore.update(s=>({...s,isInterrupted:!0,readOnly:!0,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,creatingSession:!1,loadingSession:!1,agentPending:!1,notice:null,sudoPrompt:null}));break;case"message_history":{{const u=Nt(this.stateStore).sessionId;if(u&&e.sessionId&&e.sessionId!==u)break}const s=e.sessionId,o=Nt(this.stateStore).messages.filter(u=>u.role==="user"&&u.delivery!==void 0),i=[...this.loadPersistedPending(s),...o];this.stateStore.update(u=>{const m=this.mapHistory(e.messages,e.sessionId,u.isStreaming),v=typeof e.totalCount=="number"?e.totalCount:m.length,g=typeof e.offset=="number"?e.offset:0,x=new Set(m.filter(L=>L.role==="user").map(L=>L.content)),_=new Set,$=[];for(const L of i)x.has(L.content)||_.has(L.content)||(_.add(L.content),$.push({...L,sessionId:s,delivery:"failed"}));return{...u,messages:[...m,...$],historyTotalCount:v,historyOffset:g,historyAuthoritative:!0,loadingMoreHistory:!1,loadingSession:!1,resyncing:!1}});for(const u of i)this.clearConfirm(u.id);this.persistPending(s);break}case"message_history_prepend":this.stateStore.update(s=>{const o=this.mapHistory(e.messages,e.sessionId,!1),a=typeof e.offset=="number"?e.offset:0;return o.length===0?{...s,loadingMoreHistory:!1,historyOffset:a}:{...s,messages:[...o,...s.messages],historyOffset:a,loadingMoreHistory:!1}});break;case"model_changed":this.stateStore.update(s=>({...s,activeModel:e.model}));break}}isAbortedToolResult(e){if(!e)return!1;const r=e.trimEnd().split(`
|
|
7
|
-
`),s=(r[r.length-1]||"").trim();return/^(command|operation)?\s*aborted$/i.test(s)}mapHistory(e,r,s){const o=[],a={},i={},u=(g,x)=>{const _=a[g];if(!_)return;const $=_.indexOf(x);$!==-1&&_.splice($,1)};for(const g of e)if(g.role==="tool_call"){const x=g.toolName||"unknown",_=g.content||"",$=o.length;o.push({id:this.generateId(),role:"tool",content:_?`$ ${x} ${_}`:`$ ${x}`,timestamp:g.timestamp,isStreaming:!1,toolName:x,toolArgs:_,toolOutput:"",sessionId:r,...Number.isFinite(g.timestamp)?{startedAt:g.timestamp}:{},...g.forceCommand?{forceCommand:!0}:{}}),a[x]||(a[x]=[]),a[x].push($),typeof g.toolCallId=="string"&&g.toolCallId&&(i[g.toolCallId]=$)}else if(g.role==="tool_result"){const x=g.toolName||"unknown";let _;if(typeof g.toolCallId=="string"&&g.toolCallId&&i[g.toolCallId]!==void 0)_=i[g.toolCallId],delete i[g.toolCallId],u(x,_);else if(a[x]&&a[x].length>0){_=a[x].shift();for(const[B,W]of Object.entries(i))W===_&&delete i[B]}const $=g.isError&&!this.isAbortedToolResult(g.content),L=!!g.isError&&this.isAbortedToolResult(g.content);if(_!==void 0){const B=o[_],W=B.toolArgs||"",Ne=B.startedAt;o[_]={...B,content:W?`$ ${x} ${W}
|
|
8
|
-
${g.content}`:`$ ${x}
|
|
9
|
-
${g.content}`,isStreaming:!1,toolOutput:g.content,...Array.isArray(g.images)&&g.images.length>0?{images:g.images}:{},isError:$,interrupted:L,timestamp:g.timestamp,...Ne!==void 0&&Number.isFinite(Ne)&&Number.isFinite(g.timestamp)&&g.timestamp>=Ne?{endedAt:g.timestamp}:{}}}else o.push({id:this.generateId(),role:"tool",content:`$ ${x}
|
|
10
|
-
${g.content}`,timestamp:g.timestamp,isStreaming:!1,toolName:x,toolArgs:"",toolOutput:g.content,...Array.isArray(g.images)&&g.images.length>0?{images:g.images}:{},isError:$,interrupted:L,sessionId:r})}else o.push({id:this.generateId(),role:g.role,content:g.content,timestamp:g.timestamp,isStreaming:!1,toolName:g.toolName,sessionId:r,...typeof g.entryId=="string"&&g.entryId?{entryId:g.entryId}:{}});const m=[];for(const g of Object.values(a))m.push(...g);m.sort((g,x)=>g-x);const v=s&&m.length>0?m[m.length-1]:-1;for(const g of m)g===v?o[g]={...o[g],isStreaming:!0}:o[g]={...o[g],interrupted:!0};if(s&&o.length>0){const g=o.length-1,x=o[g];(x.role==="assistant"||x.role==="thinking")&&(o[g]={...x,isStreaming:!0})}return o}loadMoreHistory(){const e=Nt(this.stateStore);e.sessionId&&e.historyAuthoritative&&(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}messageFrame(e,r,s){return{type:"message",message:e,sessionId:r,...s?.conversationMode?{conversationMode:!0}:{}}}sendMessage(e,r){const s=Nt(this.stateStore);if(!s.sessionId)return!1;if(s.agentPending)return this.stateStore.update(i=>({...i,sessionError:i.sessionError??"Preparing the session agent; please wait a moment, then resend."})),!1;if(!this.getIsConnected())return this.stateStore.update(i=>({...i,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(this.messageFrame(e,s.sessionId,r)))return this.stateStore.update(i=>({...i,sessionError:"Message failed to send (connection dropped). Please resend once reconnected."})),!1;if(e.trimStart().startsWith("!")){const i=e.trimStart(),m=(i.startsWith("!!")?i.slice(2):i.slice(1)).trim(),v=/^sudo(\s|$)/.test(m);if(m&&!v){const g=`command=${JSON.stringify(m)}`,x=Date.now(),_={id:this.generateId(),role:"tool",content:`$ bash ${g}`,timestamp:x,isStreaming:!0,toolName:"bash",toolArgs:g,toolOutput:"",startedAt:x,forceCommand:!0,optimistic:!0};return this.stateStore.update($=>({...$,sessionError:null,messages:[...$.messages,_]})),!0}return this.stateStore.update(g=>({...g,sessionError:null})),!0}const a={id:this.generateId(),role:"user",content:e,timestamp:Date.now(),isStreaming:!1,sessionId:s.sessionId,delivery:"sending"};return this.stateStore.update(i=>({...i,sessionError:null,messages:[...i.messages,a]})),this.armConfirm(a.id),this.persistPending(s.sessionId),!0}withRestoredQueuedMessages(e,r){if(r.length===0)return e;const s=new Map;for(const a of e)a.role==="user"&&s.set(a.content,(s.get(a.content)??0)+1);const o=[];for(const a of r){const i=s.get(a)??0;if(i>0){s.set(a,i-1);continue}o.push({id:this.generateId(),role:"user",content:a,timestamp:Date.now(),isStreaming:!1,restoredFromQueue:!0})}return o.length>0?[...e,...o]:e}pendingKey(e){return En.PENDING_PREFIX+e}persistPending(e){if(!e||typeof localStorage>"u")return;const r=Nt(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(i=>i.id===e);return!a||a.delivery!=="sending"?o:(s=o.sessionId,{...o,messages:o.messages.map(i=>i.id===e?{...i,delivery:"failed"}:i)})}),s&&this.persistPending(s)},En.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;const o=$s(e);return this.stateStore.update(a=>{let i=a.messages.find(u=>u.role==="user"&&u.delivery!==void 0&&u.content===e);return!i&&o&&(i=a.messages.find(u=>u.role==="user"&&u.delivery!==void 0&&$s(u.content)===o)),i?(r=i.id,s=a.sessionId,{...a,messages:a.messages.map(u=>u.id===i.id?{...u,delivery:void 0,...o?{content:e}:{}}:u)}):a}),r?(this.clearConfirm(r),this.persistPending(s),!0):!1}resendMessage(e,r){const s=Nt(this.stateStore),o=s.messages.find(i=>i.id===e&&i.role==="user");return!o||!s.sessionId?!1:this.getIsConnected()?this.send(this.messageFrame(o.content,s.sessionId,r))?(this.stateStore.update(i=>({...i,sessionError:null,messages:i.messages.map(u=>u.id===e?{...u,delivery:"sending",timestamp:Date.now()}:u)})),this.armConfirm(e),this.persistPending(s.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=Nt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}reloadResources(){const e=Nt(this.stateStore);e.sessionId&&this.send({type:"session_reload",sessionId:e.sessionId})}cancelSteer(){const e=Nt(this.stateStore);e.sessionId&&(this.send({type:"cancel_steer",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,pendingSteering:[]})))}withRestore(e,r,s){const o=e.restore;return!o||o.targetPath!==r?e:{...e,restore:s(o)}}hydrateCachedSession(e){const r=Nt(this.stateStore);if(r.activeSessionFile||this.pendingLoadFile!==null||r.connected)return;const s=e.messages.filter(o=>!(o.role==="user"&&o.delivery!==void 0));this.hydratedFile=e.sessionFile,this.stateStore.update(o=>({...o,session:e.sessionFile,sessionId:e.sessionId,activeSessionFile:e.sessionFile,activeCwd:e.cwd,activeModel:e.model,messages:s,historyTotalCount:e.historyTotalCount??s.length,historyOffset:e.historyOffset??0,historyAuthoritative:!1,resyncing:!0,isStreaming:!1,serverKey:e.serverKey??qs(this.config)}))}rejectHydration(){const e=Nt(this.stateStore).sessionId;if(this.hydratedFile=null,this.pendingLoadFile=null,this.stateStore.update(s=>({...s,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,historyTotalCount:0,historyOffset:0,historyAuthoritative:!1,serverKey:null,resyncing:!1})),!e)return;const r={type:"hydration_rejected",sessionId:e};for(const s of this.listeners)try{s(r)}catch(o){console.error("Error in message listener:",o)}}joinSession(e,r,s){this.stateStore.update(o=>({...o,folderConflict:null,folderMissing:null,restore:null,sessionError:null,loadingSession:!0,agentPending:!1})),this.pendingLoadFile=e,this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog()}switchSession(e,r,s){const o=Nt(this.stateStore);o.activeSessionFile===e&&!o.loadingSession&&!o.resyncing||(this.abandonUnsentUploads(),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,folderConflict:null,folderMissing:null,restore:null,sessionError:null,notice:null,sudoPrompt:null,creatingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null,pendingSteering:[],loadingSession:!0})),this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.hydratedFile=null,this.clearCreateWatchdog(),this.pendingLoadFile=e,this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog())}forkSession(e,r){return!e||!r?!1:this.send({type:"session_fork",sessionId:e,entryId:r})}createSession(e,r,s,o,a,i){this.abandonUnsentUploads(),this.stateStore.update(u=>({...u,folderConflict:null,folderMissing:null,restore:null,sessionError:null,creatingSession:!0,loadingSession:!1})),this.pendingLoadFile=null,this.hydratedFile=null,this.send({type:"session_new",cwd:e,model:r,gitInit:s,createRemote:o,repoVisibility:a,cloneRemote:i}),this.armCreateWatchdog()}leaveSession(){this.abandonUnsentUploads();const e=Nt(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,folderMissing:null,restore:null,notice:null,sudoPrompt:null,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null,pendingSteering:[]})),this.clearLoadWatchdog(),this.pendingLoadFile=null,this.hydratedFile=null,this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0}startRestore(e,r,s){const o=Nt(this.stateStore),a=o.restore?.targetPath??o.folderMissing?.cwd;if(!a)return!1;const i=r?.trim();return e==="clone"&&!i?!1:(this.stateStore.update(u=>{const m=u.restore?.targetPath===a?u.restore.job:null;return{...u,restore:{targetPath:a,job:m&&m.state==="running"?m:null,joined:!1,requestedUrl:i,rejection:null}}}),this.send({type:"restore_start",targetPath:a,action:e,...i?{url:i}:{},...s!==void 0?{gitInit:s}:{}}))}cancelRestore(){const r=Nt(this.stateStore).restore?.targetPath;return r?this.send({type:"restore_cancel",targetPath:r}):!1}reloadSession(){const e=Nt(this.stateStore),r=e.activeSessionFile;return r?(this.joinSession(r,e.activeCwd??void 0),!0):!1}continueFolderConflict(){const e=Nt(this.stateStore);!e.folderConflict||!e.sessionId||e.folderMissing||(this.send({type:"folder_conflict_continue",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,readOnly:!1,folderConflict:r.folderConflict?{...r.folderConflict,continued:!0}:null})))}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=Nt(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=Nt(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,o){return new Promise((a,i)=>{const u=o?.signal;if(u?.aborted){o?.onProgress?.({acked:0,size:s.size,state:"aborted"}),i(new Error("Upload cancelled"));return}const m=zd(),v={uploadId:m,sessionId:e,filename:r,mime:o?.mime||void 0,source:s,onProgress:o?.onProgress,resolve:a,reject:i,timer:null,sentOn:null,protocol:null,state:"queued",acked:0,frame:null,preparing:!1,sends:0,begun:!1,awaitingBegin:!1,nextOffset:0,inFlight:[],realigning:!1,finishing:!1,reading:!1,readGen:0,rate:null,lastAckAt:0};this.pendingUploads.set(m,v),this.reportUpload(v),u?.addEventListener("abort",()=>this.abortUpload(m),{once:!0}),this.trySendUpload(m)||this.ensureUploadTimer(m)})}pendingUploadCount(){return this.pendingUploads.size}forgetUpload(e){this.pendingUploads.has(e)||this.uploadsStore.update(r=>{if(!(e in r))return r;const s={...r};return delete s[e],s})}trySendUpload(e){const r=this.pendingUploads.get(e);if(!r||this.uploadsHeldForRejoin||!this.ws||this.ws.readyState!==1||this.socketCapabilities===null)return!1;const s=this.socketCapabilities.includes(Pd);return r.protocol===null&&(r.protocol=s?"chunked":"legacy"),r.protocol==="chunked"?s?this.beginChunkedUpload(r):(this.failUpload(e,"The server no longer supports resumable uploads, retry"),!0):this.sendLegacyUpload(r)}sendLegacyUpload(e){return e.sends>=En.MAX_UPLOAD_SENDS?(this.failUpload(e.uploadId,"Upload failed: the connection dropped during the transfer each time (the file may be too large or the connection too slow)"),!0):e.frame?this.send(e.frame)?(e.sends++,e.sentOn=this.ws,this.stopUploadTimer(e),this.reportUpload(e,"sending"),!0):!1:e.source.size>En.MAX_LEGACY_UPLOAD_BYTES?(this.failUpload(e.uploadId,"File too large to upload over the WebSocket (max 72 MB)"),!0):(e.preparing||(e.preparing=!0,this.prepareLegacyFrame(e)),!1)}prepareLegacyFrame(e){this.readLegacyBase64(e.source).then(r=>{this.pendingUploads.get(e.uploadId)===e&&(e.preparing=!1,e.frame={type:"file_upload",uploadId:e.uploadId,sessionId:e.sessionId,filename:e.filename,data:r},this.trySendUpload(e.uploadId)||this.ensureUploadTimer(e.uploadId))},r=>{if(this.pendingUploads.get(e.uploadId)!==e)return;const s=r instanceof ts?r:ko(r);this.failUpload(e.uploadId,s.message,s.code)})}async readLegacyBase64(e){const r=[];let s=0;for(let o=0;o<e.size;o+=ti){const a=Math.min(ti,e.size-o);let i;try{i=await e.read(o,a)}catch(u){throw ko(u)}if(s+=4*Math.ceil(i.length/3),s>En.MAX_UPLOAD_BASE64_CHARS)throw new ts("File too large to upload over the WebSocket (max 72 MB)");if(i.length!==a)throw ni();r.push(btoa(al(i)))}return r.join("")}beginChunkedUpload(e){return this.send({type:"upload_begin",uploadId:e.uploadId,sessionId:e.sessionId,filename:e.filename,size:e.source.size,...e.mime?{mime:e.mime}:{}})?(e.begun=!0,e.sentOn=this.ws,e.awaitingBegin=!0,e.inFlight=[],e.realigning=!1,e.finishing=!1,e.readGen++,this.stopUploadTimer(e),this.reportUpload(e,"sending"),!0):!1}handleUploadOffset(e){const r=this.pendingUploads.get(e.uploadId);if(!r||r.protocol!=="chunked"||!this.isUploadOnWire(r))return;if(e.done){this.completeUpload(r.uploadId,{savedPath:e.savedPath,filename:r.filename});return}const s=e.offset,o=r.source.size;if(!Number.isSafeInteger(s)||s<0||s>o)return;const a=Date.now();if(r.awaitingBegin)r.awaitingBegin=!1,r.nextOffset=s,r.lastAckAt=a;else{const i=r.inFlight.shift();if(!i)return;if(!r.realigning&&s===i.offset+i.length){const u=Math.max(1,a-Math.max(i.sentAt,r.lastAckAt)),m=i.length/u;r.rate=r.rate===null?m:r.rate*(1-ei)+m*ei,r.lastAckAt=a}else r.realigning||(r.realigning=!0,r.readGen++);r.realigning&&r.inFlight.length===0&&(r.realigning=!1,r.nextOffset=s,r.lastAckAt=a)}r.acked=s,this.reportUpload(r),this.pumpUpload(r)}uploadWindow(e){if(e.rate===null)return Qa;const r=e.rate*1e3*Fd;return Math.min(Nd,Math.max(Qa,Math.floor(r)))}pumpUpload(e){if(this.pendingUploads.get(e.uploadId)!==e||e.reading||e.awaitingBegin||e.realigning||e.finishing||!this.isUploadOnWire(e))return;const r=e.source.size;if(e.acked===r&&e.inFlight.length===0){if(!this.send({type:"upload_finish",uploadId:e.uploadId,sessionId:e.sessionId}))return;e.finishing=!0,this.reportUpload(e,"finishing");return}if(e.nextOffset>=r)return;const s=this.uploadWindow(e),o=Math.min(s,Ud,r-e.nextOffset);if(e.inFlight.reduce((v,g)=>v+g.length,0)+o>s)return;const i=e.nextOffset,u=e.readGen,m=this.ws;e.reading=!0,Promise.resolve().then(()=>e.source.read(i,o)).then(v=>{if(this.pendingUploads.get(e.uploadId)===e){if(e.reading=!1,u!==e.readGen||m!==this.ws||!this.isUploadOnWire(e)){this.pumpUpload(e);return}if(v.length!==o){const g=ni();this.failUpload(e.uploadId,g.message,g.code);return}this.sendBinary(Bd(e.uploadId,i,v))&&(e.inFlight.push({offset:i,length:o,sentAt:Date.now()}),e.nextOffset=i+o,this.pumpUpload(e))}},v=>{if(this.pendingUploads.get(e.uploadId)!==e)return;const g=ko(v);this.failUpload(e.uploadId,g.message,g.code)})}sendBinary(e){if(this.ws&&this.ws.readyState===1)try{return this.ws.send(e),!0}catch{return!1}return!1}reportUpload(e,r,s){r&&(e.state=r);const o={acked:e.acked,size:e.source.size,state:e.state,...s?{error:s}:{}};if(this.uploadsStore.update(a=>({...a,[e.uploadId]:o})),e.onProgress)try{e.onProgress({...o})}catch(a){console.error("Upload onProgress failed:",a)}}completeUpload(e,r){const s=this.takePendingUpload(e);s&&(s.acked=s.source.size,this.reportUpload(s,"done"),s.resolve(r))}failUpload(e,r,s){const o=this.takePendingUpload(e);if(!o)return;const a=new Error(r);s&&(a.code=s),this.reportUpload(o,"failed",s?{message:r,code:s}:{message:r}),o.reject(a)}abortUpload(e){const r=this.takePendingUpload(e);r&&(r.protocol==="chunked"&&r.begun&&this.send({type:"upload_abort",uploadId:e,sessionId:r.sessionId}),this.reportUpload(r,"aborted"),r.reject(new Error("Upload cancelled")))}isUploadOnWire(e){return e.sentOn!==null&&e.sentOn===this.ws}uploadsLostSocket(){for(const[e,r]of this.pendingUploads){const s=r.sentOn!==null;r.sentOn=null,r.protocol==="chunked"&&(r.awaitingBegin=!1,r.inFlight=[],r.realigning=!1,r.finishing=!1,r.readGen++),s&&r.state!=="paused"&&this.reportUpload(r,"paused"),this.ensureUploadTimer(e)}}failUnsentUploads(e,r){for(const[s,o]of[...this.pendingUploads])this.isUploadOnWire(o)||r&&o.sessionId===r||this.failUpload(s,e)}failHeldUploads(e){this.uploadsHeldForRejoin&&(this.uploadsHeldForRejoin=!1,this.failUnsentUploads(e))}abandonUnsentUploads(){this.uploadsHeldForRejoin=!1,this.failUnsentUploads("The session changed before the upload could be sent")}ensureUploadTimer(e){const r=this.pendingUploads.get(e);r&&!r.timer&&this.armUploadTimer(e)}stopUploadTimer(e){e.timer&&clearTimeout(e.timer),e.timer=null}armUploadTimer(e){const r=this.pendingUploads.get(e);!r||typeof setTimeout!="function"||(r.timer&&clearTimeout(r.timer),r.timer=setTimeout(()=>{this.failUpload(e,"Upload timed out (no connection to the server)")},En.UPLOAD_TIMEOUT_MS),r.timer&&typeof r.timer.unref=="function"&&r.timer.unref())}takePendingUpload(e){const r=this.pendingUploads.get(e);if(r)return this.pendingUploads.delete(e),r.timer&&clearTimeout(r.timer),r}resendPendingUploads(){for(const[e,r]of[...this.pendingUploads])this.isUploadOnWire(r)||this.trySendUpload(e)||this.ensureUploadTimer(e)}rejectPendingUploads(e){for(const r of[...this.pendingUploads.keys()])this.failUpload(r,e)}generateId(){return Math.random().toString(36).substring(2)+Date.now().toString(36)}getIsConnected(){return this.ws&&this.ws.readyState===1}}const jd=["speakReplies","collapseLongReplies","micReopensAfterReply"];function Gd(n){return jd.includes(n)}function es(n,e){return Gd(n)?e.conversationMode&&e[n]:e[n]}function Wd(n){return es("speakReplies",n)}function Kd(n,e){return n===void 0?e:n}function ll(n,e){const r=n.trim();if(e.length===0)return r;const s=e.map(o=>`[Uploaded file: ${o}]`).join(`
|
|
11
|
-
`);return r?`${r}
|
|
12
|
-
|
|
13
|
-
${s}`:`I have uploaded the following file(s) for you:
|
|
14
|
-
${s}`}const qd="The file is no longer readable, pick it again";function ri(){return Object.assign(new Error("Upload cancelled"),{name:"AbortError"})}function Vd(n){const{size:e,signal:r}=n;let s=0;const o=(a,i)=>n.onProgress?.({acked:s,size:e,state:a,...i?{error:i}:{}});return new Promise((a,i)=>{if(r?.aborted){o("aborted"),i(ri());return}const u=(n.createXhr??(()=>new XMLHttpRequest))();let m=!1;const v=()=>u.abort(),g=()=>{m=!0,r?.removeEventListener("abort",v)},x=(_,$)=>{if(m)return;g(),o("failed",$?{message:_,code:$}:{message:_}),i(Object.assign(new Error(_),$?{code:$}:{}))};u.upload.onprogress=_=>{m||(s=Math.max(0,Math.min(e,_.loaded)),o("sending"))},u.onload=()=>{if(m)return;let _;try{_=JSON.parse(u.responseText)}catch{_=void 0}if(u.status<200||u.status>=300){x(_&&typeof _.error=="string"&&_.error||`Upload failed with status ${u.status}`);return}if(!_||typeof _.savedPath!="string"){x("Upload failed: the server sent an unreadable reply");return}g(),s=e,o("done"),a(_)},u.onerror=()=>{if(m)return;(n.probeReadable??(async()=>!0))().catch(()=>!1).then($=>$?x("Upload failed (network error)"):x(qd,"not_readable"))},u.ontimeout=()=>x("Upload timed out"),u.onabort=()=>{m||(g(),o("aborted"),i(ri()))},r?.addEventListener("abort",v),u.open("POST",n.url),u.setRequestHeader("Content-Type","text/plain"),o("sending"),u.send(n.body)})}async function Yd(n){try{return await n.slice(0,1).arrayBuffer(),!0}catch{return!1}}const si="wherever-drafts-cache",To="wherever-drafts";function Xd(n){return[...n].sort((e,r)=>r.updatedAt-e.updatedAt||e.id.localeCompare(r.id))}function oi(n){if(!n)return[];try{return cl(JSON.parse(n))}catch{return[]}}function cl(n){if(!Array.isArray(n))return[];const e=[];for(const r of n){if(!r||typeof r!="object")continue;const s=r;if(typeof s.id!="string"||s.id.length===0||typeof s.text!="string")continue;const o=s.text.trim();if(o.length===0)continue;const a=typeof s.createdAt=="number"?s.createdAt:0,i=typeof s.updatedAt=="number"?s.updatedAt:a;e.push({id:s.id,text:o,createdAt:a,updatedAt:i,...typeof s.sessionId=="string"?{sessionId:s.sessionId}:{},...typeof s.cwd=="string"?{cwd:s.cwd}:{}})}return Xd(e)}function Zd(n){return JSON.stringify(n)}function Jd(n){return n.trim().length>0?"confirm":"load"}function Qd(n,e,r){if(r==="replace")return e;const s=n.replace(/\s+$/,"");return s.length===0?e:`${s}
|
|
15
|
-
|
|
16
|
-
${e}`}function eu(n,e){if(!n)return null;const r=e.trim();if(r.length===0)return null;const s=n.text.trim();return s.length===0?null:r===s||r.endsWith(`
|
|
17
|
-
|
|
18
|
-
${s}`)?n.id:null}function tu(n,e=140){const r=n.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1).trimEnd()}…`}function ai(n){if(!n.cwd)return null;const e=n.cwd.split("/").filter(Boolean);return e.length>0?e[e.length-1]:n.cwd}const nu="wherever-conversation-cache",Ao="conversations",ii="savedAt",ru=1,su=5,ou=2*1024*1024,au=5e3;function iu(n){const e=[];for(const r of n){if(r.delivery!==void 0)continue;const{images:s,...o}=r;e.push({...o,isStreaming:!1})}return e}function li(n){let e=0;for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);s<128?e+=1:s<2048?e+=2:s>=55296&&s<=56319&&r+1<n.length?(e+=4,r++):e+=3}return e}function lu(n,e){let r=li(JSON.stringify({...n,messages:[]}));const s=n.messages.map(a=>li(JSON.stringify(a)));for(let a=0;a<s.length;a++)r+=s[a]+(a>0?1:0);let o=0;for(;r>e&&o<s.length;)r-=s[o]+(o<s.length-1?1:0),o++;return o===0?n:{...n,messages:n.messages.slice(o)}}function Yr(n){return new Promise((e,r)=>{n.onsuccess=()=>e(n.result),n.onerror=()=>r(n.error)})}function cu(n){return new Promise((e,r)=>{n.oncomplete=()=>e(),n.onerror=()=>r(n.error),n.onabort=()=>r(n.error)})}function du(n={}){const e=n.indexedDB!==void 0?n.indexedDB:globalThis.indexedDB??null,r=n.now??Date.now,s=n.maxSessions??su,o=n.maxRecordBytes??ou;let a=null;function i(){return a||(a=new Promise(v=>{if(!e)return v(null);let g;try{g=e.open(nu,ru)}catch{return v(null)}g.onupgradeneeded=()=>{g.result.createObjectStore(Ao,{keyPath:["serverKey","sessionId"]}).createIndex(ii,"savedAt")},g.onsuccess=()=>{const x=g.result;x.onversionchange=()=>x.close(),v(x)},g.onerror=()=>v(null),g.onblocked=()=>v(null)}),a)}async function u(v,g,x){try{const _=await i();if(!_)return g;const $=_.transaction(Ao,v),L=cu($),B=await x($.objectStore(Ao));return await L,B}catch{return g}}function m(v,g){return new Promise((x,_)=>{const $=v.openKeyCursor();$.onerror=()=>_($.error),$.onsuccess=()=>{const L=$.result;if(!L)return x();g(L.primaryKey)&&v.delete(L.primaryKey),L.continue()}})}return{get(v,g){return u("readonly",null,async x=>await Yr(x.get([v,g]))??null)},put(v){return u("readwrite",void 0,async g=>{const x=[v.serverKey,v.sessionId],_=lu({...v,messages:iu(v.messages),savedAt:r()},o);if(_.messages.length===0){await Yr(g.delete(x));return}await Yr(g.put(_));const $=await Yr(g.index(ii).getAllKeys());for(const L of $.slice(0,Math.max(0,$.length-s)))g.delete(L)})},remove(v,g){return u("readwrite",void 0,async x=>{await Yr(x.delete([v,g]))})},retainOnly(v){return u("readwrite",void 0,g=>m(g,x=>x[0]!==v))},clear(){return u("readwrite",void 0,async v=>{await Yr(v.clear())})}}}function uu(n,e={}){const r=e.intervalMs??au;let s=null;function o(){try{const i=n();i&&typeof i.catch=="function"&&i.catch(()=>{})}catch{}}function a(){s!==null&&clearTimeout(s),s=null}return{schedule(){s===null&&(s=setTimeout(()=>{s=null,o()},r))},flush(){a(),o()},cancel:a}}const fu=300;function pu(n){return!n.serverKey||!n.sessionId||!n.activeSessionFile||!n.historyAuthoritative||n.messages.length===0?null:{serverKey:n.serverKey,sessionId:n.sessionId,sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,messages:n.messages,historyTotalCount:n.historyTotalCount,historyOffset:n.historyOffset}}function hu(n){return n.historyAuthoritative&&n.historyOffset>0}function ci(n){return n.booting||n.connected?"none":n.hasActiveSession?"resume":"connect"}function bu(n){if(!n.hashId)return Promise.resolve(null);const e=n.timeoutMs??fu;return new Promise(r=>{const s=setTimeout(()=>r(null),e),o=i=>{clearTimeout(s),r(i)};let a;try{a=n.cache.get(n.serverKey,n.hashId)}catch{return o(null)}a.then(i=>o(i&&i.sessionId===n.hashId&&i.serverKey===n.serverKey?i:null),()=>o(null))})}async function vu(n){let e=!1;try{const r=await n.cached;r&&(e=n.hydrate(r))}catch{e=!1}return n.connect({preserveState:e}),e?"hydrated":"plain"}function gu(n,e){return n.retainOnly(e)}function mu(n,e){return e?.cancel(),n.clear()}function xu(n){const e=n.win;if(e&&e.location.hash){let r="";try{r=decodeURIComponent(e.location.hash.slice(1))}catch{r=e.location.hash.slice(1)}r===n.sessionId&&e.history.replaceState(e.history.state,"",e.location.pathname+e.location.search)}n.serverKey&&n.cache.remove(n.serverKey,n.sessionId)}function _u(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n)}catch{}return null}function $r(n){localStorage.setItem("wherever-config",JSON.stringify(n))}function Os(){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 Un(){dd();const n=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",e=_u();return e?(e.port===void 0&&(e.port=Os()),(e.port===31415||e.port===void 0)&&Os()!==31415&&(e.port=Os()),(!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:"",conversationMode:!1,speakReplies:!1,collapseLongReplies:!1,micReopensAfterReply:!1,...e})):{host:n,port:Os(),token:"",hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:"",conversationMode:!1,speakReplies:!1,collapseLongReplies:!1,micReopensAfterReply:!1}}const no=vr(!!Un().beepDefault),dl="wherever-beep-overrides";function yu(){try{const n=localStorage.getItem(dl);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function wu(n){try{localStorage.setItem(dl,JSON.stringify(n))}catch{}}const ul=vr(typeof localStorage<"u"?yu():{}),ca=vr("");function ku(){return Nn(no)}function fl(){const n=Un().beepSoundUrl;return typeof n=="string"?n:""}function Su(n){const e=Un();$r({...e,beepSoundUrl:n})}const da=vn([ca,ul],([n,e])=>n&&n in e?e[n]:void 0),ua=vn([da,no],([n,e])=>n===void 0?e:n);function Tu(n){const e=Un();$r({...e,beepDefault:n}),no.set(n)}function zs(n){const e=Nn(ca);e&&ul.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,wu(s),s})}function pl(n){ca.set(n??"")}const hl="wherever-speech-direct-send";function bl(){try{return localStorage.getItem(hl)==="true"}catch{}return!1}const fa=vr(typeof localStorage<"u"?bl():!1);function vl(){return bl()}function gl(n){try{localStorage.setItem(hl,String(n))}catch{}fa.set(n)}const Ss=vr(!!Un().conversationMode),ml="wherever-conversation-mode-overrides";function Au(){try{const n=localStorage.getItem(ml);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function Cu(n){try{localStorage.setItem(ml,JSON.stringify(n))}catch{}}const xl=vr(typeof localStorage<"u"?Au():{}),ro=vr(""),pa=vn([ro,xl],([n,e])=>n&&n in e?e[n]:void 0),Eu={subscribe:Ss.subscribe},so=vr(!!Un().speakReplies),oo=vr(!!Un().collapseLongReplies),ao=vr(!!Un().micReopensAfterReply),ha=vn([pa,Ss],([n,e])=>Kd(n,e)),_l={subscribe:so.subscribe},yl={subscribe:oo.subscribe},Ru={subscribe:ao.subscribe};function wl(){return Nn(ha)}function Iu(){return Nn(Ss)}function kl(n){const e=Un();$r({...e,conversationMode:n}),Ss.set(n)}function Sl(n){const e=Nn(ro);e&&xl.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,Cu(s),s})}function Tl(n){ro.set(n??"")}function Mu(n){const e=Un();$r({...e,speakReplies:n}),so.set(n)}function $u(n){const e=Un();$r({...e,collapseLongReplies:n}),oo.set(n)}function Ou(n){const e=Un();$r({...e,micReopensAfterReply:n}),ao.set(n)}function ns(){return{conversationMode:wl(),autoSendOnSpeechEnd:vl(),speakReplies:Nn(so),collapseLongReplies:Nn(oo),micReopensAfterReply:Nn(ao)}}function Al(n){if(Nn(ro)){Sl(n);return}kl(n)}function Vs(){return{conversationMode:Wd(ns())}}const Po="wherever-client-key";function Lu(){if(!(typeof sessionStorage>"u"))try{const n=sessionStorage.getItem(Po);if(n)return n;const e=`tab-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;return sessionStorage.setItem(Po,e),e}catch{return}}function Du(n){try{sessionStorage.setItem(Po,n)}catch{}}const os=Un(),St=new En({host:os.host,port:os.port,token:os.token,clientKey:Lu(),onClientKeyChange:Du,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!os.hideThinking,hideTools:!!os.hideTools}),Ir=St.stateStore,Ts=du(),io=uu(()=>{const n=pu(Nn(Ir));return n?Ts.put(n):void 0});let No=null;function Pu(){const n=Un();return qs({host:n.host,port:n.port,token:n.token})}let di=null;Ir.subscribe(n=>{n.messages!==di&&(di=n.messages,n.isStreaming&&io.schedule())});function Uo(){io.flush()}function ba(){mu(Ts,io)}function Cl(n){return bu({cache:Ts,serverKey:Pu(),hashId:n})}function El(n){St.hydrateCachedSession(n);const e=Nn(Ir).activeSessionFile===n.sessionFile;return e&&(No=n.serverKey),e}let Co=!1,ui=null;Ir.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==ui){ui=e,pl(e),Tl(e),Co=n.isStreaming;return}Co&&!n.isStreaming&&e&&Nn(ua)&&sl(fl()),Co=n.isStreaming});let fs=null;async function Nu(n){const{query:e,files:r}=n;if(r.length===0){St.sendMessage(e,Vs());return}const s=Nn(Ir).sessionId,o=[],a=[];for(const i of r){if(!s){a.push(i.name);continue}try{const u=await ka(s,i);o.push(u.savedPath)}catch(u){a.push(`${i.name} (${u.message||"upload failed"})`)}}a.length>0&&Ir.update(i=>({...i,sessionError:`Could not attach ${a.join(", ")}`})),St.sendMessage(ll(e,o),Vs())}const va=vr({text:"",bump:0});function Rl(n){va.update(e=>({text:n,bump:e.bump+1}))}let as=null;St.onMessage(n=>{switch(n.type){case"session_forked":{const r=n;as=r.prefillText??"",As(r.sessionFile,r.cwd);break}case"session_created":if(hs(n.sessionFile),as!==null){const r=as;as=null,queueMicrotask(()=>Rl(r))}if(fs!==null){const r=fs;fs=null,queueMicrotask(()=>{Nu(r)})}break;case"message_history":case"agent_end":queueMicrotask(()=>io.flush());break;case"hydration_rejected":{const r=No;No=null,xu({sessionId:n.sessionId,serverKey:r,win:typeof window<"u"?window:null,cache:Ts});break}case"session_error":fs=null,as=null;break;case"session_destroyed":Nn(Ir).sessionId===n.sessionId&&hs(null);break;case"sessions_updated":bs();break;case"session_working":{const r=n;cd(r.sessionFile,!!r.working);break}case"session_interrupted":hs(null);break}});function Gr(n={}){const e=Un();$r(e),gu(Ts,qs({host:e.host,port:e.port,token:e.token}));const r=typeof window<"u"&&window.location&&window.location.protocol==="https:";St.connect({host:e.host,port:e.port,token:e.token,secure:r,hideThinking:!!e.hideThinking,hideTools:!!e.hideTools},!!n.preserveState)}function _s(){St.disconnect(!0),hs(null)}function Il(){St.suspend()}function Fo(){St.resume()}function Bo(){St.noteVisible()}function Uu(){return St.hasSuspendedSession()}function zo(){return St.hasActiveSession()}let ga=0;const Fu=300*1e3;function Ml(){ga=Date.now()+Fu}function ma(){ga=0}function $l(){return Date.now()<ga}function Ho(n){return St.sendMessage(n,Vs())}function Ol(n){return St.resendMessage(n,Vs())}function Ll(n){St.discardMessage(n)}function Dl(){St.abort()}function Pl(){St.cancelSteer()}function Nl(){St.reloadResources()}function Ul(n,e,r){St.joinSession(n,e,r)}function As(n,e,r){St.switchSession(n,e,r)}function Fl(n,e){St.forkSession(n,e)}function yr(n,e,r,s,o,a){St.createSession(n,e,r,s,o,a)}function Bl(n,e,r=[]){const s=n.trim();if(!s&&r.length===0)return!1;const o=Nn(qi);if(!o)return!1;const a=Nn(fd);return fs={query:s,files:r},St.createSession(o,e||void 0,a,a,a?"private":void 0),!0}function fr(){St.leaveSession(),hs(null)}function zl(){St.loadMoreHistory()}function Hl(){St.continueFolderConflict()}function Bu(){St.ping()}function jl(){St.clearMessages()}function jo(n){$r(n);const{host:e,port:r,token:s,hideThinking:o,hideTools:a}=n;St.setConfig({host:e,port:r,token:s,hideThinking:o,hideTools:a}),n.beepDefault!==void 0&&no.set(!!n.beepDefault),n.conversationMode!==void 0&&Ss.set(!!n.conversationMode),n.speakReplies!==void 0&&so.set(!!n.speakReplies),n.collapseLongReplies!==void 0&&oo.set(!!n.collapseLongReplies),n.micReopensAfterReply!==void 0&&ao.set(!!n.micReopensAfterReply)}function Gl(n){const r={...Un(),...n};$r(r),St.setConfig(r)}function Dr(){St.dismissSessionError()}function Wl(){St.dismissNotice()}function Kl(n){St.sendSudoPassword(n)}function ql(){St.cancelSudoPrompt()}function Vl(n){St.changeModel(n)}function Go(n,e,r){return St.startRestore(n,e,r)}function xa(){return St.cancelRestore()}function Yl(){return St.reloadSession()}const gn=vn(Ir,n=>n),Cs=vn(gn,n=>n.connected),_a=vn(gn,n=>n.isStreaming),Xl=vn(gn,n=>n.messages),zu=vn(gn,n=>n.error),Hu=vn(gn,n=>n.session),Zl=vn(gn,n=>n.folderConflict),ya=vn(gn,n=>n.folderMissing),wa=vn(gn,n=>n.restore),Jl=vn(gn,n=>n.isInterrupted),Ql=vn(gn,n=>n.pendingSteering),lo=vn(gn,n=>n.sessionError),ec=vn(gn,n=>n.notice),tc=vn(gn,n=>n.sudoPrompt),co=vn(gn,n=>n.readOnly),rs=vn(gn,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),ju=vn(gn,n=>n.contextUsage),nc=vn(gn,n=>n.creatingSession),Es=vn(gn,n=>n.loadingSession),Rs=vn(gn,n=>n.resyncing),rc=vn(gn,n=>n.agentPending),sc=vn(gn,n=>hu(n)),oc=vn(gn,n=>n.loadingMoreHistory);function Gu(n,e,r,s){const o=ws(),a=ks(),i=`${o}/session/upload?sessionId=${encodeURIComponent(n)}&filename=${encodeURIComponent(e.name)}${a?`&token=${encodeURIComponent(a)}`:""}`;return Vd({url:i,body:e,size:e.size,signal:r,onProgress:s,probeReadable:()=>Yd(e)})}function ac(n){return{size:n.size,read:async(e,r)=>new Uint8Array(await n.slice(e,e+r).arrayBuffer())}}function ic(n){const r=Nn(gn).sessionId;if(!r)return null;const s=ws(),o=ks();return`${s}/session/download?sessionId=${encodeURIComponent(r)}&path=${encodeURIComponent(n)}`+(o?`&token=${encodeURIComponent(o)}`:"")}async function ka(n,e,r){const s=Nn(ud),o=r?.onProgress;return s==="post"?Gu(n,e,r?.signal,o):St.uploadFileViaWebSocket(n,e.name,ac(e),{signal:r?.signal,mime:e.type||void 0,onProgress:o})}async function Sa(n,e){const r=ws(),s=ks(),o=`${r}${n}${s?`?token=${encodeURIComponent(s)}`:""}`,a=await fetch(o,{method:e?.method??"GET",...e?.body!==void 0?{headers:{"Content-Type":"application/json"},body:JSON.stringify(e.body)}:{}});if(!a.ok){const u=await a.json().catch(()=>({}));throw new Error(u.error||`Drafts request failed with status ${a.status}`)}const i=await a.json().catch(()=>({}));return cl(i.drafts)}async function lc(){return Sa("/drafts")}async function Wo(n){return Sa("/drafts",{method:"POST",body:n})}async function Ko(n){return Sa("/drafts/delete",{method:"POST",body:{id:n}})}async function qo(n){try{const e=ws(),r=ks(),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 Wu=Object.freeze(Object.defineProperty({__proto__:null,abort:Dl,activeSessionInfo:rs,autoSendOnSpeechEnd:fa,beepEnabled:ua,beepSessionOverride:da,beginFilePicker:Ml,cancelRestore:xa,cancelSteer:Pl,cancelSudoPrompt:ql,changeModel:Vl,clearConversationCache:ba,clearMessages:jl,client:St,collapseLongReplies:yl,composerPrefill:va,connect:Gr,connectionError:zu,contextUsage:ju,continueFolderConflict:Hl,conversationMode:ha,conversationModeDefault:Eu,conversationModeSessionOverride:pa,createSession:yr,currentSession:Hu,deleteDraftRemote:Ko,deleteSession:qo,discardMessage:Ll,disconnect:_s,dismissNotice:Wl,dismissSessionError:Dr,downloadFileUrl:ic,endFilePicker:ma,fetchDrafts:lc,fileByteSource:ac,flushConversationCache:Uo,folderConflict:Zl,folderMissing:ya,forkSession:Fl,getAutoSendOnSpeechEnd:vl,getBeepDefault:ku,getBeepSoundUrl:fl,getConfig:Un,getConversationKnobs:ns,getConversationMode:wl,getConversationModeDefault:Iu,hasActiveSession:zo,hasMoreHistory:sc,hasSuspendedSession:Uu,hydrateFromCache:El,isAgentPending:rc,isConnected:Cs,isCreatingSession:nc,isFilePickerActive:$l,isInterrupted:Jl,isLoadingMoreHistory:oc,isLoadingSession:Es,isReadOnly:co,isResyncing:Rs,isStreaming:_a,joinSession:Ul,leaveSession:fr,loadMoreHistory:zl,messages:Xl,micReopensAfterReply:Ru,noteVisible:Bo,parseSkillInvocation:la,pendingSteering:Ql,piState:gn,ping:Bu,prefillComposer:Rl,readBootConversation:Cl,reloadResources:Nl,reloadSession:Yl,resendMessage:Ol,restoreState:wa,resume:Fo,runSearch:Bl,saveDraftRemote:Wo,sendMessage:Ho,sendSudoPassword:Kl,sessionError:lo,sessionNotice:ec,setAutoSendOnSpeechEnd:gl,setBeepDefault:Tu,setBeepSessionKey:pl,setBeepSessionOverride:zs,setBeepSoundUrl:Su,setCollapseLongReplies:$u,setConfig:jo,setConversationModeBundle:Al,setConversationModeDefault:kl,setConversationModeSessionKey:Tl,setConversationModeSessionOverride:Sl,setMicReopensAfterReply:Ou,setSpeakReplies:Mu,speakReplies:_l,startRestore:Go,state:Ir,sudoPrompt:tc,suspend:Il,switchSession:As,updateConfig:Gl,uploadFile:ka},Symbol.toStringTag,{value:"Module"}));function Ku(n){if(!n)return null;const e=n.text;if(typeof e!="string")return null;const r=e.trim();return r||null}let gs=0,Hs=[];function qu(){if(gs>0&&gs--,gs===0&&Hs.length>0){const n=Hs;Hs=[];for(const e of n)e()}}function Vu(){return gs===0?Promise.resolve():new Promise(n=>{Hs.push(n)})}let Vo=!1,Ls=!1,js=null;function cc(n){try{typeof n.resume=="function"&&n.resume()}catch{}}const Yu=".";function dc(n){try{return typeof n.getVoices!="function"?[]:n.getVoices()??[]}catch{return[]}}function Xu(n,e){const r=(n??"").trim();if(!r)return"";if(e.length===0)return r;const s=r.toLowerCase().split(/[-_]/)[0];return e.some(a=>(a.lang??"").toLowerCase().split(/[-_]/)[0]===s)?r:""}function uo(n=Ta()){if(Vo)return!1;const{synth:e,Utterance:r}=n;if(!e||!r)return!1;try{cc(e),dc(e);const s=new r(Yu);return s.volume=0,e.speak(s),Vo=!0,js?.(),!0}catch{return!1}}const fi=["pointerdown","touchend","mousedown","keydown"];function Zu(n=typeof document>"u"?null:document,e=Ta()){if(Vo||Ls||!n)return!1;const r=()=>{uo(e)};js=()=>{if(Ls){Ls=!1,js=null;for(const s of fi)try{n.removeEventListener(s,r,{capture:!0})}catch{}}},Ls=!0;try{for(const s of fi)n.addEventListener(s,r,{capture:!0,passive:!0})}catch{return js?.(),!1}return!0}function Ta(){if(typeof window>"u")return{synth:null,Utterance:null};const n=window;return{synth:n.speechSynthesis??null,Utterance:n.SpeechSynthesisUtterance??null}}function pi(n,e,r=Ta()){const s=(n??"").trim();if(!s)return!1;const{synth:o,Utterance:a}=r;if(!o||!a)return!1;gs++;let i=!1;const u=()=>{i||(i=!0,qu())};try{cc(o);const m=new a(s),v=Xu(e,dc(o));return v&&(m.lang=v),m.onend=u,m.onerror=u,o.speak(m),!0}catch{return u(),!1}}var Ju=b('<button class="flex-1 rounded bg-rose-500 px-4 py-2 text-sm text-white transition-colors hover:bg-rose-600">Disconnect</button>'),Qu=b('<button class="flex-1 rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-4 py-2 text-sm text-white transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:from-brand-surface-3 disabled:to-brand-surface-3"></button>'),ef=b(`<div class="border-b border-brand-border p-4"><div class="space-y-3"><div><label for="pi-host" class="mb-1 block text-xs text-brand-text-muted">Host</label> <input id="pi-host" type="text" placeholder="localhost" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div><label for="pi-port" class="mb-1 block text-xs text-brand-text-muted">Port</label> <input id="pi-port" type="number" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div><label for="pi-token" class="mb-1 block text-xs text-brand-text-muted">Token (optional)</label> <input id="pi-token" type="password" placeholder="Authentication token" class="w-full rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/></div> <div class="flex items-center gap-2 py-1"><input id="pi-hide-thinking" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-0"/> <label for="pi-hide-thinking" class="cursor-pointer text-xs text-brand-text select-none">Hide thinking steps</label></div> <div class="flex items-center gap-2 py-1"><input id="pi-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="space-y-2 border-t border-brand-border pt-3"><div class="flex items-center gap-2 py-1"><input id="pi-conversation-mode" 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-conversation-mode" class="cursor-pointer text-xs font-medium text-brand-text select-none">Conversation Mode by default (spoken back-and-forth)</label></div> <p class="pl-6 text-[10px] leading-relaxed text-brand-text-muted">The DEFAULT for conversations you have not toggled: Conversation Mode is
|
|
19
|
-
per conversation, and the 💬/🗣️ toggle above the composer sets it for
|
|
20
|
-
the conversation you are in, leaving the others alone. Changing this
|
|
21
|
-
default moves every conversation still following it. It flips the knobs
|
|
22
|
-
below on at once; when off, they are dormant and the default
|
|
23
|
-
typing-first experience is unchanged. Auto-send on speech end (Direct
|
|
24
|
-
Send, in Speech Settings) keeps its own effect regardless.</p> <div class="flex items-center gap-2 py-1 pl-6"><input id="pi-speak-replies" 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-speak-replies" class="cursor-pointer text-xs text-brand-text select-none">Speak replies aloud (browser TTS)</label></div> <div class="flex items-center gap-2 py-1 pl-6"><input id="pi-collapse-long-replies" 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-collapse-long-replies" class="cursor-pointer text-xs text-brand-text select-none">Collapse long written replies</label></div> <div class="flex items-center gap-2 py-1 pl-6"><input id="pi-mic-reopen" 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-mic-reopen" class="cursor-pointer text-xs text-brand-text select-none">Re-open mic after the agent speaks (hands-free)</label></div> <p class="pl-6 text-[10px] leading-relaxed text-brand-text-muted">Applies to both speech engines. On the Cloud AI engine, which records
|
|
25
|
-
until told to stop, an auto-opened mic stops itself on silence (and
|
|
26
|
-
always within a minute), so a re-opened mic can never run away.</p></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 tf(n,e){hr(e,!0);const r=()=>we(Cs,"$isConnected",s),[s,o]=Ur();let a=N(""),i=N(0),u=N(""),m=N(!1),v=N(!1),g=N(""),x=N(!1),_=N(!1),$=N(!1),L=N(!1),B=!1,W=P(r);ys(()=>{const T=Un();p(a,T.host,!0),p(i,T.port,!0),p(u,T.token||"",!0),p(m,!!T.hideThinking),p(v,!!T.beepDefault),p(g,T.beepSoundUrl||"",!0),p(x,!!T.conversationMode),p(_,!!T.speakReplies),p($,!!T.collapseLongReplies),p(L,!!T.micReopensAfterReply)});function Ne(){sl(t(g).trim()||void 0)}function re(){jo({host:t(a),port:t(i),token:t(u),hideThinking:t(m),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(g).trim(),conversationMode:t(x),speakReplies:t(_),collapseLongReplies:t($),micReopensAfterReply:t(L)}),t(x)&&t(_)&&uo()}function Ke(){jo({host:t(a),port:t(i),token:t(u),hideThinking:t(m),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(g).trim(),conversationMode:t(x),speakReplies:t(_),collapseLongReplies:t($),micReopensAfterReply:t(L)}),_s(),setTimeout(()=>Gr(),100)}function ve(){_s(),ba()}function ce(){window.location.reload()}var K=ef(),je=d(K),Qe=d(je),Ue=f(d(Qe),2);Tt(Ue),c(Qe);var oe=f(Qe,2),et=f(d(oe),2);Tt(et),c(oe);var dt=f(oe,2),ht=f(d(dt),2);Tt(ht),c(dt);var _t=f(dt,2),Be=d(_t);Tt(Be),pt(2),c(_t);var nt=f(_t,2),yt=d(nt);Tt(yt),pt(2),c(nt);var Ft=f(nt,2),Rt=f(d(Ft),2),Wt=d(Rt);Tt(Wt);var ae=f(Wt,2);c(Rt),c(Ft);var Kt=f(Ft,2),ot=d(Kt),Bt=d(ot);Tt(Bt),pt(2),c(ot);var At=f(ot,4),It=d(At);Tt(It),pt(2),c(At);var Q=f(At,2),H=d(Q);Tt(H),pt(2),c(Q);var Ye=f(Q,2),fe=d(Ye);Tt(fe),pt(2),c(Ye),pt(2),c(Kt);var U=f(Kt,2),Se=d(U);{var X=T=>{var Z=Ju();M("click",Z,ve),h(T,Z)},le=T=>{var Z=Qu();Z.disabled=B,Z.textContent="Connect",M("click",Z,Ke),h(T,Z)};k(Se,T=>{t(W)?T(X):T(le,-1)})}c(U);var Te=f(U,2);c(je),c(K),ar(Ue,()=>t(a),T=>p(a,T)),ar(et,()=>t(i),T=>p(i,T)),ar(ht,()=>t(u),T=>p(u,T)),M("change",Be,re),Zn(Be,()=>t(m),T=>p(m,T)),M("change",yt,re),Zn(yt,()=>t(v),T=>p(v,T)),M("change",Wt,re),ar(Wt,()=>t(g),T=>p(g,T)),M("click",ae,Ne),M("change",Bt,re),Zn(Bt,()=>t(x),T=>p(x,T)),M("change",It,re),Zn(It,()=>t(_),T=>p(_,T)),M("change",H,re),Zn(H,()=>t($),T=>p($,T)),M("change",fe,re),Zn(fe,()=>t(L),T=>p(L,T)),M("click",Te,ce),h(n,K),br(),o()}Mr(["change","click"]);const nf=["png","jpg","jpeg","gif","webp","bmp","svg","avif"],rf=["mp3","wav","oga","ogg","m4a","aac","flac","opus"],sf=["mp4","webm","mov","m4v","ogv"];function of(n){if(!n||typeof n!="string")return null;const e=n.split(/[/\\]/).pop()||"",r=e.lastIndexOf(".");return r<=0||r===e.length-1?null:e.slice(r+1).toLowerCase()}function af(n){const e=of(n);return e?nf.includes(e)?"image":rf.includes(e)?"audio":sf.includes(e)?"video":null:null}function lf(n,e,r){if(r||!e)return null;const s=(n||"").toLowerCase();if(!["attach_file","read"].includes(s))return null;const o=e.path||e.filepath||e.file;return!o||typeof o!="string"?null:o.trim()||null}const cf=320;function uc(n,e=cf){const s=(n??"").replace(/```[\s\S]*?(?:```|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\bhttps?:\/\/\S+/gi," ").replace(/^[ \t]*(?:#{1,6}|>|[-*+]|\d+[.)])[ \t]+/gm,"").replace(/^[ \t]*(?:[-*_][ \t]*){3,}$/gm," ").replace(/(\*\*|__|\*|_|~~)/g,"").replace(/\s+/g," ").trim();if(!s)return"";if(s.length<=e)return s;const o=s.match(/[^.!?]+[.!?]+(?:\s|$)|[^.!?]+$/g)??[s];let a="";for(const i of o){const u=(a+i).trimEnd();if(a&&u.length>e||(a=u,a.length>=e))break}return a=a.trim(),a||(a=s),a.length>e&&(a=`${a.slice(0,e).trimEnd()}...`),a}function df(n){return!n.active||n.spokeThisTurn?!1:uc(n.reply).length>0}const uf=600;function fc(n){return n?n.length>uf:!1}function ff(n){return!n.active||n.expanded?!1:fc(n.content)}function Aa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Kr=Aa();function pc(n){Kr=n}var ms={exec:()=>null};function rn(n,e=""){let r=typeof n=="string"?n:n.source;const s={replace:(o,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Jn.caret,"$1"),r=r.replace(o,i),s},getRegex:()=>new RegExp(r,e)};return s}var Jn={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")},pf=/^(?:[ \t]*(?:\n|$))+/,hf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,bf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Is=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,vf=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ca=/(?:[*+-]|\d{1,9}[.)])/,hc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,bc=rn(hc).replace(/bull/g,Ca).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(),gf=rn(hc).replace(/bull/g,Ca).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(),Ea=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,mf=/^[^\n]+/,Ra=/(?!\s*\])(?:\\.|[^\[\]\\])+/,xf=rn(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ra).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),_f=rn(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ca).getRegex(),fo="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",Ia=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,yf=rn("^ {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",Ia).replace("tag",fo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),vc=rn(Ea).replace("hr",Is).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",fo).getRegex(),wf=rn(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",vc).getRegex(),Ma={blockquote:wf,code:hf,def:xf,fences:bf,heading:vf,hr:Is,html:yf,lheading:bc,list:_f,newline:pf,paragraph:vc,table:ms,text:mf},hi=rn("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Is).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",fo).getRegex(),kf={...Ma,lheading:gf,table:hi,paragraph:rn(Ea).replace("hr",Is).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",hi).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",fo).getRegex()},Sf={...Ma,html:rn(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ia).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:ms,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rn(Ea).replace("hr",Is).replace("heading",` *#{1,6} *[^
|
|
27
|
-
]`).replace("lheading",bc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Tf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Af=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,gc=/^( {2,}|\\)\n(?!\s*$)/,Cf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,po=/[\p{P}\p{S}]/u,$a=/[\s\p{P}\p{S}]/u,mc=/[^\s\p{P}\p{S}]/u,Ef=rn(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,$a).getRegex(),xc=/(?!~)[\p{P}\p{S}]/u,Rf=/(?!~)[\s\p{P}\p{S}]/u,If=/(?:[^\s\p{P}\p{S}]|~)/u,Mf=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,_c=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,$f=rn(_c,"u").replace(/punct/g,po).getRegex(),Of=rn(_c,"u").replace(/punct/g,xc).getRegex(),yc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Lf=rn(yc,"gu").replace(/notPunctSpace/g,mc).replace(/punctSpace/g,$a).replace(/punct/g,po).getRegex(),Df=rn(yc,"gu").replace(/notPunctSpace/g,If).replace(/punctSpace/g,Rf).replace(/punct/g,xc).getRegex(),Pf=rn("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,mc).replace(/punctSpace/g,$a).replace(/punct/g,po).getRegex(),Nf=rn(/\\(punct)/,"gu").replace(/punct/g,po).getRegex(),Uf=rn(/^<(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(),Ff=rn(Ia).replace("(?:-->|$)","-->").getRegex(),Bf=rn("^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",Ff).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ys=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,zf=rn(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Ys).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),wc=rn(/^!?\[(label)\]\[(ref)\]/).replace("label",Ys).replace("ref",Ra).getRegex(),kc=rn(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ra).getRegex(),Hf=rn("reflink|nolink(?!\\()","g").replace("reflink",wc).replace("nolink",kc).getRegex(),Oa={_backpedal:ms,anyPunctuation:Nf,autolink:Uf,blockSkip:Mf,br:gc,code:Af,del:ms,emStrongLDelim:$f,emStrongRDelimAst:Lf,emStrongRDelimUnd:Pf,escape:Tf,link:zf,nolink:kc,punctuation:Ef,reflink:wc,reflinkSearch:Hf,tag:Bf,text:Cf,url:ms},jf={...Oa,link:rn(/^!?\[(label)\]\((.*?)\)/).replace("label",Ys).getRegex(),reflink:rn(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ys).getRegex()},Yo={...Oa,emStrongRDelimAst:Df,emStrongLDelim:Of,url:rn(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Gf={...Yo,br:rn(gc).replace("{2,}","*").getRegex(),text:rn(Yo.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ds={normal:Ma,gfm:kf,pedantic:Sf},is={normal:Oa,gfm:Yo,breaks:Gf,pedantic:jf},Wf={"&":"&","<":"<",">":">",'"':""","'":"'"},bi=n=>Wf[n];function xr(n,e){if(e){if(Jn.escapeTest.test(n))return n.replace(Jn.escapeReplace,bi)}else if(Jn.escapeTestNoEncode.test(n))return n.replace(Jn.escapeReplaceNoEncode,bi);return n}function vi(n){try{n=encodeURI(n).replace(Jn.percentDecode,"%")}catch{return null}return n}function gi(n,e){const r=n.replace(Jn.findPipe,(a,i,u)=>{let m=!1,v=i;for(;--v>=0&&u[v]==="\\";)m=!m;return m?"|":" |"}),s=r.split(Jn.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(Jn.slashPipe,"|");return s}function ls(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 Kf(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 mi(n,e,r,s,o){const a=e.href,i=e.title||null,u=n[1].replace(o.other.outputLinkReplace,"$1");s.state.inLink=!0;const m={type:n[0].charAt(0)==="!"?"image":"link",raw:r,href:a,title:i,text:u,tokens:s.inlineTokens(u)};return s.state.inLink=!1,m}function qf(n,e,r){const s=n.match(r.other.indentCodeCompensation);if(s===null)return e;const o=s[1];return e.split(`
|
|
28
|
-
`).map(a=>{const i=a.match(r.other.beginningSpace);if(i===null)return a;const[u]=i;return u.length>=o.length?a.slice(o.length):a}).join(`
|
|
29
|
-
`)}var Xs=class{options;rules;lexer;constructor(n){this.options=n||Kr}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:ls(r,`
|
|
30
|
-
`)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const r=e[0],s=qf(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=ls(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:ls(e[0],`
|
|
31
|
-
`)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let r=ls(e[0],`
|
|
32
|
-
`).split(`
|
|
33
|
-
`),s="",o="";const a=[];for(;r.length>0;){let i=!1;const u=[];let m;for(m=0;m<r.length;m++)if(this.rules.other.blockquoteStart.test(r[m]))u.push(r[m]),i=!0;else if(!i)u.push(r[m]);else break;r=r.slice(m);const v=u.join(`
|
|
34
|
-
`),g=v.replace(this.rules.other.blockquoteSetextReplace,`
|
|
35
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
36
|
-
${v}`:v,o=o?`${o}
|
|
37
|
-
${g}`:g;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(g,a,!0),this.lexer.state.top=x,r.length===0)break;const _=a.at(-1);if(_?.type==="code")break;if(_?.type==="blockquote"){const $=_,L=$.raw+`
|
|
38
|
-
`+r.join(`
|
|
39
|
-
`),B=this.blockquote(L);a[a.length-1]=B,s=s.substring(0,s.length-$.raw.length)+B.raw,o=o.substring(0,o.length-$.text.length)+B.text;break}else if(_?.type==="list"){const $=_,L=$.raw+`
|
|
40
|
-
`+r.join(`
|
|
41
|
-
`),B=this.list(L);a[a.length-1]=B,s=s.substring(0,s.length-_.raw.length)+B.raw,o=o.substring(0,o.length-$.raw.length)+B.raw,r=L.substring(a.at(-1).raw.length).split(`
|
|
42
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:a,text:o}}}list(n){let e=this.rules.block.list.exec(n);if(e){let r=e[1].trim();const s=r.length>1,o={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");const a=this.rules.other.listItemRegex(r);let i=!1;for(;n;){let m=!1,v="",g="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;v=e[0],n=n.substring(v.length);let x=e[2].split(`
|
|
43
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,Ne=>" ".repeat(3*Ne.length)),_=n.split(`
|
|
44
|
-
`,1)[0],$=!x.trim(),L=0;if(this.options.pedantic?(L=2,g=x.trimStart()):$?L=e[1].length+1:(L=e[2].search(this.rules.other.nonSpaceChar),L=L>4?1:L,g=x.slice(L),L+=e[1].length),$&&this.rules.other.blankLine.test(_)&&(v+=_+`
|
|
45
|
-
`,n=n.substring(_.length+1),m=!0),!m){const Ne=this.rules.other.nextBulletRegex(L),re=this.rules.other.hrRegex(L),Ke=this.rules.other.fencesBeginRegex(L),ve=this.rules.other.headingBeginRegex(L),ce=this.rules.other.htmlBeginRegex(L);for(;n;){const K=n.split(`
|
|
46
|
-
`,1)[0];let je;if(_=K,this.options.pedantic?(_=_.replace(this.rules.other.listReplaceNesting," "),je=_):je=_.replace(this.rules.other.tabCharGlobal," "),Ke.test(_)||ve.test(_)||ce.test(_)||Ne.test(_)||re.test(_))break;if(je.search(this.rules.other.nonSpaceChar)>=L||!_.trim())g+=`
|
|
47
|
-
`+je.slice(L);else{if($||x.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Ke.test(x)||ve.test(x)||re.test(x))break;g+=`
|
|
48
|
-
`+_}!$&&!_.trim()&&($=!0),v+=K+`
|
|
49
|
-
`,n=n.substring(K.length+1),x=je.slice(L)}}o.loose||(i?o.loose=!0:this.rules.other.doubleBlankLine.test(v)&&(i=!0));let B=null,W;this.options.gfm&&(B=this.rules.other.listIsTask.exec(g),B&&(W=B[0]!=="[ ] ",g=g.replace(this.rules.other.listReplaceTask,""))),o.items.push({type:"list_item",raw:v,task:!!B,checked:W,loose:!1,text:g,tokens:[]}),o.raw+=v}const u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let m=0;m<o.items.length;m++)if(this.lexer.state.top=!1,o.items[m].tokens=this.lexer.blockTokens(o.items[m].text,[]),!o.loose){const v=o.items[m].tokens.filter(x=>x.type==="space"),g=v.length>0&&v.some(x=>this.rules.other.anyLine.test(x.raw));o.loose=g}if(o.loose)for(let m=0;m<o.items.length;m++)o.items[m].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=gi(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
50
|
-
`):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const i of s)this.rules.other.tableAlignRight.test(i)?a.align.push("right"):this.rules.other.tableAlignCenter.test(i)?a.align.push("center"):this.rules.other.tableAlignLeft.test(i)?a.align.push("left"):a.align.push(null);for(let i=0;i<r.length;i++)a.header.push({text:r[i],tokens:this.lexer.inline(r[i]),header:!0,align:a.align[i]});for(const i of o)a.rows.push(gi(i,a.header.length).map((u,m)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:a.align[m]})));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)===`
|
|
51
|
-
`?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=ls(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{const a=Kf(e[2],"()");if(a===-2)return;if(a>-1){const u=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,u).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)),mi(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 mi(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 i,u,m=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(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(u=[...i].length,s[3]||s[4]){m+=u;continue}else if((s[5]||s[6])&&a%3&&!((a+u)%3)){v+=u;continue}if(m-=u,m>0)continue;u=Math.min(u,u+m+v);const x=[...s[0]][0].length,_=n.slice(0,a+s.index+x+u);if(Math.min(a,u)%2){const L=_.slice(1,-1);return{type:"em",raw:_,text:L,tokens:this.lexer.inlineTokens(L)}}const $=_.slice(2,-2);return{type:"strong",raw:_,text:$,tokens:this.lexer.inlineTokens($)}}}}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}}}},Er=class Xo{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Kr,this.options.tokenizer=this.options.tokenizer||new Xs,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:Jn,block:Ds.normal,inline:is.normal};this.options.pedantic?(r.block=Ds.pedantic,r.inline=is.pedantic):this.options.gfm&&(r.block=Ds.gfm,this.options.breaks?r.inline=is.breaks:r.inline=is.gfm),this.tokenizer.rules=r}static get rules(){return{block:Ds,inline:is}}static lex(e,r){return new Xo(r).lex(e)}static lexInline(e,r){return new Xo(r).inlineTokens(e)}lex(e){e=e.replace(Jn.carriageReturn,`
|
|
52
|
-
`),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(Jn.tabCharGlobal," ").replace(Jn.spaceLine,""));e;){let o;if(this.options.extensions?.block?.some(i=>(o=i.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 i=r.at(-1);o.raw.length===1&&i!==void 0?i.raw+=`
|
|
53
|
-
`:r.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);const i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=`
|
|
54
|
-
`+o.raw,i.text+=`
|
|
55
|
-
`+o.text,this.inlineQueue.at(-1).src=i.text):r.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);const i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=`
|
|
56
|
-
`+o.raw,i.text+=`
|
|
57
|
-
`+o.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),r.push(o);continue}let a=e;if(this.options.extensions?.startBlock){let i=1/0;const u=e.slice(1);let m;this.options.extensions.startBlock.forEach(v=>{m=v.call({lexer:this},u),typeof m=="number"&&m>=0&&(i=Math.min(i,m))}),i<1/0&&i>=0&&(a=e.substring(0,i+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){const i=r.at(-1);s&&i?.type==="paragraph"?(i.raw+=`
|
|
58
|
-
`+o.raw,i.text+=`
|
|
59
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(o),s=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);const i=r.at(-1);i?.type==="text"?(i.raw+=`
|
|
60
|
-
`+o.raw,i.text+=`
|
|
61
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(o);continue}if(e){const i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){let s=e,o=null;if(this.tokens.links){const u=Object.keys(this.tokens.links);if(u.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)u.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,o.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(o=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let a=!1,i="";for(;e;){a||(i=""),a=!1;let u;if(this.options.extensions?.inline?.some(v=>(u=v.call({lexer:this},e,r))?(e=e.substring(u.raw.length),r.push(u),!0):!1))continue;if(u=this.tokenizer.escape(e)){e=e.substring(u.raw.length),r.push(u);continue}if(u=this.tokenizer.tag(e)){e=e.substring(u.raw.length),r.push(u);continue}if(u=this.tokenizer.link(e)){e=e.substring(u.raw.length),r.push(u);continue}if(u=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(u.raw.length);const v=r.at(-1);u.type==="text"&&v?.type==="text"?(v.raw+=u.raw,v.text+=u.text):r.push(u);continue}if(u=this.tokenizer.emStrong(e,s,i)){e=e.substring(u.raw.length),r.push(u);continue}if(u=this.tokenizer.codespan(e)){e=e.substring(u.raw.length),r.push(u);continue}if(u=this.tokenizer.br(e)){e=e.substring(u.raw.length),r.push(u);continue}if(u=this.tokenizer.del(e)){e=e.substring(u.raw.length),r.push(u);continue}if(u=this.tokenizer.autolink(e)){e=e.substring(u.raw.length),r.push(u);continue}if(!this.state.inLink&&(u=this.tokenizer.url(e))){e=e.substring(u.raw.length),r.push(u);continue}let m=e;if(this.options.extensions?.startInline){let v=1/0;const g=e.slice(1);let x;this.options.extensions.startInline.forEach(_=>{x=_.call({lexer:this},g),typeof x=="number"&&x>=0&&(v=Math.min(v,x))}),v<1/0&&v>=0&&(m=e.substring(0,v+1))}if(u=this.tokenizer.inlineText(m)){e=e.substring(u.raw.length),u.raw.slice(-1)!=="_"&&(i=u.raw.slice(-1)),a=!0;const v=r.at(-1);v?.type==="text"?(v.raw+=u.raw,v.text+=u.text):r.push(u);continue}if(e){const v="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return r}},Zs=class{options;parser;constructor(n){this.options=n||Kr}space(n){return""}code({text:n,lang:e,escaped:r}){const s=(e||"").match(Jn.notSpaceStart)?.[0],o=n.replace(Jn.endingNewline,"")+`
|
|
62
|
-
`;return s?'<pre><code class="language-'+xr(s)+'">'+(r?o:xr(o,!0))+`</code></pre>
|
|
63
|
-
`:"<pre><code>"+(r?o:xr(o,!0))+`</code></pre>
|
|
64
|
-
`}blockquote({tokens:n}){return`<blockquote>
|
|
65
|
-
${this.parser.parse(n)}</blockquote>
|
|
66
|
-
`}html({text:n}){return n}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
67
|
-
`}hr(n){return`<hr>
|
|
68
|
-
`}list(n){const e=n.ordered,r=n.start;let s="";for(let i=0;i<n.items.length;i++){const u=n.items[i];s+=this.listitem(u)}const o=e?"ol":"ul",a=e&&r!==1?' start="'+r+'"':"";return"<"+o+a+`>
|
|
69
|
-
`+s+"</"+o+`>
|
|
70
|
-
`}listitem(n){let e="";if(n.task){const r=this.checkbox({checked:!!n.checked});n.loose?n.tokens[0]?.type==="paragraph"?(n.tokens[0].text=r+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=r+" "+xr(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):e+=r+" "}return e+=this.parser.parse(n.tokens,!!n.loose),`<li>${e}</li>
|
|
71
|
-
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
72
|
-
`}table(n){let e="",r="";for(let o=0;o<n.header.length;o++)r+=this.tablecell(n.header[o]);e+=this.tablerow({text:r});let s="";for(let o=0;o<n.rows.length;o++){const a=n.rows[o];r="";for(let i=0;i<a.length;i++)r+=this.tablecell(a[i]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
73
|
-
<thead>
|
|
74
|
-
`+e+`</thead>
|
|
75
|
-
`+s+`</table>
|
|
76
|
-
`}tablerow({text:n}){return`<tr>
|
|
77
|
-
${n}</tr>
|
|
78
|
-
`}tablecell(n){const e=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+`</${r}>
|
|
79
|
-
`}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>${xr(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=vi(n);if(o===null)return s;n=o;let a='<a href="'+n+'"';return e&&(a+=' title="'+xr(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=vi(n);if(o===null)return xr(r);n=o;let a=`<img src="${n}" alt="${r}"`;return e&&(a+=` title="${xr(e)}"`),a+=">",a}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:xr(n.text)}},La=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""}},Rr=class Zo{options;renderer;textRenderer;constructor(e){this.options=e||Kr,this.options.renderer=this.options.renderer||new Zs,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new La}static parse(e,r){return new Zo(r).parse(e)}static parseInline(e,r){return new Zo(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 u=a,m=this.options.extensions.renderers[u.type].call({parser:this},u);if(m!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(u.type)){s+=m||"";continue}}const i=a;switch(i.type){case"space":{s+=this.renderer.space(i);continue}case"hr":{s+=this.renderer.hr(i);continue}case"heading":{s+=this.renderer.heading(i);continue}case"code":{s+=this.renderer.code(i);continue}case"table":{s+=this.renderer.table(i);continue}case"blockquote":{s+=this.renderer.blockquote(i);continue}case"list":{s+=this.renderer.list(i);continue}case"html":{s+=this.renderer.html(i);continue}case"paragraph":{s+=this.renderer.paragraph(i);continue}case"text":{let u=i,m=this.renderer.text(u);for(;o+1<e.length&&e[o+1].type==="text";)u=e[++o],m+=`
|
|
80
|
-
`+this.renderer.text(u);r?s+=this.renderer.paragraph({type:"paragraph",raw:m,text:m,tokens:[{type:"text",raw:m,text:m,escaped:!0}]}):s+=m;continue}default:{const u='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}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 u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=u||"";continue}}const i=a;switch(i.type){case"escape":{s+=r.text(i);break}case"html":{s+=r.html(i);break}case"link":{s+=r.link(i);break}case"image":{s+=r.image(i);break}case"strong":{s+=r.strong(i);break}case"em":{s+=r.em(i);break}case"codespan":{s+=r.codespan(i);break}case"br":{s+=r.br(i);break}case"del":{s+=r.del(i);break}case"text":{s+=r.text(i);break}default:{const u='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return s}},Gs=class{options;block;constructor(n){this.options=n||Kr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Er.lex:Er.lexInline}provideParser(){return this.block?Rr.parse:Rr.parseInline}},Vf=class{defaults=Aa();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Rr;Renderer=Zs;TextRenderer=La;Lexer=Er;Tokenizer=Xs;Hooks=Gs;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 i of a)r=r.concat(this.walkTokens(i.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 i=o[a].flat(1/0);r=r.concat(this.walkTokens(i,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(...i){let u=o.renderer.apply(this,i);return u===!1&&(u=a.apply(this,i)),u}: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 Zs(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 i=a,u=r.renderer[i],m=o[i];o[i]=(...v)=>{let g=u.apply(o,v);return g===!1&&(g=m.apply(o,v)),g||""}}s.renderer=o}if(r.tokenizer){const o=this.defaults.tokenizer||new Xs(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 i=a,u=r.tokenizer[i],m=o[i];o[i]=(...v)=>{let g=u.apply(o,v);return g===!1&&(g=m.apply(o,v)),g}}s.tokenizer=o}if(r.hooks){const o=this.defaults.hooks||new Gs;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 i=a,u=r.hooks[i],m=o[i];Gs.passThroughHooks.has(a)?o[i]=v=>{if(this.defaults.async)return Promise.resolve(u.call(o,v)).then(x=>m.call(o,x));const g=u.call(o,v);return m.call(o,g)}:o[i]=(...v)=>{let g=u.apply(o,v);return g===!1&&(g=m.apply(o,v)),g}}s.hooks=o}if(r.walkTokens){const o=this.defaults.walkTokens,a=r.walkTokens;s.walkTokens=function(i){let u=[];return u.push(a.call(this,i)),o&&(u=u.concat(o.call(this,i))),u}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return Er.lex(n,e??this.defaults)}parser(n,e){return Rr.parse(n,e??this.defaults)}parseMarkdown(n){return(r,s)=>{const o={...s},a={...this.defaults,...o},i=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&o.async===!1)return i(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 i(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return i(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 u=a.hooks?a.hooks.provideLexer():n?Er.lex:Er.lexInline,m=a.hooks?a.hooks.provideParser():n?Rr.parse:Rr.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(r):r).then(v=>u(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=>m(v,a)).then(v=>a.hooks?a.hooks.postprocess(v):v).catch(i);try{a.hooks&&(r=a.hooks.preprocess(r));let v=u(r,a);a.hooks&&(v=a.hooks.processAllTokens(v)),a.walkTokens&&this.walkTokens(v,a.walkTokens);let g=m(v,a);return a.hooks&&(g=a.hooks.postprocess(g)),g}catch(v){return i(v)}}}onError(n,e){return r=>{if(r.message+=`
|
|
81
|
-
Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+xr(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},Wr=new Vf;function nn(n,e){return Wr.parse(n,e)}nn.options=nn.setOptions=function(n){return Wr.setOptions(n),nn.defaults=Wr.defaults,pc(nn.defaults),nn};nn.getDefaults=Aa;nn.defaults=Kr;nn.use=function(...n){return Wr.use(...n),nn.defaults=Wr.defaults,pc(nn.defaults),nn};nn.walkTokens=function(n,e){return Wr.walkTokens(n,e)};nn.parseInline=Wr.parseInline;nn.Parser=Rr;nn.parser=Rr.parse;nn.Renderer=Zs;nn.TextRenderer=La;nn.Lexer=Er;nn.lexer=Er.lex;nn.Tokenizer=Xs;nn.Hooks=Gs;nn.parse=nn;nn.options;nn.setOptions;nn.use;nn.walkTokens;nn.parseInline;Rr.parse;Er.lex;function xi(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 Yf(n){if(Array.isArray(n))return n}function Xf(n,e){var r=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var s,o,a,i,u=[],m=!0,v=!1;try{if(a=(r=r.call(n)).next,e!==0)for(;!(m=(s=a.call(r)).done)&&(u.push(s.value),u.length!==e);m=!0);}catch(g){v=!0,o=g}finally{try{if(!m&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(v)throw o}}return u}}function Zf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
82
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jf(n,e){return Yf(n)||Xf(n,e)||Qf(n,e)||Zf()}function Qf(n,e){if(n){if(typeof n=="string")return xi(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)?xi(n,e):void 0}}const Sc=Object.entries,_i=Object.setPrototypeOf,ep=Object.isFrozen,tp=Object.getPrototypeOf,np=Object.getOwnPropertyDescriptor;let Hn=Object.freeze,jn=Object.seal,Jr=Object.create,Tc=typeof Reflect<"u"&&Reflect,Jo=Tc.apply,Qo=Tc.construct;Hn||(Hn=function(e){return e});jn||(jn=function(e){return e});Jo||(Jo=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)});Qo||(Qo=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 cs=Dn(Array.prototype.forEach),rp=Dn(Array.prototype.lastIndexOf),yi=Dn(Array.prototype.pop),Xr=Dn(Array.prototype.push),sp=Dn(Array.prototype.splice),Pr=Array.isArray,ps=Dn(String.prototype.toLowerCase),Eo=Dn(String.prototype.toString),wi=Dn(String.prototype.match),ds=Dn(String.prototype.replace),ki=Dn(String.prototype.indexOf),op=Dn(String.prototype.trim),ap=Dn(Number.prototype.toString),ip=Dn(Boolean.prototype.toString),Si=typeof BigInt>"u"?null:Dn(BigInt.prototype.toString),Ti=typeof Symbol>"u"?null:Dn(Symbol.prototype.toString),Pn=Dn(Object.prototype.hasOwnProperty),us=Dn(Object.prototype.toString),zn=Dn(RegExp.prototype.test),jr=lp(TypeError);function Dn(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 Jo(n,e,s)}}function lp(n){return function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return Qo(n,r)}}function Yt(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ps;if(_i&&_i(n,null),!Pr(e))return n;let s=e.length;for(;s--;){let o=e[s];if(typeof o=="string"){const a=r(o);a!==o&&(ep(e)||(e[s]=a),o=a)}n[o]=!0}return n}function cp(n){for(let e=0;e<n.length;e++)Pn(n,e)||(n[e]=null);return n}function Xn(n){const e=Jr(null);for(const s of Sc(n)){var r=Jf(s,2);const o=r[0],a=r[1];Pn(n,o)&&(Pr(a)?e[o]=cp(a):a&&typeof a=="object"&&a.constructor===Object?e[o]=Xn(a):e[o]=a)}return e}function dp(n){switch(typeof n){case"string":return n;case"number":return ap(n);case"boolean":return ip(n);case"bigint":return Si?Si(n):"0";case"symbol":return Ti?Ti(n):"Symbol()";case"undefined":return us(n);case"function":case"object":{if(n===null)return us(n);const e=n,r=_r(e,"toString");if(typeof r=="function"){const s=r(e);return typeof s=="string"?s:us(s)}return us(n)}default:return us(n)}}function _r(n,e){for(;n!==null;){const s=np(n,e);if(s){if(s.get)return Dn(s.get);if(typeof s.value=="function")return Dn(s.value)}n=tp(n)}function r(){return null}return r}function up(n){try{return zn(n,""),!0}catch{return!1}}const Ai=Hn(["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"]),Ro=Hn(["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"]),Io=Hn(["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"]),fp=Hn(["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"]),Mo=Hn(["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"]),pp=Hn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ci=Hn(["#text"]),Ei=Hn(["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"]),$o=Hn(["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"]),Ri=Hn(["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"]),Ps=Hn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hp=jn(/{{[\w\W]*|^[\w\W]*}}/g),bp=jn(/<%[\w\W]*|^[\w\W]*%>/g),vp=jn(/\${[\w\W]*/g),gp=jn(/^data-[\-\w.\u00B7-\uFFFF]+$/),mp=jn(/^aria-[\-\w]+$/),Ii=jn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),xp=jn(/^(?:\w+script|data):/i),_p=jn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yp=jn(/^html$/i),wp=jn(/^[a-z][.\w]*(-[.\w]+)+$/i),Mi=jn(/<[/\w!]/g),kp=jn(/<[/\w]/g),Sp=jn(/<\/no(script|embed|frames)/i),Tp=jn(/\/>/i),mr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ap=function(){return typeof window>"u"?null:window},Cp=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(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},$i=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Or=function(e,r,s,o){return Pn(e,r)&&Pr(e[r])?Yt(o.base?Xn(o.base):{},e[r],o.transform):s};function Ac(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ap();const e=O=>Ac(O);if(e.version="3.4.11",e.removed=[],!n||!n.document||n.document.nodeType!==mr.document||!n.Element)return e.isSupported=!1,e;let r=n.document;const s=r,o=s.currentScript;n.DocumentFragment;const a=n.HTMLTemplateElement,i=n.Node,u=n.Element,m=n.NodeFilter,v=n.NamedNodeMap;v===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const g=n.DOMParser,x=n.trustedTypes,_=u.prototype,$=_r(_,"cloneNode"),L=_r(_,"remove"),B=_r(_,"nextSibling"),W=_r(_,"childNodes"),Ne=_r(_,"parentNode"),re=_r(_,"shadowRoot"),Ke=_r(_,"attributes"),ve=i&&i.prototype?_r(i.prototype,"nodeType"):null,ce=i&&i.prototype?_r(i.prototype,"nodeName"):null;if(typeof a=="function"){const O=r.createElement("template");O.content&&O.content.ownerDocument&&(r=O.content.ownerDocument)}let K,je="",Qe,Ue=!1,oe=0;const et=function(){if(oe>0)throw jr('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.')},dt=function(l){et(),oe++;try{return K.createHTML(l)}finally{oe--}},ht=function(l){et(),oe++;try{return K.createScriptURL(l)}finally{oe--}},_t=function(){return Ue||(Qe=Cp(x,o),Ue=!0),Qe},Be=r,nt=Be.implementation,yt=Be.createNodeIterator,Ft=Be.createDocumentFragment,Rt=Be.getElementsByTagName,Wt=s.importNode;let ae=$i();e.isSupported=typeof Sc=="function"&&typeof Ne=="function"&&nt&&nt.createHTMLDocument!==void 0;const Kt=hp,ot=bp,Bt=vp,At=gp,It=mp,Q=xp,H=_p,Ye=wp;let fe=Ii,U=null;const Se=Yt({},[...Ai,...Ro,...Io,...Mo,...Ci]);let X=null;const le=Yt({},[...Ei,...$o,...Ri,...Ps]);let Te=Object.seal(Jr(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}})),T=null,Z=null;const q=Object.seal(Jr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ae=!0,Ie=!0,rt=!1,ne=!0,Me=!1,Xe=!0,bt=!1,Ct=!1,wt=null,Pt=null,ln=!1,Qt=!1,yn=!1,An=!1,sn=!0,en=!1;const cn="user-content-";let Sn=!0,Cn=!1,at={},kt=null;const wn=Yt({},["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 In=null;const Rn=Yt({},["audio","video","img","source","image","track"]);let Gn=null;const kn=Yt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),mn="http://www.w3.org/1998/Math/MathML",Mn="http://www.w3.org/2000/svg",qt="http://www.w3.org/1999/xhtml";let Fn=qt,F=!1,te=null;const Ce=Yt({},[mn,Mn,qt],Eo),$e=Hn(["mi","mo","mn","ms","mtext"]);let w=Yt({},$e);const G=Hn(["annotation-xml"]);let de=Yt({},G);const Ee=Yt({},["title","style","font","a","script"]);let qe=null;const Le=["application/xhtml+xml","text/html"],_e="text/html";let ge=null,Zt=null;const on=r.createElement("form"),zt=function(l){return l instanceof RegExp||l instanceof Function},dn=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Zt&&Zt===l)return;(!l||typeof l!="object")&&(l={}),l=Xn(l),qe=Le.indexOf(l.PARSER_MEDIA_TYPE)===-1?_e:l.PARSER_MEDIA_TYPE,ge=qe==="application/xhtml+xml"?Eo:ps,U=Or(l,"ALLOWED_TAGS",Se,{transform:ge}),X=Or(l,"ALLOWED_ATTR",le,{transform:ge}),te=Or(l,"ALLOWED_NAMESPACES",Ce,{transform:Eo}),Gn=Or(l,"ADD_URI_SAFE_ATTR",kn,{transform:ge,base:kn}),In=Or(l,"ADD_DATA_URI_TAGS",Rn,{transform:ge,base:Rn}),kt=Or(l,"FORBID_CONTENTS",wn,{transform:ge}),T=Or(l,"FORBID_TAGS",Xn({}),{transform:ge}),Z=Or(l,"FORBID_ATTR",Xn({}),{transform:ge}),at=Pn(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?Xn(l.USE_PROFILES):l.USE_PROFILES:!1,Ae=l.ALLOW_ARIA_ATTR!==!1,Ie=l.ALLOW_DATA_ATTR!==!1,rt=l.ALLOW_UNKNOWN_PROTOCOLS||!1,ne=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Me=l.SAFE_FOR_TEMPLATES||!1,Xe=l.SAFE_FOR_XML!==!1,bt=l.WHOLE_DOCUMENT||!1,Qt=l.RETURN_DOM||!1,yn=l.RETURN_DOM_FRAGMENT||!1,An=l.RETURN_TRUSTED_TYPE||!1,ln=l.FORCE_BODY||!1,sn=l.SANITIZE_DOM!==!1,en=l.SANITIZE_NAMED_PROPS||!1,Sn=l.KEEP_CONTENT!==!1,Cn=l.IN_PLACE||!1,fe=up(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:Ii,Fn=typeof l.NAMESPACE=="string"?l.NAMESPACE:qt,w=Pn(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?Xn(l.MATHML_TEXT_INTEGRATION_POINTS):Yt({},$e),de=Pn(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?Xn(l.HTML_INTEGRATION_POINTS):Yt({},G);const y=Pn(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?Xn(l.CUSTOM_ELEMENT_HANDLING):Jr(null);if(Te=Jr(null),Pn(y,"tagNameCheck")&&zt(y.tagNameCheck)&&(Te.tagNameCheck=y.tagNameCheck),Pn(y,"attributeNameCheck")&&zt(y.attributeNameCheck)&&(Te.attributeNameCheck=y.attributeNameCheck),Pn(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(Te.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),jn(Te),Me&&(Ie=!1),yn&&(Qt=!0),at&&(U=Yt({},Ci),X=Jr(null),at.html===!0&&(Yt(U,Ai),Yt(X,Ei)),at.svg===!0&&(Yt(U,Ro),Yt(X,$o),Yt(X,Ps)),at.svgFilters===!0&&(Yt(U,Io),Yt(X,$o),Yt(X,Ps)),at.mathMl===!0&&(Yt(U,Mo),Yt(X,Ri),Yt(X,Ps))),q.tagCheck=null,q.attributeCheck=null,Pn(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?q.tagCheck=l.ADD_TAGS:Pr(l.ADD_TAGS)&&(U===Se&&(U=Xn(U)),Yt(U,l.ADD_TAGS,ge))),Pn(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?q.attributeCheck=l.ADD_ATTR:Pr(l.ADD_ATTR)&&(X===le&&(X=Xn(X)),Yt(X,l.ADD_ATTR,ge))),Pn(l,"ADD_URI_SAFE_ATTR")&&Pr(l.ADD_URI_SAFE_ATTR)&&Yt(Gn,l.ADD_URI_SAFE_ATTR,ge),Pn(l,"FORBID_CONTENTS")&&Pr(l.FORBID_CONTENTS)&&(kt===wn&&(kt=Xn(kt)),Yt(kt,l.FORBID_CONTENTS,ge)),Pn(l,"ADD_FORBID_CONTENTS")&&Pr(l.ADD_FORBID_CONTENTS)&&(kt===wn&&(kt=Xn(kt)),Yt(kt,l.ADD_FORBID_CONTENTS,ge)),Sn&&(U["#text"]=!0),bt&&Yt(U,["html","head","body"]),U.table&&(Yt(U,["tbody"]),delete T.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw jr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw jr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const A=K;K=l.TRUSTED_TYPES_POLICY;try{je=dt("")}catch(z){throw K=A,z}}else l.TRUSTED_TYPES_POLICY===null?(K=void 0,je=""):(K===void 0&&(K=_t()),K&&typeof je=="string"&&(je=dt("")));Hn&&Hn(l),Zt=l},tn=Yt({},[...Ro,...Io,...fp]),Et=Yt({},[...Mo,...pp]),vt=function(l,y,A){return y.namespaceURI===qt?l==="svg":y.namespaceURI===mn?l==="svg"&&(A==="annotation-xml"||w[A]):!!tn[l]},xn=function(l,y,A){return y.namespaceURI===qt?l==="math":y.namespaceURI===Mn?l==="math"&&de[A]:!!Et[l]},it=function(l,y,A){return y.namespaceURI===Mn&&!de[A]||y.namespaceURI===mn&&!w[A]?!1:!Et[l]&&(Ee[l]||!tn[l])},ut=function(l){let y=Ne(l);(!y||!y.tagName)&&(y={namespaceURI:Fn,tagName:"template"});const A=ps(l.tagName),z=ps(y.tagName);return te[l.namespaceURI]?l.namespaceURI===Mn?vt(A,y,z):l.namespaceURI===mn?xn(A,y,z):l.namespaceURI===qt?it(A,y,z):!!(qe==="application/xhtml+xml"&&te[l.namespaceURI]):!1},Mt=function(l){Xr(e.removed,{element:l});try{Ne(l).removeChild(l)}catch{if(L(l),!Ne(l))throw jr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},un=function(l){const y=W(l);if(y){const z=[];cs(y,ke=>{Xr(z,ke)}),cs(z,ke=>{try{L(ke)}catch{}})}const A=Ke(l);if(A)for(let z=A.length-1;z>=0;--z){const ke=A[z],De=ke&&ke.name;if(typeof De=="string")try{l.removeAttribute(De)}catch{}}},pn=function(l,y){try{Xr(e.removed,{attribute:y.getAttributeNode(l),from:y})}catch{Xr(e.removed,{attribute:null,from:y})}if(y.removeAttribute(l),l==="is")if(Qt||yn)try{Mt(y)}catch{}else try{y.setAttribute(l,"")}catch{}},ye=function(l){const y=Ke(l);if(y)for(let A=y.length-1;A>=0;--A){const z=y[A],ke=z&&z.name;if(!(typeof ke!="string"||X[ge(ke)]))try{l.removeAttribute(ke)}catch{}}},Fe=function(l){const y=[l];for(;y.length>0;){const A=y.pop();(ve?ve(A):A.nodeType)===mr.element&&ye(A);const ke=W(A);if(ke)for(let De=ke.length-1;De>=0;--De)y.push(ke[De])}},gt=function(l){let y=null,A=null;if(ln)l="<remove></remove>"+l;else{const De=wi(l,/^[\r\n\t ]+/);A=De&&De[0]}qe==="application/xhtml+xml"&&Fn===qt&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const z=K?dt(l):l;if(Fn===qt)try{y=new g().parseFromString(z,qe)}catch{}if(!y||!y.documentElement){y=nt.createDocument(Fn,"template",null);try{y.documentElement.innerHTML=F?je:z}catch{}}const ke=y.body||y.documentElement;return l&&A&&ke.insertBefore(r.createTextNode(A),ke.childNodes[0]||null),Fn===qt?Rt.call(y,bt?"html":"body")[0]:bt?y.documentElement:ke},S=function(l){return yt.call(l.ownerDocument||l,l,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},C=function(l){return l=ds(l,Kt," "),l=ds(l,ot," "),l=ds(l,Bt," "),l},J=function(l){var y;l.normalize();const A=yt.call(l.ownerDocument||l,l,m.SHOW_TEXT|m.SHOW_COMMENT|m.SHOW_CDATA_SECTION|m.SHOW_PROCESSING_INSTRUCTION,null);let z=A.nextNode();for(;z;)z.data=C(z.data),z=A.nextNode();const ke=(y=l.querySelectorAll)===null||y===void 0?void 0:y.call(l,"template");ke&&cs(ke,De=>{Ge(De.content)&&J(De.content)})},pe=function(l){const y=ce?ce(l):null;return typeof y!="string"||ge(y)!=="form"?!1:typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||l.attributes!==Ke(l)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function"||l.nodeType!==ve(l)||l.childNodes!==W(l)},Ge=function(l){if(!ve||typeof l!="object"||l===null)return!1;try{return ve(l)===mr.documentFragment}catch{return!1}},Oe=function(l){if(!ve||typeof l!="object"||l===null)return!1;try{return typeof ve(l)=="number"}catch{return!1}};function ee(O,l,y){O.length!==0&&cs(O,A=>{A.call(e,l,y,Zt)})}const Re=function(l,y){return!!(Xe&&l.hasChildNodes()&&!Oe(l.firstElementChild)&&zn(Mi,l.textContent)&&zn(Mi,l.innerHTML)||Xe&&l.namespaceURI===qt&&y==="style"&&Oe(l.firstElementChild)||l.nodeType===mr.processingInstruction||Xe&&l.nodeType===mr.comment&&zn(kp,l.data))},V=function(l,y){if(!T[y]&&Ht(y)&&(Te.tagNameCheck instanceof RegExp&&zn(Te.tagNameCheck,y)||Te.tagNameCheck instanceof Function&&Te.tagNameCheck(y)))return!1;if(Sn&&!kt[y]){const A=Ne(l),z=W(l);if(z&&A){const ke=z.length;for(let De=ke-1;De>=0;--De){const ue=Cn?z[De]:$(z[De],!0);A.insertBefore(ue,B(l))}}}return Mt(l),!0},me=function(l){if(ee(ae.beforeSanitizeElements,l,null),pe(l))return Mt(l),!0;const y=ge(ce?ce(l):l.nodeName);if(ee(ae.uponSanitizeElement,l,{tagName:y,allowedTags:U}),Re(l,y))return Mt(l),!0;if(T[y]||!(q.tagCheck instanceof Function&&q.tagCheck(y))&&!U[y])return V(l,y);if((ve?ve(l):l.nodeType)===mr.element&&!ut(l)||(y==="noscript"||y==="noembed"||y==="noframes")&&zn(Sp,l.innerHTML))return Mt(l),!0;if(Me&&l.nodeType===mr.text){const z=C(l.textContent);l.textContent!==z&&(Xr(e.removed,{element:l.cloneNode()}),l.textContent=z)}return ee(ae.afterSanitizeElements,l,null),!1},ft=function(l,y,A){if(Z[y]||sn&&(y==="id"||y==="name")&&(A in r||A in on))return!1;const z=X[y]||q.attributeCheck instanceof Function&&q.attributeCheck(y,l);if(!(Ie&&zn(At,y))){if(!(Ae&&zn(It,y))){if(z){if(!Gn[y]){if(!zn(fe,ds(A,H,""))){if(!((y==="src"||y==="xlink:href"||y==="href")&&l!=="script"&&ki(A,"data:")===0&&In[l])){if(!(rt&&!zn(Q,ds(A,H,"")))){if(A)return!1}}}}}else if(!(Ht(l)&&(Te.tagNameCheck instanceof RegExp&&zn(Te.tagNameCheck,l)||Te.tagNameCheck instanceof Function&&Te.tagNameCheck(l))&&(Te.attributeNameCheck instanceof RegExp&&zn(Te.attributeNameCheck,y)||Te.attributeNameCheck instanceof Function&&Te.attributeNameCheck(y,l))||y==="is"&&Te.allowCustomizedBuiltInElements&&(Te.tagNameCheck instanceof RegExp&&zn(Te.tagNameCheck,A)||Te.tagNameCheck instanceof Function&&Te.tagNameCheck(A))))return!1}}return!0},mt=Yt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ht=function(l){return!mt[ps(l)]&&zn(Ye,l)},R=function(l,y,A,z){if(K&&typeof x=="object"&&typeof x.getAttributeType=="function"&&!A)switch(x.getAttributeType(l,y)){case"TrustedHTML":return dt(z);case"TrustedScriptURL":return ht(z)}return z},D=function(l,y,A,z){try{A?l.setAttributeNS(A,y,z):l.setAttribute(y,z),pe(l)?Mt(l):yi(e.removed)}catch{pn(y,l)}},se=function(l){ee(ae.beforeSanitizeAttributes,l,null);const y=l.attributes;if(!y||pe(l))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:X,forceKeepAttr:void 0};let z=y.length;const ke=ge(l.nodeName);for(;z--;){const De=y[z],ue=De.name,he=De.namespaceURI,be=De.value,We=ge(ue),lt=be;let Pe=ue==="value"?lt:op(lt);if(A.attrName=We,A.attrValue=Pe,A.keepAttr=!0,A.forceKeepAttr=void 0,ee(ae.uponSanitizeAttribute,l,A),Pe=A.attrValue,en&&(We==="id"||We==="name")&&ki(Pe,cn)!==0&&(pn(ue,l),Pe=cn+Pe),Xe&&zn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Pe)){pn(ue,l);continue}if(We==="attributename"&&wi(Pe,"href")){pn(ue,l);continue}if(!A.forceKeepAttr){if(!A.keepAttr){pn(ue,l);continue}if(!ne&&zn(Tp,Pe)){pn(ue,l);continue}if(Me&&(Pe=C(Pe)),!ft(ke,We,Pe)){pn(ue,l);continue}Pe=R(ke,We,he,Pe),Pe!==lt&&D(l,ue,he,Pe)}}ee(ae.afterSanitizeAttributes,l,null)},ze=function(l){let y=null;const A=S(l);for(ee(ae.beforeSanitizeShadowDOM,l,null);y=A.nextNode();)if(ee(ae.uponSanitizeShadowNode,y,null),me(y),se(y),Ge(y.content)&&ze(y.content),(ve?ve(y):y.nodeType)===mr.element){const ke=re(y);Ge(ke)&&(tt(ke),ze(ke))}ee(ae.afterSanitizeShadowDOM,l,null)},tt=function(l){const y=[{node:l,shadow:null}];for(;y.length>0;){const A=y.pop();if(A.shadow){ze(A.shadow);continue}const z=A.node,De=(ve?ve(z):z.nodeType)===mr.element,ue=W(z);if(ue)for(let he=ue.length-1;he>=0;--he)y.push({node:ue[he],shadow:null});if(De){const he=ce?ce(z):null;if(typeof he=="string"&&ge(he)==="template"){const be=z.content;Ge(be)&&y.push({node:be,shadow:null})}}if(De){const he=re(z);Ge(he)&&y.push({node:null,shadow:he},{node:he,shadow:null})}}};return e.sanitize=function(O){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,A=null,z=null,ke=null;if(F=!O,F&&(O="<!-->"),typeof O!="string"&&!Oe(O)&&(O=dp(O),typeof O!="string"))throw jr("dirty is not a string, aborting");if(!e.isSupported)return O;Ct?(U=wt,X=Pt):dn(l),(ae.uponSanitizeElement.length>0||ae.uponSanitizeAttribute.length>0)&&(U=Xn(U)),ae.uponSanitizeAttribute.length>0&&(X=Xn(X)),e.removed=[];const De=Cn&&typeof O!="string"&&Oe(O);if(De){const be=ce?ce(O):O.nodeName;if(typeof be=="string"){const We=ge(be);if(!U[We]||T[We])throw jr("root node is forbidden and cannot be sanitized in-place")}if(pe(O))throw jr("root node is clobbered and cannot be sanitized in-place");try{tt(O)}catch(We){throw un(O),We}}else if(Oe(O))y=gt("<!---->"),A=y.ownerDocument.importNode(O,!0),A.nodeType===mr.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?y=A:y.appendChild(A),tt(A);else{if(!Qt&&!Me&&!bt&&O.indexOf("<")===-1)return K&&An?dt(O):O;if(y=gt(O),!y)return Qt?null:An?je:""}y&&ln&&Mt(y.firstChild);const ue=S(De?O:y);try{for(;z=ue.nextNode();)me(z),se(z),Ge(z.content)&&ze(z.content)}catch(be){throw De&&un(O),be}if(De)return cs(e.removed,be=>{be.element&&Fe(be.element)}),Me&&J(O),O;if(Qt){if(Me&&J(y),yn)for(ke=Ft.call(y.ownerDocument);y.firstChild;)ke.appendChild(y.firstChild);else ke=y;return(X.shadowroot||X.shadowrootmode)&&(ke=Wt.call(s,ke,!0)),ke}let he=bt?y.outerHTML:y.innerHTML;return bt&&U["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&zn(yp,y.ownerDocument.doctype.name)&&(he="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
|
|
83
|
-
`+he),Me&&(he=C(he)),K&&An?dt(he):he},e.setConfig=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dn(O),Ct=!0,wt=U,Pt=X},e.clearConfig=function(){Zt=null,Ct=!1,wt=null,Pt=null,K=Qe,je=""},e.isValidAttribute=function(O,l,y){Zt||dn({});const A=ge(O),z=ge(l);return ft(A,z,y)},e.addHook=function(O,l){typeof l=="function"&&Pn(ae,O)&&Xr(ae[O],l)},e.removeHook=function(O,l){if(Pn(ae,O)){if(l!==void 0){const y=rp(ae[O],l);return y===-1?void 0:sp(ae[O],y,1)[0]}return yi(ae[O])}},e.removeHooks=function(O){Pn(ae,O)&&(ae[O]=[])},e.removeAllHooks=function(){ae=$i()},e}var Da=Ac();nn.setOptions({gfm:!0,breaks:!0});const Oi=80;function Cr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Ep={code(n){const{text:e,lang:r}=n,s=(r??"").trim().split(/\s+/)[0]??"",a=e.split(`
|
|
84
|
-
`).filter(x=>x.trim()!==""),i=a.length>1,u=`<pre><code>${Cr(e)}</code></pre>`;if(!i)return u;let v=a[0]??"";return v.length>Oi?v=v.slice(0,Oi)+"…":a.length>1&&(v+=" …"),`<details class="code-collapsible"><summary>${s?`<span class="code-lang">${Cr(s)}</span> ${Cr(v)}`:Cr(v)}</summary>${u}</details>`}};nn.use({renderer:Ep});let Li=!1;function Cc(){Li||typeof window>"u"||(Li=!0,Da.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))}))}function Rp(n){if(!n)return"";const e=nn.parse(n,{async:!1});return typeof window>"u"?"":(Cc(),Da.sanitize(e,{ADD_ATTR:["target","rel"],ADD_TAGS:["details","summary"]}))}const Ip=/\b(https?:\/\/[^\s<]+|www\.[^\s<]+)/gi;function Mp(n){if(!n||typeof window>"u")return"";let e="",r=0;for(const s of n.matchAll(Ip)){const o=s.index??0;e+=Cr(n.slice(r,o));let a=s[0],i="";const u=a.match(/[.,;:!?)\]}'"]+$/);u&&(i=u[0],a=a.slice(0,a.length-i.length));const m=a.startsWith("www.")?`https://${a}`:a;e+=`<a href="${Cr(m)}">${Cr(a)}</a>`,e+=Cr(i),r=o+s[0].length}return e+=Cr(n.slice(r)),Cc(),Da.sanitize(e,{ADD_ATTR:["target","rel"]})}const Di=new Map;function $p(n,e){const r=`${n}:${e.length}`;let s=Di.get(r);return s===void 0&&(s=Rp(e),Di.set(r,s)),s}const Pi=new Map;function Op(n){let e=Pi.get(n);return e===void 0&&(e=Mp(n),Pi.set(n,e)),e}function Lp(n){if(n>=1e6){const e=n/1e6;return(e>=10?Math.round(e).toString():e.toFixed(1))+"M"}return n>=1e3?Math.round(n/1e3)+"K":String(n)}function Dp(n){return new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Pp(n){if(!n)return{cleanContent:"",attachments:[],skill:null};const e=la(n);if(e)return{cleanContent:"",attachments:[],skill:e};const r=n.split(`
|
|
85
|
-
`),s=/^\[Uploaded file: (.+)\]$/,o=[],a=[];for(const u of r){const m=u.match(s);m?a.push(m[1]):o.push(u)}let i=o.join(`
|
|
86
|
-
`).trim();return i==="I have uploaded the following file(s) for you:"&&(i=""),{cleanContent:i,attachments:a,skill:null}}function Np(n){if(!n)return null;const e=n.trim();if(!e)return null;if(e.startsWith("{"))try{return JSON.parse(e)}catch{}const r={},s=/([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+))/g;let o;for(;(o=s.exec(e))!==null;){const a=o[1],i=o[2]!==void 0?o[2]:o[3]!==void 0?o[3]:o[4];r[a]=i}return Object.keys(r).length>0?r:null}function Up(n,e,r){if(!e)return r?r.trim():"";const s=n.toLowerCase();if(["read","write","edit","ls"].includes(s)){const a=e.path||e.filepath||e.file;if(a)return String(a)}if(s==="bash"){const a=e.command||e.cmd;if(a){const i=String(a).replace(/\s+/g," ").trim();return i.length>50?i.slice(0,47)+"...":i}}if(s==="grep"){const a=e.pattern,i=e.path;if(a)return i?`"${a}" in ${i}`:`"${a}"`}if(s==="find"){const a=e.pattern||e.path;if(a)return String(a)}const o=e.path||e.filepath||e.file||e.name||e.query;return o?String(o):Object.entries(e).filter(([a,i])=>i!==void 0&&i!=="").map(([a,i])=>`${a}=${typeof i=="object"?JSON.stringify(i):i}`).join(" ")}function Fp(n,e){return n?JSON.stringify(n,null,2):e?e.trim():""}function ea(n){return n==="attach_file"||n==="say"}function Js(n){return n.role==="tool"&&n.forceCommand===!0}function Bp(n,e){return Js(n)}function Ni(n){let e=n.toolName||"tool",r=n.toolArgs!==void 0?n.toolArgs:"",s=n.toolOutput!==void 0?n.toolOutput:"",o=!!n.isError;if(!r&&!s&&n.content){let m=n.content||"";m.startsWith("Error: ")?(o=!0,m=m.slice(7)):m.startsWith("Tool error: ")&&(o=!0,m=m.slice(12));const v=m.indexOf(`
|
|
87
|
-
`),g=v!==-1?m.slice(0,v):m;s=v!==-1?m.slice(v+1):"";let x=g.trim();x.startsWith("$ ")&&(x=x.slice(2));const _=x.indexOf(" ");e=n.toolName||(_!==-1?x.slice(0,_):x)||"tool",r=_!==-1?x.slice(_+1):""}const a=Np(r),i=Up(e,a,r),u=Fp(a,r);return{toolName:e,smartTitleArgs:i,fullArgs:u,toolOutput:s,isError:o,interrupted:!!n.interrupted,downloadPath:lf(e,a,o),sayText:e==="say"?Ku(a):null}}function Ns(n,e){if(n.startedAt===void 0)return null;const r=n.endedAt??(n.isStreaming?e:void 0);return r===void 0?null:`${(Math.max(0,r-n.startedAt)/1e3).toFixed(1)}s`}function zp(n,e,r){const s=n.filter(a=>a.role==="thinking"&&e.hideThinking?!1:a.role==="tool"&&e.hideTools&&!ea(a.toolName)?Js(a)||!!a.isStreaming:a.role!=="assistant"&&a.role!=="thinking"||a.isStreaming||a.content.trim()!==""),o=s.some(a=>a.isStreaming);if(r&&!o){const a=n.some(i=>i.role==="thinking"&&i.isStreaming);s.push({id:"fallback-loader-message-id",role:"thinking",content:a?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return s}function Ui(){return typeof localStorage>"u"?"":localStorage.getItem("wherever-speech-locale")||""}function Hp(n){for(let e=n.length-1;e>=0;e--){const r=n[e];if(r.role==="user")return null;if(!(r.role!=="assistant"||r.isStreaming))return{id:r.id,text:typeof r.content=="string"?r.content:""}}return null}function Fi(n){return n.scrollHeight-n.scrollTop-n.clientHeight<=20}var jp=b('<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="text-center"><div class="mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <p class="text-base font-medium text-brand-text">Connecting to Wherever Server...</p> <p class="mt-1 text-xs text-brand-text-muted">Establishing secure connection to your agent</p></div></div>'),Gp=b('<p class="mt-3 max-h-24 overflow-y-auto rounded bg-brand-surface-3 p-2 font-mono text-xs text-rose-300/80"> </p>'),Wp=b(`<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="w-full max-w-md rounded-lg border border-red-500/30 bg-red-500/10 p-6 text-center text-brand-text"><div class="mb-3 text-4xl">⚠️</div> <h3 class="text-lg font-bold text-rose-400">Not Connected to Server</h3> <p class="mt-2 text-sm text-brand-text-muted">We couldn't connect to the Wherever Server. Please verify the server
|
|
88
|
-
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>`),Kp=b('<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="text-center"><div class="mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <p class="text-base font-medium text-brand-text">Loading session...</p> <p class="mt-1 text-xs text-brand-text-muted">Retrieving workspace session history</p></div></div>'),qp=b('<button type="button" class="block w-full px-3 py-1.5 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"> </button>'),Vp=b('<div class="absolute right-0 left-0 z-50 mt-1 max-h-48 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl"></div>'),Yp=b('<span class="ml-1 font-medium text-emerald-400">(Git repo detected)</span>'),Xp=b('<span class="mt-1.5 block text-xs font-medium text-yellow-400">📁 Folder already exists. Joining will create a session in it. <!></span>'),Zp=b('<span class="mt-1 block text-[10px] text-brand-text-muted">Relative paths are created inside your home folder.</span>'),Jp=b("<option> </option>"),Qp=b('<select id="main-model-select" class="w-full rounded border border-brand-border bg-brand-surface-3 px-3 py-2 text-sm text-brand-text focus:border-brand-blue focus:outline-none"></select>'),eh=b('<input id="main-model-select" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-surface-3 px-3 py-2 text-sm text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/>'),th=b('<div class="flex items-center gap-4 pl-6 text-xs text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="main-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="main-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),nh=b('<div class="space-y-1.5 pt-1"><div class="flex items-center gap-2"><input id="main-create-remote" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="main-create-remote" class="cursor-pointer text-sm text-brand-text select-none"> </label></div> <!></div>'),rh=b('<div class="flex items-center gap-2 pt-1"><input id="main-git-init" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="main-git-init" class="cursor-pointer text-sm text-brand-text select-none">Initialize Git repository</label></div>'),sh=b(`<div class="flex flex-1 items-center justify-center p-6"><div class="w-full max-w-md rounded-lg border border-brand-border bg-brand-surface/40 p-6 text-brand-text"><div class="mb-5 text-center"><div class="mb-3 flex justify-center"><img alt="Wherever" class="h-16 w-16"/></div> <h2 class="mb-1 text-2xl font-bold"><span class="gradient-text">Wherever</span></h2> <h3 class="text-sm font-semibold text-brand-text">Create a New Session</h3> <p class="mt-1 text-xs text-brand-text-muted">Start a coding session in any folder on your machine, or use the
|
|
89
|
-
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"> </button></form></div></div>`),oh=b('<div class="flex flex-1 flex-col items-center justify-center bg-brand-dark p-6 text-brand-text-muted"><div class="text-center"><div class="mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <p class="text-base font-medium text-brand-text">Loading conversation...</p> <p class="mt-1 text-xs text-brand-text-muted">Retrieving workspace session history</p></div></div>'),ah=b('<div class="flex flex-1 items-center justify-center text-brand-text-muted"><div class="text-center"><div class="mb-4 text-4xl">💬</div> <p class="mb-2 text-lg font-medium text-brand-text">New Session Started</p> <p class="text-sm">Type a message below to start building</p></div></div>'),ih=b('<div class="flex justify-center pb-2"><button class="rounded border border-brand-border bg-brand-surface-2 px-3 py-1.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50"><!></button></div>'),lh=b('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent is thinking...</span></div>'),ch=b('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent working...</span></div>'),dh=b('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-brand-cyan" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Agent is thinking...</span></div>'),uh=b('<div class="mb-1 flex items-center gap-1.5 text-[10px] font-bold tracking-wider text-brand-cyan uppercase select-none"><span class="inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-brand-cyan"></span> <span>Thinking</span></div>'),fh=b('<div class="flex flex-col gap-1"><!> <div class="font-mono text-sm whitespace-pre-wrap"> </div></div>'),ph=b('<span class="font-mono text-xs text-brand-text-muted tabular-nums"> </span>'),hh=b('<div class="flex items-center gap-2 font-sans text-sm text-brand-text-muted italic select-none"><svg class="h-4 w-4 animate-spin text-amber-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Running tool: <span class="rounded bg-brand-surface-3 px-1 py-0.5 font-mono text-xs font-semibold"> </span>...</span> <!></div>'),bh=b('<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>'),vh=b('<span class="text-xs break-words text-brand-text-muted"> </span>'),gh=b('<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>'),mh=b('<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>'),xh=b('<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>'),_h=b('<a target="_blank" rel="noopener noreferrer" class="mt-2 block"><img loading="lazy" class="max-h-96 max-w-full rounded border border-brand-border/40 bg-brand-dark/60 object-contain"/></a>'),yh=b('<audio controls="" preload="metadata" class="mt-2 block w-full max-w-full"></audio>'),wh=b('<video controls="" playsinline="" preload="metadata" class="mt-2 block max-h-96 w-full max-w-full rounded border border-brand-border/40 bg-brand-dark/60"></video>',2),kh=b('<div class="flex max-w-full min-w-[240px] flex-col"><!> <!> <!> <!></div>'),Sh=b('<span class="text-xs break-words text-brand-text-muted"> </span>'),Th=b('<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 speak</span> <!></span></div>'),Ah=b('<div class="flex items-start gap-3 rounded-lg border border-brand-cyan/40 bg-brand-cyan/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-1"><span class="text-[11px] font-semibold tracking-wide text-brand-cyan uppercase select-none">spoken:</span> <span class="text-sm break-words text-brand-text"> </span></span></div>'),Ch=b('<div class="flex max-w-full min-w-[240px] flex-col"><!></div>'),Eh=b('<span class="inline-block animate-spin font-bold text-amber-400">⚡</span>'),Rh=b('<span class="font-bold text-rose-400" title="Failed">❌</span>'),Ih=b('<span class="font-bold text-brand-text-muted" title="Interrupted, no result (the running tool was stopped, e.g. by a CLI takeover)">⊘</span>'),Mh=b('<span class="font-bold text-emerald-400" title="Succeeded">✅</span>'),$h=b('<span class="max-w-[180px] truncate font-mono text-xs text-brand-text-muted sm:max-w-[300px] md:max-w-[450px]"> </span>'),Oh=b("<span> </span>"),Lh=b('Collapse <span class="text-[10px]">▲</span>',1),Dh=b('Expand <span class="text-[10px]">▼</span>',1),Ph=b('<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>'),Nh=b('<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>'),Uh=b('<a target="_blank" rel="noopener noreferrer" class="mt-2 block"><img loading="lazy" class="max-h-96 max-w-full rounded border border-brand-border/40 bg-brand-dark/60 object-contain"/></a>'),Fh=b('<audio controls="" preload="metadata" class="mt-2 block w-full max-w-full"></audio>'),Bh=b('<video controls="" playsinline="" preload="metadata" class="mt-2 block max-h-96 w-full max-w-full rounded border border-brand-border/40 bg-brand-dark/60"></video>',2),zh=b('<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>'),Hh=b('<div class="mt-2 flex flex-col gap-1"><div class="flex flex-wrap gap-2"></div></div>'),jh=b('<div class="flex flex-col gap-1"><span class="font-sans text-[10px] font-bold tracking-wider text-brand-text-muted uppercase">Arguments</span> <pre class="max-h-40 overflow-x-auto rounded border border-brand-border/30 bg-brand-dark/60 p-1.5 font-mono text-[11px] whitespace-pre-wrap text-amber-400"> </pre></div>'),Gh=b('<pre class="max-h-96 overflow-x-auto rounded border border-brand-border/40 bg-brand-dark/60 p-2 font-mono text-xs whitespace-pre-wrap text-brand-text"> </pre>'),Wh=b('<div class="animate-pulse p-1 text-xs text-brand-text-muted italic">Running and waiting for output...</div>'),Kh=b(`<div class="p-1 text-xs text-brand-text-muted italic">Interrupted before a result was returned (the
|
|
90
|
-
running tool was stopped, e.g. by a CLI takeover).
|
|
91
|
-
Its outcome is unknown.</div>`),qh=b('<div class="p-1 text-xs text-brand-text-muted italic">No output returned</div>'),Vh=b('<div class="mt-2 flex flex-col gap-3 overflow-hidden border-t border-brand-border/40 pt-2"><!> <div class="flex flex-col gap-1"><span class="font-sans text-[10px] font-bold tracking-wider text-brand-text-muted uppercase">Output</span> <!></div></div>'),Yh=b('<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>'),Xh=b('<pre class="chat-selectable font-sans text-sm leading-relaxed wrap-anywhere 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>'),Zh=b("<pre> </pre>"),Jh=b("<div></div>"),Qh=eo('<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="text-brand-green h-3.5 w-3.5"><path d="M20 6 9 17l-5-5"></path></svg> Copied',1),eb=eo('<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-3.5 w-3.5"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg> Copy',1),tb=eo('<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-3.5 w-3.5"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"></path><circle cx="12" cy="12" r="3"></circle></svg> Rendered',1),nb=eo('<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-3.5 w-3.5"><path d="m18 16 4-4-4-4"></path><path d="m6 8-4 4 4 4"></path><path d="m14.5 4-5 16"></path></svg> Raw',1),rb=b('<button type="button" class="mt-1 flex w-fit items-center gap-1 rounded px-1.5 py-0.5 text-xs font-medium text-brand-text-muted transition-colors select-none hover:bg-brand-surface-3/30 hover:text-brand-text" title="Show the full written reply (collapsed while conversation mode focuses the spoken summary)">Show full reply <span class="text-[10px]">▼</span></button>'),sb=b('<button type="button" class="mt-1 flex w-fit items-center gap-1 rounded px-1.5 py-0.5 text-xs font-medium text-brand-text-muted transition-colors select-none hover:bg-brand-surface-3/30 hover:text-brand-text" title="Collapse this long reply again">Collapse <span class="text-[10px]">▲</span></button>'),ob=b('<div class="group flex flex-col"><!> <div class="mt-1 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100"><button type="button" class="flex items-center gap-1 rounded px-1.5 py-0.5 text-xs font-medium text-brand-text-muted transition-colors select-none hover:bg-brand-surface-3/30 hover:text-brand-text" title="Copy this message to the clipboard"><!></button> <button type="button" class="flex items-center gap-1 rounded px-1.5 py-0.5 text-xs font-medium text-brand-text-muted transition-colors select-none hover:bg-brand-surface-3/30 hover:text-brand-text"><!></button></div> <!></div>'),ab=b('<div class="text-sm leading-relaxed wrap-anywhere whitespace-pre-wrap"> </div>'),ib=b('<div class="chat-selectable flex flex-col gap-1.5"><span class="inline-flex w-fit items-center gap-1.5 rounded bg-brand-blue/25 px-2 py-0.5 font-mono text-xs font-medium text-brand-text ring-1 ring-brand-blue/40" title="Skill invocation (expanded for the agent)"><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-3.5 w-3.5"><path d="M13 2 3 14h7l-1 8 10-12h-7l1-8z"></path></svg> <span> </span></span> <!></div>'),lb=b("<span></span>"),cb=b('<span class="text-brand-text-muted italic"> </span>'),db=b('<span class="ml-1 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan"></span>'),ub=b('<div class="chat-selectable text-sm leading-relaxed wrap-anywhere whitespace-pre-wrap"><!> <!></div>'),fb=b('<div class="flex items-center gap-1.5 rounded bg-brand-blue/20 px-2 py-1 font-mono text-xs text-brand-text select-all"><span>📎</span> <span class="truncate"> </span></div>'),pb=b('<div class="mt-2 flex flex-col gap-1 border-t border-brand-blue/20 pt-2"></div>'),hb=b("<!> <!>",1),bb=b('<span class="inline-block h-3 w-3 animate-spin rounded-full border border-brand-text-muted border-t-transparent" title="Sending, awaiting confirmation" aria-label="Sending"></span> <span title="Sending, awaiting confirmation">Sending</span> <span>·</span>',1),vb=b('<div class="mt-1 flex justify-end"><button type="button" class="inline-flex items-center gap-1 rounded border border-brand-border/60 bg-brand-surface-3/60 px-2 py-0.5 text-xs font-medium text-brand-text-muted transition-colors hover:border-brand-blue hover:bg-brand-blue/15 hover:text-brand-blue" title="Fork the conversation from this message (edit and resend)" aria-label="Fork from this message"><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-3.5 w-3.5"><circle cx="6" cy="6" r="2.2"></circle><circle cx="6" cy="18" r="2.2"></circle><circle cx="18" cy="8" r="2.2"></circle><path d="M6 8.2v7.6"></path><path d="M18 10.2c0 3-3 3.8-6 3.8"></path></svg> Fork</button></div>'),gb=b('<div class="mt-1.5 flex items-center justify-end gap-1 text-xs font-medium text-brand-text-muted"><span class="inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-amber-400"></span> Queued (not yet sent to the agent)</div>'),mb=b('<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>'),xb=b("<div><!> </div> <!> <!> <!>",1),_b=b("<div><div><!> <!></div></div>"),yb=b('<div class="flex-1 space-y-4 overflow-y-auto overscroll-y-contain p-4"><!> <!></div>'),wb=b('<button type="button" aria-label="Cycle waiting-for-human beep for this session"><span> </span> <span> </span></button>'),kb=b('<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>'),Sb=b('<button class="rounded border border-amber-400/50 bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text-muted transition-colors hover:bg-rose-500/80 hover:text-brand-text"> </button>'),Tb=b('<span class="ml-1 text-xs text-brand-text-muted">(already a Git repository)</span>'),Ab=b('<span class="ml-1 text-xs font-medium text-yellow-500">(folder not empty)</span>'),Cb=b('<div class="flex items-center gap-4 pl-6 text-xs text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1.5 transition-colors select-none hover:text-brand-text"><input type="radio" name="modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),Eb=b('<div class="space-y-1.5"><div class="flex items-center gap-2"><input id="modal-create-remote" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> <label for="modal-create-remote" class="cursor-pointer text-sm text-brand-text select-none"> </label></div> <!></div>'),Rb=b('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4" role="dialog" aria-modal="true"><div class="w-full max-w-sm rounded-lg border border-brand-border bg-brand-surface-2 p-6 text-brand-text"><h3 class="mb-2 text-base font-bold text-brand-text">Folder Already Exists</h3> <p class="mb-4 text-sm text-brand-text-muted">The folder <span class="font-mono text-xs text-brand-text"> </span> already exists. Do you want to initialize a Git repository in it?</p> <div class="mb-6 flex flex-col gap-3.5"><div class="flex items-center gap-2"><input id="modal-git-init" type="checkbox" class="h-4 w-4 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50"/> <label for="modal-git-init" class="cursor-pointer text-sm text-brand-text select-none disabled:opacity-50">Initialize Git repository <!></label></div> <!></div> <div class="flex justify-end gap-2.5"><button type="button" class="rounded bg-brand-surface-3 px-3.5 py-1.5 text-xs font-semibold text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button type="button" class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3.5 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Confirm & Create</button></div></div></div>'),Ib=b('<p class="mb-4 rounded bg-brand-surface-3 px-2.5 py-1.5 font-mono text-xs break-all text-brand-text-muted"> </p>'),Mb=b('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4" role="dialog" aria-modal="true"><div class="w-full max-w-sm rounded-lg border border-brand-border bg-brand-surface-2 p-6 text-brand-text"><h3 class="mb-2 text-base font-bold text-brand-text">Remote Repository Already Exists</h3> <p class="mb-3 text-sm text-brand-text-muted"> <span class="font-mono text-xs text-brand-text"> </span> already exists. Do you want to clone it instead of creating a new one?</p> <!> <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">Create New Instead</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">Clone Repository</button></div></div></div>'),$b=b('<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> <!> <button type="button" aria-label="Toggle conversation mode"><span> </span> <span> </span></button> <!></div> <div class="flex items-center gap-2"><!> <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> <!> <!></div>');function Ob(n,e){hr(e,!0);const r=()=>we(gn,"$piState",ce),s=()=>we(sa,"$availableModels",ce),o=()=>we(oa,"$gitInitDefaultStore",ce),a=()=>we(rs,"$activeSessionInfo",ce),i=()=>we(Es,"$isLoadingSession",ce),u=()=>we(Rs,"$isResyncing",ce),m=()=>we(co,"$isReadOnly",ce),v=()=>we(da,"$beepSessionOverride",ce),g=()=>we(ua,"$beepEnabled",ce),x=()=>we(ha,"$conversationMode",ce),_=()=>we(pa,"$conversationModeSessionOverride",ce),$=()=>we(yl,"$collapseLongReplies",ce),L=()=>we(Xl,"$messages",ce),B=()=>we(_l,"$speakReplies",ce),W=()=>we(_a,"$isStreaming",ce),Ne=()=>we(lo,"$sessionError",ce),re=()=>we(sc,"$hasMoreHistory",ce),Ke=()=>we(oc,"$isLoadingMoreHistory",ce),ve=()=>we(Ql,"$pendingSteering",ce),[ce,K]=Ur(),je=[];let Qe=P(()=>{const R=r().contextUsage;if(!R||!R.contextWindow)return null;const D=Lp(R.contextWindow);return R.percent==null?`– / ${D}`:`${R.percent.toFixed(1)}% / ${D}`}),Ue=N(""),oe=N(Vn([])),et=N(!1),dt=N(null),ht=N(null),_t="",Be=N(""),nt=N(!1),yt=N(null),Ft=N(!0),Rt=N("private"),Wt=N(!1),ae=N(!1),Kt=N(!1),ot=N(null);function Bt(R){yr(t(Ue).trim(),t(Be)||void 0,R?!1:t(nt),R?!1:t(H).matchingRule?t(Ft):void 0,R?void 0:t(H).matchingRule?t(Rt):void 0,R||void 0)}let At=P(r),It=P(s),Q=P(o);Ut(()=>{t(yt)===null&&p(nt,t(Q),!0)});let H=N(Vn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),Ye=P(()=>t(H).exists!==!0&&t(H).matchingRule&&t(Ft)),fe=null;async function U(R,D=!1){if(fe&&clearTimeout(fe),R===_t&&!D)return;if(_t=R,!R.trim()){p(H,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const ze=async()=>{const tt=await Ks("");p(oe,tt||[],!0)};D?await ze():fe=setTimeout(ze,300);return}const se=async()=>{const[ze,tt]=await Promise.all([Vi(R),Ks(R)]);p(oe,tt||[],!0),ze?(p(H,{exists:ze.exists,isGit:ze.isGit,resolvedPath:ze.resolvedPath,matchingRule:ze.matchingRule||null},!0),ze.exists||(p(nt,t(yt)!==null?t(yt):t(Q),!0),p(Ft,!0),ze.matchingRule&&p(Rt,ze.matchingRule.visibility,!0))):p(H,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};D?await se():fe=setTimeout(se,300)}Ut(()=>{const R=t(Ue);U(R,!1)}),Ut(()=>{if(t(It).models.length>0&&!t(Be)){const R=t(It).models.find(D=>D.isDefault);R?p(Be,`${R.provider}:${R.modelId}`):p(Be,`${t(It).models[0].provider}:${t(It).models[0].modelId}`)}});async function Se(){if(t(Ue).trim()){if(t(H).exists===!0){p(nt,!1),p(Ft,!1),t(H).matchingRule&&p(Rt,t(H).matchingRule.visibility,!0),p(Wt,!0);return}if(t(H).matchingRule&&t(Ft)){p(Kt,!0);try{const R=await pd(t(Ue).trim());if(R&&R.matched&&R.exists){p(ot,{provider:R.provider,sshUrl:R.sshUrl},!0),p(ae,!0);return}}finally{p(Kt,!1)}}Bt(!1)}}let X=N(void 0),le=P(a),Te=P(i),T=P(u),Z=P(m);function q(R){if(!R)return;const D=t(le).sessionId;D&&Fl(D,R)}let Ae=P(v),Ie=P(g),rt=P(x),ne=P(()=>_()===void 0);function Me(){uo(),Al(!t(rt))}let Xe=P(()=>es("collapseLongReplies",{conversationMode:x(),autoSendOnSpeechEnd:!1,speakReplies:!1,collapseLongReplies:$(),micReopensAfterReply:!1}));const bt=new Set;let Ct=!1;Ut(()=>{const R=L();B();for(const D of R){if(D.role!=="tool"||D.toolName!=="say"||D.isStreaming||bt.has(D.id)||(bt.add(D.id),D.isError)||!es("speakReplies",ns()))continue;const se=Ni(D);se.sayText&&(Ct=!0,pi(se.sayText,Ui()))}}),Ut(()=>{x(),B(),es("speakReplies",ns())&&Zu()});let wt=!1;const Pt=new Set;Ut(()=>{const R=L(),D=W();if(B(),D&&!wt)Ct=!1;else if(!D&&wt){const se=Hp(R);se&&!Pt.has(se.id)&&(Pt.add(se.id),df({active:es("speakReplies",ns()),spokeThisTurn:Ct,reply:se.text})&&pi(uc(se.text),Ui())),Ct=!1}wt=D});function ln(){t(Ae)===void 0?zs(!0):t(Ae)===!0?zs(!1):zs(void 0)}let Qt=P(()=>!!t(le).sessionFile),yn=P(()=>!!Ne()&&!t(Te)&&!t(T)&&!t(Qt)),An=N(!0),sn=N(!1),en=Vn({});function cn(R,D){en[R]=!D}let Sn=Vn({});function Cn(R){Sn[R]=!Sn[R]}let at=N(null),kt=null;async function wn(R,D){try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(D);else{const se=document.createElement("textarea");se.value=D,se.style.position="fixed",se.style.opacity="0",document.body.appendChild(se),se.select(),document.execCommand("copy"),document.body.removeChild(se)}p(at,R,!0),kt&&clearTimeout(kt),kt=setTimeout(()=>{p(at,null),kt=null},1500)}catch(se){console.error("Failed to copy message",se)}}function In(){t(X)&&p(An,Fi(t(X)),!0)}function Rn(){t(X)&&(t(X).scrollTop=t(X).scrollHeight)}function Gn(){(t(An)||t(sn))&&(Rn(),p(sn,!1))}ys(Rn),Ut(()=>{if(t(X))return t(X).addEventListener("scroll",In),()=>{t(X)&&t(X).removeEventListener("scroll",In)}});let kn=N(null),mn=N(!1);function Mn(){p(sn,!0),Rn(),requestAnimationFrame(()=>{Rn(),requestAnimationFrame(Rn)}),setTimeout(Rn,60),setTimeout(Rn,150)}Ut(()=>{const R=t(le).sessionFile;R!==t(kn)&&(p(kn,R,!0),p(sn,!0));const D=t(Te);t(mn)&&!D&&Mn(),p(mn,D,!0)});let qt=P(()=>zp(L(),{hideThinking:r().hideThinking,hideTools:r().hideTools},t(Fn))),Fn=P(W),F=N(Vn(Date.now())),te=P(()=>t(qt).some(R=>R.role==="tool"&&R.isStreaming));Ut(()=>{if(!t(te))return;p(F,Date.now(),!0);const R=setInterval(()=>p(F,Date.now(),!0),100);return()=>clearInterval(R)}),od(()=>{const R=t(qt)[t(qt).length-1];R&&`${t(qt).length}${R.content.length}`,t(X)&&p(An,Fi(t(X)),!0)}),Ut(()=>{const R=t(qt)[t(qt).length-1];R&&`${t(qt).length}${R.content.length}`,Gn()});function Ce(){p(sn,!0),setTimeout(Rn,0)}let $e=P(re),w=P(Ke);const G=64;let de=N(null),Ee=N(null);function qe(){!t(X)||t(w)||!t($e)||(p(de,t(qt)[0]?.id??null,!0),p(Ee,t(X).scrollHeight-t(X).scrollTop),zl())}Ut(()=>{if(L().length,(t(de)!==null||t(Ee)!==null)&&t(X)){const R=t(de),D=t(Ee);p(de,null),p(Ee,null),requestAnimationFrame(()=>{if(!t(X))return;const se=R?t(X).querySelector(`[data-msg-id="${CSS.escape(R)}"]`):null;if(se){const ze=se.getBoundingClientRect().top-t(X).getBoundingClientRect().top;t(X).scrollTop=Math.max(0,t(X).scrollTop+ze-G)}else D!==null&&(t(X).scrollTop=t(X).scrollHeight-D)})}});var Le={forceScrollToBottom:Ce},_e=$b(),ge=d(_e);{var Zt=R=>{var D=jp();h(R,D)},on=R=>{var D=Wp(),se=d(D),ze=f(d(se),6);{var tt=l=>{var y=Gp(),A=d(y,!0);c(y),E(()=>I(A,t(At).error)),h(l,y)};k(ze,l=>{t(At).error&&l(tt)})}var O=f(ze,2);c(se),c(D),M("click",O,()=>{xd(()=>Promise.resolve().then(()=>Wu),void 0,import.meta.url).then(l=>l.connect())}),h(R,D)},zt=R=>{var D=Kp();h(R,D)},dn=R=>{var D=sh(),se=d(D),ze=d(se),tt=d(ze),O=d(tt);c(tt),pt(6),c(ze);var l=f(ze,2),y=d(l),A=f(d(y),2),z=d(A);Tt(z),ir(z,j=>p(dt,j),()=>t(dt));var ke=f(z,2);{var De=j=>{var ie=Vp();Ln(ie,21,()=>t(oe),pr,(st,xt)=>{var ct=qp(),Ze=d(ct,!0);c(ct),E(()=>I(Ze,t(xt))),M("click",ct,()=>{p(Ue,t(xt),!0),U(t(xt),!0),t(dt)?.focus()}),h(st,ct)}),c(ie),h(j,ie)};k(ke,j=>{t(et)&&t(oe).length>0&&j(De)})}c(A),ir(A,j=>p(ht,j),()=>t(ht));var ue=f(A,2);{var he=j=>{var ie=Xp(),st=f(d(ie));{var xt=ct=>{var Ze=Yp();h(ct,Ze)};k(st,ct=>{t(H).isGit&&ct(xt)})}c(ie),h(j,ie)},be=j=>{var ie=Zp();h(j,ie)};k(ue,j=>{t(H).exists===!0?j(he):j(be,-1)})}c(y);var We=f(y,2),lt=f(d(We),2);{var Pe=j=>{var ie=Qp();Ln(ie,21,()=>t(It).models,pr,(st,xt)=>{var ct=Jp(),Ze=d(ct);c(ct);var Gt={};E(()=>{I(Ze,`${t(xt).label??""}${t(xt).isDefault?" (default)":""}`),Gt!==(Gt=`${t(xt).provider}:${t(xt).modelId}`)&&(ct.value=ct.__value=`${t(xt).provider}:${t(xt).modelId}`)}),h(st,ct)}),c(ie),xs(ie,()=>t(Be),st=>p(Be,st)),h(j,ie)},$t=j=>{var ie=eh();Tt(ie),ar(ie,()=>t(Be),st=>p(Be,st)),h(j,ie)};k(lt,j=>{t(It).models.length>0?j(Pe):j($t,-1)})}c(We);var fn=f(We,2);{var hn=j=>{var ie=nh(),st=d(ie),xt=d(st);Tt(xt);var ct=f(xt,2),Ze=d(ct);c(ct),c(st);var Gt=f(st,2);{var Vt=bn=>{var Yn=th(),Bn=f(d(Yn),2),$n=d(Bn);Tt($n),$n.value=$n.__value="private",pt(),c(Bn);var Wn=f(Bn,2),Tn=d(Wn);Tt(Tn),Tn.value=Tn.__value="public",pt(),c(Wn),c(Yn),Nr(je,[],$n,()=>t(Rt),On=>p(Rt,On)),Nr(je,[],Tn,()=>t(Rt),On=>p(Rt,On)),h(bn,Yn)};k(Gt,bn=>{t(Ft)&&bn(Vt)})}c(ie),E(()=>I(Ze,`Create remote ${t(H).matchingRule.provider??""} repository`)),Zn(xt,()=>t(Ft),bn=>p(Ft,bn)),h(j,ie)};k(fn,j=>{t(H).exists!==!0&&t(H).matchingRule&&j(hn)})}var jt=f(fn,2);{var Ot=j=>{var ie=rh(),st=d(ie);Tt(st),pt(2),c(ie),M("change",st,xt=>{p(yt,xt.currentTarget.checked,!0)}),Zn(st,()=>t(nt),xt=>p(nt,xt)),h(j,ie)};k(jt,j=>{t(H).exists!==!0&&(!t(H).matchingRule||!t(Ft))&&j(Ot)})}var xe=f(jt,2),Ve=d(xe,!0);c(xe),c(l),c(se),c(D),E((j,ie)=>{Y(O,"src",j),an(z,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(Ye)?"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"}`),xe.disabled=ie,I(Ve,t(Kt)?"Checking remote...":"Create & Start Session")},[()=>Qr("/logo.svg"),()=>!t(Ue).trim()||t(Kt)]),wr("submit",l,j=>{j.preventDefault(),Se()}),wr("focus",z,()=>{p(et,!0),U(t(Ue),!0)}),wr("blur",z,j=>{t(ht)&&t(ht).contains(j.relatedTarget)||p(et,!1)}),M("keydown",z,j=>{j.key==="Escape"&&p(et,!1)}),ar(z,()=>t(Ue),j=>p(Ue,j)),h(R,D)},tn=R=>{var D=oh();h(R,D)},Et=R=>{var D=ah();h(R,D)},vt=R=>{var D=yb(),se=d(D);{var ze=O=>{var l=ih(),y=d(l),A=d(y);{var z=De=>{var ue=qn("Loading older messages...");h(De,ue)},ke=De=>{var ue=qn("Load older messages");h(De,ue)};k(A,De=>{t(w)?De(z):De(ke,-1)})}c(y),c(l),E(()=>y.disabled=t(w)),M("click",y,qe),h(O,l)};k(se,O=>{t($e)&&O(ze)})}var tt=f(se,2);Ln(tt,17,()=>t(qt),O=>O.id,(O,l)=>{var y=_b(),A=d(y),z=d(A);{var ke=lt=>{var Pe=dr(),$t=Dt(Pe);{var fn=xe=>{var Ve=lh();h(xe,Ve)},hn=xe=>{var Ve=ch();h(xe,Ve)},jt=xe=>{var Ve=dh();h(xe,Ve)},Ot=xe=>{var Ve=fh(),j=d(Ve);{var ie=ct=>{var Ze=uh();h(ct,Ze)};k(j,ct=>{t(l).isStreaming&&ct(ie)})}var st=f(j,2),xt=d(st,!0);c(st),c(Ve),E(()=>I(xt,t(l).content)),h(xe,Ve)};k($t,xe=>{t(l).content==="FALLBACK_THINKING_LOADER"?xe(fn):t(l).content==="FALLBACK_LOADER"?xe(hn,1):r().hideThinking?xe(jt,2):xe(Ot,-1)})}h(lt,Pe)},De=lt=>{var Pe=dr(),$t=Dt(Pe);{var fn=Ot=>{var xe=hh(),Ve=f(d(xe),2),j=f(d(Ve)),ie=d(j,!0);c(j),pt(),c(Ve);var st=f(Ve,2);{var xt=Ze=>{var Gt=ph(),Vt=d(Gt,!0);c(Gt),E(bn=>I(Vt,bn),[()=>Ns(t(l),t(F))]),h(Ze,Gt)},ct=P(()=>Ns(t(l),t(F)));k(st,Ze=>{t(ct)&&Ze(xt)})}c(xe),E(()=>I(ie,t(l).toolName||"agent")),h(Ot,xe)},hn=P(()=>r().hideTools&&!ea(t(l).toolName)&&!Js(t(l))),jt=Ot=>{const xe=P(()=>Ni(t(l))),Ve=P(()=>en[t(l).id]!==void 0?en[t(l).id]:Bp(t(l),t(qt))),j=P(()=>t(xe).downloadPath),ie=P(()=>t(j)?ic(t(j)):null),st=P(()=>t(j)?af(t(j)):null),xt=P(()=>t(xe).toolName==="attach_file"),ct=P(()=>t(xe).toolName==="say");var Ze=dr(),Gt=Dt(Ze);{var Vt=Bn=>{const $n=P(()=>t(j)?t(j).split("/").pop()||t(j):"");var Wn=kh(),Tn=d(Wn);{var On=_n=>{var Jt=bh();h(_n,Jt)},tr=_n=>{var Jt=gh(),rr=f(d(Jt),2),lr=f(d(rr),2);{var Br=Sr=>{var zr=vh(),bo=d(zr,!0);c(zr),E(()=>I(bo,t(xe).toolOutput)),h(Sr,zr)};k(lr,Sr=>{t(xe).toolOutput&&Sr(Br)})}c(rr),c(Jt),h(_n,Jt)},nr=_n=>{var Jt=mh(),rr=f(d(Jt),2),lr=d(rr),Br=d(lr,!0);c(lr);var Sr=f(lr,2),zr=d(Sr,!0);c(Sr),c(rr),pt(2),c(Jt),E(()=>{Y(Jt,"href",t(ie)),Y(Jt,"download",t($n)),Y(Jt,"title",`Download ${t(j)}`),I(Br,t($n)),Y(Sr,"title",t(j)),I(zr,t(j))}),h(_n,Jt)},Lt=_n=>{var Jt=xh(),rr=f(d(Jt),2),lr=d(rr),Br=d(lr,!0);c(lr),pt(2),c(rr),c(Jt),E(()=>I(Br,t($n))),h(_n,Jt)};k(Tn,_n=>{t(l).isStreaming?_n(On):t(xe).isError?_n(tr,1):t(ie)?_n(nr,2):_n(Lt,-1)})}var Xt=f(Tn,2);{var kr=_n=>{var Jt=_h(),rr=d(Jt);c(Jt),E(()=>{Y(Jt,"href",t(ie)),Y(Jt,"title",`Open ${t(j)}`),Y(rr,"src",t(ie)),Y(rr,"alt",t(j))}),h(_n,Jt)};k(Xt,_n=>{!t(l).isStreaming&&!t(xe).isError&&t(ie)&&t(st)==="image"&&_n(kr)})}var gr=f(Xt,2);{var Fr=_n=>{var Jt=yh();E(()=>{Y(Jt,"src",t(ie)),Y(Jt,"title",t(j))}),h(_n,Jt)};k(gr,_n=>{!t(l).isStreaming&&!t(xe).isError&&t(ie)&&t(st)==="audio"&&_n(Fr)})}var qr=f(gr,2);{var ho=_n=>{var Jt=wh();E(()=>{Y(Jt,"src",t(ie)),Y(Jt,"title",t(j))}),h(_n,Jt)};k(qr,_n=>{!t(l).isStreaming&&!t(xe).isError&&t(ie)&&t(st)==="video"&&_n(ho)})}c(Wn),h(Bn,Wn)},bn=Bn=>{var $n=Ch(),Wn=d($n);{var Tn=tr=>{var nr=Th(),Lt=f(d(nr),2),Xt=f(d(Lt),2);{var kr=gr=>{var Fr=Sh(),qr=d(Fr,!0);c(Fr),E(()=>I(qr,t(xe).toolOutput)),h(gr,Fr)};k(Xt,gr=>{t(xe).toolOutput&&gr(kr)})}c(Lt),c(nr),h(tr,nr)},On=tr=>{var nr=Ah(),Lt=f(d(nr),2),Xt=f(d(Lt),2),kr=d(Xt,!0);c(Xt),c(Lt),c(nr),E(()=>I(kr,t(xe).sayText)),h(tr,nr)};k(Wn,tr=>{t(xe).isError?tr(Tn):t(xe).sayText&&tr(On,1)})}c($n),h(Bn,$n)},Yn=Bn=>{var $n=Yh(),Wn=d($n),Tn=d(Wn),On=d(Tn),tr=d(On);{var nr=He=>{var Je=Eh();h(He,Je)},Lt=He=>{var Je=Rh();h(He,Je)},Xt=He=>{var Je=Ih();h(He,Je)},kr=He=>{var Je=Mh();h(He,Je)};k(tr,He=>{t(l).isStreaming?He(nr):t(xe).isError?He(Lt,1):t(xe).interrupted?He(Xt,2):He(kr,-1)})}var gr=f(tr,2),Fr=d(gr,!0);c(gr);var qr=f(gr,2);{var ho=He=>{var Je=$h(),Qn=d(Je,!0);c(Je),E(()=>{Y(Je,"title",t(xe).smartTitleArgs),I(Qn,t(xe).smartTitleArgs)}),h(He,Je)};k(qr,He=>{t(xe).smartTitleArgs&&He(ho)})}var _n=f(qr,2);{var Jt=He=>{var Je=Oh(),Qn=d(Je);c(Je),E(Hr=>{an(Je,1,`shrink-0 font-mono text-xs tabular-nums ${t(l).isStreaming?"text-amber-400":"text-brand-text-muted"}`),Y(Je,"title",t(l).isStreaming?"Elapsed time":"Time taken"),I(Qn,`${t(l).isStreaming?"Elapsed":"Took"}
|
|
92
|
-
${Hr??""}`)},[()=>Ns(t(l),t(F))]),h(He,Je)},rr=P(()=>Ns(t(l),t(F)));k(_n,He=>{t(rr)&&He(Jt)})}c(On);var lr=f(On,2),Br=d(lr);{var Sr=He=>{var Je=Lh();pt(),h(He,Je)},zr=He=>{var Je=Dh();pt(),h(He,Je)};k(Br,He=>{t(Ve)?He(Sr):He(zr,-1)})}c(lr),c(Tn);var bo=f(Tn,2);{var $c=He=>{var Je=dr(),Qn=Dt(Je);{var Hr=sr=>{var cr=Ph();E(vo=>{Y(cr,"href",t(ie)),Y(cr,"download",vo),Y(cr,"title",`Download ${t(j)}`),Y(cr,"aria-label",`Download ${t(j)}`)},[()=>t(j).split("/").pop()||""]),h(sr,cr)},Tr=sr=>{var cr=Nh();h(sr,cr)};k(Qn,sr=>{t(ie)?sr(Hr):sr(Tr,-1)})}h(He,Je)};k(bo,He=>{t(j)&&He($c)})}c(Wn);var Na=f(Wn,2);{var Oc=He=>{var Je=Uh(),Qn=d(Je);c(Je),E(()=>{Y(Je,"href",t(ie)),Y(Je,"title",`Open ${t(j)}`),Y(Qn,"src",t(ie)),Y(Qn,"alt",t(j))}),h(He,Je)};k(Na,He=>{!(t(l).images&&t(l).images.length>0)&&t(ie)&&t(st)==="image"&&He(Oc)})}var Ua=f(Na,2);{var Lc=He=>{var Je=Fh();E(()=>{Y(Je,"src",t(ie)),Y(Je,"title",t(j))}),h(He,Je)};k(Ua,He=>{t(ie)&&t(st)==="audio"&&He(Lc)})}var Fa=f(Ua,2);{var Dc=He=>{var Je=Bh();E(()=>{Y(Je,"src",t(ie)),Y(Je,"title",t(j))}),h(He,Je)};k(Fa,He=>{t(ie)&&t(st)==="video"&&He(Dc)})}var Ba=f(Fa,2);{var Pc=He=>{var Je=Hh(),Qn=d(Je);Ln(Qn,21,()=>t(l).images,pr,(Hr,Tr)=>{var sr=zh(),cr=d(sr);c(sr),E(()=>{Y(sr,"href",`data:${t(Tr).mimeType};base64,${t(Tr).data}`),Y(cr,"src",`data:${t(Tr).mimeType};base64,${t(Tr).data}`)}),h(Hr,sr)}),c(Qn),c(Je),h(He,Je)};k(Ba,He=>{t(l).images&&t(l).images.length>0&&He(Pc)})}var Nc=f(Ba,2);{var Uc=He=>{var Je=Vh(),Qn=d(Je);{var Hr=Kn=>{var or=jh(),Ms=f(d(or),2),zc=d(Ms,!0);c(Ms),c(or),E(()=>I(zc,t(xe).fullArgs)),h(Kn,or)};k(Qn,Kn=>{t(xe).fullArgs&&t(xe).fullArgs!=="{}"&&Kn(Hr)})}var Tr=f(Qn,2),sr=f(d(Tr),2);{var cr=Kn=>{var or=Gh(),Ms=d(or,!0);c(or),E(()=>I(Ms,t(xe).toolOutput)),h(Kn,or)},vo=Kn=>{var or=Wh();h(Kn,or)},Fc=Kn=>{var or=Kh();h(Kn,or)},Bc=Kn=>{var or=qh();h(Kn,or)};k(sr,Kn=>{t(xe).toolOutput?Kn(cr):t(l).isStreaming?Kn(vo,1):t(xe).interrupted?Kn(Fc,2):Kn(Bc,-1)})}c(Tr),c(Je),h(He,Je)};k(Nc,He=>{t(Ve)&&He(Uc)})}c($n),E(()=>I(Fr,t(xe).toolName)),M("click",Tn,()=>cn(t(l).id,t(Ve))),h(Bn,$n)};k(Gt,Bn=>{t(xt)?Bn(Vt):t(ct)?Bn(bn,1):Bn(Yn,-1)})}h(Ot,Ze)};k($t,Ot=>{t(hn)?Ot(fn):Ot(jt,-1)})}h(lt,Pe)},ue=lt=>{var Pe=dr(),$t=Dt(Pe);{var fn=jt=>{var Ot=Xh(),xe=d(Ot,!0);pt(),c(Ot),E(()=>I(xe,t(l).content)),h(jt,Ot)},hn=jt=>{const Ot=P(()=>en[t(l).id]===!0),xe=P(()=>ff({active:t(Xe),expanded:t(Ot),content:t(l).content})),Ve=P(()=>Sn[t(l).id]===!0);var j=ob(),ie=d(j);{var st=Lt=>{var Xt=Zh(),kr=d(Xt,!0);c(Xt),E(()=>{an(Xt,1,`chat-selectable 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 ${t(xe)?"relative max-h-40 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)] opacity-80":""}`),I(kr,t(l).content)}),h(Lt,Xt)},xt=Lt=>{var Xt=Jh();qa(Xt,()=>$p(t(l).id,t(l).content),!0),c(Xt),E(()=>an(Xt,1,`chat-selectable markdown-body text-sm leading-relaxed ${t(xe)?"relative max-h-40 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)] opacity-80":""}`)),h(Lt,Xt)};k(ie,Lt=>{t(Ve)?Lt(st):Lt(xt,-1)})}var ct=f(ie,2),Ze=d(ct),Gt=d(Ze);{var Vt=Lt=>{var Xt=Qh();pt(),h(Lt,Xt)},bn=Lt=>{var Xt=eb();pt(),h(Lt,Xt)};k(Gt,Lt=>{t(at)===t(l).id?Lt(Vt):Lt(bn,-1)})}c(Ze);var Yn=f(Ze,2),Bn=d(Yn);{var $n=Lt=>{var Xt=tb();pt(),h(Lt,Xt)},Wn=Lt=>{var Xt=nb();pt(),h(Lt,Xt)};k(Bn,Lt=>{t(Ve)?Lt($n):Lt(Wn,-1)})}c(Yn),c(ct);var Tn=f(ct,2);{var On=Lt=>{var Xt=rb();M("click",Xt,()=>cn(t(l).id,t(Ot))),h(Lt,Xt)},tr=Lt=>{var Xt=sb();M("click",Xt,()=>cn(t(l).id,t(Ot))),h(Lt,Xt)},nr=P(()=>t(Xe)&&t(Ot)&&fc(t(l).content));k(Tn,Lt=>{t(xe)?Lt(On):t(nr)&&Lt(tr,1)})}c(j),E(()=>Y(Yn,"title",t(Ve)?"Show the rendered markdown":"Show the raw markdown source")),M("click",Ze,()=>wn(t(l).id,t(l).content)),M("click",Yn,()=>Cn(t(l).id)),h(jt,j)};k($t,jt=>{t(l).isStreaming?jt(fn):jt(hn,-1)})}h(lt,Pe)},he=lt=>{const Pe=P(()=>Pp(t(l).content));var $t=hb(),fn=Dt($t);{var hn=Ve=>{var j=ib(),ie=d(j),st=f(d(ie),2),xt=d(st);c(st),c(ie);var ct=f(ie,2);{var Ze=Gt=>{var Vt=ab(),bn=d(Vt,!0);c(Vt),E(()=>I(bn,t(Pe).skill.args)),h(Gt,Vt)};k(ct,Gt=>{t(Pe).skill.args&&Gt(Ze)})}c(j),E(()=>I(xt,`skill:${t(Pe).skill.skillName??""}`)),h(Ve,j)},jt=Ve=>{var j=ub(),ie=d(j);{var st=Vt=>{const bn=P(()=>Op(t(Pe).cleanContent));var Yn=dr(),Bn=Dt(Yn);{var $n=Tn=>{var On=lb();qa(On,()=>t(bn),!0),c(On),h(Tn,On)},Wn=Tn=>{var On=qn();E(()=>I(On,t(Pe).cleanContent)),h(Tn,On)};k(Bn,Tn=>{t(bn)?Tn($n):Tn(Wn,-1)})}h(Vt,Yn)},xt=Vt=>{var bn=cb(),Yn=d(bn);c(bn),E(()=>I(Yn,`Shared file${t(Pe).attachments.length>1?"s":""} with agent:`)),h(Vt,bn)},ct=Vt=>{var bn=qn();E(()=>I(bn,t(l).content||(t(l).isStreaming?"Thinking...":""))),h(Vt,bn)};k(ie,Vt=>{t(Pe).cleanContent?Vt(st):t(Pe).attachments.length>0?Vt(xt,1):Vt(ct,-1)})}var Ze=f(ie,2);{var Gt=Vt=>{var bn=db();h(Vt,bn)};k(Ze,Vt=>{t(l).isStreaming&&t(Fn)&&Vt(Gt)})}c(j),h(Ve,j)};k(fn,Ve=>{t(Pe).skill?Ve(hn):Ve(jt,-1)})}var Ot=f(fn,2);{var xe=Ve=>{var j=pb();Ln(j,21,()=>t(Pe).attachments,pr,(ie,st)=>{var xt=fb(),ct=f(d(xt),2),Ze=d(ct,!0);c(ct),c(xt),E(()=>{Y(ct,"title",t(st)),I(Ze,t(st))}),h(ie,xt)}),c(j),h(Ve,j)};k(Ot,Ve=>{t(Pe).attachments.length>0&&Ve(xe)})}h(lt,$t)};k(z,lt=>{t(l).role==="thinking"?lt(ke):t(l).role==="tool"?lt(De,1):t(l).role==="assistant"&&t(l).content!==""?lt(ue,2):lt(he,-1)})}var be=f(z,2);{var We=lt=>{var Pe=xb(),$t=Dt(Pe),fn=d($t);{var hn=Ze=>{var Gt=bb();pt(4),h(Ze,Gt)};k(fn,Ze=>{t(l).role==="user"&&t(l).delivery==="sending"&&Ze(hn)})}var jt=f(fn);c($t);var Ot=f($t,2);{var xe=Ze=>{var Gt=vb(),Vt=d(Gt);c(Gt),M("click",Vt,()=>q(t(l).entryId)),h(Ze,Gt)},Ve=P(()=>t(l).role==="user"&&t(l).entryId&&t(le).sessionId&&!t(Z)&&t(l).delivery===void 0&&!ve().includes(t(l).content));k(Ot,Ze=>{t(Ve)&&Ze(xe)})}var j=f(Ot,2);{var ie=Ze=>{var Gt=gb();h(Ze,Gt)},st=P(()=>t(l).role==="user"&&ve().includes(t(l).content));k(j,Ze=>{t(st)&&Ze(ie)})}var xt=f(j,2);{var ct=Ze=>{var Gt=mb(),Vt=f(d(Gt),2),bn=f(Vt,2);c(Gt),M("click",Vt,()=>Ol(t(l).id)),M("click",bn,()=>Ll(t(l).id)),h(Ze,Gt)};k(xt,Ze=>{t(l).role==="user"&&t(l).delivery==="failed"&&Ze(ct)})}E(Ze=>{an($t,1,`mt-1 flex items-center gap-1.5 text-xs opacity-50 ${t(l).role==="user"?"justify-end text-brand-text-muted":t(l).role==="assistant"?"text-brand-purple":"text-brand-text-muted"}`),I(jt,` ${Ze??""}`)},[()=>Dp(t(l).timestamp)]),h(lt,Pe)};k(be,lt=>{t(l).role!=="thinking"&&t(l).role!=="tool"&<(We)})}c(A),c(y),E(lt=>{Y(y,"data-msg-id",t(l).id),an(y,1,`flex ${t(l).role==="user"?"justify-end":"justify-start"}`),an(A,1,`max-w-[85%] rounded-lg px-4 py-3 ${lt??""}`)},[()=>t(l).role==="user"?t(l).delivery==="sending"?"bg-brand-blue/40 text-brand-text ring-1 ring-brand-blue/50":t(l).delivery==="failed"?"bg-brand-blue/30 text-brand-text ring-1 ring-amber-400/50":"bg-brand-blue/80 text-brand-text":t(l).role==="thinking"?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":t(l).role==="tool"&&ea(t(l).toolName)?"bg-transparent p-0 text-brand-text":t(l).role==="tool"?r().hideTools&&!Js(t(l))?"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(l).isStreaming?"border-amber-400":t(l).isError?"border-rose-400":t(l).interrupted?"border-brand-border":"border-emerald-400"}`:t(l).role==="assistant"?"border-l-2 border-brand-purple bg-brand-purple/10 text-brand-text":t(l).content===""&&t(l).isStreaming?"bg-brand-surface-3 text-brand-text-muted italic":"bg-brand-surface-2 text-brand-text"]),h(O,y)}),c(D),ir(D,O=>p(X,O),()=>t(X)),h(R,D)};k(ge,R=>{t(At).connecting&&!t(Qt)?R(Zt):!t(At).connected&&!t(Qt)?R(on,1):!t(Qt)&&(t(Te)||!t(yn)&&typeof window<"u"&&window.location.hash)?R(zt,2):t(le).sessionFile?t(qt).length===0&&(t(Te)||t(T))?R(tn,4):t(qt).length===0?R(Et,5):R(vt,-1):R(dn,3)})}var xn=f(ge,2),it=d(xn),ut=d(it),Mt=d(ut);Tt(Mt),pt(),c(ut);var un=f(ut,2);{var pn=R=>{var D=wb(),se=d(D),ze=d(se,!0);c(se);var tt=f(se,2),O=d(tt,!0);c(tt),c(D),E(()=>{an(D,1,`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text ${t(Ae)===void 0?"text-brand-text-muted":"text-brand-blue"}`),Y(D,"title",t(Ae)===void 0?`Beep when the agent is waiting: following the default (${t(Ie)?"on":"off"}). Click to set On for this session.`:t(Ae)===!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."),I(ze,t(Ie)?"🔔":"🔕"),I(O,t(Ae)===void 0?`Beep: Default (${t(Ie)?"on":"off"})`:t(Ae)?"Beep: On":"Beep: Off")}),M("click",D,ln),h(R,D)};k(un,R=>{t(le).sessionFile&&!m()&&R(pn)})}var ye=f(un,2),Fe=d(ye),gt=d(Fe,!0);c(Fe);var S=f(Fe,2),C=d(S,!0);c(S),c(ye);var J=f(ye,2);{var pe=R=>{var D=kb(),se=f(d(D),2),ze=d(se,!0);c(se),c(D),E(tt=>{Y(D,"title",tt),I(ze,t(Qe))},[()=>r().contextUsage?.tokens!=null?`${r().contextUsage.tokens.toLocaleString()} context tokens of ${r().contextUsage.contextWindow.toLocaleString()}`:"Context window size"]),h(R,D)};k(J,R=>{t(Qe)&&R(pe)})}c(it);var Ge=f(it,2),Oe=d(Ge);{var ee=R=>{var D=Sb(),se=d(D);c(D),E(()=>{Y(D,"title",`Cancel the queued steer message${ve().length>1?"s":""} (does not abort the current turn)`),I(se,`Cancel queued${ve().length>1?` (${ve().length})`:""}`)}),M("click",D,function(...ze){Pl?.apply(this,ze)}),h(R,D)};k(Oe,R=>{ve().length>0&&R(ee)})}var Re=f(Oe,2);c(Ge),c(xn);var V=f(xn,2);{var me=R=>{var D=Rb(),se=d(D),ze=f(d(se),2),tt=f(d(ze)),O=d(tt,!0);c(tt),pt(),c(ze);var l=f(ze,2),y=d(l),A=d(y);Tt(A);var z=f(A,2),ke=f(d(z));{var De=$t=>{var fn=Tb();h($t,fn)},ue=$t=>{var fn=Ab();h($t,fn)};k(ke,$t=>{t(H).isGit?$t(De):$t(ue,-1)})}c(z),c(y);var he=f(y,2);{var be=$t=>{var fn=Eb(),hn=d(fn),jt=d(hn);Tt(jt);var Ot=f(jt,2),xe=d(Ot);c(Ot),c(hn);var Ve=f(hn,2);{var j=ie=>{var st=Cb(),xt=f(d(st),2),ct=d(xt);Tt(ct),ct.value=ct.__value="private",pt(),c(xt);var Ze=f(xt,2),Gt=d(Ze);Tt(Gt),Gt.value=Gt.__value="public",pt(),c(Ze),c(st),Nr(je,[],ct,()=>t(Rt),Vt=>p(Rt,Vt)),Nr(je,[],Gt,()=>t(Rt),Vt=>p(Rt,Vt)),h(ie,st)};k(Ve,ie=>{t(Ft)&&ie(j)})}c(fn),E(()=>I(xe,`Create remote ${t(H).matchingRule.provider??""} repository`)),Zn(jt,()=>t(Ft),ie=>p(Ft,ie)),h($t,fn)};k(he,$t=>{t(H).matchingRule&&$t(be)})}c(l);var We=f(l,2),lt=d(We),Pe=f(lt,2);c(We),c(se),c(D),E(()=>{I(O,t(Ue)),A.disabled=t(H).isGit}),Zn(A,()=>t(nt),$t=>p(nt,$t)),M("click",lt,()=>p(Wt,!1)),M("click",Pe,()=>{p(Wt,!1),yr(t(Ue).trim(),t(Be)||void 0,t(nt),t(H).matchingRule?t(Ft):void 0,t(H).matchingRule?t(Rt):void 0)}),h(R,D)};k(V,R=>{t(Wt)&&R(me)})}var ft=f(V,2);{var mt=R=>{var D=Mb(),se=d(D),ze=f(d(se),2),tt=d(ze),O=f(tt),l=d(O,!0);c(O),pt(),c(ze);var y=f(ze,2);{var A=ue=>{var he=Ib(),be=d(he,!0);c(he),E(()=>I(be,t(ot).sshUrl)),h(ue,he)};k(y,ue=>{t(ot)?.sshUrl&&ue(A)})}var z=f(y,2),ke=d(z),De=f(ke,2);c(z),c(se),c(D),E(()=>{I(tt,`A ${t(ot)?.provider??"remote"??""} repository matching `),I(l,t(Ue))}),M("click",ke,()=>{p(ae,!1),p(ot,null),Bt(!1)}),M("click",De,()=>{p(ae,!1),p(ot,null),Bt(!0)}),h(R,D)};k(ft,R=>{t(ae)&&R(mt)})}c(_e),E(()=>{ra(Mt,r().hideThinking),an(ye,1,`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text ${t(rt)?"text-brand-blue":"text-brand-text-muted"}`),Y(ye,"title",`Conversation Mode for THIS conversation: ${t(rt)?"ON":"OFF"}${t(ne)?" (following your default)":" (set for this conversation)"}. ${t(rt)?"Click to turn it off here (the configured knobs go dormant); other conversations are unaffected.":"Click to flip your configured bundle of speech/voice knobs on here; other conversations are unaffected."} The default for conversations you have not toggled is in Connection Settings.`),I(gt,t(rt)?"🗣️":"💬"),I(C,t(rt)?"Conversation: On":"Conversation: Off"),Re.disabled=!t(Fn)}),M("change",Mt,R=>Gl({hideThinking:R.currentTarget.checked})),M("click",ye,Me),M("click",Re,function(...R){Dl?.apply(this,R)}),h(n,_e);var Ht=br(Le);return K(),Ht}Mr(["click","keydown","change"]);function Lb(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"}}const Pa="pre-start",Ec="Failed to upload";function Bi(n){return{state:Pa,acked:0,size:n}}function Db(n,e){if(!(e>0))return 0;const r=Math.floor(n/e*100);return Math.min(100,Math.max(0,r))}function ta(n){return n?.code!=="not_readable"}function Pb(n){switch(n.state){case Pa:return{kind:"pending"};case"queued":case"paused":return{kind:"waiting"};case"sending":return n.acked>0?{kind:"progress",percent:Db(n.acked,n.size)}:{kind:"indeterminate"};case"finishing":return{kind:"finishing",percent:100};case"done":return{kind:"done"};case"aborted":return{kind:"removed"};case"failed":{const e=ta(n.error);return{kind:"failed",message:n.error?.message||Ec,retry:e,pickAgain:!e}}}}function Rc(n){return n===Pa||n==="queued"||n==="sending"||n==="paused"||n==="finishing"}function Nb(n){const e=n.upload;return e?Rc(e.state)?!0:e.state==="done"&&!n.path:!1}function Ub(n){const e=n,r=typeof e?.message=="string"&&e.message?e.message:Ec;return e?.code==="not_readable"?{message:r,code:"not_readable"}:{message:r}}function Fb(n){return n.active?"reopen-mic":"none"}const Bb={speechLevel:.015,silenceMs:2e3,leadingSilenceMs:6e3,maxMs:6e4};function zb(n={}){const{speechLevel:e,silenceMs:r,leadingSilenceMs:s,maxMs:o}={...Bb,...n};let a=0,i=0,u=!1,m=null;return{push(v,g){return m||(a+=g,v>=e?(u=!0,i=0):i+=g,a>=o?(m="stop-max",m):i>=(u?r:s)?(m="stop-silence",m):"keep-recording")}}}function Hb(n){const e=n.length;if(!e)return 0;let r=0;for(let s=0;s<e;s++){const o=n[s];r+=o*o}return Math.sqrt(r/e)}var jb=b("<option> </option>"),Gb=b('<div class="mb-3.5"><label for="speech-locale" class="mb-1 block font-medium text-gray-400">Accent / Locale</label> <select id="speech-locale" class="w-full rounded border border-gray-600 bg-gray-950 px-2 py-1.5 text-white focus:border-blue-500 focus:outline-none"></select></div>'),Wb=b('<div class="mt-2 rounded border border-red-900/40 bg-red-950/40 p-2 leading-normal text-red-400"> </div>'),Kb=b(`<div class="fixed inset-0 z-40"></div> <div class="absolute right-0 bottom-14 z-50 w-64 rounded-lg border border-gray-600 bg-gray-800 p-4 text-xs text-white shadow-xl"><h4 class="mb-3 border-b border-gray-700 pb-1.5 font-semibold text-gray-300">Speech Settings</h4> <div class="mb-3.5"><span class="mb-1 block font-medium text-gray-400">Speech-to-Text Engine</span> <div class="flex gap-2"><button type="button">On-Device</button> <button type="button">Cloud AI</button></div> <p class="mt-1 text-[10px] leading-relaxed text-gray-400"> </p></div> <!> <div class="mb-2"><label class="flex cursor-pointer items-center gap-2 py-1"><input type="checkbox" class="rounded border-gray-600 bg-gray-950 text-blue-600 focus:ring-0 focus:ring-offset-0"/> <span class="font-medium text-gray-300">Direct Send (Auto-dispatch)</span></label> <p class="pl-6 text-[10px] leading-relaxed text-gray-400">When enabled, releasing or stopping the microphone immediately sends
|
|
93
|
-
the message.</p></div> <!></div>`,1),qb=b('<div class="relative flex shrink-0 items-center gap-1 select-none"><button type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-5 w-5"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" x2="12" y1="19" y2="22"></line></svg></button> <button type="button" class="flex h-[48px] w-[28px] items-center justify-center rounded-lg border border-gray-600 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-white disabled:cursor-not-allowed disabled:opacity-40" title="Speech Settings"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg></button> <!></div>');function Vb(n,e){hr(e,!0);let r=ur(e,"text",15),s=ur(e,"activeEngine",15,"browser");const o=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null,a=!!o;let i=N(!1),u=N(!1),m=N(!1),v=N(!1),g=N(!1),x=N("en-US"),_=N("browser"),$=N(null);Ut(()=>{s(t(_))});let L=N(null),B=null,W=null,Ne=null,re=null,Ke=null,ve=[],ce=null,K="",je=!1;const Qe=[{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)"}],Ue=fa.subscribe(T=>{p(g,T,!0)});ys(()=>{const T=localStorage.getItem("wherever-speech-locale");T!==null&&p(x,T,!0);const Z=localStorage.getItem("wherever-speech-engine");return Z!==null?p(_,Z,!0):a||p(_,"cloud"),()=>{if(Ue(),B)try{B.abort()}catch{}if(re)try{re.disconnect()}catch{}if(Ne)try{Ne.disconnect()}catch{}if(Ke)try{Ke.getTracks().forEach(q=>q.stop())}catch{}if(W)try{W.close()}catch{}t(L)&&clearTimeout(t(L))}});function oe(){gl(t(g)),localStorage.setItem("wherever-speech-locale",t(x)),localStorage.setItem("wherever-speech-engine",t(_))}function et(){const T=localStorage.getItem("wherever-config"),Z=T?JSON.parse(T):null;if(Z&&Z.host&&Z.port){const q=window.location.protocol==="https:"?"https:":"http:",Ae=Z.host.startsWith("http")?Z.host.replace(/^wss?:\/\//,""):Z.host;return`${q}//${Ae}:${Z.port}`}return`${window.location.protocol}//${window.location.host}`}function dt(){try{const T=localStorage.getItem("wherever-config");if(T)return JSON.parse(T).token||""}catch{}return""}function ht(){try{const T=window.AudioContext||window.webkitAudioContext;if(!T)return;const Z=new T,q=Z.createOscillator(),Ae=Z.createGain();q.type="sine",q.frequency.setValueAtTime(400,Z.currentTime),Ae.gain.setValueAtTime(.08,Z.currentTime),Ae.gain.exponentialRampToValueAtTime(.001,Z.currentTime+.12),q.connect(Ae),Ae.connect(Z.destination),q.start(),q.stop(Z.currentTime+.12)}catch(T){console.warn("Could not play audio beep feedback:",T)}}function _t(T,Z,q){if(Z===q)return T;const Ae=Z/q,Ie=Math.round(T.length/Ae),rt=new Float32Array(Ie);let ne=0,Me=0;for(;ne<rt.length;){const Xe=Math.round((ne+1)*Ae);let bt=0,Ct=0;for(let wt=Me;wt<Xe&&wt<T.length;wt++)bt+=T[wt],Ct++;rt[ne]=Ct>0?bt/Ct:0,ne++,Me=Xe}return rt}function Be(){if(a)try{B=new o,B.continuous=!0,B.interimResults=!0,B.lang=t(x),B.onstart=()=>{p(i,!0),p(u,!1),ht()},B.onresult=T=>{let Z="",q="";for(let Ie=T.resultIndex;Ie<T.results.length;++Ie){const rt=T.results[Ie];rt.isFinal?Z+=rt[0].transcript:q+=rt[0].transcript}const Ae=(Z+q).trim();Ae&&(je=!0,r(K+(K?" ":"")+Ae))},B.onerror=T=>{console.error("Browser speech recognition error:",T.error),T.error!=="no-speech"&&p($,`Error: ${T.error}`),nt()},B.onend=()=>{p(i,!1),t(g)&&je&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50)},B.start(),navigator.vibrate&&navigator.vibrate(40)}catch(T){console.error("Failed to start browser speech recognition:",T),p($,"Failed to start browser recording"),p(i,!1)}}function nt(){if(B)try{B.stop()}catch{}p(i,!1)}async function yt(){try{const T=await navigator.mediaDevices.getUserMedia({audio:!0});Ke=T,ve=[];const Z=window.AudioContext||window.webkitAudioContext;W=new Z,Ne=W.createMediaStreamSource(T),re=W.createScriptProcessor(4096,1,1),re.onaudioprocess=q=>{const Ae=q.inputBuffer.getChannelData(0);if(ve.push(new Float32Array(Ae)),!ce)return;const Ie=q.inputBuffer.sampleRate||44100,rt=Ae.length/Ie*1e3;ce.push(Hb(Ae),rt)!=="keep-recording"&&(ce=null,Kt())},Ne.connect(re),re.connect(W.destination),p(i,!0),p(u,!1),ht(),navigator.vibrate&&navigator.vibrate(40)}catch(T){console.error("Failed to start cloud audio recording:",T),p($,T.message||"Microphone access denied",!0),p(i,!1),p(u,!1),ce=null}}function Ft(){if(t(i)){if(p(i,!1),p(u,!0),re){try{re.disconnect()}catch{}re.onaudioprocess=null}if(Ne)try{Ne.disconnect()}catch{}if(Ke)try{Ke.getTracks().forEach(T=>T.stop())}catch{}Rt()}}async function Rt(){try{if(ve.length===0){p(u,!1);return}p($,null);let T=0;for(const ln of ve)T+=ln.length;const Z=new Float32Array(T);let q=0;for(const ln of ve)Z.set(ln,q),q+=ln.length;const Ae=W?W.sampleRate:48e3,Ie=16e3,rt=_t(Z,Ae,Ie),ne=It(rt,1,Ie,1,16),Me=new Blob([ne],{type:"audio/wav"}),Xe=et(),bt=dt(),Ct=`${Xe}/session/transcribe${bt?`?token=${encodeURIComponent(bt)}`:""}`,wt=await fetch(Ct,{method:"POST",body:Me,headers:{"Content-Type":"application/octet-stream"}}),Pt=await wt.json();if(!wt.ok)throw new Error(Pt.error||`HTTP ${wt.status}`);Pt.text&&Pt.text.trim()&&(je=!0,r(K+(K?" ":"")+Pt.text.trim()),t(g)&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50))}catch(T){console.error("Cloud transcription request failed:",T),p($,T.message||"Cloud API failed",!0)}finally{if(p(u,!1),W){try{W.close()}catch{}W=null}}}function Wt(T=!1){e.disabled||t(i)||t(u)||(p($,null),je=!1,K=r(),ce=T&&t(_)==="cloud"?zb():null,t(_)==="cloud"?yt():Be())}function ae(){Wt(!0)}function Kt(){ce=null,t(_)==="cloud"?Ft():nt()}function ot(T){if(T.button===0&&!e.disabled){if(uo(),T.preventDefault(),t(i)){Kt();return}p(m,!1),p(L,setTimeout(()=>{p(m,!0),Wt()},350),!0)}}function Bt(T){t(L)&&(clearTimeout(t(L)),p(L,null)),t(m)?(p(m,!1),Kt()):t(i)||Wt()}function At(){t(L)&&(clearTimeout(t(L)),p(L,null)),t(m)&&(p(m,!1),Kt())}function It(T,Z,q,Ae,Ie){const rt=new ArrayBuffer(44+T.length*2),ne=new DataView(rt);return H(ne,0,"RIFF"),ne.setUint32(4,36+T.length*2,!0),H(ne,8,"WAVE"),H(ne,12,"fmt "),ne.setUint32(16,16,!0),ne.setUint16(20,Ae,!0),ne.setUint16(22,Z,!0),ne.setUint32(24,q,!0),ne.setUint32(28,q*Z*(Ie/8),!0),ne.setUint16(32,Z*(Ie/8),!0),ne.setUint16(34,Ie,!0),H(ne,36,"data"),ne.setUint32(40,T.length*2,!0),Q(ne,44,T),rt}function Q(T,Z,q){for(let Ae=0;Ae<q.length;Ae++,Z+=2){let Ie=Math.max(-1,Math.min(1,q[Ae]));T.setInt16(Z,Ie<0?Ie*32768:Ie*32767,!0)}}function H(T,Z,q){for(let Ae=0;Ae<q.length;Ae++)T.setUint8(Z+Ae,q.charCodeAt(Ae))}var Ye={startRecordingProgrammatically:ae},fe=qb(),U=d(fe),Se=f(U,2),X=d(Se);c(Se);var le=f(Se,2);{var Te=T=>{var Z=Kb(),q=Dt(Z),Ae=f(q,2),Ie=f(d(Ae),2),rt=f(d(Ie),2),ne=d(rt),Me=f(ne,2);c(rt);var Xe=f(rt,2),bt=d(Xe,!0);c(Xe),c(Ie);var Ct=f(Ie,2);{var wt=sn=>{var en=Gb(),cn=f(d(en),2);Ln(cn,21,()=>Qe,pr,(Sn,Cn)=>{var at=jb(),kt=d(at,!0);c(at);var wn={};E(()=>{I(kt,t(Cn).label),wn!==(wn=t(Cn).code)&&(at.value=(at.__value=t(Cn).code)??"")}),h(Sn,at)}),c(cn),c(en),M("change",cn,oe),xs(cn,()=>t(x),Sn=>p(x,Sn)),h(sn,en)};k(Ct,sn=>{t(_)==="browser"&&sn(wt)})}var Pt=f(Ct,2),ln=d(Pt),Qt=d(ln);Tt(Qt),pt(2),c(ln),pt(2),c(Pt);var yn=f(Pt,2);{var An=sn=>{var en=Wb(),cn=d(en,!0);c(en),E(()=>I(cn,t($))),h(sn,en)};k(yn,sn=>{t($)&&sn(An)})}c(Ae),E(()=>{ne.disabled=!a,an(ne,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40
|
|
94
|
-
${t(_)==="browser"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),an(Me,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors
|
|
95
|
-
${t(_)==="cloud"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),I(bt,t(_)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),M("click",q,()=>p(v,!1)),M("click",ne,()=>{p(_,"browser"),oe()}),M("click",Me,()=>{p(_,"cloud"),oe()}),M("change",Qt,oe),Zn(Qt,()=>t(g),sn=>p(g,sn)),h(T,Z)};k(le,T=>{t(v)&&T(Te)})}return c(fe),E(()=>{U.disabled=e.disabled&&!t(i)&&!t(u)||t(u),an(U,1,`flex h-[48px] w-[48px] items-center justify-center rounded-lg border transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-40
|
|
96
|
-
${t(i)?"animate-pulse border-red-500 bg-red-600 text-white":t(u)?"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"}`),Y(U,"title",t(i)?"Recording (release/tap to stop)...":t(u)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),Se.disabled=e.disabled&&!t(i)&&!t(u)||t(u),an(X,0,`h-4 w-4 transition-transform duration-200 ${t(v)?"rotate-45 text-white":""}`)}),M("pointerdown",U,ot),M("pointerup",U,Bt),wr("pointercancel",U,At),M("click",Se,()=>p(v,!t(v))),h(n,fe),br(Ye)}Mr(["pointerdown","pointerup","click","change"]);var Yb=b('<span class="ml-1 text-brand-text-muted">syncing…</span>'),Xb=b('<span class="ml-1 text-brand-text-muted" title="Showing the last list this device saw. Saving and deleting need the server.">offline copy</span>'),Zb=b(`<div class="border-b border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-300"><div class="mb-2">⚠️ The message box is not empty. Loading this draft would replace
|
|
97
|
-
what you typed.</div> <div class="flex flex-wrap gap-2"><button type="button" class="rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-200 hover:bg-amber-500/30">Replace</button> <button type="button" class="rounded bg-brand-surface-3 px-2 py-1 font-medium text-brand-text hover:opacity-90">Append below</button> <button type="button" class="rounded px-2 py-1 text-brand-text-muted hover:text-brand-text">Cancel</button></div></div>`),Jb=b(`<p class="px-3 py-4 text-center text-xs text-brand-text-muted">No saved drafts yet. Type a message and press “Save draft” to keep it
|
|
98
|
-
on the server for later, from any device.</p>`),Qb=b('<li><button type="button" class="min-w-0 flex-1 text-left disabled:cursor-not-allowed disabled:opacity-50"><span class="line-clamp-2 text-xs text-brand-text"> </span> <span class="mt-0.5 block text-[10px] text-brand-text-muted"> </span></button> <button type="button" class="shrink-0 rounded px-1.5 py-0.5 text-xs text-brand-text-muted hover:bg-rose-500/10 hover:text-rose-400" title="Delete this draft" aria-label="Delete draft">🗑</button></li>'),ev=b('<ul class="max-h-64 overflow-y-auto"></ul>'),tv=b('<p class="border-t border-brand-border px-3 py-2 text-xs text-rose-400"> </p>'),nv=b('<div id="drafts-panel" role="dialog" aria-label="Saved drafts" class="absolute right-4 bottom-full left-4 z-30 mb-2 overflow-hidden rounded-lg border border-brand-border bg-brand-surface-2 shadow-lg"><div class="flex items-center justify-between border-b border-brand-border px-3 py-2"><span class="text-xs font-medium text-brand-text"> <!></span> <button type="button" class="text-xs text-brand-text-muted hover:text-brand-text" aria-label="Close drafts">Close ×</button></div> <!> <!> <!></div>'),rv=b('<span class="inline-block h-1.5 w-1.5 animate-ping rounded-full bg-amber-400"></span> <span>Connecting to remote server...</span>',1),sv=b('<span class="text-rose-400">⚠️</span> <span class="text-rose-400/80"> </span>',1),ov=b('<span class="inline-block h-1.5 w-1.5 rounded-full bg-brand-surface-3"></span> <span>Disconnected from remote server</span>',1),av=b('<div class="mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none"><!></div>'),iv=b('<div class="flex items-center"><button type="button" class="flex w-full items-center justify-between rounded-lg border border-brand-border bg-brand-surface-2 px-4 py-2.5 text-sm text-brand-text-muted transition-all hover:bg-brand-surface-3 hover:text-brand-text"><span class="flex items-center gap-2"><span> </span> <span><!></span></span> <span class="rounded bg-brand-surface-3 px-2 py-1 text-xs font-medium text-brand-text transition-colors hover:bg-brand-surface-2">Expand ▲</span></button></div>'),lv=b('<span class="text-brand-text-muted" title="Will be uploaded with the search">📎</span>'),cv=b('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span>'),dv=b('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-text-muted border-t-transparent"></span> <span class="text-[10px] text-brand-text-muted" title="The upload continues once reconnected">Paused, waiting for connection</span>',1),uv=b('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent" title="Finishing"></span>'),fv=b('<span class="h-1.5 w-16 overflow-hidden rounded-full bg-brand-surface-3" role="progressbar"><span class="block h-full rounded-full bg-brand-blue transition-[width]"></span></span> <span class="text-[10px] text-brand-text-muted tabular-nums"> </span> <!>',1),pv=b('<span class="shrink-0 text-brand-text-muted">Pick the file again</span>'),hv=b('<a target="_blank" class="ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80">[Test Link]</a>'),bv=b('<button type="button" class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-[10px] font-medium text-brand-text hover:bg-brand-surface-3/70">Retry</button>'),vv=b('<span class="flex items-center gap-1 text-[10px] font-medium text-rose-400"><span class="max-w-[120px] truncate"> </span> <!></span> <!>',1),gv=b('<span class="text-emerald-400">✓</span>'),mv=b('<button type="button" class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-[10px] font-medium text-brand-text-muted hover:text-brand-text">Cancel</button>'),xv=b('<div><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" title="Remove">×</button></div>'),_v=b('<div class="mb-3 flex flex-wrap gap-2"></div>'),yv=b("<option> </option>"),wv=b('<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>'),kv=b('<span class="line-clamp-1 text-[11px] text-brand-text-muted"> </span>'),Sv=b('<li><button type="button" role="option"><span class="font-mono text-brand-text"> </span> <!></button></li>'),Tv=b('<ul class="absolute bottom-full left-0 z-20 mb-1 max-h-56 w-full overflow-y-auto rounded-lg border border-brand-border bg-brand-surface-2 py-1 shadow-lg" role="listbox"></ul>'),Av=b('<button type="button" class="flex h-[40px] w-full items-center justify-center rounded-lg border border-brand-border bg-brand-surface-2 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-50" title="Attach file (image or document)">📎</button> <input type="file" multiple="" class="hidden"/>',1),Cv=b('<span class="hidden font-mono opacity-60 sm:inline">Shift+Enter to send</span>'),Ev=b('<!> <!> <form class="flex items-stretch gap-3"><div class="relative 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 flex-wrap items-center justify-between gap-y-1.5 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 disabled:cursor-not-allowed disabled:opacity-40"> </button> <button type="button" title="Open saved drafts" aria-controls="drafts-panel" 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"> </button> <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),Rv=b('<div class="relative border-t border-brand-border p-4"><!> <!> <!></div>');function Iv(n,e){hr(e,!0);const r=()=>we(_a,"$isStreaming",m),s=()=>we(co,"$isReadOnly",m),o=()=>we(rs,"$activeSessionInfo",m),a=()=>we(Cs,"$isConnected",m),i=()=>we(gn,"$piState",m),u=()=>we(va,"$composerPrefill",m),[m,v]=Ur();let g=ur(e,"sendDisabled",3,!1),x=ur(e,"showAttach",3,!0),_=ur(e,"searchMode",3,!1),$=ur(e,"searchConfigured",3,!1),L=ur(e,"searchModels",19,()=>[]),B=ur(e,"searchModel",15,""),W=N(""),Ne=N(!0),re=N(!1),Ke=N("browser"),ve=N(void 0),ce=N(!1),K=N(0),je=N(void 0),Qe=0;const Ue=new Map;let oe=N(Vn([])),et=P(r),dt=P(s),ht=P(o),_t=P(a),Be=P(i),nt=P(()=>{if(_())return null;const w=t(W).match(/^\/([^\s]*)$/);return w?w[1]:null}),yt=P(()=>{if(t(nt)===null)return[];const w=t(Be).skills??[];if(w.length===0)return[];const G=t(nt).toLowerCase();return(G?w.filter(Ee=>Ee.name.toLowerCase().includes(G)):w.slice()).sort((Ee,qe)=>{const Le=Ee.name.toLowerCase().startsWith(G)?0:1,_e=qe.name.toLowerCase().startsWith(G)?0:1;return Le-_e||Ee.name.localeCompare(qe.name)})});Ut(()=>{const w=t(yt).length;if(w===0){Ar(()=>t(ce))&&p(ce,!1);return}Ar(()=>t(ce))||p(ce,!0),Ar(()=>t(K))>=w&&p(K,0)});function Ft(w){p(W,`/${w} `),p(ce,!1),p(K,0),queueMicrotask(()=>{if(!t(ot))return;t(ot).focus();const G=t(W).length;t(ot).setSelectionRange(G,G)})}let Rt=P(()=>_()?e.disabled||!t(_t)||!$():e.disabled||t(dt)||!t(ht).sessionId),Wt=P(()=>t(Rt)||g()||!_()&&!t(_t)),ae=P(()=>t(oe).some(Nb)),Kt=P(()=>!t(Wt)&&!t(ae)&&(t(W).trim().length>0||t(oe).length>0)),ot=N(void 0);const Bt="wherever-draft:";let At=P(()=>Bt+(t(ht).sessionId??"search")),It=N(null);ys(()=>{const w=localStorage.getItem("wherever-enter-to-send");w!==null&&p(Ne,w==="true"),p(Q,Z(),!0)});let Q=N(Vn([])),H=N(!1),Ye=N(null),fe=N(null),U=N(!1),Se=N(null),X=N(!1),le=0,Te=0,T;function Z(){if(typeof localStorage>"u")return[];try{return oi(localStorage.getItem(si))}catch{return[]}}function q(w,G){if(!(G<Te)&&(Te=G,p(Q,w,!0),!(typeof localStorage>"u")))try{localStorage.setItem(si,Zd(w))}catch{}}async function Ae(){if(typeof localStorage>"u")return!1;let w=[];try{w=oi(localStorage.getItem(To))}catch{}if(w.length===0){try{localStorage.removeItem(To)}catch{}return!1}try{for(const G of[...w].reverse())await Wo({text:G.text,sessionId:G.sessionId,cwd:G.cwd});return localStorage.removeItem(To),!0}catch{return!1}}async function Ie(){if(!t(_t))return;const w=++le;p(X,!0);try{await Ae(),q(await lc(),w),p(Se,null)}catch(G){p(Se,G?.message||"Could not load drafts",!0)}finally{p(X,!1)}}let rt=!1;Ut(()=>{if(!t(_t)){rt=!1;return}rt||(rt=!0,Ie())});async function ne(){const w=t(W).trim();if(w.length===0)return;const G=t(At),de=++le;try{const Ee=await Wo({text:w,sessionId:t(ht).sessionId??void 0,cwd:t(ht).cwd??void 0});q(Ee,de),p(Se,null),t(At)===G&&t(W).trim()===w&&(p(W,""),p(fe,null)),p(U,!0),clearTimeout(T),T=setTimeout(()=>p(U,!1),1800)}catch(Ee){p(Se,Ee?.message||"Could not save the draft",!0),p(H,!0)}}function Me(w){if(Jd(t(W))==="confirm"){p(Ye,w,!0);return}Xe(w,"replace")}function Xe(w,G){p(It,t(At),!0),p(W,Qd(t(W),w.text,G),!0),p(fe,{id:w.id,text:w.text},!0),p(Ye,null),p(H,!1),t(re)&&p(re,!1),queueMicrotask(()=>{if(!t(ot))return;t(ot).focus();const de=t(W).length;t(ot).setSelectionRange(de,de)})}function bt(w){const G=eu(t(fe),w);if(p(fe,null),!G)return;const de=++le;Ko(G).then(Ee=>q(Ee,de)).catch(()=>{})}async function Ct(w){const G=++le;try{q(await Ko(w),G),p(Se,null)}catch(de){p(Se,de?.message||"Could not delete the draft",!0)}t(Ye)?.id===w&&p(Ye,null),t(fe)?.id===w&&p(fe,null)}function wt(){t(H)||Ie(),p(H,!t(H)),p(Ye,null)}function Pt(){p(H,!1),p(Ye,null)}ad(()=>clearTimeout(T)),Ut(()=>{const w=t(At);w!==t(It)&&Ar(()=>{let G=null;if(typeof localStorage<"u")try{G=localStorage.getItem(w)}catch{}p(W,G??"",!0),p(It,w,!0),p(fe,null)})});let ln=N(0);Ut(()=>{const{text:w,bump:G}=u();G===0||G===t(ln)||(p(ln,G,!0),Ar(()=>{p(It,t(At),!0),p(W,w,!0),t(re)&&p(re,!1),queueMicrotask(()=>t(ot)?.focus())}))}),Ut(()=>{const w=t(W),G=t(At);if(!(G!==t(It)||typeof localStorage>"u"))try{w.trim().length>0?localStorage.setItem(G,w):localStorage.removeItem(G)}catch{}}),Ut(()=>{_()||Ar(()=>{t(oe).some(w=>w.file)&&p(oe,t(oe).filter(w=>!w.file),!0)})});function Qt(){t(re)&&p(re,!1),t(ot)?.focus()}let yn=!1;Ut(()=>{const w=r(),G=yn&&!w;yn=w,!(!G||Fb({active:es("micReopensAfterReply",ns()),engine:t(Ke)})==="none")&&(t(Wt)||Vu().then(()=>{r()||t(Wt)||t(ve)?.startRecordingProgrammatically()}))});function An(){p(Ne,!t(Ne)),localStorage.setItem("wherever-enter-to-send",String(t(Ne)))}Ut(()=>{t(ot)&&(t(W),t(ot).style.height="auto",t(ot).style.height=`${t(ot).scrollHeight}px`)}),Ut(()=>{!t(Rt)&&t(ot)&&t(ot).focus()});async function sn(w){ma();const G=w.target;if(!G.files)return;const de=Array.from(G.files);if(G.value="",_()){p(oe,[...t(oe),...de.map(Le=>({id:Qe++,name:Le.name,file:Le}))],!0);return}const Ee=t(ht).sessionId,qe=de.map(Le=>({file:Le,id:Qe++}));p(oe,[...t(oe),...qe.map(({file:Le,id:_e})=>({id:_e,name:Le.name,upload:Bi(Le.size),retryFile:Le}))],!0);for(const{file:Le,id:_e}of qe)await Cn(_e,Le,Ee)}function en(w,G){p(oe,t(oe).map(de=>de.id===w?G(de):de),!0)}function cn(w){p(oe,t(oe).filter(G=>G.id!==w),!0)}function Sn(){try{const w=ws(),G=ks();return`${w}/health${G?`?token=${encodeURIComponent(G)}`:""}`}catch{return""}}async function Cn(w,G,de){if(!t(oe).some(_e=>_e.id===w))return;const Ee=new AbortController;Ue.set(w,Ee);const qe=()=>Ue.get(w)===Ee,Le=_e=>{if(qe()){if(_e.state==="aborted"){cn(w);return}en(w,ge=>({...ge,upload:{..._e},..._e.state==="failed"&&!ta(_e.error)?{retryFile:void 0}:{}}))}};try{if(!de)throw new Error("No active session");const _e=await ka(de,G,{signal:Ee.signal,onProgress:Le});if(!qe())return;en(w,ge=>({id:w,name:ge.name,path:_e.savedPath,upload:{state:"done",acked:G.size,size:G.size}}))}catch(_e){if(!qe())return;if(Ee.signal.aborted){cn(w);return}console.error("File upload error details:",_e);const ge=Ub(_e);en(w,Zt=>({id:w,name:Zt.name,upload:{state:"failed",acked:Zt.upload?.acked??0,size:G.size,error:ge},retryFile:ta(ge)?G:void 0,url:Sn()}))}finally{qe()&&Ue.delete(w)}}function at(w){const G=Ue.get(w);G?G.abort():cn(w)}function kt(w){const de=t(oe).find(Ee=>Ee.id===w)?.retryFile;!de||Ue.has(w)||(en(w,Ee=>({id:w,name:Ee.name,upload:Bi(de.size),retryFile:de})),Cn(w,de,t(ht).sessionId))}function wn(w){Ue.get(w)?.abort(),cn(w)}function In(){if(t(Wt)||t(ae))return;const w=t(W).trim();if(_()){const Le=t(oe).map(_e=>_e.file).filter(_e=>!!_e);if(!w&&Le.length===0||t(Rt))return;e.onSubmit?.(w,Le),bt(w),p(W,""),p(oe,[],!0),e.onSend?.();return}if(!w&&t(oe).length===0)return;const G=t(oe).map(Le=>Le.path).filter(Le=>!!Le),de=ll(w,G);if(w.startsWith("/")&&t(oe).length===0){const Le=w.toLowerCase();if(Le==="/new"||Le==="/reset"){if(t(ht).cwd){yr(t(ht).cwd,t(ht).model||void 0),p(W,""),p(fe,null);return}}else if(Le==="/clear"){jl(),p(W,""),p(fe,null);return}else if(Le==="/leave"||Le==="/exit"){fr(),p(W,""),p(fe,null);return}else if(Le==="/reload"&&t(ht).sessionId&&t(_t)&&!t(Be).agentPending){Nl(),p(W,""),p(fe,null);return}}const Ee=Lb({streaming:t(et),connected:t(_t),agentPending:t(Be).agentPending,readOnly:t(dt),hasSession:!!t(ht).sessionId});if(Ee.action!=="send"){(Ee.reason==="disconnected"||Ee.reason==="agent-pending")&&Ho(de);return}Ho(de)&&(bt(w),p(W,""),p(oe,[],!0),e.onSend?.())}function Rn(w){if(t(H)&&w.key==="Escape"){w.preventDefault(),Pt();return}if(t(ce)&&t(yt).length>0){if(w.key==="ArrowDown"){w.preventDefault(),p(K,(t(K)+1)%t(yt).length);return}if(w.key==="ArrowUp"){w.preventDefault(),p(K,(t(K)-1+t(yt).length)%t(yt).length);return}if(w.key==="Enter"||w.key==="Tab"){w.preventDefault();const G=t(yt)[t(K)]??t(yt)[0];G&&Ft(G.name);return}if(w.key==="Escape"){w.preventDefault(),p(ce,!1);return}}w.key==="Enter"&&(t(Ne)?w.shiftKey||(w.preventDefault(),In()):w.shiftKey&&(w.preventDefault(),In()))}var Gn={focusInput:Qt},kn=Rv(),mn=d(kn);{var Mn=w=>{var G=nv(),de=d(G),Ee=d(de),qe=d(Ee),Le=f(qe);{var _e=it=>{var ut=Yb();h(it,ut)},ge=it=>{var ut=Xb();h(it,ut)};k(Le,it=>{t(X)?it(_e):t(_t)||it(ge,1)})}c(Ee);var Zt=f(Ee,2);c(de);var on=f(de,2);{var zt=it=>{var ut=Zb(),Mt=f(d(ut),2),un=d(Mt),pn=f(un,2),ye=f(pn,2);c(Mt),c(ut),M("click",un,()=>t(Ye)&&Xe(t(Ye),"replace")),M("click",pn,()=>t(Ye)&&Xe(t(Ye),"append")),M("click",ye,()=>p(Ye,null)),h(it,ut)};k(on,it=>{t(Ye)&&it(zt)})}var dn=f(on,2);{var tn=it=>{var ut=Jb();h(it,ut)},Et=it=>{var ut=ev();Ln(ut,21,()=>t(Q),Mt=>Mt.id,(Mt,un)=>{var pn=Qb(),ye=d(pn),Fe=d(ye),gt=d(Fe,!0);c(Fe);var S=f(Fe,2),C=d(S);c(S),c(ye);var J=f(ye,2);c(pn),E((pe,Ge,Oe)=>{an(pn,1,`flex items-start gap-2 border-b border-brand-border/50 px-3 py-2 last:border-b-0 ${t(Ye)?.id===t(un).id?"bg-brand-surface-3/60":""}`),ye.disabled=t(Rt),Y(ye,"title",t(Rt)?"Open a session first to load this draft":t(un).text),I(gt,pe),I(C,`${Ge??""}${Oe??""}`)},[()=>tu(t(un).text),()=>new Date(t(un).updatedAt).toLocaleString(),()=>ai(t(un))?` · ${ai(t(un))}`:""]),M("click",ye,()=>Me(t(un))),M("click",J,()=>Ct(t(un).id)),h(Mt,pn)}),c(ut),h(it,ut)};k(dn,it=>{t(Q).length===0?it(tn):it(Et,-1)})}var vt=f(dn,2);{var xn=it=>{var ut=tv(),Mt=d(ut);c(ut),E(()=>I(Mt,`⚠️ ${t(Se)??""}`)),h(it,ut)};k(vt,it=>{t(Se)&&it(xn)})}c(G),E(()=>I(qe,`Saved drafts (${t(Q).length??""}) `)),M("click",Zt,Pt),h(w,G)};k(mn,w=>{t(H)&&w(Mn)})}var qt=f(mn,2);{var Fn=w=>{var G=av(),de=d(G);{var Ee=_e=>{var ge=rv();pt(2),h(_e,ge)},qe=_e=>{var ge=sv(),Zt=f(Dt(ge),2),on=d(Zt,!0);c(Zt),E(()=>I(on,t(Be).error)),h(_e,ge)},Le=_e=>{var ge=ov();pt(2),h(_e,ge)};k(de,_e=>{t(Be).connecting?_e(Ee):t(Be).error?_e(qe,1):t(_t)||_e(Le,2)})}c(G),h(w,G)};k(qt,w=>{(!t(_t)||t(Be).connecting||t(Be).error)&&w(Fn)})}var F=f(qt,2);{var te=w=>{var G=iv(),de=d(G),Ee=d(de),qe=d(Ee),Le=d(qe,!0);c(qe);var _e=f(qe,2),ge=d(_e);{var Zt=Et=>{var vt=qn();E(()=>I(vt,e.placeholder??"Search the web...")),h(Et,vt)},on=Et=>{var vt=qn("Agent is working, tap to Steer...");h(Et,vt)},zt=Et=>{var vt=qn("Read-only mode");h(Et,vt)},dn=Et=>{var vt=qn("Select a session first...");h(Et,vt)},tn=Et=>{var vt=qn("Tap to type a message...");h(Et,vt)};k(ge,Et=>{_()?Et(Zt):t(et)?Et(on,1):t(dt)?Et(zt,2):t(ht).sessionId?Et(tn,-1):Et(dn,3)})}c(_e),c(Ee),pt(2),c(de),c(G),E(()=>I(Le,_()?"🔍":"💬")),M("click",de,()=>{p(re,!1),setTimeout(()=>t(ot)?.focus(),50)}),h(w,G)},Ce=w=>{var G=Ev(),de=Dt(G);{var Ee=V=>{var me=_v();Ln(me,21,()=>t(oe),ft=>ft.id,(ft,mt)=>{const Ht=P(()=>t(mt).upload?Pb(t(mt).upload):null),R=P(()=>t(mt).upload?Rc(t(mt).upload.state):!1);var D=xv(),se=d(D),ze=d(se,!0);c(se);var tt=f(se,2);{var O=be=>{var We=lv();h(be,We)},l=be=>{var We=cv();h(be,We)},y=be=>{var We=dv();pt(2),h(be,We)},A=be=>{var We=fv(),lt=Dt(We);Y(lt,"aria-valuemin",0),Y(lt,"aria-valuemax",100);var Pe=d(lt);c(lt);var $t=f(lt,2),fn=d($t);c($t);var hn=f($t,2);{var jt=Ot=>{var xe=uv();h(Ot,xe)};k(hn,Ot=>{t(Ht).kind==="finishing"&&Ot(jt)})}E(()=>{Y(lt,"aria-valuenow",t(Ht).percent),aa(Pe,`width: ${t(Ht).percent??""}%`),I(fn,`${t(Ht).percent??""}%`)}),h(be,We)},z=be=>{var We=vv(),lt=Dt(We),Pe=d(lt),$t=d(Pe);c(Pe);var fn=f(Pe,2);{var hn=Ve=>{var j=pv();h(Ve,j)},jt=Ve=>{var j=hv();E(()=>Y(j,"href",t(mt).url)),h(Ve,j)};k(fn,Ve=>{t(Ht).pickAgain?Ve(hn):t(mt).url&&Ve(jt,1)})}c(lt);var Ot=f(lt,2);{var xe=Ve=>{var j=bv();M("click",j,()=>kt(t(mt).id)),h(Ve,j)};k(Ot,Ve=>{t(Ht).retry&&t(mt).retryFile&&Ve(xe)})}E(()=>{Y(lt,"title",t(Ht).message),I($t,`⚠️ ${t(Ht).message??""}`)}),h(be,We)},ke=be=>{var We=gv();h(be,We)};k(tt,be=>{t(mt).file?be(O):t(Ht)?.kind==="pending"||t(Ht)?.kind==="indeterminate"?be(l,1):t(Ht)?.kind==="waiting"?be(y,2):t(Ht)?.kind==="progress"||t(Ht)?.kind==="finishing"?be(A,3):t(Ht)?.kind==="failed"?be(z,4):be(ke,-1)})}var De=f(tt,2);{var ue=be=>{var We=mv();M("click",We,()=>at(t(mt).id)),h(be,We)};k(De,be=>{t(R)&&be(ue)})}var he=f(De,2);c(D),E(()=>{an(D,1,`flex items-center gap-2 rounded border bg-brand-surface-2 px-2.5 py-1.5 text-xs ${t(R)?"border-brand-blue":"border-brand-border"}`),Y(se,"title",t(mt).name),I(ze,t(mt).name)}),M("click",he,()=>wn(t(mt).id)),h(ft,D)}),c(me),h(V,me)};k(de,V=>{t(oe).length>0&&V(Ee)})}var qe=f(de,2);{var Le=V=>{var me=wv(),ft=f(d(me),2);Ln(ft,21,L,pr,(mt,Ht)=>{var R=yv(),D=d(R,!0);c(R);var se={};E(()=>{I(D,t(Ht).label),se!==(se=t(Ht).value)&&(R.value=(R.__value=t(Ht).value)??"")}),h(mt,R)}),c(ft),c(me),E(()=>ft.disabled=t(Rt)),xs(ft,B),h(V,me)};k(qe,V=>{_()&&L().length>0&&V(Le)})}var _e=f(qe,2),ge=d(_e),Zt=d(ge);{var on=V=>{var me=Tv();Ln(me,23,()=>t(yt),ft=>ft.name,(ft,mt,Ht)=>{var R=Sv(),D=d(R),se=d(D),ze=d(se);c(se);var tt=f(se,2);{var O=l=>{var y=kv(),A=d(y,!0);c(y),E(()=>I(A,t(mt).description)),h(l,y)};k(tt,l=>{t(mt).description&&l(O)})}c(D),c(R),E(()=>{Y(D,"aria-selected",t(Ht)===t(K)),an(D,1,`flex w-full flex-col items-start gap-0.5 px-3 py-1.5 text-left text-sm ${t(Ht)===t(K)?"bg-brand-surface-3 text-brand-text":"text-brand-text-muted hover:bg-brand-surface-3/60"}`),I(ze,`/${t(mt).name??""}`)}),M("mousedown",D,l=>{l.preventDefault(),Ft(t(mt).name)}),wr("mouseenter",D,()=>p(K,t(Ht),!0)),h(ft,R)}),c(me),h(V,me)};k(Zt,V=>{t(ce)&&t(yt).length>0&&V(on)})}var zt=f(Zt,2);id(zt),Y(zt,"rows",1),ir(zt,V=>p(ot,V),()=>t(ot)),c(ge);var dn=f(ge,2),tn=d(dn);{var Et=V=>{var me=Av(),ft=Dt(me),mt=f(ft,2);ir(mt,Ht=>p(je,Ht),()=>t(je)),E(()=>ft.disabled=t(Rt)),M("click",ft,()=>{Ml(),t(je)?.click()}),M("change",mt,sn),h(V,me)};k(tn,V=>{x()&&V(Et)})}var vt=f(tn,2),xn=d(vt);ir(Vb(xn,{get disabled(){return t(Rt)},onSend:In,get text(){return t(W)},set text(V){p(W,V,!0)},get activeEngine(){return t(Ke)},set activeEngine(V){p(Ke,V,!0)}}),V=>p(ve,V,!0),()=>t(ve)),c(vt);var it=f(vt,2),ut=d(it);{var Mt=V=>{var me=qn();E(()=>I(me,e.submitLabel??"Search")),h(V,me)},un=V=>{var me=qn("Steer");h(V,me)},pn=V=>{var me=qn("Send");h(V,me)};k(ut,V=>{_()?V(Mt):t(et)?V(un,1):V(pn,-1)})}c(it),c(dn),c(_e);var ye=f(_e,2),Fe=d(ye),gt=d(Fe);Tt(gt),pt(2),c(Fe);var S=f(Fe,2),C=d(S),J=d(C,!0);c(C);var pe=f(C,2),Ge=d(pe);c(pe);var Oe=f(pe,2),ee=f(Oe,2);{var Re=V=>{var me=Cv();h(V,me)};k(ee,V=>{t(Ne)||V(Re)})}c(S),c(ye),E(V=>{zt.disabled=t(Rt),Y(zt,"placeholder",_()?e.placeholder??"Search the web...":t(_t)?t(et)?"Agent is working, Steer to interrupt...":t(dt)?"Read-only mode":t(ht).sessionId?"Type a message...":"Select a session first...":t(Be).connecting?"Reconnecting... you can keep typing":"Disconnected - you can type, sending resumes once reconnected"),it.disabled=!t(Kt),Y(it,"title",!_()&&t(et)?"Steer the agent now (injected at the next step, before the next model call)":void 0),ra(gt,t(Ne)),C.disabled=V,Y(C,"title",t(_t)?"Save this message as a draft instead of sending it":"Drafts are stored on the server, which is not reachable right now"),I(J,t(U)?"✓ Saved":"💾 Save draft"),Y(pe,"aria-expanded",t(H)),I(Ge,`🗂 Drafts${t(Q).length>0?` (${t(Q).length})`:""}`)},[()=>t(W).trim().length===0||!t(_t)]),wr("submit",_e,V=>{V.preventDefault(),In()}),M("keydown",zt,Rn),ar(zt,()=>t(W),V=>p(W,V)),M("change",gt,An),M("click",C,ne),M("click",pe,wt),M("click",Oe,()=>p(re,!0)),h(w,G)};k(F,w=>{t(re)?w(te):w(Ce,-1)})}c(kn),h(n,kn);var $e=br(Gn);return v(),$e}Mr(["click","mousedown","keydown","change"]);function Mv(n){const e=new Map;for(const x of n)e.set(x.path,x);const r=new Map,s=[];for(const x of n){const _=x.parentSessionPath;_&&e.has(_)&&_!==x.path?(r.has(_)||r.set(_,[]),r.get(_).push(x)):s.push(x)}const o=new Map,a=new Set,i=x=>{const _=o.get(x.path);if(_!==void 0)return _;if(a.has(x.path))return x.modified??"";a.add(x.path);let $=x.modified??"";for(const L of r.get(x.path)??[]){const B=i(L);B.localeCompare($)>0&&($=B)}return a.delete(x.path),o.set(x.path,$),$},u=(x,_)=>i(_).localeCompare(i(x))||(_.modified??"").localeCompare(x.modified??"")||x.path.localeCompare(_.path),m=[],v=new Set,g=(x,_)=>{if(!v.has(x.path)){v.add(x.path),m.push({session:x,depth:_});for(const $ of[...r.get(x.path)??[]].sort(u))g($,_+1)}};for(const x of[...s].sort(u))g(x,0);for(const x of n)v.has(x.path)||m.push({session:x,depth:0});return m}var $v=b('<button type="button" class="mt-1.5 w-full truncate rounded px-1 py-0.5 text-left text-[10px] text-brand-blue hover:underline"> </button>'),Ov=b('<button type="button" class="block w-full px-2.5 py-1 text-left text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"> </button>'),Lv=b('<div class="absolute right-0 left-0 z-50 mt-1 max-h-40 overflow-y-auto rounded border border-brand-border bg-brand-surface-2 py-1 shadow-xl"></div>'),Dv=b('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Pv=b('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),Nv=b("<option> </option>"),Uv=b('<select id="sidebar-model" class="w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Fv=b('<input id="sidebar-model" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-dark/60 px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/>'),Bv=b('<div class="flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-visibility" class="border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-visibility" class="border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),zv=b('<div class="space-y-1 py-0.5"><div class="flex items-center gap-1.5"><input id="sidebar-create-remote" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="sidebar-create-remote" class="cursor-pointer text-xs text-brand-text select-none"> </label></div> <!></div>'),Hv=b('<div class="flex items-center gap-1.5 py-0.5"><input id="sidebar-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-brand-blue focus:ring-offset-brand-surface"/> <label for="sidebar-git-init" class="cursor-pointer text-xs text-brand-text select-none">Initialize Git repository</label></div>'),jv=b('<form class="space-y-2.5 border-t border-brand-border/30 bg-brand-surface/30 p-3"><div><label class="mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase" for="sidebar-folder">Folder Path</label> <div class="relative"><input id="sidebar-folder" type="text" autocomplete="off" spellcheck="false" placeholder="e.g. ~/projects/my-new-app"/> <!></div> <!></div> <div><label class="mb-1 block text-[10px] font-bold tracking-wider text-brand-text-muted uppercase" for="sidebar-model">Model</label> <!></div> <!> <!> <button type="submit" class="w-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50">Create Session</button></form>'),Gv=b('<div class="border-b border-brand-border/50 bg-brand-surface/10"><button class="flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/30"><span> </span></button> <!></div>'),Wv=b('<div class="p-4 text-center text-brand-text-muted"><div class="inline-block h-4 w-4 animate-spin rounded-full border-2 border-brand-text-muted border-t-transparent"></div> <span class="ml-2 text-sm">Loading sessions...</span></div>'),Kv=b('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),qv=b('<span class="flex-shrink-0 rounded border border-brand-purple/50 bg-brand-purple/15 px-1.5 py-px text-[10px] font-semibold tracking-wide text-brand-purple uppercase" title="This folder does not exist on this machine. Open a session in it to clone or create it.">Missing</span>'),Vv=b('<div class="flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5"><button class="px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none" title="Confirm Delete All">Delete All?</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),Yv=b('<button class="rounded px-2 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-rose-400 focus:outline-none" title="Delete all sessions in this folder">Delete All</button>'),Xv=b('<div class="mb-1.5 flex items-center justify-between"><button class="rounded px-2 py-1 text-left text-xs text-brand-blue transition-colors hover:bg-brand-surface-3/50 hover:opacity-90">+ New Session Here</button> <div class="flex-shrink-0"><!></div></div>'),Zv=b('<span class="flex-shrink-0 text-brand-text-muted" title="Forked from the session above" aria-label="Forked session">↳</span>'),Jv=b('<span class="h-2 w-2 flex-shrink-0 animate-pulse rounded-full bg-amber-400" role="img" title="Agent is working" aria-label="Agent is working"></span>'),Qv=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),eg=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),tg=b('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),ng=b('<div class="flex items-center gap-1 rounded border border-red-500/30 bg-brand-surface-2/80 px-1 py-0.5"><button class="px-1.5 text-xs font-bold text-rose-400 hover:text-rose-300 focus:outline-none" title="Confirm Delete">❓</button> <button class="px-1.5 text-[10px] text-brand-text-muted hover:text-brand-text focus:outline-none" title="Cancel">✕</button></div>'),rg=b('<button class="p-1 text-xs text-brand-text-muted transition-opacity hover:text-rose-400 focus:outline-none md:opacity-0 md:group-hover:opacity-100" title="Delete session">✕</button>'),sg=b('<div class="flex-shrink-0"><!></div>'),og=b('<div><!> <a class="flex min-w-0 flex-1 items-center gap-2 text-left no-underline"><!> <div class="min-w-0 flex-1"><div class="truncate text-xs text-brand-text"> </div> <div class="text-xs text-brand-text-muted"> </div></div> <!></a> <button> </button> <!></div>'),ag=b('<div class="px-3 pb-2"><!> <!></div>'),ig=b('<div class="border-b border-brand-border/50"><button class="flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-brand-surface-3/50"><span>▶</span> <div class="min-w-0 flex-1"><div class="flex items-center gap-1.5"><div class="truncate text-sm font-medium text-brand-text"> </div> <!></div> <div class="truncate text-[10px] text-brand-text-muted"> </div></div> <span class="text-xs text-brand-text-muted"> </span></button> <!></div>'),lg=b("<option> </option>"),cg=b('<select id="model-select" class="w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text"></select>'),dg=b('<input id="model-select" type="text" placeholder="provider:model" class="w-full rounded border border-brand-border bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted"/>'),ug=b('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60" role="presentation"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-6" role="dialog" tabindex="-1"><h3 class="mb-4 text-sm font-bold text-brand-text">New Session</h3> <div class="mb-4"><span class="mb-1 block text-xs text-brand-text-muted">Folder</span> <div class="truncate rounded bg-brand-surface-3 px-2 py-1.5 text-xs text-brand-text"> </div></div> <div class="mb-4"><label class="mb-1 block text-xs text-brand-text-muted" for="model-select">Model</label> <!></div> <div class="flex justify-end gap-2"><button class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Create</button></div></div></div>'),fg=b('<div class="absolute right-0 bottom-0 left-0 flex items-center justify-between border-t border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-rose-400"><span class="truncate"> </span> <button class="ml-2 flex-shrink-0 text-rose-300 hover:text-rose-200">✕</button></div>'),pg=b('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),hg=b('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),bg=b('<div class="flex items-center gap-3 pl-5 text-[10px] text-brand-text-muted"><span>Visibility:</span> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Private</label> <label class="flex cursor-pointer items-center gap-1 transition-colors select-none hover:text-brand-text"><input type="radio" name="sidebar-modal-visibility" class="border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> Public</label></div>'),vg=b('<div class="space-y-1"><div class="flex items-center gap-1.5"><input id="sidebar-modal-create-remote" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue"/> <label for="sidebar-modal-create-remote" class="cursor-pointer text-xs text-brand-text select-none"> </label></div> <!></div>'),gg=b('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4" role="dialog" aria-modal="true"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-5 text-brand-text"><h3 class="mb-2 text-sm font-bold text-brand-text">Folder Already Exists</h3> <p class="mb-3 text-xs text-brand-text-muted">The folder <span class="font-mono text-[11px] break-all text-brand-text"> </span> already exists. Do you want to initialize a Git repository in it?</p> <div class="mb-4 flex flex-col gap-3"><div class="flex items-center gap-1.5"><input id="sidebar-modal-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50"/> <label for="sidebar-modal-git-init" class="cursor-pointer text-xs text-brand-text select-none disabled:opacity-50">Initialize Git repository <!></label></div> <!></div> <div class="flex justify-end gap-2"><button type="button" class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button type="button" class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Confirm & Create</button></div></div></div>'),mg=b('<div class="flex h-full flex-col"><div class="border-b border-brand-border/50 p-2"><div class="flex gap-1.5"><input type="text" placeholder="Filter sessions..." class="min-w-0 flex-1 rounded border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-xs text-brand-text placeholder-brand-text-muted focus:border-brand-blue focus:outline-none"/> <button type="button" class="flex shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-1.5 py-1.5 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Refresh session list"><span>↻</span></button></div> <!></div> <div class="flex-1 overflow-y-auto"><!> <!></div></div> <!> <!> <!>',1);function zi(n,e){hr(e,!0);const r=()=>we(Ji,"$readOnlySessionFolders",x),s=()=>we(Qi,"$sessionFolders",x),o=()=>we(rs,"$activeSessionInfo",x),a=()=>we(Cs,"$isConnected",x),i=()=>we(Es,"$isLoadingSession",x),u=()=>we(Rs,"$isResyncing",x),m=()=>we(sa,"$availableModels",x),v=()=>we(oa,"$gitInitDefaultStore",x),g=()=>we(lo,"$sessionError",x),[x,_]=Ur(),$=[];let L=ur(e,"readOnly",3,!1),B=P(()=>L()?r().folders:s().folders),W=P(()=>L()?r().loading:s().loading);function Ne(){L()?Zi():bs()}let re=P(()=>o().sessionFile),Ke=P(a),ve=P(i),ce=P(u),K=P(()=>m().models),je=Vn({}),Qe=N(Vn({})),Ue=N(null),oe=N(null),et=N(""),dt=N(Vn([]));Ut(()=>{t(Ke)&&(Ne(),L()||(hd(),Yi()))});function ht(F,te,Ce){if(!Ce)return!0;const $e=Ce.toLowerCase();return(F.name||"").toLowerCase().includes($e)||F.firstMessage.toLowerCase().includes($e)||te.toLowerCase().includes($e)}Ut(()=>{const F=t(et),te=t(B);F?p(dt,te.map(Ce=>({...Ce,sessions:Ce.sessions.filter($e=>ht($e,Ce.name,F))})).filter(Ce=>Ce.sessions.length>0),!0):(p(dt,te,!0),p(Qe,{},!0))});function _t(F,te){el(F,te).catch(()=>{})}function Be(F){return t(et)?t(Qe)[F]!==void 0?t(Qe)[F]:!0:!!je[F]}function nt(F){t(et)?t(Qe)[F]=!Be(F):je[F]=!Be(F)}async function yt(F){try{t(re)===F&&(typeof window<"u"&&(window.location.hash=""),fr()),await qo(F),t(Ue)===F&&p(Ue,null),bs()}catch(te){console.error("Failed to delete session:",te)}}async function Ft(F){try{const te=F.sessions.map(Ce=>Ce.path);t(re)&&te.includes(t(re))&&(typeof window<"u"&&(window.location.hash=""),fr()),await Promise.all(F.sessions.map(Ce=>qo(Ce.path))),t(oe)===F.path&&p(oe,null),bs()}catch(te){console.error("Failed to delete all sessions of folder:",te)}}function Rt(F){t(re)===F&&!t(ve)&&!t(ce)||(Dr(),As(F))}let Wt=N(!1),ae=N(""),Kt=N(Vn([])),ot=N(!1),Bt=N(null),At=N(null),It="",Q=N(""),H=N(!1),Ye=N(null),fe=N(!0),U=N("private"),Se=N(!1),X=P(v);Ut(()=>{t(Ye)===null&&p(H,t(X),!0)});let le=N(Vn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),Te=P(()=>t(le).exists!==!0&&t(le).matchingRule&&t(fe)),T=null;async function Z(F,te=!1){if(T&&clearTimeout(T),F===It&&!te)return;if(It=F,!F.trim()){p(le,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const $e=async()=>{const w=await Ks("");p(Kt,w||[],!0)};te?await $e():T=setTimeout($e,300);return}const Ce=async()=>{const[$e,w]=await Promise.all([Vi(F),Ks(F)]);p(Kt,w||[],!0),$e?(p(le,{exists:$e.exists,isGit:$e.isGit,resolvedPath:$e.resolvedPath,matchingRule:$e.matchingRule||null},!0),$e.exists||(p(H,t(Ye)!==null?t(Ye):t(X),!0),p(fe,!0),$e.matchingRule&&p(U,$e.matchingRule.visibility,!0))):p(le,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};te?await Ce():T=setTimeout(Ce,300)}Ut(()=>{const F=t(ae);Z(F,!1)}),Ut(()=>{if(t(K).length>0&&!t(Q)){const F=t(K).find(te=>te.isDefault);F?p(Q,`${F.provider}:${F.modelId}`):p(Q,`${t(K)[0].provider}:${t(K)[0].modelId}`)}});function q(){if(t(ae).trim())if(t(le).exists===!0)p(H,!1),p(fe,!1),t(le).matchingRule&&p(U,t(le).matchingRule.visibility,!0),p(Se,!0);else{Dr();const F=t(ae).trim(),te=t(Q)||void 0,Ce=t(H),$e=t(le).matchingRule?t(fe):void 0,w=t(le).matchingRule?t(U):void 0;p(ae,""),p(Wt,!1),t(re)?(fr(),setTimeout(()=>{yr(F,te,Ce,$e,w)},100)):yr(F,te,Ce,$e,w)}}function Ae(){p(Se,!1),Dr();const F=t(ae).trim(),te=t(Q)||void 0,Ce=t(H),$e=t(le).matchingRule?t(fe):void 0,w=t(le).matchingRule?t(U):void 0;p(ae,""),p(Wt,!1),t(re)?(fr(),setTimeout(()=>{yr(F,te,Ce,$e,w)},100)):yr(F,te,Ce,$e,w)}let Ie=N(Vn({open:!1,folderPath:"",selected:""}));function rt(F){const te=t(K).find(Ce=>Ce.isDefault);p(Ie,{open:!0,folderPath:F,selected:te?`${te.provider}:${te.modelId}`:""},!0)}function ne(){t(Ie).open=!1}function Me(){if(!t(Ie).open)return;Dr();const F=t(Ie).folderPath,te=t(Ie).selected||void 0;ne(),t(re)?(fr(),setTimeout(()=>{yr(F,te)},100)):yr(F,te)}function Xe(F){const te=Date.now()-new Date(F).getTime(),Ce=Math.floor(te/6e4);if(Ce<1)return"just now";if(Ce<60)return`${Ce}m ago`;const $e=Math.floor(Ce/60);return $e<24?`${$e}h ago`:`${Math.floor($e/24)}d ago`}function bt(F,te=40){return F.length>te?F.slice(0,te)+"...":F}var Ct=mg(),wt=Dt(Ct),Pt=d(wt),ln=d(Pt),Qt=d(ln);Tt(Qt);var yn=f(Qt,2),An=d(yn);c(yn),c(ln);var sn=f(ln,2);{var en=F=>{var te=$v(),Ce=d(te);c(te),E($e=>I(Ce,`🔎 Search all conversations for “${$e??""}”`),[()=>t(et).trim()]),M("click",te,()=>e.onSearchAll?.(t(et).trim())),h(F,te)},cn=P(()=>e.onSearchAll&&t(et).trim().length>=2);k(sn,F=>{t(cn)&&F(en)})}c(Pt);var Sn=f(Pt,2),Cn=d(Sn);{var at=F=>{var te=Gv(),Ce=d(te),$e=d(Ce),w=d($e,!0);c($e),c(Ce);var G=f(Ce,2);{var de=Ee=>{var qe=jv(),Le=d(qe),_e=f(d(Le),2),ge=d(_e);Tt(ge),ir(ge,ye=>p(Bt,ye),()=>t(Bt));var Zt=f(ge,2);{var on=ye=>{var Fe=Lv();Ln(Fe,21,()=>t(Kt),pr,(gt,S)=>{var C=Ov(),J=d(C,!0);c(C),E(()=>I(J,t(S))),M("click",C,()=>{p(ae,t(S),!0),Z(t(S),!0),t(Bt)?.focus()}),h(gt,C)}),c(Fe),h(ye,Fe)};k(Zt,ye=>{t(ot)&&t(Kt).length>0&&ye(on)})}c(_e),ir(_e,ye=>p(At,ye),()=>t(At));var zt=f(_e,2);{var dn=ye=>{var Fe=Pv(),gt=f(d(Fe));{var S=C=>{var J=Dv();h(C,J)};k(gt,C=>{t(le).isGit&&C(S)})}c(Fe),h(ye,Fe)};k(zt,ye=>{t(le).exists===!0&&ye(dn)})}c(Le);var tn=f(Le,2),Et=f(d(tn),2);{var vt=ye=>{var Fe=Uv();Ln(Fe,21,()=>t(K),pr,(gt,S)=>{var C=Nv(),J=d(C);c(C);var pe={};E(()=>{I(J,`${t(S).label??""}${t(S).isDefault?" (default)":""}`),pe!==(pe=`${t(S).provider}:${t(S).modelId}`)&&(C.value=C.__value=`${t(S).provider}:${t(S).modelId}`)}),h(gt,C)}),c(Fe),xs(Fe,()=>t(Q),gt=>p(Q,gt)),h(ye,Fe)},xn=ye=>{var Fe=Fv();Tt(Fe),ar(Fe,()=>t(Q),gt=>p(Q,gt)),h(ye,Fe)};k(Et,ye=>{t(K).length>0?ye(vt):ye(xn,-1)})}c(tn);var it=f(tn,2);{var ut=ye=>{var Fe=zv(),gt=d(Fe),S=d(gt);Tt(S);var C=f(S,2),J=d(C);c(C),c(gt);var pe=f(gt,2);{var Ge=Oe=>{var ee=Bv(),Re=f(d(ee),2),V=d(Re);Tt(V),V.value=V.__value="private",pt(),c(Re);var me=f(Re,2),ft=d(me);Tt(ft),ft.value=ft.__value="public",pt(),c(me),c(ee),Nr($,[],V,()=>t(U),mt=>p(U,mt)),Nr($,[],ft,()=>t(U),mt=>p(U,mt)),h(Oe,ee)};k(pe,Oe=>{t(fe)&&Oe(Ge)})}c(Fe),E(()=>I(J,`Create remote ${t(le).matchingRule.provider??""} repository`)),Zn(S,()=>t(fe),Oe=>p(fe,Oe)),h(ye,Fe)};k(it,ye=>{t(le).exists!==!0&&t(le).matchingRule&&ye(ut)})}var Mt=f(it,2);{var un=ye=>{var Fe=Hv(),gt=d(Fe);Tt(gt),pt(2),c(Fe),M("change",gt,S=>{p(Ye,S.currentTarget.checked,!0)}),Zn(gt,()=>t(H),S=>p(H,S)),h(ye,Fe)};k(Mt,ye=>{t(le).exists!==!0&&(!t(le).matchingRule||!t(fe))&&ye(un)})}var pn=f(Mt,2);c(qe),E(ye=>{an(ge,1,`w-full rounded border px-2 py-1 text-xs text-brand-text placeholder-brand-text-muted transition-all duration-200 focus:outline-none ${t(Te)?"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"}`),pn.disabled=ye},[()=>!t(ae).trim()]),wr("submit",qe,ye=>{ye.preventDefault(),q()}),wr("focus",ge,()=>{p(ot,!0),Z(t(ae),!0)}),wr("blur",ge,ye=>{t(At)&&t(At).contains(ye.relatedTarget)||p(ot,!1)}),M("keydown",ge,ye=>{ye.key==="Escape"&&p(ot,!1)}),ar(ge,()=>t(ae),ye=>p(ae,ye)),h(Ee,qe)};k(G,Ee=>{t(Wt)&&Ee(de)})}c(te),E(()=>I(w,t(Wt)?"▼ Close Create Session":"✚ Create New Session")),M("click",Ce,()=>p(Wt,!t(Wt))),h(F,te)};k(Cn,F=>{L()||F(at)})}var kt=f(Cn,2);{var wn=F=>{var te=Wv();h(F,te)},In=F=>{var te=Kv(),Ce=d(te,!0);c(te),E(()=>I(Ce,t(et)?"No sessions match your filter":"No sessions found")),h(F,te)},Rn=F=>{var te=dr(),Ce=Dt(te);Ln(Ce,17,()=>t(dt),$e=>$e.path,($e,w)=>{var G=ig(),de=d(G),Ee=d(de),qe=f(Ee,2),Le=d(qe),_e=d(Le),ge=d(_e,!0);c(_e);var Zt=f(_e,2);{var on=ut=>{var Mt=qv();h(ut,Mt)};k(Zt,ut=>{t(w).missing&&ut(on)})}c(Le);var zt=f(Le,2),dn=d(zt,!0);c(zt),c(qe);var tn=f(qe,2),Et=d(tn,!0);c(tn),c(de);var vt=f(de,2);{var xn=ut=>{var Mt=ag(),un=d(Mt);{var pn=Fe=>{var gt=Xv(),S=d(gt),C=f(S,2),J=d(C);{var pe=Oe=>{var ee=Vv(),Re=d(ee),V=f(Re,2);c(ee),M("click",Re,me=>{me.stopPropagation(),Ft(t(w))}),M("click",V,me=>{me.stopPropagation(),p(oe,null)}),h(Oe,ee)},Ge=Oe=>{var ee=Yv();M("click",ee,Re=>{Re.stopPropagation(),p(oe,t(w).path,!0)}),h(Oe,ee)};k(J,Oe=>{t(oe)===t(w).path?Oe(pe):Oe(Ge,-1)})}c(C),c(gt),M("click",S,()=>rt(t(w).path)),h(Fe,gt)};k(un,Fe=>{L()||Fe(pn)})}var ye=f(un,2);Ln(ye,17,()=>Mv(t(w).sessions),({session:Fe,depth:gt})=>Fe.path,(Fe,gt)=>{let S=()=>t(gt).session,C=()=>t(gt).depth;var J=og(),pe=d(J);{var Ge=A=>{var z=Zv();h(A,z)};k(pe,A=>{C()>0&&A(Ge)})}var Oe=f(pe,2),ee=d(Oe);{var Re=A=>{var z=Jv();h(A,z)},V=A=>{var z=Qv();h(A,z)},me=A=>{var z=eg();h(A,z)};k(ee,A=>{S().isWorking?A(Re):S().isActive?A(V,1):A(me,-1)})}var ft=f(ee,2),mt=d(ft),Ht=d(mt,!0);c(mt);var R=f(mt,2),D=d(R);c(R),c(ft);var se=f(ft,2);{var ze=A=>{var z=tg(),ke=d(z,!0);c(z),E(()=>I(ke,S().clientCount)),h(A,z)};k(se,A=>{S().clientCount>0&&A(ze)})}c(Oe);var tt=f(Oe,2),O=d(tt,!0);c(tt);var l=f(tt,2);{var y=A=>{var z=sg(),ke=d(z);{var De=he=>{var be=ng(),We=d(be),lt=f(We,2);c(be),M("click",We,Pe=>{Pe.stopPropagation(),yt(S().path)}),M("click",lt,Pe=>{Pe.stopPropagation(),p(Ue,null)}),h(he,be)},ue=he=>{var be=rg();M("click",be,We=>{We.stopPropagation(),p(Ue,S().path,!0)}),h(he,be)};k(ke,he=>{t(Ue)===S().path?he(De):he(ue,-1)})}c(z),h(A,z)};k(l,A=>{L()||A(y)})}c(J),E((A,z,ke)=>{aa(J,C()>0?`margin-left: ${C()*.85}rem`:""),an(J,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 ${C()>0?"border-l border-brand-border/60 pl-2":""} ${t(re)===S().path?"bg-brand-surface-3":""}`),Y(Oe,"href",`#${A??""}`),I(Ht,z),I(D,`${ke??""} · ${S().messageCount??""}
|
|
99
|
-
msgs`),an(tt,1,`flex-shrink-0 p-1 text-sm focus:outline-none ${S().starred?"text-amber-400 hover:text-brand-text-muted":"text-brand-text-muted transition-opacity hover:text-amber-400 md:opacity-0 md:group-hover:opacity-100"}`),Y(tt,"title",S().starred?"Unstar":"Star to come back to it later"),Y(tt,"aria-label",S().starred?"Unstar session":"Star session"),I(O,S().starred?"★":"☆")},[()=>encodeURIComponent(S().id),()=>S().name||bt(S().firstMessage)||"Empty session",()=>Xe(S().modified)]),M("click",Oe,A=>{A.button===0&&!A.ctrlKey&&!A.metaKey&&!A.altKey&&!A.shiftKey&&(A.preventDefault(),Rt(S().path))}),M("click",tt,A=>{A.stopPropagation(),_t(S().path,!S().starred)}),h(Fe,J)}),c(Mt),h(ut,Mt)},it=P(()=>Be(t(w).path));k(vt,ut=>{t(it)&&ut(xn)})}c(G),E(ut=>{an(Ee,1,`text-xs text-brand-text-muted transition-transform ${ut??""}`),I(ge,t(w).name),I(dn,t(w).path),I(Et,t(w).sessions.length)},[()=>Be(t(w).path)?"rotate-90":""]),M("click",de,()=>nt(t(w).path)),h($e,G)}),h(F,te)};k(kt,F=>{t(W)&&t(dt).length===0?F(wn):t(dt).length===0?F(In,1):F(Rn,-1)})}c(Sn),c(wt);var Gn=f(wt,2);{var kn=F=>{var te=ug(),Ce=d(te),$e=f(d(Ce),2),w=f(d($e),2),G=d(w,!0);c(w),c($e);var de=f($e,2),Ee=f(d(de),2);{var qe=on=>{var zt=cg();Ln(zt,21,()=>t(K),pr,(dn,tn)=>{var Et=lg(),vt=d(Et);c(Et);var xn={};E(()=>{I(vt,`${t(tn).label??""}${t(tn).isDefault?" (default)":""}`),xn!==(xn=`${t(tn).provider}:${t(tn).modelId}`)&&(Et.value=Et.__value=`${t(tn).provider}:${t(tn).modelId}`)}),h(dn,Et)}),c(zt),xs(zt,()=>t(Ie).selected,dn=>t(Ie).selected=dn),h(on,zt)},Le=on=>{var zt=dg();Tt(zt),ar(zt,()=>t(Ie).selected,dn=>t(Ie).selected=dn),h(on,zt)};k(Ee,on=>{t(K).length>0?on(qe):on(Le,-1)})}c(de);var _e=f(de,2),ge=d(_e),Zt=f(ge,2);c(_e),c(Ce),c(te),E(()=>I(G,t(Ie).folderPath)),M("click",te,ne),M("click",Ce,on=>on.stopPropagation()),M("click",ge,ne),M("click",Zt,Me),h(F,te)};k(Gn,F=>{t(Ie).open&&F(kn)})}var mn=f(Gn,2);{var Mn=F=>{var te=fg(),Ce=d(te),$e=d(Ce,!0);c(Ce);var w=f(Ce,2);c(te),E(()=>I($e,g())),M("click",w,()=>Dr()),h(F,te)};k(mn,F=>{g()&&F(Mn)})}var qt=f(mn,2);{var Fn=F=>{var te=gg(),Ce=d(te),$e=f(d(Ce),2),w=f(d($e)),G=d(w,!0);c(w),pt(),c($e);var de=f($e,2),Ee=d(de),qe=d(Ee);Tt(qe);var Le=f(qe,2),_e=f(d(Le));{var ge=vt=>{var xn=pg();h(vt,xn)},Zt=vt=>{var xn=hg();h(vt,xn)};k(_e,vt=>{t(le).isGit?vt(ge):vt(Zt,-1)})}c(Le),c(Ee);var on=f(Ee,2);{var zt=vt=>{var xn=vg(),it=d(xn),ut=d(it);Tt(ut);var Mt=f(ut,2),un=d(Mt);c(Mt),c(it);var pn=f(it,2);{var ye=Fe=>{var gt=bg(),S=f(d(gt),2),C=d(S);Tt(C),C.value=C.__value="private",pt(),c(S);var J=f(S,2),pe=d(J);Tt(pe),pe.value=pe.__value="public",pt(),c(J),c(gt),Nr($,[],C,()=>t(U),Ge=>p(U,Ge)),Nr($,[],pe,()=>t(U),Ge=>p(U,Ge)),h(Fe,gt)};k(pn,Fe=>{t(fe)&&Fe(ye)})}c(xn),E(()=>I(un,`Create remote ${t(le).matchingRule.provider??""} repository`)),Zn(ut,()=>t(fe),Fe=>p(fe,Fe)),h(vt,xn)};k(on,vt=>{t(le).matchingRule&&vt(zt)})}c(de);var dn=f(de,2),tn=d(dn),Et=f(tn,2);c(dn),c(Ce),c(te),E(()=>{I(G,t(ae)),qe.disabled=t(le).isGit}),Zn(qe,()=>t(H),vt=>p(H,vt)),M("click",tn,()=>p(Se,!1)),M("click",Et,Ae),h(F,te)};k(qt,F=>{t(Se)&&F(Fn)})}E(()=>{Xi(Qt,t(et)),an(An,1,nl(t(W)?"animate-spin":""))}),M("input",Qt,F=>p(et,F.currentTarget.value,!0)),M("click",yn,()=>Ne()),h(n,Ct),br(),_()}Mr(["input","click","keydown","change"]);const xg="",Oo="";function Ic(n){if(!n)return[];const e=[];let r=n;for(;r.length>0;){const s=r.indexOf(xg);if(s<0){Us(e,r.split(Oo).join(""),!1);break}Us(e,r.slice(0,s).split(Oo).join(""),!1),r=r.slice(s+1);const o=r.indexOf(Oo);if(o<0){Us(e,r,!0);break}Us(e,r.slice(0,o),!0),r=r.slice(o+1)}return e}function Us(n,e,r){e&&n.push({text:e,match:r})}function _g(n){return Ic(n).map(e=>e.text).join("")}function yg(n,e){switch(n){case"user":return"you";case"assistant":return"agent";case"thinking":return"thinking";case"name":return"session name";case"summary":return"summary";case"bash":return"bash";case"toolCall":return e?`tool: ${e}`:"tool call";case"toolResult":return e?`output: ${e}`:"tool output";default:return n||"entry"}}function Hi(n,e=Date.now()){if(!n)return"";const r=Date.parse(n);if(Number.isNaN(r))return"";const s=Math.max(0,Math.round((e-r)/1e3));if(s<60)return"just now";const o=Math.round(s/60);if(o<60)return`${o}m ago`;const a=Math.round(o/60);if(a<24)return`${a}h ago`;const i=Math.round(a/24);if(i<30)return`${i}d ago`;const u=Math.round(i/30);return u<12?`${u}mo ago`:`${Math.round(u/12)}y ago`}var wg=b('<button><span class="mt-0.5 flex-shrink-0 text-brand-text-muted"> </span> <span class="min-w-0 flex-1"><span class="block truncate text-xs text-brand-text"> </span> <span class="block text-[10px] text-brand-text-muted"> </span></span></button>'),kg=b('<div class="p-3 text-xs text-brand-text-muted"></div>'),Sg=b('<div class="p-3 text-xs text-brand-text-muted">Searching…</div>'),Tg=b('<div class="break-all opacity-70"> </div>'),Ag=b(`<div class="space-y-2 p-3 text-xs text-brand-text-muted"><div class="font-semibold text-brand-text">No conversation index yet</div> <p>Search is backed by the <code class="text-brand-blue">memonaut</code> index,
|
|
100
|
-
which has not been built on this machine. Building it takes about a minute
|
|
101
|
-
and is deliberately never done from here, because it would freeze the server
|
|
102
|
-
while it ran.</p> <p>Run this on the server, then search again:</p> <pre class="overflow-x-auto rounded bg-brand-surface-2 p-2 text-brand-text">recall index</pre> <!></div>`),Cg=b('<div class="p-3 text-xs text-rose-400"> </div>'),Eg=b('<div class="mt-1 opacity-70"> </div>'),Rg=b('<div class="p-3 text-xs text-brand-text-muted"> <!></div>'),Ig=b("<span> </span>"),Mg=b('<span class="text-amber-400" title="Read-only session">👁️</span>'),$g=b('<mark class="rounded bg-brand-blue/30 px-0.5 text-brand-text"> </mark>'),Og=b('<div class="mt-0.5 border-l border-brand-border/40 pl-2"></div>'),Lg=b('<button class="mt-1 px-1.5 text-[10px] text-brand-blue hover:underline"> </button> <!>',1),Dg=b('<div class="px-1.5 pt-0.5 text-[10px] text-brand-text-muted"> </div>'),Pg=b('<div class="border-b border-brand-border/30 px-3 py-2"><div class="flex items-center gap-2 text-[10px] tracking-wide text-brand-text-muted uppercase"><span class="rounded bg-brand-surface-2 px-1.5 py-0.5"> </span> <span> </span> <!></div> <p class="mt-1 text-xs leading-relaxed text-brand-text"></p> <!> <!> <!></div>'),Ng=b('<div class="flex items-center justify-between border-b border-brand-border/30 px-3 py-1.5 text-[10px] text-brand-text-muted"><span> <!></span> <!></div> <!>',1),Ug=b(`<div class="flex h-full flex-col"><div class="border-b border-brand-border/50 p-2"><form class="flex gap-1.5"><input type="search" 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="submit" class="flex shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2 py-1.5 text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Search"><span>🔎</span></button></form> <div class="mt-1 px-0.5 text-[10px] text-brand-text-muted">Words are ANDed; use "quoted phrases", OR, NOT, or a trailing * for
|
|
103
|
-
prefixes.</div></div> <div class="flex-1 overflow-y-auto"><!></div></div>`);function Fg(n,e){hr(e,!0);const r=()=>we(rs,"$activeSessionInfo",a),s=()=>we(Es,"$isLoadingSession",a),o=()=>we(Rs,"$isResyncing",a),[a,i]=Ur(),u=(Q,H=Ka,Ye=Ka)=>{var fe=wg(),U=d(fe),Se=d(U,!0);c(U);var X=f(U,2),le=d(X),Te=d(le,!0);c(le);var T=f(le,2),Z=d(T);c(T),c(X),c(fe),E((q,Ae)=>{an(fe,1,`flex w-full items-start gap-2 rounded px-1.5 py-1 text-left transition-colors hover:bg-brand-surface-3/40 ${Ye()??""}`),Y(fe,"title",H().sessionPath),I(Se,H().isRoot?"•":"↳"),I(Te,q),I(Z,`${H().folderName??""} · ${Ae??""} · +${H().after??""}
|
|
104
|
-
after`)},[()=>et(H()),()=>Hi(H().lastActivity)]),M("click",fe,()=>Ue(H())),h(Q,fe)};let m=ur(e,"readOnly",3,!1),v=ur(e,"initialQuery",3,""),g=N(Vn(Ar(()=>v()))),x=N(null),_=N(!1),$=N(null),L=N(Vn({})),B=P(()=>r().sessionFile),W=P(s),Ne=P(o);const re=2,Ke=250;let ve=null,ce=!1;Ut(()=>{t($)?.focus(),!ce&&(ce=!0,t(g).trim().length>=re&&(p(_,!0),je(t(g))))});function K(Q){if(p(g,Q,!0),ve&&clearTimeout(ve),Q.trim().length<re){p(_,!1),p(x,null);return}p(_,!0),ve=setTimeout(()=>{ve=null,je(Q)},Ke)}async function je(Q){const H=await bd(Q.trim(),m()?"readonly":"default");H!==null&&(p(x,H,!0),p(_,!1),p(L,{},!0))}function Qe(Q){Q.preventDefault(),ve&&clearTimeout(ve),!(t(g).trim().length<re)&&(p(_,!0),je(t(g)))}function Ue(Q){if(t(B)===Q.sessionPath&&!t(W)&&!t(Ne)){e.onOpened?.();return}Dr(),As(Q.sessionPath),e.onOpened?.()}function oe(Q,H){return`${Q.entryKey}-${H}`}function et(Q){return Q.name||`${Q.folderName} · ${Q.entryCount} entries`}var dt=Ug(),ht=d(dt),_t=d(ht),Be=d(_t);Tt(Be),ir(Be,Q=>p($,Q),()=>t($));var nt=f(Be,2),yt=d(nt);c(nt),c(_t),pt(2),c(ht);var Ft=f(ht,2),Rt=d(Ft);{var Wt=Q=>{var H=kg();H.textContent=`Type at least 2 characters to search everything ever said in any
|
|
105
|
-
session.`,h(Q,H)},ae=P(()=>t(g).trim().length<re),Kt=Q=>{var H=Sg();h(Q,H)},ot=Q=>{var H=Ag(),Ye=f(d(H),8);{var fe=U=>{var Se=Tg(),X=d(Se);c(Se),E(()=>I(X,`Expected at ${t(x).index.path??""}`)),h(U,Se)};k(Ye,U=>{t(x).index?.path&&U(fe)})}c(H),h(Q,H)},Bt=Q=>{var H=Cg(),Ye=d(H,!0);c(H),E(()=>I(Ye,t(x).message||"Search is unavailable.")),h(Q,H)},At=Q=>{var H=Rg(),Ye=d(H),fe=f(Ye);{var U=Se=>{var X=Eg(),le=d(X);c(X),E(()=>I(le,`${t(x).hiddenHits??""} match${t(x).hiddenHits===1?"":"es"} were in
|
|
106
|
-
sessions not shown here.`)),h(Se,X)};k(fe,Se=>{t(x).hiddenHits&&Se(U)})}c(H),E(()=>I(Ye,`No matches for “${t(x).query??""}”. `)),h(Q,H)},It=Q=>{var H=Ng(),Ye=Dt(H),fe=d(Ye),U=d(fe),Se=f(U);{var X=Z=>{var q=qn();E(()=>I(q,`· ${t(x).hiddenHits??""} hidden`)),h(Z,q)};k(Se,Z=>{t(x).hiddenHits&&Z(X)})}c(fe);var le=f(fe,2);{var Te=Z=>{var q=Ig(),Ae=d(q);c(q),E(Ie=>{Y(q,"title",t(x).index.path),I(Ae,`${Ie??""} sessions indexed`)},[()=>t(x).index.files.toLocaleString()]),h(Z,q)};k(le,Z=>{t(x).index&&Z(Te)})}c(Ye);var T=f(Ye,2);Ln(T,19,()=>t(x).hits,(Z,q)=>oe(Z,q),(Z,q,Ae)=>{const Ie=P(()=>oe(t(q),t(Ae))),rt=P(()=>t(q).threads[0]),ne=P(()=>t(q).threads.slice(1));var Me=Pg(),Xe=d(Me),bt=d(Xe),Ct=d(bt,!0);c(bt);var wt=f(bt,2),Pt=d(wt,!0);c(wt);var ln=f(wt,2);{var Qt=at=>{var kt=Mg();h(at,kt)};k(ln,at=>{t(rt)?.readOnly&&at(Qt)})}c(Xe);var yn=f(Xe,2);Ln(yn,21,()=>Ic(t(q).snippet),pr,(at,kt)=>{var wn=dr(),In=Dt(wn);{var Rn=kn=>{var mn=$g(),Mn=d(mn,!0);c(mn),E(()=>I(Mn,t(kt).text)),h(kn,mn)},Gn=kn=>{var mn=qn();E(()=>I(mn,t(kt).text)),h(kn,mn)};k(In,kn=>{t(kt).match?kn(Rn):kn(Gn,-1)})}h(at,wn)}),c(yn);var An=f(yn,2);{var sn=at=>{u(at,()=>t(rt),()=>"mt-1.5")};k(An,at=>{t(rt)&&at(sn)})}var en=f(An,2);{var cn=at=>{var kt=Lg(),wn=Dt(kt),In=d(wn);c(wn);var Rn=f(wn,2);{var Gn=kn=>{var mn=Og();Ln(mn,21,()=>t(ne),Mn=>Mn.sessionPath,(Mn,qt)=>{u(Mn,()=>t(qt),()=>"")}),c(mn),h(kn,mn)};k(Rn,kn=>{t(L)[t(Ie)]&&kn(Gn)})}E(()=>I(In,`matched in shared history · carried by ${t(q).threadTotal??""} sessions
|
|
107
|
-
${t(L)[t(Ie)]?"▲":"▼"}`)),M("click",wn,()=>t(L)[t(Ie)]=!t(L)[t(Ie)]),h(at,kt)};k(en,at=>{t(ne).length>0&&at(cn)})}var Sn=f(en,2);{var Cn=at=>{var kt=Dg(),wn=d(kt);c(kt),E(In=>{Y(kt,"title",In),I(wn,`+${t(q).otherHits??""} more match${t(q).otherHits===1?"":"es"} in this
|
|
108
|
-
conversation`)},[()=>_g(t(q).snippet)]),h(at,kt)};k(Sn,at=>{t(q).otherHits>0&&at(Cn)})}c(Me),E((at,kt)=>{I(Ct,at),I(Pt,kt)},[()=>yg(t(q).kind,t(q).tool),()=>Hi(t(q).ts)]),h(Z,Me)}),E(()=>I(U,`${t(x).hits.length??""} result${t(x).hits.length===1?"":"s"} `)),h(Q,H)};k(Rt,Q=>{t(ae)?Q(Wt):t(_)&&!t(x)?Q(Kt,1):t(x)?.status==="not-indexed"?Q(ot,2):t(x)?.status==="unavailable"||t(x)?.status==="error"?Q(Bt,3):t(x)&&t(x).hits.length===0?Q(At,4):t(x)&&Q(It,5)})}c(Ft),c(dt),E(()=>{Y(Be,"placeholder",m()?"Search read-only conversations...":"Search all conversations..."),Xi(Be,t(g)),an(yt,1,nl(t(_)?"animate-pulse":""))}),wr("submit",_t,Qe),M("input",Be,Q=>K(Q.currentTarget.value)),h(n,dt),br(),i()}Mr(["click","input"]);var Bg=b(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60"><div class="mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl"><h2 class="mb-2 text-lg font-bold text-brand-text">Sudo password</h2> <p class="mb-3 text-sm text-brand-text-muted">This command needs your sudo password to run. It is used once and never
|
|
109
|
-
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 zg(n,e){hr(e,!0);const r=()=>we(tc,"$sudoPrompt",s),[s,o]=Ur();let a=P(r),i=N(""),u=N(null),m=N(null);Ut(()=>{const B=t(a)?.promptId??null;B!==t(m)&&(p(m,B,!0),p(i,""),B&&queueMicrotask(()=>t(u)?.focus()))});function v(){t(a)&&(Kl(t(i)),p(i,""))}function g(){ql(),p(i,"")}function x(B){B.key==="Enter"?(B.preventDefault(),v()):B.key==="Escape"&&(B.preventDefault(),g())}var _=dr(),$=Dt(_);{var L=B=>{var W=Bg(),Ne=d(W),re=f(d(Ne),4),Ke=d(re,!0);c(re);var ve=f(re,2);Tt(ve),ir(ve,Qe=>p(u,Qe),()=>t(u));var ce=f(ve,2),K=d(ce),je=f(K,2);c(ce),c(Ne),c(W),E(()=>I(Ke,t(a).command)),M("keydown",ve,x),ar(ve,()=>t(i),Qe=>p(i,Qe)),M("click",K,g),M("click",je,v),h(B,W)};k($,B=>{t(a)&&B(L)})}h(n,_),br(),o()}Mr(["keydown","click"]);var Hg=b('<div class="h-full w-1/3 animate-pulse rounded bg-brand-blue/60"></div>'),jg=b('<div class="h-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue transition-all"></div>'),Gg=b('<div class="mt-2 flex items-baseline justify-between gap-2 text-xs"><span class="min-w-0 flex-1 break-words text-brand-text"> </span> <span class="flex-shrink-0 font-mono text-brand-text-muted"> </span></div> <div class="mt-1 h-1.5 w-full overflow-hidden rounded bg-brand-surface-3"><!></div> <div class="mt-1 font-mono text-[11px] break-all text-brand-text-muted"> </div>',1),Wg=b('<div class="mt-2 text-xs text-brand-text-muted"> </div>'),Kg=b(`<div class="mt-1 text-[11px] text-brand-text-muted">Each submodule is counted separately and has its own progress above, so
|
|
110
|
-
there is no single overall percentage.</div>`),qg=b("<!> <!>",1);function Mc(n,e){hr(e,!0);let r=P(()=>e.job?.kind==="create");const s={starting:"Starting",enumerating:"Enumerating objects",counting:"Counting objects",compressing:"Compressing objects",receiving:"Receiving objects",resolving:"Resolving deltas","checking-out":"Checking out files",filtering:"Filtering content",creating:"Creating the folder",initialising:"Initialising a git repository"};function o(_){return s[_]??_}function a(_){return _==="repository"?"the repository":`submodule ${_}`}var i=qg(),u=Dt(i);{var m=_=>{const $=P(()=>e.job.progress);var L=Gg(),B=Dt(L),W=d(B),Ne=d(W);c(W);var re=f(W,2),Ke=d(re,!0);c(re),c(B);var ve=f(B,2),ce=d(ve);{var K=oe=>{var et=Hg();h(oe,et)},je=oe=>{var et=jg();E(dt=>aa(et,dt),[()=>`width: ${Math.max(0,Math.min(100,t($).percent??0))}%`]),h(oe,et)};k(ce,oe=>{t($).indeterminate?oe(K):oe(je,-1)})}c(ve);var Qe=f(ve,2),Ue=d(Qe,!0);c(Qe),E((oe,et)=>{I(Ne,`${oe??""}${et??""}`),I(Ke,t($).indeterminate?"no percentage":`${t($).percent}%`),I(Ue,t($).text)},[()=>o(t($).phase),()=>t(r)?"":` · ${a(t($).scope)}`]),h(_,L)},v=_=>{var $=Wg(),L=d($,!0);c($),E(()=>I(L,t(r)?"Starting...":"Starting the clone (git has not reported anything measurable yet)...")),h(_,$)};k(u,_=>{e.job?.progress?_(m):_(v,-1)})}var g=f(u,2);{var x=_=>{var $=Kg();h(_,$)};k(g,_=>{t(r)||_(x)})}h(n,i),br()}var Vg=b('<div class="mt-2 text-xs text-brand-text-muted">✅ The folder is ready. Reload the session to bring it back live.</div> <button type="button" class="mt-2 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">Reload session</button>',1),Yg=b('<div class="mt-2 text-xs text-brand-text-muted"> </div>'),Xg=b('<div class="mt-2 text-xs text-brand-text-muted">Cloning <span class="font-mono break-all text-brand-text"> </span></div>'),Zg=b(`<div class="mt-1 text-xs text-yellow-300">A clone of <span class="font-mono break-all"> </span> was
|
|
111
|
-
already running for this folder, so your Clone joined it. The URL you typed
|
|
112
|
-
was NOT used; cancel it if you meant a different repository.</div>`),Jg=b('<!> <!> <!> <button type="button" class="mt-2 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>',1),Qg=b('<div class="mt-2 text-xs text-brand-text-muted"> </div>'),em=b('<pre class="mt-1 max-h-32 overflow-auto rounded bg-brand-surface-3 p-2 font-mono text-[11px] whitespace-pre-wrap text-brand-text-muted"> </pre>'),tm=b('<button type="button" class="mt-1 underline opacity-80 hover:opacity-100"> </button> <!>',1),nm=b('<div class="mt-2 rounded border border-red-500/30 bg-red-500/10 p-2 text-xs text-rose-300"><div class="break-words"> </div> <!></div>'),rm=b('<div class="mt-2 rounded border border-red-500/30 bg-red-500/10 p-2 text-xs break-words text-rose-300"> </div>'),sm=b('<button type="button" class="rounded bg-brand-surface-3 px-2 py-1 font-mono text-[11px] break-all text-brand-text-muted hover:text-brand-text"> </button>'),om=b('<div class="mt-1 flex flex-wrap gap-1"></div>'),am=b(`<div class="mt-1 text-[11px] text-brand-text-muted">No repository could be worked out for this folder. Paste the SSH URL
|
|
113
|
-
to clone.</div>`),im=b('<button type="button" class="text-[11px] text-brand-text-muted underline opacity-80 hover:opacity-100">This folder was never a clone? Create it instead</button>'),lm=b(`<div class="text-[11px] text-brand-text-muted">Makes the folder and any missing parents. Nothing is downloaded, so
|
|
114
|
-
whatever the folder used to hold is not coming back with it.</div> <div class="mt-1.5 flex items-center gap-2"><input id="restore-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"/> <label for="restore-git-init" class="cursor-pointer text-xs text-brand-text-muted select-none">Initialise a git repository</label></div> <button type="button" class="mt-2 rounded border border-brand-border bg-brand-surface-3 px-3 py-1 text-[11px] font-medium text-brand-text-muted transition-colors hover:bg-brand-surface-2 hover:text-brand-text disabled:cursor-not-allowed disabled:opacity-40"> </button>`,1),cm=b(`<div class="mt-1 text-xs text-brand-text-muted">The conversation is readable, but nothing can be run here until the
|
|
115
|
-
folder is restored. Clone the repository back into that path, then
|
|
116
|
-
reload the session.</div> <!> <!> <!> <label class="mt-2 block text-xs text-brand-text-muted" for="restore-url">Repository URL (SSH)</label> <input id="restore-url" type="text" spellcheck="false" autocapitalize="off" autocorrect="off" class="mt-1 w-full rounded border border-brand-border bg-brand-surface px-2.5 py-1.5 font-mono text-xs text-brand-text placeholder:text-brand-text-muted focus:border-brand-blue focus:outline-none"/> <!> <button type="button" class="mt-2 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 disabled:cursor-not-allowed disabled:opacity-40"> </button> <div class="mt-3 border-t border-yellow-500/20 pt-2"><!></div>`,1),dm=b(`<div class="border-t border-yellow-500/30 bg-yellow-500/10 px-4 py-3 text-sm text-yellow-400"><div class="font-medium">📁 This session's folder is not on this machine</div> <div class="mt-1 font-mono text-xs break-all text-yellow-300"> </div> <!></div>`);function um(n,e){hr(e,!0);const r=()=>we(ya,"$folderMissing",a),s=()=>we(wa,"$restoreState",a),o=()=>we(oa,"$gitInitDefaultStore",a),[a,i]=Ur();let u=P(r),m=P(s),v=P(()=>t(m)?.job??null),g=P(()=>t(v)?.state==="running"),x=P(()=>t(v)?.state==="done"),_=P(()=>t(v)?.state==="failed"?t(v).failure:void 0),$=P(()=>t(m)?.rejection??null),L=N(!1),B=P(()=>(!!t(m)?.requestedUrl||t(L))&&!t(v)&&!t(m)?.rejection),W=P(()=>t(m)?.joined&&t(v)?.url&&t(m).requestedUrl&&t(v).url!==t(m).requestedUrl?t(v).url:null),Ne=P(()=>t(v)?.kind==="create"),re=N(""),Ke=N(!1),ve=N(Vn([])),ce=N(!1),K=N(!1),je=N(!1),Qe=N(!1),Ue=N(null),oe="";Ut(()=>{const nt=t(u)?.cwd;!nt||nt===oe||(oe=nt,p(re,""),p(Ke,!1),p(ve,[],!0),p(je,!1),p(Ue,null),p(L,!1),Yi(),p(ce,!0),vd(nt).then(yt=>{p(ve,yt,!0),!t(Ke)&&yt.length>0&&p(re,yt[0].url,!0)}).finally(()=>{p(ce,!1)}))}),Ut(()=>{const nt=o();p(Qe,t(Ue)===null?nt:t(Ue),!0)});function et(){t(re).trim()&&(p(K,!1),p(L,!1),Go("clone",t(re)))}function dt(){p(K,!1),p(L,!0),Go("create",void 0,t(Qe))}var ht=dr(),_t=Dt(ht);{var Be=nt=>{var yt=dm(),Ft=f(d(yt),2),Rt=d(Ft,!0);c(Ft);var Wt=f(Ft,2);{var ae=Bt=>{var At=Vg(),It=f(Dt(At),2);M("click",It,()=>Yl()),h(Bt,At)},Kt=Bt=>{var At=Jg(),It=Dt(At);{var Q=X=>{var le=Yg(),Te=d(le);c(le),E(()=>I(Te,`Creating the folder${t(v)?.gitInit?" and initialising a git repository in it":""}`)),h(X,le)},H=X=>{var le=Xg(),Te=f(d(le)),T=d(Te,!0);c(Te),c(le),E(()=>I(T,t(v)?.url??"")),h(X,le)};k(It,X=>{t(Ne)?X(Q):X(H,-1)})}var Ye=f(It,2);{var fe=X=>{var le=Zg(),Te=f(d(le)),T=d(Te,!0);c(Te),pt(),c(le),E(()=>I(T,t(W))),h(X,le)};k(Ye,X=>{t(W)&&X(fe)})}var U=f(Ye,2);Mc(U,{get job(){return t(v)}});var Se=f(U,2);M("click",Se,()=>xa()),h(Bt,At)},ot=Bt=>{var At=cm(),It=f(Dt(At),2);{var Q=ne=>{var Me=Qg(),Xe=d(Me);c(Me),E(()=>I(Xe,`The ${t(Ne)?"folder creation":"clone"} was cancelled and the folder
|
|
117
|
-
it had created was removed.`)),h(ne,Me)};k(It,ne=>{t(v)?.state==="cancelled"&&ne(Q)})}var H=f(It,2);{var Ye=ne=>{var Me=nm(),Xe=d(Me),bt=d(Xe,!0);c(Xe);var Ct=f(Xe,2);{var wt=Pt=>{var ln=tm(),Qt=Dt(ln),yn=d(Qt);c(Qt);var An=f(Qt,2);{var sn=en=>{var cn=em(),Sn=d(cn,!0);c(cn),E(()=>I(Sn,t(_).stderr)),h(en,cn)};k(An,en=>{t(K)&&en(sn)})}E(()=>I(yn,`${t(K)?"Hide":"Show"} git output`)),M("click",Qt,()=>p(K,!t(K))),h(Pt,ln)};k(Ct,Pt=>{t(_).stderr&&Pt(wt)})}c(Me),E(()=>I(bt,t(_).message)),h(ne,Me)};k(H,ne=>{t(_)&&ne(Ye)})}var fe=f(H,2);{var U=ne=>{var Me=rm(),Xe=d(Me,!0);c(Me),E(()=>I(Xe,t($).message)),h(ne,Me)};k(fe,ne=>{t($)&&ne(U)})}var Se=f(fe,4);Tt(Se);var X=f(Se,2);{var le=ne=>{var Me=om();Ln(Me,21,()=>t(ve),Xe=>Xe.url,(Xe,bt)=>{var Ct=sm(),wt=d(Ct,!0);c(Ct),E(()=>I(wt,t(bt).url)),M("click",Ct,()=>{p(re,t(bt).url,!0),p(Ke,!0)}),h(Xe,Ct)}),c(Me),h(ne,Me)},Te=ne=>{var Me=am();h(ne,Me)};k(X,ne=>{t(ve).length>1?ne(le):!t(ce)&&t(ve).length===0&&ne(Te,1)})}var T=f(X,2),Z=d(T,!0);c(T);var q=f(T,2),Ae=d(q);{var Ie=ne=>{var Me=im();M("click",Me,()=>p(je,!0)),h(ne,Me)},rt=ne=>{var Me=lm(),Xe=f(Dt(Me),2),bt=d(Xe);Tt(bt),pt(2),c(Xe);var Ct=f(Xe,2),wt=d(Ct,!0);c(Ct),E(()=>{ra(bt,t(Qe)),Ct.disabled=t(B),I(wt,t(B)?"Creating...":"Create folder")}),M("change",bt,Pt=>p(Ue,Pt.currentTarget.checked,!0)),M("click",Ct,dt),h(ne,Me)};k(Ae,ne=>{t(je)?ne(rt,-1):ne(Ie)})}c(q),E(ne=>{Y(Se,"placeholder",t(ce)?"Looking for the repository...":"git@github.com:owner/repo.git"),T.disabled=ne,I(Z,t(B)?"Starting...":"Clone repository")},[()=>!t(re).trim()||t(B)]),M("input",Se,()=>p(Ke,!0)),M("keydown",Se,ne=>{ne.key==="Enter"&&et()}),ar(Se,()=>t(re),ne=>p(re,ne)),M("click",T,et),h(Bt,At)};k(Wt,Bt=>{t(x)?Bt(ae):t(g)?Bt(Kt,1):Bt(ot,-1)})}c(yt),E(()=>I(Rt,t(u).cwd)),h(nt,yt)};k(_t,nt=>{t(u)&&nt(Be)})}h(n,ht),br(),i()}Mr(["click","input","keydown","change"]);function fm(n){return n.loading||n.resyncing||n.hasSessionHash&&!n.loadFailed}function pm(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!fm(n)}function ji(n){return!n.connected||!n.hashId||n.currentSessionId===n.hashId||n.loading||n.resyncing?"skip":n.attemptedHashId===n.hashId?n.currentSessionId?"skip":"failed":"join"}var hm=b('<div class="mt-2 font-mono text-xs break-all text-brand-text-muted"> </div>'),bm=b(`<div class="fixed inset-0 z-[100] flex items-center justify-center bg-brand-dark/60 p-4 backdrop-blur-sm"><div class="w-full max-w-sm rounded-lg border border-brand-border bg-brand-surface-2 p-5 text-brand-text"><div class="text-base font-bold">Cloning the repository...</div> <div class="mt-1 text-xs text-brand-text-muted">The session is created as soon as the clone finishes, so there is
|
|
118
|
-
nothing to wait for afterwards. It keeps running on the server if this
|
|
119
|
-
page goes away.</div> <!> <!> <button type="button" class="mt-3 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></div></div>`),vm=b('<div class="fixed inset-0 z-[100] flex items-center justify-center bg-brand-dark/60 backdrop-blur-sm"><div class="flex flex-col items-center gap-4"><div class="h-12 w-12 animate-spin rounded-full border-4 border-brand-blue border-t-transparent"></div> <span class="text-lg font-bold text-brand-text">Creating session...</span></div></div>'),gm=b('<span class="text-lg font-bold text-brand-text">Connection Settings</span> <button class="rounded px-2 py-1 text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-2 hover:text-brand-blue">◀ Back</button>',1),mm=b('<span class="max-w-32 truncate rounded-full border border-brand-border bg-brand-blue/15 px-2 py-0.5 text-[10px] font-semibold text-brand-blue"> </span>'),xm=b('<button class="flex items-center gap-2 text-left" title="Show Main Screen / New Session"><img alt="Wherever" class="h-6 w-6"/> <span class="gradient-text text-lg font-bold">Wherever</span> <!></button> <div class="flex items-center gap-2"><button class="flex items-center gap-1 rounded border border-brand-border px-1.5 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-2 hover:text-brand-text" title="Connection Settings">⚙️ Config</button> <button class="text-brand-text-muted hover:text-brand-text md:hidden">X</button></div>',1),_m=b('<div class="flex-1 overflow-y-auto"><!> <div class="mt-2 border-t border-brand-border p-4"><h3 class="mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase">Server Control</h3> <div class="space-y-2"><button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Refresh Session List</span> <span>🔄</span></button> <button class="flex w-full items-center justify-between rounded border border-brand-border bg-brand-surface-2 px-3 py-2 text-left text-sm text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text"><span>Reconnect WebSocket</span> <span>🔌</span></button> <button class="flex w-full items-center justify-between rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-left text-sm text-rose-400 transition-colors hover:bg-red-500/20 hover:text-rose-300"><span>Disconnect Server</span> <span>🛑</span></button></div></div></div>'),ym=b('<span class="text-brand-text-muted/70"> </span>'),wm=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),km=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),Sm=b('<div class="mt-2 space-y-1"><!> <!> <div class="pt-1.5"><button class="w-full rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-center text-xs text-brand-text transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Show Main Screen (Clear URL Hash)">Close Session</button></div></div>'),Tm=b('<div class="mt-2 text-xs text-rose-400"> </div>'),Am=b('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3/50 hover:text-brand-text" title="Search everything ever said in any session"><span>🔎</span> <span>Search conversations</span> <span class="ml-auto">→</span></button> <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>',1),Cm=b('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/50" title="Back to the session list"><span>←</span> <span> </span></button>'),Em=b('<button class="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs font-semibold text-brand-blue transition-colors hover:bg-brand-surface-3/50" title="Back to your sessions"><span>←</span> <span>Back to sessions</span></button> <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="Search the read-only conversations"><span>🔎</span> <span>Search these conversations</span> <span class="ml-auto">→</span></button>',1),Rm=b('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span> <span class="ml-auto font-mono text-xs text-brand-text-muted"> <!></span></div> <!> <!></div> <div class="border-b border-brand-border/50 px-2 py-1.5"><!></div> <div class="flex-1 overflow-hidden"><!></div>',1),Im=b('<button type="button" class="flex flex-shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-sm text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Search the web" aria-label="Search the web">🔍</button>'),Mm=b('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),$m=b('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Om=b('<span class="text-sm text-brand-text-muted">Not connected</span>'),Lm=b('<div class="flex min-w-0 items-center gap-2"><!></div>'),Dm=b('<div class="flex min-w-0 items-center gap-1.5 text-xs text-brand-text-muted"><span class="flex-shrink-0">📁</span> <span class="truncate"> </span></div>'),Pm=b("<option> </option>"),Nm=b('<select class="max-w-48 truncate rounded border border-brand-border bg-brand-surface-2 px-1.5 py-0.5 text-brand-text focus:border-brand-blue focus:outline-none"></select>'),Um=b('<span class="truncate text-brand-text-muted"> </span>'),Fm=b('<div class="flex min-w-0 items-center gap-1.5 text-xs"><span class="relative flex flex-shrink-0 items-center justify-center text-sm"><span>🤖</span> <span></span></span> <!></div>'),Bm=b('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),zm=b('<button type="button"> </button>'),Hm=b('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),jm=b('<div class="border border-red-500/30 bg-red-500/10 px-4 py-2 text-center text-sm text-rose-400">Your session was interrupted — another client took over.</div>'),Gm=b('<div><span class="min-w-0 flex-1 break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss notice" class="flex-shrink-0 opacity-80 hover:opacity-100">X</button></div>'),Wm=b('<button class="flex-shrink-0 rounded-md border border-yellow-500/40 bg-yellow-500/20 px-3 py-1 text-xs font-medium text-yellow-300 transition-colors hover:bg-yellow-500/30">Continue anyway</button>'),Km=b('<div class="flex items-center justify-between gap-3 border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-sm text-yellow-400"><span class="min-w-0 flex-1 break-words">⚠️ Another client is active in this folder. <!></span> <!></div>'),qm=b('<div class="flex items-start justify-between gap-2 border border-red-500/30 bg-red-500/10 px-4 py-2 text-sm text-rose-400"><span class="max-h-24 min-w-0 flex-1 overflow-y-auto break-words whitespace-pre-wrap"> </span> <button aria-label="Dismiss error" class="flex-shrink-0 text-rose-300 hover:text-rose-200">X</button></div>'),Vm=b('<div class="border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-center text-sm text-yellow-400">Read-only: this session cannot be driven from here</div>'),Ym=b('<div class="border-t border-brand-border bg-brand-surface px-4 py-3 text-center text-xs text-brand-text-muted">👁️ Read-only session, observing only, no input.</div>'),Xm=b('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Reconnecting and syncing session...</span></div>'),Zm=b('<div class="flex items-center justify-center gap-2 border-t border-brand-border bg-brand-surface px-4 py-2 text-center text-sm text-brand-text-muted"><span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span> <span>Preparing the session agent...</span></div>'),Jm=b("<!> <!>",1),Qm=b('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),ex=b('<!> <!> <div class="fixed inset-0 flex overflow-hidden overscroll-none bg-brand-dark text-brand-text"><div><div class="border-b border-brand-border bg-brand-surface-2/20 p-4"><div class="flex items-center justify-between"><!></div></div> <!></div> <div class="flex min-w-0 flex-1 flex-col"><div class="app-chrome flex items-center gap-3 border-b border-brand-border bg-brand-surface p-3"><button class="p-1 text-brand-text-muted hover:text-brand-text md:hidden">=</button> <!> <!> <!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!></div> <!> <!></div>',1);function cx(n,e){hr(e,!0);const r=()=>we(Cs,"$isConnected",K),s=()=>we(Rs,"$isResyncing",K),o=()=>we(rc,"$isAgentPending",K),a=()=>we(Es,"$isLoadingSession",K),i=()=>we(Jl,"$isInterrupted",K),u=()=>we(lo,"$sessionError",K),m=()=>we(ec,"$sessionNotice",K),v=()=>we(Zl,"$folderConflict",K),g=()=>we(ya,"$folderMissing",K),x=()=>we(co,"$isReadOnly",K),_=()=>we(rs,"$activeSessionInfo",K),$=()=>we(gn,"$piState",K),L=()=>we(sa,"$availableModels",K),B=()=>we(Qi,"$sessionFolders",K),W=()=>we(Ji,"$readOnlySessionFolders",K),Ne=()=>we(nc,"$isCreatingSession",K),re=()=>we(wa,"$restoreState",K),Ke=()=>we(qi,"$searchFolderStore",K),ve=()=>we(gd,"$searchDefaultModelStore",K),ce=()=>we(md,"$appearanceStore",K),[K,je]=Ur();let Qe=N(!1),Ue=N("main"),oe=N(!1),et=N("");function dt(S,C=""){p(oe,S,!0),p(et,C,!0),p(Ue,"search")}let ht=N(!1),_t,Be=!0;ys(()=>{{const ee=Cl(Ae());setTimeout(()=>{vu({cached:ee,hydrate:El,connect:Re=>{Be=!1,Gr(Re)}})},200)}const S=()=>{if(q=null,t(ae)){const ee=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";ee&&ee!==t(Te)?(q=ee,As(ee)):!ee&&t(Te)&&fr()}};window.addEventListener("hashchange",S);let C=null;const J=8e3,pe=()=>{if(document.visibilityState==="hidden"){if(Uo(),$l())return;C&&clearTimeout(C),C=setTimeout(()=>{C=null,document.visibilityState==="hidden"&&t(ae)&&Il()},J)}else{ma(),C&&(clearTimeout(C),C=null),Bo();const ee=ci({booting:Be,connected:t(ae),hasActiveSession:zo()});ee==="resume"?Fo():ee==="connect"&&Gr()}},Ge=ee=>{if(C&&(clearTimeout(C),C=null),document.visibilityState==="hidden")return;Bo();const Re=ci({booting:Be,connected:t(ae),hasActiveSession:zo()});Re==="resume"?Fo():Re==="connect"&&Gr()},Oe=()=>Uo();return document.addEventListener("visibilitychange",pe),window.addEventListener("pageshow",Ge),window.addEventListener("pagehide",Oe),()=>{window.removeEventListener("hashchange",S),document.removeEventListener("visibilitychange",pe),window.removeEventListener("pageshow",Ge),window.removeEventListener("pagehide",Oe),C&&clearTimeout(C)}});function nt(){Gr()}function yt(){fr(),_s(),ba()}function Ft(){_s(),setTimeout(()=>Gr(),100)}function Rt(){bs()}function Wt(){typeof window<"u"&&(window.location.hash=""),fr(),p(Qe,!1)}let ae=P(r),Kt=P(s),ot=P(o),Bt=P(a),At=P(i),It=P(u),Q=P(m),H=P(v),Ye=P(g),fe=P(x),U=P(_),Se=P($),X=P(()=>L().models),le=N(!1),Te=P(()=>t(U).sessionId),T=P(()=>{const S=t(U).sessionFile;if(!S)return!1;for(const C of[B(),W()])for(const J of C.folders){const pe=J.sessions.find(Ge=>Ge.path===S);if(pe)return!!pe.starred}return!1});Ut(()=>{typeof window<"u"&&t(ae)&&(t(Te)?(window.location.hash=encodeURIComponent(t(Te)),p(le,!0)):t(le)&&(p(le,!1),window.location.hash&&(window.location.hash="")))});let Z=null,q=null;function Ae(){return typeof window>"u"||!window.location.hash?"":decodeURIComponent(window.location.hash.slice(1))}Ut(()=>{if(!t(ae)){q=null;return}const S=Ae();S&&t(Te)===S&&(q=null);const C=ji({connected:t(ae),hashId:S,currentSessionId:t(Te),loading:t(Bt),resyncing:t(Kt),attemptedHashId:q});if(C==="failed"){q=null,window.location.hash&&history.replaceState(history.state,"",window.location.pathname+window.location.search);return}C==="join"&&(Z||(Z=setTimeout(()=>{Z=null;const J=Ae();ji({connected:t(ae),hashId:J,currentSessionId:t(Te),loading:t(Bt),resyncing:t(Kt),attemptedHashId:q})==="join"&&(q=J,Ul(J))},300)))}),Ut(()=>{t(ae)||p(le,!1)}),Ut(()=>{(t(Te)||t(Bt)||t(Kt))&&p(Qe,!1)});let Ie=P(Ne),rt=P(()=>re()?.forSessionCreate?re():null),ne=P(Ke),Me=N(void 0),Xe=P(()=>pm({connected:t(ae),searchConfigured:!!t(ne),hasSession:!!t(U).sessionFile,loading:t(Bt),resyncing:t(Kt),hasSessionHash:typeof window<"u"&&!!window.location.hash,loadFailed:!!t(It)&&!t(Bt)&&!t(Kt)&&!t(U).sessionFile})),bt=P(()=>t(X).map(S=>({value:`${S.provider}:${S.modelId}`,label:`${S.label}${S.isDefault?" (default)":""}`}))),Ct=P(ve),wt=P(()=>ce().label),Pt=N("");Ut(()=>{if(t(bt).length===0||t(bt).some(pe=>pe.value===t(Pt)))return;const C=t(bt).find(pe=>pe.value===t(Ct)),J=t(X).find(pe=>pe.isDefault);p(Pt,C?C.value:J?`${J.provider}:${J.modelId}`:t(bt)[0].value,!0)});let ln=N(!1);Ut(()=>{t(Xe)&&!t(ln)&&t(Me)&&(p(ln,!0),t(Me).focusInput())});function Qt(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),fr(),t(Me)?.focusInput()}var yn=ex(),An=Dt(yn);{let S=P(()=>t(wt)?`Wherever · ${t(wt)}`:"Wherever");Md(An,{get title(){return t(S)},description:"Create & maintain apps from wherever"})}var sn=f(An,2);{var en=S=>{var C=bm(),J=d(C),pe=f(d(J),4);{var Ge=Re=>{var V=hm(),me=d(V,!0);c(V),E(()=>I(me,t(rt).job.url)),h(Re,V)};k(pe,Re=>{t(rt).job?.url&&Re(Ge)})}var Oe=f(pe,2);Mc(Oe,{get job(){return t(rt).job}});var ee=f(Oe,2);c(J),c(C),M("click",ee,()=>xa()),h(S,C)},cn=S=>{var C=vm();h(S,C)};k(sn,S=>{t(rt)?S(en):t(Ie)&&S(cn,1)})}var Sn=f(sn,2),Cn=d(Sn),at=d(Cn),kt=d(at),wn=d(kt);{var In=S=>{var C=gm(),J=f(Dt(C),2);M("click",J,()=>p(ht,!1)),h(S,C)},Rn=S=>{var C=xm(),J=Dt(C),pe=d(J),Ge=f(pe,4);{var Oe=me=>{var ft=mm(),mt=d(ft,!0);c(ft),E(()=>{Y(ft,"title",t(wt)),I(mt,t(wt))}),h(me,ft)};k(Ge,me=>{t(wt)&&me(Oe)})}c(J);var ee=f(J,2),Re=d(ee),V=f(Re,2);c(ee),E(me=>Y(pe,"src",me),[()=>Qr("/logo.svg")]),M("click",J,Wt),M("click",Re,()=>p(ht,!0)),M("click",V,()=>p(Qe,!1)),h(S,C)};k(wn,S=>{t(ht)?S(In):S(Rn,-1)})}c(kt),c(at);var Gn=f(at,2);{var kn=S=>{var C=_m(),J=d(C);{let V=P(()=>(t(Se).connected,"localhost"));tf(J,{get host(){return t(V)},port:31415,token:"",onConnected:nt})}var pe=f(J,2),Ge=f(d(pe),2),Oe=d(Ge),ee=f(Oe,2),Re=f(ee,2);c(Ge),c(pe),c(C),M("click",Oe,Rt),M("click",ee,Ft),M("click",Re,yt),h(S,C)},mn=S=>{var C=Rm(),J=Dt(C),pe=d(J),Ge=d(pe),Oe=f(Ge,2),ee=d(Oe,!0);c(Oe);var Re=f(Oe,2),V=d(Re),me=f(V);{var ft=ue=>{var he=ym(),be=d(he);c(he),E(()=>I(be,` / srv ${t(Se).serverVersion??""}`)),h(ue,he)};k(me,ue=>{t(Se).serverVersion&&ue(ft)})}c(Re),c(pe);var mt=f(pe,2);{var Ht=ue=>{var he=Sm(),be=d(he);{var We=hn=>{var jt=wm(),Ot=d(jt);c(jt),E(xe=>{Y(jt,"title",t(U).cwd),I(Ot,`📁 ${xe??""}`)},[()=>t(U).cwd.split("/").pop()||t(U).cwd]),h(hn,jt)};k(be,hn=>{t(U).cwd&&hn(We)})}var lt=f(be,2);{var Pe=hn=>{var jt=km(),Ot=d(jt);c(jt),E(()=>{Y(jt,"title",t(U).model),I(Ot,`🤖 ${t(U).model??""}`)}),h(hn,jt)};k(lt,hn=>{t(U).model&&hn(Pe)})}var $t=f(lt,2),fn=d($t);c($t),c(he),M("click",fn,Wt),h(ue,he)};k(mt,ue=>{t(U).sessionFile&&ue(Ht)})}var R=f(mt,2);{var D=ue=>{var he=Tm(),be=d(he,!0);c(he),E(()=>I(be,t(Se).error)),h(ue,he)};k(R,ue=>{t(Se).error&&!t(ae)&&ue(D)})}c(J);var se=f(J,2),ze=d(se);{var tt=ue=>{var he=Am(),be=Dt(he),We=f(be,2);M("click",be,()=>dt(!1)),M("click",We,()=>{p(Ue,"readonly"),Zi()}),h(ue,he)},O=ue=>{var he=Cm(),be=f(d(he),2),We=d(be);c(be),c(he),E(()=>I(We,`Back to ${t(oe)?"read-only sessions":"sessions"}`)),M("click",he,()=>p(Ue,t(oe)?"readonly":"main",!0)),h(ue,he)},l=ue=>{var he=Em(),be=Dt(he),We=f(be,2);M("click",be,()=>p(Ue,"main")),M("click",We,()=>dt(!0)),h(ue,he)};k(ze,ue=>{t(Ue)==="main"?ue(tt):t(Ue)==="search"?ue(O,1):ue(l,-1)})}c(se);var y=f(se,2),A=d(y);{var z=ue=>{Fg(ue,{get readOnly(){return t(oe)},get initialQuery(){return t(et)},onOpened:()=>p(Qe,!1)})},ke=ue=>{zi(ue,{readOnly:!0,onSearchAll:he=>dt(!0,he)})},De=ue=>{zi(ue,{onSearchAll:he=>dt(!1,he)})};k(A,ue=>{t(Ue)==="search"?ue(z):t(Ue)==="readonly"?ue(ke,1):ue(De,-1)})}c(y),E(()=>{an(Ge,1,`h-2.5 w-2.5 rounded-full ${t(ae)?"bg-emerald-500":"bg-rose-500"}`),an(Oe,1,`text-sm ${t(ae)?"text-emerald-400":"text-rose-400"}`),I(ee,t(ae)?"Connected":"Disconnected"),Y(Re,"title",t(Se).serverVersion?`App build ${Fs} · server ${t(Se).serverVersion}${t(Se).piVersion?` · pi ${t(Se).piVersion}`:""}`:`App build ${Fs}`),I(V,`v${Fs}`)}),h(S,C)};k(Gn,S=>{t(ht)?S(kn):S(mn,-1)})}c(Cn);var Mn=f(Cn,2),qt=d(Mn),Fn=d(qt),F=f(Fn,2);{var te=S=>{var C=Im();M("click",C,Qt),h(S,C)};k(F,S=>{t(ae)&&t(ne)&&t(U).sessionFile&&S(te)})}var Ce=f(F,2);{var $e=S=>{var C=Lm(),J=d(C);{var pe=ee=>{var Re=Mm();h(ee,Re)},Ge=ee=>{var Re=$m();h(ee,Re)},Oe=ee=>{var Re=Om();h(ee,Re)};k(J,ee=>{t(ae)&&t(Xe)?ee(pe):t(ae)?ee(Ge,1):ee(Oe,-1)})}c(C),h(S,C)};k(Ce,S=>{(!t(ae)||!t(U).sessionFile)&&S($e)})}var w=f(Ce,2);{var G=S=>{var C=Bm(),J=d(C);{var pe=ee=>{var Re=Dm(),V=f(d(Re),2),me=d(V,!0);c(V),c(Re),E(ft=>{Y(V,"title",t(U).cwd),I(me,ft)},[()=>t(U).cwd.split("/").pop()||t(U).cwd]),h(ee,Re)};k(J,ee=>{t(U).cwd&&ee(pe)})}var Ge=f(J,2);{var Oe=ee=>{var Re=Fm(),V=d(Re),me=f(d(V),2);c(V);var ft=f(V,2);{var mt=R=>{var D=Nm();Ln(D,21,()=>t(X),pr,(ze,tt)=>{var O=Pm(),l=d(O,!0);c(O);var y={};E(()=>{I(l,t(tt).label),y!==(y=`${t(tt).provider}:${t(tt).modelId}`)&&(O.value=O.__value=`${t(tt).provider}:${t(tt).modelId}`)}),h(ze,O)}),c(D);var se;rl(D),E(()=>{se!==(se=t(U).model)&&(D.value=(D.__value=t(U).model)??"",ia(D,t(U).model))}),M("input",D,ze=>Vl(ze.currentTarget.value)),h(R,D)},Ht=R=>{var D=Um(),se=d(D,!0);c(D),E(()=>{Y(D,"title",t(U).model),I(se,t(U).model)}),h(R,D)};k(ft,R=>{t(X).length>0&&!t(fe)?R(mt):R(Ht,-1)})}c(Re),E(()=>{an(me,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(Se).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),Y(me,"title",t(Se).isStreaming?"Agent working...":"Ready")}),h(ee,Re)};k(Ge,ee=>{t(U).model&&ee(Oe)})}c(C),h(S,C)};k(w,S=>{t(U).sessionFile&&S(G)})}var de=f(w,2);{var Ee=S=>{var C=zm(),J=d(C,!0);c(C),E(()=>{an(C,1,`flex flex-shrink-0 items-center justify-center rounded border px-2 py-1 text-sm transition-colors ${t(T)?"border-amber-400/50 bg-amber-400/10 text-amber-400 hover:bg-amber-400/20":"border-brand-border bg-brand-surface-2 text-brand-text-muted hover:bg-brand-surface-3 hover:text-amber-400"}`),Y(C,"title",t(T)?"Starred. Click to unstar.":"Star this session to come back to it later"),Y(C,"aria-label",t(T)?"Unstar session":"Star session"),Y(C,"aria-pressed",t(T)),I(J,t(T)?"★":"☆")}),M("click",C,()=>el(t(U).sessionFile,!t(T)).catch(()=>{})),h(S,C)};k(de,S=>{t(U).sessionFile&&S(Ee)})}var qe=f(de,2);{var Le=S=>{var C=Hm();h(S,C)};k(qe,S=>{t(fe)&&S(Le)})}c(qt);var _e=f(qt,2);{var ge=S=>{var C=jm();h(S,C)};k(_e,S=>{t(At)&&S(ge)})}var Zt=f(_e,2);{var on=S=>{var C=Gm(),J=d(C),pe=d(J,!0);c(J);var Ge=f(J,2);c(C),E(()=>{an(C,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(Q).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),I(pe,t(Q).message)}),M("click",Ge,()=>Wl()),h(S,C)};k(Zt,S=>{t(Q)&&S(on)})}var zt=f(Zt,2);{var dn=S=>{var C=Km(),J=d(C),pe=f(d(J));{var Ge=V=>{var me=qn("You are both working in it — changes may conflict.");h(V,me)},Oe=V=>{var me=qn("You are observing (read-only) to avoid clashing.");h(V,me)};k(pe,V=>{t(H).continued?V(Ge):V(Oe,-1)})}c(J);var ee=f(J,2);{var Re=V=>{var me=Wm();M("click",me,()=>Hl()),h(V,me)};k(ee,V=>{t(H).continued||V(Re)})}c(C),h(S,C)};k(zt,S=>{t(H)?.active&&S(dn)})}var tn=f(zt,2);{var Et=S=>{var C=qm(),J=d(C),pe=d(J,!0);c(J);var Ge=f(J,2);c(C),E(()=>I(pe,t(It))),M("click",Ge,()=>Dr()),h(S,C)};k(tn,S=>{t(It)&&S(Et)})}var vt=f(tn,2);{var xn=S=>{var C=Vm();h(S,C)};k(vt,S=>{t(fe)&&!t(At)&&!t(Ye)&&!(t(H)?.active&&!t(H).continued)&&S(xn)})}var it=f(vt,2);ir(Ob(it,{onMessageSent:()=>{}}),S=>_t=S,()=>_t);var ut=f(it,2);{var Mt=S=>{um(S,{})},un=S=>{var C=Ym();h(S,C)},pn=S=>{var C=Jm(),J=Dt(C);{var pe=ee=>{var Re=Xm();h(ee,Re)},Ge=ee=>{var Re=Zm();h(ee,Re)};k(J,ee=>{t(U).sessionFile&&(t(Kt)||!t(ae))?ee(pe):t(U).sessionFile&&t(ot)&&ee(Ge,1)})}var Oe=f(J,2);{let ee=P(()=>!!t(ne)),Re=P(()=>t(Xe)?!t(ae):t(fe)||!t(U).sessionFile),V=P(()=>!t(Xe)&&(!t(ae)||t(Kt)||t(ot)));ir(Iv(Oe,{get searchMode(){return t(Xe)},get searchConfigured(){return t(ee)},get searchModels(){return t(bt)},onSubmit:(me,ft)=>Bl(me,t(Pt),ft),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(Re)},get sendDisabled(){return t(V)},onSend:()=>_t?.forceScrollToBottom(),get searchModel(){return t(Pt)},set searchModel(me){p(Pt,me,!0)}}),me=>p(Me,me,!0),()=>t(Me))}h(S,C)};k(ut,S=>{t(Ye)?S(Mt):t(fe)&&t(U).sessionFile?S(un,1):S(pn,-1)})}c(Mn);var ye=f(Mn,2);zg(ye,{});var Fe=f(ye,2);{var gt=S=>{var C=Qm();M("click",C,()=>p(Qe,!1)),h(S,C)};k(Fe,S=>{t(Qe)&&S(gt)})}c(Sn),E(()=>an(Cn,1,`app-chrome ${t(Qe)?"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`)),M("click",Fn,()=>p(Qe,!t(Qe))),h(n,yn),br(),je()}Mr(["click","input"]);export{cx as component,lx as universal};
|
|
120
|
-
//# sourceMappingURL=2._KcrsFWH.js.map
|