writetrack 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { S as SessionAnalysis } from './analysis-types-CZ2xI-JI.js';
2
- import './index-ChEZuqzG.js';
1
+ import { S as SessionAnalysis } from './analysis-types-zqWj2pHM.js';
2
+ import './index-Cy91q_po.js';
3
3
 
4
4
  /**
5
5
  * Server-side verification of WASM analysis output signatures.
package/dist/esm/viz.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WriteTrackDataSchema } from './index-ChEZuqzG.js';
2
- import { S as SessionAnalysis, a as SessionReport, d as IntegrityProof } from './analysis-types-CZ2xI-JI.js';
1
+ import { W as WriteTrackDataSchema } from './index-Cy91q_po.js';
2
+ import { S as SessionAnalysis, a as SessionReport, d as IntegrityProof } from './analysis-types-zqWj2pHM.js';
3
3
 
4
4
  /**
5
5
  * BaseChart — abstract web component base class for WriteTrack visualizations.
package/dist/esm/viz.js CHANGED
@@ -35,9 +35,9 @@ var ft=`:host {
35
35
  }
36
36
 
37
37
  /* Force light text on dark tooltips regardless of chart theme */
38
- [aria-label="tip"] { color: #fafafa; }`,S={fill:"#1a1a1d",stroke:"#27272a",textPadding:6,fontSize:11,fontFamily:"'JetBrains Mono', ui-monospace, monospace"};var g=class extends HTMLElement{constructor(){super();this._data=null;this._resizeObserver=null;this._resizeRaf=null;this.e=null;this.s=!0;this.a=!1;this.o=!1;this.shadow=this.attachShadow({mode:"open"});let a=document.createElement("style");a.textContent=this.getStylesheet(),this.shadow.appendChild(a),this.container=document.createElement("div"),this.container.className="wt-chart",this.shadow.appendChild(this.container)}static get observedAttributes(){return["data","theme","label"]}getStylesheet(){return ft}connectedCallback(){typeof ResizeObserver<"u"&&(this.s=!0,this._resizeObserver=new ResizeObserver(()=>{if(this.s){this.s=!1;return}this._data&&(this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=requestAnimationFrame(()=>{this._resizeRaf=null,this.onResize()}))}),this._resizeObserver.observe(this.container)),this.i(),typeof MutationObserver<"u"&&(this.e=new MutationObserver(()=>{this.i()}),this.e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),document.body&&this.e.observe(document.body,{attributes:!0,attributeFilter:["data-theme"]}))}disconnectedCallback(){this.destroy()}attributeChangedCallback(a,e,t){if(a==="data"&&t)try{let s=JSON.parse(t);this.setData(s)}catch(s){console.warn("[WriteTrack] BaseChart: invalid JSON in data attribute:",s)}a==="theme"&&this._data&&this.a&&this.render()}setData(a){this._data=a,this.render()}getData(){return this._data}get hasRendered(){return this.a}replaceChart(...a){for(let e of a)if(e instanceof SVGElement){e.setAttribute("role","img");let t=this.getAttribute("label")??this.tagName.toLowerCase().replace("wt-","").replace(/-/g," ")+" chart";e.setAttribute("aria-label",t)}this.container.replaceChildren(...a),this.a=!0,this.dispatchEvent(new CustomEvent("wt-render",{bubbles:!1}))}showEmptyState(a="No data"){let e=document.createElement("div");e.className="wt-empty",e.textContent=a,e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:11px;color:var(--wt-color-text-muted,#a1a1aa);",this.container.replaceChildren(e),this.a=!1}destroy(){this._resizeRaf&&(cancelAnimationFrame(this._resizeRaf),this._resizeRaf=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this.e&&(this.e.disconnect(),this.e=null),this.container.replaceChildren(),this._data=null,this.a=!1}onResize(){this.render()}static register(){customElements.get(this.tagName)||customElements.define(this.tagName,this)}i(){if(this.hasAttribute("theme")&&!this.o)return;let a=this.parentElement;for(;a;){let e=a.getAttribute("data-theme");if(e){this.shadow.host.setAttribute("theme",e),this.o=!0;return}a=a.parentElement}this.o&&(this.shadow.host.removeAttribute("theme"),this.o=!1)}};g.tagName="wt-base-chart";import*as $ from"@observablehq/plot";var Dt=5;function gt(o){var s;let r=(((s=o.session)==null?void 0:s.events)??[]).filter(n=>n.type==="keydown"&&n.flightTime!=null&&n.flightTime>0);if(r.length<2)return[[],[]];let a=o.session.sessionStartTime,e=[],t=[];for(let n=0;n<r.length;n++){let i=Math.max(0,n-Dt+1),c=0,l=0;for(let u=i;u<=n;u++)c+=r[u].flightTime,l++;let d=c/l,m=Math.round(6e4/d);e.push(Math.round((r[n].timestamp-a)/1e3*100)/100),t.push(m)}return[e,t]}var L=class L extends g{connectedCallback(){super.connectedCallback();let r=getComputedStyle(this);!this.style.display&&r.display==="inline"&&(this.style.display="inline-block"),!this.style.width&&(r.width==="auto"||r.width==="0px")&&(this.style.width="200px"),!this.style.height&&(r.height==="auto"||r.height==="0px")&&(this.style.height="40px")}render(){if(!this._data)return;let[r,a]=gt(this._data);if(r.length===0){this.showEmptyState("No data");return}let e=r.map((i,c)=>({time:i,speed:a[c]})),t=this.getBoundingClientRect(),s=Math.max(t.width||200,50),n=Math.max(t.height||40,20);try{let i=$.plot({width:s,height:n,axis:null,x:{axis:null},y:{axis:null},marks:[$.areaY(e,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.1}),$.lineY(e,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1.5})],style:{background:"transparent",overflow:"visible"},margin:0,marginTop:2,marginBottom:2,marginLeft:0,marginRight:0});this.replaceChart(i)}catch(i){console.warn("[WriteTrack] Sparkline render failed:",i)}}static create(r,a){L.register();let e=document.createElement(L.tagName);return r.appendChild(e),e.setData(a),e}};L.tagName="wt-sparkline";var lt=L;import*as C from"@observablehq/plot";function z(o){var t,s,n;let r=(s=(t=o.temporalPatterns)==null?void 0:t.metrics)==null?void 0:s.speedTimeline;if(!((n=r==null?void 0:r.timestamps)!=null&&n.length))return[];let a=Math.min(r.timestamps.length,r.values.length),e=[];for(let i=0;i<a;i++)e.push({time:r.timestamps[i]/1e3,speed:r.values[i]});return e}var F=class extends g{render(){if(!this._data)return;let r=z(this._data);if(r.length===0){this.showEmptyState("No speed data");return}let a=this.clientWidth||640,e=this.clientHeight||200;try{let t=C.plot({width:a,height:e,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Speed (CPM)",grid:!0},marks:[C.areaY(r,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.15,curve:"natural"}),C.lineY(r,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2,curve:"natural"}),C.ruleY([0],{stroke:"var(--wt-color-border, #27272a)"}),C.tip(r,C.pointerX({x:"time",y:"speed",title:s=>`${s.time.toFixed(1)}s \u2014 ${Math.round(s.speed)} CPM`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] SpeedTimeline render failed:",t)}}};F.tagName="wt-speed-timeline";import*as P from"@observablehq/plot";var ct={typing:"var(--wt-color-primary, #fbbf24)",paste:"var(--wt-color-secondary, #22d3ee)",pause:"var(--wt-color-text-muted, #a1a1aa)",tabAway:"#ef4444",autocomplete:"#a78bfa",navigating:"#34d399"};function H(o){let r=o.sessionTimeline;return r!=null&&r.length?r.map(a=>({start:a.startTime/1e3,end:a.endTime/1e3,type:a.type,color:ct[a.type]??"#666"})):[]}function yt(o){var a,e;return(((e=(a=o.contentOrigin)==null?void 0:a.metrics)==null?void 0:e.pasteEvents)??[]).map(t=>({time:t.timestamp/1e3,chars:t.characterCount,source:t.source}))}var G=class extends g{render(){if(!this._data)return;let r=H(this._data);if(r.length===0){this.showEmptyState("No session data");return}let a=yt(this._data),e=[P.barX(r,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5}),P.tip(r,P.pointer({x:n=>(n.start+n.end)/2,y:()=>"Activity",title:n=>`${n.type} \u2014 ${(n.end-n.start).toFixed(1)}s`,...S}))];a.length&&e.push(P.dot(a,{x:"time",y:()=>"Activity",r:"chars",fill:ct.paste,fillOpacity:.7,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1}));let t=this.clientWidth||640,s=this.clientHeight||80;try{let n=P.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null,padding:.3},marks:e,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(n)}catch(n){console.warn("[WriteTrack] CompositionTimeline render failed:",n)}}};G.tagName="wt-composition-timeline";import*as j from"@observablehq/plot";var Ot=10;function Y(o){var n,i,c,l,d;let r=(i=(n=o.timingAuthenticity)==null?void 0:n.metrics)==null?void 0:i.timingOverTime;if(!((c=r==null?void 0:r.timestamps)!=null&&c.length))return[];let a=((l=r.series)==null?void 0:l.meanDwell)??[],e=((d=r.series)==null?void 0:d.meanFlight)??[];if(!a.length||!e.length)return[];let t=[],s=Math.min(r.timestamps.length,a.length,e.length);for(let m=0;m<s;m++)a[m]!=null&&e[m]!=null&&t.push({dwell:a[m],flight:e[m]});return t}var V=class extends g{render(){if(!this._data)return;let r=Y(this._data);if(r.length<Ot){this.showEmptyState("Insufficient timing data");return}let a=this.clientWidth||400,e=Math.min(a,this.clientHeight||400);try{let t=j.plot({width:a,height:e,marginLeft:50,marginBottom:35,x:{label:"Dwell (ms)",grid:!0},y:{label:"Flight (ms)",grid:!0},marks:[j.dot(r,{x:"dwell",y:"flight",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.35,r:3,stroke:"var(--wt-color-primary, #fbbf24)",strokeOpacity:.6,strokeWidth:.5})],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] RhythmHeatmap render failed:",t)}}};V.tagName="wt-rhythm-heatmap";import*as _ from"@observablehq/plot";function bt(o){var a,e,t;let r=(e=(a=o.temporalPatterns)==null?void 0:a.metrics)==null?void 0:e.pauseDistribution;return(t=r==null?void 0:r.histogram)!=null&&t.length?r.histogram.map(s=>({start:s.binStart,end:s.binEnd,count:s.count})):[]}var q=class extends g{render(){if(!this._data)return;let r=bt(this._data);if(r.length===0){this.showEmptyState("No pause data");return}let a=this.clientWidth||640,e=this.clientHeight||200;try{let t=_.plot({width:a,height:e,marginLeft:50,marginBottom:35,x:{label:"Pause Duration (ms)"},y:{label:"Count",grid:!0},marks:[_.rectY(r,{x1:"start",x2:"end",y:"count",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.8,inset:.5}),_.ruleY([0])],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] PauseDistribution render failed:",t)}}};q.tagName="wt-pause-distribution";import*as E from"@observablehq/plot";var K=/^.$/u;function v(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Q(o){var i,c;let r=(i=o.session)==null?void 0:i.events;if(!(r!=null&&r.length))return[];let a=r.filter(l=>l.type==="keydown");if(a.length===0)return[];let e=a[0].timestamp,t=[];for(let l of a)l.key==="Backspace"||l.key==="Delete"?t.push({timestamp:l.timestamp,type:"key",delta:-1}):K.test(l.key)&&t.push({timestamp:l.timestamp,type:"key",delta:1});for(let l of((c=o.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?t.push({timestamp:l.timestamp,type:"paste",delta:l.length,pasteLength:l.length}):l.type==="cut"&&t.push({timestamp:l.timestamp,type:"cut",delta:-l.length,cutLength:l.length});t.sort((l,d)=>l.timestamp-d.timestamp);let s=[],n=0;for(let l of t){let d=(l.timestamp-e)/1e3;l.type==="paste"?(s.push({time:d,chars:n,isPaste:!1,isCut:!1}),n+=l.delta,s.push({time:d+.001,chars:n,isPaste:!0,isCut:!1,pasteLength:l.pasteLength})):l.type==="cut"?(s.push({time:d,chars:n,isPaste:!1,isCut:!1}),n=Math.max(0,n+l.delta),s.push({time:d+.001,chars:n,isPaste:!1,isCut:!0,cutLength:l.cutLength})):(n=Math.max(0,n+l.delta),s.push({time:d,chars:n,isPaste:!1,isCut:!1}))}return s}var U=class extends g{render(){if(!this._data)return;let r=Q(this._data);if(r.length===0){this.showEmptyState("No keystroke data");return}let a=r.filter(n=>n.isPaste),e=r.filter(n=>n.isCut),t=this.clientWidth||640,s=this.clientHeight||200;try{let n=[E.lineY(r,{x:"time",y:"chars",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2})];a.length>0&&n.push(E.text(a,{x:"time",y:"chars",text:c=>`+${c.pasteLength}`,fill:"var(--wt-color-secondary, #22d3ee)",fontSize:10,dy:-8})),e.length>0&&n.push(E.text(e,{x:"time",y:"chars",text:c=>`\u2212${c.cutLength}`,fill:"#ef4444",fontSize:10,dy:12})),n.push(E.tip(r,E.pointerX({x:"time",y:"chars",title:c=>{let l=`${c.time.toFixed(1)}s \u2014 ${c.chars} chars`;return c.isPaste?`${l}
38
+ [aria-label="tip"] { color: #fafafa; }`,S={fill:"#1a1a1d",stroke:"#27272a",textPadding:6,fontSize:11,fontFamily:"'JetBrains Mono', ui-monospace, monospace"};var g=class extends HTMLElement{constructor(){super();this._data=null;this._resizeObserver=null;this._resizeRaf=null;this.e=null;this.s=!0;this.a=!1;this.o=!1;this.shadow=this.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=this.getStylesheet(),this.shadow.appendChild(r),this.container=document.createElement("div"),this.container.className="wt-chart",this.shadow.appendChild(this.container)}static get observedAttributes(){return["data","theme","label"]}getStylesheet(){return ft}connectedCallback(){typeof ResizeObserver<"u"&&(this.s=!0,this._resizeObserver=new ResizeObserver(()=>{if(this.s){this.s=!1;return}this._data&&(this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=requestAnimationFrame(()=>{this._resizeRaf=null,this.onResize()}))}),this._resizeObserver.observe(this.container)),this.i(),typeof MutationObserver<"u"&&(this.e=new MutationObserver(()=>{this.i()}),this.e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),document.body&&this.e.observe(document.body,{attributes:!0,attributeFilter:["data-theme"]}))}disconnectedCallback(){this.destroy()}attributeChangedCallback(r,a,t){if(r==="data"&&t)try{let s=JSON.parse(t);this.setData(s)}catch(s){console.warn("[WriteTrack] BaseChart: invalid JSON in data attribute:",s)}r==="theme"&&this._data&&this.a&&this.render()}setData(r){this._data=r,this.render()}getData(){return this._data}get hasRendered(){return this.a}replaceChart(...r){for(let a of r)if(a instanceof SVGElement){a.setAttribute("role","img");let t=this.getAttribute("label")??this.tagName.toLowerCase().replace("wt-","").replace(/-/g," ")+" chart";a.setAttribute("aria-label",t)}this.container.replaceChildren(...r),this.a=!0,this.dispatchEvent(new CustomEvent("wt-render",{bubbles:!1}))}showEmptyState(r="No data"){let a=document.createElement("div");a.className="wt-empty",a.textContent=r,a.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:11px;color:var(--wt-color-text-muted,#a1a1aa);",this.container.replaceChildren(a),this.a=!1}destroy(){this._resizeRaf&&(cancelAnimationFrame(this._resizeRaf),this._resizeRaf=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this.e&&(this.e.disconnect(),this.e=null),this.container.replaceChildren(),this._data=null,this.a=!1}onResize(){this.render()}static register(){customElements.get(this.tagName)||customElements.define(this.tagName,this)}i(){if(this.hasAttribute("theme")&&!this.o)return;let r=this.parentElement;for(;r;){let a=r.getAttribute("data-theme");if(a){this.shadow.host.setAttribute("theme",a),this.o=!0;return}r=r.parentElement}this.o&&(this.shadow.host.removeAttribute("theme"),this.o=!1)}};g.tagName="wt-base-chart";import*as $ from"@observablehq/plot";var Dt=5;function gt(n){var s;let e=(((s=n.session)==null?void 0:s.events)??[]).filter(o=>o.type==="keydown"&&o.flightTime!=null&&o.flightTime>0);if(e.length<2)return[[],[]];let r=n.session.sessionStartTime,a=[],t=[];for(let o=0;o<e.length;o++){let i=Math.max(0,o-Dt+1),c=0,l=0;for(let u=i;u<=o;u++)c+=e[u].flightTime,l++;let d=c/l,m=Math.round(6e4/d);a.push(Math.round((e[o].timestamp-r)/1e3*100)/100),t.push(m)}return[a,t]}var L=class L extends g{connectedCallback(){super.connectedCallback();let e=getComputedStyle(this);!this.style.display&&e.display==="inline"&&(this.style.display="inline-block"),!this.style.width&&(e.width==="auto"||e.width==="0px")&&(this.style.width="200px"),!this.style.height&&(e.height==="auto"||e.height==="0px")&&(this.style.height="40px")}render(){if(!this._data)return;let[e,r]=gt(this._data);if(e.length===0){this.showEmptyState("No data");return}let a=e.map((i,c)=>({time:i,speed:r[c]})),t=this.getBoundingClientRect(),s=Math.max(t.width||200,50),o=Math.max(t.height||40,20);try{let i=$.plot({width:s,height:o,axis:null,x:{axis:null},y:{axis:null},marks:[$.areaY(a,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.1}),$.lineY(a,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1.5})],style:{background:"transparent",overflow:"visible"},margin:0,marginTop:2,marginBottom:2,marginLeft:0,marginRight:0});this.replaceChart(i)}catch(i){console.warn("[WriteTrack] Sparkline render failed:",i)}}static create(e,r){L.register();let a=document.createElement(L.tagName);return e.appendChild(a),a.setData(r),a}};L.tagName="wt-sparkline";var lt=L;import*as C from"@observablehq/plot";function F(n){var t,s,o;let e=(s=(t=n.temporalPatterns)==null?void 0:t.metrics)==null?void 0:s.speedTimeline;if(!((o=e==null?void 0:e.timestamps)!=null&&o.length))return[];let r=Math.min(e.timestamps.length,e.values.length),a=[];for(let i=0;i<r;i++)a.push({time:e.timestamps[i]/1e3,speed:e.values[i]});return a}var z=class extends g{render(){if(!this._data)return;let e=F(this._data);if(e.length===0){this.showEmptyState("No speed data");return}let r=this.clientWidth||640,a=this.clientHeight||200;try{let t=C.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Speed (CPM)",grid:!0},marks:[C.areaY(e,{x:"time",y:"speed",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.15,curve:"natural"}),C.lineY(e,{x:"time",y:"speed",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2,curve:"natural"}),C.ruleY([0],{stroke:"var(--wt-color-border, #27272a)"}),C.tip(e,C.pointerX({x:"time",y:"speed",title:s=>`${s.time.toFixed(1)}s \u2014 ${Math.round(s.speed)} CPM`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] SpeedTimeline render failed:",t)}}};z.tagName="wt-speed-timeline";import*as P from"@observablehq/plot";var ct={typing:"var(--wt-color-primary, #fbbf24)",paste:"var(--wt-color-secondary, #22d3ee)",pause:"var(--wt-color-text-muted, #a1a1aa)",tabAway:"#ef4444",autocomplete:"#a78bfa",navigating:"#34d399"};function H(n){let e=n.sessionTimeline;return e!=null&&e.length?e.map(r=>({start:r.startTime/1e3,end:r.endTime/1e3,type:r.type,color:ct[r.type]??"#666"})):[]}function yt(n){var r,a;return(((a=(r=n.contentOrigin)==null?void 0:r.metrics)==null?void 0:a.pasteEvents)??[]).map(t=>({time:t.timestamp/1e3,chars:t.characterCount,source:t.source}))}var G=class extends g{render(){if(!this._data)return;let e=H(this._data);if(e.length===0){this.showEmptyState("No session data");return}let r=yt(this._data),a=[P.barX(e,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5}),P.tip(e,P.pointer({x:o=>(o.start+o.end)/2,y:()=>"Activity",title:o=>`${o.type} \u2014 ${(o.end-o.start).toFixed(1)}s`,...S}))];r.length&&a.push(P.dot(r,{x:"time",y:()=>"Activity",r:"chars",fill:ct.paste,fillOpacity:.7,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1}));let t=this.clientWidth||640,s=this.clientHeight||80;try{let o=P.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null,padding:.3},marks:a,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(o)}catch(o){console.warn("[WriteTrack] CompositionTimeline render failed:",o)}}};G.tagName="wt-composition-timeline";import*as j from"@observablehq/plot";var Ot=10;function Y(n){var o,i,c,l,d;let e=(i=(o=n.timingAuthenticity)==null?void 0:o.metrics)==null?void 0:i.timingOverTime;if(!((c=e==null?void 0:e.timestamps)!=null&&c.length))return[];let r=((l=e.series)==null?void 0:l.meanDwell)??[],a=((d=e.series)==null?void 0:d.meanFlight)??[];if(!r.length||!a.length)return[];let t=[],s=Math.min(e.timestamps.length,r.length,a.length);for(let m=0;m<s;m++)r[m]!=null&&a[m]!=null&&t.push({dwell:r[m],flight:a[m]});return t}var V=class extends g{render(){if(!this._data)return;let e=Y(this._data);if(e.length<Ot){this.showEmptyState("Insufficient timing data");return}let r=this.clientWidth||400,a=Math.min(r,this.clientHeight||400);try{let t=j.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Dwell (ms)",grid:!0},y:{label:"Flight (ms)",grid:!0},marks:[j.dot(e,{x:"dwell",y:"flight",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.35,r:3,stroke:"var(--wt-color-primary, #fbbf24)",strokeOpacity:.6,strokeWidth:.5})],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] RhythmHeatmap render failed:",t)}}};V.tagName="wt-rhythm-heatmap";import*as _ from"@observablehq/plot";function bt(n){var r,a,t;let e=(a=(r=n.temporalPatterns)==null?void 0:r.metrics)==null?void 0:a.pauseDistribution;return(t=e==null?void 0:e.histogram)!=null&&t.length?e.histogram.map(s=>({start:s.binStart,end:s.binEnd,count:s.count})):[]}var q=class extends g{render(){if(!this._data)return;let e=bt(this._data);if(e.length===0){this.showEmptyState("No pause data");return}let r=this.clientWidth||640,a=this.clientHeight||200;try{let t=_.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Pause Duration (ms)"},y:{label:"Count",grid:!0},marks:[_.rectY(e,{x1:"start",x2:"end",y:"count",fill:"var(--wt-color-primary, #fbbf24)",fillOpacity:.8,inset:.5}),_.ruleY([0])],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] PauseDistribution render failed:",t)}}};q.tagName="wt-pause-distribution";import*as E from"@observablehq/plot";var K=/^.$/u;function v(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Q(n){var i,c;let e=(i=n.session)==null?void 0:i.events;if(!(e!=null&&e.length))return[];let r=e.filter(l=>l.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[];for(let l of r)l.key==="Backspace"||l.key==="Delete"?t.push({timestamp:l.timestamp,type:"key",delta:-1}):K.test(l.key)&&t.push({timestamp:l.timestamp,type:"key",delta:1});for(let l of((c=n.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?t.push({timestamp:l.timestamp,type:"paste",delta:l.length,pasteLength:l.length}):l.type==="cut"&&t.push({timestamp:l.timestamp,type:"cut",delta:-l.length,cutLength:l.length});t.sort((l,d)=>l.timestamp-d.timestamp);let s=[],o=0;for(let l of t){let d=(l.timestamp-a)/1e3;l.type==="paste"?(s.push({time:d,chars:o,isPaste:!1,isCut:!1}),o+=l.delta,s.push({time:d+.001,chars:o,isPaste:!0,isCut:!1,pasteLength:l.pasteLength})):l.type==="cut"?(s.push({time:d,chars:o,isPaste:!1,isCut:!1}),o=Math.max(0,o+l.delta),s.push({time:d+.001,chars:o,isPaste:!1,isCut:!0,cutLength:l.cutLength})):(o=Math.max(0,o+l.delta),s.push({time:d,chars:o,isPaste:!1,isCut:!1}))}return s}var U=class extends g{render(){if(!this._data)return;let e=Q(this._data);if(e.length===0){this.showEmptyState("No keystroke data");return}let r=e.filter(o=>o.isPaste),a=e.filter(o=>o.isCut),t=this.clientWidth||640,s=this.clientHeight||200;try{let o=[E.lineY(e,{x:"time",y:"chars",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:2})];r.length>0&&o.push(E.text(r,{x:"time",y:"chars",text:c=>`+${c.pasteLength}`,fill:"var(--wt-color-secondary, #22d3ee)",fontSize:10,dy:-8})),a.length>0&&o.push(E.text(a,{x:"time",y:"chars",text:c=>`\u2212${c.cutLength}`,fill:"#ef4444",fontSize:10,dy:12})),o.push(E.tip(e,E.pointerX({x:"time",y:"chars",title:c=>{let l=`${c.time.toFixed(1)}s \u2014 ${c.chars} chars`;return c.isPaste?`${l}
39
39
  +${c.pasteLength} pasted`:c.isCut?`${l}
40
- \u2212${c.cutLength} cut`:l},...S})));let i=E.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Characters",grid:!0},marks:n,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(i)}catch(n){console.warn("[WriteTrack] DocumentGrowth render failed:",n)}}};U.tagName="wt-document-growth";import*as A from"@observablehq/plot";function wt(o){var s;let r=(s=o.session)==null?void 0:s.events;if(!(r!=null&&r.length))return[];let a=r.filter(n=>n.type==="keydown");if(a.length===0)return[];let e=a[0].timestamp,t=[];for(let n=0;n<a.length;n++){let i=a[n],c=(i.timestamp-e)/1e3,l=n<a.length-1?(a[n+1].timestamp-e)/1e3:c+(i.dwellTime??50)/1e3,d=i.flightTime??0;t.push({start:c,end:l,flight:d})}return t}var X=class extends g{render(){if(!this._data)return;let r=wt(this._data);if(r.length===0){this.showEmptyState("No keystroke data");return}let a=this.clientWidth||640,e=this.clientHeight||80;try{let t=A.plot({width:a,height:e,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null},color:{type:"sequential",scheme:"YlOrRd",domain:[0,Math.max(1,r.reduce((s,n)=>n.flight>s?n.flight:s,0))],label:"Flight time (ms)"},marks:[A.rect(r,{x1:"start",x2:"end",y1:()=>0,y2:()=>1,fill:"flight",inset:.5}),A.tip(r,A.pointer({x:s=>(s.start+s.end)/2,y:()=>.5,title:s=>`${s.start.toFixed(1)}s \u2014 ${Math.round(s.flight)}ms flight time`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] DocumentRibbon render failed:",t)}}};X.tagName="wt-document-ribbon";import*as T from"@observablehq/plot";var Lt=null;function vt(){return Lt}function xt(o,r,a,e){let t=o.length;if(t<=r||r<3)return o;let s=vt();if(!s)return o;let n=new Float64Array(t),i=new Float64Array(t);for(let d=0;d<t;d++)n[d]=a(o[d]),i[d]=e(o[d]);let c=s.lttb_downsample(n,i,r);if(c.length===0)return o;let l=new Array(c.length);for(let d=0;d<c.length;d++)l[d]=o[c[d]];return l}var kt=2e3;function Z(o){var i,c;let r=(i=o.session)==null?void 0:i.events;if(!(r!=null&&r.length))return{keystrokes:[],pastes:[],cuts:[]};let a=r.filter(l=>l.type==="keydown"&&l.cursorPosition!=null);if(a.length===0)return{keystrokes:[],pastes:[],cuts:[]};let e=a[0].timestamp,t=a.map(l=>({time:(l.timestamp-e)/1e3,position:l.cursorPosition})),s=[],n=[];for(let l of((c=o.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?s.push({time:Math.max(0,(l.timestamp-e)/1e3),position:l.position}):l.type==="cut"&&n.push({time:Math.max(0,(l.timestamp-e)/1e3),position:l.position});return{keystrokes:t,pastes:s,cuts:n}}var J=class extends g{render(){if(!this._data)return;let r=Z(this._data);if(r.keystrokes.length===0){this.showEmptyState("No cursor position data");return}let a=xt(r.keystrokes,kt,i=>i.time,i=>i.position),{pastes:e,cuts:t}=r,s=this.clientWidth||640,n=this.clientHeight||200;try{let i=[T.line(a,{x:"time",y:"position",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1,strokeOpacity:.5}),T.dot(a,{x:"time",y:"position",fill:"var(--wt-color-primary, #fbbf24)",r:2})];e.length>0&&i.push(T.dot(e,{x:"time",y:"position",fill:"var(--wt-color-secondary, #22d3ee)",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),t.length>0&&i.push(T.dot(t,{x:"time",y:"position",fill:"#f97316",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),i.push(T.tip(a,T.pointerX({x:"time",y:"position",title:l=>`${l.time.toFixed(1)}s \u2014 position ${l.position}`,...S})));let c=T.plot({width:s,height:n,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Position",reverse:!0,grid:!0},marks:i,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(c)}catch(i){console.warn("[WriteTrack] EditWaterfall render failed:",i)}}};J.tagName="wt-edit-waterfall";import*as R from"@observablehq/plot";var St={insert:"#22c55e",delete:"#ef4444",paste:"var(--wt-color-secondary, #22d3ee)",cut:"#f97316"},Ct={insert:.6,delete:-.6,paste:0,cut:0};function et(o){var l,d;let r=(l=o.session)==null?void 0:l.events;if(!(r!=null&&r.length))return[];let a=r.filter(m=>m.type==="keydown");if(a.length===0)return[];let e=a[0].timestamp,t=[],s=null,n=0,i=0;function c(){s&&n>0&&t.push({time:i,chars:n,type:s,size:Math.max(4,Math.sqrt(n)*3)}),s=null,n=0}for(let m of a){let u=(m.timestamp-e)/1e3,p=null;m.key==="Backspace"||m.key==="Delete"?p="delete":K.test(m.key)&&(p="insert"),p!==null&&(p!==s&&(c(),s=p,i=u),n++)}c();for(let m of((d=o.session)==null?void 0:d.clipboardEvents)??[])if(m.type==="paste"||m.type==="cut"){let u=Math.max(0,(m.timestamp-e)/1e3),p=m.length;t.push({time:u,chars:p,type:m.type,size:Math.max(4,Math.sqrt(p)*3)})}return t.sort((m,u)=>m.time-u.time),t}var tt=class extends g{render(){if(!this._data)return;let r=et(this._data);if(r.length===0){this.showEmptyState("No edit data");return}let a=this.clientWidth||640,e=this.clientHeight||140;try{let t=R.plot({width:a,height:e,marginLeft:50,marginBottom:35,marginTop:10,x:{label:"Time (s)"},y:{axis:null,domain:[-1.5,1.5]},marks:[R.dot(r,{x:"time",y:n=>Ct[n.type],r:"size",fill:n=>St[n.type],fillOpacity:.65,stroke:n=>St[n.type],strokeWidth:1}),R.tip(r,R.pointer({x:"time",y:n=>Ct[n.type],title:n=>`${n.time.toFixed(1)}s \u2014 ${n.type}, ${n.chars} chars`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t);let s=document.createElement("div");s.className="wt-legend",s.style.cssText="display:flex;gap:12px;padding:6px 0 0;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:10px;color:var(--wt-color-text-muted,#a1a1aa);";for(let[n,i]of[["Insert","#22c55e"],["Delete","#ef4444"],["Paste","#22d3ee"],["Cut","#f97316"]]){let c=document.createElement("span");c.style.cssText="display:flex;align-items:center;gap:4px;";let l=document.createElement("span");l.style.cssText=`width:8px;height:8px;border-radius:50%;background:${i};`,c.appendChild(l),c.appendChild(document.createTextNode(n)),s.appendChild(c)}this.container.appendChild(s)}catch(t){console.warn("[WriteTrack] CorrectionsBubble render failed:",t)}}};tt.tagName="wt-corrections-bubble";var B=`:host {
40
+ \u2212${c.cutLength} cut`:l},...S})));let i=E.plot({width:t,height:s,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Characters",grid:!0},marks:o,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(i)}catch(o){console.warn("[WriteTrack] DocumentGrowth render failed:",o)}}};U.tagName="wt-document-growth";import*as A from"@observablehq/plot";function wt(n){var s;let e=(s=n.session)==null?void 0:s.events;if(!(e!=null&&e.length))return[];let r=e.filter(o=>o.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[];for(let o=0;o<r.length;o++){let i=r[o],c=(i.timestamp-a)/1e3,l=o<r.length-1?(r[o+1].timestamp-a)/1e3:c+(i.dwellTime??50)/1e3,d=i.flightTime??0;t.push({start:c,end:l,flight:d})}return t}var X=class extends g{render(){if(!this._data)return;let e=wt(this._data);if(e.length===0){this.showEmptyState("No keystroke data");return}let r=this.clientWidth||640,a=this.clientHeight||80;try{let t=A.plot({width:r,height:a,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{axis:null},color:{type:"sequential",scheme:"YlOrRd",domain:[0,Math.max(1,e.reduce((s,o)=>o.flight>s?o.flight:s,0))],label:"Flight time (ms)"},marks:[A.rect(e,{x1:"start",x2:"end",y1:()=>0,y2:()=>1,fill:"flight",inset:.5}),A.tip(e,A.pointer({x:s=>(s.start+s.end)/2,y:()=>.5,title:s=>`${s.start.toFixed(1)}s \u2014 ${Math.round(s.flight)}ms flight time`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t)}catch(t){console.warn("[WriteTrack] DocumentRibbon render failed:",t)}}};X.tagName="wt-document-ribbon";import*as T from"@observablehq/plot";var Lt=null;function vt(){return Lt}function xt(n,e,r,a){let t=n.length;if(t<=e||e<3)return n;let s=vt();if(!s)return n;let o=new Float64Array(t),i=new Float64Array(t);for(let d=0;d<t;d++)o[d]=r(n[d]),i[d]=a(n[d]);let c=s.lttb_downsample(o,i,e);if(c.length===0)return n;let l=new Array(c.length);for(let d=0;d<c.length;d++)l[d]=n[c[d]];return l}var kt=2e3;function Z(n){var i,c;let e=(i=n.session)==null?void 0:i.events;if(!(e!=null&&e.length))return{keystrokes:[],pastes:[],cuts:[]};let r=e.filter(l=>l.type==="keydown"&&l.cursorPosition!=null);if(r.length===0)return{keystrokes:[],pastes:[],cuts:[]};let a=r[0].timestamp,t=r.map(l=>({time:(l.timestamp-a)/1e3,position:l.cursorPosition})),s=[],o=[];for(let l of((c=n.session)==null?void 0:c.clipboardEvents)??[])l.type==="paste"?s.push({time:Math.max(0,(l.timestamp-a)/1e3),position:l.position}):l.type==="cut"&&o.push({time:Math.max(0,(l.timestamp-a)/1e3),position:l.position});return{keystrokes:t,pastes:s,cuts:o}}var J=class extends g{render(){if(!this._data)return;let e=Z(this._data);if(e.keystrokes.length===0){this.showEmptyState("No cursor position data");return}let r=xt(e.keystrokes,kt,i=>i.time,i=>i.position),{pastes:a,cuts:t}=e,s=this.clientWidth||640,o=this.clientHeight||200;try{let i=[T.line(r,{x:"time",y:"position",stroke:"var(--wt-color-primary, #fbbf24)",strokeWidth:1,strokeOpacity:.5}),T.dot(r,{x:"time",y:"position",fill:"var(--wt-color-primary, #fbbf24)",r:2})];a.length>0&&i.push(T.dot(a,{x:"time",y:"position",fill:"var(--wt-color-secondary, #22d3ee)",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),t.length>0&&i.push(T.dot(t,{x:"time",y:"position",fill:"#f97316",r:6,stroke:"var(--wt-color-bg, #111113)",strokeWidth:1})),i.push(T.tip(r,T.pointerX({x:"time",y:"position",title:l=>`${l.time.toFixed(1)}s \u2014 position ${l.position}`,...S})));let c=T.plot({width:s,height:o,marginLeft:50,marginBottom:35,x:{label:"Time (s)"},y:{label:"Position",reverse:!0,grid:!0},marks:i,style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(c)}catch(i){console.warn("[WriteTrack] EditWaterfall render failed:",i)}}};J.tagName="wt-edit-waterfall";import*as R from"@observablehq/plot";var St={insert:"#22c55e",delete:"#ef4444",paste:"var(--wt-color-secondary, #22d3ee)",cut:"#f97316"},Ct={insert:.6,delete:-.6,paste:0,cut:0};function et(n){var l,d;let e=(l=n.session)==null?void 0:l.events;if(!(e!=null&&e.length))return[];let r=e.filter(m=>m.type==="keydown");if(r.length===0)return[];let a=r[0].timestamp,t=[],s=null,o=0,i=0;function c(){s&&o>0&&t.push({time:i,chars:o,type:s,size:Math.max(4,Math.sqrt(o)*3)}),s=null,o=0}for(let m of r){let u=(m.timestamp-a)/1e3,p=null;m.key==="Backspace"||m.key==="Delete"?p="delete":K.test(m.key)&&(p="insert"),p!==null&&(p!==s&&(c(),s=p,i=u),o++)}c();for(let m of((d=n.session)==null?void 0:d.clipboardEvents)??[])if(m.type==="paste"||m.type==="cut"){let u=Math.max(0,(m.timestamp-a)/1e3),p=m.length;t.push({time:u,chars:p,type:m.type,size:Math.max(4,Math.sqrt(p)*3)})}return t.sort((m,u)=>m.time-u.time),t}var tt=class extends g{render(){if(!this._data)return;let e=et(this._data);if(e.length===0){this.showEmptyState("No edit data");return}let r=this.clientWidth||640,a=this.clientHeight||140;try{let t=R.plot({width:r,height:a,marginLeft:50,marginBottom:35,marginTop:10,x:{label:"Time (s)"},y:{axis:null,domain:[-1.5,1.5]},marks:[R.dot(e,{x:"time",y:o=>Ct[o.type],r:"size",fill:o=>St[o.type],fillOpacity:.65,stroke:o=>St[o.type],strokeWidth:1}),R.tip(e,R.pointer({x:"time",y:o=>Ct[o.type],title:o=>`${o.time.toFixed(1)}s \u2014 ${o.type}, ${o.chars} chars`,...S}))],style:{background:"transparent",color:"var(--wt-color-text, #fafafa)",fontFamily:"var(--wt-font-data)",fontSize:"11px"}});this.replaceChart(t);let s=document.createElement("div");s.className="wt-legend",s.style.cssText="display:flex;gap:12px;padding:6px 0 0;font-family:var(--wt-font-ui,system-ui,sans-serif);font-size:10px;color:var(--wt-color-text-muted,#a1a1aa);";for(let[o,i]of[["Insert","#22c55e"],["Delete","#ef4444"],["Paste","#22d3ee"],["Cut","#f97316"]]){let c=document.createElement("span");c.style.cssText="display:flex;align-items:center;gap:4px;";let l=document.createElement("span");l.style.cssText=`width:8px;height:8px;border-radius:50%;background:${i};`,c.appendChild(l),c.appendChild(document.createTextNode(o)),s.appendChild(c)}this.container.appendChild(s)}catch(t){console.warn("[WriteTrack] CorrectionsBubble render failed:",t)}}};tt.tagName="wt-corrections-bubble";var B=`:host {
41
41
  /* \u2500\u2500 Surface colors (light default) \u2500\u2500 */
42
42
  --wt-scorecard-bg: #F7F6F2;
43
43
  --wt-scorecard-bg-card: #FFFFFF;
@@ -102,7 +102,7 @@ var ft=`:host {
102
102
  .wt-term:hover {
103
103
  text-decoration-color: var(--wt-scorecard-text-secondary);
104
104
  }
105
- `,qe=(()=>{try{let o=new CSSStyleSheet;return o.replaceSync(B),o}catch{return null}})();var Bt={"--wt-color-bg":"var(--wt-scorecard-bg-card)","--wt-color-surface":"var(--wt-scorecard-bg-detail)","--wt-color-text":"var(--wt-scorecard-text)","--wt-color-text-muted":"var(--wt-scorecard-text-tertiary)","--wt-color-border":"var(--wt-scorecard-border)","--wt-color-primary":"var(--wt-scorecard-chart-accent)","--wt-color-secondary":"var(--wt-scorecard-chart-flagged)","--wt-font-data":"var(--wt-scorecard-font-data)","--wt-font-ui":"var(--wt-scorecard-font-body)"};function Tt(o){for(let[r,a]of Object.entries(Bt))o.style.setProperty(r,a)}var N=new Uint8Array(256),dt=new Uint8Array(256);(function(){let o=1;for(let r=0;r<255;r++)N[r]=o,dt[o]=r,o=o<<1^(o>=128?285:0);N[255]=N[0]})();function At(o,r){return o===0||r===0?0:N[(dt[o]+dt[r])%255]}function Nt(o){let r=[1];for(let a=0;a<o;a++){let e=new Array(r.length+1).fill(0);for(let t=0;t<r.length;t++)e[t]^=r[t],e[t+1]^=At(r[t],N[a]);r=e}return r}function It(o,r){let a=Nt(r),e=new Uint8Array(o.length+r);e.set(o);for(let t=0;t<o.length;t++){let s=e[t];if(s!==0)for(let n=0;n<a.length;n++)e[t+n]^=At(a[n],s)}return e.slice(o.length)}var Ft=[{ver:1,size:21,dc:16,ec:10,blocks:1,cap:14},{ver:2,size:25,dc:28,ec:16,blocks:1,cap:26},{ver:3,size:29,dc:44,ec:26,blocks:1,cap:42},{ver:4,size:33,dc:64,ec:18,blocks:2,cap:62},{ver:5,size:37,dc:86,ec:24,blocks:2,cap:84},{ver:6,size:41,dc:108,ec:16,blocks:4,cap:106}],zt=[[],[6,18],[6,22],[6,26],[6,30],[6,34]];function Gt(o){for(let r of Ft)if(o<=r.cap)return r;return null}function Ht(o,r){let a=[];function e(h,w){for(let b=w-1;b>=0;b--)a.push(h>>b&1)}e(4,4),e(o.length,8);for(let h of o)e(h,8);let t=r.dc*8;for(e(0,Math.min(4,t-a.length));a.length%8!==0;)a.push(0);let s=[236,17],n=0;for(;a.length<t;)e(s[n%2],8),n++;let i=[];for(let h=0;h<a.length;h+=8){let w=0;for(let b=0;b<8;b++)w=w<<1|a[h+b];i.push(w)}let c=Math.floor(r.dc/r.blocks),l=r.dc-c*r.blocks,d=[],m=[],u=0;for(let h=0;h<r.blocks;h++){let w=c+(h>=r.blocks-l?1:0),b=new Uint8Array(i.slice(u,u+w));d.push(b),m.push(It(b,r.ec)),u+=w}let p=[],y=0;for(let h of d)y=Math.max(y,h.length);for(let h=0;h<y;h++)for(let w of d)h<w.length&&p.push(w[h]);for(let h=0;h<r.ec;h++)for(let w of m)p.push(w[h]);return p}function Vt(o){let r=o.size,a=[],e=[];for(let i=0;i<r;i++)a.push(new Int8Array(r)),e.push(new Uint8Array(r));function t(i,c,l){a[c][i]=l?1:-1,e[c][i]=1}function s(i,c){for(let d=-3;d<=3;d++)for(let m=-3;m<=3;m++){let u=i+m,p=c+d;u<0||u>=r||p<0||p>=r||t(u,p,Math.max(Math.abs(m),Math.abs(d))!==2)}let l=[[-4,0],[4,0],[0,-4],[0,4]];for(let d=-4;d<=4;d++)for(let m of l){let u=i+(m[0]!==0?m[0]:d),p=c+(m[1]!==0?m[1]:d);u>=0&&u<r&&p>=0&&p<r&&t(u,p,!1)}}s(3,3),s(r-4,3),s(3,r-4);for(let i=8;i<r-8;i++)t(i,6,i%2===0),t(6,i,i%2===0);let n=zt[o.ver-1];if(n.length>0)for(let i=0;i<n.length;i++)for(let c=0;c<n.length;c++){let l=n[i],d=n[c];if(!e[l][d])for(let m=-2;m<=2;m++)for(let u=-2;u<=2;u++)t(d+u,l+m,Math.max(Math.abs(u),Math.abs(m))!==1)}t(8,4*o.ver+9,!0);for(let i=0;i<8;i++)e[8][i]||(e[8][i]=1),e[8][r-1-i]||(e[8][r-1-i]=1),e[i][8]||(e[i][8]=1),e[r-1-i][8]||(e[r-1-i][8]=1);return e[8][8]=1,{grid:a,reserved:e,n:r}}function jt(o,r){let{grid:a,reserved:e,n:t}=o,s=[];for(let l of r)for(let d=7;d>=0;d--)s.push(l>>d&1);let n=0,i=t-1,c=!0;for(;i>=0;){if(i===6){i--;continue}let l=c?t-1:0,d=c?-1:t,m=c?-1:1;for(let u=l;u!==d;u+=m)for(let p=0;p<2;p++){let y=i-p;y<0||e[u][y]||(a[u][y]=n<s.length&&s[n]?1:-1,n++)}i-=2,c=!c}}var Yt=[(o,r)=>(o+r)%2===0,(o,r)=>r%2===0,(o,r)=>o%3===0,(o,r)=>(o+r)%3===0,(o,r)=>(Math.floor(r/2)+Math.floor(o/3))%2===0,(o,r)=>o*r%2+o*r%3===0,(o,r)=>(o*r%2+o*r%3)%2===0,(o,r)=>((o+r)%2+o*r%3)%2===0];function Et(o,r,a,e){let t=Yt[e],s=o.map(n=>Int8Array.from(n));for(let n=0;n<a;n++)for(let i=0;i<a;i++)!r[n][i]&&t(i,n)&&(s[n][i]=s[n][i]===1?-1:1);return s}var qt=[21522,20773,24188,23371,17913,16590,20375,19104];function Pt(o,r,a){let e=qt[a],t=[];for(let i=14;i>=0;i--)t.push(e>>i&1);let s=[[0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[7,8],[8,8],[8,7],[8,5],[8,4],[8,3],[8,2],[8,1],[8,0]],n=[[8,r-1],[8,r-2],[8,r-3],[8,r-4],[8,r-5],[8,r-6],[8,r-7],[r-8,8],[r-7,8],[r-6,8],[r-5,8],[r-4,8],[r-3,8],[r-2,8],[r-1,8]];for(let i=0;i<15;i++){let c=t[i]?1:-1;o[s[i][1]][s[i][0]]=c,o[n[i][1]][n[i][0]]=c}}function Kt(o,r){let a=0;for(let e=0;e<r;e++){let t=1;for(let s=1;s<r;s++)o[e][s]>0==o[e][s-1]>0?t++:(t>=5&&(a+=t-2),t=1);t>=5&&(a+=t-2)}for(let e=0;e<r;e++){let t=1;for(let s=1;s<r;s++)o[s][e]>0==o[s-1][e]>0?t++:(t>=5&&(a+=t-2),t=1);t>=5&&(a+=t-2)}return a}function Ut(o){let r=[];for(let c=0;c<o.length;c++){let l=o.charCodeAt(c);l<128?r.push(l):l<2048&&(r.push(192|l>>6),r.push(128|l&63))}let a=Gt(r.length);if(!a)return null;let e=Ht(r,a),t=Vt(a);jt(t,e);let s=0,n=1/0;for(let c=0;c<8;c++){let l=Et(t.grid,t.reserved,t.n,c);Pt(l,t.n,c);let d=Kt(l,t.n);d<n&&(n=d,s=c)}let i=Et(t.grid,t.reserved,t.n,s);return Pt(i,t.n,s),{grid:i,size:t.n}}function Qt(o,r,a){let e=o.size,t=Math.max(2,Math.floor(88/e)),s=e*t,n=t/2,i=n*.82,c=e/2,l=e*.18;function d(x,k){let O=Math.sin(x*31+k*17)*1e4;return .75+.25*(O-Math.floor(O))}let m="";for(let x=0;x<e;x++)for(let k=0;k<e;k++){if(o.grid[x][k]<=0)continue;let O=k-c,ht=x-c;if(Math.sqrt(O*O+ht*ht)<l)continue;if(k<7&&x<7||k>=e-7&&x<7||k<7&&x>=e-7)m+=`<rect x="${k*t}" y="${x*t}" width="${t}" height="${t}" rx="${t*.15}" fill="${r}"/>`;else{let _t=i*d(k,x);m+=`<circle cx="${k*t+n}" cy="${x*t+n}" r="${_t.toFixed(1)}" fill="${r}"/>`}}let u=c*t,p=c*t,y=l*t*.6,h=a||r,w=y*2/100,b=70*w,M=`<g transform="translate(${u-y},${p-b/2}) scale(${w.toFixed(4)})">`;return M+=`<path d="M86 2 L86 64" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,M+=`<path d="M7 12 L98 12" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,M+=`<path d="M7 18 C7 32, 16 64, 30 64 C44 64, 38 28, 52 28 C66 28, 62 64, 86 64" stroke="${r}" stroke-width="5" stroke-linecap="round" fill="none"/>`,M+=`<circle cx="7" cy="12" r="7" fill="${r}"/>`,M+=`<circle cx="86" cy="64" r="7" fill="${h}"/>`,M+="</g>",`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${s} ${s}" width="${s}" height="${s}">${m}${M}</svg>`}var Xt=`.integrity-section {
105
+ `,Ke=(()=>{try{let n=new CSSStyleSheet;return n.replaceSync(B),n}catch{return null}})();var Bt={"--wt-color-bg":"var(--wt-scorecard-bg-card)","--wt-color-surface":"var(--wt-scorecard-bg-detail)","--wt-color-text":"var(--wt-scorecard-text)","--wt-color-text-muted":"var(--wt-scorecard-text-tertiary)","--wt-color-border":"var(--wt-scorecard-border)","--wt-color-primary":"var(--wt-scorecard-chart-accent)","--wt-color-secondary":"var(--wt-scorecard-chart-flagged)","--wt-font-data":"var(--wt-scorecard-font-data)","--wt-font-ui":"var(--wt-scorecard-font-body)"};function Tt(n){for(let[e,r]of Object.entries(Bt))n.style.setProperty(e,r)}var N=new Uint8Array(256),dt=new Uint8Array(256);(function(){let n=1;for(let e=0;e<255;e++)N[e]=n,dt[n]=e,n=n<<1^(n>=128?285:0);N[255]=N[0]})();function At(n,e){return n===0||e===0?0:N[(dt[n]+dt[e])%255]}function Nt(n){let e=[1];for(let r=0;r<n;r++){let a=new Array(e.length+1).fill(0);for(let t=0;t<e.length;t++)a[t]^=e[t],a[t+1]^=At(e[t],N[r]);e=a}return e}function It(n,e){let r=Nt(e),a=new Uint8Array(n.length+e);a.set(n);for(let t=0;t<n.length;t++){let s=a[t];if(s!==0)for(let o=0;o<r.length;o++)a[t+o]^=At(r[o],s)}return a.slice(n.length)}var zt=[{ver:1,size:21,dc:16,ec:10,blocks:1,cap:14},{ver:2,size:25,dc:28,ec:16,blocks:1,cap:26},{ver:3,size:29,dc:44,ec:26,blocks:1,cap:42},{ver:4,size:33,dc:64,ec:18,blocks:2,cap:62},{ver:5,size:37,dc:86,ec:24,blocks:2,cap:84},{ver:6,size:41,dc:108,ec:16,blocks:4,cap:106}],Ft=[[],[6,18],[6,22],[6,26],[6,30],[6,34]];function Gt(n){for(let e of zt)if(n<=e.cap)return e;return null}function Ht(n,e){let r=[];function a(h,w){for(let b=w-1;b>=0;b--)r.push(h>>b&1)}a(4,4),a(n.length,8);for(let h of n)a(h,8);let t=e.dc*8;for(a(0,Math.min(4,t-r.length));r.length%8!==0;)r.push(0);let s=[236,17],o=0;for(;r.length<t;)a(s[o%2],8),o++;let i=[];for(let h=0;h<r.length;h+=8){let w=0;for(let b=0;b<8;b++)w=w<<1|r[h+b];i.push(w)}let c=Math.floor(e.dc/e.blocks),l=e.dc-c*e.blocks,d=[],m=[],u=0;for(let h=0;h<e.blocks;h++){let w=c+(h>=e.blocks-l?1:0),b=new Uint8Array(i.slice(u,u+w));d.push(b),m.push(It(b,e.ec)),u+=w}let p=[],y=0;for(let h of d)y=Math.max(y,h.length);for(let h=0;h<y;h++)for(let w of d)h<w.length&&p.push(w[h]);for(let h=0;h<e.ec;h++)for(let w of m)p.push(w[h]);return p}function Vt(n){let e=n.size,r=[],a=[];for(let i=0;i<e;i++)r.push(new Int8Array(e)),a.push(new Uint8Array(e));function t(i,c,l){r[c][i]=l?1:-1,a[c][i]=1}function s(i,c){for(let d=-3;d<=3;d++)for(let m=-3;m<=3;m++){let u=i+m,p=c+d;u<0||u>=e||p<0||p>=e||t(u,p,Math.max(Math.abs(m),Math.abs(d))!==2)}let l=[[-4,0],[4,0],[0,-4],[0,4]];for(let d=-4;d<=4;d++)for(let m of l){let u=i+(m[0]!==0?m[0]:d),p=c+(m[1]!==0?m[1]:d);u>=0&&u<e&&p>=0&&p<e&&t(u,p,!1)}}s(3,3),s(e-4,3),s(3,e-4);for(let i=8;i<e-8;i++)t(i,6,i%2===0),t(6,i,i%2===0);let o=Ft[n.ver-1];if(o.length>0)for(let i=0;i<o.length;i++)for(let c=0;c<o.length;c++){let l=o[i],d=o[c];if(!a[l][d])for(let m=-2;m<=2;m++)for(let u=-2;u<=2;u++)t(d+u,l+m,Math.max(Math.abs(u),Math.abs(m))!==1)}t(8,4*n.ver+9,!0);for(let i=0;i<8;i++)a[8][i]||(a[8][i]=1),a[8][e-1-i]||(a[8][e-1-i]=1),a[i][8]||(a[i][8]=1),a[e-1-i][8]||(a[e-1-i][8]=1);return a[8][8]=1,{grid:r,reserved:a,n:e}}function jt(n,e){let{grid:r,reserved:a,n:t}=n,s=[];for(let l of e)for(let d=7;d>=0;d--)s.push(l>>d&1);let o=0,i=t-1,c=!0;for(;i>=0;){if(i===6){i--;continue}let l=c?t-1:0,d=c?-1:t,m=c?-1:1;for(let u=l;u!==d;u+=m)for(let p=0;p<2;p++){let y=i-p;y<0||a[u][y]||(r[u][y]=o<s.length&&s[o]?1:-1,o++)}i-=2,c=!c}}var Yt=[(n,e)=>(n+e)%2===0,(n,e)=>e%2===0,(n,e)=>n%3===0,(n,e)=>(n+e)%3===0,(n,e)=>(Math.floor(e/2)+Math.floor(n/3))%2===0,(n,e)=>n*e%2+n*e%3===0,(n,e)=>(n*e%2+n*e%3)%2===0,(n,e)=>((n+e)%2+n*e%3)%2===0];function Et(n,e,r,a){let t=Yt[a],s=n.map(o=>Int8Array.from(o));for(let o=0;o<r;o++)for(let i=0;i<r;i++)!e[o][i]&&t(i,o)&&(s[o][i]=s[o][i]===1?-1:1);return s}var qt=[21522,20773,24188,23371,17913,16590,20375,19104];function Pt(n,e,r){let a=qt[r],t=[];for(let i=14;i>=0;i--)t.push(a>>i&1);let s=[[0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[7,8],[8,8],[8,7],[8,5],[8,4],[8,3],[8,2],[8,1],[8,0]],o=[[8,e-1],[8,e-2],[8,e-3],[8,e-4],[8,e-5],[8,e-6],[8,e-7],[e-8,8],[e-7,8],[e-6,8],[e-5,8],[e-4,8],[e-3,8],[e-2,8],[e-1,8]];for(let i=0;i<15;i++){let c=t[i]?1:-1;n[s[i][1]][s[i][0]]=c,n[o[i][1]][o[i][0]]=c}}function Kt(n,e){let r=0;for(let a=0;a<e;a++){let t=1;for(let s=1;s<e;s++)n[a][s]>0==n[a][s-1]>0?t++:(t>=5&&(r+=t-2),t=1);t>=5&&(r+=t-2)}for(let a=0;a<e;a++){let t=1;for(let s=1;s<e;s++)n[s][a]>0==n[s-1][a]>0?t++:(t>=5&&(r+=t-2),t=1);t>=5&&(r+=t-2)}return r}function Ut(n){let e=[];for(let c=0;c<n.length;c++){let l=n.charCodeAt(c);l<128?e.push(l):l<2048&&(e.push(192|l>>6),e.push(128|l&63))}let r=Gt(e.length);if(!r)return null;let a=Ht(e,r),t=Vt(r);jt(t,a);let s=0,o=1/0;for(let c=0;c<8;c++){let l=Et(t.grid,t.reserved,t.n,c);Pt(l,t.n,c);let d=Kt(l,t.n);d<o&&(o=d,s=c)}let i=Et(t.grid,t.reserved,t.n,s);return Pt(i,t.n,s),{grid:i,size:t.n}}function Qt(n,e,r){let a=n.size,t=Math.max(2,Math.floor(88/a)),s=a*t,o=t/2,i=o*.82,c=a/2,l=a*.18;function d(x,k){let O=Math.sin(x*31+k*17)*1e4;return .75+.25*(O-Math.floor(O))}let m="";for(let x=0;x<a;x++)for(let k=0;k<a;k++){if(n.grid[x][k]<=0)continue;let O=k-c,ht=x-c;if(Math.sqrt(O*O+ht*ht)<l)continue;if(k<7&&x<7||k>=a-7&&x<7||k<7&&x>=a-7)m+=`<rect x="${k*t}" y="${x*t}" width="${t}" height="${t}" rx="${t*.15}" fill="${e}"/>`;else{let _t=i*d(k,x);m+=`<circle cx="${k*t+o}" cy="${x*t+o}" r="${_t.toFixed(1)}" fill="${e}"/>`}}let u=c*t,p=c*t,y=l*t*.6,h=r||e,w=y*2/100,b=70*w,W=`<g transform="translate(${u-y},${p-b/2}) scale(${w.toFixed(4)})">`;return W+=`<path d="M86 2 L86 64" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,W+=`<path d="M7 12 L98 12" stroke="${h}" stroke-width="5" stroke-linecap="round"/>`,W+=`<path d="M7 18 C7 32, 16 64, 30 64 C44 64, 38 28, 52 28 C66 28, 62 64, 86 64" stroke="${e}" stroke-width="5" stroke-linecap="round" fill="none"/>`,W+=`<circle cx="7" cy="12" r="7" fill="${e}"/>`,W+=`<circle cx="86" cy="64" r="7" fill="${h}"/>`,W+="</g>",`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${s} ${s}" width="${s}" height="${s}">${m}${W}</svg>`}var Xt=`.integrity-section {
106
106
  margin-top: 2rem;
107
107
  padding-top: 1.5rem;
108
108
  border-top: 1px solid var(--wt-scorecard-border);
@@ -168,7 +168,7 @@ var ft=`:host {
168
168
  flex: 1;
169
169
  }
170
170
  `,D=class extends g{getStylesheet(){return B+`
171
- `+Xt}render(){if(!this._data)return;let{integrity:r,outputSignature:a}=this._data,e=document.createElement("div");e.className="integrity-section";let t=document.createElement("div");t.className="integrity-title",t.textContent="Integrity & Verification",e.appendChild(t);let s=document.createElement("div");s.className="integrity-stats",s.textContent=`${r.eventCount} events \xB7 ${r.checkpoints.length} checkpoints`,e.appendChild(s);let n=document.createElement("div");n.className="integrity-hash-block";let i=document.createElement("span");i.className="integrity-hash-label",i.textContent="Digest (SHA-256)";let c=document.createElement("code");c.className="hash",c.textContent=r.finalDigest,n.append(i,c),e.appendChild(n);let l=document.createElement("div");l.className="integrity-hash-block";let d=document.createElement("span");d.className="integrity-hash-label",d.textContent="Output Signature";let m=document.createElement("code");m.className="hash",m.textContent=a,l.append(d,m),e.appendChild(l);let u=document.createElement("div");u.className="integrity-bottom";let p=document.createElement("div");p.className="qr-container";let y=document.createElement("p");y.className="integrity-explainer",y.textContent="This scorecard includes cryptographic integrity verification. The digest covers all input events; the signature covers the analysis output. Compare against original session data or scan for verification.",u.appendChild(p),u.appendChild(y),e.appendChild(u),this.replaceChart(e),requestAnimationFrame(()=>this.renderQr(r.finalDigest))}renderQr(r){let a=this.shadow.querySelector(".qr-container");if(!a)return;let e=Ut(r);if(!e)return;let t=getComputedStyle(this),s=t.getPropertyValue("--wt-scorecard-text").trim()||"#E4E2DA",n=t.getPropertyValue("--wt-scorecard-status-clear").trim()||"#5EAE78";a.innerHTML=Qt(e,s,n)}};D.tagName="wt-integrity-footer";var Mt=new Set(["WT-104","WT-204","WT-302","WT-403","WT-503","WT-506","WT-509","WT-601","WT-602","WT-603"]);function Jt(o){return Mt.has(o)}function W(o){return o?Mt.has(o)?"pass":"flag":"unknown"}var I={contentOrigin:"Content Origin",timingAuthenticity:"Timing & Rhythm",revisionBehavior:"Revision Behavior",sessionContinuity:"Session Continuity",physicalPlausibility:"Physical Plausibility",temporalPatterns:"Temporal Patterns"},rt=["contentOrigin","timingAuthenticity","revisionBehavior","sessionContinuity","physicalPlausibility","temporalPatterns"],mt=["contentOrigin","timingAuthenticity","revisionBehavior"],ut=["sessionContinuity","physicalPlausibility","temporalPatterns"],Zt={"WT-100":()=>"No content was recorded during this session.","WT-101":o=>{let r=o.params.pct??0,a=100-r;return`Nearly all content (${r}%) was pasted from an external source. Only ${a}% of characters were typed directly.`},"WT-102":o=>`${o.params.pct??0}% of text was inserted via autocomplete, suggesting reliance on predictive input rather than original composition.`,"WT-103":o=>{let r=o.params.pct??0,a=100-r;return`${r}% of text was pasted from external sources. The remaining ${a}% was typed directly.`},"WT-104":()=>"All text was typed directly \u2014 no paste or autocomplete events were detected."},te={"WT-200":o=>{let r=(o.params.dwellMean??0).toFixed(1),a=(o.params.flightMean??0).toFixed(1);return`Keystroke timing magnitudes (dwell ${r}ms, flight ${a}ms) fall below plausible human ranges, consistent with programmatic input injection.`},"WT-201":o=>`Keystroke timing is mechanically uniform \u2014 the coefficient of variation (${(o.params.cv??0).toFixed(2)}) falls far below the human range of 0.3\u20130.8. This pattern is consistent with automated input.`,"WT-202":o=>`A highly periodic keystroke pattern was detected (score ${(o.params.score??0).toFixed(2)}). Human typing naturally varies; metronomic regularity suggests automation.`,"WT-203":o=>`Flight times between keystrokes are suspiciously uniform (CV ${(o.params.cv??0).toFixed(2)}), lacking the natural variability expected from human finger movement.`,"WT-204":()=>"Keystroke timing variability falls within normal human ranges. The rhythm is consistent with natural typing."},ee={"WT-500":(o,r)=>`Zero corrections across the entire session. Human writers make mistakes \u2014 a ${r.keydownCount}-keystroke session with no corrections is a strong signal content was not composed here.`,"WT-501":()=>"No keystrokes were recorded, so revision behavior could not be analyzed.","WT-502":o=>`Very low correction rate (${(o.params.pct??0).toFixed(1)}%). While some writers are precise, this level of accuracy across an entire session is unusual.`,"WT-503":o=>`Normal correction rate (${(o.params.pct??0).toFixed(1)}%). The writer made and fixed mistakes at a rate consistent with natural composition.`,"WT-504":o=>`No corrections, navigation, or undo in a ${o.params.count??0}-keystroke session \u2014 the text was entered linearly without any revision.`,"WT-505":()=>"Non-linear editing was detected despite a low correction rate, suggesting some revision activity.","WT-506":o=>`Authentic revision depth detected (product-process ratio ${(o.params.ratio??0).toFixed(2)}). The writing process shows genuine iterative refinement.`,"WT-507":o=>{let r=o.params.count??0,a=o.params.keydowns??0;return`Linear transcription pattern: only ${r} insertions in a ${a}-keystroke session, with minimal revision or restructuring.`},"WT-508":o=>`Forward-edge concentration: ${Math.round((o.params.ratio??0)*100)}% of keystrokes occurred at the end of the document with almost no in-document editing, consistent with copy-typing or automation.`,"WT-509":o=>`Multi-word restructuring detected (${Math.round((o.params.ratio??0)*100)}% of chars from multi-word pastes), suggesting authentic revision where the writer rearranged their own text.`},re={"WT-300":o=>{let r=Math.round(o.params.timestamp??0),a=(o.params.magnitude??0).toFixed(1);return`Typing rhythm changed abruptly at ${r}s (magnitude ${a}), suggesting a possible switch in input method or author.`},"WT-301":o=>`${o.params.count??0} tab-away events detected \u2014 the writer left and returned to this field multiple times during the session.`,"WT-302":()=>"Behavior was consistent throughout the session with no abrupt changes in typing rhythm or style."},ae={"WT-400":o=>`${o.params.pct??0}% of events lack browser trust indicators (isTrusted=false), suggesting synthetic event injection.`,"WT-401":o=>{let r=o.params.count??0,a=o.params.pct??0;return`${r} keydown events had no matching keyup (${a}% of keydowns). Automation tools often omit keyup events.`},"WT-402":o=>`${o.params.count??0} keystroke sequences exceed the maximum human typing speed, indicating programmatic input.`,"WT-403":()=>"All keystroke timing is physically plausible \u2014 no evidence of synthetic or injected events.","WT-404":o=>{let r=o.params.chars??0,a=o.params.pct??0;return`${r} characters (${a}%) were inserted programmatically, bypassing normal keystroke input. This is consistent with automated text injection.`}},ne={"WT-600":o=>`No speed variation over a ${o.params.minutes??0}-minute session. Human typing naturally fluctuates; constant speed suggests automation.`,"WT-601":()=>"Natural warmup and fatigue pattern detected \u2014 the writer started slow, reached peak speed, then gradually slowed.","WT-602":()=>"Significant fatigue detected toward the end of the session, consistent with sustained human cognitive effort.","WT-603":()=>"Temporal patterns fall within normal range \u2014 typing pace varied naturally over the session.","WT-604":o=>`${o.params.ratio??0}% of keystrokes occurred in machine-like bursts, suggesting automated input segments.`,"WT-605":o=>`Uniform typing pace across the session (fluency SD ${(o.params.sd??0).toFixed(1)}). Human writers show more variation as they think, pause, and revise.`,"WT-606":o=>`Frequent revision interruptions detected (R-burst median ${(o.params.median??0).toFixed(1)}s), consistent with active editing behavior.`,"WT-607":o=>`No linguistic pause structure detected (sentence/word pause ratio ${(o.params.ratio??0).toFixed(2)}). Human writers pause longer before sentences than within words.`,"WT-608":o=>`Low cognitive pause rate (${(o.params.rate??0).toFixed(1)}% of keystrokes), suggesting text was transcribed rather than composed.`},oe={contentOrigin:Zt,timingAuthenticity:te,revisionBehavior:ee,sessionContinuity:re,physicalPlausibility:ae,temporalPatterns:ne};function at(o,r){let a=r[o];if(!(a!=null&&a.indicator))return"Analysis data not available.";let e=oe[o];if(!e)return Rt(a.indicator);let t=e[a.indicator.code];return t?t(a.indicator,r):Rt(a.indicator)}function Rt(o){return`Indicator ${o.code} detected.`}var se={contentOrigin:"In a typical session, you'd see a continuous band of typed content with occasional small paste events. A single bulk insertion is characteristic of copy-paste submission.",timingAuthenticity:"A human heatmap shows scattered clusters reflecting natural variation in finger movement. Tight single-point concentration indicates programmatic keystroke injection.",revisionBehavior:"Human writers produce clusters of corrections as they re-read and revise. Absence of corrections suggests transcription rather than composition.",sessionContinuity:"Steady growth with small plateaus (thinking pauses) is typical. A sudden vertical jump indicates bulk content insertion.",physicalPlausibility:"Human editing jumps around the document \u2014 revising earlier sections, appending new text. Strictly sequential cursor movement suggests automated input.",temporalPatterns:"Human typing shows varied pause durations \u2014 short pauses within words, longer pauses between sentences. Uniform pause lengths suggest automated pacing."};function pt(o){return se[o]??null}function nt(o,r){return({contentOrigin:e=>{let t=e.contentOrigin.metrics,s=Math.round(t.charactersByOrigin.pasted*100),n=Math.round(t.charactersByOrigin.typed*100),i=t.pasteEvents.length,c=t.pasteEvents.reduce((l,d)=>l+d.characterCount,0);return[{label:"pasted",value:`${s}%`,flagged:s>50},{label:"typed",value:`${n}%`,flagged:!1},{label:"paste events",value:String(i),flagged:!1},{label:"chars pasted",value:ie(c),flagged:!1}]},timingAuthenticity:e=>{let t=e.timingAuthenticity.metrics,s=t.flightTimeDistribution.cv,n=t.dwellTimeDistribution.mean;return[{label:"timing cv",value:s.toFixed(2),flagged:s<.2},{label:"mean dwell",value:`${Math.round(n)}ms`,flagged:n<20},{label:"periodicity",value:t.periodicityScore.toFixed(2),flagged:t.periodicityScore>.5},{label:"entropy",value:t.entropy.toFixed(1),flagged:t.entropy<1.5}]},revisionBehavior:e=>{let t=e.revisionBehavior.metrics;return[{label:"corrections",value:String(t.correctionCount),flagged:t.correctionCount===0},{label:"navigation",value:String(t.navigationCount),flagged:t.navigationCount===0},{label:"undo / redo",value:String(t.undoRedoCount),flagged:!1},{label:"product-process",value:t.productProcessRatio.toFixed(2),flagged:t.productProcessRatio===0}]},sessionContinuity:e=>{let t=e.sessionContinuity.metrics;return[{label:"change points",value:String(t.changePoints.length),flagged:t.changePoints.length>2},{label:"tab-away events",value:String(t.tabAwayEvents.length),flagged:!1}]},physicalPlausibility:e=>{let t=e.physicalPlausibility.metrics;return[{label:"synthetic ratio",value:`${Math.round(t.syntheticEventRatio*100)}%`,flagged:t.syntheticEventRatio>.05},{label:"impossible seq.",value:String(t.impossibleSequences.count),flagged:t.impossibleSequences.count>0},{label:"unmatched keydowns",value:String(t.unmatchedKeydownCount),flagged:t.unmatchedKeydownCount>5},{label:"zero-latency",value:String(t.zeroLatencyEventCount),flagged:t.zeroLatencyEventCount>0},{label:"Bulk Insert",value:String(t.bulkInsertCharCount),flagged:t.bulkInsertCharCount>0}]},temporalPatterns:e=>{let t=e.temporalPatterns.metrics;return[{label:"duration",value:ot(t.sessionDurationMs),flagged:!1},{label:"warmup ratio",value:t.warmupRatio.toFixed(2),flagged:!1},{label:"fatigue ratio",value:t.fatigueRatio.toFixed(2),flagged:!1},{label:"burst ratio",value:t.burstPattern.burstToTotalRatio.toFixed(2),flagged:t.burstPattern.burstToTotalRatio>.7}]}}[o]??(()=>[]))(r)}function ie(o){return o>=1e6?`${(o/1e6).toFixed(1)}m`:o>=1e3?`${(o/1e3).toFixed(1)}k`:String(o)}function ot(o){let r=Math.round(o/1e3);if(r<60)return`${r}s`;let a=Math.floor(r/60),e=r%60;return e===0?`${a}m`:`${a}m ${e}s`}var Wt={"coefficient of variation":{definition:"Standard deviation divided by the mean \u2014 measures how spread out values are relative to their average. Low CV means uniform timing.",docsPath:"/docs/analysis/timing/"},"dwell time":{definition:"How long a key is held down before being released.",docsPath:"/docs/analysis/timing/"},"flight time":{definition:"The gap between releasing one key and pressing the next.",docsPath:"/docs/analysis/timing/"},"product-process ratio":{definition:"The ratio of final text length to total characters typed. Low values suggest heavy revision; near 1.0 suggests linear transcription.",docsPath:"/docs/analysis/revision/"},periodicity:{definition:"How rhythmically regular the typing pattern is. High periodicity suggests metronomic (automated) input."},entropy:{definition:"A measure of randomness in timing. Low entropy means predictable, uniform intervals."},burst:{definition:"A rapid sequence of keystrokes between pauses. Human typing naturally occurs in bursts."},"synthetic event":{definition:"A keyboard event generated programmatically rather than by a real keypress. Browsers mark these with isTrusted=false."},"change point":{definition:"A moment where typing rhythm shifts abruptly, potentially indicating a switch in input method."}};function st(o,r){let a=v(o);for(let[e,t]of Object.entries(Wt)){let s=new RegExp(`\\b(${le(e)})\\b`,"gi");a=a.replace(s,n=>{let i=`title="${v(t.definition)}" class="wt-term"`,c=v(n);if(t.docsPath){let l=(r??"https://writetrack.dev")+t.docsPath;return`<a href="${v(l)}" target="_blank" rel="noopener"><abbr ${i}>${c}</abbr></a>`}return`<abbr ${i}>${c}</abbr>`})}return a}function le(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}import*as f from"@observablehq/plot";var ce={contentOrigin:[0,1],timingAuthenticity:[0,1],revisionBehavior:[0,3],sessionContinuity:[0,1],physicalPlausibility:[0,1],temporalPatterns:[1,2]},de={contentOrigin:{name:"Composition Timeline",desc:"Horizontal bar showing typing vs paste segments over time"},timingAuthenticity:{name:"Rhythm Heatmap",desc:"Dwell time vs flight time scatter showing keystroke timing distribution"},revisionBehavior:{name:"Corrections Timeline",desc:"Edit operations plotted over session time, sized by magnitude"},sessionContinuity:{name:"Document Growth Curve",desc:"Document length over session time, highlighting change points"},physicalPlausibility:{name:"Edit Waterfall",desc:"Cursor position over time, showing insertion and deletion patterns"},temporalPatterns:{name:"Speed Timeline",desc:"Words per minute over session duration, showing warmup, peak, and fatigue"}},$t={contentOrigin:1,timingAuthenticity:1,revisionBehavior:1,sessionContinuity:2,physicalPlausibility:2,temporalPatterns:2},me=`:host { display: block; overflow: hidden; }
171
+ `+Xt}render(){if(!this._data)return;let{integrity:e,outputSignature:r}=this._data,a=document.createElement("div");a.className="integrity-section";let t=document.createElement("div");t.className="integrity-title",t.textContent="Integrity & Verification",a.appendChild(t);let s=document.createElement("div");s.className="integrity-stats",s.textContent=`${e.eventCount} events \xB7 ${e.checkpoints.length} checkpoints`,a.appendChild(s);let o=document.createElement("div");o.className="integrity-hash-block";let i=document.createElement("span");i.className="integrity-hash-label",i.textContent="Digest (SHA-256)";let c=document.createElement("code");c.className="hash",c.textContent=e.finalDigest,o.append(i,c),a.appendChild(o);let l=document.createElement("div");l.className="integrity-hash-block";let d=document.createElement("span");d.className="integrity-hash-label",d.textContent="Output Signature";let m=document.createElement("code");m.className="hash",m.textContent=r,l.append(d,m),a.appendChild(l);let u=document.createElement("div");u.className="integrity-bottom";let p=document.createElement("div");p.className="qr-container";let y=document.createElement("p");y.className="integrity-explainer",y.textContent="This scorecard includes cryptographic integrity verification. The digest covers all input events; the signature covers the analysis output. Compare against original session data or scan for verification.",u.appendChild(p),u.appendChild(y),a.appendChild(u),this.replaceChart(a),requestAnimationFrame(()=>this.renderQr(e.finalDigest))}renderQr(e){let r=this.shadow.querySelector(".qr-container");if(!r)return;let a=Ut(e);if(!a)return;let t=getComputedStyle(this),s=t.getPropertyValue("--wt-scorecard-text").trim()||"#E4E2DA",o=t.getPropertyValue("--wt-scorecard-status-clear").trim()||"#5EAE78";r.innerHTML=Qt(a,s,o)}};D.tagName="wt-integrity-footer";var Wt=new Set(["WT-104","WT-106","WT-204","WT-302","WT-403","WT-503","WT-506","WT-509","WT-601","WT-602","WT-603"]);function Jt(n){return Wt.has(n)}function M(n){return n?Wt.has(n)?"pass":"flag":"unknown"}var I={contentOrigin:"Content Origin",timingAuthenticity:"Timing & Rhythm",revisionBehavior:"Revision Behavior",sessionContinuity:"Session Continuity",physicalPlausibility:"Physical Plausibility",temporalPatterns:"Temporal Patterns"},rt=["contentOrigin","timingAuthenticity","revisionBehavior","sessionContinuity","physicalPlausibility","temporalPatterns"],mt=["contentOrigin","timingAuthenticity","revisionBehavior"],ut=["sessionContinuity","physicalPlausibility","temporalPatterns"],Zt={"WT-100":()=>"No content was recorded during this session.","WT-101":n=>{let e=n.params.pct??0,r=100-e;return`Nearly all content (${e}%) was pasted from an external source. Only ${r}% of characters were typed directly.`},"WT-102":n=>`${n.params.pct??0}% of text was inserted via autocomplete, suggesting reliance on predictive input rather than original composition.`,"WT-103":n=>{let e=n.params.pct??0,r=100-e;return`${e}% of text was pasted from external sources. The remaining ${r}% was typed directly.`},"WT-104":()=>"All text was typed directly \u2014 no paste or autocomplete events were detected.","WT-105":()=>"Unmodified external content detected \u2014 pasted text was not edited after insertion, suggesting pre-composed content.","WT-106":n=>`${n.params.rework??0}% of pasted content was subsequently reworked, indicating the writer integrated external material into their own composition.`,"WT-107":n=>{let e=n.params.pasteRatio??0,r=n.params.retentionPct??0;return`High paste volume (${e}% paste ratio) with ${r}% left unmodified \u2014 content was pasted in bulk without rework.`}},te={"WT-105":()=>"Unmodified external content detected \u2014 pasted text was not edited after insertion, suggesting pre-composed content.","WT-106":n=>`${n.params.rework??0}% of pasted content was subsequently reworked, indicating the writer integrated external material into their own composition.`,"WT-107":n=>{let e=n.params.pasteRatio??0,r=n.params.retentionPct??0;return`High paste volume (${e}% paste ratio) with ${r}% left unmodified \u2014 content was pasted in bulk without rework.`}},ee={"WT-200":n=>{let e=(n.params.dwellMean??0).toFixed(1),r=(n.params.flightMean??0).toFixed(1);return`Keystroke timing magnitudes (dwell ${e}ms, flight ${r}ms) fall below plausible human ranges, consistent with programmatic input injection.`},"WT-201":n=>`Keystroke timing is mechanically uniform \u2014 the coefficient of variation (${(n.params.cv??0).toFixed(2)}) falls far below the human range of 0.3\u20130.8. This pattern is consistent with automated input.`,"WT-202":n=>`A highly periodic keystroke pattern was detected (score ${(n.params.score??0).toFixed(2)}). Human typing naturally varies; metronomic regularity suggests automation.`,"WT-203":n=>`Flight times between keystrokes are suspiciously uniform (CV ${(n.params.cv??0).toFixed(2)}), lacking the natural variability expected from human finger movement.`,"WT-204":()=>"Keystroke timing variability falls within normal human ranges. The rhythm is consistent with natural typing."},re={"WT-500":(n,e)=>`Zero corrections across the entire session. Human writers make mistakes \u2014 a ${e.keydownCount}-keystroke session with no corrections is a strong signal content was not composed here.`,"WT-501":()=>"No keystrokes were recorded, so revision behavior could not be analyzed.","WT-502":n=>`Very low correction rate (${(n.params.pct??0).toFixed(1)}%). While some writers are precise, this level of accuracy across an entire session is unusual.`,"WT-503":n=>`Normal correction rate (${(n.params.pct??0).toFixed(1)}%). The writer made and fixed mistakes at a rate consistent with natural composition.`,"WT-504":n=>`No corrections, navigation, or undo in a ${n.params.count??0}-keystroke session \u2014 the text was entered linearly without any revision.`,"WT-505":()=>"Non-linear editing was detected despite a low correction rate, suggesting some revision activity.","WT-506":n=>`Authentic revision depth detected (product-process ratio ${(n.params.ratio??0).toFixed(2)}). The writing process shows genuine iterative refinement.`,"WT-507":n=>{let e=n.params.count??0,r=n.params.keydowns??0;return`Linear transcription pattern: only ${e} insertions in a ${r}-keystroke session, with minimal revision or restructuring.`},"WT-508":n=>`Forward-edge concentration: ${Math.round((n.params.ratio??0)*100)}% of keystrokes occurred at the end of the document with almost no in-document editing, consistent with copy-typing or automation.`,"WT-509":n=>`Multi-word restructuring detected (${Math.round((n.params.ratio??0)*100)}% of chars from multi-word pastes), suggesting authentic revision where the writer rearranged their own text.`},ae={"WT-300":n=>{let e=Math.round(n.params.timestamp??0),r=(n.params.magnitude??0).toFixed(1);return`Typing rhythm changed abruptly at ${e}s (magnitude ${r}), suggesting a possible switch in input method or author.`},"WT-301":n=>`${n.params.count??0} tab-away events detected \u2014 the writer left and returned to this field multiple times during the session.`,"WT-302":()=>"Behavior was consistent throughout the session with no abrupt changes in typing rhythm or style."},ne={"WT-400":n=>`${n.params.pct??0}% of events lack browser trust indicators (isTrusted=false), suggesting synthetic event injection.`,"WT-401":n=>{let e=n.params.count??0,r=n.params.pct??0;return`${e} keydown events had no matching keyup (${r}% of keydowns). Automation tools often omit keyup events.`},"WT-402":n=>`${n.params.count??0} keystroke sequences exceed the maximum human typing speed, indicating programmatic input.`,"WT-403":()=>"All keystroke timing is physically plausible \u2014 no evidence of synthetic or injected events.","WT-404":n=>{let e=n.params.chars??0,r=n.params.pct??0;return`${e} characters (${r}%) were inserted programmatically, bypassing normal keystroke input. This is consistent with automated text injection.`},"WT-405":n=>{let e=n.params.count??0,r=n.params.pct??0;return`${e} events (${r}% of keydowns) have sub-millisecond dwell time. Human key press/release always takes 30\u2013150ms; zero-latency events indicate programmatic injection.`}},oe={"WT-600":n=>`No speed variation over a ${n.params.minutes??0}-minute session. Human typing naturally fluctuates; constant speed suggests automation.`,"WT-601":()=>"Natural warmup and fatigue pattern detected \u2014 the writer started slow, reached peak speed, then gradually slowed.","WT-602":()=>"Significant fatigue detected toward the end of the session, consistent with sustained human cognitive effort.","WT-603":()=>"Temporal patterns fall within normal range \u2014 typing pace varied naturally over the session.","WT-604":n=>`${n.params.ratio??0}% of keystrokes occurred in machine-like bursts, suggesting automated input segments.`,"WT-605":n=>`Uniform typing pace across the session (fluency SD ${(n.params.sd??0).toFixed(1)}). Human writers show more variation as they think, pause, and revise.`,"WT-606":n=>`Frequent revision interruptions detected (R-burst median ${(n.params.median??0).toFixed(1)}s), consistent with active editing behavior.`,"WT-607":n=>`No linguistic pause structure detected (sentence/word pause ratio ${(n.params.ratio??0).toFixed(2)}). Human writers pause longer before sentences than within words.`,"WT-608":n=>`Low cognitive pause rate (${(n.params.rate??0).toFixed(1)}% of keystrokes), suggesting text was transcribed rather than composed.`},se={contentOrigin:Zt,timingAuthenticity:ee,revisionBehavior:re,sessionContinuity:ae,physicalPlausibility:ne,temporalPatterns:oe};function at(n,e){let r=e[n];if(!(r!=null&&r.indicator))return"Analysis data not available.";let a=se[n];if(!a)return Rt(r.indicator);if(n==="contentOrigin"&&r.pasteReworkIndicator){let s=r.pasteReworkIndicator.code,o=te[s];if(o)return o(r.pasteReworkIndicator,e)}let t=a[r.indicator.code];return t?t(r.indicator,e):Rt(r.indicator)}function Rt(n){return`Indicator ${n.code} detected.`}var ie={contentOrigin:"In a typical session, you'd see a continuous band of typed content with occasional small paste events. A single bulk insertion is characteristic of copy-paste submission.",timingAuthenticity:"A human heatmap shows scattered clusters reflecting natural variation in finger movement. Tight single-point concentration indicates programmatic keystroke injection.",revisionBehavior:"Human writers produce clusters of corrections as they re-read and revise. Absence of corrections suggests transcription rather than composition.",sessionContinuity:"Steady growth with small plateaus (thinking pauses) is typical. A sudden vertical jump indicates bulk content insertion.",physicalPlausibility:"Human editing jumps around the document \u2014 revising earlier sections, appending new text. Strictly sequential cursor movement suggests automated input.",temporalPatterns:"Human typing shows varied pause durations \u2014 short pauses within words, longer pauses between sentences. Uniform pause lengths suggest automated pacing."};function pt(n){return ie[n]??null}function nt(n,e){return({contentOrigin:a=>{let t=a.contentOrigin.metrics,s=Math.round(t.charactersByOrigin.pasted*100),o=Math.round(t.charactersByOrigin.typed*100),i=t.pasteEvents.length,c=t.pasteEvents.reduce((l,d)=>l+d.characterCount,0);return[{label:"pasted",value:`${s}%`,flagged:s>50},{label:"typed",value:`${o}%`,flagged:!1},{label:"paste events",value:String(i),flagged:!1},{label:"chars pasted",value:le(c),flagged:!1}]},timingAuthenticity:a=>{let t=a.timingAuthenticity.metrics,s=t.flightTimeDistribution.cv,o=t.dwellTimeDistribution.mean;return[{label:"timing cv",value:s.toFixed(2),flagged:s<.2},{label:"mean dwell",value:`${Math.round(o)}ms`,flagged:o<20},{label:"periodicity",value:t.periodicityScore.toFixed(2),flagged:t.periodicityScore>.5},{label:"entropy",value:t.entropy.toFixed(1),flagged:t.entropy<1.5}]},revisionBehavior:a=>{let t=a.revisionBehavior.metrics;return[{label:"corrections",value:String(t.correctionCount),flagged:t.correctionCount===0},{label:"navigation",value:String(t.navigationCount),flagged:t.navigationCount===0},{label:"undo / redo",value:String(t.undoRedoCount),flagged:!1},{label:"product-process",value:t.productProcessRatio.toFixed(2),flagged:t.productProcessRatio===0}]},sessionContinuity:a=>{let t=a.sessionContinuity.metrics;return[{label:"change points",value:String(t.changePoints.length),flagged:t.changePoints.length>2},{label:"tab-away events",value:String(t.tabAwayEvents.length),flagged:!1}]},physicalPlausibility:a=>{let t=a.physicalPlausibility.metrics;return[{label:"synthetic ratio",value:`${Math.round(t.syntheticEventRatio*100)}%`,flagged:t.syntheticEventRatio>.05},{label:"impossible seq.",value:String(t.impossibleSequences.count),flagged:t.impossibleSequences.count>0},{label:"unmatched keydowns",value:String(t.unmatchedKeydownCount),flagged:t.unmatchedKeydownCount>5},{label:"zero-latency",value:String(t.zeroLatencyEventCount),flagged:t.zeroLatencyEventCount>0},{label:"Bulk Insert",value:String(t.bulkInsertCharCount),flagged:t.bulkInsertCharCount>0}]},temporalPatterns:a=>{let t=a.temporalPatterns.metrics;return[{label:"duration",value:ot(t.sessionDurationMs),flagged:!1},{label:"warmup ratio",value:t.warmupRatio.toFixed(2),flagged:!1},{label:"fatigue ratio",value:t.fatigueRatio.toFixed(2),flagged:!1},{label:"burst ratio",value:t.burstPattern.burstToTotalRatio.toFixed(2),flagged:t.burstPattern.burstToTotalRatio>.7}]}}[n]??(()=>[]))(e)}function le(n){return n>=1e6?`${(n/1e6).toFixed(1)}m`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function ot(n){let e=Math.round(n/1e3);if(e<60)return`${e}s`;let r=Math.floor(e/60),a=e%60;return a===0?`${r}m`:`${r}m ${a}s`}var Mt={"coefficient of variation":{definition:"Standard deviation divided by the mean \u2014 measures how spread out values are relative to their average. Low CV means uniform timing.",docsPath:"/docs/analysis/timing/"},"dwell time":{definition:"How long a key is held down before being released.",docsPath:"/docs/analysis/timing/"},"flight time":{definition:"The gap between releasing one key and pressing the next.",docsPath:"/docs/analysis/timing/"},"product-process ratio":{definition:"The ratio of final text length to total characters typed. Low values suggest heavy revision; near 1.0 suggests linear transcription.",docsPath:"/docs/analysis/revision/"},periodicity:{definition:"How rhythmically regular the typing pattern is. High periodicity suggests metronomic (automated) input."},entropy:{definition:"A measure of randomness in timing. Low entropy means predictable, uniform intervals."},burst:{definition:"A rapid sequence of keystrokes between pauses. Human typing naturally occurs in bursts."},"synthetic event":{definition:"A keyboard event generated programmatically rather than by a real keypress. Browsers mark these with isTrusted=false."},"change point":{definition:"A moment where typing rhythm shifts abruptly, potentially indicating a switch in input method."}};function st(n,e){let r=v(n);for(let[a,t]of Object.entries(Mt)){let s=new RegExp(`\\b(${ce(a)})\\b`,"gi");r=r.replace(s,o=>{let i=`title="${v(t.definition)}" class="wt-term"`,c=v(o);if(t.docsPath){let l=(e??"https://writetrack.dev")+t.docsPath;return`<a href="${v(l)}" target="_blank" rel="noopener"><abbr ${i}>${c}</abbr></a>`}return`<abbr ${i}>${c}</abbr>`})}return r}function ce(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}import*as f from"@observablehq/plot";var de={contentOrigin:[0,1],timingAuthenticity:[0,1],revisionBehavior:[0,3],sessionContinuity:[0,1],physicalPlausibility:[0,1],temporalPatterns:[1,2]},me={contentOrigin:{name:"Composition Timeline",desc:"Horizontal bar showing typing vs paste segments over time"},timingAuthenticity:{name:"Rhythm Heatmap",desc:"Dwell time vs flight time scatter showing keystroke timing distribution"},revisionBehavior:{name:"Corrections Timeline",desc:"Edit operations plotted over session time, sized by magnitude"},sessionContinuity:{name:"Document Growth Curve",desc:"Document length over session time, highlighting change points"},physicalPlausibility:{name:"Edit Waterfall",desc:"Cursor position over time, showing insertion and deletion patterns"},temporalPatterns:{name:"Speed Timeline",desc:"Words per minute over session duration, showing warmup, peak, and fatigue"}},$t={contentOrigin:1,timingAuthenticity:1,revisionBehavior:1,sessionContinuity:2,physicalPlausibility:2,temporalPatterns:2},ue=`:host { display: block; overflow: hidden; }
172
172
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
173
173
  .page {
174
174
  max-width: 100%;
@@ -356,4 +356,4 @@ var ft=`:host {
356
356
  .detail-inner { padding: 1rem; }
357
357
  }
358
358
  `,it=class extends g{constructor(){super();this.t={1:null,2:null};D.register()}onResize(){this.rerenderAllCharts()}getStylesheet(){return B+`
359
- `+me}attributeChangedCallback(a,e,t){if(a==="theme"&&this._data&&this.hasRendered){let s=this.shadow.querySelector(".theme-toggle");s&&(s.textContent=t==="dark"?"Light":"Dark");let n=this.shadow.querySelector("wt-integrity-footer");n&&t&&n.setAttribute("theme",t),requestAnimationFrame(()=>this.rerenderAllCharts());return}super.attributeChangedCallback(a,e,t)}render(){var m;if(!((m=this._data)!=null&&m.analysis))return;let{data:a,analysis:e}=this._data;this.t={1:null,2:null};let t=document.createElement("div");t.className="page",t.appendChild(this.buildHeader(e,a.metadata.sessionId??"")),t.appendChild(this.buildSummary(e)),t.appendChild(this.buildTierLabel("Primary Evidence"));let s=this.buildGrid(1,e);t.appendChild(s);let n=this.buildDetailPanel(1);t.appendChild(n),t.appendChild(this.buildTierLabel("Supporting Context"));let i=this.buildGrid(2,e);t.appendChild(i);let c=this.buildDetailPanel(2);t.appendChild(c);let l=document.createElement("wt-integrity-footer"),d=this.getAttribute("theme");d&&l.setAttribute("theme",d),Tt(l),l.setData({integrity:e.integrity,outputSignature:e.outputSignature,sessionId:a.metadata.sessionId??""}),t.appendChild(l),this.replaceChart(t),requestAnimationFrame(()=>{this.renderAllCharts()})}buildHeader(a,e){let t=document.createElement("header");t.className="header";let s=document.createElement("div");s.className="header-meta";let n=document.createElement("span");n.textContent=`WriteTrack v${a.version}`;let i=document.createElement("span");i.className="sep",i.innerHTML="&middot;";let c=document.createElement("span"),l=new Date(a.analyzedAt);c.textContent=l.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"});let d=document.createElement("span");d.className="sep",d.innerHTML="&middot;";let m=document.createElement("span");m.className="mono",m.textContent=e,s.append(n,i,c,d,m);let u=document.createElement("button");return u.className="theme-toggle",u.textContent=this.getAttribute("theme")==="dark"?"Light":"Dark",u.addEventListener("click",()=>{let y=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",y);try{localStorage.setItem("writetrack-v4-theme",y)}catch{}}),t.append(s,u),t}buildSummary(a){let e=document.createElement("section");e.className="summary";let t=document.createElement("div");t.className="summary-headline";let s=document.createElement("h1");s.textContent="Session Scorecard";let n=rt.filter(d=>W(this.getIndicatorCode(a,d))==="pass").length,i=document.createElement("span");i.className="tally",i.textContent=`${n} of ${rt.length} clear`,t.append(s,i),e.appendChild(t);let c=document.createElement("div");c.className="summary-stats";let l=ot(a.temporalPatterns.metrics.sessionDurationMs);c.innerHTML=`<span>${v(l)} duration</span><span class="sep">&middot;</span><span>${a.keydownCount} keystrokes</span>`,e.appendChild(c);for(let d of rt)if(W(this.getIndicatorCode(a,d))==="flag"){let m=document.createElement("div");m.className="summary-flag";let u=at(d,a);m.innerHTML=`<strong>Flagged</strong> ${v(I[d]??d)}\u2009\u2014\u2009${v(u)}`,e.appendChild(m)}return e}buildTierLabel(a){let e=document.createElement("div");return e.className="tier-label",e.textContent=a,e}buildGrid(a,e){let t=document.createElement("div");t.className="indicator-grid",t.id=`grid-${a}`;let s=a===1?mt:ut;for(let n of s)t.appendChild(this.buildCell(n,e));return t}buildCell(a,e){let t=this.getIndicatorCode(e,a),n=W(t)==="flag",i=document.createElement("div");i.className="cell"+(n?" flagged":""),i.setAttribute("data-category",a),i.addEventListener("click",()=>this.selectCell(a));let c=document.createElement("div");c.className="cell-header";let l=document.createElement("div");l.className="cell-name-col";let d=document.createElement("span");d.className="cell-name",d.textContent=I[a]??a,l.appendChild(d);let m=document.createElement("span");m.className=`cell-status ${n?"flagged":"clear"}`,m.textContent=n?"flagged":"clear",c.append(l,m),i.appendChild(c);let u=document.createElement("div");u.className="cell-chart",i.appendChild(u);let p=nt(a,e),y=ce[a];if(a==="physicalPlausibility"&&!n)if(p.every(b=>b.value==="0"||b.value==="0%")){let b=document.createElement("div");b.className="cell-allclear",b.innerHTML='<span class="cell-allclear-dot"></span>No anomalies detected',i.appendChild(b)}else i.appendChild(this.buildCellMetrics(p,y));else i.appendChild(this.buildCellMetrics(p,y));let h=document.createElement("div");return h.className="cell-affordance",h.innerHTML='<span>Details</span><span class="cell-affordance-arrow">&#x25B8;</span>',i.appendChild(h),i}buildCellMetrics(a,e){let t=document.createElement("div");t.className="cell-metrics";for(let s of e){let n=a[s];if(!n)continue;let i=document.createElement("div");i.className="cell-metric",i.innerHTML=`<span class="cell-metric-label">${v(n.label)}</span><span class="cell-metric-value">${v(n.value)}</span>`,t.appendChild(i)}return t}buildDetailPanel(a){let e=document.createElement("div");e.className="detail-panel",e.id=`detail-${a}`;let t=document.createElement("button");t.className="detail-close",t.setAttribute("aria-label","Close detail"),t.innerHTML="&times; Close",t.addEventListener("click",n=>{n.stopPropagation(),this.closeDetail(a)}),e.appendChild(t);let s=document.createElement("div");return s.className="detail-inner",s.id=`detail-${a}-inner`,e.appendChild(s),e}selectCell(a){var d;let e=(d=this._data)==null?void 0:d.analysis;if(!e)return;let t=$t[a],s=this.shadow.getElementById(`detail-${t}`),n=this.shadow.getElementById(`detail-${t}-inner`);if(!s||!n)return;let i=this.shadow.getElementById(`grid-${t}`);if(i==null||i.querySelectorAll(".cell").forEach(m=>m.classList.remove("selected")),this.t[t]===a){this.collapsePanel(s),this.t[t]=null;return}let c=this.t[t]!==null;this.t[t]=a;let l=i==null?void 0:i.querySelector(`[data-category="${a}"]`);l==null||l.classList.add("selected"),this.populateDetail(n,a,e),c?requestAnimationFrame(()=>{let m=n.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(a,!1);u&&m.replaceChildren(u)}}):this.expandPanel(s,()=>{let m=n.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(a,!1);u&&m.replaceChildren(u)}})}populateDetail(a,e,t){let s=this.getIndicatorCode(t,e),i=W(s)==="flag",c='<div class="detail-head">';c+=`<span class="detail-name">${v(I[e]??e)}</span>`,c+=`<span class="detail-code">${v(s??"")}</span>`,c+=`<span class="detail-status-label ${i?"flagged":"clear"}">${i?"flagged":"clear"}</span>`,c+="</div>";let l=at(e,t);c+=`<p class="detail-summary">${st(l)}</p>`,c+='<div class="detail-chart-area"></div>';let d=de[e];c+=`<div class="detail-chart-caption">${v(d.name)} \u2014 ${v(d.desc)}</div>`;let m=nt(e,t);c+='<div class="detail-metrics">';for(let p of m)c+=`<div class="detail-metric"><span class="detail-metric-value">${v(p.value)}</span><span class="detail-metric-label">${v(p.label)}</span></div>`;c+="</div>";let u=pt(e);u&&(c+=`<p class="detail-explainer">${st(u)}</p>`),a.innerHTML=c}closeDetail(a){let e=this.shadow.getElementById(`detail-${a}`);if(!e)return;let t=this.shadow.getElementById(`grid-${a}`);t==null||t.querySelectorAll(".cell").forEach(s=>s.classList.remove("selected")),this.collapsePanel(e),this.t[a]=null}expandPanel(a,e){let t=a.querySelector(".detail-inner");a.style.height="0px",a.style.display="block",a.offsetHeight,a.style.height=`${t.offsetHeight+40}px`;let s=()=>{a.style.height="auto",e==null||e()};a.addEventListener("transitionend",s,{once:!0})}collapsePanel(a){a.style.height=`${a.scrollHeight}px`,a.offsetHeight,a.style.height="0px";let e=()=>{a.style.display=""};a.addEventListener("transitionend",e,{once:!0})}getIndicatorCode(a,e){var s;let t=a[e];return(s=t==null?void 0:t.indicator)==null?void 0:s.code}getComputedColors(){let a=getComputedStyle(this);return{line:a.getPropertyValue("--wt-scorecard-chart-line").trim()||"#1C1B18",accent:a.getPropertyValue("--wt-scorecard-chart-accent").trim()||"#2B7A5D",flagged:a.getPropertyValue("--wt-scorecard-chart-flagged").trim()||"#B8412D",border:a.getPropertyValue("--wt-scorecard-border").trim()||"#E0DED6",tertiary:a.getPropertyValue("--wt-scorecard-text-tertiary").trim()||"#706E64"}}getChartWidth(a,e){var s;let t=e?`[data-category="${a}"] .cell-chart`:`#detail-${$t[a]}-inner .detail-chart-area`;return((s=this.shadow.querySelector(t))==null?void 0:s.getBoundingClientRect().width)??300}plotOpts(a,e,t,s,n){return{width:a,height:e?52:200,marginTop:e?4:36,marginRight:e?0:16,marginBottom:e?4:44,marginLeft:e?0:55,x:e?{axis:null,...s}:{...s},y:e?{axis:null,...n}:{...n},style:{background:"transparent",color:t.tertiary,fontFamily:"var(--wt-scorecard-font-data)",fontSize:"10px"}}}plotCategory(a,e){var d;if(!((d=this._data)!=null&&d.analysis))return null;let{data:t,analysis:s}=this._data,n=this.getComputedColors(),i=this.getIndicatorCode(s,a),l=W(i)==="flag"?n.flagged:n.accent;switch(a){case"contentOrigin":return this.plotContentOrigin(s,e,n);case"timingAuthenticity":return this.plotTimingAuthenticity(s,e,n,l);case"revisionBehavior":return this.plotRevisionBehavior(t,e,n);case"sessionContinuity":return this.plotSessionContinuity(t,s,e,n,l);case"physicalPlausibility":return this.plotPhysicalPlausibility(t,e,n);case"temporalPatterns":return this.plotTemporalPatterns(s,e,n,l)}}renderAllCharts(){this.shadow.querySelectorAll(".cell-chart").forEach(a=>{let e=a.closest(".cell"),t=e==null?void 0:e.getAttribute("data-category");if(!t)return;let s=this.plotCategory(t,!0);s&&a.replaceChildren(s)})}rerenderAllCharts(){this.renderAllCharts();for(let a of[1,2]){let e=this.t[a];if(e){let t=this.shadow.querySelector(`#detail-${a}-inner .detail-chart-area`);if(t){let s=this.plotCategory(e,!1);s&&t.replaceChildren(s)}}}}plotContentOrigin(a,e,t){let s=H(a);if(s.length===0)return null;let n={typing:t.accent,paste:t.flagged,pause:t.border,tabAway:t.tertiary,autocomplete:t.flagged,navigating:t.line},i=s.map(d=>({...d,color:n[d.type]??t.line})),c=this.getChartWidth("contentOrigin",e),l=this.plotOpts(c,e,t,{label:"Time (s)"},{padding:.2});return f.plot({...l,marginLeft:e?0:8,y:{axis:null,padding:.2},marks:[f.barX(i,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5})]})}plotTimingAuthenticity(a,e,t,s){let n=Y(a);if(n.length===0)return null;let i=this.getChartWidth("timingAuthenticity",e),c=[f.dot(n,{x:"dwell",y:"flight",fill:s,fillOpacity:e?.4:.5,r:e?2:3,stroke:"none"})];if(!e){let l=n.reduce((m,u)=>m+u.dwell,0)/n.length,d=n.reduce((m,u)=>m+u.flight,0)/n.length;c.push(f.ruleX([l],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}),f.ruleY([d],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}))}return f.plot({...this.plotOpts(i,e,t,{label:"Dwell (ms)"},{label:"Flight (ms)"}),marginRight:e?4:12,marks:c})}plotRevisionBehavior(a,e,t){let s=et(a);if(s.length===0)return null;let n={insert:t.accent,delete:t.flagged,paste:t.line,cut:t.tertiary},i=s.map(l=>({...l,color:n[l.type]??t.line})),c=this.getChartWidth("revisionBehavior",e);return e?f.plot({...this.plotOpts(c,e,t),marks:[f.dot(i,{x:"time",y:()=>0,fill:"color",fillOpacity:.6,r:Math.min(3,Math.max(2,c/i.length/4)),stroke:"none"})],style:{background:"transparent"}}):f.plot({...this.plotOpts(c,e,t,{label:"Time (s)"},{label:null,domain:["insert","delete","paste","cut"]}),marginLeft:70,r:{range:[3,12]},marks:[f.dot(i,{x:"time",y:"type",r:"chars",fill:"color",fillOpacity:.7,stroke:"none"})]})}plotSessionContinuity(a,e,t,s,n){var m,u;let i=Q(a);if(i.length===0)return null;let c=this.getChartWidth("sessionContinuity",t),l=[f.areaY(i,{x:"time",y:"chars",fill:n,fillOpacity:.1,curve:"step-after"}),f.lineY(i,{x:"time",y:"chars",stroke:n,strokeWidth:1.5,curve:"step-after"})],d=((u=(m=e.sessionContinuity)==null?void 0:m.metrics)==null?void 0:u.changePoints)??[];if(d.length>0){let p=d[0].timestamp/1e3;l.push(f.ruleX([p],{stroke:s.flagged,strokeDasharray:"4,3",strokeWidth:1}))}if(!t){let p=i.filter(h=>h.isPaste),y=i.filter(h=>h.isCut);p.length>0&&l.push(f.dot(p,{x:"time",y:"chars",fill:s.accent,r:4,stroke:"none"})),y.length>0&&l.push(f.dot(y,{x:"time",y:"chars",fill:s.flagged,r:4,symbol:"diamond",stroke:"none"}))}return f.plot({...this.plotOpts(c,t,s,{label:"Time (s)"},{label:"Characters",grid:!0}),marks:l})}plotPhysicalPlausibility(a,e,t){let s=Z(a);if(s.keystrokes.length===0)return null;let n=this.getChartWidth("physicalPlausibility",e),i=[f.line(s.keystrokes,{x:"time",y:"position",stroke:t.line,strokeWidth:e?1:1.5,strokeOpacity:e?.6:.8})];return e||(s.pastes.length>0&&i.push(f.dot(s.pastes,{x:"time",y:"position",fill:t.accent,r:4,stroke:"none"})),s.cuts.length>0&&i.push(f.dot(s.cuts,{x:"time",y:"position",fill:t.flagged,r:4,stroke:"none"}))),f.plot({...this.plotOpts(n,e,t,{label:"Time (s)"},{label:"Position",reverse:!0}),marks:i})}plotTemporalPatterns(a,e,t,s){let n=z(a);if(n.length===0)return null;let i=this.getChartWidth("temporalPatterns",e);return f.plot({...this.plotOpts(i,e,t,{label:"Time (s)"},{label:"Speed (CPM)",grid:!0}),marks:[f.areaY(n,{x:"time",y:"speed",fill:s,fillOpacity:.12,curve:"natural"}),f.lineY(n,{x:"time",y:"speed",stroke:s,strokeWidth:1.5,curve:"natural"})]})}};it.tagName="wt-scorecard";export{g as BaseChart,I as CATEGORY_NAMES,G as CompositionTimeline,tt as CorrectionsBubble,U as DocumentGrowth,X as DocumentRibbon,J as EditWaterfall,Wt as GLOSSARY,D as IntegrityFooter,q as PauseDistribution,V as RhythmHeatmap,ct as SEGMENT_COLORS,lt as Sparkline,F as SpeedTimeline,mt as TIER1_CATEGORIES,ut as TIER2_CATEGORIES,it as WtScorecard,et as extractCorrectionBubbles,Q as extractGrowthData,yt as extractPasteMarkers,bt as extractPauseHistogram,Y as extractRhythmPairs,wt as extractRibbonData,H as extractSegments,gt as extractSeries,z as extractSpeedData,Z as extractWaterfallData,ot as formatDuration,pt as generateCaption,at as generateSummary,nt as getMetrics,W as getStatus,Jt as isPass,st as wrapTerms};
359
+ `+ue}attributeChangedCallback(r,a,t){if(r==="theme"&&this._data&&this.hasRendered){let s=this.shadow.querySelector(".theme-toggle");s&&(s.textContent=t==="dark"?"Light":"Dark");let o=this.shadow.querySelector("wt-integrity-footer");o&&t&&o.setAttribute("theme",t),requestAnimationFrame(()=>this.rerenderAllCharts());return}super.attributeChangedCallback(r,a,t)}render(){var m;if(!((m=this._data)!=null&&m.analysis))return;let{data:r,analysis:a}=this._data;this.t={1:null,2:null};let t=document.createElement("div");t.className="page",t.appendChild(this.buildHeader(a,r.metadata.sessionId??"")),t.appendChild(this.buildSummary(a)),t.appendChild(this.buildTierLabel("Primary Evidence"));let s=this.buildGrid(1,a);t.appendChild(s);let o=this.buildDetailPanel(1);t.appendChild(o),t.appendChild(this.buildTierLabel("Supporting Context"));let i=this.buildGrid(2,a);t.appendChild(i);let c=this.buildDetailPanel(2);t.appendChild(c);let l=document.createElement("wt-integrity-footer"),d=this.getAttribute("theme");d&&l.setAttribute("theme",d),Tt(l),l.setData({integrity:a.integrity,outputSignature:a.outputSignature,sessionId:r.metadata.sessionId??""}),t.appendChild(l),this.replaceChart(t),requestAnimationFrame(()=>{this.renderAllCharts()})}buildHeader(r,a){let t=document.createElement("header");t.className="header";let s=document.createElement("div");s.className="header-meta";let o=document.createElement("span");o.textContent=`WriteTrack v${r.version}`;let i=document.createElement("span");i.className="sep",i.innerHTML="&middot;";let c=document.createElement("span"),l=new Date(r.analyzedAt);c.textContent=l.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"});let d=document.createElement("span");d.className="sep",d.innerHTML="&middot;";let m=document.createElement("span");m.className="mono",m.textContent=a,s.append(o,i,c,d,m);let u=document.createElement("button");return u.className="theme-toggle",u.textContent=this.getAttribute("theme")==="dark"?"Light":"Dark",u.addEventListener("click",()=>{let y=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",y);try{localStorage.setItem("writetrack-v4-theme",y)}catch{}}),t.append(s,u),t}buildSummary(r){let a=document.createElement("section");a.className="summary";let t=document.createElement("div");t.className="summary-headline";let s=document.createElement("h1");s.textContent="Session Scorecard";let o=rt.filter(d=>M(this.getIndicatorCode(r,d))==="pass").length,i=document.createElement("span");i.className="tally",i.textContent=`${o} of ${rt.length} clear`,t.append(s,i),a.appendChild(t);let c=document.createElement("div");c.className="summary-stats";let l=ot(r.temporalPatterns.metrics.sessionDurationMs);c.innerHTML=`<span>${v(l)} duration</span><span class="sep">&middot;</span><span>${r.keydownCount} keystrokes</span>`,a.appendChild(c);for(let d of rt)if(M(this.getIndicatorCode(r,d))==="flag"){let m=document.createElement("div");m.className="summary-flag";let u=at(d,r);m.innerHTML=`<strong>Flagged</strong> ${v(I[d]??d)}\u2009\u2014\u2009${v(u)}`,a.appendChild(m)}return a}buildTierLabel(r){let a=document.createElement("div");return a.className="tier-label",a.textContent=r,a}buildGrid(r,a){let t=document.createElement("div");t.className="indicator-grid",t.id=`grid-${r}`;let s=r===1?mt:ut;for(let o of s)t.appendChild(this.buildCell(o,a));return t}buildCell(r,a){let t=this.getIndicatorCode(a,r),o=M(t)==="flag",i=document.createElement("div");i.className="cell"+(o?" flagged":""),i.setAttribute("data-category",r),i.addEventListener("click",()=>this.selectCell(r));let c=document.createElement("div");c.className="cell-header";let l=document.createElement("div");l.className="cell-name-col";let d=document.createElement("span");d.className="cell-name",d.textContent=I[r]??r,l.appendChild(d);let m=document.createElement("span");m.className=`cell-status ${o?"flagged":"clear"}`,m.textContent=o?"flagged":"clear",c.append(l,m),i.appendChild(c);let u=document.createElement("div");u.className="cell-chart",i.appendChild(u);let p=nt(r,a),y=de[r];if(r==="physicalPlausibility"&&!o)if(p.every(b=>b.value==="0"||b.value==="0%")){let b=document.createElement("div");b.className="cell-allclear",b.innerHTML='<span class="cell-allclear-dot"></span>No anomalies detected',i.appendChild(b)}else i.appendChild(this.buildCellMetrics(p,y));else i.appendChild(this.buildCellMetrics(p,y));let h=document.createElement("div");return h.className="cell-affordance",h.innerHTML='<span>Details</span><span class="cell-affordance-arrow">&#x25B8;</span>',i.appendChild(h),i}buildCellMetrics(r,a){let t=document.createElement("div");t.className="cell-metrics";for(let s of a){let o=r[s];if(!o)continue;let i=document.createElement("div");i.className="cell-metric",i.innerHTML=`<span class="cell-metric-label">${v(o.label)}</span><span class="cell-metric-value">${v(o.value)}</span>`,t.appendChild(i)}return t}buildDetailPanel(r){let a=document.createElement("div");a.className="detail-panel",a.id=`detail-${r}`;let t=document.createElement("button");t.className="detail-close",t.setAttribute("aria-label","Close detail"),t.innerHTML="&times; Close",t.addEventListener("click",o=>{o.stopPropagation(),this.closeDetail(r)}),a.appendChild(t);let s=document.createElement("div");return s.className="detail-inner",s.id=`detail-${r}-inner`,a.appendChild(s),a}selectCell(r){var d;let a=(d=this._data)==null?void 0:d.analysis;if(!a)return;let t=$t[r],s=this.shadow.getElementById(`detail-${t}`),o=this.shadow.getElementById(`detail-${t}-inner`);if(!s||!o)return;let i=this.shadow.getElementById(`grid-${t}`);if(i==null||i.querySelectorAll(".cell").forEach(m=>m.classList.remove("selected")),this.t[t]===r){this.collapsePanel(s),this.t[t]=null;return}let c=this.t[t]!==null;this.t[t]=r;let l=i==null?void 0:i.querySelector(`[data-category="${r}"]`);l==null||l.classList.add("selected"),this.populateDetail(o,r,a),c?requestAnimationFrame(()=>{let m=o.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(r,!1);u&&m.replaceChildren(u)}}):this.expandPanel(s,()=>{let m=o.querySelector(".detail-chart-area");if(m){let u=this.plotCategory(r,!1);u&&m.replaceChildren(u)}})}populateDetail(r,a,t){let s=this.getIndicatorCode(t,a),i=M(s)==="flag",c='<div class="detail-head">';c+=`<span class="detail-name">${v(I[a]??a)}</span>`,c+=`<span class="detail-code">${v(s??"")}</span>`,c+=`<span class="detail-status-label ${i?"flagged":"clear"}">${i?"flagged":"clear"}</span>`,c+="</div>";let l=at(a,t);c+=`<p class="detail-summary">${st(l)}</p>`,c+='<div class="detail-chart-area"></div>';let d=me[a];c+=`<div class="detail-chart-caption">${v(d.name)} \u2014 ${v(d.desc)}</div>`;let m=nt(a,t);c+='<div class="detail-metrics">';for(let p of m)c+=`<div class="detail-metric"><span class="detail-metric-value">${v(p.value)}</span><span class="detail-metric-label">${v(p.label)}</span></div>`;c+="</div>";let u=pt(a);u&&(c+=`<p class="detail-explainer">${st(u)}</p>`),r.innerHTML=c}closeDetail(r){let a=this.shadow.getElementById(`detail-${r}`);if(!a)return;let t=this.shadow.getElementById(`grid-${r}`);t==null||t.querySelectorAll(".cell").forEach(s=>s.classList.remove("selected")),this.collapsePanel(a),this.t[r]=null}expandPanel(r,a){let t=r.querySelector(".detail-inner");r.style.height="0px",r.style.display="block",r.offsetHeight,r.style.height=`${t.offsetHeight+40}px`;let s=()=>{r.style.height="auto",a==null||a()};r.addEventListener("transitionend",s,{once:!0})}collapsePanel(r){r.style.height=`${r.scrollHeight}px`,r.offsetHeight,r.style.height="0px";let a=()=>{r.style.display=""};r.addEventListener("transitionend",a,{once:!0})}getIndicatorCode(r,a){var s;let t=r[a];return(s=t==null?void 0:t.indicator)==null?void 0:s.code}getComputedColors(){let r=getComputedStyle(this);return{line:r.getPropertyValue("--wt-scorecard-chart-line").trim()||"#1C1B18",accent:r.getPropertyValue("--wt-scorecard-chart-accent").trim()||"#2B7A5D",flagged:r.getPropertyValue("--wt-scorecard-chart-flagged").trim()||"#B8412D",border:r.getPropertyValue("--wt-scorecard-border").trim()||"#E0DED6",tertiary:r.getPropertyValue("--wt-scorecard-text-tertiary").trim()||"#706E64"}}getChartWidth(r,a){var s;let t=a?`[data-category="${r}"] .cell-chart`:`#detail-${$t[r]}-inner .detail-chart-area`;return((s=this.shadow.querySelector(t))==null?void 0:s.getBoundingClientRect().width)??300}plotOpts(r,a,t,s,o){return{width:r,height:a?52:200,marginTop:a?4:36,marginRight:a?0:16,marginBottom:a?4:44,marginLeft:a?0:55,x:a?{axis:null,...s}:{...s},y:a?{axis:null,...o}:{...o},style:{background:"transparent",color:t.tertiary,fontFamily:"var(--wt-scorecard-font-data)",fontSize:"10px"}}}plotCategory(r,a){var d;if(!((d=this._data)!=null&&d.analysis))return null;let{data:t,analysis:s}=this._data,o=this.getComputedColors(),i=this.getIndicatorCode(s,r),l=M(i)==="flag"?o.flagged:o.accent;switch(r){case"contentOrigin":return this.plotContentOrigin(s,a,o);case"timingAuthenticity":return this.plotTimingAuthenticity(s,a,o,l);case"revisionBehavior":return this.plotRevisionBehavior(t,a,o);case"sessionContinuity":return this.plotSessionContinuity(t,s,a,o,l);case"physicalPlausibility":return this.plotPhysicalPlausibility(t,a,o);case"temporalPatterns":return this.plotTemporalPatterns(s,a,o,l)}}renderAllCharts(){this.shadow.querySelectorAll(".cell-chart").forEach(r=>{let a=r.closest(".cell"),t=a==null?void 0:a.getAttribute("data-category");if(!t)return;let s=this.plotCategory(t,!0);s&&r.replaceChildren(s)})}rerenderAllCharts(){this.renderAllCharts();for(let r of[1,2]){let a=this.t[r];if(a){let t=this.shadow.querySelector(`#detail-${r}-inner .detail-chart-area`);if(t){let s=this.plotCategory(a,!1);s&&t.replaceChildren(s)}}}}plotContentOrigin(r,a,t){let s=H(r);if(s.length===0)return null;let o={typing:t.accent,paste:t.flagged,pause:t.border,tabAway:t.tertiary,autocomplete:t.flagged,navigating:t.line},i=s.map(d=>({...d,color:o[d.type]??t.line})),c=this.getChartWidth("contentOrigin",a),l=this.plotOpts(c,a,t,{label:"Time (s)"},{padding:.2});return f.plot({...l,marginLeft:a?0:8,y:{axis:null,padding:.2},marks:[f.barX(i,{x1:"start",x2:"end",fill:"color",y:()=>"Activity",inset:.5})]})}plotTimingAuthenticity(r,a,t,s){let o=Y(r);if(o.length===0)return null;let i=this.getChartWidth("timingAuthenticity",a),c=[f.dot(o,{x:"dwell",y:"flight",fill:s,fillOpacity:a?.4:.5,r:a?2:3,stroke:"none"})];if(!a){let l=o.reduce((m,u)=>m+u.dwell,0)/o.length,d=o.reduce((m,u)=>m+u.flight,0)/o.length;c.push(f.ruleX([l],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}),f.ruleY([d],{stroke:t.accent,strokeDasharray:"4,4",strokeWidth:1}))}return f.plot({...this.plotOpts(i,a,t,{label:"Dwell (ms)"},{label:"Flight (ms)"}),marginRight:a?4:12,marks:c})}plotRevisionBehavior(r,a,t){let s=et(r);if(s.length===0)return null;let o={insert:t.accent,delete:t.flagged,paste:t.line,cut:t.tertiary},i=s.map(l=>({...l,color:o[l.type]??t.line})),c=this.getChartWidth("revisionBehavior",a);return a?f.plot({...this.plotOpts(c,a,t),marks:[f.dot(i,{x:"time",y:()=>0,fill:"color",fillOpacity:.6,r:Math.min(3,Math.max(2,c/i.length/4)),stroke:"none"})],style:{background:"transparent"}}):f.plot({...this.plotOpts(c,a,t,{label:"Time (s)"},{label:null,domain:["insert","delete","paste","cut"]}),marginLeft:70,r:{range:[3,12]},marks:[f.dot(i,{x:"time",y:"type",r:"chars",fill:"color",fillOpacity:.7,stroke:"none"})]})}plotSessionContinuity(r,a,t,s,o){var m,u;let i=Q(r);if(i.length===0)return null;let c=this.getChartWidth("sessionContinuity",t),l=[f.areaY(i,{x:"time",y:"chars",fill:o,fillOpacity:.1,curve:"step-after"}),f.lineY(i,{x:"time",y:"chars",stroke:o,strokeWidth:1.5,curve:"step-after"})],d=((u=(m=a.sessionContinuity)==null?void 0:m.metrics)==null?void 0:u.changePoints)??[];if(d.length>0){let p=d[0].timestamp/1e3;l.push(f.ruleX([p],{stroke:s.flagged,strokeDasharray:"4,3",strokeWidth:1}))}if(!t){let p=i.filter(h=>h.isPaste),y=i.filter(h=>h.isCut);p.length>0&&l.push(f.dot(p,{x:"time",y:"chars",fill:s.accent,r:4,stroke:"none"})),y.length>0&&l.push(f.dot(y,{x:"time",y:"chars",fill:s.flagged,r:4,symbol:"diamond",stroke:"none"}))}return f.plot({...this.plotOpts(c,t,s,{label:"Time (s)"},{label:"Characters",grid:!0}),marks:l})}plotPhysicalPlausibility(r,a,t){let s=Z(r);if(s.keystrokes.length===0)return null;let o=this.getChartWidth("physicalPlausibility",a),i=[f.line(s.keystrokes,{x:"time",y:"position",stroke:t.line,strokeWidth:a?1:1.5,strokeOpacity:a?.6:.8})];return a||(s.pastes.length>0&&i.push(f.dot(s.pastes,{x:"time",y:"position",fill:t.accent,r:4,stroke:"none"})),s.cuts.length>0&&i.push(f.dot(s.cuts,{x:"time",y:"position",fill:t.flagged,r:4,stroke:"none"}))),f.plot({...this.plotOpts(o,a,t,{label:"Time (s)"},{label:"Position",reverse:!0}),marks:i})}plotTemporalPatterns(r,a,t,s){let o=F(r);if(o.length===0)return null;let i=this.getChartWidth("temporalPatterns",a);return f.plot({...this.plotOpts(i,a,t,{label:"Time (s)"},{label:"Speed (CPM)",grid:!0}),marks:[f.areaY(o,{x:"time",y:"speed",fill:s,fillOpacity:.12,curve:"natural"}),f.lineY(o,{x:"time",y:"speed",stroke:s,strokeWidth:1.5,curve:"natural"})]})}};it.tagName="wt-scorecard";export{g as BaseChart,I as CATEGORY_NAMES,G as CompositionTimeline,tt as CorrectionsBubble,U as DocumentGrowth,X as DocumentRibbon,J as EditWaterfall,Mt as GLOSSARY,D as IntegrityFooter,q as PauseDistribution,V as RhythmHeatmap,ct as SEGMENT_COLORS,lt as Sparkline,z as SpeedTimeline,mt as TIER1_CATEGORIES,ut as TIER2_CATEGORIES,it as WtScorecard,et as extractCorrectionBubbles,Q as extractGrowthData,yt as extractPasteMarkers,bt as extractPauseHistogram,Y as extractRhythmPairs,wt as extractRibbonData,H as extractSegments,gt as extractSeries,F as extractSpeedData,Z as extractWaterfallData,ot as formatDuration,pt as generateCaption,at as generateSummary,nt as getMetrics,M as getStatus,Jt as isPass,st as wrapTerms};
Binary file