@uptimizr/dashboard 0.2.0 → 0.3.0
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/README.md +1 -1
- package/out/404.html +1 -1
- package/out/__next.__PAGE__.txt +2 -2
- package/out/__next._full.txt +3 -3
- package/out/__next._head.txt +1 -1
- package/out/__next._index.txt +2 -2
- package/out/__next._tree.txt +2 -2
- package/out/_next/static/chunks/1vuq3dos1406d.css +3 -0
- package/out/_next/static/chunks/2-qo2o1_fmpy-.js +3 -0
- package/out/_next/static/chunks/2r3ct6se2qn8z.js +1 -0
- package/out/_next/static/chunks/{1xpwp4m1tqugp.js → 42k2-4_2hrg6u.js} +1 -1
- package/out/_not-found/__next._full.txt +2 -2
- package/out/_not-found/__next._head.txt +1 -1
- package/out/_not-found/__next._index.txt +2 -2
- package/out/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/out/_not-found/__next._not-found.txt +1 -1
- package/out/_not-found/__next._tree.txt +2 -2
- package/out/_not-found.html +1 -1
- package/out/_not-found.txt +2 -2
- package/out/index.html +1 -1
- package/out/index.txt +3 -3
- package/package.json +3 -3
- package/out/_next/static/chunks/137xbvd4nd41j.js +0 -3
- package/out/_next/static/chunks/2mdbvf1b5h00_.css +0 -3
- package/out/_next/static/chunks/2our10fwtj87e.js +0 -1
- /package/out/_next/static/{M9ZSIaKJeBgkjz1qktYio → 1NTbwHeIsn3AW-SeH9aP0}/_buildManifest.js +0 -0
- /package/out/_next/static/{M9ZSIaKJeBgkjz1qktYio → 1NTbwHeIsn3AW-SeH9aP0}/_clientMiddlewareManifest.js +0 -0
- /package/out/_next/static/{M9ZSIaKJeBgkjz1qktYio → 1NTbwHeIsn3AW-SeH9aP0}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,51581,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"BailoutToCSR",{enumerable:!0,get:function(){return a}});let n=e.r(59922);function a({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new n.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},16201,(e,t,s)=>{"use strict";function n(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"encodeURIPath",{enumerable:!0,get:function(){return n}})},1299,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"PreloadChunks",{enumerable:!0,get:function(){return o}});let n=e.r(29212),a=e.r(90611),r=e.r(50803),l=e.r(16201),i=e.r(29434);function o({moduleIds:e}){if("u">typeof window)return null;let t=r.workAsyncStorage.getStore();if(void 0===t)return null;let s=[];if(t.reactLoadableManifest&&e){let n=t.reactLoadableManifest;for(let t of e){if(!n[t])continue;let e=n[t].files;s.push(...e)}}if(0===s.length)return null;let c=(0,i.getAssetTokenQuery)();return(0,n.jsx)(n.Fragment,{children:s.map(e=>{let s=`${t.assetPrefix}/_next/${(0,l.encodeURIPath)(e)}${c}`;return e.endsWith(".css")?(0,n.jsx)("link",{precedence:"dynamic",href:s,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,a.preload)(s,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},89699,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"default",{enumerable:!0,get:function(){return c}});let n=e.r(29212),a=e.r(94179),r=e.r(51581),l=e.r(1299);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},c=function(e){let t={...o,...e},s=(0,a.lazy)(()=>t.loader().then(i)),c=t.loading;function d(e){let i=c?(0,n.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,d=o?a.Suspense:a.Fragment,u=t.ssr?(0,n.jsxs)(n.Fragment,{children:["u"<typeof window?(0,n.jsx)(l.PreloadChunks,{moduleIds:t.modules}):null,(0,n.jsx)(s,{...e})]}):(0,n.jsx)(r.BailoutToCSR,{reason:"next/dynamic",children:(0,n.jsx)(s,{...e})});return(0,n.jsx)(d,{...o?{fallback:i}:{},children:u})}return d.displayName="LoadableComponent",d}},80268,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"default",{enumerable:!0,get:function(){return a}});let n=e.r(81258)._(e.r(89699));function a(e,t){let s={};"function"==typeof e&&(s.loader=e);let a={...s,...t};return(0,n.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof s.default||"object"==typeof s.default&&null!==s.default)&&void 0===s.default.__esModule&&(Object.defineProperty(s.default,"__esModule",{value:!0}),Object.assign(s.default,s),t.exports=s.default)},14936,e=>{"use strict";var t=e.i(23838),s=e.i(29212),n=e.i(80268),a=e.i(94179),r=e.i(82665),l=e.i(20880);let i={window:"1h"},o=[{id:"1h",label:"Last hour"},{id:"24h",label:"Last 24h"},{id:"7d",label:"Last 7 days"},{id:"all",label:"All time"}],c={"1h":36e5,"24h":864e5,"7d":6048e5};function d(e,t=Date.now()){return"all"===e.window?{}:"custom"===e.window?{since:e.since,until:e.until}:{since:t-c[e.window],until:t}}function u(e,t=Date.now()){return{...d(e,t),scene:e.scene&&e.scene.length>0?e.scene:void 0,source:e.source,cameraMode:e.cameraMode}}let m=[60,300,900,1800,3600,10800,21600,43200,86400,604800];function h(e,t=80){let s=Math.max(60,Math.round(e/t/1e3));return m.find(e=>e>=s)??604800}function x(e){return"xr-controller"===e?"XR controller":e.charAt(0).toUpperCase()+e.slice(1)}let p=["mouse","touch","stylus","pen","xr-controller","hand","gaze","transient","other"];var g=e.i(56054);function f(e,t=1){let[s,n,a]=(0,g.heatRgb)(e);return`rgba(${Math.round(255*s)}, ${Math.round(255*n)}, ${Math.round(255*a)}, ${t})`}function b(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t}):"—"}var v=e.i(89339),j=e.i(88725);let w=e=>import(e);async function y(e,t={}){var s;let n,a=t.fetchImpl??fetch;try{let s=await a(e,{signal:t.signal});if(!s.ok)return{source:e,code:"manifest-fetch",message:`HTTP ${s.status}`};n=await s.json()}catch(t){return{source:e,code:"manifest-fetch",message:S(t)}}return"object"==typeof(s=n)&&null!==s&&"number"==typeof s.version&&Array.isArray(s.panels)&&s.panels.every(e=>"object"==typeof e&&null!==e&&"string"==typeof e.url&&e.url.length>0&&"number"==typeof e.contract&&(void 0===e.export||"string"==typeof e.export)&&(void 0===e.id||"string"==typeof e.id))?n:{source:e,code:"manifest-invalid",message:"Manifest shape is invalid"}}async function N(e,t={}){let s=t.importModule??w,n=[],a=[];for(let r of(await Promise.all(e.panels.map(e=>k(e,s,t.allowOrigins)))))"panel"in r?n.push(r.panel):a.push(r.error);return{panels:n,errors:a}}async function k(e,t,s){var n;let a,r,l=e.url;if(1!==e.contract)return{error:{source:l,code:"incompatible",message:`Panel declares contract ${e.contract}; host requires 1`}};if(!function(e,t){let s;if(!t||0===t.length)return!0;try{s=new URL(e).origin}catch{return!1}return t.includes(s)}(e.url,s))return{error:{source:l,code:"origin-blocked",message:"Module origin is not in the allowlist"}};try{a=await t(e.url)}catch(e){return{error:{source:l,code:"import-failed",message:S(e)}}}let i=e.export??"default",o=void 0!==(r=(n=a)[i])?r:"default"===i&&void 0!==n.panel?n.panel:void 0;return void 0===o?{error:{source:l,code:"export-missing",message:`No "${i}" export found`}}:"object"==typeof o&&null!==o&&"string"==typeof o.id&&0!==o.id.length&&"string"==typeof o.title&&"function"==typeof o.render&&(void 0===o.load||"function"==typeof o.load)&&(void 0===o.enabled||"function"==typeof o.enabled)&&(void 0===o.span||1===o.span||2===o.span)&&(void 0===o.surfaces||Array.isArray(o.surfaces))&&1?{panel:o}:{error:{source:l,code:"invalid-panel",message:"Export is not a valid PanelDefinition"}}}function S(e){return e instanceof Error?e.message:String(e)}var M=a;let z={hidden:[],settings:{}},C={load:()=>z,save:()=>{}};var P=e.i(93425);function _({panelId:e,spec:t,values:n,onChange:r,onReset:l,showReset:i=!0}){let o=(0,a.useId)(),c=Object.keys(t);return 0===c.length?null:(0,s.jsxs)("div",{className:"space-y-3","data-panel-settings":e,children:[c.map(e=>{let a=t[e];if(!a)return null;let l=`${o}-${e}`,i=a.label??e;return(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("label",{htmlFor:l,className:"text-xs font-medium text-fg",children:i}),"number"===a.type?(0,s.jsxs)("span",{className:"text-xs tabular-nums text-fg-muted",children:[String(n[e]),a.unit?` ${a.unit}`:""]}):null]}),"number"===a.type?(0,s.jsx)("input",{id:l,type:"range",className:"w-full accent-amber",min:a.min,max:a.max,step:a.step??1,value:Number(n[e]),onChange:t=>r(e,Number(t.target.value))}):null,"boolean"===a.type?(0,s.jsxs)("label",{htmlFor:l,className:"flex items-center gap-2 text-xs text-fg-muted",children:[(0,s.jsx)("input",{id:l,type:"checkbox",className:"accent-amber",checked:!!n[e],onChange:t=>r(e,t.target.checked)}),a.help??"Enabled"]}):null,"select"===a.type?(0,s.jsx)("select",{id:l,className:"w-full rounded-md border border-edge bg-ink px-2 py-1 text-xs text-fg",value:String(n[e]),onChange:t=>r(e,t.target.value),children:a.options.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label??e.value},e.value))}):null,"boolean"!==a.type&&a.help?(0,s.jsx)("p",{className:"text-[11px] leading-tight text-fg-muted",children:a.help}):null]},e)}),i?(0,s.jsx)("button",{type:"button",onClick:l,className:"text-[11px] text-fg-muted underline-offset-2 transition hover:text-amber hover:underline",children:"Reset to defaults"}):null]})}function $({panels:e,ctx:t,surface:n,revision:r=0}){let l=function(e,t){let s=(0,a.useMemo)(()=>{var t;let s;return(void 0)??(t=`uptimizr:dashboard:panels:${e}`,(s=window.localStorage?window.localStorage:null)?{load(){try{let e=s.getItem(t);return e?function(e){if(!e||"object"!=typeof e)return z;let t=Array.isArray(e.hidden)?e.hidden.filter(e=>"string"==typeof e):[],s={};if(e.settings&&"object"==typeof e.settings)for(let[t,n]of Object.entries(e.settings)){if(!n||"object"!=typeof n)continue;let e={};for(let[t,s]of Object.entries(n))("number"==typeof s||"boolean"==typeof s||"string"==typeof s)&&(e[t]=s);Object.keys(e).length>0&&(s[t]=e)}return{hidden:t,settings:s}}(JSON.parse(e)):z}catch{return z}},save(e){try{0===e.hidden.length&&0===Object.keys(e.settings).length?s.removeItem(t):s.setItem(t,JSON.stringify(e))}catch{}}}:C)},[void 0,e]),[n,r]=(0,a.useState)(z),[l,i]=(0,a.useState)(!1),o=(0,a.useRef)(t);o.current=t,(0,a.useEffect)(()=>{r(s.load()),i(!0)},[s]);let c=(0,a.useCallback)(e=>{r(e),s.save(e)},[s]),d=(0,a.useCallback)(e=>{r(t=>{if(t.hidden.includes(e))return t;let n={...t,hidden:[...t.hidden,e]};return s.save(n),n})},[s]),u=(0,a.useCallback)(e=>{r(t=>{if(!t.hidden.includes(e))return t;let n={...t,hidden:t.hidden.filter(t=>t!==e)};return s.save(n),n})},[s]),m=(0,a.useCallback)(()=>{r(e=>{if(0===e.hidden.length)return e;let t={...e,hidden:[]};return s.save(t),t})},[s]),h=(0,a.useCallback)((e,t,n)=>{r(a=>{let r={...a.settings[e]??{},[t]:n},l=function(e,t){let s={};if(!e)return s;for(let n of Object.keys(t)){let a=e[n];a&&t[n]!==a.default&&(s[n]=t[n])}return s}(o.current(e),r),i={...a.settings};Object.keys(l).length>0?i[e]=l:delete i[e];let c={...a,settings:i};return s.save(c),c})},[s]),x=(0,a.useCallback)(e=>{r(t=>{if(!t.settings[e])return t;let n={...t.settings};delete n[e];let a={...t,settings:n};return s.save(a),a})},[s]),p=(0,a.useCallback)(e=>n.settings[e]??{},[n]),g=(0,a.useCallback)(e=>n.hidden.includes(e),[n]);return{hydrated:l,hidden:n.hidden,isHidden:g,hide:d,show:u,showAll:m,overridesFor:p,setSetting:h,resetSettings:x,replace:c}}(n,(0,M.useCallback)(t=>e.find(e=>e.id===t)?.settings,[e])),i=(0,M.useMemo)(()=>e.filter(e=>(e.surfaces??["overview"]).includes(n)).map(e=>{let s=function(e,t){let s={};if(!e)return s;for(let n of Object.keys(e))s[n]=function(e,t){switch(e.type){case"number":var s,n;let a;if("number"!=typeof t||!Number.isFinite(t))return e.default;return s=e.min,n=e.max,a=t,"number"==typeof s&&a<s&&(a=s),"number"==typeof n&&a>n&&(a=n),a;case"boolean":return"boolean"==typeof t?t:e.default;case"select":if("string"!=typeof t)return e.default;return e.options.some(e=>e.value===t)?t:e.default}}(e[n],t?.[n]);return s}(e.settings,l.overridesFor(e.id));return{panel:e,panelCtx:{...t,settings:s}}}).filter(({panel:e,panelCtx:t})=>{if(!e.enabled)return!0;try{return e.enabled(t)}catch(t){return console.error(`Panel "${e.id}" enabled() threw; hiding it`,t),!1}}),[e,n,t,l]),o=l.hydrated?i.filter(({panel:e})=>!l.isHidden(e.id)):i,c=l.hydrated?i.filter(({panel:e})=>l.isHidden(e.id)):[];return(0,s.jsxs)(s.Fragment,{children:[c.length>0?(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(I,{hidden:c.map(({panel:e})=>({id:e.id,title:e.title})),onRestore:l.show,onRestoreAll:l.showAll})}):null,o.map(({panel:e,panelCtx:t})=>(0,s.jsx)("div",{className:2===e.span?"lg:col-span-2":void 0,children:(0,s.jsx)(A,{panel:e,ctx:t,revision:r,onHide:()=>l.hide(e.id),settingsForm:e.settings?(0,s.jsx)(_,{panelId:e.id,spec:e.settings,values:t.settings,onChange:(t,s)=>l.setSetting(e.id,t,s),onReset:()=>l.resetSettings(e.id)}):void 0})},e.id))]})}function I({hidden:e,onRestore:t,onRestoreAll:n}){return(0,s.jsxs)("section",{className:"flex flex-wrap items-center gap-2 rounded-xl border border-dashed border-edge bg-panel/60 px-4 py-2.5 text-xs text-fg-muted",children:[(0,s.jsxs)("span",{className:"font-medium uppercase tracking-wide",children:["Hidden panels (",e.length,")"]}),e.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>t(e.id),className:"rounded-md border border-edge px-2 py-1 text-fg transition hover:border-amber hover:text-fg-hi",children:["+ ",e.title]},e.id)),(0,s.jsx)("button",{type:"button",onClick:n,className:"ml-auto text-fg-muted underline-offset-2 transition hover:text-amber hover:underline",children:"Show all"})]})}function A({panel:e,ctx:t,revision:n,onHide:r,settingsForm:l}){let{data:i,loading:o,error:c}=function(e,t,s=0){let[n,r]=(0,a.useState)({data:null,loading:!!e.load,error:null}),l=JSON.stringify({params:t.params,settings:t.settings});return(0,a.useEffect)(()=>{if(!e.load)return void r({data:null,loading:!1,error:null});let s=!0,n=new AbortController;return r(e=>({...e,loading:!0,error:null})),e.load({...t,signal:n.signal}).then(e=>{s&&r({data:e,loading:!1,error:null})},e=>{s&&!n.signal.aborted&&r({data:null,loading:!1,error:e instanceof Error?e:Error(String(e))})}),()=>{s=!1,n.abort()}},[e,l,t.surface,t.sessionId,s]),n}(e,t,n),d="function"==typeof e.subtitle?e.subtitle(t):e.subtitle,u=o&&!!e.load&&null==i,m=function(){let[e,t]=(0,M.useState)(!1);return(0,M.useEffect)(()=>t(!0),[]),e}(),h=!e.clientOnly||m;return(0,s.jsx)(P.Panel,{title:e.title,subtitle:d,help:e.help,collapsible:e.collapsible,onHide:r,settings:l,children:h?c?(0,s.jsxs)("p",{className:"text-sm text-fg-muted",children:["Could not load: ",c.message]}):u?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"Loading…"}):(0,s.jsx)(R,{panelId:e.id,children:e.render({data:i,ctx:t})}):null})}class R extends M.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error(`Panel "${this.props.panelId}" failed to render`,e)}componentDidUpdate(e){e.panelId!==this.props.panelId&&this.state.error&&this.setState({error:null})}render(){return this.state.error?(0,s.jsxs)("p",{className:"text-sm text-fg-muted",children:["Could not render: ",this.state.error.message]}):this.props.children}}function E(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function T(e){let t=E(e),s=[[0,.1,.9],[0,.85,1],[.1,.9,.2],[1,.85,0],[1,.15,0],[1,1,1]],n=s.length-1,a=t*n,r=Math.min(Math.floor(a),n-1),l=a-r,i=s[r],o=s[r+1];return i&&o?[i[0]+(o[0]-i[0])*l,i[1]+(o[1]-i[1])*l,i[2]+(o[2]-i[2])*l]:[1,1,1]}var L=e.i(62238),F=e.i(59683),D=e.i(37660),B=e.i(42279);function O({bins:t,gridSize:n}){let r=(0,a.useRef)(null),l=(0,a.useRef)(null),i=(0,a.useRef)(null),[o,c]=(0,a.useState)("loading"),[d,u]=(0,a.useState)(null),[m,h]=(0,a.useState)("markers"),[x,p]=(0,a.useState)(null);return(0,a.useEffect)(()=>{let s=r.current;if(!s)return;if(0===t.length)return void c("empty");let a=!1,o=null;return c("loading"),u(null),(async()=>{try{let[{Engine:r},{Scene:d},{ArcRotateCamera:u},{HemisphericLight:h},{Vector3:x,Color3:f,Color4:b,Matrix:v},{MeshBuilder:j},{StandardMaterial:w},{Mesh:y},{DynamicTexture:N}]=await Promise.all([e.A(66022),e.A(48505),e.A(53976),e.A(42436),e.A(89370),e.A(67141),e.A(20693),e.A(8850),e.A(63836),e.A(9607),e.A(96664)]);if(a)return;let k=new r(s,!0,{preserveDrawingBuffer:!1}),S=new d(k);S.clearColor=new b(.04,.05,.07,1);let M=x.Zero(),z=new u("dome-cam",Math.PI/3,Math.PI/2.4,3.6,M,S);z.attachControl(s,!0),z.lowerRadiusLimit=1.6,z.upperRadiusLimit=8,(0,L.disableWheelZoom)(z),l.current=z,i.current={target:M,alpha:z.alpha,beta:z.beta,radius:z.radius},new h("dome-light",new x(.3,1,.2),S);let C=j.CreateSphere("dome",{diameter:2,segments:20},S),P=new w("dome-mat",S);P.wireframe=!0,P.disableLighting=!0,P.emissiveColor=new f(.16,.2,.28),P.alpha=.5,C.material=P,C.isPickable=!1;let _=[];for(let e=0;e<=64;e++){let t=e/64*Math.PI*2;_.push(new x(Math.cos(t),0,Math.sin(t)))}let $=j.CreateLines("dome-horizon",{points:_},S);$.color=new f(.3,.36,.46),$.isPickable=!1;let I=j.CreateLines("dome-forward",{points:[x.Zero(),new x(1.25,0,0)]},S);I.color=new f(.4,.7,.95),I.isPickable=!1;let A=t.reduce((e,t)=>Math.max(e,t.count),1),R=n>0?n:1;if("markers"===m){let e=j.CreateBox("dome-marker",{size:1},S),s=new w("dome-marker-mat",S);s.disableLighting=!0,s.emissiveColor=f.White(),s.specularColor=new f(0,0,0),e.material=s,e.isPickable=!0,e.thinInstanceEnablePicking=!0;let n=t.length,a=new Float32Array(16*n),r=new Float32Array(4*n),l=Array(n);for(let e=0;e<n;e++){let s=t[e],n=(s.azimuth_bin+.5)/R*Math.PI*2-Math.PI,i=(s.elevation_bin+.5)/R*Math.PI-Math.PI/2,o=Math.cos(i),c=o*Math.cos(n),d=Math.sin(i),u=o*Math.sin(n),m=s.count/A,h=.03+.12*m;v.Scaling(h,h,h).multiply(v.Translation(c,d,u)).copyToArray(a,16*e);let[x,p,f]=(0,g.heatRgb)(m);r[4*e]=x,r[4*e+1]=p,r[4*e+2]=f,r[4*e+3]=1,l[e]=`dir (${s.azimuth_bin}, ${s.elevation_bin}) \xb7 ${s.count}`}e.thinInstanceSetBuffer("matrix",a,16,!0),e.thinInstanceSetBuffer("color",r,4,!0),e.metadata={hoverLabels:l}}else{let e=function(e,t={}){let s=void 0!==t.width&&t.width>0?Math.floor(t.width):256,n=void 0!==t.height&&t.height>0?Math.floor(t.height):Math.max(1,Math.floor(s/2)),a=t.colorRamp??T,r=void 0!==t.blurBins&&t.blurBins>0?t.blurBins:1.5,l=E(t.alphaFloor??0),i=E(t.opacity??1),o=e.gridSize>0?e.gridSize:1,c=new Uint8ClampedArray(s*n*4),d=e.bins.filter(e=>e.count>0);if(0===d.length)return{width:s,height:n,rgba:c};let u=Math.max(1e-4,Math.PI/o*r),m=2*u*u,h=Math.cos(Math.min(Math.PI,3*u)),x=d.map(e=>{var t,s;let n,[a,r]=(t=e.azimuthBin,s=e.elevationBin,[(t+.5)/o*Math.PI*2-Math.PI,(s+.5)/o*Math.PI-Math.PI/2]);return[(n=Math.cos(r))*Math.cos(a),Math.sin(r),n*Math.sin(a)]}),p=new Float32Array(s*n),g=0;for(let e=0;e<n;e++){let t=Math.PI/2-(e+.5)/n*Math.PI,a=Math.cos(t),r=Math.sin(t);for(let t=0;t<s;t++){let n=(t+.5)/s*Math.PI*2-Math.PI,l=a*Math.cos(n),i=a*Math.sin(n),o=0;for(let e=0;e<d.length;e++){let t=x[e],s=l*t[0]+r*t[1]+i*t[2];if(s<h)continue;let n=Math.acos(s>1?1:s<-1?-1:s);o+=d[e].count*Math.exp(-(n*n)/m)}p[e*s+t]=o,o>g&&(g=o)}}if(g<=0)return{width:s,height:n,rgba:c};for(let e=0;e<p.length;e++){let t=E(p[e]/g),[s,n,r]=a(t),o=(l+(1-l)*t)*i,d=4*e;c[d]=Math.round(255*s),c[d+1]=Math.round(255*n),c[d+2]=Math.round(255*r),c[d+3]=Math.round(255*E(o))}return{width:s,height:n,rgba:c}}({bins:t.map(e=>({azimuthBin:e.azimuth_bin,elevationBin:e.elevation_bin,count:e.count})),gridSize:R},{width:256,blurBins:1.5,opacity:.95}),s=new N("dome-skytex",{width:e.width,height:e.height},S,!1);s.hasAlpha=!0;let n=s.getContext(),a=n.createImageData(e.width,e.height);a.data.set(e.rgba),n.putImageData(a,0,0),s.update();let r=j.CreateSphere("dome-sky",{diameter:2,segments:48,sideOrientation:y.DOUBLESIDE},S),l=new w("dome-sky-mat",S);l.disableLighting=!0,l.emissiveColor=f.White(),l.diffuseColor=new f(0,0,0),l.specularColor=new f(0,0,0),l.emissiveTexture=s,l.opacityTexture=s,l.backFaceCulling=!1,r.material=l,r.isPickable=!1}k.runRenderLoop(()=>S.render());let D=()=>k.resize();window.addEventListener("resize",D);let B=(0,F.attachMeshHover)(S,s,p),O=(0,L.attachDoubleClickFocus)(S,s,z);c("ready"),o=()=>{window.removeEventListener("resize",D),B(),O(),p(null),l.current=null,i.current=null,S.dispose(),k.dispose()}}catch(e){if(a)return;c("error"),u(e instanceof Error?e.message:"Failed to render dome.")}})(),()=>{a=!0,o?.()}},[t,n,m]),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("canvas",{ref:r,className:"aspect-video w-full rounded-lg border border-edge bg-ink"}),x?(0,s.jsx)("div",{className:"pointer-events-none absolute z-10 max-w-[16rem] truncate rounded border border-edge bg-ink/90 px-1.5 py-0.5 text-xs text-white shadow backdrop-blur",style:{left:x.x+12,top:x.y+12},children:x.label}):null,"ready"===o?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"absolute left-3 top-3 flex overflow-hidden rounded-md border border-edge bg-ink/80 text-xs backdrop-blur",children:["markers","skydome"].map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>h(e),className:`px-2.5 py-1 ${m===e?"bg-fg/15 font-medium text-white":"text-fg-muted hover:text-fg"}`,children:"markers"===e?"Markers":"Skydome"},e))}),(0,s.jsx)(B.ZoomButtons,{onZoom:e=>l.current&&(0,L.stepZoom)(l.current,e),onReset:()=>l.current&&i.current&&(0,L.resetFocus)(l.current,i.current)}),(0,s.jsx)(D.HeatLegend,{title:"Gaze density",lowLabel:"rarely",highLabel:"most-viewed",note:"markers"===m?"Each marker is a look-direction (camera forward). Blue line = forward, ring = horizon. Color & size scale with how often that direction was viewed.":"Continuous equirectangular heat field: the same gaze bins splatted into a smooth thermal texture wrapped on the dome. The in-scene SDK overlay (showGazeSkydome) renders this inward so you can stand inside it in WebXR."})]}):(0,s.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-sm text-fg-muted",children:"loading"===o?"Rendering…":"empty"===o?"No camera samples in range.":"error"===o?d??"Dome unavailable.":null})]})}function U({bins:e,cellSize:t}){let n=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let t=n.current;if(!t)return;let s=t.getContext("2d");if(!s||(s.clearRect(0,0,360,360),s.fillStyle="#0b0e14",s.fillRect(0,0,360,360),0===e.length))return;let a=1/0,r=-1/0,l=1/0,i=-1/0,o=0;for(let t of e)t.gx<a&&(a=t.gx),t.gx>r&&(r=t.gx),t.gz<l&&(l=t.gz),t.gz>i&&(i=t.gz),t.count>o&&(o=t.count);let c=344/Math.max(r-a+1,i-l+1);for(let t of e){s.fillStyle=f(o>0?t.count/o:0,.9);let e=8+(t.gx-a)*c,n=8+(i-t.gz)*c;s.fillRect(e,n,Math.ceil(c),Math.ceil(c))}},[e,t]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsxs)("div",{className:"relative inline-block",children:[(0,s.jsx)("canvas",{ref:n,width:360,height:360,className:"rounded-lg border border-edge","aria-label":"Floor-plan position heatmap"}),e.length>0?(0,s.jsx)(D.HeatLegend,{title:"Dwell density",lowLabel:"rarely",highLabel:"most",note:`${t} m cells`}):null]})}),0===e.length?(0,s.jsx)("p",{className:"mt-2 text-center text-xs text-fg-muted",children:"No camera-position data in range. Capture a first-person session to populate the plan."}):null]})}function H({points:e}){let t=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let s=t.current;if(!s)return;let n=s.getContext("2d");if(!n||(n.clearRect(0,0,360,360),n.fillStyle="#0b0e14",n.fillRect(0,0,360,360),0===e.length))return;let a=1/0,r=-1/0,l=1/0,i=-1/0;for(let t of e)t.gx<a&&(a=t.gx),t.gx>r&&(r=t.gx),t.gz<l&&(l=t.gz),t.gz>i&&(i=t.gz);let o=344/Math.max(r-a+1,i-l+1),c=(e,t)=>[8+(e-a+.5)*o,8+(i-t+.5)*o],d=function(e){let t=new Map;for(let s of e){let e=t.get(s.session_id);e||(e=[],t.set(s.session_id,e));let n=e[e.length-1];n&&n.gx===s.gx&&n.gz===s.gz||e.push({gx:s.gx,gz:s.gz})}return[...t.values()].map(e=>({cells:e}))}(e);for(let e of(n.lineWidth=2,n.lineJoin="round",n.lineCap="round",n.globalCompositeOperation="lighter",n.strokeStyle="rgba(251, 191, 36, 0.18)",d)){if(e.cells.length<2)continue;n.beginPath();let[t,s]=c(e.cells[0].gx,e.cells[0].gz);n.moveTo(t,s);for(let t=1;t<e.cells.length;t++){let[s,a]=c(e.cells[t].gx,e.cells[t].gz);n.lineTo(s,a)}n.stroke()}n.globalCompositeOperation="source-over"},[e]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)("canvas",{ref:t,width:360,height:360,className:"rounded-lg border border-edge","aria-label":"Aggregate desire-line paths"})}),0===e.length?(0,s.jsx)("p",{className:"mt-2 text-center text-xs text-fg-muted",children:"No camera-path data in range. Capture first-person sessions to populate the desire lines."}):null]})}let W={hover:"#60a5fa",pick:"#34d399",click:"#fbbf24",drag:"#f472b6",select:"#a78bfa",squeeze:"#fb7185",grab:"#22d3ee",release:"#94a3b8",teleport:"#f59e0b"};function G(e){return W[e]??"#64748b"}function V({rows:e,topN:t=8}){let n=function(e,t){let s=new Map;for(let t of e){let e=s.get(t.mesh);e||(e={mesh:t.mesh,total:0,kinds:[]},s.set(t.mesh,e)),e.kinds.push({kind:t.kind,count:t.count}),e.total+=t.count}let n=[...s.values()].sort((e,t)=>t.total-e.total).slice(0,t);for(let e of n)e.kinds.sort((e,t)=>t.count-e.count);return n}(e,t);if(0===n.length)return(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No mesh interactions in range."});let a=[...new Set(e.map(e=>e.kind))];return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("ul",{className:"space-y-2",children:n.map(e=>(0,s.jsxs)("li",{className:"text-sm",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{className:"truncate font-mono text-xs text-fg",children:e.mesh}),(0,s.jsx)("span",{className:"tabular-nums text-fg-muted",children:b(e.total)})]}),(0,s.jsx)("div",{className:"mt-1 flex h-2 w-full overflow-hidden rounded bg-ink/60",children:e.kinds.map(t=>(0,s.jsx)("div",{className:"h-full",style:{width:`${e.total>0?t.count/e.total*100:0}%`,backgroundColor:G(t.kind)},title:`${t.kind}: ${b(t.count)}`},t.kind))})]},e.mesh))}),(0,s.jsx)("ul",{className:"flex flex-wrap gap-x-3 gap-y-1",children:a.map(e=>(0,s.jsxs)("li",{className:"flex items-center gap-1.5 text-xs text-fg-muted",children:[(0,s.jsx)("span",{className:"inline-block h-2 w-2 rounded-sm",style:{backgroundColor:G(e)}}),e]},e))})]})}let Z={mouse:"#60a5fa",touch:"#34d399",stylus:"#a78bfa",pen:"#a78bfa","xr-controller":"#fbbf24",hand:"#f472b6",gaze:"#22d3ee",transient:"#fb7185",keyboard:"#f59e0b",gamepad:"#c084fc",other:"#94a3b8"};function K(e){return Z[e]??"#64748b"}function X({buckets:e}){if(e.length<2)return(0,s.jsx)("span",{className:"text-[10px] text-fg-muted",children:"—"});let t=e.reduce((e,t)=>Math.max(e,t),0)||1;return(0,s.jsx)("div",{className:"flex h-5 items-end gap-px","aria-hidden":!0,children:e.map((e,n)=>(0,s.jsx)("div",{className:"w-1 rounded-sm bg-sky-400/70",style:{height:`${Math.max(8,e/t*100)}%`}},n))})}function q({delta:e}){return e>0?(0,s.jsxs)("span",{className:"tabular-nums text-xs text-emerald-400",children:["▲ ",b(e)]}):e<0?(0,s.jsxs)("span",{className:"tabular-nums text-xs text-rose-400",children:["▼ ",b(-e)]}):(0,s.jsx)("span",{className:"text-xs text-fg-muted",children:"—"})}function J({sources:e,trend:t,topN:n=8}){let a=function(e,t,s){let n=new Map;for(let t of e){let e=n.get(t.mesh);e||(e={total:0,sources:new Map},n.set(t.mesh,e)),e.total+=t.count,e.sources.set(t.source,(e.sources.get(t.source)??0)+t.count)}let a=new Map;for(let e of t){let t=a.get(e.mesh);t?t.push(e):a.set(e.mesh,[e])}return[...n.entries()].map(([e,t])=>{let s=(a.get(e)??[]).slice().sort((e,t)=>e.bucket-t.bucket).map(e=>e.count),n=Math.floor(s.length/2),r=s.slice(0,n).reduce((e,t)=>e+t,0),l=s.slice(n).reduce((e,t)=>e+t,0);return{mesh:e,total:t.total,sources:[...t.sources.entries()].map(([e,t])=>({source:e,count:t})).sort((e,t)=>t.count-e.count),buckets:s,delta:l-r}}).sort((e,t)=>t.total-e.total).slice(0,s)}(e,t,n);return 0===a.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No mesh interactions in range."}):(0,s.jsx)("ol",{className:"space-y-2",children:a.map((e,t)=>(0,s.jsx)("li",{className:"text-sm",children:(0,s.jsxs)("details",{className:"group",children:[(0,s.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-3",children:[(0,s.jsx)("span",{className:"w-5 shrink-0 text-right tabular-nums text-xs text-fg-muted",children:t+1}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-fg",children:e.mesh}),(0,s.jsx)(X,{buckets:e.buckets}),(0,s.jsx)(q,{delta:e.delta}),(0,s.jsx)("span",{className:"w-12 shrink-0 text-right tabular-nums text-fg-muted",children:b(e.total)})]}),(0,s.jsx)("ul",{className:"mt-1.5 space-y-1 pl-8",children:e.sources.map(t=>(0,s.jsxs)("li",{className:"flex items-center gap-2 text-xs",children:[(0,s.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-sm",style:{backgroundColor:K(t.source)}}),(0,s.jsx)("span",{className:"w-24 shrink-0 truncate text-fg-muted",children:t.source}),(0,s.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded bg-ink/60",children:(0,s.jsx)("div",{className:"h-full rounded",style:{width:`${e.total>0?t.count/e.total*100:0}%`,backgroundColor:K(t.source)}})}),(0,s.jsx)("span",{className:"w-10 shrink-0 text-right tabular-nums text-fg-muted",children:b(t.count)})]},t.source))})]})},e.mesh))})}let Y={mouse:"#60a5fa",touch:"#34d399",stylus:"#a78bfa",pen:"#a78bfa","xr-controller":"#fbbf24",hand:"#f472b6",gaze:"#22d3ee",transient:"#fb7185",keyboard:"#f59e0b",gamepad:"#c084fc",other:"#94a3b8"};function Q(e){return Y[e]??"#64748b"}function ee({sources:e,actions:t,topActions:n=8}){let a=function(e){let t=new Map;for(let s of e)t.set(s.source,(t.get(s.source)??0)+s.count);let s=[...t.values()].reduce((e,t)=>e+t,0);return[...t.entries()].map(([e,t])=>({source:e,count:t,share:s>0?t/s:0})).sort((e,t)=>t.count-e.count)}(e),r=t.slice(0,n);return 0===a.length&&0===r.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No input interactions in range."}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted",children:"Modality share"}),0===a.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No source-bearing interactions in range."}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex h-3 w-full overflow-hidden rounded bg-ink/60",children:a.map(e=>(0,s.jsx)("div",{className:"h-full",style:{width:`${100*e.share}%`,backgroundColor:Q(e.source)},title:`${e.source}: ${b(e.count)}`},e.source))}),(0,s.jsx)("ul",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1",children:a.map(e=>(0,s.jsxs)("li",{className:"flex items-center gap-1.5 text-xs text-fg-muted",children:[(0,s.jsx)("span",{className:"inline-block h-2 w-2 rounded-sm",style:{backgroundColor:Q(e.source)}}),e.source,(0,s.jsxs)("span",{className:"tabular-nums text-fg",children:[Math.round(100*e.share),"%"]})]},e.source))})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted",children:"Most-used shortcuts"}),0===r.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No input_action events in range."}):(0,s.jsx)("ul",{className:"space-y-1.5",children:r.map(e=>(0,s.jsxs)("li",{className:"flex items-center gap-2 text-sm",children:[(0,s.jsx)("span",{className:"inline-block h-2 w-2 shrink-0 rounded-sm",style:{backgroundColor:Q(e.source)}}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-fg",children:e.action}),(0,s.jsx)("span",{className:"shrink-0 text-xs text-fg-muted",children:e.source}),(0,s.jsx)("span",{className:"w-12 shrink-0 text-right tabular-nums text-fg-muted",children:b(e.count)})]},`${e.action}/${e.source}`))})]})]})}function et({coverage:e,proxyMeshes:t,cellSize:n,topN:a=12}){if(0===t.length)return(0,s.jsxs)("div",{className:"space-y-2 text-sm text-fg-muted",children:[(0,s.jsx)("p",{children:"No scene proxy is registered, so there is no reference geometry to call “dead”."}),(0,s.jsx)("p",{children:"Register proxy geometry (ADR 0014) via the scene representation API to enumerate the regions visitors could approach."})]});if(0===e.length)return(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No camera-position samples in range — every region reads as dead. Widen the range or check that first-person camera samples are being captured."});let r=function(e,t,s,n=1){let a=s*n,r=t.slice(0,600).map(t=>{let n=0;for(let r of e)(function(e,t,s,n,a,r){let l=(e+.5)*n,i=(t+.5)*n,o=(s+.5)*n,[c,d,u,m,h,x]=a;return l>=c-r&&l<=m+r&&i>=d-r&&i<=h+r&&o>=u-r&&o<=x+r})(r.vx,r.vy,r.vz,s,t.aabb,a)&&(n+=r.count);return{mesh:t.name,path:t.path,nearbySamples:n,dead:0===n}});return r.sort((e,t)=>e.nearbySamples-t.nearbySamples),{rows:r,deadCount:r.filter(e=>e.dead).length,total:r.length}}(e,t,n),l=r.rows.reduce((e,t)=>Math.max(e,t.nearbySamples),0)||1,i=r.rows.slice(0,a);return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("p",{className:"text-xs text-fg-muted",children:[(0,s.jsx)("span",{className:"tabular-nums text-fg",children:b(r.deadCount)})," of"," ",(0,s.jsx)("span",{className:"tabular-nums text-fg",children:b(r.total)})," proxy meshes are dead (no nearby camera samples)."]}),(0,s.jsx)("ul",{className:"space-y-1.5",children:i.map(e=>(0,s.jsxs)("li",{className:"text-sm",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{className:"truncate font-mono text-xs text-fg",title:e.path??e.mesh,children:e.mesh}),e.dead?(0,s.jsx)("span",{className:"shrink-0 rounded bg-rose-500/20 px-1.5 text-xs text-rose-300",children:"dead"}):(0,s.jsx)("span",{className:"shrink-0 tabular-nums text-xs text-fg-muted",children:b(e.nearbySamples)})]}),(0,s.jsx)("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded bg-ink/60",children:(0,s.jsx)("div",{className:"h-full rounded bg-sky-500/70",style:{width:`${e.nearbySamples/l*100}%`}})})]},e.path??e.mesh))})]})}function es({label:e,value:t}){return(0,s.jsxs)("div",{className:"rounded-lg bg-ink/60 p-3",children:[(0,s.jsx)("div",{className:"text-xs uppercase tracking-wide text-fg-muted",children:e}),(0,s.jsx)("div",{className:"mt-1 text-2xl font-semibold tabular-nums text-fg-hi",children:t})]})}function en({bins:e}){if(0===e.length)return(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No FPS samples in range."});let t=[...e].sort((e,t)=>e.bucket-t.bucket),n=t.reduce((e,t)=>Math.max(e,t.sessions),0)||1,a=t.length>1?t[1].bucket-t[0].bucket:10;return(0,s.jsx)("div",{className:"space-y-1.5",children:t.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,s.jsxs)("span",{className:"w-16 shrink-0 text-right tabular-nums text-fg-muted",children:[e.bucket,"–",e.bucket+a]}),(0,s.jsx)("div",{className:"h-4 flex-1 overflow-hidden rounded bg-ink/60",children:(0,s.jsx)("div",{className:"h-full rounded bg-emerald-500/70",style:{width:`${e.sessions/n*100}%`}})}),(0,s.jsx)("span",{className:"w-10 shrink-0 tabular-nums text-fg-muted",children:e.sessions})]},e.bucket))})}function ea({distribution:e,histogram:t}){return e&&0!==e.samples?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,s.jsx)(es,{label:"p05 FPS (worst)",value:b(e.p05_fps,1)}),(0,s.jsx)(es,{label:"p50 FPS (typical)",value:b(e.p50_fps,1)}),(0,s.jsx)(es,{label:"p95 FPS (best)",value:b(e.p95_fps,1)}),(0,s.jsx)(es,{label:"Sessions",value:b(e.sessions)})]}),(0,s.jsx)(en,{bins:t})]}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No performance samples in range."})}function er(e){return`${Math.round(100*e)}%`}function el({data:e}){if(!e||0===e.samples)return(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No frame-perf samples in range."});let t=e.p50_fps>=50&&e.p50_render_scale>0&&e.p50_render_scale<.9,n=[{label:"Median FPS",value:b(Math.round(e.p50_fps))},{label:"Avg FPS",value:b(Math.round(e.avg_fps))},{label:"Median render scale",value:er(e.p50_render_scale)},{label:"Avg render scale",value:er(e.avg_render_scale)},{label:"Downscaled frames",value:er(e.downscaled_share)},{label:"Samples",value:b(e.samples)}];return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3",children:n.map(e=>(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-xs text-fg-muted",children:e.label}),(0,s.jsx)("dd",{className:"tabular-nums text-lg text-fg",children:e.value})]},e.label))}),t?(0,s.jsxs)("p",{className:"rounded-md border border-amber/40 bg-amber/10 px-3 py-2 text-xs text-amber",children:["Good FPS is being bought with resolution — the median frame renders at"," ",er(e.p50_render_scale)," scale. The headline FPS overstates the device experience."]}):null]})}let ei="__other_sp__",eo="__other_mesh__";function ec(e){return`${e[0]}|${e[1]}|${e[2]}`}function ed(e,t){return t<=1?0:1.4-e/(t-1)*2.8}let eu="__all__",em={maxStandpoints:6,maxMeshes:10,maxRibbons:70};function eh(e,t){return`${e}|${t}`}function ex({links:t,gridSize:n,proxyMeshes:r=[],maxLinks:i=80,baseUrl:o,apiKey:c,flowQuery:d,hasFirstPerson:u=!1}){let m=(0,a.useRef)(null),h=(0,a.useRef)(null),x=(0,a.useRef)(null),[p,f]=(0,a.useState)("loading"),[b,v]=(0,a.useState)(null),[j,w]=(0,a.useState)(eu),[y,N]=(0,a.useState)(eu),[k,S]=(0,a.useState)(eu),[M,z]=(0,a.useState)("aggregate"),[C,P]=(0,a.useState)(null),[_,$]=(0,a.useState)("all"),[I,A]=(0,a.useState)(t),R=!!(o&&d),E=(0,a.useMemo)(()=>d?JSON.stringify(d):"",[d]),T=(0,a.useRef)(!1);(0,a.useEffect)(()=>{!T.current&&u&&($("first-person"),T.current=!0)},[u]),(0,a.useEffect)(()=>{u&&"viewer"===_&&$("first-person")},[u,_]),(0,a.useEffect)(()=>{R||A(t)},[t,R]),(0,a.useEffect)(()=>{if(!o||!d)return;let e=!1,t=new l.CollectorApi(o,c??""),s="all"===_?void 0:_;return t.flowHeatmap({...d,bins:n,limit:400,groupByOrigin:!0,cameraMode:s}).then(t=>{e||A(t)}).catch(()=>{e||A([])}),()=>{e=!0}},[o,c,E,_,n]);let O=(0,a.useMemo)(()=>{let e=new Map;for(let t of I){if(!t.originVoxel)continue;let s=ec(t.originVoxel),n=t.origin,a=e.get(s);a?(a.count+=t.count,n&&(a.ox+=n[0]*t.count,a.oy+=n[1]*t.count,a.oz+=n[2]*t.count,a.wsum+=t.count)):e.set(s,{key:s,voxel:t.originVoxel,count:t.count,ox:n?n[0]*t.count:0,oy:n?n[1]*t.count:0,oz:n?n[2]*t.count:0,wsum:n?t.count:0})}return[...e.values()].map(e=>({key:e.key,voxel:e.voxel,count:e.count,origin:e.wsum>0?[e.ox/e.wsum,e.oy/e.wsum,e.oz/e.wsum]:void 0})).sort((e,t)=>t.count-e.count)},[I]),U=O.length>0,H=(0,a.useMemo)(()=>k===eu?null:O.find(e=>e.key===k)??null,[O,k]),W=(0,a.useMemo)(()=>(function(e,t,s,n){let a=e.filter(e=>e.originVoxel);if(0===a.length)return{standpoints:[],gazes:[],meshes:[],ribbons:[],maxCount:1};let r=t.slice(0,Math.max(1,n.maxStandpoints)),l=new Set(r.map(e=>e.key)),i=e=>{let t=e.originVoxel?ec(e.originVoxel):ei;return l.has(t)?t:ei},o=new Map;for(let e of a)o.set(e.mesh,(o.get(e.mesh)??0)+e.count);let c=new Set([...o.entries()].sort((e,t)=>t[1]-e[1]).slice(0,Math.max(1,n.maxMeshes)).map(([e])=>e)),d=e=>c.has(e)?e:eo,u=new Map;for(let e of a){let t=i(e),s=d(e.mesh),n=`${t}|${e.azimuth_bin}|${e.elevation_bin}|${s}`,a=u.get(n);a?a.count+=e.count:u.set(n,{standpointId:t,gazeId:`${t}|${e.azimuth_bin}|${e.elevation_bin}`,meshId:s,azimuthBin:e.azimuth_bin,elevationBin:e.elevation_bin,count:e.count})}let m=[...u.values()].sort((e,t)=>t.count-e.count),h=m.slice(0,Math.max(1,n.maxRibbons)),x=m.slice(Math.max(1,n.maxRibbons));if(x.length>0){let e=new Map(h.map(e=>[`${e.standpointId}|${e.azimuthBin}|${e.elevationBin}|${eo}`,e]));for(let t of x){let s=`${t.standpointId}|${t.azimuthBin}|${t.elevationBin}|${eo}`,n=e.get(s);if(n)n.count+=t.count;else{let n={standpointId:t.standpointId,gazeId:t.gazeId,meshId:eo,azimuthBin:t.azimuthBin,elevationBin:t.elevationBin,count:t.count};e.set(s,n),h.push(n)}}}let p=new Set(h.map(e=>e.standpointId)),g=new Set(h.map(e=>e.meshId)),f=[...r.filter(e=>p.has(e.key)).map(e=>e.key),...p.has(ei)?[ei]:[]],b=f.map((e,t)=>{let s=r.find(t=>t.key===e),n=h.filter(t=>t.standpointId===e).reduce((e,t)=>e+t.count,0);return{id:e,kind:"standpoint",pos:[-2.6,ed(t,f.length),0],count:n,label:s?`[${s.voxel[0]}, ${s.voxel[1]}, ${s.voxel[2]}]`:"Other standpoints",isOther:e===ei}}),v=new Map(b.map(e=>[e.id,e.pos[1]])),j=new Map;for(let e of h)j.set(e.meshId,(j.get(e.meshId)??0)+e.count);let w=[...g].sort((e,t)=>(j.get(t)??0)-(j.get(e)??0));w.sort((e,t)=>(e===eo)-(t===eo));let y=w.map((e,t)=>({id:e,kind:"mesh",pos:[2.6,ed(t,w.length),0],count:j.get(e)??0,label:e===eo?"Other meshes":e,isOther:e===eo})),N=new Map;for(let e of h){let t=N.get(e.gazeId);t?t.count+=e.count:N.set(e.gazeId,{az:e.azimuthBin,el:e.elevationBin,sp:e.standpointId,count:e.count})}let k=[...N.entries()].map(([e,t])=>{let n=v.get(t.sp)??0,a=(t.az+.5)/s-.5;return{id:e,kind:"gaze",pos:[0,n+((t.el+.5)/s-.5)*.85,1.6*a],count:t.count,label:`(${t.az}, ${t.el})`,isOther:!1}}),S=h.reduce((e,t)=>Math.max(e,t.count),1);return{standpoints:b,gazes:k,meshes:y,ribbons:h,maxCount:S}})(I,O,n,em),[I,O,n]),G="twostage"===M&&U;(0,a.useEffect)(()=>{"twostage"!==M||U||z("aggregate")},[M,U]);let V=(0,a.useMemo)(()=>{if(k!==eu&&U)return I.filter(e=>e.originVoxel&&ec(e.originVoxel)===k);if(!U)return I;let e=new Map;for(let t of I){let s=`${t.azimuth_bin}|${t.elevation_bin}|${t.mesh}`,n=e.get(s);n?n.count+=t.count:e.set(s,{azimuth_bin:t.azimuth_bin,elevation_bin:t.elevation_bin,mesh:t.mesh,count:t.count})}return[...e.values()]},[I,k,U]),Z=(0,a.useMemo)(()=>[...V].sort((e,t)=>t.count-e.count).slice(0,Math.max(1,i)),[V,i]),K=(0,a.useMemo)(()=>{let e=new Map;for(let t of Z)e.set(t.mesh,(e.get(t.mesh)??0)+t.count);return[...e.entries()].sort((e,t)=>t[1]-e[1])},[Z]),X=(0,a.useMemo)(()=>{let e=new Map;for(let t of Z){let s=eh(t.azimuth_bin,t.elevation_bin),n=e.get(s);n?n.count+=t.count:e.set(s,{azimuthBin:t.azimuth_bin,elevationBin:t.elevation_bin,count:t.count})}return[...e.values()].sort((e,t)=>t.count-e.count)},[Z]);(0,a.useEffect)(()=>{!G&&j!==eu&&(K.some(([e])=>e===j)||w(eu))},[G,j,K]),(0,a.useEffect)(()=>{!G&&y!==eu&&(X.some(e=>eh(e.azimuthBin,e.elevationBin)===y)||N(eu))},[G,y,X]),(0,a.useEffect)(()=>{!G&&k!==eu&&(O.some(e=>e.key===k)||S(eu))},[G,k,O]),(0,a.useEffect)(()=>{w(eu),N(eu),S(eu)},[M]);let q=(0,a.useMemo)(()=>G?W.ribbons.filter(e=>{let t=k===eu||e.standpointId===k,s=y===eu||eh(e.azimuthBin,e.elevationBin)===y,n=j===eu||e.meshId===j;return t&&s&&n}).length:Z.filter(e=>{let t=y===eu||eh(e.azimuth_bin,e.elevation_bin)===y,s=j===eu||e.mesh===j;return t&&s}).length,[G,W,Z,j,y,k]),J=G?W.ribbons.length:Z.length,Y=(0,a.useMemo)(()=>G?W.standpoints.map(e=>({value:e.id,label:`${e.label} \xb7 ${e.count}`})):O.slice(0,24).map(e=>({value:e.key,label:`[${e.voxel[0]}, ${e.voxel[1]}, ${e.voxel[2]}] \xb7 ${e.count}`})),[G,W,O]),Q=(0,a.useMemo)(()=>{if(G){let e=new Map;for(let t of W.ribbons){let s=eh(t.azimuthBin,t.elevationBin),n=e.get(s);n?n.count+=t.count:e.set(s,{az:t.azimuthBin,el:t.elevationBin,count:t.count})}return[...e.values()].sort((e,t)=>t.count-e.count).map(e=>({value:eh(e.az,e.el),label:`(${e.az}, ${e.el}) \xb7 ${e.count}`}))}return X.map(e=>({value:eh(e.azimuthBin,e.elevationBin),label:`(${e.azimuthBin}, ${e.elevationBin}) \xb7 ${e.count}`}))},[G,W,X]),ee=(0,a.useMemo)(()=>G?W.meshes.map(e=>({value:e.id,label:`${e.label} \xb7 ${e.count}`})):K.map(([e,t])=>({value:e,label:`${e} \xb7 ${t}`})),[G,W,K]);return(0,a.useEffect)(()=>{let t=m.current;if(!t||G)return;if(0===Z.length)return void f("empty");let s=!1,a=null;return f("loading"),v(null),(async()=>{try{let[{Engine:l},{Scene:i},{ArcRotateCamera:o},{HemisphericLight:c},{Vector3:d,Color3:u,Color4:m},{MeshBuilder:p},{StandardMaterial:b}]=await Promise.all([e.A(66022),e.A(48505),e.A(53976),e.A(42436),e.A(89370),e.A(67141),e.A(20693),e.A(96664)]);if(s)return;let v=new l(t,!0,{preserveDrawingBuffer:!1}),w=new i(v);w.clearColor=new m(.04,.05,.07,1);let N=new Map;for(let e of r)N.set(e.name,function(e){let t=e.aabb;return[(t[0]+t[3])/2,(t[1]+t[4])/2,(t[2]+t[5])/2]}(e));let k=new Map,S=K.map(([e])=>e).filter(e=>!N.has(e));for(let e=0;e<S.length;e++){let t=S[e],s=function(e){let t=0;for(let s=0;s<e.length;s++)t=31*t+e.charCodeAt(s)|0;return Math.abs(t)}(t),n=e/Math.max(1,S.length)*Math.PI*2+s%100/100*.35;k.set(t,[2.2*Math.cos(n),-.35+(s%7-3)*.06,2.2*Math.sin(n)])}for(let[e,t]of N.entries())k.set(e,t);let M=0,z=0,C=0,_=0;for(let e of k.values())M+=e[0],z+=e[1],C+=e[2],_++;let $=new d(M/Math.max(1,_),z/Math.max(1,_),C/Math.max(1,_)),I=1.8;for(let e of k.values()){let t=e[0]-$.x,s=e[1]-$.y,n=e[2]-$.z;I=Math.max(I,Math.sqrt(t*t+s*s+n*n))}let A=.75*I+1,R=Math.max(1,I/1.8),E=Z.reduce((e,t)=>Math.max(e,t.count),1),T=new b("flow-source-node",w);T.disableLighting=!0,T.emissiveColor=new u(.45,.75,1);let D=new b("flow-target-node",w);D.disableLighting=!0,D.emissiveColor=new u(1,.82,.42);let B=new Set,O=new Set,U=e=>{let t=y===eu||eh(e.azimuth_bin,e.elevation_bin)===y,s=j===eu||e.mesh===j;return t&&s},W=new Set,G=new Set;for(let e of Z)U(e)&&(W.add(eh(e.azimuth_bin,e.elevation_bin)),G.add(e.mesh));for(let e of Z){let t=`${e.azimuth_bin}|${e.elevation_bin}`,s=k.get(e.mesh);if(!s)continue;let a=U(e),r=(e.azimuth_bin+.5)/n*Math.PI*2-Math.PI,l=(e.elevation_bin+.5)/n*Math.PI-Math.PI/2,i=Math.cos(l),o=i*Math.cos(r),c=Math.sin(l),m=i*Math.sin(r),h=new d($.x+o*A,$.y+c*A,$.z+m*A),x=new d(s[0],s[1],s[2]);if(!B.has(t)){let e=p.CreateSphere(`flow-src-${t}`,{diameter:.12*R,segments:6},w);e.position=h;let s=T.clone(`flow-src-mat-${t}`);s.alpha=W.has(t)||j===eu&&y===eu?1:.22,e.material=s,e.isPickable=!1,B.add(t)}if(!O.has(e.mesh)){let t=p.CreateSphere(`flow-target-${e.mesh}`,{diameter:.2*R,segments:7},w);t.position=x;let s=D.clone(`flow-target-mat-${e.mesh}`);s.alpha=G.has(e.mesh)||j===eu&&y===eu?1:.22,t.material=s,t.isPickable=!0,t.metadata={hoverLabel:e.mesh},O.add(e.mesh)}let f=h.add(x).scale(.5),v=f.subtract($),N=Math.sqrt(v.x*v.x+v.y*v.y+v.z*v.z),S=N>1e-6?v.x/N:0,M=N>1e-6?v.y/N:1,z=N>1e-6?v.z/N:0,C=(.35+e.count/E*.75)*R,P=new d(f.x+S*C,f.y+M*C+.12*R,f.z+z*C),_=[];for(let e=0;e<=18;e++){let t=e/18,s=1-t;_.push(new d(s*s*h.x+2*s*t*P.x+t*t*x.x,s*s*h.y+2*s*t*P.y+t*t*x.y,s*s*h.z+2*s*t*P.z+t*t*x.z))}let I=e.count/E,[L,F,H]=(0,g.heatRgb)(I),V=p.CreateTube(`flow-link-${e.mesh}-${t}`,{path:_,radius:(a?1:.4)*(.012+.04*I)*R,tessellation:8,cap:0,sideOrientation:0},w),Z=new b(`flow-link-mat-${e.mesh}-${t}`,w);Z.disableLighting=!0,Z.emissiveColor=new u(L,F,H),Z.alpha=a?.35+.65*I:.08,V.material=Z,V.isPickable=!0,V.metadata={hoverLabel:e.mesh}}let V=new o("flow-cam",Math.PI/4,Math.PI/3,3.4*I,$,w);V.attachControl(t,!0),(0,L.disableWheelZoom)(V),h.current=V,x.current={target:$,alpha:V.alpha,beta:V.beta,radius:V.radius},new c("flow-light",new d(.3,1,.2),w);let X=p.CreateSphere("flow-source-dome",{diameter:2*A,segments:20},w);X.position=$;let q=new b("flow-source-dome-mat",w);q.wireframe=!0,q.disableLighting=!0,q.emissiveColor=new u(.16,.2,.28),q.alpha=.35,X.material=q,X.isPickable=!1;let J=H?.origin;if(J){let e=new d(J[0],J[1],J[2]),t=p.CreateSphere("flow-standpoint",{diameter:.26*R,segments:10},w);t.position=e;let s=new b("flow-standpoint-mat",w);s.disableLighting=!0,s.emissiveColor=new u(.95,.45,.95),t.material=s,t.isPickable=!1;let n=p.CreateLines("flow-standpoint-stem",{points:[e,new d(e.x,$.y,e.z)]},w);n.color=new u(.95,.45,.95),n.isPickable=!1}v.runRenderLoop(()=>w.render());let Y=()=>v.resize();window.addEventListener("resize",Y);let Q=(0,F.attachMeshHover)(w,t,P),ee=(0,L.attachDoubleClickFocus)(w,t,V);f("ready"),a=()=>{window.removeEventListener("resize",Y),Q(),ee(),P(null),h.current=null,x.current=null,w.dispose(),v.dispose()}}catch(e){if(s)return;f("error"),v(e instanceof Error?e.message:"Failed to render flow links.")}})(),()=>{s=!0,a?.()}},[Z,n,r,j,y,H,G]),(0,a.useEffect)(()=>{let t=m.current;if(!t||!G)return;if(0===W.ribbons.length)return void f("empty");let s=!1,n=null;return f("loading"),v(null),(async()=>{try{let[{Engine:a},{Scene:r},{ArcRotateCamera:l},{HemisphericLight:i},{Vector3:o,Color3:c,Color4:d},{MeshBuilder:u},{StandardMaterial:m}]=await Promise.all([e.A(66022),e.A(48505),e.A(53976),e.A(42436),e.A(89370),e.A(67141),e.A(20693),e.A(96664)]);if(s)return;let p=new a(t,!0,{preserveDrawingBuffer:!1}),b=new r(p);b.clearColor=new d(.04,.05,.07,1);let v=e=>{let t=k===eu||e.standpointId===k,s=y===eu||eh(e.azimuthBin,e.elevationBin)===y,n=j===eu||e.meshId===j;return t&&s&&n},w=k!==eu||y!==eu||j!==eu,N=new Set;for(let e of W.ribbons)v(e)&&(N.add(e.standpointId),N.add(e.gazeId),N.add(e.meshId));let S={standpoint:[.95,.45,.95],gaze:[.45,.75,1],mesh:[1,.82,.42]},M={standpoint:.26,gaze:.13,mesh:.22},z=[...W.standpoints,...W.gazes,...W.meshes],C=new Map(z.map(e=>[e.id,e.pos])),_=new Map(z.map(e=>[e.id,e.label]));for(let e of z){let t=u.CreateSphere(`ts-node-${e.kind}-${e.id}`,{diameter:M[e.kind],segments:8},b);t.position=new o(e.pos[0],e.pos[1],e.pos[2]);let s=new m(`ts-node-mat-${e.kind}-${e.id}`,b);s.disableLighting=!0;let[n,a,r]=S[e.kind];s.emissiveColor=new c(n,a,r),s.alpha=!w||N.has(e.id)?1:.2,t.material=s,t.isPickable=!0,t.metadata={hoverLabel:e.label}}let $=(e,t,s)=>{let n=e[0],a=e[1],r=e[2],l=t[0],i=t[1],c=t[2],d=[(n+l)/2,(a+i)/2+s,(r+c)/2],u=[];for(let e=0;e<=12;e++){let t=e/12,s=1-t;u.push(new o(s*s*n+2*s*t*d[0]+t*t*l,s*s*a+2*s*t*d[1]+t*t*i,s*s*r+2*s*t*d[2]+t*t*c))}return u};for(let e of W.ribbons){let t=C.get(e.standpointId),s=C.get(e.gazeId),n=C.get(e.meshId);if(!t||!s||!n)continue;let a=e.count/W.maxCount,r=.18+.5*a,l=[...$(t,s,r),...$(s,n,r).slice(1)],i=v(e),[o,d,h]=(0,g.heatRgb)(a),x=u.CreateTube(`ts-link-${e.standpointId}-${e.gazeId}-${e.meshId}`,{path:l,radius:(i?1:.4)*(.012+.04*a),tessellation:8,cap:0,sideOrientation:0},b),p=new m(`ts-link-mat-${e.standpointId}-${e.gazeId}-${e.meshId}`,b);p.disableLighting=!0,p.emissiveColor=new c(o,d,h),p.alpha=i?.35+.65*a:w?.06:.18,x.material=p,x.isPickable=!0,x.metadata={hoverLabel:_.get(e.meshId)??e.meshId}}let I=o.Zero(),A=new l("ts-cam",Math.PI/2,Math.PI/2.4,8.5,I,b);A.attachControl(t,!0),(0,L.disableWheelZoom)(A),h.current=A,x.current={target:I,alpha:A.alpha,beta:A.beta,radius:A.radius},new i("ts-light",new o(.3,1,.2),b),p.runRenderLoop(()=>b.render());let R=()=>p.resize();window.addEventListener("resize",R);let E=(0,F.attachMeshHover)(b,t,P),T=(0,L.attachDoubleClickFocus)(b,t,A);f("ready"),n=()=>{window.removeEventListener("resize",R),E(),T(),P(null),h.current=null,x.current=null,b.dispose(),p.dispose()}}catch(e){if(s)return;f("error"),v(e instanceof Error?e.message:"Failed to render flow links.")}})(),()=>{s=!0,n?.()}},[G,W,k,y,j]),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("canvas",{ref:m,className:"aspect-video w-full rounded-lg border border-edge bg-ink"}),C?(0,s.jsx)("div",{className:"pointer-events-none absolute z-10 max-w-[16rem] truncate rounded border border-edge bg-ink/90 px-1.5 py-0.5 text-xs text-white shadow backdrop-blur",style:{left:C.x+12,top:C.y+12},children:C.label}):null,"ready"===p?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"absolute left-3 top-3 flex flex-wrap gap-2",children:[U?(0,s.jsxs)("div",{className:"flex items-center gap-1 rounded-md border border-edge bg-ink/80 p-0.5 text-xs backdrop-blur",children:[(0,s.jsx)(ef,{active:!G,onClick:()=>z("aggregate"),children:"Aggregate"}),(0,s.jsx)(ef,{active:G,onClick:()=>z("twostage"),children:"Two-stage"})]}):null,R?(0,s.jsxs)("div",{className:"flex items-center gap-1 rounded-md border border-edge bg-ink/80 p-0.5 text-xs backdrop-blur",children:[(0,s.jsx)(ef,{active:"first-person"===_,onClick:()=>$("first-person"),children:"Walk"}),(0,s.jsx)(ef,{active:"viewer"===_,onClick:()=>$("viewer"),disabled:u,title:u?"Orbit (viewer) flow isn't available for walkable scenes":void 0,children:"Orbit"}),(0,s.jsx)(ef,{active:"all"===_,onClick:()=>$("all"),children:"All"})]}):null,U?(0,s.jsx)(eg,{label:"Standpoint",value:k,onChange:S,allLabel:"All standpoints",options:Y}):null,(0,s.jsx)(eg,{label:G?"Gaze":"Source",value:y,onChange:N,allLabel:G?"All gaze sectors":"All sources",options:Q}),(0,s.jsx)(eg,{label:"Mesh",value:j,onChange:w,allLabel:"All meshes",options:ee})]}),G?(0,s.jsx)(eb,{standpoints:O,proxyMeshes:r,selectedKey:k,onSelect:e=>S(t=>t===e?eu:e)}):null,(0,s.jsxs)("div",{className:"pointer-events-none absolute bottom-3 right-3 flex max-w-[20rem] flex-col items-end gap-2",children:[R&&!u?(0,s.jsxs)("div",{className:"rounded-md border border-edge bg-ink/80 px-2 py-1 text-xs text-fg-muted backdrop-blur",children:["Orbit-dominated scene — viewer ",(0,s.jsx)("em",{children:"position"})," adds little here. Use the"," ",(0,s.jsx)("strong",{children:"View dome"})," (§7.5) above for where viewers looked."]}):null,(0,s.jsxs)("div",{className:"rounded-md border border-edge bg-ink/80 px-2 py-1 text-xs text-fg backdrop-blur",children:["Active links: ",q,"/",J]})]}),(0,s.jsx)(B.ZoomButtons,{onZoom:e=>h.current&&(0,L.stepZoom)(h.current,e),onReset:()=>h.current&&x.current&&(0,L.resetFocus)(h.current,x.current)}),(0,s.jsx)(D.HeatLegend,{title:"Flow volume",lowLabel:"fewer links",highLabel:"dominant links",note:G?"Three columns: standpoint → gaze sector → mesh. Top standpoints/meshes are kept; the tail folds into an “Other” node. Pick a standpoint (or click the minimap), gaze sector, or mesh to emphasize matching ribbons.":"Each arc aggregates clicks from one camera-direction bin to a mesh. Pick a source or mesh to emphasize matching links and dim the rest."})]}):(0,s.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-sm text-fg-muted",children:"loading"===p?"Rendering…":"empty"===p?"No aggregate flow links in range.":"error"===p?b??"Flow view unavailable.":null})]})}let ep=(0,s.jsxs)(s.Fragment,{children:["Each ",(0,s.jsx)("strong",{children:"source"})," is a camera ",(0,s.jsx)("em",{children:"gaze-direction bin"})," — a cell on the sphere of where viewers were looking (grouped by azimuth/elevation). Each ",(0,s.jsx)("strong",{children:"target"})," is a"," ",(0,s.jsx)("em",{children:"mesh that was clicked"}),". A ribbon's thickness is how many clicks on that mesh happened while viewers looked from that direction, so you can see which viewpoints drive interaction with which objects. When the scene reports ",(0,s.jsx)("em",{children:"standpoints"}),'(where the viewer stood, §7.8), pick one to gate the flow to clicks made from that vantage — a pin marks it in the scene. "All standpoints" is the aggregate view. Switch to ',(0,s.jsx)("strong",{children:"Two-stage"})," ","for a three-column ",(0,s.jsx)("em",{children:"standpoint → gaze sector → mesh"}),'flow with a birdview minimap; the busiest standpoints/meshes are kept and the tail folds into an "Other" node.']});function eg({label:e,value:t,onChange:n,allLabel:a,options:r}){return(0,s.jsxs)("label",{className:"flex items-center gap-1.5 rounded-md border border-edge bg-ink/80 px-2 py-1 text-xs text-fg backdrop-blur",children:[(0,s.jsx)("span",{className:"font-medium text-fg-muted",children:e}),(0,s.jsxs)("select",{className:"max-w-[12rem] bg-transparent text-white outline-none",value:t,onChange:e=>n(e.target.value),children:[(0,s.jsx)("option",{value:eu,children:a}),r.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]})]})}function ef({active:e,onClick:t,children:n,disabled:a=!1,title:r}){return(0,s.jsx)("button",{type:"button",onClick:t,disabled:a,title:r,className:`rounded px-2 py-0.5 font-medium transition ${a?"cursor-not-allowed text-fg-muted/40":e?"bg-amber text-ink":"text-fg-muted hover:text-fg"}`,children:n})}function eb({standpoints:e,proxyMeshes:t,selectedKey:n,onSelect:r}){let l=(0,a.useRef)(null),i=(0,a.useMemo)(()=>e.filter(e=>e.origin),[e]),o=(0,a.useMemo)(()=>{let e=1/0,s=-1/0,n=1/0,a=-1/0,r=(t,r)=>{e=Math.min(e,t),s=Math.max(s,t),n=Math.min(n,r),a=Math.max(a,r)};for(let e of t)r(e.aabb[0],e.aabb[2]),r(e.aabb[3],e.aabb[5]);for(let e of i)r(e.origin[0],e.origin[2]);return Number.isFinite(e)?(s-e<.001&&(e-=1,s+=1),a-n<.001&&(n-=1,a+=1),{minX:e,maxX:s,minZ:n,maxZ:a}):{minX:-1,maxX:1,minZ:-1,maxZ:1}},[t,i]),c=(0,a.useMemo)(()=>{let e=Math.min(134/(o.maxX-o.minX),94/(o.maxZ-o.minZ));return(t,s)=>[8+(t-o.minX)*e,8+(s-o.minZ)*e]},[o]),d=(0,a.useMemo)(()=>i.reduce((e,t)=>Math.max(e,t.count),1),[i]);return(0,a.useEffect)(()=>{let e=l.current,s=e?.getContext("2d");if(!s)return;let a=window.devicePixelRatio||1;for(let n of(e.width=150*a,e.height=110*a,s.setTransform(a,0,0,a,0,0),s.clearRect(0,0,150,110),s.fillStyle="rgba(8,10,14,0.85)",s.fillRect(0,0,150,110),s.strokeStyle="rgba(120,140,170,0.35)",s.lineWidth=1,t)){let[e,t]=c(n.aabb[0],n.aabb[2]),[a,r]=c(n.aabb[3],n.aabb[5]);s.strokeRect(Math.min(e,a),Math.min(t,r),Math.abs(a-e),Math.abs(r-t))}for(let e of i){let[t,a]=c(e.origin[0],e.origin[2]),r=2+e.count/d*4,l=e.key===n;s.beginPath(),s.arc(t,a,r,0,2*Math.PI),s.fillStyle=l?"rgba(242,115,242,1)":"rgba(242,115,242,0.55)",s.fill(),l&&(s.beginPath(),s.arc(t,a,r+2.5,0,2*Math.PI),s.strokeStyle="rgba(255,255,255,0.9)",s.lineWidth=1.5,s.stroke())}},[t,i,c,d,n]),(0,s.jsxs)("div",{className:"absolute right-3 top-3 rounded-md border border-edge bg-ink/80 p-1 backdrop-blur",children:[(0,s.jsx)("div",{className:"px-1 pb-0.5 text-[10px] font-medium text-fg-muted",children:"Standpoints (top view)"}),(0,s.jsx)("canvas",{ref:l,className:"h-27.5 w-37.5 cursor-pointer rounded",onClick:e=>{let t=l.current;if(!t||0===i.length)return;let s=t.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*150,a=(e.clientY-s.top)/s.height*110,o=null,d=1/0;for(let e of i){let[t,s]=c(e.origin[0],e.origin[2]),r=(t-n)**2+(s-a)**2;r<d&&(d=r,o=e)}o&&d<=196&&r(o.key)}})]})}function ev(e){let t=Math.min(1,Math.max(0,e));return[.118+(.22-.118)*t,.227+.513*t,.541+(.97-.541)*t]}function ej(e){return`${e.vx}|${e.vy}|${e.vz}`}function ew({gazeVoxels:t,clickVoxels:n,cellSize:r,proxyMeshes:l=[]}){let i=(0,a.useRef)(null),o=(0,a.useRef)(null),c=(0,a.useRef)(null),[d,u]=(0,a.useState)("loading"),[m,h]=(0,a.useState)(null),[x,p]=(0,a.useState)("overlay"),[f,b]=(0,a.useState)(null);return(0,a.useEffect)(()=>{let s=i.current;if(!s)return;if(0===t.length&&0===n.length&&0===l.length)return void u("empty");let a=!1,d=null;return u("loading"),h(null),(async()=>{try{let[{Engine:i},{Scene:m},{ArcRotateCamera:h},{HemisphericLight:p},{Vector3:f,Color3:v,Color4:j,Matrix:w},{MeshBuilder:y},{StandardMaterial:N}]=await Promise.all([e.A(66022),e.A(48505),e.A(53976),e.A(42436),e.A(89370),e.A(67141),e.A(20693),e.A(9607),e.A(96664)]);if(a)return;let k=t.reduce((e,t)=>Math.max(e,t.count),1),S=n.reduce((e,t)=>Math.max(e,t.count),1),M=[...t,...n],z=0,C=0,P=0,_=0;for(let e of M)z+=(e.vx+.5)*r,C+=(e.vy+.5)*r,P+=(e.vz+.5)*r,_++;if(0===_)for(let e of l)z+=(e.aabb[0]+e.aabb[3])/2,C+=(e.aabb[1]+e.aabb[4])/2,P+=(e.aabb[2]+e.aabb[5])/2,_++;let $=new f(z/_,C/_,P/_),I=4*r;for(let e of M){let t=(e.vx+.5)*r-$.x,s=(e.vy+.5)*r-$.y,n=(e.vz+.5)*r-$.z;I=Math.max(I,Math.sqrt(t*t+s*s+n*n))}for(let e of l){let t=(e.aabb[0]+e.aabb[3])/2-$.x,s=(e.aabb[1]+e.aabb[4])/2-$.y,n=(e.aabb[2]+e.aabb[5])/2-$.z;I=Math.max(I,Math.sqrt(t*t+s*s+n*n))}let A=new i(s,!0,{preserveDrawingBuffer:!1}),R=new m(A);R.clearColor=new j(.04,.05,.07,1);let E=new h("divergence-cam",Math.PI/4,Math.PI/3,2.4*I,$,R);if(E.attachControl(s,!0),(0,L.disableWheelZoom)(E),o.current=E,c.current={target:$,alpha:E.alpha,beta:E.beta,radius:E.radius},new p("divergence-light",new f(.4,1,.3),R),l.length>0){let e=y.CreateBox("scene-proxy",{size:1},R),t=new N("scene-proxy-mat",R);t.wireframe=!0,t.disableLighting=!0,t.emissiveColor=new v(.32,.4,.52),t.alpha=.35,e.material=t,e.isPickable=!0,e.thinInstanceEnablePicking=!0,e.metadata={hoverLabels:l.map(e=>e.name)};let s=l.length,n=new Float32Array(16*s);for(let e=0;e<s;e++){let t=l[e].aabb,s=Math.max(t[3]-t[0],.001),a=Math.max(t[4]-t[1],.001),r=Math.max(t[5]-t[2],.001);w.Scaling(s,a,r).multiply(w.Translation((t[0]+t[3])/2,(t[1]+t[4])/2,(t[2]+t[5])/2)).copyToArray(n,16*e)}e.thinInstanceSetBuffer("matrix",n,16,!0)}let T=Math.max(.02*I,.25*r)/(.9*r),D=(e,t,s,n,a)=>{if(0===t.length)return;let l=y.CreateSphere(e,{diameter:.9*r,segments:6},R),i=new N(`${e}-mat`,R);i.diffuseColor=new v(1,1,1),i.specularColor=new v(0,0,0),l.material=i,l.metadata={hoverLabel:a};let o=t.length,c=new Float32Array(16*o),d=new Float32Array(4*o);for(let e=0;e<o;e++){let a=t[e],l=a.count/s,i=T*(.5+.5*l);w.Scaling(i,i,i).multiply(w.Translation((a.vx+.5)*r,(a.vy+.5)*r,(a.vz+.5)*r)).copyToArray(c,16*e);let[o,u,m]=n(l);d[4*e]=o,d[4*e+1]=u,d[4*e+2]=m,d[4*e+3]=1}l.thinInstanceSetBuffer("matrix",c,16,!1),l.thinInstanceSetBuffer("color",d,4,!0)};if("divergence"===x){let e=new Map(t.map(e=>[ej(e),e])),s=new Map(n.map(e=>[ej(e),e])),a=new Set([...e.keys(),...s.keys()]),r=[],l=[];for(let t of a){let n=(e.get(t)?.count??0)/k,a=(s.get(t)?.count??0)/S,i=s.get(t)??e.get(t),o=a-n,c={vx:i.vx,vy:i.vy,vz:i.vz,count:1e3*Math.abs(o)};(o>=0?r:l).push(c)}D("div-click",r,1e3,g.heatRgb,"Click-heavy"),D("div-gaze",l,1e3,ev,"Gaze-heavy")}else("overlay"===x||"gaze"===x)&&D("gaze-voxel",t,k,ev,"Gaze"),("overlay"===x||"click"===x)&&D("click-voxel",n,S,g.heatRgb,"Click");A.runRenderLoop(()=>R.render());let B=()=>A.resize();window.addEventListener("resize",B);let O=(0,F.attachMeshHover)(R,s,b),U=(0,L.attachDoubleClickFocus)(R,s,E);u("ready"),d=()=>{window.removeEventListener("resize",B),O(),U(),b(null),o.current=null,c.current=null,R.dispose(),A.dispose()}}catch(e){if(a)return;u("error"),h(e instanceof Error?e.message:"Failed to render overlay.")}})(),()=>{a=!0,d?.()}},[t,n,r,l,x]),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("canvas",{ref:i,className:"aspect-video w-full rounded-lg border border-edge bg-ink"}),f?(0,s.jsx)("div",{className:"pointer-events-none absolute z-10 max-w-64 truncate rounded border border-edge bg-ink/90 px-1.5 py-0.5 text-xs text-white shadow backdrop-blur",style:{left:f.x+12,top:f.y+12},children:f.label}):null,"ready"===d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"absolute left-3 top-3 flex items-center gap-1 rounded-md border border-edge bg-ink/80 p-0.5 text-xs backdrop-blur",children:[(0,s.jsx)(eN,{active:"overlay"===x,onClick:()=>p("overlay"),children:"Overlay"}),(0,s.jsx)(eN,{active:"gaze"===x,onClick:()=>p("gaze"),children:"Gaze"}),(0,s.jsx)(eN,{active:"click"===x,onClick:()=>p("click"),children:"Clicks"}),(0,s.jsx)(eN,{active:"divergence"===x,onClick:()=>p("divergence"),children:"Divergence"})]}),(0,s.jsx)(B.ZoomButtons,{onZoom:e=>o.current&&(0,L.stepZoom)(o.current,e),onReset:()=>o.current&&c.current&&(0,L.resetFocus)(o.current,c.current)}),(0,s.jsx)(ey,{mode:x})]}):(0,s.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-sm text-fg-muted",children:"loading"===d?"Rendering…":"empty"===d?"No gaze or click hit-points in range. Enable gaze + pointer capture in the SDK.":"error"===d?m??"Overlay unavailable.":null})]})}function ey({mode:e}){return(0,s.jsxs)("div",{className:"absolute bottom-3 right-3 max-w-72 rounded-md border border-edge bg-ink/80 px-2 py-1.5 text-xs text-fg backdrop-blur",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-sm bg-[#38bdf8]"}),"divergence"===e?"Gaze-heavy":"Gaze"]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-sm bg-[#f4c84b]"}),"divergence"===e?"Click-heavy":"Clicks"]})]}),(0,s.jsx)("p",{className:"mt-1 text-fg-muted",children:"divergence"===e?"Per-voxel normalized difference: which signal dominates each cell. Color & size scale with the gap.":"Gaze = where viewers looked; Clicks = where they acted. Cells with gaze but no clicks are looked-at but un-acted-on."})]})}function eN({active:e,onClick:t,children:n}){return(0,s.jsx)("button",{type:"button",onClick:t,className:`rounded px-2 py-0.5 font-medium transition ${e?"bg-amber text-ink":"text-fg-muted hover:text-fg"}`,children:n})}let ek={orbit:"Orbit",pan:"Pan",dolly:"Dolly",zoom:"Zoom",roll:"Roll",fly:"Fly",navigate:"Navigate"};function eS({stats:e}){let t=[...e].sort((e,t)=>t.gestures-e.gestures),n=t.reduce((e,t)=>e+t.gestures,0),a=t.reduce((e,t)=>Math.max(e,t.gestures),0);return 0===t.length||0===n?(0,s.jsxs)("p",{className:"text-sm text-fg-muted",children:["No camera-navigation gestures in range. Enable ",(0,s.jsx)("code",{children:"cameraGesture"})," capture in the SDK (on by default for Babylon) to populate this."]}):(0,s.jsx)("ul",{className:"space-y-3",children:t.map(e=>{var t,r;let l=n>0?e.gestures/n*100:0;return(0,s.jsxs)("li",{className:"text-sm",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{className:"font-medium text-fg",children:ek[t=e.kind]??t.charAt(0).toUpperCase()+t.slice(1)}),(0,s.jsxs)("span",{className:"tabular-nums text-fg-muted",children:[b(e.gestures),(0,s.jsxs)("span",{className:"ml-1 text-xs text-fg-muted",children:["· ",l.toFixed(0),"%"]}),(0,s.jsxs)("span",{className:"ml-2 text-xs text-fg-muted",children:["avg ",!Number.isFinite(r=e.avg_ms)||r<=0?"0 ms":r<1e3?`${Math.round(r)} ms`:`${(r/1e3).toFixed(r<1e4?2:1)} s`]})]})]}),(0,s.jsx)("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded bg-ink/60",children:(0,s.jsx)("div",{className:"h-full rounded bg-amber",style:{width:`${a>0?e.gestures/a*100:0}%`}})})]},e.kind)})})}let eM="#161210",ez={fontSize:13,color:"#a8917c"},eC={padding:"6px 10px",fontSize:13,borderTop:"1px solid #34291f"};function eP({sessions:e,onSelect:t,selectedId:n}){return 0===e.length?(0,s.jsx)("p",{style:ez,children:"No sessions in range."}):(0,s.jsx)("div",{style:{maxHeight:320,overflow:"auto"},children:(0,s.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",textAlign:"left"},children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{style:{fontSize:11,textTransform:"uppercase",color:"#a8917c"},children:[(0,s.jsx)("th",{style:{padding:"6px 10px"},children:"Session"}),(0,s.jsx)("th",{style:{padding:"6px 10px"},children:"Visitor"}),(0,s.jsx)("th",{style:{padding:"6px 10px",textAlign:"right"},children:"Events"}),(0,s.jsx)("th",{style:{padding:"6px 10px"},children:"Started"})]})}),(0,s.jsx)("tbody",{children:e.map(e=>{var a;let r,l=e.session_id===n;return(0,s.jsxs)("tr",{onClick:t?()=>t(e.session_id):void 0,style:{cursor:t?"pointer":"default",background:l?"rgba(237,166,62,0.15)":void 0},children:[(0,s.jsx)("td",{style:{...eC,fontFamily:"ui-monospace, monospace",color:"#d8c8b8"},children:e.session_id.slice(0,12)}),(0,s.jsx)("td",{style:{...eC,fontFamily:"ui-monospace, monospace",color:"#a8917c"},children:e.visitor_id.slice(0,8)}),(0,s.jsx)("td",{style:{...eC,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:b(e.events)}),(0,s.jsx)("td",{style:{...eC,fontSize:12,color:"#a8917c"},children:Number.isNaN((r=new Date((a=e.started_at).includes("T")?a:a.replace(" ","T")+"Z")).getTime())?a:r.toLocaleString()})]},e.session_id)})})]})})}function e_({bins:e,gridSize:t,size:n=320,className:r,style:l}){let i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let s=i.current;if(!s)return;let a=s.getContext("2d");a&&function(e,t,s,n){if(e.clearRect(0,0,n,n),e.fillStyle=eM,e.fillRect(0,0,n,n),0===t.length)return;let a=t.reduce((e,t)=>Math.max(e,t.count),0),r=n/s;for(let s of t)e.fillStyle=f(a>0?s.count/a:0,.85),e.fillRect(s.gx*r,s.gy*r,Math.ceil(r),Math.ceil(r))}(a,e,t,n)},[e,t,n]),(0,s.jsx)("canvas",{ref:i,width:n,height:n,className:r,style:l,"aria-label":"Pointer heatmap"})}function e$({bins:e,gridSize:t,size:n=340,className:r,style:l}){let i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let s=i.current;if(!s)return;let a=s.getContext("2d");if(!a)return;let r=Math.min(window.devicePixelRatio||1,2);s.width=n*r,s.height=n*r,a.setTransform(r,0,0,r,0,0),function(e,t,s,n){let a=n/2,r=n/2,l=n/2-18;if(e.clearRect(0,0,n,n),e.fillStyle=eM,e.fillRect(0,0,n,n),e.strokeStyle="#34291f",e.lineWidth=1,e.beginPath(),e.arc(a,r,l,0,2*Math.PI),e.stroke(),e.beginPath(),e.arc(a,r,l/2,0,2*Math.PI),e.stroke(),t.length>0){let n=t.reduce((e,t)=>Math.max(e,t.count),0),i=2*Math.PI/s;for(let o of t){let t=n>0?o.count/n:0,c=1-(o.elevation_bin+1)/s,d=1-o.elevation_bin/s,u=Math.max(0,c)*l,m=Math.max(0,d)*l,h=o.azimuth_bin*i,x=h+i;e.beginPath(),e.arc(a,r,m,h,x),e.arc(a,r,u,x,h,!0),e.closePath(),e.fillStyle=f(t,.85),e.fill()}}let i=(t,s,n)=>{e.lineWidth=3,e.strokeStyle="rgba(22,18,16,0.9)",e.strokeText(t,s,n),e.fillStyle="#d8c8b8",e.fillText(t,s,n)};for(let t of(e.font="600 10px ui-sans-serif, system-ui, sans-serif",e.textAlign="left",e.textBaseline="middle",e.strokeStyle="rgba(203,213,225,0.35)",e.lineWidth=1,e.beginPath(),e.moveTo(a,r),e.lineTo(a,r-l),e.stroke(),[0,l/2,l]))e.beginPath(),e.moveTo(a-3,r-t),e.lineTo(a+3,r-t),e.stroke();i("up",a+6,r),i("horizon",a+6,r-l/2),i("down",a+6,r-l+2)}(a,e,t,n)},[e,t,n]),(0,s.jsx)("canvas",{ref:i,className:r,style:{width:n,height:n,...l},"aria-label":"Camera view-direction heatmap: top-down polar plot where the center is looking up, the middle ring is the horizon, and the rim is looking down; color shows how often each direction was viewed."})}let eI={background:"rgba(32,25,19,0.6)",borderRadius:8,padding:12},eA={fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"#a8917c"},eR={marginTop:4,fontSize:24,fontWeight:600,color:"#f4eadf",fontVariantNumeric:"tabular-nums"};function eE({label:e,value:t}){return(0,s.jsxs)("div",{style:eI,children:[(0,s.jsx)("div",{style:eA,children:e}),(0,s.jsx)("div",{style:eR,children:t})]})}function eT({perf:e}){return e&&0!==e.samples?(0,s.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:12},children:[(0,s.jsx)(eE,{label:"Samples",value:b(e.samples)}),(0,s.jsx)(eE,{label:"Avg FPS",value:b(e.avg_fps,1)}),(0,s.jsx)(eE,{label:"p50 FPS",value:b(e.p50_fps,1)}),(0,s.jsx)(eE,{label:"Min FPS",value:b(e.min_fps,1)})]}):(0,s.jsx)("p",{style:ez,children:"No performance samples in range."})}function eL({bins:e,gridSize:t}){return(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(e_,{bins:e,gridSize:t,className:"rounded-lg border border-edge"})})}function eF({meshes:e}){let t=e.reduce((e,t)=>Math.max(e,t.count),0);return 0===e.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No mesh interactions in range."}):(0,s.jsx)("ul",{className:"space-y-1.5",children:e.map(e=>(0,s.jsxs)("li",{className:"text-sm",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{className:"truncate font-mono text-xs text-fg",children:e.mesh}),(0,s.jsx)("span",{className:"tabular-nums text-fg-muted",children:b(e.count)})]}),(0,s.jsx)("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded bg-ink/60",children:(0,s.jsx)("div",{className:"h-full rounded bg-amber",style:{width:`${t>0?e.count/t*100:0}%`}})})]},e.mesh))})}var eD=e.i(38413);function eB(e){return"session"===e.surface&&e.sessionId?{...e.params,session:e.sessionId}:e.params}async function eO(e){let t=e.params.scene;if(t){let s=await e.api.sceneRepresentation(t).catch(()=>null);return s?.proxy?.meshes??[]}return(0,v.mergeSceneProxies)(e.api,e.params)}let eU=[{id:"top-meshes",title:"Top meshes",subtitle:"Most-interacted meshes",span:1,surfaces:["overview","session"],settings:{limit:{type:"number",label:"Top N",help:"How many meshes to rank in the list.",default:25,min:5,max:100,step:5}},load:e=>e.api.topMeshes({...eB(e),source:void 0,scene:void 0,limit:e.settings.limit}),render:({data:e})=>(0,s.jsx)(eF,{meshes:e??[]})},{id:"mesh-leaderboard",title:"Part-popularity leaderboard",subtitle:"Ranked meshes, with trend and input split",help:"The most-interacted meshes ranked by total active interactions (clicks / hovers / picks / drags — passive gaze is excluded), each with a trend sparkline (rising/falling over the range) and an input-source split (mouse / touch / XR / …). Expand a row to see which sources drove it. Unlike the plain Top-meshes list, gaze-only hits don't inflate the ranking.",span:1,surfaces:["overview","session"],load:async e=>{let[t,s]=await Promise.all([e.api.topMeshesBySource({...eB(e),source:void 0,limit:400}),e.api.topMeshesTrend({...eB(e),source:void 0,interval:function(e){let{since:t,until:s}=e.params;return null==t||null==s||s<=t?3600:h(s-t,24)}(e),limit:2e3})]);return{sources:t,trend:s}},render:({data:e})=>(0,s.jsx)(J,{sources:e.sources??[],trend:e.trend??[]})},{id:"pointer-heatmap",title:"Pointer heatmap",subtitle:"Normalized screen positions",span:1,surfaces:["overview","session"],clientOnly:!0,settings:{bins:{type:"number",label:"Grid resolution",help:"Bins per axis for the 2D pointer grid. More bins sharpen detail; fewer smooth the heat.",default:50,min:10,max:120,step:10}},load:e=>e.api.pointerHeatmap({...eB(e),bins:e.settings.bins}),render:({data:e,ctx:t})=>(0,s.jsx)(eL,{bins:e??[],gridSize:t.settings.bins})},{id:"camera-dome-3d",title:"View-direction dome (3D)",subtitle:"Where the audience looked, mapped onto a sphere — drag to orbit, +/- to zoom, double-click to focus",span:2,surfaces:["overview","session"],clientOnly:!0,settings:{bins:{type:"number",label:"Direction resolution",help:"Angular bins for the view-direction dome. More bins resolve finer look-directions; fewer aggregate them.",default:36,min:12,max:72,step:6}},load:e=>e.api.cameraHeatmap({...eB(e),source:void 0,bins:e.settings.bins}),render:({data:e,ctx:t})=>(0,s.jsx)(O,{bins:e??[],gridSize:t.settings.bins})},{id:"floor-plan",title:"Floor-plan heatmap",subtitle:"Where visitors stand (top-down, first-person)",help:"Camera positions binned on the ground plane — the first-person counterpart of the pointer heatmap. Filter to the first-person camera mode to isolate walkable sessions.",span:1,surfaces:["overview","session"],clientOnly:!0,settings:{cellSize:{type:"number",label:"Cell size",help:"Ground-plane bin size in world units. Larger cells smooth the dwell heat; smaller cells sharpen spatial resolution.",default:1,min:.25,max:5,step:.25,unit:"m"}},enabled:e=>"viewer"!==e.filters.cameraMode,load:e=>e.api.cameraPositionHeatmap({...eB(e),cellSize:e.settings.cellSize}),render:({data:e,ctx:t})=>(0,s.jsx)(U,{bins:e??[],cellSize:t.settings.cellSize})},{id:"desire-lines",title:"Desire lines",subtitle:"The routes visitors actually walk",help:"Every session's camera path, binned onto the ground plane and overlaid as a faint poly-line. Where many visitors walk the same way the lines pile up into bright 'desire lines' — the routes people take vs. the ones the scene intended. Filter to the first-person camera mode to isolate walkable sessions.",span:1,surfaces:["overview"],clientOnly:!0,enabled:e=>"viewer"!==e.filters.cameraMode,load:e=>e.api.aggregatePaths({...eB(e),cellSize:1}),render:({data:e})=>(0,s.jsx)(H,{points:e??[]})},{id:"mesh-interaction-kinds",title:"Interaction kinds",subtitle:"How visitors act on each mesh",help:"Per-mesh breakdown of interaction kinds (hover, pick, click, drag, …) from mesh_interaction events. The dwell ranking says which objects draw attention; this says how people act on them — a hovered-but-never-picked mesh reads very differently from a dragged one.",span:1,surfaces:["overview","session"],load:e=>e.api.meshKinds({...eB(e),limit:200}),render:({data:e})=>(0,s.jsx)(V,{rows:e??[]})},{id:"input-modality-split",title:"Input-modality split",subtitle:"Keyboard / gamepad / touch / XR — and top shortcuts",help:"How visitors drive the experience: the share of interactions per input source (mouse / touch / keyboard / gamepad / XR), from the input-source breakdown (ADR 0011), paired with the most-used app-level shortcuts/actions from input_action events (ADR 0023).",span:1,surfaces:["overview","session"],load:async e=>{let[t,s]=await Promise.all([e.api.interactionsBySource({...eB(e),source:void 0,limit:100}),e.api.topInputActions({...eB(e),source:void 0,limit:50})]);return{sources:t,actions:s}},render:({data:e})=>(0,s.jsx)(ee,{sources:e.sources??[],actions:e.actions??[]})},{id:"render-scale-truth",title:"Render-scale truth",subtitle:"Is that FPS real, or downscaled?",help:"Adaptive renderers keep frame rate up by quietly dropping resolution. This pairs the FPS headline with the render scale that bought it, and flags the 'good FPS at a low render scale' case where the headline overstates the real device experience.",span:1,surfaces:["overview","session"],load:e=>e.api.renderScale(eB(e)),render:({data:e})=>(0,s.jsx)(el,{data:e})},{id:"perf-distribution",title:"Performance distribution",subtitle:"p05 / p50 / p95 FPS bands, not just the average",help:"The shape of rendering performance, not a single average: p05 (worst), p50 (typical) and p95 (best) FPS computed per-session then aggregated (ADR 0028 §1), plus a histogram of per-session median FPS. One session contributes one data point, so a few chatty sessions can't skew the curve.",span:1,surfaces:["overview","session"],load:async e=>{let[t,s]=await Promise.all([e.api.perfDistribution(eB(e)),e.api.fpsHistogram(eB(e))]);return{distribution:t,histogram:s}},render:({data:e})=>(0,s.jsx)(ea,{distribution:e.distribution,histogram:e.histogram??[]})},{id:"world-heatmap-3d",title:eD.WORLD_HEATMAP_TITLE,subtitle:eD.WORLD_HEATMAP_SUBTITLE,span:2,surfaces:["overview","session"],clientOnly:!0,settings:{cellSize:{type:"number",label:"Voxel size",help:"World-space voxel size for binning pointer hits. Larger voxels smooth the heat; smaller ones sharpen spatial detail.",default:.5,min:.1,max:2,step:.1,unit:"m"}},load:async e=>{let[t,s,n]=await Promise.all([e.api.worldHeatmap({...eB(e),cellSize:e.settings.cellSize}),eO(e),e.api.worldHeatmapStats({...eB(e),cellSize:e.settings.cellSize})]);return{voxels:t,proxyMeshes:s,totals:{cells:n.cells,hits:n.hits}}},render:({data:e,ctx:t})=>(0,s.jsx)(eD.WorldHeatmap3DView,{voxels:e.voxels,cellSize:t.settings.cellSize,proxyMeshes:e.proxyMeshes,totals:e.totals})},{id:"navigation-mix",title:"Navigation-style mix",subtitle:"Orbit / pan / dolly / zoom / roll / fly share + avg gesture duration",span:1,surfaces:["overview","session"],load:e=>e.api.cameraGestures({...eB(e),source:void 0}),render:({data:e})=>(0,s.jsx)(eS,{stats:e??[]})},{id:"dead-zone-report",title:"Dead-zone report",subtitle:"Scene parts visitors never approach",help:"The negative space: registered proxy meshes (ADR 0014) with near-zero camera proximity, computed by subtracting the occupied camera-position voxels (scene coverage) from the scene's proxy geometry. Ranked coldest first. Requires a registered scene proxy to know which regions could be visited.",span:1,surfaces:["overview","session"],load:async e=>{let[t,s]=await Promise.all([e.api.coverage({...eB(e),cellSize:1}),eO(e)]);return{coverage:t,proxyMeshes:s}},render:({data:e})=>(0,s.jsx)(et,{coverage:e.coverage??[],proxyMeshes:e.proxyMeshes??[],cellSize:1})},{id:"flow-sankey-3d",title:"Flow Sankey (3D)",subtitle:"Direction-bin → mesh links (aggregate), or standpoint → gaze → mesh (two-stage) — double-click to focus",help:ep,span:2,surfaces:["overview","session"],clientOnly:!0,settings:{maxLinks:{type:"number",label:"Max links",help:"Maximum aggregate flow links drawn before the panel caps for legibility.",default:80,min:10,max:200,step:10}},load:async e=>{let t={...eB(e),cameraMode:void 0},[s,n]=await Promise.all([e.api.flowHeatmap({...t,bins:36,limit:400,groupByOrigin:!0}),eO(e)]);return{links:s,proxyMeshes:n,flowQuery:t}},render:({data:e,ctx:t})=>(0,s.jsx)(ex,{links:e.links,gridSize:36,proxyMeshes:e.proxyMeshes,maxLinks:t.settings.maxLinks,baseUrl:t.baseUrl,apiKey:t.apiKey,flowQuery:e.flowQuery,hasFirstPerson:t.capabilities.hasFirstPerson})},{id:"gaze-click-divergence-3d",title:"Gaze vs. click divergence",subtitle:"Where viewers look (gaze) vs. where they act (clicks), voxel-binned in world space — double-click to focus",span:2,surfaces:["overview","session"],clientOnly:!0,settings:{cellSize:{type:"number",label:"Voxel size",help:"Shared world-space voxel size for both the gaze and click grids, so the divergence field stays aligned.",default:.5,min:.1,max:2,step:.1,unit:"m"}},load:async e=>{let[t,s,n]=await Promise.all([e.api.gazeHeatmap({...eB(e),source:void 0,cellSize:e.settings.cellSize}),e.api.worldHeatmap({...eB(e),cellSize:e.settings.cellSize}),eO(e)]);return{gaze:t,click:s,proxyMeshes:n}},render:({data:e,ctx:t})=>(0,s.jsx)(ew,{gazeVoxels:e.gaze,clickVoxels:e.click,cellSize:t.settings.cellSize,proxyMeshes:e.proxyMeshes})}];function eH(e){return e?e.split(",").map(e=>e.trim()).filter(e=>e.length>0):[]}let eW={panels:[],errors:[],loading:!1};function eG({errors:e}){let[t,n]=(0,a.useState)(!1);return 0===e.length||t?null:(0,s.jsxs)("section",{className:"rounded-xl border border-dashed border-amber/60 bg-panel/60 px-4 py-3 text-xs text-fg-muted",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("span",{className:"font-medium uppercase tracking-wide text-fg",children:[e.length," panel",1===e.length?"":"s"," failed to load"]}),(0,s.jsx)("button",{type:"button",onClick:()=>n(!0),className:"text-fg-muted underline-offset-2 transition hover:text-amber hover:underline",children:"Dismiss"})]}),(0,s.jsx)("ul",{className:"mt-2 space-y-1",children:e.map((e,t)=>(0,s.jsxs)("li",{className:"font-mono",children:[(0,s.jsx)("span",{className:"text-fg",children:e.source}),(0,s.jsxs)("span",{className:"text-fg-muted",children:[" ","— [",e.code,"] ",e.message]})]},`${e.source}-${t}`))})]})}function eV({bins:e,gridSize:t}){return(0,s.jsx)(P.Panel,{title:"View-direction heatmap",subtitle:"Top-down sphere — center = looking up, rim = looking down",help:(0,s.jsxs)(s.Fragment,{children:["A flattened top-down view of where the camera pointed."," ",(0,s.jsx)("strong",{children:"Distance from the center"})," is the up/down tilt: the ",(0,s.jsx)("strong",{children:"center"})," ","is looking straight up, the ",(0,s.jsx)("strong",{children:"middle ring"})," is the horizon (level), and the"," ",(0,s.jsx)("strong",{children:"outer rim"})," is looking straight down. The"," ",(0,s.jsx)("strong",{children:"angle around the disc"})," is the facing (azimuth) direction. Color shows how often each direction was viewed, normalized to the most-viewed direction in range."]}),children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,s.jsx)(e$,{bins:e,gridSize:t,className:"rounded-lg border border-edge"}),e.length>0?(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-fg-muted",children:[(0,s.jsx)("span",{className:"font-medium text-fg",children:"View density"}),(0,s.jsx)("span",{children:"rarely"}),(0,s.jsx)("span",{className:"h-2 w-28 rounded-sm",style:{background:g.HEAT_GRADIENT}}),(0,s.jsx)("span",{children:"most-viewed"})]}):null]})})}function eZ(e){return null==e?"":new Date(e-6e4*new Date(e).getTimezoneOffset()).toISOString().slice(0,16)}function eK(e){if(!e)return;let t=new Date(e).getTime();return Number.isNaN(t)?void 0:t}function eX({filters:e,scenes:t,onChange:n,busy:a}){let r=t=>n({...e,...t});return(0,s.jsxs)("section",{className:"mb-6 flex flex-wrap items-end gap-x-4 gap-y-3 rounded-xl border border-edge bg-panel p-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-xs text-fg-muted",children:"Time window"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",role:"group","aria-label":"Time window",children:[o.map(t=>{let n=e.window===t.id;return(0,s.jsx)("button",{type:"button",onClick:()=>r({window:t.id}),className:`rounded-md border px-2.5 py-1.5 text-xs transition ${n?"border-amber bg-amber/10 text-saffron":"border-edge text-fg hover:border-amber/60 hover:text-fg-hi"}`,children:t.label},t.id)}),(0,s.jsx)("button",{type:"button",onClick:()=>r({window:"custom",since:e.since??Date.now()-864e5,until:e.until??Date.now()}),className:`rounded-md border px-2.5 py-1.5 text-xs transition ${"custom"===e.window?"border-amber bg-amber/10 text-saffron":"border-edge text-fg hover:border-amber/60 hover:text-fg-hi"}`,children:"Custom"})]})]}),"custom"===e.window?(0,s.jsxs)("div",{className:"flex items-end gap-2",children:[(0,s.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["From",(0,s.jsx)("input",{type:"datetime-local",value:eZ(e.since),onChange:e=>r({since:eK(e.target.value)}),className:"rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron"})]}),(0,s.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["To",(0,s.jsx)("input",{type:"datetime-local",value:eZ(e.until),onChange:e=>r({until:eK(e.target.value)}),className:"rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron"})]})]}):null,(0,s.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["Scene",(0,s.jsxs)("select",{value:e.scene??"",onChange:e=>r({scene:e.target.value||void 0}),className:"min-w-40 rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron",children:[(0,s.jsx)("option",{value:"",children:"All scenes"}),t.map(e=>(0,s.jsxs)("option",{value:e.scene_id,children:[e.scene_id," (",e.events.toLocaleString(),")"]},e.scene_id))]})]}),(0,s.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["Input source",(0,s.jsxs)("select",{value:e.source??"",onChange:e=>r({source:e.target.value||void 0}),className:"min-w-36 rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron",children:[(0,s.jsx)("option",{value:"",children:"All sources"}),p.map(e=>(0,s.jsx)("option",{value:e,children:x(e)},e))]})]}),(0,s.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["Camera mode",(0,s.jsxs)("select",{value:e.cameraMode??"",onChange:e=>r({cameraMode:e.target.value||void 0}),className:"min-w-36 rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron",children:[(0,s.jsx)("option",{value:"",children:"All cameras"}),(0,s.jsx)("option",{value:"viewer",children:"Viewer (orbit)"}),(0,s.jsx)("option",{value:"first-person",children:"First-person (walk)"})]})]}),(0,s.jsx)("span",{className:`ml-auto text-xs ${a?"text-saffron":"text-fg-muted"}`,"aria-live":"polite",children:a?"Refreshing…":"Up to date"})]})}function eq({rows:e}){let t=function(e){let t=new Map;for(let s of e){let e=t.get(s.source);e||(e={source:s.source,total:0,sessions:0,byType:[]},t.set(s.source,e)),e.total+=s.count,e.sessions=Math.max(e.sessions,s.sessions),e.byType.push({event_type:s.event_type,count:s.count})}for(let e of t.values())e.byType.sort((e,t)=>t.count-e.count);return[...t.values()].sort((e,t)=>t.total-e.total)}(e),n=t.reduce((e,t)=>Math.max(e,t.total),0);return(0,s.jsx)(P.Panel,{title:"Input sources",subtitle:"Interactions by input source",children:0===t.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No source-bearing interactions in range."}):(0,s.jsx)("ul",{className:"space-y-3",children:t.map(e=>(0,s.jsxs)("li",{className:"text-sm",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{className:"font-medium text-fg",children:x(e.source)}),(0,s.jsxs)("span",{className:"tabular-nums text-fg-muted",children:[b(e.total),(0,s.jsxs)("span",{className:"ml-1 text-xs text-fg-muted",children:["· ",b(e.sessions)," ",1===e.sessions?"session":"sessions"]})]})]}),(0,s.jsx)("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded bg-ink/60",children:(0,s.jsx)("div",{className:"h-full rounded bg-amber",style:{width:`${n>0?e.total/n*100:0}%`}})}),(0,s.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:e.byType.map(e=>{let t;return(0,s.jsxs)("span",{className:"rounded bg-ink/60 px-1.5 py-0.5 font-mono text-[11px] text-fg-muted",children:[(t=e.event_type.replace(/_/g," ")).charAt(0).toUpperCase()+t.slice(1)," ",b(e.count)]},e.event_type)})})]},e.source))})})}function eJ({perf:e}){return(0,s.jsx)(P.Panel,{title:"Rendering performance",subtitle:"frame_perf samples",children:(0,s.jsx)(eT,{perf:e})})}function eY({label:e,value:t,unit:n}){return(0,s.jsxs)("div",{className:"rounded-lg bg-ink/60 p-3",children:[(0,s.jsx)("div",{className:"text-xs uppercase tracking-wide text-fg-muted",children:e}),(0,s.jsxs)("div",{className:"mt-1 text-2xl font-semibold tabular-nums text-fg-hi",children:[t,n?(0,s.jsx)("span",{className:"ml-1 text-sm font-normal text-fg-muted",children:n}):null]})]})}function eQ(e){return b(e/1048576,1)}function e0({bins:e}){if(0===e.length)return(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No FPS samples in range."});let t=[...e].sort((e,t)=>e.bucket-t.bucket),n=t.reduce((e,t)=>Math.max(e,t.sessions),0)||1,a=t.length>1?t[1].bucket-t[0].bucket:10;return(0,s.jsx)("div",{className:"space-y-1.5",children:t.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,s.jsxs)("span",{className:"w-16 shrink-0 text-right tabular-nums text-fg-muted",children:[e.bucket,"–",e.bucket+a]}),(0,s.jsx)("div",{className:"h-4 flex-1 overflow-hidden rounded bg-ink/60",children:(0,s.jsx)("div",{className:"h-full rounded bg-emerald-500/70",style:{width:`${e.sessions/n*100}%`}})}),(0,s.jsx)("span",{className:"w-10 shrink-0 tabular-nums text-fg-muted",children:e.sessions})]},e.bucket))})}function e1({data:e}){let{distribution:t,histogram:n,frameTime:a,jank:r,byDevice:l,byScene:i,resources:o,stability:c}=e,d=(t?.samples??0)>0;return(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsx)("h2",{className:"text-sm font-semibold uppercase tracking-wide text-fg-muted",children:"Performance"}),(0,s.jsx)(P.Panel,{title:"FPS distribution",subtitle:"per-session p05 / p50 / p95, summarized across sessions",children:d?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,s.jsx)(eY,{label:"p05 FPS (worst)",value:b(t.p05_fps,1)}),(0,s.jsx)(eY,{label:"p50 FPS (typical)",value:b(t.p50_fps,1)}),(0,s.jsx)(eY,{label:"p95 FPS (best)",value:b(t.p95_fps,1)}),(0,s.jsx)(eY,{label:"Sessions",value:b(t.sessions)})]}),(0,s.jsx)(e0,{bins:n})]}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No performance samples in range."})}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,s.jsx)(P.Panel,{title:"Frame time",subtitle:"per-session median & worst-window p95",children:a&&0!==a.sessions?(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(eY,{label:"p50 frame time",value:b(a.p50_ms,1),unit:"ms"}),(0,s.jsx)(eY,{label:"p95 frame time",value:b(a.p95_ms,1),unit:"ms"})]}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No frame-time samples in range."})}),(0,s.jsx)(P.Panel,{title:"Jank",subtitle:"long frames per sample window",children:r&&0!==r.sessions?(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(eY,{label:"Median session",value:b(r.median_rate,2)}),(0,s.jsx)(eY,{label:"Worst decile",value:b(r.worst_decile_rate,2)})]}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No jank data in range."})})]}),(0,s.jsx)(P.Panel,{title:"FPS by device",subtitle:"per-session median FPS, by session_start.device + UA-derived browser/OS",children:0===l.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No device data in range."}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,s.jsx)("thead",{className:"text-xs uppercase tracking-wide text-fg-muted",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"py-1 pr-4 font-medium",children:"Backend"}),(0,s.jsx)("th",{className:"py-1 pr-4 font-medium",children:"Browser"}),(0,s.jsx)("th",{className:"py-1 pr-4 font-medium",children:"OS"}),(0,s.jsx)("th",{className:"py-1 pr-4 font-medium",children:"Mobile"}),(0,s.jsx)("th",{className:"py-1 pr-4 font-medium",children:"GPU"}),(0,s.jsx)("th",{className:"py-1 pr-4 text-right font-medium",children:"Sessions"}),(0,s.jsx)("th",{className:"py-1 text-right font-medium",children:"p50 FPS"})]})}),(0,s.jsx)("tbody",{className:"text-fg",children:l.map((e,t)=>(0,s.jsxs)("tr",{className:"border-t border-ink/60",children:[(0,s.jsx)("td",{className:"py-1 pr-4",children:e.engine||"—"}),(0,s.jsx)("td",{className:"py-1 pr-4",children:e.browser||"—"}),(0,s.jsx)("td",{className:"py-1 pr-4",children:e.os||"—"}),(0,s.jsx)("td",{className:"py-1 pr-4",children:"true"===e.is_mobile?"yes":"no"}),(0,s.jsx)("td",{className:"py-1 pr-4 max-w-[16rem] truncate",title:e.renderer,children:e.renderer||"—"}),(0,s.jsx)("td",{className:"py-1 pr-4 text-right tabular-nums",children:b(e.sessions)}),(0,s.jsx)("td",{className:"py-1 text-right tabular-nums",children:b(e.p50_fps,1)})]},`${e.engine}|${e.browser}|${e.os}|${e.is_mobile}|${e.renderer}|${t}`))})]})})}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,s.jsx)(P.Panel,{title:"FPS by scene",subtitle:"per-session median FPS per scene",children:0===i.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No scene data in range."}):(0,s.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,s.jsx)("thead",{className:"text-xs uppercase tracking-wide text-fg-muted",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"py-1 pr-4 font-medium",children:"Scene"}),(0,s.jsx)("th",{className:"py-1 pr-4 text-right font-medium",children:"Sessions"}),(0,s.jsx)("th",{className:"py-1 text-right font-medium",children:"p50 FPS"})]})}),(0,s.jsx)("tbody",{className:"text-fg",children:i.map(e=>(0,s.jsxs)("tr",{className:"border-t border-ink/60",children:[(0,s.jsx)("td",{className:"py-1 pr-4",children:e.scene_id||"—"}),(0,s.jsx)("td",{className:"py-1 pr-4 text-right tabular-nums",children:b(e.sessions)}),(0,s.jsx)("td",{className:"py-1 text-right tabular-nums",children:b(e.p50_fps,1)})]},e.scene_id))})]})}),(0,s.jsx)(P.Panel,{title:"Stability",subtitle:"hard failures frame_perf can't show",children:c?(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,s.jsx)(eY,{label:"Context losses",value:b(c.context_losses)}),(0,s.jsx)(eY,{label:"Compile stalls",value:b(c.compile_stalls)}),(0,s.jsx)(eY,{label:"Incidents",value:b(c.incidents)})]}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No stability data in range."})})]}),(0,s.jsx)(P.Panel,{title:"Resource footprint",subtitle:"per-session p50 / p95 of what the scene asked of the device",children:o&&0!==o.sessions?(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[(0,s.jsx)(eY,{label:"p50 JS heap",value:eQ(o.p50_js_heap_bytes),unit:"MB"}),(0,s.jsx)(eY,{label:"p50 texture",value:eQ(o.p50_texture_bytes),unit:"MB"}),(0,s.jsx)(eY,{label:"p50 triangles",value:b(o.p50_triangles)}),(0,s.jsx)(eY,{label:"p95 JS heap",value:eQ(o.p95_js_heap_bytes),unit:"MB"}),(0,s.jsx)(eY,{label:"p95 texture",value:eQ(o.p95_texture_bytes),unit:"MB"}),(0,s.jsx)(eY,{label:"p95 triangles",value:b(o.p95_triangles)})]}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No resource samples in range."})})]})}function e2({label:e,value:t,tone:n="neutral",hint:a}){return(0,s.jsxs)("div",{className:"rounded-lg border border-edge bg-ink/40 px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wide text-fg-muted",children:e}),(0,s.jsx)("p",{className:`mt-0.5 text-lg font-semibold tabular-nums ${"bad"===n?"text-red-300":"warn"===n?"text-amber-300":"good"===n?"text-emerald-300":"text-fg-hi"}`,children:t}),a?(0,s.jsx)("p",{className:"text-[11px] text-fg-muted",children:a}):null]})}function e5({counts:e,perf:t}){let n=new Map(e.map(e=>[e.event_type,e.count])),a=e=>n.get(e)??0,r=a("session_start"),l=a("runtime_error"),i=a("context_lost"),o=a("focus_change"),c=a("visibility_change"),d=a("viewport_resize"),u=e.reduce((e,t)=>e+t.count,0),m=r>0?l/r:0;return(0,s.jsx)(P.Panel,{title:"Scene health",subtitle:"Errors, GPU context loss & attention gaps in the selected window",children:u>0?(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:[(0,s.jsx)(e2,{label:"Errors",value:b(l),tone:l>0?"bad":"good",hint:r>0?`${m.toFixed(2)} / session`:void 0}),(0,s.jsx)(e2,{label:"Context loss",value:b(i),tone:i>0?"warn":"good",hint:"GPU device lost"}),(0,s.jsx)(e2,{label:"Avg FPS",value:t&&t.samples>0?b(t.avg_fps,1):"—",tone:t&&t.samples>0?t.avg_fps>=50?"good":"warn":"neutral",hint:t&&t.samples>0?`min ${b(t.min_fps,0)}`:void 0}),(0,s.jsx)(e2,{label:"Sessions",value:b(r)}),(0,s.jsx)(e2,{label:"Attention",value:b(o+c),hint:"focus + visibility changes"}),(0,s.jsx)(e2,{label:"Resizes",value:b(d),hint:"viewport changes"})]}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No events in range."})})}function e3({label:e,value:t,hint:n}){return(0,s.jsxs)("div",{className:"rounded-lg border border-edge bg-ink/40 px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wide text-fg-muted",children:e}),(0,s.jsx)("p",{className:"mt-0.5 text-lg font-semibold tabular-nums text-fg-hi",children:t}),n?(0,s.jsx)("p",{className:"text-[11px] text-fg-muted",children:n}):null]})}function e4({buckets:e,bucketSize:t}){if(0===e.length)return(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No camera samples in range."});let n=[...e].sort((e,t)=>e.bucket-t.bucket),a=n.reduce((e,t)=>Math.max(e,t.count),0)||1;return(0,s.jsx)("div",{className:"flex flex-col gap-1",children:n.map(e=>{let n=e.bucket*t;return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"w-24 shrink-0 text-right font-mono text-[11px] text-fg-muted",children:[b(n,1),"–",b(n+t,1)]}),(0,s.jsx)("div",{className:"h-3.5 flex-1 overflow-hidden rounded-sm bg-ink/60",children:(0,s.jsx)("div",{className:"h-full rounded-sm bg-amber",style:{width:`${e.count/a*100}%`}})}),(0,s.jsx)("span",{className:"w-12 shrink-0 text-right font-mono text-[11px] text-fg-muted",children:b(e.count)})]},e.bucket)})})}function e6({coverage:e,cellSize:t,distance:n,bucketSize:a,navigation:r}){let l=e.length,i=e.reduce((e,t)=>e+t.count,0),o=r.reduce((e,t)=>e+t.total_distance,0),c=r.reduce((e,t)=>e+t.segments,0),d=r.reduce((e,t)=>e+t.active_segments,0),u=r.length,m=l>0||r.length>0;return(0,s.jsx)(P.Panel,{title:"Scene traversal",subtitle:"Coverage, camera distance & navigation effort — derived from camera_sample",collapsible:!0,defaultCollapsed:!0,children:m?(0,s.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[(0,s.jsx)(e3,{label:"Visited cells",value:b(l),hint:`${b(t,2)} u voxels`}),(0,s.jsx)(e3,{label:"Camera samples",value:b(i)}),(0,s.jsx)(e3,{label:"Avg travel",value:b(u>0?o/u:0,1),hint:u>0?`over ${b(u)} sessions`:void 0}),(0,s.jsx)(e3,{label:"Active movement",value:`${b(100*(c>0?d/c:0),0)}%`,hint:"of camera segments"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-1.5 text-xs uppercase tracking-wide text-fg-muted",children:"Camera distance distribution"}),(0,s.jsx)(e4,{buckets:n,bucketSize:a})]})]}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"No camera samples in range."})})}let e8={babylon:"Babylon.js","babylon-lite":"Babylon (lite)",three:"three.js",playcanvas:"PlayCanvas",r3f:"react-three-fiber",aframe:"A-Frame"};function e9({project:e,playgroundUrl:t,onView:n,onOpenOverlay:r}){var l;let i=e.scene,o=i?.engines.length?i.engines:[],[c,d]=(0,a.useState)(i?.defaultEngine??o[0]??""),u=t.length>0&&c.length>0;return(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-xl border border-edge bg-panel p-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-fg-hi",children:i?.label??e.name}),(0,s.jsx)("p",{className:"text-xs text-fg-muted",children:e.name})]}),i?(0,s.jsx)("span",{className:"shrink-0 rounded-full border border-edge bg-ink/50 px-2 py-0.5 text-[11px] text-fg-muted",children:"first-person"===i.cameraMode?"first-person":"viewer"}):null]}),i?.description?(0,s.jsx)("p",{className:"text-xs leading-relaxed text-fg-muted",children:i.description}):(0,s.jsx)("p",{className:"text-xs leading-relaxed text-fg-muted",children:"A project without scene metadata — open its analytics directly."}),o.length>1?(0,s.jsxs)("label",{className:"flex flex-col gap-1 text-[11px] text-fg-muted",children:["Engine",(0,s.jsx)("select",{className:"rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron",value:c,onChange:e=>d(e.target.value),children:o.map(e=>(0,s.jsx)("option",{value:e,children:e8[e]??e},e))})]}):1===o.length?(0,s.jsxs)("p",{className:"text-[11px] text-fg-muted",children:["Engine: ",e8[l=o[0]]??l]}):null,(0,s.jsxs)("div",{className:"mt-auto flex flex-wrap gap-2 pt-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>n(e),className:"rounded-md bg-amber px-3 py-1.5 text-xs font-medium text-ink transition hover:bg-ember",children:"View analytics"}),i?(0,s.jsx)("button",{type:"button",disabled:!u,onClick:()=>r(e,c),className:"rounded-md border border-edge px-3 py-1.5 text-xs text-fg transition hover:border-amber hover:text-fg-hi disabled:opacity-40",children:"Open live scene"}):null]})]})}function e7({projects:e,playgroundUrl:t,onView:n}){let[r,l]=(0,a.useState)(null),i=(0,a.useMemo)(()=>{let t=[],s=[],n=[];for(let a of e)a.scene?"first-person"===a.scene.cameraMode?s.push(a):t.push(a):n.push(a);return{viewer:t,firstPerson:s,other:n}},[e]),o=(e,s)=>{let n=e.scene;n&&t&&l({url:`${t.replace(/\/$/,"")}/?scene=${encodeURIComponent(n.id)}&engine=${encodeURIComponent(s)}`,title:`${n.label} \xb7 ${e8[s]??s}`})},c=(e,a)=>a.length>0?(0,s.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,s.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-fg-muted",children:e}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:a.map(e=>(0,s.jsx)(e9,{project:e,playgroundUrl:t,onView:n,onOpenOverlay:o},e.id))})]}):null;return(0,s.jsxs)(P.Panel,{title:"Scenes",subtitle:"Pick a scene to explore its analytics, or open it live to test capture.",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[c("Viewer",i.viewer),c("First-person",i.firstPerson),c("Other projects",i.other)]}),r?(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/70 p-4 sm:p-8",role:"dialog","aria-modal":"true","aria-label":"Live scene overlay",children:(0,s.jsxs)("div",{className:"mx-auto flex h-full w-full max-w-6xl flex-col overflow-hidden rounded-xl border border-edge bg-panel",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-edge px-4 py-2.5",children:[(0,s.jsx)("p",{className:"text-sm text-fg",children:r.title}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("a",{href:r.url,target:"_blank",rel:"noreferrer",className:"rounded-md border border-edge px-3 py-1.5 text-xs text-fg transition hover:border-amber hover:text-fg-hi",children:"Open in new tab ↗"}),(0,s.jsx)("button",{type:"button",onClick:()=>l(null),className:"rounded-md border border-edge px-3 py-1.5 text-xs text-fg transition hover:border-amber hover:text-fg-hi",children:"Close ✕"})]})]}),(0,s.jsx)("iframe",{title:r.title,src:r.url,className:"h-full w-full flex-1 bg-ink"})]})}):null]})}function te({sessions:e,onSelect:t,selectedId:n}){return(0,s.jsx)(P.Panel,{title:"Sessions",subtitle:t?`${e.length} most recent \xb7 select to drill in`:`${e.length} most recent`,children:(0,s.jsx)(eP,{sessions:e,onSelect:t,selectedId:n})})}function tt({baseUrl:e,apiKey:t,sessionId:n,scene:r}){let i=(0,a.useRef)(null),[o,c]=(0,a.useState)([]),[d,u]=(0,a.useState)("loading");return(0,a.useEffect)(()=>{let s=!1;return u("loading"),new l.CollectorApi(e,t).sessionTrajectory(n,{scene:r,limit:5e3}).then(e=>{s||(c(e),u("ready"))}).catch(()=>{s||(c([]),u("error"))}),()=>{s=!0}},[e,t,n,r]),(0,a.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.getContext("2d");if(!t||(t.clearRect(0,0,360,360),t.fillStyle="#0b0e14",t.fillRect(0,0,360,360),0===o.length))return;let s=1/0,n=-1/0,a=1/0,r=-1/0;for(let e of o)e.x<s&&(s=e.x),e.x>n&&(n=e.x),e.z<a&&(a=e.z),e.z>r&&(r=e.z);let l=328/Math.max(n-s,r-a,.001),c=e=>[16+(e.x-s)*l,16+(r-e.z)*l];t.lineWidth=2,t.strokeStyle="#38bdf8",t.beginPath(),o.forEach((e,s)=>{let[n,a]=c(e);0===s?t.moveTo(n,a):t.lineTo(n,a)}),t.stroke();let d=o[0],u=o[o.length-1];if(d){let[e,s]=c(d);t.fillStyle="#22c55e",t.beginPath(),t.arc(e,s,5,0,2*Math.PI),t.fill()}if(u){let[e,s]=c(u);t.fillStyle="#ef4444",t.beginPath(),t.arc(e,s,5,0,2*Math.PI),t.fill()}},[o]),(0,s.jsxs)(P.Panel,{title:"Walked path",subtitle:"Camera trajectory (top-down)",help:"The ordered route this session's camera took across the X/Z ground plane — green is the start, red is the end. Meaningful for first-person (walkable) sessions.",children:[(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)("canvas",{ref:i,width:360,height:360,className:"rounded-lg border border-edge","aria-label":"Session camera trajectory"})}),"loading"===d?(0,s.jsx)("p",{className:"mt-2 text-center text-xs text-fg-muted",children:"Loading trajectory…"}):"error"===d?(0,s.jsx)("p",{className:"mt-2 text-center text-xs text-red-400",children:"Failed to load trajectory."}):0===o.length?(0,s.jsx)("p",{className:"mt-2 text-center text-xs text-fg-muted",children:"No camera movement recorded for this session."}):null]})}function ts(e){return e>=36e5?`${Math.round(e/36e5)}h`:e>=6e4?`${Math.round(e/6e4)}m`:e>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function tn({buckets:e,intervalMs:t,onBrush:n,onClear:r,brushed:l}){let i=(0,a.useRef)(null),o=(0,a.useRef)(null),[c,d]=(0,a.useState)(640),u=(0,a.useRef)(null),[m,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>d(Math.max(320,e.clientWidth));t();let s=new ResizeObserver(t);return s.observe(e),()=>s.disconnect()},[]);let x={x:40,y:14,w:Math.max(1,c-40-36),h:114},p=e.length>0?{start:e[0].bucket,end:e[e.length-1].bucket+t}:null,g=(0,a.useCallback)(e=>{if(!p)return 0;let t=(e-x.x)/x.w;return Math.round(p.start+Math.max(0,Math.min(1,t))*(p.end-p.start))},[p,x.x,x.w]);(0,a.useEffect)(()=>{let s=o.current;if(!s)return;let n=s.getContext("2d");if(!n)return;if(n.clearRect(0,0,c,150),n.fillStyle="#0b0e14",n.fillRect(0,0,c,150),0===e.length||!p){n.fillStyle="#64748b",n.font="12px system-ui, sans-serif",n.textAlign="center",n.fillText("No events in range",c/2,75);return}let a=e.reduce((e,t)=>Math.max(e,t.events),0)||1,r=p.end-p.start,l=Math.max(1,x.w/e.length*.8);for(let t of e){let e=x.x+(t.bucket-p.start)/r*x.w,s=t.events/a*x.h;n.fillStyle="rgba(56, 189, 248, 0.55)",n.fillRect(e,x.y+x.h-s,l,s)}if(n.font="10px system-ui, sans-serif",n.textBaseline="middle",n.fillStyle="rgba(56, 189, 248, 0.95)",n.textAlign="right",n.fillText(String(a),x.x-5,x.y+4),n.fillText("0",x.x-5,x.y+x.h),n.textBaseline="alphabetic",n.fillStyle="rgba(56, 189, 248, 0.7)",n.textAlign="left",n.fillText(`events / ${ts(t)}`,x.x,144),m){let e=Math.min(m.x0,m.x1),t=Math.max(m.x0,m.x1);n.fillStyle="rgba(56, 189, 248, 0.18)",n.fillRect(e,x.y,t-e,x.h),n.strokeStyle="rgba(56, 189, 248, 0.8)",n.lineWidth=1,n.strokeRect(e,x.y,t-e,x.h)}},[e,c,p,m,t,x.x,x.y,x.w,x.h]);let f=()=>{let e=u.current;if(u.current=null,h(null),!e||4>Math.abs(e.x1-e.x0))return;let t=g(Math.min(e.x0,e.x1)),s=g(Math.max(e.x0,e.x1));s>t&&n(t,s)};return(0,s.jsx)(P.Panel,{title:"Event volume over time",subtitle:`Bars: events per ${ts(t)} \xb7 drag to zoom the time window`,children:(0,s.jsxs)("div",{ref:i,className:"relative",children:[(0,s.jsx)("canvas",{ref:o,width:c,height:150,className:"w-full cursor-crosshair rounded-lg border border-edge",onMouseDown:e=>{let t=e.currentTarget.getBoundingClientRect(),s=e.clientX-t.left;u.current={x0:s,x1:s},h({x0:s,x1:s})},onMouseMove:e=>{if(!u.current)return;let t=e.currentTarget.getBoundingClientRect(),s={...u.current,x1:e.clientX-t.left};u.current=s,h(s)},onMouseUp:f,onMouseLeave:f,"aria-label":"Event volume time series"}),l&&r?(0,s.jsx)("button",{type:"button",onClick:r,className:"absolute right-2 top-2 rounded-md border border-edge bg-ink/80 px-2 py-1 text-xs text-fg transition hover:border-amber hover:text-fg-hi",children:"Clear zoom"}):null]})})}var ta=e.i(19761);function tr({label:e,value:t}){return(0,s.jsxs)("div",{className:"flex items-baseline justify-between gap-3 py-0.5",children:[(0,s.jsx)("span",{className:"shrink-0 text-xs text-fg-muted",children:e}),(0,s.jsx)("span",{className:"min-w-0 truncate text-right font-mono text-xs text-fg",title:t,children:t})]})}function tl({title:e,rows:t}){return 0===t.length?null:(0,s.jsxs)("div",{className:"rounded-lg border border-edge bg-ink/40 p-3",children:[(0,s.jsx)("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-fg-muted",children:e}),t.map(([e,t])=>(0,s.jsx)(tr,{label:e,value:t},e))]})}function ti(e){let t=[];for(let[s,n]of e){let e=null==n||""===n?null:Array.isArray(n)?n.join(" × "):"boolean"==typeof n?n?"yes":"no":"object"==typeof n?JSON.stringify(n):String(n);null!=e&&t.push([s,e])}return t}function to({baseUrl:e,apiKey:t,sessionId:n,hiddenTypes:r,onToggleType:l,onSetAllHidden:i}){let o,c,d,[u,m]=(0,a.useState)([]),[h,x]=(0,a.useState)("loading"),[p,g]=(0,a.useState)(null),[f,b]=(0,a.useState)(new Set);(0,a.useEffect)(()=>{let s=!1;return x("loading"),g(null),m([]),b(new Set),(async()=>{try{let a=await (0,ta.fetchSessionEvents)({endpoint:e,apiKey:t,sessionId:n});if(s)return;m(a),x(0===a.length?"empty":"ready")}catch(e){if(s)return;x("error"),g(e instanceof Error?e.message:"Failed to load session data.")}})(),()=>{s=!0}},[e,t,n]);let{meta:v,byType:j,allTypes:w,sorted:y}=(0,a.useMemo)(()=>{let e=[...u].sort((e,t)=>e.ts-t.ts),t=new Map;for(let s of e)t.set(s.type,(t.get(s.type)??0)+1);let s=[...t.keys()].sort(),n=e[0];return{meta:{start:n,end:e[e.length-1],startEvent:e.find(e=>"session_start"===e.type)},byType:t,allTypes:s,sorted:e}},[u]);if("ready"!==h)return(0,s.jsx)(P.Panel,{title:"Session data",subtitle:"Metadata and captured event breakdown",children:(0,s.jsx)("p",{className:"py-6 text-center text-sm text-fg-muted",children:"loading"===h?"Loading session data…":"empty"===h?"No events captured for this session.":p??"Session data unavailable."})});let N=v.start,k=v.end,S=v.startEvent,M=N&&k?k.ts-N.ts:0,z=e=>e?new Date(e).toLocaleString():"—",C=N?.pageMeta,_=ti([["Project",N?.projectId],["Session",N?.sessionId],["Visitor",N?.visitorId],["SDK",N?.sdkVersion],["Scene ID",N?.sceneId],["URL",N?.url],["Started",z(N?.ts)],["Ended",z(k?.ts)],["Duration",(c=Math.floor((o=Math.round(M/1e3))/60),d=o%60,c>0?`${c}m ${d}s`:`${d}s`)],["Events",String(y.length)]]),$=C?ti([["Title",C.title],["Language",C.language],["Referrer",C.referrer],["Viewport",C.viewport],["Device pixel ratio",C.devicePixelRatio]]):[],I=S?.type==="session_start"?S.device:void 0,A=S?.type==="session_start"?S.graphics:void 0,R=S?.type==="session_start"?S.scene:void 0,E=S?.type==="session_start"?S.connector:void 0,T=S?.type==="session_start"?S.user:void 0,L=ti([["Engine",I?.engine],["Graphics API",A?.api],["Backend",A?.backend],["API version",A?.apiVersion],["Shading language",A?.shadingLanguage],["GPU vendor",I?.vendor],["GPU renderer",I?.renderer],["Max texture size",I?.maxTextureSize],["CPU cores",I?.hardwareConcurrency],["Device memory (GB)",I?.deviceMemoryGb],["Mobile",I?.isMobile]]),F=ti([["Connector",E?[E.name,E.version].filter(Boolean).join(" "):null],["Coordinate system",E?.coordinateSystem],["Description",R?.description],["Camera type",R?.cameraType],["Camera name",R?.cameraName],["Mesh count",R?.meshCount],["User id",T?.id],["User traits",T?.traits]]),D=w.every(e=>r.has(e));return(0,s.jsxs)(P.Panel,{title:"Session data",subtitle:"Metadata that was sent and a per-feature breakdown — toggle a type to show/hide it in the replay, expand to inspect raw payloads",help:(0,s.jsxs)(s.Fragment,{children:["Project-level metadata beyond the ",(0,s.jsx)("strong",{children:"Project ID"}),"isn't stored in the OSS collector (Phase 1) — everything here is derived from the session's own events. The"," ",(0,s.jsx)("strong",{children:"Device / graphics"})," and ",(0,s.jsx)("strong",{children:"Scene / connector"})," blocks come from the one-time ",(0,s.jsx)("code",{children:"session_start"})," event."]}),children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,s.jsx)(tl,{title:"Identity",rows:_}),(0,s.jsx)(tl,{title:"Page context",rows:$}),(0,s.jsx)(tl,{title:"Device / graphics",rows:L}),(0,s.jsx)(tl,{title:"Scene / connector",rows:F})]}),(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsxs)("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-fg-muted",children:["Captured features (",w.length," event types)"]}),(0,s.jsx)("button",{type:"button",onClick:()=>i(!D,w),className:"rounded-md border border-edge px-2 py-1 text-xs text-fg transition hover:border-amber hover:text-fg-hi",children:D?"Show all":"Hide all"})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2 lg:grid-cols-3",children:w.map(e=>{let t=!r.has(e),n=f.has(e),a=y.filter(t=>t.type===e).slice(0,3);return(0,s.jsxs)("div",{className:`self-start rounded-lg border border-edge bg-ink/40 ${n?"sm:col-span-2 lg:col-span-3":""}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[(0,s.jsxs)("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:t,onChange:()=>l(e),className:"accent-amber"}),(0,s.jsx)("span",{className:"truncate font-mono text-xs text-fg",children:e})]}),(0,s.jsx)("span",{className:"tabular-nums text-xs text-fg-muted",children:j.get(e)}),(0,s.jsx)("button",{type:"button",onClick:()=>b(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s}),"aria-expanded":n?"true":"false",className:"rounded border border-edge px-1.5 py-0.5 text-[10px] text-fg-muted transition hover:border-amber hover:text-fg-hi",children:n?"Hide raw":"Raw"})]}),n?(0,s.jsxs)("pre",{className:"max-h-64 overflow-auto border-t border-edge bg-black/30 px-3 py-2 text-[10px] leading-relaxed text-fg",children:[a.map(e=>JSON.stringify(e,null,2)).join("\n\n"),(j.get(e)??0)>a.length?`
|
|
2
|
+
|
|
3
|
+
… ${(j.get(e)??0)-a.length} more`:""]}):null]},e)})})]})]})}function tc(e){return e.length>10?`${e.slice(0,8)}…`:e}function td(e,t){let s=Math.max(0,Math.round((t-e)/1e3));if(s<60)return`${s}s ago`;let n=Math.floor(s/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}let tu={active:"bg-emerald-400",recent:"bg-amber-400",idle:"bg-fg-muted"},tm={idle:"offline",connecting:"connecting…",open:"live",reconnecting:"reconnecting…"};function th({status:e,sessions:t}){let n="open"===e;return(0,s.jsxs)("span",{className:"inline-flex items-center gap-2 rounded-full border border-edge bg-ink px-3 py-1 text-xs",children:[(0,s.jsxs)("span",{className:"relative flex h-2 w-2",children:[n?(0,s.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}):null,(0,s.jsx)("span",{className:`relative inline-flex h-2 w-2 rounded-full ${n?"bg-emerald-400":"idle"===e?"bg-fg-muted":"bg-amber-400"}`})]}),(0,s.jsx)("span",{className:"font-medium text-fg",children:n?`${b(t)} live now`:tm[e]})]})}function tx({snapshot:e,status:t,feed:n,now:a,onSelectSession:r}){let l=e?.sessions??[],i=e?.activeSessions??0,o=e?.activeVisitors??0;return(0,s.jsxs)(P.Panel,{title:"Live now",subtitle:"Active sessions and a real-time event feed, updating in place.",help:(0,s.jsx)(s.Fragment,{children:"Sessions seen within the liveness window, streamed over SSE from the collector. The roster is intentionally non-identifying — no geo, user-agent, or visitor id. Click a session to follow it live."}),children:[(0,s.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-4",children:[(0,s.jsx)(th,{status:t,sessions:i}),(0,s.jsxs)("span",{className:"text-xs text-fg-muted",children:[(0,s.jsx)("span",{className:"font-semibold text-fg",children:b(o)})," visitor",1===o?"":"s"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"mb-2 text-xs uppercase tracking-wide text-fg-muted",children:["Sessions (",l.length,")"]}),0===l.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"open"===t?"No active sessions right now.":"Waiting for live data…"}):(0,s.jsx)("ul",{className:"flex max-h-64 flex-col gap-1 overflow-y-auto pr-1",children:l.map(e=>(0,s.jsx)("li",{children:r?(0,s.jsxs)("button",{type:"button",onClick:()=>r(e.sessionId),className:"flex w-full items-center gap-2 rounded-md border border-transparent px-2 py-1.5 text-left transition hover:border-edge hover:bg-ink",children:[(0,s.jsx)("span",{className:`h-2 w-2 flex-none rounded-full ${tu[e.activity]}`,"aria-hidden":"true"}),(0,s.jsx)("span",{className:"font-mono text-xs text-fg",children:tc(e.sessionId)}),(0,s.jsx)("span",{className:"truncate text-xs text-fg-muted",children:e.sceneId}),(0,s.jsx)("span",{className:"ml-auto flex-none text-xs text-fg-muted",children:td(e.lastSeen,a)})]}):(0,s.jsxs)("div",{className:"flex w-full items-center gap-2 px-2 py-1.5",children:[(0,s.jsx)("span",{className:`h-2 w-2 flex-none rounded-full ${tu[e.activity]}`,"aria-hidden":"true"}),(0,s.jsx)("span",{className:"font-mono text-xs text-fg",children:tc(e.sessionId)}),(0,s.jsx)("span",{className:"truncate text-xs text-fg-muted",children:e.sceneId}),(0,s.jsx)("span",{className:"ml-auto flex-none text-xs text-fg-muted",children:td(e.lastSeen,a)})]})},e.sessionId))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-xs uppercase tracking-wide text-fg-muted",children:"Event feed"}),0===n.length?(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"open"===t?"Listening for events…":"Waiting for live data…"}):(0,s.jsx)("ul",{className:"flex max-h-64 flex-col gap-1 overflow-y-auto pr-1 font-mono text-xs",children:n.map((e,t)=>(0,s.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-2 py-1",children:[(0,s.jsx)("span",{className:"flex-none rounded bg-amber/15 px-1.5 py-0.5 text-[11px] text-saffron",children:e.type}),(0,s.jsx)("span",{className:"text-fg-muted",children:tc(e.sessionId)}),(0,s.jsx)("span",{className:"ml-auto flex-none text-fg-muted",children:td(e.ts,a)})]},`${e.sessionId}-${e.ts}-${t}`))})]})]})]})}let tp=(0,n.default)(()=>e.A(69091).then(e=>e.SessionReplay),{loadableGenerated:{modules:[12449]},ssr:!1}),tg=(0,n.default)(()=>e.A(33996).then(e=>e.WorldHeatmap3D),{loadableGenerated:{modules:[25453]},ssr:!1}),tf=(0,n.default)(()=>e.A(56403).then(e=>e.ClickRays3D),{loadableGenerated:{modules:[61518]},ssr:!1}),tb={sessions:[],camera:[],perf:null,gaze:[],clickRays:[],hasFirstPerson:!1,proxyMeshes:[],timeseries:[],counts:[],coverage:[],distance:[],navigation:[],sources:[],floorPlan:[],performance:{distribution:null,histogram:[],frameTime:null,jank:null,byDevice:[],byScene:[],resources:null,stability:null},intervalMs:36e5};e.s(["default",0,function(){let[e,n]=(0,a.useState)(r.DEFAULT_COLLECTOR_URL),[o,c]=(0,a.useState)(r.DEFAULT_API_KEY),[m,x]=(0,a.useState)([]),[p,g]=(0,a.useState)(""),[f,b]=(0,a.useState)(i),[w,k]=(0,a.useState)([]),[S,M]=(0,a.useState)(tb),[z,C]=(0,a.useState)("idle"),[P,_]=(0,a.useState)(null),[I,A]=(0,a.useState)(null),[R,E]=(0,a.useState)("idle"),[T,L]=(0,a.useState)(new Set),[F,D]=(0,a.useState)([]),[B,O]=(0,a.useState)(()=>Date.now()),[U,H]=(0,a.useState)(0),[W,G]=(0,a.useState)(void 0),V=(0,a.useRef)(void 0),Z=(0,a.useRef)(new Set),K=(0,a.useRef)(f);K.current=f;let X=(0,a.useRef)(i.window),q=(0,a.useRef)(p);q.current=p;let J=(0,a.useRef)(I);J.current=I;let Y=(0,a.useRef)(null),Q=(0,a.useRef)(null),ee=(0,a.useRef)(!1),et=(0,a.useCallback)((e,t)=>{let s=`/projects/${encodeURIComponent(e)}`;return t?`${s}/session/${encodeURIComponent(t)}`:s},[]),es=(0,a.useCallback)(e=>{window.location.pathname!==e&&window.history.pushState({},"",e)},[]);(0,a.useEffect)(()=>{let e=window.location.pathname.match(/^\/projects\/([^/]+)(?:\/session\/([^/]+))?/);e?.[1]&&(Y.current=decodeURIComponent(e[1]),e[2]&&(Q.current=decodeURIComponent(e[2])))},[]),(0,a.useEffect)(()=>{r.COLLECTOR_URL_IS_PINNED||n(window.location.origin)},[]),(0,a.useEffect)(()=>{let e=!1;return fetch("/api/projects").then(e=>e.ok?e.json():[]).then(t=>{if(e||!Array.isArray(t)||0===t.length)return;x(t);let[s]=t,n=Y.current,a=(n?t.find(e=>e.id===n):void 0)??t.find(e=>e.apiKey===r.DEFAULT_API_KEY)??s;a&&(g(a.id),c(a.apiKey),(n&&a.id===n||1===t.length&&!a.scene)&&(ee.current=!0))}).catch(()=>{}),()=>{e=!0}},[]);let en=(0,a.useCallback)(async t=>{let s=t??o;if(!s){C("error"),_("An API key is required.");return}C("loading"),_(null),A(null),E("idle");let n=K.current,a=u(n),r=d(n),i=new l.CollectorApi(e,s);try{let e=await i.sessions({...a,source:void 0,limit:100}),t=r.until??Date.now(),s=r.since;if(null==s){let n=e.reduce((e,t)=>{var s;let n=(s=t.started_at,new Date(s.includes("T")?s:s.replace(" ","T")+"Z").getTime());return Number.isFinite(n)?Math.min(e,n):e},Date.now());s=Number.isFinite(n)?n:t-864e5}let n=h(Math.max(6e4,t-s)),l=1e3*n,[o,c,d,u,m,x,p,g,f,b,v,j,w]=await Promise.all([i.cameraHeatmap({...a,source:void 0,bins:36}),i.perf({...a,source:void 0}),i.gazeHeatmap({...a,source:void 0,cellSize:.5}),i.clickRays({...a,cellSize:.5}),i.scenes({since:r.since,until:r.until,limit:200}),i.timeseries({since:r.since,until:r.until,scene:a.scene,interval:n}),i.eventCounts({since:r.since,until:r.until,scene:a.scene}),i.coverage({...a,source:void 0,cellSize:1}),i.cameraDistance({...a,source:void 0,bucketSize:1}),i.navigation({...a,source:void 0}),i.interactionsBySource(a),i.cameraPositionHeatmap({...a,source:void 0,cameraMode:"first-person",cellSize:1}),(async()=>{let[e,t,s,n,r,l,o,c]=await Promise.all([i.perfDistribution({...a,source:void 0}),i.fpsHistogram({...a,source:void 0}),i.frameTimePercentiles({...a,source:void 0}),i.jankRate({...a,source:void 0}),i.perfByDevice({...a,source:void 0}),i.perfByScene({...a,source:void 0,scene:void 0}),i.resourcePercentiles({...a,source:void 0}),i.stabilityCounts({...a,source:void 0})]);return{distribution:e,histogram:t,frameTime:s,jank:n,byDevice:r,byScene:l,resources:o,stability:c}})()]);k(m),M(t=>({sessions:e,camera:o,perf:c,gaze:d,clickRays:u,hasFirstPerson:j.length>0,proxyMeshes:t.proxyMeshes,timeseries:x,counts:p,coverage:g,distance:f,navigation:b,sources:v,floorPlan:j,performance:w,intervalMs:l})),C("ready")}catch(e){M(tb),C("error"),_(e instanceof l.ApiError?`${e.status}: ${e.message}`:e instanceof Error?e.message:"Request failed.")}},[o,e]),ea=(0,a.useCallback)(e=>{g(e.id),c(e.apiKey),G(void 0),V.current=void 0,es(et(e.id)),en(e.apiKey)},[en,et,es]);(0,a.useEffect)(()=>{if("idle"===z)return;let e=setTimeout(()=>void en(),300);return()=>clearTimeout(e)},[f]);let er="idle"!==z&&!!o,el=(0,a.useRef)(0),ei=(0,a.useRef)(!1);ei.current=null!=I;let eo=(0,a.useCallback)(e=>{D(t=>[e,...t].slice(0,30)),Z.current.forEach(t=>t(e)),!ei.current&&e.sceneId&&e.sceneId!==V.current&&(V.current=e.sceneId,G(e.sceneId),H(e=>e+1));let t=Date.now();ei.current||t-el.current<5e3||(el.current=t,en(),H(e=>e+1))},[en]),{snapshot:ec,status:ed}=(0,j.useLivePresence)(e,o,er);(0,j.useLiveStream)(e,o,er,eo),(0,a.useEffect)(()=>{if(!er)return;let e=setInterval(()=>O(Date.now()),1e3);return()=>clearInterval(e)},[er]),(0,a.useEffect)(()=>{if(!er)return;let t=new l.CollectorApi(e,o),s=!1,n=async()=>{let e=d(K.current),n=await t.scenes({since:e.since,until:e.until,limit:200}).catch(()=>null);!s&&n&&k(n)},a=setInterval(()=>void n(),5e3);return()=>{s=!0,clearInterval(a)}},[er,e,o]);let eu=f.scene&&f.scene.length>0?f.scene:void 0;(0,a.useEffect)(()=>{if("idle"===z)return;let t=!1;return(async()=>{let s=new l.CollectorApi(e,o),n=eu?(await s.sceneRepresentation(eu).catch(()=>null))?.proxy?.meshes??[]:await (0,v.mergeSceneProxies)(s,u(K.current));t||M(e=>({...e,proxyMeshes:n}))})(),()=>{t=!0}},[eu,e,o,z,U]);let em=(0,a.useCallback)(async t=>{let s=u(K.current),n=new l.CollectorApi(e,o),[a,r,i]=await Promise.all([n.cameraHeatmap({...s,source:void 0,bins:36,session:t}),n.perf({...s,source:void 0,session:t}),n.sessionMeta(t).catch(()=>null)]);return{id:t,meta:i,camera:a,perf:r}},[e,o]),eh=(0,a.useCallback)(async e=>{let t=q.current;t&&es(et(t,e)),window.scrollTo({top:0,behavior:"smooth"}),A({id:e,meta:null,camera:[],perf:null}),E("loading"),L(new Set);try{A(await em(e)),E("ready")}catch(e){E("error"),_(e instanceof l.ApiError?`${e.status}: ${e.message}`:e instanceof Error?e.message:"Request failed.")}},[em,et,es]),ex=(0,a.useCallback)(()=>{let e=q.current;e&&es(et(e)),A(null),E("idle"),L(new Set)},[et,es]),ep=(0,a.useCallback)(e=>{let t=m.find(t=>t.id===e);g(e),t&&c(t.apiKey),M(tb),k([]),C("idle"),_(null),A(null),E("idle"),L(new Set)},[m]),eg=(0,a.useCallback)(e=>{L(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),ef=(0,a.useCallback)((e,t)=>{L(e?new Set(t):new Set)},[]),eb=(0,a.useCallback)((e,t)=>{b(s=>("custom"!==s.window&&(X.current=s.window),{...s,window:"custom",since:e,until:t}))},[]),ev=(0,a.useCallback)(()=>{b(e=>({...e,window:X.current}))},[]);(0,a.useEffect)(()=>{ee.current&&o&&(ee.current=!1,en())},[m,o,en]),(0,a.useEffect)(()=>{if("ready"===z&&Q.current){let e=Q.current;Q.current=null,eh(e)}},[z,eh]),(0,a.useEffect)(()=>{let e=()=>{let e=window.location.pathname.match(/^\/projects\/[^/]+(?:\/session\/([^/]+))?/),t=e?.[1]?decodeURIComponent(e[1]):null;t?J.current?.id!==t&&eh(t):J.current&&ex()};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[eh,ex]);let ej="loading"===z,ew=(0,a.useMemo)(()=>new l.CollectorApi(e,o),[e,o]),ey=(0,a.useMemo)(()=>u(f),[f,U]),eN=(0,a.useCallback)(e=>{let t=Z.current;return t.add(e),()=>{t.delete(e)}},[]),ek=(0,a.useMemo)(()=>({selectSession:e=>void eh(e),setTimeRange:(e,t)=>eb(e,t),setFilters:e=>b(t=>({...t,...e}))}),[eh,eb]),eS={api:ew,baseUrl:e,apiKey:o,params:ey,filters:f,capabilities:{hasFirstPerson:S.hasFirstPerson},actions:ek,live:{presence:ec,enabled:er,subscribe:eN,sceneId:er?W:void 0},settings:{}},eM={...eS,surface:"overview"},ez=I?{...eS,surface:"session",sessionId:I.id}:null,eC=function(){let[e,s]=(0,a.useState)(eW);return(0,a.useEffect)(()=>{let e,n,a=(e=eH(t.default.env.NEXT_PUBLIC_PANELS_MANIFEST_URL),n=eH(t.default.env.NEXT_PUBLIC_PANELS_ALLOWED_ORIGINS),{enabled:e.length>0,manifestUrls:e,allowOrigins:n});if(!a.enabled)return;let r=!1,l=new AbortController;return s({panels:[],errors:[],loading:!0}),(async()=>{let e=[],t=[],n=new Set;for(let s of a.manifestUrls){let r=await y(s,{signal:l.signal});if("code"in r){t.push(r);continue}let i=await N(r,{allowOrigins:a.allowOrigins.length>0?a.allowOrigins:void 0});for(let s of(t.push(...i.errors),i.panels)){if(n.has(s.id)){t.push({source:s.id,code:"invalid-panel",message:`Duplicate panel id "${s.id}" from another manifest — ignored`});continue}n.add(s.id),e.push(s)}}r||s({panels:e,errors:t,loading:!1})})(),()=>{r=!0,l.abort()}},[]),e}(),eP=(0,a.useMemo)(()=>(function(e,t){let s=new Map;for(let t of e)s.set(t.id,t);let n=[...e],a=[];for(let e of t){if(s.has(e.id)){a.push({source:e.id,code:"invalid-panel",message:`Duplicate panel id "${e.id}" — kept the existing panel`});continue}s.set(e.id,e),n.push(e)}return{panels:n,errors:a}})(eU,eC.panels),[eC.panels]),e_=eP.panels,e$=(0,a.useMemo)(()=>[...eC.errors,...eP.errors],[eC.errors,eP.errors]),eI=!!(I&&ec?.sessions.some(e=>e.sessionId===I.id)),eA=(0,a.useRef)(eI);return(0,a.useEffect)(()=>{let e=eA.current;if(eA.current=eI,!e||eI)return;let t=J.current;if(!t||"ready"!==R)return;let s=t.id,n=!1;return(async()=>{try{let e=await em(s);n||J.current?.id!==s||A(e)}catch{}})(),()=>{n=!0}},[eI,R,em]),(0,a.useEffect)(()=>{if(!eI||"ready"!==R)return;let e=J.current?.id;if(!e)return;let t=!1,s=setInterval(()=>{(async()=>{try{let s=await em(e);t||J.current?.id!==e||A(s)}catch{}})()},1e3);return()=>{t=!0,clearInterval(s)}},[eI,R,em]),(0,s.jsxs)("main",{className:"mx-auto max-w-6xl px-6 py-8",children:[(0,s.jsxs)("header",{className:"mb-6 flex items-center gap-3",children:[(0,s.jsx)("img",{src:"/logo.svg",alt:"Uptimizr",width:36,height:36,className:"h-9 w-9 shrink-0"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"font-display text-2xl font-bold text-fg-hi",children:"Uptimizr"}),(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"Analytics for 3D scenes — open-source collector."})]})]}),(0,s.jsxs)("form",{className:"mb-6 flex flex-wrap items-end gap-3 rounded-xl border border-edge bg-panel p-4",onSubmit:e=>{e.preventDefault(),p&&es(et(p)),en()},children:[m.length>0?(0,s.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["Project",(0,s.jsx)("select",{className:"min-w-56 rounded-md border border-edge bg-ink px-3 py-2 text-sm text-fg outline-none focus:border-saffron",value:p,onChange:e=>ep(e.target.value),children:m.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))})]}):null,(0,s.jsxs)("label",{className:"flex flex-1 flex-col gap-1 text-xs text-fg-muted",children:["Collector URL",(0,s.jsx)("input",{className:"min-w-56 rounded-md border border-edge bg-ink px-3 py-2 text-sm text-fg outline-none focus:border-saffron",value:e,onChange:e=>n(e.target.value),placeholder:"http://localhost:4318"})]}),(0,s.jsxs)("label",{className:"flex flex-1 flex-col gap-1 text-xs text-fg-muted",children:["Project API key",(0,s.jsx)("input",{className:"min-w-56 rounded-md border border-edge bg-ink px-3 py-2 text-sm text-fg outline-none focus:border-saffron",value:o,onChange:e=>c(e.target.value),type:"password",placeholder:"utk_…"})]}),(0,s.jsx)("button",{type:"submit",disabled:"loading"===z,className:"rounded-md bg-amber px-4 py-2 text-sm font-medium text-ink transition hover:bg-ember disabled:opacity-50",children:"loading"===z?"Loading…":"Load"})]}),"idle"!==z?(0,s.jsx)(eX,{filters:f,scenes:w,onChange:b,busy:ej}):null,P?(0,s.jsx)("div",{className:"mb-6 rounded-lg border border-red-900/60 bg-red-950/40 px-4 py-3 text-sm text-red-300",children:P}):null,"idle"===z?m.length>0?(0,s.jsx)(e7,{projects:m,playgroundUrl:r.DEFAULT_PLAYGROUND_URL,onView:ea}):(0,s.jsx)("p",{className:"text-sm text-fg-muted",children:"Enter your collector URL and a project API key, then load to view analytics."}):I?(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[e$.length>0?(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(eG,{errors:e$})}):null,(0,s.jsxs)("div",{className:"lg:col-span-2 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-panel p-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wide text-fg-muted",children:"Session"}),(0,s.jsx)("p",{className:"font-mono text-sm text-fg",children:I.id}),(0,s.jsx)("p",{className:"mt-1 text-xs text-fg-muted",children:"loading"===R?"Loading session…":[I.meta?.scene?.sceneId?`scene: ${I.meta.scene.sceneId}`:null,I.meta?.device?.gpu?`gpu: ${I.meta.device.gpu}`:null,I.meta?.startedAt?`started: ${I.meta.startedAt}`:null].filter(Boolean).join(" · ")||"No session metadata."})]}),(0,s.jsx)("button",{type:"button",onClick:ex,className:"rounded-md border border-edge px-3 py-2 text-sm text-fg transition hover:border-amber hover:text-fg-hi",children:"← All sessions"})]}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(tp,{baseUrl:e,apiKey:o,sessionId:I.id,hiddenTypes:T,isLive:eI})}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(to,{baseUrl:e,apiKey:o,sessionId:I.id,hiddenTypes:T,onToggleType:eg,onSetAllHidden:ef})}),(0,s.jsx)(eJ,{perf:I.perf}),ez?(0,s.jsx)($,{panels:e_,ctx:ez,surface:"session",revision:U}):null,(0,s.jsx)(eV,{bins:I.camera,gridSize:36}),I.meta?.scene?.cameraType==="free"?(0,s.jsx)(tt,{baseUrl:e,apiKey:o,sessionId:I.id,scene:I.meta?.scene?.sceneId??f.scene}):null,(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(te,{sessions:S.sessions,selectedId:I.id,onSelect:eh})})]}):(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[e$.length>0?(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(eG,{errors:e$})}):null,(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(tx,{snapshot:ec,status:ed,feed:F,now:B,onSelectSession:eh})}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(tn,{buckets:S.timeseries,intervalMs:S.intervalMs,onBrush:eb,brushed:"custom"===f.window,onClear:ev})}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(e5,{counts:S.counts,perf:S.perf})}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(e6,{coverage:S.coverage,cellSize:1,distance:S.distance,bucketSize:1,navigation:S.navigation})}),(0,s.jsx)(eJ,{perf:S.perf}),(0,s.jsx)($,{panels:e_,ctx:eM,surface:"overview",revision:U}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(e1,{data:S.performance})}),(0,s.jsx)(eq,{rows:S.sources}),(0,s.jsx)(eV,{bins:S.camera,gridSize:36}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(tg,{voxels:S.gaze,cellSize:.5,proxyMeshes:S.proxyMeshes,title:"Gaze heatmap (3D)",subtitle:"Camera-pose gaze hit-points voxel-binned in world space — what viewers actually look at",legendTitle:"Gaze density",legendLow:"few looks",legendHigh:"most looks",legendNote:"Each marker is a voxel where the camera-forward (gaze) ray hit your scene. Enable gaze capture in the SDK to populate this.",emptyLabel:"No gaze hit-points in range. Enable gaze capture in the SDK."})}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(tf,{rays:S.clickRays,cellSize:.5,proxyMeshes:S.proxyMeshes})}),(0,s.jsx)("div",{className:"lg:col-span-2",children:(0,s.jsx)(te,{sessions:S.sessions,onSelect:eh})})]})]})}],14936)}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,82665,20880,89339,88725,e=>{"use strict";var t=e.i(23838);let s=!!t.default.env.NEXT_PUBLIC_COLLECTOR_URL,n=t.default.env.NEXT_PUBLIC_COLLECTOR_URL??"http://localhost:4318",r="1"===t.default.env.DASHBOARD_STATIC?"":t.default.env.NEXT_PUBLIC_API_KEY??"",a=t.default.env.NEXT_PUBLIC_PLAYGROUND_URL??"http://localhost:5173";e.s(["COLLECTOR_URL_IS_PINNED",0,s,"DEFAULT_API_KEY",0,r,"DEFAULT_COLLECTOR_URL",0,n,"DEFAULT_PLAYGROUND_URL",0,a],82665);class i extends Error{status;constructor(e,t){super(e),this.status=t,this.name="ApiError"}}class c{baseUrl;apiKey;constructor(e,t){this.baseUrl=e,this.apiKey=t}async get(e,t={}){let s=new URL(e,l(this.baseUrl));for(let[e,n]of Object.entries(t))null!=n&&s.searchParams.set(e,String(n));let n=await fetch(s,{headers:{"x-api-key":this.apiKey},cache:"no-store"});if(!n.ok)throw new i(await n.text().catch(()=>"")||n.statusText,n.status);return await n.json()}sessions(e){return this.get("api/v1/sessions",e).then(e=>e.map(e=>({...e,events:Number(e.events)})))}pointerHeatmap(e){return this.get("api/v1/heatmaps/pointer",e)}cameraHeatmap(e){return this.get("api/v1/heatmaps/camera",e)}topMeshes(e){return this.get("api/v1/meshes/top",e).then(e=>e.map(e=>({...e,count:Number(e.count)})))}meshKinds(e){return this.get("api/v1/meshes/kinds",e).then(e=>e.map(e=>({mesh:String(e.mesh??""),kind:String(e.kind??""),count:Number(e.count??0)})))}topMeshesBySource(e){return this.get("api/v1/meshes/sources",e).then(e=>e.map(e=>({mesh:String(e.mesh??""),source:String(e.source??""),count:Number(e.count??0)})))}topMeshesTrend(e){return this.get("api/v1/meshes/trend",e).then(e=>e.map(e=>({mesh:String(e.mesh??""),bucket:Number(e.bucket??0),count:Number(e.count??0)})))}topInputActions(e){return this.get("api/v1/input-actions/top",e).then(e=>e.map(e=>({action:String(e.action??""),source:String(e.source??""),count:Number(e.count??0)})))}perf(e){return this.get("api/v1/perf",e).then(e=>({samples:Number(e.samples??0),avg_fps:Number(e.avg_fps??0),min_fps:Number(e.min_fps??0),p50_fps:Number(e.p50_fps??0)}))}renderScale(e){return this.get("api/v1/perf/render-scale",e).then(e=>{let t=e[0]??{},s=Number(t.downscaled_samples??0),n=Number(t.scale_samples??0);return{samples:Number(t.samples??0),avg_fps:Number(t.avg_fps??0),p50_fps:Number(t.p50_fps??0),avg_render_scale:Number(t.avg_render_scale??0),p50_render_scale:Number(t.p50_render_scale??0),downscaled_samples:s,scale_samples:n,downscaled_share:n>0?s/n:0}})}perfDistribution(e){return this.get("api/v1/perf/distribution",e).then(e=>{let t=e[0]??{};return{sessions:Number(t.sessions??0),samples:Number(t.samples??0),p05_fps:Number(t.p05_fps??0),p50_fps:Number(t.p50_fps??0),p95_fps:Number(t.p95_fps??0)}})}fpsHistogram(e){return this.get("api/v1/perf/fps-histogram",e).then(e=>e.map(e=>({bucket:Number(e.bucket??0),sessions:Number(e.sessions??0)})))}frameTimePercentiles(e){return this.get("api/v1/perf/frame-time",e).then(e=>{let t=e[0]??{};return{sessions:Number(t.sessions??0),samples:Number(t.samples??0),p50_ms:Number(t.p50_ms??0),p95_ms:Number(t.p95_ms??0)}})}jankRate(e){return this.get("api/v1/perf/jank",e).then(e=>{let t=e[0]??{};return{sessions:Number(t.sessions??0),total_long_frames:Number(t.total_long_frames??0),median_rate:Number(t.median_rate??0),worst_decile_rate:Number(t.worst_decile_rate??0)}})}perfByDevice(e){return this.get("api/v1/perf/by-device",e).then(e=>e.map(e=>({engine:String(e.engine??""),is_mobile:String(e.is_mobile??""),renderer:String(e.renderer??""),browser:String(e.browser??""),os:String(e.os??""),sessions:Number(e.sessions??0),samples:Number(e.samples??0),p50_fps:Number(e.p50_fps??0)})))}perfByScene(e){return this.get("api/v1/perf/by-scene",e).then(e=>e.map(e=>({scene_id:String(e.scene_id??""),sessions:Number(e.sessions??0),samples:Number(e.samples??0),p50_fps:Number(e.p50_fps??0)})))}resourcePercentiles(e){return this.get("api/v1/perf/resource-percentiles",e).then(e=>{let t=e[0]??{};return{sessions:Number(t.sessions??0),samples:Number(t.samples??0),p50_js_heap_bytes:Number(t.p50_js_heap_bytes??0),p95_js_heap_bytes:Number(t.p95_js_heap_bytes??0),p50_texture_bytes:Number(t.p50_texture_bytes??0),p95_texture_bytes:Number(t.p95_texture_bytes??0),p50_triangles:Number(t.p50_triangles??0),p95_triangles:Number(t.p95_triangles??0)}})}stabilityCounts(e){return this.get("api/v1/perf/stability",e).then(e=>{let t=e[0]??{};return{context_losses:Number(t.context_losses??0),compile_stalls:Number(t.compile_stalls??0),incidents:Number(t.incidents??0)}})}worldHeatmap(e){return this.get("api/v1/heatmaps/world",e).then(e=>e.map(e=>({vx:Number(e.vx),vy:Number(e.vy),vz:Number(e.vz),count:Number(e.count)})))}gazeHeatmap(e){return this.get("api/v1/heatmaps/gaze",e).then(e=>e.map(e=>({vx:Number(e.vx),vy:Number(e.vy),vz:Number(e.vz),count:Number(e.count)})))}worldHeatmapStats(e){return this.get("api/v1/heatmaps/world/stats",e).then(e=>({cellSize:Number(e.cellSize??0),cells:Number(e.cells??0),hits:Number(e.hits??0)}))}gazeHeatmapStats(e){return this.get("api/v1/heatmaps/gaze/stats",e).then(e=>({cellSize:Number(e.cellSize??0),cells:Number(e.cells??0),hits:Number(e.hits??0)}))}cameraPositionHeatmap(e){return this.get("api/v1/heatmaps/position",e).then(e=>e.map(e=>({gx:Number(e.gx),gz:Number(e.gz),avg_y:Number(e.avg_y??0),count:Number(e.count??0)})))}sessionTrajectory(e,t){return this.get(`api/v1/sessions/${encodeURIComponent(e)}/trajectory`,t).then(e=>e.map(e=>({ts:Number(e.ts),x:Number(e.x),y:Number(e.y),z:Number(e.z)})))}aggregatePaths(e){return this.get("api/v1/paths",e).then(e=>e.map(e=>({session_id:String(e.session_id??""),ts:Number(e.ts),gx:Number(e.gx),gz:Number(e.gz)})))}clickRays(e){return this.get("api/v1/heatmaps/click-rays",e).then(e=>e.map(e=>({camVoxel:[Number(e.cam_vx),Number(e.cam_vy),Number(e.cam_vz)],origin:[Number(e.origin_x),Number(e.origin_y),Number(e.origin_z)],hitVoxel:[Number(e.hit_vx),Number(e.hit_vy),Number(e.hit_vz)],hit:[Number(e.hit_x),Number(e.hit_y),Number(e.hit_z)],mesh:String(e.mesh??""),count:Number(e.count)})))}flowHeatmap(e){return this.get("api/v1/heatmaps/flow",e).then(e=>e.map(e=>{let t={azimuth_bin:Number(e.azimuth_bin),elevation_bin:Number(e.elevation_bin),mesh:String(e.mesh??""),count:Number(e.count)};return null!=e.origin_vx&&(t.originVoxel=[Number(e.origin_vx),Number(e.origin_vy),Number(e.origin_vz)],t.origin=[Number(e.origin_x),Number(e.origin_y),Number(e.origin_z)]),t}))}scenes(e){return this.get("api/v1/scenes",e).then(e=>e.map(e=>({...e,events:Number(e.events)})))}timeseries(e){return this.get("api/v1/timeseries",e).then(e=>e.map(e=>({bucket:Number(e.bucket),events:Number(e.events??0),avg_fps:Number(e.avg_fps??0)})))}eventCounts(e){return this.get("api/v1/event-counts",e).then(e=>e.map(e=>({event_type:String(e.event_type),count:Number(e.count??0)})))}funnel(e,t){return this.get("api/v1/funnel",{...t,steps:JSON.stringify(e)}).then(e=>e.map(e=>({step:Number(e.step),sessions:Number(e.sessions??0)})))}coverage(e){return this.get("api/v1/coverage",e).then(e=>e.map(e=>({vx:Number(e.vx),vy:Number(e.vy),vz:Number(e.vz),count:Number(e.count??0)})))}cameraDistance(e){return this.get("api/v1/camera/distance",e).then(e=>e.map(e=>({bucket:Number(e.bucket),count:Number(e.count??0)})))}navigation(e){return this.get("api/v1/navigation",e).then(e=>e.map(e=>({session_id:String(e.session_id??""),segments:Number(e.segments??0),total_distance:Number(e.total_distance??0),active_segments:Number(e.active_segments??0),active_distance:Number(e.active_distance??0)})))}cameraGestures(e){return this.get("api/v1/camera-gestures",e).then(e=>e.map(e=>({kind:String(e.kind??""),gestures:Number(e.gestures??0),total_ms:Number(e.total_ms??0),avg_ms:Number(e.avg_ms??0),max_ms:Number(e.max_ms??0)})))}interactionsBySource(e){return this.get("api/v1/interactions/sources",e).then(e=>e.map(e=>({event_type:String(e.event_type??""),source:String(e.source??""),count:Number(e.count??0),sessions:Number(e.sessions??0)})))}sessionMeta(e){return this.get(`api/v1/sessions/${encodeURIComponent(e)}/meta`)}async sceneRepresentation(e){try{return await this.get(`api/v1/scenes/${encodeURIComponent(e)}/representation`)}catch(e){if(e instanceof i&&404===e.status)return null;throw e}}async liveToken(){let e=new URL("api/v1/live/token",l(this.baseUrl)),t=await fetch(e,{method:"POST",headers:{"x-api-key":this.apiKey},cache:"no-store"});if(!t.ok)throw new i(await t.text().catch(()=>"")||t.statusText,t.status);return await t.json()}livePresenceUrl(e){let t=new URL("api/v1/live/presence",l(this.baseUrl));return t.searchParams.set("token",e),t.toString()}liveStreamUrl(e,t){let s=new URL("api/v1/live/stream",l(this.baseUrl));return s.searchParams.set("token",e),t&&t.length>0&&s.searchParams.set("types",t.join(",")),s.toString()}liveSessionUrl(e,t){let s=new URL(`api/v1/live/sessions/${encodeURIComponent(t)}`,l(this.baseUrl));return s.searchParams.set("token",e),s.toString()}}function l(e){return e.endsWith("/")?e:`${e}/`}async function o(e,t){let s=await e.scenes(t).catch(()=>[]);if(0===s.length)return[];let n=await Promise.all(s.map(t=>e.sceneRepresentation(t.scene_id).catch(()=>null))),r=new Set,a=[];for(let e of n)for(let t of e?.proxy?.meshes??[])r.has(t.name)||(r.add(t.name),a.push(t));return a}e.s(["ApiError",0,i,"CollectorApi",0,c],20880),e.s(["mergeSceneProxies",0,o],89339);var u=e.i(94179);function h(e,t,s,n){let r={cancelled:!1,source:null,timer:null},a=0,i=async()=>{let i;if(r.cancelled)return;n(0===a?"connecting":"reconnecting");try{let{token:s}=await e.liveToken();i=t(s)}catch{c();return}if(r.cancelled)return;let l=new EventSource(i);r.source=l,l.onopen=()=>{a=0,n("open")},l.onerror=()=>{l.close(),r.source===l&&(r.source=null),c()},s(l)},c=()=>{if(r.cancelled)return;n("reconnecting");let e=Math.min(1e3*2**a,15e3);a+=1,r.timer=setTimeout(()=>void i(),e)};return i(),()=>{r.cancelled=!0,r.timer&&clearTimeout(r.timer),r.source?.close(),r.source=null}}async function m(e,t,s){let n=e.getReader(),r=new TextDecoder,a="";for(t.addEventListener("abort",()=>void n.cancel().catch(()=>{}));;){let{done:e,value:t}=await n.read();if(e)return;let i=(a+=r.decode(t,{stream:!0})).indexOf("\n\n");for(;i>=0;){let e=a.slice(0,i);a=a.slice(i+2);let t="message",n=[];for(let s of e.split("\n"))!s.startsWith(":")&&(s.startsWith("event:")?t=s.slice(6).trim():s.startsWith("data:")&&n.push(s.slice(5).replace(/^ /,"")));"event"===t&&n.length>0&&s(n.join("\n")),i=a.indexOf("\n\n")}}}e.s(["useLivePresence",0,function(e,t,s){let[n,r]=(0,u.useState)(null),[a,i]=(0,u.useState)("idle");return(0,u.useEffect)(()=>{if(!s||!t||!e){i("idle"),r(null);return}let n=new c(e,t);return h(n,e=>n.livePresenceUrl(e),e=>{e.addEventListener("presence",e=>{try{r(JSON.parse(e.data))}catch{}})},i)},[e,t,s]),{snapshot:n,status:a}},"useLiveSession",0,function(e,t,s,n,r,a){let[i,l]=(0,u.useState)("idle"),[o,h]=(0,u.useState)(!1),[p,d]=(0,u.useState)(0),b=(0,u.useRef)(r),g=(0,u.useRef)(a);return b.current=r,g.current=a,(0,u.useEffect)(()=>{if(!n||!t||!e||!s)return void l("idle");let r=new c(e,t),a=!1,i=0,o=null,u=null;h(!1),d(0);let p=()=>{if(a)return;l("reconnecting");let e=Math.min(1e3*2**i,15e3);i+=1,u=setTimeout(()=>void v(),e)},v=async()=>{let e;if(!a){l(0===i?"connecting":"reconnecting"),g.current(),d(0);try{({token:e}=await r.liveToken())}catch{p();return}if(!a){o=new AbortController;try{let t=await fetch(r.liveSessionUrl(e,s),{headers:{accept:"text/event-stream"},cache:"no-store",signal:o.signal});if(403===t.status){h(!0),l("idle");return}if(!t.ok||!t.body)return void p();i=0,l("open"),await m(t.body,o.signal,e=>{try{b.current(JSON.parse(e)),d(e=>e+1)}catch{}}),a||p()}catch{a||p()}}}};return v(),()=>{a=!0,u&&clearTimeout(u),o?.abort()}},[e,t,s,n]),{status:i,gated:o,count:p}},"useLiveStream",0,function(e,t,s,n,r){let[a,i]=(0,u.useState)("idle"),l=(0,u.useRef)(n);l.current=n;let o=r&&r.length>0?[...r].sort().join(","):"";return(0,u.useEffect)(()=>{if(!s||!t||!e)return void i("idle");let n=new c(e,t),r=o?o.split(","):void 0;return h(n,e=>n.liveStreamUrl(e,r),e=>{e.addEventListener("event",e=>{try{l.current(JSON.parse(e.data))}catch{}})},i)},[e,t,s,o]),{status:a}}],88725)},93425,e=>{"use strict";var t=e.i(29212),s=e.i(94179);function n({children:e,label:s="More information"}){return(0,t.jsxs)("span",{className:"group relative inline-flex",children:[(0,t.jsx)("button",{type:"button","aria-label":s,className:"flex h-4 w-4 items-center justify-center rounded-full border border-edge text-[10px] font-bold leading-none text-fg-muted transition hover:border-amber hover:text-fg-hi focus:outline-none focus:ring-1 focus:ring-amber",children:"?"}),(0,t.jsx)("span",{role:"tooltip",className:"pointer-events-none absolute left-1/2 top-6 z-20 w-64 -translate-x-1/2 rounded-md border border-edge bg-ink/95 p-2.5 text-xs font-normal normal-case leading-relaxed tracking-normal text-fg opacity-0 shadow-lg shadow-black/40 transition-opacity duration-150 group-hover:opacity-100 group-focus-within:opacity-100",children:e})]})}function r({label:e,onClick:s,active:n=!1,children:a}){return(0,t.jsx)("button",{type:"button","aria-label":e,title:e,onClick:s,"aria-pressed":n,className:`flex h-6 w-6 items-center justify-center rounded-md border text-sm leading-none transition focus:outline-none focus:ring-1 focus:ring-amber ${n?"border-amber text-amber":"border-edge text-fg-muted hover:border-amber hover:text-fg-hi"}`,children:a})}e.s(["Panel",0,function({title:e,subtitle:a,help:i,children:c,className:l="",collapsible:o=!1,defaultCollapsed:u=!1,onHide:h,settings:m}){let[p,d]=(0,s.useState)(o&&u),[b,g]=(0,s.useState)(!1),v=(0,t.jsxs)("header",{className:p?"":"mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold uppercase tracking-wide text-fg",children:e}),o?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-xs text-fg-muted",children:p?"▸":"▾"}):null,i?(0,t.jsx)(n,{label:`About: ${e}`,children:i}):null]}),a?(0,t.jsx)("p",{className:"mt-0.5 text-xs text-fg-muted",children:a}):null]}),f=!!m||!!h;return(0,t.jsxs)("section",{className:`rounded-xl border border-edge bg-panel p-4 shadow-lg shadow-black/20 ${l}`,children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[o?(0,t.jsx)("button",{type:"button",onClick:()=>d(e=>!e),"aria-expanded":p?"false":"true",className:"min-w-0 flex-1 text-left",children:v}):(0,t.jsx)("div",{className:"min-w-0 flex-1",children:v}),f?(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[m?(0,t.jsx)(r,{label:`${e} settings`,active:b,onClick:()=>g(e=>!e),children:(0,t.jsx)("span",{"aria-hidden":"true",children:"⚙"})}):null,h?(0,t.jsx)(r,{label:`Hide ${e}`,onClick:h,children:(0,t.jsx)("span",{"aria-hidden":"true",children:"×"})}):null]}):null]}),m&&b?(0,t.jsx)("div",{className:"mb-3 rounded-lg border border-edge bg-ink/40 p-3",children:m}):null,p?null:c]})}])},62238,e=>{"use strict";e.s(["ZOOM_IN_FACTOR",0,1/1.2,"ZOOM_OUT_FACTOR",0,1.2,"attachDoubleClickFocus",0,function(e,t,s){let n=()=>{let t=e.pick(e.pointerX,e.pointerY);t?.hit&&t.pickedPoint&&s.setTarget(t.pickedPoint)};return t.addEventListener("dblclick",n),()=>t.removeEventListener("dblclick",n)},"disableWheelZoom",0,function(e){e.inputs.removeByType("ArcRotateCameraMouseWheelInput")},"resetFocus",0,function(e,t){e.setTarget(t.target),e.alpha=t.alpha,e.beta=t.beta,e.radius=t.radius},"stepZoom",0,function(e,t){let s=e.lowerRadiusLimit??.01,n=e.upperRadiusLimit??1/0;e.radius=Math.min(n,Math.max(s,e.radius*t))}])},42279,e=>{"use strict";var t=e.i(29212),s=e.i(62238);e.s(["ZoomButtons",0,function({onZoom:e,onReset:n}){let r="grid h-8 w-8 place-items-center rounded-md border border-edge bg-ink/80 text-lg leading-none text-fg backdrop-blur transition hover:bg-ink hover:text-white";return(0,t.jsxs)("div",{className:"absolute right-3 top-3 flex flex-col gap-1",children:[(0,t.jsx)("button",{type:"button","aria-label":"Zoom in",className:r,onClick:()=>e(s.ZOOM_IN_FACTOR),children:"+"}),(0,t.jsx)("button",{type:"button","aria-label":"Zoom out",className:r,onClick:()=>e(s.ZOOM_OUT_FACTOR),children:"−"}),n?(0,t.jsx)("button",{type:"button","aria-label":"Reset camera focus to center",title:"Reset focus to center",className:r,onClick:n,children:(0,t.jsxs)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":"true",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"3"}),(0,t.jsx)("path",{d:"M8 1v2.5M8 12.5V15M1 8h2.5M12.5 8H15"})]})}):null]})}])},56054,59683,37660,e=>{"use strict";let t="linear-gradient(to right, rgb(178,47,38), rgb(224,123,57), rgb(244,200,75))";e.s(["HEAT_GRADIENT",0,t,"heatRgb",0,function(e){let t=Math.max(0,Math.min(1,e)),s=[.878,.482,.224],n=(e,t,s)=>[e[0]+(t[0]-e[0])*s,e[1]+(t[1]-e[1])*s,e[2]+(t[2]-e[2])*s];return t<.5?n([.698,.184,.149],s,t/.5):n(s,[.957,.784,.294],(t-.5)/.5)},"percentileMax",0,function(e,t=.95){if(0===e.length)return 1;let s=[...e].sort((e,t)=>e-t),n=Math.max(0,Math.min(1,t))*(s.length-1),r=Math.floor(n),a=Math.ceil(n);return Math.max(1,r===a?s[r]:s[r]+(s[a]-s[r])*(n-r))}],56054),e.s(["attachMeshHover",0,function(e,t,s){let n=0,r=null,a=t=>{let a=t.offsetX,i=t.offsetY;n||(n=requestAnimationFrame(()=>{var t,c;let l;n=0;let o=e.pick(a,i,e=>e.isPickable&&e.isEnabled()),u=o?.pickedMesh?(t=o.pickedMesh,c=o.thinInstanceIndex??-1,(l=t.metadata)?c>=0&&l.hoverLabels?l.hoverLabels[c]??null:l.hoverLabel??null:null):null;u?s({label:u,x:a,y:i}):null!==r&&s(null),r=u}))},i=()=>{n&&(cancelAnimationFrame(n),n=0),null!==r&&(r=null,s(null))};return t.addEventListener("pointermove",a),t.addEventListener("pointerleave",i),()=>{t.removeEventListener("pointermove",a),t.removeEventListener("pointerleave",i),n&&cancelAnimationFrame(n)}}],59683);var s=e.i(29212);e.s(["HeatLegend",0,function({title:e,lowLabel:n="low",highLabel:r="high",note:a}){return(0,s.jsxs)("div",{className:"pointer-events-none absolute bottom-3 left-3 rounded-md border border-edge bg-ink/80 px-3 py-2 text-fg backdrop-blur-sm",children:[(0,s.jsx)("div",{className:"mb-1 text-xs font-medium text-fg",children:e}),(0,s.jsx)("div",{className:"h-2 w-36 rounded-sm",style:{background:t}}),(0,s.jsxs)("div",{className:"mt-1 flex w-36 justify-between text-[10px] text-fg-muted",children:[(0,s.jsx)("span",{children:n}),(0,s.jsx)("span",{children:r})]}),a?(0,s.jsx)("div",{className:"mt-1 max-w-44 text-[10px] leading-tight text-fg-muted",children:a}):null]})}],37660)},38413,e=>{"use strict";var t=e.i(29212),s=e.i(94179),n=e.i(56054),r=e.i(62238),a=e.i(59683),i=e.i(37660),c=e.i(93425),l=e.i(42279);let o="World heatmap (3D)",u="Pointer hit-points voxel-binned in world space — drag to orbit, +/- to zoom, double-click to focus";function h({voxels:c,cellSize:o,proxyMeshes:u=[],legendTitle:p="Pointer-hit density",legendLow:d="few hits",legendHigh:b="most hits",legendNote:g="Each marker is a voxel where the pointer hit your scene. Color & size scale with hits, normalized to the 95th-percentile cell so a few hotspots don't wash out the rest.",emptyLabel:v="No 3D hit-points in range.",totals:f}){let x=(0,s.useRef)(null),k=(0,s.useRef)(null),j=(0,s.useRef)(null),[_,N]=(0,s.useState)("loading"),[y,w]=(0,s.useState)(null),[z,S]=(0,s.useState)("sphere"),[L,P]=(0,s.useState)(null);(0,s.useEffect)(()=>{let t=x.current;if(!t)return;if(0===c.length&&0===u.length)return void N("empty");let s=!1,i=null;return N("loading"),w(null),(async()=>{try{let[{Engine:l},{Scene:h},{ArcRotateCamera:m},{HemisphericLight:p},{Vector3:d,Color3:b,Color4:g,Matrix:v},{MeshBuilder:f},{StandardMaterial:x}]=await Promise.all([e.A(66022),e.A(48505),e.A(53976),e.A(42436),e.A(89370),e.A(67141),e.A(20693),e.A(9607),e.A(96664)]);if(s)return;let _=(0,n.percentileMax)(c.map(e=>e.count),.95),y=0,w=0,S=0,L=0;for(let e of c)y+=(e.vx+.5)*o,w+=(e.vy+.5)*o,S+=(e.vz+.5)*o,L++;if(0===L)for(let e of u)y+=(e.aabb[0]+e.aabb[3])/2,w+=(e.aabb[1]+e.aabb[4])/2,S+=(e.aabb[2]+e.aabb[5])/2,L++;let R=new d(y/L,w/L,S/L),T=4*o;for(let e of c){let t=(e.vx+.5)*o-R.x,s=(e.vy+.5)*o-R.y,n=(e.vz+.5)*o-R.z;T=Math.max(T,Math.sqrt(t*t+s*s+n*n))}for(let e of u){let t=(e.aabb[0]+e.aabb[3])/2-R.x,s=(e.aabb[1]+e.aabb[4])/2-R.y,n=(e.aabb[2]+e.aabb[5])/2-R.z;T=Math.max(T,Math.sqrt(t*t+s*s+n*n))}let C=new l(t,!0,{preserveDrawingBuffer:!1}),A=new h(C);A.clearColor=new g(.04,.05,.07,1);let M=new m("world-cam",Math.PI/4,Math.PI/3,2.4*T,R,A);if(M.attachControl(t,!0),(0,r.disableWheelZoom)(M),k.current=M,j.current={target:R,alpha:M.alpha,beta:M.beta,radius:M.radius},new p("world-light",new d(.4,1,.3),A),u.length>0){let e=f.CreateBox("scene-proxy",{size:1},A),t=new x("scene-proxy-mat",A);t.wireframe=!0,t.disableLighting=!0,t.emissiveColor=new b(.32,.4,.52),t.alpha=.35,e.material=t,e.isPickable=!0,e.thinInstanceEnablePicking=!0,e.metadata={hoverLabels:u.map(e=>e.name)};let s=u.length,n=new Float32Array(16*s);for(let e=0;e<s;e++){let t=u[e].aabb,s=Math.max(t[3]-t[0],.001),r=Math.max(t[4]-t[1],.001),a=Math.max(t[5]-t[2],.001);v.Scaling(s,r,a).multiply(v.Translation((t[0]+t[3])/2,(t[1]+t[4])/2,(t[2]+t[5])/2)).copyToArray(n,16*e)}e.thinInstanceSetBuffer("matrix",n,16,!0)}if(c.length>0){let e="cube"===z?f.CreateBox("world-voxel",{size:.9*o},A):f.CreateSphere("world-voxel",{diameter:.9*o,segments:6},A),t=new x("world-voxel-mat",A);t.diffuseColor=new b(1,1,1),t.specularColor=new b(0,0,0),e.material=t;let s=c.length,r=new Float32Array(16*s),a=new Float32Array(4*s),i=new Float32Array(s),l=Math.max(.02*T,.25*o)/(.9*o);for(let e=0;e<s;e++){let t=c[e],s=Math.min(1,t.count/_),u=l*(.5+.5*s);i[e]=u,v.Scaling(u,u,u).multiply(v.Translation((t.vx+.5)*o,(t.vy+.5)*o,(t.vz+.5)*o)).copyToArray(r,16*e);let[h,m,p]=(0,n.heatRgb)(s);a[4*e]=h,a[4*e+1]=m,a[4*e+2]=p,a[4*e+3]=1}e.thinInstanceSetBuffer("matrix",r,16,!1),e.thinInstanceSetBuffer("color",a,4,!0);let u=M.radius,h=0,m=()=>{let t=Math.min(8,Math.max(.6,M.radius/u));if(!(.01>Math.abs(t-h))){h=t;for(let e=0;e<s;e++){let s=i[e]*t,n=16*e;r[n]=s,r[n+5]=s,r[n+10]=s}e.thinInstanceBufferUpdated("matrix")}};m(),A.onBeforeRenderObservable.add(m)}C.runRenderLoop(()=>A.render());let q=()=>C.resize();window.addEventListener("resize",q);let E=(0,a.attachMeshHover)(A,t,P),U=(0,r.attachDoubleClickFocus)(A,t,M);N("ready"),i=()=>{window.removeEventListener("resize",q),E(),U(),P(null),k.current=null,j.current=null,A.dispose(),C.dispose()}}catch(e){if(s)return;N("error"),w(e instanceof Error?e.message:"Failed to render heatmap.")}})(),()=>{s=!0,i?.()}},[c,o,u,z]);let R=f?f.cells>c.length?` Showing the ${c.length.toLocaleString()} busiest of ${f.cells.toLocaleString()} occupied cells (${f.hits.toLocaleString()} total hits).`:` ${f.cells.toLocaleString()} occupied cells, ${f.hits.toLocaleString()} total hits.`:"";return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("canvas",{ref:x,className:"aspect-video w-full rounded-lg border border-edge bg-ink"}),L?(0,t.jsx)("div",{className:"pointer-events-none absolute z-10 max-w-[16rem] truncate rounded border border-edge bg-ink/90 px-1.5 py-0.5 text-xs text-white shadow backdrop-blur",style:{left:L.x+12,top:L.y+12},children:L.label}):null,"ready"===_?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m,{shape:z,onChange:S}),(0,t.jsx)(l.ZoomButtons,{onZoom:e=>k.current&&(0,r.stepZoom)(k.current,e),onReset:()=>k.current&&j.current&&(0,r.resetFocus)(k.current,j.current)}),(0,t.jsx)(i.HeatLegend,{title:p,lowLabel:d,highLabel:b,note:g+R})]}):(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-sm text-fg-muted",children:"loading"===_?"Rendering…":"empty"===_?v:"error"===_?y??"Heatmap unavailable.":null})]})}function m({shape:e,onChange:s}){let n=e=>`h-8 px-2.5 text-xs font-medium leading-none transition first:rounded-l-md last:rounded-r-md ${e?"bg-ink text-white":"bg-ink/80 text-fg hover:text-white"}`,r="sphere"===e,a="cube"===e;return(0,t.jsxs)("div",{className:"absolute left-3 top-3 flex overflow-hidden rounded-md border border-edge backdrop-blur",role:"group","aria-label":"Voxel marker shape",children:[(0,t.jsx)("button",{type:"button",className:n(r),"aria-pressed":r,onClick:()=>s("sphere"),children:"Spheres"}),(0,t.jsx)("button",{type:"button",className:n(a),"aria-pressed":a,onClick:()=>s("cube"),children:"Cubes"})]})}e.s(["WORLD_HEATMAP_SUBTITLE",0,u,"WORLD_HEATMAP_TITLE",0,o,"WorldHeatmap3D",0,function({title:e=o,subtitle:s=u,...n}){return(0,t.jsx)(c.Panel,{title:e,subtitle:s,children:(0,t.jsx)(h,{...n})})},"WorldHeatmap3DView",0,h])},66022,e=>{e.v(t=>Promise.all(["static/chunks/0v82oqyoy9zol.js","static/chunks/2ycvtdd68gub7.js","static/chunks/1uu93wuxigx4k.js","static/chunks/30-tbi7pys6fp.js","static/chunks/0grlb9lo8e502.js","static/chunks/1nj82er7msdto.js","static/chunks/1zj8x5wbgnzz-.js"].map(t=>e.l(t))).then(()=>t(94080)))},48505,e=>{e.v(t=>Promise.all(["static/chunks/43s_lbd1i2krj.js","static/chunks/0c83pe1mpx456.js","static/chunks/0v82oqyoy9zol.js","static/chunks/31u5lbu1vxznh.js","static/chunks/1nj82er7msdto.js","static/chunks/431slrqh0wa0g.js","static/chunks/2izioctrfc0s5.js","static/chunks/30-tbi7pys6fp.js","static/chunks/3-eswqjobiqk1.js"].map(t=>e.l(t))).then(()=>t(73073)))},53976,e=>{e.v(t=>Promise.all(["static/chunks/0c83pe1mpx456.js","static/chunks/14bws-suyy5zu.js","static/chunks/3xagd_2_9zft2.js","static/chunks/2izioctrfc0s5.js","static/chunks/0v82oqyoy9zol.js","static/chunks/290d93hmm_e8b.js","static/chunks/3sdoskq_buttj.js","static/chunks/1nj82er7msdto.js","static/chunks/3-eswqjobiqk1.js","static/chunks/30-tbi7pys6fp.js","static/chunks/31u5lbu1vxznh.js","static/chunks/3e8fmlq0k5wkg.js"].map(t=>e.l(t))).then(()=>t(18662)))},42436,e=>{e.v(t=>Promise.all(["static/chunks/1gs-5722l4u59.js","static/chunks/1ynju1jqfrcv0.js","static/chunks/2izioctrfc0s5.js","static/chunks/30-tbi7pys6fp.js","static/chunks/0v82oqyoy9zol.js"].map(t=>e.l(t))).then(()=>t(12847)))},89370,e=>{e.v(t=>Promise.all(["static/chunks/0dm32-jq30tg8.js","static/chunks/30-tbi7pys6fp.js","static/chunks/0v82oqyoy9zol.js"].map(t=>e.l(t))).then(()=>t(62566)))},67141,e=>{e.v(t=>Promise.all(["static/chunks/1zl6t15gh34nn.js","static/chunks/0c83pe1mpx456.js","static/chunks/0titqrn1qmcsv.js","static/chunks/33dgpebv-tf73.js","static/chunks/0v82oqyoy9zol.js","static/chunks/2d6hru4qo23tt.js","static/chunks/14bws-suyy5zu.js","static/chunks/3xagd_2_9zft2.js","static/chunks/1nj82er7msdto.js","static/chunks/3e8fmlq0k5wkg.js","static/chunks/2izioctrfc0s5.js","static/chunks/431slrqh0wa0g.js","static/chunks/3-eswqjobiqk1.js","static/chunks/30-tbi7pys6fp.js","static/chunks/31u5lbu1vxznh.js","static/chunks/2veqsohwfhfqc.js"].map(t=>e.l(t))).then(()=>t(97998)))},20693,e=>{e.v(t=>Promise.all(["static/chunks/0tnlbw78tgaxp.js","static/chunks/19016f8-ry0z6.js","static/chunks/0c83pe1mpx456.js","static/chunks/2izioctrfc0s5.js","static/chunks/3ne77mjdz2y7o.js","static/chunks/0v82oqyoy9zol.js","static/chunks/3-eswqjobiqk1.js","static/chunks/1nj82er7msdto.js","static/chunks/3xagd_2_9zft2.js","static/chunks/431slrqh0wa0g.js","static/chunks/31u5lbu1vxznh.js","static/chunks/30-tbi7pys6fp.js"].map(t=>e.l(t))).then(()=>t(32550)))},8850,e=>{e.v(t=>Promise.all(["static/chunks/3edelqkq92pil.js","static/chunks/0c83pe1mpx456.js","static/chunks/2izioctrfc0s5.js","static/chunks/31u5lbu1vxznh.js","static/chunks/2hpxou_cnp4f_.js","static/chunks/3-eswqjobiqk1.js","static/chunks/3xagd_2_9zft2.js","static/chunks/3e8fmlq0k5wkg.js","static/chunks/1nj82er7msdto.js","static/chunks/30-tbi7pys6fp.js","static/chunks/0v82oqyoy9zol.js"].map(t=>e.l(t))).then(()=>t(35131)))},63836,e=>{e.v(t=>Promise.all(["static/chunks/04_yytpc2paxy.js","static/chunks/002cjeoit6-up.js","static/chunks/0v82oqyoy9zol.js","static/chunks/1nj82er7msdto.js","static/chunks/0grlb9lo8e502.js","static/chunks/30-tbi7pys6fp.js","static/chunks/223vrr_4sfhsj.js"].map(t=>e.l(t))).then(()=>t(14960)))},9607,e=>{e.v(t=>Promise.all(["static/chunks/1hatz-jlztrn0.js","static/chunks/0c83pe1mpx456.js","static/chunks/2izioctrfc0s5.js","static/chunks/31u5lbu1vxznh.js","static/chunks/2hpxou_cnp4f_.js","static/chunks/30-tbi7pys6fp.js","static/chunks/3xagd_2_9zft2.js","static/chunks/1nj82er7msdto.js","static/chunks/3-eswqjobiqk1.js","static/chunks/3e8fmlq0k5wkg.js","static/chunks/0v82oqyoy9zol.js"].map(t=>e.l(t))).then(()=>t(26831)))},96664,e=>{e.v(t=>Promise.all(["static/chunks/0c83pe1mpx456.js","static/chunks/2hpxou_cnp4f_.js","static/chunks/0v82oqyoy9zol.js","static/chunks/31u5lbu1vxznh.js","static/chunks/3coacc4-g-g5c.js","static/chunks/30-tbi7pys6fp.js","static/chunks/2izioctrfc0s5.js","static/chunks/431slrqh0wa0g.js","static/chunks/3-eswqjobiqk1.js","static/chunks/1nj82er7msdto.js"].map(t=>e.l(t))).then(()=>t(44981)))},69091,e=>{e.v(t=>Promise.all(["static/chunks/2nck5w4c7leb7.js"].map(t=>e.l(t))).then(()=>t(12449)))},33996,e=>{e.v(t=>Promise.all(["static/chunks/0g_v2zswo4l6f.js"].map(t=>e.l(t))).then(()=>t(25453)))},56403,e=>{e.v(t=>Promise.all(["static/chunks/0927l-ygd5c8d.js"].map(t=>e.l(t))).then(()=>t(61518)))}]);
|