wherever-dev 0.25.0 → 0.26.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 +32 -0
- package/dist/assistant-channels.d.ts +42 -1
- package/dist/assistant-channels.d.ts.map +1 -1
- package/dist/assistant-channels.js +18 -0
- package/dist/assistant-channels.js.map +1 -1
- package/dist/cli-requests.d.ts +7 -0
- package/dist/cli-requests.d.ts.map +1 -1
- package/dist/cli-requests.js +27 -0
- package/dist/cli-requests.js.map +1 -1
- package/dist/index.js +197 -10
- package/dist/index.js.map +1 -1
- package/dist/kenning-delivery.d.ts +42 -0
- package/dist/kenning-delivery.d.ts.map +1 -0
- package/dist/kenning-delivery.js +40 -0
- package/dist/kenning-delivery.js.map +1 -0
- package/dist/kenning-host.d.ts +93 -0
- package/dist/kenning-host.d.ts.map +1 -0
- package/dist/kenning-host.js +165 -0
- package/dist/kenning-host.js.map +1 -0
- package/dist/kenning-human-input.d.ts +70 -0
- package/dist/kenning-human-input.d.ts.map +1 -0
- package/dist/kenning-human-input.js +87 -0
- package/dist/kenning-human-input.js.map +1 -0
- package/dist/kenning-service.d.ts +243 -0
- package/dist/kenning-service.d.ts.map +1 -0
- package/dist/kenning-service.js +516 -0
- package/dist/kenning-service.js.map +1 -0
- package/dist/protocol.d.ts +41 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/reply-routing.d.ts +26 -0
- package/dist/reply-routing.d.ts.map +1 -1
- package/dist/reply-routing.js +35 -0
- package/dist/reply-routing.js.map +1 -1
- package/dist/session-pool.d.ts +35 -0
- package/dist/session-pool.d.ts.map +1 -1
- package/dist/session-pool.js +104 -7
- package/dist/session-pool.js.map +1 -1
- package/dist/session-transcript.d.ts.map +1 -1
- package/dist/session-transcript.js +34 -2
- package/dist/session-transcript.js.map +1 -1
- package/dist/session-types.d.ts +24 -1
- package/dist/session-types.d.ts.map +1 -1
- package/dist/telegram-channel.d.ts +51 -0
- package/dist/telegram-channel.d.ts.map +1 -1
- package/dist/telegram-channel.js +105 -5
- package/dist/telegram-channel.js.map +1 -1
- package/package.json +4 -2
- package/public/_app/immutable/assets/0.CBxclSgC.css +1 -0
- package/public/_app/immutable/chunks/{XW0SPyOK.js → B_u4L4CL.js} +2 -2
- package/public/_app/immutable/chunks/{XW0SPyOK.js.map → B_u4L4CL.js.map} +1 -1
- package/public/_app/immutable/chunks/{ClUQt0nO.js → BgzcA-pV.js} +2 -2
- package/public/_app/immutable/chunks/{ClUQt0nO.js.map → BgzcA-pV.js.map} +1 -1
- package/public/_app/immutable/chunks/wWzBzbDK.js +2 -0
- package/public/_app/immutable/chunks/wWzBzbDK.js.map +1 -0
- package/public/_app/immutable/entry/{app.D1EX_9pb.js → app.CBSjrM4B.js} +3 -3
- package/public/_app/immutable/entry/{app.D1EX_9pb.js.map → app.CBSjrM4B.js.map} +1 -1
- package/public/_app/immutable/entry/start.fPf-MumQ.js +2 -0
- package/public/_app/immutable/entry/start.fPf-MumQ.js.map +1 -0
- package/public/_app/immutable/nodes/{0.DsJW22vw.js → 0.hee657hN.js} +3 -3
- package/public/_app/immutable/nodes/{0.DsJW22vw.js.map → 0.hee657hN.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.BsL25UTD.js → 1.eykDFZ1z.js} +2 -2
- package/public/_app/immutable/nodes/{1.BsL25UTD.js.map → 1.eykDFZ1z.js.map} +1 -1
- package/public/_app/immutable/nodes/2.DsE4vG-2.js +127 -0
- package/public/_app/immutable/nodes/2.DsE4vG-2.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.hWfYEET-.css +0 -1
- package/public/_app/immutable/chunks/CRvF0-wF.js +0 -2
- package/public/_app/immutable/chunks/CRvF0-wF.js.map +0 -1
- package/public/_app/immutable/entry/start.ga0QZFSJ.js +0 -2
- package/public/_app/immutable/entry/start.ga0QZFSJ.js.map +0 -1
- package/public/_app/immutable/nodes/2.DO5lRCyx.js +0 -124
- package/public/_app/immutable/nodes/2.DO5lRCyx.js.map +0 -1
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import"../chunks/DsnmJJEf.js";import{ao as tr,aU as Xs,ai as Qr,b5 as T,am as Zo,w as nd,G as Sa,aL as rd,an as za,b as nl,aj as Ba,ap as sd,k as ad,V as od,q as id,p as ld,W as cd,J as dd,K as ud,H as fd,aV as Jo,C as Qo,v as ei,aw as aa,X as $r,a7 as pd,as as hd,aS as bd,ar as rl,b4 as sl,b7 as vd,b9 as Cr,aN as co,aJ as ti,aI as nr,aF as rr,aa as mt,a_ as f,af as t,Z as gd,y as h,Q as ur,ac as b,ba as L,$ as md,be as gr,a3 as pn,ae as Ln,a0 as pr,aD as os,aT as p,M as u,aO as c,aA as dt,a1 as M,b1 as F,aW as E,aC as uo,bb as Nt,aH as Yn,bc as xd,a9 as Sr,b6 as Vn,ad as oa,aM as yd,aB as ni}from"../chunks/CAL8yDNt.js";import{i as w,s as Nr,a as ye,p as ir}from"../chunks/Cjaz9aih.js";import{x as _d,I as Z,F as ys,H as wd,o as _s,d as Sd,a as kd,p as Fr,q as Ur,L as Td,C as al,A as Ad,w as kt,J as ia,k as Ts,f as Zs,h as ol,g as fo,r as po,j as $n,s as vr,i as Cd,l as Rd,K as il,m as ll,v as cl,E as dl,G as ul,z as Id,n as Ed,B as Md,t as Od,e as $d,b as Ld}from"../chunks/CRvF0-wF.js";import{b as lr,_ as Dd}from"../chunks/BORm3wtc.js";import{v as Ws}from"../chunks/XW0SPyOK.js";import{p as Pd}from"../chunks/ClUQt0nO.js";function ri(n,e,r=!1,s=!1,a=!1,o=!1){var i=n,d="";if(r){var m=n;tr&&(i=Xs(Qr(m)))}T(()=>{var v=nd;if(d===(d=e()??"")){tr&&Zo();return}if(r&&!tr){v.nodes=null,m.innerHTML=d,d!==""&&Sa(Qr(m),m.lastChild);return}if(v.nodes!==null&&(rd(v.nodes.start,v.nodes.end),v.nodes=null),d!==""){if(tr){za.data;for(var g=Zo(),x=g;g!==null&&(g.nodeType!==nl||g.data!=="");)x=g,g=Ba(g);if(g===null)throw sd(),ad;Sa(za,x),i=Xs(g);return}var y=s?id:a?ld:void 0,D=od(s?"svg":a?"math":"template",y);D.innerHTML=d;var P=s||a?D:D.content;if(Sa(Qr(P),P.lastChild),s||a)for(;Qr(P);)i.before(Qr(P));else i.before(P)}})}function Nd(n,e){let r=null,s=tr;var a;if(tr){r=za;for(var o=Qr(document.head);o!==null&&(o.nodeType!==nl||o.data!==n);)o=Ba(o);if(o===null)Jo(!1);else{var i=Ba(o);o.remove(),Xs(i)}}tr||(a=document.head.appendChild(cd()));try{dd(()=>{var d=ud(()=>e(a));d.f|=fd})}finally{s&&(Jo(!0),Xs(r))}}function fl(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var a=n.length;for(e=0;e<a;e++)n[e]&&(r=fl(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function Fd(){for(var n,e,r=0,s="",a=arguments.length;r<a;r++)(n=arguments[r])&&(e=fl(n))&&(s&&(s+=" "),s+=e);return s}function ho(n){return typeof n=="object"?Fd(n):n??""}function Ud(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function zd(n,e){return n==null?null:String(n)}function en(n,e,r,s,a,o){var i=n[Qo];if(tr||i!==r||i===void 0){var d=Ud(r);(!tr||d!==n.getAttribute("class"))&&(d==null?n.removeAttribute("class"):e?n.className=d:n.setAttribute("class",d)),n[Qo]=r}return o}function bo(n,e,r,s){var a=n[ei];if(tr||a!==e){var o=zd(e);(!tr||o!==n.getAttribute("style"))&&(o==null?n.removeAttribute("style"):n.style.cssText=o),n[ei]=e}return s}function vo(n,e,r=!1){if(n.multiple){if(e==null)return;if(!hd(e))return bd();for(var s of n.options)s.selected=e.includes(ws(s));return}for(s of n.options){var a=ws(s);if(rl(a,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function pl(n){var e=new MutationObserver(()=>{vo(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),sl(()=>{e.disconnect()})}function As(n,e,r=e){var s=new WeakSet,a=!0;aa(n,"change",o=>{var i=o?"[selected]":":checked",d;if(n.multiple)d=[].map.call(n.querySelectorAll(i),ws);else{var m=n.querySelector(i)??n.querySelector("option:not([disabled])");d=m&&ws(m)}r(d),n.__value=d,$r!==null&&s.add($r)}),pd(()=>{var o=e();if(n===document.activeElement){var i=$r;if(s.has(i))return}if(vo(n,o,a),a&&o===void 0){var d=n.querySelector(":checked");d!==null&&(o=ws(d),r(o))}n.__value=o,a=!1}),pl(n)}function ws(n){return"__value"in n?n.__value:n.value}function fr(n,e,r=e){var s=new WeakSet;aa(n,"input",async a=>{var o=a?n.defaultValue:n.value;if(o=Ta(n)?Aa(o):o,r(o),$r!==null&&s.add($r),await vd(),o!==(o=e())){var i=n.selectionStart,d=n.selectionEnd,m=n.value.length;if(n.value=o??"",d!==null){var v=n.value.length;i===d&&d===m&&v>m?(n.selectionStart=v,n.selectionEnd=v):(n.selectionStart=i,n.selectionEnd=Math.min(d,v))}}}),(tr&&n.defaultValue!==n.value||Cr(e)==null&&n.value)&&(r(Ta(n)?Aa(n.value):n.value),$r!==null&&s.add($r)),co(()=>{var a=e();if(n===document.activeElement){var o=$r;if(s.has(o))return}Ta(n)&&a===Aa(n.value)||n.type==="date"&&!a&&!n.value||a!==n.value&&(n.value=a??"")})}const ka=new Set;function Pr(n,e,r,s,a=s){var o=r.getAttribute("type")==="checkbox",i=n;let d=!1;if(e!==null)for(var m of e)i=i[m]??=[];i.push(r),aa(r,"change",()=>{var v=r.__value;o&&(v=si(i,v,r.checked)),a(v)},()=>a(o?[]:null)),co(()=>{var v=s();if(tr&&r.defaultChecked!==r.checked){d=!0;return}o?(v=v||[],r.checked=v.includes(r.__value)):r.checked=rl(r.__value,v)}),sl(()=>{var v=i.indexOf(r);v!==-1&&i.splice(v,1)}),ka.has(i)||(ka.add(i),ti(()=>{i.sort((v,g)=>v.compareDocumentPosition(g)===4?-1:1),ka.delete(i)})),ti(()=>{if(d){var v;if(o)v=si(i,v,r.checked);else{var g=i.find(x=>x.checked);v=g?.__value}a(v)}})}function Jn(n,e,r=e){aa(n,"change",s=>{var a=s?n.defaultChecked:n.checked;r(a)}),(tr&&n.defaultChecked!==n.checked||Cr(e)==null)&&r(n.checked),co(()=>{var s=e();n.checked=!!s})}function si(n,e,r){for(var s=new Set,a=0;a<n.length;a+=1)n[a].checked&&s.add(n[a].__value);return r||s.delete(e),Array.from(s)}function Ta(n){var e=n.type;return e==="number"||e==="range"}function Aa(n){return n===""?null:+n}const Bd=!1,jd=!0,hy=Object.freeze(Object.defineProperty({__proto__:null,prerender:jd,ssr:Bd},Symbol.toStringTag,{value:"Module"})),Ca="Wherever",Hd="Create & maintain apps from wherever with a beautiful remote workspace.",Ra="https://localhost",Wd="#000000",Gd="black-translucent";function ts(n,e){return _d(n)}var qd=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 Kd(n,e){nr(e,!0);const r=Ra.endsWith("/")?Ra.slice(0,-1):Ra,s=r+"/preview.png";let a=L(()=>e.home||!1),o=L(()=>({type:e.type||"website",title:e.title||Ca,description:e.description||Hd,image:e.image||s,url:`${r}${Pd.url.pathname}`}));Nd("13n5pl5",i=>{var d=qd(),m=mt(d),v=f(m,2),g=f(v,2);{var x=Je=>{var Be=ur(),Qe=mt(Be);w(Qe,ut=>{}),h(Je,Be)};w(g,Je=>{t(a)&&Je(x)})}var y=f(g,2),D=f(y,2),P=f(D,2),re=f(P,2),U=f(re,2),B=f(U,4),W=f(B,2),ze=f(W,2),X=f(ze,2),G=f(X,2),Y=f(G,2),Ce=f(Y,2),he=f(Ce,2),Ae=f(he,2),te=f(Ae,4),Ne=f(te,4),He=f(Ne,2),Ke=f(He,2);T((Je,Be,Qe,ut)=>{Z(m,"content",t(o).title),Z(v,"content",t(o).description),Z(y,"content",t(o).type),Z(D,"content",t(o).url),Z(P,"content",t(o).title),Z(re,"content",t(o).description),Z(U,"content",t(o).image),Z(B,"content",t(o).url),Z(W,"content",t(o).title),Z(ze,"content",t(o).description),Z(X,"content",t(o).image),Z(G,"href",Je),Z(Y,"href",Be),Z(Ce,"href",Qe),Z(he,"href",ut),Z(Ae,"content",Wd),Z(te,"content",Ca),Z(Ne,"content",Gd),Z(He,"content",Ca),Z(Ke,"content",Ws)},[()=>ts("/pwa/favicon.png"),()=>ts("/pwa/favicon.ico"),()=>ts("/pwa/apple-touch-icon.png"),()=>ts("/pwa/manifest.webmanifest")]),gd(()=>{md.title=t(o).title??""}),h(i,d)}),rr()}let ds=null;function Vd(){if(typeof window>"u")return null;try{if(!ds){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;ds=new n}return ds.state==="suspended"&&ds.resume().catch(()=>{}),ds}catch{return null}}function ai(n,e,r,s,a){const o=n.createOscillator(),i=n.createGain();o.type="sine",o.frequency.value=e;const d=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(a,r+d),i.gain.exponentialRampToValueAtTime(1e-4,r+s),o.connect(i),i.connect(n.destination),o.start(r),o.stop(r+s+.02)}const oi=new Map;function Yd(n){if(typeof Audio>"u")return!1;try{let e=oi.get(n);e||(e=new Audio(n),e.preload="auto",oi.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 hl(n){if(n&&n.trim()&&Yd(n.trim()))return;const e=Vd();if(e)try{const r=e.currentTime;ai(e,1046.5,r,.16,.12),ai(e,1396.9,r+.13,.22,.12)}catch{}}function go(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),a=s.indexOf(" "),o=a===-1?s:s.slice(0,a);if(!o)return null;const i=a===-1?"":s.slice(a+1).trim();return{skillName:o,args:i}}return null}function Ns(n){const e=go(n);return e?`skill:${e.skillName}\0${e.args}`:null}function Gs(){}function Xd(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Zd(n,...e){if(n==null)return Gs;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function Mt(n){let e;return Zd(n,r=>e=r)(),e}var Xr=[];function ii(n,e=Gs){let r;const s=new Set;function a(d){if(Xd(n,d)&&(n=d,r)){const m=!Xr.length;for(const v of s)v[1](),Xr.push(v,n);if(m){for(let v=0;v<Xr.length;v+=2)Xr[v][0](Xr[v+1]);Xr.length=0}}}function o(d){a(d(n))}function i(d,m=Gs){const v=[d,m];return s.add(v),s.size===1&&(r=e(a)||Gs),d(n),()=>{s.delete(v),s.size===0&&(r(),r=null)}}return{set:a,update:o,subscribe:i}}const Jd="frames",Qd="chunk.v1",eu=1;class mo{id=null;count=0;parts=[];static isChunk(e){return e.charCodeAt(0)===eu}push(e){if(!mo.isChunk(e))return{kind:"frame",text:e};const r=e.indexOf(`
|
|
2
|
-
`);if(r<0)return{kind:"invalid"};const[s,a,o]=e.slice(1,r).split(" "),i=Number(a),d=Number(o);if(!s||!Number.isInteger(i)||!Number.isInteger(d)||d<1||i<0||i>=d)return{kind:"invalid"};if(i===0||s!==this.id){if(i!==0)return this.reset(),{kind:"invalid"};this.id=s,this.count=d,this.parts=[]}if(i!==this.parts.length||d!==this.count)return this.reset(),{kind:"invalid"};if(this.parts.push(e.slice(r+1)),this.parts.length<this.count)return{kind:"partial",received:this.parts.length,count:this.count};const m=this.parts.join("");return this.reset(),{kind:"frame",text:m}}reset(){this.id=null,this.count=0,this.parts=[]}}function li(){return`ck-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}const tu="upload.v1",la=1024,ci=64*la,nu=1024*la,ru=256*la,su=2,di=.3,ui=3*256*la,bl="The file is no longer readable, pick it again";function au(n,e,r){const s=3+n.length,a=new Uint8Array(s+8+r.length);a[0]=1,a[1]=1,a[2]=n.length;for(let i=0;i<n.length;i++)a[3+i]=n.charCodeAt(i);const o=new DataView(a.buffer);return o.setUint32(s,Math.floor(e/2**32)),o.setUint32(s+4,e>>>0),a.set(r,s+8),a}function vl(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 ou(){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(vl(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}class rs extends Error{code}function Ia(n){if(n instanceof rs)return n;if(n&&n.name==="NotReadableError"){const e=new rs(bl);return e.code="not_readable",e}return new rs(`Failed to read the file: ${n&&n.message||n}`)}function fi(){const n=new rs(bl);return n.code="not_readable",n}function gl(n){return n.startsWith("http")?n.replace(/^https?:\/\//,""):n}function iu(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 Js(n){return`${gl(n.host)}:${n.port}#${iu(n.token??"")}`}const Ea={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,assistantRetired:!1,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 An{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=An.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;queuedSessionRequest=null;abandonedSessions=new Set;socketServerKey=null;hydratedFile=null;listeners=new Set;pendingUploads=new Map;uploadsStore=ii({});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||li(),this.stateStore=ii({...Ea,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1);const s=Js(this.config),a=Mt(this.stateStore).serverKey;a!==null&&a!==s&&(r=!1,this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.pendingLoadFile=null,this.hydratedFile=null,this.queuedSessionRequest=null),this.socketServerKey=s,this.stateStore.update(B=>r?{...B,connecting:!0,error:null}:{...Ea,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const o=this.config.secure?"wss":"ws",i=gl(this.config.host),d=[];this.config.token&&d.push(`token=${encodeURIComponent(this.config.token)}`),d.push(`clientKey=${encodeURIComponent(this.clientKey)}`),d.push(`${Jd}=${Qd}`),this.config.imageRefs&&d.push("imageRefs=1");const m=`${o}://${i}:${this.config.port}/ws?${d.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=new mo;let y=!1;const D=()=>{if(this.ws!==g)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=An.MIN_RECONNECT_DELAY,this.isInitialConnect=!1,this.abandonedSessions.clear(),this.startLivenessWatchdog(),this.stateStore.update(Y=>({...Y,connected:!0,connecting:!1,error:null}));let B=this.queuedSessionRequest;if(this.queuedSessionRequest=null,B?.type==="load"&&B.sessionFile===(this.resumeSessionFile??Mt(this.stateStore).activeSessionFile)&&(B=null),B){this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.uploadsHeldForRejoin=!1,this.rejectPendingUploads("The session changed before the upload could be sent"),B.type==="load"?(this.stateStore.update(Y=>({...Y,loadingSession:!0,resyncing:!1})),this.pendingLoadFile=B.sessionFile,this.send({type:"session_load",sessionFile:B.sessionFile,cwd:B.cwd,model:B.model}),this.armLoadWatchdog()):(this.stateStore.update(Y=>({...Y,creatingSession:!0,loadingSession:!1,resyncing:!1})),this.pendingLoadFile=null,this.send(B.frame),this.armCreateWatchdog());return}const W=Mt(this.stateStore),ze=this.resumeSessionFile??W.activeSessionFile,X=this.resumeSessionFile!=null?this.resumeCwd:W.activeCwd??void 0,G=this.resumeSessionFile!=null?this.resumeModel:W.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,this.uploadsHeldForRejoin=!!ze,ze||this.rejectPendingUploads("The session was closed before the upload could be sent"),ze?(this.stateStore.update(Y=>Y.resyncing&&!Y.historyAuthoritative?Y:{...Y,resyncing:!0,historyAuthoritative:!1}),this.pendingLoadFile=ze,this.send({type:"session_load",sessionFile:ze,cwd:X,model:G}),this.armLoadWatchdog()):this.stateStore.update(Y=>Y.resyncing?{...Y,resyncing:!1}:Y)},P=B=>{if(this.ws===g){this.lastInboundAt=Date.now(),this.cancelLivenessProbe();try{const W=typeof B.data=="string"?B.data:B.data.toString(),ze=x.push(W);if(ze.kind!=="invalid"&&(y=!1),ze.kind==="partial"){this.loadWatchdog&&this.armLoadWatchdog();return}if(ze.kind==="invalid"){y||console.warn("[wherever] dropped a malformed or incomplete chunked frame"),y=!0;return}const X=JSON.parse(ze.text);this.handleMessage(X)}catch(W){console.error("Failed to parse WebSocket message:",W)}}},re=()=>{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())},U=B=>{this.ws===g&&this.stateStore.update(W=>({...W,error:W.error||"Connection error occurred"}))};typeof g.addEventListener=="function"?(g.addEventListener("open",D),g.addEventListener("message",P),g.addEventListener("close",re),g.addEventListener("error",U)):typeof g.on=="function"&&(g.on("open",D),g.on("message",B=>P({data:B})),g.on("close",re),g.on("error",U))}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.queuedSessionRequest=null,this.abandonedSessions.clear(),this.stateStore.set({...Ea,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=Mt(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=Mt(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||Mt(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,An.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now(),a=s-this.lastLivenessTickAt;if(this.lastLivenessTickAt=s,a>2*An.HEARTBEAT_MS){this.startLivenessProbe("clock jump");return}const o=s-this.lastInboundAt,i=Mt(this.stateStore).isStreaming,d=i?An.TURN_STALL_MS:An.STALE_SOCKET_MS;o<d||this.startLivenessProbe(`no inbound frame for ${o}ms (threshold ${d}ms, ${i?"mid-turn":"idle"})`)};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,An.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}noteVisible(){this.reconnectDelay=An.MIN_RECONNECT_DELAY;const e=this.ws;if(e){if(e.readyState===0){Date.now()-this.socketStartedAt>An.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?An.VISIBLE_PROBE_GRACE_MS:An.PROBE_GRACE_MS;if(this.probeTimer||!this.ws||typeof setTimeout!="function")return;const a=this.ws;try{this.ping()}catch{}const o=Date.now();this.probeTimer=setTimeout(()=>{if(this.probeTimer=null,this.ws===a){if(Date.now()-o>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 a=Mt(this.stateStore).isStreaming;console.warn(`[wherever] relay connection stale: ${e}; probe unanswered for ${r}ms; tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const o=this.ws;this.ws=null,this.uploadsLostSocket();try{typeof o.terminate=="function"?o.terminate():typeof o.close=="function"&&o.close()}catch{}this.stateStore.update(i=>({...i,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:a?"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=Mt(this.stateStore);this.queuedSessionRequest?.type==="load"&&(this.queuedSessionRequest=null),!(!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."})))},An.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null;const e=Mt(this.stateStore);this.queuedSessionRequest?.type==="create"&&(this.queuedSessionRequest=null),e.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."})))},An.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>=An.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=!!Mt(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=Mt(this.stateStore).sessionId;if(r&&e.sessionId&&e.sessionId!==r||e.sessionId&&this.abandonedSessions.has(e.sessionId))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=li();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 a=[...s.messages].reverse().find(o=>o.role==="thinking"&&o.isStreaming);if(!a){const o={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,o]}}return{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content+e.delta,isStreaming:!0}:o)}});break;case"message_update":this.stateStore.update(s=>{let a=[...s.messages].reverse().find(o=>o.role==="assistant"&&o.isStreaming);if(!a){const o={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,o]}}return{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content+e.delta,isStreaming:!0}:o)}});break;case"message_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":{const s=Array.isArray(e.steering)?[...e.steering]:[];this.stateStore.update(a=>({...a,pendingSteering:s,messages:this.withRestoredQueuedMessages(a.messages,s)}));break}case"message_end":this.stateStore.update(s=>{let a=s.messages;const o=[...a].reverse().find(d=>d.role==="thinking"&&d.isStreaming);o&&(a=a.map(d=>d.id===o.id?{...d,isStreaming:!1}:d));const i=[...a].reverse().find(d=>d.role==="assistant"&&d.isStreaming);if(i)a=a.map(d=>d.id===i.id?{...d,content:e.content||d.content,isStreaming:!1}:d);else if(e.content){if(e.role==="user"){if(this.confirmDeliveredByContent(e.content))return Mt(this.stateStore);const x=a.find(y=>y.role==="user"&&y.restoredFromQueue&&y.content===e.content);if(x)return{...s,messages:a.map(y=>y.id===x.id?{...y,restoredFromQueue:void 0}:y)}}const d=e.role==="user"?Ns(e.content):null;if(d){const g=[...a].reverse().find(x=>x.role==="user"&&Ns(x.content)===d);if(g)return g.content!==e.content&&(a=a.map(x=>x.id===g.id?{...x,content:e.content}:x)),{...s,messages:a}}const m=[...a].reverse().find(g=>g.role==="user");e.role==="user"&&m&&m.content===e.content||(a=[...a,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:a}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(a=>({...a,isStreaming:!1,pendingSteering:[],messages:a.messages.map(o=>o.isStreaming?{...o,isStreaming:!1,...o.role==="tool"?{interrupted:!0}:{},endedAt:o.role==="tool"&&o.endedAt===void 0?s:o.endedAt}:o)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,a])=>a!==void 0&&a!=="").map(([s,a])=>`${s}=${JSON.stringify(a)}`).join(" "):"";this.stateStore.update(s=>{const a=s.messages.map(m=>m.isStreaming&&(m.role==="assistant"||m.role==="thinking")?{...m,isStreaming:!1}:m),o=Date.now(),i=!!e.forceCommand;if(i){const m=a.find(v=>v.role==="tool"&&v.optimistic&&v.isStreaming);if(m)return{...s,messages:a.map(v=>v.id===m.id?{...v,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:o,timestamp:o,forceCommand:!0}:v)}}const d={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:o,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:o,...i?{forceCommand:!0}:{}};return{...s,messages:[...a,d]}});break;case"tool_update":{this.stateStore.update(s=>{const a=[...s.messages].reverse().find(o=>o.role==="tool"&&o.toolName===e.toolName&&o.isStreaming);return a?{...s,messages:s.messages.map(o=>o.id===a.id?{...o,content:o.content.includes(`
|
|
3
|
-
`)?o.content+e.delta:`${o.content}
|
|
4
|
-
${e.delta}`,toolOutput:`${o.toolOutput}${e.delta}`}:o)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"",a=!!e.isError&&this.isAbortedToolResult(s),o=!!e.isError&&!a,i=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(d=>{const m=d.messages.find(g=>g.role==="tool"&&g.toolName===e.toolName&&g.isStreaming)??[...d.messages].reverse().find(g=>g.role==="tool"&&g.toolName===e.toolName&&!g.content.startsWith("Tool error:")),v=Date.now();if(m){const g=o?"Error: ":"";return{...d,messages:d.messages.map(x=>x.id===m.id?{...x,content:`${g}${x.content}
|
|
5
|
-
${s}`,isStreaming:!1,isError:o,interrupted:a,toolOutput:s,...i?{images:i}:{},endedAt:v}:x)}}else{const g=o?`Tool error: ${e.toolName}
|
|
6
|
-
${s}`:`${e.toolName}
|
|
7
|
-
${s}`,x={id:this.generateId(),role:"tool",content:g,timestamp:v,isStreaming:!1,toolName:e.toolName,toolArgs:"",toolOutput:s,...i?{images:i}:{},isError:o,interrupted:a,endedAt:v};return{...d,messages:[...d.messages,x]}}});break}case"aborted":{const s=Date.now();this.stateStore.update(a=>({...a,isStreaming:!1,messages:a.messages.map(o=>o.isStreaming?{...o,isStreaming:!1,...o.role==="tool"?{interrupted:!0}:{},endedAt:o.role==="tool"&&o.endedAt===void 0?s:o.endedAt}:o)}));break}case"session_created":{{const s=Mt(this.stateStore),a=this.pendingLoadFile!==null&&(e.sessionFile===this.pendingLoadFile||e.sessionId===this.pendingLoadFile),o=this.pendingLoadFile===null&&s.creatingSession,i=this.abandonedSessions.has(e.sessionFile)||this.abandonedSessions.has(e.sessionId);if(!a&&(!o||i)){e.sessionId&&e.sessionId!==s.sessionId&&this.abandonedSessions.add(e.sessionId);break}}this.abandonedSessions.delete(e.sessionFile),this.abandonedSessions.delete(e.sessionId),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,assistantRetired:e.assistantRetired===!0,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=Mt(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":Mt(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,assistantRetired:!1,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(a=>({...a,sessionError:e.error,isStreaming:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1})),s&&this.rejectHydration();break}case"assistant_retired":this.stateStore.update(s=>!s.sessionId||s.sessionId!==e.sessionId?s:{...s,assistantRetired:e.retired===!0,readOnly:e.readOnly??s.readOnly,folderConflict:e.retired===!0?null:s.folderConflict});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=Mt(this.stateStore);if(s.creatingSession&&!s.restore){this.clearCreateWatchdog(),this.stateStore.update(a=>({...a,creatingSession:!1,restore:{targetPath:e.targetPath,job:e.job,joined:e.outcome==="joined",rejection:null,forSessionCreate:!0}}));break}this.stateStore.update(a=>this.withRestore(a,e.targetPath,o=>({...o,job:e.job,joined:e.outcome==="joined",rejection:null})));break}case"restore_rejected":this.stateStore.update(s=>this.withRestore(s,e.targetPath,a=>({...a,rejection:{reason:e.reason,message:e.message}})));break;case"restore_progress":case"restore_complete":{const s=Mt(this.stateStore).restore;if(e.type==="restore_complete"&&s?.forSessionCreate&&s.targetPath===e.targetPath){const a=e.job.state==="done";this.stateStore.update(o=>({...o,restore:null,creatingSession:a})),a&&this.armCreateWatchdog();break}this.stateStore.update(a=>this.withRestore(a,e.targetPath,o=>({...o,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 a=e.readOnly??s.readOnly;return e.active?s.folderConflict?{...s,readOnly:a,folderConflict:{...s.folderConflict,cwd:e.cwd,active:!0}}:{...s,readOnly:a,folderConflict:{cwd:e.cwd,active:!0,continued:!0}}:s.folderConflict||a!==s.readOnly?{...s,folderConflict:null,readOnly:a}: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 d=Mt(this.stateStore).sessionId;if(d&&e.sessionId&&e.sessionId!==d||e.sessionId&&this.abandonedSessions.has(e.sessionId))break}const s=e.sessionId,a=Mt(this.stateStore).messages.filter(d=>d.role==="user"&&d.delivery!==void 0),i=[...this.loadPersistedPending(s),...a];this.stateStore.update(d=>{const m=this.mapHistory(e.messages,e.sessionId,d.isStreaming),v=typeof e.totalCount=="number"?e.totalCount:m.length,g=typeof e.offset=="number"?e.offset:0,x=new Set(m.filter(P=>P.role==="user").map(P=>P.content)),y=new Set,D=[];for(const P of i)x.has(P.content)||y.has(P.content)||(y.add(P.content),D.push({...P,sessionId:s,delivery:"failed"}));return{...d,messages:[...m,...D],historyTotalCount:v,historyOffset:g,historyAuthoritative:!0,loadingMoreHistory:!1,loadingSession:!1,resyncing:!1}});for(const d of i)this.clearConfirm(d.id);this.persistPending(s);break}case"message_history_prepend":this.stateStore.update(s=>{const a=this.mapHistory(e.messages,e.sessionId,!1),o=typeof e.offset=="number"?e.offset:0;return a.length===0?{...s,loadingMoreHistory:!1,historyOffset:o}:{...s,messages:[...a,...s.messages],historyOffset:o,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(`
|
|
8
|
-
`),s=(r[r.length-1]||"").trim();return/^(command|operation)?\s*aborted$/i.test(s)}mapHistory(e,r,s){const a=[],o={},i={},d=(g,x)=>{const y=o[g];if(!y)return;const D=y.indexOf(x);D!==-1&&y.splice(D,1)};for(const g of e)if(g.role==="tool_call"){const x=g.toolName||"unknown",y=g.content||"",D=a.length;a.push({id:this.generateId(),role:"tool",content:y?`$ ${x} ${y}`:`$ ${x}`,timestamp:g.timestamp,isStreaming:!1,toolName:x,toolArgs:y,toolOutput:"",sessionId:r,...Number.isFinite(g.timestamp)?{startedAt:g.timestamp}:{},...g.forceCommand?{forceCommand:!0}:{}}),o[x]||(o[x]=[]),o[x].push(D),typeof g.toolCallId=="string"&&g.toolCallId&&(i[g.toolCallId]=D)}else if(g.role==="tool_result"){const x=g.toolName||"unknown";let y;if(typeof g.toolCallId=="string"&&g.toolCallId&&i[g.toolCallId]!==void 0)y=i[g.toolCallId],delete i[g.toolCallId],d(x,y);else if(o[x]&&o[x].length>0){y=o[x].shift();for(const[re,U]of Object.entries(i))U===y&&delete i[re]}const D=g.isError&&!this.isAbortedToolResult(g.content),P=!!g.isError&&this.isAbortedToolResult(g.content);if(y!==void 0){const re=a[y],U=re.toolArgs||"",B=re.startedAt;a[y]={...re,content:U?`$ ${x} ${U}
|
|
9
|
-
${g.content}`:`$ ${x}
|
|
10
|
-
${g.content}`,isStreaming:!1,toolOutput:g.content,...Array.isArray(g.images)&&g.images.length>0?{images:g.images}:{},isError:D,interrupted:P,timestamp:g.timestamp,...B!==void 0&&Number.isFinite(B)&&Number.isFinite(g.timestamp)&&g.timestamp>=B?{endedAt:g.timestamp}:{}}}else a.push({id:this.generateId(),role:"tool",content:`$ ${x}
|
|
11
|
-
${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:D,interrupted:P,sessionId:r})}else a.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(o))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?a[g]={...a[g],isStreaming:!0}:a[g]={...a[g],interrupted:!0};if(s&&a.length>0){const g=a.length-1,x=a[g];(x.role==="assistant"||x.role==="thinking")&&(a[g]={...x,isStreaming:!0})}return a}loadMoreHistory(){const e=Mt(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=Mt(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(),y={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(D=>({...D,sessionError:null,messages:[...D.messages,y]})),!0}return this.stateStore.update(g=>({...g,sessionError:null})),!0}const o={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,o]})),this.armConfirm(o.id),this.persistPending(s.sessionId),!0}withRestoredQueuedMessages(e,r){if(r.length===0)return e;const s=new Map;for(const o of e)o.role==="user"&&s.set(o.content,(s.get(o.content)??0)+1);const a=[];for(const o of r){const i=s.get(o)??0;if(i>0){s.set(o,i-1);continue}a.push({id:this.generateId(),role:"user",content:o,timestamp:Date.now(),isStreaming:!1,restoredFromQueue:!0})}return a.length>0?[...e,...a]:e}pendingKey(e){return An.PENDING_PREFIX+e}persistPending(e){if(!e||typeof localStorage>"u")return;const r=Mt(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(a=>a&&typeof a.content=="string").map(a=>({id:typeof a.id=="string"?a.id:this.generateId(),role:"user",content:a.content,timestamp:typeof a.timestamp=="number"?a.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(a=>{const o=a.messages.find(i=>i.id===e);return!o||o.delivery!=="sending"?a:(s=a.sessionId,{...a,messages:a.messages.map(i=>i.id===e?{...i,delivery:"failed"}:i)})}),s&&this.persistPending(s)},An.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 a=Ns(e);return this.stateStore.update(o=>{let i=o.messages.find(d=>d.role==="user"&&d.delivery!==void 0&&d.content===e);return!i&&a&&(i=o.messages.find(d=>d.role==="user"&&d.delivery!==void 0&&Ns(d.content)===a)),i?(r=i.id,s=o.sessionId,{...o,messages:o.messages.map(d=>d.id===i.id?{...d,delivery:void 0,...a?{content:e}:{}}:d)}):o}),r?(this.clearConfirm(r),this.persistPending(s),!0):!1}resendMessage(e,r){const s=Mt(this.stateStore),a=s.messages.find(i=>i.id===e&&i.role==="user");return!a||!s.sessionId?!1:this.getIsConnected()?this.send(this.messageFrame(a.content,s.sessionId,r))?(this.stateStore.update(i=>({...i,sessionError:null,messages:i.messages.map(d=>d.id===e?{...d,delivery:"sending",timestamp:Date.now()}:d)})),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(a=>a.id!==e)})),r&&this.persistPending(r)}abort(){const e=Mt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}reloadResources(){const e=Mt(this.stateStore);e.sessionId&&this.send({type:"session_reload",sessionId:e.sessionId})}cancelSteer(){const e=Mt(this.stateStore);e.sessionId&&(this.send({type:"cancel_steer",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,pendingSteering:[]})))}withRestore(e,r,s){const a=e.restore;return!a||a.targetPath!==r?e:{...e,restore:s(a)}}hydrateCachedSession(e){const r=Mt(this.stateStore);if(r.activeSessionFile||this.pendingLoadFile!==null||r.connected)return;const s=e.messages.filter(a=>!(a.role==="user"&&a.delivery!==void 0));this.hydratedFile=e.sessionFile,this.stateStore.update(a=>({...a,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??Js(this.config)}))}rejectHydration(){const e=Mt(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(a){console.error("Error in message listener:",a)}}joinSession(e,r,s){this.stateStore.update(a=>({...a,folderConflict:null,folderMissing:null,assistantRetired:!1,restore:null,sessionError:null,loadingSession:!0,agentPending:!1})),this.abandonPendingLoad(e),this.pendingLoadFile=e,this.sendSessionLoad(e,r,s),this.armLoadWatchdog()}abandonPendingLoad(e,{keepShownSession:r=!1}={}){this.pendingLoadFile&&this.pendingLoadFile!==e&&this.abandonedSessions.add(this.pendingLoadFile);const s=Mt(this.stateStore);!r&&s.sessionId&&!s.historyAuthoritative&&s.activeSessionFile!==e&&s.sessionId!==e&&this.abandonedSessions.add(s.sessionId),e&&this.abandonedSessions.delete(e)}sendSessionLoad(e,r,s){const a=this.send({type:"session_load",sessionFile:e,cwd:r,model:s});this.queuedSessionRequest=a?null:{type:"load",sessionFile:e,cwd:r,model:s}}switchSession(e,r,s){const a=Mt(this.stateStore);a.activeSessionFile===e&&!a.loadingSession&&!a.resyncing||(this.abandonUnsentUploads(),a.sessionId&&this.send({type:"session_leave",sessionId:a.sessionId}),this.abandonPendingLoad(e),this.stateStore.update(o=>({...o,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,folderConflict:null,folderMissing:null,assistantRetired:!1,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.sendSessionLoad(e,r,s),this.armLoadWatchdog())}forkSession(e,r){return!e||!r?!1:this.send({type:"session_fork",sessionId:e,entryId:r})}createSession(e,r,s,a,o,i){this.abandonUnsentUploads(),this.stateStore.update(m=>({...m,folderConflict:null,folderMissing:null,assistantRetired:!1,restore:null,sessionError:null,creatingSession:!0,loadingSession:!1})),this.abandonPendingLoad(void 0,{keepShownSession:!0}),this.pendingLoadFile=null,this.hydratedFile=null,this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0;const d={type:"session_new",cwd:e,model:r,gitInit:s,createRemote:a,repoVisibility:o,cloneRemote:i};this.queuedSessionRequest=this.send(d)?null:{type:"create",frame:d},this.armCreateWatchdog()}leaveSession(){this.abandonUnsentUploads();const e=Mt(this.stateStore);if(this.clearCreateWatchdog(),this.queuedSessionRequest=null,this.abandonPendingLoad(),!e.sessionId&&!e.activeSessionFile&&this.pendingLoadFile===null&&!this.resumeSessionFile){e.creatingSession&&this.stateStore.update(r=>({...r,creatingSession:!1}));return}e.sessionId&&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,assistantRetired:!1,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 a=Mt(this.stateStore),o=a.restore?.targetPath??a.folderMissing?.cwd;if(!o)return!1;const i=r?.trim();return e==="clone"&&!i?!1:(this.stateStore.update(d=>{const m=d.restore?.targetPath===o?d.restore.job:null;return{...d,restore:{targetPath:o,job:m&&m.state==="running"?m:null,joined:!1,requestedUrl:i,rejection:null}}}),this.send({type:"restore_start",targetPath:o,action:e,...i?{url:i}:{},...s!==void 0?{gitInit:s}:{}}))}cancelRestore(){const r=Mt(this.stateStore).restore?.targetPath;return r?this.send({type:"restore_cancel",targetPath:r}):!1}reloadSession(){const e=Mt(this.stateStore),r=e.activeSessionFile;return r?(this.joinSession(r,e.activeCwd??void 0),!0):!1}continueFolderConflict(){const e=Mt(this.stateStore);!e.folderConflict||!e.sessionId||e.folderMissing||e.assistantRetired||(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=Mt(this.stateStore).sudoPrompt;s&&(this.send({type:"bash_sudo_password",sessionId:s.sessionId,promptId:s.promptId,password:e}),this.stateStore.update(a=>({...a,sudoPrompt:null})))}cancelSudoPrompt(){const r=Mt(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,a){return new Promise((o,i)=>{const d=a?.signal;if(d?.aborted){a?.onProgress?.({acked:0,size:s.size,state:"aborted"}),i(new Error("Upload cancelled"));return}const m=ou(),v={uploadId:m,sessionId:e,filename:r,mime:a?.mime||void 0,source:s,onProgress:a?.onProgress,resolve:o,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),d?.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(tu);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>=An.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>An.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 rs?r:Ia(r);this.failUpload(e.uploadId,s.message,s.code)})}async readLegacyBase64(e){const r=[];let s=0;for(let a=0;a<e.size;a+=ui){const o=Math.min(ui,e.size-a);let i;try{i=await e.read(a,o)}catch(d){throw Ia(d)}if(s+=4*Math.ceil(i.length/3),s>An.MAX_UPLOAD_BASE64_CHARS)throw new rs("File too large to upload over the WebSocket (max 72 MB)");if(i.length!==o)throw fi();r.push(btoa(vl(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,a=r.source.size;if(!Number.isSafeInteger(s)||s<0||s>a)return;const o=Date.now();if(r.awaitingBegin)r.awaitingBegin=!1,r.nextOffset=s,r.lastAckAt=o;else{const i=r.inFlight.shift();if(!i)return;if(!r.realigning&&s===i.offset+i.length){const d=Math.max(1,o-Math.max(i.sentAt,r.lastAckAt)),m=i.length/d;r.rate=r.rate===null?m:r.rate*(1-di)+m*di,r.lastAckAt=o}else r.realigning||(r.realigning=!0,r.readGen++);r.realigning&&r.inFlight.length===0&&(r.realigning=!1,r.nextOffset=s,r.lastAckAt=o)}r.acked=s,this.reportUpload(r),this.pumpUpload(r)}uploadWindow(e){if(e.rate===null)return ci;const r=e.rate*1e3*su;return Math.min(nu,Math.max(ci,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),a=Math.min(s,ru,r-e.nextOffset);if(e.inFlight.reduce((v,g)=>v+g.length,0)+a>s)return;const i=e.nextOffset,d=e.readGen,m=this.ws;e.reading=!0,Promise.resolve().then(()=>e.source.read(i,a)).then(v=>{if(this.pendingUploads.get(e.uploadId)===e){if(e.reading=!1,d!==e.readGen||m!==this.ws||!this.isUploadOnWire(e)){this.pumpUpload(e);return}if(v.length!==a){const g=fi();this.failUpload(e.uploadId,g.message,g.code);return}this.sendBinary(au(e.uploadId,i,v))&&(e.inFlight.push({offset:i,length:a,sentAt:Date.now()}),e.nextOffset=i+a,this.pumpUpload(e))}},v=>{if(this.pendingUploads.get(e.uploadId)!==e)return;const g=Ia(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 a={acked:e.acked,size:e.source.size,state:e.state,...s?{error:s}:{}};if(this.uploadsStore.update(o=>({...o,[e.uploadId]:a})),e.onProgress)try{e.onProgress({...a})}catch(o){console.error("Upload onProgress failed:",o)}}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 a=this.takePendingUpload(e);if(!a)return;const o=new Error(r);s&&(o.code=s),this.reportUpload(a,"failed",s?{message:r,code:s}:{message:r}),a.reject(o)}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,a]of[...this.pendingUploads])this.isUploadOnWire(a)||r&&a.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)")},An.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 lu=["speakReplies","collapseLongReplies","micReopensAfterReply"];function cu(n){return lu.includes(n)}function ns(n,e){return cu(n)?e.conversationMode&&e[n]:e[n]}function du(n){return ns("speakReplies",n)}function uu(n,e){return n===void 0?e:n}function ml(n,e){const r=n.trim();if(e.length===0)return r;const s=e.map(a=>`[Uploaded file: ${a}]`).join(`
|
|
12
|
-
`);return r?`${r}
|
|
13
|
-
|
|
14
|
-
${s}`:`I have uploaded the following file(s) for you:
|
|
15
|
-
${s}`}function fu(n){return n.loading||n.resyncing||n.hasSessionHash&&!n.loadFailed}function pu(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!fu(n)}function pi(n){return!n.connected||!n.hashId||n.currentSessionId===n.hashId||n.loading||n.resyncing||n.creating?"skip":n.attemptedHashId===n.hashId?n.currentSessionId?"skip":"failed":"join"}function hu(n){return!n.connected&&!!n.hashId&&n.hashId!==n.target}const bu="The file is no longer readable, pick it again";function hi(){return Object.assign(new Error("Upload cancelled"),{name:"AbortError"})}function vu(n){const{size:e,signal:r}=n;let s=0;const a=(o,i)=>n.onProgress?.({acked:s,size:e,state:o,...i?{error:i}:{}});return new Promise((o,i)=>{if(r?.aborted){a("aborted"),i(hi());return}const d=(n.createXhr??(()=>new XMLHttpRequest))();let m=!1;const v=()=>d.abort(),g=()=>{m=!0,r?.removeEventListener("abort",v)},x=(y,D)=>{if(m)return;g(),a("failed",D?{message:y,code:D}:{message:y}),i(Object.assign(new Error(y),D?{code:D}:{}))};d.upload.onprogress=y=>{m||(s=Math.max(0,Math.min(e,y.loaded)),a("sending"))},d.onload=()=>{if(m)return;let y;try{y=JSON.parse(d.responseText)}catch{y=void 0}if(d.status<200||d.status>=300){x(y&&typeof y.error=="string"&&y.error||`Upload failed with status ${d.status}`);return}if(!y||typeof y.savedPath!="string"){x("Upload failed: the server sent an unreadable reply");return}g(),s=e,a("done"),o(y)},d.onerror=()=>{if(m)return;(n.probeReadable??(async()=>!0))().catch(()=>!1).then(D=>D?x("Upload failed (network error)"):x(bu,"not_readable"))},d.ontimeout=()=>x("Upload timed out"),d.onabort=()=>{m||(g(),a("aborted"),i(hi()))},r?.addEventListener("abort",v),d.open("POST",n.url),d.setRequestHeader("Content-Type","text/plain"),a("sending"),d.send(n.body)})}async function gu(n){try{return await n.slice(0,1).arrayBuffer(),!0}catch{return!1}}const bi="wherever-timezone-reported",xl=()=>Intl.DateTimeFormat().resolvedOptions().timeZone;function mu(n,e=xl){let r;try{r=e()}catch{return null}return typeof r!="string"||!r||n&&r===n?null:{type:"client_timezone",timezone:r,first:!n}}function xu(n,e=typeof localStorage<"u"?localStorage:void 0,r=xl){let s=null;try{s=e?.getItem(bi)??null}catch{s=null}const a=mu(s,r);if(a){n(a);try{e?.setItem(bi,a.timezone)}catch{}}}const vi="wherever-drafts-cache",Ma="wherever-drafts";function yu(n){return[...n].sort((e,r)=>r.updatedAt-e.updatedAt||e.id.localeCompare(r.id))}function gi(n){if(!n)return[];try{return yl(JSON.parse(n))}catch{return[]}}function yl(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 a=s.text.trim();if(a.length===0)continue;const o=typeof s.createdAt=="number"?s.createdAt:0,i=typeof s.updatedAt=="number"?s.updatedAt:o;e.push({id:s.id,text:a,createdAt:o,updatedAt:i,...typeof s.sessionId=="string"?{sessionId:s.sessionId}:{},...typeof s.cwd=="string"?{cwd:s.cwd}:{}})}return yu(e)}function _u(n){return JSON.stringify(n)}function wu(n){return n.trim().length>0?"confirm":"load"}function Su(n,e,r){if(r==="replace")return e;const s=n.replace(/\s+$/,"");return s.length===0?e:`${s}
|
|
16
|
-
|
|
17
|
-
${e}`}function ku(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(`
|
|
18
|
-
|
|
19
|
-
${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 mi(n){if(!n.cwd)return null;const e=n.cwd.split("/").filter(Boolean);return e.length>0?e[e.length-1]:n.cwd}const Au="wherever-conversation-cache",Oa="conversations",xi="savedAt",Cu=1,Ru=5,Iu=2*1024*1024,Eu=5e3;function Mu(n){const e=[];for(const r of n){if(r.delivery!==void 0)continue;const{images:s,...a}=r,o=s?.filter(i=>!i.data&&i.toolCallId);e.push({...a,...o&&o.length>0?{images:o}:{},isStreaming:!1})}return e}function yi(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 Ou(n,e){let r=yi(JSON.stringify({...n,messages:[]}));const s=n.messages.map(o=>yi(JSON.stringify(o)));for(let o=0;o<s.length;o++)r+=s[o]+(o>0?1:0);let a=0;for(;r>e&&a<s.length;)r-=s[a]+(a<s.length-1?1:0),a++;return a===0?n:{...n,messages:n.messages.slice(a)}}function Zr(n){return new Promise((e,r)=>{n.onsuccess=()=>e(n.result),n.onerror=()=>r(n.error)})}function $u(n){return new Promise((e,r)=>{n.oncomplete=()=>e(),n.onerror=()=>r(n.error),n.onabort=()=>r(n.error)})}function Lu(n={}){const e=n.indexedDB!==void 0?n.indexedDB:globalThis.indexedDB??null,r=n.now??Date.now,s=n.maxSessions??Ru,a=n.maxRecordBytes??Iu;let o=null;function i(){return o||(o=new Promise(v=>{if(!e)return v(null);let g;try{g=e.open(Au,Cu)}catch{return v(null)}g.onupgradeneeded=()=>{g.result.createObjectStore(Oa,{keyPath:["serverKey","sessionId"]}).createIndex(xi,"savedAt")},g.onsuccess=()=>{const x=g.result;x.onversionchange=()=>x.close(),v(x)},g.onerror=()=>v(null),g.onblocked=()=>v(null)}),o)}async function d(v,g,x){try{const y=await i();if(!y)return g;const D=y.transaction(Oa,v),P=$u(D),re=await x(D.objectStore(Oa));return await P,re}catch{return g}}function m(v,g){return new Promise((x,y)=>{const D=v.openKeyCursor();D.onerror=()=>y(D.error),D.onsuccess=()=>{const P=D.result;if(!P)return x();g(P.primaryKey)&&v.delete(P.primaryKey),P.continue()}})}return{get(v,g){return d("readonly",null,async x=>await Zr(x.get([v,g]))??null)},put(v){return d("readwrite",void 0,async g=>{const x=[v.serverKey,v.sessionId],y=Ou({...v,messages:Mu(v.messages),savedAt:r()},a);if(y.messages.length===0){await Zr(g.delete(x));return}await Zr(g.put(y));const D=await Zr(g.index(xi).getAllKeys());for(const P of D.slice(0,Math.max(0,D.length-s)))g.delete(P)})},remove(v,g){return d("readwrite",void 0,async x=>{await Zr(x.delete([v,g]))})},retainOnly(v){return d("readwrite",void 0,g=>m(g,x=>x[0]!==v))},clear(){return d("readwrite",void 0,async v=>{await Zr(v.clear())})}}}function Du(n,e={}){const r=e.intervalMs??Eu;let s=null;function a(){try{const i=n();i&&typeof i.catch=="function"&&i.catch(()=>{})}catch{}}function o(){s!==null&&clearTimeout(s),s=null}return{schedule(){s===null&&(s=setTimeout(()=>{s=null,a()},r))},flush(){o(),a()},cancel:o}}const Pu=300;function Nu(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 Fu(n){return n.historyAuthoritative&&n.historyOffset>0}function _i(n){return n.booting||n.connected?"none":n.hasActiveSession?"resume":"connect"}function Uu(n){if(!n.hashId)return Promise.resolve(null);const e=n.timeoutMs??Pu;return new Promise(r=>{const s=setTimeout(()=>r(null),e),a=i=>{clearTimeout(s),r(i)};let o;try{o=n.cache.get(n.serverKey,n.hashId)}catch{return a(null)}o.then(i=>a(i&&i.sessionId===n.hashId&&i.serverKey===n.serverKey?i:null),()=>a(null))})}async function zu(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 Bu(n,e){return n.retainOnly(e)}function ju(n,e){return e?.cancel(),n.clear()}function Hu(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 Wu(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n)}catch{}return null}function Mr(n){localStorage.setItem("wherever-config",JSON.stringify(n))}function Fs(){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 zn(){kd();const n=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",e=Wu();return e?(e.port===void 0&&(e.port=Fs()),(e.port===31415||e.port===void 0)&&Fs()!==31415&&(e.port=Fs()),(!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:Fs(),token:"",hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:"",conversationMode:!1,speakReplies:!1,collapseLongReplies:!1,micReopensAfterReply:!1}}const ca=gr(!!zn().beepDefault),_l="wherever-beep-overrides";function Gu(){try{const n=localStorage.getItem(_l);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function qu(n){try{localStorage.setItem(_l,JSON.stringify(n))}catch{}}const wl=gr(typeof localStorage<"u"?Gu():{}),xo=gr("");function Ku(){return Ln(ca)}function Sl(){const n=zn().beepSoundUrl;return typeof n=="string"?n:""}function Vu(n){const e=zn();Mr({...e,beepSoundUrl:n})}const yo=pn([xo,wl],([n,e])=>n&&n in e?e[n]:void 0),_o=pn([yo,ca],([n,e])=>n===void 0?e:n);function Yu(n){const e=zn();Mr({...e,beepDefault:n}),ca.set(n)}function qs(n){const e=Ln(xo);e&&wl.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,qu(s),s})}function kl(n){xo.set(n??"")}const Tl="wherever-speech-direct-send";function Al(){try{return localStorage.getItem(Tl)==="true"}catch{}return!1}const wo=gr(typeof localStorage<"u"?Al():!1);function Cl(){return Al()}function Rl(n){try{localStorage.setItem(Tl,String(n))}catch{}wo.set(n)}const Es=gr(!!zn().conversationMode),Il="wherever-conversation-mode-overrides";function Xu(){try{const n=localStorage.getItem(Il);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function Zu(n){try{localStorage.setItem(Il,JSON.stringify(n))}catch{}}const El=gr(typeof localStorage<"u"?Xu():{}),da=gr(""),So=pn([da,El],([n,e])=>n&&n in e?e[n]:void 0),Ju={subscribe:Es.subscribe},ua=gr(!!zn().speakReplies),fa=gr(!!zn().collapseLongReplies),pa=gr(!!zn().micReopensAfterReply),ko=pn([So,Es],([n,e])=>uu(n,e)),Ml={subscribe:ua.subscribe},Ol={subscribe:fa.subscribe},Qu={subscribe:pa.subscribe};function $l(){return Ln(ko)}function ef(){return Ln(Es)}function Ll(n){const e=zn();Mr({...e,conversationMode:n}),Es.set(n)}function Dl(n){const e=Ln(da);e&&El.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,Zu(s),s})}function Pl(n){da.set(n??"")}function tf(n){const e=zn();Mr({...e,speakReplies:n}),ua.set(n)}function nf(n){const e=zn();Mr({...e,collapseLongReplies:n}),fa.set(n)}function rf(n){const e=zn();Mr({...e,micReopensAfterReply:n}),pa.set(n)}function ss(){return{conversationMode:$l(),autoSendOnSpeechEnd:Cl(),speakReplies:Ln(ua),collapseLongReplies:Ln(fa),micReopensAfterReply:Ln(pa)}}function Nl(n){if(Ln(da)){Dl(n);return}Ll(n)}function Qs(){return{conversationMode:du(ss())}}const ja="wherever-client-key";function sf(){if(!(typeof sessionStorage>"u"))try{const n=sessionStorage.getItem(ja);if(n)return n;const e=`tab-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;return sessionStorage.setItem(ja,e),e}catch{return}}function af(n){try{sessionStorage.setItem(ja,n)}catch{}}const us=zn(),vt=new An({host:us.host,port:us.port,token:us.token,clientKey:sf(),onClientKeyChange:af,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!us.hideThinking,hideTools:!!us.hideTools,imageRefs:!0}),kr=vt.stateStore,Ms=Lu(),ha=Du(()=>{const n=Nu(Ln(kr));return n?Ms.put(n):void 0});let Ha=null;function of(){const n=zn();return Js({host:n.host,port:n.port,token:n.token})}let wi=null;kr.subscribe(n=>{n.messages!==wi&&(wi=n.messages,n.isStreaming&&ha.schedule())});function Wa(){ha.flush()}function To(){ju(Ms,ha)}function Fl(n){return Uu({cache:Ms,serverKey:of(),hashId:n})}function Ul(n){vt.hydrateCachedSession(n);const e=Ln(kr).activeSessionFile===n.sessionFile;return e&&(Ha=n.serverKey),e}let $a=!1,Si=null;kr.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==Si){Si=e,kl(e),Pl(e),$a=n.isStreaming;return}$a&&!n.isStreaming&&e&&Ln(_o)&&hl(Sl()),$a=n.isStreaming});let ms=null;async function lf(n){const{query:e,files:r}=n;if(r.length===0){vt.sendMessage(e,Qs());return}const s=Ln(kr).sessionId,a=[],o=[];for(const i of r){if(!s){o.push(i.name);continue}try{const d=await $o(s,i);a.push(d.savedPath)}catch(d){o.push(`${i.name} (${d.message||"upload failed"})`)}}o.length>0&&kr.update(i=>({...i,sessionError:`Could not attach ${o.join(", ")}`})),vt.sendMessage(ml(e,a),Qs())}const Ao=gr({text:"",bump:0});function zl(n){Ao.update(e=>({text:n,bump:e.bump+1}))}let fs=null;vt.onMessage(n=>{switch(n.type){case"session_forked":{const r=n;fs=r.prefillText??"",as(r.sessionFile,r.cwd);break}case"assistant_current":as(n.sessionFile,n.cwd);break;case"assistant_status":Sd({currentSessionId:n.currentSessionId??null,currentSessionFile:n.currentSessionFile??null,...n.timezone!==void 0?{timezone:n.timezone}:{}});break;case"connected":{xu(r=>vt.send(r));break}case"session_created":if(ys(n.sessionFile),fs!==null){const r=fs;fs=null,queueMicrotask(()=>zl(r))}if(ms!==null){const r=ms;ms=null,queueMicrotask(()=>{lf(r)})}break;case"message_history":case"agent_end":queueMicrotask(()=>ha.flush());break;case"hydration_rejected":{const r=Ha;Ha=null,Hu({sessionId:n.sessionId,serverKey:r,win:typeof window<"u"?window:null,cache:Ms});break}case"session_error":ms=null,fs=null;break;case"session_destroyed":Ln(kr).sessionId===n.sessionId&&ys(null);break;case"sessions_updated":_s();break;case"session_working":{const r=n;wd(r.sessionFile,!!r.working);break}case"session_interrupted":ys(null);break}});function Gr(n={}){const e=zn();Mr(e),Bu(Ms,Js({host:e.host,port:e.port,token:e.token}));const r=typeof window<"u"&&window.location&&window.location.protocol==="https:";vt.connect({host:e.host,port:e.port,token:e.token,secure:r,hideThinking:!!e.hideThinking,hideTools:!!e.hideTools},!!n.preserveState)}function Cs(){vt.disconnect(!0),ys(null)}function Bl(){vt.suspend()}function Ga(){vt.resume()}function qa(){vt.noteVisible()}function cf(){return vt.hasSuspendedSession()}function Ka(){return vt.hasActiveSession()}let Co=0;const df=300*1e3;function jl(){Co=Date.now()+df}function Ro(){Co=0}function Hl(){return Date.now()<Co}function Va(n){return vt.sendMessage(n,Qs())}function Wl(n){return vt.resendMessage(n,Qs())}function Gl(n){vt.discardMessage(n)}function ql(){vt.abort()}function Kl(){vt.cancelSteer()}function Vl(){vt.reloadResources()}function Yl(n,e,r){vt.joinSession(n,e,r)}function as(n,e,r){vt.switchSession(n,e,r),Ql(n)}function Xl(n,e){vt.forkSession(n,e)}function wr(n,e,r,s,a,o){vt.createSession(n,e,r,s,a,o)}function Zl(n,e,r=[]){const s=n.trim();if(!s&&r.length===0)return!1;const a=Ln(al);if(!a)return!1;const o=Ln(Ad);return ms={query:s,files:r},vt.createSession(a,e||void 0,o,o,o?"private":void 0),!0}function Ya(){vt.send({type:"assistant_open"})}function Jl(){vt.send({type:"assistant_reset"})}function br(){vt.leaveSession(),ys(null),Ql()}function Ql(n){if(typeof window>"u")return;const e=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";hu({connected:Ln(kr).connected,hashId:e,target:n})&&history.replaceState(history.state,"",window.location.pathname+window.location.search)}function ec(){vt.loadMoreHistory()}function tc(){vt.continueFolderConflict()}function uf(){vt.ping()}function nc(){vt.clearMessages()}function Xa(n){Mr(n);const{host:e,port:r,token:s,hideThinking:a,hideTools:o}=n;vt.setConfig({host:e,port:r,token:s,hideThinking:a,hideTools:o}),n.beepDefault!==void 0&&ca.set(!!n.beepDefault),n.conversationMode!==void 0&&Es.set(!!n.conversationMode),n.speakReplies!==void 0&&ua.set(!!n.speakReplies),n.collapseLongReplies!==void 0&&fa.set(!!n.collapseLongReplies),n.micReopensAfterReply!==void 0&&pa.set(!!n.micReopensAfterReply)}function rc(n){const r={...zn(),...n};Mr(r),vt.setConfig(r)}function Lr(){vt.dismissSessionError()}function sc(){vt.dismissNotice()}function ac(n){vt.sendSudoPassword(n)}function oc(){vt.cancelSudoPrompt()}function ic(n){vt.changeModel(n)}function Za(n,e,r){return vt.startRestore(n,e,r)}function Io(){return vt.cancelRestore()}function lc(){return vt.reloadSession()}const cn=pn(kr,n=>n),Os=pn(cn,n=>n.connected),Eo=pn(cn,n=>n.isStreaming),cc=pn(cn,n=>n.messages),ff=pn(cn,n=>n.error),pf=pn(cn,n=>n.session),dc=pn(cn,n=>n.folderConflict),Mo=pn(cn,n=>n.folderMissing),uc=pn(cn,n=>n.assistantRetired),Oo=pn(cn,n=>n.restore),fc=pn(cn,n=>n.isInterrupted),pc=pn(cn,n=>n.pendingSteering),ba=pn(cn,n=>n.sessionError),hc=pn(cn,n=>n.notice),bc=pn(cn,n=>n.sudoPrompt),va=pn(cn,n=>n.readOnly),is=pn(cn,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),hf=pn(cn,n=>n.contextUsage),vc=pn(cn,n=>n.creatingSession),$s=pn(cn,n=>n.loadingSession),Ls=pn(cn,n=>n.resyncing),gc=pn(cn,n=>n.agentPending),mc=pn(cn,n=>Fu(n)),xc=pn(cn,n=>n.loadingMoreHistory);function bf(n,e,r,s){const a=Fr(),o=Ur(),i=`${a}/session/upload?sessionId=${encodeURIComponent(n)}&filename=${encodeURIComponent(e.name)}${o?`&token=${encodeURIComponent(o)}`:""}`;return vu({url:i,body:e,size:e.size,signal:r,onProgress:s,probeReadable:()=>gu(e)})}function yc(n){return{size:n.size,read:async(e,r)=>new Uint8Array(await n.slice(e,e+r).arrayBuffer())}}function _c(n){const r=Ln(cn).sessionId;if(!r)return null;const s=Fr(),a=Ur();return`${s}/session/download?sessionId=${encodeURIComponent(r)}&path=${encodeURIComponent(n)}`+(a?`&token=${encodeURIComponent(a)}`:"")}function wc(n){if(n.data)return`data:${n.mimeType};base64,${n.data}`;if(!n.toolCallId||typeof n.index!="number")return null;const e=Ln(cn).sessionId;if(!e)return null;const r=Ur();return`${Fr()}/session/tool-image?sessionId=${encodeURIComponent(e)}&toolCallId=${encodeURIComponent(n.toolCallId)}`+(n.entryId?`&entryId=${encodeURIComponent(n.entryId)}`:"")+`&index=${n.index}`+(r?`&token=${encodeURIComponent(r)}`:"")}async function $o(n,e,r){const s=Ln(Td),a=r?.onProgress;return s==="post"?bf(n,e,r?.signal,a):vt.uploadFileViaWebSocket(n,e.name,yc(e),{signal:r?.signal,mime:e.type||void 0,onProgress:a})}async function Lo(n,e){const r=Fr(),s=Ur(),a=`${r}${n}${s?`?token=${encodeURIComponent(s)}`:""}`,o=await fetch(a,{method:e?.method??"GET",...e?.body!==void 0?{headers:{"Content-Type":"application/json"},body:JSON.stringify(e.body)}:{}});if(!o.ok){const d=await o.json().catch(()=>({}));throw new Error(d.error||`Drafts request failed with status ${o.status}`)}const i=await o.json().catch(()=>({}));return yl(i.drafts)}async function Sc(){return Lo("/drafts")}async function Ja(n){return Lo("/drafts",{method:"POST",body:n})}async function Qa(n){return Lo("/drafts/delete",{method:"POST",body:{id:n}})}async function eo(n){try{const e=Fr(),r=Ur(),s=`${e}/session/delete${r?`?token=${encodeURIComponent(r)}`:""}`,a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionFile:n})});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Delete failed with status ${a.status}`)}}catch(e){throw console.error("Failed to delete session:",e),e}}const vf=Object.freeze(Object.defineProperty({__proto__:null,abort:ql,activeSessionInfo:is,assistantRetired:uc,autoSendOnSpeechEnd:wo,beepEnabled:_o,beepSessionOverride:yo,beginFilePicker:jl,cancelRestore:Io,cancelSteer:Kl,cancelSudoPrompt:oc,changeModel:ic,clearConversationCache:To,clearMessages:nc,client:vt,collapseLongReplies:Ol,composerPrefill:Ao,connect:Gr,connectionError:ff,contextUsage:hf,continueFolderConflict:tc,conversationMode:ko,conversationModeDefault:Ju,conversationModeSessionOverride:So,createSession:wr,currentSession:pf,deleteDraftRemote:Qa,deleteSession:eo,discardMessage:Gl,disconnect:Cs,dismissNotice:sc,dismissSessionError:Lr,downloadFileUrl:_c,endFilePicker:Ro,fetchDrafts:Sc,fileByteSource:yc,flushConversationCache:Wa,folderConflict:dc,folderMissing:Mo,forkSession:Xl,getAutoSendOnSpeechEnd:Cl,getBeepDefault:Ku,getBeepSoundUrl:Sl,getConfig:zn,getConversationKnobs:ss,getConversationMode:$l,getConversationModeDefault:ef,hasActiveSession:Ka,hasMoreHistory:mc,hasSuspendedSession:cf,hydrateFromCache:Ul,isAgentPending:gc,isConnected:Os,isCreatingSession:vc,isFilePickerActive:Hl,isInterrupted:fc,isLoadingMoreHistory:xc,isLoadingSession:$s,isReadOnly:va,isResyncing:Ls,isStreaming:Eo,joinSession:Yl,leaveSession:br,loadMoreHistory:ec,messages:cc,micReopensAfterReply:Qu,noteVisible:qa,openAssistant:Ya,parseSkillInvocation:go,pendingSteering:pc,piState:cn,ping:uf,prefillComposer:zl,readBootConversation:Fl,reloadResources:Vl,reloadSession:lc,resendMessage:Wl,resetAssistant:Jl,restoreState:Oo,resume:Ga,runSearch:Zl,saveDraftRemote:Ja,sendMessage:Va,sendSudoPassword:ac,sessionError:ba,sessionNotice:hc,setAutoSendOnSpeechEnd:Rl,setBeepDefault:Yu,setBeepSessionKey:kl,setBeepSessionOverride:qs,setBeepSoundUrl:Vu,setCollapseLongReplies:nf,setConfig:Xa,setConversationModeBundle:Nl,setConversationModeDefault:Ll,setConversationModeSessionKey:Pl,setConversationModeSessionOverride:Dl,setMicReopensAfterReply:rf,setSpeakReplies:tf,speakReplies:Ml,startRestore:Za,state:kr,sudoPrompt:bc,suspend:Bl,switchSession:as,toolImageSrc:wc,updateConfig:rc,uploadFile:$o},Symbol.toStringTag,{value:"Module"}));function gf(n){if(!n)return null;const e=n.text;if(typeof e!="string")return null;const r=e.trim();return r||null}let Ss=0,Ks=[];function mf(){if(Ss>0&&Ss--,Ss===0&&Ks.length>0){const n=Ks;Ks=[];for(const e of n)e()}}function xf(){return Ss===0?Promise.resolve():new Promise(n=>{Ks.push(n)})}let to=!1,Us=!1,Vs=null;function kc(n){try{typeof n.resume=="function"&&n.resume()}catch{}}const yf=".";function Tc(n){try{return typeof n.getVoices!="function"?[]:n.getVoices()??[]}catch{return[]}}function _f(n,e){const r=(n??"").trim();if(!r)return"";if(e.length===0)return r;const s=r.toLowerCase().split(/[-_]/)[0];return e.some(o=>(o.lang??"").toLowerCase().split(/[-_]/)[0]===s)?r:""}function ga(n=Do()){if(to)return!1;const{synth:e,Utterance:r}=n;if(!e||!r)return!1;try{kc(e),Tc(e);const s=new r(yf);return s.volume=0,e.speak(s),to=!0,Vs?.(),!0}catch{return!1}}const ki=["pointerdown","touchend","mousedown","keydown"];function wf(n=typeof document>"u"?null:document,e=Do()){if(to||Us||!n)return!1;const r=()=>{ga(e)};Vs=()=>{if(Us){Us=!1,Vs=null;for(const s of ki)try{n.removeEventListener(s,r,{capture:!0})}catch{}}},Us=!0;try{for(const s of ki)n.addEventListener(s,r,{capture:!0,passive:!0})}catch{return Vs?.(),!1}return!0}function Do(){if(typeof window>"u")return{synth:null,Utterance:null};const n=window;return{synth:n.speechSynthesis??null,Utterance:n.SpeechSynthesisUtterance??null}}function Ti(n,e,r=Do()){const s=(n??"").trim();if(!s)return!1;const{synth:a,Utterance:o}=r;if(!a||!o)return!1;Ss++;let i=!1;const d=()=>{i||(i=!0,mf())};try{kc(a);const m=new o(s),v=_f(e,Tc(a));return v&&(m.lang=v),m.onend=d,m.onerror=d,a.speak(m),!0}catch{return d(),!1}}var Sf=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>'),kf=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>'),Tf=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
|
|
20
|
-
per conversation, and the 💬/🗣️ toggle above the composer sets it for
|
|
21
|
-
the conversation you are in, leaving the others alone. Changing this
|
|
22
|
-
default moves every conversation still following it. It flips the knobs
|
|
23
|
-
below on at once; when off, they are dormant and the default
|
|
24
|
-
typing-first experience is unchanged. Auto-send on speech end (Direct
|
|
25
|
-
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
|
|
26
|
-
until told to stop, an auto-opened mic stops itself on silence (and
|
|
27
|
-
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 Af(n,e){nr(e,!0);const r=()=>ye(Os,"$isConnected",s),[s,a]=Nr();let o=F(""),i=F(0),d=F(""),m=F(!1),v=F(!1),g=F(""),x=F(!1),y=F(!1),D=F(!1),P=F(!1),re=!1,U=L(r);os(()=>{const R=zn();p(o,R.host,!0),p(i,R.port,!0),p(d,R.token||"",!0),p(m,!!R.hideThinking),p(v,!!R.beepDefault),p(g,R.beepSoundUrl||"",!0),p(x,!!R.conversationMode),p(y,!!R.speakReplies),p(D,!!R.collapseLongReplies),p(P,!!R.micReopensAfterReply)});function B(){hl(t(g).trim()||void 0)}function W(){Xa({host:t(o),port:t(i),token:t(d),hideThinking:t(m),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(g).trim(),conversationMode:t(x),speakReplies:t(y),collapseLongReplies:t(D),micReopensAfterReply:t(P)}),t(x)&&t(y)&&ga()}function ze(){Xa({host:t(o),port:t(i),token:t(d),hideThinking:t(m),hideTools:!1,beepDefault:t(v),beepSoundUrl:t(g).trim(),conversationMode:t(x),speakReplies:t(y),collapseLongReplies:t(D),micReopensAfterReply:t(P)}),Cs(),setTimeout(()=>Gr(),100)}function X(){Cs(),To()}function G(){window.location.reload()}var Y=Tf(),Ce=u(Y),he=u(Ce),Ae=f(u(he),2);kt(Ae),c(he);var te=f(he,2),Ne=f(u(te),2);kt(Ne),c(te);var He=f(te,2),Ke=f(u(He),2);kt(Ke),c(He);var Je=f(He,2),Be=u(Je);kt(Be),dt(2),c(Je);var Qe=f(Je,2),ut=u(Qe);kt(ut),dt(2),c(Qe);var Ot=f(Qe,2),Tt=f(u(Ot),2),xt=u(Tt);kt(xt);var Re=f(xt,2);c(Tt),c(Ot);var Wt=f(Ot,2),ve=u(Wt),$t=u(ve);kt($t),dt(2),c(ve);var It=f(ve,4),At=u(It);kt(At),dt(2),c(It);var oe=f(It,2),q=u(oe);kt(q),dt(2),c(oe);var tt=f(oe,2),ge=u(tt);kt(ge),dt(2),c(tt),dt(2),c(Wt);var le=f(Wt,2),et=u(le);{var ee=R=>{var se=Sf();M("click",se,X),h(R,se)},K=R=>{var se=kf();se.disabled=re,se.textContent="Connect",M("click",se,ze),h(R,se)};w(et,R=>{t(U)?R(ee):R(K,-1)})}c(le);var we=f(le,2);c(Ce),c(Y),fr(Ae,()=>t(o),R=>p(o,R)),fr(Ne,()=>t(i),R=>p(i,R)),fr(Ke,()=>t(d),R=>p(d,R)),M("change",Be,W),Jn(Be,()=>t(m),R=>p(m,R)),M("change",ut,W),Jn(ut,()=>t(v),R=>p(v,R)),M("change",xt,W),fr(xt,()=>t(g),R=>p(g,R)),M("click",Re,B),M("change",$t,W),Jn($t,()=>t(x),R=>p(x,R)),M("change",At,W),Jn(At,()=>t(y),R=>p(y,R)),M("change",q,W),Jn(q,()=>t(D),R=>p(D,R)),M("change",ge,W),Jn(ge,()=>t(P),R=>p(P,R)),M("click",we,G),h(n,Y),rr(),a()}pr(["change","click"]);function Cf(n=globalThis){return!!n.navigator&&"serviceWorker"in n.navigator&&"PushManager"in n&&"Notification"in n}function Rf(n){const e="=".repeat((4-n.length%4)%4),r=(n+e).replace(/-/g,"+").replace(/_/g,"/"),s=atob(r),a=new Uint8Array(s.length);for(let o=0;o<s.length;++o)a[o]=s.charCodeAt(o);return a}function Rs(n,e,r=""){const s=new URLSearchParams(r);n.token&&s.set("token",n.token);const a=s.toString();return`${n.baseUrl}${e}${a?`?${a}`:""}`}async function Is(n){const e=await n.json().catch(()=>({}));if(!n.ok)throw new Error(e?.error||`HTTP ${n.status}`);return e}function If(n,e){if(!n)return!1;const r=new Uint8Array(n);return r.length===e.length&&r.every((s,a)=>s===e[a])}async function Ac(n,e){const r=await n.getSubscription();return r?!!(await Is(await e.fetch(Rs(e,"/push/subscription",`endpoint=${encodeURIComponent(r.endpoint)}`)))).subscribed:!1}async function Ef(n,e){const{publicKey:r}=await Is(await e.fetch(Rs(e,"/push/vapid-public-key")));if(typeof r!="string"||!r)throw new Error("the server sent no VAPID public key");const s=Rf(r);let a=await n.getSubscription();a&&!If(a.options?.applicationServerKey,s)&&(await a.unsubscribe(),a=null),a||(a=await n.subscribe({userVisibleOnly:!0,applicationServerKey:s})),await Is(await e.fetch(Rs(e,"/push/subscription"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.toJSON())}))}async function Mf(n,e){const r=await n.getSubscription();r&&(await Is(await e.fetch(Rs(e,"/push/subscription"),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:r.endpoint})})),await r.unsubscribe())}function ea(n,e){let r,s="";if(n&&typeof n=="object"&&"message"in n){const a=n;s=typeof a.name=="string"?a.name:"";const o=String(a.message??"");r=s&&s!=="Error"?`${s}: ${o}`:o}else r=String(n);return s==="NotAllowedError"||e==="denied"?`${r} Notifications are blocked for this site: re-allow them in the browser's site settings (the icon left of the address), then try again.`:s==="AbortError"?`${r} The browser's push service is disabled or unreachable. On Firefox and LibreWolf, open about:config and check that dom.push.enabled and dom.push.connection.enabled are true (and that the browser can reach its push server).`:r}async function Of(n,e,r,s){let a="";try{r?await Ef(n,e):await Mf(n,e)}catch(i){a=ea(i,s?.())}let o=!r;try{o=await Ac(n,e)}catch(i){a||(a=ea(i,s?.()))}return{subscribed:o,error:a}}async function $f(n,e){const r=await Is(await n.fetch(Rs(n,"/push/test"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?{sessionId:e}:{})})),s=Array.isArray(r?.deliveries)?r.deliveries:[],a=s.filter(d=>d.result.ok).map(d=>d.result.ok&&d.result.detail?`${d.channel} (${d.result.detail})`:d.channel),o=s.filter(d=>!d.result.ok).map(d=>`${d.channel}: ${d.result.ok?"":d.result.error}`);let i=a.length>0?`Sent: ${a.join(", ")}.`:"Sent.";return o.length>0&&(i+=` Not delivered: ${o.join("; ")}.`),i}var Lf=b(`<p class="text-xs text-brand-text-muted">This browser cannot receive push notifications (on iOS, add wherever to
|
|
28
|
-
the home screen first).</p>`),Df=b('<p class="selectable pl-6 text-[10px] leading-relaxed break-words text-rose-400"> </p>'),Pf=b('<p class="selectable mt-1 text-[10px] leading-relaxed text-emerald-400"> </p>'),Nf=b('<p class="selectable mt-1 text-[10px] leading-relaxed break-words text-rose-400"> </p>'),Ff=b(`<div class="mt-2 pl-6"><button type="button" class="rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-xs text-brand-text transition-colors hover:bg-brand-surface-3 disabled:opacity-50" title="Send a notification through the server, as an agent's assistant_notify does"> </button> <!> <!></div>`),Uf=b(`<div class="flex items-center gap-2 py-1"><input id="assistant-push" 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="assistant-push" class="cursor-pointer text-xs text-brand-text select-none">Push notifications on this device</label></div> <p class="pl-6 text-[10px] leading-relaxed text-brand-text-muted">Only when an agent deliberately notifies you (assistant_notify); tapping
|
|
29
|
-
one opens the session it is about.</p> <!> <!>`,1),zf=b('<div class="border-t border-brand-border p-4"><h3 class="mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase">Assistant notifications</h3> <!></div>');function Bf(n,e){nr(e,!0);let r=ir(e,"currentSessionId",3,null),s=F(!1),a=F(!1),o=F(!0),i=F(""),d=F(!1),m=F(""),v=F(""),g=F(void 0);const x=()=>typeof Notification<"u"?Notification.permission:void 0,y=()=>({baseUrl:Fr(),token:Ur(),fetch:(X,G)=>fetch(X,G)});async function D(){return(await navigator.serviceWorker.ready).pushManager}os(()=>{if(p(s,Cf(),!0),!t(s)){p(o,!1);return}(async()=>{try{p(a,await Ac(await D(),y()),!0)}catch(X){p(i,ea(X,x()),!0)}finally{p(o,!1)}})()});async function P(){p(o,!0),p(i,""),p(m,""),p(v,"");const X=!t(a);try{const G=await Of(await D(),y(),X,x);p(a,G.subscribed,!0),p(i,G.error,!0),Ts()}catch(G){p(i,ea(G,x()),!0)}finally{t(g)&&(t(g).checked=t(a)),p(o,!1)}}async function re(){p(d,!0),p(m,""),p(v,"");try{p(m,await $f(y(),r()),!0)}catch(X){p(v,X.message,!0)}finally{p(d,!1)}}var U=zf(),B=f(u(U),2);{var W=X=>{var G=Lf();h(X,G)},ze=X=>{var G=Uf(),Y=mt(G),Ce=u(Y);kt(Ce),lr(Ce,He=>p(g,He),()=>t(g)),dt(2),c(Y);var he=f(Y,4);{var Ae=He=>{var Ke=Df(),Je=u(Ke,!0);c(Ke),T(()=>E(Je,t(i))),h(He,Ke)};w(he,He=>{t(i)&&He(Ae)})}var te=f(he,2);{var Ne=He=>{var Ke=Ff(),Je=u(Ke),Be=u(Je,!0);c(Je);var Qe=f(Je,2);{var ut=xt=>{var Re=Pf(),Wt=u(Re,!0);c(Re),T(()=>E(Wt,t(m))),h(xt,Re)};w(Qe,xt=>{t(m)&&xt(ut)})}var Ot=f(Qe,2);{var Tt=xt=>{var Re=Nf(),Wt=u(Re,!0);c(Re),T(()=>E(Wt,t(v))),h(xt,Re)};w(Ot,xt=>{t(v)&&xt(Tt)})}c(Ke),T(()=>{Je.disabled=t(d)||t(o),E(Be,t(d)?"Sending…":"Send test notification")}),M("click",Je,re),h(He,Ke)};w(te,He=>{t(a)&&He(Ne)})}T(()=>{ia(Ce,t(a)),Ce.disabled=t(o)}),M("change",Ce,P),h(X,G)};w(B,X=>{t(s)?X(ze,-1):X(W)})}c(U),h(n,U),rr()}pr(["change","click"]);function jf(n){return n.active&&!!n.telegram?.enabled}function Hf(n){return n.state!=="unpaired"||!n.code?null:`Send /pair ${n.code} to ${n.bot??"the bot"} on Telegram.`}function Wf(n){return n.state==="paired"&&n.user.source==="pairing"}async function Gf(n){const e=n.token?`?token=${encodeURIComponent(n.token)}`:"",r=await n.fetch(`${n.baseUrl}/telegram/repair${e}`,{method:"POST"}),s=await r.json().catch(()=>({}));if(!r.ok)throw new Error(s?.error||`HTTP ${r.status}`);return s.telegram}function qf(){return{clipboard:typeof navigator<"u"?navigator.clipboard:void 0,document:typeof document<"u"?document:void 0}}async function Kf(n,e=qf()){if(e.clipboard?.writeText)try{return await e.clipboard.writeText(n),!0}catch{}const r=e.document;if(!r?.body||typeof r.execCommand!="function")return!1;const s=r.createElement("textarea");s.value=n,s.setAttribute("readonly",""),s.style.position="fixed",s.style.top="-1000px",s.style.opacity="0",r.body.appendChild(s);try{return s.select(),r.execCommand("copy")}catch{return!1}finally{r.body.removeChild(s)}}var Vf=b('<button type="button" class="flex-shrink-0 rounded border border-brand-border bg-brand-surface-2 px-2 py-0.5 text-[10px] text-brand-text transition-colors hover:bg-brand-surface-3"> </button>');function Ai(n,e){nr(e,!0);let r=ir(e,"label",3,"Copy"),s=F("idle"),a=null;async function o(){p(s,await Kf(e.value)?"copied":"failed",!0),a&&clearTimeout(a),a=setTimeout(()=>p(s,"idle"),t(s)==="copied"?1500:4e3)}uo(()=>{a&&clearTimeout(a)});var i=Vf(),d=u(i,!0);c(i),T(()=>{Z(i,"title",t(s)==="failed"?"Copying is not available here: select the text and copy it by hand":`Copy ${e.value}`),E(d,t(s)==="copied"?"Copied":t(s)==="failed"?"Select to copy":r())}),M("click",i,o),h(n,i),rr()}pr(["click"]);var Yf=b('<p class="selectable text-xs text-rose-400"> </p>'),Xf=b('<p class="text-xs text-brand-text-muted">Connecting to Telegram…</p>'),Zf=b('<p class="selectable mt-2 text-xs text-brand-text-muted"> </p> <div class="mt-1 flex items-center gap-2"><span class="selectable-all font-mono text-base tracking-widest text-brand-text"> </span> <!> <!></div> <p class="mt-1 text-[10px] leading-relaxed text-brand-text-muted">The code works once; anyone else writing to the bot is ignored.</p>',1),Jf=b('<p class="text-xs text-brand-text">Not paired yet.</p> <!>',1),Qf=b('<p class="mt-1 text-[10px] leading-relaxed text-brand-text-muted">Set in the config (assistantTelegram.userId).</p>'),ep=b('<button class="mt-2 rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-xs text-brand-text transition-colors hover:bg-brand-surface-3 disabled:opacity-50">Re-pair</button>'),tp=b('<p class="selectable text-xs text-brand-text"> </p> <!> <!>',1),np=b('<p class="selectable mt-1 text-[10px] text-amber-400"> </p>'),rp=b('<p class="selectable mt-1 text-[10px] text-rose-400"> </p>'),sp=b('<div class="border-t border-brand-border p-4"><h3 class="mb-3 text-xs font-bold tracking-wider text-brand-text-muted uppercase">Assistant on Telegram</h3> <!> <!> <!></div>');function ap(n,e){nr(e,!0);let r=F(!1),s=F(""),a=null;Nt(()=>{const U=e.status.state==="unpaired"||e.status.state==="starting";U&&!a?a=setInterval(()=>{Ts()},3e3):!U&&a&&(clearInterval(a),a=null)}),uo(()=>{a&&clearInterval(a)});async function o(){if(confirm("Unpair the current Telegram account? A new pairing code will be issued.")){p(r,!0),p(s,"");try{await Gf({baseUrl:Fr(),token:Ur(),fetch:(U,B)=>fetch(U,B)}),await Ts()}catch(U){p(s,U.message,!0)}finally{p(r,!1)}}}var i=sp(),d=f(u(i),2);{var m=U=>{var B=Yf(),W=u(B);c(B),T(()=>E(W,`Telegram is disabled${"error"in e.status&&e.status.error?`: ${e.status.error}`:""}.`)),h(U,B)},v=U=>{var B=Xf();h(U,B)},g=U=>{var B=Jf(),W=f(mt(B),2);{var ze=X=>{var G=Zf(),Y=mt(G),Ce=u(Y,!0);c(Y);var he=f(Y,2),Ae=u(he),te=u(Ae,!0);c(Ae);var Ne=f(Ae,2);Ai(Ne,{get value(){return e.status.code}});var He=f(Ne,2);{let Ke=L(()=>`/pair ${e.status.code}`);Ai(He,{get value(){return t(Ke)},label:"Copy /pair"})}c(he),dt(2),T(Ke=>{E(Ce,Ke),E(te,e.status.code)},[()=>Hf(e.status)]),h(X,G)};w(W,X=>{e.status.code&&X(ze)})}h(U,B)},x=U=>{var B=tp(),W=mt(B),ze=u(W);c(W);var X=f(W,2);{var G=Ae=>{var te=Qf();h(Ae,te)};w(X,Ae=>{e.status.user.source==="config"&&Ae(G)})}var Y=f(X,2);{var Ce=Ae=>{var te=ep();T(()=>te.disabled=t(r)),M("click",te,o),h(Ae,te)},he=L(()=>Wf(e.status));w(Y,Ae=>{t(he)&&Ae(Ce)})}T(()=>E(ze,`Paired with ${e.status.user.name??`user ${e.status.user.id}`??""}${e.status.bot?` via ${e.status.bot}`:""}.`)),h(U,B)};w(d,U=>{e.status.state==="disabled"||e.status.state==="error"?U(m):e.status.state==="starting"?U(v,1):e.status.state==="unpaired"?U(g,2):e.status.state==="paired"&&U(x,3)})}var y=f(d,2);{var D=U=>{var B=np(),W=u(B,!0);c(B),T(()=>E(W,e.status.error)),h(U,B)};w(y,U=>{e.status.state!=="disabled"&&e.status.state!=="error"&&e.status.error&&U(D)})}var P=f(y,2);{var re=U=>{var B=rp(),W=u(B,!0);c(B),T(()=>E(W,t(s))),h(U,B)};w(P,U=>{t(s)&&U(re)})}c(i),h(n,i),rr()}pr(["click"]);const op=["png","jpg","jpeg","gif","webp","bmp","svg","avif"],ip=["mp3","wav","oga","ogg","m4a","aac","flac","opus"],lp=["mp4","webm","mov","m4v","ogv"];function cp(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 dp(n){const e=cp(n);return e?op.includes(e)?"image":ip.includes(e)?"audio":lp.includes(e)?"video":null:null}function up(n,e,r){if(r||!e)return null;const s=(n||"").toLowerCase();if(!["attach_file","read"].includes(s))return null;const a=e.path||e.filepath||e.file;return!a||typeof a!="string"?null:a.trim()||null}const fp=320;function Cc(n,e=fp){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 a=s.match(/[^.!?]+[.!?]+(?:\s|$)|[^.!?]+$/g)??[s];let o="";for(const i of a){const d=(o+i).trimEnd();if(o&&d.length>e||(o=d,o.length>=e))break}return o=o.trim(),o||(o=s),o.length>e&&(o=`${o.slice(0,e).trimEnd()}...`),o}function pp(n){return!n.active||n.spokeThisTurn?!1:Cc(n.reply).length>0}const hp=600;function Rc(n){return n?n.length>hp:!1}function bp(n){return!n.active||n.expanded?!1:Rc(n.content)}function Po(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Kr=Po();function Ic(n){Kr=n}var ks={exec:()=>null};function on(n,e=""){let r=typeof n=="string"?n:n.source;const s={replace:(a,o)=>{let i=typeof o=="string"?o:o.source;return i=i.replace(Qn.caret,"$1"),r=r.replace(a,i),s},getRegex:()=>new RegExp(r,e)};return s}var Qn={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")},vp=/^(?:[ \t]*(?:\n|$))+/,gp=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,mp=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ds=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,xp=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,No=/(?:[*+-]|\d{1,9}[.)])/,Ec=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Mc=on(Ec).replace(/bull/g,No).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(),yp=on(Ec).replace(/bull/g,No).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(),Fo=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,_p=/^[^\n]+/,Uo=/(?!\s*\])(?:\\.|[^\[\]\\])+/,wp=on(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Uo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Sp=on(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,No).getRegex(),ma="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",zo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,kp=on("^ {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",zo).replace("tag",ma).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Oc=on(Fo).replace("hr",Ds).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",ma).getRegex(),Tp=on(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Oc).getRegex(),Bo={blockquote:Tp,code:gp,def:wp,fences:mp,heading:xp,hr:Ds,html:kp,lheading:Mc,list:Sp,newline:vp,paragraph:Oc,table:ks,text:_p},Ci=on("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ds).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",ma).getRegex(),Ap={...Bo,lheading:yp,table:Ci,paragraph:on(Fo).replace("hr",Ds).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ci).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",ma).getRegex()},Cp={...Bo,html:on(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",zo).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:ks,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:on(Fo).replace("hr",Ds).replace("heading",` *#{1,6} *[^
|
|
30
|
-
]`).replace("lheading",Mc).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Rp=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ip=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$c=/^( {2,}|\\)\n(?!\s*$)/,Ep=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,xa=/[\p{P}\p{S}]/u,jo=/[\s\p{P}\p{S}]/u,Lc=/[^\s\p{P}\p{S}]/u,Mp=on(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,jo).getRegex(),Dc=/(?!~)[\p{P}\p{S}]/u,Op=/(?!~)[\s\p{P}\p{S}]/u,$p=/(?:[^\s\p{P}\p{S}]|~)/u,Lp=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Pc=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Dp=on(Pc,"u").replace(/punct/g,xa).getRegex(),Pp=on(Pc,"u").replace(/punct/g,Dc).getRegex(),Nc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Np=on(Nc,"gu").replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,jo).replace(/punct/g,xa).getRegex(),Fp=on(Nc,"gu").replace(/notPunctSpace/g,$p).replace(/punctSpace/g,Op).replace(/punct/g,Dc).getRegex(),Up=on("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,jo).replace(/punct/g,xa).getRegex(),zp=on(/\\(punct)/,"gu").replace(/punct/g,xa).getRegex(),Bp=on(/^<(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(),jp=on(zo).replace("(?:-->|$)","-->").getRegex(),Hp=on("^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",jp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ta=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Wp=on(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",ta).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Fc=on(/^!?\[(label)\]\[(ref)\]/).replace("label",ta).replace("ref",Uo).getRegex(),Uc=on(/^!?\[(ref)\](?:\[\])?/).replace("ref",Uo).getRegex(),Gp=on("reflink|nolink(?!\\()","g").replace("reflink",Fc).replace("nolink",Uc).getRegex(),Ho={_backpedal:ks,anyPunctuation:zp,autolink:Bp,blockSkip:Lp,br:$c,code:Ip,del:ks,emStrongLDelim:Dp,emStrongRDelimAst:Np,emStrongRDelimUnd:Up,escape:Rp,link:Wp,nolink:Uc,punctuation:Mp,reflink:Fc,reflinkSearch:Gp,tag:Hp,text:Ep,url:ks},qp={...Ho,link:on(/^!?\[(label)\]\((.*?)\)/).replace("label",ta).getRegex(),reflink:on(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ta).getRegex()},no={...Ho,emStrongRDelimAst:Fp,emStrongLDelim:Pp,url:on(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Kp={...no,br:on($c).replace("{2,}","*").getRegex(),text:on(no.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},zs={normal:Bo,gfm:Ap,pedantic:Cp},ps={normal:Ho,gfm:no,breaks:Kp,pedantic:qp},Vp={"&":"&","<":"<",">":">",'"':""","'":"'"},Ri=n=>Vp[n];function yr(n,e){if(e){if(Qn.escapeTest.test(n))return n.replace(Qn.escapeReplace,Ri)}else if(Qn.escapeTestNoEncode.test(n))return n.replace(Qn.escapeReplaceNoEncode,Ri);return n}function Ii(n){try{n=encodeURI(n).replace(Qn.percentDecode,"%")}catch{return null}return n}function Ei(n,e){const r=n.replace(Qn.findPipe,(o,i,d)=>{let m=!1,v=i;for(;--v>=0&&d[v]==="\\";)m=!m;return m?"|":" |"}),s=r.split(Qn.splitPipe);let a=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(;a<s.length;a++)s[a]=s[a].trim().replace(Qn.slashPipe,"|");return s}function hs(n,e,r){const s=n.length;if(s===0)return"";let a=0;for(;a<s&&n.charAt(s-a-1)===e;)a++;return n.slice(0,s-a)}function Yp(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,a){const o=e.href,i=e.title||null,d=n[1].replace(a.other.outputLinkReplace,"$1");s.state.inLink=!0;const m={type:n[0].charAt(0)==="!"?"image":"link",raw:r,href:o,title:i,text:d,tokens:s.inlineTokens(d)};return s.state.inLink=!1,m}function Xp(n,e,r){const s=n.match(r.other.indentCodeCompensation);if(s===null)return e;const a=s[1];return e.split(`
|
|
31
|
-
`).map(o=>{const i=o.match(r.other.beginningSpace);if(i===null)return o;const[d]=i;return d.length>=a.length?o.slice(a.length):o}).join(`
|
|
32
|
-
`)}var na=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:hs(r,`
|
|
33
|
-
`)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const r=e[0],s=Xp(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=hs(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:hs(e[0],`
|
|
34
|
-
`)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let r=hs(e[0],`
|
|
35
|
-
`).split(`
|
|
36
|
-
`),s="",a="";const o=[];for(;r.length>0;){let i=!1;const d=[];let m;for(m=0;m<r.length;m++)if(this.rules.other.blockquoteStart.test(r[m]))d.push(r[m]),i=!0;else if(!i)d.push(r[m]);else break;r=r.slice(m);const v=d.join(`
|
|
37
|
-
`),g=v.replace(this.rules.other.blockquoteSetextReplace,`
|
|
38
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
39
|
-
${v}`:v,a=a?`${a}
|
|
40
|
-
${g}`:g;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(g,o,!0),this.lexer.state.top=x,r.length===0)break;const y=o.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){const D=y,P=D.raw+`
|
|
41
|
-
`+r.join(`
|
|
42
|
-
`),re=this.blockquote(P);o[o.length-1]=re,s=s.substring(0,s.length-D.raw.length)+re.raw,a=a.substring(0,a.length-D.text.length)+re.text;break}else if(y?.type==="list"){const D=y,P=D.raw+`
|
|
43
|
-
`+r.join(`
|
|
44
|
-
`),re=this.list(P);o[o.length-1]=re,s=s.substring(0,s.length-y.raw.length)+re.raw,a=a.substring(0,a.length-D.raw.length)+re.raw,r=P.substring(o.at(-1).raw.length).split(`
|
|
45
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:o,text:a}}}list(n){let e=this.rules.block.list.exec(n);if(e){let r=e[1].trim();const s=r.length>1,a={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 o=this.rules.other.listItemRegex(r);let i=!1;for(;n;){let m=!1,v="",g="";if(!(e=o.exec(n))||this.rules.block.hr.test(n))break;v=e[0],n=n.substring(v.length);let x=e[2].split(`
|
|
46
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,B=>" ".repeat(3*B.length)),y=n.split(`
|
|
47
|
-
`,1)[0],D=!x.trim(),P=0;if(this.options.pedantic?(P=2,g=x.trimStart()):D?P=e[1].length+1:(P=e[2].search(this.rules.other.nonSpaceChar),P=P>4?1:P,g=x.slice(P),P+=e[1].length),D&&this.rules.other.blankLine.test(y)&&(v+=y+`
|
|
48
|
-
`,n=n.substring(y.length+1),m=!0),!m){const B=this.rules.other.nextBulletRegex(P),W=this.rules.other.hrRegex(P),ze=this.rules.other.fencesBeginRegex(P),X=this.rules.other.headingBeginRegex(P),G=this.rules.other.htmlBeginRegex(P);for(;n;){const Y=n.split(`
|
|
49
|
-
`,1)[0];let Ce;if(y=Y,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),Ce=y):Ce=y.replace(this.rules.other.tabCharGlobal," "),ze.test(y)||X.test(y)||G.test(y)||B.test(y)||W.test(y))break;if(Ce.search(this.rules.other.nonSpaceChar)>=P||!y.trim())g+=`
|
|
50
|
-
`+Ce.slice(P);else{if(D||x.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ze.test(x)||X.test(x)||W.test(x))break;g+=`
|
|
51
|
-
`+y}!D&&!y.trim()&&(D=!0),v+=Y+`
|
|
52
|
-
`,n=n.substring(Y.length+1),x=Ce.slice(P)}}a.loose||(i?a.loose=!0:this.rules.other.doubleBlankLine.test(v)&&(i=!0));let re=null,U;this.options.gfm&&(re=this.rules.other.listIsTask.exec(g),re&&(U=re[0]!=="[ ] ",g=g.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:v,task:!!re,checked:U,loose:!1,text:g,tokens:[]}),a.raw+=v}const d=a.items.at(-1);if(d)d.raw=d.raw.trimEnd(),d.text=d.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let m=0;m<a.items.length;m++)if(this.lexer.state.top=!1,a.items[m].tokens=this.lexer.blockTokens(a.items[m].text,[]),!a.loose){const v=a.items[m].tokens.filter(x=>x.type==="space"),g=v.length>0&&v.some(x=>this.rules.other.anyLine.test(x.raw));a.loose=g}if(a.loose)for(let m=0;m<a.items.length;m++)a.items[m].loose=!0;return a}}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"):"",a=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:a}}}table(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const r=Ei(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
53
|
-
`):[],o={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const i of s)this.rules.other.tableAlignRight.test(i)?o.align.push("right"):this.rules.other.tableAlignCenter.test(i)?o.align.push("center"):this.rules.other.tableAlignLeft.test(i)?o.align.push("left"):o.align.push(null);for(let i=0;i<r.length;i++)o.header.push({text:r[i],tokens:this.lexer.inline(r[i]),header:!0,align:o.align[i]});for(const i of a)o.rows.push(Ei(i,o.header.length).map((d,m)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:o.align[m]})));return o}}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)===`
|
|
54
|
-
`?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 o=hs(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=Yp(e[2],"()");if(o===-2)return;if(o>-1){const d=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,d).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],a=o[3])}else a=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:a&&a.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," "),a=e[s.toLowerCase()];if(!a){const o=r[0].charAt(0);return{type:"text",raw:o,text:o}}return Mi(r,a,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 o=[...s[0]].length-1;let i,d,m=o,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+o);(s=g.exec(e))!=null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(d=[...i].length,s[3]||s[4]){m+=d;continue}else if((s[5]||s[6])&&o%3&&!((o+d)%3)){v+=d;continue}if(m-=d,m>0)continue;d=Math.min(d,d+m+v);const x=[...s[0]][0].length,y=n.slice(0,o+s.index+x+d);if(Math.min(o,d)%2){const P=y.slice(1,-1);return{type:"em",raw:y,text:P,tokens:this.lexer.inlineTokens(P)}}const D=y.slice(2,-2);return{type:"strong",raw:y,text:D,tokens:this.lexer.inlineTokens(D)}}}}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),a=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return s&&a&&(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 a;do a=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(a!==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}}}},Ir=class ro{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 na,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:Qn,block:zs.normal,inline:ps.normal};this.options.pedantic?(r.block=zs.pedantic,r.inline=ps.pedantic):this.options.gfm&&(r.block=zs.gfm,this.options.breaks?r.inline=ps.breaks:r.inline=ps.gfm),this.tokenizer.rules=r}static get rules(){return{block:zs,inline:ps}}static lex(e,r){return new ro(r).lex(e)}static lexInline(e,r){return new ro(r).inlineTokens(e)}lex(e){e=e.replace(Qn.carriageReturn,`
|
|
55
|
-
`),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(Qn.tabCharGlobal," ").replace(Qn.spaceLine,""));e;){let a;if(this.options.extensions?.block?.some(i=>(a=i.call({lexer:this},e,r))?(e=e.substring(a.raw.length),r.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);const i=r.at(-1);a.raw.length===1&&i!==void 0?i.raw+=`
|
|
56
|
-
`:r.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);const i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=`
|
|
57
|
-
`+a.raw,i.text+=`
|
|
58
|
-
`+a.text,this.inlineQueue.at(-1).src=i.text):r.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);const i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=`
|
|
59
|
-
`+a.raw,i.text+=`
|
|
60
|
-
`+a.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title});continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),r.push(a);continue}let o=e;if(this.options.extensions?.startBlock){let i=1/0;const d=e.slice(1);let m;this.options.extensions.startBlock.forEach(v=>{m=v.call({lexer:this},d),typeof m=="number"&&m>=0&&(i=Math.min(i,m))}),i<1/0&&i>=0&&(o=e.substring(0,i+1))}if(this.state.top&&(a=this.tokenizer.paragraph(o))){const i=r.at(-1);s&&i?.type==="paragraph"?(i.raw+=`
|
|
61
|
-
`+a.raw,i.text+=`
|
|
62
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(a),s=o.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);const i=r.at(-1);i?.type==="text"?(i.raw+=`
|
|
63
|
-
`+a.raw,i.text+=`
|
|
64
|
-
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(a);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,a=null;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,a.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(a=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let o=!1,i="";for(;e;){o||(i=""),o=!1;let d;if(this.options.extensions?.inline?.some(v=>(d=v.call({lexer:this},e,r))?(e=e.substring(d.raw.length),r.push(d),!0):!1))continue;if(d=this.tokenizer.escape(e)){e=e.substring(d.raw.length),r.push(d);continue}if(d=this.tokenizer.tag(e)){e=e.substring(d.raw.length),r.push(d);continue}if(d=this.tokenizer.link(e)){e=e.substring(d.raw.length),r.push(d);continue}if(d=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(d.raw.length);const v=r.at(-1);d.type==="text"&&v?.type==="text"?(v.raw+=d.raw,v.text+=d.text):r.push(d);continue}if(d=this.tokenizer.emStrong(e,s,i)){e=e.substring(d.raw.length),r.push(d);continue}if(d=this.tokenizer.codespan(e)){e=e.substring(d.raw.length),r.push(d);continue}if(d=this.tokenizer.br(e)){e=e.substring(d.raw.length),r.push(d);continue}if(d=this.tokenizer.del(e)){e=e.substring(d.raw.length),r.push(d);continue}if(d=this.tokenizer.autolink(e)){e=e.substring(d.raw.length),r.push(d);continue}if(!this.state.inLink&&(d=this.tokenizer.url(e))){e=e.substring(d.raw.length),r.push(d);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(y=>{x=y.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(d=this.tokenizer.inlineText(m)){e=e.substring(d.raw.length),d.raw.slice(-1)!=="_"&&(i=d.raw.slice(-1)),o=!0;const v=r.at(-1);v?.type==="text"?(v.raw+=d.raw,v.text+=d.text):r.push(d);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}},ra=class{options;parser;constructor(n){this.options=n||Kr}space(n){return""}code({text:n,lang:e,escaped:r}){const s=(e||"").match(Qn.notSpaceStart)?.[0],a=n.replace(Qn.endingNewline,"")+`
|
|
65
|
-
`;return s?'<pre><code class="language-'+yr(s)+'">'+(r?a:yr(a,!0))+`</code></pre>
|
|
66
|
-
`:"<pre><code>"+(r?a:yr(a,!0))+`</code></pre>
|
|
67
|
-
`}blockquote({tokens:n}){return`<blockquote>
|
|
68
|
-
${this.parser.parse(n)}</blockquote>
|
|
69
|
-
`}html({text:n}){return n}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
70
|
-
`}hr(n){return`<hr>
|
|
71
|
-
`}list(n){const e=n.ordered,r=n.start;let s="";for(let i=0;i<n.items.length;i++){const d=n.items[i];s+=this.listitem(d)}const a=e?"ol":"ul",o=e&&r!==1?' start="'+r+'"':"";return"<"+a+o+`>
|
|
72
|
-
`+s+"</"+a+`>
|
|
73
|
-
`}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+" "+yr(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>
|
|
74
|
-
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
75
|
-
`}table(n){let e="",r="";for(let a=0;a<n.header.length;a++)r+=this.tablecell(n.header[a]);e+=this.tablerow({text:r});let s="";for(let a=0;a<n.rows.length;a++){const o=n.rows[a];r="";for(let i=0;i<o.length;i++)r+=this.tablecell(o[i]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
76
|
-
<thead>
|
|
77
|
-
`+e+`</thead>
|
|
78
|
-
`+s+`</table>
|
|
79
|
-
`}tablerow({text:n}){return`<tr>
|
|
80
|
-
${n}</tr>
|
|
81
|
-
`}tablecell(n){const e=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+`</${r}>
|
|
82
|
-
`}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>${yr(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),a=Ii(n);if(a===null)return s;n=a;let o='<a href="'+n+'"';return e&&(o+=' title="'+yr(e)+'"'),o+=">"+s+"</a>",o}image({href:n,title:e,text:r,tokens:s}){s&&(r=this.parser.parseInline(s,this.parser.textRenderer));const a=Ii(n);if(a===null)return yr(r);n=a;let o=`<img src="${n}" alt="${r}"`;return e&&(o+=` title="${yr(e)}"`),o+=">",o}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:yr(n.text)}},Wo=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""}},Er=class so{options;renderer;textRenderer;constructor(e){this.options=e||Kr,this.options.renderer=this.options.renderer||new ra,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Wo}static parse(e,r){return new so(r).parse(e)}static parseInline(e,r){return new so(r).parseInline(e)}parse(e,r=!0){let s="";for(let a=0;a<e.length;a++){const o=e[a];if(this.options.extensions?.renderers?.[o.type]){const d=o,m=this.options.extensions.renderers[d.type].call({parser:this},d);if(m!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(d.type)){s+=m||"";continue}}const i=o;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 d=i,m=this.renderer.text(d);for(;a+1<e.length&&e[a+1].type==="text";)d=e[++a],m+=`
|
|
83
|
-
`+this.renderer.text(d);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 d='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return s}parseInline(e,r=this.renderer){let s="";for(let a=0;a<e.length;a++){const o=e[a];if(this.options.extensions?.renderers?.[o.type]){const d=this.options.extensions.renderers[o.type].call({parser:this},o);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=d||"";continue}}const i=o;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 d='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return s}},Ys=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?Ir.lex:Ir.lexInline}provideParser(){return this.block?Er.parse:Er.parseInline}},Zp=class{defaults=Po();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Er;Renderer=ra;TextRenderer=Wo;Lexer=Ir;Tokenizer=na;Hooks=Ys;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 a=s;for(const o of a.header)r=r.concat(this.walkTokens(o.tokens,e));for(const o of a.rows)for(const i of o)r=r.concat(this.walkTokens(i.tokens,e));break}case"list":{const a=s;r=r.concat(this.walkTokens(a.items,e));break}default:{const a=s;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(o=>{const i=a[o].flat(1/0);r=r.concat(this.walkTokens(i,e))}):a.tokens&&(r=r.concat(this.walkTokens(a.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(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const o=e.renderers[a.name];o?e.renderers[a.name]=function(...i){let d=a.renderer.apply(this,i);return d===!1&&(d=o.apply(this,i)),d}:e.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=e[a.level];o?o.unshift(a.tokenizer):e[a.level]=[a.tokenizer],a.start&&(a.level==="block"?e.startBlock?e.startBlock.push(a.start):e.startBlock=[a.start]:a.level==="inline"&&(e.startInline?e.startInline.push(a.start):e.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(e.childTokens[a.name]=a.childTokens)}),s.extensions=e),r.renderer){const a=this.defaults.renderer||new ra(this.defaults);for(const o in r.renderer){if(!(o in a))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;const i=o,d=r.renderer[i],m=a[i];a[i]=(...v)=>{let g=d.apply(a,v);return g===!1&&(g=m.apply(a,v)),g||""}}s.renderer=a}if(r.tokenizer){const a=this.defaults.tokenizer||new na(this.defaults);for(const o in r.tokenizer){if(!(o in a))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const i=o,d=r.tokenizer[i],m=a[i];a[i]=(...v)=>{let g=d.apply(a,v);return g===!1&&(g=m.apply(a,v)),g}}s.tokenizer=a}if(r.hooks){const a=this.defaults.hooks||new Ys;for(const o in r.hooks){if(!(o in a))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;const i=o,d=r.hooks[i],m=a[i];Ys.passThroughHooks.has(o)?a[i]=v=>{if(this.defaults.async)return Promise.resolve(d.call(a,v)).then(x=>m.call(a,x));const g=d.call(a,v);return m.call(a,g)}:a[i]=(...v)=>{let g=d.apply(a,v);return g===!1&&(g=m.apply(a,v)),g}}s.hooks=a}if(r.walkTokens){const a=this.defaults.walkTokens,o=r.walkTokens;s.walkTokens=function(i){let d=[];return d.push(o.call(this,i)),a&&(d=d.concat(a.call(this,i))),d}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return Ir.lex(n,e??this.defaults)}parser(n,e){return Er.parse(n,e??this.defaults)}parseMarkdown(n){return(r,s)=>{const a={...s},o={...this.defaults,...a},i=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&a.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"));o.hooks&&(o.hooks.options=o,o.hooks.block=n);const d=o.hooks?o.hooks.provideLexer():n?Ir.lex:Ir.lexInline,m=o.hooks?o.hooks.provideParser():n?Er.parse:Er.parseInline;if(o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(v=>d(v,o)).then(v=>o.hooks?o.hooks.processAllTokens(v):v).then(v=>o.walkTokens?Promise.all(this.walkTokens(v,o.walkTokens)).then(()=>v):v).then(v=>m(v,o)).then(v=>o.hooks?o.hooks.postprocess(v):v).catch(i);try{o.hooks&&(r=o.hooks.preprocess(r));let v=d(r,o);o.hooks&&(v=o.hooks.processAllTokens(v)),o.walkTokens&&this.walkTokens(v,o.walkTokens);let g=m(v,o);return o.hooks&&(g=o.hooks.postprocess(g)),g}catch(v){return i(v)}}}onError(n,e){return r=>{if(r.message+=`
|
|
84
|
-
Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+yr(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},qr=new Zp;function tn(n,e){return qr.parse(n,e)}tn.options=tn.setOptions=function(n){return qr.setOptions(n),tn.defaults=qr.defaults,Ic(tn.defaults),tn};tn.getDefaults=Po;tn.defaults=Kr;tn.use=function(...n){return qr.use(...n),tn.defaults=qr.defaults,Ic(tn.defaults),tn};tn.walkTokens=function(n,e){return qr.walkTokens(n,e)};tn.parseInline=qr.parseInline;tn.Parser=Er;tn.parser=Er.parse;tn.Renderer=ra;tn.TextRenderer=Wo;tn.Lexer=Ir;tn.lexer=Ir.lex;tn.Tokenizer=na;tn.Hooks=Ys;tn.parse=tn;tn.options;tn.setOptions;tn.use;tn.walkTokens;tn.parseInline;Er.parse;Ir.lex;function Oi(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 Jp(n){if(Array.isArray(n))return n}function Qp(n,e){var r=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var s,a,o,i,d=[],m=!0,v=!1;try{if(o=(r=r.call(n)).next,e!==0)for(;!(m=(s=o.call(r)).done)&&(d.push(s.value),d.length!==e);m=!0);}catch(g){v=!0,a=g}finally{try{if(!m&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(v)throw a}}return d}}function eh(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
85
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function th(n,e){return Jp(n)||Qp(n,e)||nh(n,e)||eh()}function nh(n,e){if(n){if(typeof n=="string")return Oi(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)?Oi(n,e):void 0}}const zc=Object.entries,$i=Object.setPrototypeOf,rh=Object.isFrozen,sh=Object.getPrototypeOf,ah=Object.getOwnPropertyDescriptor;let Wn=Object.freeze,Gn=Object.seal,es=Object.create,Bc=typeof Reflect<"u"&&Reflect,ao=Bc.apply,oo=Bc.construct;Wn||(Wn=function(e){return e});Gn||(Gn=function(e){return e});ao||(ao=function(e,r){for(var s=arguments.length,a=new Array(s>2?s-2:0),o=2;o<s;o++)a[o-2]=arguments[o];return e.apply(r,a)});oo||(oo=function(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return new e(...s)});const bs=Dn(Array.prototype.forEach),oh=Dn(Array.prototype.lastIndexOf),Li=Dn(Array.prototype.pop),Jr=Dn(Array.prototype.push),ih=Dn(Array.prototype.splice),Dr=Array.isArray,xs=Dn(String.prototype.toLowerCase),La=Dn(String.prototype.toString),Di=Dn(String.prototype.match),vs=Dn(String.prototype.replace),Pi=Dn(String.prototype.indexOf),lh=Dn(String.prototype.trim),ch=Dn(Number.prototype.toString),dh=Dn(Boolean.prototype.toString),Ni=typeof BigInt>"u"?null:Dn(BigInt.prototype.toString),Fi=typeof Symbol>"u"?null:Dn(Symbol.prototype.toString),Un=Dn(Object.prototype.hasOwnProperty),gs=Dn(Object.prototype.toString),Hn=Dn(RegExp.prototype.test),Wr=uh(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),a=1;a<r;a++)s[a-1]=arguments[a];return ao(n,e,s)}}function uh(n){return function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return oo(n,r)}}function Ht(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xs;if($i&&$i(n,null),!Dr(e))return n;let s=e.length;for(;s--;){let a=e[s];if(typeof a=="string"){const o=r(a);o!==a&&(rh(e)||(e[s]=o),a=o)}n[a]=!0}return n}function fh(n){for(let e=0;e<n.length;e++)Un(n,e)||(n[e]=null);return n}function Zn(n){const e=es(null);for(const s of zc(n)){var r=th(s,2);const a=r[0],o=r[1];Un(n,a)&&(Dr(o)?e[a]=fh(o):o&&typeof o=="object"&&o.constructor===Object?e[a]=Zn(o):e[a]=o)}return e}function ph(n){switch(typeof n){case"string":return n;case"number":return ch(n);case"boolean":return dh(n);case"bigint":return Ni?Ni(n):"0";case"symbol":return Fi?Fi(n):"Symbol()";case"undefined":return gs(n);case"function":case"object":{if(n===null)return gs(n);const e=n,r=_r(e,"toString");if(typeof r=="function"){const s=r(e);return typeof s=="string"?s:gs(s)}return gs(n)}default:return gs(n)}}function _r(n,e){for(;n!==null;){const s=ah(n,e);if(s){if(s.get)return Dn(s.get);if(typeof s.value=="function")return Dn(s.value)}n=sh(n)}function r(){return null}return r}function hh(n){try{return Hn(n,""),!0}catch{return!1}}const Ui=Wn(["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"]),Da=Wn(["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"]),Pa=Wn(["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"]),bh=Wn(["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"]),Na=Wn(["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"]),vh=Wn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zi=Wn(["#text"]),Bi=Wn(["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"]),Fa=Wn(["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"]),ji=Wn(["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"]),Bs=Wn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),gh=Gn(/{{[\w\W]*|^[\w\W]*}}/g),mh=Gn(/<%[\w\W]*|^[\w\W]*%>/g),xh=Gn(/\${[\w\W]*/g),yh=Gn(/^data-[\-\w.\u00B7-\uFFFF]+$/),_h=Gn(/^aria-[\-\w]+$/),Hi=Gn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),wh=Gn(/^(?:\w+script|data):/i),Sh=Gn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),kh=Gn(/^html$/i),Th=Gn(/^[a-z][.\w]*(-[.\w]+)+$/i),Wi=Gn(/<[/\w!]/g),Ah=Gn(/<[/\w]/g),Ch=Gn(/<\/no(script|embed|frames)/i),Rh=Gn(/\/>/i),xr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ih=function(){return typeof window>"u"?null:window},Eh=function(e,r){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const a="data-tt-policy-suffix";r&&r.hasAttribute(a)&&(s=r.getAttribute(a));const o="dompurify"+(s?"#"+s:"");try{return e.createPolicy(o,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Gi=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Or=function(e,r,s,a){return Un(e,r)&&Dr(e[r])?Ht(a.base?Zn(a.base):{},e[r],a.transform):s};function jc(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ih();const e=I=>jc(I);if(e.version="3.4.11",e.removed=[],!n||!n.document||n.document.nodeType!==xr.document||!n.Element)return e.isSupported=!1,e;let r=n.document;const s=r,a=s.currentScript;n.DocumentFragment;const o=n.HTMLTemplateElement,i=n.Node,d=n.Element,m=n.NodeFilter,v=n.NamedNodeMap;v===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const g=n.DOMParser,x=n.trustedTypes,y=d.prototype,D=_r(y,"cloneNode"),P=_r(y,"remove"),re=_r(y,"nextSibling"),U=_r(y,"childNodes"),B=_r(y,"parentNode"),W=_r(y,"shadowRoot"),ze=_r(y,"attributes"),X=i&&i.prototype?_r(i.prototype,"nodeType"):null,G=i&&i.prototype?_r(i.prototype,"nodeName"):null;if(typeof o=="function"){const I=r.createElement("template");I.content&&I.content.ownerDocument&&(r=I.content.ownerDocument)}let Y,Ce="",he,Ae=!1,te=0;const Ne=function(){if(te>0)throw Wr('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.')},He=function(l){Ne(),te++;try{return Y.createHTML(l)}finally{te--}},Ke=function(l){Ne(),te++;try{return Y.createScriptURL(l)}finally{te--}},Je=function(){return Ae||(he=Eh(x,a),Ae=!0),he},Be=r,Qe=Be.implementation,ut=Be.createNodeIterator,Ot=Be.createDocumentFragment,Tt=Be.getElementsByTagName,xt=s.importNode;let Re=Gi();e.isSupported=typeof zc=="function"&&typeof B=="function"&&Qe&&Qe.createHTMLDocument!==void 0;const Wt=gh,ve=mh,$t=xh,It=yh,At=_h,oe=wh,q=Sh,tt=Th;let ge=Hi,le=null;const et=Ht({},[...Ui,...Da,...Pa,...Na,...zi]);let ee=null;const K=Ht({},[...Bi,...Fa,...ji,...Bs]);let we=Object.seal(es(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}})),R=null,se=null;const J=Object.seal(es(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Se=!0,Le=!0,nt=!1,ce=!0,Ve=!1,at=!0,wt=!1,Et=!1,Lt=null,Ft=null,Xt=!1,zt=!1,Sn=!1,mn=!1,qt=!0,Kt=!1;const dn="user-content-";let kn=!0,En=!1,pt={},Ct=null;const _n=Ht({},["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 Cn=null;const wn=Ht({},["audio","video","img","source","image","track"]);let Nn=null;const xn=Ht({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),vn="http://www.w3.org/1998/Math/MathML",Fn="http://www.w3.org/2000/svg",Vt="http://www.w3.org/1999/xhtml";let qn=Vt,j=!1,ie=null;const Ie=Ht({},[vn,Fn,Vt],La),De=Wn(["mi","mo","mn","ms","mtext"]);let S=Ht({},De);const V=Wn(["annotation-xml"]);let be=Ht({},V);const Oe=Ht({},["title","style","font","a","script"]);let rt=null;const je=["application/xhtml+xml","text/html"],_e="text/html";let me=null,Zt=null;const nn=r.createElement("form"),Bt=function(l){return l instanceof RegExp||l instanceof Function},un=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Zt&&Zt===l)return;(!l||typeof l!="object")&&(l={}),l=Zn(l),rt=je.indexOf(l.PARSER_MEDIA_TYPE)===-1?_e:l.PARSER_MEDIA_TYPE,me=rt==="application/xhtml+xml"?La:xs,le=Or(l,"ALLOWED_TAGS",et,{transform:me}),ee=Or(l,"ALLOWED_ATTR",K,{transform:me}),ie=Or(l,"ALLOWED_NAMESPACES",Ie,{transform:La}),Nn=Or(l,"ADD_URI_SAFE_ATTR",xn,{transform:me,base:xn}),Cn=Or(l,"ADD_DATA_URI_TAGS",wn,{transform:me,base:wn}),Ct=Or(l,"FORBID_CONTENTS",_n,{transform:me}),R=Or(l,"FORBID_TAGS",Zn({}),{transform:me}),se=Or(l,"FORBID_ATTR",Zn({}),{transform:me}),pt=Un(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?Zn(l.USE_PROFILES):l.USE_PROFILES:!1,Se=l.ALLOW_ARIA_ATTR!==!1,Le=l.ALLOW_DATA_ATTR!==!1,nt=l.ALLOW_UNKNOWN_PROTOCOLS||!1,ce=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ve=l.SAFE_FOR_TEMPLATES||!1,at=l.SAFE_FOR_XML!==!1,wt=l.WHOLE_DOCUMENT||!1,zt=l.RETURN_DOM||!1,Sn=l.RETURN_DOM_FRAGMENT||!1,mn=l.RETURN_TRUSTED_TYPE||!1,Xt=l.FORCE_BODY||!1,qt=l.SANITIZE_DOM!==!1,Kt=l.SANITIZE_NAMED_PROPS||!1,kn=l.KEEP_CONTENT!==!1,En=l.IN_PLACE||!1,ge=hh(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:Hi,qn=typeof l.NAMESPACE=="string"?l.NAMESPACE:Vt,S=Un(l,"MATHML_TEXT_INTEGRATION_POINTS")&&l.MATHML_TEXT_INTEGRATION_POINTS&&typeof l.MATHML_TEXT_INTEGRATION_POINTS=="object"?Zn(l.MATHML_TEXT_INTEGRATION_POINTS):Ht({},De),be=Un(l,"HTML_INTEGRATION_POINTS")&&l.HTML_INTEGRATION_POINTS&&typeof l.HTML_INTEGRATION_POINTS=="object"?Zn(l.HTML_INTEGRATION_POINTS):Ht({},V);const _=Un(l,"CUSTOM_ELEMENT_HANDLING")&&l.CUSTOM_ELEMENT_HANDLING&&typeof l.CUSTOM_ELEMENT_HANDLING=="object"?Zn(l.CUSTOM_ELEMENT_HANDLING):es(null);if(we=es(null),Un(_,"tagNameCheck")&&Bt(_.tagNameCheck)&&(we.tagNameCheck=_.tagNameCheck),Un(_,"attributeNameCheck")&&Bt(_.attributeNameCheck)&&(we.attributeNameCheck=_.attributeNameCheck),Un(_,"allowCustomizedBuiltInElements")&&typeof _.allowCustomizedBuiltInElements=="boolean"&&(we.allowCustomizedBuiltInElements=_.allowCustomizedBuiltInElements),Gn(we),Ve&&(Le=!1),Sn&&(zt=!0),pt&&(le=Ht({},zi),ee=es(null),pt.html===!0&&(Ht(le,Ui),Ht(ee,Bi)),pt.svg===!0&&(Ht(le,Da),Ht(ee,Fa),Ht(ee,Bs)),pt.svgFilters===!0&&(Ht(le,Pa),Ht(ee,Fa),Ht(ee,Bs)),pt.mathMl===!0&&(Ht(le,Na),Ht(ee,ji),Ht(ee,Bs))),J.tagCheck=null,J.attributeCheck=null,Un(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?J.tagCheck=l.ADD_TAGS:Dr(l.ADD_TAGS)&&(le===et&&(le=Zn(le)),Ht(le,l.ADD_TAGS,me))),Un(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?J.attributeCheck=l.ADD_ATTR:Dr(l.ADD_ATTR)&&(ee===K&&(ee=Zn(ee)),Ht(ee,l.ADD_ATTR,me))),Un(l,"ADD_URI_SAFE_ATTR")&&Dr(l.ADD_URI_SAFE_ATTR)&&Ht(Nn,l.ADD_URI_SAFE_ATTR,me),Un(l,"FORBID_CONTENTS")&&Dr(l.FORBID_CONTENTS)&&(Ct===_n&&(Ct=Zn(Ct)),Ht(Ct,l.FORBID_CONTENTS,me)),Un(l,"ADD_FORBID_CONTENTS")&&Dr(l.ADD_FORBID_CONTENTS)&&(Ct===_n&&(Ct=Zn(Ct)),Ht(Ct,l.ADD_FORBID_CONTENTS,me)),kn&&(le["#text"]=!0),wt&&Ht(le,["html","head","body"]),le.table&&(Ht(le,["tbody"]),delete R.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw Wr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Wr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const A=Y;Y=l.TRUSTED_TYPES_POLICY;try{Ce=He("")}catch(N){throw Y=A,N}}else l.TRUSTED_TYPES_POLICY===null?(Y=void 0,Ce=""):(Y===void 0&&(Y=Je()),Y&&typeof Ce=="string"&&(Ce=He("")));Wn&&Wn(l),Zt=l},rn=Ht({},[...Da,...Pa,...bh]),Rt=Ht({},[...Na,...vh]),yt=function(l,_,A){return _.namespaceURI===Vt?l==="svg":_.namespaceURI===vn?l==="svg"&&(A==="annotation-xml"||S[A]):!!rn[l]},hn=function(l,_,A){return _.namespaceURI===Vt?l==="math":_.namespaceURI===Fn?l==="math"&&be[A]:!!Rt[l]},ht=function(l,_,A){return _.namespaceURI===Fn&&!be[A]||_.namespaceURI===vn&&!S[A]?!1:!Rt[l]&&(Oe[l]||!rn[l])},ft=function(l){let _=B(l);(!_||!_.tagName)&&(_={namespaceURI:qn,tagName:"template"});const A=xs(l.tagName),N=xs(_.tagName);return ie[l.namespaceURI]?l.namespaceURI===Fn?yt(A,_,N):l.namespaceURI===vn?hn(A,_,N):l.namespaceURI===Vt?ht(A,_,N):!!(rt==="application/xhtml+xml"&&ie[l.namespaceURI]):!1},Dt=function(l){Jr(e.removed,{element:l});try{B(l).removeChild(l)}catch{if(P(l),!B(l))throw Wr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ln=function(l){const _=U(l);if(_){const N=[];bs(_,de=>{Jr(N,de)}),bs(N,de=>{try{P(de)}catch{}})}const A=ze(l);if(A)for(let N=A.length-1;N>=0;--N){const de=A[N],Te=de&&de.name;if(typeof Te=="string")try{l.removeAttribute(Te)}catch{}}},bn=function(l,_){try{Jr(e.removed,{attribute:_.getAttributeNode(l),from:_})}catch{Jr(e.removed,{attribute:null,from:_})}if(_.removeAttribute(l),l==="is")if(zt||Sn)try{Dt(_)}catch{}else try{_.setAttribute(l,"")}catch{}},xe=function(l){const _=ze(l);if(_)for(let A=_.length-1;A>=0;--A){const N=_[A],de=N&&N.name;if(!(typeof de!="string"||ee[me(de)]))try{l.removeAttribute(de)}catch{}}},qe=function(l){const _=[l];for(;_.length>0;){const A=_.pop();(X?X(A):A.nodeType)===xr.element&&xe(A);const de=U(A);if(de)for(let Te=de.length-1;Te>=0;--Te)_.push(de[Te])}},bt=function(l){let _=null,A=null;if(Xt)l="<remove></remove>"+l;else{const Te=Di(l,/^[\r\n\t ]+/);A=Te&&Te[0]}rt==="application/xhtml+xml"&&qn===Vt&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");const N=Y?He(l):l;if(qn===Vt)try{_=new g().parseFromString(N,rt)}catch{}if(!_||!_.documentElement){_=Qe.createDocument(qn,"template",null);try{_.documentElement.innerHTML=j?Ce:N}catch{}}const de=_.body||_.documentElement;return l&&A&&de.insertBefore(r.createTextNode(A),de.childNodes[0]||null),qn===Vt?Tt.call(_,wt?"html":"body")[0]:wt?_.documentElement:de},ke=function(l){return ut.call(l.ownerDocument||l,l,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},st=function(l){return l=vs(l,Wt," "),l=vs(l,ve," "),l=vs(l,$t," "),l},sn=function(l){var _;l.normalize();const A=ut.call(l.ownerDocument||l,l,m.SHOW_TEXT|m.SHOW_COMMENT|m.SHOW_CDATA_SECTION|m.SHOW_PROCESSING_INSTRUCTION,null);let N=A.nextNode();for(;N;)N.data=st(N.data),N=A.nextNode();const de=(_=l.querySelectorAll)===null||_===void 0?void 0:_.call(l,"template");de&&bs(de,Te=>{yn(Te.content)&&sn(Te.content)})},Jt=function(l){const _=G?G(l):null;return typeof _!="string"||me(_)!=="form"?!1:typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||l.attributes!==ze(l)||typeof l.removeAttribute!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function"||l.nodeType!==X(l)||l.childNodes!==U(l)},yn=function(l){if(!X||typeof l!="object"||l===null)return!1;try{return X(l)===xr.documentFragment}catch{return!1}},jt=function(l){if(!X||typeof l!="object"||l===null)return!1;try{return typeof X(l)=="number"}catch{return!1}};function an(I,l,_){I.length!==0&&bs(I,A=>{A.call(e,l,_,Zt)})}const Pn=function(l,_){return!!(at&&l.hasChildNodes()&&!jt(l.firstElementChild)&&Hn(Wi,l.textContent)&&Hn(Wi,l.innerHTML)||at&&l.namespaceURI===Vt&&_==="style"&&jt(l.firstElementChild)||l.nodeType===xr.processingInstruction||at&&l.nodeType===xr.comment&&Hn(Ah,l.data))},$e=function(l,_){if(!R[_]&&pe(_)&&(we.tagNameCheck instanceof RegExp&&Hn(we.tagNameCheck,_)||we.tagNameCheck instanceof Function&&we.tagNameCheck(_)))return!1;if(kn&&!Ct[_]){const A=B(l),N=U(l);if(N&&A){const de=N.length;for(let Te=de-1;Te>=0;--Te){const gt=En?N[Te]:D(N[Te],!0);A.insertBefore(gt,re(l))}}}return Dt(l),!0},C=function(l){if(an(Re.beforeSanitizeElements,l,null),Jt(l))return Dt(l),!0;const _=me(G?G(l):l.nodeName);if(an(Re.uponSanitizeElement,l,{tagName:_,allowedTags:le}),Pn(l,_))return Dt(l),!0;if(R[_]||!(J.tagCheck instanceof Function&&J.tagCheck(_))&&!le[_])return $e(l,_);if((X?X(l):l.nodeType)===xr.element&&!ft(l)||(_==="noscript"||_==="noembed"||_==="noframes")&&Hn(Ch,l.innerHTML))return Dt(l),!0;if(Ve&&l.nodeType===xr.text){const N=st(l.textContent);l.textContent!==N&&(Jr(e.removed,{element:l.cloneNode()}),l.textContent=N)}return an(Re.afterSanitizeElements,l,null),!1},O=function(l,_,A){if(se[_]||qt&&(_==="id"||_==="name")&&(A in r||A in nn))return!1;const N=ee[_]||J.attributeCheck instanceof Function&&J.attributeCheck(_,l);if(!(Le&&Hn(It,_))){if(!(Se&&Hn(At,_))){if(N){if(!Nn[_]){if(!Hn(ge,vs(A,q,""))){if(!((_==="src"||_==="xlink:href"||_==="href")&&l!=="script"&&Pi(A,"data:")===0&&Cn[l])){if(!(nt&&!Hn(oe,vs(A,q,"")))){if(A)return!1}}}}}else if(!(pe(l)&&(we.tagNameCheck instanceof RegExp&&Hn(we.tagNameCheck,l)||we.tagNameCheck instanceof Function&&we.tagNameCheck(l))&&(we.attributeNameCheck instanceof RegExp&&Hn(we.attributeNameCheck,_)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(_,l))||_==="is"&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&Hn(we.tagNameCheck,A)||we.tagNameCheck instanceof Function&&we.tagNameCheck(A))))return!1}}return!0},Q=Ht({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),pe=function(l){return!Q[xs(l)]&&Hn(tt,l)},k=function(l,_,A,N){if(Y&&typeof x=="object"&&typeof x.getAttributeType=="function"&&!A)switch(x.getAttributeType(l,_)){case"TrustedHTML":return He(N);case"TrustedScriptURL":return Ke(N)}return N},$=function(l,_,A,N){try{A?l.setAttributeNS(A,_,N):l.setAttribute(_,N),Jt(l)?Dt(l):Li(e.removed)}catch{bn(_,l)}},z=function(l){an(Re.beforeSanitizeAttributes,l,null);const _=l.attributes;if(!_||Jt(l))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let N=_.length;const de=me(l.nodeName);for(;N--;){const Te=_[N],gt=Te.name,ot=Te.namespaceURI,Pe=Te.value,ct=me(gt),it=Pe;let We=gt==="value"?it:lh(it);if(A.attrName=ct,A.attrValue=We,A.keepAttr=!0,A.forceKeepAttr=void 0,an(Re.uponSanitizeAttribute,l,A),We=A.attrValue,Kt&&(ct==="id"||ct==="name")&&Pi(We,dn)!==0&&(bn(gt,l),We=dn+We),at&&Hn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,We)){bn(gt,l);continue}if(ct==="attributename"&&Di(We,"href")){bn(gt,l);continue}if(!A.forceKeepAttr){if(!A.keepAttr){bn(gt,l);continue}if(!ce&&Hn(Rh,We)){bn(gt,l);continue}if(Ve&&(We=st(We)),!O(de,ct,We)){bn(gt,l);continue}We=k(de,ct,ot,We),We!==it&&$(l,gt,ot,We)}}an(Re.afterSanitizeAttributes,l,null)},ne=function(l){let _=null;const A=ke(l);for(an(Re.beforeSanitizeShadowDOM,l,null);_=A.nextNode();)if(an(Re.uponSanitizeShadowNode,_,null),C(_),z(_),yn(_.content)&&ne(_.content),(X?X(_):_.nodeType)===xr.element){const de=W(_);yn(de)&&(fe(de),ne(de))}an(Re.afterSanitizeShadowDOM,l,null)},fe=function(l){const _=[{node:l,shadow:null}];for(;_.length>0;){const A=_.pop();if(A.shadow){ne(A.shadow);continue}const N=A.node,Te=(X?X(N):N.nodeType)===xr.element,gt=U(N);if(gt)for(let ot=gt.length-1;ot>=0;--ot)_.push({node:gt[ot],shadow:null});if(Te){const ot=G?G(N):null;if(typeof ot=="string"&&me(ot)==="template"){const Pe=N.content;yn(Pe)&&_.push({node:Pe,shadow:null})}}if(Te){const ot=W(N);yn(ot)&&_.push({node:null,shadow:ot},{node:ot,shadow:null})}}};return e.sanitize=function(I){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,A=null,N=null,de=null;if(j=!I,j&&(I="<!-->"),typeof I!="string"&&!jt(I)&&(I=ph(I),typeof I!="string"))throw Wr("dirty is not a string, aborting");if(!e.isSupported)return I;Et?(le=Lt,ee=Ft):un(l),(Re.uponSanitizeElement.length>0||Re.uponSanitizeAttribute.length>0)&&(le=Zn(le)),Re.uponSanitizeAttribute.length>0&&(ee=Zn(ee)),e.removed=[];const Te=En&&typeof I!="string"&&jt(I);if(Te){const Pe=G?G(I):I.nodeName;if(typeof Pe=="string"){const ct=me(Pe);if(!le[ct]||R[ct])throw Wr("root node is forbidden and cannot be sanitized in-place")}if(Jt(I))throw Wr("root node is clobbered and cannot be sanitized in-place");try{fe(I)}catch(ct){throw ln(I),ct}}else if(jt(I))_=bt("<!---->"),A=_.ownerDocument.importNode(I,!0),A.nodeType===xr.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?_=A:_.appendChild(A),fe(A);else{if(!zt&&!Ve&&!wt&&I.indexOf("<")===-1)return Y&&mn?He(I):I;if(_=bt(I),!_)return zt?null:mn?Ce:""}_&&Xt&&Dt(_.firstChild);const gt=ke(Te?I:_);try{for(;N=gt.nextNode();)C(N),z(N),yn(N.content)&&ne(N.content)}catch(Pe){throw Te&&ln(I),Pe}if(Te)return bs(e.removed,Pe=>{Pe.element&&qe(Pe.element)}),Ve&&sn(I),I;if(zt){if(Ve&&sn(_),Sn)for(de=Ot.call(_.ownerDocument);_.firstChild;)de.appendChild(_.firstChild);else de=_;return(ee.shadowroot||ee.shadowrootmode)&&(de=xt.call(s,de,!0)),de}let ot=wt?_.outerHTML:_.innerHTML;return wt&&le["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&Hn(kh,_.ownerDocument.doctype.name)&&(ot="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
|
|
86
|
-
`+ot),Ve&&(ot=st(ot)),Y&&mn?He(ot):ot},e.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};un(I),Et=!0,Lt=le,Ft=ee},e.clearConfig=function(){Zt=null,Et=!1,Lt=null,Ft=null,Y=he,Ce=""},e.isValidAttribute=function(I,l,_){Zt||un({});const A=me(I),N=me(l);return O(A,N,_)},e.addHook=function(I,l){typeof l=="function"&&Un(Re,I)&&Jr(Re[I],l)},e.removeHook=function(I,l){if(Un(Re,I)){if(l!==void 0){const _=oh(Re[I],l);return _===-1?void 0:ih(Re[I],_,1)[0]}return Li(Re[I])}},e.removeHooks=function(I){Un(Re,I)&&(Re[I]=[])},e.removeAllHooks=function(){Re=Gi()},e}var Go=jc();tn.setOptions({gfm:!0,breaks:!0});const qi=80;function Rr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Mh={code(n){const{text:e,lang:r}=n,s=(r??"").trim().split(/\s+/)[0]??"",o=e.split(`
|
|
87
|
-
`).filter(x=>x.trim()!==""),i=o.length>1,d=`<pre><code>${Rr(e)}</code></pre>`;if(!i)return d;let v=o[0]??"";return v.length>qi?v=v.slice(0,qi)+"…":o.length>1&&(v+=" …"),`<details class="code-collapsible"><summary>${s?`<span class="code-lang">${Rr(s)}</span> ${Rr(v)}`:Rr(v)}</summary>${d}</details>`}};tn.use({renderer:Mh});let Ki=!1;function Hc(){Ki||typeof window>"u"||(Ki=!0,Go.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))}))}function Oh(n){if(!n)return"";const e=tn.parse(n,{async:!1});return typeof window>"u"?"":(Hc(),Go.sanitize(e,{ADD_ATTR:["target","rel"],ADD_TAGS:["details","summary"]}))}const $h=/\b(https?:\/\/[^\s<]+|www\.[^\s<]+)/gi;function Lh(n){if(!n||typeof window>"u")return"";let e="",r=0;for(const s of n.matchAll($h)){const a=s.index??0;e+=Rr(n.slice(r,a));let o=s[0],i="";const d=o.match(/[.,;:!?)\]}'"]+$/);d&&(i=d[0],o=o.slice(0,o.length-i.length));const m=o.startsWith("www.")?`https://${o}`:o;e+=`<a href="${Rr(m)}">${Rr(o)}</a>`,e+=Rr(i),r=a+s[0].length}return e+=Rr(n.slice(r)),Hc(),Go.sanitize(e,{ADD_ATTR:["target","rel"]})}const Vi=new Map;function Dh(n,e){const r=`${n}:${e.length}`;let s=Vi.get(r);return s===void 0&&(s=Oh(e),Vi.set(r,s)),s}const Yi=new Map;function Ph(n){let e=Yi.get(n);return e===void 0&&(e=Lh(n),Yi.set(n,e)),e}function Nh(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 Fh(n){return new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Uh(n){if(!n)return{cleanContent:"",attachments:[],skill:null};const e=go(n);if(e)return{cleanContent:"",attachments:[],skill:e};const r=n.split(`
|
|
88
|
-
`),s=/^\[Uploaded file: (.+)\]$/,a=[],o=[];for(const d of r){const m=d.match(s);m?o.push(m[1]):a.push(d)}let i=a.join(`
|
|
89
|
-
`).trim();return i==="I have uploaded the following file(s) for you:"&&(i=""),{cleanContent:i,attachments:o,skill:null}}function zh(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 a;for(;(a=s.exec(e))!==null;){const o=a[1],i=a[2]!==void 0?a[2]:a[3]!==void 0?a[3]:a[4];r[o]=i}return Object.keys(r).length>0?r:null}function Bh(n,e,r){if(!e)return r?r.trim():"";const s=n.toLowerCase();if(["read","write","edit","ls"].includes(s)){const o=e.path||e.filepath||e.file;if(o)return String(o)}if(s==="bash"){const o=e.command||e.cmd;if(o){const i=String(o).replace(/\s+/g," ").trim();return i.length>50?i.slice(0,47)+"...":i}}if(s==="grep"){const o=e.pattern,i=e.path;if(o)return i?`"${o}" in ${i}`:`"${o}"`}if(s==="find"){const o=e.pattern||e.path;if(o)return String(o)}const a=e.path||e.filepath||e.file||e.name||e.query;return a?String(a):Object.entries(e).filter(([o,i])=>i!==void 0&&i!=="").map(([o,i])=>`${o}=${typeof i=="object"?JSON.stringify(i):i}`).join(" ")}function jh(n,e){return n?JSON.stringify(n,null,2):e?e.trim():""}function io(n){return n==="attach_file"||n==="say"}function sa(n){return n.role==="tool"&&n.forceCommand===!0}function Hh(n,e){return sa(n)}function Xi(n){let e=n.toolName||"tool",r=n.toolArgs!==void 0?n.toolArgs:"",s=n.toolOutput!==void 0?n.toolOutput:"",a=!!n.isError;if(!r&&!s&&n.content){let m=n.content||"";m.startsWith("Error: ")?(a=!0,m=m.slice(7)):m.startsWith("Tool error: ")&&(a=!0,m=m.slice(12));const v=m.indexOf(`
|
|
90
|
-
`),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 y=x.indexOf(" ");e=n.toolName||(y!==-1?x.slice(0,y):x)||"tool",r=y!==-1?x.slice(y+1):""}const o=zh(r),i=Bh(e,o,r),d=jh(o,r);return{toolName:e,smartTitleArgs:i,fullArgs:d,toolOutput:s,isError:a,interrupted:!!n.interrupted,downloadPath:up(e,o,a),sayText:e==="say"?gf(o):null}}function js(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 Wh(n,e,r){const s=n.filter(o=>o.role==="thinking"&&e.hideThinking?!1:o.role==="tool"&&e.hideTools&&!io(o.toolName)?sa(o)||!!o.isStreaming:o.role!=="assistant"&&o.role!=="thinking"||o.isStreaming||o.content.trim()!==""),a=s.some(o=>o.isStreaming);if(r&&!a){const o=n.some(i=>i.role==="thinking"&&i.isStreaming);s.push({id:"fallback-loader-message-id",role:"thinking",content:o?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return s}function Zi(){return typeof localStorage>"u"?"":localStorage.getItem("wherever-speech-locale")||""}function Gh(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 Ji(n){return n.scrollHeight-n.scrollTop-n.clientHeight<=20}var qh=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>'),Kh=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>'),Vh=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
|
|
91
|
-
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>`),Yh=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>'),Xh=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>'),Zh=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>'),Jh=b('<span class="ml-1 font-medium text-emerald-400">(Git repo detected)</span>'),Qh=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>'),eb=b('<span class="mt-1 block text-[10px] text-brand-text-muted">Relative paths are created inside your home folder.</span>'),tb=b("<option> </option>"),nb=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>'),rb=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"/>'),sb=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>'),ab=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>'),ob=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>'),ib=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
|
|
92
|
-
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>`),lb=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>'),cb=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>'),db=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>'),ub=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>'),fb=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>'),pb=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>'),hb=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>'),bb=b('<div class="flex flex-col gap-1"><!> <div class="font-mono text-sm whitespace-pre-wrap"> </div></div>'),vb=b('<span class="font-mono text-xs text-brand-text-muted tabular-nums"> </span>'),gb=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>'),mb=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>'),xb=b('<span class="text-xs break-words text-brand-text-muted"> </span>'),yb=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>'),_b=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>'),wb=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>'),Sb=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>'),kb=b('<audio controls="" preload="metadata" class="mt-2 block w-full max-w-full"></audio>'),Tb=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),Ab=b('<div class="flex max-w-full min-w-[240px] flex-col"><!> <!> <!> <!></div>'),Cb=b('<span class="text-xs break-words text-brand-text-muted"> </span>'),Rb=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>'),Ib=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>'),Eb=b('<div class="flex max-w-full min-w-[240px] flex-col"><!></div>'),Mb=b('<span class="inline-block animate-spin font-bold text-amber-400">⚡</span>'),Ob=b('<span class="font-bold text-rose-400" title="Failed">❌</span>'),$b=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>'),Lb=b('<span class="font-bold text-emerald-400" title="Succeeded">✅</span>'),Db=b('<span class="max-w-[180px] truncate font-mono text-xs text-brand-text-muted sm:max-w-[300px] md:max-w-[450px]"> </span>'),Pb=b("<span> </span>"),Nb=b('Collapse <span class="text-[10px]">▲</span>',1),Fb=b('Expand <span class="text-[10px]">▼</span>',1),Ub=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>'),zb=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>'),Bb=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>'),jb=b('<audio controls="" preload="metadata" class="mt-2 block w-full max-w-full"></audio>'),Hb=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),Wb=b('<a target="_blank" rel="noopener noreferrer" class="block"><img alt="Tool output" loading="lazy" class="max-h-96 max-w-full rounded border border-brand-border/40 bg-brand-dark/60 object-contain"/></a>'),Gb=b('<div class="mt-2 flex flex-col gap-1"><div class="flex flex-wrap gap-2"></div></div>'),qb=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>'),Kb=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>'),Vb=b('<div class="animate-pulse p-1 text-xs text-brand-text-muted italic">Running and waiting for output...</div>'),Yb=b(`<div class="p-1 text-xs text-brand-text-muted italic">Interrupted before a result was returned (the
|
|
93
|
-
running tool was stopped, e.g. by a CLI takeover).
|
|
94
|
-
Its outcome is unknown.</div>`),Xb=b('<div class="p-1 text-xs text-brand-text-muted italic">No output returned</div>'),Zb=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>'),Jb=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>'),Qb=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>'),ev=b("<pre> </pre>"),tv=b("<div></div>"),nv=oa('<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),rv=oa('<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),sv=oa('<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),av=oa('<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),ov=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>'),iv=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>'),lv=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>'),cv=b('<div class="text-sm leading-relaxed wrap-anywhere whitespace-pre-wrap"> </div>'),dv=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>'),uv=b("<span></span>"),fv=b('<span class="text-brand-text-muted italic"> </span>'),pv=b('<span class="ml-1 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan"></span>'),hv=b('<div class="chat-selectable text-sm leading-relaxed wrap-anywhere whitespace-pre-wrap"><!> <!></div>'),bv=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>'),vv=b('<div class="mt-2 flex flex-col gap-1 border-t border-brand-blue/20 pt-2"></div>'),gv=b("<!> <!>",1),mv=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),xv=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>'),yv=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>'),_v=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>'),wv=b("<div><!> </div> <!> <!> <!>",1),Sv=b("<div><div><!> <!></div></div>"),kv=b('<div class="flex-1 space-y-4 overflow-y-auto overscroll-y-contain p-4"><!> <!></div>'),Tv=b('<button type="button" aria-label="Cycle waiting-for-human beep for this session"><span> </span> <span> </span></button>'),Av=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>'),Cv=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>'),Rv=b('<span class="ml-1 text-xs text-brand-text-muted">(already a Git repository)</span>'),Iv=b('<span class="ml-1 text-xs font-medium text-yellow-500">(folder not empty)</span>'),Ev=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>'),Mv=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>'),Ov=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>'),$v=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>'),Lv=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>'),Dv=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 Pv(n,e){nr(e,!0);const r=()=>ye(cn,"$piState",G),s=()=>ye(fo,"$availableModels",G),a=()=>ye(po,"$gitInitDefaultStore",G),o=()=>ye(is,"$activeSessionInfo",G),i=()=>ye($s,"$isLoadingSession",G),d=()=>ye(Ls,"$isResyncing",G),m=()=>ye(va,"$isReadOnly",G),v=()=>ye(yo,"$beepSessionOverride",G),g=()=>ye(_o,"$beepEnabled",G),x=()=>ye(ko,"$conversationMode",G),y=()=>ye(So,"$conversationModeSessionOverride",G),D=()=>ye(Ol,"$collapseLongReplies",G),P=()=>ye(cc,"$messages",G),re=()=>ye(Ml,"$speakReplies",G),U=()=>ye(Eo,"$isStreaming",G),B=()=>ye(ba,"$sessionError",G),W=()=>ye(mc,"$hasMoreHistory",G),ze=()=>ye(xc,"$isLoadingMoreHistory",G),X=()=>ye(pc,"$pendingSteering",G),[G,Y]=Nr(),Ce=[];let he=L(()=>{const k=r().contextUsage;if(!k||!k.contextWindow)return null;const $=Nh(k.contextWindow);return k.percent==null?`– / ${$}`:`${k.percent.toFixed(1)}% / ${$}`}),Ae=F(""),te=F(Yn([])),Ne=F(!1),He=F(null),Ke=F(null),Je="",Be=F(""),Qe=F(!1),ut=F(null),Ot=F(!0),Tt=F("private"),xt=F(!1),Re=F(!1),Wt=F(!1),ve=F(null);function $t(k){wr(t(Ae).trim(),t(Be)||void 0,k?!1:t(Qe),k?!1:t(q).matchingRule?t(Ot):void 0,k?void 0:t(q).matchingRule?t(Tt):void 0,k||void 0)}let It=L(r),At=L(s),oe=L(a);Nt(()=>{t(ut)===null&&p(Qe,t(oe),!0)});let q=F(Yn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),tt=L(()=>t(q).exists!==!0&&t(q).matchingRule&&t(Ot)),ge=null;async function le(k,$=!1){if(ge&&clearTimeout(ge),k===Je&&!$)return;if(Je=k,!k.trim()){p(q,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const ne=async()=>{const fe=await Zs("");p(te,fe||[],!0)};$?await ne():ge=setTimeout(ne,300);return}const z=async()=>{const[ne,fe]=await Promise.all([ol(k),Zs(k)]);p(te,fe||[],!0),ne?(p(q,{exists:ne.exists,isGit:ne.isGit,resolvedPath:ne.resolvedPath,matchingRule:ne.matchingRule||null},!0),ne.exists||(p(Qe,t(ut)!==null?t(ut):t(oe),!0),p(Ot,!0),ne.matchingRule&&p(Tt,ne.matchingRule.visibility,!0))):p(q,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};$?await z():ge=setTimeout(z,300)}Nt(()=>{const k=t(Ae);le(k,!1)}),Nt(()=>{if(t(At).models.length>0&&!t(Be)){const k=t(At).models.find($=>$.isDefault);k?p(Be,`${k.provider}:${k.modelId}`):p(Be,`${t(At).models[0].provider}:${t(At).models[0].modelId}`)}});async function et(){if(t(Ae).trim()){if(t(q).exists===!0){p(Qe,!1),p(Ot,!1),t(q).matchingRule&&p(Tt,t(q).matchingRule.visibility,!0),p(xt,!0);return}if(t(q).matchingRule&&t(Ot)){p(Wt,!0);try{const k=await Cd(t(Ae).trim());if(k&&k.matched&&k.exists){p(ve,{provider:k.provider,sshUrl:k.sshUrl},!0),p(Re,!0);return}}finally{p(Wt,!1)}}$t(!1)}}let ee=F(void 0),K=L(o),we=L(i),R=L(d),se=L(m);function J(k){if(!k)return;const $=t(K).sessionId;$&&Xl($,k)}let Se=L(v),Le=L(g),nt=L(x),ce=L(()=>y()===void 0);function Ve(){ga(),Nl(!t(nt))}let at=L(()=>ns("collapseLongReplies",{conversationMode:x(),autoSendOnSpeechEnd:!1,speakReplies:!1,collapseLongReplies:D(),micReopensAfterReply:!1}));const wt=new Set;let Et=!1;Nt(()=>{const k=P();re();for(const $ of k){if($.role!=="tool"||$.toolName!=="say"||$.isStreaming||wt.has($.id)||(wt.add($.id),$.isError)||!ns("speakReplies",ss()))continue;const z=Xi($);z.sayText&&(Et=!0,Ti(z.sayText,Zi()))}}),Nt(()=>{x(),re(),ns("speakReplies",ss())&&wf()});let Lt=!1;const Ft=new Set;Nt(()=>{const k=P(),$=U();if(re(),$&&!Lt)Et=!1;else if(!$&&Lt){const z=Gh(k);z&&!Ft.has(z.id)&&(Ft.add(z.id),pp({active:ns("speakReplies",ss()),spokeThisTurn:Et,reply:z.text})&&Ti(Cc(z.text),Zi())),Et=!1}Lt=$});function Xt(){t(Se)===void 0?qs(!0):t(Se)===!0?qs(!1):qs(void 0)}let zt=L(()=>!!t(K).sessionFile),Sn=L(()=>!!B()&&!t(we)&&!t(R)&&!t(zt)),mn=F(!0),qt=F(!1),Kt=Yn({});function dn(k,$){Kt[k]=!$}let kn=Yn({});function En(k){kn[k]=!kn[k]}let pt=F(null),Ct=null;async function _n(k,$){try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText($);else{const z=document.createElement("textarea");z.value=$,z.style.position="fixed",z.style.opacity="0",document.body.appendChild(z),z.select(),document.execCommand("copy"),document.body.removeChild(z)}p(pt,k,!0),Ct&&clearTimeout(Ct),Ct=setTimeout(()=>{p(pt,null),Ct=null},1500)}catch(z){console.error("Failed to copy message",z)}}function Cn(){t(ee)&&p(mn,Ji(t(ee)),!0)}function wn(){t(ee)&&(t(ee).scrollTop=t(ee).scrollHeight)}function Nn(){(t(mn)||t(qt))&&(wn(),p(qt,!1))}os(wn),Nt(()=>{if(t(ee))return t(ee).addEventListener("scroll",Cn),()=>{t(ee)&&t(ee).removeEventListener("scroll",Cn)}});let xn=F(null),vn=F(!1);function Fn(){p(qt,!0),wn(),requestAnimationFrame(()=>{wn(),requestAnimationFrame(wn)}),setTimeout(wn,60),setTimeout(wn,150)}Nt(()=>{const k=t(K).sessionFile;k!==t(xn)&&(p(xn,k,!0),p(qt,!0));const $=t(we);t(vn)&&!$&&Fn(),p(vn,$,!0)});let Vt=L(()=>Wh(P(),{hideThinking:r().hideThinking,hideTools:r().hideTools},t(qn))),qn=L(U),j=F(Yn(Date.now())),ie=L(()=>t(Vt).some(k=>k.role==="tool"&&k.isStreaming));Nt(()=>{if(!t(ie))return;p(j,Date.now(),!0);const k=setInterval(()=>p(j,Date.now(),!0),100);return()=>clearInterval(k)}),xd(()=>{const k=t(Vt)[t(Vt).length-1];k&&`${t(Vt).length}${k.content.length}`,t(ee)&&p(mn,Ji(t(ee)),!0)}),Nt(()=>{const k=t(Vt)[t(Vt).length-1];k&&`${t(Vt).length}${k.content.length}`,Nn()});function Ie(){p(qt,!0),setTimeout(wn,0)}let De=L(W),S=L(ze);const V=64;let be=F(null),Oe=F(null);function rt(){!t(ee)||t(S)||!t(De)||(p(be,t(Vt)[0]?.id??null,!0),p(Oe,t(ee).scrollHeight-t(ee).scrollTop),ec())}Nt(()=>{if(P().length,(t(be)!==null||t(Oe)!==null)&&t(ee)){const k=t(be),$=t(Oe);p(be,null),p(Oe,null),requestAnimationFrame(()=>{if(!t(ee))return;const z=k?t(ee).querySelector(`[data-msg-id="${CSS.escape(k)}"]`):null;if(z){const ne=z.getBoundingClientRect().top-t(ee).getBoundingClientRect().top;t(ee).scrollTop=Math.max(0,t(ee).scrollTop+ne-V)}else $!==null&&(t(ee).scrollTop=t(ee).scrollHeight-$)})}});var je={forceScrollToBottom:Ie},_e=Dv(),me=u(_e);{var Zt=k=>{var $=qh();h(k,$)},nn=k=>{var $=Vh(),z=u($),ne=f(u(z),6);{var fe=l=>{var _=Kh(),A=u(_,!0);c(_),T(()=>E(A,t(It).error)),h(l,_)};w(ne,l=>{t(It).error&&l(fe)})}var I=f(ne,2);c(z),c($),M("click",I,()=>{Dd(()=>Promise.resolve().then(()=>vf),void 0,import.meta.url).then(l=>l.connect())}),h(k,$)},Bt=k=>{var $=Yh();h(k,$)},un=k=>{var $=ib(),z=u($),ne=u(z),fe=u(ne),I=u(fe);c(fe),dt(6),c(ne);var l=f(ne,2),_=u(l),A=f(u(_),2),N=u(A);kt(N),lr(N,H=>p(He,H),()=>t(He));var de=f(N,2);{var Te=H=>{var ue=Zh();$n(ue,21,()=>t(te),vr,(Ye,Xe)=>{var Ge=Xh(),Me=u(Ge,!0);c(Ge),T(()=>E(Me,t(Xe))),M("click",Ge,()=>{p(Ae,t(Xe),!0),le(t(Xe),!0),t(He)?.focus()}),h(Ye,Ge)}),c(ue),h(H,ue)};w(de,H=>{t(Ne)&&t(te).length>0&&H(Te)})}c(A),lr(A,H=>p(Ke,H),()=>t(Ke));var gt=f(A,2);{var ot=H=>{var ue=Qh(),Ye=f(u(ue));{var Xe=Ge=>{var Me=Jh();h(Ge,Me)};w(Ye,Ge=>{t(q).isGit&&Ge(Xe)})}c(ue),h(H,ue)},Pe=H=>{var ue=eb();h(H,ue)};w(gt,H=>{t(q).exists===!0?H(ot):H(Pe,-1)})}c(_);var ct=f(_,2),it=f(u(ct),2);{var We=H=>{var ue=nb();$n(ue,21,()=>t(At).models,vr,(Ye,Xe)=>{var Ge=tb(),Me=u(Ge);c(Ge);var _t={};T(()=>{E(Me,`${t(Xe).label??""}${t(Xe).isDefault?" (default)":""}`),_t!==(_t=`${t(Xe).provider}:${t(Xe).modelId}`)&&(Ge.value=Ge.__value=`${t(Xe).provider}:${t(Xe).modelId}`)}),h(Ye,Ge)}),c(ue),As(ue,()=>t(Be),Ye=>p(Be,Ye)),h(H,ue)},Ut=H=>{var ue=rb();kt(ue),fr(ue,()=>t(Be),Ye=>p(Be,Ye)),h(H,ue)};w(it,H=>{t(At).models.length>0?H(We):H(Ut,-1)})}c(ct);var fn=f(ct,2);{var Rn=H=>{var ue=ab(),Ye=u(ue),Xe=u(Ye);kt(Xe);var Ge=f(Xe,2),Me=u(Ge);c(Ge),c(Ye);var _t=f(Ye,2);{var St=Qt=>{var Bn=sb(),jn=f(u(Bn),2),Mn=u(jn);kt(Mn),Mn.value=Mn.__value="private",dt(),c(jn);var Kn=f(jn,2),Tn=u(Kn);kt(Tn),Tn.value=Tn.__value="public",dt(),c(Kn),c(Bn),Pr(Ce,[],Mn,()=>t(Tt),On=>p(Tt,On)),Pr(Ce,[],Tn,()=>t(Tt),On=>p(Tt,On)),h(Qt,Bn)};w(_t,Qt=>{t(Ot)&&Qt(St)})}c(ue),T(()=>E(Me,`Create remote ${t(q).matchingRule.provider??""} repository`)),Jn(Xe,()=>t(Ot),Qt=>p(Ot,Qt)),h(H,ue)};w(fn,H=>{t(q).exists!==!0&&t(q).matchingRule&&H(Rn)})}var Fe=f(fn,2);{var Ee=H=>{var ue=ob(),Ye=u(ue);kt(Ye),dt(2),c(ue),M("change",Ye,Xe=>{p(ut,Xe.currentTarget.checked,!0)}),Jn(Ye,()=>t(Qe),Xe=>p(Qe,Xe)),h(H,ue)};w(Fe,H=>{t(q).exists!==!0&&(!t(q).matchingRule||!t(Ot))&&H(Ee)})}var ae=f(Fe,2),Ue=u(ae,!0);c(ae),c(l),c(z),c($),T((H,ue)=>{Z(I,"src",H),en(N,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(tt)?"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"}`),ae.disabled=ue,E(Ue,t(Wt)?"Checking remote...":"Create & Start Session")},[()=>ts("/logo.svg"),()=>!t(Ae).trim()||t(Wt)]),Sr("submit",l,H=>{H.preventDefault(),et()}),Sr("focus",N,()=>{p(Ne,!0),le(t(Ae),!0)}),Sr("blur",N,H=>{t(Ke)&&t(Ke).contains(H.relatedTarget)||p(Ne,!1)}),M("keydown",N,H=>{H.key==="Escape"&&p(Ne,!1)}),fr(N,()=>t(Ae),H=>p(Ae,H)),h(k,$)},rn=k=>{var $=lb();h(k,$)},Rt=k=>{var $=cb();h(k,$)},yt=k=>{var $=kv(),z=u($);{var ne=I=>{var l=db(),_=u(l),A=u(_);{var N=Te=>{var gt=Vn("Loading older messages...");h(Te,gt)},de=Te=>{var gt=Vn("Load older messages");h(Te,gt)};w(A,Te=>{t(S)?Te(N):Te(de,-1)})}c(_),c(l),T(()=>_.disabled=t(S)),M("click",_,rt),h(I,l)};w(z,I=>{t(De)&&I(ne)})}var fe=f(z,2);$n(fe,17,()=>t(Vt),I=>I.id,(I,l)=>{var _=Sv(),A=u(_),N=u(A);{var de=it=>{var We=ur(),Ut=mt(We);{var fn=ae=>{var Ue=ub();h(ae,Ue)},Rn=ae=>{var Ue=fb();h(ae,Ue)},Fe=ae=>{var Ue=pb();h(ae,Ue)},Ee=ae=>{var Ue=bb(),H=u(Ue);{var ue=Ge=>{var Me=hb();h(Ge,Me)};w(H,Ge=>{t(l).isStreaming&&Ge(ue)})}var Ye=f(H,2),Xe=u(Ye,!0);c(Ye),c(Ue),T(()=>E(Xe,t(l).content)),h(ae,Ue)};w(Ut,ae=>{t(l).content==="FALLBACK_THINKING_LOADER"?ae(fn):t(l).content==="FALLBACK_LOADER"?ae(Rn,1):r().hideThinking?ae(Fe,2):ae(Ee,-1)})}h(it,We)},Te=it=>{var We=ur(),Ut=mt(We);{var fn=Ee=>{var ae=gb(),Ue=f(u(ae),2),H=f(u(Ue)),ue=u(H,!0);c(H),dt(),c(Ue);var Ye=f(Ue,2);{var Xe=Me=>{var _t=vb(),St=u(_t,!0);c(_t),T(Qt=>E(St,Qt),[()=>js(t(l),t(j))]),h(Me,_t)},Ge=L(()=>js(t(l),t(j)));w(Ye,Me=>{t(Ge)&&Me(Xe)})}c(ae),T(()=>E(ue,t(l).toolName||"agent")),h(Ee,ae)},Rn=L(()=>r().hideTools&&!io(t(l).toolName)&&!sa(t(l))),Fe=Ee=>{const ae=L(()=>Xi(t(l))),Ue=L(()=>Kt[t(l).id]!==void 0?Kt[t(l).id]:Hh(t(l),t(Vt))),H=L(()=>t(ae).downloadPath),ue=L(()=>t(H)?_c(t(H)):null),Ye=L(()=>t(H)?dp(t(H)):null),Xe=L(()=>t(ae).toolName==="attach_file"),Ge=L(()=>t(ae).toolName==="say");var Me=ur(),_t=mt(Me);{var St=jn=>{const Mn=L(()=>t(H)?t(H).split("/").pop()||t(H):"");var Kn=Ab(),Tn=u(Kn);{var On=gn=>{var Yt=mb();h(gn,Yt)},sr=gn=>{var Yt=yb(),or=f(u(Yt),2),hr=f(u(or),2);{var Br=Ar=>{var jr=xb(),_a=u(jr,!0);c(jr),T(()=>E(_a,t(ae).toolOutput)),h(Ar,jr)};w(hr,Ar=>{t(ae).toolOutput&&Ar(Br)})}c(or),c(Yt),h(gn,Yt)},ar=gn=>{var Yt=_b(),or=f(u(Yt),2),hr=u(or),Br=u(hr,!0);c(hr);var Ar=f(hr,2),jr=u(Ar,!0);c(Ar),c(or),dt(2),c(Yt),T(()=>{Z(Yt,"href",t(ue)),Z(Yt,"download",t(Mn)),Z(Yt,"title",`Download ${t(H)}`),E(Br,t(Mn)),Z(Ar,"title",t(H)),E(jr,t(H))}),h(gn,Yt)},Pt=gn=>{var Yt=wb(),or=f(u(Yt),2),hr=u(or),Br=u(hr,!0);c(hr),dt(2),c(or),c(Yt),T(()=>E(Br,t(Mn))),h(gn,Yt)};w(Tn,gn=>{t(l).isStreaming?gn(On):t(ae).isError?gn(sr,1):t(ue)?gn(ar,2):gn(Pt,-1)})}var Gt=f(Tn,2);{var Tr=gn=>{var Yt=Sb(),or=u(Yt);c(Yt),T(()=>{Z(Yt,"href",t(ue)),Z(Yt,"title",`Open ${t(H)}`),Z(or,"src",t(ue)),Z(or,"alt",t(H))}),h(gn,Yt)};w(Gt,gn=>{!t(l).isStreaming&&!t(ae).isError&&t(ue)&&t(Ye)==="image"&&gn(Tr)})}var mr=f(Gt,2);{var zr=gn=>{var Yt=kb();T(()=>{Z(Yt,"src",t(ue)),Z(Yt,"title",t(H))}),h(gn,Yt)};w(mr,gn=>{!t(l).isStreaming&&!t(ae).isError&&t(ue)&&t(Ye)==="audio"&&gn(zr)})}var Vr=f(mr,2);{var ya=gn=>{var Yt=Tb();T(()=>{Z(Yt,"src",t(ue)),Z(Yt,"title",t(H))}),h(gn,Yt)};w(Vr,gn=>{!t(l).isStreaming&&!t(ae).isError&&t(ue)&&t(Ye)==="video"&&gn(ya)})}c(Kn),h(jn,Kn)},Qt=jn=>{var Mn=Eb(),Kn=u(Mn);{var Tn=sr=>{var ar=Rb(),Pt=f(u(ar),2),Gt=f(u(Pt),2);{var Tr=mr=>{var zr=Cb(),Vr=u(zr,!0);c(zr),T(()=>E(Vr,t(ae).toolOutput)),h(mr,zr)};w(Gt,mr=>{t(ae).toolOutput&&mr(Tr)})}c(Pt),c(ar),h(sr,ar)},On=sr=>{var ar=Ib(),Pt=f(u(ar),2),Gt=f(u(Pt),2),Tr=u(Gt,!0);c(Gt),c(Pt),c(ar),T(()=>E(Tr,t(ae).sayText)),h(sr,ar)};w(Kn,sr=>{t(ae).isError?sr(Tn):t(ae).sayText&&sr(On,1)})}c(Mn),h(jn,Mn)},Bn=jn=>{var Mn=Jb(),Kn=u(Mn),Tn=u(Kn),On=u(Tn),sr=u(On);{var ar=Ze=>{var lt=Mb();h(Ze,lt)},Pt=Ze=>{var lt=Ob();h(Ze,lt)},Gt=Ze=>{var lt=$b();h(Ze,lt)},Tr=Ze=>{var lt=Lb();h(Ze,lt)};w(sr,Ze=>{t(l).isStreaming?Ze(ar):t(ae).isError?Ze(Pt,1):t(ae).interrupted?Ze(Gt,2):Ze(Tr,-1)})}var mr=f(sr,2),zr=u(mr,!0);c(mr);var Vr=f(mr,2);{var ya=Ze=>{var lt=Db(),er=u(lt,!0);c(lt),T(()=>{Z(lt,"title",t(ae).smartTitleArgs),E(er,t(ae).smartTitleArgs)}),h(Ze,lt)};w(Vr,Ze=>{t(ae).smartTitleArgs&&Ze(ya)})}var gn=f(Vr,2);{var Yt=Ze=>{var lt=Pb(),er=u(lt);c(lt),T(Hr=>{en(lt,1,`shrink-0 font-mono text-xs tabular-nums ${t(l).isStreaming?"text-amber-400":"text-brand-text-muted"}`),Z(lt,"title",t(l).isStreaming?"Elapsed time":"Time taken"),E(er,`${t(l).isStreaming?"Elapsed":"Took"}
|
|
95
|
-
${Hr??""}`)},[()=>js(t(l),t(j))]),h(Ze,lt)},or=L(()=>js(t(l),t(j)));w(gn,Ze=>{t(or)&&Ze(Yt)})}c(On);var hr=f(On,2),Br=u(hr);{var Ar=Ze=>{var lt=Nb();dt(),h(Ze,lt)},jr=Ze=>{var lt=Fb();dt(),h(Ze,lt)};w(Br,Ze=>{t(Ue)?Ze(Ar):Ze(jr,-1)})}c(hr),c(Tn);var _a=f(Tn,2);{var Vc=Ze=>{var lt=ur(),er=mt(lt);{var Hr=cr=>{var dr=Ub();T(ls=>{Z(dr,"href",t(ue)),Z(dr,"download",ls),Z(dr,"title",`Download ${t(H)}`),Z(dr,"aria-label",`Download ${t(H)}`)},[()=>t(H).split("/").pop()||""]),h(cr,dr)},Yr=cr=>{var dr=zb();h(cr,dr)};w(er,cr=>{t(ue)?cr(Hr):cr(Yr,-1)})}h(Ze,lt)};w(_a,Ze=>{t(H)&&Ze(Vc)})}c(Kn);var Ko=f(Kn,2);{var Yc=Ze=>{var lt=Bb(),er=u(lt);c(lt),T(()=>{Z(lt,"href",t(ue)),Z(lt,"title",`Open ${t(H)}`),Z(er,"src",t(ue)),Z(er,"alt",t(H))}),h(Ze,lt)};w(Ko,Ze=>{!(t(l).images&&t(l).images.length>0)&&t(ue)&&t(Ye)==="image"&&Ze(Yc)})}var Vo=f(Ko,2);{var Xc=Ze=>{var lt=jb();T(()=>{Z(lt,"src",t(ue)),Z(lt,"title",t(H))}),h(Ze,lt)};w(Vo,Ze=>{t(ue)&&t(Ye)==="audio"&&Ze(Xc)})}var Yo=f(Vo,2);{var Zc=Ze=>{var lt=Hb();T(()=>{Z(lt,"src",t(ue)),Z(lt,"title",t(H))}),h(Ze,lt)};w(Yo,Ze=>{t(ue)&&t(Ye)==="video"&&Ze(Zc)})}var Xo=f(Yo,2);{var Jc=Ze=>{var lt=Gb(),er=u(lt);$n(er,21,()=>t(l).images,vr,(Hr,Yr)=>{const cr=L(()=>wc(t(Yr)));var dr=ur(),ls=mt(dr);{var wa=cs=>{var In=Wb(),Xn=u(In);c(In),T(()=>{Z(In,"href",t(cr)),Z(Xn,"src",t(cr))}),h(cs,In)};w(ls,cs=>{t(cr)&&cs(wa)})}h(Hr,dr)}),c(er),c(lt),h(Ze,lt)};w(Xo,Ze=>{t(l).images&&t(l).images.length>0&&Ze(Jc)})}var Qc=f(Xo,2);{var ed=Ze=>{var lt=Zb(),er=u(lt);{var Hr=In=>{var Xn=qb(),Ps=f(u(Xn),2),td=u(Ps,!0);c(Ps),c(Xn),T(()=>E(td,t(ae).fullArgs)),h(In,Xn)};w(er,In=>{t(ae).fullArgs&&t(ae).fullArgs!=="{}"&&In(Hr)})}var Yr=f(er,2),cr=f(u(Yr),2);{var dr=In=>{var Xn=Kb(),Ps=u(Xn,!0);c(Xn),T(()=>E(Ps,t(ae).toolOutput)),h(In,Xn)},ls=In=>{var Xn=Vb();h(In,Xn)},wa=In=>{var Xn=Yb();h(In,Xn)},cs=In=>{var Xn=Xb();h(In,Xn)};w(cr,In=>{t(ae).toolOutput?In(dr):t(l).isStreaming?In(ls,1):t(ae).interrupted?In(wa,2):In(cs,-1)})}c(Yr),c(lt),h(Ze,lt)};w(Qc,Ze=>{t(Ue)&&Ze(ed)})}c(Mn),T(()=>E(zr,t(ae).toolName)),M("click",Tn,()=>dn(t(l).id,t(Ue))),h(jn,Mn)};w(_t,jn=>{t(Xe)?jn(St):t(Ge)?jn(Qt,1):jn(Bn,-1)})}h(Ee,Me)};w(Ut,Ee=>{t(Rn)?Ee(fn):Ee(Fe,-1)})}h(it,We)},gt=it=>{var We=ur(),Ut=mt(We);{var fn=Fe=>{var Ee=Qb(),ae=u(Ee,!0);dt(),c(Ee),T(()=>E(ae,t(l).content)),h(Fe,Ee)},Rn=Fe=>{const Ee=L(()=>Kt[t(l).id]===!0),ae=L(()=>bp({active:t(at),expanded:t(Ee),content:t(l).content})),Ue=L(()=>kn[t(l).id]===!0);var H=lv(),ue=u(H);{var Ye=Pt=>{var Gt=ev(),Tr=u(Gt,!0);c(Gt),T(()=>{en(Gt,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(ae)?"relative max-h-40 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)] opacity-80":""}`),E(Tr,t(l).content)}),h(Pt,Gt)},Xe=Pt=>{var Gt=tv();ri(Gt,()=>Dh(t(l).id,t(l).content),!0),c(Gt),T(()=>en(Gt,1,`chat-selectable markdown-body text-sm leading-relaxed ${t(ae)?"relative max-h-40 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)] opacity-80":""}`)),h(Pt,Gt)};w(ue,Pt=>{t(Ue)?Pt(Ye):Pt(Xe,-1)})}var Ge=f(ue,2),Me=u(Ge),_t=u(Me);{var St=Pt=>{var Gt=nv();dt(),h(Pt,Gt)},Qt=Pt=>{var Gt=rv();dt(),h(Pt,Gt)};w(_t,Pt=>{t(pt)===t(l).id?Pt(St):Pt(Qt,-1)})}c(Me);var Bn=f(Me,2),jn=u(Bn);{var Mn=Pt=>{var Gt=sv();dt(),h(Pt,Gt)},Kn=Pt=>{var Gt=av();dt(),h(Pt,Gt)};w(jn,Pt=>{t(Ue)?Pt(Mn):Pt(Kn,-1)})}c(Bn),c(Ge);var Tn=f(Ge,2);{var On=Pt=>{var Gt=ov();M("click",Gt,()=>dn(t(l).id,t(Ee))),h(Pt,Gt)},sr=Pt=>{var Gt=iv();M("click",Gt,()=>dn(t(l).id,t(Ee))),h(Pt,Gt)},ar=L(()=>t(at)&&t(Ee)&&Rc(t(l).content));w(Tn,Pt=>{t(ae)?Pt(On):t(ar)&&Pt(sr,1)})}c(H),T(()=>Z(Bn,"title",t(Ue)?"Show the rendered markdown":"Show the raw markdown source")),M("click",Me,()=>_n(t(l).id,t(l).content)),M("click",Bn,()=>En(t(l).id)),h(Fe,H)};w(Ut,Fe=>{t(l).isStreaming?Fe(fn):Fe(Rn,-1)})}h(it,We)},ot=it=>{const We=L(()=>Uh(t(l).content));var Ut=gv(),fn=mt(Ut);{var Rn=Ue=>{var H=dv(),ue=u(H),Ye=f(u(ue),2),Xe=u(Ye);c(Ye),c(ue);var Ge=f(ue,2);{var Me=_t=>{var St=cv(),Qt=u(St,!0);c(St),T(()=>E(Qt,t(We).skill.args)),h(_t,St)};w(Ge,_t=>{t(We).skill.args&&_t(Me)})}c(H),T(()=>E(Xe,`skill:${t(We).skill.skillName??""}`)),h(Ue,H)},Fe=Ue=>{var H=hv(),ue=u(H);{var Ye=St=>{const Qt=L(()=>Ph(t(We).cleanContent));var Bn=ur(),jn=mt(Bn);{var Mn=Tn=>{var On=uv();ri(On,()=>t(Qt),!0),c(On),h(Tn,On)},Kn=Tn=>{var On=Vn();T(()=>E(On,t(We).cleanContent)),h(Tn,On)};w(jn,Tn=>{t(Qt)?Tn(Mn):Tn(Kn,-1)})}h(St,Bn)},Xe=St=>{var Qt=fv(),Bn=u(Qt);c(Qt),T(()=>E(Bn,`Shared file${t(We).attachments.length>1?"s":""} with agent:`)),h(St,Qt)},Ge=St=>{var Qt=Vn();T(()=>E(Qt,t(l).content||(t(l).isStreaming?"Thinking...":""))),h(St,Qt)};w(ue,St=>{t(We).cleanContent?St(Ye):t(We).attachments.length>0?St(Xe,1):St(Ge,-1)})}var Me=f(ue,2);{var _t=St=>{var Qt=pv();h(St,Qt)};w(Me,St=>{t(l).isStreaming&&t(qn)&&St(_t)})}c(H),h(Ue,H)};w(fn,Ue=>{t(We).skill?Ue(Rn):Ue(Fe,-1)})}var Ee=f(fn,2);{var ae=Ue=>{var H=vv();$n(H,21,()=>t(We).attachments,vr,(ue,Ye)=>{var Xe=bv(),Ge=f(u(Xe),2),Me=u(Ge,!0);c(Ge),c(Xe),T(()=>{Z(Ge,"title",t(Ye)),E(Me,t(Ye))}),h(ue,Xe)}),c(H),h(Ue,H)};w(Ee,Ue=>{t(We).attachments.length>0&&Ue(ae)})}h(it,Ut)};w(N,it=>{t(l).role==="thinking"?it(de):t(l).role==="tool"?it(Te,1):t(l).role==="assistant"&&t(l).content!==""?it(gt,2):it(ot,-1)})}var Pe=f(N,2);{var ct=it=>{var We=wv(),Ut=mt(We),fn=u(Ut);{var Rn=Me=>{var _t=mv();dt(4),h(Me,_t)};w(fn,Me=>{t(l).role==="user"&&t(l).delivery==="sending"&&Me(Rn)})}var Fe=f(fn);c(Ut);var Ee=f(Ut,2);{var ae=Me=>{var _t=xv(),St=u(_t);c(_t),M("click",St,()=>J(t(l).entryId)),h(Me,_t)},Ue=L(()=>t(l).role==="user"&&t(l).entryId&&t(K).sessionId&&!t(se)&&t(l).delivery===void 0&&!X().includes(t(l).content));w(Ee,Me=>{t(Ue)&&Me(ae)})}var H=f(Ee,2);{var ue=Me=>{var _t=yv();h(Me,_t)},Ye=L(()=>t(l).role==="user"&&X().includes(t(l).content));w(H,Me=>{t(Ye)&&Me(ue)})}var Xe=f(H,2);{var Ge=Me=>{var _t=_v(),St=f(u(_t),2),Qt=f(St,2);c(_t),M("click",St,()=>Wl(t(l).id)),M("click",Qt,()=>Gl(t(l).id)),h(Me,_t)};w(Xe,Me=>{t(l).role==="user"&&t(l).delivery==="failed"&&Me(Ge)})}T(Me=>{en(Ut,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"}`),E(Fe,` ${Me??""}`)},[()=>Fh(t(l).timestamp)]),h(it,We)};w(Pe,it=>{t(l).role!=="thinking"&&t(l).role!=="tool"&&it(ct)})}c(A),c(_),T(it=>{Z(_,"data-msg-id",t(l).id),en(_,1,`flex ${t(l).role==="user"?"justify-end":"justify-start"}`),en(A,1,`max-w-[85%] rounded-lg px-4 py-3 ${it??""}`)},[()=>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"&&io(t(l).toolName)?"bg-transparent p-0 text-brand-text":t(l).role==="tool"?r().hideTools&&!sa(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(I,_)}),c($),lr($,I=>p(ee,I),()=>t(ee)),h(k,$)};w(me,k=>{t(It).connecting&&!t(zt)?k(Zt):!t(It).connected&&!t(zt)?k(nn,1):!t(zt)&&(t(we)||!t(Sn)&&typeof window<"u"&&window.location.hash)?k(Bt,2):t(K).sessionFile?t(Vt).length===0&&(t(we)||t(R))?k(rn,4):t(Vt).length===0?k(Rt,5):k(yt,-1):k(un,3)})}var hn=f(me,2),ht=u(hn),ft=u(ht),Dt=u(ft);kt(Dt),dt(),c(ft);var ln=f(ft,2);{var bn=k=>{var $=Tv(),z=u($),ne=u(z,!0);c(z);var fe=f(z,2),I=u(fe,!0);c(fe),c($),T(()=>{en($,1,`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text ${t(Se)===void 0?"text-brand-text-muted":"text-brand-blue"}`),Z($,"title",t(Se)===void 0?`Beep when the agent is waiting: following the default (${t(Le)?"on":"off"}). Click to set On for this session.`:t(Se)===!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."),E(ne,t(Le)?"🔔":"🔕"),E(I,t(Se)===void 0?`Beep: Default (${t(Le)?"on":"off"})`:t(Se)?"Beep: On":"Beep: Off")}),M("click",$,Xt),h(k,$)};w(ln,k=>{t(K).sessionFile&&!m()&&k(bn)})}var xe=f(ln,2),qe=u(xe),bt=u(qe,!0);c(qe);var ke=f(qe,2),st=u(ke,!0);c(ke),c(xe);var sn=f(xe,2);{var Jt=k=>{var $=Av(),z=f(u($),2),ne=u(z,!0);c(z),c($),T(fe=>{Z($,"title",fe),E(ne,t(he))},[()=>r().contextUsage?.tokens!=null?`${r().contextUsage.tokens.toLocaleString()} context tokens of ${r().contextUsage.contextWindow.toLocaleString()}`:"Context window size"]),h(k,$)};w(sn,k=>{t(he)&&k(Jt)})}c(ht);var yn=f(ht,2),jt=u(yn);{var an=k=>{var $=Cv(),z=u($);c($),T(()=>{Z($,"title",`Cancel the queued steer message${X().length>1?"s":""} (does not abort the current turn)`),E(z,`Cancel queued${X().length>1?` (${X().length})`:""}`)}),M("click",$,function(...ne){Kl?.apply(this,ne)}),h(k,$)};w(jt,k=>{X().length>0&&k(an)})}var Pn=f(jt,2);c(yn),c(hn);var $e=f(hn,2);{var C=k=>{var $=Ov(),z=u($),ne=f(u(z),2),fe=f(u(ne)),I=u(fe,!0);c(fe),dt(),c(ne);var l=f(ne,2),_=u(l),A=u(_);kt(A);var N=f(A,2),de=f(u(N));{var Te=Ut=>{var fn=Rv();h(Ut,fn)},gt=Ut=>{var fn=Iv();h(Ut,fn)};w(de,Ut=>{t(q).isGit?Ut(Te):Ut(gt,-1)})}c(N),c(_);var ot=f(_,2);{var Pe=Ut=>{var fn=Mv(),Rn=u(fn),Fe=u(Rn);kt(Fe);var Ee=f(Fe,2),ae=u(Ee);c(Ee),c(Rn);var Ue=f(Rn,2);{var H=ue=>{var Ye=Ev(),Xe=f(u(Ye),2),Ge=u(Xe);kt(Ge),Ge.value=Ge.__value="private",dt(),c(Xe);var Me=f(Xe,2),_t=u(Me);kt(_t),_t.value=_t.__value="public",dt(),c(Me),c(Ye),Pr(Ce,[],Ge,()=>t(Tt),St=>p(Tt,St)),Pr(Ce,[],_t,()=>t(Tt),St=>p(Tt,St)),h(ue,Ye)};w(Ue,ue=>{t(Ot)&&ue(H)})}c(fn),T(()=>E(ae,`Create remote ${t(q).matchingRule.provider??""} repository`)),Jn(Fe,()=>t(Ot),ue=>p(Ot,ue)),h(Ut,fn)};w(ot,Ut=>{t(q).matchingRule&&Ut(Pe)})}c(l);var ct=f(l,2),it=u(ct),We=f(it,2);c(ct),c(z),c($),T(()=>{E(I,t(Ae)),A.disabled=t(q).isGit}),Jn(A,()=>t(Qe),Ut=>p(Qe,Ut)),M("click",it,()=>p(xt,!1)),M("click",We,()=>{p(xt,!1),wr(t(Ae).trim(),t(Be)||void 0,t(Qe),t(q).matchingRule?t(Ot):void 0,t(q).matchingRule?t(Tt):void 0)}),h(k,$)};w($e,k=>{t(xt)&&k(C)})}var O=f($e,2);{var Q=k=>{var $=Lv(),z=u($),ne=f(u(z),2),fe=u(ne),I=f(fe),l=u(I,!0);c(I),dt(),c(ne);var _=f(ne,2);{var A=gt=>{var ot=$v(),Pe=u(ot,!0);c(ot),T(()=>E(Pe,t(ve).sshUrl)),h(gt,ot)};w(_,gt=>{t(ve)?.sshUrl&>(A)})}var N=f(_,2),de=u(N),Te=f(de,2);c(N),c(z),c($),T(()=>{E(fe,`A ${t(ve)?.provider??"remote"??""} repository matching `),E(l,t(Ae))}),M("click",de,()=>{p(Re,!1),p(ve,null),$t(!1)}),M("click",Te,()=>{p(Re,!1),p(ve,null),$t(!0)}),h(k,$)};w(O,k=>{t(Re)&&k(Q)})}c(_e),T(()=>{ia(Dt,r().hideThinking),en(xe,1,`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text ${t(nt)?"text-brand-blue":"text-brand-text-muted"}`),Z(xe,"title",`Conversation Mode for THIS conversation: ${t(nt)?"ON":"OFF"}${t(ce)?" (following your default)":" (set for this conversation)"}. ${t(nt)?"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.`),E(bt,t(nt)?"🗣️":"💬"),E(st,t(nt)?"Conversation: On":"Conversation: Off"),Pn.disabled=!t(qn)}),M("change",Dt,k=>rc({hideThinking:k.currentTarget.checked})),M("click",xe,Ve),M("click",Pn,function(...k){ql?.apply(this,k)}),h(n,_e);var pe=rr(je);return Y(),pe}pr(["click","keydown","change"]);function Nv(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 qo="pre-start",Wc="Failed to upload";function Qi(n){return{state:qo,acked:0,size:n}}function Fv(n,e){if(!(e>0))return 0;const r=Math.floor(n/e*100);return Math.min(100,Math.max(0,r))}function lo(n){return n?.code!=="not_readable"}function Uv(n){switch(n.state){case qo:return{kind:"pending"};case"queued":case"paused":return{kind:"waiting"};case"sending":return n.acked>0?{kind:"progress",percent:Fv(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=lo(n.error);return{kind:"failed",message:n.error?.message||Wc,retry:e,pickAgain:!e}}}}function Gc(n){return n===qo||n==="queued"||n==="sending"||n==="paused"||n==="finishing"}function zv(n){const e=n.upload;return e?Gc(e.state)?!0:e.state==="done"&&!n.path:!1}function Bv(n){const e=n,r=typeof e?.message=="string"&&e.message?e.message:Wc;return e?.code==="not_readable"?{message:r,code:"not_readable"}:{message:r}}function jv(n){return n.active?"reopen-mic":"none"}const Hv={speechLevel:.015,silenceMs:2e3,leadingSilenceMs:6e3,maxMs:6e4};function Wv(n={}){const{speechLevel:e,silenceMs:r,leadingSilenceMs:s,maxMs:a}={...Hv,...n};let o=0,i=0,d=!1,m=null;return{push(v,g){return m||(o+=g,v>=e?(d=!0,i=0):i+=g,o>=a?(m="stop-max",m):i>=(d?r:s)?(m="stop-silence",m):"keep-recording")}}}function Gv(n){const e=n.length;if(!e)return 0;let r=0;for(let s=0;s<e;s++){const a=n[s];r+=a*a}return Math.sqrt(r/e)}var qv=b("<option> </option>"),Kv=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>'),Vv=b('<div class="mt-2 rounded border border-red-900/40 bg-red-950/40 p-2 leading-normal text-red-400"> </div>'),Yv=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
|
|
96
|
-
the message.</p></div> <!></div>`,1),Xv=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 Zv(n,e){nr(e,!0);let r=ir(e,"text",15),s=ir(e,"activeEngine",15,"browser");const a=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null,o=!!a;let i=F(!1),d=F(!1),m=F(!1),v=F(!1),g=F(!1),x=F("en-US"),y=F("browser"),D=F(null);Nt(()=>{s(t(y))});let P=F(null),re=null,U=null,B=null,W=null,ze=null,X=[],G=null,Y="",Ce=!1;const he=[{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)"}],Ae=wo.subscribe(R=>{p(g,R,!0)});os(()=>{const R=localStorage.getItem("wherever-speech-locale");R!==null&&p(x,R,!0);const se=localStorage.getItem("wherever-speech-engine");return se!==null?p(y,se,!0):o||p(y,"cloud"),()=>{if(Ae(),re)try{re.abort()}catch{}if(W)try{W.disconnect()}catch{}if(B)try{B.disconnect()}catch{}if(ze)try{ze.getTracks().forEach(J=>J.stop())}catch{}if(U)try{U.close()}catch{}t(P)&&clearTimeout(t(P))}});function te(){Rl(t(g)),localStorage.setItem("wherever-speech-locale",t(x)),localStorage.setItem("wherever-speech-engine",t(y))}function Ne(){const R=localStorage.getItem("wherever-config"),se=R?JSON.parse(R):null;if(se&&se.host&&se.port){const J=window.location.protocol==="https:"?"https:":"http:",Se=se.host.startsWith("http")?se.host.replace(/^wss?:\/\//,""):se.host;return`${J}//${Se}:${se.port}`}return`${window.location.protocol}//${window.location.host}`}function He(){try{const R=localStorage.getItem("wherever-config");if(R)return JSON.parse(R).token||""}catch{}return""}function Ke(){try{const R=window.AudioContext||window.webkitAudioContext;if(!R)return;const se=new R,J=se.createOscillator(),Se=se.createGain();J.type="sine",J.frequency.setValueAtTime(400,se.currentTime),Se.gain.setValueAtTime(.08,se.currentTime),Se.gain.exponentialRampToValueAtTime(.001,se.currentTime+.12),J.connect(Se),Se.connect(se.destination),J.start(),J.stop(se.currentTime+.12)}catch(R){console.warn("Could not play audio beep feedback:",R)}}function Je(R,se,J){if(se===J)return R;const Se=se/J,Le=Math.round(R.length/Se),nt=new Float32Array(Le);let ce=0,Ve=0;for(;ce<nt.length;){const at=Math.round((ce+1)*Se);let wt=0,Et=0;for(let Lt=Ve;Lt<at&&Lt<R.length;Lt++)wt+=R[Lt],Et++;nt[ce]=Et>0?wt/Et:0,ce++,Ve=at}return nt}function Be(){if(o)try{re=new a,re.continuous=!0,re.interimResults=!0,re.lang=t(x),re.onstart=()=>{p(i,!0),p(d,!1),Ke()},re.onresult=R=>{let se="",J="";for(let Le=R.resultIndex;Le<R.results.length;++Le){const nt=R.results[Le];nt.isFinal?se+=nt[0].transcript:J+=nt[0].transcript}const Se=(se+J).trim();Se&&(Ce=!0,r(Y+(Y?" ":"")+Se))},re.onerror=R=>{console.error("Browser speech recognition error:",R.error),R.error!=="no-speech"&&p(D,`Error: ${R.error}`),Qe()},re.onend=()=>{p(i,!1),t(g)&&Ce&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50)},re.start(),navigator.vibrate&&navigator.vibrate(40)}catch(R){console.error("Failed to start browser speech recognition:",R),p(D,"Failed to start browser recording"),p(i,!1)}}function Qe(){if(re)try{re.stop()}catch{}p(i,!1)}async function ut(){try{const R=await navigator.mediaDevices.getUserMedia({audio:!0});ze=R,X=[];const se=window.AudioContext||window.webkitAudioContext;U=new se,B=U.createMediaStreamSource(R),W=U.createScriptProcessor(4096,1,1),W.onaudioprocess=J=>{const Se=J.inputBuffer.getChannelData(0);if(X.push(new Float32Array(Se)),!G)return;const Le=J.inputBuffer.sampleRate||44100,nt=Se.length/Le*1e3;G.push(Gv(Se),nt)!=="keep-recording"&&(G=null,Wt())},B.connect(W),W.connect(U.destination),p(i,!0),p(d,!1),Ke(),navigator.vibrate&&navigator.vibrate(40)}catch(R){console.error("Failed to start cloud audio recording:",R),p(D,R.message||"Microphone access denied",!0),p(i,!1),p(d,!1),G=null}}function Ot(){if(t(i)){if(p(i,!1),p(d,!0),W){try{W.disconnect()}catch{}W.onaudioprocess=null}if(B)try{B.disconnect()}catch{}if(ze)try{ze.getTracks().forEach(R=>R.stop())}catch{}Tt()}}async function Tt(){try{if(X.length===0){p(d,!1);return}p(D,null);let R=0;for(const Xt of X)R+=Xt.length;const se=new Float32Array(R);let J=0;for(const Xt of X)se.set(Xt,J),J+=Xt.length;const Se=U?U.sampleRate:48e3,Le=16e3,nt=Je(se,Se,Le),ce=At(nt,1,Le,1,16),Ve=new Blob([ce],{type:"audio/wav"}),at=Ne(),wt=He(),Et=`${at}/session/transcribe${wt?`?token=${encodeURIComponent(wt)}`:""}`,Lt=await fetch(Et,{method:"POST",body:Ve,headers:{"Content-Type":"application/octet-stream"}}),Ft=await Lt.json();if(!Lt.ok)throw new Error(Ft.error||`HTTP ${Lt.status}`);Ft.text&&Ft.text.trim()&&(Ce=!0,r(Y+(Y?" ":"")+Ft.text.trim()),t(g)&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50))}catch(R){console.error("Cloud transcription request failed:",R),p(D,R.message||"Cloud API failed",!0)}finally{if(p(d,!1),U){try{U.close()}catch{}U=null}}}function xt(R=!1){e.disabled||t(i)||t(d)||(p(D,null),Ce=!1,Y=r(),G=R&&t(y)==="cloud"?Wv():null,t(y)==="cloud"?ut():Be())}function Re(){xt(!0)}function Wt(){G=null,t(y)==="cloud"?Ot():Qe()}function ve(R){if(R.button===0&&!e.disabled){if(ga(),R.preventDefault(),t(i)){Wt();return}p(m,!1),p(P,setTimeout(()=>{p(m,!0),xt()},350),!0)}}function $t(R){t(P)&&(clearTimeout(t(P)),p(P,null)),t(m)?(p(m,!1),Wt()):t(i)||xt()}function It(){t(P)&&(clearTimeout(t(P)),p(P,null)),t(m)&&(p(m,!1),Wt())}function At(R,se,J,Se,Le){const nt=new ArrayBuffer(44+R.length*2),ce=new DataView(nt);return q(ce,0,"RIFF"),ce.setUint32(4,36+R.length*2,!0),q(ce,8,"WAVE"),q(ce,12,"fmt "),ce.setUint32(16,16,!0),ce.setUint16(20,Se,!0),ce.setUint16(22,se,!0),ce.setUint32(24,J,!0),ce.setUint32(28,J*se*(Le/8),!0),ce.setUint16(32,se*(Le/8),!0),ce.setUint16(34,Le,!0),q(ce,36,"data"),ce.setUint32(40,R.length*2,!0),oe(ce,44,R),nt}function oe(R,se,J){for(let Se=0;Se<J.length;Se++,se+=2){let Le=Math.max(-1,Math.min(1,J[Se]));R.setInt16(se,Le<0?Le*32768:Le*32767,!0)}}function q(R,se,J){for(let Se=0;Se<J.length;Se++)R.setUint8(se+Se,J.charCodeAt(Se))}var tt={startRecordingProgrammatically:Re},ge=Xv(),le=u(ge),et=f(le,2),ee=u(et);c(et);var K=f(et,2);{var we=R=>{var se=Yv(),J=mt(se),Se=f(J,2),Le=f(u(Se),2),nt=f(u(Le),2),ce=u(nt),Ve=f(ce,2);c(nt);var at=f(nt,2),wt=u(at,!0);c(at),c(Le);var Et=f(Le,2);{var Lt=qt=>{var Kt=Kv(),dn=f(u(Kt),2);$n(dn,21,()=>he,vr,(kn,En)=>{var pt=qv(),Ct=u(pt,!0);c(pt);var _n={};T(()=>{E(Ct,t(En).label),_n!==(_n=t(En).code)&&(pt.value=(pt.__value=t(En).code)??"")}),h(kn,pt)}),c(dn),c(Kt),M("change",dn,te),As(dn,()=>t(x),kn=>p(x,kn)),h(qt,Kt)};w(Et,qt=>{t(y)==="browser"&&qt(Lt)})}var Ft=f(Et,2),Xt=u(Ft),zt=u(Xt);kt(zt),dt(2),c(Xt),dt(2),c(Ft);var Sn=f(Ft,2);{var mn=qt=>{var Kt=Vv(),dn=u(Kt,!0);c(Kt),T(()=>E(dn,t(D))),h(qt,Kt)};w(Sn,qt=>{t(D)&&qt(mn)})}c(Se),T(()=>{ce.disabled=!o,en(ce,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40
|
|
97
|
-
${t(y)==="browser"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),en(Ve,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors
|
|
98
|
-
${t(y)==="cloud"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),E(wt,t(y)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),M("click",J,()=>p(v,!1)),M("click",ce,()=>{p(y,"browser"),te()}),M("click",Ve,()=>{p(y,"cloud"),te()}),M("change",zt,te),Jn(zt,()=>t(g),qt=>p(g,qt)),h(R,se)};w(K,R=>{t(v)&&R(we)})}return c(ge),T(()=>{le.disabled=e.disabled&&!t(i)&&!t(d)||t(d),en(le,1,`flex h-[48px] w-[48px] items-center justify-center rounded-lg border transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-40
|
|
99
|
-
${t(i)?"animate-pulse border-red-500 bg-red-600 text-white":t(d)?"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"}`),Z(le,"title",t(i)?"Recording (release/tap to stop)...":t(d)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),et.disabled=e.disabled&&!t(i)&&!t(d)||t(d),en(ee,0,`h-4 w-4 transition-transform duration-200 ${t(v)?"rotate-45 text-white":""}`)}),M("pointerdown",le,ve),M("pointerup",le,$t),Sr("pointercancel",le,It),M("click",et,()=>p(v,!t(v))),h(n,ge),rr(tt)}pr(["pointerdown","pointerup","click","change"]);var Jv=b('<span class="ml-1 text-brand-text-muted">syncing…</span>'),Qv=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>'),eg=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
|
|
100
|
-
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>`),tg=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
|
|
101
|
-
on the server for later, from any device.</p>`),ng=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>'),rg=b('<ul class="max-h-64 overflow-y-auto"></ul>'),sg=b('<p class="border-t border-brand-border px-3 py-2 text-xs text-rose-400"> </p>'),ag=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>'),og=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),ig=b('<span class="text-rose-400">⚠️</span> <span class="text-rose-400/80"> </span>',1),lg=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),cg=b('<div class="mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none"><!></div>'),dg=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>'),ug=b('<span class="text-brand-text-muted" title="Will be uploaded with the search">📎</span>'),fg=b('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span>'),pg=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),hg=b('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent" title="Finishing"></span>'),bg=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),vg=b('<span class="shrink-0 text-brand-text-muted">Pick the file again</span>'),gg=b('<a target="_blank" class="ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80">[Test Link]</a>'),mg=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>'),xg=b('<span class="flex items-center gap-1 text-[10px] font-medium text-rose-400"><span class="max-w-[120px] truncate"> </span> <!></span> <!>',1),yg=b('<span class="text-emerald-400">✓</span>'),_g=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>'),wg=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>'),Sg=b('<div class="mb-3 flex flex-wrap gap-2"></div>'),kg=b("<option> </option>"),Tg=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>'),Ag=b('<span class="line-clamp-1 text-[11px] text-brand-text-muted"> </span>'),Cg=b('<li><button type="button" role="option"><span class="font-mono text-brand-text"> </span> <!></button></li>'),Rg=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>'),Ig=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),Eg=b('<span class="hidden font-mono opacity-60 sm:inline">Shift+Enter to send</span>'),Mg=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),Og=b('<div class="relative border-t border-brand-border p-4"><!> <!> <!></div>');function $g(n,e){nr(e,!0);const r=()=>ye(Eo,"$isStreaming",m),s=()=>ye(va,"$isReadOnly",m),a=()=>ye(is,"$activeSessionInfo",m),o=()=>ye(Os,"$isConnected",m),i=()=>ye(cn,"$piState",m),d=()=>ye(Ao,"$composerPrefill",m),[m,v]=Nr();let g=ir(e,"sendDisabled",3,!1),x=ir(e,"showAttach",3,!0),y=ir(e,"searchMode",3,!1),D=ir(e,"searchConfigured",3,!1),P=ir(e,"searchModels",19,()=>[]),re=ir(e,"searchModel",15,""),U=F(""),B=F(!0),W=F(!1),ze=F("browser"),X=F(void 0),G=F(!1),Y=F(0),Ce=F(void 0),he=0;const Ae=new Map;let te=F(Yn([])),Ne=L(r),He=L(s),Ke=L(a),Je=L(o),Be=L(i),Qe=L(()=>{if(y())return null;const S=t(U).match(/^\/([^\s]*)$/);return S?S[1]:null}),ut=L(()=>{if(t(Qe)===null)return[];const S=t(Be).skills??[];if(S.length===0)return[];const V=t(Qe).toLowerCase();return(V?S.filter(Oe=>Oe.name.toLowerCase().includes(V)):S.slice()).sort((Oe,rt)=>{const je=Oe.name.toLowerCase().startsWith(V)?0:1,_e=rt.name.toLowerCase().startsWith(V)?0:1;return je-_e||Oe.name.localeCompare(rt.name)})});Nt(()=>{const S=t(ut).length;if(S===0){Cr(()=>t(G))&&p(G,!1);return}Cr(()=>t(G))||p(G,!0),Cr(()=>t(Y))>=S&&p(Y,0)});function Ot(S){p(U,`/${S} `),p(G,!1),p(Y,0),queueMicrotask(()=>{if(!t(ve))return;t(ve).focus();const V=t(U).length;t(ve).setSelectionRange(V,V)})}let Tt=L(()=>y()?e.disabled||!t(Je)||!D():e.disabled||t(He)||!t(Ke).sessionId),xt=L(()=>t(Tt)||g()||!y()&&!t(Je)),Re=L(()=>t(te).some(zv)),Wt=L(()=>!t(xt)&&!t(Re)&&(t(U).trim().length>0||t(te).length>0)),ve=F(void 0);const $t="wherever-draft:";let It=L(()=>$t+(t(Ke).sessionId??"search")),At=F(null);os(()=>{const S=localStorage.getItem("wherever-enter-to-send");S!==null&&p(B,S==="true"),p(oe,se(),!0)});let oe=F(Yn([])),q=F(!1),tt=F(null),ge=F(null),le=F(!1),et=F(null),ee=F(!1),K=0,we=0,R;function se(){if(typeof localStorage>"u")return[];try{return gi(localStorage.getItem(vi))}catch{return[]}}function J(S,V){if(!(V<we)&&(we=V,p(oe,S,!0),!(typeof localStorage>"u")))try{localStorage.setItem(vi,_u(S))}catch{}}async function Se(){if(typeof localStorage>"u")return!1;let S=[];try{S=gi(localStorage.getItem(Ma))}catch{}if(S.length===0){try{localStorage.removeItem(Ma)}catch{}return!1}try{for(const V of[...S].reverse())await Ja({text:V.text,sessionId:V.sessionId,cwd:V.cwd});return localStorage.removeItem(Ma),!0}catch{return!1}}async function Le(){if(!t(Je))return;const S=++K;p(ee,!0);try{await Se(),J(await Sc(),S),p(et,null)}catch(V){p(et,V?.message||"Could not load drafts",!0)}finally{p(ee,!1)}}let nt=!1;Nt(()=>{if(!t(Je)){nt=!1;return}nt||(nt=!0,Le())});async function ce(){const S=t(U).trim();if(S.length===0)return;const V=t(It),be=++K;try{const Oe=await Ja({text:S,sessionId:t(Ke).sessionId??void 0,cwd:t(Ke).cwd??void 0});J(Oe,be),p(et,null),t(It)===V&&t(U).trim()===S&&(p(U,""),p(ge,null)),p(le,!0),clearTimeout(R),R=setTimeout(()=>p(le,!1),1800)}catch(Oe){p(et,Oe?.message||"Could not save the draft",!0),p(q,!0)}}function Ve(S){if(wu(t(U))==="confirm"){p(tt,S,!0);return}at(S,"replace")}function at(S,V){p(At,t(It),!0),p(U,Su(t(U),S.text,V),!0),p(ge,{id:S.id,text:S.text},!0),p(tt,null),p(q,!1),t(W)&&p(W,!1),queueMicrotask(()=>{if(!t(ve))return;t(ve).focus();const be=t(U).length;t(ve).setSelectionRange(be,be)})}function wt(S){const V=ku(t(ge),S);if(p(ge,null),!V)return;const be=++K;Qa(V).then(Oe=>J(Oe,be)).catch(()=>{})}async function Et(S){const V=++K;try{J(await Qa(S),V),p(et,null)}catch(be){p(et,be?.message||"Could not delete the draft",!0)}t(tt)?.id===S&&p(tt,null),t(ge)?.id===S&&p(ge,null)}function Lt(){t(q)||Le(),p(q,!t(q)),p(tt,null)}function Ft(){p(q,!1),p(tt,null)}uo(()=>clearTimeout(R)),Nt(()=>{const S=t(It);S!==t(At)&&Cr(()=>{let V=null;if(typeof localStorage<"u")try{V=localStorage.getItem(S)}catch{}p(U,V??"",!0),p(At,S,!0),p(ge,null)})});let Xt=F(0);Nt(()=>{const{text:S,bump:V}=d();V===0||V===t(Xt)||(p(Xt,V,!0),Cr(()=>{p(At,t(It),!0),p(U,S,!0),t(W)&&p(W,!1),queueMicrotask(()=>t(ve)?.focus())}))}),Nt(()=>{const S=t(U),V=t(It);if(!(V!==t(At)||typeof localStorage>"u"))try{S.trim().length>0?localStorage.setItem(V,S):localStorage.removeItem(V)}catch{}}),Nt(()=>{y()||Cr(()=>{t(te).some(S=>S.file)&&p(te,t(te).filter(S=>!S.file),!0)})});function zt(){t(W)&&p(W,!1),t(ve)?.focus()}let Sn=!1;Nt(()=>{const S=r(),V=Sn&&!S;Sn=S,!(!V||jv({active:ns("micReopensAfterReply",ss()),engine:t(ze)})==="none")&&(t(xt)||xf().then(()=>{r()||t(xt)||t(X)?.startRecordingProgrammatically()}))});function mn(){p(B,!t(B)),localStorage.setItem("wherever-enter-to-send",String(t(B)))}Nt(()=>{t(ve)&&(t(U),t(ve).style.height="auto",t(ve).style.height=`${t(ve).scrollHeight}px`)}),Nt(()=>{!t(Tt)&&t(ve)&&t(ve).focus()});async function qt(S){Ro();const V=S.target;if(!V.files)return;const be=Array.from(V.files);if(V.value="",y()){p(te,[...t(te),...be.map(je=>({id:he++,name:je.name,file:je}))],!0);return}const Oe=t(Ke).sessionId,rt=be.map(je=>({file:je,id:he++}));p(te,[...t(te),...rt.map(({file:je,id:_e})=>({id:_e,name:je.name,upload:Qi(je.size),retryFile:je}))],!0);for(const{file:je,id:_e}of rt)await En(_e,je,Oe)}function Kt(S,V){p(te,t(te).map(be=>be.id===S?V(be):be),!0)}function dn(S){p(te,t(te).filter(V=>V.id!==S),!0)}function kn(){try{const S=Fr(),V=Ur();return`${S}/health${V?`?token=${encodeURIComponent(V)}`:""}`}catch{return""}}async function En(S,V,be){if(!t(te).some(_e=>_e.id===S))return;const Oe=new AbortController;Ae.set(S,Oe);const rt=()=>Ae.get(S)===Oe,je=_e=>{if(rt()){if(_e.state==="aborted"){dn(S);return}Kt(S,me=>({...me,upload:{..._e},..._e.state==="failed"&&!lo(_e.error)?{retryFile:void 0}:{}}))}};try{if(!be)throw new Error("No active session");const _e=await $o(be,V,{signal:Oe.signal,onProgress:je});if(!rt())return;Kt(S,me=>({id:S,name:me.name,path:_e.savedPath,upload:{state:"done",acked:V.size,size:V.size}}))}catch(_e){if(!rt())return;if(Oe.signal.aborted){dn(S);return}console.error("File upload error details:",_e);const me=Bv(_e);Kt(S,Zt=>({id:S,name:Zt.name,upload:{state:"failed",acked:Zt.upload?.acked??0,size:V.size,error:me},retryFile:lo(me)?V:void 0,url:kn()}))}finally{rt()&&Ae.delete(S)}}function pt(S){const V=Ae.get(S);V?V.abort():dn(S)}function Ct(S){const be=t(te).find(Oe=>Oe.id===S)?.retryFile;!be||Ae.has(S)||(Kt(S,Oe=>({id:S,name:Oe.name,upload:Qi(be.size),retryFile:be})),En(S,be,t(Ke).sessionId))}function _n(S){Ae.get(S)?.abort(),dn(S)}function Cn(){if(t(xt)||t(Re))return;const S=t(U).trim();if(y()){const je=t(te).map(_e=>_e.file).filter(_e=>!!_e);if(!S&&je.length===0||t(Tt))return;e.onSubmit?.(S,je),wt(S),p(U,""),p(te,[],!0),e.onSend?.();return}if(!S&&t(te).length===0)return;const V=t(te).map(je=>je.path).filter(je=>!!je),be=ml(S,V);if(S.startsWith("/")&&t(te).length===0){const je=S.toLowerCase();if(je==="/new"||je==="/reset"){if(t(Ke).cwd){wr(t(Ke).cwd,t(Ke).model||void 0),p(U,""),p(ge,null);return}}else if(je==="/clear"){nc(),p(U,""),p(ge,null);return}else if(je==="/leave"||je==="/exit"){br(),p(U,""),p(ge,null);return}else if(je==="/reload"&&t(Ke).sessionId&&t(Je)&&!t(Be).agentPending){Vl(),p(U,""),p(ge,null);return}}const Oe=Nv({streaming:t(Ne),connected:t(Je),agentPending:t(Be).agentPending,readOnly:t(He),hasSession:!!t(Ke).sessionId});if(Oe.action!=="send"){(Oe.reason==="disconnected"||Oe.reason==="agent-pending")&&Va(be);return}Va(be)&&(wt(S),p(U,""),p(te,[],!0),e.onSend?.())}function wn(S){if(t(q)&&S.key==="Escape"){S.preventDefault(),Ft();return}if(t(G)&&t(ut).length>0){if(S.key==="ArrowDown"){S.preventDefault(),p(Y,(t(Y)+1)%t(ut).length);return}if(S.key==="ArrowUp"){S.preventDefault(),p(Y,(t(Y)-1+t(ut).length)%t(ut).length);return}if(S.key==="Enter"||S.key==="Tab"){S.preventDefault();const V=t(ut)[t(Y)]??t(ut)[0];V&&Ot(V.name);return}if(S.key==="Escape"){S.preventDefault(),p(G,!1);return}}S.key==="Enter"&&(t(B)?S.shiftKey||(S.preventDefault(),Cn()):S.shiftKey&&(S.preventDefault(),Cn()))}var Nn={focusInput:zt},xn=Og(),vn=u(xn);{var Fn=S=>{var V=ag(),be=u(V),Oe=u(be),rt=u(Oe),je=f(rt);{var _e=ht=>{var ft=Jv();h(ht,ft)},me=ht=>{var ft=Qv();h(ht,ft)};w(je,ht=>{t(ee)?ht(_e):t(Je)||ht(me,1)})}c(Oe);var Zt=f(Oe,2);c(be);var nn=f(be,2);{var Bt=ht=>{var ft=eg(),Dt=f(u(ft),2),ln=u(Dt),bn=f(ln,2),xe=f(bn,2);c(Dt),c(ft),M("click",ln,()=>t(tt)&&at(t(tt),"replace")),M("click",bn,()=>t(tt)&&at(t(tt),"append")),M("click",xe,()=>p(tt,null)),h(ht,ft)};w(nn,ht=>{t(tt)&&ht(Bt)})}var un=f(nn,2);{var rn=ht=>{var ft=tg();h(ht,ft)},Rt=ht=>{var ft=rg();$n(ft,21,()=>t(oe),Dt=>Dt.id,(Dt,ln)=>{var bn=ng(),xe=u(bn),qe=u(xe),bt=u(qe,!0);c(qe);var ke=f(qe,2),st=u(ke);c(ke),c(xe);var sn=f(xe,2);c(bn),T((Jt,yn,jt)=>{en(bn,1,`flex items-start gap-2 border-b border-brand-border/50 px-3 py-2 last:border-b-0 ${t(tt)?.id===t(ln).id?"bg-brand-surface-3/60":""}`),xe.disabled=t(Tt),Z(xe,"title",t(Tt)?"Open a session first to load this draft":t(ln).text),E(bt,Jt),E(st,`${yn??""}${jt??""}`)},[()=>Tu(t(ln).text),()=>new Date(t(ln).updatedAt).toLocaleString(),()=>mi(t(ln))?` · ${mi(t(ln))}`:""]),M("click",xe,()=>Ve(t(ln))),M("click",sn,()=>Et(t(ln).id)),h(Dt,bn)}),c(ft),h(ht,ft)};w(un,ht=>{t(oe).length===0?ht(rn):ht(Rt,-1)})}var yt=f(un,2);{var hn=ht=>{var ft=sg(),Dt=u(ft);c(ft),T(()=>E(Dt,`⚠️ ${t(et)??""}`)),h(ht,ft)};w(yt,ht=>{t(et)&&ht(hn)})}c(V),T(()=>E(rt,`Saved drafts (${t(oe).length??""}) `)),M("click",Zt,Ft),h(S,V)};w(vn,S=>{t(q)&&S(Fn)})}var Vt=f(vn,2);{var qn=S=>{var V=cg(),be=u(V);{var Oe=_e=>{var me=og();dt(2),h(_e,me)},rt=_e=>{var me=ig(),Zt=f(mt(me),2),nn=u(Zt,!0);c(Zt),T(()=>E(nn,t(Be).error)),h(_e,me)},je=_e=>{var me=lg();dt(2),h(_e,me)};w(be,_e=>{t(Be).connecting?_e(Oe):t(Be).error?_e(rt,1):t(Je)||_e(je,2)})}c(V),h(S,V)};w(Vt,S=>{(!t(Je)||t(Be).connecting||t(Be).error)&&S(qn)})}var j=f(Vt,2);{var ie=S=>{var V=dg(),be=u(V),Oe=u(be),rt=u(Oe),je=u(rt,!0);c(rt);var _e=f(rt,2),me=u(_e);{var Zt=Rt=>{var yt=Vn();T(()=>E(yt,e.placeholder??"Search the web...")),h(Rt,yt)},nn=Rt=>{var yt=Vn("Agent is working, tap to Steer...");h(Rt,yt)},Bt=Rt=>{var yt=Vn("Read-only mode");h(Rt,yt)},un=Rt=>{var yt=Vn("Select a session first...");h(Rt,yt)},rn=Rt=>{var yt=Vn("Tap to type a message...");h(Rt,yt)};w(me,Rt=>{y()?Rt(Zt):t(Ne)?Rt(nn,1):t(He)?Rt(Bt,2):t(Ke).sessionId?Rt(rn,-1):Rt(un,3)})}c(_e),c(Oe),dt(2),c(be),c(V),T(()=>E(je,y()?"🔍":"💬")),M("click",be,()=>{p(W,!1),setTimeout(()=>t(ve)?.focus(),50)}),h(S,V)},Ie=S=>{var V=Mg(),be=mt(V);{var Oe=$e=>{var C=Sg();$n(C,21,()=>t(te),O=>O.id,(O,Q)=>{const pe=L(()=>t(Q).upload?Uv(t(Q).upload):null),k=L(()=>t(Q).upload?Gc(t(Q).upload.state):!1);var $=wg(),z=u($),ne=u(z,!0);c(z);var fe=f(z,2);{var I=Pe=>{var ct=ug();h(Pe,ct)},l=Pe=>{var ct=fg();h(Pe,ct)},_=Pe=>{var ct=pg();dt(2),h(Pe,ct)},A=Pe=>{var ct=bg(),it=mt(ct);Z(it,"aria-valuemin",0),Z(it,"aria-valuemax",100);var We=u(it);c(it);var Ut=f(it,2),fn=u(Ut);c(Ut);var Rn=f(Ut,2);{var Fe=Ee=>{var ae=hg();h(Ee,ae)};w(Rn,Ee=>{t(pe).kind==="finishing"&&Ee(Fe)})}T(()=>{Z(it,"aria-valuenow",t(pe).percent),bo(We,`width: ${t(pe).percent??""}%`),E(fn,`${t(pe).percent??""}%`)}),h(Pe,ct)},N=Pe=>{var ct=xg(),it=mt(ct),We=u(it),Ut=u(We);c(We);var fn=f(We,2);{var Rn=Ue=>{var H=vg();h(Ue,H)},Fe=Ue=>{var H=gg();T(()=>Z(H,"href",t(Q).url)),h(Ue,H)};w(fn,Ue=>{t(pe).pickAgain?Ue(Rn):t(Q).url&&Ue(Fe,1)})}c(it);var Ee=f(it,2);{var ae=Ue=>{var H=mg();M("click",H,()=>Ct(t(Q).id)),h(Ue,H)};w(Ee,Ue=>{t(pe).retry&&t(Q).retryFile&&Ue(ae)})}T(()=>{Z(it,"title",t(pe).message),E(Ut,`⚠️ ${t(pe).message??""}`)}),h(Pe,ct)},de=Pe=>{var ct=yg();h(Pe,ct)};w(fe,Pe=>{t(Q).file?Pe(I):t(pe)?.kind==="pending"||t(pe)?.kind==="indeterminate"?Pe(l,1):t(pe)?.kind==="waiting"?Pe(_,2):t(pe)?.kind==="progress"||t(pe)?.kind==="finishing"?Pe(A,3):t(pe)?.kind==="failed"?Pe(N,4):Pe(de,-1)})}var Te=f(fe,2);{var gt=Pe=>{var ct=_g();M("click",ct,()=>pt(t(Q).id)),h(Pe,ct)};w(Te,Pe=>{t(k)&&Pe(gt)})}var ot=f(Te,2);c($),T(()=>{en($,1,`flex items-center gap-2 rounded border bg-brand-surface-2 px-2.5 py-1.5 text-xs ${t(k)?"border-brand-blue":"border-brand-border"}`),Z(z,"title",t(Q).name),E(ne,t(Q).name)}),M("click",ot,()=>_n(t(Q).id)),h(O,$)}),c(C),h($e,C)};w(be,$e=>{t(te).length>0&&$e(Oe)})}var rt=f(be,2);{var je=$e=>{var C=Tg(),O=f(u(C),2);$n(O,21,P,vr,(Q,pe)=>{var k=kg(),$=u(k,!0);c(k);var z={};T(()=>{E($,t(pe).label),z!==(z=t(pe).value)&&(k.value=(k.__value=t(pe).value)??"")}),h(Q,k)}),c(O),c(C),T(()=>O.disabled=t(Tt)),As(O,re),h($e,C)};w(rt,$e=>{y()&&P().length>0&&$e(je)})}var _e=f(rt,2),me=u(_e),Zt=u(me);{var nn=$e=>{var C=Rg();$n(C,23,()=>t(ut),O=>O.name,(O,Q,pe)=>{var k=Cg(),$=u(k),z=u($),ne=u(z);c(z);var fe=f(z,2);{var I=l=>{var _=Ag(),A=u(_,!0);c(_),T(()=>E(A,t(Q).description)),h(l,_)};w(fe,l=>{t(Q).description&&l(I)})}c($),c(k),T(()=>{Z($,"aria-selected",t(pe)===t(Y)),en($,1,`flex w-full flex-col items-start gap-0.5 px-3 py-1.5 text-left text-sm ${t(pe)===t(Y)?"bg-brand-surface-3 text-brand-text":"text-brand-text-muted hover:bg-brand-surface-3/60"}`),E(ne,`/${t(Q).name??""}`)}),M("mousedown",$,l=>{l.preventDefault(),Ot(t(Q).name)}),Sr("mouseenter",$,()=>p(Y,t(pe),!0)),h(O,k)}),c(C),h($e,C)};w(Zt,$e=>{t(G)&&t(ut).length>0&&$e(nn)})}var Bt=f(Zt,2);yd(Bt),Z(Bt,"rows",1),lr(Bt,$e=>p(ve,$e),()=>t(ve)),c(me);var un=f(me,2),rn=u(un);{var Rt=$e=>{var C=Ig(),O=mt(C),Q=f(O,2);lr(Q,pe=>p(Ce,pe),()=>t(Ce)),T(()=>O.disabled=t(Tt)),M("click",O,()=>{jl(),t(Ce)?.click()}),M("change",Q,qt),h($e,C)};w(rn,$e=>{x()&&$e(Rt)})}var yt=f(rn,2),hn=u(yt);lr(Zv(hn,{get disabled(){return t(Tt)},onSend:Cn,get text(){return t(U)},set text($e){p(U,$e,!0)},get activeEngine(){return t(ze)},set activeEngine($e){p(ze,$e,!0)}}),$e=>p(X,$e,!0),()=>t(X)),c(yt);var ht=f(yt,2),ft=u(ht);{var Dt=$e=>{var C=Vn();T(()=>E(C,e.submitLabel??"Search")),h($e,C)},ln=$e=>{var C=Vn("Steer");h($e,C)},bn=$e=>{var C=Vn("Send");h($e,C)};w(ft,$e=>{y()?$e(Dt):t(Ne)?$e(ln,1):$e(bn,-1)})}c(ht),c(un),c(_e);var xe=f(_e,2),qe=u(xe),bt=u(qe);kt(bt),dt(2),c(qe);var ke=f(qe,2),st=u(ke),sn=u(st,!0);c(st);var Jt=f(st,2),yn=u(Jt);c(Jt);var jt=f(Jt,2),an=f(jt,2);{var Pn=$e=>{var C=Eg();h($e,C)};w(an,$e=>{t(B)||$e(Pn)})}c(ke),c(xe),T($e=>{Bt.disabled=t(Tt),Z(Bt,"placeholder",y()?e.placeholder??"Search the web...":t(Je)?t(Ne)?"Agent is working, Steer to interrupt...":t(He)?"Read-only mode":t(Ke).sessionId?"Type a message...":"Select a session first...":t(Be).connecting?"Reconnecting... you can keep typing":"Disconnected - you can type, sending resumes once reconnected"),ht.disabled=!t(Wt),Z(ht,"title",!y()&&t(Ne)?"Steer the agent now (injected at the next step, before the next model call)":void 0),ia(bt,t(B)),st.disabled=$e,Z(st,"title",t(Je)?"Save this message as a draft instead of sending it":"Drafts are stored on the server, which is not reachable right now"),E(sn,t(le)?"✓ Saved":"💾 Save draft"),Z(Jt,"aria-expanded",t(q)),E(yn,`🗂 Drafts${t(oe).length>0?` (${t(oe).length})`:""}`)},[()=>t(U).trim().length===0||!t(Je)]),Sr("submit",_e,$e=>{$e.preventDefault(),Cn()}),M("keydown",Bt,wn),fr(Bt,()=>t(U),$e=>p(U,$e)),M("change",bt,mn),M("click",st,ce),M("click",Jt,Lt),M("click",jt,()=>p(W,!0)),h(S,V)};w(j,S=>{t(W)?S(ie):S(Ie,-1)})}c(xn),h(n,xn);var De=rr(Nn);return v(),De}pr(["click","mousedown","keydown","change"]);function Lg(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 y=x.parentSessionPath;y&&e.has(y)&&y!==x.path?(r.has(y)||r.set(y,[]),r.get(y).push(x)):s.push(x)}const a=new Map,o=new Set,i=x=>{const y=a.get(x.path);if(y!==void 0)return y;if(o.has(x.path))return x.modified??"";o.add(x.path);let D=x.modified??"";for(const P of r.get(x.path)??[]){const re=i(P);re.localeCompare(D)>0&&(D=re)}return o.delete(x.path),a.set(x.path,D),D},d=(x,y)=>i(y).localeCompare(i(x))||(y.modified??"").localeCompare(x.modified??"")||x.path.localeCompare(y.path),m=[],v=new Set,g=(x,y)=>{if(!v.has(x.path)){v.add(x.path),m.push({session:x,depth:y});for(const D of[...r.get(x.path)??[]].sort(d))g(D,y+1)}};for(const x of[...s].sort(d))g(x,0);for(const x of n)v.has(x.path)||m.push({session:x,depth:0});return m}var Dg=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>'),Pg=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>'),Ng=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>'),Fg=b('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Ug=b('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),zg=b("<option> </option>"),Bg=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>'),jg=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"/>'),Hg=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>'),Wg=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>'),Gg=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>'),qg=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>'),Kg=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>'),Vg=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>'),Yg=b('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),Xg=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>'),Zg=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>'),Jg=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>'),Qg=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>'),em=b('<span class="flex-shrink-0 text-brand-text-muted" title="Forked from the session above" aria-label="Forked session">↳</span>'),tm=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>'),nm=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),rm=b('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),sm=b('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),am=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>'),om=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>'),im=b('<div class="flex-shrink-0"><!></div>'),lm=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>'),cm=b('<div class="px-3 pb-2"><!> <!></div>'),dm=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>'),um=b("<option> </option>"),fm=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>'),pm=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"/>'),hm=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>'),bm=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>'),vm=b('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),gm=b('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),mm=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>'),xm=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>'),ym=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="selectable 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>'),_m=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 el(n,e){nr(e,!0);const r=()=>ye(cl,"$readOnlySessionFolders",x),s=()=>ye(dl,"$sessionFolders",x),a=()=>ye(is,"$activeSessionInfo",x),o=()=>ye(Os,"$isConnected",x),i=()=>ye($s,"$isLoadingSession",x),d=()=>ye(Ls,"$isResyncing",x),m=()=>ye(fo,"$availableModels",x),v=()=>ye(po,"$gitInitDefaultStore",x),g=()=>ye(ba,"$sessionError",x),[x,y]=Nr(),D=[];let P=ir(e,"readOnly",3,!1),re=L(()=>P()?r().folders:s().folders),U=L(()=>P()?r().loading:s().loading);function B(){P()?ll():_s()}let W=L(()=>a().sessionFile),ze=L(o),X=L(i),G=L(d),Y=L(()=>m().models),Ce=Yn({}),he=F(Yn({})),Ae=F(null),te=F(null),Ne=F(""),He=F(Yn([]));Nt(()=>{t(ze)&&(B(),P()||(Rd(),Ts()))});function Ke(j,ie,Ie){if(!Ie)return!0;const De=Ie.toLowerCase();return(j.name||"").toLowerCase().includes(De)||j.firstMessage.toLowerCase().includes(De)||ie.toLowerCase().includes(De)}Nt(()=>{const j=t(Ne),ie=t(re);j?p(He,ie.map(Ie=>({...Ie,sessions:Ie.sessions.filter(De=>Ke(De,Ie.name,j))})).filter(Ie=>Ie.sessions.length>0),!0):(p(He,ie,!0),p(he,{},!0))});function Je(j,ie){ul(j,ie).catch(()=>{})}function Be(j){return t(Ne)?t(he)[j]!==void 0?t(he)[j]:!0:!!Ce[j]}function Qe(j){t(Ne)?t(he)[j]=!Be(j):Ce[j]=!Be(j)}async function ut(j){try{t(W)===j&&(typeof window<"u"&&(window.location.hash=""),br()),await eo(j),t(Ae)===j&&p(Ae,null),_s()}catch(ie){console.error("Failed to delete session:",ie)}}async function Ot(j){try{const ie=j.sessions.map(Ie=>Ie.path);t(W)&&ie.includes(t(W))&&(typeof window<"u"&&(window.location.hash=""),br()),await Promise.all(j.sessions.map(Ie=>eo(Ie.path))),t(te)===j.path&&p(te,null),_s()}catch(ie){console.error("Failed to delete all sessions of folder:",ie)}}function Tt(j){t(W)===j&&!t(X)&&!t(G)||(Lr(),as(j))}let xt=F(!1),Re=F(""),Wt=F(Yn([])),ve=F(!1),$t=F(null),It=F(null),At="",oe=F(""),q=F(!1),tt=F(null),ge=F(!0),le=F("private"),et=F(!1),ee=L(v);Nt(()=>{t(tt)===null&&p(q,t(ee),!0)});let K=F(Yn({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),we=L(()=>t(K).exists!==!0&&t(K).matchingRule&&t(ge)),R=null;async function se(j,ie=!1){if(R&&clearTimeout(R),j===At&&!ie)return;if(At=j,!j.trim()){p(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const De=async()=>{const S=await Zs("");p(Wt,S||[],!0)};ie?await De():R=setTimeout(De,300);return}const Ie=async()=>{const[De,S]=await Promise.all([ol(j),Zs(j)]);p(Wt,S||[],!0),De?(p(K,{exists:De.exists,isGit:De.isGit,resolvedPath:De.resolvedPath,matchingRule:De.matchingRule||null},!0),De.exists||(p(q,t(tt)!==null?t(tt):t(ee),!0),p(ge,!0),De.matchingRule&&p(le,De.matchingRule.visibility,!0))):p(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};ie?await Ie():R=setTimeout(Ie,300)}Nt(()=>{const j=t(Re);se(j,!1)}),Nt(()=>{if(t(Y).length>0&&!t(oe)){const j=t(Y).find(ie=>ie.isDefault);j?p(oe,`${j.provider}:${j.modelId}`):p(oe,`${t(Y)[0].provider}:${t(Y)[0].modelId}`)}});function J(){if(t(Re).trim())if(t(K).exists===!0)p(q,!1),p(ge,!1),t(K).matchingRule&&p(le,t(K).matchingRule.visibility,!0),p(et,!0);else{Lr();const j=t(Re).trim(),ie=t(oe)||void 0,Ie=t(q),De=t(K).matchingRule?t(ge):void 0,S=t(K).matchingRule?t(le):void 0;p(Re,""),p(xt,!1),t(W)?(br(),setTimeout(()=>{wr(j,ie,Ie,De,S)},100)):wr(j,ie,Ie,De,S)}}function Se(){p(et,!1),Lr();const j=t(Re).trim(),ie=t(oe)||void 0,Ie=t(q),De=t(K).matchingRule?t(ge):void 0,S=t(K).matchingRule?t(le):void 0;p(Re,""),p(xt,!1),t(W)?(br(),setTimeout(()=>{wr(j,ie,Ie,De,S)},100)):wr(j,ie,Ie,De,S)}let Le=F(Yn({open:!1,folderPath:"",selected:""}));function nt(j){const ie=t(Y).find(Ie=>Ie.isDefault);p(Le,{open:!0,folderPath:j,selected:ie?`${ie.provider}:${ie.modelId}`:""},!0)}function ce(){t(Le).open=!1}function Ve(){if(!t(Le).open)return;Lr();const j=t(Le).folderPath,ie=t(Le).selected||void 0;ce(),t(W)?(br(),setTimeout(()=>{wr(j,ie)},100)):wr(j,ie)}function at(j){const ie=Date.now()-new Date(j).getTime(),Ie=Math.floor(ie/6e4);if(Ie<1)return"just now";if(Ie<60)return`${Ie}m ago`;const De=Math.floor(Ie/60);return De<24?`${De}h ago`:`${Math.floor(De/24)}d ago`}function wt(j,ie=40){return j.length>ie?j.slice(0,ie)+"...":j}var Et=_m(),Lt=mt(Et),Ft=u(Lt),Xt=u(Ft),zt=u(Xt);kt(zt);var Sn=f(zt,2),mn=u(Sn);c(Sn),c(Xt);var qt=f(Xt,2);{var Kt=j=>{var ie=Dg(),Ie=u(ie);c(ie),T(De=>E(Ie,`🔎 Search all conversations for “${De??""}”`),[()=>t(Ne).trim()]),M("click",ie,()=>e.onSearchAll?.(t(Ne).trim())),h(j,ie)},dn=L(()=>e.onSearchAll&&t(Ne).trim().length>=2);w(qt,j=>{t(dn)&&j(Kt)})}c(Ft);var kn=f(Ft,2),En=u(kn);{var pt=j=>{var ie=Kg(),Ie=u(ie),De=u(Ie),S=u(De,!0);c(De),c(Ie);var V=f(Ie,2);{var be=Oe=>{var rt=qg(),je=u(rt),_e=f(u(je),2),me=u(_e);kt(me),lr(me,xe=>p($t,xe),()=>t($t));var Zt=f(me,2);{var nn=xe=>{var qe=Ng();$n(qe,21,()=>t(Wt),vr,(bt,ke)=>{var st=Pg(),sn=u(st,!0);c(st),T(()=>E(sn,t(ke))),M("click",st,()=>{p(Re,t(ke),!0),se(t(ke),!0),t($t)?.focus()}),h(bt,st)}),c(qe),h(xe,qe)};w(Zt,xe=>{t(ve)&&t(Wt).length>0&&xe(nn)})}c(_e),lr(_e,xe=>p(It,xe),()=>t(It));var Bt=f(_e,2);{var un=xe=>{var qe=Ug(),bt=f(u(qe));{var ke=st=>{var sn=Fg();h(st,sn)};w(bt,st=>{t(K).isGit&&st(ke)})}c(qe),h(xe,qe)};w(Bt,xe=>{t(K).exists===!0&&xe(un)})}c(je);var rn=f(je,2),Rt=f(u(rn),2);{var yt=xe=>{var qe=Bg();$n(qe,21,()=>t(Y),vr,(bt,ke)=>{var st=zg(),sn=u(st);c(st);var Jt={};T(()=>{E(sn,`${t(ke).label??""}${t(ke).isDefault?" (default)":""}`),Jt!==(Jt=`${t(ke).provider}:${t(ke).modelId}`)&&(st.value=st.__value=`${t(ke).provider}:${t(ke).modelId}`)}),h(bt,st)}),c(qe),As(qe,()=>t(oe),bt=>p(oe,bt)),h(xe,qe)},hn=xe=>{var qe=jg();kt(qe),fr(qe,()=>t(oe),bt=>p(oe,bt)),h(xe,qe)};w(Rt,xe=>{t(Y).length>0?xe(yt):xe(hn,-1)})}c(rn);var ht=f(rn,2);{var ft=xe=>{var qe=Wg(),bt=u(qe),ke=u(bt);kt(ke);var st=f(ke,2),sn=u(st);c(st),c(bt);var Jt=f(bt,2);{var yn=jt=>{var an=Hg(),Pn=f(u(an),2),$e=u(Pn);kt($e),$e.value=$e.__value="private",dt(),c(Pn);var C=f(Pn,2),O=u(C);kt(O),O.value=O.__value="public",dt(),c(C),c(an),Pr(D,[],$e,()=>t(le),Q=>p(le,Q)),Pr(D,[],O,()=>t(le),Q=>p(le,Q)),h(jt,an)};w(Jt,jt=>{t(ge)&&jt(yn)})}c(qe),T(()=>E(sn,`Create remote ${t(K).matchingRule.provider??""} repository`)),Jn(ke,()=>t(ge),jt=>p(ge,jt)),h(xe,qe)};w(ht,xe=>{t(K).exists!==!0&&t(K).matchingRule&&xe(ft)})}var Dt=f(ht,2);{var ln=xe=>{var qe=Gg(),bt=u(qe);kt(bt),dt(2),c(qe),M("change",bt,ke=>{p(tt,ke.currentTarget.checked,!0)}),Jn(bt,()=>t(q),ke=>p(q,ke)),h(xe,qe)};w(Dt,xe=>{t(K).exists!==!0&&(!t(K).matchingRule||!t(ge))&&xe(ln)})}var bn=f(Dt,2);c(rt),T(xe=>{en(me,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(we)?"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"}`),bn.disabled=xe},[()=>!t(Re).trim()]),Sr("submit",rt,xe=>{xe.preventDefault(),J()}),Sr("focus",me,()=>{p(ve,!0),se(t(Re),!0)}),Sr("blur",me,xe=>{t(It)&&t(It).contains(xe.relatedTarget)||p(ve,!1)}),M("keydown",me,xe=>{xe.key==="Escape"&&p(ve,!1)}),fr(me,()=>t(Re),xe=>p(Re,xe)),h(Oe,rt)};w(V,Oe=>{t(xt)&&Oe(be)})}c(ie),T(()=>E(S,t(xt)?"▼ Close Create Session":"✚ Create New Session")),M("click",Ie,()=>p(xt,!t(xt))),h(j,ie)};w(En,j=>{P()||j(pt)})}var Ct=f(En,2);{var _n=j=>{var ie=Vg();h(j,ie)},Cn=j=>{var ie=Yg(),Ie=u(ie,!0);c(ie),T(()=>E(Ie,t(Ne)?"No sessions match your filter":"No sessions found")),h(j,ie)},wn=j=>{var ie=ur(),Ie=mt(ie);$n(Ie,17,()=>t(He),De=>De.path,(De,S)=>{var V=dm(),be=u(V),Oe=u(be),rt=f(Oe,2),je=u(rt),_e=u(je),me=u(_e,!0);c(_e);var Zt=f(_e,2);{var nn=ft=>{var Dt=Xg();h(ft,Dt)};w(Zt,ft=>{t(S).missing&&ft(nn)})}c(je);var Bt=f(je,2),un=u(Bt,!0);c(Bt),c(rt);var rn=f(rt,2),Rt=u(rn,!0);c(rn),c(be);var yt=f(be,2);{var hn=ft=>{var Dt=cm(),ln=u(Dt);{var bn=qe=>{var bt=Qg(),ke=u(bt),st=f(ke,2),sn=u(st);{var Jt=jt=>{var an=Zg(),Pn=u(an),$e=f(Pn,2);c(an),M("click",Pn,C=>{C.stopPropagation(),Ot(t(S))}),M("click",$e,C=>{C.stopPropagation(),p(te,null)}),h(jt,an)},yn=jt=>{var an=Jg();M("click",an,Pn=>{Pn.stopPropagation(),p(te,t(S).path,!0)}),h(jt,an)};w(sn,jt=>{t(te)===t(S).path?jt(Jt):jt(yn,-1)})}c(st),c(bt),M("click",ke,()=>nt(t(S).path)),h(qe,bt)};w(ln,qe=>{P()||qe(bn)})}var xe=f(ln,2);$n(xe,17,()=>Lg(t(S).sessions),({session:qe,depth:bt})=>qe.path,(qe,bt)=>{let ke=()=>t(bt).session,st=()=>t(bt).depth;var sn=lm(),Jt=u(sn);{var yn=A=>{var N=em();h(A,N)};w(Jt,A=>{st()>0&&A(yn)})}var jt=f(Jt,2),an=u(jt);{var Pn=A=>{var N=tm();h(A,N)},$e=A=>{var N=nm();h(A,N)},C=A=>{var N=rm();h(A,N)};w(an,A=>{ke().isWorking?A(Pn):ke().isActive?A($e,1):A(C,-1)})}var O=f(an,2),Q=u(O),pe=u(Q,!0);c(Q);var k=f(Q,2),$=u(k);c(k),c(O);var z=f(O,2);{var ne=A=>{var N=sm(),de=u(N,!0);c(N),T(()=>E(de,ke().clientCount)),h(A,N)};w(z,A=>{ke().clientCount>0&&A(ne)})}c(jt);var fe=f(jt,2),I=u(fe,!0);c(fe);var l=f(fe,2);{var _=A=>{var N=im(),de=u(N);{var Te=ot=>{var Pe=am(),ct=u(Pe),it=f(ct,2);c(Pe),M("click",ct,We=>{We.stopPropagation(),ut(ke().path)}),M("click",it,We=>{We.stopPropagation(),p(Ae,null)}),h(ot,Pe)},gt=ot=>{var Pe=om();M("click",Pe,ct=>{ct.stopPropagation(),p(Ae,ke().path,!0)}),h(ot,Pe)};w(de,ot=>{t(Ae)===ke().path?ot(Te):ot(gt,-1)})}c(N),h(A,N)};w(l,A=>{P()||A(_)})}c(sn),T((A,N,de)=>{bo(sn,st()>0?`margin-left: ${st()*.85}rem`:""),en(sn,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 ${st()>0?"border-l border-brand-border/60 pl-2":""} ${t(W)===ke().path?"bg-brand-surface-3":""}`),Z(jt,"href",`#${A??""}`),E(pe,N),E($,`${de??""} · ${ke().messageCount??""}
|
|
102
|
-
msgs`),en(fe,1,`flex-shrink-0 p-1 text-sm focus:outline-none ${ke().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"}`),Z(fe,"title",ke().starred?"Unstar":"Star to come back to it later"),Z(fe,"aria-label",ke().starred?"Unstar session":"Star session"),E(I,ke().starred?"★":"☆")},[()=>encodeURIComponent(ke().id),()=>ke().name||wt(ke().firstMessage)||"Empty session",()=>at(ke().modified)]),M("click",jt,A=>{A.button===0&&!A.ctrlKey&&!A.metaKey&&!A.altKey&&!A.shiftKey&&(A.preventDefault(),Tt(ke().path))}),M("click",fe,A=>{A.stopPropagation(),Je(ke().path,!ke().starred)}),h(qe,sn)}),c(Dt),h(ft,Dt)},ht=L(()=>Be(t(S).path));w(yt,ft=>{t(ht)&&ft(hn)})}c(V),T(ft=>{en(Oe,1,`text-xs text-brand-text-muted transition-transform ${ft??""}`),E(me,t(S).name),E(un,t(S).path),E(Rt,t(S).sessions.length)},[()=>Be(t(S).path)?"rotate-90":""]),M("click",be,()=>Qe(t(S).path)),h(De,V)}),h(j,ie)};w(Ct,j=>{t(U)&&t(He).length===0?j(_n):t(He).length===0?j(Cn,1):j(wn,-1)})}c(kn),c(Lt);var Nn=f(Lt,2);{var xn=j=>{var ie=hm(),Ie=u(ie),De=f(u(Ie),2),S=f(u(De),2),V=u(S,!0);c(S),c(De);var be=f(De,2),Oe=f(u(be),2);{var rt=nn=>{var Bt=fm();$n(Bt,21,()=>t(Y),vr,(un,rn)=>{var Rt=um(),yt=u(Rt);c(Rt);var hn={};T(()=>{E(yt,`${t(rn).label??""}${t(rn).isDefault?" (default)":""}`),hn!==(hn=`${t(rn).provider}:${t(rn).modelId}`)&&(Rt.value=Rt.__value=`${t(rn).provider}:${t(rn).modelId}`)}),h(un,Rt)}),c(Bt),As(Bt,()=>t(Le).selected,un=>t(Le).selected=un),h(nn,Bt)},je=nn=>{var Bt=pm();kt(Bt),fr(Bt,()=>t(Le).selected,un=>t(Le).selected=un),h(nn,Bt)};w(Oe,nn=>{t(Y).length>0?nn(rt):nn(je,-1)})}c(be);var _e=f(be,2),me=u(_e),Zt=f(me,2);c(_e),c(Ie),c(ie),T(()=>E(V,t(Le).folderPath)),M("click",ie,ce),M("click",Ie,nn=>nn.stopPropagation()),M("click",me,ce),M("click",Zt,Ve),h(j,ie)};w(Nn,j=>{t(Le).open&&j(xn)})}var vn=f(Nn,2);{var Fn=j=>{var ie=bm(),Ie=u(ie),De=u(Ie,!0);c(Ie);var S=f(Ie,2);c(ie),T(()=>E(De,g())),M("click",S,()=>Lr()),h(j,ie)};w(vn,j=>{g()&&j(Fn)})}var Vt=f(vn,2);{var qn=j=>{var ie=ym(),Ie=u(ie),De=f(u(Ie),2),S=f(u(De)),V=u(S,!0);c(S),dt(),c(De);var be=f(De,2),Oe=u(be),rt=u(Oe);kt(rt);var je=f(rt,2),_e=f(u(je));{var me=yt=>{var hn=vm();h(yt,hn)},Zt=yt=>{var hn=gm();h(yt,hn)};w(_e,yt=>{t(K).isGit?yt(me):yt(Zt,-1)})}c(je),c(Oe);var nn=f(Oe,2);{var Bt=yt=>{var hn=xm(),ht=u(hn),ft=u(ht);kt(ft);var Dt=f(ft,2),ln=u(Dt);c(Dt),c(ht);var bn=f(ht,2);{var xe=qe=>{var bt=mm(),ke=f(u(bt),2),st=u(ke);kt(st),st.value=st.__value="private",dt(),c(ke);var sn=f(ke,2),Jt=u(sn);kt(Jt),Jt.value=Jt.__value="public",dt(),c(sn),c(bt),Pr(D,[],st,()=>t(le),yn=>p(le,yn)),Pr(D,[],Jt,()=>t(le),yn=>p(le,yn)),h(qe,bt)};w(bn,qe=>{t(ge)&&qe(xe)})}c(hn),T(()=>E(ln,`Create remote ${t(K).matchingRule.provider??""} repository`)),Jn(ft,()=>t(ge),qe=>p(ge,qe)),h(yt,hn)};w(nn,yt=>{t(K).matchingRule&&yt(Bt)})}c(be);var un=f(be,2),rn=u(un),Rt=f(rn,2);c(un),c(Ie),c(ie),T(()=>{E(V,t(Re)),rt.disabled=t(K).isGit}),Jn(rt,()=>t(q),yt=>p(q,yt)),M("click",rn,()=>p(et,!1)),M("click",Rt,Se),h(j,ie)};w(Vt,j=>{t(et)&&j(qn)})}T(()=>{il(zt,t(Ne)),en(mn,1,ho(t(U)?"animate-spin":""))}),M("input",zt,j=>p(Ne,j.currentTarget.value,!0)),M("click",Sn,()=>B()),h(n,Et),rr(),y()}pr(["input","click","keydown","change"]);const wm="",Ua="";function qc(n){if(!n)return[];const e=[];let r=n;for(;r.length>0;){const s=r.indexOf(wm);if(s<0){Hs(e,r.split(Ua).join(""),!1);break}Hs(e,r.slice(0,s).split(Ua).join(""),!1),r=r.slice(s+1);const a=r.indexOf(Ua);if(a<0){Hs(e,r,!0);break}Hs(e,r.slice(0,a),!0),r=r.slice(a+1)}return e}function Hs(n,e,r){e&&n.push({text:e,match:r})}function Sm(n){return qc(n).map(e=>e.text).join("")}function km(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 tl(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 a=Math.round(s/60);if(a<60)return`${a}m ago`;const o=Math.round(a/60);if(o<24)return`${o}h ago`;const i=Math.round(o/24);if(i<30)return`${i}d ago`;const d=Math.round(i/30);return d<12?`${d}mo ago`:`${Math.round(d/12)}y ago`}var Tm=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>'),Am=b('<div class="p-3 text-xs text-brand-text-muted"></div>'),Cm=b('<div class="p-3 text-xs text-brand-text-muted">Searching…</div>'),Rm=b('<div class="break-all opacity-70"> </div>'),Im=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,
|
|
103
|
-
which has not been built on this machine. Building it takes about a minute
|
|
104
|
-
and is deliberately never done from here, because it would freeze the server
|
|
105
|
-
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>`),Em=b('<div class="p-3 text-xs text-rose-400"> </div>'),Mm=b('<div class="mt-1 opacity-70"> </div>'),Om=b('<div class="p-3 text-xs text-brand-text-muted"> <!></div>'),$m=b("<span> </span>"),Lm=b('<span class="text-amber-400" title="Read-only session">👁️</span>'),Dm=b('<mark class="rounded bg-brand-blue/30 px-0.5 text-brand-text"> </mark>'),Pm=b('<div class="mt-0.5 border-l border-brand-border/40 pl-2"></div>'),Nm=b('<button class="mt-1 px-1.5 text-[10px] text-brand-blue hover:underline"> </button> <!>',1),Fm=b('<div class="px-1.5 pt-0.5 text-[10px] text-brand-text-muted"> </div>'),Um=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>'),zm=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),Bm=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
|
|
106
|
-
prefixes.</div></div> <div class="flex-1 overflow-y-auto"><!></div></div>`);function jm(n,e){nr(e,!0);const r=()=>ye(is,"$activeSessionInfo",o),s=()=>ye($s,"$isLoadingSession",o),a=()=>ye(Ls,"$isResyncing",o),[o,i]=Nr(),d=(oe,q=ni,tt=ni)=>{var ge=Tm(),le=u(ge),et=u(le,!0);c(le);var ee=f(le,2),K=u(ee),we=u(K,!0);c(K);var R=f(K,2),se=u(R);c(R),c(ee),c(ge),T((J,Se)=>{en(ge,1,`flex w-full items-start gap-2 rounded px-1.5 py-1 text-left transition-colors hover:bg-brand-surface-3/40 ${tt()??""}`),Z(ge,"title",q().sessionPath),E(et,q().isRoot?"•":"↳"),E(we,J),E(se,`${q().folderName??""} · ${Se??""} · +${q().after??""}
|
|
107
|
-
after`)},[()=>Ne(q()),()=>tl(q().lastActivity)]),M("click",ge,()=>Ae(q())),h(oe,ge)};let m=ir(e,"readOnly",3,!1),v=ir(e,"initialQuery",3,""),g=F(Yn(Cr(()=>v()))),x=F(null),y=F(!1),D=F(null),P=F(Yn({})),re=L(()=>r().sessionFile),U=L(s),B=L(a);const W=2,ze=250;let X=null,G=!1;Nt(()=>{t(D)?.focus(),!G&&(G=!0,t(g).trim().length>=W&&(p(y,!0),Ce(t(g))))});function Y(oe){if(p(g,oe,!0),X&&clearTimeout(X),oe.trim().length<W){p(y,!1),p(x,null);return}p(y,!0),X=setTimeout(()=>{X=null,Ce(oe)},ze)}async function Ce(oe){const q=await Id(oe.trim(),m()?"readonly":"default");q!==null&&(p(x,q,!0),p(y,!1),p(P,{},!0))}function he(oe){oe.preventDefault(),X&&clearTimeout(X),!(t(g).trim().length<W)&&(p(y,!0),Ce(t(g)))}function Ae(oe){if(t(re)===oe.sessionPath&&!t(U)&&!t(B)){e.onOpened?.();return}Lr(),as(oe.sessionPath),e.onOpened?.()}function te(oe,q){return`${oe.entryKey}-${q}`}function Ne(oe){return oe.name||`${oe.folderName} · ${oe.entryCount} entries`}var He=Bm(),Ke=u(He),Je=u(Ke),Be=u(Je);kt(Be),lr(Be,oe=>p(D,oe),()=>t(D));var Qe=f(Be,2),ut=u(Qe);c(Qe),c(Je),dt(2),c(Ke);var Ot=f(Ke,2),Tt=u(Ot);{var xt=oe=>{var q=Am();q.textContent=`Type at least 2 characters to search everything ever said in any
|
|
108
|
-
session.`,h(oe,q)},Re=L(()=>t(g).trim().length<W),Wt=oe=>{var q=Cm();h(oe,q)},ve=oe=>{var q=Im(),tt=f(u(q),8);{var ge=le=>{var et=Rm(),ee=u(et);c(et),T(()=>E(ee,`Expected at ${t(x).index.path??""}`)),h(le,et)};w(tt,le=>{t(x).index?.path&&le(ge)})}c(q),h(oe,q)},$t=oe=>{var q=Em(),tt=u(q,!0);c(q),T(()=>E(tt,t(x).message||"Search is unavailable.")),h(oe,q)},It=oe=>{var q=Om(),tt=u(q),ge=f(tt);{var le=et=>{var ee=Mm(),K=u(ee);c(ee),T(()=>E(K,`${t(x).hiddenHits??""} match${t(x).hiddenHits===1?"":"es"} were in
|
|
109
|
-
sessions not shown here.`)),h(et,ee)};w(ge,et=>{t(x).hiddenHits&&et(le)})}c(q),T(()=>E(tt,`No matches for “${t(x).query??""}”. `)),h(oe,q)},At=oe=>{var q=zm(),tt=mt(q),ge=u(tt),le=u(ge),et=f(le);{var ee=se=>{var J=Vn();T(()=>E(J,`· ${t(x).hiddenHits??""} hidden`)),h(se,J)};w(et,se=>{t(x).hiddenHits&&se(ee)})}c(ge);var K=f(ge,2);{var we=se=>{var J=$m(),Se=u(J);c(J),T(Le=>{Z(J,"title",t(x).index.path),E(Se,`${Le??""} sessions indexed`)},[()=>t(x).index.files.toLocaleString()]),h(se,J)};w(K,se=>{t(x).index&&se(we)})}c(tt);var R=f(tt,2);$n(R,19,()=>t(x).hits,(se,J)=>te(se,J),(se,J,Se)=>{const Le=L(()=>te(t(J),t(Se))),nt=L(()=>t(J).threads[0]),ce=L(()=>t(J).threads.slice(1));var Ve=Um(),at=u(Ve),wt=u(at),Et=u(wt,!0);c(wt);var Lt=f(wt,2),Ft=u(Lt,!0);c(Lt);var Xt=f(Lt,2);{var zt=pt=>{var Ct=Lm();h(pt,Ct)};w(Xt,pt=>{t(nt)?.readOnly&&pt(zt)})}c(at);var Sn=f(at,2);$n(Sn,21,()=>qc(t(J).snippet),vr,(pt,Ct)=>{var _n=ur(),Cn=mt(_n);{var wn=xn=>{var vn=Dm(),Fn=u(vn,!0);c(vn),T(()=>E(Fn,t(Ct).text)),h(xn,vn)},Nn=xn=>{var vn=Vn();T(()=>E(vn,t(Ct).text)),h(xn,vn)};w(Cn,xn=>{t(Ct).match?xn(wn):xn(Nn,-1)})}h(pt,_n)}),c(Sn);var mn=f(Sn,2);{var qt=pt=>{d(pt,()=>t(nt),()=>"mt-1.5")};w(mn,pt=>{t(nt)&&pt(qt)})}var Kt=f(mn,2);{var dn=pt=>{var Ct=Nm(),_n=mt(Ct),Cn=u(_n);c(_n);var wn=f(_n,2);{var Nn=xn=>{var vn=Pm();$n(vn,21,()=>t(ce),Fn=>Fn.sessionPath,(Fn,Vt)=>{d(Fn,()=>t(Vt),()=>"")}),c(vn),h(xn,vn)};w(wn,xn=>{t(P)[t(Le)]&&xn(Nn)})}T(()=>E(Cn,`matched in shared history · carried by ${t(J).threadTotal??""} sessions
|
|
110
|
-
${t(P)[t(Le)]?"▲":"▼"}`)),M("click",_n,()=>t(P)[t(Le)]=!t(P)[t(Le)]),h(pt,Ct)};w(Kt,pt=>{t(ce).length>0&&pt(dn)})}var kn=f(Kt,2);{var En=pt=>{var Ct=Fm(),_n=u(Ct);c(Ct),T(Cn=>{Z(Ct,"title",Cn),E(_n,`+${t(J).otherHits??""} more match${t(J).otherHits===1?"":"es"} in this
|
|
111
|
-
conversation`)},[()=>Sm(t(J).snippet)]),h(pt,Ct)};w(kn,pt=>{t(J).otherHits>0&&pt(En)})}c(Ve),T((pt,Ct)=>{E(Et,pt),E(Ft,Ct)},[()=>km(t(J).kind,t(J).tool),()=>tl(t(J).ts)]),h(se,Ve)}),T(()=>E(le,`${t(x).hits.length??""} result${t(x).hits.length===1?"":"s"} `)),h(oe,q)};w(Tt,oe=>{t(Re)?oe(xt):t(y)&&!t(x)?oe(Wt,1):t(x)?.status==="not-indexed"?oe(ve,2):t(x)?.status==="unavailable"||t(x)?.status==="error"?oe($t,3):t(x)&&t(x).hits.length===0?oe(It,4):t(x)&&oe(At,5)})}c(Ot),c(He),T(()=>{Z(Be,"placeholder",m()?"Search read-only conversations...":"Search all conversations..."),il(Be,t(g)),en(ut,1,ho(t(y)?"animate-pulse":""))}),Sr("submit",Je,he),M("input",Be,oe=>Y(oe.currentTarget.value)),h(n,He),rr(),i()}pr(["click","input"]);var Hm=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
|
|
112
|
-
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 Wm(n,e){nr(e,!0);const r=()=>ye(bc,"$sudoPrompt",s),[s,a]=Nr();let o=L(r),i=F(""),d=F(null),m=F(null);Nt(()=>{const re=t(o)?.promptId??null;re!==t(m)&&(p(m,re,!0),p(i,""),re&&queueMicrotask(()=>t(d)?.focus()))});function v(){t(o)&&(ac(t(i)),p(i,""))}function g(){oc(),p(i,"")}function x(re){re.key==="Enter"?(re.preventDefault(),v()):re.key==="Escape"&&(re.preventDefault(),g())}var y=ur(),D=mt(y);{var P=re=>{var U=Hm(),B=u(U),W=f(u(B),4),ze=u(W,!0);c(W);var X=f(W,2);kt(X),lr(X,he=>p(d,he),()=>t(d));var G=f(X,2),Y=u(G),Ce=f(Y,2);c(G),c(B),c(U),T(()=>E(ze,t(o).command)),M("keydown",X,x),fr(X,()=>t(i),he=>p(i,he)),M("click",Y,g),M("click",Ce,v),h(re,U)};w(D,re=>{t(o)&&re(P)})}h(n,y),rr(),a()}pr(["keydown","click"]);var Gm=b('<div class="h-full w-1/3 animate-pulse rounded bg-brand-blue/60"></div>'),qm=b('<div class="h-full rounded bg-gradient-to-r from-brand-cyan to-brand-blue transition-all"></div>'),Km=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),Vm=b('<div class="mt-2 text-xs text-brand-text-muted"> </div>'),Ym=b(`<div class="mt-1 text-[11px] text-brand-text-muted">Each submodule is counted separately and has its own progress above, so
|
|
113
|
-
there is no single overall percentage.</div>`),Xm=b("<!> <!>",1);function Kc(n,e){nr(e,!0);let r=L(()=>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 a(y){return s[y]??y}function o(y){return y==="repository"?"the repository":`submodule ${y}`}var i=Xm(),d=mt(i);{var m=y=>{const D=L(()=>e.job.progress);var P=Km(),re=mt(P),U=u(re),B=u(U);c(U);var W=f(U,2),ze=u(W,!0);c(W),c(re);var X=f(re,2),G=u(X);{var Y=te=>{var Ne=Gm();h(te,Ne)},Ce=te=>{var Ne=qm();T(He=>bo(Ne,He),[()=>`width: ${Math.max(0,Math.min(100,t(D).percent??0))}%`]),h(te,Ne)};w(G,te=>{t(D).indeterminate?te(Y):te(Ce,-1)})}c(X);var he=f(X,2),Ae=u(he,!0);c(he),T((te,Ne)=>{E(B,`${te??""}${Ne??""}`),E(ze,t(D).indeterminate?"no percentage":`${t(D).percent}%`),E(Ae,t(D).text)},[()=>a(t(D).phase),()=>t(r)?"":` · ${o(t(D).scope)}`]),h(y,P)},v=y=>{var D=Vm(),P=u(D,!0);c(D),T(()=>E(P,t(r)?"Starting...":"Starting the clone (git has not reported anything measurable yet)...")),h(y,D)};w(d,y=>{e.job?.progress?y(m):y(v,-1)})}var g=f(d,2);{var x=y=>{var D=Ym();h(y,D)};w(g,y=>{t(r)||y(x)})}h(n,i),rr()}var Zm=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),Jm=b('<div class="mt-2 text-xs text-brand-text-muted"> </div>'),Qm=b('<div class="mt-2 text-xs text-brand-text-muted">Cloning <span class="font-mono break-all text-brand-text"> </span></div>'),ex=b(`<div class="mt-1 text-xs text-yellow-300">A clone of <span class="font-mono break-all"> </span> was
|
|
114
|
-
already running for this folder, so your Clone joined it. The URL you typed
|
|
115
|
-
was NOT used; cancel it if you meant a different repository.</div>`),tx=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),nx=b('<div class="mt-2 text-xs text-brand-text-muted"> </div>'),rx=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>'),sx=b('<button type="button" class="mt-1 underline opacity-80 hover:opacity-100"> </button> <!>',1),ax=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>'),ox=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>'),ix=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>'),lx=b('<div class="mt-1 flex flex-wrap gap-1"></div>'),cx=b(`<div class="mt-1 text-[11px] text-brand-text-muted">No repository could be worked out for this folder. Paste the SSH URL
|
|
116
|
-
to clone.</div>`),dx=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>'),ux=b(`<div class="text-[11px] text-brand-text-muted">Makes the folder and any missing parents. Nothing is downloaded, so
|
|
117
|
-
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),fx=b(`<div class="mt-1 text-xs text-brand-text-muted">The conversation is readable, but nothing can be run here until the
|
|
118
|
-
folder is restored. Clone the repository back into that path, then
|
|
119
|
-
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),px=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 hx(n,e){nr(e,!0);const r=()=>ye(Mo,"$folderMissing",o),s=()=>ye(Oo,"$restoreState",o),a=()=>ye(po,"$gitInitDefaultStore",o),[o,i]=Nr();let d=L(r),m=L(s),v=L(()=>t(m)?.job??null),g=L(()=>t(v)?.state==="running"),x=L(()=>t(v)?.state==="done"),y=L(()=>t(v)?.state==="failed"?t(v).failure:void 0),D=L(()=>t(m)?.rejection??null),P=F(!1),re=L(()=>(!!t(m)?.requestedUrl||t(P))&&!t(v)&&!t(m)?.rejection),U=L(()=>t(m)?.joined&&t(v)?.url&&t(m).requestedUrl&&t(v).url!==t(m).requestedUrl?t(v).url:null),B=L(()=>t(v)?.kind==="create"),W=F(""),ze=F(!1),X=F(Yn([])),G=F(!1),Y=F(!1),Ce=F(!1),he=F(!1),Ae=F(null),te="";Nt(()=>{const Qe=t(d)?.cwd;!Qe||Qe===te||(te=Qe,p(W,""),p(ze,!1),p(X,[],!0),p(Ce,!1),p(Ae,null),p(P,!1),Ts(),p(G,!0),Ed(Qe).then(ut=>{p(X,ut,!0),!t(ze)&&ut.length>0&&p(W,ut[0].url,!0)}).finally(()=>{p(G,!1)}))}),Nt(()=>{const Qe=a();p(he,t(Ae)===null?Qe:t(Ae),!0)});function Ne(){t(W).trim()&&(p(Y,!1),p(P,!1),Za("clone",t(W)))}function He(){p(Y,!1),p(P,!0),Za("create",void 0,t(he))}var Ke=ur(),Je=mt(Ke);{var Be=Qe=>{var ut=px(),Ot=f(u(ut),2),Tt=u(Ot,!0);c(Ot);var xt=f(Ot,2);{var Re=$t=>{var It=Zm(),At=f(mt(It),2);M("click",At,()=>lc()),h($t,It)},Wt=$t=>{var It=tx(),At=mt(It);{var oe=ee=>{var K=Jm(),we=u(K);c(K),T(()=>E(we,`Creating the folder${t(v)?.gitInit?" and initialising a git repository in it":""}`)),h(ee,K)},q=ee=>{var K=Qm(),we=f(u(K)),R=u(we,!0);c(we),c(K),T(()=>E(R,t(v)?.url??"")),h(ee,K)};w(At,ee=>{t(B)?ee(oe):ee(q,-1)})}var tt=f(At,2);{var ge=ee=>{var K=ex(),we=f(u(K)),R=u(we,!0);c(we),dt(),c(K),T(()=>E(R,t(U))),h(ee,K)};w(tt,ee=>{t(U)&&ee(ge)})}var le=f(tt,2);Kc(le,{get job(){return t(v)}});var et=f(le,2);M("click",et,()=>Io()),h($t,It)},ve=$t=>{var It=fx(),At=f(mt(It),2);{var oe=ce=>{var Ve=nx(),at=u(Ve);c(Ve),T(()=>E(at,`The ${t(B)?"folder creation":"clone"} was cancelled and the folder
|
|
120
|
-
it had created was removed.`)),h(ce,Ve)};w(At,ce=>{t(v)?.state==="cancelled"&&ce(oe)})}var q=f(At,2);{var tt=ce=>{var Ve=ax(),at=u(Ve),wt=u(at,!0);c(at);var Et=f(at,2);{var Lt=Ft=>{var Xt=sx(),zt=mt(Xt),Sn=u(zt);c(zt);var mn=f(zt,2);{var qt=Kt=>{var dn=rx(),kn=u(dn,!0);c(dn),T(()=>E(kn,t(y).stderr)),h(Kt,dn)};w(mn,Kt=>{t(Y)&&Kt(qt)})}T(()=>E(Sn,`${t(Y)?"Hide":"Show"} git output`)),M("click",zt,()=>p(Y,!t(Y))),h(Ft,Xt)};w(Et,Ft=>{t(y).stderr&&Ft(Lt)})}c(Ve),T(()=>E(wt,t(y).message)),h(ce,Ve)};w(q,ce=>{t(y)&&ce(tt)})}var ge=f(q,2);{var le=ce=>{var Ve=ox(),at=u(Ve,!0);c(Ve),T(()=>E(at,t(D).message)),h(ce,Ve)};w(ge,ce=>{t(D)&&ce(le)})}var et=f(ge,4);kt(et);var ee=f(et,2);{var K=ce=>{var Ve=lx();$n(Ve,21,()=>t(X),at=>at.url,(at,wt)=>{var Et=ix(),Lt=u(Et,!0);c(Et),T(()=>E(Lt,t(wt).url)),M("click",Et,()=>{p(W,t(wt).url,!0),p(ze,!0)}),h(at,Et)}),c(Ve),h(ce,Ve)},we=ce=>{var Ve=cx();h(ce,Ve)};w(ee,ce=>{t(X).length>1?ce(K):!t(G)&&t(X).length===0&&ce(we,1)})}var R=f(ee,2),se=u(R,!0);c(R);var J=f(R,2),Se=u(J);{var Le=ce=>{var Ve=dx();M("click",Ve,()=>p(Ce,!0)),h(ce,Ve)},nt=ce=>{var Ve=ux(),at=f(mt(Ve),2),wt=u(at);kt(wt),dt(2),c(at);var Et=f(at,2),Lt=u(Et,!0);c(Et),T(()=>{ia(wt,t(he)),Et.disabled=t(re),E(Lt,t(re)?"Creating...":"Create folder")}),M("change",wt,Ft=>p(Ae,Ft.currentTarget.checked,!0)),M("click",Et,He),h(ce,Ve)};w(Se,ce=>{t(Ce)?ce(nt,-1):ce(Le)})}c(J),T(ce=>{Z(et,"placeholder",t(G)?"Looking for the repository...":"git@github.com:owner/repo.git"),R.disabled=ce,E(se,t(re)?"Starting...":"Clone repository")},[()=>!t(W).trim()||t(re)]),M("input",et,()=>p(ze,!0)),M("keydown",et,ce=>{ce.key==="Enter"&&Ne()}),fr(et,()=>t(W),ce=>p(W,ce)),M("click",R,Ne),h($t,It)};w(xt,$t=>{t(x)?$t(Re):t(g)?$t(Wt,1):$t(ve,-1)})}c(ut),T(()=>E(Tt,t(d).cwd)),h(Qe,ut)};w(Je,Qe=>{t(d)&&Qe(Be)})}h(n,Ke),rr(),i()}pr(["click","input","keydown","change"]);var bx=b('<div class="mt-2 font-mono text-xs break-all text-brand-text-muted"> </div>'),vx=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
|
|
121
|
-
nothing to wait for afterwards. It keeps running on the server if this
|
|
122
|
-
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>`),gx=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>'),mx=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),xx=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>'),yx=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),_x=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>'),wx=b('<span class="text-brand-text-muted/70"> </span>'),Sx=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),kx=b('<div class="truncate text-xs text-brand-text-muted"> </div>'),Tx=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>'),Ax=b('<div class="selectable mt-2 text-xs text-rose-400"> </div>'),Cx=b('<span class="ml-auto truncate text-[10px] font-normal text-brand-text-muted"> </span>'),Rx=b("<button><span>🧭</span> <span>Assistant</span> <!> <span>→</span></button>"),Ix=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),Ex=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>'),Mx=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),Ox=b('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span> <span class="selectable 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),$x=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>'),Lx=b('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Dx=b('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Px=b('<span class="text-sm text-brand-text-muted">Not connected</span>'),Nx=b('<div class="flex min-w-0 items-center gap-2"><!></div>'),Fx=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>'),Ux=b("<option> </option>"),zx=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>'),Bx=b('<span class="truncate text-brand-text-muted"> </span>'),jx=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>'),Hx=b('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),Wx=b('<button type="button" class="flex flex-shrink-0 items-center justify-center rounded border border-brand-border bg-brand-surface-2 px-2 py-1 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text" title="Reset the assistant: start a fresh session (its memory lives in its folder)" aria-label="Reset the assistant">↺ Reset</button>'),Gx=b('<button type="button"> </button>'),qx=b('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),Kx=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>'),Vx=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>'),Yx=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>'),Xx=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>'),Zx=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>'),Jx=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">Open current session</button>'),Qx=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">The assistant was reset: this is an earlier assistant session,
|
|
123
|
-
read-only history.</span> <!></div>`),ey=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>'),ty=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>'),ny=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>'),ry=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>'),sy=b("<!> <!>",1),ay=b('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),oy=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 by(n,e){nr(e,!0);const r=()=>ye(Os,"$isConnected",he),s=()=>ye(Ls,"$isResyncing",he),a=()=>ye(gc,"$isAgentPending",he),o=()=>ye($s,"$isLoadingSession",he),i=()=>ye(fc,"$isInterrupted",he),d=()=>ye(ba,"$sessionError",he),m=()=>ye(hc,"$sessionNotice",he),v=()=>ye(dc,"$folderConflict",he),g=()=>ye(Mo,"$folderMissing",he),x=()=>ye(uc,"$assistantRetired",he),y=()=>ye(va,"$isReadOnly",he),D=()=>ye(is,"$activeSessionInfo",he),P=()=>ye(cn,"$piState",he),re=()=>ye(fo,"$availableModels",he),U=()=>ye(dl,"$sessionFolders",he),B=()=>ye(cl,"$readOnlySessionFolders",he),W=()=>ye(vc,"$isCreatingSession",he),ze=()=>ye(Oo,"$restoreState",he),X=()=>ye(al,"$searchFolderStore",he),G=()=>ye($d,"$assistantStatusStore",he),Y=()=>ye(Md,"$searchDefaultModelStore",he),Ce=()=>ye(Ld,"$appearanceStore",he),[he,Ae]=Nr();let te=F(!1),Ne=F("main"),He=F(!1),Ke=F("");function Je(C,O=""){p(He,C,!0),p(Ke,O,!0),p(Ne,"search")}let Be=F(!1),Qe,ut=!0;os(()=>{{const z=Fl(ce());setTimeout(()=>{zu({cached:z,hydrate:Ul,connect:ne=>{ut=!1,Gr(ne)}})},200)}const C=()=>{if(nt=null,t(ve)){const z=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";z&&z!==t(J)?(nt=z,as(z)):!z&&t(J)&&br()}};window.addEventListener("hashchange",C);let O=null;const Q=8e3,pe=()=>{if(document.visibilityState==="hidden"){if(Wa(),Hl())return;O&&clearTimeout(O),O=setTimeout(()=>{O=null,document.visibilityState==="hidden"&&t(ve)&&Bl()},Q)}else{Ro(),O&&(clearTimeout(O),O=null),qa();const z=_i({booting:ut,connected:t(ve),hasActiveSession:Ka()});z==="resume"?Ga():z==="connect"&&Gr()}},k=z=>{if(O&&(clearTimeout(O),O=null),document.visibilityState==="hidden")return;qa();const ne=_i({booting:ut,connected:t(ve),hasActiveSession:Ka()});ne==="resume"?Ga():ne==="connect"&&Gr()},$=()=>Wa();return document.addEventListener("visibilitychange",pe),window.addEventListener("pageshow",k),window.addEventListener("pagehide",$),()=>{window.removeEventListener("hashchange",C),document.removeEventListener("visibilitychange",pe),window.removeEventListener("pageshow",k),window.removeEventListener("pagehide",$),O&&clearTimeout(O)}});function Ot(){Gr()}function Tt(){br(),Cs(),To()}function xt(){Cs(),setTimeout(()=>Gr(),100)}function Re(){_s()}function Wt(){typeof window<"u"&&(window.location.hash=""),br(),p(te,!1)}let ve=L(r),$t=L(s),It=L(a),At=L(o),oe=L(i),q=L(d),tt=L(m),ge=L(v),le=L(g),et=L(x),ee=L(y),K=L(D),we=L(P),R=L(()=>re().models),se=F(!1),J=L(()=>t(K).sessionId),Se=L(()=>{const C=t(K).sessionFile;if(!C)return!1;for(const O of[U(),B()])for(const Q of O.folders){const pe=Q.sessions.find(k=>k.path===C);if(pe)return!!pe.starred}return!1});Nt(()=>{typeof window<"u"&&t(ve)&&(t(J)?(window.location.hash=encodeURIComponent(t(J)),p(se,!0)):t(se)&&(p(se,!1),window.location.hash&&(window.location.hash="")))});let Le=null,nt=null;function ce(){return typeof window>"u"||!window.location.hash?"":decodeURIComponent(window.location.hash.slice(1))}Nt(()=>{if(!t(ve)){nt=null;return}const C=ce();C&&t(J)===C&&(nt=null);const O=pi({connected:t(ve),hashId:C,currentSessionId:t(J),loading:t(At),resyncing:t($t),creating:W(),attemptedHashId:nt});if(O==="failed"){nt=null,window.location.hash&&history.replaceState(history.state,"",window.location.pathname+window.location.search);return}O==="join"&&(Le||(Le=setTimeout(()=>{Le=null;const Q=ce();pi({connected:t(ve),hashId:Q,currentSessionId:t(J),loading:t(At),resyncing:t($t),creating:W(),attemptedHashId:nt})==="join"&&(nt=Q,Yl(Q))},300)))}),Nt(()=>{t(ve)||p(se,!1)}),Nt(()=>{(t(J)||t(At)||t($t))&&p(te,!1)});let Ve=L(W),at=L(()=>ze()?.forSessionCreate?ze():null),wt=L(X),Et=L(()=>G().active),Lt=L(()=>Od(G(),t(K).sessionFile)),Ft=F(void 0),Xt=L(()=>pu({connected:t(ve),searchConfigured:!!t(wt),hasSession:!!t(K).sessionFile,loading:t(At),resyncing:t($t),hasSessionHash:typeof window<"u"&&!!window.location.hash,loadFailed:!!t(q)&&!t(At)&&!t($t)&&!t(K).sessionFile})),zt=L(()=>t(R).map(C=>({value:`${C.provider}:${C.modelId}`,label:`${C.label}${C.isDefault?" (default)":""}`}))),Sn=L(Y),mn=L(()=>Ce().label),qt=F("");Nt(()=>{if(t(zt).length===0||t(zt).some(pe=>pe.value===t(qt)))return;const O=t(zt).find(pe=>pe.value===t(Sn)),Q=t(R).find(pe=>pe.isDefault);p(qt,O?O.value:Q?`${Q.provider}:${Q.modelId}`:t(zt)[0].value,!0)});let Kt=F(!1);Nt(()=>{t(Xt)&&!t(Kt)&&t(Ft)&&(p(Kt,!0),t(Ft).focusInput())});function dn(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),br(),t(Ft)?.focusInput()}var kn=oy(),En=mt(kn);{let C=L(()=>t(mn)?`Wherever · ${t(mn)}`:"Wherever");Kd(En,{get title(){return t(C)},description:"Create & maintain apps from wherever"})}var pt=f(En,2);{var Ct=C=>{var O=vx(),Q=u(O),pe=f(u(Q),4);{var k=ne=>{var fe=bx(),I=u(fe,!0);c(fe),T(()=>E(I,t(at).job.url)),h(ne,fe)};w(pe,ne=>{t(at).job?.url&&ne(k)})}var $=f(pe,2);Kc($,{get job(){return t(at).job}});var z=f($,2);c(Q),c(O),M("click",z,()=>Io()),h(C,O)},_n=C=>{var O=gx();h(C,O)};w(pt,C=>{t(at)?C(Ct):t(Ve)&&C(_n,1)})}var Cn=f(pt,2),wn=u(Cn),Nn=u(wn),xn=u(Nn),vn=u(xn);{var Fn=C=>{var O=mx(),Q=f(mt(O),2);M("click",Q,()=>p(Be,!1)),h(C,O)},Vt=C=>{var O=yx(),Q=mt(O),pe=u(Q),k=f(pe,4);{var $=I=>{var l=xx(),_=u(l,!0);c(l),T(()=>{Z(l,"title",t(mn)),E(_,t(mn))}),h(I,l)};w(k,I=>{t(mn)&&I($)})}c(Q);var z=f(Q,2),ne=u(z),fe=f(ne,2);c(z),T(I=>Z(pe,"src",I),[()=>ts("/logo.svg")]),M("click",Q,Wt),M("click",ne,()=>p(Be,!0)),M("click",fe,()=>p(te,!1)),h(C,O)};w(vn,C=>{t(Be)?C(Fn):C(Vt,-1)})}c(xn),c(Nn);var qn=f(Nn,2);{var j=C=>{var O=_x(),Q=u(O);{let N=L(()=>(t(we).connected,"localhost"));Af(Q,{get host(){return t(N)},port:31415,token:"",onConnected:Ot})}var pe=f(Q,2);{var k=N=>{{let de=L(()=>t(J)??null);Bf(N,{get currentSessionId(){return t(de)}})}};w(pe,N=>{G().active&&G().webPush?.enabled&&N(k)})}var $=f(pe,2);{var z=N=>{ap(N,{get status(){return G().telegram}})},ne=L(()=>G().telegram&&jf(G()));w($,N=>{t(ne)&&N(z)})}var fe=f($,2),I=f(u(fe),2),l=u(I),_=f(l,2),A=f(_,2);c(I),c(fe),c(O),M("click",l,Re),M("click",_,xt),M("click",A,Tt),h(C,O)},ie=C=>{var O=Ox(),Q=mt(O),pe=u(Q),k=u(pe),$=f(k,2),z=u($,!0);c($);var ne=f($,2),fe=u(ne),I=f(fe);{var l=Fe=>{var Ee=wx(),ae=u(Ee);c(Ee),T(()=>E(ae,` / srv ${t(we).serverVersion??""}`)),h(Fe,Ee)};w(I,Fe=>{t(we).serverVersion&&Fe(l)})}c(ne),c(pe);var _=f(pe,2);{var A=Fe=>{var Ee=Tx(),ae=u(Ee);{var Ue=Ge=>{var Me=Sx(),_t=u(Me);c(Me),T(St=>{Z(Me,"title",t(K).cwd),E(_t,`📁 ${St??""}`)},[()=>t(K).cwd.split("/").pop()||t(K).cwd]),h(Ge,Me)};w(ae,Ge=>{t(K).cwd&&Ge(Ue)})}var H=f(ae,2);{var ue=Ge=>{var Me=kx(),_t=u(Me);c(Me),T(()=>{Z(Me,"title",t(K).model),E(_t,`🤖 ${t(K).model??""}`)}),h(Ge,Me)};w(H,Ge=>{t(K).model&&Ge(ue)})}var Ye=f(H,2),Xe=u(Ye);c(Ye),c(Ee),M("click",Xe,Wt),h(Fe,Ee)};w(_,Fe=>{t(K).sessionFile&&Fe(A)})}var N=f(_,2);{var de=Fe=>{var Ee=Ax(),ae=u(Ee,!0);c(Ee),T(()=>E(ae,t(we).error)),h(Fe,Ee)};w(N,Fe=>{t(we).error&&!t(ve)&&Fe(de)})}c(Q);var Te=f(Q,2),gt=u(Te);{var ot=Fe=>{var Ee=Ix(),ae=mt(Ee);{var Ue=Ye=>{var Xe=Rx(),Ge=f(u(Xe),4);{var Me=St=>{var Qt=Cx(),Bn=u(Qt,!0);c(Qt),T(()=>E(Bn,G().timezone)),h(St,Qt)};w(Ge,St=>{G().timezone&&St(Me)})}var _t=f(Ge,2);c(Xe),T(()=>{Xe.disabled=!t(ve),en(Xe,1,`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors hover:bg-brand-surface-3/50 hover:text-brand-text disabled:opacity-50 ${t(Lt)?"font-semibold text-brand-blue":"text-brand-text-muted"}`),Z(Xe,"title",G().timezone?`Open the current assistant session (your timezone: ${G().timezone})`:"Open the current assistant session"),en(_t,1,ho(G().timezone?"":"ml-auto"))}),M("click",Xe,()=>{Ya(),p(te,!1)}),h(Ye,Xe)};w(ae,Ye=>{t(Et)&&Ye(Ue)})}var H=f(ae,2),ue=f(H,2);M("click",H,()=>Je(!1)),M("click",ue,()=>{p(Ne,"readonly"),ll()}),h(Fe,Ee)},Pe=Fe=>{var Ee=Ex(),ae=f(u(Ee),2),Ue=u(ae);c(ae),c(Ee),T(()=>E(Ue,`Back to ${t(He)?"read-only sessions":"sessions"}`)),M("click",Ee,()=>p(Ne,t(He)?"readonly":"main",!0)),h(Fe,Ee)},ct=Fe=>{var Ee=Mx(),ae=mt(Ee),Ue=f(ae,2);M("click",ae,()=>p(Ne,"main")),M("click",Ue,()=>Je(!0)),h(Fe,Ee)};w(gt,Fe=>{t(Ne)==="main"?Fe(ot):t(Ne)==="search"?Fe(Pe,1):Fe(ct,-1)})}c(Te);var it=f(Te,2),We=u(it);{var Ut=Fe=>{jm(Fe,{get readOnly(){return t(He)},get initialQuery(){return t(Ke)},onOpened:()=>p(te,!1)})},fn=Fe=>{el(Fe,{readOnly:!0,onSearchAll:Ee=>Je(!0,Ee)})},Rn=Fe=>{el(Fe,{onSearchAll:Ee=>Je(!1,Ee)})};w(We,Fe=>{t(Ne)==="search"?Fe(Ut):t(Ne)==="readonly"?Fe(fn,1):Fe(Rn,-1)})}c(it),T(()=>{en(k,1,`h-2.5 w-2.5 rounded-full ${t(ve)?"bg-emerald-500":"bg-rose-500"}`),en($,1,`text-sm ${t(ve)?"text-emerald-400":"text-rose-400"}`),E(z,t(ve)?"Connected":"Disconnected"),Z(ne,"title",t(we).serverVersion?`App build ${Ws} · server ${t(we).serverVersion}${t(we).piVersion?` · pi ${t(we).piVersion}`:""}`:`App build ${Ws}`),E(fe,`v${Ws}`)}),h(C,O)};w(qn,C=>{t(Be)?C(j):C(ie,-1)})}c(wn);var Ie=f(wn,2),De=u(Ie),S=u(De),V=f(S,2);{var be=C=>{var O=$x();M("click",O,dn),h(C,O)};w(V,C=>{t(ve)&&t(wt)&&t(K).sessionFile&&C(be)})}var Oe=f(V,2);{var rt=C=>{var O=Nx(),Q=u(O);{var pe=z=>{var ne=Lx();h(z,ne)},k=z=>{var ne=Dx();h(z,ne)},$=z=>{var ne=Px();h(z,ne)};w(Q,z=>{t(ve)&&t(Xt)?z(pe):t(ve)?z(k,1):z($,-1)})}c(O),h(C,O)};w(Oe,C=>{(!t(ve)||!t(K).sessionFile)&&C(rt)})}var je=f(Oe,2);{var _e=C=>{var O=Hx(),Q=u(O);{var pe=z=>{var ne=Fx(),fe=f(u(ne),2),I=u(fe,!0);c(fe),c(ne),T(l=>{Z(fe,"title",t(K).cwd),E(I,l)},[()=>t(K).cwd.split("/").pop()||t(K).cwd]),h(z,ne)};w(Q,z=>{t(K).cwd&&z(pe)})}var k=f(Q,2);{var $=z=>{var ne=jx(),fe=u(ne),I=f(u(fe),2);c(fe);var l=f(fe,2);{var _=N=>{var de=zx();$n(de,21,()=>t(R),vr,(gt,ot)=>{var Pe=Ux(),ct=u(Pe,!0);c(Pe);var it={};T(()=>{E(ct,t(ot).label),it!==(it=`${t(ot).provider}:${t(ot).modelId}`)&&(Pe.value=Pe.__value=`${t(ot).provider}:${t(ot).modelId}`)}),h(gt,Pe)}),c(de);var Te;pl(de),T(()=>{Te!==(Te=t(K).model)&&(de.value=(de.__value=t(K).model)??"",vo(de,t(K).model))}),M("input",de,gt=>ic(gt.currentTarget.value)),h(N,de)},A=N=>{var de=Bx(),Te=u(de,!0);c(de),T(()=>{Z(de,"title",t(K).model),E(Te,t(K).model)}),h(N,de)};w(l,N=>{t(R).length>0&&!t(ee)?N(_):N(A,-1)})}c(ne),T(()=>{en(I,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(we).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),Z(I,"title",t(we).isStreaming?"Agent working...":"Ready")}),h(z,ne)};w(k,z=>{t(K).model&&z($)})}c(O),h(C,O)};w(je,C=>{t(K).sessionFile&&C(_e)})}var me=f(je,2);{var Zt=C=>{var O=Wx();M("click",O,function(...Q){Jl?.apply(this,Q)}),h(C,O)};w(me,C=>{t(ve)&&t(Lt)&&C(Zt)})}var nn=f(me,2);{var Bt=C=>{var O=Gx(),Q=u(O,!0);c(O),T(()=>{en(O,1,`flex flex-shrink-0 items-center justify-center rounded border px-2 py-1 text-sm transition-colors ${t(Se)?"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"}`),Z(O,"title",t(Se)?"Starred. Click to unstar.":"Star this session to come back to it later"),Z(O,"aria-label",t(Se)?"Unstar session":"Star session"),Z(O,"aria-pressed",t(Se)),E(Q,t(Se)?"★":"☆")}),M("click",O,()=>ul(t(K).sessionFile,!t(Se)).catch(()=>{})),h(C,O)};w(nn,C=>{t(K).sessionFile&&C(Bt)})}var un=f(nn,2);{var rn=C=>{var O=qx();h(C,O)};w(un,C=>{t(ee)&&C(rn)})}c(De);var Rt=f(De,2);{var yt=C=>{var O=Kx();h(C,O)};w(Rt,C=>{t(oe)&&C(yt)})}var hn=f(Rt,2);{var ht=C=>{var O=Vx(),Q=u(O),pe=u(Q,!0);c(Q);var k=f(Q,2);c(O),T(()=>{en(O,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(tt).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),E(pe,t(tt).message)}),M("click",k,()=>sc()),h(C,O)};w(hn,C=>{t(tt)&&C(ht)})}var ft=f(hn,2);{var Dt=C=>{var O=Xx(),Q=u(O),pe=f(u(Q));{var k=fe=>{var I=Vn("You are both working in it — changes may conflict.");h(fe,I)},$=fe=>{var I=Vn("You are observing (read-only) to avoid clashing.");h(fe,I)};w(pe,fe=>{t(ge).continued?fe(k):fe($,-1)})}c(Q);var z=f(Q,2);{var ne=fe=>{var I=Yx();M("click",I,()=>tc()),h(fe,I)};w(z,fe=>{t(ge).continued||fe(ne)})}c(O),h(C,O)};w(ft,C=>{t(ge)?.active&&C(Dt)})}var ln=f(ft,2);{var bn=C=>{var O=Zx(),Q=u(O),pe=u(Q,!0);c(Q);var k=f(Q,2);c(O),T(()=>E(pe,t(q))),M("click",k,()=>Lr()),h(C,O)};w(ln,C=>{t(q)&&C(bn)})}var xe=f(ln,2);{var qe=C=>{var O=Qx(),Q=f(u(O),2);{var pe=k=>{var $=Jx();M("click",$,()=>Ya()),h(k,$)};w(Q,k=>{t(ve)&&k(pe)})}c(O),h(C,O)};w(xe,C=>{t(et)&&C(qe)})}var bt=f(xe,2);{var ke=C=>{var O=ey();h(C,O)};w(bt,C=>{t(ee)&&!t(oe)&&!t(le)&&!t(et)&&!(t(ge)?.active&&!t(ge).continued)&&C(ke)})}var st=f(bt,2);lr(Pv(st,{onMessageSent:()=>{}}),C=>Qe=C,()=>Qe);var sn=f(st,2);{var Jt=C=>{hx(C,{})},yn=C=>{var O=ty();h(C,O)},jt=C=>{var O=sy(),Q=mt(O);{var pe=z=>{var ne=ny();h(z,ne)},k=z=>{var ne=ry();h(z,ne)};w(Q,z=>{t(K).sessionFile&&(t($t)||!t(ve))?z(pe):t(K).sessionFile&&t(It)&&z(k,1)})}var $=f(Q,2);{let z=L(()=>!!t(wt)),ne=L(()=>t(Xt)?!t(ve):t(ee)||!t(K).sessionFile),fe=L(()=>!t(Xt)&&(!t(ve)||t($t)||t(It)));lr($g($,{get searchMode(){return t(Xt)},get searchConfigured(){return t(z)},get searchModels(){return t(zt)},onSubmit:(I,l)=>Zl(I,t(qt),l),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(ne)},get sendDisabled(){return t(fe)},onSend:()=>Qe?.forceScrollToBottom(),get searchModel(){return t(qt)},set searchModel(I){p(qt,I,!0)}}),I=>p(Ft,I,!0),()=>t(Ft))}h(C,O)};w(sn,C=>{t(le)?C(Jt):t(ee)&&t(K).sessionFile?C(yn,1):C(jt,-1)})}c(Ie);var an=f(Ie,2);Wm(an,{});var Pn=f(an,2);{var $e=C=>{var O=ay();M("click",O,()=>p(te,!1)),h(C,O)};w(Pn,C=>{t(te)&&C($e)})}c(Cn),T(()=>en(wn,1,`app-chrome ${t(te)?"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",S,()=>p(te,!t(te))),h(n,kn),rr(),Ae()}pr(["click","input"]);export{by as component,hy as universal};
|
|
124
|
-
//# sourceMappingURL=2.DO5lRCyx.js.map
|