wherever-dev 0.10.9 → 0.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/index.js +24 -1
  2. package/dist/index.js.map +1 -1
  3. package/dist/protocol.d.ts +1 -0
  4. package/dist/protocol.d.ts.map +1 -1
  5. package/dist/session-pool.d.ts +14 -0
  6. package/dist/session-pool.d.ts.map +1 -1
  7. package/dist/session-pool.js +19 -0
  8. package/dist/session-pool.js.map +1 -1
  9. package/package.json +1 -1
  10. package/public/_app/immutable/assets/{0.D-PmZM9S.css → 0.CC0hR-g4.css} +1 -1
  11. package/public/_app/immutable/chunks/CIOfJygp.js +2 -0
  12. package/public/_app/immutable/chunks/{C8RBOgq9.js.map → CIOfJygp.js.map} +1 -1
  13. package/public/_app/immutable/chunks/{NJQCw9It.js → CP7HQriI.js} +2 -2
  14. package/public/_app/immutable/chunks/{NJQCw9It.js.map → CP7HQriI.js.map} +1 -1
  15. package/public/_app/immutable/chunks/{DHqQrU3z.js → CgprCr9Q.js} +2 -2
  16. package/public/_app/immutable/chunks/{DHqQrU3z.js.map → CgprCr9Q.js.map} +1 -1
  17. package/public/_app/immutable/entry/{app.Dd1Cl3I6.js → app.CSBRfvfP.js} +3 -3
  18. package/public/_app/immutable/entry/{app.Dd1Cl3I6.js.map → app.CSBRfvfP.js.map} +1 -1
  19. package/public/_app/immutable/entry/start.Drl3QzB0.js +2 -0
  20. package/public/_app/immutable/entry/start.Drl3QzB0.js.map +1 -0
  21. package/public/_app/immutable/nodes/{0.Bw2Ql94P.js → 0.BvcOYIBI.js} +2 -2
  22. package/public/_app/immutable/nodes/{0.Bw2Ql94P.js.map → 0.BvcOYIBI.js.map} +1 -1
  23. package/public/_app/immutable/nodes/{1.C-hs9yrq.js → 1.DT9u4xbp.js} +2 -2
  24. package/public/_app/immutable/nodes/{1.C-hs9yrq.js.map → 1.DT9u4xbp.js.map} +1 -1
  25. package/public/_app/immutable/nodes/2.CpZdrUY8.js +89 -0
  26. package/public/_app/immutable/nodes/2.CpZdrUY8.js.map +1 -0
  27. package/public/_app/version.json +1 -1
  28. package/public/index.html +11 -11
  29. package/public/service-worker.js +1 -1
  30. package/public/_app/immutable/chunks/C8RBOgq9.js +0 -2
  31. package/public/_app/immutable/entry/start.DBHmFN_F.js +0 -2
  32. package/public/_app/immutable/entry/start.DBHmFN_F.js.map +0 -1
  33. package/public/_app/immutable/nodes/2.CTBsackz.js +0 -89
  34. package/public/_app/immutable/nodes/2.CTBsackz.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ import{b as fo,a as b,c as Tr,g,d as Qr,e as F,s as V,f as Er,t as jn,h as Ks}from"../chunks/itgD7vGH.js";import{as as Gn,b3 as Hs,am as rs,bf as $,aq as ma,O as Il,aT as $l,ar as Ro,d as Ja,an as Co,au as Ml,n as Ll,a1 as Dl,u as Ol,t as Pl,a2 as Nl,W as Fl,X as Ul,H as zl,b4 as xa,C as _a,z as ya,aF as Ys,a3 as Pr,ad as Bl,aA as Hl,a_ as Wl,az as ei,be as ti,bg as jl,bh as Kr,aV as Bo,aR as wa,aQ as zr,aN as Br,ag as rn,b7 as p,aj as t,a6 as Gl,bi as G,$ as ql,bm as Cn,ai as qn,a9 as en,aL as Es,a$ as h,Y as u,aW as c,aJ as Ve,ba as W,aP as sr,bj as Et,bk as Vl,aU as Kl}from"../chunks/CRRPBe07.js";import{i as k,s as ls,a as Se,p as Nr}from"../chunks/Dtm96ZKi.js";import{a as Yl,b as J,r as rt,c as ni,e as Fn,i as cr,d as Xl}from"../chunks/CP7HQriI.js";import{_ as Zl,b as ur}from"../chunks/CAWbdcQM.js";import{v as Ns}from"../chunks/CIOfJygp.js";import{p as Ql}from"../chunks/CgprCr9Q.js";function ka(n,e,r=!1,s=!1,o=!1,a=!1){var i=n,d="";if(r){var m=n;Gn&&(i=Hs(rs(m)))}$(()=>{var x=Il;if(d===(d=e()??"")){Gn&&ma();return}if(r&&!Gn){x.nodes=null,m.innerHTML=d,d!==""&&fo(rs(m),m.lastChild);return}if(x.nodes!==null&&($l(x.nodes.start,x.nodes.end),x.nodes=null),d!==""){if(Gn){Ro.data;for(var _=ma(),S=_;_!==null&&(_.nodeType!==Ja||_.data!=="");)S=_,_=Co(_);if(_===null)throw Ml(),Ll;fo(Ro,S),i=Hs(_);return}var R=s?Ol:o?Pl:void 0,P=Dl(s?"svg":o?"math":"template",R);P.innerHTML=d;var O=s||o?P:P.content;if(fo(rs(O),O.lastChild),s||o)for(;rs(O);)i.before(rs(O));else i.before(O)}})}function Jl(n,e){let r=null,s=Gn;var o;if(Gn){r=Ro;for(var a=rs(document.head);a!==null&&(a.nodeType!==Ja||a.data!==n);)a=Co(a);if(a===null)xa(!1);else{var i=Co(a);a.remove(),Hs(i)}}Gn||(o=document.head.appendChild(Nl()));try{Fl(()=>{var d=Ul(()=>e(o));d.f|=zl})}finally{s&&(xa(!0),Hs(r))}}function ri(n){var e,r,s="";if(typeof n=="string"||typeof n=="number")s+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(r=ri(n[e]))&&(s&&(s+=" "),s+=r)}else for(r in n)n[r]&&(s&&(s+=" "),s+=r);return s}function ec(){for(var n,e,r=0,s="",o=arguments.length;r<o;r++)(n=arguments[r])&&(e=ri(n))&&(s&&(s+=" "),s+=e);return s}function tc(n){return typeof n=="object"?ec(n):n??""}function nc(n,e,r){var s=n==null?"":""+n;return s===""?null:s}function rc(n,e){return n==null?null:String(n)}function Jt(n,e,r,s,o,a){var i=n[_a];if(Gn||i!==r||i===void 0){var d=nc(r);(!Gn||d!==n.getAttribute("class"))&&(d==null?n.removeAttribute("class"):e?n.className=d:n.setAttribute("class",d)),n[_a]=r}return a}function sc(n,e,r,s){var o=n[ya];if(Gn||o!==e){var a=rc(e);(!Gn||a!==n.getAttribute("style"))&&(a==null?n.removeAttribute("style"):n.style.cssText=a),n[ya]=e}return s}function Ho(n,e,r=!1){if(n.multiple){if(e==null)return;if(!Hl(e))return Wl();for(var s of n.options)s.selected=e.includes(ws(s));return}for(s of n.options){var o=ws(s);if(ei(o,e)){s.selected=!0;return}}(!r||e!==void 0)&&(n.selectedIndex=-1)}function si(n){var e=new MutationObserver(()=>{Ho(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),ti(()=>{e.disconnect()})}function Rs(n,e,r=e){var s=new WeakSet,o=!0;Ys(n,"change",a=>{var i=a?"[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,Pr!==null&&s.add(Pr)}),Bl(()=>{var a=e();if(n===document.activeElement){var i=Pr;if(s.has(i))return}if(Ho(n,a,o),o&&a===void 0){var d=n.querySelector(":checked");d!==null&&(a=ws(d),r(a))}n.__value=a,o=!1}),si(n)}function ws(n){return"__value"in n?n.__value:n.value}function dr(n,e,r=e){var s=new WeakSet;Ys(n,"input",async o=>{var a=o?n.defaultValue:n.value;if(a=ho(n)?bo(a):a,r(a),Pr!==null&&s.add(Pr),await jl(),a!==(a=e())){var i=n.selectionStart,d=n.selectionEnd,m=n.value.length;if(n.value=a??"",d!==null){var x=n.value.length;i===d&&d===m&&x>m?(n.selectionStart=x,n.selectionEnd=x):(n.selectionStart=i,n.selectionEnd=Math.min(d,x))}}}),(Gn&&n.defaultValue!==n.value||Kr(e)==null&&n.value)&&(r(ho(n)?bo(n.value):n.value),Pr!==null&&s.add(Pr)),Bo(()=>{var o=e();if(n===document.activeElement){var a=Pr;if(s.has(a))return}ho(n)&&o===bo(n.value)||n.type==="date"&&!o&&!n.value||o!==n.value&&(n.value=o??"")})}const po=new Set;function Ur(n,e,r,s,o=s){var a=r.getAttribute("type")==="checkbox",i=n;let d=!1;if(e!==null)for(var m of e)i=i[m]??=[];i.push(r),Ys(r,"change",()=>{var x=r.__value;a&&(x=Sa(i,x,r.checked)),o(x)},()=>o(a?[]:null)),Bo(()=>{var x=s();if(Gn&&r.defaultChecked!==r.checked){d=!0;return}a?(x=x||[],r.checked=x.includes(r.__value)):r.checked=ei(r.__value,x)}),ti(()=>{var x=i.indexOf(r);x!==-1&&i.splice(x,1)}),po.has(i)||(po.add(i),wa(()=>{i.sort((x,_)=>x.compareDocumentPosition(_)===4?-1:1),po.delete(i)})),wa(()=>{if(d){var x;if(a)x=Sa(i,x,r.checked);else{var _=i.find(S=>S.checked);x=_?.__value}o(x)}})}function Nn(n,e,r=e){Ys(n,"change",s=>{var o=s?n.defaultChecked:n.checked;r(o)}),(Gn&&n.defaultChecked!==n.checked||Kr(e)==null)&&r(n.checked),Bo(()=>{var s=e();n.checked=!!s})}function Sa(n,e,r){for(var s=new Set,o=0;o<n.length;o+=1)n[o].checked&&s.add(n[o].__value);return r||s.delete(e),Array.from(s)}function ho(n){var e=n.type;return e==="number"||e==="range"}function bo(n){return n===""?null:+n}const oc=!1,ac=!0,kb=Object.freeze(Object.defineProperty({__proto__:null,prerender:ac,ssr:oc},Symbol.toStringTag,{value:"Module"})),vo="Wherever",ic="Create & maintain apps from wherever with a beautiful remote workspace.",go="https://localhost",lc="#000000",cc="black-translucent";function os(n,e){return Yl(n)}var dc=g('<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 uc(n,e){zr(e,!0);const r=go.endsWith("/")?go.slice(0,-1):go,s=r+"/preview.png";let o=G(()=>e.home||!1),a=G(()=>({type:e.type||"website",title:e.title||vo,description:e.description||ic,image:e.image||s,url:`${r}${Ql.url.pathname}`}));Jl("13n5pl5",i=>{var d=dc(),m=rn(d),x=p(m,2),_=p(x,2);{var S=tt=>{var wt=Tr(),ct=rn(wt);k(ct,sn=>{}),b(tt,wt)};k(_,tt=>{t(o)&&tt(S)})}var R=p(_,2),P=p(R,2),O=p(P,2),q=p(O,2),ve=p(q,2),Z=p(ve,4),ae=p(Z,2),Je=p(ae,2),fe=p(Je,2),Ce=p(fe,2),he=p(Ce,2),me=p(he,2),bt=p(me,2),It=p(bt,2),et=p(It,4),At=p(et,4),se=p(At,2),Ht=p(se,2);$((tt,wt,ct,sn)=>{J(m,"content",t(a).title),J(x,"content",t(a).description),J(R,"content",t(a).type),J(P,"content",t(a).url),J(O,"content",t(a).title),J(q,"content",t(a).description),J(ve,"content",t(a).image),J(Z,"content",t(a).url),J(ae,"content",t(a).title),J(Je,"content",t(a).description),J(fe,"content",t(a).image),J(Ce,"href",tt),J(he,"href",wt),J(me,"href",ct),J(bt,"href",sn),J(It,"content",lc),J(et,"content",vo),J(At,"content",cc),J(se,"content",vo),J(Ht,"content",Ns)},[()=>os("/pwa/favicon.png"),()=>os("/pwa/favicon.ico"),()=>os("/pwa/apple-touch-icon.png"),()=>os("/pwa/manifest.webmanifest")]),Gl(()=>{ql.title=t(a).title??""}),b(i,d)}),Br()}let cs=null;function fc(){if(typeof window>"u")return null;try{if(!cs){const n=window.AudioContext||window.webkitAudioContext;if(!n)return null;cs=new n}return cs.state==="suspended"&&cs.resume().catch(()=>{}),cs}catch{return null}}function Ta(n,e,r,s,o){const a=n.createOscillator(),i=n.createGain();a.type="sine",a.frequency.value=e;const d=.015;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(o,r+d),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(n.destination),a.start(r),a.stop(r+s+.02)}const Aa=new Map;function pc(n){if(typeof Audio>"u")return!1;try{let e=Aa.get(n);e||(e=new Audio(n),e.preload="auto",Aa.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 oi(n){if(n&&n.trim()&&pc(n.trim()))return;const e=fc();if(e)try{const r=e.currentTime;Ta(e,1046.5,r,.16,.12),Ta(e,1396.9,r+.13,.22,.12)}catch{}}function Wo(n){if(!n)return null;const e=n.trimStart(),r=e.match(/^<skill\s+name="([^"]*)"[^>]*>/);if(r){const s=e.indexOf("</skill>");return s===-1?null:{skillName:r[1],args:e.slice(s+8).trim()}}if(e.startsWith("/skill:")){const s=e.slice(7),o=s.indexOf(" "),a=o===-1?s:s.slice(0,o);if(!a)return null;const i=o===-1?"":s.slice(o+1).trim();return{skillName:a,args:i}}return null}function Ds(n){const e=Wo(n);return e?`skill:${e.skillName}\0${e.args}`:null}function Fs(){}function hc(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function bc(n,...e){if(n==null)return Fs;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function qt(n){let e;return bc(n,r=>e=r)(),e}var ts=[];function vc(n,e=Fs){let r;const s=new Set;function o(d){if(hc(n,d)&&(n=d,r)){const m=!ts.length;for(const x of s)x[1](),ts.push(x,n);if(m){for(let x=0;x<ts.length;x+=2)ts[x][0](ts[x+1]);ts.length=0}}}function a(d){o(d(n))}function i(d,m=Fs){const x=[d,m];return s.add(x),s.size===1&&(r=e(o)||Fs),d(n),()=>{s.delete(x),s.size===0&&(r(),r=null)}}return{set:o,update:a,subscribe:i}}const mo={connected:!1,connecting:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,error:null,session:null,sessionId:null,isStreaming:!1,messages:[],clientId:null,serverVersion:null,folderConflict:null,isInterrupted:!1,notice:null,sudoPrompt:null,sessionError:null,readOnly:!1,activeSessionFile:null,activeCwd:null,activeModel:null,hideThinking:!1,hideTools:!1,historyTotalCount:0,historyOffset:0,loadingMoreHistory:!1,contextUsage:null,pendingSteering:[],skills:[]};class ir{ws=null;config;stateStore;reconnectTimer=null;agentEndTimeout=null;loadWatchdog=null;static LOAD_WATCHDOG_MS=12e3;createWatchdog=null;static CREATE_WATCHDOG_MS=25e3;reconnectAttempts=0;reconnectDelay=2e3;maxReconnectDelay=15e3;hasEverConnected=!1;static HANDSHAKE_FAIL_HINT_AFTER=2;livenessTimer=null;heartbeatTimer=null;lastInboundAt=0;static STALE_SOCKET_MS=6e4;static TURN_STALL_MS=45e3;static HEARTBEAT_MS=25e3;isInitialConnect=!0;resumeSessionFile=null;resumeCwd;resumeModel;pendingLoadFile=null;listeners=new Set;pendingUploads=new Map;confirmTimers=new Map;static CONFIRM_MS=12e3;static PENDING_PREFIX="wherever-pending:";constructor(e){this.config={secure:!0,...e},this.stateStore=vc({...mo,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}connect(e,r=!1){e&&(this.config={...this.config,...e}),this.disconnect(!1),this.stateStore.update(P=>r?{...P,connecting:!0,error:null}:{...mo,connecting:!0,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools});const s=this.config.secure?"wss":"ws",o=this.config.host.startsWith("http")?this.config.host.replace(/^https?:\/\//,""):this.config.host,a=this.config.token?`?token=${encodeURIComponent(this.config.token)}`:"",i=`${s}://${o}:${this.config.port}/ws${a}`,d=this.config.WebSocketCtor||(typeof globalThis<"u"?globalThis.WebSocket:null);if(!d){this.stateStore.update(P=>({...P,connecting:!1,error:"No WebSocket implementation found. Please pass custom WebSocketCtor."}));return}try{const P=this.config.secure&&this.config.WebSocketCtor?{rejectUnauthorized:!1}:void 0;this.ws=P?new d(i,P):new d(i)}catch(P){this.stateStore.update(O=>({...O,connecting:!1,error:`Failed to connect: ${P}`})),this.scheduleReconnect();return}const m=this.ws,x=()=>{if(this.ws!==m)return;this.isInitialConnect||console.info("[wherever] reconnected to relay"),this.hasEverConnected=!0,this.reconnectAttempts=0,this.reconnectDelay=2e3,this.isInitialConnect=!1,this.startLivenessWatchdog(),this.stateStore.update(Z=>({...Z,connected:!0,connecting:!1,error:null}));const P=qt(this.stateStore),O=this.resumeSessionFile??P.activeSessionFile,q=this.resumeSessionFile!=null?this.resumeCwd:P.activeCwd??void 0,ve=this.resumeSessionFile!=null?this.resumeModel:P.activeModel??void 0;this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0,O?(this.stateStore.update(Z=>Z.resyncing?Z:{...Z,resyncing:!0}),this.pendingLoadFile=O,this.send({type:"session_load",sessionFile:O,cwd:q,model:ve}),this.armLoadWatchdog()):this.stateStore.update(Z=>Z.resyncing?{...Z,resyncing:!1}:Z)},_=P=>{if(this.ws===m){this.lastInboundAt=Date.now();try{const O=typeof P.data=="string"?P.data:P.data.toString(),q=JSON.parse(O);this.handleMessage(q)}catch(O){console.error("Failed to parse WebSocket message:",O)}}},S=()=>{this.ws===m&&(this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.ws=null,this.stateStore.update(P=>({...P,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,resyncing:P.activeSessionFile?!0:P.resyncing})),this.scheduleReconnect())},R=P=>{this.ws===m&&this.stateStore.update(O=>({...O,error:O.error||"Connection error occurred"}))};typeof m.addEventListener=="function"?(m.addEventListener("open",x),m.addEventListener("message",_),m.addEventListener("close",S),m.addEventListener("error",R)):typeof m.on=="function"&&(m.on("open",x),m.on("message",P=>_({data:P})),m.on("close",S),m.on("error",R))}disconnect(e=!0){if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stopLivenessWatchdog(),this.clearLoadWatchdog(),this.clearCreateWatchdog(),this.ws){const r=this.ws;try{typeof r.removeAllListeners=="function"&&r.removeAllListeners();const s=()=>{};typeof r.on=="function"?r.on("error",s):typeof r.addEventListener=="function"?r.addEventListener("error",s):r.onerror=s,r.close()}catch{}this.ws=null}if(e){for(const r of this.confirmTimers.values())clearTimeout(r);this.confirmTimers.clear(),this.stateStore.set({...mo,hideThinking:!!this.config.hideThinking,hideTools:!!this.config.hideTools})}else this.stateStore.update(r=>({...r,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1}))}suspend(){const e=qt(this.stateStore);e.activeSessionFile&&(this.resumeSessionFile=e.activeSessionFile,this.resumeCwd=e.activeCwd??void 0,this.resumeModel=e.activeModel??void 0),e.isStreaming&&this.stateStore.update(r=>({...r,isStreaming:!1})),this.disconnect(!1)}resume(){const e=qt(this.stateStore);e.connected||e.connecting||((this.resumeSessionFile||e.activeSessionFile)&&(this.stateStore.update(r=>({...r,resyncing:!0})),this.armLoadWatchdog()),this.connect(void 0,!0))}hasSuspendedSession(){return this.resumeSessionFile!==null}hasActiveSession(){return this.resumeSessionFile!==null||qt(this.stateStore).activeSessionFile!==null}startLivenessWatchdog(){this.stopLivenessWatchdog(),this.lastInboundAt=Date.now();const e=()=>{try{this.ping()}catch{}};typeof setInterval=="function"&&(this.heartbeatTimer=setInterval(e,ir.HEARTBEAT_MS),this.heartbeatTimer&&typeof this.heartbeatTimer.unref=="function"&&this.heartbeatTimer.unref());const r=()=>{if(!this.ws)return;const s=Date.now()-this.lastInboundAt,o=qt(this.stateStore).isStreaming,a=o?ir.TURN_STALL_MS:ir.STALE_SOCKET_MS;if(s<a)return;console.warn(`[wherever] relay connection stale: no inbound frame for ${s}ms (threshold ${a}ms, ${o?"mid-turn":"idle"}); tearing down dead socket and reconnecting`),this.stopLivenessWatchdog();const i=this.ws;this.ws=null;try{typeof i.terminate=="function"?i.terminate():typeof i.close=="function"&&i.close()}catch{}this.stateStore.update(d=>({...d,connected:!1,connecting:!1,loadingSession:!1,creatingSession:!1,sessionError:o?"Connection to relay stalled mid-turn; reconnecting...":d.sessionError,isStreaming:!1})),this.scheduleReconnect()};typeof setInterval=="function"&&(this.livenessTimer=setInterval(r,ir.HEARTBEAT_MS),this.livenessTimer&&typeof this.livenessTimer.unref=="function"&&this.livenessTimer.unref())}stopLivenessWatchdog(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.livenessTimer&&(clearInterval(this.livenessTimer),this.livenessTimer=null)}armLoadWatchdog(){this.clearLoadWatchdog(),this.loadWatchdog=setTimeout(()=>{this.loadWatchdog=null;const e=qt(this.stateStore);!e.loadingSession&&!e.resyncing||(console.warn("[wherever] session load timed out; clearing loading state"),this.stateStore.update(r=>({...r,loadingSession:!1,resyncing:!1,sessionError:r.sessionError||"Loading the session timed out. Please retry from the sidebar or reload."})))},ir.LOAD_WATCHDOG_MS)}clearLoadWatchdog(){this.loadWatchdog&&(clearTimeout(this.loadWatchdog),this.loadWatchdog=null)}armCreateWatchdog(){this.clearCreateWatchdog(),this.createWatchdog=setTimeout(()=>{this.createWatchdog=null,qt(this.stateStore).creatingSession&&(console.warn("[wherever] session create timed out; clearing creating state"),this.stateStore.update(r=>({...r,creatingSession:!1,sessionError:r.sessionError||"Creating the session timed out. It may still be starting on the server; check the sidebar or reload."})))},ir.CREATE_WATCHDOG_MS)}clearCreateWatchdog(){this.createWatchdog&&(clearTimeout(this.createWatchdog),this.createWatchdog=null)}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{if(this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*1.5,this.maxReconnectDelay),console.info(`[wherever] reconnecting to relay (attempt ${++this.reconnectAttempts})`),!this.hasEverConnected&&this.reconnectAttempts>=ir.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=!!qt(this.stateStore).activeSessionFile;this.stateStore.update(r=>({...r,connecting:!0,error:"Reconnecting..."})),this.connect(void 0,e)},this.reconnectDelay))}handleMessage(e){for(const r of this.listeners)try{r(e)}catch(s){console.error("Error in message listener:",s)}switch(e.type){case"message_history":{const r=qt(this.stateStore).sessionId;if(r&&e.sessionId&&e.sessionId!==r)break;this.clearLoadWatchdog();break}case"session_error":case"session_destroyed":case"session_interrupted":this.clearLoadWatchdog();break}switch(e.type){case"session_created":case"session_error":case"session_interrupted":this.clearCreateWatchdog();break}switch(e.type){case"connected":this.stateStore.update(s=>({...s,connected:!0,connecting:!1,clientId:e.clientId,serverVersion:e.serverVersion??null,error:null}));break;case"file_uploaded":{const s=this.pendingUploads.get(e.uploadId);s&&(s.resolve({savedPath:e.savedPath,filename:e.filename}),this.pendingUploads.delete(e.uploadId));break}case"file_upload_error":{const s=this.pendingUploads.get(e.uploadId);s&&(s.reject(new Error(e.error)),this.pendingUploads.delete(e.uploadId));break}case"agent_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.stateStore.update(s=>({...s,isStreaming:!0}));break;case"thinking_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="thinking"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"thinking",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_update":this.stateStore.update(s=>{let o=[...s.messages].reverse().find(a=>a.role==="assistant"&&a.isStreaming);if(!o){const a={id:this.generateId(),role:"assistant",content:e.delta,timestamp:Date.now(),isStreaming:!0};return{...s,messages:[...s.messages,a]}}return{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content+e.delta,isStreaming:!0}:a)}});break;case"message_ack":typeof e.content=="string"&&this.confirmDeliveredByContent(e.content);break;case"queue_update":{const s=Array.isArray(e.steering)?[...e.steering]:[];this.stateStore.update(o=>({...o,pendingSteering:s,messages:this.withRestoredQueuedMessages(o.messages,s)}));break}case"message_end":this.stateStore.update(s=>{let o=s.messages;const a=[...o].reverse().find(d=>d.role==="thinking"&&d.isStreaming);a&&(o=o.map(d=>d.id===a.id?{...d,isStreaming:!1}:d));const i=[...o].reverse().find(d=>d.role==="assistant"&&d.isStreaming);if(i)o=o.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 qt(this.stateStore);const S=o.find(R=>R.role==="user"&&R.restoredFromQueue&&R.content===e.content);if(S)return{...s,messages:o.map(R=>R.id===S.id?{...R,restoredFromQueue:void 0}:R)}}const d=e.role==="user"?Ds(e.content):null;if(d){const _=[...o].reverse().find(S=>S.role==="user"&&Ds(S.content)===d);if(_)return _.content!==e.content&&(o=o.map(S=>S.id===_.id?{...S,content:e.content}:S)),{...s,messages:o}}const m=[...o].reverse().find(_=>_.role==="user");e.role==="user"&&m&&m.content===e.content||(o=[...o,{id:this.generateId(),role:e.role||"assistant",content:e.content,timestamp:Date.now(),isStreaming:!1}])}return{...s,messages:o}});break;case"agent_end":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null),this.agentEndTimeout=setTimeout(()=>{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,pendingSteering:[],messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)})),this.agentEndTimeout=null},300);break;case"tool_start":this.agentEndTimeout&&(clearTimeout(this.agentEndTimeout),this.agentEndTimeout=null);const r=e.args?Object.entries(e.args).filter(([s,o])=>o!==void 0&&o!=="").map(([s,o])=>`${s}=${JSON.stringify(o)}`).join(" "):"";this.stateStore.update(s=>{const o=s.messages.map(m=>m.isStreaming&&(m.role==="assistant"||m.role==="thinking")?{...m,isStreaming:!1}:m),a=Date.now(),i=!!e.forceCommand;if(i){const m=o.find(x=>x.role==="tool"&&x.optimistic&&x.isStreaming);if(m)return{...s,messages:o.map(x=>x.id===m.id?{...x,optimistic:!1,toolName:e.toolName,toolArgs:r,content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,startedAt:a,timestamp:a,forceCommand:!0}:x)}}const d={id:this.generateId(),role:"tool",content:r?`$ ${e.toolName} ${r}`:`$ ${e.toolName}`,timestamp:a,isStreaming:!0,toolName:e.toolName,toolArgs:r,toolOutput:"",startedAt:a,...i?{forceCommand:!0}:{}};return{...s,messages:[...o,d]}});break;case"tool_update":{this.stateStore.update(s=>{const o=[...s.messages].reverse().find(a=>a.role==="tool"&&a.toolName===e.toolName&&a.isStreaming);return o?{...s,messages:s.messages.map(a=>a.id===o.id?{...a,content:a.content.includes(`
2
+ `)?a.content+e.delta:`${a.content}
3
+ ${e.delta}`,toolOutput:`${a.toolOutput}${e.delta}`}:a)}:s});break}case"tool_end":{const s=e.result?`${e.result}`:"",o=!!e.isError&&this.isAbortedToolResult(s),a=!!e.isError&&!o,i=Array.isArray(e.images)&&e.images.length>0?e.images:void 0;this.stateStore.update(d=>{const m=d.messages.find(_=>_.role==="tool"&&_.toolName===e.toolName&&_.isStreaming)??[...d.messages].reverse().find(_=>_.role==="tool"&&_.toolName===e.toolName&&!_.content.startsWith("Tool error:")),x=Date.now();if(m){const _=a?"Error: ":"";return{...d,messages:d.messages.map(S=>S.id===m.id?{...S,content:`${_}${S.content}
4
+ ${s}`,isStreaming:!1,isError:a,interrupted:o,toolOutput:s,...i?{images:i}:{},endedAt:x}:S)}}else{const _=a?`Tool error: ${e.toolName}
5
+ ${s}`:`${e.toolName}
6
+ ${s}`,S={id:this.generateId(),role:"tool",content:_,timestamp:x,isStreaming:!1,toolName:e.toolName,toolArgs:"",toolOutput:s,...i?{images:i}:{},isError:a,interrupted:o,endedAt:x};return{...d,messages:[...d.messages,S]}}});break}case"aborted":{const s=Date.now();this.stateStore.update(o=>({...o,isStreaming:!1,messages:o.messages.map(a=>a.isStreaming?{...a,isStreaming:!1,...a.role==="tool"?{interrupted:!0}:{},endedAt:a.role==="tool"&&a.endedAt===void 0?s:a.endedAt}:a)}));break}case"session_created":{{const s=qt(this.stateStore),o=this.pendingLoadFile!==null&&(e.sessionFile===this.pendingLoadFile||e.sessionId===this.pendingLoadFile),a=this.pendingLoadFile===null&&s.creatingSession;if(!o&&!a)break}this.pendingLoadFile=null,this.stateStore.update(s=>({...s,session:e.sessionFile,sessionId:e.sessionId,activeSessionFile:e.sessionFile,activeCwd:e.cwd,activeModel:e.model,isStreaming:e.isStreaming??!1,creatingSession:!1,readOnly:e.readOnly??!1,folderConflict:e.folderConflict?{cwd:e.cwd,active:!0,continued:!1}: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=qt(this.stateStore).sessionId;s&&this.send({type:"skills_request",sessionId:s})}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":this.stateStore.update(s=>s.sessionId===e.sessionId?{...s,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,loadingSession:!1,agentPending:!1,notice:null,sudoPrompt:null}:s);break;case"session_error":this.stateStore.update(s=>({...s,sessionError:e.error,isStreaming:!1,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1}));break;case"folder_conflict":this.stateStore.update(s=>!s.sessionId||s.activeCwd&&e.cwd!==s.activeCwd?s:e.active?s.folderConflict?{...s,folderConflict:{...s.folderConflict,cwd:e.cwd,active:!0}}:{...s,folderConflict:{cwd:e.cwd,active:!0,continued:!0}}:s.folderConflict?{...s,folderConflict:null}: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=qt(this.stateStore).sessionId;if(d&&e.sessionId&&e.sessionId!==d)break}const s=e.sessionId,o=qt(this.stateStore).messages.filter(d=>d.role==="user"&&d.delivery!==void 0),i=[...this.loadPersistedPending(s),...o];this.stateStore.update(d=>{const m=this.mapHistory(e.messages,e.sessionId,d.isStreaming),x=typeof e.totalCount=="number"?e.totalCount:m.length,_=typeof e.offset=="number"?e.offset:0,S=new Set(m.filter(O=>O.role==="user").map(O=>O.content)),R=new Set,P=[];for(const O of i)S.has(O.content)||R.has(O.content)||(R.add(O.content),P.push({...O,sessionId:s,delivery:"failed"}));return{...d,messages:[...m,...P],historyTotalCount:x,historyOffset:_,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 o=this.mapHistory(e.messages,e.sessionId,!1),a=typeof e.offset=="number"?e.offset:0;return o.length===0?{...s,loadingMoreHistory:!1,historyOffset:a}:{...s,messages:[...o,...s.messages],historyOffset:a,loadingMoreHistory:!1}});break;case"model_changed":this.stateStore.update(s=>({...s,activeModel:e.model}));break}}isAbortedToolResult(e){if(!e)return!1;const r=e.trimEnd().split(`
7
+ `),s=(r[r.length-1]||"").trim();return/^(command|operation)?\s*aborted$/i.test(s)}mapHistory(e,r,s){const o=[],a={},i={},d=(_,S)=>{const R=a[_];if(!R)return;const P=R.indexOf(S);P!==-1&&R.splice(P,1)};for(const _ of e)if(_.role==="tool_call"){const S=_.toolName||"unknown",R=_.content||"",P=o.length;o.push({id:this.generateId(),role:"tool",content:R?`$ ${S} ${R}`:`$ ${S}`,timestamp:_.timestamp,isStreaming:!1,toolName:S,toolArgs:R,toolOutput:"",sessionId:r,...Number.isFinite(_.timestamp)?{startedAt:_.timestamp}:{},..._.forceCommand?{forceCommand:!0}:{}}),a[S]||(a[S]=[]),a[S].push(P),typeof _.toolCallId=="string"&&_.toolCallId&&(i[_.toolCallId]=P)}else if(_.role==="tool_result"){const S=_.toolName||"unknown";let R;if(typeof _.toolCallId=="string"&&_.toolCallId&&i[_.toolCallId]!==void 0)R=i[_.toolCallId],delete i[_.toolCallId],d(S,R);else if(a[S]&&a[S].length>0){R=a[S].shift();for(const[q,ve]of Object.entries(i))ve===R&&delete i[q]}const P=_.isError&&!this.isAbortedToolResult(_.content),O=!!_.isError&&this.isAbortedToolResult(_.content);if(R!==void 0){const q=o[R],ve=q.toolArgs||"",Z=q.startedAt;o[R]={...q,content:ve?`$ ${S} ${ve}
8
+ ${_.content}`:`$ ${S}
9
+ ${_.content}`,isStreaming:!1,toolOutput:_.content,...Array.isArray(_.images)&&_.images.length>0?{images:_.images}:{},isError:P,interrupted:O,timestamp:_.timestamp,...Z!==void 0&&Number.isFinite(Z)&&Number.isFinite(_.timestamp)&&_.timestamp>=Z?{endedAt:_.timestamp}:{}}}else o.push({id:this.generateId(),role:"tool",content:`$ ${S}
10
+ ${_.content}`,timestamp:_.timestamp,isStreaming:!1,toolName:S,toolArgs:"",toolOutput:_.content,...Array.isArray(_.images)&&_.images.length>0?{images:_.images}:{},isError:P,interrupted:O,sessionId:r})}else o.push({id:this.generateId(),role:_.role,content:_.content,timestamp:_.timestamp,isStreaming:!1,toolName:_.toolName,sessionId:r,...typeof _.entryId=="string"&&_.entryId?{entryId:_.entryId}:{}});const m=[];for(const _ of Object.values(a))m.push(..._);m.sort((_,S)=>_-S);const x=s&&m.length>0?m[m.length-1]:-1;for(const _ of m)_===x?o[_]={...o[_],isStreaming:!0}:o[_]={...o[_],interrupted:!0};if(s&&o.length>0){const _=o.length-1,S=o[_];(S.role==="assistant"||S.role==="thinking")&&(o[_]={...S,isStreaming:!0})}return o}loadMoreHistory(){const e=qt(this.stateStore);e.sessionId&&(e.loadingMoreHistory||e.historyOffset<=0||(this.stateStore.update(r=>({...r,loadingMoreHistory:!0})),this.send({type:"history_load_more",sessionId:e.sessionId,beforeOffset:e.historyOffset})))}send(e){if(this.ws&&this.ws.readyState===1)try{return this.ws.send(JSON.stringify(e)),!0}catch{return!1}return!1}messageFrame(e,r,s){return{type:"message",message:e,sessionId:r,...s?.conversationMode?{conversationMode:!0}:{}}}sendMessage(e,r){const s=qt(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(),x=/^sudo(\s|$)/.test(m);if(m&&!x){const _=`command=${JSON.stringify(m)}`,S=Date.now(),R={id:this.generateId(),role:"tool",content:`$ bash ${_}`,timestamp:S,isStreaming:!0,toolName:"bash",toolArgs:_,toolOutput:"",startedAt:S,forceCommand:!0,optimistic:!0};return this.stateStore.update(P=>({...P,sessionError:null,messages:[...P.messages,R]})),!0}return this.stateStore.update(_=>({..._,sessionError:null})),!0}const a={id:this.generateId(),role:"user",content:e,timestamp:Date.now(),isStreaming:!1,sessionId:s.sessionId,delivery:"sending"};return this.stateStore.update(i=>({...i,sessionError:null,messages:[...i.messages,a]})),this.armConfirm(a.id),this.persistPending(s.sessionId),!0}withRestoredQueuedMessages(e,r){if(r.length===0)return e;const s=new Map;for(const a of e)a.role==="user"&&s.set(a.content,(s.get(a.content)??0)+1);const o=[];for(const a of r){const i=s.get(a)??0;if(i>0){s.set(a,i-1);continue}o.push({id:this.generateId(),role:"user",content:a,timestamp:Date.now(),isStreaming:!1,restoredFromQueue:!0})}return o.length>0?[...e,...o]:e}pendingKey(e){return ir.PENDING_PREFIX+e}persistPending(e){if(!e||typeof localStorage>"u")return;const r=qt(this.stateStore).messages.filter(s=>s.role==="user"&&s.delivery!==void 0);try{r.length===0?localStorage.removeItem(this.pendingKey(e)):localStorage.setItem(this.pendingKey(e),JSON.stringify(r.map(s=>({id:s.id,content:s.content,timestamp:s.timestamp,delivery:"failed"}))))}catch{}}loadPersistedPending(e){if(typeof localStorage>"u")return[];try{const r=localStorage.getItem(this.pendingKey(e));if(!r)return[];const s=JSON.parse(r);return Array.isArray(s)?s.filter(o=>o&&typeof o.content=="string").map(o=>({id:typeof o.id=="string"?o.id:this.generateId(),role:"user",content:o.content,timestamp:typeof o.timestamp=="number"?o.timestamp:Date.now(),isStreaming:!1,sessionId:e,delivery:"failed"})):[]}catch{return[]}}armConfirm(e){if(this.clearConfirm(e),typeof setTimeout!="function")return;const r=setTimeout(()=>{this.confirmTimers.delete(e);let s=null;this.stateStore.update(o=>{const a=o.messages.find(i=>i.id===e);return!a||a.delivery!=="sending"?o:(s=o.sessionId,{...o,messages:o.messages.map(i=>i.id===e?{...i,delivery:"failed"}:i)})}),s&&this.persistPending(s)},ir.CONFIRM_MS);r&&typeof r.unref=="function"&&r.unref(),this.confirmTimers.set(e,r)}clearConfirm(e){const r=this.confirmTimers.get(e);r&&(clearTimeout(r),this.confirmTimers.delete(e))}confirmDeliveredByContent(e){let r=null,s=null;const o=Ds(e);return this.stateStore.update(a=>{let i=a.messages.find(d=>d.role==="user"&&d.delivery!==void 0&&d.content===e);return!i&&o&&(i=a.messages.find(d=>d.role==="user"&&d.delivery!==void 0&&Ds(d.content)===o)),i?(r=i.id,s=a.sessionId,{...a,messages:a.messages.map(d=>d.id===i.id?{...d,delivery:void 0,...o?{content:e}:{}}:d)}):a}),r?(this.clearConfirm(r),this.persistPending(s),!0):!1}resendMessage(e,r){const s=qt(this.stateStore),o=s.messages.find(i=>i.id===e&&i.role==="user");return!o||!s.sessionId?!1:this.getIsConnected()?this.send(this.messageFrame(o.content,s.sessionId,r))?(this.stateStore.update(i=>({...i,sessionError:null,messages:i.messages.map(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(o=>o.id!==e)})),r&&this.persistPending(r)}abort(){const e=qt(this.stateStore);e.sessionId&&this.send({type:"abort",sessionId:e.sessionId})}cancelSteer(){const e=qt(this.stateStore);e.sessionId&&(this.send({type:"cancel_steer",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,pendingSteering:[]})))}joinSession(e,r,s){this.stateStore.update(o=>({...o,folderConflict:null,sessionError:null,loadingSession:!0,agentPending:!1})),this.pendingLoadFile=e,this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog()}switchSession(e,r,s){const o=qt(this.stateStore);o.activeSessionFile===e&&!o.loadingSession&&!o.resyncing||(o.sessionId&&this.send({type:"session_leave",sessionId:o.sessionId}),this.stateStore.update(a=>({...a,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,folderConflict: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.clearCreateWatchdog(),this.pendingLoadFile=e,this.send({type:"session_load",sessionFile:e,cwd:r,model:s}),this.armLoadWatchdog())}forkSession(e,r){return!e||!r?!1:this.send({type:"session_fork",sessionId:e,entryId:r})}createSession(e,r,s,o,a,i){this.stateStore.update(d=>({...d,folderConflict:null,sessionError:null,creatingSession:!0,loadingSession:!1})),this.pendingLoadFile=null,this.send({type:"session_new",cwd:e,model:r,gitInit:s,createRemote:o,repoVisibility:a,cloneRemote:i}),this.armCreateWatchdog()}leaveSession(){const e=qt(this.stateStore);if(this.clearCreateWatchdog(),!e.sessionId){e.creatingSession&&this.stateStore.update(r=>({...r,creatingSession:!1}));return}this.send({type:"session_leave",sessionId:e.sessionId}),this.stateStore.update(r=>({...r,messages:[],session:null,sessionId:null,activeSessionFile:null,activeCwd:null,activeModel:null,readOnly:!1,notice:null,sudoPrompt:null,creatingSession:!1,loadingSession:!1,resyncing:!1,agentPending:!1,contextUsage:null,pendingSteering:[]})),this.clearLoadWatchdog(),this.pendingLoadFile=null,this.resumeSessionFile=null,this.resumeCwd=void 0,this.resumeModel=void 0}continueFolderConflict(){const e=qt(this.stateStore);!e.folderConflict||!e.sessionId||(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=qt(this.stateStore).sudoPrompt;s&&(this.send({type:"bash_sudo_password",sessionId:s.sessionId,promptId:s.promptId,password:e}),this.stateStore.update(o=>({...o,sudoPrompt:null})))}cancelSudoPrompt(){const r=qt(this.stateStore).sudoPrompt;this.stateStore.update(s=>({...s,sudoPrompt:null})),r&&this.send({type:"bash_sudo_cancel",sessionId:r.sessionId,promptId:r.promptId})}changeModel(e){this.send({type:"model_change",model:e})}setConfig(e){this.config={...this.config,...e},this.stateStore.update(r=>{const s={...r};return e.hideThinking!==void 0&&(s.hideThinking=!!e.hideThinking),e.hideTools!==void 0&&(s.hideTools=!!e.hideTools),s})}onMessage(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}uploadFileViaWebSocket(e,r,s){return new Promise((o,a)=>{const i=this.generateId();this.pendingUploads.set(i,{resolve:o,reject:a}),this.send({type:"file_upload",uploadId:i,sessionId:e,filename:r,data:s})})}generateId(){return Math.random().toString(36).substring(2)+Date.now().toString(36)}getIsConnected(){return this.ws&&this.ws.readyState===1}}const gc=["speakReplies","collapseLongReplies","micReopensAfterReply"];function mc(n){return gc.includes(n)}function Ws(n,e){return mc(n)?e.conversationMode&&e[n]:e[n]}function xc(n){return Ws("speakReplies",n)}const as=Cn({folders:[],activeSessions:[],currentSession:null,loading:!1}),is=Cn({models:[],loading:!1}),ms=Cn({folders:[],activeSessions:[],currentSession:null,loading:!1});function xo(){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 fr(){const n=localStorage.getItem("wherever-config"),e=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost";if(n){const r=JSON.parse(n),s=window.location.protocol==="https:"?"https:":"http:";let o=r.host||e;(o==="localhost"||o==="127.0.0.1")&&e&&e!=="localhost"&&e!=="127.0.0.1"&&(o=e),o=o.startsWith("http")?o.replace(/^wss?:\/\//,""):o;let a=r.port;return(a===31415||a===void 0)&&xo()!==31415&&(a=xo()),`${s}//${o}:${a||xo()}`}return`${window.location.protocol}//${window.location.host}`}let ds=null,xs=[],Eo=!1,Io=!1,Ra=0;const _c=150,yc=1e3;async function wc(){Eo=!0;try{const n=fr(),e=pr(),r=`${n}/sessions${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();as.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:qn(as).currentSession,loading:!1})}catch(n){as.update(e=>({...e,loading:!1})),console.error("Failed to fetch sessions:",n)}finally{Eo=!1}}function ks(){as.update(r=>({...r,loading:!0}));const n=new Promise(r=>{xs.push(r)});if(Eo)return Io=!0,n;const e=Date.now();if(!ds)Ra=e;else if(clearTimeout(ds),e-Ra>=yc)return ds=null,Ca(),n;return ds=setTimeout(()=>{ds=null,Ca()},_c),n}async function Ca(){try{do{Io=!1;const n=xs;xs=[];try{await wc()}finally{for(const e of n)e()}}while(Io)}finally{const n=xs;xs=[];for(const e of n)e()}}async function ai(){ms.update(n=>({...n,loading:!0}));try{const n=fr(),e=pr(),r=`${n}/sessions?view=readonly${e?`&token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();ms.set({folders:o.folders||[],activeSessions:(o.activeSessions||[]).map(a=>a.sessionFile),currentSession:qn(ms).currentSession,loading:!1})}catch(n){ms.update(e=>({...e,loading:!1})),console.error("Failed to fetch read-only sessions:",n)}}async function kc(){is.update(n=>({...n,loading:!0}));try{const n=fr(),e=pr(),r=`${n}/models${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();is.set({models:o.models||[],loading:!1})}catch(n){is.update(e=>({...e,loading:!1})),console.error("Failed to fetch models:",n)}}function pr(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n).token||""}catch{}return""}const jo=Cn(!1),ii=Cn("websocket"),Go=Cn(null),li=Cn(!1),ci=Cn(null);async function di(n){if(!n.trim())return null;try{const e=fr(),r=pr(),s=`${e}/check-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}catch(e){return console.error("Failed to check path:",e),null}}async function Sc(n){if(!n.trim())return null;try{const e=fr(),r=pr(),s=`${e}/check-remote-repo?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}catch(e){return console.error("Failed to check remote repo:",e),null}}async function js(n){try{const e=fr(),r=pr(),s=`${e}/autocomplete-path?path=${encodeURIComponent(n)}${r?`&token=${encodeURIComponent(r)}`:""}`,o=await fetch(s);if(!o.ok)throw new Error(`HTTP ${o.status}`);return(await o.json()).completions||[]}catch(e){return console.error("Failed to autocomplete path:",e),[]}}async function Tc(){try{const n=fr(),e=pr(),r=`${n}/config${e?`?token=${encodeURIComponent(e)}`:""}`,s=await fetch(r);if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.json();jo.set(!!o.gitInitDefault),ii.set(o.uploadMethod||"websocket"),Go.set(o.searchFolder||null),li.set(!!o.searchCreateRemote),ci.set(o.searchDefaultModel||null)}catch(n){console.error("Failed to fetch config:",n)}}function Ss(n){as.update(e=>({...e,currentSession:n}))}function Ac(){try{const n=localStorage.getItem("wherever-config");if(n)return JSON.parse(n)}catch{}return null}function Ir(n){localStorage.setItem("wherever-config",JSON.stringify(n))}function _o(){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 En(){const n=typeof window<"u"&&window.location&&window.location.hostname?window.location.hostname:"localhost",e=Ac();return e?((e.port===31415||e.port===void 0)&&_o()!==31415&&(e.port=_o()),(!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:_o(),token:"",hideThinking:!1,hideTools:!1,beepDefault:!1,beepSoundUrl:"",conversationMode:!1,speakReplies:!1,collapseLongReplies:!1,micReopensAfterReply:!1}}const Xs=Cn(!!En().beepDefault),ui="wherever-beep-overrides";function Rc(){try{const n=localStorage.getItem(ui);if(n){const e=JSON.parse(n);if(e&&typeof e=="object")return e}}catch{}return{}}function Cc(n){try{localStorage.setItem(ui,JSON.stringify(n))}catch{}}const fi=Cn(typeof localStorage<"u"?Rc():{}),qo=Cn("");function Ec(){return qn(Xs)}function pi(){const n=En().beepSoundUrl;return typeof n=="string"?n:""}function Ic(n){const e=En();Ir({...e,beepSoundUrl:n})}const Vo=en([qo,fi],([n,e])=>n&&n in e?e[n]:void 0),Ko=en([Vo,Xs],([n,e])=>n===void 0?e:n);function $c(n){const e=En();Ir({...e,beepDefault:n}),Xs.set(n)}function Us(n){const e=qn(qo);e&&fi.update(r=>{const s={...r};return n===void 0?delete s[e]:s[e]=n,Cc(s),s})}function hi(n){qo.set(n??"")}const bi="wherever-speech-direct-send";function vi(){try{return localStorage.getItem(bi)==="true"}catch{}return!1}const Yo=Cn(typeof localStorage<"u"?vi():!1);function gi(){return vi()}function mi(n){try{localStorage.setItem(bi,String(n))}catch{}Yo.set(n)}const Zs=Cn(!!En().conversationMode),Qs=Cn(!!En().speakReplies),Js=Cn(!!En().collapseLongReplies),eo=Cn(!!En().micReopensAfterReply),xi={subscribe:Zs.subscribe},_i={subscribe:Qs.subscribe},yi={subscribe:Js.subscribe},Mc={subscribe:eo.subscribe};function wi(){return qn(Zs)}function ki(n){const e=En();Ir({...e,conversationMode:n}),Zs.set(n)}function Lc(n){const e=En();Ir({...e,speakReplies:n}),Qs.set(n)}function Dc(n){const e=En();Ir({...e,collapseLongReplies:n}),Js.set(n)}function Oc(n){const e=En();Ir({...e,micReopensAfterReply:n}),eo.set(n)}function to(){return{conversationMode:wi(),autoSendOnSpeechEnd:gi(),speakReplies:qn(Qs),collapseLongReplies:qn(Js),micReopensAfterReply:qn(eo)}}function Si(n){ki(n)}function Xo(){return{conversationMode:xc(to())}}const us=En(),ft=new ir({host:us.host,port:us.port,token:us.token,secure:typeof window<"u"&&window.location&&window.location.protocol==="https:",hideThinking:!!us.hideThinking,hideTools:!!us.hideTools}),no=ft.stateStore;let yo=!1,Ea=null;no.subscribe(n=>{const e=n.sessionId??n.activeSessionFile??null;if(e!==Ea){Ea=e,hi(e),yo=n.isStreaming;return}yo&&!n.isStreaming&&e&&qn(Ko)&&oi(pi()),yo=n.isStreaming});let _s=null;const Zo=Cn({text:"",bump:0});function Ti(n){Zo.update(e=>({text:n,bump:e.bump+1}))}let fs=null;ft.onMessage(n=>{switch(n.type){case"session_forked":{const r=n;fs=r.prefillText??"",ro(r.sessionFile,r.cwd);break}case"session_created":if(Ss(n.sessionFile),fs!==null){const r=fs;fs=null,queueMicrotask(()=>Ti(r))}if(_s!==null){const r=_s;_s=null,queueMicrotask(()=>ft.sendMessage(r,Xo()))}break;case"session_error":_s=null,fs=null;break;case"session_destroyed":qn(no).sessionId===n.sessionId&&Ss(null);break;case"sessions_updated":ks();break;case"session_interrupted":Ss(null);break}});function Yr(){const n=En();Ir(n);const e=typeof window<"u"&&window.location&&window.location.protocol==="https:";ft.connect({host:n.host,port:n.port,token:n.token,secure:e,hideThinking:!!n.hideThinking,hideTools:!!n.hideTools})}function Cs(){ft.disconnect(!0),Ss(null)}function Ai(){ft.suspend()}function $o(){ft.resume()}function Pc(){return ft.hasSuspendedSession()}function Mo(){return ft.hasActiveSession()}let Qo=0;const Nc=300*1e3;function Ri(){Qo=Date.now()+Nc}function Jo(){Qo=0}function Ci(){return Date.now()<Qo}function Lo(n){return ft.sendMessage(n,Xo())}function Ei(n){return ft.resendMessage(n,Xo())}function Ii(n){ft.discardMessage(n)}function $i(){ft.abort()}function Mi(){ft.cancelSteer()}function Li(n,e,r){ft.joinSession(n,e,r)}function ro(n,e,r){ft.switchSession(n,e,r)}function Di(n,e){ft.forkSession(n,e)}function mr(n,e,r,s,o,a){ft.createSession(n,e,r,s,o,a)}function Oi(n,e){const r=n.trim();if(!r)return!1;const s=qn(Go);if(!s)return!1;const o=qn(li);return _s=r,ft.createSession(s,e||void 0,o,o,o?"private":void 0),!0}function lr(){ft.leaveSession(),Ss(null)}function Pi(){ft.loadMoreHistory()}function Ni(){ft.continueFolderConflict()}function Fc(){ft.ping()}function Fi(){ft.clearMessages()}function Do(n){Ir(n);const{host:e,port:r,token:s,hideThinking:o,hideTools:a}=n;ft.setConfig({host:e,port:r,token:s,hideThinking:o,hideTools:a}),n.beepDefault!==void 0&&Xs.set(!!n.beepDefault),n.conversationMode!==void 0&&Zs.set(!!n.conversationMode),n.speakReplies!==void 0&&Qs.set(!!n.speakReplies),n.collapseLongReplies!==void 0&&Js.set(!!n.collapseLongReplies),n.micReopensAfterReply!==void 0&&eo.set(!!n.micReopensAfterReply)}function Ui(n){const r={...En(),...n};Ir(r),ft.setConfig(r)}function Xr(){ft.dismissSessionError()}function zi(){ft.dismissNotice()}function Bi(n){ft.sendSudoPassword(n)}function Hi(){ft.cancelSudoPrompt()}function Wi(n){ft.changeModel(n)}const Vt=en(no,n=>n),Is=en(Vt,n=>n.connected),ea=en(Vt,n=>n.isStreaming),ji=en(Vt,n=>n.messages),Uc=en(Vt,n=>n.error),zc=en(Vt,n=>n.session),Gi=en(Vt,n=>n.folderConflict),qi=en(Vt,n=>n.isInterrupted),Vi=en(Vt,n=>n.pendingSteering),ta=en(Vt,n=>n.sessionError),Ki=en(Vt,n=>n.notice),Yi=en(Vt,n=>n.sudoPrompt),so=en(Vt,n=>n.readOnly),$s=en(Vt,n=>({sessionFile:n.activeSessionFile,cwd:n.activeCwd,model:n.activeModel,sessionId:n.sessionId})),Bc=en(Vt,n=>n.contextUsage),Xi=en(Vt,n=>n.creatingSession),oo=en(Vt,n=>n.loadingSession),na=en(Vt,n=>n.resyncing),Zi=en(Vt,n=>n.agentPending),Qi=en(Vt,n=>n.historyOffset>0),Ji=en(Vt,n=>n.loadingMoreHistory);async function Hc(n,e){const r=fr(),s=pr(),o=`${r}/session/upload?sessionId=${encodeURIComponent(n)}&filename=${encodeURIComponent(e.name)}${s?`&token=${encodeURIComponent(s)}`:""}`,a=await e.arrayBuffer(),i=await fetch(o,{method:"POST",headers:{"Content-Type":"text/plain"},body:a});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.error||`Upload failed with status ${i.status}`)}return await i.json()}function Wc(n,e){return new Promise((r,s)=>{try{const o=new FileReader;o.onload=()=>{try{const i=o.result.split(",")[1]||"";ft.uploadFileViaWebSocket(n,e.name,i).then(r).catch(s)}catch(a){s(new Error(`Failed to process file data: ${a.message}`))}},o.onerror=()=>{s(new Error("Failed to read file contents"))},o.readAsDataURL(e)}catch(o){s(o)}})}function el(n){const r=qn(Vt).sessionId;if(!r)return null;const s=fr(),o=pr();return`${s}/session/download?sessionId=${encodeURIComponent(r)}&path=${encodeURIComponent(n)}`+(o?`&token=${encodeURIComponent(o)}`:"")}async function tl(n,e){return qn(ii)==="post"?Hc(n,e):Wc(n,e)}async function Oo(n){try{const e=fr(),r=pr(),s=`${e}/session/delete${r?`?token=${encodeURIComponent(r)}`:""}`,o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionFile:n})});if(!o.ok){const a=await o.json().catch(()=>({}));throw new Error(a.error||`Delete failed with status ${o.status}`)}}catch(e){throw console.error("Failed to delete session:",e),e}}const jc=Object.freeze(Object.defineProperty({__proto__:null,abort:$i,activeSessionInfo:$s,autoSendOnSpeechEnd:Yo,beepEnabled:Ko,beepSessionOverride:Vo,beginFilePicker:Ri,cancelSteer:Mi,cancelSudoPrompt:Hi,changeModel:Wi,clearMessages:Fi,client:ft,collapseLongReplies:yi,composerPrefill:Zo,connect:Yr,connectionError:Uc,contextUsage:Bc,continueFolderConflict:Ni,conversationMode:xi,createSession:mr,currentSession:zc,deleteSession:Oo,discardMessage:Ii,disconnect:Cs,dismissNotice:zi,dismissSessionError:Xr,downloadFileUrl:el,endFilePicker:Jo,folderConflict:Gi,forkSession:Di,getAutoSendOnSpeechEnd:gi,getBeepDefault:Ec,getBeepSoundUrl:pi,getConfig:En,getConversationKnobs:to,getConversationMode:wi,hasActiveSession:Mo,hasMoreHistory:Qi,hasSuspendedSession:Pc,isAgentPending:Zi,isConnected:Is,isCreatingSession:Xi,isFilePickerActive:Ci,isInterrupted:qi,isLoadingMoreHistory:Ji,isLoadingSession:oo,isReadOnly:so,isResyncing:na,isStreaming:ea,joinSession:Li,leaveSession:lr,loadMoreHistory:Pi,messages:ji,micReopensAfterReply:Mc,parseSkillInvocation:Wo,pendingSteering:Vi,piState:Vt,ping:Fc,prefillComposer:Ti,resendMessage:Ei,resume:$o,runSearch:Oi,sendMessage:Lo,sendSudoPassword:Bi,sessionError:ta,sessionNotice:Ki,setAutoSendOnSpeechEnd:mi,setBeepDefault:$c,setBeepSessionKey:hi,setBeepSessionOverride:Us,setBeepSoundUrl:Ic,setCollapseLongReplies:Dc,setConfig:Do,setConversationMode:ki,setConversationModeBundle:Si,setMicReopensAfterReply:Oc,setSpeakReplies:Lc,speakReplies:_i,state:no,sudoPrompt:Yi,suspend:Ai,switchSession:ro,updateConfig:Ui,uploadFile:tl},Symbol.toStringTag,{value:"Module"}));function Gc(n){if(!n)return null;const e=n.text;if(typeof e!="string")return null;const r=e.trim();return r||null}let Ts=0,zs=[];function qc(){if(Ts>0&&Ts--,Ts===0&&zs.length>0){const n=zs;zs=[];for(const e of n)e()}}function Vc(){return Ts===0?Promise.resolve():new Promise(n=>{zs.push(n)})}let Ia=!1;function nl(n){try{typeof n.resume=="function"&&n.resume()}catch{}}function ra(n=rl()){if(Ia)return!1;const{synth:e,Utterance:r}=n;if(!e||!r)return!1;try{nl(e);const s=new r(" ");return s.volume=0,e.speak(s),Ia=!0,!0}catch{return!1}}function rl(){if(typeof window>"u")return{synth:null,Utterance:null};const n=window;return{synth:n.speechSynthesis??null,Utterance:n.SpeechSynthesisUtterance??null}}function Kc(n,e,r=rl()){const s=(n??"").trim();if(!s)return!1;const{synth:o,Utterance:a}=r;if(!o||!a)return!1;Ts++;let i=!1;const d=()=>{i||(i=!0,qc())};try{nl(o);const m=new a(s);return e&&e.trim()&&(m.lang=e.trim()),m.onend=d,m.onerror=d,o.speak(m),!0}catch{return d(),!1}}var Yc=g('<button class="flex-1 rounded bg-rose-500 px-4 py-2 text-sm text-white transition-colors hover:bg-rose-600">Disconnect</button>'),Xc=g('<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>'),Zc=g(`<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 (spoken back-and-forth)</label></div> <p class="pl-6 text-[10px] leading-relaxed text-brand-text-muted">Flips the knobs below on at once. When off, they are dormant and the
11
+ default typing-first experience is unchanged. Auto-send on speech end
12
+ (Direct 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></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 Qc(n,e){zr(e,!0);const r=()=>Se(Is,"$isConnected",s),[s,o]=ls();let a=W(""),i=W(0),d=W(""),m=W(!1),x=W(!1),_=W(""),S=W(!1),R=W(!1),P=W(!1),O=W(!1),q=!1,ve=G(r);Es(()=>{const A=En();h(a,A.host,!0),h(i,A.port,!0),h(d,A.token||"",!0),h(m,!!A.hideThinking),h(x,!!A.beepDefault),h(_,A.beepSoundUrl||"",!0),h(S,!!A.conversationMode),h(R,!!A.speakReplies),h(P,!!A.collapseLongReplies),h(O,!!A.micReopensAfterReply)});function Z(){oi(t(_).trim()||void 0)}function ae(){Do({host:t(a),port:t(i),token:t(d),hideThinking:t(m),hideTools:!1,beepDefault:t(x),beepSoundUrl:t(_).trim(),conversationMode:t(S),speakReplies:t(R),collapseLongReplies:t(P),micReopensAfterReply:t(O)}),t(S)&&t(R)&&ra()}function Je(){Do({host:t(a),port:t(i),token:t(d),hideThinking:t(m),hideTools:!1,beepDefault:t(x),beepSoundUrl:t(_).trim(),conversationMode:t(S),speakReplies:t(R),collapseLongReplies:t(P),micReopensAfterReply:t(O)}),Cs(),setTimeout(()=>Yr(),100)}function fe(){Cs()}function Ce(){window.location.reload()}var he=Zc(),me=u(he),bt=u(me),It=p(u(bt),2);rt(It),c(bt);var et=p(bt,2),At=p(u(et),2);rt(At),c(et);var se=p(et,2),Ht=p(u(se),2);rt(Ht),c(se);var tt=p(se,2),wt=u(tt);rt(wt),Ve(2),c(tt);var ct=p(tt,2),sn=u(ct);rt(sn),Ve(2),c(ct);var Wt=p(ct,2),je=p(u(Wt),2),$t=u(je);rt($t);var H=p($t,2);c(je),c(Wt);var ze=p(Wt,2),jt=u(ze),Kt=u(jt);rt(Kt),Ve(2),c(jt);var Mt=p(jt,4),Xt=u(Mt);rt(Xt),Ve(2),c(Mt);var Lt=p(Mt,2),Rt=u(Lt);rt(Rt),Ve(2),c(Lt);var vt=p(Lt,2),Xe=u(vt);rt(Xe),Ve(2),c(vt),c(ze);var K=p(ze,2),vn=u(K);{var Le=A=>{var le=Yc();F("click",le,fe),b(A,le)},Ge=A=>{var le=Xc();le.disabled=q,le.textContent="Connect",F("click",le,Je),b(A,le)};k(vn,A=>{t(ve)?A(Le):A(Ge,-1)})}c(K);var M=p(K,2);c(me),c(he),dr(It,()=>t(a),A=>h(a,A)),dr(At,()=>t(i),A=>h(i,A)),dr(Ht,()=>t(d),A=>h(d,A)),F("change",wt,ae),Nn(wt,()=>t(m),A=>h(m,A)),F("change",sn,ae),Nn(sn,()=>t(x),A=>h(x,A)),F("change",$t,ae),dr($t,()=>t(_),A=>h(_,A)),F("click",H,Z),F("change",Kt,ae),Nn(Kt,()=>t(S),A=>h(S,A)),F("change",Xt,ae),Nn(Xt,()=>t(R),A=>h(R,A)),F("change",Rt,ae),Nn(Rt,()=>t(P),A=>h(P,A)),F("change",Xe,ae),Nn(Xe,()=>t(O),A=>h(O,A)),F("click",M,Ce),b(n,he),Br(),o()}Qr(["change","click"]);const Jc=["png","jpg","jpeg","gif","webp","bmp","svg","avif"],ed=["mp3","wav","oga","ogg","m4a","aac","flac","opus"],td=["mp4","webm","mov","m4v","ogv"];function nd(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 rd(n){const e=nd(n);return e?Jc.includes(e)?"image":ed.includes(e)?"audio":td.includes(e)?"video":null:null}function sd(n,e,r){if(r||!e)return null;const s=(n||"").toLowerCase();if(!["attach_file","read"].includes(s))return null;const o=e.path||e.filepath||e.file;return!o||typeof o!="string"?null:o.trim()||null}const od=600;function sl(n){return n?n.length>od:!1}function ad(n){return!n.active||n.expanded?!1:sl(n.content)}function sa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Jr=sa();function ol(n){Jr=n}var As={exec:()=>null};function Tt(n,e=""){let r=typeof n=="string"?n:n.source;const s={replace:(o,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Un.caret,"$1"),r=r.replace(o,i),s},getRegex:()=>new RegExp(r,e)};return s}var Un={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")},id=/^(?:[ \t]*(?:\n|$))+/,ld=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,cd=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ms=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,dd=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,oa=/(?:[*+-]|\d{1,9}[.)])/,al=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,il=Tt(al).replace(/bull/g,oa).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(),ud=Tt(al).replace(/bull/g,oa).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(),aa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,fd=/^[^\n]+/,ia=/(?!\s*\])(?:\\.|[^\[\]\\])+/,pd=Tt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ia).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hd=Tt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,oa).getRegex(),ao="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",la=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,bd=Tt("^ {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",la).replace("tag",ao).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ll=Tt(aa).replace("hr",Ms).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",ao).getRegex(),vd=Tt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ll).getRegex(),ca={blockquote:vd,code:ld,def:pd,fences:cd,heading:dd,hr:Ms,html:bd,lheading:il,list:hd,newline:id,paragraph:ll,table:As,text:fd},$a=Tt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ms).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",ao).getRegex(),gd={...ca,lheading:ud,table:$a,paragraph:Tt(aa).replace("hr",Ms).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",$a).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",ao).getRegex()},md={...ca,html:Tt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",la).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:As,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Tt(aa).replace("hr",Ms).replace("heading",` *#{1,6} *[^
13
+ ]`).replace("lheading",il).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},xd=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_d=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,cl=/^( {2,}|\\)\n(?!\s*$)/,yd=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,io=/[\p{P}\p{S}]/u,da=/[\s\p{P}\p{S}]/u,dl=/[^\s\p{P}\p{S}]/u,wd=Tt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,da).getRegex(),ul=/(?!~)[\p{P}\p{S}]/u,kd=/(?!~)[\s\p{P}\p{S}]/u,Sd=/(?:[^\s\p{P}\p{S}]|~)/u,Td=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,fl=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ad=Tt(fl,"u").replace(/punct/g,io).getRegex(),Rd=Tt(fl,"u").replace(/punct/g,ul).getRegex(),pl="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Cd=Tt(pl,"gu").replace(/notPunctSpace/g,dl).replace(/punctSpace/g,da).replace(/punct/g,io).getRegex(),Ed=Tt(pl,"gu").replace(/notPunctSpace/g,Sd).replace(/punctSpace/g,kd).replace(/punct/g,ul).getRegex(),Id=Tt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,dl).replace(/punctSpace/g,da).replace(/punct/g,io).getRegex(),$d=Tt(/\\(punct)/,"gu").replace(/punct/g,io).getRegex(),Md=Tt(/^<(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(),Ld=Tt(la).replace("(?:-->|$)","-->").getRegex(),Dd=Tt("^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",Ld).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Gs=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Od=Tt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Gs).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),hl=Tt(/^!?\[(label)\]\[(ref)\]/).replace("label",Gs).replace("ref",ia).getRegex(),bl=Tt(/^!?\[(ref)\](?:\[\])?/).replace("ref",ia).getRegex(),Pd=Tt("reflink|nolink(?!\\()","g").replace("reflink",hl).replace("nolink",bl).getRegex(),ua={_backpedal:As,anyPunctuation:$d,autolink:Md,blockSkip:Td,br:cl,code:_d,del:As,emStrongLDelim:Ad,emStrongRDelimAst:Cd,emStrongRDelimUnd:Id,escape:xd,link:Od,nolink:bl,punctuation:wd,reflink:hl,reflinkSearch:Pd,tag:Dd,text:yd,url:As},Nd={...ua,link:Tt(/^!?\[(label)\]\((.*?)\)/).replace("label",Gs).getRegex(),reflink:Tt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Gs).getRegex()},Po={...ua,emStrongRDelimAst:Ed,emStrongLDelim:Rd,url:Tt(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Fd={...Po,br:Tt(cl).replace("{2,}","*").getRegex(),text:Tt(Po.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Os={normal:ca,gfm:gd,pedantic:md},ps={normal:ua,gfm:Po,breaks:Fd,pedantic:Nd},Ud={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ma=n=>Ud[n];function vr(n,e){if(e){if(Un.escapeTest.test(n))return n.replace(Un.escapeReplace,Ma)}else if(Un.escapeTestNoEncode.test(n))return n.replace(Un.escapeReplaceNoEncode,Ma);return n}function La(n){try{n=encodeURI(n).replace(Un.percentDecode,"%")}catch{return null}return n}function Da(n,e){const r=n.replace(Un.findPipe,(a,i,d)=>{let m=!1,x=i;for(;--x>=0&&d[x]==="\\";)m=!m;return m?"|":" |"}),s=r.split(Un.splitPipe);let o=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;o<s.length;o++)s[o]=s[o].trim().replace(Un.slashPipe,"|");return s}function hs(n,e,r){const s=n.length;if(s===0)return"";let o=0;for(;o<s&&n.charAt(s-o-1)===e;)o++;return n.slice(0,s-o)}function zd(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 Oa(n,e,r,s,o){const a=e.href,i=e.title||null,d=n[1].replace(o.other.outputLinkReplace,"$1");s.state.inLink=!0;const m={type:n[0].charAt(0)==="!"?"image":"link",raw:r,href:a,title:i,text:d,tokens:s.inlineTokens(d)};return s.state.inLink=!1,m}function Bd(n,e,r){const s=n.match(r.other.indentCodeCompensation);if(s===null)return e;const o=s[1];return e.split(`
14
+ `).map(a=>{const i=a.match(r.other.beginningSpace);if(i===null)return a;const[d]=i;return d.length>=o.length?a.slice(o.length):a}).join(`
15
+ `)}var qs=class{options;rules;lexer;constructor(n){this.options=n||Jr}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,`
16
+ `)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const r=e[0],s=Bd(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],`
17
+ `)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let r=hs(e[0],`
18
+ `).split(`
19
+ `),s="",o="";const a=[];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 x=d.join(`
20
+ `),_=x.replace(this.rules.other.blockquoteSetextReplace,`
21
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
22
+ ${x}`:x,o=o?`${o}
23
+ ${_}`:_;const S=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(_,a,!0),this.lexer.state.top=S,r.length===0)break;const R=a.at(-1);if(R?.type==="code")break;if(R?.type==="blockquote"){const P=R,O=P.raw+`
24
+ `+r.join(`
25
+ `),q=this.blockquote(O);a[a.length-1]=q,s=s.substring(0,s.length-P.raw.length)+q.raw,o=o.substring(0,o.length-P.text.length)+q.text;break}else if(R?.type==="list"){const P=R,O=P.raw+`
26
+ `+r.join(`
27
+ `),q=this.list(O);a[a.length-1]=q,s=s.substring(0,s.length-R.raw.length)+q.raw,o=o.substring(0,o.length-P.raw.length)+q.raw,r=O.substring(a.at(-1).raw.length).split(`
28
+ `);continue}}return{type:"blockquote",raw:s,tokens:a,text:o}}}list(n){let e=this.rules.block.list.exec(n);if(e){let r=e[1].trim();const s=r.length>1,o={type:"list",raw:"",ordered:s,start:s?+r.slice(0,-1):"",loose:!1,items:[]};r=s?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=s?r:"[*+-]");const a=this.rules.other.listItemRegex(r);let i=!1;for(;n;){let m=!1,x="",_="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;x=e[0],n=n.substring(x.length);let S=e[2].split(`
29
+ `,1)[0].replace(this.rules.other.listReplaceTabs,Z=>" ".repeat(3*Z.length)),R=n.split(`
30
+ `,1)[0],P=!S.trim(),O=0;if(this.options.pedantic?(O=2,_=S.trimStart()):P?O=e[1].length+1:(O=e[2].search(this.rules.other.nonSpaceChar),O=O>4?1:O,_=S.slice(O),O+=e[1].length),P&&this.rules.other.blankLine.test(R)&&(x+=R+`
31
+ `,n=n.substring(R.length+1),m=!0),!m){const Z=this.rules.other.nextBulletRegex(O),ae=this.rules.other.hrRegex(O),Je=this.rules.other.fencesBeginRegex(O),fe=this.rules.other.headingBeginRegex(O),Ce=this.rules.other.htmlBeginRegex(O);for(;n;){const he=n.split(`
32
+ `,1)[0];let me;if(R=he,this.options.pedantic?(R=R.replace(this.rules.other.listReplaceNesting," "),me=R):me=R.replace(this.rules.other.tabCharGlobal," "),Je.test(R)||fe.test(R)||Ce.test(R)||Z.test(R)||ae.test(R))break;if(me.search(this.rules.other.nonSpaceChar)>=O||!R.trim())_+=`
33
+ `+me.slice(O);else{if(P||S.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Je.test(S)||fe.test(S)||ae.test(S))break;_+=`
34
+ `+R}!P&&!R.trim()&&(P=!0),x+=he+`
35
+ `,n=n.substring(he.length+1),S=me.slice(O)}}o.loose||(i?o.loose=!0:this.rules.other.doubleBlankLine.test(x)&&(i=!0));let q=null,ve;this.options.gfm&&(q=this.rules.other.listIsTask.exec(_),q&&(ve=q[0]!=="[ ] ",_=_.replace(this.rules.other.listReplaceTask,""))),o.items.push({type:"list_item",raw:x,task:!!q,checked:ve,loose:!1,text:_,tokens:[]}),o.raw+=x}const d=o.items.at(-1);if(d)d.raw=d.raw.trimEnd(),d.text=d.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let m=0;m<o.items.length;m++)if(this.lexer.state.top=!1,o.items[m].tokens=this.lexer.blockTokens(o.items[m].text,[]),!o.loose){const x=o.items[m].tokens.filter(S=>S.type==="space"),_=x.length>0&&x.some(S=>this.rules.other.anyLine.test(S.raw));o.loose=_}if(o.loose)for(let m=0;m<o.items.length;m++)o.items[m].loose=!0;return o}}html(n){const e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){const e=this.rules.block.def.exec(n);if(e){const r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:e[0],href:s,title:o}}}table(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const r=Da(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
36
+ `):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===s.length){for(const i of s)this.rules.other.tableAlignRight.test(i)?a.align.push("right"):this.rules.other.tableAlignCenter.test(i)?a.align.push("center"):this.rules.other.tableAlignLeft.test(i)?a.align.push("left"):a.align.push(null);for(let i=0;i<r.length;i++)a.header.push({text:r[i],tokens:this.lexer.inline(r[i]),header:!0,align:a.align[i]});for(const i of o)a.rows.push(Da(i,a.header.length).map((d,m)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:a.align[m]})));return a}}lheading(n){const e=this.rules.block.lheading.exec(n);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(n){const e=this.rules.block.paragraph.exec(n);if(e){const r=e[1].charAt(e[1].length-1)===`
37
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(n){const e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){const e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){const e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){const e=this.rules.inline.link.exec(n);if(e){const r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const a=hs(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{const a=zd(e[2],"()");if(a===-2)return;if(a>-1){const d=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,d).trim(),e[3]=""}}let s=e[2],o="";if(this.options.pedantic){const a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],o=a[3])}else o=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?s=s.slice(1):s=s.slice(1,-1)),Oa(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){const s=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[s.toLowerCase()];if(!o){const a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return Oa(r,o,r[0],this.lexer,this.rules)}}emStrong(n,e,r=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!s||s[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const a=[...s[0]].length-1;let i,d,m=a,x=0;const _=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(_.lastIndex=0,e=e.slice(-1*n.length+a);(s=_.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])&&a%3&&!((a+d)%3)){x+=d;continue}if(m-=d,m>0)continue;d=Math.min(d,d+m+x);const S=[...s[0]][0].length,R=n.slice(0,a+s.index+S+d);if(Math.min(a,d)%2){const O=R.slice(1,-1);return{type:"em",raw:R,text:O,tokens:this.lexer.inlineTokens(O)}}const P=R.slice(2,-2);return{type:"strong",raw:R,text:P,tokens:this.lexer.inlineTokens(P)}}}}codespan(n){const e=this.rules.inline.code.exec(n);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," ");const s=this.rules.other.nonSpaceChar.test(r),o=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return s&&o&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(n){const e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){const e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){const e=this.rules.inline.autolink.exec(n);if(e){let r,s;return e[2]==="@"?(r=e[1],s="mailto:"+r):(r=e[1],s=r),{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let r,s;if(e[2]==="@")r=e[0],s="mailto:"+r;else{let o;do o=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(o!==e[0]);r=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){const e=this.rules.inline.text.exec(n);if(e){const r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},Rr=class No{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Jr,this.options.tokenizer=this.options.tokenizer||new qs,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:Un,block:Os.normal,inline:ps.normal};this.options.pedantic?(r.block=Os.pedantic,r.inline=ps.pedantic):this.options.gfm&&(r.block=Os.gfm,this.options.breaks?r.inline=ps.breaks:r.inline=ps.gfm),this.tokenizer.rules=r}static get rules(){return{block:Os,inline:ps}}static lex(e,r){return new No(r).lex(e)}static lexInline(e,r){return new No(r).inlineTokens(e)}lex(e){e=e.replace(Un.carriageReturn,`
38
+ `),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(Un.tabCharGlobal," ").replace(Un.spaceLine,""));e;){let o;if(this.options.extensions?.block?.some(i=>(o=i.call({lexer:this},e,r))?(e=e.substring(o.raw.length),r.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);const i=r.at(-1);o.raw.length===1&&i!==void 0?i.raw+=`
39
+ `:r.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);const i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=`
40
+ `+o.raw,i.text+=`
41
+ `+o.text,this.inlineQueue.at(-1).src=i.text):r.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);const i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=`
42
+ `+o.raw,i.text+=`
43
+ `+o.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),r.push(o);continue}let a=e;if(this.options.extensions?.startBlock){let i=1/0;const d=e.slice(1);let m;this.options.extensions.startBlock.forEach(x=>{m=x.call({lexer:this},d),typeof m=="number"&&m>=0&&(i=Math.min(i,m))}),i<1/0&&i>=0&&(a=e.substring(0,i+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){const i=r.at(-1);s&&i?.type==="paragraph"?(i.raw+=`
44
+ `+o.raw,i.text+=`
45
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(o),s=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);const i=r.at(-1);i?.type==="text"?(i.raw+=`
46
+ `+o.raw,i.text+=`
47
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(o);continue}if(e){const i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){let s=e,o=null;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)d.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,o.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(o=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let a=!1,i="";for(;e;){a||(i=""),a=!1;let d;if(this.options.extensions?.inline?.some(x=>(d=x.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 x=r.at(-1);d.type==="text"&&x?.type==="text"?(x.raw+=d.raw,x.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 x=1/0;const _=e.slice(1);let S;this.options.extensions.startInline.forEach(R=>{S=R.call({lexer:this},_),typeof S=="number"&&S>=0&&(x=Math.min(x,S))}),x<1/0&&x>=0&&(m=e.substring(0,x+1))}if(d=this.tokenizer.inlineText(m)){e=e.substring(d.raw.length),d.raw.slice(-1)!=="_"&&(i=d.raw.slice(-1)),a=!0;const x=r.at(-1);x?.type==="text"?(x.raw+=d.raw,x.text+=d.text):r.push(d);continue}if(e){const x="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(x);break}else throw new Error(x)}}return r}},Vs=class{options;parser;constructor(n){this.options=n||Jr}space(n){return""}code({text:n,lang:e,escaped:r}){const s=(e||"").match(Un.notSpaceStart)?.[0],o=n.replace(Un.endingNewline,"")+`
48
+ `;return s?'<pre><code class="language-'+vr(s)+'">'+(r?o:vr(o,!0))+`</code></pre>
49
+ `:"<pre><code>"+(r?o:vr(o,!0))+`</code></pre>
50
+ `}blockquote({tokens:n}){return`<blockquote>
51
+ ${this.parser.parse(n)}</blockquote>
52
+ `}html({text:n}){return n}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
53
+ `}hr(n){return`<hr>
54
+ `}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 o=e?"ol":"ul",a=e&&r!==1?' start="'+r+'"':"";return"<"+o+a+`>
55
+ `+s+"</"+o+`>
56
+ `}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+" "+vr(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>
57
+ `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
58
+ `}table(n){let e="",r="";for(let o=0;o<n.header.length;o++)r+=this.tablecell(n.header[o]);e+=this.tablerow({text:r});let s="";for(let o=0;o<n.rows.length;o++){const a=n.rows[o];r="";for(let i=0;i<a.length;i++)r+=this.tablecell(a[i]);s+=this.tablerow({text:r})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
59
+ <thead>
60
+ `+e+`</thead>
61
+ `+s+`</table>
62
+ `}tablerow({text:n}){return`<tr>
63
+ ${n}</tr>
64
+ `}tablecell(n){const e=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+`</${r}>
65
+ `}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>${vr(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:r}){const s=this.parser.parseInline(r),o=La(n);if(o===null)return s;n=o;let a='<a href="'+n+'"';return e&&(a+=' title="'+vr(e)+'"'),a+=">"+s+"</a>",a}image({href:n,title:e,text:r,tokens:s}){s&&(r=this.parser.parseInline(s,this.parser.textRenderer));const o=La(n);if(o===null)return vr(r);n=o;let a=`<img src="${n}" alt="${r}"`;return e&&(a+=` title="${vr(e)}"`),a+=">",a}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:vr(n.text)}},fa=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""}},Cr=class Fo{options;renderer;textRenderer;constructor(e){this.options=e||Jr,this.options.renderer=this.options.renderer||new Vs,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new fa}static parse(e,r){return new Fo(r).parse(e)}static parseInline(e,r){return new Fo(r).parseInline(e)}parse(e,r=!0){let s="";for(let o=0;o<e.length;o++){const a=e[o];if(this.options.extensions?.renderers?.[a.type]){const d=a,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=a;switch(i.type){case"space":{s+=this.renderer.space(i);continue}case"hr":{s+=this.renderer.hr(i);continue}case"heading":{s+=this.renderer.heading(i);continue}case"code":{s+=this.renderer.code(i);continue}case"table":{s+=this.renderer.table(i);continue}case"blockquote":{s+=this.renderer.blockquote(i);continue}case"list":{s+=this.renderer.list(i);continue}case"html":{s+=this.renderer.html(i);continue}case"paragraph":{s+=this.renderer.paragraph(i);continue}case"text":{let d=i,m=this.renderer.text(d);for(;o+1<e.length&&e[o+1].type==="text";)d=e[++o],m+=`
66
+ `+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 o=0;o<e.length;o++){const a=e[o];if(this.options.extensions?.renderers?.[a.type]){const d=this.options.extensions.renderers[a.type].call({parser:this},a);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=d||"";continue}}const i=a;switch(i.type){case"escape":{s+=r.text(i);break}case"html":{s+=r.html(i);break}case"link":{s+=r.link(i);break}case"image":{s+=r.image(i);break}case"strong":{s+=r.strong(i);break}case"em":{s+=r.em(i);break}case"codespan":{s+=r.codespan(i);break}case"br":{s+=r.br(i);break}case"del":{s+=r.del(i);break}case"text":{s+=r.text(i);break}default:{const d='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return s}},Bs=class{options;block;constructor(n){this.options=n||Jr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Rr.lex:Rr.lexInline}provideParser(){return this.block?Cr.parse:Cr.parseInline}},Hd=class{defaults=sa();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Cr;Renderer=Vs;TextRenderer=fa;Lexer=Rr;Tokenizer=qs;Hooks=Bs;constructor(...n){this.use(...n)}walkTokens(n,e){let r=[];for(const s of n)switch(r=r.concat(e.call(this,s)),s.type){case"table":{const o=s;for(const a of o.header)r=r.concat(this.walkTokens(a.tokens,e));for(const a of o.rows)for(const i of a)r=r.concat(this.walkTokens(i.tokens,e));break}case"list":{const o=s;r=r.concat(this.walkTokens(o.items,e));break}default:{const o=s;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{const i=o[a].flat(1/0);r=r.concat(this.walkTokens(i,e))}):o.tokens&&(r=r.concat(this.walkTokens(o.tokens,e)))}}return r}use(...n){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(r=>{const s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){const a=e.renderers[o.name];a?e.renderers[o.name]=function(...i){let d=o.renderer.apply(this,i);return d===!1&&(d=a.apply(this,i)),d}:e.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=e[o.level];a?a.unshift(o.tokenizer):e[o.level]=[o.tokenizer],o.start&&(o.level==="block"?e.startBlock?e.startBlock.push(o.start):e.startBlock=[o.start]:o.level==="inline"&&(e.startInline?e.startInline.push(o.start):e.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(e.childTokens[o.name]=o.childTokens)}),s.extensions=e),r.renderer){const o=this.defaults.renderer||new Vs(this.defaults);for(const a in r.renderer){if(!(a in o))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const i=a,d=r.renderer[i],m=o[i];o[i]=(...x)=>{let _=d.apply(o,x);return _===!1&&(_=m.apply(o,x)),_||""}}s.renderer=o}if(r.tokenizer){const o=this.defaults.tokenizer||new qs(this.defaults);for(const a in r.tokenizer){if(!(a in o))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const i=a,d=r.tokenizer[i],m=o[i];o[i]=(...x)=>{let _=d.apply(o,x);return _===!1&&(_=m.apply(o,x)),_}}s.tokenizer=o}if(r.hooks){const o=this.defaults.hooks||new Bs;for(const a in r.hooks){if(!(a in o))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const i=a,d=r.hooks[i],m=o[i];Bs.passThroughHooks.has(a)?o[i]=x=>{if(this.defaults.async)return Promise.resolve(d.call(o,x)).then(S=>m.call(o,S));const _=d.call(o,x);return m.call(o,_)}:o[i]=(...x)=>{let _=d.apply(o,x);return _===!1&&(_=m.apply(o,x)),_}}s.hooks=o}if(r.walkTokens){const o=this.defaults.walkTokens,a=r.walkTokens;s.walkTokens=function(i){let d=[];return d.push(a.call(this,i)),o&&(d=d.concat(o.call(this,i))),d}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return Rr.lex(n,e??this.defaults)}parser(n,e){return Cr.parse(n,e??this.defaults)}parseMarkdown(n){return(r,s)=>{const o={...s},a={...this.defaults,...o},i=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&o.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=n);const d=a.hooks?a.hooks.provideLexer():n?Rr.lex:Rr.lexInline,m=a.hooks?a.hooks.provideParser():n?Cr.parse:Cr.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(r):r).then(x=>d(x,a)).then(x=>a.hooks?a.hooks.processAllTokens(x):x).then(x=>a.walkTokens?Promise.all(this.walkTokens(x,a.walkTokens)).then(()=>x):x).then(x=>m(x,a)).then(x=>a.hooks?a.hooks.postprocess(x):x).catch(i);try{a.hooks&&(r=a.hooks.preprocess(r));let x=d(r,a);a.hooks&&(x=a.hooks.processAllTokens(x)),a.walkTokens&&this.walkTokens(x,a.walkTokens);let _=m(x,a);return a.hooks&&(_=a.hooks.postprocess(_)),_}catch(x){return i(x)}}}onError(n,e){return r=>{if(r.message+=`
67
+ Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+vr(r.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(r);throw r}}},Zr=new Hd;function yt(n,e){return Zr.parse(n,e)}yt.options=yt.setOptions=function(n){return Zr.setOptions(n),yt.defaults=Zr.defaults,ol(yt.defaults),yt};yt.getDefaults=sa;yt.defaults=Jr;yt.use=function(...n){return Zr.use(...n),yt.defaults=Zr.defaults,ol(yt.defaults),yt};yt.walkTokens=function(n,e){return Zr.walkTokens(n,e)};yt.parseInline=Zr.parseInline;yt.Parser=Cr;yt.parser=Cr.parse;yt.Renderer=Vs;yt.TextRenderer=fa;yt.Lexer=Rr;yt.lexer=Rr.lex;yt.Tokenizer=qs;yt.Hooks=Bs;yt.parse=yt;yt.options;yt.setOptions;yt.use;yt.walkTokens;yt.parseInline;Cr.parse;Rr.lex;function Pa(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 Wd(n){if(Array.isArray(n))return n}function jd(n,e){var r=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var s,o,a,i,d=[],m=!0,x=!1;try{if(a=(r=r.call(n)).next,e!==0)for(;!(m=(s=a.call(r)).done)&&(d.push(s.value),d.length!==e);m=!0);}catch(_){x=!0,o=_}finally{try{if(!m&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(x)throw o}}return d}}function Gd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
68
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qd(n,e){return Wd(n)||jd(n,e)||Vd(n,e)||Gd()}function Vd(n,e){if(n){if(typeof n=="string")return Pa(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)?Pa(n,e):void 0}}const vl=Object.entries,Na=Object.setPrototypeOf,Kd=Object.isFrozen,Yd=Object.getPrototypeOf,Xd=Object.getOwnPropertyDescriptor;let An=Object.freeze,Rn=Object.seal,ss=Object.create,gl=typeof Reflect<"u"&&Reflect,Uo=gl.apply,zo=gl.construct;An||(An=function(e){return e});Rn||(Rn=function(e){return e});Uo||(Uo=function(e,r){for(var s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];return e.apply(r,o)});zo||(zo=function(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return new e(...s)});const bs=bn(Array.prototype.forEach),Zd=bn(Array.prototype.lastIndexOf),Fa=bn(Array.prototype.pop),ns=bn(Array.prototype.push),Qd=bn(Array.prototype.splice),Fr=Array.isArray,ys=bn(String.prototype.toLowerCase),wo=bn(String.prototype.toString),Ua=bn(String.prototype.match),vs=bn(String.prototype.replace),za=bn(String.prototype.indexOf),Jd=bn(String.prototype.trim),eu=bn(Number.prototype.toString),tu=bn(Boolean.prototype.toString),Ba=typeof BigInt>"u"?null:bn(BigInt.prototype.toString),Ha=typeof Symbol>"u"?null:bn(Symbol.prototype.toString),wn=bn(Object.prototype.hasOwnProperty),gs=bn(Object.prototype.toString),Tn=bn(RegExp.prototype.test),Vr=nu(TypeError);function bn(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return Uo(n,e,s)}}function nu(n){return function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return zo(n,r)}}function lt(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ys;if(Na&&Na(n,null),!Fr(e))return n;let s=e.length;for(;s--;){let o=e[s];if(typeof o=="string"){const a=r(o);a!==o&&(Kd(e)||(e[s]=a),o=a)}n[o]=!0}return n}function ru(n){for(let e=0;e<n.length;e++)wn(n,e)||(n[e]=null);return n}function Pn(n){const e=ss(null);for(const s of vl(n)){var r=qd(s,2);const o=r[0],a=r[1];wn(n,o)&&(Fr(a)?e[o]=ru(a):a&&typeof a=="object"&&a.constructor===Object?e[o]=Pn(a):e[o]=a)}return e}function su(n){switch(typeof n){case"string":return n;case"number":return eu(n);case"boolean":return tu(n);case"bigint":return Ba?Ba(n):"0";case"symbol":return Ha?Ha(n):"Symbol()";case"undefined":return gs(n);case"function":case"object":{if(n===null)return gs(n);const e=n,r=gr(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 gr(n,e){for(;n!==null;){const s=Xd(n,e);if(s){if(s.get)return bn(s.get);if(typeof s.value=="function")return bn(s.value)}n=Yd(n)}function r(){return null}return r}function ou(n){try{return Tn(n,""),!0}catch{return!1}}const Wa=An(["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"]),ko=An(["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"]),So=An(["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"]),au=An(["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"]),To=An(["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"]),iu=An(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ja=An(["#text"]),Ga=An(["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"]),Ao=An(["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"]),qa=An(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ps=An(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),lu=Rn(/{{[\w\W]*|^[\w\W]*}}/g),cu=Rn(/<%[\w\W]*|^[\w\W]*%>/g),du=Rn(/\${[\w\W]*/g),uu=Rn(/^data-[\-\w.\u00B7-\uFFFF]+$/),fu=Rn(/^aria-[\-\w]+$/),Va=Rn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),pu=Rn(/^(?:\w+script|data):/i),hu=Rn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bu=Rn(/^html$/i),vu=Rn(/^[a-z][.\w]*(-[.\w]+)+$/i),Ka=Rn(/<[/\w!]/g),gu=Rn(/<[/\w]/g),mu=Rn(/<\/no(script|embed|frames)/i),xu=Rn(/\/>/i),br={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_u=function(){return typeof window>"u"?null:window},yu=function(e,r){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(s=r.getAttribute(o));const a="dompurify"+(s?"#"+s:"");try{return e.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Ya=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Or=function(e,r,s,o){return wn(e,r)&&Fr(e[r])?lt(o.base?Pn(o.base):{},e[r],o.transform):s};function ml(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_u();const e=U=>ml(U);if(e.version="3.4.11",e.removed=[],!n||!n.document||n.document.nodeType!==br.document||!n.Element)return e.isSupported=!1,e;let r=n.document;const s=r,o=s.currentScript;n.DocumentFragment;const a=n.HTMLTemplateElement,i=n.Node,d=n.Element,m=n.NodeFilter,x=n.NamedNodeMap;x===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const _=n.DOMParser,S=n.trustedTypes,R=d.prototype,P=gr(R,"cloneNode"),O=gr(R,"remove"),q=gr(R,"nextSibling"),ve=gr(R,"childNodes"),Z=gr(R,"parentNode"),ae=gr(R,"shadowRoot"),Je=gr(R,"attributes"),fe=i&&i.prototype?gr(i.prototype,"nodeType"):null,Ce=i&&i.prototype?gr(i.prototype,"nodeName"):null;if(typeof a=="function"){const U=r.createElement("template");U.content&&U.content.ownerDocument&&(r=U.content.ownerDocument)}let he,me="",bt,It=!1,et=0;const At=function(){if(et>0)throw Vr('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.')},se=function(f){At(),et++;try{return he.createHTML(f)}finally{et--}},Ht=function(f){At(),et++;try{return he.createScriptURL(f)}finally{et--}},tt=function(){return It||(bt=yu(S,o),It=!0),bt},wt=r,ct=wt.implementation,sn=wt.createNodeIterator,Wt=wt.createDocumentFragment,je=wt.getElementsByTagName,$t=s.importNode;let H=Ya();e.isSupported=typeof vl=="function"&&typeof Z=="function"&&ct&&ct.createHTMLDocument!==void 0;const ze=lu,jt=cu,Kt=du,Mt=uu,Xt=fu,Lt=pu,Rt=hu,vt=vu;let Xe=Va,K=null;const vn=lt({},[...Wa,...ko,...So,...To,...ja]);let Le=null;const Ge=lt({},[...Ga,...Ao,...qa,...Ps]);let M=Object.seal(ss(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}})),A=null,le=null;const xe=Object.seal(ss(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let L=!0,j=!0,ne=!1,Ze=!0,ue=!1,nt=!0,_e=!1,Be=!1,pt=null,kt=null,gt=!1,mt=!1,Gt=!1,Oe=!1,st=!0,dn=!1;const mn="user-content-";let kn=!0,on=!1,In={},an=null;const Vn=lt({},["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 Kn=null;const Ln=lt({},["audio","video","img","source","image","track"]);let zn=null;const tr=lt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Bn="http://www.w3.org/1998/Math/MathML",C="http://www.w3.org/2000/svg",T="http://www.w3.org/1999/xhtml";let z=T,Q=!1,oe=null;const Pe=lt({},[Bn,C,T],wo),He=An(["mi","mo","mn","ms","mtext"]);let pe=lt({},He);const Fe=An(["annotation-xml"]);let xt=lt({},Fe);const ln=lt({},["title","style","font","a","script"]);let dt=null;const E=["application/xhtml+xml","text/html"],D="text/html";let N=null,ie=null;const Te=r.createElement("form"),Ee=function(f){return f instanceof RegExp||f instanceof Function},te=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ie&&ie===f)return;(!f||typeof f!="object")&&(f={}),f=Pn(f),dt=E.indexOf(f.PARSER_MEDIA_TYPE)===-1?D:f.PARSER_MEDIA_TYPE,N=dt==="application/xhtml+xml"?wo:ys,K=Or(f,"ALLOWED_TAGS",vn,{transform:N}),Le=Or(f,"ALLOWED_ATTR",Ge,{transform:N}),oe=Or(f,"ALLOWED_NAMESPACES",Pe,{transform:wo}),zn=Or(f,"ADD_URI_SAFE_ATTR",tr,{transform:N,base:tr}),Kn=Or(f,"ADD_DATA_URI_TAGS",Ln,{transform:N,base:Ln}),an=Or(f,"FORBID_CONTENTS",Vn,{transform:N}),A=Or(f,"FORBID_TAGS",Pn({}),{transform:N}),le=Or(f,"FORBID_ATTR",Pn({}),{transform:N}),In=wn(f,"USE_PROFILES")?f.USE_PROFILES&&typeof f.USE_PROFILES=="object"?Pn(f.USE_PROFILES):f.USE_PROFILES:!1,L=f.ALLOW_ARIA_ATTR!==!1,j=f.ALLOW_DATA_ATTR!==!1,ne=f.ALLOW_UNKNOWN_PROTOCOLS||!1,Ze=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ue=f.SAFE_FOR_TEMPLATES||!1,nt=f.SAFE_FOR_XML!==!1,_e=f.WHOLE_DOCUMENT||!1,mt=f.RETURN_DOM||!1,Gt=f.RETURN_DOM_FRAGMENT||!1,Oe=f.RETURN_TRUSTED_TYPE||!1,gt=f.FORCE_BODY||!1,st=f.SANITIZE_DOM!==!1,dn=f.SANITIZE_NAMED_PROPS||!1,kn=f.KEEP_CONTENT!==!1,on=f.IN_PLACE||!1,Xe=ou(f.ALLOWED_URI_REGEXP)?f.ALLOWED_URI_REGEXP:Va,z=typeof f.NAMESPACE=="string"?f.NAMESPACE:T,pe=wn(f,"MATHML_TEXT_INTEGRATION_POINTS")&&f.MATHML_TEXT_INTEGRATION_POINTS&&typeof f.MATHML_TEXT_INTEGRATION_POINTS=="object"?Pn(f.MATHML_TEXT_INTEGRATION_POINTS):lt({},He),xt=wn(f,"HTML_INTEGRATION_POINTS")&&f.HTML_INTEGRATION_POINTS&&typeof f.HTML_INTEGRATION_POINTS=="object"?Pn(f.HTML_INTEGRATION_POINTS):lt({},Fe);const l=wn(f,"CUSTOM_ELEMENT_HANDLING")&&f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING=="object"?Pn(f.CUSTOM_ELEMENT_HANDLING):ss(null);if(M=ss(null),wn(l,"tagNameCheck")&&Ee(l.tagNameCheck)&&(M.tagNameCheck=l.tagNameCheck),wn(l,"attributeNameCheck")&&Ee(l.attributeNameCheck)&&(M.attributeNameCheck=l.attributeNameCheck),wn(l,"allowCustomizedBuiltInElements")&&typeof l.allowCustomizedBuiltInElements=="boolean"&&(M.allowCustomizedBuiltInElements=l.allowCustomizedBuiltInElements),Rn(M),ue&&(j=!1),Gt&&(mt=!0),In&&(K=lt({},ja),Le=ss(null),In.html===!0&&(lt(K,Wa),lt(Le,Ga)),In.svg===!0&&(lt(K,ko),lt(Le,Ao),lt(Le,Ps)),In.svgFilters===!0&&(lt(K,So),lt(Le,Ao),lt(Le,Ps)),In.mathMl===!0&&(lt(K,To),lt(Le,qa),lt(Le,Ps))),xe.tagCheck=null,xe.attributeCheck=null,wn(f,"ADD_TAGS")&&(typeof f.ADD_TAGS=="function"?xe.tagCheck=f.ADD_TAGS:Fr(f.ADD_TAGS)&&(K===vn&&(K=Pn(K)),lt(K,f.ADD_TAGS,N))),wn(f,"ADD_ATTR")&&(typeof f.ADD_ATTR=="function"?xe.attributeCheck=f.ADD_ATTR:Fr(f.ADD_ATTR)&&(Le===Ge&&(Le=Pn(Le)),lt(Le,f.ADD_ATTR,N))),wn(f,"ADD_URI_SAFE_ATTR")&&Fr(f.ADD_URI_SAFE_ATTR)&&lt(zn,f.ADD_URI_SAFE_ATTR,N),wn(f,"FORBID_CONTENTS")&&Fr(f.FORBID_CONTENTS)&&(an===Vn&&(an=Pn(an)),lt(an,f.FORBID_CONTENTS,N)),wn(f,"ADD_FORBID_CONTENTS")&&Fr(f.ADD_FORBID_CONTENTS)&&(an===Vn&&(an=Pn(an)),lt(an,f.ADD_FORBID_CONTENTS,N)),kn&&(K["#text"]=!0),_e&&lt(K,["html","head","body"]),K.table&&(lt(K,["tbody"]),delete A.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw Vr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Vr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const v=he;he=f.TRUSTED_TYPES_POLICY;try{me=se("")}catch(w){throw he=v,w}}else f.TRUSTED_TYPES_POLICY===null?(he=void 0,me=""):(he===void 0&&(he=tt()),he&&typeof me=="string"&&(me=se("")));An&&An(f),ie=f},be=lt({},[...ko,...So,...au]),ye=lt({},[...To,...iu]),St=function(f,l,v){return l.namespaceURI===T?f==="svg":l.namespaceURI===Bn?f==="svg"&&(v==="annotation-xml"||pe[v]):!!be[f]},xn=function(f,l,v){return l.namespaceURI===T?f==="math":l.namespaceURI===C?f==="math"&&xt[v]:!!ye[f]},un=function(f,l,v){return l.namespaceURI===C&&!xt[v]||l.namespaceURI===Bn&&!pe[v]?!1:!ye[f]&&(ln[f]||!be[f])},gn=function(f){let l=Z(f);(!l||!l.tagName)&&(l={namespaceURI:z,tagName:"template"});const v=ys(f.tagName),w=ys(l.tagName);return oe[f.namespaceURI]?f.namespaceURI===C?St(v,l,w):f.namespaceURI===Bn?xn(v,l,w):f.namespaceURI===T?un(v,l,w):!!(dt==="application/xhtml+xml"&&oe[f.namespaceURI]):!1},Y=function(f){ns(e.removed,{element:f});try{Z(f).removeChild(f)}catch{if(O(f),!Z(f))throw Vr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ce=function(f){const l=ve(f);if(l){const w=[];bs(l,I=>{ns(w,I)}),bs(w,I=>{try{O(I)}catch{}})}const v=Je(f);if(v)for(let w=v.length-1;w>=0;--w){const I=v[w],X=I&&I.name;if(typeof X=="string")try{f.removeAttribute(X)}catch{}}},we=function(f,l){try{ns(e.removed,{attribute:l.getAttributeNode(f),from:l})}catch{ns(e.removed,{attribute:null,from:l})}if(l.removeAttribute(f),f==="is")if(mt||Gt)try{Y(l)}catch{}else try{l.setAttribute(f,"")}catch{}},qe=function(f){const l=Je(f);if(l)for(let v=l.length-1;v>=0;--v){const w=l[v],I=w&&w.name;if(!(typeof I!="string"||Le[N(I)]))try{f.removeAttribute(I)}catch{}}},We=function(f){const l=[f];for(;l.length>0;){const v=l.pop();(fe?fe(v):v.nodeType)===br.element&&qe(v);const I=ve(v);if(I)for(let X=I.length-1;X>=0;--X)l.push(I[X])}},Ke=function(f){let l=null,v=null;if(gt)f="<remove></remove>"+f;else{const X=Ua(f,/^[\r\n\t ]+/);v=X&&X[0]}dt==="application/xhtml+xml"&&z===T&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const w=he?se(f):f;if(z===T)try{l=new _().parseFromString(w,dt)}catch{}if(!l||!l.documentElement){l=ct.createDocument(z,"template",null);try{l.documentElement.innerHTML=Q?me:w}catch{}}const I=l.body||l.documentElement;return f&&v&&I.insertBefore(r.createTextNode(v),I.childNodes[0]||null),z===T?je.call(l,_e?"html":"body")[0]:_e?l.documentElement:I},_t=function(f){return sn.call(f.ownerDocument||f,f,m.SHOW_ELEMENT|m.SHOW_COMMENT|m.SHOW_TEXT|m.SHOW_PROCESSING_INSTRUCTION|m.SHOW_CDATA_SECTION,null)},zt=function(f){return f=vs(f,ze," "),f=vs(f,jt," "),f=vs(f,Kt," "),f},_n=function(f){var l;f.normalize();const v=sn.call(f.ownerDocument||f,f,m.SHOW_TEXT|m.SHOW_COMMENT|m.SHOW_CDATA_SECTION|m.SHOW_PROCESSING_INSTRUCTION,null);let w=v.nextNode();for(;w;)w.data=zt(w.data),w=v.nextNode();const I=(l=f.querySelectorAll)===null||l===void 0?void 0:l.call(f,"template");I&&bs(I,X=>{Ae(X.content)&&_n(X.content)})},fn=function(f){const l=Ce?Ce(f):null;return typeof l!="string"||N(l)!=="form"?!1:typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||f.attributes!==Je(f)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function"||f.nodeType!==fe(f)||f.childNodes!==ve(f)},Ae=function(f){if(!fe||typeof f!="object"||f===null)return!1;try{return fe(f)===br.documentFragment}catch{return!1}},at=function(f){if(!fe||typeof f!="object"||f===null)return!1;try{return typeof fe(f)=="number"}catch{return!1}};function Yt(U,f,l){U.length!==0&&bs(U,v=>{v.call(e,f,l,ie)})}const Yn=function(f,l){return!!(nt&&f.hasChildNodes()&&!at(f.firstElementChild)&&Tn(Ka,f.textContent)&&Tn(Ka,f.innerHTML)||nt&&f.namespaceURI===T&&l==="style"&&at(f.firstElementChild)||f.nodeType===br.processingInstruction||nt&&f.nodeType===br.comment&&Tn(gu,f.data))},nr=function(f,l){if(!A[l]&&Ue(l)&&(M.tagNameCheck instanceof RegExp&&Tn(M.tagNameCheck,l)||M.tagNameCheck instanceof Function&&M.tagNameCheck(l)))return!1;if(kn&&!an[l]){const v=Z(f),w=ve(f);if(w&&v){const I=w.length;for(let X=I-1;X>=0;--X){const re=on?w[X]:P(w[X],!0);v.insertBefore(re,q(f))}}}return Y(f),!0},$r=function(f){if(Yt(H.beforeSanitizeElements,f,null),fn(f))return Y(f),!0;const l=N(Ce?Ce(f):f.nodeName);if(Yt(H.uponSanitizeElement,f,{tagName:l,allowedTags:K}),Yn(f,l))return Y(f),!0;if(A[l]||!(xe.tagCheck instanceof Function&&xe.tagCheck(l))&&!K[l])return nr(f,l);if((fe?fe(f):f.nodeType)===br.element&&!gn(f)||(l==="noscript"||l==="noembed"||l==="noframes")&&Tn(mu,f.innerHTML))return Y(f),!0;if(ue&&f.nodeType===br.text){const w=zt(f.textContent);f.textContent!==w&&(ns(e.removed,{element:f.cloneNode()}),f.textContent=w)}return Yt(H.afterSanitizeElements,f,null),!1},xr=function(f,l,v){if(le[l]||st&&(l==="id"||l==="name")&&(v in r||v in Te))return!1;const w=Le[l]||xe.attributeCheck instanceof Function&&xe.attributeCheck(l,f);if(!(j&&Tn(Mt,l))){if(!(L&&Tn(Xt,l))){if(w){if(!zn[l]){if(!Tn(Xe,vs(v,Rt,""))){if(!((l==="src"||l==="xlink:href"||l==="href")&&f!=="script"&&za(v,"data:")===0&&Kn[f])){if(!(ne&&!Tn(Lt,vs(v,Rt,"")))){if(v)return!1}}}}}else if(!(Ue(f)&&(M.tagNameCheck instanceof RegExp&&Tn(M.tagNameCheck,f)||M.tagNameCheck instanceof Function&&M.tagNameCheck(f))&&(M.attributeNameCheck instanceof RegExp&&Tn(M.attributeNameCheck,l)||M.attributeNameCheck instanceof Function&&M.attributeNameCheck(l,f))||l==="is"&&M.allowCustomizedBuiltInElements&&(M.tagNameCheck instanceof RegExp&&Tn(M.tagNameCheck,v)||M.tagNameCheck instanceof Function&&M.tagNameCheck(v))))return!1}}return!0},Mr=lt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ue=function(f){return!Mr[ys(f)]&&Tn(vt,f)},Ct=function(f,l,v,w){if(he&&typeof S=="object"&&typeof S.getAttributeType=="function"&&!v)switch(S.getAttributeType(f,l)){case"TrustedHTML":return se(w);case"TrustedScriptURL":return Ht(w)}return w},Hn=function(f,l,v,w){try{v?f.setAttributeNS(v,l,w):f.setAttribute(l,w),fn(f)?Y(f):Fa(e.removed)}catch{we(l,f)}},_r=function(f){Yt(H.beforeSanitizeAttributes,f,null);const l=f.attributes;if(!l||fn(f))return;const v={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Le,forceKeepAttr:void 0};let w=l.length;const I=N(f.nodeName);for(;w--;){const X=l[w],re=X.name,y=X.namespaceURI,De=X.value,Ie=N(re),Dt=De;let Ot=re==="value"?Dt:Jd(Dt);if(v.attrName=Ie,v.attrValue=Ot,v.keepAttr=!0,v.forceKeepAttr=void 0,Yt(H.uponSanitizeAttribute,f,v),Ot=v.attrValue,dn&&(Ie==="id"||Ie==="name")&&za(Ot,mn)!==0&&(we(re,f),Ot=mn+Ot),nt&&Tn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ot)){we(re,f);continue}if(Ie==="attributename"&&Ua(Ot,"href")){we(re,f);continue}if(!v.forceKeepAttr){if(!v.keepAttr){we(re,f);continue}if(!Ze&&Tn(xu,Ot)){we(re,f);continue}if(ue&&(Ot=zt(Ot)),!xr(I,Ie,Ot)){we(re,f);continue}Ot=Ct(I,Ie,y,Ot),Ot!==Dt&&Hn(f,re,y,Ot)}}Yt(H.afterSanitizeAttributes,f,null)},Lr=function(f){let l=null;const v=_t(f);for(Yt(H.beforeSanitizeShadowDOM,f,null);l=v.nextNode();)if(Yt(H.uponSanitizeShadowNode,l,null),$r(l),_r(l),Ae(l.content)&&Lr(l.content),(fe?fe(l):l.nodeType)===br.element){const I=ae(l);Ae(I)&&(rr(I),Lr(I))}Yt(H.afterSanitizeShadowDOM,f,null)},rr=function(f){const l=[{node:f,shadow:null}];for(;l.length>0;){const v=l.pop();if(v.shadow){Lr(v.shadow);continue}const w=v.node,X=(fe?fe(w):w.nodeType)===br.element,re=ve(w);if(re)for(let y=re.length-1;y>=0;--y)l.push({node:re[y],shadow:null});if(X){const y=Ce?Ce(w):null;if(typeof y=="string"&&N(y)==="template"){const De=w.content;Ae(De)&&l.push({node:De,shadow:null})}}if(X){const y=ae(w);Ae(y)&&l.push({node:null,shadow:y},{node:y,shadow:null})}}};return e.sanitize=function(U){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=null,v=null,w=null,I=null;if(Q=!U,Q&&(U="<!-->"),typeof U!="string"&&!at(U)&&(U=su(U),typeof U!="string"))throw Vr("dirty is not a string, aborting");if(!e.isSupported)return U;Be?(K=pt,Le=kt):te(f),(H.uponSanitizeElement.length>0||H.uponSanitizeAttribute.length>0)&&(K=Pn(K)),H.uponSanitizeAttribute.length>0&&(Le=Pn(Le)),e.removed=[];const X=on&&typeof U!="string"&&at(U);if(X){const De=Ce?Ce(U):U.nodeName;if(typeof De=="string"){const Ie=N(De);if(!K[Ie]||A[Ie])throw Vr("root node is forbidden and cannot be sanitized in-place")}if(fn(U))throw Vr("root node is clobbered and cannot be sanitized in-place");try{rr(U)}catch(Ie){throw ce(U),Ie}}else if(at(U))l=Ke("<!---->"),v=l.ownerDocument.importNode(U,!0),v.nodeType===br.element&&v.nodeName==="BODY"||v.nodeName==="HTML"?l=v:l.appendChild(v),rr(v);else{if(!mt&&!ue&&!_e&&U.indexOf("<")===-1)return he&&Oe?se(U):U;if(l=Ke(U),!l)return mt?null:Oe?me:""}l&&gt&&Y(l.firstChild);const re=_t(X?U:l);try{for(;w=re.nextNode();)$r(w),_r(w),Ae(w.content)&&Lr(w.content)}catch(De){throw X&&ce(U),De}if(X)return bs(e.removed,De=>{De.element&&We(De.element)}),ue&&_n(U),U;if(mt){if(ue&&_n(l),Gt)for(I=Wt.call(l.ownerDocument);l.firstChild;)I.appendChild(l.firstChild);else I=l;return(Le.shadowroot||Le.shadowrootmode)&&(I=$t.call(s,I,!0)),I}let y=_e?l.outerHTML:l.innerHTML;return _e&&K["!doctype"]&&l.ownerDocument&&l.ownerDocument.doctype&&l.ownerDocument.doctype.name&&Tn(bu,l.ownerDocument.doctype.name)&&(y="<!DOCTYPE "+l.ownerDocument.doctype.name+`>
69
+ `+y),ue&&(y=zt(y)),he&&Oe?se(y):y},e.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};te(U),Be=!0,pt=K,kt=Le},e.clearConfig=function(){ie=null,Be=!1,pt=null,kt=null,he=bt,me=""},e.isValidAttribute=function(U,f,l){ie||te({});const v=N(U),w=N(f);return xr(v,w,l)},e.addHook=function(U,f){typeof f=="function"&&wn(H,U)&&ns(H[U],f)},e.removeHook=function(U,f){if(wn(H,U)){if(f!==void 0){const l=Zd(H[U],f);return l===-1?void 0:Qd(H[U],l,1)[0]}return Fa(H[U])}},e.removeHooks=function(U){wn(H,U)&&(H[U]=[])},e.removeAllHooks=function(){H=Ya()},e}var pa=ml();yt.setOptions({gfm:!0,breaks:!0});const Xa=80;function Ar(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const wu={code(n){const{text:e,lang:r}=n,s=(r??"").trim().split(/\s+/)[0]??"",a=e.split(`
70
+ `).filter(S=>S.trim()!==""),i=a.length>1,d=`<pre><code>${Ar(e)}</code></pre>`;if(!i)return d;let x=a[0]??"";return x.length>Xa?x=x.slice(0,Xa)+"…":a.length>1&&(x+=" …"),`<details class="code-collapsible"><summary>${s?`<span class="code-lang">${Ar(s)}</span> ${Ar(x)}`:Ar(x)}</summary>${d}</details>`}};yt.use({renderer:wu});let Za=!1;function xl(){Za||typeof window>"u"||(Za=!0,pa.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))}))}function ku(n){if(!n)return"";const e=yt.parse(n,{async:!1});return typeof window>"u"?"":(xl(),pa.sanitize(e,{ADD_ATTR:["target","rel"],ADD_TAGS:["details","summary"]}))}const Su=/\b(https?:\/\/[^\s<]+|www\.[^\s<]+)/gi;function Tu(n){if(!n||typeof window>"u")return"";let e="",r=0;for(const s of n.matchAll(Su)){const o=s.index??0;e+=Ar(n.slice(r,o));let a=s[0],i="";const d=a.match(/[.,;:!?)\]}'"]+$/);d&&(i=d[0],a=a.slice(0,a.length-i.length));const m=a.startsWith("www.")?`https://${a}`:a;e+=`<a href="${Ar(m)}">${Ar(a)}</a>`,e+=Ar(i),r=o+s[0].length}return e+=Ar(n.slice(r)),xl(),pa.sanitize(e,{ADD_ATTR:["target","rel"]})}var Au=g('<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>'),Ru=g('<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>'),Cu=g(`<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
71
+ 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>`),Eu=g('<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>'),Iu=g('<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>'),$u=g('<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>'),Mu=g('<span class="ml-1 font-medium text-emerald-400">(Git repo detected)</span>'),Lu=g('<span class="mt-1.5 block text-xs font-medium text-yellow-400">📁 Folder already exists. Joining will create a session in it. <!></span>'),Du=g('<span class="mt-1 block text-[10px] text-brand-text-muted">Relative paths are created inside your home folder.</span>'),Ou=g("<option> </option>"),Pu=g('<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>'),Nu=g('<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"/>'),Fu=g('<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>'),Uu=g('<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>'),zu=g('<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>'),Bu=g(`<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
72
+ 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>`),Hu=g('<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>'),Wu=g('<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>'),ju=g('<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>'),Gu=g('<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>'),qu=g('<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>'),Vu=g('<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>'),Ku=g('<div class="flex flex-col gap-1"><!> <div class="font-mono text-sm whitespace-pre-wrap"> </div></div>'),Yu=g('<span class="font-mono text-xs text-brand-text-muted tabular-nums"> </span>'),Xu=g('<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>'),Zu=g('<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>'),Qu=g('<span class="text-xs break-words text-brand-text-muted"> </span>'),Ju=g('<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>'),ef=g('<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>'),tf=g('<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>'),nf=g('<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>'),rf=g('<audio controls="" preload="metadata" class="mt-2 block w-full max-w-full"></audio>'),sf=g('<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),of=g('<div class="flex max-w-full min-w-[240px] flex-col"><!> <!> <!> <!></div>'),af=g('<span class="text-xs break-words text-brand-text-muted"> </span>'),lf=g('<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>'),cf=g('<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>'),df=g('<div class="flex max-w-full min-w-[240px] flex-col"><!></div>'),uf=g('<span class="inline-block animate-spin font-bold text-amber-400">⚡</span>'),ff=g('<span class="font-bold text-rose-400" title="Failed">❌</span>'),pf=g('<span class="font-bold text-brand-text-muted" title="Interrupted, no result (the running tool was stopped, e.g. by a CLI takeover)">⊘</span>'),hf=g('<span class="font-bold text-emerald-400" title="Succeeded">✅</span>'),bf=g('<span class="max-w-[180px] truncate font-mono text-xs text-brand-text-muted sm:max-w-[300px] md:max-w-[450px]"> </span>'),vf=g("<span> </span>"),gf=g('Collapse <span class="text-[10px]">▲</span>',1),mf=g('Expand <span class="text-[10px]">▼</span>',1),xf=g('<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>'),_f=g('<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>'),yf=g('<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>'),wf=g('<audio controls="" preload="metadata" class="mt-2 block w-full max-w-full"></audio>'),kf=g('<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),Sf=g('<a target="_blank" rel="noopener noreferrer" class="block"><img alt="Tool output" class="max-h-96 max-w-full rounded border border-brand-border/40 bg-brand-dark/60 object-contain"/></a>'),Tf=g('<div class="mt-2 flex flex-col gap-1"><div class="flex flex-wrap gap-2"></div></div>'),Af=g('<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>'),Rf=g('<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>'),Cf=g('<div class="animate-pulse p-1 text-xs text-brand-text-muted italic">Running and waiting for output...</div>'),Ef=g(`<div class="p-1 text-xs text-brand-text-muted italic">Interrupted before a result was returned (the
73
+ running tool was stopped, e.g. by a CLI takeover).
74
+ Its outcome is unknown.</div>`),If=g('<div class="p-1 text-xs text-brand-text-muted italic">No output returned</div>'),$f=g('<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>'),Mf=g('<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>'),Lf=g('<pre class="chat-selectable font-sans text-sm leading-relaxed whitespace-pre-wrap"> <span class="ml-0.5 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan align-text-bottom"></span></pre>'),Df=g("<pre> </pre>"),Of=g("<div></div>"),Pf=Ks('<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),Nf=Ks('<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),Ff=Ks('<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),Uf=Ks('<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),zf=g('<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>'),Bf=g('<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>'),Hf=g('<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>'),Wf=g('<div class="text-sm leading-relaxed whitespace-pre-wrap"> </div>'),jf=g('<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>'),Gf=g("<span></span>"),qf=g('<span class="text-brand-text-muted italic"> </span>'),Vf=g('<span class="ml-1 inline-block h-4 w-1.5 animate-pulse bg-brand-cyan"></span>'),Kf=g('<div class="chat-selectable text-sm leading-relaxed whitespace-pre-wrap"><!> <!></div>'),Yf=g('<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>'),Xf=g('<div class="mt-2 flex flex-col gap-1 border-t border-brand-blue/20 pt-2"></div>'),Zf=g("<!> <!>",1),Qf=g('<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),Jf=g('<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>'),ep=g('<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>'),tp=g('<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>'),np=g("<div><!> </div> <!> <!> <!>",1),rp=g("<div><div><!> <!></div></div>"),sp=g('<div class="flex-1 space-y-4 overflow-y-auto overscroll-y-contain p-4"><!> <!></div>'),op=g('<button type="button" aria-label="Cycle waiting-for-human beep for this session"><span> </span> <span> </span></button>'),ap=g('<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>'),ip=g('<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>'),lp=g('<span class="ml-1 text-xs text-brand-text-muted">(already a Git repository)</span>'),cp=g('<span class="ml-1 text-xs font-medium text-yellow-500">(folder not empty)</span>'),dp=g('<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>'),up=g('<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>'),fp=g('<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>'),pp=g('<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>'),hp=g('<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>'),bp=g('<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 vp(n,e){zr(e,!0);const r=()=>Se(Vt,"$piState",ae),s=()=>Se(is,"$availableModels",ae),o=()=>Se(jo,"$gitInitDefaultStore",ae),a=()=>Se($s,"$activeSessionInfo",ae),i=()=>Se(oo,"$isLoadingSession",ae),d=()=>Se(so,"$isReadOnly",ae),m=()=>Se(Vo,"$beepSessionOverride",ae),x=()=>Se(Ko,"$beepEnabled",ae),_=()=>Se(xi,"$conversationMode",ae),S=()=>Se(yi,"$collapseLongReplies",ae),R=()=>Se(ji,"$messages",ae),P=()=>Se(_i,"$speakReplies",ae),O=()=>Se(ea,"$isStreaming",ae),q=()=>Se(Qi,"$hasMoreHistory",ae),ve=()=>Se(Ji,"$isLoadingMoreHistory",ae),Z=()=>Se(Vi,"$pendingSteering",ae),[ae,Je]=ls(),fe=[],Ce=new Map;function he(l,v){const w=`${l}:${v.length}`;let I=Ce.get(w);return I===void 0&&(I=ku(v),Ce.set(w,I)),I}const me=new Map;function bt(l){let v=me.get(l);return v===void 0&&(v=Tu(l),me.set(l,v)),v}function It(l){if(l>=1e6){const v=l/1e6;return(v>=10?Math.round(v).toString():v.toFixed(1))+"M"}return l>=1e3?Math.round(l/1e3)+"K":String(l)}let et=G(()=>{const l=r().contextUsage;if(!l||!l.contextWindow)return null;const v=It(l.contextWindow);return l.percent==null?`– / ${v}`:`${l.percent.toFixed(1)}% / ${v}`});function At(l){if(!l)return{cleanContent:"",attachments:[],skill:null};const v=Wo(l);if(v)return{cleanContent:"",attachments:[],skill:v};const w=l.split(`
75
+ `),I=/^\[Uploaded file: (.+)\]$/,X=[],re=[];for(const De of w){const Ie=De.match(I);Ie?re.push(Ie[1]):X.push(De)}let y=X.join(`
76
+ `).trim();return y==="I have uploaded the following file(s) for you:"&&(y=""),{cleanContent:y,attachments:re,skill:null}}let se=W(""),Ht=W(sr([])),tt=W(!1),wt=W(null),ct=W(null),sn="",Wt=W(""),je=W(!1),$t=W(null),H=W(!0),ze=W("private"),jt=W(!1),Kt=W(!1),Mt=W(!1),Xt=W(null);function Lt(l){mr(t(se).trim(),t(Wt)||void 0,l?!1:t(je),l?!1:t(K).matchingRule?t(H):void 0,l?void 0:t(K).matchingRule?t(ze):void 0,l||void 0)}let Rt=G(r),vt=G(s),Xe=G(o);Et(()=>{t($t)===null&&h(je,t(Xe),!0)});let K=W(sr({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),vn=G(()=>t(K).exists!==!0&&t(K).matchingRule&&t(H)),Le=null;async function Ge(l,v=!1){if(Le&&clearTimeout(Le),l===sn&&!v)return;if(sn=l,!l.trim()){h(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const I=async()=>{const X=await js("");h(Ht,X||[],!0)};v?await I():Le=setTimeout(I,300);return}const w=async()=>{const[I,X]=await Promise.all([di(l),js(l)]);h(Ht,X||[],!0),I?(h(K,{exists:I.exists,isGit:I.isGit,resolvedPath:I.resolvedPath,matchingRule:I.matchingRule||null},!0),I.exists||(h(je,t($t)!==null?t($t):t(Xe),!0),h(H,!0),I.matchingRule&&h(ze,I.matchingRule.visibility,!0))):h(K,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};v?await w():Le=setTimeout(w,300)}Et(()=>{const l=t(se);Ge(l,!1)}),Et(()=>{if(t(vt).models.length>0&&!t(Wt)){const l=t(vt).models.find(v=>v.isDefault);l?h(Wt,`${l.provider}:${l.modelId}`):h(Wt,`${t(vt).models[0].provider}:${t(vt).models[0].modelId}`)}});async function M(){if(t(se).trim()){if(t(K).exists===!0){h(je,!1),h(H,!1),t(K).matchingRule&&h(ze,t(K).matchingRule.visibility,!0),h(jt,!0);return}if(t(K).matchingRule&&t(H)){h(Mt,!0);try{const l=await Sc(t(se).trim());if(l&&l.matched&&l.exists){h(Xt,{provider:l.provider,sshUrl:l.sshUrl},!0),h(Kt,!0);return}}finally{h(Mt,!1)}}Lt(!1)}}let A=W(void 0),le=G(a),xe=G(i),L=G(d);function j(l){if(!l)return;const v=t(le).sessionId;v&&Di(v,l)}let ne=G(m),Ze=G(x),ue=G(_);function nt(){ra(),Si(!t(ue))}let _e=G(()=>Ws("collapseLongReplies",{conversationMode:_(),autoSendOnSpeechEnd:!1,speakReplies:!1,collapseLongReplies:S(),micReopensAfterReply:!1}));const Be=new Set;function pt(){return typeof localStorage>"u"?"":localStorage.getItem("wherever-speech-locale")||""}Et(()=>{const l=R();P();for(const v of l){if(v.role!=="tool"||v.toolName!=="say"||v.isStreaming||Be.has(v.id)||(Be.add(v.id),v.isError)||!Ws("speakReplies",to()))continue;const w=zn(v);w.sayText&&Kc(w.sayText,pt())}});function kt(){t(ne)===void 0?Us(!0):t(ne)===!0?Us(!1):Us(void 0)}let gt=G(()=>!!t(le).sessionFile),mt=W(!0),Gt=W(!1),Oe=sr({});function st(l,v){Oe[l]=!v}let dn=sr({});function mn(l){dn[l]=!dn[l]}let kn=W(null),on=null;async function In(l,v){try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(v);else{const w=document.createElement("textarea");w.value=v,w.style.position="fixed",w.style.opacity="0",document.body.appendChild(w),w.select(),document.execCommand("copy"),document.body.removeChild(w)}h(kn,l,!0),on&&clearTimeout(on),on=setTimeout(()=>{h(kn,null),on=null},1500)}catch(w){console.error("Failed to copy message",w)}}function an(l){if(!l)return null;const v=l.trim();if(!v)return null;if(v.startsWith("{"))try{return JSON.parse(v)}catch{}const w={},I=/([a-zA-Z0-9_-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+))/g;let X;for(;(X=I.exec(v))!==null;){const re=X[1],y=X[2]!==void 0?X[2]:X[3]!==void 0?X[3]:X[4];w[re]=y}return Object.keys(w).length>0?w:null}function Vn(l,v,w){if(!v)return w?w.trim():"";const I=l.toLowerCase();if(["read","write","edit","ls"].includes(I)){const re=v.path||v.filepath||v.file;if(re)return String(re)}if(I==="bash"){const re=v.command||v.cmd;if(re){const y=String(re).replace(/\s+/g," ").trim();return y.length>50?y.slice(0,47)+"...":y}}if(I==="grep"){const re=v.pattern,y=v.path;if(re)return y?`"${re}" in ${y}`:`"${re}"`}if(I==="find"){const re=v.pattern||v.path;if(re)return String(re)}const X=v.path||v.filepath||v.file||v.name||v.query;return X?String(X):Object.entries(v).filter(([re,y])=>y!==void 0&&y!=="").map(([re,y])=>`${re}=${typeof y=="object"?JSON.stringify(y):y}`).join(" ")}function Kn(l,v){return l?JSON.stringify(l,null,2):v?v.trim():""}function Ln(l){return l==="attach_file"||l==="say"}function zn(l){let v=l.toolName||"tool",w=l.toolArgs!==void 0?l.toolArgs:"",I=l.toolOutput!==void 0?l.toolOutput:"",X=!!l.isError;if(!w&&!I&&l.content){let Ie=l.content||"";Ie.startsWith("Error: ")?(X=!0,Ie=Ie.slice(7)):Ie.startsWith("Tool error: ")&&(X=!0,Ie=Ie.slice(12));const Dt=Ie.indexOf(`
77
+ `),Ot=Dt!==-1?Ie.slice(0,Dt):Ie;I=Dt!==-1?Ie.slice(Dt+1):"";let tn=Ot.trim();tn.startsWith("$ ")&&(tn=tn.slice(2));const yn=tn.indexOf(" ");v=l.toolName||(yn!==-1?tn.slice(0,yn):tn)||"tool",w=yn!==-1?tn.slice(yn+1):""}const re=an(w),y=Vn(v,re,w),De=Kn(re,w);return{toolName:v,smartTitleArgs:y,fullArgs:De,toolOutput:I,isError:X,interrupted:!!l.interrupted,downloadPath:sd(v,re,X),sayText:v==="say"?Gc(re):null}}function tr(l){return l.scrollHeight-l.scrollTop-l.clientHeight<=20}function Bn(){t(A)&&h(mt,tr(t(A)),!0)}function C(){t(A)&&(t(A).scrollTop=t(A).scrollHeight)}function T(){(t(mt)||t(Gt))&&(C(),h(Gt,!1))}Es(C),Et(()=>{if(t(A))return t(A).addEventListener("scroll",Bn),()=>{t(A)&&t(A).removeEventListener("scroll",Bn)}});let z=W(null),Q=W(!1);function oe(){h(Gt,!0),C(),requestAnimationFrame(()=>{C(),requestAnimationFrame(C)}),setTimeout(C,60),setTimeout(C,150)}Et(()=>{const l=t(le).sessionFile;l!==t(z)&&(h(z,l,!0),h(Gt,!0));const v=t(xe);t(Q)&&!v&&oe(),h(Q,v,!0)});let Pe=G(()=>{const l=R().filter(w=>w.role==="thinking"&&r().hideThinking?!1:w.role==="tool"&&r().hideTools&&!Ln(w.toolName)?dt(w)||!!w.isStreaming:w.role!=="assistant"&&w.role!=="thinking"||w.isStreaming||w.content.trim()!==""),v=l.some(w=>w.isStreaming);if(t(He)&&!v){const w=R().some(I=>I.role==="thinking"&&I.isStreaming);l.push({id:"fallback-loader-message-id",role:"thinking",content:w?"FALLBACK_THINKING_LOADER":"FALLBACK_LOADER",timestamp:Date.now(),isStreaming:!0})}return l}),He=G(O),pe=W(sr(Date.now())),Fe=G(()=>t(Pe).some(l=>l.role==="tool"&&l.isStreaming));Et(()=>{if(!t(Fe))return;h(pe,Date.now(),!0);const l=setInterval(()=>h(pe,Date.now(),!0),100);return()=>clearInterval(l)});function xt(l){if(l.startedAt===void 0)return null;const v=l.endedAt??(l.isStreaming?t(pe):void 0);return v===void 0?null:`${(Math.max(0,v-l.startedAt)/1e3).toFixed(1)}s`}Vl(()=>{const l=t(Pe)[t(Pe).length-1];l&&`${t(Pe).length}${l.content.length}`,t(A)&&h(mt,tr(t(A)),!0)}),Et(()=>{const l=t(Pe)[t(Pe).length-1];l&&`${t(Pe).length}${l.content.length}`,T()});function ln(l){return new Date(l).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function dt(l){return l.role==="tool"&&l.forceCommand===!0}function E(l,v){return dt(l)}function D(){h(Gt,!0),setTimeout(C,0)}let N=G(q),ie=G(ve);const Te=64;let Ee=W(null),te=W(null);function be(){!t(A)||t(ie)||!t(N)||(h(Ee,t(Pe)[0]?.id??null,!0),h(te,t(A).scrollHeight-t(A).scrollTop),Pi())}Et(()=>{if(R().length,(t(Ee)!==null||t(te)!==null)&&t(A)){const l=t(Ee),v=t(te);h(Ee,null),h(te,null),requestAnimationFrame(()=>{if(!t(A))return;const w=l?t(A).querySelector(`[data-msg-id="${CSS.escape(l)}"]`):null;if(w){const I=w.getBoundingClientRect().top-t(A).getBoundingClientRect().top;t(A).scrollTop=Math.max(0,t(A).scrollTop+I-Te)}else v!==null&&(t(A).scrollTop=t(A).scrollHeight-v)})}});var ye={forceScrollToBottom:D},St=bp(),xn=u(St);{var un=l=>{var v=Au();b(l,v)},gn=l=>{var v=Cu(),w=u(v),I=p(u(w),6);{var X=y=>{var De=Ru(),Ie=u(De,!0);c(De),$(()=>V(Ie,t(Rt).error)),b(y,De)};k(I,y=>{t(Rt).error&&y(X)})}var re=p(I,2);c(w),c(v),F("click",re,()=>{Zl(()=>Promise.resolve().then(()=>jc),void 0,import.meta.url).then(y=>y.connect())}),b(l,v)},Y=l=>{var v=Eu();b(l,v)},ce=l=>{var v=Bu(),w=u(v),I=u(w),X=u(I),re=u(X);c(X),Ve(6),c(I);var y=p(I,2),De=u(y),Ie=p(u(De),2),Dt=u(Ie);rt(Dt),ur(Dt,B=>h(wt,B),()=>t(wt));var Ot=p(Dt,2);{var tn=B=>{var ee=$u();Fn(ee,21,()=>t(Ht),cr,($e,Ne)=>{var Me=Iu(),ke=u(Me,!0);c(Me),$(()=>V(ke,t(Ne))),F("click",Me,()=>{h(se,t(Ne),!0),Ge(t(Ne),!0),t(wt)?.focus()}),b($e,Me)}),c(ee),b(B,ee)};k(Ot,B=>{t(tt)&&t(Ht).length>0&&B(tn)})}c(Ie),ur(Ie,B=>h(ct,B),()=>t(ct));var yn=p(Ie,2);{var yr=B=>{var ee=Lu(),$e=p(u(ee));{var Ne=Me=>{var ke=Mu();b(Me,ke)};k($e,Me=>{t(K).isGit&&Me(Ne)})}c(ee),b(B,ee)},Hr=B=>{var ee=Du();b(B,ee)};k(yn,B=>{t(K).exists===!0?B(yr):B(Hr,-1)})}c(De);var Dr=p(De,2),Zt=p(u(Dr),2);{var Nt=B=>{var ee=Pu();Fn(ee,21,()=>t(vt).models,cr,($e,Ne)=>{var Me=Ou(),ke=u(Me);c(Me);var ot={};$(()=>{V(ke,`${t(Ne).label??""}${t(Ne).isDefault?" (default)":""}`),ot!==(ot=`${t(Ne).provider}:${t(Ne).modelId}`)&&(Me.value=Me.__value=`${t(Ne).provider}:${t(Ne).modelId}`)}),b($e,Me)}),c(ee),Rs(ee,()=>t(Wt),$e=>h(Wt,$e)),b(B,ee)},Pt=B=>{var ee=Nu();rt(ee),dr(ee,()=>t(Wt),$e=>h(Wt,$e)),b(B,ee)};k(Zt,B=>{t(vt).models.length>0?B(Nt):B(Pt,-1)})}c(Dr);var nn=p(Dr,2);{var Dn=B=>{var ee=Uu(),$e=u(ee),Ne=u($e);rt(Ne);var Me=p(Ne,2),ke=u(Me);c(Me),c($e);var ot=p($e,2);{var it=Ut=>{var On=Fu(),Sn=p(u(On),2),pn=u(Sn);rt(pn),pn.value=pn.__value="private",Ve(),c(Sn);var $n=p(Sn,2),Qt=u($n);rt(Qt),Qt.value=Qt.__value="public",Ve(),c($n),c(On),Ur(fe,[],pn,()=>t(ze),hn=>h(ze,hn)),Ur(fe,[],Qt,()=>t(ze),hn=>h(ze,hn)),b(Ut,On)};k(ot,Ut=>{t(H)&&Ut(it)})}c(ee),$(()=>V(ke,`Create remote ${t(K).matchingRule.provider??""} repository`)),Nn(Ne,()=>t(H),Ut=>h(H,Ut)),b(B,ee)};k(nn,B=>{t(K).exists!==!0&&t(K).matchingRule&&B(Dn)})}var cn=p(nn,2);{var Ft=B=>{var ee=zu(),$e=u(ee);rt($e),Ve(2),c(ee),F("change",$e,Ne=>{h($t,Ne.currentTarget.checked,!0)}),Nn($e,()=>t(je),Ne=>h(je,Ne)),b(B,ee)};k(cn,B=>{t(K).exists!==!0&&(!t(K).matchingRule||!t(H))&&B(Ft)})}var de=p(cn,2),Ye=u(de,!0);c(de),c(y),c(w),c(v),$((B,ee)=>{J(re,"src",B),Jt(Dt,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(vn)?"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"}`),de.disabled=ee,V(Ye,t(Mt)?"Checking remote...":"Create & Start Session")},[()=>os("/logo.svg"),()=>!t(se).trim()||t(Mt)]),Er("submit",y,B=>{B.preventDefault(),M()}),Er("focus",Dt,()=>{h(tt,!0),Ge(t(se),!0)}),Er("blur",Dt,B=>{t(ct)&&t(ct).contains(B.relatedTarget)||h(tt,!1)}),F("keydown",Dt,B=>{B.key==="Escape"&&h(tt,!1)}),dr(Dt,()=>t(se),B=>h(se,B)),b(l,v)},we=l=>{var v=Hu();b(l,v)},qe=l=>{var v=sp(),w=u(v);{var I=re=>{var y=Wu(),De=u(y),Ie=u(De);{var Dt=tn=>{var yn=jn("Loading older messages...");b(tn,yn)},Ot=tn=>{var yn=jn("Load older messages");b(tn,yn)};k(Ie,tn=>{t(ie)?tn(Dt):tn(Ot,-1)})}c(De),c(y),$(()=>De.disabled=t(ie)),F("click",De,be),b(re,y)};k(w,re=>{t(N)&&re(I)})}var X=p(w,2);Fn(X,17,()=>t(Pe),re=>re.id,(re,y)=>{var De=rp(),Ie=u(De),Dt=u(Ie);{var Ot=Zt=>{var Nt=Tr(),Pt=rn(Nt);{var nn=de=>{var Ye=ju();b(de,Ye)},Dn=de=>{var Ye=Gu();b(de,Ye)},cn=de=>{var Ye=qu();b(de,Ye)},Ft=de=>{var Ye=Ku(),B=u(Ye);{var ee=Me=>{var ke=Vu();b(Me,ke)};k(B,Me=>{t(y).isStreaming&&Me(ee)})}var $e=p(B,2),Ne=u($e,!0);c($e),c(Ye),$(()=>V(Ne,t(y).content)),b(de,Ye)};k(Pt,de=>{t(y).content==="FALLBACK_THINKING_LOADER"?de(nn):t(y).content==="FALLBACK_LOADER"?de(Dn,1):r().hideThinking?de(cn,2):de(Ft,-1)})}b(Zt,Nt)},tn=Zt=>{var Nt=Tr(),Pt=rn(Nt);{var nn=Ft=>{var de=Xu(),Ye=p(u(de),2),B=p(u(Ye)),ee=u(B,!0);c(B),Ve(),c(Ye);var $e=p(Ye,2);{var Ne=ke=>{var ot=Yu(),it=u(ot,!0);c(ot),$(Ut=>V(it,Ut),[()=>xt(t(y))]),b(ke,ot)},Me=G(()=>xt(t(y)));k($e,ke=>{t(Me)&&ke(Ne)})}c(de),$(()=>V(ee,t(y).toolName||"agent")),b(Ft,de)},Dn=G(()=>r().hideTools&&!Ln(t(y).toolName)&&!dt(t(y))),cn=Ft=>{const de=G(()=>zn(t(y))),Ye=G(()=>Oe[t(y).id]!==void 0?Oe[t(y).id]:E(t(y),t(Pe))),B=G(()=>t(de).downloadPath),ee=G(()=>t(B)?el(t(B)):null),$e=G(()=>t(B)?rd(t(B)):null),Ne=G(()=>t(de).toolName==="attach_file"),Me=G(()=>t(de).toolName==="say");var ke=Tr(),ot=rn(ke);{var it=Sn=>{const pn=G(()=>t(B)?t(B).split("/").pop()||t(B):"");var $n=of(),Qt=u($n);{var hn=Bt=>{var ht=Zu();b(Bt,ht)},Xn=Bt=>{var ht=Ju(),Qn=p(u(ht),2),or=p(u(Qn),2);{var jr=kr=>{var Gr=Qu(),co=u(Gr,!0);c(Gr),$(()=>V(co,t(de).toolOutput)),b(kr,Gr)};k(or,kr=>{t(de).toolOutput&&kr(jr)})}c(Qn),c(ht),b(Bt,ht)},Zn=Bt=>{var ht=ef(),Qn=p(u(ht),2),or=u(Qn),jr=u(or,!0);c(or);var kr=p(or,2),Gr=u(kr,!0);c(kr),c(Qn),Ve(2),c(ht),$(()=>{J(ht,"href",t(ee)),J(ht,"download",t(pn)),J(ht,"title",`Download ${t(B)}`),V(jr,t(pn)),J(kr,"title",t(B)),V(Gr,t(B))}),b(Bt,ht)},Qe=Bt=>{var ht=tf(),Qn=p(u(ht),2),or=u(Qn),jr=u(or,!0);c(or),Ve(2),c(Qn),c(ht),$(()=>V(jr,t(pn))),b(Bt,ht)};k(Qt,Bt=>{t(y).isStreaming?Bt(hn):t(de).isError?Bt(Xn,1):t(ee)?Bt(Zn,2):Bt(Qe,-1)})}var ut=p(Qt,2);{var wr=Bt=>{var ht=nf(),Qn=u(ht);c(ht),$(()=>{J(ht,"href",t(ee)),J(ht,"title",`Open ${t(B)}`),J(Qn,"src",t(ee)),J(Qn,"alt",t(B))}),b(Bt,ht)};k(ut,Bt=>{!t(y).isStreaming&&!t(de).isError&&t(ee)&&t($e)==="image"&&Bt(wr)})}var hr=p(ut,2);{var Wr=Bt=>{var ht=rf();$(()=>{J(ht,"src",t(ee)),J(ht,"title",t(B))}),b(Bt,ht)};k(hr,Bt=>{!t(y).isStreaming&&!t(de).isError&&t(ee)&&t($e)==="audio"&&Bt(Wr)})}var es=p(hr,2);{var lo=Bt=>{var ht=sf();$(()=>{J(ht,"src",t(ee)),J(ht,"title",t(B))}),b(Bt,ht)};k(es,Bt=>{!t(y).isStreaming&&!t(de).isError&&t(ee)&&t($e)==="video"&&Bt(lo)})}c($n),b(Sn,$n)},Ut=Sn=>{var pn=df(),$n=u(pn);{var Qt=Xn=>{var Zn=lf(),Qe=p(u(Zn),2),ut=p(u(Qe),2);{var wr=hr=>{var Wr=af(),es=u(Wr,!0);c(Wr),$(()=>V(es,t(de).toolOutput)),b(hr,Wr)};k(ut,hr=>{t(de).toolOutput&&hr(wr)})}c(Qe),c(Zn),b(Xn,Zn)},hn=Xn=>{var Zn=cf(),Qe=p(u(Zn),2),ut=p(u(Qe),2),wr=u(ut,!0);c(ut),c(Qe),c(Zn),$(()=>V(wr,t(de).sayText)),b(Xn,Zn)};k($n,Xn=>{t(de).isError?Xn(Qt):t(de).sayText&&Xn(hn,1)})}c(pn),b(Sn,pn)},On=Sn=>{var pn=Mf(),$n=u(pn),Qt=u($n),hn=u(Qt),Xn=u(hn);{var Zn=ge=>{var Re=uf();b(ge,Re)},Qe=ge=>{var Re=ff();b(ge,Re)},ut=ge=>{var Re=pf();b(ge,Re)},wr=ge=>{var Re=hf();b(ge,Re)};k(Xn,ge=>{t(y).isStreaming?ge(Zn):t(de).isError?ge(Qe,1):t(de).interrupted?ge(ut,2):ge(wr,-1)})}var hr=p(Xn,2),Wr=u(hr,!0);c(hr);var es=p(hr,2);{var lo=ge=>{var Re=bf(),Wn=u(Re,!0);c(Re),$(()=>{J(Re,"title",t(de).smartTitleArgs),V(Wn,t(de).smartTitleArgs)}),b(ge,Re)};k(es,ge=>{t(de).smartTitleArgs&&ge(lo)})}var Bt=p(es,2);{var ht=ge=>{var Re=vf(),Wn=u(Re);c(Re),$(qr=>{Jt(Re,1,`shrink-0 font-mono text-xs tabular-nums ${t(y).isStreaming?"text-amber-400":"text-brand-text-muted"}`),J(Re,"title",t(y).isStreaming?"Elapsed time":"Time taken"),V(Wn,`${t(y).isStreaming?"Elapsed":"Took"}
78
+ ${qr??""}`)},[()=>xt(t(y))]),b(ge,Re)},Qn=G(()=>xt(t(y)));k(Bt,ge=>{t(Qn)&&ge(ht)})}c(hn);var or=p(hn,2),jr=u(or);{var kr=ge=>{var Re=gf();Ve(),b(ge,Re)},Gr=ge=>{var Re=mf();Ve(),b(ge,Re)};k(jr,ge=>{t(Ye)?ge(kr):ge(Gr,-1)})}c(or),c(Qt);var co=p(Qt,2);{var _l=ge=>{var Re=Tr(),Wn=rn(Re);{var qr=Jn=>{var ar=xf();$(uo=>{J(ar,"href",t(ee)),J(ar,"download",uo),J(ar,"title",`Download ${t(B)}`),J(ar,"aria-label",`Download ${t(B)}`)},[()=>t(B).split("/").pop()||""]),b(Jn,ar)},Sr=Jn=>{var ar=_f();b(Jn,ar)};k(Wn,Jn=>{t(ee)?Jn(qr):Jn(Sr,-1)})}b(ge,Re)};k(co,ge=>{t(B)&&ge(_l)})}c($n);var ha=p($n,2);{var yl=ge=>{var Re=yf(),Wn=u(Re);c(Re),$(()=>{J(Re,"href",t(ee)),J(Re,"title",`Open ${t(B)}`),J(Wn,"src",t(ee)),J(Wn,"alt",t(B))}),b(ge,Re)};k(ha,ge=>{!(t(y).images&&t(y).images.length>0)&&t(ee)&&t($e)==="image"&&ge(yl)})}var ba=p(ha,2);{var wl=ge=>{var Re=wf();$(()=>{J(Re,"src",t(ee)),J(Re,"title",t(B))}),b(ge,Re)};k(ba,ge=>{t(ee)&&t($e)==="audio"&&ge(wl)})}var va=p(ba,2);{var kl=ge=>{var Re=kf();$(()=>{J(Re,"src",t(ee)),J(Re,"title",t(B))}),b(ge,Re)};k(va,ge=>{t(ee)&&t($e)==="video"&&ge(kl)})}var ga=p(va,2);{var Sl=ge=>{var Re=Tf(),Wn=u(Re);Fn(Wn,21,()=>t(y).images,cr,(qr,Sr)=>{var Jn=Sf(),ar=u(Jn);c(Jn),$(()=>{J(Jn,"href",`data:${t(Sr).mimeType};base64,${t(Sr).data}`),J(ar,"src",`data:${t(Sr).mimeType};base64,${t(Sr).data}`)}),b(qr,Jn)}),c(Wn),c(Re),b(ge,Re)};k(ga,ge=>{t(y).images&&t(y).images.length>0&&ge(Sl)})}var Tl=p(ga,2);{var Al=ge=>{var Re=$f(),Wn=u(Re);{var qr=Mn=>{var er=Af(),Ls=p(u(er),2),El=u(Ls,!0);c(Ls),c(er),$(()=>V(El,t(de).fullArgs)),b(Mn,er)};k(Wn,Mn=>{t(de).fullArgs&&t(de).fullArgs!=="{}"&&Mn(qr)})}var Sr=p(Wn,2),Jn=p(u(Sr),2);{var ar=Mn=>{var er=Rf(),Ls=u(er,!0);c(er),$(()=>V(Ls,t(de).toolOutput)),b(Mn,er)},uo=Mn=>{var er=Cf();b(Mn,er)},Rl=Mn=>{var er=Ef();b(Mn,er)},Cl=Mn=>{var er=If();b(Mn,er)};k(Jn,Mn=>{t(de).toolOutput?Mn(ar):t(y).isStreaming?Mn(uo,1):t(de).interrupted?Mn(Rl,2):Mn(Cl,-1)})}c(Sr),c(Re),b(ge,Re)};k(Tl,ge=>{t(Ye)&&ge(Al)})}c(pn),$(()=>V(Wr,t(de).toolName)),F("click",Qt,()=>st(t(y).id,t(Ye))),b(Sn,pn)};k(ot,Sn=>{t(Ne)?Sn(it):t(Me)?Sn(Ut,1):Sn(On,-1)})}b(Ft,ke)};k(Pt,Ft=>{t(Dn)?Ft(nn):Ft(cn,-1)})}b(Zt,Nt)},yn=Zt=>{var Nt=Tr(),Pt=rn(Nt);{var nn=cn=>{var Ft=Lf(),de=u(Ft,!0);Ve(),c(Ft),$(()=>V(de,t(y).content)),b(cn,Ft)},Dn=cn=>{const Ft=G(()=>Oe[t(y).id]===!0),de=G(()=>ad({active:t(_e),expanded:t(Ft),content:t(y).content})),Ye=G(()=>dn[t(y).id]===!0);var B=Hf(),ee=u(B);{var $e=Qe=>{var ut=Df(),wr=u(ut,!0);c(ut),$(()=>{Jt(ut,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(de)?"relative max-h-40 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)] opacity-80":""}`),V(wr,t(y).content)}),b(Qe,ut)},Ne=Qe=>{var ut=Of();ka(ut,()=>he(t(y).id,t(y).content),!0),c(ut),$(()=>Jt(ut,1,`chat-selectable markdown-body text-sm leading-relaxed ${t(de)?"relative max-h-40 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)] opacity-80":""}`)),b(Qe,ut)};k(ee,Qe=>{t(Ye)?Qe($e):Qe(Ne,-1)})}var Me=p(ee,2),ke=u(Me),ot=u(ke);{var it=Qe=>{var ut=Pf();Ve(),b(Qe,ut)},Ut=Qe=>{var ut=Nf();Ve(),b(Qe,ut)};k(ot,Qe=>{t(kn)===t(y).id?Qe(it):Qe(Ut,-1)})}c(ke);var On=p(ke,2),Sn=u(On);{var pn=Qe=>{var ut=Ff();Ve(),b(Qe,ut)},$n=Qe=>{var ut=Uf();Ve(),b(Qe,ut)};k(Sn,Qe=>{t(Ye)?Qe(pn):Qe($n,-1)})}c(On),c(Me);var Qt=p(Me,2);{var hn=Qe=>{var ut=zf();F("click",ut,()=>st(t(y).id,t(Ft))),b(Qe,ut)},Xn=Qe=>{var ut=Bf();F("click",ut,()=>st(t(y).id,t(Ft))),b(Qe,ut)},Zn=G(()=>t(_e)&&t(Ft)&&sl(t(y).content));k(Qt,Qe=>{t(de)?Qe(hn):t(Zn)&&Qe(Xn,1)})}c(B),$(()=>J(On,"title",t(Ye)?"Show the rendered markdown":"Show the raw markdown source")),F("click",ke,()=>In(t(y).id,t(y).content)),F("click",On,()=>mn(t(y).id)),b(cn,B)};k(Pt,cn=>{t(y).isStreaming?cn(nn):cn(Dn,-1)})}b(Zt,Nt)},yr=Zt=>{const Nt=G(()=>At(t(y).content));var Pt=Zf(),nn=rn(Pt);{var Dn=Ye=>{var B=jf(),ee=u(B),$e=p(u(ee),2),Ne=u($e);c($e),c(ee);var Me=p(ee,2);{var ke=ot=>{var it=Wf(),Ut=u(it,!0);c(it),$(()=>V(Ut,t(Nt).skill.args)),b(ot,it)};k(Me,ot=>{t(Nt).skill.args&&ot(ke)})}c(B),$(()=>V(Ne,`skill:${t(Nt).skill.skillName??""}`)),b(Ye,B)},cn=Ye=>{var B=Kf(),ee=u(B);{var $e=it=>{const Ut=G(()=>bt(t(Nt).cleanContent));var On=Tr(),Sn=rn(On);{var pn=Qt=>{var hn=Gf();ka(hn,()=>t(Ut),!0),c(hn),b(Qt,hn)},$n=Qt=>{var hn=jn();$(()=>V(hn,t(Nt).cleanContent)),b(Qt,hn)};k(Sn,Qt=>{t(Ut)?Qt(pn):Qt($n,-1)})}b(it,On)},Ne=it=>{var Ut=qf(),On=u(Ut);c(Ut),$(()=>V(On,`Shared file${t(Nt).attachments.length>1?"s":""} with agent:`)),b(it,Ut)},Me=it=>{var Ut=jn();$(()=>V(Ut,t(y).content||(t(y).isStreaming?"Thinking...":""))),b(it,Ut)};k(ee,it=>{t(Nt).cleanContent?it($e):t(Nt).attachments.length>0?it(Ne,1):it(Me,-1)})}var ke=p(ee,2);{var ot=it=>{var Ut=Vf();b(it,Ut)};k(ke,it=>{t(y).isStreaming&&t(He)&&it(ot)})}c(B),b(Ye,B)};k(nn,Ye=>{t(Nt).skill?Ye(Dn):Ye(cn,-1)})}var Ft=p(nn,2);{var de=Ye=>{var B=Xf();Fn(B,21,()=>t(Nt).attachments,cr,(ee,$e)=>{var Ne=Yf(),Me=p(u(Ne),2),ke=u(Me,!0);c(Me),c(Ne),$(()=>{J(Me,"title",t($e)),V(ke,t($e))}),b(ee,Ne)}),c(B),b(Ye,B)};k(Ft,Ye=>{t(Nt).attachments.length>0&&Ye(de)})}b(Zt,Pt)};k(Dt,Zt=>{t(y).role==="thinking"?Zt(Ot):t(y).role==="tool"?Zt(tn,1):t(y).role==="assistant"&&t(y).content!==""?Zt(yn,2):Zt(yr,-1)})}var Hr=p(Dt,2);{var Dr=Zt=>{var Nt=np(),Pt=rn(Nt),nn=u(Pt);{var Dn=ke=>{var ot=Qf();Ve(4),b(ke,ot)};k(nn,ke=>{t(y).role==="user"&&t(y).delivery==="sending"&&ke(Dn)})}var cn=p(nn);c(Pt);var Ft=p(Pt,2);{var de=ke=>{var ot=Jf(),it=u(ot);c(ot),F("click",it,()=>j(t(y).entryId)),b(ke,ot)},Ye=G(()=>t(y).role==="user"&&t(y).entryId&&t(le).sessionId&&!t(L)&&t(y).delivery===void 0&&!Z().includes(t(y).content));k(Ft,ke=>{t(Ye)&&ke(de)})}var B=p(Ft,2);{var ee=ke=>{var ot=ep();b(ke,ot)},$e=G(()=>t(y).role==="user"&&Z().includes(t(y).content));k(B,ke=>{t($e)&&ke(ee)})}var Ne=p(B,2);{var Me=ke=>{var ot=tp(),it=p(u(ot),2),Ut=p(it,2);c(ot),F("click",it,()=>Ei(t(y).id)),F("click",Ut,()=>Ii(t(y).id)),b(ke,ot)};k(Ne,ke=>{t(y).role==="user"&&t(y).delivery==="failed"&&ke(Me)})}$(ke=>{Jt(Pt,1,`mt-1 flex items-center gap-1.5 text-xs opacity-50 ${t(y).role==="user"?"justify-end text-brand-text-muted":t(y).role==="assistant"?"text-brand-purple":"text-brand-text-muted"}`),V(cn,` ${ke??""}`)},[()=>ln(t(y).timestamp)]),b(Zt,Nt)};k(Hr,Zt=>{t(y).role!=="thinking"&&t(y).role!=="tool"&&Zt(Dr)})}c(Ie),c(De),$(Zt=>{J(De,"data-msg-id",t(y).id),Jt(De,1,`flex ${t(y).role==="user"?"justify-end":"justify-start"}`),Jt(Ie,1,`max-w-[85%] rounded-lg px-4 py-3 ${Zt??""}`)},[()=>t(y).role==="user"?t(y).delivery==="sending"?"bg-brand-blue/40 text-brand-text ring-1 ring-brand-blue/50":t(y).delivery==="failed"?"bg-brand-blue/30 text-brand-text ring-1 ring-amber-400/50":"bg-brand-blue/80 text-brand-text":t(y).role==="thinking"?"border-l-2 border-brand-border bg-brand-surface/30 text-sm text-brand-text-muted":t(y).role==="tool"&&Ln(t(y).toolName)?"bg-transparent p-0 text-brand-text":t(y).role==="tool"?r().hideTools&&!dt(t(y))?"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(y).isStreaming?"border-amber-400":t(y).isError?"border-rose-400":t(y).interrupted?"border-brand-border":"border-emerald-400"}`:t(y).role==="assistant"?"border-l-2 border-brand-purple bg-brand-purple/10 text-brand-text":t(y).content===""&&t(y).isStreaming?"bg-brand-surface-3 text-brand-text-muted italic":"bg-brand-surface-2 text-brand-text"]),b(re,De)}),c(v),ur(v,re=>h(A,re),()=>t(A)),b(l,v)};k(xn,l=>{t(Rt).connecting&&!t(gt)?l(un):!t(Rt).connected&&!t(gt)?l(gn,1):!t(gt)&&(t(xe)||typeof window<"u"&&window.location.hash)?l(Y,2):t(le).sessionFile?t(Pe).length===0?l(we,4):l(qe,-1):l(ce,3)})}var We=p(xn,2),Ke=u(We),_t=u(Ke),zt=u(_t);rt(zt),Ve(),c(_t);var _n=p(_t,2);{var fn=l=>{var v=op(),w=u(v),I=u(w,!0);c(w);var X=p(w,2),re=u(X,!0);c(X),c(v),$(()=>{Jt(v,1,`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text ${t(ne)===void 0?"text-brand-text-muted":"text-brand-blue"}`),J(v,"title",t(ne)===void 0?`Beep when the agent is waiting: following the default (${t(Ze)?"on":"off"}). Click to set On for this session.`:t(ne)===!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."),V(I,t(Ze)?"🔔":"🔕"),V(re,t(ne)===void 0?`Beep: Default (${t(Ze)?"on":"off"})`:t(ne)?"Beep: On":"Beep: Off")}),F("click",v,kt),b(l,v)};k(_n,l=>{t(le).sessionFile&&!d()&&l(fn)})}var Ae=p(_n,2),at=u(Ae),Yt=u(at,!0);c(at);var Yn=p(at,2),nr=u(Yn,!0);c(Yn),c(Ae);var $r=p(Ae,2);{var xr=l=>{var v=ap(),w=p(u(v),2),I=u(w,!0);c(w),c(v),$(X=>{J(v,"title",X),V(I,t(et))},[()=>r().contextUsage?.tokens!=null?`${r().contextUsage.tokens.toLocaleString()} context tokens of ${r().contextUsage.contextWindow.toLocaleString()}`:"Context window size"]),b(l,v)};k($r,l=>{t(et)&&l(xr)})}c(Ke);var Mr=p(Ke,2),Ue=u(Mr);{var Ct=l=>{var v=ip(),w=u(v);c(v),$(()=>{J(v,"title",`Cancel the queued steer message${Z().length>1?"s":""} (does not abort the current turn)`),V(w,`Cancel queued${Z().length>1?` (${Z().length})`:""}`)}),F("click",v,function(...I){Mi?.apply(this,I)}),b(l,v)};k(Ue,l=>{Z().length>0&&l(Ct)})}var Hn=p(Ue,2);c(Mr),c(We);var _r=p(We,2);{var Lr=l=>{var v=fp(),w=u(v),I=p(u(w),2),X=p(u(I)),re=u(X,!0);c(X),Ve(),c(I);var y=p(I,2),De=u(y),Ie=u(De);rt(Ie);var Dt=p(Ie,2),Ot=p(u(Dt));{var tn=Pt=>{var nn=lp();b(Pt,nn)},yn=Pt=>{var nn=cp();b(Pt,nn)};k(Ot,Pt=>{t(K).isGit?Pt(tn):Pt(yn,-1)})}c(Dt),c(De);var yr=p(De,2);{var Hr=Pt=>{var nn=up(),Dn=u(nn),cn=u(Dn);rt(cn);var Ft=p(cn,2),de=u(Ft);c(Ft),c(Dn);var Ye=p(Dn,2);{var B=ee=>{var $e=dp(),Ne=p(u($e),2),Me=u(Ne);rt(Me),Me.value=Me.__value="private",Ve(),c(Ne);var ke=p(Ne,2),ot=u(ke);rt(ot),ot.value=ot.__value="public",Ve(),c(ke),c($e),Ur(fe,[],Me,()=>t(ze),it=>h(ze,it)),Ur(fe,[],ot,()=>t(ze),it=>h(ze,it)),b(ee,$e)};k(Ye,ee=>{t(H)&&ee(B)})}c(nn),$(()=>V(de,`Create remote ${t(K).matchingRule.provider??""} repository`)),Nn(cn,()=>t(H),ee=>h(H,ee)),b(Pt,nn)};k(yr,Pt=>{t(K).matchingRule&&Pt(Hr)})}c(y);var Dr=p(y,2),Zt=u(Dr),Nt=p(Zt,2);c(Dr),c(w),c(v),$(()=>{V(re,t(se)),Ie.disabled=t(K).isGit}),Nn(Ie,()=>t(je),Pt=>h(je,Pt)),F("click",Zt,()=>h(jt,!1)),F("click",Nt,()=>{h(jt,!1),mr(t(se).trim(),t(Wt)||void 0,t(je),t(K).matchingRule?t(H):void 0,t(K).matchingRule?t(ze):void 0)}),b(l,v)};k(_r,l=>{t(jt)&&l(Lr)})}var rr=p(_r,2);{var U=l=>{var v=hp(),w=u(v),I=p(u(w),2),X=u(I),re=p(X),y=u(re,!0);c(re),Ve(),c(I);var De=p(I,2);{var Ie=yn=>{var yr=pp(),Hr=u(yr,!0);c(yr),$(()=>V(Hr,t(Xt).sshUrl)),b(yn,yr)};k(De,yn=>{t(Xt)?.sshUrl&&yn(Ie)})}var Dt=p(De,2),Ot=u(Dt),tn=p(Ot,2);c(Dt),c(w),c(v),$(()=>{V(X,`A ${t(Xt)?.provider??"remote"??""} repository matching `),V(y,t(se))}),F("click",Ot,()=>{h(Kt,!1),h(Xt,null),Lt(!1)}),F("click",tn,()=>{h(Kt,!1),h(Xt,null),Lt(!0)}),b(l,v)};k(rr,l=>{t(Kt)&&l(U)})}c(St),$(()=>{ni(zt,r().hideThinking),Jt(Ae,1,`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs select-none hover:text-brand-text ${t(ue)?"text-brand-blue":"text-brand-text-muted"}`),J(Ae,"title",t(ue)?"Conversation Mode: ON. Click to turn off (the configured knobs go dormant).":"Conversation Mode: OFF. Click to flip your configured bundle of speech/voice knobs on at once."),V(Yt,t(ue)?"🗣️":"💬"),V(nr,t(ue)?"Conversation: On":"Conversation: Off"),Hn.disabled=!t(He)}),F("change",zt,l=>Ui({hideThinking:l.currentTarget.checked})),F("click",Ae,nt),F("click",Hn,function(...l){$i?.apply(this,l)}),b(n,St);var f=Br(ye);return Je(),f}Qr(["click","keydown","change"]);function gp(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"}}function mp(n){return n.active?n.engine==="browser"?"reopen-mic":"refocus-composer":"none"}var xp=g("<option> </option>"),_p=g('<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>'),yp=g('<div class="mt-2 rounded border border-red-900/40 bg-red-950/40 p-2 leading-normal text-red-400"> </div>'),wp=g(`<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
79
+ the message.</p></div> <!></div>`,1),kp=g('<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 Sp(n,e){zr(e,!0);let r=Nr(e,"text",15),s=Nr(e,"activeEngine",15,"browser");const o=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null,a=!!o;let i=W(!1),d=W(!1),m=W(!1),x=W(!1),_=W(!1),S=W("en-US"),R=W("browser"),P=W(null);Et(()=>{s(t(R))});let O=W(null),q=null,ve=null,Z=null,ae=null,Je=null,fe=[],Ce="",he=!1;const me=[{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)"}],bt=Yo.subscribe(M=>{h(_,M,!0)});Es(()=>{const M=localStorage.getItem("wherever-speech-locale");M!==null&&h(S,M,!0);const A=localStorage.getItem("wherever-speech-engine");return A!==null?h(R,A,!0):a||h(R,"cloud"),()=>{if(bt(),q)try{q.abort()}catch{}if(ae)try{ae.disconnect()}catch{}if(Z)try{Z.disconnect()}catch{}if(Je)try{Je.getTracks().forEach(le=>le.stop())}catch{}if(ve)try{ve.close()}catch{}t(O)&&clearTimeout(t(O))}});function It(){mi(t(_)),localStorage.setItem("wherever-speech-locale",t(S)),localStorage.setItem("wherever-speech-engine",t(R))}function et(){const M=localStorage.getItem("wherever-config");if(M){const A=JSON.parse(M),le=window.location.protocol==="https:"?"https:":"http:",xe=A.host.startsWith("http")?A.host.replace(/^wss?:\/\//,""):A.host;return`${le}//${xe}:${A.port}`}return`${window.location.protocol}//${window.location.host}`}function At(){try{const M=localStorage.getItem("wherever-config");if(M)return JSON.parse(M).token||""}catch{}return""}function se(){try{const M=window.AudioContext||window.webkitAudioContext;if(!M)return;const A=new M,le=A.createOscillator(),xe=A.createGain();le.type="sine",le.frequency.setValueAtTime(400,A.currentTime),xe.gain.setValueAtTime(.08,A.currentTime),xe.gain.exponentialRampToValueAtTime(.001,A.currentTime+.12),le.connect(xe),xe.connect(A.destination),le.start(),le.stop(A.currentTime+.12)}catch(M){console.warn("Could not play audio beep feedback:",M)}}function Ht(M,A,le){if(A===le)return M;const xe=A/le,L=Math.round(M.length/xe),j=new Float32Array(L);let ne=0,Ze=0;for(;ne<j.length;){const ue=Math.round((ne+1)*xe);let nt=0,_e=0;for(let Be=Ze;Be<ue&&Be<M.length;Be++)nt+=M[Be],_e++;j[ne]=_e>0?nt/_e:0,ne++,Ze=ue}return j}function tt(){if(a)try{q=new o,q.continuous=!0,q.interimResults=!0,q.lang=t(S),q.onstart=()=>{h(i,!0),h(d,!1),se()},q.onresult=M=>{let A="",le="";for(let L=M.resultIndex;L<M.results.length;++L){const j=M.results[L];j.isFinal?A+=j[0].transcript:le+=j[0].transcript}const xe=(A+le).trim();xe&&(he=!0,r(Ce+(Ce?" ":"")+xe))},q.onerror=M=>{console.error("Browser speech recognition error:",M.error),M.error!=="no-speech"&&h(P,`Error: ${M.error}`),wt()},q.onend=()=>{h(i,!1),t(_)&&he&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50)},q.start(),navigator.vibrate&&navigator.vibrate(40)}catch(M){console.error("Failed to start browser speech recognition:",M),h(P,"Failed to start browser recording"),h(i,!1)}}function wt(){if(q)try{q.stop()}catch{}h(i,!1)}async function ct(){try{const M=await navigator.mediaDevices.getUserMedia({audio:!0});Je=M,fe=[];const A=window.AudioContext||window.webkitAudioContext;ve=new A,Z=ve.createMediaStreamSource(M),ae=ve.createScriptProcessor(4096,1,1),ae.onaudioprocess=le=>{const xe=le.inputBuffer.getChannelData(0);fe.push(new Float32Array(xe))},Z.connect(ae),ae.connect(ve.destination),h(i,!0),h(d,!1),se(),navigator.vibrate&&navigator.vibrate(40)}catch(M){console.error("Failed to start cloud audio recording:",M),h(P,M.message||"Microphone access denied",!0),h(i,!1),h(d,!1)}}function sn(){if(t(i)){if(h(i,!1),h(d,!0),ae){try{ae.disconnect()}catch{}ae.onaudioprocess=null}if(Z)try{Z.disconnect()}catch{}if(Je)try{Je.getTracks().forEach(M=>M.stop())}catch{}Wt()}}async function Wt(){try{if(fe.length===0){h(d,!1);return}h(P,null);let M=0;for(const kt of fe)M+=kt.length;const A=new Float32Array(M);let le=0;for(const kt of fe)A.set(kt,le),le+=kt.length;const xe=ve?ve.sampleRate:48e3,L=16e3,j=Ht(A,xe,L),ne=Mt(j,1,L,1,16),Ze=new Blob([ne],{type:"audio/wav"}),ue=et(),nt=At(),_e=`${ue}/session/transcribe${nt?`?token=${encodeURIComponent(nt)}`:""}`,Be=await fetch(_e,{method:"POST",body:Ze,headers:{"Content-Type":"application/octet-stream"}}),pt=await Be.json();if(!Be.ok)throw new Error(pt.error||`HTTP ${Be.status}`);pt.text&&pt.text.trim()&&(he=!0,r(Ce+(Ce?" ":"")+pt.text.trim()),t(_)&&e.onSend&&setTimeout(()=>{r().trim()&&e.onSend()},50))}catch(M){console.error("Cloud transcription request failed:",M),h(P,M.message||"Cloud API failed",!0)}finally{if(h(d,!1),ve){try{ve.close()}catch{}ve=null}}}function je(){e.disabled||t(i)||t(d)||(h(P,null),he=!1,Ce=r(),t(R)==="cloud"?ct():tt())}function $t(){je()}function H(){t(R)==="cloud"?sn():wt()}function ze(M){if(M.button===0&&!e.disabled){if(ra(),M.preventDefault(),t(i)){H();return}h(m,!1),h(O,setTimeout(()=>{h(m,!0),je()},350),!0)}}function jt(M){t(O)&&(clearTimeout(t(O)),h(O,null)),t(m)?(h(m,!1),H()):t(i)||je()}function Kt(){t(O)&&(clearTimeout(t(O)),h(O,null)),t(m)&&(h(m,!1),H())}function Mt(M,A,le,xe,L){const j=new ArrayBuffer(44+M.length*2),ne=new DataView(j);return Lt(ne,0,"RIFF"),ne.setUint32(4,36+M.length*2,!0),Lt(ne,8,"WAVE"),Lt(ne,12,"fmt "),ne.setUint32(16,16,!0),ne.setUint16(20,xe,!0),ne.setUint16(22,A,!0),ne.setUint32(24,le,!0),ne.setUint32(28,le*A*(L/8),!0),ne.setUint16(32,A*(L/8),!0),ne.setUint16(34,L,!0),Lt(ne,36,"data"),ne.setUint32(40,M.length*2,!0),Xt(ne,44,M),j}function Xt(M,A,le){for(let xe=0;xe<le.length;xe++,A+=2){let L=Math.max(-1,Math.min(1,le[xe]));M.setInt16(A,L<0?L*32768:L*32767,!0)}}function Lt(M,A,le){for(let xe=0;xe<le.length;xe++)M.setUint8(A+xe,le.charCodeAt(xe))}var Rt={startRecordingProgrammatically:$t},vt=kp(),Xe=u(vt),K=p(Xe,2),vn=u(K);c(K);var Le=p(K,2);{var Ge=M=>{var A=wp(),le=rn(A),xe=p(le,2),L=p(u(xe),2),j=p(u(L),2),ne=u(j),Ze=p(ne,2);c(j);var ue=p(j,2),nt=u(ue,!0);c(ue),c(L);var _e=p(L,2);{var Be=Oe=>{var st=_p(),dn=p(u(st),2);Fn(dn,21,()=>me,cr,(mn,kn)=>{var on=xp(),In=u(on,!0);c(on);var an={};$(()=>{V(In,t(kn).label),an!==(an=t(kn).code)&&(on.value=(on.__value=t(kn).code)??"")}),b(mn,on)}),c(dn),c(st),F("change",dn,It),Rs(dn,()=>t(S),mn=>h(S,mn)),b(Oe,st)};k(_e,Oe=>{t(R)==="browser"&&Oe(Be)})}var pt=p(_e,2),kt=u(pt),gt=u(kt);rt(gt),Ve(2),c(kt),Ve(2),c(pt);var mt=p(pt,2);{var Gt=Oe=>{var st=yp(),dn=u(st,!0);c(st),$(()=>V(dn,t(P))),b(Oe,st)};k(mt,Oe=>{t(P)&&Oe(Gt)})}c(xe),$(()=>{ne.disabled=!a,Jt(ne,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors disabled:opacity-40
80
+ ${t(R)==="browser"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),Jt(Ze,1,`flex-1 rounded border px-2 py-1.5 text-center font-medium transition-colors
81
+ ${t(R)==="cloud"?"border-blue-500 bg-blue-600 text-white":"border-gray-600 bg-gray-950 text-gray-400 hover:text-white"}`),V(nt,t(R)==="browser"?"Uses free built-in browser dictation. Streaming, zero-latency.":"Uses server-side Z.ai / Groq / OpenAI keys. High accent tolerance.")}),F("click",le,()=>h(x,!1)),F("click",ne,()=>{h(R,"browser"),It()}),F("click",Ze,()=>{h(R,"cloud"),It()}),F("change",gt,It),Nn(gt,()=>t(_),Oe=>h(_,Oe)),b(M,A)};k(Le,M=>{t(x)&&M(Ge)})}return c(vt),$(()=>{Xe.disabled=e.disabled&&!t(i)&&!t(d)||t(d),Jt(Xe,1,`flex h-[48px] w-[48px] items-center justify-center rounded-lg border transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-40
82
+ ${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"}`),J(Xe,"title",t(i)?"Recording (release/tap to stop)...":t(d)?"Processing speech...":"Hold to speak (walkie-talkie) or Tap to toggle recording"),K.disabled=e.disabled&&!t(i)&&!t(d)||t(d),Jt(vn,0,`h-4 w-4 transition-transform duration-200 ${t(x)?"rotate-45 text-white":""}`)}),F("pointerdown",Xe,ze),F("pointerup",Xe,jt),Er("pointercancel",Xe,Kt),F("click",K,()=>h(x,!t(x))),b(n,vt),Br(Rt)}Qr(["pointerdown","pointerup","click","change"]);var Tp=g('<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),Ap=g('<span class="text-rose-400">⚠️</span> <span class="text-rose-400/80"> </span>',1),Rp=g('<span class="inline-block h-1.5 w-1.5 rounded-full bg-brand-surface-3"></span> <span>Disconnected from remote server</span>',1),Cp=g('<div class="mb-2.5 flex items-center gap-1.5 text-xs font-medium text-brand-text-muted select-none"><!></div>'),Ep=g('<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>'),Ip=g('<span class="inline-block h-3 w-3 animate-spin rounded-full border-2 border-brand-blue border-t-transparent"></span>'),$p=g('<a target="_blank" class="ml-1 shrink-0 font-semibold text-brand-blue underline hover:opacity-80">[Test Link]</a>'),Mp=g('<span class="flex items-center gap-1 text-[10px] font-medium text-rose-400"><span class="max-w-[120px] truncate"> </span> <!></span>'),Lp=g('<span class="text-emerald-400">✓</span>'),Dp=g('<div class="flex items-center gap-2 rounded border border-brand-border bg-brand-surface-2 px-2.5 py-1.5 text-xs"><span class="max-w-[150px] truncate font-medium text-brand-text"> </span> <!> <button type="button" class="ml-1 font-bold text-brand-text-muted hover:text-brand-text">×</button></div>'),Op=g('<div class="mb-3 flex flex-wrap gap-2"></div>'),Pp=g("<option> </option>"),Np=g('<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>'),Fp=g('<span class="line-clamp-1 text-[11px] text-brand-text-muted"> </span>'),Up=g('<li><button type="button" role="option"><span class="font-mono text-brand-text"> </span> <!></button></li>'),zp=g('<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>'),Bp=g('<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),Hp=g('<span class="hidden font-mono opacity-60 sm:inline">Shift+Enter to send</span>'),Wp=g('<!> <!> <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 items-center justify-between px-1 text-[11px] text-brand-text-muted select-none"><label class="flex cursor-pointer items-center gap-1.5 hover:text-brand-text"><input type="checkbox" class="rounded border-brand-border bg-brand-surface-2 text-brand-blue focus:ring-0 focus:ring-offset-0"/> <span>Press Enter to send</span></label> <div class="flex items-center gap-3"><button type="button" class="rounded bg-brand-surface-3/50 px-2 py-0.5 text-xs text-brand-text-muted transition-colors hover:bg-brand-surface-3 hover:text-brand-text">Collapse ▽</button> <!></div></div>',1),jp=g('<div class="border-t border-brand-border p-4"><!> <!></div>');function Gp(n,e){zr(e,!0);const r=()=>Se(ea,"$isStreaming",m),s=()=>Se(so,"$isReadOnly",m),o=()=>Se($s,"$activeSessionInfo",m),a=()=>Se(Is,"$isConnected",m),i=()=>Se(Vt,"$piState",m),d=()=>Se(Zo,"$composerPrefill",m),[m,x]=ls();let _=Nr(e,"showAttach",3,!0),S=Nr(e,"searchMode",3,!1),R=Nr(e,"searchConfigured",3,!1),P=Nr(e,"searchModels",19,()=>[]),O=Nr(e,"searchModel",15,""),q=W(""),ve=W(!0),Z=W(!1),ae=W("browser"),Je=W(void 0),fe=W(!1),Ce=W(0),he=W(void 0),me=W(sr([])),bt=G(r),It=G(s),et=G(o),At=G(a),se=G(i),Ht=G(()=>{if(S())return null;const L=t(q).match(/^\/([^\s]*)$/);return L?L[1]:null}),tt=G(()=>{if(t(Ht)===null)return[];const L=t(se).skills??[];if(L.length===0)return[];const j=t(Ht).toLowerCase();return(j?L.filter(Ze=>Ze.name.toLowerCase().includes(j)):L.slice()).sort((Ze,ue)=>{const nt=Ze.name.toLowerCase().startsWith(j)?0:1,_e=ue.name.toLowerCase().startsWith(j)?0:1;return nt-_e||Ze.name.localeCompare(ue.name)})});Et(()=>{const L=t(tt).length;if(L===0){Kr(()=>t(fe))&&h(fe,!1);return}Kr(()=>t(fe))||h(fe,!0),Kr(()=>t(Ce))>=L&&h(Ce,0)});function wt(L){h(q,`/${L} `),h(fe,!1),h(Ce,0),queueMicrotask(()=>{if(!t(je))return;t(je).focus();const j=t(q).length;t(je).setSelectionRange(j,j)})}let ct=G(()=>S()?e.disabled||!t(At)||!R():e.disabled||!t(At)||t(It)||!t(et).sessionId),sn=G(()=>t(me).some(L=>L.uploading)),Wt=G(()=>!t(ct)&&!t(sn)&&(t(q).trim().length>0||t(me).length>0)),je=W(void 0);const $t="wherever-draft:";let H=G(()=>$t+(t(et).sessionId??"search")),ze=W(null);Es(()=>{const L=localStorage.getItem("wherever-enter-to-send");L!==null&&h(ve,L==="true")}),Et(()=>{const L=t(H);L!==t(ze)&&Kr(()=>{let j=null;if(typeof localStorage<"u")try{j=localStorage.getItem(L)}catch{}h(q,j??"",!0),h(ze,L,!0)})});let jt=W(0);Et(()=>{const{text:L,bump:j}=d();j===0||j===t(jt)||(h(jt,j,!0),Kr(()=>{h(ze,t(H),!0),h(q,L,!0),t(Z)&&h(Z,!1),queueMicrotask(()=>t(je)?.focus())}))}),Et(()=>{const L=t(q),j=t(H);if(!(j!==t(ze)||typeof localStorage>"u"))try{L.trim().length>0?localStorage.setItem(j,L):localStorage.removeItem(j)}catch{}});function Kt(){t(Z)&&h(Z,!1),t(je)?.focus()}let Mt=!1;Et(()=>{const L=r(),j=Mt&&!L;if(Mt=L,!j)return;const ne=mp({active:Ws("micReopensAfterReply",to()),engine:t(ae)});ne!=="none"&&(t(ct)||Vc().then(()=>{r()||t(ct)||(ne==="reopen-mic"?t(Je)?.startRecordingProgrammatically():Kt())}))});function Xt(){h(ve,!t(ve)),localStorage.setItem("wherever-enter-to-send",String(t(ve)))}Et(()=>{t(je)&&(t(q),t(je).style.height="auto",t(je).style.height=`${t(je).scrollHeight}px`)}),Et(()=>{!t(ct)&&t(je)&&t(je).focus()});async function Lt(L){Jo();const j=L.target;if(!j.files)return;const ne=Array.from(j.files);j.value="";const Ze=t(me).length;h(me,[...t(me),...ne.map(ue=>({name:ue.name,uploading:!0}))],!0);for(let ue=0;ue<ne.length;ue++){const nt=ne[ue],_e=Ze+ue;try{if(!t(et).sessionId)throw new Error("No active session");const Be=await tl(t(et).sessionId,nt);h(me,t(me).map((pt,kt)=>kt===_e?{name:nt.name,path:Be.savedPath,uploading:!1}:pt),!0)}catch(Be){const pt=Be.message||"Failed to upload";console.error("File upload error details:",Be);let kt="";try{const gt=fr(),mt=pr();kt=`${gt}/health${mt?`?token=${encodeURIComponent(mt)}`:""}`}catch{}h(me,t(me).map((gt,mt)=>mt===_e?{name:nt.name,error:pt,url:kt,uploading:!1}:gt),!0)}}}function Rt(L){h(me,t(me).filter((j,ne)=>ne!==L),!0)}function vt(){const L=t(q).trim();if(S()){if(!L||t(ct))return;e.onSubmit?.(L),h(q,""),e.onSend?.();return}if(!L&&t(me).length===0)return;let j=L;if(t(me).length>0){const ue=t(me).filter(nt=>nt.path);if(ue.length>0){const nt=ue.map(_e=>`[Uploaded file: ${_e.path}]`).join(`
83
+ `);j?j+=`
84
+
85
+ `+nt:j=`I have uploaded the following file(s) for you:
86
+ ${nt}`}}if(L.startsWith("/")&&t(me).length===0){const ue=L.toLowerCase();if(ue==="/new"||ue==="/reset"){if(t(et).cwd){mr(t(et).cwd,t(et).model||void 0),h(q,"");return}}else if(ue==="/clear"){Fi(),h(q,"");return}else if(ue==="/leave"||ue==="/exit"){lr(),h(q,"");return}}const ne=gp({streaming:t(bt),connected:t(At),agentPending:t(se).agentPending,readOnly:t(It),hasSession:!!t(et).sessionId});if(ne.action!=="send"){(ne.reason==="disconnected"||ne.reason==="agent-pending")&&Lo(j);return}Lo(j)&&(h(q,""),h(me,[],!0),e.onSend?.())}function Xe(L){if(t(fe)&&t(tt).length>0){if(L.key==="ArrowDown"){L.preventDefault(),h(Ce,(t(Ce)+1)%t(tt).length);return}if(L.key==="ArrowUp"){L.preventDefault(),h(Ce,(t(Ce)-1+t(tt).length)%t(tt).length);return}if(L.key==="Enter"||L.key==="Tab"){L.preventDefault();const j=t(tt)[t(Ce)]??t(tt)[0];j&&wt(j.name);return}if(L.key==="Escape"){L.preventDefault(),h(fe,!1);return}}L.key==="Enter"&&(t(ve)?L.shiftKey||(L.preventDefault(),vt()):L.shiftKey&&(L.preventDefault(),vt()))}var K={focusInput:Kt},vn=jp(),Le=u(vn);{var Ge=L=>{var j=Cp(),ne=u(j);{var Ze=_e=>{var Be=Tp();Ve(2),b(_e,Be)},ue=_e=>{var Be=Ap(),pt=p(rn(Be),2),kt=u(pt,!0);c(pt),$(()=>V(kt,t(se).error)),b(_e,Be)},nt=_e=>{var Be=Rp();Ve(2),b(_e,Be)};k(ne,_e=>{t(se).connecting?_e(Ze):t(se).error?_e(ue,1):t(At)||_e(nt,2)})}c(j),b(L,j)};k(Le,L=>{(!t(At)||t(se).connecting||t(se).error)&&L(Ge)})}var M=p(Le,2);{var A=L=>{var j=Ep(),ne=u(j),Ze=u(ne),ue=u(Ze),nt=u(ue,!0);c(ue);var _e=p(ue,2),Be=u(_e);{var pt=Oe=>{var st=jn();$(()=>V(st,e.placeholder??"Search the web...")),b(Oe,st)},kt=Oe=>{var st=jn("Agent is working, tap to Steer...");b(Oe,st)},gt=Oe=>{var st=jn("Read-only mode");b(Oe,st)},mt=Oe=>{var st=jn("Select a session first...");b(Oe,st)},Gt=Oe=>{var st=jn("Tap to type a message...");b(Oe,st)};k(Be,Oe=>{S()?Oe(pt):t(bt)?Oe(kt,1):t(It)?Oe(gt,2):t(et).sessionId?Oe(Gt,-1):Oe(mt,3)})}c(_e),c(Ze),Ve(2),c(ne),c(j),$(()=>V(nt,S()?"🔍":"💬")),F("click",ne,()=>{h(Z,!1),setTimeout(()=>t(je)?.focus(),50)}),b(L,j)},le=L=>{var j=Wp(),ne=rn(j);{var Ze=T=>{var z=Op();Fn(z,21,()=>t(me),cr,(Q,oe,Pe)=>{var He=Dp(),pe=u(He),Fe=u(pe,!0);c(pe);var xt=p(pe,2);{var ln=N=>{var ie=Ip();b(N,ie)},dt=N=>{var ie=Mp(),Te=u(ie),Ee=u(Te);c(Te);var te=p(Te,2);{var be=ye=>{var St=$p();$(()=>J(St,"href",t(oe).url)),b(ye,St)};k(te,ye=>{t(oe).url&&ye(be)})}c(ie),$(()=>{J(ie,"title",t(oe).error),V(Ee,`⚠️ ${t(oe).error??""}`)}),b(N,ie)},E=N=>{var ie=Lp();b(N,ie)};k(xt,N=>{t(oe).uploading?N(ln):t(oe).error?N(dt,1):N(E,-1)})}var D=p(xt,2);c(He),$(()=>{J(pe,"title",t(oe).name),V(Fe,t(oe).name)}),F("click",D,()=>Rt(Pe)),b(Q,He)}),c(z),b(T,z)};k(ne,T=>{t(me).length>0&&T(Ze)})}var ue=p(ne,2);{var nt=T=>{var z=Np(),Q=p(u(z),2);Fn(Q,21,P,cr,(oe,Pe)=>{var He=Pp(),pe=u(He,!0);c(He);var Fe={};$(()=>{V(pe,t(Pe).label),Fe!==(Fe=t(Pe).value)&&(He.value=(He.__value=t(Pe).value)??"")}),b(oe,He)}),c(Q),c(z),$(()=>Q.disabled=t(ct)),Rs(Q,O),b(T,z)};k(ue,T=>{S()&&P().length>0&&T(nt)})}var _e=p(ue,2),Be=u(_e),pt=u(Be);{var kt=T=>{var z=zp();Fn(z,23,()=>t(tt),Q=>Q.name,(Q,oe,Pe)=>{var He=Up(),pe=u(He),Fe=u(pe),xt=u(Fe);c(Fe);var ln=p(Fe,2);{var dt=E=>{var D=Fp(),N=u(D,!0);c(D),$(()=>V(N,t(oe).description)),b(E,D)};k(ln,E=>{t(oe).description&&E(dt)})}c(pe),c(He),$(()=>{J(pe,"aria-selected",t(Pe)===t(Ce)),Jt(pe,1,`flex w-full flex-col items-start gap-0.5 px-3 py-1.5 text-left text-sm ${t(Pe)===t(Ce)?"bg-brand-surface-3 text-brand-text":"text-brand-text-muted hover:bg-brand-surface-3/60"}`),V(xt,`/${t(oe).name??""}`)}),F("mousedown",pe,E=>{E.preventDefault(),wt(t(oe).name)}),Er("mouseenter",pe,()=>h(Ce,t(Pe),!0)),b(Q,He)}),c(z),b(T,z)};k(pt,T=>{t(fe)&&t(tt).length>0&&T(kt)})}var gt=p(pt,2);Kl(gt),J(gt,"rows",1),ur(gt,T=>h(je,T),()=>t(je)),c(Be);var mt=p(Be,2),Gt=u(mt);{var Oe=T=>{var z=Bp(),Q=rn(z),oe=p(Q,2);ur(oe,Pe=>h(he,Pe),()=>t(he)),$(()=>Q.disabled=t(ct)),F("click",Q,()=>{Ri(),t(he)?.click()}),F("change",oe,Lt),b(T,z)};k(Gt,T=>{_()&&!S()&&T(Oe)})}var st=p(Gt,2),dn=u(st);ur(Sp(dn,{get disabled(){return t(ct)},onSend:vt,get text(){return t(q)},set text(T){h(q,T,!0)},get activeEngine(){return t(ae)},set activeEngine(T){h(ae,T,!0)}}),T=>h(Je,T,!0),()=>t(Je)),c(st);var mn=p(st,2),kn=u(mn);{var on=T=>{var z=jn();$(()=>V(z,e.submitLabel??"Search")),b(T,z)},In=T=>{var z=jn("Steer");b(T,z)},an=T=>{var z=jn("Send");b(T,z)};k(kn,T=>{S()?T(on):t(bt)?T(In,1):T(an,-1)})}c(mn),c(mt),c(_e);var Vn=p(_e,2),Kn=u(Vn),Ln=u(Kn);rt(Ln),Ve(2),c(Kn);var zn=p(Kn,2),tr=u(zn),Bn=p(tr,2);{var C=T=>{var z=Hp();b(T,z)};k(Bn,T=>{t(ve)||T(C)})}c(zn),c(Vn),$(()=>{gt.disabled=t(ct),J(gt,"placeholder",S()?e.placeholder??"Search the web...":t(At)?t(bt)?"Agent is working, Steer to interrupt...":t(It)?"Read-only mode":t(et).sessionId?"Type a message...":"Select a session first...":t(se).connecting?"Reconnecting to remote server...":"Disconnected - cannot send"),mn.disabled=!t(Wt),J(mn,"title",!S()&&t(bt)?"Steer the agent now (injected at the next step, before the next model call)":void 0),ni(Ln,t(ve))}),Er("submit",_e,T=>{T.preventDefault(),vt()}),F("keydown",gt,Xe),dr(gt,()=>t(q),T=>h(q,T)),F("change",Ln,Xt),F("click",tr,()=>h(Z,!0)),b(L,j)};k(M,L=>{t(Z)?L(A):L(le,-1)})}c(vn),b(n,vn);var xe=Br(K);return x(),xe}Qr(["click","mousedown","keydown","change"]);var qp=g('<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>'),Vp=g('<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>'),Kp=g('<span class="ml-1 font-semibold text-emerald-400">(Git repo)</span>'),Yp=g('<span class="mt-1 block text-[10px] font-medium text-yellow-400">📁 Folder already exists. <!></span>'),Xp=g("<option> </option>"),Zp=g('<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>'),Qp=g('<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"/>'),Jp=g('<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>'),eh=g('<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>'),th=g('<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>'),nh=g('<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>'),rh=g('<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>'),sh=g('<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>'),oh=g('<div class="p-4 text-center text-sm text-brand-text-muted"> </div>'),ah=g('<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>'),ih=g('<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>'),lh=g('<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>'),ch=g('<span class="flex-shrink-0 text-brand-text-muted" title="Forked from the session above" aria-label="Forked session">↳</span>'),dh=g('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-emerald-500"></span>'),uh=g('<span class="h-2 w-2 flex-shrink-0 rounded-full bg-brand-surface-3"></span>'),fh=g('<span class="rounded bg-brand-surface-3 px-1.5 py-0.5 text-xs text-brand-text"> </span>'),ph=g('<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>'),hh=g('<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>'),bh=g('<div class="flex-shrink-0"><!></div>'),vh=g('<div><!> <a class="flex min-w-0 flex-1 items-center gap-2 text-left no-underline"><!> <div class="min-w-0 flex-1"><div class="truncate text-xs text-brand-text"> </div> <div class="text-xs text-brand-text-muted"> </div></div> <!></a> <!></div>'),gh=g('<div class="px-3 pb-2"><!> <!></div>'),mh=g('<div class="border-b border-brand-border/50"><button class="flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-brand-surface-3/50"><span>▶</span> <div class="min-w-0 flex-1"><div class="truncate text-sm font-medium text-brand-text"> </div> <div class="truncate text-[10px] text-brand-text-muted"> </div></div> <span class="text-xs text-brand-text-muted"> </span></button> <!></div>'),xh=g("<option> </option>"),_h=g('<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>'),yh=g('<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"/>'),wh=g('<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>'),kh=g('<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>'),Sh=g('<span class="ml-1 text-[10px] text-brand-text-muted">(already a Git repo)</span>'),Th=g('<span class="ml-1 text-[10px] font-medium text-yellow-500">(folder not empty)</span>'),Ah=g('<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>'),Rh=g('<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>'),Ch=g('<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/65 p-4" role="dialog" aria-modal="true"><div class="w-80 rounded-lg border border-brand-border bg-brand-surface-2 p-5 text-brand-text"><h3 class="mb-2 text-sm font-bold text-brand-text">Folder Already Exists</h3> <p class="mb-3 text-xs text-brand-text-muted">The folder <span class="font-mono text-[11px] break-all text-brand-text"> </span> already exists. Do you want to initialize a Git repository in it?</p> <div class="mb-4 flex flex-col gap-3"><div class="flex items-center gap-1.5"><input id="sidebar-modal-git-init" type="checkbox" class="h-3.5 w-3.5 rounded border-brand-border bg-brand-surface-3 text-brand-blue focus:ring-brand-blue disabled:opacity-50"/> <label for="sidebar-modal-git-init" class="cursor-pointer text-xs text-brand-text select-none disabled:opacity-50">Initialize Git repository <!></label></div> <!></div> <div class="flex justify-end gap-2"><button type="button" class="rounded bg-brand-surface-3 px-3 py-1.5 text-xs text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button type="button" class="rounded bg-gradient-to-r from-brand-cyan to-brand-blue px-3 py-1.5 text-xs font-semibold text-brand-text transition-all hover:opacity-90">Confirm & Create</button></div></div></div>'),Eh=g('<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 Qa(n,e){zr(e,!0);const r=()=>Se(ms,"$readOnlySessionFolders",S),s=()=>Se(as,"$sessionFolders",S),o=()=>Se($s,"$activeSessionInfo",S),a=()=>Se(Is,"$isConnected",S),i=()=>Se(oo,"$isLoadingSession",S),d=()=>Se(na,"$isResyncing",S),m=()=>Se(is,"$availableModels",S),x=()=>Se(jo,"$gitInitDefaultStore",S),_=()=>Se(ta,"$sessionError",S),[S,R]=ls(),P=[];let O=Nr(e,"readOnly",3,!1),q=G(()=>O()?r().folders:s().folders),ve=G(()=>O()?r().loading:s().loading);function Z(){O()?ai():ks()}let ae=G(()=>o().sessionFile),Je=G(a),fe=G(i),Ce=G(d),he=G(()=>m().models),me=sr({}),bt=W(sr({})),It=W(null),et=W(null),At=W(""),se=W(sr([]));Et(()=>{t(Je)&&(Z(),O()||(kc(),Tc()))});function Ht(C,T,z){if(!z)return!0;const Q=z.toLowerCase();return(C.name||"").toLowerCase().includes(Q)||C.firstMessage.toLowerCase().includes(Q)||T.toLowerCase().includes(Q)}Et(()=>{const C=t(At),T=t(q);C?h(se,T.map(z=>({...z,sessions:z.sessions.filter(Q=>Ht(Q,z.name,C))})).filter(z=>z.sessions.length>0),!0):(h(se,T,!0),h(bt,{},!0))});function tt(C){return t(At)?t(bt)[C]!==void 0?t(bt)[C]:!0:!!me[C]}function wt(C){t(At)?t(bt)[C]=!tt(C):me[C]=!tt(C)}async function ct(C){try{t(ae)===C&&(typeof window<"u"&&(window.location.hash=""),lr()),await Oo(C),t(It)===C&&h(It,null),ks()}catch(T){console.error("Failed to delete session:",T)}}async function sn(C){try{const T=C.sessions.map(z=>z.path);t(ae)&&T.includes(t(ae))&&(typeof window<"u"&&(window.location.hash=""),lr()),await Promise.all(C.sessions.map(z=>Oo(z.path))),t(et)===C.path&&h(et,null),ks()}catch(T){console.error("Failed to delete all sessions of folder:",T)}}function Wt(C){const T=new Map;for(const pe of C)T.set(pe.path,pe);const z=new Map,Q=[];for(const pe of C){const Fe=pe.parentSessionPath;Fe&&T.has(Fe)&&Fe!==pe.path?(z.has(Fe)||z.set(Fe,[]),z.get(Fe).push(pe)):Q.push(pe)}const oe=[],Pe=new Set,He=(pe,Fe)=>{if(!Pe.has(pe.path)){Pe.add(pe.path),oe.push({session:pe,depth:Fe});for(const xt of z.get(pe.path)??[])He(xt,Fe+1)}};for(const pe of Q)He(pe,0);for(const pe of C)Pe.has(pe.path)||oe.push({session:pe,depth:0});return oe}function je(C){t(ae)===C&&!t(fe)&&!t(Ce)||(Xr(),ro(C))}let $t=W(!1),H=W(""),ze=W(sr([])),jt=W(!1),Kt=W(null),Mt=W(null),Xt="",Lt=W(""),Rt=W(!1),vt=W(null),Xe=W(!0),K=W("private"),vn=W(!1),Le=G(x);Et(()=>{t(vt)===null&&h(Rt,t(Le),!0)});let Ge=W(sr({exists:null,isGit:!1,resolvedPath:"",matchingRule:null})),M=G(()=>t(Ge).exists!==!0&&t(Ge).matchingRule&&t(Xe)),A=null;async function le(C,T=!1){if(A&&clearTimeout(A),C===Xt&&!T)return;if(Xt=C,!C.trim()){h(Ge,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0);const Q=async()=>{const oe=await js("");h(ze,oe||[],!0)};T?await Q():A=setTimeout(Q,300);return}const z=async()=>{const[Q,oe]=await Promise.all([di(C),js(C)]);h(ze,oe||[],!0),Q?(h(Ge,{exists:Q.exists,isGit:Q.isGit,resolvedPath:Q.resolvedPath,matchingRule:Q.matchingRule||null},!0),Q.exists||(h(Rt,t(vt)!==null?t(vt):t(Le),!0),h(Xe,!0),Q.matchingRule&&h(K,Q.matchingRule.visibility,!0))):h(Ge,{exists:null,isGit:!1,resolvedPath:"",matchingRule:null},!0)};T?await z():A=setTimeout(z,300)}Et(()=>{const C=t(H);le(C,!1)}),Et(()=>{if(t(he).length>0&&!t(Lt)){const C=t(he).find(T=>T.isDefault);C?h(Lt,`${C.provider}:${C.modelId}`):h(Lt,`${t(he)[0].provider}:${t(he)[0].modelId}`)}});function xe(){if(t(H).trim())if(t(Ge).exists===!0)h(Rt,!1),h(Xe,!1),t(Ge).matchingRule&&h(K,t(Ge).matchingRule.visibility,!0),h(vn,!0);else{Xr();const C=t(H).trim(),T=t(Lt)||void 0,z=t(Rt),Q=t(Ge).matchingRule?t(Xe):void 0,oe=t(Ge).matchingRule?t(K):void 0;h(H,""),h($t,!1),t(ae)?(lr(),setTimeout(()=>{mr(C,T,z,Q,oe)},100)):mr(C,T,z,Q,oe)}}function L(){h(vn,!1),Xr();const C=t(H).trim(),T=t(Lt)||void 0,z=t(Rt),Q=t(Ge).matchingRule?t(Xe):void 0,oe=t(Ge).matchingRule?t(K):void 0;h(H,""),h($t,!1),t(ae)?(lr(),setTimeout(()=>{mr(C,T,z,Q,oe)},100)):mr(C,T,z,Q,oe)}let j=W(sr({open:!1,folderPath:"",selected:""}));function ne(C){const T=t(he).find(z=>z.isDefault);h(j,{open:!0,folderPath:C,selected:T?`${T.provider}:${T.modelId}`:""},!0)}function Ze(){t(j).open=!1}function ue(){if(!t(j).open)return;Xr();const C=t(j).folderPath,T=t(j).selected||void 0;Ze(),t(ae)?(lr(),setTimeout(()=>{mr(C,T)},100)):mr(C,T)}function nt(C){const T=Date.now()-new Date(C).getTime(),z=Math.floor(T/6e4);if(z<1)return"just now";if(z<60)return`${z}m ago`;const Q=Math.floor(z/60);return Q<24?`${Q}h ago`:`${Math.floor(Q/24)}d ago`}function _e(C,T=40){return C.length>T?C.slice(0,T)+"...":C}var Be=Eh(),pt=rn(Be),kt=u(pt),gt=u(kt),mt=u(gt);rt(mt);var Gt=p(mt,2),Oe=u(Gt);c(Gt),c(gt),c(kt);var st=p(kt,2),dn=u(st);{var mn=C=>{var T=rh(),z=u(T),Q=u(z),oe=u(Q,!0);c(Q),c(z);var Pe=p(z,2);{var He=pe=>{var Fe=nh(),xt=u(Fe),ln=p(u(xt),2),dt=u(ln);rt(dt),ur(dt,Y=>h(Kt,Y),()=>t(Kt));var E=p(dt,2);{var D=Y=>{var ce=Vp();Fn(ce,21,()=>t(ze),cr,(we,qe)=>{var We=qp(),Ke=u(We,!0);c(We),$(()=>V(Ke,t(qe))),F("click",We,()=>{h(H,t(qe),!0),le(t(qe),!0),t(Kt)?.focus()}),b(we,We)}),c(ce),b(Y,ce)};k(E,Y=>{t(jt)&&t(ze).length>0&&Y(D)})}c(ln),ur(ln,Y=>h(Mt,Y),()=>t(Mt));var N=p(ln,2);{var ie=Y=>{var ce=Yp(),we=p(u(ce));{var qe=We=>{var Ke=Kp();b(We,Ke)};k(we,We=>{t(Ge).isGit&&We(qe)})}c(ce),b(Y,ce)};k(N,Y=>{t(Ge).exists===!0&&Y(ie)})}c(xt);var Te=p(xt,2),Ee=p(u(Te),2);{var te=Y=>{var ce=Zp();Fn(ce,21,()=>t(he),cr,(we,qe)=>{var We=Xp(),Ke=u(We);c(We);var _t={};$(()=>{V(Ke,`${t(qe).label??""}${t(qe).isDefault?" (default)":""}`),_t!==(_t=`${t(qe).provider}:${t(qe).modelId}`)&&(We.value=We.__value=`${t(qe).provider}:${t(qe).modelId}`)}),b(we,We)}),c(ce),Rs(ce,()=>t(Lt),we=>h(Lt,we)),b(Y,ce)},be=Y=>{var ce=Qp();rt(ce),dr(ce,()=>t(Lt),we=>h(Lt,we)),b(Y,ce)};k(Ee,Y=>{t(he).length>0?Y(te):Y(be,-1)})}c(Te);var ye=p(Te,2);{var St=Y=>{var ce=eh(),we=u(ce),qe=u(we);rt(qe);var We=p(qe,2),Ke=u(We);c(We),c(we);var _t=p(we,2);{var zt=_n=>{var fn=Jp(),Ae=p(u(fn),2),at=u(Ae);rt(at),at.value=at.__value="private",Ve(),c(Ae);var Yt=p(Ae,2),Yn=u(Yt);rt(Yn),Yn.value=Yn.__value="public",Ve(),c(Yt),c(fn),Ur(P,[],at,()=>t(K),nr=>h(K,nr)),Ur(P,[],Yn,()=>t(K),nr=>h(K,nr)),b(_n,fn)};k(_t,_n=>{t(Xe)&&_n(zt)})}c(ce),$(()=>V(Ke,`Create remote ${t(Ge).matchingRule.provider??""} repository`)),Nn(qe,()=>t(Xe),_n=>h(Xe,_n)),b(Y,ce)};k(ye,Y=>{t(Ge).exists!==!0&&t(Ge).matchingRule&&Y(St)})}var xn=p(ye,2);{var un=Y=>{var ce=th(),we=u(ce);rt(we),Ve(2),c(ce),F("change",we,qe=>{h(vt,qe.currentTarget.checked,!0)}),Nn(we,()=>t(Rt),qe=>h(Rt,qe)),b(Y,ce)};k(xn,Y=>{t(Ge).exists!==!0&&(!t(Ge).matchingRule||!t(Xe))&&Y(un)})}var gn=p(xn,2);c(Fe),$(Y=>{Jt(dt,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(M)?"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"}`),gn.disabled=Y},[()=>!t(H).trim()]),Er("submit",Fe,Y=>{Y.preventDefault(),xe()}),Er("focus",dt,()=>{h(jt,!0),le(t(H),!0)}),Er("blur",dt,Y=>{t(Mt)&&t(Mt).contains(Y.relatedTarget)||h(jt,!1)}),F("keydown",dt,Y=>{Y.key==="Escape"&&h(jt,!1)}),dr(dt,()=>t(H),Y=>h(H,Y)),b(pe,Fe)};k(Pe,pe=>{t($t)&&pe(He)})}c(T),$(()=>V(oe,t($t)?"▼ Close Create Session":"✚ Create New Session")),F("click",z,()=>h($t,!t($t))),b(C,T)};k(dn,C=>{O()||C(mn)})}var kn=p(dn,2);{var on=C=>{var T=sh();b(C,T)},In=C=>{var T=oh(),z=u(T,!0);c(T),$(()=>V(z,t(At)?"No sessions match your filter":"No sessions found")),b(C,T)},an=C=>{var T=Tr(),z=rn(T);Fn(z,17,()=>t(se),Q=>Q.path,(Q,oe)=>{var Pe=mh(),He=u(Pe),pe=u(He),Fe=p(pe,2),xt=u(Fe),ln=u(xt,!0);c(xt);var dt=p(xt,2),E=u(dt,!0);c(dt),c(Fe);var D=p(Fe,2),N=u(D,!0);c(D),c(He);var ie=p(He,2);{var Te=te=>{var be=gh(),ye=u(be);{var St=un=>{var gn=lh(),Y=u(gn),ce=p(Y,2),we=u(ce);{var qe=Ke=>{var _t=ah(),zt=u(_t),_n=p(zt,2);c(_t),F("click",zt,fn=>{fn.stopPropagation(),sn(t(oe))}),F("click",_n,fn=>{fn.stopPropagation(),h(et,null)}),b(Ke,_t)},We=Ke=>{var _t=ih();F("click",_t,zt=>{zt.stopPropagation(),h(et,t(oe).path,!0)}),b(Ke,_t)};k(we,Ke=>{t(et)===t(oe).path?Ke(qe):Ke(We,-1)})}c(ce),c(gn),F("click",Y,()=>ne(t(oe).path)),b(un,gn)};k(ye,un=>{O()||un(St)})}var xn=p(ye,2);Fn(xn,17,()=>Wt(t(oe).sessions),({session:un,depth:gn})=>un.path,(un,gn)=>{let Y=()=>t(gn).session,ce=()=>t(gn).depth;var we=vh(),qe=u(we);{var We=Ue=>{var Ct=ch();b(Ue,Ct)};k(qe,Ue=>{ce()>0&&Ue(We)})}var Ke=p(qe,2),_t=u(Ke);{var zt=Ue=>{var Ct=dh();b(Ue,Ct)},_n=Ue=>{var Ct=uh();b(Ue,Ct)};k(_t,Ue=>{Y().isActive?Ue(zt):Ue(_n,-1)})}var fn=p(_t,2),Ae=u(fn),at=u(Ae,!0);c(Ae);var Yt=p(Ae,2),Yn=u(Yt);c(Yt),c(fn);var nr=p(fn,2);{var $r=Ue=>{var Ct=fh(),Hn=u(Ct,!0);c(Ct),$(()=>V(Hn,Y().clientCount)),b(Ue,Ct)};k(nr,Ue=>{Y().clientCount>0&&Ue($r)})}c(Ke);var xr=p(Ke,2);{var Mr=Ue=>{var Ct=bh(),Hn=u(Ct);{var _r=rr=>{var U=ph(),f=u(U),l=p(f,2);c(U),F("click",f,v=>{v.stopPropagation(),ct(Y().path)}),F("click",l,v=>{v.stopPropagation(),h(It,null)}),b(rr,U)},Lr=rr=>{var U=hh();F("click",U,f=>{f.stopPropagation(),h(It,Y().path,!0)}),b(rr,U)};k(Hn,rr=>{t(It)===Y().path?rr(_r):rr(Lr,-1)})}c(Ct),b(Ue,Ct)};k(xr,Ue=>{O()||Ue(Mr)})}c(we),$((Ue,Ct,Hn)=>{sc(we,ce()>0?`margin-left: ${ce()*.85}rem`:""),Jt(we,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 ${ce()>0?"border-l border-brand-border/60 pl-2":""} ${t(ae)===Y().path?"bg-brand-surface-3":""}`),J(Ke,"href",`#${Ue??""}`),V(at,Ct),V(Yn,`${Hn??""} · ${Y().messageCount??""}
87
+ msgs`)},[()=>encodeURIComponent(Y().id),()=>Y().name||_e(Y().firstMessage)||"Empty session",()=>nt(Y().modified)]),F("click",Ke,Ue=>{Ue.button===0&&!Ue.ctrlKey&&!Ue.metaKey&&!Ue.altKey&&!Ue.shiftKey&&(Ue.preventDefault(),je(Y().path))}),b(un,we)}),c(be),b(te,be)},Ee=G(()=>tt(t(oe).path));k(ie,te=>{t(Ee)&&te(Te)})}c(Pe),$(te=>{Jt(pe,1,`text-xs text-brand-text-muted transition-transform ${te??""}`),V(ln,t(oe).name),V(E,t(oe).path),V(N,t(oe).sessions.length)},[()=>tt(t(oe).path)?"rotate-90":""]),F("click",He,()=>wt(t(oe).path)),b(Q,Pe)}),b(C,T)};k(kn,C=>{t(ve)&&t(se).length===0?C(on):t(se).length===0?C(In,1):C(an,-1)})}c(st),c(pt);var Vn=p(pt,2);{var Kn=C=>{var T=wh(),z=u(T),Q=p(u(z),2),oe=p(u(Q),2),Pe=u(oe,!0);c(oe),c(Q);var He=p(Q,2),pe=p(u(He),2);{var Fe=D=>{var N=_h();Fn(N,21,()=>t(he),cr,(ie,Te)=>{var Ee=xh(),te=u(Ee);c(Ee);var be={};$(()=>{V(te,`${t(Te).label??""}${t(Te).isDefault?" (default)":""}`),be!==(be=`${t(Te).provider}:${t(Te).modelId}`)&&(Ee.value=Ee.__value=`${t(Te).provider}:${t(Te).modelId}`)}),b(ie,Ee)}),c(N),Rs(N,()=>t(j).selected,ie=>t(j).selected=ie),b(D,N)},xt=D=>{var N=yh();rt(N),dr(N,()=>t(j).selected,ie=>t(j).selected=ie),b(D,N)};k(pe,D=>{t(he).length>0?D(Fe):D(xt,-1)})}c(He);var ln=p(He,2),dt=u(ln),E=p(dt,2);c(ln),c(z),c(T),$(()=>V(Pe,t(j).folderPath)),F("click",T,Ze),F("click",z,D=>D.stopPropagation()),F("click",dt,Ze),F("click",E,ue),b(C,T)};k(Vn,C=>{t(j).open&&C(Kn)})}var Ln=p(Vn,2);{var zn=C=>{var T=kh(),z=u(T),Q=u(z,!0);c(z);var oe=p(z,2);c(T),$(()=>V(Q,_())),F("click",oe,()=>Xr()),b(C,T)};k(Ln,C=>{_()&&C(zn)})}var tr=p(Ln,2);{var Bn=C=>{var T=Ch(),z=u(T),Q=p(u(z),2),oe=p(u(Q)),Pe=u(oe,!0);c(oe),Ve(),c(Q);var He=p(Q,2),pe=u(He),Fe=u(pe);rt(Fe);var xt=p(Fe,2),ln=p(u(xt));{var dt=te=>{var be=Sh();b(te,be)},E=te=>{var be=Th();b(te,be)};k(ln,te=>{t(Ge).isGit?te(dt):te(E,-1)})}c(xt),c(pe);var D=p(pe,2);{var N=te=>{var be=Rh(),ye=u(be),St=u(ye);rt(St);var xn=p(St,2),un=u(xn);c(xn),c(ye);var gn=p(ye,2);{var Y=ce=>{var we=Ah(),qe=p(u(we),2),We=u(qe);rt(We),We.value=We.__value="private",Ve(),c(qe);var Ke=p(qe,2),_t=u(Ke);rt(_t),_t.value=_t.__value="public",Ve(),c(Ke),c(we),Ur(P,[],We,()=>t(K),zt=>h(K,zt)),Ur(P,[],_t,()=>t(K),zt=>h(K,zt)),b(ce,we)};k(gn,ce=>{t(Xe)&&ce(Y)})}c(be),$(()=>V(un,`Create remote ${t(Ge).matchingRule.provider??""} repository`)),Nn(St,()=>t(Xe),ce=>h(Xe,ce)),b(te,be)};k(D,te=>{t(Ge).matchingRule&&te(N)})}c(He);var ie=p(He,2),Te=u(ie),Ee=p(Te,2);c(ie),c(z),c(T),$(()=>{V(Pe,t(H)),Fe.disabled=t(Ge).isGit}),Nn(Fe,()=>t(Rt),te=>h(Rt,te)),F("click",Te,()=>h(vn,!1)),F("click",Ee,L),b(C,T)};k(tr,C=>{t(vn)&&C(Bn)})}$(()=>{Xl(mt,t(At)),Jt(Oe,1,tc(t(ve)?"animate-spin":""))}),F("input",mt,C=>h(At,C.currentTarget.value,!0)),F("click",Gt,()=>Z()),b(n,Be),Br(),R()}Qr(["input","click","keydown","change"]);var Ih=g(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-brand-dark/60"><div class="mx-4 w-full max-w-md rounded-xl border border-brand-border bg-brand-surface-2 p-6 shadow-xl"><h2 class="mb-2 text-lg font-bold text-brand-text">Sudo password</h2> <p class="mb-3 text-sm text-brand-text-muted">This command needs your sudo password to run. It is used once and never
88
+ stored.</p> <pre class="mb-4 overflow-x-auto rounded-lg bg-brand-surface-3 px-3 py-2 font-mono text-xs text-brand-text"> </pre> <input type="password" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" placeholder="Password" class="mb-4 w-full rounded-lg border border-brand-border bg-brand-surface-3 px-3 py-2.5 text-sm text-brand-text outline-none focus:border-brand-blue"/> <div class="flex gap-3"><button class="flex-1 rounded-lg bg-brand-surface-3 px-4 py-2.5 text-sm text-brand-text transition-colors hover:bg-brand-surface-2">Cancel</button> <button class="flex-1 rounded-lg bg-brand-blue px-4 py-2.5 text-sm text-brand-text transition-colors hover:opacity-90">Run</button></div></div></div>`);function $h(n,e){zr(e,!0);const r=()=>Se(Yi,"$sudoPrompt",s),[s,o]=ls();let a=G(r),i=W(""),d=W(null),m=W(null);Et(()=>{const q=t(a)?.promptId??null;q!==t(m)&&(h(m,q,!0),h(i,""),q&&queueMicrotask(()=>t(d)?.focus()))});function x(){t(a)&&(Bi(t(i)),h(i,""))}function _(){Hi(),h(i,"")}function S(q){q.key==="Enter"?(q.preventDefault(),x()):q.key==="Escape"&&(q.preventDefault(),_())}var R=Tr(),P=rn(R);{var O=q=>{var ve=Ih(),Z=u(ve),ae=p(u(Z),4),Je=u(ae,!0);c(ae);var fe=p(ae,2);rt(fe),ur(fe,bt=>h(d,bt),()=>t(d));var Ce=p(fe,2),he=u(Ce),me=p(he,2);c(Ce),c(Z),c(ve),$(()=>V(Je,t(a).command)),F("keydown",fe,S),dr(fe,()=>t(i),bt=>h(i,bt)),F("click",he,_),F("click",me,x),b(q,ve)};k(P,q=>{t(a)&&q(O)})}b(n,R),Br(),o()}Qr(["keydown","click"]);function Mh(n){return n.loading||n.resyncing||n.hasSessionHash}function Lh(n){return n.connected&&n.searchConfigured&&!n.hasSession&&!Mh(n)}var Dh=g('<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>'),Oh=g('<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),Ph=g('<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),Nh=g('<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>'),Fh=g('<span class="text-brand-text-muted/70"> </span>'),Uh=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),zh=g('<div class="truncate text-xs text-brand-text-muted"> </div>'),Bh=g('<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>'),Hh=g('<div class="mt-2 text-xs text-rose-400"> </div>'),Wh=g('<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>'),jh=g('<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>'),Gh=g('<div class="border-b border-brand-border p-4"><div class="flex items-center gap-2"><div></div> <span> </span> <span class="ml-auto font-mono text-xs text-brand-text-muted"> <!></span></div> <!> <!></div> <div class="border-b border-brand-border/50 px-2 py-1.5"><!></div> <div class="flex-1 overflow-hidden"><!></div>',1),qh=g('<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>'),Vh=g('<span class="text-sm text-brand-text-muted">Search the web below, or pick a session from the sidebar</span>'),Kh=g('<span class="text-sm text-brand-text-muted">Select a session from sidebar</span>'),Yh=g('<span class="text-sm text-brand-text-muted">Not connected</span>'),Xh=g('<div class="flex min-w-0 items-center gap-2"><!></div>'),Zh=g('<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>'),Qh=g("<option> </option>"),Jh=g('<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>'),eb=g('<span class="truncate text-brand-text-muted"> </span>'),tb=g('<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>'),nb=g('<div class="flex min-w-0 flex-1 items-center gap-3"><!> <!></div>'),rb=g('<span class="flex-shrink-0 rounded bg-yellow-500/20 px-2 py-1 text-xs text-yellow-400">Read-only</span>'),sb=g('<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>'),ob=g('<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>'),ab=g('<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>'),ib=g('<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>'),lb=g('<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>'),cb=g('<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>'),db=g('<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>'),ub=g('<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>'),fb=g('<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>'),pb=g("<!> <!>",1),hb=g('<button type="button" class="fixed inset-0 z-10 bg-brand-dark/50 md:hidden" aria-label="Close sidebar"></button>'),bb=g('<!> <!> <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 Sb(n,e){zr(e,!0);const r=()=>Se(Is,"$isConnected",Z),s=()=>Se(na,"$isResyncing",Z),o=()=>Se(Zi,"$isAgentPending",Z),a=()=>Se(oo,"$isLoadingSession",Z),i=()=>Se(qi,"$isInterrupted",Z),d=()=>Se(ta,"$sessionError",Z),m=()=>Se(Ki,"$sessionNotice",Z),x=()=>Se(Gi,"$folderConflict",Z),_=()=>Se(so,"$isReadOnly",Z),S=()=>Se($s,"$activeSessionInfo",Z),R=()=>Se(Vt,"$piState",Z),P=()=>Se(is,"$availableModels",Z),O=()=>Se(Xi,"$isCreatingSession",Z),q=()=>Se(Go,"$searchFolderStore",Z),ve=()=>Se(ci,"$searchDefaultModelStore",Z),[Z,ae]=ls();let Je=W(!1),fe=W("main"),Ce=W(!1),he;Es(()=>{setTimeout(()=>Yr(),200);const E=()=>{if(t(se)){const Ee=window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"";Ee&&Ee!==t(Mt)?ro(Ee):!Ee&&t(Mt)&&lr()}};window.addEventListener("hashchange",E);let D=null;const N=8e3,ie=()=>{if(document.visibilityState==="hidden"){if(Ci())return;D&&clearTimeout(D),D=setTimeout(()=>{D=null,document.visibilityState==="hidden"&&t(se)&&Ai()},N)}else Jo(),D&&(clearTimeout(D),D=null),t(se)||(Mo()?$o():Yr())},Te=Ee=>{D&&(clearTimeout(D),D=null),document.visibilityState!=="hidden"&&!t(se)&&(Mo()?$o():Yr())};return document.addEventListener("visibilitychange",ie),window.addEventListener("pageshow",Te),()=>{window.removeEventListener("hashchange",E),document.removeEventListener("visibilitychange",ie),window.removeEventListener("pageshow",Te),D&&clearTimeout(D)}});function me(){Yr()}function bt(){lr(),Cs()}function It(){Cs(),setTimeout(()=>Yr(),100)}function et(){ks()}function At(){typeof window<"u"&&(window.location.hash=""),lr(),h(Je,!1)}let se=G(r),Ht=G(s),tt=G(o),wt=G(a),ct=G(i),sn=G(d),Wt=G(m),je=G(x),$t=G(_),H=G(S),ze=G(R),jt=G(()=>P().models),Kt=W(!1),Mt=G(()=>t(H).sessionId);Et(()=>{typeof window<"u"&&t(se)&&(t(Mt)?(window.location.hash=encodeURIComponent(t(Mt)),h(Kt,!0)):t(Kt)&&(h(Kt,!1),window.location.hash&&(window.location.hash="")))});let Xt=null;Et(()=>{if(!t(se)||typeof window>"u"||!window.location.hash)return;const E=decodeURIComponent(window.location.hash.slice(1));E&&(t(Mt)===E||t(wt)||t(Ht)||Xt||(Xt=setTimeout(()=>{Xt=null,!(t(Mt)===E||t(wt)||t(Ht))&&Li(E)},300)))}),Et(()=>{t(se)||h(Kt,!1)}),Et(()=>{(t(Mt)||t(wt)||t(Ht))&&h(Je,!1)});let Lt=G(O),Rt=G(q),vt=W(void 0),Xe=G(()=>Lh({connected:t(se),searchConfigured:!!t(Rt),hasSession:!!t(H).sessionFile,loading:t(wt),resyncing:t(Ht),hasSessionHash:typeof window<"u"&&!!window.location.hash})),K=G(()=>t(jt).map(E=>({value:`${E.provider}:${E.modelId}`,label:`${E.label}${E.isDefault?" (default)":""}`}))),vn=G(ve),Le=W("");Et(()=>{if(t(K).length===0||t(K).some(ie=>ie.value===t(Le)))return;const D=t(K).find(ie=>ie.value===t(vn)),N=t(jt).find(ie=>ie.isDefault);h(Le,D?D.value:N?`${N.provider}:${N.modelId}`:t(K)[0].value,!0)});let Ge=W(!1);Et(()=>{t(Xe)&&!t(Ge)&&t(vt)&&(h(Ge,!0),t(vt).focusInput())});function M(){typeof window<"u"&&window.location.hash&&(window.location.hash=""),lr(),t(vt)?.focusInput()}var A=bb(),le=rn(A);uc(le,{title:"Wherever",description:"Create & maintain apps from wherever"});var xe=p(le,2);{var L=E=>{var D=Dh();b(E,D)};k(xe,E=>{t(Lt)&&E(L)})}var j=p(xe,2),ne=u(j),Ze=u(ne),ue=u(Ze),nt=u(ue);{var _e=E=>{var D=Oh(),N=p(rn(D),2);F("click",N,()=>h(Ce,!1)),b(E,D)},Be=E=>{var D=Ph(),N=rn(D),ie=u(N);Ve(2),c(N);var Te=p(N,2),Ee=u(Te),te=p(Ee,2);c(Te),$(be=>J(ie,"src",be),[()=>os("/logo.svg")]),F("click",N,At),F("click",Ee,()=>h(Ce,!0)),F("click",te,()=>h(Je,!1)),b(E,D)};k(nt,E=>{t(Ce)?E(_e):E(Be,-1)})}c(ue),c(Ze);var pt=p(Ze,2);{var kt=E=>{var D=Nh(),N=u(D);{let ye=G(()=>(t(ze).connected,"localhost"));Qc(N,{get host(){return t(ye)},port:31415,token:"",onConnected:me})}var ie=p(N,2),Te=p(u(ie),2),Ee=u(Te),te=p(Ee,2),be=p(te,2);c(Te),c(ie),c(D),F("click",Ee,et),F("click",te,It),F("click",be,bt),b(E,D)},gt=E=>{var D=Gh(),N=rn(D),ie=u(N),Te=u(ie),Ee=p(Te,2),te=u(Ee,!0);c(Ee);var be=p(Ee,2),ye=u(be),St=p(ye);{var xn=Ae=>{var at=Fh(),Yt=u(at);c(at),$(()=>V(Yt,` / srv ${t(ze).serverVersion??""}`)),b(Ae,at)};k(St,Ae=>{t(ze).serverVersion&&Ae(xn)})}c(be),c(ie);var un=p(ie,2);{var gn=Ae=>{var at=Bh(),Yt=u(at);{var Yn=Ue=>{var Ct=Uh(),Hn=u(Ct);c(Ct),$(_r=>{J(Ct,"title",t(H).cwd),V(Hn,`📁 ${_r??""}`)},[()=>t(H).cwd.split("/").pop()||t(H).cwd]),b(Ue,Ct)};k(Yt,Ue=>{t(H).cwd&&Ue(Yn)})}var nr=p(Yt,2);{var $r=Ue=>{var Ct=zh(),Hn=u(Ct);c(Ct),$(()=>{J(Ct,"title",t(H).model),V(Hn,`🤖 ${t(H).model??""}`)}),b(Ue,Ct)};k(nr,Ue=>{t(H).model&&Ue($r)})}var xr=p(nr,2),Mr=u(xr);c(xr),c(at),F("click",Mr,At),b(Ae,at)};k(un,Ae=>{t(H).sessionFile&&Ae(gn)})}var Y=p(un,2);{var ce=Ae=>{var at=Hh(),Yt=u(at,!0);c(at),$(()=>V(Yt,t(ze).error)),b(Ae,at)};k(Y,Ae=>{t(ze).error&&!t(se)&&Ae(ce)})}c(N);var we=p(N,2),qe=u(we);{var We=Ae=>{var at=Wh();F("click",at,()=>{h(fe,"readonly"),ai()}),b(Ae,at)},Ke=Ae=>{var at=jh();F("click",at,()=>h(fe,"main")),b(Ae,at)};k(qe,Ae=>{t(fe)==="main"?Ae(We):Ae(Ke,-1)})}c(we);var _t=p(we,2),zt=u(_t);{var _n=Ae=>{Qa(Ae,{readOnly:!0})},fn=Ae=>{Qa(Ae,{})};k(zt,Ae=>{t(fe)==="readonly"?Ae(_n):Ae(fn,-1)})}c(_t),$(()=>{Jt(Te,1,`h-2.5 w-2.5 rounded-full ${t(se)?"bg-emerald-500":"bg-rose-500"}`),Jt(Ee,1,`text-sm ${t(se)?"text-emerald-400":"text-rose-400"}`),V(te,t(se)?"Connected":"Disconnected"),J(be,"title",t(ze).serverVersion?`App build ${Ns} · server ${t(ze).serverVersion}`:`App build ${Ns}`),V(ye,`v${Ns}`)}),b(E,D)};k(pt,E=>{t(Ce)?E(kt):E(gt,-1)})}c(ne);var mt=p(ne,2),Gt=u(mt),Oe=u(Gt),st=p(Oe,2);{var dn=E=>{var D=qh();F("click",D,M),b(E,D)};k(st,E=>{t(se)&&t(Rt)&&t(H).sessionFile&&E(dn)})}var mn=p(st,2);{var kn=E=>{var D=Xh(),N=u(D);{var ie=te=>{var be=Vh();b(te,be)},Te=te=>{var be=Kh();b(te,be)},Ee=te=>{var be=Yh();b(te,be)};k(N,te=>{t(se)&&t(Xe)?te(ie):t(se)?te(Te,1):te(Ee,-1)})}c(D),b(E,D)};k(mn,E=>{(!t(se)||!t(H).sessionFile)&&E(kn)})}var on=p(mn,2);{var In=E=>{var D=nb(),N=u(D);{var ie=te=>{var be=Zh(),ye=p(u(be),2),St=u(ye,!0);c(ye),c(be),$(xn=>{J(ye,"title",t(H).cwd),V(St,xn)},[()=>t(H).cwd.split("/").pop()||t(H).cwd]),b(te,be)};k(N,te=>{t(H).cwd&&te(ie)})}var Te=p(N,2);{var Ee=te=>{var be=tb(),ye=u(be),St=p(u(ye),2);c(ye);var xn=p(ye,2);{var un=Y=>{var ce=Jh();Fn(ce,21,()=>t(jt),cr,(qe,We)=>{var Ke=Qh(),_t=u(Ke,!0);c(Ke);var zt={};$(()=>{V(_t,t(We).label),zt!==(zt=`${t(We).provider}:${t(We).modelId}`)&&(Ke.value=Ke.__value=`${t(We).provider}:${t(We).modelId}`)}),b(qe,Ke)}),c(ce);var we;si(ce),$(()=>{we!==(we=t(H).model)&&(ce.value=(ce.__value=t(H).model)??"",Ho(ce,t(H).model))}),F("input",ce,qe=>Wi(qe.currentTarget.value)),b(Y,ce)},gn=Y=>{var ce=eb(),we=u(ce,!0);c(ce),$(()=>{J(ce,"title",t(H).model),V(we,t(H).model)}),b(Y,ce)};k(xn,Y=>{t(jt).length>0&&!t($t)?Y(un):Y(gn,-1)})}c(be),$(()=>{Jt(St,1,`absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full border border-brand-surface ${t(ze).isStreaming?"animate-pulse bg-orange-500":"bg-emerald-500"}`),J(St,"title",t(ze).isStreaming?"Agent working...":"Ready")}),b(te,be)};k(Te,te=>{t(H).model&&te(Ee)})}c(D),b(E,D)};k(on,E=>{t(H).sessionFile&&E(In)})}var an=p(on,2);{var Vn=E=>{var D=rb();b(E,D)};k(an,E=>{t($t)&&E(Vn)})}c(Gt);var Kn=p(Gt,2);{var Ln=E=>{var D=sb();b(E,D)};k(Kn,E=>{t(ct)&&E(Ln)})}var zn=p(Kn,2);{var tr=E=>{var D=ob(),N=u(D),ie=u(N,!0);c(N);var Te=p(N,2);c(D),$(()=>{Jt(D,1,`flex items-start justify-between gap-2 border px-4 py-2 text-sm ${t(Wt).level==="warning"?"border-yellow-500/30 bg-yellow-500/10 text-yellow-400":"border-blue-500/30 bg-blue-500/10 text-blue-400"}`),V(ie,t(Wt).message)}),F("click",Te,()=>zi()),b(E,D)};k(zn,E=>{t(Wt)&&E(tr)})}var Bn=p(zn,2);{var C=E=>{var D=ib(),N=u(D),ie=p(u(N));{var Te=ye=>{var St=jn("You are both working in it — changes may conflict.");b(ye,St)},Ee=ye=>{var St=jn("You are observing (read-only) to avoid clashing.");b(ye,St)};k(ie,ye=>{t(je).continued?ye(Te):ye(Ee,-1)})}c(N);var te=p(N,2);{var be=ye=>{var St=ab();F("click",St,()=>Ni()),b(ye,St)};k(te,ye=>{t(je).continued||ye(be)})}c(D),b(E,D)};k(Bn,E=>{t(je)?.active&&E(C)})}var T=p(Bn,2);{var z=E=>{var D=lb(),N=u(D),ie=u(N,!0);c(N);var Te=p(N,2);c(D),$(()=>V(ie,t(sn))),F("click",Te,()=>Xr()),b(E,D)};k(T,E=>{t(sn)&&E(z)})}var Q=p(T,2);{var oe=E=>{var D=cb();b(E,D)};k(Q,E=>{t($t)&&!t(ct)&&E(oe)})}var Pe=p(Q,2);ur(vp(Pe,{onMessageSent:()=>{}}),E=>he=E,()=>he);var He=p(Pe,2);{var pe=E=>{var D=db();b(E,D)},Fe=E=>{var D=pb(),N=rn(D);{var ie=te=>{var be=ub();b(te,be)},Te=te=>{var be=fb();b(te,be)};k(N,te=>{t(H).sessionFile&&(t(Ht)||!t(se))?te(ie):t(H).sessionFile&&t(tt)&&te(Te,1)})}var Ee=p(N,2);{let te=G(()=>!!t(Rt)),be=G(()=>t(Xe)?!t(se):!t(se)||t($t)||!t(H).sessionFile||t(Ht)||t(tt));ur(Gp(Ee,{get searchMode(){return t(Xe)},get searchConfigured(){return t(te)},get searchModels(){return t(K)},onSubmit:ye=>Oi(ye,t(Le)),placeholder:"Search the web...",submitLabel:"Search",get disabled(){return t(be)},onSend:()=>he?.forceScrollToBottom(),get searchModel(){return t(Le)},set searchModel(ye){h(Le,ye,!0)}}),ye=>h(vt,ye,!0),()=>t(vt))}b(E,D)};k(He,E=>{t($t)&&t(H).sessionFile?E(pe):E(Fe,-1)})}c(mt);var xt=p(mt,2);$h(xt,{});var ln=p(xt,2);{var dt=E=>{var D=hb();F("click",D,()=>h(Je,!1)),b(E,D)};k(ln,E=>{t(Je)&&E(dt)})}c(j),$(()=>Jt(ne,1,`app-chrome ${t(Je)?"translate-x-0":"-translate-x-full"} fixed z-20 flex h-full w-72 flex-col border-r border-brand-border bg-brand-surface transition-transform duration-200 md:relative md:translate-x-0`)),F("click",Oe,()=>h(Je,!t(Je))),b(n,A),Br(),ae()}Qr(["click","input"]);export{Sb as component,kb as universal};
89
+ //# sourceMappingURL=2.CpZdrUY8.js.map