my-durable 0.0.42 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/dpi-backend/src/awake.ts +136 -0
- package/apps/dpi-backend/src/diagnostics-cli.ts +134 -0
- package/apps/dpi-backend/src/diagnostics.ts +326 -0
- package/apps/dpi-backend/src/projects.ts +15 -0
- package/apps/dpi-backend/src/store.ts +39 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/{index-o6Rn26ft.js → index-BgKiQEMm.js} +3 -3
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/{index-DaurAPEn.css → index-EulngMVY.css} +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +2 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/HostPanel.vue +11 -0
- package/apps/dpi-sdk/src/api.ts +4 -1
- package/bin/dpi.mjs +8 -0
- package/docs/host-project-checklist.md +5 -5
- package/package.json +1 -1
|
@@ -76,6 +76,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
76
76
|
`)[0]??`PR created`),await fe()}catch(e){J(`pr create failed: ${e.message.slice(0,140)}`)}finally{ue.value=!1}}}async function he(e){if(r.value&&n.value){ue.value=!0;try{let t=await G(r.value).gitOp(n.value,`pr-checks`,{n:e});T.value=new Map(T.value).set(e,t.text.slice(0,1500))}catch(e){J(`pr checks failed: ${e.message.slice(0,120)}`)}finally{ue.value=!1}}}let ge=e=>re({title:`Merge PR #${e}?`,body:`squash-merge via gh on the device.`,confirmLabel:`Squash & merge`,danger:!0,action:()=>void _e(e)});async function _e(e){if(r.value&&n.value){ue.value=!0;try{J((await G(r.value).gitOp(n.value,`pr-merge`,{n:e})).text||`PR #${e} merged`),await fe(),await Ee()}catch(e){J(`pr merge failed: ${e.message.slice(0,140)}`)}finally{ue.value=!1}}}let ve=e=>re({title:`Comment on PR #${e}`,body:`posted as the device's gh login`,confirmLabel:`Comment`,input:{placeholder:`comment…`,value:``},action:t=>void ye(e,t)});async function ye(e,t){if(r.value&&n.value&&t.trim()){ue.value=!0;try{J((await G(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{ue.value=!1}}}let be=k([]),xe=k(!1),Se=async()=>{if(r.value&&l.value)try{let e=await G(r.value).sessionGitTurns(l.value);be.value=e.turns}catch{be.value=[]}};M(xe,e=>{e&&Se()});let Ce=0;window.addEventListener(`focus`,()=>{!n.value||Date.now()-Ce<15e3||(Ce=Date.now(),$d(r.value||`?`,n.value||`?`,{force:!0}))});let we=k(new Set),Te=()=>{typeof localStorage<`u`&&(f.value=localStorage.getItem(y.value)??``)};Yd(),$d(r.value||`?`,n.value||`?`),Te(),Kr(()=>$d(r.value||`?`,n.value||`?`)),M(f,e=>{typeof localStorage<`u`&&(e?localStorage.setItem(y.value,e):localStorage.removeItem(y.value))}),M([r,n],()=>{m.value=!1,h.value=!1,_.value=null,b.value=null,S.value=``,C.value=!1,ee.value=[],se.value=new Map,we.value=new Set,$d(r.value||`?`,n.value||`?`),Te()});let Ee=()=>(p.value=new Set,_.value=null,$d(r.value||`?`,n.value||`?`,{force:!0})),De=U(()=>a.value?.files??[]);M(De,e=>{let t=new Set;for(let n of e)n.x!==`?`&&n.y!==`?`&&t.add(n.path);p.value=t},{immediate:!0});let Oe=U(()=>De.value.some(e=>p.value.has(e.path))),ke=U(()=>De.value.filter(e=>!je(e)&&e.x!==` `&&e.x!==`?`)),Ae=U(()=>De.value.filter(e=>!je(e)&&(e.x===` `||e.x===`?`))),je=e=>`UAD`.includes(e.x)&&`UAD`.includes(e.y),Me=U(()=>De.value.filter(je)),Ne=U(()=>De.value.length>=500),Pe=U(()=>(a.value?.staged??0)+(a.value?.unstaged??0)+(a.value?.untracked??0)>0),Fe=U(()=>!a.value?.identity?.name||!a.value?.identity?.email),O=U(()=>{let e=a.value?.remoteUrl??``,t=e.match(/git@([^:]+):(.+?)(?:\.git)?$/)??e.match(/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/);return t?`https://${t[1]}/${t[2]}`:``}),Ie=e=>{let t=new Set(p.value);t.has(e)?t.delete(e):t.add(e),p.value=t},Le=e=>{let t=e.every(e=>p.value.has(e.path)),n=new Set(p.value);for(let r of e)t?n.delete(r.path):n.add(r.path);p.value=n},Re=e=>{let t=e.lastIndexOf(`/`);return t===-1?`.`:e.slice(0,t)},ze=e=>{let t=new Map;for(let n of e){let e=Re(n.path);t.has(e)||t.set(e,[]),t.get(e).push(n)}return[...t.entries()].map(([e,t])=>({dir:e,files:t,open:!we.value.has(e)}))},Be=e=>{let t=new Set(we.value);t.has(e)?t.delete(e):t.add(e),we.value=t},Ve=e=>e.a===void 0&&e.d===void 0?``:e.a===-1||e.d===-1?`bin`:`+${e.a??0} −${e.d??0}`,He=e=>{navigator.clipboard?.writeText(e).then(()=>J(`copied ${e}`))};async function Ue(e,t={}){if(r.value&&n.value){u.value=e,d.value=``;try{let i=await G(r.value).gitOp(n.value,e,t);d.value=i.text||`(empty)`,e===`push`&&(S.value=``),e===`pull`&&(C.value=!1),[`fetch`,`pull`,`push`,`stash-push`,`stash-pop`].includes(e)&&J(`git ${e} ✓`),await Ee(),vt(!0)}catch(t){let n=t.message;e===`push`&&(/no upstream|has no upstream|upstream is gone/i.test(n)?S.value=`no upstream — set it while pushing?`:/fetch first|non-fast-forward|rejected.*fetch|behind/i.test(n)?S.value=`the remote has work you lack — pull first`:/authentication|permission|could not read|403|denied/i.test(n)?S.value=`credentials rejected on the device — check its git login`:S.value=``),e===`pull`&&/not possible to fast-forward|divergent|unrelated histories/i.test(n)&&(C.value=!0),J(`git ${e}: ${n.slice(0,160)}`)}finally{u.value=``}}}async function We(e,t,i=!1){if(!r.value||!n.value||(i&&(u.value=e),!t&&e!==`stage`))return;if(e===`discard`&&t&&!i){re({title:`Roll back to HEAD?`,body:`${t} — uncommitted changes are lost.`,confirmLabel:`Roll back`,danger:!0,action:()=>void We(e,t,!0)});return}u.value=e;let a=t?[t]:De.value.filter(e=>e.x===` `||e.x===`M`).map(e=>e.path);try{J((await G(r.value).gitOp(n.value,e,{files:a})).text),await Ee()}catch(t){J(`${e} failed: ${t.message.slice(0,140)}`)}finally{u.value=``}}async function Ge(e){if(r.value&&n.value&&e.length){u.value=`unstage`;try{J((await G(r.value).gitOp(n.value,`unstage`,{files:e})).text),await Ee()}catch(e){J(`unstage failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function Ke(e,t){if(r.value&&n.value){u.value=`resolve`;try{J((await G(r.value).gitOp(n.value,`resolve`,{side:e,files:[t]})).text),await Ee()}catch(e){J(`resolve failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function qe(e){if(r.value&&n.value&&e.length){u.value=`ignore`;try{J((await G(r.value).gitOp(n.value,`ignore`,{lines:e})).text),await Ee()}catch(e){J(`ignore failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function Je(e){if(r.value&&n.value){if(_.value?.path===e)return _.value=null;u.value=`diff`;try{let t=await G(r.value).gitOp(n.value,`diff-file`,{target:e,staged:v.value===`staged`});_.value={path:e,text:t.text}}catch(e){J(`diff failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}let Ye=async()=>{let e=_.value?.path;_.value=null,e&&await Je(e)},Xe=U(()=>/Binary files .* differ/i.test(_.value?.text??``));async function Ze(){if(r.value&&n.value){u.value=`abort`;try{J((await G(r.value).gitOp(n.value,`merge-abort`)).text),await Ee()}catch(e){J(`abort failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function Qe(e){if(m.value=!1,r.value&&n.value){u.value=`compare`;try{let t=await G(r.value).gitOp(n.value,`compare`,{ref:e});b.value={ref:e,ahead:t.ahead??0,behind:t.behind??0}}catch(e){J(`compare failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}}async function $e(e,t=!1){if(m.value=!1,!r.value||!n.value||e===a.value?.branch&&!t)return;u.value=`switch`;let i=G(r.value),o=!1;try{if(x.value&&!t&&Pe.value&&(await i.gitOp(n.value,`stash-push`,{message:`dpi auto-stash before ${e}`}),o=!0),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 Ee(),vt(!0)}catch(e){if(J(`switch failed: ${e.message.slice(0,140)}`),o)try{await i.gitOp(n.value,`stash-pop`)}catch{}}finally{u.value=``}}async function et(e=!1){if(!r.value||!n.value||!f.value.trim())return;u.value=`commit`;let t=De.value.filter(e=>p.value.has(e.path)).map(e=>e.path);if(!t.length)return J(`check the files to commit — nothing is selected`);let i=G(r.value);try{if(J((await i.gitOp(n.value,`commit`,{message:f.value.trim(),...a.value?.merge?{}:{files:t}})).text),f.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 Ee(),vt(!0)}catch(e){J(`commit failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}function tt(e){let t=e?.models??[],n=t.find(t=>`${t.provider}/${t.id}`===e?.defaultModel),r=new Map;for(let e of t)r.has(e.provider)||r.set(e.provider,e);let i=[...r.values()].filter(e=>e!==n).slice(0,3);return(n?[n,...i]:i).slice(0,4)}async function nt(){if(!r.value||!n.value)return;let e=De.value.filter(e=>p.value.has(e.path)).map(e=>e.path);if(!e.length)return J(`check files first — the model summarises THOSE`);u.value=`ai`;let t=G(r.value),i=``;for(let r of e.slice(0,5)){let e=await t.gitOp(n.value,`diff-file`,{target:r});if(i+=`${e.text}\n`,i.length>4e3)break}i=i.slice(0,4e3);let a=`Write ONE concise git commit message (under 72 chars, imperative, no quotes, no backticks) for these changes:\n\n${i}`,o=bu.devices.value.find(e=>e.id===r.value)?.info,s=tt(o);if(!s.length)return u.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(`
|
|
77
77
|
`)[0]?.slice(0,100):``;if(i){f.value=i;return}c.push(`${e.provider}/${e.id}: ${n.status===`unanswered`?n.reason:`empty answer`}`)}finally{t.session(r).archive().catch(()=>{})}}J(`ai message failed on every model — ${c.join(`; `).slice(0,140)}`)}catch(e){J(`ai message failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}async function rt(){if(r.value&&l.value){u.value=`session-files`;try{let e=await G(r.value).sessionGitFiles(l.value);ee.value=e.files;let t=e=>e.startsWith(`/`)||e.includes(`:\\`)?e:`${n.value}/${e}`,i=new Set(e.files.map(t)),a=De.value.filter(e=>i.has(t(e.path)));p.value=new Set(a.map(e=>e.path)),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{u.value=``}}}async function it(e){if(se.value.has(e)){se.value.delete(e),se.value=new Map(se.value);return}if(r.value&&n.value)try{let t=await G(r.value).gitOp(n.value,`show-files`,{target:e});se.value=new Map(se.value).set(e,t.changed??[])}catch(e){J(`commit files failed: ${e.message.slice(0,120)}`)}}async function at(){if(!r.value||!n.value)return;let e=`cp-${new Date().toISOString().slice(0,16).replace(/[-:T]/g,``)}`;u.value=`checkpoint`;try{J((await G(r.value).gitOp(n.value,`checkpoint`,{name:e})).text),oe.value=!0,await ot()}catch(e){J(`checkpoint failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}async function ot(){if(r.value&&n.value)try{let e=await G(r.value).gitOp(n.value,`checkpoints`);ae.value=e.checkpoints??[]}catch{ae.value=[]}}async function st(e){if(!r.value||!n.value)return;let t=e;re({title:`Rewind to ${t}?`,body:`reset --hard — ALL uncommitted changes in this worktree are LOST.`,confirmLabel:`Rewind`,danger:!0,action:()=>void ct(t)})}async function ct(e){if(r.value&&n.value){u.value=`rewind`;try{J((await G(r.value).gitOp(n.value,`rewind`,{name:e})).text),await Ee(),vt(!0)}catch(e){J(`rewind failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}M(oe,e=>{e&&ot()});async function lt(e){if(h.value=!1,!r.value||!n.value||!a.value?.root)return;let t=a.value.root,i=`${t.slice(0,t.lastIndexOf(`/`))}/${t.slice(t.lastIndexOf(`/`)+1)}-${e.replace(/[/\\]+/g,`-`)}`;u.value=`wt`;try{J((await G(r.value).gitOp(n.value,`worktree-add`,{branch:e,target:i})).text.split(`
|
|
78
78
|
`)[0]??`worktree ${i}`),g.value=``,await Ee()}catch(e){J(`worktree failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}async function ut(e,t){if(r.value){u.value=`session`;try{let n=bu.devices.value.find(e=>e.id===r.value)?.info,i=tt(n)[0];if(!i)return J(`no model available on ${r.value} — cannot create a session`);let a=await G(r.value).createSession({name:t??e.slice(e.lastIndexOf(`/`)+1),cwd:e,model:{provider:i.provider,modelId:i.id}});Lu({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{u.value=``}}}async function dt(e){if(r.value){u.value=`go`;try{let t=(await G(r.value).sessions()).find(t=>t.cwd===e);t?(Lu({deviceId:r.value,sessionId:t.id,agentId:1}),J(`switched to session "${t.name}"`)):await ut(e,null)}catch(e){J(`switch failed: ${e.message.slice(0,120)}`)}finally{u.value=``}}}async function ft(e){if(!r.value||!n.value)return;u.value=`wt`;let t=`Uncommitted changes in it will be LOST.`;try{let n=(await G(r.value).gitStatusBatch([e],{timeoutMs:6e4}))[e];t=(n?.staged??0)+(n?.unstaged??0)+(n?.untracked??0)>0?`It CONTAINS uncommitted changes — they will be LOST.`:`Its checkout is clean.`}catch{}re({title:`Remove worktree?`,body:`${e} — ${t}`,confirmLabel:`Remove`,danger:!0,action:()=>void pt(e)})}async function pt(e){u.value=`wt`;try{await G(r.value).gitOp(n.value,`worktree-remove`,{target:e}),await Ee()}catch(e){J(`remove failed: ${e.message.slice(0,140)}`)}finally{u.value=``}}let mt=k([]),ht=k(!1),gt=k(``),_t=0;async function vt(e=!1){if(r.value&&n.value&&!(!e&&mt.value.length&&Date.now()-_t<12e4)){ht.value=!0;try{let e=await G(r.value).gitOp(n.value,`log-list`);mt.value=e.commits??[],gt.value=``,_t=Date.now()}catch(e){gt.value=e.message.slice(0,120)}finally{ht.value=!1}}}vt(),M([r,n],()=>{mt.value=[],_t=0,vt()});let yt=U(()=>(a.value?.worktrees??[]).filter(e=>e.path)),bt=[`#4f8cc9`,`#b8860b`,`#7aa25c`,`#a061ba`,`#c96f6f`,`#5fa8a0`],xt=U(()=>{let e=new Map,t=[],n=[];for(let r of mt.value){let i=e.get(r.hash);i===void 0&&(i=n.indexOf(null),i===-1&&(n.push(null),i=n.length-1),e.set(r.hash,i)),n[i]=null;let a=[];r.parents.forEach((t,r)=>{let o=e.get(t);(o===void 0||n[o]===t)&&(o=n.indexOf(null),o===-1&&(n.push(null),o=n.length-1),e.set(t,o)),n[o]=t,r===0&&(n[i]=t),a.push(o)}),t.push({lane:i,parents:a,width:Math.max(1,n.length)})}return t}),St=e=>e*12+7;return(e,t)=>(I(),L(`div`,Nb,[n.value?(I(),L(F,{key:1},[o.value?(I(),L(`p`,Fb,`loading git…`)):s.value?(I(),L(`p`,Ib,`refreshing…`)):H(``,!0),c.value?(I(),L(`p`,Lb,[V(D(c.value)+` `,1),z(`button`,{onClick:t[0]||=e=>Ee()},`retry`)])):H(``,!0),a.value?(I(),L(`div`,{key:3,class:E({stale:!!c.value||!!s.value})},[a.value.repo?(I(),L(F,{key:1},[a.value.merge?(I(),L(`p`,zb,[V(` merge in progress — `+D(a.value.conflicts??Me.value.length)+` unmerged path(s). Resolve them in the lists above, or `,1),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[1]||=e=>Ze()},`abort merge`,8,Bb)])):H(``,!0),z(`div`,Vb,[z(`div`,Hb,[z(`button`,{class:`branch-btn`,disabled:!!u.value,onClick:t[2]||=e=>m.value=!m.value},[B(A(xc),{size:16}),z(`strong`,null,D(a.value.branch??`detached`),1),B(A(nc),{size:14})],8,Ub),m.value?(I(),L(`div`,Wb,[(I(!0),L(F,null,P(a.value.branches??[],e=>(I(),L(`button`,{key:e.name,class:E({cur:e.current}),onClick:t=>$e(e.name)},[B(A(xc),{size:13}),z(`span`,null,D(e.name),1),z(`span`,Kb,D(e.current?`current`:e.upstream?`→ ${e.upstream}`:``),1),t[42]||=z(`span`,{class:`grow`},null,-1),e.current?H(``,!0):(I(),R(A(Sc),{key:0,size:13,title:`compare with this base`,onClick:ks(t=>Qe(e.name),[`stop`])},null,8,[`onClick`]))],10,Gb))),128)),z(`div`,qb,[j(z(`input`,{"onUpdate:modelValue":t[3]||=e=>g.value=e,placeholder:`new branch…`,onKeyup:t[4]||=js(e=>g.value.trim()&&$e(g.value.trim(),!0),[`enter`])},null,544),[[ys,g.value]]),z(`button`,{disabled:!g.value.trim(),onClick:t[5]||=e=>$e(g.value.trim(),!0)},[B(A(Xc),{size:13})],8,Jb)]),z(`label`,Yb,[j(z(`input`,{type:`checkbox`,"onUpdate:modelValue":t[6]||=e=>x.value=e},null,512),[[bs,x.value]]),t[43]||=V(` auto-stash on switch`,-1)])])):H(``,!0)]),z(`span`,Xb,D(a.value.upstream??`no upstream`),1),a.value.ahead?(I(),L(`span`,Zb,`↑`+D(a.value.ahead),1)):H(``,!0),a.value.behind?(I(),L(`span`,Qb,`↓`+D(a.value.behind),1)):H(``,!0),b.value?(I(),L(`span`,$b,[V(` vs `+D(b.value.ref)+`: ↑`+D(b.value.ahead)+` ↓`+D(b.value.behind)+` `,1),z(`button`,{class:`tag-x`,onClick:t[7]||=e=>b.value=null},[B(A(vl),{size:11})])])):H(``,!0),z(`span`,ex,`+`+D(a.value.staged??0)+` ~`+D(a.value.unstaged??0)+` ?`+D(a.value.untracked??0),1),O.value?(I(),L(`a`,{key:3,class:`icon-button`,href:`${O.value}/tree/${a.value.branch??``}`,target:`_blank`,rel:`noopener`,title:`open on the remote`},[B(A(Ks),{size:15,style:{transform:`rotate(45deg)`}})],8,tx)):H(``,!0),z(`button`,{class:`icon-button`,disabled:!!u.value||o.value||s.value,title:`refresh`,onClick:t[8]||=e=>Ee()},[B(A($c),{size:16})],8,nx)]),z(`div`,rx,[z(`button`,{class:`small`,disabled:!!u.value,onClick:t[9]||=e=>Ue(`fetch`)},[B(A(Ws),{size:14}),t[44]||=V(`fetch`,-1)],8,ix),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[10]||=e=>Ue(`pull`)},[B(A(Ws),{size:14}),t[45]||=V(`pull`,-1)],8,ax),z(`button`,{class:`small primary`,disabled:!!u.value,title:`push`,onClick:t[11]||=e=>Ue(`push`)},[B(A(Ks),{size:14}),t[46]||=V(`push`,-1)],8,ox),z(`button`,{class:`small`,disabled:!!u.value,title:`stash changes`,onClick:t[12]||=e=>Ue(`stash-push`,{message:f.value.trim()||void 0})},[B(A(cl),{size:14}),t[47]||=V(`stash`,-1)],8,sx),z(`button`,{class:`small`,disabled:!!u.value,title:`pop the newest stash`,onClick:t[13]||=e=>Ue(`stash-pop`)},[B(A(Hc),{size:14}),t[48]||=V(`unstash`,-1)],8,cx)]),S.value?(I(),L(`p`,lx,[V(D(S.value)+` `,1),S.value.includes(`upstream`)?(I(),L(`button`,{key:0,class:`small primary`,disabled:!!u.value,onClick:t[14]||=e=>Ue(`push`,{setUpstream:!0,ref:a.value.branch})},`push -u origin `+D(a.value.branch),9,ux)):S.value.includes(`remote has work`)?(I(),L(`button`,{key:1,class:`small primary`,disabled:!!u.value,onClick:t[15]||=e=>Ue(`pull`)},`pull now`,8,dx)):H(``,!0)])):H(``,!0),C.value?(I(),L(`p`,fx,[t[49]||=V(` fast-forward is not possible — branches diverged. `,-1),z(`button`,{class:`small primary`,disabled:!!u.value,onClick:t[16]||=e=>Ue(`pull`,{rebase:!0})},`pull --rebase`,8,px)])):H(``,!0),z(`section`,mx,[z(`div`,hx,[t[50]||=z(`h4`,null,`Commit`,-1),z(`span`,gx,D(De.value.length?`${p.value.size}/${De.value.length} files`:`no changes`),1),t[51]||=z(`span`,{class:`grow`},null,-1),l.value?(I(),L(`button`,{key:0,class:`small`,disabled:!!u.value,title:`check the files this session's agent touched`,onClick:rt},[B(A(_c),{size:13}),V(` session files`+D(te.value?` (${te.value.changed}/${te.value.total})`:``),1)],8,_x)):H(``,!0),l.value?(I(),L(`button`,{key:1,class:`small`,disabled:!!u.value,title:`what each turn of this session changed`,onClick:t[17]||=e=>xe.value=!xe.value},` turns `,8,vx)):H(``,!0)]),Fe.value?(I(),L(`p`,yx,[...t[52]||=[V(`git user.name/user.email is not set on the device — `,-1),z(`code`,null,`dpi device config`,-1),V(` or `,-1),z(`code`,null,`git config --global`,-1),V(` before committing.`,-1)]])):H(``,!0),xe.value?(I(),L(`div`,bx,[be.value.length?H(``,!0):(I(),L(`p`,xx,`no turns recorded yet for this session.`)),(I(!0),L(F,null,P(be.value,(e,t)=>(I(),L(`div`,{key:t,class:`cp-row`},[z(`code`,null,`t`+D(be.value.length-t),1),z(`span`,Sx,D(e.when.slice(0,16).replace(`T`,` `)),1),z(`span`,Cx,D(e.files.map(e=>`${e.path}×${e.writes}${e.a!==void 0||e.d!==void 0?` (+${e.a??0} −${e.d??0})`:``}`).join(`, `)||`(no file writes)`),1)]))),128))])):H(``,!0),Ne.value?(I(),L(`p`,wx,`showing the first 500 changed files — commit in smaller batches`)):H(``,!0),Me.value.length?(I(),L(`div`,Tx,[z(`label`,Ex,[z(`span`,Dx,`Conflicts · `+D(Me.value.length)+` — pick a side per file`,1)]),(I(!0),L(F,null,P(Me.value,e=>(I(),L(`div`,{key:e.path,class:`file`},[z(`label`,Ox,[z(`code`,kx,D(e.x)+D(e.y),1),z(`span`,{class:`path`,title:e.path},D(e.path),9,Ax)]),z(`span`,jx,[z(`button`,{class:`icon-button`,title:`view the conflict`,onClick:t=>Je(e.path)},[B(A(hc),{size:13})],8,Mx),z(`button`,{class:`small`,disabled:!!u.value,title:`keep this branch's version and stage it`,onClick:t=>Ke(`ours`,e.path)},`ours`,8,Nx),z(`button`,{class:`small`,disabled:!!u.value,title:`take the incoming version and stage it`,onClick:t=>Ke(`theirs`,e.path)},`theirs`,8,Px)])]))),128))])):H(``,!0),ke.value.length?(I(),L(`div`,Fx,[z(`label`,Ix,[z(`input`,{type:`checkbox`,checked:ke.value.every(e=>p.value.has(e.path)),onChange:t[18]||=e=>Le(ke.value)},null,40,Lx),z(`span`,Rx,`Staged · `+D(ke.value.length),1),t[55]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,title:`stage every changed file`,onClick:t[19]||=e=>We(`stage`)},[B(A(Xc),{size:13}),t[53]||=V(` all`,-1)]),z(`button`,{class:`icon-button`,title:`unstage all (git reset HEAD)`,onClick:t[20]||=e=>Ge(ke.value.map(e=>e.path))},[B(A(Rc),{size:13}),t[54]||=V(` none`,-1)])]),(I(!0),L(F,null,P(ze(ke.value),e=>(I(),L(F,{key:e.dir},[e.dir===`.`?H(``,!0):(I(),L(`button`,{key:0,class:`dir-row`,onClick:t=>Be(e.dir)},[B(A(rc),{size:12,class:E({open:e.open})},null,8,[`class`]),V(D(e.dir),1),z(`span`,Bx,`· `+D(e.files.length),1)],8,zx)),(I(!0),L(F,null,P(e.files,t=>j((I(),L(`div`,{key:t.path,class:`file`},[z(`label`,Vx,[z(`input`,{type:`checkbox`,checked:p.value.has(t.path),onChange:e=>Ie(t.path)},null,40,Hx),z(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,Ux),z(`span`,{class:`path`,title:t.path},D(t.path),9,Wx),Ve(t)?(I(),L(`span`,{key:0,class:E([`nums`,{bin:Ve(t)===`bin`}])},D(Ve(t)),3)):H(``,!0)]),z(`span`,Gx,[z(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Je(t.path)},[B(A(hc),{size:13})],8,Kx),z(`button`,{class:`icon-button`,title:`unstage (git reset HEAD)`,onClick:e=>Ge([t.path])},[B(A(Rc),{size:13})],8,qx),z(`button`,{class:`icon-button`,title:`roll back to HEAD`,onClick:e=>We(`discard`,t.path)},[B(A(uc),{size:13})],8,Jx)])])),[[Ro,e.open]])),128))],64))),128))])):H(``,!0),Ae.value.length?(I(),L(`div`,Yx,[z(`label`,Xx,[z(`input`,{type:`checkbox`,checked:Ae.value.every(e=>p.value.has(e.path)),onChange:t[21]||=e=>Le(Ae.value)},null,40,Zx),z(`span`,Qx,`Unstaged · `+D(Ae.value.length),1)]),(I(!0),L(F,null,P(ze(Ae.value),e=>(I(),L(F,{key:e.dir},[e.dir===`.`?H(``,!0):(I(),L(`button`,{key:0,class:`dir-row`,onClick:t=>Be(e.dir)},[B(A(rc),{size:12,class:E({open:e.open})},null,8,[`class`]),V(D(e.dir),1),z(`span`,eS,`· `+D(e.files.length),1)],8,$x)),(I(!0),L(F,null,P(e.files,t=>j((I(),L(`div`,{key:t.path,class:`file`},[z(`label`,tS,[z(`input`,{type:`checkbox`,checked:p.value.has(t.path),onChange:e=>Ie(t.path)},null,40,nS),z(`code`,{class:`xy`,title:`index ${t.x} · worktree ${t.y}`},D(t.x)+D(t.y),9,rS),z(`span`,{class:`path`,title:t.path},D(t.path),9,iS),Ve(t)?(I(),L(`span`,{key:0,class:E([`nums`,{bin:Ve(t)===`bin`}])},D(Ve(t)),3)):H(``,!0)]),z(`span`,aS,[z(`button`,{class:`icon-button`,title:`view diff`,onClick:e=>Je(t.path)},[B(A(hc),{size:13})],8,oS),t.x===`?`?(I(),L(`button`,{key:0,class:`icon-button`,title:`add to .gitignore`,onClick:e=>qe([t.path])},[B(A(Ys),{size:13})],8,sS)):(I(),L(`button`,{key:1,class:`icon-button`,title:`stage (git add)`,onClick:e=>We(`stage`,t.path)},[B(A(Xc),{size:13})],8,cS)),t.x===`?`?H(``,!0):(I(),L(`button`,{key:2,class:`icon-button`,title:`roll back to HEAD`,onClick:e=>We(`discard`,t.path)},[B(A(uc),{size:13})],8,lS)),z(`button`,{class:`icon-button`,title:`copy path`,onClick:e=>He(t.path)},[B(A(sc),{size:13})],8,uS)])])),[[Ro,e.open]])),128))],64))),128))])):H(``,!0),_.value?(I(),L(`p`,dS,[z(`strong`,null,D(_.value.path),1),z(`span`,fS,[z(`button`,{class:E({on:v.value===`working`}),onClick:t[22]||=e=>{v.value=`working`,Ye()}},`working`,2),z(`button`,{class:E({on:v.value===`staged`}),onClick:t[23]||=e=>{v.value=`staged`,Ye()}},`staged`,2)]),Xe.value?(I(),L(`span`,pS,`binary file`)):_.value.text.length>8e3?(I(),L(`span`,mS,`truncated at 8000 chars`)):H(``,!0),z(`button`,{class:`icon-button`,title:`close diff`,onClick:t[24]||=e=>_.value=null},[B(A(vl),{size:13})]),Xe.value?H(``,!0):(I(),L(`pre`,hS,D(_.value.text.slice(0,8e3)),1))])):H(``,!0),j(z(`textarea`,{"onUpdate:modelValue":t[25]||=e=>f.value=e,rows:`4`,placeholder:`Commit message… (Ctrl+Enter to commit)`,onKeydown:[t[26]||=js(ks(e=>et(),[`exact`,`prevent`]),[`enter`]),t[27]||=js(ks(e=>et(),[`meta`,`prevent`]),[`enter`]),t[28]||=js(ks(e=>et(),[`ctrl`,`prevent`]),[`enter`])]},null,544),[[ys,f.value]]),z(`div`,gS,[z(`button`,{class:`small`,disabled:!!u.value||!p.value.size,title:`ask the device's model for a message`,onClick:nt},[B(A(sl),{size:14}),t[56]||=V(` ai message`,-1)],8,_S),t[58]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`primary small`,disabled:!!u.value||!f.value.trim()||!Oe.value,onClick:t[29]||=e=>et(!1)},[B(A(tc),{size:14}),V(` Commit`+D(p.value.size?` ${p.value.size} file${p.value.size>1?`s`:``}`:``),1)],8,vS),a.value.upstream?(I(),L(`button`,{key:0,class:`primary small`,disabled:!!u.value||!f.value.trim()||!Oe.value,title:`commit, then push`,onClick:t[30]||=e=>et(!0)},[B(A(tc),{size:14}),t[57]||=V(` Commit & push `,-1)],8,yS)):H(``,!0)])]),z(`section`,bS,[z(`div`,xS,[z(`h4`,null,[B(A(Ec),{size:16}),t[59]||=V(` Log`,-1)]),t[61]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:!!u.value,title:`save a checkpoint ref of HEAD`,onClick:at},[B(A(_c),{size:13}),t[60]||=V(` checkpoint`,-1)],8,SS),z(`button`,{class:`small`,disabled:!!u.value,onClick:t[31]||=e=>oe.value=!oe.value},`checkpoints `+D(ae.value.length?`(${ae.value.length})`:``),9,CS),z(`button`,{class:`icon-button`,disabled:ht.value,title:`refresh log`,onClick:t[32]||=e=>vt(!0)},[B(A($c),{size:14})],8,wS)]),oe.value?(I(),L(`div`,TS,[ae.value.length?H(``,!0):(I(),L(`p`,ES,`no checkpoints yet — one click saves a named ref of HEAD.`)),(I(!0),L(F,null,P(ae.value,e=>(I(),L(`div`,{key:e.name,class:`cp-row`},[z(`code`,null,D(e.name),1),z(`span`,DS,D(e.hash)+` · `+D(e.date),1),z(`span`,OS,D(e.subject),1),t[63]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:!!u.value,title:`reset --hard to this checkpoint (this worktree)`,onClick:t=>st(e.name)},[B(A(fl),{size:13}),t[62]||=V(` rewind`,-1)],8,kS)]))),128))])):H(``,!0),ht.value&&!mt.value.length?(I(),L(`p`,AS,`loading log…`)):mt.value.length?(I(),L(`div`,jS,[(I(!0),L(F,null,P(mt.value,(e,t)=>(I(),L(F,{key:e.hash},[z(`div`,{class:`commit-row`,title:e.refs},[xt.value[t]?(I(),L(`svg`,{key:0,class:`lane`,width:xt.value[t].width*12+4,height:`24`,"aria-hidden":`true`},[(I(!0),L(F,null,P(xt.value[t].width,e=>(I(),L(`line`,{key:e,x1:St(e-1),x2:St(e-1),y1:`0`,y2:`24`,stroke:`#3a3134`,"stroke-width":`2`},null,8,PS))),128)),(I(!0),L(F,null,P(xt.value[t].parents,(e,n)=>(I(),L(`line`,{key:`p`+n,x1:St(xt.value[t].lane),x2:St(e),y1:`12`,y2:`24`,stroke:bt[e%bt.length],"stroke-width":`2`},null,8,FS))),128)),z(`circle`,{cx:St(xt.value[t].lane),cy:`12`,r:`4`,fill:bt[xt.value[t].lane%bt.length]},null,8,IS)],8,NS)):H(``,!0),z(`button`,{class:`icon-button hash-btn`,title:`files in this commit`,onClick:t=>it(e.hash)},[B(A(rc),{size:12,class:E({open:se.value.has(e.hash)})},null,8,[`class`])],8,LS),z(`code`,RS,[O.value?(I(),L(`a`,{key:0,href:`${O.value}/commit/${e.hash}`,target:`_blank`,rel:`noopener`,title:`on the remote`},D(e.hash),9,zS)):(I(),L(F,{key:1},[V(D(e.hash),1)],64))]),e.refs?(I(),L(`span`,BS,D(e.refs.split(`,`)[0]),1)):H(``,!0),z(`span`,VS,D(e.subject),1),z(`span`,HS,D(e.author)+` · `+D(e.date),1)],8,MS),se.value.has(e.hash)?(I(),L(`div`,US,[(I(!0),L(F,null,P(se.value.get(e.hash),e=>(I(),L(`div`,{key:e.path,class:`cf`},[z(`code`,{class:`cf-status`,"data-s":e.status},D(e.status),9,WS),z(`span`,GS,D(e.path),1)]))),128)),se.value.get(e.hash)?.length?H(``,!0):(I(),L(`p`,KS,`no files (merge/empty commit)`))])):H(``,!0)],64))),128))])):gt.value?(I(),L(`p`,qS,`log failed: `+D(gt.value),1)):(I(),L(`p`,JS,`no commits`))]),z(`section`,YS,[z(`div`,XS,[z(`h4`,null,[B(A(Hc),{size:16}),t[64]||=V(` Worktrees`,-1)]),z(`div`,ZS,[z(`button`,{class:`small`,disabled:!!u.value,onClick:t[33]||=e=>h.value=!h.value},[B(A(Xc),{size:13}),t[65]||=V(` worktree`,-1)],8,QS),h.value?(I(),L(`div`,$S,[(I(!0),L(F,null,P((a.value.branches??[]).filter(e=>!e.current),e=>(I(),L(`button`,{key:e.name,onClick:t=>lt(e.name)},[B(A(xc),{size:13}),z(`span`,null,D(e.name),1),t[66]||=z(`span`,{class:`muted-line`},`existing`,-1)],8,eC))),128)),z(`div`,tC,[j(z(`input`,{"onUpdate:modelValue":t[34]||=e=>g.value=e,placeholder:`or a NEW branch…`,onKeyup:t[35]||=js(e=>g.value.trim()&<(g.value.trim()),[`enter`])},null,544),[[ys,g.value]]),z(`button`,{disabled:!g.value.trim(),onClick:t[36]||=e=>lt(g.value.trim())},`create`,8,nC)])])):H(``,!0)])]),(I(!0),L(F,null,P(yt.value,e=>(I(),L(`div`,{key:e.path,class:E([`wt`,{main:e.path===a.value.root}])},[z(`code`,{title:e.path},D(e.path),9,rC),z(`span`,iC,D(e.branch??e.head),1),t[67]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,disabled:!!u.value,title:`jump to this worktree (session or new)`,onClick:t=>dt(e.path)},[B(A(Gs),{size:13})],8,aC),z(`button`,{class:`small`,disabled:!!u.value,title:`create a session on this worktree`,onClick:t=>ut(e.path,e.branch)},`session`,8,oC),e.path===a.value.root?H(``,!0):(I(),L(`button`,{key:0,class:`icon-button`,disabled:!!u.value,onClick:t=>ft(e.path)},[B(A(vl),{size:13})],8,sC)),e.path===a.value.root?(I(),R(A(tc),{key:1,size:13,class:`muted-line`})):H(``,!0)],2))),128))]),de.value?(I(),L(`section`,cC,[z(`div`,lC,[z(`h4`,null,[B(A(wc),{size:16}),t[68]||=V(` Pull requests`,-1)]),t[69]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,disabled:ue.value||!!u.value,onClick:pe},`create PR`,8,uC),z(`button`,{class:`small`,disabled:ue.value,onClick:t[37]||=e=>le.value=!le.value},D(le.value?`hide`:`list`),9,dC)]),le.value&&!ce.value.length&&!ue.value?(I(),L(`p`,fC,`no open PRs (or gh is not logged in on the device — every action will say so).`)):H(``,!0),le.value?(I(),L(`div`,pC,[(I(!0),L(F,null,P(ce.value,e=>(I(),L(`div`,{key:e.n,class:`pr-row`},[z(`code`,mC,`#`+D(e.n),1),z(`span`,{class:E([`tag`,{open:e.state===`OPEN`}])},D(e.state.toLowerCase())+D(e.draft?` · draft`:``),3),z(`span`,hC,D(e.title),1),z(`span`,gC,D(e.branch),1),t[70]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`icon-button`,title:`run checks`,disabled:ue.value,onClick:t=>he(e.n)},[B(A($c),{size:13})],8,_C),z(`button`,{class:`icon-button`,title:`comment`,disabled:ue.value,onClick:t=>ve(e.n)},[B(A(sc),{size:13})],8,vC),e.state===`OPEN`?(I(),L(`button`,{key:0,class:`small`,disabled:ue.value||!!u.value,onClick:t=>ge(e.n)},`squash & merge`,8,yC)):H(``,!0),z(`a`,{class:`icon-button`,href:e.url,target:`_blank`,rel:`noopener`,title:`open on the forge`},[B(A(Ks),{size:13,style:{transform:`rotate(45deg)`}})],8,bC)]))),128)),(I(!0),L(F,null,P(T.value,([e,t])=>(I(),L(`pre`,{key:e,class:`pr-checks`},`#`+D(e)+` checks:`+D(`
|
|
79
|
-
`)+D(t),1))),128))])):H(``,!0)])):H(``,!0),d.value?(I(),L(`pre`,xC,D(d.value.slice(0,6e3)),1)):H(``,!0)],64)):(I(),L(`p`,Rb,[...t[41]||=[V(`Not a git repository — run `,-1),z(`code`,null,`git init`,-1),V(` (or open a session inside a repo).`,-1)]]))],2)):H(``,!0),w.value?(I(),L(`div`,{key:4,class:`modal-veil`,onClick:t[40]||=ks(e=>w.value=null,[`self`])},[z(`div`,{class:E([`modal`,{danger:w.value.danger}]),role:`dialog`,"aria-modal":`true`},[z(`h5`,null,D(w.value.title),1),z(`p`,null,D(w.value.body),1),w.value.input?j((I(),L(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>ne.value=e,rows:`2`,placeholder:w.value.input.placeholder},null,8,SC)),[[ys,ne.value]]):H(``,!0),z(`div`,CC,[t[72]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,onClick:t[39]||=e=>w.value=null},[...t[71]||=[V(`cancel `,-1),z(`span`,{class:`muted-line`},`(esc)`,-1)]]),z(`button`,{class:E([`primary small`,{danger:w.value.danger}]),disabled:!(!w.value.input||ne.value.trim()),onClick:ie},D(w.value.confirmLabel??`confirm`),11,wC)])],2)])):H(``,!0)],64)):(I(),L(`p`,Pb,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-e5829ed1`]]),EC={class:`host-panel`,"aria-label":`Device vitals`},DC={class:`panel-heading`},OC=[`disabled`],kC={key:0,class:`hint`},AC={key:1,class:`message-error`},jC={key:2,class:`hint`},MC={class:`vitals-grid`},NC={class:`vital`},PC={class:`vital`},FC={class:`vital`},IC={class:`vital`},LC={class:`meter`},RC={class:`meter-head`},zC={class:`hint`},BC=[`aria-valuenow`],VC={class:`meter`},HC={class:`meter-head`},UC={class:`hint`},WC=[`aria-valuenow`],GC={class:`path`},KC={class:`hint`},qC=Id(N({__name:`HostPanel`,setup(e){let t=k(),n=k(!1),r=k(``),i=U(()=>K.value?.deviceId),a=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]}`},o=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`},s=(e,t)=>t>0?Math.max(0,Math.min(100,Math.round(e/t*100))):0,c=U(()=>t.value?s(t.value.memory.usedBytes,t.value.memory.totalBytes):0),l=U(()=>t.value?.disk.known?s(t.value.disk.totalBytes-t.value.disk.freeBytes,t.value.disk.totalBytes):0);async function u(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).vitals()}catch(e){r.value=cu(e).slice(0,160)}finally{n.value=!1}}}M(i,u,{immediate:!0});async function d(){await u(),r.value||J(`Vitals refreshed.`)}return(e,s)=>(I(),L(`section`,EC,[z(`header`,DC,[z(`span`,null,[B(A(rl),{size:16}),s[0]||=V(`HOST`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:d},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,OC)]),i.value?r.value?(I(),L(`p`,AC,D(r.value),1)):t.value?(I(),L(F,{key:3},[z(`div`,MC,[z(`div`,NC,[s[1]||=z(`span`,{class:`label`},`Host uptime`,-1),z(`strong`,null,D(o(t.value.uptime)),1)]),z(`div`,PC,[s[2]||=z(`span`,{class:`label`},`Device process`,-1),z(`strong`,null,D(o(t.value.processUptime)),1),z(`em`,null,`pid `+D(t.value.pid),1)]),z(`div`,FC,[s[3]||=z(`span`,{class:`label`},`Load (1/5/15m)`,-1),z(`strong`,null,D(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),z(`em`,null,D(t.value.cpuCount)+` CPU`+D(t.value.cpuCount===1?``:`s`),1)]),z(`div`,IC,[s[4]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(t.value.counts?.sessions??0),1),z(`em`,null,D(t.value.counts?.archived??0)+` archived`,1)])]),z(`div`,LC,[z(`div`,RC,[s[5]||=z(`span`,{class:`label`},`Memory`,-1),z(`span`,zC,D(a(t.value.memory.usedBytes))+` / `+D(a(t.value.memory.totalBytes))+` · device `+D(a(t.value.memory.processRssBytes)),1)]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":c.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[z(`i`,{style:ge({width:`${c.value}%`}),class:E({high:c.value>=90})},null,6)],8,BC)]),z(`div`,VC,[z(`div`,HC,[s[6]||=z(`span`,{class:`label`},`Disk · data dir`,-1),z(`span`,UC,[t.value.disk.known?(I(),L(F,{key:0},[V(D(a(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+D(a(t.value.disk.freeBytes))+` free `,1)],64)):(I(),L(F,{key:1},[V(`unknown on this volume`)],64))])]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[z(`i`,{style:ge({width:`${l.value}%`}),class:E({high:l.value>=90})},null,6)],8,WC),z(`code`,GC,D(t.value.disk.path),1)]),z(`p`,KC,[B(A(Vs),{size:13}),s[7]||=V(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(I(),L(`p`,jC,D(n.value?`Reading host…`:`No vitals.`),1)):(I(),L(`p`,kC,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-9881887a`]]),JC={class:`usage-panel`,"aria-label":`Device usage`},YC={class:`panel-heading`},XC=[`disabled`],ZC={key:0,class:`hint`},QC={key:1,class:`message-error`},$C={key:2,class:`hint`},ew={key:3,class:`hint`},tw={class:`usage-block`,"aria-labelledby":`usage-totals`},nw={class:`totals`},rw={class:`total`},iw={class:`total`},aw={class:`total`},ow={class:`total`},sw={class:`usage-block`,"aria-labelledby":`usage-models`},cw={class:`section-label block-label`},lw={class:`table-scroll`},uw={class:`usage-table`,"aria-label":`Usage by model`},dw=[`title`],fw={class:`num`},pw={class:`num`},mw={class:`share-col`},hw={class:`share`},gw=[`aria-valuenow`,`aria-label`],_w={class:`pct`},vw={class:`usage-block`,"aria-labelledby":`usage-projects`},yw={class:`section-label block-label`},bw={key:0,class:`hint`},xw={key:1,class:`rows`},Sw=[`title`],Cw={class:`row-main`},ww={class:`row-num`},Tw={class:`row-num`},Ew={class:`row-meta`},Dw={class:`usage-block`,"aria-labelledby":`usage-sessions`},Ow={key:0,class:`hint`},kw={key:1,class:`rows scroll`},Aw=[`title`],jw={class:`row-main`},Mw={class:`row-num`},Nw={class:`row-num`},Pw={class:`row-meta`},Fw={class:`hint`},Iw=Id(N({__name:`UsagePanel`,setup(e){let t=k(),n=k(!1),r=k(``),i=U(()=>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=U(()=>(t.value?.models??[]).reduce((e,t)=>Math.max(e,t.cost||0),0)),c=e=>s.value>0?Math.max(0,Math.min(100,Math.round((e||0)/s.value*100))):0,l=U(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=U(()=>t.value?new Date(t.value.at).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`}):``),d=(e,t)=>`${a(e)} ${t}${e===1?``:`s`}`;async function f(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).deviceUsage()}catch(e){r.value=cu(e).slice(0,160)}finally{n.value=!1}}}M(i,f,{immediate:!0});async function p(){await f(),r.value||J(`Usage refreshed.`)}return(e,s)=>(I(),L(`section`,JC,[z(`header`,YC,[z(`span`,null,[B(A(Vs),{size:16}),s[0]||=V(`USAGE`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,XC)]),i.value?r.value?(I(),L(`p`,QC,D(r.value),1)):t.value?l.value?(I(),L(`p`,ew,`No usage recorded yet.`)):(I(),L(F,{key:4},[z(`section`,tw,[s[6]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-totals`},`TOTALS`)],-1),z(`div`,nw,[z(`div`,rw,[s[1]||=z(`span`,{class:`label`},`Tokens`,-1),z(`strong`,null,D(a(t.value.totals.tokens)),1)]),z(`div`,iw,[s[2]||=z(`span`,{class:`label`},`Cost`,-1),z(`strong`,null,D(o(t.value.totals.cost)),1)]),z(`div`,aw,[s[3]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(a(t.value.sessions.length)),1),z(`em`,null,D(a(t.value.projects.length))+` projects`,1)]),z(`div`,ow,[s[4]||=z(`span`,{class:`label`},`Models`,-1),z(`strong`,null,D(a(t.value.models.length)),1),s[5]||=z(`em`,null,`costliest first`,-1)])])]),z(`section`,sw,[z(`div`,cw,[s[7]||=z(`span`,{id:`usage-models`},`BY MODEL`,-1),B(A(dc),{size:13})]),z(`div`,lw,[z(`table`,uw,[s[8]||=z(`colgroup`,null,[z(`col`),z(`col`),z(`col`),z(`col`)],-1),s[9]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Model`),z(`th`,{scope:`col`,class:`num`},`Tokens`),z(`th`,{scope:`col`,class:`num`},`Cost`),z(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(t.value.models,e=>(I(),L(`tr`,{key:e.key},[z(`th`,{scope:`row`,class:`model-key`,title:`${e.key} — in ${e.input} · out ${e.output} · cache read ${e.cacheRead} · cache write ${e.cacheWrite}`},D(e.key),9,dw),z(`td`,fw,D(a(e.tokens)),1),z(`td`,pw,D(o(e.cost)),1),z(`td`,mw,[z(`div`,hw,[z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":c(e.cost),"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`${e.key} share of the costliest model`},[z(`i`,{style:ge({width:`${c(e.cost)}%`}),class:E({high:c(e.cost)>90})},null,6)],8,gw),z(`em`,_w,D(c(e.cost))+`%`,1)])])]))),128))])])])]),z(`section`,vw,[z(`div`,yw,[s[10]||=z(`span`,{id:`usage-projects`},`BY PROJECT`,-1),B(A(vc),{size:13})]),t.value.projects.length?(I(),L(`ul`,xw,[(I(!0),L(F,null,P(t.value.projects,e=>(I(),L(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[z(`span`,Cw,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.rootPath),1)]),z(`span`,ww,D(a(e.tokens))+` tok`,1),z(`span`,Tw,D(o(e.cost)),1),z(`span`,Ew,D(d(e.sessions,`session`)),1)],8,Sw))),128))])):(I(),L(`p`,bw,`No project usage recorded yet.`))]),z(`section`,Dw,[s[11]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(I(),L(`ul`,kw,[(I(!0),L(F,null,P(t.value.sessions,e=>(I(),L(`li`,{key:e.id,class:`row`,title:e.cwd},[z(`span`,jw,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.project??e.cwd),1)]),z(`span`,Mw,D(a(e.tokens))+` tok`,1),z(`span`,Nw,D(o(e.cost)),1),z(`span`,Pw,D(d(e.agents,`agent`)),1)],8,Aw))),128))])):(I(),L(`p`,Ow,`No session usage recorded yet.`))]),z(`p`,Fw,[B(A(Vs),{size:13}),V(` Read on demand — open this tab or press refresh (`+D(u.value)+`). Nothing polls the device. `,1)])],64)):(I(),L(`p`,$C,D(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(I(),L(`p`,ZC,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-81e8eb49`]]),Lw={class:`schedules-panel`,"aria-label":`Scheduled sessions`},Rw={class:`panel-heading`},zw=[`disabled`],Bw=[`disabled`],Vw={key:0,class:`hint`},Hw={key:1,class:`message-error`},Uw=[`value`],Ww={class:`trigger-row`},Gw={class:`inline`},Kw=[`disabled`],qw={class:`inline`},Jw=[`disabled`],Yw={class:`row`},Xw=[`disabled`],Zw={key:3,class:`hint`},Qw={key:4,class:`schedule-list`},$w={class:`head`},eT={class:`tag`},tT={key:0,class:`tag running`},nT=[`title`],rT={class:`next`},iT={class:`cwd`},aT={key:0,class:`message-error`},oT={class:`row`},sT=[`disabled`,`onClick`],cT=[`disabled`,`onClick`],lT=[`disabled`,`onClick`],uT=Id(N({__name:`SchedulesPanel`,setup(e){let t=k([]),n=k(``),r=k(``),i=k(!1),a=U(()=>K.value?.deviceId),o=()=>G(a.value??``),s=k(`60`),c=k(``),l=k(!1),u=k({name:``,cwd:``,prompt:``,model:``});async function d(){if(!a.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await o().schedules()).schedules}catch(e){let t=e.code;r.value=t===`not_found`||/allowlist/i.test(cu(e))?"This device runs an older build: update it (`dpi update`) to use schedules.":cu(e).slice(0,160)}finally{i.value=!1}}M(a,d,{immediate:!0});let f=e=>{if(!e)return`—`;let t=e-Date.now(),n=Math.round(Math.abs(t)/6e4),r=n<60?`${n}m`:n<1440?`${Math.round(n/60)}h`:`${Math.round(n/1440)}d`;return t>=0?`in ${r}`:`${r} ago`},p=e=>e.everyMinutes?`every ${e.everyMinutes}m`:`daily ${e.dailyAt}`;async function m(e,t,r){n.value=e;try{await t(),await d(),J(r)}catch(e){J(cu(e).slice(0,140))}finally{n.value=``}}let h=e=>m(e.id,()=>o().updateSchedule(e.id,{enabled:!e.enabled}),e.enabled?`Schedule paused.`:`Schedule resumed.`),g=e=>m(e.id,()=>o().runSchedule(e.id),`${e.name}: run finished.`),_=e=>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=k([]);async function y(){l.value=!0,u.value={name:``,cwd:(K.value?.sessionId,``),prompt:``,model:``};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=[]}}async function b(){let e=u.value,[t,...r]=e.model.split(`/`),i=r.join(`/`);if(e.name.trim()&&e.cwd.trim()&&e.prompt.trim()&&t&&i){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(cu(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(I(),L(`section`,Lw,[z(`header`,Rw,[z(`span`,null,[B(A(ec),{size:16}),o[7]||=V(`SCHEDULES`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[B(A($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,zw),z(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:y},[B(A(Xc),{size:15})],8,Bw)]),o[18]||=z(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(I(),L(`p`,Hw,D(r.value),1)):H(``,!0):(I(),L(`p`,Vw,`Select a session to see its device.`)),l.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(b,[`prevent`])},[z(`label`,null,[o[8]||=V(`Name`,-1),j(z(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[ys,u.value.name]])]),z(`label`,null,[o[9]||=V(`Directory`,-1),j(z(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[ys,u.value.cwd]])]),z(`label`,null,[o[10]||=V(`Prompt`,-1),j(z(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[ys,u.value.prompt]])]),z(`label`,null,[o[11]||=V(`Model `,-1),j(z(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e},[(I(!0),L(F,null,P(v.value,e=>(I(),L(`option`,{key:e.key,value:e.key},D(e.key),9,Uw))),128))],512),[[Ss,u.value.model]])]),z(`div`,Ww,[z(`label`,Gw,[o[12]||=V(`Every `,-1),j(z(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,Kw),[[ys,s.value]]),o[13]||=V(` min`,-1)]),o[15]||=z(`span`,{class:`muted`},`or`,-1),z(`label`,qw,[o[14]||=V(`daily at `,-1),j(z(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,Jw),[[ys,c.value]])])]),z(`div`,Yw,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`creating…`:`Create schedule`),9,Xw),z(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):H(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(I(),L(`p`,Zw,` No schedules yet. Press + to add one. `)):H(``,!0),t.value.length?(I(),L(`ul`,Qw,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`schedule`,{off:!e.enabled}])},[z(`div`,$w,[z(`b`,null,D(e.name),1),z(`span`,eT,D(p(e)),1),e.running?(I(),L(`span`,tT,`running`)):e.lastOutcome===`failed`?(I(),L(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,nT)):H(``,!0),z(`span`,rT,D(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),z(`code`,iT,D(e.cwd),1),e.lastError?(I(),L(`p`,aT,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,oT,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[B(A(Yc),{size:12}),o[16]||=V(`run now`,-1)],8,sT),z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[B(A(Zc),{size:12}),V(D(e.enabled?`pause`:`resume`),1)],8,cT),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[B(A(dl),{size:12}),o[17]||=V(`remove`,-1)],8,lT)])],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-7f6db3c9`]]),dT={class:`notify-panel`,"aria-label":`Notification sinks`},fT={class:`panel-heading`},pT=[`disabled`],mT=[`disabled`],hT=[`disabled`],gT={key:0,class:`hint`},_T={key:1,class:`message-error`},vT=[`placeholder`],yT={class:`row`},bT=[`disabled`],xT={key:3,class:`hint`},ST={key:4,class:`sink-list`},CT={class:`head`},wT={class:`tag`},TT={class:`next`},ET={class:`url`},DT={key:0,class:`hint`},OT={key:1,class:`message-error`},kT={class:`row`},AT=[`disabled`,`onClick`],jT=[`disabled`,`onClick`],MT={key:5,class:`results`,"aria-label":`Test results`},NT={class:`tag`},PT={key:0},FT=Id(N({__name:`NotifyPanel`,setup(e){let t=k([]),n=k(``),r=k(``),i=k(!1),a=k([]),o=U(()=>K.value?.deviceId),s=()=>G(o.value??``),c=k(!1),l=k({kind:`webhook`,url:``,label:``,events:``});async function u(){if(!o.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await s().notifySinks()).sinks}catch(e){let t=e.code;r.value=t===`not_found`||/allowlist/i.test(cu(e))?"This device runs an older build: update it (`dpi update`) to use notifications.":cu(e).slice(0,160)}finally{i.value=!1}}M(o,u,{immediate:!0});let d=e=>{if(!e)return`never`;let t=Math.round((Date.now()-e)/6e4);return t<1?`just now`:t<60?`${t}m ago`:`${Math.round(t/60)}h ago`};async function f(){let e=l.value;if(e.url.trim()){n.value=`new`;try{await s().createNotifySink({kind:e.kind,url:e.url.trim(),...e.label.trim()?{label:e.label.trim()}:{},...e.events.trim()?{events:e.events.split(`,`).map(e=>e.trim()).filter(Boolean)}:{}}),c.value=!1,l.value={kind:`webhook`,url:``,label:``,events:``},await u(),J(`Sink added on the device.`)}catch(e){J(cu(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(cu(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(cu(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(I(),L(`section`,dT,[z(`header`,fT,[z(`span`,null,[B(A(Xs),{size:16}),s[6]||=V(`NOTIFY`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[B(A($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,pT),z(`button`,{class:`icon-button`,disabled:!o.value||!t.value.length||n.value===`test`,"aria-label":`Send a test notification`,title:`Send a test event through every enabled sink`,onClick:h},[B(A(nl),{size:15})],8,mT),z(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[B(A(Xc),{size:15})],8,hT)]),s[14]||=z(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(I(),L(`p`,_T,D(r.value),1)):H(``,!0):(I(),L(`p`,gT,`Select a session to see its device.`)),c.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(f,[`prevent`])},[z(`label`,null,[s[8]||=V(`Kind `,-1),j(z(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[z(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),z(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Ss,l.value.kind]])]),z(`label`,null,[s[9]||=V(`URL `,-1),j(z(`input`,{"onUpdate:modelValue":s[2]||=e=>l.value.url=e,placeholder:l.value.kind===`ntfy`?`https://ntfy.sh/my-topic`:`https://example.com/hook`,required:``},null,8,vT),[[ys,l.value.url]])]),z(`label`,null,[s[10]||=V(`Label`,-1),j(z(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[ys,l.value.label]])]),z(`label`,null,[s[11]||=V(`Events `,-1),j(z(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[ys,l.value.events]])]),z(`div`,yT,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`adding…`:`Add sink`),9,bT),z(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=z(`p`,{class:`hint`},[V(`LAN targets (192.168.x, localhost) need `),z(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),V(` on the device.`)],-1)],32)):H(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(I(),L(`p`,xT,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):H(``,!0),t.value.length?(I(),L(`ul`,ST,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`sink`,{off:!e.enabled}])},[z(`div`,CT,[z(`span`,wT,D(e.kind),1),z(`b`,null,D(e.label||e.url),1),z(`em`,TT,D(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),z(`code`,ET,D(e.url),1),e.events?.length?(I(),L(`p`,DT,`events: `+D(e.events.join(`, `)),1)):H(``,!0),e.lastError?(I(),L(`p`,OT,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,kT,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[B(A(Zc),{size:12}),V(D(e.enabled?`disable`:`enable`),1)],8,AT),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[B(A(dl),{size:12}),s[13]||=V(`remove`,-1)],8,jT)])],2))),128))])):H(``,!0),a.value.length?(I(),L(`ul`,MT,[(I(!0),L(F,null,P(a.value,e=>(I(),L(`li`,{key:e.id,class:E(e.status)},[z(`span`,NT,D(e.status),1),V(` `+D(e.kind)+` `+D(e.id.slice(0,8))+` `,1),e.detail?(I(),L(`em`,PT,D(e.detail),1)):H(``,!0)],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-4b0b0465`]]),IT={class:`env-panel`,"aria-label":`Device environment`},LT={class:`panel-heading`},RT=[`disabled`],zT=[`disabled`],BT={key:0,class:`hint`},VT={key:1,class:`message-error`},HT={key:2,class:`message-restart`},UT={class:`row`},WT=[`disabled`],GT={key:4,class:`hint`},KT={key:5,class:`var-list`},qT={class:`head`},JT={class:`key`},YT={class:`tag`},XT={key:0,class:`tag`,title:`Has its own setting; edit that instead`},ZT=[`aria-label`,`title`,`onClick`],QT=[`aria-label`,`onClick`],$T=[`title`],eE={key:6,class:`hint path`},tE=Id(N({__name:`EnvPanel`,setup(e){let t=k(null),n=k(!1),r=k(``),i=k(``),a=U(()=>K.value?.deviceId),o=()=>G(a.value??``),s=k(!1),c=k({key:``,value:``});async function l(){if(!a.value)return void(t.value=null);n.value=!0,r.value=``;try{t.value=await o().envView()}catch(e){let t=cu(e);r.value=e.code===`not_found`||/allowlist/i.test(t)?"This device runs an older build: update it (`dpi update`) to edit env vars.":t.slice(0,160)}finally{n.value=!1}}M(a,l,{immediate:!0});let u=e=>e.source===`file`&&!e.managed;async function d(){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(cu(e).slice(0,160))}finally{i.value=``}}}function f(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 p(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)=>(I(),L(`section`,IT,[z(`header`,LT,[z(`span`,null,[B(A(gc),{size:16}),o[4]||=V(`ENV`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,RT),z(`button`,{class:`icon-button`,disabled:!a.value||!!r.value,"aria-label":`Add an env var`,title:`Add an env var to the device's env file`,onClick:o[0]||=e=>s.value=!s.value},[B(A(Xc),{size:15})],8,zT)]),o[10]||=z(`p`,{class:`hint`},` The device's env file — loaded once at boot. Keys here reach the daemon and its sessions. `,-1),a.value?r.value?(I(),L(`p`,VT,D(r.value),1)):t.value?.restartRequired?(I(),L(`p`,HT,[...o[5]||=[V(` Changed since boot — restart the device (`,-1),z(`code`,null,`dpi device stop && dpi device start`,-1),V(`) to apply. `,-1)]])):H(``,!0):(I(),L(`p`,BT,`Select a session to see its device.`)),s.value?(I(),L(`form`,{key:3,class:`add-form`,onSubmit:ks(d,[`prevent`])},[z(`label`,null,[o[6]||=V(`Key (UPPER_SNAKE_CASE)`,-1),j(z(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[ys,c.value.key]])]),z(`label`,null,[o[7]||=V(`Value`,-1),j(z(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[ys,c.value.value]])]),z(`div`,UT,[z(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},D(i.value===`new`?`saving…`:`Save to env file`),9,WT),z(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[8]||=z(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):H(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(I(),L(`p`,GT,` No vars in the env file yet. `)):H(``,!0),t.value?.vars.length?(I(),L(`ul`,KT,[(I(!0),L(F,null,P(t.value.vars,e=>(I(),L(`li`,{key:e.key,class:E([`var`,{ro:!u(e)}])},[z(`div`,qT,[z(`code`,JT,D(e.key),1),z(`span`,YT,D(e.source===`process`?`process`:`file`),1),e.managed?(I(),L(`span`,XT,`managed`)):H(``,!0),o[9]||=z(`span`,{class:`spacer`},null,-1),u(e)?(I(),L(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>f(e)},[B(A(qc),{size:13})],8,ZT)):H(``,!0),u(e)?(I(),L(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>p(e)},[B(A(dl),{size:13})],8,QT)):H(``,!0)]),z(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},D(e.masked),9,$T)],2))),128))])):H(``,!0),t.value?(I(),L(`p`,eE,D(t.value.envFile),1)):H(``,!0)]))}}),[[`__scopeId`,`data-v-3c11d19f`]]),nE={class:`extensions-panel`},rE={class:`panel-heading`},iE={key:0,class:`task-empty`},aE=[`data-extension`],oE={class:`ext-head`},sE=[`aria-checked`,`aria-label`,`disabled`,`onClick`],cE=[`checked`,`disabled`,`onChange`],lE=N({__name:`ExtensionsPanel`,setup(e){let t=rn(),n=k(!1);async function r(){let e=Fu.value;if(!e||!ku.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}M([Fu,ku,()=>JSON.stringify(Gu.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=Fu.value;if(r&&!n.value){n.value=!0;try{let n=await ad(()=>r.setExtension(e));n&&(t.value=n),ed()}finally{n.value=!1}}}return(e,r)=>(I(),L(`div`,nE,[z(`div`,rE,[r[0]||=z(`h2`,null,`Extensions`,-1),B(A(Qc),{size:18})]),r[3]||=z(`p`,{class:`hint`},` Custom harness capabilities for this agent. Turn one on and the next request uses it. The choice is stored with the agent, so it survives restarts. `,-1),t.value?H(``,!0):(I(),L(`p`,iE,`Loading extensions…`)),(I(!0),L(F,null,P(t.value?.extensions??[],e=>(I(),L(`article`,{key:e.name,class:E([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[z(`div`,oE,[z(`div`,null,[z(`strong`,null,D(e.title),1),z(`code`,null,D(e.name),1)]),z(`button`,{class:E([`switch`,{on:e.enabled}]),role:`switch`,"aria-checked":e.enabled,"aria-label":e.title,disabled:n.value,onClick:t=>i({name:e.name,enabled:!e.enabled})},[...r[1]||=[z(`span`,null,null,-1)]],10,sE)]),z(`p`,null,D(e.description),1),e.prompts?(I(),L(`ul`,{key:0,class:E([`ext-prompts`,{off:!e.enabled}])},[(I(!0),L(F,null,P(e.prompts,e=>(I(),L(`li`,{key:e.id},[z(`label`,null,[z(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,cE),z(`code`,null,D(e.id),1)]),z(`span`,null,D(e.description),1),z(`details`,null,[r[2]||=z(`summary`,null,`View prompt`,-1),z(`pre`,null,D(e.text),1)])]))),128))],2)):H(``,!0)],10,aE))),128))]))}}),uE={class:`context-section`,"aria-labelledby":`context-title`},dE={class:`section-label`},fE={key:0,class:`hint`},pE={class:`context-numbers`},mE={class:`context-pct`},hE={key:0,class:`context-compacting`},gE=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],_E={class:`context-marker-label`},vE=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],yE={class:`context-marker-label`},bE={class:`hint context-hint`},xE={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},SE={class:`context-toggle`},CE=[`checked`],wE=512,TE=4096,EE=1024,DE=N({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=U(()=>Zu.value?.contextWindow??0),r=U(()=>{let e=Gu.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}),i=U(()=>Gu.value.compactions.length>0),a=k(),o=U(()=>a.value??Nu.value?.compaction??av(n.value));M(()=>JSON.stringify(Nu.value?.compaction),e=>{a.value&&e===JSON.stringify(a.value)&&(a.value=void 0)});let s=k(),c=U(()=>q.dialog?.kind===`compaction`),l=()=>void(q.dialog=void 0);Gr(()=>c.value&&l());let u=U(()=>s.value??ov(n.value,o.value)),d=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,f=U(()=>Math.round(100*r.value/(n.value||1))),p=e=>{let t=e/(n.value||1);return t<.35?`start`:t>.65?`end`:`center`},m=(e,t)=>Math.min(n.value-EE,Math.max((t??TE)+EE,e)),h=(e,t)=>Math.min(t-EE,Math.max(TE,e));function g(e,t){let n=u.value,r=Math.round(t/wE)*wE;s.value=e===`wait`?{auto:n.auto,wait:m(r,n.auto)}:{auto:h(r,n.wait),wait:n.wait}}async function _(e){let t=Iu.value;if(!t)return;let n=await ad(()=>t.setCompaction(e));n&&(a.value=n),s.value=void 0}function v(){let e=s.value;e&&_({reserveTokens:n.value-e.wait,...e.auto===void 0?{}:{backgroundTokens:e.wait-e.auto}})}let y=k(),b;function x(e,t){b=e,t.currentTarget.setPointerCapture(t.pointerId)}function S(e){if(!b||!y.value)return;let t=y.value.getBoundingClientRect();g(b,(e.clientX-t.left)/t.width*n.value)}function C(){b&&(b=void 0,v())}function ee(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=u.value;g(e,(e===`auto`?r.auto??TE:r.wait)+n)}return(e,a)=>(I(),L(F,null,[z(`section`,uE,[z(`div`,dE,[a[7]||=z(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(I(),L(`button`,{key:0,class:`context-details-toggle`,onClick:a[0]||=e=>A(q).dialog={kind:`compaction`}},[B(A(Oc),{size:16}),a[6]||=V(`Details `,-1)])):H(``,!0)]),n.value?(I(),L(F,{key:1},[z(`div`,pE,[z(`strong`,null,D(t(r.value)),1),z(`span`,null,`of `+D(t(n.value))+` tokens`,1),z(`span`,mE,D(f.value)+`%`,1),i.value?(I(),L(`span`,hE,[...a[8]||=[z(`i`,null,null,-1),V(`Compacting`,-1)]])):H(``,!0)]),z(`div`,{ref_key:`bar`,ref:y,class:E([`context-bar`,{off:!o.value.enabled}]),onPointermove:S,onPointerup:C,onPointercancel:C},[z(`div`,{class:E([`context-fill`,{hot:u.value.auto!==void 0&&r.value>=u.value.auto}]),style:ge({width:d(r.value)})},null,6),z(`div`,{class:`context-reserve`,style:ge({left:d(u.value.wait)}),title:`Reserved for the answer`},null,4),u.value.auto===void 0?H(``,!0):(I(),L(`button`,{key:0,class:E([`context-marker auto`,`label-${p(u.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":TE,"aria-valuemax":u.value.wait-EE,"aria-valuenow":u.value.auto,"aria-valuetext":`${t(u.value.auto)} tokens`,style:ge({left:d(u.value.auto)}),onPointerdown:a[1]||=e=>x(`auto`,e),onKeydown:a[2]||=e=>ee(`auto`,e),onKeyup:v,onBlur:v},[z(`span`,_E,`Auto-compact at `+D(t(u.value.auto)),1)],46,gE)),z(`button`,{class:E([`context-marker wait`,`label-${p(u.value.wait)}`]),role:`slider`,"aria-label":`The next request waits for a summary at`,"aria-valuemin":(u.value.auto??TE)+EE,"aria-valuemax":n.value-EE,"aria-valuenow":u.value.wait,"aria-valuetext":`${t(u.value.wait)} tokens, ${t(n.value-u.value.wait)} reserved`,style:ge({left:d(u.value.wait)}),onPointerdown:a[3]||=e=>x(`wait`,e),onKeydown:a[4]||=e=>ee(`wait`,e),onKeyup:v,onBlur:v},[z(`span`,yE,`Reserve at `+D(t(u.value.wait)),1)],46,vE)],34),z(`p`,bE,[o.value.enabled?(I(),L(F,{key:0},[a[9]||=V(`Compacts in the background at `,-1),z(`strong`,null,D(t(u.value.auto??u.value.wait)),1),a[10]||=V(` and waits at `,-1),z(`strong`,null,D(t(u.value.wait)),1),a[11]||=V(`.`,-1)],64)):(I(),L(F,{key:1},[V(`Automatic compaction is off.`)],64))])],64)):(I(),L(`div`,fE,`Pick a model to see its context window.`))]),(I(),R(lr,{to:`body`},[c.value?(I(),L(`div`,{key:0,class:`modal-backdrop`,onClick:ks(l,[`self`])},[z(`section`,xE,[z(`header`,null,[a[12]||=z(`h2`,{id:`compaction-title`},`Context compaction`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:l},[B(A(vl),{size:18})])]),z(`p`,null,[a[13]||=V(` A summary starts in the background at `,-1),z(`strong`,null,D(t(u.value.auto??u.value.wait)),1),a[14]||=V(`. Above `,-1),z(`strong`,null,D(t(u.value.wait)),1),V(` the next request waits for it, keeping `+D(t(n.value-u.value.wait))+` free for the answer. Drag a marker on the bar to change either point. `,1)]),a[16]||=z(`p`,null,[V(`Older entries stay stored, and `),z(`code`,null,`search_history`),V(` still finds them.`)],-1),z(`label`,SE,[z(`input`,{type:`checkbox`,checked:o.value.enabled,onChange:a[5]||=e=>_({enabled:e.target.checked})},null,40,CE),a[15]||=V(` Automatic compaction `,-1)]),a[17]||=z(`p`,{class:`hint`},[V(` Applies to every agent in this session. `),z(`code`,null,`/compact`),V(` works either way. `)],-1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:l},`Close`)])])])):H(``,!0)]))],64))}}),OE=/^[A-Za-z_$][\w$]*$/,kE=e=>` `.repeat(e);function AE(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`),jE(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function jE(e,t,n){if(!e||typeof e!=`object`)return n(`unknown`,`type`);if(`const`in e)return PE(e.const,n);if(e.enum)return NE(e.enum.map(e=>({const:e})),t,n);if(e.anyOf??e.oneOf)return NE(e.anyOf??e.oneOf,t,n);if(Array.isArray(e.type))return NE(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`),jE(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return ME(e,t,n);default:return n(`unknown`,`type`)}}function ME(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`),jE(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
|
|
80
|
-
`);for(let[e,a]of r){let r=
|
|
81
|
-
`)}n(kE(t)),n(`}`,`punct`)}function NE(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),jE(e,t,n)})}function PE(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 FE(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(` `)} */`:``}var IE={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},LE=[`title`],RE=[`aria-label`,`title`,`onClick`],zE={key:0,class:`count`},BE={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},VE=[`id`,`aria-selected`,`onClick`],HE={key:0,class:`count`},UE=[`title`],WE=[`aria-labelledby`],GE={class:`session-heading`},KE=[`disabled`],qE=[`title`],JE={class:`cwd-trail`,dir:`rtl`},YE={dir:`ltr`},XE={class:`session-status`},ZE={key:0,class:`background-pill`},QE=[`title`],$E={class:`model-section`},eD=[`src`],tD={class:`thinking-row`},nD=[`value`],rD={class:`stats-section`,"aria-labelledby":`stats-title`},iD={class:`metrics`},aD=[`title`],oD={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},sD={scope:`row`},cD={class:`usage-total`},lD={class:`panel-heading`},uD={class:`hint app-state-description`},dD=[`disabled`],fD={class:`state-json-actions`},pD={key:0,class:`hint`},mD=[`disabled`],hD=[`disabled`],gD={key:0,class:`message-error`,role:`alert`},_D={class:`panel-heading`},vD={class:`tag`},yD={class:`hook-card`},bD=[`aria-checked`],xD={key:0,class:`tag tool-disabled`},SD={class:`tag`},CD=[`aria-label`],wD=Id(N({__name:`Inspector`,setup(e){let t=U(()=>new Map(Qu.value?.tools.map(e=>[e.name,AE(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:yc},{id:`git`,label:`Git`,icon:xc},{id:`host`,label:`Host`,icon:Vs},{id:`usage`,label:`Usage`,icon:Jc},{id:`auto`,label:`Auto`,icon:ec},{id:`notify`,label:`Notify`,icon:Xs},{id:`env`,label:`Env`,icon:gc},{id:`state`,label:`State`,icon:Qs},{id:`tasks`,label:`Tasks`,icon:Vs},{id:`tools`,label:`Tools`,icon:_l},{id:`extensions`,label:`Extend`,icon:Qc}],r=U(()=>[{label:`Input`,tokens:Xu.value.input,cost:Xu.value.inputCost},{label:`Output`,tokens:Xu.value.output,cost:Xu.value.outputCost},{label:`Cache read`,tokens:Xu.value.cacheRead,cost:Xu.value.cacheReadCost},{label:`Cache write`,tokens:Xu.value.cacheWrite,cost:Xu.value.cacheWriteCost}]),i=U(()=>Ju.value.filter(e=>e.background).length),a=k(!1);function o(e,t){ad(async()=>{await Fu.value.configure(e),await ed(),t&&J(t)})}async function s(){let e=Ou.value,t=Nu.value;if(e&&t)try{let n=await G(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: ${cu(e).slice(0,120)}`)}}async function c(){let e=Ou.value,t=Nu.value;if(e&&t){a.value=!0;try{let n=await G(e.id).exportSession(t.id),r=Uint8Array.from(atob(n.base64),e=>e.charCodeAt(0)),i=URL.createObjectURL(new Blob([r],{type:n.mime||`application/zip`})),a=document.createElement(`a`);a.href=i,a.download=n.filename,a.click(),URL.revokeObjectURL(i),J(`Bundle downloaded (${Math.max(1,Math.round(n.bytes/1024))} KiB).`)}catch(e){J(`bundle export failed: ${cu(e).slice(0,120)}`)}finally{a.value=!1}}}function l(){let e=Iu.value;e&&(q.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:Nu.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let u=Mu.sharedState,d=k(``),f=k(``),p=k(0),m=k(!1),h=k(``),g=U(()=>d.value!==f.value),_=U(()=>g.value&&u.value?.revision!==p.value);function v(){d.value=cd(u.value?.value??{}),f.value=d.value,p.value=u.value?.revision??0,h.value=``}M(u,()=>!g.value&&v(),{immediate:!0});async function y(e){if(!m.value&&Fu.value){m.value=!0,h.value=``;try{await Fu.value.demo(`state`,e)}catch(e){h.value=cu(e)}finally{m.value=!1}}}async function b(){if(!m.value&&Fu.value){h.value=``,m.value=!0;try{let e=JSON.parse(d.value);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`App State must be a JSON object.`);let t=await Fu.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:p.value});d.value=cd(t.value),f.value=d.value,p.value=t.revision,J(`Shared App State saved.`)}catch(e){h.value=cu(e)}finally{m.value=!1}}}let x=U(()=>Qu.value?.config.readOnly===!0),S=U(()=>Qu.value?.tools.filter(e=>e.offered).length??0);return(e,f)=>(I(),L(`aside`,{class:E([`inspector`,{collapsed:!A(hd),overlay:A(q).inspectorOverlay}])},[A(hd)?(I(),L(F,{key:1},[z(`div`,BE,[(I(),L(F,null,P(n,e=>z(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":A(q).tab===e.id,class:E({active:A(q).tab===e.id}),onClick:t=>A(q).tab=e.id},[(I(),R($r(e.icon),{size:18})),V(D(e.label),1),e.id===`tasks`&&A(Ju).length?(I(),L(`span`,HE,D(A(Ju).length),1)):H(``,!0)],10,VE)),64)),z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${A(xd).inspector})`,onClick:f[1]||=e=>A(_d)()},[B(A(Uc),{size:18})],8,UE)]),z(`div`,{id:`inspector-panel`,class:E([`inspector-body`,{"session-panel":A(q).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${A(q).tab}`},[A(q).tab===`session`?(I(),L(F,{key:0},[z(`section`,GE,[z(`h1`,null,[z(`span`,null,D(A(Nu)?.name??`Loading session`),1),z(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:l},[B(A(qc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:s},[B(A(pc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:a.value,onClick:c},[B(A(Hc),{size:18})],8,KE)]),z(`button`,{class:`path cwd-button`,title:A(Nu)?.cwd,"aria-label":`Show full working directory`,onClick:f[2]||=e=>A(q).dialog={kind:`path`,path:A(Nu)?.cwd??``}},[B(A(yc),{size:18}),z(`span`,JE,[z(`bdi`,YE,D(A(Nu)?.cwd),1)])],8,qE),z(`div`,XE,[z(`span`,{class:E([`status-pill`,{working:A(Yu)}])},[f[7]||=z(`i`,null,null,-1),V(D(A(Yu)?`Working`:`Idle`),1)],2),i.value?(I(),L(`span`,ZE,D(i.value)+` background`,1)):H(``,!0),z(`span`,{class:`saved`,title:A(Ou)?.id},[B(A(rl),{size:18}),V(D(A(Ou)?.name??A(Ou)?.id),1)],8,QE),A(Ou)?(I(),R(Ry,{key:1,device:A(Ou)},null,8,[`device`])):H(``,!0)])]),A(Ou)?(I(),R(tb,{key:0,device:A(Ou)},null,8,[`device`])):H(``,!0),z(`section`,$E,[f[15]||=z(`div`,{class:`section-label`},[z(`span`,null,`AGENT`)],-1),z(`button`,{class:`model-button`,onClick:f[3]||=e=>A(q).dialog={kind:`models`}},[z(`img`,{src:A(ld)(A(Gu).agent.model?.modelId),alt:``},null,8,eD),z(`div`,null,[z(`strong`,null,D(A(Zu)?.name??A(Gu).agent.model?.modelId??`Loading…`),1),z(`small`,null,D(A(Zu)?.tier??``)+` / `+D(A(Gu).agent.model?.provider??``),1)]),B(A(nc),{size:18})]),z(`div`,tD,[f[8]||=z(`span`,null,`Thinking`,-1),z(`select`,{"aria-label":`Thinking level`,value:A(Gu).agent.thinkingLevel??`low`,onChange:f[4]||=e=>o({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(I(!0),L(F,null,P(A(nv),e=>(I(),L(`option`,{key:e},D(e),1))),128))],40,nD)]),B(DE),z(`section`,rD,[f[14]||=z(`div`,{class:`section-label`},[z(`span`,{id:`stats-title`},`STATS`)],-1),z(`div`,iD,[z(`div`,{title:`${A(Xu).tokens.toLocaleString(`en-US`)} total tokens`},[z(`span`,null,D(A(sd)(A(Xu).tokens)),1),f[9]||=z(`small`,null,`total tokens`,-1)],8,aD),z(`div`,null,[z(`span`,null,`$`+D(A(Xu).cost.toFixed(4)),1),f[10]||=z(`small`,null,`agent cost`,-1)]),z(`div`,null,[z(`span`,null,D(A(Qu)?.tools.length??0),1),f[11]||=z(`small`,null,`tools`,-1)])]),z(`table`,oD,[f[13]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Type`),z(`th`,{scope:`col`},`Tokens`),z(`th`,{scope:`col`},`Cost (USD)`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(r.value,e=>(I(),L(`tr`,{key:e.label},[z(`th`,sD,D(e.label),1),z(`td`,null,D(e.tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(e.cost.toFixed(4)),1)]))),128)),z(`tr`,cD,[f[12]||=z(`th`,{scope:`row`},`Total`,-1),z(`td`,null,D(A(Xu).tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(A(Xu).cost.toFixed(4)),1)])])])])])],64)):H(``,!0),A(q).tab===`state`?(I(),L(F,{key:1},[z(`div`,lD,[f[16]||=z(`h2`,null,`App State`,-1),B(A(Qs),{size:18})]),z(`p`,uD,` One shared JSON object for every agent, session and fork on `+D(A(Ou)?.name??A(Ou)?.id)+`. You and your agents can read, create, update or delete values and fields. Changes appear live and persist across closed browsers, interrupted agents and backend restarts. `,1),j(z(`textarea`,{"onUpdate:modelValue":f[5]||=e=>d.value=e,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:m.value||!A(u),rows:`12`},null,8,dD),[[ys,d.value]]),z(`div`,fD,[_.value?(I(),L(`span`,pD,`State changed elsewhere. Load the latest JSON before saving.`)):H(``,!0),g.value?(I(),L(`button`,{key:1,class:`secondary`,disabled:m.value,onClick:v},D(_.value?`Load latest`:`Reset`),9,mD)):H(``,!0),z(`button`,{class:`primary small`,disabled:!g.value||m.value||_.value,onClick:b},D(m.value?`Saving…`:`Save JSON`),9,hD)]),h.value?(I(),L(`p`,gD,D(h.value),1)):H(``,!0),B(My,{value:A(u)?.value??{},disabled:m.value||g.value||!A(u),onChange:y},null,8,[`value`,`disabled`])],64)):H(``,!0),A(q).tab===`tasks`?(I(),R(Mb,{key:2})):H(``,!0),A(q).tab===`git`?(I(),R(TC,{key:3})):H(``,!0),A(q).tab===`host`?(I(),R(qC,{key:4})):H(``,!0),A(q).tab===`usage`?(I(),R(Iw,{key:5})):H(``,!0),A(q).tab===`auto`?(I(),R(uT,{key:6})):H(``,!0),A(q).tab===`notify`?(I(),R(FT,{key:7})):H(``,!0),A(q).tab===`env`?(I(),R(tE,{key:8})):H(``,!0),A(q).tab===`extensions`?(I(),R(lE,{key:9})):H(``,!0),A(q).tab===`tools`?(I(),L(F,{key:10},[z(`div`,_D,[f[17]||=z(`h2`,null,`Tools`,-1),z(`span`,vD,D(S.value)+` / `+D(A(Qu)?.tools.length??0),1)]),f[21]||=z(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),z(`div`,yD,[z(`div`,null,[B(A(al),{size:18}),f[19]||=z(`strong`,null,`Read only`,-1),z(`button`,{class:E([`switch`,{on:x.value}]),role:`switch`,"aria-checked":x.value,"aria-label":`Read only`,onClick:f[6]||=e=>o({readOnly:!x.value},x.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...f[18]||=[z(`span`,null,null,-1)]],10,bD)]),f[20]||=z(`p`,null,` Offers this agent only tools that read. Tools that create, update or delete leave its next request, and the choice is stored with the agent. `,-1)]),(I(!0),L(F,null,P(A(Qu)?.tools,e=>(I(),L(`details`,{key:e.name,class:E([`tool-row`,{disabled:!e.offered}])},[z(`summary`,null,[B(A(_l),{size:18}),z(`strong`,null,D(e.name),1),e.offered?H(``,!0):(I(),L(`span`,xD,`disabled`)),z(`span`,SD,D(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),z(`p`,null,D(e.description),1),e.parameters?(I(),L(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[z(`code`,null,[(I(!0),L(F,null,P(t.value.get(e.name),(e,t)=>(I(),L(`span`,{key:t,class:E(`tk-${e.kind}`)},D(e.text),3))),128))])],8,CD)):H(``,!0),z(`small`,null,D(e.replay===`safe`?`An interrupted execution may run again after recovery.`:`A crash records an interrupted result instead of rerunning this effect.`),1)],2))),128))],64)):H(``,!0)],10,WE)],64)):(I(),L(`div`,IE,[z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${A(xd).inspector})`,onClick:f[0]||=e=>A(gd)()},[B(A(Wc),{size:18})],8,LE),(I(),L(F,null,P(n,e=>z(`button`,{key:e.id,class:E([`rail-tab`,{active:A(q).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>A(gd)(e.id)},[(I(),R($r(e.icon),{size:20})),e.id===`tasks`&&A(Ju).length?(I(),L(`span`,zE,D(A(Ju).length),1)):H(``,!0)],10,RE)),64))]))],2))}}),[[`__scopeId`,`data-v-815b91a5`]]),TD={class:`chat-empty`},ED={class:`eyebrow`},DD={key:3,class:`hint offline-error`},OD={key:4,class:`offline-command`},kD={key:5,class:`hint`},AD={key:6,class:`hint`},jD={class:`offline-actions`},MD=[`disabled`],ND={key:7,class:`message-error`,role:`alert`},PD=N({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=k(!1),r=k(``),i=U(()=>{let e=t.device,n=e.source===`config`;switch(e.status){case`checking`:return{title:`Checking ${e.id}…`,text:`Probing the device. This view fills in as soon as it answers.`};case`unauthorized`:return e.transport===`tunnel`?{title:`${e.id} tunnel credentials are not valid`,text:`Pair the device again — the hub will mint a fresh credential.`}:{title:e.hasToken?`${e.id} rejected its token`:`No token for ${e.id}`,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.id} 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.id} speaks another API version`,text:`Update the device's dpi-backend.`,command:n?`just net deploy ${e.id}`:void 0};default:return{title:`${e.id} is offline`,text:`Last seen ${ud(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 su.check(t.device.id);e.status===`online`&&J(`${e.id} is online.`)}catch(e){r.value=cu(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)=>(I(),L(`section`,{class:E([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[z(`div`,TD,[e.device.status===`checking`?(I(),R(A(Ic),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(I(),R(A(il),{key:1,size:30})):(I(),R(A(ml),{key:2,size:30})),z(`span`,ED,D(e.device.kind.toUpperCase())+` · `+D(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),z(`h2`,null,D(i.value.title),1),z(`p`,null,D(i.value.text),1),e.device.error?(I(),L(`p`,DD,D(e.device.error),1)):H(``,!0),i.value.command?(I(),L(`div`,OD,[z(`code`,null,D(i.value.command),1),z(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[B(A(sc),{size:18})])])):H(``,!0),i.value.command?(I(),L(`p`,kD,`Run it in this repo's terminal, then press Check now.`)):H(``,!0),i.value.alt?(I(),L(`p`,AD,[s[2]||=V(` Never deployed or rebuilt? `,-1),z(`code`,null,D(i.value.alt),1),s[3]||=V(` provisions it from scratch. `,-1)])):H(``,!0),z(`div`,jD,[z(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[B(A($c),{size:18}),V(D(n.value?`Checking…`:`Check now`),1)],8,MD)]),r.value?(I(),L(`p`,ND,D(r.value),1)):H(``,!0)])],2))}}),FD={class:`dir-browser`},ID={class:`dir-path`},LD=[`disabled`],RD=[`aria-busy`],zD=[`title`],BD=[`aria-selected`,`title`,`onClick`],VD={key:1,class:`hint`},HD={key:0,class:`message-error`,role:`alert`},UD=N({__name:`DirBrowser`,props:si({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Di(e,`modelValue`),r=k(),i=k(!1),a=k(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await G(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=cu(e));return}finally{s===o&&(i.value=!1)}}return M(()=>t.deviceId,async()=>{r.value=void 0;let e=await s(``),t=e?.dirs[0];t&&!e.path&&await s(t.path)},{immediate:!0}),(e,t)=>(I(),L(`div`,FD,[z(`div`,ID,[j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,"aria-label":`Working directory`,required:``,placeholder:`/path/to/project`,spellcheck:`false`,autocomplete:`off`,onKeydown:t[1]||=js(ks(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[ys,n.value]]),z(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,LD)]),z(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[z(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[B(A(Dc),{size:16}),t[5]||=z(`span`,null,`Start dirs`,-1)]),r.value?.parent?(I(),L(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[B(A(lc),{size:16}),t[6]||=z(`span`,null,`..`,-1)],8,zD)):H(``,!0),(I(!0),L(F,null,P(r.value?.dirs,e=>(I(),L(`button`,{key:e.path,type:`button`,class:`dir-item`,role:`option`,"aria-selected":e.path===n.value,title:e.path,onClick:t=>s(e.path)},[e.path===n.value?(I(),R(A(yc),{key:0,size:16})):(I(),R(A(bc),{key:1,size:16})),z(`span`,null,D(e.name),1)],8,BD))),128)),r.value&&!r.value.dirs.length?(I(),L(`p`,VD,`No subdirectories.`)):H(``,!0)],8,RD),a.value?(I(),L(`p`,HD,D(a.value),1)):H(``,!0)]))}}),WD={key:0,class:`message-error`},GD=[`value`],KD={class:`field`},qD={key:0,class:`recent-cwds`},JD=[`title`,`onClick`],YD={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`},XD=[`value`],ZD={key:2,class:`message-error`,role:`alert`},QD=[`disabled`],$D=`dpi-recent-cwds`,eO=Id(N({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>bu.devices.value.filter(e=>e.status===`online`)),a=k(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=U(()=>i.value.find(e=>e.id===a.value)),s=U(()=>{let e=o.value?.info?.models??[];if(e.length)return e;let t=o.value?.info;return t?.defaultModel&&t.provider?[{id:t.defaultModel,provider:t.provider,name:`${t.defaultModel} (device default)`,tier:`—`,icon:`lab.png`,contextWindow:0,reasoning:!1,cost:{input:0,output:0}}]:[]}),c=U(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=U(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=k({name:``,cwd:``,model:``}),f=U(()=>{try{return JSON.parse(localStorage.getItem($D)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem($D)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem($D,JSON.stringify({...n,[e]:r}))}catch{}},m=k(!1),h=k(``),g=k({});M(a,async e=>{if(g.value={},e)try{let{projects:t}=await G(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),M([()=>d.value.cwd,g],()=>{let e=d.value.cwd;if(!e)return;let t=Object.keys(g.value).filter(t=>e===t||e.startsWith(`${t}/`)).sort((e,t)=>t.length-e.length),n=t.length?g.value[t[0]]:void 0;n&&(d.value.model=`${n.provider}/${n.modelId}`)},{immediate:!0}),M(o,e=>{let t=s.value,n=t.find(t=>t.id===e?.info?.defaultModel)??t[0];d.value.model=n?u(n):``,d.value.cwd=``},{immediate:!0});async function _(){if(!m.value&&o.value){m.value=!0,h.value=``;try{let e=s.value.find(e=>u(e)===d.value.model)??s.value[0];if(!e)throw Error(`Choose a model`);let t=await G(o.value.id).createSession({name:d.value.name.trim()||`New session`,cwd:d.value.cwd.trim(),model:{provider:e.provider,modelId:e.id}});p(o.value.id,t.cwd);let n=t.agents.find(e=>e.kind===`root`)??t.agents[0];Lu({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),J(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=cu(e)}finally{m.value=!1}}}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[6]||=ks(e=>r(`close`),[`self`])},[z(`form`,{class:`modal session-modal`,onSubmit:ks(_,[`prevent`])},[z(`header`,null,[t[7]||=z(`div`,null,[z(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),z(`h2`,null,`New session`)],-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[B(A(vl),{size:18})])]),i.value.length?(I(),L(F,{key:1},[z(`label`,null,[t[8]||=V(`Device`,-1),j(z(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(I(!0),L(F,null,P(i.value,e=>(I(),L(`option`,{key:e.id,value:e.id},D(e.name)+D(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,GD))),128))],512),[[Ss,a.value]])]),z(`label`,null,[t[9]||=V(`Session name`,-1),j(z(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[ys,d.value.name]])]),z(`div`,KD,[z(`span`,null,`Working directory on `+D(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(I(),L(`div`,qD,[(I(!0),L(F,null,P(f.value,e=>(I(),L(`button`,{key:e,type:`button`,class:E([`chip`,{on:e===d.value.cwd}]),title:e,onClick:t=>d.value.cwd=e},D(e.split(`/`).filter(Boolean).at(-1)||e),11,JD))),128))])):H(``,!0),B(UD,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),z(`label`,null,[t[10]||=V(`Model`,-1),c.value||l.value?(I(),L(`span`,YD,`no API key on device — chat needs one`)):H(``,!0),j(z(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(I(!0),L(F,null,P(s.value,e=>(I(),L(`option`,{key:u(e),value:u(e)},D(e.tier)+` / `+D(e.name),9,XD))),128))],512),[[Ss,d.value.model]])])],64)):(I(),L(`p`,WD,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(I(),L(`p`,ZD,D(h.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,onClick:t[5]||=e=>r(`close`)},`Cancel`),z(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[B(A(Xc),{size:18}),V(D(m.value?`Creating…`:`Create session`),1)],8,QD)])],32)]))}}),[[`__scopeId`,`data-v-78a7a326`]]),tO=new Uint8Array(512),nO=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)tO[t]=e,nO[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)tO[e]=tO[e-255]})();var rO=(e,t)=>e===0||t===0?0:tO[nO[e]+nO[t]];function iO(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]^=rO(t[r],tO[n]);t=e}return t}function aO(e,t){let n=iO(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]^=rO(n[i+1],e)}return r}var oO=[21,25,29,33,37,41,45,49,53,57,61,65],sO=[19,34,55,80,108,136,156,194,232,274,324,370],cO=[7,10,15,20,26,36,40,48,60,72,80,96],lO=[7,10,15,20,26,18,20,24,30,18,20,24],uO=[[[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]]],dO=[[],[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]],fO=e=>e<=9?8:16;function pO(e){for(let t=1;t<=oO.length;t++)if(4+fO(t)+e*8<=sO[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${sO[11]-3})`)}function mO(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,fO(t));for(let e of n)i(e,8);let a=sO[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 hO(e,t){let n=lO[e-1],r=[],i=0;for(let[n,a]of uO[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=>aO(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function gO(e){return Array.from({length:e},()=>Array(e).fill(!1))}function _O(e,t){let n=oO[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=dO[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 vO(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 yO(e,t){let n=oO[0]*0+e.length,r=vO(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 bO(e,t,n,r){let i=e.length;oO[n-1]*oO[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(SO(l,i,n))continue;if(o>=(sO[n-1]+cO[n-1])*8){o++;continue}let t=a(o++);xO(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function xO(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 SO(e,t,n){let r=oO[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=dO[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 CO(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 wO(e,t){let n=pO(new TextEncoder().encode(e).length),r=oO[n-1],i=hO(n,mO(e,n)),a=gO(r);return _O(a,n),bO(a,i,n,t),yO(a,t),a}function TO(e,t){if(t!==void 0)return wO(e,t);let n;for(let t=0;t<8;t++){let r=wO(e,t),i=CO(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function EO(e,t=160){let n=TO(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 DO={class:`device-handoff`,"aria-label":`Pair this machine`},OO={class:`row`},kO=[`disabled`],AO=[`disabled`],jO={key:0,class:`target`,"data-testid":`device-url`},MO={key:1,class:`err`},NO=Id(N({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=k(`4780`),r=k(!1),i=U(()=>{let e=/^\d{1,5}$/.test(n.value)?Number(n.value):0;if(!(!e||e<1||e>65535))return`http://127.0.0.1:${e}/pair#${t.offerFragment}`});function a(){let e=i.value;e&&window.open(e,`_blank`,`noopener`)}async function o(){let e=i.value;if(e)try{await navigator.clipboard.writeText(e),r.value=!0,setTimeout(()=>r.value=!1,1600)}catch{}}return(e,t)=>(I(),L(`section`,DO,[z(`header`,null,[B(A(zc),{size:18}),t[1]||=z(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=z(`p`,{class:`what`},[V(` If this browser runs on the device itself, open its local pairing page — the offer is relayed inside the link, nothing is sent to the hub. Start `),z(`code`,null,`dpi device`),V(` there first. `)],-1),z(`div`,OO,[z(`label`,null,[t[2]||=V(` local port `,-1),j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[ys,n.value]])]),z(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[B(A(mc),{size:15}),t[3]||=V(`Open the device page `,-1)],8,kO),z(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[B(A(sc),{size:15}),V(D(r.value?`Copied`:`Copy link`),1)],8,AO)]),i.value?(I(),L(`p`,jO,D(i.value),1)):H(``,!0),i.value?H(``,!0):(I(),L(`p`,MO,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-01884b7b`]]);function PO(e){return UO(e)&&!FO(e)&&!qO(e)&&Symbol.asyncIterator in e}function FO(e){return Array.isArray(e)}function IO(e){return typeof e==`bigint`}function LO(e){return typeof e==`boolean`}function RO(e){return e instanceof globalThis.Date}function zO(e){return typeof e==`function`}function BO(e){return UO(e)&&!FO(e)&&!qO(e)&&Symbol.iterator in e}function VO(e){return e===null}function HO(e){return typeof e==`number`}function UO(e){return typeof e==`object`&&!!e}function WO(e){return e instanceof globalThis.RegExp}function GO(e){return typeof e==`string`}function KO(e){return typeof e==`symbol`}function qO(e){return e instanceof globalThis.Uint8Array}function JO(e){return e===void 0}function YO(e){return e.map(e=>ek(e))}function XO(e){return new Date(e.getTime())}function ZO(e){return new Uint8Array(e)}function QO(e){return new RegExp(e.source,e.flags)}function $O(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=ek(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=ek(e[n]);return t}function ek(e){return FO(e)?YO(e):RO(e)?XO(e):qO(e)?ZO(e):WO(e)?QO(e):UO(e)?$O(e):e}function tk(e){return ek(e)}function nk(e,t){return tk(t===void 0?e:{...t,...e})}function rk(e){return typeof e==`object`&&!!e}function ik(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function ak(e){return e===void 0}function ok(e){return typeof e==`number`}var sk;(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=rk(t);return e.AllowArrayObject?n:n&&!ik(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?ok(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=ak(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(sk||={});function ck(e){return globalThis.Object.freeze(e).map(e=>pk(e))}function lk(e){return e}function uk(e){return e}function dk(e){return e}function fk(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=pk(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=pk(e[n]);return globalThis.Object.freeze(t)}function pk(e){return FO(e)?ck(e):RO(e)?lk(e):qO(e)?uk(e):WO(e)?dk(e):UO(e)?fk(e):e}function Y(e,t){let n=t===void 0?e:{...t,...e};switch(sk.InstanceMode){case`freeze`:return pk(n);case`clone`:return tk(n);default:return n}}var mk=class extends Error{constructor(e){super(e)}},hk=Symbol.for(`TypeBox.Transform`),gk=Symbol.for(`TypeBox.Readonly`),_k=Symbol.for(`TypeBox.Optional`),vk=Symbol.for(`TypeBox.Hint`),X=Symbol.for(`TypeBox.Kind`);function yk(e){return UO(e)&&e[gk]===`Readonly`}function bk(e){return UO(e)&&e[_k]===`Optional`}function xk(e){return Z(e,`Any`)}function Sk(e){return Z(e,`Argument`)}function Ck(e){return Z(e,`Array`)}function wk(e){return Z(e,`AsyncIterator`)}function Tk(e){return Z(e,`BigInt`)}function Ek(e){return Z(e,`Boolean`)}function Dk(e){return Z(e,`Computed`)}function Ok(e){return Z(e,`Constructor`)}function kk(e){return Z(e,`Date`)}function Ak(e){return Z(e,`Function`)}function jk(e){return Z(e,`Integer`)}function Mk(e){return Z(e,`Intersect`)}function Nk(e){return Z(e,`Iterator`)}function Z(e,t){return UO(e)&&X in e&&e[X]===t}function Pk(e){return LO(e)||HO(e)||GO(e)}function Fk(e){return Z(e,`Literal`)}function Ik(e){return Z(e,`MappedKey`)}function Lk(e){return Z(e,`MappedResult`)}function Rk(e){return Z(e,`Never`)}function zk(e){return Z(e,`Not`)}function Bk(e){return Z(e,`Null`)}function Vk(e){return Z(e,`Number`)}function Hk(e){return Z(e,`Object`)}function Uk(e){return Z(e,`Promise`)}function Wk(e){return Z(e,`Record`)}function Gk(e){return Z(e,`Ref`)}function Kk(e){return Z(e,`RegExp`)}function qk(e){return Z(e,`String`)}function Jk(e){return Z(e,`Symbol`)}function Yk(e){return Z(e,`TemplateLiteral`)}function Xk(e){return Z(e,`This`)}function Zk(e){return UO(e)&&hk in e}function Qk(e){return Z(e,`Tuple`)}function $k(e){return Z(e,`Undefined`)}function eA(e){return Z(e,`Union`)}function tA(e){return Z(e,`Uint8Array`)}function nA(e){return Z(e,`Unknown`)}function rA(e){return Z(e,`Unsafe`)}function iA(e){return Z(e,`Void`)}function aA(e){return UO(e)&&X in e&&GO(e[X])}function oA(e){return xk(e)||Sk(e)||Ck(e)||Ek(e)||Tk(e)||wk(e)||Dk(e)||Ok(e)||kk(e)||Ak(e)||jk(e)||Mk(e)||Nk(e)||Fk(e)||Ik(e)||Lk(e)||Rk(e)||zk(e)||Bk(e)||Vk(e)||Hk(e)||Uk(e)||Wk(e)||Gk(e)||Kk(e)||qk(e)||Jk(e)||Yk(e)||Xk(e)||Qk(e)||$k(e)||eA(e)||tA(e)||nA(e)||rA(e)||iA(e)||aA(e)}var sA=`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 cA(e){try{return new RegExp(e),!0}catch{return!1}}function lA(e){if(!GO(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 uA(e){return pA(e)||lj(e)}function dA(e){return JO(e)||IO(e)}function fA(e){return JO(e)||HO(e)}function pA(e){return JO(e)||LO(e)}function mA(e){return JO(e)||GO(e)}function hA(e){return JO(e)||GO(e)&&lA(e)&&cA(e)}function gA(e){return JO(e)||GO(e)&&lA(e)}function _A(e){return JO(e)||lj(e)}function vA(e){return UO(e)&&e[_k]===`Optional`}function yA(e){return NA(e,`Any`)&&mA(e.$id)}function bA(e){return NA(e,`Argument`)&&HO(e.index)}function xA(e){return NA(e,`Array`)&&e.type===`array`&&mA(e.$id)&&lj(e.items)&&fA(e.minItems)&&fA(e.maxItems)&&pA(e.uniqueItems)&&_A(e.contains)&&fA(e.minContains)&&fA(e.maxContains)}function SA(e){return NA(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&mA(e.$id)&&lj(e.items)}function CA(e){return NA(e,`BigInt`)&&e.type===`bigint`&&mA(e.$id)&&dA(e.exclusiveMaximum)&&dA(e.exclusiveMinimum)&&dA(e.maximum)&&dA(e.minimum)&&dA(e.multipleOf)}function wA(e){return NA(e,`Boolean`)&&e.type===`boolean`&&mA(e.$id)}function TA(e){return NA(e,`Computed`)&&GO(e.target)&&FO(e.parameters)&&e.parameters.every(e=>lj(e))}function EA(e){return NA(e,`Constructor`)&&e.type===`Constructor`&&mA(e.$id)&&FO(e.parameters)&&e.parameters.every(e=>lj(e))&&lj(e.returns)}function DA(e){return NA(e,`Date`)&&e.type===`Date`&&mA(e.$id)&&fA(e.exclusiveMaximumTimestamp)&&fA(e.exclusiveMinimumTimestamp)&&fA(e.maximumTimestamp)&&fA(e.minimumTimestamp)&&fA(e.multipleOfTimestamp)}function OA(e){return NA(e,`Function`)&&e.type===`Function`&&mA(e.$id)&&FO(e.parameters)&&e.parameters.every(e=>lj(e))&&lj(e.returns)}function kA(e){return NA(e,`Integer`)&&e.type===`integer`&&mA(e.$id)&&fA(e.exclusiveMaximum)&&fA(e.exclusiveMinimum)&&fA(e.maximum)&&fA(e.minimum)&&fA(e.multipleOf)}function AA(e){return UO(e)&&Object.entries(e).every(([e,t])=>lA(e)&&lj(t))}function jA(e){return NA(e,`Intersect`)&&!(GO(e.type)&&e.type!==`object`)&&FO(e.allOf)&&e.allOf.every(e=>lj(e)&&!ej(e))&&mA(e.type)&&(pA(e.unevaluatedProperties)||_A(e.unevaluatedProperties))&&mA(e.$id)}function MA(e){return NA(e,`Iterator`)&&e.type===`Iterator`&&mA(e.$id)&&lj(e.items)}function NA(e,t){return UO(e)&&X in e&&e[X]===t}function PA(e){return LA(e)&&GO(e.const)}function FA(e){return LA(e)&&HO(e.const)}function IA(e){return LA(e)&&LO(e.const)}function LA(e){return NA(e,`Literal`)&&mA(e.$id)&&RA(e.const)}function RA(e){return LO(e)||HO(e)||GO(e)}function zA(e){return NA(e,`MappedKey`)&&FO(e.keys)&&e.keys.every(e=>HO(e)||GO(e))}function BA(e){return NA(e,`MappedResult`)&&AA(e.properties)}function VA(e){return NA(e,`Never`)&&UO(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function HA(e){return NA(e,`Not`)&&lj(e.not)}function UA(e){return NA(e,`Null`)&&e.type===`null`&&mA(e.$id)}function WA(e){return NA(e,`Number`)&&e.type===`number`&&mA(e.$id)&&fA(e.exclusiveMaximum)&&fA(e.exclusiveMinimum)&&fA(e.maximum)&&fA(e.minimum)&&fA(e.multipleOf)}function GA(e){return NA(e,`Object`)&&e.type===`object`&&mA(e.$id)&&AA(e.properties)&&uA(e.additionalProperties)&&fA(e.minProperties)&&fA(e.maxProperties)}function KA(e){return NA(e,`Promise`)&&e.type===`Promise`&&mA(e.$id)&&lj(e.item)}function qA(e){return NA(e,`Record`)&&e.type===`object`&&mA(e.$id)&&uA(e.additionalProperties)&&UO(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&cA(t[0])&&UO(e.patternProperties)&&lj(e.patternProperties[t[0]])})(e)}function JA(e){return NA(e,`Ref`)&&mA(e.$id)&&GO(e.$ref)}function YA(e){return NA(e,`RegExp`)&&mA(e.$id)&&GO(e.source)&&GO(e.flags)&&fA(e.maxLength)&&fA(e.minLength)}function XA(e){return NA(e,`String`)&&e.type===`string`&&mA(e.$id)&&fA(e.minLength)&&fA(e.maxLength)&&hA(e.pattern)&&gA(e.format)}function ZA(e){return NA(e,`Symbol`)&&e.type===`symbol`&&mA(e.$id)}function QA(e){return NA(e,`TemplateLiteral`)&&e.type===`string`&&GO(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function $A(e){return NA(e,`This`)&&mA(e.$id)&&GO(e.$ref)}function ej(e){return UO(e)&&hk in e}function tj(e){return NA(e,`Tuple`)&&e.type===`array`&&mA(e.$id)&&HO(e.minItems)&&HO(e.maxItems)&&e.minItems===e.maxItems&&(JO(e.items)&&JO(e.additionalItems)&&e.minItems===0||FO(e.items)&&e.items.every(e=>lj(e)))}function nj(e){return NA(e,`Undefined`)&&e.type===`undefined`&&mA(e.$id)}function rj(e){return NA(e,`Union`)&&mA(e.$id)&&UO(e)&&FO(e.anyOf)&&e.anyOf.every(e=>lj(e))}function ij(e){return NA(e,`Uint8Array`)&&e.type===`Uint8Array`&&mA(e.$id)&&fA(e.minByteLength)&&fA(e.maxByteLength)}function aj(e){return NA(e,`Unknown`)&&mA(e.$id)}function oj(e){return NA(e,`Unsafe`)}function sj(e){return NA(e,`Void`)&&e.type===`void`&&mA(e.$id)}function cj(e){return UO(e)&&X in e&&GO(e[X])&&!sA.includes(e[X])}function lj(e){return UO(e)&&(yA(e)||bA(e)||xA(e)||wA(e)||CA(e)||SA(e)||TA(e)||EA(e)||DA(e)||OA(e)||kA(e)||jA(e)||MA(e)||LA(e)||zA(e)||BA(e)||VA(e)||HA(e)||UA(e)||WA(e)||GA(e)||KA(e)||qA(e)||JA(e)||YA(e)||XA(e)||ZA(e)||QA(e)||$A(e)||tj(e)||nj(e)||rj(e)||ij(e)||aj(e)||oj(e)||sj(e)||cj(e))}var uj=`(true|false)`,dj=`(0|[1-9][0-9]*)`,fj=`(.*)`,pj=`(?!.*)`;`${uj}`;var mj=`^${dj}$`,hj=`^${fj}$`,gj=`^${pj}$`;function _j(e,t){return e.includes(t)}function vj(e){return[...new Set(e)]}function yj(e,t){return e.filter(e=>t.includes(e))}function bj(e,t){return e.reduce((e,t)=>yj(e,t),t)}function xj(e){return e.length===1?e[0]:e.length>1?bj(e.slice(1),e[0]):[]}function Sj(e){let t=[];for(let n of e)t.push(...n);return t}function Cj(e){return Y({[X]:`Any`},e)}function wj(e,t){return Y({[X]:`Array`,type:`array`,items:e},t)}function Tj(e){return Y({[X]:`Argument`,index:e})}function Ej(e,t){return Y({[X]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function Dj(e,t,n){return Y({[X]:`Computed`,target:e,parameters:t},n)}function Oj(e,t){let{[t]:n,...r}=e;return r}function kj(e,t){return t.reduce((e,t)=>Oj(e,t),e)}function Aj(e){return Y({[X]:`Never`,not:{}},e)}function jj(e){return Y({[X]:`MappedResult`,properties:e})}function Mj(e,t,n){return Y({[X]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function Nj(e,t,n){return Y({[X]:`Function`,type:`Function`,parameters:e,returns:t},n)}function Pj(e,t){return Y({[X]:`Union`,anyOf:e},t)}function Fj(e){return e.some(e=>bk(e))}function Ij(e){return e.map(e=>bk(e)?Lj(e):e)}function Lj(e){return kj(e,[_k])}function Rj(e,t){return Fj(e)?wN(Pj(Ij(e),t)):Pj(Ij(e),t)}function zj(e,t){return e.length===1?Y(e[0],t):e.length===0?Aj(t):Rj(e,t)}function Bj(e,t){return e.length===0?Aj(t):e.length===1?Y(e[0],t):Pj(e,t)}var Vj=class extends mk{};function Hj(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function Uj(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function Wj(e,t){return Uj(e,t,`(`)}function Gj(e,t){return Uj(e,t,`)`)}function Kj(e,t){return Uj(e,t,`|`)}function qj(e){if(!(Wj(e,0)&&Gj(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(Wj(e,n)&&(t+=1),Gj(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function Jj(e){return e.slice(1,e.length-1)}function Yj(e){let t=0;for(let n=0;n<e.length;n++)if(Wj(e,n)&&(t+=1),Gj(e,n)&&--t,Kj(e,n)&&t===0)return!0;return!1}function Xj(e){for(let t=0;t<e.length;t++)if(Wj(e,t))return!0;return!1}function Zj(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(Wj(e,i)&&(t+=1),Gj(e,i)&&--t,Kj(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push($j(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push($j(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function Qj(e){function t(e,t){if(!Wj(e,t))throw new Vj(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(Wj(e,r)&&(n+=1),Gj(e,r)&&--n,n===0)return[t,r];throw new Vj(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(Wj(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(Wj(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push($j(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push($j(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function $j(e){return qj(e)?$j(Jj(e)):Yj(e)?Zj(e):Xj(e)?Qj(e):{type:`const`,const:Hj(e)}}function eM(e){return $j(e.slice(1,e.length-1))}var tM=class extends mk{};function nM(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 rM(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 iM(e){return e.type===`const`&&e.const===`.*`}function aM(e){return nM(e)||iM(e)?!1:rM(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>aM(e)):e.type===`const`||(()=>{throw new tM(`Unknown expression type`)})()}function oM(e){return aM(eM(e.pattern))}var sM=class extends mk{};function*cM(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of cM(e.slice(1)))yield`${t}${n}`}function*lM(e){return yield*cM(e.expr.map(e=>[...fM(e)]))}function*uM(e){for(let t of e.expr)yield*fM(t)}function*dM(e){return yield e.const}function*fM(e){return e.type===`and`?yield*lM(e):e.type===`or`?yield*uM(e):e.type===`const`?yield*dM(e):(()=>{throw new sM(`Unknown expression`)})()}function pM(e){let t=eM(e.pattern);return aM(t)?[...fM(t)]:[]}function mM(e,t){return Y({[X]:`Literal`,const:e,type:typeof e},t)}function hM(e){return Y({[X]:`Boolean`,type:`boolean`},e)}function gM(e){return Y({[X]:`BigInt`,type:`bigint`},e)}function _M(e){return Y({[X]:`Number`,type:`number`},e)}function vM(e){return Y({[X]:`String`,type:`string`},e)}function*yM(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield hM():t===`number`?yield _M():t===`bigint`?yield gM():t===`string`?yield vM():yield(()=>{let e=t.split(`|`).map(e=>mM(e.trim()));return e.length===0?Aj():e.length===1?e[0]:zj(e)})()}function*bM(e){if(e[1]!==`{`)return yield*[mM(`$`),...xM(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=yM(e.slice(2,t)),r=xM(e.slice(t+1));return yield*[...n,...r]}yield mM(e)}function*xM(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[mM(e.slice(0,t)),...bM(e.slice(t))];yield mM(e)}function SM(e){return[...xM(e)]}var CM=class extends mk{};function wM(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function TM(e,t){return Yk(e)?e.pattern.slice(1,e.pattern.length-1):eA(e)?`(${e.anyOf.map(e=>TM(e,t)).join(`|`)})`:Vk(e)||jk(e)||Tk(e)?`${t}${dj}`:qk(e)?`${t}${fj}`:Fk(e)?`${t}${wM(e.const.toString())}`:Ek(e)?`${t}${uj}`:(()=>{throw new CM(`Unexpected Kind '${e[X]}'`)})()}function EM(e){return`^${e.map(e=>TM(e,``)).join(``)}$`}function DM(e){return zj(pM(e).map(e=>mM(e)))}function OM(e,t){let n=GO(e)?EM(SM(e)):EM(e);return Y({[X]:`TemplateLiteral`,type:`string`,pattern:n},t)}function kM(e){return pM(e).map(e=>e.toString())}function AM(e){let t=[];for(let n of e)t.push(...MM(n));return t}function jM(e){return[e.toString()]}function MM(e){return[...new Set(Yk(e)?kM(e):eA(e)?AM(e.anyOf):Fk(e)?jM(e.const):Vk(e)||jk(e)?[`[number]`]:[])]}function NM(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=qM(e,MM(t[i]),n);return r}function PM(e,t,n){return NM(e,t.properties,n)}function FM(e,t,n){return jj(PM(e,t,n))}function IM(e,t){return e.map(e=>WM(e,t))}function LM(e){return e.filter(e=>!Rk(e))}function RM(e,t){return NN(LM(IM(e,t)))}function zM(e){return e.some(e=>Rk(e))?[]:e}function BM(e,t){return zj(zM(IM(e,t)))}function VM(e,t){return t in e?e[t]:t===`[number]`?zj(e):Aj()}function HM(e,t){return t===`[number]`?e:Aj()}function UM(e,t){return t in e?e[t]:Aj()}function WM(e,t){return Mk(e)?RM(e.allOf,t):eA(e)?BM(e.anyOf,t):Qk(e)?VM(e.items??[],t):Ck(e)?HM(e.items,t):Hk(e)?UM(e.properties,t):Aj()}function GM(e,t){return t.map(t=>WM(e,t))}function KM(e,t){return zj(GM(e,t))}function qM(e,t,n){if(Gk(e)||Gk(t)){if(!oA(e)||!oA(t))throw new mk(`Index types using Ref parameters require both Type and Key to be of TSchema`);return Dj(`Index`,[e,t])}return Lk(t)?FM(e,t,n):Ik(t)?ZM(e,t,n):Y(oA(t)?KM(e,MM(t)):KM(e,t),n)}function JM(e,t,n){return{[t]:qM(e,[t],tk(n))}}function YM(e,t,n){return t.reduce((t,r)=>({...t,...JM(e,r,n)}),{})}function XM(e,t,n){return YM(e,t.keys,n)}function ZM(e,t,n){return jj(XM(e,t,n))}function QM(e,t){return Y({[X]:`Iterator`,type:`Iterator`,items:e},t)}function $M(e){return globalThis.Object.keys(e).filter(t=>!bk(e[t]))}function eN(e,t){let n=$M(e);return Y(n.length>0?{[X]:`Object`,type:`object`,required:n,properties:e}:{[X]:`Object`,type:`object`,properties:e},t)}var tN=eN;function nN(e,t){return Y({[X]:`Promise`,type:`Promise`,item:e},t)}function rN(e){return Y(kj(e,[gk]))}function iN(e){return Y({...e,[gk]:`Readonly`})}function aN(e,t){return t===!1?rN(e):iN(e)}function oN(e,t){let n=t??!0;return Lk(e)?lN(e,n):aN(e,n)}function sN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=oN(e[r],t);return n}function cN(e,t){return sN(e.properties,t)}function lN(e,t){return jj(cN(e,t))}function uN(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 dN(e,t){return e in t?vN(e,t[e]):jj(t)}function fN(e){return{[e]:mM(e)}}function pN(e){let t={};for(let n of e)t[n]=mM(n);return t}function mN(e,t){return _j(t,e)?fN(e):pN(t)}function hN(e,t){return dN(e,mN(e,t))}function gN(e,t){return t.map(t=>vN(e,t))}function _N(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=vN(e,t[r]);return n}function vN(e,t){let n={...t};return bk(t)?wN(vN(e,kj(t,[_k]))):yk(t)?oN(vN(e,kj(t,[gk]))):Lk(t)?dN(e,t.properties):Ik(t)?hN(e,t.keys):Ok(t)?Mj(gN(e,t.parameters),vN(e,t.returns),n):Ak(t)?Nj(gN(e,t.parameters),vN(e,t.returns),n):wk(t)?Ej(vN(e,t.items),n):Nk(t)?QM(vN(e,t.items),n):Mk(t)?PN(gN(e,t.allOf),n):eA(t)?Bj(gN(e,t.anyOf),n):Qk(t)?uN(gN(e,t.items??[]),n):Hk(t)?tN(_N(e,t.properties),n):Ck(t)?wj(vN(e,t.items),n):Uk(t)?nN(vN(e,t.item),n):t}function yN(e,t){let n={};for(let r of e)n[r]=vN(r,t);return n}function bN(e,t,n){let r=oA(e)?MM(e):e;return tN(yN(r,t({[X]:`MappedKey`,keys:r})),n)}function xN(e){return Y(kj(e,[_k]))}function SN(e){return Y({...e,[_k]:`Optional`})}function CN(e,t){return t===!1?xN(e):SN(e)}function wN(e,t){let n=t??!0;return Lk(e)?DN(e,n):CN(e,n)}function TN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=wN(e[r],t);return n}function EN(e,t){return TN(e.properties,t)}function DN(e,t){return jj(EN(e,t))}function ON(e,t={}){let n=e.every(e=>Hk(e)),r=oA(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return Y(t.unevaluatedProperties===!1||oA(t.unevaluatedProperties)||n?{...r,[X]:`Intersect`,type:`object`,allOf:e}:{...r,[X]:`Intersect`,allOf:e},t)}function kN(e){return e.every(e=>bk(e))}function AN(e){return kj(e,[_k])}function jN(e){return e.map(e=>bk(e)?AN(e):e)}function MN(e,t){return kN(e)?wN(ON(jN(e),t)):ON(jN(e),t)}function NN(e,t={}){if(e.length===1)return Y(e[0],t);if(e.length===0)return Aj(t);if(e.some(e=>Zk(e)))throw Error(`Cannot intersect transform types`);return MN(e,t)}function PN(e,t){if(e.length===1)return Y(e[0],t);if(e.length===0)return Aj(t);if(e.some(e=>Zk(e)))throw Error(`Cannot intersect transform types`);return ON(e,t)}function FN(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new mk(`Ref: $ref must be a string`);return Y({[X]:`Ref`,$ref:t},n)}function IN(e,t){return Dj(`Awaited`,[Dj(e,t)])}function LN(e){return Dj(`Awaited`,[FN(e)])}function RN(e){return PN(VN(e))}function zN(e){return Bj(VN(e))}function BN(e){return HN(e)}function VN(e){return e.map(e=>HN(e))}function HN(e,t){return Y(Dk(e)?IN(e.target,e.parameters):Mk(e)?RN(e.allOf):eA(e)?zN(e.anyOf):Uk(e)?BN(e.item):Gk(e)?LN(e.$ref):e,t)}function UN(e){let t=[];for(let n of e)t.push(XN(n));return t}function WN(e){return Sj(UN(e))}function GN(e){return xj(UN(e))}function KN(e){return e.map((e,t)=>t.toString())}function qN(e){return[`[number]`]}function JN(e){return globalThis.Object.getOwnPropertyNames(e)}function YN(e){return ZN?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function XN(e){return Mk(e)?WN(e.allOf):eA(e)?GN(e.anyOf):Qk(e)?KN(e.items??[]):Ck(e)?qN(e.items):Hk(e)?JN(e.properties):Wk(e)?YN(e.patternProperties):[]}var ZN=!1;function QN(e,t){return Dj(`KeyOf`,[Dj(e,t)])}function $N(e){return Dj(`KeyOf`,[FN(e)])}function eP(e,t){return Y(zj(tP(XN(e))),t)}function tP(e){return e.map(e=>e===`[number]`?_M():mM(e))}function nP(e,t){return Dk(e)?QN(e.target,e.parameters):Gk(e)?$N(e.$ref):Lk(e)?aP(e,t):eP(e,t)}function rP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=nP(e[r],tk(t));return n}function iP(e,t){return rP(e.properties,t)}function aP(e,t){return jj(iP(e,t))}function oP(e){let t=[];for(let n of e)t.push(...XN(n));return vj(t)}function sP(e){return e.filter(e=>!Rk(e))}function cP(e,t){let n=[];for(let r of e)n.push(...GM(r,[t]));return sP(n)}function lP(e,t){let n={};for(let r of t)n[r]=NN(cP(e,r));return n}function uP(e,t){return tN(lP(e,oP(e)),t)}function dP(e){return Y({[X]:`Date`,type:`Date`},e)}function fP(e){return Y({[X]:`Null`,type:`null`},e)}function pP(e){return Y({[X]:`Symbol`,type:`symbol`},e)}function mP(e){return Y({[X]:`Undefined`,type:`undefined`},e)}function hP(e){return Y({[X]:`Uint8Array`,type:`Uint8Array`},e)}function gP(e){return Y({[X]:`Unknown`},e)}function _P(e){return e.map(e=>bP(e,!1))}function vP(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=oN(bP(e[n],!1));return t}function yP(e,t){return t===!0?e:oN(e)}function bP(e,t){return PO(e)||BO(e)?yP(Cj(),t):FO(e)?oN(uN(_P(e))):qO(e)?hP():RO(e)?dP():UO(e)?yP(tN(vP(e)),t):zO(e)?yP(Nj([],gP()),t):JO(e)?mP():VO(e)?fP():KO(e)?pP():IO(e)?gM():HO(e)||LO(e)||GO(e)?mM(e):tN({})}function xP(e,t){return Y(bP(e,!0),t)}function SP(e,t){return Ok(e)?uN(e.parameters,t):Aj(t)}function CP(e,t){if(JO(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return Bj([...new Set(n)].map(e=>mM(e)),{...t,[vk]:`Enum`})}var wP=class extends mk{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function TP(e){return e===Q.False?e:Q.True}function EP(e){throw new wP(e)}function DP(e){return VA(e)||jA(e)||rj(e)||aj(e)||yA(e)}function OP(e,t){return VA(t)?KP(e,t):jA(t)?HP(e,t):rj(t)?kF(e,t):aj(t)?jF(e,t):yA(t)?kP(e,t):EP(`StructuralRight`)}function kP(e,t){return Q.True}function AP(e,t){return jA(t)?HP(e,t):rj(t)&&t.anyOf.some(e=>yA(e)||aj(e))?Q.True:rj(t)?Q.Union:aj(t)||yA(t)?Q.True:Q.Union}function jP(e,t){return aj(e)?Q.False:yA(e)?Q.Union:VA(e)?Q.True:Q.False}function MP(e,t){return GA(t)&&lF(t)?Q.True:DP(t)?OP(e,t):xA(t)?TP(FF(e.items,t.items)):Q.False}function NP(e,t){return DP(t)?OP(e,t):SA(t)?TP(FF(e.items,t.items)):Q.False}function PP(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):CA(t)?Q.True:Q.False}function FP(e,t){return IA(e)||wA(e)?Q.True:Q.False}function IP(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):wA(t)?Q.True:Q.False}function LP(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):EA(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>TP(FF(t.parameters[n],e))===Q.True)?TP(FF(e.returns,t.returns)):Q.False:Q.False}function RP(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):DA(t)?Q.True:Q.False}function zP(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):OA(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>TP(FF(t.parameters[n],e))===Q.True)?TP(FF(e.returns,t.returns)):Q.False:Q.False}function BP(e,t){return LA(e)&&HO(e.const)||WA(e)||kA(e)?Q.True:Q.False}function VP(e,t){return kA(t)||WA(t)?Q.True:DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):Q.False}function HP(e,t){return t.allOf.every(t=>FF(e,t)===Q.True)?Q.True:Q.False}function UP(e,t){return e.allOf.some(e=>FF(e,t)===Q.True)?Q.True:Q.False}function WP(e,t){return DP(t)?OP(e,t):MA(t)?TP(FF(e.items,t.items)):Q.False}function GP(e,t){return LA(t)&&t.const===e.const?Q.True:DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):XA(t)?bF(e,t):WA(t)?ZP(e,t):kA(t)?BP(e,t):wA(t)?FP(e,t):Q.False}function KP(e,t){return Q.False}function qP(e,t){return Q.True}function JP(e){let[t,n]=[e,0];for(;HA(t);)t=t.not,n+=1;return n%2==0?t:gP()}function YP(e,t){return HA(e)?FF(JP(e),t):HA(t)?FF(e,JP(t)):EP(`Invalid fallthrough for Not`)}function XP(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):UA(t)?Q.True:Q.False}function ZP(e,t){return FA(e)||WA(e)||kA(e)?Q.True:Q.False}function QP(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):kA(t)||WA(t)?Q.True:Q.False}function $P(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function eF(e){return lF(e)}function tF(e){return $P(e,0)||$P(e,1)&&`description`in e.properties&&rj(e.properties.description)&&e.properties.description.anyOf.length===2&&(XA(e.properties.description.anyOf[0])&&nj(e.properties.description.anyOf[1])||XA(e.properties.description.anyOf[1])&&nj(e.properties.description.anyOf[0]))}function nF(e){return $P(e,0)}function rF(e){return $P(e,0)}function iF(e){return $P(e,0)}function aF(e){return $P(e,0)}function oF(e){return lF(e)}function sF(e){let t=_M();return $P(e,0)||$P(e,1)&&`length`in e.properties&&TP(FF(e.properties.length,t))===Q.True}function cF(e){return $P(e,0)}function lF(e){let t=_M();return $P(e,0)||$P(e,1)&&`length`in e.properties&&TP(FF(e.properties.length,t))===Q.True}function uF(e){let t=Nj([Cj()],Cj());return $P(e,0)||$P(e,1)&&`then`in e.properties&&TP(FF(e.properties.then,t))===Q.True}function dF(e,t){return FF(e,t)===Q.False||vA(e)&&!vA(t)?Q.False:Q.True}function fF(e,t){return aj(e)?Q.False:yA(e)?Q.Union:VA(e)||PA(e)&&eF(t)||FA(e)&&nF(t)||IA(e)&&rF(t)||ZA(e)&&tF(t)||CA(e)&&iF(t)||XA(e)&&eF(t)||ZA(e)&&tF(t)||WA(e)&&nF(t)||kA(e)&&nF(t)||wA(e)&&rF(t)||ij(e)&&oF(t)||DA(e)&&aF(t)||EA(e)&&cF(t)||OA(e)&&sF(t)?Q.True:qA(e)&&XA(hF(e))?t[vk]===`Record`?Q.True:Q.False:qA(e)&&WA(hF(e))&&$P(t,0)?Q.True:Q.False}function pF(e,t){return DP(t)?OP(e,t):qA(t)?_F(e,t):GA(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!vA(t.properties[n]))return Q.False;if(vA(t.properties[n]))return Q.True;if(dF(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function mF(e,t){return DP(t)?OP(e,t):GA(t)&&uF(t)?Q.True:KA(t)?TP(FF(e.item,t.item)):Q.False}function hF(e){return mj in e.patternProperties?_M():hj in e.patternProperties?vM():EP(`Unknown record key pattern`)}function gF(e){return mj in e.patternProperties?e.patternProperties[mj]:hj in e.patternProperties?e.patternProperties[hj]:EP(`Unable to get record value schema`)}function _F(e,t){let[n,r]=[hF(t),gF(t)];return PA(e)&&WA(n)&&TP(FF(e,r))===Q.True?Q.True:ij(e)&&WA(n)||XA(e)&&WA(n)||xA(e)&&WA(n)?FF(e,r):GA(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(dF(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function vF(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?FF(gF(e),gF(t)):Q.False}function yF(e,t){return FF(YA(e)?vM():e,YA(t)?vM():t)}function bF(e,t){return LA(e)&&GO(e.const)||XA(e)?Q.True:Q.False}function xF(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):XA(t)?Q.True:Q.False}function SF(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):ZA(t)?Q.True:Q.False}function CF(e,t){return QA(e)?FF(DM(e),t):QA(t)?FF(e,DM(t)):EP(`Invalid fallthrough for TemplateLiteral`)}function wF(e,t){return xA(t)&&e.items!==void 0&&e.items.every(e=>FF(e,t.items)===Q.True)}function TF(e,t){return VA(e)?Q.True:aj(e)?Q.False:yA(e)?Q.Union:Q.False}function EF(e,t){return DP(t)?OP(e,t):GA(t)&&lF(t)||xA(t)&&wF(e,t)?Q.True:tj(t)?JO(e.items)&&!JO(t.items)||!JO(e.items)&&JO(t.items)?Q.False:JO(e.items)&&!JO(t.items)||e.items.every((e,n)=>FF(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function DF(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):ij(t)?Q.True:Q.False}function OF(e,t){return DP(t)?OP(e,t):GA(t)?fF(e,t):qA(t)?_F(e,t):sj(t)?NF(e,t):nj(t)?Q.True:Q.False}function kF(e,t){return t.anyOf.some(t=>FF(e,t)===Q.True)?Q.True:Q.False}function AF(e,t){return e.anyOf.every(e=>FF(e,t)===Q.True)?Q.True:Q.False}function jF(e,t){return Q.True}function MF(e,t){return VA(t)?KP(e,t):jA(t)?HP(e,t):rj(t)?kF(e,t):yA(t)?kP(e,t):XA(t)?bF(e,t):WA(t)?ZP(e,t):kA(t)?BP(e,t):wA(t)?FP(e,t):xA(t)?jP(e,t):tj(t)?TF(e,t):GA(t)?fF(e,t):aj(t)?Q.True:Q.False}function NF(e,t){return nj(e)||nj(e)?Q.True:Q.False}function PF(e,t){return jA(t)?HP(e,t):rj(t)?kF(e,t):aj(t)?jF(e,t):yA(t)?kP(e,t):GA(t)?fF(e,t):sj(t)?Q.True:Q.False}function FF(e,t){return QA(e)||QA(t)?CF(e,t):YA(e)||YA(t)?yF(e,t):HA(e)||HA(t)?YP(e,t):yA(e)?AP(e,t):xA(e)?MP(e,t):CA(e)?PP(e,t):wA(e)?IP(e,t):SA(e)?NP(e,t):EA(e)?LP(e,t):DA(e)?RP(e,t):OA(e)?zP(e,t):kA(e)?VP(e,t):jA(e)?UP(e,t):MA(e)?WP(e,t):LA(e)?GP(e,t):VA(e)?qP(e,t):UA(e)?XP(e,t):WA(e)?QP(e,t):GA(e)?pF(e,t):qA(e)?vF(e,t):XA(e)?xF(e,t):ZA(e)?SF(e,t):tj(e)?EF(e,t):KA(e)?mF(e,t):ij(e)?DF(e,t):nj(e)?OF(e,t):rj(e)?AF(e,t):aj(e)?MF(e,t):sj(e)?PF(e,t):EP(`Unknown left type operand '${e[X]}'`)}function IF(e,t){return FF(e,t)}function LF(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=VF(e[o],t,n,r,tk(i));return a}function RF(e,t,n,r,i){return LF(e.properties,t,n,r,i)}function zF(e,t,n,r,i){return jj(RF(e,t,n,r,i))}function BF(e,t,n,r){let i=IF(e,t);return i===Q.Union?Bj([n,r]):i===Q.True?n:r}function VF(e,t,n,r,i){return Lk(e)?zF(e,t,n,r,i):Ik(e)?Y(GF(e,t,n,r,i)):Y(BF(e,t,n,r),i)}function HF(e,t,n,r,i){return{[e]:VF(mM(e),t,n,r,tk(i))}}function UF(e,t,n,r,i){return e.reduce((e,a)=>({...e,...HF(a,t,n,r,i)}),{})}function WF(e,t,n,r,i){return UF(e.keys,t,n,r,i)}function GF(e,t,n,r,i){return jj(WF(e,t,n,r,i))}function KF(e,t){return JF(DM(e),t)}function qF(e,t){let n=e.filter(e=>IF(e,t)===Q.False);return n.length===1?n[0]:Bj(n)}function JF(e,t,n={}){return Yk(e)?Y(KF(e,t),n):Lk(e)?Y(ZF(e,t),n):Y(eA(e)?qF(e.anyOf,t):IF(e,t)===Q.False?e:Aj(),n)}function YF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=JF(e[r],t);return n}function XF(e,t){return YF(e.properties,t)}function ZF(e,t){return jj(XF(e,t))}function QF(e,t){return eI(DM(e),t)}function $F(e,t){let n=e.filter(e=>IF(e,t)!==Q.False);return n.length===1?n[0]:Bj(n)}function eI(e,t,n){return Yk(e)?Y(QF(e,t),n):Lk(e)?Y(rI(e,t),n):Y(eA(e)?$F(e.anyOf,t):IF(e,t)===Q.False?Aj():e,n)}function tI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=eI(e[r],t);return n}function nI(e,t){return tI(e.properties,t)}function rI(e,t){return jj(nI(e,t))}function iI(e,t){return Ok(e)?Y(e.returns,t):Aj(t)}function aI(e){return oN(wN(e))}function oI(e,t,n){return Y({[X]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function sI(e,t,n){let r={};for(let n of e)r[n]=t;return tN(r,{...n,[vk]:`Record`})}function cI(e,t,n){return oM(e)?sI(MM(e),t,n):oI(e.pattern,t,n)}function lI(e,t,n){return sI(MM(Bj(e)),t,n)}function uI(e,t,n){return sI([e.toString()],t,n)}function dI(e,t,n){return oI(e.source,t,n)}function fI(e,t,n){return oI(JO(e.pattern)?hj:e.pattern,t,n)}function pI(e,t,n){return oI(hj,t,n)}function mI(e,t,n){return oI(gj,t,n)}function hI(e,t,n){return tN({true:t,false:t},n)}function gI(e,t,n){return oI(mj,t,n)}function _I(e,t,n){return oI(mj,t,n)}function vI(e,t,n={}){return eA(e)?lI(e.anyOf,t,n):Yk(e)?cI(e,t,n):Fk(e)?uI(e.const,t,n):Ek(e)?hI(e,t,n):jk(e)?gI(e,t,n):Vk(e)?_I(e,t,n):Kk(e)?dI(e,t,n):qk(e)?fI(e,t,n):xk(e)?pI(e,t,n):Rk(e)?mI(e,t,n):Aj(n)}function yI(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function bI(e){let t=yI(e);return t===hj?vM():t===mj?_M():vM({pattern:t})}function xI(e){return e.patternProperties[yI(e)]}function SI(e,t){return t.parameters=II(e,t.parameters),t.returns=LI(e,t.returns),t}function CI(e,t){return t.parameters=II(e,t.parameters),t.returns=LI(e,t.returns),t}function wI(e,t){return t.allOf=II(e,t.allOf),t}function TI(e,t){return t.anyOf=II(e,t.anyOf),t}function EI(e,t){return JO(t.items)||(t.items=II(e,t.items)),t}function DI(e,t){return t.items=LI(e,t.items),t}function OI(e,t){return t.items=LI(e,t.items),t}function kI(e,t){return t.items=LI(e,t.items),t}function AI(e,t){return t.item=LI(e,t.item),t}function jI(e,t){let n=FI(e,t.properties);return{...t,...tN(n)}}function MI(e,t){let n=vI(LI(e,bI(t)),LI(e,xI(t)));return{...t,...n}}function NI(e,t){return t.index in e?e[t.index]:gP()}function PI(e,t){let n=yk(t),r=bk(t),i=LI(e,t);return n&&r?aI(i):n&&!r?oN(i):!n&&r?wN(i):i}function FI(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:PI(e,t[r])}),{})}function II(e,t){return t.map(t=>LI(e,t))}function LI(e,t){return Ok(t)?SI(e,t):Ak(t)?CI(e,t):Mk(t)?wI(e,t):eA(t)?TI(e,t):Qk(t)?EI(e,t):Ck(t)?DI(e,t):wk(t)?OI(e,t):Nk(t)?kI(e,t):Uk(t)?AI(e,t):Hk(t)?jI(e,t):Wk(t)?MI(e,t):Sk(t)?NI(e,t):t}function RI(e,t){return LI(t,nk(e))}function zI(e){return Y({[X]:`Integer`,type:`integer`},e)}function BI(e,t,n){return{[e]:ZI(mM(e),t,tk(n))}}function VI(e,t,n){return e.reduce((e,r)=>({...e,...BI(r,t,n)}),{})}function HI(e,t,n){return VI(e.keys,t,n)}function UI(e,t,n){return jj(HI(e,t,n))}function WI(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function GI(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function KI(e){return e.toUpperCase()}function qI(e){return e.toLowerCase()}function JI(e,t,n){let r=eM(e.pattern);return aM(r)?OM([Bj(XI([...fM(r)].map(e=>mM(e)),t))],n):{...e,pattern:YI(e.pattern,t)}}function YI(e,t){return typeof e==`string`?t===`Uncapitalize`?WI(e):t===`Capitalize`?GI(e):t===`Uppercase`?KI(e):t===`Lowercase`?qI(e):e:e.toString()}function XI(e,t){return e.map(e=>ZI(e,t))}function ZI(e,t,n={}){return Ik(e)?UI(e,t,n):Yk(e)?JI(e,t,n):eA(e)?Bj(XI(e.anyOf,t),n):Fk(e)?mM(YI(e.const,t),n):Y(e,n)}function QI(e,t={}){return ZI(e,`Capitalize`,t)}function $I(e,t={}){return ZI(e,`Lowercase`,t)}function eL(e,t={}){return ZI(e,`Uncapitalize`,t)}function tL(e,t={}){return ZI(e,`Uppercase`,t)}function nL(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=fL(e[i],t,tk(n));return r}function rL(e,t,n){return nL(e.properties,t,n)}function iL(e,t,n){return jj(rL(e,t,n))}function aL(e,t){return e.map(e=>dL(e,t))}function oL(e,t){return e.map(e=>dL(e,t))}function sL(e,t){let{[t]:n,...r}=e;return r}function cL(e,t){return t.reduce((e,t)=>sL(e,t),e)}function lL(e,t,n){let r=kj(e,[hk,`$id`,`required`,`properties`]);return tN(cL(n,t),r)}function uL(e){return Bj(e.reduce((e,t)=>Pk(t)?[...e,mM(t)]:e,[]))}function dL(e,t){return Mk(e)?PN(aL(e.allOf,t)):eA(e)?Bj(oL(e.anyOf,t)):Hk(e)?lL(e,t,e.properties):tN({})}function fL(e,t,n){let r=FO(t)?uL(t):t,i=oA(t)?MM(t):t,a=Gk(e),o=Gk(t);return Lk(e)?iL(e,i,n):Ik(t)?gL(e,t,n):a&&o||!a&&o||a&&!o?Dj(`Omit`,[e,r],n):Y({...dL(e,i),...n})}function pL(e,t,n){return{[t]:fL(e,[t],tk(n))}}function mL(e,t,n){return t.reduce((t,r)=>({...t,...pL(e,r,n)}),{})}function hL(e,t,n){return mL(e,t.keys,n)}function gL(e,t,n){return jj(hL(e,t,n))}function _L(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=EL(e[i],t,tk(n));return r}function vL(e,t,n){return _L(e.properties,t,n)}function yL(e,t,n){return jj(vL(e,t,n))}function bL(e,t){return e.map(e=>TL(e,t))}function xL(e,t){return e.map(e=>TL(e,t))}function SL(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function CL(e,t,n){let r=kj(e,[hk,`$id`,`required`,`properties`]);return tN(SL(n,t),r)}function wL(e){return Bj(e.reduce((e,t)=>Pk(t)?[...e,mM(t)]:e,[]))}function TL(e,t){return Mk(e)?PN(bL(e.allOf,t)):eA(e)?Bj(xL(e.anyOf,t)):Hk(e)?CL(e,t,e.properties):tN({})}function EL(e,t,n){let r=FO(t)?wL(t):t,i=oA(t)?MM(t):t,a=Gk(e),o=Gk(t);return Lk(e)?yL(e,i,n):Ik(t)?AL(e,t,n):a&&o||!a&&o||a&&!o?Dj(`Pick`,[e,r],n):Y({...TL(e,i),...n})}function DL(e,t,n){return{[t]:EL(e,[t],tk(n))}}function OL(e,t,n){return t.reduce((t,r)=>({...t,...DL(e,r,n)}),{})}function kL(e,t,n){return OL(e,t.keys,n)}function AL(e,t,n){return jj(kL(e,t,n))}function jL(e,t){return Dj(`Partial`,[Dj(e,t)])}function ML(e){return Dj(`Partial`,[FN(e)])}function NL(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=wN(e[n]);return t}function PL(e,t){let n=kj(e,[hk,`$id`,`required`,`properties`]);return tN(NL(t),n)}function FL(e){return e.map(e=>IL(e))}function IL(e){return Dk(e)?jL(e.target,e.parameters):Gk(e)?ML(e.$ref):Mk(e)?PN(FL(e.allOf)):eA(e)?Bj(FL(e.anyOf)):Hk(e)?PL(e,e.properties):Tk(e)||Ek(e)||jk(e)||Fk(e)||Bk(e)||Vk(e)||qk(e)||Jk(e)||$k(e)?e:tN({})}function LL(e,t){return Lk(e)?BL(e,t):Y({...IL(e),...t})}function RL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=LL(e[r],tk(t));return n}function zL(e,t){return RL(e.properties,t)}function BL(e,t){return jj(zL(e,t))}function VL(e,t){return Dj(`Required`,[Dj(e,t)])}function HL(e){return Dj(`Required`,[FN(e)])}function UL(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=kj(e[n],[_k]);return t}function WL(e,t){let n=kj(e,[hk,`$id`,`required`,`properties`]);return tN(UL(t),n)}function GL(e){return e.map(e=>KL(e))}function KL(e){return Dk(e)?VL(e.target,e.parameters):Gk(e)?HL(e.$ref):Mk(e)?PN(GL(e.allOf)):eA(e)?Bj(GL(e.anyOf)):Hk(e)?WL(e,e.properties):Tk(e)||Ek(e)||jk(e)||Fk(e)||Bk(e)||Vk(e)||qk(e)||Jk(e)||$k(e)?e:tN({})}function qL(e,t){return Lk(e)?XL(e,t):Y({...KL(e),...t})}function JL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=qL(e[r],t);return n}function YL(e,t){return JL(e.properties,t)}function XL(e,t){return jj(YL(e,t))}function ZL(e,t){return t.map(t=>Gk(t)?QL(e,t.$ref):yR(e,t))}function QL(e,t){return t in e?Gk(e[t])?QL(e,e[t].$ref):yR(e,e[t]):Aj()}function $L(e){return HN(e[0])}function eR(e){return qM(e[0],e[1])}function tR(e){return nP(e[0])}function nR(e){return LL(e[0])}function rR(e){return fL(e[0],e[1])}function iR(e){return EL(e[0],e[1])}function aR(e){return qL(e[0])}function oR(e,t,n){let r=ZL(e,n);return t===`Awaited`?$L(r):t===`Index`?eR(r):t===`KeyOf`?tR(r):t===`Partial`?nR(r):t===`Omit`?rR(r):t===`Pick`?iR(r):t===`Required`?aR(r):Aj()}function sR(e,t){return wj(yR(e,t))}function cR(e,t){return Ej(yR(e,t))}function lR(e,t,n){return Mj(vR(e,t),yR(e,n))}function uR(e,t,n){return Nj(vR(e,t),yR(e,n))}function dR(e,t){return PN(vR(e,t))}function fR(e,t){return QM(yR(e,t))}function pR(e,t){return tN(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:yR(e,t[r])}),{}))}function mR(e,t){let[n,r]=[yR(e,xI(t)),yI(t)],i=nk(t);return i.patternProperties[r]=n,i}function hR(e,t){return Gk(t)?{...QL(e,t.$ref),[hk]:t[hk]}:t}function gR(e,t){return uN(vR(e,t))}function _R(e,t){return Bj(vR(e,t))}function vR(e,t){return t.map(t=>yR(e,t))}function yR(e,t){return bk(t)?Y(yR(e,kj(t,[_k])),t):yk(t)?Y(yR(e,kj(t,[gk])),t):Zk(t)?Y(hR(e,t),t):Ck(t)?Y(sR(e,t.items),t):wk(t)?Y(cR(e,t.items),t):Dk(t)?Y(oR(e,t.target,t.parameters)):Ok(t)?Y(lR(e,t.parameters,t.returns),t):Ak(t)?Y(uR(e,t.parameters,t.returns),t):Mk(t)?Y(dR(e,t.allOf),t):Nk(t)?Y(fR(e,t.items),t):Hk(t)?Y(pR(e,t.properties),t):Wk(t)?Y(mR(e,t)):Qk(t)?Y(gR(e,t.items||[]),t):eA(t)?Y(_R(e,t.anyOf),t):t}function bR(e,t){return t in e?yR(e,e[t]):Aj()}function xR(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:bR(e,n)}),{})}var SR=class{constructor(e){let t=xR(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 CR(e){return new SR(e)}function wR(e,t){return Y({[X]:`Not`,not:e},t)}function TR(e,t){return Ak(e)?uN(e.parameters,t):Aj()}var ER=0;function DR(e,t={}){JO(t.$id)&&(t.$id=`T${ER++}`);let n=nk(e({[X]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,Y({[vk]:`Recursive`,...n},t)}function OR(e,t){let n=GO(e)?new globalThis.RegExp(e):e;return Y({[X]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function kR(e){return Mk(e)?e.allOf:eA(e)?e.anyOf:Qk(e)?e.items??[]:[]}function AR(e){return kR(e)}function jR(e,t){return Ak(e)?Y(e.returns,t):Aj(t)}var MR=class{constructor(e){this.schema=e}Decode(e){return new NR(this.schema,e)}},NR=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[hk].Encode(e(n)),Decode:e=>this.decode(t[hk].Decode(e))};return{...t,[hk]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[hk]:n}}Encode(e){return Zk(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function PR(e){return new MR(e)}function FR(e={}){return Y({[X]:e[X]??`Unsafe`},e)}function IR(e){return Y({[X]:`Void`,type:`void`},e)}var $=t({Any:()=>Cj,Argument:()=>Tj,Array:()=>wj,AsyncIterator:()=>Ej,Awaited:()=>HN,BigInt:()=>gM,Boolean:()=>hM,Capitalize:()=>QI,Composite:()=>uP,Const:()=>xP,Constructor:()=>Mj,ConstructorParameters:()=>SP,Date:()=>dP,Enum:()=>CP,Exclude:()=>JF,Extends:()=>VF,Extract:()=>eI,Function:()=>Nj,Index:()=>qM,InstanceType:()=>iI,Instantiate:()=>RI,Integer:()=>zI,Intersect:()=>PN,Iterator:()=>QM,KeyOf:()=>nP,Literal:()=>mM,Lowercase:()=>$I,Mapped:()=>bN,Module:()=>CR,Never:()=>Aj,Not:()=>wR,Null:()=>fP,Number:()=>_M,Object:()=>tN,Omit:()=>fL,Optional:()=>wN,Parameters:()=>TR,Partial:()=>LL,Pick:()=>EL,Promise:()=>nN,Readonly:()=>oN,ReadonlyOptional:()=>aI,Record:()=>vI,Recursive:()=>DR,Ref:()=>FN,RegExp:()=>OR,Required:()=>qL,Rest:()=>AR,ReturnType:()=>jR,String:()=>vM,Symbol:()=>pP,TemplateLiteral:()=>OM,Transform:()=>PR,Tuple:()=>uN,Uint8Array:()=>hP,Uncapitalize:()=>eL,Undefined:()=>mP,Union:()=>Bj,Unknown:()=>gP,Unsafe:()=>FR,Uppercase:()=>tL,Void:()=>IR}),LR={additionalProperties:!1},RR=$.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}),zR=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),BR=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),VR=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),HR=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),UR=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,WR=`^(?:${UR}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,GR=$.String({pattern:WR,minLength:8,maxLength:36}),KR=new RegExp(WR),qR=/^[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 JR(e){return typeof e!=`string`||e.length>36?!1:KR.test(e)}function YR(e){if(typeof e!=`string`)return;if(qR.test(e)){let t=e.toLowerCase();return JR(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(JR(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:RR,code:GR,deviceUid:RR,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:BR,clientTime:$.Integer(),hubNonce:$.Optional(VR)},LR),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:RR,deviceUid:RR,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:BR,clientTime:$.Integer(),hubNonce:$.Optional(VR)},LR);var XR=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:RR,nonce:VR,issuedAt:$.Integer(),hubId:RR,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(BR),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},LR);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:RR,code:GR,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:RR,challenge:XR},LR),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:RR,nonce:VR,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},LR),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:RR,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},LR),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:RR,deviceUid:RR,deviceId:zR,pairingEpoch:RR,credentialId:RR,generation:$.Integer({minimum:1}),hubId:RR,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:HR,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(BR)},LR),$.Object({enrollmentId:RR,deviceUid:RR,keyFingerprint:BR,replaceKey:$.Optional($.Boolean())},LR),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:zR,pairingEpoch:RR,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},LR);var ZR=$.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}))},LR);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:RR,code:GR,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},LR);var QR=$.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:RR,expiresAt:$.Integer(),phase:QR,enrollment:$.Optional($.Object({enrollmentId:RR,deviceUid:RR,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:BR,proofVerified:$.Boolean(),keyChanged:$.Boolean()},LR)),deviceId:$.Optional(zR),error:$.Optional(ZR)},LR);function $R(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 ez(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 tz=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,nz=RegExp(`^${UR}$`),rz=/^sha256:[0-9a-f]{64}$/;function iz(e){let t=ez(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=$R(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&tz.test(r.id)&&typeof r.code==`string`&&nz.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!rz.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 az(e,t=Date.now()){let n=iz(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function oz(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=az(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function sz(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=oz(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=az(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:YR(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 cz=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,lz=e=>/^\/pair\/?$/.test(e.pathname)&&sz(e)===void 0?`/`:void 0,uz=4e3;async function dz(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 fz={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},pz={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},mz={class:`who`},hz={key:0,class:`muted`},gz={key:1,class:`muted`},_z={class:`fp`},vz={class:`row`},yz={class:`phase`},bz=[`onClick`],xz={key:2,class:`hint`},Sz={class:`pair-steps`,"aria-label":`Pairing progress`},Cz={class:`pair-grid`},wz={class:`pair-code-box`},Tz={class:`pair-code`,"aria-label":`Pairing code`},Ez={class:`pair-copy-actions`},Dz=[`innerHTML`],Oz={class:`pair-side`},kz={key:0,class:`hint`},Az={class:`pair-fingerprint`},jz={class:`fp`},Mz={class:`pair-confirm`},Nz={key:0,class:`pair-confirm warn`},Pz=[`disabled`],Fz=[`disabled`],Iz={class:`hint`},Lz=[`disabled`],Rz={key:5,class:`error`,role:`alert`},zz={key:4},Bz={class:`error`,role:`alert`},Vz=N({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=k(`boot`),o=k(),s=k(),c=k(),l=k(``),u=k(!1),d=k(!1),f=k(!1),p=k(!1),m=k(!1),h=k(!1),g=k(),_=k([]),v=U(()=>{let e=s.value?.code??``;return!JR(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=U(()=>s.value?By(s.value):``),b=U(()=>y.value?EO(y.value,148):``),x=U(()=>c.value?.enrollment?.keyFingerprint??``),S=U(()=>c.value?.deviceId??``);M(S,e=>{g.value?.(),e&&(g.value=M(()=>bu.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=Uy();o.value=t;try{let n=e?await Vy.resolveCode(e):await Vy.createCode();if(t.closed()){await Vy.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=cz(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}Ky(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 Vy.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 te(e){if(!s.value)return`cancelled`;try{let t=await Vy.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 ql&&e.status===409&&String(e.code)===`already_issued`){let e=await Vy.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 w=()=>te(!1),ne=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function re(){let e=S.value;if(e){u.value=!0;try{await Vy.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 dz({needsCancel:!!s.value&&!ne(),cancel:w,timeoutMs:uz});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 Vy.pending()).codes}catch{}}async function le(e){s.value=void 0,c.value=void 0,l.value=``;let t=Uy();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,Ky(t,e.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{l.value=e instanceof Error?e.message:String(e)})}return Vr(()=>{if(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)}),Wr(()=>{clearInterval(se);let e=o.value;e&&!e.closed()&&s.value&&!ne()&&te(!0).then(e=>{e!==`cancelled`&&J(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:ks(oe,[`self`])},[z(`div`,fz,[z(`header`,null,[t[5]||=z(`h2`,{id:`pair-title`},`Pair a device`,-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:oe},[B(A(vl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(I(),R(NO,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):H(``,!0),_.value.length?(I(),L(`section`,pz,[t[6]||=z(`h3`,null,`Machines waiting for you`,-1),z(`ul`,null,[(I(!0),L(F,null,P(_.value,e=>(I(),L(`li`,{key:e.codeId},[z(`div`,mz,[z(`strong`,null,D(e.deviceName??`unnamed device`),1),e.hostname?(I(),L(`span`,hz,D(e.hostname),1)):H(``,!0),e.platform?(I(),L(`span`,gz,D(e.platform),1)):H(``,!0)]),z(`div`,_z,D(e.keyFingerprint),1),z(`div`,vz,[z(`span`,yz,D(e.phase.replaceAll(`_`,` `)),1),z(`button`,{type:`button`,class:`small`,onClick:t=>le(e)},`Review`,8,bz)])]))),128))]),t[7]||=z(`p`,{class:`hint`},` Compare each fingerprint with the machine's own terminal before approving. Codes are minted by the hub — nothing has to be copied to the machine. `,-1)])):H(``,!0),a.value===`boot`?(I(),L(`p`,xz,`Minting a pairing code…`)):s.value?(I(),L(F,{key:3},[z(`ol`,Sz,[t[8]||=z(`li`,{class:E({on:!0})},`Code`,-1),z(`li`,{class:E({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),z(`li`,{class:E({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),z(`li`,{class:E({on:a.value===`issued`})},`Online`,2)]),z(`div`,Cz,[z(`div`,wz,[z(`div`,Tz,D(v.value),1),z(`div`,Ez,[z(`button`,{type:`button`,class:`small`,onClick:ie},[B(A(sc),{size:14}),V(` `+D(m.value?`Copied`:`Copy code`),1)]),z(`button`,{type:`button`,class:`small`,onClick:ae,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[B(A(sc),{size:14}),V(` `+D(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=z(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),z(`div`,{class:`pair-qr`,"aria-label":`Pairing QR code`,title:`Same offer link as Copy link: hub, code and expiry all in the #offer= fragment — it never reaches server logs`,innerHTML:b.value},null,8,Dz)]),z(`div`,Oz,[a.value===`code`||a.value===`proof`?(I(),L(`p`,kz,[B(A($c),{size:14,class:`spin`}),t[10]||=V(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(I(),L(F,{key:1},[z(`div`,Az,[t[11]||=z(`h3`,null,`Device key fingerprint`,-1),z(`code`,jz,D(x.value),1),t[12]||=z(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),z(`label`,Mz,[j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[bs,f.value]]),t[13]||=V(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(I(),L(`label`,Nz,[j(z(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[bs,p.value]]),B(A(il),{size:14}),t[14]||=V(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):H(``,!0),z(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:ee},` Approve device `,8,Pz),z(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:w},` Cancel pairing `,8,Fz)],64)):a.value===`issued`?(I(),L(F,{key:2},[z(`p`,Iz,[B(A(ic),{size:14}),t[15]||=V(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),z(`button`,{type:`button`,class:`small`,onClick:oe},`Close`),z(`button`,{type:`button`,class:`small danger`,disabled:!S.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:re},` Revoke this credential `,8,Lz)],64)):a.value===`cancelled`?(I(),L(F,{key:3},[t[16]||=z(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>C()},`Start over`)],64)):a.value===`expired`?(I(),L(F,{key:4},[t[17]||=z(`p`,{class:`hint`},`The pairing code expired.`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>C()},`New code`)],64)):H(``,!0),l.value?(I(),L(`p`,Rz,D(l.value),1)):H(``,!0)])])],64)):(I(),L(`div`,zz,[z(`p`,Bz,D(l.value||`This pairing link is unavailable.`),1),z(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>C()},`New code`)]))])]))}}),Hz={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},Uz={class:`hint`},Wz={key:1,class:`hint`},Gz=N({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>bu.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>r(`close`),[`self`])},[z(`section`,Hz,[z(`header`,null,[t[3]||=z(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[B(A(vl),{size:18})])]),i.value?(I(),L(F,{key:0},[z(`p`,null,[V(D(i.value.name)+` `,1),z(`code`,null,D(i.value.id),1)]),z(`p`,Uz,D(i.value.status)+` · tunnel `+D(i.value.tunnel?.state??`disconnected`)+` · `+D(i.value.tunnel?.readerCount??0)+` readers `,1),B(tb,{device:i.value},null,8,[`device`])],64)):(I(),L(`p`,Wz,`This device is no longer in the registry.`)),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),Kz={id:`prompt-title`},qz=[`disabled`],Jz={key:0,class:`hint`},Yz={key:1},Xz={key:0,class:`muted`},Zz=[`placeholder`,`disabled`],Qz=[`required`,`placeholder`,`aria-label`,`disabled`],$z={key:2,class:`message-error`,role:`alert`},eB=[`disabled`],tB=[`disabled`],nB=N({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=k(n.dialog.value??``),a=k(!1),o=k(``),s=k(),c=!!n.dialog.label;async function l(){if(!a.value&&(!c||n.dialog.optional||i.value.trim())){a.value=!0,o.value=``;try{await n.dialog.run(i.value.trim()),r(`close`)}catch(e){o.value=cu(e)}finally{a.value=!1}}}return Vr(()=>void An(()=>(s.value?.focus(),s.value?.select()))),(t,n)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:n[4]||=ks(e=>!a.value&&r(`close`),[`self`])},[z(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:ks(l,[`prevent`])},[z(`header`,null,[z(`h2`,Kz,D(e.dialog.title),1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:a.value,onClick:n[0]||=e=>r(`close`)},[B(A(vl),{size:18})],8,qz)]),e.dialog.hint?(I(),L(`p`,Jz,D(e.dialog.hint),1)):H(``,!0),c?(I(),L(`label`,Yz,[V(D(e.dialog.label)+` `,1),e.dialog.optional?(I(),L(`span`,Xz,`(optional)`)):H(``,!0),e.dialog.multiline?j((I(),L(`textarea`,{key:1,ref_key:`input`,ref:s,"onUpdate:modelValue":n[1]||=e=>i.value=e,rows:`4`,placeholder:e.dialog.placeholder,disabled:a.value},null,8,Zz)),[[ys,i.value]]):j((I(),L(`input`,{key:2,ref_key:`input`,ref:s,"onUpdate:modelValue":n[2]||=e=>i.value=e,maxlength:`100`,required:!e.dialog.optional,placeholder:e.dialog.placeholder,"aria-label":e.dialog.label,disabled:a.value},null,8,Qz)),[[ys,i.value]])])):H(``,!0),o.value?(I(),L(`p`,$z,D(o.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,disabled:a.value,onClick:n[3]||=e=>r(`close`)},` Cancel `,8,eB),z(`button`,{class:E([`primary`,{danger:e.dialog.danger}]),disabled:a.value||c&&!e.dialog.optional&&!i.value.trim()},D(a.value?`Working…`:e.dialog.submit),11,tB)])],32)]))}}),rB={class:`modal model-modal`},iB={class:`eyebrow`},aB={class:`model-list`},oB=[`onClick`],sB=[`src`],cB={class:`hint`},lB=N({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=k(``),i=U(()=>Wu.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),a=e=>e.id===Gu.value.agent.model?.modelId&&e.provider===Gu.value.agent.model?.provider;async function o(e){await ad(()=>Fu.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await ed(),J(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>n(`close`),[`self`])},[z(`section`,rB,[z(`header`,null,[z(`div`,null,[z(`span`,iB,`PER AGENT · `+D(A(Ou)?.id),1),t[3]||=z(`h2`,null,`Choose a model`,-1)]),z(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[B(A(vl),{size:18})])]),j(z(`input`,{"onUpdate:modelValue":t[1]||=e=>r.value=e,placeholder:`Search models or tiers…`,"aria-label":`Search models`},null,512),[[ys,r.value]]),z(`div`,aB,[(I(!0),L(F,null,P(i.value,e=>(I(),L(`button`,{key:`${e.provider}/${e.id}`,class:E({selected:a(e)}),onClick:t=>o(e)},[z(`img`,{src:A(ld)(e.id),alt:``},null,8,sB),z(`div`,null,[z(`strong`,null,D(e.name),1),z(`small`,null,D(e.tier)+` / `+D(e.provider)+` / `+D(A(sd)(e.contextWindow))+` context`,1)]),a(e)?(I(),R(A(tc),{key:0,size:18})):H(``,!0)],10,oB))),128))]),z(`p`,cB,`Models available on `+D(A(Ou)?.id)+`. Provider keys stay on the device.`,1)])]))}}),uB={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},dB={class:`dialog-head`},fB={class:`dialog-body`},pB={class:`n`},mB={class:`body`},hB={class:`help-callout`},gB={class:`dialog-foot`},_B={class:`right`},vB=N({__name:`HelpDialog`,setup(e){let t=[{title:`Pick a device, start a session`,body:`Every device in the tree runs dpi-backend. A session gets its own SQLite database on that device, in the directory you choose.`},{title:`Send work, then close the browser`,body:`The device owns the run. Reopening restores committed messages, state and live progress.`},{title:`Change state and fork`,body:`Edit App State by hand or through the agent. Every session and fork on a device shares it.`},{title:`Interrupt deliberately`,body:`Interrupt stops foreground work and owned subagents. Background jobs continue. Stop all includes them.`},{title:`Explore the boundaries`,body:`Queue a follow-up, steer after tools, wait for approval, compact context, reset or inspect raw state.`},{title:`Restart a device`,body:`Its tree dims and shows the restart command. Checkpointed jobs recover on boot. Replay-safe tools may rerun. Other interrupted tools return an error.`}];return(e,n)=>(I(),L(`div`,{class:`scrim`,onClick:n[2]||=ks(e=>A(q).dialog=void 0,[`self`])},[z(`section`,uB,[z(`div`,dB,[n[3]||=z(`div`,null,[z(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),z(`h3`,{id:`help-title`},`What makes this durable?`)],-1),z(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>A(q).dialog=void 0},[B(A(vl),{size:18})])]),z(`div`,fB,[(I(),L(F,null,P(t,(e,t)=>z(`div`,{key:e.title,class:`help-step`},[z(`span`,pB,D(String(t+1).padStart(2,`0`)),1),z(`div`,null,[z(`b`,null,D(e.title),1),z(`div`,mB,D(e.body),1)])])),64)),z(`div`,hB,[B(A(Oc),{size:18}),n[4]||=z(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),z(`div`,gB,[z(`div`,_B,[z(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>A(q).dialog=void 0},`Close`)])])])]))}}),yB=Wt({needed:!1,busy:!1,error:``}),bB=new Set,xB=e=>{let t=[...bB];bB=new Set;for(let n of t)n(e)},SB=()=>new Promise(e=>bB.add(e));async function CB(e){if(yB.busy||!e)return!1;yB.busy=!0,yB.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?(yB.needed=!1,xB(!0),!0):(yB.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 yB.error=`Cannot reach the hub.`,!1}finally{yB.busy=!1}}var wB=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function TB(e){return(async(t,n)=>{let r=()=>e(t,n),i=await r();if(i.status!==401||wB(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;yB.needed=!0;let a=await i.text().catch(()=>``);return await SB()?r():new Response(a,{status:i.status,headers:i.headers})})}function EB(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=TB(window.fetch.bind(window)))}var DB={class:`login-veil`,"data-testid":`login-card`},OB=[`disabled`],kB={key:0,class:`message-error`,role:`alert`},AB=[`disabled`],jB=N({__name:`LoginCard`,setup(e){let t=k(``),n=k();async function r(){if(yB.busy||!t.value.trim())return;let e=await CB(t.value.trim());t.value=``,e&&n.value?.blur()}return Vr(()=>void An(()=>n.value?.focus())),(e,i)=>(I(),L(`div`,DB,[z(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:ks(r,[`prevent`])},[i[2]||=z(`header`,null,[z(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=z(`p`,{class:`hint`},[V(` This hub is locked. Sign in with the token from its `),z(`code`,null,`admin.token`),V(` file. `)],-1),i[4]||=z(`label`,{for:`admin-token`},`Admin token`,-1),j(z(`input`,{id:`admin-token`,ref_key:`input`,ref:n,"onUpdate:modelValue":i[0]||=e=>t.value=e,type:`password`,name:`admin-token`,autocomplete:`off`,spellcheck:`false`,placeholder:`adm_…`,"aria-label":`Admin token`,disabled:A(yB).busy,onKeydown:i[1]||=js(e=>A(yB).error=``,[`esc`])},null,40,OB),[[ys,t.value]]),A(yB).error?(I(),L(`p`,kB,D(A(yB).error),1)):H(``,!0),z(`footer`,null,[z(`button`,{class:`primary`,type:`submit`,disabled:A(yB).busy||!t.value.trim()},D(A(yB).busy?`Checking…`:`Sign in`),9,AB)])],32)]))}}),MB={key:0,class:`toast`,role:`status`},NB=N({__name:`Toast`,setup(e){return(e,t)=>(I(),R(bo,{name:`toast`},{default:Hn(()=>[A(q).toast?(I(),L(`div`,MB,[B(A(tc),{size:18}),V(D(A(q).toast),1)])):H(``,!0)]),_:1}))}}),PB={class:`shell`,"data-testid":`app-shell`},FB={key:0,class:`error-banner`,role:`alert`},IB={key:4,class:`welcome`,"data-testid":`welcome-empty`},LB=[`disabled`],RB={class:`welcome-features`},zB={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},BB={class:`full-directory`},VB=N({__name:`App`,setup(e){let t=()=>bu.devices.value.filter(e=>e.status===`online`).length,n=k();function r(){q.dialog={kind:`new-session`,deviceId:K.value?.deviceId}}function i(e){let t=q.dialog?void 0:Sd(e);if(t)return e.preventDefault(),t===`tree`?vd():yd();if(e.key===`Escape`){if(q.dialog){q.dialog.kind===`pair`?n.value?.close():q.dialog=void 0;return}!e.repeat&&!e.isComposing&&Yu.value&&(e.preventDefault(),fd()),q.drawer=!1,q.inspectorOverlay=!1}}function a(e){let t=e.clientX,n=wu.value,r=e=>wu.value=Math.max(220,Math.min(560,n+e.clientX-t)),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}return Vr(()=>tf()),Vr(()=>{document.addEventListener(`keydown`,i),Hu()}),Wr(()=>{vu.stop(),document.removeEventListener(`keydown`,i)}),(e,i)=>(I(),L(`div`,PB,[B(Ld,{onNewSession:r}),A(q).error?(I(),L(`div`,FB,[B(A(Oc),{size:18}),z(`span`,null,D(A(q).error),1),z(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:i[0]||=e=>A(q).error=``},`×`)])):H(``,!0),z(`main`,{class:`net-workspace`,style:ge({"--tree-w":`${A(wu)}px`})},[B(up),A(Tu).tree?(I(),L(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:ks(a,[`prevent`])},null,32)):H(``,!0),A(q).drawer?(I(),L(`div`,{key:1,class:`tree-backdrop`,onClick:i[1]||=e=>A(q).drawer=!1})):H(``,!0),A(K)&&A(Ou)&&A(ku)?(I(),L(F,{key:2},[B(wD),A(q).inspectorOverlay?(I(),L(`div`,{key:0,class:`inspector-backdrop`,onClick:i[2]||=e=>A(_d)()})):H(``,!0),(I(),R(fy,{key:`${A(K).deviceId}/${A(K).sessionId}`}))],64)):A(K)&&A(Ou)?(I(),R(PD,{key:3,device:A(Ou)},null,8,[`device`])):(I(),L(`section`,IB,[i[14]||=z(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),i[15]||=z(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),i[16]||=z(`h1`,null,[V(`Close the tab.`),z(`br`),V(`The work continues.`)],-1),i[17]||=z(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),z(`button`,{class:`primary`,disabled:!t(),onClick:r},[B(A(Xc),{size:18}),V(D(A(bu).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,LB),z(`div`,RB,[z(`span`,null,[B(A(fc),{size:18}),i[11]||=V(`SQLite on each device`,-1)]),z(`span`,null,[B(A(Cc),{size:18}),i[12]||=V(`Branch any agent`,-1)]),z(`span`,null,[B(A(Vs),{size:18}),i[13]||=V(`Watch from anywhere`,-1)])])]))],4),B(Bd),A(q).dialog?.kind===`pair`?(I(),R(Vz,{key:1,ref_key:`pairWizard`,ref:n,handoff:A(q).dialog.handoff,onClose:i[3]||=e=>A(q).dialog=void 0},null,8,[`handoff`])):H(``,!0),A(q).dialog?.kind===`credentials`?(I(),R(Gz,{key:2,"device-id":A(q).dialog.deviceId,onClose:i[4]||=e=>A(q).dialog=void 0},null,8,[`device-id`])):H(``,!0),A(q).dialog?.kind===`new-session`?(I(),R(eO,{key:3,"device-id":A(q).dialog.deviceId,onClose:i[5]||=e=>A(q).dialog=void 0},null,8,[`device-id`])):A(q).dialog?.kind===`prompt`?(I(),R(nB,{key:4,dialog:A(q).dialog,onClose:i[6]||=e=>A(q).dialog=void 0},null,8,[`dialog`])):A(q).dialog?.kind===`models`?(I(),R(lB,{key:5,onClose:i[7]||=e=>A(q).dialog=void 0})):A(q).dialog?.kind===`path`?(I(),L(`div`,{key:6,class:`modal-backdrop`,onClick:i[10]||=ks(e=>A(q).dialog=void 0,[`self`])},[z(`section`,zB,[z(`header`,null,[i[18]||=z(`h2`,{id:`path-title`},`Working directory`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:i[8]||=e=>A(q).dialog=void 0},[B(A(vl),{size:18})])]),z(`code`,BB,D(A(q).dialog.path),1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:i[9]||=e=>A(q).dialog=void 0},`Close`)])])])):A(q).dialog?.kind===`help`?(I(),R(vB,{key:7})):H(``,!0),A(yB).needed?(I(),R(jB,{key:8})):H(``,!0),B(NB)]))}});EB();var HB=new URL(window.location.href);if(/^\/pair\/?$/.test(HB.pathname)){let e=sz(HB);e?(HB.search=``,HB.hash=``,window.history.replaceState(window.history.state,``,HB),q.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,lz(HB))}Fs(VB).mount(`#app`);
|
|
79
|
+
`)+D(t),1))),128))])):H(``,!0)])):H(``,!0),d.value?(I(),L(`pre`,xC,D(d.value.slice(0,6e3)),1)):H(``,!0)],64)):(I(),L(`p`,Rb,[...t[41]||=[V(`Not a git repository — run `,-1),z(`code`,null,`git init`,-1),V(` (or open a session inside a repo).`,-1)]]))],2)):H(``,!0),w.value?(I(),L(`div`,{key:4,class:`modal-veil`,onClick:t[40]||=ks(e=>w.value=null,[`self`])},[z(`div`,{class:E([`modal`,{danger:w.value.danger}]),role:`dialog`,"aria-modal":`true`},[z(`h5`,null,D(w.value.title),1),z(`p`,null,D(w.value.body),1),w.value.input?j((I(),L(`textarea`,{key:0,"onUpdate:modelValue":t[38]||=e=>ne.value=e,rows:`2`,placeholder:w.value.input.placeholder},null,8,SC)),[[ys,ne.value]]):H(``,!0),z(`div`,CC,[t[72]||=z(`span`,{class:`grow`},null,-1),z(`button`,{class:`small`,onClick:t[39]||=e=>w.value=null},[...t[71]||=[V(`cancel `,-1),z(`span`,{class:`muted-line`},`(esc)`,-1)]]),z(`button`,{class:E([`primary small`,{danger:w.value.danger}]),disabled:!(!w.value.input||ne.value.trim()),onClick:ie},D(w.value.confirmLabel??`confirm`),11,wC)])],2)])):H(``,!0)],64)):(I(),L(`p`,Pb,`No session selected — open a session to see its git.`))]))}}),[[`__scopeId`,`data-v-e5829ed1`]]),EC={class:`host-panel`,"aria-label":`Device vitals`},DC={class:`panel-heading`},OC=[`disabled`],kC={key:0,class:`hint`},AC={key:1,class:`message-error`},jC={key:2,class:`hint`},MC={class:`vitals-grid`},NC={class:`vital`},PC={class:`vital`},FC={key:0,class:`vital`},IC={class:`vital`},LC={class:`vital`},RC={class:`meter`},zC={class:`meter-head`},BC={class:`hint`},VC=[`aria-valuenow`],HC={class:`meter`},UC={class:`meter-head`},WC={class:`hint`},GC=[`aria-valuenow`],KC={class:`path`},qC={class:`hint`},JC=Id(N({__name:`HostPanel`,setup(e){let t=k(),n=k(!1),r=k(``),i=U(()=>K.value?.deviceId),a=U(()=>bu.devices.value.find(e=>e.id===i.value)?.info?.keepAwake),o=e=>{if(!Number.isFinite(e)||e<=0)return`0`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=100||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`},s=e=>{let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`},c=(e,t)=>t>0?Math.max(0,Math.min(100,Math.round(e/t*100))):0,l=U(()=>t.value?c(t.value.memory.usedBytes,t.value.memory.totalBytes):0),u=U(()=>t.value?.disk.known?c(t.value.disk.totalBytes-t.value.disk.freeBytes,t.value.disk.totalBytes):0);async function d(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).vitals()}catch(e){r.value=cu(e).slice(0,160)}finally{n.value=!1}}}M(i,d,{immediate:!0});async function f(){await d(),r.value||J(`Vitals refreshed.`)}return(e,c)=>(I(),L(`section`,EC,[z(`header`,DC,[z(`span`,null,[B(A(rl),{size:16}),c[0]||=V(`HOST`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh vitals`,title:`Refresh vitals`,onClick:f},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,OC)]),i.value?r.value?(I(),L(`p`,AC,D(r.value),1)):t.value?(I(),L(F,{key:3},[z(`div`,MC,[z(`div`,NC,[c[1]||=z(`span`,{class:`label`},`Host uptime`,-1),z(`strong`,null,D(s(t.value.uptime)),1)]),z(`div`,PC,[c[2]||=z(`span`,{class:`label`},`Device process`,-1),z(`strong`,null,D(s(t.value.processUptime)),1),z(`em`,null,`pid `+D(t.value.pid),1)]),a.value?(I(),L(`div`,FC,[c[3]||=z(`span`,{class:`label`},`Keep-awake`,-1),z(`strong`,null,D(a.value===`none`?`off`:a.value),1),z(`em`,null,D(a.value===`none`?`no inhibitor here`:`held while sessions run`),1)])):H(``,!0),z(`div`,IC,[c[4]||=z(`span`,{class:`label`},`Load (1/5/15m)`,-1),z(`strong`,null,D(t.value.loadavg.map(e=>e.toFixed(2)).join(` · `)),1),z(`em`,null,D(t.value.cpuCount)+` CPU`+D(t.value.cpuCount===1?``:`s`),1)]),z(`div`,LC,[c[5]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(t.value.counts?.sessions??0),1),z(`em`,null,D(t.value.counts?.archived??0)+` archived`,1)])]),z(`div`,RC,[z(`div`,zC,[c[6]||=z(`span`,{class:`label`},`Memory`,-1),z(`span`,BC,D(o(t.value.memory.usedBytes))+` / `+D(o(t.value.memory.totalBytes))+` · device `+D(o(t.value.memory.processRssBytes)),1)]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":l.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Memory used`},[z(`i`,{style:ge({width:`${l.value}%`}),class:E({high:l.value>=90})},null,6)],8,VC)]),z(`div`,HC,[z(`div`,UC,[c[7]||=z(`span`,{class:`label`},`Disk · data dir`,-1),z(`span`,WC,[t.value.disk.known?(I(),L(F,{key:0},[V(D(o(t.value.disk.totalBytes-t.value.disk.freeBytes))+` used · `+D(o(t.value.disk.freeBytes))+` free `,1)],64)):(I(),L(F,{key:1},[V(`unknown on this volume`)],64))])]),z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":u.value,"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`Disk used`},[z(`i`,{style:ge({width:`${u.value}%`}),class:E({high:u.value>=90})},null,6)],8,GC),z(`code`,KC,D(t.value.disk.path),1)]),z(`p`,qC,[B(A(Vs),{size:13}),c[8]||=V(` Read on demand — open this tab or press refresh. Nothing polls the device. `,-1)])],64)):(I(),L(`p`,jC,D(n.value?`Reading host…`:`No vitals.`),1)):(I(),L(`p`,kC,`Select a session to see its device.`))]))}}),[[`__scopeId`,`data-v-ef6f9dc5`]]),YC={class:`usage-panel`,"aria-label":`Device usage`},XC={class:`panel-heading`},ZC=[`disabled`],QC={key:0,class:`hint`},$C={key:1,class:`message-error`},ew={key:2,class:`hint`},tw={key:3,class:`hint`},nw={class:`usage-block`,"aria-labelledby":`usage-totals`},rw={class:`totals`},iw={class:`total`},aw={class:`total`},ow={class:`total`},sw={class:`total`},cw={class:`usage-block`,"aria-labelledby":`usage-models`},lw={class:`section-label block-label`},uw={class:`table-scroll`},dw={class:`usage-table`,"aria-label":`Usage by model`},fw=[`title`],pw={class:`num`},mw={class:`num`},hw={class:`share-col`},gw={class:`share`},_w=[`aria-valuenow`,`aria-label`],vw={class:`pct`},yw={class:`usage-block`,"aria-labelledby":`usage-projects`},bw={class:`section-label block-label`},xw={key:0,class:`hint`},Sw={key:1,class:`rows`},Cw=[`title`],ww={class:`row-main`},Tw={class:`row-num`},Ew={class:`row-num`},Dw={class:`row-meta`},Ow={class:`usage-block`,"aria-labelledby":`usage-sessions`},kw={key:0,class:`hint`},Aw={key:1,class:`rows scroll`},jw=[`title`],Mw={class:`row-main`},Nw={class:`row-num`},Pw={class:`row-num`},Fw={class:`row-meta`},Iw={class:`hint`},Lw=Id(N({__name:`UsagePanel`,setup(e){let t=k(),n=k(!1),r=k(``),i=U(()=>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=U(()=>(t.value?.models??[]).reduce((e,t)=>Math.max(e,t.cost||0),0)),c=e=>s.value>0?Math.max(0,Math.min(100,Math.round((e||0)/s.value*100))):0,l=U(()=>{let e=t.value;return!e||!e.models.length&&!e.sessions.length&&!e.projects.length}),u=U(()=>t.value?new Date(t.value.at).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`}):``),d=(e,t)=>`${a(e)} ${t}${e===1?``:`s`}`;async function f(){let e=i.value;if(t.value=void 0,r.value=``,e){n.value=!0;try{t.value=await G(e).deviceUsage()}catch(e){r.value=cu(e).slice(0,160)}finally{n.value=!1}}}M(i,f,{immediate:!0});async function p(){await f(),r.value||J(`Usage refreshed.`)}return(e,s)=>(I(),L(`section`,YC,[z(`header`,XC,[z(`span`,null,[B(A(Vs),{size:16}),s[0]||=V(`USAGE`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!i.value,"aria-label":`Refresh usage`,title:`Refresh usage`,onClick:p},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,ZC)]),i.value?r.value?(I(),L(`p`,$C,D(r.value),1)):t.value?l.value?(I(),L(`p`,tw,`No usage recorded yet.`)):(I(),L(F,{key:4},[z(`section`,nw,[s[6]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-totals`},`TOTALS`)],-1),z(`div`,rw,[z(`div`,iw,[s[1]||=z(`span`,{class:`label`},`Tokens`,-1),z(`strong`,null,D(a(t.value.totals.tokens)),1)]),z(`div`,aw,[s[2]||=z(`span`,{class:`label`},`Cost`,-1),z(`strong`,null,D(o(t.value.totals.cost)),1)]),z(`div`,ow,[s[3]||=z(`span`,{class:`label`},`Sessions`,-1),z(`strong`,null,D(a(t.value.sessions.length)),1),z(`em`,null,D(a(t.value.projects.length))+` projects`,1)]),z(`div`,sw,[s[4]||=z(`span`,{class:`label`},`Models`,-1),z(`strong`,null,D(a(t.value.models.length)),1),s[5]||=z(`em`,null,`costliest first`,-1)])])]),z(`section`,cw,[z(`div`,lw,[s[7]||=z(`span`,{id:`usage-models`},`BY MODEL`,-1),B(A(dc),{size:13})]),z(`div`,uw,[z(`table`,dw,[s[8]||=z(`colgroup`,null,[z(`col`),z(`col`),z(`col`),z(`col`)],-1),s[9]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Model`),z(`th`,{scope:`col`,class:`num`},`Tokens`),z(`th`,{scope:`col`,class:`num`},`Cost`),z(`th`,{scope:`col`,class:`share-col`},`Share`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(t.value.models,e=>(I(),L(`tr`,{key:e.key},[z(`th`,{scope:`row`,class:`model-key`,title:`${e.key} — in ${e.input} · out ${e.output} · cache read ${e.cacheRead} · cache write ${e.cacheWrite}`},D(e.key),9,fw),z(`td`,pw,D(a(e.tokens)),1),z(`td`,mw,D(o(e.cost)),1),z(`td`,hw,[z(`div`,gw,[z(`div`,{class:`bar`,role:`meter`,"aria-valuenow":c(e.cost),"aria-valuemin":`0`,"aria-valuemax":`100`,"aria-label":`${e.key} share of the costliest model`},[z(`i`,{style:ge({width:`${c(e.cost)}%`}),class:E({high:c(e.cost)>90})},null,6)],8,_w),z(`em`,vw,D(c(e.cost))+`%`,1)])])]))),128))])])])]),z(`section`,yw,[z(`div`,bw,[s[10]||=z(`span`,{id:`usage-projects`},`BY PROJECT`,-1),B(A(vc),{size:13})]),t.value.projects.length?(I(),L(`ul`,Sw,[(I(!0),L(F,null,P(t.value.projects,e=>(I(),L(`li`,{key:e.rootPath,class:`row`,title:e.rootPath},[z(`span`,ww,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.rootPath),1)]),z(`span`,Tw,D(a(e.tokens))+` tok`,1),z(`span`,Ew,D(o(e.cost)),1),z(`span`,Dw,D(d(e.sessions,`session`)),1)],8,Cw))),128))])):(I(),L(`p`,xw,`No project usage recorded yet.`))]),z(`section`,Ow,[s[11]||=z(`div`,{class:`section-label block-label`},[z(`span`,{id:`usage-sessions`},`BY SESSION`)],-1),t.value.sessions.length?(I(),L(`ul`,Aw,[(I(!0),L(F,null,P(t.value.sessions,e=>(I(),L(`li`,{key:e.id,class:`row`,title:e.cwd},[z(`span`,Mw,[z(`strong`,null,D(e.name),1),z(`em`,null,D(e.project??e.cwd),1)]),z(`span`,Nw,D(a(e.tokens))+` tok`,1),z(`span`,Pw,D(o(e.cost)),1),z(`span`,Fw,D(d(e.agents,`agent`)),1)],8,jw))),128))])):(I(),L(`p`,kw,`No session usage recorded yet.`))]),z(`p`,Iw,[B(A(Vs),{size:13}),V(` Read on demand — open this tab or press refresh (`+D(u.value)+`). Nothing polls the device. `,1)])],64)):(I(),L(`p`,ew,D(n.value?`Reading usage…`:`No usage recorded yet.`),1)):(I(),L(`p`,QC,`Select a session to see its device's usage.`))]))}}),[[`__scopeId`,`data-v-81e8eb49`]]),Rw={class:`schedules-panel`,"aria-label":`Scheduled sessions`},zw={class:`panel-heading`},Bw=[`disabled`],Vw=[`disabled`],Hw={key:0,class:`hint`},Uw={key:1,class:`message-error`},Ww=[`value`],Gw={class:`trigger-row`},Kw={class:`inline`},qw=[`disabled`],Jw={class:`inline`},Yw=[`disabled`],Xw={class:`row`},Zw=[`disabled`],Qw={key:3,class:`hint`},$w={key:4,class:`schedule-list`},eT={class:`head`},tT={class:`tag`},nT={key:0,class:`tag running`},rT=[`title`],iT={class:`next`},aT={class:`cwd`},oT={key:0,class:`message-error`},sT={class:`row`},cT=[`disabled`,`onClick`],lT=[`disabled`,`onClick`],uT=[`disabled`,`onClick`],dT=Id(N({__name:`SchedulesPanel`,setup(e){let t=k([]),n=k(``),r=k(``),i=k(!1),a=U(()=>K.value?.deviceId),o=()=>G(a.value??``),s=k(`60`),c=k(``),l=k(!1),u=k({name:``,cwd:``,prompt:``,model:``});async function d(){if(!a.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await o().schedules()).schedules}catch(e){let t=e.code;r.value=t===`not_found`||/allowlist/i.test(cu(e))?"This device runs an older build: update it (`dpi update`) to use schedules.":cu(e).slice(0,160)}finally{i.value=!1}}M(a,d,{immediate:!0});let f=e=>{if(!e)return`—`;let t=e-Date.now(),n=Math.round(Math.abs(t)/6e4),r=n<60?`${n}m`:n<1440?`${Math.round(n/60)}h`:`${Math.round(n/1440)}d`;return t>=0?`in ${r}`:`${r} ago`},p=e=>e.everyMinutes?`every ${e.everyMinutes}m`:`daily ${e.dailyAt}`;async function m(e,t,r){n.value=e;try{await t(),await d(),J(r)}catch(e){J(cu(e).slice(0,140))}finally{n.value=``}}let h=e=>m(e.id,()=>o().updateSchedule(e.id,{enabled:!e.enabled}),e.enabled?`Schedule paused.`:`Schedule resumed.`),g=e=>m(e.id,()=>o().runSchedule(e.id),`${e.name}: run finished.`),_=e=>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=k([]);async function y(){l.value=!0,u.value={name:``,cwd:(K.value?.sessionId,``),prompt:``,model:``};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=[]}}async function b(){let e=u.value,[t,...r]=e.model.split(`/`),i=r.join(`/`);if(e.name.trim()&&e.cwd.trim()&&e.prompt.trim()&&t&&i){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(cu(e).slice(0,160))}finally{n.value=``}}}return(e,o)=>(I(),L(`section`,Rw,[z(`header`,zw,[z(`span`,null,[B(A(ec),{size:16}),o[7]||=V(`SCHEDULES`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!a.value,"aria-label":`Refresh schedules`,title:`Refresh schedules`,onClick:d},[B(A($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,Bw),z(`button`,{class:`icon-button`,disabled:!a.value,"aria-label":`Add schedule`,title:`Add schedule`,onClick:y},[B(A(Xc),{size:15})],8,Vw)]),o[18]||=z(`p`,{class:`hint`},`Runs on the device's own clock — no browser needs to be open.`,-1),a.value?r.value?(I(),L(`p`,Uw,D(r.value),1)):H(``,!0):(I(),L(`p`,Hw,`Select a session to see its device.`)),l.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(b,[`prevent`])},[z(`label`,null,[o[8]||=V(`Name`,-1),j(z(`input`,{"onUpdate:modelValue":o[0]||=e=>u.value.name=e,placeholder:`Nightly smoke`,required:``},null,512),[[ys,u.value.name]])]),z(`label`,null,[o[9]||=V(`Directory`,-1),j(z(`input`,{"onUpdate:modelValue":o[1]||=e=>u.value.cwd=e,placeholder:`/home/me/project`,required:``},null,512),[[ys,u.value.cwd]])]),z(`label`,null,[o[10]||=V(`Prompt`,-1),j(z(`textarea`,{"onUpdate:modelValue":o[2]||=e=>u.value.prompt=e,rows:`3`,placeholder:`Run the tests and summarise failures`,required:``},null,512),[[ys,u.value.prompt]])]),z(`label`,null,[o[11]||=V(`Model `,-1),j(z(`select`,{"onUpdate:modelValue":o[3]||=e=>u.value.model=e},[(I(!0),L(F,null,P(v.value,e=>(I(),L(`option`,{key:e.key,value:e.key},D(e.key),9,Ww))),128))],512),[[Ss,u.value.model]])]),z(`div`,Gw,[z(`label`,Kw,[o[12]||=V(`Every `,-1),j(z(`input`,{"onUpdate:modelValue":o[4]||=e=>s.value=e,class:`num`,disabled:!!c.value.trim()},null,8,qw),[[ys,s.value]]),o[13]||=V(` min`,-1)]),o[15]||=z(`span`,{class:`muted`},`or`,-1),z(`label`,Jw,[o[14]||=V(`daily at `,-1),j(z(`input`,{"onUpdate:modelValue":o[5]||=e=>c.value=e,class:`num time`,placeholder:`03:00`,disabled:!!s.value},null,8,Yw),[[ys,c.value]])])]),z(`div`,Xw,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`creating…`:`Create schedule`),9,Zw),z(`button`,{class:`small`,type:`button`,onClick:o[6]||=e=>l.value=!1},`Cancel`)])],32)):H(``,!0),!l.value&&!t.value.length&&a.value&&!r.value?(I(),L(`p`,Qw,` No schedules yet. Press + to add one. `)):H(``,!0),t.value.length?(I(),L(`ul`,$w,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`schedule`,{off:!e.enabled}])},[z(`div`,eT,[z(`b`,null,D(e.name),1),z(`span`,tT,D(p(e)),1),e.running?(I(),L(`span`,nT,`running`)):e.lastOutcome===`failed`?(I(),L(`span`,{key:1,class:`tag bad`,title:e.lastError},`last run failed`,8,rT)):H(``,!0),z(`span`,iT,D(e.enabled?`next ${f(e.nextRunAt)}`:`paused`),1)]),z(`code`,aT,D(e.cwd),1),e.lastError?(I(),L(`p`,oT,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,sT,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>g(e)},[B(A(Yc),{size:12}),o[16]||=V(`run now`,-1)],8,cT),z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>h(e)},[B(A(Zc),{size:12}),V(D(e.enabled?`pause`:`resume`),1)],8,lT),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>_(e)},[B(A(dl),{size:12}),o[17]||=V(`remove`,-1)],8,uT)])],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-7f6db3c9`]]),fT={class:`notify-panel`,"aria-label":`Notification sinks`},pT={class:`panel-heading`},mT=[`disabled`],hT=[`disabled`],gT=[`disabled`],_T={key:0,class:`hint`},vT={key:1,class:`message-error`},yT=[`placeholder`],bT={class:`row`},xT=[`disabled`],ST={key:3,class:`hint`},CT={key:4,class:`sink-list`},wT={class:`head`},TT={class:`tag`},ET={class:`next`},DT={class:`url`},OT={key:0,class:`hint`},kT={key:1,class:`message-error`},AT={class:`row`},jT=[`disabled`,`onClick`],MT=[`disabled`,`onClick`],NT={key:5,class:`results`,"aria-label":`Test results`},PT={class:`tag`},FT={key:0},IT=Id(N({__name:`NotifyPanel`,setup(e){let t=k([]),n=k(``),r=k(``),i=k(!1),a=k([]),o=U(()=>K.value?.deviceId),s=()=>G(o.value??``),c=k(!1),l=k({kind:`webhook`,url:``,label:``,events:``});async function u(){if(!o.value)return void(t.value=[]);i.value=!0,r.value=``;try{t.value=(await s().notifySinks()).sinks}catch(e){let t=e.code;r.value=t===`not_found`||/allowlist/i.test(cu(e))?"This device runs an older build: update it (`dpi update`) to use notifications.":cu(e).slice(0,160)}finally{i.value=!1}}M(o,u,{immediate:!0});let d=e=>{if(!e)return`never`;let t=Math.round((Date.now()-e)/6e4);return t<1?`just now`:t<60?`${t}m ago`:`${Math.round(t/60)}h ago`};async function f(){let e=l.value;if(e.url.trim()){n.value=`new`;try{await s().createNotifySink({kind:e.kind,url:e.url.trim(),...e.label.trim()?{label:e.label.trim()}:{},...e.events.trim()?{events:e.events.split(`,`).map(e=>e.trim()).filter(Boolean)}:{}}),c.value=!1,l.value={kind:`webhook`,url:``,label:``,events:``},await u(),J(`Sink added on the device.`)}catch(e){J(cu(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(cu(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(cu(e).slice(0,160))}finally{n.value=``}}return(e,s)=>(I(),L(`section`,fT,[z(`header`,pT,[z(`span`,null,[B(A(Xs),{size:16}),s[6]||=V(`NOTIFY`,-1)]),z(`button`,{class:`icon-button`,disabled:i.value||!o.value,"aria-label":`Refresh sinks`,title:`Refresh sinks`,onClick:u},[B(A($c),{size:15,class:E({spin:i.value})},null,8,[`class`])],8,mT),z(`button`,{class:`icon-button`,disabled:!o.value||!t.value.length||n.value===`test`,"aria-label":`Send a test notification`,title:`Send a test event through every enabled sink`,onClick:h},[B(A(nl),{size:15})],8,hT),z(`button`,{class:`icon-button`,disabled:!o.value,"aria-label":`Add a sink`,title:`Add a sink`,onClick:s[0]||=e=>c.value=!c.value},[B(A(Xc),{size:15})],8,gT)]),s[14]||=z(`p`,{class:`hint`},`Delivered by the device — no browser needs to be open.`,-1),o.value?r.value?(I(),L(`p`,vT,D(r.value),1)):H(``,!0):(I(),L(`p`,_T,`Select a session to see its device.`)),c.value?(I(),L(`form`,{key:2,class:`add-form`,onSubmit:ks(f,[`prevent`])},[z(`label`,null,[s[8]||=V(`Kind `,-1),j(z(`select`,{"onUpdate:modelValue":s[1]||=e=>l.value.kind=e},[...s[7]||=[z(`option`,{value:`webhook`},`webhook (JSON POST)`,-1),z(`option`,{value:`ntfy`},`ntfy (topic)`,-1)]],512),[[Ss,l.value.kind]])]),z(`label`,null,[s[9]||=V(`URL `,-1),j(z(`input`,{"onUpdate:modelValue":s[2]||=e=>l.value.url=e,placeholder:l.value.kind===`ntfy`?`https://ntfy.sh/my-topic`:`https://example.com/hook`,required:``},null,8,yT),[[ys,l.value.url]])]),z(`label`,null,[s[10]||=V(`Label`,-1),j(z(`input`,{"onUpdate:modelValue":s[3]||=e=>l.value.label=e,placeholder:`phone`},null,512),[[ys,l.value.label]])]),z(`label`,null,[s[11]||=V(`Events `,-1),j(z(`input`,{"onUpdate:modelValue":s[4]||=e=>l.value.events=e,placeholder:`empty = all — e.g. session.failed,schedule.*`},null,512),[[ys,l.value.events]])]),z(`div`,bT,[z(`button`,{class:`primary small`,type:`submit`,disabled:n.value===`new`},D(n.value===`new`?`adding…`:`Add sink`),9,xT),z(`button`,{class:`small`,type:`button`,onClick:s[5]||=e=>c.value=!1},`Cancel`)]),s[12]||=z(`p`,{class:`hint`},[V(`LAN targets (192.168.x, localhost) need `),z(`code`,null,`DPI_NOTIFY_ALLOW_PRIVATE=1`),V(` on the device.`)],-1)],32)):H(``,!0),!c.value&&!t.value.length&&o.value&&!r.value?(I(),L(`p`,ST,` No sinks yet. Press + to add a webhook or an ntfy topic. `)):H(``,!0),t.value.length?(I(),L(`ul`,CT,[(I(!0),L(F,null,P(t.value,e=>(I(),L(`li`,{key:e.id,class:E([`sink`,{off:!e.enabled}])},[z(`div`,wT,[z(`span`,TT,D(e.kind),1),z(`b`,null,D(e.label||e.url),1),z(`em`,ET,D(e.lastError?`last failed`:`sent ${d(e.lastDeliveryAt)}`),1)]),z(`code`,DT,D(e.url),1),e.events?.length?(I(),L(`p`,OT,`events: `+D(e.events.join(`, `)),1)):H(``,!0),e.lastError?(I(),L(`p`,kT,D(e.lastError.slice(0,160)),1)):H(``,!0),z(`div`,AT,[z(`button`,{class:`small`,disabled:n.value===e.id,onClick:t=>p(e)},[B(A(Zc),{size:12}),V(D(e.enabled?`disable`:`enable`),1)],8,jT),z(`button`,{class:`small danger`,disabled:n.value===e.id,onClick:t=>m(e)},[B(A(dl),{size:12}),s[13]||=V(`remove`,-1)],8,MT)])],2))),128))])):H(``,!0),a.value.length?(I(),L(`ul`,NT,[(I(!0),L(F,null,P(a.value,e=>(I(),L(`li`,{key:e.id,class:E(e.status)},[z(`span`,PT,D(e.status),1),V(` `+D(e.kind)+` `+D(e.id.slice(0,8))+` `,1),e.detail?(I(),L(`em`,FT,D(e.detail),1)):H(``,!0)],2))),128))])):H(``,!0)]))}}),[[`__scopeId`,`data-v-4b0b0465`]]),LT={class:`env-panel`,"aria-label":`Device environment`},RT={class:`panel-heading`},zT=[`disabled`],BT=[`disabled`],VT={key:0,class:`hint`},HT={key:1,class:`message-error`},UT={key:2,class:`message-restart`},WT={class:`row`},GT=[`disabled`],KT={key:4,class:`hint`},qT={key:5,class:`var-list`},JT={class:`head`},YT={class:`key`},XT={class:`tag`},ZT={key:0,class:`tag`,title:`Has its own setting; edit that instead`},QT=[`aria-label`,`title`,`onClick`],$T=[`aria-label`,`onClick`],eE=[`title`],tE={key:6,class:`hint path`},nE=Id(N({__name:`EnvPanel`,setup(e){let t=k(null),n=k(!1),r=k(``),i=k(``),a=U(()=>K.value?.deviceId),o=()=>G(a.value??``),s=k(!1),c=k({key:``,value:``});async function l(){if(!a.value)return void(t.value=null);n.value=!0,r.value=``;try{t.value=await o().envView()}catch(e){let t=cu(e);r.value=e.code===`not_found`||/allowlist/i.test(t)?"This device runs an older build: update it (`dpi update`) to edit env vars.":t.slice(0,160)}finally{n.value=!1}}M(a,l,{immediate:!0});let u=e=>e.source===`file`&&!e.managed;async function d(){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(cu(e).slice(0,160))}finally{i.value=``}}}function f(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 p(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)=>(I(),L(`section`,LT,[z(`header`,RT,[z(`span`,null,[B(A(gc),{size:16}),o[4]||=V(`ENV`,-1)]),z(`button`,{class:`icon-button`,disabled:n.value||!a.value,"aria-label":`Refresh env`,title:`Refresh`,onClick:l},[B(A($c),{size:15,class:E({spin:n.value})},null,8,[`class`])],8,zT),z(`button`,{class:`icon-button`,disabled:!a.value||!!r.value,"aria-label":`Add an env var`,title:`Add an env var to the device's env file`,onClick:o[0]||=e=>s.value=!s.value},[B(A(Xc),{size:15})],8,BT)]),o[10]||=z(`p`,{class:`hint`},` The device's env file — loaded once at boot. Keys here reach the daemon and its sessions. `,-1),a.value?r.value?(I(),L(`p`,HT,D(r.value),1)):t.value?.restartRequired?(I(),L(`p`,UT,[...o[5]||=[V(` Changed since boot — restart the device (`,-1),z(`code`,null,`dpi device stop && dpi device start`,-1),V(`) to apply. `,-1)]])):H(``,!0):(I(),L(`p`,VT,`Select a session to see its device.`)),s.value?(I(),L(`form`,{key:3,class:`add-form`,onSubmit:ks(d,[`prevent`])},[z(`label`,null,[o[6]||=V(`Key (UPPER_SNAKE_CASE)`,-1),j(z(`input`,{"onUpdate:modelValue":o[1]||=e=>c.value.key=e,placeholder:`DPI_NOTIFY_ALLOW_PRIVATE`,required:``},null,512),[[ys,c.value.key]])]),z(`label`,null,[o[7]||=V(`Value`,-1),j(z(`input`,{"onUpdate:modelValue":o[2]||=e=>c.value.value=e,placeholder:`1`,required:``},null,512),[[ys,c.value.value]])]),z(`div`,WT,[z(`button`,{class:`primary small`,type:`submit`,disabled:i.value===`new`},D(i.value===`new`?`saving…`:`Save to env file`),9,GT),z(`button`,{class:`small`,type:`button`,onClick:o[3]||=e=>s.value=!1},`Cancel`)]),o[8]||=z(`p`,{class:`hint`},` Managed keys (DPI_TOKEN, DPI_PORT, start dirs…) have their own settings and are refused here. `,-1)],32)):H(``,!0),!s.value&&t.value&&!t.value.vars.length&&!r.value?(I(),L(`p`,KT,` No vars in the env file yet. `)):H(``,!0),t.value?.vars.length?(I(),L(`ul`,qT,[(I(!0),L(F,null,P(t.value.vars,e=>(I(),L(`li`,{key:e.key,class:E([`var`,{ro:!u(e)}])},[z(`div`,JT,[z(`code`,YT,D(e.key),1),z(`span`,XT,D(e.source===`process`?`process`:`file`),1),e.managed?(I(),L(`span`,ZT,`managed`)):H(``,!0),o[9]||=z(`span`,{class:`spacer`},null,-1),u(e)?(I(),L(`button`,{key:1,class:`icon-button`,"aria-label":`Edit ${e.key}`,title:e.secret?`Replace the value`:`Edit the value`,onClick:t=>f(e)},[B(A(qc),{size:13})],8,QT)):H(``,!0),u(e)?(I(),L(`button`,{key:2,class:`icon-button`,"aria-label":`Remove ${e.key}`,title:`Remove from the env file`,onClick:t=>p(e)},[B(A(dl),{size:13})],8,$T)):H(``,!0)]),z(`code`,{class:`value`,title:e.secret?`secret — masked`:e.masked},D(e.masked),9,eE)],2))),128))])):H(``,!0),t.value?(I(),L(`p`,tE,D(t.value.envFile),1)):H(``,!0)]))}}),[[`__scopeId`,`data-v-3c11d19f`]]),rE={class:`extensions-panel`},iE={class:`panel-heading`},aE={key:0,class:`task-empty`},oE=[`data-extension`],sE={class:`ext-head`},cE=[`aria-checked`,`aria-label`,`disabled`,`onClick`],lE=[`checked`,`disabled`,`onChange`],uE=N({__name:`ExtensionsPanel`,setup(e){let t=rn(),n=k(!1);async function r(){let e=Fu.value;if(!e||!ku.value)return void(t.value=void 0);t.value=await e.extensions().catch(()=>void 0)??t.value}M([Fu,ku,()=>JSON.stringify(Gu.value.agent.extensions??null)],r,{immediate:!0});async function i(e){let r=Fu.value;if(r&&!n.value){n.value=!0;try{let n=await ad(()=>r.setExtension(e));n&&(t.value=n),ed()}finally{n.value=!1}}}return(e,r)=>(I(),L(`div`,rE,[z(`div`,iE,[r[0]||=z(`h2`,null,`Extensions`,-1),B(A(Qc),{size:18})]),r[3]||=z(`p`,{class:`hint`},` Custom harness capabilities for this agent. Turn one on and the next request uses it. The choice is stored with the agent, so it survives restarts. `,-1),t.value?H(``,!0):(I(),L(`p`,aE,`Loading extensions…`)),(I(!0),L(F,null,P(t.value?.extensions??[],e=>(I(),L(`article`,{key:e.name,class:E([`ext-card`,{on:e.enabled}]),"data-extension":e.name},[z(`div`,sE,[z(`div`,null,[z(`strong`,null,D(e.title),1),z(`code`,null,D(e.name),1)]),z(`button`,{class:E([`switch`,{on:e.enabled}]),role:`switch`,"aria-checked":e.enabled,"aria-label":e.title,disabled:n.value,onClick:t=>i({name:e.name,enabled:!e.enabled})},[...r[1]||=[z(`span`,null,null,-1)]],10,cE)]),z(`p`,null,D(e.description),1),e.prompts?(I(),L(`ul`,{key:0,class:E([`ext-prompts`,{off:!e.enabled}])},[(I(!0),L(F,null,P(e.prompts,e=>(I(),L(`li`,{key:e.id},[z(`label`,null,[z(`input`,{type:`checkbox`,checked:e.enabled,disabled:n.value,onChange:t=>i({prompt:e.id,enabled:t.target.checked})},null,40,lE),z(`code`,null,D(e.id),1)]),z(`span`,null,D(e.description),1),z(`details`,null,[r[2]||=z(`summary`,null,`View prompt`,-1),z(`pre`,null,D(e.text),1)])]))),128))],2)):H(``,!0)],10,oE))),128))]))}}),dE={class:`context-section`,"aria-labelledby":`context-title`},fE={class:`section-label`},pE={key:0,class:`hint`},mE={class:`context-numbers`},hE={class:`context-pct`},gE={key:0,class:`context-compacting`},_E=[`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],vE={class:`context-marker-label`},yE=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`],bE={class:`context-marker-label`},xE={class:`hint context-hint`},SE={class:`modal compaction-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compaction-title`},CE={class:`context-toggle`},wE=[`checked`],TE=512,EE=4096,DE=1024,OE=N({__name:`ContextBar`,setup(e){let t=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),n=U(()=>Zu.value?.contextWindow??0),r=U(()=>{let e=Gu.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}),i=U(()=>Gu.value.compactions.length>0),a=k(),o=U(()=>a.value??Nu.value?.compaction??av(n.value));M(()=>JSON.stringify(Nu.value?.compaction),e=>{a.value&&e===JSON.stringify(a.value)&&(a.value=void 0)});let s=k(),c=U(()=>q.dialog?.kind===`compaction`),l=()=>void(q.dialog=void 0);Gr(()=>c.value&&l());let u=U(()=>s.value??ov(n.value,o.value)),d=e=>`${Math.min(100,Math.max(0,100*e/(n.value||1)))}%`,f=U(()=>Math.round(100*r.value/(n.value||1))),p=e=>{let t=e/(n.value||1);return t<.35?`start`:t>.65?`end`:`center`},m=(e,t)=>Math.min(n.value-DE,Math.max((t??EE)+DE,e)),h=(e,t)=>Math.min(t-DE,Math.max(EE,e));function g(e,t){let n=u.value,r=Math.round(t/TE)*TE;s.value=e===`wait`?{auto:n.auto,wait:m(r,n.auto)}:{auto:h(r,n.wait),wait:n.wait}}async function _(e){let t=Iu.value;if(!t)return;let n=await ad(()=>t.setCompaction(e));n&&(a.value=n),s.value=void 0}function v(){let e=s.value;e&&_({reserveTokens:n.value-e.wait,...e.auto===void 0?{}:{backgroundTokens:e.wait-e.auto}})}let y=k(),b;function x(e,t){b=e,t.currentTarget.setPointerCapture(t.pointerId)}function S(e){if(!b||!y.value)return;let t=y.value.getBoundingClientRect();g(b,(e.clientX-t.left)/t.width*n.value)}function C(){b&&(b=void 0,v())}function ee(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=u.value;g(e,(e===`auto`?r.auto??EE:r.wait)+n)}return(e,a)=>(I(),L(F,null,[z(`section`,dE,[z(`div`,fE,[a[7]||=z(`span`,{id:`context-title`},`CONTEXT`,-1),n.value?(I(),L(`button`,{key:0,class:`context-details-toggle`,onClick:a[0]||=e=>A(q).dialog={kind:`compaction`}},[B(A(Oc),{size:16}),a[6]||=V(`Details `,-1)])):H(``,!0)]),n.value?(I(),L(F,{key:1},[z(`div`,mE,[z(`strong`,null,D(t(r.value)),1),z(`span`,null,`of `+D(t(n.value))+` tokens`,1),z(`span`,hE,D(f.value)+`%`,1),i.value?(I(),L(`span`,gE,[...a[8]||=[z(`i`,null,null,-1),V(`Compacting`,-1)]])):H(``,!0)]),z(`div`,{ref_key:`bar`,ref:y,class:E([`context-bar`,{off:!o.value.enabled}]),onPointermove:S,onPointerup:C,onPointercancel:C},[z(`div`,{class:E([`context-fill`,{hot:u.value.auto!==void 0&&r.value>=u.value.auto}]),style:ge({width:d(r.value)})},null,6),z(`div`,{class:`context-reserve`,style:ge({left:d(u.value.wait)}),title:`Reserved for the answer`},null,4),u.value.auto===void 0?H(``,!0):(I(),L(`button`,{key:0,class:E([`context-marker auto`,`label-${p(u.value.auto)}`]),role:`slider`,"aria-label":`Automatic compaction starts at`,"aria-valuemin":EE,"aria-valuemax":u.value.wait-DE,"aria-valuenow":u.value.auto,"aria-valuetext":`${t(u.value.auto)} tokens`,style:ge({left:d(u.value.auto)}),onPointerdown:a[1]||=e=>x(`auto`,e),onKeydown:a[2]||=e=>ee(`auto`,e),onKeyup:v,onBlur:v},[z(`span`,vE,`Auto-compact at `+D(t(u.value.auto)),1)],46,_E)),z(`button`,{class:E([`context-marker wait`,`label-${p(u.value.wait)}`]),role:`slider`,"aria-label":`The next request waits for a summary at`,"aria-valuemin":(u.value.auto??EE)+DE,"aria-valuemax":n.value-DE,"aria-valuenow":u.value.wait,"aria-valuetext":`${t(u.value.wait)} tokens, ${t(n.value-u.value.wait)} reserved`,style:ge({left:d(u.value.wait)}),onPointerdown:a[3]||=e=>x(`wait`,e),onKeydown:a[4]||=e=>ee(`wait`,e),onKeyup:v,onBlur:v},[z(`span`,bE,`Reserve at `+D(t(u.value.wait)),1)],46,yE)],34),z(`p`,xE,[o.value.enabled?(I(),L(F,{key:0},[a[9]||=V(`Compacts in the background at `,-1),z(`strong`,null,D(t(u.value.auto??u.value.wait)),1),a[10]||=V(` and waits at `,-1),z(`strong`,null,D(t(u.value.wait)),1),a[11]||=V(`.`,-1)],64)):(I(),L(F,{key:1},[V(`Automatic compaction is off.`)],64))])],64)):(I(),L(`div`,pE,`Pick a model to see its context window.`))]),(I(),R(lr,{to:`body`},[c.value?(I(),L(`div`,{key:0,class:`modal-backdrop`,onClick:ks(l,[`self`])},[z(`section`,SE,[z(`header`,null,[a[12]||=z(`h2`,{id:`compaction-title`},`Context compaction`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close context compaction`,onClick:l},[B(A(vl),{size:18})])]),z(`p`,null,[a[13]||=V(` A summary starts in the background at `,-1),z(`strong`,null,D(t(u.value.auto??u.value.wait)),1),a[14]||=V(`. Above `,-1),z(`strong`,null,D(t(u.value.wait)),1),V(` the next request waits for it, keeping `+D(t(n.value-u.value.wait))+` free for the answer. Drag a marker on the bar to change either point. `,1)]),a[16]||=z(`p`,null,[V(`Older entries stay stored, and `),z(`code`,null,`search_history`),V(` still finds them.`)],-1),z(`label`,CE,[z(`input`,{type:`checkbox`,checked:o.value.enabled,onChange:a[5]||=e=>_({enabled:e.target.checked})},null,40,wE),a[15]||=V(` Automatic compaction `,-1)]),a[17]||=z(`p`,{class:`hint`},[V(` Applies to every agent in this session. `),z(`code`,null,`/compact`),V(` works either way. `)],-1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:l},`Close`)])])])):H(``,!0)]))],64))}}),kE=/^[A-Za-z_$][\w$]*$/,AE=e=>` `.repeat(e);function jE(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`),ME(t,0,r),r(`): `,`punct`),r(`Promise`,`type`),r(`<`,`punct`),r(`ToolResult`,`type`),r(`>;`,`punct`),n}function ME(e,t,n){if(!e||typeof e!=`object`)return n(`unknown`,`type`);if(`const`in e)return FE(e.const,n);if(e.enum)return PE(e.enum.map(e=>({const:e})),t,n);if(e.anyOf??e.oneOf)return PE(e.anyOf??e.oneOf,t,n);if(Array.isArray(e.type))return PE(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`),ME(e.items,t,n),r&&n(`)`,`punct`),n(`[]`,`punct`)}case`object`:return NE(e,t,n);default:return n(`unknown`,`type`)}}function NE(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`),ME(e.additionalProperties,t,n),n(`>`,`punct`)):n(`{}`,`punct`);let i=new Set(e.required??[]);n(`{`,`punct`),n(`
|
|
80
|
+
`);for(let[e,a]of r){let r=IE(a);r&&n(`${AE(t+1)}${r}\n`,`comment`),n(AE(t+1)),n(kE.test(e)?e:JSON.stringify(e),`property`),n(i.has(e)?`: `:`?: `,`punct`),ME(a,t+1,n),n(`;`,`punct`),n(`
|
|
81
|
+
`)}n(AE(t)),n(`}`,`punct`)}function PE(e,t,n){e.forEach((e,r)=>{r&&n(` | `,`punct`),ME(e,t,n)})}function FE(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 IE(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(` `)} */`:``}var LE={key:0,class:`panel-rail`,"aria-label":`Inspector (collapsed)`},RE=[`title`],zE=[`aria-label`,`title`,`onClick`],BE={key:0,class:`count`},VE={class:`inspector-tabs`,role:`tablist`,"aria-label":`Session details`},HE=[`id`,`aria-selected`,`onClick`],UE={key:0,class:`count`},WE=[`title`],GE=[`aria-labelledby`],KE={class:`session-heading`},qE=[`disabled`],JE=[`title`],YE={class:`cwd-trail`,dir:`rtl`},XE={dir:`ltr`},ZE={class:`session-status`},QE={key:0,class:`background-pill`},$E=[`title`],eD={class:`model-section`},tD=[`src`],nD={class:`thinking-row`},rD=[`value`],iD={class:`stats-section`,"aria-labelledby":`stats-title`},aD={class:`metrics`},oD=[`title`],sD={class:`usage-breakdown`,"aria-label":`Agent token and cost breakdown`},cD={scope:`row`},lD={class:`usage-total`},uD={class:`panel-heading`},dD={class:`hint app-state-description`},fD=[`disabled`],pD={class:`state-json-actions`},mD={key:0,class:`hint`},hD=[`disabled`],gD=[`disabled`],_D={key:0,class:`message-error`,role:`alert`},vD={class:`panel-heading`},yD={class:`tag`},bD={class:`hook-card`},xD=[`aria-checked`],SD={key:0,class:`tag tool-disabled`},CD={class:`tag`},wD=[`aria-label`],TD=Id(N({__name:`Inspector`,setup(e){let t=U(()=>new Map(Qu.value?.tools.map(e=>[e.name,jE(e.name,e.parameters)]))),n=[{id:`session`,label:`Session`,icon:yc},{id:`git`,label:`Git`,icon:xc},{id:`host`,label:`Host`,icon:Vs},{id:`usage`,label:`Usage`,icon:Jc},{id:`auto`,label:`Auto`,icon:ec},{id:`notify`,label:`Notify`,icon:Xs},{id:`env`,label:`Env`,icon:gc},{id:`state`,label:`State`,icon:Qs},{id:`tasks`,label:`Tasks`,icon:Vs},{id:`tools`,label:`Tools`,icon:_l},{id:`extensions`,label:`Extend`,icon:Qc}],r=U(()=>[{label:`Input`,tokens:Xu.value.input,cost:Xu.value.inputCost},{label:`Output`,tokens:Xu.value.output,cost:Xu.value.outputCost},{label:`Cache read`,tokens:Xu.value.cacheRead,cost:Xu.value.cacheReadCost},{label:`Cache write`,tokens:Xu.value.cacheWrite,cost:Xu.value.cacheWriteCost}]),i=U(()=>Ju.value.filter(e=>e.background).length),a=k(!1);function o(e,t){ad(async()=>{await Fu.value.configure(e),await ed(),t&&J(t)})}async function s(){let e=Ou.value,t=Nu.value;if(e&&t)try{let n=await G(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: ${cu(e).slice(0,120)}`)}}async function c(){let e=Ou.value,t=Nu.value;if(e&&t){a.value=!0;try{let n=await G(e.id).exportSession(t.id),r=Uint8Array.from(atob(n.base64),e=>e.charCodeAt(0)),i=URL.createObjectURL(new Blob([r],{type:n.mime||`application/zip`})),a=document.createElement(`a`);a.href=i,a.download=n.filename,a.click(),URL.revokeObjectURL(i),J(`Bundle downloaded (${Math.max(1,Math.round(n.bytes/1024))} KiB).`)}catch(e){J(`bundle export failed: ${cu(e).slice(0,120)}`)}finally{a.value=!1}}}function l(){let e=Iu.value;e&&(q.dialog={kind:`prompt`,title:`Rename session`,label:`Session name`,value:Nu.value?.name??``,submit:`Save name`,run:t=>e.rename(t)})}let u=Mu.sharedState,d=k(``),f=k(``),p=k(0),m=k(!1),h=k(``),g=U(()=>d.value!==f.value),_=U(()=>g.value&&u.value?.revision!==p.value);function v(){d.value=cd(u.value?.value??{}),f.value=d.value,p.value=u.value?.revision??0,h.value=``}M(u,()=>!g.value&&v(),{immediate:!0});async function y(e){if(!m.value&&Fu.value){m.value=!0,h.value=``;try{await Fu.value.demo(`state`,e)}catch(e){h.value=cu(e)}finally{m.value=!1}}}async function b(){if(!m.value&&Fu.value){h.value=``,m.value=!0;try{let e=JSON.parse(d.value);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`App State must be a JSON object.`);let t=await Fu.value.demo(`state`,{operation:`update`,path:``,value:e,expectedRevision:p.value});d.value=cd(t.value),f.value=d.value,p.value=t.revision,J(`Shared App State saved.`)}catch(e){h.value=cu(e)}finally{m.value=!1}}}let x=U(()=>Qu.value?.config.readOnly===!0),S=U(()=>Qu.value?.tools.filter(e=>e.offered).length??0);return(e,f)=>(I(),L(`aside`,{class:E([`inspector`,{collapsed:!A(hd),overlay:A(q).inspectorOverlay}])},[A(hd)?(I(),L(F,{key:1},[z(`div`,VE,[(I(),L(F,null,P(n,e=>z(`button`,{id:`inspector-tab-${e.id}`,key:e.id,role:`tab`,"aria-controls":`inspector-panel`,"aria-selected":A(q).tab===e.id,class:E({active:A(q).tab===e.id}),onClick:t=>A(q).tab=e.id},[(I(),R($r(e.icon),{size:18})),V(D(e.label),1),e.id===`tasks`&&A(Ju).length?(I(),L(`span`,UE,D(A(Ju).length),1)):H(``,!0)],10,HE)),64)),z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Collapse inspector`,title:`Collapse inspector (${A(xd).inspector})`,onClick:f[1]||=e=>A(_d)()},[B(A(Uc),{size:18})],8,WE)]),z(`div`,{id:`inspector-panel`,class:E([`inspector-body`,{"session-panel":A(q).tab===`session`}]),role:`tabpanel`,"aria-labelledby":`inspector-tab-${A(q).tab}`},[A(q).tab===`session`?(I(),L(F,{key:0},[z(`section`,KE,[z(`h1`,null,[z(`span`,null,D(A(Nu)?.name??`Loading session`),1),z(`button`,{class:`icon-button`,title:`Rename session`,"aria-label":`Rename session`,onClick:l},[B(A(qc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download transcript (markdown)`,"aria-label":`Download transcript`,onClick:s},[B(A(pc),{size:18})]),z(`button`,{class:`icon-button`,title:`Download session bundle (.zip: manifest, transcripts, configs)`,"aria-label":`Download session bundle`,disabled:a.value,onClick:c},[B(A(Hc),{size:18})],8,qE)]),z(`button`,{class:`path cwd-button`,title:A(Nu)?.cwd,"aria-label":`Show full working directory`,onClick:f[2]||=e=>A(q).dialog={kind:`path`,path:A(Nu)?.cwd??``}},[B(A(yc),{size:18}),z(`span`,YE,[z(`bdi`,XE,D(A(Nu)?.cwd),1)])],8,JE),z(`div`,ZE,[z(`span`,{class:E([`status-pill`,{working:A(Yu)}])},[f[7]||=z(`i`,null,null,-1),V(D(A(Yu)?`Working`:`Idle`),1)],2),i.value?(I(),L(`span`,QE,D(i.value)+` background`,1)):H(``,!0),z(`span`,{class:`saved`,title:A(Ou)?.id},[B(A(rl),{size:18}),V(D(A(Ou)?.name??A(Ou)?.id),1)],8,$E),A(Ou)?(I(),R(Ry,{key:1,device:A(Ou)},null,8,[`device`])):H(``,!0)])]),A(Ou)?(I(),R(tb,{key:0,device:A(Ou)},null,8,[`device`])):H(``,!0),z(`section`,eD,[f[15]||=z(`div`,{class:`section-label`},[z(`span`,null,`AGENT`)],-1),z(`button`,{class:`model-button`,onClick:f[3]||=e=>A(q).dialog={kind:`models`}},[z(`img`,{src:A(ld)(A(Gu).agent.model?.modelId),alt:``},null,8,tD),z(`div`,null,[z(`strong`,null,D(A(Zu)?.name??A(Gu).agent.model?.modelId??`Loading…`),1),z(`small`,null,D(A(Zu)?.tier??``)+` / `+D(A(Gu).agent.model?.provider??``),1)]),B(A(nc),{size:18})]),z(`div`,nD,[f[8]||=z(`span`,null,`Thinking`,-1),z(`select`,{"aria-label":`Thinking level`,value:A(Gu).agent.thinkingLevel??`low`,onChange:f[4]||=e=>o({thinkingLevel:e.target.value},`Thinking ${e.target.value}. Used on the next turn.`)},[(I(!0),L(F,null,P(A(nv),e=>(I(),L(`option`,{key:e},D(e),1))),128))],40,rD)]),B(OE),z(`section`,iD,[f[14]||=z(`div`,{class:`section-label`},[z(`span`,{id:`stats-title`},`STATS`)],-1),z(`div`,aD,[z(`div`,{title:`${A(Xu).tokens.toLocaleString(`en-US`)} total tokens`},[z(`span`,null,D(A(sd)(A(Xu).tokens)),1),f[9]||=z(`small`,null,`total tokens`,-1)],8,oD),z(`div`,null,[z(`span`,null,`$`+D(A(Xu).cost.toFixed(4)),1),f[10]||=z(`small`,null,`agent cost`,-1)]),z(`div`,null,[z(`span`,null,D(A(Qu)?.tools.length??0),1),f[11]||=z(`small`,null,`tools`,-1)])]),z(`table`,sD,[f[13]||=z(`thead`,null,[z(`tr`,null,[z(`th`,{scope:`col`},`Type`),z(`th`,{scope:`col`},`Tokens`),z(`th`,{scope:`col`},`Cost (USD)`)])],-1),z(`tbody`,null,[(I(!0),L(F,null,P(r.value,e=>(I(),L(`tr`,{key:e.label},[z(`th`,cD,D(e.label),1),z(`td`,null,D(e.tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(e.cost.toFixed(4)),1)]))),128)),z(`tr`,lD,[f[12]||=z(`th`,{scope:`row`},`Total`,-1),z(`td`,null,D(A(Xu).tokens.toLocaleString(`en-US`)),1),z(`td`,null,`$`+D(A(Xu).cost.toFixed(4)),1)])])])])])],64)):H(``,!0),A(q).tab===`state`?(I(),L(F,{key:1},[z(`div`,uD,[f[16]||=z(`h2`,null,`App State`,-1),B(A(Qs),{size:18})]),z(`p`,dD,` One shared JSON object for every agent, session and fork on `+D(A(Ou)?.name??A(Ou)?.id)+`. You and your agents can read, create, update or delete values and fields. Changes appear live and persist across closed browsers, interrupted agents and backend restarts. `,1),j(z(`textarea`,{"onUpdate:modelValue":f[5]||=e=>d.value=e,class:`app-state-json`,"aria-label":`App State JSON`,spellcheck:`false`,disabled:m.value||!A(u),rows:`12`},null,8,fD),[[ys,d.value]]),z(`div`,pD,[_.value?(I(),L(`span`,mD,`State changed elsewhere. Load the latest JSON before saving.`)):H(``,!0),g.value?(I(),L(`button`,{key:1,class:`secondary`,disabled:m.value,onClick:v},D(_.value?`Load latest`:`Reset`),9,hD)):H(``,!0),z(`button`,{class:`primary small`,disabled:!g.value||m.value||_.value,onClick:b},D(m.value?`Saving…`:`Save JSON`),9,gD)]),h.value?(I(),L(`p`,_D,D(h.value),1)):H(``,!0),B(My,{value:A(u)?.value??{},disabled:m.value||g.value||!A(u),onChange:y},null,8,[`value`,`disabled`])],64)):H(``,!0),A(q).tab===`tasks`?(I(),R(Mb,{key:2})):H(``,!0),A(q).tab===`git`?(I(),R(TC,{key:3})):H(``,!0),A(q).tab===`host`?(I(),R(JC,{key:4})):H(``,!0),A(q).tab===`usage`?(I(),R(Lw,{key:5})):H(``,!0),A(q).tab===`auto`?(I(),R(dT,{key:6})):H(``,!0),A(q).tab===`notify`?(I(),R(IT,{key:7})):H(``,!0),A(q).tab===`env`?(I(),R(nE,{key:8})):H(``,!0),A(q).tab===`extensions`?(I(),R(uE,{key:9})):H(``,!0),A(q).tab===`tools`?(I(),L(F,{key:10},[z(`div`,vD,[f[17]||=z(`h2`,null,`Tools`,-1),z(`span`,yD,D(S.value)+` / `+D(A(Qu)?.tools.length??0),1)]),f[21]||=z(`p`,{class:`hint`},` Every tool this agent's extensions provide. Open one to see its definition. `,-1),z(`div`,bD,[z(`div`,null,[B(A(al),{size:18}),f[19]||=z(`strong`,null,`Read only`,-1),z(`button`,{class:E([`switch`,{on:x.value}]),role:`switch`,"aria-checked":x.value,"aria-label":`Read only`,onClick:f[6]||=e=>o({readOnly:!x.value},x.value?`Read only off. Every tool is back.`:`Read only on. Tools that write are disabled.`)},[...f[18]||=[z(`span`,null,null,-1)]],10,xD)]),f[20]||=z(`p`,null,` Offers this agent only tools that read. Tools that create, update or delete leave its next request, and the choice is stored with the agent. `,-1)]),(I(!0),L(F,null,P(A(Qu)?.tools,e=>(I(),L(`details`,{key:e.name,class:E([`tool-row`,{disabled:!e.offered}])},[z(`summary`,null,[B(A(_l),{size:18}),z(`strong`,null,D(e.name),1),e.offered?H(``,!0):(I(),L(`span`,SD,`disabled`)),z(`span`,CD,D(e.replay===`safe`?`replay safe`:`interrupt on crash`),1)]),z(`p`,null,D(e.description),1),e.parameters?(I(),L(`pre`,{key:0,class:`tool-signature`,"aria-label":`${e.name} TypeScript definition`},[z(`code`,null,[(I(!0),L(F,null,P(t.value.get(e.name),(e,t)=>(I(),L(`span`,{key:t,class:E(`tk-${e.kind}`)},D(e.text),3))),128))])],8,wD)):H(``,!0),z(`small`,null,D(e.replay===`safe`?`An interrupted execution may run again after recovery.`:`A crash records an interrupted result instead of rerunning this effect.`),1)],2))),128))],64)):H(``,!0)],10,GE)],64)):(I(),L(`div`,LE,[z(`button`,{class:`icon-button panel-toggle`,"aria-label":`Expand inspector`,title:`Expand inspector (${A(xd).inspector})`,onClick:f[0]||=e=>A(gd)()},[B(A(Wc),{size:18})],8,RE),(I(),L(F,null,P(n,e=>z(`button`,{key:e.id,class:E([`rail-tab`,{active:A(q).tab===e.id}]),"aria-label":`Open ${e.label}`,title:e.label,onClick:t=>A(gd)(e.id)},[(I(),R($r(e.icon),{size:20})),e.id===`tasks`&&A(Ju).length?(I(),L(`span`,BE,D(A(Ju).length),1)):H(``,!0)],10,zE)),64))]))],2))}}),[[`__scopeId`,`data-v-815b91a5`]]),ED={class:`chat-empty`},DD={class:`eyebrow`},OD={key:3,class:`hint offline-error`},kD={key:4,class:`offline-command`},AD={key:5,class:`hint`},jD={key:6,class:`hint`},MD={class:`offline-actions`},ND=[`disabled`],PD={key:7,class:`message-error`,role:`alert`},FD=N({__name:`OfflinePanel`,props:{device:{}},setup(e){let t=e,n=k(!1),r=k(``),i=U(()=>{let e=t.device,n=e.source===`config`;switch(e.status){case`checking`:return{title:`Checking ${e.id}…`,text:`Probing the device. This view fills in as soon as it answers.`};case`unauthorized`:return e.transport===`tunnel`?{title:`${e.id} tunnel credentials are not valid`,text:`Pair the device again — the hub will mint a fresh credential.`}:{title:e.hasToken?`${e.id} rejected its token`:`No token for ${e.id}`,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.id} 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.id} speaks another API version`,text:`Update the device's dpi-backend.`,command:n?`just net deploy ${e.id}`:void 0};default:return{title:`${e.id} is offline`,text:`Last seen ${ud(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 su.check(t.device.id);e.status===`online`&&J(`${e.id} is online.`)}catch(e){r.value=cu(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)=>(I(),L(`section`,{class:E([`chat-panel offline-panel`,e.device.status]),"aria-live":`polite`},[z(`div`,ED,[e.device.status===`checking`?(I(),R(A(Ic),{key:0,class:`spin`,size:30})):e.device.status===`mismatch`||e.device.status===`unauthorized`?(I(),R(A(il),{key:1,size:30})):(I(),R(A(ml),{key:2,size:30})),z(`span`,DD,D(e.device.kind.toUpperCase())+` · `+D(e.device.url??(e.device.transport===`tunnel`?`tunnel`:`no endpoint`)),1),z(`h2`,null,D(i.value.title),1),z(`p`,null,D(i.value.text),1),e.device.error?(I(),L(`p`,OD,D(e.device.error),1)):H(``,!0),i.value.command?(I(),L(`div`,kD,[z(`code`,null,D(i.value.command),1),z(`button`,{class:`icon-button`,"aria-label":`Copy command`,onClick:s[0]||=e=>o(i.value.command)},[B(A(sc),{size:18})])])):H(``,!0),i.value.command?(I(),L(`p`,AD,`Run it in this repo's terminal, then press Check now.`)):H(``,!0),i.value.alt?(I(),L(`p`,jD,[s[2]||=V(` Never deployed or rebuilt? `,-1),z(`code`,null,D(i.value.alt),1),s[3]||=V(` provisions it from scratch. `,-1)])):H(``,!0),z(`div`,MD,[z(`button`,{class:`secondary`,disabled:n.value,onClick:s[1]||=e=>a()},[B(A($c),{size:18}),V(D(n.value?`Checking…`:`Check now`),1)],8,ND)]),r.value?(I(),L(`p`,PD,D(r.value),1)):H(``,!0)])],2))}}),ID={class:`dir-browser`},LD={class:`dir-path`},RD=[`disabled`],zD=[`aria-busy`],BD=[`title`],VD=[`aria-selected`,`title`,`onClick`],HD={key:1,class:`hint`},UD={key:0,class:`message-error`,role:`alert`},WD=N({__name:`DirBrowser`,props:si({deviceId:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Di(e,`modelValue`),r=k(),i=k(!1),a=k(``),o=0;async function s(e){let s=++o,c=t.deviceId;i.value=!0,a.value=``;try{let t=await G(c).dirs(e);return s===o?(r.value=t,t.path&&(n.value=t.path),t):void 0}catch(e){s===o&&(a.value=cu(e));return}finally{s===o&&(i.value=!1)}}return M(()=>t.deviceId,async()=>{r.value=void 0;let e=await s(``),t=e?.dirs[0];t&&!e.path&&await s(t.path)},{immediate:!0}),(e,t)=>(I(),L(`div`,ID,[z(`div`,LD,[j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,"aria-label":`Working directory`,required:``,placeholder:`/path/to/project`,spellcheck:`false`,autocomplete:`off`,onKeydown:t[1]||=js(ks(e=>s(n.value),[`prevent`]),[`enter`])},null,544),[[ys,n.value]]),z(`button`,{type:`button`,class:`secondary small`,disabled:i.value||!n.value,onClick:t[2]||=e=>s(n.value)},` Go `,8,RD)]),z(`div`,{class:`dir-list`,role:`listbox`,"aria-label":`Directories`,"aria-busy":i.value},[z(`button`,{type:`button`,class:`dir-item`,title:`Start directories`,onClick:t[3]||=e=>s(``)},[B(A(Dc),{size:16}),t[5]||=z(`span`,null,`Start dirs`,-1)]),r.value?.parent?(I(),L(`button`,{key:0,type:`button`,class:`dir-item`,title:r.value.parent,onClick:t[4]||=e=>s(r.value.parent)},[B(A(lc),{size:16}),t[6]||=z(`span`,null,`..`,-1)],8,BD)):H(``,!0),(I(!0),L(F,null,P(r.value?.dirs,e=>(I(),L(`button`,{key:e.path,type:`button`,class:`dir-item`,role:`option`,"aria-selected":e.path===n.value,title:e.path,onClick:t=>s(e.path)},[e.path===n.value?(I(),R(A(yc),{key:0,size:16})):(I(),R(A(bc),{key:1,size:16})),z(`span`,null,D(e.name),1)],8,VD))),128)),r.value&&!r.value.dirs.length?(I(),L(`p`,HD,`No subdirectories.`)):H(``,!0)],8,zD),a.value?(I(),L(`p`,UD,D(a.value),1)):H(``,!0)]))}}),GD={key:0,class:`message-error`},KD=[`value`],qD={class:`field`},JD={key:0,class:`recent-cwds`},YD=[`title`,`onClick`],XD={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`},ZD=[`value`],QD={key:2,class:`message-error`,role:`alert`},$D=[`disabled`],eO=`dpi-recent-cwds`,tO=Id(N({__name:`NewSessionDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>bu.devices.value.filter(e=>e.status===`online`)),a=k(i.value.find(e=>e.id===n.deviceId)?.id??i.value[0]?.id??``),o=U(()=>i.value.find(e=>e.id===a.value)),s=U(()=>{let e=o.value?.info?.models??[];if(e.length)return e;let t=o.value?.info;return t?.defaultModel&&t.provider?[{id:t.defaultModel,provider:t.provider,name:`${t.defaultModel} (device default)`,tier:`—`,icon:`lab.png`,contextWindow:0,reasoning:!1,cost:{input:0,output:0}}]:[]}),c=U(()=>!s.value.length||(o.value?.info?.models?.length??0)===0),l=U(()=>!!o.value?.info?.providerKeyMissing),u=e=>`${e.provider}/${e.id}`,d=k({name:``,cwd:``,model:``}),f=U(()=>{try{return JSON.parse(localStorage.getItem(eO)??`{}`)[a.value]??[]}catch{return[]}}),p=(e,t)=>{try{let n=JSON.parse(localStorage.getItem(eO)??`{}`),r=[t,...(n[e]??[]).filter(e=>e!==t)].slice(0,6);localStorage.setItem(eO,JSON.stringify({...n,[e]:r}))}catch{}},m=k(!1),h=k(``),g=k({});M(a,async e=>{if(g.value={},e)try{let{projects:t}=await G(e).projects(!0);g.value=Object.fromEntries(t.filter(e=>e.model).map(e=>[e.rootPath,e.model]))}catch{}},{immediate:!0}),M([()=>d.value.cwd,g],()=>{let e=d.value.cwd;if(!e)return;let t=Object.keys(g.value).filter(t=>e===t||e.startsWith(`${t}/`)).sort((e,t)=>t.length-e.length),n=t.length?g.value[t[0]]:void 0;n&&(d.value.model=`${n.provider}/${n.modelId}`)},{immediate:!0}),M(o,e=>{let t=s.value,n=t.find(t=>t.id===e?.info?.defaultModel)??t[0];d.value.model=n?u(n):``,d.value.cwd=``},{immediate:!0});async function _(){if(!m.value&&o.value){m.value=!0,h.value=``;try{let e=s.value.find(e=>u(e)===d.value.model)??s.value[0];if(!e)throw Error(`Choose a model`);let t=await G(o.value.id).createSession({name:d.value.name.trim()||`New session`,cwd:d.value.cwd.trim(),model:{provider:e.provider,modelId:e.id}});p(o.value.id,t.cwd);let n=t.agents.find(e=>e.kind===`root`)??t.agents[0];Lu({deviceId:o.value.id,sessionId:t.id,agentId:n?.id??1}),J(`Session created on ${o.value.id}.`),r(`close`)}catch(e){h.value=cu(e)}finally{m.value=!1}}}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[6]||=ks(e=>r(`close`),[`self`])},[z(`form`,{class:`modal session-modal`,onSubmit:ks(_,[`prevent`])},[z(`header`,null,[t[7]||=z(`div`,null,[z(`span`,{class:`eyebrow`},`A PERSISTENT WORKSPACE`),z(`h2`,null,`New session`)],-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close new session`,onClick:t[0]||=e=>r(`close`)},[B(A(vl),{size:18})])]),i.value.length?(I(),L(F,{key:1},[z(`label`,null,[t[8]||=V(`Device`,-1),j(z(`select`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,"aria-label":`Device`},[(I(!0),L(F,null,P(i.value,e=>(I(),L(`option`,{key:e.id,value:e.id},D(e.name)+D(e.info?.hostname&&e.info.hostname!==e.name?` · ${e.info.hostname}`:``),9,KD))),128))],512),[[Ss,a.value]])]),z(`label`,null,[t[9]||=V(`Session name`,-1),j(z(`input`,{"onUpdate:modelValue":t[2]||=e=>d.value.name=e,autofocus:``,placeholder:`My durable agent`,maxlength:`100`},null,512),[[ys,d.value.name]])]),z(`div`,qD,[z(`span`,null,`Working directory on `+D(i.value.find(e=>e.id===a.value)?.name??a.value),1),f.value.length?(I(),L(`div`,JD,[(I(!0),L(F,null,P(f.value,e=>(I(),L(`button`,{key:e,type:`button`,class:E([`chip`,{on:e===d.value.cwd}]),title:e,onClick:t=>d.value.cwd=e},D(e.split(`/`).filter(Boolean).at(-1)||e),11,YD))),128))])):H(``,!0),B(WD,{modelValue:d.value.cwd,"onUpdate:modelValue":t[3]||=e=>d.value.cwd=e,"device-id":a.value},null,8,[`modelValue`,`device-id`])]),z(`label`,null,[t[10]||=V(`Model`,-1),c.value||l.value?(I(),L(`span`,XD,`no API key on device — chat needs one`)):H(``,!0),j(z(`select`,{"onUpdate:modelValue":t[4]||=e=>d.value.model=e,"aria-label":`New session model`},[(I(!0),L(F,null,P(s.value,e=>(I(),L(`option`,{key:u(e),value:u(e)},D(e.tier)+` / `+D(e.name),9,ZD))),128))],512),[[Ss,d.value.model]])])],64)):(I(),L(`p`,GD,` No device is online. Start one with just backend run or just net up <id>, then try again. `)),h.value?(I(),L(`p`,QD,D(h.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,onClick:t[5]||=e=>r(`close`)},`Cancel`),z(`button`,{class:`primary`,disabled:m.value||!d.value.model||!d.value.cwd||!o.value},[B(A(Xc),{size:18}),V(D(m.value?`Creating…`:`Create session`),1)],8,$D)])],32)]))}}),[[`__scopeId`,`data-v-78a7a326`]]),nO=new Uint8Array(512),rO=new Uint8Array(256);(()=>{let e=1;for(let t=0;t<255;t++)nO[t]=e,rO[e]=t,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)nO[e]=nO[e-255]})();var iO=(e,t)=>e===0||t===0?0:nO[rO[e]+rO[t]];function aO(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]^=iO(t[r],nO[n]);t=e}return t}function oO(e,t){let n=aO(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]^=iO(n[i+1],e)}return r}var sO=[21,25,29,33,37,41,45,49,53,57,61,65],cO=[19,34,55,80,108,136,156,194,232,274,324,370],lO=[7,10,15,20,26,36,40,48,60,72,80,96],uO=[7,10,15,20,26,18,20,24,30,18,20,24],dO=[[[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]]],fO=[[],[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]],pO=e=>e<=9?8:16;function mO(e){for(let t=1;t<=sO.length;t++)if(4+pO(t)+e*8<=cO[t-1]*8)return t;throw Error(`qr: payload too long (${e} bytes; v12L max ${cO[11]-3})`)}function hO(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,pO(t));for(let e of n)i(e,8);let a=cO[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 gO(e,t){let n=uO[e-1],r=[],i=0;for(let[n,a]of dO[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=>oO(e,n));for(let e=0;e<n;e++)for(let t of s)a.push(t[e]);return a}function _O(e){return Array.from({length:e},()=>Array(e).fill(!1))}function vO(e,t){let n=sO[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=fO[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 yO(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 bO(e,t){let n=sO[0]*0+e.length,r=yO(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 xO(e,t,n,r){let i=e.length;sO[n-1]*sO[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(CO(l,i,n))continue;if(o>=(cO[n-1]+lO[n-1])*8){o++;continue}let t=a(o++);SO(l,i,r)&&(t=!t),e[l][i]=t}}s=!s}}function SO(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 CO(e,t,n){let r=sO[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=fO[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 wO(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 TO(e,t){let n=mO(new TextEncoder().encode(e).length),r=sO[n-1],i=gO(n,hO(e,n)),a=_O(r);return vO(a,n),xO(a,i,n,t),bO(a,t),a}function EO(e,t){if(t!==void 0)return TO(e,t);let n;for(let t=0;t<8;t++){let r=TO(e,t),i=wO(r);(!n||i<n.score)&&(n={m:r,score:i})}return n.m}function DO(e,t=160){let n=EO(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 OO={class:`device-handoff`,"aria-label":`Pair this machine`},kO={class:`row`},AO=[`disabled`],jO=[`disabled`],MO={key:0,class:`target`,"data-testid":`device-url`},NO={key:1,class:`err`},PO=Id(N({__name:`DeviceHandoff`,props:{offerFragment:{}},setup(e){let t=e,n=k(`4780`),r=k(!1),i=U(()=>{let e=/^\d{1,5}$/.test(n.value)?Number(n.value):0;if(!(!e||e<1||e>65535))return`http://127.0.0.1:${e}/pair#${t.offerFragment}`});function a(){let e=i.value;e&&window.open(e,`_blank`,`noopener`)}async function o(){let e=i.value;if(e)try{await navigator.clipboard.writeText(e),r.value=!0,setTimeout(()=>r.value=!1,1600)}catch{}}return(e,t)=>(I(),L(`section`,OO,[z(`header`,null,[B(A(zc),{size:18}),t[1]||=z(`h3`,null,`Pair THIS machine`,-1)]),t[4]||=z(`p`,{class:`what`},[V(` If this browser runs on the device itself, open its local pairing page — the offer is relayed inside the link, nothing is sent to the hub. Start `),z(`code`,null,`dpi device`),V(` there first. `)],-1),z(`div`,kO,[z(`label`,null,[t[2]||=V(` local port `,-1),j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>n.value=e,inputmode:`numeric`,spellcheck:`false`,"aria-label":`Local dpi backend port`},null,512),[[ys,n.value]])]),z(`button`,{class:`primary`,type:`button`,disabled:!i.value,onClick:a},[B(A(mc),{size:15}),t[3]||=V(`Open the device page `,-1)],8,AO),z(`button`,{class:`secondary`,type:`button`,disabled:!i.value,onClick:o},[B(A(sc),{size:15}),V(D(r.value?`Copied`:`Copy link`),1)],8,jO)]),i.value?(I(),L(`p`,MO,D(i.value),1)):H(``,!0),i.value?H(``,!0):(I(),L(`p`,NO,`port must be 1–65535`))]))}}),[[`__scopeId`,`data-v-01884b7b`]]);function FO(e){return WO(e)&&!IO(e)&&!JO(e)&&Symbol.asyncIterator in e}function IO(e){return Array.isArray(e)}function LO(e){return typeof e==`bigint`}function RO(e){return typeof e==`boolean`}function zO(e){return e instanceof globalThis.Date}function BO(e){return typeof e==`function`}function VO(e){return WO(e)&&!IO(e)&&!JO(e)&&Symbol.iterator in e}function HO(e){return e===null}function UO(e){return typeof e==`number`}function WO(e){return typeof e==`object`&&!!e}function GO(e){return e instanceof globalThis.RegExp}function KO(e){return typeof e==`string`}function qO(e){return typeof e==`symbol`}function JO(e){return e instanceof globalThis.Uint8Array}function YO(e){return e===void 0}function XO(e){return e.map(e=>tk(e))}function ZO(e){return new Date(e.getTime())}function QO(e){return new Uint8Array(e)}function $O(e){return new RegExp(e.source,e.flags)}function ek(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=tk(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=tk(e[n]);return t}function tk(e){return IO(e)?XO(e):zO(e)?ZO(e):JO(e)?QO(e):GO(e)?$O(e):WO(e)?ek(e):e}function nk(e){return tk(e)}function rk(e,t){return nk(t===void 0?e:{...t,...e})}function ik(e){return typeof e==`object`&&!!e}function ak(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function ok(e){return e===void 0}function sk(e){return typeof e==`number`}var ck;(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=ik(t);return e.AllowArrayObject?n:n&&!ak(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?sk(t):Number.isFinite(t)}e.IsNumberLike=i;function a(t){let n=ok(t);return e.AllowNullVoid?n||t===null:n}e.IsVoidLike=a})(ck||={});function lk(e){return globalThis.Object.freeze(e).map(e=>mk(e))}function uk(e){return e}function dk(e){return e}function fk(e){return e}function pk(e){let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=mk(e[n]);for(let n of Object.getOwnPropertySymbols(e))t[n]=mk(e[n]);return globalThis.Object.freeze(t)}function mk(e){return IO(e)?lk(e):zO(e)?uk(e):JO(e)?dk(e):GO(e)?fk(e):WO(e)?pk(e):e}function Y(e,t){let n=t===void 0?e:{...t,...e};switch(ck.InstanceMode){case`freeze`:return mk(n);case`clone`:return nk(n);default:return n}}var hk=class extends Error{constructor(e){super(e)}},gk=Symbol.for(`TypeBox.Transform`),_k=Symbol.for(`TypeBox.Readonly`),vk=Symbol.for(`TypeBox.Optional`),yk=Symbol.for(`TypeBox.Hint`),X=Symbol.for(`TypeBox.Kind`);function bk(e){return WO(e)&&e[_k]===`Readonly`}function xk(e){return WO(e)&&e[vk]===`Optional`}function Sk(e){return Z(e,`Any`)}function Ck(e){return Z(e,`Argument`)}function wk(e){return Z(e,`Array`)}function Tk(e){return Z(e,`AsyncIterator`)}function Ek(e){return Z(e,`BigInt`)}function Dk(e){return Z(e,`Boolean`)}function Ok(e){return Z(e,`Computed`)}function kk(e){return Z(e,`Constructor`)}function Ak(e){return Z(e,`Date`)}function jk(e){return Z(e,`Function`)}function Mk(e){return Z(e,`Integer`)}function Nk(e){return Z(e,`Intersect`)}function Pk(e){return Z(e,`Iterator`)}function Z(e,t){return WO(e)&&X in e&&e[X]===t}function Fk(e){return RO(e)||UO(e)||KO(e)}function Ik(e){return Z(e,`Literal`)}function Lk(e){return Z(e,`MappedKey`)}function Rk(e){return Z(e,`MappedResult`)}function zk(e){return Z(e,`Never`)}function Bk(e){return Z(e,`Not`)}function Vk(e){return Z(e,`Null`)}function Hk(e){return Z(e,`Number`)}function Uk(e){return Z(e,`Object`)}function Wk(e){return Z(e,`Promise`)}function Gk(e){return Z(e,`Record`)}function Kk(e){return Z(e,`Ref`)}function qk(e){return Z(e,`RegExp`)}function Jk(e){return Z(e,`String`)}function Yk(e){return Z(e,`Symbol`)}function Xk(e){return Z(e,`TemplateLiteral`)}function Zk(e){return Z(e,`This`)}function Qk(e){return WO(e)&&gk in e}function $k(e){return Z(e,`Tuple`)}function eA(e){return Z(e,`Undefined`)}function tA(e){return Z(e,`Union`)}function nA(e){return Z(e,`Uint8Array`)}function rA(e){return Z(e,`Unknown`)}function iA(e){return Z(e,`Unsafe`)}function aA(e){return Z(e,`Void`)}function oA(e){return WO(e)&&X in e&&KO(e[X])}function sA(e){return Sk(e)||Ck(e)||wk(e)||Dk(e)||Ek(e)||Tk(e)||Ok(e)||kk(e)||Ak(e)||jk(e)||Mk(e)||Nk(e)||Pk(e)||Ik(e)||Lk(e)||Rk(e)||zk(e)||Bk(e)||Vk(e)||Hk(e)||Uk(e)||Wk(e)||Gk(e)||Kk(e)||qk(e)||Jk(e)||Yk(e)||Xk(e)||Zk(e)||$k(e)||eA(e)||tA(e)||nA(e)||rA(e)||iA(e)||aA(e)||oA(e)}var cA=`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 lA(e){try{return new RegExp(e),!0}catch{return!1}}function uA(e){if(!KO(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 dA(e){return mA(e)||uj(e)}function fA(e){return YO(e)||LO(e)}function pA(e){return YO(e)||UO(e)}function mA(e){return YO(e)||RO(e)}function hA(e){return YO(e)||KO(e)}function gA(e){return YO(e)||KO(e)&&uA(e)&&lA(e)}function _A(e){return YO(e)||KO(e)&&uA(e)}function vA(e){return YO(e)||uj(e)}function yA(e){return WO(e)&&e[vk]===`Optional`}function bA(e){return PA(e,`Any`)&&hA(e.$id)}function xA(e){return PA(e,`Argument`)&&UO(e.index)}function SA(e){return PA(e,`Array`)&&e.type===`array`&&hA(e.$id)&&uj(e.items)&&pA(e.minItems)&&pA(e.maxItems)&&mA(e.uniqueItems)&&vA(e.contains)&&pA(e.minContains)&&pA(e.maxContains)}function CA(e){return PA(e,`AsyncIterator`)&&e.type===`AsyncIterator`&&hA(e.$id)&&uj(e.items)}function wA(e){return PA(e,`BigInt`)&&e.type===`bigint`&&hA(e.$id)&&fA(e.exclusiveMaximum)&&fA(e.exclusiveMinimum)&&fA(e.maximum)&&fA(e.minimum)&&fA(e.multipleOf)}function TA(e){return PA(e,`Boolean`)&&e.type===`boolean`&&hA(e.$id)}function EA(e){return PA(e,`Computed`)&&KO(e.target)&&IO(e.parameters)&&e.parameters.every(e=>uj(e))}function DA(e){return PA(e,`Constructor`)&&e.type===`Constructor`&&hA(e.$id)&&IO(e.parameters)&&e.parameters.every(e=>uj(e))&&uj(e.returns)}function OA(e){return PA(e,`Date`)&&e.type===`Date`&&hA(e.$id)&&pA(e.exclusiveMaximumTimestamp)&&pA(e.exclusiveMinimumTimestamp)&&pA(e.maximumTimestamp)&&pA(e.minimumTimestamp)&&pA(e.multipleOfTimestamp)}function kA(e){return PA(e,`Function`)&&e.type===`Function`&&hA(e.$id)&&IO(e.parameters)&&e.parameters.every(e=>uj(e))&&uj(e.returns)}function AA(e){return PA(e,`Integer`)&&e.type===`integer`&&hA(e.$id)&&pA(e.exclusiveMaximum)&&pA(e.exclusiveMinimum)&&pA(e.maximum)&&pA(e.minimum)&&pA(e.multipleOf)}function jA(e){return WO(e)&&Object.entries(e).every(([e,t])=>uA(e)&&uj(t))}function MA(e){return PA(e,`Intersect`)&&!(KO(e.type)&&e.type!==`object`)&&IO(e.allOf)&&e.allOf.every(e=>uj(e)&&!tj(e))&&hA(e.type)&&(mA(e.unevaluatedProperties)||vA(e.unevaluatedProperties))&&hA(e.$id)}function NA(e){return PA(e,`Iterator`)&&e.type===`Iterator`&&hA(e.$id)&&uj(e.items)}function PA(e,t){return WO(e)&&X in e&&e[X]===t}function FA(e){return RA(e)&&KO(e.const)}function IA(e){return RA(e)&&UO(e.const)}function LA(e){return RA(e)&&RO(e.const)}function RA(e){return PA(e,`Literal`)&&hA(e.$id)&&zA(e.const)}function zA(e){return RO(e)||UO(e)||KO(e)}function BA(e){return PA(e,`MappedKey`)&&IO(e.keys)&&e.keys.every(e=>UO(e)||KO(e))}function VA(e){return PA(e,`MappedResult`)&&jA(e.properties)}function HA(e){return PA(e,`Never`)&&WO(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function UA(e){return PA(e,`Not`)&&uj(e.not)}function WA(e){return PA(e,`Null`)&&e.type===`null`&&hA(e.$id)}function GA(e){return PA(e,`Number`)&&e.type===`number`&&hA(e.$id)&&pA(e.exclusiveMaximum)&&pA(e.exclusiveMinimum)&&pA(e.maximum)&&pA(e.minimum)&&pA(e.multipleOf)}function KA(e){return PA(e,`Object`)&&e.type===`object`&&hA(e.$id)&&jA(e.properties)&&dA(e.additionalProperties)&&pA(e.minProperties)&&pA(e.maxProperties)}function qA(e){return PA(e,`Promise`)&&e.type===`Promise`&&hA(e.$id)&&uj(e.item)}function JA(e){return PA(e,`Record`)&&e.type===`object`&&hA(e.$id)&&dA(e.additionalProperties)&&WO(e.patternProperties)&&(e=>{let t=Object.getOwnPropertyNames(e.patternProperties);return t.length===1&&lA(t[0])&&WO(e.patternProperties)&&uj(e.patternProperties[t[0]])})(e)}function YA(e){return PA(e,`Ref`)&&hA(e.$id)&&KO(e.$ref)}function XA(e){return PA(e,`RegExp`)&&hA(e.$id)&&KO(e.source)&&KO(e.flags)&&pA(e.maxLength)&&pA(e.minLength)}function ZA(e){return PA(e,`String`)&&e.type===`string`&&hA(e.$id)&&pA(e.minLength)&&pA(e.maxLength)&&gA(e.pattern)&&_A(e.format)}function QA(e){return PA(e,`Symbol`)&&e.type===`symbol`&&hA(e.$id)}function $A(e){return PA(e,`TemplateLiteral`)&&e.type===`string`&&KO(e.pattern)&&e.pattern[0]===`^`&&e.pattern[e.pattern.length-1]===`$`}function ej(e){return PA(e,`This`)&&hA(e.$id)&&KO(e.$ref)}function tj(e){return WO(e)&&gk in e}function nj(e){return PA(e,`Tuple`)&&e.type===`array`&&hA(e.$id)&&UO(e.minItems)&&UO(e.maxItems)&&e.minItems===e.maxItems&&(YO(e.items)&&YO(e.additionalItems)&&e.minItems===0||IO(e.items)&&e.items.every(e=>uj(e)))}function rj(e){return PA(e,`Undefined`)&&e.type===`undefined`&&hA(e.$id)}function ij(e){return PA(e,`Union`)&&hA(e.$id)&&WO(e)&&IO(e.anyOf)&&e.anyOf.every(e=>uj(e))}function aj(e){return PA(e,`Uint8Array`)&&e.type===`Uint8Array`&&hA(e.$id)&&pA(e.minByteLength)&&pA(e.maxByteLength)}function oj(e){return PA(e,`Unknown`)&&hA(e.$id)}function sj(e){return PA(e,`Unsafe`)}function cj(e){return PA(e,`Void`)&&e.type===`void`&&hA(e.$id)}function lj(e){return WO(e)&&X in e&&KO(e[X])&&!cA.includes(e[X])}function uj(e){return WO(e)&&(bA(e)||xA(e)||SA(e)||TA(e)||wA(e)||CA(e)||EA(e)||DA(e)||OA(e)||kA(e)||AA(e)||MA(e)||NA(e)||RA(e)||BA(e)||VA(e)||HA(e)||UA(e)||WA(e)||GA(e)||KA(e)||qA(e)||JA(e)||YA(e)||XA(e)||ZA(e)||QA(e)||$A(e)||ej(e)||nj(e)||rj(e)||ij(e)||aj(e)||oj(e)||sj(e)||cj(e)||lj(e))}var dj=`(true|false)`,fj=`(0|[1-9][0-9]*)`,pj=`(.*)`,mj=`(?!.*)`;`${dj}`;var hj=`^${fj}$`,gj=`^${pj}$`,_j=`^${mj}$`;function vj(e,t){return e.includes(t)}function yj(e){return[...new Set(e)]}function bj(e,t){return e.filter(e=>t.includes(e))}function xj(e,t){return e.reduce((e,t)=>bj(e,t),t)}function Sj(e){return e.length===1?e[0]:e.length>1?xj(e.slice(1),e[0]):[]}function Cj(e){let t=[];for(let n of e)t.push(...n);return t}function wj(e){return Y({[X]:`Any`},e)}function Tj(e,t){return Y({[X]:`Array`,type:`array`,items:e},t)}function Ej(e){return Y({[X]:`Argument`,index:e})}function Dj(e,t){return Y({[X]:`AsyncIterator`,type:`AsyncIterator`,items:e},t)}function Oj(e,t,n){return Y({[X]:`Computed`,target:e,parameters:t},n)}function kj(e,t){let{[t]:n,...r}=e;return r}function Aj(e,t){return t.reduce((e,t)=>kj(e,t),e)}function jj(e){return Y({[X]:`Never`,not:{}},e)}function Mj(e){return Y({[X]:`MappedResult`,properties:e})}function Nj(e,t,n){return Y({[X]:`Constructor`,type:`Constructor`,parameters:e,returns:t},n)}function Pj(e,t,n){return Y({[X]:`Function`,type:`Function`,parameters:e,returns:t},n)}function Fj(e,t){return Y({[X]:`Union`,anyOf:e},t)}function Ij(e){return e.some(e=>xk(e))}function Lj(e){return e.map(e=>xk(e)?Rj(e):e)}function Rj(e){return Aj(e,[vk])}function zj(e,t){return Ij(e)?TN(Fj(Lj(e),t)):Fj(Lj(e),t)}function Bj(e,t){return e.length===1?Y(e[0],t):e.length===0?jj(t):zj(e,t)}function Vj(e,t){return e.length===0?jj(t):e.length===1?Y(e[0],t):Fj(e,t)}var Hj=class extends hk{};function Uj(e){return e.replace(/\\\$/g,`$`).replace(/\\\*/g,`*`).replace(/\\\^/g,`^`).replace(/\\\|/g,`|`).replace(/\\\(/g,`(`).replace(/\\\)/g,`)`)}function Wj(e,t,n){return e[t]===n&&e.charCodeAt(t-1)!==92}function Gj(e,t){return Wj(e,t,`(`)}function Kj(e,t){return Wj(e,t,`)`)}function qj(e,t){return Wj(e,t,`|`)}function Jj(e){if(!(Gj(e,0)&&Kj(e,e.length-1)))return!1;let t=0;for(let n=0;n<e.length;n++)if(Gj(e,n)&&(t+=1),Kj(e,n)&&--t,t===0&&n!==e.length-1)return!1;return!0}function Yj(e){return e.slice(1,e.length-1)}function Xj(e){let t=0;for(let n=0;n<e.length;n++)if(Gj(e,n)&&(t+=1),Kj(e,n)&&--t,qj(e,n)&&t===0)return!0;return!1}function Zj(e){for(let t=0;t<e.length;t++)if(Gj(e,t))return!0;return!1}function Qj(e){let[t,n]=[0,0],r=[];for(let i=0;i<e.length;i++)if(Gj(e,i)&&(t+=1),Kj(e,i)&&--t,qj(e,i)&&t===0){let t=e.slice(n,i);t.length>0&&r.push(eM(t)),n=i+1}let i=e.slice(n);return i.length>0&&r.push(eM(i)),r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`or`,expr:r}}function $j(e){function t(e,t){if(!Gj(e,t))throw new Hj(`TemplateLiteralParser: Index must point to open parens`);let n=0;for(let r=t;r<e.length;r++)if(Gj(e,r)&&(n+=1),Kj(e,r)&&--n,n===0)return[t,r];throw new Hj(`TemplateLiteralParser: Unclosed group parens in expression`)}function n(e,t){for(let n=t;n<e.length;n++)if(Gj(e,n))return[t,n];return[t,e.length]}let r=[];for(let i=0;i<e.length;i++)if(Gj(e,i)){let[n,a]=t(e,i),o=e.slice(n,a+1);r.push(eM(o)),i=a}else{let[t,a]=n(e,i),o=e.slice(t,a);o.length>0&&r.push(eM(o)),i=a-1}return r.length===0?{type:`const`,const:``}:r.length===1?r[0]:{type:`and`,expr:r}}function eM(e){return Jj(e)?eM(Yj(e)):Xj(e)?Qj(e):Zj(e)?$j(e):{type:`const`,const:Uj(e)}}function tM(e){return eM(e.slice(1,e.length-1))}var nM=class extends hk{};function rM(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 iM(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 aM(e){return e.type===`const`&&e.const===`.*`}function oM(e){return rM(e)||aM(e)?!1:iM(e)?!0:e.type===`and`||e.type===`or`?e.expr.every(e=>oM(e)):e.type===`const`||(()=>{throw new nM(`Unknown expression type`)})()}function sM(e){return oM(tM(e.pattern))}var cM=class extends hk{};function*lM(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let n of lM(e.slice(1)))yield`${t}${n}`}function*uM(e){return yield*lM(e.expr.map(e=>[...pM(e)]))}function*dM(e){for(let t of e.expr)yield*pM(t)}function*fM(e){return yield e.const}function*pM(e){return e.type===`and`?yield*uM(e):e.type===`or`?yield*dM(e):e.type===`const`?yield*fM(e):(()=>{throw new cM(`Unknown expression`)})()}function mM(e){let t=tM(e.pattern);return oM(t)?[...pM(t)]:[]}function hM(e,t){return Y({[X]:`Literal`,const:e,type:typeof e},t)}function gM(e){return Y({[X]:`Boolean`,type:`boolean`},e)}function _M(e){return Y({[X]:`BigInt`,type:`bigint`},e)}function vM(e){return Y({[X]:`Number`,type:`number`},e)}function yM(e){return Y({[X]:`String`,type:`string`},e)}function*bM(e){let t=e.trim().replace(/"|'/g,``);return t===`boolean`?yield gM():t===`number`?yield vM():t===`bigint`?yield _M():t===`string`?yield yM():yield(()=>{let e=t.split(`|`).map(e=>hM(e.trim()));return e.length===0?jj():e.length===1?e[0]:Bj(e)})()}function*xM(e){if(e[1]!==`{`)return yield*[hM(`$`),...SM(e.slice(1))];for(let t=2;t<e.length;t++)if(e[t]===`}`){let n=bM(e.slice(2,t)),r=SM(e.slice(t+1));return yield*[...n,...r]}yield hM(e)}function*SM(e){for(let t=0;t<e.length;t++)if(e[t]===`$`)return yield*[hM(e.slice(0,t)),...xM(e.slice(t))];yield hM(e)}function CM(e){return[...SM(e)]}var wM=class extends hk{};function TM(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function EM(e,t){return Xk(e)?e.pattern.slice(1,e.pattern.length-1):tA(e)?`(${e.anyOf.map(e=>EM(e,t)).join(`|`)})`:Hk(e)||Mk(e)||Ek(e)?`${t}${fj}`:Jk(e)?`${t}${pj}`:Ik(e)?`${t}${TM(e.const.toString())}`:Dk(e)?`${t}${dj}`:(()=>{throw new wM(`Unexpected Kind '${e[X]}'`)})()}function DM(e){return`^${e.map(e=>EM(e,``)).join(``)}$`}function OM(e){return Bj(mM(e).map(e=>hM(e)))}function kM(e,t){let n=KO(e)?DM(CM(e)):DM(e);return Y({[X]:`TemplateLiteral`,type:`string`,pattern:n},t)}function AM(e){return mM(e).map(e=>e.toString())}function jM(e){let t=[];for(let n of e)t.push(...NM(n));return t}function MM(e){return[e.toString()]}function NM(e){return[...new Set(Xk(e)?AM(e):tA(e)?jM(e.anyOf):Ik(e)?MM(e.const):Hk(e)||Mk(e)?[`[number]`]:[])]}function PM(e,t,n){let r={};for(let i of Object.getOwnPropertyNames(t))r[i]=JM(e,NM(t[i]),n);return r}function FM(e,t,n){return PM(e,t.properties,n)}function IM(e,t,n){return Mj(FM(e,t,n))}function LM(e,t){return e.map(e=>GM(e,t))}function RM(e){return e.filter(e=>!zk(e))}function zM(e,t){return PN(RM(LM(e,t)))}function BM(e){return e.some(e=>zk(e))?[]:e}function VM(e,t){return Bj(BM(LM(e,t)))}function HM(e,t){return t in e?e[t]:t===`[number]`?Bj(e):jj()}function UM(e,t){return t===`[number]`?e:jj()}function WM(e,t){return t in e?e[t]:jj()}function GM(e,t){return Nk(e)?zM(e.allOf,t):tA(e)?VM(e.anyOf,t):$k(e)?HM(e.items??[],t):wk(e)?UM(e.items,t):Uk(e)?WM(e.properties,t):jj()}function KM(e,t){return t.map(t=>GM(e,t))}function qM(e,t){return Bj(KM(e,t))}function JM(e,t,n){if(Kk(e)||Kk(t)){if(!sA(e)||!sA(t))throw new hk(`Index types using Ref parameters require both Type and Key to be of TSchema`);return Oj(`Index`,[e,t])}return Rk(t)?IM(e,t,n):Lk(t)?QM(e,t,n):Y(sA(t)?qM(e,NM(t)):qM(e,t),n)}function YM(e,t,n){return{[t]:JM(e,[t],nk(n))}}function XM(e,t,n){return t.reduce((t,r)=>({...t,...YM(e,r,n)}),{})}function ZM(e,t,n){return XM(e,t.keys,n)}function QM(e,t,n){return Mj(ZM(e,t,n))}function $M(e,t){return Y({[X]:`Iterator`,type:`Iterator`,items:e},t)}function eN(e){return globalThis.Object.keys(e).filter(t=>!xk(e[t]))}function tN(e,t){let n=eN(e);return Y(n.length>0?{[X]:`Object`,type:`object`,required:n,properties:e}:{[X]:`Object`,type:`object`,properties:e},t)}var nN=tN;function rN(e,t){return Y({[X]:`Promise`,type:`Promise`,item:e},t)}function iN(e){return Y(Aj(e,[_k]))}function aN(e){return Y({...e,[_k]:`Readonly`})}function oN(e,t){return t===!1?iN(e):aN(e)}function sN(e,t){let n=t??!0;return Rk(e)?uN(e,n):oN(e,n)}function cN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=sN(e[r],t);return n}function lN(e,t){return cN(e.properties,t)}function uN(e,t){return Mj(lN(e,t))}function dN(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 fN(e,t){return e in t?yN(e,t[e]):Mj(t)}function pN(e){return{[e]:hM(e)}}function mN(e){let t={};for(let n of e)t[n]=hM(n);return t}function hN(e,t){return vj(t,e)?pN(e):mN(t)}function gN(e,t){return fN(e,hN(e,t))}function _N(e,t){return t.map(t=>yN(e,t))}function vN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(t))n[r]=yN(e,t[r]);return n}function yN(e,t){let n={...t};return xk(t)?TN(yN(e,Aj(t,[vk]))):bk(t)?sN(yN(e,Aj(t,[_k]))):Rk(t)?fN(e,t.properties):Lk(t)?gN(e,t.keys):kk(t)?Nj(_N(e,t.parameters),yN(e,t.returns),n):jk(t)?Pj(_N(e,t.parameters),yN(e,t.returns),n):Tk(t)?Dj(yN(e,t.items),n):Pk(t)?$M(yN(e,t.items),n):Nk(t)?FN(_N(e,t.allOf),n):tA(t)?Vj(_N(e,t.anyOf),n):$k(t)?dN(_N(e,t.items??[]),n):Uk(t)?nN(vN(e,t.properties),n):wk(t)?Tj(yN(e,t.items),n):Wk(t)?rN(yN(e,t.item),n):t}function bN(e,t){let n={};for(let r of e)n[r]=yN(r,t);return n}function xN(e,t,n){let r=sA(e)?NM(e):e;return nN(bN(r,t({[X]:`MappedKey`,keys:r})),n)}function SN(e){return Y(Aj(e,[vk]))}function CN(e){return Y({...e,[vk]:`Optional`})}function wN(e,t){return t===!1?SN(e):CN(e)}function TN(e,t){let n=t??!0;return Rk(e)?ON(e,n):wN(e,n)}function EN(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=TN(e[r],t);return n}function DN(e,t){return EN(e.properties,t)}function ON(e,t){return Mj(DN(e,t))}function kN(e,t={}){let n=e.every(e=>Uk(e)),r=sA(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return Y(t.unevaluatedProperties===!1||sA(t.unevaluatedProperties)||n?{...r,[X]:`Intersect`,type:`object`,allOf:e}:{...r,[X]:`Intersect`,allOf:e},t)}function AN(e){return e.every(e=>xk(e))}function jN(e){return Aj(e,[vk])}function MN(e){return e.map(e=>xk(e)?jN(e):e)}function NN(e,t){return AN(e)?TN(kN(MN(e),t)):kN(MN(e),t)}function PN(e,t={}){if(e.length===1)return Y(e[0],t);if(e.length===0)return jj(t);if(e.some(e=>Qk(e)))throw Error(`Cannot intersect transform types`);return NN(e,t)}function FN(e,t){if(e.length===1)return Y(e[0],t);if(e.length===0)return jj(t);if(e.some(e=>Qk(e)))throw Error(`Cannot intersect transform types`);return kN(e,t)}function IN(...e){let[t,n]=typeof e[0]==`string`?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=`string`)throw new hk(`Ref: $ref must be a string`);return Y({[X]:`Ref`,$ref:t},n)}function LN(e,t){return Oj(`Awaited`,[Oj(e,t)])}function RN(e){return Oj(`Awaited`,[IN(e)])}function zN(e){return FN(HN(e))}function BN(e){return Vj(HN(e))}function VN(e){return UN(e)}function HN(e){return e.map(e=>UN(e))}function UN(e,t){return Y(Ok(e)?LN(e.target,e.parameters):Nk(e)?zN(e.allOf):tA(e)?BN(e.anyOf):Wk(e)?VN(e.item):Kk(e)?RN(e.$ref):e,t)}function WN(e){let t=[];for(let n of e)t.push(ZN(n));return t}function GN(e){return Cj(WN(e))}function KN(e){return Sj(WN(e))}function qN(e){return e.map((e,t)=>t.toString())}function JN(e){return[`[number]`]}function YN(e){return globalThis.Object.getOwnPropertyNames(e)}function XN(e){return QN?globalThis.Object.getOwnPropertyNames(e).map(e=>e[0]===`^`&&e[e.length-1]===`$`?e.slice(1,e.length-1):e):[]}function ZN(e){return Nk(e)?GN(e.allOf):tA(e)?KN(e.anyOf):$k(e)?qN(e.items??[]):wk(e)?JN(e.items):Uk(e)?YN(e.properties):Gk(e)?XN(e.patternProperties):[]}var QN=!1;function $N(e,t){return Oj(`KeyOf`,[Oj(e,t)])}function eP(e){return Oj(`KeyOf`,[IN(e)])}function tP(e,t){return Y(Bj(nP(ZN(e))),t)}function nP(e){return e.map(e=>e===`[number]`?vM():hM(e))}function rP(e,t){return Ok(e)?$N(e.target,e.parameters):Kk(e)?eP(e.$ref):Rk(e)?oP(e,t):tP(e,t)}function iP(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=rP(e[r],nk(t));return n}function aP(e,t){return iP(e.properties,t)}function oP(e,t){return Mj(aP(e,t))}function sP(e){let t=[];for(let n of e)t.push(...ZN(n));return yj(t)}function cP(e){return e.filter(e=>!zk(e))}function lP(e,t){let n=[];for(let r of e)n.push(...KM(r,[t]));return cP(n)}function uP(e,t){let n={};for(let r of t)n[r]=PN(lP(e,r));return n}function dP(e,t){return nN(uP(e,sP(e)),t)}function fP(e){return Y({[X]:`Date`,type:`Date`},e)}function pP(e){return Y({[X]:`Null`,type:`null`},e)}function mP(e){return Y({[X]:`Symbol`,type:`symbol`},e)}function hP(e){return Y({[X]:`Undefined`,type:`undefined`},e)}function gP(e){return Y({[X]:`Uint8Array`,type:`Uint8Array`},e)}function _P(e){return Y({[X]:`Unknown`},e)}function vP(e){return e.map(e=>xP(e,!1))}function yP(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=sN(xP(e[n],!1));return t}function bP(e,t){return t===!0?e:sN(e)}function xP(e,t){return FO(e)||VO(e)?bP(wj(),t):IO(e)?sN(dN(vP(e))):JO(e)?gP():zO(e)?fP():WO(e)?bP(nN(yP(e)),t):BO(e)?bP(Pj([],_P()),t):YO(e)?hP():HO(e)?pP():qO(e)?mP():LO(e)?_M():UO(e)||RO(e)||KO(e)?hM(e):nN({})}function SP(e,t){return Y(xP(e,!0),t)}function CP(e,t){return kk(e)?dN(e.parameters,t):jj(t)}function wP(e,t){if(YO(e))throw Error(`Enum undefined or empty`);let n=globalThis.Object.getOwnPropertyNames(e).filter(e=>isNaN(e)).map(t=>e[t]);return Vj([...new Set(n)].map(e=>hM(e)),{...t,[yk]:`Enum`})}var TP=class extends hk{},Q;(function(e){e[e.Union=0]=`Union`,e[e.True=1]=`True`,e[e.False=2]=`False`})(Q||={});function EP(e){return e===Q.False?e:Q.True}function DP(e){throw new TP(e)}function OP(e){return HA(e)||MA(e)||ij(e)||oj(e)||bA(e)}function kP(e,t){return HA(t)?qP(e,t):MA(t)?UP(e,t):ij(t)?AF(e,t):oj(t)?MF(e,t):bA(t)?AP(e,t):DP(`StructuralRight`)}function AP(e,t){return Q.True}function jP(e,t){return MA(t)?UP(e,t):ij(t)&&t.anyOf.some(e=>bA(e)||oj(e))?Q.True:ij(t)?Q.Union:oj(t)||bA(t)?Q.True:Q.Union}function MP(e,t){return oj(e)?Q.False:bA(e)?Q.Union:HA(e)?Q.True:Q.False}function NP(e,t){return KA(t)&&uF(t)?Q.True:OP(t)?kP(e,t):SA(t)?EP(IF(e.items,t.items)):Q.False}function PP(e,t){return OP(t)?kP(e,t):CA(t)?EP(IF(e.items,t.items)):Q.False}function FP(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):wA(t)?Q.True:Q.False}function IP(e,t){return LA(e)||TA(e)?Q.True:Q.False}function LP(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):TA(t)?Q.True:Q.False}function RP(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):DA(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>EP(IF(t.parameters[n],e))===Q.True)?EP(IF(e.returns,t.returns)):Q.False:Q.False}function zP(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):OA(t)?Q.True:Q.False}function BP(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):kA(t)?e.parameters.length>t.parameters.length?Q.False:e.parameters.every((e,n)=>EP(IF(t.parameters[n],e))===Q.True)?EP(IF(e.returns,t.returns)):Q.False:Q.False}function VP(e,t){return RA(e)&&UO(e.const)||GA(e)||AA(e)?Q.True:Q.False}function HP(e,t){return AA(t)||GA(t)?Q.True:OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):Q.False}function UP(e,t){return t.allOf.every(t=>IF(e,t)===Q.True)?Q.True:Q.False}function WP(e,t){return e.allOf.some(e=>IF(e,t)===Q.True)?Q.True:Q.False}function GP(e,t){return OP(t)?kP(e,t):NA(t)?EP(IF(e.items,t.items)):Q.False}function KP(e,t){return RA(t)&&t.const===e.const?Q.True:OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):ZA(t)?xF(e,t):GA(t)?QP(e,t):AA(t)?VP(e,t):TA(t)?IP(e,t):Q.False}function qP(e,t){return Q.False}function JP(e,t){return Q.True}function YP(e){let[t,n]=[e,0];for(;UA(t);)t=t.not,n+=1;return n%2==0?t:_P()}function XP(e,t){return UA(e)?IF(YP(e),t):UA(t)?IF(e,YP(t)):DP(`Invalid fallthrough for Not`)}function ZP(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):WA(t)?Q.True:Q.False}function QP(e,t){return IA(e)||GA(e)||AA(e)?Q.True:Q.False}function $P(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):AA(t)||GA(t)?Q.True:Q.False}function eF(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function tF(e){return uF(e)}function nF(e){return eF(e,0)||eF(e,1)&&`description`in e.properties&&ij(e.properties.description)&&e.properties.description.anyOf.length===2&&(ZA(e.properties.description.anyOf[0])&&rj(e.properties.description.anyOf[1])||ZA(e.properties.description.anyOf[1])&&rj(e.properties.description.anyOf[0]))}function rF(e){return eF(e,0)}function iF(e){return eF(e,0)}function aF(e){return eF(e,0)}function oF(e){return eF(e,0)}function sF(e){return uF(e)}function cF(e){let t=vM();return eF(e,0)||eF(e,1)&&`length`in e.properties&&EP(IF(e.properties.length,t))===Q.True}function lF(e){return eF(e,0)}function uF(e){let t=vM();return eF(e,0)||eF(e,1)&&`length`in e.properties&&EP(IF(e.properties.length,t))===Q.True}function dF(e){let t=Pj([wj()],wj());return eF(e,0)||eF(e,1)&&`then`in e.properties&&EP(IF(e.properties.then,t))===Q.True}function fF(e,t){return IF(e,t)===Q.False||yA(e)&&!yA(t)?Q.False:Q.True}function pF(e,t){return oj(e)?Q.False:bA(e)?Q.Union:HA(e)||FA(e)&&tF(t)||IA(e)&&rF(t)||LA(e)&&iF(t)||QA(e)&&nF(t)||wA(e)&&aF(t)||ZA(e)&&tF(t)||QA(e)&&nF(t)||GA(e)&&rF(t)||AA(e)&&rF(t)||TA(e)&&iF(t)||aj(e)&&sF(t)||OA(e)&&oF(t)||DA(e)&&lF(t)||kA(e)&&cF(t)?Q.True:JA(e)&&ZA(gF(e))?t[yk]===`Record`?Q.True:Q.False:JA(e)&&GA(gF(e))&&eF(t,0)?Q.True:Q.False}function mF(e,t){return OP(t)?kP(e,t):JA(t)?vF(e,t):KA(t)?(()=>{for(let n of Object.getOwnPropertyNames(t.properties)){if(!(n in e.properties)&&!yA(t.properties[n]))return Q.False;if(yA(t.properties[n]))return Q.True;if(fF(e.properties[n],t.properties[n])===Q.False)return Q.False}return Q.True})():Q.False}function hF(e,t){return OP(t)?kP(e,t):KA(t)&&dF(t)?Q.True:qA(t)?EP(IF(e.item,t.item)):Q.False}function gF(e){return hj in e.patternProperties?vM():gj in e.patternProperties?yM():DP(`Unknown record key pattern`)}function _F(e){return hj in e.patternProperties?e.patternProperties[hj]:gj in e.patternProperties?e.patternProperties[gj]:DP(`Unable to get record value schema`)}function vF(e,t){let[n,r]=[gF(t),_F(t)];return FA(e)&&GA(n)&&EP(IF(e,r))===Q.True?Q.True:aj(e)&&GA(n)||ZA(e)&&GA(n)||SA(e)&&GA(n)?IF(e,r):KA(e)?(()=>{for(let t of Object.getOwnPropertyNames(e.properties))if(fF(r,e.properties[t])===Q.False)return Q.False;return Q.True})():Q.False}function yF(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?IF(_F(e),_F(t)):Q.False}function bF(e,t){return IF(XA(e)?yM():e,XA(t)?yM():t)}function xF(e,t){return RA(e)&&KO(e.const)||ZA(e)?Q.True:Q.False}function SF(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):ZA(t)?Q.True:Q.False}function CF(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):QA(t)?Q.True:Q.False}function wF(e,t){return $A(e)?IF(OM(e),t):$A(t)?IF(e,OM(t)):DP(`Invalid fallthrough for TemplateLiteral`)}function TF(e,t){return SA(t)&&e.items!==void 0&&e.items.every(e=>IF(e,t.items)===Q.True)}function EF(e,t){return HA(e)?Q.True:oj(e)?Q.False:bA(e)?Q.Union:Q.False}function DF(e,t){return OP(t)?kP(e,t):KA(t)&&uF(t)||SA(t)&&TF(e,t)?Q.True:nj(t)?YO(e.items)&&!YO(t.items)||!YO(e.items)&&YO(t.items)?Q.False:YO(e.items)&&!YO(t.items)||e.items.every((e,n)=>IF(e,t.items[n])===Q.True)?Q.True:Q.False:Q.False}function OF(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):aj(t)?Q.True:Q.False}function kF(e,t){return OP(t)?kP(e,t):KA(t)?pF(e,t):JA(t)?vF(e,t):cj(t)?PF(e,t):rj(t)?Q.True:Q.False}function AF(e,t){return t.anyOf.some(t=>IF(e,t)===Q.True)?Q.True:Q.False}function jF(e,t){return e.anyOf.every(e=>IF(e,t)===Q.True)?Q.True:Q.False}function MF(e,t){return Q.True}function NF(e,t){return HA(t)?qP(e,t):MA(t)?UP(e,t):ij(t)?AF(e,t):bA(t)?AP(e,t):ZA(t)?xF(e,t):GA(t)?QP(e,t):AA(t)?VP(e,t):TA(t)?IP(e,t):SA(t)?MP(e,t):nj(t)?EF(e,t):KA(t)?pF(e,t):oj(t)?Q.True:Q.False}function PF(e,t){return rj(e)||rj(e)?Q.True:Q.False}function FF(e,t){return MA(t)?UP(e,t):ij(t)?AF(e,t):oj(t)?MF(e,t):bA(t)?AP(e,t):KA(t)?pF(e,t):cj(t)?Q.True:Q.False}function IF(e,t){return $A(e)||$A(t)?wF(e,t):XA(e)||XA(t)?bF(e,t):UA(e)||UA(t)?XP(e,t):bA(e)?jP(e,t):SA(e)?NP(e,t):wA(e)?FP(e,t):TA(e)?LP(e,t):CA(e)?PP(e,t):DA(e)?RP(e,t):OA(e)?zP(e,t):kA(e)?BP(e,t):AA(e)?HP(e,t):MA(e)?WP(e,t):NA(e)?GP(e,t):RA(e)?KP(e,t):HA(e)?JP(e,t):WA(e)?ZP(e,t):GA(e)?$P(e,t):KA(e)?mF(e,t):JA(e)?yF(e,t):ZA(e)?SF(e,t):QA(e)?CF(e,t):nj(e)?DF(e,t):qA(e)?hF(e,t):aj(e)?OF(e,t):rj(e)?kF(e,t):ij(e)?jF(e,t):oj(e)?NF(e,t):cj(e)?FF(e,t):DP(`Unknown left type operand '${e[X]}'`)}function LF(e,t){return IF(e,t)}function RF(e,t,n,r,i){let a={};for(let o of globalThis.Object.getOwnPropertyNames(e))a[o]=HF(e[o],t,n,r,nk(i));return a}function zF(e,t,n,r,i){return RF(e.properties,t,n,r,i)}function BF(e,t,n,r,i){return Mj(zF(e,t,n,r,i))}function VF(e,t,n,r){let i=LF(e,t);return i===Q.Union?Vj([n,r]):i===Q.True?n:r}function HF(e,t,n,r,i){return Rk(e)?BF(e,t,n,r,i):Lk(e)?Y(KF(e,t,n,r,i)):Y(VF(e,t,n,r),i)}function UF(e,t,n,r,i){return{[e]:HF(hM(e),t,n,r,nk(i))}}function WF(e,t,n,r,i){return e.reduce((e,a)=>({...e,...UF(a,t,n,r,i)}),{})}function GF(e,t,n,r,i){return WF(e.keys,t,n,r,i)}function KF(e,t,n,r,i){return Mj(GF(e,t,n,r,i))}function qF(e,t){return YF(OM(e),t)}function JF(e,t){let n=e.filter(e=>LF(e,t)===Q.False);return n.length===1?n[0]:Vj(n)}function YF(e,t,n={}){return Xk(e)?Y(qF(e,t),n):Rk(e)?Y(QF(e,t),n):Y(tA(e)?JF(e.anyOf,t):LF(e,t)===Q.False?e:jj(),n)}function XF(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=YF(e[r],t);return n}function ZF(e,t){return XF(e.properties,t)}function QF(e,t){return Mj(ZF(e,t))}function $F(e,t){return tI(OM(e),t)}function eI(e,t){let n=e.filter(e=>LF(e,t)!==Q.False);return n.length===1?n[0]:Vj(n)}function tI(e,t,n){return Xk(e)?Y($F(e,t),n):Rk(e)?Y(iI(e,t),n):Y(tA(e)?eI(e.anyOf,t):LF(e,t)===Q.False?jj():e,n)}function nI(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=tI(e[r],t);return n}function rI(e,t){return nI(e.properties,t)}function iI(e,t){return Mj(rI(e,t))}function aI(e,t){return kk(e)?Y(e.returns,t):jj(t)}function oI(e){return sN(TN(e))}function sI(e,t,n){return Y({[X]:`Record`,type:`object`,patternProperties:{[e]:t}},n)}function cI(e,t,n){let r={};for(let n of e)r[n]=t;return nN(r,{...n,[yk]:`Record`})}function lI(e,t,n){return sM(e)?cI(NM(e),t,n):sI(e.pattern,t,n)}function uI(e,t,n){return cI(NM(Vj(e)),t,n)}function dI(e,t,n){return cI([e.toString()],t,n)}function fI(e,t,n){return sI(e.source,t,n)}function pI(e,t,n){return sI(YO(e.pattern)?gj:e.pattern,t,n)}function mI(e,t,n){return sI(gj,t,n)}function hI(e,t,n){return sI(_j,t,n)}function gI(e,t,n){return nN({true:t,false:t},n)}function _I(e,t,n){return sI(hj,t,n)}function vI(e,t,n){return sI(hj,t,n)}function yI(e,t,n={}){return tA(e)?uI(e.anyOf,t,n):Xk(e)?lI(e,t,n):Ik(e)?dI(e.const,t,n):Dk(e)?gI(e,t,n):Mk(e)?_I(e,t,n):Hk(e)?vI(e,t,n):qk(e)?fI(e,t,n):Jk(e)?pI(e,t,n):Sk(e)?mI(e,t,n):zk(e)?hI(e,t,n):jj(n)}function bI(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function xI(e){let t=bI(e);return t===gj?yM():t===hj?vM():yM({pattern:t})}function SI(e){return e.patternProperties[bI(e)]}function CI(e,t){return t.parameters=LI(e,t.parameters),t.returns=RI(e,t.returns),t}function wI(e,t){return t.parameters=LI(e,t.parameters),t.returns=RI(e,t.returns),t}function TI(e,t){return t.allOf=LI(e,t.allOf),t}function EI(e,t){return t.anyOf=LI(e,t.anyOf),t}function DI(e,t){return YO(t.items)||(t.items=LI(e,t.items)),t}function OI(e,t){return t.items=RI(e,t.items),t}function kI(e,t){return t.items=RI(e,t.items),t}function AI(e,t){return t.items=RI(e,t.items),t}function jI(e,t){return t.item=RI(e,t.item),t}function MI(e,t){let n=II(e,t.properties);return{...t,...nN(n)}}function NI(e,t){let n=yI(RI(e,xI(t)),RI(e,SI(t)));return{...t,...n}}function PI(e,t){return t.index in e?e[t.index]:_P()}function FI(e,t){let n=bk(t),r=xk(t),i=RI(e,t);return n&&r?oI(i):n&&!r?sN(i):!n&&r?TN(i):i}function II(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((n,r)=>({...n,[r]:FI(e,t[r])}),{})}function LI(e,t){return t.map(t=>RI(e,t))}function RI(e,t){return kk(t)?CI(e,t):jk(t)?wI(e,t):Nk(t)?TI(e,t):tA(t)?EI(e,t):$k(t)?DI(e,t):wk(t)?OI(e,t):Tk(t)?kI(e,t):Pk(t)?AI(e,t):Wk(t)?jI(e,t):Uk(t)?MI(e,t):Gk(t)?NI(e,t):Ck(t)?PI(e,t):t}function zI(e,t){return RI(t,rk(e))}function BI(e){return Y({[X]:`Integer`,type:`integer`},e)}function VI(e,t,n){return{[e]:QI(hM(e),t,nk(n))}}function HI(e,t,n){return e.reduce((e,r)=>({...e,...VI(r,t,n)}),{})}function UI(e,t,n){return HI(e.keys,t,n)}function WI(e,t,n){return Mj(UI(e,t,n))}function GI(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),n].join(``)}function KI(e){let[t,n]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),n].join(``)}function qI(e){return e.toUpperCase()}function JI(e){return e.toLowerCase()}function YI(e,t,n){let r=tM(e.pattern);return oM(r)?kM([Vj(ZI([...pM(r)].map(e=>hM(e)),t))],n):{...e,pattern:XI(e.pattern,t)}}function XI(e,t){return typeof e==`string`?t===`Uncapitalize`?GI(e):t===`Capitalize`?KI(e):t===`Uppercase`?qI(e):t===`Lowercase`?JI(e):e:e.toString()}function ZI(e,t){return e.map(e=>QI(e,t))}function QI(e,t,n={}){return Lk(e)?WI(e,t,n):Xk(e)?YI(e,t,n):tA(e)?Vj(ZI(e.anyOf,t),n):Ik(e)?hM(XI(e.const,t),n):Y(e,n)}function $I(e,t={}){return QI(e,`Capitalize`,t)}function eL(e,t={}){return QI(e,`Lowercase`,t)}function tL(e,t={}){return QI(e,`Uncapitalize`,t)}function nL(e,t={}){return QI(e,`Uppercase`,t)}function rL(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=pL(e[i],t,nk(n));return r}function iL(e,t,n){return rL(e.properties,t,n)}function aL(e,t,n){return Mj(iL(e,t,n))}function oL(e,t){return e.map(e=>fL(e,t))}function sL(e,t){return e.map(e=>fL(e,t))}function cL(e,t){let{[t]:n,...r}=e;return r}function lL(e,t){return t.reduce((e,t)=>cL(e,t),e)}function uL(e,t,n){let r=Aj(e,[gk,`$id`,`required`,`properties`]);return nN(lL(n,t),r)}function dL(e){return Vj(e.reduce((e,t)=>Fk(t)?[...e,hM(t)]:e,[]))}function fL(e,t){return Nk(e)?FN(oL(e.allOf,t)):tA(e)?Vj(sL(e.anyOf,t)):Uk(e)?uL(e,t,e.properties):nN({})}function pL(e,t,n){let r=IO(t)?dL(t):t,i=sA(t)?NM(t):t,a=Kk(e),o=Kk(t);return Rk(e)?aL(e,i,n):Lk(t)?_L(e,t,n):a&&o||!a&&o||a&&!o?Oj(`Omit`,[e,r],n):Y({...fL(e,i),...n})}function mL(e,t,n){return{[t]:pL(e,[t],nk(n))}}function hL(e,t,n){return t.reduce((t,r)=>({...t,...mL(e,r,n)}),{})}function gL(e,t,n){return hL(e,t.keys,n)}function _L(e,t,n){return Mj(gL(e,t,n))}function vL(e,t,n){let r={};for(let i of globalThis.Object.getOwnPropertyNames(e))r[i]=DL(e[i],t,nk(n));return r}function yL(e,t,n){return vL(e.properties,t,n)}function bL(e,t,n){return Mj(yL(e,t,n))}function xL(e,t){return e.map(e=>EL(e,t))}function SL(e,t){return e.map(e=>EL(e,t))}function CL(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function wL(e,t,n){let r=Aj(e,[gk,`$id`,`required`,`properties`]);return nN(CL(n,t),r)}function TL(e){return Vj(e.reduce((e,t)=>Fk(t)?[...e,hM(t)]:e,[]))}function EL(e,t){return Nk(e)?FN(xL(e.allOf,t)):tA(e)?Vj(SL(e.anyOf,t)):Uk(e)?wL(e,t,e.properties):nN({})}function DL(e,t,n){let r=IO(t)?TL(t):t,i=sA(t)?NM(t):t,a=Kk(e),o=Kk(t);return Rk(e)?bL(e,i,n):Lk(t)?jL(e,t,n):a&&o||!a&&o||a&&!o?Oj(`Pick`,[e,r],n):Y({...EL(e,i),...n})}function OL(e,t,n){return{[t]:DL(e,[t],nk(n))}}function kL(e,t,n){return t.reduce((t,r)=>({...t,...OL(e,r,n)}),{})}function AL(e,t,n){return kL(e,t.keys,n)}function jL(e,t,n){return Mj(AL(e,t,n))}function ML(e,t){return Oj(`Partial`,[Oj(e,t)])}function NL(e){return Oj(`Partial`,[IN(e)])}function PL(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=TN(e[n]);return t}function FL(e,t){let n=Aj(e,[gk,`$id`,`required`,`properties`]);return nN(PL(t),n)}function IL(e){return e.map(e=>LL(e))}function LL(e){return Ok(e)?ML(e.target,e.parameters):Kk(e)?NL(e.$ref):Nk(e)?FN(IL(e.allOf)):tA(e)?Vj(IL(e.anyOf)):Uk(e)?FL(e,e.properties):Ek(e)||Dk(e)||Mk(e)||Ik(e)||Vk(e)||Hk(e)||Jk(e)||Yk(e)||eA(e)?e:nN({})}function RL(e,t){return Rk(e)?VL(e,t):Y({...LL(e),...t})}function zL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=RL(e[r],nk(t));return n}function BL(e,t){return zL(e.properties,t)}function VL(e,t){return Mj(BL(e,t))}function HL(e,t){return Oj(`Required`,[Oj(e,t)])}function UL(e){return Oj(`Required`,[IN(e)])}function WL(e){let t={};for(let n of globalThis.Object.getOwnPropertyNames(e))t[n]=Aj(e[n],[vk]);return t}function GL(e,t){let n=Aj(e,[gk,`$id`,`required`,`properties`]);return nN(WL(t),n)}function KL(e){return e.map(e=>qL(e))}function qL(e){return Ok(e)?HL(e.target,e.parameters):Kk(e)?UL(e.$ref):Nk(e)?FN(KL(e.allOf)):tA(e)?Vj(KL(e.anyOf)):Uk(e)?GL(e,e.properties):Ek(e)||Dk(e)||Mk(e)||Ik(e)||Vk(e)||Hk(e)||Jk(e)||Yk(e)||eA(e)?e:nN({})}function JL(e,t){return Rk(e)?ZL(e,t):Y({...qL(e),...t})}function YL(e,t){let n={};for(let r of globalThis.Object.getOwnPropertyNames(e))n[r]=JL(e[r],t);return n}function XL(e,t){return YL(e.properties,t)}function ZL(e,t){return Mj(XL(e,t))}function QL(e,t){return t.map(t=>Kk(t)?$L(e,t.$ref):bR(e,t))}function $L(e,t){return t in e?Kk(e[t])?$L(e,e[t].$ref):bR(e,e[t]):jj()}function eR(e){return UN(e[0])}function tR(e){return JM(e[0],e[1])}function nR(e){return rP(e[0])}function rR(e){return RL(e[0])}function iR(e){return pL(e[0],e[1])}function aR(e){return DL(e[0],e[1])}function oR(e){return JL(e[0])}function sR(e,t,n){let r=QL(e,n);return t===`Awaited`?eR(r):t===`Index`?tR(r):t===`KeyOf`?nR(r):t===`Partial`?rR(r):t===`Omit`?iR(r):t===`Pick`?aR(r):t===`Required`?oR(r):jj()}function cR(e,t){return Tj(bR(e,t))}function lR(e,t){return Dj(bR(e,t))}function uR(e,t,n){return Nj(yR(e,t),bR(e,n))}function dR(e,t,n){return Pj(yR(e,t),bR(e,n))}function fR(e,t){return FN(yR(e,t))}function pR(e,t){return $M(bR(e,t))}function mR(e,t){return nN(globalThis.Object.keys(t).reduce((n,r)=>({...n,[r]:bR(e,t[r])}),{}))}function hR(e,t){let[n,r]=[bR(e,SI(t)),bI(t)],i=rk(t);return i.patternProperties[r]=n,i}function gR(e,t){return Kk(t)?{...$L(e,t.$ref),[gk]:t[gk]}:t}function _R(e,t){return dN(yR(e,t))}function vR(e,t){return Vj(yR(e,t))}function yR(e,t){return t.map(t=>bR(e,t))}function bR(e,t){return xk(t)?Y(bR(e,Aj(t,[vk])),t):bk(t)?Y(bR(e,Aj(t,[_k])),t):Qk(t)?Y(gR(e,t),t):wk(t)?Y(cR(e,t.items),t):Tk(t)?Y(lR(e,t.items),t):Ok(t)?Y(sR(e,t.target,t.parameters)):kk(t)?Y(uR(e,t.parameters,t.returns),t):jk(t)?Y(dR(e,t.parameters,t.returns),t):Nk(t)?Y(fR(e,t.allOf),t):Pk(t)?Y(pR(e,t.items),t):Uk(t)?Y(mR(e,t.properties),t):Gk(t)?Y(hR(e,t)):$k(t)?Y(_R(e,t.items||[]),t):tA(t)?Y(vR(e,t.anyOf),t):t}function xR(e,t){return t in e?bR(e,e[t]):jj()}function SR(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:xR(e,n)}),{})}var CR=class{constructor(e){let t=SR(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 wR(e){return new CR(e)}function TR(e,t){return Y({[X]:`Not`,not:e},t)}function ER(e,t){return jk(e)?dN(e.parameters,t):jj()}var DR=0;function OR(e,t={}){YO(t.$id)&&(t.$id=`T${DR++}`);let n=rk(e({[X]:`This`,$ref:`${t.$id}`}));return n.$id=t.$id,Y({[yk]:`Recursive`,...n},t)}function kR(e,t){let n=KO(e)?new globalThis.RegExp(e):e;return Y({[X]:`RegExp`,type:`RegExp`,source:n.source,flags:n.flags},t)}function AR(e){return Nk(e)?e.allOf:tA(e)?e.anyOf:$k(e)?e.items??[]:[]}function jR(e){return AR(e)}function MR(e,t){return jk(e)?Y(e.returns,t):jj(t)}var NR=class{constructor(e){this.schema=e}Decode(e){return new PR(this.schema,e)}},PR=class{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let n={Encode:n=>t[gk].Encode(e(n)),Decode:e=>this.decode(t[gk].Decode(e))};return{...t,[gk]:n}}EncodeSchema(e,t){let n={Decode:this.decode,Encode:e};return{...t,[gk]:n}}Encode(e){return Qk(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}};function FR(e){return new NR(e)}function IR(e={}){return Y({[X]:e[X]??`Unsafe`},e)}function LR(e){return Y({[X]:`Void`,type:`void`},e)}var $=t({Any:()=>wj,Argument:()=>Ej,Array:()=>Tj,AsyncIterator:()=>Dj,Awaited:()=>UN,BigInt:()=>_M,Boolean:()=>gM,Capitalize:()=>$I,Composite:()=>dP,Const:()=>SP,Constructor:()=>Nj,ConstructorParameters:()=>CP,Date:()=>fP,Enum:()=>wP,Exclude:()=>YF,Extends:()=>HF,Extract:()=>tI,Function:()=>Pj,Index:()=>JM,InstanceType:()=>aI,Instantiate:()=>zI,Integer:()=>BI,Intersect:()=>FN,Iterator:()=>$M,KeyOf:()=>rP,Literal:()=>hM,Lowercase:()=>eL,Mapped:()=>xN,Module:()=>wR,Never:()=>jj,Not:()=>TR,Null:()=>pP,Number:()=>vM,Object:()=>nN,Omit:()=>pL,Optional:()=>TN,Parameters:()=>ER,Partial:()=>RL,Pick:()=>DL,Promise:()=>rN,Readonly:()=>sN,ReadonlyOptional:()=>oI,Record:()=>yI,Recursive:()=>OR,Ref:()=>IN,RegExp:()=>kR,Required:()=>JL,Rest:()=>jR,ReturnType:()=>MR,String:()=>yM,Symbol:()=>mP,TemplateLiteral:()=>kM,Transform:()=>FR,Tuple:()=>dN,Uint8Array:()=>gP,Uncapitalize:()=>tL,Undefined:()=>hP,Union:()=>Vj,Unknown:()=>_P,Unsafe:()=>IR,Uppercase:()=>nL,Void:()=>LR}),RR={additionalProperties:!1},zR=$.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}),BR=$.String({pattern:`^[a-z0-9][a-z0-9-]{0,31}(?![\\s\\S])`,minLength:1,maxLength:32}),VR=$.String({pattern:`^sha256:[0-9a-f]{64}$`,minLength:71,maxLength:71}),HR=$.String({pattern:`^[A-Za-z0-9_-]{43}$`,minLength:43,maxLength:43}),UR=$.String({pattern:`^dpt_[A-Za-z0-9_-]{43}$`,minLength:47,maxLength:47}),WR=`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`,GR=`^(?:${WR}|[A-Z2-7]{12}|[A-Z2-7]{8})(?![\\s\\S])`,KR=$.String({pattern:GR,minLength:8,maxLength:36}),qR=new RegExp(GR),JR=/^[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 YR(e){return typeof e!=`string`||e.length>36?!1:qR.test(e)}function XR(e){if(typeof e!=`string`)return;if(JR.test(e)){let t=e.toLowerCase();return YR(t)?t:void 0}let t=e.replace(/[\s-]+/g,``).toUpperCase();if(YR(t)&&!(/[\s-]/.test(e)&&t.length!==12))return t}$.Object({type:$.Literal(`pair.request`),v:$.Literal(1),requestId:zR,code:KR,deviceUid:zR,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:VR,clientTime:$.Integer(),hubNonce:$.Optional(HR)},RR),$.Object({type:$.Literal(`pair.device-request`),v:$.Literal(1),requestId:zR,deviceUid:zR,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:VR,clientTime:$.Integer(),hubNonce:$.Optional(HR)},RR);var ZR=$.Object({type:$.Literal(`pair.challenge`),v:$.Literal(1),enrollmentId:zR,nonce:HR,issuedAt:$.Integer(),hubId:zR,hubPublicKey:$.Optional($.String({minLength:1,maxLength:256})),hubKeyFingerprint:$.Optional(VR),hubSignature:$.Optional($.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86}))},RR);$.Object({type:$.Literal(`pair.device-ack`),v:$.Literal(1),codeId:zR,code:KR,expiresAt:$.Integer(),hubOrigin:$.String(),hubId:zR,challenge:ZR},RR),$.Object({type:$.Literal(`pair.response`),v:$.Literal(1),enrollmentId:zR,nonce:HR,signature:$.String({pattern:`^[A-Za-z0-9_-]{86}$`,minLength:86,maxLength:86})},RR),$.Object({type:$.Literal(`pair.pending`),v:$.Literal(1),enrollmentId:zR,state:$.Literal(`awaiting_approval`),expiresAt:$.Integer(),pollAfterMs:$.Integer({minimum:1})},RR),$.Object({type:$.Literal(`pair.token`),v:$.Literal(1),enrollmentId:zR,deviceUid:zR,deviceId:BR,pairingEpoch:zR,credentialId:zR,generation:$.Integer({minimum:1}),hubId:zR,hubOrigin:$.String(),hubUrl:$.String(),tunnelToken:UR,issuedAt:$.Integer(),expiresAt:$.Null(),hubKeyFingerprint:$.Optional(VR)},RR),$.Object({enrollmentId:zR,deviceUid:zR,keyFingerprint:VR,replaceKey:$.Optional($.Boolean())},RR),$.Object({type:$.Literal(`pair.revoke`),v:$.Literal(1),deviceId:BR,pairingEpoch:zR,reason:$.Union([$.Literal(`user`),$.Literal(`compromise`),$.Literal(`hub_migrated`)]),revokedAt:$.Integer()},RR);var QR=$.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}))},RR);$.Object({type:$.Literal(`pair.code`),v:$.Literal(1),codeId:zR,code:KR,expiresAt:$.Integer(),hubOrigin:$.String({maxLength:2048}),pairUrl:$.String({maxLength:4096}),offerUrl:$.Optional($.String({maxLength:2048}))},RR);var $R=$.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:zR,expiresAt:$.Integer(),phase:$R,enrollment:$.Optional($.Object({enrollmentId:zR,deviceUid:zR,deviceName:$.String({minLength:1,maxLength:64}),keyFingerprint:VR,proofVerified:$.Boolean(),keyChanged:$.Boolean()},RR)),deviceId:$.Optional(BR),error:$.Optional(QR)},RR);function ez(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 tz(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 nz=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,rz=RegExp(`^${WR}$`),iz=/^sha256:[0-9a-f]{64}$/;function az(e){let t=tz(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=ez(r.hub);if(a.ok&&a.origin===r.hub&&typeof r.id==`string`&&nz.test(r.id)&&typeof r.code==`string`&&rz.test(r.code)&&typeof r.exp==`number`&&Number.isSafeInteger(r.exp))return r.v===3?typeof r.kfp!=`string`||!iz.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 oz(e,t=Date.now()){let n=az(e);if(n&&!(n.exp<t-3e4)&&!(n.exp>t+6e5))return n}function sz(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=oz(n.hash.slice(7),t);if(r&&r.hub===n.origin)return{offer:r,rest:`${n.origin}/pair`}}function cz(e){if(!/^\/pair\/?$/.test(e.pathname))return;if(e.hash.startsWith(`#offer=`)){let t=sz(e.href);if(t)return{code:t.offer.code,origin:e.origin,offerFragment:e.hash.slice(1)};let n=oz(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:XR(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 lz=e=>/^\/pair\/?$/.test(e.pathname)?`/`:void 0,uz=e=>/^\/pair\/?$/.test(e.pathname)&&cz(e)===void 0?`/`:void 0,dz=4e3;async function fz(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 pz={class:`modal pair-wizard`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pair-title`},mz={key:1,class:`pair-pending`,"aria-label":`Machines waiting for approval`},hz={class:`who`},gz={key:0,class:`muted`},_z={key:1,class:`muted`},vz={class:`fp`},yz={class:`row`},bz={class:`phase`},xz=[`onClick`],Sz={key:2,class:`hint`},Cz={class:`pair-steps`,"aria-label":`Pairing progress`},wz={class:`pair-grid`},Tz={class:`pair-code-box`},Ez={class:`pair-code`,"aria-label":`Pairing code`},Dz={class:`pair-copy-actions`},Oz=[`innerHTML`],kz={class:`pair-side`},Az={key:0,class:`hint`},jz={class:`pair-fingerprint`},Mz={class:`fp`},Nz={class:`pair-confirm`},Pz={key:0,class:`pair-confirm warn`},Fz=[`disabled`],Iz=[`disabled`],Lz={class:`hint`},Rz=[`disabled`],zz={key:5,class:`error`,role:`alert`},Bz={key:4},Vz={class:`error`,role:`alert`},Hz=N({__name:`PairDeviceWizard`,props:{handoff:{}},emits:[`close`],setup(e,{expose:t,emit:n}){let r=n,i=e,a=k(`boot`),o=k(),s=k(),c=k(),l=k(``),u=k(!1),d=k(!1),f=k(!1),p=k(!1),m=k(!1),h=k(!1),g=k(),_=k([]),v=U(()=>{let e=s.value?.code??``;return!YR(e)||e.includes(`-`)?e:(e.match(/.{4}/g)??[]).join(`-`)}),y=U(()=>s.value?By(s.value):``),b=U(()=>y.value?DO(y.value,148):``),x=U(()=>c.value?.enrollment?.keyFingerprint??``),S=U(()=>c.value?.deviceId??``);M(S,e=>{g.value?.(),e&&(g.value=M(()=>bu.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=Uy();o.value=t;try{let n=e?await Vy.resolveCode(e):await Vy.createCode();if(t.closed()){await Vy.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=lz(new URL(window.location.href));e&&window.history.replaceState(window.history.state,``,e)}Ky(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 Vy.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 te(e){if(!s.value)return`cancelled`;try{let t=await Vy.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 ql&&e.status===409&&String(e.code)===`already_issued`){let e=await Vy.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 w=()=>te(!1),ne=()=>[`issued`,`connected`,`cancelled`,`expired`].includes(c.value?.phase??``);async function re(){let e=S.value;if(e){u.value=!0;try{await Vy.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 fz({needsCancel:!!s.value&&!ne(),cancel:w,timeoutMs:dz});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 Vy.pending()).codes}catch{}}async function le(e){s.value=void 0,c.value=void 0,l.value=``;let t=Uy();o.value=t,a.value=e.phase===`approved_ready`?`approve`:`proof`,Ky(t,e.codeId,{intervalMs:1e3,onState:e=>{c.value=e,e.phase===`awaiting_proof`?a.value=`proof`:e.phase===`awaiting_approval`||e.phase===`approved`?a.value=`approve`:e.phase===`issued`||e.phase===`connected`?a.value=`issued`:e.phase===`cancelled`?a.value=`cancelled`:e.phase===`expired`&&(a.value=`expired`)}}).catch(e=>{l.value=e instanceof Error?e.message:String(e)})}return Vr(()=>{if(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)}),Wr(()=>{clearInterval(se);let e=o.value;e&&!e.closed()&&s.value&&!ne()&&te(!0).then(e=>{e!==`cancelled`&&J(`Pairing cancellation was not confirmed. Check device credentials before retrying.`)}),e?.close(),g.value?.()}),(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:ks(oe,[`self`])},[z(`div`,pz,[z(`header`,null,[t[5]||=z(`h2`,{id:`pair-title`},`Pair a device`,-1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,onClick:oe},[B(A(vl),{size:18})])]),i.handoff&&`offerFragment`in i.handoff&&i.handoff.offerFragment?(I(),R(PO,{key:0,"offer-fragment":i.handoff.offerFragment},null,8,[`offer-fragment`])):H(``,!0),_.value.length?(I(),L(`section`,mz,[t[6]||=z(`h3`,null,`Machines waiting for you`,-1),z(`ul`,null,[(I(!0),L(F,null,P(_.value,e=>(I(),L(`li`,{key:e.codeId},[z(`div`,hz,[z(`strong`,null,D(e.deviceName??`unnamed device`),1),e.hostname?(I(),L(`span`,gz,D(e.hostname),1)):H(``,!0),e.platform?(I(),L(`span`,_z,D(e.platform),1)):H(``,!0)]),z(`div`,vz,D(e.keyFingerprint),1),z(`div`,yz,[z(`span`,bz,D(e.phase.replaceAll(`_`,` `)),1),z(`button`,{type:`button`,class:`small`,onClick:t=>le(e)},`Review`,8,xz)])]))),128))]),t[7]||=z(`p`,{class:`hint`},` Compare each fingerprint with the machine's own terminal before approving. Codes are minted by the hub — nothing has to be copied to the machine. `,-1)])):H(``,!0),a.value===`boot`?(I(),L(`p`,Sz,`Minting a pairing code…`)):s.value?(I(),L(F,{key:3},[z(`ol`,Cz,[t[8]||=z(`li`,{class:E({on:!0})},`Code`,-1),z(`li`,{class:E({on:[`proof`,`approve`,`issued`].includes(a.value)})},`Proof`,2),z(`li`,{class:E({on:[`approve`,`issued`].includes(a.value)})},`Fingerprint`,2),z(`li`,{class:E({on:a.value===`issued`})},`Online`,2)]),z(`div`,wz,[z(`div`,Tz,[z(`div`,Ez,D(v.value),1),z(`div`,Dz,[z(`button`,{type:`button`,class:`small`,onClick:ie},[B(A(sc),{size:14}),V(` `+D(m.value?`Copied`:`Copy code`),1)]),z(`button`,{type:`button`,class:`small`,onClick:ae,title:`Self-contained link: hub, code and expiry all in the fragment — it never reaches server logs`},[B(A(sc),{size:14}),V(` `+D(h.value?`Copied link`:`Copy link`),1)])]),t[9]||=z(`p`,{class:`hint`},` Run the device pairing command and scan, or enter this code on the device. Expires in 5 minutes. `,-1),z(`div`,{class:`pair-qr`,"aria-label":`Pairing QR code`,title:`Same offer link as Copy link: hub, code and expiry all in the #offer= fragment — it never reaches server logs`,innerHTML:b.value},null,8,Oz)]),z(`div`,kz,[a.value===`code`||a.value===`proof`?(I(),L(`p`,Az,[B(A($c),{size:14,class:`spin`}),t[10]||=V(` Waiting for the device to submit its signing proof… `,-1)])):a.value===`approve`?(I(),L(F,{key:1},[z(`div`,jz,[t[11]||=z(`h3`,null,`Device key fingerprint`,-1),z(`code`,Mz,D(x.value),1),t[12]||=z(`p`,{class:`hint`},` Compare ALL 64 hex characters with the fingerprint shown on the device screen. `,-1)]),z(`label`,Nz,[j(z(`input`,{"onUpdate:modelValue":t[0]||=e=>f.value=e,type:`checkbox`},null,512),[[bs,f.value]]),t[13]||=V(` The fingerprint matches the device display exactly `,-1)]),c.value?.enrollment?.keyChanged?(I(),L(`label`,Pz,[j(z(`input`,{"onUpdate:modelValue":t[1]||=e=>p.value=e,type:`checkbox`},null,512),[[bs,p.value]]),B(A(il),{size:14}),t[14]||=V(` Device is already paired with a DIFFERENT key — replace the stored key (replaceKey) `,-1)])):H(``,!0),z(`button`,{type:`button`,class:`primary`,disabled:!f.value||u.value||c.value?.enrollment?.keyChanged===!0&&!p.value,onClick:ee},` Approve device `,8,Fz),z(`button`,{type:`button`,class:`small`,disabled:u.value,onClick:w},` Cancel pairing `,8,Iz)],64)):a.value===`issued`?(I(),L(F,{key:2},[z(`p`,Lz,[B(A(ic),{size:14}),t[15]||=V(` Credential issued. The device is connecting through the tunnel — you will get a toast once the monitor probe reports it online. `,-1)]),z(`button`,{type:`button`,class:`small`,onClick:oe},`Close`),z(`button`,{type:`button`,class:`small danger`,disabled:!S.value||u.value,title:`Mistaken approval? Revoke the credential now.`,onClick:re},` Revoke this credential `,8,Rz)],64)):a.value===`cancelled`?(I(),L(F,{key:3},[t[16]||=z(`p`,{class:`hint`},`Pairing was cancelled (or the signature failed too many times).`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[2]||=e=>C()},`Start over`)],64)):a.value===`expired`?(I(),L(F,{key:4},[t[17]||=z(`p`,{class:`hint`},`The pairing code expired.`,-1),z(`button`,{type:`button`,class:`small`,onClick:t[3]||=e=>C()},`New code`)],64)):H(``,!0),l.value?(I(),L(`p`,zz,D(l.value),1)):H(``,!0)])])],64)):(I(),L(`div`,Bz,[z(`p`,Vz,D(l.value||`This pairing link is unavailable.`),1),z(`button`,{type:`button`,class:`small`,onClick:t[4]||=e=>C()},`New code`)]))])]))}}),Uz={class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-credentials-title`},Wz={class:`hint`},Gz={key:1,class:`hint`},Kz=N({__name:`DeviceCredentialsDialog`,props:{deviceId:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=U(()=>bu.devices.value.find(e=>e.id===n.deviceId));return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>r(`close`),[`self`])},[z(`section`,Uz,[z(`header`,null,[t[3]||=z(`h2`,{id:`device-credentials-title`},`Device credentials`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close device credentials`,onClick:t[0]||=e=>r(`close`)},[B(A(vl),{size:18})])]),i.value?(I(),L(F,{key:0},[z(`p`,null,[V(D(i.value.name)+` `,1),z(`code`,null,D(i.value.id),1)]),z(`p`,Wz,D(i.value.status)+` · tunnel `+D(i.value.tunnel?.state??`disconnected`)+` · `+D(i.value.tunnel?.readerCount??0)+` readers `,1),B(tb,{device:i.value},null,8,[`device`])],64)):(I(),L(`p`,Gz,`This device is no longer in the registry.`)),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:t[1]||=e=>r(`close`)},`Close`)])])]))}}),qz={id:`prompt-title`},Jz=[`disabled`],Yz={key:0,class:`hint`},Xz={key:1},Zz={key:0,class:`muted`},Qz=[`placeholder`,`disabled`],$z=[`required`,`placeholder`,`aria-label`,`disabled`],eB={key:2,class:`message-error`,role:`alert`},tB=[`disabled`],nB=[`disabled`],rB=N({__name:`PromptDialog`,props:{dialog:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=k(n.dialog.value??``),a=k(!1),o=k(``),s=k(),c=!!n.dialog.label;async function l(){if(!a.value&&(!c||n.dialog.optional||i.value.trim())){a.value=!0,o.value=``;try{await n.dialog.run(i.value.trim()),r(`close`)}catch(e){o.value=cu(e)}finally{a.value=!1}}}return Vr(()=>void An(()=>(s.value?.focus(),s.value?.select()))),(t,n)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:n[4]||=ks(e=>!a.value&&r(`close`),[`self`])},[z(`form`,{class:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-title`,onSubmit:ks(l,[`prevent`])},[z(`header`,null,[z(`h2`,qz,D(e.dialog.title),1),z(`button`,{type:`button`,class:`icon-button`,"aria-label":`Close dialog`,disabled:a.value,onClick:n[0]||=e=>r(`close`)},[B(A(vl),{size:18})],8,Jz)]),e.dialog.hint?(I(),L(`p`,Yz,D(e.dialog.hint),1)):H(``,!0),c?(I(),L(`label`,Xz,[V(D(e.dialog.label)+` `,1),e.dialog.optional?(I(),L(`span`,Zz,`(optional)`)):H(``,!0),e.dialog.multiline?j((I(),L(`textarea`,{key:1,ref_key:`input`,ref:s,"onUpdate:modelValue":n[1]||=e=>i.value=e,rows:`4`,placeholder:e.dialog.placeholder,disabled:a.value},null,8,Qz)),[[ys,i.value]]):j((I(),L(`input`,{key:2,ref_key:`input`,ref:s,"onUpdate:modelValue":n[2]||=e=>i.value=e,maxlength:`100`,required:!e.dialog.optional,placeholder:e.dialog.placeholder,"aria-label":e.dialog.label,disabled:a.value},null,8,$z)),[[ys,i.value]])])):H(``,!0),o.value?(I(),L(`p`,eB,D(o.value),1)):H(``,!0),z(`footer`,null,[z(`button`,{type:`button`,class:`secondary`,disabled:a.value,onClick:n[3]||=e=>r(`close`)},` Cancel `,8,tB),z(`button`,{class:E([`primary`,{danger:e.dialog.danger}]),disabled:a.value||c&&!e.dialog.optional&&!i.value.trim()},D(a.value?`Working…`:e.dialog.submit),11,nB)])],32)]))}}),iB={class:`modal model-modal`},aB={class:`eyebrow`},oB={class:`model-list`},sB=[`onClick`],cB=[`src`],lB={class:`hint`},uB=N({__name:`ModelPicker`,emits:[`close`],setup(e,{emit:t}){let n=t,r=k(``),i=U(()=>Wu.value.filter(e=>`${e.name} ${e.id} ${e.tier}`.toLowerCase().includes(r.value.toLowerCase()))),a=e=>e.id===Gu.value.agent.model?.modelId&&e.provider===Gu.value.agent.model?.provider;async function o(e){await ad(()=>Fu.value.configure({model:{provider:e.provider,modelId:e.id}}))&&(await ed(),J(`Model saved. Used on the next turn.`),n(`close`))}return(e,t)=>(I(),L(`div`,{class:`modal-backdrop`,onClick:t[2]||=ks(e=>n(`close`),[`self`])},[z(`section`,iB,[z(`header`,null,[z(`div`,null,[z(`span`,aB,`PER AGENT · `+D(A(Ou)?.id),1),t[3]||=z(`h2`,null,`Choose a model`,-1)]),z(`button`,{class:`icon-button`,"aria-label":`Close model picker`,onClick:t[0]||=e=>n(`close`)},[B(A(vl),{size:18})])]),j(z(`input`,{"onUpdate:modelValue":t[1]||=e=>r.value=e,placeholder:`Search models or tiers…`,"aria-label":`Search models`},null,512),[[ys,r.value]]),z(`div`,oB,[(I(!0),L(F,null,P(i.value,e=>(I(),L(`button`,{key:`${e.provider}/${e.id}`,class:E({selected:a(e)}),onClick:t=>o(e)},[z(`img`,{src:A(ld)(e.id),alt:``},null,8,cB),z(`div`,null,[z(`strong`,null,D(e.name),1),z(`small`,null,D(e.tier)+` / `+D(e.provider)+` / `+D(A(sd)(e.contextWindow))+` context`,1)]),a(e)?(I(),R(A(tc),{key:0,size:18})):H(``,!0)],10,sB))),128))]),z(`p`,lB,`Models available on `+D(A(Ou)?.id)+`. Provider keys stay on the device.`,1)])]))}}),dB={class:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-title`},fB={class:`dialog-head`},pB={class:`dialog-body`},mB={class:`n`},hB={class:`body`},gB={class:`help-callout`},_B={class:`dialog-foot`},vB={class:`right`},yB=N({__name:`HelpDialog`,setup(e){let t=[{title:`Pick a device, start a session`,body:`Every device in the tree runs dpi-backend. A session gets its own SQLite database on that device, in the directory you choose.`},{title:`Send work, then close the browser`,body:`The device owns the run. Reopening restores committed messages, state and live progress.`},{title:`Change state and fork`,body:`Edit App State by hand or through the agent. Every session and fork on a device shares it.`},{title:`Interrupt deliberately`,body:`Interrupt stops foreground work and owned subagents. Background jobs continue. Stop all includes them.`},{title:`Explore the boundaries`,body:`Queue a follow-up, steer after tools, wait for approval, compact context, reset or inspect raw state.`},{title:`Restart a device`,body:`Its tree dims and shows the restart command. Checkpointed jobs recover on boot. Replay-safe tools may rerun. Other interrupted tools return an error.`}];return(e,n)=>(I(),L(`div`,{class:`scrim`,onClick:n[2]||=ks(e=>A(q).dialog=void 0,[`self`])},[z(`section`,dB,[z(`div`,fB,[n[3]||=z(`div`,null,[z(`span`,{class:`dialog-eyebrow`},`LEARN BY DOING`),z(`h3`,{id:`help-title`},`What makes this durable?`)],-1),z(`button`,{class:`icon-button`,"aria-label":`Close help`,onClick:n[0]||=e=>A(q).dialog=void 0},[B(A(vl),{size:18})])]),z(`div`,pB,[(I(),L(F,null,P(t,(e,t)=>z(`div`,{key:e.title,class:`help-step`},[z(`span`,mB,D(String(t+1).padStart(2,`0`)),1),z(`div`,null,[z(`b`,null,D(e.title),1),z(`div`,hB,D(e.body),1)])])),64)),z(`div`,gB,[B(A(Oc),{size:18}),n[4]||=z(`span`,null,`Durable does not mean exactly-once external effects. Checkpoints protect progress. Tools still need their own idempotency.`,-1)])]),z(`div`,_B,[z(`div`,vB,[z(`button`,{class:`secondary`,type:`button`,onClick:n[1]||=e=>A(q).dialog=void 0},`Close`)])])])]))}}),bB=Wt({needed:!1,busy:!1,error:``}),xB=new Set,SB=e=>{let t=[...xB];xB=new Set;for(let n of t)n(e)},CB=()=>new Promise(e=>xB.add(e));async function wB(e){if(bB.busy||!e)return!1;bB.busy=!0,bB.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?(bB.needed=!1,SB(!0),!0):(bB.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 bB.error=`Cannot reach the hub.`,!1}finally{bB.busy=!1}}var TB=e=>{try{return new URL(e,location.href).pathname===`/api/session`}catch{return e===`/api/session`}};function EB(e){return(async(t,n)=>{let r=()=>e(t,n),i=await r();if(i.status!==401||TB(typeof t==`string`?t:t instanceof URL?t.href:t.url)||n?.body instanceof ReadableStream)return i;bB.needed=!0;let a=await i.text().catch(()=>``);return await CB()?r():new Response(a,{status:i.status,headers:i.headers})})}function DB(){typeof window>`u`||window.__adminFetch||(window.__adminFetch=!0,window.fetch=EB(window.fetch.bind(window)))}var OB={class:`login-veil`,"data-testid":`login-card`},kB=[`disabled`],AB={key:0,class:`message-error`,role:`alert`},jB=[`disabled`],MB=N({__name:`LoginCard`,setup(e){let t=k(``),n=k();async function r(){if(bB.busy||!t.value.trim())return;let e=await wB(t.value.trim());t.value=``,e&&n.value?.blur()}return Vr(()=>void An(()=>n.value?.focus())),(e,i)=>(I(),L(`div`,OB,[z(`form`,{class:`modal login-card`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`login-title`,onSubmit:ks(r,[`prevent`])},[i[2]||=z(`header`,null,[z(`h2`,{id:`login-title`},`Admin token`)],-1),i[3]||=z(`p`,{class:`hint`},[V(` This hub is locked. Sign in with the token from its `),z(`code`,null,`admin.token`),V(` file. `)],-1),i[4]||=z(`label`,{for:`admin-token`},`Admin token`,-1),j(z(`input`,{id:`admin-token`,ref_key:`input`,ref:n,"onUpdate:modelValue":i[0]||=e=>t.value=e,type:`password`,name:`admin-token`,autocomplete:`off`,spellcheck:`false`,placeholder:`adm_…`,"aria-label":`Admin token`,disabled:A(bB).busy,onKeydown:i[1]||=js(e=>A(bB).error=``,[`esc`])},null,40,kB),[[ys,t.value]]),A(bB).error?(I(),L(`p`,AB,D(A(bB).error),1)):H(``,!0),z(`footer`,null,[z(`button`,{class:`primary`,type:`submit`,disabled:A(bB).busy||!t.value.trim()},D(A(bB).busy?`Checking…`:`Sign in`),9,jB)])],32)]))}}),NB={key:0,class:`toast`,role:`status`},PB=N({__name:`Toast`,setup(e){return(e,t)=>(I(),R(bo,{name:`toast`},{default:Hn(()=>[A(q).toast?(I(),L(`div`,NB,[B(A(tc),{size:18}),V(D(A(q).toast),1)])):H(``,!0)]),_:1}))}}),FB={class:`shell`,"data-testid":`app-shell`},IB={key:0,class:`error-banner`,role:`alert`},LB={key:4,class:`welcome`,"data-testid":`welcome-empty`},RB=[`disabled`],zB={class:`welcome-features`},BB={class:`modal path-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`path-title`},VB={class:`full-directory`},HB=N({__name:`App`,setup(e){let t=()=>bu.devices.value.filter(e=>e.status===`online`).length,n=k();function r(){q.dialog={kind:`new-session`,deviceId:K.value?.deviceId}}function i(e){let t=q.dialog?void 0:Sd(e);if(t)return e.preventDefault(),t===`tree`?vd():yd();if(e.key===`Escape`){if(q.dialog){q.dialog.kind===`pair`?n.value?.close():q.dialog=void 0;return}!e.repeat&&!e.isComposing&&Yu.value&&(e.preventDefault(),fd()),q.drawer=!1,q.inspectorOverlay=!1}}function a(e){let t=e.clientX,n=wu.value,r=e=>wu.value=Math.max(220,Math.min(560,n+e.clientX-t)),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)}return Vr(()=>tf()),Vr(()=>{document.addEventListener(`keydown`,i),Hu()}),Wr(()=>{vu.stop(),document.removeEventListener(`keydown`,i)}),(e,i)=>(I(),L(`div`,FB,[B(Ld,{onNewSession:r}),A(q).error?(I(),L(`div`,IB,[B(A(Oc),{size:18}),z(`span`,null,D(A(q).error),1),z(`button`,{class:`icon-button`,"aria-label":`Dismiss error`,onClick:i[0]||=e=>A(q).error=``},`×`)])):H(``,!0),z(`main`,{class:`net-workspace`,style:ge({"--tree-w":`${A(wu)}px`})},[B(up),A(Tu).tree?(I(),L(`div`,{key:0,class:`tree-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize network tree`,onPointerdown:ks(a,[`prevent`])},null,32)):H(``,!0),A(q).drawer?(I(),L(`div`,{key:1,class:`tree-backdrop`,onClick:i[1]||=e=>A(q).drawer=!1})):H(``,!0),A(K)&&A(Ou)&&A(ku)?(I(),L(F,{key:2},[B(TD),A(q).inspectorOverlay?(I(),L(`div`,{key:0,class:`inspector-backdrop`,onClick:i[2]||=e=>A(_d)()})):H(``,!0),(I(),R(fy,{key:`${A(K).deviceId}/${A(K).sessionId}`}))],64)):A(K)&&A(Ou)?(I(),R(FD,{key:3,device:A(Ou)},null,8,[`device`])):(I(),L(`section`,LB,[i[14]||=z(`img`,{class:`welcome-symbol`,src:`/icons/durable-pi.svg`,alt:`Durable Pi`},null,-1),i[15]||=z(`span`,{class:`eyebrow`},`THE DURABLE AGENT NETWORK`,-1),i[16]||=z(`h1`,null,[V(`Close the tab.`),z(`br`),V(`The work continues.`)],-1),i[17]||=z(`p`,null,`Agents run on your devices. This page is only a window into them.`,-1),z(`button`,{class:`primary`,disabled:!t(),onClick:r},[B(A(Xc),{size:18}),V(D(A(bu).devices.value.length?`Create a session`:`Add a device to dpi-network.yaml`),1)],8,RB),z(`div`,zB,[z(`span`,null,[B(A(fc),{size:18}),i[11]||=V(`SQLite on each device`,-1)]),z(`span`,null,[B(A(Cc),{size:18}),i[12]||=V(`Branch any agent`,-1)]),z(`span`,null,[B(A(Vs),{size:18}),i[13]||=V(`Watch from anywhere`,-1)])])]))],4),B(Bd),A(q).dialog?.kind===`pair`?(I(),R(Hz,{key:1,ref_key:`pairWizard`,ref:n,handoff:A(q).dialog.handoff,onClose:i[3]||=e=>A(q).dialog=void 0},null,8,[`handoff`])):H(``,!0),A(q).dialog?.kind===`credentials`?(I(),R(Kz,{key:2,"device-id":A(q).dialog.deviceId,onClose:i[4]||=e=>A(q).dialog=void 0},null,8,[`device-id`])):H(``,!0),A(q).dialog?.kind===`new-session`?(I(),R(tO,{key:3,"device-id":A(q).dialog.deviceId,onClose:i[5]||=e=>A(q).dialog=void 0},null,8,[`device-id`])):A(q).dialog?.kind===`prompt`?(I(),R(rB,{key:4,dialog:A(q).dialog,onClose:i[6]||=e=>A(q).dialog=void 0},null,8,[`dialog`])):A(q).dialog?.kind===`models`?(I(),R(uB,{key:5,onClose:i[7]||=e=>A(q).dialog=void 0})):A(q).dialog?.kind===`path`?(I(),L(`div`,{key:6,class:`modal-backdrop`,onClick:i[10]||=ks(e=>A(q).dialog=void 0,[`self`])},[z(`section`,BB,[z(`header`,null,[i[18]||=z(`h2`,{id:`path-title`},`Working directory`,-1),z(`button`,{class:`icon-button`,"aria-label":`Close working directory`,onClick:i[8]||=e=>A(q).dialog=void 0},[B(A(vl),{size:18})])]),z(`code`,VB,D(A(q).dialog.path),1),z(`footer`,null,[z(`button`,{class:`secondary`,onClick:i[9]||=e=>A(q).dialog=void 0},`Close`)])])])):A(q).dialog?.kind===`help`?(I(),R(yB,{key:7})):H(``,!0),A(bB).needed?(I(),R(MB,{key:8})):H(``,!0),B(PB)]))}});DB();var UB=new URL(window.location.href);if(/^\/pair\/?$/.test(UB.pathname)){let e=cz(UB);e?(UB.search=``,UB.hash=``,window.history.replaceState(window.history.state,``,UB),q.dialog={kind:`pair`,handoff:e}):window.history.replaceState(window.history.state,``,uz(UB))}Fs(HB).mount(`#app`);
|