@plurnk/plurnk-xr 1.0.3 → 1.0.5
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/SPEC.md +4 -4
- package/dist/assets/app.DKS42GZL.js +102 -0
- package/dist/assets/app.DKS42GZL.js.br +0 -0
- package/dist/assets/app.DKS42GZL.js.gz +0 -0
- package/dist/assets/{index.fe91a0ae.css → index.2b6e866d.css} +1 -1
- package/dist/assets/index.2b6e866d.css.br +0 -0
- package/dist/assets/index.2b6e866d.css.gz +0 -0
- package/dist/assets.json +8 -8
- package/dist/index.html +2 -2
- package/package.json +17 -16
- package/dist/assets/app.D6AFFKZZ.js +0 -102
- package/dist/assets/app.D6AFFKZZ.js.br +0 -0
- package/dist/assets/app.D6AFFKZZ.js.gz +0 -0
- package/dist/assets/index.fe91a0ae.css.br +0 -0
- package/dist/assets/index.fe91a0ae.css.gz +0 -0
package/SPEC.md
CHANGED
|
@@ -94,8 +94,8 @@ disabled, and reveals the HTTPS / `localhost` guidance via `@layer state` CSS.
|
|
|
94
94
|
|
|
95
95
|
| Aspect | Contract |
|
|
96
96
|
| :--- | :--- |
|
|
97
|
-
| Transport & auth (`xr/watch-client.js`, `xr/auth.js`) | Streams all
|
|
98
|
-
| Homomorphic level state (`xr/engine/watch-store.js`) | `notifications/snapshot` hydrates non-archived workspaces, `origin === "model"` sessions (`root`, `work`, `fork`), and open review gates (`ProposalProjection` with `disposition.decision === "review"`, `ClientInteractionProjection`) with canonical `<workspace>#<session>` addresses and concise single-line summaries (`subject.command` / `subject.title` / `request.message`). Active lifecycles (`running`, `queued`, `parked`) are always retained alongside `gates > 0`; `loop/started` materializes embedded `data.session` snapshots in place when a previously omitted session wakes, falling back to `resyncRequired` only when an unknown session delta arrives without `data.session` while `state.omitted > 0`. |
|
|
97
|
+
| Transport & auth (`xr/watch-client.js`, `xr/auth.js`) | Streams all 23 Watch Plane event types (including `workspace/deleted` and `service/hibernating`) via `on_the_money/live` `sse()` (`fetch`-SSE mode with `Last-Event-ID` replay), suspending streams and `BroadcastChannel` handles on `pagehide` and restoring on BFCache `pageshow`. Loopback and BFF cookie deployments send `{}` extra headers (`same-origin` credentials); when `localStorage["plurnk_oidc_grant"]` holds a grant matching the notifications origin, attaches `Authorization: Bearer <accessToken>`, coordinates `refresh_token` exchanges across sibling tabs (`/`, `/xr/`) via bounded `10s` Web Locks (`plurnk:oauth:refresh:<origin>`, decoupled from individual caller `AbortSignal`s) and `BroadcastChannel("plurnk_oidc_grant")` + `storage` events, and offers bounded PKCE S256 sign-in handoff (`/.well-known/oauth-protected-resource` -> `/auth/callback` with `returnTo: "/xr/"`, falling back to `/`) when `signed-out`. |
|
|
98
|
+
| Homomorphic level state (`xr/engine/watch-records.js`, `xr/engine/watch-store.js`) | `notifications/snapshot` hydrates non-archived workspaces, `origin === "model"` sessions (`root`, `work`, `fork`), and open review gates (`ProposalProjection` with `disposition.decision === "review"`, `ClientInteractionProjection`) with canonical `<workspace>#<session>` addresses and concise single-line summaries (`subject.command` / `subject.title` / `request.message`). `workspace/deleted` purges the workspace, its sessions, and any pinned gates. Active lifecycles (`running`, `queued`, `parked`) are always retained alongside `gates > 0`; `loop/started` materializes embedded `data.session` snapshots in place when a previously omitted session wakes, falling back to `resyncRequired` only when an unknown session delta arrives without `data.session` while `state.omitted > 0`. |
|
|
99
99
|
| Edge salience cues (`SalienceCue[]`) | `notifications/snapshot` emits `cues: []` so historical sessions never trigger arrival chimes or toasts on connect. Live deltas emit typed cues: `activity` (`loop/started`, `stream/concluded`), `gate-opened` (`loop/proposal` review, `loop/interaction`), `gate-settled` (`loop/gate-settled`), `replied` (`session/replied`), `terminated` (`loop/parked`, `loop/terminated`), and `notice` (`notice/event`). |
|
|
100
100
|
|
|
101
101
|
## §xr-spatial-topology OKLCH palette, cylindrical constellation, and callout queue
|
|
@@ -166,6 +166,6 @@ To remain small and dependency-clean enough for default inclusion in
|
|
|
166
166
|
`@plurnk/plurnk-service` `optionalDependencies`:
|
|
167
167
|
|
|
168
168
|
- Runtime `dependencies` contain `@plurnk/plurnk-meta` only (zero third-party runtime packages).
|
|
169
|
-
- `peerDependencies` declare `@plurnk/plurnk-contracts` and `@plurnk/plurnk-modules`.
|
|
170
|
-
- Authoring, bundling, and verification tools (`on_the_money`, `esbuild`, `linkedom`, `stylelint`, `typescript`, `eslint`, `@plurnk/plurnk-spec-check`) stay exclusively in `devDependencies
|
|
169
|
+
- `peerDependencies` declare single-major `^` ranges on `@plurnk/plurnk-contracts` and `@plurnk/plurnk-modules`.
|
|
170
|
+
- Authoring, bundling, and verification tools (`on_the_money`, `esbuild`, `linkedom`, `stylelint`, `typescript`, `eslint`, `@plurnk/plurnk-spec-check`) stay exclusively in `devDependencies` using `^x.y.z` SemVer ranges (`deps-waivers.json` + `npm run deps:check` enforce range grammar, watched-family rules, and `allowScripts` review hermetically in `test:lint`, while `npm run deps:drift` verifies manifest floors and lockfile resolutions against registry `latest`).
|
|
171
171
|
- `package.json#exports` exposes `./module` (`types` + `default`) and `./package.json`, and `package.json#files` ships `.env.defaults`, `types/module.d.ts`, `src/*.js`, `dist/`, `README.md`, `ARCHITECTURE.md`, `SPEC.md`, and `LICENSE`.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var Q=class e{static#e=new WeakMap;static on(t,o,n,r){if(typeof n!="string"||!n.trim()||typeof r!="function")throw new TypeError("on(): expected (parent, event, selector, handler)");let l=typeof t=="string"?document.querySelector(t):t||document.body;if(!l)throw new Error(`on(): parent selector matched nothing: ${t}`);let s=e.#e.get(l);s||(s=new Map,e.#e.set(l,s));let p=s.get(o);if(!p){let a=new Set,c=i=>{let f=i.target,h=f&&typeof f.closest=="function"?f:f?.parentElement||null;if(h)for(let v of[...a]){if(!a.has(v))continue;let y=h.closest(v.selector);y&&l.contains(y)&&v.fn.call(y,i,y)}};p={dispatch:c,entries:a},s.set(o,p),l.addEventListener(o,c)}let m={selector:n,fn:r};return p.entries.add(m),()=>{p.entries.delete(m),p.entries.size===0&&s.get(o)===p&&(l.removeEventListener(o,p.dispatch),s.delete(o),s.size===0&&e.#e.delete(l))}}static target(t,o,n,r={}){if(!t||typeof t.addEventListener!="function"||typeof Element<"u"&&t instanceof Element)throw new TypeError("on.target(): expected a non-Element EventTarget; use delegated on(parent, event, selector, handler) for DOM elements");if(typeof o!="string"||!o.trim()||typeof n!="function"||r===null||typeof r!="object")throw new TypeError("on.target(): expected (target, event, handler, options?)");let{signal:l,...s}=r;if(l?.aborted)return()=>{};let p=Object.keys(s).length>0,m=s.capture?{capture:!0}:void 0,a,c=s.once&&l?i=>{l.removeEventListener("abort",a),n.call(t,i)}:n;return a=()=>{t.removeEventListener(o,c,m),l?.removeEventListener("abort",a)},p?t.addEventListener(o,c,s):t.addEventListener(o,c),l?.addEventListener("abort",a,{once:!0}),a}static emit(t,o,n){let r=typeof t=="string"?document.querySelector(t):t,l=new CustomEvent(o,{bubbles:!0,cancelable:!0,detail:n});r.dispatchEvent(l)}};var fe=class{static validate(t){let o=n=>n!==null&&typeof n=="object"&&!Array.isArray(n);if(!o(t))throw new TypeError("i18n dictionary must be an object");for(let[n,r]of Object.entries(t))if(typeof r!="string"&&!(o(r)&&Object.hasOwn(r,"other")&&Object.keys(r).every(l=>["zero","one","two","few","many","other"].includes(l))&&Object.values(r).every(l=>typeof l=="string")))throw new TypeError(`i18n dictionary entry ${JSON.stringify(n)} must be a string or plural-form object of strings with an other form`);return t}};var dt=(e,t,o)=>{let n=t.endsWith("[]"),r=t.split(/[[\]]/).filter(Boolean),l=r.find(p=>["__proto__","prototype","constructor"].includes(p));if(l)throw new TypeError(`the.form: unsafe field name ${JSON.stringify(t)} contains forbidden path segment ${JSON.stringify(l)}`);let s=e;for(let p=0;p<r.length;p++){let m=r[p];p===r.length-1?n?(s[m]||=[],s[m].push(o)):s[m]!==void 0?(Array.isArray(s[m])||(s[m]=[s[m]]),s[m].push(o)):s[m]=o:(s[m]=s[m]||{},s=s[m])}};function ft(e,t="-"){if(e===null||typeof e!="object")throw new TypeError("the.flat: input must be an object");let o={},n=(r,l)=>{if(r===null||typeof r!="object"){o[l]=r;return}for(let[s,p]of Object.entries(r))n(p,l?`${l}${t}${s}`:s)};return n(e,""),o}function pt(e){let t={},o=e.querySelectorAll("input, select, textarea");for(let n of o){let r=n.name;if(!r||n.disabled)continue;let l=(n.type||"text").toLowerCase();if(l==="submit"||l==="button"||l==="reset"||l==="file"||(l==="checkbox"||l==="radio")&&!(n.checked??n.hasAttribute("checked")))continue;if(n.tagName==="SELECT"&&n.hasAttribute("multiple")){let p="selectedOptions"in n?n.selectedOptions:n.querySelectorAll("option[selected]");for(let m of p)dt(t,r,m.value);continue}let s=n.value??n.getAttribute("value")??"";dt(t,r,s)}return t}var oe=class e{static compatible(t,o){let n=new Intl.Locale(t).maximize(),r=new Intl.Locale(o).maximize();return n.language===r.language&&n.script===r.script}static chain(t){let o=new Intl.Locale(t).baseName,n=[],r=o;for(;r;){e.compatible(o,r)&&n.push(r);let l=r.lastIndexOf("-");r=l<0?"":r.slice(0,l)}return n}};var Te=null;function mt(e,t){let o=t??(typeof window<"u"&&window.location?window.location.pathname:""),n=[],l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,(m,a)=>(n.push(a),"([^/]+)")),s=o.match(new RegExp(`^${l}$`));if(!s)return null;let p={};return n.forEach((m,a)=>{p[m]=decodeURIComponent(s[a+1])}),p}function ht(e,{match:t,initial:o=!0}={}){if(typeof window>"u")return;if(Te)throw new Error("route(): a router is already active \u2014 call its unsubscribe first");let n=window.location.href,r=()=>{n=window.location.href,e(window.location.pathname,window.location.search,window.location.hash)},l=()=>{window.location.href!==n&&r()};Te=r;let s=p=>{if(p.metaKey||p.ctrlKey||p.shiftKey||p.altKey||p.button>0)return;let m=p.target.closest("a");if(!m?.getAttribute("href")||m.hasAttribute("data-external")||m.hasAttribute("download")||m.target==="_blank"||t&&!m.matches(t))return;let a=new URL(m.getAttribute("href"),window.location.href);a.origin===window.location.origin&&(a.pathname===window.location.pathname&&a.search===window.location.search&&a.hash||(p.preventDefault(),a.href!==window.location.href&&(window.history.pushState({},"",a.href),r())))};return window.addEventListener("popstate",r),window.addEventListener("hashchange",l),document.addEventListener("click",s),o&&r(),()=>{window.removeEventListener("popstate",r),window.removeEventListener("hashchange",l),document.removeEventListener("click",s),Te=null}}function gt(e,{replace:t=!1}={}){if(typeof window>"u")return;if(!Te)throw new Error("route.go(): no active router \u2014 call route() first");let o=new URL(e,window.location.href);o.href!==window.location.href&&(t?window.history.replaceState({},"",o.href):window.history.pushState({},"",o.href),Te())}var V=class e{static#e=[{dictionary:{},locale:null}];static#t=new WeakMap;static locale=typeof navigator<"u"?navigator.language:"en";static prefix="otm:";static persistKeys=new Set;static get dictionary(){return e.#e[0].dictionary}static set dictionary(t){e.#e=[{dictionary:fe.validate(t),locale:null}]}static#c=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;static#r(t){if(typeof t!="string"||!e.#c.test(t))throw new TypeError(`the(${JSON.stringify(t)}): state keys must be canonical kebab-case (e.g. "model-offline")`);return t}static the(...t){if(t.length===0)throw new TypeError("the(): missing args");return t[0]instanceof Element?e.#l(t[0],t.slice(1)):e.#l(document.body,t)}static#l(t,o){let[n,r]=o,l=t===document.body;if(o.length===1&&typeof n=="string")return e.#p(t,e.#r(n));if(o.length===2&&typeof n=="string"){if(typeof r>"u")throw new TypeError(`the(${JSON.stringify(n)}, undefined): val is required for set`);return e.#u(t,l,n,r),t}if(o.length===1&&n?.constructor===Object){for(let[s,p]of Object.entries(n))e.#u(t,l,s,p);return t}throw new TypeError(`the(): unrecognized call shape (${o.map(s=>typeof s).join(", ")})`)}static match=mt;static flat=ft;static form=pt;static route=ht;static go=gt;static _t(t,o={}){return(typeof Node<"u"?t instanceof Node:t?.nodeType)?(e.#n(t),t):t?e.#i(t,o)?.text??t:(e.#n(document.documentElement),"")}static#n(t,o=!1){let n=t.querySelectorAll?[t,...t.querySelectorAll("[data-i18n]")]:[t];for(let r of n)if(r.hasAttribute?.("data-i18n")){let l=r.getAttribute("data-i18n"),s={};for(let c of r.attributes)if(c.name.startsWith("data-i18n-")&&c.name!=="data-i18n-type"){let i=c.name.replace("data-i18n-","");s[i]=c.value}let p=r.getAttribute("data-i18n-type"),m=o?null:e.#i(l,{...s,type:p}),a=e.#t.get(r);m!==null?(a||e.#t.set(r,{text:r.textContent,lang:r.getAttribute("lang")}),e.#a(r,m.text),e.#d(r,"lang",m.locale)):a&&(e.#a(r,a.text),e.#d(r,"lang",a.lang))}}static#o(t){if(!t.currency)throw new TypeError('_t: type "currency" requires an explicit currency (options.currency or data-i18n-currency)');return t.currency}static#i(t,o){let n=e.#e.find(({dictionary:m})=>Object.hasOwn(m,t)),r=n?.dictionary[t],l=n?.locale??e.locale,s=oe.compatible(e.locale,l)?e.locale:l;if(r===void 0){if(o.val!==void 0&&(o.type==="currency"||o.type==="date")){let m=o.type==="currency"?new Intl.NumberFormat(e.locale,{style:"currency",currency:e.#o(o)}):new Intl.DateTimeFormat(e.locale);return{text:o.type==="date"?m.format(new Date(o.val)):m.format(Number(o.val)),locale:e.locale}}return null}if(typeof r=="object"){let m=o.qty!==void 0?Number(o.qty):0,a=new Intl.PluralRules(l).select(m);r=r[a]??r.other??t}if(typeof r!="string")throw new TypeError(`Invalid i18n dictionary entry ${JSON.stringify(t)}`);let p=r;for(let[m,a]of Object.entries(o)){let c=a;if(m==="val"&&o.type){let i=Number(a),f=o.type==="currency"?new Intl.NumberFormat(s,{style:"currency",currency:e.#o(o)}):o.type==="date"?new Intl.DateTimeFormat(s):new Intl.NumberFormat(s);c=o.type==="date"?f.format(new Date(a)):f.format(i)}p=p.replaceAll(`{${m}}`,()=>c)}return{text:p,locale:l}}static#f={expanded:"aria-expanded",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled"};static#s(t,o){return t===document.body?`data-${o}`:e.#f[o]||`data-${o}`}static#u(t,o,n,r){let l=e.#r(n);if(r===null){e.#w(t,l),o&&e.persistKeys.has(l)&&localStorage.removeItem(`${e.prefix}${l}`);return}let s=e.#m(l,r);e.#h(t,l,s),o&&e.persistKeys.has(l)&&localStorage.setItem(`${e.prefix}${l}`,s)}static#m(t,o){if(typeof o=="string")return o;if(typeof o=="boolean")return o?"true":"false";if(typeof o=="number"&&Number.isFinite(o))return String(o);throw new TypeError(`the(${JSON.stringify(t)}, ...): state value must be a string, finite number, boolean, or null`)}static#p(t,o){return t.getAttribute(e.#s(t,o))}static#a(t,o){t.textContent!==o&&(t.textContent=o)}static#d(t,o,n){t.getAttribute(o)!==n&&(n===null?t.removeAttribute(o):t.setAttribute(o,n))}static#h(t,o,n){e.#d(t,e.#s(t,o),n),e.#g(t,o,n,!1)}static#w(t,o){e.#d(t,e.#s(t,o),null),e.#g(t,o,"",!0)}static#g(t,o,n,r){let l=t===document.body,s=l&&typeof document<"u"?document.documentElement||document:t;if(s.querySelectorAll)for(let p of s.querySelectorAll(`[data-text="${o}"],[data-bind*="${o}"]`)){if(!l){let m=p.closest?.("[data-otm-scope]");if(m&&m!==t&&t.contains(m))continue}p.getAttribute("data-text")===o&&e.#a(p,n),e.#y(p,o,n,r)}t.getAttribute?.("data-text")===o&&e.#a(t,n),e.#y(t,o,n,r)}static#y(t,o,n,r){let l=t.getAttribute?.("data-bind");if(l)for(let s of l.split(/\s+/)){let p=s.indexOf(":");if(p<1||s.slice(p+1)!==o)continue;let m=s.slice(0,p);e.#d(t,m,r?null:n)}}static async boot({signal:t,locales:o,dictionary:n,namespace:r,locale:l,defaultLocale:s,persistKeys:p}={}){r&&(e.prefix=`${r}:`),p&&(e.persistKeys=new Set(p.map(w=>e.#r(w))));let m=typeof window<"u"&&window.location?window.location.search:"",a=new URLSearchParams(m),c=document.documentElement.lang||(typeof navigator<"u"?navigator.language:null)||"en",i=new Intl.Locale(l||a.get("lang")||e.persistKeys.has("lang")&&localStorage.getItem(`${e.prefix}lang`)||c).toString(),f=s||document.documentElement.lang,h=f?new Intl.Locale(f).baseName:null;s&&e.#d(document.documentElement,"lang",new Intl.Locale(s).toString());let v=[];if(n!==void 0)v.push({dictionary:fe.validate(n),locale:i});else{let w=document.querySelector('meta[name="i18n"]'),g=o||w?.getAttribute("content");if(g){let A=w?.getAttribute("data-fallback")||h||"en",x=new Map((w?.getAttribute("data-available")||"").split(",").map(u=>u.trim()).filter(Boolean).map(u=>[new Intl.Locale(u).baseName,u])),E=oe.chain(i);h&&oe.compatible(i,h)&&E.push(h);let S=new Set([...E,...oe.chain(A),...h?[h]:[]]);for(let u of S){if(u===h&&!x.has(u))break;let b=x.get(u)??(x.size===0&&u===new Intl.Locale(A).baseName?A:null);if(b){try{let I=await fetch(`${g}/${b}.json`,{signal:t});if(!I.ok)throw new Error(`HTTP ${I.status} for ${b}.json`);v.push({dictionary:fe.validate(await I.json()),locale:u})}catch(I){if(t?.aborted)throw I;console.warn(`otm: i18n fetch failed for "${u}"`,I)}if(u===h)break}}}}let y=v[0]?.locale??h??i;e.locale=oe.compatible(i,y)?i:y,e.#e=v.length?v:[{dictionary:{},locale:null}];for(let w of e.persistKeys){if(w==="lang")continue;let g=localStorage.getItem(`${e.prefix}${w}`);g!==null&&e.#h(document.body,w,g)}e.#n(document.documentElement,h!==null&&v.length===0)}};var rn=/^data-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,se=class e{static $(t,o){let n=t,r=o;return typeof n=="string"&&(r=n,n=document),n.querySelector(r)}static $$(t,o){let n=t,r=o;return typeof n=="string"&&(r=n,n=document),Array.from(n.querySelectorAll(r))}static clone(t,o,{position:n="beforeend"}={}){let r=typeof t=="string"?document.querySelector(t):t,l=document.querySelector(o);if(!r)throw new Error(`Parent not found: ${t}`);if(!l)throw new Error(`Template not found: ${o}`);let s=l.content.cloneNode(!0).firstElementChild;V._t(s),r.insertAdjacentElement(n,s);let p=new CustomEvent("mounted",{bubbles:!0,detail:{parent:r}});return s.dispatchEvent(p),s}static cloneEach(t,o,n,r){let l=typeof t=="string"?document.querySelector(t):t;if(!l)throw new Error(`Parent not found: ${t}`);l.replaceChildren();let s=[],p=0;for(let m of n){let a=e.clone(l,o);r?.(a,m,p++),s.push(a)}return s}static reconcile(t,o,n,{key:r,fill:l,attr:s="data-otm-key"}={}){let p=typeof t=="string"?document.querySelector(t):t;if(!p)throw new Error(`Parent not found: ${t}`);if(typeof r!="function")throw new TypeError("$.reconcile(): options.key must be a function");if(typeof s!="string"||!rn.test(s))throw new TypeError(`$.reconcile(): options.attr must be a canonical data-* attribute, got ${JSON.stringify(s)}`);let m=[],a=new Set,c=0;for(let A of n){let x=r(A,c);if(x==null||String(x)==="")throw new TypeError("$.reconcile(): key() must return a non-empty key");let E=String(x);if(a.has(E))throw new RangeError(`$.reconcile(): duplicate key ${JSON.stringify(E)}`);a.add(E),m.push({key:E,item:A,index:c++})}let i=new Map;for(let A of Array.from(p.children)){let x=A.getAttribute(s);x!==null&&!i.has(x)&&i.set(x,A)}let f=[],h=new Set;for(let A of m){let x=i.get(A.key);x||(x=e.clone(p,o),x.setAttribute(s,A.key)),h.add(x),f.push({...A,el:x})}let v=typeof document<"u"?document.activeElement:null,y=v&&p.contains(v)&&typeof v.focus=="function"?v:null;for(let A of Array.from(p.children))h.has(A)||A.remove();let w=typeof p.moveBefore=="function"?(A,x)=>p.moveBefore(A,x):(A,x)=>p.insertBefore(A,x);for(let A=0;A<f.length;A++){let{el:x}=f[A],E=p.children[A]??null;E!==x&&w(x,E)}y&&p.contains(y)&&document.activeElement!==y&&y.focus({preventScroll:!0});let g=[];for(let{el:A,item:x,index:E}of f)l?.(A,x,E),g.push(A);return g}};var Z=Q.on;Z.emit=Q.emit;Z.target=Q.target;var U=V.the,an=V._t,yt=V.route;yt.go=V.go;U.t=an;U.route=yt;U.form=V.form;U.flat=V.flat;U.match=V.match;U.boot=V.boot;Object.defineProperty(U,"dictionary",{get:()=>V.dictionary,set:e=>{V.dictionary=e}});Object.defineProperty(U,"locale",{get:()=>V.locale,set:e=>{V.locale=e}});var ae=se.$;ae.clone=se.clone;ae.cloneEach=se.cloneEach;ae.reconcile=se.reconcile;var Io=se.$$;var pe="plurnk_oidc_grant",vt="plurnk_oidc_pkce",cn="plurnk:oauth:refresh:",kt=1e4,It=1e3,ln="plurnk-web",un=Object.freeze(["openid","profile","email"]),Oe=new Set,Ge=new Map,ce=null,wt=!1,bt=!1,te=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function xt(e){let t=new AbortController,o=setTimeout(()=>{t.abort(new DOMException(`OIDC request timed out after ${e}ms`,"TimeoutError"))},e);return te(o)&&"unref"in o&&typeof o.unref=="function"&&o.unref(),{signal:t.signal,cleanup(){clearTimeout(o)}}}function _e(e,t,o){if(!t)return e;if(t.aborted){let n=t.reason??new DOMException("The operation was aborted.","AbortError");return o?.(n),Promise.reject(n)}return new Promise((n,r)=>{let l=Z.target(t,"abort",()=>{let s=t.reason??new DOMException("The operation was aborted.","AbortError");o?.(s),r(s)},{once:!0});e.then(s=>{l(),n(s)},s=>{l(),r(s)})})}async function We(e,t,o,n){let r=await _e(o(e,{...t,signal:n}),n);if(!r.ok)return r.body?.cancel().catch(()=>{}),{ok:!1,status:r.status,body:null};let l=await _e(r.json(),n,s=>{r.body?.cancel(s).catch(()=>{})});return{ok:!0,status:r.status,body:l}}function be(e){try{return typeof window<"u"?window[e]??null:null}catch{return null}}function At(){if(ce!==null){try{ce.close()}catch{}ce=null}}function dn(){bt||typeof window>"u"||typeof window.addEventListener!="function"||(bt=!0,Z.target(window,"pagehide",()=>{At()}),Z.target(window,"pageshow",e=>{e.persisted&&Oe.size>0&&Ve()}))}function Ve(){if(ce!==null)return ce;if(typeof window>"u"||typeof BroadcastChannel!="function")return null;dn();try{let e=new BroadcastChannel(pe);"unref"in e&&typeof e.unref=="function"&&e.unref(),Z.target(e,"message",()=>{Pe(!1)}),ce=e}catch{ce=null}return ce}function fn(){wt||typeof window>"u"||typeof window.addEventListener!="function"||(wt=!0,Z.target(window,"storage",e=>{let t=e.key;(t==null||t===pe)&&Pe(!1)}))}function Pe(e){if(e){let t=Ve();try{t?.postMessage("grant-changed")}catch{}}for(let t of Oe)t()}function pn(){try{let e=typeof navigator<"u"?navigator.locks:void 0;return te(e)&&typeof e.request=="function"?e:null}catch{return null}}function mn(e){return typeof globalThis.LockManager=="function"&&e instanceof globalThis.LockManager||e.request.length>=3}function hn(e){let t=typeof e.access_token=="string"&&e.access_token.trim()!==""?e.access_token.trim():null,o=typeof e.id_token=="string"&&e.id_token.trim()!==""?e.id_token.trim():null;return t!==null&&(t.split(".").length===3||o===null)?t:o}function gn(e){let t=e.split(".");if(t.length!==3||t[1]==="")return null;try{let o=t[1].replaceAll("-","+").replaceAll("_","/"),n=o+"=".repeat((4-o.length%4)%4),r=atob(n),l=new Uint8Array(r.length);for(let p=0;p<r.length;p+=1)l[p]=r.charCodeAt(p);let s=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l));return!te(s)||typeof s.exp!="number"||!Number.isFinite(s.exp)||s.exp<=0?null:Math.floor(s.exp*1e3)}catch{return null}}function yn(e,t){let o=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN;if(Number.isFinite(o)&&o>0)return Date.now()+Math.floor(o*1e3);let n=gn(t);return n!==null?n:void 0}function Ke(e){let t=be("localStorage")?.getItem(pe)??null;if(t===null)return null;try{let o=JSON.parse(t);return!te(o)||typeof o.acpOrigin!="string"||typeof o.accessToken!="string"||o.acpOrigin!==e||o.accessToken.trim()===""?null:{acpOrigin:o.acpOrigin,accessToken:o.accessToken,...typeof o.issuer=="string"?{issuer:o.issuer}:{},...typeof o.clientId=="string"?{clientId:o.clientId}:{},...typeof o.tokenEndpoint=="string"?{tokenEndpoint:o.tokenEndpoint}:{},...typeof o.refreshToken=="string"?{refreshToken:o.refreshToken}:{},...typeof o.expiresAt=="number"&&Number.isFinite(o.expiresAt)?{expiresAt:o.expiresAt}:{}}}catch{return null}}function St(){let e=be("localStorage"),t=e?.getItem(pe)!==null;try{e?.removeItem(pe),be("sessionStorage")?.removeItem(vt)}catch{}t&&Pe(!0)}function wn(e){try{be("localStorage")?.setItem(pe,JSON.stringify(e))}catch{}Pe(!0)}function Et(e,t,o={}){if(t?.aborted)return Promise.reject(t.reason);if(!e.refreshToken||!e.tokenEndpoint||!e.clientId)return Promise.resolve(null);let{fetchImpl:n=globalThis.fetch,timeoutMs:r=kt}=o,l=e.refreshToken,s=e.accessToken,p=e.acpOrigin,m=`${p}:${l}`,a=Ge.get(m);if(!a){let c=xt(r),i=async()=>{if(c.signal.aborted)return null;let y=Ke(p);if(y!==null){let g=y.accessToken!==s||y.refreshToken!==l,A=y.expiresAt===void 0||Date.now()+It<y.expiresAt;if(g&&A)return y}if(y===null&&(be("localStorage")?.getItem(pe)??null)===null)return null;let w=y??e;if(!w.refreshToken||!w.tokenEndpoint||!w.clientId)return null;try{let g=new URLSearchParams({grant_type:"refresh_token",refresh_token:w.refreshToken,client_id:w.clientId}),A=await We(w.tokenEndpoint,{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:g,cache:"no-store"},n,c.signal);if(!A.ok)return(A.status===400||A.status===401)&&St(),null;let x=A.body;if(!te(x))return null;let E=hn(x);if(E===null)return null;let S=yn(x.expires_in,E),u=typeof x.refresh_token=="string"&&x.refresh_token.trim()!==""?x.refresh_token.trim():w.refreshToken,b={...w,accessToken:E,...u?{refreshToken:u}:{},...S!==void 0?{expiresAt:S}:{}};return wn(b),b}catch{return null}},f=pn(),h=`${cn}${p}`;a=(f===null?i():mn(f)?_e(f.request(h,{signal:c.signal},i),c.signal):_e(f.request(h,i),c.signal)).catch(()=>null).finally(()=>{c.cleanup(),Ge.delete(m)}),Ge.set(m,a)}return _e(a,t)}function Xe(e){let t=typeof window<"u"?window.location.origin:"http://127.0.0.1:1066";return new URL(e,t).origin}async function Rt(e,t,o){t?.throwIfAborted();let n=Xe(e),r=Ke(n);if(!r)return{};if(!(typeof r.expiresAt=="number"&&Date.now()+It>=r.expiresAt))return{Authorization:`Bearer ${r.accessToken}`};if(!r.refreshToken)return St(),{};let s=await Et(r,t,o);return t?.throwIfAborted(),s?{Authorization:`Bearer ${s.accessToken}`}:{}}async function Mt(e,t){let o=Xe(e),n=Ke(o);return n?await Et(n,void 0,t).catch(()=>null)!==null:!1}function He(e){let t="";for(let o of e)t+=String.fromCharCode(o);return btoa(t).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function Ue(e){try{let t=new URL(e);return t.username!==""||t.password!==""?!1:t.protocol==="https:"?!0:t.protocol==="http:"&&(t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="::1"||t.hostname==="[::1]")}catch{return!1}}async function Tt(e,t={}){let{returnTo:o="/xr/",fetchImpl:n=globalThis.fetch,timeoutMs:r=kt,navigate:l=a=>{typeof window<"u"&&window.location.assign(a)}}=t,s=Xe(e),p=typeof window<"u"?window.location.origin:s,m=xt(r);try{let a=await We(`${s}/.well-known/oauth-protected-resource`,{headers:{accept:"application/json"},cache:"no-store"},n,m.signal);if(a.ok){let c=a.body,f=(te(c)&&Array.isArray(c.authorization_servers)?c.authorization_servers.filter(h=>typeof h=="string"&&Ue(h)):[])[0];if(typeof f=="string"){let h=new URL(f),v=h.pathname.replace(/\/+$/u,""),y=v===""?[`${h.origin}/.well-known/oauth-authorization-server`,`${h.origin}/.well-known/openid-configuration`]:[`${h.origin}/.well-known/oauth-authorization-server${v}`,`${h.origin}${v}/.well-known/openid-configuration`];for(let w of y){let g=await We(w,{headers:{accept:"application/json"},cache:"no-store"},n,m.signal);if(!g.ok)continue;let A=g.body;if(!te(A)||typeof A.issuer!="string"||A.issuer.replace(/\/+$/u,"")!==f.replace(/\/+$/u,"")||typeof A.authorization_endpoint!="string"||typeof A.token_endpoint!="string"||!Ue(A.authorization_endpoint)||!Ue(A.token_endpoint))continue;let x=new Uint8Array(32);globalThis.crypto.getRandomValues(x);let E=He(x),S=new Uint8Array(24);globalThis.crypto.getRandomValues(S);let u=He(S),b=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(E)),I=He(new Uint8Array(b)),O=te(c)&&typeof c.client_id=="string"&&c.client_id!==""?c.client_id:ln,k=te(c)&&typeof c.redirect_uri=="string"&&c.redirect_uri!==""?c.redirect_uri:new URL("/auth/callback",p).href,d=te(c)&&Array.isArray(c.scopes_supported)&&c.scopes_supported.length>0?c.scopes_supported.filter(M=>typeof M=="string"&&M!==""):un;be("sessionStorage")?.setItem(vt,JSON.stringify({state:u,verifier:E,returnTo:o,acpOrigin:s,issuer:f,clientId:O,tokenEndpoint:A.token_endpoint,redirectUri:k,createdAt:Date.now()}));let R=new URL(A.authorization_endpoint);return R.searchParams.set("response_type","code"),R.searchParams.set("client_id",O),R.searchParams.set("redirect_uri",k),R.searchParams.set("code_challenge",I),R.searchParams.set("code_challenge_method","S256"),R.searchParams.set("state",u),R.searchParams.set("scope",d.join(" ")),l(R.href),R.href}}}}catch{}finally{m.cleanup()}return l("/"),"/"}function Ot(e){return fn(),Ve(),Oe.add(e),()=>{Oe.delete(e),Oe.size===0&&At()}}var bn=Math.PI/180,vn=e=>e<=0?0:e>=1?1:e;function Ye(e){let t=vn(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function kn(e,t,o){let n=o*bn,r=t*Math.cos(n),l=t*Math.sin(n),s=e+.3963377774*r+.2158037573*l,p=e-.1055613458*r-.0638541728*l,m=e-.0894841775*r-1.291485548*l,a=s**3,c=p**3,i=m**3,f=4.0767416621*a-3.3077115913*c+.2309699292*i,h=-1.2684380046*a+2.6097574011*c-.3413193965*i,v=-.0041960863*a-.7034186147*c+1.707614701*i;return Object.freeze([Math.round(Ye(f)*1e4)/1e4,Math.round(Ye(h)*1e4)/1e4,Math.round(Ye(v)*1e4)/1e4])}function ne(e,t,o,n,r){return Object.freeze({slot:e,name:t,hueDeg:r,lightness:o,chroma:n,css:`oklch(${o} ${n} ${r})`,rgb:kn(o,n,r)})}var le=.74,ue=.155,_t=Object.freeze([ne(0,"teal",le,ue,185),ne(1,"azure",le,ue,245),ne(2,"emerald",le,ue,150),ne(3,"violet",le,ue,295),ne(4,"cyan",le,ue,212),ne(5,"magenta",le,ue,332),ne(6,"mint",le,ue,168),ne(7,"indigo",le,ue,268)]),re=Object.freeze({gate:ne(-1,"amber",.79,.165,75),failed:ne(-2,"crimson",.65,.2,25)});function Fe(e){let t=Number.isFinite(e)&&e>=1?Math.trunc(e)-1:Math.abs(Math.trunc(e||0));return _t[t%_t.length]}var Je=Object.freeze(["notifications/snapshot","notifications/resync","service/hibernating","workspace/created","workspace/renamed","workspace/archived","workspace/deleted","config/changed","functionality/changed","session/created","session/archived","session/deleted","session/titled","session/policy","session/replied","loop/started","loop/parked","loop/proposal","loop/interaction","loop/gate-settled","loop/terminated","stream/concluded","notice/event"]),In=96,$=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$e=e=>e==="root"||e==="work"||e==="fork"?e:null,Ze=e=>e==="model"||e==="_plurnk"?e:null,P=(e,t)=>`${e}:${t}`,ve=(e,t,o)=>`${e}:${t}:${o}`,J=(e,t)=>`${e}#${t}`,me=e=>e==="running"||e==="queued"||e==="parked";function zt(e){return e===100?"queued":e===102?"running":e===202?"parked":e===499?"cancelled":e>=400?"failed":"completed"}function ee(e,t=In){let o=e.replaceAll(/\s+/gu," ").trim(),n=[...o];return n.length<=t?o:`${n.slice(0,Math.max(1,t-1)).join("")}\u2026`}function Qe(e){let t=typeof e.op=="string"&&e.op.trim()!==""?e.op.trim():"proposal";if($(e.subject)){if(e.subject.type==="command"&&typeof e.subject.command=="string"){let o=ee(e.subject.command);if(o!=="")return`${t}: ${o}`}if(e.subject.type==="tool_call"&&typeof e.subject.title=="string"){let o=ee(e.subject.title);if(o!=="")return o}}if($(e.target)){let o=typeof e.target.scheme=="string"?e.target.scheme:"",n=typeof e.target.authority=="string"?e.target.authority:"",r=typeof e.target.pathname=="string"?e.target.pathname:"",l=ee(`${o?`${o}://`:""}${n}${r}`);if(l!=="")return`${t} ${l}`}return t}function et(e){if($(e.request)){let t=typeof e.request.toolName=="string"?e.request.toolName.trim():"",o=typeof e.request.message=="string"?ee(e.request.message):"";if(t&&o)return`${t}: ${o}`;if(o)return o;if(t)return t}return"awaiting input"}function De(e){if(!$(e)||typeof e.id!="number")return null;let t=e.completion===200||e.completion===499?e.completion:void 0,o=typeof e.excerpt=="string"?ee(e.excerpt,140):"",n=o!==""&&e.continued===!0&&!o.endsWith("\u2026")?`${o}\u2026`:o;return{id:e.id,...typeof e.coordinate=="string"?{coordinate:e.coordinate}:{},...t!==void 0?{completion:t}:{},...typeof e.at=="number"?{at:e.at}:{},...n!==""?{excerpt:n}:{},...typeof e.continued=="boolean"?{continued:e.continued}:{}}}function he(e,t,o){let n=0;for(let r of o.values())r.workspaceId===e&&r.sessionId===t&&(n+=1);return n}function ze(e,t,o){let n=!1,r=new Map(o);for(let[l,s]of o)s.workspaceId===e&&t.has(s.sessionId)&&(r.delete(l),n=!0);return{nextGates:r,removedAny:n}}function Le(){return{epoch:null,lastEventId:0,hydrated:!1,omitted:0,nextWorkspaceOrder:0,workspaces:new Map,sessions:new Map,gates:new Map}}function Lt(e,t=null){let o=new Map,n=0,r=Array.isArray(e.workspaces)?e.workspaces:[];for(let i of r){if(!$(i)||typeof i.id!="number"||typeof i.name!="string")continue;let f=typeof i.projectRoot=="string"?i.projectRoot:null,h=typeof i.projectLabel=="string"?i.projectLabel:f;o.set(i.id,{id:i.id,name:i.name,projectRoot:f,projectLabel:h,archived:!1,order:n++})}let l=new Map,s=Array.isArray(e.sessions)?e.sessions:[];for(let i of s)$(i)&&typeof i.id=="number"&&typeof i.workspaceId=="number"&&typeof i.name=="string"&&l.set(i.id,{workspaceId:i.workspaceId,name:i.name});let p=new Map,m=Array.isArray(e.proposals)?e.proposals:[];for(let i of m){if(!$(i)||typeof i.logEntryId!="number"||typeof i.sessionId!="number"||$(i.disposition)&&i.disposition.decision!=="review")continue;let f=l.get(i.sessionId),h=f?.workspaceId??t;if(h===null)continue;let v=o.get(h)?.name??String(h),y=typeof i.session=="string"&&i.session!==""?i.session:f?.name??`session-${i.sessionId}`,w=ve("proposal",h,i.logEntryId);p.set(w,{key:w,kind:"proposal",workspaceId:h,sessionId:i.sessionId,itemId:i.logEntryId,address:J(v,y),summary:Qe(i),...typeof i.op=="string"?{op:i.op}:{},...typeof i.expiresAt=="string"?{expiresAt:i.expiresAt}:{}})}let a=Array.isArray(e.interactions)?e.interactions:[];for(let i of a){if(!$(i)||typeof i.interactionId!="number"||typeof i.sessionId!="number")continue;let f=l.get(i.sessionId),h=f?.workspaceId??t;if(h===null)continue;let v=o.get(h)?.name??String(h),y=f?.name??`session-${i.sessionId}`,w=ve("interaction",h,i.interactionId);p.set(w,{key:w,kind:"interaction",workspaceId:h,sessionId:i.sessionId,itemId:i.interactionId,address:J(v,y),summary:et(i)})}let c=new Map;for(let i of s){if(!$(i)||typeof i.id!="number"||typeof i.workspaceId!="number"||typeof i.name!="string")continue;let f=o.get(i.workspaceId),h=typeof i.workspaceName=="string"?i.workspaceName:f?.name??String(i.workspaceId),v=f?.projectRoot??(typeof i.projectRoot=="string"?i.projectRoot:null),y=f?.projectLabel??(typeof i.projectLabel=="string"?i.projectLabel:v),w=typeof i.parentSessionId=="number"?i.parentSessionId:null,g=w===null?null:typeof i.parentName=="string"?i.parentName:"_plurnk",A=w===null?null:Ze(i.parentOrigin)??"_plurnk",x=he(i.workspaceId,i.id,p),E=typeof i.gates=="number"?i.gates:0,S=typeof i.title=="string"&&i.title.trim()!==""?i.title.trim():void 0,u=typeof i.opening=="string"&&i.opening.trim()!==""?ee(i.opening,140):void 0,b=typeof i.persona=="string"?i.persona:void 0;c.set(P(i.workspaceId,i.id),{workspaceId:i.workspaceId,workspaceName:h,projectRoot:v,projectLabel:y,id:i.id,name:i.name,parentSessionId:w,parentName:g,parentOrigin:A,kind:$e(i.kind)??(w===null?"root":"work"),lifecycle:typeof i.lifecycle=="string"?i.lifecycle:"idle",gates:Math.max(E,x),archived:!1,...u!==void 0?{opening:u}:{},...S!==void 0?{title:S}:{},...b!==void 0?{persona:b}:{},reply:De(i.reply)})}return{epoch:typeof e.epoch=="string"?e.epoch:null,lastEventId:typeof e.latestId=="number"?e.latestId:0,hydrated:!0,omitted:typeof e.omitted=="number"?e.omitted:0,nextWorkspaceOrder:n,workspaces:o,sessions:c,gates:p}}function Nt(e,t){if(!$(t)||typeof t.event!="string"||!$(t.data))return{state:e,changed:!1,resyncRequired:!1,cues:[]};let{event:o,data:n}=t,r=typeof t.id=="number"?t.id:e.lastEventId,l=typeof t.timestamp=="number"?t.timestamp:0,s=typeof t.workspaceId=="number"?t.workspaceId:null;if(o==="notifications/snapshot")return{state:Lt(n,s),changed:!0,resyncRequired:!1,cues:[]};if(o==="notifications/resync")return{state:{...e,epoch:typeof n.epoch=="string"?n.epoch:e.epoch,lastEventId:typeof n.latestId=="number"?n.latestId:r},changed:!1,resyncRequired:!0,cues:[]};let p=Math.max(e.lastEventId,r),m=(a=!1)=>({state:{...e,lastEventId:p},changed:!1,resyncRequired:a,cues:[]});switch(o){case"workspace/created":{let a=typeof n.id=="number"?n.id:s,c=typeof n.name=="string"?n.name:null;if(a===null||c===null)return m();let i=e.workspaces.get(a),f=typeof n.projectRoot=="string"?n.projectRoot:null,h=typeof n.projectLabel=="string"?n.projectLabel:f,v=new Map(e.workspaces);return v.set(a,{id:a,name:c,projectRoot:f,projectLabel:h,archived:!1,order:i?.order??e.nextWorkspaceOrder}),{state:{...e,lastEventId:p,nextWorkspaceOrder:i?e.nextWorkspaceOrder:e.nextWorkspaceOrder+1,workspaces:v},changed:!0,resyncRequired:!1,cues:[]}}case"workspace/renamed":{let a=typeof n.id=="number"?n.id:s,c=typeof n.name=="string"?n.name:null;if(a===null||c===null)return m();let i=e.workspaces.get(a),f=new Map(e.workspaces);f.set(a,{id:a,name:c,projectRoot:i?.projectRoot??null,projectLabel:i?.projectLabel??null,archived:i?.archived??!1,order:i?.order??e.nextWorkspaceOrder});let h=new Map(e.sessions),v=new Map;for(let[w,g]of h)g.workspaceId===a&&(v.set(g.id,g.name),g.workspaceName!==c&&h.set(w,{...g,workspaceName:c}));let y=new Map(e.gates);for(let[w,g]of y)if(g.workspaceId===a){let A=v.get(g.sessionId)??g.address.slice(g.address.indexOf("#")+1);y.set(w,{...g,address:J(c,A)})}return{state:{...e,lastEventId:p,nextWorkspaceOrder:i?e.nextWorkspaceOrder:e.nextWorkspaceOrder+1,workspaces:f,sessions:h,gates:y},changed:!0,resyncRequired:!1,cues:[]}}case"workspace/archived":{let a=typeof n.id=="number"?n.id:s;if(a===null)return m();let c=n.archivedAt!==null&&n.archivedAt!==void 0,i=e.workspaces.get(a),f=new Map(e.workspaces);i&&f.set(a,{...i,archived:c});let h=e.sessions,v=e.gates;if(c){let y=new Map(e.sessions),w=new Set;for(let[g,A]of e.sessions)A.workspaceId===a&&(y.delete(g),w.add(A.id));h=y,w.size>0&&(v=ze(a,w,v).nextGates)}return{state:{...e,lastEventId:p,workspaces:f,sessions:h,gates:v},changed:!!i||h!==e.sessions,resyncRequired:!1,cues:[]}}case"workspace/deleted":{let a=typeof n.id=="number"?n.id:s;if(a===null)return m();let c=e.workspaces.has(a),i=new Map(e.workspaces);i.delete(a);let f=new Map(e.sessions),h=new Set;for(let[w,g]of e.sessions)g.workspaceId===a&&(f.delete(w),h.add(g.id));let v=h.size>0?f:e.sessions,y=h.size>0?ze(a,h,e.gates).nextGates:e.gates;return{state:{...e,lastEventId:p,workspaces:i,sessions:v,gates:y},changed:c||v!==e.sessions,resyncRequired:!1,cues:[]}}case"session/created":{let a=typeof n.workspaceId=="number"?n.workspaceId:s,c=typeof n.id=="number"?n.id:typeof t.sessionId=="number"?t.sessionId:null,i=typeof n.name=="string"?n.name:null;if(a===null||c===null||i===null)return{state:{...e,lastEventId:p},changed:!1,resyncRequired:!1,cues:[]};let f=e.workspaces.get(a),h=typeof n.workspaceName=="string"?n.workspaceName:f?.name??String(a),v=typeof n.projectRoot=="string"?n.projectRoot:n.projectRoot===null?null:f?.projectRoot??null,y=typeof n.projectLabel=="string"?n.projectLabel:n.projectLabel===null?null:f?.projectLabel??v,w=new Map(e.workspaces);w.set(a,{id:a,name:h,projectRoot:v,projectLabel:y,archived:!1,order:f?.order??e.nextWorkspaceOrder});let g=f?e.nextWorkspaceOrder:e.nextWorkspaceOrder+1;if(n.origin!=="model")return{state:{...e,lastEventId:p,nextWorkspaceOrder:g,workspaces:w},changed:!f,resyncRequired:!1,cues:[]};let A=P(a,c),x=e.sessions.get(A),E=typeof n.parentSessionId=="number"?n.parentSessionId:null,S=E!==null?e.sessions.get(P(a,E)):void 0,u=E===null?null:S?.name??x?.parentName??"_plurnk",b=E===null?null:S!==void 0?"model":x?.parentOrigin??"_plurnk",I=$e(n.kind)??(E===null?"root":"work"),O=he(a,c,e.gates),k=x?.opening??(I==="fork"?S?.opening:void 0),d=typeof n.persona=="string"?n.persona:x?.persona,R=new Map(e.sessions);R.set(A,{workspaceId:a,workspaceName:h,projectRoot:v,projectLabel:y,id:c,name:i,parentSessionId:E,parentName:u,parentOrigin:b,kind:I,lifecycle:x?.lifecycle&&x.lifecycle!=="idle"?x.lifecycle:typeof n.lifecycle=="string"?n.lifecycle:"idle",gates:O,archived:!1,...k!==void 0?{opening:k}:{},...x?.title!==void 0?{title:x.title}:{},...d!==void 0?{persona:d}:{},reply:x?.reply??null});for(let[M,_]of R)_.workspaceId===a&&_.parentSessionId===c&&(_.parentName!==i||_.parentOrigin!=="model")&&R.set(M,{..._,parentName:i,parentOrigin:"model"});return{state:{...e,lastEventId:p,nextWorkspaceOrder:g,workspaces:w,sessions:R},changed:!0,resyncRequired:!1,cues:[]}}case"session/archived":case"session/deleted":{if(s===null||o==="session/archived"&&(n.archivedAt===null||n.archivedAt===void 0))return m();let a=Array.isArray(n.sessionIds)?n.sessionIds:[],c=new Set;for(let v of a)typeof v=="number"&&c.add(v);let i=new Map(e.sessions),f=!1;for(let v of c)i.delete(P(s,v))&&(f=!0);let h=ze(s,c,e.gates);return{state:{...e,lastEventId:p,sessions:i,gates:h.nextGates},changed:f||h.removedAny,resyncRequired:!1,cues:[]}}case"session/titled":{if(s===null||typeof n.id!="number"||typeof n.title!="string")return m();let a=P(s,n.id),c=e.sessions.get(a);if(!c)return m(e.omitted>0);let i=n.title.trim();if((c.title??"")===i)return m();let f=new Map(e.sessions);return f.set(a,{...c,title:i}),{state:{...e,lastEventId:p,sessions:f},changed:!0,resyncRequired:!1,cues:[]}}case"session/policy":{if(s===null||typeof n.sessionId!="number"||!("persona"in n))return m();let a=P(s,n.sessionId),c=e.sessions.get(a);if(!c)return m(e.omitted>0);let i=typeof n.persona=="string"?n.persona:void 0;if((c.persona??void 0)===i)return m();let f=new Map(e.sessions),{persona:h,...v}=c;return f.set(a,i!==void 0?{...v,persona:i}:v),{state:{...e,lastEventId:p,sessions:f},changed:!0,resyncRequired:!1,cues:[]}}case"session/replied":{if(s===null||typeof n.sessionId!="number")return m();let a=De(n.reply);if(a===null)return m();let c=P(s,n.sessionId),i=e.sessions.get(c);if(!i)return m(e.omitted>0);if(i.reply!==null&&i.reply.id>=a.id)return m();let f=new Map(e.sessions);f.set(c,{...i,reply:a});let h=J(i.workspaceName,i.name),v=a.excerpt?[{kind:"replied",timestamp:l,workspaceId:s,sessionId:i.id,address:h,completion:a.completion??200,excerpt:a.excerpt}]:[];return{state:{...e,lastEventId:p,sessions:f},changed:!0,resyncRequired:!1,cues:v}}case"loop/started":case"loop/parked":{if(s===null||typeof n.sessionId!="number")return m();let a=P(s,n.sessionId),c=e.sessions.get(a),i=o==="loop/started"&&typeof n.opening=="string"&&n.opening.trim()!==""?ee(n.opening,140):void 0,f=o==="loop/started"&&$(n.session)?n.session:null;if(f!==null&&typeof f.id=="number"&&typeof f.name=="string"){let x=f.id,E=f.name,S=e.workspaces.get(s),u=S?.name??c?.workspaceName??String(s),b=S?.projectRoot??c?.projectRoot??null,I=S?.projectLabel??c?.projectLabel??b,O=typeof f.parentSessionId=="number"?f.parentSessionId:null,k=O===null?null:typeof f.parentName=="string"?f.parentName:"_plurnk",d=O===null?null:Ze(f.parentOrigin)??"_plurnk",R=typeof f.gates=="number"?f.gates:0,M=Math.max(R,he(s,x,e.gates)),_=typeof f.opening=="string"&&f.opening.trim()!==""?ee(f.opening,140):void 0,T=c?.opening??_??i,N=De(f.reply),F=c?.reply!==null&&c?.reply!==void 0&&(N===null||c.reply.id>N.id)?c.reply:N,C=typeof f.title=="string"&&f.title.trim()!==""?f.title.trim():c?.title,j=typeof f.persona=="string"&&f.persona!==""?f.persona:f.persona===null?void 0:c?.persona,q=new Map(e.sessions);q.set(a,{workspaceId:s,workspaceName:u,projectRoot:b,projectLabel:I,id:x,name:E,parentSessionId:O,parentName:k,parentOrigin:d,kind:$e(f.kind)??(O===null?"root":"work"),lifecycle:"running",gates:M,archived:!1,...T!==void 0?{opening:T}:{},...C!==void 0?{title:C}:{},...j!==void 0?{persona:j}:{},reply:F});let W=!c&&e.omitted>0?e.omitted-1:e.omitted,K=J(u,E);return{state:{...e,lastEventId:p,omitted:W,sessions:q},changed:!0,resyncRequired:!1,cues:[{kind:"activity",timestamp:l,workspaceId:s,sessionId:x,address:K,source:"loop/started",...i!==void 0?{detail:i}:{}}]}}if(!c)return m(e.omitted>0);let h=o==="loop/parked"?"parked":"running",v=c.opening??i,y=new Map(e.sessions),w=c.lifecycle!==h||c.opening!==v;w&&y.set(a,{...c,lifecycle:h,...v!==void 0?{opening:v}:{}});let g=J(c.workspaceName,c.name),A=o==="loop/started"?[{kind:"activity",timestamp:l,workspaceId:s,sessionId:c.id,address:g,source:"loop/started",...i!==void 0?{detail:i}:{}}]:[{kind:"terminated",timestamp:l,workspaceId:s,sessionId:c.id,address:g,status:202,lifecycle:"parked"}];return{state:{...e,lastEventId:p,...w?{sessions:y}:{}},changed:w,resyncRequired:!1,cues:A}}case"loop/proposal":{if(s===null||typeof n.sessionId!="number"||typeof n.logEntryId!="number"||!$(n.disposition)||n.disposition.decision!=="review")return m();let a=P(s,n.sessionId),c=e.sessions.get(a);if(!c&&e.omitted>0)return m(!0);let i=c?.workspaceName??e.workspaces.get(s)?.name??String(s),f=typeof n.session=="string"&&n.session!==""?n.session:c?.name??`session-${n.sessionId}`,h=J(i,f),v=Qe(n),y=ve("proposal",s,n.logEntryId),w=e.gates.has(y),g=new Map(e.gates);g.set(y,{key:y,kind:"proposal",workspaceId:s,sessionId:n.sessionId,itemId:n.logEntryId,address:h,summary:v,...typeof n.op=="string"?{op:n.op}:{},...typeof n.expiresAt=="string"?{expiresAt:n.expiresAt}:{}});let A=new Map(e.sessions);c&&A.set(a,{...c,lifecycle:"running",gates:he(s,c.id,g)});let x=w?[]:[{kind:"gate-opened",timestamp:l,workspaceId:s,sessionId:n.sessionId,address:h,gateKey:y,gateKind:"proposal",summary:v}];return{state:{...e,lastEventId:p,gates:g,sessions:A},changed:!0,resyncRequired:!1,cues:x}}case"loop/interaction":{if(s===null||typeof n.sessionId!="number"||typeof n.interactionId!="number")return m();let a=P(s,n.sessionId),c=e.sessions.get(a);if(!c&&e.omitted>0)return m(!0);let i=c?.workspaceName??e.workspaces.get(s)?.name??String(s),f=c?.name??`session-${n.sessionId}`,h=J(i,f),v=et(n),y=ve("interaction",s,n.interactionId),w=e.gates.has(y),g=new Map(e.gates);g.set(y,{key:y,kind:"interaction",workspaceId:s,sessionId:n.sessionId,itemId:n.interactionId,address:h,summary:v});let A=new Map(e.sessions);c&&A.set(a,{...c,lifecycle:"running",gates:he(s,c.id,g)});let x=w?[]:[{kind:"gate-opened",timestamp:l,workspaceId:s,sessionId:n.sessionId,address:h,gateKey:y,gateKind:"interaction",summary:v}];return{state:{...e,lastEventId:p,gates:g,sessions:A},changed:!0,resyncRequired:!1,cues:x}}case"loop/gate-settled":{if(s===null||typeof n.sessionId!="number")return m();let a=n.kind==="proposal"?"proposal":n.kind==="interaction"?"interaction":null,c=a==="proposal"?typeof n.logEntryId=="number"?n.logEntryId:null:a==="interaction"&&typeof n.interactionId=="number"?n.interactionId:null;if(a===null||c===null)return m();let i=ve(a,s,c),f=e.gates.get(i);if(!f)return m();let h=new Map(e.gates);h.delete(i);let v=P(s,n.sessionId),y=e.sessions.get(v),w=e.sessions;if(y){let A=he(s,y.id,h);if(y.gates!==A){let x=new Map(e.sessions);x.set(v,{...y,gates:A}),w=x}}let g=a==="proposal"?typeof n.decision=="string"?n.decision:"settled":typeof n.action=="string"?n.action:"settled";return{state:{...e,lastEventId:p,gates:h,sessions:w},changed:!0,resyncRequired:!1,cues:[{kind:"gate-settled",timestamp:l,workspaceId:s,sessionId:n.sessionId,address:f.address,gateKey:i,gateKind:a,resolution:g}]}}case"loop/terminated":{if(s===null||typeof n.sessionId!="number")return m();let a=P(s,n.sessionId),c=e.sessions.get(a);if(!c)return m(e.omitted>0);let i=$(n.result)&&typeof n.result.status=="number"?n.result.status:200,f=zt(i),h=ze(s,new Set([c.id]),e.gates),v=e.sessions,y=h.removedAny;if(c.lifecycle!==f||c.gates!==0){let g=new Map(e.sessions);g.set(a,{...c,lifecycle:f,gates:0}),v=g,y=!0}let w=J(c.workspaceName,c.name);return{state:{...e,lastEventId:p,gates:h.nextGates,sessions:v},changed:y,resyncRequired:!1,cues:[{kind:"terminated",timestamp:l,workspaceId:s,sessionId:c.id,address:w,status:i,lifecycle:f}]}}case"stream/concluded":{if(s===null||typeof n.sessionId!="number")return m();let a=e.sessions.get(P(s,n.sessionId));if(!a)return m();let c=typeof n.summary=="string"&&n.summary.trim()!==""?ee(n.summary):void 0;return{state:{...e,lastEventId:p},changed:!1,resyncRequired:!1,cues:[{kind:"activity",timestamp:l,workspaceId:s,sessionId:a.id,address:J(a.workspaceName,a.name),source:"stream/concluded",...c!==void 0?{detail:c}:{}}]}}case"notice/event":{let a=$(n.notice)?n.notice:null,c=a&&typeof a.message=="string"?ee(a.message):"";if(c==="")return m();let i=a&&typeof a.level=="string"?a.level:"info",f=typeof n.sessionId=="number"?n.sessionId:null,h=s!==null&&f!==null?e.sessions.get(P(s,f)):void 0,v=s!==null?e.workspaces.get(s):void 0,y=h?J(h.workspaceName,h.name):v?v.name:null;return{state:{...e,lastEventId:p},changed:!1,resyncRequired:!1,cues:[{kind:"notice",timestamp:l,workspaceId:s,sessionId:f,address:y,level:i,message:c}]}}default:return m()}}var st=Math.PI/180,de=1.35,tt=1.85,nt=.28,xn=4,ot=Object.freeze([-38,38,-58,58,-78,78,-98,98,-116,116,-134,134]),ke=e=>Math.round(e*1e4)/1e4;function Ne(e,t,o){return Object.freeze({x:ke(o*Math.sin(e)),y:ke(t),z:ke(-o*Math.cos(e))})}function An(e,t){return e.parentSessionId===null&&e.kind==="root"&&e.lifecycle==="idle"&&e.reply===null&&e.opening===void 0&&e.title===void 0&&e.gates===0&&!t}function Sn(e){let t=Math.floor(e/2)+1;return{dAzimuthRad:(e%2===0?1:-1)*t*5.5*st,dElevationM:e%3===0?.14:e%3===1?-.13:.22,dRadiusM:-.06}}function En(e){let t=e*2.399963229728653;return{dAzimuthRad:Math.cos(t)*3.2*st,dElevationM:Math.sin(t)*.11,dRadiusM:-.05}}function jt({calloutMs:e=8e3,activityHoldMs:t=4e3,initialVisibility:o="on"}={}){let n=o,r=new Map,l=0,s=new Map,p=new Map,m=new Map,a=[],c=1;function i(y){let w=r.get(y);w===void 0&&(w=l++,r.set(y,w));let g=ot[w%ot.length],A=Math.floor(w/ot.length);return{azimuthRad:g*st,elevationM:de+A*.28,radiusM:tt}}function f(y,w){for(let g of y)g.workspaceId!==null&&g.sessionId!==null&&m.set(P(g.workspaceId,g.sessionId),w),g.kind==="replied"?h({tone:"reply",workspaceId:g.workspaceId,sessionKey:P(g.workspaceId,g.sessionId),address:g.address,text:g.excerpt,nowMs:w}):g.kind==="terminated"&&g.status!==202&&g.status!==499?h({tone:g.status>=400?"failed":"completed",workspaceId:g.workspaceId,sessionKey:P(g.workspaceId,g.sessionId),address:g.address,text:g.status>=400?`failed (${g.status})`:"completed",nowMs:w}):g.kind==="notice"&&(g.level==="warning"||g.level==="error")&&h({tone:"notice",workspaceId:g.workspaceId,sessionKey:g.workspaceId!==null&&g.sessionId!==null?P(g.workspaceId,g.sessionId):null,address:g.address??"plurnk",text:g.message,nowMs:w})}function h({tone:y,workspaceId:w,sessionKey:g,address:A,text:x,nowMs:E}){for(;a.length>=xn;)a.shift();a.push({id:`transient:${c++}`,tone:y,workspaceId:w,sessionKey:g,address:A,text:x,expiresAtMs:E+e})}function v(y,w){for(let d=a.length-1;d>=0;d-=1)a[d].expiresAtMs<=w&&a.splice(d,1);let g=[...y.workspaces.values()].filter(d=>!d.archived).toSorted((d,R)=>d.order-R.order||d.id-R.id),A=new Set(g.map(d=>d.id)),x=new Set;for(let d of y.sessions.values())!d.archived&&A.has(d.workspaceId)&&d.parentSessionId!==null&&x.add(P(d.workspaceId,d.parentSessionId));let E=new Map,S=0;for(let d of y.sessions.values()){if(d.archived||!A.has(d.workspaceId))continue;let R=P(d.workspaceId,d.id);if(An(d,x.has(R)))continue;(me(d.lifecycle)||d.gates>0)&&(S+=1);let M=E.get(d.workspaceId)??[];M.push(d),E.set(d.workspaceId,M)}let u=[],b=new Map,I=new Map;for(let d of g){let R=Fe(d.id),M=s.get(d.name)??i(d.name),_=`workspace:${d.id}`,T=(E.get(d.id)??[]).toSorted((L,G)=>L.id-G.id),N=0,F=!1,C=0;for(let L of T){N+=L.gates,me(L.lifecycle)&&(F=!0);let G=m.get(P(d.id,L.id));G!==void 0&&w-G<t&&(C=Math.max(C,1-(w-G)/t))}let j=N>0||F||C>0,q=n==="off"?0:n==="passive"?j?1:0:j?1:nt,W=Object.freeze({id:_,kind:"workspace",workspaceId:d.id,workspaceName:d.name,sessionId:null,address:d.name,label:d.name,tetherTo:null,swatch:R,lifecycle:F?"running":"idle",gates:N,azimuthRad:M.azimuthRad,elevationM:M.elevationM,radiusM:M.radiusM,position:Ne(M.azimuthRad,M.elevationM,M.radiusM),targetOpacity:q,pulseStrength:ke(C)});u.push(W),I.set(d.id,W);let K=T.filter(L=>L.parentSessionId===null||!T.some(G=>G.id===L.parentSessionId)),B=T.filter(L=>L.parentSessionId!==null&&T.some(G=>G.id===L.parentSessionId)),z=new Set;for(let L of B){let G=P(d.id,L.id),H=m.get(G);(L.gates>0||me(L.lifecycle)||H!==void 0&&w-H<t)&&L.parentSessionId!==null&&z.add(L.parentSessionId)}K.forEach((L,G)=>{let H=J(d.name,L.name),X=p.get(H)??Sn(G),Y=M.azimuthRad+X.dAzimuthRad,ge=M.elevationM+X.dElevationM,Se=Math.max(.5,M.radiusM+X.dRadiusM),Ee=P(d.id,L.id),ye=m.get(Ee),Re=ye!==void 0&&w-ye<t?1-(w-ye)/t:0,we=L.gates>0||me(L.lifecycle)||Re>0||z.has(L.id),Ce=n==="off"?0:n==="passive"?we?1:0:we?1:nt,Me=Object.freeze({id:`session:${d.id}:${L.id}`,kind:"session",workspaceId:d.id,workspaceName:d.name,sessionId:L.id,address:H,label:L.title??L.name,tetherTo:_,swatch:R,lifecycle:L.lifecycle,gates:L.gates,azimuthRad:Y,elevationM:ge,radiusM:Se,position:Ne(Y,ge,Se),targetOpacity:Ce,pulseStrength:ke(Re)});u.push(Me),b.set(Ee,Me)});let ie=new Map;for(let L of B){let G=L.parentSessionId,H=b.get(P(d.id,G))??W,X=ie.get(G)??0;ie.set(G,X+1);let Y=J(d.name,L.name),ge=p.get(Y)??En(X),Se=H.azimuthRad+ge.dAzimuthRad,Ee=H.elevationM+ge.dElevationM,ye=Math.max(.5,H.radiusM+ge.dRadiusM),Re=P(d.id,L.id),we=m.get(Re),Ce=we!==void 0&&w-we<t?1-(w-we)/t:0,Me=L.gates>0||me(L.lifecycle)||Ce>0,sn=n==="off"?0:n==="passive"?Me?1:0:Me?1:nt,ut=Object.freeze({id:`session:${d.id}:${L.id}`,kind:"satellite",workspaceId:d.id,workspaceName:d.name,sessionId:L.id,address:Y,label:L.title??L.name,tetherTo:H.id,swatch:R,lifecycle:L.lifecycle,gates:L.gates,azimuthRad:Se,elevationM:Ee,radiusM:ye,position:Ne(Se,Ee,ye),targetOpacity:sn,pulseStrength:ke(Ce)});u.push(ut),b.set(Re,ut)}}let O=[...y.gates.values()].filter(d=>A.has(d.workspaceId)),k=[];if(n!=="off"){for(let d of O){let R=b.get(P(d.workspaceId,d.sessionId))??I.get(d.workspaceId),M=Ne(0,de,tt);k.push(Object.freeze({id:`gate:${d.key}`,pinned:!0,tone:"gate",address:d.address,text:d.summary,swatch:re.gate,position:R?.position??M,expiresAtMs:null}))}for(let d of a){let R=(d.sessionKey?b.get(d.sessionKey):void 0)??(d.workspaceId!==null?I.get(d.workspaceId):void 0),M=d.tone==="failed"?re.failed:R?.swatch??re.gate,_=Ne(0,de,tt);k.push(Object.freeze({id:d.id,pinned:!1,tone:d.tone,address:d.address,text:d.text,swatch:M,position:R?.position??_,expiresAtMs:d.expiresAtMs}))}}return Object.freeze({visibilityMode:n,nodes:Object.freeze(u),callouts:Object.freeze(k),counts:Object.freeze({workspaces:g.length,activeSessions:S,openGates:O.length})})}return{get visibilityMode(){return n},setVisibilityMode(y){(y==="on"||y==="passive"||y==="off")&&(n=y)},cycleVisibilityMode(){return n=n==="on"?"passive":n==="passive"?"off":"on",n},setWorkspaceAnchor(y,w){s.set(y,{azimuthRad:w.azimuthRad,elevationM:w.elevationM,radiusM:Math.max(.5,w.radiusM)})},setSessionOffset(y,w){p.set(y,{dAzimuthRad:w.dAzimuthRad,dElevationM:w.dElevationM,dRadiusM:w.dRadiusM})},resetLayout(){s.clear(),p.clear()},exportLayout(){return{workspaces:Object.fromEntries(s),sessions:Object.fromEntries(p)}},importLayout(y){if($(y)){if($(y.workspaces))for(let[w,g]of Object.entries(y.workspaces))$(g)&&typeof g.azimuthRad=="number"&&typeof g.elevationM=="number"&&typeof g.radiusM=="number"&&s.set(w,{azimuthRad:g.azimuthRad,elevationM:g.elevationM,radiusM:Math.max(.5,g.radiusM)});if($(y.sessions))for(let[w,g]of Object.entries(y.sessions))$(g)&&typeof g.dAzimuthRad=="number"&&typeof g.dElevationM=="number"&&typeof g.dRadiusM=="number"&&p.set(w,{dAzimuthRad:g.dAzimuthRad,dElevationM:g.dElevationM,dRadiusM:g.dRadiusM})}},ingestCues:f,project:v}}var Rn=Object.freeze({x:0,y:de,z:-1.85}),Mn=Object.freeze({position:Object.freeze({x:0,y:de,z:0}),forward:Object.freeze({x:0,y:0,z:-1}),up:Object.freeze({x:0,y:1,z:0})}),Dt=Object.freeze([Object.freeze({slot:0,note:"D3",baseHz:146.83,wave:"sine"}),Object.freeze({slot:1,note:"F#3",baseHz:185,wave:"triangle"}),Object.freeze({slot:2,note:"A3",baseHz:220,wave:"sine"}),Object.freeze({slot:3,note:"B3",baseHz:246.94,wave:"triangle"}),Object.freeze({slot:4,note:"D4",baseHz:293.66,wave:"sine"}),Object.freeze({slot:5,note:"E4",baseHz:329.63,wave:"triangle"}),Object.freeze({slot:6,note:"F#4",baseHz:369.99,wave:"sine"}),Object.freeze({slot:7,note:"A4",baseHz:440,wave:"triangle"})]);function Ct(e){let t=Fe(e);return Dt[t.slot]}var Pt=e=>Number.isFinite(e)?e<=0?0:e>=1?1:e:0;function Tn(){return typeof window<"u"&&typeof window.AudioContext=="function"?new window.AudioContext({latencyHint:"interactive"}):null}function D(e,t,o,n){n&&typeof e.setTargetAtTime=="function"?e.setTargetAtTime(t,o,.03):e.setValueAtTime(t,o),e.value=t}function Bt(e,t,o,n){e.positionX&&e.positionY&&e.positionZ?(D(e.positionX,t.x,o,n),D(e.positionY,t.y,o,n),D(e.positionZ,t.z,o,n)):e.setPosition?.(t.x,t.y,t.z)}function Ft(e,t,o){let{position:n,forward:r,up:l}=t;e.positionX&&e.positionY&&e.positionZ?(D(e.positionX,n.x,o,!1),D(e.positionY,n.y,o,!1),D(e.positionZ,n.z,o,!1)):e.setPosition?.(n.x,n.y,n.z),e.forwardX&&e.forwardY&&e.forwardZ&&e.upX&&e.upY&&e.upZ?(D(e.forwardX,r.x,o,!1),D(e.forwardY,r.y,o,!1),D(e.forwardZ,r.z,o,!1),D(e.upX,l.x,o,!1),D(e.upY,l.y,o,!1),D(e.upZ,l.z,o,!1)):e.setOrientation?.(r.x,r.y,r.z,l.x,l.y,l.z)}function $t(e,t){let o=e.createPanner();return o.panningModel="HRTF",o.distanceModel="inverse",o.refDistance=1.2,o.maxDistance=12,o.rolloffFactor=1,o.coneInnerAngle=360,o.coneOuterAngle=360,o.coneOuterGain=1,Bt(o,t,e.currentTime,!1),o}function On(e){let t=[],o=new Set;for(let n of e.nodes)n.kind!=="workspace"&&n.gates>0&&(t.push(n),o.add(n.workspaceId));for(let n of e.nodes)n.kind==="workspace"&&n.gates>0&&!o.has(n.workspaceId)&&t.push(n);return t}function _n(e,t,o){if(t!==null){if(o!==null){let n=e.nodes.find(r=>r.workspaceId===t&&r.sessionId===o);if(n)return n}return e.nodes.find(n=>n.kind==="workspace"&&n.workspaceId===t)}}function qt({createAudioContext:e=Tn,initialGain:t=.35,initialMuted:o=!1,activityCooldownMs:n=1600,maxTransientVoices:r=6}={}){let l=Pt(t),s=!!o,p=!1,m=Mn,a=null,c=null,i=null,f=new Map,h=new Set,v=new Map;function y(){if(!c||!i)return;let b=s?0:l;D(i.gain,b,c.currentTime,!0)}function w(){if(p)return null;if(c!==null)return c;let b=e();if(!b)return null;c=b,i=b.createGain();let I=s?0:l;return D(i.gain,I,b.currentTime,!1),i.connect(b.destination),Ft(b.listener,m,b.currentTime),b}function g(b){for(let I of h)I.endsAtSec<=b&&(I.cleanup(),h.delete(I))}function A(b){for(let I of v.values())I.stop(b);v.clear()}function x(){for(let b of h)b.cleanup();h.clear()}function E(b,I){if(!c||!i||p||s||c.state!=="running"){A(!1);return}let O=c,k=i,d=O.currentTime,R=On(b),M=new Set(R.map(_=>_.id));for(let[_,T]of v)M.has(_)||(T.stop(!1),v.delete(_));for(let _ of R){let T=v.get(_.id);if(T){Bt(T.panner,_.position,d,!0);continue}let N=Ct(_.workspaceId),F=$t(O,_.position),C=O.createBiquadFilter();C.type="lowpass",D(C.frequency,720,d,!1),D(C.Q,.7,d,!1);let j=O.createGain(),q=_.sessionId!==null&&I.has(`${_.workspaceId}:${_.sessionId}`);D(j.gain,1e-4,d,!1),q?(j.gain.linearRampToValueAtTime(.11,d+.03),j.gain.exponentialRampToValueAtTime(.042,d+.32)):j.gain.linearRampToValueAtTime(.042,d+.35);let W=O.createOscillator();W.type="sine",D(W.frequency,N.baseHz,d,!1);let K=O.createOscillator();K.type="sine",D(K.frequency,Math.round(N.baseHz*(4/3)*100)/100,d,!1);let B=O.createOscillator();B.type="sine",D(B.frequency,.25,d,!1);let z=O.createGain();D(z.gain,.016,d,!1),W.connect(C),K.connect(C),C.connect(j),B.connect(z),z.connect(j.gain),j.connect(F),F.connect(k),W.start(d),K.start(d),B.start(d);let ie=!1,L=G=>{if(ie)return;ie=!0;let H=O.currentTime,X=()=>{try{W.disconnect(),K.disconnect(),B.disconnect(),z.disconnect(),C.disconnect(),j.disconnect(),F.disconnect()}catch{}};if(G){try{W.stop(H),K.stop(H),B.stop(H)}catch{}X();return}j.gain.cancelScheduledValues?.(H),j.gain.setValueAtTime(Math.max(1e-4,j.gain.value),H),j.gain.exponentialRampToValueAtTime(1e-4,H+.08);let Y=H+.09;W.onended=X;try{W.stop(Y),K.stop(Y),B.stop(Y)}catch{X()}};v.set(_.id,{nodeId:_.id,panner:F,voiceGain:j,stop:L})}}function S({position:b,wave:I,startHz:O,secondHz:k,stepAtSec:d=.1,peakGain:R,durationSec:M,cutoffHz:_}){if(!c||!i||p||s||c.state!=="running")return;let T=c,N=T.currentTime,F=$t(T,b),C=T.createBiquadFilter();C.type="lowpass",D(C.frequency,_,N,!1),D(C.Q,.7,N,!1);let j=T.createGain();D(j.gain,1e-4,N,!1),j.gain.linearRampToValueAtTime(R,N+.012),j.gain.exponentialRampToValueAtTime(1e-4,N+M);let q=T.createOscillator();q.type=I,D(q.frequency,O,N,!1),k!==void 0&&q.frequency.setValueAtTime(k,N+d),q.connect(C),C.connect(j),j.connect(F),F.connect(i);let W=!1,K=()=>{if(!W){W=!0;try{q.disconnect(),C.disconnect(),j.disconnect(),F.disconnect()}catch{}}},B=N+M+.02,z={endsAtSec:B,cleanup:K};h.add(z),q.onended=()=>{K(),h.delete(z)},q.start(N),q.stop(B)}function u(b,I=[],O=Date.now()){if(a=b,!c||p)return;g(c.currentTime);let k=new Set;for(let d of I)d.kind==="gate-opened"&&k.add(`${d.workspaceId}:${d.sessionId}`);if(E(b,k),!(s||c.state!=="running"))for(let d of I){let R=_n(b,d.workspaceId,d.sessionId),M=R?.position??Rn,_=d.workspaceId!==null?Ct(d.workspaceId):Dt[0];switch(d.kind){case"activity":{let T=`${d.workspaceId}:${d.sessionId}`,N=f.get(T);if(N!==void 0&&O-N<n||h.size>=r)break;f.set(T,O);let F=R?.kind==="satellite";S({position:M,wave:_.wave,startHz:F?_.baseHz*2:_.baseHz,peakGain:F?.065:.105,durationSec:F?.14:.18,cutoffHz:820});break}case"gate-settled":{let T=d.resolution==="accept"||d.resolution==="submitted"||d.resolution==="settled";S(T?{position:M,wave:"sine",startHz:Math.round(_.baseHz*(4/3)*100)/100,secondHz:Math.round(_.baseHz*1.5*100)/100,stepAtSec:.09,peakGain:.13,durationSec:.28,cutoffHz:1100}:{position:M,wave:"sine",startHz:_.baseHz,secondHz:Math.round(_.baseHz*(8/9)*100)/100,stepAtSec:.08,peakGain:.075,durationSec:.2,cutoffHz:520});break}case"terminated":{d.status===200?S({position:M,wave:_.wave,startHz:_.baseHz,secondHz:Math.round(_.baseHz*1.5*100)/100,stepAtSec:.11,peakGain:.13,durationSec:.32,cutoffHz:1050}):d.status===202?S({position:M,wave:"sine",startHz:Math.round(_.baseHz*1.25*100)/100,secondHz:_.baseHz,stepAtSec:.09,peakGain:.07,durationSec:.22,cutoffHz:680}):d.status===499?S({position:M,wave:"sine",startHz:Math.round(_.baseHz*.75*100)/100,peakGain:.06,durationSec:.15,cutoffHz:420}):d.status>=400&&S({position:M,wave:"triangle",startHz:196,secondHz:130.81,stepAtSec:.12,peakGain:.16,durationSec:.38,cutoffHz:210});break}case"notice":{(d.level==="warning"||d.level==="error")&&S({position:M,wave:"triangle",startHz:220,secondHz:196,stepAtSec:.1,peakGain:.11,durationSec:.26,cutoffHz:540});break}default:break}}}return{get gain(){return l},get muted(){return s},get unlocked(){return c!==null&&c.state==="running"},get activeGateCount(){return v.size},get activeTransientCount(){return c&&g(c.currentTime),h.size},async unlock(){let b=w();return b?(b.state!=="running"&&await b.resume().catch(()=>{}),y(),a&&b.state==="running"&&E(a,new Set),b.state==="running"):!1},setGain(b){l=Pt(b),y()},setMuted(b){let I=!!b;return s===I||(s=I,y(),s?(A(!1),x()):a&&c&&c.state==="running"&&E(a,new Set)),s},toggleMuted(){return this.setMuted(!s)},setListenerPose(b){m=b,c&&!p&&Ft(c.listener,b,c.currentTime)},syncFrame:u,async dispose(){if(p)return;p=!0,A(!0),x();let b=c;c=null,i=null,b&&await b.close().catch(()=>{})}}}async function Gt({isSecureContext:e,xr:t=null}){if(!e)return Object.freeze({posture:"2d-insecure",vrSupported:!1,arSupported:!1});if(t!==null&&typeof t=="object"&&typeof t.isSessionSupported=="function"){let[o,n]=await Promise.all([Promise.resolve(t.isSessionSupported("immersive-ar")).then(Boolean,()=>!1),Promise.resolve(t.isSessionSupported("immersive-vr")).then(Boolean,()=>!1)]);return Object.freeze({posture:o?"immersive-ar":n?"immersive-vr":"2d",vrSupported:n,arSupported:o})}return Object.freeze({posture:"2d",vrSupported:!1,arSupported:!1})}var Ie=11,xe=7,rt=Object.freeze({workspace:.085,session:.052,satellite:.032}),zn=1.16,Ln=.18,Nn=1.4,Ht=.018,jn=.65;function it(e){return e==="workspace"?rt.workspace:e==="session"?rt.session:rt.satellite}function Ut(e,t,o){let n=t[0],r=t[1],l=t[2],s=t[3],p=t[4],m=t[5],a=t[6],c=t[7],i=t[8],f=t[9],h=t[10],v=t[11],y=t[12],w=t[13],g=t[14],A=t[15];for(let x=0;x<4;x+=1){let E=x*4,S=o[E],u=o[E+1],b=o[E+2],I=o[E+3];e[E]=n*S+p*u+i*b+y*I,e[E+1]=r*S+m*u+f*b+w*I,e[E+2]=l*S+a*u+h*b+g*I,e[E+3]=s*S+c*u+v*b+A*I}return e}function Ae(e,t,o,n){let r=Math.hypot(e,t,o);return r<1e-6?n:{x:e/r||0,y:t/r||0,z:o/r||0}}function Wt(e){return{right:Ae(e[0],e[1],e[2],{x:1,y:0,z:0}),up:Ae(e[4],e[5],e[6],{x:0,y:1,z:0})}}function Vt(e){return{position:{x:e[12],y:e[13],z:e[14]},forward:Ae(-e[8],-e[9],-e[10],{x:0,y:0,z:-1}),up:Ae(e[4],e[5],e[6],{x:0,y:1,z:0})}}function Kt(){let e=new Map,t=32,o=new Float32Array(t*Ie),n=64,r=new Float32Array(n*xe);function l(a){if(!(a<=t)){for(;t<a;)t*=2;o=new Float32Array(t*Ie)}}function s(a){if(!(a<=n)){for(;n<a;)n*=2;r=new Float32Array(n*xe)}}function p({frame:a,cues:c=[],dtSec:i,timeSec:f,hoveredNodeId:h=null,grabbedNodeId:v=null,pointerRay:y=null}){let w=Number.isFinite(i)?Math.min(.25,Math.max(0,i)):.016,g=w===0?1:1-Math.exp(-w/Ln),A=w===0?1:Math.exp(-w/Nn),x=new Set;for(let k of a.nodes){x.add(k.id);let d=k.gates>0?1:0,R=k.position.x,M=k.position.y,_=k.position.z;if(k.kind==="satellite"&&k.lifecycle==="running"&&v!==k.id){let N=f*jn+(k.sessionId??0)*1.7,F=Math.cos(k.azimuthRad),C=Math.sin(k.azimuthRad),j=Math.cos(N)*Ht,q=Math.sin(N)*Ht;R+=F*j,M+=q,_+=C*j}let T=e.get(k.id);if(!T)e.set(k.id,{kind:k.kind,workspaceId:k.workspaceId,sessionId:k.sessionId,tetherTo:k.tetherTo,lifecycle:k.lifecycle,x:R,y:M,z:_,rgb:k.swatch.rgb,opacity:w===0?k.targetOpacity:k.targetOpacity*g,pulseStrength:k.pulseStrength,gateFactor:w===0?d:d*g,failFactor:0});else{let N=v===k.id?Math.max(g,.65):g;T.kind=k.kind,T.workspaceId=k.workspaceId,T.sessionId=k.sessionId,T.tetherTo=k.tetherTo,T.lifecycle=k.lifecycle,T.rgb=k.swatch.rgb,T.x+=(R-T.x)*N,T.y+=(M-T.y)*N,T.z+=(_-T.z)*N,T.opacity+=(k.targetOpacity-T.opacity)*g,T.pulseStrength=k.pulseStrength,T.gateFactor+=(d-T.gateFactor)*g,T.failFactor*=A}}for(let k of c)if(k.kind==="terminated"&&k.status>=400&&k.status!==499){let d=e.get(`session:${k.workspaceId}:${k.sessionId}`);d&&(d.failFactor=1);let R=e.get(`workspace:${k.workspaceId}`);R&&(R.failFactor=Math.max(R.failFactor,.6))}for(let[k,d]of e)x.has(k)||(d.opacity+=(0-d.opacity)*g,d.gateFactor*=1-g,d.failFactor*=A,d.opacity<.004&&e.delete(k));let E=[];for(let[k,d]of e)d.opacity>.004&&E.push([k,d]);l(E.length);let S=0;for(let[k,d]of E){let R=k===h||k===v,M=it(d.kind)*(R?zn:1);o[S]=d.x,o[S+1]=d.y,o[S+2]=d.z,o[S+3]=M,o[S+4]=d.rgb[0],o[S+5]=d.rgb[1],o[S+6]=d.rgb[2],o[S+7]=Math.min(1,R?Math.max(d.opacity,.92):d.opacity),o[S+8]=R?Math.max(d.pulseStrength,.35):d.pulseStrength,o[S+9]=d.gateFactor,o[S+10]=d.failFactor,S+=Ie}let u=E.length+(y?1:0);s(u*2);let b=0,I=0,O=re.gate.rgb;for(let[,k]of E){if(k.tetherTo===null)continue;let d=e.get(k.tetherTo);if(!d||d.opacity<=.004)continue;let R=Math.min(d.opacity,k.opacity)*.36,M=Math.min(d.opacity,k.opacity)*.58,_=k.rgb[0]+(O[0]-k.rgb[0])*k.gateFactor*.65,T=k.rgb[1]+(O[1]-k.rgb[1])*k.gateFactor*.65,N=k.rgb[2]+(O[2]-k.rgb[2])*k.gateFactor*.65;r[I]=d.x,r[I+1]=d.y,r[I+2]=d.z,r[I+3]=d.rgb[0],r[I+4]=d.rgb[1],r[I+5]=d.rgb[2],r[I+6]=R,r[I+7]=k.x,r[I+8]=k.y,r[I+9]=k.z,r[I+10]=_,r[I+11]=T,r[I+12]=N,r[I+13]=M,I+=xe*2,b+=2}if(y){let{origin:k,direction:d,lengthM:R,hovered:M}=y,_=k.x+d.x*R,T=k.y+d.y*R,N=k.z+d.z*R,F=M?.45:.65,C=M?.95:.82,j=M?.55:.78;r[I]=k.x,r[I+1]=k.y,r[I+2]=k.z,r[I+3]=F,r[I+4]=C,r[I+5]=j,r[I+6]=M?.42:.22,r[I+7]=_,r[I+8]=T,r[I+9]=N,r[I+10]=F,r[I+11]=C,r[I+12]=j,r[I+13]=M?.78:0,b+=2}return{orbCount:E.length,orbData:o.subarray(0,E.length*Ie),lineVertexCount:b,lineData:r.subarray(0,b*xe)}}function m(){e.clear()}return{step:p,reset:m}}var at=.9,ct=3.2,Cn=.35,Pn=2.65,Fn=1.65,$n=.055,Dn=.18,Bn=1.35,qn=1.85,qe=(e,t,o)=>e<t?t:e>o?o:e;function Gn(e){let t=e%(Math.PI*2);return t>Math.PI&&(t-=Math.PI*2),t<-Math.PI&&(t+=Math.PI*2),t}function Hn(e){let t=Math.hypot(e.x,e.z),o=qe(t,at,ct),n=t<1e-5?0:Math.atan2(e.x,-e.z),r=qe(e.y,Cn,Pn);return{azimuthRad:n,elevationM:r,radiusM:o}}function Un(e){return{origin:{x:e[12],y:e[13],z:e[14]},direction:Ae(-e[8],-e[9],-e[10],{x:0,y:0,z:-1})}}function Wn(e){return e==="satellite"?0:e==="session"?1:2}function Vn(e,t){let{origin:o,direction:n}=e,r=null;for(let l of t){if(l.targetOpacity<=.01)continue;let s=Math.max($n,it(l.kind)*Fn),p=o.x-l.position.x,m=o.y-l.position.y,a=o.z-l.position.z,c=p*n.x+m*n.y+a*n.z,i=p*p+m*m+a*a-s*s,f=c*c-i;if(f<0)continue;let h=Math.sqrt(f),v=-c-h,y=-c+h,w=v>=.05?v:y>=.05?y:-1;if(w<.05||w>5)continue;let g=Math.max(.05,-c),A=Wn(l.kind);(r===null||A<r.tier||A===r.tier&&g<r.distanceM)&&(r={node:l,distanceM:g,tier:A})}return r?{node:r.node,distanceM:r.distanceM}:null}function Be(e,t,o){try{let n=e.gamepad?.hapticActuators?.[0]?.pulse?.(t,o);n&&typeof n.catch=="function"&&n.catch(()=>{})}catch{}}function Xt({topology:e,audio:t,onVisibilityChange:o,onMuteChange:n,onLayoutCommit:r}){let l=new WeakMap,s=null,p=null;function m(){s!==null&&(s=null,r?.()),p=null}function a({session:c,frame:i,refSpace:f,worldFrame:h,dtSec:v}){if(c.visibilityState!=="visible")return m(),{layoutMutated:!1,visibilityMutated:!1,hoveredNodeId:null,grabbedNodeId:null,pointerRay:null};let y=Number.isFinite(v)?Math.min(.1,Math.max(0,v)):.016,w=!1,g=!1,A=[];for(let u of c.inputSources??[]){if(u.targetRayMode!=="tracked-pointer"||u.hand)continue;let b=l.get(u)??{trigger:!1,primaryFace:!1,secondaryFace:!1},I=u.gamepad?.buttons??[],O=!!I[0]?.pressed,k=!!I[4]?.pressed,d=!!I[5]?.pressed;if(k&&!b.primaryFace){let M=e.cycleVisibilityMode();g=!0,Be(u,.2,12),o?.(M)}if(d&&!b.secondaryFace){let M=t.toggleMuted();Be(u,.2,12),n?.(M)}let R=u.targetRaySpace?i.getPose(u.targetRaySpace,f):null;R?.transform?.matrix&&A.push({source:u,ray:Un(R.transform.matrix)}),s&&s.source===u&&!O&&(s=null,r?.()),l.set(u,{trigger:O,primaryFace:k,secondaryFace:d})}if(s&&!A.some(u=>u.source===s?.source)&&(s=null,r?.()),s){let u=A.find(b=>b.source===s?.source);if(u){let b=u.source.gamepad?.axes?.[3]??0;Math.abs(b)>Dn&&(s.grabDistanceM=qe(s.grabDistanceM-b*Bn*y,at,ct));let I={x:u.ray.origin.x+u.ray.direction.x*s.grabDistanceM,y:u.ray.origin.y+u.ray.direction.y*s.grabDistanceM,z:u.ray.origin.z+u.ray.direction.z*s.grabDistanceM},O=Hn(I);if(s.kind==="workspace")e.setWorkspaceAnchor(s.workspaceName,O),w=!0;else{let k=s.tetherTo?h.nodes.find(d=>d.id===s?.tetherTo):void 0;k&&(e.setSessionOffset(s.address,{dAzimuthRad:Gn(O.azimuthRad-k.azimuthRad),dElevationM:O.elevationM-k.elevationM,dRadiusM:O.radiusM-k.radiusM}),w=!0)}return p=s.nodeId,{layoutMutated:w,visibilityMutated:g,hoveredNodeId:p,grabbedNodeId:s.nodeId,pointerRay:{origin:u.ray.origin,direction:u.ray.direction,lengthM:s.grabDistanceM,hovered:!0}}}}let x=null;for(let u of A){let b=Vn(u.ray,h.nodes);(x===null||b!==null&&x.hit===null||b!==null&&x.hit!==null&&b.distanceM<x.hit.distanceM)&&(x={source:u.source,ray:u.ray,hit:b})}if(!x)return p=null,{layoutMutated:w,visibilityMutated:g,hoveredNodeId:null,grabbedNodeId:null,pointerRay:null};let E=x.hit?.node.id??null;if(E!==null&&E!==p&&Be(x.source,.16,10),p=E,!!x.source.gamepad?.buttons?.[0]?.pressed&&x.hit!==null){let u=x.hit.node;s={source:x.source,nodeId:u.id,kind:u.kind,workspaceName:u.workspaceName,address:u.address,tetherTo:u.tetherTo,grabDistanceM:qe(x.hit.distanceM,at,ct)},Be(x.source,.28,16)}return{layoutMutated:w,visibilityMutated:g,hoveredNodeId:p,grabbedNodeId:s?.nodeId??null,pointerRay:{origin:x.ray.origin,direction:x.ray.direction,lengthM:x.hit?.distanceM??qn,hovered:x.hit!==null}}}return{update:a,reset:m}}var Kn=`#version 300 es
|
|
2
|
+
precision highp float;
|
|
3
|
+
|
|
4
|
+
layout(location = 0) in vec2 a_quad;
|
|
5
|
+
layout(location = 1) in vec4 i_sphere;
|
|
6
|
+
layout(location = 2) in vec4 i_color;
|
|
7
|
+
layout(location = 3) in vec3 i_salience;
|
|
8
|
+
|
|
9
|
+
uniform mat4 u_viewProj;
|
|
10
|
+
uniform vec3 u_camRight;
|
|
11
|
+
uniform vec3 u_camUp;
|
|
12
|
+
|
|
13
|
+
out vec2 v_uv;
|
|
14
|
+
out vec4 v_color;
|
|
15
|
+
out vec3 v_salience;
|
|
16
|
+
|
|
17
|
+
void main() {
|
|
18
|
+
v_uv = a_quad;
|
|
19
|
+
v_color = i_color;
|
|
20
|
+
v_salience = i_salience;
|
|
21
|
+
vec3 worldPos = i_sphere.xyz + (u_camRight * a_quad.x + u_camUp * a_quad.y) * i_sphere.w;
|
|
22
|
+
gl_Position = u_viewProj * vec4(worldPos, 1.0);
|
|
23
|
+
}
|
|
24
|
+
`,Xn=`#version 300 es
|
|
25
|
+
precision highp float;
|
|
26
|
+
|
|
27
|
+
in vec2 v_uv;
|
|
28
|
+
in vec4 v_color;
|
|
29
|
+
in vec3 v_salience;
|
|
30
|
+
|
|
31
|
+
uniform float u_timeSec;
|
|
32
|
+
uniform vec3 u_gateRgb;
|
|
33
|
+
uniform vec3 u_failRgb;
|
|
34
|
+
|
|
35
|
+
out vec4 fragColor;
|
|
36
|
+
|
|
37
|
+
void main() {
|
|
38
|
+
float d = length(v_uv);
|
|
39
|
+
if (d > 1.35) discard;
|
|
40
|
+
|
|
41
|
+
float pulse = v_salience.x;
|
|
42
|
+
float gate = v_salience.y;
|
|
43
|
+
float fail = v_salience.z;
|
|
44
|
+
|
|
45
|
+
vec3 baseCol = mix(v_color.rgb, u_gateRgb, gate * 0.65);
|
|
46
|
+
baseCol = mix(baseCol, u_failRgb, fail * 0.85);
|
|
47
|
+
|
|
48
|
+
float alpha = 0.0;
|
|
49
|
+
vec3 rgb = baseCol;
|
|
50
|
+
|
|
51
|
+
if (d <= 1.0) {
|
|
52
|
+
float z = sqrt(max(0.0, 1.0 - d * d));
|
|
53
|
+
float fresnel = pow(1.0 - z, 2.3);
|
|
54
|
+
vec3 normal = normalize(vec3(v_uv * 0.92, z));
|
|
55
|
+
float keyLight = max(0.0, dot(normal, normalize(vec3(-0.32, 0.58, 0.75))));
|
|
56
|
+
float spec = pow(keyLight, 14.0) * 0.38;
|
|
57
|
+
rgb = baseCol * (0.42 + 0.52 * keyLight) + baseCol * fresnel * 0.75 + vec3(spec);
|
|
58
|
+
alpha = (0.34 + 0.62 * fresnel + 0.14 * z) * v_color.a;
|
|
59
|
+
} else {
|
|
60
|
+
float haloFalloff = exp(-(d - 1.0) * 8.5);
|
|
61
|
+
float gateBreath = 0.55 + 0.45 * sin(u_timeSec * 3.14159);
|
|
62
|
+
float haloBoost = 0.22 + gate * 0.62 * gateBreath + pulse * 0.35 + fail * 0.45;
|
|
63
|
+
rgb = mix(baseCol, u_gateRgb, gate * 0.8);
|
|
64
|
+
alpha = haloFalloff * haloBoost * v_color.a;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (pulse > 0.01) {
|
|
68
|
+
float ringRadius = mix(0.24, 1.26, 1.0 - pulse);
|
|
69
|
+
float ring = exp(-abs(d - ringRadius) * 18.0) * pulse;
|
|
70
|
+
rgb += baseCol * ring * 0.85;
|
|
71
|
+
alpha = min(1.0, alpha + ring * 0.55 * v_color.a);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
alpha = clamp(alpha, 0.0, 1.0);
|
|
75
|
+
fragColor = vec4(rgb * alpha, alpha);
|
|
76
|
+
}
|
|
77
|
+
`,Yn=`#version 300 es
|
|
78
|
+
precision highp float;
|
|
79
|
+
|
|
80
|
+
layout(location = 0) in vec3 a_pos;
|
|
81
|
+
layout(location = 1) in vec4 a_color;
|
|
82
|
+
|
|
83
|
+
uniform mat4 u_viewProj;
|
|
84
|
+
|
|
85
|
+
out vec4 v_color;
|
|
86
|
+
|
|
87
|
+
void main() {
|
|
88
|
+
v_color = a_color;
|
|
89
|
+
gl_Position = u_viewProj * vec4(a_pos, 1.0);
|
|
90
|
+
}
|
|
91
|
+
`,Jn=`#version 300 es
|
|
92
|
+
precision highp float;
|
|
93
|
+
|
|
94
|
+
in vec4 v_color;
|
|
95
|
+
out vec4 fragColor;
|
|
96
|
+
|
|
97
|
+
void main() {
|
|
98
|
+
float a = clamp(v_color.a, 0.0, 1.0);
|
|
99
|
+
fragColor = vec4(v_color.rgb * a, a);
|
|
100
|
+
}
|
|
101
|
+
`;function Yt(e,t,o){let n=e.createShader(t);if(!n)throw new Error("Failed to allocate WebGL2 shader.");if(e.shaderSource(n,o),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){let r=e.getShaderInfoLog(n)??"unknown shader compile error";throw e.deleteShader(n),new Error(`XR shader compilation failed: ${r}`)}return n}function Jt(e,t,o){let n=Yt(e,e.VERTEX_SHADER,t),r=Yt(e,e.FRAGMENT_SHADER,o),l=e.createProgram();if(!l)throw e.deleteShader(n),e.deleteShader(r),new Error("Failed to allocate WebGL2 program.");if(e.attachShader(l,n),e.attachShader(l,r),e.linkProgram(l),e.deleteShader(n),e.deleteShader(r),!e.getProgramParameter(l,e.LINK_STATUS)){let s=e.getProgramInfoLog(l)??"unknown program link error";throw e.deleteProgram(l),new Error(`XR program link failed: ${s}`)}return l}function Zn(){return typeof OffscreenCanvas=="function"?new OffscreenCanvas(2,2).getContext("webgl2",{alpha:!0,antialias:!0,depth:!0,premultipliedAlpha:!0,powerPreference:"low-power",xrCompatible:!0}):null}function Qn(e){let t=globalThis;return typeof t.XRRigidTransform!="function"?null:new t.XRRigidTransform(e)}function eo(e,t){let o=globalThis;if(typeof o.XRWebGLLayer!="function")throw new Error("XRWebGLLayer is unavailable in this runtime.");return new o.XRWebGLLayer(e,t,{alpha:!0})}function Zt({xr:e=null,audio:t,controllerInput:o,getWorldFrame:n,createGlContext:r=Zn,createXrLayer:l=eo,createRigidTransform:s=Qn,onSessionModeChange:p}){let m=Kt(),a=new Float32Array(16),c=[],i=null,f=null,h=0,v=!1,y=!1,w=null;function g(){if(w!==null)return w;let u=r();if(!u)return null;let b=Jt(u,Kn,Xn),I=Jt(u,Yn,Jn),O=new Float32Array([-1.35,-1.35,1.35,-1.35,-1.35,1.35,1.35,1.35]),k=u.createVertexArray(),d=u.createBuffer(),R=u.createBuffer();u.bindVertexArray(k),u.bindBuffer(u.ARRAY_BUFFER,d),u.bufferData(u.ARRAY_BUFFER,O,u.STATIC_DRAW),u.enableVertexAttribArray(0),u.vertexAttribPointer(0,2,u.FLOAT,!1,8,0);let M=Ie*4;u.bindBuffer(u.ARRAY_BUFFER,R),u.bufferData(u.ARRAY_BUFFER,M*32,u.DYNAMIC_DRAW),u.enableVertexAttribArray(1),u.vertexAttribPointer(1,4,u.FLOAT,!1,M,0),u.vertexAttribDivisor(1,1),u.enableVertexAttribArray(2),u.vertexAttribPointer(2,4,u.FLOAT,!1,M,16),u.vertexAttribDivisor(2,1),u.enableVertexAttribArray(3),u.vertexAttribPointer(3,3,u.FLOAT,!1,M,32),u.vertexAttribDivisor(3,1);let _=u.createVertexArray(),T=u.createBuffer(),N=xe*4;return u.bindVertexArray(_),u.bindBuffer(u.ARRAY_BUFFER,T),u.bufferData(u.ARRAY_BUFFER,N*64,u.DYNAMIC_DRAW),u.enableVertexAttribArray(0),u.vertexAttribPointer(0,3,u.FLOAT,!1,N,0),u.enableVertexAttribArray(1),u.vertexAttribPointer(1,4,u.FLOAT,!1,N,12),u.bindVertexArray(null),w={gl:u,orbProgram:b,orbVao:k,orbInstanceBuf:R,orbUniforms:{viewProj:u.getUniformLocation(b,"u_viewProj"),camRight:u.getUniformLocation(b,"u_camRight"),camUp:u.getUniformLocation(b,"u_camUp"),timeSec:u.getUniformLocation(b,"u_timeSec"),gateRgb:u.getUniformLocation(b,"u_gateRgb"),failRgb:u.getUniformLocation(b,"u_failRgb")},lineProgram:I,lineVao:_,lineBuf:T,lineViewProj:u.getUniformLocation(I,"u_viewProj")},w}function A(u){if(!(!i||u.length===0))for(let b of u)c.push(b)}async function x(u){if(y||v||!e||typeof e.requestSession!="function")return!1;if(i){if(f===u)return!0;await E()}let b=g();if(!b)return!1;v=!0;try{let I=b.gl;typeof I.makeXRCompatible=="function"&&await I.makeXRCompatible();let O=await e.requestSession(u,{optionalFeatures:["local-floor","bounded-floor"]}),k=l(O,b.gl);O.updateRenderState({baseLayer:k});let d=await O.requestReferenceSpace("local-floor").catch(async()=>{let T=await O.requestReferenceSpace("local"),N=s({x:0,y:-de,z:0});return N!=null&&T!==null&&typeof T=="object"&&typeof T.getOffsetReferenceSpace=="function"?T.getOffsetReferenceSpace(N):T});i=O,f=u,c=[],m.reset(),o.reset(),p?.(u);let R=-1,M=()=>{i===O&&(i=null,f=null,h=0,c=[],o.reset(),p?.(null))};O.onend=M;let _=(T,N)=>{if(i!==O||y)return;h=O.requestAnimationFrame(_);let F=R<0?0:Math.min(.25,Math.max(0,(T-R)/1e3));R=T;let C=Date.now(),j=n(C),q=o.update({session:O,frame:N,refSpace:d,worldFrame:j,dtSec:F});(q.layoutMutated||q.visibilityMutated)&&(j=n(C),t.syncFrame(j,[],C));let W=N.getViewerPose(d);if(!W)return;t.setListenerPose(Vt(W.transform.matrix));let K=c;c=[];let B=m.step({frame:j,cues:K,dtSec:F,timeSec:T/1e3,hoveredNodeId:q.hoveredNodeId,grabbedNodeId:q.grabbedNodeId,pointerRay:q.pointerRay}),{gl:z}=b,ie=O.renderState?.baseLayer??k;if(z.bindFramebuffer(z.FRAMEBUFFER,ie.framebuffer),u==="immersive-ar"?z.clearColor(0,0,0,0):z.clearColor(.02,.031,.027,1),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),B.orbCount===0&&B.lineVertexCount===0)return;z.enable(z.BLEND),z.blendFunc(z.ONE,z.ONE_MINUS_SRC_ALPHA),z.enable(z.DEPTH_TEST),z.depthMask(!1),B.lineVertexCount>0&&(z.bindBuffer(z.ARRAY_BUFFER,b.lineBuf),z.bufferData(z.ARRAY_BUFFER,B.lineData,z.DYNAMIC_DRAW)),B.orbCount>0&&(z.bindBuffer(z.ARRAY_BUFFER,b.orbInstanceBuf),z.bufferData(z.ARRAY_BUFFER,B.orbData,z.DYNAMIC_DRAW));let L=re.gate.rgb,G=re.failed.rgb;for(let H of W.views){let X=ie.getViewport(H);if(X&&(z.viewport(X.x,X.y,X.width,X.height),Ut(a,H.projectionMatrix,H.transform.inverse.matrix),B.lineVertexCount>0&&(z.useProgram(b.lineProgram),z.uniformMatrix4fv(b.lineViewProj,!1,a),z.bindVertexArray(b.lineVao),z.drawArrays(z.LINES,0,B.lineVertexCount)),B.orbCount>0)){let Y=Wt(H.transform.matrix);z.useProgram(b.orbProgram),z.uniformMatrix4fv(b.orbUniforms.viewProj,!1,a),z.uniform3f(b.orbUniforms.camRight,Y.right.x,Y.right.y,Y.right.z),z.uniform3f(b.orbUniforms.camUp,Y.up.x,Y.up.y,Y.up.z),z.uniform1f(b.orbUniforms.timeSec,T/1e3),z.uniform3f(b.orbUniforms.gateRgb,L[0],L[1],L[2]),z.uniform3f(b.orbUniforms.failRgb,G[0],G[1],G[2]),z.bindVertexArray(b.orbVao),z.drawArraysInstanced(z.TRIANGLE_STRIP,0,4,B.orbCount)}}z.bindVertexArray(null),z.depthMask(!0)};return h=O.requestAnimationFrame(_),!0}catch{return!1}finally{v=!1}}async function E(){let u=i;u&&(h&&(u.cancelAnimationFrame?.(h),h=0),i=null,f=null,o.reset(),p?.(null),await u.end().catch(()=>{}))}async function S(){y=!0,await E()}return{get activeMode(){return f},notifyCues:A,enterSession:x,exitSession:E,dispose:S}}var to=3e4;var lt=(e,t=Math.random)=>{let o=Math.min(to,1e3*2**e);return o/2+t()*(o/2)};var no=1e4,je=class e{#e=null;#t=!1;#c="";#r=null;#l=0;#n=null;#o=null;#i=null;#f=null;#s=[];constructor(t,{types:o=[],headers:n,onMessage:r,onError:l,onDown:s,onUp:p,signal:m}={}){if(m?.aborted){this.#t=!0;return}if(m&&(this.#f=Q.target(m,"abort",()=>this.close(),{once:!0})),n===void 0){this.#e=new EventSource(t),this.#e.onopen=()=>p?.(),this.#e.onerror=f=>{l?.(f),s?.(f)};let i=f=>r?.(f.type,e.#a(f.data),f.lastEventId);this.#e.onmessage=i;for(let f of o)this.#e.addEventListener(f,i);return}let a=new Set(o),c=()=>{this.#t||this.#o===null||(clearTimeout(this.#o),this.#o=null,this.#u(t,{typeSet:a,headers:n,onMessage:r,onError:l,onDown:s,onUp:p}))};typeof window<"u"&&window?.addEventListener&&this.#s.push(Q.target(window,"online",c)),typeof document<"u"&&document?.addEventListener&&this.#s.push(Q.target(document,"visibilitychange",()=>{document.visibilityState==="visible"&&c()})),this.#u(t,{typeSet:a,headers:n,onMessage:r,onError:l,onDown:s,onUp:p})}close(){if(!this.#t){this.#t=!0,clearTimeout(this.#n),this.#n=null,clearTimeout(this.#o),this.#o=null,this.#f?.(),this.#f=null;for(let t of this.#s)t();this.#s=[],this.#i?.abort(),this.#i=null,this.#e?.close(),this.#e=null}}#u(t,o){if(this.#t)return;this.#i?.abort();let n=new AbortController;this.#i=n,this.#m(t,o,n.signal)}async#m(t,{typeSet:o,headers:n,onMessage:r,onError:l,onDown:s,onUp:p},m){let a=null;try{let c=typeof n=="function"?await n(m):n;if(this.#t||m.aborted)return;let i=new Headers(c??void 0);i.has("accept")||i.set("accept","text/event-stream"),this.#c&&!i.has("last-event-id")&&i.set("last-event-id",this.#c);let f=await fetch(t,{headers:i,cache:"no-store",signal:m});if(this.#t||m.aborted)return;if(f.status===204){this.close(),s?.();return}if(f.status!==200){let S=f.status===408||f.status===429||f.status>=500,u=Object.assign(new Error(`otm sse: HTTP ${f.status}${f.statusText?` ${f.statusText}`:""}`),{status:f.status,response:f});S||this.close(),l?.(u),s?.(u),S&&this.#p(t,{typeSet:o,headers:n,onMessage:r,onError:l,onDown:s,onUp:p});return}let h=f.headers.get("content-type")?.split(";")[0].trim().toLowerCase();if(h!=="text/event-stream"||!f.body){let S=Object.assign(new Error(`otm sse: expected text/event-stream, got ${h||"none"}`),{status:f.status,response:f,protocolFailure:!0});this.close(),l?.(S),s?.(S);return}this.#n=setTimeout(()=>{this.#l=0},no),p?.(),a=f.body.getReader();let v=new TextDecoder("utf-8"),y="",w=!0,g="message",A=[],x=!1,E=S=>{if(S===""){if(x){let O=A.join(`
|
|
102
|
+
`),k=g||"message";A=[],x=!1,g="message",(k==="message"||o.has(k))&&r?.(k,e.#a(O),this.#c)}else g="message";return}if(S.startsWith(":"))return;let u=S.indexOf(":"),b=S,I="";u!==-1&&(b=S.slice(0,u),I=S.slice(u+1),I.startsWith(" ")&&(I=I.slice(1))),b==="event"?g=I:b==="data"?(A.push(I),x=!0):b==="id"?I.includes("\0")||(this.#c=I):b==="retry"&&/^\d+$/.test(I)&&(this.#r=Number(I))};for(;;){let{value:S,done:u}=await a.read();if(u)break;let b=v.decode(S,{stream:!0});w&&(w=!1,b.startsWith("\uFEFF")&&(b=b.slice(1))),y+=b;let I=y.split(/\r\n|\r|\n/);y=I.pop()??"";for(let O of I)if(E(O),this.#t||m.aborted)return}if(y+=v.decode(),this.#t||m.aborted)return;clearTimeout(this.#n),this.#n=null,s?.(),this.#p(t,{typeSet:o,headers:n,onMessage:r,onError:l,onDown:s,onUp:p})}catch(c){if(clearTimeout(this.#n),this.#n=null,this.#t||m.aborted)return;l?.(c),s?.(c),this.#p(t,{typeSet:o,headers:n,onMessage:r,onError:l,onDown:s,onUp:p})}finally{await a?.cancel().catch(()=>{})}}#p(t,o){if(this.#t)return;this.#l+=1;let n=this.#r!==null?this.#r:lt(this.#l);clearTimeout(this.#o),this.#o=setTimeout(()=>{this.#o=null,this.#u(t,o)},n)}static#a(t){try{return JSON.parse(t)}catch{return t}}};var Qt=(e,t)=>new je(e,t);function en({notificationsUrl:e,onConnectionChange:t,onUpdate:o}){let n=Le(),r="connecting",l=null,s=!1,p=!1,m=h=>{s||r===h||(r=h,t?.(h))},a=()=>{if(l?.close(),l=null,s)return;m("connecting");let h=Qt(e,{types:[...Je],headers:v=>Rt(e,v),onUp:()=>{s||l!==h||(p=!1,m("connected"))},onMessage:(v,y)=>{if(s||l!==h)return;if(!$(y)||typeof y.event!="string"||!$(y.data)){h.close(),m("disconnected");return}if(y.event==="service/hibernating"){h.close(),l=null,m("disconnected");return}let w=Nt(n,y);if(n=w.state,w.resyncRequired){a();return}o?.(w)},onError:v=>{if(s||l!==h)return;let y=Reflect.get(Object(v),"status");if(y===401||y===403){if(h.close(),y===401&&!p){p=!0,Mt(e).then(w=>{s||l!==h||(w?a():m("signed-out"))});return}m("signed-out");return}m("disconnected")},onDown:v=>{if(s||l!==h)return;let y=Reflect.get(Object(v),"status");m(r==="signed-out"||y===401||y===403?"signed-out":"disconnected")}});l=h},c=Ot(()=>{s||(p=!1,a())}),i=typeof window<"u"&&typeof window.addEventListener=="function"?Z.target(window,"pagehide",()=>{s||(l?.close(),l=null,m("disconnected"))}):()=>{},f=typeof window<"u"&&typeof window.addEventListener=="function"?Z.target(window,"pageshow",h=>{s||h.persisted&&a()}):()=>{};return t?.(r),a(),{get state(){return n},get connection(){return r},dispose(){s||(s=!0,c(),i(),f(),l?.close(),l=null)}}}var on="plurnk-xr:layout";function tn(e){return e==="passive"||e==="off"?e:"on"}function oo(e){let t=Number(e);return Number.isFinite(t)?Math.min(1,Math.max(0,t/100)):.35}function so(){try{let e=typeof window<"u"?window.localStorage?.getItem(on):null;return e?JSON.parse(e):null}catch{return null}}function nn(e){try{typeof window<"u"&&window.localStorage?.setItem(on,JSON.stringify(e))}catch{}}async function ro(e){let t=ae("html"),o=tn(U("visibility")),n=oo(U("gain")??"35");await U.boot({namespace:"plurnk-xr",persistKeys:["audio-muted","visibility"]}),U("audio-muted")===null&&U("audio-muted","false");let r=U("audio-muted")==="true",l=qt({...e.createAudioContext?{createAudioContext:e.createAudioContext}:{},initialGain:n,initialMuted:r}),s=tn(U("visibility")??o);U("visibility",s);let p=Number(t?.getAttribute("data-callout-ms")??""),m=e.calloutMs??(Number.isFinite(p)&&p>=1e3?p:8e3),a=jt({calloutMs:m,initialVisibility:s}),c=so();c!==null&&a.importLayout(c);let i=Le(),f=Xt({topology:a,audio:l,onVisibilityChange:u=>{U("visibility",u)},onMuteChange:u=>{U("audio-muted",u?"true":"false")},onLayoutCommit:()=>{nn(a.exportLayout())}}),h=Zt({xr:e.xr??null,audio:l,controllerInput:f,getWorldFrame:u=>a.project(i,u),...e.createGlContext?{createGlContext:e.createGlContext}:{},...e.createXrLayer?{createXrLayer:e.createXrLayer}:{},onSessionModeChange:u=>{U("xr-session",u?"active":"idle")}}),v=(u=[])=>{let b=Date.now();u.length>0&&(a.ingestCues(u,b),h.notifyCues(u));let I=a.project(i,b);return l.syncFrame(I,u,b),e.onWorldFrame?.(I,u),I};v();let y=ae('[data-xr-mode="immersive-vr"]'),w=ae('[data-xr-mode="immersive-ar"]'),g=e.notificationsUrl??t?.getAttribute("data-notifications-url")??"/notifications",A=Z("main","click",'[data-action="enter-xr"]',(u,b)=>{let I=b.getAttribute("data-xr-mode");(I==="immersive-vr"||I==="immersive-ar")&&(l.unlock(),e.onEnterXr?.(I),h.enterSession(I))}),x=Z("main","click",'[data-action="sign-in"]',u=>{u.preventDefault(),Tt(g,{returnTo:"/xr/"})}),E=e.connectWatch===!1?null:en({notificationsUrl:g,onConnectionChange:u=>{U("connection",u)},onUpdate:u=>{i=u.state,v(u.cues)}}),S=await Gt(e);return U("xr-posture",S.posture),y&&(y.disabled=!S.vrSupported),w&&(w.disabled=!S.arSupported),{posture:S.posture,capabilities:S,topology:a,audio:l,controllerInput:f,renderer:h,saveLayout(){nn(a.exportLayout())},applyEnvelope(u){return i=u.state,v(u.cues)},dispose(){E?.dispose(),h.dispose(),l.dispose(),A(),x()}}}if(typeof window<"u"&&ae("#xr-airlock")!==null){let e=window.navigator;ro({isSecureContext:window.isSecureContext,xr:e.xr??null})}export{ro as bootLaunchShell};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@layer schema,scheme,structure,style,state;@layer schema,scheme,structure,style,state;@layer schema{:root{color-scheme:light dark;interpolate-size:allow-keywords;--otm-font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;--otm-font-family-monospace: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;--otm-font-size: 100%;--otm-line-height: 1.5;--otm-font-weight: 400;--otm-spacing: 1rem;--otm-border-radius: .375rem;--otm-border-width: .0625rem;--otm-outline-width: .125rem;--otm-transition: .18s ease;--otm-container-max-width: 68rem;--otm-form-element-spacing-block: .625rem;--otm-form-element-spacing-inline: .875rem;--otm-primary: light-dark(#0172ad, #01aaff);--otm-primary-background: light-dark(#0172ad, #0172ad);--otm-primary-inverse: light-dark(#fff, #fff);--otm-primary-hover: color-mix( in oklch, var(--otm-primary) 82%, CanvasText );--otm-primary-hover-background: color-mix( in oklch, var(--otm-primary-background) 85%, CanvasText );--otm-primary-underline: color-mix( in oklch, var(--otm-primary) 50%, transparent );--otm-primary-focus: color-mix( in oklch, var(--otm-primary) 35%, transparent );--otm-text-selection-color: color-mix( in oklch, var(--otm-primary) 24%, transparent );--otm-background-color: light-dark(#fff, #13171f);--otm-color: light-dark(#373c44, #c2c7d0);--otm-heading-color: light-dark(#23272f, #eef0f4);--otm-muted-color: light-dark(#646b79, #8891a4);--otm-muted-border-color: light-dark(#e7eaf0, #232a36);--otm-card-background-color: light-dark(#fff, #181c25);--otm-card-sectioning-background-color: light-dark(#fbfcfc, #1c212c);--otm-card-box-shadow: 0 1px 2px color-mix(in oklch, CanvasText 6%, transparent), 0 8px 24px color-mix(in oklch, CanvasText 8%, transparent);--otm-code-background-color: light-dark(#f3f5f7, #1c212c);--otm-table-row-stripped-background-color: color-mix( in oklch, var(--otm-muted-color) 6%, transparent );--otm-mark-background-color: light-dark(#fde7c0, #014063);--otm-mark-color: light-dark(#0f1114, #fff);--otm-ins-color: light-dark(#1d6a54, #62af9a);--otm-del-color: light-dark(#b4342d, #e07a74);--otm-invalid-color: light-dark(#c53030, #e07070);--otm-valid-color: light-dark(#248265, #38b28b);--otm-modal-overlay-background-color: color-mix( in oklch, var(--otm-background-color) 72%, transparent );--otm-form-element-background-color: light-dark(#fbfcfc, #1c212c);--otm-form-element-active-background-color: light-dark(#fff, #181c25);--otm-form-element-border-color: light-dark(#cfd5e2, #2d3545);--otm-form-element-color: light-dark(#23262c, #e6e9ef);--otm-switch-background-color: light-dark(#bfc7d9, #333c4e);--otm-secondary: var(--otm-form-element-color);--otm-secondary-background: var(--otm-code-background-color);--otm-secondary-border: var(--otm-form-element-border-color);--otm-secondary-hover-background: color-mix( in oklch, var(--otm-secondary-background) 88%, var(--otm-color) );--otm-secondary-hover-border: color-mix( in oklch, var(--otm-secondary-border) 75%, var(--otm-color) );--otm-secondary-focus: color-mix( in oklch, var(--otm-muted-color) 35%, transparent );--otm-danger: var(--otm-del-color);--otm-danger-inverse: light-dark(#fff, #0f1114);--otm-danger-background: color-mix( in oklch, var(--otm-danger) 12%, transparent );--otm-danger-hover-background: color-mix( in oklch, var(--otm-danger) 20%, transparent );--otm-danger-border: color-mix( in oklch, var(--otm-danger) 55%, transparent );--otm-danger-focus: color-mix(in oklch, var(--otm-danger) 32%, transparent)}[data-theme=dark],:root:has(>body[data-theme=dark]){color-scheme:dark}[data-theme=light],:root:has(>body[data-theme=light]){color-scheme:light}[data-theme=dark],[data-theme=light]{background-color:var(--otm-background-color);color:var(--otm-color)}*,*:before,*:after{box-sizing:border-box;background-repeat:no-repeat}::selection{background-color:var(--otm-text-selection-color)}html{font-size:var(--otm-font-size);line-height:var(--otm-line-height);font-family:var(--otm-font-family);font-weight:var(--otm-font-weight);text-size-adjust:100%;background-color:var(--otm-background-color);color:var(--otm-color)}body{inline-size:100%;margin:0;background-color:var(--otm-background-color);color:var(--otm-color)}body>header,body>main,body>footer{inline-size:100%;max-inline-size:var(--otm-container-max-width);margin-inline:auto;padding-block:var(--otm-spacing);padding-inline:var(--otm-spacing)}section,search{display:block;margin-block-end:calc(var(--otm-spacing) * 2)}article{margin-block-end:var(--otm-spacing);padding-block:var(--otm-spacing);padding-inline:var(--otm-spacing);border:var(--otm-border-width) solid var(--otm-muted-border-color);border-radius:var(--otm-border-radius);background-color:var(--otm-card-background-color);box-shadow:var(--otm-card-box-shadow);>header,>footer{margin-inline:calc(var(--otm-spacing) * -1);padding-block:calc(var(--otm-spacing) * .66);padding-inline:var(--otm-spacing);background-color:var(--otm-card-sectioning-background-color)}>header{margin-block-start:calc(var(--otm-spacing) * -1);margin-block-end:var(--otm-spacing);border-block-end:var(--otm-border-width) solid var(--otm-muted-border-color);border-start-start-radius:var(--otm-border-radius);border-start-end-radius:var(--otm-border-radius)}>footer{margin-block-start:var(--otm-spacing);margin-block-end:calc(var(--otm-spacing) * -1);border-block-start:var(--otm-border-width) solid var(--otm-muted-border-color);border-end-start-radius:var(--otm-border-radius);border-end-end-radius:var(--otm-border-radius)}}h1,h2,h3,h4,h5,h6{margin-block-start:0;margin-block-end:var(--otm-spacing);color:var(--otm-heading-color);font-weight:700;line-height:1.2;text-wrap:balance;overflow-wrap:break-word}h1{font-size:2rem}h2{font-size:1.625rem}h3{font-size:1.375rem}h4{font-size:1.1875rem}h5{font-size:1.0625rem}h6{font-size:1rem;color:var(--otm-muted-color)}hgroup{margin-block-end:var(--otm-spacing);>*{margin-block:0}>:not(:first-child):last-child{color:var(--otm-muted-color);font-weight:400}}p,ul,ol,menu,dl,table,blockquote,pre,figure{margin-block-start:0;margin-block-end:var(--otm-spacing)}p{text-wrap:pretty;overflow-wrap:break-word}dt{font-weight:600;color:var(--otm-heading-color)}dd{margin-inline-start:0;margin-block-end:calc(var(--otm-spacing) * .5)}a{color:var(--otm-primary);text-decoration:underline;text-decoration-color:var(--otm-primary-underline);text-underline-offset:.125em;transition:color var(--otm-transition),text-decoration-color var(--otm-transition);&:hover,&:active,&:focus-visible{color:var(--otm-primary-hover);text-decoration-color:var(--otm-primary-hover)}&:focus-visible{outline:var(--otm-outline-width) solid var(--otm-primary-focus);outline-offset:.125rem;border-radius:var(--otm-border-radius)}}nav{display:flex;justify-content:space-between;align-items:center;gap:var(--otm-spacing);:where(ol,ul,menu){display:flex;align-items:center;margin:0;padding:0;list-style:none;gap:var(--otm-spacing)}& li{margin:0;padding:0}& a{text-decoration:none;&[aria-current=page],&[aria-current=true]{font-weight:700;text-decoration:underline}}}aside nav{display:block;:where(ol,ul,menu){flex-direction:column;align-items:stretch;gap:calc(var(--otm-spacing) * .5)}}small{font-size:.875em}mark{padding-block:.125rem;padding-inline:.25rem;background-color:var(--otm-mark-background-color);color:var(--otm-mark-color);border-radius:var(--otm-border-radius)}ins{color:var(--otm-ins-color);text-decoration:none}del{color:var(--otm-del-color)}abbr[title]{border-block-end:1px dotted;text-decoration:none;cursor:help}blockquote{margin-inline:0;padding:var(--otm-spacing);border-inline-start:.25rem solid var(--otm-muted-border-color);& footer{margin-block-start:calc(var(--otm-spacing) * .5);color:var(--otm-muted-color)}}hr{block-size:0;margin-block:var(--otm-spacing);border:0;border-block-start:var(--otm-border-width) solid var(--otm-muted-border-color)}img,svg,video,canvas,audio,iframe{max-inline-size:100%;block-size:auto}figure{margin-inline:0;& figcaption{padding-block-start:calc(var(--otm-spacing) * .5);color:var(--otm-muted-color);font-size:.875rem}}code,kbd,pre,samp{font-family:var(--otm-font-family-monospace);font-size:.875em}code,kbd{padding-block:.125rem;padding-inline:.375rem;border-radius:var(--otm-border-radius);background-color:var(--otm-code-background-color);color:var(--otm-muted-color)}kbd{display:inline-block;background-color:var(--otm-color);color:var(--otm-background-color);font-weight:700}pre{overflow-x:auto;padding:var(--otm-spacing);border-radius:var(--otm-border-radius);background-color:var(--otm-code-background-color);>code{display:block;padding:0;background:none;color:inherit}}table{inline-size:100%;border-collapse:collapse;border-spacing:0;text-indent:0}th,td{padding-block:calc(var(--otm-spacing) * .75);padding-inline:var(--otm-spacing);border-block-end:var(--otm-border-width) solid var(--otm-muted-border-color);text-align:start;vertical-align:middle}thead th{border-block-end-width:calc(var(--otm-border-width) * 2);font-weight:700}tbody tr:nth-child(odd){background-color:var(--otm-table-row-stripped-background-color)}button,input:where([type=submit],[type=button],[type=reset]),[role=button]{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;padding-block:var(--otm-form-element-spacing-block);padding-inline:var(--otm-form-element-spacing-inline);border:var(--otm-border-width) solid var(--otm-primary-background);border-radius:var(--otm-border-radius);background-color:var(--otm-primary-background);color:var(--otm-primary-inverse);font-family:inherit;font-size:1rem;font-weight:500;line-height:var(--otm-line-height);text-decoration:none;cursor:pointer;transition:background-color var(--otm-transition),border-color var(--otm-transition),color var(--otm-transition),box-shadow var(--otm-transition);&:hover,&:active{background-color:var(--otm-primary-hover-background);border-color:var(--otm-primary-hover-background);color:var(--otm-primary-inverse)}&:focus-visible{outline:none;box-shadow:0 0 0 var(--otm-outline-width) var(--otm-primary-focus)}}button[type=button],input[type=button]{background-color:var(--otm-secondary-background);border-color:var(--otm-secondary-border);color:var(--otm-secondary);&:hover,&:active{background-color:var(--otm-secondary-hover-background);border-color:var(--otm-secondary-hover-border);color:var(--otm-secondary)}&:focus-visible{box-shadow:0 0 0 var(--otm-outline-width) var(--otm-secondary-focus)}}button[type=reset],input[type=reset]{background-color:transparent;border-color:var(--otm-secondary-border);color:var(--otm-color);&:hover,&:active{background-color:var(--otm-secondary-background);border-color:var(--otm-muted-color);color:var(--otm-color)}&:focus-visible{box-shadow:0 0 0 var(--otm-outline-width) var(--otm-secondary-focus)}}fieldset{margin-block:0 var(--otm-spacing);margin-inline:0;padding:0;border:0}legend{margin-block-end:calc(var(--otm-spacing) * .5);font-weight:600}label{display:block;margin-block-end:calc(var(--otm-spacing) * .375);font-weight:500}input:where(:not([type=checkbox],[type=radio],[type=range],[type=submit],[type=button],[type=reset],[type=file],[type=color])),select,textarea{display:block;inline-size:100%;margin-block-end:var(--otm-spacing);padding-block:var(--otm-form-element-spacing-block);padding-inline:var(--otm-form-element-spacing-inline);border:var(--otm-border-width) solid var(--otm-form-element-border-color);border-radius:var(--otm-border-radius);background-color:var(--otm-form-element-background-color);color:var(--otm-form-element-color);font-family:inherit;font-size:1rem;line-height:var(--otm-line-height);transition:background-color var(--otm-transition),border-color var(--otm-transition),box-shadow var(--otm-transition);&::placeholder{color:var(--otm-muted-color)}&:focus{outline:none;background-color:var(--otm-form-element-active-background-color);border-color:var(--otm-primary-background);box-shadow:0 0 0 var(--otm-outline-width) var(--otm-primary-focus)}}textarea{resize:vertical;min-block-size:5rem}input:where([type=checkbox],[type=radio]){inline-size:1.125rem;block-size:1.125rem;margin-inline-end:.375rem;vertical-align:middle;accent-color:var(--otm-primary-background);cursor:pointer}input[type=checkbox][role=switch]{appearance:none;inline-size:2.25rem;block-size:1.25rem;border-radius:1.25rem;background-color:var(--otm-switch-background-color);position:relative;transition:background-color var(--otm-transition);&:before{content:"";position:absolute;inset-block-start:.125rem;inset-inline-start:.125rem;inline-size:1rem;block-size:1rem;border-radius:50%;background-color:#fff;transition:translate var(--otm-transition)}&:checked{background-color:var(--otm-primary-background);&:before{translate:1rem 0}}}input[type=range]{inline-size:100%;accent-color:var(--otm-primary-background);cursor:pointer}progress,meter{display:block;inline-size:100%;block-size:.5rem;margin-block-end:var(--otm-spacing);border:0;border-radius:var(--otm-border-radius);accent-color:var(--otm-primary-background)}output{display:inline-block;font-variant-numeric:tabular-nums}details{display:block;margin-block-end:var(--otm-spacing);padding-block-end:calc(var(--otm-spacing) * .5);border-block-end:var(--otm-border-width) solid var(--otm-muted-border-color);& summary{font-weight:600;cursor:pointer;list-style-position:inside}&[open]>summary{margin-block-end:calc(var(--otm-spacing) * .5)}}dialog,[popover]{max-inline-size:min(36rem,calc(100vi - 2rem));inline-size:100%;padding:var(--otm-spacing);border:var(--otm-border-width) solid var(--otm-muted-border-color);border-radius:var(--otm-border-radius);background-color:var(--otm-card-background-color);color:var(--otm-color);box-shadow:var(--otm-card-box-shadow);opacity:0;transition:opacity var(--otm-transition),overlay var(--otm-transition) allow-discrete,display var(--otm-transition) allow-discrete;&::backdrop{background-color:var(--otm-modal-overlay-background-color);backdrop-filter:blur(.25rem)}&:popover-open,&[open]{opacity:1;@starting-style{opacity:0}}}dialog:has(>article){padding:0;>article{margin:0;border:0;box-shadow:none}}[aria-invalid=true],:user-invalid{border-color:var(--otm-invalid-color);&:focus{border-color:var(--otm-invalid-color);box-shadow:0 0 0 var(--otm-outline-width) color-mix(in oklch,var(--otm-invalid-color) 30%,transparent)}}[aria-invalid=false]{border-color:var(--otm-valid-color);&:focus{border-color:var(--otm-valid-color);box-shadow:0 0 0 var(--otm-outline-width) color-mix(in oklch,var(--otm-valid-color) 30%,transparent)}}[disabled],[aria-disabled=true]{opacity:.5;cursor:not-allowed;pointer-events:none}[aria-busy=true]{cursor:progress;&:before{content:"";display:inline-block;inline-size:1em;block-size:1em;margin-inline-end:.5em;border:.15em solid currentcolor;border-inline-end-color:transparent;border-radius:50%;vertical-align:-.125em;animation:otm-spin .75s linear infinite}}[hidden]{display:none}@keyframes otm-spin{to{rotate:1turn}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation-duration:.01ms;animation-iteration-count:1;transition-duration:.01ms;scroll-behavior:auto}}}@layer schema,scheme,structure,style,state;@layer scheme{:root{--otm-primary: light-dark(#2e7d32, #55b85a);--otm-primary-background: light-dark(#2e7d32, #2e7d32);--otm-primary-inverse: light-dark(#fff, #fff)}}@layer structure{body{margin:0}body>main{max-inline-size:36rem;margin-inline:auto;padding:3rem 1.5rem}#xr-airlock{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1.5rem;max-inline-size:none;min-block-size:100dvh;padding:2rem 1.25rem;box-sizing:border-box;text-align:center}#xr-mascot{display:block;inline-size:10.5rem;block-size:10.5rem;user-select:none}#xr-entry-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.85rem}#xr-entry-actions>button{inline-size:auto;min-inline-size:8.25rem;margin-block-end:0}#xr-airlock-note{min-block-size:1.4rem;margin-block:0}}@layer style{:root{--otm-font-family: var(--otm-font-family-monospace);--otm-primary: light-dark(#148800, #4eb31b);--otm-primary-hover: light-dark(#106d00, #72cc46);--otm-primary-underline: light-dark(rgb(20 136 0 / 50%), rgb(78 179 27 / 50%));--otm-primary-background: #148800;--otm-primary-hover-background: #106d00;--otm-primary-focus: rgb(20 136 0 / 50%);--otm-primary-inverse: #fff}#xr-mascot{filter:drop-shadow(0 .5rem 1.25rem rgb(0 0 0 / 22%));transition:transform .18s ease,opacity .18s ease}#xr-airlock-note{color:var(--otm-muted-color);font-size:.82rem}}@layer state{[data-posture-key],[data-connection-key],[data-session-key]{display:none}body[data-xr-posture="2d-insecure"] [data-posture-key="2d-insecure"],body[data-xr-posture="2d"] [data-posture-key="2d"],body[data-connection=signed-out] [data-connection-key=signed-out],body[data-xr-session=active] [data-session-key=active]{display:inline}body[data-xr-session=active] [data-posture-key],body[data-xr-session=active] [data-connection-key]{display:none}body[data-xr-session=active] #xr-mascot{transform:scale(1.05)}body[data-visibility=off] #xr-mascot{opacity:.72}body[data-audio-muted=true] #xr-airlock{opacity:.94}}
|
|
1
|
+
@layer schema,scheme,structure,style,state;@layer schema,scheme,structure,style,state;@layer schema{:root{color-scheme:light dark;interpolate-size:allow-keywords;--otm-font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;--otm-font-family-monospace: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;--otm-font-size: 100%;--otm-line-height: 1.5;--otm-font-weight: 400;--otm-spacing: 1rem;--otm-border-radius: .375rem;--otm-border-width: .0625rem;--otm-outline-width: .125rem;--otm-transition: .18s ease;--otm-container-max-width: 68rem;--otm-form-element-spacing-block: .625rem;--otm-form-element-spacing-inline: .875rem;--otm-primary: light-dark(#0172ad, #01aaff);--otm-primary-background: light-dark(#0172ad, #0172ad);--otm-primary-inverse: light-dark(#fff, #fff);--otm-primary-hover: color-mix( in oklch, var(--otm-primary) 82%, CanvasText );--otm-primary-hover-background: color-mix( in oklch, var(--otm-primary-background) 85%, CanvasText );--otm-primary-underline: color-mix( in oklch, var(--otm-primary) 50%, transparent );--otm-primary-focus: color-mix( in oklch, var(--otm-primary) 35%, transparent );--otm-text-selection-color: color-mix( in oklch, var(--otm-primary) 24%, transparent );--otm-background-color: light-dark(#fff, #13171f);--otm-color: light-dark(#373c44, #c2c7d0);--otm-heading-color: light-dark(#23272f, #eef0f4);--otm-muted-color: light-dark(#646b79, #8891a4);--otm-muted-border-color: light-dark(#e7eaf0, #232a36);--otm-card-background-color: light-dark(#fff, #181c25);--otm-card-sectioning-background-color: light-dark(#fbfcfc, #1c212c);--otm-card-box-shadow: 0 1px 2px color-mix(in oklch, CanvasText 6%, transparent), 0 8px 24px color-mix(in oklch, CanvasText 8%, transparent);--otm-code-background-color: light-dark(#f3f5f7, #1c212c);--otm-table-row-stripped-background-color: color-mix( in oklch, var(--otm-muted-color) 6%, transparent );--otm-mark-background-color: light-dark(#fde7c0, #014063);--otm-mark-color: light-dark(#0f1114, #fff);--otm-ins-color: light-dark(#1d6a54, #62af9a);--otm-del-color: light-dark(#b4342d, #e07a74);--otm-invalid-color: light-dark(#c53030, #e07070);--otm-valid-color: light-dark(#248265, #38b28b);--otm-modal-overlay-background-color: color-mix( in oklch, var(--otm-background-color) 72%, transparent );--otm-form-element-background-color: light-dark(#fbfcfc, #1c212c);--otm-form-element-active-background-color: light-dark(#fff, #181c25);--otm-form-element-border-color: light-dark(#cfd5e2, #2d3545);--otm-form-element-color: light-dark(#23262c, #e6e9ef);--otm-switch-background-color: light-dark(#bfc7d9, #333c4e);--otm-secondary: var(--otm-form-element-color);--otm-secondary-background: var(--otm-code-background-color);--otm-secondary-border: var(--otm-form-element-border-color);--otm-secondary-hover-background: color-mix( in oklch, var(--otm-secondary-background) 88%, var(--otm-color) );--otm-secondary-hover-border: color-mix( in oklch, var(--otm-secondary-border) 75%, var(--otm-color) );--otm-secondary-focus: color-mix( in oklch, var(--otm-muted-color) 35%, transparent );--otm-danger: var(--otm-del-color);--otm-danger-inverse: light-dark(#fff, #0f1114);--otm-danger-background: color-mix( in oklch, var(--otm-danger) 12%, transparent );--otm-danger-hover-background: color-mix( in oklch, var(--otm-danger) 20%, transparent );--otm-danger-border: color-mix( in oklch, var(--otm-danger) 55%, transparent );--otm-danger-focus: color-mix(in oklch, var(--otm-danger) 32%, transparent)}[data-theme=dark],:root:has(>body[data-theme=dark]){color-scheme:dark}[data-theme=light],:root:has(>body[data-theme=light]){color-scheme:light}[data-theme=dark],[data-theme=light]{background-color:var(--otm-background-color);color:var(--otm-color)}*,*:before,*:after{box-sizing:border-box;background-repeat:no-repeat}::selection{background-color:var(--otm-text-selection-color)}html{font-size:var(--otm-font-size);line-height:var(--otm-line-height);font-family:var(--otm-font-family);font-weight:var(--otm-font-weight);text-size-adjust:100%;background-color:var(--otm-background-color);color:var(--otm-color)}body{inline-size:100%;margin:0;background-color:var(--otm-background-color);color:var(--otm-color)}body>header,body>main,body>footer{inline-size:100%;max-inline-size:var(--otm-container-max-width);margin-inline:auto;padding-block:var(--otm-spacing);padding-inline:var(--otm-spacing)}section,search{display:block;margin-block-end:calc(var(--otm-spacing) * 2)}article{margin-block-end:var(--otm-spacing);padding-block:var(--otm-spacing);padding-inline:var(--otm-spacing);border:var(--otm-border-width) solid var(--otm-muted-border-color);border-radius:var(--otm-border-radius);background-color:var(--otm-card-background-color);box-shadow:var(--otm-card-box-shadow);>header,>footer{margin-inline:calc(var(--otm-spacing) * -1);padding-block:calc(var(--otm-spacing) * .66);padding-inline:var(--otm-spacing);background-color:var(--otm-card-sectioning-background-color)}>header{margin-block-start:calc(var(--otm-spacing) * -1);margin-block-end:var(--otm-spacing);border-block-end:var(--otm-border-width) solid var(--otm-muted-border-color);border-start-start-radius:var(--otm-border-radius);border-start-end-radius:var(--otm-border-radius)}>footer{margin-block-start:var(--otm-spacing);margin-block-end:calc(var(--otm-spacing) * -1);border-block-start:var(--otm-border-width) solid var(--otm-muted-border-color);border-end-start-radius:var(--otm-border-radius);border-end-end-radius:var(--otm-border-radius)}}h1,h2,h3,h4,h5,h6{margin-block-start:0;margin-block-end:var(--otm-spacing);color:var(--otm-heading-color);font-weight:700;line-height:1.2;text-wrap:balance;overflow-wrap:break-word}h1{font-size:2rem}h2{font-size:1.625rem}h3{font-size:1.375rem}h4{font-size:1.1875rem}h5{font-size:1.0625rem}h6{font-size:1rem;color:var(--otm-muted-color)}hgroup{margin-block-end:var(--otm-spacing);>*{margin-block:0}>:not(:first-child):last-child{color:var(--otm-muted-color);font-weight:400}}p,ul,ol,menu,dl,table,blockquote,pre,figure{margin-block-start:0;margin-block-end:var(--otm-spacing)}p{text-wrap:pretty;overflow-wrap:break-word}dt{font-weight:600;color:var(--otm-heading-color)}dd{margin-inline-start:0;margin-block-end:calc(var(--otm-spacing) * .5)}a{color:var(--otm-primary);text-decoration:underline;text-decoration-color:var(--otm-primary-underline);text-underline-offset:.125em;transition:color var(--otm-transition),text-decoration-color var(--otm-transition);&:hover,&:active,&:focus-visible{color:var(--otm-primary-hover);text-decoration-color:var(--otm-primary-hover)}&:focus-visible{outline:var(--otm-outline-width) solid var(--otm-primary-focus);outline-offset:.125rem;border-radius:var(--otm-border-radius)}}nav{display:flex;justify-content:space-between;align-items:center;gap:var(--otm-spacing);:where(ol,ul,menu){display:flex;align-items:center;margin:0;padding:0;list-style:none;gap:var(--otm-spacing)}& li{margin:0;padding:0}& a{text-decoration:none;&[aria-current=page],&[aria-current=true]{font-weight:700;text-decoration:underline}}}aside nav{display:block;:where(ol,ul,menu){flex-direction:column;align-items:stretch;gap:calc(var(--otm-spacing) * .5)}}small{font-size:.875em}mark{padding-block:.125rem;padding-inline:.25rem;background-color:var(--otm-mark-background-color);color:var(--otm-mark-color);border-radius:var(--otm-border-radius)}ins{color:var(--otm-ins-color);text-decoration:none}del{color:var(--otm-del-color)}abbr[title]{border-block-end:1px dotted;text-decoration:none;cursor:help}blockquote{margin-inline:0;padding:var(--otm-spacing);border-inline-start:.25rem solid var(--otm-muted-border-color);& footer{margin-block-start:calc(var(--otm-spacing) * .5);color:var(--otm-muted-color)}}hr{block-size:0;margin-block:var(--otm-spacing);border:0;border-block-start:var(--otm-border-width) solid var(--otm-muted-border-color)}img,svg,video,canvas,audio,iframe{max-inline-size:100%;block-size:auto}figure{margin-inline:0;& figcaption{padding-block-start:calc(var(--otm-spacing) * .5);color:var(--otm-muted-color);font-size:.875rem}}code,kbd,pre,samp{font-family:var(--otm-font-family-monospace);font-size:.875em}code,kbd{padding-block:.125rem;padding-inline:.375rem;border-radius:var(--otm-border-radius);background-color:var(--otm-code-background-color);color:var(--otm-muted-color)}kbd{display:inline-block;background-color:var(--otm-color);color:var(--otm-background-color);font-weight:700}pre{overflow-x:auto;padding:var(--otm-spacing);border-radius:var(--otm-border-radius);background-color:var(--otm-code-background-color);>code{display:block;padding:0;background:none;color:inherit}}table{inline-size:100%;border-collapse:collapse;border-spacing:0;text-indent:0}th,td{padding-block:calc(var(--otm-spacing) * .75);padding-inline:var(--otm-spacing);border-block-end:var(--otm-border-width) solid var(--otm-muted-border-color);text-align:start;vertical-align:middle}thead th{border-block-end-width:calc(var(--otm-border-width) * 2);font-weight:700}tbody tr:nth-child(odd){background-color:var(--otm-table-row-stripped-background-color)}button,input:where([type=submit],[type=button],[type=reset]),[role=button]{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;padding-block:var(--otm-form-element-spacing-block);padding-inline:var(--otm-form-element-spacing-inline);border:var(--otm-border-width) solid var(--otm-primary-background);border-radius:var(--otm-border-radius);background-color:var(--otm-primary-background);color:var(--otm-primary-inverse);font-family:inherit;font-size:1rem;font-weight:500;line-height:var(--otm-line-height);text-decoration:none;cursor:pointer;transition:background-color var(--otm-transition),border-color var(--otm-transition),color var(--otm-transition),box-shadow var(--otm-transition);&:hover,&:active{background-color:var(--otm-primary-hover-background);border-color:var(--otm-primary-hover-background);color:var(--otm-primary-inverse)}&:focus-visible{outline:none;box-shadow:0 0 0 var(--otm-outline-width) var(--otm-primary-focus)}}button[type=button],input[type=button]{background-color:var(--otm-secondary-background);border-color:var(--otm-secondary-border);color:var(--otm-secondary);&:hover,&:active{background-color:var(--otm-secondary-hover-background);border-color:var(--otm-secondary-hover-border);color:var(--otm-secondary)}&:focus-visible{box-shadow:0 0 0 var(--otm-outline-width) var(--otm-secondary-focus)}}button[type=reset],input[type=reset]{background-color:transparent;border-color:var(--otm-secondary-border);color:var(--otm-color);&:hover,&:active{background-color:var(--otm-secondary-background);border-color:var(--otm-muted-color);color:var(--otm-color)}&:focus-visible{box-shadow:0 0 0 var(--otm-outline-width) var(--otm-secondary-focus)}}form>footer{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:calc(var(--otm-spacing) * .5);margin-block-start:var(--otm-spacing)}fieldset{margin-block:0 var(--otm-spacing);margin-inline:0;padding:0;border:0}legend{margin-block-end:calc(var(--otm-spacing) * .5);font-weight:600}label{display:block;margin-block-end:calc(var(--otm-spacing) * .375);font-weight:500}input:where(:not([type=checkbox],[type=radio],[type=range],[type=submit],[type=button],[type=reset],[type=file],[type=color])),select,textarea{display:block;inline-size:100%;margin-block-end:var(--otm-spacing);padding-block:var(--otm-form-element-spacing-block);padding-inline:var(--otm-form-element-spacing-inline);border:var(--otm-border-width) solid var(--otm-form-element-border-color);border-radius:var(--otm-border-radius);background-color:var(--otm-form-element-background-color);color:var(--otm-form-element-color);font-family:inherit;font-size:1rem;line-height:var(--otm-line-height);transition:background-color var(--otm-transition),border-color var(--otm-transition),box-shadow var(--otm-transition);&::placeholder{color:var(--otm-muted-color)}&:focus{outline:none;background-color:var(--otm-form-element-active-background-color);border-color:var(--otm-primary-background);box-shadow:0 0 0 var(--otm-outline-width) var(--otm-primary-focus)}}textarea{resize:vertical;min-block-size:5rem}input:where([type=checkbox],[type=radio]){inline-size:1.125rem;block-size:1.125rem;margin-inline-end:.375rem;vertical-align:middle;accent-color:var(--otm-primary-background);cursor:pointer}input[type=checkbox][role=switch]{appearance:none;inline-size:2.25rem;block-size:1.25rem;border-radius:1.25rem;background-color:var(--otm-switch-background-color);position:relative;transition:background-color var(--otm-transition);&:before{content:"";position:absolute;inset-block-start:.125rem;inset-inline-start:.125rem;inline-size:1rem;block-size:1rem;border-radius:50%;background-color:#fff;transition:translate var(--otm-transition)}&:checked{background-color:var(--otm-primary-background);&:before{translate:1rem 0}}}input[type=range]{inline-size:100%;accent-color:var(--otm-primary-background);cursor:pointer}progress,meter{display:block;inline-size:100%;block-size:.5rem;margin-block-end:var(--otm-spacing);border:0;border-radius:var(--otm-border-radius);accent-color:var(--otm-primary-background)}output{display:inline-block;font-variant-numeric:tabular-nums}details{display:block;margin-block-end:var(--otm-spacing);padding-block-end:calc(var(--otm-spacing) * .5);border-block-end:var(--otm-border-width) solid var(--otm-muted-border-color);& summary{font-weight:600;cursor:pointer;list-style-position:inside}&[open]>summary{margin-block-end:calc(var(--otm-spacing) * .5)}}dialog,[popover]{max-inline-size:min(36rem,calc(100vi - 2rem));inline-size:100%;padding:var(--otm-spacing);border:var(--otm-border-width) solid var(--otm-muted-border-color);border-radius:var(--otm-border-radius);background-color:var(--otm-card-background-color);color:var(--otm-color);box-shadow:var(--otm-card-box-shadow);opacity:0;transition:opacity var(--otm-transition),overlay var(--otm-transition) allow-discrete,display var(--otm-transition) allow-discrete;&::backdrop{background-color:var(--otm-modal-overlay-background-color);backdrop-filter:blur(.25rem)}&:popover-open,&[open]{opacity:1;@starting-style{opacity:0}}}dialog:has(>article){padding:0;>article{margin:0;border:0;box-shadow:none}}[aria-invalid=true],:user-invalid{border-color:var(--otm-invalid-color);&:focus{border-color:var(--otm-invalid-color);box-shadow:0 0 0 var(--otm-outline-width) color-mix(in oklch,var(--otm-invalid-color) 30%,transparent)}}[aria-invalid=false]{border-color:var(--otm-valid-color);&:focus{border-color:var(--otm-valid-color);box-shadow:0 0 0 var(--otm-outline-width) color-mix(in oklch,var(--otm-valid-color) 30%,transparent)}}[disabled],[aria-disabled=true]{opacity:.5;cursor:not-allowed;pointer-events:none}[aria-busy=true]{cursor:progress;&:before{content:"";display:inline-block;inline-size:1em;block-size:1em;margin-inline-end:.5em;border:.15em solid currentcolor;border-inline-end-color:transparent;border-radius:50%;vertical-align:-.125em;animation:otm-spin .75s linear infinite}}[hidden]{display:none}@keyframes otm-spin{to{rotate:1turn}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation-duration:.01ms;animation-iteration-count:1;transition-duration:.01ms;scroll-behavior:auto}}}@layer schema,scheme,structure,style,state;@layer scheme{:root{--otm-primary: light-dark(#2e7d32, #55b85a);--otm-primary-background: light-dark(#2e7d32, #2e7d32);--otm-primary-inverse: light-dark(#fff, #fff)}}@layer structure{body{margin:0}body>main{max-inline-size:36rem;margin-inline:auto;padding:3rem 1.5rem}#xr-airlock{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1.5rem;max-inline-size:none;min-block-size:100dvh;padding:2rem 1.25rem;box-sizing:border-box;text-align:center}#xr-mascot{display:block;inline-size:10.5rem;block-size:10.5rem;user-select:none}#xr-entry-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.85rem}#xr-entry-actions>button{inline-size:auto;min-inline-size:8.25rem;margin-block-end:0}#xr-airlock-note{min-block-size:1.4rem;margin-block:0}}@layer style{:root{--otm-font-family: var(--otm-font-family-monospace);--otm-primary: light-dark(#148800, #4eb31b);--otm-primary-hover: light-dark(#106d00, #72cc46);--otm-primary-underline: light-dark(rgb(20 136 0 / 50%), rgb(78 179 27 / 50%));--otm-primary-background: #148800;--otm-primary-hover-background: #106d00;--otm-primary-focus: rgb(20 136 0 / 50%);--otm-primary-inverse: #fff}#xr-mascot{filter:drop-shadow(0 .5rem 1.25rem rgb(0 0 0 / 22%));transition:transform .18s ease,opacity .18s ease}#xr-airlock-note{color:var(--otm-muted-color);font-size:.82rem}}@layer state{[data-posture-key],[data-connection-key],[data-session-key]{display:none}body[data-xr-posture="2d-insecure"] [data-posture-key="2d-insecure"],body[data-xr-posture="2d"] [data-posture-key="2d"],body[data-connection=signed-out] [data-connection-key=signed-out],body[data-xr-session=active] [data-session-key=active]{display:inline}body[data-xr-session=active] [data-posture-key],body[data-xr-session=active] [data-connection-key]{display:none}body[data-xr-session=active] #xr-mascot{transform:scale(1.05)}body[data-visibility=off] #xr-mascot{opacity:.72}body[data-audio-muted=true] #xr-airlock{opacity:.94}}
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
on_the_money/src/css/schema.css:
|
|
Binary file
|
|
Binary file
|
package/dist/assets.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
[
|
|
2
2
|
[
|
|
3
|
-
"/xr/assets/app.
|
|
4
|
-
"assets/app.
|
|
3
|
+
"/xr/assets/app.DKS42GZL.js",
|
|
4
|
+
"assets/app.DKS42GZL.js",
|
|
5
5
|
"text/javascript",
|
|
6
6
|
{
|
|
7
|
-
"br": "assets/app.
|
|
8
|
-
"gzip": "assets/app.
|
|
7
|
+
"br": "assets/app.DKS42GZL.js.br",
|
|
8
|
+
"gzip": "assets/app.DKS42GZL.js.gz"
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
[
|
|
12
|
-
"/xr/assets/index.
|
|
13
|
-
"assets/index.
|
|
12
|
+
"/xr/assets/index.2b6e866d.css",
|
|
13
|
+
"assets/index.2b6e866d.css",
|
|
14
14
|
"text/css",
|
|
15
15
|
{
|
|
16
|
-
"br": "assets/index.
|
|
17
|
-
"gzip": "assets/index.
|
|
16
|
+
"br": "assets/index.2b6e866d.css.br",
|
|
17
|
+
"gzip": "assets/index.2b6e866d.css.gz"
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
20
|
[
|
package/dist/index.html
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<meta charset="utf-8">
|
|
3
3
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
4
4
|
<title>Plurnk XR</title>
|
|
5
|
-
<link rel="stylesheet" href="assets/index.
|
|
6
|
-
<script type="module" src="assets/app.
|
|
5
|
+
<link rel="stylesheet" href="assets/index.2b6e866d.css">
|
|
6
|
+
<script type="module" src="assets/app.DKS42GZL.js"></script>
|
|
7
7
|
</head>
|
|
8
8
|
<body data-xr-posture="probing" data-xr-session="idle" data-connection="connecting" data-visibility="on" data-audio-muted="false" data-gain="35">
|
|
9
9
|
<main id="xr-airlock">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-xr",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Optional Plurnk daemon module providing a passive WebXR and spatial-audio peripheral awareness surface at /xr.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "git+https://github.com/plurnk/plurnk-xr.git"
|
|
14
14
|
},
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/plurnk/plurnk
|
|
16
|
+
"url": "https://github.com/plurnk/plurnk/issues"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
@@ -44,24 +44,24 @@
|
|
|
44
44
|
"LICENSE"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@plurnk/plurnk-meta": "^4.
|
|
47
|
+
"@plurnk/plurnk-meta": "^4.3.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@plurnk/plurnk-contracts": "^
|
|
50
|
+
"@plurnk/plurnk-contracts": "^12.2.0",
|
|
51
51
|
"@plurnk/plurnk-modules": "^5.2.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@eslint/js": "10.0.1",
|
|
54
|
+
"@eslint/js": "^10.0.1",
|
|
55
55
|
"@plurnk/plurnk-spec-check": "^0.3.0",
|
|
56
56
|
"@types/node": "^26.6.11",
|
|
57
|
-
"esbuild": "0.28.2",
|
|
58
|
-
"eslint": "10.16.0",
|
|
59
|
-
"eslint-plugin-no-unsanitized": "4.1.5",
|
|
60
|
-
"globals": "17.15.0",
|
|
61
|
-
"linkedom": "0.18.15",
|
|
62
|
-
"on_the_money": "0.
|
|
63
|
-
"stylelint": "18.2.0",
|
|
64
|
-
"stylelint-config-standard": "41.1.0",
|
|
57
|
+
"esbuild": "^0.28.2",
|
|
58
|
+
"eslint": "^10.16.0",
|
|
59
|
+
"eslint-plugin-no-unsanitized": "^4.1.5",
|
|
60
|
+
"globals": "^17.15.0",
|
|
61
|
+
"linkedom": "^0.18.15",
|
|
62
|
+
"on_the_money": "^0.18.0",
|
|
63
|
+
"stylelint": "^18.2.0",
|
|
64
|
+
"stylelint-config-standard": "^41.1.0",
|
|
65
65
|
"typescript": "^7.0.2"
|
|
66
66
|
},
|
|
67
67
|
"allowScripts": {
|
|
@@ -71,13 +71,14 @@
|
|
|
71
71
|
"build:clean": "node -e \"import('node:fs/promises').then((fs) => fs.rm('dist', { recursive: true, force: true }))\"",
|
|
72
72
|
"build:dist": "node scripts/build.mjs",
|
|
73
73
|
"build": "npm run build:clean && npm run build:dist",
|
|
74
|
-
"
|
|
75
|
-
"test:
|
|
74
|
+
"deps:check": "node scripts/deps-check.mjs",
|
|
75
|
+
"test:lint": "plurnk-spec-check && npm run deps:check && tsc && tsc -p tsconfig.browser.json && tsc -p tsconfig.test.json && eslint . && otm-lint --check xr && stylelint 'xr/styles/*.css'",
|
|
76
|
+
"test:unit": "node --env-file=.env.defaults --test --test-timeout=60000 --test-force-exit test/module.test.js test/route-settlement.test.js test/build.test.js test/watch-store.test.js test/topology.test.js test/audio.test.js test/constellation-math.test.js test/xr-input.test.js test/xr-renderer.test.js test/watch-client.test.js test/launch-shell.test.js test/package.test.js",
|
|
76
77
|
"test": "npm run build && npm run test:lint && npm run test:unit",
|
|
77
78
|
"deps:drift": "node scripts/deps-drift.mjs",
|
|
78
79
|
"release:gate": "npm run deps:drift",
|
|
79
80
|
"prepack": "npm run build",
|
|
80
81
|
"prepublishOnly": "npm audit --audit-level=moderate && npm run release:gate && npm test"
|
|
81
82
|
},
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "7ef6f76855af63fc14da32110c2d52fc1ee43814"
|
|
83
84
|
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
var Z=class e{static#e=new WeakMap;static on(t,o,n,i){if(typeof n!="string"||!n.trim()||typeof i!="function")throw new TypeError("on(): expected (parent, event, selector, handler)");let l=typeof t=="string"?document.querySelector(t):t||document.body;if(!l)throw new Error(`on(): parent selector matched nothing: ${t}`);let s=e.#e.get(l);s||(s=new Map,e.#e.set(l,s));let f=s.get(o);if(!f){let a=new Set,c=r=>{let p=r.target,g=p&&typeof p.closest=="function"?p:p?.parentElement||null;if(g)for(let I of[...a]){if(!a.has(I))continue;let b=g.closest(I.selector);b&&l.contains(b)&&I.fn.call(b,r,b)}};f={dispatch:c,entries:a},s.set(o,f),l.addEventListener(o,c)}let m={selector:n,fn:i};return f.entries.add(m),()=>{f.entries.delete(m),f.entries.size===0&&s.get(o)===f&&(l.removeEventListener(o,f.dispatch),s.delete(o),s.size===0&&e.#e.delete(l))}}static target(t,o,n,i={}){if(!t||typeof t.addEventListener!="function"||typeof Element<"u"&&t instanceof Element)throw new TypeError("on.target(): expected a non-Element EventTarget; use delegated on(parent, event, selector, handler) for DOM elements");if(typeof o!="string"||!o.trim()||typeof n!="function"||i===null||typeof i!="object")throw new TypeError("on.target(): expected (target, event, handler, options?)");let{signal:l,...s}=i;if(l?.aborted)return()=>{};let f=Object.keys(s).length>0,m=s.capture?{capture:!0}:void 0,a,c=s.once&&l?r=>{l.removeEventListener("abort",a),n.call(t,r)}:n;return a=()=>{t.removeEventListener(o,c,m),l?.removeEventListener("abort",a)},f?t.addEventListener(o,c,s):t.addEventListener(o,c),l?.addEventListener("abort",a,{once:!0}),a}static emit(t,o,n){let i=typeof t=="string"?document.querySelector(t):t,l=new CustomEvent(o,{bubbles:!0,cancelable:!0,detail:n});i.dispatchEvent(l)}};var de=class{static validate(t){let o=n=>n!==null&&typeof n=="object"&&!Array.isArray(n);if(!o(t))throw new TypeError("i18n dictionary must be an object");for(let[n,i]of Object.entries(t))if(typeof i!="string"&&!(o(i)&&Object.hasOwn(i,"other")&&Object.keys(i).every(l=>["zero","one","two","few","many","other"].includes(l))&&Object.values(i).every(l=>typeof l=="string")))throw new TypeError(`i18n dictionary entry ${JSON.stringify(n)} must be a string or plural-form object of strings with an other form`);return t}};var st=(e,t,o)=>{let n=t.endsWith("[]"),i=t.split(/[[\]]/).filter(Boolean),l=i.find(f=>["__proto__","prototype","constructor"].includes(f));if(l)throw new TypeError(`the.form: unsafe field name ${JSON.stringify(t)} contains forbidden path segment ${JSON.stringify(l)}`);let s=e;for(let f=0;f<i.length;f++){let m=i[f];f===i.length-1?n?(s[m]||=[],s[m].push(o)):s[m]!==void 0?(Array.isArray(s[m])||(s[m]=[s[m]]),s[m].push(o)):s[m]=o:(s[m]=s[m]||{},s=s[m])}};function rt(e,t="-"){if(e===null||typeof e!="object")throw new TypeError("the.flat: input must be an object");let o={},n=(i,l)=>{if(i===null||typeof i!="object"){o[l]=i;return}for(let[s,f]of Object.entries(i))n(f,l?`${l}${t}${s}`:s)};return n(e,""),o}function it(e){let t={},o=e.querySelectorAll("input, select, textarea");for(let n of o){let i=n.name;if(!i||n.disabled)continue;let l=(n.type||"text").toLowerCase();if(l==="submit"||l==="button"||l==="reset"||l==="file"||(l==="checkbox"||l==="radio")&&!(n.checked??n.hasAttribute("checked")))continue;if(n.tagName==="SELECT"&&n.hasAttribute("multiple")){let f="selectedOptions"in n?n.selectedOptions:n.querySelectorAll("option[selected]");for(let m of f)st(t,i,m.value);continue}let s=n.value??n.getAttribute("value")??"";st(t,i,s)}return t}var ne=class e{static compatible(t,o){let n=new Intl.Locale(t).maximize(),i=new Intl.Locale(o).maximize();return n.language===i.language&&n.script===i.script}static chain(t){let o=new Intl.Locale(t).baseName,n=[],i=o;for(;i;){e.compatible(o,i)&&n.push(i);let l=i.lastIndexOf("-");i=l<0?"":i.slice(0,l)}return n}};var Re=null;function at(e,t){let o=t??(typeof window<"u"&&window.location?window.location.pathname:""),n=[],l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,(m,a)=>(n.push(a),"([^/]+)")),s=o.match(new RegExp(`^${l}$`));if(!s)return null;let f={};return n.forEach((m,a)=>{f[m]=decodeURIComponent(s[a+1])}),f}function ct(e,{match:t,initial:o=!0}={}){if(typeof window>"u")return;if(Re)throw new Error("route(): a router is already active \u2014 call its unsubscribe first");let n=window.location.href,i=()=>{n=window.location.href,e(window.location.pathname,window.location.search,window.location.hash)},l=()=>{window.location.href!==n&&i()};Re=i;let s=f=>{if(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||f.button>0)return;let m=f.target.closest("a");if(!m?.getAttribute("href")||m.hasAttribute("data-external")||m.hasAttribute("download")||m.target==="_blank"||t&&!m.matches(t))return;let a=new URL(m.getAttribute("href"),window.location.href);a.origin===window.location.origin&&(a.pathname===window.location.pathname&&a.search===window.location.search&&a.hash||(f.preventDefault(),a.href!==window.location.href&&(window.history.pushState({},"",a.href),i())))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",l),document.addEventListener("click",s),o&&i(),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",l),document.removeEventListener("click",s),Re=null}}function lt(e,{replace:t=!1}={}){if(typeof window>"u")return;if(!Re)throw new Error("route.go(): no active router \u2014 call route() first");let o=new URL(e,window.location.href);o.href!==window.location.href&&(t?window.history.replaceState({},"",o.href):window.history.pushState({},"",o.href),Re())}var V=class e{static#e=[{dictionary:{},locale:null}];static#t=new WeakMap;static locale=typeof navigator<"u"?navigator.language:"en";static prefix="otm:";static persistKeys=new Set;static get dictionary(){return e.#e[0].dictionary}static set dictionary(t){e.#e=[{dictionary:de.validate(t),locale:null}]}static#c=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;static#r(t){if(typeof t!="string"||!e.#c.test(t))throw new TypeError(`the(${JSON.stringify(t)}): state keys must be canonical kebab-case (e.g. "model-offline")`);return t}static the(...t){if(t.length===0)throw new TypeError("the(): missing args");return t[0]instanceof Element?e.#l(t[0],t.slice(1)):e.#l(document.body,t)}static#l(t,o){let[n,i]=o,l=t===document.body;if(o.length===1&&typeof n=="string")return e.#p(t,e.#r(n));if(o.length===2&&typeof n=="string"){if(typeof i>"u")throw new TypeError(`the(${JSON.stringify(n)}, undefined): val is required for set`);return e.#u(t,l,n,i),t}if(o.length===1&&n?.constructor===Object){for(let[s,f]of Object.entries(n))e.#u(t,l,s,f);return t}throw new TypeError(`the(): unrecognized call shape (${o.map(s=>typeof s).join(", ")})`)}static match=at;static flat=rt;static form=it;static route=ct;static go=lt;static _t(t,o={}){return(typeof Node<"u"?t instanceof Node:t?.nodeType)?(e.#n(t),t):t?e.#i(t,o)?.text??t:(e.#n(document.documentElement),"")}static#n(t,o=!1){let n=t.querySelectorAll?[t,...t.querySelectorAll("[data-i18n]")]:[t];for(let i of n)if(i.hasAttribute?.("data-i18n")){let l=i.getAttribute("data-i18n"),s={};for(let c of i.attributes)if(c.name.startsWith("data-i18n-")&&c.name!=="data-i18n-type"){let r=c.name.replace("data-i18n-","");s[r]=c.value}let f=i.getAttribute("data-i18n-type"),m=o?null:e.#i(l,{...s,type:f}),a=e.#t.get(i);m!==null?(a||e.#t.set(i,{text:i.textContent,lang:i.getAttribute("lang")}),e.#a(i,m.text),e.#d(i,"lang",m.locale)):a&&(e.#a(i,a.text),e.#d(i,"lang",a.lang))}}static#o(t){if(!t.currency)throw new TypeError('_t: type "currency" requires an explicit currency (options.currency or data-i18n-currency)');return t.currency}static#i(t,o){let n=e.#e.find(({dictionary:m})=>Object.hasOwn(m,t)),i=n?.dictionary[t],l=n?.locale??e.locale,s=ne.compatible(e.locale,l)?e.locale:l;if(i===void 0){if(o.val!==void 0&&(o.type==="currency"||o.type==="date")){let m=o.type==="currency"?new Intl.NumberFormat(e.locale,{style:"currency",currency:e.#o(o)}):new Intl.DateTimeFormat(e.locale);return{text:o.type==="date"?m.format(new Date(o.val)):m.format(Number(o.val)),locale:e.locale}}return null}if(typeof i=="object"){let m=o.qty!==void 0?Number(o.qty):0,a=new Intl.PluralRules(l).select(m);i=i[a]??i.other??t}if(typeof i!="string")throw new TypeError(`Invalid i18n dictionary entry ${JSON.stringify(t)}`);let f=i;for(let[m,a]of Object.entries(o)){let c=a;if(m==="val"&&o.type){let r=Number(a),p=o.type==="currency"?new Intl.NumberFormat(s,{style:"currency",currency:e.#o(o)}):o.type==="date"?new Intl.DateTimeFormat(s):new Intl.NumberFormat(s);c=o.type==="date"?p.format(new Date(a)):p.format(r)}f=f.replaceAll(`{${m}}`,()=>c)}return{text:f,locale:l}}static#f={expanded:"aria-expanded",selected:"aria-selected",checked:"aria-checked",disabled:"aria-disabled"};static#s(t,o){return t===document.body?`data-${o}`:e.#f[o]||`data-${o}`}static#u(t,o,n,i){let l=e.#r(n);if(i===null){e.#w(t,l),o&&e.persistKeys.has(l)&&localStorage.removeItem(`${e.prefix}${l}`);return}let s=e.#m(l,i);e.#h(t,l,s),o&&e.persistKeys.has(l)&&localStorage.setItem(`${e.prefix}${l}`,s)}static#m(t,o){if(typeof o=="string")return o;if(typeof o=="boolean")return o?"true":"false";if(typeof o=="number"&&Number.isFinite(o))return String(o);throw new TypeError(`the(${JSON.stringify(t)}, ...): state value must be a string, finite number, boolean, or null`)}static#p(t,o){return t.getAttribute(e.#s(t,o))}static#a(t,o){t.textContent!==o&&(t.textContent=o)}static#d(t,o,n){t.getAttribute(o)!==n&&(n===null?t.removeAttribute(o):t.setAttribute(o,n))}static#h(t,o,n){e.#d(t,e.#s(t,o),n),e.#g(t,o,n,!1)}static#w(t,o){e.#d(t,e.#s(t,o),null),e.#g(t,o,"",!0)}static#g(t,o,n,i){let l=t===document.body,s=l&&typeof document<"u"?document.documentElement||document:t;if(s.querySelectorAll)for(let f of s.querySelectorAll(`[data-text="${o}"],[data-bind*="${o}"]`)){if(!l){let m=f.closest?.("[data-otm-scope]");if(m&&m!==t&&t.contains(m))continue}f.getAttribute("data-text")===o&&e.#a(f,n),e.#y(f,o,n,i)}t.getAttribute?.("data-text")===o&&e.#a(t,n),e.#y(t,o,n,i)}static#y(t,o,n,i){let l=t.getAttribute?.("data-bind");if(l)for(let s of l.split(/\s+/)){let f=s.indexOf(":");if(f<1||s.slice(f+1)!==o)continue;let m=s.slice(0,f);e.#d(t,m,i?null:n)}}static async boot({signal:t,locales:o,dictionary:n,namespace:i,locale:l,defaultLocale:s,persistKeys:f}={}){i&&(e.prefix=`${i}:`),f&&(e.persistKeys=new Set(f.map(y=>e.#r(y))));let m=typeof window<"u"&&window.location?window.location.search:"",a=new URLSearchParams(m),c=document.documentElement.lang||(typeof navigator<"u"?navigator.language:null)||"en",r=new Intl.Locale(l||a.get("lang")||e.persistKeys.has("lang")&&localStorage.getItem(`${e.prefix}lang`)||c).toString(),p=s||document.documentElement.lang,g=p?new Intl.Locale(p).baseName:null;s&&e.#d(document.documentElement,"lang",new Intl.Locale(s).toString());let I=[];if(n!==void 0)I.push({dictionary:de.validate(n),locale:r});else{let y=document.querySelector('meta[name="i18n"]'),h=o||y?.getAttribute("content");if(h){let A=y?.getAttribute("data-fallback")||g||"en",x=new Map((y?.getAttribute("data-available")||"").split(",").map(u=>u.trim()).filter(Boolean).map(u=>[new Intl.Locale(u).baseName,u])),E=ne.chain(r);g&&ne.compatible(r,g)&&E.push(g);let S=new Set([...E,...ne.chain(A),...g?[g]:[]]);for(let u of S){if(u===g&&!x.has(u))break;let w=x.get(u)??(x.size===0&&u===new Intl.Locale(A).baseName?A:null);if(w){try{let k=await fetch(`${h}/${w}.json`,{signal:t});if(!k.ok)throw new Error(`HTTP ${k.status} for ${w}.json`);I.push({dictionary:de.validate(await k.json()),locale:u})}catch(k){if(t?.aborted)throw k;console.warn(`otm: i18n fetch failed for "${u}"`,k)}if(u===g)break}}}}let b=I[0]?.locale??g??r;e.locale=ne.compatible(r,b)?r:b,e.#e=I.length?I:[{dictionary:{},locale:null}];for(let y of e.persistKeys){if(y==="lang")continue;let h=localStorage.getItem(`${e.prefix}${y}`);h!==null&&e.#h(document.body,y,h)}e.#n(document.documentElement,g!==null&&I.length===0)}};var Jt=/^data-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,oe=class e{static $(t,o){let n=t,i=o;return typeof n=="string"&&(i=n,n=document),n.querySelector(i)}static $$(t,o){let n=t,i=o;return typeof n=="string"&&(i=n,n=document),Array.from(n.querySelectorAll(i))}static clone(t,o,{position:n="beforeend"}={}){let i=typeof t=="string"?document.querySelector(t):t,l=document.querySelector(o);if(!i)throw new Error(`Parent not found: ${t}`);if(!l)throw new Error(`Template not found: ${o}`);let s=l.content.cloneNode(!0).firstElementChild;V._t(s),i.insertAdjacentElement(n,s);let f=new CustomEvent("mounted",{bubbles:!0,detail:{parent:i}});return s.dispatchEvent(f),s}static cloneEach(t,o,n,i){let l=typeof t=="string"?document.querySelector(t):t;if(!l)throw new Error(`Parent not found: ${t}`);l.replaceChildren();let s=[],f=0;for(let m of n){let a=e.clone(l,o);i?.(a,m,f++),s.push(a)}return s}static reconcile(t,o,n,{key:i,fill:l,attr:s="data-otm-key"}={}){let f=typeof t=="string"?document.querySelector(t):t;if(!f)throw new Error(`Parent not found: ${t}`);if(typeof i!="function")throw new TypeError("$.reconcile(): options.key must be a function");if(typeof s!="string"||!Jt.test(s))throw new TypeError(`$.reconcile(): options.attr must be a canonical data-* attribute, got ${JSON.stringify(s)}`);let m=[],a=new Set,c=0;for(let A of n){let x=i(A,c);if(x==null||String(x)==="")throw new TypeError("$.reconcile(): key() must return a non-empty key");let E=String(x);if(a.has(E))throw new RangeError(`$.reconcile(): duplicate key ${JSON.stringify(E)}`);a.add(E),m.push({key:E,item:A,index:c++})}let r=new Map;for(let A of Array.from(f.children)){let x=A.getAttribute(s);x!==null&&!r.has(x)&&r.set(x,A)}let p=[],g=new Set;for(let A of m){let x=r.get(A.key);x||(x=e.clone(f,o),x.setAttribute(s,A.key)),g.add(x),p.push({...A,el:x})}let I=typeof document<"u"?document.activeElement:null,b=I&&f.contains(I)&&typeof I.focus=="function"?I:null;for(let A of Array.from(f.children))g.has(A)||A.remove();let y=typeof f.moveBefore=="function"?(A,x)=>f.moveBefore(A,x):(A,x)=>f.insertBefore(A,x);for(let A=0;A<p.length;A++){let{el:x}=p[A],E=f.children[A]??null;E!==x&&y(x,E)}b&&f.contains(b)&&document.activeElement!==b&&b.focus({preventScroll:!0});let h=[];for(let{el:A,item:x,index:E}of p)l?.(A,x,E),h.push(A);return h}};var Q=Z.on;Q.emit=Z.emit;Q.target=Z.target;var U=V.the,Zt=V._t,ut=V.route;ut.go=V.go;U.t=Zt;U.route=ut;U.form=V.form;U.flat=V.flat;U.match=V.match;U.boot=V.boot;Object.defineProperty(U,"dictionary",{get:()=>V.dictionary,set:e=>{V.dictionary=e}});Object.defineProperty(U,"locale",{get:()=>V.locale,set:e=>{V.locale=e}});var ae=oe.$;ae.clone=oe.clone;ae.cloneEach=oe.cloneEach;ae.reconcile=oe.reconcile;var mo=oe.$$;var fe="plurnk_oidc_grant",ft="plurnk_oidc_pkce",Qt="plurnk:oauth:refresh:",pt=1e3,en="plurnk-web",tn=Object.freeze(["openid","profile","email"]),De=new Set,Fe=new Map,Me=null,dt=!1,se=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ge(e){try{return typeof window<"u"?window[e]??null:null}catch{return null}}function mt(){if(Me!==null)return Me;if(typeof window>"u"||typeof BroadcastChannel!="function")return null;try{let e=new BroadcastChannel(fe);"unref"in e&&typeof e.unref=="function"&&e.unref(),Q.target(e,"message",()=>{Le(!1)}),Me=e}catch{Me=null}return Me}function nn(){dt||typeof window>"u"||typeof window.addEventListener!="function"||(dt=!0,Q.target(window,"storage",e=>{let t=e.key;(t==null||t===fe)&&Le(!1)}))}function Le(e){if(e){let t=mt();try{t?.postMessage("grant-changed")}catch{}}for(let t of De)t()}function on(){try{let e=typeof navigator<"u"?navigator.locks:void 0;return se(e)&&typeof e.request=="function"?e:null}catch{return null}}function sn(e){let t=typeof e.access_token=="string"&&e.access_token.trim()!==""?e.access_token.trim():null,o=typeof e.id_token=="string"&&e.id_token.trim()!==""?e.id_token.trim():null;return t!==null&&(t.split(".").length===3||o===null)?t:o}function rn(e){let t=e.split(".");if(t.length!==3||t[1]==="")return null;try{let o=t[1].replaceAll("-","+").replaceAll("_","/"),n=o+"=".repeat((4-o.length%4)%4),i=atob(n),l=new Uint8Array(i.length);for(let f=0;f<i.length;f+=1)l[f]=i.charCodeAt(f);let s=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l));return!se(s)||typeof s.exp!="number"||!Number.isFinite(s.exp)||s.exp<=0?null:Math.floor(s.exp*1e3)}catch{return null}}function an(e,t){let o=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN;if(Number.isFinite(o)&&o>0)return Date.now()+Math.floor(o*1e3);let n=rn(t);return n!==null?n:void 0}function qe(e){let t=ge("localStorage")?.getItem(fe)??null;if(t===null)return null;try{let o=JSON.parse(t);return!se(o)||typeof o.acpOrigin!="string"||typeof o.accessToken!="string"||o.acpOrigin!==e||o.accessToken.trim()===""?null:{acpOrigin:o.acpOrigin,accessToken:o.accessToken,...typeof o.issuer=="string"?{issuer:o.issuer}:{},...typeof o.clientId=="string"?{clientId:o.clientId}:{},...typeof o.tokenEndpoint=="string"?{tokenEndpoint:o.tokenEndpoint}:{},...typeof o.refreshToken=="string"?{refreshToken:o.refreshToken}:{},...typeof o.expiresAt=="number"&&Number.isFinite(o.expiresAt)?{expiresAt:o.expiresAt}:{}}}catch{return null}}function ht(){let e=ge("localStorage"),t=e?.getItem(fe)!==null;try{e?.removeItem(fe),ge("sessionStorage")?.removeItem(ft)}catch{}t&&Le(!0)}function cn(e){try{ge("localStorage")?.setItem(fe,JSON.stringify(e))}catch{}Le(!0)}async function gt(e,t){if(!e.refreshToken||!e.tokenEndpoint||!e.clientId)return null;let o=e.refreshToken,n=e.accessToken,i=e.acpOrigin,l=`${i}:${o}`,s=Fe.get(l);if(s)return await s;let f=async()=>{let a=qe(i);if(a!==null){let r=a.accessToken!==n||a.refreshToken!==o,p=a.expiresAt===void 0||Date.now()+pt<a.expiresAt;if(r&&p)return a}if(a===null&&(ge("localStorage")?.getItem(fe)??null)===null)return null;let c=a??e;if(!c.refreshToken||!c.tokenEndpoint||!c.clientId)return null;try{let r=new URLSearchParams({grant_type:"refresh_token",refresh_token:c.refreshToken,client_id:c.clientId}),p=await fetch(c.tokenEndpoint,{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:r,cache:"no-store",signal:t});if(!p.ok)return(p.status===400||p.status===401)&&ht(),null;let g=await p.json();if(!se(g))return null;let I=sn(g);if(I===null)return null;let b=an(g.expires_in,I),y=typeof g.refresh_token=="string"&&g.refresh_token.trim()!==""?g.refresh_token.trim():c.refreshToken,h={...c,accessToken:I,...y?{refreshToken:y}:{},...b!==void 0?{expiresAt:b}:{}};return cn(h),h}catch{return null}},m=(async()=>{try{let a=on();return a!==null?await a.request(`${Qt}${i}`,f):await f()}finally{Fe.delete(l)}})();return Fe.set(l,m),await m}function Ge(e){let t=typeof window<"u"?window.location.origin:"http://127.0.0.1:1066";return new URL(e,t).origin}async function yt(e,t){t?.throwIfAborted();let o=Ge(e),n=qe(o);if(!n)return{};if(!(typeof n.expiresAt=="number"&&Date.now()+pt>=n.expiresAt))return{Authorization:`Bearer ${n.accessToken}`};if(!n.refreshToken)return ht(),{};let l=await gt(n,t);return t?.throwIfAborted(),l?{Authorization:`Bearer ${l.accessToken}`}:{}}async function wt(e){let t=Ge(e),o=qe(t);return o?await gt(o)!==null:!1}function $e(e){let t="";for(let o of e)t+=String.fromCharCode(o);return btoa(t).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function Be(e){try{let t=new URL(e);return t.username!==""||t.password!==""?!1:t.protocol==="https:"?!0:t.protocol==="http:"&&(t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="::1"||t.hostname==="[::1]")}catch{return!1}}async function bt(e,t={}){let{returnTo:o="/xr/",fetchImpl:n=globalThis.fetch,navigate:i=f=>{typeof window<"u"&&window.location.assign(f)}}=t,l=Ge(e),s=typeof window<"u"?window.location.origin:l;try{let f=await n(`${l}/.well-known/oauth-protected-resource`,{headers:{accept:"application/json"},cache:"no-store"});if(f.ok){let m=await f.json(),c=(se(m)&&Array.isArray(m.authorization_servers)?m.authorization_servers.filter(r=>typeof r=="string"&&Be(r)):[])[0];if(typeof c=="string"){let r=new URL(c),p=r.pathname.replace(/\/+$/u,""),g=p===""?[`${r.origin}/.well-known/oauth-authorization-server`,`${r.origin}/.well-known/openid-configuration`]:[`${r.origin}/.well-known/oauth-authorization-server${p}`,`${r.origin}${p}/.well-known/openid-configuration`];for(let I of g){let b=await n(I,{headers:{accept:"application/json"},cache:"no-store"});if(!b.ok)continue;let y=await b.json();if(!se(y)||typeof y.issuer!="string"||y.issuer.replace(/\/+$/u,"")!==c.replace(/\/+$/u,"")||typeof y.authorization_endpoint!="string"||typeof y.token_endpoint!="string"||!Be(y.authorization_endpoint)||!Be(y.token_endpoint))continue;let h=new Uint8Array(32);globalThis.crypto.getRandomValues(h);let A=$e(h),x=new Uint8Array(24);globalThis.crypto.getRandomValues(x);let E=$e(x),S=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(A)),u=$e(new Uint8Array(S)),w=se(m)&&typeof m.client_id=="string"&&m.client_id!==""?m.client_id:en,k=se(m)&&typeof m.redirect_uri=="string"&&m.redirect_uri!==""?m.redirect_uri:new URL("/auth/callback",s).href,T=se(m)&&Array.isArray(m.scopes_supported)&&m.scopes_supported.length>0?m.scopes_supported.filter(d=>typeof d=="string"&&d!==""):tn;ge("sessionStorage")?.setItem(ft,JSON.stringify({state:E,verifier:A,returnTo:o,acpOrigin:l,issuer:c,clientId:w,tokenEndpoint:y.token_endpoint,redirectUri:k,createdAt:Date.now()}));let v=new URL(y.authorization_endpoint);return v.searchParams.set("response_type","code"),v.searchParams.set("client_id",w),v.searchParams.set("redirect_uri",k),v.searchParams.set("code_challenge",u),v.searchParams.set("code_challenge_method","S256"),v.searchParams.set("state",E),v.searchParams.set("scope",T.join(" ")),i(v.href),v.href}}}}catch{}return i("/"),"/"}function vt(e){return nn(),mt(),De.add(e),()=>{De.delete(e)}}var ln=Math.PI/180,un=e=>e<=0?0:e>=1?1:e;function He(e){let t=un(e);return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function dn(e,t,o){let n=o*ln,i=t*Math.cos(n),l=t*Math.sin(n),s=e+.3963377774*i+.2158037573*l,f=e-.1055613458*i-.0638541728*l,m=e-.0894841775*i-1.291485548*l,a=s**3,c=f**3,r=m**3,p=4.0767416621*a-3.3077115913*c+.2309699292*r,g=-1.2684380046*a+2.6097574011*c-.3413193965*r,I=-.0041960863*a-.7034186147*c+1.707614701*r;return Object.freeze([Math.round(He(p)*1e4)/1e4,Math.round(He(g)*1e4)/1e4,Math.round(He(I)*1e4)/1e4])}function ee(e,t,o,n,i){return Object.freeze({slot:e,name:t,hueDeg:i,lightness:o,chroma:n,css:`oklch(${o} ${n} ${i})`,rgb:dn(o,n,i)})}var ce=.74,le=.155,It=Object.freeze([ee(0,"teal",ce,le,185),ee(1,"azure",ce,le,245),ee(2,"emerald",ce,le,150),ee(3,"violet",ce,le,295),ee(4,"cyan",ce,le,212),ee(5,"magenta",ce,le,332),ee(6,"mint",ce,le,168),ee(7,"indigo",ce,le,268)]),re=Object.freeze({gate:ee(-1,"amber",.79,.165,75),failed:ee(-2,"crimson",.65,.2,25)});function Ne(e){let t=Number.isFinite(e)&&e>=1?Math.trunc(e)-1:Math.abs(Math.trunc(e||0));return It[t%It.length]}var kt=Object.freeze(["notifications/snapshot","notifications/resync","workspace/created","workspace/renamed","workspace/archived","config/changed","functionality/changed","session/created","session/archived","session/deleted","session/titled","session/policy","session/replied","loop/started","loop/parked","loop/proposal","loop/interaction","loop/gate-settled","loop/terminated","stream/concluded","notice/event"]),fn=96,$=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),We=e=>e==="root"||e==="work"||e==="fork"?e:null,xt=e=>e==="model"||e==="_plurnk"?e:null,P=(e,t)=>`${e}:${t}`,Te=(e,t,o)=>`${e}:${t}:${o}`,J=(e,t)=>`${e}#${t}`,we=e=>e==="running"||e==="queued"||e==="parked";function pn(e){return e===100?"queued":e===102?"running":e===202?"parked":e===499?"cancelled":e>=400?"failed":"completed"}function te(e,t=fn){let o=e.replaceAll(/\s+/gu," ").trim(),n=[...o];return n.length<=t?o:`${n.slice(0,Math.max(1,t-1)).join("")}\u2026`}function At(e){let t=typeof e.op=="string"&&e.op.trim()!==""?e.op.trim():"proposal";if($(e.subject)){if(e.subject.type==="command"&&typeof e.subject.command=="string"){let o=te(e.subject.command);if(o!=="")return`${t}: ${o}`}if(e.subject.type==="tool_call"&&typeof e.subject.title=="string"){let o=te(e.subject.title);if(o!=="")return o}}if($(e.target)){let o=typeof e.target.scheme=="string"?e.target.scheme:"",n=typeof e.target.authority=="string"?e.target.authority:"",i=typeof e.target.pathname=="string"?e.target.pathname:"",l=te(`${o?`${o}://`:""}${n}${i}`);if(l!=="")return`${t} ${l}`}return t}function St(e){if($(e.request)){let t=typeof e.request.toolName=="string"?e.request.toolName.trim():"",o=typeof e.request.message=="string"?te(e.request.message):"";if(t&&o)return`${t}: ${o}`;if(o)return o;if(t)return t}return"awaiting input"}function Ve(e){if(!$(e)||typeof e.id!="number")return null;let t=e.completion===200||e.completion===499?e.completion:void 0,o=typeof e.excerpt=="string"?te(e.excerpt,140):"",n=o!==""&&e.continued===!0&&!o.endsWith("\u2026")?`${o}\u2026`:o;return{id:e.id,...typeof e.coordinate=="string"?{coordinate:e.coordinate}:{},...t!==void 0?{completion:t}:{},...typeof e.at=="number"?{at:e.at}:{},...n!==""?{excerpt:n}:{},...typeof e.continued=="boolean"?{continued:e.continued}:{}}}function ye(e,t,o){let n=0;for(let i of o.values())i.workspaceId===e&&i.sessionId===t&&(n+=1);return n}function Ue(e,t,o){let n=!1,i=new Map(o);for(let[l,s]of o)s.workspaceId===e&&t.has(s.sessionId)&&(i.delete(l),n=!0);return{nextGates:i,removedAny:n}}function je(){return{epoch:null,lastEventId:0,hydrated:!1,omitted:0,nextWorkspaceOrder:0,workspaces:new Map,sessions:new Map,gates:new Map}}function mn(e,t=null){let o=new Map,n=0,i=Array.isArray(e.workspaces)?e.workspaces:[];for(let r of i){if(!$(r)||typeof r.id!="number"||typeof r.name!="string")continue;let p=typeof r.projectRoot=="string"?r.projectRoot:null,g=typeof r.projectLabel=="string"?r.projectLabel:p;o.set(r.id,{id:r.id,name:r.name,projectRoot:p,projectLabel:g,archived:!1,order:n++})}let l=new Map,s=Array.isArray(e.sessions)?e.sessions:[];for(let r of s)$(r)&&typeof r.id=="number"&&typeof r.workspaceId=="number"&&typeof r.name=="string"&&l.set(r.id,{workspaceId:r.workspaceId,name:r.name});let f=new Map,m=Array.isArray(e.proposals)?e.proposals:[];for(let r of m){if(!$(r)||typeof r.logEntryId!="number"||typeof r.sessionId!="number"||$(r.disposition)&&r.disposition.decision!=="review")continue;let p=l.get(r.sessionId),g=p?.workspaceId??t;if(g===null)continue;let I=o.get(g)?.name??String(g),b=typeof r.session=="string"&&r.session!==""?r.session:p?.name??`session-${r.sessionId}`,y=Te("proposal",g,r.logEntryId);f.set(y,{key:y,kind:"proposal",workspaceId:g,sessionId:r.sessionId,itemId:r.logEntryId,address:J(I,b),summary:At(r),...typeof r.op=="string"?{op:r.op}:{},...typeof r.expiresAt=="string"?{expiresAt:r.expiresAt}:{}})}let a=Array.isArray(e.interactions)?e.interactions:[];for(let r of a){if(!$(r)||typeof r.interactionId!="number"||typeof r.sessionId!="number")continue;let p=l.get(r.sessionId),g=p?.workspaceId??t;if(g===null)continue;let I=o.get(g)?.name??String(g),b=p?.name??`session-${r.sessionId}`,y=Te("interaction",g,r.interactionId);f.set(y,{key:y,kind:"interaction",workspaceId:g,sessionId:r.sessionId,itemId:r.interactionId,address:J(I,b),summary:St(r)})}let c=new Map;for(let r of s){if(!$(r)||typeof r.id!="number"||typeof r.workspaceId!="number"||typeof r.name!="string")continue;let p=o.get(r.workspaceId),g=typeof r.workspaceName=="string"?r.workspaceName:p?.name??String(r.workspaceId),I=p?.projectRoot??(typeof r.projectRoot=="string"?r.projectRoot:null),b=p?.projectLabel??(typeof r.projectLabel=="string"?r.projectLabel:I),y=typeof r.parentSessionId=="number"?r.parentSessionId:null,h=y===null?null:typeof r.parentName=="string"?r.parentName:"_plurnk",A=y===null?null:xt(r.parentOrigin)??"_plurnk",x=ye(r.workspaceId,r.id,f),E=typeof r.gates=="number"?r.gates:0,S=typeof r.title=="string"&&r.title.trim()!==""?r.title.trim():void 0,u=typeof r.opening=="string"&&r.opening.trim()!==""?te(r.opening,140):void 0,w=typeof r.persona=="string"?r.persona:void 0;c.set(P(r.workspaceId,r.id),{workspaceId:r.workspaceId,workspaceName:g,projectRoot:I,projectLabel:b,id:r.id,name:r.name,parentSessionId:y,parentName:h,parentOrigin:A,kind:We(r.kind)??(y===null?"root":"work"),lifecycle:typeof r.lifecycle=="string"?r.lifecycle:"idle",gates:Math.max(E,x),archived:!1,...u!==void 0?{opening:u}:{},...S!==void 0?{title:S}:{},...w!==void 0?{persona:w}:{},reply:Ve(r.reply)})}return{epoch:typeof e.epoch=="string"?e.epoch:null,lastEventId:typeof e.latestId=="number"?e.latestId:0,hydrated:!0,omitted:typeof e.omitted=="number"?e.omitted:0,nextWorkspaceOrder:n,workspaces:o,sessions:c,gates:f}}function Et(e,t){if(!$(t)||typeof t.event!="string"||!$(t.data))return{state:e,changed:!1,resyncRequired:!1,cues:[]};let{event:o,data:n}=t,i=typeof t.id=="number"?t.id:e.lastEventId,l=typeof t.timestamp=="number"?t.timestamp:0,s=typeof t.workspaceId=="number"?t.workspaceId:null;if(o==="notifications/snapshot")return{state:mn(n,s),changed:!0,resyncRequired:!1,cues:[]};if(o==="notifications/resync")return{state:{...e,epoch:typeof n.epoch=="string"?n.epoch:e.epoch,lastEventId:typeof n.latestId=="number"?n.latestId:i},changed:!1,resyncRequired:!0,cues:[]};let f=Math.max(e.lastEventId,i),m=(a=!1)=>({state:{...e,lastEventId:f},changed:!1,resyncRequired:a,cues:[]});switch(o){case"workspace/created":{let a=typeof n.id=="number"?n.id:s,c=typeof n.name=="string"?n.name:null;if(a===null||c===null)return m();let r=e.workspaces.get(a),p=typeof n.projectRoot=="string"?n.projectRoot:null,g=typeof n.projectLabel=="string"?n.projectLabel:p,I=new Map(e.workspaces);return I.set(a,{id:a,name:c,projectRoot:p,projectLabel:g,archived:!1,order:r?.order??e.nextWorkspaceOrder}),{state:{...e,lastEventId:f,nextWorkspaceOrder:r?e.nextWorkspaceOrder:e.nextWorkspaceOrder+1,workspaces:I},changed:!0,resyncRequired:!1,cues:[]}}case"workspace/renamed":{let a=typeof n.id=="number"?n.id:s,c=typeof n.name=="string"?n.name:null;if(a===null||c===null)return m();let r=e.workspaces.get(a),p=new Map(e.workspaces);p.set(a,{id:a,name:c,projectRoot:r?.projectRoot??null,projectLabel:r?.projectLabel??null,archived:r?.archived??!1,order:r?.order??e.nextWorkspaceOrder});let g=new Map(e.sessions),I=new Map;for(let[y,h]of g)h.workspaceId===a&&(I.set(h.id,h.name),h.workspaceName!==c&&g.set(y,{...h,workspaceName:c}));let b=new Map(e.gates);for(let[y,h]of b)if(h.workspaceId===a){let A=I.get(h.sessionId)??h.address.slice(h.address.indexOf("#")+1);b.set(y,{...h,address:J(c,A)})}return{state:{...e,lastEventId:f,nextWorkspaceOrder:r?e.nextWorkspaceOrder:e.nextWorkspaceOrder+1,workspaces:p,sessions:g,gates:b},changed:!0,resyncRequired:!1,cues:[]}}case"workspace/archived":{let a=typeof n.id=="number"?n.id:s;if(a===null)return m();let c=n.archivedAt!==null&&n.archivedAt!==void 0,r=e.workspaces.get(a),p=new Map(e.workspaces);r&&p.set(a,{...r,archived:c});let g=e.sessions,I=e.gates;if(c){let b=new Map(e.sessions),y=new Set;for(let[h,A]of e.sessions)A.workspaceId===a&&(b.delete(h),y.add(A.id));g=b,y.size>0&&(I=Ue(a,y,I).nextGates)}return{state:{...e,lastEventId:f,workspaces:p,sessions:g,gates:I},changed:!!r||g!==e.sessions,resyncRequired:!1,cues:[]}}case"session/created":{let a=typeof n.workspaceId=="number"?n.workspaceId:s,c=typeof n.id=="number"?n.id:typeof t.sessionId=="number"?t.sessionId:null,r=typeof n.name=="string"?n.name:null;if(a===null||c===null||r===null)return{state:{...e,lastEventId:f},changed:!1,resyncRequired:!1,cues:[]};let p=e.workspaces.get(a),g=typeof n.workspaceName=="string"?n.workspaceName:p?.name??String(a),I=typeof n.projectRoot=="string"?n.projectRoot:n.projectRoot===null?null:p?.projectRoot??null,b=typeof n.projectLabel=="string"?n.projectLabel:n.projectLabel===null?null:p?.projectLabel??I,y=new Map(e.workspaces);y.set(a,{id:a,name:g,projectRoot:I,projectLabel:b,archived:!1,order:p?.order??e.nextWorkspaceOrder});let h=p?e.nextWorkspaceOrder:e.nextWorkspaceOrder+1;if(n.origin!=="model")return{state:{...e,lastEventId:f,nextWorkspaceOrder:h,workspaces:y},changed:!p,resyncRequired:!1,cues:[]};let A=P(a,c),x=e.sessions.get(A),E=typeof n.parentSessionId=="number"?n.parentSessionId:null,S=E!==null?e.sessions.get(P(a,E)):void 0,u=E===null?null:S?.name??x?.parentName??"_plurnk",w=E===null?null:S!==void 0?"model":x?.parentOrigin??"_plurnk",k=We(n.kind)??(E===null?"root":"work"),T=ye(a,c,e.gates),v=x?.opening??(k==="fork"?S?.opening:void 0),d=typeof n.persona=="string"?n.persona:x?.persona,_=new Map(e.sessions);_.set(A,{workspaceId:a,workspaceName:g,projectRoot:I,projectLabel:b,id:c,name:r,parentSessionId:E,parentName:u,parentOrigin:w,kind:k,lifecycle:x?.lifecycle&&x.lifecycle!=="idle"?x.lifecycle:typeof n.lifecycle=="string"?n.lifecycle:"idle",gates:T,archived:!1,...v!==void 0?{opening:v}:{},...x?.title!==void 0?{title:x.title}:{},...d!==void 0?{persona:d}:{},reply:x?.reply??null});for(let[M,O]of _)O.workspaceId===a&&O.parentSessionId===c&&(O.parentName!==r||O.parentOrigin!=="model")&&_.set(M,{...O,parentName:r,parentOrigin:"model"});return{state:{...e,lastEventId:f,nextWorkspaceOrder:h,workspaces:y,sessions:_},changed:!0,resyncRequired:!1,cues:[]}}case"session/archived":case"session/deleted":{if(s===null||o==="session/archived"&&(n.archivedAt===null||n.archivedAt===void 0))return m();let a=Array.isArray(n.sessionIds)?n.sessionIds:[],c=new Set;for(let I of a)typeof I=="number"&&c.add(I);let r=new Map(e.sessions),p=!1;for(let I of c)r.delete(P(s,I))&&(p=!0);let g=Ue(s,c,e.gates);return{state:{...e,lastEventId:f,sessions:r,gates:g.nextGates},changed:p||g.removedAny,resyncRequired:!1,cues:[]}}case"session/titled":{if(s===null||typeof n.id!="number"||typeof n.title!="string")return m();let a=P(s,n.id),c=e.sessions.get(a);if(!c)return m(e.omitted>0);let r=n.title.trim();if((c.title??"")===r)return m();let p=new Map(e.sessions);return p.set(a,{...c,title:r}),{state:{...e,lastEventId:f,sessions:p},changed:!0,resyncRequired:!1,cues:[]}}case"session/policy":{if(s===null||typeof n.sessionId!="number"||!("persona"in n))return m();let a=P(s,n.sessionId),c=e.sessions.get(a);if(!c)return m(e.omitted>0);let r=typeof n.persona=="string"?n.persona:void 0;if((c.persona??void 0)===r)return m();let p=new Map(e.sessions),{persona:g,...I}=c;return p.set(a,r!==void 0?{...I,persona:r}:I),{state:{...e,lastEventId:f,sessions:p},changed:!0,resyncRequired:!1,cues:[]}}case"session/replied":{if(s===null||typeof n.sessionId!="number")return m();let a=Ve(n.reply);if(a===null)return m();let c=P(s,n.sessionId),r=e.sessions.get(c);if(!r)return m(e.omitted>0);if(r.reply!==null&&r.reply.id>=a.id)return m();let p=new Map(e.sessions);p.set(c,{...r,reply:a});let g=J(r.workspaceName,r.name),I=a.excerpt?[{kind:"replied",timestamp:l,workspaceId:s,sessionId:r.id,address:g,completion:a.completion??200,excerpt:a.excerpt}]:[];return{state:{...e,lastEventId:f,sessions:p},changed:!0,resyncRequired:!1,cues:I}}case"loop/started":case"loop/parked":{if(s===null||typeof n.sessionId!="number")return m();let a=P(s,n.sessionId),c=e.sessions.get(a),r=o==="loop/started"&&typeof n.opening=="string"&&n.opening.trim()!==""?te(n.opening,140):void 0,p=o==="loop/started"&&$(n.session)?n.session:null;if(p!==null&&typeof p.id=="number"&&typeof p.name=="string"){let x=p.id,E=p.name,S=e.workspaces.get(s),u=S?.name??c?.workspaceName??String(s),w=S?.projectRoot??c?.projectRoot??null,k=S?.projectLabel??c?.projectLabel??w,T=typeof p.parentSessionId=="number"?p.parentSessionId:null,v=T===null?null:typeof p.parentName=="string"?p.parentName:"_plurnk",d=T===null?null:xt(p.parentOrigin)??"_plurnk",_=typeof p.gates=="number"?p.gates:0,M=Math.max(_,ye(s,x,e.gates)),O=typeof p.opening=="string"&&p.opening.trim()!==""?te(p.opening,140):void 0,R=c?.opening??O??r,N=Ve(p.reply),F=c?.reply!==null&&c?.reply!==void 0&&(N===null||c.reply.id>N.id)?c.reply:N,C=typeof p.title=="string"&&p.title.trim()!==""?p.title.trim():c?.title,j=typeof p.persona=="string"&&p.persona!==""?p.persona:p.persona===null?void 0:c?.persona,q=new Map(e.sessions);q.set(a,{workspaceId:s,workspaceName:u,projectRoot:w,projectLabel:k,id:x,name:E,parentSessionId:T,parentName:v,parentOrigin:d,kind:We(p.kind)??(T===null?"root":"work"),lifecycle:"running",gates:M,archived:!1,...R!==void 0?{opening:R}:{},...C!==void 0?{title:C}:{},...j!==void 0?{persona:j}:{},reply:F});let W=!c&&e.omitted>0?e.omitted-1:e.omitted,K=J(u,E);return{state:{...e,lastEventId:f,omitted:W,sessions:q},changed:!0,resyncRequired:!1,cues:[{kind:"activity",timestamp:l,workspaceId:s,sessionId:x,address:K,source:"loop/started",...r!==void 0?{detail:r}:{}}]}}if(!c)return m(e.omitted>0);let g=o==="loop/parked"?"parked":"running",I=c.opening??r,b=new Map(e.sessions),y=c.lifecycle!==g||c.opening!==I;y&&b.set(a,{...c,lifecycle:g,...I!==void 0?{opening:I}:{}});let h=J(c.workspaceName,c.name),A=o==="loop/started"?[{kind:"activity",timestamp:l,workspaceId:s,sessionId:c.id,address:h,source:"loop/started",...r!==void 0?{detail:r}:{}}]:[{kind:"terminated",timestamp:l,workspaceId:s,sessionId:c.id,address:h,status:202,lifecycle:"parked"}];return{state:{...e,lastEventId:f,...y?{sessions:b}:{}},changed:y,resyncRequired:!1,cues:A}}case"loop/proposal":{if(s===null||typeof n.sessionId!="number"||typeof n.logEntryId!="number"||!$(n.disposition)||n.disposition.decision!=="review")return m();let a=P(s,n.sessionId),c=e.sessions.get(a);if(!c&&e.omitted>0)return m(!0);let r=c?.workspaceName??e.workspaces.get(s)?.name??String(s),p=typeof n.session=="string"&&n.session!==""?n.session:c?.name??`session-${n.sessionId}`,g=J(r,p),I=At(n),b=Te("proposal",s,n.logEntryId),y=e.gates.has(b),h=new Map(e.gates);h.set(b,{key:b,kind:"proposal",workspaceId:s,sessionId:n.sessionId,itemId:n.logEntryId,address:g,summary:I,...typeof n.op=="string"?{op:n.op}:{},...typeof n.expiresAt=="string"?{expiresAt:n.expiresAt}:{}});let A=new Map(e.sessions);c&&A.set(a,{...c,lifecycle:"running",gates:ye(s,c.id,h)});let x=y?[]:[{kind:"gate-opened",timestamp:l,workspaceId:s,sessionId:n.sessionId,address:g,gateKey:b,gateKind:"proposal",summary:I}];return{state:{...e,lastEventId:f,gates:h,sessions:A},changed:!0,resyncRequired:!1,cues:x}}case"loop/interaction":{if(s===null||typeof n.sessionId!="number"||typeof n.interactionId!="number")return m();let a=P(s,n.sessionId),c=e.sessions.get(a);if(!c&&e.omitted>0)return m(!0);let r=c?.workspaceName??e.workspaces.get(s)?.name??String(s),p=c?.name??`session-${n.sessionId}`,g=J(r,p),I=St(n),b=Te("interaction",s,n.interactionId),y=e.gates.has(b),h=new Map(e.gates);h.set(b,{key:b,kind:"interaction",workspaceId:s,sessionId:n.sessionId,itemId:n.interactionId,address:g,summary:I});let A=new Map(e.sessions);c&&A.set(a,{...c,lifecycle:"running",gates:ye(s,c.id,h)});let x=y?[]:[{kind:"gate-opened",timestamp:l,workspaceId:s,sessionId:n.sessionId,address:g,gateKey:b,gateKind:"interaction",summary:I}];return{state:{...e,lastEventId:f,gates:h,sessions:A},changed:!0,resyncRequired:!1,cues:x}}case"loop/gate-settled":{if(s===null||typeof n.sessionId!="number")return m();let a=n.kind==="proposal"?"proposal":n.kind==="interaction"?"interaction":null,c=a==="proposal"?typeof n.logEntryId=="number"?n.logEntryId:null:a==="interaction"&&typeof n.interactionId=="number"?n.interactionId:null;if(a===null||c===null)return m();let r=Te(a,s,c),p=e.gates.get(r);if(!p)return m();let g=new Map(e.gates);g.delete(r);let I=P(s,n.sessionId),b=e.sessions.get(I),y=e.sessions;if(b){let A=ye(s,b.id,g);if(b.gates!==A){let x=new Map(e.sessions);x.set(I,{...b,gates:A}),y=x}}let h=a==="proposal"?typeof n.decision=="string"?n.decision:"settled":typeof n.action=="string"?n.action:"settled";return{state:{...e,lastEventId:f,gates:g,sessions:y},changed:!0,resyncRequired:!1,cues:[{kind:"gate-settled",timestamp:l,workspaceId:s,sessionId:n.sessionId,address:p.address,gateKey:r,gateKind:a,resolution:h}]}}case"loop/terminated":{if(s===null||typeof n.sessionId!="number")return m();let a=P(s,n.sessionId),c=e.sessions.get(a);if(!c)return m(e.omitted>0);let r=$(n.result)&&typeof n.result.status=="number"?n.result.status:200,p=pn(r),g=Ue(s,new Set([c.id]),e.gates),I=e.sessions,b=g.removedAny;if(c.lifecycle!==p||c.gates!==0){let h=new Map(e.sessions);h.set(a,{...c,lifecycle:p,gates:0}),I=h,b=!0}let y=J(c.workspaceName,c.name);return{state:{...e,lastEventId:f,gates:g.nextGates,sessions:I},changed:b,resyncRequired:!1,cues:[{kind:"terminated",timestamp:l,workspaceId:s,sessionId:c.id,address:y,status:r,lifecycle:p}]}}case"stream/concluded":{if(s===null||typeof n.sessionId!="number")return m();let a=e.sessions.get(P(s,n.sessionId));if(!a)return m();let c=typeof n.summary=="string"&&n.summary.trim()!==""?te(n.summary):void 0;return{state:{...e,lastEventId:f},changed:!1,resyncRequired:!1,cues:[{kind:"activity",timestamp:l,workspaceId:s,sessionId:a.id,address:J(a.workspaceName,a.name),source:"stream/concluded",...c!==void 0?{detail:c}:{}}]}}case"notice/event":{let a=$(n.notice)?n.notice:null,c=a&&typeof a.message=="string"?te(a.message):"";if(c==="")return m();let r=a&&typeof a.level=="string"?a.level:"info",p=typeof n.sessionId=="number"?n.sessionId:null,g=s!==null&&p!==null?e.sessions.get(P(s,p)):void 0,I=s!==null?e.workspaces.get(s):void 0,b=g?J(g.workspaceName,g.name):I?I.name:null;return{state:{...e,lastEventId:f},changed:!1,resyncRequired:!1,cues:[{kind:"notice",timestamp:l,workspaceId:s,sessionId:p,address:b,level:r,message:c}]}}default:return m()}}var Je=Math.PI/180,ue=1.35,Ke=1.85,Xe=.28,hn=4,Ye=Object.freeze([-38,38,-58,58,-78,78,-98,98,-116,116,-134,134]),be=e=>Math.round(e*1e4)/1e4;function Oe(e,t,o){return Object.freeze({x:be(o*Math.sin(e)),y:be(t),z:be(-o*Math.cos(e))})}function gn(e,t){return e.parentSessionId===null&&e.kind==="root"&&e.lifecycle==="idle"&&e.reply===null&&e.opening===void 0&&e.title===void 0&&e.gates===0&&!t}function yn(e){let t=Math.floor(e/2)+1;return{dAzimuthRad:(e%2===0?1:-1)*t*5.5*Je,dElevationM:e%3===0?.14:e%3===1?-.13:.22,dRadiusM:-.06}}function wn(e){let t=e*2.399963229728653;return{dAzimuthRad:Math.cos(t)*3.2*Je,dElevationM:Math.sin(t)*.11,dRadiusM:-.05}}function Rt({calloutMs:e=8e3,activityHoldMs:t=4e3,initialVisibility:o="on"}={}){let n=o,i=new Map,l=0,s=new Map,f=new Map,m=new Map,a=[],c=1;function r(b){let y=i.get(b);y===void 0&&(y=l++,i.set(b,y));let h=Ye[y%Ye.length],A=Math.floor(y/Ye.length);return{azimuthRad:h*Je,elevationM:ue+A*.28,radiusM:Ke}}function p(b,y){for(let h of b)h.workspaceId!==null&&h.sessionId!==null&&m.set(P(h.workspaceId,h.sessionId),y),h.kind==="replied"?g({tone:"reply",workspaceId:h.workspaceId,sessionKey:P(h.workspaceId,h.sessionId),address:h.address,text:h.excerpt,nowMs:y}):h.kind==="terminated"&&h.status!==202&&h.status!==499?g({tone:h.status>=400?"failed":"completed",workspaceId:h.workspaceId,sessionKey:P(h.workspaceId,h.sessionId),address:h.address,text:h.status>=400?`failed (${h.status})`:"completed",nowMs:y}):h.kind==="notice"&&(h.level==="warning"||h.level==="error")&&g({tone:"notice",workspaceId:h.workspaceId,sessionKey:h.workspaceId!==null&&h.sessionId!==null?P(h.workspaceId,h.sessionId):null,address:h.address??"plurnk",text:h.message,nowMs:y})}function g({tone:b,workspaceId:y,sessionKey:h,address:A,text:x,nowMs:E}){for(;a.length>=hn;)a.shift();a.push({id:`transient:${c++}`,tone:b,workspaceId:y,sessionKey:h,address:A,text:x,expiresAtMs:E+e})}function I(b,y){for(let d=a.length-1;d>=0;d-=1)a[d].expiresAtMs<=y&&a.splice(d,1);let h=[...b.workspaces.values()].filter(d=>!d.archived).toSorted((d,_)=>d.order-_.order||d.id-_.id),A=new Set(h.map(d=>d.id)),x=new Set;for(let d of b.sessions.values())!d.archived&&A.has(d.workspaceId)&&d.parentSessionId!==null&&x.add(P(d.workspaceId,d.parentSessionId));let E=new Map,S=0;for(let d of b.sessions.values()){if(d.archived||!A.has(d.workspaceId))continue;let _=P(d.workspaceId,d.id);if(gn(d,x.has(_)))continue;(we(d.lifecycle)||d.gates>0)&&(S+=1);let M=E.get(d.workspaceId)??[];M.push(d),E.set(d.workspaceId,M)}let u=[],w=new Map,k=new Map;for(let d of h){let _=Ne(d.id),M=s.get(d.name)??r(d.name),O=`workspace:${d.id}`,R=(E.get(d.id)??[]).toSorted((L,G)=>L.id-G.id),N=0,F=!1,C=0;for(let L of R){N+=L.gates,we(L.lifecycle)&&(F=!0);let G=m.get(P(d.id,L.id));G!==void 0&&y-G<t&&(C=Math.max(C,1-(y-G)/t))}let j=N>0||F||C>0,q=n==="off"?0:n==="passive"?j?1:0:j?1:Xe,W=Object.freeze({id:O,kind:"workspace",workspaceId:d.id,workspaceName:d.name,sessionId:null,address:d.name,label:d.name,tetherTo:null,swatch:_,lifecycle:F?"running":"idle",gates:N,azimuthRad:M.azimuthRad,elevationM:M.elevationM,radiusM:M.radiusM,position:Oe(M.azimuthRad,M.elevationM,M.radiusM),targetOpacity:q,pulseStrength:be(C)});u.push(W),k.set(d.id,W);let K=R.filter(L=>L.parentSessionId===null||!R.some(G=>G.id===L.parentSessionId)),D=R.filter(L=>L.parentSessionId!==null&&R.some(G=>G.id===L.parentSessionId)),z=new Set;for(let L of D){let G=P(d.id,L.id),H=m.get(G);(L.gates>0||we(L.lifecycle)||H!==void 0&&y-H<t)&&L.parentSessionId!==null&&z.add(L.parentSessionId)}K.forEach((L,G)=>{let H=J(d.name,L.name),X=f.get(H)??yn(G),Y=M.azimuthRad+X.dAzimuthRad,pe=M.elevationM+X.dElevationM,xe=Math.max(.5,M.radiusM+X.dRadiusM),Ae=P(d.id,L.id),me=m.get(Ae),Se=me!==void 0&&y-me<t?1-(y-me)/t:0,he=L.gates>0||we(L.lifecycle)||Se>0||z.has(L.id),ze=n==="off"?0:n==="passive"?he?1:0:he?1:Xe,Ee=Object.freeze({id:`session:${d.id}:${L.id}`,kind:"session",workspaceId:d.id,workspaceName:d.name,sessionId:L.id,address:H,label:L.title??L.name,tetherTo:O,swatch:_,lifecycle:L.lifecycle,gates:L.gates,azimuthRad:Y,elevationM:pe,radiusM:xe,position:Oe(Y,pe,xe),targetOpacity:ze,pulseStrength:be(Se)});u.push(Ee),w.set(Ae,Ee)});let ie=new Map;for(let L of D){let G=L.parentSessionId,H=w.get(P(d.id,G))??W,X=ie.get(G)??0;ie.set(G,X+1);let Y=J(d.name,L.name),pe=f.get(Y)??wn(X),xe=H.azimuthRad+pe.dAzimuthRad,Ae=H.elevationM+pe.dElevationM,me=Math.max(.5,H.radiusM+pe.dRadiusM),Se=P(d.id,L.id),he=m.get(Se),ze=he!==void 0&&y-he<t?1-(y-he)/t:0,Ee=L.gates>0||we(L.lifecycle)||ze>0,Yt=n==="off"?0:n==="passive"?Ee?1:0:Ee?1:Xe,ot=Object.freeze({id:`session:${d.id}:${L.id}`,kind:"satellite",workspaceId:d.id,workspaceName:d.name,sessionId:L.id,address:Y,label:L.title??L.name,tetherTo:H.id,swatch:_,lifecycle:L.lifecycle,gates:L.gates,azimuthRad:xe,elevationM:Ae,radiusM:me,position:Oe(xe,Ae,me),targetOpacity:Yt,pulseStrength:be(ze)});u.push(ot),w.set(Se,ot)}}let T=[...b.gates.values()].filter(d=>A.has(d.workspaceId)),v=[];if(n!=="off"){for(let d of T){let _=w.get(P(d.workspaceId,d.sessionId))??k.get(d.workspaceId),M=Oe(0,ue,Ke);v.push(Object.freeze({id:`gate:${d.key}`,pinned:!0,tone:"gate",address:d.address,text:d.summary,swatch:re.gate,position:_?.position??M,expiresAtMs:null}))}for(let d of a){let _=(d.sessionKey?w.get(d.sessionKey):void 0)??(d.workspaceId!==null?k.get(d.workspaceId):void 0),M=d.tone==="failed"?re.failed:_?.swatch??re.gate,O=Oe(0,ue,Ke);v.push(Object.freeze({id:d.id,pinned:!1,tone:d.tone,address:d.address,text:d.text,swatch:M,position:_?.position??O,expiresAtMs:d.expiresAtMs}))}}return Object.freeze({visibilityMode:n,nodes:Object.freeze(u),callouts:Object.freeze(v),counts:Object.freeze({workspaces:h.length,activeSessions:S,openGates:T.length})})}return{get visibilityMode(){return n},setVisibilityMode(b){(b==="on"||b==="passive"||b==="off")&&(n=b)},cycleVisibilityMode(){return n=n==="on"?"passive":n==="passive"?"off":"on",n},setWorkspaceAnchor(b,y){s.set(b,{azimuthRad:y.azimuthRad,elevationM:y.elevationM,radiusM:Math.max(.5,y.radiusM)})},setSessionOffset(b,y){f.set(b,{dAzimuthRad:y.dAzimuthRad,dElevationM:y.dElevationM,dRadiusM:y.dRadiusM})},resetLayout(){s.clear(),f.clear()},exportLayout(){return{workspaces:Object.fromEntries(s),sessions:Object.fromEntries(f)}},importLayout(b){if($(b)){if($(b.workspaces))for(let[y,h]of Object.entries(b.workspaces))$(h)&&typeof h.azimuthRad=="number"&&typeof h.elevationM=="number"&&typeof h.radiusM=="number"&&s.set(y,{azimuthRad:h.azimuthRad,elevationM:h.elevationM,radiusM:Math.max(.5,h.radiusM)});if($(b.sessions))for(let[y,h]of Object.entries(b.sessions))$(h)&&typeof h.dAzimuthRad=="number"&&typeof h.dElevationM=="number"&&typeof h.dRadiusM=="number"&&f.set(y,{dAzimuthRad:h.dAzimuthRad,dElevationM:h.dElevationM,dRadiusM:h.dRadiusM})}},ingestCues:p,project:I}}var bn=Object.freeze({x:0,y:ue,z:-1.85}),vn=Object.freeze({position:Object.freeze({x:0,y:ue,z:0}),forward:Object.freeze({x:0,y:0,z:-1}),up:Object.freeze({x:0,y:1,z:0})}),zt=Object.freeze([Object.freeze({slot:0,note:"D3",baseHz:146.83,wave:"sine"}),Object.freeze({slot:1,note:"F#3",baseHz:185,wave:"triangle"}),Object.freeze({slot:2,note:"A3",baseHz:220,wave:"sine"}),Object.freeze({slot:3,note:"B3",baseHz:246.94,wave:"triangle"}),Object.freeze({slot:4,note:"D4",baseHz:293.66,wave:"sine"}),Object.freeze({slot:5,note:"E4",baseHz:329.63,wave:"triangle"}),Object.freeze({slot:6,note:"F#4",baseHz:369.99,wave:"sine"}),Object.freeze({slot:7,note:"A4",baseHz:440,wave:"triangle"})]);function Mt(e){let t=Ne(e);return zt[t.slot]}var Tt=e=>Number.isFinite(e)?e<=0?0:e>=1?1:e:0;function In(){return typeof window<"u"&&typeof window.AudioContext=="function"?new window.AudioContext({latencyHint:"interactive"}):null}function B(e,t,o,n){n&&typeof e.setTargetAtTime=="function"?e.setTargetAtTime(t,o,.03):e.setValueAtTime(t,o),e.value=t}function Lt(e,t,o,n){e.positionX&&e.positionY&&e.positionZ?(B(e.positionX,t.x,o,n),B(e.positionY,t.y,o,n),B(e.positionZ,t.z,o,n)):e.setPosition?.(t.x,t.y,t.z)}function Ot(e,t,o){let{position:n,forward:i,up:l}=t;e.positionX&&e.positionY&&e.positionZ?(B(e.positionX,n.x,o,!1),B(e.positionY,n.y,o,!1),B(e.positionZ,n.z,o,!1)):e.setPosition?.(n.x,n.y,n.z),e.forwardX&&e.forwardY&&e.forwardZ&&e.upX&&e.upY&&e.upZ?(B(e.forwardX,i.x,o,!1),B(e.forwardY,i.y,o,!1),B(e.forwardZ,i.z,o,!1),B(e.upX,l.x,o,!1),B(e.upY,l.y,o,!1),B(e.upZ,l.z,o,!1)):e.setOrientation?.(i.x,i.y,i.z,l.x,l.y,l.z)}function _t(e,t){let o=e.createPanner();return o.panningModel="HRTF",o.distanceModel="inverse",o.refDistance=1.2,o.maxDistance=12,o.rolloffFactor=1,o.coneInnerAngle=360,o.coneOuterAngle=360,o.coneOuterGain=1,Lt(o,t,e.currentTime,!1),o}function kn(e){let t=[],o=new Set;for(let n of e.nodes)n.kind!=="workspace"&&n.gates>0&&(t.push(n),o.add(n.workspaceId));for(let n of e.nodes)n.kind==="workspace"&&n.gates>0&&!o.has(n.workspaceId)&&t.push(n);return t}function xn(e,t,o){if(t!==null){if(o!==null){let n=e.nodes.find(i=>i.workspaceId===t&&i.sessionId===o);if(n)return n}return e.nodes.find(n=>n.kind==="workspace"&&n.workspaceId===t)}}function Nt({createAudioContext:e=In,initialGain:t=.35,initialMuted:o=!1,activityCooldownMs:n=1600,maxTransientVoices:i=6}={}){let l=Tt(t),s=!!o,f=!1,m=vn,a=null,c=null,r=null,p=new Map,g=new Set,I=new Map;function b(){if(!c||!r)return;let w=s?0:l;B(r.gain,w,c.currentTime,!0)}function y(){if(f)return null;if(c!==null)return c;let w=e();if(!w)return null;c=w,r=w.createGain();let k=s?0:l;return B(r.gain,k,w.currentTime,!1),r.connect(w.destination),Ot(w.listener,m,w.currentTime),w}function h(w){for(let k of g)k.endsAtSec<=w&&(k.cleanup(),g.delete(k))}function A(w){for(let k of I.values())k.stop(w);I.clear()}function x(){for(let w of g)w.cleanup();g.clear()}function E(w,k){if(!c||!r||f||s||c.state!=="running"){A(!1);return}let T=c,v=r,d=T.currentTime,_=kn(w),M=new Set(_.map(O=>O.id));for(let[O,R]of I)M.has(O)||(R.stop(!1),I.delete(O));for(let O of _){let R=I.get(O.id);if(R){Lt(R.panner,O.position,d,!0);continue}let N=Mt(O.workspaceId),F=_t(T,O.position),C=T.createBiquadFilter();C.type="lowpass",B(C.frequency,720,d,!1),B(C.Q,.7,d,!1);let j=T.createGain(),q=O.sessionId!==null&&k.has(`${O.workspaceId}:${O.sessionId}`);B(j.gain,1e-4,d,!1),q?(j.gain.linearRampToValueAtTime(.11,d+.03),j.gain.exponentialRampToValueAtTime(.042,d+.32)):j.gain.linearRampToValueAtTime(.042,d+.35);let W=T.createOscillator();W.type="sine",B(W.frequency,N.baseHz,d,!1);let K=T.createOscillator();K.type="sine",B(K.frequency,Math.round(N.baseHz*(4/3)*100)/100,d,!1);let D=T.createOscillator();D.type="sine",B(D.frequency,.25,d,!1);let z=T.createGain();B(z.gain,.016,d,!1),W.connect(C),K.connect(C),C.connect(j),D.connect(z),z.connect(j.gain),j.connect(F),F.connect(v),W.start(d),K.start(d),D.start(d);let ie=!1,L=G=>{if(ie)return;ie=!0;let H=T.currentTime,X=()=>{try{W.disconnect(),K.disconnect(),D.disconnect(),z.disconnect(),C.disconnect(),j.disconnect(),F.disconnect()}catch{}};if(G){try{W.stop(H),K.stop(H),D.stop(H)}catch{}X();return}j.gain.cancelScheduledValues?.(H),j.gain.setValueAtTime(Math.max(1e-4,j.gain.value),H),j.gain.exponentialRampToValueAtTime(1e-4,H+.08);let Y=H+.09;W.onended=X;try{W.stop(Y),K.stop(Y),D.stop(Y)}catch{X()}};I.set(O.id,{nodeId:O.id,panner:F,voiceGain:j,stop:L})}}function S({position:w,wave:k,startHz:T,secondHz:v,stepAtSec:d=.1,peakGain:_,durationSec:M,cutoffHz:O}){if(!c||!r||f||s||c.state!=="running")return;let R=c,N=R.currentTime,F=_t(R,w),C=R.createBiquadFilter();C.type="lowpass",B(C.frequency,O,N,!1),B(C.Q,.7,N,!1);let j=R.createGain();B(j.gain,1e-4,N,!1),j.gain.linearRampToValueAtTime(_,N+.012),j.gain.exponentialRampToValueAtTime(1e-4,N+M);let q=R.createOscillator();q.type=k,B(q.frequency,T,N,!1),v!==void 0&&q.frequency.setValueAtTime(v,N+d),q.connect(C),C.connect(j),j.connect(F),F.connect(r);let W=!1,K=()=>{if(!W){W=!0;try{q.disconnect(),C.disconnect(),j.disconnect(),F.disconnect()}catch{}}},D=N+M+.02,z={endsAtSec:D,cleanup:K};g.add(z),q.onended=()=>{K(),g.delete(z)},q.start(N),q.stop(D)}function u(w,k=[],T=Date.now()){if(a=w,!c||f)return;h(c.currentTime);let v=new Set;for(let d of k)d.kind==="gate-opened"&&v.add(`${d.workspaceId}:${d.sessionId}`);if(E(w,v),!(s||c.state!=="running"))for(let d of k){let _=xn(w,d.workspaceId,d.sessionId),M=_?.position??bn,O=d.workspaceId!==null?Mt(d.workspaceId):zt[0];switch(d.kind){case"activity":{let R=`${d.workspaceId}:${d.sessionId}`,N=p.get(R);if(N!==void 0&&T-N<n||g.size>=i)break;p.set(R,T);let F=_?.kind==="satellite";S({position:M,wave:O.wave,startHz:F?O.baseHz*2:O.baseHz,peakGain:F?.065:.105,durationSec:F?.14:.18,cutoffHz:820});break}case"gate-settled":{let R=d.resolution==="accept"||d.resolution==="submitted"||d.resolution==="settled";S(R?{position:M,wave:"sine",startHz:Math.round(O.baseHz*(4/3)*100)/100,secondHz:Math.round(O.baseHz*1.5*100)/100,stepAtSec:.09,peakGain:.13,durationSec:.28,cutoffHz:1100}:{position:M,wave:"sine",startHz:O.baseHz,secondHz:Math.round(O.baseHz*(8/9)*100)/100,stepAtSec:.08,peakGain:.075,durationSec:.2,cutoffHz:520});break}case"terminated":{d.status===200?S({position:M,wave:O.wave,startHz:O.baseHz,secondHz:Math.round(O.baseHz*1.5*100)/100,stepAtSec:.11,peakGain:.13,durationSec:.32,cutoffHz:1050}):d.status===202?S({position:M,wave:"sine",startHz:Math.round(O.baseHz*1.25*100)/100,secondHz:O.baseHz,stepAtSec:.09,peakGain:.07,durationSec:.22,cutoffHz:680}):d.status===499?S({position:M,wave:"sine",startHz:Math.round(O.baseHz*.75*100)/100,peakGain:.06,durationSec:.15,cutoffHz:420}):d.status>=400&&S({position:M,wave:"triangle",startHz:196,secondHz:130.81,stepAtSec:.12,peakGain:.16,durationSec:.38,cutoffHz:210});break}case"notice":{(d.level==="warning"||d.level==="error")&&S({position:M,wave:"triangle",startHz:220,secondHz:196,stepAtSec:.1,peakGain:.11,durationSec:.26,cutoffHz:540});break}default:break}}}return{get gain(){return l},get muted(){return s},get unlocked(){return c!==null&&c.state==="running"},get activeGateCount(){return I.size},get activeTransientCount(){return c&&h(c.currentTime),g.size},async unlock(){let w=y();return w?(w.state!=="running"&&await w.resume().catch(()=>{}),b(),a&&w.state==="running"&&E(a,new Set),w.state==="running"):!1},setGain(w){l=Tt(w),b()},setMuted(w){let k=!!w;return s===k||(s=k,b(),s?(A(!1),x()):a&&c&&c.state==="running"&&E(a,new Set)),s},toggleMuted(){return this.setMuted(!s)},setListenerPose(w){m=w,c&&!f&&Ot(c.listener,w,c.currentTime)},syncFrame:u,async dispose(){if(f)return;f=!0,A(!0),x();let w=c;c=null,r=null,w&&await w.close().catch(()=>{})}}}async function jt({isSecureContext:e,xr:t=null}){if(!e)return Object.freeze({posture:"2d-insecure",vrSupported:!1,arSupported:!1});if(t!==null&&typeof t=="object"&&typeof t.isSessionSupported=="function"){let[o,n]=await Promise.all([Promise.resolve(t.isSessionSupported("immersive-ar")).then(Boolean,()=>!1),Promise.resolve(t.isSessionSupported("immersive-vr")).then(Boolean,()=>!1)]);return Object.freeze({posture:o?"immersive-ar":n?"immersive-vr":"2d",vrSupported:n,arSupported:o})}return Object.freeze({posture:"2d",vrSupported:!1,arSupported:!1})}var ve=11,Ie=7,Ze=Object.freeze({workspace:.085,session:.052,satellite:.032}),An=1.16,Sn=.18,En=1.4,Ct=.018,Rn=.65;function Qe(e){return e==="workspace"?Ze.workspace:e==="session"?Ze.session:Ze.satellite}function Pt(e,t,o){let n=t[0],i=t[1],l=t[2],s=t[3],f=t[4],m=t[5],a=t[6],c=t[7],r=t[8],p=t[9],g=t[10],I=t[11],b=t[12],y=t[13],h=t[14],A=t[15];for(let x=0;x<4;x+=1){let E=x*4,S=o[E],u=o[E+1],w=o[E+2],k=o[E+3];e[E]=n*S+f*u+r*w+b*k,e[E+1]=i*S+m*u+p*w+y*k,e[E+2]=l*S+a*u+g*w+h*k,e[E+3]=s*S+c*u+I*w+A*k}return e}function ke(e,t,o,n){let i=Math.hypot(e,t,o);return i<1e-6?n:{x:e/i||0,y:t/i||0,z:o/i||0}}function Ft(e){return{right:ke(e[0],e[1],e[2],{x:1,y:0,z:0}),up:ke(e[4],e[5],e[6],{x:0,y:1,z:0})}}function $t(e){return{position:{x:e[12],y:e[13],z:e[14]},forward:ke(-e[8],-e[9],-e[10],{x:0,y:0,z:-1}),up:ke(e[4],e[5],e[6],{x:0,y:1,z:0})}}function Bt(){let e=new Map,t=32,o=new Float32Array(t*ve),n=64,i=new Float32Array(n*Ie);function l(a){if(!(a<=t)){for(;t<a;)t*=2;o=new Float32Array(t*ve)}}function s(a){if(!(a<=n)){for(;n<a;)n*=2;i=new Float32Array(n*Ie)}}function f({frame:a,cues:c=[],dtSec:r,timeSec:p,hoveredNodeId:g=null,grabbedNodeId:I=null,pointerRay:b=null}){let y=Number.isFinite(r)?Math.min(.25,Math.max(0,r)):.016,h=y===0?1:1-Math.exp(-y/Sn),A=y===0?1:Math.exp(-y/En),x=new Set;for(let v of a.nodes){x.add(v.id);let d=v.gates>0?1:0,_=v.position.x,M=v.position.y,O=v.position.z;if(v.kind==="satellite"&&v.lifecycle==="running"&&I!==v.id){let N=p*Rn+(v.sessionId??0)*1.7,F=Math.cos(v.azimuthRad),C=Math.sin(v.azimuthRad),j=Math.cos(N)*Ct,q=Math.sin(N)*Ct;_+=F*j,M+=q,O+=C*j}let R=e.get(v.id);if(!R)e.set(v.id,{kind:v.kind,workspaceId:v.workspaceId,sessionId:v.sessionId,tetherTo:v.tetherTo,lifecycle:v.lifecycle,x:_,y:M,z:O,rgb:v.swatch.rgb,opacity:y===0?v.targetOpacity:v.targetOpacity*h,pulseStrength:v.pulseStrength,gateFactor:y===0?d:d*h,failFactor:0});else{let N=I===v.id?Math.max(h,.65):h;R.kind=v.kind,R.workspaceId=v.workspaceId,R.sessionId=v.sessionId,R.tetherTo=v.tetherTo,R.lifecycle=v.lifecycle,R.rgb=v.swatch.rgb,R.x+=(_-R.x)*N,R.y+=(M-R.y)*N,R.z+=(O-R.z)*N,R.opacity+=(v.targetOpacity-R.opacity)*h,R.pulseStrength=v.pulseStrength,R.gateFactor+=(d-R.gateFactor)*h,R.failFactor*=A}}for(let v of c)if(v.kind==="terminated"&&v.status>=400&&v.status!==499){let d=e.get(`session:${v.workspaceId}:${v.sessionId}`);d&&(d.failFactor=1);let _=e.get(`workspace:${v.workspaceId}`);_&&(_.failFactor=Math.max(_.failFactor,.6))}for(let[v,d]of e)x.has(v)||(d.opacity+=(0-d.opacity)*h,d.gateFactor*=1-h,d.failFactor*=A,d.opacity<.004&&e.delete(v));let E=[];for(let[v,d]of e)d.opacity>.004&&E.push([v,d]);l(E.length);let S=0;for(let[v,d]of E){let _=v===g||v===I,M=Qe(d.kind)*(_?An:1);o[S]=d.x,o[S+1]=d.y,o[S+2]=d.z,o[S+3]=M,o[S+4]=d.rgb[0],o[S+5]=d.rgb[1],o[S+6]=d.rgb[2],o[S+7]=Math.min(1,_?Math.max(d.opacity,.92):d.opacity),o[S+8]=_?Math.max(d.pulseStrength,.35):d.pulseStrength,o[S+9]=d.gateFactor,o[S+10]=d.failFactor,S+=ve}let u=E.length+(b?1:0);s(u*2);let w=0,k=0,T=re.gate.rgb;for(let[,v]of E){if(v.tetherTo===null)continue;let d=e.get(v.tetherTo);if(!d||d.opacity<=.004)continue;let _=Math.min(d.opacity,v.opacity)*.36,M=Math.min(d.opacity,v.opacity)*.58,O=v.rgb[0]+(T[0]-v.rgb[0])*v.gateFactor*.65,R=v.rgb[1]+(T[1]-v.rgb[1])*v.gateFactor*.65,N=v.rgb[2]+(T[2]-v.rgb[2])*v.gateFactor*.65;i[k]=d.x,i[k+1]=d.y,i[k+2]=d.z,i[k+3]=d.rgb[0],i[k+4]=d.rgb[1],i[k+5]=d.rgb[2],i[k+6]=_,i[k+7]=v.x,i[k+8]=v.y,i[k+9]=v.z,i[k+10]=O,i[k+11]=R,i[k+12]=N,i[k+13]=M,k+=Ie*2,w+=2}if(b){let{origin:v,direction:d,lengthM:_,hovered:M}=b,O=v.x+d.x*_,R=v.y+d.y*_,N=v.z+d.z*_,F=M?.45:.65,C=M?.95:.82,j=M?.55:.78;i[k]=v.x,i[k+1]=v.y,i[k+2]=v.z,i[k+3]=F,i[k+4]=C,i[k+5]=j,i[k+6]=M?.42:.22,i[k+7]=O,i[k+8]=R,i[k+9]=N,i[k+10]=F,i[k+11]=C,i[k+12]=j,i[k+13]=M?.78:0,w+=2}return{orbCount:E.length,orbData:o.subarray(0,E.length*ve),lineVertexCount:w,lineData:i.subarray(0,w*Ie)}}function m(){e.clear()}return{step:f,reset:m}}var et=.9,tt=3.2,Mn=.35,Tn=2.65,On=1.65,_n=.055,zn=.18,Ln=1.35,Nn=1.85,Pe=(e,t,o)=>e<t?t:e>o?o:e;function jn(e){let t=e%(Math.PI*2);return t>Math.PI&&(t-=Math.PI*2),t<-Math.PI&&(t+=Math.PI*2),t}function Cn(e){let t=Math.hypot(e.x,e.z),o=Pe(t,et,tt),n=t<1e-5?0:Math.atan2(e.x,-e.z),i=Pe(e.y,Mn,Tn);return{azimuthRad:n,elevationM:i,radiusM:o}}function Pn(e){return{origin:{x:e[12],y:e[13],z:e[14]},direction:ke(-e[8],-e[9],-e[10],{x:0,y:0,z:-1})}}function Fn(e){return e==="satellite"?0:e==="session"?1:2}function $n(e,t){let{origin:o,direction:n}=e,i=null;for(let l of t){if(l.targetOpacity<=.01)continue;let s=Math.max(_n,Qe(l.kind)*On),f=o.x-l.position.x,m=o.y-l.position.y,a=o.z-l.position.z,c=f*n.x+m*n.y+a*n.z,r=f*f+m*m+a*a-s*s,p=c*c-r;if(p<0)continue;let g=Math.sqrt(p),I=-c-g,b=-c+g,y=I>=.05?I:b>=.05?b:-1;if(y<.05||y>5)continue;let h=Math.max(.05,-c),A=Fn(l.kind);(i===null||A<i.tier||A===i.tier&&h<i.distanceM)&&(i={node:l,distanceM:h,tier:A})}return i?{node:i.node,distanceM:i.distanceM}:null}function Ce(e,t,o){try{let n=e.gamepad?.hapticActuators?.[0]?.pulse?.(t,o);n&&typeof n.catch=="function"&&n.catch(()=>{})}catch{}}function Dt({topology:e,audio:t,onVisibilityChange:o,onMuteChange:n,onLayoutCommit:i}){let l=new WeakMap,s=null,f=null;function m(){s!==null&&(s=null,i?.()),f=null}function a({session:c,frame:r,refSpace:p,worldFrame:g,dtSec:I}){if(c.visibilityState!=="visible")return m(),{layoutMutated:!1,visibilityMutated:!1,hoveredNodeId:null,grabbedNodeId:null,pointerRay:null};let b=Number.isFinite(I)?Math.min(.1,Math.max(0,I)):.016,y=!1,h=!1,A=[];for(let u of c.inputSources??[]){if(u.targetRayMode!=="tracked-pointer"||u.hand)continue;let w=l.get(u)??{trigger:!1,primaryFace:!1,secondaryFace:!1},k=u.gamepad?.buttons??[],T=!!k[0]?.pressed,v=!!k[4]?.pressed,d=!!k[5]?.pressed;if(v&&!w.primaryFace){let M=e.cycleVisibilityMode();h=!0,Ce(u,.2,12),o?.(M)}if(d&&!w.secondaryFace){let M=t.toggleMuted();Ce(u,.2,12),n?.(M)}let _=u.targetRaySpace?r.getPose(u.targetRaySpace,p):null;_?.transform?.matrix&&A.push({source:u,ray:Pn(_.transform.matrix)}),s&&s.source===u&&!T&&(s=null,i?.()),l.set(u,{trigger:T,primaryFace:v,secondaryFace:d})}if(s&&!A.some(u=>u.source===s?.source)&&(s=null,i?.()),s){let u=A.find(w=>w.source===s?.source);if(u){let w=u.source.gamepad?.axes?.[3]??0;Math.abs(w)>zn&&(s.grabDistanceM=Pe(s.grabDistanceM-w*Ln*b,et,tt));let k={x:u.ray.origin.x+u.ray.direction.x*s.grabDistanceM,y:u.ray.origin.y+u.ray.direction.y*s.grabDistanceM,z:u.ray.origin.z+u.ray.direction.z*s.grabDistanceM},T=Cn(k);if(s.kind==="workspace")e.setWorkspaceAnchor(s.workspaceName,T),y=!0;else{let v=s.tetherTo?g.nodes.find(d=>d.id===s?.tetherTo):void 0;v&&(e.setSessionOffset(s.address,{dAzimuthRad:jn(T.azimuthRad-v.azimuthRad),dElevationM:T.elevationM-v.elevationM,dRadiusM:T.radiusM-v.radiusM}),y=!0)}return f=s.nodeId,{layoutMutated:y,visibilityMutated:h,hoveredNodeId:f,grabbedNodeId:s.nodeId,pointerRay:{origin:u.ray.origin,direction:u.ray.direction,lengthM:s.grabDistanceM,hovered:!0}}}}let x=null;for(let u of A){let w=$n(u.ray,g.nodes);(x===null||w!==null&&x.hit===null||w!==null&&x.hit!==null&&w.distanceM<x.hit.distanceM)&&(x={source:u.source,ray:u.ray,hit:w})}if(!x)return f=null,{layoutMutated:y,visibilityMutated:h,hoveredNodeId:null,grabbedNodeId:null,pointerRay:null};let E=x.hit?.node.id??null;if(E!==null&&E!==f&&Ce(x.source,.16,10),f=E,!!x.source.gamepad?.buttons?.[0]?.pressed&&x.hit!==null){let u=x.hit.node;s={source:x.source,nodeId:u.id,kind:u.kind,workspaceName:u.workspaceName,address:u.address,tetherTo:u.tetherTo,grabDistanceM:Pe(x.hit.distanceM,et,tt)},Ce(x.source,.28,16)}return{layoutMutated:y,visibilityMutated:h,hoveredNodeId:f,grabbedNodeId:s?.nodeId??null,pointerRay:{origin:x.ray.origin,direction:x.ray.direction,lengthM:x.hit?.distanceM??Nn,hovered:x.hit!==null}}}return{update:a,reset:m}}var Bn=`#version 300 es
|
|
2
|
-
precision highp float;
|
|
3
|
-
|
|
4
|
-
layout(location = 0) in vec2 a_quad;
|
|
5
|
-
layout(location = 1) in vec4 i_sphere;
|
|
6
|
-
layout(location = 2) in vec4 i_color;
|
|
7
|
-
layout(location = 3) in vec3 i_salience;
|
|
8
|
-
|
|
9
|
-
uniform mat4 u_viewProj;
|
|
10
|
-
uniform vec3 u_camRight;
|
|
11
|
-
uniform vec3 u_camUp;
|
|
12
|
-
|
|
13
|
-
out vec2 v_uv;
|
|
14
|
-
out vec4 v_color;
|
|
15
|
-
out vec3 v_salience;
|
|
16
|
-
|
|
17
|
-
void main() {
|
|
18
|
-
v_uv = a_quad;
|
|
19
|
-
v_color = i_color;
|
|
20
|
-
v_salience = i_salience;
|
|
21
|
-
vec3 worldPos = i_sphere.xyz + (u_camRight * a_quad.x + u_camUp * a_quad.y) * i_sphere.w;
|
|
22
|
-
gl_Position = u_viewProj * vec4(worldPos, 1.0);
|
|
23
|
-
}
|
|
24
|
-
`,Dn=`#version 300 es
|
|
25
|
-
precision highp float;
|
|
26
|
-
|
|
27
|
-
in vec2 v_uv;
|
|
28
|
-
in vec4 v_color;
|
|
29
|
-
in vec3 v_salience;
|
|
30
|
-
|
|
31
|
-
uniform float u_timeSec;
|
|
32
|
-
uniform vec3 u_gateRgb;
|
|
33
|
-
uniform vec3 u_failRgb;
|
|
34
|
-
|
|
35
|
-
out vec4 fragColor;
|
|
36
|
-
|
|
37
|
-
void main() {
|
|
38
|
-
float d = length(v_uv);
|
|
39
|
-
if (d > 1.35) discard;
|
|
40
|
-
|
|
41
|
-
float pulse = v_salience.x;
|
|
42
|
-
float gate = v_salience.y;
|
|
43
|
-
float fail = v_salience.z;
|
|
44
|
-
|
|
45
|
-
vec3 baseCol = mix(v_color.rgb, u_gateRgb, gate * 0.65);
|
|
46
|
-
baseCol = mix(baseCol, u_failRgb, fail * 0.85);
|
|
47
|
-
|
|
48
|
-
float alpha = 0.0;
|
|
49
|
-
vec3 rgb = baseCol;
|
|
50
|
-
|
|
51
|
-
if (d <= 1.0) {
|
|
52
|
-
float z = sqrt(max(0.0, 1.0 - d * d));
|
|
53
|
-
float fresnel = pow(1.0 - z, 2.3);
|
|
54
|
-
vec3 normal = normalize(vec3(v_uv * 0.92, z));
|
|
55
|
-
float keyLight = max(0.0, dot(normal, normalize(vec3(-0.32, 0.58, 0.75))));
|
|
56
|
-
float spec = pow(keyLight, 14.0) * 0.38;
|
|
57
|
-
rgb = baseCol * (0.42 + 0.52 * keyLight) + baseCol * fresnel * 0.75 + vec3(spec);
|
|
58
|
-
alpha = (0.34 + 0.62 * fresnel + 0.14 * z) * v_color.a;
|
|
59
|
-
} else {
|
|
60
|
-
float haloFalloff = exp(-(d - 1.0) * 8.5);
|
|
61
|
-
float gateBreath = 0.55 + 0.45 * sin(u_timeSec * 3.14159);
|
|
62
|
-
float haloBoost = 0.22 + gate * 0.62 * gateBreath + pulse * 0.35 + fail * 0.45;
|
|
63
|
-
rgb = mix(baseCol, u_gateRgb, gate * 0.8);
|
|
64
|
-
alpha = haloFalloff * haloBoost * v_color.a;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (pulse > 0.01) {
|
|
68
|
-
float ringRadius = mix(0.24, 1.26, 1.0 - pulse);
|
|
69
|
-
float ring = exp(-abs(d - ringRadius) * 18.0) * pulse;
|
|
70
|
-
rgb += baseCol * ring * 0.85;
|
|
71
|
-
alpha = min(1.0, alpha + ring * 0.55 * v_color.a);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
alpha = clamp(alpha, 0.0, 1.0);
|
|
75
|
-
fragColor = vec4(rgb * alpha, alpha);
|
|
76
|
-
}
|
|
77
|
-
`,qn=`#version 300 es
|
|
78
|
-
precision highp float;
|
|
79
|
-
|
|
80
|
-
layout(location = 0) in vec3 a_pos;
|
|
81
|
-
layout(location = 1) in vec4 a_color;
|
|
82
|
-
|
|
83
|
-
uniform mat4 u_viewProj;
|
|
84
|
-
|
|
85
|
-
out vec4 v_color;
|
|
86
|
-
|
|
87
|
-
void main() {
|
|
88
|
-
v_color = a_color;
|
|
89
|
-
gl_Position = u_viewProj * vec4(a_pos, 1.0);
|
|
90
|
-
}
|
|
91
|
-
`,Gn=`#version 300 es
|
|
92
|
-
precision highp float;
|
|
93
|
-
|
|
94
|
-
in vec4 v_color;
|
|
95
|
-
out vec4 fragColor;
|
|
96
|
-
|
|
97
|
-
void main() {
|
|
98
|
-
float a = clamp(v_color.a, 0.0, 1.0);
|
|
99
|
-
fragColor = vec4(v_color.rgb * a, a);
|
|
100
|
-
}
|
|
101
|
-
`;function qt(e,t,o){let n=e.createShader(t);if(!n)throw new Error("Failed to allocate WebGL2 shader.");if(e.shaderSource(n,o),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){let i=e.getShaderInfoLog(n)??"unknown shader compile error";throw e.deleteShader(n),new Error(`XR shader compilation failed: ${i}`)}return n}function Gt(e,t,o){let n=qt(e,e.VERTEX_SHADER,t),i=qt(e,e.FRAGMENT_SHADER,o),l=e.createProgram();if(!l)throw e.deleteShader(n),e.deleteShader(i),new Error("Failed to allocate WebGL2 program.");if(e.attachShader(l,n),e.attachShader(l,i),e.linkProgram(l),e.deleteShader(n),e.deleteShader(i),!e.getProgramParameter(l,e.LINK_STATUS)){let s=e.getProgramInfoLog(l)??"unknown program link error";throw e.deleteProgram(l),new Error(`XR program link failed: ${s}`)}return l}function Hn(){return typeof OffscreenCanvas=="function"?new OffscreenCanvas(2,2).getContext("webgl2",{alpha:!0,antialias:!0,depth:!0,premultipliedAlpha:!0,powerPreference:"low-power",xrCompatible:!0}):null}function Un(e){let t=globalThis;return typeof t.XRRigidTransform!="function"?null:new t.XRRigidTransform(e)}function Wn(e,t){let o=globalThis;if(typeof o.XRWebGLLayer!="function")throw new Error("XRWebGLLayer is unavailable in this runtime.");return new o.XRWebGLLayer(e,t,{alpha:!0})}function Ht({xr:e=null,audio:t,controllerInput:o,getWorldFrame:n,createGlContext:i=Hn,createXrLayer:l=Wn,createRigidTransform:s=Un,onSessionModeChange:f}){let m=Bt(),a=new Float32Array(16),c=[],r=null,p=null,g=0,I=!1,b=!1,y=null;function h(){if(y!==null)return y;let u=i();if(!u)return null;let w=Gt(u,Bn,Dn),k=Gt(u,qn,Gn),T=new Float32Array([-1.35,-1.35,1.35,-1.35,-1.35,1.35,1.35,1.35]),v=u.createVertexArray(),d=u.createBuffer(),_=u.createBuffer();u.bindVertexArray(v),u.bindBuffer(u.ARRAY_BUFFER,d),u.bufferData(u.ARRAY_BUFFER,T,u.STATIC_DRAW),u.enableVertexAttribArray(0),u.vertexAttribPointer(0,2,u.FLOAT,!1,8,0);let M=ve*4;u.bindBuffer(u.ARRAY_BUFFER,_),u.bufferData(u.ARRAY_BUFFER,M*32,u.DYNAMIC_DRAW),u.enableVertexAttribArray(1),u.vertexAttribPointer(1,4,u.FLOAT,!1,M,0),u.vertexAttribDivisor(1,1),u.enableVertexAttribArray(2),u.vertexAttribPointer(2,4,u.FLOAT,!1,M,16),u.vertexAttribDivisor(2,1),u.enableVertexAttribArray(3),u.vertexAttribPointer(3,3,u.FLOAT,!1,M,32),u.vertexAttribDivisor(3,1);let O=u.createVertexArray(),R=u.createBuffer(),N=Ie*4;return u.bindVertexArray(O),u.bindBuffer(u.ARRAY_BUFFER,R),u.bufferData(u.ARRAY_BUFFER,N*64,u.DYNAMIC_DRAW),u.enableVertexAttribArray(0),u.vertexAttribPointer(0,3,u.FLOAT,!1,N,0),u.enableVertexAttribArray(1),u.vertexAttribPointer(1,4,u.FLOAT,!1,N,12),u.bindVertexArray(null),y={gl:u,orbProgram:w,orbVao:v,orbInstanceBuf:_,orbUniforms:{viewProj:u.getUniformLocation(w,"u_viewProj"),camRight:u.getUniformLocation(w,"u_camRight"),camUp:u.getUniformLocation(w,"u_camUp"),timeSec:u.getUniformLocation(w,"u_timeSec"),gateRgb:u.getUniformLocation(w,"u_gateRgb"),failRgb:u.getUniformLocation(w,"u_failRgb")},lineProgram:k,lineVao:O,lineBuf:R,lineViewProj:u.getUniformLocation(k,"u_viewProj")},y}function A(u){if(!(!r||u.length===0))for(let w of u)c.push(w)}async function x(u){if(b||I||!e||typeof e.requestSession!="function")return!1;if(r){if(p===u)return!0;await E()}let w=h();if(!w)return!1;I=!0;try{let k=w.gl;typeof k.makeXRCompatible=="function"&&await k.makeXRCompatible();let T=await e.requestSession(u,{optionalFeatures:["local-floor","bounded-floor"]}),v=l(T,w.gl);T.updateRenderState({baseLayer:v});let d=await T.requestReferenceSpace("local-floor").catch(async()=>{let R=await T.requestReferenceSpace("local"),N=s({x:0,y:-ue,z:0});return N!=null&&R!==null&&typeof R=="object"&&typeof R.getOffsetReferenceSpace=="function"?R.getOffsetReferenceSpace(N):R});r=T,p=u,c=[],m.reset(),o.reset(),f?.(u);let _=-1,M=()=>{r===T&&(r=null,p=null,g=0,c=[],o.reset(),f?.(null))};T.onend=M;let O=(R,N)=>{if(r!==T||b)return;g=T.requestAnimationFrame(O);let F=_<0?0:Math.min(.25,Math.max(0,(R-_)/1e3));_=R;let C=Date.now(),j=n(C),q=o.update({session:T,frame:N,refSpace:d,worldFrame:j,dtSec:F});(q.layoutMutated||q.visibilityMutated)&&(j=n(C),t.syncFrame(j,[],C));let W=N.getViewerPose(d);if(!W)return;t.setListenerPose($t(W.transform.matrix));let K=c;c=[];let D=m.step({frame:j,cues:K,dtSec:F,timeSec:R/1e3,hoveredNodeId:q.hoveredNodeId,grabbedNodeId:q.grabbedNodeId,pointerRay:q.pointerRay}),{gl:z}=w,ie=T.renderState?.baseLayer??v;if(z.bindFramebuffer(z.FRAMEBUFFER,ie.framebuffer),u==="immersive-ar"?z.clearColor(0,0,0,0):z.clearColor(.02,.031,.027,1),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),D.orbCount===0&&D.lineVertexCount===0)return;z.enable(z.BLEND),z.blendFunc(z.ONE,z.ONE_MINUS_SRC_ALPHA),z.enable(z.DEPTH_TEST),z.depthMask(!1),D.lineVertexCount>0&&(z.bindBuffer(z.ARRAY_BUFFER,w.lineBuf),z.bufferData(z.ARRAY_BUFFER,D.lineData,z.DYNAMIC_DRAW)),D.orbCount>0&&(z.bindBuffer(z.ARRAY_BUFFER,w.orbInstanceBuf),z.bufferData(z.ARRAY_BUFFER,D.orbData,z.DYNAMIC_DRAW));let L=re.gate.rgb,G=re.failed.rgb;for(let H of W.views){let X=ie.getViewport(H);if(X&&(z.viewport(X.x,X.y,X.width,X.height),Pt(a,H.projectionMatrix,H.transform.inverse.matrix),D.lineVertexCount>0&&(z.useProgram(w.lineProgram),z.uniformMatrix4fv(w.lineViewProj,!1,a),z.bindVertexArray(w.lineVao),z.drawArrays(z.LINES,0,D.lineVertexCount)),D.orbCount>0)){let Y=Ft(H.transform.matrix);z.useProgram(w.orbProgram),z.uniformMatrix4fv(w.orbUniforms.viewProj,!1,a),z.uniform3f(w.orbUniforms.camRight,Y.right.x,Y.right.y,Y.right.z),z.uniform3f(w.orbUniforms.camUp,Y.up.x,Y.up.y,Y.up.z),z.uniform1f(w.orbUniforms.timeSec,R/1e3),z.uniform3f(w.orbUniforms.gateRgb,L[0],L[1],L[2]),z.uniform3f(w.orbUniforms.failRgb,G[0],G[1],G[2]),z.bindVertexArray(w.orbVao),z.drawArraysInstanced(z.TRIANGLE_STRIP,0,4,D.orbCount)}}z.bindVertexArray(null),z.depthMask(!0)};return g=T.requestAnimationFrame(O),!0}catch{return!1}finally{I=!1}}async function E(){let u=r;u&&(g&&(u.cancelAnimationFrame?.(g),g=0),r=null,p=null,o.reset(),f?.(null),await u.end().catch(()=>{}))}async function S(){b=!0,await E()}return{get activeMode(){return p},notifyCues:A,enterSession:x,exitSession:E,dispose:S}}var Vn=3e4;var nt=(e,t=Math.random)=>{let o=Math.min(Vn,1e3*2**e);return o/2+t()*(o/2)};var Kn=1e4,_e=class e{#e=null;#t=!1;#c="";#r=null;#l=0;#n=null;#o=null;#i=null;#f=null;#s=[];constructor(t,{types:o=[],headers:n,onMessage:i,onError:l,onDown:s,onUp:f,signal:m}={}){if(m?.aborted){this.#t=!0;return}if(m&&(this.#f=Z.target(m,"abort",()=>this.close(),{once:!0})),n===void 0){this.#e=new EventSource(t),this.#e.onopen=()=>f?.(),this.#e.onerror=p=>{l?.(p),s?.(p)};let r=p=>i?.(p.type,e.#a(p.data),p.lastEventId);this.#e.onmessage=r;for(let p of o)this.#e.addEventListener(p,r);return}let a=new Set(o),c=()=>{this.#t||this.#o===null||(clearTimeout(this.#o),this.#o=null,this.#u(t,{typeSet:a,headers:n,onMessage:i,onError:l,onDown:s,onUp:f}))};typeof window<"u"&&window?.addEventListener&&this.#s.push(Z.target(window,"online",c)),typeof document<"u"&&document?.addEventListener&&this.#s.push(Z.target(document,"visibilitychange",()=>{document.visibilityState==="visible"&&c()})),this.#u(t,{typeSet:a,headers:n,onMessage:i,onError:l,onDown:s,onUp:f})}close(){if(!this.#t){this.#t=!0,clearTimeout(this.#n),this.#n=null,clearTimeout(this.#o),this.#o=null,this.#f?.(),this.#f=null;for(let t of this.#s)t();this.#s=[],this.#i?.abort(),this.#i=null,this.#e?.close(),this.#e=null}}#u(t,o){if(this.#t)return;this.#i?.abort();let n=new AbortController;this.#i=n,this.#m(t,o,n.signal)}async#m(t,{typeSet:o,headers:n,onMessage:i,onError:l,onDown:s,onUp:f},m){let a=null;try{let c=typeof n=="function"?await n(m):n;if(this.#t||m.aborted)return;let r=new Headers(c??void 0);r.has("accept")||r.set("accept","text/event-stream"),this.#c&&!r.has("last-event-id")&&r.set("last-event-id",this.#c);let p=await fetch(t,{headers:r,cache:"no-store",signal:m});if(this.#t||m.aborted)return;if(p.status===204){this.close(),s?.();return}if(p.status!==200){let S=p.status===408||p.status===429||p.status>=500,u=Object.assign(new Error(`otm sse: HTTP ${p.status}${p.statusText?` ${p.statusText}`:""}`),{status:p.status,response:p});S||this.close(),l?.(u),s?.(u),S&&this.#p(t,{typeSet:o,headers:n,onMessage:i,onError:l,onDown:s,onUp:f});return}let g=p.headers.get("content-type")?.split(";")[0].trim().toLowerCase();if(g!=="text/event-stream"||!p.body){let S=Object.assign(new Error(`otm sse: expected text/event-stream, got ${g||"none"}`),{status:p.status,response:p,protocolFailure:!0});this.close(),l?.(S),s?.(S);return}this.#n=setTimeout(()=>{this.#l=0},Kn),f?.(),a=p.body.getReader();let I=new TextDecoder("utf-8"),b="",y=!0,h="message",A=[],x=!1,E=S=>{if(S===""){if(x){let T=A.join(`
|
|
102
|
-
`),v=h||"message";A=[],x=!1,h="message",(v==="message"||o.has(v))&&i?.(v,e.#a(T),this.#c)}else h="message";return}if(S.startsWith(":"))return;let u=S.indexOf(":"),w=S,k="";u!==-1&&(w=S.slice(0,u),k=S.slice(u+1),k.startsWith(" ")&&(k=k.slice(1))),w==="event"?h=k:w==="data"?(A.push(k),x=!0):w==="id"?k.includes("\0")||(this.#c=k):w==="retry"&&/^\d+$/.test(k)&&(this.#r=Number(k))};for(;;){let{value:S,done:u}=await a.read();if(u)break;let w=I.decode(S,{stream:!0});y&&(y=!1,w.startsWith("\uFEFF")&&(w=w.slice(1))),b+=w;let k=b.split(/\r\n|\r|\n/);b=k.pop()??"";for(let T of k)if(E(T),this.#t||m.aborted)return}if(b+=I.decode(),this.#t||m.aborted)return;clearTimeout(this.#n),this.#n=null,s?.(),this.#p(t,{typeSet:o,headers:n,onMessage:i,onError:l,onDown:s,onUp:f})}catch(c){if(clearTimeout(this.#n),this.#n=null,this.#t||m.aborted)return;l?.(c),s?.(c),this.#p(t,{typeSet:o,headers:n,onMessage:i,onError:l,onDown:s,onUp:f})}finally{await a?.cancel().catch(()=>{})}}#p(t,o){if(this.#t)return;this.#l+=1;let n=this.#r!==null?this.#r:nt(this.#l);clearTimeout(this.#o),this.#o=setTimeout(()=>{this.#o=null,this.#u(t,o)},n)}static#a(t){try{return JSON.parse(t)}catch{return t}}};var Ut=(e,t)=>new _e(e,t);function Wt({notificationsUrl:e,onConnectionChange:t,onUpdate:o}){let n=je(),i="connecting",l=null,s=!1,f=!1,m=g=>{s||i===g||(i=g,t?.(g))},a=()=>{if(l?.close(),l=null,s)return;m("connecting");let g=Ut(e,{types:[...kt],headers:I=>yt(e,I),onUp:()=>{s||l!==g||(f=!1,m("connected"))},onMessage:(I,b)=>{if(s||l!==g)return;if(!$(b)||typeof b.event!="string"||!$(b.data)){g.close(),m("disconnected");return}let y=Et(n,b);if(n=y.state,y.resyncRequired){a();return}o?.(y)},onError:I=>{if(s||l!==g)return;let b=Reflect.get(Object(I),"status");if(b===401||b===403){if(g.close(),b===401&&!f){f=!0,wt(e).then(y=>{s||l!==g||(y?a():m("signed-out"))});return}m("signed-out");return}m("disconnected")},onDown:I=>{if(s||l!==g)return;let b=Reflect.get(Object(I),"status");m(i==="signed-out"||b===401||b===403?"signed-out":"disconnected")}});l=g},c=vt(()=>{s||(f=!1,a())}),r=typeof window<"u"&&typeof window.addEventListener=="function"?Q.target(window,"pagehide",()=>{s||(l?.close(),l=null)}):()=>{},p=typeof window<"u"&&typeof window.addEventListener=="function"?Q.target(window,"pageshow",g=>{s||g.persisted&&a()}):()=>{};return t?.(i),a(),{get state(){return n},get connection(){return i},dispose(){s||(s=!0,c(),r(),p(),l?.close(),l=null)}}}var Xt="plurnk-xr:layout";function Vt(e){return e==="passive"||e==="off"?e:"on"}function Xn(e){let t=Number(e);return Number.isFinite(t)?Math.min(1,Math.max(0,t/100)):.35}function Yn(){try{let e=typeof window<"u"?window.localStorage?.getItem(Xt):null;return e?JSON.parse(e):null}catch{return null}}function Kt(e){try{typeof window<"u"&&window.localStorage?.setItem(Xt,JSON.stringify(e))}catch{}}async function Jn(e){let t=ae("html"),o=Vt(U("visibility")),n=Xn(U("gain")??"35");await U.boot({namespace:"plurnk-xr",persistKeys:["audio-muted","visibility"]}),U("audio-muted")===null&&U("audio-muted","false");let i=U("audio-muted")==="true",l=Nt({...e.createAudioContext?{createAudioContext:e.createAudioContext}:{},initialGain:n,initialMuted:i}),s=Vt(U("visibility")??o);U("visibility",s);let f=Number(t?.getAttribute("data-callout-ms")??""),m=e.calloutMs??(Number.isFinite(f)&&f>=1e3?f:8e3),a=Rt({calloutMs:m,initialVisibility:s}),c=Yn();c!==null&&a.importLayout(c);let r=je(),p=Dt({topology:a,audio:l,onVisibilityChange:u=>{U("visibility",u)},onMuteChange:u=>{U("audio-muted",u?"true":"false")},onLayoutCommit:()=>{Kt(a.exportLayout())}}),g=Ht({xr:e.xr??null,audio:l,controllerInput:p,getWorldFrame:u=>a.project(r,u),...e.createGlContext?{createGlContext:e.createGlContext}:{},...e.createXrLayer?{createXrLayer:e.createXrLayer}:{},onSessionModeChange:u=>{U("xr-session",u?"active":"idle")}}),I=(u=[])=>{let w=Date.now();u.length>0&&(a.ingestCues(u,w),g.notifyCues(u));let k=a.project(r,w);return l.syncFrame(k,u,w),e.onWorldFrame?.(k,u),k};I();let b=ae('[data-xr-mode="immersive-vr"]'),y=ae('[data-xr-mode="immersive-ar"]'),h=e.notificationsUrl??t?.getAttribute("data-notifications-url")??"/notifications",A=Q("main","click",'[data-action="enter-xr"]',(u,w)=>{let k=w.getAttribute("data-xr-mode");(k==="immersive-vr"||k==="immersive-ar")&&(l.unlock(),e.onEnterXr?.(k),g.enterSession(k))}),x=Q("main","click",'[data-action="sign-in"]',u=>{u.preventDefault(),bt(h,{returnTo:"/xr/"})}),E=e.connectWatch===!1?null:Wt({notificationsUrl:h,onConnectionChange:u=>{U("connection",u)},onUpdate:u=>{r=u.state,I(u.cues)}}),S=await jt(e);return U("xr-posture",S.posture),b&&(b.disabled=!S.vrSupported),y&&(y.disabled=!S.arSupported),{posture:S.posture,capabilities:S,topology:a,audio:l,controllerInput:p,renderer:g,saveLayout(){Kt(a.exportLayout())},applyEnvelope(u){return r=u.state,I(u.cues)},dispose(){E?.dispose(),g.dispose(),l.dispose(),A(),x()}}}if(typeof window<"u"&&ae("#xr-airlock")!==null){let e=window.navigator;Jn({isSecureContext:window.isSecureContext,xr:e.xr??null})}export{Jn as bootLaunchShell};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|