@huynle/hub 0.10.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/README.md +36 -8
- package/package.json +1 -1
- package/packages/claude-code/package.json +1 -1
- package/packages/claude-code/src/sessions.ts +4 -1
- package/packages/cli/dist/hub-cli.js +851 -466
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/cli.ts +12 -7
- package/packages/cli/src/decisions.ts +52 -4
- package/packages/cli/src/format.ts +9 -0
- package/packages/cli/src/grants-mcp.ts +65 -0
- package/packages/cli/src/mcp-operations.ts +49 -0
- package/packages/cli/src/mcp.ts +26 -4
- package/packages/cli/src/subscriptions-mcp.ts +76 -0
- package/packages/cli/src/team-intake-mcp.ts +2 -1
- package/packages/cli/src/teams-mcp.ts +9 -3
- package/packages/codex/package.json +1 -1
- package/packages/codex/src/sessions.ts +14 -3
- package/packages/node/package.json +1 -1
- package/packages/preset/package.json +1 -1
- package/packages/protocol/package.json +1 -1
- package/packages/protocol/schema/api/v1/_root.json +119 -0
- package/packages/protocol/schema/api/v1/account.json +419 -0
- package/packages/protocol/schema/api/v1/decisions.json +635 -0
- package/packages/protocol/schema/api/v1/discovery.json +110 -0
- package/packages/protocol/schema/api/v1/events.json +679 -0
- package/packages/protocol/schema/api/v1/session-actions.json +660 -0
- package/packages/protocol/schema/api/v1/sessions.json +2055 -0
- package/packages/protocol/schema/api/v1/speech.json +492 -0
- package/packages/protocol/schema/api/v1/unspecified.json +282 -0
- package/packages/protocol/schema/app-delivery/v1.schema.json +67 -5
- package/packages/protocol/schema/app-front/v1.schema.json +7 -3
- package/packages/protocol/src/api-v1.ts +8 -0
- package/packages/protocol/src/index.ts +2 -0
- package/packages/protocol/src/teams.ts +16 -0
- package/packages/protocol/src/voice-recording.ts +39 -2
- package/packages/runtime-openshell/image/entry.sh +3 -1
- package/packages/runtime-openshell/image/start.sh +3 -1
- package/packages/runtime-openshell/package.json +1 -1
- package/packages/runtime-sdk/package.json +1 -1
- package/packages/sdk/package.json +1 -1
- package/packages/sdk/src/app-front.ts +2 -2
- package/packages/sdk/src/ask-fields.ts +76 -0
- package/packages/sdk/src/client.ts +24 -2
- package/packages/sdk/src/envelope.ts +3 -2
- package/packages/sdk/src/index.ts +1 -0
- package/packages/sdk/src/team-intake.ts +6 -0
- package/packages/sdk/src/teams.ts +4 -0
- package/packages/sdk/src/types.ts +36 -4
- package/packages/sdk/src/wake.ts +9 -4
- package/packages/spoke-sdk/package.json +1 -1
- package/src/central/agent/agent-limits.ts +185 -0
- package/src/central/agent/app-decisions.ts +6 -5
- package/src/central/agent/decisions.ts +136 -9
- package/src/central/agent/delivery.ts +164 -22
- package/src/central/agent/errors.ts +2 -1
- package/src/central/agent/events.ts +20 -2
- package/src/central/agent/grant-routes.ts +14 -1
- package/src/central/agent/grants.ts +23 -0
- package/src/central/agent/launch-engine.ts +9 -6
- package/src/central/agent/message-limits.ts +6 -0
- package/src/central/agent/message-routes.ts +33 -6
- package/src/central/agent/messages.ts +7 -0
- package/src/central/agent/placement.ts +4 -2
- package/src/central/agent/read-routes.ts +5 -0
- package/src/central/agent/routes.ts +13 -0
- package/src/central/agent/subscriptions.ts +15 -4
- package/src/central/api-v1.ts +115 -0
- package/src/central/artifacts/store.ts +4 -2
- package/src/central/concierge/board-results.ts +2 -1
- package/src/central/concierge/notifier.ts +4 -2
- package/src/central/config.ts +24 -3
- package/src/central/health/classify.ts +209 -0
- package/src/central/http.ts +380 -36
- package/src/central/recording/export.ts +57 -3
- package/src/central/recording/index.ts +236 -17
- package/src/central/recording/ingest.ts +11 -2
- package/src/central/recording/routes.ts +61 -7
- package/src/central/recording/schema.ts +68 -3
- package/src/central/recording/settings.ts +19 -5
- package/src/central/recording/store.ts +19 -0
- package/src/central/recording/taps.ts +45 -1
- package/src/central/registry.ts +34 -3
- package/src/central/speech/openai.ts +4 -4
- package/src/central/speech/openrouter.ts +4 -4
- package/src/central/speech/provider.ts +32 -1
- package/src/central/speech/service.ts +6 -5
- package/src/central/teams/budgets.ts +144 -0
- package/src/central/teams/hop-stalls.ts +80 -0
- package/src/central/teams/intake.ts +38 -6
- package/src/central/teams/involvement.ts +95 -0
- package/src/central/teams/item-decisions.ts +60 -0
- package/src/central/teams/item-eligibility.ts +35 -0
- package/src/central/teams/item-stalls.ts +87 -0
- package/src/central/teams/loops.ts +40 -0
- package/src/central/teams/policy.ts +10 -0
- package/src/central/teams/progress.ts +154 -0
- package/src/central/teams/routes.ts +2 -0
- package/src/central/teams/seats.ts +3 -3
- package/src/central/teams/staffing.ts +5 -0
- package/src/central/teams/store.ts +20 -1
- package/src/central/teams/validation.ts +16 -2
- package/src/central/workspaces/coordinator.ts +3 -1
- package/src/spoke/hub-tool.ts +26 -11
- package/web/dist/assets/{ArtifactPage-CsPjam8D.js → ArtifactPage-TbFJi59n.js} +1 -1
- package/web/dist/assets/{ArtifactPane-B9weO8L6.js → ArtifactPane-7D-M-Ich.js} +1 -1
- package/web/dist/assets/{ArtifactWorkbench-DzKhMs3l.js → ArtifactWorkbench-DlCLEjut.js} +1 -1
- package/web/dist/assets/{Diagram-CuRIffka.js → Diagram-PvOPetOI.js} +1 -1
- package/web/dist/assets/{Library-rv5DGtrm.js → Library-Cdi83pOV.js} +2 -2
- package/web/dist/assets/{ProfilesDestination-DUuQ9jmd.js → ProfilesDestination-cryC7P6j.js} +1 -1
- package/web/dist/assets/TeamsPage-B4xrlGhp.js +1 -0
- package/web/dist/assets/Watchtower-60B1JX_J.js +2 -0
- package/web/dist/assets/{artifacts-But87Jfo.js → artifacts-DlQEYmDl.js} +1 -1
- package/web/dist/assets/index-DA0gKIzv.js +33 -0
- package/web/dist/assets/{index-rW6LKQj1.css → index-Dyq-jBeE.css} +1 -1
- package/web/dist/assets/live-B2IfKm37.js +5 -0
- package/web/dist/assets/{live-BUofsQpz.css → live-De-kd3eW.css} +1 -1
- package/web/dist/assets/{pane-layout-BW0RdX5a.js → pane-layout-BAuu_pA3.js} +1 -1
- package/web/dist/assets/{renderer2d-DyANQ1WS.js → renderer2d-CsZnF3_o.js} +1 -1
- package/web/dist/assets/{renderer3d-vYYKFAJq.js → renderer3d-BIMA0wFn.js} +2 -2
- package/web/dist/assets/{safe-area-B2Bk__FK.js → safe-area-dtrnw9NF.js} +1 -1
- package/web/dist/assets/{silero-worker-e802lB5T.js → silero-worker-CC2etKS3.js} +1 -1
- package/web/dist/assets/{source-C-De8L3s.js → source-GYayxUxS.js} +1 -1
- package/web/dist/assets/{toast-CXTwTvDw.js → toast-q818mjUF.js} +1 -1
- package/web/dist/index.html +5 -5
- package/web/dist/assets/TeamsPage-D_17MkvN.js +0 -1
- package/web/dist/assets/Watchtower-DlrNOJ7X.js +0 -2
- package/web/dist/assets/index-bX8B6NLo.js +0 -33
- package/web/dist/assets/live-BGLA-peO.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{O as e}from"./live-B2IfKm37.js";var t=`watchtower.layout`,n=1e3,r=[`--accent`,`--blue`,`--violet`,`--orange`,`--ok`,`--warn`];function i(e,t=0){let n=110+26*Math.sqrt(Math.max(1,e))+7*Math.sqrt(Math.max(0,t)),r=Math.PI*(3-Math.sqrt(5));return Array.from({length:e},(t,i)=>{let a=e===1?0:1-i/(e-1)*2,o=Math.sqrt(1-a*a),s=i*r;return[l(Math.cos(s)*o*n),l(a*n*.55),l(Math.sin(s)*o*n)]})}function a(t){let n=new Set(t.nodes.map(e=>e.id)),a=i(t.groups.length,t.groups.reduce((e,t)=>e+t.sections.reduce((e,t)=>e+t.members.length,0),0));return t.groups.map((t,i)=>{let o=[];n.has(t.id)&&o.push(t.id);for(let e of t.sections)e.id!==void 0&&n.has(e.id)&&o.push(e.id),o.push(...e.members);let s=t.machine===void 0?r[i%r.length]:e[t.machine%e.length];return{id:t.id,label:t.label,color:s,center:a[i],members:o}})}function o(e){let t=new Map;for(let n of e.links)n.kind!==`structure`&&n.kind!==`policy`&&(t.set(n.source,(t.get(n.source)??0)+n.count),t.set(n.target,(t.get(n.target)??0)+n.count));return t}function s(e,t){let n=new Set,r=new Set(e.groups.map(e=>e.id));for(let t of e.nodes)(t.kind===`hub`||t.kind===`user`||t.kind===`app`||t.kind===`role`||r.has(t.id)||t.match)&&n.add(t.id);let i=o(e),a=e.nodes.filter(e=>!n.has(e.id)&&e.kind!==`role`);a.sort((e,t)=>(i.get(t.id)??0)-(i.get(e.id)??0)||(e.id<t.id?-1:+(e.id>t.id)));for(let e of a.slice(0,Math.max(0,t.max)))n.add(e.id);for(let e of t.extra??[])n.add(e);return n}var c=e=>e.kind===`role`&&e.vacant?`${e.label} · vacant`:e.label,l=e=>Math.round(e*10)/10,u=e=>typeof e==`number`&&Number.isFinite(e);function d(e){let t=new Map;if(!e)return t;let n;try{n=JSON.parse(e)}catch{return t}if(typeof n!=`object`||!n||Array.isArray(n))return t;let{v:r,p:i}=n;if(r!==1||typeof i!=`object`||!i||Array.isArray(i))return t;for(let[e,n]of Object.entries(i)){if(t.size>=1e3)break;if(!Array.isArray(n)||n.length!==3)continue;let[r,i,a]=n;u(r)&&u(i)&&u(a)&&t.set(e,[r,i,a])}return t}function f(e,t,r=n){let i={},a=0;for(let n of[e,t])for(let[e,t]of n){if(a>=r)break;e in i||!t.every(u)||(i[e]=[l(t[0]),l(t[1]),l(t[2])],a++)}return JSON.stringify({v:1,p:i})}function p(e,t){let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619);let r=(n>>>0)%1e3/1e3,i=(Math.imul(n,2654435761)>>>0)%1e3/1e3,a=r*Math.PI*2,o=i*2-1,s=Math.sqrt(1-o*o),c=t*(.6+.4*r);return[Math.cos(a)*s*c,o*c,Math.sin(a)*s*c]}function m(e,t){let n=new Map,r=new Set,i=new Map;for(let t of a(e))for(let e of t.members)i.set(e,t);let o=new Map,s=new Map;for(let t of e.links)t.kind===`structure`&&(o.get(t.target)??o.set(t.target,[]).get(t.target)).push(t.source),(s.get(t.target)??s.set(t.target,[]).get(t.target)).push(t.source),(s.get(t.source)??s.set(t.source,[]).get(t.source)).push(t.target);n.set(`hub`,[0,0,0]);for(let r of e.nodes){if(r.id===`hub`)continue;let e=t.get(r.id);e&&n.set(r.id,e)}let c=new Set(e.groups.map(e=>e.id)),u=[...e.nodes.filter(e=>c.has(e.id)),...e.nodes.filter(e=>!c.has(e.id))];for(let e of u){if(n.has(e.id))continue;r.add(e.id);let t=[...o.get(e.id)??[],...s.get(e.id)??[]].find(e=>e!==`hub`&&n.has(e)),a=i.get(e.id),c=t===void 0?a?.center:n.get(t),u=p(e.id,t===void 0?a?24:40:14),d=c??[0,0,0];n.set(e.id,[l(d[0]+u[0]),l(d[1]+u[1]),l(d[2]+u[2])])}return{positions:n,fresh:r}}function h(e,t){let n=new Map,r=[],i=e=>r.some(t=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h),a=[...e.filter(e=>e.pinned),...e.filter(e=>!e.pinned)];for(let e of a)for(let a of e.texts){let o=t(a,e),s={x:e.x-o/2,y:e.y,w:o,h:e.h};if(e.pinned||!i(s)){r.push(s),n.set(e.id,{text:a,box:s});break}}return n}var g=8,_=900;function v(e){let t={top:0,right:0,bottom:0,left:0},n=e.closest(`.wt-stage`);if(!n)return t;let r=e.getBoundingClientRect();if(!r.height)return t;let i=n.querySelector(`.wt-dock`)?.getBoundingClientRect(),a=n.querySelector(`.wt-chips`)?.getBoundingClientRect(),o=r.width>=_?n.querySelector(`.wt-pop-legend`)?.getBoundingClientRect():void 0,s=o&&o.width?Math.max(0,o.right-r.left+g):0,c=i&&i.height?Math.max(0,r.bottom-i.top+g):0,l=a&&a.height?Math.max(0,a.bottom-r.top+g):0;return{top:Math.min(l,r.height/3),right:0,bottom:Math.min(c,r.height/3),left:Math.min(s,r.width/3)}}export{c as a,a as c,s as i,m as l,t as n,d as o,o as r,h as s,v as t,f as u};
|
|
@@ -8,4 +8,4 @@ if(typeof n<`u`)return n.apply(this,arguments);throw Error(`Dynamic require of "
|
|
|
8
8
|
`);return e[0]==`Error`&&e.shift(),Et(e),q.Wa=Tt(),q.$a=e,q.Wa}function Dt(e,t,n){if(e>>>=0,t>>>=0,q.Wa==e)var r=q.$a;else(r=Error().stack.toString().split(`
|
|
9
9
|
`))[0]==`Error`&&r.shift(),Et(r);for(var i=3;r[i]&&Tt()!=e;)++i;for(e=0;e<n&&r[e+i];++e)E()[t+4*e>>>2>>>0]=Tt();return e}var Ot,kt={},At=()=>{if(!Ot){var e,t={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(typeof navigator==`object`&&navigator.languages&&navigator.languages[0]||`C`).replace(`-`,`_`)+`.UTF-8`,_:`./this.program`};for(e in kt)kt[e]===void 0?delete t[e]:t[e]=kt[e];var n=[];for(e in t)n.push(`${e}=${t[e]}`);Ot=n}return Ot};function jt(e,t){if(s)return I(19,1,e,t);e>>>=0,t>>>=0;var n,r=0,i=0;for(n of At()){var a=t+r;D()[e+i>>>2>>>0]=a,r+=G(n,a,1/0)+1,i+=4}return 0}var Mt=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);127>=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t};function Nt(e,t){if(s)return I(20,1,e,t);e>>>=0,t>>>=0;var n=At();for(var r of(D()[e>>>2>>>0]=n.length,e=0,n))e+=Mt(r)+1;return D()[t>>>2>>>0]=e,0}function Pt(e){return s?I(21,1,e):52}function Ft(e,t,n,r){return s?I(22,1,e,t,n,r):52}function It(e,t,n,r){return s?I(23,1,e,t,n,r):70}var Y=[null,[],[]];function X(e,t,n,r){if(s)return I(24,1,e,t,n,r);t>>>=0,n>>>=0,r>>>=0;for(var i=0,a=0;a<n;a++){var o=D()[t>>>2>>>0],c=D()[t+4>>>2>>>0];t+=8;for(var l=0;l<c;l++){var u=e,d=T()[o+l>>>0],f=Y[u];d===0||d===10?((u===1?ae:w)(Fe(f)),f.length=0):f.push(d)}i+=c}return D()[r>>>2>>>0]=i,0}s||function(){for(var e=r.numThreads-1;e--;)z();N.push(()=>{pe++,function(e){s?e():Promise.all(L.map(Te)).then(e)}(()=>me())})}(),s||(h=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),A()),r.wasmBinary&&(m=r.wasmBinary),r.stackSave=()=>Yt(),r.stackRestore=e=>qt(e),r.stackAlloc=e=>Jt(e),r.setValue=function(e,t,n=`i8`){switch(n.endsWith(`*`)&&(n=`*`),n){case`i1`:case`i8`:ce()[e>>>0]=t;break;case`i16`:le()[e>>>1>>>0]=t;break;case`i32`:E()[e>>>2>>>0]=t;break;case`i64`:S[e>>>3]=BigInt(t);break;case`float`:O()[e>>>2>>>0]=t;break;case`double`:k()[e>>>3>>>0]=t;break;case`*`:D()[e>>>2>>>0]=t;break;default:M(`invalid type for setValue: ${n}`)}},r.getValue=function(e,t=`i8`){switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:case`i8`:return ce()[e>>>0];case`i16`:return le()[e>>>1>>>0];case`i32`:return E()[e>>>2>>>0];case`i64`:return S[e>>>3];case`float`:return O()[e>>>2>>>0];case`double`:return k()[e>>>3>>>0];case`*`:return D()[e>>>2>>>0];default:M(`invalid type for getValue: ${t}`)}},r.UTF8ToString=Ie,r.stringToUTF8=G,r.lengthBytesUTF8=Mt;var Lt=[ve,ye,Me,Le,Re,ze,B,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,ct,lt,ft,jt,Nt,Pt,Ft,It,X],Rt={853836:(e,t,n,i,a)=>{if(r===void 0||!r.Sa)return 1;if((e=Ie(Number(e>>>0))).startsWith(`./`)&&(e=e.substring(2)),!(e=r.Sa.get(e)))return 2;if(t=Number(t>>>0),n=Number(n>>>0),i=Number(i>>>0),t+n>e.byteLength)return 3;try{let o=e.subarray(t,t+n);switch(a){case 0:T().set(o,i>>>0);break;case 1:r.hb?r.hb(i,o):r.jb(i,o);break;default:return 4}return 0}catch{return 4}},854660:()=>typeof wasmOffsetConverter<`u`};function zt(){return typeof wasmOffsetConverter<`u`}var Z=await async function(){function e(e,t){return Z=e.exports,Z=function(){var e=Z,t=e=>()=>e()>>>0,n=e=>t=>e(t)>>>0;return(e=Object.assign({},e)).Aa=t(e.Aa),e.Ca=n(e.Ca),e.Oa=n(e.Oa),e.Pa=t(e.Pa),e.__cxa_get_exception_ptr=n(e.__cxa_get_exception_ptr),e}(),Se.push(Z.Da),Ee=Z.Ea,g=t,me(),Z}pe++;var t=he();if(r.instantiateWasm)return new Promise(n=>{r.instantiateWasm(t,(t,r)=>{n(e(t,r))})});if(s)return new Promise(t=>{ne=n=>{t(e(new WebAssembly.Instance(n,he()),n))}});fe??=r.locateFile?r.locateFile?r.locateFile(`ort-wasm-simd-threaded.wasm`,p):p+`ort-wasm-simd-threaded.wasm`:new URL(`/assets/ort-wasm-simd-threaded-CxTQ5xH-.wasm`,``+import.meta.url).href;try{var i=await async function(e){var t=fe;if(!m&&typeof WebAssembly.instantiateStreaming==`function`&&!se(t))try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){w(`wasm streaming compile failed: ${e}`),w(`falling back to ArrayBuffer instantiation`)}return async function(e,t){try{var n=await async function(e){if(!m)try{var t=await c(e);return new Uint8Array(t)}catch{}if(e==fe&&m)e=new Uint8Array(m);else{if(!l)throw`both async and sync fetching of the wasm failed`;e=l(e)}return e}(e);return await WebAssembly.instantiate(n,t)}catch(e){w(`failed to asynchronously prepare wasm: ${e}`),M(e)}}(t,e)}(t);return e(i.instance,i.module)}catch(e){return n(e),Promise.reject(e)}}();r._OrtInit=(e,t)=>(r._OrtInit=Z.aa)(e,t),r._OrtGetLastError=(e,t)=>(r._OrtGetLastError=Z.ba)(e,t),r._OrtCreateSessionOptions=(e,t,n,i,a,o,s,c,l,u)=>(r._OrtCreateSessionOptions=Z.ca)(e,t,n,i,a,o,s,c,l,u),r._OrtAppendExecutionProvider=(e,t,n,i,a)=>(r._OrtAppendExecutionProvider=Z.da)(e,t,n,i,a),r._OrtAddFreeDimensionOverride=(e,t,n)=>(r._OrtAddFreeDimensionOverride=Z.ea)(e,t,n),r._OrtAddSessionConfigEntry=(e,t,n)=>(r._OrtAddSessionConfigEntry=Z.fa)(e,t,n),r._OrtReleaseSessionOptions=e=>(r._OrtReleaseSessionOptions=Z.ga)(e),r._OrtCreateSession=(e,t,n)=>(r._OrtCreateSession=Z.ha)(e,t,n),r._OrtReleaseSession=e=>(r._OrtReleaseSession=Z.ia)(e),r._OrtGetInputOutputCount=(e,t,n)=>(r._OrtGetInputOutputCount=Z.ja)(e,t,n),r._OrtGetInputOutputMetadata=(e,t,n,i)=>(r._OrtGetInputOutputMetadata=Z.ka)(e,t,n,i),r._OrtFree=e=>(r._OrtFree=Z.la)(e),r._OrtCreateTensor=(e,t,n,i,a,o)=>(r._OrtCreateTensor=Z.ma)(e,t,n,i,a,o),r._OrtGetTensorData=(e,t,n,i,a)=>(r._OrtGetTensorData=Z.na)(e,t,n,i,a),r._OrtReleaseTensor=e=>(r._OrtReleaseTensor=Z.oa)(e),r._OrtCreateRunOptions=(e,t,n,i)=>(r._OrtCreateRunOptions=Z.pa)(e,t,n,i),r._OrtAddRunConfigEntry=(e,t,n)=>(r._OrtAddRunConfigEntry=Z.qa)(e,t,n),r._OrtReleaseRunOptions=e=>(r._OrtReleaseRunOptions=Z.ra)(e),r._OrtCreateBinding=e=>(r._OrtCreateBinding=Z.sa)(e),r._OrtBindInput=(e,t,n)=>(r._OrtBindInput=Z.ta)(e,t,n),r._OrtBindOutput=(e,t,n,i)=>(r._OrtBindOutput=Z.ua)(e,t,n,i),r._OrtClearBoundOutputs=e=>(r._OrtClearBoundOutputs=Z.va)(e),r._OrtReleaseBinding=e=>(r._OrtReleaseBinding=Z.wa)(e),r._OrtRunWithBinding=(e,t,n,i,a)=>(r._OrtRunWithBinding=Z.xa)(e,t,n,i,a),r._OrtRun=(e,t,n,i,a,o,s,c)=>(r._OrtRun=Z.ya)(e,t,n,i,a,o,s,c),r._OrtEndProfiling=e=>(r._OrtEndProfiling=Z.za)(e);var Bt=()=>(Bt=Z.Aa)();r._free=e=>(r._free=Z.Ba)(e),r._malloc=e=>(r._malloc=Z.Ca)(e);var Vt=(e,t,n,r,i,a)=>(Vt=Z.Fa)(e,t,n,r,i,a),Q=()=>(Q=Z.Ga)(),$=(e,t,n,r,i)=>($=Z.Ha)(e,t,n,r,i),Ht=e=>(Ht=Z.Ia)(e),Ut=e=>(Ut=Z.Ja)(e),Wt=(e,t)=>(Wt=Z.Ka)(e,t),Gt=()=>(Gt=Z.La)(),Kt=(e,t)=>(Kt=Z.Ma)(e,t),qt=e=>(qt=Z.Na)(e),Jt=e=>(Jt=Z.Oa)(e),Yt=()=>(Yt=Z.Pa)();return function e(){if(0<pe)j=e;else if(s)t(r),de();else{for(;0<N.length;)N.shift()(r);0<pe?j=e:(r.calledRun=!0,oe||(de(),t(r)))}}(),r.PTR_SIZE=4,i},Pe=Ne,Fe=globalThis.self?.name?.startsWith(`em-pthread`),Fe&&Ne()}),Le,Re,ze,B,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe=l(()=>{Ee(),Le=typeof location>`u`?void 0:location.origin,Re=import.meta.url>`file:`&&import.meta.url<`file;`,ze=()=>Re?new URL(new URL(`ort.wasm.bundle.min.mjs`,import.meta.url).href,Le).href:import.meta.url,B=ze(),Be=()=>{if(B&&!B.startsWith(`blob:`))return B.substring(0,B.lastIndexOf(`/`)+1)},Ve=(e,t)=>{try{let n=t??B;return(n?new URL(e,n):new URL(e)).origin===Le}catch{return!1}},He=(e,t)=>{let n=t??B;try{return(n?new URL(e,n):new URL(e)).href}catch{return}},Ue=(e,t)=>`${t??`./`}${e}`,We=async e=>{let t=await(await fetch(e,{credentials:`same-origin`})).blob();return URL.createObjectURL(t)},Ge=async e=>(await import(
|
|
10
10
|
/*webpackIgnore:true*/
|
|
11
|
-
e)).default,Ke=(je(),f(De)).default,qe=async()=>{if(!B)throw Error(`Failed to load proxy worker: cannot determine the script source URL.`);if(Ve(B))return[void 0,Ke()];let e=await We(B);return[e,Ke(e)]},Je=(Ie(),f(Me)).default,Ye=async(e,t,n,r)=>{let i=Je&&!(e||t);if(i){if(B)i=Ve(B);else if(r&&!n)i=!0;else throw Error(`cannot determine the script source URL.`)}if(i)return[void 0,Je];{let r=`ort-wasm-simd-threaded.mjs`,i=e??He(r,t),a=n&&i&&!Ve(i,t),o=a?await We(i):i??Ue(r,t);return[a?o:void 0,await Ge(o)]}}}),Ze,Qe,V,$e,et,tt,nt,rt,H,it=l(()=>{Xe(),Qe=!1,V=!1,$e=!1,et=()=>{if(typeof SharedArrayBuffer>`u`)return!1;try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},tt=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},nt=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},rt=async e=>{if(Qe)return Promise.resolve();if(V)throw Error(`multiple calls to 'initializeWebAssembly()' detected.`);if($e)throw Error(`previous call to 'initializeWebAssembly()' failed.`);V=!0;let t=e.initTimeout,n=e.numThreads;if(e.simd!==!1){if(e.simd===`relaxed`){if(!nt())throw Error(`Relaxed WebAssembly SIMD is not supported in the current environment.`)}else if(!tt())throw Error(`WebAssembly SIMD is not supported in the current environment.`)}let r=et();n>1&&!r&&(typeof self<`u`&&!self.crossOriginIsolated&&console.warn(`env.wasm.numThreads is set to `+n+`, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info.`),console.warn(`WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading.`),e.numThreads=n=1);let i=e.wasmPaths,a=typeof i==`string`?i:void 0,o=i?.mjs,s=o?.href??o,c=i?.wasm,l=c?.href??c,u=e.wasmBinary,[d,f]=await Ye(s,a,n>1,!!u||!!l),p=!1,m=[];if(t>0&&m.push(new Promise(e=>{setTimeout(()=>{p=!0,e()},t)})),m.push(new Promise((e,t)=>{let r={numThreads:n};if(u)r.wasmBinary=u;else if(l||a)r.locateFile=e=>l??a+e;else if(s&&s.indexOf(`blob:`)!==0)r.locateFile=e=>new URL(e,s).href;else if(d){let e=Be();e&&(r.locateFile=t=>e+t)}f(r).then(t=>{V=!1,Qe=!0,Ze=t,e(),d&&URL.revokeObjectURL(d)},e=>{V=!1,$e=!0,t(e)})})),await Promise.race(m),p)throw Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},H=()=>{if(Qe&&Ze)return Ze;throw Error(`WebAssembly is not initialized yet.`)}}),U,at,W,ot=l(()=>{it(),U=(e,t)=>{let n=H(),r=n.lengthBytesUTF8(e)+1,i=n._malloc(r);return n.stringToUTF8(e,i,r),t.push(i),i},at=(e,t,n,r)=>{if(typeof e==`object`&&e){if(n.has(e))throw Error(`Circular reference in options`);n.add(e)}Object.entries(e).forEach(([e,i])=>{let a=t?t+e:e;if(typeof i==`object`)at(i,a+`.`,n,r);else if(typeof i==`string`||typeof i==`number`)r(a,i.toString());else if(typeof i==`boolean`)r(a,i?`1`:`0`);else throw Error(`Can't handle extra config type: ${typeof i}`)})},W=e=>{let t=H(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetLastError(r,r+n);let i=Number(t.getValue(r,n===4?`i32`:`i64`)),a=t.getValue(r+n,`*`),o=a?t.UTF8ToString(a):``;throw Error(`${e} ERROR_CODE: ${i}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(n)}}}),st,ct=l(()=>{it(),ot(),st=e=>{let t=H(),n=0,r=[],i=e||{};try{if(e?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof e.logSeverityLevel!=`number`||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!=`number`||!Number.isInteger(e.logVerbosityLevel))throw Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(i.terminate=!1);let a=0;return e?.tag!==void 0&&(a=U(e.tag,r)),n=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,a),n===0&&W(`Can't create run options.`),e?.extra!==void 0&&at(e.extra,``,/* @__PURE__ */ new WeakSet,(e,i)=>{let a=U(e,r),o=U(i,r);t._OrtAddRunConfigEntry(n,a,o)!==0&&W(`Can't set a run config entry: ${e} - ${i}.`)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseRunOptions(n),r.forEach(e=>t._free(e)),e}}}),lt,ut,dt,ft,G,pt,mt=l(()=>{it(),ot(),lt=e=>{switch(e){case`disabled`:return 0;case`basic`:return 1;case`extended`:return 2;case`layout`:return 3;case`all`:return 99;default:throw Error(`unsupported graph optimization level: ${e}`)}},ut=e=>{switch(e){case`sequential`:return 0;case`parallel`:return 1;default:throw Error(`unsupported execution mode: ${e}`)}},dt=e=>{e.extra||={},e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||=`1`,e.executionProviders&&e.executionProviders.some(e=>(typeof e==`string`?e:e.name)===`webgpu`)&&(e.enableMemPattern=!1)},ft=(e,t,n,r)=>{let i=U(t,r),a=U(n,r);H()._OrtAddSessionConfigEntry(e,i,a)!==0&&W(`Can't set a session config entry: ${t} - ${n}.`)},G=async(e,t,n)=>{for(let r of t){let t=typeof r==`string`?r:r.name,i=[];switch(t){case`webnn`:if(t=`WEBNN`,typeof r!=`string`){let t=r?.deviceType;t&&ft(e,`deviceType`,t,n)}break;case`webgpu`:if(t=`JS`,typeof r!=`string`){let t=r;if(t?.preferredLayout){if(t.preferredLayout!==`NCHW`&&t.preferredLayout!==`NHWC`)throw Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${t.preferredLayout}`);ft(e,`preferredLayout`,t.preferredLayout,n)}}break;case`wasm`:case`cpu`:continue;default:throw Error(`not supported execution provider: ${t}`)}let a=U(t,n),o=i.length,s=0,c=0;if(o>0){s=H()._malloc(o*H().PTR_SIZE),n.push(s),c=H()._malloc(o*H().PTR_SIZE),n.push(c);for(let e=0;e<o;e++)H().setValue(s+e*H().PTR_SIZE,i[e][0],`*`),H().setValue(c+e*H().PTR_SIZE,i[e][1],`*`)}await H()._OrtAppendExecutionProvider(e,a,s,c,o)!==0&&W(`Can't append execution provider: ${t}.`)}},pt=async e=>{let t=H(),n=0,r=[],i=e||{};dt(i);try{let e=lt(i.graphOptimizationLevel??`all`),a=ut(i.executionMode??`sequential`),o=typeof i.logId==`string`?U(i.logId,r):0,s=i.logSeverityLevel??2;if(!Number.isInteger(s)||s<0||s>4)throw Error(`log severity level is not valid: ${s}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw Error(`log verbosity level is not valid: ${c}`);let l=typeof i.optimizedModelFilePath==`string`?U(i.optimizedModelFilePath,r):0;if(n=t._OrtCreateSessionOptions(e,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,s,c,l),n===0&&W(`Can't create session options.`),i.executionProviders&&await G(n,i.executionProviders,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!=`boolean`)throw Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);ft(n,`enableGraphCapture`,i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[e,a]of Object.entries(i.freeDimensionOverrides)){if(typeof e!=`string`)throw Error(`free dimension override name must be a string: ${e}`);if(typeof a!=`number`||!Number.isInteger(a)||a<0)throw Error(`free dimension override value must be a non-negative integer: ${a}`);let i=U(e,r);t._OrtAddFreeDimensionOverride(n,i,a)!==0&&W(`Can't set a free dimension override: ${e} - ${a}.`)}return i.extra!==void 0&&at(i.extra,``,/* @__PURE__ */ new WeakSet,(e,t)=>{ft(n,e,t,r)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseSessionOptions(n)!==0&&W(`Can't release session options.`),r.forEach(e=>t._free(e)),e}}}),ht,gt,K,_t,vt,yt,bt,xt,St=l(()=>{ht=e=>{switch(e){case`int8`:return 3;case`uint8`:return 2;case`bool`:return 9;case`int16`:return 5;case`uint16`:return 4;case`int32`:return 6;case`uint32`:return 12;case`float16`:return 10;case`float32`:return 1;case`float64`:return 11;case`string`:return 8;case`int64`:return 7;case`uint64`:return 13;case`int4`:return 22;case`uint4`:return 21;default:throw Error(`unsupported data type: ${e}`)}},gt=e=>{switch(e){case 3:return`int8`;case 2:return`uint8`;case 9:return`bool`;case 5:return`int16`;case 4:return`uint16`;case 6:return`int32`;case 12:return`uint32`;case 10:return`float16`;case 1:return`float32`;case 11:return`float64`;case 8:return`string`;case 7:return`int64`;case 13:return`uint64`;case 22:return`int4`;case 21:return`uint4`;default:throw Error(`unsupported data type: ${e}`)}},K=(e,t)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],r=typeof t==`number`?t:t.reduce((e,t)=>e*t,1);return n>0?Math.ceil(r*n):void 0},_t=e=>{switch(e){case`float16`:return typeof Float16Array<`u`&&Float16Array.from?Float16Array:Uint16Array;case`float32`:return Float32Array;case`uint8`:return Uint8Array;case`int8`:return Int8Array;case`uint16`:return Uint16Array;case`int16`:return Int16Array;case`int32`:return Int32Array;case`bool`:return Uint8Array;case`float64`:return Float64Array;case`uint32`:return Uint32Array;case`int64`:return BigInt64Array;case`uint64`:return BigUint64Array;default:throw Error(`unsupported type: ${e}`)}},vt=e=>{switch(e){case`verbose`:return 0;case`info`:return 1;case`warning`:return 2;case`error`:return 3;case`fatal`:return 4;default:throw Error(`unsupported logging level: ${e}`)}},yt=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,bt=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint64`||e===`int8`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,xt=e=>{switch(e){case`none`:return 0;case`cpu`:return 1;case`cpu-pinned`:return 2;case`texture`:return 3;case`gpu-buffer`:return 4;case`ml-tensor`:return 5;default:throw Error(`unsupported data location: ${e}`)}}}),Ct,wt=l(()=>{Ee(),Ct=async e=>{if(typeof e==`string`){let t=await fetch(e);if(!t.ok)throw Error(`failed to load external data file: ${e}`);let n=t.headers.get(`Content-Length`),r=n?parseInt(n,10):0;if(r<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw Error(`failed to load external data file: ${e}, no response body.`);let n=t.body.getReader(),i;try{i=new ArrayBuffer(r)}catch(e){if(e instanceof RangeError){let e=Math.ceil(r/65536);i=new WebAssembly.Memory({initial:e,maximum:e}).buffer}else throw e}let a=0;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=t.byteLength;new Uint8Array(i,a,r).set(t),a+=r}return new Uint8Array(i,0,r)}}return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),Tt,q,Et,J,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It=l(()=>{z(),ct(),mt(),St(),it(),ot(),wt(),Tt=(e,t)=>{H()._OrtInit(e,t)!==0&&W(`Can't initialize onnxruntime.`)},q=async e=>{Tt(e.wasm.numThreads,vt(e.logLevel))},Et=async(e,t)=>{H().asyncInit?.();let n=e.webgpu.adapter;if(t===`webgpu`){if(typeof navigator>`u`||!navigator.gpu)throw Error(`WebGPU is not supported in current environment`);if(n){if(typeof n.limits!=`object`||typeof n.features!=`object`||typeof n.requestDevice!=`function`)throw Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let t=e.webgpu.powerPreference;if(t!==void 0&&t!==`low-power`&&t!==`high-performance`)throw Error(`Invalid powerPreference setting: "${t}"`);let r=e.webgpu.forceFallbackAdapter;if(r!==void 0&&typeof r!=`boolean`)throw Error(`Invalid forceFallbackAdapter setting: "${r}"`);if(n=await navigator.gpu.requestAdapter({powerPreference:t,forceFallbackAdapter:r}),!n)throw Error(`Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.`)}}if(t===`webnn`&&(typeof navigator>`u`||!navigator.ml))throw Error(`WebNN is not supported in current environment`)},J=/* @__PURE__ */ new Map,Dt=e=>{let t=H(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetInputOutputCount(e,r,r+n)!==0&&W(`Can't get session input/output count.`);let i=n===4?`i32`:`i64`;return[Number(t.getValue(r,i)),Number(t.getValue(r+n,i))]}finally{t.stackRestore(n)}},Ot=(e,t)=>{let n=H(),r=n.stackSave(),i=0;try{let r=n.PTR_SIZE,a=n.stackAlloc(2*r);n._OrtGetInputOutputMetadata(e,t,a,a+r)!==0&&W(`Can't get session input/output metadata.`);let o=Number(n.getValue(a,`*`));i=Number(n.getValue(a+r,`*`));let s=n.HEAP32[i/4];if(s===0)return[o,0];let c=n.HEAPU32[i/4+1],l=[];for(let e=0;e<c;e++){let t=Number(n.getValue(i+8+e*r,`*`));l.push(t===0?Number(n.getValue(i+8+(e+c)*r,`*`)):n.UTF8ToString(t))}return[o,s,l]}finally{n.stackRestore(r),i!==0&&n._OrtFree(i)}},kt=e=>{let t=H(),n=t._malloc(e.byteLength);if(n===0)throw Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,n),[n,e.byteLength]},At=async(e,t)=>{let n,r,i=H();Array.isArray(e)?[n,r]=e:e.buffer===i.HEAPU8.buffer?[n,r]=[e.byteOffset,e.byteLength]:[n,r]=kt(e);let a=0,o=0,s=[],c=[],l=[];try{if([o,s]=await pt(t),t?.externalData&&i.mountExternalData){let e=[];for(let n of t.externalData){let t=typeof n==`string`?n:n.path;e.push(Ct(typeof n==`string`?n:n.data).then(e=>{i.mountExternalData(t,e)}))}await Promise.all(e)}for(let e of t?.executionProviders??[])if((typeof e==`string`?e:e.name)===`webnn`){if(i.shouldTransferToMLTensor=!1,typeof e!=`string`){let t=e,n=t?.context,r=t?.gpuDevice,a=t?.deviceType,o=t?.powerPreference;i.currentContext=n||(r?await i.webnnCreateMLContext(r):await i.webnnCreateMLContext({deviceType:a,powerPreference:o}))}else i.currentContext=await i.webnnCreateMLContext();break}a=await i._OrtCreateSession(n,r,o),i.webgpuOnCreateSession?.(a),a===0&&W(`Can't create a session.`),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(a,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[e,u]=Dt(a),d=!!t?.enableGraphCapture,f=[],p=[],m=[],h=[];for(let t=0;t<e;t++){let[e,n,r]=Ot(a,t);e===0&&W(`Can't get an input name.`),c.push(e);let o=i.UTF8ToString(e);f.push(o),m.push(n===0?{name:o,isTensor:!1}:{name:o,isTensor:!0,type:gt(n),shape:r})}for(let t=0;t<u;t++){let[n,r,o]=Ot(a,t+e);n===0&&W(`Can't get an output name.`),l.push(n);let s=i.UTF8ToString(n);p.push(s),h.push(r===0?{name:s,isTensor:!1}:{name:s,isTensor:!0,type:gt(r),shape:o})}return J.set(a,[a,c,l,null,d,!1]),[a,f,p,m,h]}catch(e){throw c.forEach(e=>i._OrtFree(e)),l.forEach(e=>i._OrtFree(e)),a!==0&&i._OrtReleaseSession(a)!==0&&W(`Can't release session.`),e}finally{i._free(n),o!==0&&i._OrtReleaseSessionOptions(o)!==0&&W(`Can't release session options.`),s.forEach(e=>i._free(e)),i.unmountExternalData?.()}},jt=e=>{let t=H(),n=J.get(e);if(!n)throw Error(`cannot release session. invalid session id: ${e}`);let[r,i,a,o,s]=n;o&&(s&&t._OrtClearBoundOutputs(o.handle)!==0&&W(`Can't clear bound outputs.`),t._OrtReleaseBinding(o.handle)!==0&&W(`Can't release IO binding.`)),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),i.forEach(e=>t._OrtFree(e)),a.forEach(e=>t._OrtFree(e)),t._OrtReleaseSession(r)!==0&&W(`Can't release session.`),J.delete(e)},Mt=async(e,t,n,r,i,a,o=!1)=>{if(!e){t.push(0);return}let s=H(),c=s.PTR_SIZE,l=e[0],u=e[1],d=e[3],f=d,p,m;if(l===`string`&&(d===`gpu-buffer`||d===`ml-tensor`))throw Error(`String tensor is not supported on GPU.`);if(o&&d!==`gpu-buffer`)throw Error(`External buffer must be provided for input/output index ${a} when enableGraphCapture is true.`);if(d===`gpu-buffer`){let t=e[2].gpuBuffer;m=K(ht(l),u);{let e=s.jsepRegisterBuffer;if(!e)throw Error(`Tensor location "gpu-buffer" is not supported without using WebGPU.`);p=e(r,a,t,m)}}else if(d===`ml-tensor`){let t=e[2].mlTensor;m=K(ht(l),u);let n=s.webnnRegisterMLTensor;if(!n)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);p=n(r,t,ht(l),u)}else{let t=e[2];if(Array.isArray(t)){m=c*t.length,p=s._malloc(m),n.push(p);for(let e=0;e<t.length;e++){if(typeof t[e]!=`string`)throw TypeError(`tensor data at index ${e} is not a string`);s.setValue(p+e*c,U(t[e],n),`*`)}}else{let e=s.webnnIsGraphInput,a=s.webnnIsGraphOutput;if(l!==`string`&&e&&a){let o=s.UTF8ToString(i);if(e(r,o)||a(r,o)){let e=ht(l);m=K(e,u),f=`ml-tensor`;let n=s.webnnCreateTemporaryTensor,i=s.webnnUploadTensor;if(!n||!i)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);let a=await n(r,e,u);i(a,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),p=a}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}}let h=s.stackSave(),g=s.stackAlloc(4*u.length);try{u.forEach((e,t)=>s.setValue(g+t*c,e,c===4?`i32`:`i64`));let e=s._OrtCreateTensor(ht(l),p,m,g,u.length,xt(f));e===0&&W(`Can't create tensor for input/output. session=${r}, index=${a}.`),t.push(e)}finally{s.stackRestore(h)}},Nt=async(e,t,n,r,i,a)=>{let o=H(),s=o.PTR_SIZE,c=J.get(e);if(!c)throw Error(`cannot run inference. invalid session id: ${e}`);let l=c[0],u=c[1],d=c[2],f=c[3],p=c[4];c[5];let m=t.length,h=r.length,g=0,_=[],v=[],y=[],ee=[],b=o.stackSave(),te=o.stackAlloc(m*s),x=o.stackAlloc(m*s),S=o.stackAlloc(h*s),C=o.stackAlloc(h*s);try{[g,_]=st(a),F(`wasm prepareInputOutputTensor`);for(let r=0;r<m;r++)await Mt(n[r],v,ee,e,u[t[r]],t[r],p);for(let t=0;t<h;t++)await Mt(i[t],y,ee,e,d[r[t]],m+r[t],p);I(`wasm prepareInputOutputTensor`);for(let e=0;e<m;e++)o.setValue(te+e*s,v[e],`*`),o.setValue(x+e*s,u[t[e]],`*`);for(let e=0;e<h;e++)o.setValue(S+e*s,y[e],`*`),o.setValue(C+e*s,d[r[e]],`*`);o.jsepOnRunStart?.(l),o.webnnOnRunStart?.(l);let c;c=await o._OrtRun(l,x,te,m,C,h,S,g),c!==0&&W(`failed to call OrtRun().`);let b=[],ne=[];F(`wasm ProcessOutputTensor`);for(let t=0;t<h;t++){let n=Number(o.getValue(S+t*s,`*`));if(n===y[t]){b.push(i[t]);continue}let a=o.stackSave(),c=o.stackAlloc(4*s),l=!1,u,d=0;try{o._OrtGetTensorData(n,c,c+s,c+2*s,c+3*s)!==0&&W(`Can't access output tensor data on index ${t}.`);let i=s===4?`i32`:`i64`,a=Number(o.getValue(c,i));d=o.getValue(c+s,`*`);let p=o.getValue(c+s*2,`*`),m=Number(o.getValue(c+s*3,i)),h=[];for(let e=0;e<m;e++)h.push(Number(o.getValue(p+e*s,i)));o._OrtFree(p)!==0&&W(`Can't free memory for tensor dims.`);let g=h.reduce((e,t)=>e*t,1);u=gt(a);let _=f?.outputPreferredLocations[r[t]];if(u===`string`){if(_===`gpu-buffer`||_===`ml-tensor`)throw Error(`String tensor is not supported on GPU.`);let e=[];for(let t=0;t<g;t++){let n=o.getValue(d+t*s,`*`),r=o.getValue(d+(t+1)*s,`*`),i=t===g-1?void 0:r-n;e.push(o.UTF8ToString(n,i))}b.push([u,h,e,`cpu`])}else if(_===`gpu-buffer`&&g>0){let e=o.jsepGetBuffer;if(!e)throw Error(`preferredLocation "gpu-buffer" is not supported without using WebGPU.`);let t=e(d),r=K(a,g);if(r===void 0||!yt(u))throw Error(`Unsupported data type: ${u}`);l=!0,b.push([u,h,{gpuBuffer:t,download:o.jsepCreateDownloader(t,r,u),dispose:()=>{o._OrtReleaseTensor(n)!==0&&W(`Can't release tensor.`)}},`gpu-buffer`])}else if(_===`ml-tensor`&&g>0){let t=o.webnnEnsureTensor,r=o.webnnIsGraphInputOutputTypeSupported;if(!t||!r)throw Error(`preferredLocation "ml-tensor" is not supported without using WebNN.`);if(K(a,g)===void 0||!bt(u))throw Error(`Unsupported data type: ${u}`);if(!r(e,u,!1))throw Error(`preferredLocation "ml-tensor" for ${u} output is not supported by current WebNN Context.`);let i=await t(e,d,a,h,!1);l=!0,b.push([u,h,{mlTensor:i,download:o.webnnCreateMLTensorDownloader(d,u),dispose:()=>{o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n)}},`ml-tensor`])}else if(_===`ml-tensor-cpu-output`&&g>0){let e=o.webnnCreateMLTensorDownloader(d,u)(),t=b.length;l=!0,ne.push((async()=>{let r=[t,await e];return o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n),r})()),b.push([u,h,[],`cpu`])}else{let e=new(_t(u))(g);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(o.HEAPU8.subarray(d,d+e.byteLength)),b.push([u,h,e,`cpu`])}}finally{o.stackRestore(a),u===`string`&&d&&o._free(d),l||o._OrtReleaseTensor(n)}}f&&!p&&(o._OrtClearBoundOutputs(f.handle)!==0&&W(`Can't clear bound outputs.`),J.set(e,[l,u,d,f,p,!1]));for(let[e,t]of await Promise.all(ne))b[e][2]=t;return I(`wasm ProcessOutputTensor`),b}finally{o.webnnOnRunEnd?.(l),o.stackRestore(b),v.forEach(e=>o._OrtReleaseTensor(e)),y.forEach(e=>o._OrtReleaseTensor(e)),ee.forEach(e=>o._free(e)),g!==0&&o._OrtReleaseRunOptions(g),_.forEach(e=>o._free(e))}},Pt=e=>{let t=H(),n=J.get(e);if(!n)throw Error(`invalid session id`);let r=n[0],i=t._OrtEndProfiling(r);i===0&&W(`Can't get an profile file name.`),t._OrtFree(i)},Ft=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&`buffer`in e&&t.push(e.buffer)}return t}}),Y,X,Lt,Rt,zt,Z,Bt,Vt,Q,$,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt=l(()=>{z(),It(),it(),Xe(),Y=()=>!!C.wasm.proxy&&typeof document<`u`,Lt=!1,Rt=!1,zt=!1,Vt=/* @__PURE__ */ new Map,Q=(e,t)=>{let n=Vt.get(e);n?n.push(t):Vt.set(e,[t])},$=()=>{if(Lt||!Rt||zt||!X)throw Error(`worker not ready`)},Ht=e=>{switch(e.data.type){case`init-wasm`:Lt=!1,e.data.err?(zt=!0,Bt[1](e.data.err)):(Rt=!0,Bt[0]()),Z&&=(URL.revokeObjectURL(Z),void 0);break;case`init-ep`:case`copy-from`:case`create`:case`release`:case`run`:case`end-profiling`:{let t=Vt.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}}},Ut=async()=>{if(!Rt){if(Lt)throw Error(`multiple calls to 'initWasm()' detected.`);if(zt)throw Error(`previous call to 'initWasm()' failed.`);if(Lt=!0,Y())return new Promise((e,t)=>{X?.terminate(),qe().then(([n,r])=>{try{X=r,X.onerror=e=>t(e),X.onmessage=Ht,Bt=[e,t];let i={type:`init-wasm`,in:C};!i.in.wasm.wasmPaths&&(n||Re)&&(i.in.wasm.wasmPaths={wasm:new URL(`/assets/ort-wasm-simd-threaded-CxTQ5xH-.wasm`,``+import.meta.url).href}),X.postMessage(i),Z=n}catch(e){t(e)}},t)});try{await rt(C.wasm),await q(C),Rt=!0}catch(e){throw zt=!0,e}finally{Lt=!1}}},Wt=async e=>{if(Y())return $(),new Promise((t,n)=>{Q(`init-ep`,[t,n]);let r={type:`init-ep`,in:{epName:e,env:C}};X.postMessage(r)});await Et(C,e)},Gt=async e=>Y()?($(),new Promise((t,n)=>{Q(`copy-from`,[t,n]);let r={type:`copy-from`,in:{buffer:e}};X.postMessage(r,[e.buffer])})):kt(e),Kt=async(e,t)=>{if(Y()){if(t?.preferredOutputLocation)throw Error(`session option "preferredOutputLocation" is not supported for proxy.`);return $(),new Promise((n,r)=>{Q(`create`,[n,r]);let i={type:`create`,in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),X.postMessage(i,a)})}return At(e,t)},qt=async e=>{if(Y())return $(),new Promise((t,n)=>{Q(`release`,[t,n]);let r={type:`release`,in:e};X.postMessage(r)});jt(e)},Jt=async(e,t,n,r,i,a)=>{if(Y()){if(n.some(e=>e[3]!==`cpu`))throw Error(`input tensor on GPU is not supported for proxy.`);if(i.some(e=>e))throw Error(`pre-allocated output tensor is not supported for proxy.`);return $(),new Promise((i,o)=>{Q(`run`,[i,o]);let s=n,c={type:`run`,in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:a}};X.postMessage(c,Ft(s))})}return Nt(e,t,n,r,i,a)},Yt=async e=>{if(Y())return $(),new Promise((t,n)=>{Q(`end-profiling`,[t,n]);let r={type:`end-profiling`,in:e};X.postMessage(r)});Pt(e)}}),Zt,Qt,$t,en=l(()=>{z(),Xt(),St(),Ee(),wt(),Zt=(e,t)=>{switch(e.location){case`cpu`:return[e.type,e.dims,e.data,`cpu`];case`gpu-buffer`:return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},`gpu-buffer`];case`ml-tensor`:return[e.type,e.dims,{mlTensor:e.mlTensor},`ml-tensor`];default:throw Error(`invalid data location: ${e.location} for ${t()}`)}},Qt=e=>{switch(e[3]){case`cpu`:return new M(e[0],e[2],e[1]);case`gpu-buffer`:{let t=e[0];if(!yt(t))throw Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=e[2];return M.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:i})}case`ml-tensor`:{let t=e[0];if(!bt(t))throw Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:n,download:r,dispose:i}=e[2];return M.fromMLTensor(n,{dataType:t,dims:e[1],download:r,dispose:i})}default:throw Error(`invalid data location: ${e[3]}`)}},$t=class{async fetchModelAndCopyToWasmMemory(e){return Gt(await Ct(e))}async loadModel(e,t){N();let n;n=typeof e==`string`?await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Kt(n,t),P()}async dispose(){return qt(this.sessionId)}async run(e,t,n){N();let r=[],i=[];Object.entries(e).forEach(e=>{let t=e[0],n=e[1],a=this.inputNames.indexOf(t);if(a===-1)throw Error(`invalid input '${t}'`);r.push(n),i.push(a)});let a=[],o=[];Object.entries(t).forEach(e=>{let t=e[0],n=e[1],r=this.outputNames.indexOf(t);if(r===-1)throw Error(`invalid output '${t}'`);a.push(n),o.push(r)});let s=r.map((e,t)=>Zt(e,()=>`input "${this.inputNames[i[t]]}"`)),c=a.map((e,t)=>e?Zt(e,()=>`output "${this.outputNames[o[t]]}"`):null),l=await Jt(this.sessionId,i,s,o,c,n),u={};for(let e=0;e<l.length;e++)u[this.outputNames[o[e]]]=a[e]??Qt(l[e]);return P(),u}startProfiling(){}endProfiling(){Yt(this.sessionId)}}}),tn={};u(tn,{OnnxruntimeWebAssemblyBackend:()=>rn,initializeFlags:()=>nn,wasmBackend:()=>an});var nn,rn,an,on=l(()=>{z(),Xt(),en(),nn=()=>{(typeof C.wasm.initTimeout!=`number`||C.wasm.initTimeout<0)&&(C.wasm.initTimeout=0);let e=C.wasm.simd;if(typeof e!=`boolean`&&e!==void 0&&e!==`fixed`&&e!==`relaxed`&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${e}". Reset it to \`false\` and ignore SIMD feature checking.`),C.wasm.simd=!1),typeof C.wasm.proxy!=`boolean`&&(C.wasm.proxy=!1),typeof C.wasm.trace!=`boolean`&&(C.wasm.trace=!1),typeof C.wasm.numThreads!=`number`||!Number.isInteger(C.wasm.numThreads)||C.wasm.numThreads<=0){if(typeof self<`u`&&!self.crossOriginIsolated)C.wasm.numThreads=1;else{let e=typeof navigator>`u`?c(`node:os`).cpus().length:navigator.hardwareConcurrency;C.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}}},rn=class{async init(e){nn(),await Ut(),await Wt(e)}async createInferenceSessionHandler(e,t){let n=new $t;return await n.loadModel(e,t),n}},an=new rn});z(),z(),z();var sn=`1.23.2`,cn=Te;{let e=(on(),f(tn)).wasmBackend;h(`cpu`,e,10),h(`wasm`,e,10)}Object.defineProperty(C.versions,"web",{value:sn,enumerable:!0});var ln=`/assets/silero_vad-Dt9-bTDn.onnx`;27/Math.log(6.4);const un=/* @__PURE__ */ new Float64Array(400),dn=/* @__PURE__ */ new Float64Array(400);for(let e=0;e<400;e++)un[e]=Math.cos(2*Math.PI*e/400),dn[e]=-Math.sin(2*Math.PI*e/400);Object.freeze([`timers`,`smart`]),Object.freeze({threshold:.5,graceMs:150,recheckMs:400,fallbackMs:3e3,slowMs:1500}),Object.freeze([{key:`voiceTurn.threshold`,field:`threshold`,min:.01,max:.99},{key:`voiceTurn.grace`,field:`graceMs`,min:0,max:2e3},{key:`voiceTurn.recheck`,field:`recheckMs`,min:100,max:5e3},{key:`voiceTurn.fallback`,field:`fallbackMs`,min:500,max:1e4},{key:`voiceTurn.slow`,field:`slowMs`,min:500,max:5e3}]),[.../* @__PURE__ */ new Set([`um`,`umm`,`uh`,`uhh`,`uhm`,`erm`,`er`,`eh`,`ah`,`hmm`,`hm`,`mm`,`mmm`,`mhm`,`mm-hmm`,`uh-huh`])];const fn=Object.freeze({minSpeechMs:300,endSilenceMs:350,trailingKeepMs:200,preRollMs:300,holdMs:1600,finishedHoldMs:1e3});fn.trailingKeepMs;const pn=Object.freeze({startProb:.6,endProb:.35,speakingStartProb:.85,minSpeechMs:250,endSilenceMs:fn.endSilenceMs,maxSegmentMs:6e4,gateDb:3,energyMarginDb:10,energyMinSpeechMs:fn.minSpeechMs});Object.freeze([`low`,`normal`,`high`]),Object.freeze({low:Object.freeze({...pn,startProb:.75,endProb:.45,speakingStartProb:.92,minSpeechMs:350,gateDb:6,energyMarginDb:13,energyMinSpeechMs:400}),normal:pn,high:Object.freeze({...pn,startProb:.45,endProb:.25,speakingStartProb:.75,minSpeechMs:180,gateDb:0,energyMarginDb:7,energyMinSpeechMs:250})});var mn=class e{ort;session;state=/* @__PURE__ */ new Float32Array(256);context=/* @__PURE__ */ new Float32Array(64);sr;constructor(e,t){this.ort=e,this.session=t,this.sr=new e.Tensor(`int64`,BigInt64Array.from([BigInt(16e3)]),[])}static async load(t,n){let r=await t.InferenceSession.create(n,{executionProviders:[`wasm`],graphOptimizationLevel:`all`});return new e(t,r)}reset(){this.state=/* @__PURE__ */ new Float32Array(256),this.context=/* @__PURE__ */ new Float32Array(64)}async probability(e){if(e.length!==512)throw Error(`Silero VAD needs 512-sample chunks, got ${e.length}`);let t=/* @__PURE__ */ new Float32Array(576);t.set(this.context),t.set(e,64),this.context=e.slice(448);let n=await this.session.run({input:new this.ort.Tensor(`float32`,t,[1,t.length]),state:new this.ort.Tensor(`float32`,this.state,[2,1,128]),sr:this.sr});return this.state=Float32Array.from(n.stateN.data),n.output.data[0]}};C.wasm.numThreads=1,C.wasm.proxy=!1,C.logLevel=`error`;const hn=self,gn=performance.now(),_n=(async()=>{let e=await fetch(ln);if(!e.ok)throw Error(`model download failed (${e.status})`);return mn.load(r,new Uint8Array(await e.arrayBuffer()))})();_n.then(()=>hn.postMessage({type:`ready`,ms:Math.round(performance.now()-gn)}),e=>hn.postMessage({type:`error`,message:e instanceof Error?e.message:String(e)}));let vn=Promise.resolve();hn.onmessage=e=>{let t=e.data;vn=vn.then(async()=>{let e;try{e=await _n}catch(e){t.type===`chunk`&&hn.postMessage({type:`fail`,id:t.id,message:String(e?.message??e)});return}if(t.type===`reset`)return e.reset();if(t.type===`chunk`)try{hn.postMessage({type:`prob`,id:t.id,p:await e.probability(t.samples)})}catch(e){hn.postMessage({type:`fail`,id:t.id,message:String(e?.message??e)})}})};
|
|
11
|
+
e)).default,Ke=(je(),f(De)).default,qe=async()=>{if(!B)throw Error(`Failed to load proxy worker: cannot determine the script source URL.`);if(Ve(B))return[void 0,Ke()];let e=await We(B);return[e,Ke(e)]},Je=(Ie(),f(Me)).default,Ye=async(e,t,n,r)=>{let i=Je&&!(e||t);if(i){if(B)i=Ve(B);else if(r&&!n)i=!0;else throw Error(`cannot determine the script source URL.`)}if(i)return[void 0,Je];{let r=`ort-wasm-simd-threaded.mjs`,i=e??He(r,t),a=n&&i&&!Ve(i,t),o=a?await We(i):i??Ue(r,t);return[a?o:void 0,await Ge(o)]}}}),Ze,Qe,V,$e,et,tt,nt,rt,H,it=l(()=>{Xe(),Qe=!1,V=!1,$e=!1,et=()=>{if(typeof SharedArrayBuffer>`u`)return!1;try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},tt=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},nt=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},rt=async e=>{if(Qe)return Promise.resolve();if(V)throw Error(`multiple calls to 'initializeWebAssembly()' detected.`);if($e)throw Error(`previous call to 'initializeWebAssembly()' failed.`);V=!0;let t=e.initTimeout,n=e.numThreads;if(e.simd!==!1){if(e.simd===`relaxed`){if(!nt())throw Error(`Relaxed WebAssembly SIMD is not supported in the current environment.`)}else if(!tt())throw Error(`WebAssembly SIMD is not supported in the current environment.`)}let r=et();n>1&&!r&&(typeof self<`u`&&!self.crossOriginIsolated&&console.warn(`env.wasm.numThreads is set to `+n+`, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info.`),console.warn(`WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading.`),e.numThreads=n=1);let i=e.wasmPaths,a=typeof i==`string`?i:void 0,o=i?.mjs,s=o?.href??o,c=i?.wasm,l=c?.href??c,u=e.wasmBinary,[d,f]=await Ye(s,a,n>1,!!u||!!l),p=!1,m=[];if(t>0&&m.push(new Promise(e=>{setTimeout(()=>{p=!0,e()},t)})),m.push(new Promise((e,t)=>{let r={numThreads:n};if(u)r.wasmBinary=u;else if(l||a)r.locateFile=e=>l??a+e;else if(s&&s.indexOf(`blob:`)!==0)r.locateFile=e=>new URL(e,s).href;else if(d){let e=Be();e&&(r.locateFile=t=>e+t)}f(r).then(t=>{V=!1,Qe=!0,Ze=t,e(),d&&URL.revokeObjectURL(d)},e=>{V=!1,$e=!0,t(e)})})),await Promise.race(m),p)throw Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},H=()=>{if(Qe&&Ze)return Ze;throw Error(`WebAssembly is not initialized yet.`)}}),U,at,W,ot=l(()=>{it(),U=(e,t)=>{let n=H(),r=n.lengthBytesUTF8(e)+1,i=n._malloc(r);return n.stringToUTF8(e,i,r),t.push(i),i},at=(e,t,n,r)=>{if(typeof e==`object`&&e){if(n.has(e))throw Error(`Circular reference in options`);n.add(e)}Object.entries(e).forEach(([e,i])=>{let a=t?t+e:e;if(typeof i==`object`)at(i,a+`.`,n,r);else if(typeof i==`string`||typeof i==`number`)r(a,i.toString());else if(typeof i==`boolean`)r(a,i?`1`:`0`);else throw Error(`Can't handle extra config type: ${typeof i}`)})},W=e=>{let t=H(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetLastError(r,r+n);let i=Number(t.getValue(r,n===4?`i32`:`i64`)),a=t.getValue(r+n,`*`),o=a?t.UTF8ToString(a):``;throw Error(`${e} ERROR_CODE: ${i}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(n)}}}),st,ct=l(()=>{it(),ot(),st=e=>{let t=H(),n=0,r=[],i=e||{};try{if(e?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof e.logSeverityLevel!=`number`||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!=`number`||!Number.isInteger(e.logVerbosityLevel))throw Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(i.terminate=!1);let a=0;return e?.tag!==void 0&&(a=U(e.tag,r)),n=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,a),n===0&&W(`Can't create run options.`),e?.extra!==void 0&&at(e.extra,``,/* @__PURE__ */ new WeakSet,(e,i)=>{let a=U(e,r),o=U(i,r);t._OrtAddRunConfigEntry(n,a,o)!==0&&W(`Can't set a run config entry: ${e} - ${i}.`)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseRunOptions(n),r.forEach(e=>t._free(e)),e}}}),lt,ut,dt,ft,G,pt,mt=l(()=>{it(),ot(),lt=e=>{switch(e){case`disabled`:return 0;case`basic`:return 1;case`extended`:return 2;case`layout`:return 3;case`all`:return 99;default:throw Error(`unsupported graph optimization level: ${e}`)}},ut=e=>{switch(e){case`sequential`:return 0;case`parallel`:return 1;default:throw Error(`unsupported execution mode: ${e}`)}},dt=e=>{e.extra||={},e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||=`1`,e.executionProviders&&e.executionProviders.some(e=>(typeof e==`string`?e:e.name)===`webgpu`)&&(e.enableMemPattern=!1)},ft=(e,t,n,r)=>{let i=U(t,r),a=U(n,r);H()._OrtAddSessionConfigEntry(e,i,a)!==0&&W(`Can't set a session config entry: ${t} - ${n}.`)},G=async(e,t,n)=>{for(let r of t){let t=typeof r==`string`?r:r.name,i=[];switch(t){case`webnn`:if(t=`WEBNN`,typeof r!=`string`){let t=r?.deviceType;t&&ft(e,`deviceType`,t,n)}break;case`webgpu`:if(t=`JS`,typeof r!=`string`){let t=r;if(t?.preferredLayout){if(t.preferredLayout!==`NCHW`&&t.preferredLayout!==`NHWC`)throw Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${t.preferredLayout}`);ft(e,`preferredLayout`,t.preferredLayout,n)}}break;case`wasm`:case`cpu`:continue;default:throw Error(`not supported execution provider: ${t}`)}let a=U(t,n),o=i.length,s=0,c=0;if(o>0){s=H()._malloc(o*H().PTR_SIZE),n.push(s),c=H()._malloc(o*H().PTR_SIZE),n.push(c);for(let e=0;e<o;e++)H().setValue(s+e*H().PTR_SIZE,i[e][0],`*`),H().setValue(c+e*H().PTR_SIZE,i[e][1],`*`)}await H()._OrtAppendExecutionProvider(e,a,s,c,o)!==0&&W(`Can't append execution provider: ${t}.`)}},pt=async e=>{let t=H(),n=0,r=[],i=e||{};dt(i);try{let e=lt(i.graphOptimizationLevel??`all`),a=ut(i.executionMode??`sequential`),o=typeof i.logId==`string`?U(i.logId,r):0,s=i.logSeverityLevel??2;if(!Number.isInteger(s)||s<0||s>4)throw Error(`log severity level is not valid: ${s}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw Error(`log verbosity level is not valid: ${c}`);let l=typeof i.optimizedModelFilePath==`string`?U(i.optimizedModelFilePath,r):0;if(n=t._OrtCreateSessionOptions(e,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,s,c,l),n===0&&W(`Can't create session options.`),i.executionProviders&&await G(n,i.executionProviders,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!=`boolean`)throw Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);ft(n,`enableGraphCapture`,i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[e,a]of Object.entries(i.freeDimensionOverrides)){if(typeof e!=`string`)throw Error(`free dimension override name must be a string: ${e}`);if(typeof a!=`number`||!Number.isInteger(a)||a<0)throw Error(`free dimension override value must be a non-negative integer: ${a}`);let i=U(e,r);t._OrtAddFreeDimensionOverride(n,i,a)!==0&&W(`Can't set a free dimension override: ${e} - ${a}.`)}return i.extra!==void 0&&at(i.extra,``,/* @__PURE__ */ new WeakSet,(e,t)=>{ft(n,e,t,r)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseSessionOptions(n)!==0&&W(`Can't release session options.`),r.forEach(e=>t._free(e)),e}}}),ht,gt,K,_t,vt,yt,bt,xt,St=l(()=>{ht=e=>{switch(e){case`int8`:return 3;case`uint8`:return 2;case`bool`:return 9;case`int16`:return 5;case`uint16`:return 4;case`int32`:return 6;case`uint32`:return 12;case`float16`:return 10;case`float32`:return 1;case`float64`:return 11;case`string`:return 8;case`int64`:return 7;case`uint64`:return 13;case`int4`:return 22;case`uint4`:return 21;default:throw Error(`unsupported data type: ${e}`)}},gt=e=>{switch(e){case 3:return`int8`;case 2:return`uint8`;case 9:return`bool`;case 5:return`int16`;case 4:return`uint16`;case 6:return`int32`;case 12:return`uint32`;case 10:return`float16`;case 1:return`float32`;case 11:return`float64`;case 8:return`string`;case 7:return`int64`;case 13:return`uint64`;case 22:return`int4`;case 21:return`uint4`;default:throw Error(`unsupported data type: ${e}`)}},K=(e,t)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],r=typeof t==`number`?t:t.reduce((e,t)=>e*t,1);return n>0?Math.ceil(r*n):void 0},_t=e=>{switch(e){case`float16`:return typeof Float16Array<`u`&&Float16Array.from?Float16Array:Uint16Array;case`float32`:return Float32Array;case`uint8`:return Uint8Array;case`int8`:return Int8Array;case`uint16`:return Uint16Array;case`int16`:return Int16Array;case`int32`:return Int32Array;case`bool`:return Uint8Array;case`float64`:return Float64Array;case`uint32`:return Uint32Array;case`int64`:return BigInt64Array;case`uint64`:return BigUint64Array;default:throw Error(`unsupported type: ${e}`)}},vt=e=>{switch(e){case`verbose`:return 0;case`info`:return 1;case`warning`:return 2;case`error`:return 3;case`fatal`:return 4;default:throw Error(`unsupported logging level: ${e}`)}},yt=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,bt=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint64`||e===`int8`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,xt=e=>{switch(e){case`none`:return 0;case`cpu`:return 1;case`cpu-pinned`:return 2;case`texture`:return 3;case`gpu-buffer`:return 4;case`ml-tensor`:return 5;default:throw Error(`unsupported data location: ${e}`)}}}),Ct,wt=l(()=>{Ee(),Ct=async e=>{if(typeof e==`string`){let t=await fetch(e);if(!t.ok)throw Error(`failed to load external data file: ${e}`);let n=t.headers.get(`Content-Length`),r=n?parseInt(n,10):0;if(r<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw Error(`failed to load external data file: ${e}, no response body.`);let n=t.body.getReader(),i;try{i=new ArrayBuffer(r)}catch(e){if(e instanceof RangeError){let e=Math.ceil(r/65536);i=new WebAssembly.Memory({initial:e,maximum:e}).buffer}else throw e}let a=0;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=t.byteLength;new Uint8Array(i,a,r).set(t),a+=r}return new Uint8Array(i,0,r)}}return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),Tt,q,Et,J,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It=l(()=>{z(),ct(),mt(),St(),it(),ot(),wt(),Tt=(e,t)=>{H()._OrtInit(e,t)!==0&&W(`Can't initialize onnxruntime.`)},q=async e=>{Tt(e.wasm.numThreads,vt(e.logLevel))},Et=async(e,t)=>{H().asyncInit?.();let n=e.webgpu.adapter;if(t===`webgpu`){if(typeof navigator>`u`||!navigator.gpu)throw Error(`WebGPU is not supported in current environment`);if(n){if(typeof n.limits!=`object`||typeof n.features!=`object`||typeof n.requestDevice!=`function`)throw Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let t=e.webgpu.powerPreference;if(t!==void 0&&t!==`low-power`&&t!==`high-performance`)throw Error(`Invalid powerPreference setting: "${t}"`);let r=e.webgpu.forceFallbackAdapter;if(r!==void 0&&typeof r!=`boolean`)throw Error(`Invalid forceFallbackAdapter setting: "${r}"`);if(n=await navigator.gpu.requestAdapter({powerPreference:t,forceFallbackAdapter:r}),!n)throw Error(`Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.`)}}if(t===`webnn`&&(typeof navigator>`u`||!navigator.ml))throw Error(`WebNN is not supported in current environment`)},J=/* @__PURE__ */ new Map,Dt=e=>{let t=H(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetInputOutputCount(e,r,r+n)!==0&&W(`Can't get session input/output count.`);let i=n===4?`i32`:`i64`;return[Number(t.getValue(r,i)),Number(t.getValue(r+n,i))]}finally{t.stackRestore(n)}},Ot=(e,t)=>{let n=H(),r=n.stackSave(),i=0;try{let r=n.PTR_SIZE,a=n.stackAlloc(2*r);n._OrtGetInputOutputMetadata(e,t,a,a+r)!==0&&W(`Can't get session input/output metadata.`);let o=Number(n.getValue(a,`*`));i=Number(n.getValue(a+r,`*`));let s=n.HEAP32[i/4];if(s===0)return[o,0];let c=n.HEAPU32[i/4+1],l=[];for(let e=0;e<c;e++){let t=Number(n.getValue(i+8+e*r,`*`));l.push(t===0?Number(n.getValue(i+8+(e+c)*r,`*`)):n.UTF8ToString(t))}return[o,s,l]}finally{n.stackRestore(r),i!==0&&n._OrtFree(i)}},kt=e=>{let t=H(),n=t._malloc(e.byteLength);if(n===0)throw Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,n),[n,e.byteLength]},At=async(e,t)=>{let n,r,i=H();Array.isArray(e)?[n,r]=e:e.buffer===i.HEAPU8.buffer?[n,r]=[e.byteOffset,e.byteLength]:[n,r]=kt(e);let a=0,o=0,s=[],c=[],l=[];try{if([o,s]=await pt(t),t?.externalData&&i.mountExternalData){let e=[];for(let n of t.externalData){let t=typeof n==`string`?n:n.path;e.push(Ct(typeof n==`string`?n:n.data).then(e=>{i.mountExternalData(t,e)}))}await Promise.all(e)}for(let e of t?.executionProviders??[])if((typeof e==`string`?e:e.name)===`webnn`){if(i.shouldTransferToMLTensor=!1,typeof e!=`string`){let t=e,n=t?.context,r=t?.gpuDevice,a=t?.deviceType,o=t?.powerPreference;i.currentContext=n||(r?await i.webnnCreateMLContext(r):await i.webnnCreateMLContext({deviceType:a,powerPreference:o}))}else i.currentContext=await i.webnnCreateMLContext();break}a=await i._OrtCreateSession(n,r,o),i.webgpuOnCreateSession?.(a),a===0&&W(`Can't create a session.`),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(a,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[e,u]=Dt(a),d=!!t?.enableGraphCapture,f=[],p=[],m=[],h=[];for(let t=0;t<e;t++){let[e,n,r]=Ot(a,t);e===0&&W(`Can't get an input name.`),c.push(e);let o=i.UTF8ToString(e);f.push(o),m.push(n===0?{name:o,isTensor:!1}:{name:o,isTensor:!0,type:gt(n),shape:r})}for(let t=0;t<u;t++){let[n,r,o]=Ot(a,t+e);n===0&&W(`Can't get an output name.`),l.push(n);let s=i.UTF8ToString(n);p.push(s),h.push(r===0?{name:s,isTensor:!1}:{name:s,isTensor:!0,type:gt(r),shape:o})}return J.set(a,[a,c,l,null,d,!1]),[a,f,p,m,h]}catch(e){throw c.forEach(e=>i._OrtFree(e)),l.forEach(e=>i._OrtFree(e)),a!==0&&i._OrtReleaseSession(a)!==0&&W(`Can't release session.`),e}finally{i._free(n),o!==0&&i._OrtReleaseSessionOptions(o)!==0&&W(`Can't release session options.`),s.forEach(e=>i._free(e)),i.unmountExternalData?.()}},jt=e=>{let t=H(),n=J.get(e);if(!n)throw Error(`cannot release session. invalid session id: ${e}`);let[r,i,a,o,s]=n;o&&(s&&t._OrtClearBoundOutputs(o.handle)!==0&&W(`Can't clear bound outputs.`),t._OrtReleaseBinding(o.handle)!==0&&W(`Can't release IO binding.`)),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),i.forEach(e=>t._OrtFree(e)),a.forEach(e=>t._OrtFree(e)),t._OrtReleaseSession(r)!==0&&W(`Can't release session.`),J.delete(e)},Mt=async(e,t,n,r,i,a,o=!1)=>{if(!e){t.push(0);return}let s=H(),c=s.PTR_SIZE,l=e[0],u=e[1],d=e[3],f=d,p,m;if(l===`string`&&(d===`gpu-buffer`||d===`ml-tensor`))throw Error(`String tensor is not supported on GPU.`);if(o&&d!==`gpu-buffer`)throw Error(`External buffer must be provided for input/output index ${a} when enableGraphCapture is true.`);if(d===`gpu-buffer`){let t=e[2].gpuBuffer;m=K(ht(l),u);{let e=s.jsepRegisterBuffer;if(!e)throw Error(`Tensor location "gpu-buffer" is not supported without using WebGPU.`);p=e(r,a,t,m)}}else if(d===`ml-tensor`){let t=e[2].mlTensor;m=K(ht(l),u);let n=s.webnnRegisterMLTensor;if(!n)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);p=n(r,t,ht(l),u)}else{let t=e[2];if(Array.isArray(t)){m=c*t.length,p=s._malloc(m),n.push(p);for(let e=0;e<t.length;e++){if(typeof t[e]!=`string`)throw TypeError(`tensor data at index ${e} is not a string`);s.setValue(p+e*c,U(t[e],n),`*`)}}else{let e=s.webnnIsGraphInput,a=s.webnnIsGraphOutput;if(l!==`string`&&e&&a){let o=s.UTF8ToString(i);if(e(r,o)||a(r,o)){let e=ht(l);m=K(e,u),f=`ml-tensor`;let n=s.webnnCreateTemporaryTensor,i=s.webnnUploadTensor;if(!n||!i)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);let a=await n(r,e,u);i(a,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),p=a}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}}let h=s.stackSave(),g=s.stackAlloc(4*u.length);try{u.forEach((e,t)=>s.setValue(g+t*c,e,c===4?`i32`:`i64`));let e=s._OrtCreateTensor(ht(l),p,m,g,u.length,xt(f));e===0&&W(`Can't create tensor for input/output. session=${r}, index=${a}.`),t.push(e)}finally{s.stackRestore(h)}},Nt=async(e,t,n,r,i,a)=>{let o=H(),s=o.PTR_SIZE,c=J.get(e);if(!c)throw Error(`cannot run inference. invalid session id: ${e}`);let l=c[0],u=c[1],d=c[2],f=c[3],p=c[4];c[5];let m=t.length,h=r.length,g=0,_=[],v=[],y=[],ee=[],b=o.stackSave(),te=o.stackAlloc(m*s),x=o.stackAlloc(m*s),S=o.stackAlloc(h*s),C=o.stackAlloc(h*s);try{[g,_]=st(a),F(`wasm prepareInputOutputTensor`);for(let r=0;r<m;r++)await Mt(n[r],v,ee,e,u[t[r]],t[r],p);for(let t=0;t<h;t++)await Mt(i[t],y,ee,e,d[r[t]],m+r[t],p);I(`wasm prepareInputOutputTensor`);for(let e=0;e<m;e++)o.setValue(te+e*s,v[e],`*`),o.setValue(x+e*s,u[t[e]],`*`);for(let e=0;e<h;e++)o.setValue(S+e*s,y[e],`*`),o.setValue(C+e*s,d[r[e]],`*`);o.jsepOnRunStart?.(l),o.webnnOnRunStart?.(l);let c;c=await o._OrtRun(l,x,te,m,C,h,S,g),c!==0&&W(`failed to call OrtRun().`);let b=[],ne=[];F(`wasm ProcessOutputTensor`);for(let t=0;t<h;t++){let n=Number(o.getValue(S+t*s,`*`));if(n===y[t]){b.push(i[t]);continue}let a=o.stackSave(),c=o.stackAlloc(4*s),l=!1,u,d=0;try{o._OrtGetTensorData(n,c,c+s,c+2*s,c+3*s)!==0&&W(`Can't access output tensor data on index ${t}.`);let i=s===4?`i32`:`i64`,a=Number(o.getValue(c,i));d=o.getValue(c+s,`*`);let p=o.getValue(c+s*2,`*`),m=Number(o.getValue(c+s*3,i)),h=[];for(let e=0;e<m;e++)h.push(Number(o.getValue(p+e*s,i)));o._OrtFree(p)!==0&&W(`Can't free memory for tensor dims.`);let g=h.reduce((e,t)=>e*t,1);u=gt(a);let _=f?.outputPreferredLocations[r[t]];if(u===`string`){if(_===`gpu-buffer`||_===`ml-tensor`)throw Error(`String tensor is not supported on GPU.`);let e=[];for(let t=0;t<g;t++){let n=o.getValue(d+t*s,`*`),r=o.getValue(d+(t+1)*s,`*`),i=t===g-1?void 0:r-n;e.push(o.UTF8ToString(n,i))}b.push([u,h,e,`cpu`])}else if(_===`gpu-buffer`&&g>0){let e=o.jsepGetBuffer;if(!e)throw Error(`preferredLocation "gpu-buffer" is not supported without using WebGPU.`);let t=e(d),r=K(a,g);if(r===void 0||!yt(u))throw Error(`Unsupported data type: ${u}`);l=!0,b.push([u,h,{gpuBuffer:t,download:o.jsepCreateDownloader(t,r,u),dispose:()=>{o._OrtReleaseTensor(n)!==0&&W(`Can't release tensor.`)}},`gpu-buffer`])}else if(_===`ml-tensor`&&g>0){let t=o.webnnEnsureTensor,r=o.webnnIsGraphInputOutputTypeSupported;if(!t||!r)throw Error(`preferredLocation "ml-tensor" is not supported without using WebNN.`);if(K(a,g)===void 0||!bt(u))throw Error(`Unsupported data type: ${u}`);if(!r(e,u,!1))throw Error(`preferredLocation "ml-tensor" for ${u} output is not supported by current WebNN Context.`);let i=await t(e,d,a,h,!1);l=!0,b.push([u,h,{mlTensor:i,download:o.webnnCreateMLTensorDownloader(d,u),dispose:()=>{o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n)}},`ml-tensor`])}else if(_===`ml-tensor-cpu-output`&&g>0){let e=o.webnnCreateMLTensorDownloader(d,u)(),t=b.length;l=!0,ne.push((async()=>{let r=[t,await e];return o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n),r})()),b.push([u,h,[],`cpu`])}else{let e=new(_t(u))(g);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(o.HEAPU8.subarray(d,d+e.byteLength)),b.push([u,h,e,`cpu`])}}finally{o.stackRestore(a),u===`string`&&d&&o._free(d),l||o._OrtReleaseTensor(n)}}f&&!p&&(o._OrtClearBoundOutputs(f.handle)!==0&&W(`Can't clear bound outputs.`),J.set(e,[l,u,d,f,p,!1]));for(let[e,t]of await Promise.all(ne))b[e][2]=t;return I(`wasm ProcessOutputTensor`),b}finally{o.webnnOnRunEnd?.(l),o.stackRestore(b),v.forEach(e=>o._OrtReleaseTensor(e)),y.forEach(e=>o._OrtReleaseTensor(e)),ee.forEach(e=>o._free(e)),g!==0&&o._OrtReleaseRunOptions(g),_.forEach(e=>o._free(e))}},Pt=e=>{let t=H(),n=J.get(e);if(!n)throw Error(`invalid session id`);let r=n[0],i=t._OrtEndProfiling(r);i===0&&W(`Can't get an profile file name.`),t._OrtFree(i)},Ft=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&`buffer`in e&&t.push(e.buffer)}return t}}),Y,X,Lt,Rt,zt,Z,Bt,Vt,Q,$,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt=l(()=>{z(),It(),it(),Xe(),Y=()=>!!C.wasm.proxy&&typeof document<`u`,Lt=!1,Rt=!1,zt=!1,Vt=/* @__PURE__ */ new Map,Q=(e,t)=>{let n=Vt.get(e);n?n.push(t):Vt.set(e,[t])},$=()=>{if(Lt||!Rt||zt||!X)throw Error(`worker not ready`)},Ht=e=>{switch(e.data.type){case`init-wasm`:Lt=!1,e.data.err?(zt=!0,Bt[1](e.data.err)):(Rt=!0,Bt[0]()),Z&&=(URL.revokeObjectURL(Z),void 0);break;case`init-ep`:case`copy-from`:case`create`:case`release`:case`run`:case`end-profiling`:{let t=Vt.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}}},Ut=async()=>{if(!Rt){if(Lt)throw Error(`multiple calls to 'initWasm()' detected.`);if(zt)throw Error(`previous call to 'initWasm()' failed.`);if(Lt=!0,Y())return new Promise((e,t)=>{X?.terminate(),qe().then(([n,r])=>{try{X=r,X.onerror=e=>t(e),X.onmessage=Ht,Bt=[e,t];let i={type:`init-wasm`,in:C};!i.in.wasm.wasmPaths&&(n||Re)&&(i.in.wasm.wasmPaths={wasm:new URL(`/assets/ort-wasm-simd-threaded-CxTQ5xH-.wasm`,``+import.meta.url).href}),X.postMessage(i),Z=n}catch(e){t(e)}},t)});try{await rt(C.wasm),await q(C),Rt=!0}catch(e){throw zt=!0,e}finally{Lt=!1}}},Wt=async e=>{if(Y())return $(),new Promise((t,n)=>{Q(`init-ep`,[t,n]);let r={type:`init-ep`,in:{epName:e,env:C}};X.postMessage(r)});await Et(C,e)},Gt=async e=>Y()?($(),new Promise((t,n)=>{Q(`copy-from`,[t,n]);let r={type:`copy-from`,in:{buffer:e}};X.postMessage(r,[e.buffer])})):kt(e),Kt=async(e,t)=>{if(Y()){if(t?.preferredOutputLocation)throw Error(`session option "preferredOutputLocation" is not supported for proxy.`);return $(),new Promise((n,r)=>{Q(`create`,[n,r]);let i={type:`create`,in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),X.postMessage(i,a)})}return At(e,t)},qt=async e=>{if(Y())return $(),new Promise((t,n)=>{Q(`release`,[t,n]);let r={type:`release`,in:e};X.postMessage(r)});jt(e)},Jt=async(e,t,n,r,i,a)=>{if(Y()){if(n.some(e=>e[3]!==`cpu`))throw Error(`input tensor on GPU is not supported for proxy.`);if(i.some(e=>e))throw Error(`pre-allocated output tensor is not supported for proxy.`);return $(),new Promise((i,o)=>{Q(`run`,[i,o]);let s=n,c={type:`run`,in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:a}};X.postMessage(c,Ft(s))})}return Nt(e,t,n,r,i,a)},Yt=async e=>{if(Y())return $(),new Promise((t,n)=>{Q(`end-profiling`,[t,n]);let r={type:`end-profiling`,in:e};X.postMessage(r)});Pt(e)}}),Zt,Qt,$t,en=l(()=>{z(),Xt(),St(),Ee(),wt(),Zt=(e,t)=>{switch(e.location){case`cpu`:return[e.type,e.dims,e.data,`cpu`];case`gpu-buffer`:return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},`gpu-buffer`];case`ml-tensor`:return[e.type,e.dims,{mlTensor:e.mlTensor},`ml-tensor`];default:throw Error(`invalid data location: ${e.location} for ${t()}`)}},Qt=e=>{switch(e[3]){case`cpu`:return new M(e[0],e[2],e[1]);case`gpu-buffer`:{let t=e[0];if(!yt(t))throw Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=e[2];return M.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:i})}case`ml-tensor`:{let t=e[0];if(!bt(t))throw Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:n,download:r,dispose:i}=e[2];return M.fromMLTensor(n,{dataType:t,dims:e[1],download:r,dispose:i})}default:throw Error(`invalid data location: ${e[3]}`)}},$t=class{async fetchModelAndCopyToWasmMemory(e){return Gt(await Ct(e))}async loadModel(e,t){N();let n;n=typeof e==`string`?await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Kt(n,t),P()}async dispose(){return qt(this.sessionId)}async run(e,t,n){N();let r=[],i=[];Object.entries(e).forEach(e=>{let t=e[0],n=e[1],a=this.inputNames.indexOf(t);if(a===-1)throw Error(`invalid input '${t}'`);r.push(n),i.push(a)});let a=[],o=[];Object.entries(t).forEach(e=>{let t=e[0],n=e[1],r=this.outputNames.indexOf(t);if(r===-1)throw Error(`invalid output '${t}'`);a.push(n),o.push(r)});let s=r.map((e,t)=>Zt(e,()=>`input "${this.inputNames[i[t]]}"`)),c=a.map((e,t)=>e?Zt(e,()=>`output "${this.outputNames[o[t]]}"`):null),l=await Jt(this.sessionId,i,s,o,c,n),u={};for(let e=0;e<l.length;e++)u[this.outputNames[o[e]]]=a[e]??Qt(l[e]);return P(),u}startProfiling(){}endProfiling(){Yt(this.sessionId)}}}),tn={};u(tn,{OnnxruntimeWebAssemblyBackend:()=>rn,initializeFlags:()=>nn,wasmBackend:()=>an});var nn,rn,an,on=l(()=>{z(),Xt(),en(),nn=()=>{(typeof C.wasm.initTimeout!=`number`||C.wasm.initTimeout<0)&&(C.wasm.initTimeout=0);let e=C.wasm.simd;if(typeof e!=`boolean`&&e!==void 0&&e!==`fixed`&&e!==`relaxed`&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${e}". Reset it to \`false\` and ignore SIMD feature checking.`),C.wasm.simd=!1),typeof C.wasm.proxy!=`boolean`&&(C.wasm.proxy=!1),typeof C.wasm.trace!=`boolean`&&(C.wasm.trace=!1),typeof C.wasm.numThreads!=`number`||!Number.isInteger(C.wasm.numThreads)||C.wasm.numThreads<=0){if(typeof self<`u`&&!self.crossOriginIsolated)C.wasm.numThreads=1;else{let e=typeof navigator>`u`?c(`node:os`).cpus().length:navigator.hardwareConcurrency;C.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}}},rn=class{async init(e){nn(),await Ut(),await Wt(e)}async createInferenceSessionHandler(e,t){let n=new $t;return await n.loadModel(e,t),n}},an=new rn});z(),z(),z();var sn=`1.23.2`,cn=Te;{let e=(on(),f(tn)).wasmBackend;h(`cpu`,e,10),h(`wasm`,e,10)}Object.defineProperty(C.versions,"web",{value:sn,enumerable:!0});var ln=`/assets/silero_vad-Dt9-bTDn.onnx`;27/Math.log(6.4);const un=/* @__PURE__ */ new Float64Array(400),dn=/* @__PURE__ */ new Float64Array(400);for(let e=0;e<400;e++)un[e]=Math.cos(2*Math.PI*e/400),dn[e]=-Math.sin(2*Math.PI*e/400);Object.freeze([`timers`,`smart`]),Object.freeze({threshold:.5,graceMs:150,recheckMs:400,fallbackMs:3e3,slowMs:1500}),Object.freeze([{key:`voiceTurn.threshold`,field:`threshold`,min:.01,max:.99},{key:`voiceTurn.grace`,field:`graceMs`,min:0,max:2e3},{key:`voiceTurn.recheck`,field:`recheckMs`,min:100,max:5e3},{key:`voiceTurn.fallback`,field:`fallbackMs`,min:500,max:1e4},{key:`voiceTurn.slow`,field:`slowMs`,min:500,max:5e3}]),[.../* @__PURE__ */ new Set([`um`,`umm`,`uh`,`uhh`,`uhm`,`erm`,`er`,`eh`,`ah`,`hmm`,`hm`,`mm`,`mmm`,`mhm`,`mm-hmm`,`uh-huh`])];const fn=Object.freeze({minSpeechMs:300,endSilenceMs:350,trailingKeepMs:200,preRollMs:300,holdMs:1600,finishedHoldMs:1e3});fn.trailingKeepMs,Object.freeze({nearMinMs:150,probMargin:.2,dbMargin:3,runGapMs:100,minOnsetVoicedMs:60,nearGapMs:500,nearPerMinute:20,summaryMs:1e4}),Object.freeze({preFrames:48,postFrames:16,perMinute:30,gapMs:1e3});const pn=Object.freeze({startProb:.6,endProb:.35,speakingStartProb:.85,minSpeechMs:250,endSilenceMs:fn.endSilenceMs,maxSegmentMs:6e4,gateDb:3,energyMarginDb:10,energyMinSpeechMs:fn.minSpeechMs});Object.freeze([`low`,`normal`,`high`]),Object.freeze({low:Object.freeze({...pn,startProb:.75,endProb:.45,speakingStartProb:.92,minSpeechMs:350,gateDb:6,energyMarginDb:13,energyMinSpeechMs:400}),normal:pn,high:Object.freeze({...pn,startProb:.45,endProb:.25,speakingStartProb:.75,minSpeechMs:180,gateDb:0,energyMarginDb:7,energyMinSpeechMs:250})});var mn=class e{ort;session;state=/* @__PURE__ */ new Float32Array(256);context=/* @__PURE__ */ new Float32Array(64);sr;constructor(e,t){this.ort=e,this.session=t,this.sr=new e.Tensor(`int64`,BigInt64Array.from([BigInt(16e3)]),[])}static async load(t,n){let r=await t.InferenceSession.create(n,{executionProviders:[`wasm`],graphOptimizationLevel:`all`});return new e(t,r)}reset(){this.state=/* @__PURE__ */ new Float32Array(256),this.context=/* @__PURE__ */ new Float32Array(64)}async probability(e){if(e.length!==512)throw Error(`Silero VAD needs 512-sample chunks, got ${e.length}`);let t=/* @__PURE__ */ new Float32Array(576);t.set(this.context),t.set(e,64),this.context=e.slice(448);let n=await this.session.run({input:new this.ort.Tensor(`float32`,t,[1,t.length]),state:new this.ort.Tensor(`float32`,this.state,[2,1,128]),sr:this.sr});return this.state=Float32Array.from(n.stateN.data),n.output.data[0]}};C.wasm.numThreads=1,C.wasm.proxy=!1,C.logLevel=`error`;const hn=self,gn=performance.now(),_n=(async()=>{let e=await fetch(ln);if(!e.ok)throw Error(`model download failed (${e.status})`);return mn.load(r,new Uint8Array(await e.arrayBuffer()))})();_n.then(()=>hn.postMessage({type:`ready`,ms:Math.round(performance.now()-gn)}),e=>hn.postMessage({type:`error`,message:e instanceof Error?e.message:String(e)}));let vn=Promise.resolve();hn.onmessage=e=>{let t=e.data;vn=vn.then(async()=>{let e;try{e=await _n}catch(e){t.type===`chunk`&&hn.postMessage({type:`fail`,id:t.id,message:String(e?.message??e)});return}if(t.type===`reset`)return e.reset();if(t.type===`chunk`)try{hn.postMessage({type:`prob`,id:t.id,p:await e.probability(t.samples)})}catch(e){hn.postMessage({type:`fail`,id:t.id,message:String(e?.message??e)})}})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,U as t,V as n,W as r}from"./toast-
|
|
1
|
+
import{A as e,U as t,V as n,W as r}from"./toast-q818mjUF.js";import{t as i}from"./artifacts-DlQEYmDl.js";var a=`/api/agent/artifacts`,o={workspace:``,type:``},s=e=>typeof e==`string`&&i.includes(e);function c(t){let n=typeof t==`string`?new URLSearchParams(t):t,r=n.get(`workspace`)??``,i=n.get(`type`)??``;return{workspace:r===`none`||e(`workspace`,r)?r:``,type:s(i)?i:``,...n.get(`origin`)===`preview`?{origin:`preview`}:{}}}function l(e){let t=new URLSearchParams;e.workspace&&t.set(`workspace`,e.workspace),e.type&&t.set(`type`,e.type),e.origin&&t.set(`origin`,e.origin);let n=t.toString();return n?`?${n}`:``}var u=e=>e.workspace&&e.workspace!==`none`?e.workspace:``,d=e=>`${u(e)}|${e.origin??``}`;function f(e,t){let n=new URLSearchParams({state:`active`,limit:`50`}),r=u(e);return r&&n.set(`workspace`,r),e.origin&&n.set(`origin`,e.origin),t&&n.set(`cursor`,t),`${a}?${n}`}var p=e=>typeof e==`string`&&e.length>0;function m(e){if(!e||typeof e!=`object`)return;let t=e;if(p(t.id)&&typeof t.title==`string`&&s(t.kind)&&typeof t.updatedAt==`number`)return{id:t.id,title:t.title,kind:t.kind,visibility:t.visibility===`workspace`?`workspace`:`private`,...p(t.workspaceID)?{workspaceID:t.workspaceID}:{},...p(t.description)?{description:t.description}:{},updatedAt:t.updatedAt,...t.origin===`preview`?{origin:`preview`,...typeof t.revision==`number`?{revision:t.revision}:{}}:{}}}function h(e){let t=e&&typeof e==`object`?e:{};return{items:Array.isArray(t.items)?t.items.flatMap(e=>m(e)??[]):[],...p(t.cursor)?{cursor:t.cursor}:{}}}function g(e,t){return e.filter(e=>e.origin===`preview`==(t.origin===`preview`)&&(t.type===``||e.kind===t.type)&&(t.workspace===``||(t.workspace===`none`?!e.workspaceID:e.workspaceID===t.workspace)))}function _(e){return e.status===422||e.code===`unsupported`?{kind:`unsupported`,text:`Artifacts aren't supported on this hub yet.`}:e.status===404?{kind:`unavailable`,text:`This hub doesn't have artifacts.`}:e.status===403||e.status===401?{kind:`forbidden`,text:`This device isn't allowed to read artifacts.`}:{kind:`error`,text:e.message?`Could not load artifacts: ${e.message}`:`Could not load artifacts (HTTP ${e.status}).`}}function v(e){let t=e&&typeof e==`object`?e:{};return{status:typeof t.status==`number`?t.status:0,...typeof t.code==`string`?{code:t.code}:{},message:typeof t.message==`string`?t.message:String(e)}}function y(e,t){return t?`None of the artifacts loaded so far match. Load more to keep looking.`:e.origin===`preview`?`No previews. HTML previews you open from a session stay here for a day after you last view them.`:e.workspace===``&&e.type===``?`No artifacts yet. Artifacts that your sessions create show up here.`:`No artifacts match these filters.`}var b=(e,t)=>t.get(e)??`Workspace ${e.slice(0,12)}…`,x=e=>`/artifacts/${encodeURIComponent(e)}`;function S(e,t){let n=o,r,i=0,a=[],s,c={status:`loading`},l=()=>c.status===`ready`?{status:`ready`,items:g(a,n),total:a.length,more:s!==void 0,loadingMore:c.loadingMore,...c.moreError?{moreError:c.moreError}:{}}:c,u=e=>{c=e,t(l())};function f(o){n=o;let f=d(o);if(f===r&&c.status===`ready`){t(l());return}r=f;let p=++i;a=[],s=void 0,u({status:`loading`}),e.list(o).then(e=>{p===i&&(a=[...e.items],s=e.cursor,u({status:`ready`,loadingMore:!1}))},e=>p===i&&u({status:`error`,error:_(v(e))}))}function p(){if(c.status!==`ready`||c.loadingMore||s===void 0)return;let t=i;u({status:`ready`,loadingMore:!0}),e.list(n,s).then(e=>{if(t!==i)return;let n=new Set(a.map(e=>e.id));a=[...a,...e.items.filter(e=>!n.has(e.id))],s=e.cursor,u({status:`ready`,loadingMore:!1})},e=>t===i&&u({status:`ready`,loadingMore:!1,moreError:_(v(e)).text}))}function m(){r=void 0,f(n)}async function h(n){if(!e.keep)return`Keep is not available here.`;try{await e.keep(n)}catch(e){return`Could not keep it: ${v(e).message}`}a=a.filter(e=>e.id!==n.id),c.status===`ready`&&t(l())}return{load:f,more:p,reload:m,view:l,keep:h}}var C={list:async(e,n)=>h(await t(f(e,n))),keep:async e=>void await r(`/api/agent/artifacts/${n(e.id)}/keep`,{expectedRevision:e.revision??0})};async function w(){try{return((await t(`/api/agent/workspaces?state=active&limit=200`)).items??[]).flatMap(e=>typeof e.id==`string`&&typeof e.title==`string`?[{id:e.id,title:e.title}]:[])}catch{return[]}}export{y as a,b as c,S as i,w as n,l as o,x as r,c as s,C as t};
|
|
@@ -6,4 +6,4 @@ import{J as e}from"./ui-CFB4wQfF.js";var t=e=>String(e??``).normalize(`NFD`).rep
|
|
|
6
6
|
`):``,never:e?e.permissions.never.join(`
|
|
7
7
|
`):``,expires:`8h`,maxActionsPerHour:String(e?.maxActionsPerHour??60),allowAlways:e?.allowAlways??!1}}var j=e=>e.split(`
|
|
8
8
|
`).map(e=>e.trim()).filter(Boolean),Xe=/^\d+(s|m|h|d)?$/,Ze=e=>/^([A-Za-z]:)?[\\/]/.test(e);function Qe(e){let t={},n=e.holder.trim();n||(t.holder=`Who holds it: @@orchestrator, @name, ses_… or app:<token id>`);let r=j(e.projects),i=r.find(e=>!Ze(e));r.length?i!==void 0&&(t.projects=`${i} is not an absolute directory`):t.projects=`At least one project directory`;let a=Pe.filter(t=>e.allow.includes(t));a.length||(t.allow=`Pick at least one action`);let o=e.expires.trim();Xe.test(o)||(t.expires=`A duration: seconds, or 30m, 8h, 2d`);let s=e.maxActionsPerHour.trim(),c=/^\d+$/.test(s)?Number(s):NaN;return c>=1&&c<=1e3||(t.maxActionsPerHour=`A whole number from 1 to 1000`),Object.keys(t).length?{ok:!1,errors:t}:{ok:!0,body:{holder:n,scope:{projects:r},allow:a,permissions:{allow:j(e.permit),never:j(e.never)},expires:o,maxActionsPerHour:c,allowAlways:e.allowAlways}}}function $e(e){if(/^permissions\.never/.test(e))return`never`;if(/^permissions/.test(e))return`permit`;if(/^scope/.test(e))return`projects`;if(/^allow\b/.test(e))return`allow`;if(/^expires/.test(e))return`expires`;if(/^maxActionsPerHour/.test(e))return`maxActionsPerHour`;if(/^allowAlways/.test(e))return`allowAlways`;if(/holder|^No app token|^No session|^No such session/i.test(e))return`holder`}function M(e){if(!D(e))return;let{seq:t,at:n,actor:r,verb:i,target:a,decision:o,outcome:s}=e;if(typeof t==`number`&&typeof n==`number`&&D(r)&&typeof r.kind==`string`&&typeof i==`string`&&D(a)&&typeof o==`string`&&typeof s==`string`)return e}function et(e){if(!D(e))return{entries:[]};let t=(Array.isArray(e.entries)?e.entries:[]).map(M).filter(e=>!!e);return typeof e.next==`number`?{entries:t,next:e.next}:{entries:t}}var tt={allow:`allowed`,needs_user:`needs you`,forbidden:`refused`,paused:`paused`,rate_limited:`rate limited`,busy:`hub busy`},nt={ok:`done`,failed:`failed`,gone:`already answered`,offline:`offline`,unsupported:`unsupported`,escalated:`sent to you`,refused:`refused`},rt=new Set([`forbidden`,`paused`,`rate_limited`,`busy`]),it=new Set([`failed`,`refused`,`offline`,`unsupported`]),N={"acting.pause":`turned agent actions off`,"acting.resume":`turned agent actions on`},at={approve:[`approved`,`approved $`],deny:[`denied`,`denied $`],answer:[`answered`,`answered $`],prompt:[`prompted a session`,`prompted $`],stop:[`stopped a session`,`stopped $`],propose:[`proposed an action`,`proposed an action for $`],msg:[`sent a message`,`messaged $`],roles:[`claimed a role`,`claimed a role for $`],"roles.release":[`released a role`,`released a role of $`],launch:[`launched a session`,`launched $`],"launch.stop":[`stopped a launch`,`stopped the launch of $`],"team.staff":[`staffed a team role`,`staffed a team role with $`],"team.unstaff":[`unstaffed a team role`,`unstaffed $ from a team role`],"team.denied":[`sent a message the team's rules refused`,`sent $ a message the team's rules refused`],"grant.request":[`asked for a grant`,`asked for a grant for $`],"grant.approve":[`approved a grant request`,`approved a grant request from $`],"grant.deny":[`denied a grant request`,`denied a grant request from $`],"decision.answer":[`answered a Decision`,`answered a Decision of $`]},ot={deny:[`proposed denying`,`proposed denying a request in`],answer:[`proposed answering`,`proposed answering a form in`],prompt:[`proposed prompting`,`proposed a prompt to`],stop:[`proposed stopping`,`proposed stopping`]},st=/^Decision dec_[A-Za-z0-9]{1,64}: (\w+)$/;function ct(e,t,n){let r=ot[st.exec(e??``)?.[1]??``],i=n?` in ${n}`:``;return t?`${r?r[0]:`proposed an action on`} ${t}${i}`:n?`${r?r[1]:`proposed an action for`} ${n}`:`proposed an action`}function lt(e,t,n,r){if(e===`propose`)return ct(r,t,n);let i=at[e];return i?t?`${i[0]} ${t}${n?` in ${n}`:``}`:n?i[1].replace(`$`,n):i[0]:[e.replace(/[._]+/g,` `).trim()||e,t,t&&n?`in ${n}`:n].filter(Boolean).join(` `)}var P=(e,t)=>e.as===`concierge`?`@@concierge`:e.actor.kind===`user`?`you`:t?Ae(e.actor,e=>t(e)??T(e)):f(e.actor);function ut(e,t){if(e.outcome!==`escalated`)return;let n=/\bDecision (dec_[A-Za-z0-9]{1,64})\b/.exec(e.reason??``)?.[1];for(let r of t)if(n?r.id===n:e.target.requestID&&r.action?.requestID===e.target.requestID)return r}function dt(e){if(e.state!==`answered`)return e.state;let t=e.answer?.option,n=e.options.find(e=>e.id===t)?.label??t,r=_(e);return`${n?`answered “${n}”`:`answered`}${r?` by ${r}`:``}`}var ft=`Shell, outside folders and tools always need the user's tap`,pt=`The Concierge never answers “always”: the user decides`,mt={approve:`Approved`,deny:`Denied`,answer:`Answered`,prompt:`Prompted`,stop:`Stopped`},F=e=>e.replace(/\binGrant\s*=\s*yes\b/gi,`inside your grant`).replace(/\binGrant\s*=\s*no\b/gi,`outside your grant`).replace(/\bauto\s*=\s*yes\b/gi,`approvable without you`).replace(/\bauto\s*=\s*no\b/gi,`needs your tap`).replace(/\bdec_[A-Za-z0-9]{1,64}\b/g,`a Decision`),ht=/[\u061c\u200b-\u200f\u2028-\u202e\u2060-\u206f\ufeff\u{E0000}-\u{E007F}]/gu,gt=300;function _t(e){let t=F(e).replace(ht,``).replace(/«/g,`‹`).replace(/»/g,`›`).replace(/[\u0000-\u001f\u007f-\u009f]/g,` `).replace(/\s+/g,` `).trim(),n=Array.from(t);return`«${n.length>gt?`${n.slice(0,299).join(``)}…`:t}»`}function vt(e){let t=e.reason??``;if(e.decision===`busy`)return`Refused: the hub was busy (its state did not answer in time); try again`;if(e.reason===`concierge inbound rule`)return`Refused: only you can message the Concierge`;if(e.actor.kind===`user`&&/^Decision dec_[A-Za-z0-9]{1,64} proposed by @@concierge$/.test(t))return`You said yes to the Concierge's proposal`;if(e.as!==`concierge`)return t;if(t===`concierge outbound rule`)return`Refused: the Concierge may message only you`;if(e.verb===`propose`)return`The Concierge proposed this for your answer`;if(t===ft)return`Needed your tap: shell commands, outside folders and tools always do`;if(t===pt)return`Needed your tap: the Concierge never answers “always”`;if(e.decision===`needs_user`)return t?`Needed you: ${F(t).replace(/ outside the grant\b/,` outside the Concierge's grant`)}`:`Needed you`;let n=mt[e.verb];return n&&e.decision===`allow`&&e.outcome===`ok`?`${n} by the Concierge inside your grant${t?`. Its note: ${_t(t)}`:``}`:F(t)}function yt(e,t,n){let r=e.target.requestID??e.target.formID,i=e.target.requestID?`a permission request`:e.target.formID?`a form`:void 0,a=e.target.sessionID,o=a?n?.(a)??T(a):``,s=N[e.verb]??lt(e.verb,i,o,e.reason),c=N[e.verb]?void 0:[r,r&&a?`in ${a}`:a].filter(Boolean).join(` `)||void 0,l=tt[e.decision]??e.decision,u=nt[e.outcome]??e.outcome,d=e.decision===`allow`&&e.outcome===`ok`,f=t&&t.state!==`open`?`${u} · ${dt(t)}`:void 0;return{seq:e.seq,at:e.at,who:P(e,n??(()=>void 0)),what:s,...c?{whatTitle:c}:{},result:d?`done`:f??(l===u?l:`${l} · ${u}`),tone:d||t?.state===`answered`?`ok`:rt.has(e.decision)||it.has(e.outcome)?`err`:`warn`,grant:e.grant?`grant`:``,...e.grant?{grantTitle:e.grant}:{},reason:vt(e)}}var bt={approve:`Approved`,deny:`Denied`,answer:`Answered`},xt=3,I=3,St=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function Ct(e,t,n){let r=n?.(e);if(t.as===`concierge`||r?.holder===`@@concierge`)return`the Concierge's grant`;let i=r?.scope.projects.map(St)??[];if(!i.length)return`your grant`;let a=i.slice(0,I).join(`, `);return`your grant for ${i.length>I?`${a} and ${i.length-I} more`:a}`}function L(e,t,n){let r=bt[e.verb];if(!r||e.decision!==`allow`||e.outcome!==`ok`)return;let i=`${r} by ${P(e,t)}`;return e.grant?{text:`${i} · ${Ct(e.grant,e,n)}`,title:e.grant}:{text:i}}function R(e,t,n){return L(e,t,n)?.text}function wt(e,t){return[t,...e.filter(e=>e.seq!==t.seq)].sort((e,t)=>t.seq-e.seq).slice(0,100)}function Tt(e,t,n,r){for(let i of e){if(i.target.requestID!==t&&i.target.formID!==t)continue;let e=L(i,n,r);if(e)return e}}function Et(e,t,n,r,i,a,o){let s=[];for(let c of[...e].sort((e,t)=>t.at-e.at||t.seq-e.seq)){if(s.length>=xt)break;if(!c.target.sessionID||!t.has(c.target.sessionID)||n-c.at>6e5||r!==void 0&&c.at<r)continue;let e=L(c,a,o),l=c.target.requestID??c.target.formID??`seq-${c.seq}`;e&&!i?.has(l)&&!s.some(e=>e.key===l)&&s.push({key:l,...e,at:c.at})}return s}function Dt(e,t,n,r=6e4,i){for(let a of[...e].sort((e,t)=>t.at-e.at||t.seq-e.seq)){if(n-a.at>r)break;if(a.verb!==`deny`||!a.target.sessionID||!t.has(a.target.sessionID))continue;let e=R(a,void 0,i);if(e)return{key:a.target.requestID??a.target.formID??`seq-${a.seq}`,text:e}}}function Ot(e,t,n,r){let{since:i,until:a}=n,o;for(let n of e){if(n.verb!==`deny`||n.target.sessionID!==t||i!==void 0&&n.at<i||a!==void 0&&n.at>=a)continue;let e=R(n,void 0,r);e&&(!o||(i===void 0?n.at>o.e.at||n.at===o.e.at&&n.seq>o.e.seq:n.at<o.e.at||n.at===o.e.at&&n.seq<o.e.seq))&&(o={e:n,text:e})}return o&&{key:o.e.target.requestID??o.e.target.formID??`seq-${o.e.seq}`,text:o.text}}function kt(e,t){return e.filter(e=>e.denial===void 0||!t.has(e.denial))}function At(e){let t=e.enabled!==!1,n=e.hubEnabled!==!1;return{on:t,hubOn:n,note:n?t?``:`Agents cannot act for you (approve, deny, answer, prompt, stop, launch). Reading and messaging still work.`:`An admin turned agent actions off for the whole hub: no agent can approve, deny, answer, prompt, stop or launch until it is on again.`}}var jt=/^(.*?) asks to approve( always(?: \(saves .*?\))?)? (.*?)\. Outside its grant: (.*)$/s,Mt=`a permission request (details unknown)`;function Nt(e){if(e.action?.kind!==`permission`)return;let t={requester:g(e),always:e.action.always===!0,...e.action.requestID?{requestID:e.action.requestID}:{}},n=jt.exec(e.question);if(!n)return{...t,action:void 0,resources:[],reason:void 0};let r=n[3],i=r.indexOf(`: `),a=r!==Mt;return{...t,always:t.always||!!n[2],action:a?i<0?r:r.slice(0,i):void 0,resources:a&&i>=0?r.slice(i+2).split(`, `).filter(Boolean):[],reason:n[4].trim()||void 0}}function Pt(e,t){return!D(e)||typeof e.by!=`string`||e.recommends!==`approve`?``:`${t?E(e.by,t):e.by} recommends Approve${typeof e.why==`string`&&e.why?`: ${e.why}`:``}`}var z={clientID:/^hcl_[0-9a-f]{16}$/,clientSecret:/^hcs_[A-Za-z0-9_-]{43}$/,flow:/^hcf_[0-9a-f]{24}$/,code:/^hco_[A-Za-z0-9_-]{43}$/,access:/^hca_([0-9a-f]{16})_[A-Za-z0-9_-]{43}$/,refresh:/^hcr_([0-9a-f]{16})_[A-Za-z0-9_-]{43}$/,connectionID:/^[0-9a-f]{16}$/},Ft=[`hub`,`user`],It=2048,Lt=new Set([`127.0.0.1`,`[::1]`,`localhost`]);function Rt(e){if(typeof e!=`string`||e===``)return`a redirect URI is a non-empty string`;if(e.length>2048)return`a redirect URI is at most ${It} characters`;if(e.trim()!==e||/\s/.test(e))return`a redirect URI has no whitespace`;if(e.includes(`*`))return`a redirect URI has no wildcard`;let t;try{t=new URL(e)}catch{return`a redirect URI is an absolute URL`}if(t.protocol!==`https:`&&t.protocol!==`http:`)return`a redirect URI uses https (http only on a loopback host)`;if(t.protocol===`http:`&&!Lt.has(t.hostname))return`http is allowed only on a loopback host (127.0.0.1, [::1], localhost)`;if(t.username||t.password)return`a redirect URI has no user info`;if(e.includes(`#`))return`a redirect URI has no fragment`}var B=e=>!!e&&typeof e==`object`&&!Array.isArray(e),V=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),zt=new Set([`sessions:act`,`sessions:launch`,`profiles:assign`,`conversation:write`,`decisions:answer`]),Bt=e=>ze[e]??e,Vt=/^\/connect\/consent\/(hcf_[0-9a-f]{24})$/;function Ht(e){return Vt.exec(e)?.[1]}function Ut(e){if(!B(e)||typeof e.id!=`string`||!z.flow.test(e.id))return;let{client:t,scopes:n,expiresAt:r,connection:i}=e;if(!B(t)||typeof t.id!=`string`||typeof t.name!=`string`||typeof t.redirectOrigin!=`string`||!V(n)||n.length===0||typeof r!=`number`)return;let a=B(i)&&typeof i.id==`string`&&V(i.scopes)?{id:i.id,scopes:[...i.scopes]}:void 0;return{id:e.id,client:{id:t.id,name:t.name,redirectOrigin:t.redirectOrigin},scopes:[...n],expiresAt:r,...a?{connection:a}:{}}}function Wt(e){return e.scopes.map(t=>({scope:t,label:Bt(t),act:zt.has(t),checked:!0,current:e.connection?.scopes.includes(t)??!1}))}function Gt(e,t){if(!t.length)return{ok:!1,error:`Tick at least one thing it may do, or deny`};let n=t.find(t=>!e.scopes.includes(t));return n===void 0?{ok:!0,body:{scopes:e.scopes.filter(e=>t.includes(e))}}:{ok:!1,error:`The app did not ask for ${n}`}}function Kt(e){if(!B(e)||typeof e.id!=`string`||!z.connectionID.test(e.id))return;let{clientID:t,clientName:n,scopes:r,created:i,lastUsed:a,refreshExpiresAt:o}=e;if(typeof t==`string`&&typeof n==`string`&&V(r)&&typeof i==`number`&&typeof o==`number`)return{id:e.id,clientID:t,clientName:n,scopes:[...r],created:i,...typeof a==`number`?{lastUsed:a}:{},refreshExpiresAt:o}}function qt(e){return(B(e)&&Array.isArray(e.connections)?e.connections:[]).map(Kt).filter(e=>!!e)}var Jt=(e,t)=>{let n=Math.max(0,Math.round((t-e)/1e3));return n<45?`just now`:n<3600?`${Math.round(n/60)}m ago`:n<86400?`${Math.round(n/3600)}h ago`:`${Math.round(n/86400)}d ago`};function Yt(e,t){let n=[`connected ${Jt(e.created,t)}`];return e.lastUsed!==void 0&&n.push(`last refreshed ${Jt(e.lastUsed,t)}`),{title:e.clientName,scopes:e.scopes.join(`, `)||`No scopes`,detail:n.join(` · `),holder:`app:${e.id}`}}function Xt(e){if(!B(e)||typeof e.id!=`string`||!z.clientID.test(e.id))return;let{name:t,redirectURIs:n,scopes:r,created:i,createdBy:a,audience:o,disabled:s}=e;if(typeof t==`string`&&V(n)&&V(r)&&typeof i==`number`&&typeof a==`string`&&Ft.includes(o))return{id:e.id,name:t,redirectURIs:[...n],scopes:[...r],created:i,createdBy:a,audience:o,...s===!0?{disabled:!0}:{}}}function Zt(e){return(B(e)&&Array.isArray(e.clients)?e.clients:[]).map(Xt).filter(e=>!!e)}function Qt(e){return{badge:e.audience===`hub`?`Hub-wide`:`Only you`,...e.disabled?{state:`Disabled`}:{},redirects:e.redirectURIs.join(`, `),scopes:e.scopes.join(`, `)}}function $t(e){let t=e.name.trim().replace(/\s+/g,` `);if(!t)return{ok:!1,field:`name`,error:`Give the app a name`};if(t.length>100)return{ok:!1,field:`name`,error:`A name is at most 100 characters`};let n=[...new Set(e.redirects.split(`
|
|
9
|
-
`).map(e=>e.trim()).filter(Boolean))];if(!n.length)return{ok:!1,field:`redirects`,error:`Add at least one redirect URI`};if(n.length>10)return{ok:!1,field:`redirects`,error:`At most 10 redirect URIs`};for(let e of n){let t=Rt(e);if(t)return{ok:!1,field:`redirects`,error:`${e}: ${t}`}}return e.scopes.length?{ok:!0,body:{name:t,redirectURIs:n,scopes:[...new Set(e.scopes)],...e.audience?{audience:e.audience}:{}}}:{ok:!1,field:`scopes`,error:`Pick at least one scope`}}var en=class extends Error{status;code;field;hint;details;constructor(e,t){super(t),this.status=e}},tn=class extends Error{cause;name=`NetworkError`;constructor(e){super(`Can't reach the hub: the connection dropped. Check your network and try again.`),this.cause=e}},nn;function rn(e){nn=e}async function H(e,{method:t=`GET`,json:n,body:r,headers:i={},signal:a,keepalive:o}={}){let s={method:t,credentials:`same-origin`,headers:{...i},signal:a,keepalive:o};n===void 0?r!==void 0&&(s.body=r):(s.headers[`content-type`]=`application/json`,s.body=JSON.stringify(n));let c;try{c=await fetch(e,s)}catch(e){throw e instanceof TypeError?new tn(e):e}if(!c.ok){let e=await c.json().catch(()=>({}));c.status===401&&nn?.();let t=e.error&&typeof e.error==`object`?e.error:e,n=typeof e.error==`string`?e.error:typeof t.message==`string`?t.message:``,r=new en(c.status,n||`HTTP ${c.status}`);throw typeof t.field==`string`&&(r.field=t.field),typeof t.code==`string`&&(r.code=t.code),typeof t.hint==`string`&&(r.hint=t.hint),e.error&&typeof e.error==`object`&&(r.details=t),r}return c}var an=async e=>(await H(e)).json(),on=async(e,t={})=>(await H(e,{method:`POST`,json:t})).json().catch(()=>({})),sn=encodeURIComponent,cn=e=>`/api/sessions/${sn(e)}`,ln=e=>e instanceof Error?e.message:String(e),un=e=>typeof e==`object`&&!!e&&!Array.isArray(e),dn=/^[A-Za-z0-9_.:@/+~-]{1,300}$/,fn=/[\p{Cc}\p{Cf}\u2028\u2029]/u,pn={workspace:`ws`,binding:`wsb`,member:`wsm`,assignment:`asg`,supervision:`sup`,checkpoint:`chk`,sideChat:`chat`,profile:`prof`,artifact:`art`,revision:`rev`,blob:`blob`,aiJob:`job`,team:`team`,staffing:`stf`,intake:`itk`},mn=/^[A-Za-z0-9]{16,32}$/;function hn(e,t){if(typeof t!=`string`)return!1;let n=`${pn[e]}_`;return t.startsWith(n)&&mn.test(t.slice(n.length))}var gn=/^[a-z0-9-]{2,40}$/,U=e=>typeof e==`string`&&gn.test(e),_n=(e,t=120)=>typeof e==`string`&&e.trim().length>0&&e.length<=t&&!fn.test(e),vn=4e3,yn=/[\u0000-\u0009\u000b-\u001f\u007f\u2028\u2029\u200b-\u200f\u202a-\u202e\u2066-\u2069]/,bn=(e,t=vn)=>typeof e==`string`&&e.length<=t&&!yn.test(e);function xn(e){if(e!==void 0){if(!Array.isArray(e)||e.length>32)return`tags must be a list of at most 32`;if(!e.every(U))return`each tag must be 2–40 lowercase letters, digits or dashes`;if(new Set(e).size!==e.length)return`tags must be unique`}}function Sn(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))return`metadata must be an object`;let t=Object.entries(e);if(t.length>32)return`metadata has more than 32 keys`;for(let[e,n]of t){if(!U(e))return`metadata key ${JSON.stringify(String(e).slice(0,50))} must be a slug`;if(!_n(n,200))return`metadata.${e} must be 1–200 characters of text`}}var W=e=>e.signedIn,G=[{id:`sessions`,label:`All sessions`,icon:`home`,route:`/`,order:10,available:e=>W(e)?!0:`hidden`},{id:`concierge`,label:`Concierge`,icon:`spark`,route:`/concierge`,order:15,available:e=>W(e)&&e.concierge!==void 0&&e.concierge!==`disabled`?!0:`hidden`},{id:`artifacts`,label:`Artifacts`,icon:`file`,route:`/artifacts`,order:20,available:e=>W(e)?!0:`hidden`},{id:`teams`,label:`Teams`,icon:`team`,route:`/teams`,order:25,available:e=>W(e)?!0:`hidden`},{id:`watchtower`,label:`Watchtower`,icon:`watchtower`,route:`/watchtower`,order:30,available:e=>W(e)?!0:`hidden`},{id:`profiles`,label:`Agent profiles`,icon:`settings`,route:`/profiles`,order:40,available:e=>W(e)?!0:`hidden`}],Cn={"/birds-eye":`/watchtower`};function wn(e,t=``,n=``){for(let[r,i]of Object.entries(Cn))if(e===r||e.startsWith(`${r}/`))return`${i}${e.slice(r.length)}${t}${n}`}function Tn(e,t){try{return e.available(t)}catch{return`hidden`}}function En(e,t=G){return[...t].sort((e,t)=>e.order-t.order).flatMap(t=>{let n=Tn(t,e);return n===`hidden`?[]:[{dest:t,enabled:n===!0}]})}var Dn=(e,t)=>Tn(e,t)===!0?`ok`:`unavailable`;function On(e,t=G){for(let n of t)if(n.route!==`/`&&(e===n.route||e.startsWith(`${n.route}/`)))try{return{dest:n,rest:e.slice(n.route.length).split(`/`).filter(Boolean).map(decodeURIComponent)}}catch{return}}function kn(e,t=G){return e===`/`?t.find(e=>e.route===`/`)?.id:On(e,t)?.dest.id}function An(e){return e.supported?e.permission===`denied`?{state:`blocked`,message:`Notifications are blocked for this site. Allow them in the browser's site settings, then reload.`,action:`none`,warn:!0}:e.permission==="default"?{state:`off`,message:`Notifications are off on this device.`,action:`enable`,warn:!0}:!e.worker||!e.endpoint||!e.hubSubscribed?{state:`repair`,message:`Allowed, but this device is not subscribed on this hub, so nothing will arrive (this happens after the hub moves to a new address). Enable again to fix it.`,action:`enable`,warn:!0}:{state:`on`,message:`On for this device.`,action:`disable`,warn:!1}:{state:`unsupported`,message:`This browser can't get notifications here. On iPhone, add the app to the Home Screen first (iOS 16.4+); everywhere else the hub must be on https.`,action:`none`,warn:!0}}var jn=e=>e.supported&&e.permission===`granted`&&(!e.endpoint||!e.hubSubscribed);function Mn(e){if(e.subscriptions===0)return{ok:!1,text:`This device is not subscribed; enable notifications first`};if(e.sent>0)return{ok:!0,text:e.sent===1?`Test notification sent to this device`:`Test notification sent (${e.sent} subscriptions)`};let t=e.failed[0];return t?{ok:!1,text:`Test failed: ${t.host} ${t.status===void 0?`did not answer`:`answered ${t.status}`}`}:{ok:!1,text:`Test failed`}}var Nn=[1,2,5,10,15,30,60],K=[{title:`Needs you`,kinds:[{key:`question`,label:`Question`,description:`A session or subagent asks you something.`},{key:`permission`,label:`Needs permission`,description:`A tool call waits for your OK (answer from the notification).`},{key:`decision`,label:`Decision`,description:`A session asks you to decide (hub ask @me), with options and a recommendation.`},{key:`message`,label:`Message`,description:`Agent messaging needs you: a message to you, an unanswered ask, or sessions looping.`},{key:`concierge`,label:`Concierge`,description:`Your Concierge needs you or has news: its questions, permissions, decisions, messages and spoken replies.`}]},{title:`Session`,kinds:[{key:`done`,label:`All done`,description:`The session and all its subagents and scripts finished; nothing waits on you. Once per run.`},{key:`failed`,label:`Failed`,description:`The session's run failed (provider or tool error), with the reason.`},{key:`providerError`,label:`Model provider error`,description:`Quota, budget, auth or model-routing errors of the session or a subagent; once per run.`},{key:`turn`,label:`Turn finished`,description:`Every reply of the main session, also the short ones between subagents. Noisy.`},{key:`stopped`,label:`Stopped`,description:`A run stopped without you asking (OpenCode shut down, inactivity).`},{key:`retry`,label:`Retrying`,description:`The provider failed and OpenCode is retrying the request.`}]},{title:`Subagents`,kinds:[{key:`subagentDone`,label:`Subagent finished`,description:`Each subagent that finishes, by name.`},{key:`subagentFailed`,label:`Subagent failed`,description:`Each subagent that fails, with the reason.`}]},{title:`Scripts and tools`,kinds:[{key:`jobDone`,label:`Script finished`,description:`A background shell or terminal exited 0.`},{key:`jobFailed`,label:`Script failed`,description:`A background shell or terminal exited non-zero, was killed or timed out.`},{key:`longTool`,label:`Long tool finished`,description:`A tool call that ran 30 seconds or more ended.`}]},{title:`Voice`,kinds:[{key:`say`,label:`Spoken reply`,description:`Voice mode replies while no device shows the session.`},{key:`handoff`,label:`Hand-off`,description:`A session sent to this device from the terminal (ignores quiet hours).`}]},{title:`Activity digest`,kinds:[{key:`activity`,label:`Activity`,description:`One quiet, self-replacing summary per session: subagents, long tools, scripts, idle.`}]}],Pn=K.flatMap(e=>e.kinds);function Fn(e){let t=Pn.filter(t=>e[t.key]).map(e=>e.label);return t.length?`You'll get: ${t.join(`, `)}.`:`You'll get no notifications on this device.`}function In(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}var q=[{id:`general`,label:`General`,description:`Account, theme, text size and the Hub app`},{id:`notifications`,label:`Notifications`,description:`This device's notifications, what to notify about, quiet hours`},{id:`voice`,label:`Voice & speech`,description:`Voice mode, mic sensitivity, speech-to-text and text-to-speech`},{id:`media`,label:`Media`,description:`Web images in replies: the sites whose images load at once`},{id:`machines`,label:`Machines & devices`,description:`Connected machines, approvals, signed-in browsers and apps`},{id:`agents`,label:`Agents & access`,description:`App tokens, acting switches, grants and agent activity`},{id:`concierge`,label:`Concierge`,description:`Your hub-managed assistant: machine, directory, model and its grant`},{id:`teams`,label:`Teams`,description:`Team isolation: what team members see`},{id:`admin`,label:`Admin`,description:`Users, all machines, approvals and the audit log`,admin:!0}],Ln=e=>q.filter(t=>e||!t.admin);function Rn(e){if(e!==`/settings`&&!e.startsWith(`/settings/`))return;let t=e.slice(10).split(`/`)[0]??``;if(!t)return{};try{return{section:decodeURIComponent(t)}}catch{return{section:t}}}function zn(e,t){return e===void 0?t.phone?`list`:`general`:Ln(t.admin).find(t=>t.id===e)?.id}var Bn={account:`general`,appearance:`general`,notifications:`notifications`,voice:`voice`,speech:`voice`,machines:`machines`,devices:`machines`,agents:`agents`,admin:`admin`,recording:`voice`,recordings:`voice`},Vn={recording:`recordings`};function Hn(e){return Vn[e]??e}function Un(e){let t=e.replace(/^#/,``);if(!t)return;let n=Bn[t];if(n)return`/settings/${n}#${Hn(t)}`;if(q.some(e=>e.id===t))return`/settings/${t}`}var Wn=[{id:`account`,section:`general`,label:`Account`,description:`Who you are signed in as; sign out of this device`,keywords:`sign out logout user email`},{id:`set-theme`,section:`general`,label:`Color theme`,description:`Light, dark or the system's theme`,keywords:`appearance light dark system mode`},{id:`set-text-size`,section:`general`,label:`Text size`,description:`How big text is on this device`,keywords:`appearance font scale zoom`},{id:`add-app`,section:`general`,label:`Add the Hub app`,description:`Link the Hub app on a phone or tablet with a QR code`,keywords:`mobile android ios install pair link`},{id:`notifications`,section:`notifications`,label:`Notifications on this device`,description:`Enable or turn off push notifications here; permission and subscription status`,keywords:`push enable subscribe permission service worker`},{id:`notify-test`,section:`notifications`,label:`Send test notification`,description:`Check that notifications reach this device`,keywords:`push try`},{id:`quiet-hours`,section:`notifications`,label:`Quiet hours`,description:`No notifications at night (hand-offs still come through)`,keywords:`do not disturb night sleep time`},{id:`set-voice-speed`,section:`voice`,label:`Voice speed`,description:`How fast replies are spoken`,keywords:`rate tts`},{id:`set-sensitivity`,section:`voice`,label:`Mic sensitivity`,description:`How sure Voice mode must be that you are speaking to it`,keywords:`microphone noise vad`},{id:`set-turn-detection`,section:`voice`,label:`Turn detection`,description:`When Voice mode decides you finished speaking: silence timers, or the Smart Turn audio model (experimental)`,keywords:`end of turn endpointing smart turn pause hold vad experimental`},{id:`set-voice-front`,section:`voice`,label:`Voice front`,description:`Voice mode's fast voice agent: it says what it understood, then relays to the session, which keeps its own agent. On by default; turn it off to talk to the session directly`,keywords:`front echo relay fast assistant agent off direct`},{id:`set-cues`,section:`voice`,label:`Progress cues`,description:`Tones and short acknowledgements while the agent works`,keywords:`sounds acknowledgement`},{id:`set-background`,section:`voice`,label:`Keep listening when the screen is off`,description:`Lock-screen controls and listening with the screen off`,keywords:`background lock screen`},{id:`set-recording`,section:`voice`,label:`Record voice conversations (developer)`,description:`Saves your voice segments, transcripts, replies, timing and Concierge actions on this hub, for 7 days; export or delete them`,keywords:`record debug developer training audio export delete`},{id:`recordings`,section:`voice`,label:`Your recordings`,description:`The voice conversations recorded on this hub: play a segment, export or delete them`,keywords:`recordings list play segment export zip delete storage usage`},{id:`speech`,section:`voice`,label:`Speech`,description:`Speech-to-text and text-to-speech provider, model, voice and API keys`,keywords:`stt tts transcription openrouter openai key`},{id:`media-allowlist`,section:`media`,label:`Web images`,description:`Sites whose images in replies load at once; images from other sites wait for a tap`,keywords:`allowlist allow remote image picture domain host site github load`},{id:`machines`,section:`machines`,label:`Machines`,description:`Computers running OpenCode connected to this hub; approve or revoke them`,keywords:`computer approve enrollment revoke opencode`},{id:`setup-machine`,section:`machines`,label:`Set up Hub on a machine`,description:`A one-line installer for macOS, Linux or Windows that connects a computer to this hub`,keywords:`setup install connect add new computer server laptop hubctl curl powershell windows linux macos enroll`},{id:`devices`,section:`machines`,label:`Devices`,description:`Browsers and the Hub app signed in to your account; revoke them`,keywords:`browser phone sessions revoke sign out`},{id:`agents`,section:`agents`,label:`Acting switch`,description:`Whether sessions and apps may act for you at all`,keywords:`pause kill switch acting`},{id:`app-tokens`,section:`agents`,label:`App tokens`,description:`Tokens for MCP gateways, CLIs and other apps, with their scopes`,keywords:`api key token scopes mcp cli`},{id:`grants`,section:`agents`,label:`Grants`,description:`What sessions and apps may approve, deny, answer, prompt or stop for you`,keywords:`permissions delegate allow`},{id:`agent-activity`,section:`agents`,label:`Agent activity`,description:`What agents did for you (the agent audit)`,keywords:`audit log history`},{id:`concierge`,section:`concierge`,label:`Concierge`,description:`Turn the Concierge on or off, pick its machine and directory, restart it`,keywords:`assistant butler watch sessions`},{id:`concierge-grant`,section:`concierge`,label:`Concierge grant`,description:`What the Concierge may do for you without asking; renew or remove it`,keywords:`permissions approve deny preset`},{id:`context-cards`,section:`concierge`,label:`Context cards`,description:`Short pick-up summaries of your sessions, written by a light model`,keywords:`summary pickup card model resume findability`},{id:`team-isolation`,section:`teams`,label:`Team isolation`,description:`Team members see only their teams' sessions, not your other sessions`,keywords:`teams privacy hide members`}],Gn=[{id:`admin`,section:`admin`,label:`Users`,description:`Everyone on this hub: roles, disable, remove`,keywords:`admin accounts people`},{id:`admin-machines`,section:`admin`,label:`All machines`,description:`Every machine connected to this hub, by owner`,keywords:`admin revoke`},{id:`admin-audit`,section:`admin`,label:`Audit log`,description:`Who changed what on this hub`,keywords:`admin history`}],Kn=(e,t)=>({id:`pref-${e.key}`,section:`notifications`,label:e.label,description:e.description,keywords:`notify ${t}`});function qn(e){return[...Wn,...K.flatMap(e=>e.kinds.map(t=>Kn(t,e.title))),...e?Gn:[]]}var Jn=e=>q.find(t=>t.id===e)?.label??e;function Yn(e,t){let n=e.trim().toLowerCase();if(!n)return[];let r=n.split(/\s+/),i=e=>{let t=e.label.toLowerCase();return t.startsWith(n)?0:t.includes(n)?1:r.every(e=>t.includes(e))?2:3};return t.filter(e=>{let t=`${e.label} ${e.description} ${e.keywords??``} ${Jn(e.section)}`.toLowerCase();return r.every(e=>t.includes(e))}).map((e,t)=>({e,i:t,r:i(e)})).sort((e,t)=>e.r-t.r||e.i-t.i).map(e=>e.e)}function Xn(e,t){let n=e.filter(e=>e.key in t);if(!n.length)return``;let r=n.filter(e=>t[e.key]);return r.length===n.length?`All on`:r.length?`${r.length} of ${n.length} on: ${r.map(e=>e.label).join(`, `)}`:`All off`}var Zn=e=>e&&e.startsWith(`/`)&&!e.startsWith(`//`)&&!e.includes(`\\`)?e:`/`;function Qn(e){let t=e.pathname,n=e.searchParams;if(t===`/pair`)return{name:`pair`,next:Zn(n.get(`next`)),error:n.get(`error`)??``};if(t===`/approve`)return{name:`approve`,code:n.get(`code`)??``};let r=Ht(t);if(r)return{name:`consent`,flow:r};if(t===`/new`)return{name:`new`,machine:n.get(`machine`)??void 0,dir:n.get(`dir`)??void 0,key:n.get(`key`)??void 0};if(t===`/panes`)return{name:`panes`};if(t===`/concierge`||t.startsWith(`/concierge/`))return{name:`concierge`};let i=Rn(t);if(i)return{name:`settings`,...i};let a=On(t);if(a)return{name:`feature`,id:a.dest.id,rest:a.rest};let o=/^\/s\/([^/]+)$/.exec(t);if(o)try{return{name:`session`,id:decodeURIComponent(o[1])}}catch{return{name:`home`}}return{name:`home`}}function J(){let e=(location.pathname===`/settings`?Un(location.hash):void 0)??wn(location.pathname,location.search,location.hash);return e&&history.replaceState(history.state,``,e),new URL(location.href)}var[$n,er]=e(J()),tr=$n,nr=()=>Qn($n()),Y=0;function X(e,{replace:t=!1}={}){let n=new URL(e,location.origin);n.pathname+n.search+n.hash!==location.pathname+location.search+location.hash&&(history[t?`replaceState`:`pushState`]({},``,n.pathname+n.search+n.hash),t||Y++),er(J())}function rr(e=`/`){Y>0?history.back():X(e)}window.addEventListener(`popstate`,()=>{Y=Math.max(0,Y-1),er(J())}),document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`a[href]`);if(!t||t.target||t.hasAttribute(`download`)||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let n=t.getAttribute(`href`)??``;!n.startsWith(`/`)||n.startsWith(`//`)||n.startsWith(`/auth/`)||n.startsWith(`/api/`)||(e.preventDefault(),X(n))});var Z=()=>new Set;function ir(e){Z=e}var ar=e=>Z().has(e),or=e=>Z().has(e)?`/concierge`:`/s/${encodeURIComponent(e)}`,[sr,Q]=e(),cr=sr,lr=0,$;function ur(e,t=``,n){let r=++lr;Q({id:r,text:e,kind:t,action:n}),clearTimeout($),$=setTimeout(()=>sr()?.id===r&&Q(void 0),n||t?8e3:4e3)}var dr=()=>Q(void 0);export{Zt as $,hn as A,je as At,H as B,_ as Bt,Fn as C,M as Ct,En as D,Ge as Dt,kn as E,We as Et,xn as F,Ce as Ft,cn as G,ie as Gt,ln as H,h as Ht,dn as I,be as It,Qt as J,r as Jt,rn as K,ne as Kt,un as L,Te as Lt,U as M,Ne as Mt,bn as N,E as Nt,Dn as O,Dt as Ot,Sn as P,ke as Pt,Xt as Q,en as R,fe as Rt,An as S,Le as St,G as T,Ve as Tt,an as U,le as Ut,sn as V,se as Vt,on as W,ue as Wt,Gt as X,ee as Xt,Yt as Y,u as Yt,Wt as Z,Nn as _,A as _t,ar as a,Et as at,Mn as b,kt as bt,nr as c,ut as ct,Xn as d,He as dt,Ut as et,zn as f,Ot as ft,Ln as g,Je as gt,qn as h,Qe as ht,rr as i,At as it,_n as j,Me as jt,vn as k,Pt as kt,or as l,yt as lt,Hn as m,Nt as mt,dr as n,k as nt,tr as o,Re as ot,Yn as p,Ye as pt,$t as q,ce as qt,ur as r,Pe as rt,X as s,wt as st,cr as t,qt as tt,ir as u,Ue as ut,K as v,$e as vt,jn as w,et as wt,In as x,Ie as xt,Pn as y,Tt as yt,tn as z,de as zt};
|
|
9
|
+
`).map(e=>e.trim()).filter(Boolean))];if(!n.length)return{ok:!1,field:`redirects`,error:`Add at least one redirect URI`};if(n.length>10)return{ok:!1,field:`redirects`,error:`At most 10 redirect URIs`};for(let e of n){let t=Rt(e);if(t)return{ok:!1,field:`redirects`,error:`${e}: ${t}`}}return e.scopes.length?{ok:!0,body:{name:t,redirectURIs:n,scopes:[...new Set(e.scopes)],...e.audience?{audience:e.audience}:{}}}:{ok:!1,field:`scopes`,error:`Pick at least one scope`}}var en=class extends Error{status;code;field;hint;details;constructor(e,t){super(t),this.status=e}},tn=class extends Error{cause;name=`NetworkError`;constructor(e){super(`Can't reach the hub: the connection dropped. Check your network and try again.`),this.cause=e}},nn;function rn(e){nn=e}async function H(e,{method:t=`GET`,json:n,body:r,headers:i={},signal:a,keepalive:o}={}){let s={method:t,credentials:`same-origin`,headers:{...i},signal:a,keepalive:o};n===void 0?r!==void 0&&(s.body=r):(s.headers[`content-type`]=`application/json`,s.body=JSON.stringify(n));let c;try{c=await fetch(e,s)}catch(e){throw e instanceof TypeError?new tn(e):e}if(!c.ok){let e=await c.json().catch(()=>({}));c.status===401&&nn?.();let t=e.error&&typeof e.error==`object`?e.error:e,n=typeof e.error==`string`?e.error:typeof t.message==`string`?t.message:``,r=new en(c.status,n||`HTTP ${c.status}`);throw typeof t.field==`string`&&(r.field=t.field),typeof t.code==`string`&&(r.code=t.code),typeof t.hint==`string`&&(r.hint=t.hint),e.error&&typeof e.error==`object`&&(r.details=t),r}return c}var an=async e=>(await H(e)).json(),on=async(e,t={})=>(await H(e,{method:`POST`,json:t})).json().catch(()=>({})),sn=encodeURIComponent,cn=e=>`/api/sessions/${sn(e)}`,ln=e=>e instanceof Error?e.message:String(e),un=e=>typeof e==`object`&&!!e&&!Array.isArray(e),dn=/^[A-Za-z0-9_.:@/+~-]{1,300}$/,fn=/[\p{Cc}\p{Cf}\u2028\u2029]/u,pn={workspace:`ws`,binding:`wsb`,member:`wsm`,assignment:`asg`,supervision:`sup`,checkpoint:`chk`,sideChat:`chat`,profile:`prof`,artifact:`art`,revision:`rev`,blob:`blob`,aiJob:`job`,team:`team`,staffing:`stf`,intake:`itk`},mn=/^[A-Za-z0-9]{16,32}$/;function hn(e,t){if(typeof t!=`string`)return!1;let n=`${pn[e]}_`;return t.startsWith(n)&&mn.test(t.slice(n.length))}var gn=/^[a-z0-9-]{2,40}$/,U=e=>typeof e==`string`&&gn.test(e),_n=(e,t=120)=>typeof e==`string`&&e.trim().length>0&&e.length<=t&&!fn.test(e),vn=4e3,yn=/[\u0000-\u0009\u000b-\u001f\u007f\u2028\u2029\u200b-\u200f\u202a-\u202e\u2066-\u2069]/,bn=(e,t=vn)=>typeof e==`string`&&e.length<=t&&!yn.test(e);function xn(e){if(e!==void 0){if(!Array.isArray(e)||e.length>32)return`tags must be a list of at most 32`;if(!e.every(U))return`each tag must be 2–40 lowercase letters, digits or dashes`;if(new Set(e).size!==e.length)return`tags must be unique`}}function Sn(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))return`metadata must be an object`;let t=Object.entries(e);if(t.length>32)return`metadata has more than 32 keys`;for(let[e,n]of t){if(!U(e))return`metadata key ${JSON.stringify(String(e).slice(0,50))} must be a slug`;if(!_n(n,200))return`metadata.${e} must be 1–200 characters of text`}}var W=e=>e.signedIn,G=[{id:`sessions`,label:`All sessions`,icon:`home`,route:`/`,order:10,available:e=>W(e)?!0:`hidden`},{id:`concierge`,label:`Concierge`,icon:`spark`,route:`/concierge`,order:15,available:e=>W(e)&&e.concierge!==void 0&&e.concierge!==`disabled`?!0:`hidden`},{id:`artifacts`,label:`Artifacts`,icon:`file`,route:`/artifacts`,order:20,available:e=>W(e)?!0:`hidden`},{id:`teams`,label:`Teams`,icon:`team`,route:`/teams`,order:25,available:e=>W(e)?!0:`hidden`},{id:`watchtower`,label:`Watchtower`,icon:`watchtower`,route:`/watchtower`,order:30,available:e=>W(e)?!0:`hidden`},{id:`profiles`,label:`Agent profiles`,icon:`settings`,route:`/profiles`,order:40,available:e=>W(e)?!0:`hidden`}],Cn={"/birds-eye":`/watchtower`};function wn(e,t=``,n=``){for(let[r,i]of Object.entries(Cn))if(e===r||e.startsWith(`${r}/`))return`${i}${e.slice(r.length)}${t}${n}`}function Tn(e,t){try{return e.available(t)}catch{return`hidden`}}function En(e,t=G){return[...t].sort((e,t)=>e.order-t.order).flatMap(t=>{let n=Tn(t,e);return n===`hidden`?[]:[{dest:t,enabled:n===!0}]})}var Dn=(e,t)=>Tn(e,t)===!0?`ok`:`unavailable`;function On(e,t=G){for(let n of t)if(n.route!==`/`&&(e===n.route||e.startsWith(`${n.route}/`)))try{return{dest:n,rest:e.slice(n.route.length).split(`/`).filter(Boolean).map(decodeURIComponent)}}catch{return}}function kn(e,t=G){return e===`/`?t.find(e=>e.route===`/`)?.id:On(e,t)?.dest.id}function An(e){return e.supported?e.permission===`denied`?{state:`blocked`,message:`Notifications are blocked for this site. Allow them in the browser's site settings, then reload.`,action:`none`,warn:!0}:e.permission==="default"?{state:`off`,message:`Notifications are off on this device.`,action:`enable`,warn:!0}:!e.worker||!e.endpoint||!e.hubSubscribed?{state:`repair`,message:`Allowed, but this device is not subscribed on this hub, so nothing will arrive (this happens after the hub moves to a new address). Enable again to fix it.`,action:`enable`,warn:!0}:{state:`on`,message:`On for this device.`,action:`disable`,warn:!1}:{state:`unsupported`,message:`This browser can't get notifications here. On iPhone, add the app to the Home Screen first (iOS 16.4+); everywhere else the hub must be on https.`,action:`none`,warn:!0}}var jn=e=>e.supported&&e.permission===`granted`&&(!e.endpoint||!e.hubSubscribed);function Mn(e){if(e.subscriptions===0)return{ok:!1,text:`This device is not subscribed; enable notifications first`};if(e.sent>0)return{ok:!0,text:e.sent===1?`Test notification sent to this device`:`Test notification sent (${e.sent} subscriptions)`};let t=e.failed[0];return t?{ok:!1,text:`Test failed: ${t.host} ${t.status===void 0?`did not answer`:`answered ${t.status}`}`}:{ok:!1,text:`Test failed`}}var Nn=[1,2,5,10,15,30,60],K=[{title:`Needs you`,kinds:[{key:`question`,label:`Question`,description:`A session or subagent asks you something.`},{key:`permission`,label:`Needs permission`,description:`A tool call waits for your OK (answer from the notification).`},{key:`decision`,label:`Decision`,description:`A session asks you to decide (hub ask @me), with options and a recommendation.`},{key:`message`,label:`Message`,description:`Agent messaging needs you: a message to you, an unanswered ask, or sessions looping.`},{key:`concierge`,label:`Concierge`,description:`Your Concierge needs you or has news: its questions, permissions, decisions, messages and spoken replies.`}]},{title:`Session`,kinds:[{key:`done`,label:`All done`,description:`The session and all its subagents and scripts finished; nothing waits on you. Once per run.`},{key:`failed`,label:`Failed`,description:`The session's run failed (provider or tool error), with the reason.`},{key:`providerError`,label:`Model provider error`,description:`Quota, budget, auth or model-routing errors of the session or a subagent; once per run.`},{key:`turn`,label:`Turn finished`,description:`Every reply of the main session, also the short ones between subagents. Noisy.`},{key:`stopped`,label:`Stopped`,description:`A run stopped without you asking (OpenCode shut down, inactivity).`},{key:`retry`,label:`Retrying`,description:`The provider failed and OpenCode is retrying the request.`}]},{title:`Subagents`,kinds:[{key:`subagentDone`,label:`Subagent finished`,description:`Each subagent that finishes, by name.`},{key:`subagentFailed`,label:`Subagent failed`,description:`Each subagent that fails, with the reason.`}]},{title:`Scripts and tools`,kinds:[{key:`jobDone`,label:`Script finished`,description:`A background shell or terminal exited 0.`},{key:`jobFailed`,label:`Script failed`,description:`A background shell or terminal exited non-zero, was killed or timed out.`},{key:`longTool`,label:`Long tool finished`,description:`A tool call that ran 30 seconds or more ended.`}]},{title:`Voice`,kinds:[{key:`say`,label:`Spoken reply`,description:`Voice mode replies while no device shows the session.`},{key:`handoff`,label:`Hand-off`,description:`A session sent to this device from the terminal (ignores quiet hours).`}]},{title:`Activity digest`,kinds:[{key:`activity`,label:`Activity`,description:`One quiet, self-replacing summary per session: subagents, long tools, scripts, idle.`}]}],Pn=K.flatMap(e=>e.kinds);function Fn(e){let t=Pn.filter(t=>e[t.key]).map(e=>e.label);return t.length?`You'll get: ${t.join(`, `)}.`:`You'll get no notifications on this device.`}function In(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}var q=[{id:`general`,label:`General`,description:`Account, theme, text size and the Hub app`},{id:`notifications`,label:`Notifications`,description:`This device's notifications, what to notify about, quiet hours`},{id:`voice`,label:`Voice & speech`,description:`Voice mode, mic sensitivity, speech-to-text and text-to-speech`},{id:`media`,label:`Media`,description:`Web images in replies: the sites whose images load at once`},{id:`machines`,label:`Machines & devices`,description:`Connected machines, approvals, signed-in browsers and apps`},{id:`agents`,label:`Agents & access`,description:`App tokens, acting switches, grants and agent activity`},{id:`concierge`,label:`Concierge`,description:`Your hub-managed assistant: machine, directory, model and its grant`},{id:`teams`,label:`Teams`,description:`Team isolation: what team members see`},{id:`admin`,label:`Admin`,description:`Users, all machines, approvals and the audit log`,admin:!0}],Ln=e=>q.filter(t=>e||!t.admin);function Rn(e){if(e!==`/settings`&&!e.startsWith(`/settings/`))return;let t=e.slice(10).split(`/`)[0]??``;if(!t)return{};try{return{section:decodeURIComponent(t)}}catch{return{section:t}}}function zn(e,t){return e===void 0?t.phone?`list`:`general`:Ln(t.admin).find(t=>t.id===e)?.id}var Bn={account:`general`,appearance:`general`,notifications:`notifications`,voice:`voice`,speech:`voice`,machines:`machines`,devices:`machines`,agents:`agents`,admin:`admin`,recording:`voice`,recordings:`voice`},Vn={recording:`recordings`};function Hn(e){return Vn[e]??e}function Un(e){let t=e.replace(/^#/,``);if(!t)return;let n=Bn[t];if(n)return`/settings/${n}#${Hn(t)}`;if(q.some(e=>e.id===t))return`/settings/${t}`}var Wn=[{id:`account`,section:`general`,label:`Account`,description:`Who you are signed in as; sign out of this device`,keywords:`sign out logout user email`},{id:`set-theme`,section:`general`,label:`Color theme`,description:`Light, dark or the system's theme`,keywords:`appearance light dark system mode`},{id:`set-text-size`,section:`general`,label:`Text size`,description:`How big text is on this device`,keywords:`appearance font scale zoom`},{id:`add-app`,section:`general`,label:`Add the Hub app`,description:`Link the Hub app on a phone or tablet with a QR code`,keywords:`mobile android ios install pair link`},{id:`notifications`,section:`notifications`,label:`Notifications on this device`,description:`Enable or turn off push notifications here; permission and subscription status`,keywords:`push enable subscribe permission service worker`},{id:`notify-test`,section:`notifications`,label:`Send test notification`,description:`Check that notifications reach this device`,keywords:`push try`},{id:`quiet-hours`,section:`notifications`,label:`Quiet hours`,description:`No notifications at night (hand-offs still come through)`,keywords:`do not disturb night sleep time`},{id:`set-voice-speed`,section:`voice`,label:`Voice speed`,description:`How fast replies are spoken`,keywords:`rate tts`},{id:`set-sensitivity`,section:`voice`,label:`Mic sensitivity`,description:`How sure Voice mode must be that you are speaking to it`,keywords:`microphone noise vad`},{id:`set-turn-detection`,section:`voice`,label:`Turn detection`,description:`When Voice mode decides you finished speaking: silence timers, or the Smart Turn audio model (experimental)`,keywords:`end of turn endpointing smart turn pause hold vad experimental`},{id:`set-voice-front`,section:`voice`,label:`Voice front`,description:`Voice mode's fast voice agent: it says what it understood, then relays to the session, which keeps its own agent. On by default; turn it off to talk to the session directly`,keywords:`front echo relay fast assistant agent off direct`},{id:`set-cues`,section:`voice`,label:`Progress cues`,description:`Tones and short acknowledgements while the agent works`,keywords:`sounds acknowledgement`},{id:`set-background`,section:`voice`,label:`Keep listening when the screen is off`,description:`Lock-screen controls and listening with the screen off`,keywords:`background lock screen`},{id:`set-recording`,section:`voice`,label:`Record voice conversations (developer)`,description:`Saves your voice segments, transcripts, replies, timing and Concierge actions on this hub, for 7 days; export or delete them`,keywords:`record debug developer training audio export delete`},{id:`set-developer`,section:`voice`,label:`Developer mode`,description:`Records much more for debugging Voice: raw microphone audio clips, reply audio, detector traces, devices and network, console errors, models and token counts`,keywords:`developer mode debug diagnostics raw audio clips reply logs errors trace model tokens`},{id:`recordings`,section:`voice`,label:`Your recordings`,description:`The voice conversations recorded on this hub: play a segment, export or delete them`,keywords:`recordings list play segment export zip delete storage usage`},{id:`speech`,section:`voice`,label:`Speech`,description:`Speech-to-text and text-to-speech provider, model, voice and API keys`,keywords:`stt tts transcription openrouter openai key`},{id:`media-allowlist`,section:`media`,label:`Web images`,description:`Sites whose images in replies load at once; images from other sites wait for a tap`,keywords:`allowlist allow remote image picture domain host site github load`},{id:`machines`,section:`machines`,label:`Machines`,description:`Computers running OpenCode connected to this hub; approve or revoke them`,keywords:`computer approve enrollment revoke opencode`},{id:`setup-machine`,section:`machines`,label:`Set up Hub on a machine`,description:`A one-line installer for macOS, Linux or Windows that connects a computer to this hub`,keywords:`setup install connect add new computer server laptop hubctl curl powershell windows linux macos enroll`},{id:`devices`,section:`machines`,label:`Devices`,description:`Browsers and the Hub app signed in to your account; revoke them`,keywords:`browser phone sessions revoke sign out`},{id:`agents`,section:`agents`,label:`Acting switch`,description:`Whether sessions and apps may act for you at all`,keywords:`pause kill switch acting`},{id:`app-tokens`,section:`agents`,label:`App tokens`,description:`Tokens for MCP gateways, CLIs and other apps, with their scopes`,keywords:`api key token scopes mcp cli`},{id:`grants`,section:`agents`,label:`Grants`,description:`What sessions and apps may approve, deny, answer, prompt or stop for you`,keywords:`permissions delegate allow`},{id:`agent-activity`,section:`agents`,label:`Agent activity`,description:`What agents did for you (the agent audit)`,keywords:`audit log history`},{id:`concierge`,section:`concierge`,label:`Concierge`,description:`Turn the Concierge on or off, pick its machine and directory, restart it`,keywords:`assistant butler watch sessions`},{id:`concierge-grant`,section:`concierge`,label:`Concierge grant`,description:`What the Concierge may do for you without asking; renew or remove it`,keywords:`permissions approve deny preset`},{id:`context-cards`,section:`concierge`,label:`Context cards`,description:`Short pick-up summaries of your sessions, written by a light model`,keywords:`summary pickup card model resume findability`},{id:`team-isolation`,section:`teams`,label:`Team isolation`,description:`Team members see only their teams' sessions, not your other sessions`,keywords:`teams privacy hide members`}],Gn=[{id:`admin`,section:`admin`,label:`Users`,description:`Everyone on this hub: roles, disable, remove`,keywords:`admin accounts people`},{id:`admin-machines`,section:`admin`,label:`All machines`,description:`Every machine connected to this hub, by owner`,keywords:`admin revoke`},{id:`admin-audit`,section:`admin`,label:`Audit log`,description:`Who changed what on this hub`,keywords:`admin history`}],Kn=(e,t)=>({id:`pref-${e.key}`,section:`notifications`,label:e.label,description:e.description,keywords:`notify ${t}`});function qn(e){return[...Wn,...K.flatMap(e=>e.kinds.map(t=>Kn(t,e.title))),...e?Gn:[]]}var Jn=e=>q.find(t=>t.id===e)?.label??e;function Yn(e,t){let n=e.trim().toLowerCase();if(!n)return[];let r=n.split(/\s+/),i=e=>{let t=e.label.toLowerCase();return t.startsWith(n)?0:t.includes(n)?1:r.every(e=>t.includes(e))?2:3};return t.filter(e=>{let t=`${e.label} ${e.description} ${e.keywords??``} ${Jn(e.section)}`.toLowerCase();return r.every(e=>t.includes(e))}).map((e,t)=>({e,i:t,r:i(e)})).sort((e,t)=>e.r-t.r||e.i-t.i).map(e=>e.e)}function Xn(e,t){let n=e.filter(e=>e.key in t);if(!n.length)return``;let r=n.filter(e=>t[e.key]);return r.length===n.length?`All on`:r.length?`${r.length} of ${n.length} on: ${r.map(e=>e.label).join(`, `)}`:`All off`}var Zn=e=>e&&e.startsWith(`/`)&&!e.startsWith(`//`)&&!e.includes(`\\`)?e:`/`;function Qn(e){let t=e.pathname,n=e.searchParams;if(t===`/pair`)return{name:`pair`,next:Zn(n.get(`next`)),error:n.get(`error`)??``};if(t===`/approve`)return{name:`approve`,code:n.get(`code`)??``};let r=Ht(t);if(r)return{name:`consent`,flow:r};if(t===`/new`)return{name:`new`,machine:n.get(`machine`)??void 0,dir:n.get(`dir`)??void 0,key:n.get(`key`)??void 0};if(t===`/panes`)return{name:`panes`};if(t===`/concierge`||t.startsWith(`/concierge/`))return{name:`concierge`};let i=Rn(t);if(i)return{name:`settings`,...i};let a=On(t);if(a)return{name:`feature`,id:a.dest.id,rest:a.rest};let o=/^\/s\/([^/]+)$/.exec(t);if(o)try{return{name:`session`,id:decodeURIComponent(o[1])}}catch{return{name:`home`}}return{name:`home`}}function J(){let e=(location.pathname===`/settings`?Un(location.hash):void 0)??wn(location.pathname,location.search,location.hash);return e&&history.replaceState(history.state,``,e),new URL(location.href)}var[$n,er]=e(J()),tr=$n,nr=()=>Qn($n()),Y=0;function X(e,{replace:t=!1}={}){let n=new URL(e,location.origin);n.pathname+n.search+n.hash!==location.pathname+location.search+location.hash&&(history[t?`replaceState`:`pushState`]({},``,n.pathname+n.search+n.hash),t||Y++),er(J())}function rr(e=`/`){Y>0?history.back():X(e)}window.addEventListener(`popstate`,()=>{Y=Math.max(0,Y-1),er(J())}),document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`a[href]`);if(!t||t.target||t.hasAttribute(`download`)||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let n=t.getAttribute(`href`)??``;!n.startsWith(`/`)||n.startsWith(`//`)||n.startsWith(`/auth/`)||n.startsWith(`/api/`)||(e.preventDefault(),X(n))});var Z=()=>new Set;function ir(e){Z=e}var ar=e=>Z().has(e),or=e=>Z().has(e)?`/concierge`:`/s/${encodeURIComponent(e)}`,[sr,Q]=e(),cr=sr,lr=0,$;function ur(e,t=``,n){let r=++lr;Q({id:r,text:e,kind:t,action:n}),clearTimeout($),$=setTimeout(()=>sr()?.id===r&&Q(void 0),n||t?8e3:4e3)}var dr=()=>Q(void 0);export{Zt as $,hn as A,je as At,H as B,_ as Bt,Fn as C,M as Ct,En as D,Ge as Dt,kn as E,We as Et,xn as F,Ce as Ft,cn as G,ie as Gt,ln as H,h as Ht,dn as I,be as It,Qt as J,r as Jt,rn as K,ne as Kt,un as L,Te as Lt,U as M,Ne as Mt,bn as N,E as Nt,Dn as O,Dt as Ot,Sn as P,ke as Pt,Xt as Q,en as R,fe as Rt,An as S,Le as St,G as T,Ve as Tt,an as U,le as Ut,sn as V,se as Vt,on as W,ue as Wt,Gt as X,ee as Xt,Yt as Y,u as Yt,Wt as Z,Nn as _,A as _t,ar as a,Et as at,Mn as b,kt as bt,nr as c,ut as ct,Xn as d,He as dt,Ut as et,zn as f,Ot as ft,Ln as g,Je as gt,qn as h,Qe as ht,rr as i,At as it,_n as j,Me as jt,vn as k,Pt as kt,or as l,yt as lt,Hn as m,Nt as mt,dr as n,k as nt,tr as o,Re as ot,Yn as p,Ye as pt,$t as q,ce as qt,ur as r,Pe as rt,X as s,wt as st,cr as t,qt as tt,ir as u,Ue as ut,K as v,$e as vt,jn as w,et as wt,In as x,Ie as xt,Pn as y,Tt as yt,tn as z,de as zt};
|
package/web/dist/index.html
CHANGED
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
<link rel="icon" href="/icon.svg" type="image/svg+xml" />
|
|
18
18
|
<link rel="icon" href="/icon-192.png" type="image/png" sizes="192x192" />
|
|
19
19
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
20
|
-
<script type="module" crossorigin src="/assets/index-
|
|
20
|
+
<script type="module" crossorigin src="/assets/index-DA0gKIzv.js"></script>
|
|
21
21
|
<link rel="modulepreload" crossorigin href="/assets/ui-CFB4wQfF.js">
|
|
22
|
-
<link rel="modulepreload" crossorigin href="/assets/toast-
|
|
23
|
-
<link rel="modulepreload" crossorigin href="/assets/pane-layout-
|
|
22
|
+
<link rel="modulepreload" crossorigin href="/assets/toast-q818mjUF.js">
|
|
23
|
+
<link rel="modulepreload" crossorigin href="/assets/pane-layout-BAuu_pA3.js">
|
|
24
24
|
<link rel="modulepreload" crossorigin href="/assets/plural-Bspvoqfq.js">
|
|
25
|
-
<link rel="modulepreload" crossorigin href="/assets/artifacts-
|
|
25
|
+
<link rel="modulepreload" crossorigin href="/assets/artifacts-DlQEYmDl.js">
|
|
26
26
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-BLdHbfdN.js">
|
|
27
27
|
<link rel="modulepreload" crossorigin href="/assets/MediaImage-Ch3ryIdR.js">
|
|
28
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
28
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Dyq-jBeE.css">
|
|
29
29
|
</head>
|
|
30
30
|
<body>
|
|
31
31
|
<div id="root"></div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,F as n,G as r,I as i,J as a,N as o,R as s,S as c,T as l,W as u,b as d,k as f,tt as p,x as m,y as h}from"./ui-CFB4wQfF.js";import{R as g,o as _,s as v}from"./toast-CXTwTvDw.js";import{t as y}from"./plural-Bspvoqfq.js";import{t as b}from"./index-bX8B6NLo.js";import{K as x,S,_ as C,a as w,c as T,d as E,dt as D,f as O,g as k,h as ee,i as A,l as j,lt as M,m as N,n as P,o as te,p as ne,r as F,s as I,st as L,t as R,u as z,y as B}from"./live-BGLA-peO.js";var V=f(`<p class="muted tm-lede">A team takes work as a unit: its entry role receives tasks, its members hold roles, and its communication paths decide who may reach whom.`),H=f(`<p role=alert class=wt-error>`),U=f(`<p class=muted>Loading teams…`),W=f(`<div class=tm-empty-state><p>No teams yet.</p><button type=button class="btn primary">Create your first team`),G=f(`<ul class=tm-cards aria-label=Teams>`),K=f(`<label class="wt-check tm-archived-toggle"><input type=checkbox><span>Show `),q=f(`<button type=button class="btn small primary">New team`),J=f(`<span class="tm-badge warn">Paused`),Y=f(`<span class="tm-badge warn">Archived`),X=f(`<span class=tm-badge>Unpublished draft`),Z=f(`<span class=tm-warn> · `),re=f(`<div><dt class=sr-only>Work</dt><dd>`),ie=f(`<ul class=tm-tags aria-label=Tags>`),ae=f(`<li class=tm-card><div class=tm-card-head><a class=tm-card-title></a><span class=muted>#</span></div><div class=tm-badges><span></span></div><dl class=tm-card-facts><div><dt class=sr-only>Entry role</dt><dd>Entry role: </dd></div><div><dt class=sr-only>Members</dt><dd>`),oe=f(`<li>`),se=f(`<a class=tm-back href=/teams>← All teams`),ce=f(`<p class=tm-draft-note>'s roles or paths. <button type=button class=tm-linkish>Review them`),le=f(`<div class=tm-detail><section class=tm-head aria-label=Team><div class=tm-head-main><span class="muted tm-handle">#</span><div class=tm-badges><span></span><span class=tm-badge>Entry role: </span></div></div><div class="te-row tm-head-actions"><button type=button class="btn small"></button><button type=button class="btn small"></button><a class="btn small">Edit in Watchtower</a></div></section><div class=tm-tabs role=tablist aria-label="Team sections"></div><div class=tm-panel role=tabpanel>`),ue=f(`<p class=muted>Loading the team…`),de=f(`<span class=tm-tab-count>`),fe=f(`<button type=button role=tab class=tm-tab>`),pe=f(`<section class=tm-section aria-labelledby=tm-submit-h><h2 id=tm-submit-h>Submit a task`),me=f(`<section class=tm-section aria-labelledby=tm-intake-h><h2 id=tm-intake-h>Tasks`),he=f(`<section class=tm-section aria-labelledby=tm-live-h><h2 id=tm-live-h>Live now (version <!>)`),ge=f(`<section class=tm-section aria-labelledby=tm-mode-h><h2 id=tm-mode-h>Mode`),_e=f(`<section class=tm-section aria-labelledby=tm-roles-h><h2 id=tm-roles-h>Roles`),ve=f(`<section class=tm-section aria-labelledby=tm-paths-h><h2 id=tm-paths-h>Paths`),ye=f(`<p class=muted>Projects: `),be=f(`<section class=tm-section aria-labelledby=tm-details-h><h2 id=tm-details-h>Details`),xe=f(`<section class=tm-section aria-labelledby=tm-history-h><h2 id=tm-history-h>History`);function Q(t){return e(i,{get when(){return t.rest[0]},keyed:!0,get fallback(){return e(Se,{})},children:t=>e(Te,{id:t})})}function Se(){let[t,l]=a(),[d,f]=a(``),[m,h]=a(!1),[_,v]=a(!1),x=async()=>{try{let e=await C(`all`);l(t=>e.map(e=>t?.find(t=>t.id===e.id&&t.seatsFilled!==void 0)??L(e)).map((t,n)=>({...t,...e[n]}))),f(``);let t=[...e],n=async()=>{for(let e=t.shift();e;e=t.shift()){let t=e,n=await B(t.id).catch(()=>void 0);n&&l(e=>e?.map(e=>e.id===t.id?L(t,n.roster,n.intake):e))}};await Promise.all([n(),n(),n(),n()])}catch(e){f(e instanceof g&&e.status===404?`This hub doesn't have teams yet.`:M(e).message)}};p(()=>void x()),R(x,()=>(t()??[]).some(e=>(e.openIntake??0)>0));let S=u(()=>(t()??[]).filter(e=>_()||e.state!==`archived`)),w=u(()=>(t()??[]).filter(e=>e.state===`archived`).length);return e(b,{title:`Teams`,get actions(){return(()=>{var e=q();return e.$$click=()=>h(!0),r(()=>e.disabled=!!d()),e})()},get children(){return[V(),e(s,{get children(){return[e(n,{get when(){return d()},get children(){var e=H();return c(e,d),e}}),e(n,{get when(){return!t()},get children(){return U()}}),e(n,{get when(){return t().length===0},get children(){var e=W(),t=e.firstChild.nextSibling;return t.$$click=()=>h(!0),e}}),e(n,{get when(){return t()},get children(){return[(()=>{var t=G();return c(t,e(o,{get each(){return S().map(e=>e.id)},children:t=>e(i,{get when(){return S().find(e=>e.id===t)},children:t=>e(Ce,{get card(){return t()}})})})),t})(),e(i,{get when(){return w()},get children(){var e=K(),t=e.firstChild,n=t.nextSibling;return n.firstChild,t.addEventListener(`change`,e=>v(e.currentTarget.checked)),c(n,()=>y(w(),`archived team`),null),r(()=>t.checked=_()),e}})]}})]}}),e(P,{get open(){return m()},onClose:()=>h(!1)})]}})}function Ce(n){let a=()=>n.card;return(()=>{var n=ae(),s=n.firstChild,u=s.firstChild,f=u.nextSibling;f.firstChild;var p=s.nextSibling,m=p.firstChild,h=p.nextSibling,g=h.firstChild,_=g.firstChild.nextSibling;_.firstChild;var v=g.nextSibling.firstChild.nextSibling;return c(u,()=>a().title),c(f,()=>a().name,null),c(m,()=>a().mode===`open`?`Open`:`Restricted`),c(p,e(i,{get when(){return a().paused},get children(){return J()}}),null),c(p,e(i,{get when(){return a().state===`archived`},get children(){return Y()}}),null),c(p,e(i,{get when(){return a().hasDraft},get children(){return X()}}),null),c(_,()=>a().entryRole,null),c(v,(()=>{var e=t(()=>a().seatsFilled===void 0);return()=>e()?`${y(a().roles,`role`)}`:`${y(a().seatsFilled,`seat`)} filled`})(),null),c(v,e(i,{get when(){return a().vacantRoles.length},get children(){var e=Z();return e.firstChild,c(e,(()=>{var e=t(()=>a().vacantRoles.length===1);return()=>e()?`${a().vacantRoles[0]} vacant`:`${a().vacantRoles.length} roles vacant`})(),null),e}}),null),c(h,e(i,{get when(){return a().openIntake!==void 0},get children(){var e=re(),n=e.firstChild.nextSibling;return c(n,(()=>{var e=t(()=>!!a().openIntake);return()=>e()?`${y(a().openIntake,`open task`)}`:`No open work`})()),e}}),null),c(n,e(i,{get when(){return a().tags.length},get children(){var t=ie();return c(t,e(o,{get each(){return[...a().tags]},children:e=>(()=>{var t=oe();return c(t,e),t})()})),t}}),null),r(e=>{var t=!!a().paused,r=a().state===`archived`,i=F(a().id),o=`tm-badge tm-mode-${a().mode}`;return t!==e.e&&n.classList.toggle(`paused`,e.e=t),r!==e.t&&n.classList.toggle(`archived`,e.t=r),i!==e.a&&l(u,`href`,e.a=i),o!==e.o&&d(m,e.o=o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()}var $=[{id:`members`,label:`Members`},{id:`work`,label:`Work`},{id:`communication`,label:`Communication`},{id:`details`,label:`Details`}];function we(){let[e,t]=a(),n=()=>void S(x({window:`24h`},Date.now())).then(t).catch(()=>t(e=>e??{nodes:[],edges:[],at:Date.now()}));return p(n),Object.assign(e,{reload:n})}function Te(a){let f=we(),m=k(a.id,{intake:!0,onChanged:()=>f.reload()});p(()=>void m.load()),R(async()=>{await m.refresh()},m.openWork);let g=u(()=>{let e=_().searchParams.get(`tab`);return $.some(t=>t.id===e)?e:`members`}),y=e=>v(`${F(a.id)}${e===`members`?``:`?tab=${e}`}`,{replace:!0}),x=e=>{let t=$.findIndex(e=>e.id===g()),n=e.key===`ArrowRight`?(t+1)%$.length:e.key===`ArrowLeft`?(t+$.length-1)%$.length:e.key===`Home`?0:e.key===`End`?$.length-1:-1;n<0||(e.preventDefault(),y($[n].id),queueMicrotask(()=>document.getElementById(`tm-tab-${$[n].id}`)?.focus()))},S=()=>m.spec()?.title||m.team()?.title||`Team`;return e(b,{get title(){return t(()=>!!m.team())()?m.read().published.title||m.team().name:`Team`},get children(){return[se(),e(i,{get when(){return m.loadError()},get children(){var e=H();return c(e,()=>m.loadError()),e}}),e(i,{get when(){return t(()=>!!m.team())()&&m.spec()},get fallback(){return e(i,{get when(){return!m.loadError()},get children(){return ue()}})},get children(){var a=le(),u=a.firstChild,p=u.firstChild,_=p.firstChild;_.firstChild;var v=_.nextSibling,b=v.firstChild,C=b.nextSibling;C.firstChild;var w=p.nextSibling.firstChild,T=w.nextSibling,E=T.nextSibling,D=u.nextSibling,O=D.nextSibling;return h(a,`keydown`,m.onKey,!0),c(_,()=>m.team().name,null),c(b,()=>m.read().published.mode===`open`?`Open`:`Restricted`),c(C,()=>m.read().published.entryRole,null),c(v,e(i,{get when(){return m.team().paused},get children(){return J()}}),null),c(v,e(i,{get when(){return m.team().state===`archived`},get children(){return Y()}}),null),w.$$click=()=>void m.togglePause(),c(w,()=>m.team().paused?`Resume`:`Pause`),T.$$click=()=>void m.toggleArchive(),c(T,()=>m.team().state===`archived`?`Restore`:`Archive`),c(a,e(j,{get notice(){return m.notice()}}),D),c(a,e(i,{get when(){return t(()=>!!(m.dirty()||m.team().hasDraft))()&&(g()===`members`||g()===`work`)},get children(){var e=ce(),t=e.firstChild,n=t.nextSibling;return c(e,()=>m.dirty()?`You have unsaved changes to `:`An unpublished draft changes `,t),c(e,S,t),n.$$click=()=>y(`communication`),e}}),D),D.$$keydown=x,c(D,e(o,{each:$,children:n=>(()=>{var a=fe();return a.$$click=()=>y(n.id),c(a,()=>n.label,null),c(a,e(i,{get when(){return t(()=>n.id===`work`)()&&m.items()?.some(e=>e.status===`queued`||e.status===`routed`)},get children(){var e=de();return c(e,()=>m.items().filter(e=>e.status===`queued`||e.status===`routed`).length),e}}),null),r(e=>{var t=`tm-tab-${n.id}`,r=g()===n.id,i=`tm-panel-${n.id}`,o=g()===n.id?0:-1;return t!==e.e&&l(a,`id`,e.e=t),r!==e.t&&l(a,`aria-selected`,e.t=r),i!==e.a&&l(a,`aria-controls`,e.a=i),o!==e.o&&l(a,`tabindex`,e.o=o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),a})()})),c(O,e(s,{get children(){return[e(n,{get when(){return g()===`members`},get children(){return e(I,{c:m,get snap(){return f()}})}}),e(n,{get when(){return g()===`work`},get children(){return e(Ee,{c:m,get snap(){return f()}})}}),e(n,{get when(){return g()===`communication`},get children(){return e(De,{c:m})}}),e(n,{get when(){return g()===`details`},get children(){return e(ke,{c:m})}})]}})),r(e=>{var t=`tm-badge tm-mode-${m.read().published.mode}`,n=m.busy()||m.team().state===`archived`,r=m.busy(),i=`/watchtower?view=2d&group=team&edit=${encodeURIComponent(m.team().id)}`,a=`tm-panel-${g()}`,o=`tm-tab-${g()}`;return t!==e.e&&d(b,e.e=t),n!==e.t&&(w.disabled=e.t=n),r!==e.a&&(T.disabled=e.a=r),i!==e.o&&l(E,`href`,e.o=i),a!==e.i&&l(O,`id`,e.i=a),o!==e.n&&l(O,`aria-labelledby`,e.n=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),a}})]}})}function Ee(t){return[(()=>{var n=pe();return n.firstChild,c(n,e(ne,{get c(){return t.c}}),null),n})(),(()=>{var n=me();return n.firstChild,c(n,e(te,{get c(){return t.c},get snap(){return t.snap}}),null),n})()]}function De(t){let n=t.c;return[e(N,{c:n}),e(w,{c:n}),(()=>{var t=he(),r=t.firstChild,i=r.firstChild.nextSibling;return i.nextSibling,c(r,()=>n.team().version,i),c(t,e(E,{c:n}),null),t})(),(()=>{var t=ge();return t.firstChild,c(t,e(T,{get value(){return n.spec().mode},onChange:e=>n.apply(Oe(n,e)),get name(){return`tm-mode-${n.id}`}}),null),t})(),(()=>{var t=_e();return t.firstChild,c(t,e(O,{c:n}),null),t})(),(()=>{var t=ve();return t.firstChild,c(t,e(z,{c:n}),null),t})()]}var Oe=(e,t)=>D(e.spec(),t);function ke(t){let n=t.c;return[e(N,{c:n}),e(w,{c:n}),(()=>{var t=be();return t.firstChild,c(t,e(A,{c:n}),null),c(t,e(i,{get when(){return n.read().published.projects?.length},get children(){var e=ye();return e.firstChild,c(e,()=>n.read().published.projects.join(`, `),null),e}}),null),t})(),(()=>{var t=xe();return t.firstChild,c(t,e(ee,{c:n}),null),t})()]}m([`click`,`keydown`]);export{Q as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderer2d-DyANQ1WS.js","assets/live-BGLA-peO.js","assets/ui-CFB4wQfF.js","assets/toast-CXTwTvDw.js","assets/plural-Bspvoqfq.js","assets/index-bX8B6NLo.js","assets/pane-layout-BW0RdX5a.js","assets/artifacts-But87Jfo.js","assets/MediaImage-Ch3ryIdR.js","assets/preload-helper-BLdHbfdN.js","assets/index-rW6LKQj1.css","assets/live-BUofsQpz.css","assets/safe-area-B2Bk__FK.js","assets/renderer3d-vYYKFAJq.js","assets/renderer3d-Co5yCKMg.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,I as s,J as c,N as l,Q as u,R as d,S as f,T as p,U as m,W as h,a as g,b as _,et as v,g as y,i as b,k as x,nt as S,q as C,r as w,tt as T,u as E,x as D,y as O}from"./ui-CFB4wQfF.js";import{R as k,l as A,o as j,s as M}from"./toast-CXTwTvDw.js";import{s as N}from"./artifacts-But87Jfo.js";import{t as P}from"./preload-helper-BLdHbfdN.js";import{$ as F,et as I,it as ee,k as te,nt as L,ot as ne,rt as R,tt as re}from"./index-bX8B6NLo.js";import{$ as ie,A as z,C as ae,D as oe,F as se,H as ce,I as le,J as ue,K as de,L as fe,M as pe,N as me,O as he,P as ge,Q as _e,R as ve,S as ye,T as be,U as xe,V as Se,W as Ce,X as we,Y as Te,Z as Ee,a as De,at as Oe,b as ke,ct as Ae,et as je,f as Me,ft as Ne,g as Pe,i as Fe,it as Ie,j as Le,k as B,l as Re,lt as V,m as ze,n as Be,nt as Ve,o as He,ot as Ue,p as We,q as Ge,r as H,rt as Ke,s as U,t as qe,tt as Je,u as Ye,ut as Xe,v as Ze,w as W,x as G,z as Qe}from"./live-BGLA-peO.js";var K=Object.create,$e=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=Object.getOwnPropertyNames,nt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty,it=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),q=(e,t)=>{let n={};for(var r in e)$e(n,r,{get:e[r],enumerable:!0});return t||$e(n,Symbol.toStringTag,{value:`Module`}),n},J=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=tt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!rt.call(e,s)&&s!==n&&$e(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=et(t,s))||r.enumerable});return e},at=(e,t,n)=>(n=e==null?{}:K(nt(e)),J(t||!e||!e.__esModule||!rt.call(e,`default`)?$e(n,`default`,{value:e,enumerable:!0}):n,e)),ot=[`machine`,`harness`,`state`,`team`,`role`,`project`,`workspace`,`tag`,`meta`],Y={machine:`Machine`,harness:`Harness`,state:`State`,team:`Team`,role:`Role`,project:`Project`,workspace:`Workspace`,tag:`Tag`,meta:`Metadata`},st=`watchtower.filtersOpen`,ct=`watchtower.legendOpen`;function lt(e,t={}){let n=[];for(let r of ot){let i=e[r];if(!i)continue;let a=r===`state`?z[e.state]:r===`machine`||r===`harness`||r===`team`?t[r]?.(i)??i:i;n.push({key:r,label:Y[r],value:a,clear:{[r]:void 0}})}if(e.q&&n.push({key:`q`,label:`Search`,value:e.q,clear:{q:void 0}}),e.kinds){let t=ie(e).kinds.size;n.push({key:`kinds`,label:`Lines`,value:t===be.length?`all kinds`:`${t} of ${be.length} kinds`,clear:{kinds:void 0}})}return e.tree===!1&&n.push({key:`tree`,label:`Session tree`,value:`off`,clear:{tree:void 0}}),n}var ut=e=>lt(e).filter(e=>e.key!==`q`).length,dt=(e,t)=>ot.filter(n=>!!e[n]||t.includes(n)),ft=(e,t)=>{let n=new Set(dt(e,t));return ot.filter(e=>!n.has(e))},pt=(e,t)=>e===`1`||e!==`0`&&t;function mt(e,t,n){if(!(n<=0))switch(t){case`ArrowRight`:case`ArrowDown`:return(e+1)%n;case`ArrowLeft`:case`ArrowUp`:return(e-1+n)%n;case`Home`:return 0;case`End`:return n-1;default:return}}var ht=2500;function gt(e){return e.panelOpen||e.focusInside||e.hover?!1:e.now-e.lastActivity>=ht}var _t=(e,t)=>e>Math.min(120,t/4),vt=x(`<div class=wt-backdrop aria-hidden=true>`),yt=x(`<section role=dialog tabindex=-1><header class=wt-panel-head><h2></h2></header><div class=wt-panel-body>`),bt=x(`<div class=wt-handle aria-hidden=true>`);function xt(e){let r,i=t=>{e.onClose(),t&&e.opener&&queueMicrotask(()=>document.getElementById(e.opener)?.focus())};return T(()=>{e.autoFocus&&r.focus({preventScroll:!0})}),[n(s,{get when(){return e.phone},get children(){var e=vt();return e.$$click=()=>i(!1),e}}),(()=>{var a=yt(),s=a.firstChild,c=s.firstChild,l=s.nextSibling;a.$$keydown=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),i(!0))};var u=r;return typeof u==`function`?t(u,a):r=a,f(a,n(St,{onClose:()=>i(!1)}),s),f(c,()=>e.title),f(s,()=>e.actions,null),f(s,n(b,{icon:`close`,get label(){return`Close ${e.title.toLowerCase()}`},onClick:()=>i(!0)}),null),f(l,()=>e.children),o(t=>{var n=e.id,r=`wt-panel wt-sheetable ${e.class??``}`,i=!!e.phone,o=e.phone?`true`:`false`,s=`${e.id}-title`,l=`${e.id}-title`;return n!==t.e&&p(a,`id`,t.e=n),r!==t.t&&_(a,t.t=r),i!==t.a&&a.classList.toggle(`wt-sheet`,t.a=i),o!==t.o&&p(a,`aria-modal`,t.o=o),s!==t.i&&p(a,`aria-labelledby`,t.i=s),l!==t.n&&p(c,`id`,t.n=l),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),a})()]}function St(e){let t=0,n=0,r=null,i=t=>{if(!r)return;let i=r.offsetHeight;r.style.transform=``,r.style.transition=``,r=null,t&&_t(n,i)&&e.onClose()};return(()=>{var e=bt();return e.addEventListener(`pointercancel`,()=>i(!1)),e.$$pointerup=()=>i(!0),e.$$pointermove=e=>{r&&(n=Math.max(0,e.clientY-t),r.style.transform=`translateY(${n}px)`)},e.$$pointerdown=e=>{r=e.currentTarget.closest(`.wt-sheetable`),r&&(t=e.clientY,n=0,r.style.transition=`none`,e.currentTarget.setPointerCapture?.(e.pointerId))},e})()}D([`click`,`keydown`,`pointerdown`,`pointermove`,`pointerup`]);var Ct=x(`<div class=te-row><button type=button class="btn small">Edit team</button><a class="btn small">Open team page`),wt=x(`<p role=alert class=wt-error>Could not load the timeline: <!> <button type=button class=btn>Retry`),Tt=x(`<p class=muted>Loading…`),Et=x(`<p class=muted>No messages in this window.`),Dt=x(`<button type=button class=btn>Load older`),Ot=x(`<aside class="wt-slider wt-sheetable"aria-label=Details><header class=wt-slider-head><h2></h2></header><div class=wt-slider-body><section class=wt-section><h3>Timeline</h3><ol class=wt-timeline>`),kt=x(`<p class=muted>This is no longer in the chosen window.`),At=x(`<span class=muted>Loading…`),jt=x(`<span class=wt-error>`),Mt=x(`<div class=wt-text>`),Nt=x(`<div class="wt-text wt-answer"><span class=muted>Answer: `),Pt=x(`<li><div class=wt-tl-row><span class=wt-tl-kind></span><span> → </span><span class=muted> · `),Ft=x(`<button type=button class="btn wt-show-text">Show text`),It=x(`<dl class=wt-facts>`),Lt=x(`<dt>`),Rt=x(`<dd>`),zt=x(`<section class=wt-section><h3>Members</h3><ul class=wt-peers>`),Bt=x(`<p class=wt-actions><a class="btn primary"href=/concierge>`),Vt=x(`<span class="btn wt-drag"draggable=true title="Drag onto a pane: an edge splits, the centre replaces"aria-hidden=true> Drag into a pane`),Ht=x(`<p class=wt-actions><a class="btn primary">Open session</a> <button type=button class=btn>Open in pane beside</button> <button type=button class=btn>Start side chat…`),Ut=x(`<section class=wt-section><h3>Supervised by</h3><button type=button class=wt-link>`),Wt=x(`<section class=wt-section><h3>Parent</h3><button type=button class=wt-link>`),Gt=x(`<section class=wt-section><h3>Subsessions</h3><ul class=wt-peers>`),Kt=x(`<section class=wt-section><h3>Talks with</h3><ul class=wt-peers>`),qt=x(`<li><button type=button class=wt-link></button><span class=muted> · `),Jt=x(`<li><button type=button class=wt-link>`),Yt=x(`<p class=wt-endpoints><button type=button class=wt-link></button><span aria-hidden=true> → </span><span class=sr-only> to </span><button type=button class=wt-link>`),Xt={msg:`Message`,ask:`Ask`,reply:`Reply`,decline:`Decline`};function Zt(i){let u,h=e=>i.snap.nodes.find(t=>t.id===e)?.label??e,[g,_]=c([]),[x,S]=c(),[C,w]=c(`loading`),[D,O]=c(``),[k,A]=c({}),j=0,M=async e=>{let t=++j,n=i.selection;w(`loading`);try{let r=await ke(n,i.window,Date.now(),e?x():void 0);if(t!==j)return;_(e?[...g(),...r.messages]:r.messages),S(r.cursor),w(`ready`)}catch(e){if(t!==j)return;O(ae(e).message),w(`error`)}};m(e(()=>`${i.selection.type}:${i.selection.id}:${i.window}`,()=>{_([]),S(void 0),A({}),M(!1)}));let N=async e=>{A({...k(),[e]:`loading`});try{let t=await G(e);A({...k(),[e]:t})}catch(t){A({...k(),[e]:{error:ae(t).message}})}};T(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&!y()&&i.onClose()};document.addEventListener(`keydown`,e),v(()=>document.removeEventListener(`keydown`,e))});let P=()=>i.edge?i.edge.label:i.node?.title??i.selection.id;return(()=>{var e=Ot(),c=e.firstChild,m=c.firstChild,_=c.nextSibling,v=_.firstChild,y=v.firstChild.nextSibling,S=u;return typeof S==`function`?t(S,e):u=e,f(e,n(St,{onClose:()=>i.onClose()}),c),f(m,P),f(c,n(b,{icon:`close`,label:`Close details`,onClick:()=>i.onClose()}),null),f(_,n(d,{get fallback(){return kt()},get children(){return[n(a,{get when(){return i.edge},children:e=>n(rn,{get edge(){return e()},get onSelect(){return i.onSelect}})}),n(a,{get when(){return i.node},children:e=>n(nn,{get node(){return e()},label:h,get onSelect(){return i.onSelect}})})]}}),v),f(_,n(s,{get when(){return r(()=>i.node?.kind===`team`)()&&i.onEditTeam},get children(){var e=Ct(),t=e.firstChild,n=t.nextSibling;return t.$$click=()=>i.onEditTeam(i.node.id),o(()=>p(n,`href`,`/teams/${encodeURIComponent(i.node.id)}`)),e}}),v),f(v,n(s,{get when(){return C()===`error`},get children(){var e=wt(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling;return f(e,D,t),n.$$click=()=>void M(!1),e}}),y),f(y,n(l,{get each(){return g()},children:e=>{let t=()=>k()[e.id];return(()=>{var i=Pt(),o=i.firstChild.firstChild,c=o.nextSibling,l=c.firstChild,u=c.nextSibling,p=u.firstChild;return f(o,()=>Xt[e.kind]??e.kind),f(c,()=>h(e.from),l),f(c,()=>h(e.to),null),f(u,()=>e.state,p),f(u,(()=>{var t=r(()=>!!e.delivery);return()=>t()?` · ${Qe(e.delivery)}`:``})(),p),f(u,()=>e.decisionID?` · Decision`:``,p),f(u,()=>E(e.at),null),f(i,n(d,{get fallback(){return(()=>{var t=Ft();return t.$$click=()=>void N(e.id),t})()},get children(){return[n(a,{get when(){return t()===`loading`},get children(){return At()}}),n(a,{get when(){return r(()=>typeof t()==`object`&&t()!==null)()&&`error`in t()},get children(){var e=jt();return f(e,()=>t().error),e}}),n(a,{get when(){return r(()=>typeof t()==`object`&&t()!==null)()&&`text`in t()},get children(){return[(()=>{var e=Mt();return f(e,()=>t().text),e})(),n(s,{get when(){return t().answer},get children(){var e=Nt();return e.firstChild,f(e,()=>t().answer,null),e}})]}})]}}),null),i})()}})),f(v,n(s,{get when(){return C()===`loading`},get children(){return Tt()}}),null),f(v,n(s,{get when(){return r(()=>C()===`ready`)()&&!g().length},get children(){return Et()}}),null),f(v,n(s,{get when(){return r(()=>C()===`ready`)()&&x()},get children(){var e=Dt();return e.$$click=()=>void M(!0),e}}),null),e})()}function Qt(e){return(()=>{var t=It();return f(t,n(l,{get each(){return e.rows.filter(e=>e[1]!==void 0&&e[1]!==``)},children:([e,t])=>[(()=>{var t=Lt();return f(t,e),t})(),(()=>{var e=Rt();return f(e,t),e})()]})),t})()}var $t=e=>Se(e),en=e=>e&&Object.keys(e).length?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):void 0,tn=e=>e?Object.entries(e).map(([e,t])=>`${e} ${t}`).join(`, `):void 0;function nn(e){let t=()=>e.node,i={current:`Concierge (hub-managed session)`,previous:`Previous Concierge session (ended)`,service:`The hub's Concierge service (its updates, digests and launches)`},a=()=>t().conciergeRole?i[t().conciergeRole]:t().concierge?i.current:{hub:`Hub`,user:`You`,app:`App`,machine:`Machine`,session:`Session`,team:`Team`}[t().kind];return[n(Qt,{get rows(){return[[`Kind`,a()],[`State`,t().ring?z[t().ring]:void 0],[`Machine`,t().machine],[`Harness`,t().harness],[`Project`,t().project],[`Mode`,t().team?.mode===`restricted`?`Restricted: only its team paths`:t().team?.mode===`open`?`Open: everyone may message everyone`:void 0],[`Entry role`,t().team?.entryRole],[`Paused`,t().team?.paused?`yes`:void 0],[t().kind===`team`?`Roles`:`Directory roles`,t().roles.join(`, `)||void 0],[`Teams`,t().seats.map(e=>`${e.team} (${e.role})`).join(`, `)||void 0],[`Tags`,(t().team?.tags??t().tags).join(`, `)||void 0],[`Launch labels`,en(t().labels)],[`Metadata`,en(t().team?.metadata)],[`Workspaces`,t().workspaceIDs.join(`, `)||void 0],[`Launch`,t().launchID],[`Last seen`,t().lastSeen?E(t().lastSeen):void 0],...t().kind===`hub`||t().kind===`machine`?[[`Messages through it`,t().routed]]:[[`Sent`,t().sent],[`Received`,t().received]],[`By kind`,Object.entries(t().byKind).map(([e,t])=>`${$t(e)} ${t}`).join(`, `)||void 0],[`Sessions`,t().states?Object.entries(t().states).map(([e,t])=>`${z[e]} ${t}`).join(`, `):void 0],[`Machines online`,t().machinesOnline?`${t().machinesOnline.online} of ${t().machinesOnline.total}`:void 0]]}}),n(s,{get when(){return t().team?.members.length},get children(){var r=zt(),i=r.firstChild.nextSibling;return f(i,n(l,{get each(){return[...t().team.members]},children:t=>(()=>{var n=qt(),r=n.firstChild,i=r.nextSibling;return i.firstChild,r.$$click=()=>e.onSelect({type:`node`,id:t.id}),f(r,()=>t.label),f(i,()=>t.role,null),n})()})),r}}),n(s,{get when(){return r(()=>!!t().openable)()&&t().concierge},get children(){var e=Bt(),n=e.firstChild;return f(n,()=>t().conciergeRole===`previous`?`Open the current Concierge`:`Open the Concierge`),e}}),n(s,{get when(){return r(()=>!!t().openable)()&&!t().concierge},get children(){var e=Ht(),r=e.firstChild,i=r.nextSibling.nextSibling,a=i.nextSibling.nextSibling;return i.$$click=()=>N(t().id),f(e,n(s,{get when(){return!R()},get children(){return[(()=>{var e=Vt(),r=e.firstChild;return O(e,`dragend`,re),e.addEventListener(`dragstart`,e=>L(e,{target:{sessionID:t().id},label:t().title})),f(e,n(w,{name:`grip`}),r),e})(),` `]}}),a),a.$$click=()=>I(t().id,t().workspaceIDs[0]?{workspaceID:t().workspaceIDs[0]}:{}),o(()=>p(r,`href`,A(t().id))),e}}),n(s,{get when(){return t().supervisorID},get children(){var n=Ut(),r=n.firstChild.nextSibling;return r.$$click=()=>e.onSelect({type:`node`,id:t().supervisorID}),f(r,()=>t().supervisorLabel??t().supervisorID),n}}),n(s,{get when(){return t().parentID},get children(){var n=Wt(),r=n.firstChild.nextSibling;return r.$$click=()=>e.onSelect({type:`node`,id:t().parentID}),f(r,()=>e.label(t().parentID)),n}}),n(s,{get when(){return t().children.length},get children(){var r=Gt(),i=r.firstChild.nextSibling;return f(i,n(l,{get each(){return[...t().children]},children:t=>(()=>{var n=Jt(),r=n.firstChild;return r.$$click=()=>e.onSelect({type:`node`,id:t}),f(r,()=>e.label(t)),n})()})),r}}),n(s,{get when(){return t().peers.length},get children(){var r=Kt(),i=r.firstChild.nextSibling;return f(i,n(l,{get each(){return[...t().peers]},children:t=>(()=>{var n=qt(),r=n.firstChild,i=r.nextSibling;return i.firstChild,r.$$click=()=>e.onSelect({type:`node`,id:t.id}),f(r,()=>t.label),f(i,()=>t.count,null),n})()})),r}})]}function rn(e){let t=()=>e.edge;return[(()=>{var n=Yt(),r=n.firstChild,i=r.nextSibling.nextSibling.nextSibling;return r.$$click=()=>e.onSelect({type:`node`,id:t().from}),f(r,()=>t().fromLabel),i.$$click=()=>e.onSelect({type:`node`,id:t().to}),f(i,()=>t().toLabel),n})(),n(Qt,{get rows(){return[[`Messages`,t().kind===`policy`?void 0:t().count],[`First`,t().firstAt?E(t().firstAt):void 0],[`Last`,t().lastAt?E(t().lastAt):void 0],[`States`,tn(t().states)],[`Delivery`,ve(t().delivery)],[`Declined`,t().declined],[`Refused by team policy`,t().denied],[`To a role address`,t().roleAddressed],[`Team`,t().teamLabel??t().teamID],[`Permitted kinds`,t().kinds?.join(`, `)],[`Permitted path`,t().permitted===void 0?void 0:t().permitted?`yes`:`no (refused attempts only)`]]}})]}D([`click`]);var an=x(`<svg viewBox="0 0 24 24"width=16 height=16 fill=none stroke=currentColor stroke-width=1.8 stroke-linecap=round stroke-linejoin=round aria-hidden=true>`),on=x(`<svg><path></svg>`,!1,!0,!1),sn=x(`<button type=button class=wt-dock-item><span class=wt-dock-text>`),cn=x(`<span class="wt-dock-matches muted"role=status> `),ln=x(`<span class=wt-dock-search><input type=search aria-label="Search nodes"placeholder="Search @name, role, machine…"><button type=button class=wt-dock-close aria-label="Close search"title="Close search">`),un=x(`<div class=wt-dock-wrap><div class=wt-dock role=toolbar aria-label="Watchtower controls"aria-orientation=horizontal><div class=wt-dock-seg role=group aria-label=View></div><span class=wt-dock-sep aria-hidden=true></span><span class=wt-dock-more>`),dn=x(`<button type=button class="wt-dock-item wt-dock-view">`),fn=x(`<span class=wt-badge aria-hidden=true>`),pn=x(`<button type=button class=wt-dock-item aria-label=Search title="Search nodes"aria-expanded=false>`),mn={filters:[`M4 6h16`,`M7 12h10`,`M10 18h4`],legend:[`M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z`,`M12 11v6`,`M12 7.5h.01`],teams:[`M9 11a3 3 0 1 0 0-6a3 3 0 0 0 0 6z`,`M3 20a6 6 0 0 1 12 0`,`M16 5.5a3 3 0 0 1 0 5.5`,`M21 20a6 6 0 0 0-4-5.6`],hub:[`M12 9a3 3 0 1 0 0 6a3 3 0 0 0 0-6z`,`M12 3v6`,`M12 15v6`,`M3 12h6`,`M15 12h6`],reset:[`M4 9V4h5`,`M20 9V4h-5`,`M4 15v5h5`,`M20 15v5h-5`],pause:[`M8 5v14`,`M16 5v14`],play:[`M7 5l12 7-12 7z`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 0 0 0-14z`,`M20 20l-4-4`],close:[`M6 6l12 12`,`M18 6L6 18`],more:[`M5 12h.01`,`M12 12h.01`,`M19 12h.01`]};function hn(e){return(()=>{var t=an();return f(t,n(l,{get each(){return[...mn[e.name]]},children:e=>(()=>{var t=on();return p(t,`d`,e),t})()})),o(()=>p(t,`class`,`wt-glyph wt-glyph-${e.name}`)),t})()}function gn(e){let r,i,[a,u]=c(!!e.search),[d,m]=c(!1),[h,_]=c(Date.now()),[y,b]=c(Date.now()),[x,S]=c(!1),[C,w]=c(!1),E=()=>gt({now:y(),lastActivity:h(),panelOpen:e.panelOpen,focusInside:C(),hover:x()}),D,O=()=>{let e=Date.now();e-h()<150&&!E()||(_(e),b(e),clearTimeout(D),D=setTimeout(()=>b(Date.now()),ht+50))},k=!1;T(()=>{let e=[`pointermove`,`pointerdown`,`touchstart`,`keydown`,`wheel`];for(let t of e)window.addEventListener(t,O,{passive:!0});let t=e=>{k&&(k=!1,e.preventDefault(),e.stopPropagation())};r.addEventListener(`click`,t,!0),O(),j();let n=r.parentElement,i=n?new ResizeObserver(()=>m(n.clientWidth<=540)):void 0;n&&i.observe(n),v(()=>i?.disconnect()),v(()=>{r.removeEventListener(`click`,t,!0);for(let t of e)window.removeEventListener(t,O);clearTimeout(D)})});let A=()=>[...r.querySelectorAll(`.wt-dock-item`)].filter(e=>e.offsetParent!==null&&!e.disabled),j=e=>{let t=A(),n=e&&t.includes(e)?e:t.find(e=>e.tabIndex===0)??t[0];for(let e of r.querySelectorAll(`.wt-dock-item`))e.tabIndex=e===n?0:-1},M=e=>{let t=e.target;if(t.tagName===`INPUT`||!t.classList.contains(`wt-dock-item`))return;let n=A(),r=mt(n.indexOf(t),e.key,n.length);r!==void 0&&(e.preventDefault(),n[r].focus())},N=!1,P=()=>{N=!0,u(!0)},F=()=>{u(!1),queueMicrotask(()=>i?.focus())},I=e=>(()=>{var t=sn(),r=t.firstChild;return t.$$click=()=>e.onClick(),f(t,n(s,{get when(){return e.glyph},children:e=>n(hn,{get name(){return e()}})}),r),f(r,()=>e.text),f(t,()=>e.badge,null),o(n=>{var r=e.id,i=!!e.wide,a=e.label,o=e.title??e.label,s=e.pressed,c=e.expanded,l=e.expanded?e.controls:void 0,u=e.disabled;return r!==n.e&&p(t,`id`,n.e=r),i!==n.t&&t.classList.toggle(`wt-dock-wide`,n.t=i),a!==n.a&&p(t,`aria-label`,n.a=a),o!==n.o&&p(t,`title`,n.o=o),s!==n.i&&p(t,`aria-pressed`,n.i=s),c!==n.n&&p(t,`aria-expanded`,n.n=c),l!==n.s&&p(t,`aria-controls`,n.s=l),u!==n.h&&(t.disabled=n.h=u),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),t})();return(()=>{var c=un(),u=c.firstChild,m=u.firstChild,h=m.nextSibling.nextSibling;u.$$focusout=e=>{r.contains(e.relatedTarget)||w(!1)},u.$$focusin=e=>{w(!0),e.target.classList.contains(`wt-dock-item`)&&j(e.target)},u.$$pointerdown=e=>{k=E()&&e.pointerType===`touch`},u.addEventListener(`pointerleave`,()=>S(!1)),u.addEventListener(`pointerenter`,()=>S(!0)),u.$$keydown=M;var _=r;return typeof _==`function`?t(_,u):r=u,f(m,n(l,{each:[[`3d`,`3D`],[`2d`,`2D`],[`list`,`List`]],children:([t,n])=>(()=>{var r=dn();return r.$$click=()=>e.setView(t),f(r,n),o(()=>p(r,`aria-pressed`,e.view===t)),r})()})),f(u,()=>I({id:`wt-dock-filters`,label:e.filterCount?`Filters (${e.filterCount} active)`:`Filters`,text:`Filters`,glyph:`filters`,expanded:e.filtersOpen,controls:`wt-filters`,onClick:e.onFilters,badge:n(s,{get when(){return e.filterCount},get children(){var t=fn();return f(t,()=>e.filterCount),t}})}),h),f(u,()=>I({id:`wt-dock-legend`,label:`Legend`,text:`Legend`,glyph:`legend`,expanded:e.legendOpen,controls:`wt-legend`,onClick:e.onLegend}),h),f(u,()=>I({id:`wt-dock-teams`,label:`Teams`,text:`Teams`,glyph:`teams`,pressed:e.teamsOpen,onClick:e.onTeams}),h),f(u,()=>I({label:`Hub details`,text:`Hub`,glyph:`hub`,wide:!0,onClick:e.onHub}),h),f(u,()=>I({label:`Reset view`,text:`Reset`,glyph:`reset`,wide:!0,disabled:!e.drawn,onClick:e.onReset}),h),f(u,()=>I({label:e.paused?`Resume motion`:`Pause motion`,text:e.paused?`Resume`:`Pause`,glyph:e.paused?`play`:`pause`,wide:!0,pressed:e.paused,disabled:e.reduced,...e.reduced?{title:`Motion is off: your system asks for reduced motion`}:{},onClick:e.onPause}),h),f(h,n(g,{label:`More controls`,class:`wt-dock-item`,up:!0,align:`right`,items:()=>[...d()?[{label:`Hub details`,run:e.onHub},{label:`Reset view`,run:e.onReset,disabled:!e.drawn},{label:e.paused?`Resume motion`:`Pause motion`,run:e.onPause,disabled:e.reduced}]:[],{label:`Re-layout`,run:()=>e.onRelayout?.(),disabled:!e.canRelayout}],get text(){return n(hn,{name:`more`})}})),f(u,n(s,{get when(){return a()},get fallback(){return(()=>{var e=pn();e.$$click=P;var r=i;return typeof r==`function`?t(r,e):i=e,f(e,n(hn,{name:`search`})),e})()},get children(){var r=ln(),i=r.firstChild,a=i.nextSibling;return f(r,n(hn,{name:`search`}),i),i.$$keydown=t=>{t.key===`Enter`?(t.preventDefault(),e.onSearchEnter()):t.key===`Escape`&&(t.preventDefault(),F())},i.$$input=t=>e.onSearch(t.currentTarget.value),t(e=>{N&&(N=!1,queueMicrotask(()=>e.focus()))},i),f(r,n(s,{get when(){return e.search.trim()},get children(){var t=cn(),n=t.firstChild;return f(t,()=>e.matches??0,n),f(t,()=>e.matches===1?`match`:`matches`,null),t}}),a),a.$$click=F,f(a,n(hn,{name:`close`})),o(()=>i.value=e.search),r}}),null),o(e=>{var t=E()?`true`:`false`,n=a()?`open`:void 0;return t!==e.e&&p(u,`data-faded`,e.e=t),n!==e.t&&p(u,`data-search`,e.t=n),e},{e:void 0,t:void 0}),c})()}D([`click`,`keydown`,`pointerdown`,`focusin`,`focusout`,`input`]);var _n=x(`<label class=wt-field><span></span><input type=text class=wt-meta aria-label=Metadata aria-describedby=wt-meta-help placeholder="key=value"list=wt-meta-keys><datalist id=wt-meta-keys></datalist><span id=wt-meta-help class=sr-only>Launch labels and team metadata: key=value or key, several separated by spaces (all must match).`),vn=x(`<option>`),yn=x(`<fieldset class=wt-fs><legend>View</legend><div class=wt-fs-row><label class=wt-field><span>Time window</span><select aria-label="Time window"></select></label><label class=wt-field><span>Group by</span><select aria-label="Group by"></select></label><label class=wt-check><input type=checkbox><span>Session tree`),bn=x(`<div class=wt-scope>`),xn=x(`<select class=wt-add aria-label="Add filter"><option value selected>+ Add filter`),Sn=x(`<fieldset class=wt-fs><legend>Scope`),Cn=x(`<fieldset class=wt-fs><legend>Show</legend><div class=wt-kinds>`),wn=x(`<form class=wt-preset-form><input type=text aria-label="Preset name"placeholder="Preset name"maxlength=60><button type=submit class="btn small">Save</button><button type=button class="btn small">Cancel`),Tn=x(`<button type=button class="btn small">Delete preset`),En=x(`<footer class=wt-panel-foot role=group aria-label=Presets><select aria-label="Filter presets"><option value></option></select><span class=wt-foot-gap></span><button type=button class="btn small">Clear filters</button><button type=button class="btn small">Copy link</button><span class="muted wt-copied"role=status>`),Dn=x(`<p class="muted wt-fs-empty">Everything is shown. Add a filter to narrow it.`),On=x(`<div class=wt-scope-row><button type=button class=wt-x>×`),kn=x(`<label class=wt-toggle><input type=checkbox><span>`),An=x(`<button type=button class="btn small">Save preset`),jn=x(`<button type=button class=wt-chip-clear>Clear all`),Mn=x(`<div class=wt-chipbar><ul class=wt-chips aria-label="Active filters">`),Nn=x(`<li class=wt-chip><span><span class=wt-chip-label>:</span> </span><button type=button class=wt-x title=Remove>×`),Pn=x(`<label class=wt-field><span></span><select><option value>`),Fn={machine:void 0,harness:void 0,state:void 0,team:void 0,role:void 0,project:void 0,workspace:void 0,tag:void 0,meta:void 0,q:void 0,kinds:void 0,tree:void 0},In={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}}};function Ln(e){let[r,i]=c([]),a=()=>dt(e.url,r()),u=()=>ft(e.url,r()),d=()=>ie(e.url).kinds,m=(t,n)=>e.setURL({[t]:n.trim()?n:void 0}),h=e=>{i([...r(),e]),queueMicrotask(()=>document.getElementById(`wt-scope-${e}`)?.focus())},g=t=>{i(r().filter(e=>e!==t)),e.setURL({[t]:void 0})},_=(t,n)=>{let r=new Set(d());n?r.add(t):r.delete(t),e.setURL({kinds:be.filter(e=>r.has(e))})},[v,y]=c(je(In.get(oe))),[b,x]=c(``),[S,C]=c(!1),[w,T]=c(``),[E,D]=c(``),O=e=>{y(e),In.set(oe,JSON.stringify(e))},k=t=>{x(t);let n=v().find(e=>e.name===t);n&&e.go(se(e.url,n.search))},A=()=>{let t=w().trim();t&&(O(Oe(v(),t,Ke(e.url))),x(t),C(!1),T(``))},j=async()=>{try{await navigator.clipboard.writeText(location.href),D(`Link copied`)}catch{D(`Copy the address bar to share these filters`)}setTimeout(()=>D(``),3e3)},M=t=>{let r=Y[t],i=`wt-scope-${t}`;switch(t){case`machine`:return n(X,{id:i,label:r,all:`All machines`,get value(){return e.url.machine},get options(){return e.machines},onChange:e=>m(t,e)});case`harness`:return n(X,{id:i,label:r,all:`All harnesses`,get value(){return e.url.harness},get options(){return e.harnesses},onChange:e=>m(t,e)});case`state`:return n(X,{id:i,label:r,all:`Any state`,get value(){return e.url.state},get options(){return he.map(e=>({value:e,label:z[e]}))},onChange:t=>e.setURL({state:t||void 0})});case`team`:return n(X,{id:i,label:r,all:`All teams`,get value(){return e.teamValue},get options(){return e.choices.teams.map(e=>({value:e.id,label:e.label}))},onChange:e=>m(t,e)});case`role`:return n(X,{id:i,label:r,all:`Any role`,get value(){return e.url.role},get options(){return e.choices.roles.map(e=>({value:e,label:e}))},onChange:e=>m(t,e)});case`project`:return n(X,{id:i,label:r,all:`All projects`,get value(){return e.url.project},get options(){return e.choices.projects.map(e=>({value:e,label:e}))},onChange:e=>m(t,e)});case`workspace`:return n(X,{id:i,label:r,all:`All workspaces`,get value(){return e.url.workspace},get options(){return e.choices.workspaces.map(e=>({value:e,label:e}))},onChange:e=>m(t,e)});case`tag`:return n(X,{id:i,label:r,all:`Any tag`,get value(){return e.url.tag},get options(){return e.choices.tags.map(e=>({value:e,label:e}))},onChange:e=>m(t,e)});case`meta`:return(()=>{var t=_n(),a=t.firstChild,s=a.nextSibling,c=s.nextSibling;return p(t,`for`,i),f(a,r),s.$$input=e=>m(`meta`,e.currentTarget.value),s.addEventListener(`change`,e=>m(`meta`,e.currentTarget.value)),p(s,`id`,i),f(c,n(l,{get each(){return[...e.choices.metaKeys]},children:e=>(()=>{var t=vn();return t.value=`${e}=`,t})()})),o(()=>s.value=e.url.meta??``),t})()}};return n(xt,{id:`wt-filters`,title:`Filters`,class:`wt-pop wt-pop-filters`,get phone(){return e.phone},get autoFocus(){return e.autoFocus},opener:`wt-dock-filters`,get onClose(){return e.onClose},get children(){return[(()=>{var t=yn(),r=t.firstChild.nextSibling.firstChild,i=r.firstChild.nextSibling,a=r.nextSibling,s=a.firstChild.nextSibling,c=a.nextSibling.firstChild;return i.addEventListener(`change`,t=>e.setURL({window:t.currentTarget.value})),f(i,n(l,{get each(){return Object.entries(ge)},children:([t,n])=>(()=>{var r=vn();return r.value=t,f(r,()=>n.label),o(()=>r.selected=e.url.window===t),r})()})),s.addEventListener(`change`,t=>e.setURL({groupBy:t.currentTarget.value})),f(s,n(l,{get each(){return Object.entries(W)},children:([t,n])=>(()=>{var r=vn();return r.value=t,f(r,n),o(()=>r.selected=e.url.groupBy===t),r})()})),c.addEventListener(`change`,t=>e.setURL({tree:t.currentTarget.checked?void 0:!1})),o(()=>c.checked=e.url.tree!==!1),t})(),(()=>{var e=Sn();return e.firstChild,f(e,n(s,{get when(){return a().length},get fallback(){return Dn()},get children(){var e=bn();return f(e,n(l,{get each(){return a()},children:e=>(()=>{var t=On(),n=t.firstChild;return f(t,()=>M(e),n),n.$$click=()=>g(e),o(t=>{var r=`Remove ${Y[e]} filter`,i=`Remove ${Y[e]} filter`;return r!==t.e&&p(n,`aria-label`,t.e=r),i!==t.t&&p(n,`title`,t.t=i),t},{e:void 0,t:void 0}),t})()})),e}}),null),f(e,n(s,{get when(){return u().length},get children(){var e=xn();return e.firstChild,e.addEventListener(`change`,e=>{let t=e.currentTarget.value;e.currentTarget.value=``,t&&h(t)}),f(e,n(l,{get each(){return u()},children:e=>(()=>{var t=vn();return t.value=e,f(t,()=>Y[e]),t})()}),null),e}}),null),e})(),(()=>{var e=Cn(),t=e.firstChild.nextSibling;return f(t,n(l,{get each(){return[...ce()]},children:e=>(()=>{var t=kn(),n=t.firstChild,r=n.nextSibling;return n.addEventListener(`change`,t=>_(e.kind,t.currentTarget.checked)),f(r,()=>e.label),o(()=>p(t,`title`,e.description)),o(()=>n.checked=d().has(e.kind)),t})()})),e})(),(()=>{var r=En(),a=r.firstChild,c=a.firstChild,u=a.nextSibling,d=u.nextSibling,p=d.nextSibling,m=p.nextSibling;return a.addEventListener(`change`,e=>k(e.currentTarget.value)),f(c,()=>v().length?`Choose a preset…`:`No presets yet`),f(a,n(l,{get each(){return v()},children:e=>(()=>{var t=vn();return f(t,()=>e.name),o(()=>t.selected=b()===e.name),o(()=>t.value=e.name),t})()}),null),f(r,n(s,{get when(){return S()},get fallback(){return(()=>{var e=An();return e.$$click=()=>C(!0),e})()},get children(){var e=wn(),n=e.firstChild,r=n.nextSibling,i=r.nextSibling;return e.addEventListener(`submit`,e=>{e.preventDefault(),A()}),t(e=>queueMicrotask(()=>e.focus()),n),n.$$input=e=>T(e.currentTarget.value),i.$$click=()=>C(!1),o(()=>r.disabled=!w().trim()),o(()=>n.value=w()),e}}),u),f(r,n(s,{get when(){return b()},get children(){var e=Tn();return e.$$click=()=>{O(fe(v(),b())),x(``)},e}}),u),d.$$click=()=>{i([]),e.setURL(Fn)},p.$$click=()=>void j(),f(m,E),o(t=>{var n=b()===``,r=!lt(e.url).length;return n!==t.e&&(c.selected=t.e=n),r!==t.t&&(d.disabled=t.t=r),t},{e:void 0,t:void 0}),r})()]}})}function Rn(e){return n(s,{get when(){return e.chips.length},get children(){var t=Mn(),r=t.firstChild;return f(r,n(l,{get each(){return e.chips},children:t=>(()=>{var n=Nn(),r=n.firstChild,i=r.firstChild,a=i.firstChild;i.nextSibling;var s=r.nextSibling;return f(i,()=>t.label,a),f(r,()=>t.value,null),s.$$click=()=>e.onRemove(t),o(()=>p(s,`aria-label`,`Remove filter ${t.label}: ${t.value}`)),n})()})),f(t,n(s,{get when(){return e.chips.length>1},get children(){var t=jn();return t.$$click=()=>e.onClear(),t}}),null),t}})}function X(e){let t=()=>e.value&&!e.options.some(t=>t.value===e.value)?[...e.options,{value:e.value,label:e.value}]:e.options;return(()=>{var r=Pn(),i=r.firstChild,a=i.nextSibling,s=a.firstChild;return f(i,()=>e.label),a.addEventListener(`change`,t=>e.onChange(t.currentTarget.value)),f(s,()=>e.all),f(a,n(l,{get each(){return t()},children:t=>(()=>{var n=vn();return f(n,()=>t.label),o(()=>n.selected=e.value===t.value),o(()=>n.value=t.value),n})()}),null),o(t=>{var n=e.id,i=e.id,o=e.label,c=!e.value;return n!==t.e&&p(r,`for`,t.e=n),i!==t.t&&p(a,`id`,t.t=i),o!==t.a&&p(a,`aria-label`,t.a=o),c!==t.o&&(s.selected=t.o=c),t},{e:void 0,t:void 0,a:void 0,o:void 0}),r})()}D([`input`,`click`]);var zn=x(`<div class="wt-canvas wt-2d"><div class=wt-2d-host tabindex=0 role=application aria-roledescription="graph canvas"aria-label="Interaction graph (2D)"aria-describedby=wt-2d-help></div><p id=wt-2d-help class=sr-only>Arrow keys move between nodes, Enter opens the focused node, Home goes to the hub, Shift and arrow keys pan, plus and minus zoom, 0 fits everything. The list view shows the same as a table.</p><p class="sr-only wt-2d-live"role=status aria-live=polite>`);function Bn(e){let n,r,i=!1,a,[o,s]=c(``);return T(()=>{P(()=>import(`./renderer2d-DyANQ1WS.js`).then(t=>{if(i)return;try{r=t.createRenderer2D(n,{onNode:t=>e.onNode(t),onLink:t=>e.onLink(t),onBackground:()=>e.onBackground(),announce:s})}catch(t){e.onFail(t);return}r.resize(n.clientWidth,n.clientHeight),a=e.onRenderer?.(r,n),m(()=>r?.update(e.view,e.palette,{motion:e.motion,...e.selected===void 0?{}:{selected:e.selected},...e.look?{look:e.look}:{}})),m(()=>{let t=e.focus;t&&r?.focus(t.id,e.motion)});let o=!0;m(()=>{e.resetSeq,o?o=!1:r?.reset(e.motion)})}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).catch(t=>!i&&e.onFail(t));let t=new ResizeObserver(()=>r?.resize(n.clientWidth,n.clientHeight));t.observe(n),v(()=>{i=!0,t.disconnect(),a?.(),r?.destroy(),r=void 0})}),(()=>{var e=zn(),r=e.firstChild,i=r.nextSibling.nextSibling,a=n;return typeof a==`function`?t(a,r):n=r,f(i,o),e})()}var Vn=x(`<div class=wt-canvas>`);function Hn(){try{let e=document.createElement(`canvas`);return!!(e.getContext(`webgl2`)??e.getContext(`webgl`))}catch{return!1}}function Un(e){let n,r,i=!1,a;return T(()=>{P(()=>import(`./renderer3d-vYYKFAJq.js`).then(t=>{if(i)return;try{r=t.createRenderer(n,{onNode:t=>e.onNode(t),onLink:t=>e.onLink(t),onBackground:()=>e.onBackground()},{motion:e.motion,...e.options?{options:e.options}:{}})}catch(t){e.onFail(t);return}r.resize(n.clientWidth,n.clientHeight),a=e.onRenderer?.(r)??void 0,m(()=>e.options&&r?.setOptions(e.options)),m(()=>r?.setSelected(e.selected));let o=!1;m(()=>{r?.update(e.view,e.palette,e.motion),o||(o=!0,setTimeout(()=>r?.reset(!1),250))}),m(()=>{let t=e.focus;t&&r?.focus(t.id,e.motion)});let s=!0;m(()=>{e.resetSeq,s?s=!1:r?.reset(e.motion)})}),__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,10,11,12,14])).catch(t=>!i&&e.onFail(t));let t=new ResizeObserver(()=>r?.resize(n.clientWidth,n.clientHeight));t.observe(n);let o=()=>document.visibilityState===`hidden`?r?.pause():r?.resume();document.addEventListener(`visibilitychange`,o),v(()=>{i=!0,a?.(),t.disconnect(),document.removeEventListener(`visibilitychange`,o),r?.destroy(),r=void 0})}),(()=>{var e=Vn(),r=n;return typeof r==`function`?t(r,e):n=e,e})()}var Wn={sphere:`circle`,cube:`square`,octahedron:`diamond`,tetrahedron:`triangle`,dodecahedron:`pentagon`};function Gn(e){switch(e.kind){case`hub`:return`hub`;case`machine`:return`hexagon`;case`user`:return`ring`;case`app`:return`hollow-triangle`;case`team`:case`cluster`:return`hollow-square`;case`role`:return e.vacant?`dashed-ring`:`pill`;case`aggregate`:return`dashed-ring`;default:return Wn[e.shape??`dodecahedron`]??`pentagon`}}var Kn=e=>e===`hexagon`||e===`ring`||e===`hollow-triangle`||e===`hollow-square`||e===`dashed-ring`||e===`pill`;function qn(e,t,n,r,i,a=-Math.PI/2){e.beginPath();for(let o=0;o<i;o++){let s=a+o*2*Math.PI/i;o===0?e.moveTo(t+r*Math.cos(s),n+r*Math.sin(s)):e.lineTo(t+r*Math.cos(s),n+r*Math.sin(s))}e.closePath()}function Jn(e,t,n,r,i){switch(t){case`square`:case`hollow-square`:e.beginPath(),e.roundRect(n-i*.82,r-i*.82,i*1.64,i*1.64,i*.28);return;case`diamond`:qn(e,n,r,i*1.08,4);return;case`triangle`:case`hollow-triangle`:qn(e,n,r+i*.15,i*1.12,3);return;case`pentagon`:qn(e,n,r,i,5);return;case`hexagon`:qn(e,n,r,i,6,0);return;case`pill`:e.beginPath(),e.roundRect(n-i*1.4,r-i*.6,i*2.8,i*1.2,i*.6);return;default:e.beginPath(),e.arc(n,r,i,0,Math.PI*2)}}function Yn(e,t,n,r,i,a,o=`#ffffff`){if(e.save(),Jn(e,t,n,r,i),Kn(t))e.lineWidth=Math.max(1.2,i*.24),e.strokeStyle=a,t===`dashed-ring`&&e.setLineDash([i*.5,i*.35]),e.stroke(),e.setLineDash([]),e.beginPath(),e.arc(n,r,i*.24,0,Math.PI*2),e.fillStyle=a,e.fill();else{let s=e.createRadialGradient(n-i*.25,r-i*.3,i*.05,n,r,i*1.1);s.addColorStop(0,o),s.addColorStop(t===`hub`?.45:.3,a),s.addColorStop(1,a),e.fillStyle=s,e.fill()}e.restore()}function Xn(e,t,n,r,i,a){if(a<=0||r<=0)return;e.save(),e.globalAlpha=Math.min(1,a);let o=e.createRadialGradient(t,n,0,t,n,r);o.addColorStop(0,Zn(i,.9)),o.addColorStop(.3,Zn(i,.32)),o.addColorStop(1,Zn(i,0)),e.fillStyle=o,e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill(),e.restore()}function Zn(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n)return e;let r=n[1].length===3?[...n[1]].map(e=>e+e).join(``):n[1],[i,a,o]=[0,2,4].map(e=>parseInt(r.slice(e,e+2),16));return`rgba(${i}, ${a}, ${o}, ${Math.max(0,Math.min(1,t))})`}function Qn(e){let t=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!t)return!1;let[n,r,i]=[0,2,4].map(e=>parseInt(t[1].slice(e,e+2),16)/255);return .2126*n+.7152*r+.0722*i<.4}var $n=x(`<canvas class=wt-glyph-swatch aria-hidden=true>`),er=x(`<details class=wt-legend-sec open><summary>Teams</summary><ul><li><span class="wt-hull wt-hull-open"aria-hidden=true></span><span>Open team <span class=muted>· solid hull: everyone may message everyone, so no lines are drawn</span></span></li><li><span class="wt-hull wt-hull-restricted"aria-hidden=true></span><span>Restricted team <span class=muted>· dashed hull: only its team paths</span></span></li><li><span class="wt-role wt-role-entry"aria-hidden=true>★</span><span>Entry role <span class=muted>· ★, bold and tinted: receives the team's work</span></span></li><li><span class=wt-role aria-hidden=true></span><span>Role <span class=muted>· a row of its members, each tied to it by a violet tether</span></span></li><li><span class="wt-role wt-role-vacant"aria-hidden=true></span><span>Vacant role <span class=muted>· hollow and dashed, labelled “vacant”: nobody holds it</span></span></li><li><span class="wt-line wt-line-solid wt-line-tether"aria-hidden=true></span><span>Staffed <span class=muted>· a tether from a role to each session that holds it</span></span></li><li><span class=wt-multi aria-hidden=true>×2</span><span>In several teams <span class=muted>· dotted outer ring and ×N, drawn once; a dashed bridge reaches each other seat`),tr=x(`<div class=wt-legend-body><details class=wt-legend-sec open><summary>Machines (color)</summary><ul></ul></details><details class=wt-legend-sec open><summary>Harness (glyph)</summary><ul></ul></details><details class=wt-legend-sec open><summary>Markers</summary><ul><li><span class=wt-region aria-hidden=true></span><span>Region <span class=muted>· a soft tinted area per group of the current Group by (a machine keeps its colour)</span></span></li></ul></details><details class=wt-legend-sec open><summary>State (ring)</summary><ul></ul></details><details class=wt-legend-sec open><summary>Interactions (line)</summary><ul><li><span class="wt-line wt-line-solid wt-line-structure"aria-hidden=true></span><span>Structure <span class=muted>· thin grey: hub → group → session → subsession</span></span></li></ul><p class="muted wt-legend-note">Fibers brighten towards the receiver; brighter fibers carry more messages. Pulses travel along a fiber after a message, fade with its age, and stop once nothing on it is working or waiting.`),nr=x(`<button type=button class="btn small wt-compact"title="Hide the explanations">Compact`),rr=x(`<li><span class=wt-swatch role=img></span><span><span class=muted> · <!> sessions`),ir=x(`<li><span> <span class=muted>· <!> · `),ar=x(`<li><span> <span class=muted>· `),or=x(`<li><span aria-hidden=true></span><span> <span class=muted>· `),sr={sphere:`circle`,cube:`square`,octahedron:`diamond`,tetrahedron:`triangle`,dodecahedron:`pentagon`},cr={policy:`dotted; in 2D an arrowhead at one end is one-way, at both ends two-way`,denied:`dashed red with ✕ and the count`},lr=[{glyph:`hub`,color:`--accent`,label:`Hub`,text:`the bright core in the middle`},{glyph:`ring`,color:`--text`,label:`You`,text:`hollow circle`},{glyph:`hollow-triangle`,color:`--text`,label:`App`,text:`hollow triangle`},{glyph:`hexagon`,color:`--muted`,label:`Machine`,text:`hollow hexagon, at the head of its region`},{glyph:`hollow-square`,color:`--violet`,label:`Team or cluster`,text:`hollow square`},{glyph:`dashed-ring`,color:`--muted`,label:`Folded sessions`,text:`dashed ring with the count`}];function ur(e){let n,r=()=>e.size??14,[a,s]=c(0);return T(()=>{let e=matchMedia(`(prefers-color-scheme: dark)`),t=()=>s(e=>e+1);e.addEventListener(`change`,t),v(()=>e.removeEventListener(`change`,t))}),m(()=>{F(),a();let t=window.devicePixelRatio||1,i=r();n.width=Math.round(i*t),n.height=Math.round(i*t);let o=n.getContext(`2d`);if(!o)return;o.setTransform(t,0,0,t,0,0),o.clearRect(0,0,i,i);let s=getComputedStyle(n).getPropertyValue(e.color).trim()||`#888888`;Yn(o,e.glyph,i/2,i/2,i*.36,s,`#ffffff`)}),(()=>{var e=$n(),a=n;return typeof a==`function`?t(a,e):n=e,o(t=>{var n=`${r()}px`,a=`${r()}px`;return n!==t.e&&i(e,`width`,t.e=n),a!==t.t&&i(e,`height`,t.t=a),t},{e:void 0,t:void 0}),e})()}var dr={pulse:`pulsing ring`,thin:`thin ring`,thick:`thick ring`,double:`double ring`,broken:`broken ring`,none:`no ring`},fr=`watchtower.legendCompact`;function pr(e){let t=()=>e.view.teams.length>0||e.view.nodes.some(e=>e.teams||e.kind===`role`),[r,a]=c(mr(fr)===`1`),u=e=>{a(e);try{localStorage.setItem(fr,e?`1`:`0`)}catch{}};return n(xt,{id:`wt-legend`,title:`Legend`,get class(){return e.mode===`list`&&!e.phone?`wt-legend wt-panel-inline`:`wt-legend wt-pop wt-pop-legend`},get phone(){return e.phone},get autoFocus(){return e.autoFocus},opener:`wt-dock-legend`,get onClose(){return e.onClose},get actions(){return(()=>{var e=nr();return e.$$click=()=>u(!r()),o(()=>p(e,`aria-pressed`,r())),e})()},get children(){var a=tr(),c=a.firstChild,u=c.firstChild.nextSibling,d=c.nextSibling,m=d.firstChild.nextSibling,h=d.nextSibling,g=h.firstChild.nextSibling,v=g.firstChild,y=h.nextSibling,b=y.firstChild.nextSibling,x=y.nextSibling,S=x.firstChild.nextSibling,C=S.firstChild;return f(u,n(l,{get each(){return e.view.machines},children:e=>(()=>{var t=rr(),n=t.firstChild,r=n.nextSibling,a=r.firstChild,s=a.firstChild.nextSibling;return s.nextSibling,f(n,()=>e.symbol),f(r,()=>e.label,a),f(a,()=>e.sessions,s),f(a,()=>e.online?``:` · offline`,null),o(t=>{var r=`var(${e.color})`,a=`Marker ${e.symbol}`;return r!==t.e&&i(n,`color`,t.e=r),a!==t.t&&p(n,`aria-label`,t.t=a),t},{e:void 0,t:void 0}),t})()})),f(m,n(l,{get each(){return e.view.harnesses},children:e=>(()=>{var t=ir(),r=t.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild.nextSibling;return o.nextSibling,f(t,n(ur,{get glyph(){return sr[e.shape]},color:`--muted`}),r),f(r,()=>e.label,i),f(a,()=>pe[e.shape],o),f(a,()=>e.sessions,null),t})()})),f(g,n(l,{get each(){return[...lr]},children:e=>(()=>{var t=ar(),r=t.firstChild,i=r.firstChild,a=i.nextSibling;return a.firstChild,f(t,n(ur,{get glyph(){return e.glyph},get color(){return e.color}}),r),f(r,()=>e.label,i),f(a,()=>e.text,null),t})()}),v),f(b,n(l,{get each(){return[...he]},children:e=>(()=>{var t=or(),n=t.firstChild,r=n.nextSibling,a=r.firstChild,s=a.nextSibling;return s.firstChild,f(r,()=>z[e],a),f(s,()=>dr[Le[e]],null),o(t=>{var r=`wt-ring wt-ring-${Le[e]}`,a=`var(${B[e]})`;return r!==t.e&&_(n,t.e=r),a!==t.t&&i(n,`border-color`,t.t=a),t},{e:void 0,t:void 0}),t})()})),f(a,n(s,{get when(){return t()},get children(){return er()}}),x),f(S,n(l,{get each(){return[...ce()]},children:e=>(()=>{var t=or(),n=t.firstChild,r=n.nextSibling,a=r.firstChild,s=a.nextSibling;return s.firstChild,f(r,()=>e.label,a),f(s,()=>cr[e.kind]??`solid, dashed while waiting`,null),o(r=>{var a=e.description,o=`wt-line wt-line-${e.style}`,s=`var(${e.color})`;return a!==r.e&&p(t,`title`,r.e=a),o!==r.t&&_(n,r.t=o),s!==r.a&&i(n,`border-color`,r.a=s),r},{e:void 0,t:void 0,a:void 0}),t})()}),C),o(()=>a.classList.toggle(`wt-legend-compact`,!!r())),a}})}function mr(e){try{return localStorage.getItem(e)}catch{return null}}D([`click`]);var hr=x(`<p class=muted>No sessions match.`),gr=x(`<p class=muted>No interactions match.`),_r=x(`<div class=wt-list><table class=wt-table aria-label=Sessions><thead><tr><th scope=col>Session</th><th scope=col>Machine</th><th scope=col>Harness</th><th scope=col>State</th><th scope=col>Sent</th><th scope=col>Received</th></tr></thead><tbody></tbody></table><table class=wt-table aria-label=Interactions><thead><tr><th scope=col>Kind</th><th scope=col>From → to</th><th scope=col>Messages</th><th scope=col>Last</th></tr></thead><tbody>`),vr=x(`<span class=muted aria-hidden=true>↳ `),yr=x(`<tr><td><button type=button class=wt-link></button></td><td></td><td></td><td></td><td></td><td>`),br=x(`<span class=muted> (<!>)`),xr=x(`<tr><td></td><td><button type=button class=wt-link> → </button></td><td></td><td>`);function Sr(e){return(()=>{var t=_r(),a=t.firstChild,c=a.firstChild.nextSibling,u=a.nextSibling,d=u.firstChild.nextSibling;return f(t,()=>e.children,a),f(c,n(l,{get each(){return e.nodes},children:t=>(()=>{var r=yr(),a=r.firstChild,c=a.firstChild,l=a.nextSibling,u=l.nextSibling,d=u.nextSibling,p=d.nextSibling,m=p.nextSibling;return f(a,n(s,{get when(){return t.depth>0},get children(){return vr()}}),c),c.$$click=()=>e.onNode(t.id),f(c,()=>t.label),f(l,()=>t.machine),f(u,()=>t.harness),f(d,()=>t.state),f(p,()=>t.sent),f(m,()=>t.received),o(n=>{var o=e.selected===t.id,s=`${8+t.depth*16}px`;return o!==n.e&&r.classList.toggle(`selected`,n.e=o),s!==n.t&&i(a,`padding-left`,n.t=s),n},{e:void 0,t:void 0}),r})()})),f(t,n(s,{get when(){return!e.nodes.length},get children(){return hr()}}),u),f(d,n(l,{get each(){return e.edges},children:t=>(()=>{var i=xr(),a=i.firstChild,c=a.nextSibling,l=c.firstChild,u=l.firstChild,d=c.nextSibling,m=d.nextSibling;return f(a,()=>t.kind,null),f(a,n(s,{get when(){return t.style!==`solid`},get children(){var e=br(),n=e.firstChild.nextSibling;return n.nextSibling,f(e,()=>t.style===`dashed`?`waiting`:`permitted path`,n),e}}),null),l.$$click=()=>e.onEdge(t.id),f(l,()=>t.from,u),f(l,()=>t.to,null),f(d,()=>t.count),f(m,(()=>{var e=r(()=>!!t.lastAt);return()=>e()?E(t.lastAt):`—`})()),o(n=>{var r=e.selected===t.id,a=`${t.kind} from ${t.from} to ${t.to}`;return r!==n.e&&i.classList.toggle(`selected`,n.e=r),a!==n.t&&p(l,`aria-label`,n.t=a),n},{e:void 0,t:void 0}),i})()})),f(t,n(s,{get when(){return!e.edges.length},get children(){return gr()}}),null),t})()}D([`click`]);var[Cr,wr]=c(),[Tr,Er]=c(),[Dr,Or]=c(),kr=0,Z=Cr,Q=Tr,Ar=Dr,$=(e=`pick`)=>wr(e);function jr(){wr(void 0),Er(void 0)}var Mr=Er,Nr=e=>Or({...e,seq:++kr}),Pr=(e,t)=>getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t;function Fr(e,t,n,r){let i=Math.atan2(n.y-t.y,n.x-t.x);e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x-r*Math.cos(i-.4),n.y-r*Math.sin(i-.4)),e.lineTo(n.x-r*Math.cos(i+.4),n.y-r*Math.sin(i+.4)),e.closePath(),e.fill()}function Ir(e,t,n){let r=Math.hypot(t.x-e.x,t.y-e.y)||1,i=(t.x-e.x)/r,a=(t.y-e.y)/r;return[{x:e.x+i*n,y:e.y+a*n},{x:t.x-i*n,y:t.y-a*n}]}function Lr(e,t,n){let r,i,a=(t,n)=>{let a=Q(),o=e.layout();if(!a||!o)return;s(a.id,o.positions,n);let c=e=>o.positions.get(`role:${a.id}:${e}`),l=Pr(`--accent`,`#3b82f6`);if(t.lineWidth=2/Math.max(.5,n.k),t.strokeStyle=l,t.fillStyle=l,t.font=`${11/Math.max(.6,n.k)}px system-ui, sans-serif`,t.textAlign=`center`,a.spec.mode===`restricted`)for(let e of a.spec.edges){let n=c(e.from),r=c(e.to);if(!n||!r)continue;let[i,a]=Ir(n,r,16);t.setLineDash([6,4]),t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(a.x,a.y),t.stroke(),t.setLineDash([]),Fr(t,i,a,9),e.direction===`two-way`&&Fr(t,a,i,9),t.fillText(`${e.kinds.join(`+`)}${e.direction===`two-way`?` ⇄`:``}`,(i.x+a.x)/2,(i.y+a.y)/2-6)}if(r?.moved&&r.at){let e=o.positions.get(r.from);if(e){let a=i?o.positions.get(i)??r.at:r.at;t.setLineDash([]),t.lineWidth=3/Math.max(.5,n.k),t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(a.x,a.y),t.stroke(),Fr(t,e,a,11),i&&(t.beginPath(),t.arc(a.x,a.y,20,0,Math.PI*2),t.stroke())}}},o=``,s=(e,n,r)=>{let i=t.getBoundingClientRect(),a={};for(let[t,o]of n)(Xe(t,e)!==void 0||t.startsWith(`ses_`))&&(a[t]=[Math.round(i.left+o.x*r.k+r.x),Math.round(i.top+o.y*r.k+r.y)]);let s=JSON.stringify(a);s!==o&&(t.dataset.editorPoints=o=s)},c=e=>{let t=Q();return!!t&&(Xe(e,t.id)!==void 0||e.startsWith(`ses_`))},l=n=>{if(n.button!==0||!Q())return;let i=e.hitTest(n.clientX,n.clientY);i?.type===`node`&&c(i.id)&&(n.stopPropagation(),n.preventDefault(),n.target.setPointerCapture?.(n.pointerId),r={from:i.id,start:{x:n.clientX,y:n.clientY},moved:!1,pointer:n.pointerId},t.dataset.editorDrag=`pending`)},u=n=>{if(!r||n.pointerId!==r.pointer||(n.stopPropagation(),!r.moved&&Math.hypot(n.clientX-r.start.x,n.clientY-r.start.y)>5&&(r.moved=!0),!r.moved))return;r.at=e.toWorld(n.clientX,n.clientY);let o=e.hitTest(n.clientX,n.clientY),s=Q();i=o?.type===`node`&&s&&Ae(s.id,r.from,o.id)?o.id:void 0,t.dataset.editorDrag=i?`over`:`dragging`,e.setOverlay(a)},d=o=>{if(!r||o.pointerId!==r.pointer)return;o.stopPropagation();let s=r;r=void 0;let c=i;if(i=void 0,delete t.dataset.editorDrag,e.setOverlay(a),!s.moved)return n(s.from);let l=Q(),u=l&&c?Ae(l.id,s.from,c):void 0;u&&Nr(u)},f=()=>{r=void 0,i=void 0,delete t.dataset.editorDrag,e.setOverlay(a)};t.addEventListener(`pointerdown`,l,!0),t.addEventListener(`pointermove`,u,!0),t.addEventListener(`pointerup`,d,!0),t.addEventListener(`pointercancel`,f,!0);let p=C(n=>(m(()=>{let n=Q();t.dataset.editorPaths=n?String(n.spec.mode===`restricted`?n.spec.edges.length:0):``,e.setOverlay(n?a:void 0)}),n));return()=>{p(),t.removeEventListener(`pointerdown`,l,!0),t.removeEventListener(`pointermove`,u,!0),t.removeEventListener(`pointerup`,d,!0),t.removeEventListener(`pointercancel`,f,!0),e.setOverlay(void 0)}}var Rr=x(`<aside class="wt-slider wt-sheetable te-panel"aria-label="Team editor">`),zr=x(`<div class=wt-slider-head><h2>Teams`),Br=x(`<p role=alert class=wt-error>`),Vr=x(`<ul class="te-list te-team-list">`),Hr=x(`<section class=wt-section aria-labelledby=te-teams><div class="te-row te-picker-head"><h3 id=te-teams>Open a team</h3><button type=button class="btn small primary">New team</button></div><p class=muted>Teams also have their own page: <a href=/teams>Teams</a>.`),Ur=x(`<div class=wt-slider-body>`),Wr=x(`<p class=muted>No teams yet. Create one to staff roles and give it work.`),Gr=x(`<li><button type=button class=te-team-open><strong></strong><span class=muted>#`),Kr=x(`<div class=wt-slider-head><h2>`),qr=x(`<button type=button class="btn small">All teams`),Jr=x(`<div class="te-row te-panel-links"><span class=muted> #</span><a class="btn small">Open team page`),Yr=x(`<section class=wt-section aria-labelledby=te-members><h3 id=te-members>Members`),Xr=x(`<section class=wt-section aria-labelledby=te-intake><h3 id=te-intake>Submit a task to the team</h3><h4 class=te-sub>Recent tasks`),Zr=x(`<section class="wt-section te-draft"aria-labelledby=te-draft><h3 id=te-draft>Edit the team (draft)</h3><h4 class=te-sub id=te-details>Details</h4><h4 class=te-sub id=te-roles>Roles</h4><h4 class=te-sub id=te-paths>Communication paths`),Qr=x(`<section class=wt-section aria-labelledby=te-life><h3 id=te-life>Team</h3><div class=te-row><button type=button class="btn small"></button><button type=button class="btn small">All teams`),$r=x(`<div class="wt-slider-body te-body">`),ei=x(`<dt>Paths`),ti=x(`<dd>`),ni=x(`<dt>Tags`),ri=x(`<section class=wt-section aria-label="Team overview"><dl class=wt-facts><dt>Communication</dt><dd></dd><dt>Entry role</dt><dd></dd><dt>Roles</dt><dd></dd></dl><h3>Members</h3><button type=button class=btn>Edit with form`);function ii(e){return(()=>{var t=Rr();return f(t,n(St,{onClose:jr}),null),f(t,n(s,{get when(){return Z()===`pick`},get fallback(){return n(s,{get when(){return Z()},keyed:!0,children:t=>n(oi,u({id:t},e))})},get children(){return n(ai,e)}}),null),t})()}function ai(e){let[t,r]=c(),[i,a]=c(``),[u,d]=c(!1);return T(async()=>{try{r(await Ze())}catch(e){a(e instanceof k&&e.status===404?`This hub doesn't have teams yet.`:V(e).message)}}),[(()=>{var e=zr();return e.firstChild,f(e,n(b,{icon:`close`,label:`Close the team editor`,onClick:jr}),null),e})(),(()=>{var e=Ur();return f(e,n(s,{get when(){return i()},get children(){var e=Br();return f(e,i),e}}),null),f(e,n(s,{get when(){return t()},get children(){var e=Hr(),r=e.firstChild,i=r.firstChild.nextSibling,a=r.nextSibling;return i.$$click=()=>d(!0),f(e,n(s,{get when(){return t().length},get fallback(){return Wr()},get children(){var e=Vr();return f(e,n(l,{get each(){return t()},children:e=>(()=>{var t=Gr(),n=t.firstChild,r=n.firstChild,i=r.nextSibling;return i.firstChild,n.$$click=()=>$(e.id),f(r,()=>e.title),f(i,()=>e.name,null),f(i,()=>e.paused?` · paused`:``,null),f(i,()=>e.hasDraft?` · draft`:``,null),o(()=>p(n,`aria-label`,`Edit ${e.title}`)),t})()})),e}}),a),e}}),null),e})(),n(Be,{get open(){return u()},onClose:()=>d(!1),onCreated:t=>{e.onChanged(),$(t)}})]}function oi(t){let i=Pe(t.id,{intake:!0,onChanged:t.onChanged}),[a,l]=c(t.phone);T(()=>void i.load()),qe(()=>i.refresh(),i.openWork),m(()=>{let e=i.team(),t=i.spec();e&&t&&Mr({id:e.id,name:e.name,spec:t,...i.roster()?{seats:i.roster().seats}:{}})}),v(()=>Mr(void 0));let u,d,h=new Map,g=e=>t.snap?.nodes.find(t=>t.id===e)?.label??e;return m(e(Ar,e=>{if(e&&i.spec()&&!a()){if(e.type===`connect`)d?.prefill(e.from,e.to),i.setNotice({kind:`ok`,text:`Path ${e.from} → ${e.to}: choose its direction and kinds, then Add path.`});else if(e.type===`attach`){if(!i.publishedRoles().has(e.role))return i.setNotice({kind:`error`,text:`${e.role} isn't published yet: publish the draft, then staff it.`});i.setNotice({kind:`ok`,text:`Add ${g(e.sessionID)} to ${e.role}? Check its other teams, then confirm.`}),u?.add(e.role,e.sessionID)}else e.type===`role`&&queueMicrotask(()=>h.get(e.role)?.focus())}},{defer:!0})),[(()=>{var e=Kr(),t=e.firstChild;return f(t,(()=>{var e=r(()=>!!i.team());return()=>e()?`Team: ${i.spec()?.title||i.team().title}`:`Team`})()),f(e,n(b,{icon:`close`,label:`Close the team editor`,onClick:jr}),null),e})(),(()=>{var e=$r();return O(e,`keydown`,i.onKey,!0),f(e,n(s,{get when(){return i.loadError()},get children(){return[(()=>{var e=Br();return f(e,()=>i.loadError()),e})(),(()=>{var e=qr();return e.$$click=()=>$(`pick`),e})()]}}),null),f(e,n(s,{get when(){return r(()=>!!i.team())()&&i.spec()},get children(){return[(()=>{var e=Jr(),t=e.firstChild;t.firstChild;var r=t.nextSibling;return f(e,n(ze,{c:i}),t),f(t,()=>i.team().name,null),o(()=>p(r,`href`,H(i.team().id))),e})(),n(Re,{get notice(){return i.notice()}}),n(s,{get when(){return!a()},get fallback(){return n(si,{c:i,get snap(){return t.snap},onEdit:()=>l(!1)})},get children(){return[(()=>{var e=Yr();return e.firstChild,f(e,n(U,{c:i,get snap(){return t.snap},canvasHint:!0,handle:e=>u=e}),null),e})(),(()=>{var e=Xr(),r=e.firstChild.nextSibling;return f(e,n(We,{c:i}),r),f(e,n(He,{c:i,get snap(){return t.snap},limit:5}),null),e})(),(()=>{var e=Zr(),t=e.firstChild.nextSibling,r=t.nextSibling,a=r.nextSibling;return f(e,n(De,{c:i}),t),f(e,n(Fe,{c:i,withMode:!0}),r),f(e,n(Me,{c:i,roleInput:(e,t)=>h.set(e,t)}),a),f(e,n(Ye,{c:i,canvasHint:!0,handle:e=>d=e}),null),e})()]}}),(()=>{var e=Qr(),t=e.firstChild.nextSibling.firstChild,n=t.nextSibling;return t.$$click=()=>void i.togglePause(),f(t,()=>i.team().paused?`Resume team`:`Pause team`),n.$$click=()=>$(`pick`),o(()=>t.disabled=i.busy()),e})()]}}),null),e})()]}function si(e){let t=()=>e.c.read().published;return(()=>{var r=ri(),i=r.firstChild,a=i.firstChild.nextSibling,o=a.nextSibling.nextSibling,c=o.nextSibling.nextSibling,l=i.nextSibling.nextSibling;return f(a,()=>t().mode===`open`?`Open: everyone may message everyone`:`Restricted: only the drawn paths`),f(o,()=>t().entryRole),f(c,()=>t().roles.map(e=>e.label?`${e.name} (${e.label})`:e.name).join(`, `)),f(i,n(s,{get when(){return t().mode===`restricted`},get children(){return[ei(),(()=>{var e=ti();return f(e,()=>t().edges.map(e=>`${e.from} ${e.direction===`two-way`?`⇄`:`→`} ${e.to} (${e.kinds.join(`+`)})`).join(`, `)||`none`),e})()]}}),null),f(i,n(s,{get when(){return t().tags?.length},get children(){return[ni(),(()=>{var e=ti();return f(e,()=>t().tags.join(`, `)),e})()]}}),null),f(r,n(U,{get c(){return e.c},get snap(){return e.snap}}),l),O(l,`click`,e.onEdit,!0),r})()}D([`click`,`keydown`]);var ci=q({default:()=>Ni}),li=x(`<p role=status class=wt-notice>Older interactions may have been evicted: the hub keeps only the most recent messages.`),ui=x(`<p role=status class=wt-notice>The hub cut this graph at its limits. Narrow the time window to see everything.`),di=x(`<p role=status class=wt-notice> messages with archived or deleted sessions are left out.`),fi=x(`<p role=status class=wt-notice>Subsessions are folded into their root to keep the picture readable. The list shows every session.`),pi=x(`<p role=status class=wt-notice>Sessions are folded per group to keep the picture readable. Narrow the filters or pick another grouping to see them; the list shows every session.`),mi=x(`<p role=status class=wt-notice>3D needs WebGL, which this browser can't use, so here's the 2D view.`),hi=x(`<p role=status class=wt-notice>This graph is too large to draw, so here's the list. Narrow the filters or group by machine.`),gi=x(`<p role=alert class="wt-notice wt-error">Couldn't refresh: <!>. Showing the last snapshot. <button type=button class="btn small">Retry`),_i=x(`<p role=alert class=wt-error>Could not load the interaction graph: `),vi=x(`<button type=button class=btn>Retry`),yi=x(`<div class=wt-center>`),bi=x(`<div class=wt-center><p class=muted>Loading…`),xi=x(`<button type=button class="btn primary wt-empty-cta">Connect a machine`),Si=x(`<p class="muted small">Copy the one-line installer, run it on the machine, then approve the machine in Settings.`),Ci=x(`<div class=wt-empty><p class=muted>No sessions or interactions in this window yet.`),wi=x(`<div class=wt-page><header class="topbar wt-top"><h1 class=title>Watchtower</h1><span class="wt-live muted"role=status></span></header><div class=wt-notices></div><div class=wt-stage><div class=wt-overlay>`),Ti=x(`<p class=muted>`),Ei=x(`<p class="muted small">Start a session on a machine, or pick a longer time window in Filters.`),Di=3e3,Oi=3e4;function ki(){let e=matchMedia(`(prefers-color-scheme: dark)`),[t,n]=c(0),r=()=>n(e=>e+1);return e.addEventListener(`change`,r),v(()=>e.removeEventListener(`change`,r)),h(()=>{F(),t();let e=getComputedStyle(document.documentElement),n=new Map;return t=>{let r=n.get(t);return r===void 0&&n.set(t,r=e.getPropertyValue(t).trim()||`#888888`),r}})}function Ai(){let e=matchMedia(`(prefers-reduced-motion: reduce)`),[t,n]=c(e.matches),r=()=>n(e.matches);return e.addEventListener(`change`,r),v(()=>e.removeEventListener(`change`,r)),t}var ji={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}}},Mi=1100;function Ni(l){try{Ee(localStorage)}catch{}let[g,_]=c(Ve(ji.get(me))),x=h(()=>Je(j().search,g()),void 0,{equals:(e,t)=>Ue(e)===Ue(t)}),C=e=>M(`/watchtower${Ue(e,g()??`3d`)}`,{replace:!0}),w=e=>C({...x(),...e}),E=e=>{ji.set(me,e),_(e),w({view:e})},D=()=>x().q??``,[O,k]=c(!1),[A,N]=c(innerWidth),P=()=>!R()&&A()>=Mi,[F,I]=c(!R()&&pt(ji.get(`watchtower.filtersOpen`),!1)),[L,re]=c(!R()&&pt(ji.get(`watchtower.legendOpen`),innerWidth>=1280));F()&&L()&&innerWidth<1280&&re(!1);let[z,oe]=c(),se=e=>{oe(e?`filters`:void 0),I(e),ji.set(st,e?`1`:`0`),e&&fe(`filters`)},ce=e=>{oe(e?`legend`:void 0),re(e),ji.set(ct,e?`1`:`0`),e&&fe(`legend`)},fe=e=>{e!==`filters`&&!P()&&I(!1),e!==`legend`&&!P()&&re(!1),e!==`side`&&R()&&(S(x).selected&&J(void 0),Z()&&jr())},pe=Ai(),he=()=>!pe()&&!O(),ge=ki(),[ve]=c(Hn()),[be,Se]=c(!1),[De,Oe]=c(!1),[ke,Ae]=c(),[je,Me]=c(0),[Pe,Fe]=c(),Le=h(()=>x().window),[B,Re]=c(),[V,ze]=c(),[Be,He]=c(!0),We=0,H,Ke=0,U=async()=>{clearTimeout(H),H=void 0;let e=++Ke;We=Date.now(),He(!0);try{let t=await ye(de({window:S(Le)},Date.now()));if(e!==Ke)return;Re(t),ze(void 0)}catch(t){if(e!==Ke)return;ze(ae(t))}finally{e===Ke&&He(!1)}},qe=()=>{H||document.visibilityState===`hidden`||(H=setTimeout(()=>void U(),Math.max(0,We+Di-Date.now())))};m(e(Le,()=>void U())),T(()=>{let e=ne(e=>Te(e)&&qe()),t=setInterval(()=>document.visibilityState===`visible`&&Date.now()-We>=Oi&&void U(),5e3),n=()=>document.visibilityState===`visible`&&Date.now()-We>=Oi&&void U();document.addEventListener(`visibilitychange`,n),v(()=>{e(),clearInterval(t),clearTimeout(H),document.removeEventListener(`visibilitychange`,n)})});let Ye=h(()=>{let e=B(),t=Q();return e&&t?Ne(e,t,t.spec,t.seats):e});v(jr),T(()=>{let e=j().searchParams.get(`edit`);e&&$(e)}),m(e(Z,e=>e&&e!==`pick`&&S(x).groupBy!==`team`&&w({groupBy:`team`})));let Ze=h(()=>ie(x())),W=h(()=>{let e=Ye();return e?le(e,Ze(),{now:e.at,reducedMotion:!he()}):void 0}),G=h(()=>{let e=Ie({webgl:ve()&&!be(),tooLarge:W()?.tooLarge??!1,chosen:x().view});return e.mode===`2d`&&De()?{mode:`list`,reason:`chosen`}:e}),Qe=()=>G().reason,K=()=>G().mode===`3d`||G().mode===`2d`,$e=h(()=>{let e=B();return e?Ce(e):{teams:[],roles:[],projects:[],workspaces:[],tags:[],metaKeys:[]}}),et=h(()=>(B()?.nodes??[]).filter(e=>e.kind===`team`)),tt=h(()=>lt(x(),{machine:e=>W()?.machines.find(t=>t.id===e)?.label??e,harness:ue,team:e=>$e().teams.find(t=>t.id===e)?.label??e})),nt=h(()=>{let e=Ye(),t=W();return e&&t&&G().mode===`list`?we(e,t):{nodes:[],edges:[]}}),rt=h(()=>[...new Set((B()?.nodes??[]).filter(e=>e.kind===`session`).map(Ge))].sort((e,t)=>ue(e).localeCompare(ue(t)))),it=h(()=>{let e=B();return!!e&&!e.nodes.some(e=>e.kind===`session`)&&!e.edges.length}),q=()=>x().selected,J=e=>w({selected:e}),at=h(()=>{let e=B(),t=q();return e&&t?.type===`node`?_e(e,t.id):void 0}),ot=h(()=>{let e=B(),t=q();return e&&t?.type===`edge`?xe(e,t.id):void 0});m(e([q,Z],([e,t])=>(e||t)&&R()&&fe(`side`)));let Y=e=>{if(e.startsWith(`agg:`)||e.startsWith(`group:`))return;let t=Q(),n=t?Xe(e,t.id):void 0;if(n!==void 0)return Nr({type:`role`,role:n});let r=/^role:([^:]+):/.exec(e);J({type:`node`,id:r?r[1]:e})},dt=e=>{let t=B(),n=[...e.edgeIDs].sort((e,n)=>(t?.edges.find(e=>e.id===n)?.count??0)-(t?.edges.find(t=>t.id===e)?.count??0))[0];n&&J({type:`edge`,id:n})},ft=()=>{let e=W()?.nodes.find(e=>e.match&&!e.id.startsWith(`agg:`)&&!e.id.startsWith(`group:`)&&!e.id.startsWith(`role:`));e&&(J({type:`node`,id:e.id}),Ae({id:e.id,seq:(ke()?.seq??0)+1}))},mt=()=>!!(B()&&q())||!!Z(),ht=()=>R()?`0px`:Z()?`min(440px, 100%)`:B()&&q()?`min(380px, 100%)`:`0px`,gt;return T(()=>{let e=new ResizeObserver(()=>N(gt.clientWidth));e.observe(gt),N(gt.clientWidth),F()&&L()&&!P()&&re(!1);let t=e=>{e.key!==`Escape`||e.defaultPrevented||y()||q()||Z()||(F()?se(!1):L()&&ce(!1))};document.addEventListener(`keydown`,t),v(()=>{e.disconnect(),document.removeEventListener(`keydown`,t)})}),(()=>{var e=wi(),c=e.firstChild,l=c.firstChild,m=l.nextSibling,h=c.nextSibling,g=h.nextSibling,_=g.firstChild;f(c,n(s,{get when(){return R()},get children(){return n(b,{icon:`menu`,label:`Open sidebar`,onClick:ee})}}),l),f(m,()=>Be()&&B()?`Updating…`:``),f(c,n(s,{get when(){return!R()},get children(){return n(b,{icon:`sidebar`,label:`Toggle sidebar (⌘B)`,onClick:ee})}}),null),f(h,n(s,{get when(){return B()?.truncated},get children(){return li()}}),null),f(h,n(s,{get when(){return B()?.capped},get children(){return ui()}}),null),f(h,n(s,{get when(){return(B()?.hiddenMessages??0)>0},get children(){var e=di(),t=e.firstChild;return f(e,()=>B().hiddenMessages,t),e}}),null),f(h,n(s,{get when(){return r(()=>W()?.lod===`roots`)()&&K()},get children(){return fi()}}),null),f(h,n(s,{get when(){return r(()=>W()?.lod===`groups`)()&&K()},get children(){return pi()}}),null),f(h,n(s,{get when(){return r(()=>G().mode===`2d`)()&&Qe()===`webgl`},get children(){return mi()}}),null),f(h,n(s,{get when(){return r(()=>G().mode===`list`)()&&Qe()===`large`},get children(){return hi()}}),null),f(h,n(s,{get when(){return r(()=>!!V())()&&B()},get children(){var e=gi(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling;return f(e,()=>V().message,t),n.$$click=()=>void U(),e}}),null);var v=gt;return typeof v==`function`?t(v,g):gt=g,f(g,n(d,{get children(){return[n(a,{get when(){return r(()=>!B())()&&V()},get children(){var e=yi();return f(e,n(s,{get when(){return V().kind!==`missing`},get fallback(){return(()=>{var e=Ti();return f(e,()=>V().message),e})()},get children(){return[(()=>{var e=_i();return e.firstChild,f(e,()=>V().message,null),e})(),(()=>{var e=vi();return e.$$click=()=>void U(),e})()]}})),e}}),n(a,{get when(){return!B()},get children(){return bi()}}),n(a,{get when(){return r(()=>G().mode===`3d`)()&&W()},children:e=>n(Un,u({get view(){return e()},get palette(){return ge()},get motion(){return he()},get focus(){return ke()},get resetSeq(){return je()},onNode:Y,onLink:dt,onBackground:()=>void 0,onFail:()=>Se(!0)},()=>q()?.type===`node`?{selected:q().id}:{},{onRenderer:e=>(Fe(e),()=>Fe(void 0))}))}),n(a,{get when(){return r(()=>G().mode===`2d`)()&&W()},children:e=>n(Bn,u({get view(){return e()},get palette(){return ge()},get motion(){return he()}},()=>q()?.type===`node`?{selected:q().id}:{},{get focus(){return ke()},get resetSeq(){return je()},onNode:Y,onLink:dt,onBackground:()=>void 0,onFail:()=>Oe(!0),onRenderer:(e,t)=>Lr(e,t,Y)}))}),n(a,{get when(){return G().mode===`list`},get children(){return n(Sr,{get nodes(){return nt().nodes},get edges(){return nt().edges},get selected(){return q()?.id},onNode:Y,onEdge:e=>J({type:`edge`,id:e}),get children(){return n(s,{get when(){return r(()=>!(!L()||R()))()&&W()},children:e=>n(pr,{get view(){return e()},mode:`list`,phone:!1,get autoFocus(){return z()===`legend`},onClose:()=>ce(!1)})})}})}})]}}),_),f(g,n(s,{get when(){return it()},get children(){var e=Ci();return e.firstChild,f(e,n(s,{get when(){return!B().nodes.some(e=>e.kind===`machine`)},get fallback(){return Ei()},get children(){return[(()=>{var e=xi();return e.$$click=()=>te(),e})(),Si()]}}),null),o(()=>e.classList.toggle(`wt-empty-drawn`,!!K())),e}}),_),f(_,n(Rn,{get chips(){return tt()},onRemove:e=>w(e.clear),onClear:()=>w(Fn)}),null),f(_,n(s,{get when(){return r(()=>!!(L()&&W()))()&&(K()||R())},get children(){return n(pr,{get view(){return W()},get mode(){return r(()=>G().mode===`2d`)()?`2d`:G().mode===`list`?`list`:`3d`},get phone(){return R()},get autoFocus(){return z()===`legend`},onClose:()=>ce(!1)})}}),null),f(_,n(s,{get when(){return r(()=>!!F())()&&B()},get children(){return n(Ln,{get url(){return x()},get phone(){return R()},get autoFocus(){return z()===`filters`},get machines(){return(W()?.machines??[]).map(e=>({value:e.id,label:e.label}))},get harnesses(){return rt().map(e=>({value:e,label:ue(e)}))},get choices(){return $e()},get teamValue(){return et().find(e=>e.id===x().team||e.name===x().team)?.id??x().team},setURL:w,go:C,onClose:()=>se(!1)})}}),null),f(_,n(gn,u({get view(){return x().view},get drawn(){return K()},get filtersOpen(){return F()},get filterCount(){return ut(x())},get legendOpen(){return L()},get teamsOpen(){return!!Z()},get paused(){return O()},get reduced(){return pe()},get panelOpen(){return F()||L()&&R()||R()&&mt()},get search(){return D()}},()=>D().trim()?{matches:W()?.matches??0}:{},{setView:E,onFilters:()=>se(!F()),onLegend:()=>ce(!L()),onTeams:()=>Z()?jr():$(),onHub:()=>J({type:`node`,id:`hub`}),onReset:()=>Me(e=>e+1),onPause:()=>k(!O()),get canRelayout(){return r(()=>G().mode===`3d`)()&&!!Pe()},onRelayout:()=>Pe()?.relayout(),onSearch:e=>w({q:e.trim()?e:void 0}),onSearchEnter:ft})),null),f(g,n(s,{get when(){return r(()=>!!(B()&&q()))()&&!Z()},get children(){return n(Zt,{get snap(){return B()},get selection(){return q()},get node(){return at()},get edge(){return ot()},get window(){return x().window},onSelect:J,onClose:()=>J(void 0),onEditTeam:e=>$(e)})}}),null),f(g,n(s,{get when(){return Z()},get children(){return n(ii,{get snap(){return Ye()},get phone(){return R()},onChanged:()=>void U()})}}),null),o(e=>{var t=G().mode,n=he()?`live`:`static`,r=tt().length?``:void 0,a=ht();return t!==e.e&&p(g,`data-mode`,e.e=t),n!==e.t&&p(g,`data-motion`,e.t=n),r!==e.a&&p(g,`data-chips`,e.a=r),a!==e.o&&i(g,`--wt-side`,e.o=a),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e})()}D([`click`]);export{Qn as a,at as c,Ni as default,Gn as i,Xn as n,Zn as o,Yn as r,it as s,ci as t};
|