my-durable 0.0.65 → 0.0.67

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.
@@ -12,13 +12,13 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
12
12
 
13
13
  `))>=0;){let e=f.slice(0,p),t=tu(e);if(t>n)throw a();f=f.slice(p+2),s-=t+2;let r=ru(e);r&&(yield r)}if(s>n)throw a();o=f?[f]:[],c=f.slice(-1)}}finally{r.cancel().catch(()=>{})}}function ru(e){let t=`message`,n,r=[];for(let i of e.split(`
14
14
  `)){if(!i||i.startsWith(`:`))continue;let e=i.indexOf(`:`),a=e<0?i:i.slice(0,e),o=e<0?``:i.slice(e+1).replace(/^ /,``);a===`event`?t=o:a===`data`?r.push(o):a===`id`&&(n=o)}return r.length?{event:t,data:r.join(`
15
- `),id:n}:void 0}var iu=encodeURIComponent,au=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,ou=e=>e.normalize(`NFKD`).replace(/[^\w.-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60).toLowerCase()||`session`,su=class{token;baseUrl;constructor(e,t){this.token=t,this.baseUrl=e.replace(/\/+$/,``)}headers(e,t={}){return{...this.token?{authorization:`Bearer ${this.token}`,"x-dpi-token":this.token}:{},...e?{"content-type":`application/json`}:{},...t}}async request(e,t,n,r={}){let i=AbortSignal.timeout(r.timeoutMs??2e4),a=r.signal?AbortSignal.any([r.signal,i]):i,o;try{o=await fetch(this.baseUrl+t,{method:e,signal:a,headers:this.headers(n!==void 0,r.idempotencyKey?{"idempotency-key":r.idempotencyKey}:{}),body:n===void 0?void 0:JSON.stringify(n)})}catch(e){throw r.signal?.aborted?e:new Sl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}let s=await o.text(),c;try{c=s?JSON.parse(s):void 0}catch{c=void 0}if(!o.ok){let e=c?.error;throw new Sl(e?.code??(o.status===401?`unauthorized`:o.status===404?`not_found`:`internal`),e?.message??`${o.status} ${o.statusText}`,o.status)}return c}async*stream(e,t,n){let r;try{r=await fetch(this.baseUrl+e,{headers:{...this.headers(!1),accept:`text/event-stream`},signal:t})}catch(e){if(t.aborted)return;throw new Sl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}if(!r.ok||!r.body){let e=await r.json().catch(()=>void 0);throw new Sl(e?.error?.code??(r.status===401?`unauthorized`:`unavailable`),e?.error?.message??`Stream failed (${r.status})`,r.status)}try{for await(let e of nu(r.body,n))yield JSON.parse(e.data)}catch(e){if(t.aborted)return;throw e}}device(e){return this.request(`GET`,`/v1/device`,void 0,e)}vitals(){return this.request(`GET`,`/v1/device/vitals`)}tree(){return this.request(`GET`,`/v1/tree`)}projects(e=!1){return this.request(`GET`,`/v1/projects${e?`?includeArchived=1`:``}`)}updateProject(e,t){return this.request(`PATCH`,`/v1/projects/${iu(e)}`,t)}archiveProject(e){return this.request(`POST`,`/v1/projects/${iu(e)}/archive`,{})}unarchiveProject(e){return this.request(`POST`,`/v1/projects/${iu(e)}/unarchive`,{})}notifySinks(){return this.request(`GET`,`/v1/notify/sinks`)}createNotifySink(e){return this.request(`POST`,`/v1/notify/sinks`,e)}updateNotifySink(e,t){return this.request(`PATCH`,`/v1/notify/sinks/${iu(e)}`,t)}removeNotifySink(e){return this.request(`DELETE`,`/v1/notify/sinks/${iu(e)}`)}testNotifySinks(){return this.request(`POST`,`/v1/notify/test`,{})}envView(){return this.request(`GET`,`/v1/device/env`)}setEnvVar(e,t){return this.request(`POST`,`/v1/device/env`,{key:e,value:t})}removeEnvVar(e){return this.request(`DELETE`,`/v1/device/env/${iu(e)}`)}piAuth(){return this.request(`GET`,`/v1/device/pi-auth`)}setPiApiKey(e,t){return this.request(`PUT`,`/v1/device/pi-auth/${iu(e)}`,{key:t})}removePiApiKey(e){return this.request(`DELETE`,`/v1/device/pi-auth/${iu(e)}`)}graphs(){return this.request(`GET`,`/v1/graphs`)}graph(e){return this.request(`GET`,`/v1/graphs/${iu(e)}`)}createGraph(e){return this.request(`POST`,`/v1/graphs`,e)}runGraph(e){return this.request(`POST`,`/v1/graphs/${iu(e)}/run`,{})}removeGraph(e){return this.request(`DELETE`,`/v1/graphs/${iu(e)}`)}schedules(){return this.request(`GET`,`/v1/schedules`)}createSchedule(e){return this.request(`POST`,`/v1/schedules`,e)}updateSchedule(e,t){return this.request(`PATCH`,`/v1/schedules/${iu(e)}`,t)}removeSchedule(e){return this.request(`DELETE`,`/v1/schedules/${iu(e)}`)}runSchedule(e){return this.request(`POST`,`/v1/schedules/${iu(e)}/run`,{})}deviceUsage(){return this.request(`GET`,`/v1/device/usage`)}searchSessions(e){return this.request(`GET`,`/v1/sessions/search?q=${iu(e)}`)}dirs(e=``){return this.request(`GET`,`/v1/fs/dirs?path=${iu(e)}`)}deviceDoc(e){return this.request(`GET`,`/v1/docs/${iu(e)}`)}deviceEvents(e,t=[]){return this.stream(`/v1/events${t.length?`?docs=${t.map(iu).join(`,`)}`:``}`,e)}gitStatus(e,t={}){return this.request(`GET`,`/v1/git/status?path=${iu(e)}`,void 0,t)}gitOp(e,t,n={}){return this.request(`POST`,`/v1/git`,{path:e,op:t,...n})}async exportSession(e,t={}){let n=AbortSignal.timeout(t.timeoutMs??6e4),r=t.signal?AbortSignal.any([t.signal,n]):n,i;try{i=await fetch(this.baseUrl+`/v1/sessions/${iu(e)}/export`,{headers:this.headers(!1),signal:r})}catch(e){throw t.signal?.aborted?e:new Sl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}if(!i.ok){let e=await i.text().catch(()=>``),t;try{t=e?JSON.parse(e):void 0}catch{t=void 0}throw new Sl(t?.error?.code??(i.status===401?`unauthorized`:i.status===404?`not_found`:`internal`),t?.error?.message??`${i.status} ${i.statusText}`,i.status)}let a=new Uint8Array(await i.arrayBuffer()),o=i.headers.get(`content-disposition`)??``,s=/filename="((?:[^"\\]|\\.)*)"/i.exec(o)?.[1],c=/filename=([^;\s]+)/i.exec(o)?.[1];return{filename:(s===void 0?c:s.replace(/\\(.)/g,`$1`))||`${ou(e)}.bundle.zip`,mime:i.headers.get(`content-type`)??`application/zip`,bytes:a}}sessionGitFiles(e){return this.request(`GET`,`/v1/sessions/${iu(e)}/git-files`)}sessionGitTurns(e){return this.request(`GET`,`/v1/sessions/${iu(e)}/git-turns`)}gitStatusBatch(e,t={}){return this.request(`POST`,`/v1/git/status-batch`,{paths:e},t)}sessions(){return this.request(`GET`,`/v1/sessions`)}archived(){return this.request(`GET`,`/v1/archive`)}archivedTranscript(e,t=`markdown`){return this.request(`GET`,`/v1/archive/${iu(e)}/transcript?format=${t}`)}restoreArchived(e){return this.request(`POST`,`/v1/archive/${iu(e)}/restore`,{})}createSession(e,t=au()){return this.request(`POST`,`/v1/sessions`,e,{idempotencyKey:t})}session(e){return new cu(this,e)}agent(e,t){return new lu(this,e,String(t))}},cu=class{client;ref;constructor(e,t){this.client=e,this.ref=t}get base(){return`/v1/sessions/${iu(this.ref)}`}get(){return this.client.request(`GET`,this.base)}rename(e){return this.client.request(`PATCH`,this.base,{name:e})}archive(){return this.client.request(`DELETE`,this.base)}agents(){return this.client.request(`GET`,`${this.base}/agents`)}createAgent(e={},t=au()){return this.client.request(`POST`,`${this.base}/agents`,e,{idempotencyKey:t})}tasks(e=`terminal`,t=20){return this.client.request(`GET`,`${this.base}/tasks?status=${e}&limit=${t}`)}abortTask(e){return this.client.request(`POST`,`${this.base}/tasks/${e}/abort`,{})}inspect(){return this.client.request(`GET`,`${this.base}/inspect`)}compaction(){return this.client.request(`GET`,`${this.base}/compaction`)}setCompaction(e){return this.client.request(`PATCH`,`${this.base}/compaction`,e)}submission(e,t=0){return this.client.request(`GET`,`${this.base}/submissions/${e}?waitMs=${t}`,void 0,{timeoutMs:t+2e4})}events(e){return this.client.stream(`${this.base}/events`,e)}},lu=class{client;session;agent;constructor(e,t,n){this.client=e,this.session=t,this.agent=n}get base(){return`/v1/sessions/${iu(this.session)}/agents/${iu(this.agent)}`}get(){return this.client.request(`GET`,this.base)}rename(e){return this.client.request(`PATCH`,this.base,{name:e})}send(e,t=`followUp`,n=au(),r){return this.client.request(`POST`,`${this.base}/messages`,{content:e,whenBusy:t,requestId:n,waitMs:r},{timeoutMs:(r??0)+2e4})}withdraw(e){return this.client.request(`DELETE`,`${this.base}/inbox/${e}`)}abort(e=!1){return this.client.request(`POST`,`${this.base}/abort`,{background:e})}fork(e,t=au()){return this.client.request(`POST`,`${this.base}/fork`,e,{idempotencyKey:t})}config(){return this.client.request(`GET`,`${this.base}/config`)}configure(e){return this.client.request(`PATCH`,`${this.base}/config`,e)}compact(e){return this.client.request(`POST`,`${this.base}/compact`,{instructions:e})}reset(e){return this.client.request(`POST`,`${this.base}/reset`,{note:e})}entries(e={}){let t=new URLSearchParams({scope:e.scope??`all`,limit:String(e.limit??500),...e.cursor?{cursor:e.cursor}:{}});return this.client.request(`GET`,`${this.base}/entries?${t}`)}transcript(e=`json`){return this.client.request(`GET`,`${this.base}/transcript?format=${e}`)}doc(e){return this.client.request(`GET`,`${this.base}/docs/${iu(e)}`)}extensions(){return this.client.request(`GET`,`${this.base}/extensions`)}setExtension(e){return this.client.request(`PATCH`,`${this.base}/extensions`,e)}demo(e,t,n=`POST`){return this.client.request(n,`${this.base}/demo/${e}`,t)}events(e,t=[]){return this.client.stream(`${this.base}/events${t.length?`?docs=${t.map(iu).join(`,`)}`:``}`,e)}},G=e=>new su(`/api/devices/${encodeURIComponent(e)}`);async function uu(e,t,n){let r=await fetch(`/api${t}`,{method:e,headers:n===void 0?{}:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>void 0);if(!r.ok){let e=i?.error;throw new Sl(e?.code??`internal`,e?.message??`${r.status} ${r.statusText}`,r.status)}return i}var du={network:()=>uu(`GET`,`/network`),version:()=>uu(`GET`,`/version`),check:e=>uu(`POST`,`/devices/${encodeURIComponent(e)}/check`,{}),createShare:e=>uu(`POST`,`/shares`,e),async uiGet(e){return(await uu(`GET`,`/ui-state/${encodeURIComponent(e)}`)).value??void 0},uiSet:(e,t)=>uu(`PUT`,`/ui-state/${encodeURIComponent(e)}`,{value:t})},K=e=>e instanceof Error?e.message:String(e),fu=[`demo.job-runs`,`demo.workspace`],pu=e=>`${e.deviceId}/agent/${e.sessionId}/${e.agentId}?docs=${fu.join(`,`)}`,mu=e=>`${e.deviceId}/session/${e.sessionId}`,hu=e=>`${e}/device?docs=app.shared-state`;function gu(e,t,n,r=`hello`){let i=k(`idle`),a=k(``);return e.route(t,e=>{e.type===`hello`?(i.value=r===`hello`?`live`:`connecting`,r===`hello`&&(a.value=``)):e.type===`disconnected`?i.value=`reconnecting`:e.type===`fault`?(i.value=`fault`,a.value=e.error.message):(n(e),e.type===r&&(a.value=``,i.value=`live`))}),{status:i,fault:a,select:n=>{a.value=``,i.value=n?`connecting`:`idle`,e.set(t,n)},retry:()=>{i.value=`connecting`,e.reopen(t)}}}function _u(e){let t=new Ul,n=k(0);return t.subscribe(()=>n.value++),e.onNetwork(e=>t.apply({type:`network`,devices:e})),{model:t,devices:U(()=>(n.value,t.devices)),tree:U(()=>(n.value,t.tree()))}}function vu(e,t){let n=rn(),r=rn([]),{status:i,select:a}=gu(e,`device`,e=>{e.type===`doc`&&e.kind===`app.shared-state`?n.value={value:e.value,revision:e.revision??0}:e.type===`activity`&&(r.value=[...r.value,...e.items].slice(-50))});return M(t,e=>{n.value=void 0,a(e?hu(e):void 0)},{immediate:!0}),{sharedState:n,activity:r,status:i}}function yu(e,t){let n=new Il,r=k(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o}=gu(e,`session`,e=>n.apply(e));return M(()=>t.value?mu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:U(()=>(r.value,n.state)),status:i,fault:a}}function bu(e,t){let n=new Fl,r=k(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o,retry:s}=gu(e,`agent`,e=>n.apply(e),`snapshot`);return M(()=>t.value?pu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:U(()=>(r.value,{...n.state})),status:i,fault:a,version:r,retry:s}}var xu=new Jl,Su=k(xu.state);xu.onState(e=>Su.value=e);var Cu=_u(xu),wu=k(),Tu=k(),q=k(),Eu=k(new Set),Du=k(300),Ou=Wt({tree:!0,inspector:!0}),ku=k(!1),Au=U(()=>q.value?.deviceId),ju=U(()=>Cu.devices.value.find(e=>e.id===Au.value)),Mu=U(()=>ju.value?.status===`online`),Nu=yu(xu,U(()=>q.value?{deviceId:q.value.deviceId,sessionId:q.value.sessionId}:void 0)),Pu=bu(xu,q),Fu=vu(xu,Au),Iu=U(()=>ju.value?.tree?.sessions.find(e=>e.id===q.value?.sessionId)),Lu=U(()=>Au.value?G(Au.value):void 0),Ru=U(()=>q.value&&Lu.value?Lu.value.agent(q.value.sessionId,q.value.agentId):void 0),zu=U(()=>q.value&&Lu.value?Lu.value.session(q.value.sessionId):void 0);function Bu(e){q.value=e,J.drawer=!1,Vu=!!e,Hu()}var Vu=!1;function Hu(){let e=q.value;if(!Vu||!e)return;let t=Cu.devices.value.find(t=>t.id===e.deviceId)?.tree?.sessions.find(t=>t.id===e.sessionId)?.agents,n=new Map((t??[]).map(e=>[e.id,e])),r=[e.deviceId,`${e.deviceId}/s/${e.sessionId}`,`${e.deviceId}/s/${e.sessionId}/a/${e.agentId}`],i=n.get(e.agentId),a=new Set;for(;i&&!a.has(i.id);){a.add(i.id);let t=i.parentId??i.ownerAgentId;if(t===void 0)break;r.push(`${e.deviceId}/s/${e.sessionId}/a/${t}`),i=n.get(t)}r.some(e=>!Eu.value.has(e))&&(Eu.value=new Set([...Eu.value,...r])),n.has(e.agentId)&&(Vu=!1)}M(()=>Cu.devices.value,Hu);function Uu(e,t){let n=new Set(Eu.value);t??!n.has(e)?n.add(e):n.delete(e),Eu.value=n}var Wu=(()=>{let e=new Map;return(t,n)=>{clearTimeout(e.get(t)),e.set(t,setTimeout(()=>void du.uiSet(t,n).catch(()=>{}),300))}})();M(q,e=>ku.value&&void du.uiSet(`tree.selected`,e??null).catch(()=>{})),M(Du,e=>ku.value&&Wu(`tree.width`,e)),M(Ou,e=>ku.value&&Wu(`layout.panels`,{...e}));async function Gu(){let e;try{e=await du.network()}catch(e){e instanceof Sl&&e.status===401||xu.start(),J.error=K(e),ku.value=!0;return}xu.start();try{let[t,n,r]=await Promise.all([du.uiGet(`tree.selected`),du.uiGet(`tree.width`),du.uiGet(`layout.panels`)]);r&&Object.assign(Ou,r),du.version().then(e=>Tu.value=e.version).catch(()=>{}),wu.value=e.configFile,Cu.model.devices.length||Cu.model.apply({type:`network`,devices:e.devices}),Eu.value=new Set,n&&(Du.value=n),t&&e.devices.some(e=>e.id===t.deviceId)?Bu(t):Ku(e.devices)}catch(e){J.error=K(e)}finally{ku.value=!0}}function Ku(e){for(let t of e){let e=t.status===`online`?t.tree?.sessions[0]:void 0,n=e?.agents.find(e=>e.kind===`root`)??e?.agents[0];if(e&&n)return Bu({deviceId:t.id,sessionId:e.id,agentId:n.id})}}M(()=>[Pu.status.value,Iu.value],([e,t])=>{e===`fault`&&!t&&Mu.value&&(Y(`That session was archived on its device.`),Bu(void 0))});var qu=U(()=>ju.value?.info?.models??[]),Ju=Pu.state,Yu=U(()=>Nu.state.value.agents.length?Nu.state.value.agents:Iu.value?.agents??[]),Xu=U(()=>q.value?Ll(Yu.value,q.value.agentId):[]),Zu=U(()=>{let e=q.value?.agentId;if(e===void 0)return[];let t=Yu.value,n=new Set([e]);for(let e=!0;e;){e=!1;for(let r of t)r.ownerAgentId!==void 0&&n.has(r.ownerAgentId)&&!n.has(r.id)&&(n.add(r.id),e=!0)}let r=Nu.state.value.tasks,i=new Map(r.map(e=>[e.id,e])),a=new Map(t.map(e=>[e.id,e.ownerTaskId]));return r.filter(e=>n.has(e.conversationId)).map(e=>{let t=e,n=!1,r=new Set;for(;t&&!r.has(t.id);){if(r.add(t.id),t.background){n=!0;break}let e=t.owner??a.get(t.conversationId);t=e===void 0?void 0:i.get(e)}return{...e,effectiveBackground:n}})}),Qu=U(()=>Ju.value.running||Zu.value.some(e=>!e.effectiveBackground&&e.conversationId===q.value?.agentId)),$u=U(()=>Al(Ju.value.usage)),ed=U(()=>{let e=Ju.value.agent.model;return qu.value.find(t=>t.provider===e?.provider&&t.id===e?.modelId)}),td=U(()=>{let e=Ju.value.agent.model;if(e?.modelId)return e;let t=Iu.value;return t?.model?{provider:t.provider??``,modelId:t.model}:void 0}),nd=U(()=>{let e=td.value;return e?qu.value.find(t=>t.provider===e.provider&&t.id===e.modelId):void 0}),rd=rn(),id=0;async function ad(){let e=Ru.value,t=++id;if(!e||!Mu.value)return void(rd.value=void 0);try{let n=await e.get();t===id&&(rd.value=n)}catch{t===id&&(rd.value=void 0)}}M([Ru,Mu],()=>void ad(),{immediate:!0});var J=Wt({error:``,toast:``,drawer:!1,inspectorOverlay:!1,tab:`session`,composer:``,dialog:void 0}),od,sd=Wt([]),cd=1;function ld(){for(let e of sd)e.read=!0}function Y(e){J.toast=e,e&&(sd.unshift({id:cd++,text:e,at:Date.now(),read:!1}),sd.length>50&&(sd.length=50)),clearTimeout(od),od=setTimeout(()=>J.toast=``,4500)}async function ud(e){J.error=``;try{return await e()}catch(e){J.error=K(e);return}}function dd(e){J.composer=e,setTimeout(()=>document.querySelector(`.composer textarea`)?.focus())}var fd=e=>Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e),pd=e=>JSON.stringify(e,null,2),md=(e=``)=>Xl(qu.value.find(t=>t.id===e)?.icon);function hd(e){if(!e)return`never`;let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}var gd=k(!1);async function _d(){Qu.value&&!gd.value&&Ru.value&&(gd.value=!0,await ud(()=>Ru.value.abort(!1))&&Y(`Foreground work interrupted. Background jobs continue.`),gd.value=!1)}var vd=window.matchMedia(`(max-width: 1100px)`),yd=k(vd.matches);vd.addEventListener(`change`,e=>yd.value=e.matches);var bd=U(()=>yd.value?J.inspectorOverlay:Ou.inspector);function xd(e){e&&(J.tab=e),yd.value?(J.drawer=!1,J.inspectorOverlay=!0):Ou.inspector=!0}function Sd(){yd.value?J.inspectorOverlay=!1:Ou.inspector=!1}function Cd(){yd.value?(J.drawer=!J.drawer)&&(J.inspectorOverlay=!1,Ou.tree=!0):Ou.tree=!Ou.tree}function wd(){bd.value?Sd():xd()}var Td=/Mac|iPhone|iPad/.test(navigator.userAgent),Ed=Td?{tree:`Ctrl+N`,inspector:`Ctrl+T`}:{tree:`Alt+Shift+N`,inspector:`Alt+Shift+T`};function Dd(e){if(!(!(Td?e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey:e.altKey&&e.shiftKey&&!e.ctrlKey&&!e.metaKey)||e.repeat||e.isComposing)){if(e.code===`KeyN`)return`tree`;if(e.code===`KeyT`)return`inspector`}}var Od={class:`topbar`},kd={class:`brand`},Ad={class:`daemon`,"data-testid":`topbar-stats`},jd=[`title`],Md={class:`top-actions`},Nd={key:0,class:`usage-chip`,title:`This session's token usage and cost`},Pd=[`aria-label`,`title`],Fd={key:0,class:`bell-dot`},Id={key:0,class:`hint`},Ld={class:`when`},Rd=[`disabled`],zd=[`disabled`],Bd=N({__name:`TopBar`,emits:[`newSession`],setup(e,{emit:t}){let n=k(!1),r=U(()=>sd.filter(e=>!e.read).length),i=()=>{n.value=!n.value,n.value&&ld()},a=e=>{let t=Math.round((Date.now()-e)/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`},o=U(()=>$u.value.input+$u.value.output+$u.value.cacheRead+$u.value.cacheWrite),s=U(()=>($u.value.inputCost??0)+($u.value.outputCost??0)+($u.value.cacheReadCost??0)+($u.value.cacheWriteCost??0)),c=U(()=>Cu.devices.value.filter(e=>e.status===`online`).length),l=U(()=>Cu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.length??0),0)),u=U(()=>Cu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.reduce((e,t)=>e+t.agents.length,0)??0),0)),d=k(!1);async function f(){let e=zu.value,t=q.value;if(!e||!t||d.value)return;d.value=!0;let n=await ud(()=>e.createAgent({name:`Agent ${Yu.value.length+1}`}));d.value=!1,n&&(Bu({...t,agentId:n.id}),Y(`New agent. Same session, same shared App State.`))}let p=t;return(e,t)=>(I(),L(`header`,Od,[z(`div`,kd,[z(`button`,{class:`icon-button tree-toggle`,"aria-label":`Toggle network`,title:`Network`,onClick:t[0]||=e=>A(J).drawer=!A(J).drawer},[B(A(Gc),{size:19})]),t[6]||=z(`img`,{class:`brandmark`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),t[7]||=z(`strong`,null,`Durable Pi`,-1)]),t[15]||=z(`span`,{class:`topbar-sep`,"aria-hidden":`true`},null,-1),z(`div`,Ad,[z(`span`,{class:E([`dot`,{off:!c.value}]),"aria-hidden":`true`},null,2),z(`span`,{class:`network-summary`,title:`${c.value} of ${A(Cu).devices.value.length} devices online`},[B(A(Bc),{size:16}),V(D(c.value)+` of `+D(A(Cu).devices.value.length)+` online`,1)],8,jd),t[10]||=z(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),z(`span`,null,[z(`b`,null,D(l.value),1),t[8]||=V(` sessions`,-1)]),t[11]||=z(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),z(`span`,null,[z(`b`,null,D(u.value),1),t[9]||=V(` agents`,-1)])]),z(`div`,Md,[z(`span`,{class:E([`chip connection`,{accent:A(Su)===`live`}])},[z(`span`,{class:E([`dot`,{off:A(Su)!==`live`}]),"aria-hidden":`true`},null,2),V(D(A(Su)===`live`?`Connected`:`Reconnecting`),1)],2),o.value?(I(),L(`span`,Nd,D(o.value.toLocaleString())+` tok · $`+D(s.value.toFixed(3)),1)):H(``,!0),z(`button`,{class:`icon-button`,"aria-label":`Notifications${r.value?` (${r.value} unread)`:``}`,title:`Notification center${r.value?` — ${r.value} unread`:``}`,onClick:i},[B(A(Xs),{size:18}),r.value?(I(),L(`i`,Fd,D(r.value>9?`9+`:r.value),1)):H(``,!0)],8,Pd),n.value?(I(),L(`div`,{key:1,class:`notif-panel`,onClick:t[2]||=ks(()=>{},[`stop`])},[z(`header`,null,[t[12]||=z(`b`,null,`Notifications`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close notifications`,onClick:t[1]||=e=>n.value=!1},`✕`)]),A(sd).length?H(``,!0):(I(),L(`p`,Id,`Nothing yet — events land here as they happen.`)),z(`ul`,null,[(I(!0),L(F,null,P(A(sd),e=>(I(),L(`li`,{key:e.id,class:E({unread:!e.read})},[z(`span`,Ld,D(a(e.at)),1),z(`span`,null,D(e.text),1)],2))),128))])])):H(``,!0),z(`button`,{class:`icon-button`,title:`How this works`,"aria-label":`How this works`,onClick:t[3]||=e=>A(J).dialog={kind:`help`}},[B(A(ac),{size:19})]),z(`button`,{class:`secondary small new-agent-button`,disabled:!A(q)||!A(Mu)||d.value,title:`Start a fresh agent in this session`,onClick:f},[B(A(Xc),{size:18}),t[13]||=V(`New agent `,-1)],8,Rd),z(`button`,{class:`primary small`,onClick:t[4]||=e=>p(`newSession`)},[B(A(Xc),{size:18}),t[14]||=V(`New session `,-1)]),z(`button`,{class:`icon-button inspector-toggle`,"aria-label":`Toggle inspector`,title:`Inspector`,disabled:!A(q)||!A(Mu),onClick:t[5]||=e=>A(J).inspectorOverlay?A(Sd)():A(xd)()},[B(A(Kc),{size:19})],8,zd)])]))}}),Vd=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Hd=Vd(Bd,[[`__scopeId`,`data-v-de526f26`]]),Ud={class:`mnav`,"aria-label":`Panels`},Wd={key:0,class:`badge`},Gd=N({__name:`MobileNav`,setup(e){function t(){J.drawer=!1,J.inspectorOverlay=!1}return(e,n)=>(I(),L(`nav`,Ud,[z(`button`,{type:`button`,class:E({"is-on":!A(J).drawer&&!A(bd)}),onClick:t},[B(A(Lc),{size:18}),n[2]||=V(`Chat `,-1)],2),z(`button`,{type:`button`,class:E({"is-on":A(bd)}),onClick:n[0]||=e=>A(bd)?A(Sd)():A(xd)()},[B(A(Kc),{size:18}),n[3]||=V(`Details`,-1),A(Zu).length?(I(),L(`span`,Wd,D(A(Zu).length),1)):H(``,!0)],2),z(`button`,{type:`button`,class:E({"is-on":A(J).drawer}),onClick:n[1]||=e=>A(Cd)()},[B(A(gl),{size:18}),n[4]||=V(`Network `,-1)],2)]))}}),Kd=[`width`,`height`,`aria-label`],qd=[`width`,`height`,`aria-label`],Jd=N({__name:`DeviceIcon`,props:{device:{},size:{default:16}},setup(e){let t=e,n=U(()=>{let e=t.device;return e?.kind===`exe-dev`||e?.url?.includes(`.exe.xyz`)?`exe`:e?.info?.platform.startsWith(`darwin`)?`apple`:e?.kind===`local`?`laptop`:`server`}),r=U(()=>{let e={exe:`exe.dev VM`,apple:`macOS`,laptop:`This computer`,server:`Server`}[n.value];return t.device?.transport===`tunnel`?`${e} (tunnel)`:e});return(t,i)=>n.value===`exe`?(I(),L(`svg`,{key:0,class:`device-icon exe`,viewBox:`0 0 512 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[z(`title`,null,D(r.value),1),i[0]||=z(`path`,{fill:`currentColor`,"fill-rule":`evenodd`,d:`M8 332.2l.9 1.4 1.5 .5 38.5-4.1 3.1 .4 2.7 2.2 8.8 13.2 10.1 12.8 1.1 2.6-.3 3.2-16.4 35.6 0 1.7 1 1.2 2.2 0 33.8-18.2 3.1-.8 3.4 1 12.4 8.7 15.3 9.4 1.5 2.1 .5 2.5-3.1 38.9 .4 1.5 1.3 .9 2.3-.7 25.9-29.2 2.1-1.3 2.8-.4 16.3 4.4 15.7 3.2 3 1.8 1.6 2.8 9.8 37.1 1.5 1.6 1.7-.1 1.1-1.1 14.5-35.6 1.8-2.5 3.4-1.5 15.7-1.1 16.1-2.4 3.2 .5 2.3 1.8 22.4 32 2.2 .9 1.4-.7 .6-1.5 1.4-39 1-2.7 2.4-2.2 14.7-6.8 13.8-7.8 3.4-.7 3 1 32.4 21 2.3 0 1.1-1.1 0-1.6-13.4-36.6-.3-2.5 .7-2.4 12.2-13.9 8.8-12.1 2.8-2 3.1-.3 38.4 5.4 2.1-.9 .5-1.5-.6-1.4-27.5-27.4-1.6-2.7-.2-3.1 4.6-15.8 2.9-15.8 1.3-2.6 2.5-1.9 37.3-12.2 1.6-1.9-.3-1.5-1.1-1-36.8-12.5-2.4-1.4-1.8-3.3-3.1-17.7 0-2.2 .9-2.4 3.1-2.9 10.6-15.3 3.3-1.8 3.4 .3 3.8 3 4.5 6.8 8.9 11.2 12.5 12.5 6.2 4.8 7.3 4.3 6.3 2.4 3.8 .3 4-.3 5.1-2.4 6.5-7 4.8-10.6 3.3-11.9 2-14.1 1.3-3.4 0-66.6-.8-2.6-2-13.6-3.8-14.6-7.5-18.7-4.7-9.4-4-6-7.2-7.1-5-2.1-6.5 0-2.2 .7-6 3.5-12 12-13.1 17.8-11.7 18.2-3.7 1.6-11.8-.1-3.1-1.6-1.8-2.9-.3-8.8-2.8-12.7-1.5-4-7.1-13.3-5.9-7.8-10.7-9.3-8.6-4.7-5.9-2-4.1-.5-6.7-.5-4.1 .5-7 2-7.3 3.8-7.5 7-2.2 3.2-2.5 5.5-2.8 10.5-.5 3.6 .1 17.1-.3 2.2-1.1 1.9-1.7 1.5-3.7 1.5-2.6 .3-27.5-10.5-14.5-4-15.7-3.2-2.6-1.3-1.9-3-9.9-37.5-.9-1.2-1.4-.4-1.3 .4-.8 1-14.7 36.1-1.8 2.1-2.2 1.2-17.8 1.4-15 2.2-3.4-.7-2.4-2.1-22-31.5-2-.9-1.5 .5-.7 1.5-1.4 38.6-.9 3-2.5 2.5-14.7 6.8-13.8 7.8-2.8 .7-3.1-.7-32.9-21.3-2.3 0-1.1 1.1-.1 1.6 13.6 36.9 0 3.1-1.2 2.6-10.8 12-9.5 12.9-2.8 2-3.2 .3-38.4-5.4-1.5 .4-.9 1.4 .6 2.1 27.6 27.6 1.2 1.8 .5 2.2-3 10.6-1.5 2.4-2.4 1.6-5.8 1-4.4 1.8-3.8 3-3 3.8-1.7 4-.7 4.7 .4 4.7 1.5 4.2 .3 .5 30.7 0 1.7 .6 1.4 1.1 1.1 3-1.1 2.9-2.7 1.6-31.1 .1-.6 1.1-1.2 3.6-.4 4.1 .4 4.2 1.2 3.5 2.5 4 3.2 3.1 4.1 2.3 5.6 1.8 2.4 2.1 .9 2.1 5.1 21.2-.6 2.1-1.2 1.9-28.5 26.5zM283.6 189.4l6.6 .5 5.6 1.2 6.2 2.2 5.9 3.1 4.6 3.4 4.8 4.5 3.5 4.4 3.4 5.8 2.6 6.2 1.6 6.4 .6 5.6-.2 6.7-1.1 6.5-1.7 5.4-2.9 6-3.6 5.5-7.1 7.3-8.4 5.4-9.4 3.5-9.9 1.3-11-1-40.4-10.4-2.8-1.1-3.1-2.4-1.7-.6-.9-1.1-.1-2.2-1.4-2.2 1.6-6.3 18.1-38.5 4.7-7.5 7.1-7.3 8.4-5.4 9.4-3.5zM173.9 198l-1.1 5.9-2.3 5.5-3.4 5-4.2 4.3-5 3.3-5.5 2.3-5.9 1.2-6 0-5.9-1.2-5.6-2.3-5-3.3-4.2-4.3-3.3-5-2.3-5.5-1.2-5.9 0-6 1.2-5.9 2.3-5.5 3.3-5 4.2-4.3 5-3.3 5.6-2.3 5.9-1.2 6 0 5.9 1.2 5.5 2.3 5 3.3 4.2 4.3 3.4 5 2.3 5.5 1.1 5.9zM315.1 213.5l-63.1 37.7 69.5-12.9 0-6.2-1-6.5-2.1-6.1zM237.3 260l-2.6 1.5 40.6 10.5 7.4 .9 7.4-.5 5.4-1.4 5.2-2.1 8.5-5.8 3.8-4.1 3.2-4.5 2.6-5 1.6-4.9zM284.5 196.9l-7.4 .5-8.1 2.3-7.3 4.1-6.3 5.5-5.8 8.5-17.4 37.1 3-.6 76.1-45.5-5.8-5-6.5-3.7-7.1-2.3zM141.1 183.6l-1.1-2.9-2-2.3-2.8-1.3-3.1-.1-2.9 1-2.3 2.1-1.3 2.8-.1 3 1 2.9 2.1 2.3 2.7 1.3 3.1 .2 2.9-1.1 2.3-2 1.3-2.8z`},null,-1)],8,Kd)):n.value===`apple`?(I(),L(`svg`,{key:1,class:`device-icon apple`,viewBox:`0 0 384 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[z(`title`,null,D(r.value),1),i[1]||=z(`path`,{fill:`currentColor`,d:`M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z`},null,-1)],8,qd)):n.value===`laptop`?(I(),R(A(Ac),{key:2,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`])):(I(),R(A(il),{key:3,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`]))}}),Yd=new Map,Xd=new Map;async function Zd(e,t){let n=t.filter(t=>!rf(nf(e,t),Qd));if(n.length)try{let t=await G(e).gitStatusBatch(n,{timeoutMs:6e4});for(let[n,r]of Object.entries(t)){let t=nf(e,n);t.status=r,t.at=Date.now(),t.error=``}}catch{}}var Qd=6e4,$d=!1;function ef(){$d||($d=!0,M(()=>Cu.devices.value,e=>{let t=Date.now();for(let n of e){let e=(n.tree?.git??[]).filter(e=>t-e.at<6e4);if(e.length)for(let r of[...Yd.keys()]){let[i,a]=r.split(`::`);if(i!==n.id||!a)continue;let o=Yd.get(r);e.some(e=>a===e.root||a.startsWith(e.root+`/`)||a.startsWith(e.root+`\\`))&&(o.loading||t-o.at<4e3||af(i,a,{force:!0}))}}}))}var tf=(e,t)=>`${e}::${t}`;function nf(e,t){let n=tf(e,t),r=Yd.get(n);return r||(r=Wt({at:0,status:null,error:``,loading:!1,refreshing:!1}),Yd.set(n,r)),r}var rf=(e,t)=>e.at>0&&Date.now()-e.at<t&&(e.status!==null||e.error);async function af(e,t,n={}){let{staleMs:r=6e4,force:i=!1,timeoutMs:a=6e4}=n;if(!e||!t)return;let o=tf(e,t),s=nf(e,t);if(!i&&rf(s,r))return;let c=Xd.get(o);if(c)return c;s.status===null&&!s.error?s.loading=!0:s.refreshing=!0,s.error=``;let l=(async()=>{try{s.status=await G(e).gitStatus(t,{timeoutMs:a}),s.at=Date.now()}catch(e){let t=e.message??``;s.error=/fetch failed|Cannot reach|Failed to fetch|NetworkError|abort/i.test(t)?`device unreachable — check that it is online, then retry (${t.slice(0,80)})`:t.slice(0,160),s.at=Date.now()}finally{s.loading=!1,s.refreshing=!1,Xd.delete(o)}})();return Xd.set(o,l),l}var of=new Map;function sf(){M(()=>Cu.devices.value.map(e=>`${e.id}:${e.status}:${e.tree?.sessions.length??0}:${e.tree?.sessions.map(e=>e.cwd).join(`|`)}`).join(`;`),()=>{for(let e of Cu.devices.value){if(e.status!==`online`||!e.tree?.sessions.length)continue;let t=Date.now();t-(of.get(e.id)??0)<6e4||(of.set(e.id,t),Zd(e.id,e.tree.sessions.map(e=>e.cwd)))}},{immediate:!0})}var cf=(e,t)=>nf(e,t).status?.branch,lf=[`aria-level`,`aria-expanded`,`aria-selected`,`data-key`,`title`],uf=[`aria-label`],df={key:1,class:`chev`},ff={class:`name`},pf={class:`badge`},mf=[`title`],hf=[`aria-label`],gf=[`disabled`,`aria-label`],_f=[`aria-label`],vf=[`checked`,`aria-label`],yf={class:`name`},bf={class:`path`},xf=[`title`],Sf=[`title`],Cf={key:3,class:`dot work`,title:`Working`},wf=[`title`],Tf=[`disabled`,`aria-label`],Ef=[`disabled`,`aria-label`],Df=[`disabled`,`aria-label`],Of=[`disabled`,`aria-label`],kf={class:`name`},Af={key:3,class:`meta`},jf={key:4,class:`dot work`,title:`Working`},Mf=[`title`],Nf=[`disabled`,`aria-label`],Pf=Vd(N({__name:`TreeRow`,props:{node:{},depth:{},open:{type:Boolean},selected:{type:Boolean},focused:{type:Boolean},online:{type:Boolean},checkbox:{type:Boolean},checked:{type:Boolean}},emits:[`toggle`,`activate`,`action`,`check`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>n.node.children.length>0),a=U(()=>n.node.type===`device`?n.node.device:void 0),o=U(()=>n.node.type===`session`?n.node.session:void 0),s=U(()=>n.node.type===`agent`?n.node.agent:void 0),c=U(()=>o.value?o.value.agents.reduce((e,t)=>e+t.background,0):s.value?.background??0),l=U(()=>o.value?.busy||s.value?.busy),u=U(()=>{let e=a.value?.info,t=e?.packageVersion??e?.durableVersion,n=Tu.value;return!!(t&&n&&n!==`unknown`&&t!==n)}),d=U(()=>{let e=a.value?.info;return e?.packageVersion??e?.durableVersion??`?`}),f=U(()=>{let e=a.value;if(!e)return``;let t=e.tree?.sessions.length??0;switch(e.status){case`online`:return`${t} session${t===1?``:`s`}`;case`checking`:return`checking…`;case`unauthorized`:return e.hasToken?`token rejected`:`no token`;case`mismatch`:return`identity changed`;case`incompatible`:return`incompatible`;default:return`offline · ${hd(e.lastSeenAt)}`}}),p=U(()=>{let e=a.value?.status;return e===`online`?`on`:e===`checking`?`chk`:e===`offline`?`off`:`err`}),m=U(()=>{let e=n.node;return e.type===`session`?cf(e.deviceId,e.session.cwd):void 0}),h=U(()=>a.value?.name??a.value?.id??o.value?.name??s.value?.name??``),g=U(()=>{if(a.value){let e=a.value;return`${e.name}${e.url?` · ${e.url}`:``}${e.error?`\n${e.error}`:``}`}if(o.value)return`${o.value.name}\n${o.value.cwd}`;let e=s.value;return e.kind===`fork`?`Fork of agent #${e.parentId} at entry #${e.forkedAt}`:e.kind===`subagent`?`Subagent owned by agent #${e.ownerAgentId}`:`Root agent`});return(t,n)=>(I(),L(`div`,{class:E([`tree-row`,[e.node.type,{sel:e.selected,focus:e.focused,stale:e.node.stale}]]),style:ge({"--depth":e.depth}),role:`treeitem`,"aria-level":e.depth+1,"aria-expanded":i.value?e.open:void 0,"aria-selected":e.selected,"data-key":e.node.key,title:g.value,onClick:n[14]||=e=>r(`activate`)},[i.value?(I(),L(`button`,{key:0,class:`chev`,tabindex:`-1`,"aria-label":e.open?`Collapse ${h.value}`:`Expand ${h.value}`,onClick:n[0]||=ks(e=>r(`toggle`),[`stop`])},[e.open?(I(),R(A(nc),{key:0,size:16})):(I(),R(A(rc),{key:1,size:16}))],8,uf)):(I(),L(`span`,df)),a.value?(I(),L(F,{key:2},[z(`i`,{class:E([`dot`,p.value])},null,2),B(Jd,{device:a.value,size:16},null,8,[`device`]),z(`b`,ff,D(h.value),1),z(`span`,pf,D(a.value.kind),1),u.value?(I(),L(`span`,{key:0,class:`tag update`,title:`device runs ${d.value}; hub runs ${A(Tu)}. Devices self-update: dpi update`},`update`,8,mf)):H(``,!0),z(`span`,{class:E([`meta`,{err:p.value===`err`}])},D(f.value),3),z(`span`,{class:`acts`,onClick:n[4]||=ks(()=>{},[`stop`])},[a.value.pairing?(I(),L(`button`,{key:0,class:`icon-button`,"aria-label":`Manage credentials for ${h.value}`,title:`Manage device credentials, including while offline`,onClick:n[1]||=e=>r(`action`,`credentials`)},[B(A(kc),{size:16})],8,hf)):H(``,!0),z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New session on ${h.value}`,title:`New session on this device`,onClick:n[2]||=e=>r(`action`,`new-session`)},[B(A(Xc),{size:16})],8,gf),z(`button`,{class:`icon-button`,"aria-label":`Check ${h.value}`,title:`Check connection now`,onClick:n[3]||=e=>r(`action`,`check`)},[B(A($c),{size:16})],8,_f)])],64)):o.value?(I(),L(F,{key:3},[e.checkbox?(I(),L(`input`,{key:0,type:`checkbox`,class:`bulk-check`,checked:e.checked,"aria-label":`Select ${h.value}`,tabindex:`-1`,onClick:n[5]||=ks(()=>{},[`stop`]),onChange:n[6]||=e=>r(`check`)},null,40,vf)):H(``,!0),B(A(yc),{class:`ico`,size:16}),z(`b`,yf,D(h.value),1),z(`span`,bf,`…/`+D(o.value.cwd.split(`/`).filter(Boolean).at(-1)),1),m.value?(I(),L(`span`,{key:1,class:`branch`,title:`git branch of ${o.value.cwd}`},`⎇ `+D(m.value),9,xf)):H(``,!0),o.value.model?(I(),L(`span`,{key:2,class:`tag`,title:o.value.provider?`${o.value.provider} / ${o.value.model}`:o.value.model},D(o.value.model),9,Sf)):H(``,!0),l.value?(I(),L(`i`,Cf)):H(``,!0),c.value?(I(),L(`span`,{key:4,class:`bg-count`,title:`${c.value} background task(s)`},[n[15]||=z(`i`,{class:`dot bg`},null,-1),V(D(c.value)+` bg`,1)],8,wf)):H(``,!0),z(`span`,{class:`acts`,onClick:n[11]||=ks(()=>{},[`stop`])},[z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New agent in ${h.value}`,title:`New agent in this session`,onClick:n[7]||=e=>r(`action`,`new-agent`)},[B(A(Xc),{size:16})],8,Tf),z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename session ${h.value}`,title:`Rename session`,onClick:n[8]||=e=>r(`action`,`rename`)},[B(A(qc),{size:16})],8,Ef),z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New worktree session from ${h.value}`,title:`New worktree session: branch this folder's repo and open a session in the sibling checkout`,onClick:n[9]||=e=>r(`action`,`worktree`)},[B(A(ul),{size:16})],8,Df),z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Archive session ${h.value}`,title:`Archive session`,onClick:n[10]||=e=>r(`action`,`archive`)},[B(A(Us),{size:16})],8,Of)])],64)):s.value?(I(),L(F,{key:4},[s.value.kind===`fork`?(I(),R(A(Cc),{key:0,class:`ico`,size:16})):s.value.kind===`subagent`?(I(),R(A(cc),{key:1,class:`ico`,size:16})):(I(),R(A(Lc),{key:2,class:`ico root`,size:16})),z(`span`,kf,D(h.value),1),s.value.kind===`fork`&&s.value.forkedAt!==void 0?(I(),L(`span`,Af,`@ #`+D(s.value.forkedAt),1)):H(``,!0),l.value?(I(),L(`i`,jf)):H(``,!0),c.value?(I(),L(`span`,{key:5,class:`bg-count`,title:`${c.value} background task(s)`},[n[16]||=z(`i`,{class:`dot bg`},null,-1),V(D(c.value),1)],8,Mf)):H(``,!0),z(`span`,{class:`acts`,onClick:n[13]||=ks(()=>{},[`stop`])},[z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename agent ${h.value}`,title:`Rename agent`,onClick:n[12]||=e=>r(`action`,`rename`)},[B(A(qc),{size:16})],8,Nf)])],64)):H(``,!0)],14,lf))}}),[[`__scopeId`,`data-v-ec99cf9d`]]),Ff={class:`project-bar`,"aria-label":`Projects`},If={class:`project-head`},Lf={class:`project-title`},Rf=[`aria-label`,`title`],zf={key:0,class:`project-hint`},Bf={key:0,class:`chips`},Vf=[`title`,`onClick`,`onDblclick`],Hf={class:`chip-name`},Uf={class:`chip-count`},Wf={key:1,class:`project-hint`},Gf={key:2,class:`project-actions`},Kf=[`onClick`],qf=[`onClick`],Jf=[`onClick`],Yf=[`onClick`],Xf={key:3,class:`message-error`},Zf={key:4,class:`project-hint labels-hint`},Qf=Vd(N({__name:`ProjectBar`,props:{active:{},activeModifiers:{}},emits:[`update:active`],setup(e,{expose:t}){let n=Di(e,`active`),r=k([]),i=k(!1),a=k(``),o=k(!1),s=U(()=>Cu.devices.value.filter(e=>e.status===`online`).map(e=>e.id));async function c(){i.value=!0,a.value=``;let e=[],t=[];for(let n of s.value){let r=Cu.devices.value.find(e=>e.id===n),i=await G(n).projects(o.value).catch(e=>{let r=K(e);e.code===`not_found`||/allowlist|not found/i.test(r)||t.push(`${n}: ${r.slice(0,60)}`)});for(let t of i?.projects??[]){let i=(r?.tree?.sessions??[]).filter(e=>e.cwd===t.rootPath||e.cwd.startsWith(`${t.rootPath}/`)).length;e.push({deviceId:n,project:t,sessions:i})}}r.value=e.sort((e,t)=>l(e.project).localeCompare(l(t.project))),t.length&&(a.value=t.join(` · `)),i.value=!1}M([s,o],c,{immediate:!0});let l=e=>e.customName??e.name,u=e=>n.value?.deviceId===e.deviceId&&n.value.rootPath===e.project.rootPath;function d(e){n.value=u(e)?void 0:{deviceId:e.deviceId,rootPath:e.project.rootPath}}function f(e){let t=e.project;J.dialog={kind:`prompt`,title:`Rename ${l(t)}`,label:`Project name`,hint:`Shown in the tree and in usage rollups. Leave empty to use the folder name.`,value:t.customName??``,placeholder:t.name,submit:`Save name`,run:async n=>{let r=await G(e.deviceId).updateProject(t.id,{customName:n});Y(`Project renamed to ${r.customName??r.name}.`),await c()}}}function p(e){let t=e.project;J.dialog={kind:`prompt`,title:`Labels for ${l(t)}`,label:`Labels (comma separated)`,hint:`Lowercase, up to 12 labels of 32 characters. Used to filter projects.`,value:t.labels.join(`, `),submit:`Save labels`,run:async n=>{let r=await G(e.deviceId).updateProject(t.id,{labels:n.split(`,`).map(e=>e.trim()).filter(Boolean)});Y(r.labels.length?`Labels: ${r.labels.join(`, `)}.`:`Labels cleared on ${l(r)}.`),await c()}}}function m(e){let t=e.project,n=Cu.devices.value.find(t=>t.id===e.deviceId)?.info?.models??[];J.dialog={kind:`prompt`,title:`Default model for ${l(t)}`,label:`Model (provider/modelId)`,hint:n.length?`New sessions in this project start on this model instead of the device default. Leave empty to use the device default. E.g. ${n[0].provider}/${n[0].id}`:`New sessions in this project start on this model. Leave empty to use the device default.`,value:t.model?`${t.model.provider}/${t.model.modelId}`:``,placeholder:`device default`,submit:`Save default model`,run:async r=>{if(!r.trim()){await G(e.deviceId).updateProject(t.id,{model:``}),Y(`Default model cleared on ${l(t)}.`),await c();return}let[i,...a]=r.trim().split(`/`),o=a.join(`/`),s=n.some(e=>e.provider===i&&e.id===o);if(!i||!o)throw Error(`Format: provider/modelId`);if(!s)throw Error(`${r.trim()} is not in this device's catalog`);await G(e.deviceId).updateProject(t.id,{model:{provider:i,modelId:o}}),Y(`New sessions in ${l(t)} start on ${o}.`),await c()}}}function h(e){let t=e.project,r=t.archivedAt!==null;J.dialog={kind:`prompt`,title:`${r?`Restore`:`Archive`} ${l(t)}?`,hint:r?`The project returns to the tree. Its sessions were never touched.`:`Bookkeeping only: the project leaves the list, its sessions keep running. Nothing is deleted.`,submit:r?`Restore project`:`Archive project`,danger:!r,run:async()=>{let i=G(e.deviceId);r?await i.unarchiveProject(t.id):await g(i,t.id),!r&&u(e)&&(n.value=void 0),await c()}}}let g=(e,t)=>e.archiveProject(t);return t({reload:c}),(e,t)=>(I(),L(`div`,Ff,[z(`div`,If,[z(`span`,Lf,[B(A(vc),{size:13}),t[2]||=V(`PROJECTS`,-1)]),z(`button`,{class:E([`icon-button tiny`,{on:o.value}]),"aria-label":o.value?`Hide archived projects`:`Show archived projects`,title:o.value?`Hide archived projects`:`Show archived projects`,onClick:t[0]||=e=>o.value=!o.value},[B(A(Us),{size:12})],10,Rf),i.value?(I(),L(`span`,zf,`…`)):H(``,!0)]),r.value.length?(I(),L(`div`,Bf,[(I(!0),L(F,null,P(r.value,e=>(I(),L(`button`,{key:`${e.deviceId}-${e.project.id}`,class:E([`chip`,{on:u(e),archived:e.project.archivedAt}]),title:`${e.project.rootPath} — ${e.sessions} session${e.sessions===1?``:`s`}`,onClick:t=>d(e),onDblclick:t=>f(e)},[e.project.kind===`plain`?(I(),R(A(bc),{key:0,size:11})):(I(),R(A(vc),{key:1,size:11})),z(`span`,Hf,D(l(e.project)),1),z(`em`,Uf,D(e.sessions),1),(I(!0),L(F,null,P(e.project.labels.slice(0,2),e=>(I(),L(`span`,{key:e,class:`chip-label`},D(e),1))),128))],42,Vf))),128))])):i.value?H(``,!0):(I(),L(`p`,Wf,` No projects yet — a project appears when a session starts in a folder. `)),n.value?(I(),L(`div`,Gf,[t[5]||=z(`span`,{class:`project-hint`},`filtering`,-1),(I(!0),L(F,null,P(r.value.filter(u),e=>(I(),L(F,{key:e.project.id},[z(`button`,{class:`small`,onClick:t=>f(e)},[B(A(qc),{size:12}),t[3]||=V(`name`,-1)],8,Kf),z(`button`,{class:`small`,onClick:t=>p(e)},[B(A(fl),{size:12}),t[4]||=V(`labels`,-1)],8,qf),z(`button`,{class:`small`,onClick:t=>m(e),title:`Default model for new sessions in this project`},[B(A(dc),{size:12}),V(D(e.project.model?`model ✓`:`model`),1)],8,Jf),z(`button`,{class:`small`,onClick:t=>h(e)},[e.project.archivedAt?(I(),R(A(Hs),{key:0,size:12})):(I(),R(A(Us),{key:1,size:12})),V(` `+D(e.project.archivedAt?`restore`:`archive`),1)],8,Yf),z(`button`,{class:`icon-button tiny`,"aria-label":`Clear project filter`,onClick:t[1]||=e=>n.value=void 0},[B(A(xl),{size:12})])],64))),128))])):H(``,!0),a.value?(I(),L(`p`,Xf,D(a.value),1)):H(``,!0),r.value.some(e=>e.project.labels.length)?(I(),L(`p`,Zf,[B(A(fl),{size:11}),V(`labels: `+D([...new Set(r.value.flatMap(e=>e.project.labels))].join(` · `)),1)])):H(``,!0)]))}}),[[`__scopeId`,`data-v-77864963`]]);function $f(e,t){return`${e.slice(0,e.lastIndexOf(`/`))}/${e.slice(e.lastIndexOf(`/`)+1)}-${t.replace(/[/\\]+/g,`-`)}`}async function ep(e,t,n,r){let i=$f(n,r);return{target:i,text:(await e.gitOp(t,`worktree-add`,{branch:r,target:i})).text.split(`
16
- `)[0]??`worktree ${i}`}}async function tp(e,t,n,r){return e.createSession(r?{name:n,cwd:t,model:r}:{name:n,cwd:t})}async function np({deviceApi:e,cwd:t,sessionName:n,branch:r,root:i,source:a,catalog:o,defaultModel:s}){let c=i;if(!c){let n=await e.gitStatus(t);if(!n.repo||!n.root)throw Error(`${t} is not a git repository`);c=n.root}let{target:l}=await ep(e,t,c,r),{model:u,provider:d}=a??{},f=u&&d&&(!o||o.some(e=>e.provider===d&&e.id===u))?{provider:d,modelId:u}:void 0,p=o?.length?o.find(e=>`${e.provider}/${e.id}`===s)??o[0]:void 0;return tp(e,l,n,f??(p?{provider:p.provider,modelId:p.id}:void 0))}var rp={class:`tree-head`},ip=[`aria-label`,`title`],ap=[`title`],op={class:`tree-search`},sp={key:1,class:`searching`,"aria-label":`Searching devices`},cp={key:0,class:`bulk-bar`},lp=[`disabled`],up=[`disabled`],dp={class:`hit-head hint`},fp=[`title`,`onClick`],pp={class:`hit-name`},mp={class:`hit-cwd`},hp={key:0,class:`hit-where`},gp={key:2,class:`hint tree-empty`},_p={key:3,class:`hint tree-empty`,"data-testid":`tree-empty`},vp={key:1,class:`panel-rail`,"aria-label":`Network (collapsed)`},yp=[`title`],bp=[`title`,`aria-label`,`onClick`],xp=Vd(N({__name:`NetworkSidebar`,setup(e){let t=U(()=>{let e=[],t=(n,r,i)=>{for(let a of n)e.push({node:a,depth:r,parent:i}),a.children.length&&Eu.value.has(a.key)&&t(a.children,r+1,a.key)};return t(Cu.tree.value,0),e}),n=k(),r=k(),i=k(``),a=k([]),o=k(!1),s=U(()=>i.value.trim().toLowerCase()),c=U(()=>s.value.length>=2),l=U(()=>{let e=new Set;if(!c.value)return e;for(let t of Cu.devices.value)for(let n of t.tree?.sessions??[])`${n.name}\n${n.cwd}`.toLowerCase().includes(s.value)&&e.add(n.id);return e}),u=k(),d=(e,t)=>!u.value||u.value.deviceId===e&&(t===u.value.rootPath||t.startsWith(`${u.value.rootPath}/`)),f=U(()=>{if(!c.value&&!u.value)return t.value;let e=e=>{if(u.value){let t=e.type===`device`?e.device.id:e.deviceId;if(e.type===`session`&&!d(t,e.session.cwd))return!1;if(e.type===`agent`){let t=Cu.devices.value.find(t=>t.id===e.deviceId)?.tree?.sessions.find(t=>t.id===e.sessionId);if(t&&!d(e.deviceId,t.cwd))return!1}if(e.type===`device`)return(e.device.tree?.sessions??[]).some(t=>d(e.device.id,t.cwd))}return c.value?e.type===`session`?l.value.has(e.session.id):e.type===`agent`?l.value.has(e.sessionId)||e.agent.name.toLowerCase().includes(s.value):(e.device.tree?.sessions??[]).some(e=>l.value.has(e.id)):!0},n=new Set(t.value.filter(t=>e(t.node)).map(e=>e.node.key));return t.value.filter(e=>n.has(e.node.key))}),p=U(()=>a.value.filter(e=>!t.value.some(t=>t.node.type===`session`&&t.node.session.id===e.id))),m;M(i,e=>{clearTimeout(m);let t=e.trim();if(t.length<2){a.value=[],o.value=!1;return}m=setTimeout(async()=>{o.value=!0;let e=[];for(let n of Cu.devices.value.filter(e=>e.status===`online`)){let r=await G(n.id).searchSessions(t).catch(()=>void 0);for(let t of r?.matches??[])e.push({deviceId:n.id,id:t.id,name:t.name,cwd:t.cwd,where:t.where})}a.value=e,o.value=!1},250)});let h=()=>(i.value=``,a.value=[]),g=k(!1),_=k(new Set),v=k(``),y=e=>{if(e.type!==`session`)return;let t=new Set(_.value);t.has(e.session.id)?t.delete(e.session.id):t.add(e.session.id),_.value=t},b=async e=>{v.value=e;let n=0,r=[];for(let i of t.value.map(e=>e.node)){if(i.type!==`session`||!_.value.has(i.session.id))continue;let t=x(i);if(!t)continue;let a=G(t.id);try{e===`archive`?await a.session(i.session.id).archive():await a.agent(i.session.id,1).abort(!0),n++,e===`archive`&&q.value?.sessionId===i.session.id&&Bu(void 0)}catch{r.push(i.session.name)}}Y(`${e}: ${n} done${r.length?`, ${r.length} failed (${r.slice(0,3).join(`, `)})`:``}`),_.value=new Set,v.value=``},x=e=>Cu.devices.value.find(t=>t.id===(e.type===`device`?e.device.id:e.deviceId)),S=e=>x(e)?.status===`online`,C=e=>e.type===`agent`&&q.value?.deviceId===e.deviceId&&q.value.sessionId===e.sessionId&&q.value.agentId===e.agent.id;function ee(e){if(n.value=e.key,g.value&&e.type===`session`)return y(e);if(e.type===`device`)return Uu(e.key);if(e.type===`agent`)return Bu({deviceId:e.deviceId,sessionId:e.sessionId,agentId:e.agent.id});let t=e.session.agents.find(e=>e.kind===`root`)??e.session.agents[0];Uu(e.key,!0),t&&Bu({deviceId:e.deviceId,sessionId:e.session.id,agentId:t.id})}async function w(e,t){let n=x(e);if(!n)return;let r=G(n.id);if(e.type===`device`){t===`new-session`?J.dialog={kind:`new-session`,deviceId:n.id}:t===`check`?await ud(()=>du.check(n.id)):t===`credentials`&&(J.dialog={kind:`credentials`,deviceId:n.id});return}if(e.type===`session`){let i=e.session;if(t===`new-agent`){let e=await ud(()=>r.session(i.id).createAgent({name:`Agent ${i.agents.length+1}`}));e&&(Bu({deviceId:n.id,sessionId:i.id,agentId:e.id}),Y(`New agent. Same session, same shared App State.`))}else t===`rename`?J.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:i.name,submit:`Save name`,run:e=>r.session(i.id).rename(e)}:t===`worktree`?J.dialog={kind:`prompt`,title:`New worktree session`,label:`Branch name`,value:i.name.replace(/[/\\]+/g,`-`),hint:`Adds a sibling checkout of ${i.cwd} on the branch (git worktree add) and opens a session in it.`,submit:`Create worktree session`,run:async e=>{let t=await np({deviceApi:r,cwd:i.cwd,sessionName:e,branch:e,source:i,catalog:n.info?.models,defaultModel:n.info?.defaultModel}),a=t.agents.find(e=>e.kind===`root`)??t.agents[0];Bu({deviceId:n.id,sessionId:t.id,agentId:a?.id??1}),Y(`session "${t.name}" on ${t.cwd}`)}}:t===`archive`&&(J.dialog={kind:`prompt`,title:`Archive ${i.name}?`,hint:`Stops all of its work and moves its files to archive/ on ${n.id}. Nothing is deleted.`,submit:`Archive session`,danger:!0,run:async()=>{await r.session(i.id).archive(),q.value?.sessionId===i.id&&Bu(void 0)}});return}let i=e.agent;t===`rename`&&(J.dialog={kind:`prompt`,title:`Rename agent`,label:`Agent name`,value:i.named?i.name:``,placeholder:i.name,submit:`Save name`,run:t=>r.agent(e.sessionId,i.id).rename(t)})}function T(e){let i=t.value.findIndex(e=>e.node.key===n.value),a=t.value[Math.max(0,Math.min(t.value.length-1,(i<0?0:i)+e))];a&&(n.value=a.node.key,An(()=>r.value?.querySelector(`[data-key="${CSS.escape(a.node.key)}"]`)?.scrollIntoView({block:`nearest`})))}function te(){n.value??=t.value[0]?.node.key}function ne(e){let r=t.value.find(e=>e.node.key===n.value);if(e.key===`ArrowDown`)T(1);else if(e.key===`ArrowUp`)T(-1);else if(e.key===`ArrowRight`&&r){if(!r.node.children.length)return;Eu.value.has(r.node.key)?T(1):Uu(r.node.key,!0)}else if(e.key===`ArrowLeft`&&r)r.node.children.length&&Eu.value.has(r.node.key)?Uu(r.node.key,!1):r.parent&&(n.value=r.parent);else if((e.key===`Enter`||e.key===` `)&&r)ee(r.node);else return;e.preventDefault()}return(e,a)=>(I(),L(`aside`,{class:E([`network-sidebar`,{open:A(J).drawer,collapsed:!A(Ou).tree&&!A(J).drawer}]),"aria-label":`Network`},[A(Ou).tree||A(J).drawer?(I(),L(F,{key:0},[z(`header`,rp,[z(`span`,null,[B(A(Bc),{size:16}),a[8]||=V(`NETWORK`,-1)]),z(`button`,{class:E([`icon-button`,{on:g.value}]),"aria-label":g.value?`Exit bulk select`:`Bulk manage sessions`,title:g.value?`Exit bulk select`:`Bulk manage sessions (select → archive / abort)`,onClick:a[0]||=e=>(g.value=!g.value,_.value=new Set)},[B(A(Pc),{size:15})],10,ip),z(`button`,{class:`icon-button`,"aria-label":`Pair a device`,title:`Pair a device`,onClick:a[1]||=e=>A(J).dialog={kind:`pair`}},[B(A(Nc),{size:15})]),z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse network`,title:`Collapse network (${A(Ed).tree})`,onClick:a[2]||=e=>(A(Ou).tree=!1,A(J).drawer=!1)},[B(A(Uc),{size:18})],8,ap)]),z(`div`,op,[B(A(nl),{size:14,class:`search-icon`}),j(z(`input`,{"onUpdate:modelValue":a[3]||=e=>i.value=e,type:`search`,class:`search-input`,placeholder:`Search sessions…`,"aria-label":`Search sessions`,spellcheck:`false`},null,512),[[ys,i.value]]),i.value?(I(),L(`button`,{key:0,class:`icon-button clear`,"aria-label":`Clear search`,onClick:h},[B(A(xl),{size:13})])):H(``,!0),o.value?(I(),L(`span`,sp,`…`)):H(``,!0)]),B(Qf,{active:u.value,"onUpdate:active":a[4]||=e=>u.value=e},null,8,[`active`]),z(`div`,{ref_key:`list`,ref:r,class:`tree-list`,role:`tree`,tabindex:`0`,"aria-label":`Devices, sessions and agents`,onKeydown:ne,onFocus:te},[g.value&&_.value.size?(I(),L(`div`,cp,[z(`span`,null,D(_.value.size)+` selected`,1),z(`button`,{class:`small`,disabled:!!v.value,onClick:a[5]||=e=>b(`abort`)},`abort work`,8,lp),z(`button`,{class:`small danger`,disabled:!!v.value,onClick:a[6]||=e=>b(`archive`)},D(v.value===`archive`?`archiving…`:`archive`),9,up)])):H(``,!0),(I(!0),L(F,null,P(f.value,e=>(I(),R(Pf,{key:e.node.key,node:e.node,depth:e.depth,open:A(Eu).has(e.node.key),selected:C(e.node),focused:n.value===e.node.key,online:S(e.node),checkbox:g.value&&e.node.type===`session`,checked:e.node.type===`session`&&_.value.has(e.node.session.id),onToggle:t=>A(Uu)(e.node.key),onActivate:t=>ee(e.node),onAction:t=>w(e.node,t),onCheck:t=>y(e.node)},null,8,[`node`,`depth`,`open`,`selected`,`focused`,`online`,`checkbox`,`checked`,`onToggle`,`onActivate`,`onAction`,`onCheck`]))),128)),c.value&&p.value.length?(I(),L(F,{key:1},[z(`div`,dp,D(p.value.length)+` more on device`,1),(I(!0),L(F,null,P(p.value,e=>(I(),L(`button`,{key:`${e.deviceId}-${e.id}`,class:`hit`,title:e.cwd,onClick:t=>A(Bu)({deviceId:e.deviceId,sessionId:e.id,agentId:1})},[z(`span`,pp,D(e.name),1),z(`code`,mp,D(e.cwd),1),e.where.length?(I(),L(`em`,hp,D(e.where.join(` · `)),1)):H(``,!0)],8,fp))),128))],64)):H(``,!0),c.value&&!f.value.length&&!p.value.length?(I(),L(`p`,gp,` No session matches “`+D(i.value.trim())+`”. `,1)):H(``,!0),!t.value.length&&!c.value?(I(),L(`p`,_p,[...a[9]||=[V(` No devices yet. Declare them in `,-1),z(`code`,null,`dpi-network.yaml`,-1),V(` (start from `,-1),z(`code`,null,`dpi-network.example.yaml`,-1),V(`), then run `,-1),z(`code`,null,`just net up <id>`,-1),V(`. `,-1)]])):H(``,!0)],544)],64)):(I(),L(`div`,vp,[z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand network`,title:`Expand network (${A(Ed).tree})`,onClick:a[7]||=e=>A(Ou).tree=!0},[B(A(Wc),{size:18})],8,yp),(I(!0),L(F,null,P(A(Cu).devices.value,e=>(I(),L(`button`,{key:e.id,class:`rail-device`,title:`${e.id} · ${e.status}`,"aria-label":`Show ${e.id}`,onClick:t=>(A(Ou).tree=!0,A(Uu)(e.id,!0))},[B(Jd,{device:e,size:20},null,8,[`device`]),z(`i`,{class:E([`dot`,e.status===`online`?`on`:e.status===`checking`?`chk`:e.status===`offline`?`off`:`err`])},null,2)],8,bp))),128))]))],2))}}),[[`__scopeId`,`data-v-b75a54cc`]]);function Sp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Cp=Sp();function wp(e){Cp=e}var Tp={exec:()=>null};function Ep(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Op.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Dp=(()=>{try{return!0}catch{return!1}})(),Op={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,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ 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,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},kp=/^(?:[ \t]*(?:\n|$))+/,Ap=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jp=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mp=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Np=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Fp=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ip=Ep(Fp).replace(/bull/g,Pp).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(),Lp=Ep(Fp).replace(/bull/g,Pp).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(),Rp=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,zp=/^[^\n]+/,Bp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Vp=Ep(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Bp).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Hp=Ep(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Pp).getRegex(),Up=`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`,Wp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gp=Ep(`^ {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`,Wp).replace(`tag`,Up).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Kp=Ep(Rp).replace(`hr`,Mp).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[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Up).getRegex(),qp={blockquote:Ep(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Kp).getRegex(),code:Ap,def:Vp,fences:jp,heading:Np,hr:Mp,html:Gp,lheading:Ip,list:Hp,newline:kp,paragraph:Kp,table:Tp,text:zp},Jp=Ep(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Mp).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[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Up).getRegex(),Yp={...qp,lheading:Lp,table:Jp,paragraph:Ep(Rp).replace(`hr`,Mp).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Jp).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Up).getRegex()},Xp={...qp,html:Ep(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Wp).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:Tp,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ep(Rp).replace(`hr`,Mp).replace(`heading`,` *#{1,6} *[^
17
- ]`).replace(`lheading`,Ip).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Zp=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Qp=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$p=/^( {2,}|\\)\n(?!\s*$)/,em=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,tm=/[\p{P}\p{S}]/u,nm=/[\s\p{P}\p{S}]/u,rm=/[^\s\p{P}\p{S}]/u,im=Ep(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,nm).getRegex(),am=/(?!~)[\p{P}\p{S}]/u,om=/(?!~)[\s\p{P}\p{S}]/u,sm=/(?:[^\s\p{P}\p{S}]|~)/u,cm=Ep(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Dp?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),lm=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,um=Ep(lm,`u`).replace(/punct/g,tm).getRegex(),dm=Ep(lm,`u`).replace(/punct/g,am).getRegex(),fm=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,pm=Ep(fm,`gu`).replace(/notPunctSpace/g,rm).replace(/punctSpace/g,nm).replace(/punct/g,tm).getRegex(),mm=Ep(fm,`gu`).replace(/notPunctSpace/g,sm).replace(/punctSpace/g,om).replace(/punct/g,am).getRegex(),hm=Ep(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,rm).replace(/punctSpace/g,nm).replace(/punct/g,tm).getRegex(),gm=Ep(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,tm).getRegex(),_m=Ep(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,rm).replace(/punctSpace/g,nm).replace(/punct/g,tm).getRegex(),vm=Ep(/\\(punct)/,`gu`).replace(/punct/g,tm).getRegex(),ym=Ep(/^<(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(),bm=Ep(Wp).replace(`(?:-->|$)`,`-->`).getRegex(),xm=Ep(`^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`,bm).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Sm=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Cm=Ep(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Sm).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),wm=Ep(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Sm).replace(`ref`,Bp).getRegex(),Tm=Ep(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Bp).getRegex(),Em=Ep(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,wm).replace(`nolink`,Tm).getRegex(),Dm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Om={_backpedal:Tp,anyPunctuation:vm,autolink:ym,blockSkip:cm,br:$p,code:Qp,del:Tp,delLDelim:Tp,delRDelim:Tp,emStrongLDelim:um,emStrongRDelimAst:pm,emStrongRDelimUnd:hm,escape:Zp,link:Cm,nolink:Tm,punctuation:im,reflink:wm,reflinkSearch:Em,tag:xm,text:em,url:Tp},km={...Om,link:Ep(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Sm).getRegex(),reflink:Ep(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Sm).getRegex()},Am={...Om,emStrongRDelimAst:mm,emStrongLDelim:dm,delLDelim:gm,delRDelim:_m,url:Ep(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Dm).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\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Ep(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Dm).getRegex()},jm={...Am,br:Ep($p).replace(`{2,}`,`*`).getRegex(),text:Ep(Am.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Mm={normal:qp,gfm:Yp,pedantic:Xp},Nm={normal:Om,gfm:Am,breaks:jm,pedantic:km},Pm={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Fm=e=>Pm[e];function Im(e,t){if(t){if(Op.escapeTest.test(e))return e.replace(Op.escapeReplace,Fm)}else if(Op.escapeTestNoEncode.test(e))return e.replace(Op.escapeReplaceNoEncode,Fm);return e}function Lm(e){try{e=encodeURI(e).replace(Op.percentDecode,`%`)}catch{return null}return e}function Rm(e,t){let n=e.replace(Op.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Op.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(Op.slashPipe,`|`);return n}function zm(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Bm(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Vm(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Hm(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Um(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
15
+ `),id:n}:void 0}var iu=encodeURIComponent,au=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,ou=e=>e.normalize(`NFKD`).replace(/[^\w.-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60).toLowerCase()||`session`,su=class{token;hooks;baseUrl;constructor(e,t,n={}){this.token=t,this.hooks=n,this.baseUrl=e.replace(/\/+$/,``)}headers(e,t={}){return{...this.token?{authorization:`Bearer ${this.token}`,"x-dpi-token":this.token}:{},...e?{"content-type":`application/json`}:{},...t}}async request(e,t,n,r={}){let i=AbortSignal.timeout(r.timeoutMs??2e4),a=r.signal?AbortSignal.any([r.signal,i]):i,o;try{o=await fetch(this.baseUrl+t,{method:e,signal:a,headers:this.headers(n!==void 0,r.idempotencyKey?{"idempotency-key":r.idempotencyKey}:{}),body:n===void 0?void 0:JSON.stringify(n)})}catch(e){throw r.signal?.aborted?e:new Sl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}let s=await o.text(),c;try{c=s?JSON.parse(s):void 0}catch{c=void 0}if(!o.ok){let e=c?.error;throw new Sl(e?.code??(o.status===401?`unauthorized`:o.status===404?`not_found`:`internal`),e?.message??`${o.status} ${o.statusText}`,o.status)}return o.headers.get(`idempotent-replay`)===`true`&&this.hooks.onIdempotentReplay?.(t),c}async*stream(e,t,n){let r;try{r=await fetch(this.baseUrl+e,{headers:{...this.headers(!1),accept:`text/event-stream`},signal:t})}catch(e){if(t.aborted)return;throw new Sl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}if(!r.ok||!r.body){let e=await r.json().catch(()=>void 0);throw new Sl(e?.error?.code??(r.status===401?`unauthorized`:`unavailable`),e?.error?.message??`Stream failed (${r.status})`,r.status)}try{for await(let e of nu(r.body,n))yield JSON.parse(e.data)}catch(e){if(t.aborted)return;throw e}}device(e){return this.request(`GET`,`/v1/device`,void 0,e)}vitals(){return this.request(`GET`,`/v1/device/vitals`)}tree(){return this.request(`GET`,`/v1/tree`)}projects(e=!1){return this.request(`GET`,`/v1/projects${e?`?includeArchived=1`:``}`)}updateProject(e,t){return this.request(`PATCH`,`/v1/projects/${iu(e)}`,t)}archiveProject(e){return this.request(`POST`,`/v1/projects/${iu(e)}/archive`,{})}unarchiveProject(e){return this.request(`POST`,`/v1/projects/${iu(e)}/unarchive`,{})}notifySinks(){return this.request(`GET`,`/v1/notify/sinks`)}createNotifySink(e){return this.request(`POST`,`/v1/notify/sinks`,e)}updateNotifySink(e,t){return this.request(`PATCH`,`/v1/notify/sinks/${iu(e)}`,t)}removeNotifySink(e){return this.request(`DELETE`,`/v1/notify/sinks/${iu(e)}`)}testNotifySinks(){return this.request(`POST`,`/v1/notify/test`,{})}envView(){return this.request(`GET`,`/v1/device/env`)}setEnvVar(e,t){return this.request(`POST`,`/v1/device/env`,{key:e,value:t})}removeEnvVar(e){return this.request(`DELETE`,`/v1/device/env/${iu(e)}`)}piAuth(){return this.request(`GET`,`/v1/device/pi-auth`)}setPiApiKey(e,t){return this.request(`PUT`,`/v1/device/pi-auth/${iu(e)}`,{key:t})}removePiApiKey(e){return this.request(`DELETE`,`/v1/device/pi-auth/${iu(e)}`)}graphs(){return this.request(`GET`,`/v1/graphs`)}graph(e){return this.request(`GET`,`/v1/graphs/${iu(e)}`)}createGraph(e){return this.request(`POST`,`/v1/graphs`,e)}runGraph(e){return this.request(`POST`,`/v1/graphs/${iu(e)}/run`,{})}removeGraph(e){return this.request(`DELETE`,`/v1/graphs/${iu(e)}`)}schedules(){return this.request(`GET`,`/v1/schedules`)}createSchedule(e){return this.request(`POST`,`/v1/schedules`,e)}updateSchedule(e,t){return this.request(`PATCH`,`/v1/schedules/${iu(e)}`,t)}removeSchedule(e){return this.request(`DELETE`,`/v1/schedules/${iu(e)}`)}runSchedule(e){return this.request(`POST`,`/v1/schedules/${iu(e)}/run`,{})}deviceUsage(){return this.request(`GET`,`/v1/device/usage`)}searchSessions(e){return this.request(`GET`,`/v1/sessions/search?q=${iu(e)}`)}dirs(e=``){return this.request(`GET`,`/v1/fs/dirs?path=${iu(e)}`)}deviceDoc(e){return this.request(`GET`,`/v1/docs/${iu(e)}`)}deviceEvents(e,t=[]){return this.stream(`/v1/events${t.length?`?docs=${t.map(iu).join(`,`)}`:``}`,e)}gitStatus(e,t={}){return this.request(`GET`,`/v1/git/status?path=${iu(e)}`,void 0,t)}gitOp(e,t,n={}){return this.request(`POST`,`/v1/git`,{path:e,op:t,...n})}async exportSession(e,t={}){let n=AbortSignal.timeout(t.timeoutMs??6e4),r=t.signal?AbortSignal.any([t.signal,n]):n,i;try{i=await fetch(this.baseUrl+`/v1/sessions/${iu(e)}/export`,{headers:this.headers(!1),signal:r})}catch(e){throw t.signal?.aborted?e:new Sl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}if(!i.ok){let e=await i.text().catch(()=>``),t;try{t=e?JSON.parse(e):void 0}catch{t=void 0}throw new Sl(t?.error?.code??(i.status===401?`unauthorized`:i.status===404?`not_found`:`internal`),t?.error?.message??`${i.status} ${i.statusText}`,i.status)}let a=new Uint8Array(await i.arrayBuffer()),o=i.headers.get(`content-disposition`)??``,s=/filename="((?:[^"\\]|\\.)*)"/i.exec(o)?.[1],c=/filename=([^;\s]+)/i.exec(o)?.[1];return{filename:(s===void 0?c:s.replace(/\\(.)/g,`$1`))||`${ou(e)}.bundle.zip`,mime:i.headers.get(`content-type`)??`application/zip`,bytes:a}}sessionGitFiles(e){return this.request(`GET`,`/v1/sessions/${iu(e)}/git-files`)}sessionGitTurns(e){return this.request(`GET`,`/v1/sessions/${iu(e)}/git-turns`)}gitStatusBatch(e,t={}){return this.request(`POST`,`/v1/git/status-batch`,{paths:e},t)}sessions(){return this.request(`GET`,`/v1/sessions`)}archived(){return this.request(`GET`,`/v1/archive`)}archivedTranscript(e,t=`markdown`){return this.request(`GET`,`/v1/archive/${iu(e)}/transcript?format=${t}`)}restoreArchived(e){return this.request(`POST`,`/v1/archive/${iu(e)}/restore`,{})}createSession(e,t=au()){return this.request(`POST`,`/v1/sessions`,e,{idempotencyKey:t})}session(e){return new cu(this,e)}agent(e,t){return new lu(this,e,String(t))}},cu=class{client;ref;constructor(e,t){this.client=e,this.ref=t}get base(){return`/v1/sessions/${iu(this.ref)}`}get(){return this.client.request(`GET`,this.base)}rename(e){return this.client.request(`PATCH`,this.base,{name:e})}archive(){return this.client.request(`DELETE`,this.base)}agents(){return this.client.request(`GET`,`${this.base}/agents`)}createAgent(e={},t=au()){return this.client.request(`POST`,`${this.base}/agents`,e,{idempotencyKey:t})}tasks(e=`terminal`,t=20){return this.client.request(`GET`,`${this.base}/tasks?status=${e}&limit=${t}`)}abortTask(e){return this.client.request(`POST`,`${this.base}/tasks/${e}/abort`,{})}inspect(){return this.client.request(`GET`,`${this.base}/inspect`)}compaction(){return this.client.request(`GET`,`${this.base}/compaction`)}setCompaction(e){return this.client.request(`PATCH`,`${this.base}/compaction`,e)}submission(e,t=0){return this.client.request(`GET`,`${this.base}/submissions/${e}?waitMs=${t}`,void 0,{timeoutMs:t+2e4})}events(e){return this.client.stream(`${this.base}/events`,e)}},lu=class{client;session;agent;constructor(e,t,n){this.client=e,this.session=t,this.agent=n}get base(){return`/v1/sessions/${iu(this.session)}/agents/${iu(this.agent)}`}get(){return this.client.request(`GET`,this.base)}rename(e){return this.client.request(`PATCH`,this.base,{name:e})}send(e,t=`followUp`,n=au(),r){return this.client.request(`POST`,`${this.base}/messages`,{content:e,whenBusy:t,requestId:n,waitMs:r},{timeoutMs:(r??0)+2e4})}withdraw(e){return this.client.request(`DELETE`,`${this.base}/inbox/${e}`)}abort(e=!1){return this.client.request(`POST`,`${this.base}/abort`,{background:e})}fork(e,t=au()){return this.client.request(`POST`,`${this.base}/fork`,e,{idempotencyKey:t})}config(){return this.client.request(`GET`,`${this.base}/config`)}configure(e){return this.client.request(`PATCH`,`${this.base}/config`,e)}compact(e){return this.client.request(`POST`,`${this.base}/compact`,{instructions:e})}reset(e){return this.client.request(`POST`,`${this.base}/reset`,{note:e})}entries(e={}){let t=new URLSearchParams({scope:e.scope??`all`,limit:String(e.limit??500),...e.cursor?{cursor:e.cursor}:{}});return this.client.request(`GET`,`${this.base}/entries?${t}`)}transcript(e=`json`){return this.client.request(`GET`,`${this.base}/transcript?format=${e}`)}doc(e){return this.client.request(`GET`,`${this.base}/docs/${iu(e)}`)}extensions(){return this.client.request(`GET`,`${this.base}/extensions`)}setExtension(e){return this.client.request(`PATCH`,`${this.base}/extensions`,e)}demo(e,t,n=`POST`){return this.client.request(n,`${this.base}/demo/${e}`,t)}events(e,t=[]){return this.client.stream(`${this.base}/events${t.length?`?docs=${t.map(iu).join(`,`)}`:``}`,e)}},uu=0,G=e=>new su(`/api/devices/${encodeURIComponent(e)}`,void 0,{onIdempotentReplay:e=>{Date.now()-uu<3e4||(uu=Date.now(),Y(`Replayed an earlier identical request (${e}) — send a custom idempotency key for deliberate repeats.`))}});async function du(e,t,n){let r=await fetch(`/api${t}`,{method:e,headers:n===void 0?{}:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>void 0);if(!r.ok){let e=i?.error;throw new Sl(e?.code??`internal`,e?.message??`${r.status} ${r.statusText}`,r.status)}return i}var fu={network:()=>du(`GET`,`/network`),version:()=>du(`GET`,`/version`),check:e=>du(`POST`,`/devices/${encodeURIComponent(e)}/check`,{}),createShare:e=>du(`POST`,`/shares`,e),async uiGet(e){return(await du(`GET`,`/ui-state/${encodeURIComponent(e)}`)).value??void 0},uiSet:(e,t)=>du(`PUT`,`/ui-state/${encodeURIComponent(e)}`,{value:t})},K=e=>e instanceof Error?e.message:String(e),pu=[`demo.job-runs`,`demo.workspace`],mu=e=>`${e.deviceId}/agent/${e.sessionId}/${e.agentId}?docs=${pu.join(`,`)}`,hu=e=>`${e.deviceId}/session/${e.sessionId}`,gu=e=>`${e}/device?docs=app.shared-state`;function _u(e,t,n,r=`hello`){let i=k(`idle`),a=k(``);return e.route(t,e=>{e.type===`hello`?(i.value=r===`hello`?`live`:`connecting`,r===`hello`&&(a.value=``)):e.type===`disconnected`?i.value=`reconnecting`:e.type===`fault`?(i.value=`fault`,a.value=e.error.message):(n(e),e.type===r&&(a.value=``,i.value=`live`))}),{status:i,fault:a,select:n=>{a.value=``,i.value=n?`connecting`:`idle`,e.set(t,n)},retry:()=>{i.value=`connecting`,e.reopen(t)}}}function vu(e){let t=new Ul,n=k(0);return t.subscribe(()=>n.value++),e.onNetwork(e=>t.apply({type:`network`,devices:e})),{model:t,devices:U(()=>(n.value,t.devices)),tree:U(()=>(n.value,t.tree()))}}function yu(e,t){let n=rn(),r=rn([]),{status:i,select:a}=_u(e,`device`,e=>{e.type===`doc`&&e.kind===`app.shared-state`?n.value={value:e.value,revision:e.revision??0}:e.type===`activity`&&(r.value=[...r.value,...e.items].slice(-50))});return M(t,e=>{n.value=void 0,a(e?gu(e):void 0)},{immediate:!0}),{sharedState:n,activity:r,status:i}}function bu(e,t){let n=new Il,r=k(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o}=_u(e,`session`,e=>n.apply(e));return M(()=>t.value?hu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:U(()=>(r.value,n.state)),status:i,fault:a}}function xu(e,t){let n=new Fl,r=k(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o,retry:s}=_u(e,`agent`,e=>n.apply(e),`snapshot`);return M(()=>t.value?mu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:U(()=>(r.value,{...n.state})),status:i,fault:a,version:r,retry:s}}var Su=new Jl,Cu=k(Su.state);Su.onState(e=>Cu.value=e);var wu=vu(Su),Tu=k(),Eu=k(),q=k(),Du=k(new Set),Ou=k(300),ku=Wt({tree:!0,inspector:!0}),Au=k(!1),ju=U(()=>q.value?.deviceId),Mu=U(()=>wu.devices.value.find(e=>e.id===ju.value)),Nu=U(()=>Mu.value?.status===`online`),Pu=bu(Su,U(()=>q.value?{deviceId:q.value.deviceId,sessionId:q.value.sessionId}:void 0)),Fu=xu(Su,q),Iu=yu(Su,ju),Lu=U(()=>Mu.value?.tree?.sessions.find(e=>e.id===q.value?.sessionId)),Ru=U(()=>ju.value?G(ju.value):void 0),zu=U(()=>q.value&&Ru.value?Ru.value.agent(q.value.sessionId,q.value.agentId):void 0),Bu=U(()=>q.value&&Ru.value?Ru.value.session(q.value.sessionId):void 0);function Vu(e){q.value=e,J.drawer=!1,Hu=!!e,Uu()}var Hu=!1;function Uu(){let e=q.value;if(!Hu||!e)return;let t=wu.devices.value.find(t=>t.id===e.deviceId)?.tree?.sessions.find(t=>t.id===e.sessionId)?.agents,n=new Map((t??[]).map(e=>[e.id,e])),r=[e.deviceId,`${e.deviceId}/s/${e.sessionId}`,`${e.deviceId}/s/${e.sessionId}/a/${e.agentId}`],i=n.get(e.agentId),a=new Set;for(;i&&!a.has(i.id);){a.add(i.id);let t=i.parentId??i.ownerAgentId;if(t===void 0)break;r.push(`${e.deviceId}/s/${e.sessionId}/a/${t}`),i=n.get(t)}r.some(e=>!Du.value.has(e))&&(Du.value=new Set([...Du.value,...r])),n.has(e.agentId)&&(Hu=!1)}M(()=>wu.devices.value,Uu);function Wu(e,t){let n=new Set(Du.value);t??!n.has(e)?n.add(e):n.delete(e),Du.value=n}var Gu=(()=>{let e=new Map;return(t,n)=>{clearTimeout(e.get(t)),e.set(t,setTimeout(()=>void fu.uiSet(t,n).catch(()=>{}),300))}})();M(q,e=>Au.value&&void fu.uiSet(`tree.selected`,e??null).catch(()=>{})),M(Ou,e=>Au.value&&Gu(`tree.width`,e)),M(ku,e=>Au.value&&Gu(`layout.panels`,{...e}));async function Ku(){let e;try{e=await fu.network()}catch(e){e instanceof Sl&&e.status===401||Su.start(),J.error=K(e),Au.value=!0;return}Su.start();try{let[t,n,r]=await Promise.all([fu.uiGet(`tree.selected`),fu.uiGet(`tree.width`),fu.uiGet(`layout.panels`)]);r&&Object.assign(ku,r),fu.version().then(e=>Eu.value=e.version).catch(()=>{}),Tu.value=e.configFile,wu.model.devices.length||wu.model.apply({type:`network`,devices:e.devices}),Du.value=new Set,n&&(Ou.value=n),t&&e.devices.some(e=>e.id===t.deviceId)?Vu(t):qu(e.devices)}catch(e){J.error=K(e)}finally{Au.value=!0}}function qu(e){for(let t of e){let e=t.status===`online`?t.tree?.sessions[0]:void 0,n=e?.agents.find(e=>e.kind===`root`)??e?.agents[0];if(e&&n)return Vu({deviceId:t.id,sessionId:e.id,agentId:n.id})}}M(()=>[Fu.status.value,Lu.value],([e,t])=>{e===`fault`&&!t&&Nu.value&&(Y(`That session was archived on its device.`),Vu(void 0))});var Ju=U(()=>Mu.value?.info?.models??[]),Yu=Fu.state,Xu=U(()=>Pu.state.value.agents.length?Pu.state.value.agents:Lu.value?.agents??[]),Zu=U(()=>q.value?Ll(Xu.value,q.value.agentId):[]),Qu=U(()=>{let e=q.value?.agentId;if(e===void 0)return[];let t=Xu.value,n=new Set([e]);for(let e=!0;e;){e=!1;for(let r of t)r.ownerAgentId!==void 0&&n.has(r.ownerAgentId)&&!n.has(r.id)&&(n.add(r.id),e=!0)}let r=Pu.state.value.tasks,i=new Map(r.map(e=>[e.id,e])),a=new Map(t.map(e=>[e.id,e.ownerTaskId]));return r.filter(e=>n.has(e.conversationId)).map(e=>{let t=e,n=!1,r=new Set;for(;t&&!r.has(t.id);){if(r.add(t.id),t.background){n=!0;break}let e=t.owner??a.get(t.conversationId);t=e===void 0?void 0:i.get(e)}return{...e,effectiveBackground:n}})}),$u=U(()=>Yu.value.running||Qu.value.some(e=>!e.effectiveBackground&&e.conversationId===q.value?.agentId)),ed=U(()=>Al(Yu.value.usage)),td=U(()=>{let e=Yu.value.agent.model;return Ju.value.find(t=>t.provider===e?.provider&&t.id===e?.modelId)}),nd=U(()=>{let e=Yu.value.agent.model;if(e?.modelId)return e;let t=Lu.value;return t?.model?{provider:t.provider??``,modelId:t.model}:void 0}),rd=U(()=>{let e=nd.value;return e?Ju.value.find(t=>t.provider===e.provider&&t.id===e.modelId):void 0}),id=rn(),ad=0;async function od(){let e=zu.value,t=++ad;if(!e||!Nu.value)return void(id.value=void 0);try{let n=await e.get();t===ad&&(id.value=n)}catch{t===ad&&(id.value=void 0)}}M([zu,Nu],()=>void od(),{immediate:!0});var J=Wt({error:``,toast:``,drawer:!1,inspectorOverlay:!1,tab:`session`,composer:``,dialog:void 0}),sd,cd=Wt([]),ld=1;function ud(){for(let e of cd)e.read=!0}function Y(e){J.toast=e,e&&(cd.unshift({id:ld++,text:e,at:Date.now(),read:!1}),cd.length>50&&(cd.length=50)),clearTimeout(sd),sd=setTimeout(()=>J.toast=``,4500)}async function dd(e){J.error=``;try{return await e()}catch(e){J.error=K(e);return}}function fd(e){J.composer=e,setTimeout(()=>document.querySelector(`.composer textarea`)?.focus())}var pd=e=>Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e),md=e=>JSON.stringify(e,null,2),hd=(e=``)=>Xl(Ju.value.find(t=>t.id===e)?.icon);function gd(e){if(!e)return`never`;let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}var _d=k(!1);async function vd(){$u.value&&!_d.value&&zu.value&&(_d.value=!0,await dd(()=>zu.value.abort(!1))&&Y(`Foreground work interrupted. Background jobs continue.`),_d.value=!1)}var yd=window.matchMedia(`(max-width: 1100px)`),bd=k(yd.matches);yd.addEventListener(`change`,e=>bd.value=e.matches);var xd=U(()=>bd.value?J.inspectorOverlay:ku.inspector);function Sd(e){e&&(J.tab=e),bd.value?(J.drawer=!1,J.inspectorOverlay=!0):ku.inspector=!0}function Cd(){bd.value?J.inspectorOverlay=!1:ku.inspector=!1}function wd(){bd.value?(J.drawer=!J.drawer)&&(J.inspectorOverlay=!1,ku.tree=!0):ku.tree=!ku.tree}function Td(){xd.value?Cd():Sd()}var Ed=/Mac|iPhone|iPad/.test(navigator.userAgent),Dd=Ed?{tree:`Ctrl+N`,inspector:`Ctrl+T`}:{tree:`Alt+Shift+N`,inspector:`Alt+Shift+T`};function Od(e){if(!(!(Ed?e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey:e.altKey&&e.shiftKey&&!e.ctrlKey&&!e.metaKey)||e.repeat||e.isComposing)){if(e.code===`KeyN`)return`tree`;if(e.code===`KeyT`)return`inspector`}}var kd={class:`topbar`},Ad={class:`brand`},jd={class:`daemon`,"data-testid":`topbar-stats`},Md=[`title`],Nd={class:`top-actions`},Pd={key:0,class:`usage-chip`,title:`This session's token usage and cost`},Fd=[`aria-label`,`title`],Id={key:0,class:`bell-dot`},Ld={key:0,class:`hint`},Rd={class:`when`},zd=[`disabled`],Bd=[`disabled`],Vd=N({__name:`TopBar`,emits:[`newSession`],setup(e,{emit:t}){let n=k(!1),r=U(()=>cd.filter(e=>!e.read).length),i=()=>{n.value=!n.value,n.value&&ud()},a=e=>{let t=Math.round((Date.now()-e)/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`},o=U(()=>ed.value.input+ed.value.output+ed.value.cacheRead+ed.value.cacheWrite),s=U(()=>(ed.value.inputCost??0)+(ed.value.outputCost??0)+(ed.value.cacheReadCost??0)+(ed.value.cacheWriteCost??0)),c=U(()=>wu.devices.value.filter(e=>e.status===`online`).length),l=U(()=>wu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.length??0),0)),u=U(()=>wu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.reduce((e,t)=>e+t.agents.length,0)??0),0)),d=k(!1);async function f(){let e=Bu.value,t=q.value;if(!e||!t||d.value)return;d.value=!0;let n=await dd(()=>e.createAgent({name:`Agent ${Xu.value.length+1}`}));d.value=!1,n&&(Vu({...t,agentId:n.id}),Y(`New agent. Same session, same shared App State.`))}let p=t;return(e,t)=>(I(),L(`header`,kd,[z(`div`,Ad,[z(`button`,{class:`icon-button tree-toggle`,"aria-label":`Toggle network`,title:`Network`,onClick:t[0]||=e=>A(J).drawer=!A(J).drawer},[B(A(Gc),{size:19})]),t[6]||=z(`img`,{class:`brandmark`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),t[7]||=z(`strong`,null,`Durable Pi`,-1)]),t[15]||=z(`span`,{class:`topbar-sep`,"aria-hidden":`true`},null,-1),z(`div`,jd,[z(`span`,{class:E([`dot`,{off:!c.value}]),"aria-hidden":`true`},null,2),z(`span`,{class:`network-summary`,title:`${c.value} of ${A(wu).devices.value.length} devices online`},[B(A(Bc),{size:16}),V(D(c.value)+` of `+D(A(wu).devices.value.length)+` online`,1)],8,Md),t[10]||=z(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),z(`span`,null,[z(`b`,null,D(l.value),1),t[8]||=V(` sessions`,-1)]),t[11]||=z(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),z(`span`,null,[z(`b`,null,D(u.value),1),t[9]||=V(` agents`,-1)])]),z(`div`,Nd,[z(`span`,{class:E([`chip connection`,{accent:A(Cu)===`live`}])},[z(`span`,{class:E([`dot`,{off:A(Cu)!==`live`}]),"aria-hidden":`true`},null,2),V(D(A(Cu)===`live`?`Connected`:`Reconnecting`),1)],2),o.value?(I(),L(`span`,Pd,D(o.value.toLocaleString())+` tok · $`+D(s.value.toFixed(3)),1)):H(``,!0),z(`button`,{class:`icon-button`,"aria-label":`Notifications${r.value?` (${r.value} unread)`:``}`,title:`Notification center${r.value?` — ${r.value} unread`:``}`,onClick:i},[B(A(Xs),{size:18}),r.value?(I(),L(`i`,Id,D(r.value>9?`9+`:r.value),1)):H(``,!0)],8,Fd),n.value?(I(),L(`div`,{key:1,class:`notif-panel`,onClick:t[2]||=ks(()=>{},[`stop`])},[z(`header`,null,[t[12]||=z(`b`,null,`Notifications`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close notifications`,onClick:t[1]||=e=>n.value=!1},`✕`)]),A(cd).length?H(``,!0):(I(),L(`p`,Ld,`Nothing yet — events land here as they happen.`)),z(`ul`,null,[(I(!0),L(F,null,P(A(cd),e=>(I(),L(`li`,{key:e.id,class:E({unread:!e.read})},[z(`span`,Rd,D(a(e.at)),1),z(`span`,null,D(e.text),1)],2))),128))])])):H(``,!0),z(`button`,{class:`icon-button`,title:`How this works`,"aria-label":`How this works`,onClick:t[3]||=e=>A(J).dialog={kind:`help`}},[B(A(ac),{size:19})]),z(`button`,{class:`secondary small new-agent-button`,disabled:!A(q)||!A(Nu)||d.value,title:`Start a fresh agent in this session`,onClick:f},[B(A(Xc),{size:18}),t[13]||=V(`New agent `,-1)],8,zd),z(`button`,{class:`primary small`,onClick:t[4]||=e=>p(`newSession`)},[B(A(Xc),{size:18}),t[14]||=V(`New session `,-1)]),z(`button`,{class:`icon-button inspector-toggle`,"aria-label":`Toggle inspector`,title:`Inspector`,disabled:!A(q)||!A(Nu),onClick:t[5]||=e=>A(J).inspectorOverlay?A(Cd)():A(Sd)()},[B(A(Kc),{size:19})],8,Bd)])]))}}),Hd=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Ud=Hd(Vd,[[`__scopeId`,`data-v-de526f26`]]),Wd={class:`mnav`,"aria-label":`Panels`},Gd={key:0,class:`badge`},Kd=N({__name:`MobileNav`,setup(e){function t(){J.drawer=!1,J.inspectorOverlay=!1}return(e,n)=>(I(),L(`nav`,Wd,[z(`button`,{type:`button`,class:E({"is-on":!A(J).drawer&&!A(xd)}),onClick:t},[B(A(Lc),{size:18}),n[2]||=V(`Chat `,-1)],2),z(`button`,{type:`button`,class:E({"is-on":A(xd)}),onClick:n[0]||=e=>A(xd)?A(Cd)():A(Sd)()},[B(A(Kc),{size:18}),n[3]||=V(`Details`,-1),A(Qu).length?(I(),L(`span`,Gd,D(A(Qu).length),1)):H(``,!0)],2),z(`button`,{type:`button`,class:E({"is-on":A(J).drawer}),onClick:n[1]||=e=>A(wd)()},[B(A(gl),{size:18}),n[4]||=V(`Network `,-1)],2)]))}}),qd=[`width`,`height`,`aria-label`],Jd=[`width`,`height`,`aria-label`],Yd=N({__name:`DeviceIcon`,props:{device:{},size:{default:16}},setup(e){let t=e,n=U(()=>{let e=t.device;return e?.kind===`exe-dev`||e?.url?.includes(`.exe.xyz`)?`exe`:e?.info?.platform.startsWith(`darwin`)?`apple`:e?.kind===`local`?`laptop`:`server`}),r=U(()=>{let e={exe:`exe.dev VM`,apple:`macOS`,laptop:`This computer`,server:`Server`}[n.value];return t.device?.transport===`tunnel`?`${e} (tunnel)`:e});return(t,i)=>n.value===`exe`?(I(),L(`svg`,{key:0,class:`device-icon exe`,viewBox:`0 0 512 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[z(`title`,null,D(r.value),1),i[0]||=z(`path`,{fill:`currentColor`,"fill-rule":`evenodd`,d:`M8 332.2l.9 1.4 1.5 .5 38.5-4.1 3.1 .4 2.7 2.2 8.8 13.2 10.1 12.8 1.1 2.6-.3 3.2-16.4 35.6 0 1.7 1 1.2 2.2 0 33.8-18.2 3.1-.8 3.4 1 12.4 8.7 15.3 9.4 1.5 2.1 .5 2.5-3.1 38.9 .4 1.5 1.3 .9 2.3-.7 25.9-29.2 2.1-1.3 2.8-.4 16.3 4.4 15.7 3.2 3 1.8 1.6 2.8 9.8 37.1 1.5 1.6 1.7-.1 1.1-1.1 14.5-35.6 1.8-2.5 3.4-1.5 15.7-1.1 16.1-2.4 3.2 .5 2.3 1.8 22.4 32 2.2 .9 1.4-.7 .6-1.5 1.4-39 1-2.7 2.4-2.2 14.7-6.8 13.8-7.8 3.4-.7 3 1 32.4 21 2.3 0 1.1-1.1 0-1.6-13.4-36.6-.3-2.5 .7-2.4 12.2-13.9 8.8-12.1 2.8-2 3.1-.3 38.4 5.4 2.1-.9 .5-1.5-.6-1.4-27.5-27.4-1.6-2.7-.2-3.1 4.6-15.8 2.9-15.8 1.3-2.6 2.5-1.9 37.3-12.2 1.6-1.9-.3-1.5-1.1-1-36.8-12.5-2.4-1.4-1.8-3.3-3.1-17.7 0-2.2 .9-2.4 3.1-2.9 10.6-15.3 3.3-1.8 3.4 .3 3.8 3 4.5 6.8 8.9 11.2 12.5 12.5 6.2 4.8 7.3 4.3 6.3 2.4 3.8 .3 4-.3 5.1-2.4 6.5-7 4.8-10.6 3.3-11.9 2-14.1 1.3-3.4 0-66.6-.8-2.6-2-13.6-3.8-14.6-7.5-18.7-4.7-9.4-4-6-7.2-7.1-5-2.1-6.5 0-2.2 .7-6 3.5-12 12-13.1 17.8-11.7 18.2-3.7 1.6-11.8-.1-3.1-1.6-1.8-2.9-.3-8.8-2.8-12.7-1.5-4-7.1-13.3-5.9-7.8-10.7-9.3-8.6-4.7-5.9-2-4.1-.5-6.7-.5-4.1 .5-7 2-7.3 3.8-7.5 7-2.2 3.2-2.5 5.5-2.8 10.5-.5 3.6 .1 17.1-.3 2.2-1.1 1.9-1.7 1.5-3.7 1.5-2.6 .3-27.5-10.5-14.5-4-15.7-3.2-2.6-1.3-1.9-3-9.9-37.5-.9-1.2-1.4-.4-1.3 .4-.8 1-14.7 36.1-1.8 2.1-2.2 1.2-17.8 1.4-15 2.2-3.4-.7-2.4-2.1-22-31.5-2-.9-1.5 .5-.7 1.5-1.4 38.6-.9 3-2.5 2.5-14.7 6.8-13.8 7.8-2.8 .7-3.1-.7-32.9-21.3-2.3 0-1.1 1.1-.1 1.6 13.6 36.9 0 3.1-1.2 2.6-10.8 12-9.5 12.9-2.8 2-3.2 .3-38.4-5.4-1.5 .4-.9 1.4 .6 2.1 27.6 27.6 1.2 1.8 .5 2.2-3 10.6-1.5 2.4-2.4 1.6-5.8 1-4.4 1.8-3.8 3-3 3.8-1.7 4-.7 4.7 .4 4.7 1.5 4.2 .3 .5 30.7 0 1.7 .6 1.4 1.1 1.1 3-1.1 2.9-2.7 1.6-31.1 .1-.6 1.1-1.2 3.6-.4 4.1 .4 4.2 1.2 3.5 2.5 4 3.2 3.1 4.1 2.3 5.6 1.8 2.4 2.1 .9 2.1 5.1 21.2-.6 2.1-1.2 1.9-28.5 26.5zM283.6 189.4l6.6 .5 5.6 1.2 6.2 2.2 5.9 3.1 4.6 3.4 4.8 4.5 3.5 4.4 3.4 5.8 2.6 6.2 1.6 6.4 .6 5.6-.2 6.7-1.1 6.5-1.7 5.4-2.9 6-3.6 5.5-7.1 7.3-8.4 5.4-9.4 3.5-9.9 1.3-11-1-40.4-10.4-2.8-1.1-3.1-2.4-1.7-.6-.9-1.1-.1-2.2-1.4-2.2 1.6-6.3 18.1-38.5 4.7-7.5 7.1-7.3 8.4-5.4 9.4-3.5zM173.9 198l-1.1 5.9-2.3 5.5-3.4 5-4.2 4.3-5 3.3-5.5 2.3-5.9 1.2-6 0-5.9-1.2-5.6-2.3-5-3.3-4.2-4.3-3.3-5-2.3-5.5-1.2-5.9 0-6 1.2-5.9 2.3-5.5 3.3-5 4.2-4.3 5-3.3 5.6-2.3 5.9-1.2 6 0 5.9 1.2 5.5 2.3 5 3.3 4.2 4.3 3.4 5 2.3 5.5 1.1 5.9zM315.1 213.5l-63.1 37.7 69.5-12.9 0-6.2-1-6.5-2.1-6.1zM237.3 260l-2.6 1.5 40.6 10.5 7.4 .9 7.4-.5 5.4-1.4 5.2-2.1 8.5-5.8 3.8-4.1 3.2-4.5 2.6-5 1.6-4.9zM284.5 196.9l-7.4 .5-8.1 2.3-7.3 4.1-6.3 5.5-5.8 8.5-17.4 37.1 3-.6 76.1-45.5-5.8-5-6.5-3.7-7.1-2.3zM141.1 183.6l-1.1-2.9-2-2.3-2.8-1.3-3.1-.1-2.9 1-2.3 2.1-1.3 2.8-.1 3 1 2.9 2.1 2.3 2.7 1.3 3.1 .2 2.9-1.1 2.3-2 1.3-2.8z`},null,-1)],8,qd)):n.value===`apple`?(I(),L(`svg`,{key:1,class:`device-icon apple`,viewBox:`0 0 384 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[z(`title`,null,D(r.value),1),i[1]||=z(`path`,{fill:`currentColor`,d:`M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z`},null,-1)],8,Jd)):n.value===`laptop`?(I(),R(A(Ac),{key:2,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`])):(I(),R(A(il),{key:3,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`]))}}),Xd=new Map,Zd=new Map;async function Qd(e,t){let n=t.filter(t=>!af(rf(e,t),$d));if(n.length)try{let t=await G(e).gitStatusBatch(n,{timeoutMs:6e4});for(let[n,r]of Object.entries(t)){let t=rf(e,n);t.status=r,t.at=Date.now(),t.error=``}}catch{}}var $d=6e4,ef=!1;function tf(){ef||(ef=!0,M(()=>wu.devices.value,e=>{let t=Date.now();for(let n of e){let e=(n.tree?.git??[]).filter(e=>t-e.at<6e4);if(e.length)for(let r of[...Xd.keys()]){let[i,a]=r.split(`::`);if(i!==n.id||!a)continue;let o=Xd.get(r);e.some(e=>a===e.root||a.startsWith(e.root+`/`)||a.startsWith(e.root+`\\`))&&(o.loading||t-o.at<4e3||of(i,a,{force:!0}))}}}))}var nf=(e,t)=>`${e}::${t}`;function rf(e,t){let n=nf(e,t),r=Xd.get(n);return r||(r=Wt({at:0,status:null,error:``,loading:!1,refreshing:!1}),Xd.set(n,r)),r}var af=(e,t)=>e.at>0&&Date.now()-e.at<t&&(e.status!==null||e.error);async function of(e,t,n={}){let{staleMs:r=6e4,force:i=!1,timeoutMs:a=6e4}=n;if(!e||!t)return;let o=nf(e,t),s=rf(e,t);if(!i&&af(s,r))return;let c=Zd.get(o);if(c)return c;s.status===null&&!s.error?s.loading=!0:s.refreshing=!0,s.error=``;let l=(async()=>{try{s.status=await G(e).gitStatus(t,{timeoutMs:a}),s.at=Date.now()}catch(e){let t=e.message??``;s.error=/fetch failed|Cannot reach|Failed to fetch|NetworkError|abort/i.test(t)?`device unreachable — check that it is online, then retry (${t.slice(0,80)})`:t.slice(0,160),s.at=Date.now()}finally{s.loading=!1,s.refreshing=!1,Zd.delete(o)}})();return Zd.set(o,l),l}var sf=new Map;function cf(){M(()=>wu.devices.value.map(e=>`${e.id}:${e.status}:${e.tree?.sessions.length??0}:${e.tree?.sessions.map(e=>e.cwd).join(`|`)}`).join(`;`),()=>{for(let e of wu.devices.value){if(e.status!==`online`||!e.tree?.sessions.length)continue;let t=Date.now();t-(sf.get(e.id)??0)<6e4||(sf.set(e.id,t),Qd(e.id,e.tree.sessions.map(e=>e.cwd)))}},{immediate:!0})}var lf=(e,t)=>rf(e,t).status?.branch,uf=[`aria-level`,`aria-expanded`,`aria-selected`,`data-key`,`title`],df=[`aria-label`],ff={key:1,class:`chev`},pf={class:`name`},mf={class:`badge`},hf=[`title`],gf=[`aria-label`],_f=[`disabled`,`aria-label`],vf=[`aria-label`],yf=[`checked`,`aria-label`],bf={class:`name`},xf={class:`path`},Sf=[`title`],Cf=[`title`],wf={key:3,class:`dot work`,title:`Working`},Tf=[`title`],Ef=[`disabled`,`aria-label`],Df=[`disabled`,`aria-label`],Of=[`disabled`,`aria-label`],kf=[`disabled`,`aria-label`],Af={class:`name`},jf={key:3,class:`meta`},Mf={key:4,class:`dot work`,title:`Working`},Nf=[`title`],Pf=[`disabled`,`aria-label`],Ff=Hd(N({__name:`TreeRow`,props:{node:{},depth:{},open:{type:Boolean},selected:{type:Boolean},focused:{type:Boolean},online:{type:Boolean},checkbox:{type:Boolean},checked:{type:Boolean}},emits:[`toggle`,`activate`,`action`,`check`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>n.node.children.length>0),a=U(()=>n.node.type===`device`?n.node.device:void 0),o=U(()=>n.node.type===`session`?n.node.session:void 0),s=U(()=>n.node.type===`agent`?n.node.agent:void 0),c=U(()=>o.value?o.value.agents.reduce((e,t)=>e+t.background,0):s.value?.background??0),l=U(()=>o.value?.busy||s.value?.busy),u=U(()=>{let e=a.value?.info,t=e?.packageVersion??e?.durableVersion,n=Eu.value;return!!(t&&n&&n!==`unknown`&&t!==n)}),d=U(()=>{let e=a.value?.info;return e?.packageVersion??e?.durableVersion??`?`}),f=U(()=>{let e=a.value;if(!e)return``;let t=e.tree?.sessions.length??0;switch(e.status){case`online`:return`${t} session${t===1?``:`s`}`;case`checking`:return`checking…`;case`unauthorized`:return e.hasToken?`token rejected`:`no token`;case`mismatch`:return`identity changed`;case`incompatible`:return`incompatible`;default:return`offline · ${gd(e.lastSeenAt)}`}}),p=U(()=>{let e=a.value?.status;return e===`online`?`on`:e===`checking`?`chk`:e===`offline`?`off`:`err`}),m=U(()=>{let e=n.node;return e.type===`session`?lf(e.deviceId,e.session.cwd):void 0}),h=U(()=>a.value?.name??a.value?.id??o.value?.name??s.value?.name??``),g=U(()=>{if(a.value){let e=a.value;return`${e.name}${e.url?` · ${e.url}`:``}${e.error?`\n${e.error}`:``}`}if(o.value)return`${o.value.name}\n${o.value.cwd}`;let e=s.value;return e.kind===`fork`?`Fork of agent #${e.parentId} at entry #${e.forkedAt}`:e.kind===`subagent`?`Subagent owned by agent #${e.ownerAgentId}`:`Root agent`});return(t,n)=>(I(),L(`div`,{class:E([`tree-row`,[e.node.type,{sel:e.selected,focus:e.focused,stale:e.node.stale}]]),style:ge({"--depth":e.depth}),role:`treeitem`,"aria-level":e.depth+1,"aria-expanded":i.value?e.open:void 0,"aria-selected":e.selected,"data-key":e.node.key,title:g.value,onClick:n[14]||=e=>r(`activate`)},[i.value?(I(),L(`button`,{key:0,class:`chev`,tabindex:`-1`,"aria-label":e.open?`Collapse ${h.value}`:`Expand ${h.value}`,onClick:n[0]||=ks(e=>r(`toggle`),[`stop`])},[e.open?(I(),R(A(nc),{key:0,size:16})):(I(),R(A(rc),{key:1,size:16}))],8,df)):(I(),L(`span`,ff)),a.value?(I(),L(F,{key:2},[z(`i`,{class:E([`dot`,p.value])},null,2),B(Yd,{device:a.value,size:16},null,8,[`device`]),z(`b`,pf,D(h.value),1),z(`span`,mf,D(a.value.kind),1),u.value?(I(),L(`span`,{key:0,class:`tag update`,title:`device runs ${d.value}; hub runs ${A(Eu)}. Devices self-update: dpi update`},`update`,8,hf)):H(``,!0),z(`span`,{class:E([`meta`,{err:p.value===`err`}])},D(f.value),3),z(`span`,{class:`acts`,onClick:n[4]||=ks(()=>{},[`stop`])},[a.value.pairing?(I(),L(`button`,{key:0,class:`icon-button`,"aria-label":`Manage credentials for ${h.value}`,title:`Manage device credentials, including while offline`,onClick:n[1]||=e=>r(`action`,`credentials`)},[B(A(kc),{size:16})],8,gf)):H(``,!0),z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New session on ${h.value}`,title:`New session on this device`,onClick:n[2]||=e=>r(`action`,`new-session`)},[B(A(Xc),{size:16})],8,_f),z(`button`,{class:`icon-button`,"aria-label":`Check ${h.value}`,title:`Check connection now`,onClick:n[3]||=e=>r(`action`,`check`)},[B(A($c),{size:16})],8,vf)])],64)):o.value?(I(),L(F,{key:3},[e.checkbox?(I(),L(`input`,{key:0,type:`checkbox`,class:`bulk-check`,checked:e.checked,"aria-label":`Select ${h.value}`,tabindex:`-1`,onClick:n[5]||=ks(()=>{},[`stop`]),onChange:n[6]||=e=>r(`check`)},null,40,yf)):H(``,!0),B(A(yc),{class:`ico`,size:16}),z(`b`,bf,D(h.value),1),z(`span`,xf,`…/`+D(o.value.cwd.split(`/`).filter(Boolean).at(-1)),1),m.value?(I(),L(`span`,{key:1,class:`branch`,title:`git branch of ${o.value.cwd}`},`⎇ `+D(m.value),9,Sf)):H(``,!0),o.value.model?(I(),L(`span`,{key:2,class:`tag`,title:o.value.provider?`${o.value.provider} / ${o.value.model}`:o.value.model},D(o.value.model),9,Cf)):H(``,!0),l.value?(I(),L(`i`,wf)):H(``,!0),c.value?(I(),L(`span`,{key:4,class:`bg-count`,title:`${c.value} background task(s)`},[n[15]||=z(`i`,{class:`dot bg`},null,-1),V(D(c.value)+` bg`,1)],8,Tf)):H(``,!0),z(`span`,{class:`acts`,onClick:n[11]||=ks(()=>{},[`stop`])},[z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New agent in ${h.value}`,title:`New agent in this session`,onClick:n[7]||=e=>r(`action`,`new-agent`)},[B(A(Xc),{size:16})],8,Ef),z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename session ${h.value}`,title:`Rename session`,onClick:n[8]||=e=>r(`action`,`rename`)},[B(A(qc),{size:16})],8,Df),z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`New worktree session from ${h.value}`,title:`New worktree session: branch this folder's repo and open a session in the sibling checkout`,onClick:n[9]||=e=>r(`action`,`worktree`)},[B(A(ul),{size:16})],8,Of),z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Archive session ${h.value}`,title:`Archive session`,onClick:n[10]||=e=>r(`action`,`archive`)},[B(A(Us),{size:16})],8,kf)])],64)):s.value?(I(),L(F,{key:4},[s.value.kind===`fork`?(I(),R(A(Cc),{key:0,class:`ico`,size:16})):s.value.kind===`subagent`?(I(),R(A(cc),{key:1,class:`ico`,size:16})):(I(),R(A(Lc),{key:2,class:`ico root`,size:16})),z(`span`,Af,D(h.value),1),s.value.kind===`fork`&&s.value.forkedAt!==void 0?(I(),L(`span`,jf,`@ #`+D(s.value.forkedAt),1)):H(``,!0),l.value?(I(),L(`i`,Mf)):H(``,!0),c.value?(I(),L(`span`,{key:5,class:`bg-count`,title:`${c.value} background task(s)`},[n[16]||=z(`i`,{class:`dot bg`},null,-1),V(D(c.value),1)],8,Nf)):H(``,!0),z(`span`,{class:`acts`,onClick:n[13]||=ks(()=>{},[`stop`])},[z(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename agent ${h.value}`,title:`Rename agent`,onClick:n[12]||=e=>r(`action`,`rename`)},[B(A(qc),{size:16})],8,Pf)])],64)):H(``,!0)],14,uf))}}),[[`__scopeId`,`data-v-ec99cf9d`]]),If={class:`project-bar`,"aria-label":`Projects`},Lf={class:`project-head`},Rf={class:`project-title`},zf=[`aria-label`,`title`],Bf={key:0,class:`project-hint`},Vf={key:0,class:`chips`},Hf=[`title`,`onClick`,`onDblclick`],Uf={class:`chip-name`},Wf={class:`chip-count`},Gf={key:1,class:`project-hint`},Kf={key:2,class:`project-actions`},qf=[`onClick`],Jf=[`onClick`],Yf=[`onClick`],Xf=[`onClick`],Zf={key:3,class:`message-error`},Qf={key:4,class:`project-hint labels-hint`},$f=Hd(N({__name:`ProjectBar`,props:{active:{},activeModifiers:{}},emits:[`update:active`],setup(e,{expose:t}){let n=Di(e,`active`),r=k([]),i=k(!1),a=k(``),o=k(!1),s=U(()=>wu.devices.value.filter(e=>e.status===`online`).map(e=>e.id));async function c(){i.value=!0,a.value=``;let e=[],t=[];for(let n of s.value){let r=wu.devices.value.find(e=>e.id===n),i=await G(n).projects(o.value).catch(e=>{let r=K(e);e.code===`not_found`||/allowlist|not found/i.test(r)||t.push(`${n}: ${r.slice(0,60)}`)});for(let t of i?.projects??[]){let i=(r?.tree?.sessions??[]).filter(e=>e.cwd===t.rootPath||e.cwd.startsWith(`${t.rootPath}/`)).length;e.push({deviceId:n,project:t,sessions:i})}}r.value=e.sort((e,t)=>l(e.project).localeCompare(l(t.project))),t.length&&(a.value=t.join(` · `)),i.value=!1}M([s,o],c,{immediate:!0});let l=e=>e.customName??e.name,u=e=>n.value?.deviceId===e.deviceId&&n.value.rootPath===e.project.rootPath;function d(e){n.value=u(e)?void 0:{deviceId:e.deviceId,rootPath:e.project.rootPath}}function f(e){let t=e.project;J.dialog={kind:`prompt`,title:`Rename ${l(t)}`,label:`Project name`,hint:`Shown in the tree and in usage rollups. Leave empty to use the folder name.`,value:t.customName??``,placeholder:t.name,submit:`Save name`,run:async n=>{let r=await G(e.deviceId).updateProject(t.id,{customName:n});Y(`Project renamed to ${r.customName??r.name}.`),await c()}}}function p(e){let t=e.project;J.dialog={kind:`prompt`,title:`Labels for ${l(t)}`,label:`Labels (comma separated)`,hint:`Lowercase, up to 12 labels of 32 characters. Used to filter projects.`,value:t.labels.join(`, `),submit:`Save labels`,run:async n=>{let r=await G(e.deviceId).updateProject(t.id,{labels:n.split(`,`).map(e=>e.trim()).filter(Boolean)});Y(r.labels.length?`Labels: ${r.labels.join(`, `)}.`:`Labels cleared on ${l(r)}.`),await c()}}}function m(e){let t=e.project,n=wu.devices.value.find(t=>t.id===e.deviceId)?.info?.models??[];J.dialog={kind:`prompt`,title:`Default model for ${l(t)}`,label:`Model (provider/modelId)`,hint:n.length?`New sessions in this project start on this model instead of the device default. Leave empty to use the device default. E.g. ${n[0].provider}/${n[0].id}`:`New sessions in this project start on this model. Leave empty to use the device default.`,value:t.model?`${t.model.provider}/${t.model.modelId}`:``,placeholder:`device default`,submit:`Save default model`,run:async r=>{if(!r.trim()){await G(e.deviceId).updateProject(t.id,{model:``}),Y(`Default model cleared on ${l(t)}.`),await c();return}let[i,...a]=r.trim().split(`/`),o=a.join(`/`),s=n.some(e=>e.provider===i&&e.id===o);if(!i||!o)throw Error(`Format: provider/modelId`);if(!s)throw Error(`${r.trim()} is not in this device's catalog`);await G(e.deviceId).updateProject(t.id,{model:{provider:i,modelId:o}}),Y(`New sessions in ${l(t)} start on ${o}.`),await c()}}}function h(e){let t=e.project,r=t.archivedAt!==null;J.dialog={kind:`prompt`,title:`${r?`Restore`:`Archive`} ${l(t)}?`,hint:r?`The project returns to the tree. Its sessions were never touched.`:`Bookkeeping only: the project leaves the list, its sessions keep running. Nothing is deleted.`,submit:r?`Restore project`:`Archive project`,danger:!r,run:async()=>{let i=G(e.deviceId);r?await i.unarchiveProject(t.id):await g(i,t.id),!r&&u(e)&&(n.value=void 0),await c()}}}let g=(e,t)=>e.archiveProject(t);return t({reload:c}),(e,t)=>(I(),L(`div`,If,[z(`div`,Lf,[z(`span`,Rf,[B(A(vc),{size:13}),t[2]||=V(`PROJECTS`,-1)]),z(`button`,{class:E([`icon-button tiny`,{on:o.value}]),"aria-label":o.value?`Hide archived projects`:`Show archived projects`,title:o.value?`Hide archived projects`:`Show archived projects`,onClick:t[0]||=e=>o.value=!o.value},[B(A(Us),{size:12})],10,zf),i.value?(I(),L(`span`,Bf,`…`)):H(``,!0)]),r.value.length?(I(),L(`div`,Vf,[(I(!0),L(F,null,P(r.value,e=>(I(),L(`button`,{key:`${e.deviceId}-${e.project.id}`,class:E([`chip`,{on:u(e),archived:e.project.archivedAt}]),title:`${e.project.rootPath} — ${e.sessions} session${e.sessions===1?``:`s`}`,onClick:t=>d(e),onDblclick:t=>f(e)},[e.project.kind===`plain`?(I(),R(A(bc),{key:0,size:11})):(I(),R(A(vc),{key:1,size:11})),z(`span`,Uf,D(l(e.project)),1),z(`em`,Wf,D(e.sessions),1),(I(!0),L(F,null,P(e.project.labels.slice(0,2),e=>(I(),L(`span`,{key:e,class:`chip-label`},D(e),1))),128))],42,Hf))),128))])):i.value?H(``,!0):(I(),L(`p`,Gf,` No projects yet — a project appears when a session starts in a folder. `)),n.value?(I(),L(`div`,Kf,[t[5]||=z(`span`,{class:`project-hint`},`filtering`,-1),(I(!0),L(F,null,P(r.value.filter(u),e=>(I(),L(F,{key:e.project.id},[z(`button`,{class:`small`,onClick:t=>f(e)},[B(A(qc),{size:12}),t[3]||=V(`name`,-1)],8,qf),z(`button`,{class:`small`,onClick:t=>p(e)},[B(A(fl),{size:12}),t[4]||=V(`labels`,-1)],8,Jf),z(`button`,{class:`small`,onClick:t=>m(e),title:`Default model for new sessions in this project`},[B(A(dc),{size:12}),V(D(e.project.model?`model ✓`:`model`),1)],8,Yf),z(`button`,{class:`small`,onClick:t=>h(e)},[e.project.archivedAt?(I(),R(A(Hs),{key:0,size:12})):(I(),R(A(Us),{key:1,size:12})),V(` `+D(e.project.archivedAt?`restore`:`archive`),1)],8,Xf),z(`button`,{class:`icon-button tiny`,"aria-label":`Clear project filter`,onClick:t[1]||=e=>n.value=void 0},[B(A(xl),{size:12})])],64))),128))])):H(``,!0),a.value?(I(),L(`p`,Zf,D(a.value),1)):H(``,!0),r.value.some(e=>e.project.labels.length)?(I(),L(`p`,Qf,[B(A(fl),{size:11}),V(`labels: `+D([...new Set(r.value.flatMap(e=>e.project.labels))].join(` · `)),1)])):H(``,!0)]))}}),[[`__scopeId`,`data-v-77864963`]]);function ep(e,t){return`${e.slice(0,e.lastIndexOf(`/`))}/${e.slice(e.lastIndexOf(`/`)+1)}-${t.replace(/[/\\]+/g,`-`)}`}async function tp(e,t,n,r){let i=ep(n,r);return{target:i,text:(await e.gitOp(t,`worktree-add`,{branch:r,target:i})).text.split(`
16
+ `)[0]??`worktree ${i}`}}async function np(e,t,n,r){return e.createSession(r?{name:n,cwd:t,model:r}:{name:n,cwd:t})}async function rp({deviceApi:e,cwd:t,sessionName:n,branch:r,root:i,source:a,catalog:o,defaultModel:s}){let c=i;if(!c){let n=await e.gitStatus(t);if(!n.repo||!n.root)throw Error(`${t} is not a git repository`);c=n.root}let{target:l}=await tp(e,t,c,r),{model:u,provider:d}=a??{},f=u&&d&&(!o||o.some(e=>e.provider===d&&e.id===u))?{provider:d,modelId:u}:void 0,p=o?.length?o.find(e=>`${e.provider}/${e.id}`===s)??o[0]:void 0;return np(e,l,n,f??(p?{provider:p.provider,modelId:p.id}:void 0))}var ip={class:`tree-head`},ap=[`aria-label`,`title`],op=[`title`],sp={class:`tree-search`},cp={key:1,class:`searching`,"aria-label":`Searching devices`},lp={key:0,class:`bulk-bar`},up=[`disabled`],dp=[`disabled`],fp={class:`hit-head hint`},pp=[`title`,`onClick`],mp={class:`hit-name`},hp={class:`hit-cwd`},gp={key:0,class:`hit-where`},_p={key:2,class:`hint tree-empty`},vp={key:3,class:`hint tree-empty`,"data-testid":`tree-empty`},yp={key:1,class:`panel-rail`,"aria-label":`Network (collapsed)`},bp=[`title`],xp=[`title`,`aria-label`,`onClick`],Sp=Hd(N({__name:`NetworkSidebar`,setup(e){let t=U(()=>{let e=[],t=(n,r,i)=>{for(let a of n)e.push({node:a,depth:r,parent:i}),a.children.length&&Du.value.has(a.key)&&t(a.children,r+1,a.key)};return t(wu.tree.value,0),e}),n=k(),r=k(),i=k(``),a=k([]),o=k(!1),s=U(()=>i.value.trim().toLowerCase()),c=U(()=>s.value.length>=2),l=U(()=>{let e=new Set;if(!c.value)return e;for(let t of wu.devices.value)for(let n of t.tree?.sessions??[])`${n.name}\n${n.cwd}`.toLowerCase().includes(s.value)&&e.add(n.id);return e}),u=k(),d=(e,t)=>!u.value||u.value.deviceId===e&&(t===u.value.rootPath||t.startsWith(`${u.value.rootPath}/`)),f=U(()=>{if(!c.value&&!u.value)return t.value;let e=e=>{if(u.value){let t=e.type===`device`?e.device.id:e.deviceId;if(e.type===`session`&&!d(t,e.session.cwd))return!1;if(e.type===`agent`){let t=wu.devices.value.find(t=>t.id===e.deviceId)?.tree?.sessions.find(t=>t.id===e.sessionId);if(t&&!d(e.deviceId,t.cwd))return!1}if(e.type===`device`)return(e.device.tree?.sessions??[]).some(t=>d(e.device.id,t.cwd))}return c.value?e.type===`session`?l.value.has(e.session.id):e.type===`agent`?l.value.has(e.sessionId)||e.agent.name.toLowerCase().includes(s.value):(e.device.tree?.sessions??[]).some(e=>l.value.has(e.id)):!0},n=new Set(t.value.filter(t=>e(t.node)).map(e=>e.node.key));return t.value.filter(e=>n.has(e.node.key))}),p=U(()=>a.value.filter(e=>!t.value.some(t=>t.node.type===`session`&&t.node.session.id===e.id))),m;M(i,e=>{clearTimeout(m);let t=e.trim();if(t.length<2){a.value=[],o.value=!1;return}m=setTimeout(async()=>{o.value=!0;let e=[];for(let n of wu.devices.value.filter(e=>e.status===`online`)){let r=await G(n.id).searchSessions(t).catch(()=>void 0);for(let t of r?.matches??[])e.push({deviceId:n.id,id:t.id,name:t.name,cwd:t.cwd,where:t.where})}a.value=e,o.value=!1},250)});let h=()=>(i.value=``,a.value=[]),g=k(!1),_=k(new Set),v=k(``),y=e=>{if(e.type!==`session`)return;let t=new Set(_.value);t.has(e.session.id)?t.delete(e.session.id):t.add(e.session.id),_.value=t},b=async e=>{v.value=e;let n=0,r=[];for(let i of t.value.map(e=>e.node)){if(i.type!==`session`||!_.value.has(i.session.id))continue;let t=x(i);if(!t)continue;let a=G(t.id);try{e===`archive`?await a.session(i.session.id).archive():await a.agent(i.session.id,1).abort(!0),n++,e===`archive`&&q.value?.sessionId===i.session.id&&Vu(void 0)}catch{r.push(i.session.name)}}Y(`${e}: ${n} done${r.length?`, ${r.length} failed (${r.slice(0,3).join(`, `)})`:``}`),_.value=new Set,v.value=``},x=e=>wu.devices.value.find(t=>t.id===(e.type===`device`?e.device.id:e.deviceId)),S=e=>x(e)?.status===`online`,C=e=>e.type===`agent`&&q.value?.deviceId===e.deviceId&&q.value.sessionId===e.sessionId&&q.value.agentId===e.agent.id;function ee(e){if(n.value=e.key,g.value&&e.type===`session`)return y(e);if(e.type===`device`)return Wu(e.key);if(e.type===`agent`)return Vu({deviceId:e.deviceId,sessionId:e.sessionId,agentId:e.agent.id});let t=e.session.agents.find(e=>e.kind===`root`)??e.session.agents[0];Wu(e.key,!0),t&&Vu({deviceId:e.deviceId,sessionId:e.session.id,agentId:t.id})}async function w(e,t){let n=x(e);if(!n)return;let r=G(n.id);if(e.type===`device`){t===`new-session`?J.dialog={kind:`new-session`,deviceId:n.id}:t===`check`?await dd(()=>fu.check(n.id)):t===`credentials`&&(J.dialog={kind:`credentials`,deviceId:n.id});return}if(e.type===`session`){let i=e.session;if(t===`new-agent`){let e=await dd(()=>r.session(i.id).createAgent({name:`Agent ${i.agents.length+1}`}));e&&(Vu({deviceId:n.id,sessionId:i.id,agentId:e.id}),Y(`New agent. Same session, same shared App State.`))}else t===`rename`?J.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:i.name,submit:`Save name`,run:e=>r.session(i.id).rename(e)}:t===`worktree`?J.dialog={kind:`prompt`,title:`New worktree session`,label:`Branch name`,value:i.name.replace(/[/\\]+/g,`-`),hint:`Adds a sibling checkout of ${i.cwd} on the branch (git worktree add) and opens a session in it.`,submit:`Create worktree session`,run:async e=>{let t=await rp({deviceApi:r,cwd:i.cwd,sessionName:e,branch:e,source:i,catalog:n.info?.models,defaultModel:n.info?.defaultModel}),a=t.agents.find(e=>e.kind===`root`)??t.agents[0];Vu({deviceId:n.id,sessionId:t.id,agentId:a?.id??1}),Y(`session "${t.name}" on ${t.cwd}`)}}:t===`archive`&&(J.dialog={kind:`prompt`,title:`Archive ${i.name}?`,hint:`Stops all of its work and moves its files to archive/ on ${n.id}. Nothing is deleted.`,submit:`Archive session`,danger:!0,run:async()=>{await r.session(i.id).archive(),q.value?.sessionId===i.id&&Vu(void 0)}});return}let i=e.agent;t===`rename`&&(J.dialog={kind:`prompt`,title:`Rename agent`,label:`Agent name`,value:i.named?i.name:``,placeholder:i.name,submit:`Save name`,run:t=>r.agent(e.sessionId,i.id).rename(t)})}function T(e){let i=t.value.findIndex(e=>e.node.key===n.value),a=t.value[Math.max(0,Math.min(t.value.length-1,(i<0?0:i)+e))];a&&(n.value=a.node.key,An(()=>r.value?.querySelector(`[data-key="${CSS.escape(a.node.key)}"]`)?.scrollIntoView({block:`nearest`})))}function te(){n.value??=t.value[0]?.node.key}function ne(e){let r=t.value.find(e=>e.node.key===n.value);if(e.key===`ArrowDown`)T(1);else if(e.key===`ArrowUp`)T(-1);else if(e.key===`ArrowRight`&&r){if(!r.node.children.length)return;Du.value.has(r.node.key)?T(1):Wu(r.node.key,!0)}else if(e.key===`ArrowLeft`&&r)r.node.children.length&&Du.value.has(r.node.key)?Wu(r.node.key,!1):r.parent&&(n.value=r.parent);else if((e.key===`Enter`||e.key===` `)&&r)ee(r.node);else return;e.preventDefault()}return(e,a)=>(I(),L(`aside`,{class:E([`network-sidebar`,{open:A(J).drawer,collapsed:!A(ku).tree&&!A(J).drawer}]),"aria-label":`Network`},[A(ku).tree||A(J).drawer?(I(),L(F,{key:0},[z(`header`,ip,[z(`span`,null,[B(A(Bc),{size:16}),a[8]||=V(`NETWORK`,-1)]),z(`button`,{class:E([`icon-button`,{on:g.value}]),"aria-label":g.value?`Exit bulk select`:`Bulk manage sessions`,title:g.value?`Exit bulk select`:`Bulk manage sessions (select → archive / abort)`,onClick:a[0]||=e=>(g.value=!g.value,_.value=new Set)},[B(A(Pc),{size:15})],10,ap),z(`button`,{class:`icon-button`,"aria-label":`Pair a device`,title:`Pair a device`,onClick:a[1]||=e=>A(J).dialog={kind:`pair`}},[B(A(Nc),{size:15})]),z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse network`,title:`Collapse network (${A(Dd).tree})`,onClick:a[2]||=e=>(A(ku).tree=!1,A(J).drawer=!1)},[B(A(Uc),{size:18})],8,op)]),z(`div`,sp,[B(A(nl),{size:14,class:`search-icon`}),j(z(`input`,{"onUpdate:modelValue":a[3]||=e=>i.value=e,type:`search`,class:`search-input`,placeholder:`Search sessions…`,"aria-label":`Search sessions`,spellcheck:`false`},null,512),[[ys,i.value]]),i.value?(I(),L(`button`,{key:0,class:`icon-button clear`,"aria-label":`Clear search`,onClick:h},[B(A(xl),{size:13})])):H(``,!0),o.value?(I(),L(`span`,cp,`…`)):H(``,!0)]),B($f,{active:u.value,"onUpdate:active":a[4]||=e=>u.value=e},null,8,[`active`]),z(`div`,{ref_key:`list`,ref:r,class:`tree-list`,role:`tree`,tabindex:`0`,"aria-label":`Devices, sessions and agents`,onKeydown:ne,onFocus:te},[g.value&&_.value.size?(I(),L(`div`,lp,[z(`span`,null,D(_.value.size)+` selected`,1),z(`button`,{class:`small`,disabled:!!v.value,onClick:a[5]||=e=>b(`abort`)},`abort work`,8,up),z(`button`,{class:`small danger`,disabled:!!v.value,onClick:a[6]||=e=>b(`archive`)},D(v.value===`archive`?`archiving…`:`archive`),9,dp)])):H(``,!0),(I(!0),L(F,null,P(f.value,e=>(I(),R(Ff,{key:e.node.key,node:e.node,depth:e.depth,open:A(Du).has(e.node.key),selected:C(e.node),focused:n.value===e.node.key,online:S(e.node),checkbox:g.value&&e.node.type===`session`,checked:e.node.type===`session`&&_.value.has(e.node.session.id),onToggle:t=>A(Wu)(e.node.key),onActivate:t=>ee(e.node),onAction:t=>w(e.node,t),onCheck:t=>y(e.node)},null,8,[`node`,`depth`,`open`,`selected`,`focused`,`online`,`checkbox`,`checked`,`onToggle`,`onActivate`,`onAction`,`onCheck`]))),128)),c.value&&p.value.length?(I(),L(F,{key:1},[z(`div`,fp,D(p.value.length)+` more on device`,1),(I(!0),L(F,null,P(p.value,e=>(I(),L(`button`,{key:`${e.deviceId}-${e.id}`,class:`hit`,title:e.cwd,onClick:t=>A(Vu)({deviceId:e.deviceId,sessionId:e.id,agentId:1})},[z(`span`,mp,D(e.name),1),z(`code`,hp,D(e.cwd),1),e.where.length?(I(),L(`em`,gp,D(e.where.join(` · `)),1)):H(``,!0)],8,pp))),128))],64)):H(``,!0),c.value&&!f.value.length&&!p.value.length?(I(),L(`p`,_p,` No session matches “`+D(i.value.trim())+`”. `,1)):H(``,!0),!t.value.length&&!c.value?(I(),L(`p`,vp,[...a[9]||=[V(` No devices yet. Declare them in `,-1),z(`code`,null,`dpi-network.yaml`,-1),V(` (start from `,-1),z(`code`,null,`dpi-network.example.yaml`,-1),V(`), then run `,-1),z(`code`,null,`just net up <id>`,-1),V(`. `,-1)]])):H(``,!0)],544)],64)):(I(),L(`div`,yp,[z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand network`,title:`Expand network (${A(Dd).tree})`,onClick:a[7]||=e=>A(ku).tree=!0},[B(A(Wc),{size:18})],8,bp),(I(!0),L(F,null,P(A(wu).devices.value,e=>(I(),L(`button`,{key:e.id,class:`rail-device`,title:`${e.id} · ${e.status}`,"aria-label":`Show ${e.id}`,onClick:t=>(A(ku).tree=!0,A(Wu)(e.id,!0))},[B(Yd,{device:e,size:20},null,8,[`device`]),z(`i`,{class:E([`dot`,e.status===`online`?`on`:e.status===`checking`?`chk`:e.status===`offline`?`off`:`err`])},null,2)],8,xp))),128))]))],2))}}),[[`__scopeId`,`data-v-b75a54cc`]]);function Cp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var wp=Cp();function Tp(e){wp=e}var Ep={exec:()=>null};function Dp(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(kp.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Op=(()=>{try{return!0}catch{return!1}})(),kp={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,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ 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,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},Ap=/^(?:[ \t]*(?:\n|$))+/,jp=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Mp=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Np=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Pp=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Fp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ip=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Lp=Dp(Ip).replace(/bull/g,Fp).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(),Rp=Dp(Ip).replace(/bull/g,Fp).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(),zp=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Bp=/^[^\n]+/,Vp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Hp=Dp(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Vp).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Up=Dp(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Fp).getRegex(),Wp=`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`,Gp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Kp=Dp(`^ {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`,Gp).replace(`tag`,Wp).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),qp=Dp(zp).replace(`hr`,Np).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[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Wp).getRegex(),Jp={blockquote:Dp(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,qp).getRegex(),code:jp,def:Hp,fences:Mp,heading:Pp,hr:Np,html:Kp,lheading:Lp,list:Up,newline:Ap,paragraph:qp,table:Ep,text:Bp},Yp=Dp(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Np).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[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Wp).getRegex(),Xp={...Jp,lheading:Rp,table:Yp,paragraph:Dp(zp).replace(`hr`,Np).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Yp).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Wp).getRegex()},Zp={...Jp,html:Dp(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Gp).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:Ep,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Dp(zp).replace(`hr`,Np).replace(`heading`,` *#{1,6} *[^
17
+ ]`).replace(`lheading`,Lp).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Qp=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,$p=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,em=/^( {2,}|\\)\n(?!\s*$)/,tm=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,nm=/[\p{P}\p{S}]/u,rm=/[\s\p{P}\p{S}]/u,im=/[^\s\p{P}\p{S}]/u,am=Dp(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,rm).getRegex(),om=/(?!~)[\p{P}\p{S}]/u,sm=/(?!~)[\s\p{P}\p{S}]/u,cm=/(?:[^\s\p{P}\p{S}]|~)/u,lm=Dp(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Op?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),um=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,dm=Dp(um,`u`).replace(/punct/g,nm).getRegex(),fm=Dp(um,`u`).replace(/punct/g,om).getRegex(),pm=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,mm=Dp(pm,`gu`).replace(/notPunctSpace/g,im).replace(/punctSpace/g,rm).replace(/punct/g,nm).getRegex(),hm=Dp(pm,`gu`).replace(/notPunctSpace/g,cm).replace(/punctSpace/g,sm).replace(/punct/g,om).getRegex(),gm=Dp(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,im).replace(/punctSpace/g,rm).replace(/punct/g,nm).getRegex(),_m=Dp(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,nm).getRegex(),vm=Dp(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,im).replace(/punctSpace/g,rm).replace(/punct/g,nm).getRegex(),ym=Dp(/\\(punct)/,`gu`).replace(/punct/g,nm).getRegex(),bm=Dp(/^<(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(),xm=Dp(Gp).replace(`(?:-->|$)`,`-->`).getRegex(),Sm=Dp(`^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`,xm).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Cm=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,wm=Dp(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Cm).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Tm=Dp(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Cm).replace(`ref`,Vp).getRegex(),Em=Dp(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Vp).getRegex(),Dm=Dp(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Tm).replace(`nolink`,Em).getRegex(),Om=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,km={_backpedal:Ep,anyPunctuation:ym,autolink:bm,blockSkip:lm,br:em,code:$p,del:Ep,delLDelim:Ep,delRDelim:Ep,emStrongLDelim:dm,emStrongRDelimAst:mm,emStrongRDelimUnd:gm,escape:Qp,link:wm,nolink:Em,punctuation:am,reflink:Tm,reflinkSearch:Dm,tag:Sm,text:tm,url:Ep},Am={...km,link:Dp(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Cm).getRegex(),reflink:Dp(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Cm).getRegex()},jm={...km,emStrongRDelimAst:hm,emStrongLDelim:fm,delLDelim:_m,delRDelim:vm,url:Dp(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Om).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\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Dp(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Om).getRegex()},Mm={...jm,br:Dp(em).replace(`{2,}`,`*`).getRegex(),text:Dp(jm.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Nm={normal:Jp,gfm:Xp,pedantic:Zp},Pm={normal:km,gfm:jm,breaks:Mm,pedantic:Am},Fm={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Im=e=>Fm[e];function Lm(e,t){if(t){if(kp.escapeTest.test(e))return e.replace(kp.escapeReplace,Im)}else if(kp.escapeTestNoEncode.test(e))return e.replace(kp.escapeReplaceNoEncode,Im);return e}function Rm(e){try{e=encodeURI(e).replace(kp.percentDecode,`%`)}catch{return null}return e}function zm(e,t){let n=e.replace(kp.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(kp.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(kp.slashPipe,`|`);return n}function Bm(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Vm(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Hm(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Um(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Wm(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
18
18
  `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
19
- `)}var Wm=class{options;rules;lexer;constructor(e){this.options=e||Cp}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:zm(e,`
20
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Um(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=zm(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:zm(t[0],`
21
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=zm(t[0],`
19
+ `)}var Gm=class{options;rules;lexer;constructor(e){this.options=e||wp}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:Bm(e,`
20
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Wm(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Bm(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Bm(t[0],`
21
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Bm(t[0],`
22
22
  `).split(`
23
23
  `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
24
24
  `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
@@ -29,17 +29,17 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
29
29
  `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
30
30
  `+e.join(`
31
31
  `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
32
- `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=Vm(t[2].split(`
32
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=Hm(t[2].split(`
33
33
  `,1)[0],t[1].length),l=e.split(`
34
34
  `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
35
35
  `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
36
36
  `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
37
37
  `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
38
38
  `+l}u=!l.trim(),r+=p+`
39
- `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Rm(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
40
- `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Rm(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
41
- `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=zm(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Bm(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Hm(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Hm(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Gm=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Cp,this.options.tokenizer=this.options.tokenizer||new Wm,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Op,block:Mm.normal,inline:Nm.normal};this.options.pedantic?(t.block=Mm.pedantic,t.inline=Nm.pedantic):this.options.gfm&&(t.block=Mm.gfm,t.inline=this.options.breaks?Nm.breaks:Nm.gfm),this.tokenizer.rules=t}static get rules(){return{block:Mm,inline:Nm}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Op.carriageReturn,`
42
- `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Op.tabCharGlobal,` `).replace(Op.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
39
+ `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=zm(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
40
+ `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(zm(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
41
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Bm(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Vm(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Um(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Um(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Km=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||wp,this.options.tokenizer=this.options.tokenizer||new Gm,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:kp,block:Nm.normal,inline:Pm.normal};this.options.pedantic?(t.block=Nm.pedantic,t.inline=Pm.pedantic):this.options.gfm&&(t.block=Nm.gfm,t.inline=this.options.breaks?Pm.breaks:Pm.gfm),this.tokenizer.rules=t}static get rules(){return{block:Nm,inline:Pm}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(kp.carriageReturn,`
42
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(kp.tabCharGlobal,` `).replace(kp.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
43
43
  `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
44
44
  `)?``:`
45
45
  `)+r.raw,n.text+=`
@@ -52,9 +52,9 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
52
52
  `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
53
53
  `)?``:`
54
54
  `)+r.raw,n.text+=`
55
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},Km=class{options;parser;constructor(e){this.options=e||Cp}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Op.notSpaceStart)?.[0],i=e.replace(Op.endingNewline,``)+`
56
- `;return r?`<pre><code class="language-`+Im(r)+`">`+(n?i:Im(i,!0))+`</code></pre>
57
- `:`<pre><code>`+(n?i:Im(i,!0))+`</code></pre>
55
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},qm=class{options;parser;constructor(e){this.options=e||wp}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(kp.notSpaceStart)?.[0],i=e.replace(kp.endingNewline,``)+`
56
+ `;return r?`<pre><code class="language-`+Lm(r)+`">`+(n?i:Lm(i,!0))+`</code></pre>
57
+ `:`<pre><code>`+(n?i:Lm(i,!0))+`</code></pre>
58
58
  `}blockquote({tokens:e}){return`<blockquote>
59
59
  ${this.parser.parse(e)}</blockquote>
60
60
  `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -70,12 +70,12 @@ ${this.parser.parse(e)}</blockquote>
70
70
  `}tablerow({text:e}){return`<tr>
71
71
  ${e}</tr>
72
72
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
73
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Im(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Lm(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Im(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Lm(e);if(i===null)return Im(n);e=i;let a=`<img src="${e}" alt="${Im(n)}"`;return t&&(a+=` title="${Im(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Im(e.text)}},qm=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Jm=class e{options;renderer;textRenderer;constructor(e){this.options=e||Cp,this.options.renderer=this.options.renderer||new Km,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new qm}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Ym=class{options;block;constructor(e){this.options=e||Cp}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Gm.lex:Gm.lexInline}provideParser(e=this.block){return e?Jm.parse:Jm.parseInline}},Xm=new class{defaults=Sp();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Jm;Renderer=Km;TextRenderer=qm;Lexer=Gm;Tokenizer=Wm;Hooks=Ym;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Km(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Wm(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Ym;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Ym.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Ym.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Gm.lex(e,t??this.defaults)}parser(e,t){return Jm.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Gm.lex:Gm.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Jm.parse:Jm.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Gm.lex:Gm.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Jm.parse:Jm.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
74
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Im(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Zm(e,t){return Xm.parse(e,t)}Zm.options=Zm.setOptions=function(e){return Xm.setOptions(e),Zm.defaults=Xm.defaults,wp(Zm.defaults),Zm},Zm.getDefaults=Sp,Zm.defaults=Cp,Zm.use=function(...e){return Xm.use(...e),Zm.defaults=Xm.defaults,wp(Zm.defaults),Zm},Zm.walkTokens=function(e,t){return Xm.walkTokens(e,t)},Zm.parseInline=Xm.parseInline,Zm.Parser=Jm,Zm.parser=Jm.parse,Zm.Renderer=Km,Zm.TextRenderer=qm,Zm.Lexer=Gm,Zm.lexer=Gm.lex,Zm.Tokenizer=Wm,Zm.Hooks=Ym,Zm.parse=Zm,Zm.options,Zm.setOptions,Zm.use,Zm.walkTokens,Zm.parseInline,Jm.parse,Gm.lex;function Qm(e,t){this.v=e,this.k=t}function $m(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eh(e){if(Array.isArray(e))return e}function th(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function nh(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
75
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rh(e,t){return eh(e)||th(e,t)||ih(e,t)||nh()}function ih(e,t){if(e){if(typeof e==`string`)return $m(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$m(e,t):void 0}}function ah(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Qm;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}ah.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},ah.prototype.next=function(e){return this._invoke(`next`,e)},ah.prototype.throw=function(e){return this._invoke(`throw`,e)},ah.prototype.return=function(e){return this._invoke(`return`,e)};var oh=Object.entries,sh=Object.setPrototypeOf,ch=Object.isFrozen,lh=Object.getPrototypeOf,uh=Object.getOwnPropertyDescriptor,dh=Object.freeze,fh=Object.seal,ph=Object.create,mh=typeof Reflect<`u`&&Reflect,hh=mh.apply,gh=mh.construct;dh||=function(e){return e},fh||=function(e){return e},hh||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},gh||=function(e){return new e(...[...arguments].slice(1))};var _h=Lh(Array.prototype.forEach);Array.prototype.indexOf;var vh=Lh(Array.prototype.lastIndexOf),yh=Lh(Array.prototype.pop),bh=Lh(Array.prototype.push);Array.prototype.slice;var xh=Lh(Array.prototype.splice),Sh=Array.isArray,Ch=Lh(String.prototype.toLowerCase),wh=Lh(String.prototype.toString),Th=Lh(String.prototype.match),Eh=Lh(String.prototype.replace),Dh=Lh(String.prototype.indexOf),Oh=Lh(String.prototype.trim),kh=Lh(Number.prototype.toString),Ah=Lh(Boolean.prototype.toString),jh=typeof BigInt>`u`?null:Lh(BigInt.prototype.toString),Mh=typeof Symbol>`u`?null:Lh(Symbol.prototype.toString),Nh=Lh(Object.prototype.hasOwnProperty),Ph=Lh(Object.prototype.toString),Fh=Lh(RegExp.prototype.test),Ih=Rh(TypeError);function Lh(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return hh(e,t,n)}}function Rh(e){return function(){return gh(e,[...arguments])}}function zh(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ch;if(sh&&sh(e,null),!Sh(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ch(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Bh(e){for(let t=0;t<e.length;t++)Nh(e,t)||(e[t]=null);return e}function Vh(e){let t=ph(null);for(let r of oh(e)){var n=rh(r,2);let i=n[0],a=n[1];Nh(e,i)&&(t[i]=Sh(a)?Bh(a):a&&typeof a==`object`&&a.constructor===Object?Vh(a):a)}return t}function Hh(e){switch(typeof e){case`string`:return e;case`number`:return kh(e);case`boolean`:return Ah(e);case`bigint`:return jh?jh(e):`0`;case`symbol`:return Mh?Mh(e):`Symbol()`;case`undefined`:return Ph(e);case`function`:case`object`:{if(e===null)return Ph(e);let t=e,n=Uh(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Ph(e)}return Ph(e)}default:return Ph(e)}}function Uh(e,t){for(;e!==null;){let n=uh(e,t);if(n){if(n.get)return Lh(n.get);if(typeof n.value==`function`)return Lh(n.value)}e=lh(e)}function n(){return null}return n}function Wh(e){try{return Fh(e,``),!0}catch{return!1}}var Gh=dh(`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`.split(`.`)),Kh=dh(`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`.split(`.`)),qh=dh([`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`]),Jh=dh([`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`]),Yh=dh(`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`.split(`.`)),Xh=dh([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Zh=dh([`#text`]),Qh=dh(`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`.split(`.`)),$h=dh(`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.dominant-baseline.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.pointer-events.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-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.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`.split(`.`)),eg=dh(`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`.split(`.`)),tg=dh([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),ng=fh(/{{[\w\W]*|^[\w\W]*}}/g),rg=fh(/<%[\w\W]*|^[\w\W]*%>/g),ig=fh(/\${[\w\W]*/g),ag=fh(/^data-[\-\w.\u00B7-\uFFFF]+$/),og=fh(/^aria-[\-\w]+$/),sg=fh(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cg=fh(/^(?:\w+script|data):/i),lg=fh(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ug=fh(/^html$/i),dg=fh(/^[a-z][.\w]*(-[.\w]+)+$/i),fg=fh(/<[/\w!]/g),pg=fh(/<[/\w]/g),mg=fh(/<\/no(script|embed|frames)/i),hg=fh(/\/>/i),gg={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_g=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],vg=dh(zh({},_g)),yg=function(){let e={};return _h(_g,t=>{e[t]=fh(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),dh(e)}(),bg=function(){return typeof window>`u`?null:window},xg=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Sg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Cg=function(e,t,n,r){return Nh(e,t)&&Sh(e[t])?zh(r.base?Vh(r.base):{},e[t],r.transform):n},wg=function(e,t,n){let r=Nh(e,t)?e[t]:void 0;return r&&typeof r==`object`?Vh(r):n()};function Tg(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:bg(),t=e=>Tg(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==gg.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Uh(d,`cloneNode`),p=Uh(d,`remove`),m=Uh(d,`removeAttributeNode`),h=Uh(d,`nextSibling`),g=Uh(d,`childNodes`),_=Uh(d,`parentNode`),v=Uh(d,`shadowRoot`),y=Uh(d,`attributes`),b=o&&o.prototype?Uh(o.prototype,`nodeType`):null,x=o&&o.prototype?Uh(o.prototype,`nodeName`):null,S=o&&o.prototype?Uh(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},ee=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let w,T=``,te,ne=!1,re=0,ie=function(){if(re>0)throw Ih(`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.`)},ae=function(e){ie(),re++;try{return w.createHTML(e)}finally{re--}},oe=function(e){ie(),re++;try{return w.createScriptURL(e)}finally{re--}},se=function(){return ne||=(te=xg(u,i),!0),te},ce=n,le=ce.implementation,ue=ce.createNodeIterator,de=ce.createDocumentFragment,fe=ce.getElementsByTagName,pe=r.importNode,me=Sg();t.isSupported=typeof oh==`function`&&typeof _==`function`&&le&&le.createHTMLDocument!==void 0;let he=ng,ge=rg,_e=ig,ve=ag,ye=og,be=cg,E=lg,xe=dg,Se=sg,Ce=null,we=zh({},[...Gh,...Kh,...qh,...Yh,...Zh]),Te=null,Ee=zh({},[...Qh,...$h,...eg,...tg]),De=Object.seal(ph(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}})),Oe=null,ke=null,Ae=Object.seal(ph(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),D=!0,je=!0,Me=!1,Ne=!0,Pe=!1,Fe=!0,O=!1,Ie=!1,Le=null,Re=null,ze=!1,Be=!1,Ve=!1,He=!1,Ue=!0,We=!1,Ge=`user-content-`,Ke=!0,qe=!1,Je={},Ye=null,Xe=zh({},`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`.split(`.`)),Ze=null,Qe=zh({},[`audio`,`video`,`img`,`source`,`image`,`track`]),$e=null,et=zh({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),tt=`http://www.w3.org/1998/Math/MathML`,nt=`http://www.w3.org/2000/svg`,rt=`http://www.w3.org/1999/xhtml`,it=rt,at=!1,ot=null,st=zh({},[tt,nt,rt],wh),ct=dh([`mi`,`mo`,`mn`,`ms`,`mtext`]),lt=zh({},ct),ut=dh([`annotation-xml`]),dt=zh({},ut),ft=zh({},[`title`,`style`,`font`,`a`,`script`]),pt=null,mt=[`application/xhtml+xml`,`text/html`],ht=null,gt=null,_t=n.createElement(`form`),vt=function(e){return e instanceof RegExp||e instanceof Function},yt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(gt&&gt===e)return;(!e||typeof e!=`object`)&&(e={}),e=Vh(e),pt=mt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ht=pt===`application/xhtml+xml`?wh:Ch,Ce=Cg(e,`ALLOWED_TAGS`,we,{transform:ht}),Te=Cg(e,`ALLOWED_ATTR`,Ee,{transform:ht}),ot=Cg(e,`ALLOWED_NAMESPACES`,st,{transform:wh}),$e=Cg(e,`ADD_URI_SAFE_ATTR`,et,{transform:ht,base:et}),Ze=Cg(e,`ADD_DATA_URI_TAGS`,Qe,{transform:ht,base:Qe}),Ye=Cg(e,`FORBID_CONTENTS`,Xe,{transform:ht}),Oe=Cg(e,`FORBID_TAGS`,Vh({}),{transform:ht}),ke=Cg(e,`FORBID_ATTR`,Vh({}),{transform:ht}),Je=Nh(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Vh(e.USE_PROFILES):e.USE_PROFILES:!1,D=e.ALLOW_ARIA_ATTR!==!1,je=e.ALLOW_DATA_ATTR!==!1,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Pe=e.SAFE_FOR_TEMPLATES||!1,Fe=e.SAFE_FOR_XML!==!1,O=e.WHOLE_DOCUMENT||!1,Be=e.RETURN_DOM||!1,Ve=e.RETURN_DOM_FRAGMENT||!1,He=e.RETURN_TRUSTED_TYPE||!1,ze=e.FORCE_BODY||!1,Ue=e.SANITIZE_DOM!==!1,We=e.SANITIZE_NAMED_PROPS||!1,Ke=e.KEEP_CONTENT!==!1,qe=e.IN_PLACE||!1,Se=Wh(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:sg,it=typeof e.NAMESPACE==`string`?e.NAMESPACE:rt,lt=wg(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>zh({},ct)),dt=wg(e,`HTML_INTEGRATION_POINTS`,()=>zh({},ut));let t=wg(e,`CUSTOM_ELEMENT_HANDLING`,()=>ph(null));if(De=ph(null),Nh(t,`tagNameCheck`)&&vt(t.tagNameCheck)&&(De.tagNameCheck=t.tagNameCheck),Nh(t,`attributeNameCheck`)&&vt(t.attributeNameCheck)&&(De.attributeNameCheck=t.attributeNameCheck),Nh(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(De.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),fh(De),Pe&&(je=!1),Ve&&(Be=!0),Je&&(Ce=zh({},Zh),Te=ph(null),Je.html===!0&&(zh(Ce,Gh),zh(Te,Qh)),Je.svg===!0&&(zh(Ce,Kh),zh(Te,$h),zh(Te,tg)),Je.svgFilters===!0&&(zh(Ce,qh),zh(Te,$h),zh(Te,tg)),Je.mathMl===!0&&(zh(Ce,Yh),zh(Te,eg),zh(Te,tg))),Ae.tagCheck=null,Ae.attributeCheck=null,Nh(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Ae.tagCheck=e.ADD_TAGS:Sh(e.ADD_TAGS)&&(Ce===we&&(Ce=Vh(Ce)),zh(Ce,e.ADD_TAGS,ht))),Nh(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Ae.attributeCheck=e.ADD_ATTR:Sh(e.ADD_ATTR)&&(Te===Ee&&(Te=Vh(Te)),zh(Te,e.ADD_ATTR,ht))),Nh(e,`ADD_FORBID_CONTENTS`)&&Sh(e.ADD_FORBID_CONTENTS)&&(Ye===Xe&&(Ye=Vh(Ye)),zh(Ye,e.ADD_FORBID_CONTENTS,ht)),Ke&&(Ce[`#text`]=!0),O&&zh(Ce,[`html`,`head`,`body`]),Ce.table&&(zh(Ce,[`tbody`]),delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Ih(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Ih(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=w;w=e.TRUSTED_TYPES_POLICY;try{T=ae(``)}catch(e){throw w=t,e}}else e.TRUSTED_TYPES_POLICY===null?(w=void 0,T=``):(w===void 0&&(w=se()),w&&typeof T==`string`&&(T=ae(``)));dh&&dh(e),gt=e},bt=zh({},[...Kh,...qh,...Jh]),xt=zh({},[...Yh,...Xh]),St=function(e,t,n){return t.namespaceURI===rt?e===`svg`:t.namespaceURI===tt?e===`svg`&&(n===`annotation-xml`||lt[n]):!!bt[e]},Ct=function(e,t,n){return t.namespaceURI===rt?e===`math`:t.namespaceURI===nt?e===`math`&&dt[n]:!!xt[e]},wt=function(e,t,n){return t.namespaceURI===nt&&!dt[n]||t.namespaceURI===tt&&!lt[n]?!1:!xt[e]&&(ft[e]||!bt[e])},Tt=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:it,tagName:`template`});let n=Ch(e.tagName),r=Ch(t.tagName);return ot[e.namespaceURI]?e.namespaceURI===nt?St(n,t,r):e.namespaceURI===tt?Ct(n,t,r):e.namespaceURI===rt?wt(n,t,r):!!(pt===`application/xhtml+xml`&&ot[e.namespaceURI]):!1},Et=function(e){bh(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw Ih(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Dt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Ot=function(e){jt(e);let t=g(e);if(t){let e=[];_h(t,t=>{bh(e,t)}),_h(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&Dt(e,r,i)}},kt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}bh(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Be||Ve)try{Et(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},At=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||Te[ht(i)]||Dt(e,r,i)}},jt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===gg.element&&At(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Mt=function(e,t){return Fe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Nt=function(e){if(!Fe)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===gg.processingInstruction||n===gg.comment&&Fh(pg,e.data)){try{p(e)}catch{}continue}if(n===gg.element){let t=e,n=ht(ee(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Mt(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Pt=function(e){let t=null,r=null;if(ze)e=`<remove></remove>`+e;else{let t=Th(e,/^[\r\n\t ]+/);r=t&&t[0]}pt===`application/xhtml+xml`&&it===rt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=w?ae(e):e;if(it===rt)try{t=new l().parseFromString(i,pt)}catch{}if(!t||!t.documentElement){t=le.createDocument(it,`template`,null);try{t.documentElement.innerHTML=at?T:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),it===rt?fe.call(t,O?`html`:`body`)[0]:O?t.documentElement:a},Ft=function(e){let t=S?S(e):e.ownerDocument;return ue.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},It=function(e){return e=Eh(e,he,` `),e=Eh(e,ge,` `),e=Eh(e,_e,` `),e},Lt=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=ue.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=It(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&_h(i,e=>{zt(e.content)&&Lt(e.content)})},Rt=function(e){let t=x?x(e):null;return typeof t!=`string`||ht(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},zt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===gg.documentFragment}catch{return!1}},Bt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Vt(e,n,r){e.length!==0&&_h(e,e=>{e.call(t,n,r,gt)})}let Ht=function(e,t){return!!(Fe&&e.hasChildNodes()&&!Bt(e.firstElementChild)&&Fh(fg,e.textContent)&&Fh(fg,e.innerHTML)||Fe&&e.namespaceURI===rt&&vg[t]&&(Bt(e.firstElementChild)||typeof e.textContent==`string`&&Fh(yg[t],e.textContent))||e.nodeType===gg.processingInstruction||Fe&&e.nodeType===gg.comment&&Fh(pg,e.data))},Ut=function(e,t){return e instanceof RegExp?Fh(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Wt=function(e,t,n){if(!Oe[t]&&Xt(t)&&Ut(De.tagNameCheck,t))return!1;if(Ke&&!Ye[t]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return Et(e),!0},Gt=function(e,t,n,r){return e.length===0?t:t===n||t===r?Vh(t):t},Kt=function(e,t){return e===t||_(e)!==null?!1:(qe&&jt(e),!0)},qt=function(e,n){if(Vt(me.beforeSanitizeElements,e,null),Kt(e,n))return!0;if(Rt(e))return Et(e),!0;let r=ht(ee(e));if(Ce=Gt(me.uponSanitizeElement,Ce,we,Le),Vt(me.uponSanitizeElement,e,{tagName:r,allowedTags:Ce}),Kt(e,n))return!0;if(Ht(e,r))return Et(e),!0;if(Oe[r]||!(Ae.tagCheck instanceof Function&&Ae.tagCheck(r))&&!Ce[r]){let t=Wt(e,r,n);return t===!1&&(Vt(me.afterSanitizeElements,e,null),Kt(e,n))?!0:t}if(C(e)===gg.element&&!Tt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Fh(mg,e.innerHTML))return Et(e),!0;if(Pe&&e.nodeType===gg.text){let n=It(e.textContent);e.textContent!==n&&(bh(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Vt(me.afterSanitizeElements,e,null),Kt(e,n)},Jt=function(e,t,r){if(ke[t]||Mt(t,e)||Ue&&(t===`id`||t===`name`)&&(r in n||r in _t))return!1;let i=Te[t]||Ae.attributeCheck instanceof Function&&Ae.attributeCheck(t,e);return je&&Fh(ve,t)||D&&Fh(ye,t)?!0:i?$e[t]||Fh(Se,Eh(r,E,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Dh(r,`data:`)===0&&Ze[e]||Me&&!Fh(be,Eh(r,E,``))?!0:!r:Xt(e)&&Ut(De.tagNameCheck,e)&&Ut(De.attributeNameCheck,t,e)||t===`is`&&De.allowCustomizedBuiltInElements&&Ut(De.tagNameCheck,r)},Yt=zh({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Xt=function(e){return!Yt[Ch(e)]&&Fh(xe,e)},Zt=function(e,t,n,r){if(w&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ae(r);case`TrustedScriptURL`:return oe(r)}return r},Qt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Rt(e)||(Et(e),!1)}catch{return kt(t,e),!1}},$t=function(e,n){if(Vt(me.beforeSanitizeAttributes,e,null),Kt(e,n))return;let r=e.attributes;if(!r||Rt(e))return;Te=Gt(me.uponSanitizeAttribute,Te,Ee,Re);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:Te,forceKeepAttr:void 0},a=r.length,o=ht(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=ht(s),d=l,f=s===`value`?d:Oh(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Vt(me.uponSanitizeAttribute,e,i),f=i.attrValue,We&&(u===`id`||u===`name`)&&Dh(f,Ge)!==0&&(kt(s,e,n),f=Ge+f,p=!0),Fe&&Fh(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){kt(s,e,n);continue}if(u===`attributename`&&Th(f,`href`)){kt(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){kt(s,e,n);continue}if(!Ne&&Fh(hg,f)){kt(s,e,n);continue}if(Pe&&(f=It(f)),!Jt(o,u,f)){kt(s,e,n);continue}f=Zt(o,u,c,f),f!==d&&Qt(e,s,c,f)&&p&&yh(t.removed)}}Vt(me.afterSanitizeAttributes,e,null),Kt(e,n)},en=function(e){let t=null,n=Ft(e);for(Vt(me.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Vt(me.uponSanitizeShadowNode,t,null),qt(t,e),$t(t,e),zt(t.content)&&en(t.content),C(t)===gg.element){let e=v(t);zt(e)&&(tn(e),en(e))}Vt(me.afterSanitizeShadowDOM,e,null)},tn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){en(e.shadow);continue}let n=e.node,r=C(n)===gg.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&ht(e)===`template`){let e=n.content;zt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);zt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(at=!e,at&&(e=`<!-->`),typeof e!=`string`&&!Bt(e)&&(e=Hh(e),typeof e!=`string`))throw Ih(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ie?(Ce=Le,Te=Re):yt(n),(me.uponSanitizeElement.length>0||me.uponSanitizeAttribute.length>0)&&(Ce=Vh(Ce)),me.uponSanitizeAttribute.length>0&&(Te=Vh(Te)),t.removed=[];let c=qe&&typeof e!=`string`&&Bt(e);if(c){Nt(e);let t=ee(e);if(typeof t==`string`){let n=ht(t);if(!Ce[n]||Oe[n])throw Ot(e),Ih(`root node is forbidden and cannot be sanitized in-place`)}if(Rt(e))throw Ot(e),Ih(`root node is clobbered and cannot be sanitized in-place`);try{tn(e)}catch(t){throw Ot(e),t}}else if(Bt(e))i=Pt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===gg.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),tn(i);else{if(!Be&&!Pe&&!O&&e.indexOf(`<`)===-1)return w&&He?ae(e):e;if(i=Pt(e),!i)return Be?null:He?T:``}i&&ze&&Et(i.firstChild);let l=c?e:i;try{let e=Ft(l);for(;o=e.nextNode();)qt(o,l),$t(o,l),zt(o.content)&&en(o.content)}catch(n){throw c&&(Ot(e),_h(t.removed,e=>{e.element&&jt(e.element)})),n}if(c){let n=!1;if(_h(t.removed,t=>{t.element&&(t.element===e&&(n=!0),jt(t.element))}),n)throw Ih(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Pe&&Lt(e),e}if(Be){if(Pe&&Lt(i),Ve)for(s=de.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(Te.shadowroot||Te.shadowrootmode)&&(s=pe.call(r,s,!0)),s}let u=O?i.outerHTML:i.innerHTML;return O&&Ce[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Fh(ug,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
76
- `+u),Pe&&(u=It(u)),w&&He?ae(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yt(e),Ie=!0,Le=Ce,Re=Te},t.clearConfig=function(){gt=null,Ie=!1,Le=null,Re=null,w=te,T=``},t.isValidAttribute=function(e,t,n){gt||yt({});let r=ht(e),i=ht(t);return Jt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Nh(me,e)&&bh(me[e],t)},t.removeHook=function(e,t){if(Nh(me,e)){if(t!==void 0){let n=vh(me[e],t);return n===-1?void 0:xh(me[e],n,1)[0]}return yh(me[e])}},t.removeHooks=function(e){Nh(me,e)&&(me[e]=[])},t.removeAllHooks=function(){me=Sg()},t}var Eg=Tg();function Dg(e,t){let n;try{n=new URL(e.trim())}catch{return null}return n.protocol!==`https:`&&n.protocol!==`http:`||n.origin===t?null:n.href}var Og=`p.br.hr.strong.b.em.i.del.s.code.pre.blockquote.ul.ol.li.a.h1.h2.h3.h4.h5.h6.small.sub.sup.table.thead.tbody.tr.th.td.img.input`.split(`.`),kg=[`form`,`style`,`script`,`button`,`select`,`textarea`,`iframe`,`object`,`embed`,`svg`,`math`],Ag={a:[`href`,`title`],img:[`src`,`alt`,`title`],th:[`colspan`,`rowspan`,`align`],td:[`colspan`,`rowspan`,`align`],ol:[`start`],code:[`class`],input:[`type`,`checked`,`disabled`]},jg=[...new Set(Object.values(Ag).flat())],Mg=/^language-[\w-]+$/,Ng=/^\d{1,4}$/,Pg=/^(left|right|center)$/i;function Fg(e,t,n){if(!Object.hasOwn(Ag,e)||!Ag[e].includes(t))return!1;switch(t){case`class`:return Mg.test(n);case`type`:return n.toLowerCase()===`checkbox`;case`colspan`:case`rowspan`:case`start`:return Ng.test(n);case`align`:return Pg.test(n);default:return!0}}var Ig=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/i,Lg=/^\/api(\/|$)/i;function Rg(e,t){if(Ig.test(e))return!0;if(!e.trim())return!1;let n;try{n=new URL(e,t)}catch{return!1}return(n.protocol===`https:`||n.protocol===`http:`)&&n.origin===t&&!Lg.test(n.pathname)}Eg.isSupported&&Eg.addHook(`afterSanitizeAttributes`,e=>{let t=e.nodeName.toLowerCase();for(let{name:n,value:r}of Array.from(e.attributes))Fg(t,n,r)||e.removeAttribute(n);if(t===`img`&&!Rg(e.getAttribute(`src`)??``,location.origin)){e.replaceWith(document.createTextNode(e.getAttribute(`alt`)??``));return}if(t===`input`){e.getAttribute(`type`)===null?e.remove():e.setAttribute(`disabled`,``);return}if(t!==`a`)return;let n=e.getAttribute(`href`),r=n===null?null:Dg(n,location.origin);r?(e.setAttribute(`href`,r),e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):(e.removeAttribute(`href`),e.removeAttribute(`target`))});var zg={ALLOWED_TAGS:Og,ALLOWED_ATTR:jg,FORBID_TAGS:kg,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1},Bg=new Map;function Vg(e){let t=Bg.get(e);return t===void 0&&(t=Eg.sanitize(Zm.parse(e,{async:!1}),zg),Bg.size>400&&Bg.delete(Bg.keys().next().value),Bg.set(e,t)),t}var Hg=`demo.job-runs`,Ug=e=>e.status!==`running`&&e.status!==`waiting`,Wg=U(()=>ju.value?.info?.jobs??[]),Gg=e=>Wg.value.find(t=>t.id===e),Kg=U(()=>{let e=Ju.value.docs[Hg];return Object.values(e?.items??{}).sort((e,t)=>t.id-e.id)}),qg=e=>Kg.value.find(t=>t.id===e),Jg=e=>Kg.value.find(t=>t.toolCallId===e),Yg=k(Date.now());setInterval(()=>Yg.value=Date.now(),1e3);var Xg=e=>e<1e3?`${Math.max(0,Math.round(e))}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`,Zg=k();async function Qg(e,t){if(!Zg.value){Zg.value=e;try{return await ud(t)}finally{Zg.value=void 0}}}function $g(e){yd.value&&Sd(),setTimeout(()=>document.querySelector(`[data-job-run="${e}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`}))}async function e_(e){let t=await Qg(`start:${e.id}`,()=>Ru.value.demo(`jobs`,{job:e.id}));t&&(Y(`${e.title} started. It runs in the chat.`),$g(t.taskId))}var t_=(e,t)=>Qg(`decide:${e.id}`,()=>Ru.value.demo(`jobs/${e.id}/approval`,{approved:t})),n_=e=>Qg(`stop:${e.id}`,()=>zu.value.abortTask(e.id));function r_(e){q.value&&Bu({...q.value,agentId:e})}var i_=[`data-job-run`,`aria-label`],a_={class:`job-run-head`},o_={class:`job-run-icon`},s_={class:`job-run-titles`},c_={class:`job-run-eyebrow`},l_={class:`job-run-repeat`},u_={key:0,class:`job-run-about`},d_={class:`job-run-meta`},f_={key:0,class:`job-run-resumed`},p_={class:`job-stepper`,"aria-label":`Phases`},m_=[`aria-current`],h_={class:`job-chip`},g_={class:`job-step-dot`},__={class:`job-step-label`},v_={key:0,class:`job-step-progress`},y_={class:`job-phases`},b_=[`open`],x_={class:`job-phase-n`},S_={class:`job-phase-summary`},C_={class:`job-phase-time`},w_={key:0,class:`job-phase-about`},T_={key:1,class:`job-steps`},E_=[`open`],D_={key:1,class:`job-step-line`},O_=[`onClick`],k_={key:2,class:`job-phase-empty`},A_={key:1,class:`job-approval`,role:`group`,"aria-label":`Approval`},j_={class:`job-approval-buttons`},M_=[`disabled`],N_=[`disabled`],P_={key:2,class:`message-error`},F_={class:`job-run-foot`},I_=[`disabled`],L_=N({__name:`JobCard`,props:{run:{}},setup(e){let t=e,n=U(()=>Gg(t.run.job)),r=U(()=>Ug(t.run)),i=U(()=>Xg((t.run.endedAt??Yg.value)-t.run.startedAt)),a={running:`Running`,waiting:`Waiting for you`,completed:`Completed`,failed:`Failed`,aborted:`Stopped`,declined:`Declined`},o={command:pl,tool:bl,agent:Zs,state:Qs,approval:sl,checkpoint:_c,note:Pc},s=e=>e.kind===`tool`?`${e.label}: a subagent tool call, its own durable task`:e.label,c=e=>{let t=e.step,n=[`command`,`tool`,`state`].includes(t.kind)?io(`code`,{title:s(t)},t.label):io(`span`,{class:`job-step-text`},t.label),r=t.status===`running`?io(Fc,{size:15,class:`spin`}):t.status===`done`?io(tc,{size:15}):t.status===`waiting`?io(Tc,{size:15}):io(xl,{size:15});return[io(o[t.kind],{size:16,class:`job-step-kind`}),n,t.kind===`tool`&&t.detail?io(`span`,{class:`job-step-args`,title:t.detail},t.detail):null,io(`span`,{class:`job-step-state`},[r,t.ms!==void 0&&t.kind!==`note`?io(`span`,Xg(t.ms)):null])]};c.props=[`step`];let l=e=>n.value?.phases.find(t=>t.id===e),u=e=>e.startedAt?Xg((e.endedAt??(e.status===`running`||e.status===`waiting`?Yg.value:e.startedAt))-e.startedAt):``,d=e=>e.status!==`pending`&&e.status!==`skipped`,f=U(()=>Object.entries(t.run.input)),p=U(()=>t.run.phases.find(e=>e.status===`waiting`));return(t,o)=>(I(),L(`article`,{class:E([`job-run`,`is-${e.run.status}`]),"data-job-run":e.run.id,"aria-label":`${e.run.title} run ${e.run.run}: ${a[e.run.status]}`},[z(`header`,a_,[z(`span`,o_,[B(A(yl),{size:22})]),z(`div`,s_,[z(`div`,c_,[o[3]||=z(`span`,null,`DURABLE JOB`,-1),z(`span`,l_,[B(A(el),{size:15}),V(`Repeatable workflow, run #`+D(e.run.run),1)])]),z(`h3`,null,D(e.run.title),1)]),z(`span`,{class:E([`job-run-status`,e.run.status])},[o[4]||=z(`i`,null,null,-1),V(D(a[e.run.status]),1)],2)]),n.value?(I(),L(`p`,u_,D(n.value.summary),1)):H(``,!0),z(`div`,d_,[z(`span`,null,`task #`+D(e.run.id),1),z(`span`,null,D(e.run.startedBy===`agent`?`started by the agent`:`started by you`),1),z(`span`,null,D(i.value),1),(I(!0),L(F,null,P(f.value,([e,t])=>(I(),L(`span`,{key:e,class:`job-run-input`},D(e)+`=`+D(t),1))),128)),e.run.resumed?(I(),L(`span`,f_,`resumed `+D(e.run.resumed)+`× after restart`,1)):H(``,!0)]),z(`ol`,p_,[(I(!0),L(F,null,P(e.run.phases,(t,n)=>(I(),L(`li`,{key:t.id,class:E(`ph-${t.status}`),"aria-current":e.run.phase===t.id&&!r.value?`step`:void 0},[z(`span`,h_,[z(`span`,g_,[t.status===`done`?(I(),R(A(tc),{key:0,size:15})):t.status===`running`?(I(),R(A(Fc),{key:1,size:15,class:`spin`})):t.status===`waiting`?(I(),R(A(Tc),{key:2,size:15})):[`failed`,`aborted`].includes(t.status)?(I(),R(A(xl),{key:3,size:15})):(I(),L(F,{key:4},[V(D(n+1),1)],64))]),z(`span`,__,D(t.label),1),t.progress?(I(),L(`span`,v_,D(t.progress.done)+`/`+D(t.progress.total),1)):H(``,!0)])],10,m_))),128))]),z(`div`,y_,[(I(!0),L(F,null,P(e.run.phases,(e,t)=>(I(),L(`details`,{key:e.id,class:E([`job-phase`,`ph-${e.status}`]),open:d(e)},[z(`summary`,null,[z(`span`,x_,D(t+1),1),z(`strong`,null,D(e.label),1),z(`span`,S_,D(e.summary??(e.status===`pending`?l(e.id)?.summary:e.status===`skipped`?`Skipped`:``)),1),z(`span`,C_,D(u(e)),1)]),e.status===`done`?H(``,!0):(I(),L(`p`,w_,D(l(e.id)?.summary),1)),e.steps.length?(I(),L(`ul`,T_,[(I(!0),L(F,null,P(e.steps,e=>(I(),L(`li`,{key:e.id,class:E([`k-${e.kind}`,`st-${e.status}`])},[e.detail&&e.kind!==`tool`?(I(),L(`details`,{key:0,open:e.status===`error`},[z(`summary`,null,[B(c,{step:e},null,8,[`step`])]),z(`pre`,null,D(e.detail),1)],8,E_)):(I(),L(`div`,D_,[B(c,{step:e},null,8,[`step`])])),e.kind===`agent`&&e.conversationId?(I(),L(`button`,{key:2,class:`text-button job-step-link`,onClick:t=>A(r_)(e.conversationId)},` Open subagent #`+D(e.conversationId),9,O_)):H(``,!0)],2))),128))])):e.status===`pending`?(I(),L(`p`,k_,`Not started yet.`)):H(``,!0)],10,b_))),128))]),e.run.approval===`pending`?(I(),L(`div`,A_,[z(`div`,null,[B(A(sl),{size:20}),o[5]||=z(`strong`,null,`Approve to continue`,-1)]),z(`p`,null,D(p.value?l(p.value.id)?.summary:`This run waits for you`)+`. It is paused on a saved checkpoint: close the browser or restart the device and the decision will still be waiting. `,1),z(`div`,j_,[z(`button`,{class:`primary small`,disabled:!!A(Zg),onClick:o[0]||=t=>A(t_)(e.run,!0)},[B(A(tc),{size:18}),o[6]||=V(`Approve & continue `,-1)],8,M_),z(`button`,{class:`secondary`,disabled:!!A(Zg),onClick:o[1]||=t=>A(t_)(e.run,!1)},`Decline`,8,N_)])])):H(``,!0),e.run.error&&e.run.status!==`aborted`?(I(),L(`p`,P_,D(e.run.error),1)):H(``,!0),z(`footer`,F_,[z(`span`,null,D(e.run.background?`Runs in the background: the conversation owns it, so Interrupt leaves it running.`:`Owned by this tool call: Interrupt stops it.`)+` Each phase saves a checkpoint, so a restart resumes the current phase.`,1),r.value?H(``,!0):(I(),L(`button`,{key:0,class:`secondary danger`,disabled:!!A(Zg),onClick:o[2]||=t=>A(n_)(e.run)},[B(A(Vc),{size:16}),o[7]||=V(`Stop `,-1)],8,I_))])],10,i_))}}),R_={class:`message-label`},z_={class:`user-message`},B_={class:`message-label`},V_={key:0,class:`streaming`},H_={key:1},U_=[`aria-label`],W_=[`innerHTML`],G_={key:1,class:`thinking`},K_=[`data-call-id`],q_={class:`tool-status`},J_={class:`tool-section-label`},Y_=[`aria-label`,`onClick`],X_={key:0,class:`typing`},Z_={key:1,class:`message-error`},Q_=[`aria-label`],$_={key:3,class:`live-tool`},ev={key:0},tv={class:`event-line`},nv=[`aria-label`],rv={key:0,class:`raw`},iv=N({__name:`TranscriptItem`,props:{item:{}},emits:[`fork`],setup(e,{emit:t}){let n=t,r=e=>e.status===`error`?`Error`:e.status===`done`?`Done`:e.status,i=e=>e.kind===`user`?`pi-user`:e.kind===`assistant`?e.streaming?`live-generation`:`pi-assistant`:e.kind===`tool-result`?`pi-tool-result`:e.kind===`tool`?`live-tool-entry`:e.entryKind.replaceAll(`.`,`-`);return(t,a)=>(I(),L(`article`,{class:E([`entry`,i(e.item)])},[e.item.kind===`user`?(I(),L(F,{key:0},[z(`div`,R_,[a[3]||=V(` YOU `,-1),z(`span`,null,`#`+D(e.item.id),1)]),z(`div`,z_,D(e.item.text),1)],64)):e.item.kind===`assistant`?(I(),L(F,{key:1},[z(`div`,B_,[a[5]||=V(` AGENT `,-1),e.item.streaming?(I(),L(`span`,V_,`Working`)):(I(),L(`span`,H_,`#`+D(e.item.id),1)),e.item.streaming?H(``,!0):(I(),L(`button`,{key:2,class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,title:`Fork from this entry. App State stays shared.`,onClick:a[0]||=t=>n(`fork`,e.item.id)},[B(A(Cc),{size:18}),a[4]||=V(`Fork `,-1)],8,U_))]),(I(!0),L(F,null,P(e.item.blocks,(e,t)=>(I(),L(F,{key:t},[e.type===`text`?(I(),L(`div`,{key:0,class:`markdown`,innerHTML:A(Vg)(e.text)},null,8,W_)):e.type===`thinking`?(I(),L(`details`,G_,[a[6]||=z(`summary`,null,`Thinking`,-1),z(`div`,null,D(e.text),1)])):(I(),L(`details`,{key:2,class:E([`tool-call`,{failed:e.call.status===`error`}]),"data-call-id":e.call.callId},[z(`summary`,null,[e.call.status===`error`?(I(),R(A(Oc),{key:0,size:18})):e.call.status===`done`?(I(),R(A(tc),{key:1,size:18})):e.call.status===`running`?(I(),R(A(Vs),{key:2,size:18})):(I(),R(A(bl),{key:3,size:18})),z(`strong`,null,D(e.call.name),1),z(`code`,null,D(A(pd)(e.call.args)?.slice(0,90)),1),z(`span`,q_,D(r(e.call)),1)]),a[10]||=z(`div`,{class:`tool-section-label`},`Input`,-1),z(`pre`,null,D(A(pd)(e.call.args)),1),e.call.result===void 0?e.call.output?(I(),L(F,{key:1},[a[9]||=z(`div`,{class:`tool-section-label`},`Live output`,-1),z(`pre`,null,D(e.call.output),1)],64)):H(``,!0):(I(),L(F,{key:0},[z(`div`,J_,[a[8]||=z(`span`,null,`Result`,-1),e.call.resultEntryId===void 0?H(``,!0):(I(),L(`button`,{key:0,class:`fork-button`,"aria-label":`Fork at entry ${e.call.resultEntryId}`,title:`Fork after this result`,onClick:t=>n(`fork`,e.call.resultEntryId)},[B(A(Cc),{size:18}),a[7]||=V(`Fork `,-1)],8,Y_))]),z(`pre`,null,D(e.call.result),1)],64))],10,K_)),e.type===`tool`&&e.call.name===`run_durable_job`&&A(Jg)(e.call.callId)?(I(),R(L_,{key:3,run:A(Jg)(e.call.callId)},null,8,[`run`])):H(``,!0)],64))),128)),e.item.streaming&&!e.item.blocks.length?(I(),L(`div`,X_,[...a[11]||=[z(`i`,null,null,-1),z(`i`,null,null,-1),z(`i`,null,null,-1)]])):H(``,!0),e.item.error?(I(),L(`div`,Z_,D(e.item.error),1)):H(``,!0)],64)):e.item.kind===`tool-result`?(I(),L(`details`,{key:2,class:E([`tool-result`,{failed:e.item.isError}])},[z(`summary`,null,[e.item.isError?(I(),R(A(Oc),{key:1,size:18})):(I(),R(A(tc),{key:0,size:18})),z(`strong`,null,D(e.item.name),1),z(`span`,null,D(e.item.isError?`error`:`result`),1),z(`button`,{class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,onClick:a[1]||=ks(t=>n(`fork`,e.item.id),[`prevent`])},[B(A(Cc),{size:18}),a[12]||=V(`Fork `,-1)],8,Q_)]),z(`pre`,null,D(e.item.text),1)],2)):e.item.kind===`tool`?(I(),L(`div`,$_,[z(`div`,null,[B(A(Vs),{size:18}),z(`strong`,null,D(e.item.call.name),1),z(`span`,null,D(e.item.call.status),1)]),e.item.call.output?(I(),L(`pre`,ev,D(e.item.call.output),1)):H(``,!0),e.item.call.name===`run_durable_job`&&A(Jg)(e.item.call.callId)?(I(),R(L_,{key:1,run:A(Jg)(e.item.call.callId)},null,8,[`run`])):H(``,!0)])):e.item.entryKind===`demo.job`&&A(qg)(e.item.data.taskId)?(I(),R(L_,{key:4,run:A(qg)(e.item.data.taskId)},null,8,[`run`])):(I(),L(F,{key:5},[z(`div`,tv,[e.item.entryKind===`demo.state-change`?(I(),R(A(Qs),{key:0,size:18})):(I(),R(A(jc),{key:1,size:18})),z(`span`,null,D(e.item.text),1),z(`button`,{class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,onClick:a[2]||=t=>n(`fork`,e.item.id)},[B(A(Cc),{size:18}),a[13]||=V(`Fork `,-1)],8,nv)]),e.item.note?(I(),L(`details`,rv,[a[14]||=z(`summary`,null,`Context note`,-1),z(`pre`,null,D(e.item.note),1)])):H(``,!0)],64))],2))}}),av={key:0,class:`git-chip-wrap`},ov=[`title`],sv={class:`branch`},cv={key:0,class:`dirty`},lv={key:1,class:`ahead`},uv={key:2,class:`behind`},dv=Vd(N({__name:`GitChip`,props:{deviceId:{},cwd:{}},setup(e){let t=e,n=U(()=>t.cwd??Iu.value?.cwd??``),r=U(()=>t.deviceId??Au.value),i=U(()=>nf(r.value||`?`,n.value||`?`)),a=U(()=>i.value.status),o=U(()=>i.value.loading),s=U(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0));return af(r.value||`?`,n.value||`?`),Kr(()=>af(r.value||`?`,n.value||`?`)),M([r,n],()=>void af(r.value||`?`,n.value||`?`)),(e,t)=>a.value?.repo||o.value?(I(),L(`span`,av,[z(`button`,{class:`crumb git-chip`,title:a.value?`${a.value.root} · ${a.value.head??``} ${a.value.subject??``} — opens the Git tab`:`loading git…`,onClick:t[0]||=e=>A(xd)(`git`)},[B(A(xc),{size:16,"aria-hidden":`true`}),z(`span`,sv,D(a.value?.branch??a.value?.head??`…`),1),s.value?(I(),L(`span`,cv,`±`+D(s.value),1)):H(``,!0),a.value?.ahead?(I(),L(`span`,lv,`↑`+D(a.value.ahead),1)):H(``,!0),a.value?.behind?(I(),L(`span`,uv,`↓`+D(a.value.behind),1)):H(``,!0),B(A(nc),{size:14,"aria-hidden":`true`})],8,ov)])):H(``,!0)}}),[[`__scopeId`,`data-v-c0fb9e98`]]),fv=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,pv=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],mv={enabled:!0,reserveTokens:16384,backgroundTokens:32768,keepRecentTokens:2e3},hv={auto:2e5,wait:25e4};function gv(e){if(!(e>0))return{...mv};let t=Math.min(hv.wait,e-mv.reserveTokens),n=Math.min(hv.auto,t-mv.backgroundTokens);return{...mv,reserveTokens:e-t,backgroundTokens:t-n}}function _v(e,t){let n=Math.max(0,e-t.reserveTokens);return{wait:n,auto:t.backgroundTokens>0?Math.max(0,n-t.backgroundTokens):void 0}}var vv=(e,t)=>{if(e===void 0)throw Error(`No ${t} selected`);return e},yv=[{name:`compact`,args:`[instructions]`,description:`Summarize older context; stored entries stay`,run:async e=>{await vv(Ru.value,`agent`).compact(e||void 0),Y(`Compaction requested. /tasks shows its outcome.`)}},{name:`reset`,args:`[handoff note]`,description:`Start a fresh context; history stays stored`,run:async e=>{await vv(Ru.value,`agent`).reset(e||void 0),Y(`New context started.`)}},{name:`tasks`,description:`Open the Tasks panel`,run:()=>xd(`tasks`)},{name:`new`,args:`[name]`,description:`New agent in this workspace`,run:async e=>{let t=vv(q.value,`workspace`),n=await vv(zu.value,`workspace`).createAgent({name:e||`Agent ${Yu.value.length+1}`});Bu({...t,agentId:n.id}),Y(`New agent ${n.name}.`)}},{name:`fork`,args:`[entryId] [name]`,description:`Fork at an entry (default: the last reply)`,run:async e=>{let[t,...n]=e.split(/\s+/).filter(Boolean),r=t&&/^\d+$/.test(t)?Number(t):void 0,i=(r===void 0?[t,...n]:n).filter(Boolean).join(` `),a=r??Ju.value.entries.filter(e=>e.kind===`pi.assistant`).at(-1)?.id;if(a===void 0)throw Error(`Nothing to fork yet`);let o=vv(q.value,`agent`),s=await vv(Ru.value,`agent`).fork({entryId:a,name:i||void 0});Bu({...o,agentId:s.id}),Y(`Forked at entry #${a}. App State stays shared.`)}},{name:`name`,args:`<name>`,description:`Rename this agent`,run:async e=>{if(!e)throw Error(`Usage: /name <name>`);await vv(Ru.value,`agent`).rename(e),Y(`Agent renamed to ${e}.`)}},{name:`model`,description:`Choose this agent's model`,run:()=>J.dialog={kind:`models`}},{name:`thinking`,args:`<level>`,description:`Thinking level: ${pv.join(`, `)}`,run:async e=>{if(!pv.includes(e))throw Error(`Levels: ${pv.join(`, `)}`);await vv(Ru.value,`agent`).configure({thinkingLevel:e}),await ad(),Y(`Thinking ${e}. Used on the next turn.`)}},{name:`help`,description:`How this works, keys and commands`,run:()=>J.dialog={kind:`help`}}];function bv(e){let t=e.trim().match(/^\/(\S+)\s*([\s\S]*)$/),n=t&&yv.find(e=>e.name===t[1]);return n?{command:n,arg:t[2].trim()}:void 0}var xv={class:`composer-region`},Sv={key:0,class:`queue`},Cv=[`aria-label`,`onClick`],wv={class:`composer`},Tv={key:0,class:`slash-menu`,role:`listbox`,"aria-label":`Slash commands`},Ev=[`aria-selected`,`onMousedown`],Dv={key:0,class:`slash-args`},Ov={class:`slash-desc`},kv={class:`composer-toolbar`},Av={class:`composer-left`},jv={class:`lib-wrap`},Mv=[`aria-label`],Nv={key:0,class:`hint`},Pv={class:`save-row`},Fv=[`disabled`],Iv=[`title`,`onClick`],Lv=[`aria-label`,`onClick`],Rv={class:`queue-mode`},zv={class:`composer-right`},Bv=[`disabled`],Vv=[`disabled`],Hv=`dpi-prompt-library`,Uv=Vd(N({__name:`Composer`,setup(e){let t=k(`followUp`),n=k(!1),r=k(``),i=k([]),a=()=>{try{i.value=JSON.parse(localStorage.getItem(Hv)??`[]`)}catch{i.value=[]}},o=()=>localStorage.setItem(Hv,JSON.stringify(i.value));a();let s=()=>{let e=J.composer.trim(),t=r.value.trim()||e.slice(0,24)||`snippet`;e&&(i.value=[{name:t,text:e},...i.value.filter(e=>e.name!==t)].slice(0,30),o(),r.value=``)},c=e=>{i.value=i.value.filter(t=>t.name!==e),o()},l=k(!1),u=U(()=>Mu.value&&Ju.value.ready&&Pu.status.value===`live`&&Su.value===`live`),d=k(0),f=k(!1),p=U(()=>{let e=J.composer.match(/^\/(\S*)$/);return e&&!f.value?yv.filter(t=>t.name.startsWith(e[1].toLowerCase())):[]});M(()=>J.composer,()=>{d.value=0,J.composer.startsWith(`/`)||(f.value=!1)});async function m(e,t=!1){!e.args||t&&e.args.startsWith(`[`)&&J.composer===`/${e.name}`?(J.composer=`/${e.name}`,await _()):J.composer=`/${e.name} `}function h(e){if(!p.value.length){e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),_());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=p.value.length;d.value=(d.value+(e.key===`ArrowDown`?1:t-1))%t}else if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)m(p.value[d.value],e.key===`Enter`);else if(e.key===`Escape`)f.value=!0;else return;e.preventDefault(),e.stopPropagation()}async function g(e){let t=bv(e);return t?(l.value=!0,await ud(async()=>{await t.command.run(t.arg),J.composer=``}),l.value=!1,!0):!1}async function _(){let e=J.composer.trim(),n=Ru.value;if(!e||l.value||!n||!u.value||e.startsWith(`/`)&&await g(e))return;l.value=!0;let r=q.value,i=`${r.deviceId}/${r.sessionId}/${r.agentId}`,a;try{a=JSON.parse(sessionStorage.getItem(`dpi.pending-send`)??`null`)}catch{}let o=a?.key===i&&a.content===e&&a.mode===t.value?a.requestId:fv();sessionStorage.setItem(`dpi.pending-send`,JSON.stringify({key:i,content:e,mode:t.value,requestId:o})),await ud(async()=>{await n.send(e,t.value,o),sessionStorage.removeItem(`dpi.pending-send`),J.composer=``}),l.value=!1}function v(e){ud(()=>Ru.value.withdraw(e))}return(e,a)=>(I(),L(`div`,xv,[A(Ju).inbox.length?(I(),L(`div`,Sv,[(I(!0),L(F,null,P(A(Ju).inbox,e=>(I(),L(`div`,{key:e.id},[B(A(oc),{size:18}),z(`span`,null,D(e.mode===`steer`?`Steer`:`Queued`)+`: `+D(e.content??`Context update`),1),z(`button`,{class:`icon-button`,"aria-label":`Withdraw submission ${e.id}`,title:`Withdraw queued input`,onClick:t=>v(e.id)},[B(A(xl),{size:18})],8,Cv)]))),128))])):H(``,!0),z(`div`,wv,[p.value.length?(I(),L(`ul`,Tv,[(I(!0),L(F,null,P(p.value,(e,t)=>(I(),L(`li`,{key:e.name,role:`option`,"aria-selected":t===d.value,class:E({active:t===d.value}),onMousedown:ks(t=>m(e),[`prevent`])},[z(`code`,null,`/`+D(e.name),1),e.args?(I(),L(`span`,Dv,D(e.args),1)):H(``,!0),z(`span`,Ov,D(e.description),1)],42,Ev))),128))])):H(``,!0),j(z(`textarea`,{"onUpdate:modelValue":a[0]||=e=>A(J).composer=e,rows:`2`,placeholder:`Give your agent something to do, or type / for commands…`,"aria-label":`Message your agent`,onKeydown:h},null,544),[[ys,A(J).composer]]),z(`div`,kv,[z(`div`,Av,[z(`div`,jv,[z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Prompt library (${i.value.length})`,title:`Prompt library — saved snippets`,onClick:a[1]||=e=>n.value=!n.value},[B(A(Mc),{size:18})],8,Mv),n.value?(I(),L(`div`,{key:0,class:`lib`,onClick:a[4]||=ks(()=>{},[`stop`])},[z(`header`,null,[a[7]||=z(`b`,null,`Prompts`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close library`,onClick:a[2]||=e=>n.value=!1},[B(A(xl),{size:14})])]),i.value.length?H(``,!0):(I(),L(`p`,Nv,`Type something below, give it a name, save it.`)),z(`div`,Pv,[j(z(`input`,{"onUpdate:modelValue":a[3]||=e=>r.value=e,placeholder:`name…`,onKeyup:js(s,[`enter`])},null,544),[[ys,r.value]]),z(`button`,{type:`button`,class:`small`,disabled:!A(J).composer.trim(),onClick:s},`save composer as`,8,Fv)]),z(`ul`,null,[(I(!0),L(F,null,P(i.value,e=>(I(),L(`li`,{key:e.name},[z(`button`,{type:`button`,class:`use`,title:e.text,onClick:t=>(A(J).composer=e.text,n.value=!1)},[z(`b`,null,D(e.name),1)],8,Iv),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Delete ${e.name}`,onClick:t=>c(e.name)},[B(A(ml),{size:13})],8,Lv)]))),128))])])):H(``,!0)]),z(`div`,Rv,[j(z(`select`,{"onUpdate:modelValue":a[5]||=e=>t.value=e,"aria-label":`When busy`,title:`Follow-up waits for this run. Steer joins after a tool round.`},[...a[8]||=[z(`option`,{value:`followUp`},`Follow-up`,-1),z(`option`,{value:`steer`},`Steer`,-1),z(`option`,{value:`reject`},`Reject if busy`,-1)]],512),[[Ss,t.value]]),B(A(nc),{size:24,"aria-hidden":`true`})])]),z(`div`,zv,[z(`button`,{class:`interrupt`,disabled:!A(Qu)||A(gd),title:`Stop foreground work and owned subagents (Escape). Background jobs continue.`,onClick:a[6]||=(...e)=>A(_d)&&A(_d)(...e)},[B(A(Vc),{size:24,class:`stop-sign`,fill:`currentColor`}),a[9]||=V(`Interrupt`,-1)],8,Bv),z(`button`,{class:`send`,"aria-label":`Send message`,disabled:!A(J).composer.trim()||l.value||!u.value,onClick:_},[B(A(Js),{size:20})],8,Vv)])])]),a[10]||=z(`div`,{class:`composer-footnote`},[z(`span`,null,[z(`i`,{class:`live-dot`}),V(`Closing this window never interrupts your agent.`)])],-1)]))}}),[[`__scopeId`,`data-v-b2af49ae`]]),Wv={class:`chat-panel`},Gv={class:`chat-header`},Kv={class:`lineage-picker`},qv={class:`lineage-toolbar`},Jv=[`title`],Yv={class:`crumb-main`},Xv={class:`device-chip`},Zv=[`title`],Qv={class:`crumb-main`},$v={class:`crumb-name`},ey=[`aria-current`,`title`,`onClick`],ty={class:`crumb-kind`},ny={class:`crumb-main`},ry={class:`crumb-name`},iy=[`disabled`],ay=[`aria-expanded`],oy={key:0,class:`lineage-source`},sy={id:`conversation-picker`,class:`conversation-picker`,role:`dialog`,"aria-label":`Choose conversation`},cy=[`aria-label`,`aria-current`,`onClick`],ly={class:`conversation-choice-content`},uy={class:`choice-lineage`},dy={class:`choice-source`},fy={key:0,class:`agent-stream-status`,role:`alert`},py=[`disabled`],my={key:0,class:`chat-empty`},hy={key:0},gy={key:1},_y={key:0,class:`chat-empty`},vy={class:`starter-grid`},yy={key:1,class:`entry live-generation`},by={class:`message-label`},xy={class:`streaming`},Sy={key:2,class:`hint retry-note`},Cy=N({__name:`AgentView`,setup(e){let t=k(),n=k(),r=k(!1),i=U(()=>Ju.value.items),a=U(()=>i.value.some(e=>e.kind===`assistant`&&e.streaming)),o=U(()=>i.value.some(e=>e.kind===`tool`&&e.call.status===`running`||e.kind===`assistant`&&e.blocks.some(e=>e.type===`tool`&&e.call.status===`running`))),s=e=>e.kind===`fork`?`Forked from agent #${e.parentId} at entry #${e.forkedAt}`:e.kind===`subagent`?`Owned by agent #${e.ownerAgentId}`:`Root agent`,c=U(()=>Yu.value.map(e=>({...e,lineage:Ll(Yu.value,e.id)})).sort((e,t)=>{for(let n=0;n<Math.min(e.lineage.length,t.lineage.length);n++)if(e.lineage[n].id!==t.lineage[n].id)return e.lineage[n].id-t.lineage[n].id;return e.lineage.length-t.lineage.length})),l=U(()=>Xu.value.at(-1)),u=e=>e.kind===`root`?`agent`:e.kind;function d(){q.value&&(Ou.tree=!0,Uu(q.value.deviceId,!0))}function f(){let e=Yu.value.find(e=>e.kind===`root`)??Yu.value[0];e&&p(e.id)}function p(e){r.value=!1,q.value&&Bu({...q.value,agentId:e})}function m(e){let t=Ru.value,n=q.value;t&&n&&(J.dialog={kind:`prompt`,title:`Fork conversation`,hint:`${l.value?.name??`Agent #${n.agentId}`} / entry #${e}. Leave the name blank to use Fork #ID.`,label:`Fork name`,optional:!0,placeholder:`e.g. Alternative approach`,submit:`Create fork`,run:async r=>{let i=await t.fork({entryId:e,name:r||void 0});Bu({...n,agentId:i.id}),Y(`Forked at entry #${e}. App State stays shared.`)}})}function h(){let e=Ru.value,t=l.value;e&&t&&(J.dialog={kind:`prompt`,title:`Rename agent`,label:`Agent name`,value:t.named?t.name:``,placeholder:t.name,submit:`Save name`,run:t=>e.rename(t)})}M(q,()=>{r.value=!1});let g=!0;return M(Pu.version,()=>{let e=t.value;g=!e||e.scrollHeight-e.scrollTop-e.clientHeight<120},{flush:`pre`}),M(Pu.version,()=>{g&&An(()=>t.value?.scrollTo({top:t.value.scrollHeight,behavior:`instant`}))}),M(()=>Xu.value.length,()=>void An(()=>n.value&&(n.value.scrollLeft=n.value.scrollWidth))),(e,g)=>(I(),L(`section`,Wv,[z(`header`,Gv,[z(`div`,Kv,[z(`div`,qv,[z(`nav`,{ref_key:`lineageNav`,ref:n,class:`crumbs conversation-lineage`,"aria-label":`Conversation lineage`},[z(`button`,{class:`crumb`,title:`${A(ju)?.name} · ${A(ju)?.url}`,onClick:d},[g[5]||=z(`span`,{class:`crumb-kind`},`device`,-1),z(`span`,Yv,[B(Jd,{device:A(ju),size:18},null,8,[`device`]),z(`span`,Xv,D(A(ju)?.name??A(ju)?.id),1)])],8,Jv),B(A(rc),{class:`crumb-sep`,size:18,"aria-hidden":`true`}),z(`button`,{class:`crumb`,title:A(Iu)?.cwd,onClick:f},[g[6]||=z(`span`,{class:`crumb-kind`},`workspace`,-1),z(`span`,Qv,[B(A(yc),{size:18,"aria-hidden":`true`}),z(`span`,$v,D(A(Iu)?.name),1)])],8,Zv),A(Iu)?.cwd?(I(),R(dv,{key:0})):H(``,!0),(I(!0),L(F,null,P(A(Xu),e=>(I(),L(F,{key:e.id},[B(A(rc),{class:`crumb-sep`,size:18,"aria-hidden":`true`}),z(`button`,{class:E([`crumb`,{current:e.id===A(q)?.agentId}]),"aria-current":e.id===A(q)?.agentId?`page`:void 0,title:s(e),onClick:t=>p(e.id)},[z(`span`,ty,D(u(e)),1),z(`span`,ny,[e.kind===`fork`?(I(),R(A(Cc),{key:0,size:18,"aria-hidden":`true`})):e.kind===`subagent`?(I(),R(A(cc),{key:1,size:18,"aria-hidden":`true`})):(I(),R(A(Lc),{key:2,size:18,"aria-hidden":`true`})),z(`span`,ry,D(e.name),1)])],10,ey)],64))),128))],512),z(`button`,{class:`icon-button`,"aria-label":`Rename agent`,title:`Rename this agent`,disabled:!l.value,onClick:h},[B(A(qc),{size:18})],8,iy),z(`button`,{class:`icon-button conversation-menu-toggle`,"aria-label":`Browse conversations`,"aria-haspopup":`dialog`,"aria-expanded":r.value,"aria-controls":`conversation-picker`,title:`Browse roots and forks`,onClick:g[0]||=e=>r.value=!r.value},[B(A(nc),{size:18})],8,ay)]),l.value&&l.value.kind!==`root`?(I(),L(`div`,oy,D(s(l.value)),1)):H(``,!0),r.value?(I(),L(F,{key:1},[z(`button`,{class:`conversation-menu-dismiss`,"aria-label":`Close conversation picker`,onClick:g[1]||=e=>r.value=!1}),z(`section`,sy,[g[7]||=z(`div`,{class:`conversation-picker-heading`},`Roots & forks`,-1),(I(!0),L(F,null,P(c.value,e=>(I(),L(`button`,{key:e.id,class:E([`conversation-choice`,{selected:e.id===A(q)?.agentId}]),"aria-label":e.lineage.map(e=>e.name).join(` → `),"aria-current":e.id===A(q)?.agentId?`page`:void 0,onClick:t=>p(e.id)},[z(`div`,ly,[z(`span`,uy,[(I(!0),L(F,null,P(e.lineage,(t,n)=>(I(),L(F,{key:t.id},[n?(I(),R(A(rc),{key:0,size:18,"aria-hidden":`true`})):H(``,!0),z(`span`,{class:E({"choice-ancestor":n<e.lineage.length-1})},D(t.name),3)],64))),128))]),z(`span`,dy,D(s(e)),1)]),e.id===A(q)?.agentId?(I(),R(A(tc),{key:0,size:18,"aria-hidden":`true`})):e.kind===`fork`?(I(),R(A(Cc),{key:1,size:18,"aria-hidden":`true`})):(I(),R(A(Lc),{key:2,size:18,"aria-hidden":`true`}))],10,cy))),128))])],64)):H(``,!0)])]),A(Pu).fault.value||A(Pu).status.value===`fault`||A(Pu).status.value===`reconnecting`||A(Ju).ready&&A(Pu).status.value===`connecting`?(I(),L(`div`,fy,[z(`div`,null,[z(`strong`,null,D(A(Ju).ready?`Cached transcript is stale.`:`Agent stream unavailable.`),1),z(`p`,null,D(A(Pu).fault.value||`Updates are paused while the stream reconnects.`),1),g[8]||=z(`p`,null,`Sending is paused until a fresh snapshot arrives. Your draft is kept.`,-1)]),z(`button`,{disabled:A(Pu).status.value===`connecting`,onClick:g[2]||=(...e)=>A(Pu).retry&&A(Pu).retry(...e)},` Retry stream `,8,py)])):H(``,!0),z(`div`,{ref_key:`chat`,ref:t,class:`chat-scroll`,"data-testid":`chat`},[A(Ju).ready?(I(),L(F,{key:1},[i.value.length?H(``,!0):(I(),L(`div`,_y,[g[13]||=z(`div`,{class:`agent-orb`},[z(`img`,{src:`/icons/durable-pi.svg`,alt:`Durable Pi`}),z(`i`)],-1),g[14]||=z(`span`,{class:`eyebrow`},`YOUR DURABLE AGENT IS READY`,-1),g[15]||=z(`h2`,null,`A conversation with continuity.`,-1),z(`p`,null,`Messages, tools and state live on `+D(A(ju)?.id)+`, beyond this window.`,1),z(`div`,vy,[z(`button`,{onClick:g[3]||=e=>A(dd)(`Inspect this directory using your tools and give me a brief overview. Do not modify any files.`)},[B(A(yc),{size:18}),g[9]||=z(`strong`,null,`Explore this directory`,-1),g[10]||=z(`span`,null,`See coding tools in action`,-1),B(A(qs),{size:18})]),z(`button`,{onClick:g[4]||=e=>A(dd)(`Use read_state, then update_state to add a field called progress with value 1 and a boolean called ready with value false.`)},[B(A(Qs),{size:18}),g[11]||=z(`strong`,null,`Make a state change`,-1),g[12]||=z(`span`,null,`Watch the workspace update`,-1),B(A(qs),{size:18})])])])),(I(!0),L(F,null,P(i.value,e=>(I(),R(iv,{key:e.id,item:e,onFork:m},null,8,[`item`]))),128)),A(Ju).running&&!a.value&&!o.value?(I(),L(`div`,yy,[z(`div`,by,[g[16]||=V(` AGENT `,-1),z(`span`,xy,D(A(Ju).retry?`Retry scheduled`:`Working`),1)]),g[17]||=z(`div`,{class:`typing`},[z(`i`),z(`i`),z(`i`)],-1)])):H(``,!0),A(Ju).retry?(I(),L(`p`,Sy,` Retrying: `+D(A(Ju).retry.error),1)):H(``,!0),(I(!0),L(F,null,P(A(Ju).notices,(e,t)=>(I(),L(`p`,{key:t,class:`message-error`},D(e),1))),128))],64)):(I(),L(`div`,my,[B(A(Vs),{size:30}),A(Pu).status.value===`fault`?(I(),L(`h2`,hy,`This agent is unavailable.`)):(I(),L(`h2`,gy,`Connecting to the agent…`)),z(`p`,null,`The agent keeps working on `+D(A(ju)?.id)+` while this view connects.`,1)]))],512),B(Uv)]))}});function wy(e,t){return`${e}/${t.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`}function Ty(e){if(e===``)return[];if(!e.startsWith(`/`))throw Error(`Use a JSON Pointer path, such as /counter`);return e.slice(1).split(`/`).map(e=>{if(/~(?![01])/u.test(e))throw Error(`Invalid JSON Pointer escape`);let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if([`__proto__`,`constructor`,`prototype`].includes(t))throw Error(`Reserved field name`);return t})}function Ey(e,t){if(typeof e!=`object`||!e||!Object.hasOwn(e,t))throw Error(`Field does not exist: ${t}`);if(Array.isArray(e)&&!/^(0|[1-9]\d*)$/u.test(t))throw Error(`Invalid array index`);return e[t]}function Dy(e,t=0){if(t>24)throw Error(`State is too deeply nested`);if(e!==null&&typeof e!=`string`&&typeof e!=`boolean`&&!(typeof e==`number`&&Number.isFinite(e))){if(typeof e!=`object`||!e)throw Error(`Value must be valid JSON`);for(let[n,r]of Object.entries(e)){if([`__proto__`,`constructor`,`prototype`].includes(n))throw Error(`Reserved field name`);Dy(r,t+1)}}}function Oy(e,t){if(![`create`,`update`,`delete`,`increment`].includes(t.operation))throw Error(`Invalid state operation`);if(typeof t.path!=`string`)throw Error(`State path is required`);let n=Ty(t.path),r=JSON.parse(JSON.stringify(e));if(!n.length){if(t.operation===`delete`)return{};if(t.operation!==`update`||t.value===null||Array.isArray(t.value)||typeof t.value!=`object`)throw Error(`The state root must be a JSON object. Use update to replace it.`);if(Dy(t.value),JSON.stringify(t.value).length>1e5)throw Error(`App State must be under 100,000 characters`);return JSON.parse(JSON.stringify(t.value))}let i=n.pop(),a=n.reduce(Ey,r);if(typeof a!=`object`||!a)throw Error(`Parent must be an object or array`);let o=Object.hasOwn(a,i),s=Array.isArray(a),c=s&&(i===`-`||i===String(a.length));if(s&&!c&&(!/^(0|[1-9]\d*)$/u.test(i)||Number(i)>=a.length))throw Error(`Invalid array index`);if(t.operation===`create`&&o)throw Error(`Field already exists. Use update.`);if(t.operation!==`create`&&!o)throw Error(`Field does not exist. Use create.`);if(t.operation===`delete`)s?a.splice(Number(i),1):delete a[i];else{let e=t.value;if(t.operation===`increment`){let t=a[i];if(typeof t!=`number`||typeof e!=`number`)throw Error(`Increment requires numbers`);e=t+e}Dy(e),s?a[c?a.length:Number(i)]=e:a[i]=e}if(Dy(r),JSON.stringify(r).length>1e5)throw Error(`App State must be under 100,000 characters`);return r}var ky=[`data-state-path`],Ay={key:0,class:`state-field-heading`},jy=[`value`,`aria-label`,`disabled`],My=[`value`],Ny=[`aria-label`,`disabled`],Py=[`aria-label`,`disabled`],Fy=[`aria-label`,`disabled`],Iy=[`value`],Ly=[`disabled`],Ry=[`disabled`,`aria-label`],zy={key:2,class:`state-number`},By=[`aria-label`,`disabled`],Vy=[`aria-label`,`disabled`],Hy=[`aria-label`,`disabled`],Uy={key:3,class:`state-boolean`},Wy=[`aria-label`,`aria-checked`,`disabled`],Gy=[`aria-label`,`disabled`],Ky={key:5,class:`muted`},qy=N({__name:`StateEditor`,props:{value:{type:[String,Number,Boolean,null,Array,Object]},path:{default:``},label:{default:`App State`},disabled:{type:Boolean}},emits:[`change`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>n.value===null?`null`:Array.isArray(n.value)?`array`:typeof n.value),a=U(()=>i.value===`object`||i.value===`array`),o=U(()=>a.value?Object.entries(n.value):[]),s=k(``),c=k(!1),l=k(``),u=k(`string`),d=k(!1),f=[`string`,`number`,`boolean`,`object`,`array`,`null`],p={string:()=>``,number:()=>0,boolean:()=>!1,object:()=>({}),array:()=>[],null:()=>null};M(()=>n.value,e=>{c.value||(s.value=String(e??``))},{immediate:!0});function m(e,t){r(`change`,{operation:e,path:n.path,value:t})}function h(){c.value=!1;let e=i.value===`number`?Number(s.value):s.value;if(i.value===`number`&&(!String(s.value).trim()||!Number.isFinite(e))){s.value=String(n.value);return}e!==n.value&&m(`update`,e)}function g(){let e=i.value===`array`?`-`:l.value.trim();e&&(r(`change`,{operation:`create`,path:wy(n.path,e),value:p[u.value]()}),l.value=``,d.value=!1)}return(t,n)=>{let _=Zr(`StateEditor`,!0);return I(),L(`div`,{class:E([`state-field`,{"state-root":e.path===``}]),"data-state-path":e.path},[e.path===``?H(``,!0):(I(),L(`div`,Ay,[z(`strong`,null,D(e.label),1),z(`select`,{value:i.value,"aria-label":`Type of ${e.path}`,disabled:e.disabled,onChange:n[0]||=e=>m(`update`,p[e.target.value]())},[(I(),L(F,null,P(f,e=>z(`option`,{key:e,value:e},D(e),9,My)),64))],40,jy),z(`button`,{class:`icon-button`,"aria-label":`Delete ${e.path}`,title:`Delete field`,disabled:e.disabled,onClick:n[1]||=e=>m(`delete`)},[B(A(ml),{size:18})],8,Ny)])),a.value?(I(),L(F,{key:1},[(I(!0),L(F,null,P(o.value,([t,i])=>(I(),R(_,{key:t,value:i,path:A(wy)(e.path,t),label:t,disabled:e.disabled,onChange:n[2]||=e=>r(`change`,e)},null,8,[`value`,`path`,`label`,`disabled`]))),128)),d.value?(I(),L(`form`,{key:0,class:`state-add`,onSubmit:ks(g,[`prevent`])},[i.value===`array`?H(``,!0):j((I(),L(`input`,{key:0,"onUpdate:modelValue":n[3]||=e=>l.value=e,placeholder:`Field name`,"aria-label":`New field name in ${e.path||`/`}`,required:``,disabled:e.disabled},null,8,Py)),[[ys,l.value]]),j(z(`select`,{"onUpdate:modelValue":n[4]||=e=>u.value=e,"aria-label":`New field type in ${e.path||`/`}`,disabled:e.disabled},[(I(),L(F,null,P(f,e=>z(`option`,{key:e,value:e},D(e),9,Iy)),64))],8,Fy),[[Ss,u.value]]),z(`button`,{class:`secondary small`,disabled:e.disabled||i.value!==`array`&&!l.value.trim()},` Add `,8,Ly),z(`button`,{type:`button`,class:`text-button`,onClick:n[5]||=e=>d.value=!1},`Cancel`)],32)):(I(),L(`button`,{key:1,class:`text-button state-add-button`,disabled:e.disabled,"aria-label":`Add ${i.value===`array`?`item`:`field`} to ${e.path||`/`}`,onClick:n[6]||=e=>d.value=!0},[B(A(Xc),{size:18}),V(D(i.value===`array`?`Add item`:`Add field`),1)],8,Ry))],64)):i.value===`number`?(I(),L(`div`,zy,[z(`button`,{class:`secondary`,"aria-label":`Decrement ${e.path}`,disabled:e.disabled,onClick:n[7]||=e=>m(`increment`,-1)},[B(A(Rc),{size:18})],8,By),j(z(`input`,{"onUpdate:modelValue":n[8]||=e=>s.value=e,type:`number`,step:`any`,"aria-label":`Value of ${e.path}`,disabled:e.disabled,onFocus:n[9]||=e=>c.value=!0,onBlur:h,onKeydown:n[10]||=js(e=>e.target.blur(),[`enter`])},null,40,Vy),[[ys,s.value]]),z(`button`,{class:`secondary`,"aria-label":`Increment ${e.path}`,disabled:e.disabled,onClick:n[11]||=e=>m(`increment`,1)},[B(A(Xc),{size:18})],8,Hy)])):i.value===`boolean`?(I(),L(`div`,Uy,[z(`button`,{class:E([`switch`,{on:e.value===!0}]),role:`switch`,"aria-label":`Value of ${e.path}`,"aria-checked":e.value===!0,disabled:e.disabled,onClick:n[12]||=t=>m(`update`,!e.value)},[...n[15]||=[z(`span`,null,null,-1)]],10,Wy),z(`span`,null,D(e.value),1)])):i.value===`string`?j((I(),L(`textarea`,{key:4,"onUpdate:modelValue":n[13]||=e=>s.value=e,rows:`2`,"aria-label":`Value of ${e.path}`,disabled:e.disabled,onFocus:n[14]||=e=>c.value=!0,onBlur:h},null,40,Gy)),[[ys,s.value]]):(I(),L(`span`,Ky,`null`))],10,ky)}}}),Jy=[`data-status`],Yy=[`title`],Xy=[`title`],Zy=[`href`],Qy=[`title`],$y=N({__name:`TunnelStatusBar`,props:{device:{}},setup(e){let t=e,n=U(()=>t.device.status===`online`),r=U(()=>t.device.transport===`tunnel`),i=U(()=>n.value?r.value?`online · via tunnel`:`online · LAN`:r.value?`tunnel`:`LAN`),a=U(()=>t.device.tunnel?.state===`connected`);return(t,o)=>(I(),L(`span`,{class:`tunnel-status`,"data-status":e.device.status},[z(`span`,{class:`axis transport`,title:r.value?`Hub ⇄ device over the tunnel (WSS)`:`Hub → device over LAN`},[r.value?(I(),R(A($s),{key:0,size:13,class:E({live:a.value})},null,8,[`class`])):(I(),R(A(vl),{key:1,size:13,class:E({live:n.value})},null,8,[`class`])),V(` `+D(i.value),1)],8,Yy),z(`span`,{class:E([`axis monitor`,e.device.status])},[e.device.status===`offline`?(I(),R(A(_l),{key:0,size:13})):(I(),L(F,{key:1},[V(D(e.device.status),1)],64))],2),r.value&&a.value&&e.device.tunnel?(I(),L(`span`,{key:0,class:`axis muted`,title:`tunnel last seen ${A(hd)(e.device.tunnel.lastSeenAt)}`},D(e.device.tunnel.readerCount)+` reader`+D(e.device.tunnel.readerCount===1?``:`s`),9,Xy)):H(``,!0),e.device.url?(I(),L(`a`,{key:1,class:`axis url`,href:e.device.url,target:`_blank`,rel:`noreferrer`},D(e.device.url),9,Zy)):H(``,!0),e.device.lastSeenAt?(I(),L(`span`,{key:2,class:`axis muted`,title:`last probe ${A(hd)(e.device.lastSeenAt)}`},D(A(hd)(e.device.lastSeenAt)),9,Qy)):H(``,!0)],8,Jy))}});async function eb(e,t,n,r,i){let a=await fetch(`/api${t}`,{method:e,headers:n===void 0?{}:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n),signal:r,...i?{keepalive:i}:{}}),o=await a.json().catch(()=>void 0);if(!a.ok){let e=o?.error;throw new Sl(e?.code??`internal`,e?.message??`${a.status} ${a.statusText}`,a.status)}return o}function tb(e){return e.offerUrl??e.pairUrl}var nb={pending:e=>eb(`GET`,`/pair/codes`,void 0,e),pairings:e=>eb(`GET`,`/pairings`,void 0,e),createCode:e=>eb(`POST`,`/pair/code`,{},e),resolveCode:(e,t)=>eb(`POST`,`/pair/resolve`,{code:e},t),codeState:(e,t)=>eb(`GET`,`/pair/codes/${encodeURIComponent(e)}`,void 0,t),approve:(e,t,n)=>eb(`POST`,`/pair/codes/${encodeURIComponent(e)}/approve`,t,n),cancel:(e,t,n)=>eb(`POST`,`/pair/codes/${encodeURIComponent(e)}/cancel`,{},t,n),rotate:(e,t)=>eb(`POST`,`/pairings/${encodeURIComponent(e)}/rotate`,{},t),revoke:(e,t=`user`,n)=>eb(`POST`,`/pairings/${encodeURIComponent(e)}/revoke`,{reason:t},n)},rb=0;function ib(){let e=++rb,t=!1;return{gen:e,close:()=>t=!0,closed:()=>t}}var ab=class extends Error{codeId;constructor(e){super(`pairing poll timed out for ${e}`),this.codeId=e,this.name=`PollTimeout`}},ob=e=>e===`issued`||e===`cancelled`||e===`expired`;async function sb(e,t,n={}){let r=n.intervalMs??1e3,i=Date.now()+(n.timeoutMs??33e4);for(;;){if(e.closed())return;if(n.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);if(Date.now()>i)throw new ab(t);let a=await nb.codeState(t,n.signal);if(e.closed())return;if(e.state=a,n.onState?.(a),ob(a.phase))return a;await new Promise(e=>setTimeout(e,r))}}var cb={key:0,class:`token-manager`,"aria-label":`Credential manager`},lb={class:`credential-fingerprint`},ub=[`title`],db={key:0,class:`rotation-badge`,role:`status`},fb={class:`token-actions`},pb=[`disabled`],mb=[`disabled`],hb={key:1,class:`message-error`,role:`alert`},gb=N({__name:`TokenManager`,props:{device:{}},setup(e){let t=e,n=k(!1),r=k(``),i=U(()=>t.device.pairing);async function a(){if(!n.value){n.value=!0,r.value=``;try{await nb.rotate(t.device.id),Y(`Rotation queued — it completes when the device acknowledges the new credential.`)}catch(e){r.value=K(e)}finally{n.value=!1}}}async function o(){n.value||(J.dialog={kind:`prompt`,title:`Revoke ${t.device.id}?`,hint:`Every tunnel credential for this device dies at commit and the live tunnel is cut within a second. The device cleans its own files the next time it talks to the hub.`,submit:`Revoke`,danger:!0,run:async()=>{await nb.revoke(t.device.id,`user`),Y(`Revoke committed on the hub. The tunnel is cut; the device cleans up on its next contact.`)}})}return(e,t)=>i.value?(I(),L(`section`,cb,[z(`header`,null,[B(A(kc),{size:15}),t[0]||=z(`h3`,null,`Credential`,-1),z(`span`,{class:E([`pairing-status`,i.value.status])},D(i.value.status),3)]),z(`dl`,null,[t[1]||=z(`dt`,null,`Key fingerprint`,-1),z(`dd`,null,[z(`code`,lb,D(i.value.keyFingerprint),1)]),t[2]||=z(`dt`,null,`Paired`,-1),z(`dd`,{title:new Date(i.value.pairedAt).toISOString()},D(A(hd)(i.value.pairedAt)),9,ub),t[3]||=z(`dt`,null,`Generation`,-1),z(`dd`,null,D(i.value.credentialGeneration),1)]),i.value.rotationPending?(I(),L(`p`,db,[B(A($c),{size:13,class:`spin`}),t[4]||=V(` rotation queued — waiting for the device to ACK `,-1)])):H(``,!0),z(`div`,fb,[i.value.status===`paired`?(I(),L(`button`,{key:0,class:`small`,disabled:n.value||i.value.rotationPending,onClick:a},[B(A($c),{size:14}),t[5]||=V(` Rotate credential `,-1)],8,pb)):H(``,!0),i.value.status===`paired`?(I(),L(`button`,{key:1,class:`small danger`,disabled:n.value,onClick:o},[B(A(cl),{size:14}),t[6]||=V(` Revoke `,-1)],8,mb)):H(``,!0)]),r.value?(I(),L(`p`,hb,D(r.value),1)):H(``,!0)])):H(``,!0)}}),_b={class:`tasks-panel`},vb={class:`panel-heading`},yb={class:`tag`},bb={key:0,class:`message-error`,role:`alert`},xb={class:`task-section`,"aria-label":`Durable jobs`},Sb={key:0,class:`task-empty`},Cb=[`data-job`],wb={class:`job-def-head`},Tb={key:0,class:`tag`},Eb={class:`tag`},Db=[`aria-label`],Ob=[`title`],kb={class:`job-def-meta`},Ab=[`title`],jb=[`title`],Mb={key:0,class:`job-def-last`},Nb=[`onClick`],Pb=[`disabled`,`onClick`],Fb=[`disabled`,`onClick`],Ib=[`disabled`,`onClick`],Lb={class:`task-section`,"aria-label":`Agent activity`},Rb={class:`panel-heading`},zb={key:0,class:`task-empty`},Bb={key:1,class:`task-tree`},Vb=[`data-task-kind`],Hb={class:`tag`},Ub={key:0,class:`task-phase`},Wb=[`onClick`],Gb=[`disabled`],Kb={class:`raw`},qb=N({__name:`TasksPanel`,setup(e){let t=k(``),n=k(!1),r=k([]),i=k(),a=e=>({running:`Running`,waiting:`Waiting`,completed:`Completed`,aborted:`Stopped`,declined:`Declined`,failed:`Failed`,pending:`Queued`,completing:`Finishing`,terminal:`Finished`})[e]??e,o=U(()=>new Map(Wg.value.map(e=>[e.id,Kg.value.find(t=>t.job===e.id)]))),s=U(()=>{let e=Zu.value,t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.owner!==void 0&&t.has(r.owner)?r.owner:void 0;n.set(e,[...n.get(e)??[],r])}let r=[],i=(e,t)=>{for(let a of(n.get(e)??[]).sort((e,t)=>e.id-t.id))r.push({task:a,depth:t}),i(a.id,t+1)};return i(void 0,0),r}),c=e=>e.kind===`pi.tool`?{icon:bl,name:e.label??`Tool call`,what:`tool call`}:e.kind===`pi.generation`?{icon:Zs,name:`Model response`,what:`generation`}:e.kind===`pi.compaction`?{icon:jc,name:`Compaction`,what:`compaction`}:e.kind.startsWith(`demo.job.`)?{icon:yl,name:e.label??Gg(e.kind.slice(9))?.title??e.kind,what:`durable job`}:e.kind===`demo.job-approval`?{icon:sl,name:`Approval`,what:`waits for you`}:{icon:Vs,name:e.label??e.kind,what:e.kind},l=e=>e.state.phase?e.kind.startsWith(`demo.job.`)?Gg(e.kind.slice(9))?.phases.find(t=>t.id===e.state.phase)?.label??e.state.phase:e.state.phase:``;async function u(){if(!n.value&&Ru.value){n.value=!0,t.value=``;try{await Ru.value.abort(!0)}catch(e){t.value=K(e)}finally{n.value=!1}}}async function d(e){let n=zu.value;if(e.target.open&&n)try{let[e,t]=await Promise.all([n.tasks(`terminal`,40),n.inspect()]);r.value=e,i.value=t}catch(e){t.value=K(e)}}let f=U(()=>r.value.filter(e=>e.state.status===`terminal`).slice(-12).reverse());return(e,r)=>(I(),L(`div`,_b,[z(`div`,vb,[r[0]||=z(`h2`,null,`Tasks`,-1),z(`span`,yb,D(A(Zu).length)+` active`,1)]),t.value?(I(),L(`p`,bb,D(t.value),1)):H(``,!0),z(`section`,xb,[z(`h3`,null,[B(A(el),{size:18}),r[1]||=V(`Durable jobs`,-1)]),r[2]||=z(`p`,{class:`hint`},[V(` Repeatable workflows with named phases. Every run follows the same phases and saves a checkpoint after each one. Start one here, or ask your agent: it finds these with `),z(`code`,null,`list_durable_jobs`),V(`, starts them with `),z(`code`,null,`run_durable_job`),V(` and checks them with `),z(`code`,null,`check_durable_job`),V(`. Runs play out live in the chat. `)],-1),A(Wg).length?H(``,!0):(I(),L(`p`,Sb,` This device has no durable jobs. Deploy the latest backend to it. `)),(I(!0),L(F,null,P(A(Wg),e=>(I(),L(`article`,{key:e.id,class:`job-def`,"data-job":e.id},[z(`div`,wb,[B(A(yl),{size:18}),z(`strong`,null,D(e.title),1),e.approval?(I(),L(`span`,Tb,`needs approval`)):H(``,!0),z(`span`,Eb,`~`+D(e.seconds)+`s`,1)]),z(`p`,null,D(e.summary),1),z(`ol`,{class:`job-chain`,"aria-label":`${e.title} phases`},[(I(!0),L(F,null,P(e.phases,(e,t)=>(I(),L(`li`,{key:e.id,title:e.summary},[z(`span`,null,D(t+1),1),V(D(e.label),1),e.kind===`repeat`?(I(),R(A(el),{key:0,size:13})):H(``,!0),e.kind===`approval`?(I(),R(A(sl),{key:1,size:13})):H(``,!0)],8,Ob))),128))],8,Db),z(`div`,kb,[(I(!0),L(F,null,P(e.inputs,e=>(I(),L(`code`,{key:e.name,title:e.description},D(e.name)+`=`+D(e.default),9,Ab))),128)),z(`code`,{title:`Each run saves its result to App State ${e.resultPath}`},`→ `+D(e.resultPath),9,jb)]),o.value.get(e.id)?(I(),L(`div`,Mb,[z(`span`,null,[V(`Run #`+D(o.value.get(e.id).run)+`: `,1),z(`strong`,null,D(a(o.value.get(e.id).status)),1),A(Ug)(o.value.get(e.id))?H(``,!0):(I(),L(F,{key:0},[V(` in `+D(o.value.get(e.id).phases.find(t=>t.id===o.value.get(e.id).phase)?.label),1)],64))]),z(`button`,{class:`text-button`,onClick:t=>A($g)(o.value.get(e.id).id)},` Show in chat `,8,Nb),o.value.get(e.id).approval===`pending`?(I(),L(F,{key:0},[z(`button`,{class:`primary small`,disabled:!!A(Zg),onClick:t=>A(t_)(o.value.get(e.id),!0)},` Approve `,8,Pb),z(`button`,{class:`secondary`,disabled:!!A(Zg),onClick:t=>A(t_)(o.value.get(e.id),!1)},` Decline `,8,Fb)],64)):H(``,!0)])):H(``,!0),z(`button`,{class:`secondary job-def-run`,disabled:!!A(Zg)||!A(Ru),onClick:t=>A(e_)(e)},[B(A(Yc),{size:16}),V(`Run `+D(e.title),1)],8,Ib)],8,Cb))),128))]),z(`section`,Lb,[z(`div`,Rb,[r[3]||=z(`h3`,null,`Agent activity`,-1),B(A(Vs),{size:18})]),r[5]||=z(`p`,{class:`hint`},` Every model response and every tool call is its own durable task with an id, an owner and a checkpoint. Follow them live here; after a restart each one resumes or reports how it ended. `,-1),s.value.length?(I(),L(`ul`,Bb,[(I(!0),L(F,null,P(s.value,({task:e,depth:t})=>(I(),L(`li`,{key:e.id,class:`task-row`,style:ge({"--depth":t}),"data-task-kind":e.kind},[(I(),R($r(c(e).icon),{size:16})),z(`strong`,null,D(c(e).name),1),z(`span`,Hb,D(a(e.state.status)),1),l(e)?(I(),L(`span`,Ub,D(l(e)),1)):H(``,!0),z(`small`,null,`#`+D(e.id)+` `+D(c(e).what)+`, agent #`+D(e.conversationId)+D(e.effectiveBackground?`, background`:``),1),(I(!0),L(F,null,P(e.conversations,e=>(I(),L(`button`,{key:e,class:`text-button`,onClick:t=>A(r_)(e)},` Open agent #`+D(e),9,Wb))),128))],12,Vb))),128))])):(I(),L(`p`,zb,`Nothing running. Send a message or run a job.`)),r[6]||=z(`p`,{class:`hint`},` Interrupt or Esc stops foreground work and what it owns. Stop all also stops background runs. `,-1),z(`button`,{class:`secondary danger`,disabled:!A(Zu).length||n.value,onClick:u},[B(A(Vc),{size:18}),r[4]||=V(`Stop all `,-1)],8,Gb)]),z(`details`,{class:`raw task-section`,onToggle:d},[z(`summary`,null,[B(A(oc),{size:18}),r[7]||=V(`Runtime details`,-1)]),r[9]||=z(`p`,{class:`hint`},` Recent task results and recovery records, read from the device when opened. `,-1),(I(!0),L(F,null,P(f.value,e=>(I(),L(`details`,{key:e.id,class:`raw`},[z(`summary`,null,[V(D(e.kind)+` #`+D(e.id),1),z(`span`,null,D(a(e.state.outcome?.status??e.state.status)),1)]),z(`pre`,null,D(JSON.stringify(e.state.outcome,null,2)),1)]))),128)),z(`details`,Kb,[r[8]||=z(`summary`,null,`Recovery inspection`,-1),z(`pre`,null,D(JSON.stringify(i.value,null,2)),1)])],32)]))}}),Jb={class:`git-pane`},Yb={key:0,class:`hint`},Xb={key:0,class:`hint`},Zb={key:1,class:`muted-line`},Qb={key:2,class:`message-error`},$b={key:0,class:`hint`},ex={key:0,class:`message-error merge-banner`},tx=[`disabled`],nx={class:`panel-heading git-top`},rx={class:`branch-wrap`},ix=[`disabled`],ax={key:0,class:`menu`},ox=[`onClick`],sx={class:`muted-line`},cx={class:`new-branch`},lx=[`disabled`],ux={class:`auto-stash`},dx={class:`tag`},fx={key:0,class:`tag`},px={key:1,class:`tag`},mx={key:2,class:`tag`,title:`vs the picked base`},hx={class:`tag`},gx=[`href`],_x=[`disabled`],vx={class:`row ops`},yx=[`disabled`],bx=[`disabled`],xx=[`disabled`],Sx=[`disabled`],Cx=[`disabled`],wx={key:1,class:`message-error hintbox`},Tx=[`disabled`],Ex=[`disabled`],Dx={key:2,class:`message-error hintbox`},Ox=[`disabled`],kx={class:`task-section`,"aria-label":`Commit`},Ax={class:`panel-heading`},jx={class:`tag`},Mx=[`disabled`],Nx=[`disabled`],Px={key:0,class:`hintbox warn`},Fx={key:1,class:`cps turns`},Ix={key:0,class:`hint`},Lx={class:`muted-line`},Rx={class:`cp-subj`},zx={key:2,class:`muted-line cap`},Bx={key:3,class:`files conflicts`},Vx={class:`file all`},Hx={class:`muted-line conflict-head`},Ux={class:`file-label`},Wx={class:`xy`},Gx=[`title`],Kx={class:`file-acts`},qx=[`onClick`],Jx=[`disabled`,`onClick`],Yx=[`disabled`,`onClick`],Xx={key:4,class:`files`},Zx={class:`file all`},Qx=[`checked`],$x={class:`muted-line`},eS=[`onClick`],tS={class:`muted-line`},nS={class:`file-label`},rS=[`checked`,`onChange`],iS=[`title`],aS=[`title`],oS={class:`file-acts`},sS=[`onClick`],cS=[`onClick`],lS=[`onClick`],uS={key:5,class:`files`},dS={class:`file all`},fS=[`checked`],pS={class:`muted-line`},mS=[`onClick`],hS={class:`muted-line`},gS={class:`file-label`},_S=[`checked`,`onChange`],vS=[`title`],yS=[`title`],bS={class:`file-acts`},xS=[`onClick`],SS=[`onClick`],CS=[`onClick`],wS=[`onClick`],TS=[`onClick`],ES={key:6,class:`file-diff`},DS={class:`mode-chips`},OS={key:0,class:`nums bin`},kS={key:1,class:`nums`},AS={key:2},jS={class:`row`},MS=[`disabled`],NS=[`disabled`],PS=[`disabled`],FS={class:`task-section`,"aria-label":`Log`},IS={class:`panel-heading`},LS=[`disabled`],RS=[`disabled`],zS=[`disabled`],BS={key:0,class:`cps`},VS={key:0,class:`hint`},HS={class:`muted-line`},US={class:`cp-subj`},WS=[`disabled`,`onClick`],GS={key:1,class:`hint`},KS={key:2,class:`commits`},qS=[`title`],JS=[`width`],YS=[`x1`,`x2`],XS=[`x1`,`x2`,`stroke`],ZS=[`cx`,`fill`],QS=[`onClick`],$S={class:`hash`},eC=[`href`],tC={key:1,class:`refs`},nC={class:`subject`},rC={class:`muted-line who`},iC={key:0,class:`commit-files`},aC=[`data-s`],oC={class:`path`},sC={key:0,class:`hint`},cC={key:3,class:`message-error`},lC={key:4,class:`hint`},uC={class:`task-section`,"aria-label":`Worktrees`},dC={class:`panel-heading`},fC={class:`branch-wrap`},pC=[`disabled`],mC={key:0,class:`menu`},hC=[`onClick`],gC={class:`new-branch`},_C=[`disabled`],vC=[`title`],yC={class:`muted-line`},bC=[`disabled`,`onClick`],xC=[`disabled`,`onClick`],SC=[`disabled`,`onClick`],CC={key:3,class:`task-section`,"aria-label":`Pull requests`},wC={class:`panel-heading`},TC=[`disabled`],EC=[`disabled`],DC={key:0,class:`hint`},OC={key:1,class:`commits`},kC={class:`hash`},AC={class:`subject`},jC={class:`muted-line who`},MC=[`disabled`,`onClick`],NC=[`disabled`,`onClick`],PC=[`disabled`,`onClick`],FC=[`href`],IC={key:4,class:`op-out`},LC=[`placeholder`],RC={class:`row`},zC=[`disabled`],BC=Vd(N({__name:`GitPanel`,props:{deviceId:{},cwd:{}},setup(e){let t=e,n=U(()=>t.cwd??Iu.value?.cwd??``),r=U(()=>t.deviceId??Au.value),i=U(()=>nf(r.value||`?`,n.value||`?`)),a=U(()=>i.value.status),o=U(()=>i.value.loading),s=U(()=>i.value.refreshing),c=U(()=>i.value.error),l=U(()=>{let e=Iu.value;return e&&e.cwd===n.value&&!t.deviceId?e.id:void 0}),u=k(``),d=k(``),f=k(``),p=k(new Set),m=k(!1),h=k(!1),g=k(``),_=k(null),v=k(`working`),y=U(()=>`dpi-git-draft:${r.value}:${n.value}`),b=k(null),x=k(!0),S=k(``),C=k(!1),ee=k([]),w=U(()=>{if(!ee.value.length||!n.value)return null;let e=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,t=new Set(ee.value);return{changed:(a.value?.files??[]).filter(n=>t.has(e(n.path))).length,total:ee.value.length}}),T=k(null),te=k(``),ne=e=>{te.value=e.input?.value??``,T.value=e},re=()=>{let e=T.value;T.value=null,e&&e.action(te.value)};window.addEventListener(`keydown`,e=>{e.key===`Escape`&&T.value&&(T.value=null)});let ie=k([]),ae=k(!1),oe=k(new Map),se=k([]),ce=k(!1),le=k(new Map),ue=k(!1),de=U(()=>/github\.com|gitlab/i.test(a.value?.remoteUrl??``)),fe=async()=>{if(r.value&&n.value){ue.value=!0;try{let e=await G(r.value).gitOp(n.value,`pr-list`);se.value=e.prs??[]}catch(e){Y(`pr list failed: ${e.message.slice(0,120)}`)}finally{ue.value=!1}}};M(ce,e=>{e&&fe()});let pe=()=>ne({title:`Create pull request`,body:`head: ${a.value?.branch??`?`}`,confirmLabel:`Create PR`,input:{placeholder:`PR title`,value:f.value.trim()||``},action:e=>void me(e)});async function me(e){if(r.value&&n.value&&e.trim()){ue.value=!0;try{Y((await G(r.value).gitOp(n.value,`pr-create`,{message:e.trim(),body:e.trim()})).text.split(`
77
- `)[0]??`PR created`),await fe()}catch(e){Y(`pr create failed: ${e.message.slice(0,140)}`)}finally{ue.value=!1}}}async function he(e){if(r.value&&n.value){ue.value=!0;try{let t=await G(r.value).gitOp(n.value,`pr-checks`,{n:e});le.value=new Map(le.value).set(e,t.text.slice(0,1500))}catch(e){Y(`pr checks failed: ${e.message.slice(0,120)}`)}finally{ue.value=!1}}}let ge=e=>ne({title:`Merge PR #${e}?`,body:`squash-merge via gh on the device.`,confirmLabel:`Squash & merge`,danger:!0,action:()=>void _e(e)});async function _e(e){if(r.value&&n.value){ue.value=!0;try{Y((await G(r.value).gitOp(n.value,`pr-merge`,{n:e})).text||`PR #${e} merged`),await fe(),await Ee()}catch(e){Y(`pr merge failed: ${e.message.slice(0,140)}`)}finally{ue.value=!1}}}let ve=e=>ne({title:`Comment on PR #${e}`,body:`posted as the device's gh login`,confirmLabel:`Comment`,input:{placeholder:`comment…`,value:``},action:t=>void ye(e,t)});async function ye(e,t){if(r.value&&n.value&&t.trim()){ue.value=!0;try{Y((await G(r.value).gitOp(n.value,`pr-comment`,{n:e,body:t.trim()})).text||`comment posted`)}catch(e){Y(`pr comment failed: ${e.message.slice(0,140)}`)}finally{ue.value=!1}}}let be=k([]),xe=k(!1),Se=async()=>{if(r.value&&l.value)try{let e=await G(r.value).sessionGitTurns(l.value);be.value=e.turns}catch{be.value=[]}};M(xe,e=>{e&&Se()});let Ce=0;window.addEventListener(`focus`,()=>{!n.value||Date.now()-Ce<15e3||(Ce=Date.now(),af(r.value||`?`,n.value||`?`,{force:!0}))});let we=k(new Set),Te=()=>{typeof localStorage<`u`&&(f.value=localStorage.getItem(y.value)??``)};ef(),af(r.value||`?`,n.value||`?`),Te(),Kr(()=>af(r.value||`?`,n.value||`?`)),M(f,e=>{typeof localStorage<`u`&&(e?localStorage.setItem(y.value,e):localStorage.removeItem(y.value))}),M([r,n],()=>{m.value=!1,h.value=!1,_.value=null,b.value=null,S.value=``,C.value=!1,ee.value=[],oe.value=new Map,we.value=new Set,af(r.value||`?`,n.value||`?`),Te()});let Ee=()=>(p.value=new Set,_.value=null,af(r.value||`?`,n.value||`?`,{force:!0})),De=U(()=>a.value?.files??[]);M(De,e=>{let t=new Set;for(let n of e)n.x!==`?`&&n.y!==`?`&&t.add(n.path);p.value=t},{immediate:!0});let Oe=U(()=>De.value.some(e=>p.value.has(e.path))),ke=U(()=>De.value.filter(e=>!je(e)&&e.x!==` `&&e.x!==`?`)),Ae=U(()=>De.value.filter(e=>!je(e)&&(e.x===` `||e.x===`?`))),je=e=>`UAD`.includes(e.x)&&`UAD`.includes(e.y),Me=U(()=>De.value.filter(je)),Ne=U(()=>De.value.length>=500),Pe=U(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0)>0),Fe=U(()=>!a.value?.identity?.name||!a.value?.identity?.email),O=U(()=>{let e=a.value?.remoteUrl??``,t=e.match(/git@([^:]+):(.+?)(?:\.git)?$/)??e.match(/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/);return t?`https://${t[1]}/${t[2]}`:``}),Ie=e=>{let t=new Set(p.value);t.has(e)?t.delete(e):t.add(e),p.value=t},Le=e=>{let t=e.every(e=>p.value.has(e.path)),n=new Set(p.value);for(let r of e)t?n.delete(r.path):n.add(r.path);p.value=n},Re=e=>{let t=e.lastIndexOf(`/`);return t===-1?`.`:e.slice(0,t)},ze=e=>{let t=new Map;for(let n of e){let e=Re(n.path);t.has(e)||t.set(e,[]),t.get(e).push(n)}return[...t.entries()].map(([e,t])=>({dir:e,files:t,open:!we.value.has(e)}))},Be=e=>{let t=new Set(we.value);t.has(e)?t.delete(e):t.add(e),we.value=t},Ve=e=>e.a===void 0&&e.d===void 0?``:e.a===-1||e.d===-1?`bin`:`+${e.a??0} −${e.d??0}`,He=e=>{navigator.clipboard?.writeText(e).then(()=>Y(`copied ${e}`))};async function Ue(e,t={}){if(r.value&&n.value){u.value=e,d.value=``;try{let i=await G(r.value).gitOp(n.value,e,t);d.value=i.text||`(empty)`,e===`push`&&(S.value=``),e===`pull`&&(C.value=!1),[`fetch`,`pull`,`push`,`stash-push`,`stash-pop`].includes(e)&&Y(`git ${e} ✓`),await Ee(),vt(!0)}catch(t){let n=t.message;e===`push`&&(/no upstream|has no upstream|upstream is gone/i.test(n)?S.value=`no upstream — set it while pushing?`:/fetch first|non-fast-forward|rejected.*fetch|behind/i.test(n)?S.value=`the remote has work you lack — pull first`:/authentication|permission|could not read|403|denied/i.test(n)?S.value=`credentials rejected on the device — check its git login`:S.value=``),e===`pull`&&/not possible to fast-forward|divergent|unrelated histories/i.test(n)&&(C.value=!0),Y(`git ${e}: ${n.slice(0,160)}`)}finally{u.value=``}}}async function We(e,t,i=!1){if(!r.value||!n.value||(i&&(u.value=e),!t&&e!==`stage`))return;if(e===`discard`&&t&&!i){ne({title:`Roll back to HEAD?`,body:`${t} — uncommitted changes are lost.`,confirmLabel:`Roll back`,danger:!0,action:()=>void We(e,t,!0)});return}u.value=e;let a=t?[t]:De.value.filter(e=>e.x===` `||e.x===`M`).map(e=>e.path);try{Y((await G(r.value).gitOp(n.value,e,{files:a})).text),await Ee()}catch(t){Y(`${e} failed: ${t.message.slice(0,140)}`)}finally{u.value=``}}async function Ge(e){if(r.value&&n.value&&e.length){u.value=`unstage`;try{Y((await G(r.value).gitOp(n.value,`unstage`,{files:e})).text),await Ee()}catch(e){Y(`unstage failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function Ke(e,t){if(r.value&&n.value){u.value=`resolve`;try{Y((await G(r.value).gitOp(n.value,`resolve`,{side:e,files:[t]})).text),await Ee()}catch(e){Y(`resolve failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function qe(e){if(r.value&&n.value&&e.length){u.value=`ignore`;try{Y((await G(r.value).gitOp(n.value,`ignore`,{lines:e})).text),await Ee()}catch(e){Y(`ignore failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function Je(e){if(r.value&&n.value){if(_.value?.path===e)return _.value=null;u.value=`diff`;try{let t=await G(r.value).gitOp(n.value,`diff-file`,{target:e,staged:v.value===`staged`});_.value={path:e,text:t.text}}catch(e){Y(`diff failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}let Ye=async()=>{let e=_.value?.path;_.value=null,e&&await Je(e)},Xe=U(()=>/Binary files .* differ/i.test(_.value?.text??``));async function Ze(){if(r.value&&n.value){u.value=`abort`;try{Y((await G(r.value).gitOp(n.value,`merge-abort`)).text),await Ee()}catch(e){Y(`abort failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function Qe(e){if(m.value=!1,r.value&&n.value){u.value=`compare`;try{let t=await G(r.value).gitOp(n.value,`compare`,{ref:e});b.value={ref:e,ahead:t.ahead??0,behind:t.behind??0}}catch(e){Y(`compare failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function $e(e,t=!1){if(m.value=!1,!r.value||!n.value||e===a.value?.branch&&!t)return;u.value=`switch`;let i=G(r.value),o=!1;try{if(x.value&&!t&&Pe.value&&(await i.gitOp(n.value,`stash-push`,{message:`dpi auto-stash before ${e}`}),o=!0),Y((await i.gitOp(n.value,`switch`,{ref:e,create:t})).text||`switched to ${e}`),o)try{let e=await i.gitOp(n.value,`stash-pop`);/conflict/i.test(e.text)&&Y(`stash popped WITH CONFLICTS — resolve in the file list`)}catch{Y(`switched, but the stash did not pop — resolve manually (git stash list)`)}await Ee(),vt(!0)}catch(e){if(Y(`switch failed: ${e.message.slice(0,140)}`),o)try{await i.gitOp(n.value,`stash-pop`)}catch{}}finally{u.value=``}}async function et(e=!1){if(!r.value||!n.value||!f.value.trim())return;u.value=`commit`;let t=De.value.filter(e=>p.value.has(e.path)).map(e=>e.path);if(!t.length)return Y(`check the files to commit — nothing is selected`);let i=G(r.value);try{if(Y((await i.gitOp(n.value,`commit`,{message:f.value.trim(),...a.value?.merge?{}:{files:t}})).text),f.value=``,e)try{Y(`pushed: ${(await i.gitOp(n.value,`push`)).text.slice(0,80)}`)}catch(e){Y(`committed, but push failed: ${e.message.slice(0,120)}`)}await Ee(),vt(!0)}catch(e){Y(`commit failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}function tt(e){let t=e?.models??[],n=t.find(t=>`${t.provider}/${t.id}`===e?.defaultModel),r=new Map;for(let e of t)r.has(e.provider)||r.set(e.provider,e);let i=[...r.values()].filter(e=>e!==n).slice(0,3);return(n?[n,...i]:i).slice(0,4)}async function nt(){if(!r.value||!n.value)return;let e=De.value.filter(e=>p.value.has(e.path)).map(e=>e.path);if(!e.length)return Y(`check files first — the model summarises THOSE`);u.value=`ai`;let t=G(r.value),i=``;for(let r of e.slice(0,5)){let e=await t.gitOp(n.value,`diff-file`,{target:r});if(i+=`${e.text}\n`,i.length>4e3)break}i=i.slice(0,4e3);let a=`Write ONE concise git commit message (under 72 chars, imperative, no quotes, no backticks) for these changes:\n\n${i}`,o=Cu.devices.value.find(e=>e.id===r.value)?.info,s=tt(o);if(!s.length)return u.value=``,Y(`no model on the device`);let c=[];try{for(let e of s){let r=await t.createSession({name:`git-msg`,cwd:n.value,model:{provider:e.provider,modelId:e.id}}).then(e=>e.id).catch(()=>``);if(!r){c.push(`${e.provider}: no session`);continue}try{let n=await t.agent(r,1).send(a,`followUp`,void 0,12e4),i=n.status===`done`?n.answer.text.trim().split(`
78
- `)[0]?.slice(0,100):``;if(i){f.value=i;return}c.push(`${e.provider}/${e.id}: ${n.status===`unanswered`?n.reason:`empty answer`}`)}finally{t.session(r).archive().catch(()=>{})}}Y(`ai message failed on every model — ${c.join(`; `).slice(0,140)}`)}catch(e){Y(`ai message failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}async function rt(){if(r.value&&l.value){u.value=`session-files`;try{let e=await G(r.value).sessionGitFiles(l.value);ee.value=e.files;let t=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,i=new Set(e.files.map(t)),a=De.value.filter(e=>i.has(t(e.path)));p.value=new Set(a.map(e=>e.path)),Y(a.length?`${a.length} session file(s) still changed — checked`:`the session touched nothing that is still changed`)}catch(e){Y(`session files failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function it(e){if(oe.value.has(e)){oe.value.delete(e),oe.value=new Map(oe.value);return}if(r.value&&n.value)try{let t=await G(r.value).gitOp(n.value,`show-files`,{target:e});oe.value=new Map(oe.value).set(e,t.changed??[])}catch(e){Y(`commit files failed: ${e.message.slice(0,120)}`)}}async function at(){if(!r.value||!n.value)return;let e=`cp-${new Date().toISOString().slice(0,16).replace(/[-:T]/g,``)}`;u.value=`checkpoint`;try{Y((await G(r.value).gitOp(n.value,`checkpoint`,{name:e})).text),ae.value=!0,await ot()}catch(e){Y(`checkpoint failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}async function ot(){if(r.value&&n.value)try{let e=await G(r.value).gitOp(n.value,`checkpoints`);ie.value=e.checkpoints??[]}catch{ie.value=[]}}async function st(e){if(!r.value||!n.value)return;let t=e;ne({title:`Rewind to ${t}?`,body:`reset --hard — ALL uncommitted changes in this worktree are LOST.`,confirmLabel:`Rewind`,danger:!0,action:()=>void ct(t)})}async function ct(e){if(r.value&&n.value){u.value=`rewind`;try{Y((await G(r.value).gitOp(n.value,`rewind`,{name:e})).text),await Ee(),vt(!0)}catch(e){Y(`rewind failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}M(ae,e=>{e&&ot()});async function lt(e){if(h.value=!1,r.value&&n.value&&a.value?.root){u.value=`wt`;try{Y((await ep(G(r.value),n.value,a.value.root,e)).text),g.value=``,await Ee()}catch(e){Y(`worktree failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function ut(e,t){if(r.value){u.value=`session`;try{let n=Cu.devices.value.find(e=>e.id===r.value)?.info,i=tt(n)[0];if(!i)return Y(`no model available on ${r.value} — cannot create a session`);let a=await tp(G(r.value),e,t??e.slice(e.lastIndexOf(`/`)+1),{provider:i.provider,modelId:i.id});Bu({deviceId:r.value,sessionId:a.id,agentId:1}),Y(`session "${a.name}" on ${e}`)}catch(e){Y(`session failed: ${e.message.slice(0,160)}`)}finally{u.value=``}}}async function dt(e){if(r.value){u.value=`go`;try{let t=(await G(r.value).sessions()).find(t=>t.cwd===e);t?(Bu({deviceId:r.value,sessionId:t.id,agentId:1}),Y(`switched to session "${t.name}"`)):await ut(e,null)}catch(e){Y(`switch failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function ft(e){if(!r.value||!n.value)return;u.value=`wt`;let t=`Uncommitted changes in it will be LOST.`;try{let n=(await G(r.value).gitStatusBatch([e],{timeoutMs:6e4}))[e];t=(n?.staged??0)+(n?.unstaged??0)+(n?.untracked??0)>0?`It CONTAINS uncommitted changes — they will be LOST.`:`Its checkout is clean.`}catch{}ne({title:`Remove worktree?`,body:`${e} — ${t}`,confirmLabel:`Remove`,danger:!0,action:()=>void pt(e)})}async function pt(e){u.value=`wt`;try{await G(r.value).gitOp(n.value,`worktree-remove`,{target:e}),await Ee()}catch(e){Y(`remove failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}let mt=k([]),ht=k(!1),gt=k(``),_t=0;async function vt(e=!1){if(r.value&&n.value&&!(!e&&mt.value.length&&Date.now()-_t<12e4)){ht.value=!0;try{let e=await G(r.value).gitOp(n.value,`log-list`);mt.value=e.commits??[],gt.value=``,_t=Date.now()}catch(e){gt.value=e.message.slice(0,120)}finally{ht.value=!1}}}vt(),M([r,n],()=>{mt.value=[],_t=0,vt()});let yt=U(()=>(a.value?.worktrees??[]).filter(e=>e.path)),bt=[`#4f8cc9`,`#b8860b`,`#7aa25c`,`#a061ba`,`#c96f6f`,`#5fa8a0`],xt=U(()=>{let e=new Map,t=[],n=[];for(let r of mt.value){let i=e.get(r.hash);i===void 0&&(i=n.indexOf(null),i===-1&&(n.push(null),i=n.length-1),e.set(r.hash,i)),n[i]=null;let a=[];r.parents.forEach((t,r)=>{let o=e.get(t);(o===void 0||n[o]===t)&&(o=n.indexOf(null),o===-1&&(n.push(null),o=n.length-1),e.set(t,o)),n[o]=t,r===0&&(n[i]=t),a.push(o)}),t.push({lane:i,parents:a,width:Math.max(1,n.length)})}return t}),St=e=>e*12+7;return(e,t)=>(I(),L(`div`,Jb,[n.value?(I(),L(F,{key:1},[o.value?(I(),L(`p`,Xb,`loading git…`)):s.value?(I(),L(`p`,Zb,`refreshing…`)):H(``,!0),c.value?(I(),L(`p`,Qb,[V(D(c.value)+` `,1),z(`button`,{onClick:t[0]||=e=>Ee()},`retry`)])):H(``,!0),a.value?(I(),L(`div`,{key:3,class:E({stale:!!c.value||!!s.value})},[a.value.repo?(I(),L(F,{key:1},[a.value.merge?(I(),L(`p`,ex,[V(` merge in progress — `+D(a.value.conflicts??Me.value.length)+` unmerged path(s). Resolve them in the lists above, or `,1),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[1]||=e=>Ze()},`abort merge`,8,tx)])):H(``,!0),z(`div`,nx,[z(`div`,rx,[z(`button`,{class:`branch-btn`,disabled:!!u.value,onClick:t[2]||=e=>m.value=!m.value},[B(A(xc),{size:16}),z(`strong`,null,D(a.value.branch??`detached`),1),B(A(nc),{size:14})],8,ix),m.value?(I(),L(`div`,ax,[(I(!0),L(F,null,P(a.value.branches??[],e=>(I(),L(`button`,{key:e.name,class:E({cur:e.current}),onClick:t=>$e(e.name)},[B(A(xc),{size:13}),z(`span`,null,D(e.name),1),z(`span`,sx,D(e.current?`current`:e.upstream?`→ ${e.upstream}`:``),1),t[42]||=z(`span`,{class:`grow`},null,-1),e.current?H(``,!0):(I(),R(A(Sc),{key:0,size:13,title:`compare with this base`,onClick:ks(t=>Qe(e.name),[`stop`])},null,8,[`onClick`]))],10,ox))),128)),z(`div`,cx,[j(z(`input`,{"onUpdate:modelValue":t[3]||=e=>g.value=e,placeholder:`new branch…`,onKeyup:t[4]||=js(e=>g.value.trim()&&$e(g.value.trim(),!0),[`enter`])},null,544),[[ys,g.value]]),z(`button`,{disabled:!g.value.trim(),onClick:t[5]||=e=>$e(g.value.trim(),!0)},[B(A(Xc),{size:13})],8,lx)]),z(`label`,ux,[j(z(`input`,{type:`checkbox`,"onUpdate:modelValue":t[6]||=e=>x.value=e},null,512),[[bs,x.value]]),t[43]||=V(` auto-stash on switch`,-1)])])):H(``,!0)]),z(`span`,dx,D(a.value.upstream??`no upstream`),1),a.value.ahead?(I(),L(`span`,fx,`↑`+D(a.value.ahead),1)):H(``,!0),a.value.behind?(I(),L(`span`,px,`↓`+D(a.value.behind),1)):H(``,!0),b.value?(I(),L(`span`,mx,[V(` vs `+D(b.value.ref)+`: ↑`+D(b.value.ahead)+` ↓`+D(b.value.behind)+` `,1),z(`button`,{class:`tag-x`,onClick:t[7]||=e=>b.value=null},[B(A(xl),{size:11})])])):H(``,!0),z(`span`,hx,`+`+D(a.value.staged??0)+` ~`+D(a.value.unstaged??0)+` ?`+D(a.value.untracked??0),1),O.value?(I(),L(`a`,{key:3,class:`icon-button`,href:`${O.value}/tree/${a.value.branch??``}`,target:`_blank`,rel:`noopener`,title:`open on the remote`},[B(A(Ks),{size:15,style:{transform:`rotate(45deg)`}})],8,gx)):H(``,!0),z(`button`,{class:`icon-button`,disabled:!!u.value||o.value||s.value,title:`refresh`,onClick:t[8]||=e=>Ee()},[B(A($c),{size:16})],8,_x)]),z(`div`,vx,[z(`button`,{class:`small`,disabled:!!u.value,onClick:t[9]||=e=>Ue(`fetch`)},[B(A(Ws),{size:14}),t[44]||=V(`fetch`,-1)],8,yx),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[10]||=e=>Ue(`pull`)},[B(A(Ws),{size:14}),t[45]||=V(`pull`,-1)],8,bx),z(`button`,{class:`small primary`,disabled:!!u.value,title:`push`,onClick:t[11]||=e=>Ue(`push`)},[B(A(Ks),{size:14}),t[46]||=V(`push`,-1)],8,xx),z(`button`,{class:`small`,disabled:!!u.value,title:`stash changes`,onClick:t[12]||=e=>Ue(`stash-push`,{message:f.value.trim()||void 0})},[B(A(dl),{size:14}),t[47]||=V(`stash`,-1)],8,Sx),z(`button`,{class:`small`,disabled:!!u.value,title:`pop the newest stash`,onClick:t[13]||=e=>Ue(`stash-pop`)},[B(A(Hc),{size:14}),t[48]||=V(`unstash`,-1)],8,Cx)]),S.value?(I(),L(`p`,wx,[V(D(S.value)+` `,1),S.value.includes(`upstream`)?(I(),L(`button`,{key:0,class:`small primary`,disabled:!!u.value,onClick:t[14]||=e=>Ue(`push`,{setUpstream:!0,ref:a.value.branch})},`push -u origin `+D(a.value.branch),9,Tx)):S.value.includes(`remote has work`)?(I(),L(`button`,{key:1,class:`small primary`,disabled:!!u.value,onClick:t[15]||=e=>Ue(`pull`)},`pull now`,8,Ex)):H(``,!0)])):H(``,!0),C.value?(I(),L(`p`,Dx,[t[49]||=V(` fast-forward is not possible — branches diverged. `,-1),z(`button`,{class:`small primary`,disabled:!!u.value,onClick:t[16]||=e=>Ue(`pull`,{rebase:!0})},`pull --rebase`,8,Ox)])):H(``,!0),z(`section`,kx,[z(`div`,Ax,[t[50]||=z(`h4`,null,`Commit`,-1),z(`span`,jx,D(De.value.length?`${p.value.size}/${De.value.length} files`:`no changes`),1),t[51]||=z(`span`,{class:`grow`},null,-1),l.value?(I(),L(`button`,{key:0,class:`small`,disabled:!!u.value,title:`check the files this session's agent touched`,onClick:rt},[B(A(_c),{size:13}),V(` session files`+D(w.value?` (${w.value.changed}/${w.value.total})`:``),1)],8,Mx)):H(``,!0),l.value?(I(),L(`button`,{key:1,class:`small`,disabled:!!u.value,title:`what each turn of this session changed`,onClick:t[17]||=e=>xe.value=!xe.value},` turns `,8,Nx)):H(``,!0)]),Fe.value?(I(),L(`p`,Px,[...t[52]||=[V(`git user.name/user.email is not set on the device — `,-1),z(`code`,null,`dpi device config`,-1),V(` or `,-1),z(`code`,null,`git config --global`,-1),V(` before committing.`,-1)]])):H(``,!0),xe.value?(I(),L(`div`,Fx,[be.value.length?H(``,!0):(I(),L(`p`,Ix,`no turns recorded yet for this session.`)),(I(!0),L(F,null,P(be.value,(e,t)=>(I(),L(`div`,{key:t,class:`cp-row`},[z(`code`,null,`t`+D(be.value.length-t),1),z(`span`,Lx,D(e.when.slice(0,16).replace(`T`,` `)),1),z(`span`,Rx,D(e.files.map(e=>`${e.path}×${e.writes}${e.a!==void 0||e.d!==void 0?` (+${e.a??0} −${e.d??0})`:``}`).join(`, `)||`(no file writes)`),1)]))),128))])):H(``,!0),Ne.value?(I(),L(`p`,zx,`showing the first 500 changed files — commit in smaller batches`)):H(``,!0),Me.value.length?(I(),L(`div`,Bx,[z(`label`,Vx,[z(`span`,Hx,`Conflicts · `+D(Me.value.length)+` — pick a side per file`,1)]),(I(!0),L(F,null,P(Me.value,e=>(I(),L(`div`,{key:e.path,class:`file`},[z(`label`,Ux,[z(`code`,Wx,D(e.x)+D(e.y),1),z(`span`,{class:`path`,title:e.path},D(e.path),9,Gx)]),z(`span`,Kx,[z(`button`,{class:`icon-button`,title:`view the conflict`,onClick:t=>Je(e.path)},[B(A(hc),{size:13})],8,qx),z(`button`,{class:`small`,disabled:!!u.value,title:`keep this branch's version and stage it`,onClick:t=>Ke(`ours`,e.path)},`ours`,8,Jx),z(`button`,{class:`small`,disabled:!!u.value,title:`take the incoming version and stage it`,onClick:t=>Ke(`theirs`,e.path)},`theirs`,8,Yx)])]))),128))])):H(``,!0),ke.value.length?(I(),L(`div`,Xx,[z(`label`,Zx,[z(`input`,{type:`checkbox`,checked:ke.value.every(e=>p.value.has(e.path)),onChange:t[18]||=e=>Le(ke.value)},null,40,Qx),z(`span`,$x,`Staged · `+D(ke.value.length),1),t[55]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,title:`stage every changed file`,onClick:t[19]||=e=>We(`stage`)},[B(A(Xc),{size:13}),t[53]||=V(` all`,-1)]),z(`button`,{class:`icon-button`,title:`unstage all (git reset HEAD)`,onClick:t[20]||=e=>Ge(ke.value.map(e=>e.path))},[B(A(Rc),{size:13}),t[54]||=V(` none`,-1)])]),(I(!0),L(F,null,P(ze(ke.value),e=>(I(),L(F,{key:e.dir},[e.dir===`.`?H(``,!0):(I(),L(`button`,{key:0,class:`dir-row`,onClick:t=>Be(e.dir)},[B(A(rc),{size:12,class:E({open:e.open})},null,8,[`class`]),V(D(e.dir),1),z(`span`,tS,`· `+D(e.files.length),1)],8,eS)),(I(!0),L(F,null,P(e.files,t=>j((I(),L(`div`,{key:t.path,class:`file`},[z(`label`,nS,[z(`input`,{type:`checkbox`,checked:p.value.has(t.path),onChange:e=>Ie(t.path)},null,40,rS),z(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,iS),z(`span`,{class:`path`,title:t.path},D(t.path),9,aS),Ve(t)?(I(),L(`span`,{key:0,class:E([`nums`,{bin:Ve(t)===`bin`}])},D(Ve(t)),3)):H(``,!0)]),z(`span`,oS,[z(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Je(t.path)},[B(A(hc),{size:13})],8,sS),z(`button`,{class:`icon-button`,title:`unstage (git reset HEAD)`,onClick:e=>Ge([t.path])},[B(A(Rc),{size:13})],8,cS),z(`button`,{class:`icon-button`,title:`roll back to HEAD`,onClick:e=>We(`discard`,t.path)},[B(A(uc),{size:13})],8,lS)])])),[[Ro,e.open]])),128))],64))),128))])):H(``,!0),Ae.value.length?(I(),L(`div`,uS,[z(`label`,dS,[z(`input`,{type:`checkbox`,checked:Ae.value.every(e=>p.value.has(e.path)),onChange:t[21]||=e=>Le(Ae.value)},null,40,fS),z(`span`,pS,`Unstaged · `+D(Ae.value.length),1)]),(I(!0),L(F,null,P(ze(Ae.value),e=>(I(),L(F,{key:e.dir},[e.dir===`.`?H(``,!0):(I(),L(`button`,{key:0,class:`dir-row`,onClick:t=>Be(e.dir)},[B(A(rc),{size:12,class:E({open:e.open})},null,8,[`class`]),V(D(e.dir),1),z(`span`,hS,`· `+D(e.files.length),1)],8,mS)),(I(!0),L(F,null,P(e.files,t=>j((I(),L(`div`,{key:t.path,class:`file`},[z(`label`,gS,[z(`input`,{type:`checkbox`,checked:p.value.has(t.path),onChange:e=>Ie(t.path)},null,40,_S),z(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,vS),z(`span`,{class:`path`,title:t.path},D(t.path),9,yS),Ve(t)?(I(),L(`span`,{key:0,class:E([`nums`,{bin:Ve(t)===`bin`}])},D(Ve(t)),3)):H(``,!0)]),z(`span`,bS,[z(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Je(t.path)},[B(A(hc),{size:13})],8,xS),t.x===`?`?(I(),L(`button`,{key:0,class:`icon-button`,title:`add to .gitignore`,onClick:e=>qe([t.path])},[B(A(Ys),{size:13})],8,SS)):(I(),L(`button`,{key:1,class:`icon-button`,title:`stage (git add)`,onClick:e=>We(`stage`,t.path)},[B(A(Xc),{size:13})],8,CS)),t.x===`?`?H(``,!0):(I(),L(`button`,{key:2,class:`icon-button`,title:`roll back to HEAD`,onClick:e=>We(`discard`,t.path)},[B(A(uc),{size:13})],8,wS)),z(`button`,{class:`icon-button`,title:`copy path`,onClick:e=>He(t.path)},[B(A(sc),{size:13})],8,TS)])])),[[Ro,e.open]])),128))],64))),128))])):H(``,!0),_.value?(I(),L(`p`,ES,[z(`strong`,null,D(_.value.path),1),z(`span`,DS,[z(`button`,{class:E({on:v.value===`working`}),onClick:t[22]||=e=>{v.value=`working`,Ye()}},`working`,2),z(`button`,{class:E({on:v.value===`staged`}),onClick:t[23]||=e=>{v.value=`staged`,Ye()}},`staged`,2)]),Xe.value?(I(),L(`span`,OS,`binary file`)):_.value.text.length>8e3?(I(),L(`span`,kS,`truncated at 8000 chars`)):H(``,!0),z(`button`,{class:`icon-button`,title:`close diff`,onClick:t[24]||=e=>_.value=null},[B(A(xl),{size:13})]),Xe.value?H(``,!0):(I(),L(`pre`,AS,D(_.value.text.slice(0,8e3)),1))])):H(``,!0),j(z(`textarea`,{"onUpdate:modelValue":t[25]||=e=>f.value=e,rows:`4`,placeholder:`Commit message… (Ctrl+Enter to commit)`,onKeydown:[t[26]||=js(ks(e=>et(),[`exact`,`prevent`]),[`enter`]),t[27]||=js(ks(e=>et(),[`meta`,`prevent`]),[`enter`]),t[28]||=js(ks(e=>et(),[`ctrl`,`prevent`]),[`enter`])]},null,544),[[ys,f.value]]),z(`div`,jS,[z(`button`,{class:`small`,disabled:!!u.value||!p.value.size,title:`ask the device's model for a message`,onClick:nt},[B(A(ll),{size:14}),t[56]||=V(` ai message`,-1)],8,MS),t[58]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`primary small`,disabled:!!u.value||!f.value.trim()||!Oe.value,onClick:t[29]||=e=>et(!1)},[B(A(tc),{size:14}),V(` Commit`+D(p.value.size?` ${p.value.size} file${p.value.size>1?`s`:``}`:``),1)],8,NS),a.value.upstream?(I(),L(`button`,{key:0,class:`primary small`,disabled:!!u.value||!f.value.trim()||!Oe.value,title:`commit, then push`,onClick:t[30]||=e=>et(!0)},[B(A(tc),{size:14}),t[57]||=V(` Commit & push `,-1)],8,PS)):H(``,!0)])]),z(`section`,FS,[z(`div`,IS,[z(`h4`,null,[B(A(Ec),{size:16}),t[59]||=V(` Log`,-1)]),t[61]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:!!u.value,title:`save a checkpoint ref of HEAD`,onClick:at},[B(A(_c),{size:13}),t[60]||=V(` checkpoint`,-1)],8,LS),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[31]||=e=>ae.value=!ae.value},`checkpoints `+D(ie.value.length?`(${ie.value.length})`:``),9,RS),z(`button`,{class:`icon-button`,disabled:ht.value,title:`refresh log`,onClick:t[32]||=e=>vt(!0)},[B(A($c),{size:14})],8,zS)]),ae.value?(I(),L(`div`,BS,[ie.value.length?H(``,!0):(I(),L(`p`,VS,`no checkpoints yet — one click saves a named ref of HEAD.`)),(I(!0),L(F,null,P(ie.value,e=>(I(),L(`div`,{key:e.name,class:`cp-row`},[z(`code`,null,D(e.name),1),z(`span`,HS,D(e.hash)+` · `+D(e.date),1),z(`span`,US,D(e.subject),1),t[63]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:!!u.value,title:`reset --hard to this checkpoint (this worktree)`,onClick:t=>st(e.name)},[B(A(hl),{size:13}),t[62]||=V(` rewind`,-1)],8,WS)]))),128))])):H(``,!0),ht.value&&!mt.value.length?(I(),L(`p`,GS,`loading log…`)):mt.value.length?(I(),L(`div`,KS,[(I(!0),L(F,null,P(mt.value,(e,t)=>(I(),L(F,{key:e.hash},[z(`div`,{class:`commit-row`,title:e.refs},[xt.value[t]?(I(),L(`svg`,{key:0,class:`lane`,width:xt.value[t].width*12+4,height:`24`,"aria-hidden":`true`},[(I(!0),L(F,null,P(xt.value[t].width,e=>(I(),L(`line`,{key:e,x1:St(e-1),x2:St(e-1),y1:`0`,y2:`24`,stroke:`#3a3134`,"stroke-width":`2`},null,8,YS))),128)),(I(!0),L(F,null,P(xt.value[t].parents,(e,n)=>(I(),L(`line`,{key:`p`+n,x1:St(xt.value[t].lane),x2:St(e),y1:`12`,y2:`24`,stroke:bt[e%bt.length],"stroke-width":`2`},null,8,XS))),128)),z(`circle`,{cx:St(xt.value[t].lane),cy:`12`,r:`4`,fill:bt[xt.value[t].lane%bt.length]},null,8,ZS)],8,JS)):H(``,!0),z(`button`,{class:`icon-button hash-btn`,title:`files in this commit`,onClick:t=>it(e.hash)},[B(A(rc),{size:12,class:E({open:oe.value.has(e.hash)})},null,8,[`class`])],8,QS),z(`code`,$S,[O.value?(I(),L(`a`,{key:0,href:`${O.value}/commit/${e.hash}`,target:`_blank`,rel:`noopener`,title:`on the remote`},D(e.hash),9,eC)):(I(),L(F,{key:1},[V(D(e.hash),1)],64))]),e.refs?(I(),L(`span`,tC,D(e.refs.split(`,`)[0]),1)):H(``,!0),z(`span`,nC,D(e.subject),1),z(`span`,rC,D(e.author)+` · `+D(e.date),1)],8,qS),oe.value.has(e.hash)?(I(),L(`div`,iC,[(I(!0),L(F,null,P(oe.value.get(e.hash),e=>(I(),L(`div`,{key:e.path,class:`cf`},[z(`code`,{class:`cf-status`,"data-s":e.status},D(e.status),9,aC),z(`span`,oC,D(e.path),1)]))),128)),oe.value.get(e.hash)?.length?H(``,!0):(I(),L(`p`,sC,`no files (merge/empty commit)`))])):H(``,!0)],64))),128))])):gt.value?(I(),L(`p`,cC,`log failed: `+D(gt.value),1)):(I(),L(`p`,lC,`no commits`))]),z(`section`,uC,[z(`div`,dC,[z(`h4`,null,[B(A(Hc),{size:16}),t[64]||=V(` Worktrees`,-1)]),z(`div`,fC,[z(`button`,{class:`small`,disabled:!!u.value,onClick:t[33]||=e=>h.value=!h.value},[B(A(Xc),{size:13}),t[65]||=V(` worktree`,-1)],8,pC),h.value?(I(),L(`div`,mC,[(I(!0),L(F,null,P((a.value.branches??[]).filter(e=>!e.current),e=>(I(),L(`button`,{key:e.name,onClick:t=>lt(e.name)},[B(A(xc),{size:13}),z(`span`,null,D(e.name),1),t[66]||=z(`span`,{class:`muted-line`},`existing`,-1)],8,hC))),128)),z(`div`,gC,[j(z(`input`,{"onUpdate:modelValue":t[34]||=e=>g.value=e,placeholder:`or a NEW branch…`,onKeyup:t[35]||=js(e=>g.value.trim()&&lt(g.value.trim()),[`enter`])},null,544),[[ys,g.value]]),z(`button`,{disabled:!g.value.trim(),onClick:t[36]||=e=>lt(g.value.trim())},`create`,8,_C)])])):H(``,!0)])]),(I(!0),L(F,null,P(yt.value,e=>(I(),L(`div`,{key:e.path,class:E([`wt`,{main:e.path===a.value.root}])},[z(`code`,{title:e.path},D(e.path),9,vC),z(`span`,yC,D(e.branch??e.head),1),t[67]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,disabled:!!u.value,title:`jump to this worktree (session or new)`,onClick:t=>dt(e.path)},[B(A(Gs),{size:13})],8,bC),z(`button`,{class:`small`,disabled:!!u.value,title:`create a session on this worktree`,onClick:t=>ut(e.path,e.branch)},`session`,8,xC),e.path===a.value.root?H(``,!0):(I(),L(`button`,{key:0,class:`icon-button`,disabled:!!u.value,onClick:t=>ft(e.path)},[B(A(xl),{size:13})],8,SC)),e.path===a.value.root?(I(),R(A(tc),{key:1,size:13,class:`muted-line`})):H(``,!0)],2))),128))]),de.value?(I(),L(`section`,CC,[z(`div`,wC,[z(`h4`,null,[B(A(wc),{size:16}),t[68]||=V(` Pull requests`,-1)]),t[69]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:ue.value||!!u.value,onClick:pe},`create PR`,8,TC),z(`button`,{class:`small`,disabled:ue.value,onClick:t[37]||=e=>ce.value=!ce.value},D(ce.value?`hide`:`list`),9,EC)]),ce.value&&!se.value.length&&!ue.value?(I(),L(`p`,DC,`no open PRs (or gh is not logged in on the device — every action will say so).`)):H(``,!0),ce.value?(I(),L(`div`,OC,[(I(!0),L(F,null,P(se.value,e=>(I(),L(`div`,{key:e.n,class:`pr-row`},[z(`code`,kC,`#`+D(e.n),1),z(`span`,{class:E([`tag`,{open:e.state===`OPEN`}])},D(e.state.toLowerCase())+D(e.draft?` · draft`:``),3),z(`span`,AC,D(e.title),1),z(`span`,jC,D(e.branch),1),t[70]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,title:`run checks`,disabled:ue.value,onClick:t=>he(e.n)},[B(A($c),{size:13})],8,MC),z(`button`,{class:`icon-button`,title:`comment`,disabled:ue.value,onClick:t=>ve(e.n)},[B(A(sc),{size:13})],8,NC),e.state===`OPEN`?(I(),L(`button`,{key:0,class:`small`,disabled:ue.value||!!u.value,onClick:t=>ge(e.n)},`squash & merge`,8,PC)):H(``,!0),z(`a`,{class:`icon-button`,href:e.url,target:`_blank`,rel:`noopener`,title:`open on the forge`},[B(A(Ks),{size:13,style:{transform:`rotate(45deg)`}})],8,FC)]))),128)),(I(!0),L(F,null,P(le.value,([e,t])=>(I(),L(`pre`,{key:e,class:`pr-checks`},`#`+D(e)+` checks:`+D(`
79
- `)+D(t),1))),128))])):H(``,!0)])):H(``,!0),d.value?(I(),L(`pre`,IC,D(d.value.slice(0,6e3)),1)):H(``,!0)],64)):(I(),L(`p`,$b,[...t[41]||=[V(`Not a git repository — run `,-1),z(`code`,null,`git init`,-1),V(` (or open a session inside a repo).`,-1)]]))],2)):H(``,!0),T.value?(I(),L(`div`,{key:4,class:`modal-veil`,onClick:t[40]||=ks(e=>T.value=null,[`self`])},[z(`div`,{class:E([`modal`,{danger:T.value.danger}]),role:`dialog`,"aria-modal":`true`},[z(`h5`,null,D(T.value.title),1),z(`p`,null,D(T.value.body),1),T.value.input?j((I(),L(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>te.value=e,rows:`2`,placeholder:T.value.input.placeholder},null,8,LC)),[[ys,te.value]]):H(``,!0),z(`div`,RC,[t[72]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,onClick:t[39]||=e=>T.value=null},[...t[71]||=[V(`cancel `,-1),z(`span`,{class:`muted-line`},`(esc)`,-1)]]),z(`button`,{class:E([`primary small`,{danger:T.value.danger}]),disabled:!(!T.value.input||te.value.trim()),onClick:re},D(T.value.confirmLabel??`confirm`),11,zC)])],2)])):H(``,!0)],64)):(I(),L(`p`,Yb,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-6598e11c`]]),VC={class:`host-panel`,"aria-label":`Device vitals`},HC={class:`panel-heading`},UC=[`disabled`],WC={key:0,class:`hint`},GC={key:1,class:`message-error`},KC={key:2,class:`hint`},qC={class:`vitals-grid`},JC={class:`vital`},YC={class:`vital`},XC={key:0,class:`vital`},ZC={class:`vital`},QC={class:`vital`},$C={class:`meter`},ew={class:`meter-head`},tw={class:`hint`},nw=[`aria-valuenow`],rw={class:`meter`},iw={class:`meter-head`},aw={class:`hint`},ow=[`aria-valuenow`],sw={class:`path`},cw={class:`hint`},lw=Vd(N({__name:`HostPanel`,setup(e){let t=k(),n=k(!1),r=k(``),i=U(()=>q.value?.deviceId),a=U(()=>Cu.devices.value.find(e=>e.id===i.value)?.info?.keepAwake),o=e=>{if(!Number.isFinite(e)||e<=0)return`0`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=100||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`},s=e=>{let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`},c=(e,t)=>t>0?Math.max(0,Math.min(100,Math.round(e/t*100))):0,l=U(()=>t.value?c(t.value.memory.usedBytes,t.value.memory.totalBytes):0),u=U(()=>t.value?.disk.known?c(t.value.disk.totalBytes-t.value.disk.freeBytes,t.value.disk.totalBytes):0);async function d(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).vitals()}catch(e){r.value=K(e).slice(0,160)}finally{n.value=!1}}}M(i,d,{immediate:!0});async function f(){await d(),r.value||Y(`Vitals refreshed.`)}return(e,c)=>(I(),L(`section`,VC,[z(`header`,HC,[z(`span`,null,[B(A(il),{size:16}),c[0]||=V(`HOST`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:f},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,UC)]),i.value?r.value?(I(),L(`p`,GC,D(r.value),1)):t.value?(I(),L(F,{key:3},[z(`div`,qC,[z(`div`,JC,[c[1]||=z(`span`,{class:`label`},`Host uptime`,-1),z(`strong`,null,D(s(t.value.uptime)),1)]),z(`div`,YC,[c[2]||=z(`span`,{class:`label`},`Device process`,-1),z(`strong`,null,D(s(t.value.processUptime)),1),z(`em`,null,`pid `+D(t.value.pid),1)]),a.value?(I(),L(`div`,XC,[c[3]||=z(`span`,{class:`label`},`Keep-awake`,-1),z(`strong`,null,D(a.value===`none`?`off`:a.value),1),z(`em`,null,D(a.value===`none`?`no inhibitor here`:`held while sessions run`),1)])):H(``,!0),z(`div`,ZC,[c[4]||=z(`span`,{class:`label`},`Load (1/5/15m)`,-1),z(`strong`,null,D(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),z(`em`,null,D(t.value.cpuCount)+` CPU`+D(t.value.cpuCount===1?``:`s`),1)]),z(`div`,QC,[c[5]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(t.value.counts?.sessions??0),1),z(`em`,null,D(t.value.counts?.archived??0)+` archived`,1)])]),z(`div`,$C,[z(`div`,ew,[c[6]||=z(`span`,{class:`label`},`Memory`,-1),z(`span`,tw,D(o(t.value.memory.usedBytes))+` / `+D(o(t.value.memory.totalBytes))+` · device `+D(o(t.value.memory.processRssBytes)),1)]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[z(`i`,{style:ge({width:`${l.value}%`}),class:E({high:l.value>=90})},null,6)],8,nw)]),z(`div`,rw,[z(`div`,iw,[c[7]||=z(`span`,{class:`label`},`Disk · data dir`,-1),z(`span`,aw,[t.value.disk.known?(I(),L(F,{key:0},[V(D(o(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+D(o(t.value.disk.freeBytes))+` free `,1)],64)):(I(),L(F,{key:1},[V(`unknown on this volume`)],64))])]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":u.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[z(`i`,{style:ge({width:`${u.value}%`}),class:E({high:u.value>=90})},null,6)],8,ow),z(`code`,sw,D(t.value.disk.path),1)]),z(`p`,cw,[B(A(Vs),{size:13}),c[8]||=V(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(I(),L(`p`,KC,D(n.value?`Reading host…`:`No vitals.`),1)):(I(),L(`p`,WC,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-ef6f9dc5`]]);function uw(e){let t=K(e);return e.code===`not_found`||/allowlist|not found/i.test(t)}function dw(e,t){let n=Cu.devices.value.find(t=>t.id===e),r=n?.name||`This device`,i=n?.info;return i&&!i.packageVersion&&i.durableVersion?`${r} runs the pre-rename build (durable ${i.durableVersion}) — ${t} needs the new one. On that machine: npm i -g my-durable@latest, then dpi device stop && dpi device start.`:`${r} runs an older build — ${t}. Update it on that machine (\`dpi update\`).`}var fw={class:`usage-panel`,"aria-label":`Device usage`},pw={class:`panel-heading`},mw=[`disabled`],hw={key:0,class:`hint`},gw={key:1,class:`message-error`},_w={key:2,class:`hint`},vw={key:3,class:`hint`},yw={class:`usage-block`,"aria-labelledby":`usage-totals`},bw={class:`totals`},xw={class:`total`},Sw={class:`total`},Cw={class:`total`},ww={class:`total`},Tw={class:`usage-block`,"aria-labelledby":`usage-models`},Ew={class:`section-label block-label`},Dw={class:`table-scroll`},Ow={class:`usage-table`,"aria-label":`Usage by model`},kw=[`title`],Aw={class:`num`},jw={class:`num`},Mw={class:`share-col`},Nw={class:`share`},Pw=[`aria-valuenow`,`aria-label`],Fw={class:`pct`},Iw={class:`usage-block`,"aria-labelledby":`usage-projects`},Lw={class:`section-label block-label`},Rw={key:0,class:`hint`},zw={key:1,class:`rows`},Bw=[`title`],Vw={class:`row-main`},Hw={class:`row-num`},Uw={class:`row-num`},Ww={class:`row-meta`},Gw={class:`usage-block`,"aria-labelledby":`usage-sessions`},Kw={key:0,class:`hint`},qw={key:1,class:`rows scroll`},Jw=[`title`],Yw={class:`row-main`},Xw={class:`row-num`},Zw={class:`row-num`},Qw={class:`row-meta`},$w={class:`hint`},eT=Vd(N({__name:`UsagePanel`,setup(e){let t=k(),n=k(!1),r=k(``),i=U(()=>q.value?.deviceId),a=e=>Math.round(e||0).toLocaleString(`en-US`),o=e=>{let t=e||0;return t===0?`$0.0000`:t<1e-4?`$${t.toPrecision(2)}`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`},s=U(()=>(t.value?.models??[]).reduce((e,t)=>Math.max(e,t.cost||0),0)),c=e=>s.value>0?Math.max(0,Math.min(100,Math.round((e||0)/s.value*100))):0,l=U(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=U(()=>t.value?new Date(t.value.at).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`}):``),d=(e,t)=>`${a(e)} ${t}${e===1?``:`s`}`;async function f(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).deviceUsage()}catch(e){r.value=uw(e)?dw(i.value,`usage`):K(e).slice(0,220)}finally{n.value=!1}}}M(i,f,{immediate:!0});async function p(){await f(),r.value||Y(`Usage refreshed.`)}return(e,s)=>(I(),L(`section`,fw,[z(`header`,pw,[z(`span`,null,[B(A(Vs),{size:16}),s[0]||=V(`USAGE`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,mw)]),i.value?r.value?(I(),L(`p`,gw,D(r.value),1)):t.value?l.value?(I(),L(`p`,vw,`No usage recorded yet.`)):(I(),L(F,{key:4},[z(`section`,yw,[s[6]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-totals`},`TOTALS`)],-1),z(`div`,bw,[z(`div`,xw,[s[1]||=z(`span`,{class:`label`},`Tokens`,-1),z(`strong`,null,D(a(t.value.totals.tokens)),1)]),z(`div`,Sw,[s[2]||=z(`span`,{class:`label`},`Cost`,-1),z(`strong`,null,D(o(t.value.totals.cost)),1)]),z(`div`,Cw,[s[3]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(a(t.value.sessions.length)),1),z(`em`,null,D(a(t.value.projects.length))+` projects`,1)]),z(`div`,ww,[s[4]||=z(`span`,{class:`label`},`Models`,-1),z(`strong`,null,D(a(t.value.models.length)),1),s[5]||=z(`em`,null,`costliest first`,-1)])])]),z(`section`,Tw,[z(`div`,Ew,[s[7]||=z(`span`,{id:`usage-models`},`BY MODEL`,-1),B(A(dc),{size:13})]),z(`div`,Dw,[z(`table`,Ow,[s[8]||=z(`colgroup`,null,[z(`col`),z(`col`),z(`col`),z(`col`)],-1),s[9]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Model`),z(`th`,{scope:`col`,class:`num`},`Tokens`),z(`th`,{scope:`col`,class:`num`},`Cost`),z(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(t.value.models,e=>(I(),L(`tr`,{key:e.key},[z(`th`,{scope:`row`,class:`model-key`,title:`${e.key} — in ${e.input} · out ${e.output} · cache read ${e.cacheRead} · cache write ${e.cacheWrite}`},D(e.key),9,kw),z(`td`,Aw,D(a(e.tokens)),1),z(`td`,jw,D(o(e.cost)),1),z(`td`,Mw,[z(`div`,Nw,[z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":c(e.cost),"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`${e.key} share of the costliest model`},[z(`i`,{style:ge({width:`${c(e.cost)}%`}),class:E({high:c(e.cost)>90})},null,6)],8,Pw),z(`em`,Fw,D(c(e.cost))+`%`,1)])])]))),128))])])])]),z(`section`,Iw,[z(`div`,Lw,[s[10]||=z(`span`,{id:`usage-projects`},`BY PROJECT`,-1),B(A(vc),{size:13})]),t.value.projects.length?(I(),L(`ul`,zw,[(I(!0),L(F,null,P(t.value.projects,e=>(I(),L(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[z(`span`,Vw,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.rootPath),1)]),z(`span`,Hw,D(a(e.tokens))+` tok`,1),z(`span`,Uw,D(o(e.cost)),1),z(`span`,Ww,D(d(e.sessions,`session`)),1)],8,Bw))),128))])):(I(),L(`p`,Rw,`No project usage recorded yet.`))]),z(`section`,Gw,[s[11]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(I(),L(`ul`,qw,[(I(!0),L(F,null,P(t.value.sessions,e=>(I(),L(`li`,{key:e.id,class:`row`,title:e.cwd},[z(`span`,Yw,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.project??e.cwd),1)]),z(`span`,Xw,D(a(e.tokens))+` tok`,1),z(`span`,Zw,D(o(e.cost)),1),z(`span`,Qw,D(d(e.agents,`agent`)),1)],8,Jw))),128))])):(I(),L(`p`,Kw,`No session usage recorded yet.`))]),z(`p`,$w,[B(A(Vs),{size:13}),V(` Read on demand — open this tab or press refresh (`+D(u.value)+`). Nothing polls the device. `,1)])],64)):(I(),L(`p`,_w,D(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(I(),L(`p`,hw,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-7a8f5c75`]]),tT={class:`schedules-panel`,"aria-label":`Scheduled sessions`},nT={class:`panel-heading`},rT=[`disabled`],iT=[`disabled`],aT={key:0,class:`hint`},oT={key:1,class:`message-error`},sT=[`disabled`],cT={key:0,value:``},lT={key:1,value:``},uT=[`value`],dT={class:`trigger-row`},fT={class:`inline`},pT=[`disabled`],mT={class:`inline`},hT=[`disabled`],gT={class:`row`},_T=[`disabled`],vT={key:3,class:`hint`},yT={key:4,class:`schedule-list`},bT={class:`head`},xT={class:`tag`},ST={key:0,class:`tag running`},CT=[`title`],wT={class:`next`},TT={class:`cwd`},ET={key:0,class:`message-error`},DT={class:`row`},OT=[`disabled`,`onClick`],kT=[`disabled`,`onClick`],AT=[`disabled`,`onClick`],jT=Vd(N({__name:`SchedulesPanel`,setup(e){let t=k([]),n=k(``),r=k(``),i=k(!1),a=U(()=>q.value?.deviceId),o=()=>G(a.value??``),s=k(`60`),c=k(``),l=k(!1),u=k({name:``,cwd:``,prompt:``,model:``});async function d(){if(!a.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await o().schedules()).schedules}catch(e){r.value=uw(e)?dw(a.value,`schedules`):K(e).slice(0,220)}finally{i.value=!1}}M(a,d,{immediate:!0});let f=e=>{if(!e)return`—`;let t=e-Date.now(),n=Math.round(Math.abs(t)/6e4),r=n<60?`${n}m`:n<1440?`${Math.round(n/60)}h`:`${Math.round(n/1440)}d`;return t>=0?`in ${r}`:`${r} ago`},p=e=>e.everyMinutes?`every ${e.everyMinutes}m`:`daily ${e.dailyAt}`;async function m(e,t,r){n.value=e;try{await t(),await d(),Y(r)}catch(e){Y(K(e).slice(0,140))}finally{n.value=``}}let h=e=>m(e.id,()=>o().updateSchedule(e.id,{enabled:!e.enabled}),e.enabled?`Schedule paused.`:`Schedule resumed.`),g=e=>m(e.id,()=>o().runSchedule(e.id),`${e.name}: run finished.`),_=e=>J.dialog={kind:`prompt`,title:`Remove ${e.name}?`,hint:`The schedule stops being run. Sessions it already created are untouched.`,submit:`Remove schedule`,danger:!0,run:()=>m(e.id,()=>o().removeSchedule(e.id),`Schedule removed.`)},v=k([]),y=k(!1);async function b(){l.value=!0,u.value={name:``,cwd:``,prompt:``,model:``},v.value=[],y.value=!0;try{let e=await o().device();v.value=e.models.map(e=>({key:`${e.provider}/${e.id}`})),u.value.model=e.defaultModel}catch{v.value=[]}finally{y.value=!1}}async function x(){let e=u.value,[t,...r]=e.model.split(`/`),i=r.join(`/`);if(e.name.trim()&&e.cwd.trim()&&e.prompt.trim()){if(!t||!i){Y(y.value?`Still loading the model list — one moment.`:`Pick a model first.`);return}n.value=`new`;try{await o().createSchedule({name:e.name.trim(),cwd:e.cwd.trim(),prompt:e.prompt,model:{provider:t,modelId:i},...c.value.trim()?{dailyAt:c.value.trim()}:{everyMinutes:Number(s.value)||60}}),l.value=!1,await d(),Y(`Schedule created. The device runs it on its own clock.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(I(),L(`section`,tT,[z(`header`,nT,[z(`span`,null,[B(A(ec),{size:16}),o[7]||=V(`SCHEDULES`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[B(A($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,rT),z(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:b},[B(A(Xc),{size:15})],8,iT)]),o[18]||=z(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(I(),L(`p`,oT,D(r.value),1)):H(``,!0):(I(),L(`p`,aT,`Select a session to see its device.`)),l.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(x,[`prevent`])},[z(`label`,null,[o[8]||=V(`Name`,-1),j(z(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[ys,u.value.name]])]),z(`label`,null,[o[9]||=V(`Directory`,-1),j(z(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[ys,u.value.cwd]])]),z(`label`,null,[o[10]||=V(`Prompt`,-1),j(z(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[ys,u.value.prompt]])]),z(`label`,null,[o[11]||=V(`Model `,-1),j(z(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e,disabled:y.value},[y.value?(I(),L(`option`,cT,`loading…`)):v.value.length?H(``,!0):(I(),L(`option`,lT,`(no models — check the device)`)),(I(!0),L(F,null,P(v.value,e=>(I(),L(`option`,{key:e.key,value:e.key},D(e.key),9,uT))),128))],8,sT),[[Ss,u.value.model]])]),z(`div`,dT,[z(`label`,fT,[o[12]||=V(`Every `,-1),j(z(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,pT),[[ys,s.value]]),o[13]||=V(` min`,-1)]),o[15]||=z(`span`,{class:`muted`},`or`,-1),z(`label`,mT,[o[14]||=V(`daily at `,-1),j(z(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,hT),[[ys,c.value]])])]),z(`div`,gT,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`||y.value||!u.value.model},D(n.value===`new`?`creating…`:y.value?`loading models…`:`Create schedule`),9,_T),z(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):H(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(I(),L(`p`,vT,D(i.value?`Reading schedules…`:`No schedules yet. Press + to add one.`),1)):H(``,!0),t.value.length?(I(),L(`ul`,yT,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`schedule`,{off:!e.enabled}])},[z(`div`,bT,[z(`b`,null,D(e.name),1),z(`span`,xT,D(p(e)),1),e.running?(I(),L(`span`,ST,`running`)):e.lastOutcome===`failed`?(I(),L(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,CT)):H(``,!0),z(`span`,wT,D(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),z(`code`,TT,D(e.cwd),1),e.lastError?(I(),L(`p`,ET,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,DT,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[B(A(Yc),{size:12}),o[16]||=V(`run now`,-1)],8,OT),z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[B(A(Zc),{size:12}),V(D(e.enabled?`pause`:`resume`),1)],8,kT),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[B(A(ml),{size:12}),o[17]||=V(`remove`,-1)],8,AT)])],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-c6d93e71`]]),MT={class:`archive-panel`,"aria-label":`Old sessions`},NT={class:`panel-heading`},PT=[`disabled`],FT={key:0,class:`hint`},IT={key:1,class:`message-error`},LT={key:2,class:`hint`},RT={key:3,class:`old-list`},zT={class:`head`},BT=[`title`],VT={class:`meta`},HT=[`aria-label`,`onClick`],UT=[`aria-label`,`onClick`],WT={class:`facts`},GT={key:0,class:`cwd`},KT={key:1,class:`tag`},qT={class:`meta`},JT={class:`meta`},YT={key:2,class:`meta`},XT=Vd(N({__name:`ArchivePanel`,setup(e){let t=k(null),n=k(!1),r=k(``),i=U(()=>q.value?.deviceId),a=()=>G(i.value??``);async function o(){if(!i.value)return void(t.value=null);n.value=!0,r.value=``;try{t.value=(await a().archived()).sessions}catch(e){r.value=uw(e)?dw(i.value,`browsing old sessions`):K(e).slice(0,220)}finally{n.value=!1}}M(i,o,{immediate:!0});let s=e=>{if(e<=0)return`0`;let t=[`B`,`KiB`,`MiB`,`GiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=100||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`},c=e=>{let t=Math.max(0,(Date.now()-e)/1e3);return t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`};function l(e){J.dialog={kind:`prompt`,title:`Restore “${e.name}”?`,hint:`The session returns to the live list with its transcript and jobs intact. Nothing is copied — the bundle simply moves back.`,submit:`Restore`,run:async()=>{await a().restoreArchived(e.sessionId),await o(),Y(`${e.name} restored to the live list.`)}}}async function u(e){try{let t=await a().archivedTranscript(e.sessionId,`markdown`),n=new Blob([t.text??``],{type:`text/markdown`}),r=document.createElement(`a`);r.href=URL.createObjectURL(n),r.download=`${e.name.replace(/[^\w.-]+/g,`_`)||e.sessionId}.md`,r.click(),URL.revokeObjectURL(r.href)}catch(e){Y(K(e).slice(0,160))}}return(e,a)=>(I(),L(`section`,MT,[z(`header`,NT,[z(`span`,null,[B(A(Us),{size:16}),a[0]||=V(`ARCHIVE`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh archive`,title:`Refresh archive`,onClick:o},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,PT)]),a[2]||=z(`p`,{class:`hint`},` Every session this device ever archived — read-only. Restore brings one back to the live list; nothing here deletes. `,-1),i.value?r.value?(I(),L(`p`,IT,D(r.value),1)):t.value&&!t.value.length?(I(),L(`p`,LT,`Nothing archived on this device yet.`)):H(``,!0):(I(),L(`p`,FT,`Select a session to see its device.`)),t.value?.length?(I(),L(`ul`,RT,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:`${e.sessionId}-${e.archivedAt}`,class:`old`},[z(`div`,zT,[z(`b`,null,D(e.name),1),z(`span`,{class:`tag`,title:e.hasManifest?`bundled with full identity`:`old bundle — name unknown`},D(e.hasManifest?`manifest`:`legacy`),9,BT),z(`span`,VT,`archived `+D(c(e.archivedAt)),1),a[1]||=z(`span`,{class:`spacer`},null,-1),z(`button`,{class:`icon-button`,"aria-label":`Download transcript of ${e.name}`,title:`Download transcript (markdown)`,onClick:t=>u(e)},[B(A(pc),{size:13})],8,HT),z(`button`,{class:`icon-button`,"aria-label":`Restore ${e.name}`,title:`Restore to the live list`,onClick:t=>l(e)},[B(A(tl),{size:13})],8,UT)]),z(`div`,WT,[e.cwd?(I(),L(`span`,GT,D(e.cwd),1)):H(``,!0),e.model?(I(),L(`span`,KT,D(e.model),1)):H(``,!0),z(`span`,qT,D(e.turns>=0?`${e.turns} turns`:`turns unknown`),1),z(`span`,JT,D(s(e.bytes)),1),e.lastMessageAt?(I(),L(`span`,YT,`last message `+D(c(e.lastMessageAt)),1)):H(``,!0)])]))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-054371cd`]]),ZT={class:`graph-panel`,"aria-label":`Task graphs`},QT={class:`panel-heading`},$T=[`disabled`],eE=[`disabled`],tE={key:0,class:`hint`},nE={key:1,class:`message-error`},rE={key:2,class:`hint`},iE={class:`row`},aE=[`disabled`],oE={class:`head`},sE=[`title`],cE=[`aria-label`,`disabled`,`onClick`],lE=[`aria-label`,`onClick`],uE={class:`tasks`},dE=[`title`],fE={key:0,class:`deps`},pE={class:`tag`},mE={key:1,class:`err`},hE=Vd(N({__name:`GraphPanel`,setup(e){let t=k([]),n=k({}),r=k(!1),i=k(``),a=k(``),o=k(!1),s=k(``),c=U(()=>q.value?.deviceId),l=()=>G(c.value??``);async function u(){if(!c.value)return void(t.value=[]);r.value=!0,i.value=``;try{let e=await l().graphs();t.value=e.graphs,n.value={}}catch(e){i.value=uw(e)?dw(c.value,`running task-graphs`):K(e).slice(0,220)}finally{r.value=!1}}M(c,u,{immediate:!0});let d={ok:`ok`,failed:`bad`,running:`run`,pending:``,skipped:`skip`};function f(e,t){return n.value[e.id]?.tasks[t]?.status??e.lastRun?.tasks[t]?.status??`pending`}async function p(e){try{let t=await l().graph(e.id);n.value={...n.value,[e.id]:t.runs[0]??e.lastRun},t.runs.length||Y(`This graph has not run yet.`)}catch(e){Y(K(e).slice(0,140))}}async function m(e){a.value=e.id;try{let{run:t}=await l().runGraph(e.id);n.value={...n.value,[e.id]:t},Y(`Run started: ${Object.keys(t.tasks).length} tasks.`),p(e)}catch(e){Y(K(e).slice(0,140))}finally{a.value=``}}function h(e){J.dialog={kind:`prompt`,title:`Remove the graph "${e.name}"?`,hint:`The registry record goes. Sessions the graph created are never touched.`,submit:`Remove graph`,danger:!0,run:async()=>{await l().removeGraph(e.id),await u()}}}async function g(){let e=s.value.trim();if(e){a.value=`new`;try{let t=JSON.parse(e),n=await l().createGraph({name:String(t.name??``),cwd:String(t.cwd??``),tasks:t.tasks});o.value=!1,s.value=``,Y(`Graph "${n.name}" added (${n.tasks.length} tasks).`),await u()}catch(e){Y(K(e).slice(0,200))}finally{a.value=``}}}return(e,l)=>(I(),L(`section`,ZT,[z(`header`,QT,[z(`span`,null,[B(A(gl),{size:16}),l[3]||=V(`DAG`,-1)]),z(`button`,{class:`icon-button`,disabled:r.value||!c.value,"aria-label":`Refresh graphs`,title:`Refresh`,onClick:u},[B(A($c),{size:15,class:E({spin:r.value})},null,8,[`class`])],8,$T),z(`button`,{class:`icon-button`,disabled:!c.value||!!i.value,"aria-label":`Add a graph`,title:`Add a graph from JSON`,onClick:l[0]||=e=>o.value=!o.value},[B(A(Xc),{size:15})],8,eE)]),l[7]||=z(`p`,{class:`hint`},`Tasks run on the device, in dependency order — one fresh session each.`,-1),c.value?i.value?(I(),L(`p`,nE,D(i.value),1)):!t.value.length&&!o.value?(I(),L(`p`,rE,` No graphs yet. Press + and paste a graph JSON ({ name, cwd, tasks: [{ id, name, prompt, dependsOn }] }). `)):H(``,!0):(I(),L(`p`,tE,`Select a session to see its device.`)),o.value?(I(),L(`form`,{key:3,class:`add-form`,onSubmit:ks(g,[`prevent`])},[z(`label`,null,[l[4]||=V(`Graph JSON `,-1),j(z(`textarea`,{"onUpdate:modelValue":l[1]||=e=>s.value=e,rows:`8`,placeholder:`{ "name": "nightly", "cwd": "~/work/app", "tasks": [{ "id": "build", "name": "Build", "prompt": "run the build", "dependsOn": [] }, { "id": "report", "name": "Report", "prompt": "summarise", "dependsOn": ["build"] }] }`},null,512),[[ys,s.value]])]),z(`div`,iE,[z(`button`,{class:`primary small`,type:`submit`,disabled:a.value===`new`},D(a.value===`new`?`adding…`:`Add graph`),9,aE),z(`button`,{class:`small`,type:`button`,onClick:l[2]||=e=>o.value=!1},`Cancel`)])],32)):H(``,!0),(I(!0),L(F,null,P(t.value,e=>(I(),L(`div`,{key:e.id,class:`graph`},[z(`div`,oE,[z(`b`,null,D(e.name),1),z(`code`,{class:`cwd`,title:e.cwd},D(e.cwd.split(`/`).filter(Boolean).at(-1)||e.cwd),9,sE),z(`span`,{class:E([`tag`,d[e.lastRun?.status??`pending`]??``])},D(e.lastRun?e.lastRun.status:`never run`),3),l[5]||=z(`span`,{class:`spacer`},null,-1),z(`button`,{class:`icon-button`,"aria-label":`Run ${e.name}`,title:`Run now`,disabled:a.value===e.id,onClick:t=>m(e)},[B(A(Yc),{size:14})],8,cE),z(`button`,{class:`icon-button`,"aria-label":`Remove ${e.name}`,title:`Remove graph`,onClick:t=>h(e)},[B(A(ml),{size:14})],8,lE)]),z(`ul`,uE,[(I(!0),L(F,null,P(e.tasks,t=>(I(),L(`li`,{key:t.id,class:E(d[f(e,t.id)])},[l[6]||=z(`span`,{class:`dot`,"aria-hidden":`true`},null,-1),z(`span`,{class:`name`,title:t.prompt},D(t.name),9,dE),t.dependsOn.length?(I(),L(`code`,fE,`← `+D(t.dependsOn.join(`, `)),1)):H(``,!0),z(`span`,pE,D(f(e,t.id)),1),n.value[e.id]?.tasks[t.id]?.error?(I(),L(`em`,mE,D(n.value[e.id].tasks[t.id].error.slice(0,120)),1)):H(``,!0)],2))),128))])]))),128))]))}}),[[`__scopeId`,`data-v-4acbb881`]]),gE={class:`notify-panel`,"aria-label":`Notification sinks`},_E={class:`panel-heading`},vE=[`disabled`],yE=[`disabled`],bE=[`disabled`],xE={key:0,class:`hint`},SE={key:1,class:`message-error`},CE=[`placeholder`],wE={class:`row`},TE=[`disabled`],EE={key:3,class:`hint`},DE={key:4,class:`sink-list`},OE={class:`head`},kE={class:`tag`},AE={class:`next`},jE={class:`url`},ME={key:0,class:`hint`},NE={key:1,class:`message-error`},PE={class:`row`},FE=[`disabled`,`onClick`],IE=[`disabled`,`onClick`],LE={key:5,class:`results`,"aria-label":`Test results`},RE={class:`tag`},zE={key:0},BE=Vd(N({__name:`NotifyPanel`,setup(e){let t=k([]),n=k(``),r=k(``),i=k(!1),a=k([]),o=U(()=>q.value?.deviceId),s=()=>G(o.value??``),c=k(!1),l=k({kind:`webhook`,url:``,label:``,events:``});async function u(){if(!o.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await s().notifySinks()).sinks}catch(e){r.value=uw(e)?dw(o.value,`notifications`):K(e).slice(0,220)}finally{i.value=!1}}M(o,u,{immediate:!0});let d=e=>{if(!e)return`never`;let t=Math.round((Date.now()-e)/6e4);return t<1?`just now`:t<60?`${t}m ago`:`${Math.round(t/60)}h ago`};async function f(){let e=l.value;if(e.url.trim()){n.value=`new`;try{await s().createNotifySink({kind:e.kind,url:e.url.trim(),...e.label.trim()?{label:e.label.trim()}:{},...e.events.trim()?{events:e.events.split(`,`).map(e=>e.trim()).filter(Boolean)}:{}}),c.value=!1,l.value={kind:`webhook`,url:``,label:``,events:``},await u(),Y(`Sink added on the device.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}}async function p(e){n.value=e.id;try{await s().updateNotifySink(e.id,{enabled:!e.enabled}),await u()}catch(e){Y(K(e).slice(0,140))}finally{n.value=``}}function m(e){J.dialog={kind:`prompt`,title:`Remove this ${e.kind} sink?`,hint:`The device stops notifying this target. Nothing else changes.`,submit:`Remove sink`,danger:!0,run:async()=>{await s().removeNotifySink(e.id),await u()}}}async function h(){n.value=`test`,a.value=[];try{a.value=(await s().testNotifySinks()).results;let e=a.value.filter(e=>e.status===`failed`).length;Y(a.value.length?`Test: ${a.value.length-e} sent${e?`, ${e} failed`:``}.`:`No enabled sinks matched — nothing was sent.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(I(),L(`section`,gE,[z(`header`,_E,[z(`span`,null,[B(A(Xs),{size:16}),s[6]||=V(`NOTIFY`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[B(A($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,vE),z(`button`,{class:`icon-button`,disabled:!o.value||!t.value.length||n.value===`test`,"aria-label":`Send a test notification`,title:`Send a test event through every enabled sink`,onClick:h},[B(A(rl),{size:15})],8,yE),z(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[B(A(Xc),{size:15})],8,bE)]),s[14]||=z(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(I(),L(`p`,SE,D(r.value),1)):H(``,!0):(I(),L(`p`,xE,`Select a session to see its device.`)),c.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(f,[`prevent`])},[z(`label`,null,[s[8]||=V(`Kind `,-1),j(z(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[z(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),z(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Ss,l.value.kind]])]),z(`label`,null,[s[9]||=V(`URL `,-1),j(z(`input`,{"onUpdate:modelValue":s[2]||=e=>l.value.url=e,placeholder:l.value.kind===`ntfy`?`https://ntfy.sh/my-topic`:`https://example.com/hook`,required:``},null,8,CE),[[ys,l.value.url]])]),z(`label`,null,[s[10]||=V(`Label`,-1),j(z(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[ys,l.value.label]])]),z(`label`,null,[s[11]||=V(`Events `,-1),j(z(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[ys,l.value.events]])]),z(`div`,wE,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`adding…`:`Add sink`),9,TE),z(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=z(`p`,{class:`hint`},[V(`LAN targets (192.168.x, localhost) need `),z(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),V(` on the device.`)],-1)],32)):H(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(I(),L(`p`,EE,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):H(``,!0),t.value.length?(I(),L(`ul`,DE,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`sink`,{off:!e.enabled}])},[z(`div`,OE,[z(`span`,kE,D(e.kind),1),z(`b`,null,D(e.label||e.url),1),z(`em`,AE,D(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),z(`code`,jE,D(e.url),1),e.events?.length?(I(),L(`p`,ME,`events: `+D(e.events.join(`, `)),1)):H(``,!0),e.lastError?(I(),L(`p`,NE,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,PE,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[B(A(Zc),{size:12}),V(D(e.enabled?`disable`:`enable`),1)],8,FE),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[B(A(ml),{size:12}),s[13]||=V(`remove`,-1)],8,IE)])],2))),128))])):H(``,!0),a.value.length?(I(),L(`ul`,LE,[(I(!0),L(F,null,P(a.value,e=>(I(),L(`li`,{key:e.id,class:E(e.status)},[z(`span`,RE,D(e.status),1),V(` `+D(e.kind)+` `+D(e.id.slice(0,8))+` `,1),e.detail?(I(),L(`em`,zE,D(e.detail),1)):H(``,!0)],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-6fa0ab18`]]),VE={class:`env-panel`,"aria-label":`Device environment`},HE={class:`panel-heading`},UE=[`disabled`],WE=[`disabled`],GE={key:0,class:`hint`},KE={key:1,class:`message-error`},qE={key:2,class:`message-restart`},JE={class:`row`},YE=[`disabled`],XE={key:4,class:`hint`},ZE={key:5,class:`var-list`},QE={class:`head`},$E={class:`key`},eD={class:`tag`},tD={key:0,class:`tag`,title:`Has its own setting; edit that instead`},nD=[`aria-label`,`title`,`onClick`],rD=[`aria-label`,`onClick`],iD=[`title`],aD={key:6,class:`hint path`},oD={class:`panel-heading keys-heading`},sD=[`disabled`],cD=[`disabled`],lD={key:7,class:`message-error`},uD={class:`row`},dD=[`disabled`],fD={key:9,class:`hint`},pD={key:10,class:`var-list`},mD={class:`head`},hD={class:`key`},gD={class:`tag`},_D={key:0,class:`tag`,title:`Set by pi /login — read-only here`},vD=[`aria-label`,`onClick`],yD={class:`value`,title:`write-only — masked tail`},bD=Vd(N({__name:`EnvPanel`,setup(e){let t=k(null),n=k(!1),r=k(``),i=k(``),a=U(()=>q.value?.deviceId),o=()=>G(a.value??``),s=k(!1),c=k({key:``,value:``});async function l(){if(!a.value)return void(t.value=null);n.value=!0,r.value=``;try{t.value=await o().envView()}catch(e){r.value=uw(e)?dw(a.value,`editing env vars`):K(e).slice(0,220)}finally{n.value=!1}m()}M(a,l,{immediate:!0});let u=k(null),d=k(``),f=k(!1),p=k({providerId:``,key:``});async function m(){if(!a.value)return void(u.value=null);try{u.value=await o().piAuth(),d.value=``}catch(e){K(e),d.value=uw(e)?dw(a.value,`managing pi keys`):K(e).slice(0,220)}}async function h(){let e=p.value.providerId.trim();if(e&&p.value.key){i.value=`pi-key`;try{let t=await o().setPiApiKey(e,p.value.key);p.value={providerId:``,key:``},f.value=!1,await m(),Y(`${e} saved (now ${t.masked}) — restart the device to apply it.`)}catch(e){Y(K(e).slice(0,160))}finally{i.value=``}}}function g(e){J.dialog={kind:`prompt`,title:`Remove the ${e} key?`,hint:`The entry is deleted from pi's auth.json. pi's own logins are never touched. Restart the device to apply.`,submit:`Remove`,danger:!0,run:async()=>{await o().removePiApiKey(e),await m(),Y(`${e} removed — restart the device to apply it.`)}}}let _=e=>e.source===`file`&&!e.managed;async function v(){let e=c.value.key.trim().toUpperCase();if(e&&c.value.value){i.value=`new`;try{await o().setEnvVar(e,c.value.value),s.value=!1,c.value={key:``,value:``},await l(),Y(`${e} saved — restart the device to apply it.`)}catch(e){Y(K(e).slice(0,160))}finally{i.value=``}}}function y(e){J.dialog={kind:`prompt`,title:`Set ${e.key}`,label:`Value`,hint:e.secret?`The current value is secret and stays masked. Type a new value to replace it.`:`Single line. Applies after the next device restart.`,value:e.secret?``:e.masked,placeholder:e.secret?e.masked:``,submit:`Save value`,run:async t=>{if(!t)throw Error(`A value is required`);await o().setEnvVar(e.key,t),await l(),Y(`${e.key} saved — restart the device to apply it.`)}}}function b(e){J.dialog={kind:`prompt`,title:`Remove ${e.key} from the env file?`,hint:`The line is deleted from the file. Restart the device to apply it.`,submit:`Remove`,danger:!0,run:async()=>{await o().removeEnvVar(e.key),await l(),Y(`${e.key} removed — restart the device to apply it.`)}}}return(e,o)=>(I(),L(`section`,VE,[z(`header`,HE,[z(`span`,null,[B(A(gc),{size:16}),o[8]||=V(`ENV`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,UE),z(`button`,{class:`icon-button`,disabled:!a.value||!!r.value,"aria-label":`Add an env var`,title:`Add an env var to the device's env file`,onClick:o[0]||=e=>s.value=!s.value},[B(A(Xc),{size:15})],8,WE)]),o[19]||=z(`p`,{class:`hint`},` The device's env file — loaded once at boot. Keys here reach the daemon and its sessions. `,-1),a.value?r.value?(I(),L(`p`,KE,D(r.value),1)):t.value?.restartRequired?(I(),L(`p`,qE,[...o[9]||=[V(` Changed since boot — restart the device (`,-1),z(`code`,null,`dpi device stop && dpi device start`,-1),V(`) to apply. `,-1)]])):H(``,!0):(I(),L(`p`,GE,`Select a session to see its device.`)),s.value?(I(),L(`form`,{key:3,class:`add-form`,onSubmit:ks(v,[`prevent`])},[z(`label`,null,[o[10]||=V(`Key (UPPER_SNAKE_CASE)`,-1),j(z(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[ys,c.value.key]])]),z(`label`,null,[o[11]||=V(`Value`,-1),j(z(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[ys,c.value.value]])]),z(`div`,JE,[z(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},D(i.value===`new`?`saving…`:`Save to env file`),9,YE),z(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[12]||=z(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):H(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(I(),L(`p`,XE,` No vars in the env file yet. `)):H(``,!0),t.value?.vars.length?(I(),L(`ul`,ZE,[(I(!0),L(F,null,P(t.value.vars,e=>(I(),L(`li`,{key:e.key,class:E([`var`,{ro:!_(e)}])},[z(`div`,QE,[z(`code`,$E,D(e.key),1),z(`span`,eD,D(e.source===`process`?`process`:`file`),1),e.managed?(I(),L(`span`,tD,`managed`)):H(``,!0),o[13]||=z(`span`,{class:`spacer`},null,-1),_(e)?(I(),L(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>y(e)},[B(A(qc),{size:13})],8,nD)):H(``,!0),_(e)?(I(),L(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>b(e)},[B(A(ml),{size:13})],8,rD)):H(``,!0)]),z(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},D(e.masked),9,iD)],2))),128))])):H(``,!0),t.value?(I(),L(`p`,aD,D(t.value.envFile),1)):H(``,!0),z(`header`,oD,[z(`span`,null,[B(A(kc),{size:16}),o[14]||=V(`PI KEYS`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh pi keys`,title:`Refresh`,onClick:m},[B(A($c),{size:15})],8,sD),z(`button`,{class:`icon-button`,disabled:!a.value||!!d.value,"aria-label":`Add a pi provider key`,title:`Add a provider key to pi's auth.json`,onClick:o[4]||=e=>f.value=!f.value},[B(A(Xc),{size:15})],8,cD)]),o[20]||=z(`p`,{class:`hint`},[V(` Provider keys in pi's own `),z(`code`,null,`auth.json`),V(` — write-only: values are never shown, pi's interactive logins (oauth) are never touched. `)],-1),d.value?(I(),L(`p`,lD,D(d.value),1)):H(``,!0),f.value?(I(),L(`form`,{key:8,class:`add-form`,onSubmit:ks(h,[`prevent`])},[z(`label`,null,[o[15]||=V(`Provider id`,-1),j(z(`input`,{"onUpdate:modelValue":o[5]||=e=>p.value.providerId=e,placeholder:`zai`,required:``},null,512),[[ys,p.value.providerId]])]),z(`label`,null,[o[16]||=V(`Key`,-1),j(z(`input`,{"onUpdate:modelValue":o[6]||=e=>p.value.key=e,type:`password`,autocomplete:`off`,placeholder:`paste the api key`,required:``},null,512),[[ys,p.value.key]])]),z(`div`,uD,[z(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`pi-key`},D(i.value===`pi-key`?`saving…`:`Save to auth.json`),9,dD),z(`button`,{class:`small`,type:`button`,onClick:o[7]||=e=>f.value=!1},`Cancel`)]),o[17]||=z(`p`,{class:`hint`},`Applies after the next device restart. Existing keys for other providers stay as they are.`,-1)],32)):H(``,!0),!f.value&&u.value&&!u.value.entries.length&&!d.value?(I(),L(`p`,fD,` No provider keys found. `)):H(``,!0),u.value?.entries.length?(I(),L(`ul`,pD,[(I(!0),L(F,null,P(u.value.entries,e=>(I(),L(`li`,{key:e.providerId,class:`var`},[z(`div`,mD,[z(`code`,hD,D(e.providerId),1),z(`span`,gD,D(e.source),1),e.type===`api_key`?H(``,!0):(I(),L(`span`,_D,D(e.type),1)),o[18]||=z(`span`,{class:`spacer`},null,-1),e.type===`api_key`?(I(),L(`button`,{key:1,class:`icon-button`,"aria-label":`Remove ${e.providerId} key`,title:`Remove from auth.json`,onClick:t=>g(e.providerId)},[B(A(ml),{size:13})],8,vD)):H(``,!0)]),z(`code`,yD,D(e.masked),1)]))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-d92de86a`]]),xD={class:`extensions-panel`},SD={class:`panel-heading`},CD={key:0,class:`task-empty`},wD=[`data-extension`],TD={class:`ext-head`},ED=[`aria-checked`,`aria-label`,`disabled`,`onClick`],DD=[`checked`,`disabled`,`onChange`],OD=N({__name:`ExtensionsPanel`,setup(e){let t=rn(),n=k(!1);async function r(){let e=Ru.value;if(!e||!Mu.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}M([Ru,Mu,()=>JSON.stringify(Ju.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=Ru.value;if(r&&!n.value){n.value=!0;try{let n=await ud(()=>r.setExtension(e));n&&(t.value=n),ad()}finally{n.value=!1}}}return(e,r)=>(I(),L(`div`,xD,[z(`div`,SD,[r[0]||=z(`h2`,null,`Extensions`,-1),B(A(Qc),{size:18})]),r[3]||=z(`p`,{class:`hint`},` Custom harness capabilities for this agent. Turn one on and the next request uses it. The choice is stored with the agent, so it survives restarts. `,-1),t.value?H(``,!0):(I(),L(`p`,CD,`Loading extensions…`)),(I(!0),L(F,null,P(t.value?.extensions??[],e=>(I(),L(`article`,{key:e.name,class:E([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[z(`div`,TD,[z(`div`,null,[z(`strong`,null,D(e.title),1),z(`code`,null,D(e.name),1)]),z(`button`,{class:E([`switch`,{on:e.enabled}]),role:`switch`,"aria-checked":e.enabled,"aria-label":e.title,disabled:n.value,onClick:t=>i({name:e.name,enabled:!e.enabled})},[...r[1]||=[z(`span`,null,null,-1)]],10,ED)]),z(`p`,null,D(e.description),1),e.prompts?(I(),L(`ul`,{key:0,class:E([`ext-prompts`,{off:!e.enabled}])},[(I(!0),L(F,null,P(e.prompts,e=>(I(),L(`li`,{key:e.id},[z(`label`,null,[z(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,DD),z(`code`,null,D(e.id),1)]),z(`span`,null,D(e.description),1),z(`details`,null,[r[2]||=z(`summary`,null,`View prompt`,-1),z(`pre`,null,D(e.text),1)])]))),128))],2)):H(``,!0)],10,wD))),128))]))}}),kD={class:`context-section`,"aria-labelledby":`context-title`},AD={class:`section-label`},jD={key:0,class:`hint`},MD={key:1,class:`hint`},ND={class:`context-numbers`},PD={class:`context-pct`},FD={key:0,class:`context-compacting`},ID=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],LD={class:`context-marker-label`},RD=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],zD={class:`context-marker-label`},BD={class:`hint context-hint`},VD={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},HD={class:`context-toggle`},UD=[`checked`],WD=512,GD=4096,KD=1024,qD=N({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=U(()=>nd.value?.contextWindow??0),r=U(()=>{let e=td.value;return e&&!nd.value?`${e.provider?`${e.provider} / `:``}${e.modelId}`:``}),i=U(()=>{let e=Ju.value.entries;for(let t=e.length-1;t>=0;t--){if(e[t].kind!==`pi.assistant`)continue;let n=e[t].model?.find(e=>e.role===`assistant`)?.usage;if(n)return n.totalTokens||n.input+n.output+n.cacheRead+n.cacheWrite}return 0}),a=U(()=>Ju.value.compactions.length>0),o=k(),s=U(()=>o.value??Iu.value?.compaction??gv(n.value));M(()=>JSON.stringify(Iu.value?.compaction),e=>{o.value&&e===JSON.stringify(o.value)&&(o.value=void 0)});let c=k(),l=U(()=>J.dialog?.kind===`compaction`),u=()=>void(J.dialog=void 0);Gr(()=>l.value&&u());let d=U(()=>c.value??_v(n.value,s.value)),f=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,p=U(()=>Math.round(100*i.value/(n.value||1))),m=e=>{let t=e/(n.value||1);return t<.35?`start`:t>.65?`end`:`center`},h=(e,t)=>Math.min(n.value-KD,Math.max((t??GD)+KD,e)),g=(e,t)=>Math.min(t-KD,Math.max(GD,e));function _(e,t){let n=d.value,r=Math.round(t/WD)*WD;c.value=e===`wait`?{auto:n.auto,wait:h(r,n.auto)}:{auto:g(r,n.wait),wait:n.wait}}async function v(e){let t=zu.value;if(!t)return;let n=await ud(()=>t.setCompaction(e));n&&(o.value=n),c.value=void 0}function y(){let e=c.value;e&&v({reserveTokens:n.value-e.wait,...e.auto===void 0?{}:{backgroundTokens:e.wait-e.auto}})}let b=k(),x;function S(e,t){x=e,t.currentTarget.setPointerCapture(t.pointerId)}function C(e){if(!x||!b.value)return;let t=b.value.getBoundingClientRect();_(x,(e.clientX-t.left)/t.width*n.value)}function ee(){x&&(x=void 0,y())}function w(e,t){let n=(t.shiftKey?8192:1024)*(t.key===`ArrowRight`||t.key===`ArrowUp`?1:t.key===`ArrowLeft`||t.key===`ArrowDown`?-1:0);if(!n)return;t.preventDefault();let r=d.value;_(e,(e===`auto`?r.auto??GD:r.wait)+n)}return(e,o)=>(I(),L(F,null,[z(`section`,kD,[z(`div`,AD,[o[7]||=z(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(I(),L(`button`,{key:0,class:`context-details-toggle`,onClick:o[0]||=e=>A(J).dialog={kind:`compaction`}},[B(A(Oc),{size:16}),o[6]||=V(`Details `,-1)])):H(``,!0)]),r.value?(I(),L(`div`,jD,D(r.value)+` — not in this device's catalog, so its context window is unknown here. `,1)):n.value?(I(),L(F,{key:2},[z(`div`,ND,[z(`strong`,null,D(t(i.value)),1),z(`span`,null,`of `+D(t(n.value))+` tokens`,1),z(`span`,PD,D(p.value)+`%`,1),a.value?(I(),L(`span`,FD,[...o[8]||=[z(`i`,null,null,-1),V(`Compacting`,-1)]])):H(``,!0)]),z(`div`,{ref_key:`bar`,ref:b,class:E([`context-bar`,{off:!s.value.enabled}]),onPointermove:C,onPointerup:ee,onPointercancel:ee},[z(`div`,{class:E([`context-fill`,{hot:d.value.auto!==void 0&&i.value>=d.value.auto}]),style:ge({width:f(i.value)})},null,6),z(`div`,{class:`context-reserve`,style:ge({left:f(d.value.wait)}),title:`Reserved for the answer`},null,4),d.value.auto===void 0?H(``,!0):(I(),L(`button`,{key:0,class:E([`context-marker auto`,`label-${m(d.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":GD,"aria-valuemax":d.value.wait-KD,"aria-valuenow":d.value.auto,"aria-valuetext":`${t(d.value.auto)} tokens`,style:ge({left:f(d.value.auto)}),onPointerdown:o[1]||=e=>S(`auto`,e),onKeydown:o[2]||=e=>w(`auto`,e),onKeyup:y,onBlur:y},[z(`span`,LD,`Auto-compact at `+D(t(d.value.auto)),1)],46,ID)),z(`button`,{class:E([`context-marker wait`,`label-${m(d.value.wait)}`]),role:`slider`,"aria-label":`The next request waits for a summary at`,"aria-valuemin":(d.value.auto??GD)+KD,"aria-valuemax":n.value-KD,"aria-valuenow":d.value.wait,"aria-valuetext":`${t(d.value.wait)} tokens, ${t(n.value-d.value.wait)} reserved`,style:ge({left:f(d.value.wait)}),onPointerdown:o[3]||=e=>S(`wait`,e),onKeydown:o[4]||=e=>w(`wait`,e),onKeyup:y,onBlur:y},[z(`span`,zD,`Reserve at `+D(t(d.value.wait)),1)],46,RD)],34),z(`p`,BD,[s.value.enabled?(I(),L(F,{key:0},[o[9]||=V(`Compacts in the background at `,-1),z(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[10]||=V(` and waits at `,-1),z(`strong`,null,D(t(d.value.wait)),1),o[11]||=V(`.`,-1)],64)):(I(),L(F,{key:1},[V(`Automatic compaction is off.`)],64))])],64)):(I(),L(`div`,MD,`Pick a model to see its context window.`))]),(I(),R(lr,{to:`body`},[l.value?(I(),L(`div`,{key:0,class:`modal-backdrop`,onClick:ks(u,[`self`])},[z(`section`,VD,[z(`header`,null,[o[12]||=z(`h2`,{id:`compaction-title`},`Context compaction`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:u},[B(A(xl),{size:18})])]),z(`p`,null,[o[13]||=V(` A summary starts in the background at `,-1),z(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[14]||=V(`. Above `,-1),z(`strong`,null,D(t(d.value.wait)),1),V(` the next request waits for it, keeping `+D(t(n.value-d.value.wait))+` free for the answer. Drag a marker on the bar to change either point. `,1)]),o[16]||=z(`p`,null,[V(`Older entries stay stored, and `),z(`code`,null,`search_history`),V(` still finds them.`)],-1),z(`label`,HD,[z(`input`,{type:`checkbox`,checked:s.value.enabled,onChange:o[5]||=e=>v({enabled:e.target.checked})},null,40,UD),o[15]||=V(` Automatic compaction `,-1)]),o[17]||=z(`p`,{class:`hint`},[V(` Applies to every agent in this session. `),z(`code`,null,`/compact`),V(` works either way. `)],-1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:u},`Close`)])])])):H(``,!0)]))],64))}}),JD=/^[A-Za-z_$][\w$]*$/,YD=e=>` `.repeat(e);function XD(e,t){let n=[],r=(e,t=`text`)=>n.push({text:e,kind:t});return r(`function`,`keyword`),r(` `),r(e,`function`),r(`(`,`punct`),r(`args`),r(`: `,`punct`),ZD(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function ZD(e,t,n){if(!e||typeof e!=`object`)return n(`unknown`,`type`);if(`const`in e)return eO(e.const,n);if(e.enum)return $D(e.enum.map(e=>({const:e})),t,n);if(e.anyOf??e.oneOf)return $D(e.anyOf??e.oneOf,t,n);if(Array.isArray(e.type))return $D(e.type.map(t=>({...e,type:t})),t,n);switch(e.type){case`string`:case`boolean`:case`null`:return n(e.type,`type`);case`number`:case`integer`:return n(`number`,`type`);case`array`:{let r=!!(e.items?.anyOf??e.items?.oneOf??e.items?.enum);return r&&n(`(`,`punct`),ZD(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return QD(e,t,n);default:return n(`unknown`,`type`)}}function QD(e,t,n){let r=Object.entries(e.properties??{});if(!r.length)return e.additionalProperties&&typeof e.additionalProperties==`object`?(n(`Record`,`type`),n(`<`,`punct`),n(`string`,`type`),n(`, `,`punct`),ZD(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
80
- `);for(let[e,a]of r){let r=tO(a);r&&n(`${YD(t+1)}${r}\n`,`comment`),n(YD(t+1)),n(JD.test(e)?e:JSON.stringify(e),`property`),n(i.has(e)?`: `:`?: `,`punct`),ZD(a,t+1,n),n(`;`,`punct`),n(`
81
- `)}n(YD(t)),n(`}`,`punct`)}function $D(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),ZD(e,t,n)})}function eO(e,t){if(typeof e==`string`)return t(JSON.stringify(e),`string`);if(typeof e==`number`)return t(String(e),`number`);t(String(e),`type`)}function tO(e){let t=[e.description,e.minimum===void 0?``:`@minimum ${e.minimum}`,e.maximum===void 0?``:`@maximum ${e.maximum}`,e.default===void 0?``:`@default ${JSON.stringify(e.default)}`].filter(Boolean);return t.length?`/** ${t.join(` `)} */`:``}function nO(e){let t=document.createElement(`a`);t.href=URL.createObjectURL(new Blob([e.bytes.slice()],{type:e.mime||`application/zip`})),t.download=e.filename,t.click(),URL.revokeObjectURL(t.href)}function rO(e,t={}){let n=t.fetchBundle??((e,t)=>G(e).exportSession(t)),r=t.download??nO,i=t.notify??(()=>{}),a=k(!1),o=k(``);async function s(){let{device:t,summary:s}=e.value;if(t&&s&&!a.value){a.value=!0,o.value=``;try{let e=await n(t.id,s.id);r(e),i(`Bundle downloaded (${Math.max(1,Math.round(e.bytes.length/1024))} KiB).`)}catch(e){o.value=`bundle export failed: ${K(e).slice(0,300)}`,i(o.value.slice(0,120))}finally{a.value=!1}}}return M(()=>e.value.summary?.id,()=>o.value=``),{exporting:a,error:o,run:s}}function iO(e){try{let t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!=`object`)throw Error(`App State must be a JSON object.`);return Oy({},{operation:`update`,path:``,value:t}),``}catch(e){return K(e)}}function aO(e,t){let n=k(``),r=k(``),i=k(0),a=k(),o=k(!1),s=k(``),c=U(()=>n.value!==r.value),l=U(()=>c.value&&a.value!==t.value),u=U(()=>c.value&&(l.value||e.value?.revision!==i.value));function d(){n.value=JSON.stringify(e.value?.value??{},null,2),r.value=n.value,i.value=e.value?.revision??0,a.value=t.value,s.value=``}function f(e,t){n.value=JSON.stringify(e,null,2),r.value=n.value,i.value=t,s.value=``}M(e,()=>!c.value&&d(),{immediate:!0}),M(t,()=>d());let p;return M(n,()=>{clearTimeout(p),p=setTimeout(()=>s.value=c.value?iO(n.value):``,250)}),{draft:n,dirty:c,conflict:u,deviceChanged:l,saving:o,problem:s,revision:i,reset:d,commit:f}}var oO={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},sO=[`title`],cO=[`aria-label`,`title`,`onClick`],lO={key:0,class:`count`},uO={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},dO=[`id`,`aria-selected`,`title`,`onClick`],fO={class:`tab-label`},pO={key:0,class:`count`},mO=[`title`],hO=[`aria-labelledby`],gO={class:`session-heading`},_O=[`disabled`],vO=[`disabled`],yO=[`title`],bO={class:`cwd-trail`,dir:`rtl`},xO={dir:`ltr`},SO={class:`session-status`},CO={key:0,class:`background-pill`},wO=[`title`],TO={key:0,class:`message-error`,role:`alert`},EO=[`disabled`],DO={class:`model-section`},OO=[`src`],kO={key:0,class:`hint model-provenance`},AO={class:`thinking-row`},jO=[`value`],MO={class:`stats-section`,"aria-labelledby":`stats-title`},NO={class:`metrics`},PO=[`title`],FO={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},IO={scope:`row`},LO={class:`usage-total`},RO={class:`panel-heading`},zO={class:`hint app-state-description`},BO=[`disabled`],VO={class:`state-json-actions`},HO={key:0,class:`hint`},UO=[`disabled`],WO=[`disabled`],GO={key:0,class:`message-error`,role:`alert`},KO={key:1,class:`message-error`,role:`alert`},qO={class:`panel-heading`},JO={class:`tag`},YO={class:`hook-card`},XO=[`aria-checked`],ZO={key:0,class:`tag tool-disabled`},QO={class:`tag`},$O=[`aria-label`],ek=Vd(N({__name:`Inspector`,setup(e){let t=U(()=>new Map(rd.value?.tools.map(e=>[e.name,XD(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:yc},{id:`git`,label:`Git`,icon:xc},{id:`host`,label:`Host`,icon:Vs},{id:`usage`,label:`Usage`,icon:Jc},{id:`auto`,label:`Auto`,icon:ec},{id:`archive`,label:`Archive`,icon:Us},{id:`dag`,label:`DAG`,icon:gl},{id:`notify`,label:`Notify`,icon:Xs},{id:`env`,label:`Env`,icon:gc},{id:`state`,label:`State`,icon:Qs},{id:`tasks`,label:`Tasks`,icon:Vs},{id:`tools`,label:`Tools`,icon:bl},{id:`extensions`,label:`Extend`,icon:Qc}],r=U(()=>[{label:`Input`,tokens:$u.value.input,cost:$u.value.inputCost},{label:`Output`,tokens:$u.value.output,cost:$u.value.outputCost},{label:`Cache read`,tokens:$u.value.cacheRead,cost:$u.value.cacheReadCost},{label:`Cache write`,tokens:$u.value.cacheWrite,cost:$u.value.cacheWriteCost}]),i=U(()=>Zu.value.filter(e=>e.background).length);function a(e,t){ud(async()=>{await Ru.value.configure(e),await ad(),t&&Y(t)})}async function o(){let e=ju.value,t=Iu.value;if(e&&t)try{let n=await G(e.id).agent(t.id,q.value?.agentId??1).transcript(`markdown`),r=new Blob([typeof n==`string`?n:JSON.stringify(n)],{type:`text/markdown`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=`${t.name.replace(/[^\w.-]+/g,`_`)||`session`}-${t.id.slice(0,8)}.md`,i.click(),URL.revokeObjectURL(i.href),Y(`Transcript downloaded.`)}catch(e){Y(`transcript download failed: ${K(e).slice(0,120)}`)}}let{exporting:s,error:c,run:l}=rO(U(()=>({device:ju.value,summary:Iu.value}))),u=k(!1);function d(){let e=ju.value,t=Iu.value;e&&t&&!u.value&&(J.dialog={kind:`prompt`,title:`Share this transcript publicly?`,hint:`Anyone with the link can read this session's transcripts. The link expires in 7 days and can be removed on the hub.`,submit:`Create share link`,run:async()=>{u.value=!0;try{let n=G(e.id),r=t.agents.length?t.agents:[{id:1,name:`main`}],i=[];for(let e of r){let r=await n.agent(t.id,e.id).transcript(`markdown`),a=typeof r==`string`?r:r.text??JSON.stringify(r,null,2);i.push({name:e.name||`agent ${e.id}`,markdown:a})}let a=await du.createShare({title:`${t.name} · ${e.name}`,agents:i}),o=`${location.origin}${a.url}`;await navigator.clipboard?.writeText(o).catch(()=>{}),Y(`Share link copied — expires ${a.expiresAt.slice(0,10)}.`)}catch(e){Y(`share failed: ${K(e).slice(0,140)}`)}finally{u.value=!1}}})}function f(){let e=zu.value;e&&(J.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:Iu.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let p=k({});M(ju,async e=>{if(p.value={},e)try{let{projects:t}=await G(e.id).projects(!0);p.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0});let m=U(()=>{let e=td.value;if(!e)return!1;let t=Iu.value?.cwd,n=Object.keys(p.value).filter(e=>t===e||(t??``).startsWith(`${e}/`)).sort((e,t)=>t.length-e.length),r=n.length?p.value[n[0]]:void 0,i=r?`${r.provider}/${r.modelId}`:ju.value?.info?.defaultModel??``;return!!i&&i===`${e.provider}/${e.modelId}`}),h=U(()=>td.value&&`model: ${td.value.modelId} (${td.value.provider})${m.value?` (default)`:``}`),g=Fu.sharedState,{draft:_,dirty:v,conflict:y,deviceChanged:b,problem:x,revision:S,reset:C,commit:ee}=aO(g,Au),w=k(!1),T=k(``);async function te(e){if(!w.value&&Ru.value){w.value=!0,T.value=``;try{await Ru.value.demo(`state`,e)}catch(e){T.value=K(e)}finally{w.value=!1}}}async function ne(){if(!(w.value||y.value||!Ru.value)){T.value=``,w.value=!0;try{let e=JSON.parse(_.value);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`App State must be a JSON object.`);let t=await Ru.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:S.value});ee(t.value,t.revision),Y(`Shared App State saved.`)}catch(e){T.value=K(e)}finally{w.value=!1}}}let re=U(()=>rd.value?.config.readOnly===!0),ie=U(()=>rd.value?.tools.filter(e=>e.offered).length??0);return(e,p)=>(I(),L(`aside`,{class:E([`inspector`,{collapsed:!A(bd),overlay:A(J).inspectorOverlay}])},[A(bd)?(I(),L(F,{key:1},[z(`div`,uO,[(I(),L(F,null,P(n,e=>z(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":A(J).tab===e.id,title:e.label,class:E({active:A(J).tab===e.id}),onClick:t=>A(J).tab=e.id},[(I(),R($r(e.icon),{size:18})),z(`span`,fO,D(e.label),1),e.id===`tasks`&&A(Zu).length?(I(),L(`span`,pO,D(A(Zu).length),1)):H(``,!0)],10,dO)),64)),z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${A(Ed).inspector})`,onClick:p[1]||=e=>A(Sd)()},[B(A(Uc),{size:18})],8,mO)]),z(`div`,{id:`inspector-panel`,class:E([`inspector-body`,{"session-panel":A(J).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${A(J).tab}`},[A(J).tab===`session`?(I(),L(F,{key:0},[z(`section`,gO,[z(`h1`,null,[z(`span`,null,D(A(Iu)?.name??`Loading session`),1),z(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:f},[B(A(qc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:o},[B(A(pc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:A(s),onClick:p[2]||=(...e)=>A(l)&&A(l)(...e)},[B(A(Hc),{size:18})],8,_O),z(`button`,{class:`icon-button`,title:`Share a public read-only link to this transcript`,"aria-label":`Share transcript`,disabled:u.value,onClick:d},[B(A(al),{size:18})],8,vO)]),z(`button`,{class:`path cwd-button`,title:A(Iu)?.cwd,"aria-label":`Show full working directory`,onClick:p[3]||=e=>A(J).dialog={kind:`path`,path:A(Iu)?.cwd??``}},[B(A(yc),{size:18}),z(`span`,bO,[z(`bdi`,xO,D(A(Iu)?.cwd),1)])],8,yO),z(`div`,SO,[z(`span`,{class:E([`status-pill`,{working:A(Qu)}])},[p[10]||=z(`i`,null,null,-1),V(D(A(Qu)?`Working`:`Idle`),1)],2),i.value?(I(),L(`span`,CO,D(i.value)+` background`,1)):H(``,!0),z(`span`,{class:`saved`,title:A(ju)?.id},[B(A(il),{size:18}),V(D(A(ju)?.name??A(ju)?.id),1)],8,wO),A(ju)?(I(),R($y,{key:1,device:A(ju)},null,8,[`device`])):H(``,!0)]),A(c)?(I(),L(`p`,TO,[V(D(A(c))+` `,1),z(`button`,{class:`small`,disabled:A(s),onClick:p[4]||=(...e)=>A(l)&&A(l)(...e)},` retry `,8,EO)])):H(``,!0)]),A(ju)?(I(),R(gb,{key:0,device:A(ju)},null,8,[`device`])):H(``,!0),z(`section`,DO,[p[18]||=z(`div`,{class:`section-label`},[z(`span`,null,`AGENT`)],-1),z(`button`,{class:`model-button`,onClick:p[5]||=e=>A(J).dialog={kind:`models`}},[z(`img`,{src:A(md)(A(Ju).agent.model?.modelId),alt:``},null,8,OO),z(`div`,null,[z(`strong`,null,D(A(ed)?.name??A(Ju).agent.model?.modelId??`Loading…`),1),z(`small`,null,D(A(ed)?.tier??``)+` / `+D(A(Ju).agent.model?.provider??``),1)]),B(A(nc),{size:18})]),h.value?(I(),L(`p`,kO,D(h.value),1)):H(``,!0),z(`div`,AO,[p[11]||=z(`span`,null,`Thinking`,-1),z(`select`,{"aria-label":`Thinking level`,value:A(Ju).agent.thinkingLevel??`medium`,onChange:p[6]||=e=>a({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(I(!0),L(F,null,P(A(pv),e=>(I(),L(`option`,{key:e},D(e),1))),128))],40,jO)]),B(qD),z(`section`,MO,[p[17]||=z(`div`,{class:`section-label`},[z(`span`,{id:`stats-title`},`STATS`)],-1),z(`div`,NO,[z(`div`,{title:`${A($u).tokens.toLocaleString(`en-US`)} total tokens`},[z(`span`,null,D(A(fd)(A($u).tokens)),1),p[12]||=z(`small`,null,`total tokens`,-1)],8,PO),z(`div`,null,[z(`span`,null,`$`+D(A($u).cost.toFixed(4)),1),p[13]||=z(`small`,null,`agent cost`,-1)]),z(`div`,null,[z(`span`,null,D(A(rd)?.tools.length??0),1),p[14]||=z(`small`,null,`tools`,-1)])]),z(`table`,FO,[p[16]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Type`),z(`th`,{scope:`col`},`Tokens`),z(`th`,{scope:`col`},`Cost (USD)`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(r.value,e=>(I(),L(`tr`,{key:e.label},[z(`th`,IO,D(e.label),1),z(`td`,null,D(e.tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(e.cost.toFixed(4)),1)]))),128)),z(`tr`,LO,[p[15]||=z(`th`,{scope:`row`},`Total`,-1),z(`td`,null,D(A($u).tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(A($u).cost.toFixed(4)),1)])])])])])],64)):H(``,!0),A(J).tab===`state`?(I(),L(F,{key:1},[z(`div`,RO,[p[19]||=z(`h2`,null,`App State`,-1),B(A(Qs),{size:18})]),z(`p`,zO,` One shared JSON object for every agent, session and fork on `+D(A(ju)?.name??A(ju)?.id)+`. You and your agents can read, create, update or delete values and fields. Changes appear live and persist across closed browsers, interrupted agents and backend restarts. `,1),j(z(`textarea`,{"onUpdate:modelValue":p[7]||=e=>nn(_)?_.value=e:null,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:w.value||!A(g),rows:`12`},null,8,BO),[[ys,A(_)]]),p[20]||=z(`p`,{class:`hint state-limits`},` One JSON object, at most 24 levels of nesting and 100,000 characters, checked as you type. `,-1),z(`div`,VO,[A(y)?(I(),L(`span`,HO,D(A(b)?`Device changed since this draft loaded. Load the latest JSON before saving.`:`State changed elsewhere. Load the latest JSON before saving.`),1)):H(``,!0),A(v)?(I(),L(`button`,{key:1,class:`secondary`,disabled:w.value,onClick:p[8]||=(...e)=>A(C)&&A(C)(...e)},D(A(y)?`Load latest`:`Reset`),9,UO)):H(``,!0),z(`button`,{class:`primary small`,disabled:!A(v)||w.value||A(y)||!!A(x),onClick:ne},D(w.value?`Saving…`:`Save JSON`),9,WO)]),A(x)?(I(),L(`p`,GO,D(A(x)),1)):H(``,!0),T.value?(I(),L(`p`,KO,D(T.value),1)):H(``,!0),B(qy,{value:A(g)?.value??{},disabled:w.value||A(v)||!A(g),onChange:te},null,8,[`value`,`disabled`])],64)):H(``,!0),A(J).tab===`tasks`?(I(),R(qb,{key:2})):H(``,!0),A(J).tab===`git`?(I(),R(BC,{key:3})):H(``,!0),A(J).tab===`host`?(I(),R(lw,{key:4})):H(``,!0),A(J).tab===`usage`?(I(),R(eT,{key:5})):H(``,!0),A(J).tab===`auto`?(I(),R(jT,{key:6})):H(``,!0),A(J).tab===`archive`?(I(),R(XT,{key:7})):H(``,!0),A(J).tab===`dag`?(I(),R(hE,{key:8})):H(``,!0),A(J).tab===`notify`?(I(),R(BE,{key:9})):H(``,!0),A(J).tab===`env`?(I(),R(bD,{key:10})):H(``,!0),A(J).tab===`extensions`?(I(),R(OD,{key:11})):H(``,!0),A(J).tab===`tools`?(I(),L(F,{key:12},[z(`div`,qO,[p[21]||=z(`h2`,null,`Tools`,-1),z(`span`,JO,D(ie.value)+` / `+D(A(rd)?.tools.length??0),1)]),p[25]||=z(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),z(`div`,YO,[z(`div`,null,[B(A(sl),{size:18}),p[23]||=z(`strong`,null,`Read only`,-1),z(`button`,{class:E([`switch`,{on:re.value}]),role:`switch`,"aria-checked":re.value,"aria-label":`Read only`,onClick:p[9]||=e=>a({readOnly:!re.value},re.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...p[22]||=[z(`span`,null,null,-1)]],10,XO)]),p[24]||=z(`p`,null,` Offers this agent only tools that read. Tools that create, update or delete leave its next request, and the choice is stored with the agent. `,-1)]),(I(!0),L(F,null,P(A(rd)?.tools,e=>(I(),L(`details`,{key:e.name,class:E([`tool-row`,{disabled:!e.offered}])},[z(`summary`,null,[B(A(bl),{size:18}),z(`strong`,null,D(e.name),1),e.offered?H(``,!0):(I(),L(`span`,ZO,`disabled`)),z(`span`,QO,D(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),z(`p`,null,D(e.description),1),e.parameters?(I(),L(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[z(`code`,null,[(I(!0),L(F,null,P(t.value.get(e.name),(e,t)=>(I(),L(`span`,{key:t,class:E(`tk-${e.kind}`)},D(e.text),3))),128))])],8,$O)):H(``,!0),z(`small`,null,D(e.replay===`safe`?`An interrupted execution may run again after recovery.`:`A crash records an interrupted result instead of rerunning this effect.`),1)],2))),128))],64)):H(``,!0)],10,hO)],64)):(I(),L(`div`,oO,[z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${A(Ed).inspector})`,onClick:p[0]||=e=>A(xd)()},[B(A(Wc),{size:18})],8,sO),(I(),L(F,null,P(n,e=>z(`button`,{key:e.id,class:E([`rail-tab`,{active:A(J).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>A(xd)(e.id)},[(I(),R($r(e.icon),{size:20})),e.id===`tasks`&&A(Zu).length?(I(),L(`span`,lO,D(A(Zu).length),1)):H(``,!0)],10,cO)),64))]))],2))}}),[[`__scopeId`,`data-v-419eb6ed`]]),tk={class:`chat-empty`},nk={class:`eyebrow`},rk={key:3,class:`hint offline-error`},ik={key:4,class:`offline-command`},ak={key:5,class:`hint`},ok={key:6,class:`hint`},sk={class:`offline-actions`},ck=[`disabled`],lk={key:7,class:`message-error`,role:`alert`},uk=N({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=k(!1),r=k(``),i=U(()=>{let e=t.device,n=e.source===`config`;switch(e.status){case`checking`:return{title:`Checking ${e.name}…`,text:`Probing the device. This view fills in as soon as it answers.`};case`unauthorized`:return e.transport===`tunnel`?{title:`${e.name} tunnel credentials are not valid`,text:`Pair the device again — the hub will mint a fresh credential.`}:{title:e.hasToken?`${e.name} rejected its token`:`No token for ${e.name}`,text:e.hasToken?`The device's DPI_TOKEN changed (a rotate or a rebuilt device). Copy the current token into this hub's registry, then check again.`:`This hub has no token for the device yet. Register it, then check again.`,command:n&&e.kind!==`url`?`just net register ${e.id}`:`just net register ${e.id} --token <token>`};case`mismatch`:return{title:`${e.name} answers as a different device`,text:`The URL now reaches a backend with another identity (a rebuilt VM or a new data directory). If that is expected, register it again: that trusts the identity it answers with now.`,command:e.kind===`url`?`just net register ${e.id} --token <token>`:`just net register ${e.id}`};case`incompatible`:return{title:`${e.name} speaks another API version`,text:`Update the device's dpi-backend.`,command:n?`just net deploy ${e.id}`:void 0};default:return{title:`${e.name} is offline`,text:`Last seen ${hd(e.lastSeenAt)}. Its agents keep their state on the device and resume when its backend starts again. The tree shows the last known sessions.`,command:n?e.kind===`local`?`just backend run`:e.kind===`url`?void 0:`just net restart ${e.id}`:void 0,alt:n&&e.kind!==`local`&&e.kind!==`url`?`just net up ${e.id}`:void 0}}});async function a(){n.value=!0,r.value=``;try{let e=await du.check(t.device.id);e.status===`online`&&Y(`${e.id} is online.`)}catch(e){r.value=K(e)}finally{n.value=!1}}async function o(e){try{await navigator.clipboard.writeText(e),Y(`Copied.`)}catch{Y(`Clipboard needs localhost or HTTPS. Select the text to copy.`)}}return(t,s)=>(I(),L(`section`,{class:E([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[z(`div`,tk,[e.device.status===`checking`?(I(),R(A(Ic),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(I(),R(A(ol),{key:1,size:30})):(I(),R(A(_l),{key:2,size:30})),z(`span`,nk,D(e.device.kind.toUpperCase())+` · `+D(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),z(`h2`,null,D(i.value.title),1),z(`p`,null,D(i.value.text),1),e.device.error?(I(),L(`p`,rk,D(e.device.error),1)):H(``,!0),i.value.command?(I(),L(`div`,ik,[z(`code`,null,D(i.value.command),1),z(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[B(A(sc),{size:18})])])):H(``,!0),i.value.command?(I(),L(`p`,ak,`Run it in this repo's terminal, then press Check now.`)):H(``,!0),i.value.alt?(I(),L(`p`,ok,[s[2]||=V(` Never deployed or rebuilt? `,-1),z(`code`,null,D(i.value.alt),1),s[3]||=V(` provisions it from scratch. `,-1)])):H(``,!0),z(`div`,sk,[z(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[B(A($c),{size:18}),V(D(n.value?`Checking…`:`Check now`),1)],8,ck)]),r.value?(I(),L(`p`,lk,D(r.value),1)):H(``,!0)])],2))}}),dk={class:`dir-browser`},fk={class:`dir-path`},pk=[`disabled`],mk=[`aria-busy`],hk=[`title`],gk=[`aria-selected`,`title`,`onClick`],_k={key:1,class:`hint`},vk={key:0,class:`message-error`,role:`alert`},yk=N({__name:`DirBrowser`,props:si({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Di(e,`modelValue`),r=k(),i=k(!1),a=k(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await G(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=K(e));return}finally{s===o&&(i.value=!1)}}return M(()=>t.deviceId,async()=>{r.value=void 0;let e=await s(``),t=e?.dirs[0];t&&!e.path&&await s(t.path)},{immediate:!0}),(e,t)=>(I(),L(`div`,dk,[z(`div`,fk,[j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,"aria-label":`Working directory`,required:``,placeholder:`/path/to/project`,spellcheck:`false`,autocomplete:`off`,onKeydown:t[1]||=js(ks(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[ys,n.value]]),z(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,pk)]),z(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[z(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[B(A(Dc),{size:16}),t[5]||=z(`span`,null,`Start dirs`,-1)]),r.value?.parent?(I(),L(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[B(A(lc),{size:16}),t[6]||=z(`span`,null,`..`,-1)],8,hk)):H(``,!0),(I(!0),L(F,null,P(r.value?.dirs,e=>(I(),L(`button`,{key:e.path,type:`button`,class:`dir-item`,role:`option`,"aria-selected":e.path===n.value,title:e.path,onClick:t=>s(e.path)},[e.path===n.value?(I(),R(A(yc),{key:0,size:16})):(I(),R(A(bc),{key:1,size:16})),z(`span`,null,D(e.name),1)],8,gk))),128)),r.value&&!r.value.dirs.length?(I(),L(`p`,_k,`No subdirectories.`)):H(``,!0)],8,mk),a.value?(I(),L(`p`,vk,D(a.value),1)):H(``,!0)]))}}),bk={key:0,class:`message-error`},xk=[`value`],Sk={class:`field`},Ck={key:0,class:`recent-cwds`},wk=[`title`,`onClick`],Tk={key:0,class:`hint`,title:`The device has no provider key — it lists its built-in catalog, and chat needs OPENROUTER_API_KEY set in the device's env file`},Ek=[`value`],Dk=[`value`],Ok={key:2,class:`message-error`,role:`alert`},kk=[`disabled`],Ak=`dpi-recent-cwds`,jk=Vd(N({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>Cu.devices.value.filter(e=>e.status===`online`)),a=k(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=U(()=>i.value.find(e=>e.id===a.value)),s=U(()=>{let e=o.value?.info?.models??[];if(e.length)return e;let t=o.value?.info;return t?.defaultModel&&t.provider?[{id:t.defaultModel,provider:t.provider,name:`${t.defaultModel} (device default)`,tier:`—`,icon:`lab.png`,contextWindow:0,reasoning:!1,cost:{input:0,output:0}}]:[]}),c=U(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=U(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=k({name:``,cwd:``,model:``,thinking:`medium`}),f=U(()=>{try{return JSON.parse(localStorage.getItem(Ak)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(Ak)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(Ak,JSON.stringify({...n,[e]:r}))}catch{}},m=k(!1),h=k(``),g=k({});M(a,async e=>{if(g.value={},e)try{let{projects:t}=await G(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),M([()=>d.value.cwd,g],()=>{let e=d.value.cwd;if(!e)return;let t=Object.keys(g.value).filter(t=>e===t||e.startsWith(`${t}/`)).sort((e,t)=>t.length-e.length),n=t.length?g.value[t[0]]:void 0;n&&(d.value.model=`${n.provider}/${n.modelId}`)},{immediate:!0}),M(o,e=>{let t=s.value,n=t.find(t=>t.id===e?.info?.defaultModel)??t[0];d.value.model=n?u(n):``,d.value.cwd=``},{immediate:!0});async function _(){if(!m.value&&o.value){m.value=!0,h.value=``;try{let e=s.value.find(e=>u(e)===d.value.model)??s.value[0];if(!e)throw Error(`Choose a model`);let t=await G(o.value.id).createSession({name:d.value.name.trim()||`New session`,cwd:d.value.cwd.trim(),model:{provider:e.provider,modelId:e.id},thinkingLevel:d.value.thinking});p(o.value.id,t.cwd);let n=t.agents.find(e=>e.kind===`root`)??t.agents[0];Bu({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),Y(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=K(e)}finally{m.value=!1}}}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[7]||=ks(e=>r(`close`),[`self`])},[z(`form`,{class:`modal session-modal`,onSubmit:ks(_,[`prevent`])},[z(`header`,null,[t[8]||=z(`div`,null,[z(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),z(`h2`,null,`New session`)],-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[B(A(xl),{size:18})])]),i.value.length?(I(),L(F,{key:1},[z(`label`,null,[t[9]||=V(`Device`,-1),j(z(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(I(!0),L(F,null,P(i.value,e=>(I(),L(`option`,{key:e.id,value:e.id},D(e.name)+D(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,xk))),128))],512),[[Ss,a.value]])]),z(`label`,null,[t[10]||=V(`Session name`,-1),j(z(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[ys,d.value.name]])]),z(`div`,Sk,[z(`span`,null,`Working directory on `+D(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(I(),L(`div`,Ck,[(I(!0),L(F,null,P(f.value,e=>(I(),L(`button`,{key:e,type:`button`,class:E([`chip`,{on:e===d.value.cwd}]),title:e,onClick:t=>d.value.cwd=e},D(e.split(`/`).filter(Boolean).at(-1)||e),11,wk))),128))])):H(``,!0),B(yk,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),z(`label`,null,[t[11]||=V(`Model`,-1),c.value||l.value?(I(),L(`span`,Tk,`no API key on device — chat needs one`)):H(``,!0),j(z(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(I(!0),L(F,null,P(s.value,e=>(I(),L(`option`,{key:u(e),value:u(e)},D(e.tier)+` / `+D(e.name),9,Ek))),128))],512),[[Ss,d.value.model]])]),z(`label`,null,[t[12]||=V(`Thinking`,-1),j(z(`select`,{"onUpdate:modelValue":t[5]||=e=>d.value.thinking=e,"aria-label":`New session thinking level`},[(I(!0),L(F,null,P(A(pv),e=>(I(),L(`option`,{key:e,value:e},D(e),9,Dk))),128))],512),[[Ss,d.value.thinking]])])],64)):(I(),L(`p`,bk,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(I(),L(`p`,Ok,D(h.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,onClick:t[6]||=e=>r(`close`)},`Cancel`),z(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[B(A(Xc),{size:18}),V(D(m.value?`Creating…`:`Create session`),1)],8,kk)])],32)]))}}),[[`__scopeId`,`data-v-95f14dc6`]]),Mk=new Uint8Array(512),Nk=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)Mk[t]=e,Nk[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)Mk[e]=Mk[e-255]})();var Pk=(e,t)=>e===0||t===0?0:Mk[Nk[e]+Nk[t]];function Fk(e){let t=[1];for(let n=0;n<e;n++){let e=Array(t.length+1).fill(0);for(let r=0;r<t.length;r++)e[r]^=t[r],e[r+1]^=Pk(t[r],Mk[n]);t=e}return t}function Ik(e,t){let n=Fk(t),r=Array(t).fill(0);for(let i of e){let e=i^r[0];r.shift(),r.push(0);for(let i=0;i<t;i++)r[i]^=Pk(n[i+1],e)}return r}var Lk=[21,25,29,33,37,41,45,49,53,57,61,65],Rk=[19,34,55,80,108,136,156,194,232,274,324,370],zk=[7,10,15,20,26,36,40,48,60,72,80,96],Bk=[7,10,15,20,26,18,20,24,30,18,20,24],Vk=[[[1,19]],[[1,34]],[[1,55]],[[1,80]],[[1,108]],[[2,68]],[[2,78]],[[2,97]],[[2,116]],[[2,68],[2,69]],[[4,81]],[[2,92],[2,93]]],Hk=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58]],Uk=e=>e<=9?8:16;function Wk(e){for(let t=1;t<=Lk.length;t++)if(4+Uk(t)+e*8<=Rk[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${Rk[11]-3})`)}function Gk(e,t){let n=[...new TextEncoder().encode(e)],r=[],i=(e,t)=>{for(let n=t-1;n>=0;n--)r.push(e>>n&1)};i(4,4),i(n.length,Uk(t));for(let e of n)i(e,8);let a=Rk[t-1],o=a*8;for(i(0,Math.min(4,o-r.length));r.length%8!=0;)r.push(0);let s=[236,17],c=0;for(;r.length<o;)i(s[c++%2],8);let l=[];for(let e=0;e<a;e++){let t=0;for(let n=0;n<8;n++)t=t<<1|r[e*8+n];l.push(t)}return l}function Kk(e,t){let n=Bk[e-1],r=[],i=0;for(let[n,a]of Vk[e-1])for(let e=0;e<n;e++)r.push(t.slice(i,i+=a));let a=[],o=Math.max(...r.map(e=>e.length));for(let e=0;e<o;e++)for(let t of r)e<t.length&&a.push(t[e]);let s=r.map(e=>Ik(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function qk(e){return Array.from({length:e},()=>Array(e).fill(!1))}function Jk(e,t){let n=Lk[t-1],r=(t,r)=>{for(let i=-1;i<=7;i++)for(let a=-1;a<=7;a++){let o=t+i,s=r+a;if(o<0||o>=n||s<0||s>=n)continue;let c=i>=0&&i<=6&&a>=0&&a<=6&&(i===0||i===6||a===0||a===6),l=i>=2&&i<=4&&a>=2&&a<=4;e[o][s]=c||l}};r(0,0),r(0,n-7),r(n-7,0);for(let t=8;t<n-8;t++)e[6][t]=t%2==0,e[t][6]=t%2==0;let i=Hk[t-1];for(let t of i)for(let r of i)if(!(t<=8&&r<=8||t<=8&&r>=n-9||t>=n-9&&r<=8))for(let n=-2;n<=2;n++)for(let i=-2;i<=2;i++)e[t+n][r+i]=Math.max(Math.abs(n),Math.abs(i))!==1;if(e[n-8][8]=!0,t>=7){let r=t<<12;for(let e=17;e>=12;e--)r>>e&1&&(r^=7973<<e-12);let i=t<<12|r&4095;for(let t=0;t<18;t++){let r=(i>>t&1)==1,a=n-11+t%3,o=t/3|0;e[a][o]=r,e[o][a]=r}}}function Yk(e){let t=8|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>9&1?1335:0);let r=(t<<10|n)^21522,i=[];for(let e=14;e>=0;e--)i.push((r>>e&1)==1);return i}function Xk(e,t){let n=Lk[0]*0+e.length,r=Yk(t);for(let t=0;t<=5;t++)e[8][t]=r[t];e[8][7]=r[6],e[8][8]=r[7],e[7][8]=r[8];for(let t=9;t<15;t++)e[14-t][8]=r[t];for(let t=0;t<7;t++)e[n-1-t][8]=r[t];e[8][n-8]=r[7];for(let t=8;t<15;t++)e[8][n-15+t]=r[t];e[n-8][8]=!0}function Zk(e,t,n,r){let i=e.length;Lk[n-1]*Lk[n-1];let a=e=>((t[e>>3]??0)>>7-(e&7)&1)==1,o=0,s=!0;for(let t=i-1;t>0;t-=2){t===6&&t--;for(let c=0;c<i;c++){let l=s?i-1-c:c;for(let i of[t,t-1]){if($k(l,i,n))continue;if(o>=(Rk[n-1]+zk[n-1])*8){o++;continue}let t=a(o++);Qk(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function Qk(e,t,n){switch(n){case 0:return(e+t)%2==0;case 1:return e%2==0;case 2:return t%3==0;case 3:return(e+t)%3==0;case 4:return(Math.floor(e/2)+Math.floor(t/3))%2==0;case 5:return e*t%2+e*t%3==0;case 6:return(e*t%2+e*t%3)%2==0;default:return((e+t)%2+e*t%3)%2==0}}function $k(e,t,n){let r=Lk[n-1];if(e<=8&&t<=8||e<=8&&t>=r-8||e>=r-8&&t<=8||e===6||t===6||n>=7&&(e>=r-11&&e<=r-9&&t<=5||t>=r-11&&t<=r-9&&e<=5))return!0;let i=Hk[n-1];for(let n of i)for(let a of i)if(!(n<=8&&a<=8||n<=8&&a>=r-9||n>=r-9&&a<=8)&&Math.abs(e-n)<=2&&Math.abs(t-a)<=2)return!0;return!1}function eA(e){let t=e.length,n=0;for(let r=0;r<2;r++)for(let i=0;i<t;i++){let a=1;for(let o=1;o<t;o++)(r===0?e[i][o]:e[o][i])===(r===0?e[i][o-1]:e[o-1][i])?(a++,o===t-1&&a>=5&&(n+=3+(a-5))):(a>=5&&(n+=3+(a-5)),a=1)}for(let r=0;r<t-1;r++)for(let i=0;i<t-1;i++){let t=e[r][i];e[r][i+1]===t&&e[r+1][i]===t&&e[r+1][i+1]===t&&(n+=3)}let r=[!0,!1,!0,!0,!0,!1,!0,!1,!1,!1,!1],i=(e,t)=>{for(let i=0;i+11<=t;i++){let t=!0;for(let n=0;n<11;n++)if(e(i+n)!==r[n]){t=!1;break}t&&(n+=40)}};for(let n=0;n<t;n++)i(t=>e[n][t],t);for(let n=0;n<t;n++)i(t=>e[t][n],t);let a=0;for(let t of e)for(let e of t)e&&a++;let o=a*100/(t*t);return n+=Math.floor(Math.abs(o-50)/5)*10,n}function tA(e,t){let n=Wk(new TextEncoder().encode(e).length),r=Lk[n-1],i=Kk(n,Gk(e,n)),a=qk(r);return Jk(a,n),Zk(a,i,n,t),Xk(a,t),a}function nA(e,t){if(t!==void 0)return tA(e,t);let n;for(let t=0;t<8;t++){let r=tA(e,t),i=eA(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function rA(e,t=160){let n=nA(e),r=n.length,i=t/(r+8),a=``;for(let e=0;e<r;e++)for(let t=0;t<r;t++)n[e][t]&&(a+=`<rect x="${((t+4)*i).toFixed(2)}" y="${((e+4)*i).toFixed(2)}" width="${i.toFixed(3)}" height="${i.toFixed(3)}"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${t}" shape-rendering="crispEdges"><rect width="${t}" height="${t}" fill="#fff"/><g fill="#000">${a}</g></svg>`}var iA={class:`device-handoff`,"aria-label":`Pair this machine`},aA={class:`row`},oA=[`disabled`],sA=[`disabled`],cA={key:0,class:`target`,"data-testid":`device-url`},lA={key:1,class:`err`},uA=Vd(N({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=k(`4780`),r=k(!1),i=U(()=>{let e=/^\d{1,5}$/.test(n.value)?Number(n.value):0;if(!(!e||e<1||e>65535))return`http://127.0.0.1:${e}/pair#${t.offerFragment}`});function a(){let e=i.value;e&&window.open(e,`_blank`,`noopener`)}async function o(){let e=i.value;if(e)try{await navigator.clipboard.writeText(e),r.value=!0,setTimeout(()=>r.value=!1,1600)}catch{}}return(e,t)=>(I(),L(`section`,iA,[z(`header`,null,[B(A(zc),{size:18}),t[1]||=z(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=z(`p`,{class:`what`},[V(` If this browser runs on the device itself, open its local pairing page — the offer is relayed inside the link, nothing is sent to the hub. Start `),z(`code`,null,`dpi device`),V(` there first. `)],-1),z(`div`,aA,[z(`label`,null,[t[2]||=V(` local port `,-1),j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[ys,n.value]])]),z(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[B(A(mc),{size:15}),t[3]||=V(`Open the device page `,-1)],8,oA),z(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[B(A(sc),{size:15}),V(D(r.value?`Copied`:`Copy link`),1)],8,sA)]),i.value?(I(),L(`p`,cA,D(i.value),1)):H(``,!0),i.value?H(``,!0):(I(),L(`p`,lA,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-01884b7b`]]);function dA(e){return bA(e)&&!fA(e)&&!wA(e)&&Symbol.asyncIterator in e}function fA(e){return Array.isArray(e)}function pA(e){return typeof e==`bigint`}function mA(e){return typeof e==`boolean`}function hA(e){return e instanceof globalThis.Date}function gA(e){return typeof e==`function`}function _A(e){return bA(e)&&!fA(e)&&!wA(e)&&Symbol.iterator in e}function vA(e){return e===null}function yA(e){return typeof e==`number`}function bA(e){return typeof e==`object`&&!!e}function xA(e){return e instanceof globalThis.RegExp}function SA(e){return typeof e==`string`}function CA(e){return typeof e==`symbol`}function wA(e){return e instanceof globalThis.Uint8Array}function TA(e){return e===void 0}function EA(e){return e.map(e=>jA(e))}function DA(e){return new Date(e.getTime())}function OA(e){return new Uint8Array(e)}function kA(e){return new RegExp(e.source,e.flags)}function AA(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=jA(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=jA(e[n]);return t}function jA(e){return fA(e)?EA(e):hA(e)?DA(e):wA(e)?OA(e):xA(e)?kA(e):bA(e)?AA(e):e}function MA(e){return jA(e)}function NA(e,t){return MA(t===void 0?e:{...t,...e})}function PA(e){return typeof e==`object`&&!!e}function FA(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function IA(e){return e===void 0}function LA(e){return typeof e==`number`}var RA;(function(e){e.InstanceMode=`default`,e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(t,n){return e.ExactOptionalPropertyTypes?n in t:t[n]!==void 0}e.IsExactOptionalProperty=t;function n(t){let n=PA(t);return e.AllowArrayObject?n:n&&!FA(t)}e.IsObjectLike=n;function r(e){return n(e)&&!(e instanceof Date)&&!(e instanceof Uint8Array)}e.IsRecordLike=r;function i(t){return e.AllowNaN?LA(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=IA(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(RA||={});function zA(e){return globalThis.Object.freeze(e).map(e=>WA(e))}function BA(e){return e}function VA(e){return e}function HA(e){return e}function UA(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=WA(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=WA(e[n]);return globalThis.Object.freeze(t)}function WA(e){return fA(e)?zA(e):hA(e)?BA(e):wA(e)?VA(e):xA(e)?HA(e):bA(e)?UA(e):e}function X(e,t){let n=t===void 0?e:{...t,...e};switch(RA.InstanceMode){case`freeze`:return WA(n);case`clone`:return MA(n);default:return n}}var GA=class extends Error{constructor(e){super(e)}},KA=Symbol.for(`TypeBox.Transform`),qA=Symbol.for(`TypeBox.Readonly`),JA=Symbol.for(`TypeBox.Optional`),YA=Symbol.for(`TypeBox.Hint`),Z=Symbol.for(`TypeBox.Kind`);function XA(e){return bA(e)&&e[qA]===`Readonly`}function ZA(e){return bA(e)&&e[JA]===`Optional`}function QA(e){return dj(e,`Any`)}function $A(e){return dj(e,`Argument`)}function ej(e){return dj(e,`Array`)}function tj(e){return dj(e,`AsyncIterator`)}function nj(e){return dj(e,`BigInt`)}function rj(e){return dj(e,`Boolean`)}function ij(e){return dj(e,`Computed`)}function aj(e){return dj(e,`Constructor`)}function oj(e){return dj(e,`Date`)}function sj(e){return dj(e,`Function`)}function cj(e){return dj(e,`Integer`)}function lj(e){return dj(e,`Intersect`)}function uj(e){return dj(e,`Iterator`)}function dj(e,t){return bA(e)&&Z in e&&e[Z]===t}function fj(e){return mA(e)||yA(e)||SA(e)}function pj(e){return dj(e,`Literal`)}function mj(e){return dj(e,`MappedKey`)}function hj(e){return dj(e,`MappedResult`)}function gj(e){return dj(e,`Never`)}function _j(e){return dj(e,`Not`)}function vj(e){return dj(e,`Null`)}function yj(e){return dj(e,`Number`)}function bj(e){return dj(e,`Object`)}function xj(e){return dj(e,`Promise`)}function Sj(e){return dj(e,`Record`)}function Cj(e){return dj(e,`Ref`)}function wj(e){return dj(e,`RegExp`)}function Tj(e){return dj(e,`String`)}function Ej(e){return dj(e,`Symbol`)}function Dj(e){return dj(e,`TemplateLiteral`)}function Oj(e){return dj(e,`This`)}function kj(e){return bA(e)&&KA in e}function Aj(e){return dj(e,`Tuple`)}function jj(e){return dj(e,`Undefined`)}function Mj(e){return dj(e,`Union`)}function Nj(e){return dj(e,`Uint8Array`)}function Pj(e){return dj(e,`Unknown`)}function Fj(e){return dj(e,`Unsafe`)}function Ij(e){return dj(e,`Void`)}function Lj(e){return bA(e)&&Z in e&&SA(e[Z])}function Rj(e){return QA(e)||$A(e)||ej(e)||rj(e)||nj(e)||tj(e)||ij(e)||aj(e)||oj(e)||sj(e)||cj(e)||lj(e)||uj(e)||pj(e)||mj(e)||hj(e)||gj(e)||_j(e)||vj(e)||yj(e)||bj(e)||xj(e)||Sj(e)||Cj(e)||wj(e)||Tj(e)||Ej(e)||Dj(e)||Oj(e)||Aj(e)||jj(e)||Mj(e)||Nj(e)||Pj(e)||Fj(e)||Ij(e)||Lj(e)}var zj=`Argument.Any.Array.AsyncIterator.BigInt.Boolean.Computed.Constructor.Date.Enum.Function.Integer.Intersect.Iterator.Literal.MappedKey.MappedResult.Not.Null.Number.Object.Promise.Record.Ref.RegExp.String.Symbol.TemplateLiteral.This.Tuple.Undefined.Union.Uint8Array.Unknown.Void`.split(`.`);function Bj(e){try{return new RegExp(e),!0}catch{return!1}}function Vj(e){if(!SA(e))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=7&&n<=13||n===27||n===127)return!1}return!0}function Hj(e){return Gj(e)||VM(e)}function Uj(e){return TA(e)||pA(e)}function Wj(e){return TA(e)||yA(e)}function Gj(e){return TA(e)||mA(e)}function Kj(e){return TA(e)||SA(e)}function qj(e){return TA(e)||SA(e)&&Vj(e)&&Bj(e)}function Jj(e){return TA(e)||SA(e)&&Vj(e)}function Yj(e){return TA(e)||VM(e)}function Xj(e){return bA(e)&&e[JA]===`Optional`}function Zj(e){return dM(e,`Any`)&&Kj(e.$id)}function Qj(e){return dM(e,`Argument`)&&yA(e.index)}function $j(e){return dM(e,`Array`)&&e.type===`array`&&Kj(e.$id)&&VM(e.items)&&Wj(e.minItems)&&Wj(e.maxItems)&&Gj(e.uniqueItems)&&Yj(e.contains)&&Wj(e.minContains)&&Wj(e.maxContains)}function eM(e){return dM(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&Kj(e.$id)&&VM(e.items)}function tM(e){return dM(e,`BigInt`)&&e.type===`bigint`&&Kj(e.$id)&&Uj(e.exclusiveMaximum)&&Uj(e.exclusiveMinimum)&&Uj(e.maximum)&&Uj(e.minimum)&&Uj(e.multipleOf)}function nM(e){return dM(e,`Boolean`)&&e.type===`boolean`&&Kj(e.$id)}function rM(e){return dM(e,`Computed`)&&SA(e.target)&&fA(e.parameters)&&e.parameters.every(e=>VM(e))}function iM(e){return dM(e,`Constructor`)&&e.type===`Constructor`&&Kj(e.$id)&&fA(e.parameters)&&e.parameters.every(e=>VM(e))&&VM(e.returns)}function aM(e){return dM(e,`Date`)&&e.type===`Date`&&Kj(e.$id)&&Wj(e.exclusiveMaximumTimestamp)&&Wj(e.exclusiveMinimumTimestamp)&&Wj(e.maximumTimestamp)&&Wj(e.minimumTimestamp)&&Wj(e.multipleOfTimestamp)}function oM(e){return dM(e,`Function`)&&e.type===`Function`&&Kj(e.$id)&&fA(e.parameters)&&e.parameters.every(e=>VM(e))&&VM(e.returns)}function sM(e){return dM(e,`Integer`)&&e.type===`integer`&&Kj(e.$id)&&Wj(e.exclusiveMaximum)&&Wj(e.exclusiveMinimum)&&Wj(e.maximum)&&Wj(e.minimum)&&Wj(e.multipleOf)}function cM(e){return bA(e)&&Object.entries(e).every(([e,t])=>Vj(e)&&VM(t))}function lM(e){return dM(e,`Intersect`)&&!(SA(e.type)&&e.type!==`object`)&&fA(e.allOf)&&e.allOf.every(e=>VM(e)&&!MM(e))&&Kj(e.type)&&(Gj(e.unevaluatedProperties)||Yj(e.unevaluatedProperties))&&Kj(e.$id)}function uM(e){return dM(e,`Iterator`)&&e.type===`Iterator`&&Kj(e.$id)&&VM(e.items)}function dM(e,t){return bA(e)&&Z in e&&e[Z]===t}function fM(e){return hM(e)&&SA(e.const)}function pM(e){return hM(e)&&yA(e.const)}function mM(e){return hM(e)&&mA(e.const)}function hM(e){return dM(e,`Literal`)&&Kj(e.$id)&&gM(e.const)}function gM(e){return mA(e)||yA(e)||SA(e)}function _M(e){return dM(e,`MappedKey`)&&fA(e.keys)&&e.keys.every(e=>yA(e)||SA(e))}function vM(e){return dM(e,`MappedResult`)&&cM(e.properties)}function yM(e){return dM(e,`Never`)&&bA(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function bM(e){return dM(e,`Not`)&&VM(e.not)}function xM(e){return dM(e,`Null`)&&e.type===`null`&&Kj(e.$id)}function SM(e){return dM(e,`Number`)&&e.type===`number`&&Kj(e.$id)&&Wj(e.exclusiveMaximum)&&Wj(e.exclusiveMinimum)&&Wj(e.maximum)&&Wj(e.minimum)&&Wj(e.multipleOf)}function CM(e){return dM(e,`Object`)&&e.type===`object`&&Kj(e.$id)&&cM(e.properties)&&Hj(e.additionalProperties)&&Wj(e.minProperties)&&Wj(e.maxProperties)}function wM(e){return dM(e,`Promise`)&&e.type===`Promise`&&Kj(e.$id)&&VM(e.item)}function TM(e){return dM(e,`Record`)&&e.type===`object`&&Kj(e.$id)&&Hj(e.additionalProperties)&&bA(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&Bj(t[0])&&bA(e.patternProperties)&&VM(e.patternProperties[t[0]])})(e)}function EM(e){return dM(e,`Ref`)&&Kj(e.$id)&&SA(e.$ref)}function DM(e){return dM(e,`RegExp`)&&Kj(e.$id)&&SA(e.source)&&SA(e.flags)&&Wj(e.maxLength)&&Wj(e.minLength)}function OM(e){return dM(e,`String`)&&e.type===`string`&&Kj(e.$id)&&Wj(e.minLength)&&Wj(e.maxLength)&&qj(e.pattern)&&Jj(e.format)}function kM(e){return dM(e,`Symbol`)&&e.type===`symbol`&&Kj(e.$id)}function AM(e){return dM(e,`TemplateLiteral`)&&e.type===`string`&&SA(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function jM(e){return dM(e,`This`)&&Kj(e.$id)&&SA(e.$ref)}function MM(e){return bA(e)&&KA in e}function NM(e){return dM(e,`Tuple`)&&e.type===`array`&&Kj(e.$id)&&yA(e.minItems)&&yA(e.maxItems)&&e.minItems===e.maxItems&&(TA(e.items)&&TA(e.additionalItems)&&e.minItems===0||fA(e.items)&&e.items.every(e=>VM(e)))}function PM(e){return dM(e,`Undefined`)&&e.type===`undefined`&&Kj(e.$id)}function FM(e){return dM(e,`Union`)&&Kj(e.$id)&&bA(e)&&fA(e.anyOf)&&e.anyOf.every(e=>VM(e))}function IM(e){return dM(e,`Uint8Array`)&&e.type===`Uint8Array`&&Kj(e.$id)&&Wj(e.minByteLength)&&Wj(e.maxByteLength)}function LM(e){return dM(e,`Unknown`)&&Kj(e.$id)}function RM(e){return dM(e,`Unsafe`)}function zM(e){return dM(e,`Void`)&&e.type===`void`&&Kj(e.$id)}function BM(e){return bA(e)&&Z in e&&SA(e[Z])&&!zj.includes(e[Z])}function VM(e){return bA(e)&&(Zj(e)||Qj(e)||$j(e)||nM(e)||tM(e)||eM(e)||rM(e)||iM(e)||aM(e)||oM(e)||sM(e)||lM(e)||uM(e)||hM(e)||_M(e)||vM(e)||yM(e)||bM(e)||xM(e)||SM(e)||CM(e)||wM(e)||TM(e)||EM(e)||DM(e)||OM(e)||kM(e)||AM(e)||jM(e)||NM(e)||PM(e)||FM(e)||IM(e)||LM(e)||RM(e)||zM(e)||BM(e))}var HM=`(true|false)`,UM=`(0|[1-9][0-9]*)`,WM=`(.*)`,GM=`(?!.*)`;`${HM}`;var KM=`^${UM}$`,qM=`^${WM}$`,JM=`^${GM}$`;function YM(e,t){return e.includes(t)}function XM(e){return[...new Set(e)]}function ZM(e,t){return e.filter(e=>t.includes(e))}function QM(e,t){return e.reduce((e,t)=>ZM(e,t),t)}function $M(e){return e.length===1?e[0]:e.length>1?QM(e.slice(1),e[0]):[]}function eN(e){let t=[];for(let n of e)t.push(...n);return t}function tN(e){return X({[Z]:`Any`},e)}function nN(e,t){return X({[Z]:`Array`,type:`array`,items:e},t)}function rN(e){return X({[Z]:`Argument`,index:e})}function iN(e,t){return X({[Z]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function aN(e,t,n){return X({[Z]:`Computed`,target:e,parameters:t},n)}function oN(e,t){let{[t]:n,...r}=e;return r}function sN(e,t){return t.reduce((e,t)=>oN(e,t),e)}function cN(e){return X({[Z]:`Never`,not:{}},e)}function lN(e){return X({[Z]:`MappedResult`,properties:e})}function uN(e,t,n){return X({[Z]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function dN(e,t,n){return X({[Z]:`Function`,type:`Function`,parameters:e,returns:t},n)}function fN(e,t){return X({[Z]:`Union`,anyOf:e},t)}function pN(e){return e.some(e=>ZA(e))}function mN(e){return e.map(e=>ZA(e)?hN(e):e)}function hN(e){return sN(e,[JA])}function gN(e,t){return pN(e)?nF(fN(mN(e),t)):fN(mN(e),t)}function _N(e,t){return e.length===1?X(e[0],t):e.length===0?cN(t):gN(e,t)}function vN(e,t){return e.length===0?cN(t):e.length===1?X(e[0],t):fN(e,t)}var yN=class extends GA{};function bN(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function xN(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function SN(e,t){return xN(e,t,`(`)}function CN(e,t){return xN(e,t,`)`)}function wN(e,t){return xN(e,t,`|`)}function TN(e){if(!(SN(e,0)&&CN(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(SN(e,n)&&(t+=1),CN(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function EN(e){return e.slice(1,e.length-1)}function DN(e){let t=0;for(let n=0;n<e.length;n++)if(SN(e,n)&&(t+=1),CN(e,n)&&--t,wN(e,n)&&t===0)return!0;return!1}function ON(e){for(let t=0;t<e.length;t++)if(SN(e,t))return!0;return!1}function kN(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(SN(e,i)&&(t+=1),CN(e,i)&&--t,wN(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(jN(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(jN(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function AN(e){function t(e,t){if(!SN(e,t))throw new yN(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(SN(e,r)&&(n+=1),CN(e,r)&&--n,n===0)return[t,r];throw new yN(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(SN(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(SN(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(jN(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(jN(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function jN(e){return TN(e)?jN(EN(e)):DN(e)?kN(e):ON(e)?AN(e):{type:`const`,const:bN(e)}}function MN(e){return jN(e.slice(1,e.length-1))}var NN=class extends GA{};function PN(e){return e.type===`or`&&e.expr.length===2&&e.expr[0].type===`const`&&e.expr[0].const===`0`&&e.expr[1].type===`const`&&e.expr[1].const===`[1-9][0-9]*`}function FN(e){return e.type===`or`&&e.expr.length===2&&e.expr[0].type===`const`&&e.expr[0].const===`true`&&e.expr[1].type===`const`&&e.expr[1].const===`false`}function IN(e){return e.type===`const`&&e.const===`.*`}function LN(e){return PN(e)||IN(e)?!1:FN(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>LN(e)):e.type===`const`||(()=>{throw new NN(`Unknown expression type`)})()}function RN(e){return LN(MN(e.pattern))}var zN=class extends GA{};function*BN(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of BN(e.slice(1)))yield`${t}${n}`}function*VN(e){return yield*BN(e.expr.map(e=>[...WN(e)]))}function*HN(e){for(let t of e.expr)yield*WN(t)}function*UN(e){return yield e.const}function*WN(e){return e.type===`and`?yield*VN(e):e.type===`or`?yield*HN(e):e.type===`const`?yield*UN(e):(()=>{throw new zN(`Unknown expression`)})()}function GN(e){let t=MN(e.pattern);return LN(t)?[...WN(t)]:[]}function KN(e,t){return X({[Z]:`Literal`,const:e,type:typeof e},t)}function qN(e){return X({[Z]:`Boolean`,type:`boolean`},e)}function JN(e){return X({[Z]:`BigInt`,type:`bigint`},e)}function YN(e){return X({[Z]:`Number`,type:`number`},e)}function XN(e){return X({[Z]:`String`,type:`string`},e)}function*ZN(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield qN():t===`number`?yield YN():t===`bigint`?yield JN():t===`string`?yield XN():yield(()=>{let e=t.split(`|`).map(e=>KN(e.trim()));return e.length===0?cN():e.length===1?e[0]:_N(e)})()}function*QN(e){if(e[1]!==`{`)return yield*[KN(`$`),...$N(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=ZN(e.slice(2,t)),r=$N(e.slice(t+1));return yield*[...n,...r]}yield KN(e)}function*$N(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[KN(e.slice(0,t)),...QN(e.slice(t))];yield KN(e)}function eP(e){return[...$N(e)]}var tP=class extends GA{};function nP(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function rP(e,t){return Dj(e)?e.pattern.slice(1,e.pattern.length-1):Mj(e)?`(${e.anyOf.map(e=>rP(e,t)).join(`|`)})`:yj(e)||cj(e)||nj(e)?`${t}${UM}`:Tj(e)?`${t}${WM}`:pj(e)?`${t}${nP(e.const.toString())}`:rj(e)?`${t}${HM}`:(()=>{throw new tP(`Unexpected Kind '${e[Z]}'`)})()}function iP(e){return`^${e.map(e=>rP(e,``)).join(``)}$`}function aP(e){return _N(GN(e).map(e=>KN(e)))}function oP(e,t){let n=SA(e)?iP(eP(e)):iP(e);return X({[Z]:`TemplateLiteral`,type:`string`,pattern:n},t)}function sP(e){return GN(e).map(e=>e.toString())}function cP(e){let t=[];for(let n of e)t.push(...uP(n));return t}function lP(e){return[e.toString()]}function uP(e){return[...new Set(Dj(e)?sP(e):Mj(e)?cP(e.anyOf):pj(e)?lP(e.const):yj(e)||cj(e)?[`[number]`]:[])]}function dP(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=TP(e,uP(t[i]),n);return r}function fP(e,t,n){return dP(e,t.properties,n)}function pP(e,t,n){return lN(fP(e,t,n))}function mP(e,t){return e.map(e=>SP(e,t))}function hP(e){return e.filter(e=>!gj(e))}function gP(e,t){return dF(hP(mP(e,t)))}function _P(e){return e.some(e=>gj(e))?[]:e}function vP(e,t){return _N(_P(mP(e,t)))}function yP(e,t){return t in e?e[t]:t===`[number]`?_N(e):cN()}function bP(e,t){return t===`[number]`?e:cN()}function xP(e,t){return t in e?e[t]:cN()}function SP(e,t){return lj(e)?gP(e.allOf,t):Mj(e)?vP(e.anyOf,t):Aj(e)?yP(e.items??[],t):ej(e)?bP(e.items,t):bj(e)?xP(e.properties,t):cN()}function CP(e,t){return t.map(t=>SP(e,t))}function wP(e,t){return _N(CP(e,t))}function TP(e,t,n){if(Cj(e)||Cj(t)){if(!Rj(e)||!Rj(t))throw new GA(`Index types using Ref parameters require both Type and Key to be of TSchema`);return aN(`Index`,[e,t])}return hj(t)?pP(e,t,n):mj(t)?kP(e,t,n):X(Rj(t)?wP(e,uP(t)):wP(e,t),n)}function EP(e,t,n){return{[t]:TP(e,[t],MA(n))}}function DP(e,t,n){return t.reduce((t,r)=>({...t,...EP(e,r,n)}),{})}function OP(e,t,n){return DP(e,t.keys,n)}function kP(e,t,n){return lN(OP(e,t,n))}function AP(e,t){return X({[Z]:`Iterator`,type:`Iterator`,items:e},t)}function jP(e){return globalThis.Object.keys(e).filter(t=>!ZA(e[t]))}function MP(e,t){let n=jP(e);return X(n.length>0?{[Z]:`Object`,type:`object`,required:n,properties:e}:{[Z]:`Object`,type:`object`,properties:e},t)}var NP=MP;function PP(e,t){return X({[Z]:`Promise`,type:`Promise`,item:e},t)}function FP(e){return X(sN(e,[qA]))}function IP(e){return X({...e,[qA]:`Readonly`})}function LP(e,t){return t===!1?FP(e):IP(e)}function RP(e,t){let n=t??!0;return hj(e)?VP(e,n):LP(e,n)}function zP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=RP(e[r],t);return n}function BP(e,t){return zP(e.properties,t)}function VP(e,t){return lN(BP(e,t))}function HP(e,t){return X(e.length>0?{[Z]:`Tuple`,type:`array`,items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[Z]:`Tuple`,type:`array`,minItems:e.length,maxItems:e.length},t)}function UP(e,t){return e in t?XP(e,t[e]):lN(t)}function WP(e){return{[e]:KN(e)}}function GP(e){let t={};for(let n of e)t[n]=KN(n);return t}function KP(e,t){return YM(t,e)?WP(e):GP(t)}function qP(e,t){return UP(e,KP(e,t))}function JP(e,t){return t.map(t=>XP(e,t))}function YP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=XP(e,t[r]);return n}function XP(e,t){let n={...t};return ZA(t)?nF(XP(e,sN(t,[JA]))):XA(t)?RP(XP(e,sN(t,[qA]))):hj(t)?UP(e,t.properties):mj(t)?qP(e,t.keys):aj(t)?uN(JP(e,t.parameters),XP(e,t.returns),n):sj(t)?dN(JP(e,t.parameters),XP(e,t.returns),n):tj(t)?iN(XP(e,t.items),n):uj(t)?AP(XP(e,t.items),n):lj(t)?fF(JP(e,t.allOf),n):Mj(t)?vN(JP(e,t.anyOf),n):Aj(t)?HP(JP(e,t.items??[]),n):bj(t)?NP(YP(e,t.properties),n):ej(t)?nN(XP(e,t.items),n):xj(t)?PP(XP(e,t.item),n):t}function ZP(e,t){let n={};for(let r of e)n[r]=XP(r,t);return n}function QP(e,t,n){let r=Rj(e)?uP(e):e;return NP(ZP(r,t({[Z]:`MappedKey`,keys:r})),n)}function $P(e){return X(sN(e,[JA]))}function eF(e){return X({...e,[JA]:`Optional`})}function tF(e,t){return t===!1?$P(e):eF(e)}function nF(e,t){let n=t??!0;return hj(e)?aF(e,n):tF(e,n)}function rF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=nF(e[r],t);return n}function iF(e,t){return rF(e.properties,t)}function aF(e,t){return lN(iF(e,t))}function oF(e,t={}){let n=e.every(e=>bj(e)),r=Rj(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return X(t.unevaluatedProperties===!1||Rj(t.unevaluatedProperties)||n?{...r,[Z]:`Intersect`,type:`object`,allOf:e}:{...r,[Z]:`Intersect`,allOf:e},t)}function sF(e){return e.every(e=>ZA(e))}function cF(e){return sN(e,[JA])}function lF(e){return e.map(e=>ZA(e)?cF(e):e)}function uF(e,t){return sF(e)?nF(oF(lF(e),t)):oF(lF(e),t)}function dF(e,t={}){if(e.length===1)return X(e[0],t);if(e.length===0)return cN(t);if(e.some(e=>kj(e)))throw Error(`Cannot intersect transform types`);return uF(e,t)}function fF(e,t){if(e.length===1)return X(e[0],t);if(e.length===0)return cN(t);if(e.some(e=>kj(e)))throw Error(`Cannot intersect transform types`);return oF(e,t)}function pF(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new GA(`Ref: $ref must be a string`);return X({[Z]:`Ref`,$ref:t},n)}function mF(e,t){return aN(`Awaited`,[aN(e,t)])}function hF(e){return aN(`Awaited`,[pF(e)])}function gF(e){return fF(yF(e))}function _F(e){return vN(yF(e))}function vF(e){return bF(e)}function yF(e){return e.map(e=>bF(e))}function bF(e,t){return X(ij(e)?mF(e.target,e.parameters):lj(e)?gF(e.allOf):Mj(e)?_F(e.anyOf):xj(e)?vF(e.item):Cj(e)?hF(e.$ref):e,t)}function xF(e){let t=[];for(let n of e)t.push(OF(n));return t}function SF(e){return eN(xF(e))}function CF(e){return $M(xF(e))}function wF(e){return e.map((e,t)=>t.toString())}function TF(e){return[`[number]`]}function EF(e){return globalThis.Object.getOwnPropertyNames(e)}function DF(e){return kF?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function OF(e){return lj(e)?SF(e.allOf):Mj(e)?CF(e.anyOf):Aj(e)?wF(e.items??[]):ej(e)?TF(e.items):bj(e)?EF(e.properties):Sj(e)?DF(e.patternProperties):[]}var kF=!1;function AF(e,t){return aN(`KeyOf`,[aN(e,t)])}function jF(e){return aN(`KeyOf`,[pF(e)])}function MF(e,t){return X(_N(NF(OF(e))),t)}function NF(e){return e.map(e=>e===`[number]`?YN():KN(e))}function PF(e,t){return ij(e)?AF(e.target,e.parameters):Cj(e)?jF(e.$ref):hj(e)?LF(e,t):MF(e,t)}function FF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=PF(e[r],MA(t));return n}function IF(e,t){return FF(e.properties,t)}function LF(e,t){return lN(IF(e,t))}function RF(e){let t=[];for(let n of e)t.push(...OF(n));return XM(t)}function zF(e){return e.filter(e=>!gj(e))}function BF(e,t){let n=[];for(let r of e)n.push(...CP(r,[t]));return zF(n)}function VF(e,t){let n={};for(let r of t)n[r]=dF(BF(e,r));return n}function HF(e,t){return NP(VF(e,RF(e)),t)}function UF(e){return X({[Z]:`Date`,type:`Date`},e)}function WF(e){return X({[Z]:`Null`,type:`null`},e)}function GF(e){return X({[Z]:`Symbol`,type:`symbol`},e)}function KF(e){return X({[Z]:`Undefined`,type:`undefined`},e)}function qF(e){return X({[Z]:`Uint8Array`,type:`Uint8Array`},e)}function JF(e){return X({[Z]:`Unknown`},e)}function YF(e){return e.map(e=>QF(e,!1))}function XF(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=RP(QF(e[n],!1));return t}function ZF(e,t){return t===!0?e:RP(e)}function QF(e,t){return dA(e)||_A(e)?ZF(tN(),t):fA(e)?RP(HP(YF(e))):wA(e)?qF():hA(e)?UF():bA(e)?ZF(NP(XF(e)),t):gA(e)?ZF(dN([],JF()),t):TA(e)?KF():vA(e)?WF():CA(e)?GF():pA(e)?JN():yA(e)||mA(e)||SA(e)?KN(e):NP({})}function $F(e,t){return X(QF(e,!0),t)}function eI(e,t){return aj(e)?HP(e.parameters,t):cN(t)}function tI(e,t){if(TA(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return vN([...new Set(n)].map(e=>KN(e)),{...t,[YA]:`Enum`})}var nI=class extends GA{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function rI(e){return e===Q.False?e:Q.True}function iI(e){throw new nI(e)}function aI(e){return yM(e)||lM(e)||FM(e)||LM(e)||Zj(e)}function oI(e,t){return yM(t)?wI(e,t):lM(t)?bI(e,t):FM(t)?sL(e,t):LM(t)?lL(e,t):Zj(t)?sI(e,t):iI(`StructuralRight`)}function sI(e,t){return Q.True}function cI(e,t){return lM(t)?bI(e,t):FM(t)&&t.anyOf.some(e=>Zj(e)||LM(e))?Q.True:FM(t)?Q.Union:LM(t)||Zj(t)?Q.True:Q.Union}function lI(e,t){return LM(e)?Q.False:Zj(e)?Q.Union:yM(e)?Q.True:Q.False}function uI(e,t){return CM(t)&&VI(t)?Q.True:aI(t)?oI(e,t):$j(t)?rI(pL(e.items,t.items)):Q.False}function dI(e,t){return aI(t)?oI(e,t):eM(t)?rI(pL(e.items,t.items)):Q.False}function fI(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):tM(t)?Q.True:Q.False}function pI(e,t){return mM(e)||nM(e)?Q.True:Q.False}function mI(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):nM(t)?Q.True:Q.False}function hI(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):iM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>rI(pL(t.parameters[n],e))===Q.True)?rI(pL(e.returns,t.returns)):Q.False:Q.False}function gI(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):aM(t)?Q.True:Q.False}function _I(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):oM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>rI(pL(t.parameters[n],e))===Q.True)?rI(pL(e.returns,t.returns)):Q.False:Q.False}function vI(e,t){return hM(e)&&yA(e.const)||SM(e)||sM(e)?Q.True:Q.False}function yI(e,t){return sM(t)||SM(t)?Q.True:aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):Q.False}function bI(e,t){return t.allOf.every(t=>pL(e,t)===Q.True)?Q.True:Q.False}function xI(e,t){return e.allOf.some(e=>pL(e,t)===Q.True)?Q.True:Q.False}function SI(e,t){return aI(t)?oI(e,t):uM(t)?rI(pL(e.items,t.items)):Q.False}function CI(e,t){return hM(t)&&t.const===e.const?Q.True:aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):OM(t)?QI(e,t):SM(t)?kI(e,t):sM(t)?vI(e,t):nM(t)?pI(e,t):Q.False}function wI(e,t){return Q.False}function TI(e,t){return Q.True}function EI(e){let[t,n]=[e,0];for(;bM(t);)t=t.not,n+=1;return n%2==0?t:JF()}function DI(e,t){return bM(e)?pL(EI(e),t):bM(t)?pL(e,EI(t)):iI(`Invalid fallthrough for Not`)}function OI(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):xM(t)?Q.True:Q.False}function kI(e,t){return pM(e)||SM(e)||sM(e)?Q.True:Q.False}function AI(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):sM(t)||SM(t)?Q.True:Q.False}function jI(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function MI(e){return VI(e)}function NI(e){return jI(e,0)||jI(e,1)&&`description`in e.properties&&FM(e.properties.description)&&e.properties.description.anyOf.length===2&&(OM(e.properties.description.anyOf[0])&&PM(e.properties.description.anyOf[1])||OM(e.properties.description.anyOf[1])&&PM(e.properties.description.anyOf[0]))}function PI(e){return jI(e,0)}function FI(e){return jI(e,0)}function II(e){return jI(e,0)}function LI(e){return jI(e,0)}function RI(e){return VI(e)}function zI(e){let t=YN();return jI(e,0)||jI(e,1)&&`length`in e.properties&&rI(pL(e.properties.length,t))===Q.True}function BI(e){return jI(e,0)}function VI(e){let t=YN();return jI(e,0)||jI(e,1)&&`length`in e.properties&&rI(pL(e.properties.length,t))===Q.True}function HI(e){let t=dN([tN()],tN());return jI(e,0)||jI(e,1)&&`then`in e.properties&&rI(pL(e.properties.then,t))===Q.True}function UI(e,t){return pL(e,t)===Q.False||Xj(e)&&!Xj(t)?Q.False:Q.True}function WI(e,t){return LM(e)?Q.False:Zj(e)?Q.Union:yM(e)||fM(e)&&MI(t)||pM(e)&&PI(t)||mM(e)&&FI(t)||kM(e)&&NI(t)||tM(e)&&II(t)||OM(e)&&MI(t)||kM(e)&&NI(t)||SM(e)&&PI(t)||sM(e)&&PI(t)||nM(e)&&FI(t)||IM(e)&&RI(t)||aM(e)&&LI(t)||iM(e)&&BI(t)||oM(e)&&zI(t)?Q.True:TM(e)&&OM(qI(e))?t[YA]===`Record`?Q.True:Q.False:TM(e)&&SM(qI(e))&&jI(t,0)?Q.True:Q.False}function GI(e,t){return aI(t)?oI(e,t):TM(t)?YI(e,t):CM(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!Xj(t.properties[n]))return Q.False;if(Xj(t.properties[n]))return Q.True;if(UI(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function KI(e,t){return aI(t)?oI(e,t):CM(t)&&HI(t)?Q.True:wM(t)?rI(pL(e.item,t.item)):Q.False}function qI(e){return KM in e.patternProperties?YN():qM in e.patternProperties?XN():iI(`Unknown record key pattern`)}function JI(e){return KM in e.patternProperties?e.patternProperties[KM]:qM in e.patternProperties?e.patternProperties[qM]:iI(`Unable to get record value schema`)}function YI(e,t){let[n,r]=[qI(t),JI(t)];return fM(e)&&SM(n)&&rI(pL(e,r))===Q.True?Q.True:IM(e)&&SM(n)||OM(e)&&SM(n)||$j(e)&&SM(n)?pL(e,r):CM(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(UI(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function XI(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?pL(JI(e),JI(t)):Q.False}function ZI(e,t){return pL(DM(e)?XN():e,DM(t)?XN():t)}function QI(e,t){return hM(e)&&SA(e.const)||OM(e)?Q.True:Q.False}function $I(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):OM(t)?Q.True:Q.False}function eL(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):kM(t)?Q.True:Q.False}function tL(e,t){return AM(e)?pL(aP(e),t):AM(t)?pL(e,aP(t)):iI(`Invalid fallthrough for TemplateLiteral`)}function nL(e,t){return $j(t)&&e.items!==void 0&&e.items.every(e=>pL(e,t.items)===Q.True)}function rL(e,t){return yM(e)?Q.True:LM(e)?Q.False:Zj(e)?Q.Union:Q.False}function iL(e,t){return aI(t)?oI(e,t):CM(t)&&VI(t)||$j(t)&&nL(e,t)?Q.True:NM(t)?TA(e.items)&&!TA(t.items)||!TA(e.items)&&TA(t.items)?Q.False:TA(e.items)&&!TA(t.items)||e.items.every((e,n)=>pL(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function aL(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):IM(t)?Q.True:Q.False}function oL(e,t){return aI(t)?oI(e,t):CM(t)?WI(e,t):TM(t)?YI(e,t):zM(t)?dL(e,t):PM(t)?Q.True:Q.False}function sL(e,t){return t.anyOf.some(t=>pL(e,t)===Q.True)?Q.True:Q.False}function cL(e,t){return e.anyOf.every(e=>pL(e,t)===Q.True)?Q.True:Q.False}function lL(e,t){return Q.True}function uL(e,t){return yM(t)?wI(e,t):lM(t)?bI(e,t):FM(t)?sL(e,t):Zj(t)?sI(e,t):OM(t)?QI(e,t):SM(t)?kI(e,t):sM(t)?vI(e,t):nM(t)?pI(e,t):$j(t)?lI(e,t):NM(t)?rL(e,t):CM(t)?WI(e,t):LM(t)?Q.True:Q.False}function dL(e,t){return PM(e)||PM(e)?Q.True:Q.False}function fL(e,t){return lM(t)?bI(e,t):FM(t)?sL(e,t):LM(t)?lL(e,t):Zj(t)?sI(e,t):CM(t)?WI(e,t):zM(t)?Q.True:Q.False}function pL(e,t){return AM(e)||AM(t)?tL(e,t):DM(e)||DM(t)?ZI(e,t):bM(e)||bM(t)?DI(e,t):Zj(e)?cI(e,t):$j(e)?uI(e,t):tM(e)?fI(e,t):nM(e)?mI(e,t):eM(e)?dI(e,t):iM(e)?hI(e,t):aM(e)?gI(e,t):oM(e)?_I(e,t):sM(e)?yI(e,t):lM(e)?xI(e,t):uM(e)?SI(e,t):hM(e)?CI(e,t):yM(e)?TI(e,t):xM(e)?OI(e,t):SM(e)?AI(e,t):CM(e)?GI(e,t):TM(e)?XI(e,t):OM(e)?$I(e,t):kM(e)?eL(e,t):NM(e)?iL(e,t):wM(e)?KI(e,t):IM(e)?aL(e,t):PM(e)?oL(e,t):FM(e)?cL(e,t):LM(e)?uL(e,t):zM(e)?fL(e,t):iI(`Unknown left type operand '${e[Z]}'`)}function mL(e,t){return pL(e,t)}function hL(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=yL(e[o],t,n,r,MA(i));return a}function gL(e,t,n,r,i){return hL(e.properties,t,n,r,i)}function _L(e,t,n,r,i){return lN(gL(e,t,n,r,i))}function vL(e,t,n,r){let i=mL(e,t);return i===Q.Union?vN([n,r]):i===Q.True?n:r}function yL(e,t,n,r,i){return hj(e)?_L(e,t,n,r,i):mj(e)?X(CL(e,t,n,r,i)):X(vL(e,t,n,r),i)}function bL(e,t,n,r,i){return{[e]:yL(KN(e),t,n,r,MA(i))}}function xL(e,t,n,r,i){return e.reduce((e,a)=>({...e,...bL(a,t,n,r,i)}),{})}function SL(e,t,n,r,i){return xL(e.keys,t,n,r,i)}function CL(e,t,n,r,i){return lN(SL(e,t,n,r,i))}function wL(e,t){return EL(aP(e),t)}function TL(e,t){let n=e.filter(e=>mL(e,t)===Q.False);return n.length===1?n[0]:vN(n)}function EL(e,t,n={}){return Dj(e)?X(wL(e,t),n):hj(e)?X(kL(e,t),n):X(Mj(e)?TL(e.anyOf,t):mL(e,t)===Q.False?e:cN(),n)}function DL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=EL(e[r],t);return n}function OL(e,t){return DL(e.properties,t)}function kL(e,t){return lN(OL(e,t))}function AL(e,t){return ML(aP(e),t)}function jL(e,t){let n=e.filter(e=>mL(e,t)!==Q.False);return n.length===1?n[0]:vN(n)}function ML(e,t,n){return Dj(e)?X(AL(e,t),n):hj(e)?X(FL(e,t),n):X(Mj(e)?jL(e.anyOf,t):mL(e,t)===Q.False?cN():e,n)}function NL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=ML(e[r],t);return n}function PL(e,t){return NL(e.properties,t)}function FL(e,t){return lN(PL(e,t))}function IL(e,t){return aj(e)?X(e.returns,t):cN(t)}function LL(e){return RP(nF(e))}function RL(e,t,n){return X({[Z]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function zL(e,t,n){let r={};for(let n of e)r[n]=t;return NP(r,{...n,[YA]:`Record`})}function BL(e,t,n){return RN(e)?zL(uP(e),t,n):RL(e.pattern,t,n)}function VL(e,t,n){return zL(uP(vN(e)),t,n)}function HL(e,t,n){return zL([e.toString()],t,n)}function UL(e,t,n){return RL(e.source,t,n)}function WL(e,t,n){return RL(TA(e.pattern)?qM:e.pattern,t,n)}function GL(e,t,n){return RL(qM,t,n)}function KL(e,t,n){return RL(JM,t,n)}function qL(e,t,n){return NP({true:t,false:t},n)}function JL(e,t,n){return RL(KM,t,n)}function YL(e,t,n){return RL(KM,t,n)}function XL(e,t,n={}){return Mj(e)?VL(e.anyOf,t,n):Dj(e)?BL(e,t,n):pj(e)?HL(e.const,t,n):rj(e)?qL(e,t,n):cj(e)?JL(e,t,n):yj(e)?YL(e,t,n):wj(e)?UL(e,t,n):Tj(e)?WL(e,t,n):QA(e)?GL(e,t,n):gj(e)?KL(e,t,n):cN(n)}function ZL(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function QL(e){let t=ZL(e);return t===qM?XN():t===KM?YN():XN({pattern:t})}function $L(e){return e.patternProperties[ZL(e)]}function eR(e,t){return t.parameters=mR(e,t.parameters),t.returns=hR(e,t.returns),t}function tR(e,t){return t.parameters=mR(e,t.parameters),t.returns=hR(e,t.returns),t}function nR(e,t){return t.allOf=mR(e,t.allOf),t}function rR(e,t){return t.anyOf=mR(e,t.anyOf),t}function iR(e,t){return TA(t.items)||(t.items=mR(e,t.items)),t}function aR(e,t){return t.items=hR(e,t.items),t}function oR(e,t){return t.items=hR(e,t.items),t}function sR(e,t){return t.items=hR(e,t.items),t}function cR(e,t){return t.item=hR(e,t.item),t}function lR(e,t){let n=pR(e,t.properties);return{...t,...NP(n)}}function uR(e,t){let n=XL(hR(e,QL(t)),hR(e,$L(t)));return{...t,...n}}function dR(e,t){return t.index in e?e[t.index]:JF()}function fR(e,t){let n=XA(t),r=ZA(t),i=hR(e,t);return n&&r?LL(i):n&&!r?RP(i):!n&&r?nF(i):i}function pR(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:fR(e,t[r])}),{})}function mR(e,t){return t.map(t=>hR(e,t))}function hR(e,t){return aj(t)?eR(e,t):sj(t)?tR(e,t):lj(t)?nR(e,t):Mj(t)?rR(e,t):Aj(t)?iR(e,t):ej(t)?aR(e,t):tj(t)?oR(e,t):uj(t)?sR(e,t):xj(t)?cR(e,t):bj(t)?lR(e,t):Sj(t)?uR(e,t):$A(t)?dR(e,t):t}function gR(e,t){return hR(t,NA(e))}function _R(e){return X({[Z]:`Integer`,type:`integer`},e)}function vR(e,t,n){return{[e]:kR(KN(e),t,MA(n))}}function yR(e,t,n){return e.reduce((e,r)=>({...e,...vR(r,t,n)}),{})}function bR(e,t,n){return yR(e.keys,t,n)}function xR(e,t,n){return lN(bR(e,t,n))}function SR(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function CR(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function wR(e){return e.toUpperCase()}function TR(e){return e.toLowerCase()}function ER(e,t,n){let r=MN(e.pattern);return LN(r)?oP([vN(OR([...WN(r)].map(e=>KN(e)),t))],n):{...e,pattern:DR(e.pattern,t)}}function DR(e,t){return typeof e==`string`?t===`Uncapitalize`?SR(e):t===`Capitalize`?CR(e):t===`Uppercase`?wR(e):t===`Lowercase`?TR(e):e:e.toString()}function OR(e,t){return e.map(e=>kR(e,t))}function kR(e,t,n={}){return mj(e)?xR(e,t,n):Dj(e)?ER(e,t,n):Mj(e)?vN(OR(e.anyOf,t),n):pj(e)?KN(DR(e.const,t),n):X(e,n)}function AR(e,t={}){return kR(e,`Capitalize`,t)}function jR(e,t={}){return kR(e,`Lowercase`,t)}function MR(e,t={}){return kR(e,`Uncapitalize`,t)}function NR(e,t={}){return kR(e,`Uppercase`,t)}function PR(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=WR(e[i],t,MA(n));return r}function FR(e,t,n){return PR(e.properties,t,n)}function IR(e,t,n){return lN(FR(e,t,n))}function LR(e,t){return e.map(e=>UR(e,t))}function RR(e,t){return e.map(e=>UR(e,t))}function zR(e,t){let{[t]:n,...r}=e;return r}function BR(e,t){return t.reduce((e,t)=>zR(e,t),e)}function VR(e,t,n){let r=sN(e,[KA,`$id`,`required`,`properties`]);return NP(BR(n,t),r)}function HR(e){return vN(e.reduce((e,t)=>fj(t)?[...e,KN(t)]:e,[]))}function UR(e,t){return lj(e)?fF(LR(e.allOf,t)):Mj(e)?vN(RR(e.anyOf,t)):bj(e)?VR(e,t,e.properties):NP({})}function WR(e,t,n){let r=fA(t)?HR(t):t,i=Rj(t)?uP(t):t,a=Cj(e),o=Cj(t);return hj(e)?IR(e,i,n):mj(t)?JR(e,t,n):a&&o||!a&&o||a&&!o?aN(`Omit`,[e,r],n):X({...UR(e,i),...n})}function GR(e,t,n){return{[t]:WR(e,[t],MA(n))}}function KR(e,t,n){return t.reduce((t,r)=>({...t,...GR(e,r,n)}),{})}function qR(e,t,n){return KR(e,t.keys,n)}function JR(e,t,n){return lN(qR(e,t,n))}function YR(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=iz(e[i],t,MA(n));return r}function XR(e,t,n){return YR(e.properties,t,n)}function ZR(e,t,n){return lN(XR(e,t,n))}function QR(e,t){return e.map(e=>rz(e,t))}function $R(e,t){return e.map(e=>rz(e,t))}function ez(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function tz(e,t,n){let r=sN(e,[KA,`$id`,`required`,`properties`]);return NP(ez(n,t),r)}function nz(e){return vN(e.reduce((e,t)=>fj(t)?[...e,KN(t)]:e,[]))}function rz(e,t){return lj(e)?fF(QR(e.allOf,t)):Mj(e)?vN($R(e.anyOf,t)):bj(e)?tz(e,t,e.properties):NP({})}function iz(e,t,n){let r=fA(t)?nz(t):t,i=Rj(t)?uP(t):t,a=Cj(e),o=Cj(t);return hj(e)?ZR(e,i,n):mj(t)?cz(e,t,n):a&&o||!a&&o||a&&!o?aN(`Pick`,[e,r],n):X({...rz(e,i),...n})}function az(e,t,n){return{[t]:iz(e,[t],MA(n))}}function oz(e,t,n){return t.reduce((t,r)=>({...t,...az(e,r,n)}),{})}function sz(e,t,n){return oz(e,t.keys,n)}function cz(e,t,n){return lN(sz(e,t,n))}function lz(e,t){return aN(`Partial`,[aN(e,t)])}function uz(e){return aN(`Partial`,[pF(e)])}function dz(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=nF(e[n]);return t}function fz(e,t){let n=sN(e,[KA,`$id`,`required`,`properties`]);return NP(dz(t),n)}function pz(e){return e.map(e=>mz(e))}function mz(e){return ij(e)?lz(e.target,e.parameters):Cj(e)?uz(e.$ref):lj(e)?fF(pz(e.allOf)):Mj(e)?vN(pz(e.anyOf)):bj(e)?fz(e,e.properties):nj(e)||rj(e)||cj(e)||pj(e)||vj(e)||yj(e)||Tj(e)||Ej(e)||jj(e)?e:NP({})}function hz(e,t){return hj(e)?vz(e,t):X({...mz(e),...t})}function gz(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=hz(e[r],MA(t));return n}function _z(e,t){return gz(e.properties,t)}function vz(e,t){return lN(_z(e,t))}function yz(e,t){return aN(`Required`,[aN(e,t)])}function bz(e){return aN(`Required`,[pF(e)])}function xz(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=sN(e[n],[JA]);return t}function Sz(e,t){let n=sN(e,[KA,`$id`,`required`,`properties`]);return NP(xz(t),n)}function Cz(e){return e.map(e=>wz(e))}function wz(e){return ij(e)?yz(e.target,e.parameters):Cj(e)?bz(e.$ref):lj(e)?fF(Cz(e.allOf)):Mj(e)?vN(Cz(e.anyOf)):bj(e)?Sz(e,e.properties):nj(e)||rj(e)||cj(e)||pj(e)||vj(e)||yj(e)||Tj(e)||Ej(e)||jj(e)?e:NP({})}function Tz(e,t){return hj(e)?Oz(e,t):X({...wz(e),...t})}function Ez(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Tz(e[r],t);return n}function Dz(e,t){return Ez(e.properties,t)}function Oz(e,t){return lN(Dz(e,t))}function kz(e,t){return t.map(t=>Cj(t)?Az(e,t.$ref):Zz(e,t))}function Az(e,t){return t in e?Cj(e[t])?Az(e,e[t].$ref):Zz(e,e[t]):cN()}function jz(e){return bF(e[0])}function Mz(e){return TP(e[0],e[1])}function Nz(e){return PF(e[0])}function Pz(e){return hz(e[0])}function Fz(e){return WR(e[0],e[1])}function Iz(e){return iz(e[0],e[1])}function Lz(e){return Tz(e[0])}function Rz(e,t,n){let r=kz(e,n);return t===`Awaited`?jz(r):t===`Index`?Mz(r):t===`KeyOf`?Nz(r):t===`Partial`?Pz(r):t===`Omit`?Fz(r):t===`Pick`?Iz(r):t===`Required`?Lz(r):cN()}function zz(e,t){return nN(Zz(e,t))}function Bz(e,t){return iN(Zz(e,t))}function Vz(e,t,n){return uN(Xz(e,t),Zz(e,n))}function Hz(e,t,n){return dN(Xz(e,t),Zz(e,n))}function Uz(e,t){return fF(Xz(e,t))}function Wz(e,t){return AP(Zz(e,t))}function Gz(e,t){return NP(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:Zz(e,t[r])}),{}))}function Kz(e,t){let[n,r]=[Zz(e,$L(t)),ZL(t)],i=NA(t);return i.patternProperties[r]=n,i}function qz(e,t){return Cj(t)?{...Az(e,t.$ref),[KA]:t[KA]}:t}function Jz(e,t){return HP(Xz(e,t))}function Yz(e,t){return vN(Xz(e,t))}function Xz(e,t){return t.map(t=>Zz(e,t))}function Zz(e,t){return ZA(t)?X(Zz(e,sN(t,[JA])),t):XA(t)?X(Zz(e,sN(t,[qA])),t):kj(t)?X(qz(e,t),t):ej(t)?X(zz(e,t.items),t):tj(t)?X(Bz(e,t.items),t):ij(t)?X(Rz(e,t.target,t.parameters)):aj(t)?X(Vz(e,t.parameters,t.returns),t):sj(t)?X(Hz(e,t.parameters,t.returns),t):lj(t)?X(Uz(e,t.allOf),t):uj(t)?X(Wz(e,t.items),t):bj(t)?X(Gz(e,t.properties),t):Sj(t)?X(Kz(e,t)):Aj(t)?X(Jz(e,t.items||[]),t):Mj(t)?X(Yz(e,t.anyOf),t):t}function Qz(e,t){return t in e?Zz(e,e[t]):cN()}function $z(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:Qz(e,n)}),{})}var eB=class{constructor(e){let t=$z(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:X(this.$defs[e],t)};return X({[Z]:`Import`,$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}};function tB(e){return new eB(e)}function nB(e,t){return X({[Z]:`Not`,not:e},t)}function rB(e,t){return sj(e)?HP(e.parameters,t):cN()}var iB=0;function aB(e,t={}){TA(t.$id)&&(t.$id=`T${iB++}`);let n=NA(e({[Z]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,X({[YA]:`Recursive`,...n},t)}function oB(e,t){let n=SA(e)?new globalThis.RegExp(e):e;return X({[Z]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function sB(e){return lj(e)?e.allOf:Mj(e)?e.anyOf:Aj(e)?e.items??[]:[]}function cB(e){return sB(e)}function lB(e,t){return sj(e)?X(e.returns,t):cN(t)}var uB=class{constructor(e){this.schema=e}Decode(e){return new dB(this.schema,e)}},dB=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[KA].Encode(e(n)),Decode:e=>this.decode(t[KA].Decode(e))};return{...t,[KA]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[KA]:n}}Encode(e){return kj(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function fB(e){return new uB(e)}function pB(e={}){return X({[Z]:e[Z]??`Unsafe`},e)}function mB(e){return X({[Z]:`Void`,type:`void`},e)}var $=t({Any:()=>tN,Argument:()=>rN,Array:()=>nN,AsyncIterator:()=>iN,Awaited:()=>bF,BigInt:()=>JN,Boolean:()=>qN,Capitalize:()=>AR,Composite:()=>HF,Const:()=>$F,Constructor:()=>uN,ConstructorParameters:()=>eI,Date:()=>UF,Enum:()=>tI,Exclude:()=>EL,Extends:()=>yL,Extract:()=>ML,Function:()=>dN,Index:()=>TP,InstanceType:()=>IL,Instantiate:()=>gR,Integer:()=>_R,Intersect:()=>fF,Iterator:()=>AP,KeyOf:()=>PF,Literal:()=>KN,Lowercase:()=>jR,Mapped:()=>QP,Module:()=>tB,Never:()=>cN,Not:()=>nB,Null:()=>WF,Number:()=>YN,Object:()=>NP,Omit:()=>WR,Optional:()=>nF,Parameters:()=>rB,Partial:()=>hz,Pick:()=>iz,Promise:()=>PP,Readonly:()=>RP,ReadonlyOptional:()=>LL,Record:()=>XL,Recursive:()=>aB,Ref:()=>pF,RegExp:()=>oB,Required:()=>Tz,Rest:()=>cB,ReturnType:()=>lB,String:()=>XN,Symbol:()=>GF,TemplateLiteral:()=>oP,Transform:()=>fB,Tuple:()=>HP,Uint8Array:()=>qF,Uncapitalize:()=>MR,Undefined:()=>KF,Union:()=>vN,Unknown:()=>JF,Unsafe:()=>pB,Uppercase:()=>NR,Void:()=>mB}),hB={additionalProperties:!1},gB=$.String({pattern:`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,minLength:36,maxLength:36}),_B=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),vB=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),yB=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),bB=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),xB=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,SB=`^(?:${xB}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,CB=$.String({pattern:SB,minLength:8,maxLength:36}),wB=new RegExp(SB),TB=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/;function EB(e){return typeof e!=`string`||e.length>36?!1:wB.test(e)}function DB(e){if(typeof e!=`string`)return;if(TB.test(e)){let t=e.toLowerCase();return EB(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(EB(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:gB,code:CB,deviceUid:gB,deviceName:$.String({minLength:1,maxLength:64}),hostname:$.Optional($.String({minLength:1,maxLength:128})),platform:$.Optional($.String({minLength:1,maxLength:64})),publicKey:$.String({minLength:1,maxLength:256}),keyFingerprint:vB,clientTime:$.Integer(),hubNonce:$.Optional(yB)},hB),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:gB,deviceUid:gB,deviceName:$.String({minLength:1,maxLength:64}),hostname:$.Optional($.String({minLength:1,maxLength:128})),platform:$.Optional($.String({minLength:1,maxLength:64})),publicKey:$.String({minLength:1,maxLength:256}),keyFingerprint:vB,clientTime:$.Integer(),hubNonce:$.Optional(yB)},hB);var OB=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:gB,nonce:yB,issuedAt:$.Integer(),hubId:gB,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(vB),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},hB);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:gB,code:CB,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:gB,challenge:OB},hB),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:gB,nonce:yB,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},hB),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:gB,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},hB),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:gB,deviceUid:gB,deviceId:_B,pairingEpoch:gB,credentialId:gB,generation:$.Integer({minimum:1}),hubId:gB,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:bB,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(vB)},hB),$.Object({enrollmentId:gB,deviceUid:gB,keyFingerprint:vB,replaceKey:$.Optional($.Boolean())},hB),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:_B,pairingEpoch:gB,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},hB);var kB=$.Object({type:$.Literal(`pair.error`),v:$.Literal(1),code:$.Union([$.Literal(`code_invalid`),$.Literal(`code_expired`),$.Literal(`code_used`),$.Literal(`code_in_use`),$.Literal(`rate_limited`),$.Literal(`signature_invalid`),$.Literal(`clock_skew`),$.Literal(`paired_elsewhere`),$.Literal(`hub_required`),$.Literal(`fingerprint_mismatch`),$.Literal(`identity_conflict`),$.Literal(`enrollment_lost`),$.Literal(`enrollment_cancelled`),$.Literal(`already_issued`),$.Literal(`challenge_expired`)]),message:$.String({maxLength:512}),retryAfterMs:$.Optional($.Integer({minimum:1}))},hB);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:gB,code:CB,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},hB);var AB=$.Union([$.Literal(`open`),$.Literal(`awaiting_proof`),$.Literal(`awaiting_approval`),$.Literal(`approved`),$.Literal(`issued`),$.Literal(`connected`),$.Literal(`cancelled`),$.Literal(`expired`)]);$.Object({type:$.Literal(`pair.code-state`),v:$.Literal(1),codeId:gB,expiresAt:$.Integer(),phase:AB,enrollment:$.Optional($.Object({enrollmentId:gB,deviceUid:gB,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:vB,proofVerified:$.Boolean(),keyChanged:$.Boolean()},hB)),deviceId:$.Optional(_B),error:$.Optional(kB)},hB);function jB(e){if(typeof e!=`string`||e.length===0||e.length>2048)return{ok:!1,error:`origin: empty or too long`};if(/\s|\n|\r|\t/.test(e))return{ok:!1,error:`origin: whitespace not allowed`};let t;try{t=new URL(e)}catch{return{ok:!1,error:`origin: not a valid URL`}}return t.protocol!==`https:`&&!(t.protocol===`http:`&&/^(127\.0\.0\.1|\[::1\]|localhost)$/.test(t.hostname))?{ok:!1,error:`origin: HTTPS origin required`}:t.username||t.password?{ok:!1,error:`origin: userinfo not allowed`}:t.search||t.hash?{ok:!1,error:`origin: query/fragment not allowed`}:t.pathname!==`/`&&t.pathname!==``?{ok:!1,error:`origin: base path not allowed`}:{ok:!0,origin:t.origin,tunnelUrl:`${t.origin}/api/tunnel`}}function MB(e){if(e!==``&&/^[A-Za-z0-9_-]+$/.test(e))try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return}}var NB=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,PB=RegExp(`^${xB}$`),FB=/^sha256:[0-9a-f]{64}$/;function IB(e){let t=MB(e);if(!t||t.length>1024)return;let n;try{n=JSON.parse(new TextDecoder().decode(t))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(r.v!==2&&r.v!==3)return;let i=r.v===3?6:5;if(Object.keys(r).length!==i||typeof r.hub!=`string`)return;let a=jB(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&NB.test(r.id)&&typeof r.code==`string`&&PB.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!FB.test(r.kfp)?void 0:{v:3,hub:r.hub,id:r.id,code:r.code,exp:r.exp,kfp:r.kfp}:{v:2,hub:r.hub,id:r.id,code:r.code,exp:r.exp}}function LB(e,t=Date.now()){let n=IB(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function RB(e,t=Date.now()){let n;try{n=new URL(e)}catch{return}if(!/^\/pair\/?$/.test(n.pathname)||n.username||n.password||n.search||!n.hash.startsWith(`#offer=`))return;let r=LB(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function zB(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=RB(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=LB(e.hash.slice(7));return n&&n.hub!==e.origin?{error:`This pairing link does not belong to this hub. Open the original hub link instead.`}:{error:`Invalid pairing link. Use a complete link from the hub wizard.`}}let t=e.searchParams;if(!t.has(`code`)&&!t.has(`origin`)&&!t.has(`v`))return;let n=t.get(`code`),r=n===null?void 0:DB(n);if(e.username||e.password||e.hash||t.getAll(`code`).length!==1||!r||t.getAll(`v`).length!==1||t.get(`v`)!==`1`)return{error:`Invalid pairing link. Use a complete version 1 link from the hub wizard.`};if(t.has(`origin`))try{let n=new URL(t.get(`origin`));if(t.getAll(`origin`).length!==1||n.origin!==e.origin||n.pathname!==`/`||n.username||n.password||n.search||n.hash)throw Error(`origin mismatch`)}catch{return{error:`This pairing link does not belong to this hub. Open the original hub link instead.`}}return{code:r,origin:e.origin}}var BB=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,VB=e=>/^\/pair\/?$/.test(e.pathname)&&zB(e)===void 0?`/`:void 0,HB=4e3;async function UB(e){if(!e.needsCancel)return{closed:!0,confirmed:!0};let t,n=await Promise.race([e.cancel().catch(()=>`failed`),new Promise(n=>t=setTimeout(()=>n(`failed`),e.timeoutMs))]);return clearTimeout(t),{closed:n!==`issued`,confirmed:n===`cancelled`}}var WB={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},GB={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},KB={class:`who`},qB={key:0,class:`muted`},JB={key:1,class:`muted`},YB={class:`fp`},XB={class:`row`},ZB={class:`phase`},QB=[`onClick`],$B={key:2,class:`hint`},eV={class:`pair-steps`,"aria-label":`Pairing progress`},tV={class:`pair-grid`},nV={class:`pair-code-box`},rV={class:`pair-code`,"aria-label":`Pairing code`},iV={class:`pair-copy-actions`},aV=[`innerHTML`],oV={class:`pair-side`},sV={key:0,class:`hint`},cV={class:`pair-fingerprint`},lV={class:`fp`},uV={class:`pair-confirm`},dV={key:0,class:`pair-confirm warn`},fV=[`disabled`],pV=[`disabled`],mV={class:`hint`},hV=[`disabled`],gV={key:5,class:`error`,role:`alert`},_V={key:4},vV={class:`error`,role:`alert`},yV=N({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=k(`boot`),o=k(),s=k(),c=k(),l=k(``),u=k(!1),d=k(!1),f=k(!1),p=k(!1),m=k(!1),h=k(!1),g=k(),_=k([]),v=U(()=>{let e=s.value?.code??``;return!EB(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=U(()=>s.value?tb(s.value):``),b=U(()=>y.value?rA(y.value,148):``),x=U(()=>c.value?.enrollment?.keyFingerprint??``),S=U(()=>c.value?.deviceId??``);M(S,e=>{g.value?.(),e&&(g.value=M(()=>Cu.devices.value.find(t=>t.id===e)?.status,e=>{e===`online`&&(Y(`Device paired and online.`),g.value?.(),g.value=void 0)},{immediate:!0}))});async function C(e){a.value=`boot`,l.value=``,f.value=!1,p.value=!1,c.value=void 0,s.value=void 0,o.value?.close();let t=ib();o.value=t;try{let n=e?await nb.resolveCode(e):await nb.createCode();if(t.closed()){await nb.cancel(n.codeId).catch(()=>{Y(`The late pairing code could not be cancelled. Check device credentials before retrying.`)});return}if(s.value=n,a.value=`code`,e){let e=BB(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}sb(t,n.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{t.closed()||(l.value=e instanceof Error?e.message:String(e),a.value=`expired`)})}catch(e){l.value=e instanceof Error?e.message:String(e),a.value=`expired`}}async function ee(){let e=c.value,t=o.value;if(e?.enrollment&&t&&!u.value){u.value=!0,l.value=``;try{let t=await nb.approve(s.value.codeId,{enrollmentId:e.enrollment.enrollmentId,deviceUid:e.enrollment.deviceUid,keyFingerprint:e.enrollment.keyFingerprint,...p.value?{replaceKey:!0}:{}});c.value=t,(t.phase===`issued`||t.phase===`connected`)&&(a.value=`issued`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function w(e){if(!s.value)return`cancelled`;try{let t=await nb.cancel(s.value.codeId,void 0,e);return c.value=t,o.value&&(o.value.state=t),a.value=t.phase===`expired`?`expired`:`cancelled`,o.value?.close(),`cancelled`}catch(e){if(e instanceof Sl&&e.status===409&&String(e.code)===`already_issued`){let e=await nb.codeState(s.value.codeId).catch(()=>void 0);return e&&(c.value=e,o.value&&(o.value.state=e)),a.value=`issued`,l.value=`Credential already issued. Closing does not revoke it; choose Revoke explicitly if needed.`,`issued`}return l.value=e instanceof Error?e.message:String(e),`failed`}}let T=()=>w(!1),te=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function ne(){let e=S.value;if(e){u.value=!0;try{await nb.revoke(e,`user`),Y(`Issued credential revoked.`),r(`close`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function re(){if(s.value)try{await navigator.clipboard.writeText(s.value.code),m.value=!0,setTimeout(()=>m.value=!1,1500)}catch{l.value=`Clipboard unavailable; copy the code manually.`}}async function ie(){if(s.value)try{await navigator.clipboard.writeText(s.value.offerUrl??s.value.pairUrl),h.value=!0,setTimeout(()=>h.value=!1,1500)}catch{l.value=`Clipboard unavailable; copy the link manually.`}}async function ae(){if(!d.value){d.value=!0,u.value=!0;try{let e=await UB({needsCancel:!!s.value&&!te(),cancel:T,timeoutMs:HB});if(!e.closed)return;o.value?.close(),g.value?.(),e.confirmed||Y(`Pairing cancellation was not confirmed. The code expires on its own; check device credentials before retrying.`),r(`close`)}finally{d.value=!1,u.value=!1}}}t({close:ae});let oe;async function se(){try{_.value=(await nb.pending()).codes}catch{}}async function ce(e){s.value=void 0,c.value=void 0,l.value=``;let t=ib();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,sb(t,e.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{l.value=e instanceof Error?e.message:String(e)})}return Vr(()=>{if(se(),oe=setInterval(()=>void se(),3e3),i.handoff&&`error`in i.handoff){l.value=i.handoff.error,a.value=`expired`;return}C(i.handoff?.code)}),Wr(()=>{clearInterval(oe);let e=o.value;e&&!e.closed()&&s.value&&!te()&&w(!0).then(e=>{e!==`cancelled`&&Y(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:ks(ae,[`self`])},[z(`div`,WB,[z(`header`,null,[t[5]||=z(`h2`,{id:`pair-title`},`Pair a device`,-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:ae},[B(A(xl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(I(),R(uA,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):H(``,!0),_.value.length?(I(),L(`section`,GB,[t[6]||=z(`h3`,null,`Machines waiting for you`,-1),z(`ul`,null,[(I(!0),L(F,null,P(_.value,e=>(I(),L(`li`,{key:e.codeId},[z(`div`,KB,[z(`strong`,null,D(e.deviceName??`unnamed device`),1),e.hostname?(I(),L(`span`,qB,D(e.hostname),1)):H(``,!0),e.platform?(I(),L(`span`,JB,D(e.platform),1)):H(``,!0)]),z(`div`,YB,D(e.keyFingerprint),1),z(`div`,XB,[z(`span`,ZB,D(e.phase.replaceAll(`_`,` `)),1),z(`button`,{type:`button`,class:`small`,onClick:t=>ce(e)},`Review`,8,QB)])]))),128))]),t[7]||=z(`p`,{class:`hint`},` Compare each fingerprint with the machine's own terminal before approving. Codes are minted by the hub — nothing has to be copied to the machine. `,-1)])):H(``,!0),a.value===`boot`?(I(),L(`p`,$B,`Minting a pairing code…`)):s.value?(I(),L(F,{key:3},[z(`ol`,eV,[t[8]||=z(`li`,{class:E({on:!0})},`Code`,-1),z(`li`,{class:E({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),z(`li`,{class:E({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),z(`li`,{class:E({on:a.value===`issued`})},`Online`,2)]),z(`div`,tV,[z(`div`,nV,[z(`div`,rV,D(v.value),1),z(`div`,iV,[z(`button`,{type:`button`,class:`small`,onClick:re},[B(A(sc),{size:14}),V(` `+D(m.value?`Copied`:`Copy code`),1)]),z(`button`,{type:`button`,class:`small`,onClick:ie,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[B(A(sc),{size:14}),V(` `+D(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=z(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),z(`div`,{class:`pair-qr`,"aria-label":`Pairing QR code`,title:`Same offer link as Copy link: hub, code and expiry all in the #offer= fragment — it never reaches server logs`,innerHTML:b.value},null,8,aV)]),z(`div`,oV,[a.value===`code`||a.value===`proof`?(I(),L(`p`,sV,[B(A($c),{size:14,class:`spin`}),t[10]||=V(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(I(),L(F,{key:1},[z(`div`,cV,[t[11]||=z(`h3`,null,`Device key fingerprint`,-1),z(`code`,lV,D(x.value),1),t[12]||=z(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),z(`label`,uV,[j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[bs,f.value]]),t[13]||=V(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(I(),L(`label`,dV,[j(z(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[bs,p.value]]),B(A(ol),{size:14}),t[14]||=V(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):H(``,!0),z(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:ee},` Approve device `,8,fV),z(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:T},` Cancel pairing `,8,pV)],64)):a.value===`issued`?(I(),L(F,{key:2},[z(`p`,mV,[B(A(ic),{size:14}),t[15]||=V(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),z(`button`,{type:`button`,class:`small`,onClick:ae},`Close`),z(`button`,{type:`button`,class:`small danger`,disabled:!S.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:ne},` Revoke this credential `,8,hV)],64)):a.value===`cancelled`?(I(),L(F,{key:3},[t[16]||=z(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>C()},`Start over`)],64)):a.value===`expired`?(I(),L(F,{key:4},[t[17]||=z(`p`,{class:`hint`},`The pairing code expired.`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>C()},`New code`)],64)):H(``,!0),l.value?(I(),L(`p`,gV,D(l.value),1)):H(``,!0)])])],64)):(I(),L(`div`,_V,[z(`p`,vV,D(l.value||`This pairing link is unavailable.`),1),z(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>C()},`New code`)]))])]))}}),bV={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},xV={class:`hint`},SV={key:1,class:`hint`},CV=N({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>Cu.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>r(`close`),[`self`])},[z(`section`,bV,[z(`header`,null,[t[3]||=z(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[B(A(xl),{size:18})])]),i.value?(I(),L(F,{key:0},[z(`p`,null,[V(D(i.value.name)+` `,1),z(`code`,null,D(i.value.id),1)]),z(`p`,xV,D(i.value.status)+` · tunnel `+D(i.value.tunnel?.state??`disconnected`)+` · `+D(i.value.tunnel?.readerCount??0)+` readers `,1),B(gb,{device:i.value},null,8,[`device`])],64)):(I(),L(`p`,SV,`This device is no longer in the registry.`)),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),wV={id:`prompt-title`},TV=[`disabled`],EV={key:0,class:`hint`},DV={key:1},OV={key:0,class:`muted`},kV=[`placeholder`,`disabled`],AV=[`required`,`placeholder`,`aria-label`,`disabled`],jV={key:2,class:`message-error`,role:`alert`},MV=[`disabled`],NV=[`disabled`],PV=N({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=k(r.dialog.value??``),o=k(!1),s=k(``),c=k(),l=!!r.dialog.label;async function u(){if(!o.value&&(!l||r.dialog.optional||a.value.trim())){o.value=!0,s.value=``;try{await r.dialog.run(a.value.trim()),i(`close`)}catch(e){s.value=K(e)}finally{o.value=!1}}}return Vr(()=>void An(()=>(c.value?.focus(),c.value?.select()))),t({busy:o}),(t,n)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:n[4]||=ks(e=>!o.value&&i(`close`),[`self`])},[z(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:ks(u,[`prevent`])},[z(`header`,null,[z(`h2`,wV,D(e.dialog.title),1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:o.value,onClick:n[0]||=e=>i(`close`)},[B(A(xl),{size:18})],8,TV)]),e.dialog.hint?(I(),L(`p`,EV,D(e.dialog.hint),1)):H(``,!0),l?(I(),L(`label`,DV,[V(D(e.dialog.label)+` `,1),e.dialog.optional?(I(),L(`span`,OV,`(optional)`)):H(``,!0),e.dialog.multiline?j((I(),L(`textarea`,{key:1,ref_key:`input`,ref:c,"onUpdate:modelValue":n[1]||=e=>a.value=e,rows:`4`,placeholder:e.dialog.placeholder,disabled:o.value},null,8,kV)),[[ys,a.value]]):j((I(),L(`input`,{key:2,ref_key:`input`,ref:c,"onUpdate:modelValue":n[2]||=e=>a.value=e,maxlength:`100`,required:!e.dialog.optional,placeholder:e.dialog.placeholder,"aria-label":e.dialog.label,disabled:o.value},null,8,AV)),[[ys,a.value]])])):H(``,!0),s.value?(I(),L(`p`,jV,D(s.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,disabled:o.value,onClick:n[3]||=e=>i(`close`)},` Cancel `,8,MV),z(`button`,{class:E([`primary`,{danger:e.dialog.danger}]),disabled:o.value||l&&!e.dialog.optional&&!a.value.trim()},D(o.value?`Working…`:e.dialog.submit),11,NV)])],32)]))}}),FV={class:`modal model-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Model picker`},IV={class:`eyebrow`},LV={class:`model-list`},RV={key:0,class:`model-row off-catalog`,"aria-disabled":`true`},zV=[`src`],BV=[`onClick`],VV=[`src`],HV={class:`hint`},UV=N({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=k(``),i=k();Vr(()=>void An(()=>i.value?.focus()));let a=U(()=>qu.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),o=e=>{let t=td.value;return!!t&&e.id===t.modelId&&e.provider===t.provider},s=U(()=>{let e=td.value;return e&&!qu.value.some(t=>t.provider===e.provider&&t.id===e.modelId)?e:void 0});async function c(e){await ud(()=>Ru.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await ad(),Y(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>n(`close`),[`self`])},[z(`section`,FV,[z(`header`,null,[z(`div`,null,[z(`span`,IV,`PER AGENT · `+D(A(ju)?.name??A(ju)?.id),1),t[3]||=z(`h2`,null,`Choose a model`,-1)]),z(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[B(A(xl),{size:18})])]),j(z(`input`,{ref_key:`searchInput`,ref:i,"onUpdate:modelValue":t[1]||=e=>r.value=e,placeholder:`Search models or tiers…`,"aria-label":`Search models`},null,512),[[ys,r.value]]),z(`div`,LV,[s.value?(I(),L(`div`,RV,[z(`img`,{src:A(md)(s.value.modelId),alt:``},null,8,zV),z(`div`,null,[z(`strong`,null,D(s.value.modelId),1),z(`small`,null,D(s.value.provider)+` / current · not in this device's catalog`,1)])])):H(``,!0),(I(!0),L(F,null,P(a.value,e=>(I(),L(`button`,{key:`${e.provider}/${e.id}`,class:E({selected:o(e)}),onClick:t=>c(e)},[z(`img`,{src:A(md)(e.id),alt:``},null,8,VV),z(`div`,null,[z(`strong`,null,D(e.name),1),z(`small`,null,D(e.tier)+` / `+D(e.provider)+` / `+D(A(fd)(e.contextWindow))+` context`,1)]),o(e)?(I(),R(A(tc),{key:0,size:18})):H(``,!0)],10,BV))),128))]),z(`p`,HV,`Models available on `+D(A(ju)?.id)+`. Provider keys stay on the device.`,1)])]))}}),WV={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},GV={class:`dialog-head`},KV={class:`dialog-body`},qV={class:`n`},JV={class:`body`},YV={class:`help-callout`},XV={class:`dialog-foot`},ZV={class:`right`},QV=N({__name:`HelpDialog`,setup(e){let t=[{title:`Pick a device, start a session`,body:`Every device in the tree runs dpi-backend. A session gets its own SQLite database on that device, in the directory you choose.`},{title:`Send work, then close the browser`,body:`The device owns the run. Reopening restores committed messages, state and live progress.`},{title:`Change state and fork`,body:`Edit App State by hand or through the agent. Every session and fork on a device shares it.`},{title:`Interrupt deliberately`,body:`Interrupt stops foreground work and owned subagents. Background jobs continue. Stop all includes them.`},{title:`Explore the boundaries`,body:`Queue a follow-up, steer after tools, wait for approval, compact context, reset or inspect raw state.`},{title:`Restart a device`,body:`Its tree dims and shows the restart command. Checkpointed jobs recover on boot. Replay-safe tools may rerun. Other interrupted tools return an error.`}];return(e,n)=>(I(),L(`div`,{class:`scrim`,onClick:n[2]||=ks(e=>A(J).dialog=void 0,[`self`])},[z(`section`,WV,[z(`div`,GV,[n[3]||=z(`div`,null,[z(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),z(`h3`,{id:`help-title`},`What makes this durable?`)],-1),z(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>A(J).dialog=void 0},[B(A(xl),{size:18})])]),z(`div`,KV,[(I(),L(F,null,P(t,(e,t)=>z(`div`,{key:e.title,class:`help-step`},[z(`span`,qV,D(String(t+1).padStart(2,`0`)),1),z(`div`,null,[z(`b`,null,D(e.title),1),z(`div`,JV,D(e.body),1)])])),64)),z(`div`,YV,[B(A(Oc),{size:18}),n[4]||=z(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),z(`div`,XV,[z(`div`,ZV,[z(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>A(J).dialog=void 0},`Close`)])])])]))}}),$V=Wt({needed:!1,busy:!1,error:``}),eH=new Set,tH=e=>{let t=[...eH];eH=new Set;for(let n of t)n(e)},nH=()=>new Promise(e=>eH.add(e));async function rH(e){if($V.busy||!e)return!1;$V.busy=!0,$V.error=``;try{let t=await fetch(`/api/session`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})});return await t.text().catch(()=>``),t.ok?($V.needed=!1,tH(!0),!0):($V.error=t.status===401?`That token was not accepted.`:t.status===429?`Too many attempts. Wait a minute and try again.`:`Login failed (${t.status}).`,!1)}catch{return $V.error=`Cannot reach the hub.`,!1}finally{$V.busy=!1}}var iH=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function aH(e){return(async(t,n)=>{let r=()=>e(t,n),i=await r();if(i.status!==401||iH(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;$V.needed=!0;let a=await i.text().catch(()=>``);return await nH()?r():new Response(a,{status:i.status,headers:i.headers})})}function oH(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=aH(window.fetch.bind(window)))}var sH={class:`login-veil`,"data-testid":`login-card`},cH=[`disabled`],lH={key:0,class:`message-error`,role:`alert`},uH=[`disabled`],dH=N({__name:`LoginCard`,setup(e){let t=k(``),n=k();async function r(){if($V.busy||!t.value.trim())return;let e=await rH(t.value.trim());t.value=``,e&&n.value?.blur()}return Vr(()=>void An(()=>n.value?.focus())),(e,i)=>(I(),L(`div`,sH,[z(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:ks(r,[`prevent`])},[i[2]||=z(`header`,null,[z(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=z(`p`,{class:`hint`},[V(` This hub is locked. Sign in with the token from its `),z(`code`,null,`admin.token`),V(` file. `)],-1),i[4]||=z(`label`,{for:`admin-token`},`Admin token`,-1),j(z(`input`,{id:`admin-token`,ref_key:`input`,ref:n,"onUpdate:modelValue":i[0]||=e=>t.value=e,type:`password`,name:`admin-token`,autocomplete:`off`,spellcheck:`false`,placeholder:`adm_…`,"aria-label":`Admin token`,disabled:A($V).busy,onKeydown:i[1]||=js(e=>A($V).error=``,[`esc`])},null,40,cH),[[ys,t.value]]),A($V).error?(I(),L(`p`,lH,D(A($V).error),1)):H(``,!0),z(`footer`,null,[z(`button`,{class:`primary`,type:`submit`,disabled:A($V).busy||!t.value.trim()},D(A($V).busy?`Checking…`:`Sign in`),9,uH)])],32)]))}}),fH={key:0,class:`toast`,role:`status`},pH=N({__name:`Toast`,setup(e){return(e,t)=>(I(),R(bo,{name:`toast`},{default:Hn(()=>[A(J).toast?(I(),L(`div`,fH,[B(A(tc),{size:18}),V(D(A(J).toast),1)])):H(``,!0)]),_:1}))}});function mH(e,t=!1){return e.kind===`pair`?`pair`:e.kind===`prompt`&&t?`keep`:`close`}var hH={class:`shell`,"data-testid":`app-shell`},gH={key:0,class:`error-banner`,role:`alert`},_H={key:4,class:`welcome`,"data-testid":`welcome-empty`},vH=[`disabled`],yH={class:`welcome-features`},bH={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},xH={class:`full-directory`},SH=N({__name:`App`,setup(e){let t=()=>Cu.devices.value.filter(e=>e.status===`online`).length,n=k(),r=k();function i(){J.dialog={kind:`new-session`,deviceId:q.value?.deviceId}}function a(e){let t=J.dialog?void 0:Dd(e);if(t)return e.preventDefault(),t===`tree`?Cd():wd();if(e.key===`Escape`){if(J.dialog){let e=mH(J.dialog,r.value?.busy??!1);e===`pair`?n.value?.close():e===`close`&&(J.dialog=void 0);return}!e.repeat&&!e.isComposing&&Qu.value&&(e.preventDefault(),_d()),J.drawer=!1,J.inspectorOverlay=!1}}function o(e){let t=e.clientX,n=Du.value,r=e=>Du.value=Math.max(220,Math.min(560,n+e.clientX-t)),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}return Vr(()=>sf()),Vr(()=>{document.addEventListener(`keydown`,a),Gu()}),Wr(()=>{xu.stop(),document.removeEventListener(`keydown`,a)}),(e,a)=>(I(),L(`div`,hH,[B(Hd,{onNewSession:i}),A(J).error?(I(),L(`div`,gH,[B(A(Oc),{size:18}),z(`span`,null,D(A(J).error),1),z(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:a[0]||=e=>A(J).error=``},`×`)])):H(``,!0),z(`main`,{class:`net-workspace`,style:ge({"--tree-w":`${A(Du)}px`})},[B(xp),A(Ou).tree?(I(),L(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:ks(o,[`prevent`])},null,32)):H(``,!0),A(J).drawer?(I(),L(`div`,{key:1,class:`tree-backdrop`,onClick:a[1]||=e=>A(J).drawer=!1})):H(``,!0),A(q)&&A(ju)&&A(Mu)?(I(),L(F,{key:2},[B(ek),A(J).inspectorOverlay?(I(),L(`div`,{key:0,class:`inspector-backdrop`,onClick:a[2]||=e=>A(Sd)()})):H(``,!0),(I(),R(Cy,{key:`${A(q).deviceId}/${A(q).sessionId}`}))],64)):A(q)&&A(ju)?(I(),R(uk,{key:3,device:A(ju)},null,8,[`device`])):(I(),L(`section`,_H,[a[14]||=z(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),a[15]||=z(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),a[16]||=z(`h1`,null,[V(`Close the tab.`),z(`br`),V(`The work continues.`)],-1),a[17]||=z(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),z(`button`,{class:`primary`,disabled:!t(),onClick:i},[B(A(Xc),{size:18}),V(D(A(Cu).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,vH),z(`div`,yH,[z(`span`,null,[B(A(fc),{size:18}),a[11]||=V(`SQLite on each device`,-1)]),z(`span`,null,[B(A(Cc),{size:18}),a[12]||=V(`Branch any agent`,-1)]),z(`span`,null,[B(A(Vs),{size:18}),a[13]||=V(`Watch from anywhere`,-1)])])]))],4),B(Gd),A(J).dialog?.kind===`pair`?(I(),R(yV,{key:1,ref_key:`pairWizard`,ref:n,handoff:A(J).dialog.handoff,onClose:a[3]||=e=>A(J).dialog=void 0},null,8,[`handoff`])):H(``,!0),A(J).dialog?.kind===`credentials`?(I(),R(CV,{key:2,"device-id":A(J).dialog.deviceId,onClose:a[4]||=e=>A(J).dialog=void 0},null,8,[`device-id`])):H(``,!0),A(J).dialog?.kind===`new-session`?(I(),R(jk,{key:3,"device-id":A(J).dialog.deviceId,onClose:a[5]||=e=>A(J).dialog=void 0},null,8,[`device-id`])):A(J).dialog?.kind===`prompt`?(I(),R(PV,{key:4,ref_key:`promptDialog`,ref:r,dialog:A(J).dialog,onClose:a[6]||=e=>A(J).dialog=void 0},null,8,[`dialog`])):A(J).dialog?.kind===`models`?(I(),R(UV,{key:5,onClose:a[7]||=e=>A(J).dialog=void 0})):A(J).dialog?.kind===`path`?(I(),L(`div`,{key:6,class:`modal-backdrop`,onClick:a[10]||=ks(e=>A(J).dialog=void 0,[`self`])},[z(`section`,bH,[z(`header`,null,[a[18]||=z(`h2`,{id:`path-title`},`Working directory`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:a[8]||=e=>A(J).dialog=void 0},[B(A(xl),{size:18})])]),z(`code`,xH,D(A(J).dialog.path),1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:a[9]||=e=>A(J).dialog=void 0},`Close`)])])])):A(J).dialog?.kind===`help`?(I(),R(QV,{key:7})):H(``,!0),A($V).needed?(I(),R(dH,{key:8})):H(``,!0),B(pH)]))}});oH();var CH=new URL(window.location.href);if(/^\/pair\/?$/.test(CH.pathname)){let e=zB(CH);e?(CH.search=``,CH.hash=``,window.history.replaceState(window.history.state,``,CH),J.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,VB(CH))}Fs(SH).mount(`#app`);
73
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Lm(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Rm(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Lm(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Rm(e);if(i===null)return Lm(n);e=i;let a=`<img src="${e}" alt="${Lm(n)}"`;return t&&(a+=` title="${Lm(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Lm(e.text)}},Jm=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Ym=class e{options;renderer;textRenderer;constructor(e){this.options=e||wp,this.options.renderer=this.options.renderer||new qm,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Jm}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Xm=class{options;block;constructor(e){this.options=e||wp}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Km.lex:Km.lexInline}provideParser(e=this.block){return e?Ym.parse:Ym.parseInline}},Zm=new class{defaults=Cp();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ym;Renderer=qm;TextRenderer=Jm;Lexer=Km;Tokenizer=Gm;Hooks=Xm;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new qm(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Gm(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Xm;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Xm.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Xm.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Km.lex(e,t??this.defaults)}parser(e,t){return Ym.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Km.lex:Km.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Ym.parse:Ym.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Km.lex:Km.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Ym.parse:Ym.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
74
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Lm(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Qm(e,t){return Zm.parse(e,t)}Qm.options=Qm.setOptions=function(e){return Zm.setOptions(e),Qm.defaults=Zm.defaults,Tp(Qm.defaults),Qm},Qm.getDefaults=Cp,Qm.defaults=wp,Qm.use=function(...e){return Zm.use(...e),Qm.defaults=Zm.defaults,Tp(Qm.defaults),Qm},Qm.walkTokens=function(e,t){return Zm.walkTokens(e,t)},Qm.parseInline=Zm.parseInline,Qm.Parser=Ym,Qm.parser=Ym.parse,Qm.Renderer=qm,Qm.TextRenderer=Jm,Qm.Lexer=Km,Qm.lexer=Km.lex,Qm.Tokenizer=Gm,Qm.Hooks=Xm,Qm.parse=Qm,Qm.options,Qm.setOptions,Qm.use,Qm.walkTokens,Qm.parseInline,Ym.parse,Km.lex;function $m(e,t){this.v=e,this.k=t}function eh(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function th(e){if(Array.isArray(e))return e}function nh(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function rh(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
75
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ih(e,t){return th(e)||nh(e,t)||ah(e,t)||rh()}function ah(e,t){if(e){if(typeof e==`string`)return eh(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?eh(e,t):void 0}}function oh(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof $m;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}oh.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},oh.prototype.next=function(e){return this._invoke(`next`,e)},oh.prototype.throw=function(e){return this._invoke(`throw`,e)},oh.prototype.return=function(e){return this._invoke(`return`,e)};var sh=Object.entries,ch=Object.setPrototypeOf,lh=Object.isFrozen,uh=Object.getPrototypeOf,dh=Object.getOwnPropertyDescriptor,fh=Object.freeze,ph=Object.seal,mh=Object.create,hh=typeof Reflect<`u`&&Reflect,gh=hh.apply,_h=hh.construct;fh||=function(e){return e},ph||=function(e){return e},gh||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},_h||=function(e){return new e(...[...arguments].slice(1))};var vh=Rh(Array.prototype.forEach);Array.prototype.indexOf;var yh=Rh(Array.prototype.lastIndexOf),bh=Rh(Array.prototype.pop),xh=Rh(Array.prototype.push);Array.prototype.slice;var Sh=Rh(Array.prototype.splice),Ch=Array.isArray,wh=Rh(String.prototype.toLowerCase),Th=Rh(String.prototype.toString),Eh=Rh(String.prototype.match),Dh=Rh(String.prototype.replace),Oh=Rh(String.prototype.indexOf),kh=Rh(String.prototype.trim),Ah=Rh(Number.prototype.toString),jh=Rh(Boolean.prototype.toString),Mh=typeof BigInt>`u`?null:Rh(BigInt.prototype.toString),Nh=typeof Symbol>`u`?null:Rh(Symbol.prototype.toString),Ph=Rh(Object.prototype.hasOwnProperty),Fh=Rh(Object.prototype.toString),Ih=Rh(RegExp.prototype.test),Lh=zh(TypeError);function Rh(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return gh(e,t,n)}}function zh(e){return function(){return _h(e,[...arguments])}}function Bh(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wh;if(ch&&ch(e,null),!Ch(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(lh(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Vh(e){for(let t=0;t<e.length;t++)Ph(e,t)||(e[t]=null);return e}function Hh(e){let t=mh(null);for(let r of sh(e)){var n=ih(r,2);let i=n[0],a=n[1];Ph(e,i)&&(t[i]=Ch(a)?Vh(a):a&&typeof a==`object`&&a.constructor===Object?Hh(a):a)}return t}function Uh(e){switch(typeof e){case`string`:return e;case`number`:return Ah(e);case`boolean`:return jh(e);case`bigint`:return Mh?Mh(e):`0`;case`symbol`:return Nh?Nh(e):`Symbol()`;case`undefined`:return Fh(e);case`function`:case`object`:{if(e===null)return Fh(e);let t=e,n=Wh(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Fh(e)}return Fh(e)}default:return Fh(e)}}function Wh(e,t){for(;e!==null;){let n=dh(e,t);if(n){if(n.get)return Rh(n.get);if(typeof n.value==`function`)return Rh(n.value)}e=uh(e)}function n(){return null}return n}function Gh(e){try{return Ih(e,``),!0}catch{return!1}}var Kh=fh(`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`.split(`.`)),qh=fh(`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`.split(`.`)),Jh=fh([`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`]),Yh=fh([`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`]),Xh=fh(`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`.split(`.`)),Zh=fh([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Qh=fh([`#text`]),$h=fh(`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`.split(`.`)),eg=fh(`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.dominant-baseline.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.pointer-events.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-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.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`.split(`.`)),tg=fh(`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`.split(`.`)),ng=fh([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),rg=ph(/{{[\w\W]*|^[\w\W]*}}/g),ig=ph(/<%[\w\W]*|^[\w\W]*%>/g),ag=ph(/\${[\w\W]*/g),og=ph(/^data-[\-\w.\u00B7-\uFFFF]+$/),sg=ph(/^aria-[\-\w]+$/),cg=ph(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lg=ph(/^(?:\w+script|data):/i),ug=ph(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),dg=ph(/^html$/i),fg=ph(/^[a-z][.\w]*(-[.\w]+)+$/i),pg=ph(/<[/\w!]/g),mg=ph(/<[/\w]/g),hg=ph(/<\/no(script|embed|frames)/i),gg=ph(/\/>/i),_g={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},vg=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],yg=fh(Bh({},vg)),bg=function(){let e={};return vh(vg,t=>{e[t]=ph(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),fh(e)}(),xg=function(){return typeof window>`u`?null:window},Sg=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Cg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wg=function(e,t,n,r){return Ph(e,t)&&Ch(e[t])?Bh(r.base?Hh(r.base):{},e[t],r.transform):n},Tg=function(e,t,n){let r=Ph(e,t)?e[t]:void 0;return r&&typeof r==`object`?Hh(r):n()};function Eg(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xg(),t=e=>Eg(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==_g.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Wh(d,`cloneNode`),p=Wh(d,`remove`),m=Wh(d,`removeAttributeNode`),h=Wh(d,`nextSibling`),g=Wh(d,`childNodes`),_=Wh(d,`parentNode`),v=Wh(d,`shadowRoot`),y=Wh(d,`attributes`),b=o&&o.prototype?Wh(o.prototype,`nodeType`):null,x=o&&o.prototype?Wh(o.prototype,`nodeName`):null,S=o&&o.prototype?Wh(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},ee=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let w,T=``,te,ne=!1,re=0,ie=function(){if(re>0)throw Lh(`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.`)},ae=function(e){ie(),re++;try{return w.createHTML(e)}finally{re--}},oe=function(e){ie(),re++;try{return w.createScriptURL(e)}finally{re--}},se=function(){return ne||=(te=Sg(u,i),!0),te},ce=n,le=ce.implementation,ue=ce.createNodeIterator,de=ce.createDocumentFragment,fe=ce.getElementsByTagName,pe=r.importNode,me=Cg();t.isSupported=typeof sh==`function`&&typeof _==`function`&&le&&le.createHTMLDocument!==void 0;let he=rg,ge=ig,_e=ag,ve=og,ye=sg,be=lg,E=ug,xe=fg,Se=cg,Ce=null,we=Bh({},[...Kh,...qh,...Jh,...Xh,...Qh]),Te=null,Ee=Bh({},[...$h,...eg,...tg,...ng]),De=Object.seal(mh(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}})),Oe=null,ke=null,Ae=Object.seal(mh(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),D=!0,je=!0,Me=!1,Ne=!0,Pe=!1,Fe=!0,O=!1,Ie=!1,Le=null,Re=null,ze=!1,Be=!1,Ve=!1,He=!1,Ue=!0,We=!1,Ge=`user-content-`,Ke=!0,qe=!1,Je={},Ye=null,Xe=Bh({},`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`.split(`.`)),Ze=null,Qe=Bh({},[`audio`,`video`,`img`,`source`,`image`,`track`]),$e=null,et=Bh({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),tt=`http://www.w3.org/1998/Math/MathML`,nt=`http://www.w3.org/2000/svg`,rt=`http://www.w3.org/1999/xhtml`,it=rt,at=!1,ot=null,st=Bh({},[tt,nt,rt],Th),ct=fh([`mi`,`mo`,`mn`,`ms`,`mtext`]),lt=Bh({},ct),ut=fh([`annotation-xml`]),dt=Bh({},ut),ft=Bh({},[`title`,`style`,`font`,`a`,`script`]),pt=null,mt=[`application/xhtml+xml`,`text/html`],ht=null,gt=null,_t=n.createElement(`form`),vt=function(e){return e instanceof RegExp||e instanceof Function},yt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(gt&&gt===e)return;(!e||typeof e!=`object`)&&(e={}),e=Hh(e),pt=mt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ht=pt===`application/xhtml+xml`?Th:wh,Ce=wg(e,`ALLOWED_TAGS`,we,{transform:ht}),Te=wg(e,`ALLOWED_ATTR`,Ee,{transform:ht}),ot=wg(e,`ALLOWED_NAMESPACES`,st,{transform:Th}),$e=wg(e,`ADD_URI_SAFE_ATTR`,et,{transform:ht,base:et}),Ze=wg(e,`ADD_DATA_URI_TAGS`,Qe,{transform:ht,base:Qe}),Ye=wg(e,`FORBID_CONTENTS`,Xe,{transform:ht}),Oe=wg(e,`FORBID_TAGS`,Hh({}),{transform:ht}),ke=wg(e,`FORBID_ATTR`,Hh({}),{transform:ht}),Je=Ph(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Hh(e.USE_PROFILES):e.USE_PROFILES:!1,D=e.ALLOW_ARIA_ATTR!==!1,je=e.ALLOW_DATA_ATTR!==!1,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Pe=e.SAFE_FOR_TEMPLATES||!1,Fe=e.SAFE_FOR_XML!==!1,O=e.WHOLE_DOCUMENT||!1,Be=e.RETURN_DOM||!1,Ve=e.RETURN_DOM_FRAGMENT||!1,He=e.RETURN_TRUSTED_TYPE||!1,ze=e.FORCE_BODY||!1,Ue=e.SANITIZE_DOM!==!1,We=e.SANITIZE_NAMED_PROPS||!1,Ke=e.KEEP_CONTENT!==!1,qe=e.IN_PLACE||!1,Se=Gh(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:cg,it=typeof e.NAMESPACE==`string`?e.NAMESPACE:rt,lt=Tg(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>Bh({},ct)),dt=Tg(e,`HTML_INTEGRATION_POINTS`,()=>Bh({},ut));let t=Tg(e,`CUSTOM_ELEMENT_HANDLING`,()=>mh(null));if(De=mh(null),Ph(t,`tagNameCheck`)&&vt(t.tagNameCheck)&&(De.tagNameCheck=t.tagNameCheck),Ph(t,`attributeNameCheck`)&&vt(t.attributeNameCheck)&&(De.attributeNameCheck=t.attributeNameCheck),Ph(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(De.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),ph(De),Pe&&(je=!1),Ve&&(Be=!0),Je&&(Ce=Bh({},Qh),Te=mh(null),Je.html===!0&&(Bh(Ce,Kh),Bh(Te,$h)),Je.svg===!0&&(Bh(Ce,qh),Bh(Te,eg),Bh(Te,ng)),Je.svgFilters===!0&&(Bh(Ce,Jh),Bh(Te,eg),Bh(Te,ng)),Je.mathMl===!0&&(Bh(Ce,Xh),Bh(Te,tg),Bh(Te,ng))),Ae.tagCheck=null,Ae.attributeCheck=null,Ph(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Ae.tagCheck=e.ADD_TAGS:Ch(e.ADD_TAGS)&&(Ce===we&&(Ce=Hh(Ce)),Bh(Ce,e.ADD_TAGS,ht))),Ph(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Ae.attributeCheck=e.ADD_ATTR:Ch(e.ADD_ATTR)&&(Te===Ee&&(Te=Hh(Te)),Bh(Te,e.ADD_ATTR,ht))),Ph(e,`ADD_FORBID_CONTENTS`)&&Ch(e.ADD_FORBID_CONTENTS)&&(Ye===Xe&&(Ye=Hh(Ye)),Bh(Ye,e.ADD_FORBID_CONTENTS,ht)),Ke&&(Ce[`#text`]=!0),O&&Bh(Ce,[`html`,`head`,`body`]),Ce.table&&(Bh(Ce,[`tbody`]),delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Lh(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Lh(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=w;w=e.TRUSTED_TYPES_POLICY;try{T=ae(``)}catch(e){throw w=t,e}}else e.TRUSTED_TYPES_POLICY===null?(w=void 0,T=``):(w===void 0&&(w=se()),w&&typeof T==`string`&&(T=ae(``)));fh&&fh(e),gt=e},bt=Bh({},[...qh,...Jh,...Yh]),xt=Bh({},[...Xh,...Zh]),St=function(e,t,n){return t.namespaceURI===rt?e===`svg`:t.namespaceURI===tt?e===`svg`&&(n===`annotation-xml`||lt[n]):!!bt[e]},Ct=function(e,t,n){return t.namespaceURI===rt?e===`math`:t.namespaceURI===nt?e===`math`&&dt[n]:!!xt[e]},wt=function(e,t,n){return t.namespaceURI===nt&&!dt[n]||t.namespaceURI===tt&&!lt[n]?!1:!xt[e]&&(ft[e]||!bt[e])},Tt=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:it,tagName:`template`});let n=wh(e.tagName),r=wh(t.tagName);return ot[e.namespaceURI]?e.namespaceURI===nt?St(n,t,r):e.namespaceURI===tt?Ct(n,t,r):e.namespaceURI===rt?wt(n,t,r):!!(pt===`application/xhtml+xml`&&ot[e.namespaceURI]):!1},Et=function(e){xh(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw Lh(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Dt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Ot=function(e){jt(e);let t=g(e);if(t){let e=[];vh(t,t=>{xh(e,t)}),vh(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&Dt(e,r,i)}},kt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}xh(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Be||Ve)try{Et(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},At=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||Te[ht(i)]||Dt(e,r,i)}},jt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===_g.element&&At(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Mt=function(e,t){return Fe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Nt=function(e){if(!Fe)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===_g.processingInstruction||n===_g.comment&&Ih(mg,e.data)){try{p(e)}catch{}continue}if(n===_g.element){let t=e,n=ht(ee(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Mt(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Pt=function(e){let t=null,r=null;if(ze)e=`<remove></remove>`+e;else{let t=Eh(e,/^[\r\n\t ]+/);r=t&&t[0]}pt===`application/xhtml+xml`&&it===rt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=w?ae(e):e;if(it===rt)try{t=new l().parseFromString(i,pt)}catch{}if(!t||!t.documentElement){t=le.createDocument(it,`template`,null);try{t.documentElement.innerHTML=at?T:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),it===rt?fe.call(t,O?`html`:`body`)[0]:O?t.documentElement:a},Ft=function(e){let t=S?S(e):e.ownerDocument;return ue.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},It=function(e){return e=Dh(e,he,` `),e=Dh(e,ge,` `),e=Dh(e,_e,` `),e},Lt=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=ue.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=It(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&vh(i,e=>{zt(e.content)&&Lt(e.content)})},Rt=function(e){let t=x?x(e):null;return typeof t!=`string`||ht(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},zt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===_g.documentFragment}catch{return!1}},Bt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Vt(e,n,r){e.length!==0&&vh(e,e=>{e.call(t,n,r,gt)})}let Ht=function(e,t){return!!(Fe&&e.hasChildNodes()&&!Bt(e.firstElementChild)&&Ih(pg,e.textContent)&&Ih(pg,e.innerHTML)||Fe&&e.namespaceURI===rt&&yg[t]&&(Bt(e.firstElementChild)||typeof e.textContent==`string`&&Ih(bg[t],e.textContent))||e.nodeType===_g.processingInstruction||Fe&&e.nodeType===_g.comment&&Ih(mg,e.data))},Ut=function(e,t){return e instanceof RegExp?Ih(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Wt=function(e,t,n){if(!Oe[t]&&Xt(t)&&Ut(De.tagNameCheck,t))return!1;if(Ke&&!Ye[t]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return Et(e),!0},Gt=function(e,t,n,r){return e.length===0?t:t===n||t===r?Hh(t):t},Kt=function(e,t){return e===t||_(e)!==null?!1:(qe&&jt(e),!0)},qt=function(e,n){if(Vt(me.beforeSanitizeElements,e,null),Kt(e,n))return!0;if(Rt(e))return Et(e),!0;let r=ht(ee(e));if(Ce=Gt(me.uponSanitizeElement,Ce,we,Le),Vt(me.uponSanitizeElement,e,{tagName:r,allowedTags:Ce}),Kt(e,n))return!0;if(Ht(e,r))return Et(e),!0;if(Oe[r]||!(Ae.tagCheck instanceof Function&&Ae.tagCheck(r))&&!Ce[r]){let t=Wt(e,r,n);return t===!1&&(Vt(me.afterSanitizeElements,e,null),Kt(e,n))?!0:t}if(C(e)===_g.element&&!Tt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Ih(hg,e.innerHTML))return Et(e),!0;if(Pe&&e.nodeType===_g.text){let n=It(e.textContent);e.textContent!==n&&(xh(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Vt(me.afterSanitizeElements,e,null),Kt(e,n)},Jt=function(e,t,r){if(ke[t]||Mt(t,e)||Ue&&(t===`id`||t===`name`)&&(r in n||r in _t))return!1;let i=Te[t]||Ae.attributeCheck instanceof Function&&Ae.attributeCheck(t,e);return je&&Ih(ve,t)||D&&Ih(ye,t)?!0:i?$e[t]||Ih(Se,Dh(r,E,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Oh(r,`data:`)===0&&Ze[e]||Me&&!Ih(be,Dh(r,E,``))?!0:!r:Xt(e)&&Ut(De.tagNameCheck,e)&&Ut(De.attributeNameCheck,t,e)||t===`is`&&De.allowCustomizedBuiltInElements&&Ut(De.tagNameCheck,r)},Yt=Bh({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Xt=function(e){return!Yt[wh(e)]&&Ih(xe,e)},Zt=function(e,t,n,r){if(w&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ae(r);case`TrustedScriptURL`:return oe(r)}return r},Qt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Rt(e)||(Et(e),!1)}catch{return kt(t,e),!1}},$t=function(e,n){if(Vt(me.beforeSanitizeAttributes,e,null),Kt(e,n))return;let r=e.attributes;if(!r||Rt(e))return;Te=Gt(me.uponSanitizeAttribute,Te,Ee,Re);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:Te,forceKeepAttr:void 0},a=r.length,o=ht(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=ht(s),d=l,f=s===`value`?d:kh(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Vt(me.uponSanitizeAttribute,e,i),f=i.attrValue,We&&(u===`id`||u===`name`)&&Oh(f,Ge)!==0&&(kt(s,e,n),f=Ge+f,p=!0),Fe&&Ih(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){kt(s,e,n);continue}if(u===`attributename`&&Eh(f,`href`)){kt(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){kt(s,e,n);continue}if(!Ne&&Ih(gg,f)){kt(s,e,n);continue}if(Pe&&(f=It(f)),!Jt(o,u,f)){kt(s,e,n);continue}f=Zt(o,u,c,f),f!==d&&Qt(e,s,c,f)&&p&&bh(t.removed)}}Vt(me.afterSanitizeAttributes,e,null),Kt(e,n)},en=function(e){let t=null,n=Ft(e);for(Vt(me.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Vt(me.uponSanitizeShadowNode,t,null),qt(t,e),$t(t,e),zt(t.content)&&en(t.content),C(t)===_g.element){let e=v(t);zt(e)&&(tn(e),en(e))}Vt(me.afterSanitizeShadowDOM,e,null)},tn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){en(e.shadow);continue}let n=e.node,r=C(n)===_g.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&ht(e)===`template`){let e=n.content;zt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);zt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(at=!e,at&&(e=`<!-->`),typeof e!=`string`&&!Bt(e)&&(e=Uh(e),typeof e!=`string`))throw Lh(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ie?(Ce=Le,Te=Re):yt(n),(me.uponSanitizeElement.length>0||me.uponSanitizeAttribute.length>0)&&(Ce=Hh(Ce)),me.uponSanitizeAttribute.length>0&&(Te=Hh(Te)),t.removed=[];let c=qe&&typeof e!=`string`&&Bt(e);if(c){Nt(e);let t=ee(e);if(typeof t==`string`){let n=ht(t);if(!Ce[n]||Oe[n])throw Ot(e),Lh(`root node is forbidden and cannot be sanitized in-place`)}if(Rt(e))throw Ot(e),Lh(`root node is clobbered and cannot be sanitized in-place`);try{tn(e)}catch(t){throw Ot(e),t}}else if(Bt(e))i=Pt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===_g.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),tn(i);else{if(!Be&&!Pe&&!O&&e.indexOf(`<`)===-1)return w&&He?ae(e):e;if(i=Pt(e),!i)return Be?null:He?T:``}i&&ze&&Et(i.firstChild);let l=c?e:i;try{let e=Ft(l);for(;o=e.nextNode();)qt(o,l),$t(o,l),zt(o.content)&&en(o.content)}catch(n){throw c&&(Ot(e),vh(t.removed,e=>{e.element&&jt(e.element)})),n}if(c){let n=!1;if(vh(t.removed,t=>{t.element&&(t.element===e&&(n=!0),jt(t.element))}),n)throw Lh(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Pe&&Lt(e),e}if(Be){if(Pe&&Lt(i),Ve)for(s=de.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(Te.shadowroot||Te.shadowrootmode)&&(s=pe.call(r,s,!0)),s}let u=O?i.outerHTML:i.innerHTML;return O&&Ce[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Ih(dg,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
76
+ `+u),Pe&&(u=It(u)),w&&He?ae(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yt(e),Ie=!0,Le=Ce,Re=Te},t.clearConfig=function(){gt=null,Ie=!1,Le=null,Re=null,w=te,T=``},t.isValidAttribute=function(e,t,n){gt||yt({});let r=ht(e),i=ht(t);return Jt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Ph(me,e)&&xh(me[e],t)},t.removeHook=function(e,t){if(Ph(me,e)){if(t!==void 0){let n=yh(me[e],t);return n===-1?void 0:Sh(me[e],n,1)[0]}return bh(me[e])}},t.removeHooks=function(e){Ph(me,e)&&(me[e]=[])},t.removeAllHooks=function(){me=Cg()},t}var Dg=Eg();function Og(e,t){let n;try{n=new URL(e.trim())}catch{return null}return n.protocol!==`https:`&&n.protocol!==`http:`||n.origin===t?null:n.href}var kg=`p.br.hr.strong.b.em.i.del.s.code.pre.blockquote.ul.ol.li.a.h1.h2.h3.h4.h5.h6.small.sub.sup.table.thead.tbody.tr.th.td.img.input`.split(`.`),Ag=[`form`,`style`,`script`,`button`,`select`,`textarea`,`iframe`,`object`,`embed`,`svg`,`math`],jg={a:[`href`,`title`],img:[`src`,`alt`,`title`],th:[`colspan`,`rowspan`,`align`],td:[`colspan`,`rowspan`,`align`],ol:[`start`],code:[`class`],input:[`type`,`checked`,`disabled`]},Mg=[...new Set(Object.values(jg).flat())],Ng=/^language-[\w-]+$/,Pg=/^\d{1,4}$/,Fg=/^(left|right|center)$/i;function Ig(e,t,n){if(!Object.hasOwn(jg,e)||!jg[e].includes(t))return!1;switch(t){case`class`:return Ng.test(n);case`type`:return n.toLowerCase()===`checkbox`;case`colspan`:case`rowspan`:case`start`:return Pg.test(n);case`align`:return Fg.test(n);default:return!0}}var Lg=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/i,Rg=/^\/api(\/|$)/i;function zg(e,t){if(Lg.test(e))return!0;if(!e.trim())return!1;let n;try{n=new URL(e,t)}catch{return!1}return(n.protocol===`https:`||n.protocol===`http:`)&&n.origin===t&&!Rg.test(n.pathname)}Dg.isSupported&&Dg.addHook(`afterSanitizeAttributes`,e=>{let t=e.nodeName.toLowerCase();for(let{name:n,value:r}of Array.from(e.attributes))Ig(t,n,r)||e.removeAttribute(n);if(t===`img`&&!zg(e.getAttribute(`src`)??``,location.origin)){e.replaceWith(document.createTextNode(e.getAttribute(`alt`)??``));return}if(t===`input`){e.getAttribute(`type`)===null?e.remove():e.setAttribute(`disabled`,``);return}if(t!==`a`)return;let n=e.getAttribute(`href`),r=n===null?null:Og(n,location.origin);r?(e.setAttribute(`href`,r),e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):(e.removeAttribute(`href`),e.removeAttribute(`target`))});var Bg={ALLOWED_TAGS:kg,ALLOWED_ATTR:Mg,FORBID_TAGS:Ag,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1},Vg=new Map;function Hg(e){let t=Vg.get(e);return t===void 0&&(t=Dg.sanitize(Qm.parse(e,{async:!1}),Bg),Vg.size>400&&Vg.delete(Vg.keys().next().value),Vg.set(e,t)),t}var Ug=`demo.job-runs`,Wg=e=>e.status!==`running`&&e.status!==`waiting`,Gg=U(()=>Mu.value?.info?.jobs??[]),Kg=e=>Gg.value.find(t=>t.id===e),qg=U(()=>{let e=Yu.value.docs[Ug];return Object.values(e?.items??{}).sort((e,t)=>t.id-e.id)}),Jg=e=>qg.value.find(t=>t.id===e),Yg=e=>qg.value.find(t=>t.toolCallId===e),Xg=k(Date.now());setInterval(()=>Xg.value=Date.now(),1e3);var Zg=e=>e<1e3?`${Math.max(0,Math.round(e))}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`,Qg=k();async function $g(e,t){if(!Qg.value){Qg.value=e;try{return await dd(t)}finally{Qg.value=void 0}}}function e_(e){bd.value&&Cd(),setTimeout(()=>document.querySelector(`[data-job-run="${e}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`}))}async function t_(e){let t=await $g(`start:${e.id}`,()=>zu.value.demo(`jobs`,{job:e.id}));t&&(Y(`${e.title} started. It runs in the chat.`),e_(t.taskId))}var n_=(e,t)=>$g(`decide:${e.id}`,()=>zu.value.demo(`jobs/${e.id}/approval`,{approved:t})),r_=e=>$g(`stop:${e.id}`,()=>Bu.value.abortTask(e.id));function i_(e){q.value&&Vu({...q.value,agentId:e})}var a_=[`data-job-run`,`aria-label`],o_={class:`job-run-head`},s_={class:`job-run-icon`},c_={class:`job-run-titles`},l_={class:`job-run-eyebrow`},u_={class:`job-run-repeat`},d_={key:0,class:`job-run-about`},f_={class:`job-run-meta`},p_={key:0,class:`job-run-resumed`},m_={class:`job-stepper`,"aria-label":`Phases`},h_=[`aria-current`],g_={class:`job-chip`},__={class:`job-step-dot`},v_={class:`job-step-label`},y_={key:0,class:`job-step-progress`},b_={class:`job-phases`},x_=[`open`],S_={class:`job-phase-n`},C_={class:`job-phase-summary`},w_={class:`job-phase-time`},T_={key:0,class:`job-phase-about`},E_={key:1,class:`job-steps`},D_=[`open`],O_={key:1,class:`job-step-line`},k_=[`onClick`],A_={key:2,class:`job-phase-empty`},j_={key:1,class:`job-approval`,role:`group`,"aria-label":`Approval`},M_={class:`job-approval-buttons`},N_=[`disabled`],P_=[`disabled`],F_={key:2,class:`message-error`},I_={class:`job-run-foot`},L_=[`disabled`],R_=N({__name:`JobCard`,props:{run:{}},setup(e){let t=e,n=U(()=>Kg(t.run.job)),r=U(()=>Wg(t.run)),i=U(()=>Zg((t.run.endedAt??Xg.value)-t.run.startedAt)),a={running:`Running`,waiting:`Waiting for you`,completed:`Completed`,failed:`Failed`,aborted:`Stopped`,declined:`Declined`},o={command:pl,tool:bl,agent:Zs,state:Qs,approval:sl,checkpoint:_c,note:Pc},s=e=>e.kind===`tool`?`${e.label}: a subagent tool call, its own durable task`:e.label,c=e=>{let t=e.step,n=[`command`,`tool`,`state`].includes(t.kind)?io(`code`,{title:s(t)},t.label):io(`span`,{class:`job-step-text`},t.label),r=t.status===`running`?io(Fc,{size:15,class:`spin`}):t.status===`done`?io(tc,{size:15}):t.status===`waiting`?io(Tc,{size:15}):io(xl,{size:15});return[io(o[t.kind],{size:16,class:`job-step-kind`}),n,t.kind===`tool`&&t.detail?io(`span`,{class:`job-step-args`,title:t.detail},t.detail):null,io(`span`,{class:`job-step-state`},[r,t.ms!==void 0&&t.kind!==`note`?io(`span`,Zg(t.ms)):null])]};c.props=[`step`];let l=e=>n.value?.phases.find(t=>t.id===e),u=e=>e.startedAt?Zg((e.endedAt??(e.status===`running`||e.status===`waiting`?Xg.value:e.startedAt))-e.startedAt):``,d=e=>e.status!==`pending`&&e.status!==`skipped`,f=U(()=>Object.entries(t.run.input)),p=U(()=>t.run.phases.find(e=>e.status===`waiting`));return(t,o)=>(I(),L(`article`,{class:E([`job-run`,`is-${e.run.status}`]),"data-job-run":e.run.id,"aria-label":`${e.run.title} run ${e.run.run}: ${a[e.run.status]}`},[z(`header`,o_,[z(`span`,s_,[B(A(yl),{size:22})]),z(`div`,c_,[z(`div`,l_,[o[3]||=z(`span`,null,`DURABLE JOB`,-1),z(`span`,u_,[B(A(el),{size:15}),V(`Repeatable workflow, run #`+D(e.run.run),1)])]),z(`h3`,null,D(e.run.title),1)]),z(`span`,{class:E([`job-run-status`,e.run.status])},[o[4]||=z(`i`,null,null,-1),V(D(a[e.run.status]),1)],2)]),n.value?(I(),L(`p`,d_,D(n.value.summary),1)):H(``,!0),z(`div`,f_,[z(`span`,null,`task #`+D(e.run.id),1),z(`span`,null,D(e.run.startedBy===`agent`?`started by the agent`:`started by you`),1),z(`span`,null,D(i.value),1),(I(!0),L(F,null,P(f.value,([e,t])=>(I(),L(`span`,{key:e,class:`job-run-input`},D(e)+`=`+D(t),1))),128)),e.run.resumed?(I(),L(`span`,p_,`resumed `+D(e.run.resumed)+`× after restart`,1)):H(``,!0)]),z(`ol`,m_,[(I(!0),L(F,null,P(e.run.phases,(t,n)=>(I(),L(`li`,{key:t.id,class:E(`ph-${t.status}`),"aria-current":e.run.phase===t.id&&!r.value?`step`:void 0},[z(`span`,g_,[z(`span`,__,[t.status===`done`?(I(),R(A(tc),{key:0,size:15})):t.status===`running`?(I(),R(A(Fc),{key:1,size:15,class:`spin`})):t.status===`waiting`?(I(),R(A(Tc),{key:2,size:15})):[`failed`,`aborted`].includes(t.status)?(I(),R(A(xl),{key:3,size:15})):(I(),L(F,{key:4},[V(D(n+1),1)],64))]),z(`span`,v_,D(t.label),1),t.progress?(I(),L(`span`,y_,D(t.progress.done)+`/`+D(t.progress.total),1)):H(``,!0)])],10,h_))),128))]),z(`div`,b_,[(I(!0),L(F,null,P(e.run.phases,(e,t)=>(I(),L(`details`,{key:e.id,class:E([`job-phase`,`ph-${e.status}`]),open:d(e)},[z(`summary`,null,[z(`span`,S_,D(t+1),1),z(`strong`,null,D(e.label),1),z(`span`,C_,D(e.summary??(e.status===`pending`?l(e.id)?.summary:e.status===`skipped`?`Skipped`:``)),1),z(`span`,w_,D(u(e)),1)]),e.status===`done`?H(``,!0):(I(),L(`p`,T_,D(l(e.id)?.summary),1)),e.steps.length?(I(),L(`ul`,E_,[(I(!0),L(F,null,P(e.steps,e=>(I(),L(`li`,{key:e.id,class:E([`k-${e.kind}`,`st-${e.status}`])},[e.detail&&e.kind!==`tool`?(I(),L(`details`,{key:0,open:e.status===`error`},[z(`summary`,null,[B(c,{step:e},null,8,[`step`])]),z(`pre`,null,D(e.detail),1)],8,D_)):(I(),L(`div`,O_,[B(c,{step:e},null,8,[`step`])])),e.kind===`agent`&&e.conversationId?(I(),L(`button`,{key:2,class:`text-button job-step-link`,onClick:t=>A(i_)(e.conversationId)},` Open subagent #`+D(e.conversationId),9,k_)):H(``,!0)],2))),128))])):e.status===`pending`?(I(),L(`p`,A_,`Not started yet.`)):H(``,!0)],10,x_))),128))]),e.run.approval===`pending`?(I(),L(`div`,j_,[z(`div`,null,[B(A(sl),{size:20}),o[5]||=z(`strong`,null,`Approve to continue`,-1)]),z(`p`,null,D(p.value?l(p.value.id)?.summary:`This run waits for you`)+`. It is paused on a saved checkpoint: close the browser or restart the device and the decision will still be waiting. `,1),z(`div`,M_,[z(`button`,{class:`primary small`,disabled:!!A(Qg),onClick:o[0]||=t=>A(n_)(e.run,!0)},[B(A(tc),{size:18}),o[6]||=V(`Approve & continue `,-1)],8,N_),z(`button`,{class:`secondary`,disabled:!!A(Qg),onClick:o[1]||=t=>A(n_)(e.run,!1)},`Decline`,8,P_)])])):H(``,!0),e.run.error&&e.run.status!==`aborted`?(I(),L(`p`,F_,D(e.run.error),1)):H(``,!0),z(`footer`,I_,[z(`span`,null,D(e.run.background?`Runs in the background: the conversation owns it, so Interrupt leaves it running.`:`Owned by this tool call: Interrupt stops it.`)+` Each phase saves a checkpoint, so a restart resumes the current phase.`,1),r.value?H(``,!0):(I(),L(`button`,{key:0,class:`secondary danger`,disabled:!!A(Qg),onClick:o[2]||=t=>A(r_)(e.run)},[B(A(Vc),{size:16}),o[7]||=V(`Stop `,-1)],8,L_))])],10,a_))}}),z_={class:`message-label`},B_={class:`user-message`},V_={class:`message-label`},H_={key:0,class:`streaming`},U_={key:1},W_=[`aria-label`],G_=[`innerHTML`],K_={key:1,class:`thinking`},q_=[`data-call-id`],J_={class:`tool-status`},Y_={class:`tool-section-label`},X_=[`aria-label`,`onClick`],Z_={key:0,class:`typing`},Q_={key:1,class:`message-error`},$_=[`aria-label`],ev={key:3,class:`live-tool`},tv={key:0},nv={class:`event-line`},rv=[`aria-label`],iv={key:0,class:`raw`},av=N({__name:`TranscriptItem`,props:{item:{}},emits:[`fork`],setup(e,{emit:t}){let n=t,r=e=>e.status===`error`?`Error`:e.status===`done`?`Done`:e.status,i=e=>e.kind===`user`?`pi-user`:e.kind===`assistant`?e.streaming?`live-generation`:`pi-assistant`:e.kind===`tool-result`?`pi-tool-result`:e.kind===`tool`?`live-tool-entry`:e.entryKind.replaceAll(`.`,`-`);return(t,a)=>(I(),L(`article`,{class:E([`entry`,i(e.item)])},[e.item.kind===`user`?(I(),L(F,{key:0},[z(`div`,z_,[a[3]||=V(` YOU `,-1),z(`span`,null,`#`+D(e.item.id),1)]),z(`div`,B_,D(e.item.text),1)],64)):e.item.kind===`assistant`?(I(),L(F,{key:1},[z(`div`,V_,[a[5]||=V(` AGENT `,-1),e.item.streaming?(I(),L(`span`,H_,`Working`)):(I(),L(`span`,U_,`#`+D(e.item.id),1)),e.item.streaming?H(``,!0):(I(),L(`button`,{key:2,class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,title:`Fork from this entry. App State stays shared.`,onClick:a[0]||=t=>n(`fork`,e.item.id)},[B(A(Cc),{size:18}),a[4]||=V(`Fork `,-1)],8,W_))]),(I(!0),L(F,null,P(e.item.blocks,(e,t)=>(I(),L(F,{key:t},[e.type===`text`?(I(),L(`div`,{key:0,class:`markdown`,innerHTML:A(Hg)(e.text)},null,8,G_)):e.type===`thinking`?(I(),L(`details`,K_,[a[6]||=z(`summary`,null,`Thinking`,-1),z(`div`,null,D(e.text),1)])):(I(),L(`details`,{key:2,class:E([`tool-call`,{failed:e.call.status===`error`}]),"data-call-id":e.call.callId},[z(`summary`,null,[e.call.status===`error`?(I(),R(A(Oc),{key:0,size:18})):e.call.status===`done`?(I(),R(A(tc),{key:1,size:18})):e.call.status===`running`?(I(),R(A(Vs),{key:2,size:18})):(I(),R(A(bl),{key:3,size:18})),z(`strong`,null,D(e.call.name),1),z(`code`,null,D(A(md)(e.call.args)?.slice(0,90)),1),z(`span`,J_,D(r(e.call)),1)]),a[10]||=z(`div`,{class:`tool-section-label`},`Input`,-1),z(`pre`,null,D(A(md)(e.call.args)),1),e.call.result===void 0?e.call.output?(I(),L(F,{key:1},[a[9]||=z(`div`,{class:`tool-section-label`},`Live output`,-1),z(`pre`,null,D(e.call.output),1)],64)):H(``,!0):(I(),L(F,{key:0},[z(`div`,Y_,[a[8]||=z(`span`,null,`Result`,-1),e.call.resultEntryId===void 0?H(``,!0):(I(),L(`button`,{key:0,class:`fork-button`,"aria-label":`Fork at entry ${e.call.resultEntryId}`,title:`Fork after this result`,onClick:t=>n(`fork`,e.call.resultEntryId)},[B(A(Cc),{size:18}),a[7]||=V(`Fork `,-1)],8,X_))]),z(`pre`,null,D(e.call.result),1)],64))],10,q_)),e.type===`tool`&&e.call.name===`run_durable_job`&&A(Yg)(e.call.callId)?(I(),R(R_,{key:3,run:A(Yg)(e.call.callId)},null,8,[`run`])):H(``,!0)],64))),128)),e.item.streaming&&!e.item.blocks.length?(I(),L(`div`,Z_,[...a[11]||=[z(`i`,null,null,-1),z(`i`,null,null,-1),z(`i`,null,null,-1)]])):H(``,!0),e.item.error?(I(),L(`div`,Q_,D(e.item.error),1)):H(``,!0)],64)):e.item.kind===`tool-result`?(I(),L(`details`,{key:2,class:E([`tool-result`,{failed:e.item.isError}])},[z(`summary`,null,[e.item.isError?(I(),R(A(Oc),{key:1,size:18})):(I(),R(A(tc),{key:0,size:18})),z(`strong`,null,D(e.item.name),1),z(`span`,null,D(e.item.isError?`error`:`result`),1),z(`button`,{class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,onClick:a[1]||=ks(t=>n(`fork`,e.item.id),[`prevent`])},[B(A(Cc),{size:18}),a[12]||=V(`Fork `,-1)],8,$_)]),z(`pre`,null,D(e.item.text),1)],2)):e.item.kind===`tool`?(I(),L(`div`,ev,[z(`div`,null,[B(A(Vs),{size:18}),z(`strong`,null,D(e.item.call.name),1),z(`span`,null,D(e.item.call.status),1)]),e.item.call.output?(I(),L(`pre`,tv,D(e.item.call.output),1)):H(``,!0),e.item.call.name===`run_durable_job`&&A(Yg)(e.item.call.callId)?(I(),R(R_,{key:1,run:A(Yg)(e.item.call.callId)},null,8,[`run`])):H(``,!0)])):e.item.entryKind===`demo.job`&&A(Jg)(e.item.data.taskId)?(I(),R(R_,{key:4,run:A(Jg)(e.item.data.taskId)},null,8,[`run`])):(I(),L(F,{key:5},[z(`div`,nv,[e.item.entryKind===`demo.state-change`?(I(),R(A(Qs),{key:0,size:18})):(I(),R(A(jc),{key:1,size:18})),z(`span`,null,D(e.item.text),1),z(`button`,{class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,onClick:a[2]||=t=>n(`fork`,e.item.id)},[B(A(Cc),{size:18}),a[13]||=V(`Fork `,-1)],8,rv)]),e.item.note?(I(),L(`details`,iv,[a[14]||=z(`summary`,null,`Context note`,-1),z(`pre`,null,D(e.item.note),1)])):H(``,!0)],64))],2))}}),ov={key:0,class:`git-chip-wrap`},sv=[`title`],cv={class:`branch`},lv={key:0,class:`dirty`},uv={key:1,class:`ahead`},dv={key:2,class:`behind`},fv=Hd(N({__name:`GitChip`,props:{deviceId:{},cwd:{}},setup(e){let t=e,n=U(()=>t.cwd??Lu.value?.cwd??``),r=U(()=>t.deviceId??ju.value),i=U(()=>rf(r.value||`?`,n.value||`?`)),a=U(()=>i.value.status),o=U(()=>i.value.loading),s=U(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0));return of(r.value||`?`,n.value||`?`),Kr(()=>of(r.value||`?`,n.value||`?`)),M([r,n],()=>void of(r.value||`?`,n.value||`?`)),(e,t)=>a.value?.repo||o.value?(I(),L(`span`,ov,[z(`button`,{class:`crumb git-chip`,title:a.value?`${a.value.root} · ${a.value.head??``} ${a.value.subject??``} — opens the Git tab`:`loading git…`,onClick:t[0]||=e=>A(Sd)(`git`)},[B(A(xc),{size:16,"aria-hidden":`true`}),z(`span`,cv,D(a.value?.branch??a.value?.head??`…`),1),s.value?(I(),L(`span`,lv,`±`+D(s.value),1)):H(``,!0),a.value?.ahead?(I(),L(`span`,uv,`↑`+D(a.value.ahead),1)):H(``,!0),a.value?.behind?(I(),L(`span`,dv,`↓`+D(a.value.behind),1)):H(``,!0),B(A(nc),{size:14,"aria-hidden":`true`})],8,sv)])):H(``,!0)}}),[[`__scopeId`,`data-v-c0fb9e98`]]),pv=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,mv=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],hv={enabled:!0,reserveTokens:16384,backgroundTokens:32768,keepRecentTokens:2e3},gv={auto:2e5,wait:25e4};function _v(e){if(!(e>0))return{...hv};let t=Math.min(gv.wait,e-hv.reserveTokens),n=Math.min(gv.auto,t-hv.backgroundTokens);return{...hv,reserveTokens:e-t,backgroundTokens:t-n}}function vv(e,t){let n=Math.max(0,e-t.reserveTokens);return{wait:n,auto:t.backgroundTokens>0?Math.max(0,n-t.backgroundTokens):void 0}}var yv=(e,t)=>{if(e===void 0)throw Error(`No ${t} selected`);return e},bv=[{name:`compact`,args:`[instructions]`,description:`Summarize older context; stored entries stay`,run:async e=>{await yv(zu.value,`agent`).compact(e||void 0),Y(`Compaction requested. /tasks shows its outcome.`)}},{name:`reset`,args:`[handoff note]`,description:`Start a fresh context; history stays stored`,run:async e=>{await yv(zu.value,`agent`).reset(e||void 0),Y(`New context started.`)}},{name:`tasks`,description:`Open the Tasks panel`,run:()=>Sd(`tasks`)},{name:`new`,args:`[name]`,description:`New agent in this workspace`,run:async e=>{let t=yv(q.value,`workspace`),n=await yv(Bu.value,`workspace`).createAgent({name:e||`Agent ${Xu.value.length+1}`});Vu({...t,agentId:n.id}),Y(`New agent ${n.name}.`)}},{name:`fork`,args:`[entryId] [name]`,description:`Fork at an entry (default: the last reply)`,run:async e=>{let[t,...n]=e.split(/\s+/).filter(Boolean),r=t&&/^\d+$/.test(t)?Number(t):void 0,i=(r===void 0?[t,...n]:n).filter(Boolean).join(` `),a=r??Yu.value.entries.filter(e=>e.kind===`pi.assistant`).at(-1)?.id;if(a===void 0)throw Error(`Nothing to fork yet`);let o=yv(q.value,`agent`),s=await yv(zu.value,`agent`).fork({entryId:a,name:i||void 0});Vu({...o,agentId:s.id}),Y(`Forked at entry #${a}. App State stays shared.`)}},{name:`name`,args:`<name>`,description:`Rename this agent`,run:async e=>{if(!e)throw Error(`Usage: /name <name>`);await yv(zu.value,`agent`).rename(e),Y(`Agent renamed to ${e}.`)}},{name:`model`,description:`Choose this agent's model`,run:()=>J.dialog={kind:`models`}},{name:`thinking`,args:`<level>`,description:`Thinking level: ${mv.join(`, `)}`,run:async e=>{if(!mv.includes(e))throw Error(`Levels: ${mv.join(`, `)}`);await yv(zu.value,`agent`).configure({thinkingLevel:e}),await od(),Y(`Thinking ${e}. Used on the next turn.`)}},{name:`help`,description:`How this works, keys and commands`,run:()=>J.dialog={kind:`help`}}];function xv(e){let t=e.trim().match(/^\/(\S+)\s*([\s\S]*)$/),n=t&&bv.find(e=>e.name===t[1]);return n?{command:n,arg:t[2].trim()}:void 0}var Sv={class:`composer-region`},Cv={key:0,class:`queue`},wv=[`aria-label`,`onClick`],Tv={class:`composer`},Ev={key:0,class:`slash-menu`,role:`listbox`,"aria-label":`Slash commands`},Dv=[`aria-selected`,`onMousedown`],Ov={key:0,class:`slash-args`},kv={class:`slash-desc`},Av={class:`composer-toolbar`},jv={class:`composer-left`},Mv={class:`lib-wrap`},Nv=[`aria-label`],Pv={key:0,class:`hint`},Fv={class:`save-row`},Iv=[`disabled`],Lv=[`title`,`onClick`],Rv=[`aria-label`,`onClick`],zv={class:`queue-mode`},Bv={class:`composer-right`},Vv=[`disabled`],Hv=[`disabled`],Uv=`dpi-prompt-library`,Wv=Hd(N({__name:`Composer`,setup(e){let t=k(`followUp`),n=k(!1),r=k(``),i=k([]),a=()=>{try{i.value=JSON.parse(localStorage.getItem(Uv)??`[]`)}catch{i.value=[]}},o=()=>localStorage.setItem(Uv,JSON.stringify(i.value));a();let s=()=>{let e=J.composer.trim(),t=r.value.trim()||e.slice(0,24)||`snippet`;e&&(i.value=[{name:t,text:e},...i.value.filter(e=>e.name!==t)].slice(0,30),o(),r.value=``)},c=e=>{i.value=i.value.filter(t=>t.name!==e),o()},l=k(!1),u=U(()=>Nu.value&&Yu.value.ready&&Fu.status.value===`live`&&Cu.value===`live`),d=k(0),f=k(!1),p=U(()=>{let e=J.composer.match(/^\/(\S*)$/);return e&&!f.value?bv.filter(t=>t.name.startsWith(e[1].toLowerCase())):[]});M(()=>J.composer,()=>{d.value=0,J.composer.startsWith(`/`)||(f.value=!1)});async function m(e,t=!1){!e.args||t&&e.args.startsWith(`[`)&&J.composer===`/${e.name}`?(J.composer=`/${e.name}`,await _()):J.composer=`/${e.name} `}function h(e){if(!p.value.length){e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),_());return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=p.value.length;d.value=(d.value+(e.key===`ArrowDown`?1:t-1))%t}else if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)m(p.value[d.value],e.key===`Enter`);else if(e.key===`Escape`)f.value=!0;else return;e.preventDefault(),e.stopPropagation()}async function g(e){let t=xv(e);return t?(l.value=!0,await dd(async()=>{await t.command.run(t.arg),J.composer=``}),l.value=!1,!0):!1}async function _(){let e=J.composer.trim(),n=zu.value;if(!e||l.value||!n||!u.value||e.startsWith(`/`)&&await g(e))return;l.value=!0;let r=q.value,i=`${r.deviceId}/${r.sessionId}/${r.agentId}`,a;try{a=JSON.parse(sessionStorage.getItem(`dpi.pending-send`)??`null`)}catch{}let o=a?.key===i&&a.content===e&&a.mode===t.value?a.requestId:pv();sessionStorage.setItem(`dpi.pending-send`,JSON.stringify({key:i,content:e,mode:t.value,requestId:o})),await dd(async()=>{await n.send(e,t.value,o),sessionStorage.removeItem(`dpi.pending-send`),J.composer=``}),l.value=!1}function v(e){dd(()=>zu.value.withdraw(e))}return(e,a)=>(I(),L(`div`,Sv,[A(Yu).inbox.length?(I(),L(`div`,Cv,[(I(!0),L(F,null,P(A(Yu).inbox,e=>(I(),L(`div`,{key:e.id},[B(A(oc),{size:18}),z(`span`,null,D(e.mode===`steer`?`Steer`:`Queued`)+`: `+D(e.content??`Context update`),1),z(`button`,{class:`icon-button`,"aria-label":`Withdraw submission ${e.id}`,title:`Withdraw queued input`,onClick:t=>v(e.id)},[B(A(xl),{size:18})],8,wv)]))),128))])):H(``,!0),z(`div`,Tv,[p.value.length?(I(),L(`ul`,Ev,[(I(!0),L(F,null,P(p.value,(e,t)=>(I(),L(`li`,{key:e.name,role:`option`,"aria-selected":t===d.value,class:E({active:t===d.value}),onMousedown:ks(t=>m(e),[`prevent`])},[z(`code`,null,`/`+D(e.name),1),e.args?(I(),L(`span`,Ov,D(e.args),1)):H(``,!0),z(`span`,kv,D(e.description),1)],42,Dv))),128))])):H(``,!0),j(z(`textarea`,{"onUpdate:modelValue":a[0]||=e=>A(J).composer=e,rows:`2`,placeholder:`Give your agent something to do, or type / for commands…`,"aria-label":`Message your agent`,onKeydown:h},null,544),[[ys,A(J).composer]]),z(`div`,Av,[z(`div`,jv,[z(`div`,Mv,[z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Prompt library (${i.value.length})`,title:`Prompt library — saved snippets`,onClick:a[1]||=e=>n.value=!n.value},[B(A(Mc),{size:18})],8,Nv),n.value?(I(),L(`div`,{key:0,class:`lib`,onClick:a[4]||=ks(()=>{},[`stop`])},[z(`header`,null,[a[7]||=z(`b`,null,`Prompts`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close library`,onClick:a[2]||=e=>n.value=!1},[B(A(xl),{size:14})])]),i.value.length?H(``,!0):(I(),L(`p`,Pv,`Type something below, give it a name, save it.`)),z(`div`,Fv,[j(z(`input`,{"onUpdate:modelValue":a[3]||=e=>r.value=e,placeholder:`name…`,onKeyup:js(s,[`enter`])},null,544),[[ys,r.value]]),z(`button`,{type:`button`,class:`small`,disabled:!A(J).composer.trim(),onClick:s},`save composer as`,8,Iv)]),z(`ul`,null,[(I(!0),L(F,null,P(i.value,e=>(I(),L(`li`,{key:e.name},[z(`button`,{type:`button`,class:`use`,title:e.text,onClick:t=>(A(J).composer=e.text,n.value=!1)},[z(`b`,null,D(e.name),1)],8,Lv),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Delete ${e.name}`,onClick:t=>c(e.name)},[B(A(ml),{size:13})],8,Rv)]))),128))])])):H(``,!0)]),z(`div`,zv,[j(z(`select`,{"onUpdate:modelValue":a[5]||=e=>t.value=e,"aria-label":`When busy`,title:`Follow-up waits for this run. Steer joins after a tool round.`},[...a[8]||=[z(`option`,{value:`followUp`},`Follow-up`,-1),z(`option`,{value:`steer`},`Steer`,-1),z(`option`,{value:`reject`},`Reject if busy`,-1)]],512),[[Ss,t.value]]),B(A(nc),{size:24,"aria-hidden":`true`})])]),z(`div`,Bv,[z(`button`,{class:`interrupt`,disabled:!A($u)||A(_d),title:`Stop foreground work and owned subagents (Escape). Background jobs continue.`,onClick:a[6]||=(...e)=>A(vd)&&A(vd)(...e)},[B(A(Vc),{size:24,class:`stop-sign`,fill:`currentColor`}),a[9]||=V(`Interrupt`,-1)],8,Vv),z(`button`,{class:`send`,"aria-label":`Send message`,disabled:!A(J).composer.trim()||l.value||!u.value,onClick:_},[B(A(Js),{size:20})],8,Hv)])])]),a[10]||=z(`div`,{class:`composer-footnote`},[z(`span`,null,[z(`i`,{class:`live-dot`}),V(`Closing this window never interrupts your agent.`)])],-1)]))}}),[[`__scopeId`,`data-v-b2af49ae`]]),Gv={class:`chat-panel`},Kv={class:`chat-header`},qv={class:`lineage-picker`},Jv={class:`lineage-toolbar`},Yv=[`title`],Xv={class:`crumb-main`},Zv={class:`device-chip`},Qv=[`title`],$v={class:`crumb-main`},ey={class:`crumb-name`},ty=[`aria-current`,`title`,`onClick`],ny={class:`crumb-kind`},ry={class:`crumb-main`},iy={class:`crumb-name`},ay=[`disabled`],oy=[`aria-expanded`],sy={key:0,class:`lineage-source`},cy={id:`conversation-picker`,class:`conversation-picker`,role:`dialog`,"aria-label":`Choose conversation`},ly=[`aria-label`,`aria-current`,`onClick`],uy={class:`conversation-choice-content`},dy={class:`choice-lineage`},fy={class:`choice-source`},py={key:0,class:`agent-stream-status`,role:`alert`},my=[`disabled`],hy={key:0,class:`chat-empty`},gy={key:0},_y={key:1},vy={key:0,class:`chat-empty`},yy={class:`starter-grid`},by={key:1,class:`entry live-generation`},xy={class:`message-label`},Sy={class:`streaming`},Cy={key:2,class:`hint retry-note`},wy=N({__name:`AgentView`,setup(e){let t=k(),n=k(),r=k(!1),i=U(()=>Yu.value.items),a=U(()=>i.value.some(e=>e.kind===`assistant`&&e.streaming)),o=U(()=>i.value.some(e=>e.kind===`tool`&&e.call.status===`running`||e.kind===`assistant`&&e.blocks.some(e=>e.type===`tool`&&e.call.status===`running`))),s=e=>e.kind===`fork`?`Forked from agent #${e.parentId} at entry #${e.forkedAt}`:e.kind===`subagent`?`Owned by agent #${e.ownerAgentId}`:`Root agent`,c=U(()=>Xu.value.map(e=>({...e,lineage:Ll(Xu.value,e.id)})).sort((e,t)=>{for(let n=0;n<Math.min(e.lineage.length,t.lineage.length);n++)if(e.lineage[n].id!==t.lineage[n].id)return e.lineage[n].id-t.lineage[n].id;return e.lineage.length-t.lineage.length})),l=U(()=>Zu.value.at(-1)),u=e=>e.kind===`root`?`agent`:e.kind;function d(){q.value&&(ku.tree=!0,Wu(q.value.deviceId,!0))}function f(){let e=Xu.value.find(e=>e.kind===`root`)??Xu.value[0];e&&p(e.id)}function p(e){r.value=!1,q.value&&Vu({...q.value,agentId:e})}function m(e){let t=zu.value,n=q.value;t&&n&&(J.dialog={kind:`prompt`,title:`Fork conversation`,hint:`${l.value?.name??`Agent #${n.agentId}`} / entry #${e}. Leave the name blank to use Fork #ID.`,label:`Fork name`,optional:!0,placeholder:`e.g. Alternative approach`,submit:`Create fork`,run:async r=>{let i=await t.fork({entryId:e,name:r||void 0});Vu({...n,agentId:i.id}),Y(`Forked at entry #${e}. App State stays shared.`)}})}function h(){let e=zu.value,t=l.value;e&&t&&(J.dialog={kind:`prompt`,title:`Rename agent`,label:`Agent name`,value:t.named?t.name:``,placeholder:t.name,submit:`Save name`,run:t=>e.rename(t)})}M(q,()=>{r.value=!1});let g=!0;return M(Fu.version,()=>{let e=t.value;g=!e||e.scrollHeight-e.scrollTop-e.clientHeight<120},{flush:`pre`}),M(Fu.version,()=>{g&&An(()=>t.value?.scrollTo({top:t.value.scrollHeight,behavior:`instant`}))}),M(()=>Zu.value.length,()=>void An(()=>n.value&&(n.value.scrollLeft=n.value.scrollWidth))),(e,g)=>(I(),L(`section`,Gv,[z(`header`,Kv,[z(`div`,qv,[z(`div`,Jv,[z(`nav`,{ref_key:`lineageNav`,ref:n,class:`crumbs conversation-lineage`,"aria-label":`Conversation lineage`},[z(`button`,{class:`crumb`,title:`${A(Mu)?.name} · ${A(Mu)?.url}`,onClick:d},[g[5]||=z(`span`,{class:`crumb-kind`},`device`,-1),z(`span`,Xv,[B(Yd,{device:A(Mu),size:18},null,8,[`device`]),z(`span`,Zv,D(A(Mu)?.name??A(Mu)?.id),1)])],8,Yv),B(A(rc),{class:`crumb-sep`,size:18,"aria-hidden":`true`}),z(`button`,{class:`crumb`,title:A(Lu)?.cwd,onClick:f},[g[6]||=z(`span`,{class:`crumb-kind`},`workspace`,-1),z(`span`,$v,[B(A(yc),{size:18,"aria-hidden":`true`}),z(`span`,ey,D(A(Lu)?.name),1)])],8,Qv),A(Lu)?.cwd?(I(),R(fv,{key:0})):H(``,!0),(I(!0),L(F,null,P(A(Zu),e=>(I(),L(F,{key:e.id},[B(A(rc),{class:`crumb-sep`,size:18,"aria-hidden":`true`}),z(`button`,{class:E([`crumb`,{current:e.id===A(q)?.agentId}]),"aria-current":e.id===A(q)?.agentId?`page`:void 0,title:s(e),onClick:t=>p(e.id)},[z(`span`,ny,D(u(e)),1),z(`span`,ry,[e.kind===`fork`?(I(),R(A(Cc),{key:0,size:18,"aria-hidden":`true`})):e.kind===`subagent`?(I(),R(A(cc),{key:1,size:18,"aria-hidden":`true`})):(I(),R(A(Lc),{key:2,size:18,"aria-hidden":`true`})),z(`span`,iy,D(e.name),1)])],10,ty)],64))),128))],512),z(`button`,{class:`icon-button`,"aria-label":`Rename agent`,title:`Rename this agent`,disabled:!l.value,onClick:h},[B(A(qc),{size:18})],8,ay),z(`button`,{class:`icon-button conversation-menu-toggle`,"aria-label":`Browse conversations`,"aria-haspopup":`dialog`,"aria-expanded":r.value,"aria-controls":`conversation-picker`,title:`Browse roots and forks`,onClick:g[0]||=e=>r.value=!r.value},[B(A(nc),{size:18})],8,oy)]),l.value&&l.value.kind!==`root`?(I(),L(`div`,sy,D(s(l.value)),1)):H(``,!0),r.value?(I(),L(F,{key:1},[z(`button`,{class:`conversation-menu-dismiss`,"aria-label":`Close conversation picker`,onClick:g[1]||=e=>r.value=!1}),z(`section`,cy,[g[7]||=z(`div`,{class:`conversation-picker-heading`},`Roots & forks`,-1),(I(!0),L(F,null,P(c.value,e=>(I(),L(`button`,{key:e.id,class:E([`conversation-choice`,{selected:e.id===A(q)?.agentId}]),"aria-label":e.lineage.map(e=>e.name).join(` → `),"aria-current":e.id===A(q)?.agentId?`page`:void 0,onClick:t=>p(e.id)},[z(`div`,uy,[z(`span`,dy,[(I(!0),L(F,null,P(e.lineage,(t,n)=>(I(),L(F,{key:t.id},[n?(I(),R(A(rc),{key:0,size:18,"aria-hidden":`true`})):H(``,!0),z(`span`,{class:E({"choice-ancestor":n<e.lineage.length-1})},D(t.name),3)],64))),128))]),z(`span`,fy,D(s(e)),1)]),e.id===A(q)?.agentId?(I(),R(A(tc),{key:0,size:18,"aria-hidden":`true`})):e.kind===`fork`?(I(),R(A(Cc),{key:1,size:18,"aria-hidden":`true`})):(I(),R(A(Lc),{key:2,size:18,"aria-hidden":`true`}))],10,ly))),128))])],64)):H(``,!0)])]),A(Fu).fault.value||A(Fu).status.value===`fault`||A(Fu).status.value===`reconnecting`||A(Yu).ready&&A(Fu).status.value===`connecting`?(I(),L(`div`,py,[z(`div`,null,[z(`strong`,null,D(A(Yu).ready?`Cached transcript is stale.`:`Agent stream unavailable.`),1),z(`p`,null,D(A(Fu).fault.value||`Updates are paused while the stream reconnects.`),1),g[8]||=z(`p`,null,`Sending is paused until a fresh snapshot arrives. Your draft is kept.`,-1)]),z(`button`,{disabled:A(Fu).status.value===`connecting`,onClick:g[2]||=(...e)=>A(Fu).retry&&A(Fu).retry(...e)},` Retry stream `,8,my)])):H(``,!0),z(`div`,{ref_key:`chat`,ref:t,class:`chat-scroll`,"data-testid":`chat`},[A(Yu).ready?(I(),L(F,{key:1},[i.value.length?H(``,!0):(I(),L(`div`,vy,[g[13]||=z(`div`,{class:`agent-orb`},[z(`img`,{src:`/icons/durable-pi.svg`,alt:`Durable Pi`}),z(`i`)],-1),g[14]||=z(`span`,{class:`eyebrow`},`YOUR DURABLE AGENT IS READY`,-1),g[15]||=z(`h2`,null,`A conversation with continuity.`,-1),z(`p`,null,`Messages, tools and state live on `+D(A(Mu)?.id)+`, beyond this window.`,1),z(`div`,yy,[z(`button`,{onClick:g[3]||=e=>A(fd)(`Inspect this directory using your tools and give me a brief overview. Do not modify any files.`)},[B(A(yc),{size:18}),g[9]||=z(`strong`,null,`Explore this directory`,-1),g[10]||=z(`span`,null,`See coding tools in action`,-1),B(A(qs),{size:18})]),z(`button`,{onClick:g[4]||=e=>A(fd)(`Use read_state, then update_state to add a field called progress with value 1 and a boolean called ready with value false.`)},[B(A(Qs),{size:18}),g[11]||=z(`strong`,null,`Make a state change`,-1),g[12]||=z(`span`,null,`Watch the workspace update`,-1),B(A(qs),{size:18})])])])),(I(!0),L(F,null,P(i.value,e=>(I(),R(av,{key:e.id,item:e,onFork:m},null,8,[`item`]))),128)),A(Yu).running&&!a.value&&!o.value?(I(),L(`div`,by,[z(`div`,xy,[g[16]||=V(` AGENT `,-1),z(`span`,Sy,D(A(Yu).retry?`Retry scheduled`:`Working`),1)]),g[17]||=z(`div`,{class:`typing`},[z(`i`),z(`i`),z(`i`)],-1)])):H(``,!0),A(Yu).retry?(I(),L(`p`,Cy,` Retrying: `+D(A(Yu).retry.error),1)):H(``,!0),(I(!0),L(F,null,P(A(Yu).notices,(e,t)=>(I(),L(`p`,{key:t,class:`message-error`},D(e),1))),128))],64)):(I(),L(`div`,hy,[B(A(Vs),{size:30}),A(Fu).status.value===`fault`?(I(),L(`h2`,gy,`This agent is unavailable.`)):(I(),L(`h2`,_y,`Connecting to the agent…`)),z(`p`,null,`The agent keeps working on `+D(A(Mu)?.id)+` while this view connects.`,1)]))],512),B(Wv)]))}});function Ty(e,t){return`${e}/${t.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`}function Ey(e){if(e===``)return[];if(!e.startsWith(`/`))throw Error(`Use a JSON Pointer path, such as /counter`);return e.slice(1).split(`/`).map(e=>{if(/~(?![01])/u.test(e))throw Error(`Invalid JSON Pointer escape`);let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if([`__proto__`,`constructor`,`prototype`].includes(t))throw Error(`Reserved field name`);return t})}function Dy(e,t){if(typeof e!=`object`||!e||!Object.hasOwn(e,t))throw Error(`Field does not exist: ${t}`);if(Array.isArray(e)&&!/^(0|[1-9]\d*)$/u.test(t))throw Error(`Invalid array index`);return e[t]}function Oy(e,t=0){if(t>24)throw Error(`State is too deeply nested`);if(e!==null&&typeof e!=`string`&&typeof e!=`boolean`&&!(typeof e==`number`&&Number.isFinite(e))){if(typeof e!=`object`||!e)throw Error(`Value must be valid JSON`);for(let[n,r]of Object.entries(e)){if([`__proto__`,`constructor`,`prototype`].includes(n))throw Error(`Reserved field name`);Oy(r,t+1)}}}function ky(e,t){if(![`create`,`update`,`delete`,`increment`].includes(t.operation))throw Error(`Invalid state operation`);if(typeof t.path!=`string`)throw Error(`State path is required`);let n=Ey(t.path),r=JSON.parse(JSON.stringify(e));if(!n.length){if(t.operation===`delete`)return{};if(t.operation!==`update`||t.value===null||Array.isArray(t.value)||typeof t.value!=`object`)throw Error(`The state root must be a JSON object. Use update to replace it.`);if(Oy(t.value),JSON.stringify(t.value).length>1e5)throw Error(`App State must be under 100,000 characters`);return JSON.parse(JSON.stringify(t.value))}let i=n.pop(),a=n.reduce(Dy,r);if(typeof a!=`object`||!a)throw Error(`Parent must be an object or array`);let o=Object.hasOwn(a,i),s=Array.isArray(a),c=s&&(i===`-`||i===String(a.length));if(s&&!c&&(!/^(0|[1-9]\d*)$/u.test(i)||Number(i)>=a.length))throw Error(`Invalid array index`);if(t.operation===`create`&&o)throw Error(`Field already exists. Use update.`);if(t.operation!==`create`&&!o)throw Error(`Field does not exist. Use create.`);if(t.operation===`delete`)s?a.splice(Number(i),1):delete a[i];else{let e=t.value;if(t.operation===`increment`){let t=a[i];if(typeof t!=`number`||typeof e!=`number`)throw Error(`Increment requires numbers`);e=t+e}Oy(e),s?a[c?a.length:Number(i)]=e:a[i]=e}if(Oy(r),JSON.stringify(r).length>1e5)throw Error(`App State must be under 100,000 characters`);return r}var Ay=[`data-state-path`],jy={key:0,class:`state-field-heading`},My=[`value`,`aria-label`,`disabled`],Ny=[`value`],Py=[`aria-label`,`disabled`],Fy=[`aria-label`,`disabled`],Iy=[`aria-label`,`disabled`],Ly=[`value`],Ry=[`disabled`],zy=[`disabled`,`aria-label`],By={key:2,class:`state-number`},Vy=[`aria-label`,`disabled`],Hy=[`aria-label`,`disabled`],Uy=[`aria-label`,`disabled`],Wy={key:3,class:`state-boolean`},Gy=[`aria-label`,`aria-checked`,`disabled`],Ky=[`aria-label`,`disabled`],qy={key:5,class:`muted`},Jy=N({__name:`StateEditor`,props:{value:{type:[String,Number,Boolean,null,Array,Object]},path:{default:``},label:{default:`App State`},disabled:{type:Boolean}},emits:[`change`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>n.value===null?`null`:Array.isArray(n.value)?`array`:typeof n.value),a=U(()=>i.value===`object`||i.value===`array`),o=U(()=>a.value?Object.entries(n.value):[]),s=k(``),c=k(!1),l=k(``),u=k(`string`),d=k(!1),f=[`string`,`number`,`boolean`,`object`,`array`,`null`],p={string:()=>``,number:()=>0,boolean:()=>!1,object:()=>({}),array:()=>[],null:()=>null};M(()=>n.value,e=>{c.value||(s.value=String(e??``))},{immediate:!0});function m(e,t){r(`change`,{operation:e,path:n.path,value:t})}function h(){c.value=!1;let e=i.value===`number`?Number(s.value):s.value;if(i.value===`number`&&(!String(s.value).trim()||!Number.isFinite(e))){s.value=String(n.value);return}e!==n.value&&m(`update`,e)}function g(){let e=i.value===`array`?`-`:l.value.trim();e&&(r(`change`,{operation:`create`,path:Ty(n.path,e),value:p[u.value]()}),l.value=``,d.value=!1)}return(t,n)=>{let _=Zr(`StateEditor`,!0);return I(),L(`div`,{class:E([`state-field`,{"state-root":e.path===``}]),"data-state-path":e.path},[e.path===``?H(``,!0):(I(),L(`div`,jy,[z(`strong`,null,D(e.label),1),z(`select`,{value:i.value,"aria-label":`Type of ${e.path}`,disabled:e.disabled,onChange:n[0]||=e=>m(`update`,p[e.target.value]())},[(I(),L(F,null,P(f,e=>z(`option`,{key:e,value:e},D(e),9,Ny)),64))],40,My),z(`button`,{class:`icon-button`,"aria-label":`Delete ${e.path}`,title:`Delete field`,disabled:e.disabled,onClick:n[1]||=e=>m(`delete`)},[B(A(ml),{size:18})],8,Py)])),a.value?(I(),L(F,{key:1},[(I(!0),L(F,null,P(o.value,([t,i])=>(I(),R(_,{key:t,value:i,path:A(Ty)(e.path,t),label:t,disabled:e.disabled,onChange:n[2]||=e=>r(`change`,e)},null,8,[`value`,`path`,`label`,`disabled`]))),128)),d.value?(I(),L(`form`,{key:0,class:`state-add`,onSubmit:ks(g,[`prevent`])},[i.value===`array`?H(``,!0):j((I(),L(`input`,{key:0,"onUpdate:modelValue":n[3]||=e=>l.value=e,placeholder:`Field name`,"aria-label":`New field name in ${e.path||`/`}`,required:``,disabled:e.disabled},null,8,Fy)),[[ys,l.value]]),j(z(`select`,{"onUpdate:modelValue":n[4]||=e=>u.value=e,"aria-label":`New field type in ${e.path||`/`}`,disabled:e.disabled},[(I(),L(F,null,P(f,e=>z(`option`,{key:e,value:e},D(e),9,Ly)),64))],8,Iy),[[Ss,u.value]]),z(`button`,{class:`secondary small`,disabled:e.disabled||i.value!==`array`&&!l.value.trim()},` Add `,8,Ry),z(`button`,{type:`button`,class:`text-button`,onClick:n[5]||=e=>d.value=!1},`Cancel`)],32)):(I(),L(`button`,{key:1,class:`text-button state-add-button`,disabled:e.disabled,"aria-label":`Add ${i.value===`array`?`item`:`field`} to ${e.path||`/`}`,onClick:n[6]||=e=>d.value=!0},[B(A(Xc),{size:18}),V(D(i.value===`array`?`Add item`:`Add field`),1)],8,zy))],64)):i.value===`number`?(I(),L(`div`,By,[z(`button`,{class:`secondary`,"aria-label":`Decrement ${e.path}`,disabled:e.disabled,onClick:n[7]||=e=>m(`increment`,-1)},[B(A(Rc),{size:18})],8,Vy),j(z(`input`,{"onUpdate:modelValue":n[8]||=e=>s.value=e,type:`number`,step:`any`,"aria-label":`Value of ${e.path}`,disabled:e.disabled,onFocus:n[9]||=e=>c.value=!0,onBlur:h,onKeydown:n[10]||=js(e=>e.target.blur(),[`enter`])},null,40,Hy),[[ys,s.value]]),z(`button`,{class:`secondary`,"aria-label":`Increment ${e.path}`,disabled:e.disabled,onClick:n[11]||=e=>m(`increment`,1)},[B(A(Xc),{size:18})],8,Uy)])):i.value===`boolean`?(I(),L(`div`,Wy,[z(`button`,{class:E([`switch`,{on:e.value===!0}]),role:`switch`,"aria-label":`Value of ${e.path}`,"aria-checked":e.value===!0,disabled:e.disabled,onClick:n[12]||=t=>m(`update`,!e.value)},[...n[15]||=[z(`span`,null,null,-1)]],10,Gy),z(`span`,null,D(e.value),1)])):i.value===`string`?j((I(),L(`textarea`,{key:4,"onUpdate:modelValue":n[13]||=e=>s.value=e,rows:`2`,"aria-label":`Value of ${e.path}`,disabled:e.disabled,onFocus:n[14]||=e=>c.value=!0,onBlur:h},null,40,Ky)),[[ys,s.value]]):(I(),L(`span`,qy,`null`))],10,Ay)}}}),Yy=[`data-status`],Xy=[`title`],Zy=[`title`],Qy=[`href`],$y=[`title`],eb=N({__name:`TunnelStatusBar`,props:{device:{}},setup(e){let t=e,n=U(()=>t.device.status===`online`),r=U(()=>t.device.transport===`tunnel`),i=U(()=>n.value?r.value?`online · via tunnel`:`online · LAN`:r.value?`tunnel`:`LAN`),a=U(()=>t.device.tunnel?.state===`connected`);return(t,o)=>(I(),L(`span`,{class:`tunnel-status`,"data-status":e.device.status},[z(`span`,{class:`axis transport`,title:r.value?`Hub ⇄ device over the tunnel (WSS)`:`Hub → device over LAN`},[r.value?(I(),R(A($s),{key:0,size:13,class:E({live:a.value})},null,8,[`class`])):(I(),R(A(vl),{key:1,size:13,class:E({live:n.value})},null,8,[`class`])),V(` `+D(i.value),1)],8,Xy),z(`span`,{class:E([`axis monitor`,e.device.status])},[e.device.status===`offline`?(I(),R(A(_l),{key:0,size:13})):(I(),L(F,{key:1},[V(D(e.device.status),1)],64))],2),r.value&&a.value&&e.device.tunnel?(I(),L(`span`,{key:0,class:`axis muted`,title:`tunnel last seen ${A(gd)(e.device.tunnel.lastSeenAt)}`},D(e.device.tunnel.readerCount)+` reader`+D(e.device.tunnel.readerCount===1?``:`s`),9,Zy)):H(``,!0),e.device.url?(I(),L(`a`,{key:1,class:`axis url`,href:e.device.url,target:`_blank`,rel:`noreferrer`},D(e.device.url),9,Qy)):H(``,!0),e.device.lastSeenAt?(I(),L(`span`,{key:2,class:`axis muted`,title:`last probe ${A(gd)(e.device.lastSeenAt)}`},D(A(gd)(e.device.lastSeenAt)),9,$y)):H(``,!0)],8,Yy))}});async function tb(e,t,n,r,i){let a=await fetch(`/api${t}`,{method:e,headers:n===void 0?{}:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n),signal:r,...i?{keepalive:i}:{}}),o=await a.json().catch(()=>void 0);if(!a.ok){let e=o?.error;throw new Sl(e?.code??`internal`,e?.message??`${a.status} ${a.statusText}`,a.status)}return o}function nb(e){return e.offerUrl??e.pairUrl}var rb={pending:e=>tb(`GET`,`/pair/codes`,void 0,e),pairings:e=>tb(`GET`,`/pairings`,void 0,e),createCode:e=>tb(`POST`,`/pair/code`,{},e),resolveCode:(e,t)=>tb(`POST`,`/pair/resolve`,{code:e},t),codeState:(e,t)=>tb(`GET`,`/pair/codes/${encodeURIComponent(e)}`,void 0,t),approve:(e,t,n)=>tb(`POST`,`/pair/codes/${encodeURIComponent(e)}/approve`,t,n),cancel:(e,t,n)=>tb(`POST`,`/pair/codes/${encodeURIComponent(e)}/cancel`,{},t,n),rotate:(e,t)=>tb(`POST`,`/pairings/${encodeURIComponent(e)}/rotate`,{},t),revoke:(e,t=`user`,n)=>tb(`POST`,`/pairings/${encodeURIComponent(e)}/revoke`,{reason:t},n)},ib=0;function ab(){let e=++ib,t=!1;return{gen:e,close:()=>t=!0,closed:()=>t}}var ob=class extends Error{codeId;constructor(e){super(`pairing poll timed out for ${e}`),this.codeId=e,this.name=`PollTimeout`}},sb=e=>e===`issued`||e===`cancelled`||e===`expired`;async function cb(e,t,n={}){let r=n.intervalMs??1e3,i=Date.now()+(n.timeoutMs??33e4);for(;;){if(e.closed())return;if(n.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);if(Date.now()>i)throw new ob(t);let a=await rb.codeState(t,n.signal);if(e.closed())return;if(e.state=a,n.onState?.(a),sb(a.phase))return a;await new Promise(e=>setTimeout(e,r))}}var lb={key:0,class:`token-manager`,"aria-label":`Credential manager`},ub={class:`credential-fingerprint`},db=[`title`],fb={key:0,class:`rotation-badge`,role:`status`},pb={class:`token-actions`},mb=[`disabled`],hb=[`disabled`],gb={key:1,class:`message-error`,role:`alert`},_b=N({__name:`TokenManager`,props:{device:{}},setup(e){let t=e,n=k(!1),r=k(``),i=U(()=>t.device.pairing);async function a(){if(!n.value){n.value=!0,r.value=``;try{await rb.rotate(t.device.id),Y(`Rotation queued — it completes when the device acknowledges the new credential.`)}catch(e){r.value=K(e)}finally{n.value=!1}}}async function o(){n.value||(J.dialog={kind:`prompt`,title:`Revoke ${t.device.id}?`,hint:`Every tunnel credential for this device dies at commit and the live tunnel is cut within a second. The device cleans its own files the next time it talks to the hub.`,submit:`Revoke`,danger:!0,run:async()=>{await rb.revoke(t.device.id,`user`),Y(`Revoke committed on the hub. The tunnel is cut; the device cleans up on its next contact.`)}})}return(e,t)=>i.value?(I(),L(`section`,lb,[z(`header`,null,[B(A(kc),{size:15}),t[0]||=z(`h3`,null,`Credential`,-1),z(`span`,{class:E([`pairing-status`,i.value.status])},D(i.value.status),3)]),z(`dl`,null,[t[1]||=z(`dt`,null,`Key fingerprint`,-1),z(`dd`,null,[z(`code`,ub,D(i.value.keyFingerprint),1)]),t[2]||=z(`dt`,null,`Paired`,-1),z(`dd`,{title:new Date(i.value.pairedAt).toISOString()},D(A(gd)(i.value.pairedAt)),9,db),t[3]||=z(`dt`,null,`Generation`,-1),z(`dd`,null,D(i.value.credentialGeneration),1)]),i.value.rotationPending?(I(),L(`p`,fb,[B(A($c),{size:13,class:`spin`}),t[4]||=V(` rotation queued — waiting for the device to ACK `,-1)])):H(``,!0),z(`div`,pb,[i.value.status===`paired`?(I(),L(`button`,{key:0,class:`small`,disabled:n.value||i.value.rotationPending,onClick:a},[B(A($c),{size:14}),t[5]||=V(` Rotate credential `,-1)],8,mb)):H(``,!0),i.value.status===`paired`?(I(),L(`button`,{key:1,class:`small danger`,disabled:n.value,onClick:o},[B(A(cl),{size:14}),t[6]||=V(` Revoke `,-1)],8,hb)):H(``,!0)]),r.value?(I(),L(`p`,gb,D(r.value),1)):H(``,!0)])):H(``,!0)}}),vb={class:`tasks-panel`},yb={class:`panel-heading`},bb={class:`tag`},xb={key:0,class:`message-error`,role:`alert`},Sb={class:`task-section`,"aria-label":`Durable jobs`},Cb={key:0,class:`task-empty`},wb=[`data-job`],Tb={class:`job-def-head`},Eb={key:0,class:`tag`},Db={class:`tag`},Ob=[`aria-label`],kb=[`title`],Ab={class:`job-def-meta`},jb=[`title`],Mb=[`title`],Nb={key:0,class:`job-def-last`},Pb=[`onClick`],Fb=[`disabled`,`onClick`],Ib=[`disabled`,`onClick`],Lb=[`disabled`,`onClick`],Rb={class:`task-section`,"aria-label":`Agent activity`},zb={class:`panel-heading`},Bb={key:0,class:`task-empty`},Vb={key:1,class:`task-tree`},Hb=[`data-task-kind`],Ub={class:`tag`},Wb={key:0,class:`task-phase`},Gb=[`onClick`],Kb=[`disabled`],qb={class:`raw`},Jb=N({__name:`TasksPanel`,setup(e){let t=k(``),n=k(!1),r=k([]),i=k(),a=e=>({running:`Running`,waiting:`Waiting`,completed:`Completed`,aborted:`Stopped`,declined:`Declined`,failed:`Failed`,pending:`Queued`,completing:`Finishing`,terminal:`Finished`})[e]??e,o=U(()=>new Map(Gg.value.map(e=>[e.id,qg.value.find(t=>t.job===e.id)]))),s=U(()=>{let e=Qu.value,t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.owner!==void 0&&t.has(r.owner)?r.owner:void 0;n.set(e,[...n.get(e)??[],r])}let r=[],i=(e,t)=>{for(let a of(n.get(e)??[]).sort((e,t)=>e.id-t.id))r.push({task:a,depth:t}),i(a.id,t+1)};return i(void 0,0),r}),c=e=>e.kind===`pi.tool`?{icon:bl,name:e.label??`Tool call`,what:`tool call`}:e.kind===`pi.generation`?{icon:Zs,name:`Model response`,what:`generation`}:e.kind===`pi.compaction`?{icon:jc,name:`Compaction`,what:`compaction`}:e.kind.startsWith(`demo.job.`)?{icon:yl,name:e.label??Kg(e.kind.slice(9))?.title??e.kind,what:`durable job`}:e.kind===`demo.job-approval`?{icon:sl,name:`Approval`,what:`waits for you`}:{icon:Vs,name:e.label??e.kind,what:e.kind},l=e=>e.state.phase?e.kind.startsWith(`demo.job.`)?Kg(e.kind.slice(9))?.phases.find(t=>t.id===e.state.phase)?.label??e.state.phase:e.state.phase:``;async function u(){if(!n.value&&zu.value){n.value=!0,t.value=``;try{await zu.value.abort(!0)}catch(e){t.value=K(e)}finally{n.value=!1}}}async function d(e){let n=Bu.value;if(e.target.open&&n)try{let[e,t]=await Promise.all([n.tasks(`terminal`,40),n.inspect()]);r.value=e,i.value=t}catch(e){t.value=K(e)}}let f=U(()=>r.value.filter(e=>e.state.status===`terminal`).slice(-12).reverse());return(e,r)=>(I(),L(`div`,vb,[z(`div`,yb,[r[0]||=z(`h2`,null,`Tasks`,-1),z(`span`,bb,D(A(Qu).length)+` active`,1)]),t.value?(I(),L(`p`,xb,D(t.value),1)):H(``,!0),z(`section`,Sb,[z(`h3`,null,[B(A(el),{size:18}),r[1]||=V(`Durable jobs`,-1)]),r[2]||=z(`p`,{class:`hint`},[V(` Repeatable workflows with named phases. Every run follows the same phases and saves a checkpoint after each one. Start one here, or ask your agent: it finds these with `),z(`code`,null,`list_durable_jobs`),V(`, starts them with `),z(`code`,null,`run_durable_job`),V(` and checks them with `),z(`code`,null,`check_durable_job`),V(`. Runs play out live in the chat. `)],-1),A(Gg).length?H(``,!0):(I(),L(`p`,Cb,` This device has no durable jobs. Deploy the latest backend to it. `)),(I(!0),L(F,null,P(A(Gg),e=>(I(),L(`article`,{key:e.id,class:`job-def`,"data-job":e.id},[z(`div`,Tb,[B(A(yl),{size:18}),z(`strong`,null,D(e.title),1),e.approval?(I(),L(`span`,Eb,`needs approval`)):H(``,!0),z(`span`,Db,`~`+D(e.seconds)+`s`,1)]),z(`p`,null,D(e.summary),1),z(`ol`,{class:`job-chain`,"aria-label":`${e.title} phases`},[(I(!0),L(F,null,P(e.phases,(e,t)=>(I(),L(`li`,{key:e.id,title:e.summary},[z(`span`,null,D(t+1),1),V(D(e.label),1),e.kind===`repeat`?(I(),R(A(el),{key:0,size:13})):H(``,!0),e.kind===`approval`?(I(),R(A(sl),{key:1,size:13})):H(``,!0)],8,kb))),128))],8,Ob),z(`div`,Ab,[(I(!0),L(F,null,P(e.inputs,e=>(I(),L(`code`,{key:e.name,title:e.description},D(e.name)+`=`+D(e.default),9,jb))),128)),z(`code`,{title:`Each run saves its result to App State ${e.resultPath}`},`→ `+D(e.resultPath),9,Mb)]),o.value.get(e.id)?(I(),L(`div`,Nb,[z(`span`,null,[V(`Run #`+D(o.value.get(e.id).run)+`: `,1),z(`strong`,null,D(a(o.value.get(e.id).status)),1),A(Wg)(o.value.get(e.id))?H(``,!0):(I(),L(F,{key:0},[V(` in `+D(o.value.get(e.id).phases.find(t=>t.id===o.value.get(e.id).phase)?.label),1)],64))]),z(`button`,{class:`text-button`,onClick:t=>A(e_)(o.value.get(e.id).id)},` Show in chat `,8,Pb),o.value.get(e.id).approval===`pending`?(I(),L(F,{key:0},[z(`button`,{class:`primary small`,disabled:!!A(Qg),onClick:t=>A(n_)(o.value.get(e.id),!0)},` Approve `,8,Fb),z(`button`,{class:`secondary`,disabled:!!A(Qg),onClick:t=>A(n_)(o.value.get(e.id),!1)},` Decline `,8,Ib)],64)):H(``,!0)])):H(``,!0),z(`button`,{class:`secondary job-def-run`,disabled:!!A(Qg)||!A(zu),onClick:t=>A(t_)(e)},[B(A(Yc),{size:16}),V(`Run `+D(e.title),1)],8,Lb)],8,wb))),128))]),z(`section`,Rb,[z(`div`,zb,[r[3]||=z(`h3`,null,`Agent activity`,-1),B(A(Vs),{size:18})]),r[5]||=z(`p`,{class:`hint`},` Every model response and every tool call is its own durable task with an id, an owner and a checkpoint. Follow them live here; after a restart each one resumes or reports how it ended. `,-1),s.value.length?(I(),L(`ul`,Vb,[(I(!0),L(F,null,P(s.value,({task:e,depth:t})=>(I(),L(`li`,{key:e.id,class:`task-row`,style:ge({"--depth":t}),"data-task-kind":e.kind},[(I(),R($r(c(e).icon),{size:16})),z(`strong`,null,D(c(e).name),1),z(`span`,Ub,D(a(e.state.status)),1),l(e)?(I(),L(`span`,Wb,D(l(e)),1)):H(``,!0),z(`small`,null,`#`+D(e.id)+` `+D(c(e).what)+`, agent #`+D(e.conversationId)+D(e.effectiveBackground?`, background`:``),1),(I(!0),L(F,null,P(e.conversations,e=>(I(),L(`button`,{key:e,class:`text-button`,onClick:t=>A(i_)(e)},` Open agent #`+D(e),9,Gb))),128))],12,Hb))),128))])):(I(),L(`p`,Bb,`Nothing running. Send a message or run a job.`)),r[6]||=z(`p`,{class:`hint`},` Interrupt or Esc stops foreground work and what it owns. Stop all also stops background runs. `,-1),z(`button`,{class:`secondary danger`,disabled:!A(Qu).length||n.value,onClick:u},[B(A(Vc),{size:18}),r[4]||=V(`Stop all `,-1)],8,Kb)]),z(`details`,{class:`raw task-section`,onToggle:d},[z(`summary`,null,[B(A(oc),{size:18}),r[7]||=V(`Runtime details`,-1)]),r[9]||=z(`p`,{class:`hint`},` Recent task results and recovery records, read from the device when opened. `,-1),(I(!0),L(F,null,P(f.value,e=>(I(),L(`details`,{key:e.id,class:`raw`},[z(`summary`,null,[V(D(e.kind)+` #`+D(e.id),1),z(`span`,null,D(a(e.state.outcome?.status??e.state.status)),1)]),z(`pre`,null,D(JSON.stringify(e.state.outcome,null,2)),1)]))),128)),z(`details`,qb,[r[8]||=z(`summary`,null,`Recovery inspection`,-1),z(`pre`,null,D(JSON.stringify(i.value,null,2)),1)])],32)]))}}),Yb={class:`git-pane`},Xb={key:0,class:`hint`},Zb={key:0,class:`hint`},Qb={key:1,class:`muted-line`},$b={key:2,class:`message-error`},ex={key:0,class:`hint`},tx={key:0,class:`message-error merge-banner`},nx=[`disabled`],rx={class:`panel-heading git-top`},ix={class:`branch-wrap`},ax=[`disabled`],ox={key:0,class:`menu`},sx=[`onClick`],cx={class:`muted-line`},lx={class:`new-branch`},ux=[`disabled`],dx={class:`auto-stash`},fx={class:`tag`},px={key:0,class:`tag`},mx={key:1,class:`tag`},hx={key:2,class:`tag`,title:`vs the picked base`},gx={class:`tag`},_x=[`href`],vx=[`disabled`],yx={class:`row ops`},bx=[`disabled`],xx=[`disabled`],Sx=[`disabled`],Cx=[`disabled`],wx=[`disabled`],Tx={key:1,class:`message-error hintbox`},Ex=[`disabled`],Dx=[`disabled`],Ox={key:2,class:`message-error hintbox`},kx=[`disabled`],Ax={class:`task-section`,"aria-label":`Commit`},jx={class:`panel-heading`},Mx={class:`tag`},Nx=[`disabled`],Px=[`disabled`],Fx={key:0,class:`hintbox warn`},Ix={key:1,class:`cps turns`},Lx={key:0,class:`hint`},Rx={class:`muted-line`},zx={class:`cp-subj`},Bx={key:2,class:`muted-line cap`},Vx={key:3,class:`files conflicts`},Hx={class:`file all`},Ux={class:`muted-line conflict-head`},Wx={class:`file-label`},Gx={class:`xy`},Kx=[`title`],qx={class:`file-acts`},Jx=[`onClick`],Yx=[`disabled`,`onClick`],Xx=[`disabled`,`onClick`],Zx={key:4,class:`files`},Qx={class:`file all`},$x=[`checked`],eS={class:`muted-line`},tS=[`onClick`],nS={class:`muted-line`},rS={class:`file-label`},iS=[`checked`,`onChange`],aS=[`title`],oS=[`title`],sS={class:`file-acts`},cS=[`onClick`],lS=[`onClick`],uS=[`onClick`],dS={key:5,class:`files`},fS={class:`file all`},pS=[`checked`],mS={class:`muted-line`},hS=[`onClick`],gS={class:`muted-line`},_S={class:`file-label`},vS=[`checked`,`onChange`],yS=[`title`],bS=[`title`],xS={class:`file-acts`},SS=[`onClick`],CS=[`onClick`],wS=[`onClick`],TS=[`onClick`],ES=[`onClick`],DS={key:6,class:`file-diff`},OS={class:`mode-chips`},kS={key:0,class:`nums bin`},AS={key:1,class:`nums`},jS={key:2},MS={class:`row`},NS=[`disabled`],PS=[`disabled`],FS=[`disabled`],IS={class:`task-section`,"aria-label":`Log`},LS={class:`panel-heading`},RS=[`disabled`],zS=[`disabled`],BS=[`disabled`],VS={key:0,class:`cps`},HS={key:0,class:`hint`},US={class:`muted-line`},WS={class:`cp-subj`},GS=[`disabled`,`onClick`],KS={key:1,class:`hint`},qS={key:2,class:`commits`},JS=[`title`],YS=[`width`],XS=[`x1`,`x2`],ZS=[`x1`,`x2`,`stroke`],QS=[`cx`,`fill`],$S=[`onClick`],eC={class:`hash`},tC=[`href`],nC={key:1,class:`refs`},rC={class:`subject`},iC={class:`muted-line who`},aC={key:0,class:`commit-files`},oC=[`data-s`],sC={class:`path`},cC={key:0,class:`hint`},lC={key:3,class:`message-error`},uC={key:4,class:`hint`},dC={class:`task-section`,"aria-label":`Worktrees`},fC={class:`panel-heading`},pC={class:`branch-wrap`},mC=[`disabled`],hC={key:0,class:`menu`},gC=[`onClick`],_C={class:`new-branch`},vC=[`disabled`],yC=[`title`],bC={class:`muted-line`},xC=[`disabled`,`onClick`],SC=[`disabled`,`onClick`],CC=[`disabled`,`onClick`],wC={key:3,class:`task-section`,"aria-label":`Pull requests`},TC={class:`panel-heading`},EC=[`disabled`],DC=[`disabled`],OC={key:0,class:`hint`},kC={key:1,class:`commits`},AC={class:`hash`},jC={class:`subject`},MC={class:`muted-line who`},NC=[`disabled`,`onClick`],PC=[`disabled`,`onClick`],FC=[`disabled`,`onClick`],IC=[`href`],LC={key:4,class:`op-out`},RC=[`placeholder`],zC={class:`row`},BC=[`disabled`],VC=Hd(N({__name:`GitPanel`,props:{deviceId:{},cwd:{}},setup(e){let t=e,n=U(()=>t.cwd??Lu.value?.cwd??``),r=U(()=>t.deviceId??ju.value),i=U(()=>rf(r.value||`?`,n.value||`?`)),a=U(()=>i.value.status),o=U(()=>i.value.loading),s=U(()=>i.value.refreshing),c=U(()=>i.value.error),l=U(()=>{let e=Lu.value;return e&&e.cwd===n.value&&!t.deviceId?e.id:void 0}),u=k(``),d=k(``),f=k(``),p=k(new Set),m=k(!1),h=k(!1),g=k(``),_=k(null),v=k(`working`),y=U(()=>`dpi-git-draft:${r.value}:${n.value}`),b=k(null),x=k(!0),S=k(``),C=k(!1),ee=k([]),w=U(()=>{if(!ee.value.length||!n.value)return null;let e=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,t=new Set(ee.value);return{changed:(a.value?.files??[]).filter(n=>t.has(e(n.path))).length,total:ee.value.length}}),T=k(null),te=k(``),ne=e=>{te.value=e.input?.value??``,T.value=e},re=()=>{let e=T.value;T.value=null,e&&e.action(te.value)};window.addEventListener(`keydown`,e=>{e.key===`Escape`&&T.value&&(T.value=null)});let ie=k([]),ae=k(!1),oe=k(new Map),se=k([]),ce=k(!1),le=k(new Map),ue=k(!1),de=U(()=>/github\.com|gitlab/i.test(a.value?.remoteUrl??``)),fe=async()=>{if(r.value&&n.value){ue.value=!0;try{let e=await G(r.value).gitOp(n.value,`pr-list`);se.value=e.prs??[]}catch(e){Y(`pr list failed: ${e.message.slice(0,120)}`)}finally{ue.value=!1}}};M(ce,e=>{e&&fe()});let pe=()=>ne({title:`Create pull request`,body:`head: ${a.value?.branch??`?`}`,confirmLabel:`Create PR`,input:{placeholder:`PR title`,value:f.value.trim()||``},action:e=>void me(e)});async function me(e){if(r.value&&n.value&&e.trim()){ue.value=!0;try{Y((await G(r.value).gitOp(n.value,`pr-create`,{message:e.trim(),body:e.trim()})).text.split(`
77
+ `)[0]??`PR created`),await fe()}catch(e){Y(`pr create failed: ${e.message.slice(0,140)}`)}finally{ue.value=!1}}}async function he(e){if(r.value&&n.value){ue.value=!0;try{let t=await G(r.value).gitOp(n.value,`pr-checks`,{n:e});le.value=new Map(le.value).set(e,t.text.slice(0,1500))}catch(e){Y(`pr checks failed: ${e.message.slice(0,120)}`)}finally{ue.value=!1}}}let ge=e=>ne({title:`Merge PR #${e}?`,body:`squash-merge via gh on the device.`,confirmLabel:`Squash & merge`,danger:!0,action:()=>void _e(e)});async function _e(e){if(r.value&&n.value){ue.value=!0;try{Y((await G(r.value).gitOp(n.value,`pr-merge`,{n:e})).text||`PR #${e} merged`),await fe(),await Ee()}catch(e){Y(`pr merge failed: ${e.message.slice(0,140)}`)}finally{ue.value=!1}}}let ve=e=>ne({title:`Comment on PR #${e}`,body:`posted as the device's gh login`,confirmLabel:`Comment`,input:{placeholder:`comment…`,value:``},action:t=>void ye(e,t)});async function ye(e,t){if(r.value&&n.value&&t.trim()){ue.value=!0;try{Y((await G(r.value).gitOp(n.value,`pr-comment`,{n:e,body:t.trim()})).text||`comment posted`)}catch(e){Y(`pr comment failed: ${e.message.slice(0,140)}`)}finally{ue.value=!1}}}let be=k([]),xe=k(!1),Se=async()=>{if(r.value&&l.value)try{let e=await G(r.value).sessionGitTurns(l.value);be.value=e.turns}catch{be.value=[]}};M(xe,e=>{e&&Se()});let Ce=0;window.addEventListener(`focus`,()=>{!n.value||Date.now()-Ce<15e3||(Ce=Date.now(),of(r.value||`?`,n.value||`?`,{force:!0}))});let we=k(new Set),Te=()=>{typeof localStorage<`u`&&(f.value=localStorage.getItem(y.value)??``)};tf(),of(r.value||`?`,n.value||`?`),Te(),Kr(()=>of(r.value||`?`,n.value||`?`)),M(f,e=>{typeof localStorage<`u`&&(e?localStorage.setItem(y.value,e):localStorage.removeItem(y.value))}),M([r,n],()=>{m.value=!1,h.value=!1,_.value=null,b.value=null,S.value=``,C.value=!1,ee.value=[],oe.value=new Map,we.value=new Set,of(r.value||`?`,n.value||`?`),Te()});let Ee=()=>(p.value=new Set,_.value=null,of(r.value||`?`,n.value||`?`,{force:!0})),De=U(()=>a.value?.files??[]);M(De,e=>{let t=new Set;for(let n of e)n.x!==`?`&&n.y!==`?`&&t.add(n.path);p.value=t},{immediate:!0});let Oe=U(()=>De.value.some(e=>p.value.has(e.path))),ke=U(()=>De.value.filter(e=>!je(e)&&e.x!==` `&&e.x!==`?`)),Ae=U(()=>De.value.filter(e=>!je(e)&&(e.x===` `||e.x===`?`))),je=e=>`UAD`.includes(e.x)&&`UAD`.includes(e.y),Me=U(()=>De.value.filter(je)),Ne=U(()=>De.value.length>=500),Pe=U(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0)>0),Fe=U(()=>!a.value?.identity?.name||!a.value?.identity?.email),O=U(()=>{let e=a.value?.remoteUrl??``,t=e.match(/git@([^:]+):(.+?)(?:\.git)?$/)??e.match(/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/);return t?`https://${t[1]}/${t[2]}`:``}),Ie=e=>{let t=new Set(p.value);t.has(e)?t.delete(e):t.add(e),p.value=t},Le=e=>{let t=e.every(e=>p.value.has(e.path)),n=new Set(p.value);for(let r of e)t?n.delete(r.path):n.add(r.path);p.value=n},Re=e=>{let t=e.lastIndexOf(`/`);return t===-1?`.`:e.slice(0,t)},ze=e=>{let t=new Map;for(let n of e){let e=Re(n.path);t.has(e)||t.set(e,[]),t.get(e).push(n)}return[...t.entries()].map(([e,t])=>({dir:e,files:t,open:!we.value.has(e)}))},Be=e=>{let t=new Set(we.value);t.has(e)?t.delete(e):t.add(e),we.value=t},Ve=e=>e.a===void 0&&e.d===void 0?``:e.a===-1||e.d===-1?`bin`:`+${e.a??0} −${e.d??0}`,He=e=>{navigator.clipboard?.writeText(e).then(()=>Y(`copied ${e}`))};async function Ue(e,t={}){if(r.value&&n.value){u.value=e,d.value=``;try{let i=await G(r.value).gitOp(n.value,e,t);d.value=i.text||`(empty)`,e===`push`&&(S.value=``),e===`pull`&&(C.value=!1),[`fetch`,`pull`,`push`,`stash-push`,`stash-pop`].includes(e)&&Y(`git ${e} ✓`),await Ee(),vt(!0)}catch(t){let n=t.message;e===`push`&&(/no upstream|has no upstream|upstream is gone/i.test(n)?S.value=`no upstream — set it while pushing?`:/fetch first|non-fast-forward|rejected.*fetch|behind/i.test(n)?S.value=`the remote has work you lack — pull first`:/authentication|permission|could not read|403|denied/i.test(n)?S.value=`credentials rejected on the device — check its git login`:S.value=``),e===`pull`&&/not possible to fast-forward|divergent|unrelated histories/i.test(n)&&(C.value=!0),Y(`git ${e}: ${n.slice(0,160)}`)}finally{u.value=``}}}async function We(e,t,i=!1){if(!r.value||!n.value||(i&&(u.value=e),!t&&e!==`stage`))return;if(e===`discard`&&t&&!i){ne({title:`Roll back to HEAD?`,body:`${t} — uncommitted changes are lost.`,confirmLabel:`Roll back`,danger:!0,action:()=>void We(e,t,!0)});return}u.value=e;let a=t?[t]:De.value.filter(e=>e.x===` `||e.x===`M`).map(e=>e.path);try{Y((await G(r.value).gitOp(n.value,e,{files:a})).text),await Ee()}catch(t){Y(`${e} failed: ${t.message.slice(0,140)}`)}finally{u.value=``}}async function Ge(e){if(r.value&&n.value&&e.length){u.value=`unstage`;try{Y((await G(r.value).gitOp(n.value,`unstage`,{files:e})).text),await Ee()}catch(e){Y(`unstage failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function Ke(e,t){if(r.value&&n.value){u.value=`resolve`;try{Y((await G(r.value).gitOp(n.value,`resolve`,{side:e,files:[t]})).text),await Ee()}catch(e){Y(`resolve failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function qe(e){if(r.value&&n.value&&e.length){u.value=`ignore`;try{Y((await G(r.value).gitOp(n.value,`ignore`,{lines:e})).text),await Ee()}catch(e){Y(`ignore failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function Je(e){if(r.value&&n.value){if(_.value?.path===e)return _.value=null;u.value=`diff`;try{let t=await G(r.value).gitOp(n.value,`diff-file`,{target:e,staged:v.value===`staged`});_.value={path:e,text:t.text}}catch(e){Y(`diff failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}let Ye=async()=>{let e=_.value?.path;_.value=null,e&&await Je(e)},Xe=U(()=>/Binary files .* differ/i.test(_.value?.text??``));async function Ze(){if(r.value&&n.value){u.value=`abort`;try{Y((await G(r.value).gitOp(n.value,`merge-abort`)).text),await Ee()}catch(e){Y(`abort failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function Qe(e){if(m.value=!1,r.value&&n.value){u.value=`compare`;try{let t=await G(r.value).gitOp(n.value,`compare`,{ref:e});b.value={ref:e,ahead:t.ahead??0,behind:t.behind??0}}catch(e){Y(`compare failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function $e(e,t=!1){if(m.value=!1,!r.value||!n.value||e===a.value?.branch&&!t)return;u.value=`switch`;let i=G(r.value),o=!1;try{if(x.value&&!t&&Pe.value&&(await i.gitOp(n.value,`stash-push`,{message:`dpi auto-stash before ${e}`}),o=!0),Y((await i.gitOp(n.value,`switch`,{ref:e,create:t})).text||`switched to ${e}`),o)try{let e=await i.gitOp(n.value,`stash-pop`);/conflict/i.test(e.text)&&Y(`stash popped WITH CONFLICTS — resolve in the file list`)}catch{Y(`switched, but the stash did not pop — resolve manually (git stash list)`)}await Ee(),vt(!0)}catch(e){if(Y(`switch failed: ${e.message.slice(0,140)}`),o)try{await i.gitOp(n.value,`stash-pop`)}catch{}}finally{u.value=``}}async function et(e=!1){if(!r.value||!n.value||!f.value.trim())return;u.value=`commit`;let t=De.value.filter(e=>p.value.has(e.path)).map(e=>e.path);if(!t.length)return Y(`check the files to commit — nothing is selected`);let i=G(r.value);try{if(Y((await i.gitOp(n.value,`commit`,{message:f.value.trim(),...a.value?.merge?{}:{files:t}})).text),f.value=``,e)try{Y(`pushed: ${(await i.gitOp(n.value,`push`)).text.slice(0,80)}`)}catch(e){Y(`committed, but push failed: ${e.message.slice(0,120)}`)}await Ee(),vt(!0)}catch(e){Y(`commit failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}function tt(e){let t=e?.models??[],n=t.find(t=>`${t.provider}/${t.id}`===e?.defaultModel),r=new Map;for(let e of t)r.has(e.provider)||r.set(e.provider,e);let i=[...r.values()].filter(e=>e!==n).slice(0,3);return(n?[n,...i]:i).slice(0,4)}async function nt(){if(!r.value||!n.value)return;let e=De.value.filter(e=>p.value.has(e.path)).map(e=>e.path);if(!e.length)return Y(`check files first — the model summarises THOSE`);u.value=`ai`;let t=G(r.value),i=``;for(let r of e.slice(0,5)){let e=await t.gitOp(n.value,`diff-file`,{target:r});if(i+=`${e.text}\n`,i.length>4e3)break}i=i.slice(0,4e3);let a=`Write ONE concise git commit message (under 72 chars, imperative, no quotes, no backticks) for these changes:\n\n${i}`,o=wu.devices.value.find(e=>e.id===r.value)?.info,s=tt(o);if(!s.length)return u.value=``,Y(`no model on the device`);let c=[];try{for(let e of s){let r=await t.createSession({name:`git-msg`,cwd:n.value,model:{provider:e.provider,modelId:e.id}}).then(e=>e.id).catch(()=>``);if(!r){c.push(`${e.provider}: no session`);continue}try{let n=await t.agent(r,1).send(a,`followUp`,void 0,12e4),i=n.status===`done`?n.answer.text.trim().split(`
78
+ `)[0]?.slice(0,100):``;if(i){f.value=i;return}c.push(`${e.provider}/${e.id}: ${n.status===`unanswered`?n.reason:`empty answer`}`)}finally{t.session(r).archive().catch(()=>{})}}Y(`ai message failed on every model — ${c.join(`; `).slice(0,140)}`)}catch(e){Y(`ai message failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}async function rt(){if(r.value&&l.value){u.value=`session-files`;try{let e=await G(r.value).sessionGitFiles(l.value);ee.value=e.files;let t=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,i=new Set(e.files.map(t)),a=De.value.filter(e=>i.has(t(e.path)));p.value=new Set(a.map(e=>e.path)),Y(a.length?`${a.length} session file(s) still changed — checked`:`the session touched nothing that is still changed`)}catch(e){Y(`session files failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function it(e){if(oe.value.has(e)){oe.value.delete(e),oe.value=new Map(oe.value);return}if(r.value&&n.value)try{let t=await G(r.value).gitOp(n.value,`show-files`,{target:e});oe.value=new Map(oe.value).set(e,t.changed??[])}catch(e){Y(`commit files failed: ${e.message.slice(0,120)}`)}}async function at(){if(!r.value||!n.value)return;let e=`cp-${new Date().toISOString().slice(0,16).replace(/[-:T]/g,``)}`;u.value=`checkpoint`;try{Y((await G(r.value).gitOp(n.value,`checkpoint`,{name:e})).text),ae.value=!0,await ot()}catch(e){Y(`checkpoint failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}async function ot(){if(r.value&&n.value)try{let e=await G(r.value).gitOp(n.value,`checkpoints`);ie.value=e.checkpoints??[]}catch{ie.value=[]}}async function st(e){if(!r.value||!n.value)return;let t=e;ne({title:`Rewind to ${t}?`,body:`reset --hard — ALL uncommitted changes in this worktree are LOST.`,confirmLabel:`Rewind`,danger:!0,action:()=>void ct(t)})}async function ct(e){if(r.value&&n.value){u.value=`rewind`;try{Y((await G(r.value).gitOp(n.value,`rewind`,{name:e})).text),await Ee(),vt(!0)}catch(e){Y(`rewind failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}M(ae,e=>{e&&ot()});async function lt(e){if(h.value=!1,r.value&&n.value&&a.value?.root){u.value=`wt`;try{Y((await tp(G(r.value),n.value,a.value.root,e)).text),g.value=``,await Ee()}catch(e){Y(`worktree failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function ut(e,t){if(r.value){u.value=`session`;try{let n=wu.devices.value.find(e=>e.id===r.value)?.info,i=tt(n)[0];if(!i)return Y(`no model available on ${r.value} — cannot create a session`);let a=await np(G(r.value),e,t??e.slice(e.lastIndexOf(`/`)+1),{provider:i.provider,modelId:i.id});Vu({deviceId:r.value,sessionId:a.id,agentId:1}),Y(`session "${a.name}" on ${e}`)}catch(e){Y(`session failed: ${e.message.slice(0,160)}`)}finally{u.value=``}}}async function dt(e){if(r.value){u.value=`go`;try{let t=(await G(r.value).sessions()).find(t=>t.cwd===e);t?(Vu({deviceId:r.value,sessionId:t.id,agentId:1}),Y(`switched to session "${t.name}"`)):await ut(e,null)}catch(e){Y(`switch failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function ft(e){if(!r.value||!n.value)return;u.value=`wt`;let t=`Uncommitted changes in it will be LOST.`;try{let n=(await G(r.value).gitStatusBatch([e],{timeoutMs:6e4}))[e];t=(n?.staged??0)+(n?.unstaged??0)+(n?.untracked??0)>0?`It CONTAINS uncommitted changes — they will be LOST.`:`Its checkout is clean.`}catch{}ne({title:`Remove worktree?`,body:`${e} — ${t}`,confirmLabel:`Remove`,danger:!0,action:()=>void pt(e)})}async function pt(e){u.value=`wt`;try{await G(r.value).gitOp(n.value,`worktree-remove`,{target:e}),await Ee()}catch(e){Y(`remove failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}let mt=k([]),ht=k(!1),gt=k(``),_t=0;async function vt(e=!1){if(r.value&&n.value&&!(!e&&mt.value.length&&Date.now()-_t<12e4)){ht.value=!0;try{let e=await G(r.value).gitOp(n.value,`log-list`);mt.value=e.commits??[],gt.value=``,_t=Date.now()}catch(e){gt.value=e.message.slice(0,120)}finally{ht.value=!1}}}vt(),M([r,n],()=>{mt.value=[],_t=0,vt()});let yt=U(()=>(a.value?.worktrees??[]).filter(e=>e.path)),bt=[`#4f8cc9`,`#b8860b`,`#7aa25c`,`#a061ba`,`#c96f6f`,`#5fa8a0`],xt=U(()=>{let e=new Map,t=[],n=[];for(let r of mt.value){let i=e.get(r.hash);i===void 0&&(i=n.indexOf(null),i===-1&&(n.push(null),i=n.length-1),e.set(r.hash,i)),n[i]=null;let a=[];r.parents.forEach((t,r)=>{let o=e.get(t);(o===void 0||n[o]===t)&&(o=n.indexOf(null),o===-1&&(n.push(null),o=n.length-1),e.set(t,o)),n[o]=t,r===0&&(n[i]=t),a.push(o)}),t.push({lane:i,parents:a,width:Math.max(1,n.length)})}return t}),St=e=>e*12+7;return(e,t)=>(I(),L(`div`,Yb,[n.value?(I(),L(F,{key:1},[o.value?(I(),L(`p`,Zb,`loading git…`)):s.value?(I(),L(`p`,Qb,`refreshing…`)):H(``,!0),c.value?(I(),L(`p`,$b,[V(D(c.value)+` `,1),z(`button`,{onClick:t[0]||=e=>Ee()},`retry`)])):H(``,!0),a.value?(I(),L(`div`,{key:3,class:E({stale:!!c.value||!!s.value})},[a.value.repo?(I(),L(F,{key:1},[a.value.merge?(I(),L(`p`,tx,[V(` merge in progress — `+D(a.value.conflicts??Me.value.length)+` unmerged path(s). Resolve them in the lists above, or `,1),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[1]||=e=>Ze()},`abort merge`,8,nx)])):H(``,!0),z(`div`,rx,[z(`div`,ix,[z(`button`,{class:`branch-btn`,disabled:!!u.value,onClick:t[2]||=e=>m.value=!m.value},[B(A(xc),{size:16}),z(`strong`,null,D(a.value.branch??`detached`),1),B(A(nc),{size:14})],8,ax),m.value?(I(),L(`div`,ox,[(I(!0),L(F,null,P(a.value.branches??[],e=>(I(),L(`button`,{key:e.name,class:E({cur:e.current}),onClick:t=>$e(e.name)},[B(A(xc),{size:13}),z(`span`,null,D(e.name),1),z(`span`,cx,D(e.current?`current`:e.upstream?`→ ${e.upstream}`:``),1),t[42]||=z(`span`,{class:`grow`},null,-1),e.current?H(``,!0):(I(),R(A(Sc),{key:0,size:13,title:`compare with this base`,onClick:ks(t=>Qe(e.name),[`stop`])},null,8,[`onClick`]))],10,sx))),128)),z(`div`,lx,[j(z(`input`,{"onUpdate:modelValue":t[3]||=e=>g.value=e,placeholder:`new branch…`,onKeyup:t[4]||=js(e=>g.value.trim()&&$e(g.value.trim(),!0),[`enter`])},null,544),[[ys,g.value]]),z(`button`,{disabled:!g.value.trim(),onClick:t[5]||=e=>$e(g.value.trim(),!0)},[B(A(Xc),{size:13})],8,ux)]),z(`label`,dx,[j(z(`input`,{type:`checkbox`,"onUpdate:modelValue":t[6]||=e=>x.value=e},null,512),[[bs,x.value]]),t[43]||=V(` auto-stash on switch`,-1)])])):H(``,!0)]),z(`span`,fx,D(a.value.upstream??`no upstream`),1),a.value.ahead?(I(),L(`span`,px,`↑`+D(a.value.ahead),1)):H(``,!0),a.value.behind?(I(),L(`span`,mx,`↓`+D(a.value.behind),1)):H(``,!0),b.value?(I(),L(`span`,hx,[V(` vs `+D(b.value.ref)+`: ↑`+D(b.value.ahead)+` ↓`+D(b.value.behind)+` `,1),z(`button`,{class:`tag-x`,onClick:t[7]||=e=>b.value=null},[B(A(xl),{size:11})])])):H(``,!0),z(`span`,gx,`+`+D(a.value.staged??0)+` ~`+D(a.value.unstaged??0)+` ?`+D(a.value.untracked??0),1),O.value?(I(),L(`a`,{key:3,class:`icon-button`,href:`${O.value}/tree/${a.value.branch??``}`,target:`_blank`,rel:`noopener`,title:`open on the remote`},[B(A(Ks),{size:15,style:{transform:`rotate(45deg)`}})],8,_x)):H(``,!0),z(`button`,{class:`icon-button`,disabled:!!u.value||o.value||s.value,title:`refresh`,onClick:t[8]||=e=>Ee()},[B(A($c),{size:16})],8,vx)]),z(`div`,yx,[z(`button`,{class:`small`,disabled:!!u.value,onClick:t[9]||=e=>Ue(`fetch`)},[B(A(Ws),{size:14}),t[44]||=V(`fetch`,-1)],8,bx),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[10]||=e=>Ue(`pull`)},[B(A(Ws),{size:14}),t[45]||=V(`pull`,-1)],8,xx),z(`button`,{class:`small primary`,disabled:!!u.value,title:`push`,onClick:t[11]||=e=>Ue(`push`)},[B(A(Ks),{size:14}),t[46]||=V(`push`,-1)],8,Sx),z(`button`,{class:`small`,disabled:!!u.value,title:`stash changes`,onClick:t[12]||=e=>Ue(`stash-push`,{message:f.value.trim()||void 0})},[B(A(dl),{size:14}),t[47]||=V(`stash`,-1)],8,Cx),z(`button`,{class:`small`,disabled:!!u.value,title:`pop the newest stash`,onClick:t[13]||=e=>Ue(`stash-pop`)},[B(A(Hc),{size:14}),t[48]||=V(`unstash`,-1)],8,wx)]),S.value?(I(),L(`p`,Tx,[V(D(S.value)+` `,1),S.value.includes(`upstream`)?(I(),L(`button`,{key:0,class:`small primary`,disabled:!!u.value,onClick:t[14]||=e=>Ue(`push`,{setUpstream:!0,ref:a.value.branch})},`push -u origin `+D(a.value.branch),9,Ex)):S.value.includes(`remote has work`)?(I(),L(`button`,{key:1,class:`small primary`,disabled:!!u.value,onClick:t[15]||=e=>Ue(`pull`)},`pull now`,8,Dx)):H(``,!0)])):H(``,!0),C.value?(I(),L(`p`,Ox,[t[49]||=V(` fast-forward is not possible — branches diverged. `,-1),z(`button`,{class:`small primary`,disabled:!!u.value,onClick:t[16]||=e=>Ue(`pull`,{rebase:!0})},`pull --rebase`,8,kx)])):H(``,!0),z(`section`,Ax,[z(`div`,jx,[t[50]||=z(`h4`,null,`Commit`,-1),z(`span`,Mx,D(De.value.length?`${p.value.size}/${De.value.length} files`:`no changes`),1),t[51]||=z(`span`,{class:`grow`},null,-1),l.value?(I(),L(`button`,{key:0,class:`small`,disabled:!!u.value,title:`check the files this session's agent touched`,onClick:rt},[B(A(_c),{size:13}),V(` session files`+D(w.value?` (${w.value.changed}/${w.value.total})`:``),1)],8,Nx)):H(``,!0),l.value?(I(),L(`button`,{key:1,class:`small`,disabled:!!u.value,title:`what each turn of this session changed`,onClick:t[17]||=e=>xe.value=!xe.value},` turns `,8,Px)):H(``,!0)]),Fe.value?(I(),L(`p`,Fx,[...t[52]||=[V(`git user.name/user.email is not set on the device — `,-1),z(`code`,null,`dpi device config`,-1),V(` or `,-1),z(`code`,null,`git config --global`,-1),V(` before committing.`,-1)]])):H(``,!0),xe.value?(I(),L(`div`,Ix,[be.value.length?H(``,!0):(I(),L(`p`,Lx,`no turns recorded yet for this session.`)),(I(!0),L(F,null,P(be.value,(e,t)=>(I(),L(`div`,{key:t,class:`cp-row`},[z(`code`,null,`t`+D(be.value.length-t),1),z(`span`,Rx,D(e.when.slice(0,16).replace(`T`,` `)),1),z(`span`,zx,D(e.files.map(e=>`${e.path}×${e.writes}${e.a!==void 0||e.d!==void 0?` (+${e.a??0} −${e.d??0})`:``}`).join(`, `)||`(no file writes)`),1)]))),128))])):H(``,!0),Ne.value?(I(),L(`p`,Bx,`showing the first 500 changed files — commit in smaller batches`)):H(``,!0),Me.value.length?(I(),L(`div`,Vx,[z(`label`,Hx,[z(`span`,Ux,`Conflicts · `+D(Me.value.length)+` — pick a side per file`,1)]),(I(!0),L(F,null,P(Me.value,e=>(I(),L(`div`,{key:e.path,class:`file`},[z(`label`,Wx,[z(`code`,Gx,D(e.x)+D(e.y),1),z(`span`,{class:`path`,title:e.path},D(e.path),9,Kx)]),z(`span`,qx,[z(`button`,{class:`icon-button`,title:`view the conflict`,onClick:t=>Je(e.path)},[B(A(hc),{size:13})],8,Jx),z(`button`,{class:`small`,disabled:!!u.value,title:`keep this branch's version and stage it`,onClick:t=>Ke(`ours`,e.path)},`ours`,8,Yx),z(`button`,{class:`small`,disabled:!!u.value,title:`take the incoming version and stage it`,onClick:t=>Ke(`theirs`,e.path)},`theirs`,8,Xx)])]))),128))])):H(``,!0),ke.value.length?(I(),L(`div`,Zx,[z(`label`,Qx,[z(`input`,{type:`checkbox`,checked:ke.value.every(e=>p.value.has(e.path)),onChange:t[18]||=e=>Le(ke.value)},null,40,$x),z(`span`,eS,`Staged · `+D(ke.value.length),1),t[55]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,title:`stage every changed file`,onClick:t[19]||=e=>We(`stage`)},[B(A(Xc),{size:13}),t[53]||=V(` all`,-1)]),z(`button`,{class:`icon-button`,title:`unstage all (git reset HEAD)`,onClick:t[20]||=e=>Ge(ke.value.map(e=>e.path))},[B(A(Rc),{size:13}),t[54]||=V(` none`,-1)])]),(I(!0),L(F,null,P(ze(ke.value),e=>(I(),L(F,{key:e.dir},[e.dir===`.`?H(``,!0):(I(),L(`button`,{key:0,class:`dir-row`,onClick:t=>Be(e.dir)},[B(A(rc),{size:12,class:E({open:e.open})},null,8,[`class`]),V(D(e.dir),1),z(`span`,nS,`· `+D(e.files.length),1)],8,tS)),(I(!0),L(F,null,P(e.files,t=>j((I(),L(`div`,{key:t.path,class:`file`},[z(`label`,rS,[z(`input`,{type:`checkbox`,checked:p.value.has(t.path),onChange:e=>Ie(t.path)},null,40,iS),z(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,aS),z(`span`,{class:`path`,title:t.path},D(t.path),9,oS),Ve(t)?(I(),L(`span`,{key:0,class:E([`nums`,{bin:Ve(t)===`bin`}])},D(Ve(t)),3)):H(``,!0)]),z(`span`,sS,[z(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Je(t.path)},[B(A(hc),{size:13})],8,cS),z(`button`,{class:`icon-button`,title:`unstage (git reset HEAD)`,onClick:e=>Ge([t.path])},[B(A(Rc),{size:13})],8,lS),z(`button`,{class:`icon-button`,title:`roll back to HEAD`,onClick:e=>We(`discard`,t.path)},[B(A(uc),{size:13})],8,uS)])])),[[Ro,e.open]])),128))],64))),128))])):H(``,!0),Ae.value.length?(I(),L(`div`,dS,[z(`label`,fS,[z(`input`,{type:`checkbox`,checked:Ae.value.every(e=>p.value.has(e.path)),onChange:t[21]||=e=>Le(Ae.value)},null,40,pS),z(`span`,mS,`Unstaged · `+D(Ae.value.length),1)]),(I(!0),L(F,null,P(ze(Ae.value),e=>(I(),L(F,{key:e.dir},[e.dir===`.`?H(``,!0):(I(),L(`button`,{key:0,class:`dir-row`,onClick:t=>Be(e.dir)},[B(A(rc),{size:12,class:E({open:e.open})},null,8,[`class`]),V(D(e.dir),1),z(`span`,gS,`· `+D(e.files.length),1)],8,hS)),(I(!0),L(F,null,P(e.files,t=>j((I(),L(`div`,{key:t.path,class:`file`},[z(`label`,_S,[z(`input`,{type:`checkbox`,checked:p.value.has(t.path),onChange:e=>Ie(t.path)},null,40,vS),z(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,yS),z(`span`,{class:`path`,title:t.path},D(t.path),9,bS),Ve(t)?(I(),L(`span`,{key:0,class:E([`nums`,{bin:Ve(t)===`bin`}])},D(Ve(t)),3)):H(``,!0)]),z(`span`,xS,[z(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Je(t.path)},[B(A(hc),{size:13})],8,SS),t.x===`?`?(I(),L(`button`,{key:0,class:`icon-button`,title:`add to .gitignore`,onClick:e=>qe([t.path])},[B(A(Ys),{size:13})],8,CS)):(I(),L(`button`,{key:1,class:`icon-button`,title:`stage (git add)`,onClick:e=>We(`stage`,t.path)},[B(A(Xc),{size:13})],8,wS)),t.x===`?`?H(``,!0):(I(),L(`button`,{key:2,class:`icon-button`,title:`roll back to HEAD`,onClick:e=>We(`discard`,t.path)},[B(A(uc),{size:13})],8,TS)),z(`button`,{class:`icon-button`,title:`copy path`,onClick:e=>He(t.path)},[B(A(sc),{size:13})],8,ES)])])),[[Ro,e.open]])),128))],64))),128))])):H(``,!0),_.value?(I(),L(`p`,DS,[z(`strong`,null,D(_.value.path),1),z(`span`,OS,[z(`button`,{class:E({on:v.value===`working`}),onClick:t[22]||=e=>{v.value=`working`,Ye()}},`working`,2),z(`button`,{class:E({on:v.value===`staged`}),onClick:t[23]||=e=>{v.value=`staged`,Ye()}},`staged`,2)]),Xe.value?(I(),L(`span`,kS,`binary file`)):_.value.text.length>8e3?(I(),L(`span`,AS,`truncated at 8000 chars`)):H(``,!0),z(`button`,{class:`icon-button`,title:`close diff`,onClick:t[24]||=e=>_.value=null},[B(A(xl),{size:13})]),Xe.value?H(``,!0):(I(),L(`pre`,jS,D(_.value.text.slice(0,8e3)),1))])):H(``,!0),j(z(`textarea`,{"onUpdate:modelValue":t[25]||=e=>f.value=e,rows:`4`,placeholder:`Commit message… (Ctrl+Enter to commit)`,onKeydown:[t[26]||=js(ks(e=>et(),[`exact`,`prevent`]),[`enter`]),t[27]||=js(ks(e=>et(),[`meta`,`prevent`]),[`enter`]),t[28]||=js(ks(e=>et(),[`ctrl`,`prevent`]),[`enter`])]},null,544),[[ys,f.value]]),z(`div`,MS,[z(`button`,{class:`small`,disabled:!!u.value||!p.value.size,title:`ask the device's model for a message`,onClick:nt},[B(A(ll),{size:14}),t[56]||=V(` ai message`,-1)],8,NS),t[58]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`primary small`,disabled:!!u.value||!f.value.trim()||!Oe.value,onClick:t[29]||=e=>et(!1)},[B(A(tc),{size:14}),V(` Commit`+D(p.value.size?` ${p.value.size} file${p.value.size>1?`s`:``}`:``),1)],8,PS),a.value.upstream?(I(),L(`button`,{key:0,class:`primary small`,disabled:!!u.value||!f.value.trim()||!Oe.value,title:`commit, then push`,onClick:t[30]||=e=>et(!0)},[B(A(tc),{size:14}),t[57]||=V(` Commit & push `,-1)],8,FS)):H(``,!0)])]),z(`section`,IS,[z(`div`,LS,[z(`h4`,null,[B(A(Ec),{size:16}),t[59]||=V(` Log`,-1)]),t[61]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:!!u.value,title:`save a checkpoint ref of HEAD`,onClick:at},[B(A(_c),{size:13}),t[60]||=V(` checkpoint`,-1)],8,RS),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[31]||=e=>ae.value=!ae.value},`checkpoints `+D(ie.value.length?`(${ie.value.length})`:``),9,zS),z(`button`,{class:`icon-button`,disabled:ht.value,title:`refresh log`,onClick:t[32]||=e=>vt(!0)},[B(A($c),{size:14})],8,BS)]),ae.value?(I(),L(`div`,VS,[ie.value.length?H(``,!0):(I(),L(`p`,HS,`no checkpoints yet — one click saves a named ref of HEAD.`)),(I(!0),L(F,null,P(ie.value,e=>(I(),L(`div`,{key:e.name,class:`cp-row`},[z(`code`,null,D(e.name),1),z(`span`,US,D(e.hash)+` · `+D(e.date),1),z(`span`,WS,D(e.subject),1),t[63]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:!!u.value,title:`reset --hard to this checkpoint (this worktree)`,onClick:t=>st(e.name)},[B(A(hl),{size:13}),t[62]||=V(` rewind`,-1)],8,GS)]))),128))])):H(``,!0),ht.value&&!mt.value.length?(I(),L(`p`,KS,`loading log…`)):mt.value.length?(I(),L(`div`,qS,[(I(!0),L(F,null,P(mt.value,(e,t)=>(I(),L(F,{key:e.hash},[z(`div`,{class:`commit-row`,title:e.refs},[xt.value[t]?(I(),L(`svg`,{key:0,class:`lane`,width:xt.value[t].width*12+4,height:`24`,"aria-hidden":`true`},[(I(!0),L(F,null,P(xt.value[t].width,e=>(I(),L(`line`,{key:e,x1:St(e-1),x2:St(e-1),y1:`0`,y2:`24`,stroke:`#3a3134`,"stroke-width":`2`},null,8,XS))),128)),(I(!0),L(F,null,P(xt.value[t].parents,(e,n)=>(I(),L(`line`,{key:`p`+n,x1:St(xt.value[t].lane),x2:St(e),y1:`12`,y2:`24`,stroke:bt[e%bt.length],"stroke-width":`2`},null,8,ZS))),128)),z(`circle`,{cx:St(xt.value[t].lane),cy:`12`,r:`4`,fill:bt[xt.value[t].lane%bt.length]},null,8,QS)],8,YS)):H(``,!0),z(`button`,{class:`icon-button hash-btn`,title:`files in this commit`,onClick:t=>it(e.hash)},[B(A(rc),{size:12,class:E({open:oe.value.has(e.hash)})},null,8,[`class`])],8,$S),z(`code`,eC,[O.value?(I(),L(`a`,{key:0,href:`${O.value}/commit/${e.hash}`,target:`_blank`,rel:`noopener`,title:`on the remote`},D(e.hash),9,tC)):(I(),L(F,{key:1},[V(D(e.hash),1)],64))]),e.refs?(I(),L(`span`,nC,D(e.refs.split(`,`)[0]),1)):H(``,!0),z(`span`,rC,D(e.subject),1),z(`span`,iC,D(e.author)+` · `+D(e.date),1)],8,JS),oe.value.has(e.hash)?(I(),L(`div`,aC,[(I(!0),L(F,null,P(oe.value.get(e.hash),e=>(I(),L(`div`,{key:e.path,class:`cf`},[z(`code`,{class:`cf-status`,"data-s":e.status},D(e.status),9,oC),z(`span`,sC,D(e.path),1)]))),128)),oe.value.get(e.hash)?.length?H(``,!0):(I(),L(`p`,cC,`no files (merge/empty commit)`))])):H(``,!0)],64))),128))])):gt.value?(I(),L(`p`,lC,`log failed: `+D(gt.value),1)):(I(),L(`p`,uC,`no commits`))]),z(`section`,dC,[z(`div`,fC,[z(`h4`,null,[B(A(Hc),{size:16}),t[64]||=V(` Worktrees`,-1)]),z(`div`,pC,[z(`button`,{class:`small`,disabled:!!u.value,onClick:t[33]||=e=>h.value=!h.value},[B(A(Xc),{size:13}),t[65]||=V(` worktree`,-1)],8,mC),h.value?(I(),L(`div`,hC,[(I(!0),L(F,null,P((a.value.branches??[]).filter(e=>!e.current),e=>(I(),L(`button`,{key:e.name,onClick:t=>lt(e.name)},[B(A(xc),{size:13}),z(`span`,null,D(e.name),1),t[66]||=z(`span`,{class:`muted-line`},`existing`,-1)],8,gC))),128)),z(`div`,_C,[j(z(`input`,{"onUpdate:modelValue":t[34]||=e=>g.value=e,placeholder:`or a NEW branch…`,onKeyup:t[35]||=js(e=>g.value.trim()&&lt(g.value.trim()),[`enter`])},null,544),[[ys,g.value]]),z(`button`,{disabled:!g.value.trim(),onClick:t[36]||=e=>lt(g.value.trim())},`create`,8,vC)])])):H(``,!0)])]),(I(!0),L(F,null,P(yt.value,e=>(I(),L(`div`,{key:e.path,class:E([`wt`,{main:e.path===a.value.root}])},[z(`code`,{title:e.path},D(e.path),9,yC),z(`span`,bC,D(e.branch??e.head),1),t[67]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,disabled:!!u.value,title:`jump to this worktree (session or new)`,onClick:t=>dt(e.path)},[B(A(Gs),{size:13})],8,xC),z(`button`,{class:`small`,disabled:!!u.value,title:`create a session on this worktree`,onClick:t=>ut(e.path,e.branch)},`session`,8,SC),e.path===a.value.root?H(``,!0):(I(),L(`button`,{key:0,class:`icon-button`,disabled:!!u.value,onClick:t=>ft(e.path)},[B(A(xl),{size:13})],8,CC)),e.path===a.value.root?(I(),R(A(tc),{key:1,size:13,class:`muted-line`})):H(``,!0)],2))),128))]),de.value?(I(),L(`section`,wC,[z(`div`,TC,[z(`h4`,null,[B(A(wc),{size:16}),t[68]||=V(` Pull requests`,-1)]),t[69]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:ue.value||!!u.value,onClick:pe},`create PR`,8,EC),z(`button`,{class:`small`,disabled:ue.value,onClick:t[37]||=e=>ce.value=!ce.value},D(ce.value?`hide`:`list`),9,DC)]),ce.value&&!se.value.length&&!ue.value?(I(),L(`p`,OC,`no open PRs (or gh is not logged in on the device — every action will say so).`)):H(``,!0),ce.value?(I(),L(`div`,kC,[(I(!0),L(F,null,P(se.value,e=>(I(),L(`div`,{key:e.n,class:`pr-row`},[z(`code`,AC,`#`+D(e.n),1),z(`span`,{class:E([`tag`,{open:e.state===`OPEN`}])},D(e.state.toLowerCase())+D(e.draft?` · draft`:``),3),z(`span`,jC,D(e.title),1),z(`span`,MC,D(e.branch),1),t[70]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,title:`run checks`,disabled:ue.value,onClick:t=>he(e.n)},[B(A($c),{size:13})],8,NC),z(`button`,{class:`icon-button`,title:`comment`,disabled:ue.value,onClick:t=>ve(e.n)},[B(A(sc),{size:13})],8,PC),e.state===`OPEN`?(I(),L(`button`,{key:0,class:`small`,disabled:ue.value||!!u.value,onClick:t=>ge(e.n)},`squash & merge`,8,FC)):H(``,!0),z(`a`,{class:`icon-button`,href:e.url,target:`_blank`,rel:`noopener`,title:`open on the forge`},[B(A(Ks),{size:13,style:{transform:`rotate(45deg)`}})],8,IC)]))),128)),(I(!0),L(F,null,P(le.value,([e,t])=>(I(),L(`pre`,{key:e,class:`pr-checks`},`#`+D(e)+` checks:`+D(`
79
+ `)+D(t),1))),128))])):H(``,!0)])):H(``,!0),d.value?(I(),L(`pre`,LC,D(d.value.slice(0,6e3)),1)):H(``,!0)],64)):(I(),L(`p`,ex,[...t[41]||=[V(`Not a git repository — run `,-1),z(`code`,null,`git init`,-1),V(` (or open a session inside a repo).`,-1)]]))],2)):H(``,!0),T.value?(I(),L(`div`,{key:4,class:`modal-veil`,onClick:t[40]||=ks(e=>T.value=null,[`self`])},[z(`div`,{class:E([`modal`,{danger:T.value.danger}]),role:`dialog`,"aria-modal":`true`},[z(`h5`,null,D(T.value.title),1),z(`p`,null,D(T.value.body),1),T.value.input?j((I(),L(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>te.value=e,rows:`2`,placeholder:T.value.input.placeholder},null,8,RC)),[[ys,te.value]]):H(``,!0),z(`div`,zC,[t[72]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,onClick:t[39]||=e=>T.value=null},[...t[71]||=[V(`cancel `,-1),z(`span`,{class:`muted-line`},`(esc)`,-1)]]),z(`button`,{class:E([`primary small`,{danger:T.value.danger}]),disabled:!(!T.value.input||te.value.trim()),onClick:re},D(T.value.confirmLabel??`confirm`),11,BC)])],2)])):H(``,!0)],64)):(I(),L(`p`,Xb,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-6598e11c`]]),HC={class:`host-panel`,"aria-label":`Device vitals`},UC={class:`panel-heading`},WC=[`disabled`],GC={key:0,class:`hint`},KC={key:1,class:`message-error`},qC={key:2,class:`hint`},JC={class:`vitals-grid`},YC={class:`vital`},XC={class:`vital`},ZC={key:0,class:`vital`},QC={class:`vital`},$C={class:`vital`},ew={class:`meter`},tw={class:`meter-head`},nw={class:`hint`},rw=[`aria-valuenow`],iw={class:`meter`},aw={class:`meter-head`},ow={class:`hint`},sw=[`aria-valuenow`],cw={class:`path`},lw={class:`hint`},uw=Hd(N({__name:`HostPanel`,setup(e){let t=k(),n=k(!1),r=k(``),i=U(()=>q.value?.deviceId),a=U(()=>wu.devices.value.find(e=>e.id===i.value)?.info?.keepAwake),o=e=>{if(!Number.isFinite(e)||e<=0)return`0`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=100||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`},s=e=>{let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`},c=(e,t)=>t>0?Math.max(0,Math.min(100,Math.round(e/t*100))):0,l=U(()=>t.value?c(t.value.memory.usedBytes,t.value.memory.totalBytes):0),u=U(()=>t.value?.disk.known?c(t.value.disk.totalBytes-t.value.disk.freeBytes,t.value.disk.totalBytes):0);async function d(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).vitals()}catch(e){r.value=K(e).slice(0,160)}finally{n.value=!1}}}M(i,d,{immediate:!0});async function f(){await d(),r.value||Y(`Vitals refreshed.`)}return(e,c)=>(I(),L(`section`,HC,[z(`header`,UC,[z(`span`,null,[B(A(il),{size:16}),c[0]||=V(`HOST`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:f},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,WC)]),i.value?r.value?(I(),L(`p`,KC,D(r.value),1)):t.value?(I(),L(F,{key:3},[z(`div`,JC,[z(`div`,YC,[c[1]||=z(`span`,{class:`label`},`Host uptime`,-1),z(`strong`,null,D(s(t.value.uptime)),1)]),z(`div`,XC,[c[2]||=z(`span`,{class:`label`},`Device process`,-1),z(`strong`,null,D(s(t.value.processUptime)),1),z(`em`,null,`pid `+D(t.value.pid),1)]),a.value?(I(),L(`div`,ZC,[c[3]||=z(`span`,{class:`label`},`Keep-awake`,-1),z(`strong`,null,D(a.value===`none`?`off`:a.value),1),z(`em`,null,D(a.value===`none`?`no inhibitor here`:`held while sessions run`),1)])):H(``,!0),z(`div`,QC,[c[4]||=z(`span`,{class:`label`},`Load (1/5/15m)`,-1),z(`strong`,null,D(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),z(`em`,null,D(t.value.cpuCount)+` CPU`+D(t.value.cpuCount===1?``:`s`),1)]),z(`div`,$C,[c[5]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(t.value.counts?.sessions??0),1),z(`em`,null,D(t.value.counts?.archived??0)+` archived`,1)])]),z(`div`,ew,[z(`div`,tw,[c[6]||=z(`span`,{class:`label`},`Memory`,-1),z(`span`,nw,D(o(t.value.memory.usedBytes))+` / `+D(o(t.value.memory.totalBytes))+` · device `+D(o(t.value.memory.processRssBytes)),1)]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[z(`i`,{style:ge({width:`${l.value}%`}),class:E({high:l.value>=90})},null,6)],8,rw)]),z(`div`,iw,[z(`div`,aw,[c[7]||=z(`span`,{class:`label`},`Disk · data dir`,-1),z(`span`,ow,[t.value.disk.known?(I(),L(F,{key:0},[V(D(o(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+D(o(t.value.disk.freeBytes))+` free `,1)],64)):(I(),L(F,{key:1},[V(`unknown on this volume`)],64))])]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":u.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[z(`i`,{style:ge({width:`${u.value}%`}),class:E({high:u.value>=90})},null,6)],8,sw),z(`code`,cw,D(t.value.disk.path),1)]),z(`p`,lw,[B(A(Vs),{size:13}),c[8]||=V(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(I(),L(`p`,qC,D(n.value?`Reading host…`:`No vitals.`),1)):(I(),L(`p`,GC,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-ef6f9dc5`]]);function dw(e){let t=K(e);return e.code===`not_found`||/allowlist|not found/i.test(t)}function fw(e,t){let n=wu.devices.value.find(t=>t.id===e),r=n?.name||`This device`,i=n?.info;return i&&!i.packageVersion&&i.durableVersion?`${r} runs the pre-rename build (durable ${i.durableVersion}) — ${t} needs the new one. On that machine: npm i -g my-durable@latest, then dpi device stop && dpi device start.`:`${r} runs an older build — ${t}. Update it on that machine (\`dpi update\`).`}var pw={class:`usage-panel`,"aria-label":`Device usage`},mw={class:`panel-heading`},hw=[`disabled`],gw={key:0,class:`hint`},_w={key:1,class:`message-error`},vw={key:2,class:`hint`},yw={key:3,class:`hint`},bw={class:`usage-block`,"aria-labelledby":`usage-totals`},xw={class:`totals`},Sw={class:`total`},Cw={class:`total`},ww={class:`total`},Tw={class:`total`},Ew={class:`usage-block`,"aria-labelledby":`usage-models`},Dw={class:`section-label block-label`},Ow={class:`table-scroll`},kw={class:`usage-table`,"aria-label":`Usage by model`},Aw=[`title`],jw={class:`num`},Mw={class:`num`},Nw={class:`share-col`},Pw={class:`share`},Fw=[`aria-valuenow`,`aria-label`],Iw={class:`pct`},Lw={class:`usage-block`,"aria-labelledby":`usage-projects`},Rw={class:`section-label block-label`},zw={key:0,class:`hint`},Bw={key:1,class:`rows`},Vw=[`title`],Hw={class:`row-main`},Uw={class:`row-num`},Ww={class:`row-num`},Gw={class:`row-meta`},Kw={class:`usage-block`,"aria-labelledby":`usage-sessions`},qw={key:0,class:`hint`},Jw={key:1,class:`rows scroll`},Yw=[`title`],Xw={class:`row-main`},Zw={class:`row-num`},Qw={class:`row-num`},$w={class:`row-meta`},eT={class:`hint`},tT=Hd(N({__name:`UsagePanel`,setup(e){let t=k(),n=k(!1),r=k(``),i=U(()=>q.value?.deviceId),a=e=>Math.round(e||0).toLocaleString(`en-US`),o=e=>{let t=e||0;return t===0?`$0.0000`:t<1e-4?`$${t.toPrecision(2)}`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`},s=U(()=>(t.value?.models??[]).reduce((e,t)=>Math.max(e,t.cost||0),0)),c=e=>s.value>0?Math.max(0,Math.min(100,Math.round((e||0)/s.value*100))):0,l=U(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=U(()=>t.value?new Date(t.value.at).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`}):``),d=(e,t)=>`${a(e)} ${t}${e===1?``:`s`}`;async function f(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).deviceUsage()}catch(e){r.value=dw(e)?fw(i.value,`usage`):K(e).slice(0,220)}finally{n.value=!1}}}M(i,f,{immediate:!0});async function p(){await f(),r.value||Y(`Usage refreshed.`)}return(e,s)=>(I(),L(`section`,pw,[z(`header`,mw,[z(`span`,null,[B(A(Vs),{size:16}),s[0]||=V(`USAGE`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,hw)]),i.value?r.value?(I(),L(`p`,_w,D(r.value),1)):t.value?l.value?(I(),L(`p`,yw,`No usage recorded yet.`)):(I(),L(F,{key:4},[z(`section`,bw,[s[6]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-totals`},`TOTALS`)],-1),z(`div`,xw,[z(`div`,Sw,[s[1]||=z(`span`,{class:`label`},`Tokens`,-1),z(`strong`,null,D(a(t.value.totals.tokens)),1)]),z(`div`,Cw,[s[2]||=z(`span`,{class:`label`},`Cost`,-1),z(`strong`,null,D(o(t.value.totals.cost)),1)]),z(`div`,ww,[s[3]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(a(t.value.sessions.length)),1),z(`em`,null,D(a(t.value.projects.length))+` projects`,1)]),z(`div`,Tw,[s[4]||=z(`span`,{class:`label`},`Models`,-1),z(`strong`,null,D(a(t.value.models.length)),1),s[5]||=z(`em`,null,`costliest first`,-1)])])]),z(`section`,Ew,[z(`div`,Dw,[s[7]||=z(`span`,{id:`usage-models`},`BY MODEL`,-1),B(A(dc),{size:13})]),z(`div`,Ow,[z(`table`,kw,[s[8]||=z(`colgroup`,null,[z(`col`),z(`col`),z(`col`),z(`col`)],-1),s[9]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Model`),z(`th`,{scope:`col`,class:`num`},`Tokens`),z(`th`,{scope:`col`,class:`num`},`Cost`),z(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(t.value.models,e=>(I(),L(`tr`,{key:e.key},[z(`th`,{scope:`row`,class:`model-key`,title:`${e.key} — in ${e.input} · out ${e.output} · cache read ${e.cacheRead} · cache write ${e.cacheWrite}`},D(e.key),9,Aw),z(`td`,jw,D(a(e.tokens)),1),z(`td`,Mw,D(o(e.cost)),1),z(`td`,Nw,[z(`div`,Pw,[z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":c(e.cost),"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`${e.key} share of the costliest model`},[z(`i`,{style:ge({width:`${c(e.cost)}%`}),class:E({high:c(e.cost)>90})},null,6)],8,Fw),z(`em`,Iw,D(c(e.cost))+`%`,1)])])]))),128))])])])]),z(`section`,Lw,[z(`div`,Rw,[s[10]||=z(`span`,{id:`usage-projects`},`BY PROJECT`,-1),B(A(vc),{size:13})]),t.value.projects.length?(I(),L(`ul`,Bw,[(I(!0),L(F,null,P(t.value.projects,e=>(I(),L(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[z(`span`,Hw,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.rootPath),1)]),z(`span`,Uw,D(a(e.tokens))+` tok`,1),z(`span`,Ww,D(o(e.cost)),1),z(`span`,Gw,D(d(e.sessions,`session`)),1)],8,Vw))),128))])):(I(),L(`p`,zw,`No project usage recorded yet.`))]),z(`section`,Kw,[s[11]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(I(),L(`ul`,Jw,[(I(!0),L(F,null,P(t.value.sessions,e=>(I(),L(`li`,{key:e.id,class:`row`,title:e.cwd},[z(`span`,Xw,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.project??e.cwd),1)]),z(`span`,Zw,D(a(e.tokens))+` tok`,1),z(`span`,Qw,D(o(e.cost)),1),z(`span`,$w,D(d(e.agents,`agent`)),1)],8,Yw))),128))])):(I(),L(`p`,qw,`No session usage recorded yet.`))]),z(`p`,eT,[B(A(Vs),{size:13}),V(` Read on demand — open this tab or press refresh (`+D(u.value)+`). Nothing polls the device. `,1)])],64)):(I(),L(`p`,vw,D(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(I(),L(`p`,gw,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-7a8f5c75`]]),nT={class:`schedules-panel`,"aria-label":`Scheduled sessions`},rT={class:`panel-heading`},iT=[`disabled`],aT=[`disabled`],oT={key:0,class:`hint`},sT={key:1,class:`message-error`},cT=[`disabled`],lT={key:0,value:``},uT={key:1,value:``},dT=[`value`],fT={class:`trigger-row`},pT={class:`inline`},mT=[`disabled`],hT={class:`inline`},gT=[`disabled`],_T={class:`row`},vT=[`disabled`],yT={key:3,class:`hint`},bT={key:4,class:`schedule-list`},xT={class:`head`},ST={class:`tag`},CT={key:0,class:`tag running`},wT=[`title`],TT={class:`next`},ET={class:`cwd`},DT={key:0,class:`message-error`},OT={class:`row`},kT=[`disabled`,`onClick`],AT=[`disabled`,`onClick`],jT=[`disabled`,`onClick`],MT=Hd(N({__name:`SchedulesPanel`,setup(e){let t=k([]),n=k(``),r=k(``),i=k(!1),a=U(()=>q.value?.deviceId),o=()=>G(a.value??``),s=k(`60`),c=k(``),l=k(!1),u=k({name:``,cwd:``,prompt:``,model:``});async function d(){if(!a.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await o().schedules()).schedules}catch(e){r.value=dw(e)?fw(a.value,`schedules`):K(e).slice(0,220)}finally{i.value=!1}}M(a,d,{immediate:!0});let f=e=>{if(!e)return`—`;let t=e-Date.now(),n=Math.round(Math.abs(t)/6e4),r=n<60?`${n}m`:n<1440?`${Math.round(n/60)}h`:`${Math.round(n/1440)}d`;return t>=0?`in ${r}`:`${r} ago`},p=e=>e.everyMinutes?`every ${e.everyMinutes}m`:`daily ${e.dailyAt}`;async function m(e,t,r){n.value=e;try{await t(),await d(),Y(r)}catch(e){Y(K(e).slice(0,140))}finally{n.value=``}}let h=e=>m(e.id,()=>o().updateSchedule(e.id,{enabled:!e.enabled}),e.enabled?`Schedule paused.`:`Schedule resumed.`),g=e=>m(e.id,()=>o().runSchedule(e.id),`${e.name}: run started.`),_=e=>J.dialog={kind:`prompt`,title:`Remove ${e.name}?`,hint:`The schedule stops being run. Sessions it already created are untouched.`,submit:`Remove schedule`,danger:!0,run:()=>m(e.id,()=>o().removeSchedule(e.id),`Schedule removed.`)},v=k([]),y=k(!1);async function b(){l.value=!0,u.value={name:``,cwd:``,prompt:``,model:``},v.value=[],y.value=!0;try{let e=await o().device();v.value=e.models.map(e=>({key:`${e.provider}/${e.id}`})),u.value.model=e.defaultModel}catch{v.value=[]}finally{y.value=!1}}async function x(){let e=u.value,[t,...r]=e.model.split(`/`),i=r.join(`/`);if(e.name.trim()&&e.cwd.trim()&&e.prompt.trim()){if(!t||!i){Y(y.value?`Still loading the model list — one moment.`:`Pick a model first.`);return}n.value=`new`;try{await o().createSchedule({name:e.name.trim(),cwd:e.cwd.trim(),prompt:e.prompt,model:{provider:t,modelId:i},...c.value.trim()?{dailyAt:c.value.trim()}:{everyMinutes:Number(s.value)||60}}),l.value=!1,await d(),Y(`Schedule created. The device runs it on its own clock.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(I(),L(`section`,nT,[z(`header`,rT,[z(`span`,null,[B(A(ec),{size:16}),o[7]||=V(`SCHEDULES`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[B(A($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,iT),z(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:b},[B(A(Xc),{size:15})],8,aT)]),o[18]||=z(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(I(),L(`p`,sT,D(r.value),1)):H(``,!0):(I(),L(`p`,oT,`Select a session to see its device.`)),l.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(x,[`prevent`])},[z(`label`,null,[o[8]||=V(`Name`,-1),j(z(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[ys,u.value.name]])]),z(`label`,null,[o[9]||=V(`Directory`,-1),j(z(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[ys,u.value.cwd]])]),z(`label`,null,[o[10]||=V(`Prompt`,-1),j(z(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[ys,u.value.prompt]])]),z(`label`,null,[o[11]||=V(`Model `,-1),j(z(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e,disabled:y.value},[y.value?(I(),L(`option`,lT,`loading…`)):v.value.length?H(``,!0):(I(),L(`option`,uT,`(no models — check the device)`)),(I(!0),L(F,null,P(v.value,e=>(I(),L(`option`,{key:e.key,value:e.key},D(e.key),9,dT))),128))],8,cT),[[Ss,u.value.model]])]),z(`div`,fT,[z(`label`,pT,[o[12]||=V(`Every `,-1),j(z(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,mT),[[ys,s.value]]),o[13]||=V(` min`,-1)]),o[15]||=z(`span`,{class:`muted`},`or`,-1),z(`label`,hT,[o[14]||=V(`daily at `,-1),j(z(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,gT),[[ys,c.value]])])]),z(`div`,_T,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`||y.value||!u.value.model},D(n.value===`new`?`creating…`:y.value?`loading models…`:`Create schedule`),9,vT),z(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):H(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(I(),L(`p`,yT,D(i.value?`Reading schedules…`:`No schedules yet. Press + to add one.`),1)):H(``,!0),t.value.length?(I(),L(`ul`,bT,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`schedule`,{off:!e.enabled}])},[z(`div`,xT,[z(`b`,null,D(e.name),1),z(`span`,ST,D(p(e)),1),e.running?(I(),L(`span`,CT,`running`)):e.lastOutcome===`failed`?(I(),L(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,wT)):H(``,!0),z(`span`,TT,D(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),z(`code`,ET,D(e.cwd),1),e.lastError?(I(),L(`p`,DT,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,OT,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[B(A(Yc),{size:12}),o[16]||=V(`run now`,-1)],8,kT),z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[B(A(Zc),{size:12}),V(D(e.enabled?`pause`:`resume`),1)],8,AT),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[B(A(ml),{size:12}),o[17]||=V(`remove`,-1)],8,jT)])],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-1284f0f2`]]),NT={class:`archive-panel`,"aria-label":`Old sessions`},PT={class:`panel-heading`},FT=[`disabled`],IT={key:0,class:`hint`},LT={key:1,class:`message-error`},RT={key:2,class:`hint`},zT={key:3,class:`old-list`},BT={class:`head`},VT=[`title`],HT={class:`meta`},UT=[`aria-label`,`onClick`],WT=[`aria-label`,`onClick`],GT={class:`facts`},KT={key:0,class:`cwd`},qT={key:1,class:`tag`},JT={class:`meta`},YT={class:`meta`},XT={key:2,class:`meta`},ZT=Hd(N({__name:`ArchivePanel`,setup(e){let t=k(null),n=k(!1),r=k(``),i=U(()=>q.value?.deviceId),a=()=>G(i.value??``);async function o(){if(!i.value)return void(t.value=null);n.value=!0,r.value=``;try{t.value=(await a().archived()).sessions}catch(e){r.value=dw(e)?fw(i.value,`browsing old sessions`):K(e).slice(0,220)}finally{n.value=!1}}M(i,o,{immediate:!0});let s=e=>{if(e<=0)return`0`;let t=[`B`,`KiB`,`MiB`,`GiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=100||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`},c=e=>{let t=Math.max(0,(Date.now()-e)/1e3);return t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`};function l(e){J.dialog={kind:`prompt`,title:`Restore “${e.name}”?`,hint:`The session returns to the live list with its transcript and jobs intact. Nothing is copied — the bundle simply moves back.`,submit:`Restore`,run:async()=>{await a().restoreArchived(e.sessionId),await o(),Y(`${e.name} restored to the live list.`)}}}async function u(e){try{let t=await a().archivedTranscript(e.sessionId,`markdown`),n=new Blob([t.text??``],{type:`text/markdown`}),r=document.createElement(`a`);r.href=URL.createObjectURL(n),r.download=`${e.name.replace(/[^\w.-]+/g,`_`)||e.sessionId}.md`,r.click(),URL.revokeObjectURL(r.href)}catch(e){Y(K(e).slice(0,160))}}return(e,a)=>(I(),L(`section`,NT,[z(`header`,PT,[z(`span`,null,[B(A(Us),{size:16}),a[0]||=V(`ARCHIVE`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh archive`,title:`Refresh archive`,onClick:o},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,FT)]),a[2]||=z(`p`,{class:`hint`},` Every session this device ever archived — read-only. Restore brings one back to the live list; nothing here deletes. `,-1),i.value?r.value?(I(),L(`p`,LT,D(r.value),1)):t.value&&!t.value.length?(I(),L(`p`,RT,`Nothing archived on this device yet.`)):H(``,!0):(I(),L(`p`,IT,`Select a session to see its device.`)),t.value?.length?(I(),L(`ul`,zT,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:`${e.sessionId}-${e.archivedAt}`,class:`old`},[z(`div`,BT,[z(`b`,null,D(e.name),1),z(`span`,{class:`tag`,title:e.hasManifest?`bundled with full identity`:`old bundle — name unknown`},D(e.hasManifest?`manifest`:`legacy`),9,VT),z(`span`,HT,`archived `+D(c(e.archivedAt)),1),a[1]||=z(`span`,{class:`spacer`},null,-1),z(`button`,{class:`icon-button`,"aria-label":`Download transcript of ${e.name}`,title:`Download transcript (markdown)`,onClick:t=>u(e)},[B(A(pc),{size:13})],8,UT),z(`button`,{class:`icon-button`,"aria-label":`Restore ${e.name}`,title:`Restore to the live list`,onClick:t=>l(e)},[B(A(tl),{size:13})],8,WT)]),z(`div`,GT,[e.cwd?(I(),L(`span`,KT,D(e.cwd),1)):H(``,!0),e.model?(I(),L(`span`,qT,D(e.model),1)):H(``,!0),z(`span`,JT,D(e.turns>=0?`${e.turns} turns`:`turns unknown`),1),z(`span`,YT,D(s(e.bytes)),1),e.lastMessageAt?(I(),L(`span`,XT,`last message `+D(c(e.lastMessageAt)),1)):H(``,!0)])]))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-054371cd`]]),QT={class:`graph-panel`,"aria-label":`Task graphs`},$T={class:`panel-heading`},eE=[`disabled`],tE=[`disabled`],nE={key:0,class:`hint`},rE={key:1,class:`message-error`},iE={key:2,class:`hint`},aE={class:`row`},oE=[`disabled`],sE={class:`head`},cE=[`title`],lE=[`aria-label`,`disabled`,`onClick`],uE=[`aria-label`,`onClick`],dE={class:`tasks`},fE=[`title`],pE={key:0,class:`deps`},mE={class:`tag`},hE={key:1,class:`err`},gE=Hd(N({__name:`GraphPanel`,setup(e){let t=k([]),n=k({}),r=k(!1),i=k(``),a=k(``),o=k(!1),s=k(``),c=U(()=>q.value?.deviceId),l=()=>G(c.value??``);async function u(){if(!c.value)return void(t.value=[]);r.value=!0,i.value=``;try{let e=await l().graphs();t.value=e.graphs,n.value={}}catch(e){i.value=dw(e)?fw(c.value,`running task-graphs`):K(e).slice(0,220)}finally{r.value=!1}}M(c,u,{immediate:!0});let d={ok:`ok`,failed:`bad`,running:`run`,pending:``,skipped:`skip`};function f(e,t){return n.value[e.id]?.tasks[t]?.status??e.lastRun?.tasks[t]?.status??`pending`}async function p(e){try{let t=await l().graph(e.id);n.value={...n.value,[e.id]:t.runs[0]??e.lastRun},t.runs.length||Y(`This graph has not run yet.`)}catch(e){Y(K(e).slice(0,140))}}async function m(e){a.value=e.id;try{let{run:t}=await l().runGraph(e.id);n.value={...n.value,[e.id]:t},Y(`Run started: ${Object.keys(t.tasks).length} tasks.`),p(e)}catch(e){Y(K(e).slice(0,140))}finally{a.value=``}}function h(e){J.dialog={kind:`prompt`,title:`Remove the graph "${e.name}"?`,hint:`The registry record goes. Sessions the graph created are never touched.`,submit:`Remove graph`,danger:!0,run:async()=>{await l().removeGraph(e.id),await u()}}}async function g(){let e=s.value.trim();if(e){a.value=`new`;try{let t=JSON.parse(e),n=await l().createGraph({name:String(t.name??``),cwd:String(t.cwd??``),tasks:t.tasks});o.value=!1,s.value=``,Y(`Graph "${n.name}" added (${n.tasks.length} tasks).`),await u()}catch(e){Y(K(e).slice(0,200))}finally{a.value=``}}}return(e,l)=>(I(),L(`section`,QT,[z(`header`,$T,[z(`span`,null,[B(A(gl),{size:16}),l[3]||=V(`DAG`,-1)]),z(`button`,{class:`icon-button`,disabled:r.value||!c.value,"aria-label":`Refresh graphs`,title:`Refresh`,onClick:u},[B(A($c),{size:15,class:E({spin:r.value})},null,8,[`class`])],8,eE),z(`button`,{class:`icon-button`,disabled:!c.value||!!i.value,"aria-label":`Add a graph`,title:`Add a graph from JSON`,onClick:l[0]||=e=>o.value=!o.value},[B(A(Xc),{size:15})],8,tE)]),l[7]||=z(`p`,{class:`hint`},`Tasks run on the device, in dependency order — one fresh session each.`,-1),c.value?i.value?(I(),L(`p`,rE,D(i.value),1)):!t.value.length&&!o.value?(I(),L(`p`,iE,` No graphs yet. Press + and paste a graph JSON ({ name, cwd, tasks: [{ id, name, prompt, dependsOn }] }). `)):H(``,!0):(I(),L(`p`,nE,`Select a session to see its device.`)),o.value?(I(),L(`form`,{key:3,class:`add-form`,onSubmit:ks(g,[`prevent`])},[z(`label`,null,[l[4]||=V(`Graph JSON `,-1),j(z(`textarea`,{"onUpdate:modelValue":l[1]||=e=>s.value=e,rows:`8`,placeholder:`{ "name": "nightly", "cwd": "~/work/app", "tasks": [{ "id": "build", "name": "Build", "prompt": "run the build", "dependsOn": [] }, { "id": "report", "name": "Report", "prompt": "summarise", "dependsOn": ["build"] }] }`},null,512),[[ys,s.value]])]),z(`div`,aE,[z(`button`,{class:`primary small`,type:`submit`,disabled:a.value===`new`},D(a.value===`new`?`adding…`:`Add graph`),9,oE),z(`button`,{class:`small`,type:`button`,onClick:l[2]||=e=>o.value=!1},`Cancel`)])],32)):H(``,!0),(I(!0),L(F,null,P(t.value,e=>(I(),L(`div`,{key:e.id,class:`graph`},[z(`div`,sE,[z(`b`,null,D(e.name),1),z(`code`,{class:`cwd`,title:e.cwd},D(e.cwd.split(`/`).filter(Boolean).at(-1)||e.cwd),9,cE),z(`span`,{class:E([`tag`,d[e.lastRun?.status??`pending`]??``])},D(e.lastRun?e.lastRun.status:`never run`),3),l[5]||=z(`span`,{class:`spacer`},null,-1),z(`button`,{class:`icon-button`,"aria-label":`Run ${e.name}`,title:`Run now`,disabled:a.value===e.id,onClick:t=>m(e)},[B(A(Yc),{size:14})],8,lE),z(`button`,{class:`icon-button`,"aria-label":`Remove ${e.name}`,title:`Remove graph`,onClick:t=>h(e)},[B(A(ml),{size:14})],8,uE)]),z(`ul`,dE,[(I(!0),L(F,null,P(e.tasks,t=>(I(),L(`li`,{key:t.id,class:E(d[f(e,t.id)])},[l[6]||=z(`span`,{class:`dot`,"aria-hidden":`true`},null,-1),z(`span`,{class:`name`,title:t.prompt},D(t.name),9,fE),t.dependsOn.length?(I(),L(`code`,pE,`← `+D(t.dependsOn.join(`, `)),1)):H(``,!0),z(`span`,mE,D(f(e,t.id)),1),n.value[e.id]?.tasks[t.id]?.error?(I(),L(`em`,hE,D(n.value[e.id].tasks[t.id].error.slice(0,120)),1)):H(``,!0)],2))),128))])]))),128))]))}}),[[`__scopeId`,`data-v-4acbb881`]]),_E={class:`notify-panel`,"aria-label":`Notification sinks`},vE={class:`panel-heading`},yE=[`disabled`],bE=[`disabled`],xE=[`disabled`],SE={key:0,class:`hint`},CE={key:1,class:`message-error`},wE=[`placeholder`],TE={class:`row`},EE=[`disabled`],DE={key:3,class:`hint`},OE={key:4,class:`sink-list`},kE={class:`head`},AE={class:`tag`},jE={class:`next`},ME={class:`url`},NE={key:0,class:`hint`},PE={key:1,class:`message-error`},FE={class:`row`},IE=[`disabled`,`onClick`],LE=[`disabled`,`onClick`],RE={key:5,class:`results`,"aria-label":`Test results`},zE={class:`tag`},BE={key:0},VE=Hd(N({__name:`NotifyPanel`,setup(e){let t=k([]),n=k(``),r=k(``),i=k(!1),a=k([]),o=U(()=>q.value?.deviceId),s=()=>G(o.value??``),c=k(!1),l=k({kind:`webhook`,url:``,label:``,events:``});async function u(){if(!o.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await s().notifySinks()).sinks}catch(e){r.value=dw(e)?fw(o.value,`notifications`):K(e).slice(0,220)}finally{i.value=!1}}M(o,u,{immediate:!0});let d=e=>{if(!e)return`never`;let t=Math.round((Date.now()-e)/6e4);return t<1?`just now`:t<60?`${t}m ago`:`${Math.round(t/60)}h ago`};async function f(){let e=l.value;if(e.url.trim()){n.value=`new`;try{await s().createNotifySink({kind:e.kind,url:e.url.trim(),...e.label.trim()?{label:e.label.trim()}:{},...e.events.trim()?{events:e.events.split(`,`).map(e=>e.trim()).filter(Boolean)}:{}}),c.value=!1,l.value={kind:`webhook`,url:``,label:``,events:``},await u(),Y(`Sink added on the device.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}}async function p(e){n.value=e.id;try{await s().updateNotifySink(e.id,{enabled:!e.enabled}),await u()}catch(e){Y(K(e).slice(0,140))}finally{n.value=``}}function m(e){J.dialog={kind:`prompt`,title:`Remove this ${e.kind} sink?`,hint:`The device stops notifying this target. Nothing else changes.`,submit:`Remove sink`,danger:!0,run:async()=>{await s().removeNotifySink(e.id),await u()}}}async function h(){n.value=`test`,a.value=[];try{a.value=(await s().testNotifySinks()).results;let e=a.value.filter(e=>e.status===`failed`).length;Y(a.value.length?`Test: ${a.value.length-e} sent${e?`, ${e} failed`:``}.`:`No enabled sinks matched — nothing was sent.`)}catch(e){Y(K(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(I(),L(`section`,_E,[z(`header`,vE,[z(`span`,null,[B(A(Xs),{size:16}),s[6]||=V(`NOTIFY`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[B(A($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,yE),z(`button`,{class:`icon-button`,disabled:!o.value||!t.value.length||n.value===`test`,"aria-label":`Send a test notification`,title:`Send a test event through every enabled sink`,onClick:h},[B(A(rl),{size:15})],8,bE),z(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[B(A(Xc),{size:15})],8,xE)]),s[14]||=z(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(I(),L(`p`,CE,D(r.value),1)):H(``,!0):(I(),L(`p`,SE,`Select a session to see its device.`)),c.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(f,[`prevent`])},[z(`label`,null,[s[8]||=V(`Kind `,-1),j(z(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[z(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),z(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Ss,l.value.kind]])]),z(`label`,null,[s[9]||=V(`URL `,-1),j(z(`input`,{"onUpdate:modelValue":s[2]||=e=>l.value.url=e,placeholder:l.value.kind===`ntfy`?`https://ntfy.sh/my-topic`:`https://example.com/hook`,required:``},null,8,wE),[[ys,l.value.url]])]),z(`label`,null,[s[10]||=V(`Label`,-1),j(z(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[ys,l.value.label]])]),z(`label`,null,[s[11]||=V(`Events `,-1),j(z(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[ys,l.value.events]])]),z(`div`,TE,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`adding…`:`Add sink`),9,EE),z(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=z(`p`,{class:`hint`},[V(`LAN targets (192.168.x, localhost) need `),z(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),V(` on the device.`)],-1)],32)):H(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(I(),L(`p`,DE,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):H(``,!0),t.value.length?(I(),L(`ul`,OE,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`sink`,{off:!e.enabled}])},[z(`div`,kE,[z(`span`,AE,D(e.kind),1),z(`b`,null,D(e.label||e.url),1),z(`em`,jE,D(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),z(`code`,ME,D(e.url),1),e.events?.length?(I(),L(`p`,NE,`events: `+D(e.events.join(`, `)),1)):H(``,!0),e.lastError?(I(),L(`p`,PE,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,FE,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[B(A(Zc),{size:12}),V(D(e.enabled?`disable`:`enable`),1)],8,IE),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[B(A(ml),{size:12}),s[13]||=V(`remove`,-1)],8,LE)])],2))),128))])):H(``,!0),a.value.length?(I(),L(`ul`,RE,[(I(!0),L(F,null,P(a.value,e=>(I(),L(`li`,{key:e.id,class:E(e.status)},[z(`span`,zE,D(e.status),1),V(` `+D(e.kind)+` `+D(e.id.slice(0,8))+` `,1),e.detail?(I(),L(`em`,BE,D(e.detail),1)):H(``,!0)],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-6fa0ab18`]]),HE={class:`env-panel`,"aria-label":`Device environment`},UE={class:`panel-heading`},WE=[`disabled`],GE=[`disabled`],KE={key:0,class:`hint`},qE={key:1,class:`message-error`},JE={key:2,class:`message-restart`},YE={class:`row`},XE=[`disabled`],ZE={key:4,class:`hint`},QE={key:5,class:`var-list`},$E={class:`head`},eD={class:`key`},tD={class:`tag`},nD={key:0,class:`tag`,title:`Has its own setting; edit that instead`},rD=[`aria-label`,`title`,`onClick`],iD=[`aria-label`,`onClick`],aD=[`title`],oD={key:6,class:`hint path`},sD={class:`panel-heading keys-heading`},cD=[`disabled`],lD=[`disabled`],uD={key:7,class:`message-error`},dD={class:`row`},fD=[`disabled`],pD={key:9,class:`hint`},mD={key:10,class:`var-list`},hD={class:`head`},gD={class:`key`},_D={class:`tag`},vD={key:0,class:`tag`,title:`Set by pi /login — read-only here`},yD=[`aria-label`,`onClick`],bD={class:`value`,title:`write-only — masked tail`},xD=Hd(N({__name:`EnvPanel`,setup(e){let t=k(null),n=k(!1),r=k(``),i=k(``),a=U(()=>q.value?.deviceId),o=()=>G(a.value??``),s=k(!1),c=k({key:``,value:``});async function l(){if(!a.value)return void(t.value=null);n.value=!0,r.value=``;try{t.value=await o().envView()}catch(e){r.value=dw(e)?fw(a.value,`editing env vars`):K(e).slice(0,220)}finally{n.value=!1}m()}M(a,l,{immediate:!0});let u=k(null),d=k(``),f=k(!1),p=k({providerId:``,key:``});async function m(){if(!a.value)return void(u.value=null);try{u.value=await o().piAuth(),d.value=``}catch(e){K(e),d.value=dw(e)?fw(a.value,`managing pi keys`):K(e).slice(0,220)}}async function h(){let e=p.value.providerId.trim();if(e&&p.value.key){i.value=`pi-key`;try{let t=await o().setPiApiKey(e,p.value.key);p.value={providerId:``,key:``},f.value=!1,await m(),Y(`${e} saved (now ${t.masked}) — restart the device to apply it.`)}catch(e){Y(K(e).slice(0,160))}finally{i.value=``}}}function g(e){J.dialog={kind:`prompt`,title:`Remove the ${e} key?`,hint:`The entry is deleted from pi's auth.json. pi's own logins are never touched. Restart the device to apply.`,submit:`Remove`,danger:!0,run:async()=>{await o().removePiApiKey(e),await m(),Y(`${e} removed — restart the device to apply it.`)}}}let _=e=>e.source===`file`&&!e.managed;async function v(){let e=c.value.key.trim().toUpperCase();if(e&&c.value.value){i.value=`new`;try{await o().setEnvVar(e,c.value.value),s.value=!1,c.value={key:``,value:``},await l(),Y(`${e} saved — restart the device to apply it.`)}catch(e){Y(K(e).slice(0,160))}finally{i.value=``}}}function y(e){J.dialog={kind:`prompt`,title:`Set ${e.key}`,label:`Value`,hint:e.secret?`The current value is secret and stays masked. Type a new value to replace it.`:`Single line. Applies after the next device restart.`,value:e.secret?``:e.masked,placeholder:e.secret?e.masked:``,submit:`Save value`,run:async t=>{if(!t)throw Error(`A value is required`);await o().setEnvVar(e.key,t),await l(),Y(`${e.key} saved — restart the device to apply it.`)}}}function b(e){J.dialog={kind:`prompt`,title:`Remove ${e.key} from the env file?`,hint:`The line is deleted from the file. Restart the device to apply it.`,submit:`Remove`,danger:!0,run:async()=>{await o().removeEnvVar(e.key),await l(),Y(`${e.key} removed — restart the device to apply it.`)}}}return(e,o)=>(I(),L(`section`,HE,[z(`header`,UE,[z(`span`,null,[B(A(gc),{size:16}),o[8]||=V(`ENV`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,WE),z(`button`,{class:`icon-button`,disabled:!a.value||!!r.value,"aria-label":`Add an env var`,title:`Add an env var to the device's env file`,onClick:o[0]||=e=>s.value=!s.value},[B(A(Xc),{size:15})],8,GE)]),o[19]||=z(`p`,{class:`hint`},` The device's env file — loaded once at boot. Keys here reach the daemon and its sessions. `,-1),a.value?r.value?(I(),L(`p`,qE,D(r.value),1)):t.value?.restartRequired?(I(),L(`p`,JE,[...o[9]||=[V(` Changed since boot — restart the device (`,-1),z(`code`,null,`dpi device stop && dpi device start`,-1),V(`) to apply. `,-1)]])):H(``,!0):(I(),L(`p`,KE,`Select a session to see its device.`)),s.value?(I(),L(`form`,{key:3,class:`add-form`,onSubmit:ks(v,[`prevent`])},[z(`label`,null,[o[10]||=V(`Key (UPPER_SNAKE_CASE)`,-1),j(z(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[ys,c.value.key]])]),z(`label`,null,[o[11]||=V(`Value`,-1),j(z(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[ys,c.value.value]])]),z(`div`,YE,[z(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},D(i.value===`new`?`saving…`:`Save to env file`),9,XE),z(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[12]||=z(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):H(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(I(),L(`p`,ZE,` No vars in the env file yet. `)):H(``,!0),t.value?.vars.length?(I(),L(`ul`,QE,[(I(!0),L(F,null,P(t.value.vars,e=>(I(),L(`li`,{key:e.key,class:E([`var`,{ro:!_(e)}])},[z(`div`,$E,[z(`code`,eD,D(e.key),1),z(`span`,tD,D(e.source===`process`?`process`:`file`),1),e.managed?(I(),L(`span`,nD,`managed`)):H(``,!0),o[13]||=z(`span`,{class:`spacer`},null,-1),_(e)?(I(),L(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>y(e)},[B(A(qc),{size:13})],8,rD)):H(``,!0),_(e)?(I(),L(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>b(e)},[B(A(ml),{size:13})],8,iD)):H(``,!0)]),z(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},D(e.masked),9,aD)],2))),128))])):H(``,!0),t.value?(I(),L(`p`,oD,D(t.value.envFile),1)):H(``,!0),z(`header`,sD,[z(`span`,null,[B(A(kc),{size:16}),o[14]||=V(`PI KEYS`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh pi keys`,title:`Refresh`,onClick:m},[B(A($c),{size:15})],8,cD),z(`button`,{class:`icon-button`,disabled:!a.value||!!d.value,"aria-label":`Add a pi provider key`,title:`Add a provider key to pi's auth.json`,onClick:o[4]||=e=>f.value=!f.value},[B(A(Xc),{size:15})],8,lD)]),o[20]||=z(`p`,{class:`hint`},[V(` Provider keys in pi's own `),z(`code`,null,`auth.json`),V(` — write-only: values are never shown, pi's interactive logins (oauth) are never touched. `)],-1),d.value?(I(),L(`p`,uD,D(d.value),1)):H(``,!0),f.value?(I(),L(`form`,{key:8,class:`add-form`,onSubmit:ks(h,[`prevent`])},[z(`label`,null,[o[15]||=V(`Provider id`,-1),j(z(`input`,{"onUpdate:modelValue":o[5]||=e=>p.value.providerId=e,placeholder:`zai`,required:``},null,512),[[ys,p.value.providerId]])]),z(`label`,null,[o[16]||=V(`Key`,-1),j(z(`input`,{"onUpdate:modelValue":o[6]||=e=>p.value.key=e,type:`password`,autocomplete:`off`,placeholder:`paste the api key`,required:``},null,512),[[ys,p.value.key]])]),z(`div`,dD,[z(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`pi-key`},D(i.value===`pi-key`?`saving…`:`Save to auth.json`),9,fD),z(`button`,{class:`small`,type:`button`,onClick:o[7]||=e=>f.value=!1},`Cancel`)]),o[17]||=z(`p`,{class:`hint`},`Applies after the next device restart. Existing keys for other providers stay as they are.`,-1)],32)):H(``,!0),!f.value&&u.value&&!u.value.entries.length&&!d.value?(I(),L(`p`,pD,` No provider keys found. `)):H(``,!0),u.value?.entries.length?(I(),L(`ul`,mD,[(I(!0),L(F,null,P(u.value.entries,e=>(I(),L(`li`,{key:e.providerId,class:`var`},[z(`div`,hD,[z(`code`,gD,D(e.providerId),1),z(`span`,_D,D(e.source),1),e.type===`api_key`?H(``,!0):(I(),L(`span`,vD,D(e.type),1)),o[18]||=z(`span`,{class:`spacer`},null,-1),e.type===`api_key`?(I(),L(`button`,{key:1,class:`icon-button`,"aria-label":`Remove ${e.providerId} key`,title:`Remove from auth.json`,onClick:t=>g(e.providerId)},[B(A(ml),{size:13})],8,yD)):H(``,!0)]),z(`code`,bD,D(e.masked),1)]))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-d92de86a`]]),SD={class:`extensions-panel`},CD={class:`panel-heading`},wD={key:0,class:`task-empty`},TD=[`data-extension`],ED={class:`ext-head`},DD=[`aria-checked`,`aria-label`,`disabled`,`onClick`],OD=[`checked`,`disabled`,`onChange`],kD=N({__name:`ExtensionsPanel`,setup(e){let t=rn(),n=k(!1);async function r(){let e=zu.value;if(!e||!Nu.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}M([zu,Nu,()=>JSON.stringify(Yu.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=zu.value;if(r&&!n.value){n.value=!0;try{let n=await dd(()=>r.setExtension(e));n&&(t.value=n),od()}finally{n.value=!1}}}return(e,r)=>(I(),L(`div`,SD,[z(`div`,CD,[r[0]||=z(`h2`,null,`Extensions`,-1),B(A(Qc),{size:18})]),r[3]||=z(`p`,{class:`hint`},` Custom harness capabilities for this agent. Turn one on and the next request uses it. The choice is stored with the agent, so it survives restarts. `,-1),t.value?H(``,!0):(I(),L(`p`,wD,`Loading extensions…`)),(I(!0),L(F,null,P(t.value?.extensions??[],e=>(I(),L(`article`,{key:e.name,class:E([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[z(`div`,ED,[z(`div`,null,[z(`strong`,null,D(e.title),1),z(`code`,null,D(e.name),1)]),z(`button`,{class:E([`switch`,{on:e.enabled}]),role:`switch`,"aria-checked":e.enabled,"aria-label":e.title,disabled:n.value,onClick:t=>i({name:e.name,enabled:!e.enabled})},[...r[1]||=[z(`span`,null,null,-1)]],10,DD)]),z(`p`,null,D(e.description),1),e.prompts?(I(),L(`ul`,{key:0,class:E([`ext-prompts`,{off:!e.enabled}])},[(I(!0),L(F,null,P(e.prompts,e=>(I(),L(`li`,{key:e.id},[z(`label`,null,[z(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,OD),z(`code`,null,D(e.id),1)]),z(`span`,null,D(e.description),1),z(`details`,null,[r[2]||=z(`summary`,null,`View prompt`,-1),z(`pre`,null,D(e.text),1)])]))),128))],2)):H(``,!0)],10,TD))),128))]))}}),AD={class:`context-section`,"aria-labelledby":`context-title`},jD={class:`section-label`},MD={key:0,class:`hint`},ND={key:1,class:`hint`},PD={class:`context-numbers`},FD={class:`context-pct`},ID={key:0,class:`context-compacting`},LD=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],RD={class:`context-marker-label`},zD=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],BD={class:`context-marker-label`},VD={class:`hint context-hint`},HD={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},UD={class:`context-toggle`},WD=[`checked`],GD=512,KD=4096,qD=1024,JD=N({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=U(()=>rd.value?.contextWindow??0),r=U(()=>{let e=nd.value;return e&&!rd.value?`${e.provider?`${e.provider} / `:``}${e.modelId}`:``}),i=U(()=>{let e=Yu.value.entries;for(let t=e.length-1;t>=0;t--){if(e[t].kind!==`pi.assistant`)continue;let n=e[t].model?.find(e=>e.role===`assistant`)?.usage;if(n)return n.totalTokens||n.input+n.output+n.cacheRead+n.cacheWrite}return 0}),a=U(()=>Yu.value.compactions.length>0),o=k(),s=U(()=>o.value??Lu.value?.compaction??_v(n.value));M(()=>JSON.stringify(Lu.value?.compaction),e=>{o.value&&e===JSON.stringify(o.value)&&(o.value=void 0)});let c=k(),l=U(()=>J.dialog?.kind===`compaction`),u=()=>void(J.dialog=void 0);Gr(()=>l.value&&u());let d=U(()=>c.value??vv(n.value,s.value)),f=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,p=U(()=>Math.round(100*i.value/(n.value||1))),m=e=>{let t=e/(n.value||1);return t<.35?`start`:t>.65?`end`:`center`},h=(e,t)=>Math.min(n.value-qD,Math.max((t??KD)+qD,e)),g=(e,t)=>Math.min(t-qD,Math.max(KD,e));function _(e,t){let n=d.value,r=Math.round(t/GD)*GD;c.value=e===`wait`?{auto:n.auto,wait:h(r,n.auto)}:{auto:g(r,n.wait),wait:n.wait}}async function v(e){let t=Bu.value;if(!t)return;let n=await dd(()=>t.setCompaction(e));n&&(o.value=n),c.value=void 0}function y(){let e=c.value;e&&v({reserveTokens:n.value-e.wait,...e.auto===void 0?{}:{backgroundTokens:e.wait-e.auto}})}let b=k(),x;function S(e,t){x=e,t.currentTarget.setPointerCapture(t.pointerId)}function C(e){if(!x||!b.value)return;let t=b.value.getBoundingClientRect();_(x,(e.clientX-t.left)/t.width*n.value)}function ee(){x&&(x=void 0,y())}function w(e,t){let n=(t.shiftKey?8192:1024)*(t.key===`ArrowRight`||t.key===`ArrowUp`?1:t.key===`ArrowLeft`||t.key===`ArrowDown`?-1:0);if(!n)return;t.preventDefault();let r=d.value;_(e,(e===`auto`?r.auto??KD:r.wait)+n)}return(e,o)=>(I(),L(F,null,[z(`section`,AD,[z(`div`,jD,[o[7]||=z(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(I(),L(`button`,{key:0,class:`context-details-toggle`,onClick:o[0]||=e=>A(J).dialog={kind:`compaction`}},[B(A(Oc),{size:16}),o[6]||=V(`Details `,-1)])):H(``,!0)]),r.value?(I(),L(`div`,MD,D(r.value)+` — not in this device's catalog, so its context window is unknown here. `,1)):n.value?(I(),L(F,{key:2},[z(`div`,PD,[z(`strong`,null,D(t(i.value)),1),z(`span`,null,`of `+D(t(n.value))+` tokens`,1),z(`span`,FD,D(p.value)+`%`,1),a.value?(I(),L(`span`,ID,[...o[8]||=[z(`i`,null,null,-1),V(`Compacting`,-1)]])):H(``,!0)]),z(`div`,{ref_key:`bar`,ref:b,class:E([`context-bar`,{off:!s.value.enabled}]),onPointermove:C,onPointerup:ee,onPointercancel:ee},[z(`div`,{class:E([`context-fill`,{hot:d.value.auto!==void 0&&i.value>=d.value.auto}]),style:ge({width:f(i.value)})},null,6),z(`div`,{class:`context-reserve`,style:ge({left:f(d.value.wait)}),title:`Reserved for the answer`},null,4),d.value.auto===void 0?H(``,!0):(I(),L(`button`,{key:0,class:E([`context-marker auto`,`label-${m(d.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":KD,"aria-valuemax":d.value.wait-qD,"aria-valuenow":d.value.auto,"aria-valuetext":`${t(d.value.auto)} tokens`,style:ge({left:f(d.value.auto)}),onPointerdown:o[1]||=e=>S(`auto`,e),onKeydown:o[2]||=e=>w(`auto`,e),onKeyup:y,onBlur:y},[z(`span`,RD,`Auto-compact at `+D(t(d.value.auto)),1)],46,LD)),z(`button`,{class:E([`context-marker wait`,`label-${m(d.value.wait)}`]),role:`slider`,"aria-label":`The next request waits for a summary at`,"aria-valuemin":(d.value.auto??KD)+qD,"aria-valuemax":n.value-qD,"aria-valuenow":d.value.wait,"aria-valuetext":`${t(d.value.wait)} tokens, ${t(n.value-d.value.wait)} reserved`,style:ge({left:f(d.value.wait)}),onPointerdown:o[3]||=e=>S(`wait`,e),onKeydown:o[4]||=e=>w(`wait`,e),onKeyup:y,onBlur:y},[z(`span`,BD,`Reserve at `+D(t(d.value.wait)),1)],46,zD)],34),z(`p`,VD,[s.value.enabled?(I(),L(F,{key:0},[o[9]||=V(`Compacts in the background at `,-1),z(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[10]||=V(` and waits at `,-1),z(`strong`,null,D(t(d.value.wait)),1),o[11]||=V(`.`,-1)],64)):(I(),L(F,{key:1},[V(`Automatic compaction is off.`)],64))])],64)):(I(),L(`div`,ND,`Pick a model to see its context window.`))]),(I(),R(lr,{to:`body`},[l.value?(I(),L(`div`,{key:0,class:`modal-backdrop`,onClick:ks(u,[`self`])},[z(`section`,HD,[z(`header`,null,[o[12]||=z(`h2`,{id:`compaction-title`},`Context compaction`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:u},[B(A(xl),{size:18})])]),z(`p`,null,[o[13]||=V(` A summary starts in the background at `,-1),z(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[14]||=V(`. Above `,-1),z(`strong`,null,D(t(d.value.wait)),1),V(` the next request waits for it, keeping `+D(t(n.value-d.value.wait))+` free for the answer. Drag a marker on the bar to change either point. `,1)]),o[16]||=z(`p`,null,[V(`Older entries stay stored, and `),z(`code`,null,`search_history`),V(` still finds them.`)],-1),z(`label`,UD,[z(`input`,{type:`checkbox`,checked:s.value.enabled,onChange:o[5]||=e=>v({enabled:e.target.checked})},null,40,WD),o[15]||=V(` Automatic compaction `,-1)]),o[17]||=z(`p`,{class:`hint`},[V(` Applies to every agent in this session. `),z(`code`,null,`/compact`),V(` works either way. `)],-1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:u},`Close`)])])])):H(``,!0)]))],64))}}),YD=/^[A-Za-z_$][\w$]*$/,XD=e=>` `.repeat(e);function ZD(e,t){let n=[],r=(e,t=`text`)=>n.push({text:e,kind:t});return r(`function`,`keyword`),r(` `),r(e,`function`),r(`(`,`punct`),r(`args`),r(`: `,`punct`),QD(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function QD(e,t,n){if(!e||typeof e!=`object`)return n(`unknown`,`type`);if(`const`in e)return tO(e.const,n);if(e.enum)return eO(e.enum.map(e=>({const:e})),t,n);if(e.anyOf??e.oneOf)return eO(e.anyOf??e.oneOf,t,n);if(Array.isArray(e.type))return eO(e.type.map(t=>({...e,type:t})),t,n);switch(e.type){case`string`:case`boolean`:case`null`:return n(e.type,`type`);case`number`:case`integer`:return n(`number`,`type`);case`array`:{let r=!!(e.items?.anyOf??e.items?.oneOf??e.items?.enum);return r&&n(`(`,`punct`),QD(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return $D(e,t,n);default:return n(`unknown`,`type`)}}function $D(e,t,n){let r=Object.entries(e.properties??{});if(!r.length)return e.additionalProperties&&typeof e.additionalProperties==`object`?(n(`Record`,`type`),n(`<`,`punct`),n(`string`,`type`),n(`, `,`punct`),QD(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
80
+ `);for(let[e,a]of r){let r=nO(a);r&&n(`${XD(t+1)}${r}\n`,`comment`),n(XD(t+1)),n(YD.test(e)?e:JSON.stringify(e),`property`),n(i.has(e)?`: `:`?: `,`punct`),QD(a,t+1,n),n(`;`,`punct`),n(`
81
+ `)}n(XD(t)),n(`}`,`punct`)}function eO(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),QD(e,t,n)})}function tO(e,t){if(typeof e==`string`)return t(JSON.stringify(e),`string`);if(typeof e==`number`)return t(String(e),`number`);t(String(e),`type`)}function nO(e){let t=[e.description,e.minimum===void 0?``:`@minimum ${e.minimum}`,e.maximum===void 0?``:`@maximum ${e.maximum}`,e.default===void 0?``:`@default ${JSON.stringify(e.default)}`].filter(Boolean);return t.length?`/** ${t.join(` `)} */`:``}function rO(e){let t=document.createElement(`a`);t.href=URL.createObjectURL(new Blob([e.bytes.slice()],{type:e.mime||`application/zip`})),t.download=e.filename,t.click(),URL.revokeObjectURL(t.href)}function iO(e,t={}){let n=t.fetchBundle??((e,t)=>G(e).exportSession(t)),r=t.download??rO,i=t.notify??(()=>{}),a=k(!1),o=k(``);async function s(){let{device:t,summary:s}=e.value;if(t&&s&&!a.value){a.value=!0,o.value=``;try{let e=await n(t.id,s.id);r(e),i(`Bundle downloaded (${Math.max(1,Math.round(e.bytes.length/1024))} KiB).`)}catch(e){o.value=`bundle export failed: ${K(e).slice(0,300)}`,i(o.value.slice(0,120))}finally{a.value=!1}}}return M(()=>e.value.summary?.id,()=>o.value=``),{exporting:a,error:o,run:s}}function aO(e){try{let t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!=`object`)throw Error(`App State must be a JSON object.`);return ky({},{operation:`update`,path:``,value:t}),``}catch(e){return K(e)}}function oO(e,t){let n=k(``),r=k(``),i=k(0),a=k(),o=k(!1),s=k(``),c=U(()=>n.value!==r.value),l=U(()=>c.value&&a.value!==t.value),u=U(()=>c.value&&(l.value||e.value?.revision!==i.value));function d(){n.value=JSON.stringify(e.value?.value??{},null,2),r.value=n.value,i.value=e.value?.revision??0,a.value=t.value,s.value=``}function f(e,t){n.value=JSON.stringify(e,null,2),r.value=n.value,i.value=t,s.value=``}M(e,()=>!c.value&&d(),{immediate:!0}),M(t,()=>d());let p;return M(n,()=>{clearTimeout(p),p=setTimeout(()=>s.value=c.value?aO(n.value):``,250)}),{draft:n,dirty:c,conflict:u,deviceChanged:l,saving:o,problem:s,revision:i,reset:d,commit:f}}var sO={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},cO=[`title`],lO=[`aria-label`,`title`,`onClick`],uO={key:0,class:`count`},dO={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},fO=[`id`,`aria-selected`,`title`,`onClick`],pO={class:`tab-label`},mO={key:0,class:`count`},hO=[`title`],gO=[`aria-labelledby`],_O={class:`session-heading`},vO=[`disabled`],yO=[`disabled`],bO=[`title`],xO={class:`cwd-trail`,dir:`rtl`},SO={dir:`ltr`},CO={class:`session-status`},wO={key:0,class:`background-pill`},TO=[`title`],EO={key:0,class:`message-error`,role:`alert`},DO=[`disabled`],OO={class:`model-section`},kO=[`src`],AO={key:0,class:`hint model-provenance`},jO={class:`thinking-row`},MO=[`value`],NO={class:`stats-section`,"aria-labelledby":`stats-title`},PO={class:`metrics`},FO=[`title`],IO={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},LO={scope:`row`},RO={class:`usage-total`},zO={class:`panel-heading`},BO={class:`hint app-state-description`},VO=[`disabled`],HO={class:`state-json-actions`},UO={key:0,class:`hint`},WO=[`disabled`],GO=[`disabled`],KO={key:0,class:`message-error`,role:`alert`},qO={key:1,class:`message-error`,role:`alert`},JO={class:`panel-heading`},YO={class:`tag`},XO={class:`hook-card`},ZO=[`aria-checked`],QO={key:0,class:`tag tool-disabled`},$O={class:`tag`},ek=[`aria-label`],tk=Hd(N({__name:`Inspector`,setup(e){let t=U(()=>new Map(id.value?.tools.map(e=>[e.name,ZD(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:yc},{id:`git`,label:`Git`,icon:xc},{id:`host`,label:`Host`,icon:Vs},{id:`usage`,label:`Usage`,icon:Jc},{id:`auto`,label:`Auto`,icon:ec},{id:`archive`,label:`Archive`,icon:Us},{id:`dag`,label:`DAG`,icon:gl},{id:`notify`,label:`Notify`,icon:Xs},{id:`env`,label:`Env`,icon:gc},{id:`state`,label:`State`,icon:Qs},{id:`tasks`,label:`Tasks`,icon:Vs},{id:`tools`,label:`Tools`,icon:bl},{id:`extensions`,label:`Extend`,icon:Qc}],r=U(()=>[{label:`Input`,tokens:ed.value.input,cost:ed.value.inputCost},{label:`Output`,tokens:ed.value.output,cost:ed.value.outputCost},{label:`Cache read`,tokens:ed.value.cacheRead,cost:ed.value.cacheReadCost},{label:`Cache write`,tokens:ed.value.cacheWrite,cost:ed.value.cacheWriteCost}]),i=U(()=>Qu.value.filter(e=>e.background).length);function a(e,t){dd(async()=>{await zu.value.configure(e),await od(),t&&Y(t)})}async function o(){let e=Mu.value,t=Lu.value;if(e&&t)try{let n=await G(e.id).agent(t.id,q.value?.agentId??1).transcript(`markdown`),r=new Blob([typeof n==`string`?n:JSON.stringify(n)],{type:`text/markdown`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=`${t.name.replace(/[^\w.-]+/g,`_`)||`session`}-${t.id.slice(0,8)}.md`,i.click(),URL.revokeObjectURL(i.href),Y(`Transcript downloaded.`)}catch(e){Y(`transcript download failed: ${K(e).slice(0,120)}`)}}let{exporting:s,error:c,run:l}=iO(U(()=>({device:Mu.value,summary:Lu.value}))),u=k(!1);function d(){let e=Mu.value,t=Lu.value;e&&t&&!u.value&&(J.dialog={kind:`prompt`,title:`Share this transcript publicly?`,hint:`Anyone with the link can read this session's transcripts. The link expires in 7 days and can be removed on the hub.`,submit:`Create share link`,run:async()=>{u.value=!0;try{let n=G(e.id),r=t.agents.length?t.agents:[{id:1,name:`main`}],i=[];for(let e of r){let r=await n.agent(t.id,e.id).transcript(`markdown`),a=typeof r==`string`?r:r.text??JSON.stringify(r,null,2);i.push({name:e.name||`agent ${e.id}`,markdown:a})}let a=await fu.createShare({title:`${t.name} · ${e.name}`,agents:i}),o=`${location.origin}${a.url}`;await navigator.clipboard?.writeText(o).catch(()=>{}),Y(`Share link copied — expires ${a.expiresAt.slice(0,10)}.`)}catch(e){Y(`share failed: ${K(e).slice(0,140)}`)}finally{u.value=!1}}})}function f(){let e=Bu.value;e&&(J.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:Lu.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let p=k({});M(Mu,async e=>{if(p.value={},e)try{let{projects:t}=await G(e.id).projects(!0);p.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0});let m=U(()=>{let e=nd.value;if(!e)return!1;let t=Lu.value?.cwd,n=Object.keys(p.value).filter(e=>t===e||(t??``).startsWith(`${e}/`)).sort((e,t)=>t.length-e.length),r=n.length?p.value[n[0]]:void 0,i=r?`${r.provider}/${r.modelId}`:Mu.value?.info?.defaultModel??``;return!!i&&i===`${e.provider}/${e.modelId}`}),h=U(()=>nd.value&&`model: ${nd.value.modelId} (${nd.value.provider})${m.value?` (default)`:``}`),g=Iu.sharedState,{draft:_,dirty:v,conflict:y,deviceChanged:b,problem:x,revision:S,reset:C,commit:ee}=oO(g,ju),w=k(!1),T=k(``);async function te(e){if(!w.value&&zu.value){w.value=!0,T.value=``;try{await zu.value.demo(`state`,e)}catch(e){T.value=K(e)}finally{w.value=!1}}}async function ne(){if(!(w.value||y.value||!zu.value)){T.value=``,w.value=!0;try{let e=JSON.parse(_.value);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`App State must be a JSON object.`);let t=await zu.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:S.value});ee(t.value,t.revision),Y(`Shared App State saved.`)}catch(e){T.value=K(e)}finally{w.value=!1}}}let re=U(()=>id.value?.config.readOnly===!0),ie=U(()=>id.value?.tools.filter(e=>e.offered).length??0);return(e,p)=>(I(),L(`aside`,{class:E([`inspector`,{collapsed:!A(xd),overlay:A(J).inspectorOverlay}])},[A(xd)?(I(),L(F,{key:1},[z(`div`,dO,[(I(),L(F,null,P(n,e=>z(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":A(J).tab===e.id,title:e.label,class:E({active:A(J).tab===e.id}),onClick:t=>A(J).tab=e.id},[(I(),R($r(e.icon),{size:18})),z(`span`,pO,D(e.label),1),e.id===`tasks`&&A(Qu).length?(I(),L(`span`,mO,D(A(Qu).length),1)):H(``,!0)],10,fO)),64)),z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${A(Dd).inspector})`,onClick:p[1]||=e=>A(Cd)()},[B(A(Uc),{size:18})],8,hO)]),z(`div`,{id:`inspector-panel`,class:E([`inspector-body`,{"session-panel":A(J).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${A(J).tab}`},[A(J).tab===`session`?(I(),L(F,{key:0},[z(`section`,_O,[z(`h1`,null,[z(`span`,null,D(A(Lu)?.name??`Loading session`),1),z(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:f},[B(A(qc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:o},[B(A(pc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:A(s),onClick:p[2]||=(...e)=>A(l)&&A(l)(...e)},[B(A(Hc),{size:18})],8,vO),z(`button`,{class:`icon-button`,title:`Share a public read-only link to this transcript`,"aria-label":`Share transcript`,disabled:u.value,onClick:d},[B(A(al),{size:18})],8,yO)]),z(`button`,{class:`path cwd-button`,title:A(Lu)?.cwd,"aria-label":`Show full working directory`,onClick:p[3]||=e=>A(J).dialog={kind:`path`,path:A(Lu)?.cwd??``}},[B(A(yc),{size:18}),z(`span`,xO,[z(`bdi`,SO,D(A(Lu)?.cwd),1)])],8,bO),z(`div`,CO,[z(`span`,{class:E([`status-pill`,{working:A($u)}])},[p[10]||=z(`i`,null,null,-1),V(D(A($u)?`Working`:`Idle`),1)],2),i.value?(I(),L(`span`,wO,D(i.value)+` background`,1)):H(``,!0),z(`span`,{class:`saved`,title:A(Mu)?.id},[B(A(il),{size:18}),V(D(A(Mu)?.name??A(Mu)?.id),1)],8,TO),A(Mu)?(I(),R(eb,{key:1,device:A(Mu)},null,8,[`device`])):H(``,!0)]),A(c)?(I(),L(`p`,EO,[V(D(A(c))+` `,1),z(`button`,{class:`small`,disabled:A(s),onClick:p[4]||=(...e)=>A(l)&&A(l)(...e)},` retry `,8,DO)])):H(``,!0)]),A(Mu)?(I(),R(_b,{key:0,device:A(Mu)},null,8,[`device`])):H(``,!0),z(`section`,OO,[p[18]||=z(`div`,{class:`section-label`},[z(`span`,null,`AGENT`)],-1),z(`button`,{class:`model-button`,onClick:p[5]||=e=>A(J).dialog={kind:`models`}},[z(`img`,{src:A(hd)(A(Yu).agent.model?.modelId),alt:``},null,8,kO),z(`div`,null,[z(`strong`,null,D(A(td)?.name??A(Yu).agent.model?.modelId??`Loading…`),1),z(`small`,null,D(A(td)?.tier??``)+` / `+D(A(Yu).agent.model?.provider??``),1)]),B(A(nc),{size:18})]),h.value?(I(),L(`p`,AO,D(h.value),1)):H(``,!0),z(`div`,jO,[p[11]||=z(`span`,null,`Thinking`,-1),z(`select`,{"aria-label":`Thinking level`,value:A(Yu).agent.thinkingLevel??`medium`,onChange:p[6]||=e=>a({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(I(!0),L(F,null,P(A(mv),e=>(I(),L(`option`,{key:e},D(e),1))),128))],40,MO)]),B(JD),z(`section`,NO,[p[17]||=z(`div`,{class:`section-label`},[z(`span`,{id:`stats-title`},`STATS`)],-1),z(`div`,PO,[z(`div`,{title:`${A(ed).tokens.toLocaleString(`en-US`)} total tokens`},[z(`span`,null,D(A(pd)(A(ed).tokens)),1),p[12]||=z(`small`,null,`total tokens`,-1)],8,FO),z(`div`,null,[z(`span`,null,`$`+D(A(ed).cost.toFixed(4)),1),p[13]||=z(`small`,null,`agent cost`,-1)]),z(`div`,null,[z(`span`,null,D(A(id)?.tools.length??0),1),p[14]||=z(`small`,null,`tools`,-1)])]),z(`table`,IO,[p[16]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Type`),z(`th`,{scope:`col`},`Tokens`),z(`th`,{scope:`col`},`Cost (USD)`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(r.value,e=>(I(),L(`tr`,{key:e.label},[z(`th`,LO,D(e.label),1),z(`td`,null,D(e.tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(e.cost.toFixed(4)),1)]))),128)),z(`tr`,RO,[p[15]||=z(`th`,{scope:`row`},`Total`,-1),z(`td`,null,D(A(ed).tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(A(ed).cost.toFixed(4)),1)])])])])])],64)):H(``,!0),A(J).tab===`state`?(I(),L(F,{key:1},[z(`div`,zO,[p[19]||=z(`h2`,null,`App State`,-1),B(A(Qs),{size:18})]),z(`p`,BO,` One shared JSON object for every agent, session and fork on `+D(A(Mu)?.name??A(Mu)?.id)+`. You and your agents can read, create, update or delete values and fields. Changes appear live and persist across closed browsers, interrupted agents and backend restarts. `,1),j(z(`textarea`,{"onUpdate:modelValue":p[7]||=e=>nn(_)?_.value=e:null,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:w.value||!A(g),rows:`12`},null,8,VO),[[ys,A(_)]]),p[20]||=z(`p`,{class:`hint state-limits`},` One JSON object, at most 24 levels of nesting and 100,000 characters, checked as you type. `,-1),z(`div`,HO,[A(y)?(I(),L(`span`,UO,D(A(b)?`Device changed since this draft loaded. Load the latest JSON before saving.`:`State changed elsewhere. Load the latest JSON before saving.`),1)):H(``,!0),A(v)?(I(),L(`button`,{key:1,class:`secondary`,disabled:w.value,onClick:p[8]||=(...e)=>A(C)&&A(C)(...e)},D(A(y)?`Load latest`:`Reset`),9,WO)):H(``,!0),z(`button`,{class:`primary small`,disabled:!A(v)||w.value||A(y)||!!A(x),onClick:ne},D(w.value?`Saving…`:`Save JSON`),9,GO)]),A(x)?(I(),L(`p`,KO,D(A(x)),1)):H(``,!0),T.value?(I(),L(`p`,qO,D(T.value),1)):H(``,!0),B(Jy,{value:A(g)?.value??{},disabled:w.value||A(v)||!A(g),onChange:te},null,8,[`value`,`disabled`])],64)):H(``,!0),A(J).tab===`tasks`?(I(),R(Jb,{key:2})):H(``,!0),A(J).tab===`git`?(I(),R(VC,{key:3})):H(``,!0),A(J).tab===`host`?(I(),R(uw,{key:4})):H(``,!0),A(J).tab===`usage`?(I(),R(tT,{key:5})):H(``,!0),A(J).tab===`auto`?(I(),R(MT,{key:6})):H(``,!0),A(J).tab===`archive`?(I(),R(ZT,{key:7})):H(``,!0),A(J).tab===`dag`?(I(),R(gE,{key:8})):H(``,!0),A(J).tab===`notify`?(I(),R(VE,{key:9})):H(``,!0),A(J).tab===`env`?(I(),R(xD,{key:10})):H(``,!0),A(J).tab===`extensions`?(I(),R(kD,{key:11})):H(``,!0),A(J).tab===`tools`?(I(),L(F,{key:12},[z(`div`,JO,[p[21]||=z(`h2`,null,`Tools`,-1),z(`span`,YO,D(ie.value)+` / `+D(A(id)?.tools.length??0),1)]),p[25]||=z(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),z(`div`,XO,[z(`div`,null,[B(A(sl),{size:18}),p[23]||=z(`strong`,null,`Read only`,-1),z(`button`,{class:E([`switch`,{on:re.value}]),role:`switch`,"aria-checked":re.value,"aria-label":`Read only`,onClick:p[9]||=e=>a({readOnly:!re.value},re.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...p[22]||=[z(`span`,null,null,-1)]],10,ZO)]),p[24]||=z(`p`,null,` Offers this agent only tools that read. Tools that create, update or delete leave its next request, and the choice is stored with the agent. `,-1)]),(I(!0),L(F,null,P(A(id)?.tools,e=>(I(),L(`details`,{key:e.name,class:E([`tool-row`,{disabled:!e.offered}])},[z(`summary`,null,[B(A(bl),{size:18}),z(`strong`,null,D(e.name),1),e.offered?H(``,!0):(I(),L(`span`,QO,`disabled`)),z(`span`,$O,D(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),z(`p`,null,D(e.description),1),e.parameters?(I(),L(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[z(`code`,null,[(I(!0),L(F,null,P(t.value.get(e.name),(e,t)=>(I(),L(`span`,{key:t,class:E(`tk-${e.kind}`)},D(e.text),3))),128))])],8,ek)):H(``,!0),z(`small`,null,D(e.replay===`safe`?`An interrupted execution may run again after recovery.`:`A crash records an interrupted result instead of rerunning this effect.`),1)],2))),128))],64)):H(``,!0)],10,gO)],64)):(I(),L(`div`,sO,[z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${A(Dd).inspector})`,onClick:p[0]||=e=>A(Sd)()},[B(A(Wc),{size:18})],8,cO),(I(),L(F,null,P(n,e=>z(`button`,{key:e.id,class:E([`rail-tab`,{active:A(J).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>A(Sd)(e.id)},[(I(),R($r(e.icon),{size:20})),e.id===`tasks`&&A(Qu).length?(I(),L(`span`,uO,D(A(Qu).length),1)):H(``,!0)],10,lO)),64))]))],2))}}),[[`__scopeId`,`data-v-419eb6ed`]]),nk={class:`chat-empty`},rk={class:`eyebrow`},ik={key:3,class:`hint offline-error`},ak={key:4,class:`offline-command`},ok={key:5,class:`hint`},sk={key:6,class:`hint`},ck={class:`offline-actions`},lk=[`disabled`],uk={key:7,class:`message-error`,role:`alert`},dk=N({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=k(!1),r=k(``),i=U(()=>{let e=t.device,n=e.source===`config`;switch(e.status){case`checking`:return{title:`Checking ${e.name}…`,text:`Probing the device. This view fills in as soon as it answers.`};case`unauthorized`:return e.transport===`tunnel`?{title:`${e.name} tunnel credentials are not valid`,text:`Pair the device again — the hub will mint a fresh credential.`}:{title:e.hasToken?`${e.name} rejected its token`:`No token for ${e.name}`,text:e.hasToken?`The device's DPI_TOKEN changed (a rotate or a rebuilt device). Copy the current token into this hub's registry, then check again.`:`This hub has no token for the device yet. Register it, then check again.`,command:n&&e.kind!==`url`?`just net register ${e.id}`:`just net register ${e.id} --token <token>`};case`mismatch`:return{title:`${e.name} answers as a different device`,text:`The URL now reaches a backend with another identity (a rebuilt VM or a new data directory). If that is expected, register it again: that trusts the identity it answers with now.`,command:e.kind===`url`?`just net register ${e.id} --token <token>`:`just net register ${e.id}`};case`incompatible`:return{title:`${e.name} speaks another API version`,text:`Update the device's dpi-backend.`,command:n?`just net deploy ${e.id}`:void 0};default:return{title:`${e.name} is offline`,text:`Last seen ${gd(e.lastSeenAt)}. Its agents keep their state on the device and resume when its backend starts again. The tree shows the last known sessions.`,command:n?e.kind===`local`?`just backend run`:e.kind===`url`?void 0:`just net restart ${e.id}`:void 0,alt:n&&e.kind!==`local`&&e.kind!==`url`?`just net up ${e.id}`:void 0}}});async function a(){n.value=!0,r.value=``;try{let e=await fu.check(t.device.id);e.status===`online`&&Y(`${e.id} is online.`)}catch(e){r.value=K(e)}finally{n.value=!1}}async function o(e){try{await navigator.clipboard.writeText(e),Y(`Copied.`)}catch{Y(`Clipboard needs localhost or HTTPS. Select the text to copy.`)}}return(t,s)=>(I(),L(`section`,{class:E([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[z(`div`,nk,[e.device.status===`checking`?(I(),R(A(Ic),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(I(),R(A(ol),{key:1,size:30})):(I(),R(A(_l),{key:2,size:30})),z(`span`,rk,D(e.device.kind.toUpperCase())+` · `+D(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),z(`h2`,null,D(i.value.title),1),z(`p`,null,D(i.value.text),1),e.device.error?(I(),L(`p`,ik,D(e.device.error),1)):H(``,!0),i.value.command?(I(),L(`div`,ak,[z(`code`,null,D(i.value.command),1),z(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[B(A(sc),{size:18})])])):H(``,!0),i.value.command?(I(),L(`p`,ok,`Run it in this repo's terminal, then press Check now.`)):H(``,!0),i.value.alt?(I(),L(`p`,sk,[s[2]||=V(` Never deployed or rebuilt? `,-1),z(`code`,null,D(i.value.alt),1),s[3]||=V(` provisions it from scratch. `,-1)])):H(``,!0),z(`div`,ck,[z(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[B(A($c),{size:18}),V(D(n.value?`Checking…`:`Check now`),1)],8,lk)]),r.value?(I(),L(`p`,uk,D(r.value),1)):H(``,!0)])],2))}}),fk={class:`dir-browser`},pk={class:`dir-path`},mk=[`disabled`],hk=[`aria-busy`],gk=[`title`],_k=[`aria-selected`,`title`,`onClick`],vk={key:1,class:`hint`},yk={key:0,class:`message-error`,role:`alert`},bk=N({__name:`DirBrowser`,props:si({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Di(e,`modelValue`),r=k(),i=k(!1),a=k(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await G(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=K(e));return}finally{s===o&&(i.value=!1)}}return M(()=>t.deviceId,async()=>{r.value=void 0;let e=await s(``),t=e?.dirs[0];t&&!e.path&&await s(t.path)},{immediate:!0}),(e,t)=>(I(),L(`div`,fk,[z(`div`,pk,[j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,"aria-label":`Working directory`,required:``,placeholder:`/path/to/project`,spellcheck:`false`,autocomplete:`off`,onKeydown:t[1]||=js(ks(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[ys,n.value]]),z(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,mk)]),z(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[z(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[B(A(Dc),{size:16}),t[5]||=z(`span`,null,`Start dirs`,-1)]),r.value?.parent?(I(),L(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[B(A(lc),{size:16}),t[6]||=z(`span`,null,`..`,-1)],8,gk)):H(``,!0),(I(!0),L(F,null,P(r.value?.dirs,e=>(I(),L(`button`,{key:e.path,type:`button`,class:`dir-item`,role:`option`,"aria-selected":e.path===n.value,title:e.path,onClick:t=>s(e.path)},[e.path===n.value?(I(),R(A(yc),{key:0,size:16})):(I(),R(A(bc),{key:1,size:16})),z(`span`,null,D(e.name),1)],8,_k))),128)),r.value&&!r.value.dirs.length?(I(),L(`p`,vk,`No subdirectories.`)):H(``,!0)],8,hk),a.value?(I(),L(`p`,yk,D(a.value),1)):H(``,!0)]))}}),xk={key:0,class:`message-error`},Sk=[`value`],Ck={class:`field`},wk={key:0,class:`recent-cwds`},Tk=[`title`,`onClick`],Ek={key:0,class:`hint`,title:`The device has no provider key — it lists its built-in catalog, and chat needs OPENROUTER_API_KEY set in the device's env file`},Dk=[`value`],Ok=[`value`],kk={key:2,class:`message-error`,role:`alert`},Ak=[`disabled`],jk=`dpi-recent-cwds`,Mk=Hd(N({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>wu.devices.value.filter(e=>e.status===`online`)),a=k(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=U(()=>i.value.find(e=>e.id===a.value)),s=U(()=>{let e=o.value?.info?.models??[];if(e.length)return e;let t=o.value?.info;return t?.defaultModel&&t.provider?[{id:t.defaultModel,provider:t.provider,name:`${t.defaultModel} (device default)`,tier:`—`,icon:`lab.png`,contextWindow:0,reasoning:!1,cost:{input:0,output:0}}]:[]}),c=U(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=U(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=k({name:``,cwd:``,model:``,thinking:`medium`}),f=U(()=>{try{return JSON.parse(localStorage.getItem(jk)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(jk)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(jk,JSON.stringify({...n,[e]:r}))}catch{}},m=k(!1),h=k(``),g=k({});M(a,async e=>{if(g.value={},e)try{let{projects:t}=await G(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),M([()=>d.value.cwd,g],()=>{let e=d.value.cwd;if(!e)return;let t=Object.keys(g.value).filter(t=>e===t||e.startsWith(`${t}/`)).sort((e,t)=>t.length-e.length),n=t.length?g.value[t[0]]:void 0;n&&(d.value.model=`${n.provider}/${n.modelId}`)},{immediate:!0}),M(o,e=>{let t=s.value,n=t.find(t=>t.id===e?.info?.defaultModel)??t[0];d.value.model=n?u(n):``,d.value.cwd=``},{immediate:!0});async function _(){if(!m.value&&o.value){m.value=!0,h.value=``;try{let e=s.value.find(e=>u(e)===d.value.model)??s.value[0];if(!e)throw Error(`Choose a model`);let t=await G(o.value.id).createSession({name:d.value.name.trim()||`New session`,cwd:d.value.cwd.trim(),model:{provider:e.provider,modelId:e.id},thinkingLevel:d.value.thinking});p(o.value.id,t.cwd);let n=t.agents.find(e=>e.kind===`root`)??t.agents[0];Vu({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),Y(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=K(e)}finally{m.value=!1}}}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[7]||=ks(e=>r(`close`),[`self`])},[z(`form`,{class:`modal session-modal`,onSubmit:ks(_,[`prevent`])},[z(`header`,null,[t[8]||=z(`div`,null,[z(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),z(`h2`,null,`New session`)],-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[B(A(xl),{size:18})])]),i.value.length?(I(),L(F,{key:1},[z(`label`,null,[t[9]||=V(`Device`,-1),j(z(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(I(!0),L(F,null,P(i.value,e=>(I(),L(`option`,{key:e.id,value:e.id},D(e.name)+D(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,Sk))),128))],512),[[Ss,a.value]])]),z(`label`,null,[t[10]||=V(`Session name`,-1),j(z(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[ys,d.value.name]])]),z(`div`,Ck,[z(`span`,null,`Working directory on `+D(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(I(),L(`div`,wk,[(I(!0),L(F,null,P(f.value,e=>(I(),L(`button`,{key:e,type:`button`,class:E([`chip`,{on:e===d.value.cwd}]),title:e,onClick:t=>d.value.cwd=e},D(e.split(`/`).filter(Boolean).at(-1)||e),11,Tk))),128))])):H(``,!0),B(bk,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),z(`label`,null,[t[11]||=V(`Model`,-1),c.value||l.value?(I(),L(`span`,Ek,`no API key on device — chat needs one`)):H(``,!0),j(z(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(I(!0),L(F,null,P(s.value,e=>(I(),L(`option`,{key:u(e),value:u(e)},D(e.tier)+` / `+D(e.name),9,Dk))),128))],512),[[Ss,d.value.model]])]),z(`label`,null,[t[12]||=V(`Thinking`,-1),j(z(`select`,{"onUpdate:modelValue":t[5]||=e=>d.value.thinking=e,"aria-label":`New session thinking level`},[(I(!0),L(F,null,P(A(mv),e=>(I(),L(`option`,{key:e,value:e},D(e),9,Ok))),128))],512),[[Ss,d.value.thinking]])])],64)):(I(),L(`p`,xk,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(I(),L(`p`,kk,D(h.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,onClick:t[6]||=e=>r(`close`)},`Cancel`),z(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[B(A(Xc),{size:18}),V(D(m.value?`Creating…`:`Create session`),1)],8,Ak)])],32)]))}}),[[`__scopeId`,`data-v-95f14dc6`]]),Nk=new Uint8Array(512),Pk=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)Nk[t]=e,Pk[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)Nk[e]=Nk[e-255]})();var Fk=(e,t)=>e===0||t===0?0:Nk[Pk[e]+Pk[t]];function Ik(e){let t=[1];for(let n=0;n<e;n++){let e=Array(t.length+1).fill(0);for(let r=0;r<t.length;r++)e[r]^=t[r],e[r+1]^=Fk(t[r],Nk[n]);t=e}return t}function Lk(e,t){let n=Ik(t),r=Array(t).fill(0);for(let i of e){let e=i^r[0];r.shift(),r.push(0);for(let i=0;i<t;i++)r[i]^=Fk(n[i+1],e)}return r}var Rk=[21,25,29,33,37,41,45,49,53,57,61,65],zk=[19,34,55,80,108,136,156,194,232,274,324,370],Bk=[7,10,15,20,26,36,40,48,60,72,80,96],Vk=[7,10,15,20,26,18,20,24,30,18,20,24],Hk=[[[1,19]],[[1,34]],[[1,55]],[[1,80]],[[1,108]],[[2,68]],[[2,78]],[[2,97]],[[2,116]],[[2,68],[2,69]],[[4,81]],[[2,92],[2,93]]],Uk=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58]],Wk=e=>e<=9?8:16;function Gk(e){for(let t=1;t<=Rk.length;t++)if(4+Wk(t)+e*8<=zk[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${zk[11]-3})`)}function Kk(e,t){let n=[...new TextEncoder().encode(e)],r=[],i=(e,t)=>{for(let n=t-1;n>=0;n--)r.push(e>>n&1)};i(4,4),i(n.length,Wk(t));for(let e of n)i(e,8);let a=zk[t-1],o=a*8;for(i(0,Math.min(4,o-r.length));r.length%8!=0;)r.push(0);let s=[236,17],c=0;for(;r.length<o;)i(s[c++%2],8);let l=[];for(let e=0;e<a;e++){let t=0;for(let n=0;n<8;n++)t=t<<1|r[e*8+n];l.push(t)}return l}function qk(e,t){let n=Vk[e-1],r=[],i=0;for(let[n,a]of Hk[e-1])for(let e=0;e<n;e++)r.push(t.slice(i,i+=a));let a=[],o=Math.max(...r.map(e=>e.length));for(let e=0;e<o;e++)for(let t of r)e<t.length&&a.push(t[e]);let s=r.map(e=>Lk(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function Jk(e){return Array.from({length:e},()=>Array(e).fill(!1))}function Yk(e,t){let n=Rk[t-1],r=(t,r)=>{for(let i=-1;i<=7;i++)for(let a=-1;a<=7;a++){let o=t+i,s=r+a;if(o<0||o>=n||s<0||s>=n)continue;let c=i>=0&&i<=6&&a>=0&&a<=6&&(i===0||i===6||a===0||a===6),l=i>=2&&i<=4&&a>=2&&a<=4;e[o][s]=c||l}};r(0,0),r(0,n-7),r(n-7,0);for(let t=8;t<n-8;t++)e[6][t]=t%2==0,e[t][6]=t%2==0;let i=Uk[t-1];for(let t of i)for(let r of i)if(!(t<=8&&r<=8||t<=8&&r>=n-9||t>=n-9&&r<=8))for(let n=-2;n<=2;n++)for(let i=-2;i<=2;i++)e[t+n][r+i]=Math.max(Math.abs(n),Math.abs(i))!==1;if(e[n-8][8]=!0,t>=7){let r=t<<12;for(let e=17;e>=12;e--)r>>e&1&&(r^=7973<<e-12);let i=t<<12|r&4095;for(let t=0;t<18;t++){let r=(i>>t&1)==1,a=n-11+t%3,o=t/3|0;e[a][o]=r,e[o][a]=r}}}function Xk(e){let t=8|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>9&1?1335:0);let r=(t<<10|n)^21522,i=[];for(let e=14;e>=0;e--)i.push((r>>e&1)==1);return i}function Zk(e,t){let n=Rk[0]*0+e.length,r=Xk(t);for(let t=0;t<=5;t++)e[8][t]=r[t];e[8][7]=r[6],e[8][8]=r[7],e[7][8]=r[8];for(let t=9;t<15;t++)e[14-t][8]=r[t];for(let t=0;t<7;t++)e[n-1-t][8]=r[t];e[8][n-8]=r[7];for(let t=8;t<15;t++)e[8][n-15+t]=r[t];e[n-8][8]=!0}function Qk(e,t,n,r){let i=e.length;Rk[n-1]*Rk[n-1];let a=e=>((t[e>>3]??0)>>7-(e&7)&1)==1,o=0,s=!0;for(let t=i-1;t>0;t-=2){t===6&&t--;for(let c=0;c<i;c++){let l=s?i-1-c:c;for(let i of[t,t-1]){if(eA(l,i,n))continue;if(o>=(zk[n-1]+Bk[n-1])*8){o++;continue}let t=a(o++);$k(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function $k(e,t,n){switch(n){case 0:return(e+t)%2==0;case 1:return e%2==0;case 2:return t%3==0;case 3:return(e+t)%3==0;case 4:return(Math.floor(e/2)+Math.floor(t/3))%2==0;case 5:return e*t%2+e*t%3==0;case 6:return(e*t%2+e*t%3)%2==0;default:return((e+t)%2+e*t%3)%2==0}}function eA(e,t,n){let r=Rk[n-1];if(e<=8&&t<=8||e<=8&&t>=r-8||e>=r-8&&t<=8||e===6||t===6||n>=7&&(e>=r-11&&e<=r-9&&t<=5||t>=r-11&&t<=r-9&&e<=5))return!0;let i=Uk[n-1];for(let n of i)for(let a of i)if(!(n<=8&&a<=8||n<=8&&a>=r-9||n>=r-9&&a<=8)&&Math.abs(e-n)<=2&&Math.abs(t-a)<=2)return!0;return!1}function tA(e){let t=e.length,n=0;for(let r=0;r<2;r++)for(let i=0;i<t;i++){let a=1;for(let o=1;o<t;o++)(r===0?e[i][o]:e[o][i])===(r===0?e[i][o-1]:e[o-1][i])?(a++,o===t-1&&a>=5&&(n+=3+(a-5))):(a>=5&&(n+=3+(a-5)),a=1)}for(let r=0;r<t-1;r++)for(let i=0;i<t-1;i++){let t=e[r][i];e[r][i+1]===t&&e[r+1][i]===t&&e[r+1][i+1]===t&&(n+=3)}let r=[!0,!1,!0,!0,!0,!1,!0,!1,!1,!1,!1],i=(e,t)=>{for(let i=0;i+11<=t;i++){let t=!0;for(let n=0;n<11;n++)if(e(i+n)!==r[n]){t=!1;break}t&&(n+=40)}};for(let n=0;n<t;n++)i(t=>e[n][t],t);for(let n=0;n<t;n++)i(t=>e[t][n],t);let a=0;for(let t of e)for(let e of t)e&&a++;let o=a*100/(t*t);return n+=Math.floor(Math.abs(o-50)/5)*10,n}function nA(e,t){let n=Gk(new TextEncoder().encode(e).length),r=Rk[n-1],i=qk(n,Kk(e,n)),a=Jk(r);return Yk(a,n),Qk(a,i,n,t),Zk(a,t),a}function rA(e,t){if(t!==void 0)return nA(e,t);let n;for(let t=0;t<8;t++){let r=nA(e,t),i=tA(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function iA(e,t=160){let n=rA(e),r=n.length,i=t/(r+8),a=``;for(let e=0;e<r;e++)for(let t=0;t<r;t++)n[e][t]&&(a+=`<rect x="${((t+4)*i).toFixed(2)}" y="${((e+4)*i).toFixed(2)}" width="${i.toFixed(3)}" height="${i.toFixed(3)}"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${t}" shape-rendering="crispEdges"><rect width="${t}" height="${t}" fill="#fff"/><g fill="#000">${a}</g></svg>`}var aA={class:`device-handoff`,"aria-label":`Pair this machine`},oA={class:`row`},sA=[`disabled`],cA=[`disabled`],lA={key:0,class:`target`,"data-testid":`device-url`},uA={key:1,class:`err`},dA=Hd(N({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=k(`4780`),r=k(!1),i=U(()=>{let e=/^\d{1,5}$/.test(n.value)?Number(n.value):0;if(!(!e||e<1||e>65535))return`http://127.0.0.1:${e}/pair#${t.offerFragment}`});function a(){let e=i.value;e&&window.open(e,`_blank`,`noopener`)}async function o(){let e=i.value;if(e)try{await navigator.clipboard.writeText(e),r.value=!0,setTimeout(()=>r.value=!1,1600)}catch{}}return(e,t)=>(I(),L(`section`,aA,[z(`header`,null,[B(A(zc),{size:18}),t[1]||=z(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=z(`p`,{class:`what`},[V(` If this browser runs on the device itself, open its local pairing page — the offer is relayed inside the link, nothing is sent to the hub. Start `),z(`code`,null,`dpi device`),V(` there first. `)],-1),z(`div`,oA,[z(`label`,null,[t[2]||=V(` local port `,-1),j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[ys,n.value]])]),z(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[B(A(mc),{size:15}),t[3]||=V(`Open the device page `,-1)],8,sA),z(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[B(A(sc),{size:15}),V(D(r.value?`Copied`:`Copy link`),1)],8,cA)]),i.value?(I(),L(`p`,lA,D(i.value),1)):H(``,!0),i.value?H(``,!0):(I(),L(`p`,uA,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-01884b7b`]]);function fA(e){return xA(e)&&!pA(e)&&!TA(e)&&Symbol.asyncIterator in e}function pA(e){return Array.isArray(e)}function mA(e){return typeof e==`bigint`}function hA(e){return typeof e==`boolean`}function gA(e){return e instanceof globalThis.Date}function _A(e){return typeof e==`function`}function vA(e){return xA(e)&&!pA(e)&&!TA(e)&&Symbol.iterator in e}function yA(e){return e===null}function bA(e){return typeof e==`number`}function xA(e){return typeof e==`object`&&!!e}function SA(e){return e instanceof globalThis.RegExp}function CA(e){return typeof e==`string`}function wA(e){return typeof e==`symbol`}function TA(e){return e instanceof globalThis.Uint8Array}function EA(e){return e===void 0}function DA(e){return e.map(e=>MA(e))}function OA(e){return new Date(e.getTime())}function kA(e){return new Uint8Array(e)}function AA(e){return new RegExp(e.source,e.flags)}function jA(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=MA(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=MA(e[n]);return t}function MA(e){return pA(e)?DA(e):gA(e)?OA(e):TA(e)?kA(e):SA(e)?AA(e):xA(e)?jA(e):e}function NA(e){return MA(e)}function PA(e,t){return NA(t===void 0?e:{...t,...e})}function FA(e){return typeof e==`object`&&!!e}function IA(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function LA(e){return e===void 0}function RA(e){return typeof e==`number`}var zA;(function(e){e.InstanceMode=`default`,e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(t,n){return e.ExactOptionalPropertyTypes?n in t:t[n]!==void 0}e.IsExactOptionalProperty=t;function n(t){let n=FA(t);return e.AllowArrayObject?n:n&&!IA(t)}e.IsObjectLike=n;function r(e){return n(e)&&!(e instanceof Date)&&!(e instanceof Uint8Array)}e.IsRecordLike=r;function i(t){return e.AllowNaN?RA(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=LA(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(zA||={});function BA(e){return globalThis.Object.freeze(e).map(e=>GA(e))}function VA(e){return e}function HA(e){return e}function UA(e){return e}function WA(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=GA(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=GA(e[n]);return globalThis.Object.freeze(t)}function GA(e){return pA(e)?BA(e):gA(e)?VA(e):TA(e)?HA(e):SA(e)?UA(e):xA(e)?WA(e):e}function X(e,t){let n=t===void 0?e:{...t,...e};switch(zA.InstanceMode){case`freeze`:return GA(n);case`clone`:return NA(n);default:return n}}var KA=class extends Error{constructor(e){super(e)}},qA=Symbol.for(`TypeBox.Transform`),JA=Symbol.for(`TypeBox.Readonly`),YA=Symbol.for(`TypeBox.Optional`),XA=Symbol.for(`TypeBox.Hint`),Z=Symbol.for(`TypeBox.Kind`);function ZA(e){return xA(e)&&e[JA]===`Readonly`}function QA(e){return xA(e)&&e[YA]===`Optional`}function $A(e){return fj(e,`Any`)}function ej(e){return fj(e,`Argument`)}function tj(e){return fj(e,`Array`)}function nj(e){return fj(e,`AsyncIterator`)}function rj(e){return fj(e,`BigInt`)}function ij(e){return fj(e,`Boolean`)}function aj(e){return fj(e,`Computed`)}function oj(e){return fj(e,`Constructor`)}function sj(e){return fj(e,`Date`)}function cj(e){return fj(e,`Function`)}function lj(e){return fj(e,`Integer`)}function uj(e){return fj(e,`Intersect`)}function dj(e){return fj(e,`Iterator`)}function fj(e,t){return xA(e)&&Z in e&&e[Z]===t}function pj(e){return hA(e)||bA(e)||CA(e)}function mj(e){return fj(e,`Literal`)}function hj(e){return fj(e,`MappedKey`)}function gj(e){return fj(e,`MappedResult`)}function _j(e){return fj(e,`Never`)}function vj(e){return fj(e,`Not`)}function yj(e){return fj(e,`Null`)}function bj(e){return fj(e,`Number`)}function xj(e){return fj(e,`Object`)}function Sj(e){return fj(e,`Promise`)}function Cj(e){return fj(e,`Record`)}function wj(e){return fj(e,`Ref`)}function Tj(e){return fj(e,`RegExp`)}function Ej(e){return fj(e,`String`)}function Dj(e){return fj(e,`Symbol`)}function Oj(e){return fj(e,`TemplateLiteral`)}function kj(e){return fj(e,`This`)}function Aj(e){return xA(e)&&qA in e}function jj(e){return fj(e,`Tuple`)}function Mj(e){return fj(e,`Undefined`)}function Nj(e){return fj(e,`Union`)}function Pj(e){return fj(e,`Uint8Array`)}function Fj(e){return fj(e,`Unknown`)}function Ij(e){return fj(e,`Unsafe`)}function Lj(e){return fj(e,`Void`)}function Rj(e){return xA(e)&&Z in e&&CA(e[Z])}function zj(e){return $A(e)||ej(e)||tj(e)||ij(e)||rj(e)||nj(e)||aj(e)||oj(e)||sj(e)||cj(e)||lj(e)||uj(e)||dj(e)||mj(e)||hj(e)||gj(e)||_j(e)||vj(e)||yj(e)||bj(e)||xj(e)||Sj(e)||Cj(e)||wj(e)||Tj(e)||Ej(e)||Dj(e)||Oj(e)||kj(e)||jj(e)||Mj(e)||Nj(e)||Pj(e)||Fj(e)||Ij(e)||Lj(e)||Rj(e)}var Bj=`Argument.Any.Array.AsyncIterator.BigInt.Boolean.Computed.Constructor.Date.Enum.Function.Integer.Intersect.Iterator.Literal.MappedKey.MappedResult.Not.Null.Number.Object.Promise.Record.Ref.RegExp.String.Symbol.TemplateLiteral.This.Tuple.Undefined.Union.Uint8Array.Unknown.Void`.split(`.`);function Vj(e){try{return new RegExp(e),!0}catch{return!1}}function Hj(e){if(!CA(e))return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=7&&n<=13||n===27||n===127)return!1}return!0}function Uj(e){return Kj(e)||HM(e)}function Wj(e){return EA(e)||mA(e)}function Gj(e){return EA(e)||bA(e)}function Kj(e){return EA(e)||hA(e)}function qj(e){return EA(e)||CA(e)}function Jj(e){return EA(e)||CA(e)&&Hj(e)&&Vj(e)}function Yj(e){return EA(e)||CA(e)&&Hj(e)}function Xj(e){return EA(e)||HM(e)}function Zj(e){return xA(e)&&e[YA]===`Optional`}function Qj(e){return fM(e,`Any`)&&qj(e.$id)}function $j(e){return fM(e,`Argument`)&&bA(e.index)}function eM(e){return fM(e,`Array`)&&e.type===`array`&&qj(e.$id)&&HM(e.items)&&Gj(e.minItems)&&Gj(e.maxItems)&&Kj(e.uniqueItems)&&Xj(e.contains)&&Gj(e.minContains)&&Gj(e.maxContains)}function tM(e){return fM(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&qj(e.$id)&&HM(e.items)}function nM(e){return fM(e,`BigInt`)&&e.type===`bigint`&&qj(e.$id)&&Wj(e.exclusiveMaximum)&&Wj(e.exclusiveMinimum)&&Wj(e.maximum)&&Wj(e.minimum)&&Wj(e.multipleOf)}function rM(e){return fM(e,`Boolean`)&&e.type===`boolean`&&qj(e.$id)}function iM(e){return fM(e,`Computed`)&&CA(e.target)&&pA(e.parameters)&&e.parameters.every(e=>HM(e))}function aM(e){return fM(e,`Constructor`)&&e.type===`Constructor`&&qj(e.$id)&&pA(e.parameters)&&e.parameters.every(e=>HM(e))&&HM(e.returns)}function oM(e){return fM(e,`Date`)&&e.type===`Date`&&qj(e.$id)&&Gj(e.exclusiveMaximumTimestamp)&&Gj(e.exclusiveMinimumTimestamp)&&Gj(e.maximumTimestamp)&&Gj(e.minimumTimestamp)&&Gj(e.multipleOfTimestamp)}function sM(e){return fM(e,`Function`)&&e.type===`Function`&&qj(e.$id)&&pA(e.parameters)&&e.parameters.every(e=>HM(e))&&HM(e.returns)}function cM(e){return fM(e,`Integer`)&&e.type===`integer`&&qj(e.$id)&&Gj(e.exclusiveMaximum)&&Gj(e.exclusiveMinimum)&&Gj(e.maximum)&&Gj(e.minimum)&&Gj(e.multipleOf)}function lM(e){return xA(e)&&Object.entries(e).every(([e,t])=>Hj(e)&&HM(t))}function uM(e){return fM(e,`Intersect`)&&!(CA(e.type)&&e.type!==`object`)&&pA(e.allOf)&&e.allOf.every(e=>HM(e)&&!NM(e))&&qj(e.type)&&(Kj(e.unevaluatedProperties)||Xj(e.unevaluatedProperties))&&qj(e.$id)}function dM(e){return fM(e,`Iterator`)&&e.type===`Iterator`&&qj(e.$id)&&HM(e.items)}function fM(e,t){return xA(e)&&Z in e&&e[Z]===t}function pM(e){return gM(e)&&CA(e.const)}function mM(e){return gM(e)&&bA(e.const)}function hM(e){return gM(e)&&hA(e.const)}function gM(e){return fM(e,`Literal`)&&qj(e.$id)&&_M(e.const)}function _M(e){return hA(e)||bA(e)||CA(e)}function vM(e){return fM(e,`MappedKey`)&&pA(e.keys)&&e.keys.every(e=>bA(e)||CA(e))}function yM(e){return fM(e,`MappedResult`)&&lM(e.properties)}function bM(e){return fM(e,`Never`)&&xA(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function xM(e){return fM(e,`Not`)&&HM(e.not)}function SM(e){return fM(e,`Null`)&&e.type===`null`&&qj(e.$id)}function CM(e){return fM(e,`Number`)&&e.type===`number`&&qj(e.$id)&&Gj(e.exclusiveMaximum)&&Gj(e.exclusiveMinimum)&&Gj(e.maximum)&&Gj(e.minimum)&&Gj(e.multipleOf)}function wM(e){return fM(e,`Object`)&&e.type===`object`&&qj(e.$id)&&lM(e.properties)&&Uj(e.additionalProperties)&&Gj(e.minProperties)&&Gj(e.maxProperties)}function TM(e){return fM(e,`Promise`)&&e.type===`Promise`&&qj(e.$id)&&HM(e.item)}function EM(e){return fM(e,`Record`)&&e.type===`object`&&qj(e.$id)&&Uj(e.additionalProperties)&&xA(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&Vj(t[0])&&xA(e.patternProperties)&&HM(e.patternProperties[t[0]])})(e)}function DM(e){return fM(e,`Ref`)&&qj(e.$id)&&CA(e.$ref)}function OM(e){return fM(e,`RegExp`)&&qj(e.$id)&&CA(e.source)&&CA(e.flags)&&Gj(e.maxLength)&&Gj(e.minLength)}function kM(e){return fM(e,`String`)&&e.type===`string`&&qj(e.$id)&&Gj(e.minLength)&&Gj(e.maxLength)&&Jj(e.pattern)&&Yj(e.format)}function AM(e){return fM(e,`Symbol`)&&e.type===`symbol`&&qj(e.$id)}function jM(e){return fM(e,`TemplateLiteral`)&&e.type===`string`&&CA(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function MM(e){return fM(e,`This`)&&qj(e.$id)&&CA(e.$ref)}function NM(e){return xA(e)&&qA in e}function PM(e){return fM(e,`Tuple`)&&e.type===`array`&&qj(e.$id)&&bA(e.minItems)&&bA(e.maxItems)&&e.minItems===e.maxItems&&(EA(e.items)&&EA(e.additionalItems)&&e.minItems===0||pA(e.items)&&e.items.every(e=>HM(e)))}function FM(e){return fM(e,`Undefined`)&&e.type===`undefined`&&qj(e.$id)}function IM(e){return fM(e,`Union`)&&qj(e.$id)&&xA(e)&&pA(e.anyOf)&&e.anyOf.every(e=>HM(e))}function LM(e){return fM(e,`Uint8Array`)&&e.type===`Uint8Array`&&qj(e.$id)&&Gj(e.minByteLength)&&Gj(e.maxByteLength)}function RM(e){return fM(e,`Unknown`)&&qj(e.$id)}function zM(e){return fM(e,`Unsafe`)}function BM(e){return fM(e,`Void`)&&e.type===`void`&&qj(e.$id)}function VM(e){return xA(e)&&Z in e&&CA(e[Z])&&!Bj.includes(e[Z])}function HM(e){return xA(e)&&(Qj(e)||$j(e)||eM(e)||rM(e)||nM(e)||tM(e)||iM(e)||aM(e)||oM(e)||sM(e)||cM(e)||uM(e)||dM(e)||gM(e)||vM(e)||yM(e)||bM(e)||xM(e)||SM(e)||CM(e)||wM(e)||TM(e)||EM(e)||DM(e)||OM(e)||kM(e)||AM(e)||jM(e)||MM(e)||PM(e)||FM(e)||IM(e)||LM(e)||RM(e)||zM(e)||BM(e)||VM(e))}var UM=`(true|false)`,WM=`(0|[1-9][0-9]*)`,GM=`(.*)`,KM=`(?!.*)`;`${UM}`;var qM=`^${WM}$`,JM=`^${GM}$`,YM=`^${KM}$`;function XM(e,t){return e.includes(t)}function ZM(e){return[...new Set(e)]}function QM(e,t){return e.filter(e=>t.includes(e))}function $M(e,t){return e.reduce((e,t)=>QM(e,t),t)}function eN(e){return e.length===1?e[0]:e.length>1?$M(e.slice(1),e[0]):[]}function tN(e){let t=[];for(let n of e)t.push(...n);return t}function nN(e){return X({[Z]:`Any`},e)}function rN(e,t){return X({[Z]:`Array`,type:`array`,items:e},t)}function iN(e){return X({[Z]:`Argument`,index:e})}function aN(e,t){return X({[Z]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function oN(e,t,n){return X({[Z]:`Computed`,target:e,parameters:t},n)}function sN(e,t){let{[t]:n,...r}=e;return r}function cN(e,t){return t.reduce((e,t)=>sN(e,t),e)}function lN(e){return X({[Z]:`Never`,not:{}},e)}function uN(e){return X({[Z]:`MappedResult`,properties:e})}function dN(e,t,n){return X({[Z]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function fN(e,t,n){return X({[Z]:`Function`,type:`Function`,parameters:e,returns:t},n)}function pN(e,t){return X({[Z]:`Union`,anyOf:e},t)}function mN(e){return e.some(e=>QA(e))}function hN(e){return e.map(e=>QA(e)?gN(e):e)}function gN(e){return cN(e,[YA])}function _N(e,t){return mN(e)?rF(pN(hN(e),t)):pN(hN(e),t)}function vN(e,t){return e.length===1?X(e[0],t):e.length===0?lN(t):_N(e,t)}function yN(e,t){return e.length===0?lN(t):e.length===1?X(e[0],t):pN(e,t)}var bN=class extends KA{};function xN(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function SN(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function CN(e,t){return SN(e,t,`(`)}function wN(e,t){return SN(e,t,`)`)}function TN(e,t){return SN(e,t,`|`)}function EN(e){if(!(CN(e,0)&&wN(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(CN(e,n)&&(t+=1),wN(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function DN(e){return e.slice(1,e.length-1)}function ON(e){let t=0;for(let n=0;n<e.length;n++)if(CN(e,n)&&(t+=1),wN(e,n)&&--t,TN(e,n)&&t===0)return!0;return!1}function kN(e){for(let t=0;t<e.length;t++)if(CN(e,t))return!0;return!1}function AN(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(CN(e,i)&&(t+=1),wN(e,i)&&--t,TN(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(MN(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(MN(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function jN(e){function t(e,t){if(!CN(e,t))throw new bN(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(CN(e,r)&&(n+=1),wN(e,r)&&--n,n===0)return[t,r];throw new bN(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(CN(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(CN(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(MN(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(MN(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function MN(e){return EN(e)?MN(DN(e)):ON(e)?AN(e):kN(e)?jN(e):{type:`const`,const:xN(e)}}function NN(e){return MN(e.slice(1,e.length-1))}var PN=class extends KA{};function FN(e){return e.type===`or`&&e.expr.length===2&&e.expr[0].type===`const`&&e.expr[0].const===`0`&&e.expr[1].type===`const`&&e.expr[1].const===`[1-9][0-9]*`}function IN(e){return e.type===`or`&&e.expr.length===2&&e.expr[0].type===`const`&&e.expr[0].const===`true`&&e.expr[1].type===`const`&&e.expr[1].const===`false`}function LN(e){return e.type===`const`&&e.const===`.*`}function RN(e){return FN(e)||LN(e)?!1:IN(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>RN(e)):e.type===`const`||(()=>{throw new PN(`Unknown expression type`)})()}function zN(e){return RN(NN(e.pattern))}var BN=class extends KA{};function*VN(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of VN(e.slice(1)))yield`${t}${n}`}function*HN(e){return yield*VN(e.expr.map(e=>[...GN(e)]))}function*UN(e){for(let t of e.expr)yield*GN(t)}function*WN(e){return yield e.const}function*GN(e){return e.type===`and`?yield*HN(e):e.type===`or`?yield*UN(e):e.type===`const`?yield*WN(e):(()=>{throw new BN(`Unknown expression`)})()}function KN(e){let t=NN(e.pattern);return RN(t)?[...GN(t)]:[]}function qN(e,t){return X({[Z]:`Literal`,const:e,type:typeof e},t)}function JN(e){return X({[Z]:`Boolean`,type:`boolean`},e)}function YN(e){return X({[Z]:`BigInt`,type:`bigint`},e)}function XN(e){return X({[Z]:`Number`,type:`number`},e)}function ZN(e){return X({[Z]:`String`,type:`string`},e)}function*QN(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield JN():t===`number`?yield XN():t===`bigint`?yield YN():t===`string`?yield ZN():yield(()=>{let e=t.split(`|`).map(e=>qN(e.trim()));return e.length===0?lN():e.length===1?e[0]:vN(e)})()}function*$N(e){if(e[1]!==`{`)return yield*[qN(`$`),...eP(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=QN(e.slice(2,t)),r=eP(e.slice(t+1));return yield*[...n,...r]}yield qN(e)}function*eP(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[qN(e.slice(0,t)),...$N(e.slice(t))];yield qN(e)}function tP(e){return[...eP(e)]}var nP=class extends KA{};function rP(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function iP(e,t){return Oj(e)?e.pattern.slice(1,e.pattern.length-1):Nj(e)?`(${e.anyOf.map(e=>iP(e,t)).join(`|`)})`:bj(e)||lj(e)||rj(e)?`${t}${WM}`:Ej(e)?`${t}${GM}`:mj(e)?`${t}${rP(e.const.toString())}`:ij(e)?`${t}${UM}`:(()=>{throw new nP(`Unexpected Kind '${e[Z]}'`)})()}function aP(e){return`^${e.map(e=>iP(e,``)).join(``)}$`}function oP(e){return vN(KN(e).map(e=>qN(e)))}function sP(e,t){let n=CA(e)?aP(tP(e)):aP(e);return X({[Z]:`TemplateLiteral`,type:`string`,pattern:n},t)}function cP(e){return KN(e).map(e=>e.toString())}function lP(e){let t=[];for(let n of e)t.push(...dP(n));return t}function uP(e){return[e.toString()]}function dP(e){return[...new Set(Oj(e)?cP(e):Nj(e)?lP(e.anyOf):mj(e)?uP(e.const):bj(e)||lj(e)?[`[number]`]:[])]}function fP(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=EP(e,dP(t[i]),n);return r}function pP(e,t,n){return fP(e,t.properties,n)}function mP(e,t,n){return uN(pP(e,t,n))}function hP(e,t){return e.map(e=>CP(e,t))}function gP(e){return e.filter(e=>!_j(e))}function _P(e,t){return fF(gP(hP(e,t)))}function vP(e){return e.some(e=>_j(e))?[]:e}function yP(e,t){return vN(vP(hP(e,t)))}function bP(e,t){return t in e?e[t]:t===`[number]`?vN(e):lN()}function xP(e,t){return t===`[number]`?e:lN()}function SP(e,t){return t in e?e[t]:lN()}function CP(e,t){return uj(e)?_P(e.allOf,t):Nj(e)?yP(e.anyOf,t):jj(e)?bP(e.items??[],t):tj(e)?xP(e.items,t):xj(e)?SP(e.properties,t):lN()}function wP(e,t){return t.map(t=>CP(e,t))}function TP(e,t){return vN(wP(e,t))}function EP(e,t,n){if(wj(e)||wj(t)){if(!zj(e)||!zj(t))throw new KA(`Index types using Ref parameters require both Type and Key to be of TSchema`);return oN(`Index`,[e,t])}return gj(t)?mP(e,t,n):hj(t)?AP(e,t,n):X(zj(t)?TP(e,dP(t)):TP(e,t),n)}function DP(e,t,n){return{[t]:EP(e,[t],NA(n))}}function OP(e,t,n){return t.reduce((t,r)=>({...t,...DP(e,r,n)}),{})}function kP(e,t,n){return OP(e,t.keys,n)}function AP(e,t,n){return uN(kP(e,t,n))}function jP(e,t){return X({[Z]:`Iterator`,type:`Iterator`,items:e},t)}function MP(e){return globalThis.Object.keys(e).filter(t=>!QA(e[t]))}function NP(e,t){let n=MP(e);return X(n.length>0?{[Z]:`Object`,type:`object`,required:n,properties:e}:{[Z]:`Object`,type:`object`,properties:e},t)}var PP=NP;function FP(e,t){return X({[Z]:`Promise`,type:`Promise`,item:e},t)}function IP(e){return X(cN(e,[JA]))}function LP(e){return X({...e,[JA]:`Readonly`})}function RP(e,t){return t===!1?IP(e):LP(e)}function zP(e,t){let n=t??!0;return gj(e)?HP(e,n):RP(e,n)}function BP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=zP(e[r],t);return n}function VP(e,t){return BP(e.properties,t)}function HP(e,t){return uN(VP(e,t))}function UP(e,t){return X(e.length>0?{[Z]:`Tuple`,type:`array`,items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[Z]:`Tuple`,type:`array`,minItems:e.length,maxItems:e.length},t)}function WP(e,t){return e in t?ZP(e,t[e]):uN(t)}function GP(e){return{[e]:qN(e)}}function KP(e){let t={};for(let n of e)t[n]=qN(n);return t}function qP(e,t){return XM(t,e)?GP(e):KP(t)}function JP(e,t){return WP(e,qP(e,t))}function YP(e,t){return t.map(t=>ZP(e,t))}function XP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=ZP(e,t[r]);return n}function ZP(e,t){let n={...t};return QA(t)?rF(ZP(e,cN(t,[YA]))):ZA(t)?zP(ZP(e,cN(t,[JA]))):gj(t)?WP(e,t.properties):hj(t)?JP(e,t.keys):oj(t)?dN(YP(e,t.parameters),ZP(e,t.returns),n):cj(t)?fN(YP(e,t.parameters),ZP(e,t.returns),n):nj(t)?aN(ZP(e,t.items),n):dj(t)?jP(ZP(e,t.items),n):uj(t)?pF(YP(e,t.allOf),n):Nj(t)?yN(YP(e,t.anyOf),n):jj(t)?UP(YP(e,t.items??[]),n):xj(t)?PP(XP(e,t.properties),n):tj(t)?rN(ZP(e,t.items),n):Sj(t)?FP(ZP(e,t.item),n):t}function QP(e,t){let n={};for(let r of e)n[r]=ZP(r,t);return n}function $P(e,t,n){let r=zj(e)?dP(e):e;return PP(QP(r,t({[Z]:`MappedKey`,keys:r})),n)}function eF(e){return X(cN(e,[YA]))}function tF(e){return X({...e,[YA]:`Optional`})}function nF(e,t){return t===!1?eF(e):tF(e)}function rF(e,t){let n=t??!0;return gj(e)?oF(e,n):nF(e,n)}function iF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=rF(e[r],t);return n}function aF(e,t){return iF(e.properties,t)}function oF(e,t){return uN(aF(e,t))}function sF(e,t={}){let n=e.every(e=>xj(e)),r=zj(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return X(t.unevaluatedProperties===!1||zj(t.unevaluatedProperties)||n?{...r,[Z]:`Intersect`,type:`object`,allOf:e}:{...r,[Z]:`Intersect`,allOf:e},t)}function cF(e){return e.every(e=>QA(e))}function lF(e){return cN(e,[YA])}function uF(e){return e.map(e=>QA(e)?lF(e):e)}function dF(e,t){return cF(e)?rF(sF(uF(e),t)):sF(uF(e),t)}function fF(e,t={}){if(e.length===1)return X(e[0],t);if(e.length===0)return lN(t);if(e.some(e=>Aj(e)))throw Error(`Cannot intersect transform types`);return dF(e,t)}function pF(e,t){if(e.length===1)return X(e[0],t);if(e.length===0)return lN(t);if(e.some(e=>Aj(e)))throw Error(`Cannot intersect transform types`);return sF(e,t)}function mF(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new KA(`Ref: $ref must be a string`);return X({[Z]:`Ref`,$ref:t},n)}function hF(e,t){return oN(`Awaited`,[oN(e,t)])}function gF(e){return oN(`Awaited`,[mF(e)])}function _F(e){return pF(bF(e))}function vF(e){return yN(bF(e))}function yF(e){return xF(e)}function bF(e){return e.map(e=>xF(e))}function xF(e,t){return X(aj(e)?hF(e.target,e.parameters):uj(e)?_F(e.allOf):Nj(e)?vF(e.anyOf):Sj(e)?yF(e.item):wj(e)?gF(e.$ref):e,t)}function SF(e){let t=[];for(let n of e)t.push(kF(n));return t}function CF(e){return tN(SF(e))}function wF(e){return eN(SF(e))}function TF(e){return e.map((e,t)=>t.toString())}function EF(e){return[`[number]`]}function DF(e){return globalThis.Object.getOwnPropertyNames(e)}function OF(e){return AF?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function kF(e){return uj(e)?CF(e.allOf):Nj(e)?wF(e.anyOf):jj(e)?TF(e.items??[]):tj(e)?EF(e.items):xj(e)?DF(e.properties):Cj(e)?OF(e.patternProperties):[]}var AF=!1;function jF(e,t){return oN(`KeyOf`,[oN(e,t)])}function MF(e){return oN(`KeyOf`,[mF(e)])}function NF(e,t){return X(vN(PF(kF(e))),t)}function PF(e){return e.map(e=>e===`[number]`?XN():qN(e))}function FF(e,t){return aj(e)?jF(e.target,e.parameters):wj(e)?MF(e.$ref):gj(e)?RF(e,t):NF(e,t)}function IF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=FF(e[r],NA(t));return n}function LF(e,t){return IF(e.properties,t)}function RF(e,t){return uN(LF(e,t))}function zF(e){let t=[];for(let n of e)t.push(...kF(n));return ZM(t)}function BF(e){return e.filter(e=>!_j(e))}function VF(e,t){let n=[];for(let r of e)n.push(...wP(r,[t]));return BF(n)}function HF(e,t){let n={};for(let r of t)n[r]=fF(VF(e,r));return n}function UF(e,t){return PP(HF(e,zF(e)),t)}function WF(e){return X({[Z]:`Date`,type:`Date`},e)}function GF(e){return X({[Z]:`Null`,type:`null`},e)}function KF(e){return X({[Z]:`Symbol`,type:`symbol`},e)}function qF(e){return X({[Z]:`Undefined`,type:`undefined`},e)}function JF(e){return X({[Z]:`Uint8Array`,type:`Uint8Array`},e)}function YF(e){return X({[Z]:`Unknown`},e)}function XF(e){return e.map(e=>$F(e,!1))}function ZF(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=zP($F(e[n],!1));return t}function QF(e,t){return t===!0?e:zP(e)}function $F(e,t){return fA(e)||vA(e)?QF(nN(),t):pA(e)?zP(UP(XF(e))):TA(e)?JF():gA(e)?WF():xA(e)?QF(PP(ZF(e)),t):_A(e)?QF(fN([],YF()),t):EA(e)?qF():yA(e)?GF():wA(e)?KF():mA(e)?YN():bA(e)||hA(e)||CA(e)?qN(e):PP({})}function eI(e,t){return X($F(e,!0),t)}function tI(e,t){return oj(e)?UP(e.parameters,t):lN(t)}function nI(e,t){if(EA(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return yN([...new Set(n)].map(e=>qN(e)),{...t,[XA]:`Enum`})}var rI=class extends KA{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function iI(e){return e===Q.False?e:Q.True}function aI(e){throw new rI(e)}function oI(e){return bM(e)||uM(e)||IM(e)||RM(e)||Qj(e)}function sI(e,t){return bM(t)?TI(e,t):uM(t)?xI(e,t):IM(t)?cL(e,t):RM(t)?uL(e,t):Qj(t)?cI(e,t):aI(`StructuralRight`)}function cI(e,t){return Q.True}function lI(e,t){return uM(t)?xI(e,t):IM(t)&&t.anyOf.some(e=>Qj(e)||RM(e))?Q.True:IM(t)?Q.Union:RM(t)||Qj(t)?Q.True:Q.Union}function uI(e,t){return RM(e)?Q.False:Qj(e)?Q.Union:bM(e)?Q.True:Q.False}function dI(e,t){return wM(t)&&HI(t)?Q.True:oI(t)?sI(e,t):eM(t)?iI(mL(e.items,t.items)):Q.False}function fI(e,t){return oI(t)?sI(e,t):tM(t)?iI(mL(e.items,t.items)):Q.False}function pI(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):nM(t)?Q.True:Q.False}function mI(e,t){return hM(e)||rM(e)?Q.True:Q.False}function hI(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):rM(t)?Q.True:Q.False}function gI(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):aM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>iI(mL(t.parameters[n],e))===Q.True)?iI(mL(e.returns,t.returns)):Q.False:Q.False}function _I(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):oM(t)?Q.True:Q.False}function vI(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):sM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>iI(mL(t.parameters[n],e))===Q.True)?iI(mL(e.returns,t.returns)):Q.False:Q.False}function yI(e,t){return gM(e)&&bA(e.const)||CM(e)||cM(e)?Q.True:Q.False}function bI(e,t){return cM(t)||CM(t)?Q.True:oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):Q.False}function xI(e,t){return t.allOf.every(t=>mL(e,t)===Q.True)?Q.True:Q.False}function SI(e,t){return e.allOf.some(e=>mL(e,t)===Q.True)?Q.True:Q.False}function CI(e,t){return oI(t)?sI(e,t):dM(t)?iI(mL(e.items,t.items)):Q.False}function wI(e,t){return gM(t)&&t.const===e.const?Q.True:oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):kM(t)?$I(e,t):CM(t)?AI(e,t):cM(t)?yI(e,t):rM(t)?mI(e,t):Q.False}function TI(e,t){return Q.False}function EI(e,t){return Q.True}function DI(e){let[t,n]=[e,0];for(;xM(t);)t=t.not,n+=1;return n%2==0?t:YF()}function OI(e,t){return xM(e)?mL(DI(e),t):xM(t)?mL(e,DI(t)):aI(`Invalid fallthrough for Not`)}function kI(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):SM(t)?Q.True:Q.False}function AI(e,t){return mM(e)||CM(e)||cM(e)?Q.True:Q.False}function jI(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):cM(t)||CM(t)?Q.True:Q.False}function MI(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function NI(e){return HI(e)}function PI(e){return MI(e,0)||MI(e,1)&&`description`in e.properties&&IM(e.properties.description)&&e.properties.description.anyOf.length===2&&(kM(e.properties.description.anyOf[0])&&FM(e.properties.description.anyOf[1])||kM(e.properties.description.anyOf[1])&&FM(e.properties.description.anyOf[0]))}function FI(e){return MI(e,0)}function II(e){return MI(e,0)}function LI(e){return MI(e,0)}function RI(e){return MI(e,0)}function zI(e){return HI(e)}function BI(e){let t=XN();return MI(e,0)||MI(e,1)&&`length`in e.properties&&iI(mL(e.properties.length,t))===Q.True}function VI(e){return MI(e,0)}function HI(e){let t=XN();return MI(e,0)||MI(e,1)&&`length`in e.properties&&iI(mL(e.properties.length,t))===Q.True}function UI(e){let t=fN([nN()],nN());return MI(e,0)||MI(e,1)&&`then`in e.properties&&iI(mL(e.properties.then,t))===Q.True}function WI(e,t){return mL(e,t)===Q.False||Zj(e)&&!Zj(t)?Q.False:Q.True}function GI(e,t){return RM(e)?Q.False:Qj(e)?Q.Union:bM(e)||pM(e)&&NI(t)||mM(e)&&FI(t)||hM(e)&&II(t)||AM(e)&&PI(t)||nM(e)&&LI(t)||kM(e)&&NI(t)||AM(e)&&PI(t)||CM(e)&&FI(t)||cM(e)&&FI(t)||rM(e)&&II(t)||LM(e)&&zI(t)||oM(e)&&RI(t)||aM(e)&&VI(t)||sM(e)&&BI(t)?Q.True:EM(e)&&kM(JI(e))?t[XA]===`Record`?Q.True:Q.False:EM(e)&&CM(JI(e))&&MI(t,0)?Q.True:Q.False}function KI(e,t){return oI(t)?sI(e,t):EM(t)?XI(e,t):wM(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!Zj(t.properties[n]))return Q.False;if(Zj(t.properties[n]))return Q.True;if(WI(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function qI(e,t){return oI(t)?sI(e,t):wM(t)&&UI(t)?Q.True:TM(t)?iI(mL(e.item,t.item)):Q.False}function JI(e){return qM in e.patternProperties?XN():JM in e.patternProperties?ZN():aI(`Unknown record key pattern`)}function YI(e){return qM in e.patternProperties?e.patternProperties[qM]:JM in e.patternProperties?e.patternProperties[JM]:aI(`Unable to get record value schema`)}function XI(e,t){let[n,r]=[JI(t),YI(t)];return pM(e)&&CM(n)&&iI(mL(e,r))===Q.True?Q.True:LM(e)&&CM(n)||kM(e)&&CM(n)||eM(e)&&CM(n)?mL(e,r):wM(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(WI(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function ZI(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?mL(YI(e),YI(t)):Q.False}function QI(e,t){return mL(OM(e)?ZN():e,OM(t)?ZN():t)}function $I(e,t){return gM(e)&&CA(e.const)||kM(e)?Q.True:Q.False}function eL(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):kM(t)?Q.True:Q.False}function tL(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):AM(t)?Q.True:Q.False}function nL(e,t){return jM(e)?mL(oP(e),t):jM(t)?mL(e,oP(t)):aI(`Invalid fallthrough for TemplateLiteral`)}function rL(e,t){return eM(t)&&e.items!==void 0&&e.items.every(e=>mL(e,t.items)===Q.True)}function iL(e,t){return bM(e)?Q.True:RM(e)?Q.False:Qj(e)?Q.Union:Q.False}function aL(e,t){return oI(t)?sI(e,t):wM(t)&&HI(t)||eM(t)&&rL(e,t)?Q.True:PM(t)?EA(e.items)&&!EA(t.items)||!EA(e.items)&&EA(t.items)?Q.False:EA(e.items)&&!EA(t.items)||e.items.every((e,n)=>mL(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function oL(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):LM(t)?Q.True:Q.False}function sL(e,t){return oI(t)?sI(e,t):wM(t)?GI(e,t):EM(t)?XI(e,t):BM(t)?fL(e,t):FM(t)?Q.True:Q.False}function cL(e,t){return t.anyOf.some(t=>mL(e,t)===Q.True)?Q.True:Q.False}function lL(e,t){return e.anyOf.every(e=>mL(e,t)===Q.True)?Q.True:Q.False}function uL(e,t){return Q.True}function dL(e,t){return bM(t)?TI(e,t):uM(t)?xI(e,t):IM(t)?cL(e,t):Qj(t)?cI(e,t):kM(t)?$I(e,t):CM(t)?AI(e,t):cM(t)?yI(e,t):rM(t)?mI(e,t):eM(t)?uI(e,t):PM(t)?iL(e,t):wM(t)?GI(e,t):RM(t)?Q.True:Q.False}function fL(e,t){return FM(e)||FM(e)?Q.True:Q.False}function pL(e,t){return uM(t)?xI(e,t):IM(t)?cL(e,t):RM(t)?uL(e,t):Qj(t)?cI(e,t):wM(t)?GI(e,t):BM(t)?Q.True:Q.False}function mL(e,t){return jM(e)||jM(t)?nL(e,t):OM(e)||OM(t)?QI(e,t):xM(e)||xM(t)?OI(e,t):Qj(e)?lI(e,t):eM(e)?dI(e,t):nM(e)?pI(e,t):rM(e)?hI(e,t):tM(e)?fI(e,t):aM(e)?gI(e,t):oM(e)?_I(e,t):sM(e)?vI(e,t):cM(e)?bI(e,t):uM(e)?SI(e,t):dM(e)?CI(e,t):gM(e)?wI(e,t):bM(e)?EI(e,t):SM(e)?kI(e,t):CM(e)?jI(e,t):wM(e)?KI(e,t):EM(e)?ZI(e,t):kM(e)?eL(e,t):AM(e)?tL(e,t):PM(e)?aL(e,t):TM(e)?qI(e,t):LM(e)?oL(e,t):FM(e)?sL(e,t):IM(e)?lL(e,t):RM(e)?dL(e,t):BM(e)?pL(e,t):aI(`Unknown left type operand '${e[Z]}'`)}function hL(e,t){return mL(e,t)}function gL(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=bL(e[o],t,n,r,NA(i));return a}function _L(e,t,n,r,i){return gL(e.properties,t,n,r,i)}function vL(e,t,n,r,i){return uN(_L(e,t,n,r,i))}function yL(e,t,n,r){let i=hL(e,t);return i===Q.Union?yN([n,r]):i===Q.True?n:r}function bL(e,t,n,r,i){return gj(e)?vL(e,t,n,r,i):hj(e)?X(wL(e,t,n,r,i)):X(yL(e,t,n,r),i)}function xL(e,t,n,r,i){return{[e]:bL(qN(e),t,n,r,NA(i))}}function SL(e,t,n,r,i){return e.reduce((e,a)=>({...e,...xL(a,t,n,r,i)}),{})}function CL(e,t,n,r,i){return SL(e.keys,t,n,r,i)}function wL(e,t,n,r,i){return uN(CL(e,t,n,r,i))}function TL(e,t){return DL(oP(e),t)}function EL(e,t){let n=e.filter(e=>hL(e,t)===Q.False);return n.length===1?n[0]:yN(n)}function DL(e,t,n={}){return Oj(e)?X(TL(e,t),n):gj(e)?X(AL(e,t),n):X(Nj(e)?EL(e.anyOf,t):hL(e,t)===Q.False?e:lN(),n)}function OL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=DL(e[r],t);return n}function kL(e,t){return OL(e.properties,t)}function AL(e,t){return uN(kL(e,t))}function jL(e,t){return NL(oP(e),t)}function ML(e,t){let n=e.filter(e=>hL(e,t)!==Q.False);return n.length===1?n[0]:yN(n)}function NL(e,t,n){return Oj(e)?X(jL(e,t),n):gj(e)?X(IL(e,t),n):X(Nj(e)?ML(e.anyOf,t):hL(e,t)===Q.False?lN():e,n)}function PL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=NL(e[r],t);return n}function FL(e,t){return PL(e.properties,t)}function IL(e,t){return uN(FL(e,t))}function LL(e,t){return oj(e)?X(e.returns,t):lN(t)}function RL(e){return zP(rF(e))}function zL(e,t,n){return X({[Z]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function BL(e,t,n){let r={};for(let n of e)r[n]=t;return PP(r,{...n,[XA]:`Record`})}function VL(e,t,n){return zN(e)?BL(dP(e),t,n):zL(e.pattern,t,n)}function HL(e,t,n){return BL(dP(yN(e)),t,n)}function UL(e,t,n){return BL([e.toString()],t,n)}function WL(e,t,n){return zL(e.source,t,n)}function GL(e,t,n){return zL(EA(e.pattern)?JM:e.pattern,t,n)}function KL(e,t,n){return zL(JM,t,n)}function qL(e,t,n){return zL(YM,t,n)}function JL(e,t,n){return PP({true:t,false:t},n)}function YL(e,t,n){return zL(qM,t,n)}function XL(e,t,n){return zL(qM,t,n)}function ZL(e,t,n={}){return Nj(e)?HL(e.anyOf,t,n):Oj(e)?VL(e,t,n):mj(e)?UL(e.const,t,n):ij(e)?JL(e,t,n):lj(e)?YL(e,t,n):bj(e)?XL(e,t,n):Tj(e)?WL(e,t,n):Ej(e)?GL(e,t,n):$A(e)?KL(e,t,n):_j(e)?qL(e,t,n):lN(n)}function QL(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function $L(e){let t=QL(e);return t===JM?ZN():t===qM?XN():ZN({pattern:t})}function eR(e){return e.patternProperties[QL(e)]}function tR(e,t){return t.parameters=hR(e,t.parameters),t.returns=gR(e,t.returns),t}function nR(e,t){return t.parameters=hR(e,t.parameters),t.returns=gR(e,t.returns),t}function rR(e,t){return t.allOf=hR(e,t.allOf),t}function iR(e,t){return t.anyOf=hR(e,t.anyOf),t}function aR(e,t){return EA(t.items)||(t.items=hR(e,t.items)),t}function oR(e,t){return t.items=gR(e,t.items),t}function sR(e,t){return t.items=gR(e,t.items),t}function cR(e,t){return t.items=gR(e,t.items),t}function lR(e,t){return t.item=gR(e,t.item),t}function uR(e,t){let n=mR(e,t.properties);return{...t,...PP(n)}}function dR(e,t){let n=ZL(gR(e,$L(t)),gR(e,eR(t)));return{...t,...n}}function fR(e,t){return t.index in e?e[t.index]:YF()}function pR(e,t){let n=ZA(t),r=QA(t),i=gR(e,t);return n&&r?RL(i):n&&!r?zP(i):!n&&r?rF(i):i}function mR(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:pR(e,t[r])}),{})}function hR(e,t){return t.map(t=>gR(e,t))}function gR(e,t){return oj(t)?tR(e,t):cj(t)?nR(e,t):uj(t)?rR(e,t):Nj(t)?iR(e,t):jj(t)?aR(e,t):tj(t)?oR(e,t):nj(t)?sR(e,t):dj(t)?cR(e,t):Sj(t)?lR(e,t):xj(t)?uR(e,t):Cj(t)?dR(e,t):ej(t)?fR(e,t):t}function _R(e,t){return gR(t,PA(e))}function vR(e){return X({[Z]:`Integer`,type:`integer`},e)}function yR(e,t,n){return{[e]:AR(qN(e),t,NA(n))}}function bR(e,t,n){return e.reduce((e,r)=>({...e,...yR(r,t,n)}),{})}function xR(e,t,n){return bR(e.keys,t,n)}function SR(e,t,n){return uN(xR(e,t,n))}function CR(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function wR(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function TR(e){return e.toUpperCase()}function ER(e){return e.toLowerCase()}function DR(e,t,n){let r=NN(e.pattern);return RN(r)?sP([yN(kR([...GN(r)].map(e=>qN(e)),t))],n):{...e,pattern:OR(e.pattern,t)}}function OR(e,t){return typeof e==`string`?t===`Uncapitalize`?CR(e):t===`Capitalize`?wR(e):t===`Uppercase`?TR(e):t===`Lowercase`?ER(e):e:e.toString()}function kR(e,t){return e.map(e=>AR(e,t))}function AR(e,t,n={}){return hj(e)?SR(e,t,n):Oj(e)?DR(e,t,n):Nj(e)?yN(kR(e.anyOf,t),n):mj(e)?qN(OR(e.const,t),n):X(e,n)}function jR(e,t={}){return AR(e,`Capitalize`,t)}function MR(e,t={}){return AR(e,`Lowercase`,t)}function NR(e,t={}){return AR(e,`Uncapitalize`,t)}function PR(e,t={}){return AR(e,`Uppercase`,t)}function FR(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=GR(e[i],t,NA(n));return r}function IR(e,t,n){return FR(e.properties,t,n)}function LR(e,t,n){return uN(IR(e,t,n))}function RR(e,t){return e.map(e=>WR(e,t))}function zR(e,t){return e.map(e=>WR(e,t))}function BR(e,t){let{[t]:n,...r}=e;return r}function VR(e,t){return t.reduce((e,t)=>BR(e,t),e)}function HR(e,t,n){let r=cN(e,[qA,`$id`,`required`,`properties`]);return PP(VR(n,t),r)}function UR(e){return yN(e.reduce((e,t)=>pj(t)?[...e,qN(t)]:e,[]))}function WR(e,t){return uj(e)?pF(RR(e.allOf,t)):Nj(e)?yN(zR(e.anyOf,t)):xj(e)?HR(e,t,e.properties):PP({})}function GR(e,t,n){let r=pA(t)?UR(t):t,i=zj(t)?dP(t):t,a=wj(e),o=wj(t);return gj(e)?LR(e,i,n):hj(t)?YR(e,t,n):a&&o||!a&&o||a&&!o?oN(`Omit`,[e,r],n):X({...WR(e,i),...n})}function KR(e,t,n){return{[t]:GR(e,[t],NA(n))}}function qR(e,t,n){return t.reduce((t,r)=>({...t,...KR(e,r,n)}),{})}function JR(e,t,n){return qR(e,t.keys,n)}function YR(e,t,n){return uN(JR(e,t,n))}function XR(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=az(e[i],t,NA(n));return r}function ZR(e,t,n){return XR(e.properties,t,n)}function QR(e,t,n){return uN(ZR(e,t,n))}function $R(e,t){return e.map(e=>iz(e,t))}function ez(e,t){return e.map(e=>iz(e,t))}function tz(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function nz(e,t,n){let r=cN(e,[qA,`$id`,`required`,`properties`]);return PP(tz(n,t),r)}function rz(e){return yN(e.reduce((e,t)=>pj(t)?[...e,qN(t)]:e,[]))}function iz(e,t){return uj(e)?pF($R(e.allOf,t)):Nj(e)?yN(ez(e.anyOf,t)):xj(e)?nz(e,t,e.properties):PP({})}function az(e,t,n){let r=pA(t)?rz(t):t,i=zj(t)?dP(t):t,a=wj(e),o=wj(t);return gj(e)?QR(e,i,n):hj(t)?lz(e,t,n):a&&o||!a&&o||a&&!o?oN(`Pick`,[e,r],n):X({...iz(e,i),...n})}function oz(e,t,n){return{[t]:az(e,[t],NA(n))}}function sz(e,t,n){return t.reduce((t,r)=>({...t,...oz(e,r,n)}),{})}function cz(e,t,n){return sz(e,t.keys,n)}function lz(e,t,n){return uN(cz(e,t,n))}function uz(e,t){return oN(`Partial`,[oN(e,t)])}function dz(e){return oN(`Partial`,[mF(e)])}function fz(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=rF(e[n]);return t}function pz(e,t){let n=cN(e,[qA,`$id`,`required`,`properties`]);return PP(fz(t),n)}function mz(e){return e.map(e=>hz(e))}function hz(e){return aj(e)?uz(e.target,e.parameters):wj(e)?dz(e.$ref):uj(e)?pF(mz(e.allOf)):Nj(e)?yN(mz(e.anyOf)):xj(e)?pz(e,e.properties):rj(e)||ij(e)||lj(e)||mj(e)||yj(e)||bj(e)||Ej(e)||Dj(e)||Mj(e)?e:PP({})}function gz(e,t){return gj(e)?yz(e,t):X({...hz(e),...t})}function _z(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=gz(e[r],NA(t));return n}function vz(e,t){return _z(e.properties,t)}function yz(e,t){return uN(vz(e,t))}function bz(e,t){return oN(`Required`,[oN(e,t)])}function xz(e){return oN(`Required`,[mF(e)])}function Sz(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=cN(e[n],[YA]);return t}function Cz(e,t){let n=cN(e,[qA,`$id`,`required`,`properties`]);return PP(Sz(t),n)}function wz(e){return e.map(e=>Tz(e))}function Tz(e){return aj(e)?bz(e.target,e.parameters):wj(e)?xz(e.$ref):uj(e)?pF(wz(e.allOf)):Nj(e)?yN(wz(e.anyOf)):xj(e)?Cz(e,e.properties):rj(e)||ij(e)||lj(e)||mj(e)||yj(e)||bj(e)||Ej(e)||Dj(e)||Mj(e)?e:PP({})}function Ez(e,t){return gj(e)?kz(e,t):X({...Tz(e),...t})}function Dz(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Ez(e[r],t);return n}function Oz(e,t){return Dz(e.properties,t)}function kz(e,t){return uN(Oz(e,t))}function Az(e,t){return t.map(t=>wj(t)?jz(e,t.$ref):Qz(e,t))}function jz(e,t){return t in e?wj(e[t])?jz(e,e[t].$ref):Qz(e,e[t]):lN()}function Mz(e){return xF(e[0])}function Nz(e){return EP(e[0],e[1])}function Pz(e){return FF(e[0])}function Fz(e){return gz(e[0])}function Iz(e){return GR(e[0],e[1])}function Lz(e){return az(e[0],e[1])}function Rz(e){return Ez(e[0])}function zz(e,t,n){let r=Az(e,n);return t===`Awaited`?Mz(r):t===`Index`?Nz(r):t===`KeyOf`?Pz(r):t===`Partial`?Fz(r):t===`Omit`?Iz(r):t===`Pick`?Lz(r):t===`Required`?Rz(r):lN()}function Bz(e,t){return rN(Qz(e,t))}function Vz(e,t){return aN(Qz(e,t))}function Hz(e,t,n){return dN(Zz(e,t),Qz(e,n))}function Uz(e,t,n){return fN(Zz(e,t),Qz(e,n))}function Wz(e,t){return pF(Zz(e,t))}function Gz(e,t){return jP(Qz(e,t))}function Kz(e,t){return PP(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:Qz(e,t[r])}),{}))}function qz(e,t){let[n,r]=[Qz(e,eR(t)),QL(t)],i=PA(t);return i.patternProperties[r]=n,i}function Jz(e,t){return wj(t)?{...jz(e,t.$ref),[qA]:t[qA]}:t}function Yz(e,t){return UP(Zz(e,t))}function Xz(e,t){return yN(Zz(e,t))}function Zz(e,t){return t.map(t=>Qz(e,t))}function Qz(e,t){return QA(t)?X(Qz(e,cN(t,[YA])),t):ZA(t)?X(Qz(e,cN(t,[JA])),t):Aj(t)?X(Jz(e,t),t):tj(t)?X(Bz(e,t.items),t):nj(t)?X(Vz(e,t.items),t):aj(t)?X(zz(e,t.target,t.parameters)):oj(t)?X(Hz(e,t.parameters,t.returns),t):cj(t)?X(Uz(e,t.parameters,t.returns),t):uj(t)?X(Wz(e,t.allOf),t):dj(t)?X(Gz(e,t.items),t):xj(t)?X(Kz(e,t.properties),t):Cj(t)?X(qz(e,t)):jj(t)?X(Yz(e,t.items||[]),t):Nj(t)?X(Xz(e,t.anyOf),t):t}function $z(e,t){return t in e?Qz(e,e[t]):lN()}function eB(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:$z(e,n)}),{})}var tB=class{constructor(e){let t=eB(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:X(this.$defs[e],t)};return X({[Z]:`Import`,$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}};function nB(e){return new tB(e)}function rB(e,t){return X({[Z]:`Not`,not:e},t)}function iB(e,t){return cj(e)?UP(e.parameters,t):lN()}var aB=0;function oB(e,t={}){EA(t.$id)&&(t.$id=`T${aB++}`);let n=PA(e({[Z]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,X({[XA]:`Recursive`,...n},t)}function sB(e,t){let n=CA(e)?new globalThis.RegExp(e):e;return X({[Z]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function cB(e){return uj(e)?e.allOf:Nj(e)?e.anyOf:jj(e)?e.items??[]:[]}function lB(e){return cB(e)}function uB(e,t){return cj(e)?X(e.returns,t):lN(t)}var dB=class{constructor(e){this.schema=e}Decode(e){return new fB(this.schema,e)}},fB=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[qA].Encode(e(n)),Decode:e=>this.decode(t[qA].Decode(e))};return{...t,[qA]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[qA]:n}}Encode(e){return Aj(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function pB(e){return new dB(e)}function mB(e={}){return X({[Z]:e[Z]??`Unsafe`},e)}function hB(e){return X({[Z]:`Void`,type:`void`},e)}var $=t({Any:()=>nN,Argument:()=>iN,Array:()=>rN,AsyncIterator:()=>aN,Awaited:()=>xF,BigInt:()=>YN,Boolean:()=>JN,Capitalize:()=>jR,Composite:()=>UF,Const:()=>eI,Constructor:()=>dN,ConstructorParameters:()=>tI,Date:()=>WF,Enum:()=>nI,Exclude:()=>DL,Extends:()=>bL,Extract:()=>NL,Function:()=>fN,Index:()=>EP,InstanceType:()=>LL,Instantiate:()=>_R,Integer:()=>vR,Intersect:()=>pF,Iterator:()=>jP,KeyOf:()=>FF,Literal:()=>qN,Lowercase:()=>MR,Mapped:()=>$P,Module:()=>nB,Never:()=>lN,Not:()=>rB,Null:()=>GF,Number:()=>XN,Object:()=>PP,Omit:()=>GR,Optional:()=>rF,Parameters:()=>iB,Partial:()=>gz,Pick:()=>az,Promise:()=>FP,Readonly:()=>zP,ReadonlyOptional:()=>RL,Record:()=>ZL,Recursive:()=>oB,Ref:()=>mF,RegExp:()=>sB,Required:()=>Ez,Rest:()=>lB,ReturnType:()=>uB,String:()=>ZN,Symbol:()=>KF,TemplateLiteral:()=>sP,Transform:()=>pB,Tuple:()=>UP,Uint8Array:()=>JF,Uncapitalize:()=>NR,Undefined:()=>qF,Union:()=>yN,Unknown:()=>YF,Unsafe:()=>mB,Uppercase:()=>PR,Void:()=>hB}),gB={additionalProperties:!1},_B=$.String({pattern:`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,minLength:36,maxLength:36}),vB=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),yB=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),bB=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),xB=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),SB=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,CB=`^(?:${SB}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,wB=$.String({pattern:CB,minLength:8,maxLength:36}),TB=new RegExp(CB),EB=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/;function DB(e){return typeof e!=`string`||e.length>36?!1:TB.test(e)}function OB(e){if(typeof e!=`string`)return;if(EB.test(e)){let t=e.toLowerCase();return DB(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(DB(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:_B,code:wB,deviceUid:_B,deviceName:$.String({minLength:1,maxLength:64}),hostname:$.Optional($.String({minLength:1,maxLength:128})),platform:$.Optional($.String({minLength:1,maxLength:64})),publicKey:$.String({minLength:1,maxLength:256}),keyFingerprint:yB,clientTime:$.Integer(),hubNonce:$.Optional(bB)},gB),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:_B,deviceUid:_B,deviceName:$.String({minLength:1,maxLength:64}),hostname:$.Optional($.String({minLength:1,maxLength:128})),platform:$.Optional($.String({minLength:1,maxLength:64})),publicKey:$.String({minLength:1,maxLength:256}),keyFingerprint:yB,clientTime:$.Integer(),hubNonce:$.Optional(bB)},gB);var kB=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:_B,nonce:bB,issuedAt:$.Integer(),hubId:_B,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(yB),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},gB);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:_B,code:wB,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:_B,challenge:kB},gB),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:_B,nonce:bB,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},gB),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:_B,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},gB),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:_B,deviceUid:_B,deviceId:vB,pairingEpoch:_B,credentialId:_B,generation:$.Integer({minimum:1}),hubId:_B,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:xB,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(yB)},gB),$.Object({enrollmentId:_B,deviceUid:_B,keyFingerprint:yB,replaceKey:$.Optional($.Boolean())},gB),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:vB,pairingEpoch:_B,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},gB);var AB=$.Object({type:$.Literal(`pair.error`),v:$.Literal(1),code:$.Union([$.Literal(`code_invalid`),$.Literal(`code_expired`),$.Literal(`code_used`),$.Literal(`code_in_use`),$.Literal(`rate_limited`),$.Literal(`signature_invalid`),$.Literal(`clock_skew`),$.Literal(`paired_elsewhere`),$.Literal(`hub_required`),$.Literal(`fingerprint_mismatch`),$.Literal(`identity_conflict`),$.Literal(`enrollment_lost`),$.Literal(`enrollment_cancelled`),$.Literal(`already_issued`),$.Literal(`challenge_expired`)]),message:$.String({maxLength:512}),retryAfterMs:$.Optional($.Integer({minimum:1}))},gB);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:_B,code:wB,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},gB);var jB=$.Union([$.Literal(`open`),$.Literal(`awaiting_proof`),$.Literal(`awaiting_approval`),$.Literal(`approved`),$.Literal(`issued`),$.Literal(`connected`),$.Literal(`cancelled`),$.Literal(`expired`)]);$.Object({type:$.Literal(`pair.code-state`),v:$.Literal(1),codeId:_B,expiresAt:$.Integer(),phase:jB,enrollment:$.Optional($.Object({enrollmentId:_B,deviceUid:_B,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:yB,proofVerified:$.Boolean(),keyChanged:$.Boolean()},gB)),deviceId:$.Optional(vB),error:$.Optional(AB)},gB);function MB(e){if(typeof e!=`string`||e.length===0||e.length>2048)return{ok:!1,error:`origin: empty or too long`};if(/\s|\n|\r|\t/.test(e))return{ok:!1,error:`origin: whitespace not allowed`};let t;try{t=new URL(e)}catch{return{ok:!1,error:`origin: not a valid URL`}}return t.protocol!==`https:`&&!(t.protocol===`http:`&&/^(127\.0\.0\.1|\[::1\]|localhost)$/.test(t.hostname))?{ok:!1,error:`origin: HTTPS origin required`}:t.username||t.password?{ok:!1,error:`origin: userinfo not allowed`}:t.search||t.hash?{ok:!1,error:`origin: query/fragment not allowed`}:t.pathname!==`/`&&t.pathname!==``?{ok:!1,error:`origin: base path not allowed`}:{ok:!0,origin:t.origin,tunnelUrl:`${t.origin}/api/tunnel`}}function NB(e){if(e!==``&&/^[A-Za-z0-9_-]+$/.test(e))try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return}}var PB=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,FB=RegExp(`^${SB}$`),IB=/^sha256:[0-9a-f]{64}$/;function LB(e){let t=NB(e);if(!t||t.length>1024)return;let n;try{n=JSON.parse(new TextDecoder().decode(t))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(r.v!==2&&r.v!==3)return;let i=r.v===3?6:5;if(Object.keys(r).length!==i||typeof r.hub!=`string`)return;let a=MB(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&PB.test(r.id)&&typeof r.code==`string`&&FB.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!IB.test(r.kfp)?void 0:{v:3,hub:r.hub,id:r.id,code:r.code,exp:r.exp,kfp:r.kfp}:{v:2,hub:r.hub,id:r.id,code:r.code,exp:r.exp}}function RB(e,t=Date.now()){let n=LB(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function zB(e,t=Date.now()){let n;try{n=new URL(e)}catch{return}if(!/^\/pair\/?$/.test(n.pathname)||n.username||n.password||n.search||!n.hash.startsWith(`#offer=`))return;let r=RB(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function BB(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=zB(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=RB(e.hash.slice(7));return n&&n.hub!==e.origin?{error:`This pairing link does not belong to this hub. Open the original hub link instead.`}:{error:`Invalid pairing link. Use a complete link from the hub wizard.`}}let t=e.searchParams;if(!t.has(`code`)&&!t.has(`origin`)&&!t.has(`v`))return;let n=t.get(`code`),r=n===null?void 0:OB(n);if(e.username||e.password||e.hash||t.getAll(`code`).length!==1||!r||t.getAll(`v`).length!==1||t.get(`v`)!==`1`)return{error:`Invalid pairing link. Use a complete version 1 link from the hub wizard.`};if(t.has(`origin`))try{let n=new URL(t.get(`origin`));if(t.getAll(`origin`).length!==1||n.origin!==e.origin||n.pathname!==`/`||n.username||n.password||n.search||n.hash)throw Error(`origin mismatch`)}catch{return{error:`This pairing link does not belong to this hub. Open the original hub link instead.`}}return{code:r,origin:e.origin}}var VB=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,HB=e=>/^\/pair\/?$/.test(e.pathname)&&BB(e)===void 0?`/`:void 0,UB=4e3;async function WB(e){if(!e.needsCancel)return{closed:!0,confirmed:!0};let t,n=await Promise.race([e.cancel().catch(()=>`failed`),new Promise(n=>t=setTimeout(()=>n(`failed`),e.timeoutMs))]);return clearTimeout(t),{closed:n!==`issued`,confirmed:n===`cancelled`}}var GB={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},KB={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},qB={class:`who`},JB={key:0,class:`muted`},YB={key:1,class:`muted`},XB={class:`fp`},ZB={class:`row`},QB={class:`phase`},$B=[`onClick`],eV={key:2,class:`hint`},tV={class:`pair-steps`,"aria-label":`Pairing progress`},nV={class:`pair-grid`},rV={class:`pair-code-box`},iV={class:`pair-code`,"aria-label":`Pairing code`},aV={class:`pair-copy-actions`},oV=[`innerHTML`],sV={class:`pair-side`},cV={key:0,class:`hint`},lV={class:`pair-fingerprint`},uV={class:`fp`},dV={class:`pair-confirm`},fV={key:0,class:`pair-confirm warn`},pV=[`disabled`],mV=[`disabled`],hV={class:`hint`},gV=[`disabled`],_V={key:5,class:`error`,role:`alert`},vV={key:4},yV={class:`error`,role:`alert`},bV=N({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=k(`boot`),o=k(),s=k(),c=k(),l=k(``),u=k(!1),d=k(!1),f=k(!1),p=k(!1),m=k(!1),h=k(!1),g=k(),_=k([]),v=U(()=>{let e=s.value?.code??``;return!DB(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=U(()=>s.value?nb(s.value):``),b=U(()=>y.value?iA(y.value,148):``),x=U(()=>c.value?.enrollment?.keyFingerprint??``),S=U(()=>c.value?.deviceId??``);M(S,e=>{g.value?.(),e&&(g.value=M(()=>wu.devices.value.find(t=>t.id===e)?.status,e=>{e===`online`&&(Y(`Device paired and online.`),g.value?.(),g.value=void 0)},{immediate:!0}))});async function C(e){a.value=`boot`,l.value=``,f.value=!1,p.value=!1,c.value=void 0,s.value=void 0,o.value?.close();let t=ab();o.value=t;try{let n=e?await rb.resolveCode(e):await rb.createCode();if(t.closed()){await rb.cancel(n.codeId).catch(()=>{Y(`The late pairing code could not be cancelled. Check device credentials before retrying.`)});return}if(s.value=n,a.value=`code`,e){let e=VB(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}cb(t,n.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{t.closed()||(l.value=e instanceof Error?e.message:String(e),a.value=`expired`)})}catch(e){l.value=e instanceof Error?e.message:String(e),a.value=`expired`}}async function ee(){let e=c.value,t=o.value;if(e?.enrollment&&t&&!u.value){u.value=!0,l.value=``;try{let t=await rb.approve(s.value.codeId,{enrollmentId:e.enrollment.enrollmentId,deviceUid:e.enrollment.deviceUid,keyFingerprint:e.enrollment.keyFingerprint,...p.value?{replaceKey:!0}:{}});c.value=t,(t.phase===`issued`||t.phase===`connected`)&&(a.value=`issued`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function w(e){if(!s.value)return`cancelled`;try{let t=await rb.cancel(s.value.codeId,void 0,e);return c.value=t,o.value&&(o.value.state=t),a.value=t.phase===`expired`?`expired`:`cancelled`,o.value?.close(),`cancelled`}catch(e){if(e instanceof Sl&&e.status===409&&String(e.code)===`already_issued`){let e=await rb.codeState(s.value.codeId).catch(()=>void 0);return e&&(c.value=e,o.value&&(o.value.state=e)),a.value=`issued`,l.value=`Credential already issued. Closing does not revoke it; choose Revoke explicitly if needed.`,`issued`}return l.value=e instanceof Error?e.message:String(e),`failed`}}let T=()=>w(!1),te=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function ne(){let e=S.value;if(e){u.value=!0;try{await rb.revoke(e,`user`),Y(`Issued credential revoked.`),r(`close`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function re(){if(s.value)try{await navigator.clipboard.writeText(s.value.code),m.value=!0,setTimeout(()=>m.value=!1,1500)}catch{l.value=`Clipboard unavailable; copy the code manually.`}}async function ie(){if(s.value)try{await navigator.clipboard.writeText(s.value.offerUrl??s.value.pairUrl),h.value=!0,setTimeout(()=>h.value=!1,1500)}catch{l.value=`Clipboard unavailable; copy the link manually.`}}async function ae(){if(!d.value){d.value=!0,u.value=!0;try{let e=await WB({needsCancel:!!s.value&&!te(),cancel:T,timeoutMs:UB});if(!e.closed)return;o.value?.close(),g.value?.(),e.confirmed||Y(`Pairing cancellation was not confirmed. The code expires on its own; check device credentials before retrying.`),r(`close`)}finally{d.value=!1,u.value=!1}}}t({close:ae});let oe;async function se(){try{_.value=(await rb.pending()).codes}catch{}}async function ce(e){s.value=void 0,c.value=void 0,l.value=``;let t=ab();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,cb(t,e.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{l.value=e instanceof Error?e.message:String(e)})}return Vr(()=>{if(se(),oe=setInterval(()=>void se(),3e3),i.handoff&&`error`in i.handoff){l.value=i.handoff.error,a.value=`expired`;return}C(i.handoff?.code)}),Wr(()=>{clearInterval(oe);let e=o.value;e&&!e.closed()&&s.value&&!te()&&w(!0).then(e=>{e!==`cancelled`&&Y(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:ks(ae,[`self`])},[z(`div`,GB,[z(`header`,null,[t[5]||=z(`h2`,{id:`pair-title`},`Pair a device`,-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:ae},[B(A(xl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(I(),R(dA,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):H(``,!0),_.value.length?(I(),L(`section`,KB,[t[6]||=z(`h3`,null,`Machines waiting for you`,-1),z(`ul`,null,[(I(!0),L(F,null,P(_.value,e=>(I(),L(`li`,{key:e.codeId},[z(`div`,qB,[z(`strong`,null,D(e.deviceName??`unnamed device`),1),e.hostname?(I(),L(`span`,JB,D(e.hostname),1)):H(``,!0),e.platform?(I(),L(`span`,YB,D(e.platform),1)):H(``,!0)]),z(`div`,XB,D(e.keyFingerprint),1),z(`div`,ZB,[z(`span`,QB,D(e.phase.replaceAll(`_`,` `)),1),z(`button`,{type:`button`,class:`small`,onClick:t=>ce(e)},`Review`,8,$B)])]))),128))]),t[7]||=z(`p`,{class:`hint`},` Compare each fingerprint with the machine's own terminal before approving. Codes are minted by the hub — nothing has to be copied to the machine. `,-1)])):H(``,!0),a.value===`boot`?(I(),L(`p`,eV,`Minting a pairing code…`)):s.value?(I(),L(F,{key:3},[z(`ol`,tV,[t[8]||=z(`li`,{class:E({on:!0})},`Code`,-1),z(`li`,{class:E({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),z(`li`,{class:E({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),z(`li`,{class:E({on:a.value===`issued`})},`Online`,2)]),z(`div`,nV,[z(`div`,rV,[z(`div`,iV,D(v.value),1),z(`div`,aV,[z(`button`,{type:`button`,class:`small`,onClick:re},[B(A(sc),{size:14}),V(` `+D(m.value?`Copied`:`Copy code`),1)]),z(`button`,{type:`button`,class:`small`,onClick:ie,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[B(A(sc),{size:14}),V(` `+D(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=z(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),z(`div`,{class:`pair-qr`,"aria-label":`Pairing QR code`,title:`Same offer link as Copy link: hub, code and expiry all in the #offer= fragment — it never reaches server logs`,innerHTML:b.value},null,8,oV)]),z(`div`,sV,[a.value===`code`||a.value===`proof`?(I(),L(`p`,cV,[B(A($c),{size:14,class:`spin`}),t[10]||=V(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(I(),L(F,{key:1},[z(`div`,lV,[t[11]||=z(`h3`,null,`Device key fingerprint`,-1),z(`code`,uV,D(x.value),1),t[12]||=z(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),z(`label`,dV,[j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[bs,f.value]]),t[13]||=V(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(I(),L(`label`,fV,[j(z(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[bs,p.value]]),B(A(ol),{size:14}),t[14]||=V(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):H(``,!0),z(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:ee},` Approve device `,8,pV),z(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:T},` Cancel pairing `,8,mV)],64)):a.value===`issued`?(I(),L(F,{key:2},[z(`p`,hV,[B(A(ic),{size:14}),t[15]||=V(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),z(`button`,{type:`button`,class:`small`,onClick:ae},`Close`),z(`button`,{type:`button`,class:`small danger`,disabled:!S.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:ne},` Revoke this credential `,8,gV)],64)):a.value===`cancelled`?(I(),L(F,{key:3},[t[16]||=z(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>C()},`Start over`)],64)):a.value===`expired`?(I(),L(F,{key:4},[t[17]||=z(`p`,{class:`hint`},`The pairing code expired.`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>C()},`New code`)],64)):H(``,!0),l.value?(I(),L(`p`,_V,D(l.value),1)):H(``,!0)])])],64)):(I(),L(`div`,vV,[z(`p`,yV,D(l.value||`This pairing link is unavailable.`),1),z(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>C()},`New code`)]))])]))}}),xV={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},SV={class:`hint`},CV={key:1,class:`hint`},wV=N({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>wu.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>r(`close`),[`self`])},[z(`section`,xV,[z(`header`,null,[t[3]||=z(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[B(A(xl),{size:18})])]),i.value?(I(),L(F,{key:0},[z(`p`,null,[V(D(i.value.name)+` `,1),z(`code`,null,D(i.value.id),1)]),z(`p`,SV,D(i.value.status)+` · tunnel `+D(i.value.tunnel?.state??`disconnected`)+` · `+D(i.value.tunnel?.readerCount??0)+` readers `,1),B(_b,{device:i.value},null,8,[`device`])],64)):(I(),L(`p`,CV,`This device is no longer in the registry.`)),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),TV={id:`prompt-title`},EV=[`disabled`],DV={key:0,class:`hint`},OV={key:1},kV={key:0,class:`muted`},AV=[`placeholder`,`disabled`],jV=[`required`,`placeholder`,`aria-label`,`disabled`],MV={key:2,class:`message-error`,role:`alert`},NV=[`disabled`],PV=[`disabled`],FV=N({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=k(r.dialog.value??``),o=k(!1),s=k(``),c=k(),l=!!r.dialog.label;async function u(){if(!o.value&&(!l||r.dialog.optional||a.value.trim())){o.value=!0,s.value=``;try{await r.dialog.run(a.value.trim()),i(`close`)}catch(e){s.value=K(e)}finally{o.value=!1}}}return Vr(()=>void An(()=>(c.value?.focus(),c.value?.select()))),t({busy:o}),(t,n)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:n[4]||=ks(e=>!o.value&&i(`close`),[`self`])},[z(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:ks(u,[`prevent`])},[z(`header`,null,[z(`h2`,TV,D(e.dialog.title),1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:o.value,onClick:n[0]||=e=>i(`close`)},[B(A(xl),{size:18})],8,EV)]),e.dialog.hint?(I(),L(`p`,DV,D(e.dialog.hint),1)):H(``,!0),l?(I(),L(`label`,OV,[V(D(e.dialog.label)+` `,1),e.dialog.optional?(I(),L(`span`,kV,`(optional)`)):H(``,!0),e.dialog.multiline?j((I(),L(`textarea`,{key:1,ref_key:`input`,ref:c,"onUpdate:modelValue":n[1]||=e=>a.value=e,rows:`4`,placeholder:e.dialog.placeholder,disabled:o.value},null,8,AV)),[[ys,a.value]]):j((I(),L(`input`,{key:2,ref_key:`input`,ref:c,"onUpdate:modelValue":n[2]||=e=>a.value=e,maxlength:`100`,required:!e.dialog.optional,placeholder:e.dialog.placeholder,"aria-label":e.dialog.label,disabled:o.value},null,8,jV)),[[ys,a.value]])])):H(``,!0),s.value?(I(),L(`p`,MV,D(s.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,disabled:o.value,onClick:n[3]||=e=>i(`close`)},` Cancel `,8,NV),z(`button`,{class:E([`primary`,{danger:e.dialog.danger}]),disabled:o.value||l&&!e.dialog.optional&&!a.value.trim()},D(o.value?`Working…`:e.dialog.submit),11,PV)])],32)]))}}),IV={class:`modal model-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Model picker`},LV={class:`eyebrow`},RV={class:`model-list`},zV={key:0,class:`model-row off-catalog`,"aria-disabled":`true`},BV=[`src`],VV=[`onClick`],HV=[`src`],UV={class:`hint`},WV=N({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=k(``),i=k();Vr(()=>void An(()=>i.value?.focus()));let a=U(()=>Ju.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),o=e=>{let t=nd.value;return!!t&&e.id===t.modelId&&e.provider===t.provider},s=U(()=>{let e=nd.value;return e&&!Ju.value.some(t=>t.provider===e.provider&&t.id===e.modelId)?e:void 0});async function c(e){await dd(()=>zu.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await od(),Y(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>n(`close`),[`self`])},[z(`section`,IV,[z(`header`,null,[z(`div`,null,[z(`span`,LV,`PER AGENT · `+D(A(Mu)?.name??A(Mu)?.id),1),t[3]||=z(`h2`,null,`Choose a model`,-1)]),z(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[B(A(xl),{size:18})])]),j(z(`input`,{ref_key:`searchInput`,ref:i,"onUpdate:modelValue":t[1]||=e=>r.value=e,placeholder:`Search models or tiers…`,"aria-label":`Search models`},null,512),[[ys,r.value]]),z(`div`,RV,[s.value?(I(),L(`div`,zV,[z(`img`,{src:A(hd)(s.value.modelId),alt:``},null,8,BV),z(`div`,null,[z(`strong`,null,D(s.value.modelId),1),z(`small`,null,D(s.value.provider)+` / current · not in this device's catalog`,1)])])):H(``,!0),(I(!0),L(F,null,P(a.value,e=>(I(),L(`button`,{key:`${e.provider}/${e.id}`,class:E({selected:o(e)}),onClick:t=>c(e)},[z(`img`,{src:A(hd)(e.id),alt:``},null,8,HV),z(`div`,null,[z(`strong`,null,D(e.name),1),z(`small`,null,D(e.tier)+` / `+D(e.provider)+` / `+D(A(pd)(e.contextWindow))+` context`,1)]),o(e)?(I(),R(A(tc),{key:0,size:18})):H(``,!0)],10,VV))),128))]),z(`p`,UV,`Models available on `+D(A(Mu)?.id)+`. Provider keys stay on the device.`,1)])]))}}),GV={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},KV={class:`dialog-head`},qV={class:`dialog-body`},JV={class:`n`},YV={class:`body`},XV={class:`help-callout`},ZV={class:`dialog-foot`},QV={class:`right`},$V=N({__name:`HelpDialog`,setup(e){let t=[{title:`Pick a device, start a session`,body:`Every device in the tree runs dpi-backend. A session gets its own SQLite database on that device, in the directory you choose.`},{title:`Send work, then close the browser`,body:`The device owns the run. Reopening restores committed messages, state and live progress.`},{title:`Change state and fork`,body:`Edit App State by hand or through the agent. Every session and fork on a device shares it.`},{title:`Interrupt deliberately`,body:`Interrupt stops foreground work and owned subagents. Background jobs continue. Stop all includes them.`},{title:`Explore the boundaries`,body:`Queue a follow-up, steer after tools, wait for approval, compact context, reset or inspect raw state.`},{title:`Restart a device`,body:`Its tree dims and shows the restart command. Checkpointed jobs recover on boot. Replay-safe tools may rerun. Other interrupted tools return an error.`}];return(e,n)=>(I(),L(`div`,{class:`scrim`,onClick:n[2]||=ks(e=>A(J).dialog=void 0,[`self`])},[z(`section`,GV,[z(`div`,KV,[n[3]||=z(`div`,null,[z(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),z(`h3`,{id:`help-title`},`What makes this durable?`)],-1),z(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>A(J).dialog=void 0},[B(A(xl),{size:18})])]),z(`div`,qV,[(I(),L(F,null,P(t,(e,t)=>z(`div`,{key:e.title,class:`help-step`},[z(`span`,JV,D(String(t+1).padStart(2,`0`)),1),z(`div`,null,[z(`b`,null,D(e.title),1),z(`div`,YV,D(e.body),1)])])),64)),z(`div`,XV,[B(A(Oc),{size:18}),n[4]||=z(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),z(`div`,ZV,[z(`div`,QV,[z(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>A(J).dialog=void 0},`Close`)])])])]))}}),eH=Wt({needed:!1,busy:!1,error:``}),tH=new Set,nH=e=>{let t=[...tH];tH=new Set;for(let n of t)n(e)},rH=()=>new Promise(e=>tH.add(e));async function iH(e){if(eH.busy||!e)return!1;eH.busy=!0,eH.error=``;try{let t=await fetch(`/api/session`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})});return await t.text().catch(()=>``),t.ok?(eH.needed=!1,nH(!0),!0):(eH.error=t.status===401?`That token was not accepted.`:t.status===429?`Too many attempts. Wait a minute and try again.`:`Login failed (${t.status}).`,!1)}catch{return eH.error=`Cannot reach the hub.`,!1}finally{eH.busy=!1}}var aH=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function oH(e){return(async(t,n)=>{let r=()=>e(t,n),i=await r();if(i.status!==401||aH(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;eH.needed=!0;let a=await i.text().catch(()=>``);return await rH()?r():new Response(a,{status:i.status,headers:i.headers})})}function sH(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=oH(window.fetch.bind(window)))}var cH={class:`login-veil`,"data-testid":`login-card`},lH=[`disabled`],uH={key:0,class:`message-error`,role:`alert`},dH=[`disabled`],fH=N({__name:`LoginCard`,setup(e){let t=k(``),n=k();async function r(){if(eH.busy||!t.value.trim())return;let e=await iH(t.value.trim());t.value=``,e&&n.value?.blur()}return Vr(()=>void An(()=>n.value?.focus())),(e,i)=>(I(),L(`div`,cH,[z(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:ks(r,[`prevent`])},[i[2]||=z(`header`,null,[z(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=z(`p`,{class:`hint`},[V(` This hub is locked. Sign in with the token from its `),z(`code`,null,`admin.token`),V(` file. `)],-1),i[4]||=z(`label`,{for:`admin-token`},`Admin token`,-1),j(z(`input`,{id:`admin-token`,ref_key:`input`,ref:n,"onUpdate:modelValue":i[0]||=e=>t.value=e,type:`password`,name:`admin-token`,autocomplete:`off`,spellcheck:`false`,placeholder:`adm_…`,"aria-label":`Admin token`,disabled:A(eH).busy,onKeydown:i[1]||=js(e=>A(eH).error=``,[`esc`])},null,40,lH),[[ys,t.value]]),A(eH).error?(I(),L(`p`,uH,D(A(eH).error),1)):H(``,!0),z(`footer`,null,[z(`button`,{class:`primary`,type:`submit`,disabled:A(eH).busy||!t.value.trim()},D(A(eH).busy?`Checking…`:`Sign in`),9,dH)])],32)]))}}),pH={key:0,class:`toast`,role:`status`},mH=N({__name:`Toast`,setup(e){return(e,t)=>(I(),R(bo,{name:`toast`},{default:Hn(()=>[A(J).toast?(I(),L(`div`,pH,[B(A(tc),{size:18}),V(D(A(J).toast),1)])):H(``,!0)]),_:1}))}});function hH(e,t=!1){return e.kind===`pair`?`pair`:e.kind===`prompt`&&t?`keep`:`close`}var gH={class:`shell`,"data-testid":`app-shell`},_H={key:0,class:`error-banner`,role:`alert`},vH={key:4,class:`welcome`,"data-testid":`welcome-empty`},yH=[`disabled`],bH={class:`welcome-features`},xH={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},SH={class:`full-directory`},CH=N({__name:`App`,setup(e){let t=()=>wu.devices.value.filter(e=>e.status===`online`).length,n=k(),r=k();function i(){J.dialog={kind:`new-session`,deviceId:q.value?.deviceId}}function a(e){let t=J.dialog?void 0:Od(e);if(t)return e.preventDefault(),t===`tree`?wd():Td();if(e.key===`Escape`){if(J.dialog){let e=hH(J.dialog,r.value?.busy??!1);e===`pair`?n.value?.close():e===`close`&&(J.dialog=void 0);return}!e.repeat&&!e.isComposing&&$u.value&&(e.preventDefault(),vd()),J.drawer=!1,J.inspectorOverlay=!1}}function o(e){let t=e.clientX,n=Ou.value,r=e=>Ou.value=Math.max(220,Math.min(560,n+e.clientX-t)),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}return Vr(()=>cf()),Vr(()=>{document.addEventListener(`keydown`,a),Ku()}),Wr(()=>{Su.stop(),document.removeEventListener(`keydown`,a)}),(e,a)=>(I(),L(`div`,gH,[B(Ud,{onNewSession:i}),A(J).error?(I(),L(`div`,_H,[B(A(Oc),{size:18}),z(`span`,null,D(A(J).error),1),z(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:a[0]||=e=>A(J).error=``},`×`)])):H(``,!0),z(`main`,{class:`net-workspace`,style:ge({"--tree-w":`${A(Ou)}px`})},[B(Sp),A(ku).tree?(I(),L(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:ks(o,[`prevent`])},null,32)):H(``,!0),A(J).drawer?(I(),L(`div`,{key:1,class:`tree-backdrop`,onClick:a[1]||=e=>A(J).drawer=!1})):H(``,!0),A(q)&&A(Mu)&&A(Nu)?(I(),L(F,{key:2},[B(tk),A(J).inspectorOverlay?(I(),L(`div`,{key:0,class:`inspector-backdrop`,onClick:a[2]||=e=>A(Cd)()})):H(``,!0),(I(),R(wy,{key:`${A(q).deviceId}/${A(q).sessionId}`}))],64)):A(q)&&A(Mu)?(I(),R(dk,{key:3,device:A(Mu)},null,8,[`device`])):(I(),L(`section`,vH,[a[14]||=z(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),a[15]||=z(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),a[16]||=z(`h1`,null,[V(`Close the tab.`),z(`br`),V(`The work continues.`)],-1),a[17]||=z(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),z(`button`,{class:`primary`,disabled:!t(),onClick:i},[B(A(Xc),{size:18}),V(D(A(wu).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,yH),z(`div`,bH,[z(`span`,null,[B(A(fc),{size:18}),a[11]||=V(`SQLite on each device`,-1)]),z(`span`,null,[B(A(Cc),{size:18}),a[12]||=V(`Branch any agent`,-1)]),z(`span`,null,[B(A(Vs),{size:18}),a[13]||=V(`Watch from anywhere`,-1)])])]))],4),B(Kd),A(J).dialog?.kind===`pair`?(I(),R(bV,{key:1,ref_key:`pairWizard`,ref:n,handoff:A(J).dialog.handoff,onClose:a[3]||=e=>A(J).dialog=void 0},null,8,[`handoff`])):H(``,!0),A(J).dialog?.kind===`credentials`?(I(),R(wV,{key:2,"device-id":A(J).dialog.deviceId,onClose:a[4]||=e=>A(J).dialog=void 0},null,8,[`device-id`])):H(``,!0),A(J).dialog?.kind===`new-session`?(I(),R(Mk,{key:3,"device-id":A(J).dialog.deviceId,onClose:a[5]||=e=>A(J).dialog=void 0},null,8,[`device-id`])):A(J).dialog?.kind===`prompt`?(I(),R(FV,{key:4,ref_key:`promptDialog`,ref:r,dialog:A(J).dialog,onClose:a[6]||=e=>A(J).dialog=void 0},null,8,[`dialog`])):A(J).dialog?.kind===`models`?(I(),R(WV,{key:5,onClose:a[7]||=e=>A(J).dialog=void 0})):A(J).dialog?.kind===`path`?(I(),L(`div`,{key:6,class:`modal-backdrop`,onClick:a[10]||=ks(e=>A(J).dialog=void 0,[`self`])},[z(`section`,xH,[z(`header`,null,[a[18]||=z(`h2`,{id:`path-title`},`Working directory`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:a[8]||=e=>A(J).dialog=void 0},[B(A(xl),{size:18})])]),z(`code`,SH,D(A(J).dialog.path),1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:a[9]||=e=>A(J).dialog=void 0},`Close`)])])])):A(J).dialog?.kind===`help`?(I(),R($V,{key:7})):H(``,!0),A(eH).needed?(I(),R(fH,{key:8})):H(``,!0),B(mH)]))}});sH();var wH=new URL(window.location.href);if(/^\/pair\/?$/.test(wH.pathname)){let e=BB(wH);e?(wH.search=``,wH.hash=``,window.history.replaceState(window.history.state,``,wH),J.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,HB(wH))}Fs(CH).mount(`#app`);