@zortexhq/indra-v2.5 0.2.3 → 0.2.4
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/dist/measurement-context.js +1 -1
- package/dist/product-feedback.js +2 -2
- package/dist/profile.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/dist/galaxy-text.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/dist/localizer.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/dist/routes.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/account.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-i18n-twin.js +1 -0
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-i18n.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-model.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-text.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app.html +92 -36
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/connection-panel.js +1 -0
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/galaxy-renderer.js +13 -0
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/galaxy.html +141 -0
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/live-model.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/live-state.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/panels-live.js +3 -3
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/product.js +1 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/shell.css +16 -46
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/shell.js +1 -1
- package/node_modules/@zortexhq/plugin-posthog/dist/activity.js +1 -0
- package/node_modules/@zortexhq/plugin-posthog/dist/northstar.js +1 -1
- package/node_modules/@zortexhq/plugin-telemetry/dist/api/measurement.js +1 -1
- package/node_modules/@zortexhq/plugin-telemetry/dist/api/telemetry.js +1 -1
- package/node_modules/@zortexhq/plugin-telemetry/dist/device-identity.js +1 -0
- package/node_modules/@zortexhq/plugin-telemetry/dist/index.js +1 -1
- package/package.json +6 -6
- package/profiles/core.yml +1 -0
- package/release-provenance.json +13 -13
- package/update-manifest.json +91 -67
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-catalog.js +0 -1
- package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/demo.js +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{graphFacts}from"./product-model.js";import{esc}from"./setup-model.js";import{mountNodes}from"./star-graph-nodes.js";import{mountTopics}from"./star-graph-topics.js";import{sourceBands,mountSourcesBig,totalGraph}from"./star-graph-sources.js";import{mountLinks}from"./star-graph-links.js";import{mountFogLinks}from"./star-graph-fog-links.js";import{readViewState,writeViewState,timelineIndex,cameraSnapshot,restoreCamera}from"./star-graph-view-state.js";import{loadTwinCPU}from"./star-graph-cpu.js";import{timelinePainter}from"./star-graph-timeline-paint.js";(async()=>{const params=new URLSearchParams(location.search),$=id=>document.getElementById(id);const demo=params.get("demo")==="1",compact=params.get("compact")==="1";const message=$("graph-message");try{const response=await fetch(demo?"demo-profile.json":"star-graph-data.json");if(!response.ok)throw new Error("Personal graph data unavailable");window.GALAXY_ROWS=await response.json();if(window.ZX_LOOK!=="plain")await loadTwinCPU();await new Promise((resolve,reject)=>{const script=document.createElement("script");script.src=window.ZX_LOOK==="plain"?"star-graph-plain.gen.js":"star-graph-twin.gen.js";script.onload=resolve;script.onerror=reject;document.body.appendChild(script)});if(!window.galaxy?.ready||!window.__portrait)throw new Error("Personal graph unavailable");if(!compact)await home();requestAnimationFrame(()=>$("universe").classList.add("ready"));if(demo&¶ms.get("forming")==="1"){const[{loadDemo},{progress},catalogue]=await Promise.all([import("./demo-state.js"),import("./setup-model.js"),fetch("abilities.json").then(r=>r.json())]);const idle=Number(params.get("idle"))||0;let forming,sent=null,away=false;try{away=parent!==window&&parent.location.origin!==location.origin}catch{away=true}addEventListener("message",e=>{if(e.source===parent&&e.data?.type==="zortex-demo"&&e.data.state){sent=e.data.state;update()}});const update=()=>{const state=sent??(away?null:loadDemo());if(!state)return;const p=state.run?progress(state,catalogue.apps):idle?{percent:0,done:false}:{percent:100,done:true};window.galaxy.setForm(Math.max(idle||.08,p.percent/100));if(p.done)clearInterval(forming)};forming=setInterval(update,300);update();if(away)parent.postMessage({type:"zortex-demo-ask"},"*");addEventListener("pagehide",()=>clearInterval(forming))}}catch{window.galaxy?.stop();$("universe").hidden=true;message.hidden=false;message.textContent="Your twin isn\u2019t available yet."}async function home(){const galaxy=window.galaxy,rows=window.GALAXY_ROWS;let shown=rows,facts=graphFacts(rows);const panel=$("world"),toggle=$("world-toggle");const VIEW_KEY=demo?null:"zx-twin-view-v1";let viewStorage=null;try{viewStorage=sessionStorage}catch{}const previousView=readViewState(viewStorage,VIEW_KEY);let restoringView=true,saveViewTimer=0,selectedPerson=null;function persistView(){clearTimeout(saveViewTimer);if(restoringView)return;const snapshots=history?.snapshots;const position=want==null?at:want;writeViewState(viewStorage,VIEW_KEY,{version:1,mode,person:selectedPerson,date:mode==="time"&&snapshots?.length?position===snapshots.length-1?"today":snapshots[position]?.as_of:null,playing:!!playing,panel:panel.hidden?null:view,scroll:panel.scrollTop,camera:cameraSnapshot(galaxy.state,inset,galaxy.viewScale())})}function rememberView(){if(restoringView)return;clearTimeout(saveViewTimer);saveViewTimer=setTimeout(persistView,120)}$("controls").hidden=false;const ask=text=>parent.postMessage({type:"zortex-compose",text},"*");let nodes=null,nodesData=null;if(!demo){const data=nodesData=await fetch("star-graph-nodes.json").then(r=>r.ok?r.json():null).catch(()=>null);try{if(data)nodes=mountNodes({galaxy,data,canvas:$("universe"),overlay:$("nodes"),card:$("node-card"),onAsk:ask})}catch(error){console.error("Could not place the real things on the twin",error)}}const sources=data=>new Set([...(data?.things||[]).map(t=>t.label),...(data?.people||[]).map(p=>p.via)]).size;const links=galaxy.live&&rows.mode!=="record-map"?mountLinks({galaxy,canvas:$("links"),sources:nodesData?sources(nodesData):3}):null;window.zxLinks=links;window.zxNodes=nodes;const unlit=[];unlit.push=function(x){if(this.length>500)this.shift();return Array.prototype.push.call(this,x)};window.zxUnlit=()=>unlit.splice(0);let feedHover=()=>{},streaming=false,resumable=false,step=[],flying=[],waiting=[],ended=false;if(nodes){const queue=[];feedHover=list=>{if(mode!=="time"||!playing)return;const now=performance.now();for(const a of list)if(a.related.length)queue.push({...a,at:now});queue.sort((x,y)=>y.weight-x.weight);queue.length=Math.min(queue.length,8)};nodes.onArrive=list=>feedHover(list);window.zxWaiting=()=>waiting.length;window.zxFlying=()=>flying.length;window.zxLanes=()=>step.map(x=>x&&[x.phase,Math.round(performance.now()-x.at),+(galaxy.gap?.(x.a.star)??-1).toFixed(3)]);setInterval(()=>{if(mode!=="time"||!playing){queue.length=0;return}if(streaming){queue.length=0;if(nodes.auto!=null)nodes.auto=null;return}const now=performance.now();while(queue.length&&now-queue[0].at>1500)queue.shift();const a=queue.shift();if(!a)return;nodes.auto=a.node;if(!streaming)galaxy.bring?.(a.star,a.related)},220)}let fogLinks=null;if(galaxy.linkDots&&galaxy.layers){fogLinks=mountFogLinks({galaxy});window.zxFogLinks=fogLinks}const count=n=>new Intl.NumberFormat("en").format(n),plural=(n,one,many=one+"s")=>`${count(n)} ${n===1?one:many}`;if(nodes){const n=nodes.counts,f=x=>x.toLocaleString("en");$("world-note").textContent=`Zoom in and every point is something real: one of the ${f(n.things)} things in your vault (the ${f(n.made)} you made shine brighter than the ${f(n.kept)} you keep), or one of your ${f(n.people)} people. Around the twin is what a thing is about; out from the centre is when it came. Your people are the small companions.`}$("modes-foot").textContent=nodes?`${count(nodes.counts.things+nodes.counts.people)} things and people, from your vault`:demo?"An example twin, made up":"Drawn from your vault";const day=iso=>new Intl.DateTimeFormat("en",{day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}).format(new Date(iso));let pendingFacts=null;function fill(r,when,force=false){shown=r;facts=graphFacts(r);pendingFacts={r,when};$("facts-count").textContent=plural(facts.length,"measurement");if(!force&&(panel.hidden||panel.dataset.view!=="facts"))return;pendingFacts=null;$("world-sub").textContent=r.mode==="record-map"?`${when}. Real record map; semantic portrait has not been calculated. Geometry is layout only.`:r.evidence?.semantic==="measured-subset"?`${when}. Measured from an authored subset with existing vectors. Unknown dimensions use layout defaults; see coverage.`:`${when}. Each part of it comes from one of these measurements.`;$("world-facts").innerHTML=facts.map((f,i)=>`<article class="fact">
|
|
2
|
+
<p class="fact-name">${esc(f.name)}</p>
|
|
3
|
+
<p class="fact-figure"><strong>${esc(f.figure)}</strong>${esc(f.unit)}</p>
|
|
4
|
+
${f.sentence?`<p class="fact-sentence">${esc(f.sentence)}</p>`:""}
|
|
5
|
+
${picture(f.visual)}
|
|
6
|
+
<p class="fact-twin"><b>In the twin: ${esc(f.shape.toLowerCase())}</b>${esc(f.description)}</p>
|
|
7
|
+
<button class="fact-ask" type="button" data-ask="${i}">Ask Zortex about this \u203A</button>
|
|
8
|
+
</article>`).join("")}const yours=demo?"An example twin":`Your twin on ${day(rows.as_of)}`;fill(rows,yours);$("world-facts").onclick=e=>{const fact=facts[e.target.closest("[data-ask]")?.dataset.ask];if(!fact)return;ask(`Explain this part of my twin in plain language. ${demo||shown.as_of==="example"?"Fictional example":`Snapshot ${shown.as_of}`}: ${fact.name} \u2014 ${fact.value}. ${fact.detail} In the twin it is ${fact.shape.toLowerCase()}. What does this tell me, and what are its limits?`)};let view="modes";function setView(v){view=v;panel.dataset.view=v;panel.querySelectorAll(".view").forEach(el=>{el.hidden=el.dataset.for!==v});panel.setAttribute("aria-labelledby",{modes:"modes-title",facts:"world-title",play:"play-title"}[v]);panel.scrollTop=0;if(v==="modes")thumbs();if(v==="facts"&&pendingFacts)fill(pendingFacts.r,pendingFacts.when,true);rememberView()}function setPanel(open,v=mode==="play"?"play":"modes"){if(open)setView(v);panel.hidden=!open;toggle.setAttribute("aria-expanded",String(open));if(mode==="time"){$("settings-btn").setAttribute("aria-expanded",String(open&&v==="play"))}document.body.toggleAttribute("data-play-open",open&&v==="play"&&mode==="time");if(open)panel.querySelector(`.view[data-for="${v}"] :is([data-close], .done)`)?.focus({preventScroll:true});rememberView()}toggle.onclick=()=>setPanel(panel.hidden);new MutationObserver(()=>{$("time-side").hidden=$("time").hidden}).observe($("time"),{attributes:true,attributeFilter:["hidden"]});let downAt=null;addEventListener("pointerdown",e=>{downAt=[e.clientX,e.clientY]},true);addEventListener("click",e=>{if(!downAt||Math.hypot(e.clientX-downAt[0],e.clientY-downAt[1])>6)return;if(mode!=="time"||panel.hidden||view!=="play"||panel.contains(e.target)||e.target.closest?.("#settings-btn"))return;setPanel(false)},true);panel.addEventListener("click",e=>{if(e.target.closest("[data-close]")){setPanel(false);toggle.focus();return}const to=e.target.closest("button[data-view]")?.dataset.view;if(to)setView(to)});$("universe").addEventListener("pointerdown",()=>{if(!panel.hidden&&view!=="play")setPanel(false)});const tiles=[...panel.querySelectorAll(".mode")];if(!galaxy.reshape)tiles.forEach(t=>{if(t.dataset.mode!=="twin")t.hidden=true});const check=m=>{tiles.forEach(t=>t.setAttribute("aria-checked",String(t.dataset.mode===({time:"play"}[m]||m||"twin"))));parent.postMessage({type:"zortex-twin-mode",mode:m||"twin"},"*");document.body.dataset.mode=m||"twin"};$("modes").onclick=e=>{const m=e.target.closest(".mode")?.dataset.mode;if(!m)return;if(m==="twin")backToYou();else openMode(m==="play"?"time":m);setPanel(false)};const time=$("time"),others=$("others"),month=iso=>new Intl.DateTimeFormat("en",{month:"short",year:"numeric",timeZone:"UTC"}).format(new Date(iso));let mode=null,history=null,people=null,at=0,want=null,playing=null,backTimer,modeRun=0;let other=false,lit=1,past=null;const id=who=>who?`rows:example:${who}`:void 0;const theirs=p=>p&&{...p.rows,anchor:rows};const loadPeople=async()=>people||=await fetch("star-graph-others.json").then(r=>r.ok?r.json():null).catch(()=>null);const thingsBack=ms=>{clearTimeout(backTimer);backTimer=setTimeout(()=>{if(nodes&&!other&&lit>=1)nodes.away=false},ms+50)};function whole(ms){if(lit<1||galaxy.state.form<1){lit=1;galaxy.growTo(1,ms)}}function endGrowth(){visualActive=null;visualClosing=false;galaxy.presentation?.(false);if(resumable){resumable=false;knob=null;nodes?.streamEnd()}galaxy.still?.(false)}function leaving(){endGrowth();if(mode==="play")leavePlay();if(mode==="insights")topics?.shut(true);if(mode==="time"){feedClear();past=null;nodes?.timeline(null,700);if(nodes)nodes.marks="names";if(!panel.hidden&&view==="play")setPanel(false);leavePlay();axis(true);fullScreen(false)}}function draw(r,ms,who,flow){clearTimeout(backTimer);if(nodes)nodes.away=true;whole(ms);other=true;galaxy.reshape(r,ms,id(who),flow)}function backToYou(){modeRun++;selectedPerson=null;stop();leaving();mode=null;check(null);time.hidden=others.hidden=true;galaxy.spinClose?.(false);rememberView();if(shown===rows&&!other&&lit>=1)return;whole(800);if(other){galaxy.reshape(rows,800);other=false}if(shown!==rows)fill(rows,yours);thingsBack(800)}async function openMode(which,resume=null){if(mode===which)return;const mine=++modeRun;stop();leaving();mode=which;selectedPerson=null;check(which);galaxy.spinClose?.(true);time.hidden=which!=="time";others.hidden=which!=="others";if(which==="time"){if(nodes)nodes.marks=marksAt;entry={tilt:galaxy.state.targetTilt,speed:galaxy.state.speed,paused:galaxy.state.paused};galaxy.setPaused(true);if(pg.who!==-1){pg={who:-1,set:Object.fromEntries(Object.entries(pg.set).filter(([k])=>!/^(f|c)\./.test(k)))};save()}base=galaxy.featuresOf(rows);applyNow();history||=await fetch("star-graph-history.json").then(r=>r.ok?r.json():null).catch(()=>null);if(mine!==modeRun)return;const snaps=history?.snapshots||[];if(!snaps.length){$("time-date").textContent="No history yet";$("time-line").textContent="Your twin over time needs a saved history from this Mac.";return}years(snaps);at=resume?timelineIndex(snaps,resume.date):nodes?.streamFrom?0:snaps.length-1;if(resume&&at<snaps.length-1&&!nodes?.streamFrom)await readyShape(at);if(mine!==modeRun)return;showAt(at,0);if(!resume||resume.playing&&at<snaps.length-1)play()}else if(which==="insights"){if(shown!==rows||lit<1||other){whole(800);if(other){galaxy.reshape(rows,800);other=false}fill(rows,yours);thingsBack(800)}history||=await fetch("star-graph-history.json").then(r=>r.ok?r.json():null).catch(()=>null);if(mine!==modeRun||!nodes?.topicCountsAt)return;const snaps=history?.snapshots||[],from=snaps.length?Date.parse(snaps[0].as_of):void 0,to=snaps.length?Date.parse(snaps[snaps.length-1].as_of):void 0;mountAnalytics();topics.draw(to,from,to);if(nodes.sourceSeries)topics.sources.set(sourceBands(nodes.sourceSeries(120,from,to)));topics.open()}else{if(shown!==rows||lit<1||other){whole(800);if(other){galaxy.reshape(rows,800);other=false}fill(rows,yours);thingsBack(800)}await loadPeople();if(mine!==modeRun)return;$("others-title").textContent="Other people\u2019s twins";$("others-line").textContent="Made-up people, drawn by the same rules as yours.";$("others-list").innerHTML=[{name:"You"},...people?.people||[]].map((p,i)=>`<button type="button" data-person="${i-1}" aria-pressed="${i===0}">${esc(p.name)}</button>`).join("")}rememberView()}const ownFeatures=galaxy.featuresOf?.(rows)||{};const historyFamily=Object.freeze({old:ownFeatures.age>.65,edge:ownFeatures.night>.65,ring:ownFeatures.ring>.65&&ownFeatures.night<=.65,twin:ownFeatures.merger>.5,irregular:ownFeatures.irregular>.45});const spread=r=>{const snaps=history.snapshots,end=snaps[snaps.length-1],prev=snaps[snaps.length-2]||end,m=r.mass;if(r===end||!end.mass.undated||m.things==null||!prev.mass.things)return m;const folk=Math.max(0,Math.min(end.mass.undated,end.mass.people-prev.mass.people)),things=end.mass.undated-folk;return{...m,things:Math.round(m.things*(1+things/prev.mass.things)),people:Math.round((m.people||0)*(1+folk/Math.max(1,prev.mass.people||0)))}};const historyRows=r=>({...r,mass:spread(r),family:historyFamily,growthTotal:held(history.snapshots[history.snapshots.length-1])});const held=r=>r.mass.things==null?r.mass.items:r.mass.things+(r.mass.people||0);const heldThen=r=>held({mass:spread(r)});const dayOf=t=>new Date(t).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric",timeZone:"UTC"});let feedLast=null,feedNames=true,feedTimer=0;const BANDS=[[160,185,255],[240,228,205],[214,190,148],[165,198,178],[150,152,162],[186,168,228]];let growth=null,growthT=null,growthTimer=0;const growthAt=t=>{growthT=t;growthTimer||=setTimeout(growthDraw,100)};let topics=null;const mountAnalytics=()=>topics||=mountTopics({nodes,explore:$("topic-explore"),sources:mountSourcesBig,onClose:()=>{if(mode==="insights")backToYou()}});let totalDraw=null;function growthDraw(){growthTimer=0;if(!nodes?.births)return;const snaps=history?.snapshots;if(!snaps?.length)return;totalDraw||=totalGraph($("time-growth"),$("time-total"));totalDraw(nodes.births(Date.parse(snaps[0].as_of),Date.parse(snaps[snaps.length-1].as_of)),growthT)}$("time-growth").onclick=()=>openMode("insights");const feedDraw=()=>{feedTimer=0;const box=$("feed"),e=feedLast;if(!e||mode!=="time"){box.hidden=true;return}const pic=nodes.logoTile(e.app,14);let ico;if(pic){ico=document.createElement("canvas");ico.width=pic.width;ico.height=pic.height;ico.getContext("2d").drawImage(pic,0,0)}else{ico=document.createElement("span");ico.className="no-ico"}const app=document.createElement("span"),what=document.createElement("span"),verb=document.createElement("span");app.className="app";app.textContent=e.appName;what.className="what";what.textContent=feedNames?e.name||e.type:e.type;verb.className="verb";verb.textContent=e.verb;box.replaceChildren(ico,app,what,verb);box.hidden=false};const feedAdd=list=>{if(!list.length)return;feedLast=list[list.length-1];feedTimer||=setTimeout(feedDraw,100)};const feedClear=()=>{feedLast=null;clearTimeout(feedTimer);feedTimer=0;$("feed").hidden=true};function showAt(i,ms=600,flow=false){const snaps=history.snapshots,r=snaps[i],last=i===snaps.length-1,was=past?heldThen(past):held(rows);if(last&&mode==="time"&&nodes?.visualToday){showVisualToday(i,ms);return}if(!last&&nodes?.streamFrom){grownAt(i,ms);return}at=i;endGrowth();feedClear();clearTimeout(backTimer);whole(ms);if(!last||other||shown!==rows||galaxy.state.form<1)galaxy.reshape(last?rows:historyRows(r),ms,void 0,flow);other=!last;past=last?null:r;const from=Date.parse(snaps[0].as_of),to=Date.parse(snaps[snaps.length-1].as_of);const m=r.mass,tell=d=>{const things=d?d.things:m.things,folk=d?d.people:m.people,undated=d?d.undated:m.undated;const line=things==null?plural(m.items,"thing"):`${plural(things,"thing")} \xB7 ${plural(folk,"person","people")}`;$("time-line").textContent=undated?`${line} \xB7 ${count(undated)} ${d?"undated, spread over the years":"with no date"}`:r.circle.weekly?`${line} \xB7 ${count(r.circle.weekly)} in touch every week`:line};if(nodes){nodes.away=false;nodes.timeline(last?null:Date.parse(r.as_of)+864e5,ms,{from,to,tick:tell,visualToday:last})}else tell(null);if(last&&mode==="time")applyShape(ms);if(last){if(shown!==rows)fill(rows,yours)}else fill(r,`Your twin at the end of ${month(r.as_of)}`);$("time-date").textContent=last?"Today":month(r.as_of);growthAt(last?null:Date.parse(r.as_of)+864e5);$("time-track").setAttribute("aria-valuemax",String(snaps.length-1));$("time-track").setAttribute("aria-valuenow",String(i));$("time-track").setAttribute("aria-valuetext",last?"Today":month(r.as_of));bars();yearNow();rememberView()}function showVisualToday(i,ms){const snaps=history.snapshots,from=Date.parse(snaps[0].as_of),to=Date.parse(snaps[snaps.length-1].as_of);const mine=++stillRun;visualActive=null;visualClosing=false;resumable=false;at=i;knob=null;past=null;feedClear();clearTimeout(backTimer);galaxy.presentation(true);nodes.away=false;if(other)galaxy.reshape(rows,Math.max(1,ms));other=false;whole(Math.max(1,ms));const settle=()=>{if(mine!==stillRun||mode!=="time")return;if(galaxy.morphing?.()){setTimeout(settle,30);return}galaxy.still(true);nodes.visualToday(from,to);if(shown!==rows)fill(rows,yours);$("time-date").textContent="Today";const c=nodes.counted;$("time-line").textContent=`${plural(c.things,"thing")} \xB7 ${plural(c.people,"person","people")}`;$("time-track").setAttribute("aria-valuemax",String(snaps.length-1));$("time-track").setAttribute("aria-valuenow",String(i));$("time-track").setAttribute("aria-valuetext","Today");growthAt(null);bars();yearNow();rememberView()};settle()}const GLOW=200;let stillRun=0;function grownAt(i,ms){const snaps=history.snapshots,r=snaps[i],from=Date.parse(snaps[0].as_of),to=Date.parse(snaps[snaps.length-1].as_of);at=i;knob=null;clearTimeout(backTimer);other=false;past=null;nodes.away=false;feedClear();visualActive=null;visualClosing=false;step=[];flying=[];waiting=[];ended=false;galaxy.presentation?.(true);galaxy.reshape(rows,1);const mine=++stillRun,settle=()=>{if(mine!==stillRun||mode!=="time")return;if(galaxy.morphing?.())setTimeout(settle,40);else{galaxy.still?.(true);nodes.lay?.()}};nodes.growth=spawnAt;nodes.streamFrom(i===0?-Infinity:Date.parse(r.as_of)+864e5,from,to);settle();resumable=true;const c=nodes.counted,total=nodes.counts.things+nodes.counts.people;galaxy.growTo(galaxy.formAt(Math.max(0,(c.things+c.people-GLOW)/Math.max(1,total-GLOW))),Math.max(1,ms));if(shown!==r)fill(r,`Your twin at the end of ${month(r.as_of)}`);$("time-date").textContent=i===0?`Before ${dayOf(nodes.nextBorn??from)}`:month(r.as_of);growthAt(i===0?nodes.streamAt:Date.parse(r.as_of)+864e5);$("time-line").textContent=`${plural(c.things,"thing")} \xB7 ${plural(c.people,"person","people")}`;$("time-track").setAttribute("aria-valuemax",String(snaps.length-1));$("time-track").setAttribute("aria-valuenow",String(i));$("time-track").setAttribute("aria-valuetext",$("time-date").textContent);bars();yearNow();rememberView()}let knob=null;function bars(){const canvas=$("time-bars"),snaps=history.snapshots,dpr=devicePixelRatio||1;const w=canvas.clientWidth,h=canvas.clientHeight,ctx=canvas.getContext("2d");canvas.width=Math.round(w*dpr);canvas.height=Math.round(h*dpr);ctx.setTransform(dpr,0,0,dpr,0,0);const y=h/2,x=(knob??at+.5)/snaps.length*w,r=6;ctx.clearRect(0,0,w,h);ctx.fillStyle="rgba(245,245,247,.18)";ctx.beginPath();ctx.roundRect(0,y-2,w,4,2);ctx.fill();ctx.fillStyle="#f5f5f7";ctx.beginPath();ctx.roundRect(0,y-2,Math.max(4,x),4,2);ctx.fill();ctx.beginPath();ctx.arc(Math.min(w-r,Math.max(r,x)),y,r,0,Math.PI*2);ctx.fill()}function years(snaps){const n=snaps.length;$("time-years").innerHTML=snaps.map((r,i)=>{const at2=(i+.5)/n;if(i===n-1||r.as_of.slice(5,7)!=="01")return"";return`<button type="button" data-at="${i}" style="left:${at2*100}%" aria-label="Go to ${r.as_of.slice(0,4)}">${r.as_of.slice(0,4)}</button>`}).join("")+`<button type="button" class="now" data-at="${n-1}">Today</button>`;const box=$("time-years"),now=box.querySelector(".now").getBoundingClientRect();box.querySelectorAll("button:not(.now)").forEach(s=>{if(s.getBoundingClientRect().right>now.left-8)s.remove()});yearNow()}function yearNow(){const snaps=history?.snapshots;if(!snaps?.length)return;const y=at===snaps.length-1?null:snaps[at].as_of.slice(0,4);$("time-years").querySelectorAll("button").forEach(b=>b.setAttribute("aria-current",String(b.classList.contains("now")?y==null:snaps[+b.dataset.at].as_of.slice(0,4)===y)))}$("time-years").onclick=e=>{const b=e.target.closest("button[data-at]"),snaps=history?.snapshots;if(!b||!snaps?.length)return;const i=+b.dataset.at;stop();if(i!==at||i===0)showAt(i,700)};let speed=1;try{speed=[1,2,4,8,16,32,64,128,256,512,1024].includes(+localStorage.getItem("zx-timeline-speed"))?+localStorage.getItem("zx-timeline-speed"):1}catch{}const showSpeed=()=>{$("time-speed").textContent=`${speed}\xD7`;$("time-speed").setAttribute("aria-label",`Speed ${speed}\xD7, click to change`)};showSpeed();$("time-speed").onclick=()=>{speed=speed>=1024?1:speed*2;showSpeed();try{localStorage.setItem("zx-timeline-speed",String(speed))}catch{}};let run=0;const readyShape=i=>new Promise((resolve,reject)=>{const timer=setTimeout(()=>reject(new Error("Twin shape did not arrive within 5 seconds")),5e3);Promise.resolve(i===history.snapshots.length-1?null:galaxy.shapeOf(historyRows(history.snapshots[i]))).then(v=>{clearTimeout(timer);resolve(v)},e=>{clearTimeout(timer);reject(e)})});async function play(){window.__zxPlaying=true;const snaps=history?.snapshots;if(!snaps?.length)return;if(playing){stop();return}const mine=++run;playing=-1;galaxy.setPaused(entry?.paused??false);rememberView();$("time-play").setAttribute("aria-label","Pause");$("time-play").classList.add("on");const failed=error=>{if(mine!==run)return;stop();console.error("Twin timeline:",error);$("time-line").textContent="Could not prepare this timeline. Try again.";$("time-date").textContent="Could not prepare this timeline. Try again."};try{if(at>=snaps.length-1){if(!nodes?.streamFrom)await readyShape(0);if(mine!==run)return;showAt(0,0)}if(nodes?.streamFrom){stream(mine,snaps,failed);return}const every=()=>Math.max(1,Math.round(snaps.length*speed/320));const stepMs=()=>9700*8/speed/Math.max(1,Math.ceil((snaps.length-1)/every()));const after=i=>Math.min(snaps.length-1,i+every());const prefetch=i=>{if(i<snaps.length-1)galaxy.prepare(historyRows(snaps[i]))};const next=async()=>{try{if(mine!==run)return;if(at>=snaps.length-1){stop();return}const i=after(at);await readyShape(i);if(mine!==run)return;const STEP=stepMs();showAt(i,STEP,true);if(i<snaps.length-1)prefetch(after(i));playing=setTimeout(next,STEP+(i===snaps.length-1?2e3:0))}catch(error){failed(error)}};prefetch(after(at));playing=setTimeout(next,300)}catch(error){failed(error)}}const PER_DAY=5;const lanes=()=>PER_DAY;let dynamicPace=true,paceFrom=0;const pace=()=>{if(!dynamicPace||window.zxPileCheck||speed<=1||!nodes)return speed;const c=nodes.counted,ramp=2**Math.max(0,(performance.now()-paceFrom-4e3)/1500);return Math.min(speed,Math.max(ramp,(c.things+c.people)/64))};let batchEnd=-Infinity,batchFrame=-1;const frameNo=()=>window.zxFrameNo||0;if(!window.zxFrameNo)(function count2(){window.zxFrameNo=(window.zxFrameNo||0)+1;requestAnimationFrame(count2)})();window.zxLanes2=()=>({speed,lanes:lanes()});let spawnAt="place";const SPAWNS={place:"A \xB7 edge, its side",link:"B \xB7 edge, its link\u2019s side",pool:"C \xB7 fed from one side"};try{const v=localStorage.getItem("zx-timeline-growth");if(SPAWNS[v])spawnAt=v}catch{}const showSpawn=()=>{$("time-spawn").textContent=SPAWNS[spawnAt];if(nodes)nodes.growth=spawnAt};showSpawn();let marksAt="logos";const MARKS={logos:"App logos",names:"Names"};try{const v=localStorage.getItem("zx-timeline-marks");if(MARKS[v])marksAt=v}catch{}const showMarks=()=>{$("time-marks").textContent=MARKS[marksAt];$("time-marks").setAttribute("aria-label",`Below the dots: ${MARKS[marksAt]}, click to change`);if(nodes&&mode==="time")nodes.marks=marksAt};showMarks();$("time-marks").onclick=()=>{marksAt=marksAt==="logos"?"names":"logos";showMarks();try{localStorage.setItem("zx-timeline-marks",marksAt)}catch{}};$("time-spawn").onclick=()=>{spawnAt={place:"link",link:"pool",pool:"place"}[spawnAt];showSpawn();try{localStorage.setItem("zx-timeline-growth",spawnAt)}catch{}};const VISUAL_DAY_MAX=400;let visualActive=null,visualClosing=false;function visualStream(mine,snaps,failed){const from=Date.parse(snaps[0].as_of),to=Date.parse(snaps[snaps.length-1].as_of);const fresh=!resumable;if(fresh){nodes.streamFrom(at===0||at===snaps.length-1?-Infinity:Date.parse(snaps[at].as_of)+864e5,from,to);visualActive=null;visualClosing=false;other=false;past=null;galaxy.growTo(0,1);if(shown!==rows||galaxy.state.form<1)galaxy.reshape(rows,1)}if(visualActive&&visualActive.epoch!==nodes.streamEpoch)visualActive=null;if(typeof galaxy.frameNumber!=="function"||typeof galaxy.presentation!=="function")throw new Error("Timeline renderer is stale: rebuild the current source");resumable=false;streaming=true;window.__zxPlaying=true;galaxy.presentation(true);let prepared=false,previousDay=-Infinity,lastUI=0;const paintUI=(final=false)=>{const c=nodes.counted,t=nodes.streamAt;$("time-date").textContent=final?"Today":dayOf(t);$("time-line").textContent=`${plural(c.things,"thing")} \xB7 ${plural(c.people,"person","people")}`;knob=final?null:Math.max(0,Math.min(snaps.length,(t-from)/Math.max(1,to-from)*(snaps.length-1)+.5));if(final)at=snaps.length-1;else{let i=at;while(i<snaps.length-1&&t>Date.parse(snaps[i].as_of)+864e5)i++;at=i}$("time-track").setAttribute("aria-valuenow",String(at));$("time-track").setAttribute("aria-valuetext",final?"Today":$("time-date").textContent);growthAt(final?null:t);bars();yearNow()};const completeToday=()=>{streaming=false;window.__zxPlaying=false;knob=null;nodes.streamEnd({preserveGeometry:true});past=null;other=false;fill(rows,yours);lit=1;paintUI(true);rememberView();stop()};const tick=()=>{try{if(mine!==run)return;const now=performance.now();if(!prepared){if(galaxy.morphing?.()){playing=setTimeout(tick,30);return}galaxy.still?.(true);nodes.pushesHeld=true;prepared=true}const k=pace();galaxy.pace?.(k);nodes.visualPace=k;if(visualActive){const batch=visualActive.items;for(const state of batch){if(state.done)continue;const a=state.a;if(state.phase==="link"&&(nodes.visualReceipt(a.node)?.brightUntil??Infinity)<=now){if(nodes.inPool?.(a.node))nodes.leavePool(a.node);const[x,y]=nodes.visualTarget(a.node);galaxy.aim?.(a.star,x,y);state.phase="move"}if(nodes.visualLinkDone(a.node,frameNo())){nodes.landed?.(a.node,a.b);state.done=true}}if(batch.every(s=>s.done))visualActive=null}if(!visualActive&&!visualClosing){const next=nodes.nextBorn;if(next==null){visualClosing=true;galaxy.growTo(1,850)}else{const d=Math.floor(next/864e5);if(nodes.visualLinkProgress().unfinished.length)throw new Error("Next day admitted before its required links and geometry settled");const got=nodes.spawnDay(VISUAL_DAY_MAX);if(!got){visualClosing=true;galaxy.growTo(1,850)}else{const items=[];for(const a of got){if(a.x==null)throw new Error("A visual arrival has no edge spawn coordinate");galaxy.attach?.(a.star,-1,a.x,a.y,0);nodes.link(a);items.push({a,phase:"link",at:now})}visualActive=items.length?{items,epoch:nodes.streamEpoch}:null;previousDay=d;const c=nodes.counted,total=nodes.counts.things+nodes.counts.people;const share=(c.things+c.people)/Math.max(1,total);galaxy.growTo(Math.min(1,Math.pow(share,.58)),230)}}}if(visualClosing&&!visualActive&&galaxy.state.form>=1&&nodes.visualEndReady()){const p=nodes.visualLinkProgress();if(p.unfinished.length||p.arrived!==p.finished)throw new Error("End reached with unfinished synthetic links");completeToday();return}if(now-lastUI>100){paintUI();lastUI=now}const latest=nodes.feedLatest(nodes.streamAt);if(latest)feedAdd([nodes.feedRow(latest)]);playing=setTimeout(tick,16)}catch(error){failed(error)}};playing=setTimeout(tick,16)}function stream(mine,snaps,failed){if(nodes?.visualLinkDone){visualStream(mine,snaps,failed);return}const ends=snaps.map(r=>Date.parse(r.as_of)+864e5),from=Date.parse(snaps[0].as_of),to=Date.parse(snaps[snaps.length-1].as_of);const total=nodes.counts.things+nodes.counts.people;const fresh=!resumable;if(!resumable){nodes.growth=spawnAt;nodes.streamFrom(at===0||at===snaps.length-1?-Infinity:ends[at],from,to);clearTimeout(backTimer);other=false;past=null;galaxy.growTo(0,1);if(shown!==rows||galaxy.state.form<1)galaxy.reshape(rows,1)}resumable=false;streaming=true;window.__zxPlaying=true;paceFrom=performance.now();let cur=at,stillAt=0,acc=0,day2=null,last=performance.now(),grewAt=0,laidAt=-1;if(fresh){step=[];flying=[];waiting=[];ended=false;feedClear()}const enter=i=>{at=i};const drawTimelineUI=()=>{const t=nodes.streamAt,c=nodes.counted;$("time-date").textContent=dayOf(t);growthAt(t);$("time-line").textContent=`${plural(c.things,"thing")} \xB7 ${plural(c.people,"person","people")}`;knob=Math.max(0,Math.min(snaps.length,(t-from)/Math.max(1,to-from)*(snaps.length-1)+.5));bars();yearNow()};const ui=timelinePainter(requestAnimationFrame,cancelAnimationFrame,()=>{if(mine===run&&streaming&&mode==="time")drawTimelineUI()});const tell=()=>speed>=64?ui.queue():ui.now();const tick=()=>{try{if(mine!==run)return;const now=performance.now(),speed2=pace();if(!stillAt){if(galaxy.morphing?.()){last=now;playing=setTimeout(tick,40);return}stillAt=now;galaxy.still?.(true);if(fresh)nodes.lay?.();laidAt=frameNo()}if(nodes.pushesHeld===false){if((frameNo()<laidAt+3||window.zxField?.backlog>0)&&now-stillAt<2e3){last=now;playing=setTimeout(tick,40);return}nodes.pushesHeld=true}if(frameNo()-grewAt>=3){grewAt=frameNo();nodes.grow?.()}const NEAR=.3;const k=speed2,LINK=200/k,PAUSE=100/k,STOP=180/k;const TURN=5e3/(8*k);galaxy.pace?.(k);const advance=st=>{if(st.phase==="link"&&now-st.at>=LINK+PAUSE){const s=galaxy.live?.(),b=st.a.to;let spot=null;if(nodes.inPool?.(st.a.node))nodes.leavePool(st.a.node);if(st.a.b>=0&&nodes.inPool?.(st.a.b)){spot=nodes.leavePool(st.a.b);if(spot)galaxy.aim?.(b,spot[0],spot[1])}const own=galaxy.stars;if(galaxy.aim&&s&&own&&b>=0&&st.a.x!=null){const o=st.a.star*9;if(nodes.growth==="pool"){st.a.x=s[o];st.a.y=s[o+1]}const[tx,ty]=nodes.landing?nodes.landing(st.a.node):[own[o],own[o+1]];st.a.tx=tx;st.a.ty=ty;const ex=tx-st.a.x,ey=ty-st.a.y,side=(Math.random()<.5?-1:1)*(.15+.2*Math.random());galaxy.aim(st.a.star,st.a.x+ex*(.4+.2*Math.random())-ey*side,st.a.y+ey*(.4+.2*Math.random())+ex*side);st.phase="stop";st.at=st.movedAt=now}else{galaxy.attach?.(st.a.star,st.a.to,st.a.x,st.a.y,st.a.d);st.phase="move";st.at=st.movedAt=now}}else if(st.phase==="stop"&&(galaxy.gap?.(st.a.star)<.03||now-st.at>3e3/k)){st.phase="rest";st.at=now}else if(st.phase==="rest"&&now-st.at>=STOP){if(nodes.landing)[st.a.tx,st.a.ty]=nodes.landing(st.a.node);galaxy.aim(st.a.star,st.a.tx,st.a.ty);st.phase="move";st.at=now}else if(st.phase==="move"&&(galaxy.gap?.(st.a.star)<.02||st.stalled||now-st.at>4e3/k)){nodes.landed?.(st.a.node,st.a.b);return true}if(k>=2&&now-st.born>TURN&&st.phase!=="link"){if(nodes.landing)[st.a.tx,st.a.ty]=nodes.landing(st.a.node);if(st.a.tx!=null)galaxy.attach?.(st.a.star,-1,st.a.tx,st.a.ty,0);nodes.landed?.(st.a.node,st.a.b);return true}if(st.phase==="move"){const g=galaxy.gap?.(st.a.star)??0;if(st.g==null||now-st.gAt>=150/k){const why=g<NEAR?"near":st.g!=null&&now-st.at>300/k&&st.g-g<.15?"stalled":null;if(st.g!=null&&now-st.at>300/k&&st.g-g<.03)st.stalled=true;st.g=g;st.gAt=now;if(why&&!st.dark){st.dark=true;nodes.unlight?.(st.a.node);unlit.push([why,Math.round(now-st.movedAt),+g.toFixed(2)])}}else if(g<NEAR&&!st.dark){st.dark=true;nodes.unlight?.(st.a.node);unlit.push(["near",Math.round(now-st.movedAt),+g.toFixed(2)])}}return false};step=step.filter(st=>st&&!advance(st));acc+=(now-last)/1e3*8*speed2;last=now;const n=Math.min(Math.max(6,speed2/2),Math.floor(acc));let made=0;for(;made<n&&!ended;made++){if(step.length>=lanes())break;if(speed2>=64&&performance.now()-now>10)break;const next=nodes.nextBorn;if(next==null){ended=true;break}const d=Math.floor(next/864e5);if(d!==day2&&step.length)break;if(speed2>=64&&(d>=batchEnd||d<batchEnd-speed2/32)){if(step.length||batchFrame===frameNo())break;batchEnd=d+speed2/32;batchFrame=frameNo()}day2=d;if(speed2>=64)batchFrame=frameNo();const got=nodes.spawn(1);if(!got){ended=true;break}const fast=speed2>=64;if(!fast){const c=nodes.counted;galaxy.growTo(galaxy.formAt(Math.max(0,(c.things+c.people-GLOW)/Math.max(1,total-GLOW))),400)}for(const a of got){if(a.x==null)continue;if(fast){const[x,y]=nodes.landing?nodes.landing(a.node):[a.x,a.y];galaxy.attach?.(a.star,-1,x,y,0);if(a.to>=0)nodes.link(a);nodes.landed?.(a.node,a.b);continue}galaxy.attach?.(a.star,-1,a.x,a.y,0);if(a.to>=0){step.push({a,phase:"link",at:now,born:now});nodes.link(a)}}const t=nodes.streamAt;let i=cur;while(i<snaps.length-1&&t>ends[i])i++;if(i!==cur){cur=i;enter(i)}if(!fast)tell()}if(made&&speed2>=64){const c=nodes.counted;galaxy.growTo(galaxy.formAt(Math.max(0,(c.things+c.people-GLOW)/Math.max(1,total-GLOW))),400);tell()}acc-=made;if(made<n)acc=Math.min(acc,1);{const latest=nodes.feedLatest(nodes.streamAt);if(latest)feedAdd([nodes.feedRow(latest)])}flying=flying.filter(st=>!advance(st));if(ended&&step.every(x=>!x)&&!flying.length&&!waiting.length){ui.cancel();streaming=false;window.__zxPlaying=false;knob=null;nodes.streamEnd();requestAnimationFrame(()=>{if(mode!=="time")return;showAt(snaps.length-1,1500,true);requestAnimationFrame(()=>{if(mode!=="time")return;stop();endShot()})});return}playing=setTimeout(tick,speed2>=64?4:16)}catch(error){failed(error)}};window.__zxPlaying=true;playing=setTimeout(tick,300)}function endShot(){if(!following)galaxy.look?.(0,0,43)}let following=false,camTimer=0,heldAt=0,shot=null;function camFollow(on){if(on===following)return;following=on;clearInterval(camTimer);shot=null;if(on)camTimer=setInterval(()=>{if(mode!=="time"||window.zxPileCheck||!nodes?.spread||!streaming){shot=null;return}const st=galaxy.state,now=performance.now();if(now-heldAt<5e3){shot=null;return}const r=nodes.reach90?nodes.reach90():nodes.spread().things[1];if(!(r>0))return;const fits=Math.min(65,Math.max(2.5,r*3.2));if(!shot)shot={goal:fits*1.35,cur:st.targetDistance,at:now,n:1};const dt=Math.min(.5,(now-shot.at)/1e3);shot.at=now;if(fits>shot.goal*.9||fits<shot.goal*.45){shot.goal=Math.min(65,fits*1.35);shot.n++}else if(Math.abs(shot.goal-shot.cur)<shot.goal*.02)shot.goal=Math.max(fits*1.1,shot.goal*(1-.01*dt));shot.cur+=(shot.goal-shot.cur)*(1-Math.exp(-dt/1.1));st.targetDistance=shot.cur;const k=1-Math.exp(-dt/2);st.targetPanX-=st.targetPanX*k;st.targetPanY-=st.targetPanY*k},100)}window.zxCam=()=>({following,shot,held:performance.now()-heldAt<5e3});for(const ev of["pointerdown","wheel"])$("universe").addEventListener(ev,()=>{heldAt=performance.now()},{passive:true});let clipping=false;async function recordClip(by="month"){const snaps=history?.snapshots;if(clipping||typeof MediaRecorder==="undefined"||!snaps?.length||mode!=="time")return;clipping=true;setPanel(false);const src=$("universe"),W=Math.min(1920,src.width),H=Math.round(W*src.height/src.width),k=W/innerWidth;const out=document.createElement("canvas");out.width=W;out.height=H;const g=out.getContext("2d");const paint=()=>{g.fillStyle="#000";g.fillRect(0,0,W,H);for(const id2 of["universe","links","nodes"]){const c=$(id2);if(c?.width)g.drawImage(c,0,0,W,H)}const gc=$("time-growth"),x=20*k,y=H-24*k;g.globalAlpha=.85;g.fillStyle="#f5f5f7";g.font=`600 ${15*k}px Inter, system-ui`;g.fillText($("time-date").textContent,x,y-64*k);if(gc.width)g.drawImage(gc,x,y-gc.clientHeight*k,gc.clientWidth*k,gc.clientHeight*k);g.globalAlpha=1};const was=galaxy.onframe;galaxy.onframe=()=>{was?.();paint()};if(nodes){nodes.logos={say:"none",forming:"logo"};nodes.marks="logos"}const type=["video/mp4;codecs=avc1","video/webm;codecs=vp9","video/webm"].find(t=>MediaRecorder.isTypeSupported(t));const rec=new MediaRecorder(out.captureStream(30),{mimeType:type,videoBitsPerSecond:12e6}),parts=[];rec.ondataavailable=e=>{if(e.data.size)parts.push(e.data)};const done=new Promise(ok=>{rec.onstop=ok});const wait=ms=>new Promise(ok=>setTimeout(ok,ms)),last=snaps.length-1;const steps=by==="year"?[0,...snaps.map((r,i)=>i).filter(i=>i>0&&i<last&&r0(i)),last]:snaps.map((r,i)=>i);function r0(i){return snaps[i].as_of.slice(5,7)==="01"}const hold=by==="year"?1200:300;stop();paint();rec.start(500);for(const i of steps){if(i===last)showAt(last,1);else grownAt(i,1);while(galaxy.morphing?.())await wait(40);await wait(i===last?2e3:hold)}rec.stop();await done;galaxy.onframe=was;if(nodes){logoNow();if(mode==="time")nodes.marks=marksAt}clipping=false;const a=document.createElement("a"),ext=type.startsWith("video/mp4")?"mp4":"webm";a.href=URL.createObjectURL(new Blob(parts,{type}));a.download=`zortex-twin-by-${by}-${new Date().toISOString().slice(0,10)}.${ext}`;document.body.append(a);a.click();a.remove();setTimeout(()=>URL.revokeObjectURL(a.href),6e4)}function stop(){run++;window.__zxPlaying=false;galaxy.pace?.(1);clearTimeout(playing);playing=null;if(nodes)nodes.auto=null;if(streaming){streaming=false;resumable=true}$("time-play").setAttribute("aria-label","Play");$("time-play").classList.remove("on");if(mode==="time")galaxy.setPaused(true);rememberView()}function scrubTo(x){const r=$("time-track").getBoundingClientRect(),snaps=history?.snapshots;if(!snaps?.length)return;const i=Math.max(0,Math.min(snaps.length-1,Math.floor((x-r.left)/r.width*snaps.length)));if(i===at&&want==null)return;stop();if(want==null)requestAnimationFrame(()=>{const i2=want;want=null;if(i2!==at)showAt(i2,420)});want=i}$("others-close").onclick=backToYou;$("play-clip").onclick=()=>recordClip("month");$("play-clip-year").onclick=()=>recordClip("year");$("time-play").onclick=play;const track=$("time-track");track.addEventListener("pointerdown",e=>{track.setPointerCapture(e.pointerId);scrubTo(e.clientX)});track.addEventListener("pointermove",e=>{if(track.hasPointerCapture(e.pointerId))scrubTo(e.clientX)});track.addEventListener("keydown",e=>{const snaps=history?.snapshots;if(!snaps?.length)return;const d={ArrowLeft:-1,ArrowRight:1,Home:-at,End:snaps.length-1-at}[e.key];if(d==null)return;e.preventDefault();e.stopPropagation();stop();showAt(Math.max(0,Math.min(snaps.length-1,at+d)),420)});addEventListener("resize",()=>{if(mode==="time"&&history){bars();years(history.snapshots)}});function showPerson(i,ms=900){const p=people?.people?.[i];selectedPerson=p?.name||null;$("others-list").querySelectorAll("[data-person]").forEach(x=>x.setAttribute("aria-pressed",String(+x.dataset.person===(p?i:-1))));$("others-title").textContent=p?`${p.name}, made up`:"You";$("others-line").textContent=p?p.about:"Your twin today, from your vault.";rememberView();if(!p){if(other){galaxy.reshape(rows,ms);other=false}if(shown!==rows)fill(rows,yours);thingsBack(ms);return}draw(theirs(p),ms,p.name);fill(p.rows,`${p.name}\u2019s twin, made up`)}$("others-list").onclick=e=>{const b=e.target.closest("[data-person]");if(b)showPerson(+b.dataset.person)};let pictured=false;async function thumbs(){if(pictured||!galaxy.shapeOf)return;pictured=true;const canvases=Object.fromEntries(tiles.map(t=>[t.dataset.mode,t.querySelector("canvas")]));const mine=await galaxy.shapeOf(rows);if(!mine){pictured=false;return}const frame=()=>new Promise(requestAnimationFrame);sketch(canvases.twin,[{g:mine}]);history||=await fetch("star-graph-history.json").then(r=>r.ok?r.json():null).catch(()=>null);const snaps=history?.snapshots||[],young=snaps.find(r=>galaxy.growthOf(historyRows(r))>=.12);const early=young?await galaxy.shapeOf(historyRows(young)):null;await frame();sketch(canvases.time,[{g:early||mine,until:early?2:galaxy.formAt(.28),scale:early?1:.62}]);await frame();sketch(canvases.play,[{g:mine,tint:[1.25,.92,.62],wind:.5,x:.6,scale:.9}],true);await loadPeople();const pick=["Mira","Theo","Lu"].map(n=>people?.people?.find(p=>p.name===n)).filter(Boolean);const shapes=await Promise.all(pick.map(p=>galaxy.shapeOf(theirs(p),id(p.name))));await frame();sketch(canvases.others,shapes.map((g,i)=>g&&{g,x:(i+.5)/shapes.length,scale:.42}).filter(Boolean));if(canvases.insights)analyticsThumb(canvases.insights)}function analyticsThumb(cv){const dpr=Math.min(2,devicePixelRatio||1),w=cv.clientWidth||140,h=cv.clientHeight||88,g=cv.getContext("2d");cv.width=Math.round(w*dpr);cv.height=Math.round(h*dpr);g.scale(dpr,dpr);g.fillStyle="#000";g.fillRect(0,0,w,h);const cols=["#3987e5","#d95926","#199e70","#c98500","#9085e9"],n=24,x0=w*.12,x1=w*.88,yb=h*.8,top=h*.22;const run2=cols.map((_,j)=>Array.from({length:n},(_2,i)=>Math.pow(i/(n-1),1.6+j*.35)*(1-j*.14)));const sum=run2.reduce((t,a)=>t+a[n-1],0),X=i=>x0+i/(n-1)*(x1-x0),Y=v=>yb-v/sum*(yb-top),below=new Array(n).fill(0);run2.forEach((a,j)=>{g.beginPath();for(let i=0;i<n;i++)g.lineTo(X(i),Y(below[i]+a[i]));for(let i=n-1;i>=0;i--)g.lineTo(X(i),Y(below[i]));g.closePath();g.globalAlpha=.35;g.fillStyle=cols[j];g.fill();g.globalAlpha=1;g.beginPath();for(let i=0;i<n;i++)g.lineTo(X(i),Y(below[i]+a[i]));g.strokeStyle=cols[j];g.lineWidth=1;g.stroke();for(let i=0;i<n;i++)below[i]+=a[i]})}function sketch(canvas,parts,sliders=false){const dpr=Math.min(2,devicePixelRatio||1),w=canvas.clientWidth||140,h=canvas.clientHeight||88;const W=canvas.width=Math.round(w*dpr),H=canvas.height=Math.round(h*dpr),acc=new Float32Array(W*H*3);const tilt=1.02,roll=-.34,ct=Math.cos(tilt),st=Math.sin(tilt),cr=Math.cos(roll),sr=Math.sin(roll);const add=(px2,py,r,g,b,rad)=>{const x0=Math.round(px2),y0=Math.round(py),n=Math.ceil(rad);for(let dy=-n;dy<=n;dy++)for(let dx=-n;dx<=n;dx++){const x=x0+dx,y=y0+dy;if(x<0||y<0||x>=W||y>=H)continue;const k=rad?Math.exp(-(dx*dx+dy*dy)/(rad*rad*.5)):1,o=(y*W+x)*3;acc[o]+=r*k;acc[o+1]+=g*k;acc[o+2]+=b*k}};for(const{g,until=2,scale=1,x:at2=.5,tint=[1,1,1],wind=0}of parts){const k=H*.04*scale,cx=W*at2,cy=H*.5;const each=(a,e,step2,gain,rad)=>{for(let i=0;i<a.length;i+=9*step2){if(e[i/9*4]>until)continue;let x=a[i],y=a[i+1];const z=a[i+2],yaw=.3+wind*Math.hypot(x,y)*.02,c=Math.cos(yaw),n2=Math.sin(yaw);[x,y]=[c*x-n2*y,n2*x+c*y];const y2=ct*y-st*z,x3=cr*x-sr*y2,y3=sr*x+cr*y2,l=a[i+7]*gain;add(cx+x3*k,cy-y3*k,a[i+3]*tint[0]*l,a[i+4]*tint[1]*l,a[i+5]*tint[2]*l,rad)}};each(g.clouds.a,g.clouds.e,7,.03,(1.6*scale+.6)*dpr);const n=g.stars.a.length/9;each(g.stars.a,g.stars.e,Math.max(1,Math.round(n/(6500*scale))),1,0)}const ctx=canvas.getContext("2d"),img=ctx.createImageData(W,H),px=img.data;for(let i=0,j=0;i<acc.length;i+=3,j+=4){px[j]=255*(1-Math.exp(-1.5*acc[i]));px[j+1]=255*(1-Math.exp(-1.5*acc[i+1]));px[j+2]=255*(1-Math.exp(-1.5*acc[i+2]));px[j+3]=255}ctx.putImageData(img,0,0);if(sliders){ctx.setTransform(dpr,0,0,dpr,0,0);ctx.lineCap="round";[[.3,.62],[.5,.3],[.7,.78]].forEach(([y,v])=>{const x0=w*.08,x1=w*.3;ctx.strokeStyle="rgba(255,255,255,.28)";ctx.lineWidth=2;ctx.beginPath();ctx.moveTo(x0,h*y);ctx.lineTo(x1,h*y);ctx.stroke();ctx.fillStyle="#f5f5f7";ctx.beginPath();ctx.arc(x0+(x1-x0)*v,h*y,3.6,0,Math.PI*2);ctx.fill()})}}const pct=v=>`${Math.round(v*100)}%`,times=v=>`${v.toFixed(2).replace(/\.?0+$/,"")}\xD7`,num=d=>v=>v.toFixed(d);const R=16,PULL=links?.options.pull??1;const GROUPS=[{name:"Shape",note:"From your measurements: size from what you hold, arms from your fields, companions from your weekly people.",controls:[{id:"f.growth",label:"Size",min:.002,max:1,step:.002,fmt:pct},{id:"f.arms",label:"Arms",min:1,max:6,step:.05,fmt:num(1)},{id:"f.bar",label:"Bar",min:0,max:1,step:.01,fmt:pct},{id:"f.pitch",label:"Arm angle",min:8,max:45,step:.5,fmt:v=>`${Math.round(v)}\xB0`},{id:"f.bulge",label:"Core",min:.04,max:.7,step:.01,fmt:num(2)},{id:"f.clumps",label:"Clumps",min:.05,max:.95,step:.01,fmt:pct},{id:"f.coherence",label:"Neat arms",min:.2,max:1,step:.01,fmt:pct},{id:"f.satellites",label:"Companions",min:0,max:6,step:1,fmt:num(0)},{id:"f.shells",label:"Layers",min:0,max:9,step:1,fmt:num(0)},{id:"f.merger",label:"Second body",min:0,max:1,step:.01,fmt:pct},{id:"f.breadth",label:"Halo reach",min:0,max:1,step:.01,fmt:pct}]},{name:"3D",note:"Thicken the disc and tilt it to see its depth. With \u201CDrag turns the twin\u201D, a drag turns it in space.",controls:[{id:"f.thickness",label:"Disc thickness",min:R*.004,max:R*.045,step:R*.001,fmt:num(2)},{id:"t.depth",label:"Depth",min:.3,max:2.5,step:.05,fmt:times,def:1},{id:"cam.tilt",label:"Tilt",min:0,max:1.45,step:.01,fmt:v=>`${Math.round(v*180/Math.PI)}\xB0`},{id:"cam.turns",label:"Drag turns the twin",toggle:true,def:false}]},{name:"Colour",controls:[{id:"c.warmth",label:"Warmth",min:0,max:1,step:.01,fmt:pct},{id:"f.young",label:"Blue edge",min:0,max:1,step:.01,fmt:pct},{id:"f.clock",label:"Night blue",min:0,max:1,step:.01,fmt:pct},{id:"c.rose",label:"Pink knots",min:0,max:1,step:.01,fmt:pct},{id:"c.violet",label:"Violet",min:0,max:1,step:.01,fmt:pct},{id:"t.sat",label:"Colour strength",min:0,max:2.5,step:.05,fmt:times,def:1}]},{name:"Light",controls:[{id:"e.stars",label:"Disc stars",min:0,max:2.5,step:.05,fmt:times,def:1},{id:"e.core",label:"Core",min:0,max:2.5,step:.05,fmt:times,def:1},{id:"e.companions",label:"Companions",min:0,max:2.5,step:.05,fmt:times,def:1},{id:"e.halo",label:"Halo",min:0,max:2.5,step:.05,fmt:times,def:1},{id:"e.gas",label:"Fog",min:0,max:2.5,step:.05,fmt:times,def:1},{id:"e.dust",label:"Dust lanes",min:0,max:2.5,step:.05,fmt:times,def:1},{id:"t.size",label:"Star size",min:.4,max:2.5,step:.05,fmt:times,def:1},{id:"sky",label:"Mist behind the twin",toggle:true,def:true}]},...nodes?[{name:"Things",note:"Your real things sit on your own shape. Change the shape, or start from someone else, and they step aside.",controls:[{id:"v.made",label:"Things you made",toggle:true,def:true},{id:"v.kept",label:"Things you keep",toggle:true,def:true},{id:"v.people",label:"People",toggle:true,def:true},{id:"v.docs",label:"Documents",toggle:true,def:true},{id:"v.thoughts",label:"Thoughts",toggle:true,def:true},{id:"v.names",label:"Names when close",toggle:true,def:true},{id:"v.links",label:"Links on hover",toggle:true,def:true},{id:"v.open",label:"Open on click",toggle:true,def:false},{id:"v.blend",label:"Blend in with the stars",toggle:true,def:true}]},{name:"App logos",note:"The app each thing came from, in place of its name (the button on the timeline chooses logos or names).",controls:[{id:"g.size",label:"Logo size",min:8,max:40,step:1,fmt:v=>`${Math.round(v)} px`,def:14},{id:"g.from",label:"Show from",min:9,max:80,step:1,fmt:v=>`${Math.round(v)}`,def:26},{id:"g.many",label:"How many",min:.25,max:4,step:.05,fmt:times,def:1},{id:"g.onDot",label:"Logo is the dot",toggle:true,def:false},{id:"g.say",label:"Names show as",choice:[["name","Its name"],["app","App and number"],["type","Type and number"],["all","Logo, number and type"],["safe","Safe to share"],["none","Nothing"]],def:"name"},{id:"g.forming",label:"As links form",choice:[["names","Names"],["logo","App logo"],["both","Logo and name"],["off","Nothing"]],def:"names"}]},{name:"While links form",note:"On the timeline, as each link forms: the dots not on it darken as they do when you point at one, and the galaxy can darken too, or go, leaving only the dots.",controls:[{id:"q.linkDensity",label:"Presentation links",choice:[["single","One clear link"],["branched","Branching"],["rich","Connected"]],def:"branched"},{id:"w.dim",label:"Darken the other dots",toggle:true,def:true},{id:"w.galaxy",label:"Galaxy",min:0,max:1,step:.01,fmt:pct,def:1}]},{name:"What is coming in",note:"As the timeline plays, at the bottom left: the app and the document being taken in now, and whether it was received, created or edited.",controls:[{id:"q.names",label:"Names",toggle:true,def:true}]},{name:"Camera and pace",note:"Cinematic camera: on the timeline the camera holds a still shot of everything that has come, and moves out slowly only when it is outgrown. Drag or zoom and it waits 5 seconds. Dynamic speed: the first things come slowly, then faster as more has come, up to the speed you chose.",controls:[{id:"q.follow",label:"Cinematic camera",toggle:true,def:true},{id:"q.dynamic",label:"Dynamic speed",toggle:true,def:true}]}]:[],{name:"Galaxy layers",note:"Each part of the galaxy on or off; your dots stay. The mist behind it is under Light.",controls:[{id:"y.fog",label:"Fog",toggle:true,def:true},{id:"y.stars",label:"Stars",toggle:true,def:true},{id:"y.dust",label:"Dust lanes",toggle:true,def:true},{id:"y.glow",label:"Glow",toggle:true,def:true}]},{name:"Experiments",note:"Obsidian graph: each of your things joined to the things nearest it in meaning. Fog made of links: the galaxy\u2019s fog drawn as made-up links between its dots; the same from afar, lines close in.",controls:[...nodes?[{id:"v.edges",label:"Obsidian graph",toggle:true,def:false}]:[],...fogLinks?[{id:"x.foglinks",label:"Fog made of links",toggle:true,def:false},{id:"x.foglight",label:"Link light",min:0,max:4,step:.05,fmt:times,def:1}]:[],{id:"x.bg",label:"Background",min:0,max:1,step:.01,fmt:pct,def:0}]},{name:"Links",note:"The twin at work: links forming one at a time and pulling it together, things arriving and staying, now and then a run of links like lightning that lights the core.",controls:[{id:"l.rate",label:"Links forming",min:0,max:4,step:.05,fmt:times,def:0},{id:"l.lightning",label:"Lightning",toggle:true,def:false},{id:"l.pull",label:"Links pull",min:0,max:4,step:.05,fmt:times,def:PULL},{id:"l.core",label:"Core glow from links",min:0,max:4,step:.05,fmt:times,def:1},{id:"l.stay",label:"New things stay",toggle:true,def:true},{id:"l.web",label:"Light from links",toggle:true,def:false}]},{name:"Motion",note:"Still stops everything: turning, links, the fog.",controls:[{id:"m.still",label:"Still",toggle:true,def:false},{id:"m.speed",label:"Speed",min:0,max:4,step:.05,fmt:times,def:1},{id:"m.turning",label:"Turning",toggle:true,def:true},{id:"m.fog",label:"Fog drifts",min:0,max:4,step:.05,fmt:times,def:1}]}];const CONTROLS=GROUPS.flatMap(g=>g.controls),byId=Object.fromEntries(CONTROLS.map(c=>[c.id,c]));const STORE="zx-twin-playground";let pg={who:-1,set:{}},base=null,entry=null,tuneTimer=0,tuned=0;try{const saved2=JSON.parse(localStorage.getItem(STORE)||"null");if(saved2?.set)pg={who:saved2.who??-1,set:saved2.set}}catch{}const save=()=>{try{localStorage.setItem(STORE,JSON.stringify(pg))}catch{}};if(Object.keys(pg.set).some(k=>/^(f|c|e|t)\./.test(k)&&!byId[k])){pg.set=Object.fromEntries(Object.entries(pg.set).filter(([k])=>!/^(f|c|e|t)\./.test(k)||byId[k]));save()}const startRows=()=>pg.who<0?rows:theirs(people?.people?.[pg.who])||rows;const startName=()=>pg.who<0?null:people?.people?.[pg.who]?.name||null;const defOf=c=>c.def??(c.id==="cam.tilt"?entry?.tilt??1.02:base?.[c.id.slice(2)]??0);const valueOf=c=>pg.set[c.id]??defOf(c);const GRAPH=/^(f|c|e|t)\./;const logoNow=()=>{if(nodes)nodes.logos={size:valueOf(byId["g.size"]),from:valueOf(byId["g.from"]),many:valueOf(byId["g.many"]),onDot:valueOf(byId["g.onDot"]),say:valueOf(byId["g.say"]),forming:valueOf(byId["g.forming"])}};if(byId["g.size"])logoNow();const back=c=>`<button type="button" class="one-back" data-back="${c.id}" aria-label="Put ${esc(c.label)} back" title="Put back">\u21BA</button>`;const openGroups=new Set;function buildPlay(){const who=startName();$("play-presets").innerHTML=[{name:"You"},...people?.people||[]].map((p,i)=>`<button type="button" role="radio" data-who="${i-1}" aria-checked="${i-1===pg.who}">${esc(p.name)}</button>`).join("");$("play-groups").innerHTML=GROUPS.map((g,gi)=>`<details class="group"${gi===0||g.name==="Experiments"||openGroups.has(g.name)?" open":""} data-group="${esc(g.name)}"><summary>${esc(g.name)}<svg viewBox="0 0 20 20" aria-hidden="true"><path d="m6 8 4 4 4-4"/></svg></summary>
|
|
9
|
+
${g.note?`<p class="group-note">${esc(g.note)}</p>`:""}
|
|
10
|
+
${g.controls.map(c=>c.choice?`<div class="ctl choice-row" data-id="${c.id}"><label for="pg-${c.id}">${esc(c.label)}</label><select id="pg-${c.id}" data-id="${c.id}">${c.choice.map(([v,l])=>`<option value="${v}">${esc(l)}</option>`).join("")}</select>${back(c)}</div>`:c.toggle?`<div class="ctl switch-row" data-id="${c.id}"><label><span>${esc(c.label)}</span><input type="checkbox" role="switch" data-id="${c.id}"><i class="switch" aria-hidden="true"></i></label>${back(c)}</div>`:`<div class="ctl" data-id="${c.id}"><label for="pg-${c.id}" title="Double-click to put back">${esc(c.label)}</label>
|
|
11
|
+
<div class="range"><input type="range" id="pg-${c.id}" data-id="${c.id}" min="${c.min}" max="${c.max}" step="${c.step}"><i class="mine" title="${who?`${esc(who)}\u2019s`:"Yours"}"></i></div><output id="pgo-${c.id}"></output>${back(c)}</div>`).join("")}
|
|
12
|
+
</details>`).join("");sync()}function sync(){for(const c of CONTROLS){const v=valueOf(c),el=$("play-groups").querySelector(`[data-id="${c.id}"]:is(input, select)`);if(!el)continue;if(c.choice){el.value=v;el.closest(".ctl").classList.toggle("moved",c.id in pg.set);continue}if(c.toggle){el.checked=!!v;el.closest(".ctl").classList.toggle("moved",c.id in pg.set);continue}el.value=v;$(`pgo-${c.id}`).textContent=c.fmt(+v);const d=defOf(c),mine=el.parentElement.querySelector(".mine");mine.style.left=`calc(1px + (100% - 2px) * ${Math.max(0,Math.min(1,(d-c.min)/(c.max-c.min)))})`;el.style.setProperty("--fill",`${Math.max(0,Math.min(1,(v-c.min)/(c.max-c.min)))*100}%`);el.closest(".ctl").classList.toggle("moved",c.id in pg.set)}$("play-presets").querySelectorAll("[data-who]").forEach(b=>b.setAttribute("aria-checked",String(+b.dataset.who===pg.who)));showSaved()}const SAVED="zx-twin-playground-saved";let saved=[],pair=[];try{saved=JSON.parse(localStorage.getItem(SAVED)||"[]").filter(x=>x?.set&&x.name)}catch{}const keepSaved=()=>{try{localStorage.setItem(SAVED,JSON.stringify(saved))}catch{}};const flat=set=>JSON.stringify(Object.entries(set).sort(([a],[b])=>a<b?-1:1));const same=(a,b)=>a.who===b.who&&flat(a.set)===flat(b.set);const chose=i=>{if(pair[pair.length-1]!==i)pair=[pair[pair.length-1],i].filter(v=>v!=null)};function showSaved(){const at2=saved.findIndex(x=>same(x,pg)),time2=t=>new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});$("play-saved").innerHTML=saved.map((x,i)=>`<span class="chip"><button type="button" role="radio" data-slot="${i}" aria-checked="${i===at2}" title="From ${esc(x.start)}, saved at ${time2(x.at)}">${esc(x.name)}</button><button type="button" class="drop" data-drop="${i}" aria-label="Forget ${esc(x.name)}">\xD7</button></span>`).join("");$("play-saved").hidden=!saved.length;$("play-flip").disabled=pair.filter(i=>saved[i]).length<2}function useSaved(i){const x=saved[i];if(!x)return;const who=pg.who;pg={who:x.who,set:{...x.set}};save();chose(i);if(x.who!==who){base=galaxy.featuresOf(startRows());buildPlay()}else sync();applyNow();applyShape(600)}$("play-save").onclick=()=>{let at2=saved.findIndex(x=>same(x,pg));if(at2<0){const taken=new Set(saved.map(x=>x.name)),name=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"].find(c=>!taken.has(c))||`${saved.length+1}`;saved.push({name,who:pg.who,start:startName()||"You",set:{...pg.set},at:Date.now()});keepSaved();at2=saved.length-1;chose(at2)}showSaved();const b=$("play-save");b.textContent=`Saved as ${saved[at2].name}`;setTimeout(()=>{b.textContent="Save"},1400)};$("play-flip").onclick=()=>{const p=pair.filter(i=>saved[i]);if(p.length===2)useSaved(p[0])};$("play-saved").onclick=e=>{const d=e.target.closest("[data-drop]");if(d){const i=+d.dataset.drop;saved.splice(i,1);pair=pair.filter(v=>v!==i).map(v=>v>i?v-1:v);keepSaved();showSaved();return}const b=e.target.closest("[data-slot]");if(b)useSaved(+b.dataset.slot)};function applyNow(){const still=valueOf(byId["m.still"]);galaxy.sky(valueOf(byId.sky));galaxy.state.speed=valueOf(byId["m.speed"]);galaxy.setPaused(still||!valueOf(byId["m.turning"]));galaxy.dragTurns(valueOf(byId["cam.turns"]));galaxy.state.targetTilt=valueOf(byId["cam.tilt"]);galaxy.life?.({fog:valueOf(byId["m.fog"]),core:valueOf(byId["l.core"]),stay:valueOf(byId["l.stay"])});if(byId["x.bg"])background(valueOf(byId["x.bg"]));if(fogLinks)fogLinks.options={on:valueOf(byId["x.foglinks"]),light:valueOf(byId["x.foglight"])};if(nodes)nodes.view=Object.fromEntries(["made","kept","people","docs","thoughts","names","links","open","blend","edges"].map(k=>[k,valueOf(byId[`v.${k}`])]));if(nodes)logoNow();galaxy.galaxyLook?.({fog:valueOf(byId["y.fog"]),stars:valueOf(byId["y.stars"]),dust:valueOf(byId["y.dust"]),glow:valueOf(byId["y.glow"])});if(nodes)nodes.linkLook={dim:valueOf(byId["w.dim"]),galaxy:valueOf(byId["w.galaxy"])};if(nodes&&byId["q.linkDensity"])nodes.visualDensity=valueOf(byId["q.linkDensity"]);camFollow(byId["q.follow"]?valueOf(byId["q.follow"]):pg.set["q.follow"]??true);dynamicPace=byId["q.dynamic"]?valueOf(byId["q.dynamic"]):pg.set["q.dynamic"]??true;if(byId["q.names"]&&feedNames!==valueOf(byId["q.names"])){feedNames=valueOf(byId["q.names"]);if(feedLast)feedDraw()}if(links)links.options={rate:still?0:valueOf(byId["l.rate"]),lightning:!still&&valueOf(byId["l.lightning"]),web:valueOf(byId["l.web"]),pull:valueOf(byId["l.pull"])}}function applyShape(ms=450){clearTimeout(tuneTimer);if(mode==="time"&&(past||playing||resumable))return;tuneTimer=setTimeout(()=>{const start=startRows(),who=startName(),tune={f:{},e:{}};let any=false;for(const[k,v]of Object.entries(pg.set)){if(!GRAPH.test(k)||!byId[k])continue;any=true;const[kind,key]=k.split(".");if(kind==="f")tune.f[key]=v;else if(kind==="e")tune.e[key]=v;else tune[key]=v}const moved=who!=null||Object.keys(tune.f).some(k=>!["young","clock"].includes(k))||tune.depth!=null;if(nodes)nodes.away=moved;if(!any&&who==null){if(other){galaxy.reshape(rows,ms);other=false}return}other=true;galaxy.reshape(any?{...start,as_of:`${start.as_of}~${++tuned}`,tune}:start,ms,id(who))},90)}$("settings-btn").onclick=()=>{if(!panel.hidden&&view==="play"){setPanel(false);return}buildPlay();setPanel(true,"play")};function sideAside(){const by=0;document.body.style.setProperty("--strip-aside",`${by}px`)}addEventListener("resize",sideAside);function axis(show){document.body.toggleAttribute("data-axis-hidden",!show);$("time-shown").hidden=show||mode!=="time"}$("time-hide").onclick=()=>axis(false);$("time-unhide").onclick=()=>axis(true);$("time-today").onclick=()=>{stop();const n=history?.snapshots?.length;if(n)showAt(n-1)};let full=false,fullOpen=false,hintTimer=0;function fullScreen(on){if(full===on)return;full=on;document.body.toggleAttribute("data-full",on);parent.postMessage({type:"zortex-twin-full",on},"*");if(on){fullOpen=!panel.hidden&&view==="play";if(!panel.hidden)setPanel(false);hint()}else{document.body.removeAttribute("data-full-hint");if(fullOpen&&mode==="time")setPanel(true,"play")}}function hint(){if(!full)return;document.body.setAttribute("data-full-hint","");clearTimeout(hintTimer);hintTimer=setTimeout(()=>document.body.removeAttribute("data-full-hint"),2200)}addEventListener("pointermove",hint,{passive:true});$("full-btn").onclick=()=>fullScreen(true);$("full-exit").onclick=()=>fullScreen(false);async function openPlay(){if(mode==="play"){setPanel(true,"play");return}const mine=++modeRun;stop();time.hidden=others.hidden=true;if(mode){leaving();mode=null;whole(600);if(other){galaxy.reshape(rows,600);other=false}if(shown!==rows)fill(rows,yours)}mode="play";check("play");entry={tilt:galaxy.state.targetTilt,speed:galaxy.state.speed,paused:galaxy.state.paused};await loadPeople();if(mine!==modeRun)return;base=galaxy.featuresOf(startRows());buildPlay();setPanel(true,"play");applyNow();applyShape(700);aside(true);rememberView()}let inset=0;const shift=on=>((on&&innerWidth>=900?panel.offsetWidth+82:0)-inset)/2;function aside(on){const st=galaxy.state,k=st.targetDistance/galaxy.viewScale(),phone=innerWidth<=600;st.targetPanX=shift(on)*k;st.targetPanY=on&&phone?-innerHeight*.22*k:0}function background(v){const g=Math.round(v*46),canvas=$("universe");document.body.style.backgroundColor=v>0?`rgb(${g},${g},${g+3})`:"";canvas.style.mixBlendMode=v>0?"screen":""}function leavePlay(){clearTimeout(tuneTimer);galaxy.sky(true);galaxy.dragTurns(false);aside(false);if(entry){galaxy.state.targetTilt=entry.tilt;galaxy.state.speed=entry.speed;galaxy.setPaused(entry.paused)}if(nodes){nodes.view={made:true,kept:true,people:true,docs:true,thoughts:true,names:true,links:true,open:false,blend:true,edges:false};nodes.marks="names"}background(0);if(fogLinks)fogLinks.options={on:false};if(links)links.options={rate:0,lightning:false,web:false,pull:PULL};galaxy.life?.({fog:1,core:1,stay:true});if(other){galaxy.reshape(rows,700);other=false}thingsBack(700);if(!panel.hidden&&view==="play")setView("modes")}const changed=c=>{save();sync();if(GRAPH.test(c.id))applyShape();else applyNow()};$("play-groups").addEventListener("input",e=>{const c=byId[e.target.dataset.id];if(!c)return;pg.set[c.id]=c.toggle?e.target.checked:c.choice?e.target.value:+e.target.value;if(c.toggle||c.choice?pg.set[c.id]===defOf(c):Math.abs(pg.set[c.id]-defOf(c))<c.step/2)delete pg.set[c.id];changed(c)});$("play-groups").addEventListener("toggle",e=>{const g=e.target.dataset?.group;if(g)e.target.open?openGroups.add(g):openGroups.delete(g)},true);$("play-groups").addEventListener("click",e=>{const id2=e.target.closest("[data-back]")?.dataset.back,c=byId[id2];if(!c||!(c.id in pg.set))return;e.preventDefault();delete pg.set[c.id];changed(c)});$("play-groups").addEventListener("dblclick",e=>{const c=byId[e.target.closest(".ctl:not(.switch-row)")?.dataset.id];if(!c||!(c.id in pg.set))return;delete pg.set[c.id];changed(c)});$("play-presets").onclick=e=>{const b=e.target.closest("[data-who]");if(!b)return;pg={who:+b.dataset.who,set:Object.fromEntries(Object.entries(pg.set).filter(([k])=>!/^(f|c)\./.test(k)))};base=galaxy.featuresOf(startRows());save();buildPlay();applyShape(800)};$("play-reset").onclick=()=>{pg={who:pg.who,set:{}};save();sync();applyNow();applyShape(700)};$("play-shuffle").onclick=()=>{for(const c of CONTROLS)if(/^(f|c)\./.test(c.id)&&c.id!=="f.growth"){const v=c.min+Math.random()*(c.max-c.min);pg.set[c.id]=Math.round(v/c.step)*c.step}save();sync();applyShape(900)};$("play-copy").onclick=async()=>{const text=JSON.stringify({start:startName()||"You",...Object.fromEntries(Object.entries(pg.set).map(([k,v])=>[k,typeof v==="number"?+v.toFixed(3):v]))},null,1);let ok=false;try{await navigator.clipboard.writeText(text);ok=true}catch{const t=document.createElement("textarea");t.value=text;document.body.appendChild(t);t.select();try{ok=document.execCommand("copy")}catch{}t.remove()}const b=$("play-copy");b.textContent=ok?"Copied":"Couldn\u2019t copy";setTimeout(()=>{b.textContent="Copy settings"},1600)};$("play-done").onclick=()=>{if(mode==="time"){setPanel(false);return}backToYou();setPanel(false);toggle.focus()};const zoom=f=>galaxy.zoomAt(f,innerWidth/2-shift(mode==="play"),innerHeight/2);$("zoom-in").onclick=()=>zoom(1/1.3);$("zoom-out").onclick=()=>zoom(1.3);$("recenter").onclick=()=>{galaxy.reset();aside(mode==="play");if(mode==="play")galaxy.state.targetTilt=valueOf(byId["cam.tilt"])};addEventListener("keydown",e=>{if(e.key==="Escape"&&full){e.preventDefault();fullScreen(false);return}if(e.key==="Escape"&&nodes?.open){e.preventDefault();nodes.close();return}if(e.key==="Escape"&&!panel.hidden){e.preventDefault();if(view==="facts")setView("modes");else{setPanel(false);toggle.focus()}return}if(e.key==="Escape"&&mode){e.preventDefault();backToYou();return}if(e.metaKey||e.ctrlKey||e.altKey||e.key.length!==1||e.target.closest?.("button,input,textarea,select,a,label"))return;e.preventDefault();e.stopImmediatePropagation();if(e.key!==" ")parent.postMessage({type:"zortex-key",key:e.key},"*")},true);addEventListener("message",e=>{if(e.source!==parent||e.data?.type!=="zortex-twin")return;const left=e.data.inset;if(Number.isFinite(left)&&left!==inset){galaxy.state.targetPanX-=(left-inset)/2*galaxy.state.targetDistance/galaxy.viewScale();inset=left}document.body.classList.toggle("resting",!e.data.visible);if(!e.data.visible){if(mode==="play"||full)backToYou();galaxy.stop();setPanel(false);return}const paused=galaxy.state.paused;galaxy.play();if(paused)galaxy.setPaused(true)});async function restoreView(){if(!previousView||!galaxy.reshape)return;if(previousView.mode==="time")await openMode("time",previousView);else if(previousView.mode==="others"){await openMode("others");const i=people?.people?.findIndex(p=>p.name===previousView.person)??-1;if(i>=0)await galaxy.shapeOf(theirs(people.people[i]),id(people.people[i].name));if(mode==="others")showPerson(i,0)}else if(previousView.mode==="play")await openMode("time");restoreCamera(galaxy.state,previousView.camera,inset,galaxy.viewScale());galaxy.setPaused(galaxy.state.paused);if(previousView.panel&&previousView.panel!=="play")setPanel(true,previousView.panel);panel.scrollTop=previousView.scroll}try{await restoreView()}catch(error){console.warn("Could not restore the twin view:",error)}restoringView=false;for(const event of["pointerup","pointercancel","wheel","keyup","input","change"])addEventListener(event,rememberView,{passive:true});panel.addEventListener("scroll",rememberView,{passive:true});addEventListener("pagehide",persistView);document.addEventListener("visibilitychange",()=>{if(document.hidden)persistView()});parent.postMessage({type:"zortex-twin-ready"},"*")}function picture(v){if(!v)return"";const pct=x=>`${Math.round(x*100)}%`;if(v.kind==="share")return`<div class="viz"><div class="viz-track"><i style="width:${pct(v.value)}"></i></div><div class="viz-label"><span>${esc(v.label)}</span></div></div>`;if(v.kind==="parts")return`<div class="viz"><div class="viz-parts">${v.values.map((x,i)=>`<i style="flex:${x};--a:${(.85-i*.55/Math.max(1,v.values.length-1)).toFixed(2)}"></i>`).join("")}</div>
|
|
13
|
+
<div class="viz-parts-label">${v.values.map(x=>`<span style="flex:${x}">${pct(x)}</span>`).join("")}</div></div>`;if(v.kind==="bars"){const top=Math.max(...v.values);return`<div class="viz"><div class="viz-bars">${v.values.map(x=>`<i style="height:${Math.max(4,x/top*100)}%" title="${x} days"></i>`).join("")}</div><div class="viz-label"><span>${esc(v.label)}</span><span>${top} days at most</span></div></div>`}if(v.kind==="scale")return`<div class="viz"><div class="viz-scale"><i style="left:${(v.value+1)/2*100}%"></i></div><div class="viz-label"><span>${esc(v.from)}</span><span>${esc(v.to)}</span></div></div>`;if(v.kind==="timeline")return`<div class="viz"><div class="viz-time">${"<i></i>".repeat(Math.min(v.ticks+1,60))}</div><div class="viz-label"><span>${esc(v.from)}</span><span>${esc(v.to)}</span></div></div>`;return""}})();
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>Your digital twin</title>
|
|
7
|
+
<script src="look.js"></script>
|
|
8
|
+
<link rel="stylesheet" href="vendor/galaxy.css">
|
|
9
|
+
<link rel="stylesheet" href="zx-tokens.css">
|
|
10
|
+
<link rel="stylesheet" href="star-graph.css">
|
|
11
|
+
<link rel="stylesheet" href="product.css"></head>
|
|
12
|
+
<body>
|
|
13
|
+
<canvas id="universe" role="img" aria-label="Your digital twin. Drag to move around it, Option-drag to turn it; scroll or use the zoom buttons to zoom." tabindex="-1"></canvas>
|
|
14
|
+
<!-- The window's controls, where Apple Maps keeps them: the twin's modes and the whole view, and zoom (the compass is gone, founder 2026-10-06). -->
|
|
15
|
+
<nav class="map-controls" id="controls" aria-label="Twin controls" hidden>
|
|
16
|
+
<div class="capsule">
|
|
17
|
+
<button id="world-toggle" type="button" aria-label="Twin modes" title="Twin modes" aria-expanded="false" aria-controls="world">
|
|
18
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path class="fill" d="M3.2 6.7 8 4.6v14.7l-4.8 2.1zM9.4 4.6l5.2 2.1v14.7l-5.2-2.1zM16 6.7l4.8-2.1v14.7L16 21.4z"/></svg>
|
|
19
|
+
</button>
|
|
20
|
+
<button id="recenter" type="button" aria-label="Show the whole twin" title="Show the whole twin">
|
|
21
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20 4 4.2 10.9l7.1 1.8 1.8 7.1z"/></svg>
|
|
22
|
+
</button>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="capsule play-only">
|
|
25
|
+
<button id="settings-btn" type="button" aria-label="Graph settings" title="Graph settings" aria-expanded="false" aria-controls="world">
|
|
26
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h9M17 7h3M4 17h3M11 17h9"/><circle cx="15" cy="7" r="2"/><circle cx="9" cy="17" r="2"/></svg>
|
|
27
|
+
</button>
|
|
28
|
+
<button id="full-btn" type="button" aria-label="Full screen" title="Full screen: only the galaxy (Esc to come back)">
|
|
29
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 9V5h4M19 9V5h-4M5 15v4h4M19 15v4h-4"/></svg>
|
|
30
|
+
</button>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="capsule">
|
|
33
|
+
<button id="zoom-in" type="button" aria-label="Zoom in" title="Zoom in"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5.5v13M5.5 12h13"/></svg></button>
|
|
34
|
+
<button id="zoom-out" type="button" aria-label="Zoom out" title="Zoom out"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5.5 12h13"/></svg></button>
|
|
35
|
+
</div>
|
|
36
|
+
</nav>
|
|
37
|
+
<!-- One glass panel beside the controls, like the Map Modes popover in Apple Maps. It shows the twin's modes, what
|
|
38
|
+
shapes it, or the playground. The window's engine steps aside while it is open (app.js watches #world). -->
|
|
39
|
+
<!-- the time bar hidden: a small button to bring it back, and one to jump to today -->
|
|
40
|
+
<div id="time-shown" class="time-shown" hidden><button id="time-unhide" type="button">Show the time bar</button><button id="time-today" type="button">Today</button></div>
|
|
41
|
+
<button id="full-exit" class="full-exit" type="button">Exit full screen <kbd>esc</kbd></button>
|
|
42
|
+
<section id="world" class="world" role="dialog" aria-labelledby="modes-title" data-view="modes" hidden>
|
|
43
|
+
<div class="view" data-for="modes">
|
|
44
|
+
<header><h2 id="modes-title">Twin Modes</h2>
|
|
45
|
+
<button class="close" type="button" aria-label="Close" data-close><svg viewBox="0 0 20 20" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button></header>
|
|
46
|
+
<div class="modes" id="modes" role="radiogroup" aria-labelledby="modes-title">
|
|
47
|
+
<button class="mode" type="button" role="radio" data-mode="twin" aria-checked="true"><canvas></canvas><span>Twin</span></button>
|
|
48
|
+
<button class="mode" type="button" role="radio" data-mode="time" aria-checked="false" hidden><canvas></canvas><span>Timeline</span></button>
|
|
49
|
+
<button class="mode" type="button" role="radio" data-mode="play" aria-checked="false"><canvas></canvas><span>Playground</span></button>
|
|
50
|
+
<button class="mode" type="button" role="radio" data-mode="others" aria-checked="false"><canvas></canvas><span>People</span></button>
|
|
51
|
+
<button class="mode" type="button" role="radio" data-mode="insights" aria-checked="false"><canvas></canvas><span>Analytics</span></button>
|
|
52
|
+
</div>
|
|
53
|
+
<button class="row" type="button" data-view="facts"><span>What shapes your twin</span><small id="facts-count"></small>
|
|
54
|
+
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="m8 5 5 5-5 5"/></svg></button>
|
|
55
|
+
<p class="world-foot" id="modes-foot"></p>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="view" data-for="facts" hidden>
|
|
58
|
+
<header><button class="back" type="button" data-view="modes" aria-label="Back to modes"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="m12 5-5 5 5 5"/></svg></button>
|
|
59
|
+
<h2 id="world-title">What shapes your world</h2>
|
|
60
|
+
<button class="close" type="button" aria-label="Close" data-close><svg viewBox="0 0 20 20" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button></header>
|
|
61
|
+
<p class="world-sub" id="world-sub"></p>
|
|
62
|
+
<div id="world-facts"></div>
|
|
63
|
+
<p class="world-note" id="world-note">The twin is a picture of a saved snapshot, drawn from these numbers. No star is a single record or a person.</p>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="view" data-for="play" hidden>
|
|
66
|
+
<!-- one bar that stays at the top while the settings scroll (founder, 2026-10-05: "hard to navigate", TW-38) -->
|
|
67
|
+
<div class="play-bar">
|
|
68
|
+
<header><button class="back" type="button" data-view="modes" aria-label="Back to modes"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="m12 5-5 5 5 5"/></svg></button>
|
|
69
|
+
<h2 id="play-title">Playground</h2><button class="done" id="play-done" type="button">Done</button></header>
|
|
70
|
+
<div class="play-tools">
|
|
71
|
+
<button type="button" class="tool" id="play-reset" title="Put every setting back">Reset all</button>
|
|
72
|
+
<button type="button" class="tool" id="play-shuffle">Surprise me</button>
|
|
73
|
+
<span class="spacer"></span>
|
|
74
|
+
<button type="button" class="tool play-only" id="play-clip" title="Records the twin month by month, from its first month to today, names hidden, and saves it as a video">Record by month</button><button type="button" class="tool play-only" id="play-clip-year" title="Records the twin year by year, from its first month to today, names hidden, and saves it as a video">By year</button><button type="button" class="tool" id="play-save">Save</button><button type="button" class="tool" id="play-flip" disabled>Flip</button>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="saved" id="play-saved" role="radiogroup" aria-label="Saved settings" hidden></div>
|
|
77
|
+
</div>
|
|
78
|
+
<p class="world-sub" id="play-sub">Move a setting and the twin follows. Shape, colour and light show on Today; earlier months keep their own. The mark under a slider is your own value; ↺ puts one back.</p>
|
|
79
|
+
<!-- the timeline's two choices, moved here from the time bar (founder, 2026-10-07) -->
|
|
80
|
+
<div class="play-time play-only">
|
|
81
|
+
<div class="ctl choice-row"><label>Below the dots</label><button id="time-marks" class="pill" type="button">App logos</button></div>
|
|
82
|
+
<div class="ctl choice-row"><label>New things appear</label><button id="time-spawn" class="pill" type="button">A · from edge</button></div>
|
|
83
|
+
</div>
|
|
84
|
+
<div id="play-groups"></div>
|
|
85
|
+
<details class="group" id="play-start" hidden><summary>Start from someone else<svg viewBox="0 0 20 20" aria-hidden="true"><path d="m6 8 4 4 4-4"/></svg></summary>
|
|
86
|
+
<p class="group-note">The sliders take that person’s values instead of yours.</p>
|
|
87
|
+
<div class="presets" id="play-presets" role="radiogroup" aria-label="Start from"></div>
|
|
88
|
+
</details>
|
|
89
|
+
<div class="play-actions"><button type="button" class="tool" id="play-copy">Copy settings</button></div>
|
|
90
|
+
<p class="world-foot" id="play-foot">Only you see these. Done puts your twin back; the playground remembers where you left it.</p>
|
|
91
|
+
</div>
|
|
92
|
+
</section>
|
|
93
|
+
<!-- Your twin over time (one step per month), and other people's twins: the same rules drawn from other numbers. -->
|
|
94
|
+
<!-- beside the timeline, on the left: the day, how the twin has grown, and what is coming in now (founder, 2026-10-07) -->
|
|
95
|
+
<aside id="time-side" class="time-side" aria-label="Where the timeline is" hidden>
|
|
96
|
+
<p class="side-date" id="time-date"></p><p class="side-line" id="time-line"></p>
|
|
97
|
+
<canvas id="time-growth" aria-hidden="true"></canvas>
|
|
98
|
+
<p class="growth-total"><b id="time-total"></b> things and people</p>
|
|
99
|
+
<div id="feed" class="feed" aria-label="What is coming in now" aria-live="off" hidden></div>
|
|
100
|
+
</aside>
|
|
101
|
+
<div class="topic-explore" id="topic-explore" hidden></div>
|
|
102
|
+
<section id="time" class="strip" aria-label="Your twin over time" hidden>
|
|
103
|
+
<div class="strip-head">
|
|
104
|
+
<button id="time-play" class="play" type="button" aria-label="Play"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="tri" d="M5 3.2v9.6L12.8 8z"/><path class="bars" d="M5 3.5h2v9H5zM9 3.5h2v9H9z"/></svg></button>
|
|
105
|
+
<button id="time-speed" class="speed" type="button" aria-label="Speed 1×, click for faster">1×</button>
|
|
106
|
+
<button id="time-hide" class="close" type="button" aria-label="Hide the time bar" title="Hide the time bar"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="m6 8 4 4 4-4"/></svg></button>
|
|
107
|
+
</div>
|
|
108
|
+
<div class="track" id="time-track" tabindex="0" role="slider" aria-label="When" aria-valuemin="0"><canvas id="time-bars"></canvas></div>
|
|
109
|
+
<div class="years" id="time-years"></div>
|
|
110
|
+
</section>
|
|
111
|
+
<section id="others" class="strip" aria-labelledby="others-title" hidden>
|
|
112
|
+
<div class="strip-head">
|
|
113
|
+
<div class="strip-text"><p class="strip-title" id="others-title">Other people’s twins</p><p class="strip-line" id="others-line">Made-up people, drawn by the same rules as yours.</p></div>
|
|
114
|
+
<button id="others-close" class="close" type="button" aria-label="Back to your twin"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="people" id="others-list"></div>
|
|
117
|
+
</section>
|
|
118
|
+
<!-- The real things on the twin's stars (star-graph-nodes.js): their names, and the one you opened. -->
|
|
119
|
+
<canvas id="links" aria-hidden="true"></canvas>
|
|
120
|
+
<canvas id="nodes" aria-hidden="true"></canvas>
|
|
121
|
+
<section id="node-card" class="node-card" role="dialog" aria-labelledby="node-title" hidden></section>
|
|
122
|
+
<p id="graph-message" role="status" hidden></p>
|
|
123
|
+
<!-- The renderer binds these; the page shows its own controls instead. -->
|
|
124
|
+
<div id="dock-wrap" class="dock-wrap" hidden>
|
|
125
|
+
<div id="speed-popover" class="speed-popover glass" hidden>
|
|
126
|
+
<input id="speed" type="range" min="0.15" max="2.5" step="0.05" value="1"><output id="speed-label" for="speed">1×</output>
|
|
127
|
+
</div>
|
|
128
|
+
<nav id="dock" class="dock glass">
|
|
129
|
+
<button id="dock-grip" class="grip control" type="button"></button>
|
|
130
|
+
<button id="pause" class="control primary" type="button"><svg id="pause-icon" viewBox="0 0 20 20"><path d="M7 5v10M13 5v10"/></svg></button>
|
|
131
|
+
<button id="speed-toggle" class="control" type="button"></button>
|
|
132
|
+
<button id="reset" class="control" type="button"></button>
|
|
133
|
+
<button id="cinema" class="control" type="button"></button>
|
|
134
|
+
</nav>
|
|
135
|
+
</div>
|
|
136
|
+
<button id="restore" class="restore glass" type="button" hidden></button>
|
|
137
|
+
<div id="status" class="sr-only" role="status" aria-live="polite"></div>
|
|
138
|
+
<div id="loader" hidden><span></span></div>
|
|
139
|
+
<script type="module" src="star-graph.js"></script>
|
|
140
|
+
<script src="app-i18n-twin.js"></script><script type="module" src="product.js"></script></body>
|
|
141
|
+
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{syncSummary}from"./sync-model.js";import{connectionView}from"./app-model.js";const names={"google-chrome":"Google Chrome","microsoft-edge":"Microsoft Edge","gmail":"Gmail","google-drive":"Google Drive","google-calendar":"Google Calendar","youtube":"YouTube","notion":"Notion","slack":"Slack","outlook":"Outlook"};export function connectionRows(state,apps=[]){const catalog=new Map(apps.filter(app=>typeof app.id==="string"&&app.id).map(app=>[app.id,app]));const coverage=new Map((state.coverage||[]).map(row=>[row.source,row]));const reports=new Map([...state.connectionReport?.sources||[],...state.connectionReport?.others||[]].map(row=>[row.source,row]));return[...new Set([...coverage.keys(),...catalog.keys(),...reports.keys()])].map(source=>{const row=coverage.get(source)||{source,directory:catalog.has(source),registered:false,configured:false,connectionState:"unverified",items:null,dataState:"unverified"};const app=catalog.get(source);const sync=syncSummary(row.sync),guidance=row.support,progress=row.progress,report=reports.get(row.source),view=report?connectionView(row,report):null;const running=progress&&progress.stage!=="finished";const failed=progress?.stage==="finished"&&!!progress.errorCode;const attempt=running?`Current attempt: ${progress.stage}`:failed?`Latest attempt failed: ${progress.errorCode}. Open this app to review and retry.`:null;const label=app?.name&&app.name!==source?app.name:report?.label||names[source]||source;const stored=Number.isSafeInteger(row.items)?`${row.items.toLocaleString()} stored records`:"Stored records unverified";return{id:row.source,name:label,group:guidance?.state==="unsupported"?"Unavailable here":guidance?.state==="setup-required"||row.registration==="deferred"?"Setup required":row.registered?"Registered source":row.configured?"Product candidate source":row.directory?"Source directory":"Additional local source",items:row.items,detail:view?`${view.status} \xB7 ${view.description}${sync?` \xB7 ${sync}`:""}`:`${attempt?`${attempt} \xB7 `:""}${row.registered===null?"connection status unavailable":row.registration==="deferred"?"setup required in this app":row.verification==="configuration-only"?"configured \xB7 connection unverified":row.readiness?`Actions ready \xB7 ${failed?"latest attempt failed":row.readiness.operation.state==="not-run"?"read not run":row.readiness.operation.returned===void 0?"action succeeded":`read returned ${row.readiness.operation.returned}`}`:row.readEvidence?failed?"connected \xB7 latest attempt failed":`connected \xB7 read returned ${row.readEvidence.returned}`:row.connectionState} \xB7 ${stored} \xB7 ${row.dataState.replaceAll("_"," ")}${guidance?` \xB7 ${guidance.message}`:""}${sync?` \xB7 ${sync}`:""}`,status:report&&["connected","not-connected","unavailable"].includes(report.connection)?report.connection:row.connectionState,reason:attempt??guidance?.message??row.connectionState,bucket:view?view.kind==="working"?"connecting":view.attention?"attention":view.connected?"connected":"attention":running?"connecting":failed?"attention":row.connectionState==="connected"?"connected":"attention"}})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let current={coverage:[]};const observers=new Set;export function setSnapshot(snapshot){current=snapshot||{coverage:[]};for(const notify of observers)notify()}export function loadState(){return{coverage:current.coverage||[],ais:[],cloud:{mode:null},mods:{},appSettings:{actions:"never"},appPrefs:{}}}export function observeState(notify){observers.add(notify);return()=>observers.delete(notify)}
|
|
1
|
+
let current={coverage:[]};const observers=new Set;export function setSnapshot(snapshot){current=snapshot||{coverage:[]};for(const notify of observers)notify()}export function loadState(){return{coverage:current.coverage||[],connectionReport:current.connectionReport,ais:[],cloud:{mode:null},mods:{},appSettings:{actions:"never"},appPrefs:{}}}export function observeState(notify){observers.add(notify);return()=>observers.delete(notify)}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{loadState as loadDemo,observeState as observeDemo}from"./live-state.js";import{connectionRows
|
|
1
|
+
import{loadState as loadDemo,observeState as observeDemo}from"./live-state.js";import{connectionRows}from"./live-model.js";import{aiScopeSummary,MODS,WORKFLOWS,modOn,getMod,dropMod,dependents}from"./product-model.js";import{esc}from"./setup-model.js";import{modIcon}from"./mod-icons.js";import{READS,ACTIONS,ACTION_SUMMARY,GROUP_ACTIONS,appSkills,appFlows,prefsFor,setPrefs,actionFor,readOn,skillOn,flowOn}from"./apps-model.js";const chev='<svg class="chev" viewBox="0 0 20 20" aria-hidden="true"><path d="m8 5 5 5-5 5"/></svg>';const plus='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5.5v13M5.5 12h13"/></svg>';const cap=s=>String(s||"").replace(/^./,c=>c.toUpperCase());const and=names=>names.length<2?names.join(""):names.slice(0,-1).join(", ")+" and "+names.at(-1);const compact=n=>new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(n);export async function mountPanels({open,openStore,sourceDetails,sourceAction,connectSource}){const $=id=>document.getElementById(id),el=$("panel"),body=$("panel-body"),tools=$("panel-tools");const fetchApps=()=>fetch("abilities.json",{cache:"no-store"}).then(r=>{if(!r.ok)throw new Error(`apps: HTTP ${r.status}`);return r.json()});const first=await fetchApps(),{iconSources,iconAliases={},localIconPaths={}}=first;let apps=first.apps;let reading=null;const refreshApps=()=>reading??=fetchApps().then(next=>{if(Array.isArray(next?.apps))apps=next.apps}).catch(()=>{}).finally(()=>{reading=null});let demo=loadDemo(),rows=connectionRows(demo,apps),at=null,drawn=null,linking=null;const ui={q:"",pending:new Set,ask:null,mode:"cloud",waiting:null,done:null};const timers=new Set,scrolls=new Map;const say=text=>{$("panel-status").textContent=text};const ico=id=>{if(localIconPaths[id])return`<span class="app-ico s"><img src="${esc(localIconPaths[id])}" alt=""></span>`;const icon=iconAliases[id]||id,source=iconSources[icon];if(!source)return'<span class="app-ico"><span aria-hidden="true">'+esc(String(id).slice(0,1).toUpperCase())+"</span></span>";const src=`icons/${encodeURIComponent(icon)}.${source==="s"?"svg":"png"}`;return`<span class="app-ico ${source}">${source==="f"?`<span><img src="${src}" alt=""></span>`:`<img src="${src}" alt="">`}</span>`};const aiIco=ai=>ai.icon==="zortex"?'<span class="app-ico z"><span><img src="zortex-mark.png" alt=""></span></span>':ico(ai.icon);const card=(to,icon,name,line,wrap=false)=>`<button class="p-card${wrap?" wrap":""}" type="button" data-to="${esc(to)}">${icon}<span class="p-words"><b>${esc(name)}</b><small>${esc(line)}</small></span></button>`;const link=(to,name,value="",disabled=false)=>`<button class="p-row" type="button" data-to="${esc(to)}" ${disabled?"disabled":""}><span class="grow">${esc(name)}</span><span class="value">${esc(value)}</span>${chev}</button>`;const sw=(id,attrs,on,label,disabled=false)=>`<input class="switch" type="checkbox" role="switch" id="${esc(id)}" ${attrs} aria-label="${esc(label)}" ${on?"checked":""} ${disabled?"disabled":""}>`;const pick=(id,attrs,value,options,label,disabled=false)=>`<select class="pick" id="${esc(id)}" ${attrs} aria-label="${esc(label)}" ${disabled?"disabled":""}>${Object.entries(options).map(([v,l])=>`<option value="${v}" ${v===value?"selected":""}>${esc(l)}</option>`).join("")}</select>`;const search=(id,label)=>`<label class="p-search"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="6.5"/><path d="m16 16 4 4"/></svg><input id="${id}" type="search" placeholder="Search" aria-label="${esc(label)}" autocomplete="off" spellcheck="false" value="${esc(ui.q)}"></label>`;const fact=(key,value)=>`<div class="p-row tall"><span class="key">${esc(key)}</span><span class="grow">${esc(value)}</span></div>`;const hero=(icon,lines2)=>`<div class="p-hero">${icon}<p>${lines2}</p></div>`;const lines=(title,items)=>items.length?`<p class="p-label">${esc(title)}</p><div class="p-group">${items.map(t=>`<div class="p-row">${esc(t)}</div>`).join("")}</div>`:"";const confirm=(key,title,text,attr)=>ui.ask!==key?"":`<div class="p-callout" role="alert"><b>${esc(title)}</b> ${esc(text)}<div class="p-actions"><button class="p-pill" type="button" ${attr}>Turn Off</button><button class="text-button" type="button" data-cancel>Cancel</button></div></div>`;const findAI=id=>demo.ais.find(a=>a.id===id);const live=ai=>ai.connected&&(ai.where!=="cloud"||!!demo.cloud.mode);const reads=(ai,id)=>ai.apps==="selected"||(ai.apps||[]).includes(id);const linked=()=>rows.filter(a=>a.bucket==="connected");function aisView(){return{title:"Connected AIs",html:'<p class="p-lead">Use Zortex through your connected AI.</p><p class="p-note">Connected AI status is not available yet.</p>'}}const findApp=id=>rows.find(a=>a.id===id);const appState=a=>ui.pending.has(a.id)||a.bucket==="connecting"?"connecting":a.bucket==="connected"?"on":a.bucket==="attention"?"attention":"off";const appLine=a=>a.detail||"Connection unverified";const paused=()=>MODS.length>0&&!modOn(demo,"apps");const readers=()=>demo.ais.filter(ai=>ai.connected&&ai.context);function appsView([a,b]){if(a)return a==="all"?{title:"All Apps",back:"apps",html:'<p class="p-note">Permissions are managed by your connected AI. This view reports actual connection and read evidence; it does not change grants.</p>'}:{title:findApp(a)?.name||a,back:"apps",html:"<div data-source-receipt></div>"};const off=paused(),s=demo.appSettings;if(!a){const sorted=[...rows].sort((x,y)=>x.name.localeCompare(y.name)),on2=rows.filter(x=>appState(x)==="on").length;return{title:"Apps",html:`${search("panel-q","Search your apps")}
|
|
2
2
|
${off?'<div class="p-callout"><b>Apps is off.</b> Your AI can\u2019t read any of your apps until you turn it back on.<div class="p-actions"><button class="p-pill" type="button" data-mod-get="apps">Turn On</button></div></div>':""}
|
|
3
3
|
|
|
4
4
|
<p class="p-label">${on2} of ${rows.length} on</p>
|
|
5
|
-
<div data-filter>${sorted.map(x=>{const st2=appState(x);return`<div class="p-app ${st2}" data-name="${esc([x.name,x.group,x.detail].join(" ").toLowerCase())}"><button type="button" data-to="apps/${esc(x.id)}">${ico(x.id)}<span class="p-words"><b>${esc(x.name)}</b><small>${esc(appLine(x,st2))}</small></span></button
|
|
5
|
+
<div data-filter>${sorted.map(x=>{const st2=appState(x);return`<div class="p-app ${st2}" data-name="${esc([x.name,x.group,x.detail].join(" ").toLowerCase())}"><button type="button" data-to="apps/${esc(x.id)}">${ico(x.id)}<span class="p-words"><b>${esc(x.name)}</b><small>${esc(appLine(x,st2))}</small></span></button><button type="button" class="p-pill" data-source-connect="${esc(x.id)}" aria-label="${esc((sourceAction?.(x.id)?.actionLabel||"Open app")+" \xB7 "+x.name)}">${esc(sourceAction?.(x.id)?.actionLabel||"Open app")}</button></div>`}).join("")}</div>
|
|
6
6
|
<p class="p-none" data-none hidden>No matching apps.</p>`}}if(a==="all"){const n=readers().length;return{title:"All Apps",back:"apps",html:`<p class="p-lead">These apply to every app, unless you change one on its own page.</p>
|
|
7
7
|
<div class="p-group"><label class="p-row"><span class="grow">Actions<small>What your AI may do in your apps, like sending, paying or deleting.</small></span>${pick("g-actions",'data-global="actions"',s.actions,ACTIONS,"Actions for all apps")}</label></div>
|
|
8
8
|
<p class="p-label">Read your apps</p>
|
|
@@ -32,4 +32,4 @@ import{loadState as loadDemo,observeState as observeDemo}from"./live-state.js";i
|
|
|
32
32
|
${lines("Can read",m.reads)}${lines("Can do",m.does)}
|
|
33
33
|
${needs.length?`<p class="p-label">Needs</p><div class="p-group">${needs.join("")}</div>`:""}
|
|
34
34
|
${m.access.length?`<p class="p-label">Permissions</p><div class="p-group">${m.access.map(x=>`<div class="p-row"><span class="grow">${esc(x.name)}${x.why?`<small>${esc(x.why)}</small>`:""}</span></div>`).join("")}</div>`:""}
|
|
35
|
-
<div class="p-actions"><button class="text-button" type="button" data-store="mod/${esc(m.id)}">See it in the Mods store</button></div>`}}function filter(){const q=ui.q.trim().toLowerCase(),list=body.querySelector("[data-filter]");if(!list)return;let shown=0;for(const row of list.children){const hit=!q||row.dataset.name.includes(q);row.hidden=!hit;shown+=hit}list.hidden=!shown;const none=body.querySelector("[data-none]");if(none)none.hidden=shown>0}function draw(){if(!at)return;demo=loadDemo();rows=connectionRows(demo,apps);const key=[at.panel,...at.sub].join("/"),v={ais:aisView,apps:appsView,mods:modsView}[at.panel](at.sub);if(v.to!=null){open(v.to,true);return}const same=key===drawn,top=body.scrollTop,focus=same&&body.contains(document.activeElement)?document.activeElement:null;const caret=focus?.type==="search"?focus.selectionStart:null;if(!same&&drawn)scrolls.set(drawn,top);$("panel-title").textContent=v.title;$("panel-back").hidden=!v.back;$("panel-back").dataset.to=v.back||"";body.innerHTML=v.html;tools.innerHTML=v.tools||"";tools.hidden=!v.tools;if(at.panel==="apps"&&at.sub[0]&&at.sub[0]!=="all")sourceDetails(body.querySelector("[data-source-receipt]"),at.sub[0]);for(const input of body.querySelectorAll('input:not([type="search"]), select'))input.disabled=true;for(const button of body.querySelectorAll("button:not([data-to]):not([data-store]):not([data-live-action])"))button.disabled=true;filter();body.scrollTop=same?top:drawn?.startsWith(key+"/")?scrolls.get(key)||0:0;if(focus?.id){const next=document.getElementById(focus.id);next?.focus({preventScroll:true});if(caret!=null)next?.setSelectionRange(caret,caret)}else if(!same)$("panel-title").focus({preventScroll:true});drawn=key;const going=rows.some(a=>a.bucket==="connecting");if(going&&!linking){let tick=0;linking=setInterval(()=>{if(++tick%3===0)void refreshApps().then(()=>{if(at)draw()});else draw()},1e3)}else if(!going&&linking){clearInterval(linking);linking=null}}const refreshVisibleApps=()=>{if(at&&!linking&&document.visibilityState==="visible")void refreshApps().then(()=>{if(at&&!linking)draw()})};const statusTimer=setInterval(refreshVisibleApps,3e3);document.addEventListener("visibilitychange",refreshVisibleApps);el.addEventListener("click",e=>{const b=e.target.closest("button");if(!b||b.disabled)return;const d=b.dataset;if(b.id==="panel-back"||d.to!=null){ui.ask=null;ui.q="";open(d.to);return}if(b.id==="panel-close"){open("");return}if("store"in d)openStore(d.store)});el.addEventListener("input",e=>{if(e.target.id==="panel-q"){ui.q=e.target.value;filter()}});observeDemo(draw);addEventListener("pagehide",()=>{clearInterval(linking);clearInterval(statusTimer);document.removeEventListener("visibilitychange",refreshVisibleApps);timers.forEach(clearTimeout)});return{show(panel,sub=[]){const fresh=!at||at.panel!==panel;if(fresh){ui.q="";ui.ask=null;scrolls.clear()}at={panel,sub};el.hidden=false;draw();refreshVisibleApps()},hide(){if(!at)return;at=null;drawn=null;el.hidden=true;ui.ask=null;ui.done=null;clearInterval(linking);linking=null},get back(){return at?$("panel-back").hidden?"":$("panel-back").dataset.to:null},refresh:draw}}
|
|
35
|
+
<div class="p-actions"><button class="text-button" type="button" data-store="mod/${esc(m.id)}">See it in the Mods store</button></div>`}}function filter(){const q=ui.q.trim().toLowerCase(),list=body.querySelector("[data-filter]");if(!list)return;let shown=0;for(const row of list.children){const hit=!q||row.dataset.name.includes(q);row.hidden=!hit;shown+=hit}list.hidden=!shown;const none=body.querySelector("[data-none]");if(none)none.hidden=shown>0}function draw(){if(!at)return;demo=loadDemo();rows=connectionRows(demo,apps);const key=[at.panel,...at.sub].join("/"),v={ais:aisView,apps:appsView,mods:modsView}[at.panel](at.sub);if(v.to!=null){open(v.to,true);return}const same=key===drawn,top=body.scrollTop,focus=same&&body.contains(document.activeElement)?document.activeElement:null;if(same&&focus?.closest("[data-connection-panel]")&&focus.matches("input,textarea,select"))return;const caret=focus?.type==="search"?focus.selectionStart:null;if(!same&&drawn)scrolls.set(drawn,top);$("panel-title").textContent=v.title;$("panel-back").hidden=!v.back;$("panel-back").dataset.to=v.back||"";body.innerHTML=v.html;tools.innerHTML=v.tools||"";tools.hidden=!v.tools;if(at.panel==="apps"&&at.sub[0]&&at.sub[0]!=="all")sourceDetails(body.querySelector("[data-source-receipt]"),at.sub[0]);for(const input of body.querySelectorAll('input:not([type="search"]), select'))if(!input.closest("[data-connection-panel]"))input.disabled=true;for(const button of body.querySelectorAll("button:not([data-to]):not([data-store]):not([data-live-action]):not([data-source-connect])"))if(!button.closest("[data-connection-panel]"))button.disabled=true;filter();body.scrollTop=same?top:drawn?.startsWith(key+"/")?scrolls.get(key)||0:0;if(focus?.id){const next=document.getElementById(focus.id);next?.focus({preventScroll:true});if(caret!=null)next?.setSelectionRange(caret,caret)}else if(!same)$("panel-title").focus({preventScroll:true});drawn=key;const going=rows.some(a=>a.bucket==="connecting");if(going&&!linking){let tick=0;linking=setInterval(()=>{if(++tick%3===0)void refreshApps().then(()=>{if(at)draw()});else draw()},1e3)}else if(!going&&linking){clearInterval(linking);linking=null}}const refreshVisibleApps=()=>{if(at&&!linking&&document.visibilityState==="visible")void refreshApps().then(()=>{if(at&&!linking)draw()})};const statusTimer=setInterval(refreshVisibleApps,3e3);document.addEventListener("visibilitychange",refreshVisibleApps);el.addEventListener("click",e=>{const b=e.target.closest("button");if(!b||b.disabled)return;const d=b.dataset;if(b.id==="panel-back"||d.to!=null){ui.ask=null;ui.q="";open(d.to);return}if(b.id==="panel-close"){open("");return}if(d.sourceConnect){void connectSource?.(d.sourceConnect);return}if("store"in d)openStore(d.store)});el.addEventListener("input",e=>{if(e.target.id==="panel-q"){ui.q=e.target.value;filter()}});observeDemo(draw);addEventListener("pagehide",()=>{clearInterval(linking);clearInterval(statusTimer);document.removeEventListener("visibilitychange",refreshVisibleApps);timers.forEach(clearTimeout)});return{show(panel,sub=[]){const fresh=!at||at.panel!==panel;if(fresh){ui.q="";ui.ask=null;scrolls.clear()}at={panel,sub};el.hidden=false;draw();refreshVisibleApps()},hide(){if(!at)return;at=null;drawn=null;el.hidden=true;ui.ask=null;ui.done=null;clearInterval(linking);linking=null},get back(){return at?$("panel-back").hidden?"":$("panel-back").dataset.to:null},refresh:draw}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const renderStarted=performance.now();const el=(tag,text,parent)=>{const node=document.createElement(tag);if(text!==void 0)node.textContent=text;parent?.appendChild(node);return node};const panel=el("details",void 0,document.body);panel.className="zx-vault";panel.open=false;if(window.parent!==window)panel.hidden=true;const summary=el("summary","Loading your local Vault\u2026",panel);const number=n=>Number(n).toLocaleString();try{const response=await fetch("snapshot.json");if(!response.ok)throw new Error("Vault unavailable");const data=await response.json();const measured=data.portrait?.state==="measured-subset";summary.textContent=`${data.inventory?.label??"Current Vault"} \xB7 ${number(data.inventory?.storedRecords??data.totalItems)} ${data.inventory?"stored records":"mapped records"}`;el("p",`
|
|
1
|
+
const renderStarted=performance.now();const el=(tag,text,parent)=>{const node=document.createElement(tag);if(text!==void 0)node.textContent=text;parent?.appendChild(node);return node};const panel=el("details",void 0,document.body);panel.className="zx-vault";panel.open=false;if(window.parent!==window)panel.hidden=true;const summary=el("summary","Loading your local Vault\u2026",panel);const number=n=>Number(n).toLocaleString();try{const response=await fetch("snapshot.json");if(!response.ok)throw new Error("Vault unavailable");const data=await response.json();const sample=data.sampleData===true;const measured=data.portrait?.state==="measured-subset";summary.textContent=`${data.inventory?.label??"Current Vault"} \xB7 ${number(data.inventory?.storedRecords??data.totalItems)} ${data.inventory?"stored records":"mapped records"}`;el("p",`Mapped records: ${number(data.portrait?.mappedThings??data.totalItems)}. Stored counts include revisions and provider cache entries.`,panel);el("p",`${data.productVersion?`Zortex ${data.productVersion} \xB7 `:""}${data.status==="live-local"?"Vault records":data.status==="empty"?"No local records":"Vault unavailable"}`,panel);el("p",measured?"Privacy view: local cached vectors and source-proven authorship determine measured dimensions. Missing contacts and topic taxonomy remain unknown; their geometry is layout only. No new embeddings are requested.":"Privacy view: anonymized record nodes, sources and record timestamps. Semantic portrait, authorship and relationships are unverified; geometry is layout only.",panel);el("p",`Latest mapped record: ${data.latest??"Not available"}`,panel);el("h2",`${data.coverage.length} directory, product candidate, registered or observed sources`,panel);el("p","Connection status and local records are separate evidence. Sources without a registered status remain unverified.",panel);const table=el("table",void 0,panel);table.setAttribute("aria-label","Local source coverage");const head=el("tr",void 0,el("thead",void 0,table));el("th","Source / evidence",head);el("th","Records",head);const body=el("tbody",void 0,table);for(const source of data.coverage){const row=el("tr",void 0,body),name=el("td",source.source,row);el("span",`Connection: ${source.connectionState}`,name).className="zx-state";el("span",`Data: ${source.dataState.replaceAll("_"," ")}`,name).className="zx-state";if(source.readiness)el("span",`Actions ready \xB7 ${source.readiness.operation.state==="not-run"?"read not run":source.readiness.operation.returned===void 0?"action succeeded":`read returned ${source.readiness.operation.returned}`}`,name).className="zx-state";el("td",number(source.items),row);row.title=`First: ${source.first??"unknown"}; latest: ${source.latest??"unknown"}`}const days=[...new Set(data.sourceDays.map(row=>row.day))].sort();if(days.length){const label=el("label","Records by date",panel),range=el("input",void 0,label);range.type="range";range.min="0";range.max=String(days.length-1);range.value=range.max;const result=el("p","",panel);result.setAttribute("aria-live","polite");const show=()=>{const day=days[Number(range.value)],rows=data.sourceDays.filter(row=>row.day===day);range.setAttribute("aria-valuetext",day);result.textContent=`${day}: ${number(rows.reduce((sum,row)=>sum+row.items,0))} records \xB7 ${rows.map(row=>`${row.source} ${number(row.items)}`).join(" \xB7 ")}`};range.addEventListener("input",show);show()}const refresh=el("button","Refresh local counts",panel);refresh.type="button";refresh.addEventListener("click",()=>location.reload());if(data.status==="live-local"&&!sample){await new Promise((resolve,reject)=>{const started=performance.now();const check=()=>{if(window.galaxy?.ready&&document.getElementById("universe")?.classList.contains("ready"))return resolve();if(performance.now()-started>3e4)return reject(new Error("Renderer unavailable"));setTimeout(check,100)};check()});await fetch("loaded",{method:"POST",headers:{"X-Zortex-Galaxy":document.querySelector('meta[name="zortex-galaxy-token"]')?.content||"","X-Zortex-Render-Ms":String(Math.round(performance.now()-renderStarted))}})}}catch(error){el("p",error.message==="Renderer unavailable"?"Local counts loaded; the original Galaxy renderer did not become ready.":"Vault data could not be read. Please refresh to try again.",panel).setAttribute("role","status")}
|