my-durable 0.0.78 → 0.0.80

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,7 +12,7 @@ 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=hu(e);if(t>n)throw a();f=f.slice(p+2),s-=t+2;let r=_u(e);r&&(yield r)}if(s>n)throw a();o=f?[f]:[],c=f.slice(-1)}}finally{r.cancel().catch(()=>{})}}function _u(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 vu=encodeURIComponent,yu=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,bu=e=>e.normalize(`NFKD`).replace(/[^\w.-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60).toLowerCase()||`session`,xu=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 Cl(`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 Cl(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 Cl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}if(!r.ok||!r.body){let e=await r.json().catch(()=>void 0);throw new Cl(e?.error?.code??(r.status===401?`unauthorized`:`unavailable`),e?.error?.message??`Stream failed (${r.status})`,r.status)}try{for await(let e of gu(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/${vu(e)}`,t)}archiveProject(e){return this.request(`POST`,`/v1/projects/${vu(e)}/archive`,{})}unarchiveProject(e){return this.request(`POST`,`/v1/projects/${vu(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/${vu(e)}`,t)}removeNotifySink(e){return this.request(`DELETE`,`/v1/notify/sinks/${vu(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/${vu(e)}`)}piAuth(){return this.request(`GET`,`/v1/device/pi-auth`)}setPiApiKey(e,t){return this.request(`PUT`,`/v1/device/pi-auth/${vu(e)}`,{key:t})}removePiApiKey(e){return this.request(`DELETE`,`/v1/device/pi-auth/${vu(e)}`)}graphs(){return this.request(`GET`,`/v1/graphs`)}graph(e){return this.request(`GET`,`/v1/graphs/${vu(e)}`)}createGraph(e){return this.request(`POST`,`/v1/graphs`,e)}runGraph(e){return this.request(`POST`,`/v1/graphs/${vu(e)}/run`,{})}removeGraph(e){return this.request(`DELETE`,`/v1/graphs/${vu(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/${vu(e)}`,t)}removeSchedule(e){return this.request(`DELETE`,`/v1/schedules/${vu(e)}`)}runSchedule(e){return this.request(`POST`,`/v1/schedules/${vu(e)}/run`,{})}deviceUsage(){return this.request(`GET`,`/v1/device/usage`)}searchSessions(e,t){return this.request(`GET`,`/v1/sessions/search?q=${vu(e)}${t===`all`?`&scope=all`:``}`)}dirs(e=``){return this.request(`GET`,`/v1/fs/dirs?path=${vu(e)}`)}deviceDoc(e){return this.request(`GET`,`/v1/docs/${vu(e)}`)}deviceEvents(e,t=[]){return this.stream(`/v1/events${t.length?`?docs=${t.map(vu).join(`,`)}`:``}`,e)}gitStatus(e,t={}){return this.request(`GET`,`/v1/git/status?path=${vu(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/${vu(e)}/export`,{headers:this.headers(!1),signal:r})}catch(e){throw t.signal?.aborted?e:new Cl(`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 Cl(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`))||`${bu(e)}.bundle.zip`,mime:i.headers.get(`content-type`)??`application/zip`,bytes:a}}sessionGitFiles(e){return this.request(`GET`,`/v1/sessions/${vu(e)}/git-files`)}sessionGitTurns(e){return this.request(`GET`,`/v1/sessions/${vu(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/${vu(e)}/transcript?format=${t}`)}restoreArchived(e){return this.request(`POST`,`/v1/archive/${vu(e)}/restore`,{})}createSession(e,t=yu()){return this.request(`POST`,`/v1/sessions`,e,{idempotencyKey:t})}session(e){return new Su(this,e)}agent(e,t){return new Cu(this,e,String(t))}},Su=class{client;ref;constructor(e,t){this.client=e,this.ref=t}get base(){return`/v1/sessions/${vu(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=yu()){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)}},Cu=class{client;session;agent;constructor(e,t,n){this.client=e,this.session=t,this.agent=n}get base(){return`/v1/sessions/${vu(this.session)}/agents/${vu(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=yu(),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=yu()){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/${vu(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(vu).join(`,`)}`:``}`,e)}};function wu(e,t){let n=String(e??``).trim();return t?n.replace(/\//g,`\\`).replace(/\\+$/,``).toLowerCase():n.replace(/\/+$/,``)}function Tu(e,t){let n=e?.startDirs;if(!Array.isArray(n)||n.length===0)return!0;let r=String(e?.platform??``).startsWith(`win32`),i=wu(t,r);return n.some(e=>{let t=wu(String(e),r);return!!t&&(i===t||i.startsWith(r?`${t}\\`:`${t}/`))})}function Eu(e){let t=Array.isArray(e?.startDirs)?e.startDirs.map(String):[];return t.length?`outside the device's start dirs (it serves: ${t.join(`, `)})`:`outside the device's start dirs`}var Du=0,Ou=e=>new xu(`/api/devices/${encodeURIComponent(e)}`,void 0,{onIdempotentReplay:e=>{Date.now()-Du<3e4||(Du=Date.now(),J(`Replayed an earlier identical request (${e}) — send a custom idempotency key for deliberate repeats.`))}}),W=e=>{let t=Ou(e),n=()=>Hu.devices.value.find(t=>t.id===e)?.info,r=t.gitOp.bind(t);return t.gitOp=((e,t,i)=>{let a=n();return a&&e&&!Tu(a,e)?Promise.reject(new Cl(`invalid`,`git ${t} skipped: ${Eu(a)}`,400)):r(e,t,i)}),t};async function ku(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 Cl(e?.code??`internal`,e?.message??`${r.status} ${r.statusText}`,r.status)}return i}var Au={network:()=>ku(`GET`,`/network`),version:()=>ku(`GET`,`/version`),check:e=>ku(`POST`,`/devices/${encodeURIComponent(e)}/check`,{}),createShare:e=>ku(`POST`,`/shares`,e),async uiGet(e){return(await ku(`GET`,`/ui-state/${encodeURIComponent(e)}`)).value??void 0},uiSet:(e,t)=>ku(`PUT`,`/ui-state/${encodeURIComponent(e)}`,{value:t})},G=e=>e instanceof Error?e.message:String(e),ju=[`demo.job-runs`,`demo.workspace`],Mu=e=>`${e.deviceId}/agent/${e.sessionId}/${e.agentId}?docs=${ju.join(`,`)}`,Nu=e=>`${e.deviceId}/session/${e.sessionId}`,Pu=e=>`${e}/device?docs=app.shared-state`;function Fu(e,t,n,r=`hello`){let i=O(`idle`),a=O(``);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 Iu(e){let t=new nu,n=O(0);return t.subscribe(()=>n.value++),e.onNetwork(e=>t.apply({type:`network`,devices:e})),{model:t,devices:H(()=>(n.value,t.devices)),tree:H(()=>(n.value,t.tree()))}}function Lu(e,t){let n=an(),r=an([]),{status:i,select:a}=Fu(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 j(t,e=>{n.value=void 0,a(e?Pu(e):void 0)},{immediate:!0}),{sharedState:n,activity:r,status:i}}function Ru(e,t){let n=new Yl,r=O(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o}=Fu(e,`session`,e=>n.apply(e));return j(()=>t.value?Nu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:H(()=>(r.value,n.state)),status:i,fault:a}}function zu(e,t){let n=new Jl,r=O(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o,retry:s}=Fu(e,`agent`,e=>n.apply(e),`snapshot`);return j(()=>t.value?Mu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:H(()=>(r.value,{...n.state})),status:i,fault:a,version:r,retry:s}}var Bu=new cu,Vu=O(Bu.state);Bu.onState(e=>Vu.value=e);var Hu=Iu(Bu),Uu=O(),Wu=O(),K=O(),Gu=O(new Set),Ku=O(300),qu=Gt({tree:!0,inspector:!0}),Ju=O(!1),Yu=H(()=>K.value?.deviceId),Xu=H(()=>Hu.devices.value.find(e=>e.id===Yu.value)),Zu=H(()=>Xu.value?.status===`online`),Qu=Ru(Bu,H(()=>K.value?{deviceId:K.value.deviceId,sessionId:K.value.sessionId}:void 0)),$u=zu(Bu,K),ed=Lu(Bu,Yu),td=H(()=>Xu.value?.tree?.sessions.find(e=>e.id===K.value?.sessionId)),nd=H(()=>Yu.value?W(Yu.value):void 0),rd=H(()=>K.value&&nd.value?nd.value.agent(K.value.sessionId,K.value.agentId):void 0),id=H(()=>K.value&&nd.value?nd.value.session(K.value.sessionId):void 0);function ad(e){K.value=e,q.drawer=!1,od=!!e,sd()}var od=!1;function sd(){let e=K.value;if(!od||!e)return;let t=Hu.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=>!Gu.value.has(e))&&(Gu.value=new Set([...Gu.value,...r])),n.has(e.agentId)&&(od=!1)}j(()=>Hu.devices.value,sd);function cd(e,t){let n=new Set(Gu.value);t??!n.has(e)?n.add(e):n.delete(e),Gu.value=n}var ld=(()=>{let e=new Map;return(t,n)=>{clearTimeout(e.get(t)),e.set(t,setTimeout(()=>void Au.uiSet(t,n).catch(()=>{}),300))}})();j(K,e=>Ju.value&&void Au.uiSet(`tree.selected`,e??null).catch(()=>{})),j(Ku,e=>Ju.value&&ld(`tree.width`,e)),j(qu,e=>Ju.value&&ld(`layout.panels`,{...e}));async function ud(){let e;try{e=await Au.network()}catch(e){e instanceof Cl&&e.status===401||Bu.start(),q.error=G(e),Ju.value=!0;return}Bu.start();try{let[t,n,r]=await Promise.all([Au.uiGet(`tree.selected`),Au.uiGet(`tree.width`),Au.uiGet(`layout.panels`)]);r&&Object.assign(qu,r),Au.version().then(e=>Wu.value=e.version).catch(()=>{}),Uu.value=e.configFile,Hu.model.devices.length||Hu.model.apply({type:`network`,devices:e.devices}),Gu.value=new Set,n&&(Ku.value=n),t&&e.devices.some(e=>e.id===t.deviceId)?ad(t):dd(e.devices)}catch(e){q.error=G(e)}finally{Ju.value=!0}}function dd(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 ad({deviceId:t.id,sessionId:e.id,agentId:n.id})}}j(()=>[$u.status.value,td.value],([e,t])=>{e===`fault`&&!t&&Zu.value&&(J(`That session was archived on its device.`),ad(void 0))});var fd=H(()=>Xu.value?.info?.models??[]),pd=$u.state,md=H(()=>Qu.state.value.agents.length?Qu.state.value.agents:td.value?.agents??[]),hd=H(()=>K.value?Xl(md.value,K.value.agentId):[]),gd=H(()=>{let e=K.value?.agentId;if(e===void 0)return[];let t=md.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=Qu.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}})}),_d=H(()=>pd.value.running||gd.value.some(e=>!e.effectiveBackground&&e.conversationId===K.value?.agentId)),vd=H(()=>jl(pd.value.usage)),yd=H(()=>{let e=pd.value.agent.model;return fd.value.find(t=>t.provider===e?.provider&&t.id===e?.modelId)}),bd=H(()=>{let e=pd.value.agent.model;if(e?.modelId)return e;let t=td.value;return t?.model?{provider:t.provider??``,modelId:t.model}:void 0}),xd=H(()=>{let e=bd.value;return e?fd.value.find(t=>t.provider===e.provider&&t.id===e.modelId):void 0}),Sd=an(),Cd=0;async function wd(){let e=rd.value,t=++Cd;if(!e||!Zu.value)return void(Sd.value=void 0);try{let n=await e.get();t===Cd&&(Sd.value=n)}catch{t===Cd&&(Sd.value=void 0)}}j([rd,Zu],()=>void wd(),{immediate:!0});var q=Gt({error:``,toast:``,drawer:!1,inspectorOverlay:!1,tab:`session`,composer:``,dialog:void 0}),Td,Ed=Gt([]),Dd=1;function Od(){for(let e of Ed)e.read=!0}function J(e){q.toast=e,e&&(Ed.unshift({id:Dd++,text:e,at:Date.now(),read:!1}),Ed.length>50&&(Ed.length=50)),clearTimeout(Td),Td=setTimeout(()=>q.toast=``,4500)}async function kd(e){q.error=``;try{return await e()}catch(e){q.error=G(e);return}}function Ad(e){q.composer=e,setTimeout(()=>document.querySelector(`.composer textarea`)?.focus())}var jd=e=>Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e),Md=e=>JSON.stringify(e,null,2),Nd=(e=``)=>uu(fd.value.find(t=>t.id===e)?.icon);function Pd(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 Fd=O(!1);async function Id(){_d.value&&!Fd.value&&rd.value&&(Fd.value=!0,await kd(()=>rd.value.abort(!1))&&J(`Foreground work interrupted. Background jobs continue.`),Fd.value=!1)}var Ld=window.matchMedia(`(max-width: 1100px)`),Rd=O(Ld.matches);Ld.addEventListener(`change`,e=>Rd.value=e.matches);var zd=H(()=>Rd.value?q.inspectorOverlay:qu.inspector);function Bd(e){e&&(q.tab=e),Rd.value?(q.drawer=!1,q.inspectorOverlay=!0):qu.inspector=!0}function Vd(){Rd.value?q.inspectorOverlay=!1:qu.inspector=!1}function Hd(){Rd.value?(q.drawer=!q.drawer)&&(q.inspectorOverlay=!1,qu.tree=!0):qu.tree=!qu.tree}function Ud(){zd.value?Vd():Bd()}var Wd=/Mac|iPhone|iPad/.test(navigator.userAgent),Gd=Wd?{tree:`Ctrl+N`,inspector:`Ctrl+T`}:{tree:`Alt+Shift+N`,inspector:`Alt+Shift+T`};function Kd(e){if(!(!(Wd?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 qd={class:`topbar`},Jd={class:`brand`},Yd={class:`daemon`,"data-testid":`topbar-stats`},Xd=[`title`],Zd={class:`top-actions`},Qd={key:0,class:`usage-chip`,title:`This session's token usage and cost`},$d=[`aria-label`,`title`],ef={key:0,class:`bell-dot`},tf={key:0,class:`hint`},nf={class:`when`},rf=[`disabled`],af=[`disabled`],of=M({__name:`TopBar`,emits:[`newSession`],setup(e,{emit:t}){let n=O(!1),r=H(()=>Ed.filter(e=>!e.read).length),i=()=>{n.value=!n.value,n.value&&Od()},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=H(()=>vd.value.input+vd.value.output+vd.value.cacheRead+vd.value.cacheWrite),s=H(()=>(vd.value.inputCost??0)+(vd.value.outputCost??0)+(vd.value.cacheReadCost??0)+(vd.value.cacheWriteCost??0)),c=H(()=>Hu.devices.value.filter(e=>e.status===`online`).length),l=H(()=>Hu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.length??0),0)),u=H(()=>Hu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.reduce((e,t)=>e+t.agents.length,0)??0),0)),d=O(!1);async function f(){let e=id.value,t=K.value;if(!e||!t||d.value)return;d.value=!0;let n=await kd(()=>e.createAgent({name:`Agent ${md.value.length+1}`}));d.value=!1,n&&(ad({...t,agentId:n.id}),J(`New agent. Same session, same shared App State.`))}let p=t;return(e,t)=>(F(),I(`header`,qd,[R(`div`,Jd,[R(`button`,{class:`icon-button tree-toggle`,"aria-label":`Toggle network`,title:`Network`,onClick:t[0]||=e=>k(q).drawer=!k(q).drawer},[z(k(Kc),{size:19})]),t[6]||=R(`img`,{class:`brandmark`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),t[7]||=R(`strong`,null,`Durable Pi`,-1)]),t[15]||=R(`span`,{class:`topbar-sep`,"aria-hidden":`true`},null,-1),R(`div`,Yd,[R(`span`,{class:E([`dot`,{off:!c.value}]),"aria-hidden":`true`},null,2),R(`span`,{class:`network-summary`,title:`${c.value} of ${k(Hu).devices.value.length} devices online`},[z(k(Vc),{size:16}),B(D(c.value)+` of `+D(k(Hu).devices.value.length)+` online`,1)],8,Xd),t[10]||=R(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),R(`span`,null,[R(`b`,null,D(l.value),1),t[8]||=B(` sessions`,-1)]),t[11]||=R(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),R(`span`,null,[R(`b`,null,D(u.value),1),t[9]||=B(` agents`,-1)])]),R(`div`,Zd,[R(`span`,{class:E([`chip connection`,{accent:k(Vu)===`live`}])},[R(`span`,{class:E([`dot`,{off:k(Vu)!==`live`}]),"aria-hidden":`true`},null,2),B(D(k(Vu)===`live`?`Connected`:`Reconnecting`),1)],2),o.value?(F(),I(`span`,Qd,D(o.value.toLocaleString())+` tok · $`+D(s.value.toFixed(3)),1)):V(``,!0),R(`button`,{class:`icon-button`,"aria-label":`Notifications${r.value?` (${r.value} unread)`:``}`,title:`Notification center${r.value?` — ${r.value} unread`:``}`,onClick:i},[z(k(Zs),{size:18}),r.value?(F(),I(`i`,ef,D(r.value>9?`9+`:r.value),1)):V(``,!0)],8,$d),n.value?(F(),I(`div`,{key:1,class:`notif-panel`,onClick:t[2]||=As(()=>{},[`stop`])},[R(`header`,null,[t[12]||=R(`b`,null,`Notifications`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close notifications`,onClick:t[1]||=e=>n.value=!1},`✕`)]),k(Ed).length?V(``,!0):(F(),I(`p`,tf,`Nothing yet — events land here as they happen.`)),R(`ul`,null,[(F(!0),I(P,null,N(k(Ed),e=>(F(),I(`li`,{key:e.id,class:E({unread:!e.read})},[R(`span`,nf,D(a(e.at)),1),R(`span`,null,D(e.text),1)],2))),128))])])):V(``,!0),R(`button`,{class:`icon-button`,title:`How this works`,"aria-label":`How this works`,onClick:t[3]||=e=>k(q).dialog={kind:`help`}},[z(k(oc),{size:19})]),R(`button`,{class:`secondary small new-agent-button`,disabled:!k(K)||!k(Zu)||d.value,title:`Start a fresh agent in this session`,onClick:f},[z(k(Zc),{size:18}),t[13]||=B(`New agent `,-1)],8,rf),R(`button`,{class:`primary small`,onClick:t[4]||=e=>p(`newSession`)},[z(k(Zc),{size:18}),t[14]||=B(`New session `,-1)]),R(`button`,{class:`icon-button inspector-toggle`,"aria-label":`Toggle inspector`,title:`Inspector`,disabled:!k(K)||!k(Zu),onClick:t[5]||=e=>k(q).inspectorOverlay?k(Vd)():k(Bd)()},[z(k(qc),{size:19})],8,af)])]))}}),sf=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},cf=sf(of,[[`__scopeId`,`data-v-de526f26`]]),lf={class:`mnav`,"aria-label":`Panels`},uf={key:0,class:`badge`},df=M({__name:`MobileNav`,setup(e){function t(){q.drawer=!1,q.inspectorOverlay=!1}return(e,n)=>(F(),I(`nav`,lf,[R(`button`,{type:`button`,class:E({"is-on":!k(q).drawer&&!k(zd)}),onClick:t},[z(k(Rc),{size:18}),n[2]||=B(`Chat `,-1)],2),R(`button`,{type:`button`,class:E({"is-on":k(zd)}),onClick:n[0]||=e=>k(zd)?k(Vd)():k(Bd)()},[z(k(qc),{size:18}),n[3]||=B(`Details`,-1),k(gd).length?(F(),I(`span`,uf,D(k(gd).length),1)):V(``,!0)],2),R(`button`,{type:`button`,class:E({"is-on":k(q).drawer}),onClick:n[1]||=e=>k(Hd)()},[z(k(_l),{size:18}),n[4]||=B(`Network `,-1)],2)]))}}),ff=[`width`,`height`,`aria-label`],pf=[`width`,`height`,`aria-label`],mf=M({__name:`DeviceIcon`,props:{device:{},size:{default:16}},setup(e){let t=e,n=H(()=>{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=H(()=>{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`?(F(),I(`svg`,{key:0,class:`device-icon exe`,viewBox:`0 0 512 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[R(`title`,null,D(r.value),1),i[0]||=R(`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,ff)):n.value===`apple`?(F(),I(`svg`,{key:1,class:`device-icon apple`,viewBox:`0 0 384 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[R(`title`,null,D(r.value),1),i[1]||=R(`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,pf)):n.value===`laptop`?(F(),L(k(jc),{key:2,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`])):(F(),L(k(al),{key:3,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`]))}}),hf=new Map,gf=new Map,_f=2e3;function vf(){for(;hf.size>_f;){let e=hf.keys().next().value;if(e===void 0)break;hf.delete(e)}}function yf(e,t){return Tu(Hu.devices.value.find(t=>t.id===e)?.info,t)}function bf(e,t){if(!yf(e,t))return{ok:!1,reason:`outside the device's start dirs`};let n=Df(e,t);return n.status&&n.status.repo===!1&&Date.now()-n.at<5e3?{ok:!1,reason:`not a git repository`}:{ok:!0}}function xf(e,t){t&&typeof t.error==`string`?(e.status=null,e.error=t.error):(e.status=t??null,e.error=``),e.at=Date.now()}async function Sf(e,t){let n=t.filter(t=>!Of(Df(e,t),Cf)&&yf(e,t));if(n.length){for(let t=0;t<n.length&&t<500;t+=50){let r=n.slice(t,t+50);try{let t=await W(e).gitStatusBatch(r,{timeoutMs:6e4});for(let n of r){let r=t[n];r!==void 0&&xf(Df(e,n),r)}}catch{}}vf()}}var Cf=6e4,wf=!1;function Tf(){wf||(wf=!0,j(()=>Hu.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[...hf.keys()]){let i=r.indexOf(`::`),a=r.slice(0,i),o=r.slice(i+2);if(i<0||!a||a!==n.id||!o)continue;let s=hf.get(r);e.some(e=>o===e.root||o.startsWith(e.root+`/`)||o.startsWith(e.root+`\\`))&&(s.loading||t-s.at<4e3||kf(a,o,{force:!0}))}}}))}var Ef=(e,t)=>`${e}::${t}`;function Df(e,t){let n=Ef(e,t),r=hf.get(n);return r||(r=Gt({at:0,status:null,error:``,loading:!1,refreshing:!1}),hf.set(n,r)),r}var Of=(e,t)=>e.at>0&&Date.now()-e.at<t&&(e.status!==null||e.error);async function kf(e,t,n={}){let{staleMs:r=6e4,force:i=!1,timeoutMs:a=6e4}=n;if(!e||!t)return;let o=Ef(e,t),s=Df(e,t);if(!i&&Of(s,r))return;if(!yf(e,t)){xf(s,{error:`outside the device's start dirs`});return}vf();let c=gf.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 W(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,gf.delete(o)}})();return gf.set(o,l),l}var Af=new Map;function jf(){j(()=>Hu.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 Hu.devices.value){if(e.status!==`online`||!e.tree?.sessions.length)continue;let t=Date.now();t-(Af.get(e.id)??0)<6e4||(Af.set(e.id,t),Sf(e.id,e.tree.sessions.map(e=>e.cwd)))}},{immediate:!0})}var Mf=(e,t)=>Df(e,t).status?.branch,Nf=[`aria-level`,`aria-expanded`,`aria-selected`,`data-key`,`title`],Pf=[`aria-label`],Ff={key:1,class:`chev`},If={class:`name`},Lf={class:`badge`},Rf=[`title`],zf=[`aria-label`],Bf=[`disabled`,`aria-label`],Vf=[`aria-label`],Hf=[`checked`,`aria-label`],Uf={class:`name`},Wf={class:`path`},Gf=[`title`],Kf=[`title`],qf={key:3,class:`dot work`,title:`Working`},Jf=[`title`],Yf=[`disabled`,`aria-label`],Xf=[`disabled`,`aria-label`],Zf=[`disabled`,`aria-label`],Qf=[`disabled`,`aria-label`],$f={class:`name`},ep={key:3,class:`meta`},tp={key:4,class:`dot work`,title:`Working`},np=[`title`],rp=[`disabled`,`aria-label`],ip=sf(M({__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=H(()=>n.node.children.length>0),a=H(()=>n.node.type===`device`?n.node.device:void 0),o=H(()=>n.node.type===`session`?n.node.session:void 0),s=H(()=>n.node.type===`agent`?n.node.agent:void 0),c=H(()=>o.value?o.value.agents.reduce((e,t)=>e+t.background,0):s.value?.background??0),l=H(()=>o.value?.busy||s.value?.busy),u=H(()=>{let e=a.value?.info,t=e?.packageVersion??e?.durableVersion,n=Wu.value;return!!(t&&n&&n!==`unknown`&&t!==n)}),d=H(()=>{let e=a.value?.info;return e?.packageVersion??e?.durableVersion??`?`}),f=H(()=>{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 · ${Pd(e.lastSeenAt)}`}}),p=H(()=>{let e=a.value?.status;return e===`online`?`on`:e===`checking`?`chk`:e===`offline`?`off`:`err`}),m=H(()=>{let e=n.node;return e.type===`session`?Mf(e.deviceId,e.session.cwd):void 0}),h=H(()=>a.value?.name??a.value?.id??o.value?.name??s.value?.name??``),g=H(()=>{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)=>(F(),I(`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?(F(),I(`button`,{key:0,class:`chev`,tabindex:`-1`,"aria-label":e.open?`Collapse ${h.value}`:`Expand ${h.value}`,onClick:n[0]||=As(e=>r(`toggle`),[`stop`])},[e.open?(F(),L(k(rc),{key:0,size:16})):(F(),L(k(ic),{key:1,size:16}))],8,Pf)):(F(),I(`span`,Ff)),a.value?(F(),I(P,{key:2},[R(`i`,{class:E([`dot`,p.value])},null,2),z(mf,{device:a.value,size:16},null,8,[`device`]),R(`b`,If,D(h.value),1),R(`span`,Lf,D(a.value.kind),1),u.value?(F(),I(`span`,{key:0,class:`tag update`,title:`device runs ${d.value}; hub runs ${k(Wu)}. Devices self-update: dpi update`},`update`,8,Rf)):V(``,!0),R(`span`,{class:E([`meta`,{err:p.value===`err`}])},D(f.value),3),R(`span`,{class:`acts`,onClick:n[4]||=As(()=>{},[`stop`])},[a.value.pairing?(F(),I(`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`)},[z(k(Ac),{size:16})],8,zf)):V(``,!0),R(`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`)},[z(k(Zc),{size:16})],8,Bf),R(`button`,{class:`icon-button`,"aria-label":`Check ${h.value}`,title:`Check connection now`,onClick:n[3]||=e=>r(`action`,`check`)},[z(k(el),{size:16})],8,Vf)])],64)):o.value?(F(),I(P,{key:3},[e.checkbox?(F(),I(`input`,{key:0,type:`checkbox`,class:`bulk-check`,checked:e.checked,"aria-label":`Select ${h.value}`,tabindex:`-1`,onClick:n[5]||=As(()=>{},[`stop`]),onChange:n[6]||=e=>r(`check`)},null,40,Hf)):V(``,!0),z(k(bc),{class:`ico`,size:16}),R(`b`,Uf,D(h.value),1),R(`span`,Wf,`…/`+D(o.value.cwd.split(`/`).filter(Boolean).at(-1)),1),m.value?(F(),I(`span`,{key:1,class:`branch`,title:`git branch of ${o.value.cwd}`},`⎇ `+D(m.value),9,Gf)):V(``,!0),o.value.model?(F(),I(`span`,{key:2,class:`tag`,title:o.value.provider?`${o.value.provider} / ${o.value.model}`:o.value.model},D(o.value.model),9,Kf)):V(``,!0),l.value?(F(),I(`i`,qf)):V(``,!0),c.value?(F(),I(`span`,{key:4,class:`bg-count`,title:`${c.value} background task(s)`},[n[15]||=R(`i`,{class:`dot bg`},null,-1),B(D(c.value)+` bg`,1)],8,Jf)):V(``,!0),R(`span`,{class:`acts`,onClick:n[11]||=As(()=>{},[`stop`])},[R(`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`)},[z(k(Zc),{size:16})],8,Yf),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename session ${h.value}`,title:`Rename session`,onClick:n[8]||=e=>r(`action`,`rename`)},[z(k(Jc),{size:16})],8,Xf),R(`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`)},[z(k(dl),{size:16})],8,Zf),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Archive session ${h.value}`,title:`Archive session`,onClick:n[10]||=e=>r(`action`,`archive`)},[z(k(Ws),{size:16})],8,Qf)])],64)):s.value?(F(),I(P,{key:4},[s.value.kind===`fork`?(F(),L(k(wc),{key:0,class:`ico`,size:16})):s.value.kind===`subagent`?(F(),L(k(lc),{key:1,class:`ico`,size:16})):(F(),L(k(Rc),{key:2,class:`ico root`,size:16})),R(`span`,$f,D(h.value),1),s.value.kind===`fork`&&s.value.forkedAt!==void 0?(F(),I(`span`,ep,`@ #`+D(s.value.forkedAt),1)):V(``,!0),l.value?(F(),I(`i`,tp)):V(``,!0),c.value?(F(),I(`span`,{key:5,class:`bg-count`,title:`${c.value} background task(s)`},[n[16]||=R(`i`,{class:`dot bg`},null,-1),B(D(c.value),1)],8,np)):V(``,!0),R(`span`,{class:`acts`,onClick:n[13]||=As(()=>{},[`stop`])},[R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename agent ${h.value}`,title:`Rename agent`,onClick:n[12]||=e=>r(`action`,`rename`)},[z(k(Jc),{size:16})],8,rp)])],64)):V(``,!0)],14,Nf))}}),[[`__scopeId`,`data-v-ec99cf9d`]]),ap={class:`project-bar`,"aria-label":`Projects`},op={class:`project-head`},sp={class:`project-title`},cp=[`aria-label`,`title`],lp={key:0,class:`project-hint`},up={key:0,class:`chips`},dp=[`title`,`onClick`,`onDblclick`],fp={class:`chip-name`},pp={class:`chip-count`},mp={key:1,class:`project-hint`},hp={key:2,class:`project-actions`},gp=[`onClick`],_p=[`onClick`],vp=[`onClick`],yp=[`onClick`],bp={key:3,class:`message-error`},xp={key:4,class:`project-hint labels-hint`},Sp=sf(M({__name:`ProjectBar`,props:{active:{},activeModifiers:{}},emits:[`update:active`],setup(e,{expose:t}){let n=Oi(e,`active`),r=O([]),i=O(!1),a=O(``),o=O(!1),s=H(()=>Hu.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=Hu.devices.value.find(e=>e.id===n),i=await W(n).projects(o.value).catch(e=>{let r=G(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}j([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;q.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 W(e.deviceId).updateProject(t.id,{customName:n});J(`Project renamed to ${r.customName??r.name}.`),await c()}}}function p(e){let t=e.project;q.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 W(e.deviceId).updateProject(t.id,{labels:n.split(`,`).map(e=>e.trim()).filter(Boolean)});J(r.labels.length?`Labels: ${r.labels.join(`, `)}.`:`Labels cleared on ${l(r)}.`),await c()}}}function m(e){let t=e.project,n=Hu.devices.value.find(t=>t.id===e.deviceId)?.info?.models??[];q.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 W(e.deviceId).updateProject(t.id,{model:``}),J(`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 W(e.deviceId).updateProject(t.id,{model:{provider:i,modelId:o}}),J(`New sessions in ${l(t)} start on ${o}.`),await c()}}}function h(e){let t=e.project,r=t.archivedAt!==null;q.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=W(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)=>(F(),I(`div`,ap,[R(`div`,op,[R(`span`,sp,[z(k(yc),{size:13}),t[2]||=B(`PROJECTS`,-1)]),R(`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},[z(k(Ws),{size:12})],10,cp),i.value?(F(),I(`span`,lp,`…`)):V(``,!0)]),r.value.length?(F(),I(`div`,up,[(F(!0),I(P,null,N(r.value,e=>(F(),I(`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`?(F(),L(k(xc),{key:0,size:11})):(F(),L(k(yc),{key:1,size:11})),R(`span`,fp,D(l(e.project)),1),R(`em`,pp,D(e.sessions),1),(F(!0),I(P,null,N(e.project.labels.slice(0,2),e=>(F(),I(`span`,{key:e,class:`chip-label`},D(e),1))),128))],42,dp))),128))])):i.value?V(``,!0):(F(),I(`p`,mp,` No projects yet — a project appears when a session starts in a folder. `)),n.value?(F(),I(`div`,hp,[t[5]||=R(`span`,{class:`project-hint`},`filtering`,-1),(F(!0),I(P,null,N(r.value.filter(u),e=>(F(),I(P,{key:e.project.id},[R(`button`,{class:`small`,onClick:t=>f(e)},[z(k(Jc),{size:12}),t[3]||=B(`name`,-1)],8,gp),R(`button`,{class:`small`,onClick:t=>p(e)},[z(k(pl),{size:12}),t[4]||=B(`labels`,-1)],8,_p),R(`button`,{class:`small`,onClick:t=>m(e),title:`Default model for new sessions in this project`},[z(k(fc),{size:12}),B(D(e.project.model?`model ✓`:`model`),1)],8,vp),R(`button`,{class:`small`,onClick:t=>h(e)},[e.project.archivedAt?(F(),L(k(Us),{key:0,size:12})):(F(),L(k(Ws),{key:1,size:12})),B(` `+D(e.project.archivedAt?`restore`:`archive`),1)],8,yp),R(`button`,{class:`icon-button tiny`,"aria-label":`Clear project filter`,onClick:t[1]||=e=>n.value=void 0},[z(k(Sl),{size:12})])],64))),128))])):V(``,!0),a.value?(F(),I(`p`,bp,D(a.value),1)):V(``,!0),r.value.some(e=>e.project.labels.length)?(F(),I(`p`,xp,[z(k(pl),{size:11}),B(`labels: `+D([...new Set(r.value.flatMap(e=>e.project.labels))].join(` · `)),1)])):V(``,!0)]))}}),[[`__scopeId`,`data-v-77864963`]]);function Cp(e,t){return`${e.slice(0,e.lastIndexOf(`/`))}/${e.slice(e.lastIndexOf(`/`)+1)}-${t.replace(/[/\\]+/g,`-`)}`}async function wp(e,t,n,r){let i=Cp(n,r);return{target:i,text:(await e.gitOp(t,`worktree-add`,{branch:r,target:i})).text.split(`
15
+ `),id:n}:void 0}var vu=encodeURIComponent,yu=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,bu=e=>e.normalize(`NFKD`).replace(/[^\w.-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60).toLowerCase()||`session`,xu=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 Cl(`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 Cl(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 Cl(`offline`,`Cannot reach ${this.baseUrl}`,0,{cause:e})}if(!r.ok||!r.body){let e=await r.json().catch(()=>void 0);throw new Cl(e?.error?.code??(r.status===401?`unauthorized`:`unavailable`),e?.error?.message??`Stream failed (${r.status})`,r.status)}try{for await(let e of gu(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/${vu(e)}`,t)}archiveProject(e){return this.request(`POST`,`/v1/projects/${vu(e)}/archive`,{})}unarchiveProject(e){return this.request(`POST`,`/v1/projects/${vu(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/${vu(e)}`,t)}removeNotifySink(e){return this.request(`DELETE`,`/v1/notify/sinks/${vu(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/${vu(e)}`)}piAuth(){return this.request(`GET`,`/v1/device/pi-auth`)}setPiApiKey(e,t){return this.request(`PUT`,`/v1/device/pi-auth/${vu(e)}`,{key:t})}removePiApiKey(e){return this.request(`DELETE`,`/v1/device/pi-auth/${vu(e)}`)}graphs(){return this.request(`GET`,`/v1/graphs`)}graph(e){return this.request(`GET`,`/v1/graphs/${vu(e)}`)}createGraph(e){return this.request(`POST`,`/v1/graphs`,e)}runGraph(e){return this.request(`POST`,`/v1/graphs/${vu(e)}/run`,{})}removeGraph(e){return this.request(`DELETE`,`/v1/graphs/${vu(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/${vu(e)}`,t)}removeSchedule(e){return this.request(`DELETE`,`/v1/schedules/${vu(e)}`)}runSchedule(e){return this.request(`POST`,`/v1/schedules/${vu(e)}/run`,{})}deviceUsage(){return this.request(`GET`,`/v1/device/usage`)}searchSessions(e,t){return this.request(`GET`,`/v1/sessions/search?q=${vu(e)}${t===`all`?`&scope=all`:``}`)}dirs(e=``){return this.request(`GET`,`/v1/fs/dirs?path=${vu(e)}`)}deviceDoc(e){return this.request(`GET`,`/v1/docs/${vu(e)}`)}deviceEvents(e,t=[]){return this.stream(`/v1/events${t.length?`?docs=${t.map(vu).join(`,`)}`:``}`,e)}gitStatus(e,t={}){return this.request(`GET`,`/v1/git/status?path=${vu(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/${vu(e)}/export`,{headers:this.headers(!1),signal:r})}catch(e){throw t.signal?.aborted?e:new Cl(`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 Cl(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`))||`${bu(e)}.bundle.zip`,mime:i.headers.get(`content-type`)??`application/zip`,bytes:a}}sessionGitFiles(e){return this.request(`GET`,`/v1/sessions/${vu(e)}/git-files`)}sessionGitTurns(e){return this.request(`GET`,`/v1/sessions/${vu(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/${vu(e)}/transcript?format=${t}`)}restoreArchived(e){return this.request(`POST`,`/v1/archive/${vu(e)}/restore`,{})}createSession(e,t=yu()){return this.request(`POST`,`/v1/sessions`,e,{idempotencyKey:t})}session(e){return new Su(this,e)}agent(e,t){return new Cu(this,e,String(t))}},Su=class{client;ref;constructor(e,t){this.client=e,this.ref=t}get base(){return`/v1/sessions/${vu(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=yu()){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)}},Cu=class{client;session;agent;constructor(e,t,n){this.client=e,this.session=t,this.agent=n}get base(){return`/v1/sessions/${vu(this.session)}/agents/${vu(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=yu(),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=yu()){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/${vu(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(vu).join(`,`)}`:``}`,e)}};function wu(e,t){let n=String(e??``).trim();return t?n.replace(/\//g,`\\`).replace(/\\+$/,``).toLowerCase():n.replace(/\/+$/,``)}function Tu(e,t){let n=Array.isArray(e?.gitDirs)&&e.gitDirs.length?e.gitDirs:e?.startDirs;if(!Array.isArray(n)||n.length===0)return!0;let r=String(e?.platform??``).startsWith(`win32`),i=wu(t,r);return n.some(e=>{let t=wu(String(e),r);return!!t&&(i===t||i.startsWith(r?`${t}\\`:`${t}/`))})}function Eu(e){let t=Array.isArray(e?.gitDirs)&&e.gitDirs.length?e.gitDirs:e?.startDirs,n=Array.isArray(t)?t.map(String):[];return n.length?`outside the device's start dirs (it serves: ${n.join(`, `)})`:`outside the device's start dirs`}var Du=0,Ou=e=>new xu(`/api/devices/${encodeURIComponent(e)}`,void 0,{onIdempotentReplay:e=>{Date.now()-Du<3e4||(Du=Date.now(),J(`Replayed an earlier identical request (${e}) — send a custom idempotency key for deliberate repeats.`))}}),W=e=>{let t=Ou(e),n=()=>Hu.devices.value.find(t=>t.id===e)?.info,r=t.gitOp.bind(t);return t.gitOp=((e,t,i)=>{let a=n();return a&&e&&!Tu(a,e)?Promise.reject(new Cl(`invalid`,`git ${t} skipped: ${Eu(a)}`,400)):r(e,t,i)}),t};async function ku(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 Cl(e?.code??`internal`,e?.message??`${r.status} ${r.statusText}`,r.status)}return i}var Au={network:()=>ku(`GET`,`/network`),version:()=>ku(`GET`,`/version`),check:e=>ku(`POST`,`/devices/${encodeURIComponent(e)}/check`,{}),createShare:e=>ku(`POST`,`/shares`,e),async uiGet(e){return(await ku(`GET`,`/ui-state/${encodeURIComponent(e)}`)).value??void 0},uiSet:(e,t)=>ku(`PUT`,`/ui-state/${encodeURIComponent(e)}`,{value:t})},G=e=>e instanceof Error?e.message:String(e),ju=[`demo.job-runs`,`demo.workspace`],Mu=e=>`${e.deviceId}/agent/${e.sessionId}/${e.agentId}?docs=${ju.join(`,`)}`,Nu=e=>`${e.deviceId}/session/${e.sessionId}`,Pu=e=>`${e}/device?docs=app.shared-state`;function Fu(e,t,n,r=`hello`){let i=O(`idle`),a=O(``);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 Iu(e){let t=new nu,n=O(0);return t.subscribe(()=>n.value++),e.onNetwork(e=>t.apply({type:`network`,devices:e})),{model:t,devices:H(()=>(n.value,t.devices)),tree:H(()=>(n.value,t.tree()))}}function Lu(e,t){let n=an(),r=an([]),{status:i,select:a}=Fu(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 j(t,e=>{n.value=void 0,a(e?Pu(e):void 0)},{immediate:!0}),{sharedState:n,activity:r,status:i}}function Ru(e,t){let n=new Yl,r=O(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o}=Fu(e,`session`,e=>n.apply(e));return j(()=>t.value?Nu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:H(()=>(r.value,n.state)),status:i,fault:a}}function zu(e,t){let n=new Jl,r=O(0);n.subscribe(()=>r.value++);let{status:i,fault:a,select:o,retry:s}=Fu(e,`agent`,e=>n.apply(e),`snapshot`);return j(()=>t.value?Mu(t.value):void 0,e=>{n.clear(),o(e)},{immediate:!0}),{model:n,state:H(()=>(r.value,{...n.state})),status:i,fault:a,version:r,retry:s}}var Bu=new cu,Vu=O(Bu.state);Bu.onState(e=>Vu.value=e);var Hu=Iu(Bu),Uu=O(),Wu=O(),K=O(),Gu=O(new Set),Ku=O(300),qu=Gt({tree:!0,inspector:!0}),Ju=O(!1),Yu=H(()=>K.value?.deviceId),Xu=H(()=>Hu.devices.value.find(e=>e.id===Yu.value)),Zu=H(()=>Xu.value?.status===`online`),Qu=Ru(Bu,H(()=>K.value?{deviceId:K.value.deviceId,sessionId:K.value.sessionId}:void 0)),$u=zu(Bu,K),ed=Lu(Bu,Yu),td=H(()=>Xu.value?.tree?.sessions.find(e=>e.id===K.value?.sessionId)),nd=H(()=>Yu.value?W(Yu.value):void 0),rd=H(()=>K.value&&nd.value?nd.value.agent(K.value.sessionId,K.value.agentId):void 0),id=H(()=>K.value&&nd.value?nd.value.session(K.value.sessionId):void 0);function ad(e){K.value=e,q.drawer=!1,od=!!e,sd()}var od=!1;function sd(){let e=K.value;if(!od||!e)return;let t=Hu.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=>!Gu.value.has(e))&&(Gu.value=new Set([...Gu.value,...r])),n.has(e.agentId)&&(od=!1)}j(()=>Hu.devices.value,sd);function cd(e,t){let n=new Set(Gu.value);t??!n.has(e)?n.add(e):n.delete(e),Gu.value=n}var ld=(()=>{let e=new Map;return(t,n)=>{clearTimeout(e.get(t)),e.set(t,setTimeout(()=>void Au.uiSet(t,n).catch(()=>{}),300))}})();j(K,e=>Ju.value&&void Au.uiSet(`tree.selected`,e??null).catch(()=>{})),j(Ku,e=>Ju.value&&ld(`tree.width`,e)),j(qu,e=>Ju.value&&ld(`layout.panels`,{...e}));async function ud(){let e;try{e=await Au.network()}catch(e){e instanceof Cl&&e.status===401||Bu.start(),q.error=G(e),Ju.value=!0;return}Bu.start();try{let[t,n,r]=await Promise.all([Au.uiGet(`tree.selected`),Au.uiGet(`tree.width`),Au.uiGet(`layout.panels`)]);r&&Object.assign(qu,r),Au.version().then(e=>Wu.value=e.version).catch(()=>{}),Uu.value=e.configFile,Hu.model.devices.length||Hu.model.apply({type:`network`,devices:e.devices}),Gu.value=new Set,n&&(Ku.value=n),t&&e.devices.some(e=>e.id===t.deviceId)?ad(t):dd(e.devices)}catch(e){q.error=G(e)}finally{Ju.value=!0}}function dd(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 ad({deviceId:t.id,sessionId:e.id,agentId:n.id})}}j(()=>[$u.status.value,td.value],([e,t])=>{e===`fault`&&!t&&Zu.value&&(J(`That session was archived on its device.`),ad(void 0))});var fd=H(()=>Xu.value?.info?.models??[]),pd=$u.state,md=H(()=>Qu.state.value.agents.length?Qu.state.value.agents:td.value?.agents??[]),hd=H(()=>K.value?Xl(md.value,K.value.agentId):[]),gd=H(()=>{let e=K.value?.agentId;if(e===void 0)return[];let t=md.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=Qu.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}})}),_d=H(()=>pd.value.running||gd.value.some(e=>!e.effectiveBackground&&e.conversationId===K.value?.agentId)),vd=H(()=>jl(pd.value.usage)),yd=H(()=>{let e=pd.value.agent.model;return fd.value.find(t=>t.provider===e?.provider&&t.id===e?.modelId)}),bd=H(()=>{let e=pd.value.agent.model;if(e?.modelId)return e;let t=td.value;return t?.model?{provider:t.provider??``,modelId:t.model}:void 0}),xd=H(()=>{let e=bd.value;return e?fd.value.find(t=>t.provider===e.provider&&t.id===e.modelId):void 0}),Sd=an(),Cd=0;async function wd(){let e=rd.value,t=++Cd;if(!e||!Zu.value)return void(Sd.value=void 0);try{let n=await e.get();t===Cd&&(Sd.value=n)}catch{t===Cd&&(Sd.value=void 0)}}j([rd,Zu],()=>void wd(),{immediate:!0});var q=Gt({error:``,toast:``,drawer:!1,inspectorOverlay:!1,tab:`session`,composer:``,dialog:void 0}),Td,Ed=Gt([]),Dd=1;function Od(){for(let e of Ed)e.read=!0}function J(e){q.toast=e,e&&(Ed.unshift({id:Dd++,text:e,at:Date.now(),read:!1}),Ed.length>50&&(Ed.length=50)),clearTimeout(Td),Td=setTimeout(()=>q.toast=``,4500)}async function kd(e){q.error=``;try{return await e()}catch(e){q.error=G(e);return}}function Ad(e){q.composer=e,setTimeout(()=>document.querySelector(`.composer textarea`)?.focus())}var jd=e=>Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e),Md=e=>JSON.stringify(e,null,2),Nd=(e=``)=>uu(fd.value.find(t=>t.id===e)?.icon);function Pd(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 Fd=O(!1);async function Id(){_d.value&&!Fd.value&&rd.value&&(Fd.value=!0,await kd(()=>rd.value.abort(!1))&&J(`Foreground work interrupted. Background jobs continue.`),Fd.value=!1)}var Ld=window.matchMedia(`(max-width: 1100px)`),Rd=O(Ld.matches);Ld.addEventListener(`change`,e=>Rd.value=e.matches);var zd=H(()=>Rd.value?q.inspectorOverlay:qu.inspector);function Bd(e){e&&(q.tab=e),Rd.value?(q.drawer=!1,q.inspectorOverlay=!0):qu.inspector=!0}function Vd(){Rd.value?q.inspectorOverlay=!1:qu.inspector=!1}function Hd(){Rd.value?(q.drawer=!q.drawer)&&(q.inspectorOverlay=!1,qu.tree=!0):qu.tree=!qu.tree}function Ud(){zd.value?Vd():Bd()}var Wd=/Mac|iPhone|iPad/.test(navigator.userAgent),Gd=Wd?{tree:`Ctrl+N`,inspector:`Ctrl+T`}:{tree:`Alt+Shift+N`,inspector:`Alt+Shift+T`};function Kd(e){if(!(!(Wd?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 qd={class:`topbar`},Jd={class:`brand`},Yd={class:`daemon`,"data-testid":`topbar-stats`},Xd=[`title`],Zd={class:`top-actions`},Qd={key:0,class:`usage-chip`,title:`This session's token usage and cost`},$d=[`aria-label`,`title`],ef={key:0,class:`bell-dot`},tf={key:0,class:`hint`},nf={class:`when`},rf=[`disabled`],af=[`disabled`],of=M({__name:`TopBar`,emits:[`newSession`],setup(e,{emit:t}){let n=O(!1),r=H(()=>Ed.filter(e=>!e.read).length),i=()=>{n.value=!n.value,n.value&&Od()},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=H(()=>vd.value.input+vd.value.output+vd.value.cacheRead+vd.value.cacheWrite),s=H(()=>(vd.value.inputCost??0)+(vd.value.outputCost??0)+(vd.value.cacheReadCost??0)+(vd.value.cacheWriteCost??0)),c=H(()=>Hu.devices.value.filter(e=>e.status===`online`).length),l=H(()=>Hu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.length??0),0)),u=H(()=>Hu.devices.value.reduce((e,t)=>e+(t.tree?.sessions.reduce((e,t)=>e+t.agents.length,0)??0),0)),d=O(!1);async function f(){let e=id.value,t=K.value;if(!e||!t||d.value)return;d.value=!0;let n=await kd(()=>e.createAgent({name:`Agent ${md.value.length+1}`}));d.value=!1,n&&(ad({...t,agentId:n.id}),J(`New agent. Same session, same shared App State.`))}let p=t;return(e,t)=>(F(),I(`header`,qd,[R(`div`,Jd,[R(`button`,{class:`icon-button tree-toggle`,"aria-label":`Toggle network`,title:`Network`,onClick:t[0]||=e=>k(q).drawer=!k(q).drawer},[z(k(Kc),{size:19})]),t[6]||=R(`img`,{class:`brandmark`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),t[7]||=R(`strong`,null,`Durable Pi`,-1)]),t[15]||=R(`span`,{class:`topbar-sep`,"aria-hidden":`true`},null,-1),R(`div`,Yd,[R(`span`,{class:E([`dot`,{off:!c.value}]),"aria-hidden":`true`},null,2),R(`span`,{class:`network-summary`,title:`${c.value} of ${k(Hu).devices.value.length} devices online`},[z(k(Vc),{size:16}),B(D(c.value)+` of `+D(k(Hu).devices.value.length)+` online`,1)],8,Xd),t[10]||=R(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),R(`span`,null,[R(`b`,null,D(l.value),1),t[8]||=B(` sessions`,-1)]),t[11]||=R(`span`,{class:`sep`,"aria-hidden":`true`},`·`,-1),R(`span`,null,[R(`b`,null,D(u.value),1),t[9]||=B(` agents`,-1)])]),R(`div`,Zd,[R(`span`,{class:E([`chip connection`,{accent:k(Vu)===`live`}])},[R(`span`,{class:E([`dot`,{off:k(Vu)!==`live`}]),"aria-hidden":`true`},null,2),B(D(k(Vu)===`live`?`Connected`:`Reconnecting`),1)],2),o.value?(F(),I(`span`,Qd,D(o.value.toLocaleString())+` tok · $`+D(s.value.toFixed(3)),1)):V(``,!0),R(`button`,{class:`icon-button`,"aria-label":`Notifications${r.value?` (${r.value} unread)`:``}`,title:`Notification center${r.value?` — ${r.value} unread`:``}`,onClick:i},[z(k(Zs),{size:18}),r.value?(F(),I(`i`,ef,D(r.value>9?`9+`:r.value),1)):V(``,!0)],8,$d),n.value?(F(),I(`div`,{key:1,class:`notif-panel`,onClick:t[2]||=As(()=>{},[`stop`])},[R(`header`,null,[t[12]||=R(`b`,null,`Notifications`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close notifications`,onClick:t[1]||=e=>n.value=!1},`✕`)]),k(Ed).length?V(``,!0):(F(),I(`p`,tf,`Nothing yet — events land here as they happen.`)),R(`ul`,null,[(F(!0),I(P,null,N(k(Ed),e=>(F(),I(`li`,{key:e.id,class:E({unread:!e.read})},[R(`span`,nf,D(a(e.at)),1),R(`span`,null,D(e.text),1)],2))),128))])])):V(``,!0),R(`button`,{class:`icon-button`,title:`How this works`,"aria-label":`How this works`,onClick:t[3]||=e=>k(q).dialog={kind:`help`}},[z(k(oc),{size:19})]),R(`button`,{class:`secondary small new-agent-button`,disabled:!k(K)||!k(Zu)||d.value,title:`Start a fresh agent in this session`,onClick:f},[z(k(Zc),{size:18}),t[13]||=B(`New agent `,-1)],8,rf),R(`button`,{class:`primary small`,onClick:t[4]||=e=>p(`newSession`)},[z(k(Zc),{size:18}),t[14]||=B(`New session `,-1)]),R(`button`,{class:`icon-button inspector-toggle`,"aria-label":`Toggle inspector`,title:`Inspector`,disabled:!k(K)||!k(Zu),onClick:t[5]||=e=>k(q).inspectorOverlay?k(Vd)():k(Bd)()},[z(k(qc),{size:19})],8,af)])]))}}),sf=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},cf=sf(of,[[`__scopeId`,`data-v-de526f26`]]),lf={class:`mnav`,"aria-label":`Panels`},uf={key:0,class:`badge`},df=M({__name:`MobileNav`,setup(e){function t(){q.drawer=!1,q.inspectorOverlay=!1}return(e,n)=>(F(),I(`nav`,lf,[R(`button`,{type:`button`,class:E({"is-on":!k(q).drawer&&!k(zd)}),onClick:t},[z(k(Rc),{size:18}),n[2]||=B(`Chat `,-1)],2),R(`button`,{type:`button`,class:E({"is-on":k(zd)}),onClick:n[0]||=e=>k(zd)?k(Vd)():k(Bd)()},[z(k(qc),{size:18}),n[3]||=B(`Details`,-1),k(gd).length?(F(),I(`span`,uf,D(k(gd).length),1)):V(``,!0)],2),R(`button`,{type:`button`,class:E({"is-on":k(q).drawer}),onClick:n[1]||=e=>k(Hd)()},[z(k(_l),{size:18}),n[4]||=B(`Network `,-1)],2)]))}}),ff=[`width`,`height`,`aria-label`],pf=[`width`,`height`,`aria-label`],mf=M({__name:`DeviceIcon`,props:{device:{},size:{default:16}},setup(e){let t=e,n=H(()=>{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=H(()=>{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`?(F(),I(`svg`,{key:0,class:`device-icon exe`,viewBox:`0 0 512 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[R(`title`,null,D(r.value),1),i[0]||=R(`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,ff)):n.value===`apple`?(F(),I(`svg`,{key:1,class:`device-icon apple`,viewBox:`0 0 384 512`,width:e.size,height:e.size,role:`img`,"aria-label":r.value},[R(`title`,null,D(r.value),1),i[1]||=R(`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,pf)):n.value===`laptop`?(F(),L(k(jc),{key:2,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`])):(F(),L(k(al),{key:3,class:`device-icon`,size:e.size,"aria-label":r.value},null,8,[`size`,`aria-label`]))}}),hf=new Map,gf=new Map,_f=2e3;function vf(){for(;hf.size>_f;){let e=hf.keys().next().value;if(e===void 0)break;hf.delete(e)}}function yf(e,t){return Tu(Hu.devices.value.find(t=>t.id===e)?.info,t)}function bf(e,t){if(!yf(e,t))return{ok:!1,reason:`outside the device's start dirs`};let n=Df(e,t);return n.status&&n.status.repo===!1&&Date.now()-n.at<5e3?{ok:!1,reason:`not a git repository`}:{ok:!0}}function xf(e,t){t&&typeof t.error==`string`?(e.status=null,e.error=t.error):(e.status=t??null,e.error=``),e.at=Date.now()}async function Sf(e,t){let n=t.filter(t=>!Of(Df(e,t),Cf)&&yf(e,t));if(n.length){for(let t=0;t<n.length&&t<500;t+=50){let r=n.slice(t,t+50);try{let t=await W(e).gitStatusBatch(r,{timeoutMs:6e4});for(let n of r){let r=t[n];r!==void 0&&xf(Df(e,n),r)}}catch{}}vf()}}var Cf=6e4,wf=!1;function Tf(){wf||(wf=!0,j(()=>Hu.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[...hf.keys()]){let i=r.indexOf(`::`),a=r.slice(0,i),o=r.slice(i+2);if(i<0||!a||a!==n.id||!o)continue;let s=hf.get(r);e.some(e=>o===e.root||o.startsWith(e.root+`/`)||o.startsWith(e.root+`\\`))&&(s.loading||t-s.at<4e3||kf(a,o,{force:!0}))}}}))}var Ef=(e,t)=>`${e}::${t}`;function Df(e,t){let n=Ef(e,t),r=hf.get(n);return r||(r=Gt({at:0,status:null,error:``,loading:!1,refreshing:!1}),hf.set(n,r)),r}var Of=(e,t)=>e.at>0&&Date.now()-e.at<t&&(e.status!==null||e.error);async function kf(e,t,n={}){let{staleMs:r=6e4,force:i=!1,timeoutMs:a=6e4}=n;if(!e||!t)return;let o=Ef(e,t),s=Df(e,t);if(!i&&Of(s,r))return;if(!yf(e,t)){xf(s,{error:`outside the device's start dirs`});return}vf();let c=gf.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 W(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,gf.delete(o)}})();return gf.set(o,l),l}var Af=new Map;function jf(){j(()=>Hu.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 Hu.devices.value){if(e.status!==`online`||!e.tree?.sessions.length)continue;let t=Date.now();t-(Af.get(e.id)??0)<6e4||(Af.set(e.id,t),Sf(e.id,e.tree.sessions.map(e=>e.cwd)))}},{immediate:!0})}var Mf=(e,t)=>Df(e,t).status?.branch,Nf=[`aria-level`,`aria-expanded`,`aria-selected`,`data-key`,`title`],Pf=[`aria-label`],Ff={key:1,class:`chev`},If={class:`name`},Lf={class:`badge`},Rf=[`title`],zf=[`aria-label`],Bf=[`disabled`,`aria-label`],Vf=[`aria-label`],Hf=[`checked`,`aria-label`],Uf={class:`name`},Wf={class:`path`},Gf=[`title`],Kf=[`title`],qf={key:3,class:`dot work`,title:`Working`},Jf=[`title`],Yf=[`disabled`,`aria-label`],Xf=[`disabled`,`aria-label`],Zf=[`disabled`,`aria-label`],Qf=[`disabled`,`aria-label`],$f={class:`name`},ep={key:3,class:`meta`},tp={key:4,class:`dot work`,title:`Working`},np=[`title`],rp=[`disabled`,`aria-label`],ip=sf(M({__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=H(()=>n.node.children.length>0),a=H(()=>n.node.type===`device`?n.node.device:void 0),o=H(()=>n.node.type===`session`?n.node.session:void 0),s=H(()=>n.node.type===`agent`?n.node.agent:void 0),c=H(()=>o.value?o.value.agents.reduce((e,t)=>e+t.background,0):s.value?.background??0),l=H(()=>o.value?.busy||s.value?.busy),u=H(()=>{let e=a.value?.info,t=e?.packageVersion??e?.durableVersion,n=Wu.value;return!!(t&&n&&n!==`unknown`&&t!==n)}),d=H(()=>{let e=a.value?.info;return e?.packageVersion??e?.durableVersion??`?`}),f=H(()=>{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 · ${Pd(e.lastSeenAt)}`}}),p=H(()=>{let e=a.value?.status;return e===`online`?`on`:e===`checking`?`chk`:e===`offline`?`off`:`err`}),m=H(()=>{let e=n.node;return e.type===`session`?Mf(e.deviceId,e.session.cwd):void 0}),h=H(()=>a.value?.name??a.value?.id??o.value?.name??s.value?.name??``),g=H(()=>{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)=>(F(),I(`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?(F(),I(`button`,{key:0,class:`chev`,tabindex:`-1`,"aria-label":e.open?`Collapse ${h.value}`:`Expand ${h.value}`,onClick:n[0]||=As(e=>r(`toggle`),[`stop`])},[e.open?(F(),L(k(rc),{key:0,size:16})):(F(),L(k(ic),{key:1,size:16}))],8,Pf)):(F(),I(`span`,Ff)),a.value?(F(),I(P,{key:2},[R(`i`,{class:E([`dot`,p.value])},null,2),z(mf,{device:a.value,size:16},null,8,[`device`]),R(`b`,If,D(h.value),1),R(`span`,Lf,D(a.value.kind),1),u.value?(F(),I(`span`,{key:0,class:`tag update`,title:`device runs ${d.value}; hub runs ${k(Wu)}. Devices self-update: dpi update`},`update`,8,Rf)):V(``,!0),R(`span`,{class:E([`meta`,{err:p.value===`err`}])},D(f.value),3),R(`span`,{class:`acts`,onClick:n[4]||=As(()=>{},[`stop`])},[a.value.pairing?(F(),I(`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`)},[z(k(Ac),{size:16})],8,zf)):V(``,!0),R(`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`)},[z(k(Zc),{size:16})],8,Bf),R(`button`,{class:`icon-button`,"aria-label":`Check ${h.value}`,title:`Check connection now`,onClick:n[3]||=e=>r(`action`,`check`)},[z(k(el),{size:16})],8,Vf)])],64)):o.value?(F(),I(P,{key:3},[e.checkbox?(F(),I(`input`,{key:0,type:`checkbox`,class:`bulk-check`,checked:e.checked,"aria-label":`Select ${h.value}`,tabindex:`-1`,onClick:n[5]||=As(()=>{},[`stop`]),onChange:n[6]||=e=>r(`check`)},null,40,Hf)):V(``,!0),z(k(bc),{class:`ico`,size:16}),R(`b`,Uf,D(h.value),1),R(`span`,Wf,`…/`+D(o.value.cwd.split(`/`).filter(Boolean).at(-1)),1),m.value?(F(),I(`span`,{key:1,class:`branch`,title:`git branch of ${o.value.cwd}`},`⎇ `+D(m.value),9,Gf)):V(``,!0),o.value.model?(F(),I(`span`,{key:2,class:`tag`,title:o.value.provider?`${o.value.provider} / ${o.value.model}`:o.value.model},D(o.value.model),9,Kf)):V(``,!0),l.value?(F(),I(`i`,qf)):V(``,!0),c.value?(F(),I(`span`,{key:4,class:`bg-count`,title:`${c.value} background task(s)`},[n[15]||=R(`i`,{class:`dot bg`},null,-1),B(D(c.value)+` bg`,1)],8,Jf)):V(``,!0),R(`span`,{class:`acts`,onClick:n[11]||=As(()=>{},[`stop`])},[R(`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`)},[z(k(Zc),{size:16})],8,Yf),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename session ${h.value}`,title:`Rename session`,onClick:n[8]||=e=>r(`action`,`rename`)},[z(k(Jc),{size:16})],8,Xf),R(`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`)},[z(k(dl),{size:16})],8,Zf),R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Archive session ${h.value}`,title:`Archive session`,onClick:n[10]||=e=>r(`action`,`archive`)},[z(k(Ws),{size:16})],8,Qf)])],64)):s.value?(F(),I(P,{key:4},[s.value.kind===`fork`?(F(),L(k(wc),{key:0,class:`ico`,size:16})):s.value.kind===`subagent`?(F(),L(k(lc),{key:1,class:`ico`,size:16})):(F(),L(k(Rc),{key:2,class:`ico root`,size:16})),R(`span`,$f,D(h.value),1),s.value.kind===`fork`&&s.value.forkedAt!==void 0?(F(),I(`span`,ep,`@ #`+D(s.value.forkedAt),1)):V(``,!0),l.value?(F(),I(`i`,tp)):V(``,!0),c.value?(F(),I(`span`,{key:5,class:`bg-count`,title:`${c.value} background task(s)`},[n[16]||=R(`i`,{class:`dot bg`},null,-1),B(D(c.value),1)],8,np)):V(``,!0),R(`span`,{class:`acts`,onClick:n[13]||=As(()=>{},[`stop`])},[R(`button`,{class:`icon-button`,disabled:!e.online,"aria-label":`Rename agent ${h.value}`,title:`Rename agent`,onClick:n[12]||=e=>r(`action`,`rename`)},[z(k(Jc),{size:16})],8,rp)])],64)):V(``,!0)],14,Nf))}}),[[`__scopeId`,`data-v-ec99cf9d`]]),ap={class:`project-bar`,"aria-label":`Projects`},op={class:`project-head`},sp={class:`project-title`},cp=[`aria-label`,`title`],lp={key:0,class:`project-hint`},up={key:0,class:`chips`},dp=[`title`,`onClick`,`onDblclick`],fp={class:`chip-name`},pp={class:`chip-count`},mp={key:1,class:`project-hint`},hp={key:2,class:`project-actions`},gp=[`onClick`],_p=[`onClick`],vp=[`onClick`],yp=[`onClick`],bp={key:3,class:`message-error`},xp={key:4,class:`project-hint labels-hint`},Sp=sf(M({__name:`ProjectBar`,props:{active:{},activeModifiers:{}},emits:[`update:active`],setup(e,{expose:t}){let n=Oi(e,`active`),r=O([]),i=O(!1),a=O(``),o=O(!1),s=H(()=>Hu.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=Hu.devices.value.find(e=>e.id===n),i=await W(n).projects(o.value).catch(e=>{let r=G(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}j([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;q.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 W(e.deviceId).updateProject(t.id,{customName:n});J(`Project renamed to ${r.customName??r.name}.`),await c()}}}function p(e){let t=e.project;q.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 W(e.deviceId).updateProject(t.id,{labels:n.split(`,`).map(e=>e.trim()).filter(Boolean)});J(r.labels.length?`Labels: ${r.labels.join(`, `)}.`:`Labels cleared on ${l(r)}.`),await c()}}}function m(e){let t=e.project,n=Hu.devices.value.find(t=>t.id===e.deviceId)?.info?.models??[];q.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 W(e.deviceId).updateProject(t.id,{model:``}),J(`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 W(e.deviceId).updateProject(t.id,{model:{provider:i,modelId:o}}),J(`New sessions in ${l(t)} start on ${o}.`),await c()}}}function h(e){let t=e.project,r=t.archivedAt!==null;q.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=W(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)=>(F(),I(`div`,ap,[R(`div`,op,[R(`span`,sp,[z(k(yc),{size:13}),t[2]||=B(`PROJECTS`,-1)]),R(`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},[z(k(Ws),{size:12})],10,cp),i.value?(F(),I(`span`,lp,`…`)):V(``,!0)]),r.value.length?(F(),I(`div`,up,[(F(!0),I(P,null,N(r.value,e=>(F(),I(`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`?(F(),L(k(xc),{key:0,size:11})):(F(),L(k(yc),{key:1,size:11})),R(`span`,fp,D(l(e.project)),1),R(`em`,pp,D(e.sessions),1),(F(!0),I(P,null,N(e.project.labels.slice(0,2),e=>(F(),I(`span`,{key:e,class:`chip-label`},D(e),1))),128))],42,dp))),128))])):i.value?V(``,!0):(F(),I(`p`,mp,` No projects yet — a project appears when a session starts in a folder. `)),n.value?(F(),I(`div`,hp,[t[5]||=R(`span`,{class:`project-hint`},`filtering`,-1),(F(!0),I(P,null,N(r.value.filter(u),e=>(F(),I(P,{key:e.project.id},[R(`button`,{class:`small`,onClick:t=>f(e)},[z(k(Jc),{size:12}),t[3]||=B(`name`,-1)],8,gp),R(`button`,{class:`small`,onClick:t=>p(e)},[z(k(pl),{size:12}),t[4]||=B(`labels`,-1)],8,_p),R(`button`,{class:`small`,onClick:t=>m(e),title:`Default model for new sessions in this project`},[z(k(fc),{size:12}),B(D(e.project.model?`model ✓`:`model`),1)],8,vp),R(`button`,{class:`small`,onClick:t=>h(e)},[e.project.archivedAt?(F(),L(k(Us),{key:0,size:12})):(F(),L(k(Ws),{key:1,size:12})),B(` `+D(e.project.archivedAt?`restore`:`archive`),1)],8,yp),R(`button`,{class:`icon-button tiny`,"aria-label":`Clear project filter`,onClick:t[1]||=e=>n.value=void 0},[z(k(Sl),{size:12})])],64))),128))])):V(``,!0),a.value?(F(),I(`p`,bp,D(a.value),1)):V(``,!0),r.value.some(e=>e.project.labels.length)?(F(),I(`p`,xp,[z(k(pl),{size:11}),B(`labels: `+D([...new Set(r.value.flatMap(e=>e.project.labels))].join(` · `)),1)])):V(``,!0)]))}}),[[`__scopeId`,`data-v-77864963`]]);function Cp(e,t){return`${e.slice(0,e.lastIndexOf(`/`))}/${e.slice(e.lastIndexOf(`/`)+1)}-${t.replace(/[/\\]+/g,`-`)}`}async function wp(e,t,n,r){let i=Cp(n,r);return{target:i,text:(await e.gitOp(t,`worktree-add`,{branch:r,target:i})).text.split(`
16
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 Ep({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 wp(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 Dp={class:`tree-head`},Op=[`aria-label`,`title`],kp=[`title`],Ap={class:`tree-search`},jp={key:1,class:`searching`,"aria-label":`Searching devices`},Mp={key:0,class:`bulk-bar`},Np=[`disabled`],Pp=[`disabled`],Fp={class:`hit-head hint`},Ip=[`title`,`onClick`],Lp={class:`hit-name`},Rp={class:`hit-cwd`},zp={key:0,class:`hit-where`},Bp=[`title`],Vp={key:2,class:`hint tree-empty`},Hp={key:3,class:`hint tree-empty`,"data-testid":`tree-empty`},Up={key:1,class:`panel-rail`,"aria-label":`Network (collapsed)`},Wp=[`title`],Gp=[`title`,`aria-label`,`onClick`],Kp=sf(M({__name:`NetworkSidebar`,setup(e){let t=H(()=>{let e=[],t=(n,r,i)=>{for(let a of n)e.push({node:a,depth:r,parent:i}),a.children.length&&Gu.value.has(a.key)&&t(a.children,r+1,a.key)};return t(Hu.tree.value,0),e}),n=O(),r=O(),i=O(``),a=O([]),o=O(!1),s=H(()=>i.value.trim().toLowerCase()),c=H(()=>s.value.length>=2),l=H(()=>{let e=new Set;if(!c.value)return e;for(let t of Hu.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=O(),d=(e,t)=>!u.value||u.value.deviceId===e&&(t===u.value.rootPath||t.startsWith(`${u.value.rootPath}/`)),f=H(()=>{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=Hu.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=H(()=>a.value.filter(e=>!t.value.some(t=>t.node.type===`session`&&t.node.session.id===e.id))),m,h=0;j(i,e=>{clearTimeout(m);let t=e.trim();if(t.length<2){++h,a.value=[],o.value=!1;return}m=setTimeout(async()=>{o.value=!0;let e=++h,n=[];for(let r of Hu.devices.value.filter(e=>e.status===`online`)){let i=await W(r.id).searchSessions(t,`all`).catch(()=>void 0);if(e!==h)return;for(let e of i?.matches??[])n.push({deviceId:r.id,id:e.id,name:e.name,cwd:e.cwd,where:e.where,hits:e.hits??[]})}a.value=n,o.value=!1},250)});let g=()=>(i.value=``,++h,a.value=[]),_=O(!1),v=O(new Set),y=O(``),b=e=>{if(e.type!==`session`)return;let t=new Set(v.value);t.has(e.session.id)?t.delete(e.session.id):t.add(e.session.id),v.value=t},x=async e=>{y.value=e;let n=0,r=[];for(let i of t.value.map(e=>e.node)){if(i.type!==`session`||!v.value.has(i.session.id))continue;let t=S(i);if(!t)continue;let a=W(t.id);try{e===`archive`?await a.session(i.session.id).archive():await a.agent(i.session.id,1).abort(!0),n++,e===`archive`&&K.value?.sessionId===i.session.id&&ad(void 0)}catch{r.push(i.session.name)}}J(`${e}: ${n} done${r.length?`, ${r.length} failed (${r.slice(0,3).join(`, `)})`:``}`),v.value=new Set,y.value=``},S=e=>Hu.devices.value.find(t=>t.id===(e.type===`device`?e.device.id:e.deviceId)),C=e=>S(e)?.status===`online`,ee=e=>e.type===`agent`&&K.value?.deviceId===e.deviceId&&K.value.sessionId===e.sessionId&&K.value.agentId===e.agent.id;function w(e){if(n.value=e.key,_.value&&e.type===`session`)return b(e);if(e.type===`device`)return cd(e.key);if(e.type===`agent`)return ad({deviceId:e.deviceId,sessionId:e.sessionId,agentId:e.agent.id});let t=e.session.agents.find(e=>e.kind===`root`)??e.session.agents[0];cd(e.key,!0),t&&ad({deviceId:e.deviceId,sessionId:e.session.id,agentId:t.id})}async function te(e,t){let n=S(e);if(!n)return;let r=W(n.id);if(e.type===`device`){t===`new-session`?q.dialog={kind:`new-session`,deviceId:n.id}:t===`check`?await kd(()=>Au.check(n.id)):t===`credentials`&&(q.dialog={kind:`credentials`,deviceId:n.id});return}if(e.type===`session`){let i=e.session;if(t===`new-agent`){let e=await kd(()=>r.session(i.id).createAgent({name:`Agent ${i.agents.length+1}`}));e&&(ad({deviceId:n.id,sessionId:i.id,agentId:e.id}),J(`New agent. Same session, same shared App State.`))}else t===`rename`?q.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`?q.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 Ep({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];ad({deviceId:n.id,sessionId:t.id,agentId:a?.id??1}),J(`session "${t.name}" on ${t.cwd}`)}}:t===`archive`&&(q.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(),K.value?.sessionId===i.id&&ad(void 0)}});return}let i=e.agent;t===`rename`&&(q.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 ne(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,jn(()=>r.value?.querySelector(`[data-key="${CSS.escape(a.node.key)}"]`)?.scrollIntoView({block:`nearest`})))}function re(){n.value??=t.value[0]?.node.key}function ie(e){let r=t.value.find(e=>e.node.key===n.value);if(e.key===`ArrowDown`)ne(1);else if(e.key===`ArrowUp`)ne(-1);else if(e.key===`ArrowRight`&&r){if(!r.node.children.length)return;Gu.value.has(r.node.key)?ne(1):cd(r.node.key,!0)}else if(e.key===`ArrowLeft`&&r)r.node.children.length&&Gu.value.has(r.node.key)?cd(r.node.key,!1):r.parent&&(n.value=r.parent);else if((e.key===`Enter`||e.key===` `)&&r)w(r.node);else return;e.preventDefault()}return(e,a)=>(F(),I(`aside`,{class:E([`network-sidebar`,{open:k(q).drawer,collapsed:!k(qu).tree&&!k(q).drawer}]),"aria-label":`Network`},[k(qu).tree||k(q).drawer?(F(),I(P,{key:0},[R(`header`,Dp,[R(`span`,null,[z(k(Vc),{size:16}),a[8]||=B(`NETWORK`,-1)]),R(`button`,{class:E([`icon-button`,{on:_.value}]),"aria-label":_.value?`Exit bulk select`:`Bulk manage sessions`,title:_.value?`Exit bulk select`:`Bulk manage sessions (select → archive / abort)`,onClick:a[0]||=e=>(_.value=!_.value,v.value=new Set)},[z(k(Fc),{size:15})],10,Op),R(`button`,{class:`icon-button`,"aria-label":`Pair a device`,title:`Pair a device`,onClick:a[1]||=e=>k(q).dialog={kind:`pair`}},[z(k(Pc),{size:15})]),R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse network`,title:`Collapse network (${k(Gd).tree})`,onClick:a[2]||=e=>(k(qu).tree=!1,k(q).drawer=!1)},[z(k(Wc),{size:18})],8,kp)]),R(`div`,Ap,[z(k(rl),{size:14,class:`search-icon`}),A(R(`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),[[bs,i.value]]),i.value?(F(),I(`button`,{key:0,class:`icon-button clear`,"aria-label":`Clear search`,onClick:g},[z(k(Sl),{size:13})])):V(``,!0),o.value?(F(),I(`span`,jp,`…`)):V(``,!0)]),z(Sp,{active:u.value,"onUpdate:active":a[4]||=e=>u.value=e},null,8,[`active`]),R(`div`,{ref_key:`list`,ref:r,class:`tree-list`,role:`tree`,tabindex:`0`,"aria-label":`Devices, sessions and agents`,onKeydown:ie,onFocus:re},[_.value&&v.value.size?(F(),I(`div`,Mp,[R(`span`,null,D(v.value.size)+` selected`,1),R(`button`,{class:`small`,disabled:!!y.value,onClick:a[5]||=e=>x(`abort`)},`abort work`,8,Np),R(`button`,{class:`small danger`,disabled:!!y.value,onClick:a[6]||=e=>x(`archive`)},D(y.value===`archive`?`archiving…`:`archive`),9,Pp)])):V(``,!0),(F(!0),I(P,null,N(f.value,e=>(F(),L(ip,{key:e.node.key,node:e.node,depth:e.depth,open:k(Gu).has(e.node.key),selected:ee(e.node),focused:n.value===e.node.key,online:C(e.node),checkbox:_.value&&e.node.type===`session`,checked:e.node.type===`session`&&v.value.has(e.node.session.id),onToggle:t=>k(cd)(e.node.key),onActivate:t=>w(e.node),onAction:t=>te(e.node,t),onCheck:t=>b(e.node)},null,8,[`node`,`depth`,`open`,`selected`,`focused`,`online`,`checkbox`,`checked`,`onToggle`,`onActivate`,`onAction`,`onCheck`]))),128)),c.value&&p.value.length?(F(),I(P,{key:1},[R(`div`,Fp,D(p.value.length)+` more on device`,1),(F(!0),I(P,null,N(p.value,e=>(F(),I(`button`,{key:`${e.deviceId}-${e.id}`,class:`hit`,title:e.cwd,onClick:t=>k(ad)({deviceId:e.deviceId,sessionId:e.id,agentId:1})},[R(`span`,Lp,D(e.name),1),R(`code`,Rp,D(e.cwd),1),e.where.length?(F(),I(`em`,zp,D(e.where.join(` · `)),1)):V(``,!0),e.hits.length?(F(),I(`em`,{key:1,class:`hit-line`,title:e.hits.map(e=>`${e.agent} #${e.entry}: ${e.text}`).join(`
17
17
  `)},D(e.hits[0].agent)+` #`+D(e.hits[0].entry)+` · `+D(e.hits[0].text.slice(0,90)),9,Bp)):V(``,!0)],8,Ip))),128))],64)):V(``,!0),c.value&&!f.value.length&&!p.value.length?(F(),I(`p`,Vp,` No session matches “`+D(i.value.trim())+`”. `,1)):V(``,!0),!t.value.length&&!c.value?(F(),I(`p`,Hp,[...a[9]||=[B(` No devices yet. Declare them in `,-1),R(`code`,null,`dpi-network.yaml`,-1),B(` (start from `,-1),R(`code`,null,`dpi-network.example.yaml`,-1),B(`), then run `,-1),R(`code`,null,`just net up <id>`,-1),B(`. `,-1)]])):V(``,!0)],544)],64)):(F(),I(`div`,Up,[R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand network`,title:`Expand network (${k(Gd).tree})`,onClick:a[7]||=e=>k(qu).tree=!0},[z(k(Gc),{size:18})],8,Wp),(F(!0),I(P,null,N(k(Hu).devices.value,e=>(F(),I(`button`,{key:e.id,class:`rail-device`,title:`${e.id} · ${e.status}`,"aria-label":`Show ${e.id}`,onClick:t=>(k(qu).tree=!0,k(cd)(e.id,!0))},[z(mf,{device:e,size:20},null,8,[`device`]),R(`i`,{class:E([`dot`,e.status===`online`?`on`:e.status===`checking`?`chk`:e.status===`offline`?`off`:`err`])},null,2)],8,Gp))),128))]))],2))}}),[[`__scopeId`,`data-v-f78dbc9c`]]);function qp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Jp=qp();function Yp(e){Jp=e}var Xp={exec:()=>null};function Zp(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($p.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Qp=(()=>{try{return!0}catch{return!1}})(),$p={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)}}>`)},em=/^(?:[ \t]*(?:\n|$))+/,tm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,nm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,rm=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,im=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,am=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,om=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,sm=Zp(om).replace(/bull/g,am).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(),cm=Zp(om).replace(/bull/g,am).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(),lm=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,um=/^[^\n]+/,dm=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,fm=Zp(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,dm).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),pm=Zp(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,am).getRegex(),mm=`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`,hm=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,gm=Zp(`^ {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`,hm).replace(`tag`,mm).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_m=Zp(lm).replace(`hr`,rm).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`,mm).getRegex(),vm={blockquote:Zp(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,_m).getRegex(),code:tm,def:fm,fences:nm,heading:im,hr:rm,html:gm,lheading:sm,list:pm,newline:em,paragraph:_m,table:Xp,text:um},ym=Zp(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,rm).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`,mm).getRegex(),bm={...vm,lheading:cm,table:ym,paragraph:Zp(lm).replace(`hr`,rm).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,ym).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`,mm).getRegex()},xm={...vm,html:Zp(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,hm).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:Xp,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Zp(lm).replace(`hr`,rm).replace(`heading`,` *#{1,6} *[^
18
18
  ]`).replace(`lheading`,sm).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Sm=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Cm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,wm=/^( {2,}|\\)\n(?!\s*$)/,Tm=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Em=/[\p{P}\p{S}]/u,Dm=/[\s\p{P}\p{S}]/u,Om=/[^\s\p{P}\p{S}]/u,km=Zp(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Dm).getRegex(),Am=/(?!~)[\p{P}\p{S}]/u,jm=/(?!~)[\s\p{P}\p{S}]/u,Mm=/(?:[^\s\p{P}\p{S}]|~)/u,Nm=Zp(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Qp?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Pm=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Fm=Zp(Pm,`u`).replace(/punct/g,Em).getRegex(),Im=Zp(Pm,`u`).replace(/punct/g,Am).getRegex(),Lm=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Rm=Zp(Lm,`gu`).replace(/notPunctSpace/g,Om).replace(/punctSpace/g,Dm).replace(/punct/g,Em).getRegex(),zm=Zp(Lm,`gu`).replace(/notPunctSpace/g,Mm).replace(/punctSpace/g,jm).replace(/punct/g,Am).getRegex(),Bm=Zp(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Om).replace(/punctSpace/g,Dm).replace(/punct/g,Em).getRegex(),Vm=Zp(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Em).getRegex(),Hm=Zp(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Om).replace(/punctSpace/g,Dm).replace(/punct/g,Em).getRegex(),Um=Zp(/\\(punct)/,`gu`).replace(/punct/g,Em).getRegex(),Wm=Zp(/^<(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(),Gm=Zp(hm).replace(`(?:-->|$)`,`-->`).getRegex(),Km=Zp(`^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`,Gm).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qm=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Jm=Zp(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,qm).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ym=Zp(/^!?\[(label)\]\[(ref)\]/).replace(`label`,qm).replace(`ref`,dm).getRegex(),Xm=Zp(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,dm).getRegex(),Zm=Zp(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Ym).replace(`nolink`,Xm).getRegex(),Qm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,$m={_backpedal:Xp,anyPunctuation:Um,autolink:Wm,blockSkip:Nm,br:wm,code:Cm,del:Xp,delLDelim:Xp,delRDelim:Xp,emStrongLDelim:Fm,emStrongRDelimAst:Rm,emStrongRDelimUnd:Bm,escape:Sm,link:Jm,nolink:Xm,punctuation:km,reflink:Ym,reflinkSearch:Zm,tag:Km,text:Tm,url:Xp},eh={...$m,link:Zp(/^!?\[(label)\]\((.*?)\)/).replace(`label`,qm).getRegex(),reflink:Zp(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,qm).getRegex()},th={...$m,emStrongRDelimAst:zm,emStrongLDelim:Im,delLDelim:Vm,delRDelim:Hm,url:Zp(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Qm).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:Zp(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Qm).getRegex()},nh={...th,br:Zp(wm).replace(`{2,}`,`*`).getRegex(),text:Zp(th.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},rh={normal:vm,gfm:bm,pedantic:xm},ih={normal:$m,gfm:th,breaks:nh,pedantic:eh},ah={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},oh=e=>ah[e];function sh(e,t){if(t){if($p.escapeTest.test(e))return e.replace($p.escapeReplace,oh)}else if($p.escapeTestNoEncode.test(e))return e.replace($p.escapeReplaceNoEncode,oh);return e}function ch(e){try{e=encodeURI(e).replace($p.percentDecode,`%`)}catch{return null}return e}function lh(e,t){let n=e.replace($p.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split($p.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($p.slashPipe,`|`);return n}function uh(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 dh(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 fh(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 ph(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 mh(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
@@ -74,9 +74,9 @@ ${e}</tr>
74
74
  `}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>${sh(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=ch(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+sh(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=ch(e);if(i===null)return sh(n);e=i;let a=`<img src="${e}" alt="${sh(n)}"`;return t&&(a+=` title="${sh(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:sh(e.text)}},vh=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}},yh=class e{options;renderer;textRenderer;constructor(e){this.options=e||Jp,this.options.renderer=this.options.renderer||new _h,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vh}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}},bh=class{options;block;constructor(e){this.options=e||Jp}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?gh.lex:gh.lexInline}provideParser(e=this.block){return e?yh.parse:yh.parseInline}},xh=new class{defaults=qp();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=yh;Renderer=_h;TextRenderer=vh;Lexer=gh;Tokenizer=hh;Hooks=bh;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 _h(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 hh(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 bh;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]=bh.passThroughHooks.has(n)?e=>{if(this.defaults.async&&bh.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 gh.lex(e,t??this.defaults)}parser(e,t){return yh.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?gh.lex:gh.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?yh.parse:yh.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?gh.lex:gh.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?yh.parse:yh.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+=`
75
75
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+sh(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Sh(e,t){return xh.parse(e,t)}Sh.options=Sh.setOptions=function(e){return xh.setOptions(e),Sh.defaults=xh.defaults,Yp(Sh.defaults),Sh},Sh.getDefaults=qp,Sh.defaults=Jp,Sh.use=function(...e){return xh.use(...e),Sh.defaults=xh.defaults,Yp(Sh.defaults),Sh},Sh.walkTokens=function(e,t){return xh.walkTokens(e,t)},Sh.parseInline=xh.parseInline,Sh.Parser=yh,Sh.parser=yh.parse,Sh.Renderer=_h,Sh.TextRenderer=vh,Sh.Lexer=gh,Sh.lexer=gh.lex,Sh.Tokenizer=hh,Sh.Hooks=bh,Sh.parse=Sh,Sh.options,Sh.setOptions,Sh.use,Sh.walkTokens,Sh.parseInline,yh.parse,gh.lex;function Ch(e,t){this.v=e,this.k=t}function wh(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 Eh(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 Dh(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
76
76
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oh(e,t){return Th(e)||Eh(e,t)||kh(e,t)||Dh()}function kh(e,t){if(e){if(typeof e==`string`)return wh(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)?wh(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 Ch;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 jh=Object.entries,Mh=Object.setPrototypeOf,Nh=Object.isFrozen,Ph=Object.getPrototypeOf,Fh=Object.getOwnPropertyDescriptor,Ih=Object.freeze,Lh=Object.seal,Rh=Object.create,zh=typeof Reflect<`u`&&Reflect,Bh=zh.apply,Vh=zh.construct;Ih||=function(e){return e},Lh||=function(e){return e},Bh||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Vh||=function(e){return new e(...[...arguments].slice(1))};var Hh=cg(Array.prototype.forEach);Array.prototype.indexOf;var Uh=cg(Array.prototype.lastIndexOf),Wh=cg(Array.prototype.pop),Gh=cg(Array.prototype.push);Array.prototype.slice;var Kh=cg(Array.prototype.splice),qh=Array.isArray,Jh=cg(String.prototype.toLowerCase),Yh=cg(String.prototype.toString),Xh=cg(String.prototype.match),Zh=cg(String.prototype.replace),Qh=cg(String.prototype.indexOf),$h=cg(String.prototype.trim),eg=cg(Number.prototype.toString),tg=cg(Boolean.prototype.toString),ng=typeof BigInt>`u`?null:cg(BigInt.prototype.toString),rg=typeof Symbol>`u`?null:cg(Symbol.prototype.toString),ig=cg(Object.prototype.hasOwnProperty),ag=cg(Object.prototype.toString),og=cg(RegExp.prototype.test),sg=lg(TypeError);function cg(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return Bh(e,t,n)}}function lg(e){return function(){return Vh(e,[...arguments])}}function ug(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jh;if(Mh&&Mh(e,null),!qh(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Nh(t)||(t[r]=e),i=e)}e[i]=!0}return e}function dg(e){for(let t=0;t<e.length;t++)ig(e,t)||(e[t]=null);return e}function fg(e){let t=Rh(null);for(let r of jh(e)){var n=Oh(r,2);let i=n[0],a=n[1];ig(e,i)&&(t[i]=qh(a)?dg(a):a&&typeof a==`object`&&a.constructor===Object?fg(a):a)}return t}function pg(e){switch(typeof e){case`string`:return e;case`number`:return eg(e);case`boolean`:return tg(e);case`bigint`:return ng?ng(e):`0`;case`symbol`:return rg?rg(e):`Symbol()`;case`undefined`:return ag(e);case`function`:case`object`:{if(e===null)return ag(e);let t=e,n=mg(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:ag(e)}return ag(e)}default:return ag(e)}}function mg(e,t){for(;e!==null;){let n=Fh(e,t);if(n){if(n.get)return cg(n.get);if(typeof n.value==`function`)return cg(n.value)}e=Ph(e)}function n(){return null}return n}function hg(e){try{return og(e,``),!0}catch{return!1}}var gg=Ih(`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(`.`)),_g=Ih(`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(`.`)),vg=Ih([`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`]),yg=Ih([`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`]),bg=Ih(`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(`.`)),xg=Ih([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Sg=Ih([`#text`]),Cg=Ih(`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(`.`)),wg=Ih(`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=Ih(`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(`.`)),Eg=Ih([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Dg=Lh(/{{[\w\W]*|^[\w\W]*}}/g),Og=Lh(/<%[\w\W]*|^[\w\W]*%>/g),kg=Lh(/\${[\w\W]*/g),Ag=Lh(/^data-[\-\w.\u00B7-\uFFFF]+$/),jg=Lh(/^aria-[\-\w]+$/),Mg=Lh(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ng=Lh(/^(?:\w+script|data):/i),Pg=Lh(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Fg=Lh(/^html$/i),Ig=Lh(/^[a-z][.\w]*(-[.\w]+)+$/i),Lg=Lh(/<[/\w!]/g),Rg=Lh(/<[/\w]/g),zg=Lh(/<\/no(script|embed|frames)/i),Bg=Lh(/\/>/i),Vg={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Hg=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],Ug=Ih(ug({},Hg)),Wg=function(){let e={};return Hh(Hg,t=>{e[t]=Lh(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),Ih(e)}(),Gg=function(){return typeof window>`u`?null:window},Kg=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}},qg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Jg=function(e,t,n,r){return ig(e,t)&&qh(e[t])?ug(r.base?fg(r.base):{},e[t],r.transform):n},Yg=function(e,t,n){let r=ig(e,t)?e[t]:void 0;return r&&typeof r==`object`?fg(r):n()};function Xg(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Gg(),t=e=>Xg(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==Vg.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=mg(d,`cloneNode`),p=mg(d,`remove`),m=mg(d,`removeAttributeNode`),h=mg(d,`nextSibling`),g=mg(d,`childNodes`),_=mg(d,`parentNode`),v=mg(d,`shadowRoot`),y=mg(d,`attributes`),b=o&&o.prototype?mg(o.prototype,`nodeType`):null,x=o&&o.prototype?mg(o.prototype,`nodeName`):null,S=o&&o.prototype?mg(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,te=``,ne,re=!1,ie=0,ae=function(){if(ie>0)throw sg(`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.`)},oe=function(e){ae(),ie++;try{return w.createHTML(e)}finally{ie--}},se=function(e){ae(),ie++;try{return w.createScriptURL(e)}finally{ie--}},ce=function(){return re||=(ne=Kg(u,i),!0),ne},le=n,T=le.implementation,ue=le.createNodeIterator,de=le.createDocumentFragment,fe=le.getElementsByTagName,pe=r.importNode,me=qg();t.isSupported=typeof jh==`function`&&typeof _==`function`&&T&&T.createHTMLDocument!==void 0;let he=Dg,ge=Og,_e=kg,ve=Ag,ye=jg,be=Ng,E=Pg,xe=Ig,Se=Mg,Ce=null,we=ug({},[...gg,..._g,...vg,...bg,...Sg]),Te=null,Ee=ug({},[...Cg,...wg,...Tg,...Eg]),De=Object.seal(Rh(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(Rh(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,Ie=!1,Le=!1,Re=null,ze=null,Be=!1,Ve=!1,He=!1,Ue=!1,We=!0,Ge=!1,Ke=`user-content-`,qe=!0,Je=!1,Ye={},Xe=null,Ze=ug({},`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(`.`)),Qe=null,$e=ug({},[`audio`,`video`,`img`,`source`,`image`,`track`]),et=null,tt=ug({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),nt=`http://www.w3.org/1998/Math/MathML`,rt=`http://www.w3.org/2000/svg`,it=`http://www.w3.org/1999/xhtml`,at=it,ot=!1,st=null,ct=ug({},[nt,rt,it],Yh),lt=Ih([`mi`,`mo`,`mn`,`ms`,`mtext`]),ut=ug({},lt),dt=Ih([`annotation-xml`]),ft=ug({},dt),pt=ug({},[`title`,`style`,`font`,`a`,`script`]),mt=null,ht=[`application/xhtml+xml`,`text/html`],gt=null,_t=null,vt=n.createElement(`form`),yt=function(e){return e instanceof RegExp||e instanceof Function},bt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(_t&&_t===e)return;(!e||typeof e!=`object`)&&(e={}),e=fg(e),mt=ht.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,gt=mt===`application/xhtml+xml`?Yh:Jh,Ce=Jg(e,`ALLOWED_TAGS`,we,{transform:gt}),Te=Jg(e,`ALLOWED_ATTR`,Ee,{transform:gt}),st=Jg(e,`ALLOWED_NAMESPACES`,ct,{transform:Yh}),et=Jg(e,`ADD_URI_SAFE_ATTR`,tt,{transform:gt,base:tt}),Qe=Jg(e,`ADD_DATA_URI_TAGS`,$e,{transform:gt,base:$e}),Xe=Jg(e,`FORBID_CONTENTS`,Ze,{transform:gt}),Oe=Jg(e,`FORBID_TAGS`,fg({}),{transform:gt}),ke=Jg(e,`FORBID_ATTR`,fg({}),{transform:gt}),Ye=ig(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?fg(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,Ie=e.WHOLE_DOCUMENT||!1,Ve=e.RETURN_DOM||!1,He=e.RETURN_DOM_FRAGMENT||!1,Ue=e.RETURN_TRUSTED_TYPE||!1,Be=e.FORCE_BODY||!1,We=e.SANITIZE_DOM!==!1,Ge=e.SANITIZE_NAMED_PROPS||!1,qe=e.KEEP_CONTENT!==!1,Je=e.IN_PLACE||!1,Se=hg(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Mg,at=typeof e.NAMESPACE==`string`?e.NAMESPACE:it,ut=Yg(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>ug({},lt)),ft=Yg(e,`HTML_INTEGRATION_POINTS`,()=>ug({},dt));let t=Yg(e,`CUSTOM_ELEMENT_HANDLING`,()=>Rh(null));if(De=Rh(null),ig(t,`tagNameCheck`)&&yt(t.tagNameCheck)&&(De.tagNameCheck=t.tagNameCheck),ig(t,`attributeNameCheck`)&&yt(t.attributeNameCheck)&&(De.attributeNameCheck=t.attributeNameCheck),ig(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(De.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),Lh(De),Pe&&(je=!1),He&&(Ve=!0),Ye&&(Ce=ug({},Sg),Te=Rh(null),Ye.html===!0&&(ug(Ce,gg),ug(Te,Cg)),Ye.svg===!0&&(ug(Ce,_g),ug(Te,wg),ug(Te,Eg)),Ye.svgFilters===!0&&(ug(Ce,vg),ug(Te,wg),ug(Te,Eg)),Ye.mathMl===!0&&(ug(Ce,bg),ug(Te,Tg),ug(Te,Eg))),Ae.tagCheck=null,Ae.attributeCheck=null,ig(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Ae.tagCheck=e.ADD_TAGS:qh(e.ADD_TAGS)&&(Ce===we&&(Ce=fg(Ce)),ug(Ce,e.ADD_TAGS,gt))),ig(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Ae.attributeCheck=e.ADD_ATTR:qh(e.ADD_ATTR)&&(Te===Ee&&(Te=fg(Te)),ug(Te,e.ADD_ATTR,gt))),ig(e,`ADD_FORBID_CONTENTS`)&&qh(e.ADD_FORBID_CONTENTS)&&(Xe===Ze&&(Xe=fg(Xe)),ug(Xe,e.ADD_FORBID_CONTENTS,gt)),qe&&(Ce[`#text`]=!0),Ie&&ug(Ce,[`html`,`head`,`body`]),Ce.table&&(ug(Ce,[`tbody`]),delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw sg(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw sg(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=w;w=e.TRUSTED_TYPES_POLICY;try{te=oe(``)}catch(e){throw w=t,e}}else e.TRUSTED_TYPES_POLICY===null?(w=void 0,te=``):(w===void 0&&(w=ce()),w&&typeof te==`string`&&(te=oe(``)));Ih&&Ih(e),_t=e},xt=ug({},[..._g,...vg,...yg]),St=ug({},[...bg,...xg]),Ct=function(e,t,n){return t.namespaceURI===it?e===`svg`:t.namespaceURI===nt?e===`svg`&&(n===`annotation-xml`||ut[n]):!!xt[e]},wt=function(e,t,n){return t.namespaceURI===it?e===`math`:t.namespaceURI===rt?e===`math`&&ft[n]:!!St[e]},Tt=function(e,t,n){return t.namespaceURI===rt&&!ft[n]||t.namespaceURI===nt&&!ut[n]?!1:!St[e]&&(pt[e]||!xt[e])},Et=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:at,tagName:`template`});let n=Jh(e.tagName),r=Jh(t.tagName);return st[e.namespaceURI]?e.namespaceURI===rt?Ct(n,t,r):e.namespaceURI===nt?wt(n,t,r):e.namespaceURI===it?Tt(n,t,r):!!(mt===`application/xhtml+xml`&&st[e.namespaceURI]):!1},Dt=function(e){Gh(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw sg(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Ot=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},kt=function(e){Mt(e);let t=g(e);if(t){let e=[];Hh(t,t=>{Gh(e,t)}),Hh(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`&&Ot(e,r,i)}},At=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}Gh(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(Ve||He)try{Dt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},jt=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[gt(i)]||Ot(e,r,i)}},Mt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===Vg.element&&jt(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Nt=function(e,t){return Fe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Pt=function(e){if(!Fe)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===Vg.processingInstruction||n===Vg.comment&&og(Rg,e.data)){try{p(e)}catch{}continue}if(n===Vg.element){let t=e,n=gt(ee(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Nt(`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])}},Ft=function(e){let t=null,r=null;if(Be)e=`<remove></remove>`+e;else{let t=Xh(e,/^[\r\n\t ]+/);r=t&&t[0]}mt===`application/xhtml+xml`&&at===it&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=w?oe(e):e;if(at===it)try{t=new l().parseFromString(i,mt)}catch{}if(!t||!t.documentElement){t=T.createDocument(at,`template`,null);try{t.documentElement.innerHTML=ot?te:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),at===it?fe.call(t,Ie?`html`:`body`)[0]:Ie?t.documentElement:a},It=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)},Lt=function(e){return e=Zh(e,he,` `),e=Zh(e,ge,` `),e=Zh(e,_e,` `),e},Rt=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=Lt(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&Hh(i,e=>{Bt(e.content)&&Rt(e.content)})},zt=function(e){let t=x?x(e):null;return typeof t!=`string`||gt(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)},Bt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===Vg.documentFragment}catch{return!1}},Vt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Ht(e,n,r){e.length!==0&&Hh(e,e=>{e.call(t,n,r,_t)})}let Ut=function(e,t){return!!(Fe&&e.hasChildNodes()&&!Vt(e.firstElementChild)&&og(Lg,e.textContent)&&og(Lg,e.innerHTML)||Fe&&e.namespaceURI===it&&Ug[t]&&(Vt(e.firstElementChild)||typeof e.textContent==`string`&&og(Wg[t],e.textContent))||e.nodeType===Vg.processingInstruction||Fe&&e.nodeType===Vg.comment&&og(Rg,e.data))},Wt=function(e,t){return e instanceof RegExp?og(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Gt=function(e,t,n){if(!Oe[t]&&Zt(t)&&Wt(De.tagNameCheck,t))return!1;if(qe&&!Xe[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 Dt(e),!0},Kt=function(e,t,n,r){return e.length===0?t:t===n||t===r?fg(t):t},qt=function(e,t){return e===t||_(e)!==null?!1:(Je&&Mt(e),!0)},Jt=function(e,n){if(Ht(me.beforeSanitizeElements,e,null),qt(e,n))return!0;if(zt(e))return Dt(e),!0;let r=gt(ee(e));if(Ce=Kt(me.uponSanitizeElement,Ce,we,Re),Ht(me.uponSanitizeElement,e,{tagName:r,allowedTags:Ce}),qt(e,n))return!0;if(Ut(e,r))return Dt(e),!0;if(Oe[r]||!(Ae.tagCheck instanceof Function&&Ae.tagCheck(r))&&!Ce[r]){let t=Gt(e,r,n);return t===!1&&(Ht(me.afterSanitizeElements,e,null),qt(e,n))?!0:t}if(C(e)===Vg.element&&!Et(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&og(zg,e.innerHTML))return Dt(e),!0;if(Pe&&e.nodeType===Vg.text){let n=Lt(e.textContent);e.textContent!==n&&(Gh(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Ht(me.afterSanitizeElements,e,null),qt(e,n)},Yt=function(e,t,r){if(ke[t]||Nt(t,e)||We&&(t===`id`||t===`name`)&&(r in n||r in vt))return!1;let i=Te[t]||Ae.attributeCheck instanceof Function&&Ae.attributeCheck(t,e);return je&&og(ve,t)||D&&og(ye,t)?!0:i?et[t]||og(Se,Zh(r,E,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Qh(r,`data:`)===0&&Qe[e]||Me&&!og(be,Zh(r,E,``))?!0:!r:Zt(e)&&Wt(De.tagNameCheck,e)&&Wt(De.attributeNameCheck,t,e)||t===`is`&&De.allowCustomizedBuiltInElements&&Wt(De.tagNameCheck,r)},Xt=ug({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Zt=function(e){return!Xt[Jh(e)]&&og(xe,e)},Qt=function(e,t,n,r){if(w&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return oe(r);case`TrustedScriptURL`:return se(r)}return r},$t=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!zt(e)||(Dt(e),!1)}catch{return At(t,e),!1}},en=function(e,n){if(Ht(me.beforeSanitizeAttributes,e,null),qt(e,n))return;let r=e.attributes;if(!r||zt(e))return;Te=Kt(me.uponSanitizeAttribute,Te,Ee,ze);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:Te,forceKeepAttr:void 0},a=r.length,o=gt(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=gt(s),d=l,f=s===`value`?d:$h(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Ht(me.uponSanitizeAttribute,e,i),f=i.attrValue,Ge&&(u===`id`||u===`name`)&&Qh(f,Ke)!==0&&(At(s,e,n),f=Ke+f,p=!0),Fe&&og(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){At(s,e,n);continue}if(u===`attributename`&&Xh(f,`href`)){At(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){At(s,e,n);continue}if(!Ne&&og(Bg,f)){At(s,e,n);continue}if(Pe&&(f=Lt(f)),!Yt(o,u,f)){At(s,e,n);continue}f=Qt(o,u,c,f),f!==d&&$t(e,s,c,f)&&p&&Wh(t.removed)}}Ht(me.afterSanitizeAttributes,e,null),qt(e,n)},tn=function(e){let t=null,n=It(e);for(Ht(me.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Ht(me.uponSanitizeShadowNode,t,null),Jt(t,e),en(t,e),Bt(t.content)&&tn(t.content),C(t)===Vg.element){let e=v(t);Bt(e)&&(nn(e),tn(e))}Ht(me.afterSanitizeShadowDOM,e,null)},nn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){tn(e.shadow);continue}let n=e.node,r=C(n)===Vg.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`&&gt(e)===`template`){let e=n.content;Bt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);Bt(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(ot=!e,ot&&(e=`<!-->`),typeof e!=`string`&&!Vt(e)&&(e=pg(e),typeof e!=`string`))throw sg(`dirty is not a string, aborting`);if(!t.isSupported)return e;Le?(Ce=Re,Te=ze):bt(n),(me.uponSanitizeElement.length>0||me.uponSanitizeAttribute.length>0)&&(Ce=fg(Ce)),me.uponSanitizeAttribute.length>0&&(Te=fg(Te)),t.removed=[];let c=Je&&typeof e!=`string`&&Vt(e);if(c){Pt(e);let t=ee(e);if(typeof t==`string`){let n=gt(t);if(!Ce[n]||Oe[n])throw kt(e),sg(`root node is forbidden and cannot be sanitized in-place`)}if(zt(e))throw kt(e),sg(`root node is clobbered and cannot be sanitized in-place`);try{nn(e)}catch(t){throw kt(e),t}}else if(Vt(e))i=Ft(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Vg.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),nn(i);else{if(!Ve&&!Pe&&!Ie&&e.indexOf(`<`)===-1)return w&&Ue?oe(e):e;if(i=Ft(e),!i)return Ve?null:Ue?te:``}i&&Be&&Dt(i.firstChild);let l=c?e:i;try{let e=It(l);for(;o=e.nextNode();)Jt(o,l),en(o,l),Bt(o.content)&&tn(o.content)}catch(n){throw c&&(kt(e),Hh(t.removed,e=>{e.element&&Mt(e.element)})),n}if(c){let n=!1;if(Hh(t.removed,t=>{t.element&&(t.element===e&&(n=!0),Mt(t.element))}),n)throw sg(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Pe&&Rt(e),e}if(Ve){if(Pe&&Rt(i),He)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=Ie?i.outerHTML:i.innerHTML;return Ie&&Ce[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&og(Fg,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
77
- `+u),Pe&&(u=Lt(u)),w&&Ue?oe(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};bt(e),Le=!0,Re=Ce,ze=Te},t.clearConfig=function(){_t=null,Le=!1,Re=null,ze=null,w=ne,te=``},t.isValidAttribute=function(e,t,n){_t||bt({});let r=gt(e),i=gt(t);return Yt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&ig(me,e)&&Gh(me[e],t)},t.removeHook=function(e,t){if(ig(me,e)){if(t!==void 0){let n=Uh(me[e],t);return n===-1?void 0:Kh(me[e],n,1)[0]}return Wh(me[e])}},t.removeHooks=function(e){ig(me,e)&&(me[e]=[])},t.removeAllHooks=function(){me=qg()},t}var Zg=Xg();function Qg(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 $g=`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(`.`),e_=[`form`,`style`,`script`,`button`,`select`,`textarea`,`iframe`,`object`,`embed`,`svg`,`math`],t_={a:[`href`,`title`],img:[`src`,`alt`,`title`],th:[`colspan`,`rowspan`,`align`],td:[`colspan`,`rowspan`,`align`],ol:[`start`],code:[`class`],input:[`type`,`checked`,`disabled`]},n_=[...new Set(Object.values(t_).flat())],r_=/^language-[\w-]+$/,i_=/^\d{1,4}$/,a_=/^(left|right|center)$/i;function o_(e,t,n){if(!Object.hasOwn(t_,e)||!t_[e].includes(t))return!1;switch(t){case`class`:return r_.test(n);case`type`:return n.toLowerCase()===`checkbox`;case`colspan`:case`rowspan`:case`start`:return i_.test(n);case`align`:return a_.test(n);default:return!0}}var s_=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/i,c_=/^\/api(\/|$)/i;function l_(e,t){if(s_.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&&!c_.test(n.pathname)}Zg.isSupported&&Zg.addHook(`afterSanitizeAttributes`,e=>{let t=e.nodeName.toLowerCase();for(let{name:n,value:r}of Array.from(e.attributes))o_(t,n,r)||e.removeAttribute(n);if(t===`img`&&!l_(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:Qg(n,location.origin);r?(e.setAttribute(`href`,r),e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):(e.removeAttribute(`href`),e.removeAttribute(`target`))});var u_={ALLOWED_TAGS:$g,ALLOWED_ATTR:n_,FORBID_TAGS:e_,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1},d_=new Map;function f_(e){let t=d_.get(e);return t===void 0&&(t=Zg.sanitize(Sh.parse(e,{async:!1}),u_),d_.size>400&&d_.delete(d_.keys().next().value),d_.set(e,t)),t}var p_=`demo.job-runs`,m_=e=>e.status!==`running`&&e.status!==`waiting`,h_=H(()=>Xu.value?.info?.jobs??[]),g_=e=>h_.value.find(t=>t.id===e),__=H(()=>{let e=pd.value.docs[p_];return Object.values(e?.items??{}).sort((e,t)=>t.id-e.id)}),v_=e=>__.value.find(t=>t.id===e),y_=e=>__.value.find(t=>t.toolCallId===e),b_=O(Date.now());setInterval(()=>b_.value=Date.now(),1e3);var x_=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`,S_=O();async function C_(e,t){if(!S_.value){S_.value=e;try{return await kd(t)}finally{S_.value=void 0}}}function w_(e){Rd.value&&Vd(),setTimeout(()=>document.querySelector(`[data-job-run="${e}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`}))}async function T_(e){let t=await C_(`start:${e.id}`,()=>rd.value.demo(`jobs`,{job:e.id}));t&&(J(`${e.title} started. It runs in the chat.`),w_(t.taskId))}var E_=(e,t)=>C_(`decide:${e.id}`,()=>rd.value.demo(`jobs/${e.id}/approval`,{approved:t})),D_=e=>C_(`stop:${e.id}`,()=>id.value.abortTask(e.id));function O_(e){K.value&&ad({...K.value,agentId:e})}var k_=[`data-job-run`,`aria-label`],A_={class:`job-run-head`},j_={class:`job-run-icon`},M_={class:`job-run-titles`},N_={class:`job-run-eyebrow`},P_={class:`job-run-repeat`},F_={key:0,class:`job-run-about`},I_={class:`job-run-meta`},L_={key:0,class:`job-run-resumed`},R_={class:`job-stepper`,"aria-label":`Phases`},z_=[`aria-current`],B_={class:`job-chip`},V_={class:`job-step-dot`},H_={class:`job-step-label`},U_={key:0,class:`job-step-progress`},W_={class:`job-phases`},G_=[`open`],K_={class:`job-phase-n`},q_={class:`job-phase-summary`},J_={class:`job-phase-time`},Y_={key:0,class:`job-phase-about`},X_={key:1,class:`job-steps`},Z_=[`open`],Q_={key:1,class:`job-step-line`},$_=[`onClick`],ev={key:2,class:`job-phase-empty`},tv={key:1,class:`job-approval`,role:`group`,"aria-label":`Approval`},nv={class:`job-approval-buttons`},rv=[`disabled`],iv=[`disabled`],av={key:2,class:`message-error`},ov={class:`job-run-foot`},sv=[`disabled`],cv=M({__name:`JobCard`,props:{run:{}},setup(e){let t=e,n=H(()=>g_(t.run.job)),r=H(()=>m_(t.run)),i=H(()=>x_((t.run.endedAt??b_.value)-t.run.startedAt)),a={running:`Running`,waiting:`Waiting for you`,completed:`Completed`,failed:`Failed`,aborted:`Stopped`,declined:`Declined`},o={command:ml,tool:xl,agent:Qs,state:$s,approval:cl,checkpoint:vc,note:Fc},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)?ao(`code`,{title:s(t)},t.label):ao(`span`,{class:`job-step-text`},t.label),r=t.status===`running`?ao(Ic,{size:15,class:`spin`}):t.status===`done`?ao(nc,{size:15}):t.status===`waiting`?ao(Ec,{size:15}):ao(Sl,{size:15});return[ao(o[t.kind],{size:16,class:`job-step-kind`}),n,t.kind===`tool`&&t.detail?ao(`span`,{class:`job-step-args`,title:t.detail},t.detail):null,ao(`span`,{class:`job-step-state`},[r,t.ms!==void 0&&t.kind!==`note`?ao(`span`,x_(t.ms)):null])]};c.props=[`step`];let l=e=>n.value?.phases.find(t=>t.id===e),u=e=>e.startedAt?x_((e.endedAt??(e.status===`running`||e.status===`waiting`?b_.value:e.startedAt))-e.startedAt):``,d=e=>e.status!==`pending`&&e.status!==`skipped`,f=H(()=>Object.entries(t.run.input)),p=H(()=>t.run.phases.find(e=>e.status===`waiting`));return(t,o)=>(F(),I(`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]}`},[R(`header`,A_,[R(`span`,j_,[z(k(bl),{size:22})]),R(`div`,M_,[R(`div`,N_,[o[3]||=R(`span`,null,`DURABLE JOB`,-1),R(`span`,P_,[z(k(tl),{size:15}),B(`Repeatable workflow, run #`+D(e.run.run),1)])]),R(`h3`,null,D(e.run.title),1)]),R(`span`,{class:E([`job-run-status`,e.run.status])},[o[4]||=R(`i`,null,null,-1),B(D(a[e.run.status]),1)],2)]),n.value?(F(),I(`p`,F_,D(n.value.summary),1)):V(``,!0),R(`div`,I_,[R(`span`,null,`task #`+D(e.run.id),1),R(`span`,null,D(e.run.startedBy===`agent`?`started by the agent`:`started by you`),1),R(`span`,null,D(i.value),1),(F(!0),I(P,null,N(f.value,([e,t])=>(F(),I(`span`,{key:e,class:`job-run-input`},D(e)+`=`+D(t),1))),128)),e.run.resumed?(F(),I(`span`,L_,`resumed `+D(e.run.resumed)+`× after restart`,1)):V(``,!0)]),R(`ol`,R_,[(F(!0),I(P,null,N(e.run.phases,(t,n)=>(F(),I(`li`,{key:t.id,class:E(`ph-${t.status}`),"aria-current":e.run.phase===t.id&&!r.value?`step`:void 0},[R(`span`,B_,[R(`span`,V_,[t.status===`done`?(F(),L(k(nc),{key:0,size:15})):t.status===`running`?(F(),L(k(Ic),{key:1,size:15,class:`spin`})):t.status===`waiting`?(F(),L(k(Ec),{key:2,size:15})):[`failed`,`aborted`].includes(t.status)?(F(),L(k(Sl),{key:3,size:15})):(F(),I(P,{key:4},[B(D(n+1),1)],64))]),R(`span`,H_,D(t.label),1),t.progress?(F(),I(`span`,U_,D(t.progress.done)+`/`+D(t.progress.total),1)):V(``,!0)])],10,z_))),128))]),R(`div`,W_,[(F(!0),I(P,null,N(e.run.phases,(e,t)=>(F(),I(`details`,{key:e.id,class:E([`job-phase`,`ph-${e.status}`]),open:d(e)},[R(`summary`,null,[R(`span`,K_,D(t+1),1),R(`strong`,null,D(e.label),1),R(`span`,q_,D(e.summary??(e.status===`pending`?l(e.id)?.summary:e.status===`skipped`?`Skipped`:``)),1),R(`span`,J_,D(u(e)),1)]),e.status===`done`?V(``,!0):(F(),I(`p`,Y_,D(l(e.id)?.summary),1)),e.steps.length?(F(),I(`ul`,X_,[(F(!0),I(P,null,N(e.steps,e=>(F(),I(`li`,{key:e.id,class:E([`k-${e.kind}`,`st-${e.status}`])},[e.detail&&e.kind!==`tool`?(F(),I(`details`,{key:0,open:e.status===`error`},[R(`summary`,null,[z(c,{step:e},null,8,[`step`])]),R(`pre`,null,D(e.detail),1)],8,Z_)):(F(),I(`div`,Q_,[z(c,{step:e},null,8,[`step`])])),e.kind===`agent`&&e.conversationId?(F(),I(`button`,{key:2,class:`text-button job-step-link`,onClick:t=>k(O_)(e.conversationId)},` Open subagent #`+D(e.conversationId),9,$_)):V(``,!0)],2))),128))])):e.status===`pending`?(F(),I(`p`,ev,`Not started yet.`)):V(``,!0)],10,G_))),128))]),e.run.approval===`pending`?(F(),I(`div`,tv,[R(`div`,null,[z(k(cl),{size:20}),o[5]||=R(`strong`,null,`Approve to continue`,-1)]),R(`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),R(`div`,nv,[R(`button`,{class:`primary small`,disabled:!!k(S_),onClick:o[0]||=t=>k(E_)(e.run,!0)},[z(k(nc),{size:18}),o[6]||=B(`Approve & continue `,-1)],8,rv),R(`button`,{class:`secondary`,disabled:!!k(S_),onClick:o[1]||=t=>k(E_)(e.run,!1)},`Decline`,8,iv)])])):V(``,!0),e.run.error&&e.run.status!==`aborted`?(F(),I(`p`,av,D(e.run.error),1)):V(``,!0),R(`footer`,ov,[R(`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?V(``,!0):(F(),I(`button`,{key:0,class:`secondary danger`,disabled:!!k(S_),onClick:o[2]||=t=>k(D_)(e.run)},[z(k(Hc),{size:16}),o[7]||=B(`Stop `,-1)],8,sv))])],10,k_))}}),lv={class:`message-label`},uv={class:`user-message`},dv={class:`message-label`},fv={key:0,class:`streaming`},pv={key:1},mv=[`aria-label`],hv=[`innerHTML`],gv={key:1,class:`thinking`},_v=[`data-call-id`],vv={class:`tool-status`},yv={class:`tool-section-label`},bv=[`aria-label`,`onClick`],xv={key:0,class:`typing`},Sv={key:1,class:`message-error`},Cv=[`aria-label`],wv={key:3,class:`live-tool`},Tv={key:0},Ev={class:`event-line`},Dv=[`aria-label`],Ov={key:0,class:`raw`},kv=M({__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)=>(F(),I(`article`,{class:E([`entry`,i(e.item)])},[e.item.kind===`user`?(F(),I(P,{key:0},[R(`div`,lv,[a[3]||=B(` YOU `,-1),R(`span`,null,`#`+D(e.item.id),1)]),R(`div`,uv,D(e.item.text),1)],64)):e.item.kind===`assistant`?(F(),I(P,{key:1},[R(`div`,dv,[a[5]||=B(` AGENT `,-1),e.item.streaming?(F(),I(`span`,fv,`Working`)):(F(),I(`span`,pv,`#`+D(e.item.id),1)),e.item.streaming?V(``,!0):(F(),I(`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)},[z(k(wc),{size:18}),a[4]||=B(`Fork `,-1)],8,mv))]),(F(!0),I(P,null,N(e.item.blocks,(e,t)=>(F(),I(P,{key:t},[e.type===`text`?(F(),I(`div`,{key:0,class:`markdown`,innerHTML:k(f_)(e.text)},null,8,hv)):e.type===`thinking`?(F(),I(`details`,gv,[a[6]||=R(`summary`,null,`Thinking`,-1),R(`div`,null,D(e.text),1)])):(F(),I(`details`,{key:2,class:E([`tool-call`,{failed:e.call.status===`error`}]),"data-call-id":e.call.callId},[R(`summary`,null,[e.call.status===`error`?(F(),L(k(kc),{key:0,size:18})):e.call.status===`done`?(F(),L(k(nc),{key:1,size:18})):e.call.status===`running`?(F(),L(k(Hs),{key:2,size:18})):(F(),L(k(xl),{key:3,size:18})),R(`strong`,null,D(e.call.name),1),R(`code`,null,D(k(Md)(e.call.args)?.slice(0,90)),1),R(`span`,vv,D(r(e.call)),1)]),a[10]||=R(`div`,{class:`tool-section-label`},`Input`,-1),R(`pre`,null,D(k(Md)(e.call.args)),1),e.call.result===void 0?e.call.output?(F(),I(P,{key:1},[a[9]||=R(`div`,{class:`tool-section-label`},`Live output`,-1),R(`pre`,null,D(e.call.output),1)],64)):V(``,!0):(F(),I(P,{key:0},[R(`div`,yv,[a[8]||=R(`span`,null,`Result`,-1),e.call.resultEntryId===void 0?V(``,!0):(F(),I(`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)},[z(k(wc),{size:18}),a[7]||=B(`Fork `,-1)],8,bv))]),R(`pre`,null,D(e.call.result),1)],64))],10,_v)),e.type===`tool`&&e.call.name===`run_durable_job`&&k(y_)(e.call.callId)?(F(),L(cv,{key:3,run:k(y_)(e.call.callId)},null,8,[`run`])):V(``,!0)],64))),128)),e.item.streaming&&!e.item.blocks.length?(F(),I(`div`,xv,[...a[11]||=[R(`i`,null,null,-1),R(`i`,null,null,-1),R(`i`,null,null,-1)]])):V(``,!0),e.item.error?(F(),I(`div`,Sv,D(e.item.error),1)):V(``,!0)],64)):e.item.kind===`tool-result`?(F(),I(`details`,{key:2,class:E([`tool-result`,{failed:e.item.isError}])},[R(`summary`,null,[e.item.isError?(F(),L(k(kc),{key:1,size:18})):(F(),L(k(nc),{key:0,size:18})),R(`strong`,null,D(e.item.name),1),R(`span`,null,D(e.item.isError?`error`:`result`),1),R(`button`,{class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,onClick:a[1]||=As(t=>n(`fork`,e.item.id),[`prevent`])},[z(k(wc),{size:18}),a[12]||=B(`Fork `,-1)],8,Cv)]),R(`pre`,null,D(e.item.text),1)],2)):e.item.kind===`tool`?(F(),I(`div`,wv,[R(`div`,null,[z(k(Hs),{size:18}),R(`strong`,null,D(e.item.call.name),1),R(`span`,null,D(e.item.call.status),1)]),e.item.call.output?(F(),I(`pre`,Tv,D(e.item.call.output),1)):V(``,!0),e.item.call.name===`run_durable_job`&&k(y_)(e.item.call.callId)?(F(),L(cv,{key:1,run:k(y_)(e.item.call.callId)},null,8,[`run`])):V(``,!0)])):e.item.entryKind===`demo.job`&&k(v_)(e.item.data.taskId)?(F(),L(cv,{key:4,run:k(v_)(e.item.data.taskId)},null,8,[`run`])):(F(),I(P,{key:5},[R(`div`,Ev,[e.item.entryKind===`demo.state-change`?(F(),L(k($s),{key:0,size:18})):(F(),L(k(Mc),{key:1,size:18})),R(`span`,null,D(e.item.text),1),R(`button`,{class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,onClick:a[2]||=t=>n(`fork`,e.item.id)},[z(k(wc),{size:18}),a[13]||=B(`Fork `,-1)],8,Dv)]),e.item.note?(F(),I(`details`,Ov,[a[14]||=R(`summary`,null,`Context note`,-1),R(`pre`,null,D(e.item.note),1)])):V(``,!0)],64))],2))}}),Av={key:0,class:`git-chip-wrap`},jv=[`title`],Mv={class:`branch`},Nv={key:0,class:`dirty`},Pv={key:1,class:`ahead`},Fv={key:2,class:`behind`},Iv=sf(M({__name:`GitChip`,props:{deviceId:{},cwd:{}},setup(e){let t=e,n=H(()=>t.cwd??td.value?.cwd??``),r=H(()=>t.deviceId??Yu.value),i=H(()=>Df(r.value||`?`,n.value||`?`)),a=H(()=>i.value.status),o=H(()=>i.value.loading),s=H(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0));return kf(r.value||`?`,n.value||`?`),qr(()=>kf(r.value||`?`,n.value||`?`)),j([r,n],()=>void kf(r.value||`?`,n.value||`?`)),(e,t)=>a.value?.repo||o.value?(F(),I(`span`,Av,[R(`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=>k(Bd)(`git`)},[z(k(Sc),{size:16,"aria-hidden":`true`}),R(`span`,Mv,D(a.value?.branch??a.value?.head??`…`),1),s.value?(F(),I(`span`,Nv,`±`+D(s.value),1)):V(``,!0),a.value?.ahead?(F(),I(`span`,Pv,`↑`+D(a.value.ahead),1)):V(``,!0),a.value?.behind?(F(),I(`span`,Fv,`↓`+D(a.value.behind),1)):V(``,!0),z(k(rc),{size:14,"aria-hidden":`true`})],8,jv)])):V(``,!0)}}),[[`__scopeId`,`data-v-c0fb9e98`]]),Lv=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,Rv=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],zv={enabled:!0,reserveTokens:16384,backgroundTokens:32768,keepRecentTokens:2e3},Bv={auto:2e5,wait:25e4};function Vv(e){if(!(e>0))return{...zv};let t=Math.min(Bv.wait,e-zv.reserveTokens),n=Math.min(Bv.auto,t-zv.backgroundTokens);return{...zv,reserveTokens:e-t,backgroundTokens:t-n}}function Hv(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 Uv=(e,t)=>{if(e===void 0)throw Error(`No ${t} selected`);return e},Wv=[{name:`compact`,args:`[instructions]`,description:`Summarize older context; stored entries stay`,run:async e=>{await Uv(rd.value,`agent`).compact(e||void 0),J(`Compaction requested. /tasks shows its outcome.`)}},{name:`reset`,args:`[handoff note]`,description:`Start a fresh context; history stays stored`,run:async e=>{await Uv(rd.value,`agent`).reset(e||void 0),J(`New context started.`)}},{name:`tasks`,description:`Open the Tasks panel`,run:()=>Bd(`tasks`)},{name:`new`,args:`[name]`,description:`New agent in this workspace`,run:async e=>{let t=Uv(K.value,`workspace`),n=await Uv(id.value,`workspace`).createAgent({name:e||`Agent ${md.value.length+1}`});ad({...t,agentId:n.id}),J(`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??pd.value.entries.filter(e=>e.kind===`pi.assistant`).at(-1)?.id;if(a===void 0)throw Error(`Nothing to fork yet`);let o=Uv(K.value,`agent`),s=await Uv(rd.value,`agent`).fork({entryId:a,name:i||void 0});ad({...o,agentId:s.id}),J(`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 Uv(rd.value,`agent`).rename(e),J(`Agent renamed to ${e}.`)}},{name:`model`,description:`Choose this agent's model`,run:()=>q.dialog={kind:`models`}},{name:`thinking`,args:`<level>`,description:`Thinking level: ${Rv.join(`, `)}`,run:async e=>{if(!Rv.includes(e))throw Error(`Levels: ${Rv.join(`, `)}`);await Uv(rd.value,`agent`).configure({thinkingLevel:e}),await wd(),J(`Thinking ${e}. Used on the next turn.`)}},{name:`help`,description:`How this works, keys and commands`,run:()=>q.dialog={kind:`help`}}];function Gv(e){let t=e.trim().match(/^\/(\S+)\s*([\s\S]*)$/),n=t&&Wv.find(e=>e.name===t[1]);return n?{command:n,arg:t[2].trim()}:void 0}var Kv={class:`composer-region`},qv={key:0,class:`queue`},Jv=[`aria-label`,`onClick`],Yv={class:`composer`},Xv={key:0,class:`slash-menu`,role:`listbox`,"aria-label":`Slash commands`},Zv=[`aria-selected`,`onMousedown`],Qv={key:0,class:`slash-args`},$v={class:`slash-desc`},ey={class:`composer-toolbar`},ty={class:`composer-left`},ny={class:`lib-wrap`},ry=[`aria-label`],iy={key:0,class:`hint`},ay={class:`save-row`},oy=[`disabled`],sy=[`title`,`onClick`],cy=[`aria-label`,`onClick`],ly={class:`queue-mode`},uy={class:`composer-right`},dy=[`disabled`],fy=[`disabled`],py=`dpi-prompt-library`,my=sf(M({__name:`Composer`,setup(e){let t=O(`followUp`),n=O(!1),r=O(``),i=O([]),a=()=>{try{i.value=JSON.parse(localStorage.getItem(py)??`[]`)}catch{i.value=[]}},o=()=>localStorage.setItem(py,JSON.stringify(i.value));a();let s=()=>{let e=q.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=O(!1),u=H(()=>Zu.value&&pd.value.ready&&$u.status.value===`live`&&Vu.value===`live`),d=O(0),f=O(!1),p=H(()=>{let e=q.composer.match(/^\/(\S*)$/);return e&&!f.value?Wv.filter(t=>t.name.startsWith(e[1].toLowerCase())):[]});j(()=>q.composer,()=>{d.value=0,q.composer.startsWith(`/`)||(f.value=!1)});async function m(e,t=!1){!e.args||t&&e.args.startsWith(`[`)&&q.composer===`/${e.name}`?(q.composer=`/${e.name}`,await _()):q.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=Gv(e);return t?(l.value=!0,await kd(async()=>{await t.command.run(t.arg),q.composer=``}),l.value=!1,!0):!1}async function _(){let e=q.composer.trim(),n=rd.value;if(!e||l.value||!n||!u.value||e.startsWith(`/`)&&await g(e))return;l.value=!0;let r=K.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:Lv();sessionStorage.setItem(`dpi.pending-send`,JSON.stringify({key:i,content:e,mode:t.value,requestId:o})),await kd(async()=>{await n.send(e,t.value,o),sessionStorage.removeItem(`dpi.pending-send`),q.composer=``}),l.value=!1}function v(e){kd(()=>rd.value.withdraw(e))}return(e,a)=>(F(),I(`div`,Kv,[k(pd).inbox.length?(F(),I(`div`,qv,[(F(!0),I(P,null,N(k(pd).inbox,e=>(F(),I(`div`,{key:e.id},[z(k(sc),{size:18}),R(`span`,null,D(e.mode===`steer`?`Steer`:`Queued`)+`: `+D(e.content??`Context update`),1),R(`button`,{class:`icon-button`,"aria-label":`Withdraw submission ${e.id}`,title:`Withdraw queued input`,onClick:t=>v(e.id)},[z(k(Sl),{size:18})],8,Jv)]))),128))])):V(``,!0),R(`div`,Yv,[p.value.length?(F(),I(`ul`,Xv,[(F(!0),I(P,null,N(p.value,(e,t)=>(F(),I(`li`,{key:e.name,role:`option`,"aria-selected":t===d.value,class:E({active:t===d.value}),onMousedown:As(t=>m(e),[`prevent`])},[R(`code`,null,`/`+D(e.name),1),e.args?(F(),I(`span`,Qv,D(e.args),1)):V(``,!0),R(`span`,$v,D(e.description),1)],42,Zv))),128))])):V(``,!0),A(R(`textarea`,{"onUpdate:modelValue":a[0]||=e=>k(q).composer=e,rows:`2`,placeholder:`Give your agent something to do, or type / for commands…`,"aria-label":`Message your agent`,onKeydown:h},null,544),[[bs,k(q).composer]]),R(`div`,ey,[R(`div`,ty,[R(`div`,ny,[R(`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},[z(k(Nc),{size:18})],8,ry),n.value?(F(),I(`div`,{key:0,class:`lib`,onClick:a[4]||=As(()=>{},[`stop`])},[R(`header`,null,[a[7]||=R(`b`,null,`Prompts`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close library`,onClick:a[2]||=e=>n.value=!1},[z(k(Sl),{size:14})])]),i.value.length?V(``,!0):(F(),I(`p`,iy,`Type something below, give it a name, save it.`)),R(`div`,ay,[A(R(`input`,{"onUpdate:modelValue":a[3]||=e=>r.value=e,placeholder:`name…`,onKeyup:Ms(s,[`enter`])},null,544),[[bs,r.value]]),R(`button`,{type:`button`,class:`small`,disabled:!k(q).composer.trim(),onClick:s},`save composer as`,8,oy)]),R(`ul`,null,[(F(!0),I(P,null,N(i.value,e=>(F(),I(`li`,{key:e.name},[R(`button`,{type:`button`,class:`use`,title:e.text,onClick:t=>(k(q).composer=e.text,n.value=!1)},[R(`b`,null,D(e.name),1)],8,sy),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Delete ${e.name}`,onClick:t=>c(e.name)},[z(k(hl),{size:13})],8,cy)]))),128))])])):V(``,!0)]),R(`div`,ly,[A(R(`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]||=[R(`option`,{value:`followUp`},`Follow-up`,-1),R(`option`,{value:`steer`},`Steer`,-1),R(`option`,{value:`reject`},`Reject if busy`,-1)]],512),[[Cs,t.value]]),z(k(rc),{size:24,"aria-hidden":`true`})])]),R(`div`,uy,[R(`button`,{class:`interrupt`,disabled:!k(_d)||k(Fd),title:`Stop foreground work and owned subagents (Escape). Background jobs continue.`,onClick:a[6]||=(...e)=>k(Id)&&k(Id)(...e)},[z(k(Hc),{size:24,class:`stop-sign`,fill:`currentColor`}),a[9]||=B(`Interrupt`,-1)],8,dy),R(`button`,{class:`send`,"aria-label":`Send message`,disabled:!k(q).composer.trim()||l.value||!u.value,onClick:_},[z(k(Ys),{size:20})],8,fy)])])]),a[10]||=R(`div`,{class:`composer-footnote`},[R(`span`,null,[R(`i`,{class:`live-dot`}),B(`Closing this window never interrupts your agent.`)])],-1)]))}}),[[`__scopeId`,`data-v-b2af49ae`]]),hy={class:`chat-panel`},gy={class:`chat-header`},_y={class:`lineage-picker`},vy={class:`lineage-toolbar`},yy=[`title`],by={class:`crumb-main`},xy={class:`device-chip`},Sy=[`title`],Cy={class:`crumb-main`},wy={class:`crumb-name`},Ty=[`aria-current`,`title`,`onClick`],Ey={class:`crumb-kind`},Dy={class:`crumb-main`},Oy={class:`crumb-name`},ky=[`disabled`],Ay=[`aria-expanded`],jy={key:0,class:`lineage-source`},My={id:`conversation-picker`,class:`conversation-picker`,role:`dialog`,"aria-label":`Choose conversation`},Ny=[`aria-label`,`aria-current`,`onClick`],Py={class:`conversation-choice-content`},Fy={class:`choice-lineage`},Iy={class:`choice-source`},Ly={key:0,class:`agent-stream-status`,role:`alert`},Ry=[`disabled`],zy={key:0,class:`chat-empty`},By={key:0},Vy={key:1},Hy={key:0,class:`chat-empty`},Uy={class:`starter-grid`},Wy={key:1,class:`entry live-generation`},Gy={class:`message-label`},Ky={class:`streaming`},qy={key:2,class:`hint retry-note`},Jy=M({__name:`AgentView`,setup(e){let t=O(),n=O(),r=O(!1),i=H(()=>pd.value.items),a=H(()=>i.value.some(e=>e.kind===`assistant`&&e.streaming)),o=H(()=>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=H(()=>md.value.map(e=>({...e,lineage:Xl(md.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=H(()=>hd.value.at(-1)),u=e=>e.kind===`root`?`agent`:e.kind;function d(){K.value&&(qu.tree=!0,cd(K.value.deviceId,!0))}function f(){let e=md.value.find(e=>e.kind===`root`)??md.value[0];e&&p(e.id)}function p(e){r.value=!1,K.value&&ad({...K.value,agentId:e})}function m(e){let t=rd.value,n=K.value;t&&n&&(q.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});ad({...n,agentId:i.id}),J(`Forked at entry #${e}. App State stays shared.`)}})}function h(){let e=rd.value,t=l.value;e&&t&&(q.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)})}j(K,()=>{r.value=!1});let g=!0;return j($u.version,()=>{let e=t.value;g=!e||e.scrollHeight-e.scrollTop-e.clientHeight<120},{flush:`pre`}),j($u.version,()=>{g&&jn(()=>t.value?.scrollTo({top:t.value.scrollHeight,behavior:`instant`}))}),j(()=>hd.value.length,()=>void jn(()=>n.value&&(n.value.scrollLeft=n.value.scrollWidth))),(e,g)=>(F(),I(`section`,hy,[R(`header`,gy,[R(`div`,_y,[R(`div`,vy,[R(`nav`,{ref_key:`lineageNav`,ref:n,class:`crumbs conversation-lineage`,"aria-label":`Conversation lineage`},[R(`button`,{class:`crumb`,title:`${k(Xu)?.name} · ${k(Xu)?.url}`,onClick:d},[g[5]||=R(`span`,{class:`crumb-kind`},`device`,-1),R(`span`,by,[z(mf,{device:k(Xu),size:18},null,8,[`device`]),R(`span`,xy,D(k(Xu)?.name??k(Xu)?.id),1)])],8,yy),z(k(ic),{class:`crumb-sep`,size:18,"aria-hidden":`true`}),R(`button`,{class:`crumb`,title:k(td)?.cwd,onClick:f},[g[6]||=R(`span`,{class:`crumb-kind`},`workspace`,-1),R(`span`,Cy,[z(k(bc),{size:18,"aria-hidden":`true`}),R(`span`,wy,D(k(td)?.name),1)])],8,Sy),k(td)?.cwd?(F(),L(Iv,{key:0})):V(``,!0),(F(!0),I(P,null,N(k(hd),e=>(F(),I(P,{key:e.id},[z(k(ic),{class:`crumb-sep`,size:18,"aria-hidden":`true`}),R(`button`,{class:E([`crumb`,{current:e.id===k(K)?.agentId}]),"aria-current":e.id===k(K)?.agentId?`page`:void 0,title:s(e),onClick:t=>p(e.id)},[R(`span`,Ey,D(u(e)),1),R(`span`,Dy,[e.kind===`fork`?(F(),L(k(wc),{key:0,size:18,"aria-hidden":`true`})):e.kind===`subagent`?(F(),L(k(lc),{key:1,size:18,"aria-hidden":`true`})):(F(),L(k(Rc),{key:2,size:18,"aria-hidden":`true`})),R(`span`,Oy,D(e.name),1)])],10,Ty)],64))),128))],512),R(`button`,{class:`icon-button`,"aria-label":`Rename agent`,title:`Rename this agent`,disabled:!l.value,onClick:h},[z(k(Jc),{size:18})],8,ky),R(`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},[z(k(rc),{size:18})],8,Ay)]),l.value&&l.value.kind!==`root`?(F(),I(`div`,jy,D(s(l.value)),1)):V(``,!0),r.value?(F(),I(P,{key:1},[R(`button`,{class:`conversation-menu-dismiss`,"aria-label":`Close conversation picker`,onClick:g[1]||=e=>r.value=!1}),R(`section`,My,[g[7]||=R(`div`,{class:`conversation-picker-heading`},`Roots & forks`,-1),(F(!0),I(P,null,N(c.value,e=>(F(),I(`button`,{key:e.id,class:E([`conversation-choice`,{selected:e.id===k(K)?.agentId}]),"aria-label":e.lineage.map(e=>e.name).join(` → `),"aria-current":e.id===k(K)?.agentId?`page`:void 0,onClick:t=>p(e.id)},[R(`div`,Py,[R(`span`,Fy,[(F(!0),I(P,null,N(e.lineage,(t,n)=>(F(),I(P,{key:t.id},[n?(F(),L(k(ic),{key:0,size:18,"aria-hidden":`true`})):V(``,!0),R(`span`,{class:E({"choice-ancestor":n<e.lineage.length-1})},D(t.name),3)],64))),128))]),R(`span`,Iy,D(s(e)),1)]),e.id===k(K)?.agentId?(F(),L(k(nc),{key:0,size:18,"aria-hidden":`true`})):e.kind===`fork`?(F(),L(k(wc),{key:1,size:18,"aria-hidden":`true`})):(F(),L(k(Rc),{key:2,size:18,"aria-hidden":`true`}))],10,Ny))),128))])],64)):V(``,!0)])]),k($u).fault.value||k($u).status.value===`fault`||k($u).status.value===`reconnecting`||k(pd).ready&&k($u).status.value===`connecting`?(F(),I(`div`,Ly,[R(`div`,null,[R(`strong`,null,D(k(pd).ready?`Cached transcript is stale.`:`Agent stream unavailable.`),1),R(`p`,null,D(k($u).fault.value||`Updates are paused while the stream reconnects.`),1),g[8]||=R(`p`,null,`Sending is paused until a fresh snapshot arrives. Your draft is kept.`,-1)]),R(`button`,{disabled:k($u).status.value===`connecting`,onClick:g[2]||=(...e)=>k($u).retry&&k($u).retry(...e)},` Retry stream `,8,Ry)])):V(``,!0),R(`div`,{ref_key:`chat`,ref:t,class:`chat-scroll`,"data-testid":`chat`},[k(pd).ready?(F(),I(P,{key:1},[i.value.length?V(``,!0):(F(),I(`div`,Hy,[g[13]||=R(`div`,{class:`agent-orb`},[R(`img`,{src:`/icons/durable-pi.svg`,alt:`Durable Pi`}),R(`i`)],-1),g[14]||=R(`span`,{class:`eyebrow`},`YOUR DURABLE AGENT IS READY`,-1),g[15]||=R(`h2`,null,`A conversation with continuity.`,-1),R(`p`,null,`Messages, tools and state live on `+D(k(Xu)?.id)+`, beyond this window.`,1),R(`div`,Uy,[R(`button`,{onClick:g[3]||=e=>k(Ad)(`Inspect this directory using your tools and give me a brief overview. Do not modify any files.`)},[z(k(bc),{size:18}),g[9]||=R(`strong`,null,`Explore this directory`,-1),g[10]||=R(`span`,null,`See coding tools in action`,-1),z(k(Js),{size:18})]),R(`button`,{onClick:g[4]||=e=>k(Ad)(`Use read_state, then update_state to add a field called progress with value 1 and a boolean called ready with value false.`)},[z(k($s),{size:18}),g[11]||=R(`strong`,null,`Make a state change`,-1),g[12]||=R(`span`,null,`Watch the workspace update`,-1),z(k(Js),{size:18})])])])),(F(!0),I(P,null,N(i.value,e=>(F(),L(kv,{key:e.id,item:e,onFork:m},null,8,[`item`]))),128)),k(pd).running&&!a.value&&!o.value?(F(),I(`div`,Wy,[R(`div`,Gy,[g[16]||=B(` AGENT `,-1),R(`span`,Ky,D(k(pd).retry?`Retry scheduled`:`Working`),1)]),g[17]||=R(`div`,{class:`typing`},[R(`i`),R(`i`),R(`i`)],-1)])):V(``,!0),k(pd).retry?(F(),I(`p`,qy,` Retrying: `+D(k(pd).retry.error),1)):V(``,!0),(F(!0),I(P,null,N(k(pd).notices,(e,t)=>(F(),I(`p`,{key:t,class:`message-error`},D(e),1))),128))],64)):(F(),I(`div`,zy,[z(k(Hs),{size:30}),k($u).status.value===`fault`?(F(),I(`h2`,By,`This agent is unavailable.`)):(F(),I(`h2`,Vy,`Connecting to the agent…`)),R(`p`,null,`The agent keeps working on `+D(k(Xu)?.id)+` while this view connects.`,1)]))],512),z(my)]))}});function Yy(e,t){return`${e}/${t.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`}function Xy(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 Zy(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 Qy(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`);Qy(r,t+1)}}}function $y(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=Xy(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(Qy(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(Zy,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}Qy(e),s?a[c?a.length:Number(i)]=e:a[i]=e}if(Qy(r),JSON.stringify(r).length>1e5)throw Error(`App State must be under 100,000 characters`);return r}var eb=[`data-state-path`],tb={key:0,class:`state-field-heading`},nb=[`value`,`aria-label`,`disabled`],rb=[`value`],ib=[`aria-label`,`disabled`],ab=[`aria-label`,`disabled`],ob=[`aria-label`,`disabled`],sb=[`value`],cb=[`disabled`],lb=[`disabled`,`aria-label`],ub={key:2,class:`state-number`},db=[`aria-label`,`disabled`],fb=[`aria-label`,`disabled`],pb=[`aria-label`,`disabled`],mb={key:3,class:`state-boolean`},hb=[`aria-label`,`aria-checked`,`disabled`],gb=[`aria-label`,`disabled`],_b={key:5,class:`muted`},vb=M({__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=H(()=>n.value===null?`null`:Array.isArray(n.value)?`array`:typeof n.value),a=H(()=>i.value===`object`||i.value===`array`),o=H(()=>a.value?Object.entries(n.value):[]),s=O(``),c=O(!1),l=O(``),u=O(`string`),d=O(!1),f=[`string`,`number`,`boolean`,`object`,`array`,`null`],p={string:()=>``,number:()=>0,boolean:()=>!1,object:()=>({}),array:()=>[],null:()=>null};j(()=>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:Yy(n.path,e),value:p[u.value]()}),l.value=``,d.value=!1)}return(t,n)=>{let _=Qr(`StateEditor`,!0);return F(),I(`div`,{class:E([`state-field`,{"state-root":e.path===``}]),"data-state-path":e.path},[e.path===``?V(``,!0):(F(),I(`div`,tb,[R(`strong`,null,D(e.label),1),R(`select`,{value:i.value,"aria-label":`Type of ${e.path}`,disabled:e.disabled,onChange:n[0]||=e=>m(`update`,p[e.target.value]())},[(F(),I(P,null,N(f,e=>R(`option`,{key:e,value:e},D(e),9,rb)),64))],40,nb),R(`button`,{class:`icon-button`,"aria-label":`Delete ${e.path}`,title:`Delete field`,disabled:e.disabled,onClick:n[1]||=e=>m(`delete`)},[z(k(hl),{size:18})],8,ib)])),a.value?(F(),I(P,{key:1},[(F(!0),I(P,null,N(o.value,([t,i])=>(F(),L(_,{key:t,value:i,path:k(Yy)(e.path,t),label:t,disabled:e.disabled,onChange:n[2]||=e=>r(`change`,e)},null,8,[`value`,`path`,`label`,`disabled`]))),128)),d.value?(F(),I(`form`,{key:0,class:`state-add`,onSubmit:As(g,[`prevent`])},[i.value===`array`?V(``,!0):A((F(),I(`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,ab)),[[bs,l.value]]),A(R(`select`,{"onUpdate:modelValue":n[4]||=e=>u.value=e,"aria-label":`New field type in ${e.path||`/`}`,disabled:e.disabled},[(F(),I(P,null,N(f,e=>R(`option`,{key:e,value:e},D(e),9,sb)),64))],8,ob),[[Cs,u.value]]),R(`button`,{class:`secondary small`,disabled:e.disabled||i.value!==`array`&&!l.value.trim()},` Add `,8,cb),R(`button`,{type:`button`,class:`text-button`,onClick:n[5]||=e=>d.value=!1},`Cancel`)],32)):(F(),I(`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},[z(k(Zc),{size:18}),B(D(i.value===`array`?`Add item`:`Add field`),1)],8,lb))],64)):i.value===`number`?(F(),I(`div`,ub,[R(`button`,{class:`secondary`,"aria-label":`Decrement ${e.path}`,disabled:e.disabled,onClick:n[7]||=e=>m(`increment`,-1)},[z(k(zc),{size:18})],8,db),A(R(`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]||=Ms(e=>e.target.blur(),[`enter`])},null,40,fb),[[bs,s.value]]),R(`button`,{class:`secondary`,"aria-label":`Increment ${e.path}`,disabled:e.disabled,onClick:n[11]||=e=>m(`increment`,1)},[z(k(Zc),{size:18})],8,pb)])):i.value===`boolean`?(F(),I(`div`,mb,[R(`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]||=[R(`span`,null,null,-1)]],10,hb),R(`span`,null,D(e.value),1)])):i.value===`string`?A((F(),I(`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,gb)),[[bs,s.value]]):(F(),I(`span`,_b,`null`))],10,eb)}}}),yb=[`data-status`],bb=[`title`],xb=[`title`],Sb=[`href`],Cb=[`title`],wb=M({__name:`TunnelStatusBar`,props:{device:{}},setup(e){let t=e,n=H(()=>t.device.status===`online`),r=H(()=>t.device.transport===`tunnel`),i=H(()=>n.value?r.value?`online · via tunnel`:`online · LAN`:r.value?`tunnel`:`LAN`),a=H(()=>t.device.tunnel?.state===`connected`);return(t,o)=>(F(),I(`span`,{class:`tunnel-status`,"data-status":e.device.status},[R(`span`,{class:`axis transport`,title:r.value?`Hub ⇄ device over the tunnel (WSS)`:`Hub → device over LAN`},[r.value?(F(),L(k(ec),{key:0,size:13,class:E({live:a.value})},null,8,[`class`])):(F(),L(k(yl),{key:1,size:13,class:E({live:n.value})},null,8,[`class`])),B(` `+D(i.value),1)],8,bb),R(`span`,{class:E([`axis monitor`,e.device.status])},[e.device.status===`offline`?(F(),L(k(vl),{key:0,size:13})):(F(),I(P,{key:1},[B(D(e.device.status),1)],64))],2),r.value&&a.value&&e.device.tunnel?(F(),I(`span`,{key:0,class:`axis muted`,title:`tunnel last seen ${k(Pd)(e.device.tunnel.lastSeenAt)}`},D(e.device.tunnel.readerCount)+` reader`+D(e.device.tunnel.readerCount===1?``:`s`),9,xb)):V(``,!0),e.device.url?(F(),I(`a`,{key:1,class:`axis url`,href:e.device.url,target:`_blank`,rel:`noreferrer`},D(e.device.url),9,Sb)):V(``,!0),e.device.lastSeenAt?(F(),I(`span`,{key:2,class:`axis muted`,title:`last probe ${k(Pd)(e.device.lastSeenAt)}`},D(k(Pd)(e.device.lastSeenAt)),9,Cb)):V(``,!0)],8,yb))}});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 Cl(e?.code??`internal`,e?.message??`${a.status} ${a.statusText}`,a.status)}return o}function Eb(e){return e.offerUrl??e.pairUrl}var Db={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)},Ob=0;function kb(){let e=++Ob,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`}},jb=e=>e===`issued`||e===`cancelled`||e===`expired`;async function Mb(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 Db.codeState(t,n.signal);if(e.closed())return;if(e.state=a,n.onState?.(a),jb(a.phase))return a;await new Promise(e=>setTimeout(e,r))}}var Nb={key:0,class:`token-manager`,"aria-label":`Credential manager`},Pb={class:`credential-fingerprint`},Fb=[`title`],Ib={key:0,class:`rotation-badge`,role:`status`},Lb={class:`token-actions`},Rb=[`disabled`],zb=[`disabled`],Bb={key:1,class:`message-error`,role:`alert`},Vb=M({__name:`TokenManager`,props:{device:{}},setup(e){let t=e,n=O(!1),r=O(``),i=H(()=>t.device.pairing);async function a(){if(!n.value){n.value=!0,r.value=``;try{await Db.rotate(t.device.id),J(`Rotation queued — it completes when the device acknowledges the new credential.`)}catch(e){r.value=G(e)}finally{n.value=!1}}}async function o(){n.value||(q.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 Db.revoke(t.device.id,`user`),J(`Revoke committed on the hub. The tunnel is cut; the device cleans up on its next contact.`)}})}return(e,t)=>i.value?(F(),I(`section`,Nb,[R(`header`,null,[z(k(Ac),{size:15}),t[0]||=R(`h3`,null,`Credential`,-1),R(`span`,{class:E([`pairing-status`,i.value.status])},D(i.value.status),3)]),R(`dl`,null,[t[1]||=R(`dt`,null,`Key fingerprint`,-1),R(`dd`,null,[R(`code`,Pb,D(i.value.keyFingerprint),1)]),t[2]||=R(`dt`,null,`Paired`,-1),R(`dd`,{title:new Date(i.value.pairedAt).toISOString()},D(k(Pd)(i.value.pairedAt)),9,Fb),t[3]||=R(`dt`,null,`Generation`,-1),R(`dd`,null,D(i.value.credentialGeneration),1)]),i.value.rotationPending?(F(),I(`p`,Ib,[z(k(el),{size:13,class:`spin`}),t[4]||=B(` rotation queued — waiting for the device to ACK `,-1)])):V(``,!0),R(`div`,Lb,[i.value.status===`paired`?(F(),I(`button`,{key:0,class:`small`,disabled:n.value||i.value.rotationPending,onClick:a},[z(k(el),{size:14}),t[5]||=B(` Rotate credential `,-1)],8,Rb)):V(``,!0),i.value.status===`paired`?(F(),I(`button`,{key:1,class:`small danger`,disabled:n.value,onClick:o},[z(k(ll),{size:14}),t[6]||=B(` Revoke `,-1)],8,zb)):V(``,!0)]),r.value?(F(),I(`p`,Bb,D(r.value),1)):V(``,!0)])):V(``,!0)}}),Hb={class:`tasks-panel`},Ub={class:`panel-heading`},Wb={class:`tag`},Gb={key:0,class:`message-error`,role:`alert`},Kb={class:`task-section`,"aria-label":`Durable jobs`},qb={key:0,class:`task-empty`},Jb=[`data-job`],Yb={class:`job-def-head`},Xb={key:0,class:`tag`},Zb={class:`tag`},Qb=[`aria-label`],$b=[`title`],ex={class:`job-def-meta`},tx=[`title`],nx=[`title`],rx={key:0,class:`job-def-last`},ix=[`onClick`],ax=[`disabled`,`onClick`],ox=[`disabled`,`onClick`],sx=[`disabled`,`onClick`],cx={class:`task-section`,"aria-label":`Agent activity`},lx={class:`panel-heading`},ux={key:0,class:`task-empty`},dx={key:1,class:`task-tree`},fx=[`data-task-kind`],px={class:`tag`},mx={key:0,class:`task-phase`},hx=[`onClick`],gx=[`disabled`],_x={class:`raw`},vx=M({__name:`TasksPanel`,setup(e){let t=O(``),n=O(!1),r=O([]),i=O(),a=e=>({running:`Running`,waiting:`Waiting`,completed:`Completed`,aborted:`Stopped`,declined:`Declined`,failed:`Failed`,pending:`Queued`,completing:`Finishing`,terminal:`Finished`})[e]??e,o=H(()=>new Map(h_.value.map(e=>[e.id,__.value.find(t=>t.job===e.id)]))),s=H(()=>{let e=gd.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:xl,name:e.label??`Tool call`,what:`tool call`}:e.kind===`pi.generation`?{icon:Qs,name:`Model response`,what:`generation`}:e.kind===`pi.compaction`?{icon:Mc,name:`Compaction`,what:`compaction`}:e.kind.startsWith(`demo.job.`)?{icon:bl,name:e.label??g_(e.kind.slice(9))?.title??e.kind,what:`durable job`}:e.kind===`demo.job-approval`?{icon:cl,name:`Approval`,what:`waits for you`}:{icon:Hs,name:e.label??e.kind,what:e.kind},l=e=>e.state.phase?e.kind.startsWith(`demo.job.`)?g_(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&&rd.value){n.value=!0,t.value=``;try{await rd.value.abort(!0)}catch(e){t.value=G(e)}finally{n.value=!1}}}async function d(e){let n=id.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=G(e)}}let f=H(()=>r.value.filter(e=>e.state.status===`terminal`).slice(-12).reverse());return(e,r)=>(F(),I(`div`,Hb,[R(`div`,Ub,[r[0]||=R(`h2`,null,`Tasks`,-1),R(`span`,Wb,D(k(gd).length)+` active`,1)]),t.value?(F(),I(`p`,Gb,D(t.value),1)):V(``,!0),R(`section`,Kb,[R(`h3`,null,[z(k(tl),{size:18}),r[1]||=B(`Durable jobs`,-1)]),r[2]||=R(`p`,{class:`hint`},[B(` 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 `),R(`code`,null,`list_durable_jobs`),B(`, starts them with `),R(`code`,null,`run_durable_job`),B(` and checks them with `),R(`code`,null,`check_durable_job`),B(`. Runs play out live in the chat. `)],-1),k(h_).length?V(``,!0):(F(),I(`p`,qb,` This device has no durable jobs. Deploy the latest backend to it. `)),(F(!0),I(P,null,N(k(h_),e=>(F(),I(`article`,{key:e.id,class:`job-def`,"data-job":e.id},[R(`div`,Yb,[z(k(bl),{size:18}),R(`strong`,null,D(e.title),1),e.approval?(F(),I(`span`,Xb,`needs approval`)):V(``,!0),R(`span`,Zb,`~`+D(e.seconds)+`s`,1)]),R(`p`,null,D(e.summary),1),R(`ol`,{class:`job-chain`,"aria-label":`${e.title} phases`},[(F(!0),I(P,null,N(e.phases,(e,t)=>(F(),I(`li`,{key:e.id,title:e.summary},[R(`span`,null,D(t+1),1),B(D(e.label),1),e.kind===`repeat`?(F(),L(k(tl),{key:0,size:13})):V(``,!0),e.kind===`approval`?(F(),L(k(cl),{key:1,size:13})):V(``,!0)],8,$b))),128))],8,Qb),R(`div`,ex,[(F(!0),I(P,null,N(e.inputs,e=>(F(),I(`code`,{key:e.name,title:e.description},D(e.name)+`=`+D(e.default),9,tx))),128)),R(`code`,{title:`Each run saves its result to App State ${e.resultPath}`},`→ `+D(e.resultPath),9,nx)]),o.value.get(e.id)?(F(),I(`div`,rx,[R(`span`,null,[B(`Run #`+D(o.value.get(e.id).run)+`: `,1),R(`strong`,null,D(a(o.value.get(e.id).status)),1),k(m_)(o.value.get(e.id))?V(``,!0):(F(),I(P,{key:0},[B(` in `+D(o.value.get(e.id).phases.find(t=>t.id===o.value.get(e.id).phase)?.label),1)],64))]),R(`button`,{class:`text-button`,onClick:t=>k(w_)(o.value.get(e.id).id)},` Show in chat `,8,ix),o.value.get(e.id).approval===`pending`?(F(),I(P,{key:0},[R(`button`,{class:`primary small`,disabled:!!k(S_),onClick:t=>k(E_)(o.value.get(e.id),!0)},` Approve `,8,ax),R(`button`,{class:`secondary`,disabled:!!k(S_),onClick:t=>k(E_)(o.value.get(e.id),!1)},` Decline `,8,ox)],64)):V(``,!0)])):V(``,!0),R(`button`,{class:`secondary job-def-run`,disabled:!!k(S_)||!k(rd),onClick:t=>k(T_)(e)},[z(k(Xc),{size:16}),B(`Run `+D(e.title),1)],8,sx)],8,Jb))),128))]),R(`section`,cx,[R(`div`,lx,[r[3]||=R(`h3`,null,`Agent activity`,-1),z(k(Hs),{size:18})]),r[5]||=R(`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?(F(),I(`ul`,dx,[(F(!0),I(P,null,N(s.value,({task:e,depth:t})=>(F(),I(`li`,{key:e.id,class:`task-row`,style:ge({"--depth":t}),"data-task-kind":e.kind},[(F(),L(ei(c(e).icon),{size:16})),R(`strong`,null,D(c(e).name),1),R(`span`,px,D(a(e.state.status)),1),l(e)?(F(),I(`span`,mx,D(l(e)),1)):V(``,!0),R(`small`,null,`#`+D(e.id)+` `+D(c(e).what)+`, agent #`+D(e.conversationId)+D(e.effectiveBackground?`, background`:``),1),(F(!0),I(P,null,N(e.conversations,e=>(F(),I(`button`,{key:e,class:`text-button`,onClick:t=>k(O_)(e)},` Open agent #`+D(e),9,hx))),128))],12,fx))),128))])):(F(),I(`p`,ux,`Nothing running. Send a message or run a job.`)),r[6]||=R(`p`,{class:`hint`},` Interrupt or Esc stops foreground work and what it owns. Stop all also stops background runs. `,-1),R(`button`,{class:`secondary danger`,disabled:!k(gd).length||n.value,onClick:u},[z(k(Hc),{size:18}),r[4]||=B(`Stop all `,-1)],8,gx)]),R(`details`,{class:`raw task-section`,onToggle:d},[R(`summary`,null,[z(k(sc),{size:18}),r[7]||=B(`Runtime details`,-1)]),r[9]||=R(`p`,{class:`hint`},` Recent task results and recovery records, read from the device when opened. `,-1),(F(!0),I(P,null,N(f.value,e=>(F(),I(`details`,{key:e.id,class:`raw`},[R(`summary`,null,[B(D(e.kind)+` #`+D(e.id),1),R(`span`,null,D(a(e.state.outcome?.status??e.state.status)),1)]),R(`pre`,null,D(JSON.stringify(e.state.outcome,null,2)),1)]))),128)),R(`details`,_x,[r[8]||=R(`summary`,null,`Recovery inspection`,-1),R(`pre`,null,D(JSON.stringify(i.value,null,2)),1)])],32)]))}}),yx={class:`git-pane`},bx={key:0,class:`hint`},xx={key:0,class:`hint`},Sx={key:1,class:`muted-line`},Cx={key:2,class:`message-error`},wx={key:3,class:`message-error`},Tx={key:0,class:`hint`},Ex={key:0,class:`message-error merge-banner`},Dx=[`disabled`],Ox={class:`panel-heading git-top`},kx={class:`branch-wrap`},Ax=[`disabled`],jx={key:0,class:`menu`},Mx=[`onClick`],Nx={class:`muted-line`},Px={class:`new-branch`},Fx=[`disabled`],Ix={class:`auto-stash`},Lx={class:`tag`},Rx={key:0,class:`tag`},zx={key:1,class:`tag`},Bx={key:2,class:`tag`,title:`vs the picked base`},Vx={class:`tag`},Hx=[`href`],Ux=[`disabled`],Wx={class:`row ops`},Gx=[`disabled`],Kx=[`disabled`],qx=[`disabled`],Jx=[`disabled`],Yx=[`disabled`],Xx={key:1,class:`message-error hintbox`},Zx=[`disabled`],Qx=[`disabled`],$x={key:2,class:`message-error hintbox`},eS=[`disabled`],tS={class:`task-section`,"aria-label":`Commit`},nS={class:`panel-heading`},rS={class:`tag`},iS=[`disabled`],aS=[`disabled`],oS={key:0,class:`hintbox warn`},sS={key:1,class:`cps turns`},cS={key:0,class:`hint`},lS={class:`muted-line`},uS={class:`cp-subj`},dS={key:2,class:`muted-line cap`},fS={key:3,class:`files conflicts`},pS={class:`file all`},mS={class:`muted-line conflict-head`},hS={class:`file-label`},gS={class:`xy`},_S=[`title`],vS={class:`file-acts`},yS=[`onClick`],bS=[`disabled`,`onClick`],xS=[`disabled`,`onClick`],SS={key:4,class:`files`},CS={class:`file all`},wS=[`checked`],TS={class:`muted-line`},ES=[`onClick`],DS={class:`muted-line`},OS={class:`file-label`},kS=[`checked`,`onChange`],AS=[`title`],jS=[`title`],MS={class:`file-acts`},NS=[`onClick`],PS=[`onClick`],FS=[`onClick`],IS={key:5,class:`files`},LS={class:`file all`},RS=[`checked`],zS={class:`muted-line`},BS=[`onClick`],VS={class:`muted-line`},HS={class:`file-label`},US=[`checked`,`onChange`],WS=[`title`],GS=[`title`],KS={class:`file-acts`},qS=[`onClick`],JS=[`onClick`],YS=[`onClick`],XS=[`onClick`],ZS=[`onClick`],QS={key:6,class:`file-diff`},$S={class:`mode-chips`},eC={key:0,class:`nums bin`},tC={key:1,class:`nums`},nC={key:2},rC={class:`row`},iC=[`disabled`],aC=[`disabled`],oC=[`disabled`],sC={class:`task-section`,"aria-label":`Log`},cC={class:`panel-heading`},lC=[`disabled`],uC=[`disabled`],dC=[`disabled`],fC={key:0,class:`cps`},pC={key:0,class:`hint`},mC={class:`muted-line`},hC={class:`cp-subj`},gC=[`disabled`,`onClick`],_C={key:1,class:`hint`},vC={key:2,class:`commits`},yC=[`title`],bC=[`width`],xC=[`x1`,`x2`],SC=[`x1`,`x2`,`stroke`],CC=[`cx`,`fill`],wC=[`onClick`],TC={class:`hash`},EC=[`href`],DC={key:1,class:`refs`},OC={class:`subject`},kC={class:`muted-line who`},AC={key:0,class:`commit-files`},jC=[`data-s`],MC={class:`path`},NC={key:0,class:`hint`},PC={key:3,class:`message-error`},FC={key:4,class:`hint`},IC={class:`task-section`,"aria-label":`Worktrees`},LC={class:`panel-heading`},RC={class:`branch-wrap`},zC=[`disabled`],BC={key:0,class:`menu`},VC=[`onClick`],HC={class:`new-branch`},UC=[`disabled`],WC=[`title`],GC={class:`muted-line`},KC=[`disabled`,`onClick`],qC=[`disabled`,`onClick`],JC=[`disabled`,`onClick`],YC={key:3,class:`task-section`,"aria-label":`Pull requests`},XC={class:`panel-heading`},ZC=[`disabled`],QC=[`disabled`],$C={key:0,class:`hint`},ew={key:1,class:`commits`},tw={class:`hash`},nw={class:`subject`},rw={class:`muted-line who`},iw=[`disabled`,`onClick`],aw=[`disabled`,`onClick`],ow=[`disabled`,`onClick`],sw=[`href`],cw={key:4,class:`op-out`},lw=[`placeholder`],uw={class:`row`},dw=[`disabled`],fw=sf(M({__name:`GitPanel`,props:{deviceId:{},cwd:{}},setup(e){let t=e,n=H(()=>t.cwd??td.value?.cwd??``),r=H(()=>t.deviceId??Yu.value),i=H(()=>Df(r.value||`?`,n.value||`?`)),a=H(()=>i.value.status),o=H(()=>i.value.loading),s=H(()=>{let e=i.value;if(!e.error||!/start dirs/i.test(e.error))return``;let t=Hu.devices.value.find(e=>e.id===r.value)?.info?.startDirs;return Array.isArray(t)&&t.length?t.map(String).join(`, `):``}),c=H(()=>i.value.refreshing),l=H(()=>i.value.error),u=H(()=>{let e=td.value;return e&&e.cwd===n.value&&!t.deviceId?e.id:void 0}),d=O(``),f=O(``),p=O(``),m=O(new Set),h=O(!1),g=O(!1),_=O(``),v=O(null),y=O(`working`),b=H(()=>`dpi-git-draft:${r.value}:${n.value}`),x=O(null),S=O(!0),C=O(``),ee=O(!1),w=O([]),te=H(()=>{if(!w.value.length||!n.value)return null;let e=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,t=new Set(w.value);return{changed:(a.value?.files??[]).filter(n=>t.has(e(n.path))).length,total:w.value.length}}),ne=O(null),re=O(``),ie=e=>{re.value=e.input?.value??``,ne.value=e},ae=()=>{let e=ne.value;ne.value=null,e&&e.action(re.value)};window.addEventListener(`keydown`,e=>{e.key===`Escape`&&ne.value&&(ne.value=null)});let oe=O([]),se=O(!1),ce=O(new Map),le=O([]),T=O(!1),ue=O(new Map),de=O(!1),fe=H(()=>/github\.com|gitlab/i.test(a.value?.remoteUrl??``)),pe=async()=>{if(!r.value||!n.value)return;let e=bf(r.value,n.value);if(!e.ok){le.value=[],J(`pull requests unavailable: ${e.reason}`);return}de.value=!0;try{let e=await W(r.value).gitOp(n.value,`pr-list`);le.value=e.prs??[]}catch(e){J(`pr list failed: ${e.message.slice(0,120)}`)}finally{de.value=!1}};j(T,e=>{e&&pe()});let me=()=>ie({title:`Create pull request`,body:`head: ${a.value?.branch??`?`}`,confirmLabel:`Create PR`,input:{placeholder:`PR title`,value:p.value.trim()||``},action:e=>void he(e)});async function he(e){if(r.value&&n.value&&e.trim()){de.value=!0;try{J((await W(r.value).gitOp(n.value,`pr-create`,{message:e.trim(),body:e.trim()})).text.split(`
78
- `)[0]??`PR created`),await pe()}catch(e){J(`pr create failed: ${e.message.slice(0,140)}`)}finally{de.value=!1}}}async function ge(e){if(r.value&&n.value){de.value=!0;try{let t=await W(r.value).gitOp(n.value,`pr-checks`,{n:e});ue.value=new Map(ue.value).set(e,t.text.slice(0,1500))}catch(e){J(`pr checks failed: ${e.message.slice(0,120)}`)}finally{de.value=!1}}}let _e=e=>ie({title:`Merge PR #${e}?`,body:`squash-merge via gh on the device.`,confirmLabel:`Squash & merge`,danger:!0,action:()=>void ve(e)});async function ve(e){if(r.value&&n.value){de.value=!0;try{J((await W(r.value).gitOp(n.value,`pr-merge`,{n:e})).text||`PR #${e} merged`),await pe(),await De()}catch(e){J(`pr merge failed: ${e.message.slice(0,140)}`)}finally{de.value=!1}}}let ye=e=>ie({title:`Comment on PR #${e}`,body:`posted as the device's gh login`,confirmLabel:`Comment`,input:{placeholder:`comment…`,value:``},action:t=>void be(e,t)});async function be(e,t){if(r.value&&n.value&&t.trim()){de.value=!0;try{J((await W(r.value).gitOp(n.value,`pr-comment`,{n:e,body:t.trim()})).text||`comment posted`)}catch(e){J(`pr comment failed: ${e.message.slice(0,140)}`)}finally{de.value=!1}}}let xe=O([]),Se=O(!1),Ce=async()=>{if(r.value&&u.value)try{let e=await W(r.value).sessionGitTurns(u.value);xe.value=e.turns}catch{xe.value=[]}};j(Se,e=>{e&&Ce()});let we=0;window.addEventListener(`focus`,()=>{!n.value||Date.now()-we<15e3||(we=Date.now(),kf(r.value||`?`,n.value||`?`,{force:!0}))});let Te=O(new Set),Ee=()=>{typeof localStorage<`u`&&(p.value=localStorage.getItem(b.value)??``)};Tf(),kf(r.value||`?`,n.value||`?`),Ee(),qr(()=>kf(r.value||`?`,n.value||`?`)),j(p,e=>{typeof localStorage<`u`&&(e?localStorage.setItem(b.value,e):localStorage.removeItem(b.value))}),j([r,n],()=>{h.value=!1,g.value=!1,v.value=null,x.value=null,C.value=``,ee.value=!1,w.value=[],ce.value=new Map,Te.value=new Set,kf(r.value||`?`,n.value||`?`),Ee()});let De=()=>(m.value=new Set,v.value=null,kf(r.value||`?`,n.value||`?`,{force:!0})),Oe=H(()=>a.value?.files??[]);j(Oe,e=>{let t=new Set;for(let n of e)n.x!==`?`&&n.y!==`?`&&t.add(n.path);m.value=t},{immediate:!0});let ke=H(()=>Oe.value.some(e=>m.value.has(e.path))),Ae=H(()=>Oe.value.filter(e=>!Me(e)&&e.x!==` `&&e.x!==`?`)),je=H(()=>Oe.value.filter(e=>!Me(e)&&(e.x===` `||e.x===`?`))),Me=e=>`UAD`.includes(e.x)&&`UAD`.includes(e.y),Ne=H(()=>Oe.value.filter(Me)),Pe=H(()=>Oe.value.length>=500),Fe=H(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0)>0),Ie=H(()=>!a.value?.identity?.name||!a.value?.identity?.email),Le=H(()=>{let e=a.value?.remoteUrl??``,t=e.match(/git@([^:]+):(.+?)(?:\.git)?$/)??e.match(/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/);return t?`https://${t[1]}/${t[2]}`:``}),Re=e=>{let t=new Set(m.value);t.has(e)?t.delete(e):t.add(e),m.value=t},ze=e=>{let t=e.every(e=>m.value.has(e.path)),n=new Set(m.value);for(let r of e)t?n.delete(r.path):n.add(r.path);m.value=n},Be=e=>{let t=e.lastIndexOf(`/`);return t===-1?`.`:e.slice(0,t)},Ve=e=>{let t=new Map;for(let n of e){let e=Be(n.path);t.has(e)||t.set(e,[]),t.get(e).push(n)}return[...t.entries()].map(([e,t])=>({dir:e,files:t,open:!Te.value.has(e)}))},He=e=>{let t=new Set(Te.value);t.has(e)?t.delete(e):t.add(e),Te.value=t},Ue=e=>e.a===void 0&&e.d===void 0?``:e.a===-1||e.d===-1?`bin`:`+${e.a??0} −${e.d??0}`,We=e=>{navigator.clipboard?.writeText(e).then(()=>J(`copied ${e}`))};async function Ge(e,t={}){if(!r.value||!n.value)return;let i=bf(r.value,n.value);if(!i.ok){J(`git ${e} skipped: ${i.reason}`);return}d.value=e,f.value=``;try{let i=await W(r.value).gitOp(n.value,e,t);f.value=i.text||`(empty)`,e===`push`&&(C.value=``),e===`pull`&&(ee.value=!1),[`fetch`,`pull`,`push`,`stash-push`,`stash-pop`].includes(e)&&J(`git ${e} ✓`),await De(),bt(!0)}catch(t){let n=t.message;e===`push`&&(/no upstream|has no upstream|upstream is gone/i.test(n)?C.value=`no upstream — set it while pushing?`:/fetch first|non-fast-forward|rejected.*fetch|behind/i.test(n)?C.value=`the remote has work you lack — pull first`:/authentication|permission|could not read|403|denied/i.test(n)?C.value=`credentials rejected on the device — check its git login`:C.value=``),e===`pull`&&/not possible to fast-forward|divergent|unrelated histories/i.test(n)&&(ee.value=!0),J(`git ${e}: ${n.slice(0,160)}`)}finally{d.value=``}}async function Ke(e,t,i=!1){if(!r.value||!n.value||(i&&(d.value=e),!t&&e!==`stage`))return;if(e===`discard`&&t&&!i){ie({title:`Roll back to HEAD?`,body:`${t} — uncommitted changes are lost.`,confirmLabel:`Roll back`,danger:!0,action:()=>void Ke(e,t,!0)});return}d.value=e;let a=t?[t]:Oe.value.filter(e=>e.x===` `||e.x===`M`).map(e=>e.path);try{J((await W(r.value).gitOp(n.value,e,{files:a})).text),await De()}catch(t){J(`${e} failed: ${t.message.slice(0,140)}`)}finally{d.value=``}}async function qe(e){if(r.value&&n.value&&e.length){d.value=`unstage`;try{J((await W(r.value).gitOp(n.value,`unstage`,{files:e})).text),await De()}catch(e){J(`unstage failed: ${e.message.slice(0,140)}`)}finally{d.value=``}}}async function Je(e,t){if(r.value&&n.value){d.value=`resolve`;try{J((await W(r.value).gitOp(n.value,`resolve`,{side:e,files:[t]})).text),await De()}catch(e){J(`resolve failed: ${e.message.slice(0,140)}`)}finally{d.value=``}}}async function Ye(e){if(r.value&&n.value&&e.length){d.value=`ignore`;try{J((await W(r.value).gitOp(n.value,`ignore`,{lines:e})).text),await De()}catch(e){J(`ignore failed: ${e.message.slice(0,140)}`)}finally{d.value=``}}}async function Xe(e){if(r.value&&n.value){if(v.value?.path===e)return v.value=null;d.value=`diff`;try{let t=await W(r.value).gitOp(n.value,`diff-file`,{target:e,staged:y.value===`staged`});v.value={path:e,text:t.text}}catch(e){J(`diff failed: ${e.message.slice(0,140)}`)}finally{d.value=``}}}let Ze=async()=>{let e=v.value?.path;v.value=null,e&&await Xe(e)},Qe=H(()=>/Binary files .* differ/i.test(v.value?.text??``));async function $e(){if(r.value&&n.value){d.value=`abort`;try{J((await W(r.value).gitOp(n.value,`merge-abort`)).text),await De()}catch(e){J(`abort failed: ${e.message.slice(0,120)}`)}finally{d.value=``}}}async function et(e){if(h.value=!1,r.value&&n.value){d.value=`compare`;try{let t=await W(r.value).gitOp(n.value,`compare`,{ref:e});x.value={ref:e,ahead:t.ahead??0,behind:t.behind??0}}catch(e){J(`compare failed: ${e.message.slice(0,140)}`)}finally{d.value=``}}}async function tt(e,t=!1){if(h.value=!1,!r.value||!n.value||e===a.value?.branch&&!t)return;d.value=`switch`;let i=W(r.value),o=!1;try{if(S.value&&!t&&Fe.value&&(await i.gitOp(n.value,`stash-push`,{message:`dpi auto-stash before ${e}`}),o=!0),J((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)&&J(`stash popped WITH CONFLICTS — resolve in the file list`)}catch{J(`switched, but the stash did not pop — resolve manually (git stash list)`)}await De(),bt(!0)}catch(e){if(J(`switch failed: ${e.message.slice(0,140)}`),o)try{await i.gitOp(n.value,`stash-pop`)}catch{}}finally{d.value=``}}async function nt(e=!1){if(!r.value||!n.value||!p.value.trim())return;d.value=`commit`;let t=Oe.value.filter(e=>m.value.has(e.path)).map(e=>e.path);if(!t.length)return J(`check the files to commit — nothing is selected`);let i=W(r.value);try{if(J((await i.gitOp(n.value,`commit`,{message:p.value.trim(),...a.value?.merge?{}:{files:t}})).text),p.value=``,e)try{J(`pushed: ${(await i.gitOp(n.value,`push`)).text.slice(0,80)}`)}catch(e){J(`committed, but push failed: ${e.message.slice(0,120)}`)}await De(),bt(!0)}catch(e){J(`commit failed: ${e.message.slice(0,140)}`)}finally{d.value=``}}function rt(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 it(){if(!r.value||!n.value)return;let e=Oe.value.filter(e=>m.value.has(e.path)).map(e=>e.path);if(!e.length)return J(`check files first — the model summarises THOSE`);d.value=`ai`;let t=W(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=Hu.devices.value.find(e=>e.id===r.value)?.info,s=rt(o);if(!s.length)return d.value=``,J(`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(`
79
- `)[0]?.slice(0,100):``;if(i){p.value=i;return}c.push(`${e.provider}/${e.id}: ${n.status===`unanswered`?n.reason:`empty answer`}`)}finally{t.session(r).archive().catch(()=>{})}}J(`ai message failed on every model — ${c.join(`; `).slice(0,140)}`)}catch(e){J(`ai message failed: ${e.message.slice(0,120)}`)}finally{d.value=``}}async function at(){if(r.value&&u.value){d.value=`session-files`;try{let e=await W(r.value).sessionGitFiles(u.value);w.value=e.files;let t=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,i=new Set(e.files.map(t)),a=Oe.value.filter(e=>i.has(t(e.path)));m.value=new Set(a.map(e=>e.path)),J(a.length?`${a.length} session file(s) still changed — checked`:`the session touched nothing that is still changed`)}catch(e){J(`session files failed: ${e.message.slice(0,120)}`)}finally{d.value=``}}}async function ot(e){if(ce.value.has(e)){ce.value.delete(e),ce.value=new Map(ce.value);return}if(r.value&&n.value)try{let t=await W(r.value).gitOp(n.value,`show-files`,{target:e});ce.value=new Map(ce.value).set(e,t.changed??[])}catch(e){J(`commit files failed: ${e.message.slice(0,120)}`)}}async function st(){if(!r.value||!n.value)return;let e=`cp-${new Date().toISOString().slice(0,16).replace(/[-:T]/g,``)}`;d.value=`checkpoint`;try{J((await W(r.value).gitOp(n.value,`checkpoint`,{name:e})).text),se.value=!0,await ct()}catch(e){J(`checkpoint failed: ${e.message.slice(0,120)}`)}finally{d.value=``}}async function ct(){if(r.value&&n.value)try{let e=await W(r.value).gitOp(n.value,`checkpoints`);oe.value=e.checkpoints??[]}catch{oe.value=[]}}async function lt(e){if(!r.value||!n.value)return;let t=e;ie({title:`Rewind to ${t}?`,body:`reset --hard — ALL uncommitted changes in this worktree are LOST.`,confirmLabel:`Rewind`,danger:!0,action:()=>void ut(t)})}async function ut(e){if(r.value&&n.value){d.value=`rewind`;try{J((await W(r.value).gitOp(n.value,`rewind`,{name:e})).text),await De(),bt(!0)}catch(e){J(`rewind failed: ${e.message.slice(0,120)}`)}finally{d.value=``}}}j(se,e=>{e&&ct()});async function dt(e){if(g.value=!1,r.value&&n.value&&a.value?.root){d.value=`wt`;try{J((await wp(W(r.value),n.value,a.value.root,e)).text),_.value=``,await De()}catch(e){J(`worktree failed: ${e.message.slice(0,140)}`)}finally{d.value=``}}}async function ft(e,t){if(r.value){d.value=`session`;try{let n=Hu.devices.value.find(e=>e.id===r.value)?.info,i=rt(n)[0];if(!i)return J(`no model available on ${r.value} — cannot create a session`);let a=await Tp(W(r.value),e,t??e.slice(e.lastIndexOf(`/`)+1),{provider:i.provider,modelId:i.id});ad({deviceId:r.value,sessionId:a.id,agentId:1}),J(`session "${a.name}" on ${e}`)}catch(e){J(`session failed: ${e.message.slice(0,160)}`)}finally{d.value=``}}}async function pt(e){if(r.value){d.value=`go`;try{let t=(await W(r.value).sessions()).find(t=>t.cwd===e);t?(ad({deviceId:r.value,sessionId:t.id,agentId:1}),J(`switched to session "${t.name}"`)):await ft(e,null)}catch(e){J(`switch failed: ${e.message.slice(0,120)}`)}finally{d.value=``}}}async function mt(e){if(!r.value||!n.value)return;d.value=`wt`;let t=`Uncommitted changes in it will be LOST.`;try{let n=(await W(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{}ie({title:`Remove worktree?`,body:`${e} — ${t}`,confirmLabel:`Remove`,danger:!0,action:()=>void ht(e)})}async function ht(e){d.value=`wt`;try{await W(r.value).gitOp(n.value,`worktree-remove`,{target:e}),await De()}catch(e){J(`remove failed: ${e.message.slice(0,140)}`)}finally{d.value=``}}let gt=O([]),_t=O(!1),vt=O(``),yt=0;async function bt(e=!1){if(!r.value||!n.value||!e&&gt.value.length&&Date.now()-yt<12e4)return;let t=bf(r.value,n.value);if(!t.ok){gt.value=[],vt.value=t.reason,yt=Date.now();return}_t.value=!0;try{let e=await W(r.value).gitOp(n.value,`log-list`);gt.value=e.commits??[],vt.value=``,yt=Date.now()}catch(e){vt.value=e.message.slice(0,120)}finally{_t.value=!1}}bt(),j([r,n],()=>{gt.value=[],yt=0,bt()});let xt=H(()=>(a.value?.worktrees??[]).filter(e=>e.path)),St=[`#4f8cc9`,`#b8860b`,`#7aa25c`,`#a061ba`,`#c96f6f`,`#5fa8a0`],Ct=H(()=>{let e=new Map,t=[],n=[];for(let r of gt.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}),wt=e=>e*12+7;return(e,t)=>(F(),I(`div`,yx,[n.value?(F(),I(P,{key:1},[o.value?(F(),I(`p`,xx,`loading git…`)):c.value?(F(),I(`p`,Sx,`refreshing…`)):V(``,!0),s.value?(F(),I(`div`,Cx,[R(`p`,null,[R(`strong`,null,D(n.value),1),t[41]||=B(` is not served by this device — its start dirs are `,-1),R(`code`,null,D(s.value),1),t[42]||=B(`. `,-1)]),t[43]||=R(`p`,{class:`muted-line`},[B(` Add the folder to `),R(`code`,null,`DPI_START_DIRS`),B(` on the device (then restart it), or open a session under one of the served folders. Retrying will not change this. `)],-1)])):l.value?(F(),I(`p`,wx,[B(D(l.value)+` `,1),R(`button`,{onClick:t[0]||=e=>De()},`retry`)])):V(``,!0),a.value?(F(),I(`div`,{key:4,class:E({stale:!!l.value||!!c.value})},[a.value.repo?(F(),I(P,{key:1},[a.value.merge?(F(),I(`p`,Ex,[B(` merge in progress — `+D(a.value.conflicts??Ne.value.length)+` unmerged path(s). Resolve them in the lists above, or `,1),R(`button`,{class:`small`,disabled:!!d.value,onClick:t[1]||=e=>$e()},`abort merge`,8,Dx)])):V(``,!0),R(`div`,Ox,[R(`div`,kx,[R(`button`,{class:`branch-btn`,disabled:!!d.value,onClick:t[2]||=e=>h.value=!h.value},[z(k(Sc),{size:16}),R(`strong`,null,D(a.value.branch??`detached`),1),z(k(rc),{size:14})],8,Ax),h.value?(F(),I(`div`,jx,[(F(!0),I(P,null,N(a.value.branches??[],e=>(F(),I(`button`,{key:e.name,class:E({cur:e.current}),onClick:t=>tt(e.name)},[z(k(Sc),{size:13}),R(`span`,null,D(e.name),1),R(`span`,Nx,D(e.current?`current`:e.upstream?`→ ${e.upstream}`:``),1),t[45]||=R(`span`,{class:`grow`},null,-1),e.current?V(``,!0):(F(),L(k(Cc),{key:0,size:13,title:`compare with this base`,onClick:As(t=>et(e.name),[`stop`])},null,8,[`onClick`]))],10,Mx))),128)),R(`div`,Px,[A(R(`input`,{"onUpdate:modelValue":t[3]||=e=>_.value=e,placeholder:`new branch…`,onKeyup:t[4]||=Ms(e=>_.value.trim()&&tt(_.value.trim(),!0),[`enter`])},null,544),[[bs,_.value]]),R(`button`,{disabled:!_.value.trim(),onClick:t[5]||=e=>tt(_.value.trim(),!0)},[z(k(Zc),{size:13})],8,Fx)]),R(`label`,Ix,[A(R(`input`,{type:`checkbox`,"onUpdate:modelValue":t[6]||=e=>S.value=e},null,512),[[xs,S.value]]),t[46]||=B(` auto-stash on switch`,-1)])])):V(``,!0)]),R(`span`,Lx,D(a.value.upstream??`no upstream`),1),a.value.ahead?(F(),I(`span`,Rx,`↑`+D(a.value.ahead),1)):V(``,!0),a.value.behind?(F(),I(`span`,zx,`↓`+D(a.value.behind),1)):V(``,!0),x.value?(F(),I(`span`,Bx,[B(` vs `+D(x.value.ref)+`: ↑`+D(x.value.ahead)+` ↓`+D(x.value.behind)+` `,1),R(`button`,{class:`tag-x`,onClick:t[7]||=e=>x.value=null},[z(k(Sl),{size:11})])])):V(``,!0),R(`span`,Vx,`+`+D(a.value.staged??0)+` ~`+D(a.value.unstaged??0)+` ?`+D(a.value.untracked??0),1),Le.value?(F(),I(`a`,{key:3,class:`icon-button`,href:`${Le.value}/tree/${a.value.branch??``}`,target:`_blank`,rel:`noopener`,title:`open on the remote`},[z(k(qs),{size:15,style:{transform:`rotate(45deg)`}})],8,Hx)):V(``,!0),R(`button`,{class:`icon-button`,disabled:!!d.value||o.value||c.value,title:`refresh`,onClick:t[8]||=e=>De()},[z(k(el),{size:16})],8,Ux)]),R(`div`,Wx,[R(`button`,{class:`small`,disabled:!!d.value,onClick:t[9]||=e=>Ge(`fetch`)},[z(k(Gs),{size:14}),t[47]||=B(`fetch`,-1)],8,Gx),R(`button`,{class:`small`,disabled:!!d.value,onClick:t[10]||=e=>Ge(`pull`)},[z(k(Gs),{size:14}),t[48]||=B(`pull`,-1)],8,Kx),R(`button`,{class:`small primary`,disabled:!!d.value,title:`push`,onClick:t[11]||=e=>Ge(`push`)},[z(k(qs),{size:14}),t[49]||=B(`push`,-1)],8,qx),R(`button`,{class:`small`,disabled:!!d.value,title:`stash changes`,onClick:t[12]||=e=>Ge(`stash-push`,{message:p.value.trim()||void 0})},[z(k(fl),{size:14}),t[50]||=B(`stash`,-1)],8,Jx),R(`button`,{class:`small`,disabled:!!d.value,title:`pop the newest stash`,onClick:t[13]||=e=>Ge(`stash-pop`)},[z(k(Uc),{size:14}),t[51]||=B(`unstash`,-1)],8,Yx)]),C.value?(F(),I(`p`,Xx,[B(D(C.value)+` `,1),C.value.includes(`upstream`)?(F(),I(`button`,{key:0,class:`small primary`,disabled:!!d.value,onClick:t[14]||=e=>Ge(`push`,{setUpstream:!0,ref:a.value.branch})},`push -u origin `+D(a.value.branch),9,Zx)):C.value.includes(`remote has work`)?(F(),I(`button`,{key:1,class:`small primary`,disabled:!!d.value,onClick:t[15]||=e=>Ge(`pull`)},`pull now`,8,Qx)):V(``,!0)])):V(``,!0),ee.value?(F(),I(`p`,$x,[t[52]||=B(` fast-forward is not possible — branches diverged. `,-1),R(`button`,{class:`small primary`,disabled:!!d.value,onClick:t[16]||=e=>Ge(`pull`,{rebase:!0})},`pull --rebase`,8,eS)])):V(``,!0),R(`section`,tS,[R(`div`,nS,[t[53]||=R(`h4`,null,`Commit`,-1),R(`span`,rS,D(Oe.value.length?`${m.value.size}/${Oe.value.length} files`:`no changes`),1),t[54]||=R(`span`,{class:`grow`},null,-1),u.value?(F(),I(`button`,{key:0,class:`small`,disabled:!!d.value,title:`check the files this session's agent touched`,onClick:at},[z(k(vc),{size:13}),B(` session files`+D(te.value?` (${te.value.changed}/${te.value.total})`:``),1)],8,iS)):V(``,!0),u.value?(F(),I(`button`,{key:1,class:`small`,disabled:!!d.value,title:`what each turn of this session changed`,onClick:t[17]||=e=>Se.value=!Se.value},` turns `,8,aS)):V(``,!0)]),Ie.value?(F(),I(`p`,oS,[...t[55]||=[B(`git user.name/user.email is not set on the device — `,-1),R(`code`,null,`dpi device config`,-1),B(` or `,-1),R(`code`,null,`git config --global`,-1),B(` before committing.`,-1)]])):V(``,!0),Se.value?(F(),I(`div`,sS,[xe.value.length?V(``,!0):(F(),I(`p`,cS,`no turns recorded yet for this session.`)),(F(!0),I(P,null,N(xe.value,(e,t)=>(F(),I(`div`,{key:t,class:`cp-row`},[R(`code`,null,`t`+D(xe.value.length-t),1),R(`span`,lS,D(e.when.slice(0,16).replace(`T`,` `)),1),R(`span`,uS,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))])):V(``,!0),Pe.value?(F(),I(`p`,dS,`showing the first 500 changed files — commit in smaller batches`)):V(``,!0),Ne.value.length?(F(),I(`div`,fS,[R(`label`,pS,[R(`span`,mS,`Conflicts · `+D(Ne.value.length)+` — pick a side per file`,1)]),(F(!0),I(P,null,N(Ne.value,e=>(F(),I(`div`,{key:e.path,class:`file`},[R(`label`,hS,[R(`code`,gS,D(e.x)+D(e.y),1),R(`span`,{class:`path`,title:e.path},D(e.path),9,_S)]),R(`span`,vS,[R(`button`,{class:`icon-button`,title:`view the conflict`,onClick:t=>Xe(e.path)},[z(k(gc),{size:13})],8,yS),R(`button`,{class:`small`,disabled:!!d.value,title:`keep this branch's version and stage it`,onClick:t=>Je(`ours`,e.path)},`ours`,8,bS),R(`button`,{class:`small`,disabled:!!d.value,title:`take the incoming version and stage it`,onClick:t=>Je(`theirs`,e.path)},`theirs`,8,xS)])]))),128))])):V(``,!0),Ae.value.length?(F(),I(`div`,SS,[R(`label`,CS,[R(`input`,{type:`checkbox`,checked:Ae.value.every(e=>m.value.has(e.path)),onChange:t[18]||=e=>ze(Ae.value)},null,40,wS),R(`span`,TS,`Staged · `+D(Ae.value.length),1),t[58]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,title:`stage every changed file`,onClick:t[19]||=e=>Ke(`stage`)},[z(k(Zc),{size:13}),t[56]||=B(` all`,-1)]),R(`button`,{class:`icon-button`,title:`unstage all (git reset HEAD)`,onClick:t[20]||=e=>qe(Ae.value.map(e=>e.path))},[z(k(zc),{size:13}),t[57]||=B(` none`,-1)])]),(F(!0),I(P,null,N(Ve(Ae.value),e=>(F(),I(P,{key:e.dir},[e.dir===`.`?V(``,!0):(F(),I(`button`,{key:0,class:`dir-row`,onClick:t=>He(e.dir)},[z(k(ic),{size:12,class:E({open:e.open})},null,8,[`class`]),B(D(e.dir),1),R(`span`,DS,`· `+D(e.files.length),1)],8,ES)),(F(!0),I(P,null,N(e.files,t=>A((F(),I(`div`,{key:t.path,class:`file`},[R(`label`,OS,[R(`input`,{type:`checkbox`,checked:m.value.has(t.path),onChange:e=>Re(t.path)},null,40,kS),R(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,AS),R(`span`,{class:`path`,title:t.path},D(t.path),9,jS),Ue(t)?(F(),I(`span`,{key:0,class:E([`nums`,{bin:Ue(t)===`bin`}])},D(Ue(t)),3)):V(``,!0)]),R(`span`,MS,[R(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Xe(t.path)},[z(k(gc),{size:13})],8,NS),R(`button`,{class:`icon-button`,title:`unstage (git reset HEAD)`,onClick:e=>qe([t.path])},[z(k(zc),{size:13})],8,PS),R(`button`,{class:`icon-button`,title:`roll back to HEAD`,onClick:e=>Ke(`discard`,t.path)},[z(k(dc),{size:13})],8,FS)])])),[[zo,e.open]])),128))],64))),128))])):V(``,!0),je.value.length?(F(),I(`div`,IS,[R(`label`,LS,[R(`input`,{type:`checkbox`,checked:je.value.every(e=>m.value.has(e.path)),onChange:t[21]||=e=>ze(je.value)},null,40,RS),R(`span`,zS,`Unstaged · `+D(je.value.length),1)]),(F(!0),I(P,null,N(Ve(je.value),e=>(F(),I(P,{key:e.dir},[e.dir===`.`?V(``,!0):(F(),I(`button`,{key:0,class:`dir-row`,onClick:t=>He(e.dir)},[z(k(ic),{size:12,class:E({open:e.open})},null,8,[`class`]),B(D(e.dir),1),R(`span`,VS,`· `+D(e.files.length),1)],8,BS)),(F(!0),I(P,null,N(e.files,t=>A((F(),I(`div`,{key:t.path,class:`file`},[R(`label`,HS,[R(`input`,{type:`checkbox`,checked:m.value.has(t.path),onChange:e=>Re(t.path)},null,40,US),R(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,WS),R(`span`,{class:`path`,title:t.path},D(t.path),9,GS),Ue(t)?(F(),I(`span`,{key:0,class:E([`nums`,{bin:Ue(t)===`bin`}])},D(Ue(t)),3)):V(``,!0)]),R(`span`,KS,[R(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Xe(t.path)},[z(k(gc),{size:13})],8,qS),t.x===`?`?(F(),I(`button`,{key:0,class:`icon-button`,title:`add to .gitignore`,onClick:e=>Ye([t.path])},[z(k(Xs),{size:13})],8,JS)):(F(),I(`button`,{key:1,class:`icon-button`,title:`stage (git add)`,onClick:e=>Ke(`stage`,t.path)},[z(k(Zc),{size:13})],8,YS)),t.x===`?`?V(``,!0):(F(),I(`button`,{key:2,class:`icon-button`,title:`roll back to HEAD`,onClick:e=>Ke(`discard`,t.path)},[z(k(dc),{size:13})],8,XS)),R(`button`,{class:`icon-button`,title:`copy path`,onClick:e=>We(t.path)},[z(k(cc),{size:13})],8,ZS)])])),[[zo,e.open]])),128))],64))),128))])):V(``,!0),v.value?(F(),I(`p`,QS,[R(`strong`,null,D(v.value.path),1),R(`span`,$S,[R(`button`,{class:E({on:y.value===`working`}),onClick:t[22]||=e=>{y.value=`working`,Ze()}},`working`,2),R(`button`,{class:E({on:y.value===`staged`}),onClick:t[23]||=e=>{y.value=`staged`,Ze()}},`staged`,2)]),Qe.value?(F(),I(`span`,eC,`binary file`)):v.value.text.length>8e3?(F(),I(`span`,tC,`truncated at 8000 chars`)):V(``,!0),R(`button`,{class:`icon-button`,title:`close diff`,onClick:t[24]||=e=>v.value=null},[z(k(Sl),{size:13})]),Qe.value?V(``,!0):(F(),I(`pre`,nC,D(v.value.text.slice(0,8e3)),1))])):V(``,!0),A(R(`textarea`,{"onUpdate:modelValue":t[25]||=e=>p.value=e,rows:`4`,placeholder:`Commit message… (Ctrl+Enter to commit)`,onKeydown:[t[26]||=Ms(As(e=>nt(),[`exact`,`prevent`]),[`enter`]),t[27]||=Ms(As(e=>nt(),[`meta`,`prevent`]),[`enter`]),t[28]||=Ms(As(e=>nt(),[`ctrl`,`prevent`]),[`enter`])]},null,544),[[bs,p.value]]),R(`div`,rC,[R(`button`,{class:`small`,disabled:!!d.value||!m.value.size,title:`ask the device's model for a message`,onClick:it},[z(k(ul),{size:14}),t[59]||=B(` ai message`,-1)],8,iC),t[61]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`primary small`,disabled:!!d.value||!p.value.trim()||!ke.value,onClick:t[29]||=e=>nt(!1)},[z(k(nc),{size:14}),B(` Commit`+D(m.value.size?` ${m.value.size} file${m.value.size>1?`s`:``}`:``),1)],8,aC),a.value.upstream?(F(),I(`button`,{key:0,class:`primary small`,disabled:!!d.value||!p.value.trim()||!ke.value,title:`commit, then push`,onClick:t[30]||=e=>nt(!0)},[z(k(nc),{size:14}),t[60]||=B(` Commit & push `,-1)],8,oC)):V(``,!0)])]),R(`section`,sC,[R(`div`,cC,[R(`h4`,null,[z(k(Dc),{size:16}),t[62]||=B(` Log`,-1)]),t[64]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:!!d.value,title:`save a checkpoint ref of HEAD`,onClick:st},[z(k(vc),{size:13}),t[63]||=B(` checkpoint`,-1)],8,lC),R(`button`,{class:`small`,disabled:!!d.value,onClick:t[31]||=e=>se.value=!se.value},`checkpoints `+D(oe.value.length?`(${oe.value.length})`:``),9,uC),R(`button`,{class:`icon-button`,disabled:_t.value,title:`refresh log`,onClick:t[32]||=e=>bt(!0)},[z(k(el),{size:14})],8,dC)]),se.value?(F(),I(`div`,fC,[oe.value.length?V(``,!0):(F(),I(`p`,pC,`no checkpoints yet — one click saves a named ref of HEAD.`)),(F(!0),I(P,null,N(oe.value,e=>(F(),I(`div`,{key:e.name,class:`cp-row`},[R(`code`,null,D(e.name),1),R(`span`,mC,D(e.hash)+` · `+D(e.date),1),R(`span`,hC,D(e.subject),1),t[66]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:!!d.value,title:`reset --hard to this checkpoint (this worktree)`,onClick:t=>lt(e.name)},[z(k(gl),{size:13}),t[65]||=B(` rewind`,-1)],8,gC)]))),128))])):V(``,!0),_t.value&&!gt.value.length?(F(),I(`p`,_C,`loading log…`)):gt.value.length?(F(),I(`div`,vC,[(F(!0),I(P,null,N(gt.value,(e,t)=>(F(),I(P,{key:e.hash},[R(`div`,{class:`commit-row`,title:e.refs},[Ct.value[t]?(F(),I(`svg`,{key:0,class:`lane`,width:Ct.value[t].width*12+4,height:`24`,"aria-hidden":`true`},[(F(!0),I(P,null,N(Ct.value[t].width,e=>(F(),I(`line`,{key:e,x1:wt(e-1),x2:wt(e-1),y1:`0`,y2:`24`,stroke:`#3a3134`,"stroke-width":`2`},null,8,xC))),128)),(F(!0),I(P,null,N(Ct.value[t].parents,(e,n)=>(F(),I(`line`,{key:`p`+n,x1:wt(Ct.value[t].lane),x2:wt(e),y1:`12`,y2:`24`,stroke:St[e%St.length],"stroke-width":`2`},null,8,SC))),128)),R(`circle`,{cx:wt(Ct.value[t].lane),cy:`12`,r:`4`,fill:St[Ct.value[t].lane%St.length]},null,8,CC)],8,bC)):V(``,!0),R(`button`,{class:`icon-button hash-btn`,title:`files in this commit`,onClick:t=>ot(e.hash)},[z(k(ic),{size:12,class:E({open:ce.value.has(e.hash)})},null,8,[`class`])],8,wC),R(`code`,TC,[Le.value?(F(),I(`a`,{key:0,href:`${Le.value}/commit/${e.hash}`,target:`_blank`,rel:`noopener`,title:`on the remote`},D(e.hash),9,EC)):(F(),I(P,{key:1},[B(D(e.hash),1)],64))]),e.refs?(F(),I(`span`,DC,D(e.refs.split(`,`)[0]),1)):V(``,!0),R(`span`,OC,D(e.subject),1),R(`span`,kC,D(e.author)+` · `+D(e.date),1)],8,yC),ce.value.has(e.hash)?(F(),I(`div`,AC,[(F(!0),I(P,null,N(ce.value.get(e.hash),e=>(F(),I(`div`,{key:e.path,class:`cf`},[R(`code`,{class:`cf-status`,"data-s":e.status},D(e.status),9,jC),R(`span`,MC,D(e.path),1)]))),128)),ce.value.get(e.hash)?.length?V(``,!0):(F(),I(`p`,NC,`no files (merge/empty commit)`))])):V(``,!0)],64))),128))])):vt.value?(F(),I(`p`,PC,`log failed: `+D(vt.value),1)):(F(),I(`p`,FC,`no commits`))]),R(`section`,IC,[R(`div`,LC,[R(`h4`,null,[z(k(Uc),{size:16}),t[67]||=B(` Worktrees`,-1)]),R(`div`,RC,[R(`button`,{class:`small`,disabled:!!d.value,onClick:t[33]||=e=>g.value=!g.value},[z(k(Zc),{size:13}),t[68]||=B(` worktree`,-1)],8,zC),g.value?(F(),I(`div`,BC,[(F(!0),I(P,null,N((a.value.branches??[]).filter(e=>!e.current),e=>(F(),I(`button`,{key:e.name,onClick:t=>dt(e.name)},[z(k(Sc),{size:13}),R(`span`,null,D(e.name),1),t[69]||=R(`span`,{class:`muted-line`},`existing`,-1)],8,VC))),128)),R(`div`,HC,[A(R(`input`,{"onUpdate:modelValue":t[34]||=e=>_.value=e,placeholder:`or a NEW branch…`,onKeyup:t[35]||=Ms(e=>_.value.trim()&&dt(_.value.trim()),[`enter`])},null,544),[[bs,_.value]]),R(`button`,{disabled:!_.value.trim(),onClick:t[36]||=e=>dt(_.value.trim())},`create`,8,UC)])])):V(``,!0)])]),(F(!0),I(P,null,N(xt.value,e=>(F(),I(`div`,{key:e.path,class:E([`wt`,{main:e.path===a.value.root}])},[R(`code`,{title:e.path},D(e.path),9,WC),R(`span`,GC,D(e.branch??e.head),1),t[70]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,disabled:!!d.value,title:`jump to this worktree (session or new)`,onClick:t=>pt(e.path)},[z(k(Ks),{size:13})],8,KC),R(`button`,{class:`small`,disabled:!!d.value,title:`create a session on this worktree`,onClick:t=>ft(e.path,e.branch)},`session`,8,qC),e.path===a.value.root?V(``,!0):(F(),I(`button`,{key:0,class:`icon-button`,disabled:!!d.value,onClick:t=>mt(e.path)},[z(k(Sl),{size:13})],8,JC)),e.path===a.value.root?(F(),L(k(nc),{key:1,size:13,class:`muted-line`})):V(``,!0)],2))),128))]),fe.value?(F(),I(`section`,YC,[R(`div`,XC,[R(`h4`,null,[z(k(Tc),{size:16}),t[71]||=B(` Pull requests`,-1)]),t[72]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:de.value||!!d.value,onClick:me},`create PR`,8,ZC),R(`button`,{class:`small`,disabled:de.value,onClick:t[37]||=e=>T.value=!T.value},D(T.value?`hide`:`list`),9,QC)]),T.value&&!le.value.length&&!de.value?(F(),I(`p`,$C,`no open PRs (or gh is not logged in on the device — every action will say so).`)):V(``,!0),T.value?(F(),I(`div`,ew,[(F(!0),I(P,null,N(le.value,e=>(F(),I(`div`,{key:e.n,class:`pr-row`},[R(`code`,tw,`#`+D(e.n),1),R(`span`,{class:E([`tag`,{open:e.state===`OPEN`}])},D(e.state.toLowerCase())+D(e.draft?` · draft`:``),3),R(`span`,nw,D(e.title),1),R(`span`,rw,D(e.branch),1),t[73]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,title:`run checks`,disabled:de.value,onClick:t=>ge(e.n)},[z(k(el),{size:13})],8,iw),R(`button`,{class:`icon-button`,title:`comment`,disabled:de.value,onClick:t=>ye(e.n)},[z(k(cc),{size:13})],8,aw),e.state===`OPEN`?(F(),I(`button`,{key:0,class:`small`,disabled:de.value||!!d.value,onClick:t=>_e(e.n)},`squash & merge`,8,ow)):V(``,!0),R(`a`,{class:`icon-button`,href:e.url,target:`_blank`,rel:`noopener`,title:`open on the forge`},[z(k(qs),{size:13,style:{transform:`rotate(45deg)`}})],8,sw)]))),128)),(F(!0),I(P,null,N(ue.value,([e,t])=>(F(),I(`pre`,{key:e,class:`pr-checks`},`#`+D(e)+` checks:`+D(`
80
- `)+D(t),1))),128))])):V(``,!0)])):V(``,!0),f.value?(F(),I(`pre`,cw,D(f.value.slice(0,6e3)),1)):V(``,!0)],64)):(F(),I(`p`,Tx,[...t[44]||=[B(`Not a git repository — run `,-1),R(`code`,null,`git init`,-1),B(` (or open a session inside a repo).`,-1)]]))],2)):V(``,!0),ne.value?(F(),I(`div`,{key:5,class:`modal-veil`,onClick:t[40]||=As(e=>ne.value=null,[`self`])},[R(`div`,{class:E([`modal`,{danger:ne.value.danger}]),role:`dialog`,"aria-modal":`true`},[R(`h5`,null,D(ne.value.title),1),R(`p`,null,D(ne.value.body),1),ne.value.input?A((F(),I(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>re.value=e,rows:`2`,placeholder:ne.value.input.placeholder},null,8,lw)),[[bs,re.value]]):V(``,!0),R(`div`,uw,[t[75]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,onClick:t[39]||=e=>ne.value=null},[...t[74]||=[B(`cancel `,-1),R(`span`,{class:`muted-line`},`(esc)`,-1)]]),R(`button`,{class:E([`primary small`,{danger:ne.value.danger}]),disabled:!(!ne.value.input||re.value.trim()),onClick:ae},D(ne.value.confirmLabel??`confirm`),11,dw)])],2)])):V(``,!0)],64)):(F(),I(`p`,bx,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-fba0896c`]]),pw={class:`host-panel`,"aria-label":`Device vitals`},mw={class:`panel-heading`},hw=[`disabled`],gw={key:0,class:`hint`},_w={key:1,class:`message-error`},vw={key:2,class:`hint`},yw={class:`vitals-grid`},bw={class:`vital`},xw={class:`vital`},Sw={key:0,class:`vital`},Cw={class:`vital`},ww={class:`vital`},Tw={class:`meter`},Ew={class:`meter-head`},Dw={class:`hint`},Ow=[`aria-valuenow`],kw={class:`meter`},Aw={class:`meter-head`},jw={class:`hint`},Mw=[`aria-valuenow`],Nw={class:`path`},Pw={class:`hint`},Fw=sf(M({__name:`HostPanel`,setup(e){let t=O(),n=O(!1),r=O(``),i=H(()=>K.value?.deviceId),a=H(()=>Hu.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=H(()=>t.value?c(t.value.memory.usedBytes,t.value.memory.totalBytes):0),u=H(()=>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 W(e).vitals()}catch(e){r.value=G(e).slice(0,160)}finally{n.value=!1}}}j(i,d,{immediate:!0});async function f(){await d(),r.value||J(`Vitals refreshed.`)}return(e,c)=>(F(),I(`section`,pw,[R(`header`,mw,[R(`span`,null,[z(k(al),{size:16}),c[0]||=B(`HOST`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:f},[z(k(el),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,hw)]),i.value?r.value?(F(),I(`p`,_w,D(r.value),1)):t.value?(F(),I(P,{key:3},[R(`div`,yw,[R(`div`,bw,[c[1]||=R(`span`,{class:`label`},`Host uptime`,-1),R(`strong`,null,D(s(t.value.uptime)),1)]),R(`div`,xw,[c[2]||=R(`span`,{class:`label`},`Device process`,-1),R(`strong`,null,D(s(t.value.processUptime)),1),R(`em`,null,`pid `+D(t.value.pid),1)]),a.value?(F(),I(`div`,Sw,[c[3]||=R(`span`,{class:`label`},`Keep-awake`,-1),R(`strong`,null,D(a.value===`none`?`off`:a.value),1),R(`em`,null,D(a.value===`none`?`no inhibitor here`:`held while sessions run`),1)])):V(``,!0),R(`div`,Cw,[c[4]||=R(`span`,{class:`label`},`Load (1/5/15m)`,-1),R(`strong`,null,D(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),R(`em`,null,D(t.value.cpuCount)+` CPU`+D(t.value.cpuCount===1?``:`s`),1)]),R(`div`,ww,[c[5]||=R(`span`,{class:`label`},`Sessions`,-1),R(`strong`,null,D(t.value.counts?.sessions??0),1),R(`em`,null,D(t.value.counts?.archived??0)+` archived`,1)])]),R(`div`,Tw,[R(`div`,Ew,[c[6]||=R(`span`,{class:`label`},`Memory`,-1),R(`span`,Dw,D(o(t.value.memory.usedBytes))+` / `+D(o(t.value.memory.totalBytes))+` · device `+D(o(t.value.memory.processRssBytes)),1)]),R(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[R(`i`,{style:ge({width:`${l.value}%`}),class:E({high:l.value>=90})},null,6)],8,Ow)]),R(`div`,kw,[R(`div`,Aw,[c[7]||=R(`span`,{class:`label`},`Disk · data dir`,-1),R(`span`,jw,[t.value.disk.known?(F(),I(P,{key:0},[B(D(o(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+D(o(t.value.disk.freeBytes))+` free `,1)],64)):(F(),I(P,{key:1},[B(`unknown on this volume`)],64))])]),R(`div`,{class:`bar`,role:`meter`,"aria-valuenow":u.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[R(`i`,{style:ge({width:`${u.value}%`}),class:E({high:u.value>=90})},null,6)],8,Mw),R(`code`,Nw,D(t.value.disk.path),1)]),R(`p`,Pw,[z(k(Hs),{size:13}),c[8]||=B(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(F(),I(`p`,vw,D(n.value?`Reading host…`:`No vitals.`),1)):(F(),I(`p`,gw,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-ef6f9dc5`]]);function Iw(e){let t=G(e);return e.code===`not_found`||/allowlist|not found/i.test(t)}function Lw(e,t){let n=Hu.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 Rw={class:`usage-panel`,"aria-label":`Device usage`},zw={class:`panel-heading`},Bw=[`disabled`],Vw={key:0,class:`hint`},Hw={key:1,class:`message-error`},Uw={key:2,class:`hint`},Ww={key:3,class:`hint`},Gw={class:`usage-block`,"aria-labelledby":`usage-totals`},Kw={class:`totals`},qw={class:`total`},Jw={class:`total`},Yw={class:`total`},Xw={class:`total`},Zw={class:`usage-block`,"aria-labelledby":`usage-models`},Qw={class:`section-label block-label`},$w={class:`table-scroll`},eT={class:`usage-table`,"aria-label":`Usage by model`},tT=[`title`],nT={class:`num`},rT={class:`num`},iT={class:`share-col`},aT={class:`share`},oT=[`aria-valuenow`,`aria-label`],sT={class:`pct`},cT={class:`usage-block`,"aria-labelledby":`usage-projects`},lT={class:`section-label block-label`},uT={key:0,class:`hint`},dT={key:1,class:`rows`},fT=[`title`],pT={class:`row-main`},mT={class:`row-num`},hT={class:`row-num`},gT={class:`row-meta`},_T={class:`usage-block`,"aria-labelledby":`usage-sessions`},vT={key:0,class:`hint`},yT={key:1,class:`rows scroll`},bT=[`title`],xT={class:`row-main`},ST={class:`row-num`},CT={class:`row-num`},wT={class:`row-meta`},TT={class:`hint`},ET=sf(M({__name:`UsagePanel`,setup(e){let t=O(),n=O(!1),r=O(``),i=H(()=>K.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=H(()=>(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=H(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=H(()=>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 W(e).deviceUsage()}catch(e){r.value=Iw(e)?Lw(i.value,`usage`):G(e).slice(0,220)}finally{n.value=!1}}}j(i,f,{immediate:!0});async function p(){await f(),r.value||J(`Usage refreshed.`)}return(e,s)=>(F(),I(`section`,Rw,[R(`header`,zw,[R(`span`,null,[z(k(Hs),{size:16}),s[0]||=B(`USAGE`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[z(k(el),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,Bw)]),i.value?r.value?(F(),I(`p`,Hw,D(r.value),1)):t.value?l.value?(F(),I(`p`,Ww,`No usage recorded yet.`)):(F(),I(P,{key:4},[R(`section`,Gw,[s[6]||=R(`div`,{class:`section-label block-label`},[R(`span`,{id:`usage-totals`},`TOTALS`)],-1),R(`div`,Kw,[R(`div`,qw,[s[1]||=R(`span`,{class:`label`},`Tokens`,-1),R(`strong`,null,D(a(t.value.totals.tokens)),1)]),R(`div`,Jw,[s[2]||=R(`span`,{class:`label`},`Cost`,-1),R(`strong`,null,D(o(t.value.totals.cost)),1)]),R(`div`,Yw,[s[3]||=R(`span`,{class:`label`},`Sessions`,-1),R(`strong`,null,D(a(t.value.sessions.length)),1),R(`em`,null,D(a(t.value.projects.length))+` projects`,1)]),R(`div`,Xw,[s[4]||=R(`span`,{class:`label`},`Models`,-1),R(`strong`,null,D(a(t.value.models.length)),1),s[5]||=R(`em`,null,`costliest first`,-1)])])]),R(`section`,Zw,[R(`div`,Qw,[s[7]||=R(`span`,{id:`usage-models`},`BY MODEL`,-1),z(k(fc),{size:13})]),R(`div`,$w,[R(`table`,eT,[s[8]||=R(`colgroup`,null,[R(`col`),R(`col`),R(`col`),R(`col`)],-1),s[9]||=R(`thead`,null,[R(`tr`,null,[R(`th`,{scope:`col`},`Model`),R(`th`,{scope:`col`,class:`num`},`Tokens`),R(`th`,{scope:`col`,class:`num`},`Cost`),R(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),R(`tbody`,null,[(F(!0),I(P,null,N(t.value.models,e=>(F(),I(`tr`,{key:e.key},[R(`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,tT),R(`td`,nT,D(a(e.tokens)),1),R(`td`,rT,D(o(e.cost)),1),R(`td`,iT,[R(`div`,aT,[R(`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`},[R(`i`,{style:ge({width:`${c(e.cost)}%`}),class:E({high:c(e.cost)>90})},null,6)],8,oT),R(`em`,sT,D(c(e.cost))+`%`,1)])])]))),128))])])])]),R(`section`,cT,[R(`div`,lT,[s[10]||=R(`span`,{id:`usage-projects`},`BY PROJECT`,-1),z(k(yc),{size:13})]),t.value.projects.length?(F(),I(`ul`,dT,[(F(!0),I(P,null,N(t.value.projects,e=>(F(),I(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[R(`span`,pT,[R(`strong`,null,D(e.name),1),R(`em`,null,D(e.rootPath),1)]),R(`span`,mT,D(a(e.tokens))+` tok`,1),R(`span`,hT,D(o(e.cost)),1),R(`span`,gT,D(d(e.sessions,`session`)),1)],8,fT))),128))])):(F(),I(`p`,uT,`No project usage recorded yet.`))]),R(`section`,_T,[s[11]||=R(`div`,{class:`section-label block-label`},[R(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(F(),I(`ul`,yT,[(F(!0),I(P,null,N(t.value.sessions,e=>(F(),I(`li`,{key:e.id,class:`row`,title:e.cwd},[R(`span`,xT,[R(`strong`,null,D(e.name),1),R(`em`,null,D(e.project??e.cwd),1)]),R(`span`,ST,D(a(e.tokens))+` tok`,1),R(`span`,CT,D(o(e.cost)),1),R(`span`,wT,D(d(e.agents,`agent`)),1)],8,bT))),128))])):(F(),I(`p`,vT,`No session usage recorded yet.`))]),R(`p`,TT,[z(k(Hs),{size:13}),B(` Read on demand — open this tab or press refresh (`+D(u.value)+`). Nothing polls the device. `,1)])],64)):(F(),I(`p`,Uw,D(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(F(),I(`p`,Vw,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-7a8f5c75`]]),DT={class:`schedules-panel`,"aria-label":`Scheduled sessions`},OT={class:`panel-heading`},kT=[`disabled`],AT=[`disabled`],jT={key:0,class:`hint`},MT={key:1,class:`message-error`},NT=[`disabled`],PT={key:0,value:``},FT={key:1,value:``},IT=[`value`],LT={class:`trigger-row`},RT={class:`inline`},zT=[`disabled`],BT={class:`inline`},VT=[`disabled`],HT={class:`row`},UT=[`disabled`],WT={key:3,class:`hint`},GT={key:4,class:`schedule-list`},KT={class:`head`},qT={class:`tag`},JT={key:0,class:`tag running`},YT=[`title`],XT={class:`next`},ZT={class:`cwd`},QT={key:0,class:`message-error`},$T={class:`row`},eE=[`disabled`,`onClick`],tE=[`disabled`,`onClick`],nE=[`disabled`,`onClick`],rE=sf(M({__name:`SchedulesPanel`,setup(e){let t=O([]),n=O(``),r=O(``),i=O(!1),a=H(()=>K.value?.deviceId),o=()=>W(a.value??``),s=O(`60`),c=O(``),l=O(!1),u=O({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=Iw(e)?Lw(a.value,`schedules`):G(e).slice(0,220)}finally{i.value=!1}}j(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(),J(r)}catch(e){J(G(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=>q.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=O([]),y=O(!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){J(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(),J(`Schedule created. The device runs it on its own clock.`)}catch(e){J(G(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(F(),I(`section`,DT,[R(`header`,OT,[R(`span`,null,[z(k(tc),{size:16}),o[7]||=B(`SCHEDULES`,-1)]),R(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[z(k(el),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,kT),R(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:b},[z(k(Zc),{size:15})],8,AT)]),o[18]||=R(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(F(),I(`p`,MT,D(r.value),1)):V(``,!0):(F(),I(`p`,jT,`Select a session to see its device.`)),l.value?(F(),I(`form`,{key:2,class:`add-form`,onSubmit:As(x,[`prevent`])},[R(`label`,null,[o[8]||=B(`Name`,-1),A(R(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[bs,u.value.name]])]),R(`label`,null,[o[9]||=B(`Directory`,-1),A(R(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[bs,u.value.cwd]])]),R(`label`,null,[o[10]||=B(`Prompt`,-1),A(R(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[bs,u.value.prompt]])]),R(`label`,null,[o[11]||=B(`Model `,-1),A(R(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e,disabled:y.value},[y.value?(F(),I(`option`,PT,`loading…`)):v.value.length?V(``,!0):(F(),I(`option`,FT,`(no models — check the device)`)),(F(!0),I(P,null,N(v.value,e=>(F(),I(`option`,{key:e.key,value:e.key},D(e.key),9,IT))),128))],8,NT),[[Cs,u.value.model]])]),R(`div`,LT,[R(`label`,RT,[o[12]||=B(`Every `,-1),A(R(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,zT),[[bs,s.value]]),o[13]||=B(` min`,-1)]),o[15]||=R(`span`,{class:`muted`},`or`,-1),R(`label`,BT,[o[14]||=B(`daily at `,-1),A(R(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,VT),[[bs,c.value]])])]),R(`div`,HT,[R(`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,UT),R(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):V(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(F(),I(`p`,WT,D(i.value?`Reading schedules…`:`No schedules yet. Press + to add one.`),1)):V(``,!0),t.value.length?(F(),I(`ul`,GT,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:e.id,class:E([`schedule`,{off:!e.enabled}])},[R(`div`,KT,[R(`b`,null,D(e.name),1),R(`span`,qT,D(p(e)),1),e.running?(F(),I(`span`,JT,`running`)):e.lastOutcome===`failed`?(F(),I(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,YT)):V(``,!0),R(`span`,XT,D(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),R(`code`,ZT,D(e.cwd),1),e.lastError?(F(),I(`p`,QT,D(e.lastError.slice(0,160)),1)):V(``,!0),R(`div`,$T,[R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[z(k(Xc),{size:12}),o[16]||=B(`run now`,-1)],8,eE),R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[z(k(Qc),{size:12}),B(D(e.enabled?`pause`:`resume`),1)],8,tE),R(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[z(k(hl),{size:12}),o[17]||=B(`remove`,-1)],8,nE)])],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-1284f0f2`]]),iE={class:`archive-panel`,"aria-label":`Old sessions`},aE={class:`panel-heading`},oE=[`disabled`],sE={key:0,class:`hint`},cE={key:1,class:`message-error`},lE={key:2,class:`hint`},uE={key:3,class:`old-list`},dE={class:`head`},fE=[`title`],pE={class:`meta`},mE=[`aria-label`,`onClick`],hE=[`aria-label`,`onClick`],gE={class:`facts`},_E={key:0,class:`cwd`},vE={key:1,class:`tag`},yE={class:`meta`},bE={class:`meta`},xE={key:2,class:`meta`},SE=sf(M({__name:`ArchivePanel`,setup(e){let t=O(null),n=O(!1),r=O(``),i=H(()=>K.value?.deviceId),a=()=>W(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=Iw(e)?Lw(i.value,`browsing old sessions`):G(e).slice(0,220)}finally{n.value=!1}}j(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){q.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(),J(`${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){J(G(e).slice(0,160))}}return(e,a)=>(F(),I(`section`,iE,[R(`header`,aE,[R(`span`,null,[z(k(Ws),{size:16}),a[0]||=B(`ARCHIVE`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh archive`,title:`Refresh archive`,onClick:o},[z(k(el),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,oE)]),a[2]||=R(`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?(F(),I(`p`,cE,D(r.value),1)):t.value&&!t.value.length?(F(),I(`p`,lE,`Nothing archived on this device yet.`)):V(``,!0):(F(),I(`p`,sE,`Select a session to see its device.`)),t.value?.length?(F(),I(`ul`,uE,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:`${e.sessionId}-${e.archivedAt}`,class:`old`},[R(`div`,dE,[R(`b`,null,D(e.name),1),R(`span`,{class:`tag`,title:e.hasManifest?`bundled with full identity`:`old bundle — name unknown`},D(e.hasManifest?`manifest`:`legacy`),9,fE),R(`span`,pE,`archived `+D(c(e.archivedAt)),1),a[1]||=R(`span`,{class:`spacer`},null,-1),R(`button`,{class:`icon-button`,"aria-label":`Download transcript of ${e.name}`,title:`Download transcript (markdown)`,onClick:t=>u(e)},[z(k(mc),{size:13})],8,mE),R(`button`,{class:`icon-button`,"aria-label":`Restore ${e.name}`,title:`Restore to the live list`,onClick:t=>l(e)},[z(k(nl),{size:13})],8,hE)]),R(`div`,gE,[e.cwd?(F(),I(`span`,_E,D(e.cwd),1)):V(``,!0),e.model?(F(),I(`span`,vE,D(e.model),1)):V(``,!0),R(`span`,yE,D(e.turns>=0?`${e.turns} turns`:`turns unknown`),1),R(`span`,bE,D(s(e.bytes)),1),e.lastMessageAt?(F(),I(`span`,xE,`last message `+D(c(e.lastMessageAt)),1)):V(``,!0)])]))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-054371cd`]]),CE={class:`graph-panel`,"aria-label":`Task graphs`},wE={class:`panel-heading`},TE=[`disabled`],EE=[`disabled`],DE={key:0,class:`hint`},OE={key:1,class:`message-error`},kE={key:2,class:`hint`},AE={class:`row`},jE=[`disabled`],ME={class:`head`},NE=[`title`],PE=[`aria-label`,`disabled`,`onClick`],FE=[`aria-label`,`onClick`],IE={class:`tasks`},LE=[`title`],RE={key:0,class:`deps`},zE={class:`tag`},BE={key:1,class:`err`},VE=sf(M({__name:`GraphPanel`,setup(e){let t=O([]),n=O({}),r=O(!1),i=O(``),a=O(``),o=O(!1),s=O(``),c=H(()=>K.value?.deviceId),l=()=>W(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=Iw(e)?Lw(c.value,`running task-graphs`):G(e).slice(0,220)}finally{r.value=!1}}j(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||J(`This graph has not run yet.`)}catch(e){J(G(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},J(`Run started: ${Object.keys(t.tasks).length} tasks.`),p(e)}catch(e){J(G(e).slice(0,140))}finally{a.value=``}}function h(e){q.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=``,J(`Graph "${n.name}" added (${n.tasks.length} tasks).`),await u()}catch(e){J(G(e).slice(0,200))}finally{a.value=``}}}return(e,l)=>(F(),I(`section`,CE,[R(`header`,wE,[R(`span`,null,[z(k(_l),{size:16}),l[3]||=B(`DAG`,-1)]),R(`button`,{class:`icon-button`,disabled:r.value||!c.value,"aria-label":`Refresh graphs`,title:`Refresh`,onClick:u},[z(k(el),{size:15,class:E({spin:r.value})},null,8,[`class`])],8,TE),R(`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},[z(k(Zc),{size:15})],8,EE)]),l[7]||=R(`p`,{class:`hint`},`Tasks run on the device, in dependency order — one fresh session each.`,-1),c.value?i.value?(F(),I(`p`,OE,D(i.value),1)):!t.value.length&&!o.value?(F(),I(`p`,kE,` No graphs yet. Press + and paste a graph JSON ({ name, cwd, tasks: [{ id, name, prompt, dependsOn }] }). `)):V(``,!0):(F(),I(`p`,DE,`Select a session to see its device.`)),o.value?(F(),I(`form`,{key:3,class:`add-form`,onSubmit:As(g,[`prevent`])},[R(`label`,null,[l[4]||=B(`Graph JSON `,-1),A(R(`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),[[bs,s.value]])]),R(`div`,AE,[R(`button`,{class:`primary small`,type:`submit`,disabled:a.value===`new`},D(a.value===`new`?`adding…`:`Add graph`),9,jE),R(`button`,{class:`small`,type:`button`,onClick:l[2]||=e=>o.value=!1},`Cancel`)])],32)):V(``,!0),(F(!0),I(P,null,N(t.value,e=>(F(),I(`div`,{key:e.id,class:`graph`},[R(`div`,ME,[R(`b`,null,D(e.name),1),R(`code`,{class:`cwd`,title:e.cwd},D(e.cwd.split(`/`).filter(Boolean).at(-1)||e.cwd),9,NE),R(`span`,{class:E([`tag`,d[e.lastRun?.status??`pending`]??``])},D(e.lastRun?e.lastRun.status:`never run`),3),l[5]||=R(`span`,{class:`spacer`},null,-1),R(`button`,{class:`icon-button`,"aria-label":`Run ${e.name}`,title:`Run now`,disabled:a.value===e.id,onClick:t=>m(e)},[z(k(Xc),{size:14})],8,PE),R(`button`,{class:`icon-button`,"aria-label":`Remove ${e.name}`,title:`Remove graph`,onClick:t=>h(e)},[z(k(hl),{size:14})],8,FE)]),R(`ul`,IE,[(F(!0),I(P,null,N(e.tasks,t=>(F(),I(`li`,{key:t.id,class:E(d[f(e,t.id)])},[l[6]||=R(`span`,{class:`dot`,"aria-hidden":`true`},null,-1),R(`span`,{class:`name`,title:t.prompt},D(t.name),9,LE),t.dependsOn.length?(F(),I(`code`,RE,`← `+D(t.dependsOn.join(`, `)),1)):V(``,!0),R(`span`,zE,D(f(e,t.id)),1),n.value[e.id]?.tasks[t.id]?.error?(F(),I(`em`,BE,D(n.value[e.id].tasks[t.id].error.slice(0,120)),1)):V(``,!0)],2))),128))])]))),128))]))}}),[[`__scopeId`,`data-v-4acbb881`]]),HE={class:`notify-panel`,"aria-label":`Notification sinks`},UE={class:`panel-heading`},WE=[`disabled`],GE=[`disabled`],KE=[`disabled`],qE={key:0,class:`hint`},JE={key:1,class:`message-error`},YE=[`placeholder`],XE={class:`row`},ZE=[`disabled`],QE={key:3,class:`hint`},$E={key:4,class:`sink-list`},eD={class:`head`},tD={class:`tag`},nD={class:`next`},rD={class:`url`},iD={key:0,class:`hint`},aD={key:1,class:`message-error`},oD={class:`row`},sD=[`disabled`,`onClick`],cD=[`disabled`,`onClick`],lD={key:5,class:`results`,"aria-label":`Test results`},uD={class:`tag`},dD={key:0},fD=sf(M({__name:`NotifyPanel`,setup(e){let t=O([]),n=O(``),r=O(``),i=O(!1),a=O([]),o=H(()=>K.value?.deviceId),s=()=>W(o.value??``),c=O(!1),l=O({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=Iw(e)?Lw(o.value,`notifications`):G(e).slice(0,220)}finally{i.value=!1}}j(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(),J(`Sink added on the device.`)}catch(e){J(G(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){J(G(e).slice(0,140))}finally{n.value=``}}function m(e){q.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;J(a.value.length?`Test: ${a.value.length-e} sent${e?`, ${e} failed`:``}.`:`No enabled sinks matched — nothing was sent.`)}catch(e){J(G(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(F(),I(`section`,HE,[R(`header`,UE,[R(`span`,null,[z(k(Zs),{size:16}),s[6]||=B(`NOTIFY`,-1)]),R(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[z(k(el),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,WE),R(`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},[z(k(il),{size:15})],8,GE),R(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[z(k(Zc),{size:15})],8,KE)]),s[14]||=R(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(F(),I(`p`,JE,D(r.value),1)):V(``,!0):(F(),I(`p`,qE,`Select a session to see its device.`)),c.value?(F(),I(`form`,{key:2,class:`add-form`,onSubmit:As(f,[`prevent`])},[R(`label`,null,[s[8]||=B(`Kind `,-1),A(R(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[R(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),R(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Cs,l.value.kind]])]),R(`label`,null,[s[9]||=B(`URL `,-1),A(R(`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,YE),[[bs,l.value.url]])]),R(`label`,null,[s[10]||=B(`Label`,-1),A(R(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[bs,l.value.label]])]),R(`label`,null,[s[11]||=B(`Events `,-1),A(R(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[bs,l.value.events]])]),R(`div`,XE,[R(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`adding…`:`Add sink`),9,ZE),R(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=R(`p`,{class:`hint`},[B(`LAN targets (192.168.x, localhost) need `),R(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),B(` on the device.`)],-1)],32)):V(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(F(),I(`p`,QE,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):V(``,!0),t.value.length?(F(),I(`ul`,$E,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:e.id,class:E([`sink`,{off:!e.enabled}])},[R(`div`,eD,[R(`span`,tD,D(e.kind),1),R(`b`,null,D(e.label||e.url),1),R(`em`,nD,D(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),R(`code`,rD,D(e.url),1),e.events?.length?(F(),I(`p`,iD,`events: `+D(e.events.join(`, `)),1)):V(``,!0),e.lastError?(F(),I(`p`,aD,D(e.lastError.slice(0,160)),1)):V(``,!0),R(`div`,oD,[R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[z(k(Qc),{size:12}),B(D(e.enabled?`disable`:`enable`),1)],8,sD),R(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[z(k(hl),{size:12}),s[13]||=B(`remove`,-1)],8,cD)])],2))),128))])):V(``,!0),a.value.length?(F(),I(`ul`,lD,[(F(!0),I(P,null,N(a.value,e=>(F(),I(`li`,{key:e.id,class:E(e.status)},[R(`span`,uD,D(e.status),1),B(` `+D(e.kind)+` `+D(e.id.slice(0,8))+` `,1),e.detail?(F(),I(`em`,dD,D(e.detail),1)):V(``,!0)],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-6fa0ab18`]]),pD={class:`env-panel`,"aria-label":`Device environment`},mD={class:`panel-heading`},hD=[`disabled`],gD=[`disabled`],_D={key:0,class:`hint`},vD={key:1,class:`message-error`},yD={key:2,class:`message-restart`},bD={class:`row`},xD=[`disabled`],SD={key:4,class:`hint`},CD={key:5,class:`var-list`},wD={class:`head`},TD={class:`key`},ED={class:`tag`},DD={key:0,class:`tag`,title:`Has its own setting; edit that instead`},OD=[`aria-label`,`title`,`onClick`],kD=[`aria-label`,`onClick`],AD=[`title`],jD={key:6,class:`hint path`},MD={class:`panel-heading keys-heading`},ND=[`disabled`],PD=[`disabled`],FD={key:7,class:`message-error`},ID={class:`row`},LD=[`disabled`],RD={key:9,class:`hint`},zD={key:10,class:`var-list`},BD={class:`head`},VD={class:`key`},HD={class:`tag`},UD={key:0,class:`tag`,title:`Set by pi /login — read-only here`},WD=[`aria-label`,`onClick`],GD={class:`value`,title:`write-only — masked tail`},KD=sf(M({__name:`EnvPanel`,setup(e){let t=O(null),n=O(!1),r=O(``),i=O(``),a=H(()=>K.value?.deviceId),o=()=>W(a.value??``),s=O(!1),c=O({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=Iw(e)?Lw(a.value,`editing env vars`):G(e).slice(0,220)}finally{n.value=!1}m()}j(a,l,{immediate:!0});let u=O(null),d=O(``),f=O(!1),p=O({providerId:``,key:``});async function m(){if(!a.value)return void(u.value=null);try{u.value=await o().piAuth(),d.value=``}catch(e){G(e),d.value=Iw(e)?Lw(a.value,`managing pi keys`):G(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(),J(`${e} saved (now ${t.masked}) — restart the device to apply it.`)}catch(e){J(G(e).slice(0,160))}finally{i.value=``}}}function g(e){q.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(),J(`${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(),J(`${e} saved — restart the device to apply it.`)}catch(e){J(G(e).slice(0,160))}finally{i.value=``}}}function y(e){q.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(),J(`${e.key} saved — restart the device to apply it.`)}}}function b(e){q.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(),J(`${e.key} removed — restart the device to apply it.`)}}}return(e,o)=>(F(),I(`section`,pD,[R(`header`,mD,[R(`span`,null,[z(k(_c),{size:16}),o[8]||=B(`ENV`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[z(k(el),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,hD),R(`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},[z(k(Zc),{size:15})],8,gD)]),o[19]||=R(`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?(F(),I(`p`,vD,D(r.value),1)):t.value?.restartRequired?(F(),I(`p`,yD,[...o[9]||=[B(` Changed since boot — restart the device (`,-1),R(`code`,null,`dpi device stop && dpi device start`,-1),B(`) to apply. `,-1)]])):V(``,!0):(F(),I(`p`,_D,`Select a session to see its device.`)),s.value?(F(),I(`form`,{key:3,class:`add-form`,onSubmit:As(v,[`prevent`])},[R(`label`,null,[o[10]||=B(`Key (UPPER_SNAKE_CASE)`,-1),A(R(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[bs,c.value.key]])]),R(`label`,null,[o[11]||=B(`Value`,-1),A(R(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[bs,c.value.value]])]),R(`div`,bD,[R(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},D(i.value===`new`?`saving…`:`Save to env file`),9,xD),R(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[12]||=R(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):V(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(F(),I(`p`,SD,` No vars in the env file yet. `)):V(``,!0),t.value?.vars.length?(F(),I(`ul`,CD,[(F(!0),I(P,null,N(t.value.vars,e=>(F(),I(`li`,{key:e.key,class:E([`var`,{ro:!_(e)}])},[R(`div`,wD,[R(`code`,TD,D(e.key),1),R(`span`,ED,D(e.source===`process`?`process`:`file`),1),e.managed?(F(),I(`span`,DD,`managed`)):V(``,!0),o[13]||=R(`span`,{class:`spacer`},null,-1),_(e)?(F(),I(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>y(e)},[z(k(Jc),{size:13})],8,OD)):V(``,!0),_(e)?(F(),I(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>b(e)},[z(k(hl),{size:13})],8,kD)):V(``,!0)]),R(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},D(e.masked),9,AD)],2))),128))])):V(``,!0),t.value?(F(),I(`p`,jD,D(t.value.envFile),1)):V(``,!0),R(`header`,MD,[R(`span`,null,[z(k(Ac),{size:16}),o[14]||=B(`PI KEYS`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh pi keys`,title:`Refresh`,onClick:m},[z(k(el),{size:15})],8,ND),R(`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},[z(k(Zc),{size:15})],8,PD)]),o[20]||=R(`p`,{class:`hint`},[B(` Provider keys in pi's own `),R(`code`,null,`auth.json`),B(` — write-only: values are never shown, pi's interactive logins (oauth) are never touched. `)],-1),d.value?(F(),I(`p`,FD,D(d.value),1)):V(``,!0),f.value?(F(),I(`form`,{key:8,class:`add-form`,onSubmit:As(h,[`prevent`])},[R(`label`,null,[o[15]||=B(`Provider id`,-1),A(R(`input`,{"onUpdate:modelValue":o[5]||=e=>p.value.providerId=e,placeholder:`zai`,required:``},null,512),[[bs,p.value.providerId]])]),R(`label`,null,[o[16]||=B(`Key`,-1),A(R(`input`,{"onUpdate:modelValue":o[6]||=e=>p.value.key=e,type:`password`,autocomplete:`off`,placeholder:`paste the api key`,required:``},null,512),[[bs,p.value.key]])]),R(`div`,ID,[R(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`pi-key`},D(i.value===`pi-key`?`saving…`:`Save to auth.json`),9,LD),R(`button`,{class:`small`,type:`button`,onClick:o[7]||=e=>f.value=!1},`Cancel`)]),o[17]||=R(`p`,{class:`hint`},`Applies after the next device restart. Existing keys for other providers stay as they are.`,-1)],32)):V(``,!0),!f.value&&u.value&&!u.value.entries.length&&!d.value?(F(),I(`p`,RD,` No provider keys found. `)):V(``,!0),u.value?.entries.length?(F(),I(`ul`,zD,[(F(!0),I(P,null,N(u.value.entries,e=>(F(),I(`li`,{key:e.providerId,class:`var`},[R(`div`,BD,[R(`code`,VD,D(e.providerId),1),R(`span`,HD,D(e.source),1),e.type===`api_key`?V(``,!0):(F(),I(`span`,UD,D(e.type),1)),o[18]||=R(`span`,{class:`spacer`},null,-1),e.type===`api_key`?(F(),I(`button`,{key:1,class:`icon-button`,"aria-label":`Remove ${e.providerId} key`,title:`Remove from auth.json`,onClick:t=>g(e.providerId)},[z(k(hl),{size:13})],8,WD)):V(``,!0)]),R(`code`,GD,D(e.masked),1)]))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-d92de86a`]]),qD={class:`extensions-panel`},JD={class:`panel-heading`},YD={key:0,class:`task-empty`},XD=[`data-extension`],ZD={class:`ext-head`},QD=[`aria-checked`,`aria-label`,`disabled`,`onClick`],$D=[`checked`,`disabled`,`onChange`],eO=M({__name:`ExtensionsPanel`,setup(e){let t=an(),n=O(!1);async function r(){let e=rd.value;if(!e||!Zu.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}j([rd,Zu,()=>JSON.stringify(pd.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=rd.value;if(r&&!n.value){n.value=!0;try{let n=await kd(()=>r.setExtension(e));n&&(t.value=n),wd()}finally{n.value=!1}}}return(e,r)=>(F(),I(`div`,qD,[R(`div`,JD,[r[0]||=R(`h2`,null,`Extensions`,-1),z(k($c),{size:18})]),r[3]||=R(`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?V(``,!0):(F(),I(`p`,YD,`Loading extensions…`)),(F(!0),I(P,null,N(t.value?.extensions??[],e=>(F(),I(`article`,{key:e.name,class:E([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[R(`div`,ZD,[R(`div`,null,[R(`strong`,null,D(e.title),1),R(`code`,null,D(e.name),1)]),R(`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]||=[R(`span`,null,null,-1)]],10,QD)]),R(`p`,null,D(e.description),1),e.prompts?(F(),I(`ul`,{key:0,class:E([`ext-prompts`,{off:!e.enabled}])},[(F(!0),I(P,null,N(e.prompts,e=>(F(),I(`li`,{key:e.id},[R(`label`,null,[R(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,$D),R(`code`,null,D(e.id),1)]),R(`span`,null,D(e.description),1),R(`details`,null,[r[2]||=R(`summary`,null,`View prompt`,-1),R(`pre`,null,D(e.text),1)])]))),128))],2)):V(``,!0)],10,XD))),128))]))}}),tO={class:`context-section`,"aria-labelledby":`context-title`},nO={class:`section-label`},rO={key:0,class:`hint`},iO={key:1,class:`hint`},aO={class:`context-numbers`},oO={class:`context-pct`},sO={key:0,class:`context-compacting`},cO=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],lO={class:`context-marker-label`},uO=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],dO={class:`context-marker-label`},fO={class:`hint context-hint`},pO={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},mO={class:`context-toggle`},hO=[`checked`],gO=512,_O=4096,vO=1024,yO=M({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=H(()=>xd.value?.contextWindow??0),r=H(()=>{let e=bd.value;return e&&!xd.value?`${e.provider?`${e.provider} / `:``}${e.modelId}`:``}),i=H(()=>{let e=pd.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=H(()=>pd.value.compactions.length>0),o=O(),s=H(()=>o.value??td.value?.compaction??Vv(n.value));j(()=>JSON.stringify(td.value?.compaction),e=>{o.value&&e===JSON.stringify(o.value)&&(o.value=void 0)});let c=O(),l=H(()=>q.dialog?.kind===`compaction`),u=()=>void(q.dialog=void 0);Kr(()=>l.value&&u());let d=H(()=>c.value??Hv(n.value,s.value)),f=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,p=H(()=>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-vO,Math.max((t??_O)+vO,e)),g=(e,t)=>Math.min(t-vO,Math.max(_O,e));function _(e,t){let n=d.value,r=Math.round(t/gO)*gO;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=id.value;if(!t)return;let n=await kd(()=>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=O(),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??_O:r.wait)+n)}return(e,o)=>(F(),I(P,null,[R(`section`,tO,[R(`div`,nO,[o[7]||=R(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(F(),I(`button`,{key:0,class:`context-details-toggle`,onClick:o[0]||=e=>k(q).dialog={kind:`compaction`}},[z(k(kc),{size:16}),o[6]||=B(`Details `,-1)])):V(``,!0)]),r.value?(F(),I(`div`,rO,D(r.value)+` — not in this device's catalog, so its context window is unknown here. `,1)):n.value?(F(),I(P,{key:2},[R(`div`,aO,[R(`strong`,null,D(t(i.value)),1),R(`span`,null,`of `+D(t(n.value))+` tokens`,1),R(`span`,oO,D(p.value)+`%`,1),a.value?(F(),I(`span`,sO,[...o[8]||=[R(`i`,null,null,-1),B(`Compacting`,-1)]])):V(``,!0)]),R(`div`,{ref_key:`bar`,ref:b,class:E([`context-bar`,{off:!s.value.enabled}]),onPointermove:C,onPointerup:ee,onPointercancel:ee},[R(`div`,{class:E([`context-fill`,{hot:d.value.auto!==void 0&&i.value>=d.value.auto}]),style:ge({width:f(i.value)})},null,6),R(`div`,{class:`context-reserve`,style:ge({left:f(d.value.wait)}),title:`Reserved for the answer`},null,4),d.value.auto===void 0?V(``,!0):(F(),I(`button`,{key:0,class:E([`context-marker auto`,`label-${m(d.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":_O,"aria-valuemax":d.value.wait-vO,"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},[R(`span`,lO,`Auto-compact at `+D(t(d.value.auto)),1)],46,cO)),R(`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??_O)+vO,"aria-valuemax":n.value-vO,"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},[R(`span`,dO,`Reserve at `+D(t(d.value.wait)),1)],46,uO)],34),R(`p`,fO,[s.value.enabled?(F(),I(P,{key:0},[o[9]||=B(`Compacts in the background at `,-1),R(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[10]||=B(` and waits at `,-1),R(`strong`,null,D(t(d.value.wait)),1),o[11]||=B(`.`,-1)],64)):(F(),I(P,{key:1},[B(`Automatic compaction is off.`)],64))])],64)):(F(),I(`div`,iO,`Pick a model to see its context window.`))]),(F(),L(ur,{to:`body`},[l.value?(F(),I(`div`,{key:0,class:`modal-backdrop`,onClick:As(u,[`self`])},[R(`section`,pO,[R(`header`,null,[o[12]||=R(`h2`,{id:`compaction-title`},`Context compaction`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:u},[z(k(Sl),{size:18})])]),R(`p`,null,[o[13]||=B(` A summary starts in the background at `,-1),R(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[14]||=B(`. Above `,-1),R(`strong`,null,D(t(d.value.wait)),1),B(` 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]||=R(`p`,null,[B(`Older entries stay stored, and `),R(`code`,null,`search_history`),B(` still finds them.`)],-1),R(`label`,mO,[R(`input`,{type:`checkbox`,checked:s.value.enabled,onChange:o[5]||=e=>v({enabled:e.target.checked})},null,40,hO),o[15]||=B(` Automatic compaction `,-1)]),o[17]||=R(`p`,{class:`hint`},[B(` Applies to every agent in this session. `),R(`code`,null,`/compact`),B(` works either way. `)],-1),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:u},`Close`)])])])):V(``,!0)]))],64))}}),bO=/^[A-Za-z_$][\w$]*$/,xO=e=>` `.repeat(e);function SO(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`),CO(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function CO(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 TO(e.enum.map(e=>({const:e})),t,n);if(e.anyOf??e.oneOf)return TO(e.anyOf??e.oneOf,t,n);if(Array.isArray(e.type))return TO(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`),CO(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return wO(e,t,n);default:return n(`unknown`,`type`)}}function wO(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`),CO(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
81
- `);for(let[e,a]of r){let r=DO(a);r&&n(`${xO(t+1)}${r}\n`,`comment`),n(xO(t+1)),n(bO.test(e)?e:JSON.stringify(e),`property`),n(i.has(e)?`: `:`?: `,`punct`),CO(a,t+1,n),n(`;`,`punct`),n(`
82
- `)}n(xO(t)),n(`}`,`punct`)}function TO(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),CO(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 DO(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 OO(e){let t=document.createElement(`a`),n=(e.filename||`device-response`).replace(/[^A-Za-z0-9._-]/g,`_`).slice(0,80)||`device-response`;/\.zip$/i.test(e.filename)&&!/\.zip$/i.test(n)&&(n=`${n.slice(0,76)}.zip`),t.href=URL.createObjectURL(new Blob([e.bytes.slice()],{type:`application/zip`})),t.download=n,t.click(),URL.revokeObjectURL(t.href)}function kO(e,t={}){let n=t.fetchBundle??((e,t)=>W(e).exportSession(t)),r=t.download??OO,i=t.notify??(()=>{}),a=O(!1),o=O(``);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: ${G(e).slice(0,300)}`,i(o.value.slice(0,120))}finally{a.value=!1}}}return j(()=>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 $y({},{operation:`update`,path:``,value:t}),``}catch(e){return G(e)}}function jO(e,t){let n=O(``),r=O(``),i=O(0),a=O(),o=O(!1),s=O(``),c=H(()=>n.value!==r.value),l=H(()=>c.value&&a.value!==t.value),u=H(()=>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=``}j(e,()=>!c.value&&d(),{immediate:!0}),j(t,()=>d());let p;return j(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 MO={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},NO=[`title`],PO=[`aria-label`,`title`,`onClick`],FO={key:0,class:`count`},IO={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},LO=[`id`,`aria-selected`,`title`,`onClick`],RO={class:`tab-label`},zO={key:0,class:`count`},BO=[`title`],VO=[`aria-labelledby`],HO={class:`session-heading`},UO=[`disabled`],WO=[`disabled`],GO=[`title`],KO={class:`cwd-trail`,dir:`rtl`},qO={dir:`ltr`},JO={class:`session-status`},YO={key:0,class:`background-pill`},XO=[`title`],ZO={key:0,class:`message-error`,role:`alert`},QO=[`disabled`],$O={class:`model-section`},ek=[`src`],tk={key:0,class:`hint model-provenance`},nk={class:`thinking-row`},rk=[`value`],ik={class:`stats-section`,"aria-labelledby":`stats-title`},ak={class:`metrics`},ok=[`title`],sk={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},ck={scope:`row`},lk={class:`usage-total`},uk={class:`panel-heading`},dk={class:`hint app-state-description`},fk=[`disabled`],pk={class:`state-json-actions`},mk={key:0,class:`hint`},hk=[`disabled`],gk=[`disabled`],_k={key:0,class:`message-error`,role:`alert`},vk={key:1,class:`message-error`,role:`alert`},yk={class:`panel-heading`},bk={class:`tag`},xk={class:`hook-card`},Sk=[`aria-checked`],Ck={key:0,class:`tag tool-disabled`},wk={class:`tag`},Tk=[`aria-label`],Ek=sf(M({__name:`Inspector`,setup(e){let t=H(()=>new Map(Sd.value?.tools.map(e=>[e.name,SO(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:bc},{id:`git`,label:`Git`,icon:Sc},{id:`host`,label:`Host`,icon:Hs},{id:`usage`,label:`Usage`,icon:Yc},{id:`auto`,label:`Auto`,icon:tc},{id:`archive`,label:`Archive`,icon:Ws},{id:`dag`,label:`DAG`,icon:_l},{id:`notify`,label:`Notify`,icon:Zs},{id:`env`,label:`Env`,icon:_c},{id:`state`,label:`State`,icon:$s},{id:`tasks`,label:`Tasks`,icon:Hs},{id:`tools`,label:`Tools`,icon:xl},{id:`extensions`,label:`Extend`,icon:$c}],r=H(()=>[{label:`Input`,tokens:vd.value.input,cost:vd.value.inputCost},{label:`Output`,tokens:vd.value.output,cost:vd.value.outputCost},{label:`Cache read`,tokens:vd.value.cacheRead,cost:vd.value.cacheReadCost},{label:`Cache write`,tokens:vd.value.cacheWrite,cost:vd.value.cacheWriteCost}]),i=H(()=>gd.value.filter(e=>e.background).length);function a(e,t){kd(async()=>{await rd.value.configure(e),await wd(),t&&J(t)})}async function o(){let e=Xu.value,t=td.value;if(e&&t)try{let n=await W(e.id).agent(t.id,K.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),J(`Transcript downloaded.`)}catch(e){J(`transcript download failed: ${G(e).slice(0,120)}`)}}let{exporting:s,error:c,run:l}=kO(H(()=>({device:Xu.value,summary:td.value}))),u=O(!1);function d(){let e=Xu.value,t=td.value;e&&t&&!u.value&&(q.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=W(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 Au.createShare({title:`${t.name} · ${e.name}`,agents:i}),o=`${location.origin}${a.url}`;await navigator.clipboard?.writeText(o).catch(()=>{}),J(`Share link copied — expires ${a.expiresAt.slice(0,10)}.`)}catch(e){J(`share failed: ${G(e).slice(0,140)}`)}finally{u.value=!1}}})}function f(){let e=id.value;e&&(q.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:td.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let p=O({});j(Xu,async e=>{if(p.value={},e)try{let{projects:t}=await W(e.id).projects(!0);p.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0});let m=H(()=>{let e=bd.value;if(!e)return!1;let t=td.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}`:Xu.value?.info?.defaultModel??``;return!!i&&i===`${e.provider}/${e.modelId}`}),h=H(()=>bd.value&&`model: ${bd.value.modelId} (${bd.value.provider})${m.value?` (default)`:``}`),g=ed.sharedState,{draft:_,dirty:v,conflict:y,deviceChanged:b,problem:x,revision:S,reset:C,commit:ee}=jO(g,Yu),w=O(!1),te=O(``);async function ne(e){if(!w.value&&rd.value){w.value=!0,te.value=``;try{await rd.value.demo(`state`,e)}catch(e){te.value=G(e)}finally{w.value=!1}}}async function re(){if(!(w.value||y.value||!rd.value)){te.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 rd.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:S.value});ee(t.value,t.revision),J(`Shared App State saved.`)}catch(e){te.value=G(e)}finally{w.value=!1}}}let ie=H(()=>Sd.value?.config.readOnly===!0),ae=H(()=>Sd.value?.tools.filter(e=>e.offered).length??0);return(e,p)=>(F(),I(`aside`,{class:E([`inspector`,{collapsed:!k(zd),overlay:k(q).inspectorOverlay}])},[k(zd)?(F(),I(P,{key:1},[R(`div`,IO,[(F(),I(P,null,N(n,e=>R(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":k(q).tab===e.id,title:e.label,class:E({active:k(q).tab===e.id}),onClick:t=>k(q).tab=e.id},[(F(),L(ei(e.icon),{size:18})),R(`span`,RO,D(e.label),1),e.id===`tasks`&&k(gd).length?(F(),I(`span`,zO,D(k(gd).length),1)):V(``,!0)],10,LO)),64)),R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${k(Gd).inspector})`,onClick:p[1]||=e=>k(Vd)()},[z(k(Wc),{size:18})],8,BO)]),R(`div`,{id:`inspector-panel`,class:E([`inspector-body`,{"session-panel":k(q).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${k(q).tab}`},[k(q).tab===`session`?(F(),I(P,{key:0},[R(`section`,HO,[R(`h1`,null,[R(`span`,null,D(k(td)?.name??`Loading session`),1),R(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:f},[z(k(Jc),{size:18})]),R(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:o},[z(k(mc),{size:18})]),R(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:k(s),onClick:p[2]||=(...e)=>k(l)&&k(l)(...e)},[z(k(Uc),{size:18})],8,UO),R(`button`,{class:`icon-button`,title:`Share a public read-only link to this transcript`,"aria-label":`Share transcript`,disabled:u.value,onClick:d},[z(k(ol),{size:18})],8,WO)]),R(`button`,{class:`path cwd-button`,title:k(td)?.cwd,"aria-label":`Show full working directory`,onClick:p[3]||=e=>k(q).dialog={kind:`path`,path:k(td)?.cwd??``}},[z(k(bc),{size:18}),R(`span`,KO,[R(`bdi`,qO,D(k(td)?.cwd),1)])],8,GO),R(`div`,JO,[R(`span`,{class:E([`status-pill`,{working:k(_d)}])},[p[10]||=R(`i`,null,null,-1),B(D(k(_d)?`Working`:`Idle`),1)],2),i.value?(F(),I(`span`,YO,D(i.value)+` background`,1)):V(``,!0),R(`span`,{class:`saved`,title:k(Xu)?.id},[z(k(al),{size:18}),B(D(k(Xu)?.name??k(Xu)?.id),1)],8,XO),k(Xu)?(F(),L(wb,{key:1,device:k(Xu)},null,8,[`device`])):V(``,!0)]),k(c)?(F(),I(`p`,ZO,[B(D(k(c))+` `,1),R(`button`,{class:`small`,disabled:k(s),onClick:p[4]||=(...e)=>k(l)&&k(l)(...e)},` retry `,8,QO)])):V(``,!0)]),k(Xu)?(F(),L(Vb,{key:0,device:k(Xu)},null,8,[`device`])):V(``,!0),R(`section`,$O,[p[18]||=R(`div`,{class:`section-label`},[R(`span`,null,`AGENT`)],-1),R(`button`,{class:`model-button`,onClick:p[5]||=e=>k(q).dialog={kind:`models`}},[R(`img`,{src:k(Nd)(k(pd).agent.model?.modelId),alt:``},null,8,ek),R(`div`,null,[R(`strong`,null,D(k(yd)?.name??k(pd).agent.model?.modelId??`Loading…`),1),R(`small`,null,D(k(yd)?.tier??``)+` / `+D(k(pd).agent.model?.provider??``),1)]),z(k(rc),{size:18})]),h.value?(F(),I(`p`,tk,D(h.value),1)):V(``,!0),R(`div`,nk,[p[11]||=R(`span`,null,`Thinking`,-1),R(`select`,{"aria-label":`Thinking level`,value:k(pd).agent.thinkingLevel??`medium`,onChange:p[6]||=e=>a({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(F(!0),I(P,null,N(k(Rv),e=>(F(),I(`option`,{key:e},D(e),1))),128))],40,rk)]),z(yO),R(`section`,ik,[p[17]||=R(`div`,{class:`section-label`},[R(`span`,{id:`stats-title`},`STATS`)],-1),R(`div`,ak,[R(`div`,{title:`${k(vd).tokens.toLocaleString(`en-US`)} total tokens`},[R(`span`,null,D(k(jd)(k(vd).tokens)),1),p[12]||=R(`small`,null,`total tokens`,-1)],8,ok),R(`div`,null,[R(`span`,null,`$`+D(k(vd).cost.toFixed(4)),1),p[13]||=R(`small`,null,`agent cost`,-1)]),R(`div`,null,[R(`span`,null,D(k(Sd)?.tools.length??0),1),p[14]||=R(`small`,null,`tools`,-1)])]),R(`table`,sk,[p[16]||=R(`thead`,null,[R(`tr`,null,[R(`th`,{scope:`col`},`Type`),R(`th`,{scope:`col`},`Tokens`),R(`th`,{scope:`col`},`Cost (USD)`)])],-1),R(`tbody`,null,[(F(!0),I(P,null,N(r.value,e=>(F(),I(`tr`,{key:e.label},[R(`th`,ck,D(e.label),1),R(`td`,null,D(e.tokens.toLocaleString(`en-US`)),1),R(`td`,null,`$`+D(e.cost.toFixed(4)),1)]))),128)),R(`tr`,lk,[p[15]||=R(`th`,{scope:`row`},`Total`,-1),R(`td`,null,D(k(vd).tokens.toLocaleString(`en-US`)),1),R(`td`,null,`$`+D(k(vd).cost.toFixed(4)),1)])])])])])],64)):V(``,!0),k(q).tab===`state`?(F(),I(P,{key:1},[R(`div`,uk,[p[19]||=R(`h2`,null,`App State`,-1),z(k($s),{size:18})]),R(`p`,dk,` One shared JSON object for every agent, session and fork on `+D(k(Xu)?.name??k(Xu)?.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),A(R(`textarea`,{"onUpdate:modelValue":p[7]||=e=>rn(_)?_.value=e:null,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:w.value||!k(g),rows:`12`},null,8,fk),[[bs,k(_)]]),p[20]||=R(`p`,{class:`hint state-limits`},` One JSON object, at most 24 levels of nesting and 100,000 characters, checked as you type. `,-1),R(`div`,pk,[k(y)?(F(),I(`span`,mk,D(k(b)?`Device changed since this draft loaded. Load the latest JSON before saving.`:`State changed elsewhere. Load the latest JSON before saving.`),1)):V(``,!0),k(v)?(F(),I(`button`,{key:1,class:`secondary`,disabled:w.value,onClick:p[8]||=(...e)=>k(C)&&k(C)(...e)},D(k(y)?`Load latest`:`Reset`),9,hk)):V(``,!0),R(`button`,{class:`primary small`,disabled:!k(v)||w.value||k(y)||!!k(x),onClick:re},D(w.value?`Saving…`:`Save JSON`),9,gk)]),k(x)?(F(),I(`p`,_k,D(k(x)),1)):V(``,!0),te.value?(F(),I(`p`,vk,D(te.value),1)):V(``,!0),z(vb,{value:k(g)?.value??{},disabled:w.value||k(v)||!k(g),onChange:ne},null,8,[`value`,`disabled`])],64)):V(``,!0),k(q).tab===`tasks`?(F(),L(vx,{key:2})):V(``,!0),k(q).tab===`git`?(F(),L(fw,{key:3})):V(``,!0),k(q).tab===`host`?(F(),L(Fw,{key:4})):V(``,!0),k(q).tab===`usage`?(F(),L(ET,{key:5})):V(``,!0),k(q).tab===`auto`?(F(),L(rE,{key:6})):V(``,!0),k(q).tab===`archive`?(F(),L(SE,{key:7})):V(``,!0),k(q).tab===`dag`?(F(),L(VE,{key:8})):V(``,!0),k(q).tab===`notify`?(F(),L(fD,{key:9})):V(``,!0),k(q).tab===`env`?(F(),L(KD,{key:10})):V(``,!0),k(q).tab===`extensions`?(F(),L(eO,{key:11})):V(``,!0),k(q).tab===`tools`?(F(),I(P,{key:12},[R(`div`,yk,[p[21]||=R(`h2`,null,`Tools`,-1),R(`span`,bk,D(ae.value)+` / `+D(k(Sd)?.tools.length??0),1)]),p[25]||=R(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),R(`div`,xk,[R(`div`,null,[z(k(cl),{size:18}),p[23]||=R(`strong`,null,`Read only`,-1),R(`button`,{class:E([`switch`,{on:ie.value}]),role:`switch`,"aria-checked":ie.value,"aria-label":`Read only`,onClick:p[9]||=e=>a({readOnly:!ie.value},ie.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...p[22]||=[R(`span`,null,null,-1)]],10,Sk)]),p[24]||=R(`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)]),(F(!0),I(P,null,N(k(Sd)?.tools,e=>(F(),I(`details`,{key:e.name,class:E([`tool-row`,{disabled:!e.offered}])},[R(`summary`,null,[z(k(xl),{size:18}),R(`strong`,null,D(e.name),1),e.offered?V(``,!0):(F(),I(`span`,Ck,`disabled`)),R(`span`,wk,D(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),R(`p`,null,D(e.description),1),e.parameters?(F(),I(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[R(`code`,null,[(F(!0),I(P,null,N(t.value.get(e.name),(e,t)=>(F(),I(`span`,{key:t,class:E(`tk-${e.kind}`)},D(e.text),3))),128))])],8,Tk)):V(``,!0),R(`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)):V(``,!0)],10,VO)],64)):(F(),I(`div`,MO,[R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${k(Gd).inspector})`,onClick:p[0]||=e=>k(Bd)()},[z(k(Gc),{size:18})],8,NO),(F(),I(P,null,N(n,e=>R(`button`,{key:e.id,class:E([`rail-tab`,{active:k(q).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>k(Bd)(e.id)},[(F(),L(ei(e.icon),{size:20})),e.id===`tasks`&&k(gd).length?(F(),I(`span`,FO,D(k(gd).length),1)):V(``,!0)],10,PO)),64))]))],2))}}),[[`__scopeId`,`data-v-419eb6ed`]]),Dk={class:`chat-empty`},Ok={class:`eyebrow`},kk={key:3,class:`hint offline-error`},Ak={key:4,class:`offline-command`},jk={key:5,class:`hint`},Mk={key:6,class:`hint`},Nk={class:`offline-actions`},Pk=[`disabled`],Fk={key:7,class:`message-error`,role:`alert`},Ik=M({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=O(!1),r=O(``),i=H(()=>{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 ${Pd(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 Au.check(t.device.id);e.status===`online`&&J(`${e.id} is online.`)}catch(e){r.value=G(e)}finally{n.value=!1}}async function o(e){try{await navigator.clipboard.writeText(e),J(`Copied.`)}catch{J(`Clipboard needs localhost or HTTPS. Select the text to copy.`)}}return(t,s)=>(F(),I(`section`,{class:E([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[R(`div`,Dk,[e.device.status===`checking`?(F(),L(k(Lc),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(F(),L(k(sl),{key:1,size:30})):(F(),L(k(vl),{key:2,size:30})),R(`span`,Ok,D(e.device.kind.toUpperCase())+` · `+D(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),R(`h2`,null,D(i.value.title),1),R(`p`,null,D(i.value.text),1),e.device.error?(F(),I(`p`,kk,D(e.device.error),1)):V(``,!0),i.value.command?(F(),I(`div`,Ak,[R(`code`,null,D(i.value.command),1),R(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[z(k(cc),{size:18})])])):V(``,!0),i.value.command?(F(),I(`p`,jk,`Run it in this repo's terminal, then press Check now.`)):V(``,!0),i.value.alt?(F(),I(`p`,Mk,[s[2]||=B(` Never deployed or rebuilt? `,-1),R(`code`,null,D(i.value.alt),1),s[3]||=B(` provisions it from scratch. `,-1)])):V(``,!0),R(`div`,Nk,[R(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[z(k(el),{size:18}),B(D(n.value?`Checking…`:`Check now`),1)],8,Pk)]),r.value?(F(),I(`p`,Fk,D(r.value),1)):V(``,!0)])],2))}}),Lk={class:`dir-browser`},Rk={class:`dir-path`},zk=[`disabled`],Bk=[`aria-busy`],Vk=[`title`],Hk=[`aria-selected`,`title`,`onClick`],Uk={key:1,class:`hint`},Wk={key:0,class:`message-error`,role:`alert`},Gk=M({__name:`DirBrowser`,props:ci({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Oi(e,`modelValue`),r=O(),i=O(!1),a=O(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await W(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=G(e));return}finally{s===o&&(i.value=!1)}}return j(()=>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)=>(F(),I(`div`,Lk,[R(`div`,Rk,[A(R(`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]||=Ms(As(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[bs,n.value]]),R(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,zk)]),R(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[R(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[z(k(Oc),{size:16}),t[5]||=R(`span`,null,`Start dirs`,-1)]),r.value?.parent?(F(),I(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[z(k(uc),{size:16}),t[6]||=R(`span`,null,`..`,-1)],8,Vk)):V(``,!0),(F(!0),I(P,null,N(r.value?.dirs,e=>(F(),I(`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?(F(),L(k(bc),{key:0,size:16})):(F(),L(k(xc),{key:1,size:16})),R(`span`,null,D(e.name),1)],8,Hk))),128)),r.value&&!r.value.dirs.length?(F(),I(`p`,Uk,`No subdirectories.`)):V(``,!0)],8,Bk),a.value?(F(),I(`p`,Wk,D(a.value),1)):V(``,!0)]))}}),Kk={key:0,class:`message-error`},qk=[`value`],Jk={class:`field`},Yk={key:0,class:`recent-cwds`},Xk=[`title`,`onClick`],Zk={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`},Qk=[`value`],$k=[`value`],eA={key:2,class:`message-error`,role:`alert`},tA=[`disabled`],nA=`dpi-recent-cwds`,rA=sf(M({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>Hu.devices.value.filter(e=>e.status===`online`)),a=O(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=H(()=>i.value.find(e=>e.id===a.value)),s=H(()=>{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=H(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=H(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=O({name:``,cwd:``,model:``,thinking:`medium`}),f=H(()=>{try{return JSON.parse(localStorage.getItem(nA)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(nA)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(nA,JSON.stringify({...n,[e]:r}))}catch{}},m=O(!1),h=O(``),g=O({});j(a,async e=>{if(g.value={},e)try{let{projects:t}=await W(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),j([()=>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}),j(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 W(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];ad({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),J(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=G(e)}finally{m.value=!1}}}return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[7]||=As(e=>r(`close`),[`self`])},[R(`form`,{class:`modal session-modal`,onSubmit:As(_,[`prevent`])},[R(`header`,null,[t[8]||=R(`div`,null,[R(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),R(`h2`,null,`New session`)],-1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[z(k(Sl),{size:18})])]),i.value.length?(F(),I(P,{key:1},[R(`label`,null,[t[9]||=B(`Device`,-1),A(R(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(F(!0),I(P,null,N(i.value,e=>(F(),I(`option`,{key:e.id,value:e.id},D(e.name)+D(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,qk))),128))],512),[[Cs,a.value]])]),R(`label`,null,[t[10]||=B(`Session name`,-1),A(R(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[bs,d.value.name]])]),R(`div`,Jk,[R(`span`,null,`Working directory on `+D(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(F(),I(`div`,Yk,[(F(!0),I(P,null,N(f.value,e=>(F(),I(`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,Xk))),128))])):V(``,!0),z(Gk,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),R(`label`,null,[t[11]||=B(`Model`,-1),c.value||l.value?(F(),I(`span`,Zk,`no API key on device — chat needs one`)):V(``,!0),A(R(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(F(!0),I(P,null,N(s.value,e=>(F(),I(`option`,{key:u(e),value:u(e)},D(e.tier)+` / `+D(e.name),9,Qk))),128))],512),[[Cs,d.value.model]])]),R(`label`,null,[t[12]||=B(`Thinking`,-1),A(R(`select`,{"onUpdate:modelValue":t[5]||=e=>d.value.thinking=e,"aria-label":`New session thinking level`},[(F(!0),I(P,null,N(k(Rv),e=>(F(),I(`option`,{key:e,value:e},D(e),9,$k))),128))],512),[[Cs,d.value.thinking]])])],64)):(F(),I(`p`,Kk,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(F(),I(`p`,eA,D(h.value),1)):V(``,!0),R(`footer`,null,[R(`button`,{type:`button`,class:`secondary`,onClick:t[6]||=e=>r(`close`)},`Cancel`),R(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[z(k(Zc),{size:18}),B(D(m.value?`Creating…`:`Create session`),1)],8,tA)])],32)]))}}),[[`__scopeId`,`data-v-95f14dc6`]]),iA=new Uint8Array(512),aA=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)iA[t]=e,aA[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)iA[e]=iA[e-255]})();var oA=(e,t)=>e===0||t===0?0:iA[aA[e]+aA[t]];function sA(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]^=oA(t[r],iA[n]);t=e}return t}function cA(e,t){let n=sA(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]^=oA(n[i+1],e)}return r}var lA=[21,25,29,33,37,41,45,49,53,57,61,65],uA=[19,34,55,80,108,136,156,194,232,274,324,370],dA=[7,10,15,20,26,36,40,48,60,72,80,96],fA=[7,10,15,20,26,18,20,24,30,18,20,24],pA=[[[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]]],mA=[[],[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]],hA=e=>e<=9?8:16;function gA(e){for(let t=1;t<=lA.length;t++)if(4+hA(t)+e*8<=uA[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${uA[11]-3})`)}function _A(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,hA(t));for(let e of n)i(e,8);let a=uA[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 vA(e,t){let n=fA[e-1],r=[],i=0;for(let[n,a]of pA[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=>cA(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function yA(e){return Array.from({length:e},()=>Array(e).fill(!1))}function bA(e,t){let n=lA[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=mA[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 xA(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 SA(e,t){let n=lA[0]*0+e.length,r=xA(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 CA(e,t,n,r){let i=e.length;lA[n-1]*lA[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(TA(l,i,n))continue;if(o>=(uA[n-1]+dA[n-1])*8){o++;continue}let t=a(o++);wA(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function wA(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 TA(e,t,n){let r=lA[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=mA[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 DA(e,t){let n=gA(new TextEncoder().encode(e).length),r=lA[n-1],i=vA(n,_A(e,n)),a=yA(r);return bA(a,n),CA(a,i,n,t),SA(a,t),a}function OA(e,t){if(t!==void 0)return DA(e,t);let n;for(let t=0;t<8;t++){let r=DA(e,t),i=EA(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function kA(e,t=160){let n=OA(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`},jA={class:`row`},MA=[`disabled`],NA=[`disabled`],PA={key:0,class:`target`,"data-testid":`device-url`},FA={key:1,class:`err`},IA=sf(M({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=O(`4780`),r=O(!1),i=H(()=>{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)=>(F(),I(`section`,AA,[R(`header`,null,[z(k(Bc),{size:18}),t[1]||=R(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=R(`p`,{class:`what`},[B(` 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 `),R(`code`,null,`dpi device`),B(` there first. `)],-1),R(`div`,jA,[R(`label`,null,[t[2]||=B(` local port `,-1),A(R(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[bs,n.value]])]),R(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[z(k(hc),{size:15}),t[3]||=B(`Open the device page `,-1)],8,MA),R(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[z(k(cc),{size:15}),B(D(r.value?`Copied`:`Copy link`),1)],8,NA)]),i.value?(F(),I(`p`,PA,D(i.value),1)):V(``,!0),i.value?V(``,!0):(F(),I(`p`,FA,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-01884b7b`]]);function LA(e){return KA(e)&&!RA(e)&&!XA(e)&&Symbol.asyncIterator in e}function RA(e){return Array.isArray(e)}function zA(e){return typeof e==`bigint`}function BA(e){return typeof e==`boolean`}function VA(e){return e instanceof globalThis.Date}function HA(e){return typeof e==`function`}function UA(e){return KA(e)&&!RA(e)&&!XA(e)&&Symbol.iterator in e}function WA(e){return e===null}function GA(e){return typeof e==`number`}function KA(e){return typeof e==`object`&&!!e}function qA(e){return e instanceof globalThis.RegExp}function JA(e){return typeof e==`string`}function YA(e){return typeof e==`symbol`}function XA(e){return e instanceof globalThis.Uint8Array}function ZA(e){return e===void 0}function QA(e){return e.map(e=>rj(e))}function $A(e){return new Date(e.getTime())}function ej(e){return new Uint8Array(e)}function tj(e){return new RegExp(e.source,e.flags)}function nj(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=rj(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=rj(e[n]);return t}function rj(e){return RA(e)?QA(e):VA(e)?$A(e):XA(e)?ej(e):qA(e)?tj(e):KA(e)?nj(e):e}function ij(e){return rj(e)}function aj(e,t){return ij(t===void 0?e:{...t,...e})}function oj(e){return typeof e==`object`&&!!e}function sj(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function cj(e){return e===void 0}function lj(e){return typeof e==`number`}var uj;(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=oj(t);return e.AllowArrayObject?n:n&&!sj(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?lj(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=cj(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(uj||={});function dj(e){return globalThis.Object.freeze(e).map(e=>gj(e))}function fj(e){return e}function pj(e){return e}function mj(e){return e}function hj(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=gj(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=gj(e[n]);return globalThis.Object.freeze(t)}function gj(e){return RA(e)?dj(e):VA(e)?fj(e):XA(e)?pj(e):qA(e)?mj(e):KA(e)?hj(e):e}function Y(e,t){let n=t===void 0?e:{...t,...e};switch(uj.InstanceMode){case`freeze`:return gj(n);case`clone`:return ij(n);default:return n}}var _j=class extends Error{constructor(e){super(e)}},vj=Symbol.for(`TypeBox.Transform`),yj=Symbol.for(`TypeBox.Readonly`),bj=Symbol.for(`TypeBox.Optional`),xj=Symbol.for(`TypeBox.Hint`),X=Symbol.for(`TypeBox.Kind`);function Sj(e){return KA(e)&&e[yj]===`Readonly`}function Cj(e){return KA(e)&&e[bj]===`Optional`}function wj(e){return Z(e,`Any`)}function Tj(e){return Z(e,`Argument`)}function Ej(e){return Z(e,`Array`)}function Dj(e){return Z(e,`AsyncIterator`)}function Oj(e){return Z(e,`BigInt`)}function kj(e){return Z(e,`Boolean`)}function Aj(e){return Z(e,`Computed`)}function jj(e){return Z(e,`Constructor`)}function Mj(e){return Z(e,`Date`)}function Nj(e){return Z(e,`Function`)}function Pj(e){return Z(e,`Integer`)}function Fj(e){return Z(e,`Intersect`)}function Ij(e){return Z(e,`Iterator`)}function Z(e,t){return KA(e)&&X in e&&e[X]===t}function Lj(e){return BA(e)||GA(e)||JA(e)}function Rj(e){return Z(e,`Literal`)}function zj(e){return Z(e,`MappedKey`)}function Bj(e){return Z(e,`MappedResult`)}function Vj(e){return Z(e,`Never`)}function Hj(e){return Z(e,`Not`)}function Uj(e){return Z(e,`Null`)}function Wj(e){return Z(e,`Number`)}function Gj(e){return Z(e,`Object`)}function Kj(e){return Z(e,`Promise`)}function qj(e){return Z(e,`Record`)}function Jj(e){return Z(e,`Ref`)}function Yj(e){return Z(e,`RegExp`)}function Xj(e){return Z(e,`String`)}function Zj(e){return Z(e,`Symbol`)}function Qj(e){return Z(e,`TemplateLiteral`)}function $j(e){return Z(e,`This`)}function eM(e){return KA(e)&&vj in e}function tM(e){return Z(e,`Tuple`)}function nM(e){return Z(e,`Undefined`)}function rM(e){return Z(e,`Union`)}function iM(e){return Z(e,`Uint8Array`)}function aM(e){return Z(e,`Unknown`)}function oM(e){return Z(e,`Unsafe`)}function sM(e){return Z(e,`Void`)}function cM(e){return KA(e)&&X in e&&JA(e[X])}function lM(e){return wj(e)||Tj(e)||Ej(e)||kj(e)||Oj(e)||Dj(e)||Aj(e)||jj(e)||Mj(e)||Nj(e)||Pj(e)||Fj(e)||Ij(e)||Rj(e)||zj(e)||Bj(e)||Vj(e)||Hj(e)||Uj(e)||Wj(e)||Gj(e)||Kj(e)||qj(e)||Jj(e)||Yj(e)||Xj(e)||Zj(e)||Qj(e)||$j(e)||tM(e)||nM(e)||rM(e)||iM(e)||aM(e)||oM(e)||sM(e)||cM(e)}var uM=`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 dM(e){try{return new RegExp(e),!0}catch{return!1}}function fM(e){if(!JA(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 pM(e){return gM(e)||fN(e)}function mM(e){return ZA(e)||zA(e)}function hM(e){return ZA(e)||GA(e)}function gM(e){return ZA(e)||BA(e)}function _M(e){return ZA(e)||JA(e)}function vM(e){return ZA(e)||JA(e)&&fM(e)&&dM(e)}function yM(e){return ZA(e)||JA(e)&&fM(e)}function bM(e){return ZA(e)||fN(e)}function xM(e){return KA(e)&&e[bj]===`Optional`}function SM(e){return IM(e,`Any`)&&_M(e.$id)}function CM(e){return IM(e,`Argument`)&&GA(e.index)}function wM(e){return IM(e,`Array`)&&e.type===`array`&&_M(e.$id)&&fN(e.items)&&hM(e.minItems)&&hM(e.maxItems)&&gM(e.uniqueItems)&&bM(e.contains)&&hM(e.minContains)&&hM(e.maxContains)}function TM(e){return IM(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&_M(e.$id)&&fN(e.items)}function EM(e){return IM(e,`BigInt`)&&e.type===`bigint`&&_M(e.$id)&&mM(e.exclusiveMaximum)&&mM(e.exclusiveMinimum)&&mM(e.maximum)&&mM(e.minimum)&&mM(e.multipleOf)}function DM(e){return IM(e,`Boolean`)&&e.type===`boolean`&&_M(e.$id)}function OM(e){return IM(e,`Computed`)&&JA(e.target)&&RA(e.parameters)&&e.parameters.every(e=>fN(e))}function kM(e){return IM(e,`Constructor`)&&e.type===`Constructor`&&_M(e.$id)&&RA(e.parameters)&&e.parameters.every(e=>fN(e))&&fN(e.returns)}function AM(e){return IM(e,`Date`)&&e.type===`Date`&&_M(e.$id)&&hM(e.exclusiveMaximumTimestamp)&&hM(e.exclusiveMinimumTimestamp)&&hM(e.maximumTimestamp)&&hM(e.minimumTimestamp)&&hM(e.multipleOfTimestamp)}function jM(e){return IM(e,`Function`)&&e.type===`Function`&&_M(e.$id)&&RA(e.parameters)&&e.parameters.every(e=>fN(e))&&fN(e.returns)}function MM(e){return IM(e,`Integer`)&&e.type===`integer`&&_M(e.$id)&&hM(e.exclusiveMaximum)&&hM(e.exclusiveMinimum)&&hM(e.maximum)&&hM(e.minimum)&&hM(e.multipleOf)}function NM(e){return KA(e)&&Object.entries(e).every(([e,t])=>fM(e)&&fN(t))}function PM(e){return IM(e,`Intersect`)&&!(JA(e.type)&&e.type!==`object`)&&RA(e.allOf)&&e.allOf.every(e=>fN(e)&&!rN(e))&&_M(e.type)&&(gM(e.unevaluatedProperties)||bM(e.unevaluatedProperties))&&_M(e.$id)}function FM(e){return IM(e,`Iterator`)&&e.type===`Iterator`&&_M(e.$id)&&fN(e.items)}function IM(e,t){return KA(e)&&X in e&&e[X]===t}function LM(e){return BM(e)&&JA(e.const)}function RM(e){return BM(e)&&GA(e.const)}function zM(e){return BM(e)&&BA(e.const)}function BM(e){return IM(e,`Literal`)&&_M(e.$id)&&VM(e.const)}function VM(e){return BA(e)||GA(e)||JA(e)}function HM(e){return IM(e,`MappedKey`)&&RA(e.keys)&&e.keys.every(e=>GA(e)||JA(e))}function UM(e){return IM(e,`MappedResult`)&&NM(e.properties)}function WM(e){return IM(e,`Never`)&&KA(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function GM(e){return IM(e,`Not`)&&fN(e.not)}function KM(e){return IM(e,`Null`)&&e.type===`null`&&_M(e.$id)}function qM(e){return IM(e,`Number`)&&e.type===`number`&&_M(e.$id)&&hM(e.exclusiveMaximum)&&hM(e.exclusiveMinimum)&&hM(e.maximum)&&hM(e.minimum)&&hM(e.multipleOf)}function JM(e){return IM(e,`Object`)&&e.type===`object`&&_M(e.$id)&&NM(e.properties)&&pM(e.additionalProperties)&&hM(e.minProperties)&&hM(e.maxProperties)}function YM(e){return IM(e,`Promise`)&&e.type===`Promise`&&_M(e.$id)&&fN(e.item)}function XM(e){return IM(e,`Record`)&&e.type===`object`&&_M(e.$id)&&pM(e.additionalProperties)&&KA(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&dM(t[0])&&KA(e.patternProperties)&&fN(e.patternProperties[t[0]])})(e)}function ZM(e){return IM(e,`Ref`)&&_M(e.$id)&&JA(e.$ref)}function QM(e){return IM(e,`RegExp`)&&_M(e.$id)&&JA(e.source)&&JA(e.flags)&&hM(e.maxLength)&&hM(e.minLength)}function $M(e){return IM(e,`String`)&&e.type===`string`&&_M(e.$id)&&hM(e.minLength)&&hM(e.maxLength)&&vM(e.pattern)&&yM(e.format)}function eN(e){return IM(e,`Symbol`)&&e.type===`symbol`&&_M(e.$id)}function tN(e){return IM(e,`TemplateLiteral`)&&e.type===`string`&&JA(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function nN(e){return IM(e,`This`)&&_M(e.$id)&&JA(e.$ref)}function rN(e){return KA(e)&&vj in e}function iN(e){return IM(e,`Tuple`)&&e.type===`array`&&_M(e.$id)&&GA(e.minItems)&&GA(e.maxItems)&&e.minItems===e.maxItems&&(ZA(e.items)&&ZA(e.additionalItems)&&e.minItems===0||RA(e.items)&&e.items.every(e=>fN(e)))}function aN(e){return IM(e,`Undefined`)&&e.type===`undefined`&&_M(e.$id)}function oN(e){return IM(e,`Union`)&&_M(e.$id)&&KA(e)&&RA(e.anyOf)&&e.anyOf.every(e=>fN(e))}function sN(e){return IM(e,`Uint8Array`)&&e.type===`Uint8Array`&&_M(e.$id)&&hM(e.minByteLength)&&hM(e.maxByteLength)}function cN(e){return IM(e,`Unknown`)&&_M(e.$id)}function lN(e){return IM(e,`Unsafe`)}function uN(e){return IM(e,`Void`)&&e.type===`void`&&_M(e.$id)}function dN(e){return KA(e)&&X in e&&JA(e[X])&&!uM.includes(e[X])}function fN(e){return KA(e)&&(SM(e)||CM(e)||wM(e)||DM(e)||EM(e)||TM(e)||OM(e)||kM(e)||AM(e)||jM(e)||MM(e)||PM(e)||FM(e)||BM(e)||HM(e)||UM(e)||WM(e)||GM(e)||KM(e)||qM(e)||JM(e)||YM(e)||XM(e)||ZM(e)||QM(e)||$M(e)||eN(e)||tN(e)||nN(e)||iN(e)||aN(e)||oN(e)||sN(e)||cN(e)||lN(e)||uN(e)||dN(e))}var pN=`(true|false)`,mN=`(0|[1-9][0-9]*)`,hN=`(.*)`,gN=`(?!.*)`;`${pN}`;var _N=`^${mN}$`,vN=`^${hN}$`,yN=`^${gN}$`;function bN(e,t){return e.includes(t)}function xN(e){return[...new Set(e)]}function SN(e,t){return e.filter(e=>t.includes(e))}function CN(e,t){return e.reduce((e,t)=>SN(e,t),t)}function wN(e){return e.length===1?e[0]:e.length>1?CN(e.slice(1),e[0]):[]}function TN(e){let t=[];for(let n of e)t.push(...n);return t}function EN(e){return Y({[X]:`Any`},e)}function DN(e,t){return Y({[X]:`Array`,type:`array`,items:e},t)}function ON(e){return Y({[X]:`Argument`,index:e})}function kN(e,t){return Y({[X]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function AN(e,t,n){return Y({[X]:`Computed`,target:e,parameters:t},n)}function jN(e,t){let{[t]:n,...r}=e;return r}function MN(e,t){return t.reduce((e,t)=>jN(e,t),e)}function NN(e){return Y({[X]:`Never`,not:{}},e)}function PN(e){return Y({[X]:`MappedResult`,properties:e})}function FN(e,t,n){return Y({[X]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function IN(e,t,n){return Y({[X]:`Function`,type:`Function`,parameters:e,returns:t},n)}function LN(e,t){return Y({[X]:`Union`,anyOf:e},t)}function RN(e){return e.some(e=>Cj(e))}function zN(e){return e.map(e=>Cj(e)?BN(e):e)}function BN(e){return MN(e,[bj])}function VN(e,t){return RN(e)?DF(LN(zN(e),t)):LN(zN(e),t)}function HN(e,t){return e.length===1?Y(e[0],t):e.length===0?NN(t):VN(e,t)}function UN(e,t){return e.length===0?NN(t):e.length===1?Y(e[0],t):LN(e,t)}var WN=class extends _j{};function GN(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function KN(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function qN(e,t){return KN(e,t,`(`)}function JN(e,t){return KN(e,t,`)`)}function YN(e,t){return KN(e,t,`|`)}function XN(e){if(!(qN(e,0)&&JN(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(qN(e,n)&&(t+=1),JN(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function ZN(e){return e.slice(1,e.length-1)}function QN(e){let t=0;for(let n=0;n<e.length;n++)if(qN(e,n)&&(t+=1),JN(e,n)&&--t,YN(e,n)&&t===0)return!0;return!1}function $N(e){for(let t=0;t<e.length;t++)if(qN(e,t))return!0;return!1}function eP(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(qN(e,i)&&(t+=1),JN(e,i)&&--t,YN(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(nP(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(nP(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function tP(e){function t(e,t){if(!qN(e,t))throw new WN(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(qN(e,r)&&(n+=1),JN(e,r)&&--n,n===0)return[t,r];throw new WN(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(qN(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(qN(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(nP(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(nP(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function nP(e){return XN(e)?nP(ZN(e)):QN(e)?eP(e):$N(e)?tP(e):{type:`const`,const:GN(e)}}function rP(e){return nP(e.slice(1,e.length-1))}var iP=class extends _j{};function aP(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 oP(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 sP(e){return e.type===`const`&&e.const===`.*`}function cP(e){return aP(e)||sP(e)?!1:oP(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>cP(e)):e.type===`const`||(()=>{throw new iP(`Unknown expression type`)})()}function lP(e){return cP(rP(e.pattern))}var uP=class extends _j{};function*dP(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of dP(e.slice(1)))yield`${t}${n}`}function*fP(e){return yield*dP(e.expr.map(e=>[...hP(e)]))}function*pP(e){for(let t of e.expr)yield*hP(t)}function*mP(e){return yield e.const}function*hP(e){return e.type===`and`?yield*fP(e):e.type===`or`?yield*pP(e):e.type===`const`?yield*mP(e):(()=>{throw new uP(`Unknown expression`)})()}function gP(e){let t=rP(e.pattern);return cP(t)?[...hP(t)]:[]}function _P(e,t){return Y({[X]:`Literal`,const:e,type:typeof e},t)}function vP(e){return Y({[X]:`Boolean`,type:`boolean`},e)}function yP(e){return Y({[X]:`BigInt`,type:`bigint`},e)}function bP(e){return Y({[X]:`Number`,type:`number`},e)}function xP(e){return Y({[X]:`String`,type:`string`},e)}function*SP(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield vP():t===`number`?yield bP():t===`bigint`?yield yP():t===`string`?yield xP():yield(()=>{let e=t.split(`|`).map(e=>_P(e.trim()));return e.length===0?NN():e.length===1?e[0]:HN(e)})()}function*CP(e){if(e[1]!==`{`)return yield*[_P(`$`),...wP(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=SP(e.slice(2,t)),r=wP(e.slice(t+1));return yield*[...n,...r]}yield _P(e)}function*wP(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[_P(e.slice(0,t)),...CP(e.slice(t))];yield _P(e)}function TP(e){return[...wP(e)]}var EP=class extends _j{};function DP(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function OP(e,t){return Qj(e)?e.pattern.slice(1,e.pattern.length-1):rM(e)?`(${e.anyOf.map(e=>OP(e,t)).join(`|`)})`:Wj(e)||Pj(e)||Oj(e)?`${t}${mN}`:Xj(e)?`${t}${hN}`:Rj(e)?`${t}${DP(e.const.toString())}`:kj(e)?`${t}${pN}`:(()=>{throw new EP(`Unexpected Kind '${e[X]}'`)})()}function kP(e){return`^${e.map(e=>OP(e,``)).join(``)}$`}function AP(e){return HN(gP(e).map(e=>_P(e)))}function jP(e,t){let n=JA(e)?kP(TP(e)):kP(e);return Y({[X]:`TemplateLiteral`,type:`string`,pattern:n},t)}function MP(e){return gP(e).map(e=>e.toString())}function NP(e){let t=[];for(let n of e)t.push(...FP(n));return t}function PP(e){return[e.toString()]}function FP(e){return[...new Set(Qj(e)?MP(e):rM(e)?NP(e.anyOf):Rj(e)?PP(e.const):Wj(e)||Pj(e)?[`[number]`]:[])]}function IP(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=XP(e,FP(t[i]),n);return r}function LP(e,t,n){return IP(e,t.properties,n)}function RP(e,t,n){return PN(LP(e,t,n))}function zP(e,t){return e.map(e=>qP(e,t))}function BP(e){return e.filter(e=>!Vj(e))}function VP(e,t){return IF(BP(zP(e,t)))}function HP(e){return e.some(e=>Vj(e))?[]:e}function UP(e,t){return HN(HP(zP(e,t)))}function WP(e,t){return t in e?e[t]:t===`[number]`?HN(e):NN()}function GP(e,t){return t===`[number]`?e:NN()}function KP(e,t){return t in e?e[t]:NN()}function qP(e,t){return Fj(e)?VP(e.allOf,t):rM(e)?UP(e.anyOf,t):tM(e)?WP(e.items??[],t):Ej(e)?GP(e.items,t):Gj(e)?KP(e.properties,t):NN()}function JP(e,t){return t.map(t=>qP(e,t))}function YP(e,t){return HN(JP(e,t))}function XP(e,t,n){if(Jj(e)||Jj(t)){if(!lM(e)||!lM(t))throw new _j(`Index types using Ref parameters require both Type and Key to be of TSchema`);return AN(`Index`,[e,t])}return Bj(t)?RP(e,t,n):zj(t)?eF(e,t,n):Y(lM(t)?YP(e,FP(t)):YP(e,t),n)}function ZP(e,t,n){return{[t]:XP(e,[t],ij(n))}}function QP(e,t,n){return t.reduce((t,r)=>({...t,...ZP(e,r,n)}),{})}function $P(e,t,n){return QP(e,t.keys,n)}function eF(e,t,n){return PN($P(e,t,n))}function tF(e,t){return Y({[X]:`Iterator`,type:`Iterator`,items:e},t)}function nF(e){return globalThis.Object.keys(e).filter(t=>!Cj(e[t]))}function rF(e,t){let n=nF(e);return Y(n.length>0?{[X]:`Object`,type:`object`,required:n,properties:e}:{[X]:`Object`,type:`object`,properties:e},t)}var iF=rF;function aF(e,t){return Y({[X]:`Promise`,type:`Promise`,item:e},t)}function oF(e){return Y(MN(e,[yj]))}function sF(e){return Y({...e,[yj]:`Readonly`})}function cF(e,t){return t===!1?oF(e):sF(e)}function lF(e,t){let n=t??!0;return Bj(e)?fF(e,n):cF(e,n)}function uF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=lF(e[r],t);return n}function dF(e,t){return uF(e.properties,t)}function fF(e,t){return PN(dF(e,t))}function pF(e,t){return Y(e.length>0?{[X]:`Tuple`,type:`array`,items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[X]:`Tuple`,type:`array`,minItems:e.length,maxItems:e.length},t)}function mF(e,t){return e in t?xF(e,t[e]):PN(t)}function hF(e){return{[e]:_P(e)}}function gF(e){let t={};for(let n of e)t[n]=_P(n);return t}function _F(e,t){return bN(t,e)?hF(e):gF(t)}function vF(e,t){return mF(e,_F(e,t))}function yF(e,t){return t.map(t=>xF(e,t))}function bF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=xF(e,t[r]);return n}function xF(e,t){let n={...t};return Cj(t)?DF(xF(e,MN(t,[bj]))):Sj(t)?lF(xF(e,MN(t,[yj]))):Bj(t)?mF(e,t.properties):zj(t)?vF(e,t.keys):jj(t)?FN(yF(e,t.parameters),xF(e,t.returns),n):Nj(t)?IN(yF(e,t.parameters),xF(e,t.returns),n):Dj(t)?kN(xF(e,t.items),n):Ij(t)?tF(xF(e,t.items),n):Fj(t)?LF(yF(e,t.allOf),n):rM(t)?UN(yF(e,t.anyOf),n):tM(t)?pF(yF(e,t.items??[]),n):Gj(t)?iF(bF(e,t.properties),n):Ej(t)?DN(xF(e,t.items),n):Kj(t)?aF(xF(e,t.item),n):t}function SF(e,t){let n={};for(let r of e)n[r]=xF(r,t);return n}function CF(e,t,n){let r=lM(e)?FP(e):e;return iF(SF(r,t({[X]:`MappedKey`,keys:r})),n)}function wF(e){return Y(MN(e,[bj]))}function TF(e){return Y({...e,[bj]:`Optional`})}function EF(e,t){return t===!1?wF(e):TF(e)}function DF(e,t){let n=t??!0;return Bj(e)?AF(e,n):EF(e,n)}function OF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=DF(e[r],t);return n}function kF(e,t){return OF(e.properties,t)}function AF(e,t){return PN(kF(e,t))}function jF(e,t={}){let n=e.every(e=>Gj(e)),r=lM(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return Y(t.unevaluatedProperties===!1||lM(t.unevaluatedProperties)||n?{...r,[X]:`Intersect`,type:`object`,allOf:e}:{...r,[X]:`Intersect`,allOf:e},t)}function MF(e){return e.every(e=>Cj(e))}function NF(e){return MN(e,[bj])}function PF(e){return e.map(e=>Cj(e)?NF(e):e)}function FF(e,t){return MF(e)?DF(jF(PF(e),t)):jF(PF(e),t)}function IF(e,t={}){if(e.length===1)return Y(e[0],t);if(e.length===0)return NN(t);if(e.some(e=>eM(e)))throw Error(`Cannot intersect transform types`);return FF(e,t)}function LF(e,t){if(e.length===1)return Y(e[0],t);if(e.length===0)return NN(t);if(e.some(e=>eM(e)))throw Error(`Cannot intersect transform types`);return jF(e,t)}function RF(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new _j(`Ref: $ref must be a string`);return Y({[X]:`Ref`,$ref:t},n)}function zF(e,t){return AN(`Awaited`,[AN(e,t)])}function BF(e){return AN(`Awaited`,[RF(e)])}function VF(e){return LF(WF(e))}function HF(e){return UN(WF(e))}function UF(e){return GF(e)}function WF(e){return e.map(e=>GF(e))}function GF(e,t){return Y(Aj(e)?zF(e.target,e.parameters):Fj(e)?VF(e.allOf):rM(e)?HF(e.anyOf):Kj(e)?UF(e.item):Jj(e)?BF(e.$ref):e,t)}function KF(e){let t=[];for(let n of e)t.push($F(n));return t}function qF(e){return TN(KF(e))}function JF(e){return wN(KF(e))}function YF(e){return e.map((e,t)=>t.toString())}function XF(e){return[`[number]`]}function ZF(e){return globalThis.Object.getOwnPropertyNames(e)}function QF(e){return eI?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function $F(e){return Fj(e)?qF(e.allOf):rM(e)?JF(e.anyOf):tM(e)?YF(e.items??[]):Ej(e)?XF(e.items):Gj(e)?ZF(e.properties):qj(e)?QF(e.patternProperties):[]}var eI=!1;function tI(e,t){return AN(`KeyOf`,[AN(e,t)])}function nI(e){return AN(`KeyOf`,[RF(e)])}function rI(e,t){return Y(HN(iI($F(e))),t)}function iI(e){return e.map(e=>e===`[number]`?bP():_P(e))}function aI(e,t){return Aj(e)?tI(e.target,e.parameters):Jj(e)?nI(e.$ref):Bj(e)?cI(e,t):rI(e,t)}function oI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=aI(e[r],ij(t));return n}function sI(e,t){return oI(e.properties,t)}function cI(e,t){return PN(sI(e,t))}function lI(e){let t=[];for(let n of e)t.push(...$F(n));return xN(t)}function uI(e){return e.filter(e=>!Vj(e))}function dI(e,t){let n=[];for(let r of e)n.push(...JP(r,[t]));return uI(n)}function fI(e,t){let n={};for(let r of t)n[r]=IF(dI(e,r));return n}function pI(e,t){return iF(fI(e,lI(e)),t)}function mI(e){return Y({[X]:`Date`,type:`Date`},e)}function hI(e){return Y({[X]:`Null`,type:`null`},e)}function gI(e){return Y({[X]:`Symbol`,type:`symbol`},e)}function _I(e){return Y({[X]:`Undefined`,type:`undefined`},e)}function vI(e){return Y({[X]:`Uint8Array`,type:`Uint8Array`},e)}function yI(e){return Y({[X]:`Unknown`},e)}function bI(e){return e.map(e=>CI(e,!1))}function xI(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=lF(CI(e[n],!1));return t}function SI(e,t){return t===!0?e:lF(e)}function CI(e,t){return LA(e)||UA(e)?SI(EN(),t):RA(e)?lF(pF(bI(e))):XA(e)?vI():VA(e)?mI():KA(e)?SI(iF(xI(e)),t):HA(e)?SI(IN([],yI()),t):ZA(e)?_I():WA(e)?hI():YA(e)?gI():zA(e)?yP():GA(e)||BA(e)||JA(e)?_P(e):iF({})}function wI(e,t){return Y(CI(e,!0),t)}function TI(e,t){return jj(e)?pF(e.parameters,t):NN(t)}function EI(e,t){if(ZA(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return UN([...new Set(n)].map(e=>_P(e)),{...t,[xj]:`Enum`})}var DI=class extends _j{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function OI(e){return e===Q.False?e:Q.True}function kI(e){throw new DI(e)}function AI(e){return WM(e)||PM(e)||oN(e)||cN(e)||SM(e)}function jI(e,t){return WM(t)?YI(e,t):PM(t)?GI(e,t):oN(t)?ML(e,t):cN(t)?PL(e,t):SM(t)?MI(e,t):kI(`StructuralRight`)}function MI(e,t){return Q.True}function NI(e,t){return PM(t)?GI(e,t):oN(t)&&t.anyOf.some(e=>SM(e)||cN(e))?Q.True:oN(t)?Q.Union:cN(t)||SM(t)?Q.True:Q.Union}function PI(e,t){return cN(e)?Q.False:SM(e)?Q.Union:WM(e)?Q.True:Q.False}function FI(e,t){return JM(t)&&fL(t)?Q.True:AI(t)?jI(e,t):wM(t)?OI(RL(e.items,t.items)):Q.False}function II(e,t){return AI(t)?jI(e,t):TM(t)?OI(RL(e.items,t.items)):Q.False}function LI(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):EM(t)?Q.True:Q.False}function RI(e,t){return zM(e)||DM(e)?Q.True:Q.False}function zI(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):DM(t)?Q.True:Q.False}function BI(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):kM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>OI(RL(t.parameters[n],e))===Q.True)?OI(RL(e.returns,t.returns)):Q.False:Q.False}function VI(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):AM(t)?Q.True:Q.False}function HI(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):jM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>OI(RL(t.parameters[n],e))===Q.True)?OI(RL(e.returns,t.returns)):Q.False:Q.False}function UI(e,t){return BM(e)&&GA(e.const)||qM(e)||MM(e)?Q.True:Q.False}function WI(e,t){return MM(t)||qM(t)?Q.True:AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):Q.False}function GI(e,t){return t.allOf.every(t=>RL(e,t)===Q.True)?Q.True:Q.False}function KI(e,t){return e.allOf.some(e=>RL(e,t)===Q.True)?Q.True:Q.False}function qI(e,t){return AI(t)?jI(e,t):FM(t)?OI(RL(e.items,t.items)):Q.False}function JI(e,t){return BM(t)&&t.const===e.const?Q.True:AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):$M(t)?CL(e,t):qM(t)?eL(e,t):MM(t)?UI(e,t):DM(t)?RI(e,t):Q.False}function YI(e,t){return Q.False}function XI(e,t){return Q.True}function ZI(e){let[t,n]=[e,0];for(;GM(t);)t=t.not,n+=1;return n%2==0?t:yI()}function QI(e,t){return GM(e)?RL(ZI(e),t):GM(t)?RL(e,ZI(t)):kI(`Invalid fallthrough for Not`)}function $I(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):KM(t)?Q.True:Q.False}function eL(e,t){return RM(e)||qM(e)||MM(e)?Q.True:Q.False}function tL(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):MM(t)||qM(t)?Q.True:Q.False}function nL(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function rL(e){return fL(e)}function iL(e){return nL(e,0)||nL(e,1)&&`description`in e.properties&&oN(e.properties.description)&&e.properties.description.anyOf.length===2&&($M(e.properties.description.anyOf[0])&&aN(e.properties.description.anyOf[1])||$M(e.properties.description.anyOf[1])&&aN(e.properties.description.anyOf[0]))}function aL(e){return nL(e,0)}function oL(e){return nL(e,0)}function sL(e){return nL(e,0)}function cL(e){return nL(e,0)}function lL(e){return fL(e)}function uL(e){let t=bP();return nL(e,0)||nL(e,1)&&`length`in e.properties&&OI(RL(e.properties.length,t))===Q.True}function dL(e){return nL(e,0)}function fL(e){let t=bP();return nL(e,0)||nL(e,1)&&`length`in e.properties&&OI(RL(e.properties.length,t))===Q.True}function pL(e){let t=IN([EN()],EN());return nL(e,0)||nL(e,1)&&`then`in e.properties&&OI(RL(e.properties.then,t))===Q.True}function mL(e,t){return RL(e,t)===Q.False||xM(e)&&!xM(t)?Q.False:Q.True}function hL(e,t){return cN(e)?Q.False:SM(e)?Q.Union:WM(e)||LM(e)&&rL(t)||RM(e)&&aL(t)||zM(e)&&oL(t)||eN(e)&&iL(t)||EM(e)&&sL(t)||$M(e)&&rL(t)||eN(e)&&iL(t)||qM(e)&&aL(t)||MM(e)&&aL(t)||DM(e)&&oL(t)||sN(e)&&lL(t)||AM(e)&&cL(t)||kM(e)&&dL(t)||jM(e)&&uL(t)?Q.True:XM(e)&&$M(vL(e))?t[xj]===`Record`?Q.True:Q.False:XM(e)&&qM(vL(e))&&nL(t,0)?Q.True:Q.False}function gL(e,t){return AI(t)?jI(e,t):XM(t)?bL(e,t):JM(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!xM(t.properties[n]))return Q.False;if(xM(t.properties[n]))return Q.True;if(mL(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function _L(e,t){return AI(t)?jI(e,t):JM(t)&&pL(t)?Q.True:YM(t)?OI(RL(e.item,t.item)):Q.False}function vL(e){return _N in e.patternProperties?bP():vN in e.patternProperties?xP():kI(`Unknown record key pattern`)}function yL(e){return _N in e.patternProperties?e.patternProperties[_N]:vN in e.patternProperties?e.patternProperties[vN]:kI(`Unable to get record value schema`)}function bL(e,t){let[n,r]=[vL(t),yL(t)];return LM(e)&&qM(n)&&OI(RL(e,r))===Q.True?Q.True:sN(e)&&qM(n)||$M(e)&&qM(n)||wM(e)&&qM(n)?RL(e,r):JM(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(mL(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function xL(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?RL(yL(e),yL(t)):Q.False}function SL(e,t){return RL(QM(e)?xP():e,QM(t)?xP():t)}function CL(e,t){return BM(e)&&JA(e.const)||$M(e)?Q.True:Q.False}function wL(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):$M(t)?Q.True:Q.False}function TL(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):eN(t)?Q.True:Q.False}function EL(e,t){return tN(e)?RL(AP(e),t):tN(t)?RL(e,AP(t)):kI(`Invalid fallthrough for TemplateLiteral`)}function DL(e,t){return wM(t)&&e.items!==void 0&&e.items.every(e=>RL(e,t.items)===Q.True)}function OL(e,t){return WM(e)?Q.True:cN(e)?Q.False:SM(e)?Q.Union:Q.False}function kL(e,t){return AI(t)?jI(e,t):JM(t)&&fL(t)||wM(t)&&DL(e,t)?Q.True:iN(t)?ZA(e.items)&&!ZA(t.items)||!ZA(e.items)&&ZA(t.items)?Q.False:ZA(e.items)&&!ZA(t.items)||e.items.every((e,n)=>RL(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function AL(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):sN(t)?Q.True:Q.False}function jL(e,t){return AI(t)?jI(e,t):JM(t)?hL(e,t):XM(t)?bL(e,t):uN(t)?IL(e,t):aN(t)?Q.True:Q.False}function ML(e,t){return t.anyOf.some(t=>RL(e,t)===Q.True)?Q.True:Q.False}function NL(e,t){return e.anyOf.every(e=>RL(e,t)===Q.True)?Q.True:Q.False}function PL(e,t){return Q.True}function FL(e,t){return WM(t)?YI(e,t):PM(t)?GI(e,t):oN(t)?ML(e,t):SM(t)?MI(e,t):$M(t)?CL(e,t):qM(t)?eL(e,t):MM(t)?UI(e,t):DM(t)?RI(e,t):wM(t)?PI(e,t):iN(t)?OL(e,t):JM(t)?hL(e,t):cN(t)?Q.True:Q.False}function IL(e,t){return aN(e)||aN(e)?Q.True:Q.False}function LL(e,t){return PM(t)?GI(e,t):oN(t)?ML(e,t):cN(t)?PL(e,t):SM(t)?MI(e,t):JM(t)?hL(e,t):uN(t)?Q.True:Q.False}function RL(e,t){return tN(e)||tN(t)?EL(e,t):QM(e)||QM(t)?SL(e,t):GM(e)||GM(t)?QI(e,t):SM(e)?NI(e,t):wM(e)?FI(e,t):EM(e)?LI(e,t):DM(e)?zI(e,t):TM(e)?II(e,t):kM(e)?BI(e,t):AM(e)?VI(e,t):jM(e)?HI(e,t):MM(e)?WI(e,t):PM(e)?KI(e,t):FM(e)?qI(e,t):BM(e)?JI(e,t):WM(e)?XI(e,t):KM(e)?$I(e,t):qM(e)?tL(e,t):JM(e)?gL(e,t):XM(e)?xL(e,t):$M(e)?wL(e,t):eN(e)?TL(e,t):iN(e)?kL(e,t):YM(e)?_L(e,t):sN(e)?AL(e,t):aN(e)?jL(e,t):oN(e)?NL(e,t):cN(e)?FL(e,t):uN(e)?LL(e,t):kI(`Unknown left type operand '${e[X]}'`)}function zL(e,t){return RL(e,t)}function BL(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=WL(e[o],t,n,r,ij(i));return a}function VL(e,t,n,r,i){return BL(e.properties,t,n,r,i)}function HL(e,t,n,r,i){return PN(VL(e,t,n,r,i))}function UL(e,t,n,r){let i=zL(e,t);return i===Q.Union?UN([n,r]):i===Q.True?n:r}function WL(e,t,n,r,i){return Bj(e)?HL(e,t,n,r,i):zj(e)?Y(JL(e,t,n,r,i)):Y(UL(e,t,n,r),i)}function GL(e,t,n,r,i){return{[e]:WL(_P(e),t,n,r,ij(i))}}function KL(e,t,n,r,i){return e.reduce((e,a)=>({...e,...GL(a,t,n,r,i)}),{})}function qL(e,t,n,r,i){return KL(e.keys,t,n,r,i)}function JL(e,t,n,r,i){return PN(qL(e,t,n,r,i))}function YL(e,t){return ZL(AP(e),t)}function XL(e,t){let n=e.filter(e=>zL(e,t)===Q.False);return n.length===1?n[0]:UN(n)}function ZL(e,t,n={}){return Qj(e)?Y(YL(e,t),n):Bj(e)?Y(eR(e,t),n):Y(rM(e)?XL(e.anyOf,t):zL(e,t)===Q.False?e:NN(),n)}function QL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=ZL(e[r],t);return n}function $L(e,t){return QL(e.properties,t)}function eR(e,t){return PN($L(e,t))}function tR(e,t){return rR(AP(e),t)}function nR(e,t){let n=e.filter(e=>zL(e,t)!==Q.False);return n.length===1?n[0]:UN(n)}function rR(e,t,n){return Qj(e)?Y(tR(e,t),n):Bj(e)?Y(oR(e,t),n):Y(rM(e)?nR(e.anyOf,t):zL(e,t)===Q.False?NN():e,n)}function iR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=rR(e[r],t);return n}function aR(e,t){return iR(e.properties,t)}function oR(e,t){return PN(aR(e,t))}function sR(e,t){return jj(e)?Y(e.returns,t):NN(t)}function cR(e){return lF(DF(e))}function lR(e,t,n){return Y({[X]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function uR(e,t,n){let r={};for(let n of e)r[n]=t;return iF(r,{...n,[xj]:`Record`})}function dR(e,t,n){return lP(e)?uR(FP(e),t,n):lR(e.pattern,t,n)}function fR(e,t,n){return uR(FP(UN(e)),t,n)}function pR(e,t,n){return uR([e.toString()],t,n)}function mR(e,t,n){return lR(e.source,t,n)}function hR(e,t,n){return lR(ZA(e.pattern)?vN:e.pattern,t,n)}function gR(e,t,n){return lR(vN,t,n)}function _R(e,t,n){return lR(yN,t,n)}function vR(e,t,n){return iF({true:t,false:t},n)}function yR(e,t,n){return lR(_N,t,n)}function bR(e,t,n){return lR(_N,t,n)}function xR(e,t,n={}){return rM(e)?fR(e.anyOf,t,n):Qj(e)?dR(e,t,n):Rj(e)?pR(e.const,t,n):kj(e)?vR(e,t,n):Pj(e)?yR(e,t,n):Wj(e)?bR(e,t,n):Yj(e)?mR(e,t,n):Xj(e)?hR(e,t,n):wj(e)?gR(e,t,n):Vj(e)?_R(e,t,n):NN(n)}function SR(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function CR(e){let t=SR(e);return t===vN?xP():t===_N?bP():xP({pattern:t})}function wR(e){return e.patternProperties[SR(e)]}function TR(e,t){return t.parameters=zR(e,t.parameters),t.returns=BR(e,t.returns),t}function ER(e,t){return t.parameters=zR(e,t.parameters),t.returns=BR(e,t.returns),t}function DR(e,t){return t.allOf=zR(e,t.allOf),t}function OR(e,t){return t.anyOf=zR(e,t.anyOf),t}function kR(e,t){return ZA(t.items)||(t.items=zR(e,t.items)),t}function AR(e,t){return t.items=BR(e,t.items),t}function jR(e,t){return t.items=BR(e,t.items),t}function MR(e,t){return t.items=BR(e,t.items),t}function NR(e,t){return t.item=BR(e,t.item),t}function PR(e,t){let n=RR(e,t.properties);return{...t,...iF(n)}}function FR(e,t){let n=xR(BR(e,CR(t)),BR(e,wR(t)));return{...t,...n}}function IR(e,t){return t.index in e?e[t.index]:yI()}function LR(e,t){let n=Sj(t),r=Cj(t),i=BR(e,t);return n&&r?cR(i):n&&!r?lF(i):!n&&r?DF(i):i}function RR(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:LR(e,t[r])}),{})}function zR(e,t){return t.map(t=>BR(e,t))}function BR(e,t){return jj(t)?TR(e,t):Nj(t)?ER(e,t):Fj(t)?DR(e,t):rM(t)?OR(e,t):tM(t)?kR(e,t):Ej(t)?AR(e,t):Dj(t)?jR(e,t):Ij(t)?MR(e,t):Kj(t)?NR(e,t):Gj(t)?PR(e,t):qj(t)?FR(e,t):Tj(t)?IR(e,t):t}function VR(e,t){return BR(t,aj(e))}function HR(e){return Y({[X]:`Integer`,type:`integer`},e)}function UR(e,t,n){return{[e]:ez(_P(e),t,ij(n))}}function WR(e,t,n){return e.reduce((e,r)=>({...e,...UR(r,t,n)}),{})}function GR(e,t,n){return WR(e.keys,t,n)}function KR(e,t,n){return PN(GR(e,t,n))}function qR(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function JR(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function YR(e){return e.toUpperCase()}function XR(e){return e.toLowerCase()}function ZR(e,t,n){let r=rP(e.pattern);return cP(r)?jP([UN($R([...hP(r)].map(e=>_P(e)),t))],n):{...e,pattern:QR(e.pattern,t)}}function QR(e,t){return typeof e==`string`?t===`Uncapitalize`?qR(e):t===`Capitalize`?JR(e):t===`Uppercase`?YR(e):t===`Lowercase`?XR(e):e:e.toString()}function $R(e,t){return e.map(e=>ez(e,t))}function ez(e,t,n={}){return zj(e)?KR(e,t,n):Qj(e)?ZR(e,t,n):rM(e)?UN($R(e.anyOf,t),n):Rj(e)?_P(QR(e.const,t),n):Y(e,n)}function tz(e,t={}){return ez(e,`Capitalize`,t)}function nz(e,t={}){return ez(e,`Lowercase`,t)}function rz(e,t={}){return ez(e,`Uncapitalize`,t)}function iz(e,t={}){return ez(e,`Uppercase`,t)}function az(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=hz(e[i],t,ij(n));return r}function oz(e,t,n){return az(e.properties,t,n)}function sz(e,t,n){return PN(oz(e,t,n))}function cz(e,t){return e.map(e=>mz(e,t))}function lz(e,t){return e.map(e=>mz(e,t))}function uz(e,t){let{[t]:n,...r}=e;return r}function dz(e,t){return t.reduce((e,t)=>uz(e,t),e)}function fz(e,t,n){let r=MN(e,[vj,`$id`,`required`,`properties`]);return iF(dz(n,t),r)}function pz(e){return UN(e.reduce((e,t)=>Lj(t)?[...e,_P(t)]:e,[]))}function mz(e,t){return Fj(e)?LF(cz(e.allOf,t)):rM(e)?UN(lz(e.anyOf,t)):Gj(e)?fz(e,t,e.properties):iF({})}function hz(e,t,n){let r=RA(t)?pz(t):t,i=lM(t)?FP(t):t,a=Jj(e),o=Jj(t);return Bj(e)?sz(e,i,n):zj(t)?yz(e,t,n):a&&o||!a&&o||a&&!o?AN(`Omit`,[e,r],n):Y({...mz(e,i),...n})}function gz(e,t,n){return{[t]:hz(e,[t],ij(n))}}function _z(e,t,n){return t.reduce((t,r)=>({...t,...gz(e,r,n)}),{})}function vz(e,t,n){return _z(e,t.keys,n)}function yz(e,t,n){return PN(vz(e,t,n))}function bz(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=kz(e[i],t,ij(n));return r}function xz(e,t,n){return bz(e.properties,t,n)}function Sz(e,t,n){return PN(xz(e,t,n))}function Cz(e,t){return e.map(e=>Oz(e,t))}function wz(e,t){return e.map(e=>Oz(e,t))}function Tz(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Ez(e,t,n){let r=MN(e,[vj,`$id`,`required`,`properties`]);return iF(Tz(n,t),r)}function Dz(e){return UN(e.reduce((e,t)=>Lj(t)?[...e,_P(t)]:e,[]))}function Oz(e,t){return Fj(e)?LF(Cz(e.allOf,t)):rM(e)?UN(wz(e.anyOf,t)):Gj(e)?Ez(e,t,e.properties):iF({})}function kz(e,t,n){let r=RA(t)?Dz(t):t,i=lM(t)?FP(t):t,a=Jj(e),o=Jj(t);return Bj(e)?Sz(e,i,n):zj(t)?Nz(e,t,n):a&&o||!a&&o||a&&!o?AN(`Pick`,[e,r],n):Y({...Oz(e,i),...n})}function Az(e,t,n){return{[t]:kz(e,[t],ij(n))}}function jz(e,t,n){return t.reduce((t,r)=>({...t,...Az(e,r,n)}),{})}function Mz(e,t,n){return jz(e,t.keys,n)}function Nz(e,t,n){return PN(Mz(e,t,n))}function Pz(e,t){return AN(`Partial`,[AN(e,t)])}function Fz(e){return AN(`Partial`,[RF(e)])}function Iz(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=DF(e[n]);return t}function Lz(e,t){let n=MN(e,[vj,`$id`,`required`,`properties`]);return iF(Iz(t),n)}function Rz(e){return e.map(e=>zz(e))}function zz(e){return Aj(e)?Pz(e.target,e.parameters):Jj(e)?Fz(e.$ref):Fj(e)?LF(Rz(e.allOf)):rM(e)?UN(Rz(e.anyOf)):Gj(e)?Lz(e,e.properties):Oj(e)||kj(e)||Pj(e)||Rj(e)||Uj(e)||Wj(e)||Xj(e)||Zj(e)||nM(e)?e:iF({})}function Bz(e,t){return Bj(e)?Uz(e,t):Y({...zz(e),...t})}function Vz(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Bz(e[r],ij(t));return n}function Hz(e,t){return Vz(e.properties,t)}function Uz(e,t){return PN(Hz(e,t))}function Wz(e,t){return AN(`Required`,[AN(e,t)])}function Gz(e){return AN(`Required`,[RF(e)])}function Kz(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=MN(e[n],[bj]);return t}function qz(e,t){let n=MN(e,[vj,`$id`,`required`,`properties`]);return iF(Kz(t),n)}function Jz(e){return e.map(e=>Yz(e))}function Yz(e){return Aj(e)?Wz(e.target,e.parameters):Jj(e)?Gz(e.$ref):Fj(e)?LF(Jz(e.allOf)):rM(e)?UN(Jz(e.anyOf)):Gj(e)?qz(e,e.properties):Oj(e)||kj(e)||Pj(e)||Rj(e)||Uj(e)||Wj(e)||Xj(e)||Zj(e)||nM(e)?e:iF({})}function Xz(e,t){return Bj(e)?$z(e,t):Y({...Yz(e),...t})}function Zz(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Xz(e[r],t);return n}function Qz(e,t){return Zz(e.properties,t)}function $z(e,t){return PN(Qz(e,t))}function eB(e,t){return t.map(t=>Jj(t)?tB(e,t.$ref):SB(e,t))}function tB(e,t){return t in e?Jj(e[t])?tB(e,e[t].$ref):SB(e,e[t]):NN()}function nB(e){return GF(e[0])}function rB(e){return XP(e[0],e[1])}function iB(e){return aI(e[0])}function aB(e){return Bz(e[0])}function oB(e){return hz(e[0],e[1])}function sB(e){return kz(e[0],e[1])}function cB(e){return Xz(e[0])}function lB(e,t,n){let r=eB(e,n);return t===`Awaited`?nB(r):t===`Index`?rB(r):t===`KeyOf`?iB(r):t===`Partial`?aB(r):t===`Omit`?oB(r):t===`Pick`?sB(r):t===`Required`?cB(r):NN()}function uB(e,t){return DN(SB(e,t))}function dB(e,t){return kN(SB(e,t))}function fB(e,t,n){return FN(xB(e,t),SB(e,n))}function pB(e,t,n){return IN(xB(e,t),SB(e,n))}function mB(e,t){return LF(xB(e,t))}function hB(e,t){return tF(SB(e,t))}function gB(e,t){return iF(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:SB(e,t[r])}),{}))}function _B(e,t){let[n,r]=[SB(e,wR(t)),SR(t)],i=aj(t);return i.patternProperties[r]=n,i}function vB(e,t){return Jj(t)?{...tB(e,t.$ref),[vj]:t[vj]}:t}function yB(e,t){return pF(xB(e,t))}function bB(e,t){return UN(xB(e,t))}function xB(e,t){return t.map(t=>SB(e,t))}function SB(e,t){return Cj(t)?Y(SB(e,MN(t,[bj])),t):Sj(t)?Y(SB(e,MN(t,[yj])),t):eM(t)?Y(vB(e,t),t):Ej(t)?Y(uB(e,t.items),t):Dj(t)?Y(dB(e,t.items),t):Aj(t)?Y(lB(e,t.target,t.parameters)):jj(t)?Y(fB(e,t.parameters,t.returns),t):Nj(t)?Y(pB(e,t.parameters,t.returns),t):Fj(t)?Y(mB(e,t.allOf),t):Ij(t)?Y(hB(e,t.items),t):Gj(t)?Y(gB(e,t.properties),t):qj(t)?Y(_B(e,t)):tM(t)?Y(yB(e,t.items||[]),t):rM(t)?Y(bB(e,t.anyOf),t):t}function CB(e,t){return t in e?SB(e,e[t]):NN()}function wB(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:CB(e,n)}),{})}var TB=class{constructor(e){let t=wB(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:Y(this.$defs[e],t)};return Y({[X]:`Import`,$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}};function EB(e){return new TB(e)}function DB(e,t){return Y({[X]:`Not`,not:e},t)}function OB(e,t){return Nj(e)?pF(e.parameters,t):NN()}var kB=0;function AB(e,t={}){ZA(t.$id)&&(t.$id=`T${kB++}`);let n=aj(e({[X]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,Y({[xj]:`Recursive`,...n},t)}function jB(e,t){let n=JA(e)?new globalThis.RegExp(e):e;return Y({[X]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function MB(e){return Fj(e)?e.allOf:rM(e)?e.anyOf:tM(e)?e.items??[]:[]}function NB(e){return MB(e)}function PB(e,t){return Nj(e)?Y(e.returns,t):NN(t)}var FB=class{constructor(e){this.schema=e}Decode(e){return new IB(this.schema,e)}},IB=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[vj].Encode(e(n)),Decode:e=>this.decode(t[vj].Decode(e))};return{...t,[vj]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[vj]:n}}Encode(e){return eM(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function LB(e){return new FB(e)}function RB(e={}){return Y({[X]:e[X]??`Unsafe`},e)}function zB(e){return Y({[X]:`Void`,type:`void`},e)}var $=t({Any:()=>EN,Argument:()=>ON,Array:()=>DN,AsyncIterator:()=>kN,Awaited:()=>GF,BigInt:()=>yP,Boolean:()=>vP,Capitalize:()=>tz,Composite:()=>pI,Const:()=>wI,Constructor:()=>FN,ConstructorParameters:()=>TI,Date:()=>mI,Enum:()=>EI,Exclude:()=>ZL,Extends:()=>WL,Extract:()=>rR,Function:()=>IN,Index:()=>XP,InstanceType:()=>sR,Instantiate:()=>VR,Integer:()=>HR,Intersect:()=>LF,Iterator:()=>tF,KeyOf:()=>aI,Literal:()=>_P,Lowercase:()=>nz,Mapped:()=>CF,Module:()=>EB,Never:()=>NN,Not:()=>DB,Null:()=>hI,Number:()=>bP,Object:()=>iF,Omit:()=>hz,Optional:()=>DF,Parameters:()=>OB,Partial:()=>Bz,Pick:()=>kz,Promise:()=>aF,Readonly:()=>lF,ReadonlyOptional:()=>cR,Record:()=>xR,Recursive:()=>AB,Ref:()=>RF,RegExp:()=>jB,Required:()=>Xz,Rest:()=>NB,ReturnType:()=>PB,String:()=>xP,Symbol:()=>gI,TemplateLiteral:()=>jP,Transform:()=>LB,Tuple:()=>pF,Uint8Array:()=>vI,Uncapitalize:()=>rz,Undefined:()=>_I,Union:()=>UN,Unknown:()=>yI,Unsafe:()=>RB,Uppercase:()=>iz,Void:()=>zB}),BB={additionalProperties:!1},VB=$.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}),HB=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),UB=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),WB=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),GB=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),KB=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,qB=`^(?:${KB}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,JB=$.String({pattern:qB,minLength:8,maxLength:36}),YB=new RegExp(qB),XB=/^[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 ZB(e){return typeof e!=`string`||e.length>36?!1:YB.test(e)}function QB(e){if(typeof e!=`string`)return;if(XB.test(e)){let t=e.toLowerCase();return ZB(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(ZB(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:VB,code:JB,deviceUid:VB,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:UB,clientTime:$.Integer(),hubNonce:$.Optional(WB)},BB),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:VB,deviceUid:VB,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:UB,clientTime:$.Integer(),hubNonce:$.Optional(WB)},BB);var $B=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:VB,nonce:WB,issuedAt:$.Integer(),hubId:VB,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(UB),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},BB);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:VB,code:JB,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:VB,challenge:$B},BB),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:VB,nonce:WB,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},BB),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:VB,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},BB),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:VB,deviceUid:VB,deviceId:HB,pairingEpoch:VB,credentialId:VB,generation:$.Integer({minimum:1}),hubId:VB,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:GB,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(UB)},BB),$.Object({enrollmentId:VB,deviceUid:VB,keyFingerprint:UB,replaceKey:$.Optional($.Boolean())},BB),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:HB,pairingEpoch:VB,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},BB);var eV=$.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}))},BB);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:VB,code:JB,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},BB);var tV=$.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:VB,expiresAt:$.Integer(),phase:tV,enrollment:$.Optional($.Object({enrollmentId:VB,deviceUid:VB,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:UB,proofVerified:$.Boolean(),keyChanged:$.Boolean()},BB)),deviceId:$.Optional(HB),error:$.Optional(eV)},BB);function nV(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 rV(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 iV=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,aV=RegExp(`^${KB}$`),oV=/^sha256:[0-9a-f]{64}$/;function sV(e){let t=rV(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=nV(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&iV.test(r.id)&&typeof r.code==`string`&&aV.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!oV.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 cV(e,t=Date.now()){let n=sV(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function lV(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=cV(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function uV(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=lV(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=cV(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:QB(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 dV=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,fV=e=>/^\/pair\/?$/.test(e.pathname)&&uV(e)===void 0?`/`:void 0,pV=4e3;async function mV(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 hV={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},gV={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},_V={class:`who`},vV={key:0,class:`muted`},yV={key:1,class:`muted`},bV={class:`fp`},xV={class:`row`},SV={class:`phase`},CV=[`onClick`],wV={key:2,class:`hint`},TV={class:`pair-steps`,"aria-label":`Pairing progress`},EV={class:`pair-grid`},DV={class:`pair-code-box`},OV={class:`pair-code`,"aria-label":`Pairing code`},kV={class:`pair-copy-actions`},AV=[`innerHTML`],jV={class:`pair-side`},MV={key:0,class:`hint`},NV={class:`pair-fingerprint`},PV={class:`fp`},FV={class:`pair-confirm`},IV={key:0,class:`pair-confirm warn`},LV=[`disabled`],RV=[`disabled`],zV={class:`hint`},BV=[`disabled`],VV={key:5,class:`error`,role:`alert`},HV={key:4},UV={class:`error`,role:`alert`},WV=M({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=O(`boot`),o=O(),s=O(),c=O(),l=O(``),u=O(!1),d=O(!1),f=O(!1),p=O(!1),m=O(!1),h=O(!1),g=O(),_=O([]),v=H(()=>{let e=s.value?.code??``;return!ZB(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=H(()=>s.value?Eb(s.value):``),b=H(()=>y.value?kA(y.value,148):``),x=H(()=>c.value?.enrollment?.keyFingerprint??``),S=H(()=>c.value?.deviceId??``);j(S,e=>{g.value?.(),e&&(g.value=j(()=>Hu.devices.value.find(t=>t.id===e)?.status,e=>{e===`online`&&(J(`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=kb();o.value=t;try{let n=e?await Db.resolveCode(e):await Db.createCode();if(t.closed()){await Db.cancel(n.codeId).catch(()=>{J(`The late pairing code could not be cancelled. Check device credentials before retrying.`)});return}if(s.value=n,a.value=`code`,e){let e=dV(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}Mb(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 Db.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 Db.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 Cl&&e.status===409&&String(e.code)===`already_issued`){let e=await Db.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 te=()=>w(!1),ne=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function re(){let e=S.value;if(e){u.value=!0;try{await Db.revoke(e,`user`),J(`Issued credential revoked.`),r(`close`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function ie(){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 ae(){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 oe(){if(!d.value){d.value=!0,u.value=!0;try{let e=await mV({needsCancel:!!s.value&&!ne(),cancel:te,timeoutMs:pV});if(!e.closed)return;o.value?.close(),g.value?.(),e.confirmed||J(`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:oe});let se;async function ce(){try{_.value=(await Db.pending()).codes}catch{}}async function le(e){s.value=void 0,c.value=void 0,l.value=``;let t=kb();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,Mb(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 Hr(()=>{if(ce(),se=setInterval(()=>void ce(),3e3),i.handoff&&`error`in i.handoff){l.value=i.handoff.error,a.value=`expired`;return}C(i.handoff?.code)}),Gr(()=>{clearInterval(se);let e=o.value;e&&!e.closed()&&s.value&&!ne()&&w(!0).then(e=>{e!==`cancelled`&&J(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:As(oe,[`self`])},[R(`div`,hV,[R(`header`,null,[t[5]||=R(`h2`,{id:`pair-title`},`Pair a device`,-1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:oe},[z(k(Sl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(F(),L(IA,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):V(``,!0),_.value.length?(F(),I(`section`,gV,[t[6]||=R(`h3`,null,`Machines waiting for you`,-1),R(`ul`,null,[(F(!0),I(P,null,N(_.value,e=>(F(),I(`li`,{key:e.codeId},[R(`div`,_V,[R(`strong`,null,D(e.deviceName??`unnamed device`),1),e.hostname?(F(),I(`span`,vV,D(e.hostname),1)):V(``,!0),e.platform?(F(),I(`span`,yV,D(e.platform),1)):V(``,!0)]),R(`div`,bV,D(e.keyFingerprint),1),R(`div`,xV,[R(`span`,SV,D(e.phase.replaceAll(`_`,` `)),1),R(`button`,{type:`button`,class:`small`,onClick:t=>le(e)},`Review`,8,CV)])]))),128))]),t[7]||=R(`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)])):V(``,!0),a.value===`boot`?(F(),I(`p`,wV,`Minting a pairing code…`)):s.value?(F(),I(P,{key:3},[R(`ol`,TV,[t[8]||=R(`li`,{class:E({on:!0})},`Code`,-1),R(`li`,{class:E({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),R(`li`,{class:E({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),R(`li`,{class:E({on:a.value===`issued`})},`Online`,2)]),R(`div`,EV,[R(`div`,DV,[R(`div`,OV,D(v.value),1),R(`div`,kV,[R(`button`,{type:`button`,class:`small`,onClick:ie},[z(k(cc),{size:14}),B(` `+D(m.value?`Copied`:`Copy code`),1)]),R(`button`,{type:`button`,class:`small`,onClick:ae,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[z(k(cc),{size:14}),B(` `+D(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=R(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),R(`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)]),R(`div`,jV,[a.value===`code`||a.value===`proof`?(F(),I(`p`,MV,[z(k(el),{size:14,class:`spin`}),t[10]||=B(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(F(),I(P,{key:1},[R(`div`,NV,[t[11]||=R(`h3`,null,`Device key fingerprint`,-1),R(`code`,PV,D(x.value),1),t[12]||=R(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),R(`label`,FV,[A(R(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[xs,f.value]]),t[13]||=B(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(F(),I(`label`,IV,[A(R(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[xs,p.value]]),z(k(sl),{size:14}),t[14]||=B(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):V(``,!0),R(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:ee},` Approve device `,8,LV),R(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:te},` Cancel pairing `,8,RV)],64)):a.value===`issued`?(F(),I(P,{key:2},[R(`p`,zV,[z(k(ac),{size:14}),t[15]||=B(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),R(`button`,{type:`button`,class:`small`,onClick:oe},`Close`),R(`button`,{type:`button`,class:`small danger`,disabled:!S.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:re},` Revoke this credential `,8,BV)],64)):a.value===`cancelled`?(F(),I(P,{key:3},[t[16]||=R(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),R(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>C()},`Start over`)],64)):a.value===`expired`?(F(),I(P,{key:4},[t[17]||=R(`p`,{class:`hint`},`The pairing code expired.`,-1),R(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>C()},`New code`)],64)):V(``,!0),l.value?(F(),I(`p`,VV,D(l.value),1)):V(``,!0)])])],64)):(F(),I(`div`,HV,[R(`p`,UV,D(l.value||`This pairing link is unavailable.`),1),R(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>C()},`New code`)]))])]))}}),GV={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},KV={class:`hint`},qV={key:1,class:`hint`},JV=M({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>Hu.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[2]||=As(e=>r(`close`),[`self`])},[R(`section`,GV,[R(`header`,null,[t[3]||=R(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[z(k(Sl),{size:18})])]),i.value?(F(),I(P,{key:0},[R(`p`,null,[B(D(i.value.name)+` `,1),R(`code`,null,D(i.value.id),1)]),R(`p`,KV,D(i.value.status)+` · tunnel `+D(i.value.tunnel?.state??`disconnected`)+` · `+D(i.value.tunnel?.readerCount??0)+` readers `,1),z(Vb,{device:i.value},null,8,[`device`])],64)):(F(),I(`p`,qV,`This device is no longer in the registry.`)),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),YV={id:`prompt-title`},XV=[`disabled`],ZV={key:0,class:`hint`},QV={key:1},$V={key:0,class:`muted`},eH=[`placeholder`,`disabled`],tH=[`required`,`placeholder`,`aria-label`,`disabled`],nH={key:2,class:`message-error`,role:`alert`},rH=[`disabled`],iH=[`disabled`],aH=M({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=O(r.dialog.value??``),o=O(!1),s=O(``),c=O(),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=G(e)}finally{o.value=!1}}}return Hr(()=>void jn(()=>(c.value?.focus(),c.value?.select()))),t({busy:o}),(t,n)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:n[4]||=As(e=>!o.value&&i(`close`),[`self`])},[R(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:As(u,[`prevent`])},[R(`header`,null,[R(`h2`,YV,D(e.dialog.title),1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:o.value,onClick:n[0]||=e=>i(`close`)},[z(k(Sl),{size:18})],8,XV)]),e.dialog.hint?(F(),I(`p`,ZV,D(e.dialog.hint),1)):V(``,!0),l?(F(),I(`label`,QV,[B(D(e.dialog.label)+` `,1),e.dialog.optional?(F(),I(`span`,$V,`(optional)`)):V(``,!0),e.dialog.multiline?A((F(),I(`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,eH)),[[bs,a.value]]):A((F(),I(`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,tH)),[[bs,a.value]])])):V(``,!0),s.value?(F(),I(`p`,nH,D(s.value),1)):V(``,!0),R(`footer`,null,[R(`button`,{type:`button`,class:`secondary`,disabled:o.value,onClick:n[3]||=e=>i(`close`)},` Cancel `,8,rH),R(`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,iH)])],32)]))}}),oH={class:`modal model-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Model picker`},sH={class:`eyebrow`},cH={class:`model-list`},lH={key:0,class:`model-row off-catalog`,"aria-disabled":`true`},uH=[`src`],dH=[`onClick`],fH=[`src`],pH={class:`hint`},mH=M({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=O(``),i=O();Hr(()=>void jn(()=>i.value?.focus()));let a=H(()=>fd.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),o=e=>{let t=bd.value;return!!t&&e.id===t.modelId&&e.provider===t.provider},s=H(()=>{let e=bd.value;return e&&!fd.value.some(t=>t.provider===e.provider&&t.id===e.modelId)?e:void 0});async function c(e){await kd(()=>rd.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await wd(),J(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[2]||=As(e=>n(`close`),[`self`])},[R(`section`,oH,[R(`header`,null,[R(`div`,null,[R(`span`,sH,`PER AGENT · `+D(k(Xu)?.name??k(Xu)?.id),1),t[3]||=R(`h2`,null,`Choose a model`,-1)]),R(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[z(k(Sl),{size:18})])]),A(R(`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),[[bs,r.value]]),R(`div`,cH,[s.value?(F(),I(`div`,lH,[R(`img`,{src:k(Nd)(s.value.modelId),alt:``},null,8,uH),R(`div`,null,[R(`strong`,null,D(s.value.modelId),1),R(`small`,null,D(s.value.provider)+` / current · not in this device's catalog`,1)])])):V(``,!0),(F(!0),I(P,null,N(a.value,e=>(F(),I(`button`,{key:`${e.provider}/${e.id}`,class:E({selected:o(e)}),onClick:t=>c(e)},[R(`img`,{src:k(Nd)(e.id),alt:``},null,8,fH),R(`div`,null,[R(`strong`,null,D(e.name),1),R(`small`,null,D(e.tier)+` / `+D(e.provider)+` / `+D(k(jd)(e.contextWindow))+` context`,1)]),o(e)?(F(),L(k(nc),{key:0,size:18})):V(``,!0)],10,dH))),128))]),R(`p`,pH,`Models available on `+D(k(Xu)?.id)+`. Provider keys stay on the device.`,1)])]))}}),hH={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},gH={class:`dialog-head`},_H={class:`dialog-body`},vH={class:`n`},yH={class:`body`},bH={class:`help-callout`},xH={class:`dialog-foot`},SH={class:`right`},CH=M({__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)=>(F(),I(`div`,{class:`scrim`,onClick:n[2]||=As(e=>k(q).dialog=void 0,[`self`])},[R(`section`,hH,[R(`div`,gH,[n[3]||=R(`div`,null,[R(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),R(`h3`,{id:`help-title`},`What makes this durable?`)],-1),R(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>k(q).dialog=void 0},[z(k(Sl),{size:18})])]),R(`div`,_H,[(F(),I(P,null,N(t,(e,t)=>R(`div`,{key:e.title,class:`help-step`},[R(`span`,vH,D(String(t+1).padStart(2,`0`)),1),R(`div`,null,[R(`b`,null,D(e.title),1),R(`div`,yH,D(e.body),1)])])),64)),R(`div`,bH,[z(k(kc),{size:18}),n[4]||=R(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),R(`div`,xH,[R(`div`,SH,[R(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>k(q).dialog=void 0},`Close`)])])])]))}}),wH=Gt({needed:!1,busy:!1,error:``}),TH=new Set,EH=e=>{let t=[...TH];TH=new Set;for(let n of t)n(e)},DH=()=>new Promise(e=>TH.add(e));async function OH(e){if(wH.busy||!e)return!1;wH.busy=!0,wH.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?(wH.needed=!1,EH(!0),!0):(wH.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 wH.error=`Cannot reach the hub.`,!1}finally{wH.busy=!1}}var kH=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||kH(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;wH.needed=!0;let a=await i.text().catch(()=>``);return await DH()?r():new Response(a,{status:i.status,headers:i.headers})})}function jH(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=AH(window.fetch.bind(window)))}var MH={class:`login-veil`,"data-testid":`login-card`},NH=[`disabled`],PH={key:0,class:`message-error`,role:`alert`},FH=[`disabled`],IH=M({__name:`LoginCard`,setup(e){let t=O(``),n=O();async function r(){if(wH.busy||!t.value.trim())return;let e=await OH(t.value.trim());t.value=``,e&&n.value?.blur()}return Hr(()=>void jn(()=>n.value?.focus())),(e,i)=>(F(),I(`div`,MH,[R(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:As(r,[`prevent`])},[i[2]||=R(`header`,null,[R(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=R(`p`,{class:`hint`},[B(` This hub is locked. Sign in with the token from its `),R(`code`,null,`admin.token`),B(` file. `)],-1),i[4]||=R(`label`,{for:`admin-token`},`Admin token`,-1),A(R(`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:k(wH).busy,onKeydown:i[1]||=Ms(e=>k(wH).error=``,[`esc`])},null,40,NH),[[bs,t.value]]),k(wH).error?(F(),I(`p`,PH,D(k(wH).error),1)):V(``,!0),R(`footer`,null,[R(`button`,{class:`primary`,type:`submit`,disabled:k(wH).busy||!t.value.trim()},D(k(wH).busy?`Checking…`:`Sign in`),9,FH)])],32)]))}}),LH={key:0,class:`toast`,role:`status`},RH=M({__name:`Toast`,setup(e){return(e,t)=>(F(),L(xo,{name:`toast`},{default:Un(()=>[k(q).toast?(F(),I(`div`,LH,[z(k(nc),{size:18}),B(D(k(q).toast),1)])):V(``,!0)]),_:1}))}});function zH(e,t=!1){return e.kind===`pair`?`pair`:e.kind===`prompt`&&t?`keep`:`close`}var BH={class:`shell`,"data-testid":`app-shell`},VH={key:0,class:`error-banner`,role:`alert`},HH={key:4,class:`welcome`,"data-testid":`welcome-empty`},UH=[`disabled`],WH={class:`welcome-features`},GH={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},KH={class:`full-directory`},qH=M({__name:`App`,setup(e){let t=()=>Hu.devices.value.filter(e=>e.status===`online`).length,n=O(),r=O();function i(){q.dialog={kind:`new-session`,deviceId:K.value?.deviceId}}function a(e){let t=q.dialog?void 0:Kd(e);if(t)return e.preventDefault(),t===`tree`?Hd():Ud();if(e.key===`Escape`){if(q.dialog){let e=zH(q.dialog,r.value?.busy??!1);e===`pair`?n.value?.close():e===`close`&&(q.dialog=void 0);return}!e.repeat&&!e.isComposing&&_d.value&&(e.preventDefault(),Id()),q.drawer=!1,q.inspectorOverlay=!1}}function o(e){let t=e.clientX,n=Ku.value,r=e=>Ku.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 Hr(()=>jf()),Hr(()=>{document.addEventListener(`keydown`,a),ud()}),Gr(()=>{Bu.stop(),document.removeEventListener(`keydown`,a)}),(e,a)=>(F(),I(`div`,BH,[z(cf,{onNewSession:i}),k(q).error?(F(),I(`div`,VH,[z(k(kc),{size:18}),R(`span`,null,D(k(q).error),1),R(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:a[0]||=e=>k(q).error=``},`×`)])):V(``,!0),R(`main`,{class:`net-workspace`,style:ge({"--tree-w":`${k(Ku)}px`})},[z(Kp),k(qu).tree?(F(),I(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:As(o,[`prevent`])},null,32)):V(``,!0),k(q).drawer?(F(),I(`div`,{key:1,class:`tree-backdrop`,onClick:a[1]||=e=>k(q).drawer=!1})):V(``,!0),k(K)&&k(Xu)&&k(Zu)?(F(),I(P,{key:2},[z(Ek),k(q).inspectorOverlay?(F(),I(`div`,{key:0,class:`inspector-backdrop`,onClick:a[2]||=e=>k(Vd)()})):V(``,!0),(F(),L(Jy,{key:`${k(K).deviceId}/${k(K).sessionId}`}))],64)):k(K)&&k(Xu)?(F(),L(Ik,{key:3,device:k(Xu)},null,8,[`device`])):(F(),I(`section`,HH,[a[14]||=R(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),a[15]||=R(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),a[16]||=R(`h1`,null,[B(`Close the tab.`),R(`br`),B(`The work continues.`)],-1),a[17]||=R(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),R(`button`,{class:`primary`,disabled:!t(),onClick:i},[z(k(Zc),{size:18}),B(D(k(Hu).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,UH),R(`div`,WH,[R(`span`,null,[z(k(pc),{size:18}),a[11]||=B(`SQLite on each device`,-1)]),R(`span`,null,[z(k(wc),{size:18}),a[12]||=B(`Branch any agent`,-1)]),R(`span`,null,[z(k(Hs),{size:18}),a[13]||=B(`Watch from anywhere`,-1)])])]))],4),z(df),k(q).dialog?.kind===`pair`?(F(),L(WV,{key:1,ref_key:`pairWizard`,ref:n,handoff:k(q).dialog.handoff,onClose:a[3]||=e=>k(q).dialog=void 0},null,8,[`handoff`])):V(``,!0),k(q).dialog?.kind===`credentials`?(F(),L(JV,{key:2,"device-id":k(q).dialog.deviceId,onClose:a[4]||=e=>k(q).dialog=void 0},null,8,[`device-id`])):V(``,!0),k(q).dialog?.kind===`new-session`?(F(),L(rA,{key:3,"device-id":k(q).dialog.deviceId,onClose:a[5]||=e=>k(q).dialog=void 0},null,8,[`device-id`])):k(q).dialog?.kind===`prompt`?(F(),L(aH,{key:4,ref_key:`promptDialog`,ref:r,dialog:k(q).dialog,onClose:a[6]||=e=>k(q).dialog=void 0},null,8,[`dialog`])):k(q).dialog?.kind===`models`?(F(),L(mH,{key:5,onClose:a[7]||=e=>k(q).dialog=void 0})):k(q).dialog?.kind===`path`?(F(),I(`div`,{key:6,class:`modal-backdrop`,onClick:a[10]||=As(e=>k(q).dialog=void 0,[`self`])},[R(`section`,GH,[R(`header`,null,[a[18]||=R(`h2`,{id:`path-title`},`Working directory`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:a[8]||=e=>k(q).dialog=void 0},[z(k(Sl),{size:18})])]),R(`code`,KH,D(k(q).dialog.path),1),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:a[9]||=e=>k(q).dialog=void 0},`Close`)])])])):k(q).dialog?.kind===`help`?(F(),L(CH,{key:7})):V(``,!0),k(wH).needed?(F(),L(IH,{key:8})):V(``,!0),z(RH)]))}});jH();var JH=new URL(window.location.href);if(/^\/pair\/?$/.test(JH.pathname)){let e=uV(JH);e?(JH.search=``,JH.hash=``,window.history.replaceState(window.history.state,``,JH),q.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,fV(JH))}Is(qH).mount(`#app`);
77
+ `+u),Pe&&(u=Lt(u)),w&&Ue?oe(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};bt(e),Le=!0,Re=Ce,ze=Te},t.clearConfig=function(){_t=null,Le=!1,Re=null,ze=null,w=ne,te=``},t.isValidAttribute=function(e,t,n){_t||bt({});let r=gt(e),i=gt(t);return Yt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&ig(me,e)&&Gh(me[e],t)},t.removeHook=function(e,t){if(ig(me,e)){if(t!==void 0){let n=Uh(me[e],t);return n===-1?void 0:Kh(me[e],n,1)[0]}return Wh(me[e])}},t.removeHooks=function(e){ig(me,e)&&(me[e]=[])},t.removeAllHooks=function(){me=qg()},t}var Zg=Xg();function Qg(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 $g=`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(`.`),e_=[`form`,`style`,`script`,`button`,`select`,`textarea`,`iframe`,`object`,`embed`,`svg`,`math`],t_={a:[`href`,`title`],img:[`src`,`alt`,`title`],th:[`colspan`,`rowspan`,`align`],td:[`colspan`,`rowspan`,`align`],ol:[`start`],code:[`class`],input:[`type`,`checked`,`disabled`]},n_=[...new Set(Object.values(t_).flat())],r_=/^language-[\w-]+$/,i_=/^\d{1,4}$/,a_=/^(left|right|center)$/i;function o_(e,t,n){if(!Object.hasOwn(t_,e)||!t_[e].includes(t))return!1;switch(t){case`class`:return r_.test(n);case`type`:return n.toLowerCase()===`checkbox`;case`colspan`:case`rowspan`:case`start`:return i_.test(n);case`align`:return a_.test(n);default:return!0}}var s_=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/i,c_=/^\/api(\/|$)/i;function l_(e,t){if(s_.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&&!c_.test(n.pathname)}Zg.isSupported&&Zg.addHook(`afterSanitizeAttributes`,e=>{let t=e.nodeName.toLowerCase();for(let{name:n,value:r}of Array.from(e.attributes))o_(t,n,r)||e.removeAttribute(n);if(t===`img`&&!l_(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:Qg(n,location.origin);r?(e.setAttribute(`href`,r),e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):(e.removeAttribute(`href`),e.removeAttribute(`target`))});var u_={ALLOWED_TAGS:$g,ALLOWED_ATTR:n_,FORBID_TAGS:e_,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1},d_=new Map;function f_(e){let t=d_.get(e);return t===void 0&&(t=Zg.sanitize(Sh.parse(e,{async:!1}),u_),d_.size>400&&d_.delete(d_.keys().next().value),d_.set(e,t)),t}var p_=`demo.job-runs`,m_=e=>e.status!==`running`&&e.status!==`waiting`,h_=H(()=>Xu.value?.info?.jobs??[]),g_=e=>h_.value.find(t=>t.id===e),__=H(()=>{let e=pd.value.docs[p_];return Object.values(e?.items??{}).sort((e,t)=>t.id-e.id)}),v_=e=>__.value.find(t=>t.id===e),y_=e=>__.value.find(t=>t.toolCallId===e),b_=O(Date.now());setInterval(()=>b_.value=Date.now(),1e3);var x_=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`,S_=O();async function C_(e,t){if(!S_.value){S_.value=e;try{return await kd(t)}finally{S_.value=void 0}}}function w_(e){Rd.value&&Vd(),setTimeout(()=>document.querySelector(`[data-job-run="${e}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`}))}async function T_(e){let t=await C_(`start:${e.id}`,()=>rd.value.demo(`jobs`,{job:e.id}));t&&(J(`${e.title} started. It runs in the chat.`),w_(t.taskId))}var E_=(e,t)=>C_(`decide:${e.id}`,()=>rd.value.demo(`jobs/${e.id}/approval`,{approved:t})),D_=e=>C_(`stop:${e.id}`,()=>id.value.abortTask(e.id));function O_(e){K.value&&ad({...K.value,agentId:e})}var k_=[`data-job-run`,`aria-label`],A_={class:`job-run-head`},j_={class:`job-run-icon`},M_={class:`job-run-titles`},N_={class:`job-run-eyebrow`},P_={class:`job-run-repeat`},F_={key:0,class:`job-run-about`},I_={class:`job-run-meta`},L_={key:0,class:`job-run-resumed`},R_={class:`job-stepper`,"aria-label":`Phases`},z_=[`aria-current`],B_={class:`job-chip`},V_={class:`job-step-dot`},H_={class:`job-step-label`},U_={key:0,class:`job-step-progress`},W_={class:`job-phases`},G_=[`open`],K_={class:`job-phase-n`},q_={class:`job-phase-summary`},J_={class:`job-phase-time`},Y_={key:0,class:`job-phase-about`},X_={key:1,class:`job-steps`},Z_=[`open`],Q_={key:1,class:`job-step-line`},$_=[`onClick`],ev={key:2,class:`job-phase-empty`},tv={key:1,class:`job-approval`,role:`group`,"aria-label":`Approval`},nv={class:`job-approval-buttons`},rv=[`disabled`],iv=[`disabled`],av={key:2,class:`message-error`},ov={class:`job-run-foot`},sv=[`disabled`],cv=M({__name:`JobCard`,props:{run:{}},setup(e){let t=e,n=H(()=>g_(t.run.job)),r=H(()=>m_(t.run)),i=H(()=>x_((t.run.endedAt??b_.value)-t.run.startedAt)),a={running:`Running`,waiting:`Waiting for you`,completed:`Completed`,failed:`Failed`,aborted:`Stopped`,declined:`Declined`},o={command:ml,tool:xl,agent:Qs,state:$s,approval:cl,checkpoint:vc,note:Fc},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)?ao(`code`,{title:s(t)},t.label):ao(`span`,{class:`job-step-text`},t.label),r=t.status===`running`?ao(Ic,{size:15,class:`spin`}):t.status===`done`?ao(nc,{size:15}):t.status===`waiting`?ao(Ec,{size:15}):ao(Sl,{size:15});return[ao(o[t.kind],{size:16,class:`job-step-kind`}),n,t.kind===`tool`&&t.detail?ao(`span`,{class:`job-step-args`,title:t.detail},t.detail):null,ao(`span`,{class:`job-step-state`},[r,t.ms!==void 0&&t.kind!==`note`?ao(`span`,x_(t.ms)):null])]};c.props=[`step`];let l=e=>n.value?.phases.find(t=>t.id===e),u=e=>e.startedAt?x_((e.endedAt??(e.status===`running`||e.status===`waiting`?b_.value:e.startedAt))-e.startedAt):``,d=e=>e.status!==`pending`&&e.status!==`skipped`,f=H(()=>Object.entries(t.run.input)),p=H(()=>t.run.phases.find(e=>e.status===`waiting`));return(t,o)=>(F(),I(`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]}`},[R(`header`,A_,[R(`span`,j_,[z(k(bl),{size:22})]),R(`div`,M_,[R(`div`,N_,[o[3]||=R(`span`,null,`DURABLE JOB`,-1),R(`span`,P_,[z(k(tl),{size:15}),B(`Repeatable workflow, run #`+D(e.run.run),1)])]),R(`h3`,null,D(e.run.title),1)]),R(`span`,{class:E([`job-run-status`,e.run.status])},[o[4]||=R(`i`,null,null,-1),B(D(a[e.run.status]),1)],2)]),n.value?(F(),I(`p`,F_,D(n.value.summary),1)):V(``,!0),R(`div`,I_,[R(`span`,null,`task #`+D(e.run.id),1),R(`span`,null,D(e.run.startedBy===`agent`?`started by the agent`:`started by you`),1),R(`span`,null,D(i.value),1),(F(!0),I(P,null,N(f.value,([e,t])=>(F(),I(`span`,{key:e,class:`job-run-input`},D(e)+`=`+D(t),1))),128)),e.run.resumed?(F(),I(`span`,L_,`resumed `+D(e.run.resumed)+`× after restart`,1)):V(``,!0)]),R(`ol`,R_,[(F(!0),I(P,null,N(e.run.phases,(t,n)=>(F(),I(`li`,{key:t.id,class:E(`ph-${t.status}`),"aria-current":e.run.phase===t.id&&!r.value?`step`:void 0},[R(`span`,B_,[R(`span`,V_,[t.status===`done`?(F(),L(k(nc),{key:0,size:15})):t.status===`running`?(F(),L(k(Ic),{key:1,size:15,class:`spin`})):t.status===`waiting`?(F(),L(k(Ec),{key:2,size:15})):[`failed`,`aborted`].includes(t.status)?(F(),L(k(Sl),{key:3,size:15})):(F(),I(P,{key:4},[B(D(n+1),1)],64))]),R(`span`,H_,D(t.label),1),t.progress?(F(),I(`span`,U_,D(t.progress.done)+`/`+D(t.progress.total),1)):V(``,!0)])],10,z_))),128))]),R(`div`,W_,[(F(!0),I(P,null,N(e.run.phases,(e,t)=>(F(),I(`details`,{key:e.id,class:E([`job-phase`,`ph-${e.status}`]),open:d(e)},[R(`summary`,null,[R(`span`,K_,D(t+1),1),R(`strong`,null,D(e.label),1),R(`span`,q_,D(e.summary??(e.status===`pending`?l(e.id)?.summary:e.status===`skipped`?`Skipped`:``)),1),R(`span`,J_,D(u(e)),1)]),e.status===`done`?V(``,!0):(F(),I(`p`,Y_,D(l(e.id)?.summary),1)),e.steps.length?(F(),I(`ul`,X_,[(F(!0),I(P,null,N(e.steps,e=>(F(),I(`li`,{key:e.id,class:E([`k-${e.kind}`,`st-${e.status}`])},[e.detail&&e.kind!==`tool`?(F(),I(`details`,{key:0,open:e.status===`error`},[R(`summary`,null,[z(c,{step:e},null,8,[`step`])]),R(`pre`,null,D(e.detail),1)],8,Z_)):(F(),I(`div`,Q_,[z(c,{step:e},null,8,[`step`])])),e.kind===`agent`&&e.conversationId?(F(),I(`button`,{key:2,class:`text-button job-step-link`,onClick:t=>k(O_)(e.conversationId)},` Open subagent #`+D(e.conversationId),9,$_)):V(``,!0)],2))),128))])):e.status===`pending`?(F(),I(`p`,ev,`Not started yet.`)):V(``,!0)],10,G_))),128))]),e.run.approval===`pending`?(F(),I(`div`,tv,[R(`div`,null,[z(k(cl),{size:20}),o[5]||=R(`strong`,null,`Approve to continue`,-1)]),R(`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),R(`div`,nv,[R(`button`,{class:`primary small`,disabled:!!k(S_),onClick:o[0]||=t=>k(E_)(e.run,!0)},[z(k(nc),{size:18}),o[6]||=B(`Approve & continue `,-1)],8,rv),R(`button`,{class:`secondary`,disabled:!!k(S_),onClick:o[1]||=t=>k(E_)(e.run,!1)},`Decline`,8,iv)])])):V(``,!0),e.run.error&&e.run.status!==`aborted`?(F(),I(`p`,av,D(e.run.error),1)):V(``,!0),R(`footer`,ov,[R(`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?V(``,!0):(F(),I(`button`,{key:0,class:`secondary danger`,disabled:!!k(S_),onClick:o[2]||=t=>k(D_)(e.run)},[z(k(Hc),{size:16}),o[7]||=B(`Stop `,-1)],8,sv))])],10,k_))}}),lv={class:`message-label`},uv={class:`user-message`},dv={class:`message-label`},fv={key:0,class:`streaming`},pv={key:1},mv=[`aria-label`],hv=[`innerHTML`],gv={key:1,class:`thinking`},_v=[`data-call-id`],vv={class:`tool-status`},yv={class:`tool-section-label`},bv=[`aria-label`,`onClick`],xv={key:0,class:`typing`},Sv={key:1,class:`message-error`},Cv=[`aria-label`],wv={key:3,class:`live-tool`},Tv={key:0},Ev={class:`event-line`},Dv=[`aria-label`],Ov={key:0,class:`raw`},kv=M({__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)=>(F(),I(`article`,{class:E([`entry`,i(e.item)])},[e.item.kind===`user`?(F(),I(P,{key:0},[R(`div`,lv,[a[3]||=B(` YOU `,-1),R(`span`,null,`#`+D(e.item.id),1)]),R(`div`,uv,D(e.item.text),1)],64)):e.item.kind===`assistant`?(F(),I(P,{key:1},[R(`div`,dv,[a[5]||=B(` AGENT `,-1),e.item.streaming?(F(),I(`span`,fv,`Working`)):(F(),I(`span`,pv,`#`+D(e.item.id),1)),e.item.streaming?V(``,!0):(F(),I(`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)},[z(k(wc),{size:18}),a[4]||=B(`Fork `,-1)],8,mv))]),(F(!0),I(P,null,N(e.item.blocks,(e,t)=>(F(),I(P,{key:t},[e.type===`text`?(F(),I(`div`,{key:0,class:`markdown`,innerHTML:k(f_)(e.text)},null,8,hv)):e.type===`thinking`?(F(),I(`details`,gv,[a[6]||=R(`summary`,null,`Thinking`,-1),R(`div`,null,D(e.text),1)])):(F(),I(`details`,{key:2,class:E([`tool-call`,{failed:e.call.status===`error`}]),"data-call-id":e.call.callId},[R(`summary`,null,[e.call.status===`error`?(F(),L(k(kc),{key:0,size:18})):e.call.status===`done`?(F(),L(k(nc),{key:1,size:18})):e.call.status===`running`?(F(),L(k(Hs),{key:2,size:18})):(F(),L(k(xl),{key:3,size:18})),R(`strong`,null,D(e.call.name),1),R(`code`,null,D(k(Md)(e.call.args)?.slice(0,90)),1),R(`span`,vv,D(r(e.call)),1)]),a[10]||=R(`div`,{class:`tool-section-label`},`Input`,-1),R(`pre`,null,D(k(Md)(e.call.args)),1),e.call.result===void 0?e.call.output?(F(),I(P,{key:1},[a[9]||=R(`div`,{class:`tool-section-label`},`Live output`,-1),R(`pre`,null,D(e.call.output),1)],64)):V(``,!0):(F(),I(P,{key:0},[R(`div`,yv,[a[8]||=R(`span`,null,`Result`,-1),e.call.resultEntryId===void 0?V(``,!0):(F(),I(`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)},[z(k(wc),{size:18}),a[7]||=B(`Fork `,-1)],8,bv))]),R(`pre`,null,D(e.call.result),1)],64))],10,_v)),e.type===`tool`&&e.call.name===`run_durable_job`&&k(y_)(e.call.callId)?(F(),L(cv,{key:3,run:k(y_)(e.call.callId)},null,8,[`run`])):V(``,!0)],64))),128)),e.item.streaming&&!e.item.blocks.length?(F(),I(`div`,xv,[...a[11]||=[R(`i`,null,null,-1),R(`i`,null,null,-1),R(`i`,null,null,-1)]])):V(``,!0),e.item.error?(F(),I(`div`,Sv,D(e.item.error),1)):V(``,!0)],64)):e.item.kind===`tool-result`?(F(),I(`details`,{key:2,class:E([`tool-result`,{failed:e.item.isError}])},[R(`summary`,null,[e.item.isError?(F(),L(k(kc),{key:1,size:18})):(F(),L(k(nc),{key:0,size:18})),R(`strong`,null,D(e.item.name),1),R(`span`,null,D(e.item.isError?`error`:`result`),1),R(`button`,{class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,onClick:a[1]||=As(t=>n(`fork`,e.item.id),[`prevent`])},[z(k(wc),{size:18}),a[12]||=B(`Fork `,-1)],8,Cv)]),R(`pre`,null,D(e.item.text),1)],2)):e.item.kind===`tool`?(F(),I(`div`,wv,[R(`div`,null,[z(k(Hs),{size:18}),R(`strong`,null,D(e.item.call.name),1),R(`span`,null,D(e.item.call.status),1)]),e.item.call.output?(F(),I(`pre`,Tv,D(e.item.call.output),1)):V(``,!0),e.item.call.name===`run_durable_job`&&k(y_)(e.item.call.callId)?(F(),L(cv,{key:1,run:k(y_)(e.item.call.callId)},null,8,[`run`])):V(``,!0)])):e.item.entryKind===`demo.job`&&k(v_)(e.item.data.taskId)?(F(),L(cv,{key:4,run:k(v_)(e.item.data.taskId)},null,8,[`run`])):(F(),I(P,{key:5},[R(`div`,Ev,[e.item.entryKind===`demo.state-change`?(F(),L(k($s),{key:0,size:18})):(F(),L(k(Mc),{key:1,size:18})),R(`span`,null,D(e.item.text),1),R(`button`,{class:`fork-button`,"aria-label":`Fork at entry ${e.item.id}`,onClick:a[2]||=t=>n(`fork`,e.item.id)},[z(k(wc),{size:18}),a[13]||=B(`Fork `,-1)],8,Dv)]),e.item.note?(F(),I(`details`,Ov,[a[14]||=R(`summary`,null,`Context note`,-1),R(`pre`,null,D(e.item.note),1)])):V(``,!0)],64))],2))}}),Av={key:0,class:`git-chip-wrap`},jv=[`title`],Mv={class:`branch`},Nv={key:0,class:`dirty`},Pv={key:1,class:`ahead`},Fv={key:2,class:`behind`},Iv=sf(M({__name:`GitChip`,props:{deviceId:{},cwd:{}},setup(e){let t=e,n=H(()=>t.cwd??td.value?.cwd??``),r=H(()=>t.deviceId??Yu.value),i=H(()=>Df(r.value||`?`,n.value||`?`)),a=H(()=>i.value.status),o=H(()=>i.value.loading),s=H(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0));return kf(r.value||`?`,n.value||`?`),qr(()=>kf(r.value||`?`,n.value||`?`)),j([r,n],()=>void kf(r.value||`?`,n.value||`?`)),(e,t)=>a.value?.repo||o.value?(F(),I(`span`,Av,[R(`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=>k(Bd)(`git`)},[z(k(Sc),{size:16,"aria-hidden":`true`}),R(`span`,Mv,D(a.value?.branch??a.value?.head??`…`),1),s.value?(F(),I(`span`,Nv,`±`+D(s.value),1)):V(``,!0),a.value?.ahead?(F(),I(`span`,Pv,`↑`+D(a.value.ahead),1)):V(``,!0),a.value?.behind?(F(),I(`span`,Fv,`↓`+D(a.value.behind),1)):V(``,!0),z(k(rc),{size:14,"aria-hidden":`true`})],8,jv)])):V(``,!0)}}),[[`__scopeId`,`data-v-c0fb9e98`]]),Lv=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,Rv=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],zv={enabled:!0,reserveTokens:16384,backgroundTokens:32768,keepRecentTokens:2e3},Bv={auto:2e5,wait:25e4};function Vv(e){if(!(e>0))return{...zv};let t=Math.min(Bv.wait,e-zv.reserveTokens),n=Math.min(Bv.auto,t-zv.backgroundTokens);return{...zv,reserveTokens:e-t,backgroundTokens:t-n}}function Hv(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 Uv=(e,t)=>{if(e===void 0)throw Error(`No ${t} selected`);return e},Wv=[{name:`compact`,args:`[instructions]`,description:`Summarize older context; stored entries stay`,run:async e=>{await Uv(rd.value,`agent`).compact(e||void 0),J(`Compaction requested. /tasks shows its outcome.`)}},{name:`reset`,args:`[handoff note]`,description:`Start a fresh context; history stays stored`,run:async e=>{await Uv(rd.value,`agent`).reset(e||void 0),J(`New context started.`)}},{name:`tasks`,description:`Open the Tasks panel`,run:()=>Bd(`tasks`)},{name:`new`,args:`[name]`,description:`New agent in this workspace`,run:async e=>{let t=Uv(K.value,`workspace`),n=await Uv(id.value,`workspace`).createAgent({name:e||`Agent ${md.value.length+1}`});ad({...t,agentId:n.id}),J(`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??pd.value.entries.filter(e=>e.kind===`pi.assistant`).at(-1)?.id;if(a===void 0)throw Error(`Nothing to fork yet`);let o=Uv(K.value,`agent`),s=await Uv(rd.value,`agent`).fork({entryId:a,name:i||void 0});ad({...o,agentId:s.id}),J(`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 Uv(rd.value,`agent`).rename(e),J(`Agent renamed to ${e}.`)}},{name:`model`,description:`Choose this agent's model`,run:()=>q.dialog={kind:`models`}},{name:`thinking`,args:`<level>`,description:`Thinking level: ${Rv.join(`, `)}`,run:async e=>{if(!Rv.includes(e))throw Error(`Levels: ${Rv.join(`, `)}`);await Uv(rd.value,`agent`).configure({thinkingLevel:e}),await wd(),J(`Thinking ${e}. Used on the next turn.`)}},{name:`help`,description:`How this works, keys and commands`,run:()=>q.dialog={kind:`help`}}];function Gv(e){let t=e.trim().match(/^\/(\S+)\s*([\s\S]*)$/),n=t&&Wv.find(e=>e.name===t[1]);return n?{command:n,arg:t[2].trim()}:void 0}var Kv={class:`composer-region`},qv={key:0,class:`queue`},Jv=[`aria-label`,`onClick`],Yv={class:`composer`},Xv={key:0,class:`slash-menu`,role:`listbox`,"aria-label":`Slash commands`},Zv=[`aria-selected`,`onMousedown`],Qv={key:0,class:`slash-args`},$v={class:`slash-desc`},ey={class:`composer-toolbar`},ty={class:`composer-left`},ny={class:`lib-wrap`},ry=[`aria-label`],iy={key:0,class:`hint`},ay={class:`save-row`},oy=[`disabled`],sy=[`title`,`onClick`],cy=[`aria-label`,`onClick`],ly={class:`queue-mode`},uy={class:`composer-right`},dy=[`disabled`],fy=[`disabled`],py=`dpi-prompt-library`,my=sf(M({__name:`Composer`,setup(e){let t=O(`followUp`),n=O(!1),r=O(``),i=O([]),a=()=>{try{i.value=JSON.parse(localStorage.getItem(py)??`[]`)}catch{i.value=[]}},o=()=>localStorage.setItem(py,JSON.stringify(i.value));a();let s=()=>{let e=q.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=O(!1),u=H(()=>Zu.value&&pd.value.ready&&$u.status.value===`live`&&Vu.value===`live`),d=O(0),f=O(!1),p=H(()=>{let e=q.composer.match(/^\/(\S*)$/);return e&&!f.value?Wv.filter(t=>t.name.startsWith(e[1].toLowerCase())):[]});j(()=>q.composer,()=>{d.value=0,q.composer.startsWith(`/`)||(f.value=!1)});async function m(e,t=!1){!e.args||t&&e.args.startsWith(`[`)&&q.composer===`/${e.name}`?(q.composer=`/${e.name}`,await _()):q.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=Gv(e);return t?(l.value=!0,await kd(async()=>{await t.command.run(t.arg),q.composer=``}),l.value=!1,!0):!1}async function _(){let e=q.composer.trim(),n=rd.value;if(!e||l.value||!n||!u.value||e.startsWith(`/`)&&await g(e))return;l.value=!0;let r=K.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:Lv();sessionStorage.setItem(`dpi.pending-send`,JSON.stringify({key:i,content:e,mode:t.value,requestId:o})),await kd(async()=>{await n.send(e,t.value,o),sessionStorage.removeItem(`dpi.pending-send`),q.composer=``}),l.value=!1}function v(e){kd(()=>rd.value.withdraw(e))}return(e,a)=>(F(),I(`div`,Kv,[k(pd).inbox.length?(F(),I(`div`,qv,[(F(!0),I(P,null,N(k(pd).inbox,e=>(F(),I(`div`,{key:e.id},[z(k(sc),{size:18}),R(`span`,null,D(e.mode===`steer`?`Steer`:`Queued`)+`: `+D(e.content??`Context update`),1),R(`button`,{class:`icon-button`,"aria-label":`Withdraw submission ${e.id}`,title:`Withdraw queued input`,onClick:t=>v(e.id)},[z(k(Sl),{size:18})],8,Jv)]))),128))])):V(``,!0),R(`div`,Yv,[p.value.length?(F(),I(`ul`,Xv,[(F(!0),I(P,null,N(p.value,(e,t)=>(F(),I(`li`,{key:e.name,role:`option`,"aria-selected":t===d.value,class:E({active:t===d.value}),onMousedown:As(t=>m(e),[`prevent`])},[R(`code`,null,`/`+D(e.name),1),e.args?(F(),I(`span`,Qv,D(e.args),1)):V(``,!0),R(`span`,$v,D(e.description),1)],42,Zv))),128))])):V(``,!0),A(R(`textarea`,{"onUpdate:modelValue":a[0]||=e=>k(q).composer=e,rows:`2`,placeholder:`Give your agent something to do, or type / for commands…`,"aria-label":`Message your agent`,onKeydown:h},null,544),[[bs,k(q).composer]]),R(`div`,ey,[R(`div`,ty,[R(`div`,ny,[R(`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},[z(k(Nc),{size:18})],8,ry),n.value?(F(),I(`div`,{key:0,class:`lib`,onClick:a[4]||=As(()=>{},[`stop`])},[R(`header`,null,[a[7]||=R(`b`,null,`Prompts`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close library`,onClick:a[2]||=e=>n.value=!1},[z(k(Sl),{size:14})])]),i.value.length?V(``,!0):(F(),I(`p`,iy,`Type something below, give it a name, save it.`)),R(`div`,ay,[A(R(`input`,{"onUpdate:modelValue":a[3]||=e=>r.value=e,placeholder:`name…`,onKeyup:Ms(s,[`enter`])},null,544),[[bs,r.value]]),R(`button`,{type:`button`,class:`small`,disabled:!k(q).composer.trim(),onClick:s},`save composer as`,8,oy)]),R(`ul`,null,[(F(!0),I(P,null,N(i.value,e=>(F(),I(`li`,{key:e.name},[R(`button`,{type:`button`,class:`use`,title:e.text,onClick:t=>(k(q).composer=e.text,n.value=!1)},[R(`b`,null,D(e.name),1)],8,sy),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Delete ${e.name}`,onClick:t=>c(e.name)},[z(k(hl),{size:13})],8,cy)]))),128))])])):V(``,!0)]),R(`div`,ly,[A(R(`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]||=[R(`option`,{value:`followUp`},`Follow-up`,-1),R(`option`,{value:`steer`},`Steer`,-1),R(`option`,{value:`reject`},`Reject if busy`,-1)]],512),[[Cs,t.value]]),z(k(rc),{size:24,"aria-hidden":`true`})])]),R(`div`,uy,[R(`button`,{class:`interrupt`,disabled:!k(_d)||k(Fd),title:`Stop foreground work and owned subagents (Escape). Background jobs continue.`,onClick:a[6]||=(...e)=>k(Id)&&k(Id)(...e)},[z(k(Hc),{size:24,class:`stop-sign`,fill:`currentColor`}),a[9]||=B(`Interrupt`,-1)],8,dy),R(`button`,{class:`send`,"aria-label":`Send message`,disabled:!k(q).composer.trim()||l.value||!u.value,onClick:_},[z(k(Ys),{size:20})],8,fy)])])]),a[10]||=R(`div`,{class:`composer-footnote`},[R(`span`,null,[R(`i`,{class:`live-dot`}),B(`Closing this window never interrupts your agent.`)])],-1)]))}}),[[`__scopeId`,`data-v-b2af49ae`]]),hy={class:`chat-panel`},gy={class:`chat-header`},_y={class:`lineage-picker`},vy={class:`lineage-toolbar`},yy=[`title`],by={class:`crumb-main`},xy={class:`device-chip`},Sy=[`title`],Cy={class:`crumb-main`},wy={class:`crumb-name`},Ty=[`aria-current`,`title`,`onClick`],Ey={class:`crumb-kind`},Dy={class:`crumb-main`},Oy={class:`crumb-name`},ky=[`disabled`],Ay=[`aria-expanded`],jy={key:0,class:`lineage-source`},My={id:`conversation-picker`,class:`conversation-picker`,role:`dialog`,"aria-label":`Choose conversation`},Ny=[`aria-label`,`aria-current`,`onClick`],Py={class:`conversation-choice-content`},Fy={class:`choice-lineage`},Iy={class:`choice-source`},Ly={key:0,class:`agent-stream-status`,role:`alert`},Ry=[`disabled`],zy={key:0,class:`chat-empty`},By={key:0},Vy={key:1},Hy={key:0,class:`chat-empty`},Uy={class:`starter-grid`},Wy={key:1,class:`entry live-generation`},Gy={class:`message-label`},Ky={class:`streaming`},qy={key:2,class:`hint retry-note`},Jy=M({__name:`AgentView`,setup(e){let t=O(),n=O(),r=O(!1),i=H(()=>pd.value.items),a=H(()=>i.value.some(e=>e.kind===`assistant`&&e.streaming)),o=H(()=>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=H(()=>md.value.map(e=>({...e,lineage:Xl(md.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=H(()=>hd.value.at(-1)),u=e=>e.kind===`root`?`agent`:e.kind;function d(){K.value&&(qu.tree=!0,cd(K.value.deviceId,!0))}function f(){let e=md.value.find(e=>e.kind===`root`)??md.value[0];e&&p(e.id)}function p(e){r.value=!1,K.value&&ad({...K.value,agentId:e})}function m(e){let t=rd.value,n=K.value;t&&n&&(q.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});ad({...n,agentId:i.id}),J(`Forked at entry #${e}. App State stays shared.`)}})}function h(){let e=rd.value,t=l.value;e&&t&&(q.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)})}j(K,()=>{r.value=!1});let g=!0;return j($u.version,()=>{let e=t.value;g=!e||e.scrollHeight-e.scrollTop-e.clientHeight<120},{flush:`pre`}),j($u.version,()=>{g&&jn(()=>t.value?.scrollTo({top:t.value.scrollHeight,behavior:`instant`}))}),j(()=>hd.value.length,()=>void jn(()=>n.value&&(n.value.scrollLeft=n.value.scrollWidth))),(e,g)=>(F(),I(`section`,hy,[R(`header`,gy,[R(`div`,_y,[R(`div`,vy,[R(`nav`,{ref_key:`lineageNav`,ref:n,class:`crumbs conversation-lineage`,"aria-label":`Conversation lineage`},[R(`button`,{class:`crumb`,title:`${k(Xu)?.name} · ${k(Xu)?.url}`,onClick:d},[g[5]||=R(`span`,{class:`crumb-kind`},`device`,-1),R(`span`,by,[z(mf,{device:k(Xu),size:18},null,8,[`device`]),R(`span`,xy,D(k(Xu)?.name??k(Xu)?.id),1)])],8,yy),z(k(ic),{class:`crumb-sep`,size:18,"aria-hidden":`true`}),R(`button`,{class:`crumb`,title:k(td)?.cwd,onClick:f},[g[6]||=R(`span`,{class:`crumb-kind`},`workspace`,-1),R(`span`,Cy,[z(k(bc),{size:18,"aria-hidden":`true`}),R(`span`,wy,D(k(td)?.name),1)])],8,Sy),k(td)?.cwd?(F(),L(Iv,{key:0})):V(``,!0),(F(!0),I(P,null,N(k(hd),e=>(F(),I(P,{key:e.id},[z(k(ic),{class:`crumb-sep`,size:18,"aria-hidden":`true`}),R(`button`,{class:E([`crumb`,{current:e.id===k(K)?.agentId}]),"aria-current":e.id===k(K)?.agentId?`page`:void 0,title:s(e),onClick:t=>p(e.id)},[R(`span`,Ey,D(u(e)),1),R(`span`,Dy,[e.kind===`fork`?(F(),L(k(wc),{key:0,size:18,"aria-hidden":`true`})):e.kind===`subagent`?(F(),L(k(lc),{key:1,size:18,"aria-hidden":`true`})):(F(),L(k(Rc),{key:2,size:18,"aria-hidden":`true`})),R(`span`,Oy,D(e.name),1)])],10,Ty)],64))),128))],512),R(`button`,{class:`icon-button`,"aria-label":`Rename agent`,title:`Rename this agent`,disabled:!l.value,onClick:h},[z(k(Jc),{size:18})],8,ky),R(`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},[z(k(rc),{size:18})],8,Ay)]),l.value&&l.value.kind!==`root`?(F(),I(`div`,jy,D(s(l.value)),1)):V(``,!0),r.value?(F(),I(P,{key:1},[R(`button`,{class:`conversation-menu-dismiss`,"aria-label":`Close conversation picker`,onClick:g[1]||=e=>r.value=!1}),R(`section`,My,[g[7]||=R(`div`,{class:`conversation-picker-heading`},`Roots & forks`,-1),(F(!0),I(P,null,N(c.value,e=>(F(),I(`button`,{key:e.id,class:E([`conversation-choice`,{selected:e.id===k(K)?.agentId}]),"aria-label":e.lineage.map(e=>e.name).join(` → `),"aria-current":e.id===k(K)?.agentId?`page`:void 0,onClick:t=>p(e.id)},[R(`div`,Py,[R(`span`,Fy,[(F(!0),I(P,null,N(e.lineage,(t,n)=>(F(),I(P,{key:t.id},[n?(F(),L(k(ic),{key:0,size:18,"aria-hidden":`true`})):V(``,!0),R(`span`,{class:E({"choice-ancestor":n<e.lineage.length-1})},D(t.name),3)],64))),128))]),R(`span`,Iy,D(s(e)),1)]),e.id===k(K)?.agentId?(F(),L(k(nc),{key:0,size:18,"aria-hidden":`true`})):e.kind===`fork`?(F(),L(k(wc),{key:1,size:18,"aria-hidden":`true`})):(F(),L(k(Rc),{key:2,size:18,"aria-hidden":`true`}))],10,Ny))),128))])],64)):V(``,!0)])]),k($u).fault.value||k($u).status.value===`fault`||k($u).status.value===`reconnecting`||k(pd).ready&&k($u).status.value===`connecting`?(F(),I(`div`,Ly,[R(`div`,null,[R(`strong`,null,D(k(pd).ready?`Cached transcript is stale.`:`Agent stream unavailable.`),1),R(`p`,null,D(k($u).fault.value||`Updates are paused while the stream reconnects.`),1),g[8]||=R(`p`,null,`Sending is paused until a fresh snapshot arrives. Your draft is kept.`,-1)]),R(`button`,{disabled:k($u).status.value===`connecting`,onClick:g[2]||=(...e)=>k($u).retry&&k($u).retry(...e)},` Retry stream `,8,Ry)])):V(``,!0),R(`div`,{ref_key:`chat`,ref:t,class:`chat-scroll`,"data-testid":`chat`},[k(pd).ready?(F(),I(P,{key:1},[i.value.length?V(``,!0):(F(),I(`div`,Hy,[g[13]||=R(`div`,{class:`agent-orb`},[R(`img`,{src:`/icons/durable-pi.svg`,alt:`Durable Pi`}),R(`i`)],-1),g[14]||=R(`span`,{class:`eyebrow`},`YOUR DURABLE AGENT IS READY`,-1),g[15]||=R(`h2`,null,`A conversation with continuity.`,-1),R(`p`,null,`Messages, tools and state live on `+D(k(Xu)?.id)+`, beyond this window.`,1),R(`div`,Uy,[R(`button`,{onClick:g[3]||=e=>k(Ad)(`Inspect this directory using your tools and give me a brief overview. Do not modify any files.`)},[z(k(bc),{size:18}),g[9]||=R(`strong`,null,`Explore this directory`,-1),g[10]||=R(`span`,null,`See coding tools in action`,-1),z(k(Js),{size:18})]),R(`button`,{onClick:g[4]||=e=>k(Ad)(`Use read_state, then update_state to add a field called progress with value 1 and a boolean called ready with value false.`)},[z(k($s),{size:18}),g[11]||=R(`strong`,null,`Make a state change`,-1),g[12]||=R(`span`,null,`Watch the workspace update`,-1),z(k(Js),{size:18})])])])),(F(!0),I(P,null,N(i.value,e=>(F(),L(kv,{key:e.id,item:e,onFork:m},null,8,[`item`]))),128)),k(pd).running&&!a.value&&!o.value?(F(),I(`div`,Wy,[R(`div`,Gy,[g[16]||=B(` AGENT `,-1),R(`span`,Ky,D(k(pd).retry?`Retry scheduled`:`Working`),1)]),g[17]||=R(`div`,{class:`typing`},[R(`i`),R(`i`),R(`i`)],-1)])):V(``,!0),k(pd).retry?(F(),I(`p`,qy,` Retrying: `+D(k(pd).retry.error),1)):V(``,!0),(F(!0),I(P,null,N(k(pd).notices,(e,t)=>(F(),I(`p`,{key:t,class:`message-error`},D(e),1))),128))],64)):(F(),I(`div`,zy,[z(k(Hs),{size:30}),k($u).status.value===`fault`?(F(),I(`h2`,By,`This agent is unavailable.`)):(F(),I(`h2`,Vy,`Connecting to the agent…`)),R(`p`,null,`The agent keeps working on `+D(k(Xu)?.id)+` while this view connects.`,1)]))],512),z(my)]))}});function Yy(e,t){return`${e}/${t.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`}function Xy(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 Zy(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 Qy(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`);Qy(r,t+1)}}}function $y(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=Xy(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(Qy(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(Zy,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}Qy(e),s?a[c?a.length:Number(i)]=e:a[i]=e}if(Qy(r),JSON.stringify(r).length>1e5)throw Error(`App State must be under 100,000 characters`);return r}var eb=[`data-state-path`],tb={key:0,class:`state-field-heading`},nb=[`value`,`aria-label`,`disabled`],rb=[`value`],ib=[`aria-label`,`disabled`],ab=[`aria-label`,`disabled`],ob=[`aria-label`,`disabled`],sb=[`value`],cb=[`disabled`],lb=[`disabled`,`aria-label`],ub={key:2,class:`state-number`},db=[`aria-label`,`disabled`],fb=[`aria-label`,`disabled`],pb=[`aria-label`,`disabled`],mb={key:3,class:`state-boolean`},hb=[`aria-label`,`aria-checked`,`disabled`],gb=[`aria-label`,`disabled`],_b={key:5,class:`muted`},vb=M({__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=H(()=>n.value===null?`null`:Array.isArray(n.value)?`array`:typeof n.value),a=H(()=>i.value===`object`||i.value===`array`),o=H(()=>a.value?Object.entries(n.value):[]),s=O(``),c=O(!1),l=O(``),u=O(`string`),d=O(!1),f=[`string`,`number`,`boolean`,`object`,`array`,`null`],p={string:()=>``,number:()=>0,boolean:()=>!1,object:()=>({}),array:()=>[],null:()=>null};j(()=>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:Yy(n.path,e),value:p[u.value]()}),l.value=``,d.value=!1)}return(t,n)=>{let _=Qr(`StateEditor`,!0);return F(),I(`div`,{class:E([`state-field`,{"state-root":e.path===``}]),"data-state-path":e.path},[e.path===``?V(``,!0):(F(),I(`div`,tb,[R(`strong`,null,D(e.label),1),R(`select`,{value:i.value,"aria-label":`Type of ${e.path}`,disabled:e.disabled,onChange:n[0]||=e=>m(`update`,p[e.target.value]())},[(F(),I(P,null,N(f,e=>R(`option`,{key:e,value:e},D(e),9,rb)),64))],40,nb),R(`button`,{class:`icon-button`,"aria-label":`Delete ${e.path}`,title:`Delete field`,disabled:e.disabled,onClick:n[1]||=e=>m(`delete`)},[z(k(hl),{size:18})],8,ib)])),a.value?(F(),I(P,{key:1},[(F(!0),I(P,null,N(o.value,([t,i])=>(F(),L(_,{key:t,value:i,path:k(Yy)(e.path,t),label:t,disabled:e.disabled,onChange:n[2]||=e=>r(`change`,e)},null,8,[`value`,`path`,`label`,`disabled`]))),128)),d.value?(F(),I(`form`,{key:0,class:`state-add`,onSubmit:As(g,[`prevent`])},[i.value===`array`?V(``,!0):A((F(),I(`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,ab)),[[bs,l.value]]),A(R(`select`,{"onUpdate:modelValue":n[4]||=e=>u.value=e,"aria-label":`New field type in ${e.path||`/`}`,disabled:e.disabled},[(F(),I(P,null,N(f,e=>R(`option`,{key:e,value:e},D(e),9,sb)),64))],8,ob),[[Cs,u.value]]),R(`button`,{class:`secondary small`,disabled:e.disabled||i.value!==`array`&&!l.value.trim()},` Add `,8,cb),R(`button`,{type:`button`,class:`text-button`,onClick:n[5]||=e=>d.value=!1},`Cancel`)],32)):(F(),I(`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},[z(k(Zc),{size:18}),B(D(i.value===`array`?`Add item`:`Add field`),1)],8,lb))],64)):i.value===`number`?(F(),I(`div`,ub,[R(`button`,{class:`secondary`,"aria-label":`Decrement ${e.path}`,disabled:e.disabled,onClick:n[7]||=e=>m(`increment`,-1)},[z(k(zc),{size:18})],8,db),A(R(`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]||=Ms(e=>e.target.blur(),[`enter`])},null,40,fb),[[bs,s.value]]),R(`button`,{class:`secondary`,"aria-label":`Increment ${e.path}`,disabled:e.disabled,onClick:n[11]||=e=>m(`increment`,1)},[z(k(Zc),{size:18})],8,pb)])):i.value===`boolean`?(F(),I(`div`,mb,[R(`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]||=[R(`span`,null,null,-1)]],10,hb),R(`span`,null,D(e.value),1)])):i.value===`string`?A((F(),I(`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,gb)),[[bs,s.value]]):(F(),I(`span`,_b,`null`))],10,eb)}}}),yb=[`data-status`],bb=[`title`],xb=[`title`],Sb=[`href`],Cb=[`title`],wb=M({__name:`TunnelStatusBar`,props:{device:{}},setup(e){let t=e,n=H(()=>t.device.status===`online`),r=H(()=>t.device.transport===`tunnel`),i=H(()=>n.value?r.value?`online · via tunnel`:`online · LAN`:r.value?`tunnel`:`LAN`),a=H(()=>t.device.tunnel?.state===`connected`);return(t,o)=>(F(),I(`span`,{class:`tunnel-status`,"data-status":e.device.status},[R(`span`,{class:`axis transport`,title:r.value?`Hub ⇄ device over the tunnel (WSS)`:`Hub → device over LAN`},[r.value?(F(),L(k(ec),{key:0,size:13,class:E({live:a.value})},null,8,[`class`])):(F(),L(k(yl),{key:1,size:13,class:E({live:n.value})},null,8,[`class`])),B(` `+D(i.value),1)],8,bb),R(`span`,{class:E([`axis monitor`,e.device.status])},[e.device.status===`offline`?(F(),L(k(vl),{key:0,size:13})):(F(),I(P,{key:1},[B(D(e.device.status),1)],64))],2),r.value&&a.value&&e.device.tunnel?(F(),I(`span`,{key:0,class:`axis muted`,title:`tunnel last seen ${k(Pd)(e.device.tunnel.lastSeenAt)}`},D(e.device.tunnel.readerCount)+` reader`+D(e.device.tunnel.readerCount===1?``:`s`),9,xb)):V(``,!0),e.device.url?(F(),I(`a`,{key:1,class:`axis url`,href:e.device.url,target:`_blank`,rel:`noreferrer`},D(e.device.url),9,Sb)):V(``,!0),e.device.lastSeenAt?(F(),I(`span`,{key:2,class:`axis muted`,title:`last probe ${k(Pd)(e.device.lastSeenAt)}`},D(k(Pd)(e.device.lastSeenAt)),9,Cb)):V(``,!0)],8,yb))}});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 Cl(e?.code??`internal`,e?.message??`${a.status} ${a.statusText}`,a.status)}return o}function Eb(e){return e.offerUrl??e.pairUrl}var Db={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)},Ob=0;function kb(){let e=++Ob,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`}},jb=e=>e===`issued`||e===`cancelled`||e===`expired`;async function Mb(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 Db.codeState(t,n.signal);if(e.closed())return;if(e.state=a,n.onState?.(a),jb(a.phase))return a;await new Promise(e=>setTimeout(e,r))}}var Nb={key:0,class:`token-manager`,"aria-label":`Credential manager`},Pb={class:`credential-fingerprint`},Fb=[`title`],Ib={key:0,class:`rotation-badge`,role:`status`},Lb={class:`token-actions`},Rb=[`disabled`],zb=[`disabled`],Bb={key:1,class:`message-error`,role:`alert`},Vb=M({__name:`TokenManager`,props:{device:{}},setup(e){let t=e,n=O(!1),r=O(``),i=H(()=>t.device.pairing);async function a(){if(!n.value){n.value=!0,r.value=``;try{await Db.rotate(t.device.id),J(`Rotation queued — it completes when the device acknowledges the new credential.`)}catch(e){r.value=G(e)}finally{n.value=!1}}}async function o(){n.value||(q.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 Db.revoke(t.device.id,`user`),J(`Revoke committed on the hub. The tunnel is cut; the device cleans up on its next contact.`)}})}return(e,t)=>i.value?(F(),I(`section`,Nb,[R(`header`,null,[z(k(Ac),{size:15}),t[0]||=R(`h3`,null,`Credential`,-1),R(`span`,{class:E([`pairing-status`,i.value.status])},D(i.value.status),3)]),R(`dl`,null,[t[1]||=R(`dt`,null,`Key fingerprint`,-1),R(`dd`,null,[R(`code`,Pb,D(i.value.keyFingerprint),1)]),t[2]||=R(`dt`,null,`Paired`,-1),R(`dd`,{title:new Date(i.value.pairedAt).toISOString()},D(k(Pd)(i.value.pairedAt)),9,Fb),t[3]||=R(`dt`,null,`Generation`,-1),R(`dd`,null,D(i.value.credentialGeneration),1)]),i.value.rotationPending?(F(),I(`p`,Ib,[z(k(el),{size:13,class:`spin`}),t[4]||=B(` rotation queued — waiting for the device to ACK `,-1)])):V(``,!0),R(`div`,Lb,[i.value.status===`paired`?(F(),I(`button`,{key:0,class:`small`,disabled:n.value||i.value.rotationPending,onClick:a},[z(k(el),{size:14}),t[5]||=B(` Rotate credential `,-1)],8,Rb)):V(``,!0),i.value.status===`paired`?(F(),I(`button`,{key:1,class:`small danger`,disabled:n.value,onClick:o},[z(k(ll),{size:14}),t[6]||=B(` Revoke `,-1)],8,zb)):V(``,!0)]),r.value?(F(),I(`p`,Bb,D(r.value),1)):V(``,!0)])):V(``,!0)}}),Hb={class:`tasks-panel`},Ub={class:`panel-heading`},Wb={class:`tag`},Gb={key:0,class:`message-error`,role:`alert`},Kb={class:`task-section`,"aria-label":`Durable jobs`},qb={key:0,class:`task-empty`},Jb=[`data-job`],Yb={class:`job-def-head`},Xb={key:0,class:`tag`},Zb={class:`tag`},Qb=[`aria-label`],$b=[`title`],ex={class:`job-def-meta`},tx=[`title`],nx=[`title`],rx={key:0,class:`job-def-last`},ix=[`onClick`],ax=[`disabled`,`onClick`],ox=[`disabled`,`onClick`],sx=[`disabled`,`onClick`],cx={class:`task-section`,"aria-label":`Agent activity`},lx={class:`panel-heading`},ux={key:0,class:`task-empty`},dx={key:1,class:`task-tree`},fx=[`data-task-kind`],px={class:`tag`},mx={key:0,class:`task-phase`},hx=[`onClick`],gx=[`disabled`],_x={class:`raw`},vx=M({__name:`TasksPanel`,setup(e){let t=O(``),n=O(!1),r=O([]),i=O(),a=e=>({running:`Running`,waiting:`Waiting`,completed:`Completed`,aborted:`Stopped`,declined:`Declined`,failed:`Failed`,pending:`Queued`,completing:`Finishing`,terminal:`Finished`})[e]??e,o=H(()=>new Map(h_.value.map(e=>[e.id,__.value.find(t=>t.job===e.id)]))),s=H(()=>{let e=gd.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:xl,name:e.label??`Tool call`,what:`tool call`}:e.kind===`pi.generation`?{icon:Qs,name:`Model response`,what:`generation`}:e.kind===`pi.compaction`?{icon:Mc,name:`Compaction`,what:`compaction`}:e.kind.startsWith(`demo.job.`)?{icon:bl,name:e.label??g_(e.kind.slice(9))?.title??e.kind,what:`durable job`}:e.kind===`demo.job-approval`?{icon:cl,name:`Approval`,what:`waits for you`}:{icon:Hs,name:e.label??e.kind,what:e.kind},l=e=>e.state.phase?e.kind.startsWith(`demo.job.`)?g_(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&&rd.value){n.value=!0,t.value=``;try{await rd.value.abort(!0)}catch(e){t.value=G(e)}finally{n.value=!1}}}async function d(e){let n=id.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=G(e)}}let f=H(()=>r.value.filter(e=>e.state.status===`terminal`).slice(-12).reverse());return(e,r)=>(F(),I(`div`,Hb,[R(`div`,Ub,[r[0]||=R(`h2`,null,`Tasks`,-1),R(`span`,Wb,D(k(gd).length)+` active`,1)]),t.value?(F(),I(`p`,Gb,D(t.value),1)):V(``,!0),R(`section`,Kb,[R(`h3`,null,[z(k(tl),{size:18}),r[1]||=B(`Durable jobs`,-1)]),r[2]||=R(`p`,{class:`hint`},[B(` 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 `),R(`code`,null,`list_durable_jobs`),B(`, starts them with `),R(`code`,null,`run_durable_job`),B(` and checks them with `),R(`code`,null,`check_durable_job`),B(`. Runs play out live in the chat. `)],-1),k(h_).length?V(``,!0):(F(),I(`p`,qb,` This device has no durable jobs. Deploy the latest backend to it. `)),(F(!0),I(P,null,N(k(h_),e=>(F(),I(`article`,{key:e.id,class:`job-def`,"data-job":e.id},[R(`div`,Yb,[z(k(bl),{size:18}),R(`strong`,null,D(e.title),1),e.approval?(F(),I(`span`,Xb,`needs approval`)):V(``,!0),R(`span`,Zb,`~`+D(e.seconds)+`s`,1)]),R(`p`,null,D(e.summary),1),R(`ol`,{class:`job-chain`,"aria-label":`${e.title} phases`},[(F(!0),I(P,null,N(e.phases,(e,t)=>(F(),I(`li`,{key:e.id,title:e.summary},[R(`span`,null,D(t+1),1),B(D(e.label),1),e.kind===`repeat`?(F(),L(k(tl),{key:0,size:13})):V(``,!0),e.kind===`approval`?(F(),L(k(cl),{key:1,size:13})):V(``,!0)],8,$b))),128))],8,Qb),R(`div`,ex,[(F(!0),I(P,null,N(e.inputs,e=>(F(),I(`code`,{key:e.name,title:e.description},D(e.name)+`=`+D(e.default),9,tx))),128)),R(`code`,{title:`Each run saves its result to App State ${e.resultPath}`},`→ `+D(e.resultPath),9,nx)]),o.value.get(e.id)?(F(),I(`div`,rx,[R(`span`,null,[B(`Run #`+D(o.value.get(e.id).run)+`: `,1),R(`strong`,null,D(a(o.value.get(e.id).status)),1),k(m_)(o.value.get(e.id))?V(``,!0):(F(),I(P,{key:0},[B(` in `+D(o.value.get(e.id).phases.find(t=>t.id===o.value.get(e.id).phase)?.label),1)],64))]),R(`button`,{class:`text-button`,onClick:t=>k(w_)(o.value.get(e.id).id)},` Show in chat `,8,ix),o.value.get(e.id).approval===`pending`?(F(),I(P,{key:0},[R(`button`,{class:`primary small`,disabled:!!k(S_),onClick:t=>k(E_)(o.value.get(e.id),!0)},` Approve `,8,ax),R(`button`,{class:`secondary`,disabled:!!k(S_),onClick:t=>k(E_)(o.value.get(e.id),!1)},` Decline `,8,ox)],64)):V(``,!0)])):V(``,!0),R(`button`,{class:`secondary job-def-run`,disabled:!!k(S_)||!k(rd),onClick:t=>k(T_)(e)},[z(k(Xc),{size:16}),B(`Run `+D(e.title),1)],8,sx)],8,Jb))),128))]),R(`section`,cx,[R(`div`,lx,[r[3]||=R(`h3`,null,`Agent activity`,-1),z(k(Hs),{size:18})]),r[5]||=R(`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?(F(),I(`ul`,dx,[(F(!0),I(P,null,N(s.value,({task:e,depth:t})=>(F(),I(`li`,{key:e.id,class:`task-row`,style:ge({"--depth":t}),"data-task-kind":e.kind},[(F(),L(ei(c(e).icon),{size:16})),R(`strong`,null,D(c(e).name),1),R(`span`,px,D(a(e.state.status)),1),l(e)?(F(),I(`span`,mx,D(l(e)),1)):V(``,!0),R(`small`,null,`#`+D(e.id)+` `+D(c(e).what)+`, agent #`+D(e.conversationId)+D(e.effectiveBackground?`, background`:``),1),(F(!0),I(P,null,N(e.conversations,e=>(F(),I(`button`,{key:e,class:`text-button`,onClick:t=>k(O_)(e)},` Open agent #`+D(e),9,hx))),128))],12,fx))),128))])):(F(),I(`p`,ux,`Nothing running. Send a message or run a job.`)),r[6]||=R(`p`,{class:`hint`},` Interrupt or Esc stops foreground work and what it owns. Stop all also stops background runs. `,-1),R(`button`,{class:`secondary danger`,disabled:!k(gd).length||n.value,onClick:u},[z(k(Hc),{size:18}),r[4]||=B(`Stop all `,-1)],8,gx)]),R(`details`,{class:`raw task-section`,onToggle:d},[R(`summary`,null,[z(k(sc),{size:18}),r[7]||=B(`Runtime details`,-1)]),r[9]||=R(`p`,{class:`hint`},` Recent task results and recovery records, read from the device when opened. `,-1),(F(!0),I(P,null,N(f.value,e=>(F(),I(`details`,{key:e.id,class:`raw`},[R(`summary`,null,[B(D(e.kind)+` #`+D(e.id),1),R(`span`,null,D(a(e.state.outcome?.status??e.state.status)),1)]),R(`pre`,null,D(JSON.stringify(e.state.outcome,null,2)),1)]))),128)),R(`details`,_x,[r[8]||=R(`summary`,null,`Recovery inspection`,-1),R(`pre`,null,D(JSON.stringify(i.value,null,2)),1)])],32)]))}}),yx={class:`git-pane`},bx={key:0,class:`hint`},xx={key:0,class:`hint`},Sx={key:1,class:`muted-line`},Cx={key:2,class:`message-error`},wx={class:`muted-line`},Tx={key:3,class:`message-error`},Ex={key:0,class:`hint`},Dx={key:0,class:`message-error merge-banner`},Ox=[`disabled`],kx={class:`panel-heading git-top`},Ax={class:`branch-wrap`},jx=[`disabled`],Mx={key:0,class:`menu`},Nx=[`onClick`],Px={class:`muted-line`},Fx={class:`new-branch`},Ix=[`disabled`],Lx={class:`auto-stash`},Rx={class:`tag`},zx={key:0,class:`tag`},Bx={key:1,class:`tag`},Vx={key:2,class:`tag`,title:`vs the picked base`},Hx={class:`tag`},Ux=[`href`],Wx=[`disabled`],Gx={class:`row ops`},Kx=[`disabled`],qx=[`disabled`],Jx=[`disabled`],Yx=[`disabled`],Xx=[`disabled`],Zx={key:1,class:`message-error hintbox`},Qx=[`disabled`],$x=[`disabled`],eS={key:2,class:`message-error hintbox`},tS=[`disabled`],nS={class:`task-section`,"aria-label":`Commit`},rS={class:`panel-heading`},iS={class:`tag`},aS=[`disabled`],oS=[`disabled`],sS={key:0,class:`hintbox warn`},cS={key:1,class:`cps turns`},lS={key:0,class:`hint`},uS={class:`muted-line`},dS={class:`cp-subj`},fS={key:2,class:`muted-line cap`},pS={key:3,class:`files conflicts`},mS={class:`file all`},hS={class:`muted-line conflict-head`},gS={class:`file-label`},_S={class:`xy`},vS=[`title`],yS={class:`file-acts`},bS=[`onClick`],xS=[`disabled`,`onClick`],SS=[`disabled`,`onClick`],CS={key:4,class:`files`},wS={class:`file all`},TS=[`checked`],ES={class:`muted-line`},DS=[`onClick`],OS={class:`muted-line`},kS={class:`file-label`},AS=[`checked`,`onChange`],jS=[`title`],MS=[`title`],NS={class:`file-acts`},PS=[`onClick`],FS=[`onClick`],IS=[`onClick`],LS={key:5,class:`files`},RS={class:`file all`},zS=[`checked`],BS={class:`muted-line`},VS=[`onClick`],HS={class:`muted-line`},US={class:`file-label`},WS=[`checked`,`onChange`],GS=[`title`],KS=[`title`],qS={class:`file-acts`},JS=[`onClick`],YS=[`onClick`],XS=[`onClick`],ZS=[`onClick`],QS=[`onClick`],$S={key:6,class:`file-diff`},eC={class:`mode-chips`},tC={key:0,class:`nums bin`},nC={key:1,class:`nums`},rC={key:2},iC={class:`row`},aC=[`disabled`],oC=[`disabled`],sC=[`disabled`],cC={class:`task-section`,"aria-label":`Log`},lC={class:`panel-heading`},uC=[`disabled`],dC=[`disabled`],fC=[`disabled`],pC={key:0,class:`cps`},mC={key:0,class:`hint`},hC={class:`muted-line`},gC={class:`cp-subj`},_C=[`disabled`,`onClick`],vC={key:1,class:`hint`},yC={key:2,class:`commits`},bC=[`title`],xC=[`width`],SC=[`x1`,`x2`],CC=[`x1`,`x2`,`stroke`],wC=[`cx`,`fill`],TC=[`onClick`],EC={class:`hash`},DC=[`href`],OC={key:1,class:`refs`},kC={class:`subject`},AC={class:`muted-line who`},jC={key:0,class:`commit-files`},MC=[`data-s`],NC={class:`path`},PC={key:0,class:`hint`},FC={key:3,class:`message-error`},IC={key:4,class:`hint`},LC={class:`task-section`,"aria-label":`Worktrees`},RC={class:`panel-heading`},zC={class:`branch-wrap`},BC=[`disabled`],VC={key:0,class:`menu`},HC=[`onClick`],UC={class:`new-branch`},WC=[`disabled`],GC=[`title`],KC={class:`muted-line`},qC=[`disabled`,`onClick`],JC=[`disabled`,`onClick`],YC=[`disabled`,`onClick`],XC={key:3,class:`task-section`,"aria-label":`Pull requests`},ZC={class:`panel-heading`},QC=[`disabled`],$C=[`disabled`],ew={key:0,class:`hint`},tw={key:1,class:`commits`},nw={class:`hash`},rw={class:`subject`},iw={class:`muted-line who`},aw=[`disabled`,`onClick`],ow=[`disabled`,`onClick`],sw=[`disabled`,`onClick`],cw=[`href`],lw={key:4,class:`op-out`},uw=[`placeholder`],dw={class:`row`},fw=[`disabled`],pw=sf(M({__name:`GitPanel`,props:{deviceId:{},cwd:{}},setup(e){let t=e,n=H(()=>t.cwd??td.value?.cwd??``),r=H(()=>t.deviceId??Yu.value),i=H(()=>Df(r.value||`?`,n.value||`?`)),a=H(()=>i.value.status),o=H(()=>i.value.loading),s=H(()=>String(Hu.devices.value.find(e=>e.id===r.value)?.info?.platform??``).startsWith(`win32`)),c=H(()=>{let e=i.value;if(!e.error||!/start dirs/i.test(e.error))return``;let t=Hu.devices.value.find(e=>e.id===r.value)?.info?.startDirs;return Array.isArray(t)&&t.length?t.map(String).join(`, `):``}),l=H(()=>i.value.refreshing),u=H(()=>i.value.error),d=H(()=>{let e=td.value;return e&&e.cwd===n.value&&!t.deviceId?e.id:void 0}),f=O(``),p=O(``),m=O(``),h=O(new Set),g=O(!1),_=O(!1),v=O(``),y=O(null),b=O(`working`),x=H(()=>`dpi-git-draft:${r.value}:${n.value}`),S=O(null),C=O(!0),ee=O(``),w=O(!1),te=O([]),ne=H(()=>{if(!te.value.length||!n.value)return null;let e=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,t=new Set(te.value);return{changed:(a.value?.files??[]).filter(n=>t.has(e(n.path))).length,total:te.value.length}}),re=O(null),ie=O(``),ae=e=>{ie.value=e.input?.value??``,re.value=e},oe=()=>{let e=re.value;re.value=null,e&&e.action(ie.value)};window.addEventListener(`keydown`,e=>{e.key===`Escape`&&re.value&&(re.value=null)});let se=O([]),ce=O(!1),le=O(new Map),T=O([]),ue=O(!1),de=O(new Map),fe=O(!1),pe=H(()=>/github\.com|gitlab/i.test(a.value?.remoteUrl??``)),me=async()=>{if(!r.value||!n.value)return;let e=bf(r.value,n.value);if(!e.ok){T.value=[],J(`pull requests unavailable: ${e.reason}`);return}fe.value=!0;try{let e=await W(r.value).gitOp(n.value,`pr-list`);T.value=e.prs??[]}catch(e){J(`pr list failed: ${e.message.slice(0,120)}`)}finally{fe.value=!1}};j(ue,e=>{e&&me()});let he=()=>ae({title:`Create pull request`,body:`head: ${a.value?.branch??`?`}`,confirmLabel:`Create PR`,input:{placeholder:`PR title`,value:m.value.trim()||``},action:e=>void ge(e)});async function ge(e){if(r.value&&n.value&&e.trim()){fe.value=!0;try{J((await W(r.value).gitOp(n.value,`pr-create`,{message:e.trim(),body:e.trim()})).text.split(`
78
+ `)[0]??`PR created`),await me()}catch(e){J(`pr create failed: ${e.message.slice(0,140)}`)}finally{fe.value=!1}}}async function _e(e){if(r.value&&n.value){fe.value=!0;try{let t=await W(r.value).gitOp(n.value,`pr-checks`,{n:e});de.value=new Map(de.value).set(e,t.text.slice(0,1500))}catch(e){J(`pr checks failed: ${e.message.slice(0,120)}`)}finally{fe.value=!1}}}let ve=e=>ae({title:`Merge PR #${e}?`,body:`squash-merge via gh on the device.`,confirmLabel:`Squash & merge`,danger:!0,action:()=>void ye(e)});async function ye(e){if(r.value&&n.value){fe.value=!0;try{J((await W(r.value).gitOp(n.value,`pr-merge`,{n:e})).text||`PR #${e} merged`),await me(),await Oe()}catch(e){J(`pr merge failed: ${e.message.slice(0,140)}`)}finally{fe.value=!1}}}let be=e=>ae({title:`Comment on PR #${e}`,body:`posted as the device's gh login`,confirmLabel:`Comment`,input:{placeholder:`comment…`,value:``},action:t=>void xe(e,t)});async function xe(e,t){if(r.value&&n.value&&t.trim()){fe.value=!0;try{J((await W(r.value).gitOp(n.value,`pr-comment`,{n:e,body:t.trim()})).text||`comment posted`)}catch(e){J(`pr comment failed: ${e.message.slice(0,140)}`)}finally{fe.value=!1}}}let Se=O([]),Ce=O(!1),we=async()=>{if(r.value&&d.value)try{let e=await W(r.value).sessionGitTurns(d.value);Se.value=e.turns}catch{Se.value=[]}};j(Ce,e=>{e&&we()});let Te=0;window.addEventListener(`focus`,()=>{!n.value||Date.now()-Te<15e3||(Te=Date.now(),kf(r.value||`?`,n.value||`?`,{force:!0}))});let Ee=O(new Set),De=()=>{typeof localStorage<`u`&&(m.value=localStorage.getItem(x.value)??``)};Tf(),kf(r.value||`?`,n.value||`?`),De(),qr(()=>kf(r.value||`?`,n.value||`?`)),j(m,e=>{typeof localStorage<`u`&&(e?localStorage.setItem(x.value,e):localStorage.removeItem(x.value))}),j([r,n],()=>{g.value=!1,_.value=!1,y.value=null,S.value=null,ee.value=``,w.value=!1,te.value=[],le.value=new Map,Ee.value=new Set,kf(r.value||`?`,n.value||`?`),De()});let Oe=()=>(h.value=new Set,y.value=null,kf(r.value||`?`,n.value||`?`,{force:!0})),ke=H(()=>a.value?.files??[]);j(ke,e=>{let t=new Set;for(let n of e)n.x!==`?`&&n.y!==`?`&&t.add(n.path);h.value=t},{immediate:!0});let Ae=H(()=>ke.value.some(e=>h.value.has(e.path))),je=H(()=>ke.value.filter(e=>!Ne(e)&&e.x!==` `&&e.x!==`?`)),Me=H(()=>ke.value.filter(e=>!Ne(e)&&(e.x===` `||e.x===`?`))),Ne=e=>`UAD`.includes(e.x)&&`UAD`.includes(e.y),Pe=H(()=>ke.value.filter(Ne)),Fe=H(()=>ke.value.length>=500),Ie=H(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0)>0),Le=H(()=>!a.value?.identity?.name||!a.value?.identity?.email),Re=H(()=>{let e=a.value?.remoteUrl??``,t=e.match(/git@([^:]+):(.+?)(?:\.git)?$/)??e.match(/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/);return t?`https://${t[1]}/${t[2]}`:``}),ze=e=>{let t=new Set(h.value);t.has(e)?t.delete(e):t.add(e),h.value=t},Be=e=>{let t=e.every(e=>h.value.has(e.path)),n=new Set(h.value);for(let r of e)t?n.delete(r.path):n.add(r.path);h.value=n},Ve=e=>{let t=e.lastIndexOf(`/`);return t===-1?`.`:e.slice(0,t)},He=e=>{let t=new Map;for(let n of e){let e=Ve(n.path);t.has(e)||t.set(e,[]),t.get(e).push(n)}return[...t.entries()].map(([e,t])=>({dir:e,files:t,open:!Ee.value.has(e)}))},Ue=e=>{let t=new Set(Ee.value);t.has(e)?t.delete(e):t.add(e),Ee.value=t},We=e=>e.a===void 0&&e.d===void 0?``:e.a===-1||e.d===-1?`bin`:`+${e.a??0} −${e.d??0}`,Ge=e=>{navigator.clipboard?.writeText(e).then(()=>J(`copied ${e}`))};async function Ke(e,t={}){if(!r.value||!n.value)return;let i=bf(r.value,n.value);if(!i.ok){J(`git ${e} skipped: ${i.reason}`);return}f.value=e,p.value=``;try{let i=await W(r.value).gitOp(n.value,e,t);p.value=i.text||`(empty)`,e===`push`&&(ee.value=``),e===`pull`&&(w.value=!1),[`fetch`,`pull`,`push`,`stash-push`,`stash-pop`].includes(e)&&J(`git ${e} ✓`),await Oe(),xt(!0)}catch(t){let n=t.message;e===`push`&&(/no upstream|has no upstream|upstream is gone/i.test(n)?ee.value=`no upstream — set it while pushing?`:/fetch first|non-fast-forward|rejected.*fetch|behind/i.test(n)?ee.value=`the remote has work you lack — pull first`:/authentication|permission|could not read|403|denied/i.test(n)?ee.value=`credentials rejected on the device — check its git login`:ee.value=``),e===`pull`&&/not possible to fast-forward|divergent|unrelated histories/i.test(n)&&(w.value=!0),J(`git ${e}: ${n.slice(0,160)}`)}finally{f.value=``}}async function qe(e,t,i=!1){if(!r.value||!n.value||(i&&(f.value=e),!t&&e!==`stage`))return;if(e===`discard`&&t&&!i){ae({title:`Roll back to HEAD?`,body:`${t} — uncommitted changes are lost.`,confirmLabel:`Roll back`,danger:!0,action:()=>void qe(e,t,!0)});return}f.value=e;let a=t?[t]:ke.value.filter(e=>e.x===` `||e.x===`M`).map(e=>e.path);try{J((await W(r.value).gitOp(n.value,e,{files:a})).text),await Oe()}catch(t){J(`${e} failed: ${t.message.slice(0,140)}`)}finally{f.value=``}}async function Je(e){if(r.value&&n.value&&e.length){f.value=`unstage`;try{J((await W(r.value).gitOp(n.value,`unstage`,{files:e})).text),await Oe()}catch(e){J(`unstage failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}}async function Ye(e,t){if(r.value&&n.value){f.value=`resolve`;try{J((await W(r.value).gitOp(n.value,`resolve`,{side:e,files:[t]})).text),await Oe()}catch(e){J(`resolve failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}}async function Xe(e){if(r.value&&n.value&&e.length){f.value=`ignore`;try{J((await W(r.value).gitOp(n.value,`ignore`,{lines:e})).text),await Oe()}catch(e){J(`ignore failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}}async function Ze(e){if(r.value&&n.value){if(y.value?.path===e)return y.value=null;f.value=`diff`;try{let t=await W(r.value).gitOp(n.value,`diff-file`,{target:e,staged:b.value===`staged`});y.value={path:e,text:t.text}}catch(e){J(`diff failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}}let Qe=async()=>{let e=y.value?.path;y.value=null,e&&await Ze(e)},$e=H(()=>/Binary files .* differ/i.test(y.value?.text??``));async function et(){if(r.value&&n.value){f.value=`abort`;try{J((await W(r.value).gitOp(n.value,`merge-abort`)).text),await Oe()}catch(e){J(`abort failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}}async function tt(e){if(g.value=!1,r.value&&n.value){f.value=`compare`;try{let t=await W(r.value).gitOp(n.value,`compare`,{ref:e});S.value={ref:e,ahead:t.ahead??0,behind:t.behind??0}}catch(e){J(`compare failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}}async function nt(e,t=!1){if(g.value=!1,!r.value||!n.value||e===a.value?.branch&&!t)return;f.value=`switch`;let i=W(r.value),o=!1;try{if(C.value&&!t&&Ie.value&&(await i.gitOp(n.value,`stash-push`,{message:`dpi auto-stash before ${e}`}),o=!0),J((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)&&J(`stash popped WITH CONFLICTS — resolve in the file list`)}catch{J(`switched, but the stash did not pop — resolve manually (git stash list)`)}await Oe(),xt(!0)}catch(e){if(J(`switch failed: ${e.message.slice(0,140)}`),o)try{await i.gitOp(n.value,`stash-pop`)}catch{}}finally{f.value=``}}async function rt(e=!1){if(!r.value||!n.value||!m.value.trim())return;f.value=`commit`;let t=ke.value.filter(e=>h.value.has(e.path)).map(e=>e.path);if(!t.length)return J(`check the files to commit — nothing is selected`);let i=W(r.value);try{if(J((await i.gitOp(n.value,`commit`,{message:m.value.trim(),...a.value?.merge?{}:{files:t}})).text),m.value=``,e)try{J(`pushed: ${(await i.gitOp(n.value,`push`)).text.slice(0,80)}`)}catch(e){J(`committed, but push failed: ${e.message.slice(0,120)}`)}await Oe(),xt(!0)}catch(e){J(`commit failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}function it(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 at(){if(!r.value||!n.value)return;let e=ke.value.filter(e=>h.value.has(e.path)).map(e=>e.path);if(!e.length)return J(`check files first — the model summarises THOSE`);f.value=`ai`;let t=W(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=Hu.devices.value.find(e=>e.id===r.value)?.info,s=it(o);if(!s.length)return f.value=``,J(`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(`
79
+ `)[0]?.slice(0,100):``;if(i){m.value=i;return}c.push(`${e.provider}/${e.id}: ${n.status===`unanswered`?n.reason:`empty answer`}`)}finally{t.session(r).archive().catch(()=>{})}}J(`ai message failed on every model — ${c.join(`; `).slice(0,140)}`)}catch(e){J(`ai message failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}async function ot(){if(r.value&&d.value){f.value=`session-files`;try{let e=await W(r.value).sessionGitFiles(d.value);te.value=e.files;let t=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,i=new Set(e.files.map(t)),a=ke.value.filter(e=>i.has(t(e.path)));h.value=new Set(a.map(e=>e.path)),J(a.length?`${a.length} session file(s) still changed — checked`:`the session touched nothing that is still changed`)}catch(e){J(`session files failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}}async function st(e){if(le.value.has(e)){le.value.delete(e),le.value=new Map(le.value);return}if(r.value&&n.value)try{let t=await W(r.value).gitOp(n.value,`show-files`,{target:e});le.value=new Map(le.value).set(e,t.changed??[])}catch(e){J(`commit files failed: ${e.message.slice(0,120)}`)}}async function ct(){if(!r.value||!n.value)return;let e=`cp-${new Date().toISOString().slice(0,16).replace(/[-:T]/g,``)}`;f.value=`checkpoint`;try{J((await W(r.value).gitOp(n.value,`checkpoint`,{name:e})).text),ce.value=!0,await lt()}catch(e){J(`checkpoint failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}async function lt(){if(r.value&&n.value)try{let e=await W(r.value).gitOp(n.value,`checkpoints`);se.value=e.checkpoints??[]}catch{se.value=[]}}async function ut(e){if(!r.value||!n.value)return;let t=e;ae({title:`Rewind to ${t}?`,body:`reset --hard — ALL uncommitted changes in this worktree are LOST.`,confirmLabel:`Rewind`,danger:!0,action:()=>void dt(t)})}async function dt(e){if(r.value&&n.value){f.value=`rewind`;try{J((await W(r.value).gitOp(n.value,`rewind`,{name:e})).text),await Oe(),xt(!0)}catch(e){J(`rewind failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}}j(ce,e=>{e&&lt()});async function ft(e){if(_.value=!1,r.value&&n.value&&a.value?.root){f.value=`wt`;try{J((await wp(W(r.value),n.value,a.value.root,e)).text),v.value=``,await Oe()}catch(e){J(`worktree failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}}async function pt(e,t){if(r.value){f.value=`session`;try{let n=Hu.devices.value.find(e=>e.id===r.value)?.info,i=it(n)[0];if(!i)return J(`no model available on ${r.value} — cannot create a session`);let a=await Tp(W(r.value),e,t??e.slice(e.lastIndexOf(`/`)+1),{provider:i.provider,modelId:i.id});ad({deviceId:r.value,sessionId:a.id,agentId:1}),J(`session "${a.name}" on ${e}`)}catch(e){J(`session failed: ${e.message.slice(0,160)}`)}finally{f.value=``}}}async function mt(e){if(r.value){f.value=`go`;try{let t=(await W(r.value).sessions()).find(t=>t.cwd===e);t?(ad({deviceId:r.value,sessionId:t.id,agentId:1}),J(`switched to session "${t.name}"`)):await pt(e,null)}catch(e){J(`switch failed: ${e.message.slice(0,120)}`)}finally{f.value=``}}}async function ht(e){if(!r.value||!n.value)return;f.value=`wt`;let t=`Uncommitted changes in it will be LOST.`;try{let n=(await W(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{}ae({title:`Remove worktree?`,body:`${e} — ${t}`,confirmLabel:`Remove`,danger:!0,action:()=>void gt(e)})}async function gt(e){f.value=`wt`;try{await W(r.value).gitOp(n.value,`worktree-remove`,{target:e}),await Oe()}catch(e){J(`remove failed: ${e.message.slice(0,140)}`)}finally{f.value=``}}let _t=O([]),vt=O(!1),yt=O(``),bt=0;async function xt(e=!1){if(!r.value||!n.value||!e&&_t.value.length&&Date.now()-bt<12e4)return;let t=bf(r.value,n.value);if(!t.ok){_t.value=[],yt.value=t.reason,bt=Date.now();return}vt.value=!0;try{let e=await W(r.value).gitOp(n.value,`log-list`);_t.value=e.commits??[],yt.value=``,bt=Date.now()}catch(e){yt.value=e.message.slice(0,120)}finally{vt.value=!1}}xt(),j([r,n],()=>{_t.value=[],bt=0,xt()});let St=H(()=>(a.value?.worktrees??[]).filter(e=>e.path)),Ct=[`#4f8cc9`,`#b8860b`,`#7aa25c`,`#a061ba`,`#c96f6f`,`#5fa8a0`],wt=H(()=>{let e=new Map,t=[],n=[];for(let r of _t.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}),Tt=e=>e*12+7;return(e,t)=>(F(),I(`div`,yx,[n.value?(F(),I(P,{key:1},[o.value?(F(),I(`p`,xx,`loading git…`)):l.value?(F(),I(`p`,Sx,`refreshing…`)):V(``,!0),c.value?(F(),I(`div`,Cx,[R(`p`,null,[R(`strong`,null,D(n.value),1),t[41]||=B(` is outside the folders this device serves — it serves `,-1),R(`code`,null,D(c.value),1),t[42]||=B(`. `,-1)]),t[43]||=R(`p`,{class:`muted-line`},[B(` Your session and its history are intact, and the agent still runs in that folder; only the Git and Files panels (the device's HTTP surface) are confined. Nothing has to be recreated: add the folder to `),R(`code`,null,`DPI_START_DIRS`),B(` and restart the device, and this panel works again for the same session. `)],-1),R(`p`,wx,[B(` Example (`+D(s.value?`Windows: separate with ;`:`Linux/macOS: separate with :`)+`) — `,1),R(`code`,null,D(s.value?`setx DPI_START_DIRS "%USERPROFILE%\\dpi-work;D:\\source"`:`DPI_START_DIRS="$HOME/dpi-work:/srv/src"`),1)])])):u.value?(F(),I(`p`,Tx,[B(D(u.value)+` `,1),R(`button`,{onClick:t[0]||=e=>Oe()},`retry`)])):V(``,!0),a.value?(F(),I(`div`,{key:4,class:E({stale:!!u.value||!!l.value})},[a.value.repo?(F(),I(P,{key:1},[a.value.merge?(F(),I(`p`,Dx,[B(` merge in progress — `+D(a.value.conflicts??Pe.value.length)+` unmerged path(s). Resolve them in the lists above, or `,1),R(`button`,{class:`small`,disabled:!!f.value,onClick:t[1]||=e=>et()},`abort merge`,8,Ox)])):V(``,!0),R(`div`,kx,[R(`div`,Ax,[R(`button`,{class:`branch-btn`,disabled:!!f.value,onClick:t[2]||=e=>g.value=!g.value},[z(k(Sc),{size:16}),R(`strong`,null,D(a.value.branch??`detached`),1),z(k(rc),{size:14})],8,jx),g.value?(F(),I(`div`,Mx,[(F(!0),I(P,null,N(a.value.branches??[],e=>(F(),I(`button`,{key:e.name,class:E({cur:e.current}),onClick:t=>nt(e.name)},[z(k(Sc),{size:13}),R(`span`,null,D(e.name),1),R(`span`,Px,D(e.current?`current`:e.upstream?`→ ${e.upstream}`:``),1),t[45]||=R(`span`,{class:`grow`},null,-1),e.current?V(``,!0):(F(),L(k(Cc),{key:0,size:13,title:`compare with this base`,onClick:As(t=>tt(e.name),[`stop`])},null,8,[`onClick`]))],10,Nx))),128)),R(`div`,Fx,[A(R(`input`,{"onUpdate:modelValue":t[3]||=e=>v.value=e,placeholder:`new branch…`,onKeyup:t[4]||=Ms(e=>v.value.trim()&&nt(v.value.trim(),!0),[`enter`])},null,544),[[bs,v.value]]),R(`button`,{disabled:!v.value.trim(),onClick:t[5]||=e=>nt(v.value.trim(),!0)},[z(k(Zc),{size:13})],8,Ix)]),R(`label`,Lx,[A(R(`input`,{type:`checkbox`,"onUpdate:modelValue":t[6]||=e=>C.value=e},null,512),[[xs,C.value]]),t[46]||=B(` auto-stash on switch`,-1)])])):V(``,!0)]),R(`span`,Rx,D(a.value.upstream??`no upstream`),1),a.value.ahead?(F(),I(`span`,zx,`↑`+D(a.value.ahead),1)):V(``,!0),a.value.behind?(F(),I(`span`,Bx,`↓`+D(a.value.behind),1)):V(``,!0),S.value?(F(),I(`span`,Vx,[B(` vs `+D(S.value.ref)+`: ↑`+D(S.value.ahead)+` ↓`+D(S.value.behind)+` `,1),R(`button`,{class:`tag-x`,onClick:t[7]||=e=>S.value=null},[z(k(Sl),{size:11})])])):V(``,!0),R(`span`,Hx,`+`+D(a.value.staged??0)+` ~`+D(a.value.unstaged??0)+` ?`+D(a.value.untracked??0),1),Re.value?(F(),I(`a`,{key:3,class:`icon-button`,href:`${Re.value}/tree/${a.value.branch??``}`,target:`_blank`,rel:`noopener`,title:`open on the remote`},[z(k(qs),{size:15,style:{transform:`rotate(45deg)`}})],8,Ux)):V(``,!0),R(`button`,{class:`icon-button`,disabled:!!f.value||o.value||l.value,title:`refresh`,onClick:t[8]||=e=>Oe()},[z(k(el),{size:16})],8,Wx)]),R(`div`,Gx,[R(`button`,{class:`small`,disabled:!!f.value,onClick:t[9]||=e=>Ke(`fetch`)},[z(k(Gs),{size:14}),t[47]||=B(`fetch`,-1)],8,Kx),R(`button`,{class:`small`,disabled:!!f.value,onClick:t[10]||=e=>Ke(`pull`)},[z(k(Gs),{size:14}),t[48]||=B(`pull`,-1)],8,qx),R(`button`,{class:`small primary`,disabled:!!f.value,title:`push`,onClick:t[11]||=e=>Ke(`push`)},[z(k(qs),{size:14}),t[49]||=B(`push`,-1)],8,Jx),R(`button`,{class:`small`,disabled:!!f.value,title:`stash changes`,onClick:t[12]||=e=>Ke(`stash-push`,{message:m.value.trim()||void 0})},[z(k(fl),{size:14}),t[50]||=B(`stash`,-1)],8,Yx),R(`button`,{class:`small`,disabled:!!f.value,title:`pop the newest stash`,onClick:t[13]||=e=>Ke(`stash-pop`)},[z(k(Uc),{size:14}),t[51]||=B(`unstash`,-1)],8,Xx)]),ee.value?(F(),I(`p`,Zx,[B(D(ee.value)+` `,1),ee.value.includes(`upstream`)?(F(),I(`button`,{key:0,class:`small primary`,disabled:!!f.value,onClick:t[14]||=e=>Ke(`push`,{setUpstream:!0,ref:a.value.branch})},`push -u origin `+D(a.value.branch),9,Qx)):ee.value.includes(`remote has work`)?(F(),I(`button`,{key:1,class:`small primary`,disabled:!!f.value,onClick:t[15]||=e=>Ke(`pull`)},`pull now`,8,$x)):V(``,!0)])):V(``,!0),w.value?(F(),I(`p`,eS,[t[52]||=B(` fast-forward is not possible — branches diverged. `,-1),R(`button`,{class:`small primary`,disabled:!!f.value,onClick:t[16]||=e=>Ke(`pull`,{rebase:!0})},`pull --rebase`,8,tS)])):V(``,!0),R(`section`,nS,[R(`div`,rS,[t[53]||=R(`h4`,null,`Commit`,-1),R(`span`,iS,D(ke.value.length?`${h.value.size}/${ke.value.length} files`:`no changes`),1),t[54]||=R(`span`,{class:`grow`},null,-1),d.value?(F(),I(`button`,{key:0,class:`small`,disabled:!!f.value,title:`check the files this session's agent touched`,onClick:ot},[z(k(vc),{size:13}),B(` session files`+D(ne.value?` (${ne.value.changed}/${ne.value.total})`:``),1)],8,aS)):V(``,!0),d.value?(F(),I(`button`,{key:1,class:`small`,disabled:!!f.value,title:`what each turn of this session changed`,onClick:t[17]||=e=>Ce.value=!Ce.value},` turns `,8,oS)):V(``,!0)]),Le.value?(F(),I(`p`,sS,[...t[55]||=[B(`git user.name/user.email is not set on the device — `,-1),R(`code`,null,`dpi device config`,-1),B(` or `,-1),R(`code`,null,`git config --global`,-1),B(` before committing.`,-1)]])):V(``,!0),Ce.value?(F(),I(`div`,cS,[Se.value.length?V(``,!0):(F(),I(`p`,lS,`no turns recorded yet for this session.`)),(F(!0),I(P,null,N(Se.value,(e,t)=>(F(),I(`div`,{key:t,class:`cp-row`},[R(`code`,null,`t`+D(Se.value.length-t),1),R(`span`,uS,D(e.when.slice(0,16).replace(`T`,` `)),1),R(`span`,dS,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))])):V(``,!0),Fe.value?(F(),I(`p`,fS,`showing the first 500 changed files — commit in smaller batches`)):V(``,!0),Pe.value.length?(F(),I(`div`,pS,[R(`label`,mS,[R(`span`,hS,`Conflicts · `+D(Pe.value.length)+` — pick a side per file`,1)]),(F(!0),I(P,null,N(Pe.value,e=>(F(),I(`div`,{key:e.path,class:`file`},[R(`label`,gS,[R(`code`,_S,D(e.x)+D(e.y),1),R(`span`,{class:`path`,title:e.path},D(e.path),9,vS)]),R(`span`,yS,[R(`button`,{class:`icon-button`,title:`view the conflict`,onClick:t=>Ze(e.path)},[z(k(gc),{size:13})],8,bS),R(`button`,{class:`small`,disabled:!!f.value,title:`keep this branch's version and stage it`,onClick:t=>Ye(`ours`,e.path)},`ours`,8,xS),R(`button`,{class:`small`,disabled:!!f.value,title:`take the incoming version and stage it`,onClick:t=>Ye(`theirs`,e.path)},`theirs`,8,SS)])]))),128))])):V(``,!0),je.value.length?(F(),I(`div`,CS,[R(`label`,wS,[R(`input`,{type:`checkbox`,checked:je.value.every(e=>h.value.has(e.path)),onChange:t[18]||=e=>Be(je.value)},null,40,TS),R(`span`,ES,`Staged · `+D(je.value.length),1),t[58]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,title:`stage every changed file`,onClick:t[19]||=e=>qe(`stage`)},[z(k(Zc),{size:13}),t[56]||=B(` all`,-1)]),R(`button`,{class:`icon-button`,title:`unstage all (git reset HEAD)`,onClick:t[20]||=e=>Je(je.value.map(e=>e.path))},[z(k(zc),{size:13}),t[57]||=B(` none`,-1)])]),(F(!0),I(P,null,N(He(je.value),e=>(F(),I(P,{key:e.dir},[e.dir===`.`?V(``,!0):(F(),I(`button`,{key:0,class:`dir-row`,onClick:t=>Ue(e.dir)},[z(k(ic),{size:12,class:E({open:e.open})},null,8,[`class`]),B(D(e.dir),1),R(`span`,OS,`· `+D(e.files.length),1)],8,DS)),(F(!0),I(P,null,N(e.files,t=>A((F(),I(`div`,{key:t.path,class:`file`},[R(`label`,kS,[R(`input`,{type:`checkbox`,checked:h.value.has(t.path),onChange:e=>ze(t.path)},null,40,AS),R(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,jS),R(`span`,{class:`path`,title:t.path},D(t.path),9,MS),We(t)?(F(),I(`span`,{key:0,class:E([`nums`,{bin:We(t)===`bin`}])},D(We(t)),3)):V(``,!0)]),R(`span`,NS,[R(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Ze(t.path)},[z(k(gc),{size:13})],8,PS),R(`button`,{class:`icon-button`,title:`unstage (git reset HEAD)`,onClick:e=>Je([t.path])},[z(k(zc),{size:13})],8,FS),R(`button`,{class:`icon-button`,title:`roll back to HEAD`,onClick:e=>qe(`discard`,t.path)},[z(k(dc),{size:13})],8,IS)])])),[[zo,e.open]])),128))],64))),128))])):V(``,!0),Me.value.length?(F(),I(`div`,LS,[R(`label`,RS,[R(`input`,{type:`checkbox`,checked:Me.value.every(e=>h.value.has(e.path)),onChange:t[21]||=e=>Be(Me.value)},null,40,zS),R(`span`,BS,`Unstaged · `+D(Me.value.length),1)]),(F(!0),I(P,null,N(He(Me.value),e=>(F(),I(P,{key:e.dir},[e.dir===`.`?V(``,!0):(F(),I(`button`,{key:0,class:`dir-row`,onClick:t=>Ue(e.dir)},[z(k(ic),{size:12,class:E({open:e.open})},null,8,[`class`]),B(D(e.dir),1),R(`span`,HS,`· `+D(e.files.length),1)],8,VS)),(F(!0),I(P,null,N(e.files,t=>A((F(),I(`div`,{key:t.path,class:`file`},[R(`label`,US,[R(`input`,{type:`checkbox`,checked:h.value.has(t.path),onChange:e=>ze(t.path)},null,40,WS),R(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,GS),R(`span`,{class:`path`,title:t.path},D(t.path),9,KS),We(t)?(F(),I(`span`,{key:0,class:E([`nums`,{bin:We(t)===`bin`}])},D(We(t)),3)):V(``,!0)]),R(`span`,qS,[R(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Ze(t.path)},[z(k(gc),{size:13})],8,JS),t.x===`?`?(F(),I(`button`,{key:0,class:`icon-button`,title:`add to .gitignore`,onClick:e=>Xe([t.path])},[z(k(Xs),{size:13})],8,YS)):(F(),I(`button`,{key:1,class:`icon-button`,title:`stage (git add)`,onClick:e=>qe(`stage`,t.path)},[z(k(Zc),{size:13})],8,XS)),t.x===`?`?V(``,!0):(F(),I(`button`,{key:2,class:`icon-button`,title:`roll back to HEAD`,onClick:e=>qe(`discard`,t.path)},[z(k(dc),{size:13})],8,ZS)),R(`button`,{class:`icon-button`,title:`copy path`,onClick:e=>Ge(t.path)},[z(k(cc),{size:13})],8,QS)])])),[[zo,e.open]])),128))],64))),128))])):V(``,!0),y.value?(F(),I(`p`,$S,[R(`strong`,null,D(y.value.path),1),R(`span`,eC,[R(`button`,{class:E({on:b.value===`working`}),onClick:t[22]||=e=>{b.value=`working`,Qe()}},`working`,2),R(`button`,{class:E({on:b.value===`staged`}),onClick:t[23]||=e=>{b.value=`staged`,Qe()}},`staged`,2)]),$e.value?(F(),I(`span`,tC,`binary file`)):y.value.text.length>8e3?(F(),I(`span`,nC,`truncated at 8000 chars`)):V(``,!0),R(`button`,{class:`icon-button`,title:`close diff`,onClick:t[24]||=e=>y.value=null},[z(k(Sl),{size:13})]),$e.value?V(``,!0):(F(),I(`pre`,rC,D(y.value.text.slice(0,8e3)),1))])):V(``,!0),A(R(`textarea`,{"onUpdate:modelValue":t[25]||=e=>m.value=e,rows:`4`,placeholder:`Commit message… (Ctrl+Enter to commit)`,onKeydown:[t[26]||=Ms(As(e=>rt(),[`exact`,`prevent`]),[`enter`]),t[27]||=Ms(As(e=>rt(),[`meta`,`prevent`]),[`enter`]),t[28]||=Ms(As(e=>rt(),[`ctrl`,`prevent`]),[`enter`])]},null,544),[[bs,m.value]]),R(`div`,iC,[R(`button`,{class:`small`,disabled:!!f.value||!h.value.size,title:`ask the device's model for a message`,onClick:at},[z(k(ul),{size:14}),t[59]||=B(` ai message`,-1)],8,aC),t[61]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`primary small`,disabled:!!f.value||!m.value.trim()||!Ae.value,onClick:t[29]||=e=>rt(!1)},[z(k(nc),{size:14}),B(` Commit`+D(h.value.size?` ${h.value.size} file${h.value.size>1?`s`:``}`:``),1)],8,oC),a.value.upstream?(F(),I(`button`,{key:0,class:`primary small`,disabled:!!f.value||!m.value.trim()||!Ae.value,title:`commit, then push`,onClick:t[30]||=e=>rt(!0)},[z(k(nc),{size:14}),t[60]||=B(` Commit & push `,-1)],8,sC)):V(``,!0)])]),R(`section`,cC,[R(`div`,lC,[R(`h4`,null,[z(k(Dc),{size:16}),t[62]||=B(` Log`,-1)]),t[64]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:!!f.value,title:`save a checkpoint ref of HEAD`,onClick:ct},[z(k(vc),{size:13}),t[63]||=B(` checkpoint`,-1)],8,uC),R(`button`,{class:`small`,disabled:!!f.value,onClick:t[31]||=e=>ce.value=!ce.value},`checkpoints `+D(se.value.length?`(${se.value.length})`:``),9,dC),R(`button`,{class:`icon-button`,disabled:vt.value,title:`refresh log`,onClick:t[32]||=e=>xt(!0)},[z(k(el),{size:14})],8,fC)]),ce.value?(F(),I(`div`,pC,[se.value.length?V(``,!0):(F(),I(`p`,mC,`no checkpoints yet — one click saves a named ref of HEAD.`)),(F(!0),I(P,null,N(se.value,e=>(F(),I(`div`,{key:e.name,class:`cp-row`},[R(`code`,null,D(e.name),1),R(`span`,hC,D(e.hash)+` · `+D(e.date),1),R(`span`,gC,D(e.subject),1),t[66]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:!!f.value,title:`reset --hard to this checkpoint (this worktree)`,onClick:t=>ut(e.name)},[z(k(gl),{size:13}),t[65]||=B(` rewind`,-1)],8,_C)]))),128))])):V(``,!0),vt.value&&!_t.value.length?(F(),I(`p`,vC,`loading log…`)):_t.value.length?(F(),I(`div`,yC,[(F(!0),I(P,null,N(_t.value,(e,t)=>(F(),I(P,{key:e.hash},[R(`div`,{class:`commit-row`,title:e.refs},[wt.value[t]?(F(),I(`svg`,{key:0,class:`lane`,width:wt.value[t].width*12+4,height:`24`,"aria-hidden":`true`},[(F(!0),I(P,null,N(wt.value[t].width,e=>(F(),I(`line`,{key:e,x1:Tt(e-1),x2:Tt(e-1),y1:`0`,y2:`24`,stroke:`#3a3134`,"stroke-width":`2`},null,8,SC))),128)),(F(!0),I(P,null,N(wt.value[t].parents,(e,n)=>(F(),I(`line`,{key:`p`+n,x1:Tt(wt.value[t].lane),x2:Tt(e),y1:`12`,y2:`24`,stroke:Ct[e%Ct.length],"stroke-width":`2`},null,8,CC))),128)),R(`circle`,{cx:Tt(wt.value[t].lane),cy:`12`,r:`4`,fill:Ct[wt.value[t].lane%Ct.length]},null,8,wC)],8,xC)):V(``,!0),R(`button`,{class:`icon-button hash-btn`,title:`files in this commit`,onClick:t=>st(e.hash)},[z(k(ic),{size:12,class:E({open:le.value.has(e.hash)})},null,8,[`class`])],8,TC),R(`code`,EC,[Re.value?(F(),I(`a`,{key:0,href:`${Re.value}/commit/${e.hash}`,target:`_blank`,rel:`noopener`,title:`on the remote`},D(e.hash),9,DC)):(F(),I(P,{key:1},[B(D(e.hash),1)],64))]),e.refs?(F(),I(`span`,OC,D(e.refs.split(`,`)[0]),1)):V(``,!0),R(`span`,kC,D(e.subject),1),R(`span`,AC,D(e.author)+` · `+D(e.date),1)],8,bC),le.value.has(e.hash)?(F(),I(`div`,jC,[(F(!0),I(P,null,N(le.value.get(e.hash),e=>(F(),I(`div`,{key:e.path,class:`cf`},[R(`code`,{class:`cf-status`,"data-s":e.status},D(e.status),9,MC),R(`span`,NC,D(e.path),1)]))),128)),le.value.get(e.hash)?.length?V(``,!0):(F(),I(`p`,PC,`no files (merge/empty commit)`))])):V(``,!0)],64))),128))])):yt.value?(F(),I(`p`,FC,`log failed: `+D(yt.value),1)):(F(),I(`p`,IC,`no commits`))]),R(`section`,LC,[R(`div`,RC,[R(`h4`,null,[z(k(Uc),{size:16}),t[67]||=B(` Worktrees`,-1)]),R(`div`,zC,[R(`button`,{class:`small`,disabled:!!f.value,onClick:t[33]||=e=>_.value=!_.value},[z(k(Zc),{size:13}),t[68]||=B(` worktree`,-1)],8,BC),_.value?(F(),I(`div`,VC,[(F(!0),I(P,null,N((a.value.branches??[]).filter(e=>!e.current),e=>(F(),I(`button`,{key:e.name,onClick:t=>ft(e.name)},[z(k(Sc),{size:13}),R(`span`,null,D(e.name),1),t[69]||=R(`span`,{class:`muted-line`},`existing`,-1)],8,HC))),128)),R(`div`,UC,[A(R(`input`,{"onUpdate:modelValue":t[34]||=e=>v.value=e,placeholder:`or a NEW branch…`,onKeyup:t[35]||=Ms(e=>v.value.trim()&&ft(v.value.trim()),[`enter`])},null,544),[[bs,v.value]]),R(`button`,{disabled:!v.value.trim(),onClick:t[36]||=e=>ft(v.value.trim())},`create`,8,WC)])])):V(``,!0)])]),(F(!0),I(P,null,N(St.value,e=>(F(),I(`div`,{key:e.path,class:E([`wt`,{main:e.path===a.value.root}])},[R(`code`,{title:e.path},D(e.path),9,GC),R(`span`,KC,D(e.branch??e.head),1),t[70]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,disabled:!!f.value,title:`jump to this worktree (session or new)`,onClick:t=>mt(e.path)},[z(k(Ks),{size:13})],8,qC),R(`button`,{class:`small`,disabled:!!f.value,title:`create a session on this worktree`,onClick:t=>pt(e.path,e.branch)},`session`,8,JC),e.path===a.value.root?V(``,!0):(F(),I(`button`,{key:0,class:`icon-button`,disabled:!!f.value,onClick:t=>ht(e.path)},[z(k(Sl),{size:13})],8,YC)),e.path===a.value.root?(F(),L(k(nc),{key:1,size:13,class:`muted-line`})):V(``,!0)],2))),128))]),pe.value?(F(),I(`section`,XC,[R(`div`,ZC,[R(`h4`,null,[z(k(Tc),{size:16}),t[71]||=B(` Pull requests`,-1)]),t[72]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,disabled:fe.value||!!f.value,onClick:he},`create PR`,8,QC),R(`button`,{class:`small`,disabled:fe.value,onClick:t[37]||=e=>ue.value=!ue.value},D(ue.value?`hide`:`list`),9,$C)]),ue.value&&!T.value.length&&!fe.value?(F(),I(`p`,ew,`no open PRs (or gh is not logged in on the device — every action will say so).`)):V(``,!0),ue.value?(F(),I(`div`,tw,[(F(!0),I(P,null,N(T.value,e=>(F(),I(`div`,{key:e.n,class:`pr-row`},[R(`code`,nw,`#`+D(e.n),1),R(`span`,{class:E([`tag`,{open:e.state===`OPEN`}])},D(e.state.toLowerCase())+D(e.draft?` · draft`:``),3),R(`span`,rw,D(e.title),1),R(`span`,iw,D(e.branch),1),t[73]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`icon-button`,title:`run checks`,disabled:fe.value,onClick:t=>_e(e.n)},[z(k(el),{size:13})],8,aw),R(`button`,{class:`icon-button`,title:`comment`,disabled:fe.value,onClick:t=>be(e.n)},[z(k(cc),{size:13})],8,ow),e.state===`OPEN`?(F(),I(`button`,{key:0,class:`small`,disabled:fe.value||!!f.value,onClick:t=>ve(e.n)},`squash & merge`,8,sw)):V(``,!0),R(`a`,{class:`icon-button`,href:e.url,target:`_blank`,rel:`noopener`,title:`open on the forge`},[z(k(qs),{size:13,style:{transform:`rotate(45deg)`}})],8,cw)]))),128)),(F(!0),I(P,null,N(de.value,([e,t])=>(F(),I(`pre`,{key:e,class:`pr-checks`},`#`+D(e)+` checks:`+D(`
80
+ `)+D(t),1))),128))])):V(``,!0)])):V(``,!0),p.value?(F(),I(`pre`,lw,D(p.value.slice(0,6e3)),1)):V(``,!0)],64)):(F(),I(`p`,Ex,[...t[44]||=[B(`Not a git repository — run `,-1),R(`code`,null,`git init`,-1),B(` (or open a session inside a repo).`,-1)]]))],2)):V(``,!0),re.value?(F(),I(`div`,{key:5,class:`modal-veil`,onClick:t[40]||=As(e=>re.value=null,[`self`])},[R(`div`,{class:E([`modal`,{danger:re.value.danger}]),role:`dialog`,"aria-modal":`true`},[R(`h5`,null,D(re.value.title),1),R(`p`,null,D(re.value.body),1),re.value.input?A((F(),I(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>ie.value=e,rows:`2`,placeholder:re.value.input.placeholder},null,8,uw)),[[bs,ie.value]]):V(``,!0),R(`div`,dw,[t[75]||=R(`span`,{class:`grow`},null,-1),R(`button`,{class:`small`,onClick:t[39]||=e=>re.value=null},[...t[74]||=[B(`cancel `,-1),R(`span`,{class:`muted-line`},`(esc)`,-1)]]),R(`button`,{class:E([`primary small`,{danger:re.value.danger}]),disabled:!(!re.value.input||ie.value.trim()),onClick:oe},D(re.value.confirmLabel??`confirm`),11,fw)])],2)])):V(``,!0)],64)):(F(),I(`p`,bx,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-7fc55dcd`]]),mw={class:`host-panel`,"aria-label":`Device vitals`},hw={class:`panel-heading`},gw=[`disabled`],_w={key:0,class:`hint`},vw={key:1,class:`message-error`},yw={key:2,class:`hint`},bw={class:`vitals-grid`},xw={class:`vital`},Sw={class:`vital`},Cw={key:0,class:`vital`},ww={class:`vital`},Tw={class:`vital`},Ew={class:`meter`},Dw={class:`meter-head`},Ow={class:`hint`},kw=[`aria-valuenow`],Aw={class:`meter`},jw={class:`meter-head`},Mw={class:`hint`},Nw=[`aria-valuenow`],Pw={class:`path`},Fw={class:`hint`},Iw=sf(M({__name:`HostPanel`,setup(e){let t=O(),n=O(!1),r=O(``),i=H(()=>K.value?.deviceId),a=H(()=>Hu.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=H(()=>t.value?c(t.value.memory.usedBytes,t.value.memory.totalBytes):0),u=H(()=>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 W(e).vitals()}catch(e){r.value=G(e).slice(0,160)}finally{n.value=!1}}}j(i,d,{immediate:!0});async function f(){await d(),r.value||J(`Vitals refreshed.`)}return(e,c)=>(F(),I(`section`,mw,[R(`header`,hw,[R(`span`,null,[z(k(al),{size:16}),c[0]||=B(`HOST`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:f},[z(k(el),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,gw)]),i.value?r.value?(F(),I(`p`,vw,D(r.value),1)):t.value?(F(),I(P,{key:3},[R(`div`,bw,[R(`div`,xw,[c[1]||=R(`span`,{class:`label`},`Host uptime`,-1),R(`strong`,null,D(s(t.value.uptime)),1)]),R(`div`,Sw,[c[2]||=R(`span`,{class:`label`},`Device process`,-1),R(`strong`,null,D(s(t.value.processUptime)),1),R(`em`,null,`pid `+D(t.value.pid),1)]),a.value?(F(),I(`div`,Cw,[c[3]||=R(`span`,{class:`label`},`Keep-awake`,-1),R(`strong`,null,D(a.value===`none`?`off`:a.value),1),R(`em`,null,D(a.value===`none`?`no inhibitor here`:`held while sessions run`),1)])):V(``,!0),R(`div`,ww,[c[4]||=R(`span`,{class:`label`},`Load (1/5/15m)`,-1),R(`strong`,null,D(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),R(`em`,null,D(t.value.cpuCount)+` CPU`+D(t.value.cpuCount===1?``:`s`),1)]),R(`div`,Tw,[c[5]||=R(`span`,{class:`label`},`Sessions`,-1),R(`strong`,null,D(t.value.counts?.sessions??0),1),R(`em`,null,D(t.value.counts?.archived??0)+` archived`,1)])]),R(`div`,Ew,[R(`div`,Dw,[c[6]||=R(`span`,{class:`label`},`Memory`,-1),R(`span`,Ow,D(o(t.value.memory.usedBytes))+` / `+D(o(t.value.memory.totalBytes))+` · device `+D(o(t.value.memory.processRssBytes)),1)]),R(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[R(`i`,{style:ge({width:`${l.value}%`}),class:E({high:l.value>=90})},null,6)],8,kw)]),R(`div`,Aw,[R(`div`,jw,[c[7]||=R(`span`,{class:`label`},`Disk · data dir`,-1),R(`span`,Mw,[t.value.disk.known?(F(),I(P,{key:0},[B(D(o(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+D(o(t.value.disk.freeBytes))+` free `,1)],64)):(F(),I(P,{key:1},[B(`unknown on this volume`)],64))])]),R(`div`,{class:`bar`,role:`meter`,"aria-valuenow":u.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[R(`i`,{style:ge({width:`${u.value}%`}),class:E({high:u.value>=90})},null,6)],8,Nw),R(`code`,Pw,D(t.value.disk.path),1)]),R(`p`,Fw,[z(k(Hs),{size:13}),c[8]||=B(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(F(),I(`p`,yw,D(n.value?`Reading host…`:`No vitals.`),1)):(F(),I(`p`,_w,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-ef6f9dc5`]]);function Lw(e){let t=G(e);return e.code===`not_found`||/allowlist|not found/i.test(t)}function Rw(e,t){let n=Hu.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 zw={class:`usage-panel`,"aria-label":`Device usage`},Bw={class:`panel-heading`},Vw=[`disabled`],Hw={key:0,class:`hint`},Uw={key:1,class:`message-error`},Ww={key:2,class:`hint`},Gw={key:3,class:`hint`},Kw={class:`usage-block`,"aria-labelledby":`usage-totals`},qw={class:`totals`},Jw={class:`total`},Yw={class:`total`},Xw={class:`total`},Zw={class:`total`},Qw={class:`usage-block`,"aria-labelledby":`usage-models`},$w={class:`section-label block-label`},eT={class:`table-scroll`},tT={class:`usage-table`,"aria-label":`Usage by model`},nT=[`title`],rT={class:`num`},iT={class:`num`},aT={class:`share-col`},oT={class:`share`},sT=[`aria-valuenow`,`aria-label`],cT={class:`pct`},lT={class:`usage-block`,"aria-labelledby":`usage-projects`},uT={class:`section-label block-label`},dT={key:0,class:`hint`},fT={key:1,class:`rows`},pT=[`title`],mT={class:`row-main`},hT={class:`row-num`},gT={class:`row-num`},_T={class:`row-meta`},vT={class:`usage-block`,"aria-labelledby":`usage-sessions`},yT={key:0,class:`hint`},bT={key:1,class:`rows scroll`},xT=[`title`],ST={class:`row-main`},CT={class:`row-num`},wT={class:`row-num`},TT={class:`row-meta`},ET={class:`hint`},DT=sf(M({__name:`UsagePanel`,setup(e){let t=O(),n=O(!1),r=O(``),i=H(()=>K.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=H(()=>(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=H(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=H(()=>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 W(e).deviceUsage()}catch(e){r.value=Lw(e)?Rw(i.value,`usage`):G(e).slice(0,220)}finally{n.value=!1}}}j(i,f,{immediate:!0});async function p(){await f(),r.value||J(`Usage refreshed.`)}return(e,s)=>(F(),I(`section`,zw,[R(`header`,Bw,[R(`span`,null,[z(k(Hs),{size:16}),s[0]||=B(`USAGE`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[z(k(el),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,Vw)]),i.value?r.value?(F(),I(`p`,Uw,D(r.value),1)):t.value?l.value?(F(),I(`p`,Gw,`No usage recorded yet.`)):(F(),I(P,{key:4},[R(`section`,Kw,[s[6]||=R(`div`,{class:`section-label block-label`},[R(`span`,{id:`usage-totals`},`TOTALS`)],-1),R(`div`,qw,[R(`div`,Jw,[s[1]||=R(`span`,{class:`label`},`Tokens`,-1),R(`strong`,null,D(a(t.value.totals.tokens)),1)]),R(`div`,Yw,[s[2]||=R(`span`,{class:`label`},`Cost`,-1),R(`strong`,null,D(o(t.value.totals.cost)),1)]),R(`div`,Xw,[s[3]||=R(`span`,{class:`label`},`Sessions`,-1),R(`strong`,null,D(a(t.value.sessions.length)),1),R(`em`,null,D(a(t.value.projects.length))+` projects`,1)]),R(`div`,Zw,[s[4]||=R(`span`,{class:`label`},`Models`,-1),R(`strong`,null,D(a(t.value.models.length)),1),s[5]||=R(`em`,null,`costliest first`,-1)])])]),R(`section`,Qw,[R(`div`,$w,[s[7]||=R(`span`,{id:`usage-models`},`BY MODEL`,-1),z(k(fc),{size:13})]),R(`div`,eT,[R(`table`,tT,[s[8]||=R(`colgroup`,null,[R(`col`),R(`col`),R(`col`),R(`col`)],-1),s[9]||=R(`thead`,null,[R(`tr`,null,[R(`th`,{scope:`col`},`Model`),R(`th`,{scope:`col`,class:`num`},`Tokens`),R(`th`,{scope:`col`,class:`num`},`Cost`),R(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),R(`tbody`,null,[(F(!0),I(P,null,N(t.value.models,e=>(F(),I(`tr`,{key:e.key},[R(`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,nT),R(`td`,rT,D(a(e.tokens)),1),R(`td`,iT,D(o(e.cost)),1),R(`td`,aT,[R(`div`,oT,[R(`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`},[R(`i`,{style:ge({width:`${c(e.cost)}%`}),class:E({high:c(e.cost)>90})},null,6)],8,sT),R(`em`,cT,D(c(e.cost))+`%`,1)])])]))),128))])])])]),R(`section`,lT,[R(`div`,uT,[s[10]||=R(`span`,{id:`usage-projects`},`BY PROJECT`,-1),z(k(yc),{size:13})]),t.value.projects.length?(F(),I(`ul`,fT,[(F(!0),I(P,null,N(t.value.projects,e=>(F(),I(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[R(`span`,mT,[R(`strong`,null,D(e.name),1),R(`em`,null,D(e.rootPath),1)]),R(`span`,hT,D(a(e.tokens))+` tok`,1),R(`span`,gT,D(o(e.cost)),1),R(`span`,_T,D(d(e.sessions,`session`)),1)],8,pT))),128))])):(F(),I(`p`,dT,`No project usage recorded yet.`))]),R(`section`,vT,[s[11]||=R(`div`,{class:`section-label block-label`},[R(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(F(),I(`ul`,bT,[(F(!0),I(P,null,N(t.value.sessions,e=>(F(),I(`li`,{key:e.id,class:`row`,title:e.cwd},[R(`span`,ST,[R(`strong`,null,D(e.name),1),R(`em`,null,D(e.project??e.cwd),1)]),R(`span`,CT,D(a(e.tokens))+` tok`,1),R(`span`,wT,D(o(e.cost)),1),R(`span`,TT,D(d(e.agents,`agent`)),1)],8,xT))),128))])):(F(),I(`p`,yT,`No session usage recorded yet.`))]),R(`p`,ET,[z(k(Hs),{size:13}),B(` Read on demand — open this tab or press refresh (`+D(u.value)+`). Nothing polls the device. `,1)])],64)):(F(),I(`p`,Ww,D(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(F(),I(`p`,Hw,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-7a8f5c75`]]),OT={class:`schedules-panel`,"aria-label":`Scheduled sessions`},kT={class:`panel-heading`},AT=[`disabled`],jT=[`disabled`],MT={key:0,class:`hint`},NT={key:1,class:`message-error`},PT=[`disabled`],FT={key:0,value:``},IT={key:1,value:``},LT=[`value`],RT={class:`trigger-row`},zT={class:`inline`},BT=[`disabled`],VT={class:`inline`},HT=[`disabled`],UT={class:`row`},WT=[`disabled`],GT={key:3,class:`hint`},KT={key:4,class:`schedule-list`},qT={class:`head`},JT={class:`tag`},YT={key:0,class:`tag running`},XT=[`title`],ZT={class:`next`},QT={class:`cwd`},$T={key:0,class:`message-error`},eE={class:`row`},tE=[`disabled`,`onClick`],nE=[`disabled`,`onClick`],rE=[`disabled`,`onClick`],iE=sf(M({__name:`SchedulesPanel`,setup(e){let t=O([]),n=O(``),r=O(``),i=O(!1),a=H(()=>K.value?.deviceId),o=()=>W(a.value??``),s=O(`60`),c=O(``),l=O(!1),u=O({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=Lw(e)?Rw(a.value,`schedules`):G(e).slice(0,220)}finally{i.value=!1}}j(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(),J(r)}catch(e){J(G(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=>q.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=O([]),y=O(!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){J(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(),J(`Schedule created. The device runs it on its own clock.`)}catch(e){J(G(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(F(),I(`section`,OT,[R(`header`,kT,[R(`span`,null,[z(k(tc),{size:16}),o[7]||=B(`SCHEDULES`,-1)]),R(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[z(k(el),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,AT),R(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:b},[z(k(Zc),{size:15})],8,jT)]),o[18]||=R(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(F(),I(`p`,NT,D(r.value),1)):V(``,!0):(F(),I(`p`,MT,`Select a session to see its device.`)),l.value?(F(),I(`form`,{key:2,class:`add-form`,onSubmit:As(x,[`prevent`])},[R(`label`,null,[o[8]||=B(`Name`,-1),A(R(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[bs,u.value.name]])]),R(`label`,null,[o[9]||=B(`Directory`,-1),A(R(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[bs,u.value.cwd]])]),R(`label`,null,[o[10]||=B(`Prompt`,-1),A(R(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[bs,u.value.prompt]])]),R(`label`,null,[o[11]||=B(`Model `,-1),A(R(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e,disabled:y.value},[y.value?(F(),I(`option`,FT,`loading…`)):v.value.length?V(``,!0):(F(),I(`option`,IT,`(no models — check the device)`)),(F(!0),I(P,null,N(v.value,e=>(F(),I(`option`,{key:e.key,value:e.key},D(e.key),9,LT))),128))],8,PT),[[Cs,u.value.model]])]),R(`div`,RT,[R(`label`,zT,[o[12]||=B(`Every `,-1),A(R(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,BT),[[bs,s.value]]),o[13]||=B(` min`,-1)]),o[15]||=R(`span`,{class:`muted`},`or`,-1),R(`label`,VT,[o[14]||=B(`daily at `,-1),A(R(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,HT),[[bs,c.value]])])]),R(`div`,UT,[R(`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,WT),R(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):V(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(F(),I(`p`,GT,D(i.value?`Reading schedules…`:`No schedules yet. Press + to add one.`),1)):V(``,!0),t.value.length?(F(),I(`ul`,KT,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:e.id,class:E([`schedule`,{off:!e.enabled}])},[R(`div`,qT,[R(`b`,null,D(e.name),1),R(`span`,JT,D(p(e)),1),e.running?(F(),I(`span`,YT,`running`)):e.lastOutcome===`failed`?(F(),I(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,XT)):V(``,!0),R(`span`,ZT,D(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),R(`code`,QT,D(e.cwd),1),e.lastError?(F(),I(`p`,$T,D(e.lastError.slice(0,160)),1)):V(``,!0),R(`div`,eE,[R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[z(k(Xc),{size:12}),o[16]||=B(`run now`,-1)],8,tE),R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[z(k(Qc),{size:12}),B(D(e.enabled?`pause`:`resume`),1)],8,nE),R(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[z(k(hl),{size:12}),o[17]||=B(`remove`,-1)],8,rE)])],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-1284f0f2`]]),aE={class:`archive-panel`,"aria-label":`Old sessions`},oE={class:`panel-heading`},sE=[`disabled`],cE={key:0,class:`hint`},lE={key:1,class:`message-error`},uE={key:2,class:`hint`},dE={key:3,class:`old-list`},fE={class:`head`},pE=[`title`],mE={class:`meta`},hE=[`aria-label`,`onClick`],gE=[`aria-label`,`onClick`],_E={class:`facts`},vE={key:0,class:`cwd`},yE={key:1,class:`tag`},bE={class:`meta`},xE={class:`meta`},SE={key:2,class:`meta`},CE=sf(M({__name:`ArchivePanel`,setup(e){let t=O(null),n=O(!1),r=O(``),i=H(()=>K.value?.deviceId),a=()=>W(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=Lw(e)?Rw(i.value,`browsing old sessions`):G(e).slice(0,220)}finally{n.value=!1}}j(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){q.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(),J(`${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){J(G(e).slice(0,160))}}return(e,a)=>(F(),I(`section`,aE,[R(`header`,oE,[R(`span`,null,[z(k(Ws),{size:16}),a[0]||=B(`ARCHIVE`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh archive`,title:`Refresh archive`,onClick:o},[z(k(el),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,sE)]),a[2]||=R(`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?(F(),I(`p`,lE,D(r.value),1)):t.value&&!t.value.length?(F(),I(`p`,uE,`Nothing archived on this device yet.`)):V(``,!0):(F(),I(`p`,cE,`Select a session to see its device.`)),t.value?.length?(F(),I(`ul`,dE,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:`${e.sessionId}-${e.archivedAt}`,class:`old`},[R(`div`,fE,[R(`b`,null,D(e.name),1),R(`span`,{class:`tag`,title:e.hasManifest?`bundled with full identity`:`old bundle — name unknown`},D(e.hasManifest?`manifest`:`legacy`),9,pE),R(`span`,mE,`archived `+D(c(e.archivedAt)),1),a[1]||=R(`span`,{class:`spacer`},null,-1),R(`button`,{class:`icon-button`,"aria-label":`Download transcript of ${e.name}`,title:`Download transcript (markdown)`,onClick:t=>u(e)},[z(k(mc),{size:13})],8,hE),R(`button`,{class:`icon-button`,"aria-label":`Restore ${e.name}`,title:`Restore to the live list`,onClick:t=>l(e)},[z(k(nl),{size:13})],8,gE)]),R(`div`,_E,[e.cwd?(F(),I(`span`,vE,D(e.cwd),1)):V(``,!0),e.model?(F(),I(`span`,yE,D(e.model),1)):V(``,!0),R(`span`,bE,D(e.turns>=0?`${e.turns} turns`:`turns unknown`),1),R(`span`,xE,D(s(e.bytes)),1),e.lastMessageAt?(F(),I(`span`,SE,`last message `+D(c(e.lastMessageAt)),1)):V(``,!0)])]))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-054371cd`]]),wE={class:`graph-panel`,"aria-label":`Task graphs`},TE={class:`panel-heading`},EE=[`disabled`],DE=[`disabled`],OE={key:0,class:`hint`},kE={key:1,class:`message-error`},AE={key:2,class:`hint`},jE={class:`row`},ME=[`disabled`],NE={class:`head`},PE=[`title`],FE=[`aria-label`,`disabled`,`onClick`],IE=[`aria-label`,`onClick`],LE={class:`tasks`},RE=[`title`],zE={key:0,class:`deps`},BE={class:`tag`},VE={key:1,class:`err`},HE=sf(M({__name:`GraphPanel`,setup(e){let t=O([]),n=O({}),r=O(!1),i=O(``),a=O(``),o=O(!1),s=O(``),c=H(()=>K.value?.deviceId),l=()=>W(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=Lw(e)?Rw(c.value,`running task-graphs`):G(e).slice(0,220)}finally{r.value=!1}}j(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||J(`This graph has not run yet.`)}catch(e){J(G(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},J(`Run started: ${Object.keys(t.tasks).length} tasks.`),p(e)}catch(e){J(G(e).slice(0,140))}finally{a.value=``}}function h(e){q.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=``,J(`Graph "${n.name}" added (${n.tasks.length} tasks).`),await u()}catch(e){J(G(e).slice(0,200))}finally{a.value=``}}}return(e,l)=>(F(),I(`section`,wE,[R(`header`,TE,[R(`span`,null,[z(k(_l),{size:16}),l[3]||=B(`DAG`,-1)]),R(`button`,{class:`icon-button`,disabled:r.value||!c.value,"aria-label":`Refresh graphs`,title:`Refresh`,onClick:u},[z(k(el),{size:15,class:E({spin:r.value})},null,8,[`class`])],8,EE),R(`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},[z(k(Zc),{size:15})],8,DE)]),l[7]||=R(`p`,{class:`hint`},`Tasks run on the device, in dependency order — one fresh session each.`,-1),c.value?i.value?(F(),I(`p`,kE,D(i.value),1)):!t.value.length&&!o.value?(F(),I(`p`,AE,` No graphs yet. Press + and paste a graph JSON ({ name, cwd, tasks: [{ id, name, prompt, dependsOn }] }). `)):V(``,!0):(F(),I(`p`,OE,`Select a session to see its device.`)),o.value?(F(),I(`form`,{key:3,class:`add-form`,onSubmit:As(g,[`prevent`])},[R(`label`,null,[l[4]||=B(`Graph JSON `,-1),A(R(`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),[[bs,s.value]])]),R(`div`,jE,[R(`button`,{class:`primary small`,type:`submit`,disabled:a.value===`new`},D(a.value===`new`?`adding…`:`Add graph`),9,ME),R(`button`,{class:`small`,type:`button`,onClick:l[2]||=e=>o.value=!1},`Cancel`)])],32)):V(``,!0),(F(!0),I(P,null,N(t.value,e=>(F(),I(`div`,{key:e.id,class:`graph`},[R(`div`,NE,[R(`b`,null,D(e.name),1),R(`code`,{class:`cwd`,title:e.cwd},D(e.cwd.split(`/`).filter(Boolean).at(-1)||e.cwd),9,PE),R(`span`,{class:E([`tag`,d[e.lastRun?.status??`pending`]??``])},D(e.lastRun?e.lastRun.status:`never run`),3),l[5]||=R(`span`,{class:`spacer`},null,-1),R(`button`,{class:`icon-button`,"aria-label":`Run ${e.name}`,title:`Run now`,disabled:a.value===e.id,onClick:t=>m(e)},[z(k(Xc),{size:14})],8,FE),R(`button`,{class:`icon-button`,"aria-label":`Remove ${e.name}`,title:`Remove graph`,onClick:t=>h(e)},[z(k(hl),{size:14})],8,IE)]),R(`ul`,LE,[(F(!0),I(P,null,N(e.tasks,t=>(F(),I(`li`,{key:t.id,class:E(d[f(e,t.id)])},[l[6]||=R(`span`,{class:`dot`,"aria-hidden":`true`},null,-1),R(`span`,{class:`name`,title:t.prompt},D(t.name),9,RE),t.dependsOn.length?(F(),I(`code`,zE,`← `+D(t.dependsOn.join(`, `)),1)):V(``,!0),R(`span`,BE,D(f(e,t.id)),1),n.value[e.id]?.tasks[t.id]?.error?(F(),I(`em`,VE,D(n.value[e.id].tasks[t.id].error.slice(0,120)),1)):V(``,!0)],2))),128))])]))),128))]))}}),[[`__scopeId`,`data-v-4acbb881`]]),UE={class:`notify-panel`,"aria-label":`Notification sinks`},WE={class:`panel-heading`},GE=[`disabled`],KE=[`disabled`],qE=[`disabled`],JE={key:0,class:`hint`},YE={key:1,class:`message-error`},XE=[`placeholder`],ZE={class:`row`},QE=[`disabled`],$E={key:3,class:`hint`},eD={key:4,class:`sink-list`},tD={class:`head`},nD={class:`tag`},rD={class:`next`},iD={class:`url`},aD={key:0,class:`hint`},oD={key:1,class:`message-error`},sD={class:`row`},cD=[`disabled`,`onClick`],lD=[`disabled`,`onClick`],uD={key:5,class:`results`,"aria-label":`Test results`},dD={class:`tag`},fD={key:0},pD=sf(M({__name:`NotifyPanel`,setup(e){let t=O([]),n=O(``),r=O(``),i=O(!1),a=O([]),o=H(()=>K.value?.deviceId),s=()=>W(o.value??``),c=O(!1),l=O({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=Lw(e)?Rw(o.value,`notifications`):G(e).slice(0,220)}finally{i.value=!1}}j(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(),J(`Sink added on the device.`)}catch(e){J(G(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){J(G(e).slice(0,140))}finally{n.value=``}}function m(e){q.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;J(a.value.length?`Test: ${a.value.length-e} sent${e?`, ${e} failed`:``}.`:`No enabled sinks matched — nothing was sent.`)}catch(e){J(G(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(F(),I(`section`,UE,[R(`header`,WE,[R(`span`,null,[z(k(Zs),{size:16}),s[6]||=B(`NOTIFY`,-1)]),R(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[z(k(el),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,GE),R(`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},[z(k(il),{size:15})],8,KE),R(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[z(k(Zc),{size:15})],8,qE)]),s[14]||=R(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(F(),I(`p`,YE,D(r.value),1)):V(``,!0):(F(),I(`p`,JE,`Select a session to see its device.`)),c.value?(F(),I(`form`,{key:2,class:`add-form`,onSubmit:As(f,[`prevent`])},[R(`label`,null,[s[8]||=B(`Kind `,-1),A(R(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[R(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),R(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Cs,l.value.kind]])]),R(`label`,null,[s[9]||=B(`URL `,-1),A(R(`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,XE),[[bs,l.value.url]])]),R(`label`,null,[s[10]||=B(`Label`,-1),A(R(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[bs,l.value.label]])]),R(`label`,null,[s[11]||=B(`Events `,-1),A(R(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[bs,l.value.events]])]),R(`div`,ZE,[R(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`adding…`:`Add sink`),9,QE),R(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=R(`p`,{class:`hint`},[B(`LAN targets (192.168.x, localhost) need `),R(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),B(` on the device.`)],-1)],32)):V(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(F(),I(`p`,$E,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):V(``,!0),t.value.length?(F(),I(`ul`,eD,[(F(!0),I(P,null,N(t.value,e=>(F(),I(`li`,{key:e.id,class:E([`sink`,{off:!e.enabled}])},[R(`div`,tD,[R(`span`,nD,D(e.kind),1),R(`b`,null,D(e.label||e.url),1),R(`em`,rD,D(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),R(`code`,iD,D(e.url),1),e.events?.length?(F(),I(`p`,aD,`events: `+D(e.events.join(`, `)),1)):V(``,!0),e.lastError?(F(),I(`p`,oD,D(e.lastError.slice(0,160)),1)):V(``,!0),R(`div`,sD,[R(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[z(k(Qc),{size:12}),B(D(e.enabled?`disable`:`enable`),1)],8,cD),R(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[z(k(hl),{size:12}),s[13]||=B(`remove`,-1)],8,lD)])],2))),128))])):V(``,!0),a.value.length?(F(),I(`ul`,uD,[(F(!0),I(P,null,N(a.value,e=>(F(),I(`li`,{key:e.id,class:E(e.status)},[R(`span`,dD,D(e.status),1),B(` `+D(e.kind)+` `+D(e.id.slice(0,8))+` `,1),e.detail?(F(),I(`em`,fD,D(e.detail),1)):V(``,!0)],2))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-6fa0ab18`]]),mD={class:`env-panel`,"aria-label":`Device environment`},hD={class:`panel-heading`},gD=[`disabled`],_D=[`disabled`],vD={key:0,class:`hint`},yD={key:1,class:`message-error`},bD={key:2,class:`message-restart`},xD={class:`row`},SD=[`disabled`],CD={key:4,class:`hint`},wD={key:5,class:`var-list`},TD={class:`head`},ED={class:`key`},DD={class:`tag`},OD={key:0,class:`tag`,title:`Has its own setting; edit that instead`},kD=[`aria-label`,`title`,`onClick`],AD=[`aria-label`,`onClick`],jD=[`title`],MD={key:6,class:`hint path`},ND={class:`panel-heading keys-heading`},PD=[`disabled`],FD=[`disabled`],ID={key:7,class:`message-error`},LD={class:`row`},RD=[`disabled`],zD={key:9,class:`hint`},BD={key:10,class:`var-list`},VD={class:`head`},HD={class:`key`},UD={class:`tag`},WD={key:0,class:`tag`,title:`Set by pi /login — read-only here`},GD=[`aria-label`,`onClick`],KD={class:`value`,title:`write-only — masked tail`},qD=sf(M({__name:`EnvPanel`,setup(e){let t=O(null),n=O(!1),r=O(``),i=O(``),a=H(()=>K.value?.deviceId),o=()=>W(a.value??``),s=O(!1),c=O({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=Lw(e)?Rw(a.value,`editing env vars`):G(e).slice(0,220)}finally{n.value=!1}m()}j(a,l,{immediate:!0});let u=O(null),d=O(``),f=O(!1),p=O({providerId:``,key:``});async function m(){if(!a.value)return void(u.value=null);try{u.value=await o().piAuth(),d.value=``}catch(e){G(e),d.value=Lw(e)?Rw(a.value,`managing pi keys`):G(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(),J(`${e} saved (now ${t.masked}) — restart the device to apply it.`)}catch(e){J(G(e).slice(0,160))}finally{i.value=``}}}function g(e){q.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(),J(`${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(),J(`${e} saved — restart the device to apply it.`)}catch(e){J(G(e).slice(0,160))}finally{i.value=``}}}function y(e){q.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(),J(`${e.key} saved — restart the device to apply it.`)}}}function b(e){q.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(),J(`${e.key} removed — restart the device to apply it.`)}}}return(e,o)=>(F(),I(`section`,mD,[R(`header`,hD,[R(`span`,null,[z(k(_c),{size:16}),o[8]||=B(`ENV`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[z(k(el),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,gD),R(`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},[z(k(Zc),{size:15})],8,_D)]),o[19]||=R(`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?(F(),I(`p`,yD,D(r.value),1)):t.value?.restartRequired?(F(),I(`p`,bD,[...o[9]||=[B(` Changed since boot — restart the device (`,-1),R(`code`,null,`dpi device stop && dpi device start`,-1),B(`) to apply. `,-1)]])):V(``,!0):(F(),I(`p`,vD,`Select a session to see its device.`)),s.value?(F(),I(`form`,{key:3,class:`add-form`,onSubmit:As(v,[`prevent`])},[R(`label`,null,[o[10]||=B(`Key (UPPER_SNAKE_CASE)`,-1),A(R(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[bs,c.value.key]])]),R(`label`,null,[o[11]||=B(`Value`,-1),A(R(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[bs,c.value.value]])]),R(`div`,xD,[R(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},D(i.value===`new`?`saving…`:`Save to env file`),9,SD),R(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[12]||=R(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):V(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(F(),I(`p`,CD,` No vars in the env file yet. `)):V(``,!0),t.value?.vars.length?(F(),I(`ul`,wD,[(F(!0),I(P,null,N(t.value.vars,e=>(F(),I(`li`,{key:e.key,class:E([`var`,{ro:!_(e)}])},[R(`div`,TD,[R(`code`,ED,D(e.key),1),R(`span`,DD,D(e.source===`process`?`process`:`file`),1),e.managed?(F(),I(`span`,OD,`managed`)):V(``,!0),o[13]||=R(`span`,{class:`spacer`},null,-1),_(e)?(F(),I(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>y(e)},[z(k(Jc),{size:13})],8,kD)):V(``,!0),_(e)?(F(),I(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>b(e)},[z(k(hl),{size:13})],8,AD)):V(``,!0)]),R(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},D(e.masked),9,jD)],2))),128))])):V(``,!0),t.value?(F(),I(`p`,MD,D(t.value.envFile),1)):V(``,!0),R(`header`,ND,[R(`span`,null,[z(k(Ac),{size:16}),o[14]||=B(`PI KEYS`,-1)]),R(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh pi keys`,title:`Refresh`,onClick:m},[z(k(el),{size:15})],8,PD),R(`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},[z(k(Zc),{size:15})],8,FD)]),o[20]||=R(`p`,{class:`hint`},[B(` Provider keys in pi's own `),R(`code`,null,`auth.json`),B(` — write-only: values are never shown, pi's interactive logins (oauth) are never touched. `)],-1),d.value?(F(),I(`p`,ID,D(d.value),1)):V(``,!0),f.value?(F(),I(`form`,{key:8,class:`add-form`,onSubmit:As(h,[`prevent`])},[R(`label`,null,[o[15]||=B(`Provider id`,-1),A(R(`input`,{"onUpdate:modelValue":o[5]||=e=>p.value.providerId=e,placeholder:`zai`,required:``},null,512),[[bs,p.value.providerId]])]),R(`label`,null,[o[16]||=B(`Key`,-1),A(R(`input`,{"onUpdate:modelValue":o[6]||=e=>p.value.key=e,type:`password`,autocomplete:`off`,placeholder:`paste the api key`,required:``},null,512),[[bs,p.value.key]])]),R(`div`,LD,[R(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`pi-key`},D(i.value===`pi-key`?`saving…`:`Save to auth.json`),9,RD),R(`button`,{class:`small`,type:`button`,onClick:o[7]||=e=>f.value=!1},`Cancel`)]),o[17]||=R(`p`,{class:`hint`},`Applies after the next device restart. Existing keys for other providers stay as they are.`,-1)],32)):V(``,!0),!f.value&&u.value&&!u.value.entries.length&&!d.value?(F(),I(`p`,zD,` No provider keys found. `)):V(``,!0),u.value?.entries.length?(F(),I(`ul`,BD,[(F(!0),I(P,null,N(u.value.entries,e=>(F(),I(`li`,{key:e.providerId,class:`var`},[R(`div`,VD,[R(`code`,HD,D(e.providerId),1),R(`span`,UD,D(e.source),1),e.type===`api_key`?V(``,!0):(F(),I(`span`,WD,D(e.type),1)),o[18]||=R(`span`,{class:`spacer`},null,-1),e.type===`api_key`?(F(),I(`button`,{key:1,class:`icon-button`,"aria-label":`Remove ${e.providerId} key`,title:`Remove from auth.json`,onClick:t=>g(e.providerId)},[z(k(hl),{size:13})],8,GD)):V(``,!0)]),R(`code`,KD,D(e.masked),1)]))),128))])):V(``,!0)]))}}),[[`__scopeId`,`data-v-d92de86a`]]),JD={class:`extensions-panel`},YD={class:`panel-heading`},XD={key:0,class:`task-empty`},ZD=[`data-extension`],QD={class:`ext-head`},$D=[`aria-checked`,`aria-label`,`disabled`,`onClick`],eO=[`checked`,`disabled`,`onChange`],tO=M({__name:`ExtensionsPanel`,setup(e){let t=an(),n=O(!1);async function r(){let e=rd.value;if(!e||!Zu.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}j([rd,Zu,()=>JSON.stringify(pd.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=rd.value;if(r&&!n.value){n.value=!0;try{let n=await kd(()=>r.setExtension(e));n&&(t.value=n),wd()}finally{n.value=!1}}}return(e,r)=>(F(),I(`div`,JD,[R(`div`,YD,[r[0]||=R(`h2`,null,`Extensions`,-1),z(k($c),{size:18})]),r[3]||=R(`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?V(``,!0):(F(),I(`p`,XD,`Loading extensions…`)),(F(!0),I(P,null,N(t.value?.extensions??[],e=>(F(),I(`article`,{key:e.name,class:E([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[R(`div`,QD,[R(`div`,null,[R(`strong`,null,D(e.title),1),R(`code`,null,D(e.name),1)]),R(`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]||=[R(`span`,null,null,-1)]],10,$D)]),R(`p`,null,D(e.description),1),e.prompts?(F(),I(`ul`,{key:0,class:E([`ext-prompts`,{off:!e.enabled}])},[(F(!0),I(P,null,N(e.prompts,e=>(F(),I(`li`,{key:e.id},[R(`label`,null,[R(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,eO),R(`code`,null,D(e.id),1)]),R(`span`,null,D(e.description),1),R(`details`,null,[r[2]||=R(`summary`,null,`View prompt`,-1),R(`pre`,null,D(e.text),1)])]))),128))],2)):V(``,!0)],10,ZD))),128))]))}}),nO={class:`context-section`,"aria-labelledby":`context-title`},rO={class:`section-label`},iO={key:0,class:`hint`},aO={key:1,class:`hint`},oO={class:`context-numbers`},sO={class:`context-pct`},cO={key:0,class:`context-compacting`},lO=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],uO={class:`context-marker-label`},dO=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],fO={class:`context-marker-label`},pO={class:`hint context-hint`},mO={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},hO={class:`context-toggle`},gO=[`checked`],_O=512,vO=4096,yO=1024,bO=M({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=H(()=>xd.value?.contextWindow??0),r=H(()=>{let e=bd.value;return e&&!xd.value?`${e.provider?`${e.provider} / `:``}${e.modelId}`:``}),i=H(()=>{let e=pd.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=H(()=>pd.value.compactions.length>0),o=O(),s=H(()=>o.value??td.value?.compaction??Vv(n.value));j(()=>JSON.stringify(td.value?.compaction),e=>{o.value&&e===JSON.stringify(o.value)&&(o.value=void 0)});let c=O(),l=H(()=>q.dialog?.kind===`compaction`),u=()=>void(q.dialog=void 0);Kr(()=>l.value&&u());let d=H(()=>c.value??Hv(n.value,s.value)),f=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,p=H(()=>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-yO,Math.max((t??vO)+yO,e)),g=(e,t)=>Math.min(t-yO,Math.max(vO,e));function _(e,t){let n=d.value,r=Math.round(t/_O)*_O;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=id.value;if(!t)return;let n=await kd(()=>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=O(),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??vO:r.wait)+n)}return(e,o)=>(F(),I(P,null,[R(`section`,nO,[R(`div`,rO,[o[7]||=R(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(F(),I(`button`,{key:0,class:`context-details-toggle`,onClick:o[0]||=e=>k(q).dialog={kind:`compaction`}},[z(k(kc),{size:16}),o[6]||=B(`Details `,-1)])):V(``,!0)]),r.value?(F(),I(`div`,iO,D(r.value)+` — not in this device's catalog, so its context window is unknown here. `,1)):n.value?(F(),I(P,{key:2},[R(`div`,oO,[R(`strong`,null,D(t(i.value)),1),R(`span`,null,`of `+D(t(n.value))+` tokens`,1),R(`span`,sO,D(p.value)+`%`,1),a.value?(F(),I(`span`,cO,[...o[8]||=[R(`i`,null,null,-1),B(`Compacting`,-1)]])):V(``,!0)]),R(`div`,{ref_key:`bar`,ref:b,class:E([`context-bar`,{off:!s.value.enabled}]),onPointermove:C,onPointerup:ee,onPointercancel:ee},[R(`div`,{class:E([`context-fill`,{hot:d.value.auto!==void 0&&i.value>=d.value.auto}]),style:ge({width:f(i.value)})},null,6),R(`div`,{class:`context-reserve`,style:ge({left:f(d.value.wait)}),title:`Reserved for the answer`},null,4),d.value.auto===void 0?V(``,!0):(F(),I(`button`,{key:0,class:E([`context-marker auto`,`label-${m(d.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":vO,"aria-valuemax":d.value.wait-yO,"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},[R(`span`,uO,`Auto-compact at `+D(t(d.value.auto)),1)],46,lO)),R(`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??vO)+yO,"aria-valuemax":n.value-yO,"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},[R(`span`,fO,`Reserve at `+D(t(d.value.wait)),1)],46,dO)],34),R(`p`,pO,[s.value.enabled?(F(),I(P,{key:0},[o[9]||=B(`Compacts in the background at `,-1),R(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[10]||=B(` and waits at `,-1),R(`strong`,null,D(t(d.value.wait)),1),o[11]||=B(`.`,-1)],64)):(F(),I(P,{key:1},[B(`Automatic compaction is off.`)],64))])],64)):(F(),I(`div`,aO,`Pick a model to see its context window.`))]),(F(),L(ur,{to:`body`},[l.value?(F(),I(`div`,{key:0,class:`modal-backdrop`,onClick:As(u,[`self`])},[R(`section`,mO,[R(`header`,null,[o[12]||=R(`h2`,{id:`compaction-title`},`Context compaction`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:u},[z(k(Sl),{size:18})])]),R(`p`,null,[o[13]||=B(` A summary starts in the background at `,-1),R(`strong`,null,D(t(d.value.auto??d.value.wait)),1),o[14]||=B(`. Above `,-1),R(`strong`,null,D(t(d.value.wait)),1),B(` 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]||=R(`p`,null,[B(`Older entries stay stored, and `),R(`code`,null,`search_history`),B(` still finds them.`)],-1),R(`label`,hO,[R(`input`,{type:`checkbox`,checked:s.value.enabled,onChange:o[5]||=e=>v({enabled:e.target.checked})},null,40,gO),o[15]||=B(` Automatic compaction `,-1)]),o[17]||=R(`p`,{class:`hint`},[B(` Applies to every agent in this session. `),R(`code`,null,`/compact`),B(` works either way. `)],-1),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:u},`Close`)])])])):V(``,!0)]))],64))}}),xO=/^[A-Za-z_$][\w$]*$/,SO=e=>` `.repeat(e);function CO(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`),wO(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function wO(e,t,n){if(!e||typeof e!=`object`)return n(`unknown`,`type`);if(`const`in e)return DO(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`),wO(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return TO(e,t,n);default:return n(`unknown`,`type`)}}function TO(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`),wO(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
81
+ `);for(let[e,a]of r){let r=OO(a);r&&n(`${SO(t+1)}${r}\n`,`comment`),n(SO(t+1)),n(xO.test(e)?e:JSON.stringify(e),`property`),n(i.has(e)?`: `:`?: `,`punct`),wO(a,t+1,n),n(`;`,`punct`),n(`
82
+ `)}n(SO(t)),n(`}`,`punct`)}function EO(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),wO(e,t,n)})}function DO(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 OO(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 kO(e){let t=document.createElement(`a`),n=(e.filename||`device-response`).replace(/[^A-Za-z0-9._-]/g,`_`).slice(0,80)||`device-response`;/\.zip$/i.test(e.filename)&&!/\.zip$/i.test(n)&&(n=`${n.slice(0,76)}.zip`),t.href=URL.createObjectURL(new Blob([e.bytes.slice()],{type:`application/zip`})),t.download=n,t.click(),URL.revokeObjectURL(t.href)}function AO(e,t={}){let n=t.fetchBundle??((e,t)=>W(e).exportSession(t)),r=t.download??kO,i=t.notify??(()=>{}),a=O(!1),o=O(``);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: ${G(e).slice(0,300)}`,i(o.value.slice(0,120))}finally{a.value=!1}}}return j(()=>e.value.summary?.id,()=>o.value=``),{exporting:a,error:o,run:s}}function jO(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 $y({},{operation:`update`,path:``,value:t}),``}catch(e){return G(e)}}function MO(e,t){let n=O(``),r=O(``),i=O(0),a=O(),o=O(!1),s=O(``),c=H(()=>n.value!==r.value),l=H(()=>c.value&&a.value!==t.value),u=H(()=>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=``}j(e,()=>!c.value&&d(),{immediate:!0}),j(t,()=>d());let p;return j(n,()=>{clearTimeout(p),p=setTimeout(()=>s.value=c.value?jO(n.value):``,250)}),{draft:n,dirty:c,conflict:u,deviceChanged:l,saving:o,problem:s,revision:i,reset:d,commit:f}}var NO={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},PO=[`title`],FO=[`aria-label`,`title`,`onClick`],IO={key:0,class:`count`},LO={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},RO=[`id`,`aria-selected`,`title`,`onClick`],zO={class:`tab-label`},BO={key:0,class:`count`},VO=[`title`],HO=[`aria-labelledby`],UO={class:`session-heading`},WO=[`disabled`],GO=[`disabled`],KO=[`title`],qO={class:`cwd-trail`,dir:`rtl`},JO={dir:`ltr`},YO={class:`session-status`},XO={key:0,class:`background-pill`},ZO=[`title`],QO={key:0,class:`message-error`,role:`alert`},$O=[`disabled`],ek={class:`model-section`},tk=[`src`],nk={key:0,class:`hint model-provenance`},rk={class:`thinking-row`},ik=[`value`],ak={class:`stats-section`,"aria-labelledby":`stats-title`},ok={class:`metrics`},sk=[`title`],ck={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},lk={scope:`row`},uk={class:`usage-total`},dk={class:`panel-heading`},fk={class:`hint app-state-description`},pk=[`disabled`],mk={class:`state-json-actions`},hk={key:0,class:`hint`},gk=[`disabled`],_k=[`disabled`],vk={key:0,class:`message-error`,role:`alert`},yk={key:1,class:`message-error`,role:`alert`},bk={class:`panel-heading`},xk={class:`tag`},Sk={class:`hook-card`},Ck=[`aria-checked`],wk={key:0,class:`tag tool-disabled`},Tk={class:`tag`},Ek=[`aria-label`],Dk=sf(M({__name:`Inspector`,setup(e){let t=H(()=>new Map(Sd.value?.tools.map(e=>[e.name,CO(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:bc},{id:`git`,label:`Git`,icon:Sc},{id:`host`,label:`Host`,icon:Hs},{id:`usage`,label:`Usage`,icon:Yc},{id:`auto`,label:`Auto`,icon:tc},{id:`archive`,label:`Archive`,icon:Ws},{id:`dag`,label:`DAG`,icon:_l},{id:`notify`,label:`Notify`,icon:Zs},{id:`env`,label:`Env`,icon:_c},{id:`state`,label:`State`,icon:$s},{id:`tasks`,label:`Tasks`,icon:Hs},{id:`tools`,label:`Tools`,icon:xl},{id:`extensions`,label:`Extend`,icon:$c}],r=H(()=>[{label:`Input`,tokens:vd.value.input,cost:vd.value.inputCost},{label:`Output`,tokens:vd.value.output,cost:vd.value.outputCost},{label:`Cache read`,tokens:vd.value.cacheRead,cost:vd.value.cacheReadCost},{label:`Cache write`,tokens:vd.value.cacheWrite,cost:vd.value.cacheWriteCost}]),i=H(()=>gd.value.filter(e=>e.background).length);function a(e,t){kd(async()=>{await rd.value.configure(e),await wd(),t&&J(t)})}async function o(){let e=Xu.value,t=td.value;if(e&&t)try{let n=await W(e.id).agent(t.id,K.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),J(`Transcript downloaded.`)}catch(e){J(`transcript download failed: ${G(e).slice(0,120)}`)}}let{exporting:s,error:c,run:l}=AO(H(()=>({device:Xu.value,summary:td.value}))),u=O(!1);function d(){let e=Xu.value,t=td.value;e&&t&&!u.value&&(q.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=W(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 Au.createShare({title:`${t.name} · ${e.name}`,agents:i}),o=`${location.origin}${a.url}`;await navigator.clipboard?.writeText(o).catch(()=>{}),J(`Share link copied — expires ${a.expiresAt.slice(0,10)}.`)}catch(e){J(`share failed: ${G(e).slice(0,140)}`)}finally{u.value=!1}}})}function f(){let e=id.value;e&&(q.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:td.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let p=O({});j(Xu,async e=>{if(p.value={},e)try{let{projects:t}=await W(e.id).projects(!0);p.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0});let m=H(()=>{let e=bd.value;if(!e)return!1;let t=td.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}`:Xu.value?.info?.defaultModel??``;return!!i&&i===`${e.provider}/${e.modelId}`}),h=H(()=>bd.value&&`model: ${bd.value.modelId} (${bd.value.provider})${m.value?` (default)`:``}`),g=ed.sharedState,{draft:_,dirty:v,conflict:y,deviceChanged:b,problem:x,revision:S,reset:C,commit:ee}=MO(g,Yu),w=O(!1),te=O(``);async function ne(e){if(!w.value&&rd.value){w.value=!0,te.value=``;try{await rd.value.demo(`state`,e)}catch(e){te.value=G(e)}finally{w.value=!1}}}async function re(){if(!(w.value||y.value||!rd.value)){te.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 rd.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:S.value});ee(t.value,t.revision),J(`Shared App State saved.`)}catch(e){te.value=G(e)}finally{w.value=!1}}}let ie=H(()=>Sd.value?.config.readOnly===!0),ae=H(()=>Sd.value?.tools.filter(e=>e.offered).length??0);return(e,p)=>(F(),I(`aside`,{class:E([`inspector`,{collapsed:!k(zd),overlay:k(q).inspectorOverlay}])},[k(zd)?(F(),I(P,{key:1},[R(`div`,LO,[(F(),I(P,null,N(n,e=>R(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":k(q).tab===e.id,title:e.label,class:E({active:k(q).tab===e.id}),onClick:t=>k(q).tab=e.id},[(F(),L(ei(e.icon),{size:18})),R(`span`,zO,D(e.label),1),e.id===`tasks`&&k(gd).length?(F(),I(`span`,BO,D(k(gd).length),1)):V(``,!0)],10,RO)),64)),R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${k(Gd).inspector})`,onClick:p[1]||=e=>k(Vd)()},[z(k(Wc),{size:18})],8,VO)]),R(`div`,{id:`inspector-panel`,class:E([`inspector-body`,{"session-panel":k(q).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${k(q).tab}`},[k(q).tab===`session`?(F(),I(P,{key:0},[R(`section`,UO,[R(`h1`,null,[R(`span`,null,D(k(td)?.name??`Loading session`),1),R(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:f},[z(k(Jc),{size:18})]),R(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:o},[z(k(mc),{size:18})]),R(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:k(s),onClick:p[2]||=(...e)=>k(l)&&k(l)(...e)},[z(k(Uc),{size:18})],8,WO),R(`button`,{class:`icon-button`,title:`Share a public read-only link to this transcript`,"aria-label":`Share transcript`,disabled:u.value,onClick:d},[z(k(ol),{size:18})],8,GO)]),R(`button`,{class:`path cwd-button`,title:k(td)?.cwd,"aria-label":`Show full working directory`,onClick:p[3]||=e=>k(q).dialog={kind:`path`,path:k(td)?.cwd??``}},[z(k(bc),{size:18}),R(`span`,qO,[R(`bdi`,JO,D(k(td)?.cwd),1)])],8,KO),R(`div`,YO,[R(`span`,{class:E([`status-pill`,{working:k(_d)}])},[p[10]||=R(`i`,null,null,-1),B(D(k(_d)?`Working`:`Idle`),1)],2),i.value?(F(),I(`span`,XO,D(i.value)+` background`,1)):V(``,!0),R(`span`,{class:`saved`,title:k(Xu)?.id},[z(k(al),{size:18}),B(D(k(Xu)?.name??k(Xu)?.id),1)],8,ZO),k(Xu)?(F(),L(wb,{key:1,device:k(Xu)},null,8,[`device`])):V(``,!0)]),k(c)?(F(),I(`p`,QO,[B(D(k(c))+` `,1),R(`button`,{class:`small`,disabled:k(s),onClick:p[4]||=(...e)=>k(l)&&k(l)(...e)},` retry `,8,$O)])):V(``,!0)]),k(Xu)?(F(),L(Vb,{key:0,device:k(Xu)},null,8,[`device`])):V(``,!0),R(`section`,ek,[p[18]||=R(`div`,{class:`section-label`},[R(`span`,null,`AGENT`)],-1),R(`button`,{class:`model-button`,onClick:p[5]||=e=>k(q).dialog={kind:`models`}},[R(`img`,{src:k(Nd)(k(pd).agent.model?.modelId),alt:``},null,8,tk),R(`div`,null,[R(`strong`,null,D(k(yd)?.name??k(pd).agent.model?.modelId??`Loading…`),1),R(`small`,null,D(k(yd)?.tier??``)+` / `+D(k(pd).agent.model?.provider??``),1)]),z(k(rc),{size:18})]),h.value?(F(),I(`p`,nk,D(h.value),1)):V(``,!0),R(`div`,rk,[p[11]||=R(`span`,null,`Thinking`,-1),R(`select`,{"aria-label":`Thinking level`,value:k(pd).agent.thinkingLevel??`medium`,onChange:p[6]||=e=>a({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(F(!0),I(P,null,N(k(Rv),e=>(F(),I(`option`,{key:e},D(e),1))),128))],40,ik)]),z(bO),R(`section`,ak,[p[17]||=R(`div`,{class:`section-label`},[R(`span`,{id:`stats-title`},`STATS`)],-1),R(`div`,ok,[R(`div`,{title:`${k(vd).tokens.toLocaleString(`en-US`)} total tokens`},[R(`span`,null,D(k(jd)(k(vd).tokens)),1),p[12]||=R(`small`,null,`total tokens`,-1)],8,sk),R(`div`,null,[R(`span`,null,`$`+D(k(vd).cost.toFixed(4)),1),p[13]||=R(`small`,null,`agent cost`,-1)]),R(`div`,null,[R(`span`,null,D(k(Sd)?.tools.length??0),1),p[14]||=R(`small`,null,`tools`,-1)])]),R(`table`,ck,[p[16]||=R(`thead`,null,[R(`tr`,null,[R(`th`,{scope:`col`},`Type`),R(`th`,{scope:`col`},`Tokens`),R(`th`,{scope:`col`},`Cost (USD)`)])],-1),R(`tbody`,null,[(F(!0),I(P,null,N(r.value,e=>(F(),I(`tr`,{key:e.label},[R(`th`,lk,D(e.label),1),R(`td`,null,D(e.tokens.toLocaleString(`en-US`)),1),R(`td`,null,`$`+D(e.cost.toFixed(4)),1)]))),128)),R(`tr`,uk,[p[15]||=R(`th`,{scope:`row`},`Total`,-1),R(`td`,null,D(k(vd).tokens.toLocaleString(`en-US`)),1),R(`td`,null,`$`+D(k(vd).cost.toFixed(4)),1)])])])])])],64)):V(``,!0),k(q).tab===`state`?(F(),I(P,{key:1},[R(`div`,dk,[p[19]||=R(`h2`,null,`App State`,-1),z(k($s),{size:18})]),R(`p`,fk,` One shared JSON object for every agent, session and fork on `+D(k(Xu)?.name??k(Xu)?.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),A(R(`textarea`,{"onUpdate:modelValue":p[7]||=e=>rn(_)?_.value=e:null,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:w.value||!k(g),rows:`12`},null,8,pk),[[bs,k(_)]]),p[20]||=R(`p`,{class:`hint state-limits`},` One JSON object, at most 24 levels of nesting and 100,000 characters, checked as you type. `,-1),R(`div`,mk,[k(y)?(F(),I(`span`,hk,D(k(b)?`Device changed since this draft loaded. Load the latest JSON before saving.`:`State changed elsewhere. Load the latest JSON before saving.`),1)):V(``,!0),k(v)?(F(),I(`button`,{key:1,class:`secondary`,disabled:w.value,onClick:p[8]||=(...e)=>k(C)&&k(C)(...e)},D(k(y)?`Load latest`:`Reset`),9,gk)):V(``,!0),R(`button`,{class:`primary small`,disabled:!k(v)||w.value||k(y)||!!k(x),onClick:re},D(w.value?`Saving…`:`Save JSON`),9,_k)]),k(x)?(F(),I(`p`,vk,D(k(x)),1)):V(``,!0),te.value?(F(),I(`p`,yk,D(te.value),1)):V(``,!0),z(vb,{value:k(g)?.value??{},disabled:w.value||k(v)||!k(g),onChange:ne},null,8,[`value`,`disabled`])],64)):V(``,!0),k(q).tab===`tasks`?(F(),L(vx,{key:2})):V(``,!0),k(q).tab===`git`?(F(),L(pw,{key:3})):V(``,!0),k(q).tab===`host`?(F(),L(Iw,{key:4})):V(``,!0),k(q).tab===`usage`?(F(),L(DT,{key:5})):V(``,!0),k(q).tab===`auto`?(F(),L(iE,{key:6})):V(``,!0),k(q).tab===`archive`?(F(),L(CE,{key:7})):V(``,!0),k(q).tab===`dag`?(F(),L(HE,{key:8})):V(``,!0),k(q).tab===`notify`?(F(),L(pD,{key:9})):V(``,!0),k(q).tab===`env`?(F(),L(qD,{key:10})):V(``,!0),k(q).tab===`extensions`?(F(),L(tO,{key:11})):V(``,!0),k(q).tab===`tools`?(F(),I(P,{key:12},[R(`div`,bk,[p[21]||=R(`h2`,null,`Tools`,-1),R(`span`,xk,D(ae.value)+` / `+D(k(Sd)?.tools.length??0),1)]),p[25]||=R(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),R(`div`,Sk,[R(`div`,null,[z(k(cl),{size:18}),p[23]||=R(`strong`,null,`Read only`,-1),R(`button`,{class:E([`switch`,{on:ie.value}]),role:`switch`,"aria-checked":ie.value,"aria-label":`Read only`,onClick:p[9]||=e=>a({readOnly:!ie.value},ie.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...p[22]||=[R(`span`,null,null,-1)]],10,Ck)]),p[24]||=R(`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)]),(F(!0),I(P,null,N(k(Sd)?.tools,e=>(F(),I(`details`,{key:e.name,class:E([`tool-row`,{disabled:!e.offered}])},[R(`summary`,null,[z(k(xl),{size:18}),R(`strong`,null,D(e.name),1),e.offered?V(``,!0):(F(),I(`span`,wk,`disabled`)),R(`span`,Tk,D(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),R(`p`,null,D(e.description),1),e.parameters?(F(),I(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[R(`code`,null,[(F(!0),I(P,null,N(t.value.get(e.name),(e,t)=>(F(),I(`span`,{key:t,class:E(`tk-${e.kind}`)},D(e.text),3))),128))])],8,Ek)):V(``,!0),R(`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)):V(``,!0)],10,HO)],64)):(F(),I(`div`,NO,[R(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${k(Gd).inspector})`,onClick:p[0]||=e=>k(Bd)()},[z(k(Gc),{size:18})],8,PO),(F(),I(P,null,N(n,e=>R(`button`,{key:e.id,class:E([`rail-tab`,{active:k(q).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>k(Bd)(e.id)},[(F(),L(ei(e.icon),{size:20})),e.id===`tasks`&&k(gd).length?(F(),I(`span`,IO,D(k(gd).length),1)):V(``,!0)],10,FO)),64))]))],2))}}),[[`__scopeId`,`data-v-419eb6ed`]]),Ok={class:`chat-empty`},kk={class:`eyebrow`},Ak={key:3,class:`hint offline-error`},jk={key:4,class:`offline-command`},Mk={key:5,class:`hint`},Nk={key:6,class:`hint`},Pk={class:`offline-actions`},Fk=[`disabled`],Ik={key:7,class:`message-error`,role:`alert`},Lk=M({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=O(!1),r=O(``),i=H(()=>{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 ${Pd(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 Au.check(t.device.id);e.status===`online`&&J(`${e.id} is online.`)}catch(e){r.value=G(e)}finally{n.value=!1}}async function o(e){try{await navigator.clipboard.writeText(e),J(`Copied.`)}catch{J(`Clipboard needs localhost or HTTPS. Select the text to copy.`)}}return(t,s)=>(F(),I(`section`,{class:E([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[R(`div`,Ok,[e.device.status===`checking`?(F(),L(k(Lc),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(F(),L(k(sl),{key:1,size:30})):(F(),L(k(vl),{key:2,size:30})),R(`span`,kk,D(e.device.kind.toUpperCase())+` · `+D(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),R(`h2`,null,D(i.value.title),1),R(`p`,null,D(i.value.text),1),e.device.error?(F(),I(`p`,Ak,D(e.device.error),1)):V(``,!0),i.value.command?(F(),I(`div`,jk,[R(`code`,null,D(i.value.command),1),R(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[z(k(cc),{size:18})])])):V(``,!0),i.value.command?(F(),I(`p`,Mk,`Run it in this repo's terminal, then press Check now.`)):V(``,!0),i.value.alt?(F(),I(`p`,Nk,[s[2]||=B(` Never deployed or rebuilt? `,-1),R(`code`,null,D(i.value.alt),1),s[3]||=B(` provisions it from scratch. `,-1)])):V(``,!0),R(`div`,Pk,[R(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[z(k(el),{size:18}),B(D(n.value?`Checking…`:`Check now`),1)],8,Fk)]),r.value?(F(),I(`p`,Ik,D(r.value),1)):V(``,!0)])],2))}}),Rk={class:`dir-browser`},zk={class:`dir-path`},Bk=[`disabled`],Vk=[`aria-busy`],Hk=[`title`],Uk=[`aria-selected`,`title`,`onClick`],Wk={key:1,class:`hint`},Gk={key:0,class:`message-error`,role:`alert`},Kk=M({__name:`DirBrowser`,props:ci({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Oi(e,`modelValue`),r=O(),i=O(!1),a=O(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await W(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=G(e));return}finally{s===o&&(i.value=!1)}}return j(()=>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)=>(F(),I(`div`,Rk,[R(`div`,zk,[A(R(`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]||=Ms(As(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[bs,n.value]]),R(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,Bk)]),R(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[R(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[z(k(Oc),{size:16}),t[5]||=R(`span`,null,`Start dirs`,-1)]),r.value?.parent?(F(),I(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[z(k(uc),{size:16}),t[6]||=R(`span`,null,`..`,-1)],8,Hk)):V(``,!0),(F(!0),I(P,null,N(r.value?.dirs,e=>(F(),I(`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?(F(),L(k(bc),{key:0,size:16})):(F(),L(k(xc),{key:1,size:16})),R(`span`,null,D(e.name),1)],8,Uk))),128)),r.value&&!r.value.dirs.length?(F(),I(`p`,Wk,`No subdirectories.`)):V(``,!0)],8,Vk),a.value?(F(),I(`p`,Gk,D(a.value),1)):V(``,!0)]))}}),qk={key:0,class:`message-error`},Jk=[`value`],Yk={class:`field`},Xk={key:0,class:`recent-cwds`},Zk=[`title`,`onClick`],Qk={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`},$k=[`value`],eA=[`value`],tA={key:2,class:`message-error`,role:`alert`},nA=[`disabled`],rA=`dpi-recent-cwds`,iA=sf(M({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>Hu.devices.value.filter(e=>e.status===`online`)),a=O(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=H(()=>i.value.find(e=>e.id===a.value)),s=H(()=>{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=H(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=H(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=O({name:``,cwd:``,model:``,thinking:`medium`}),f=H(()=>{try{return JSON.parse(localStorage.getItem(rA)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(rA)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(rA,JSON.stringify({...n,[e]:r}))}catch{}},m=O(!1),h=O(``),g=O({});j(a,async e=>{if(g.value={},e)try{let{projects:t}=await W(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),j([()=>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}),j(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 W(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];ad({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),J(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=G(e)}finally{m.value=!1}}}return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[7]||=As(e=>r(`close`),[`self`])},[R(`form`,{class:`modal session-modal`,onSubmit:As(_,[`prevent`])},[R(`header`,null,[t[8]||=R(`div`,null,[R(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),R(`h2`,null,`New session`)],-1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[z(k(Sl),{size:18})])]),i.value.length?(F(),I(P,{key:1},[R(`label`,null,[t[9]||=B(`Device`,-1),A(R(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(F(!0),I(P,null,N(i.value,e=>(F(),I(`option`,{key:e.id,value:e.id},D(e.name)+D(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,Jk))),128))],512),[[Cs,a.value]])]),R(`label`,null,[t[10]||=B(`Session name`,-1),A(R(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[bs,d.value.name]])]),R(`div`,Yk,[R(`span`,null,`Working directory on `+D(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(F(),I(`div`,Xk,[(F(!0),I(P,null,N(f.value,e=>(F(),I(`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,Zk))),128))])):V(``,!0),z(Kk,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),R(`label`,null,[t[11]||=B(`Model`,-1),c.value||l.value?(F(),I(`span`,Qk,`no API key on device — chat needs one`)):V(``,!0),A(R(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(F(!0),I(P,null,N(s.value,e=>(F(),I(`option`,{key:u(e),value:u(e)},D(e.tier)+` / `+D(e.name),9,$k))),128))],512),[[Cs,d.value.model]])]),R(`label`,null,[t[12]||=B(`Thinking`,-1),A(R(`select`,{"onUpdate:modelValue":t[5]||=e=>d.value.thinking=e,"aria-label":`New session thinking level`},[(F(!0),I(P,null,N(k(Rv),e=>(F(),I(`option`,{key:e,value:e},D(e),9,eA))),128))],512),[[Cs,d.value.thinking]])])],64)):(F(),I(`p`,qk,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(F(),I(`p`,tA,D(h.value),1)):V(``,!0),R(`footer`,null,[R(`button`,{type:`button`,class:`secondary`,onClick:t[6]||=e=>r(`close`)},`Cancel`),R(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[z(k(Zc),{size:18}),B(D(m.value?`Creating…`:`Create session`),1)],8,nA)])],32)]))}}),[[`__scopeId`,`data-v-95f14dc6`]]),aA=new Uint8Array(512),oA=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)aA[t]=e,oA[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)aA[e]=aA[e-255]})();var sA=(e,t)=>e===0||t===0?0:aA[oA[e]+oA[t]];function cA(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]^=sA(t[r],aA[n]);t=e}return t}function lA(e,t){let n=cA(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]^=sA(n[i+1],e)}return r}var uA=[21,25,29,33,37,41,45,49,53,57,61,65],dA=[19,34,55,80,108,136,156,194,232,274,324,370],fA=[7,10,15,20,26,36,40,48,60,72,80,96],pA=[7,10,15,20,26,18,20,24,30,18,20,24],mA=[[[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]]],hA=[[],[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]],gA=e=>e<=9?8:16;function _A(e){for(let t=1;t<=uA.length;t++)if(4+gA(t)+e*8<=dA[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${dA[11]-3})`)}function vA(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,gA(t));for(let e of n)i(e,8);let a=dA[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 yA(e,t){let n=pA[e-1],r=[],i=0;for(let[n,a]of mA[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=>lA(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function bA(e){return Array.from({length:e},()=>Array(e).fill(!1))}function xA(e,t){let n=uA[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=hA[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 SA(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 CA(e,t){let n=uA[0]*0+e.length,r=SA(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 wA(e,t,n,r){let i=e.length;uA[n-1]*uA[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>=(dA[n-1]+fA[n-1])*8){o++;continue}let t=a(o++);TA(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function TA(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=uA[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=hA[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 DA(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 OA(e,t){let n=_A(new TextEncoder().encode(e).length),r=uA[n-1],i=yA(n,vA(e,n)),a=bA(r);return xA(a,n),wA(a,i,n,t),CA(a,t),a}function kA(e,t){if(t!==void 0)return OA(e,t);let n;for(let t=0;t<8;t++){let r=OA(e,t),i=DA(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function AA(e,t=160){let n=kA(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 jA={class:`device-handoff`,"aria-label":`Pair this machine`},MA={class:`row`},NA=[`disabled`],PA=[`disabled`],FA={key:0,class:`target`,"data-testid":`device-url`},IA={key:1,class:`err`},LA=sf(M({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=O(`4780`),r=O(!1),i=H(()=>{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)=>(F(),I(`section`,jA,[R(`header`,null,[z(k(Bc),{size:18}),t[1]||=R(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=R(`p`,{class:`what`},[B(` 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 `),R(`code`,null,`dpi device`),B(` there first. `)],-1),R(`div`,MA,[R(`label`,null,[t[2]||=B(` local port `,-1),A(R(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[bs,n.value]])]),R(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[z(k(hc),{size:15}),t[3]||=B(`Open the device page `,-1)],8,NA),R(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[z(k(cc),{size:15}),B(D(r.value?`Copied`:`Copy link`),1)],8,PA)]),i.value?(F(),I(`p`,FA,D(i.value),1)):V(``,!0),i.value?V(``,!0):(F(),I(`p`,IA,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-01884b7b`]]);function RA(e){return qA(e)&&!zA(e)&&!ZA(e)&&Symbol.asyncIterator in e}function zA(e){return Array.isArray(e)}function BA(e){return typeof e==`bigint`}function VA(e){return typeof e==`boolean`}function HA(e){return e instanceof globalThis.Date}function UA(e){return typeof e==`function`}function WA(e){return qA(e)&&!zA(e)&&!ZA(e)&&Symbol.iterator in e}function GA(e){return e===null}function KA(e){return typeof e==`number`}function qA(e){return typeof e==`object`&&!!e}function JA(e){return e instanceof globalThis.RegExp}function YA(e){return typeof e==`string`}function XA(e){return typeof e==`symbol`}function ZA(e){return e instanceof globalThis.Uint8Array}function QA(e){return e===void 0}function $A(e){return e.map(e=>ij(e))}function ej(e){return new Date(e.getTime())}function tj(e){return new Uint8Array(e)}function nj(e){return new RegExp(e.source,e.flags)}function rj(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=ij(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=ij(e[n]);return t}function ij(e){return zA(e)?$A(e):HA(e)?ej(e):ZA(e)?tj(e):JA(e)?nj(e):qA(e)?rj(e):e}function aj(e){return ij(e)}function oj(e,t){return aj(t===void 0?e:{...t,...e})}function sj(e){return typeof e==`object`&&!!e}function cj(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function lj(e){return e===void 0}function uj(e){return typeof e==`number`}var dj;(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=sj(t);return e.AllowArrayObject?n:n&&!cj(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?uj(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=lj(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(dj||={});function fj(e){return globalThis.Object.freeze(e).map(e=>_j(e))}function pj(e){return e}function mj(e){return e}function hj(e){return e}function gj(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=_j(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=_j(e[n]);return globalThis.Object.freeze(t)}function _j(e){return zA(e)?fj(e):HA(e)?pj(e):ZA(e)?mj(e):JA(e)?hj(e):qA(e)?gj(e):e}function Y(e,t){let n=t===void 0?e:{...t,...e};switch(dj.InstanceMode){case`freeze`:return _j(n);case`clone`:return aj(n);default:return n}}var vj=class extends Error{constructor(e){super(e)}},yj=Symbol.for(`TypeBox.Transform`),bj=Symbol.for(`TypeBox.Readonly`),xj=Symbol.for(`TypeBox.Optional`),Sj=Symbol.for(`TypeBox.Hint`),X=Symbol.for(`TypeBox.Kind`);function Cj(e){return qA(e)&&e[bj]===`Readonly`}function wj(e){return qA(e)&&e[xj]===`Optional`}function Tj(e){return Z(e,`Any`)}function Ej(e){return Z(e,`Argument`)}function Dj(e){return Z(e,`Array`)}function Oj(e){return Z(e,`AsyncIterator`)}function kj(e){return Z(e,`BigInt`)}function Aj(e){return Z(e,`Boolean`)}function jj(e){return Z(e,`Computed`)}function Mj(e){return Z(e,`Constructor`)}function Nj(e){return Z(e,`Date`)}function Pj(e){return Z(e,`Function`)}function Fj(e){return Z(e,`Integer`)}function Ij(e){return Z(e,`Intersect`)}function Lj(e){return Z(e,`Iterator`)}function Z(e,t){return qA(e)&&X in e&&e[X]===t}function Rj(e){return VA(e)||KA(e)||YA(e)}function zj(e){return Z(e,`Literal`)}function Bj(e){return Z(e,`MappedKey`)}function Vj(e){return Z(e,`MappedResult`)}function Hj(e){return Z(e,`Never`)}function Uj(e){return Z(e,`Not`)}function Wj(e){return Z(e,`Null`)}function Gj(e){return Z(e,`Number`)}function Kj(e){return Z(e,`Object`)}function qj(e){return Z(e,`Promise`)}function Jj(e){return Z(e,`Record`)}function Yj(e){return Z(e,`Ref`)}function Xj(e){return Z(e,`RegExp`)}function Zj(e){return Z(e,`String`)}function Qj(e){return Z(e,`Symbol`)}function $j(e){return Z(e,`TemplateLiteral`)}function eM(e){return Z(e,`This`)}function tM(e){return qA(e)&&yj in e}function nM(e){return Z(e,`Tuple`)}function rM(e){return Z(e,`Undefined`)}function iM(e){return Z(e,`Union`)}function aM(e){return Z(e,`Uint8Array`)}function oM(e){return Z(e,`Unknown`)}function sM(e){return Z(e,`Unsafe`)}function cM(e){return Z(e,`Void`)}function lM(e){return qA(e)&&X in e&&YA(e[X])}function uM(e){return Tj(e)||Ej(e)||Dj(e)||Aj(e)||kj(e)||Oj(e)||jj(e)||Mj(e)||Nj(e)||Pj(e)||Fj(e)||Ij(e)||Lj(e)||zj(e)||Bj(e)||Vj(e)||Hj(e)||Uj(e)||Wj(e)||Gj(e)||Kj(e)||qj(e)||Jj(e)||Yj(e)||Xj(e)||Zj(e)||Qj(e)||$j(e)||eM(e)||nM(e)||rM(e)||iM(e)||aM(e)||oM(e)||sM(e)||cM(e)||lM(e)}var dM=`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 fM(e){try{return new RegExp(e),!0}catch{return!1}}function pM(e){if(!YA(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 mM(e){return _M(e)||pN(e)}function hM(e){return QA(e)||BA(e)}function gM(e){return QA(e)||KA(e)}function _M(e){return QA(e)||VA(e)}function vM(e){return QA(e)||YA(e)}function yM(e){return QA(e)||YA(e)&&pM(e)&&fM(e)}function bM(e){return QA(e)||YA(e)&&pM(e)}function xM(e){return QA(e)||pN(e)}function SM(e){return qA(e)&&e[xj]===`Optional`}function CM(e){return LM(e,`Any`)&&vM(e.$id)}function wM(e){return LM(e,`Argument`)&&KA(e.index)}function TM(e){return LM(e,`Array`)&&e.type===`array`&&vM(e.$id)&&pN(e.items)&&gM(e.minItems)&&gM(e.maxItems)&&_M(e.uniqueItems)&&xM(e.contains)&&gM(e.minContains)&&gM(e.maxContains)}function EM(e){return LM(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&vM(e.$id)&&pN(e.items)}function DM(e){return LM(e,`BigInt`)&&e.type===`bigint`&&vM(e.$id)&&hM(e.exclusiveMaximum)&&hM(e.exclusiveMinimum)&&hM(e.maximum)&&hM(e.minimum)&&hM(e.multipleOf)}function OM(e){return LM(e,`Boolean`)&&e.type===`boolean`&&vM(e.$id)}function kM(e){return LM(e,`Computed`)&&YA(e.target)&&zA(e.parameters)&&e.parameters.every(e=>pN(e))}function AM(e){return LM(e,`Constructor`)&&e.type===`Constructor`&&vM(e.$id)&&zA(e.parameters)&&e.parameters.every(e=>pN(e))&&pN(e.returns)}function jM(e){return LM(e,`Date`)&&e.type===`Date`&&vM(e.$id)&&gM(e.exclusiveMaximumTimestamp)&&gM(e.exclusiveMinimumTimestamp)&&gM(e.maximumTimestamp)&&gM(e.minimumTimestamp)&&gM(e.multipleOfTimestamp)}function MM(e){return LM(e,`Function`)&&e.type===`Function`&&vM(e.$id)&&zA(e.parameters)&&e.parameters.every(e=>pN(e))&&pN(e.returns)}function NM(e){return LM(e,`Integer`)&&e.type===`integer`&&vM(e.$id)&&gM(e.exclusiveMaximum)&&gM(e.exclusiveMinimum)&&gM(e.maximum)&&gM(e.minimum)&&gM(e.multipleOf)}function PM(e){return qA(e)&&Object.entries(e).every(([e,t])=>pM(e)&&pN(t))}function FM(e){return LM(e,`Intersect`)&&!(YA(e.type)&&e.type!==`object`)&&zA(e.allOf)&&e.allOf.every(e=>pN(e)&&!iN(e))&&vM(e.type)&&(_M(e.unevaluatedProperties)||xM(e.unevaluatedProperties))&&vM(e.$id)}function IM(e){return LM(e,`Iterator`)&&e.type===`Iterator`&&vM(e.$id)&&pN(e.items)}function LM(e,t){return qA(e)&&X in e&&e[X]===t}function RM(e){return VM(e)&&YA(e.const)}function zM(e){return VM(e)&&KA(e.const)}function BM(e){return VM(e)&&VA(e.const)}function VM(e){return LM(e,`Literal`)&&vM(e.$id)&&HM(e.const)}function HM(e){return VA(e)||KA(e)||YA(e)}function UM(e){return LM(e,`MappedKey`)&&zA(e.keys)&&e.keys.every(e=>KA(e)||YA(e))}function WM(e){return LM(e,`MappedResult`)&&PM(e.properties)}function GM(e){return LM(e,`Never`)&&qA(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function KM(e){return LM(e,`Not`)&&pN(e.not)}function qM(e){return LM(e,`Null`)&&e.type===`null`&&vM(e.$id)}function JM(e){return LM(e,`Number`)&&e.type===`number`&&vM(e.$id)&&gM(e.exclusiveMaximum)&&gM(e.exclusiveMinimum)&&gM(e.maximum)&&gM(e.minimum)&&gM(e.multipleOf)}function YM(e){return LM(e,`Object`)&&e.type===`object`&&vM(e.$id)&&PM(e.properties)&&mM(e.additionalProperties)&&gM(e.minProperties)&&gM(e.maxProperties)}function XM(e){return LM(e,`Promise`)&&e.type===`Promise`&&vM(e.$id)&&pN(e.item)}function ZM(e){return LM(e,`Record`)&&e.type===`object`&&vM(e.$id)&&mM(e.additionalProperties)&&qA(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&fM(t[0])&&qA(e.patternProperties)&&pN(e.patternProperties[t[0]])})(e)}function QM(e){return LM(e,`Ref`)&&vM(e.$id)&&YA(e.$ref)}function $M(e){return LM(e,`RegExp`)&&vM(e.$id)&&YA(e.source)&&YA(e.flags)&&gM(e.maxLength)&&gM(e.minLength)}function eN(e){return LM(e,`String`)&&e.type===`string`&&vM(e.$id)&&gM(e.minLength)&&gM(e.maxLength)&&yM(e.pattern)&&bM(e.format)}function tN(e){return LM(e,`Symbol`)&&e.type===`symbol`&&vM(e.$id)}function nN(e){return LM(e,`TemplateLiteral`)&&e.type===`string`&&YA(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function rN(e){return LM(e,`This`)&&vM(e.$id)&&YA(e.$ref)}function iN(e){return qA(e)&&yj in e}function aN(e){return LM(e,`Tuple`)&&e.type===`array`&&vM(e.$id)&&KA(e.minItems)&&KA(e.maxItems)&&e.minItems===e.maxItems&&(QA(e.items)&&QA(e.additionalItems)&&e.minItems===0||zA(e.items)&&e.items.every(e=>pN(e)))}function oN(e){return LM(e,`Undefined`)&&e.type===`undefined`&&vM(e.$id)}function sN(e){return LM(e,`Union`)&&vM(e.$id)&&qA(e)&&zA(e.anyOf)&&e.anyOf.every(e=>pN(e))}function cN(e){return LM(e,`Uint8Array`)&&e.type===`Uint8Array`&&vM(e.$id)&&gM(e.minByteLength)&&gM(e.maxByteLength)}function lN(e){return LM(e,`Unknown`)&&vM(e.$id)}function uN(e){return LM(e,`Unsafe`)}function dN(e){return LM(e,`Void`)&&e.type===`void`&&vM(e.$id)}function fN(e){return qA(e)&&X in e&&YA(e[X])&&!dM.includes(e[X])}function pN(e){return qA(e)&&(CM(e)||wM(e)||TM(e)||OM(e)||DM(e)||EM(e)||kM(e)||AM(e)||jM(e)||MM(e)||NM(e)||FM(e)||IM(e)||VM(e)||UM(e)||WM(e)||GM(e)||KM(e)||qM(e)||JM(e)||YM(e)||XM(e)||ZM(e)||QM(e)||$M(e)||eN(e)||tN(e)||nN(e)||rN(e)||aN(e)||oN(e)||sN(e)||cN(e)||lN(e)||uN(e)||dN(e)||fN(e))}var mN=`(true|false)`,hN=`(0|[1-9][0-9]*)`,gN=`(.*)`,_N=`(?!.*)`;`${mN}`;var vN=`^${hN}$`,yN=`^${gN}$`,bN=`^${_N}$`;function xN(e,t){return e.includes(t)}function SN(e){return[...new Set(e)]}function CN(e,t){return e.filter(e=>t.includes(e))}function wN(e,t){return e.reduce((e,t)=>CN(e,t),t)}function TN(e){return e.length===1?e[0]:e.length>1?wN(e.slice(1),e[0]):[]}function EN(e){let t=[];for(let n of e)t.push(...n);return t}function DN(e){return Y({[X]:`Any`},e)}function ON(e,t){return Y({[X]:`Array`,type:`array`,items:e},t)}function kN(e){return Y({[X]:`Argument`,index:e})}function AN(e,t){return Y({[X]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function jN(e,t,n){return Y({[X]:`Computed`,target:e,parameters:t},n)}function MN(e,t){let{[t]:n,...r}=e;return r}function NN(e,t){return t.reduce((e,t)=>MN(e,t),e)}function PN(e){return Y({[X]:`Never`,not:{}},e)}function FN(e){return Y({[X]:`MappedResult`,properties:e})}function IN(e,t,n){return Y({[X]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function LN(e,t,n){return Y({[X]:`Function`,type:`Function`,parameters:e,returns:t},n)}function RN(e,t){return Y({[X]:`Union`,anyOf:e},t)}function zN(e){return e.some(e=>wj(e))}function BN(e){return e.map(e=>wj(e)?VN(e):e)}function VN(e){return NN(e,[xj])}function HN(e,t){return zN(e)?OF(RN(BN(e),t)):RN(BN(e),t)}function UN(e,t){return e.length===1?Y(e[0],t):e.length===0?PN(t):HN(e,t)}function WN(e,t){return e.length===0?PN(t):e.length===1?Y(e[0],t):RN(e,t)}var GN=class extends vj{};function KN(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function qN(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function JN(e,t){return qN(e,t,`(`)}function YN(e,t){return qN(e,t,`)`)}function XN(e,t){return qN(e,t,`|`)}function ZN(e){if(!(JN(e,0)&&YN(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(JN(e,n)&&(t+=1),YN(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function QN(e){return e.slice(1,e.length-1)}function $N(e){let t=0;for(let n=0;n<e.length;n++)if(JN(e,n)&&(t+=1),YN(e,n)&&--t,XN(e,n)&&t===0)return!0;return!1}function eP(e){for(let t=0;t<e.length;t++)if(JN(e,t))return!0;return!1}function tP(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(JN(e,i)&&(t+=1),YN(e,i)&&--t,XN(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(rP(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(rP(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function nP(e){function t(e,t){if(!JN(e,t))throw new GN(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(JN(e,r)&&(n+=1),YN(e,r)&&--n,n===0)return[t,r];throw new GN(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(JN(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(JN(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(rP(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(rP(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function rP(e){return ZN(e)?rP(QN(e)):$N(e)?tP(e):eP(e)?nP(e):{type:`const`,const:KN(e)}}function iP(e){return rP(e.slice(1,e.length-1))}var aP=class extends vj{};function oP(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 sP(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 cP(e){return e.type===`const`&&e.const===`.*`}function lP(e){return oP(e)||cP(e)?!1:sP(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>lP(e)):e.type===`const`||(()=>{throw new aP(`Unknown expression type`)})()}function uP(e){return lP(iP(e.pattern))}var dP=class extends vj{};function*fP(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of fP(e.slice(1)))yield`${t}${n}`}function*pP(e){return yield*fP(e.expr.map(e=>[...gP(e)]))}function*mP(e){for(let t of e.expr)yield*gP(t)}function*hP(e){return yield e.const}function*gP(e){return e.type===`and`?yield*pP(e):e.type===`or`?yield*mP(e):e.type===`const`?yield*hP(e):(()=>{throw new dP(`Unknown expression`)})()}function _P(e){let t=iP(e.pattern);return lP(t)?[...gP(t)]:[]}function vP(e,t){return Y({[X]:`Literal`,const:e,type:typeof e},t)}function yP(e){return Y({[X]:`Boolean`,type:`boolean`},e)}function bP(e){return Y({[X]:`BigInt`,type:`bigint`},e)}function xP(e){return Y({[X]:`Number`,type:`number`},e)}function SP(e){return Y({[X]:`String`,type:`string`},e)}function*CP(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield yP():t===`number`?yield xP():t===`bigint`?yield bP():t===`string`?yield SP():yield(()=>{let e=t.split(`|`).map(e=>vP(e.trim()));return e.length===0?PN():e.length===1?e[0]:UN(e)})()}function*wP(e){if(e[1]!==`{`)return yield*[vP(`$`),...TP(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=CP(e.slice(2,t)),r=TP(e.slice(t+1));return yield*[...n,...r]}yield vP(e)}function*TP(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[vP(e.slice(0,t)),...wP(e.slice(t))];yield vP(e)}function EP(e){return[...TP(e)]}var DP=class extends vj{};function OP(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function kP(e,t){return $j(e)?e.pattern.slice(1,e.pattern.length-1):iM(e)?`(${e.anyOf.map(e=>kP(e,t)).join(`|`)})`:Gj(e)||Fj(e)||kj(e)?`${t}${hN}`:Zj(e)?`${t}${gN}`:zj(e)?`${t}${OP(e.const.toString())}`:Aj(e)?`${t}${mN}`:(()=>{throw new DP(`Unexpected Kind '${e[X]}'`)})()}function AP(e){return`^${e.map(e=>kP(e,``)).join(``)}$`}function jP(e){return UN(_P(e).map(e=>vP(e)))}function MP(e,t){let n=YA(e)?AP(EP(e)):AP(e);return Y({[X]:`TemplateLiteral`,type:`string`,pattern:n},t)}function NP(e){return _P(e).map(e=>e.toString())}function PP(e){let t=[];for(let n of e)t.push(...IP(n));return t}function FP(e){return[e.toString()]}function IP(e){return[...new Set($j(e)?NP(e):iM(e)?PP(e.anyOf):zj(e)?FP(e.const):Gj(e)||Fj(e)?[`[number]`]:[])]}function LP(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=ZP(e,IP(t[i]),n);return r}function RP(e,t,n){return LP(e,t.properties,n)}function zP(e,t,n){return FN(RP(e,t,n))}function BP(e,t){return e.map(e=>JP(e,t))}function VP(e){return e.filter(e=>!Hj(e))}function HP(e,t){return LF(VP(BP(e,t)))}function UP(e){return e.some(e=>Hj(e))?[]:e}function WP(e,t){return UN(UP(BP(e,t)))}function GP(e,t){return t in e?e[t]:t===`[number]`?UN(e):PN()}function KP(e,t){return t===`[number]`?e:PN()}function qP(e,t){return t in e?e[t]:PN()}function JP(e,t){return Ij(e)?HP(e.allOf,t):iM(e)?WP(e.anyOf,t):nM(e)?GP(e.items??[],t):Dj(e)?KP(e.items,t):Kj(e)?qP(e.properties,t):PN()}function YP(e,t){return t.map(t=>JP(e,t))}function XP(e,t){return UN(YP(e,t))}function ZP(e,t,n){if(Yj(e)||Yj(t)){if(!uM(e)||!uM(t))throw new vj(`Index types using Ref parameters require both Type and Key to be of TSchema`);return jN(`Index`,[e,t])}return Vj(t)?zP(e,t,n):Bj(t)?tF(e,t,n):Y(uM(t)?XP(e,IP(t)):XP(e,t),n)}function QP(e,t,n){return{[t]:ZP(e,[t],aj(n))}}function $P(e,t,n){return t.reduce((t,r)=>({...t,...QP(e,r,n)}),{})}function eF(e,t,n){return $P(e,t.keys,n)}function tF(e,t,n){return FN(eF(e,t,n))}function nF(e,t){return Y({[X]:`Iterator`,type:`Iterator`,items:e},t)}function rF(e){return globalThis.Object.keys(e).filter(t=>!wj(e[t]))}function iF(e,t){let n=rF(e);return Y(n.length>0?{[X]:`Object`,type:`object`,required:n,properties:e}:{[X]:`Object`,type:`object`,properties:e},t)}var aF=iF;function oF(e,t){return Y({[X]:`Promise`,type:`Promise`,item:e},t)}function sF(e){return Y(NN(e,[bj]))}function cF(e){return Y({...e,[bj]:`Readonly`})}function lF(e,t){return t===!1?sF(e):cF(e)}function uF(e,t){let n=t??!0;return Vj(e)?pF(e,n):lF(e,n)}function dF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=uF(e[r],t);return n}function fF(e,t){return dF(e.properties,t)}function pF(e,t){return FN(fF(e,t))}function mF(e,t){return Y(e.length>0?{[X]:`Tuple`,type:`array`,items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[X]:`Tuple`,type:`array`,minItems:e.length,maxItems:e.length},t)}function hF(e,t){return e in t?SF(e,t[e]):FN(t)}function gF(e){return{[e]:vP(e)}}function _F(e){let t={};for(let n of e)t[n]=vP(n);return t}function vF(e,t){return xN(t,e)?gF(e):_F(t)}function yF(e,t){return hF(e,vF(e,t))}function bF(e,t){return t.map(t=>SF(e,t))}function xF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=SF(e,t[r]);return n}function SF(e,t){let n={...t};return wj(t)?OF(SF(e,NN(t,[xj]))):Cj(t)?uF(SF(e,NN(t,[bj]))):Vj(t)?hF(e,t.properties):Bj(t)?yF(e,t.keys):Mj(t)?IN(bF(e,t.parameters),SF(e,t.returns),n):Pj(t)?LN(bF(e,t.parameters),SF(e,t.returns),n):Oj(t)?AN(SF(e,t.items),n):Lj(t)?nF(SF(e,t.items),n):Ij(t)?RF(bF(e,t.allOf),n):iM(t)?WN(bF(e,t.anyOf),n):nM(t)?mF(bF(e,t.items??[]),n):Kj(t)?aF(xF(e,t.properties),n):Dj(t)?ON(SF(e,t.items),n):qj(t)?oF(SF(e,t.item),n):t}function CF(e,t){let n={};for(let r of e)n[r]=SF(r,t);return n}function wF(e,t,n){let r=uM(e)?IP(e):e;return aF(CF(r,t({[X]:`MappedKey`,keys:r})),n)}function TF(e){return Y(NN(e,[xj]))}function EF(e){return Y({...e,[xj]:`Optional`})}function DF(e,t){return t===!1?TF(e):EF(e)}function OF(e,t){let n=t??!0;return Vj(e)?jF(e,n):DF(e,n)}function kF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=OF(e[r],t);return n}function AF(e,t){return kF(e.properties,t)}function jF(e,t){return FN(AF(e,t))}function MF(e,t={}){let n=e.every(e=>Kj(e)),r=uM(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return Y(t.unevaluatedProperties===!1||uM(t.unevaluatedProperties)||n?{...r,[X]:`Intersect`,type:`object`,allOf:e}:{...r,[X]:`Intersect`,allOf:e},t)}function NF(e){return e.every(e=>wj(e))}function PF(e){return NN(e,[xj])}function FF(e){return e.map(e=>wj(e)?PF(e):e)}function IF(e,t){return NF(e)?OF(MF(FF(e),t)):MF(FF(e),t)}function LF(e,t={}){if(e.length===1)return Y(e[0],t);if(e.length===0)return PN(t);if(e.some(e=>tM(e)))throw Error(`Cannot intersect transform types`);return IF(e,t)}function RF(e,t){if(e.length===1)return Y(e[0],t);if(e.length===0)return PN(t);if(e.some(e=>tM(e)))throw Error(`Cannot intersect transform types`);return MF(e,t)}function zF(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new vj(`Ref: $ref must be a string`);return Y({[X]:`Ref`,$ref:t},n)}function BF(e,t){return jN(`Awaited`,[jN(e,t)])}function VF(e){return jN(`Awaited`,[zF(e)])}function HF(e){return RF(GF(e))}function UF(e){return WN(GF(e))}function WF(e){return KF(e)}function GF(e){return e.map(e=>KF(e))}function KF(e,t){return Y(jj(e)?BF(e.target,e.parameters):Ij(e)?HF(e.allOf):iM(e)?UF(e.anyOf):qj(e)?WF(e.item):Yj(e)?VF(e.$ref):e,t)}function qF(e){let t=[];for(let n of e)t.push(eI(n));return t}function JF(e){return EN(qF(e))}function YF(e){return TN(qF(e))}function XF(e){return e.map((e,t)=>t.toString())}function ZF(e){return[`[number]`]}function QF(e){return globalThis.Object.getOwnPropertyNames(e)}function $F(e){return tI?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function eI(e){return Ij(e)?JF(e.allOf):iM(e)?YF(e.anyOf):nM(e)?XF(e.items??[]):Dj(e)?ZF(e.items):Kj(e)?QF(e.properties):Jj(e)?$F(e.patternProperties):[]}var tI=!1;function nI(e,t){return jN(`KeyOf`,[jN(e,t)])}function rI(e){return jN(`KeyOf`,[zF(e)])}function iI(e,t){return Y(UN(aI(eI(e))),t)}function aI(e){return e.map(e=>e===`[number]`?xP():vP(e))}function oI(e,t){return jj(e)?nI(e.target,e.parameters):Yj(e)?rI(e.$ref):Vj(e)?lI(e,t):iI(e,t)}function sI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=oI(e[r],aj(t));return n}function cI(e,t){return sI(e.properties,t)}function lI(e,t){return FN(cI(e,t))}function uI(e){let t=[];for(let n of e)t.push(...eI(n));return SN(t)}function dI(e){return e.filter(e=>!Hj(e))}function fI(e,t){let n=[];for(let r of e)n.push(...YP(r,[t]));return dI(n)}function pI(e,t){let n={};for(let r of t)n[r]=LF(fI(e,r));return n}function mI(e,t){return aF(pI(e,uI(e)),t)}function hI(e){return Y({[X]:`Date`,type:`Date`},e)}function gI(e){return Y({[X]:`Null`,type:`null`},e)}function _I(e){return Y({[X]:`Symbol`,type:`symbol`},e)}function vI(e){return Y({[X]:`Undefined`,type:`undefined`},e)}function yI(e){return Y({[X]:`Uint8Array`,type:`Uint8Array`},e)}function bI(e){return Y({[X]:`Unknown`},e)}function xI(e){return e.map(e=>wI(e,!1))}function SI(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=uF(wI(e[n],!1));return t}function CI(e,t){return t===!0?e:uF(e)}function wI(e,t){return RA(e)||WA(e)?CI(DN(),t):zA(e)?uF(mF(xI(e))):ZA(e)?yI():HA(e)?hI():qA(e)?CI(aF(SI(e)),t):UA(e)?CI(LN([],bI()),t):QA(e)?vI():GA(e)?gI():XA(e)?_I():BA(e)?bP():KA(e)||VA(e)||YA(e)?vP(e):aF({})}function TI(e,t){return Y(wI(e,!0),t)}function EI(e,t){return Mj(e)?mF(e.parameters,t):PN(t)}function DI(e,t){if(QA(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return WN([...new Set(n)].map(e=>vP(e)),{...t,[Sj]:`Enum`})}var OI=class extends vj{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function kI(e){return e===Q.False?e:Q.True}function AI(e){throw new OI(e)}function jI(e){return GM(e)||FM(e)||sN(e)||lN(e)||CM(e)}function MI(e,t){return GM(t)?XI(e,t):FM(t)?KI(e,t):sN(t)?NL(e,t):lN(t)?FL(e,t):CM(t)?NI(e,t):AI(`StructuralRight`)}function NI(e,t){return Q.True}function PI(e,t){return FM(t)?KI(e,t):sN(t)&&t.anyOf.some(e=>CM(e)||lN(e))?Q.True:sN(t)?Q.Union:lN(t)||CM(t)?Q.True:Q.Union}function FI(e,t){return lN(e)?Q.False:CM(e)?Q.Union:GM(e)?Q.True:Q.False}function II(e,t){return YM(t)&&pL(t)?Q.True:jI(t)?MI(e,t):TM(t)?kI(zL(e.items,t.items)):Q.False}function LI(e,t){return jI(t)?MI(e,t):EM(t)?kI(zL(e.items,t.items)):Q.False}function RI(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):DM(t)?Q.True:Q.False}function zI(e,t){return BM(e)||OM(e)?Q.True:Q.False}function BI(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):OM(t)?Q.True:Q.False}function VI(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):AM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>kI(zL(t.parameters[n],e))===Q.True)?kI(zL(e.returns,t.returns)):Q.False:Q.False}function HI(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):jM(t)?Q.True:Q.False}function UI(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):MM(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>kI(zL(t.parameters[n],e))===Q.True)?kI(zL(e.returns,t.returns)):Q.False:Q.False}function WI(e,t){return VM(e)&&KA(e.const)||JM(e)||NM(e)?Q.True:Q.False}function GI(e,t){return NM(t)||JM(t)?Q.True:jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):Q.False}function KI(e,t){return t.allOf.every(t=>zL(e,t)===Q.True)?Q.True:Q.False}function qI(e,t){return e.allOf.some(e=>zL(e,t)===Q.True)?Q.True:Q.False}function JI(e,t){return jI(t)?MI(e,t):IM(t)?kI(zL(e.items,t.items)):Q.False}function YI(e,t){return VM(t)&&t.const===e.const?Q.True:jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):eN(t)?wL(e,t):JM(t)?tL(e,t):NM(t)?WI(e,t):OM(t)?zI(e,t):Q.False}function XI(e,t){return Q.False}function ZI(e,t){return Q.True}function QI(e){let[t,n]=[e,0];for(;KM(t);)t=t.not,n+=1;return n%2==0?t:bI()}function $I(e,t){return KM(e)?zL(QI(e),t):KM(t)?zL(e,QI(t)):AI(`Invalid fallthrough for Not`)}function eL(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):qM(t)?Q.True:Q.False}function tL(e,t){return zM(e)||JM(e)||NM(e)?Q.True:Q.False}function nL(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):NM(t)||JM(t)?Q.True:Q.False}function rL(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function iL(e){return pL(e)}function aL(e){return rL(e,0)||rL(e,1)&&`description`in e.properties&&sN(e.properties.description)&&e.properties.description.anyOf.length===2&&(eN(e.properties.description.anyOf[0])&&oN(e.properties.description.anyOf[1])||eN(e.properties.description.anyOf[1])&&oN(e.properties.description.anyOf[0]))}function oL(e){return rL(e,0)}function sL(e){return rL(e,0)}function cL(e){return rL(e,0)}function lL(e){return rL(e,0)}function uL(e){return pL(e)}function dL(e){let t=xP();return rL(e,0)||rL(e,1)&&`length`in e.properties&&kI(zL(e.properties.length,t))===Q.True}function fL(e){return rL(e,0)}function pL(e){let t=xP();return rL(e,0)||rL(e,1)&&`length`in e.properties&&kI(zL(e.properties.length,t))===Q.True}function mL(e){let t=LN([DN()],DN());return rL(e,0)||rL(e,1)&&`then`in e.properties&&kI(zL(e.properties.then,t))===Q.True}function hL(e,t){return zL(e,t)===Q.False||SM(e)&&!SM(t)?Q.False:Q.True}function gL(e,t){return lN(e)?Q.False:CM(e)?Q.Union:GM(e)||RM(e)&&iL(t)||zM(e)&&oL(t)||BM(e)&&sL(t)||tN(e)&&aL(t)||DM(e)&&cL(t)||eN(e)&&iL(t)||tN(e)&&aL(t)||JM(e)&&oL(t)||NM(e)&&oL(t)||OM(e)&&sL(t)||cN(e)&&uL(t)||jM(e)&&lL(t)||AM(e)&&fL(t)||MM(e)&&dL(t)?Q.True:ZM(e)&&eN(yL(e))?t[Sj]===`Record`?Q.True:Q.False:ZM(e)&&JM(yL(e))&&rL(t,0)?Q.True:Q.False}function _L(e,t){return jI(t)?MI(e,t):ZM(t)?xL(e,t):YM(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!SM(t.properties[n]))return Q.False;if(SM(t.properties[n]))return Q.True;if(hL(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function vL(e,t){return jI(t)?MI(e,t):YM(t)&&mL(t)?Q.True:XM(t)?kI(zL(e.item,t.item)):Q.False}function yL(e){return vN in e.patternProperties?xP():yN in e.patternProperties?SP():AI(`Unknown record key pattern`)}function bL(e){return vN in e.patternProperties?e.patternProperties[vN]:yN in e.patternProperties?e.patternProperties[yN]:AI(`Unable to get record value schema`)}function xL(e,t){let[n,r]=[yL(t),bL(t)];return RM(e)&&JM(n)&&kI(zL(e,r))===Q.True?Q.True:cN(e)&&JM(n)||eN(e)&&JM(n)||TM(e)&&JM(n)?zL(e,r):YM(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(hL(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function SL(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?zL(bL(e),bL(t)):Q.False}function CL(e,t){return zL($M(e)?SP():e,$M(t)?SP():t)}function wL(e,t){return VM(e)&&YA(e.const)||eN(e)?Q.True:Q.False}function TL(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):eN(t)?Q.True:Q.False}function EL(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):tN(t)?Q.True:Q.False}function DL(e,t){return nN(e)?zL(jP(e),t):nN(t)?zL(e,jP(t)):AI(`Invalid fallthrough for TemplateLiteral`)}function OL(e,t){return TM(t)&&e.items!==void 0&&e.items.every(e=>zL(e,t.items)===Q.True)}function kL(e,t){return GM(e)?Q.True:lN(e)?Q.False:CM(e)?Q.Union:Q.False}function AL(e,t){return jI(t)?MI(e,t):YM(t)&&pL(t)||TM(t)&&OL(e,t)?Q.True:aN(t)?QA(e.items)&&!QA(t.items)||!QA(e.items)&&QA(t.items)?Q.False:QA(e.items)&&!QA(t.items)||e.items.every((e,n)=>zL(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function jL(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):cN(t)?Q.True:Q.False}function ML(e,t){return jI(t)?MI(e,t):YM(t)?gL(e,t):ZM(t)?xL(e,t):dN(t)?LL(e,t):oN(t)?Q.True:Q.False}function NL(e,t){return t.anyOf.some(t=>zL(e,t)===Q.True)?Q.True:Q.False}function PL(e,t){return e.anyOf.every(e=>zL(e,t)===Q.True)?Q.True:Q.False}function FL(e,t){return Q.True}function IL(e,t){return GM(t)?XI(e,t):FM(t)?KI(e,t):sN(t)?NL(e,t):CM(t)?NI(e,t):eN(t)?wL(e,t):JM(t)?tL(e,t):NM(t)?WI(e,t):OM(t)?zI(e,t):TM(t)?FI(e,t):aN(t)?kL(e,t):YM(t)?gL(e,t):lN(t)?Q.True:Q.False}function LL(e,t){return oN(e)||oN(e)?Q.True:Q.False}function RL(e,t){return FM(t)?KI(e,t):sN(t)?NL(e,t):lN(t)?FL(e,t):CM(t)?NI(e,t):YM(t)?gL(e,t):dN(t)?Q.True:Q.False}function zL(e,t){return nN(e)||nN(t)?DL(e,t):$M(e)||$M(t)?CL(e,t):KM(e)||KM(t)?$I(e,t):CM(e)?PI(e,t):TM(e)?II(e,t):DM(e)?RI(e,t):OM(e)?BI(e,t):EM(e)?LI(e,t):AM(e)?VI(e,t):jM(e)?HI(e,t):MM(e)?UI(e,t):NM(e)?GI(e,t):FM(e)?qI(e,t):IM(e)?JI(e,t):VM(e)?YI(e,t):GM(e)?ZI(e,t):qM(e)?eL(e,t):JM(e)?nL(e,t):YM(e)?_L(e,t):ZM(e)?SL(e,t):eN(e)?TL(e,t):tN(e)?EL(e,t):aN(e)?AL(e,t):XM(e)?vL(e,t):cN(e)?jL(e,t):oN(e)?ML(e,t):sN(e)?PL(e,t):lN(e)?IL(e,t):dN(e)?RL(e,t):AI(`Unknown left type operand '${e[X]}'`)}function BL(e,t){return zL(e,t)}function VL(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=GL(e[o],t,n,r,aj(i));return a}function HL(e,t,n,r,i){return VL(e.properties,t,n,r,i)}function UL(e,t,n,r,i){return FN(HL(e,t,n,r,i))}function WL(e,t,n,r){let i=BL(e,t);return i===Q.Union?WN([n,r]):i===Q.True?n:r}function GL(e,t,n,r,i){return Vj(e)?UL(e,t,n,r,i):Bj(e)?Y(YL(e,t,n,r,i)):Y(WL(e,t,n,r),i)}function KL(e,t,n,r,i){return{[e]:GL(vP(e),t,n,r,aj(i))}}function qL(e,t,n,r,i){return e.reduce((e,a)=>({...e,...KL(a,t,n,r,i)}),{})}function JL(e,t,n,r,i){return qL(e.keys,t,n,r,i)}function YL(e,t,n,r,i){return FN(JL(e,t,n,r,i))}function XL(e,t){return QL(jP(e),t)}function ZL(e,t){let n=e.filter(e=>BL(e,t)===Q.False);return n.length===1?n[0]:WN(n)}function QL(e,t,n={}){return $j(e)?Y(XL(e,t),n):Vj(e)?Y(tR(e,t),n):Y(iM(e)?ZL(e.anyOf,t):BL(e,t)===Q.False?e:PN(),n)}function $L(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=QL(e[r],t);return n}function eR(e,t){return $L(e.properties,t)}function tR(e,t){return FN(eR(e,t))}function nR(e,t){return iR(jP(e),t)}function rR(e,t){let n=e.filter(e=>BL(e,t)!==Q.False);return n.length===1?n[0]:WN(n)}function iR(e,t,n){return $j(e)?Y(nR(e,t),n):Vj(e)?Y(sR(e,t),n):Y(iM(e)?rR(e.anyOf,t):BL(e,t)===Q.False?PN():e,n)}function aR(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=iR(e[r],t);return n}function oR(e,t){return aR(e.properties,t)}function sR(e,t){return FN(oR(e,t))}function cR(e,t){return Mj(e)?Y(e.returns,t):PN(t)}function lR(e){return uF(OF(e))}function uR(e,t,n){return Y({[X]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function dR(e,t,n){let r={};for(let n of e)r[n]=t;return aF(r,{...n,[Sj]:`Record`})}function fR(e,t,n){return uP(e)?dR(IP(e),t,n):uR(e.pattern,t,n)}function pR(e,t,n){return dR(IP(WN(e)),t,n)}function mR(e,t,n){return dR([e.toString()],t,n)}function hR(e,t,n){return uR(e.source,t,n)}function gR(e,t,n){return uR(QA(e.pattern)?yN:e.pattern,t,n)}function _R(e,t,n){return uR(yN,t,n)}function vR(e,t,n){return uR(bN,t,n)}function yR(e,t,n){return aF({true:t,false:t},n)}function bR(e,t,n){return uR(vN,t,n)}function xR(e,t,n){return uR(vN,t,n)}function SR(e,t,n={}){return iM(e)?pR(e.anyOf,t,n):$j(e)?fR(e,t,n):zj(e)?mR(e.const,t,n):Aj(e)?yR(e,t,n):Fj(e)?bR(e,t,n):Gj(e)?xR(e,t,n):Xj(e)?hR(e,t,n):Zj(e)?gR(e,t,n):Tj(e)?_R(e,t,n):Hj(e)?vR(e,t,n):PN(n)}function CR(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function wR(e){let t=CR(e);return t===yN?SP():t===vN?xP():SP({pattern:t})}function TR(e){return e.patternProperties[CR(e)]}function ER(e,t){return t.parameters=BR(e,t.parameters),t.returns=VR(e,t.returns),t}function DR(e,t){return t.parameters=BR(e,t.parameters),t.returns=VR(e,t.returns),t}function OR(e,t){return t.allOf=BR(e,t.allOf),t}function kR(e,t){return t.anyOf=BR(e,t.anyOf),t}function AR(e,t){return QA(t.items)||(t.items=BR(e,t.items)),t}function jR(e,t){return t.items=VR(e,t.items),t}function MR(e,t){return t.items=VR(e,t.items),t}function NR(e,t){return t.items=VR(e,t.items),t}function PR(e,t){return t.item=VR(e,t.item),t}function FR(e,t){let n=zR(e,t.properties);return{...t,...aF(n)}}function IR(e,t){let n=SR(VR(e,wR(t)),VR(e,TR(t)));return{...t,...n}}function LR(e,t){return t.index in e?e[t.index]:bI()}function RR(e,t){let n=Cj(t),r=wj(t),i=VR(e,t);return n&&r?lR(i):n&&!r?uF(i):!n&&r?OF(i):i}function zR(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:RR(e,t[r])}),{})}function BR(e,t){return t.map(t=>VR(e,t))}function VR(e,t){return Mj(t)?ER(e,t):Pj(t)?DR(e,t):Ij(t)?OR(e,t):iM(t)?kR(e,t):nM(t)?AR(e,t):Dj(t)?jR(e,t):Oj(t)?MR(e,t):Lj(t)?NR(e,t):qj(t)?PR(e,t):Kj(t)?FR(e,t):Jj(t)?IR(e,t):Ej(t)?LR(e,t):t}function HR(e,t){return VR(t,oj(e))}function UR(e){return Y({[X]:`Integer`,type:`integer`},e)}function WR(e,t,n){return{[e]:tz(vP(e),t,aj(n))}}function GR(e,t,n){return e.reduce((e,r)=>({...e,...WR(r,t,n)}),{})}function KR(e,t,n){return GR(e.keys,t,n)}function qR(e,t,n){return FN(KR(e,t,n))}function JR(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function YR(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function XR(e){return e.toUpperCase()}function ZR(e){return e.toLowerCase()}function QR(e,t,n){let r=iP(e.pattern);return lP(r)?MP([WN(ez([...gP(r)].map(e=>vP(e)),t))],n):{...e,pattern:$R(e.pattern,t)}}function $R(e,t){return typeof e==`string`?t===`Uncapitalize`?JR(e):t===`Capitalize`?YR(e):t===`Uppercase`?XR(e):t===`Lowercase`?ZR(e):e:e.toString()}function ez(e,t){return e.map(e=>tz(e,t))}function tz(e,t,n={}){return Bj(e)?qR(e,t,n):$j(e)?QR(e,t,n):iM(e)?WN(ez(e.anyOf,t),n):zj(e)?vP($R(e.const,t),n):Y(e,n)}function nz(e,t={}){return tz(e,`Capitalize`,t)}function rz(e,t={}){return tz(e,`Lowercase`,t)}function iz(e,t={}){return tz(e,`Uncapitalize`,t)}function az(e,t={}){return tz(e,`Uppercase`,t)}function oz(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=gz(e[i],t,aj(n));return r}function sz(e,t,n){return oz(e.properties,t,n)}function cz(e,t,n){return FN(sz(e,t,n))}function lz(e,t){return e.map(e=>hz(e,t))}function uz(e,t){return e.map(e=>hz(e,t))}function dz(e,t){let{[t]:n,...r}=e;return r}function fz(e,t){return t.reduce((e,t)=>dz(e,t),e)}function pz(e,t,n){let r=NN(e,[yj,`$id`,`required`,`properties`]);return aF(fz(n,t),r)}function mz(e){return WN(e.reduce((e,t)=>Rj(t)?[...e,vP(t)]:e,[]))}function hz(e,t){return Ij(e)?RF(lz(e.allOf,t)):iM(e)?WN(uz(e.anyOf,t)):Kj(e)?pz(e,t,e.properties):aF({})}function gz(e,t,n){let r=zA(t)?mz(t):t,i=uM(t)?IP(t):t,a=Yj(e),o=Yj(t);return Vj(e)?cz(e,i,n):Bj(t)?bz(e,t,n):a&&o||!a&&o||a&&!o?jN(`Omit`,[e,r],n):Y({...hz(e,i),...n})}function _z(e,t,n){return{[t]:gz(e,[t],aj(n))}}function vz(e,t,n){return t.reduce((t,r)=>({...t,..._z(e,r,n)}),{})}function yz(e,t,n){return vz(e,t.keys,n)}function bz(e,t,n){return FN(yz(e,t,n))}function xz(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=Az(e[i],t,aj(n));return r}function Sz(e,t,n){return xz(e.properties,t,n)}function Cz(e,t,n){return FN(Sz(e,t,n))}function wz(e,t){return e.map(e=>kz(e,t))}function Tz(e,t){return e.map(e=>kz(e,t))}function Ez(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Dz(e,t,n){let r=NN(e,[yj,`$id`,`required`,`properties`]);return aF(Ez(n,t),r)}function Oz(e){return WN(e.reduce((e,t)=>Rj(t)?[...e,vP(t)]:e,[]))}function kz(e,t){return Ij(e)?RF(wz(e.allOf,t)):iM(e)?WN(Tz(e.anyOf,t)):Kj(e)?Dz(e,t,e.properties):aF({})}function Az(e,t,n){let r=zA(t)?Oz(t):t,i=uM(t)?IP(t):t,a=Yj(e),o=Yj(t);return Vj(e)?Cz(e,i,n):Bj(t)?Pz(e,t,n):a&&o||!a&&o||a&&!o?jN(`Pick`,[e,r],n):Y({...kz(e,i),...n})}function jz(e,t,n){return{[t]:Az(e,[t],aj(n))}}function Mz(e,t,n){return t.reduce((t,r)=>({...t,...jz(e,r,n)}),{})}function Nz(e,t,n){return Mz(e,t.keys,n)}function Pz(e,t,n){return FN(Nz(e,t,n))}function Fz(e,t){return jN(`Partial`,[jN(e,t)])}function Iz(e){return jN(`Partial`,[zF(e)])}function Lz(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=OF(e[n]);return t}function Rz(e,t){let n=NN(e,[yj,`$id`,`required`,`properties`]);return aF(Lz(t),n)}function zz(e){return e.map(e=>Bz(e))}function Bz(e){return jj(e)?Fz(e.target,e.parameters):Yj(e)?Iz(e.$ref):Ij(e)?RF(zz(e.allOf)):iM(e)?WN(zz(e.anyOf)):Kj(e)?Rz(e,e.properties):kj(e)||Aj(e)||Fj(e)||zj(e)||Wj(e)||Gj(e)||Zj(e)||Qj(e)||rM(e)?e:aF({})}function Vz(e,t){return Vj(e)?Wz(e,t):Y({...Bz(e),...t})}function Hz(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Vz(e[r],aj(t));return n}function Uz(e,t){return Hz(e.properties,t)}function Wz(e,t){return FN(Uz(e,t))}function Gz(e,t){return jN(`Required`,[jN(e,t)])}function Kz(e){return jN(`Required`,[zF(e)])}function qz(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=NN(e[n],[xj]);return t}function Jz(e,t){let n=NN(e,[yj,`$id`,`required`,`properties`]);return aF(qz(t),n)}function Yz(e){return e.map(e=>Xz(e))}function Xz(e){return jj(e)?Gz(e.target,e.parameters):Yj(e)?Kz(e.$ref):Ij(e)?RF(Yz(e.allOf)):iM(e)?WN(Yz(e.anyOf)):Kj(e)?Jz(e,e.properties):kj(e)||Aj(e)||Fj(e)||zj(e)||Wj(e)||Gj(e)||Zj(e)||Qj(e)||rM(e)?e:aF({})}function Zz(e,t){return Vj(e)?eB(e,t):Y({...Xz(e),...t})}function Qz(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=Zz(e[r],t);return n}function $z(e,t){return Qz(e.properties,t)}function eB(e,t){return FN($z(e,t))}function tB(e,t){return t.map(t=>Yj(t)?nB(e,t.$ref):CB(e,t))}function nB(e,t){return t in e?Yj(e[t])?nB(e,e[t].$ref):CB(e,e[t]):PN()}function rB(e){return KF(e[0])}function iB(e){return ZP(e[0],e[1])}function aB(e){return oI(e[0])}function oB(e){return Vz(e[0])}function sB(e){return gz(e[0],e[1])}function cB(e){return Az(e[0],e[1])}function lB(e){return Zz(e[0])}function uB(e,t,n){let r=tB(e,n);return t===`Awaited`?rB(r):t===`Index`?iB(r):t===`KeyOf`?aB(r):t===`Partial`?oB(r):t===`Omit`?sB(r):t===`Pick`?cB(r):t===`Required`?lB(r):PN()}function dB(e,t){return ON(CB(e,t))}function fB(e,t){return AN(CB(e,t))}function pB(e,t,n){return IN(SB(e,t),CB(e,n))}function mB(e,t,n){return LN(SB(e,t),CB(e,n))}function hB(e,t){return RF(SB(e,t))}function gB(e,t){return nF(CB(e,t))}function _B(e,t){return aF(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:CB(e,t[r])}),{}))}function vB(e,t){let[n,r]=[CB(e,TR(t)),CR(t)],i=oj(t);return i.patternProperties[r]=n,i}function yB(e,t){return Yj(t)?{...nB(e,t.$ref),[yj]:t[yj]}:t}function bB(e,t){return mF(SB(e,t))}function xB(e,t){return WN(SB(e,t))}function SB(e,t){return t.map(t=>CB(e,t))}function CB(e,t){return wj(t)?Y(CB(e,NN(t,[xj])),t):Cj(t)?Y(CB(e,NN(t,[bj])),t):tM(t)?Y(yB(e,t),t):Dj(t)?Y(dB(e,t.items),t):Oj(t)?Y(fB(e,t.items),t):jj(t)?Y(uB(e,t.target,t.parameters)):Mj(t)?Y(pB(e,t.parameters,t.returns),t):Pj(t)?Y(mB(e,t.parameters,t.returns),t):Ij(t)?Y(hB(e,t.allOf),t):Lj(t)?Y(gB(e,t.items),t):Kj(t)?Y(_B(e,t.properties),t):Jj(t)?Y(vB(e,t)):nM(t)?Y(bB(e,t.items||[]),t):iM(t)?Y(xB(e,t.anyOf),t):t}function wB(e,t){return t in e?CB(e,e[t]):PN()}function TB(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:wB(e,n)}),{})}var EB=class{constructor(e){let t=TB(e),n=this.WithIdentifiers(t);this.$defs=n}Import(e,t){let n={...this.$defs,[e]:Y(this.$defs[e],t)};return Y({[X]:`Import`,$defs:n,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:{...e[n],$id:n}}),{})}};function DB(e){return new EB(e)}function OB(e,t){return Y({[X]:`Not`,not:e},t)}function kB(e,t){return Pj(e)?mF(e.parameters,t):PN()}var AB=0;function jB(e,t={}){QA(t.$id)&&(t.$id=`T${AB++}`);let n=oj(e({[X]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,Y({[Sj]:`Recursive`,...n},t)}function MB(e,t){let n=YA(e)?new globalThis.RegExp(e):e;return Y({[X]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function NB(e){return Ij(e)?e.allOf:iM(e)?e.anyOf:nM(e)?e.items??[]:[]}function PB(e){return NB(e)}function FB(e,t){return Pj(e)?Y(e.returns,t):PN(t)}var IB=class{constructor(e){this.schema=e}Decode(e){return new LB(this.schema,e)}},LB=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[yj].Encode(e(n)),Decode:e=>this.decode(t[yj].Decode(e))};return{...t,[yj]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[yj]:n}}Encode(e){return tM(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function RB(e){return new IB(e)}function zB(e={}){return Y({[X]:e[X]??`Unsafe`},e)}function BB(e){return Y({[X]:`Void`,type:`void`},e)}var $=t({Any:()=>DN,Argument:()=>kN,Array:()=>ON,AsyncIterator:()=>AN,Awaited:()=>KF,BigInt:()=>bP,Boolean:()=>yP,Capitalize:()=>nz,Composite:()=>mI,Const:()=>TI,Constructor:()=>IN,ConstructorParameters:()=>EI,Date:()=>hI,Enum:()=>DI,Exclude:()=>QL,Extends:()=>GL,Extract:()=>iR,Function:()=>LN,Index:()=>ZP,InstanceType:()=>cR,Instantiate:()=>HR,Integer:()=>UR,Intersect:()=>RF,Iterator:()=>nF,KeyOf:()=>oI,Literal:()=>vP,Lowercase:()=>rz,Mapped:()=>wF,Module:()=>DB,Never:()=>PN,Not:()=>OB,Null:()=>gI,Number:()=>xP,Object:()=>aF,Omit:()=>gz,Optional:()=>OF,Parameters:()=>kB,Partial:()=>Vz,Pick:()=>Az,Promise:()=>oF,Readonly:()=>uF,ReadonlyOptional:()=>lR,Record:()=>SR,Recursive:()=>jB,Ref:()=>zF,RegExp:()=>MB,Required:()=>Zz,Rest:()=>PB,ReturnType:()=>FB,String:()=>SP,Symbol:()=>_I,TemplateLiteral:()=>MP,Transform:()=>RB,Tuple:()=>mF,Uint8Array:()=>yI,Uncapitalize:()=>iz,Undefined:()=>vI,Union:()=>WN,Unknown:()=>bI,Unsafe:()=>zB,Uppercase:()=>az,Void:()=>BB}),VB={additionalProperties:!1},HB=$.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}),UB=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),WB=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),GB=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),KB=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),qB=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,JB=`^(?:${qB}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,YB=$.String({pattern:JB,minLength:8,maxLength:36}),XB=new RegExp(JB),ZB=/^[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 QB(e){return typeof e!=`string`||e.length>36?!1:XB.test(e)}function $B(e){if(typeof e!=`string`)return;if(ZB.test(e)){let t=e.toLowerCase();return QB(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(QB(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:HB,code:YB,deviceUid:HB,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:WB,clientTime:$.Integer(),hubNonce:$.Optional(GB)},VB),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:HB,deviceUid:HB,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:WB,clientTime:$.Integer(),hubNonce:$.Optional(GB)},VB);var eV=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:HB,nonce:GB,issuedAt:$.Integer(),hubId:HB,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(WB),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},VB);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:HB,code:YB,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:HB,challenge:eV},VB),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:HB,nonce:GB,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},VB),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:HB,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},VB),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:HB,deviceUid:HB,deviceId:UB,pairingEpoch:HB,credentialId:HB,generation:$.Integer({minimum:1}),hubId:HB,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:KB,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(WB)},VB),$.Object({enrollmentId:HB,deviceUid:HB,keyFingerprint:WB,replaceKey:$.Optional($.Boolean())},VB),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:UB,pairingEpoch:HB,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},VB);var tV=$.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}))},VB);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:HB,code:YB,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},VB);var nV=$.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:HB,expiresAt:$.Integer(),phase:nV,enrollment:$.Optional($.Object({enrollmentId:HB,deviceUid:HB,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:WB,proofVerified:$.Boolean(),keyChanged:$.Boolean()},VB)),deviceId:$.Optional(UB),error:$.Optional(tV)},VB);function rV(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 iV(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 aV=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,oV=RegExp(`^${qB}$`),sV=/^sha256:[0-9a-f]{64}$/;function cV(e){let t=iV(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=rV(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&aV.test(r.id)&&typeof r.code==`string`&&oV.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!sV.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 lV(e,t=Date.now()){let n=cV(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function uV(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=lV(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function dV(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=uV(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=lV(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:$B(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 fV=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,pV=e=>/^\/pair\/?$/.test(e.pathname)&&dV(e)===void 0?`/`:void 0,mV=4e3;async function hV(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 gV={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},_V={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},vV={class:`who`},yV={key:0,class:`muted`},bV={key:1,class:`muted`},xV={class:`fp`},SV={class:`row`},CV={class:`phase`},wV=[`onClick`],TV={key:2,class:`hint`},EV={class:`pair-steps`,"aria-label":`Pairing progress`},DV={class:`pair-grid`},OV={class:`pair-code-box`},kV={class:`pair-code`,"aria-label":`Pairing code`},AV={class:`pair-copy-actions`},jV=[`innerHTML`],MV={class:`pair-side`},NV={key:0,class:`hint`},PV={class:`pair-fingerprint`},FV={class:`fp`},IV={class:`pair-confirm`},LV={key:0,class:`pair-confirm warn`},RV=[`disabled`],zV=[`disabled`],BV={class:`hint`},VV=[`disabled`],HV={key:5,class:`error`,role:`alert`},UV={key:4},WV={class:`error`,role:`alert`},GV=M({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=O(`boot`),o=O(),s=O(),c=O(),l=O(``),u=O(!1),d=O(!1),f=O(!1),p=O(!1),m=O(!1),h=O(!1),g=O(),_=O([]),v=H(()=>{let e=s.value?.code??``;return!QB(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=H(()=>s.value?Eb(s.value):``),b=H(()=>y.value?AA(y.value,148):``),x=H(()=>c.value?.enrollment?.keyFingerprint??``),S=H(()=>c.value?.deviceId??``);j(S,e=>{g.value?.(),e&&(g.value=j(()=>Hu.devices.value.find(t=>t.id===e)?.status,e=>{e===`online`&&(J(`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=kb();o.value=t;try{let n=e?await Db.resolveCode(e):await Db.createCode();if(t.closed()){await Db.cancel(n.codeId).catch(()=>{J(`The late pairing code could not be cancelled. Check device credentials before retrying.`)});return}if(s.value=n,a.value=`code`,e){let e=fV(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}Mb(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 Db.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 Db.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 Cl&&e.status===409&&String(e.code)===`already_issued`){let e=await Db.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 te=()=>w(!1),ne=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function re(){let e=S.value;if(e){u.value=!0;try{await Db.revoke(e,`user`),J(`Issued credential revoked.`),r(`close`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}}async function ie(){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 ae(){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 oe(){if(!d.value){d.value=!0,u.value=!0;try{let e=await hV({needsCancel:!!s.value&&!ne(),cancel:te,timeoutMs:mV});if(!e.closed)return;o.value?.close(),g.value?.(),e.confirmed||J(`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:oe});let se;async function ce(){try{_.value=(await Db.pending()).codes}catch{}}async function le(e){s.value=void 0,c.value=void 0,l.value=``;let t=kb();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,Mb(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 Hr(()=>{if(ce(),se=setInterval(()=>void ce(),3e3),i.handoff&&`error`in i.handoff){l.value=i.handoff.error,a.value=`expired`;return}C(i.handoff?.code)}),Gr(()=>{clearInterval(se);let e=o.value;e&&!e.closed()&&s.value&&!ne()&&w(!0).then(e=>{e!==`cancelled`&&J(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:As(oe,[`self`])},[R(`div`,gV,[R(`header`,null,[t[5]||=R(`h2`,{id:`pair-title`},`Pair a device`,-1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:oe},[z(k(Sl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(F(),L(LA,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):V(``,!0),_.value.length?(F(),I(`section`,_V,[t[6]||=R(`h3`,null,`Machines waiting for you`,-1),R(`ul`,null,[(F(!0),I(P,null,N(_.value,e=>(F(),I(`li`,{key:e.codeId},[R(`div`,vV,[R(`strong`,null,D(e.deviceName??`unnamed device`),1),e.hostname?(F(),I(`span`,yV,D(e.hostname),1)):V(``,!0),e.platform?(F(),I(`span`,bV,D(e.platform),1)):V(``,!0)]),R(`div`,xV,D(e.keyFingerprint),1),R(`div`,SV,[R(`span`,CV,D(e.phase.replaceAll(`_`,` `)),1),R(`button`,{type:`button`,class:`small`,onClick:t=>le(e)},`Review`,8,wV)])]))),128))]),t[7]||=R(`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)])):V(``,!0),a.value===`boot`?(F(),I(`p`,TV,`Minting a pairing code…`)):s.value?(F(),I(P,{key:3},[R(`ol`,EV,[t[8]||=R(`li`,{class:E({on:!0})},`Code`,-1),R(`li`,{class:E({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),R(`li`,{class:E({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),R(`li`,{class:E({on:a.value===`issued`})},`Online`,2)]),R(`div`,DV,[R(`div`,OV,[R(`div`,kV,D(v.value),1),R(`div`,AV,[R(`button`,{type:`button`,class:`small`,onClick:ie},[z(k(cc),{size:14}),B(` `+D(m.value?`Copied`:`Copy code`),1)]),R(`button`,{type:`button`,class:`small`,onClick:ae,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[z(k(cc),{size:14}),B(` `+D(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=R(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),R(`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,jV)]),R(`div`,MV,[a.value===`code`||a.value===`proof`?(F(),I(`p`,NV,[z(k(el),{size:14,class:`spin`}),t[10]||=B(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(F(),I(P,{key:1},[R(`div`,PV,[t[11]||=R(`h3`,null,`Device key fingerprint`,-1),R(`code`,FV,D(x.value),1),t[12]||=R(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),R(`label`,IV,[A(R(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[xs,f.value]]),t[13]||=B(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(F(),I(`label`,LV,[A(R(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[xs,p.value]]),z(k(sl),{size:14}),t[14]||=B(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):V(``,!0),R(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:ee},` Approve device `,8,RV),R(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:te},` Cancel pairing `,8,zV)],64)):a.value===`issued`?(F(),I(P,{key:2},[R(`p`,BV,[z(k(ac),{size:14}),t[15]||=B(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),R(`button`,{type:`button`,class:`small`,onClick:oe},`Close`),R(`button`,{type:`button`,class:`small danger`,disabled:!S.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:re},` Revoke this credential `,8,VV)],64)):a.value===`cancelled`?(F(),I(P,{key:3},[t[16]||=R(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),R(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>C()},`Start over`)],64)):a.value===`expired`?(F(),I(P,{key:4},[t[17]||=R(`p`,{class:`hint`},`The pairing code expired.`,-1),R(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>C()},`New code`)],64)):V(``,!0),l.value?(F(),I(`p`,HV,D(l.value),1)):V(``,!0)])])],64)):(F(),I(`div`,UV,[R(`p`,WV,D(l.value||`This pairing link is unavailable.`),1),R(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>C()},`New code`)]))])]))}}),KV={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},qV={class:`hint`},JV={key:1,class:`hint`},YV=M({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=H(()=>Hu.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[2]||=As(e=>r(`close`),[`self`])},[R(`section`,KV,[R(`header`,null,[t[3]||=R(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[z(k(Sl),{size:18})])]),i.value?(F(),I(P,{key:0},[R(`p`,null,[B(D(i.value.name)+` `,1),R(`code`,null,D(i.value.id),1)]),R(`p`,qV,D(i.value.status)+` · tunnel `+D(i.value.tunnel?.state??`disconnected`)+` · `+D(i.value.tunnel?.readerCount??0)+` readers `,1),z(Vb,{device:i.value},null,8,[`device`])],64)):(F(),I(`p`,JV,`This device is no longer in the registry.`)),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),XV={id:`prompt-title`},ZV=[`disabled`],QV={key:0,class:`hint`},$V={key:1},eH={key:0,class:`muted`},tH=[`placeholder`,`disabled`],nH=[`required`,`placeholder`,`aria-label`,`disabled`],rH={key:2,class:`message-error`,role:`alert`},iH=[`disabled`],aH=[`disabled`],oH=M({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=O(r.dialog.value??``),o=O(!1),s=O(``),c=O(),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=G(e)}finally{o.value=!1}}}return Hr(()=>void jn(()=>(c.value?.focus(),c.value?.select()))),t({busy:o}),(t,n)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:n[4]||=As(e=>!o.value&&i(`close`),[`self`])},[R(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:As(u,[`prevent`])},[R(`header`,null,[R(`h2`,XV,D(e.dialog.title),1),R(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:o.value,onClick:n[0]||=e=>i(`close`)},[z(k(Sl),{size:18})],8,ZV)]),e.dialog.hint?(F(),I(`p`,QV,D(e.dialog.hint),1)):V(``,!0),l?(F(),I(`label`,$V,[B(D(e.dialog.label)+` `,1),e.dialog.optional?(F(),I(`span`,eH,`(optional)`)):V(``,!0),e.dialog.multiline?A((F(),I(`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,tH)),[[bs,a.value]]):A((F(),I(`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,nH)),[[bs,a.value]])])):V(``,!0),s.value?(F(),I(`p`,rH,D(s.value),1)):V(``,!0),R(`footer`,null,[R(`button`,{type:`button`,class:`secondary`,disabled:o.value,onClick:n[3]||=e=>i(`close`)},` Cancel `,8,iH),R(`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,aH)])],32)]))}}),sH={class:`modal model-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Model picker`},cH={class:`eyebrow`},lH={class:`model-list`},uH={key:0,class:`model-row off-catalog`,"aria-disabled":`true`},dH=[`src`],fH=[`onClick`],pH=[`src`],mH={class:`hint`},hH=M({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=O(``),i=O();Hr(()=>void jn(()=>i.value?.focus()));let a=H(()=>fd.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),o=e=>{let t=bd.value;return!!t&&e.id===t.modelId&&e.provider===t.provider},s=H(()=>{let e=bd.value;return e&&!fd.value.some(t=>t.provider===e.provider&&t.id===e.modelId)?e:void 0});async function c(e){await kd(()=>rd.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await wd(),J(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(F(),I(`div`,{class:`modal-backdrop`,onClick:t[2]||=As(e=>n(`close`),[`self`])},[R(`section`,sH,[R(`header`,null,[R(`div`,null,[R(`span`,cH,`PER AGENT · `+D(k(Xu)?.name??k(Xu)?.id),1),t[3]||=R(`h2`,null,`Choose a model`,-1)]),R(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[z(k(Sl),{size:18})])]),A(R(`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),[[bs,r.value]]),R(`div`,lH,[s.value?(F(),I(`div`,uH,[R(`img`,{src:k(Nd)(s.value.modelId),alt:``},null,8,dH),R(`div`,null,[R(`strong`,null,D(s.value.modelId),1),R(`small`,null,D(s.value.provider)+` / current · not in this device's catalog`,1)])])):V(``,!0),(F(!0),I(P,null,N(a.value,e=>(F(),I(`button`,{key:`${e.provider}/${e.id}`,class:E({selected:o(e)}),onClick:t=>c(e)},[R(`img`,{src:k(Nd)(e.id),alt:``},null,8,pH),R(`div`,null,[R(`strong`,null,D(e.name),1),R(`small`,null,D(e.tier)+` / `+D(e.provider)+` / `+D(k(jd)(e.contextWindow))+` context`,1)]),o(e)?(F(),L(k(nc),{key:0,size:18})):V(``,!0)],10,fH))),128))]),R(`p`,mH,`Models available on `+D(k(Xu)?.id)+`. Provider keys stay on the device.`,1)])]))}}),gH={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},_H={class:`dialog-head`},vH={class:`dialog-body`},yH={class:`n`},bH={class:`body`},xH={class:`help-callout`},SH={class:`dialog-foot`},CH={class:`right`},wH=M({__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)=>(F(),I(`div`,{class:`scrim`,onClick:n[2]||=As(e=>k(q).dialog=void 0,[`self`])},[R(`section`,gH,[R(`div`,_H,[n[3]||=R(`div`,null,[R(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),R(`h3`,{id:`help-title`},`What makes this durable?`)],-1),R(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>k(q).dialog=void 0},[z(k(Sl),{size:18})])]),R(`div`,vH,[(F(),I(P,null,N(t,(e,t)=>R(`div`,{key:e.title,class:`help-step`},[R(`span`,yH,D(String(t+1).padStart(2,`0`)),1),R(`div`,null,[R(`b`,null,D(e.title),1),R(`div`,bH,D(e.body),1)])])),64)),R(`div`,xH,[z(k(kc),{size:18}),n[4]||=R(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),R(`div`,SH,[R(`div`,CH,[R(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>k(q).dialog=void 0},`Close`)])])])]))}}),TH=Gt({needed:!1,busy:!1,error:``}),EH=new Set,DH=e=>{let t=[...EH];EH=new Set;for(let n of t)n(e)},OH=()=>new Promise(e=>EH.add(e));async function kH(e){if(TH.busy||!e)return!1;TH.busy=!0,TH.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?(TH.needed=!1,DH(!0),!0):(TH.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 TH.error=`Cannot reach the hub.`,!1}finally{TH.busy=!1}}var AH=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function jH(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;TH.needed=!0;let a=await i.text().catch(()=>``);return await OH()?r():new Response(a,{status:i.status,headers:i.headers})})}function MH(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=jH(window.fetch.bind(window)))}var NH={class:`login-veil`,"data-testid":`login-card`},PH=[`disabled`],FH={key:0,class:`message-error`,role:`alert`},IH=[`disabled`],LH=M({__name:`LoginCard`,setup(e){let t=O(``),n=O();async function r(){if(TH.busy||!t.value.trim())return;let e=await kH(t.value.trim());t.value=``,e&&n.value?.blur()}return Hr(()=>void jn(()=>n.value?.focus())),(e,i)=>(F(),I(`div`,NH,[R(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:As(r,[`prevent`])},[i[2]||=R(`header`,null,[R(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=R(`p`,{class:`hint`},[B(` This hub is locked. Sign in with the token from its `),R(`code`,null,`admin.token`),B(` file. `)],-1),i[4]||=R(`label`,{for:`admin-token`},`Admin token`,-1),A(R(`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:k(TH).busy,onKeydown:i[1]||=Ms(e=>k(TH).error=``,[`esc`])},null,40,PH),[[bs,t.value]]),k(TH).error?(F(),I(`p`,FH,D(k(TH).error),1)):V(``,!0),R(`footer`,null,[R(`button`,{class:`primary`,type:`submit`,disabled:k(TH).busy||!t.value.trim()},D(k(TH).busy?`Checking…`:`Sign in`),9,IH)])],32)]))}}),RH={key:0,class:`toast`,role:`status`},zH=M({__name:`Toast`,setup(e){return(e,t)=>(F(),L(xo,{name:`toast`},{default:Un(()=>[k(q).toast?(F(),I(`div`,RH,[z(k(nc),{size:18}),B(D(k(q).toast),1)])):V(``,!0)]),_:1}))}});function BH(e,t=!1){return e.kind===`pair`?`pair`:e.kind===`prompt`&&t?`keep`:`close`}var VH={class:`shell`,"data-testid":`app-shell`},HH={key:0,class:`error-banner`,role:`alert`},UH={key:4,class:`welcome`,"data-testid":`welcome-empty`},WH=[`disabled`],GH={class:`welcome-features`},KH={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},qH={class:`full-directory`},JH=M({__name:`App`,setup(e){let t=()=>Hu.devices.value.filter(e=>e.status===`online`).length,n=O(),r=O();function i(){q.dialog={kind:`new-session`,deviceId:K.value?.deviceId}}function a(e){let t=q.dialog?void 0:Kd(e);if(t)return e.preventDefault(),t===`tree`?Hd():Ud();if(e.key===`Escape`){if(q.dialog){let e=BH(q.dialog,r.value?.busy??!1);e===`pair`?n.value?.close():e===`close`&&(q.dialog=void 0);return}!e.repeat&&!e.isComposing&&_d.value&&(e.preventDefault(),Id()),q.drawer=!1,q.inspectorOverlay=!1}}function o(e){let t=e.clientX,n=Ku.value,r=e=>Ku.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 Hr(()=>jf()),Hr(()=>{document.addEventListener(`keydown`,a),ud()}),Gr(()=>{Bu.stop(),document.removeEventListener(`keydown`,a)}),(e,a)=>(F(),I(`div`,VH,[z(cf,{onNewSession:i}),k(q).error?(F(),I(`div`,HH,[z(k(kc),{size:18}),R(`span`,null,D(k(q).error),1),R(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:a[0]||=e=>k(q).error=``},`×`)])):V(``,!0),R(`main`,{class:`net-workspace`,style:ge({"--tree-w":`${k(Ku)}px`})},[z(Kp),k(qu).tree?(F(),I(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:As(o,[`prevent`])},null,32)):V(``,!0),k(q).drawer?(F(),I(`div`,{key:1,class:`tree-backdrop`,onClick:a[1]||=e=>k(q).drawer=!1})):V(``,!0),k(K)&&k(Xu)&&k(Zu)?(F(),I(P,{key:2},[z(Dk),k(q).inspectorOverlay?(F(),I(`div`,{key:0,class:`inspector-backdrop`,onClick:a[2]||=e=>k(Vd)()})):V(``,!0),(F(),L(Jy,{key:`${k(K).deviceId}/${k(K).sessionId}`}))],64)):k(K)&&k(Xu)?(F(),L(Lk,{key:3,device:k(Xu)},null,8,[`device`])):(F(),I(`section`,UH,[a[14]||=R(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),a[15]||=R(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),a[16]||=R(`h1`,null,[B(`Close the tab.`),R(`br`),B(`The work continues.`)],-1),a[17]||=R(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),R(`button`,{class:`primary`,disabled:!t(),onClick:i},[z(k(Zc),{size:18}),B(D(k(Hu).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,WH),R(`div`,GH,[R(`span`,null,[z(k(pc),{size:18}),a[11]||=B(`SQLite on each device`,-1)]),R(`span`,null,[z(k(wc),{size:18}),a[12]||=B(`Branch any agent`,-1)]),R(`span`,null,[z(k(Hs),{size:18}),a[13]||=B(`Watch from anywhere`,-1)])])]))],4),z(df),k(q).dialog?.kind===`pair`?(F(),L(GV,{key:1,ref_key:`pairWizard`,ref:n,handoff:k(q).dialog.handoff,onClose:a[3]||=e=>k(q).dialog=void 0},null,8,[`handoff`])):V(``,!0),k(q).dialog?.kind===`credentials`?(F(),L(YV,{key:2,"device-id":k(q).dialog.deviceId,onClose:a[4]||=e=>k(q).dialog=void 0},null,8,[`device-id`])):V(``,!0),k(q).dialog?.kind===`new-session`?(F(),L(iA,{key:3,"device-id":k(q).dialog.deviceId,onClose:a[5]||=e=>k(q).dialog=void 0},null,8,[`device-id`])):k(q).dialog?.kind===`prompt`?(F(),L(oH,{key:4,ref_key:`promptDialog`,ref:r,dialog:k(q).dialog,onClose:a[6]||=e=>k(q).dialog=void 0},null,8,[`dialog`])):k(q).dialog?.kind===`models`?(F(),L(hH,{key:5,onClose:a[7]||=e=>k(q).dialog=void 0})):k(q).dialog?.kind===`path`?(F(),I(`div`,{key:6,class:`modal-backdrop`,onClick:a[10]||=As(e=>k(q).dialog=void 0,[`self`])},[R(`section`,KH,[R(`header`,null,[a[18]||=R(`h2`,{id:`path-title`},`Working directory`,-1),R(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:a[8]||=e=>k(q).dialog=void 0},[z(k(Sl),{size:18})])]),R(`code`,qH,D(k(q).dialog.path),1),R(`footer`,null,[R(`button`,{class:`secondary`,onClick:a[9]||=e=>k(q).dialog=void 0},`Close`)])])])):k(q).dialog?.kind===`help`?(F(),L(wH,{key:7})):V(``,!0),k(TH).needed?(F(),L(LH,{key:8})):V(``,!0),z(zH)]))}});MH();var YH=new URL(window.location.href);if(/^\/pair\/?$/.test(YH.pathname)){let e=dV(YH);e?(YH.search=``,YH.hash=``,window.history.replaceState(window.history.state,``,YH),q.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,pV(YH))}Is(JH).mount(`#app`);