@bitcobblers/wod-wiki-tools 0.43.2151 → 0.43.2152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/wod.cjs +1 -1
- package/dist/bin/wod.cjs.map +1 -1
- package/dist/bin/wod.mjs +2 -2
- package/dist/{chunk-W5WHFDZL.mjs → chunk-5VV67662.mjs} +3 -3
- package/dist/chunk-5VV67662.mjs.map +1 -0
- package/dist/{chunk-MCZPOCTC.mjs → chunk-NGBNYVXW.mjs} +4 -4
- package/dist/{chunk-MCZPOCTC.mjs.map → chunk-NGBNYVXW.mjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{scaffoldCatalog-5SXWHQTQ.mjs → scaffoldCatalog-RJC76TW2.mjs} +3 -3
- package/dist/{scaffoldCatalog-5SXWHQTQ.mjs.map → scaffoldCatalog-RJC76TW2.mjs.map} +1 -1
- package/dist/web/playground/assets/main-BNGxzpq1.css +2 -0
- package/dist/web/playground/assets/{main-CH2efPfj.js → main-Dqtuz8vM.js} +4 -4
- package/dist/web/playground/assets/{statementBuilderFlow-CazhcFP3.js → statementBuilderFlow-BxaSCews.js} +2 -2
- package/dist/web/playground/index.html +2 -2
- package/dist/web/{server/seed/core/chunks/canvas.2de5fbb9.json → playground/seed/core/chunks/canvas.4a0dd037.json} +1 -1
- package/dist/web/playground/seed/core/chunks/{efforts.9319895f.json → efforts.22170a07.json} +1 -1
- package/dist/web/playground/seed/core/manifest.json +7 -7
- package/dist/web/playground/seed/core/report.html +10 -10
- package/dist/web/server/assets/{main-CXyt6K52.js → main-59F7JOmq.js} +4 -4
- package/dist/web/server/assets/main-BNGxzpq1.css +2 -0
- package/dist/web/server/assets/{statementBuilderFlow-3pxq8hDy.js → statementBuilderFlow-XSY8fWC7.js} +2 -2
- package/dist/web/server/index.html +2 -2
- package/dist/web/{playground/seed/core/chunks/canvas.2de5fbb9.json → server/seed/core/chunks/canvas.4a0dd037.json} +1 -1
- package/dist/web/server/seed/core/chunks/{efforts.9319895f.json → efforts.22170a07.json} +1 -1
- package/dist/web/server/seed/core/manifest.json +7 -7
- package/dist/web/server/seed/core/report.html +10 -10
- package/package.json +6 -6
- package/dist/chunk-W5WHFDZL.mjs.map +0 -1
- package/dist/web/playground/assets/main-DajNgZgc.css +0 -2
- package/dist/web/server/assets/main-DajNgZgc.css +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-BFExl-KH.js","assets/rolldown-runtime-C0FnF6B9.js","assets/statementBuilderFlow-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-BFExl-KH.js","assets/rolldown-runtime-C0FnF6B9.js","assets/statementBuilderFlow-XSY8fWC7.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{$ as n,$n as r,$r as i,$t as a,A as o,An as s,Ar as c,B as l,Bn as u,Br as d,Bt as f,C as p,Cn as m,Cr as h,D as g,Dn as _,Dr as v,Dt as y,E as b,En as x,Er as S,Et as C,F as w,Fn as T,Fr as E,Ft as D,G as O,Gn as k,Gr as A,Gt as j,H as M,Hn as N,Hr as P,Ht as F,I,In as L,Ir as R,It as ee,J as z,Jn as te,Jr as ne,Jt as re,K as ie,Kn as ae,Kr as oe,Kt as B,L as se,Ln as V,Lr as ce,Lt as le,M as ue,Mn as de,Mr as fe,N as pe,Nn as me,Nr as he,O as ge,On as _e,Or as ve,P as ye,Pn as be,Pr as xe,Pt as Se,Q as Ce,Qn as we,Qr as Te,Qt as Ee,R as De,Rn as Oe,Rr as ke,Rt as Ae,S as je,Sn as Me,Sr as Ne,St as Pe,T as Fe,Tn as Ie,U as Le,Un as Re,Ur as ze,Ut as Be,V as Ve,Vn as He,Vr as Ue,Vt as We,W as Ge,Wn as Ke,Wr as qe,Wt as Je,X as Ye,Xr as Xe,Xt as Ze,Y as Qe,Yn as $e,Yr as et,Yt as tt,Z as nt,Zn as rt,Zr as it,Zt as at,_ as ot,_n as st,_r as ct,_t as lt,a as ut,ai as dt,an as ft,ar as pt,at as mt,b as ht,bn as gt,br as _t,bt as vt,c as yt,ci as bt,cn as xt,cr as St,ct as Ct,d as wt,di as Tt,dn as Et,dr as Dt,dt as Ot,ei as kt,en as At,er as jt,et as Mt,f as Nt,fi as Pt,fn as Ft,fr as It,ft as Lt,g as Rt,gn as zt,gr as Bt,gt as Vt,h as Ht,hn as Ut,hr as Wt,ht as Gt,i as Kt,ii as qt,in as Jt,ir as Yt,it as Xt,j as Zt,jn as Qt,jr as $t,k as en,kn as tn,kr as nn,l as rn,li as an,ln as on,lr as sn,lt as cn,m as ln,mn as un,mr as dn,mt as fn,n as pn,ni as mn,nn as hn,nr as gn,nt as _n,o as vn,oi as yn,on as bn,or as xn,ot as Sn,p as Cn,pn as wn,pr as Tn,pt as En,q as Dn,qn as On,qr as kn,qt as An,r as jn,ri as H,rn as Mn,rr as Nn,rt as Pn,s as Fn,si as In,sn as Ln,sr as Rn,st as zn,t as Bn,ti as Vn,tn as Hn,tr as Un,tt as Wn,u as Gn,ui as Kn,un as qn,ur as Jn,ut as Yn,v as Xn,vn as Zn,vr as Qn,vt as $n,w as er,wn as tr,wr as nr,wt as rr,x as ir,xn as ar,xr as or,xt as sr,y as cr,yn as lr,yr as ur,yt as dr,z as fr,zn as pr,zr as mr,zt as hr}from"./vendor-BFExl-KH.js";import{$ as gr,A as _r,B as U,C as vr,D as yr,E as br,F as xr,G as Sr,H as Cr,I as wr,J as Tr,K as Er,L as Dr,M as Or,N as kr,O as Ar,P as jr,Q as Mr,R as Nr,S as Pr,T as Fr,U as Ir,V as Lr,W as Rr,X as zr,Y as Br,Z as Vr,_ as Hr,a as Ur,at as Wr,b as Gr,c as Kr,ct as qr,d as Jr,et as Yr,f as Xr,g as Zr,h as Qr,i as $r,it as ei,j as ti,k as ni,l as ri,lt as ii,m as ai,n as oi,nt as si,o as ci,ot as li,p as ui,q as di,r as fi,rt as pi,s as mi,st as hi,t as gi,tt as _i,u as vi,ut as yi,v as bi,w as xi,x as Si,y as Ci,z as wi}from"./vendor-codemirror-BojMZ9SI.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ti=Kn(),W=e(Pt(),1),G=Te(),Ei=(0,W.createContext)({theme:`system`,setTheme:()=>null});function Di({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`}){let[r,i]=(0,W.useState)(()=>localStorage.getItem(n)||t);(0,W.useEffect)(()=>{let e=window.document.documentElement,t=()=>{if(e.classList.remove(`light`,`dark`),r===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t);return}e.classList.add(r)};if(t(),r===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>t();return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)}},[r]);let a=(0,W.useCallback)(e=>{localStorage.setItem(n,e),i(e)},[n]),o=(0,W.useMemo)(()=>({theme:r,setTheme:a}),[r,a]);return(0,G.jsx)(Ei.Provider,{value:o,children:e})}var Oi=()=>{let e=(0,W.useContext)(Ei);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function K(...e){return v(it(e))}function ki(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}var Ai=ve(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-input bg-background hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-10 px-4 py-2`,sm:`h-9 rounded-md px-3`,lg:`h-11 rounded-md px-8`,icon:`h-10 w-10`}},defaultVariants:{variant:`default`,size:`default`}}),q=W.memo(W.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>{let o=r?nn:`button`;return(0,G.jsx)(Xe,{as:o,className:K(Ai({variant:t,size:n,className:e})),ref:a,...i})}));q.displayName=`Button`;var ji=[`parser`,`dialect`,`user-plan`,`runtime`,`user-entry`],Mi={parser:`parser`,compiler:`dialect`,dialect:`dialect`,hinted:`dialect`,"user-plan":`user-plan`,runtime:`runtime`,tracked:`runtime`,analyzed:`runtime`,"analyzed-estimated":`runtime`,execution:`runtime`,user:`user-entry`,collected:`user-entry`};function Ni(e){return Mi[e??`parser`]??`parser`}var J=function(e){return e.Duration=`duration`,e.Spans=`spans`,e.SystemTime=`system-time`,e.Time=`time`,e.Elapsed=`elapsed`,e.Total=`total`,e.Rep=`rep`,e.Effort=`effort`,e.Equipment=`equipment`,e.Distance=`distance`,e.Rounds=`rounds`,e.CurrentRound=`current-round`,e.Action=`action`,e.Increment=`increment`,e.Group=`group`,e.Text=`text`,e.Resistance=`resistance`,e.Sound=`sound`,e.System=`system`,e.Label=`label`,e.Lap=`lap`,e.Metric=`metric`,e.Hint=`hint`,e.Custom=`custom`,e.Volume=`volume`,e.Intensity=`intensity`,e.Grade=`grade`,e.Load=`load`,e.Work=`work`,e.RIR=`rir`,e.SessionRPE=`session-rpe`,e.SessionLoad=`session-load`,e.METScore=`met-score`,e.TIS=`tis`,e.Calculated=`calculated`,e.Choice=`choice`,e}({}),Pi={parser:0,dialect:1,"user-plan":2,runtime:3,"user-entry":4};function Fi(e){return e.ownershipLayer??Ni(e.origin)}function Ii(e){return Pi[Fi(e)]??0}function Li(e){return e.map((e,t)=>{let n=Fi(e);return{metric:e,type:e.type,layer:n,layerRank:Pi[n]??0,index:t,isSuppressor:e.action===`suppress`}})}function Ri(e,t){return t?e.filter(e=>!(t.types&&!t.types.includes(e.type)||t.layers&&!t.layers.includes(e.layer))):[...e]}function zi(e){let t=new Map;for(let n of e){let e=t.get(n.type);if(e){e.push(n);continue}t.set(n.type,[n])}return t}function Bi(e){let t;for(let n of e)n.isSuppressor||(t==null||n.layerRank>t)&&(t=n.layerRank);return t}function Vi(e,t){return{metric:e.metric,type:e.type,layer:e.layer,outcome:t}}function Hi(e,t){return e.index-t.index}function Ui(e){let t=Li(e);return{raw(e){return Ri(t,e).map(e=>e.metric)},visible(e){let n=zi(Ri(t,e)),r=[];for(let e of n.values()){if(e.some(e=>e.isSuppressor))continue;let t=Bi(e);if(t!=null)for(let n of e)!n.isSuppressor&&n.layerRank===t&&r.push(n)}return r.sort(Hi),r.map(e=>e.metric)},byLayer(e){let n=Ri(t,e),r={};for(let e of ji)r[e]=[];for(let e of n)r[e.layer].push(e.metric);for(let e of ji)r[e]?.length===0&&delete r[e];return r},promotionCandidates(e){let n=zi(Ri(t,e)),r=[];for(let e of n.values()){let t=e.filter(e=>e.isSuppressor),n=e.filter(e=>!e.isSuppressor);if(n.length===0)continue;if(t.length>0){let e=Math.max(...n.map(e=>e.layerRank)),i=Math.max(...t.map(e=>e.layerRank));for(let t of n)t.layerRank===e&&r.push({metric:t.metric,type:t.type,layer:t.layer,reason:`suppressed`,blockedByLayer:ji[i]});continue}let i=Bi(n);if(i==null)continue;let a=n.filter(e=>e.layerRank<i);if(a.length===0)continue;let o=Math.max(...a.map(e=>e.layerRank));for(let e of a)e.layerRank===o&&r.push({metric:e.metric,type:e.type,layer:e.layer,reason:`shadowed-by-higher-layer`,blockedByLayer:ji[i]})}return r.sort((e,t)=>{let n=(Pi[t.layer]??0)-(Pi[e.layer]??0);return n===0?0:n}),r},explain(e){let n=zi(Ri(t,e)),r=[];for(let[e,t]of n.entries()){let n=t.some(e=>e.isSuppressor),i=n?void 0:Bi(t),a=t.map(e=>e.isSuppressor?Vi(e,`suppressor`):n?Vi(e,`hidden-by-suppressor`):i!=null&&e.layerRank===i?Vi(e,`visible`):Vi(e,`hidden-by-layer`));r.push({type:e,winnerLayer:i==null?void 0:ji[i],suppressed:n,entries:a})}return r}}}function Wi(e,t){let n=[...e];return(t?.types?.includes(J.Hint)??!1)||(n=n.filter(e=>e.type!==J.Hint)),t?(t.origins&&(n=n.filter(e=>t.origins.includes(e.origin??`parser`))),t.types&&(n=n.filter(e=>t.types.includes(e.type))),t.excludeTypes&&(n=n.filter(e=>!t.excludeTypes.includes(e.type))),n):n}var Gi=class{resolve(e,t){return Ui(Wi(e,t)).visible()}resolveOne(e,t){return this.resolve(e,{types:[t]})[0]}resolveAll(e,t){let n=e.filter(e=>e.type===t);return n.length<=1?n:[...n].sort((e,t)=>Ii(t)-Ii(e))}};function Ki(e){let t=e.split(/[\s_\-\u2010-\u2015]+/).filter(Boolean),n=[];for(let e of t){let t=e.replace(/([\p{Ll}\p{Nd}])(\p{Lu})/gu,`$1\0$2`).replace(/(\p{Lu})(\p{Lu}\p{Ll})/gu,`$1\0$2`);for(let e of t.split(`\0`))e&&n.push(e)}return n}function qi(e){let t=Ki(e);return t.length===0?``:t.map((e,t)=>{let n=e.toLowerCase();return t===0?n:n.charAt(0).toUpperCase()+n.slice(1)}).join(``)}function Ji(e){return e.split(`.`).map(qi).filter(e=>e.length>0).join(`.`)}function Yi(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(Array.isArray(e))return`array`;switch(typeof e){case`number`:return`number`;case`string`:return`string`;case`boolean`:return`boolean`;case`object`:return`object`;default:return`undefined`}}function Xi(e){return JSON.stringify([e.path,e.kind,e.dimension??null])}var Zi=class extends Error{code;constructor(e,t){super(t),this.name=`UnitConversionError`,this.code=e}},Qi=[{canonical:`m`,dimension:`distance`,factor:1,aliases:[`meter`,`meters`,`metre`,`metres`]},{canonical:`km`,dimension:`distance`,factor:1e3,aliases:[`kilometer`,`kilometers`,`kilometre`,`kilometres`]},{canonical:`cm`,dimension:`distance`,factor:.01,aliases:[`centimeter`,`centimeters`]},{canonical:`mm`,dimension:`distance`,factor:.001,aliases:[`millimeter`,`millimeters`]},{canonical:`ft`,dimension:`distance`,factor:.3048,aliases:[`foot`,`feet`]},{canonical:`in`,dimension:`distance`,factor:.0254,aliases:[`inch`,`inches`]},{canonical:`yd`,dimension:`distance`,factor:.9144,aliases:[`yard`,`yards`]},{canonical:`mi`,dimension:`distance`,factor:1609.344,aliases:[`mile`,`miles`]},{canonical:`kg`,dimension:`mass`,factor:1,aliases:[`kilogram`,`kilograms`,`kilo`,`kilos`]},{canonical:`g`,dimension:`mass`,factor:.001,aliases:[`gram`,`grams`]},{canonical:`lb`,dimension:`mass`,factor:.45359237,aliases:[`lbs`,`pound`,`pounds`]},{canonical:`ms`,dimension:`duration`,factor:.001,aliases:[`millisecond`,`milliseconds`]},{canonical:`s`,dimension:`duration`,factor:1,aliases:[`sec`,`secs`,`second`,`seconds`]},{canonical:`min`,dimension:`duration`,factor:60,aliases:[`mins`,`minute`,`minutes`]},{canonical:`h`,dimension:`duration`,factor:3600,aliases:[`hr`,`hrs`,`hour`,`hours`]},{canonical:`count`,dimension:`count`,factor:1},{canonical:`rep`,dimension:`count`,factor:1,aliases:[`reps`]},{canonical:`pull-up`,dimension:`count`,factor:1},{canonical:`thruster`,dimension:`count`,factor:1},{canonical:`problem`,dimension:`count`,factor:1},{canonical:`count/s`,dimension:`count-rate`,factor:1},{canonical:`bpm`,dimension:`count-rate`,factor:1/60},{canonical:`cal`,dimension:`energy`,factor:1,aliases:[`calorie`,`calories`]},{canonical:`kcal`,dimension:`energy`,factor:1e3,aliases:[`kilocalorie`,`kilocalories`]},{canonical:`m/s`,dimension:`speed`,factor:1},{canonical:`km/h`,dimension:`speed`,factor:1e3/3600,aliases:[`kmh`,`kph`]},{canonical:`mph`,dimension:`speed`,factor:1609.344/3600},{canonical:`min/km`,dimension:`pace`,factor:1},{canonical:`min/mi`,dimension:`pace`,factor:1e3/1609.344},{canonical:`s/m`,dimension:`pace`,factor:1/60},{canonical:`ratio`,dimension:`ratio`,factor:1,aliases:[`x`]},{canonical:`%`,dimension:`ratio`,factor:.01,aliases:[`pct`,`percent`]},{canonical:`au`,dimension:`ratio`,factor:1,aliases:[`AU`]},{canonical:`pts`,dimension:`ratio`,factor:1,aliases:[`point`,`points`]},{canonical:`rating`,dimension:`ratio`,factor:1,aliases:[`ratings`]}],$i=(()=>{let e=new Map;for(let t of Qi){e.set(t.canonical.toLowerCase(),t);for(let n of t.aliases??[])e.has(n.toLowerCase())||e.set(n.toLowerCase(),t)}return e})();function ea(e){if(typeof e==`string`)return $i.get(e.trim().toLowerCase())}function ta(e){return ea(e)?.dimension}var na=Object.freeze({mass:`kg`,distance:`m`,duration:`s`,count:`count`,"count-rate":`count/s`,energy:`cal`,speed:`m/s`,pace:`min/km`,ratio:void 0});function ra(e){return na[e]}function ia(e,t,n){let r=ea(t);if(!r)throw new Zi(`unknown-unit`,`Unknown unit "${t}"`);let i=ea(n);if(!i)throw new Zi(`unknown-unit`,`Unknown unit "${n}"`);if(r.dimension!==i.dimension)throw new Zi(`dimension-mismatch`,`Cannot convert ${t} (${r.dimension}) to ${n} (${i.dimension})`);if(r.dimension===`ratio`&&r.canonical!==i.canonical&&r.canonical!==`ratio`&&i.canonical!==`ratio`)throw new Zi(`scale-mismatch`,`Named scales ${t} and ${n} are not interchangeable`);if(!Number.isFinite(e))throw new Zi(`non-finite`,`Non-finite value cannot be converted`);return e*r.factor/i.factor}var aa=`references`,oa=[`explicit`,`split`,`whole`,`default`,`none`];function sa(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.kind===`effort`||t.kind===`equipment`)&&typeof t.slug==`string`&&!!t.slug&&typeof t.label==`string`}function ca(e){return!e||typeof e!=`object`?!1:typeof e.reason==`string`}function la(e){let t=e?.[aa];if(!t||typeof t!=`object`)return;let n=t;if(!(typeof n.matched!=`string`||!oa.includes(n.matched))&&typeof n.source==`string`&&!(n.refs!==void 0&&(!Array.isArray(n.refs)||!n.refs.every(sa)))&&!(n.diagnostics!==void 0&&(!Array.isArray(n.diagnostics)||!n.diagnostics.every(ca))))return t}var ua=class{line;startOffset;endOffset;length;columnStart;columnEnd;raw;constructor(e,t,n,r,i=0,a=0,o=``){this.line=e,this.startOffset=t,this.endOffset=n,this.length=r,this.columnStart=i,this.columnEnd=a,this.raw=o}},da=class e{_metrics;_indexedLength=0;_resolver=new Gi;id;constructor(t,n=`metrics`){if(this.id=n,t instanceof e){this._metrics=t.toArray(),this.syncIndexProperties();return}this._metrics=Array.isArray(t)?[...t]:[],this.syncIndexProperties()}static from(t,n=`metrics`){if(t instanceof e)return t.clone(n);if(Array.isArray(t))return new e(t,n);if(typeof t==`object`&&t&&`_metrics`in t){let r=t._metrics;if(Array.isArray(r))return new e(r,n)}return e.empty(n)}static empty(t=`metrics`){return new e(void 0,t)}clone(t=this.id){return new e(this._metrics,t)}get all(){return[...this._metrics]}get length(){return this._metrics.length}get size(){return this._metrics.length}get isEmpty(){return this._metrics.length===0}getByType(e){let t=this._metrics.filter(t=>t.type===e||t.name===e);return t.length<=1?t:[...t].sort((e,t)=>Ii(t)-Ii(e))}getFirst(e){let t=this.getByType(e);return t.length>0?t[0]:void 0}get(e){return this.getFirst(e)}has(e){return this._metrics.some(t=>t.type===e||t.name===e)}hasMetric(e){return this.has(e)}getDisplayMetrics(e){return this.resolve(e)}getMetric(e){return this._resolver.resolveOne(this._metrics,e)}getAllMetricsByType(e){return this.getByType(e)}get rawMetrics(){return this.toArray()}getAll(){return this.toArray()}getByOrigin(e){return this._metrics.filter(t=>(t.origin??`parser`)===e)}resolve(e){return this._resolver.resolve(this._metrics,e)}add(...e){return this._metrics.push(...e),this.syncIndexProperties(),this}remove(e){let t=[];return this._metrics=this._metrics.filter(n=>!e(n)||(t.push(n),!1)),this.syncIndexProperties(),t}removeByType(e){return this.remove(t=>t.type===e||t.name===e)}clear(){return this._metrics=[],this.syncIndexProperties(),this}replaceByType(e,...t){let n=this.removeByType(e);return this._metrics.push(...t),this.syncIndexProperties(),n}merge(t){let n=t instanceof e?t._metrics:Array.isArray(t)?t:t.metrics.toArray(),r=new Map;for(let e of n){let t=r.get(e.type)??[];t.push(e),r.set(e.type,t)}for(let[e,t]of r){let n=this._metrics.filter(t=>t.type===e);if(n.length===0){this._metrics.push(...t);continue}let r=Math.max(...n.map(e=>Ii(e))),i=Math.max(...t.map(e=>Ii(e)));i>r?(this._metrics=this._metrics.filter(t=>t.type!==e),this._metrics.push(...t)):i===r&&this._metrics.push(...t)}return this.syncIndexProperties(),this}[Symbol.iterator](){return this._metrics[Symbol.iterator]()}filter(e){return this._metrics.filter(e)}map(e){return this._metrics.map(e)}flatMap(e){return this._metrics.flatMap(e)}find(e){return this._metrics.find(e)}some(e){return this._metrics.some(e)}every(e){return this._metrics.every(e)}toArray(){return[...this._metrics]}get raw(){return this._metrics}syncIndexProperties(){for(let e=0;e<this._indexedLength;e++)delete this[e];for(let e=0;e<this._metrics.length;e++)this[e]=this._metrics[e];this._indexedLength=this._metrics.length}toString(){return`MetricContainer(${this._metrics.length})[${this._metrics.map(e=>e.type).join(`, `)}]`}},fa=class{exerciseId;line;text;raw;dialect;hasMetric(e){return this.metricContainer.hasMetric(e)}getDisplayMetrics(e){return this.metricContainer.getDisplayMetrics(e)}getMetric(e){return this.metricContainer.getMetric(e)}getAllMetricsByType(e){return this.metricContainer.getAllMetricsByType(e)}get rawMetrics(){return this.metricContainer.rawMetrics}get metricContainer(){return this.metrics instanceof da?this.metrics:da.from(this.metrics,this.id)}},pa=class extends fa{id=0;parent;children=[];meta=new ua(0,0,0,0);_metrics=da.empty();metricMeta=new Map;isLeaf;get metrics(){return this._metrics}set metrics(e){this._metrics=da.from(e,this.id)}constructor(e){super(),e&&(Object.assign(this,e),e.metrics&&(this.metrics=da.from(e.metrics,this.id)),this.metricMeta||=new Map)}},ma=class e extends fa{static nextId=1e6;id;outputType;timeSpan;sourceStatementId;sourceBlockKey;stackLevel;metrics;metricMeta;completionReason;parent;children;isLeaf;meta;statement;timestamp;constructor(t,n,r){if(super(),t&&`outputType`in t&&`timeSpan`in t){let n=t;this.id=e.nextId++,this.outputType=n.outputType,this.timeSpan=n.timeSpan,this.sourceBlockKey=n.sourceBlockKey??``,this.sourceStatementId=n.sourceStatementId,this.line=n.line,this.text=n.text,this.dialect=n.dialect,this.stackLevel=n.stackLevel??0,this.metrics=da.from(n.metrics,this.id),this.metricMeta=n.metricMeta??new Map,this.completionReason=n.completionReason,this.parent=n.parent,this.children=n.children??[],this.isLeaf=this.children.length===0,this.meta=new ua(0,0,0,0)}else{let i=t;this.id=e.nextId++,this.statement=i,this.outputType=`segment`,this.timeSpan={started:r??Date.now()},this.sourceBlockKey=``,this.sourceStatementId=typeof i?.id==`number`?i.id:void 0,this.stackLevel=0,this.metrics=da.from(n,this.id),this.metricMeta=new Map,this.children=[],this.isLeaf=!0,this.meta=i?.meta??new ua(0,0,0,0),this.line=i?.line,this.text=i?.text,this.dialect=i?.dialect,this.timestamp=r??Date.now()}}static resetIdCounter(t=1e6){e.nextId=t}},ha=class{value;constructor(e){this.value=e??(typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():Math.random().toString(36).slice(2))}toString(){return this.value}valueOf(){return this.value}equals(e){return this.value===e?.value}};function ga(e){let t=e.trim(),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return`bc-${(n>>>0).toString(16).padStart(8,`0`)}`}var _a=[`segment`,`system`,`load`,`event`,`compiler`,`completion`,`analytics`,`wellness`];function va(e){return e===`time`?`run`:e===`log`?`log`:null}function ya(e){let t=e.trim();return t.startsWith(`notebook/`)||t.startsWith(`notebook:`)?t.slice(9):t}function ba(e){return`notebook/${ya(e)}`}function xa(e){return e.seedOrigin!==`seed`}var Sa=[`playground-run-tip`,`attention`,`code-example`,`syntax-group`];function Ca(e){let t=e.match(/^`{3,}(time|log)(?::([\w-]+))?\s*$/i);return t?{dialect:t[1].toLowerCase()===`time`?`time`:`log`,...t[2]?{sport:t[2]}:{}}:null}function wa(e){let t=e.type?.toLowerCase();if(t===`youtube`||t===`strava`||t===`amazon`||t===`file`||t===`effort`||t===`equipment`)return t;let n=(e.url||e.link||``).replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).split(/[/?#:]/,1)[0].toLowerCase();return n===`youtu.be`||n===`youtube.com`||n.endsWith(`.youtube.com`)?`youtube`:n===`strava.com`||n.endsWith(`.strava.com`)?`strava`:n===`amzn.to`||n===`amazon.com`||n.endsWith(`.amazon.com`)?`amazon`:[`baseAttributes`,`discipline`,`effortType`,`targetRPE`,`equipment`,`aliases`,`derivation`].some(t=>t in e)?`effort`:[`slug`,`label`,`registrySource`,`ownerNoteId`,`sourcePath`].some(t=>t in e)?`equipment`:`default`}function Ta(e){return/^#{1,6}\s/.test(e)?`heading`:/^[-*+]\s|^\d+\.\s/.test(e)?`list`:/^>\s?/.test(e)?`blockquote`:e.startsWith(`|`)&&/^\|[\s:]*-+/m.test(e)?`table`:`paragraph`}function Ea(e,t={}){if(!e)return[];let n=e.split(/\r\n|\n|\r/),r=[],i=[],a=0;for(let t of n){r.push(a),a+=t.length;let n=e.startsWith(`\r
|
|
3
3
|
`,a)?`\r
|
|
4
4
|
`:/[\r\n]/.test(e[a]??``)?e[a]:``;i.push(n),a+=n.length}let o=[],s=Date.now(),c=!0,l=0;function u(t,a,o){let c=r[a],l=r[o]+n[o].length;return{id:crypto.randomUUID(),type:t,from:c,to:l,rawContent:e.slice(c,l),displayContent:e.slice(c,l),startLine:a,endLine:o,lineCount:o-a+1,version:1,createdAt:s,separatorAfter:i[o]}}for(;l<n.length;){let a=n[l].trim(),d=a.match(/^(`{3,}|~{3,})(.*)$/);if(d){let a=d[1],c=l+1,f=RegExp(`^${a[0]}{${a.length},}\\s*$`);for(;c<n.length&&!f.test(n[c].trim());)c++;let p=c<n.length,m=p?c:n.length-1,h=d[2].trim(),g=a[0]==="`"?Ca(`\`\`\`${h}`):null,_=a[0]==="`"?h.match(/^widget:([\w-]+)$/):null,v=a[0]==="`"?h.match(/^query(?:[:\s](.*))?$/i):null,y=t.registeredWidgets??Sa,b=_&&(`has`in y?y.has(_[1]):y.includes(_[1])),x=p&&g?g.dialect:p&&b?`widget`:p&&v?`query`:`code`,S=u(x,l,m);S.contentFrom=r[l]+n[l].length+i[l].length,S.contentTo=p?r[c]:S.to,S.displayContent=e.slice(S.contentFrom,S.contentTo),g&&p&&(S.sport=g.sport,S.contentId=ga(S.displayContent),S.scriptBlock={id:S.id,contentId:S.contentId,dialect:g.dialect,sport:g.sport,startLine:l,endLine:m,content:S.displayContent,state:`idle`,version:1,createdAt:s}),x===`widget`&&_&&(S.widgetName=_[1]),x===`query`&&v&&(S.querySuffix=(v[1]??``).trim()),o.push(S),l=m+1;continue}if(a===`---`&&n[l+1]?.trim()){let t=l+1;for(;t<n.length&&n[t].trim()!==`---`&&!/^(`{3,}|~{3,})/.test(n[t].trim());)t++;let i=n.slice(l+1,t);if(n[t]?.trim()===`---`&&i.some(e=>/^[A-Za-z_][\w-]*\s*:/.test(e.trim()))){let n=u(`frontmatter`,l,t);n.contentFrom=r[l+1],n.contentTo=r[t],n.displayContent=e.slice(n.contentFrom,n.contentTo),n.properties={};for(let e of i){let t=e.match(/^([^:]+):\s*(.*)$/);t&&(n.properties[t[1].trim()]=t[2].trim())}n.frontmatterType=wa(n.properties),o.push(n),l=t+1;continue}}let f=a.match(/^(!)?\[([^\]]*)\]\((https?:\/\/[^)\s]+|\/[^)\s]+)\)$/);if(f){let e=u(`embed`,l,l),t=!!f[1];e.embed={type:t?`image`:/(?:youtube\.com|youtu\.be)/i.test(f[3])?`youtube`:`link`,label:f[2],url:f[3],isImage:t},o.push(e),l++;continue}let p=l;if(a)for(;p+1<n.length&&n[p+1].trim()&&!/^(?:`{3,}|~{3,}|---\s*$|!?\[[^\]]*\]\()/.test(n[p+1].trim());)p++;let m=u(a&&c?`title`:`markdown`,l,p);m.subtype=Ta(m.displayContent.trim()),a&&(c=!1),o.push(m),l=p+1}return o}function Da(e){return e.type===`time`||e.type===`log`?`wod`:e.type===`query`||e.type===`widget`||e.type===`embed`?e.type:null}function Oa(e,t){if(!Number.isSafeInteger(t.sourceRevision)||t.sourceRevision<1)throw Error(`Invalid source revision`);let n=Object.create(null),r=Object.values(t.blocks??{}).filter(e=>e&&typeof e==`object`),i=t.createId??(()=>crypto.randomUUID());for(let a of Ea(e,t)){let e=Da(a);if(!e)continue;let o=r.filter(t=>t.from===a.from&&t.to===a.to&&t.kind===e),s=o.length===1?o[0]:void 0,c=s?.id??i();if(!c||Object.hasOwn(n,c))throw Error(`Duplicate block occurrence ID`);n[c]={id:c,kind:e,from:a.from,to:a.to,sourceRevision:t.sourceRevision,version:s?.version??1,...e===`wod`&&(a.type===`time`||a.type===`log`)?{dialect:a.type,...a.sport?{sport:a.sport}:{}}:{}}}return n}function ka(e,t,n,r={}){if(typeof e!=`string`||!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid Note source or blocks`);for(let[e,r]of Object.entries(t))if(!r||r.id!==e||!e||!Number.isSafeInteger(r.version)||r.version<1||r.sourceRevision!==n||!Number.isSafeInteger(r.from)||!Number.isSafeInteger(r.to))throw Error(`Invalid block identity, version or source revision`);let i=Oa(e,{...r,sourceRevision:n,blocks:t});if(Object.keys(i).length!==Object.keys(t).length)throw Error(`Incomplete actionable block map`);for(let[e,n]of Object.entries(t)){let t=i[e];if(!t||t.from!==n.from||t.to!==n.to||t.kind!==n.kind||t.dialect!==n.dialect||t.sport!==n.sport)throw Error(`Block does not match authored source`)}}function Aa(e,t){let n=0;for(let e of t){if(!Number.isSafeInteger(e.from)||!Number.isSafeInteger(e.to)||e.from<n||e.to<e.from||typeof e.insert!=`string`)throw Error(`Invalid source changes`);n=e.to}let r={};for(let n of Object.values(e)){let e=n.from,i=n.to,a=!1;for(let r of t){let t=r.insert.length-(r.to-r.from);if(r.from<=n.from&&r.to>=n.to||r.from<n.from&&r.to>n.from||r.from<n.to&&r.to>n.to){a=!0;break}r.to<=n.from?(e+=t,i+=t):r.from<n.to&&(i+=t)}a||(r[n.id]={...n,from:e,to:i})}return r}var ja=/^[A-Za-z][\w.-]*$/,Ma=/^---\r?\n([\s\S]*?)\r?\n---/;function Na(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Pa(e){let t=e.trim();return t===``||t.startsWith(`#`)}function Fa(e){return Array.isArray(e)}function Ia(e){if(e===``)return`""`;let t=!isNaN(Number(e)),n=/^(true|false|null|yes|no|on|off)$/i.test(e);return/[:"'\n#{}[\],&*?|<>=%!@`]/.test(e)||e!==e.trim()||e.startsWith(`-`)||t||n?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/\t/g,`\\t`)}"`:e}function La(e,t,n){let r=` `.repeat(e);return Fa(n)?n.length===0?[`${r}${t}: []`]:[`${r}${t}:`,...n.map(e=>`${r} - ${typeof e==`number`?String(e):Ia(e)}`)]:[`${r}${t}: ${typeof n==`number`?String(n):Ia(n)}`]}function Ra(e,t,n,r){let i=[],a=r;for(let r=t;r<e.length;r++)r===e.length-1?i.push(...La(a,e[r],n)):i.push(`${` `.repeat(a)}${e[r]}:`),a+=2;return i}function za(e){let t=!1,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){i===`\\`?r++:i===`"`&&(n=!1);continue}if(t){i===`'`&&(t=!1);continue}if(i===`"`)n=!0;else if(i===`'`)t=!0;else if(i===`#`&&(r===0||/\s/.test(e[r-1])))return r}return-1}function Ba(e,t,n){let r=[t],i=[];for(let a=t+1;a<e.length;a++){let t=e[a];if(Pa(t)){i.push(a);continue}if(t.length-t.trimStart().length>n)r.push(...i,a),i=[];else break}return r}function Va(e,t,n,r,i){let a=RegExp(`^ {${n}}${Na(t)}\\s*:`);for(let t=r;t<i;t++)if(a.test(e[t]))return t;return-1}function Ha(e,t,n){if(t.length===0||!t.every(e=>typeof e==`string`&&ja.test(e)))return e;let r=e.includes(`\r
|
|
@@ -97,7 +97,7 @@ sum:$metric{} by {week}
|
|
|
97
97
|
`)?e:e+`
|
|
98
98
|
`;return{statements:Ds(ei.create({doc:n,extensions:[Fs]}),t),errors:[],success:!0}}catch(e){return{statements:[],errors:[{message:e instanceof Error?e.message:`Unknown parse error`,severity:`error`}],success:!1}}}function hF(e,...t){console.warn(`[${e}]`,...t)}function gF(e,...t){console.error(`[${e}]`,...t)}function _F(e,t={}){let n=t.sourceRevision??1,r=Oa(e,{...t,blocks:t.noteBlocks,sourceRevision:n}),i=Ea(e,t),a=[];for(let e of i){if(!Da(e))continue;let t=Object.values(r).find(t=>t.from===e.from&&t.to===e.to);t&&(e.id=t.id,e.version=t.version,e.scriptBlock&&(e.scriptBlock=vF({...e.scriptBlock,id:t.id,version:t.version}),a.push(e.scriptBlock)))}return{sections:i,blocks:a,noteBlocks:r,rawContent:e,sourceRevision:n}}function vF(e){try{let t=mF(e.content,e.sport);return{...e,statements:t.statements,errors:t.errors,state:t.success?`parsed`:`error`}}catch(t){return gF(`WorkbenchDocumentModel`,`Block parse error:`,t),e}}function yF(e){if(e.kind!==`wod`||!e.dialect)throw Error(`The saved revision is not a workout.`);let t=Ea(e.rawContent).find(t=>t.type===e.dialect);if(!t?.scriptBlock)throw Error(`The saved workout fence cannot be read.`);let n=t.scriptBlock.content;return{id:e.blockId,content:n,dialect:e.dialect,sport:e.sport,statements:Ps().read(n,e.sport).statements,startLine:0,endLine:e.rawContent.split(`
|
|
99
99
|
`).length-1,version:e.version,state:`idle`,widgetIds:{},createdAt:e.savedAt}}async function bF(e,t,n,r,i=Rj){let a=Date.now(),o=await i.startSession(e,{id:n,noteId:e.noteId,blockId:t.id,blockContentId:t.contentId,origin:r??`journal`,startTime:a,endTime:a,duration:0,completed:!1,status:`in-progress`,createdAt:a});return{...o,block:yF(o.revision)}}async function xF(e,t,n,r){let i=await Z.getNote(e);if(!i)throw Error(`The note is unavailable. Save the note before starting a workout.`);return bF({noteId:i.id,rawContent:i.rawContent,blocks:i.blocks,expectedSourceRevision:i.sourceRevision},t,n,r)}var SF={content:``,sections:null,noteBlocks:{},sourceRevision:0,capturedRun:null,saveError:null,blocks:[],activeBlockId:null,saveState:`idle`,lastSavedContent:``,loadedRouteId:null,results:[],currentEntry:null,historyEntries:[],panelLayouts:{},attachments:[],runtime:null,execution:{status:`idle`,elapsedTime:0,stepCount:0,startTime:null,start:()=>{},pause:()=>{},stop:()=>{},reset:()=>{},step:()=>{}},handles:{handleStart:()=>{},handlePause:()=>{},handleStop:()=>{},handleNext:()=>{},handleStartWorkoutAction:()=>{}},activeSegmentIds:new Set,activeStatementIds:new Set,analyticsSegments:[],analyticsGroups:[],selectedAnalyticsIds:new Set,lastSelectedAnalyticsId:null,outputStatementList:[],logOutputList:[],userOutputOverrides:new Map,gridViewPreset:`default`,hoveredBlockKey:null,documentItems:[],selectedBlock:null,selectedBlockId:null,cursorLine:1,highlightedLine:null,subscriptionManager:null,viewMode:`plan`},CF=5e3;function wF(e={}){let t=e.listeners??[],n=e.nowProvider??Nc,r=e.notePersistence,i=e.setTimeout??((e,t)=>window.setTimeout(e,t)),a=e.clearTimeout??(e=>{typeof e==`number`&&window.clearTimeout(e)}),o=null,s=[],c=ln()((t,n)=>{let c=Promise.resolve(),l=async i=>{let a=n(),o=a.currentEntry?.id??a.loadedRouteId;if(!(!o||!r||!e.provider?.capabilities.canWrite)&&(i.rawContent!==a.lastSavedContent||JSON.stringify(Object.values(i.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))!==JSON.stringify(Object.values(a.currentEntry?.blocks??{}).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport])))){t({saveState:`saving`,saveError:null});try{let e=await r.saveNote({noteId:o,rawContent:i.rawContent,blocks:i.blocks,expectedSourceRevision:a.sourceRevision,metadata:{title:i.rawContent.match(/^#\s+(.+)$/m)?.[1]?.trim()??`Untitled Session`},noteType:`playground`}),s=n();t({currentEntry:e,...s.content===i.rawContent&&JSON.stringify(Object.values(s.noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))===JSON.stringify(Object.values(i.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))?{noteBlocks:e.blocks}:{},sourceRevision:e.sourceRevision??a.sourceRevision,lastSavedContent:i.rawContent,saveState:`saved`})}catch(e){throw t({saveState:`error`,saveError:e instanceof Error?e.message:String(e)}),e}}},u=()=>{o=null;let e=n(),t={rawContent:e.content,blocks:e.noteBlocks,sourceRevision:e.sourceRevision},r=c.catch(()=>{}).then(()=>l(t));return c=r,r};return{...SF,setContent:r=>{let s=_F(r,{noteBlocks:n().noteBlocks,sourceRevision:Math.max(1,n().sourceRevision)}),c=n(),l={content:r,sections:s.sections,blocks:s.blocks,noteBlocks:s.noteBlocks};r!==c.lastSavedContent&&(c.saveState===`idle`&&(l.saveState=`changed`),o!==null&&a(o),e.provider&&e.provider.capabilities.canWrite&&(o=i(()=>{u().catch(()=>{})},CF))),t(l)},setBlocks:e=>t({blocks:e}),setEditorIdentity:r=>{let s=JSON.stringify(Object.values(n().noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))!==JSON.stringify(Object.values(r.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]));t({content:r.rawContent,noteBlocks:r.blocks}),s&&e.provider?.capabilities.canWrite&&(o!==null&&a(o),o=i(()=>{u().catch(()=>{})},CF))},acceptSaved:e=>t(t=>({...t.content===e.rawContent&&JSON.stringify(Object.values(t.noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))===JSON.stringify(Object.values(e.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))?{noteBlocks:e.blocks}:{},sourceRevision:e.sourceRevision,lastSavedContent:e.rawContent})),restoreBlock:async e=>{if(!r)throw Error(`Note persistence is unavailable.`);await u();let i=n(),a=ZP({rawContent:i.content,blocks:i.noteBlocks,sourceRevision:i.sourceRevision},e),o=await r.saveNote({noteId:e.noteId,rawContent:a.rawContent,blocks:a.blocks,expectedSourceRevision:i.sourceRevision}),s=_F(o.rawContent,{noteBlocks:o.blocks,sourceRevision:o.sourceRevision});t({content:o.rawContent,noteBlocks:o.blocks,sourceRevision:o.sourceRevision,lastSavedContent:o.rawContent,currentEntry:o,sections:s.sections,blocks:s.blocks})},startPinnedRun:async e=>{await c.catch(()=>{});let i=n(),a=i.currentEntry?.id??i.loadedRouteId;if(!a||!r)throw Error(`Save the note before starting a workout.`);try{let n=await bF({noteId:a,rawContent:i.content,blocks:i.noteBlocks,expectedSourceRevision:i.sourceRevision},e,C(),void 0,r);return t({capturedRun:n,noteBlocks:n.note.blocks,sourceRevision:n.note.sourceRevision,currentEntry:{...i.currentEntry,...n.note,updatedAt:Date.now(),targetDate:i.currentEntry?.targetDate??Date.now(),schemaVersion:1},lastSavedContent:n.note.rawContent,saveError:null}),n.block}catch(e){throw t({saveState:`error`,saveError:e instanceof Error?e.message:String(e)}),e}},setActiveBlockId:e=>t({activeBlockId:e}),setSaveState:e=>t({saveState:e}),flushSave:async()=>{o!==null&&a(o),o=null,await u()},markSaved:e=>t({lastSavedContent:e,saveState:`saved`}),setResults:e=>t({results:e}),resetResults:()=>t({results:[]}),setCurrentEntry:e=>{if(e&&e.id!==n().currentEntry?.id){let n=_F(e.rawContent,{noteBlocks:e.blocks,sourceRevision:Math.max(1,e.sourceRevision??0)});t({currentEntry:e,content:e.rawContent,noteBlocks:n.noteBlocks,sections:n.sections,blocks:n.blocks,sourceRevision:e.sourceRevision??0,lastSavedContent:e.rawContent})}else t({currentEntry:e})},setHistoryEntries:e=>t({historyEntries:e}),setPanelLayouts:e=>t({panelLayouts:e}),expandPanel:(e,n)=>t(t=>{let r=t.panelLayouts[e]??{viewId:e,panelSpans:{},expandedPanelId:null},i=r.expandedPanelId?r.panelSpans:{...r.panelSpans};return{panelLayouts:{...t.panelLayouts,[e]:{...r,panelSpans:{...i,[n]:3},expandedPanelId:n}}}}),collapsePanel:e=>t(t=>{let n=t.panelLayouts[e];return n?{panelLayouts:{...t.panelLayouts,[e]:{...n,expandedPanelId:null}}}:t}),setAttachments:e=>t({attachments:e}),addAttachment:async r=>{let i=e.notePersistence,a=e.provider,o=n().currentEntry?.id;if(!o||!a?.capabilities.canWrite||!i)return;console.log(`[WorkbenchSession] Processing attachment: ${r.name}`);let s=await Gv.process(r),{v7:c}=await an(async()=>{let{v7:e}=await import(`./vendor-BFExl-KH.js`).then(e=>e.Tt);return{v7:e}},__vite__mapDeps([0,1]));console.log(`[WorkbenchSession] Saving attachment to entry ${o}`),await i.mutateNote(o,{attachments:{add:[{id:c(),label:s.label,mimeType:s.mimeType,data:s.data,timeSpan:s.timeSpan??{start:Date.now(),end:Date.now()}}]}}),t({attachments:(await i.getNote(o,{projection:`workbench`,includeAttachments:!0})).attachments??[]}),console.log(`[WorkbenchSession] Attachment saved successfully`)},deleteAttachment:async r=>{let i=e.notePersistence,a=n().currentEntry?.id;!a||!i||(await i.mutateNote(a,{attachments:{remove:[r]}}),t({attachments:(await i.getNote(a,{projection:`workbench`,includeAttachments:!0})).attachments??[]}))},patchCurrentEntryResults:e=>t(t=>t.currentEntry?{currentEntry:{...t.currentEntry,results:e}}:t),completeWorkout:async(e,i)=>{let a=n().capturedRun,o=i??a?.session.id;if(!o||!r?.finishSession)throw Error(`The saved run pin is unavailable.`);let s=await r.finishSession(o,e,e.endTime);return t(t=>({results:[...t.results,e]})),s.id},loadEntry:async r=>{let i=e.notePersistence,a=e.provider;if(!i||!a)return null;let{routeId:o,routeView:s,routeSectionId:c,routeResultId:l,resultFromLocationState:u,initialActiveEntryId:d,propInitialContent:f}=r;if(n().setContent(``),n().setBlocks([]),t({currentEntry:null,loadedRouteId:o??null}),o){if(a.mode===`history`||a.mode===`static`)try{let e=l?{mode:`by-result-id`,resultId:l}:c&&s===`review`?{mode:`latest-for-section`,blockId:c}:{mode:`latest`},d=await i.getNote(o,{projection:s===`review`?`review`:`workbench`,includeAttachments:!0,includeSections:!0,resultSelection:e}).catch(async t=>(console.warn(`[WorkbenchSession] Note persistence projection failed, falling back to provider entry:`,{routeId:o,projection:s===`review`?`review`:`workbench`,resultSelectionMode:e.mode,err:t}),a.getEntry(o)));if(d){let e=_F(d.rawContent,{noteBlocks:d.blocks,sourceRevision:Math.max(1,d.sourceRevision??0)});return t({currentEntry:d,content:d.rawContent,sections:e.sections,blocks:e.blocks,noteBlocks:e.noteBlocks,sourceRevision:d.sourceRevision??0,lastSavedContent:d.rawContent,saveState:`saved`}),s===`review`&&u&&t(e=>e.currentEntry?{currentEntry:{...e.currentEntry,results:u}}:e),r.onLoaded?.(d),d}if(a.mode===`static`){let e=await eF(o);if(e)return n().setContent(e),null}}catch(e){console.error(`[WorkbenchSession] Failed to load entry for ID:`,o,e)}}else d&&e.navigate?.({type:`goToPlan`,noteId:d});return n().setContent(f??``),null},setActiveSegmentIds:e=>t({activeSegmentIds:e}),setActiveStatementIds:e=>t({activeStatementIds:e}),setAnalytics:(e,n)=>t({analyticsSegments:e,analyticsGroups:n}),appendOutputStatement:e=>t(t=>{let n=[...t.outputStatementList,e],{segments:r,groups:i}=WP(t.runtime);return t.runtime?{outputStatementList:n,analyticsSegments:r,analyticsGroups:i}:{outputStatementList:n}}),clearOutputStatementList:()=>t({outputStatementList:[]}),feedLogOutputs:(e,n)=>{let{segments:r,groups:i}=GP(e,n);t({logOutputList:e,analyticsSegments:r,analyticsGroups:i})},toggleAnalyticsSegment:(e,n,r)=>t(t=>{let i=new Set(t.selectedAnalyticsIds);if(n?.shiftKey&&t.lastSelectedAnalyticsId!==null&&r){let n=r.indexOf(t.lastSelectedAnalyticsId),a=r.indexOf(e);if(n!==-1&&a!==-1){let e=Math.min(n,a),t=Math.max(n,a);r.slice(e,t+1).forEach(e=>i.add(e))}}else n?.ctrlKey?i.has(e)?i.delete(e):i.add(e):(i.clear(),i.add(e));return{selectedAnalyticsIds:i,lastSelectedAnalyticsId:e}}),setUserOverride:(e,n)=>t(t=>{let r=new Map(t.userOutputOverrides);return r.set(e,da.from(n,e)),{userOutputOverrides:r}}),clearUserOverride:e=>t(t=>{let n=new Map(t.userOutputOverrides);return n.delete(e),{userOutputOverrides:n}}),setGridViewPreset:e=>t({gridViewPreset:e}),setHoveredBlockKey:e=>t({hoveredBlockKey:e}),setDocumentItems:e=>t({documentItems:e}),setSelectedBlock:e=>t({selectedBlock:e,selectedBlockId:e?.id??null}),setSelectedBlockId:e=>t({selectedBlockId:e}),setCursorLine:e=>t({cursorLine:e}),setHighlightedLine:e=>t({highlightedLine:e}),setSubscriptionManager:e=>{t({subscriptionManager:e}),pF.setSubscriptionRegistry(e)},setViewMode:e=>t({viewMode:e}),setRuntime:e=>{for(let e of s)e();if(s=[],e){let r=WP(e);t({runtime:e,outputStatementList:[],analyticsSegments:r.segments,analyticsGroups:r.groups}),s.push(e.subscribeToOutput(()=>{n().appendOutputStatement({})})),s.push(e.subscribeToStack(e=>{let n=e.blocks[0],r=new Set;for(let t of e.blocks)r.add(ki(t.key.toString()));let i=new Set;if(n&&Array.isArray(n.sourceIds))for(let e of n.sourceIds)i.add(e);t({activeSegmentIds:r,activeStatementIds:i})}));let i=KO();if(i?.connected){let t=new cF(i);s.push(e.subscribeToStack(e=>t.onStackSnapshot(e)),e.subscribeToOutput(e=>t.onOutput(e)),()=>t.dispose());try{t.onStackSnapshot(e.getStackSnapshot())}catch{}}}else t({runtime:null,outputStatementList:[]})},setExecution:e=>t({execution:e}),setHandles:e=>t({handles:e}),getNote:async(e,t)=>{if(!r)throw Error(`[WorkbenchSession] getNote called without a notePersistence port`);return r.getNote(e,t)},resetStore:()=>{o!==null&&(a(o),o=null);for(let e of s)e();s=[],t({...SF})}}});return t.length>0&&c.subscribe(e=>{for(let n of t)n(e)}),Object.assign(c,{__nowProvider:n})}var TF=wF();function EF(e){let t=TF;return TF=e,t}function DF(){return TF}var OF=e=>Cn(TF,e),kF=({nowProvider:e,notePersistence:t,provider:n,navigate:r,children:i})=>{let a=(0,W.useMemo)(()=>wF({nowProvider:e,notePersistence:t,provider:n,navigate:r}),[e,t,n,r]);return(0,W.useEffect)(()=>{let e=EF(a);return()=>{EF(e),a.getState().resetStore()}},[a]),W.createElement(W.Fragment,null,i)},AF={getEventsByTimeRange:(e,t)=>Z.getEventsByTimeRange(e,t),getEventsByMetricDates:e=>Z.getEventsByMetricDates(e),getEventsByResult:e=>Z.getEventsByResult(e),getEventsForNote:e=>Z.getEventsForNote(e),getEventsByContent:e=>Z.getEventsByContent(e),scanAll:()=>Z.scanAll(),appendEvents:e=>Z.appendEvents(e),finalizeSummaries:(e,t)=>Z.finalizeSummaries(e,t),deleteEvents:e=>Z.deleteEvents(e)},jF={getAllNotes:()=>Z.getAllNotes(),getNotesByIds:async e=>[...(await Z.getEntryBatches(e)).values()].map(e=>e.note),getNoteIdsForTag:async e=>new Set((await Z.getNotesForTag(e)).map(e=>e.id)),getNoteTagLabels:async e=>(await Z.getTagsForNote(e)).map(e=>e.label),queryDomain:async e=>{if(!Z.queryDomain)return;let t=await Z.queryDomain({...e,plan:`notes`});return t&&t.plan===`notes`?t:void 0}},MF={getAllBlocks:()=>Z.getAllBlockIndex(),queryDomain:async e=>{if(!Z.queryDomain)return;let t=await Z.queryDomain({...e,plan:`blocks`});return t&&t.plan===`blocks`?t:void 0}},NF=class{async getAllEfforts(){let e=wE();return e.isInitialized()||await SE(e),[...e.list()]}},PF=new Ih,FF={events:[],notes:[]},IF={events:[],notes:[]};PF.set(`@session`,FF),PF.set(`@today`,IF);function LF(){let e=DF().getState(),t=e.runtime?.getOutputStatements()??[],n=e.currentEntry;return FF.notes=n?[{id:n.id,title:n.title,createdAt:n.createdAt,date:n.targetDate,rawContent:n.rawContent,sourceRevision:n.sourceRevision??1,blocks:n.blocks??{}}]:[],t.length===0?(FF.events=[],FF):(FF.events=qh(t.map(Uf),{noteId:n?.id??``,resultId:`live:${n?.id??`session`}`,origin:`playground`,workoutTimestamp:n?.targetDate}),FF)}function RF(e,t,n,r){let i=[...t].sort((e,t)=>(e.position??1/0)-(t.position??1/0)||e.createdAt-t.createdAt);for(let e of i){let t=n.get(e.pageId)?.date;if(t)return t}return bh(e.date??e.createdAt,r)}async function zF(e,t){let n=bh(e.instant,e.timeZone),r=Th(n,e.timeZone),i=Th(xh(n,1),e.timeZone),[a,o,s,c]=await Promise.all([Z.getEventsByTimeRange(r,i),Z.getAllNotes(),Z.getAllPageNotes(),Z.getAllPages()]),l=a.filter(e=>e.timestamp>=r&&e.timestamp<i),u=new Map(c.map(e=>[e.id,e])),d=new Map;for(let e of s){let t=d.get(e.noteId);t?t.push(e):d.set(e.noteId,[e])}let f=[];for(let t of o)RF(t,d.get(t.id)??[],u,e.timeZone)===n&&f.push(t);t===HF&&(IF.events=l,IF.notes=f,LF())}var BF=null,VF=null,HF=0,UF=!1,WF=new Set;function GF(){for(let e of WF)e()}function KF(e,t){VF=t;let n=++HF;return BF=zF(e,n),BF.then(()=>{n===HF&&qF()},()=>{n===HF&&qF()}),BF}function qF(){UF=!0,GF()}function JF(){let e=mh(),t=bh(e.instant,e.timeZone);return!BF||VF!==t?KF(e,t):BF}function YF(){UF=!1;let e=mh();return KF(e,bh(e.instant,e.timeZone))}function XF(){return UF}function ZF(e){return WF.add(e),()=>{WF.delete(e)}}var QF=class extends Dg{async runQuery(e,t){return await JF(),super.runQuery(e,t)}async runPipeline(e,t){return await JF(),super.runPipeline(e,t)}async runFind(e,t){return await JF(),super.runFind(e,t)}async runRows(e,t){return await JF(),super.runRows(e,t)}async run(e,t){return await JF(),super.run(e,t)}};function $F(){return new QF({eventStore:AF,noteStore:jF,blockStore:MF,effortStore:new NF,blockEffortsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`block_efforts`,e,t)},tagsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`tags`,e,t)},noteTagsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`note_tags`,e,t)},pageStore:{getNotePages:e=>Z.getNotePages(e),getPage:e=>Z.getPage(e)},relationStore:{getBatches:e=>Z.getEntryBatches(e)},datasetStore:{getDataset:e=>e===`@session`?LF():PF.getDataset(e)}})}var eI=$F();function tI(e){let t=e.split(`/`),n=t[0]??e,r=t[1]??``;return n===`journal`?{kind:`journal`,id:r,raw:e}:n===`playground`?{kind:`playground`,id:r,raw:e}:t.length<2?{kind:`workout`,id:n,raw:e}:{kind:`workout`,category:n,id:r,raw:e}}var nI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function rI(e){return typeof e==`string`&&e&&!nI.test(e)?e:void 0}function iI(e){return!!e.sourceId?.startsWith(`collection:`)||!!e.sourceId?.startsWith(`page:collection:`)||e.type===`feed`||/^markdown\/collections\/[^/]+\/.+/.test(e.sourcePath??``)}function aI(e){return!!e.sourceId?.startsWith(`feed:`)||e.sourcePath?.startsWith(`markdown/feeds/`)===!0}function oI(e){return e.type===`dashboard`||e.sourceId===`dashboards`||e.sourcePath?.startsWith(`markdown/dashboards/`)===!0}function sI(e){return e.sourceId===`efforts`||e.sourcePath?.startsWith(`markdown/efforts/`)===!0}function cI(e){return e.sourceId===`equipment`||e.sourcePath?.startsWith(`markdown/equipment/`)===!0}function lI(e,t){let n=e.sourcePath?.replace(/^markdown\/[^/]+\//,``).replace(/\.md$/,``);if(!n)return;let r=n.split(`/`);return r.length===t?r[t-1]:void 0}function uI(e){let t=e.sourceId;if(t?.startsWith(`page:collection:`)){let e=t.slice(16);if(e)return{catalog:e,item:``}}else if(t?.startsWith(`collection:`)){let e=t.slice(11);if(e){let t=e.indexOf(`/`);return t===-1?{catalog:e,item:``}:{catalog:e.slice(0,t),item:e.slice(t+1)}}}let n=/^markdown\/collections\/([^/]+)\/(.+)\.md$/.exec(e.sourcePath??``);if(n)return{catalog:n[1],item:n[2].toLowerCase()===`readme`?``:n[2]};let r=e.id.replace(/^page:collection:/,``);if(nI.test(r))return{catalog:e.catalog??``,item:``};let[i,...a]=r.split(`/`);return{catalog:i,item:a.join(`/`)}}function dI(e){return e.sourceId===`playground`||e.type===`playground`||e.id.startsWith(`playground/`)}function fI(e){return e.id.startsWith(`playground/`)?e.id.slice(11):e.id}function pI(e){return{...mI(e),noteType:e.type,catalog:ng(e),notebookId:rg(e),editable:xa(e),noteId:e.id}}function mI(e){let t=e.id,n=e.title,r=e.tags&&e.tags.length>0?e.tags:void 0;if(dI(e))return{id:t,kind:`note`,sourceCatalog:`playground`,sourceItem:fI(e),sourceId:e.sourceId,title:n,date:null,createdAt:e.createdAt,...r?{tags:r}:{}};if(iI(e)){let i=t.replace(/^page:collection:/,``),{catalog:a,item:o}=uI(e);return{id:i,kind:`session`,sourceCatalog:a,sourceItem:!o||e.type===`feed`||e.type===`page`?``:o,sourceId:e.sourceId,sourcePath:e.sourcePath,pageId:`pageId`in e&&typeof e.pageId==`string`?e.pageId:void 0,pageSlug:`slug`in e?rI(e.slug):void 0,title:n,date:e.date?Gj(new Date(e.date)):null,createdAt:e.createdAt,subtitle:e.catalog??a,...r?{tags:r}:{}}}if(aI(e)){let i=e.sourceId?.startsWith(`feed:`)?e.sourceId.slice(5):e.sourcePath?.startsWith(`markdown/feeds/`)?e.sourcePath.slice(9).replace(/\.md$/,``):e.id,a=(i.startsWith(`feeds/`)?i.slice(6):i).split(`/`),o=a[1]&&/^\d{4}-\d{2}-\d{2}$/.test(a[1])?a[1]:null;return{id:t,kind:`post`,sourceCatalog:a[0],sourceItem:a.slice(2).join(`/`)||a[a.length-1],sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:o,createdAt:e.createdAt,subtitle:e.catalog??a[0],...r?{tags:r}:{}}}if(oI(e))return{id:t,kind:`dashboard`,sourceCatalog:`dashboards`,sourceItem:lI(e,1)??t,sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:null,createdAt:e.createdAt,subtitle:e.catalog??`dashboards`,...r?{tags:r}:{}};if(sI(e)){let i=lI(e,2)??t,a=e.sourcePath?.match(/^markdown\/efforts\/([^/]+)\//)?.[1];return{id:t,kind:`effort`,sourceCatalog:`efforts`,sourceItem:i,sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:null,createdAt:e.createdAt,subtitle:a,effort:{slug:i},...r?{tags:r}:{}}}if(cI(e))return{id:t,kind:`equipment`,sourceCatalog:`equipment`,sourceItem:lI(e,1)??t,sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:null,createdAt:e.createdAt,subtitle:`equipment`,...r?{tags:r}:{}};if(e.sourceId?.startsWith(`guides:`)){let i=e.sourceId.slice(7)||t;return{id:t,kind:`note`,sourceCatalog:`guides`,sourceItem:i,sourceId:e.sourceId,sourcePath:e.sourcePath,pageSlug:rI(i.replace(/^\//,``).replace(/^guide\//,``)),title:n,date:null,createdAt:e.createdAt,...r?{tags:r}:{}}}let i=null;return`journalDate`in e&&typeof e.journalDate==`string`?i=e.journalDate:`date`in e&&typeof e.date==`string`?i=e.date:`targetDate`in e&&e.targetDate&&(typeof e.targetDate==`number`||typeof e.targetDate==`string`)?i=Gj(new Date(e.targetDate)):e.createdAt&&(i=Gj(new Date(e.createdAt))),{id:t,kind:`note`,sourceCatalog:`journal`,sourceItem:t,sourceId:e.sourceId,sourcePath:e.sourcePath,pageId:`pageId`in e&&typeof e.pageId==`string`?e.pageId:void 0,pageSlug:`slug`in e?rI(e.slug):void 0,title:n,date:i,createdAt:e.createdAt,...r?{tags:r}:{}}}function hI(e){return{id:e.noteId,title:e.noteTitle,createdAt:e.createdAt,type:`note`,sourceId:e.sourceId,sourcePath:e.sourcePath,rawContent:``,sourceRevision:1,blocks:{}}}var gI=3,_I=120;function vI(e){return e.split(`
|
|
100
|
-
`).map(e=>e.trim()).filter(Boolean).slice(0,gI).map(e=>e.length>_I?`${e.slice(0,119)}…`:e)}function yI(e){let t=pI(hI(e));return{...t,blockContentId:e.blockContentId??t.blockContentId,catalog:ng(e),block:{blockId:e.blockId,dataType:e.dataType,preview:vI(e.rawContent)}}}function bI(e){return e?e.split(`-`).map(e=>{let t=e.toLowerCase();return t===`c2b`?`C2B`:t===`t2b`?`T2B`:t===`ghd`?`GHD`:t===`hspu`?`HSPU`:e.charAt(0).toUpperCase()+e.slice(1)}).join(` `):``}function xI(e){if(!Number.isFinite(e)||e<=0)return`00:00`;let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;if(n>=60){let e=Math.floor(n/60),t=n%60;return`${e}:${String(t).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}function SI(e){if(!e)return`Workout Session`;let t=tI(e);return t.kind===`journal`?t.id?`Journal: ${t.id}`:`Journal Entry`:t.kind===`workout`?bI(t.id)||t.id:t.id?bI(t.id):e}function CI(e){let t=[e.baseAttributes?.discipline,e.baseAttributes?.met==null?void 0:`MET ${e.baseAttributes.met.toFixed(1)}`,e.baseAttributes?.intensityTier].filter(Boolean);return{id:e.slug,kind:`effort`,sourceCatalog:e.registrySource??`effort`,sourceItem:e.slug,title:e.label,date:null,subtitle:t.join(` • `),detail:e.aliases&&e.aliases.length>0?`Aliases: ${e.aliases.join(`, `)}`:void 0,effort:{slug:e.slug,label:e.label,discipline:e.baseAttributes?.discipline,met:e.baseAttributes?.met,intensityTier:e.baseAttributes?.intensityTier,aliases:e.aliases,registrySource:e.registrySource}}}function wI(e){let t=(e.type??``).toLowerCase(),n=(`name`in e&&typeof e.name==`string`?e.name:``).toLowerCase(),r=typeof e.value==`number`?e.value:Number(e.value);return Number.isFinite(r)?t===`rep`||n===`reps`||n===`rep`?{kind:`rep`,val:r}:t===`weight`||t===`load`||n===`load`||n===`weight`||n===`volume`?{kind:`load`,val:r}:t===`distance`||n===`distance`?{kind:`distance`,val:r}:t===`tis`||n===`tis`?{kind:`tis`,val:r}:t===`duration`||n===`duration`?{kind:`duration`,val:r}:null:null}function TI(e){let t=1/0,n=-1/0,r=0,i=0,a=0,o=0,s=new Set;for(let c of e.events)if(c.outputType===`segment`&&o++,c.effortSlug&&s.add(c.effortSlug),c.timeSpan?.started!=null&&(c.timeSpan.started<t&&(t=c.timeSpan.started),c.timeSpan.ended!=null&&c.timeSpan.ended>n&&(n=c.timeSpan.ended)),Array.isArray(c.metrics))for(let e of c.metrics){let t=wI(e);t&&(t.kind===`rep`?r+=t.val:t.kind===`load`?i+=t.val:t.kind===`tis`&&t.val>a&&(a=t.val))}return{elapsedMs:Number.isFinite(t)&&Number.isFinite(n)&&n>t?n-t:void 0,reps:r>0?r:void 0,loadLbs:i>0?i:void 0,tis:a>0?a:void 0,segmentCount:o>0?o:void 0,effortSlugs:Array.from(s)}}function EI(e,t){let n=TI(e),r=[];n.elapsedMs!=null&&r.push(xI(n.elapsedMs)),n.tis!=null&&r.push(`TIS ${n.tis.toFixed(1)}`),n.loadLbs!=null&&r.push(`Volume: ${n.loadLbs.toLocaleString()} lbs`),n.reps!=null&&r.push(`${n.reps} reps`),n.segmentCount!=null&&r.push(`${n.segmentCount} splits`);let i=n.effortSlugs.map(bI),a=Gj(new Date(e.timestamp)),o=e.events.find(e=>!!e.blockContentId)?.blockContentId;return{id:e.resultId,kind:`result`,sourceCatalog:`results`,sourceItem:e.resultId,title:t?.noteTitle??SI(e.noteId),date:a,blockContentId:o,subtitle:r.join(` • `),detail:i.length>0?i.join(`, `):void 0,execution:{resultId:e.resultId,noteId:e.noteId,timestamp:e.timestamp,outputType:`all`,elapsedMs:n.elapsedMs,reps:n.reps,loadLbs:n.loadLbs,tis:n.tis,segmentCount:n.segmentCount,events:e.events}}}function DI(e,t){let n;e.timeSpan?.started!=null&&e.timeSpan?.ended!=null&&(n=e.timeSpan.ended-e.timeSpan.started);let r,i,a,o;if(Array.isArray(e.metrics))for(let t of e.metrics){let e=wI(t);e&&(e.kind===`rep`?r=e.val:e.kind===`load`?i=e.val:e.kind===`distance`?a=e.val:e.kind===`tis`?o=e.val:e.kind===`duration`&&!n&&(n=e.val))}let s=e.outputType===`segment`?`segment`:`event`,c=t?.index??0,l=e.effortSlug?bI(e.effortSlug):e.outputType===`segment`?`Round ${c+1}`:`${e.outputType.charAt(0).toUpperCase()+e.outputType.slice(1)} ${c+1}`,u=[];n!=null&&u.push(xI(n)),r!=null&&i!=null?u.push(`${r} reps @ ${i} lbs`):r==null?i!=null&&u.push(`${i} lbs`):u.push(`${r} reps`),a!=null&&u.push(`${a}m`),o!=null&&u.push(`TIS ${o.toFixed(1)}`);let d=Gj(new Date(e.timestamp));return{id:e.id,kind:s,sourceCatalog:`results`,sourceItem:e.id,title:l,date:d,blockContentId:e.blockContentId,subtitle:u.join(` • `),detail:e.effortSlug?bI(e.effortSlug):void 0,execution:{resultId:e.resultId,noteId:e.noteId,timestamp:e.timestamp,outputType:e.outputType,effortSlug:e.effortSlug,elapsedMs:n,reps:r,loadLbs:i,distanceMeters:a,tis:o,metrics:e.metrics}}}function OI(e,t){if(!e||e.error||!e.runs)return[];let n=e.parsed?.filters?.find(e=>e.key===`plane`&&!e.negate),r=e.parsed?.outputType??n?.values[0]?.value;if(r===`segment`){let t=[];for(let n of e.runs){let e=0;for(let r of n.events)r.outputType===`segment`&&t.push(DI(r,{index:e++}))}return t}if(r&&r!==`all`){let t=[];for(let n of e.runs){let e=0;for(let i of n.events)i.outputType===r&&t.push(DI(i,{index:e++}))}return t}return e.runs.map(e=>EI(e,{noteTitle:t?.noteTitles?.get(e.noteId)}))}function kI(e,t,n){let r=typeof e.__id==`string`&&e.__id?e.__id:void 0,i=typeof e.__resultId==`string`&&e.__resultId?e.__resultId:void 0,a=typeof e.effort==`string`&&e.effort?e.effort:void 0,o=[];for(let[t,n]of Object.entries(e))t.startsWith(`__`)||t===`date`||t===`effort`||(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)&&o.push(`${t}: ${n}`);return{id:r??i??`${t}:${n}`,kind:t,sourceCatalog:`results`,sourceItem:i??r??`${t}:${n}`,title:a?bI(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function AI(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function jI(e){return typeof e==`object`&&!!e&&`runFind`in e}var MI=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){jI(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver)}get service(){return this.customService??eI}withNoteBlockInfo(){let t=new e({service:this.service,noteTitleResolver:this.noteTitleResolver,noteTagsResolver:this.noteTagsResolver,noteBlockInfo:!0});return Object.prototype.hasOwnProperty.call(this,`query`)&&(t.query=this.query),t}async hydrateEntries(e,t){let n=e=>e.noteId??e.id,r=new Set;for(let i of e)i.sourceCatalog===`journal`&&r.add(n(i)),t&&(!i.title||!i.tags||i.tags.length===0)&&r.add(n(i));if(r.size===0)return;let i=await Z.getEntryBatches([...r]);for(let t of e){if(t.sourceCatalog!==`journal`)continue;let e=i.get(n(t)),r=[...e?.links??[]].sort((e,t)=>(e.position??1/0)-(t.position??1/0)||e.createdAt-t.createdAt);for(let n of r){let r=e?.pages.find(e=>e.id===n.pageId);if(r&&(t.pageId??=r.id,!r.date&&r.slug)){t.pageSlug=r.slug;break}}}if(t)for(let t of e){let e=i.get(n(t));!t.title&&e?.note.title&&(t.title=e.note.title),e&&e.tags.length>0&&((!t.tags||t.tags.length===0)&&(t.tags=e.tags.map(e=>e.label)),t.typedTags=e.tags.map(e=>({label:e.label,type:e.type})))}}async query(e,t){let n=typeof e==`string`?X(e):e;if(!n||n.error)return[];if(Vp(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=(e.efforts??[]).map(CI);return AI(t,e.stages,r),r}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map(yI);return await this.hydrateEntries(r,!0),AI(t,e.stages,r),r}if(n.target===`session`){let e=await this.service.runFind(n);t?.(e.stages);let r;if(this.noteTitleResolver&&e.runs){r=new Map;for(let t of e.runs)if(!r.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&r.set(t.noteId,e)}}let i=OI(e,{noteTitles:r});return AI(t,e.stages,i),i}if(n.target===`segment`||n.target===`event`){let e=n.target,r=await this.service.runFind(n),i=(r.table?.rows??[]).map((t,n)=>kI(t,e,n));return AI(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(pI);if(this.noteTagsResolver?(await this.hydrateEntries(r,!1),await Promise.all(r.map(async e=>{if(!e.tags||e.tags.length===0){let t=await this.noteTagsResolver(e.id);t&&t.length>0&&(e.tags=t)}}))):await this.hydrateEntries(r,!0),AI(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=vI(i.rawContent);try{ka(i.rawContent,i.blocks,i.sourceRevision)}catch{continue}let a=Object.values(i.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&Ea(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=ga(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}return[]}};async function NI(e,t=MI,n){return t.query(e,n)}function PI(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function FI(e){try{let t=(await NI(e.query)).filter(t=>!e.filterEntry||e.filterEntry(t)).slice(0,e.limit??6).map(t=>({kind:`link`,id:`${e.id}:${t.id}`,label:e.labelFromEntry?e.labelFromEntry(t):t.title,to:e.toEntry?e.toEntry(t):void 0,muted:!0}));return{kind:`section`,id:e.id,label:e.label,entries:t}}catch{return{kind:`section`,id:e.id,label:e.label,entries:[]}}}function II(e){let t=PI(e),n=(0,W.useRef)(e);n.current=e;let[r,i]=(0,W.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,W.useEffect)(()=>{let e=n.current;if(!e){i([]);return}if(!e.some(e=>e.kind===`wql`)){i(e);return}let t=!1;return Promise.all(e.map(e=>e.kind===`wql`?FI(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function LI(){let[e]=Ht(`s`,{shallow:!0}),{navState:t}=bA(),n=t.activeL3Id??``;return e||n||``}function RI({entry:e,active:t,onActivate:n}){let r=e.onRun;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:K(`group flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors`,e.muted?`text-[11.5px]`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:K(`hover:bg-muted/60 hover:text-foreground`,e.muted?`text-muted-foreground/70`:`text-muted-foreground`)),children:[e.icon&&(0,G.jsx)(e.icon,{className:`size-4 shrink-0`}),e.timestamp&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.timestamp}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/50`,children:e.badge}),r&&(0,G.jsx)(`span`,{role:`button`,tabIndex:-1,title:e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,onClick:t=>{t.stopPropagation(),e.onRun?.()},className:`flex size-5 shrink-0 items-center justify-center rounded text-primary opacity-0 transition-all group-hover:opacity-100 hover:bg-primary/10`,children:e.runIcon===`link`?(0,G.jsx)(l,{className:`size-3.5`}):e.runIcon===`stop`?(0,G.jsx)(b,{className:`size-3.5`}):e.runIcon===`edit`?(0,G.jsx)(o,{className:`size-3.5`}):(0,G.jsx)(en,{className:`size-3.5`})})]})}function zI({entries:e,activeId:t,onSection:n}){let r=yn(),{scrollToSection:i}=bA(),a=e=>{if(n)return n(e);if(e.onRun)return e.onRun();if(e.to)return r(e.to);if(e.sectionId)return i(e.sectionId)};return(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,G.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,G.jsx)(zI,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:(0,G.jsx)(RI,{entry:e,active:t!=null&&e.sectionId===t,onActivate:a},e.id))})}function BI(){let e=yn(),{scrollToSection:t}=bA();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function VI(){let e=BI(),{openCreateJournal:t}=bA();return n=>{if(n.id===`home-new-journal`){t({mode:`blank`});return}ZM(n.action,e)}}function HI(e,t,n){return e.isActive?e.isActive(n,t):e.action.type===`route`?e.action.to===`/`?n.pathname===`/`||n.pathname===``:n.pathname===e.action.to:e.action.type===`scroll`?t.activeL3Id===e.action.sectionId:e.action.type===`query`&&t.activeL3Id===e.id}function UI({items:e}){let{navState:t}=bA(),n=dt(),r=VI();return(0,G.jsx)(fM,{children:e.map(e=>{if(e.variant===`notable`)return(0,G.jsx)(`div`,{className:`mb-2`,children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`nav-item-${e.id}`,onClick:()=>r(e),className:`flex w-full items-center justify-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-xs font-semibold text-primary transition-all hover:bg-primary hover:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary shadow-sm`,children:[(0,G.jsx)(wn,{className:`size-4 shrink-0`}),(0,G.jsx)(`span`,{children:e.label})]})},e.id);let i=HI(e,t,n);return e.children&&e.children.length>0?(0,G.jsx)(nN,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>HI(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=HI(e,t,n);return(0,G.jsxs)(pM,{onClick:()=>r(e),current:i,children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(mM,{children:e.label})]},e.id)})},e.id):(0,G.jsxs)(pM,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:e.disabled?`opacity-60`:void 0,children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(mM,{children:e.disabled?`+`:e.label})]},e.id)})})}function WI({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=bA(),a=dt(),o=II(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,G.jsxs)(lM,{children:[(0,G.jsx)(uM,{children:(0,G.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s?.label??`Wod Wiki`})}),(0,G.jsxs)(dM,{children:[(()=>{if(c||!s)return null;if(s.panel){let e=s.panel;return(0,G.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,G.jsx)(e,{item:s,navState:n,dispatch:r})})}return s.children&&s.children.length>0?(0,G.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,G.jsx)(UI,{items:s.children})}):null})(),c?(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(zI,{entries:c.spec})}):o.length>0&&(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(zI,{entries:o})})]})]})}var GI=`0.43.2151`,KI=`https://github.com/bitcobblers/wod-wiki/releases`;function qI(e){return/-pr\.\d+$/.test(e)?KI:`${KI}/tag/v${e}`}function JI({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=bA(),a=yn(),o=dt(),s=rM(),c={navigate:(e,t)=>a(e,{replace:t?.replace}),setQueryParam:()=>{},scrollToSection:()=>{}},l=(n??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),u=o.pathname.startsWith(`/settings`);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(`/`),"aria-label":`Wod Wiki home`,className:`mb-3 grid size-8 shrink-0 place-items-center rounded-xl bg-primary text-primary-foreground shadow-md shadow-primary/20 rotate-3`,children:(0,G.jsx)(k,{size:17})}),(0,G.jsx)(`nav`,{"aria-label":`Primary`,className:`flex flex-col items-center gap-1.5`,children:l.map(e=>{let t=e.icon,n=HI(e,r,o);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{i({type:`SET_ACTIVE_L1`,id:e.id}),ZM(e.action,c)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,className:K(`relative grid size-9 place-items-center rounded-lg transition-colors`,n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[n&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(t,{className:`size-5`})]},e.id)})}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{type:`button`,onClick:e,title:`Search (⌘/)`,"aria-label":`Search`,className:`grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:(0,G.jsx)(Zt,{className:`size-5`})}),(0,G.jsx)(`a`,{href:YN,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:`grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:(0,G.jsx)(XN,{className:`size-5`})}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":o.pathname.startsWith(`/settings/profile`)?`page`:void 0,"data-testid":`nav-profile`,className:K(`relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,o.pathname.startsWith(`/settings/profile`)?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[o.pathname.startsWith(`/settings/profile`)&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(Ae,{className:`size-5`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":u?`page`:void 0,"data-testid":`nav-settings`,className:K(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,u?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[u&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(ft,{className:`size-5`}),(0,G.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-0 left-full z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 font-mono text-[10px] text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`v`,GI]})]})]})}function YI({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,G.jsx)(`nav`,{className:K(`lg:sticky z-20 flex items-center gap-1 px-4 py-2 bg-background/95 backdrop-blur-sm border-b border-border/50 overflow-x-auto`,n===`top-fixed`?`lg:top-0`:`lg:top-[104px]`,i),children:e.map(e=>(0,G.jsx)(`button`,{onClick:()=>ZM(e.action,r),className:K(`px-3 py-1.5 rounded-full text-[10px] font-black uppercase tracking-[0.12em] whitespace-nowrap transition-all ring-1`,t===e.id?`bg-primary text-primary-foreground ring-primary/30 shadow-md`:`bg-muted/50 text-muted-foreground ring-transparent hover:bg-muted hover:ring-border`),children:e.label},e.id))})}var XI=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=Nc){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},ZI=20,QI=e=>{let[t,n]=(0,W.useState)(`idle`),[r,i]=(0,W.useState)(0),[a,o]=(0,W.useState)(0),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),n(`idle`)},[]),f=(0,W.useCallback)(()=>{if(e)try{let t=new XI(void 0,e.nowProvider);e.handle(t),o(e=>e+1)}catch{d(),n(`error`)}},[e,d]);(0,W.useEffect)(()=>{if(e)return e.subscribeToStack(e=>{e.blocks.length===0&&t!==`completed`&&(l.current&&=(clearInterval(l.current),null),n(`completed`))})},[e,t]),(0,W.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]);let p=(0,W.useCallback)(()=>{if(!e){console.warn(`useRuntimeExecution: Cannot start execution without a runtime`);return}if(t===`running`){console.warn(`useRuntimeExecution: Runtime is already running`);return}t===`paused`&&e.handle({name:`timer:resume`,timestamp:new Date,data:{}}),n(`running`);let i=e?.nowProvider?.nowMs()??Nc.nowMs();u.current=i-r,r===0&&c(i),l.current=setInterval(f,ZI)},[e,t,r,f]),m=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),e&&e.handle({name:`timer:pause`,timestamp:new Date,data:{}}),n(`paused`)},[e]),h=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),i(0),o(0),n(`idle`),c(null),u.current=null},[e]),g=(0,W.useCallback)(()=>{!e||t===`running`||(n(`paused`),f())},[e,t,f]);return(0,W.useEffect)(()=>{if(t!==`running`||!u.current)return;let n=setInterval(()=>{i((e?.nowProvider?.nowMs()??Nc.nowMs())-u.current)},100);return()=>clearInterval(n)},[t,e?.nowProvider]),(0,W.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]),(0,W.useEffect)(()=>{h()},[e,h]),(0,W.useMemo)(()=>({status:t,elapsedTime:r,stepCount:a,startTime:s,start:p,pause:m,stop:d,reset:h,step:g}),[t,r,a,s,p,m,d,h,g])},$I=(e,t)=>!e||!Array.isArray(e)?0:e.reduce((e,n)=>{if(`started`in n){let r=n.started,i=n.ended??t;return e+Math.max(0,i-r)}let r=n.start instanceof Date?n.start.getTime():n.start||0,i=n.stop?n.stop instanceof Date?n.stop.getTime():n.stop:t;return e+Math.max(0,i-r)},0);function eL(e,t){let n=t,r=()=>{let t=e?.getMemoryByTag(n)[0];if(t)return n===`round`?t.metrics[0]:t.metrics[0]?.value},[i,a]=(0,W.useState)(r);return(0,W.useEffect)(()=>{if(!e){a(void 0);return}a(r());let t=e.getMemoryByTag(n)[0];if(t)return t.subscribe(e=>{a(n===`round`?e[0]:e[0]?.value)})},[e,t]),i}function tL(e){return eL(e,`round`)}function nL(e){return eL(e,`display`)}function rL(e){let t=tL(e),n=nL(e);return(0,W.useMemo)(()=>{if(!t)return null;let e=n?.roundDisplay??(t.total===void 0?`Round ${t.current}`:`Round ${t.current} of ${t.total}`),r=t.total===void 0?void 0:Math.min(1,(t.current-1)/t.total);return{current:t.current,total:t.total,label:e,progress:r}},[t,n?.roundDisplay])}var iL=(0,W.createContext)(void 0),aL=({runtime:e,children:t})=>(0,G.jsx)(iL.Provider,{value:e,children:t});function oL(){let e=(0,W.useContext)(iL);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function sL(e){let t=oL(),n=e===void 0?t:e,[r,i]=(0,W.useState)(()=>n?.getOutputStatements?.()??[]);return(0,W.useEffect)(()=>{if(!n){i([]);return}return i(n.getOutputStatements()),n.subscribeToOutput?.(()=>{i(n.getOutputStatements())})},[n]),(0,W.useMemo)(()=>{let e=new Map,t=new Map,n=[],i=[];for(let a of r){e.set(a.id,a);let r=t.get(a.sourceBlockKey)??[];switch(r.push(a),t.set(a.sourceBlockKey,r),a.outputType){case`segment`:n.push(a);break;case`metric`:i.push(a)}}let a=n.filter(e=>e.completionReason!==void 0);return{outputs:r,byId:e,byBlockKey:t,segments:n,completions:a,metrics:i}},[r])}function cL(e){let t=oL(),n=e===void 0?t:e,[r,i]=(0,W.useState)(()=>n?.getLiveAnalytics?.()??[]);return(0,W.useEffect)(()=>{if(!n){i([]);return}return i(n.getLiveAnalytics?.()??[]),n.subscribeToOutput?.(()=>{i(n.getLiveAnalytics?.()??[])})},[n]),r}function lL(){let e=oL(),[t,n]=(0,W.useState)({type:`initial`,blocks:e.stack.blocks,depth:e.stack.count,clockTime:e.clock.currentDate});return(0,W.useEffect)(()=>e.subscribeToStack(e=>{n(e)}),[e]),t}function uL(){return lL().blocks}function dL(){let e=uL(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:next`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{for(let t of e){let e=t.getMemoryByTag(`metric:next`);if(e.length===0)continue;let n=da.empty(t.key.toString());for(let t of e)n.merge(t.metrics);if(n.length>0)return{metrics:n,block:t}}return null},[e,t])}function fL(){let e=uL(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`time`)[0];if(e){let r=e.subscribe(()=>{n(e=>e+1)});t.push(r)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{let t=[];for(let n of e){let e=n.getMemoryByTag(`time`)[0];if(!e)continue;let r=e.metrics[0]?.value;r&&t.push({block:n,timer:r,isPinned:r.role===`primary`})}return t},[e,t])}function pL(){let e=fL();return(0,W.useMemo)(()=>{if(e.length===0)return;let t=e[0];return t.block.blockType===`Rest`?t:[...e].reverse().find(e=>e.isPinned)||t},[e])}function mL(){let e=fL(),t=pL();return(0,W.useMemo)(()=>t?e.filter(e=>e.block!==t.block):[],[e,t])}function hL(){let e=uL(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`controls`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r].getMemoryByTag(`controls`);if(i.length===0)continue;let a=i[0].metrics.map(e=>e.value).filter(Boolean),o=r===e.length-1;for(let e of a)e.isPinned?t.push(e):o&&n.push(e)}let r=new Set,i=[];for(let e of t)r.has(e.id)||(r.add(e.id),i.push(e));for(let e of n)r.has(e.id)||(r.add(e.id),i.push(e));return i},[e,t])}function gL(){let e=uL(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:display`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{if(e.length===0)return;let t=[],n=[...e].reverse();return n.forEach((e,r)=>{if(e.blockType===`Root`&&!e.label)return;let i=e.getMemoryByTag(`metric:display`),a=i.map(e=>e.metrics);if(a.length===0&&!e.label)return;let o=r===n.length-1,s=i.length>1?i.map(e=>e.metrics):void 0;t.push({block:e,displayRows:a,label:e.label,depth:r,isLeaf:o,metricGroups:s})}),t.length>0?t:void 0},[e,t])}function _L(e){let t=oL(),n=(0,W.useMemo)(()=>t.stack.blocks.find(t=>t.key.toString()===e),[t,e]),[r,i]=(0,W.useState)(()=>n?.getMemoryByTag(`time`)[0]?.metrics[0]?.value);(0,W.useEffect)(()=>t.stack.subscribe(()=>{let n=t.stack.blocks.find(t=>t.key.toString()===e);if(n){let e=n.getMemoryByTag(`time`)[0];i(e?.metrics[0]?.value)}else i(void 0)}),[t,e]),(0,W.useEffect)(()=>{if(!n){i(void 0);return}let e=n.getMemoryByTag(`time`)[0];if(i(e?.metrics[0]?.value),e)return e.subscribe(e=>{i(e[0]?.value)})},[n]);let a=(0,W.useMemo)(()=>r?.spans??[],[r]),o=a.length>0&&a[a.length-1].ended===void 0,[s,c]=(0,W.useState)(xl()),l=(0,W.useMemo)(()=>a.length===0?0:$I(a,s),[a,s]);return(0,W.useEffect)(()=>{if(!o)return;let e,t=()=>{c(xl()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}var vL=(0,W.createContext)(void 0),yL=(0,W.createContext)(null),bL={getState:()=>DF().getState(),setState:(e,t)=>{let n=DF();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>DF().subscribe(e)},xL=({factory:e,children:t})=>{let[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(e);u.current=e;let d=(0,W.useRef)(null),f=(0,W.useRef)(null),p=(0,W.useRef)(!1),m=(0,W.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),bL.getState().setSubscriptionManager(null);let e=d.current;if(d.current=null,e)try{u.current.disposeRuntime(e)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime:`,e)}r(null),l(null)},[]),h=(0,W.useCallback)(e=>{if(!p.current){p.current=!0,s(!0),l(null);try{f.current&&=(f.current.dispose(),null);let t=d.current;if(d.current=null,t)try{u.current.disposeRuntime(t)}catch(e){console.error(`[RuntimeProvider] Error disposing existing runtime:`,e)}let n=u.current.createRuntime(e);if(d.current=n,r(n),n){let e=new Ef(n);e.add(new Tf({id:`local`})),f.current=e,a(e),bL.getState().setSubscriptionManager(e)}else f.current=null,a(null),bL.getState().setSubscriptionManager(null)}catch(e){console.error(`[RuntimeProvider] Error creating runtime:`,e),l(e instanceof Error?e:Error(String(e))),d.current=null}finally{p.current=!1,s(!1)}}},[]);(0,W.useEffect)(()=>()=>{if(f.current&&f.current.dispose(),d.current)try{u.current.disposeRuntime(d.current)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime on unmount:`,e)}},[]);let g={runtime:n,isInitializing:o,error:c,initializeRuntime:h,disposeRuntime:m};return(0,G.jsx)(vL.Provider,{value:g,children:(0,G.jsx)(yL.Provider,{value:i,children:t})})};function SL({factory:e,children:t}){return(0,G.jsx)(xL,{factory:e,children:t})}var CL=`bg-background ring-1 ring-zinc-950/5 shadow-sm lg:shadow-[-18px_0_36px_-28px_rgba(15,23,42,0.16),18px_0_36px_-28px_rgba(15,23,42,0.16)] dark:shadow-none dark:ring-white/10`,wL=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function TL({id:e,title:t,subtitle:n,titleAccessory:r,actions:i,queryBar:a,subheader:o,titleTestId:s,className:c}){return(0,G.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:K(`max-lg:hidden lg:sticky lg:top-0 z-30 bg-background/80 backdrop-blur-md transition-colors`,c),children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,children:[t&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[(0,G.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{"data-testid":s,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:t}),n&&(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:n})]}),r]})]}),a&&(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),i&&(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:i})]}),o&&(0,G.jsx)(`div`,{className:`bg-background/40`,children:o})]})}function EL({ids:e,enabled:t=!0,rootMargin:n=`-10% 0px -40% 0px`,threshold:r=[0,.3,1],onChange:i,shouldAcceptChange:a,scrollDirection:o=`ratio`,dataAttribute:s,debounceMs:c=0}){let l=(0,W.useRef)(``),u=(0,W.useRef)(i),d=(0,W.useRef)(a),f=(0,W.useRef)(null),p=(0,W.useRef)(1);(0,W.useEffect)(()=>{u.current=i},[i]),(0,W.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,W.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,W.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,W.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,W.useEffect)(()=>{if(!t||g.length===0||typeof IntersectionObserver>`u`)return;let e=new Map,r=e=>s?e.getAttribute(s):e.id||null,i;if(o===`topmost-when-up`){let e=window.scrollY,t=()=>{let t=window.scrollY;t!==e&&(p.current=t>e?1:-1),e=t};window.addEventListener(`scroll`,t,{passive:!0}),i=()=>window.removeEventListener(`scroll`,t)}let a=new IntersectionObserver(t=>{if(t.forEach(t=>{let n=r(t.target);n&&(t.isIntersecting?e.set(n,t.intersectionRatio):e.delete(n))}),e.size===0)return;let n=``;if(o===`topmost-when-up`&&p.current===-1){let t=1/0;e.forEach((e,r)=>{let i=g.indexOf(r);i>=0&&i<t&&(t=i,n=r)})}else{let t=-1;e.forEach((e,r)=>{e>t&&(t=e,n=r)})}!n||n===l.current||d.current&&!d.current(n)||(l.current=n,c>0?(v(),f.current=setTimeout(()=>{u.current(n),f.current=null},c)):u.current(n))},{rootMargin:n,threshold:_});return g.forEach(e=>{let t=s?document.querySelector(`[${s}="${e}"]`):document.getElementById(e);t&&a.observe(t)}),()=>{a.disconnect(),v(),i?.()}},[t,g,_,n,o,s,c,v])}function DL({title:e,titleAccessory:t,actions:n,subheader:r,children:i,index:a=[],activeSectionId:o,hero:s,sections:c,className:l}){let u=!!(c&&c.length>0)&&!e,[,d]=Ht(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,W.useState)(c?.[0]?.id??``);if(EL({ids:a.map(e=>e.id),enabled:!u&&a.length>0,rootMargin:`-10% 0px -40% 0px`,threshold:[0,.3,1],onChange:e=>{d(e)},shouldAcceptChange:()=>!0}),EL({ids:c?.map(e=>e.id)??[],enabled:u,rootMargin:`-20% 0px -50% 0px`,threshold:[0,.25,.5,.75],onChange:p}),u){let e=c.map(e=>({id:e.id,label:e.label,action:{type:`scroll`,sectionId:e.id}}));return(0,G.jsxs)(`div`,{className:K(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,G.jsx)(YI,{activations:e,activeSection:f,variant:`top-fixed`,deps:{navigate:()=>{},setQueryParam:()=>{},scrollToSection:e=>{let t=document.getElementById(e);if(t){let e=t.getBoundingClientRect().top+window.scrollY-64;window.scrollTo({top:e,behavior:`smooth`})}}}}),(0,G.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,G.jsx)(`div`,{id:e.id,"data-section-id":e.id,className:`py-12 lg:py-16 px-6 lg:px-10 border-b border-border/30`,children:e.content},e.id);return e.runtimeFactory?(0,G.jsx)(SL,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,G.jsx)(`div`,{className:K(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,G.jsxs)(`div`,{className:K(wL,CL),children:[(0,G.jsx)(TL,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,G.jsx)(`div`,{className:`flex-1`,children:i})]})})}var OL=`[data-page-sticky-boundary="true"]`,kL=0;function AL(e,t=kL){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(OL)).reduce((e,t)=>{let n=t.getBoundingClientRect();return n.height<=0||n.bottom<=0?e:Math.max(e,n.bottom)},0);return n>0?n+t:e}function jL(e,t=kL){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r(AL(e,t)))};return i(),window.addEventListener(`scroll`,i,{passive:!0}),window.addEventListener(`resize`,i),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i)}},[e,t]),n}function ML({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,G.jsxs)(`div`,{"data-testid":a,className:K(`sticky z-10 flex items-center gap-2 border-y border-border/60 bg-card/95 px-6 py-2 shadow-[0_1px_2px_rgba(0,0,0,0.03)] backdrop-blur`,o),style:{top:`${e}px`},children:[n,(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var NL=(0,W.createContext)(null),PL=(0,W.createContext)(null);function FL({children:e}){let[t,n]=(0,W.useState)(null);return(0,G.jsx)(PL.Provider,{value:n,children:(0,G.jsx)(NL.Provider,{value:t,children:e})})}function IL({className:e}){let t=(0,W.useContext)(PL);return(0,G.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function LL(){return(0,W.useContext)(NL)}function RL({editor:e,title:t,subtitle:n,titleTestId:r,actions:i,timerOverlay:a,reviewOverlay:o,isTimerOpen:s=!1,isReviewOpen:c=!1,onCloseTimer:l,onCloseReview:u,className:d}){return(0,G.jsxs)(`div`,{className:K(`relative flex w-full min-h-screen justify-start items-start`,d),children:[(0,G.jsxs)(`div`,{className:K(wL,CL),children:[(0,G.jsx)(TL,{title:t,subtitle:n,titleTestId:r,actions:i}),(0,G.jsx)(`main`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),s&&a&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,G.jsx)(`button`,{onClick:l,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:a})]})}),c&&o&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,G.jsx)(`button`,{onClick:u,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:o})]})})]})}function zL(e){return e.map(e=>{let t=e.action,n=e.secondaryAction?.action,r={kind:`link`,id:e.id,label:e.label,muted:e.level===3&&!!e.secondaryAction};return n&&n.type===`call`&&(r.onRun=n.handler,r.runIcon=e.secondaryRunIcon??`play`),t.type===`route`?{...r,to:t.to}:t.type===`scroll`?{...r,sectionId:t.sectionId}:t.type===`call`?{...r,onRun:t.handler}:r})}var BL=W.createContext(null);function VL(){let e=W.useContext(BL);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}var HL=({children:e,open:t,onOpenChange:n})=>{let r=W.useContext(BL),i=W.useId(),a=r?`${r.portalChain}/${i}`:i,[o,s]=W.useState(t??!1),c=W.useRef(null),[l,u]=W.useState(-1),d=W.useRef(new Map),[,f]=W.useReducer(e=>e+1,0);W.useEffect(()=>{t!==void 0&&s(t)},[t]);let p=W.useCallback(e=>{s(e),u(-1),n?.(e)},[n]),m=W.useCallback((e,t)=>{d.current.set(e,t),f()},[]),h=W.useCallback(e=>{d.current.delete(e),f()},[]),g=W.useCallback(e=>Array.from(d.current.keys()).indexOf(e),[]),_=d.current.size,v=W.useMemo(()=>({isOpen:o,setIsOpen:p,triggerRef:c,registerItem:m,unregisterItem:h,getItemIndex:g,activeIndex:l,setActiveIndex:u,itemCount:_,menuId:i,portalChain:a}),[o,p,m,h,g,l,_,i,a]);return(0,G.jsx)(BL.Provider,{value:v,children:(0,G.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},UL=W.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=VL(),s=e=>{e.stopPropagation(),o(!a)};return n&&W.isValidElement(t)?W.cloneElement(t,{...r,onClick:s}):(0,G.jsx)(`button`,{ref:i,className:e,onClick:s,...r,children:t})});UL.displayName=`DropdownMenuTrigger`;var WL=W.forwardRef(({className:e,children:t,align:n=`center`,side:r=`bottom`,...i},a)=>{let{isOpen:o,setIsOpen:s,triggerRef:c,setActiveIndex:l,itemCount:u,menuId:d,portalChain:f}=VL(),p=W.useRef(null),m=a||p,[h,g]=W.useState({top:0,bottom:0,left:0,width:0});W.useEffect(()=>{if(!o||!c.current)return;let e=c.current.getBoundingClientRect();g({top:e.bottom+8,bottom:window.innerHeight-e.top+8,left:e.left,width:e.width})},[o,c]),W.useEffect(()=>{if(!o||u===0)return;let e=setTimeout(()=>{l(0)},0);return()=>clearTimeout(e)},[o,u,l]),W.useEffect(()=>{if(!o)return;let e=e=>{let t=e.target;if(m.current&&m.current.contains(t)||c.current&&c.current.contains(t))return;let n=t.closest?.(`[data-dropdown-chain]`)?.getAttribute(`data-dropdown-chain`);n&&n.split(`/`).includes(d)||s(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[o,s,m,c,d]);let _=e=>{if(u!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),l(e=>e<u-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),l(e=>e>0?e-1:u-1);break;case`Home`:e.preventDefault(),l(0);break;case`End`:e.preventDefault(),l(u-1);break;case`Escape`:e.preventDefault(),s(!1),c.current?.querySelector(`button`)?.focus();break;case`Tab`:s(!1)}};if(!o)return null;let v={position:`fixed`,zIndex:9999};return r===`top`?v.bottom=h.bottom:v.top=h.top,n===`end`?v.right=window.innerWidth-h.left-h.width:n===`start`?v.left=h.left:(v.left=h.left+h.width/2,v.transform=`translateX(-50%)`),qx.createPortal((0,G.jsx)(`div`,{ref:m,role:`menu`,"data-dropdown-chain":f,className:K(`min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95`,e),style:v,onKeyDown:_,...i,children:t}),document.body)});WL.displayName=`DropdownMenuContent`;var GL=W.forwardRef(({className:e,disabled:t,inset:n,onClick:r,onKeyDown:i,...a},o)=>{let{setIsOpen:s,registerItem:c,unregisterItem:l,getItemIndex:u,activeIndex:d}=VL(),f=W.useId(),p=W.useRef(null),m=W.useCallback(e=>{p.current=e,typeof o==`function`?o(e):o&&(o.current=e)},[o]);W.useEffect(()=>(c(f,p),()=>l(f)),[f,c,l]);let h=u(f)===d;return W.useEffect(()=>{h&&p.current?.focus()},[h]),(0,G.jsx)(`div`,{ref:m,role:`menuitem`,tabIndex:t?-1:h?0:-1,"aria-disabled":t,"data-active":h?`true`:void 0,className:K(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors`,`focus:bg-accent focus:text-accent-foreground`,`data-[active]:bg-accent data-[active]:text-accent-foreground`,n&&`pl-8`,t&&`pointer-events-none opacity-50`,e),onClick:e=>{t||(r?.(e),s(!1))},onKeyDown:e=>{t||(i?.(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r?.(e),s(!1)))},...a})});GL.displayName=`DropdownMenuItem`;var KL=W.forwardRef(({className:e,inset:t,...n},r)=>(0,G.jsx)(`div`,{ref:r,className:K(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));KL.displayName=`DropdownMenuLabel`;var qL=W.forwardRef(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:K(`-mx-1 my-1 h-px bg-muted`,e),...t}));qL.displayName=`DropdownMenuSeparator`;function JL({className:e,children:t,...n}){return(0,G.jsx)(`div`,{className:K(`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,e),...n,children:t})}var YL=[{label:`Past 1 week`,value:`last 1w`},{label:`Past 2 weeks`,value:`last 2w`},{label:`Past 4 weeks`,value:`last 4w`},{label:`Past 8 weeks`,value:`last 8w`},{label:`Past 12 weeks`,value:`last 12w`},{label:`Past 1 year`,value:`last 52w`},{label:`All time`,value:`all`}],XL=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function ZL(e,t){return new Date(e,t+1,0).getDate()}function QL(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function $L(e,t){let n=X(e);if(n.error)return e;if(!t||t===`all`)return Mm({...n,window:void 0});let r=X(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:Mm({...n,window:r.window})}function eR(e){let t=X(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function tR({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,W.useMemo)(()=>eR(e),[e]),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(()=>new Date),l=s.getFullYear(),u=s.getMonth(),d=(0,W.useMemo)(()=>i?i.kind===`relative`?`last ${i.size}${i.unit}`:i.end?`from ${i.start} to ${i.end}`:`from ${i.start}`:`All time`,[i]),f=(0,W.useMemo)(()=>{if(!i)return null;if(i.kind===`range`)return{start:i.start,end:i.end??i.start};let e=new Date,t=new Date;return i.unit===`d`?t.setDate(e.getDate()-i.size):t.setDate(e.getDate()-i.size*7),{start:Gj(t),end:Gj(e)}},[i]),p=(0,W.useMemo)(()=>{let e=ZL(l,u),t=QL(l,u),n=[];for(let e=0;e<t;e++)n.push(null);for(let t=1;t<=e;t++)n.push(t);return n},[l,u]),m=n=>{if(!a)o(n),t($L(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t($L(e,`from ${r} to ${i}`))}},h=e=>{e.stopPropagation(),c(new Date(l,u-1,1))},g=e=>{e.stopPropagation(),c(new Date(l,u+1,1))},_=s.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`}),v=Gj(new Date);return(0,G.jsxs)(`div`,{className:K(`relative inline-flex items-center`,r),children:[(0,G.jsxs)(HL,{children:[(0,G.jsx)(UL,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`wql-window-picker-trigger`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,G.jsx)(dn,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,G.jsx)(St,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,G.jsxs)(WL,{align:`end`,className:`w-72 p-3`,children:[(0,G.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1 border-b border-border/60 pb-2`,children:YL.map(n=>{let r=n.value===`all`?!i:i?.kind===`relative`&&`last ${i.size}${i.unit}`===n.value;return(0,G.jsx)(`button`,{type:`button`,"data-testid":`wql-window-preset-${n.value}`,onClick:()=>{o(null),t($L(e,n.value))},className:K(`rounded-md px-2 py-1 text-[11px] font-medium transition-colors`,r?`bg-primary text-primary-foreground`:`bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground`),children:n.label},n.value)})}),(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:h,"data-testid":`wql-calendar-prev-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Previous month`,children:(0,G.jsx)(Rn,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:_}),(0,G.jsx)(`button`,{type:`button`,onClick:g,"data-testid":`wql-calendar-next-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Next month`,children:(0,G.jsx)(xn,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:XL.map(e=>(0,G.jsx)(`div`,{className:`text-center text-[10px] font-medium text-muted-foreground`,children:e},e))}),(0,G.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,"data-testid":`wql-calendar-grid`,children:p.map((e,t)=>{if(e===null)return(0,G.jsx)(`div`,{className:`size-8`},`empty-${t}`);let r=`${l}-${String(u+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,i=f&&r>=f.start&&r<=f.end,o=f&&r===f.start||a===r,s=f&&r===f.end,c=r===v,d=n.has(r);return(0,G.jsxs)(`button`,{type:`button`,"data-testid":`wql-calendar-day-${r}`,onClick:()=>m(r),className:K(`relative flex size-8 items-center justify-center rounded-md text-xs transition-colors`,o||s?`bg-primary font-bold text-primary-foreground`:i?`bg-primary/15 font-semibold text-primary`:c?`border border-primary font-semibold text-primary`:`text-foreground hover:bg-muted`),children:[(0,G.jsx)(`span`,{children:e}),d&&!o&&!s&&(0,G.jsx)(`span`,{className:`absolute bottom-0.5 size-1 rounded-full bg-primary`})]},r)})}),a&&(0,G.jsxs)(`div`,{className:`mt-2 text-center text-[10px] text-muted-foreground`,children:[`Select second date to complete range (starting from `,a,`)`]})]})]}),i&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`wql-window-picker-clear`,onClick:()=>{o(null),t($L(e,null))},title:`Clear time window`,"aria-label":`Clear time window`,className:`ml-1 grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,G.jsx)(Se,{className:`size-3.5`})})]})}function nR(e){switch(e.kind){case`note`:case`post`:return`note`;case`session`:return`session`;case`result`:return`result`;case`segment`:case`event`:return`segment`;case`effort`:return`effort`;default:return`note`}}var rR=[{id:`title`,label:`Title`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`tags`,label:`Tags`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.tags??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)},{id:`excerpt`,label:`Text Excerpt`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.block?.preview?.join(` `)||e.detail||``,formatValue:e=>String(e??``)},{id:`catalog`,label:`Catalog Source`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.sourceCatalog,formatValue:e=>String(e??``)},{id:`date`,label:`Date`,level:`note`,defaultVisible:!0,align:`right`,getValue:e=>e.date,formatValue:e=>String(e??``)}],iR={note:rR,session:[{id:`title`,label:`Title`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`protocol`,label:`Protocol`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.block?.dataType||e.subtitle||``,formatValue:e=>String(e??``)},{id:`movements`,label:`Movements`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.detail||``,formatValue:e=>String(e??``)},{id:`targetDuration`,label:`Target Duration`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:xI(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``}],result:[{id:`title`,label:`Title`,level:`result`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`elapsedTime`,label:`Elapsed Time`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:xI(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{id:`tis`,label:`TIS Score`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.tis,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`prBadges`,label:`PR Badges`,level:`result`,defaultVisible:!0,align:`center`,getValue:e=>e.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:xI(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`roundIndex`,label:`Round/Lap Index`,level:`segment`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`reps`,label:`Reps`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.reps,formatValue:e=>e==null?``:String(e)},{id:`load`,label:`Load`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{id:`pacingTier`,label:`Pacing / HR Tier`,level:`segment`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier||e.execution?.effortSlug||``,formatValue:e=>String(e??``)}],effort:[{id:`label`,label:`Label`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.label||e.title,formatValue:e=>String(e??``)},{id:`canonicalSlug`,label:`Canonical Slug`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.slug||e.id,formatValue:e=>String(e??``)},{id:`discipline`,label:`Discipline`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.discipline??``,formatValue:e=>String(e??``)},{id:`met`,label:`MET Score`,level:`effort`,defaultVisible:!0,align:`right`,getValue:e=>e.effort?.met,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`intensityTier`,label:`Intensity Tier`,level:`effort`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier??``,formatValue:e=>String(e??``)},{id:`aliases`,label:`Aliases`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.aliases??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)}]};function aR(e){return iR[e]??rR}function oR(e){return aR(e).filter(e=>e.defaultVisible).map(e=>e.id)}var sR=[{id:`cards`,label:`Cards`,icon:tn},{id:`rows`,label:`Rows`,icon:B},{id:`feed`,label:`Feed`,icon:qn}];function cR({streamControls:e}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`l3-stream-controls`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date window`}),(0,G.jsx)(tR,{query:e.query,onQueryChange:e.onQueryChange,className:`w-full justify-between`})]}),e.availableGroupDims.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Group by`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-groupby-options`,children:e.availableGroupDims.map(t=>{let n=e.groupDims.some(e=>e.toLowerCase()===t.id.toLowerCase());return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-groupby-${t.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleGroupDim(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{children:t.label})]},t.id)})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Layout`}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,"data-testid":`l3-layout-options`,children:sR.map(t=>{let n=t.icon,r=e.settings.layout===t.id;return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>e.onLayoutChange(t.id),"data-testid":`l3-layout-${t.id}`,className:`flex min-h-8 items-center justify-center gap-1 rounded-md border px-1.5 py-1 text-[11px] font-medium transition-colors ${r?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,G.jsx)(n,{"aria-hidden":!0,className:`size-3`}),t.label]},t.id)})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Fields`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-field-options`,children:aR(e.level).map(t=>{let n=e.settings.visibleFields.includes(t.id);return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-field-${t.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleField(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{children:t.label})]},t.id)})})]})]})}function lR({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=bA(),i=II(e),a=(0,W.useMemo)(()=>zL(n),[n]),o=LI();return i.length===0&&a.length===0&&!r&&!t?null:(0,G.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[r&&(0,G.jsx)(`div`,{className:`pb-3 border-b border-border/50`,children:(0,G.jsx)(cR,{streamControls:r})}),i.length>0&&(0,G.jsx)(zI,{entries:i,activeId:o}),a.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 pt-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,G.jsx)(zI,{entries:a,activeId:o})]}),t&&(0,G.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var uR=1023;function dR(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function fR(e,t){if(e===`query:new`)return``;let n=e=>{let n=`/${e}`;for(let r of Object.keys(t))if(r===e||r.endsWith(n))return r;return null},r=e=>{let r=n(e);return r===null?null:hb(t[r])};if(e.startsWith(`markdown/`)){let t=r(e);if(t!==null)return t}let i=e;if(e.startsWith(`wods/examples/`))i=`markdown/canvas/`+e.replace(/^wods\/examples\//,``);else if(e.startsWith(`wods/`))i=`markdown/canvas/`+e.replace(/^wods\//,``);else if(e.startsWith(`collections/`))i=`markdown/collections/`+e.replace(/^collections\//,``);else if(e.startsWith(`canvas/`))i=`markdown/canvas/`+e.replace(/^canvas\//,``);else{let t=r(`markdown/canvas/`+e);if(t!==null)return t;let n=r(`markdown/collections/`+e);if(n!==null)return n;i=`markdown/`+e}return r(i)??`# Source not found\n\nPath: \`${e}\`\nResolved: \`${i}\``}function pR(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function mR(e){let t=new Map,n=null;for(let r of e)pR(r)&&(n=r),t.set(r.id,n);return t}function hR(){let[e,t]=(0,W.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${uR}px)`).matches);return(0,W.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${uR}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var gR=`wodwiki:fabAlignment`,_R=[{id:`left`,label:`Bottom left`,description:`Left-handed — search and page actions float near your left thumb`},{id:`right`,label:`Bottom right`,description:`Right-handed — search and page actions float near your right thumb`}];function vR(){try{return yR(localStorage.getItem(gR))}catch{return}}function yR(e){return e===`right`||e===`left`?e:void 0}var bR=typeof window>`u`?void 0:vR();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===gR&&(bR=yR(e.newValue))});function xR(e){bR=e;try{e===`right`?localStorage.removeItem(gR):localStorage.setItem(gR,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:gR,newValue:e}))}function SR(){let[e,t]=(0,W.useState)(()=>bR??`right`);return(0,W.useEffect)(()=>{let e=e=>{e.key===gR&&t(yR(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,xR]}function CR({onOpen:e}){return(0,G.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,"data-testid":`search-fab`,className:K(`size-14 rounded-full flex items-center justify-center`,`bg-primary text-primary-foreground shadow-lg`,`hover:bg-primary/90 active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:(0,G.jsx)(Zt,{className:`size-6`})})}var wR=(0,W.createContext)(null),TR=(0,W.createContext)(!1),ER=(0,W.createContext)(null);function DR(){return(0,W.useContext)(wR)!==null}function OR({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,W.useContext)(wR),o=(0,W.useContext)(TR),s=hR(),c=(0,W.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=(0,G.jsx)(TR.Provider,{value:!0,children:n});return(0,W.useEffect)(()=>{if(!(!l&&!u))return a.register({id:c,primary:e,navbar:t,children:d,label:r??`Page options`,fallback:i}),()=>a.unregister(c)},[l,u,a,c,e,d,r,i]),i||a&&s&&!o?null:(0,G.jsx)(TR.Provider,{value:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function kR({onSearch:e,children:t}){let[n,r]=(0,W.useState)([]),i=(0,W.useCallback)(e=>r(t=>[...t.filter(t=>t.id!==e.id),e]),[]),a=(0,W.useCallback)(e=>r(t=>t.filter(t=>t.id!==e)),[]),o=(0,W.useMemo)(()=>({register:i,unregister:a}),[i,a]),s=(0,W.useMemo)(()=>{for(let e=n.length-1;e>=0;--e)if(!n[e].fallback)return n[e].navbar??null;return null},[n]);return(0,G.jsx)(wR.Provider,{value:o,children:(0,G.jsxs)(ER.Provider,{value:s,children:[t,(0,G.jsx)(jR,{registrations:n,onSearch:e})]})})}function AR(){let e=(0,W.useContext)(ER);return e?(0,G.jsx)(G.Fragment,{children:e}):null}function jR({registrations:e,onSearch:t}){let n=hR(),[r]=SR(),i=Yx(),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=dt(),[l,u]=(0,W.useState)(!1),d=(0,W.useRef)(0),f=i.offsetBottom>0,p=(0,W.useRef)(null),m=(0,W.useRef)(null),h=(0,W.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),g=(0,W.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]);(0,W.useEffect)(()=>{o(!1),u(!1),d.current=window.scrollY},[c.pathname]),(0,W.useEffect)(()=>{if(!n)return;let e=()=>{let e=window.scrollY;if(e<=0||f||a){d.current=e,u(!1);return}let t=e-d.current;Math.abs(t)<8||(d.current=e,u(t>0))};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[n,f,a]),(0,W.useLayoutEffect)(()=>{a&&s.current?.focus()},[a]);let[_,v]=(0,W.useState)({active:0,global:0});(0,W.useLayoutEffect)(()=>{let e=p.current?.childElementCount??0,t=m.current?.childElementCount??0;v(n=>n.active===e&&n.global===t?n:{active:e,global:t})},[h,g]);let y=_.active>0||_.global>0;return!n||!t&&!h&&!g?null:(0,G.jsxs)(`div`,{"data-testid":`actions-dock`,className:K(`lg:hidden fixed z-40 flex flex-col items-center gap-2`,`transition-[transform,visibility] duration-200 ease-out`,r===`left`?`left-4 items-start`:`right-4 items-end`,l&&!a&&!f&&`translate-y-[calc(100%+2rem)] invisible pointer-events-none`),style:{bottom:`calc(1rem + var(--thumb-dock-lift, 0px) + ${i.offsetBottom}px + env(safe-area-inset-bottom))`},children:[(0,G.jsxs)(`div`,{className:`relative z-40 flex flex-col items-center gap-2`,children:[h?.primary&&(0,G.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:h.primary}),t&&(0,G.jsx)(CR,{onOpen:()=>{o(!1),t()}})]}),a&&y&&(0,G.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 cursor-default`,onClick:()=>o(!1)}),(0,G.jsxs)(`div`,{ref:s,role:`dialog`,"aria-label":h?.label??g?.label??`Page options`,tabIndex:-1,hidden:!a||!y,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),o(!1))},className:K(`relative z-40 flex w-60 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/5 outline-none`,`[&_button]:min-h-11 [&_button]:min-w-11`),style:{maxHeight:`calc(${i.height===null?`100dvh`:`${i.height}px`} - 6rem - env(safe-area-inset-bottom))`},children:[(0,G.jsx)(`div`,{ref:p,className:`contents`,children:h?.children}),_.active>0&&_.global>0&&(0,G.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,G.jsx)(`div`,{ref:m,className:`contents`,children:g?.children})]}),y&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-label":h?.label??g?.label??`Page options`,"aria-expanded":a,"data-testid":`actions-overflow`,className:K(`relative z-40 flex size-12 items-center justify-center rounded-full`,`bg-card text-foreground shadow-lg ring-1 ring-foreground/10`,`hover:bg-muted active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:a?(0,G.jsx)(Fe,{className:`size-6`}):(0,G.jsx)(pe,{className:`size-6`})})]})}function MR(){return(0,G.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,G.jsx)(`path`,{d:`M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z`})})}function NR(){return(0,G.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}function PR(){let{tree:e,navState:t,contextNav:n}=bA(),r=dt(),i=rM();return!e.find(e=>e.id===t.activeL1Id)?.applyFooter||n?.pathname===r.pathname?null:(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})}function FR({open:e,close:t,onSearch:n,onCreate:r,children:i}){return(0,G.jsxs)(ze,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Ue,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,G.jsx)(A,{transition:!0,className:`fixed inset-y-0 left-0 w-full transition duration-300 ease-out data-closed:-translate-x-full`,children:(0,G.jsx)(nM,{close:t,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,G.jsx)(`div`,{className:`flex h-full w-14 shrink-0 flex-col items-center border-r border-zinc-950/5 bg-background/72 py-3 dark:border-white/5 [&_a]:size-11 [&_button]:size-11`,children:(0,G.jsx)(JI,{onSearch:()=>{t(),n?.()},onCreate:r?()=>{t(),r()}:void 0})}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,G.jsx)(`div`,{className:`flex items-center px-4 pt-3`,children:(0,G.jsx)(et,{as:zP,"aria-label":`Close navigation`,children:(0,G.jsx)(NR,{})})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),(0,G.jsx)(PR,{})]})]})})})]})}function IR({open:e,close:t,children:n}){return(0,G.jsxs)(ze,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Ue,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,G.jsx)(A,{transition:!0,className:`fixed inset-y-0 right-0 w-full transition duration-300 ease-out data-closed:translate-x-full`,children:(0,G.jsx)(nM,{close:t,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-end px-4 pt-3`,children:(0,G.jsx)(et,{as:zP,"aria-label":`Close page options`,children:(0,G.jsx)(NR,{})})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:n}),(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})]})})})]})}function LR({navbar:e,sidebar:t,onSearch:n,onCreate:r,secondary:i,pageAction:a,hideDesktopSidebar:o,children:s}){let[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),f=(0,W.useRef)(null),[p,m]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=f.current;if(!e)return;let t=()=>m(t=>{let n=e.childElementCount>0;return t===n?t:n}),n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0}),t(),()=>n.disconnect()},[]);let{streamControls:h}=bA(),g=(0,W.useMemo)(()=>{let e=X(h?.query??``);return!e.error&&Vp(e)&&e.filters.length>0},[h?.query]);return(0,G.jsx)(FL,{children:(0,G.jsx)(kR,{onSearch:n,children:(0,G.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,G.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,G.jsxs)(`nav`,{"aria-label":`Main`,className:`hidden lg:flex`,children:[(0,G.jsx)(`div`,{className:`w-14 shrink-0 sticky top-0 h-svh flex flex-col items-center border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm z-40 py-3`,children:(0,G.jsx)(JI,{onSearch:n??(()=>{}),onCreate:r})}),(0,G.jsx)(`div`,{className:K(`w-60 shrink-0 sticky top-0 self-start h-svh min-h-0 overflow-hidden border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm flex flex-col`,o&&`lg:hidden`),children:t})]}),(0,G.jsx)(FR,{open:c,close:()=>l(!1),onSearch:n,onCreate:r,children:t}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col min-w-0 xl:max-w-[984px] 2xl:max-w-none`,children:[(0,G.jsxs)(`header`,{"data-page-sticky-boundary":`true`,className:`lg:hidden sticky top-0 z-20 flex items-center px-2 sm:px-4 bg-card`,children:[(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsx)(zP,{onClick:()=>l(!0),"aria-label":`Open navigation`,children:(0,G.jsx)(MR,{})})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),r&&(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsx)(zP,{onClick:r,"aria-label":`New journal note`,children:(0,G.jsx)(Wt,{className:`size-5`})})}),p&&(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsx)(zP,{onClick:()=>d(!0),"aria-label":`Open page options`,children:(0,G.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,G.jsx)(hn,{className:`size-5`}),g&&(0,G.jsx)(`span`,{"data-testid":`drawer-filters-active`,className:`absolute -top-1 -right-1 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`})]})})})]}),(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col lg:min-w-0`,children:[(0,G.jsx)(`div`,{className:`grow w-full max-lg:pb-48 lg:overflow-visible`,children:s}),(0,G.jsx)(RR,{})]})]}),(0,G.jsx)(`aside`,{className:`hidden 2xl:flex w-60 shrink-0 sticky top-0 h-svh flex-col overflow-y-auto bg-background/72 backdrop-blur-sm`,children:(0,G.jsx)(`div`,{ref:f,className:`contents`,children:(0,G.jsx)(lR,{spec:i,pageAction:a})})}),(0,G.jsx)(IR,{open:u,close:()=>d(!1),children:(0,G.jsx)(lR,{spec:i,pageAction:a})})]})})})})}function RR(){let e=(0,W.useRef)(null),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=Math.round(e[0]?.contentRect.height??0);n(e=>e===t?e:t)});r.observe(t,{box:`content-box`});let i=Math.round(t.getBoundingClientRect().height);return n(e=>e===i?e:i),()=>r.disconnect()},[]),(0,W.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${t}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[t]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:K(`lg:hidden fixed inset-x-0 bottom-0 z-30`,t>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,G.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,G.jsx)(IL,{className:`flex w-full min-w-0`})})}),(0,G.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function zR(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function BR(e){return String(gb(ub(e).meta,`search`)??``).toLowerCase()===`hidden`}function VR(e){let t=gb(ub(e).meta,`date`);if(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t))return;let n=new Date(`${t}T12:00:00Z`);return Number.isFinite(n.getTime())&&n.toISOString().slice(0,10)===t?n.getTime():void 0}function HR(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=gb(ub(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():kE(r),category:zR(n),content:i,date:VR(i),searchHidden:BR(i)}})}function UR(){let e=ZE();return(0,W.useMemo)(()=>e?HR(e):[],[e])}var WR={};function GR(e){if(!(`payload`in e))return;let t=e.payload;if(!t||typeof t!=`object`)return;let n=t;return n.targetDate??n.updatedAt}function KR(e,t){let{canvasPage:n,workoutItems:r,recentResults:i,selectWorkout:a}=t;if(n){let t=/^\/(?:c|collections)\//.test(e),i=t?e.split(`/`).pop()??null:null;if(e===`/`)return[];let o=[],s=e.startsWith(`/guide/`);return n.sections.filter(e=>e.level>1).forEach(e=>{if(o.push({id:e.id,label:e.heading,type:`heading`}),!s){let t=sP(e).split(`
|
|
100
|
+
`).map(e=>e.trim()).filter(Boolean).slice(0,gI).map(e=>e.length>_I?`${e.slice(0,119)}…`:e)}function yI(e){let t=pI(hI(e));return{...t,blockContentId:e.blockContentId??t.blockContentId,catalog:ng(e),block:{blockId:e.blockId,dataType:e.dataType,preview:vI(e.rawContent)}}}function bI(e){return e?e.split(`-`).map(e=>{let t=e.toLowerCase();return t===`c2b`?`C2B`:t===`t2b`?`T2B`:t===`ghd`?`GHD`:t===`hspu`?`HSPU`:e.charAt(0).toUpperCase()+e.slice(1)}).join(` `):``}function xI(e){if(!Number.isFinite(e)||e<=0)return`00:00`;let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;if(n>=60){let e=Math.floor(n/60),t=n%60;return`${e}:${String(t).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}function SI(e){if(!e)return`Workout Session`;let t=tI(e);return t.kind===`journal`?t.id?`Journal: ${t.id}`:`Journal Entry`:t.kind===`workout`?bI(t.id)||t.id:t.id?bI(t.id):e}function CI(e){let t=[e.baseAttributes?.discipline,e.baseAttributes?.met==null?void 0:`MET ${e.baseAttributes.met.toFixed(1)}`,e.baseAttributes?.intensityTier].filter(Boolean);return{id:e.slug,kind:`effort`,sourceCatalog:e.registrySource??`effort`,sourceItem:e.slug,title:e.label,date:null,subtitle:t.join(` • `),detail:e.aliases&&e.aliases.length>0?`Aliases: ${e.aliases.join(`, `)}`:void 0,effort:{slug:e.slug,label:e.label,discipline:e.baseAttributes?.discipline,met:e.baseAttributes?.met,intensityTier:e.baseAttributes?.intensityTier,aliases:e.aliases,registrySource:e.registrySource}}}function wI(e){let t=(e.type??``).toLowerCase(),n=(`name`in e&&typeof e.name==`string`?e.name:``).toLowerCase(),r=typeof e.value==`number`?e.value:Number(e.value);return Number.isFinite(r)?t===`rep`||n===`reps`||n===`rep`?{kind:`rep`,val:r}:t===`weight`||t===`load`||n===`load`||n===`weight`||n===`volume`?{kind:`load`,val:r}:t===`distance`||n===`distance`?{kind:`distance`,val:r}:t===`tis`||n===`tis`?{kind:`tis`,val:r}:t===`duration`||n===`duration`?{kind:`duration`,val:r}:null:null}function TI(e){let t=1/0,n=-1/0,r=0,i=0,a=0,o=0,s=new Set;for(let c of e.events)if(c.outputType===`segment`&&o++,c.effortSlug&&s.add(c.effortSlug),c.timeSpan?.started!=null&&(c.timeSpan.started<t&&(t=c.timeSpan.started),c.timeSpan.ended!=null&&c.timeSpan.ended>n&&(n=c.timeSpan.ended)),Array.isArray(c.metrics))for(let e of c.metrics){let t=wI(e);t&&(t.kind===`rep`?r+=t.val:t.kind===`load`?i+=t.val:t.kind===`tis`&&t.val>a&&(a=t.val))}return{elapsedMs:Number.isFinite(t)&&Number.isFinite(n)&&n>t?n-t:void 0,reps:r>0?r:void 0,loadLbs:i>0?i:void 0,tis:a>0?a:void 0,segmentCount:o>0?o:void 0,effortSlugs:Array.from(s)}}function EI(e,t){let n=TI(e),r=[];n.elapsedMs!=null&&r.push(xI(n.elapsedMs)),n.tis!=null&&r.push(`TIS ${n.tis.toFixed(1)}`),n.loadLbs!=null&&r.push(`Volume: ${n.loadLbs.toLocaleString()} lbs`),n.reps!=null&&r.push(`${n.reps} reps`),n.segmentCount!=null&&r.push(`${n.segmentCount} splits`);let i=n.effortSlugs.map(bI),a=Gj(new Date(e.timestamp)),o=e.events.find(e=>!!e.blockContentId)?.blockContentId;return{id:e.resultId,kind:`result`,sourceCatalog:`results`,sourceItem:e.resultId,title:t?.noteTitle??SI(e.noteId),date:a,blockContentId:o,subtitle:r.join(` • `),detail:i.length>0?i.join(`, `):void 0,execution:{resultId:e.resultId,noteId:e.noteId,timestamp:e.timestamp,outputType:`all`,elapsedMs:n.elapsedMs,reps:n.reps,loadLbs:n.loadLbs,tis:n.tis,segmentCount:n.segmentCount,events:e.events}}}function DI(e,t){let n;e.timeSpan?.started!=null&&e.timeSpan?.ended!=null&&(n=e.timeSpan.ended-e.timeSpan.started);let r,i,a,o;if(Array.isArray(e.metrics))for(let t of e.metrics){let e=wI(t);e&&(e.kind===`rep`?r=e.val:e.kind===`load`?i=e.val:e.kind===`distance`?a=e.val:e.kind===`tis`?o=e.val:e.kind===`duration`&&!n&&(n=e.val))}let s=e.outputType===`segment`?`segment`:`event`,c=t?.index??0,l=e.effortSlug?bI(e.effortSlug):e.outputType===`segment`?`Round ${c+1}`:`${e.outputType.charAt(0).toUpperCase()+e.outputType.slice(1)} ${c+1}`,u=[];n!=null&&u.push(xI(n)),r!=null&&i!=null?u.push(`${r} reps @ ${i} lbs`):r==null?i!=null&&u.push(`${i} lbs`):u.push(`${r} reps`),a!=null&&u.push(`${a}m`),o!=null&&u.push(`TIS ${o.toFixed(1)}`);let d=Gj(new Date(e.timestamp));return{id:e.id,kind:s,sourceCatalog:`results`,sourceItem:e.id,title:l,date:d,blockContentId:e.blockContentId,subtitle:u.join(` • `),detail:e.effortSlug?bI(e.effortSlug):void 0,execution:{resultId:e.resultId,noteId:e.noteId,timestamp:e.timestamp,outputType:e.outputType,effortSlug:e.effortSlug,elapsedMs:n,reps:r,loadLbs:i,distanceMeters:a,tis:o,metrics:e.metrics}}}function OI(e,t){if(!e||e.error||!e.runs)return[];let n=e.parsed?.filters?.find(e=>e.key===`plane`&&!e.negate),r=e.parsed?.outputType??n?.values[0]?.value;if(r===`segment`){let t=[];for(let n of e.runs){let e=0;for(let r of n.events)r.outputType===`segment`&&t.push(DI(r,{index:e++}))}return t}if(r&&r!==`all`){let t=[];for(let n of e.runs){let e=0;for(let i of n.events)i.outputType===r&&t.push(DI(i,{index:e++}))}return t}return e.runs.map(e=>EI(e,{noteTitle:t?.noteTitles?.get(e.noteId)}))}function kI(e,t,n){let r=typeof e.__id==`string`&&e.__id?e.__id:void 0,i=typeof e.__resultId==`string`&&e.__resultId?e.__resultId:void 0,a=typeof e.effort==`string`&&e.effort?e.effort:void 0,o=[];for(let[t,n]of Object.entries(e))t.startsWith(`__`)||t===`date`||t===`effort`||(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)&&o.push(`${t}: ${n}`);return{id:r??i??`${t}:${n}`,kind:t,sourceCatalog:`results`,sourceItem:i??r??`${t}:${n}`,title:a?bI(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function AI(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function jI(e){return typeof e==`object`&&!!e&&`runFind`in e}var MI=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){jI(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver)}get service(){return this.customService??eI}withNoteBlockInfo(){let t=new e({service:this.service,noteTitleResolver:this.noteTitleResolver,noteTagsResolver:this.noteTagsResolver,noteBlockInfo:!0});return Object.prototype.hasOwnProperty.call(this,`query`)&&(t.query=this.query),t}async hydrateEntries(e,t){let n=e=>e.noteId??e.id,r=new Set;for(let i of e)i.sourceCatalog===`journal`&&r.add(n(i)),t&&(!i.title||!i.tags||i.tags.length===0)&&r.add(n(i));if(r.size===0)return;let i=await Z.getEntryBatches([...r]);for(let t of e){if(t.sourceCatalog!==`journal`)continue;let e=i.get(n(t)),r=[...e?.links??[]].sort((e,t)=>(e.position??1/0)-(t.position??1/0)||e.createdAt-t.createdAt);for(let n of r){let r=e?.pages.find(e=>e.id===n.pageId);if(r&&(t.pageId??=r.id,!r.date&&r.slug)){t.pageSlug=r.slug;break}}}if(t)for(let t of e){let e=i.get(n(t));!t.title&&e?.note.title&&(t.title=e.note.title),e&&e.tags.length>0&&((!t.tags||t.tags.length===0)&&(t.tags=e.tags.map(e=>e.label)),t.typedTags=e.tags.map(e=>({label:e.label,type:e.type})))}}async query(e,t){let n=typeof e==`string`?X(e):e;if(!n||n.error)return[];if(Vp(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=(e.efforts??[]).map(CI);return AI(t,e.stages,r),r}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map(yI);return await this.hydrateEntries(r,!0),AI(t,e.stages,r),r}if(n.target===`session`){let e=await this.service.runFind(n);t?.(e.stages);let r;if(this.noteTitleResolver&&e.runs){r=new Map;for(let t of e.runs)if(!r.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&r.set(t.noteId,e)}}let i=OI(e,{noteTitles:r});return AI(t,e.stages,i),i}if(n.target===`segment`||n.target===`event`){let e=n.target,r=await this.service.runFind(n),i=(r.table?.rows??[]).map((t,n)=>kI(t,e,n));return AI(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(pI);if(this.noteTagsResolver?(await this.hydrateEntries(r,!1),await Promise.all(r.map(async e=>{if(!e.tags||e.tags.length===0){let t=await this.noteTagsResolver(e.id);t&&t.length>0&&(e.tags=t)}}))):await this.hydrateEntries(r,!0),AI(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=vI(i.rawContent);try{ka(i.rawContent,i.blocks,i.sourceRevision)}catch{continue}let a=Object.values(i.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&Ea(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=ga(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}return[]}};async function NI(e,t=MI,n){return t.query(e,n)}function PI(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function FI(e){try{let t=(await NI(e.query)).filter(t=>!e.filterEntry||e.filterEntry(t)).slice(0,e.limit??6).map(t=>({kind:`link`,id:`${e.id}:${t.id}`,label:e.labelFromEntry?e.labelFromEntry(t):t.title,to:e.toEntry?e.toEntry(t):void 0,muted:!0}));return{kind:`section`,id:e.id,label:e.label,entries:t}}catch{return{kind:`section`,id:e.id,label:e.label,entries:[]}}}function II(e){let t=PI(e),n=(0,W.useRef)(e);n.current=e;let[r,i]=(0,W.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,W.useEffect)(()=>{let e=n.current;if(!e){i([]);return}if(!e.some(e=>e.kind===`wql`)){i(e);return}let t=!1;return Promise.all(e.map(e=>e.kind===`wql`?FI(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function LI(){let[e]=Ht(`s`,{shallow:!0}),{navState:t}=bA(),n=t.activeL3Id??``;return e||n||``}function RI({entry:e,active:t,onActivate:n}){let r=e.onRun;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:K(`group flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors`,e.muted?`text-[11.5px]`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:K(`hover:bg-muted/60 hover:text-foreground`,e.muted?`text-muted-foreground/70`:`text-muted-foreground`)),children:[e.icon&&(0,G.jsx)(e.icon,{className:`size-4 shrink-0`}),e.timestamp&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.timestamp}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/50`,children:e.badge}),r&&(0,G.jsx)(`span`,{role:`button`,tabIndex:-1,title:e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,onClick:t=>{t.stopPropagation(),e.onRun?.()},className:`flex size-5 shrink-0 items-center justify-center rounded text-primary opacity-0 transition-all group-hover:opacity-100 hover:bg-primary/10`,children:e.runIcon===`link`?(0,G.jsx)(l,{className:`size-3.5`}):e.runIcon===`stop`?(0,G.jsx)(b,{className:`size-3.5`}):e.runIcon===`edit`?(0,G.jsx)(o,{className:`size-3.5`}):(0,G.jsx)(en,{className:`size-3.5`})})]})}function zI({entries:e,activeId:t,onSection:n}){let r=yn(),{scrollToSection:i}=bA(),a=e=>{if(n)return n(e);if(e.onRun)return e.onRun();if(e.to)return r(e.to);if(e.sectionId)return i(e.sectionId)};return(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,G.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,G.jsx)(zI,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:(0,G.jsx)(RI,{entry:e,active:t!=null&&e.sectionId===t,onActivate:a},e.id))})}function BI(){let e=yn(),{scrollToSection:t}=bA();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function VI(){let e=BI(),{openCreateJournal:t}=bA();return n=>{if(n.id===`home-new-journal`){t({mode:`blank`});return}ZM(n.action,e)}}function HI(e,t,n){return e.isActive?e.isActive(n,t):e.action.type===`route`?e.action.to===`/`?n.pathname===`/`||n.pathname===``:n.pathname===e.action.to:e.action.type===`scroll`?t.activeL3Id===e.action.sectionId:e.action.type===`query`&&t.activeL3Id===e.id}function UI({items:e}){let{navState:t}=bA(),n=dt(),r=VI();return(0,G.jsx)(fM,{children:e.map(e=>{if(e.variant===`notable`)return(0,G.jsx)(`div`,{className:`mb-2`,children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`nav-item-${e.id}`,onClick:()=>r(e),className:`flex w-full items-center justify-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-xs font-semibold text-primary transition-all hover:bg-primary hover:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary shadow-sm`,children:[(0,G.jsx)(wn,{className:`size-4 shrink-0`}),(0,G.jsx)(`span`,{children:e.label})]})},e.id);let i=HI(e,t,n);return e.children&&e.children.length>0?(0,G.jsx)(nN,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>HI(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=HI(e,t,n);return(0,G.jsxs)(pM,{onClick:()=>r(e),current:i,children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(mM,{children:e.label})]},e.id)})},e.id):(0,G.jsxs)(pM,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:e.disabled?`opacity-60`:void 0,children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(mM,{children:e.disabled?`+`:e.label})]},e.id)})})}function WI({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=bA(),a=dt(),o=II(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,G.jsxs)(lM,{children:[(0,G.jsx)(uM,{children:(0,G.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s?.label??`Wod Wiki`})}),(0,G.jsxs)(dM,{children:[(()=>{if(c||!s)return null;if(s.panel){let e=s.panel;return(0,G.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,G.jsx)(e,{item:s,navState:n,dispatch:r})})}return s.children&&s.children.length>0?(0,G.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,G.jsx)(UI,{items:s.children})}):null})(),c?(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(zI,{entries:c.spec})}):o.length>0&&(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(zI,{entries:o})})]})]})}var GI=`0.43.2152`,KI=`https://github.com/bitcobblers/wod-wiki/releases`;function qI(e){return/-pr\.\d+$/.test(e)?KI:`${KI}/tag/v${e}`}function JI({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=bA(),a=yn(),o=dt(),s=rM(),c={navigate:(e,t)=>a(e,{replace:t?.replace}),setQueryParam:()=>{},scrollToSection:()=>{}},l=(n??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),u=o.pathname.startsWith(`/settings`);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(`/`),"aria-label":`Wod Wiki home`,className:`mb-3 grid size-8 shrink-0 place-items-center rounded-xl bg-primary text-primary-foreground shadow-md shadow-primary/20 rotate-3`,children:(0,G.jsx)(k,{size:17})}),(0,G.jsx)(`nav`,{"aria-label":`Primary`,className:`flex flex-col items-center gap-1.5`,children:l.map(e=>{let t=e.icon,n=HI(e,r,o);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{i({type:`SET_ACTIVE_L1`,id:e.id}),ZM(e.action,c)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,className:K(`relative grid size-9 place-items-center rounded-lg transition-colors`,n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[n&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(t,{className:`size-5`})]},e.id)})}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{type:`button`,onClick:e,title:`Search (⌘/)`,"aria-label":`Search`,className:`grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:(0,G.jsx)(Zt,{className:`size-5`})}),(0,G.jsx)(`a`,{href:YN,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:`grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:(0,G.jsx)(XN,{className:`size-5`})}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":o.pathname.startsWith(`/settings/profile`)?`page`:void 0,"data-testid":`nav-profile`,className:K(`relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,o.pathname.startsWith(`/settings/profile`)?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[o.pathname.startsWith(`/settings/profile`)&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(Ae,{className:`size-5`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":u?`page`:void 0,"data-testid":`nav-settings`,className:K(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,u?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[u&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(ft,{className:`size-5`}),(0,G.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-0 left-full z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 font-mono text-[10px] text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`v`,GI]})]})]})}function YI({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,G.jsx)(`nav`,{className:K(`lg:sticky z-20 flex items-center gap-1 px-4 py-2 bg-background/95 backdrop-blur-sm border-b border-border/50 overflow-x-auto`,n===`top-fixed`?`lg:top-0`:`lg:top-[104px]`,i),children:e.map(e=>(0,G.jsx)(`button`,{onClick:()=>ZM(e.action,r),className:K(`px-3 py-1.5 rounded-full text-[10px] font-black uppercase tracking-[0.12em] whitespace-nowrap transition-all ring-1`,t===e.id?`bg-primary text-primary-foreground ring-primary/30 shadow-md`:`bg-muted/50 text-muted-foreground ring-transparent hover:bg-muted hover:ring-border`),children:e.label},e.id))})}var XI=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=Nc){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},ZI=20,QI=e=>{let[t,n]=(0,W.useState)(`idle`),[r,i]=(0,W.useState)(0),[a,o]=(0,W.useState)(0),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),n(`idle`)},[]),f=(0,W.useCallback)(()=>{if(e)try{let t=new XI(void 0,e.nowProvider);e.handle(t),o(e=>e+1)}catch{d(),n(`error`)}},[e,d]);(0,W.useEffect)(()=>{if(e)return e.subscribeToStack(e=>{e.blocks.length===0&&t!==`completed`&&(l.current&&=(clearInterval(l.current),null),n(`completed`))})},[e,t]),(0,W.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]);let p=(0,W.useCallback)(()=>{if(!e){console.warn(`useRuntimeExecution: Cannot start execution without a runtime`);return}if(t===`running`){console.warn(`useRuntimeExecution: Runtime is already running`);return}t===`paused`&&e.handle({name:`timer:resume`,timestamp:new Date,data:{}}),n(`running`);let i=e?.nowProvider?.nowMs()??Nc.nowMs();u.current=i-r,r===0&&c(i),l.current=setInterval(f,ZI)},[e,t,r,f]),m=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),e&&e.handle({name:`timer:pause`,timestamp:new Date,data:{}}),n(`paused`)},[e]),h=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),i(0),o(0),n(`idle`),c(null),u.current=null},[e]),g=(0,W.useCallback)(()=>{!e||t===`running`||(n(`paused`),f())},[e,t,f]);return(0,W.useEffect)(()=>{if(t!==`running`||!u.current)return;let n=setInterval(()=>{i((e?.nowProvider?.nowMs()??Nc.nowMs())-u.current)},100);return()=>clearInterval(n)},[t,e?.nowProvider]),(0,W.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]),(0,W.useEffect)(()=>{h()},[e,h]),(0,W.useMemo)(()=>({status:t,elapsedTime:r,stepCount:a,startTime:s,start:p,pause:m,stop:d,reset:h,step:g}),[t,r,a,s,p,m,d,h,g])},$I=(e,t)=>!e||!Array.isArray(e)?0:e.reduce((e,n)=>{if(`started`in n){let r=n.started,i=n.ended??t;return e+Math.max(0,i-r)}let r=n.start instanceof Date?n.start.getTime():n.start||0,i=n.stop?n.stop instanceof Date?n.stop.getTime():n.stop:t;return e+Math.max(0,i-r)},0);function eL(e,t){let n=t,r=()=>{let t=e?.getMemoryByTag(n)[0];if(t)return n===`round`?t.metrics[0]:t.metrics[0]?.value},[i,a]=(0,W.useState)(r);return(0,W.useEffect)(()=>{if(!e){a(void 0);return}a(r());let t=e.getMemoryByTag(n)[0];if(t)return t.subscribe(e=>{a(n===`round`?e[0]:e[0]?.value)})},[e,t]),i}function tL(e){return eL(e,`round`)}function nL(e){return eL(e,`display`)}function rL(e){let t=tL(e),n=nL(e);return(0,W.useMemo)(()=>{if(!t)return null;let e=n?.roundDisplay??(t.total===void 0?`Round ${t.current}`:`Round ${t.current} of ${t.total}`),r=t.total===void 0?void 0:Math.min(1,(t.current-1)/t.total);return{current:t.current,total:t.total,label:e,progress:r}},[t,n?.roundDisplay])}var iL=(0,W.createContext)(void 0),aL=({runtime:e,children:t})=>(0,G.jsx)(iL.Provider,{value:e,children:t});function oL(){let e=(0,W.useContext)(iL);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function sL(e){let t=oL(),n=e===void 0?t:e,[r,i]=(0,W.useState)(()=>n?.getOutputStatements?.()??[]);return(0,W.useEffect)(()=>{if(!n){i([]);return}return i(n.getOutputStatements()),n.subscribeToOutput?.(()=>{i(n.getOutputStatements())})},[n]),(0,W.useMemo)(()=>{let e=new Map,t=new Map,n=[],i=[];for(let a of r){e.set(a.id,a);let r=t.get(a.sourceBlockKey)??[];switch(r.push(a),t.set(a.sourceBlockKey,r),a.outputType){case`segment`:n.push(a);break;case`metric`:i.push(a)}}let a=n.filter(e=>e.completionReason!==void 0);return{outputs:r,byId:e,byBlockKey:t,segments:n,completions:a,metrics:i}},[r])}function cL(e){let t=oL(),n=e===void 0?t:e,[r,i]=(0,W.useState)(()=>n?.getLiveAnalytics?.()??[]);return(0,W.useEffect)(()=>{if(!n){i([]);return}return i(n.getLiveAnalytics?.()??[]),n.subscribeToOutput?.(()=>{i(n.getLiveAnalytics?.()??[])})},[n]),r}function lL(){let e=oL(),[t,n]=(0,W.useState)({type:`initial`,blocks:e.stack.blocks,depth:e.stack.count,clockTime:e.clock.currentDate});return(0,W.useEffect)(()=>e.subscribeToStack(e=>{n(e)}),[e]),t}function uL(){return lL().blocks}function dL(){let e=uL(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:next`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{for(let t of e){let e=t.getMemoryByTag(`metric:next`);if(e.length===0)continue;let n=da.empty(t.key.toString());for(let t of e)n.merge(t.metrics);if(n.length>0)return{metrics:n,block:t}}return null},[e,t])}function fL(){let e=uL(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`time`)[0];if(e){let r=e.subscribe(()=>{n(e=>e+1)});t.push(r)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{let t=[];for(let n of e){let e=n.getMemoryByTag(`time`)[0];if(!e)continue;let r=e.metrics[0]?.value;r&&t.push({block:n,timer:r,isPinned:r.role===`primary`})}return t},[e,t])}function pL(){let e=fL();return(0,W.useMemo)(()=>{if(e.length===0)return;let t=e[0];return t.block.blockType===`Rest`?t:[...e].reverse().find(e=>e.isPinned)||t},[e])}function mL(){let e=fL(),t=pL();return(0,W.useMemo)(()=>t?e.filter(e=>e.block!==t.block):[],[e,t])}function hL(){let e=uL(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`controls`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r].getMemoryByTag(`controls`);if(i.length===0)continue;let a=i[0].metrics.map(e=>e.value).filter(Boolean),o=r===e.length-1;for(let e of a)e.isPinned?t.push(e):o&&n.push(e)}let r=new Set,i=[];for(let e of t)r.has(e.id)||(r.add(e.id),i.push(e));for(let e of n)r.has(e.id)||(r.add(e.id),i.push(e));return i},[e,t])}function gL(){let e=uL(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:display`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{if(e.length===0)return;let t=[],n=[...e].reverse();return n.forEach((e,r)=>{if(e.blockType===`Root`&&!e.label)return;let i=e.getMemoryByTag(`metric:display`),a=i.map(e=>e.metrics);if(a.length===0&&!e.label)return;let o=r===n.length-1,s=i.length>1?i.map(e=>e.metrics):void 0;t.push({block:e,displayRows:a,label:e.label,depth:r,isLeaf:o,metricGroups:s})}),t.length>0?t:void 0},[e,t])}function _L(e){let t=oL(),n=(0,W.useMemo)(()=>t.stack.blocks.find(t=>t.key.toString()===e),[t,e]),[r,i]=(0,W.useState)(()=>n?.getMemoryByTag(`time`)[0]?.metrics[0]?.value);(0,W.useEffect)(()=>t.stack.subscribe(()=>{let n=t.stack.blocks.find(t=>t.key.toString()===e);if(n){let e=n.getMemoryByTag(`time`)[0];i(e?.metrics[0]?.value)}else i(void 0)}),[t,e]),(0,W.useEffect)(()=>{if(!n){i(void 0);return}let e=n.getMemoryByTag(`time`)[0];if(i(e?.metrics[0]?.value),e)return e.subscribe(e=>{i(e[0]?.value)})},[n]);let a=(0,W.useMemo)(()=>r?.spans??[],[r]),o=a.length>0&&a[a.length-1].ended===void 0,[s,c]=(0,W.useState)(xl()),l=(0,W.useMemo)(()=>a.length===0?0:$I(a,s),[a,s]);return(0,W.useEffect)(()=>{if(!o)return;let e,t=()=>{c(xl()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}var vL=(0,W.createContext)(void 0),yL=(0,W.createContext)(null),bL={getState:()=>DF().getState(),setState:(e,t)=>{let n=DF();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>DF().subscribe(e)},xL=({factory:e,children:t})=>{let[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(e);u.current=e;let d=(0,W.useRef)(null),f=(0,W.useRef)(null),p=(0,W.useRef)(!1),m=(0,W.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),bL.getState().setSubscriptionManager(null);let e=d.current;if(d.current=null,e)try{u.current.disposeRuntime(e)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime:`,e)}r(null),l(null)},[]),h=(0,W.useCallback)(e=>{if(!p.current){p.current=!0,s(!0),l(null);try{f.current&&=(f.current.dispose(),null);let t=d.current;if(d.current=null,t)try{u.current.disposeRuntime(t)}catch(e){console.error(`[RuntimeProvider] Error disposing existing runtime:`,e)}let n=u.current.createRuntime(e);if(d.current=n,r(n),n){let e=new Ef(n);e.add(new Tf({id:`local`})),f.current=e,a(e),bL.getState().setSubscriptionManager(e)}else f.current=null,a(null),bL.getState().setSubscriptionManager(null)}catch(e){console.error(`[RuntimeProvider] Error creating runtime:`,e),l(e instanceof Error?e:Error(String(e))),d.current=null}finally{p.current=!1,s(!1)}}},[]);(0,W.useEffect)(()=>()=>{if(f.current&&f.current.dispose(),d.current)try{u.current.disposeRuntime(d.current)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime on unmount:`,e)}},[]);let g={runtime:n,isInitializing:o,error:c,initializeRuntime:h,disposeRuntime:m};return(0,G.jsx)(vL.Provider,{value:g,children:(0,G.jsx)(yL.Provider,{value:i,children:t})})};function SL({factory:e,children:t}){return(0,G.jsx)(xL,{factory:e,children:t})}var CL=`bg-background ring-1 ring-zinc-950/5 shadow-sm lg:shadow-[-18px_0_36px_-28px_rgba(15,23,42,0.16),18px_0_36px_-28px_rgba(15,23,42,0.16)] dark:shadow-none dark:ring-white/10`,wL=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function TL({id:e,title:t,subtitle:n,titleAccessory:r,actions:i,queryBar:a,subheader:o,titleTestId:s,className:c}){return(0,G.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:K(`max-lg:hidden lg:sticky lg:top-0 z-30 bg-background/80 backdrop-blur-md transition-colors`,c),children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,children:[t&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[(0,G.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{"data-testid":s,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:t}),n&&(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:n})]}),r]})]}),a&&(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),i&&(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:i})]}),o&&(0,G.jsx)(`div`,{className:`bg-background/40`,children:o})]})}function EL({ids:e,enabled:t=!0,rootMargin:n=`-10% 0px -40% 0px`,threshold:r=[0,.3,1],onChange:i,shouldAcceptChange:a,scrollDirection:o=`ratio`,dataAttribute:s,debounceMs:c=0}){let l=(0,W.useRef)(``),u=(0,W.useRef)(i),d=(0,W.useRef)(a),f=(0,W.useRef)(null),p=(0,W.useRef)(1);(0,W.useEffect)(()=>{u.current=i},[i]),(0,W.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,W.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,W.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,W.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,W.useEffect)(()=>{if(!t||g.length===0||typeof IntersectionObserver>`u`)return;let e=new Map,r=e=>s?e.getAttribute(s):e.id||null,i;if(o===`topmost-when-up`){let e=window.scrollY,t=()=>{let t=window.scrollY;t!==e&&(p.current=t>e?1:-1),e=t};window.addEventListener(`scroll`,t,{passive:!0}),i=()=>window.removeEventListener(`scroll`,t)}let a=new IntersectionObserver(t=>{if(t.forEach(t=>{let n=r(t.target);n&&(t.isIntersecting?e.set(n,t.intersectionRatio):e.delete(n))}),e.size===0)return;let n=``;if(o===`topmost-when-up`&&p.current===-1){let t=1/0;e.forEach((e,r)=>{let i=g.indexOf(r);i>=0&&i<t&&(t=i,n=r)})}else{let t=-1;e.forEach((e,r)=>{e>t&&(t=e,n=r)})}!n||n===l.current||d.current&&!d.current(n)||(l.current=n,c>0?(v(),f.current=setTimeout(()=>{u.current(n),f.current=null},c)):u.current(n))},{rootMargin:n,threshold:_});return g.forEach(e=>{let t=s?document.querySelector(`[${s}="${e}"]`):document.getElementById(e);t&&a.observe(t)}),()=>{a.disconnect(),v(),i?.()}},[t,g,_,n,o,s,c,v])}function DL({title:e,titleAccessory:t,actions:n,subheader:r,children:i,index:a=[],activeSectionId:o,hero:s,sections:c,className:l}){let u=!!(c&&c.length>0)&&!e,[,d]=Ht(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,W.useState)(c?.[0]?.id??``);if(EL({ids:a.map(e=>e.id),enabled:!u&&a.length>0,rootMargin:`-10% 0px -40% 0px`,threshold:[0,.3,1],onChange:e=>{d(e)},shouldAcceptChange:()=>!0}),EL({ids:c?.map(e=>e.id)??[],enabled:u,rootMargin:`-20% 0px -50% 0px`,threshold:[0,.25,.5,.75],onChange:p}),u){let e=c.map(e=>({id:e.id,label:e.label,action:{type:`scroll`,sectionId:e.id}}));return(0,G.jsxs)(`div`,{className:K(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,G.jsx)(YI,{activations:e,activeSection:f,variant:`top-fixed`,deps:{navigate:()=>{},setQueryParam:()=>{},scrollToSection:e=>{let t=document.getElementById(e);if(t){let e=t.getBoundingClientRect().top+window.scrollY-64;window.scrollTo({top:e,behavior:`smooth`})}}}}),(0,G.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,G.jsx)(`div`,{id:e.id,"data-section-id":e.id,className:`py-12 lg:py-16 px-6 lg:px-10 border-b border-border/30`,children:e.content},e.id);return e.runtimeFactory?(0,G.jsx)(SL,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,G.jsx)(`div`,{className:K(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,G.jsxs)(`div`,{className:K(wL,CL),children:[(0,G.jsx)(TL,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,G.jsx)(`div`,{className:`flex-1`,children:i})]})})}var OL=`[data-page-sticky-boundary="true"]`,kL=0;function AL(e,t=kL){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(OL)).reduce((e,t)=>{let n=t.getBoundingClientRect();return n.height<=0||n.bottom<=0?e:Math.max(e,n.bottom)},0);return n>0?n+t:e}function jL(e,t=kL){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r(AL(e,t)))};return i(),window.addEventListener(`scroll`,i,{passive:!0}),window.addEventListener(`resize`,i),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i)}},[e,t]),n}function ML({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,G.jsxs)(`div`,{"data-testid":a,className:K(`sticky z-10 flex items-center gap-2 border-y border-border/60 bg-card/95 px-6 py-2 shadow-[0_1px_2px_rgba(0,0,0,0.03)] backdrop-blur`,o),style:{top:`${e}px`},children:[n,(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var NL=(0,W.createContext)(null),PL=(0,W.createContext)(null);function FL({children:e}){let[t,n]=(0,W.useState)(null);return(0,G.jsx)(PL.Provider,{value:n,children:(0,G.jsx)(NL.Provider,{value:t,children:e})})}function IL({className:e}){let t=(0,W.useContext)(PL);return(0,G.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function LL(){return(0,W.useContext)(NL)}function RL({editor:e,title:t,subtitle:n,titleTestId:r,actions:i,timerOverlay:a,reviewOverlay:o,isTimerOpen:s=!1,isReviewOpen:c=!1,onCloseTimer:l,onCloseReview:u,className:d}){return(0,G.jsxs)(`div`,{className:K(`relative flex w-full min-h-screen justify-start items-start`,d),children:[(0,G.jsxs)(`div`,{className:K(wL,CL),children:[(0,G.jsx)(TL,{title:t,subtitle:n,titleTestId:r,actions:i}),(0,G.jsx)(`main`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),s&&a&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,G.jsx)(`button`,{onClick:l,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:a})]})}),c&&o&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,G.jsx)(`button`,{onClick:u,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:o})]})})]})}function zL(e){return e.map(e=>{let t=e.action,n=e.secondaryAction?.action,r={kind:`link`,id:e.id,label:e.label,muted:e.level===3&&!!e.secondaryAction};return n&&n.type===`call`&&(r.onRun=n.handler,r.runIcon=e.secondaryRunIcon??`play`),t.type===`route`?{...r,to:t.to}:t.type===`scroll`?{...r,sectionId:t.sectionId}:t.type===`call`?{...r,onRun:t.handler}:r})}var BL=W.createContext(null);function VL(){let e=W.useContext(BL);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}var HL=({children:e,open:t,onOpenChange:n})=>{let r=W.useContext(BL),i=W.useId(),a=r?`${r.portalChain}/${i}`:i,[o,s]=W.useState(t??!1),c=W.useRef(null),[l,u]=W.useState(-1),d=W.useRef(new Map),[,f]=W.useReducer(e=>e+1,0);W.useEffect(()=>{t!==void 0&&s(t)},[t]);let p=W.useCallback(e=>{s(e),u(-1),n?.(e)},[n]),m=W.useCallback((e,t)=>{d.current.set(e,t),f()},[]),h=W.useCallback(e=>{d.current.delete(e),f()},[]),g=W.useCallback(e=>Array.from(d.current.keys()).indexOf(e),[]),_=d.current.size,v=W.useMemo(()=>({isOpen:o,setIsOpen:p,triggerRef:c,registerItem:m,unregisterItem:h,getItemIndex:g,activeIndex:l,setActiveIndex:u,itemCount:_,menuId:i,portalChain:a}),[o,p,m,h,g,l,_,i,a]);return(0,G.jsx)(BL.Provider,{value:v,children:(0,G.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},UL=W.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=VL(),s=e=>{e.stopPropagation(),o(!a)};return n&&W.isValidElement(t)?W.cloneElement(t,{...r,onClick:s}):(0,G.jsx)(`button`,{ref:i,className:e,onClick:s,...r,children:t})});UL.displayName=`DropdownMenuTrigger`;var WL=W.forwardRef(({className:e,children:t,align:n=`center`,side:r=`bottom`,...i},a)=>{let{isOpen:o,setIsOpen:s,triggerRef:c,setActiveIndex:l,itemCount:u,menuId:d,portalChain:f}=VL(),p=W.useRef(null),m=a||p,[h,g]=W.useState({top:0,bottom:0,left:0,width:0});W.useEffect(()=>{if(!o||!c.current)return;let e=c.current.getBoundingClientRect();g({top:e.bottom+8,bottom:window.innerHeight-e.top+8,left:e.left,width:e.width})},[o,c]),W.useEffect(()=>{if(!o||u===0)return;let e=setTimeout(()=>{l(0)},0);return()=>clearTimeout(e)},[o,u,l]),W.useEffect(()=>{if(!o)return;let e=e=>{let t=e.target;if(m.current&&m.current.contains(t)||c.current&&c.current.contains(t))return;let n=t.closest?.(`[data-dropdown-chain]`)?.getAttribute(`data-dropdown-chain`);n&&n.split(`/`).includes(d)||s(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[o,s,m,c,d]);let _=e=>{if(u!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),l(e=>e<u-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),l(e=>e>0?e-1:u-1);break;case`Home`:e.preventDefault(),l(0);break;case`End`:e.preventDefault(),l(u-1);break;case`Escape`:e.preventDefault(),s(!1),c.current?.querySelector(`button`)?.focus();break;case`Tab`:s(!1)}};if(!o)return null;let v={position:`fixed`,zIndex:9999};return r===`top`?v.bottom=h.bottom:v.top=h.top,n===`end`?v.right=window.innerWidth-h.left-h.width:n===`start`?v.left=h.left:(v.left=h.left+h.width/2,v.transform=`translateX(-50%)`),qx.createPortal((0,G.jsx)(`div`,{ref:m,role:`menu`,"data-dropdown-chain":f,className:K(`min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95`,e),style:v,onKeyDown:_,...i,children:t}),document.body)});WL.displayName=`DropdownMenuContent`;var GL=W.forwardRef(({className:e,disabled:t,inset:n,onClick:r,onKeyDown:i,...a},o)=>{let{setIsOpen:s,registerItem:c,unregisterItem:l,getItemIndex:u,activeIndex:d}=VL(),f=W.useId(),p=W.useRef(null),m=W.useCallback(e=>{p.current=e,typeof o==`function`?o(e):o&&(o.current=e)},[o]);W.useEffect(()=>(c(f,p),()=>l(f)),[f,c,l]);let h=u(f)===d;return W.useEffect(()=>{h&&p.current?.focus()},[h]),(0,G.jsx)(`div`,{ref:m,role:`menuitem`,tabIndex:t?-1:h?0:-1,"aria-disabled":t,"data-active":h?`true`:void 0,className:K(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors`,`focus:bg-accent focus:text-accent-foreground`,`data-[active]:bg-accent data-[active]:text-accent-foreground`,n&&`pl-8`,t&&`pointer-events-none opacity-50`,e),onClick:e=>{t||(r?.(e),s(!1))},onKeyDown:e=>{t||(i?.(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r?.(e),s(!1)))},...a})});GL.displayName=`DropdownMenuItem`;var KL=W.forwardRef(({className:e,inset:t,...n},r)=>(0,G.jsx)(`div`,{ref:r,className:K(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));KL.displayName=`DropdownMenuLabel`;var qL=W.forwardRef(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:K(`-mx-1 my-1 h-px bg-muted`,e),...t}));qL.displayName=`DropdownMenuSeparator`;function JL({className:e,children:t,...n}){return(0,G.jsx)(`div`,{className:K(`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,e),...n,children:t})}var YL=[{label:`Past 1 week`,value:`last 1w`},{label:`Past 2 weeks`,value:`last 2w`},{label:`Past 4 weeks`,value:`last 4w`},{label:`Past 8 weeks`,value:`last 8w`},{label:`Past 12 weeks`,value:`last 12w`},{label:`Past 1 year`,value:`last 52w`},{label:`All time`,value:`all`}],XL=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function ZL(e,t){return new Date(e,t+1,0).getDate()}function QL(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function $L(e,t){let n=X(e);if(n.error)return e;if(!t||t===`all`)return Mm({...n,window:void 0});let r=X(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:Mm({...n,window:r.window})}function eR(e){let t=X(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function tR({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,W.useMemo)(()=>eR(e),[e]),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(()=>new Date),l=s.getFullYear(),u=s.getMonth(),d=(0,W.useMemo)(()=>i?i.kind===`relative`?`last ${i.size}${i.unit}`:i.end?`from ${i.start} to ${i.end}`:`from ${i.start}`:`All time`,[i]),f=(0,W.useMemo)(()=>{if(!i)return null;if(i.kind===`range`)return{start:i.start,end:i.end??i.start};let e=new Date,t=new Date;return i.unit===`d`?t.setDate(e.getDate()-i.size):t.setDate(e.getDate()-i.size*7),{start:Gj(t),end:Gj(e)}},[i]),p=(0,W.useMemo)(()=>{let e=ZL(l,u),t=QL(l,u),n=[];for(let e=0;e<t;e++)n.push(null);for(let t=1;t<=e;t++)n.push(t);return n},[l,u]),m=n=>{if(!a)o(n),t($L(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t($L(e,`from ${r} to ${i}`))}},h=e=>{e.stopPropagation(),c(new Date(l,u-1,1))},g=e=>{e.stopPropagation(),c(new Date(l,u+1,1))},_=s.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`}),v=Gj(new Date);return(0,G.jsxs)(`div`,{className:K(`relative inline-flex items-center`,r),children:[(0,G.jsxs)(HL,{children:[(0,G.jsx)(UL,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`wql-window-picker-trigger`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,G.jsx)(dn,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,G.jsx)(St,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,G.jsxs)(WL,{align:`end`,className:`w-72 p-3`,children:[(0,G.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1 border-b border-border/60 pb-2`,children:YL.map(n=>{let r=n.value===`all`?!i:i?.kind===`relative`&&`last ${i.size}${i.unit}`===n.value;return(0,G.jsx)(`button`,{type:`button`,"data-testid":`wql-window-preset-${n.value}`,onClick:()=>{o(null),t($L(e,n.value))},className:K(`rounded-md px-2 py-1 text-[11px] font-medium transition-colors`,r?`bg-primary text-primary-foreground`:`bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground`),children:n.label},n.value)})}),(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:h,"data-testid":`wql-calendar-prev-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Previous month`,children:(0,G.jsx)(Rn,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:_}),(0,G.jsx)(`button`,{type:`button`,onClick:g,"data-testid":`wql-calendar-next-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Next month`,children:(0,G.jsx)(xn,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:XL.map(e=>(0,G.jsx)(`div`,{className:`text-center text-[10px] font-medium text-muted-foreground`,children:e},e))}),(0,G.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,"data-testid":`wql-calendar-grid`,children:p.map((e,t)=>{if(e===null)return(0,G.jsx)(`div`,{className:`size-8`},`empty-${t}`);let r=`${l}-${String(u+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,i=f&&r>=f.start&&r<=f.end,o=f&&r===f.start||a===r,s=f&&r===f.end,c=r===v,d=n.has(r);return(0,G.jsxs)(`button`,{type:`button`,"data-testid":`wql-calendar-day-${r}`,onClick:()=>m(r),className:K(`relative flex size-8 items-center justify-center rounded-md text-xs transition-colors`,o||s?`bg-primary font-bold text-primary-foreground`:i?`bg-primary/15 font-semibold text-primary`:c?`border border-primary font-semibold text-primary`:`text-foreground hover:bg-muted`),children:[(0,G.jsx)(`span`,{children:e}),d&&!o&&!s&&(0,G.jsx)(`span`,{className:`absolute bottom-0.5 size-1 rounded-full bg-primary`})]},r)})}),a&&(0,G.jsxs)(`div`,{className:`mt-2 text-center text-[10px] text-muted-foreground`,children:[`Select second date to complete range (starting from `,a,`)`]})]})]}),i&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`wql-window-picker-clear`,onClick:()=>{o(null),t($L(e,null))},title:`Clear time window`,"aria-label":`Clear time window`,className:`ml-1 grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,G.jsx)(Se,{className:`size-3.5`})})]})}function nR(e){switch(e.kind){case`note`:case`post`:return`note`;case`session`:return`session`;case`result`:return`result`;case`segment`:case`event`:return`segment`;case`effort`:return`effort`;default:return`note`}}var rR=[{id:`title`,label:`Title`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`tags`,label:`Tags`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.tags??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)},{id:`excerpt`,label:`Text Excerpt`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.block?.preview?.join(` `)||e.detail||``,formatValue:e=>String(e??``)},{id:`catalog`,label:`Catalog Source`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.sourceCatalog,formatValue:e=>String(e??``)},{id:`date`,label:`Date`,level:`note`,defaultVisible:!0,align:`right`,getValue:e=>e.date,formatValue:e=>String(e??``)}],iR={note:rR,session:[{id:`title`,label:`Title`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`protocol`,label:`Protocol`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.block?.dataType||e.subtitle||``,formatValue:e=>String(e??``)},{id:`movements`,label:`Movements`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.detail||``,formatValue:e=>String(e??``)},{id:`targetDuration`,label:`Target Duration`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:xI(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``}],result:[{id:`title`,label:`Title`,level:`result`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`elapsedTime`,label:`Elapsed Time`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:xI(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{id:`tis`,label:`TIS Score`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.tis,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`prBadges`,label:`PR Badges`,level:`result`,defaultVisible:!0,align:`center`,getValue:e=>e.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:xI(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`roundIndex`,label:`Round/Lap Index`,level:`segment`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`reps`,label:`Reps`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.reps,formatValue:e=>e==null?``:String(e)},{id:`load`,label:`Load`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{id:`pacingTier`,label:`Pacing / HR Tier`,level:`segment`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier||e.execution?.effortSlug||``,formatValue:e=>String(e??``)}],effort:[{id:`label`,label:`Label`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.label||e.title,formatValue:e=>String(e??``)},{id:`canonicalSlug`,label:`Canonical Slug`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.slug||e.id,formatValue:e=>String(e??``)},{id:`discipline`,label:`Discipline`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.discipline??``,formatValue:e=>String(e??``)},{id:`met`,label:`MET Score`,level:`effort`,defaultVisible:!0,align:`right`,getValue:e=>e.effort?.met,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`intensityTier`,label:`Intensity Tier`,level:`effort`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier??``,formatValue:e=>String(e??``)},{id:`aliases`,label:`Aliases`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.aliases??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)}]};function aR(e){return iR[e]??rR}function oR(e){return aR(e).filter(e=>e.defaultVisible).map(e=>e.id)}var sR=[{id:`cards`,label:`Cards`,icon:tn},{id:`rows`,label:`Rows`,icon:B},{id:`feed`,label:`Feed`,icon:qn}];function cR({streamControls:e}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`l3-stream-controls`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date window`}),(0,G.jsx)(tR,{query:e.query,onQueryChange:e.onQueryChange,className:`w-full justify-between`})]}),e.availableGroupDims.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Group by`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-groupby-options`,children:e.availableGroupDims.map(t=>{let n=e.groupDims.some(e=>e.toLowerCase()===t.id.toLowerCase());return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-groupby-${t.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleGroupDim(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{children:t.label})]},t.id)})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Layout`}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,"data-testid":`l3-layout-options`,children:sR.map(t=>{let n=t.icon,r=e.settings.layout===t.id;return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>e.onLayoutChange(t.id),"data-testid":`l3-layout-${t.id}`,className:`flex min-h-8 items-center justify-center gap-1 rounded-md border px-1.5 py-1 text-[11px] font-medium transition-colors ${r?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,G.jsx)(n,{"aria-hidden":!0,className:`size-3`}),t.label]},t.id)})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Fields`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-field-options`,children:aR(e.level).map(t=>{let n=e.settings.visibleFields.includes(t.id);return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-field-${t.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleField(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{children:t.label})]},t.id)})})]})]})}function lR({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=bA(),i=II(e),a=(0,W.useMemo)(()=>zL(n),[n]),o=LI();return i.length===0&&a.length===0&&!r&&!t?null:(0,G.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[r&&(0,G.jsx)(`div`,{className:`pb-3 border-b border-border/50`,children:(0,G.jsx)(cR,{streamControls:r})}),i.length>0&&(0,G.jsx)(zI,{entries:i,activeId:o}),a.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 pt-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,G.jsx)(zI,{entries:a,activeId:o})]}),t&&(0,G.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var uR=1023;function dR(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function fR(e,t){if(e===`query:new`)return``;let n=e=>{let n=`/${e}`;for(let r of Object.keys(t))if(r===e||r.endsWith(n))return r;return null},r=e=>{let r=n(e);return r===null?null:hb(t[r])};if(e.startsWith(`markdown/`)){let t=r(e);if(t!==null)return t}let i=e;if(e.startsWith(`wods/examples/`))i=`markdown/canvas/`+e.replace(/^wods\/examples\//,``);else if(e.startsWith(`wods/`))i=`markdown/canvas/`+e.replace(/^wods\//,``);else if(e.startsWith(`collections/`))i=`markdown/collections/`+e.replace(/^collections\//,``);else if(e.startsWith(`canvas/`))i=`markdown/canvas/`+e.replace(/^canvas\//,``);else{let t=r(`markdown/canvas/`+e);if(t!==null)return t;let n=r(`markdown/collections/`+e);if(n!==null)return n;i=`markdown/`+e}return r(i)??`# Source not found\n\nPath: \`${e}\`\nResolved: \`${i}\``}function pR(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function mR(e){let t=new Map,n=null;for(let r of e)pR(r)&&(n=r),t.set(r.id,n);return t}function hR(){let[e,t]=(0,W.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${uR}px)`).matches);return(0,W.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${uR}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var gR=`wodwiki:fabAlignment`,_R=[{id:`left`,label:`Bottom left`,description:`Left-handed — search and page actions float near your left thumb`},{id:`right`,label:`Bottom right`,description:`Right-handed — search and page actions float near your right thumb`}];function vR(){try{return yR(localStorage.getItem(gR))}catch{return}}function yR(e){return e===`right`||e===`left`?e:void 0}var bR=typeof window>`u`?void 0:vR();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===gR&&(bR=yR(e.newValue))});function xR(e){bR=e;try{e===`right`?localStorage.removeItem(gR):localStorage.setItem(gR,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:gR,newValue:e}))}function SR(){let[e,t]=(0,W.useState)(()=>bR??`right`);return(0,W.useEffect)(()=>{let e=e=>{e.key===gR&&t(yR(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,xR]}function CR({onOpen:e}){return(0,G.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,"data-testid":`search-fab`,className:K(`size-14 rounded-full flex items-center justify-center`,`bg-primary text-primary-foreground shadow-lg`,`hover:bg-primary/90 active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:(0,G.jsx)(Zt,{className:`size-6`})})}var wR=(0,W.createContext)(null),TR=(0,W.createContext)(!1),ER=(0,W.createContext)(null);function DR(){return(0,W.useContext)(wR)!==null}function OR({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,W.useContext)(wR),o=(0,W.useContext)(TR),s=hR(),c=(0,W.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=(0,G.jsx)(TR.Provider,{value:!0,children:n});return(0,W.useEffect)(()=>{if(!(!l&&!u))return a.register({id:c,primary:e,navbar:t,children:d,label:r??`Page options`,fallback:i}),()=>a.unregister(c)},[l,u,a,c,e,d,r,i]),i||a&&s&&!o?null:(0,G.jsx)(TR.Provider,{value:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function kR({onSearch:e,children:t}){let[n,r]=(0,W.useState)([]),i=(0,W.useCallback)(e=>r(t=>[...t.filter(t=>t.id!==e.id),e]),[]),a=(0,W.useCallback)(e=>r(t=>t.filter(t=>t.id!==e)),[]),o=(0,W.useMemo)(()=>({register:i,unregister:a}),[i,a]),s=(0,W.useMemo)(()=>{for(let e=n.length-1;e>=0;--e)if(!n[e].fallback)return n[e].navbar??null;return null},[n]);return(0,G.jsx)(wR.Provider,{value:o,children:(0,G.jsxs)(ER.Provider,{value:s,children:[t,(0,G.jsx)(jR,{registrations:n,onSearch:e})]})})}function AR(){let e=(0,W.useContext)(ER);return e?(0,G.jsx)(G.Fragment,{children:e}):null}function jR({registrations:e,onSearch:t}){let n=hR(),[r]=SR(),i=Yx(),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=dt(),[l,u]=(0,W.useState)(!1),d=(0,W.useRef)(0),f=i.offsetBottom>0,p=(0,W.useRef)(null),m=(0,W.useRef)(null),h=(0,W.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),g=(0,W.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]);(0,W.useEffect)(()=>{o(!1),u(!1),d.current=window.scrollY},[c.pathname]),(0,W.useEffect)(()=>{if(!n)return;let e=()=>{let e=window.scrollY;if(e<=0||f||a){d.current=e,u(!1);return}let t=e-d.current;Math.abs(t)<8||(d.current=e,u(t>0))};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[n,f,a]),(0,W.useLayoutEffect)(()=>{a&&s.current?.focus()},[a]);let[_,v]=(0,W.useState)({active:0,global:0});(0,W.useLayoutEffect)(()=>{let e=p.current?.childElementCount??0,t=m.current?.childElementCount??0;v(n=>n.active===e&&n.global===t?n:{active:e,global:t})},[h,g]);let y=_.active>0||_.global>0;return!n||!t&&!h&&!g?null:(0,G.jsxs)(`div`,{"data-testid":`actions-dock`,className:K(`lg:hidden fixed z-40 flex flex-col items-center gap-2`,`transition-[transform,visibility] duration-200 ease-out`,r===`left`?`left-4 items-start`:`right-4 items-end`,l&&!a&&!f&&`translate-y-[calc(100%+2rem)] invisible pointer-events-none`),style:{bottom:`calc(1rem + var(--thumb-dock-lift, 0px) + ${i.offsetBottom}px + env(safe-area-inset-bottom))`},children:[(0,G.jsxs)(`div`,{className:`relative z-40 flex flex-col items-center gap-2`,children:[h?.primary&&(0,G.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:h.primary}),t&&(0,G.jsx)(CR,{onOpen:()=>{o(!1),t()}})]}),a&&y&&(0,G.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 cursor-default`,onClick:()=>o(!1)}),(0,G.jsxs)(`div`,{ref:s,role:`dialog`,"aria-label":h?.label??g?.label??`Page options`,tabIndex:-1,hidden:!a||!y,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),o(!1))},className:K(`relative z-40 flex w-60 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/5 outline-none`,`[&_button]:min-h-11 [&_button]:min-w-11`),style:{maxHeight:`calc(${i.height===null?`100dvh`:`${i.height}px`} - 6rem - env(safe-area-inset-bottom))`},children:[(0,G.jsx)(`div`,{ref:p,className:`contents`,children:h?.children}),_.active>0&&_.global>0&&(0,G.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,G.jsx)(`div`,{ref:m,className:`contents`,children:g?.children})]}),y&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-label":h?.label??g?.label??`Page options`,"aria-expanded":a,"data-testid":`actions-overflow`,className:K(`relative z-40 flex size-12 items-center justify-center rounded-full`,`bg-card text-foreground shadow-lg ring-1 ring-foreground/10`,`hover:bg-muted active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:a?(0,G.jsx)(Fe,{className:`size-6`}):(0,G.jsx)(pe,{className:`size-6`})})]})}function MR(){return(0,G.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,G.jsx)(`path`,{d:`M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z`})})}function NR(){return(0,G.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}function PR(){let{tree:e,navState:t,contextNav:n}=bA(),r=dt(),i=rM();return!e.find(e=>e.id===t.activeL1Id)?.applyFooter||n?.pathname===r.pathname?null:(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})}function FR({open:e,close:t,onSearch:n,onCreate:r,children:i}){return(0,G.jsxs)(ze,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Ue,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,G.jsx)(A,{transition:!0,className:`fixed inset-y-0 left-0 w-full transition duration-300 ease-out data-closed:-translate-x-full`,children:(0,G.jsx)(nM,{close:t,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,G.jsx)(`div`,{className:`flex h-full w-14 shrink-0 flex-col items-center border-r border-zinc-950/5 bg-background/72 py-3 dark:border-white/5 [&_a]:size-11 [&_button]:size-11`,children:(0,G.jsx)(JI,{onSearch:()=>{t(),n?.()},onCreate:r?()=>{t(),r()}:void 0})}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,G.jsx)(`div`,{className:`flex items-center px-4 pt-3`,children:(0,G.jsx)(et,{as:zP,"aria-label":`Close navigation`,children:(0,G.jsx)(NR,{})})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),(0,G.jsx)(PR,{})]})]})})})]})}function IR({open:e,close:t,children:n}){return(0,G.jsxs)(ze,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Ue,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,G.jsx)(A,{transition:!0,className:`fixed inset-y-0 right-0 w-full transition duration-300 ease-out data-closed:translate-x-full`,children:(0,G.jsx)(nM,{close:t,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-end px-4 pt-3`,children:(0,G.jsx)(et,{as:zP,"aria-label":`Close page options`,children:(0,G.jsx)(NR,{})})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:n}),(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})]})})})]})}function LR({navbar:e,sidebar:t,onSearch:n,onCreate:r,secondary:i,pageAction:a,hideDesktopSidebar:o,children:s}){let[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),f=(0,W.useRef)(null),[p,m]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=f.current;if(!e)return;let t=()=>m(t=>{let n=e.childElementCount>0;return t===n?t:n}),n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0}),t(),()=>n.disconnect()},[]);let{streamControls:h}=bA(),g=(0,W.useMemo)(()=>{let e=X(h?.query??``);return!e.error&&Vp(e)&&e.filters.length>0},[h?.query]);return(0,G.jsx)(FL,{children:(0,G.jsx)(kR,{onSearch:n,children:(0,G.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,G.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,G.jsxs)(`nav`,{"aria-label":`Main`,className:`hidden lg:flex`,children:[(0,G.jsx)(`div`,{className:`w-14 shrink-0 sticky top-0 h-svh flex flex-col items-center border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm z-40 py-3`,children:(0,G.jsx)(JI,{onSearch:n??(()=>{}),onCreate:r})}),(0,G.jsx)(`div`,{className:K(`w-60 shrink-0 sticky top-0 self-start h-svh min-h-0 overflow-hidden border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm flex flex-col`,o&&`lg:hidden`),children:t})]}),(0,G.jsx)(FR,{open:c,close:()=>l(!1),onSearch:n,onCreate:r,children:t}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col min-w-0 xl:max-w-[984px] 2xl:max-w-none`,children:[(0,G.jsxs)(`header`,{"data-page-sticky-boundary":`true`,className:`lg:hidden sticky top-0 z-20 flex items-center px-2 sm:px-4 bg-card`,children:[(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsx)(zP,{onClick:()=>l(!0),"aria-label":`Open navigation`,children:(0,G.jsx)(MR,{})})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),r&&(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsx)(zP,{onClick:r,"aria-label":`New journal note`,children:(0,G.jsx)(Wt,{className:`size-5`})})}),p&&(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsx)(zP,{onClick:()=>d(!0),"aria-label":`Open page options`,children:(0,G.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,G.jsx)(hn,{className:`size-5`}),g&&(0,G.jsx)(`span`,{"data-testid":`drawer-filters-active`,className:`absolute -top-1 -right-1 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`})]})})})]}),(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col lg:min-w-0`,children:[(0,G.jsx)(`div`,{className:`grow w-full max-lg:pb-48 lg:overflow-visible`,children:s}),(0,G.jsx)(RR,{})]})]}),(0,G.jsx)(`aside`,{className:`hidden 2xl:flex w-60 shrink-0 sticky top-0 h-svh flex-col overflow-y-auto bg-background/72 backdrop-blur-sm`,children:(0,G.jsx)(`div`,{ref:f,className:`contents`,children:(0,G.jsx)(lR,{spec:i,pageAction:a})})}),(0,G.jsx)(IR,{open:u,close:()=>d(!1),children:(0,G.jsx)(lR,{spec:i,pageAction:a})})]})})})})}function RR(){let e=(0,W.useRef)(null),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=Math.round(e[0]?.contentRect.height??0);n(e=>e===t?e:t)});r.observe(t,{box:`content-box`});let i=Math.round(t.getBoundingClientRect().height);return n(e=>e===i?e:i),()=>r.disconnect()},[]),(0,W.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${t}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[t]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:K(`lg:hidden fixed inset-x-0 bottom-0 z-30`,t>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,G.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,G.jsx)(IL,{className:`flex w-full min-w-0`})})}),(0,G.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function zR(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function BR(e){return String(gb(ub(e).meta,`search`)??``).toLowerCase()===`hidden`}function VR(e){let t=gb(ub(e).meta,`date`);if(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t))return;let n=new Date(`${t}T12:00:00Z`);return Number.isFinite(n.getTime())&&n.toISOString().slice(0,10)===t?n.getTime():void 0}function HR(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=gb(ub(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():kE(r),category:zR(n),content:i,date:VR(i),searchHidden:BR(i)}})}function UR(){let e=ZE();return(0,W.useMemo)(()=>e?HR(e):[],[e])}var WR={};function GR(e){if(!(`payload`in e))return;let t=e.payload;if(!t||typeof t!=`object`)return;let n=t;return n.targetDate??n.updatedAt}function KR(e,t){let{canvasPage:n,workoutItems:r,recentResults:i,selectWorkout:a}=t;if(n){let t=/^\/(?:c|collections)\//.test(e),i=t?e.split(`/`).pop()??null:null;if(e===`/`)return[];let o=[],s=e.startsWith(`/guide/`);return n.sections.filter(e=>e.level>1).forEach(e=>{if(o.push({id:e.id,label:e.heading,type:`heading`}),!s){let t=sP(e).split(`
|
|
101
101
|
`),n=0;t.forEach((t,r)=>{let i=t.trim().match(/^```(time|log)(:\w+)?\s*$/);if(i){let t=i[1];n++,o.push({id:`${e.id}-${t}-${r+1}`,label:`Workout ${n}`,type:t})}})}}),t&&i&&(o.push({id:`collection-workouts`,label:`Explore`,type:`heading`}),r.filter(e=>e.category===i&&e.name.toLowerCase()!==`readme`).forEach(e=>{o.push({id:`workout-${e.id}`,label:e.name,type:`time`,onRun:()=>a(e),runIcon:`link`})})),o}if(e===`/journal`){let e=new Set;return i.forEach(t=>{let n=new Date(t.createdAt).getTime();Number.isFinite(n)&&e.add(Gj(new Date(n)))}),r.forEach(t=>{let n=GR(t);n&&Number.isFinite(new Date(n).getTime())&&e.add(Gj(new Date(n)))}),Array.from(e).sort().reverse().slice(0,10).map(e=>({id:e,label:JP(new Date(e+`T00:00:00`)),type:`heading`}))}return[]}var qR=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function JR(e){return qR.test(e)}function YR(e){try{return decodeURIComponent(e)}catch{return null}}function XR(e){if(!Jj(e))return!1;let t=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return!1;let n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return n.getUTCFullYear()===Number(t[1])&&n.getUTCMonth()===Number(t[2])-1&&n.getUTCDate()===Number(t[3])}function ZR(e){let t=e.length>1?e.replace(/\/+$/,``):e;if(t===`/journal`)return{kind:`index`};if(!t.startsWith(`/journal/`))return{kind:`invalid`};let n=t.slice(9).split(`/`).map(YR);if(n.some(e=>e==null))return{kind:`invalid`};let r=n;if(r.length===1){let e=r[0];return XR(e)?{kind:`date`,journalDate:e}:qR.test(e)?{kind:`uuid-alias`,noteId:e}:e?{kind:`slug-alias`,slug:e}:{kind:`invalid`}}if(r.length===2){let[e,t]=r;if(XR(e)&&qR.test(t))return{kind:`note`,journalDate:e,noteId:t}}return{kind:`invalid`}}var QR=`# My Workout Notebook
|
|
102
102
|
|
|
103
103
|
Welcome to the **WOD.WIKI** playground.
|
|
@@ -156,7 +156,7 @@ Timer 12:00
|
|
|
156
156
|
border border-border/80 shadow-xl rounded-lg overflow-hidden pointer-events-auto`,style:{top:k,maxHeight:200},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-muted/40 border-b border-border/50 shrink-0`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-mono px-2 py-0.5 rounded bg-metric-time/10 text-metric-time uppercase tracking-wider font-semibold`,children:m.type}),(0,G.jsxs)(`div`,{className:`flex items-center min-w-0 gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`L`,D]}),(0,G.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}),(0,G.jsx)(`span`,{className:`text-xs font-mono text-foreground/90 truncate font-medium`,title:E,children:E||(0,G.jsx)(`span`,{className:`italic text-muted-foreground`,children:`—`})})]})]}),(0,G.jsx)(`div`,{className:`px-3 py-2.5 min-h-0 overflow-auto`,children:C.length>0?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-sm font-semibold ${e.color}`,title:e.label,children:[(0,G.jsx)(`span`,{className:`text-base leading-none`,children:e.icon}),(0,G.jsx)(`span`,{className:`font-mono tracking-tight`,children:e.value})]},t))}):(0,G.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`No metrics on this line`})}),w&&(0,G.jsx)(kG,{summary:w}),(0,G.jsx)(`div`,{className:`border-t border-border/40 shrink-0`,children:(0,G.jsx)(NG,{commands:d,section:m,view:n})})]})]})},FG=({sectionId:e,widgetName:t,view:n,registry:r,docVersion:i})=>{let{rawContent:a,config:o}=(0,W.useMemo)(()=>{let t=n.state.field(zC).sections.find(t=>t.id===e),r=t?.contentFrom!==void 0&&t?.contentTo!==void 0?n.state.doc.sliceString(t.contentFrom,t.contentTo).trim():``,i={};if(r)try{i=JSON.parse(r)}catch{}return{rawContent:r,config:i}},[n,e,i]),s=r.get(t);return s?(0,G.jsx)(`div`,{className:`h-full w-full overflow-hidden rounded-l-md border-l border-border bg-background shadow-sm`,children:(0,G.jsx)(s,{config:o,rawContent:a,sectionId:e})}):(0,G.jsxs)(`div`,{className:`flex h-full w-full items-center justify-center rounded-l-md border-l border-border bg-muted/60 p-4 text-xs text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`font-mono`,children:[`widget:`,t]}),(0,G.jsx)(`span`,{className:`ml-2 opacity-60`,children:`— not registered`})]})};function IG(e,t,n,r,i){switch(t.type){case`fixed-field`:return LG(e,t);case`metric-type`:return RG(e,t);case`derived`:return zG(e,t,n,r,i);case`fallback`:return BG(e,t,n,r,i);default:return}}function LG(e,t){return e[t.field]}function RG(e,t){return e.cells.get(t.metricType)}function zG(e,t,n,r,i){let a=new Map;if(t.dependencies&&r)for(let o of t.dependencies){if(i?.includes(o))throw Error(`Circular dependency detected in column '${o}': ${(i??[]).join(` -> `)} -> ${o}`);let t=r.get(o);if(t){let s=IG(e,t.source,n,r,[...i??[],o]);a.set(o,s)}}let o={...n,allRows:n?.allRows??[e],rowIndex:n?.rowIndex??0,columnDef:n?.columnDef??{id:`unknown`,label:``,source:t,format:{type:`text`}},dependencies:a,...t.context};return t.compute(e,o)}function BG(e,t,n,r,i){return VG(e,t,n,r,i)}function VG(e,t,n,r,i){if(!(!t.sources||t.sources.length===0))switch(t.semantics){case`first-present`:return HG(e,t.sources,n,r,i);case`all-present-joined`:return UG(e,t.sources,t.joinString,n,r,i);case`all-present-combined`:return WG(e,t.sources,n,r,i);default:return}}function HG(e,t,n,r,i){for(let a of t){let t=IG(e,a,n,r,i);if(t!=null)return t}}function UG(e,t,n,r,i,a){let o=[];for(let n of t){let t=IG(e,n,r,i,a);if(t==null)return;o.push(t)}let s=n??` `;return o.map(e=>KG(e)).join(s)}function WG(e,t,n,r,i){let a=[];for(let o of t){let t=IG(e,o,n,r,i);if(t==null)return;a.push(t)}return a}function GG(e){if(e==null)return``;let t=Array.isArray(e)?e:e instanceof da?e.toArray():[];if(t.length===0)return``;let n=t[0];if(typeof n==`object`&&n){if(`image`in n&&typeof n.image==`string`)return n.image;if(`value`in n&&n.value!==void 0)return String(n.value)}return String(n)}function KG(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`&&`metrics`in e){let t=GG(e.metrics);if(t.length>0)return t}return String(e)}function qG(e,t,n,r){if(!t.sort)return``;let i=IG(e,t.source,n,r);return(t.sort.type===`custom`?typeof i==`number`||typeof i==`string`?i:String(i??``):t.sort.extractor(i))??``}function JG(e,t){if(typeof e==`number`&&typeof t==`number`)return Number.isNaN(e)&&Number.isNaN(t)?0:Number.isNaN(e)?1:Number.isNaN(t)?-1:e-t;let n=String(e??``),r=String(t??``),i=parseFloat(n),a=parseFloat(r);return!Number.isNaN(i)&&!Number.isNaN(a)&&n===String(i)&&r===String(a)?i-a:n.localeCompare(r)}function YG(e,t,n,r){if(!t.graph)return;let i=IG(e,t.source,n,r);return t.graph.extractor(i)}function XG(e,t,n,r){if(!t.filter)return``;let i=IG(e,t.source,n,r);return t.filter.extractor(i)??``}function ZG(e,t,n,r,i){if(!n||n.trim().length===0||!t.filter)return!0;let a=XG(e,t,r,i),o=t.filter.caseInsensitive===!1?n.trim():n.trim().toLowerCase(),s=t.filter.caseInsensitive===!1?a:a.toLowerCase();return t.filter.matcher?t.filter.matcher(s,o):s.includes(o)}var QG=({metric:e})=>{let t=e.origin===`hinted`||e.image===`?`,n=(0,W.useMemo)(()=>oV(ho.present(e,`review-grid-cell`)),[e]);return(0,G.jsxs)(`span`,{className:[`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium border transition-all`,t?`bg-warning/10 border-warning/40 text-warning animate-pulse-opacity`:`${n.colorClasses} ${n.originClasses}`].join(` `),title:t?`Missing value - click to fill`:n.tooltip,children:[t&&(0,G.jsx)(`span`,{className:`mr-0.5 text-[10px]`,children:`◉`}),n.label,n.userEntered&&!t&&(0,G.jsx)(`span`,{className:`text-[10px] opacity-70 ml-0.5`,children:`👤`})]})},$G=({columnDef:e,row:t,allRows:n,rowIndex:r,indent:i=0,onDoubleClick:a,className:o,style:s,definitionMap:c})=>{let l=(0,W.useRef)(null),u=(0,W.useMemo)(()=>{if(!(!n||r===void 0))return{allRows:n,rowIndex:r,columnDef:e,dependencies:new Map}},[n,r,e]),d=(0,W.useMemo)(()=>IG(t,e.source,u,c),[t,e.source,u,c]),f=e.source.type===`metric-type`,p=(0,W.useCallback)(n=>{if(n.stopPropagation(),f&&a&&l.current){let n=l.current.getBoundingClientRect();a(t.sourceBlockKey,e.source.metricType,n)}},[f,e.source,t.sourceBlockKey,a]),m=(0,W.useMemo)(()=>eK(d,e.format,i,t),[d,e.format,i,t]);return(0,G.jsx)(`td`,{ref:l,className:K(`py-1 px-2`,f&&`cursor-cell`,o),style:s,onDoubleClick:p,children:m})};function eK(e,t,n,r){if(e==null)return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[pK(n),(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`})]});switch(t.type){case`text`:return tK(e,t,n);case`time`:return nK(e,t);case`number`:return rK(e,t);case`badge`:return iK(e,t);case`pill`:return aK(e,t);case`combined`:return sK(e,t,n);case`custom`:return lK(e,t,r);default:return dK(e,n)}}function tK(e,t,n){let r=t.transform?t.transform(e):mK(e);return(0,G.jsxs)(`span`,{className:K(`inline-flex items-center gap-1`,t.className),children:[pK(n),r]})}function nK(e,t){let n=hK(e);if(n==null||!Number.isFinite(n))return(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r;switch(t.style){case`long`:r=CB(n);break;case`precise`:r=`${n.toFixed(2)}s`;break;default:r=SB(n)}return t.transform&&(r=t.transform(r)),(0,G.jsx)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:r})}function rK(e,t){let n=hK(e);if(n==null||!Number.isFinite(n))return(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t.decimals??0,i=n.toFixed(r)+(t.unit??``);return t.transform?(0,G.jsx)(`span`,{children:t.transform(i)}):(0,G.jsx)(`span`,{children:i})}function iK(e,t){let n=t.styleResolver(e),r=t.textResolver(e);return(0,G.jsxs)(`span`,{className:K(`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium`,n.className),title:n.title,children:[n.icon&&(0,G.jsx)(`span`,{className:`mr-0.5`,children:n.icon}),r]})}function aK(e,t){let n=t.transform?t.transform(e):mK(e),r=t.backgroundColor??`bg-muted`,i=t.borderRadius??`rounded`;return(0,G.jsx)(`span`,{className:K(`inline-block px-1.5 py-0.5 text-xs font-medium`,r,i),children:n})}var oK={primary:`text-sm font-semibold text-foreground`,secondary:`text-xs text-muted-foreground`,tertiary:`text-[11px] text-muted-foreground opacity-80`};function sK(e,t,n,r){let[i,a,o]=Array.isArray(e)?e:[e],s=i===void 0?null:cK(i,t.primaryFormat??{type:`text`},r,`primary`),c=a===void 0?null:cK(a,t.secondaryFormat??{type:`text`},r,`secondary`),l=o===void 0?null:cK(o,t.tertiaryFormat??{type:`text`},r,`tertiary`),u=t.layout===`horizontal`;return(0,G.jsxs)(`div`,{className:K(`inline-flex`,u?`flex-row items-center gap-1`:`flex-col items-start gap-0.5`,t.containerClassName),children:[pK(n),s,c&&(0,G.jsxs)(G.Fragment,{children:[u&&t.separator&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:t.separator}),c]}),l&&(0,G.jsxs)(G.Fragment,{children:[u&&t.separator&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:t.separator}),l]})]})}function cK(e,t,n,r){let i=eK(e,t,0,n);return r?(0,G.jsx)(`span`,{className:K(`inline-flex items-center`,oK[r]),children:i}):i}function lK(e,t,n){let r=n?{...t.context,row:n}:t.context;return t.render(e,r)}function uK(e){let t=e?.metrics;if(!t)return[];if(Array.isArray(t))return t;if(typeof t==`object`&&t&&`toArray`in t){let e=t;if(typeof e.toArray==`function`)return e.toArray()}return[]}function dK(e,t){return e?.metrics?fK(e,t):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[pK(t),mK(e)]})}function fK(e,t){let n=uK(e);return n.length===0?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[pK(t),(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`})]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[pK(t),n.map((e,t)=>(0,G.jsx)(QG,{metric:e},t))]})}function pK(e){return e<=0?null:(0,G.jsx)(`div`,{className:`flex-shrink-0 mr-1 border-l-2 border-muted h-4`,style:{width:`${e*1.25}rem`,marginLeft:`2px`}})}function mK(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=uK(e);if(t.length>0){let e=t[0];if(e?.image)return e.image;if(e?.value!==void 0)return String(e.value)}return String(e)}function hK(e){if(e==null)return;if(typeof e==`number`)return e;if(typeof e==`string`){let t=parseFloat(e);if(!Number.isNaN(t))return t}let t=uK(e);if(t.length>0&&typeof t[0]?.value==`number`)return t[0].value}var gK=e=>e;function _K(e){let t=e?.metrics;if(!t)return[];if(Array.isArray(t))return t;if(typeof t==`object`&&t&&`toArray`in t){let e=t;if(typeof e.toArray==`function`)return e.toArray()}return[]}function vK(e){let t=_K(e);if(t.length===0)return;let n=t[0];return typeof n?.value==`number`?n.value:n?.image?n.image:String(n?.value??``)}function yK(e){let t=_K(e);for(let e of t)if(typeof e?.value==`number`)return e.value}function bK(e){return _K(e).map(e=>e.image??String(e.value??``)).join(`, `)}function xK(e){return e==null?``:Array.isArray(e)?e.map(e=>xK(e)).filter(Boolean).join(` — `):typeof e==`string`?e:typeof e==`number`?String(e):bK(e)}function SK(e){switch(e){case J.Duration:case J.Rep:case J.Distance:case J.Rounds:case J.Resistance:case J.Increment:case J.Metric:case J.Volume:case J.Intensity:case J.Load:case J.Work:case J.CurrentRound:case J.Calculated:return!0;default:return!1}}function CK(e){switch(e){case J.Duration:return`s`;case J.Rep:return`reps`;case J.Distance:return`m`;case J.Rounds:return`rounds`;case J.Resistance:return`kg`;case J.Increment:return`Δ`;case J.Calculated:case J.Custom:return``;default:return``}}function wK(e,t){let n=uo(e),r=HB(e)??void 0,i=t?.graphable??SK(e);return{id:e,label:n,icon:r,source:{type:`metric-type`,metricType:e},format:{type:`custom`,render:e=>fK(e,0)},sort:SK(e)?{type:`numeric`,extractor:e=>yK(e)}:{type:`text`,extractor:e=>{let t=vK(e);return t===void 0?void 0:String(t)}},graph:i?{extractor:e=>yK(e),axisLabel:n,unit:CK(e)}:void 0,filter:{extractor:e=>bK(e),caseInsensitive:!0},meta:{defaultVisible:t?.defaultVisible??!0,debugOnly:t?.debugOnly,tags:[e]}}}function TK(e){switch(e){case`segment`:return`bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200`;case`milestone`:return`bg-yellow-100 text-yellow-800 dark:bg-yellow-900/50 dark:text-yellow-200`;case`system`:return`bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400`;case`event`:return`bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-200`;case`group`:return`bg-indigo-100 text-indigo-800 dark:bg-indigo-900/50 dark:text-indigo-200`;case`load`:return`bg-green-100 text-green-800 dark:bg-green-900/50 dark:text-green-200`;case`compiler`:return`bg-pink-100 text-pink-800 dark:bg-pink-900/50 dark:text-pink-200`;default:return`bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300`}}function EK(e,t){if(!e||e.length===0)return``;let n=e=>SB(e);if(t===0)return n(e[0].started);let r=n(e[0].started),i=e[e.length-1];if(i.ended===void 0)return r;let a=n(i.ended);return r===a?r:`${r} — ${a}`}function DK(e,t=!0){if(e===void 0||e===0)return``;let n=new Date(e),r=n.getHours().toString().padStart(2,`0`),i=n.getMinutes().toString().padStart(2,`0`),a=n.getSeconds().toString().padStart(2,`0`);return t?`${r}:${i}:${a}.${n.getMilliseconds().toString().padStart(3,`0`)}`:`${r}:${i}:${a}`}function OK({value:e}){let t=e.match(/^(-?)(\d+)(:\d{2})(?::\d{2})?(\.\d+)?$/);if(!t)return(0,G.jsx)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:e});let[,n,r,i,a,o]=t,s=i.slice(1);return(0,G.jsxs)(`span`,{className:`font-mono text-xs whitespace-nowrap inline-flex items-baseline`,children:[n&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:n}),(0,G.jsx)(`span`,{className:`font-semibold text-foreground`,children:r}),(0,G.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`:`,s]}),a&&(0,G.jsx)(`span`,{className:`text-muted-foreground/40`,children:a}),o&&(0,G.jsx)(`span`,{className:`text-muted-foreground/30 text-[10px]`,children:o})]})}function kK({elapsed:e,duration:t}){let n=SB(e);return(0,G.jsxs)(`span`,{className:`inline-flex items-baseline gap-0.5`,children:[(0,G.jsx)(OK,{value:n}),t!==void 0&&t>0&&t!==e&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground/40 mx-0.5`,children:`/`}),(0,G.jsx)(`span`,{className:`opacity-60`,children:(0,G.jsx)(OK,{value:SB(t)})})]})]})}var AK={id:`#`,label:`#`,source:{type:`derived`,compute:e=>({index:e.index,outputType:e.outputType,sourceBlockKey:e.sourceBlockKey})},format:{type:`custom`,render:e=>{let{index:t,outputType:n,sourceBlockKey:r}=e??{};return(0,G.jsx)(`span`,{className:K(`font-mono text-[11px] w-8 text-right inline-block`,TK(n)),title:`Type: ${n}\nBlock: ${r}`,children:t})}},sort:{type:`numeric`,extractor:e=>gK(e)?.index||0},meta:{tags:[`layout`],defaultVisible:!0,width:`40px`,resizable:!1}},jK={id:`timestamp`,label:`Timestamp`,source:{type:`fixed-field`,field:`absoluteStartTime`},format:{type:`custom`,render:(e,t)=>{let n=e,r=gK(t)?.hideMs!==!1;return(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px] text-center w-24 whitespace-nowrap`,children:DK(n,r)})},context:{hideMs:!1}},sort:{type:`numeric`,extractor:e=>gK(e)?.absoluteStartTime??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},MK={id:`spans`,label:`Time`,source:{type:`derived`,compute:e=>({spans:e.spans,duration:e.duration})},format:{type:`custom`,render:e=>{let{spans:t,duration:n}=e??{};return(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px] text-center w-40 whitespace-nowrap`,children:EK(t,n)})}},sort:{type:`numeric`,extractor:e=>(gK(e)?.spans)?.[0]?.started??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},NK={id:`timeSpan`,label:`Time`,source:{type:`derived`,compute:e=>({timestamp:e.absoluteStartTime,elapsed:e.elapsed,duration:e.duration})},format:{type:`custom`,render:e=>{let{timestamp:t,elapsed:n,duration:r}=e??{};return n===void 0?(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`}):(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-0 leading-tight`,children:[t!==void 0&&t>0&&(0,G.jsx)(`span`,{className:`text-muted-foreground/50 font-mono text-[10px] whitespace-nowrap`,children:DK(t,!1)}),(0,G.jsx)(kK,{elapsed:n,duration:r})]})}},sort:{type:`numeric`,extractor:e=>gK(e)?.elapsed??0},graph:{extractor:e=>gK(e)?.elapsed,axisLabel:`Elapsed`,unit:`s`},filter:{extractor:e=>{let{timestamp:t,elapsed:n,duration:r}=e??{},i=[];return t!==void 0&&t>0&&i.push(DK(t,!1)),n!==void 0&&i.push(SB(n)),r!==void 0&&r>0&&r!==n&&i.push(SB(r)),i.join(` `)},caseInsensitive:!0},meta:{tags:[`timing`,`compound`],defaultVisible:!0,width:`100px`,subsumes:[`duration`,`elapsedTotal`]}},PK={id:`blockKey`,label:`Block`,source:{type:`fixed-field`,field:`sourceBlockKey`},format:{type:`text`,className:`truncate max-w-[160px] text-sm`},sort:{type:`text`,extractor:e=>gK(e)?.sourceBlockKey??``},filter:{extractor:e=>gK(e)?.sourceBlockKey??``,caseInsensitive:!0},meta:{tags:[`layout`],defaultVisible:!1}},FK={id:`outputType`,label:`Type`,source:{type:`fixed-field`,field:`outputType`},format:{type:`custom`,render:e=>{let t=String(e??``);return(0,G.jsx)(`span`,{className:K(`text-xs px-1.5 py-0.5 rounded font-medium`,TK(t)),children:t})}},sort:{type:`text`,extractor:e=>gK(e)?.outputType??``},filter:{extractor:e=>gK(e)?.outputType??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1}},IK={id:`stackLevel`,label:`Depth`,source:{type:`fixed-field`,field:`stackLevel`},format:{type:`text`,className:`text-muted-foreground font-mono text-xs text-center w-12`},sort:{type:`numeric`,extractor:e=>gK(e)?.stackLevel??0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},LK={id:`elapsedTotal`,label:`Elapsed`,source:{type:`derived`,compute:e=>({elapsed:e.elapsed,total:e.total})},format:{type:`custom`,render:e=>{let{elapsed:t,total:n}=e??{};if(t===void 0||n===void 0)return``;let r=t===n?SB(t):`${SB(t)} / ${SB(n)}`;return(0,G.jsx)(`span`,{className:`text-foreground font-mono text-xs text-right w-32 whitespace-nowrap`,children:r})}},sort:{type:`numeric`,extractor:e=>gK(e)?.elapsed??0},graph:{extractor:e=>gK(e)?.elapsed,axisLabel:`Elapsed`,unit:`s`,color:`#14b8a6`},meta:{tags:[`timing`],defaultVisible:!1}},RK={id:`completionReason`,label:`Reason`,source:{type:`fixed-field`,field:`completionReason`},format:{type:`text`,className:`text-muted-foreground text-xs truncate max-w-[120px]`},sort:{type:`text`,extractor:e=>gK(e)?.completionReason??``},filter:{extractor:e=>gK(e)?.completionReason??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},zK=wK(J.Effort,{defaultVisible:!1}),BK=wK(J.Duration,{debugOnly:!0}),VK=wK(J.Rep),HK=wK(J.Rounds,{defaultVisible:!1}),UK=wK(J.Distance),WK=wK(J.Resistance),GK=wK(J.Action),KK=wK(J.Increment),qK=wK(J.Metric),JK=wK(J.Calculated),YK=wK(J.Custom,{defaultVisible:!1}),XK=wK(J.Group,{defaultVisible:!1}),ZK=wK(J.System,{defaultVisible:!1}),QK=wK(J.Label,{defaultVisible:!1}),$K=wK(J.Text),eq=wK(J.CurrentRound,{defaultVisible:!1}),tq=wK(J.Volume),nq=wK(J.Intensity),rq=wK(J.Load),iq=wK(J.Work),aq=[AK,NK,jK,MK,PK,FK,IK,LK,RK,{id:`exercise`,label:`Exercise`,icon:HB(J.Effort)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`fallback`,semantics:`all-present-combined`,sources:[{type:`metric-type`,metricType:J.Effort},{type:`metric-type`,metricType:J.Text}]},{type:`metric-type`,metricType:J.Text},{type:`metric-type`,metricType:J.Label},{type:`metric-type`,metricType:J.Effort}]},format:{type:`combined`,layout:`vertical`,primaryFormat:{type:`text`,className:`font-medium text-foreground`},secondaryFormat:{type:`text`,className:`text-muted-foreground text-xs`},containerClassName:`items-start`},sort:{type:`text`,extractor:e=>xK(e)},filter:{extractor:e=>xK(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`grouping`,`fallback`,`descriptor`],subsumes:[`effort`,`text`,`label`]}},{id:`descriptor`,label:`Descriptor`,icon:HB(J.Effort)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`metric-type`,metricType:J.Effort},{type:`metric-type`,metricType:J.Label},{type:`metric-type`,metricType:J.Rounds},{type:`metric-type`,metricType:J.CurrentRound}]},format:{type:`custom`,render:e=>fK(e,0)},sort:{type:`text`,extractor:e=>xK(e)},filter:{extractor:e=>xK(e),caseInsensitive:!0},meta:{defaultVisible:!0,subsumes:[`effort`,`label`,`rounds`,`current-round`]}},zK,$K,QK,BK,{id:`pace`,label:`Pace`,icon:`⏱️`,source:{type:`derived`,dependencies:[`distance`,`duration`],compute:(e,t)=>{let n=yK(t.dependencies.get(`distance`)),r=yK(t.dependencies.get(`duration`));if(!(!n||!r))return n/r}},format:{type:`custom`,render:e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`});let t=1e3/e;return(0,G.jsxs)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:[SB(t),`/km`]})}},sort:{type:`numeric`,extractor:e=>typeof e==`number`?e:void 0},graph:{extractor:e=>typeof e==`number`?e:void 0,axisLabel:`Pace`,unit:`m/s`},filter:{extractor:e=>typeof e!=`number`||!Number.isFinite(e)||e<=0?``:`${SB(1e3/e)}/km`,caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`endurance`,`derived`]}},VK,HK,UK,WK,GK,KK,qK,JK,YK,eq,tq,nq,{id:`loadFocus`,label:`Load`,icon:HB(J.Load)??HB(J.Resistance)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`metric-type`,metricType:J.Load},{type:`metric-type`,metricType:J.Resistance}]},format:{type:`custom`,render:e=>fK(e,0)},sort:{type:`numeric`,extractor:e=>yK(e)},graph:{extractor:e=>yK(e),axisLabel:`Load`,unit:`kg`},filter:{extractor:e=>bK(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`strength`,`fallback`]}},rq,iq,XK,ZK],oq={outputTypes:[`segment`,`milestone`,`group`,`analytics`]},sq={definitions:aq,presets:{default:{label:`Default`,filters:oq,visibleColumnIds:[`#`,`timeSpan`,`descriptor`,`rep`,`distance`,`resistance`,`action`,`increment`,`metric`,`calculated`,`custom`,`volume`,`intensity`,`load`,`work`]},debug:{label:`Debug`,filters:{},visibleColumnIds:[`#`,`timeSpan`,`timestamp`,`spans`,`blockKey`,`outputType`,`stackLevel`,`descriptor`,`duration`,`rep`,`distance`,`resistance`,`action`,`increment`,`metric`,`calculated`,`custom`,`volume`,`intensity`,`load`,`work`,`group`,`system`,`elapsedTotal`,`completionReason`]},strength:{label:`Strength`,filters:oq,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`rep`,`loadFocus`,`volume`,`intensity`,`load`,`work`,`elapsedTotal`]},endurance:{label:`Endurance`,filters:oq,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`distance`,`duration`,`pace`,`rounds`,`increment`,`work`,`elapsedTotal`]}},defaultPreset:`default`},cq=new class{config;definitionMap;constructor(e){this.config=e,this.definitionMap=new Map(e.definitions.map(e=>[e.id,e]))}getVisibleColumns(e){return this.getOrderedCandidates(e).filter(t=>this.computeVisibility(t.id,e))}getAvailableColumns(e){let t=new Set(this.getVisibleColumns(e).map(e=>e.id));return this.config.definitions.filter(n=>!t.has(n.id)&&this.isColumnAvailable(n,e))}getGraphableColumns(e){return this.getVisibleColumns(e).filter(e=>e.graph!==void 0)}getGraphTaggedColumns(e){let t=e.graphTaggedColumnIds;return!t||t.size===0?[]:this.getVisibleColumns(e).filter(e=>t.has(e.id))}isColumnVisible(e,t){return this.getDefinition(e)?this.computeVisibility(e,t):!1}getDefinition(e){return this.definitionMap.get(e)}getPreset(e){return this.config.presets[e]??this.config.presets[this.config.defaultPreset]}getAllDefinitions(){return this.config.definitions}get definitions(){return this.definitionMap}resolveColumnValue(e,t,n,r){let i=this.getDefinition(t);if(!i)return;let a={allRows:n,rowIndex:r??n.findIndex(t=>t.id===e.id),columnDef:i,dependencies:new Map};return IG(e,i.source,a,this.definitionMap)}getOrderedCandidates(e){let t=this.getPreset(e.activePresetId),n=[],r=new Set,i=e=>{if(r.has(e))return;let t=this.getDefinition(e);t&&(n.push(t),r.add(e))};for(let e of t.visibleColumnIds)i(e);for(let e of this.config.definitions)i(e.id);if(e.addedColumnIds)for(let t of e.addedColumnIds)i(t);return n}computeVisibility(e,t,n){if(t.visibilityOverrides&&e in t.visibilityOverrides)return t.visibilityOverrides[e];if(t.addedColumnIds?.has(e))return!0;let r=this.getDefinition(e);if(!r||r.meta?.debugOnly&&!t.isDebugMode||!n&&this.isColumnSubsumed(e,t))return!1;let i=this.getPreset(t.activePresetId).visibleColumnIds.includes(e),a=this.hasDataInRows(r,t.rows);switch(r.source.type){case`fixed-field`:return i;case`derived`:return i;case`metric-type`:return a;case`fallback`:return i&&a;default:return i}}isColumnSubsumed(e,t){for(let n of this.config.definitions)if(n.meta?.subsumes?.length&&this.getPreset(t.activePresetId).visibleColumnIds.includes(n.id)&&n.meta.subsumes.includes(e))return!0;return!1}isColumnAvailable(e,t){return e.meta?.debugOnly&&!t.isDebugMode?!1:this.getPreset(t.activePresetId).visibleColumnIds.includes(e.id)?!this.computeVisibility(e.id,t):e.source.type===`fixed-field`||e.source.type===`derived`||this.hasDataInRows(e,t.rows)}hasDataInRows(e,t){if(t.length===0)return!1;switch(e.source.type){case`fixed-field`:return!0;case`metric-type`:{let{metricType:n}=e.source;return t.some(e=>e.cells.has(n))}case`derived`:return!0;case`fallback`:{let{sources:n}=e.source;return t.some(e=>n.some(t=>this.sourceHasDataInRow(t,e)))}default:return!0}}sourceHasDataInRow(e,t){switch(e.type){case`fixed-field`:return t[e.field]!==void 0&&t[e.field]!==null;case`metric-type`:return t.cells.has(e.metricType);case`derived`:return!0;case`fallback`:return e.sources.some(e=>this.sourceHasDataInRow(e,t));default:return!1}}}(sq);function lq(e){let{segments:t,userOutputOverrides:n,presetId:r,isDebugMode:i,sortConfigs:a,filterOverrides:o,graphTaggedColumns:s,extraMetricTypes:c,columnVisibilityOverrides:l,addedColumnIds:u}=e,d=(0,W.useMemo)(()=>uq(t,n),[t,n]),f=(0,W.useMemo)(()=>{let e=new Set(u??[]);for(let t of c??[])e.add(t);return e},[u,c]),p=(0,W.useMemo)(()=>({rows:d,activePresetId:r,isDebugMode:i,graphTaggedColumnIds:s,visibilityOverrides:l,addedColumnIds:f}),[d,r,i,s,l,f]),m=(0,W.useMemo)(()=>cq.getVisibleColumns(p),[p]),h=(0,W.useMemo)(()=>cq.getAvailableColumns(p),[p]),g=(0,W.useMemo)(()=>({...cq.getPreset(r).filters??{},...o}),[r,o]);return{rows:(0,W.useMemo)(()=>mq(pq(d,g,m,cq.definitions),a,m,cq.definitions),[d,g,a,m]),visibleColumns:m,availableColumns:h,graphTaggedColumnIds:(0,W.useMemo)(()=>Array.from(s??[]),[s])}}function uq(e,t){return e.map((e,n)=>{let r=new Map;if(e.metrics)for(let t of e.metrics)fq(r,t);let i=dq(e),a=i?t.get(i):void 0;if(a)for(let e of a)fq(r,e);for(let[,e]of r)e.hasUserOverride=e.metrics.some(e=>e.origin===`user`);let o=e.context?.outputType??e.type;return{id:e.id,index:n+1,sourceBlockKey:i??`segment-${e.id}`,sourceStatementId:e.context?.sourceStatementId,outputType:o,stackLevel:e.depth,absoluteStartTime:e.absoluteStartTime,duration:e.duration,elapsed:e.elapsed,total:e.total,spans:e.spans?[...e.spans]:[],completionReason:e.context?.completionReason,cells:r}})}function dq(e){let t=e.context;return t?.sourceBlockKey?t.sourceBlockKey:e.name}function fq(e,t){let n=t.type;if(n===J.Sound)return;let r=e.get(n);r?e.set(n,{metrics:r.metrics.clone().add(t),hasUserOverride:r.hasUserOverride}):e.set(n,{metrics:da.empty(n).add(t),hasUserOverride:!1})}function pq(e,t,n,r){let i=e;if(t.outputTypes&&t.outputTypes.length>0){let e=new Set(t.outputTypes);i=i.filter(t=>e.has(t.outputType))}if(t.origins&&t.origins.length>0){let e=new Set(t.origins);i=i.filter(t=>{for(let[,n]of t.cells)if(n.metrics.some(t=>t.origin&&e.has(t.origin)))return!0;return!1})}if(t.searchText&&t.searchText.trim().length>0){let a=t.searchText.trim().toLowerCase();i=i.filter(t=>{for(let i of n)if(i.filter&&XG(t,i,{allRows:e,rowIndex:e.indexOf(t),columnDef:i,dependencies:new Map},r).toLowerCase().includes(a))return!0;return!1})}if(t.columnFilters)for(let[a,o]of Object.entries(t.columnFilters)){if(!o||o.trim().length===0)continue;let t=n.find(e=>e.id===a);t&&(i=i.filter(n=>{let i={allRows:e,rowIndex:e.indexOf(n),columnDef:t,dependencies:new Map};return ZG(n,t,o,i,r)}))}return i}function mq(e,t,n,r){if(t.length===0)return e;let i=[...e];return i.sort((i,a)=>{for(let o of t){let t=n.find(e=>e.id===o.columnId);if(!t||!t.sort)continue;let s={allRows:e,rowIndex:e.indexOf(i),columnDef:t,dependencies:new Map},c={allRows:e,rowIndex:e.indexOf(a),columnDef:t,dependencies:new Map},l=JG(qG(i,t,s,r),qG(a,t,c,r));if(l!==0)return o.direction===`asc`?l:-l}return i.index-a.index}),i}function hq(e,t){return{id:e,label:t.label,filters:t.filters??{},visibleColumns:[...t.visibleColumnIds],isDefault:e===sq.defaultPreset}}var gq=Object.fromEntries(Object.entries(sq.presets).map(([e,t])=>[e,hq(e,t)])),_q=gq.default;gq.debug,gq.strength,gq.endurance;function vq(e){return gq[e]??_q}var yq=({activePreset:e,onPresetChange:t,searchText:n,onSearchChange:r,showFilters:i,onToggleFilters:a,totalRows:o,visibleRows:s})=>(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 border-b border-border bg-muted/10 dark:bg-muted/5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`label`,{className:`text-xs text-muted-foreground font-medium`,children:`View:`}),(0,G.jsx)(`select`,{className:`text-xs rounded border border-border bg-background text-foreground px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,value:e.id,onChange:e=>t(e.target.value),children:Object.values(gq).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,G.jsx)(`div`,{className:`w-px h-5 bg-border`}),(0,G.jsx)(`div`,{className:`flex items-center flex-1 max-w-md`,children:(0,G.jsxs)(`div`,{className:`flex w-full group`,children:[(0,G.jsx)(`input`,{type:`text`,className:`flex-1 px-2.5 py-1 text-xs rounded-l border border-r-0 border-border bg-background text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:ring-1 focus:ring-primary/40 focus:z-10`,placeholder:`Filter results…`,value:n,onChange:e=>r(e.target.value)}),(0,G.jsxs)(`button`,{className:`px-2.5 py-1 text-xs rounded-r border border-border bg-muted/30 text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors flex items-center gap-1.5 border-l-0`,title:`Filter results`,children:[(0,G.jsx)(`span`,{children:`🔍`}),(0,G.jsx)(`span`,{className:`font-medium`,children:`Search`})]})]})}),(0,G.jsx)(`div`,{className:`w-px h-5 bg-border`}),(0,G.jsx)(`button`,{className:[`text-xs px-2 py-1 rounded border transition-colors`,i?`bg-primary/10 border-primary/30 text-primary`:`bg-muted/30 border-border text-muted-foreground hover:text-foreground`].join(` `),onClick:a,title:i?`Hide column filters`:`Show column filters`,children:`🔽 Filters`}),(0,G.jsx)(`div`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:s===o?`${o} rows`:`${s} / ${o} rows`})]}),bq={"#":`40px`,exercise:`180px`,text:`160px`,notes:`160px`,completionReason:`160px`,rep:`72px`,rounds:`72px`,"current-round":`72px`,duration:`96px`,distance:`96px`,resistance:`96px`,load:`96px`,volume:`96px`,intensity:`96px`,metric:`96px`,work:`96px`,elapsedTotal:`96px`,action:`96px`,increment:`96px`,timestamp:`96px`,spans:`96px`,blockKey:`180px`,outputType:`96px`,stackLevel:`72px`,elapsed:`96px`},xq=`48px`;function Sq(e){return e.meta?.width??bq[e.id]??`96px`}function Cq(){return xq}var wq=({columns:e,sortConfigs:t,onSort:n,onToggleGraph:r,showFilters:i,columnFilters:a,onColumnFilterChange:o,availableToAdd:s,onAddColumn:c,graphTaggedColumnIds:l})=>(0,G.jsxs)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 sticky top-0 z-10`,children:[(0,G.jsxs)(`tr`,{className:`border-b border-border`,children:[e.map(e=>(0,G.jsx)(Tq,{column:e,sortConfig:t.find(t=>t.columnId===e.id),onSort:n,onToggleGraph:r,isGraphed:l?.has(e.id)??!1},e.id)),c&&(0,G.jsx)(`th`,{className:`py-2 px-1`,style:{minWidth:Cq()},children:(0,G.jsx)(Oq,{availableToAdd:s??[],onAddColumn:c})})]}),i&&(0,G.jsxs)(`tr`,{className:`border-b border-border/50 bg-muted/20 dark:bg-muted/10`,children:[e.map(e=>(0,G.jsx)(Dq,{column:e,value:a[e.id]??``,onChange:o},e.id)),c&&(0,G.jsx)(`th`,{className:`py-1 px-1`,style:{minWidth:Cq()}})]})]}),Tq=({column:e,sortConfig:t,onSort:n,onToggleGraph:r,isGraphed:i})=>{let a=e.sort!==void 0,o=e.graph!==void 0,s=(0,W.useCallback)(t=>{a&&n(e.id,t.shiftKey)},[e.id,a,n]),c=(0,W.useCallback)(t=>{t.stopPropagation(),r(e.id)},[e.id,r]);return(0,G.jsx)(`th`,{className:[`py-1.5 px-2 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider whitespace-nowrap select-none`,a?`cursor-pointer hover:text-foreground transition-colors`:``].join(` `),style:{minWidth:Sq(e)},onClick:s,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.icon&&(0,G.jsx)(`span`,{className:`text-sm`,children:e.icon}),(0,G.jsx)(`span`,{children:e.label}),t&&(0,G.jsx)(Eq,{direction:t.direction}),o&&(0,G.jsx)(`button`,{className:[`ml-auto text-sm opacity-40 hover:opacity-100 transition-opacity`,i?`opacity-100 text-primary`:``].join(` `),onClick:c,title:i?`Remove from graph`:`Add to graph`,children:`📊`})]})})},Eq=({direction:e})=>(0,G.jsx)(`span`,{className:`text-primary text-[10px] ml-0.5`,children:e===`asc`?`▲`:`▼`}),Dq=({column:e,value:t,onChange:n})=>e.filter?(0,G.jsx)(`th`,{className:`py-1 px-2`,style:{minWidth:Sq(e)},children:(0,G.jsx)(`input`,{type:`text`,className:`w-full px-1.5 py-0.5 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/40`,placeholder:`Filter…`,value:t,onChange:t=>n(e.id,t.target.value)})}):(0,G.jsx)(`th`,{className:`py-1 px-2`,style:{minWidth:Sq(e)}}),Oq=({availableToAdd:e,onAddColumn:t})=>{let[n,r]=(0,W.useState)(!1),i=(0,W.useRef)(null),a=(0,W.useRef)(null);return(0,W.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&a.current&&!a.current.contains(e.target)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),e.length===0?null:(0,G.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,G.jsx)(`button`,{ref:a,title:`Add metric column`,onClick:e=>{e.stopPropagation(),r(e=>!e)},className:[`flex items-center justify-center w-5 h-5 rounded text-[11px] font-bold transition-all`,`text-muted-foreground hover:text-foreground hover:bg-primary/10 hover:border-primary/40`,`border border-dashed border-muted-foreground/40`,n?`bg-primary/10 border-primary/40 text-foreground`:``].join(` `),children:`+`}),n&&(0,G.jsxs)(`div`,{ref:i,className:`absolute right-0 top-full mt-1 z-50 min-w-[160px] max-h-64 overflow-y-auto
|
|
157
157
|
bg-popover border border-border rounded-md shadow-xl py-1`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider border-b border-border/50 mb-1`,children:`Add metric column`}),e.map(e=>{let n=HB(e)??`•`,i=ho.columnLabel(e);return(0,G.jsxs)(`button`,{onClick:()=>{t(e),r(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs hover:bg-muted text-foreground transition-colors`,children:[(0,G.jsx)(`span`,{className:`text-sm w-4 text-center`,children:n}),(0,G.jsx)(`span`,{children:i})]},e)})]})]})},kq=({row:e,allRows:t,rowIndex:n,columns:r,isSelected:i,onSelect:a,isHovered:o,onHover:s,onCellDoubleClick:c})=>{let l=t=>{a(e.id,{ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey})},u=e.outputType===`group`;return(0,G.jsx)(`tr`,{className:K(`border-b border-border transition-colors cursor-pointer`,u?`bg-muted/50 font-bold`:``,i?`bg-accent dark:bg-accent/20`:o?`bg-muted/50 dark:bg-muted/40`:`hover:bg-muted/30 dark:hover:bg-muted/20`),onClick:l,onMouseEnter:()=>s(e.sourceBlockKey),onMouseLeave:()=>s(null),children:r.map(r=>{let i=r.source.type===`metric-type`&&r.source.metricType===J.Effort;return(0,G.jsx)($G,{columnDef:r,row:e,allRows:t,rowIndex:n,indent:i?e.stackLevel:0,onDoubleClick:c,style:{minWidth:Sq(r)}},r.id)})})};function Aq(e){let{rows:t,columns:n,graphTaggedColumnIds:r,definitionMap:i}=e,a=(0,W.useMemo)(()=>jq(r,n),[r,n]),o=(0,W.useMemo)(()=>Mq(t,r,n,i),[t,r,n,i]);return{data:o,graphConfigs:a,hasData:a.length>0&&o.length>0}}function jq(e,t){let n=[];for(let r of e){let e=t.find(e=>e.id===r);e&&n.push({id:r,label:e.label,unit:Iq(e),color:Nq(e),dataKey:r,icon:e.icon})}return n}function Mq(e,t,n,r){return t.length===0?[]:e.map((i,a)=>{let o={index:i.index,label:i.sourceBlockKey};for(let s of t){let t=n.find(e=>e.id===s);if(!t||!t.graph){o[s]=0;continue}o[s]=YG(i,t,{allRows:e,rowIndex:a,columnDef:t,dependencies:new Map},r)??0}return o})}function Nq(e){if(e.graph?.color)return e.graph.color;let t=Pq(e);return t?Fq[t]??`#888888`:`#888888`}function Pq(e){if(e.source.type===`metric-type`)return e.source.metricType}var Fq={[J.Time]:`#3b82f6`,[J.Rep]:`#22c55e`,[J.Effort]:`#eab308`,[J.Distance]:`#14b8a6`,[J.Rounds]:`#a855f7`,[J.Resistance]:`#ef4444`,[J.Increment]:`#6366f1`,[J.Action]:`#ec4899`};function Iq(e){if(e.graph?.unit)return e.graph.unit;let t=Pq(e);if(!t)return``;switch(t){case J.Time:return`ms`;case J.Rep:return`reps`;case J.Distance:return`m`;case J.Rounds:return`rounds`;case J.Resistance:return`kg`;case J.Increment:return`Δ`;default:return``}}var Lq=({rows:e,columns:t,graphTaggedColumnIds:n,selectedIds:r,onSelectRow:i})=>{let[a,o]=(0,W.useState)(!1),{data:s,graphConfigs:c,hasData:l}=Aq({rows:e,columns:t,graphTaggedColumnIds:n,selectedIds:r}),u=(0,W.useCallback)(t=>{if(!t?.activePayload?.[0])return;let n=t.activePayload[0].payload,r=e.find(e=>e.index===n.index);r&&i&&i(r.id)},[e,i]);return n.length===0?null:(0,G.jsxs)(`div`,{className:`border-b border-border bg-background`,children:[(0,G.jsxs)(`button`,{className:`w-full flex items-center justify-between px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors`,onClick:()=>o(e=>!e),children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{children:`📊`}),(0,G.jsxs)(`span`,{children:[`Graph — `,c.map(e=>e.label).join(`, `)]})]}),(0,G.jsx)(`span`,{className:`text-[10px]`,children:a?`▼`:`▲`})]}),!a&&(0,G.jsx)(`div`,{className:`px-3 pb-3`,children:l?(0,G.jsx)(`div`,{className:`w-full bg-muted/30 rounded-lg border border-border p-2`,style:{height:220},children:(0,G.jsx)(Pn,{width:`100%`,height:`100%`,children:(0,G.jsxs)(Dn,{data:s,onClick:u,children:[(0,G.jsx)(Ce,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,G.jsx)(Qe,{dataKey:`index`,stroke:`hsl(var(--muted-foreground))`,tick:{fontSize:10},label:{value:`Row #`,position:`insideBottom`,offset:-5,fill:`hsl(var(--muted-foreground))`,fontSize:10}}),(0,G.jsx)(z,{stroke:`hsl(var(--muted-foreground))`,tick:{fontSize:10},domain:[`auto`,`auto`]}),(0,G.jsx)(Wn,{contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,fontSize:`12px`,color:`hsl(var(--popover-foreground))`},labelFormatter:e=>`Row ${e}`,formatter:(e,t)=>{let n=c.find(e=>e.dataKey===t);return[`${typeof e==`number`?e.toLocaleString():e}${n?.unit?` ${n.unit}`:``}`,n?.label??t]}}),(0,G.jsx)(_n,{verticalAlign:`top`,height:24,wrapperStyle:{fontSize:`11px`}}),c.map(e=>(0,G.jsx)(nt,{type:`monotone`,dataKey:e.dataKey,name:e.label,stroke:e.color,strokeWidth:2,dot:{r:3,fill:e.color},activeDot:{r:5,stroke:e.color,strokeWidth:2}},e.id))]})})}):(0,G.jsx)(`div`,{className:`h-32 flex items-center justify-center text-sm text-muted-foreground`,children:`No numeric data available for the tagged columns.`})})]})},Rq=({isOpen:e,blockKey:t,metricType:n,existingFragments:r,existingUserValue:i,anchorRect:a,onSave:o,onRemove:s,onClose:c})=>{let[l,u]=(0,W.useState)(``),d=(0,W.useRef)(null),f=(0,W.useRef)(null);(0,W.useEffect)(()=>{e&&(u(i===void 0?``:String(i)),setTimeout(()=>d.current?.focus(),0))},[e,i]),(0,W.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&c()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,c]),(0,W.useEffect)(()=>{if(!e)return;let t=e=>{f.current&&!f.current.contains(e.target)&&c()},n=setTimeout(()=>{document.addEventListener(`mousedown`,t)},100);return()=>{clearTimeout(n),document.removeEventListener(`mousedown`,t)}},[e,c]);let p=(0,W.useCallback)(()=>{if(l.trim()===``)return;let e=Number(l.trim()),r=!isNaN(e)&&l.trim()!==``?e:l.trim();o(t,n,r,String(r)),c()},[l,t,n,o,c]),m=(0,W.useCallback)(()=>{s(t,n),c()},[t,n,s,c]),h=(0,W.useCallback)(e=>{e.key===`Enter`&&(e.preventDefault(),p())},[p]);if(!e)return null;let g=HB(n),_=BB(n),v=i!==void 0,y=r.filter(e=>e.origin!==`user`),b=a?{position:`fixed`,top:a.bottom+4,left:Math.max(8,Math.min(a.left,window.innerWidth-280)),zIndex:50}:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:50};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/20 dark:bg-black/40 z-40`}),(0,G.jsxs)(`div`,{ref:f,className:`w-64 rounded-lg border border-border bg-popover text-popover-foreground shadow-lg`,style:b,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[g&&(0,G.jsx)(`span`,{className:`text-sm`,children:g}),(0,G.jsx)(`span`,{className:`text-sm font-medium capitalize`,children:n}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto truncate max-w-[100px]`,title:t,children:t})]}),y.length>0&&(0,G.jsxs)(`div`,{className:`px-3 py-1.5 border-b border-border/50 bg-muted/10`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1 uppercase tracking-wider`,children:`Current`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:y.map((e,t)=>(0,G.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs border ${_}`,children:e.image??String(e.value??e.type)},t))})]}),(0,G.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-1 block`,children:v?`Update override`:`Enter value`}),(0,G.jsx)(`input`,{ref:d,type:`text`,className:`w-full px-2 py-1.5 text-sm rounded border border-border bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/40`,placeholder:`Enter ${n} value…`,value:l,onChange:e=>u(e.target.value),onKeyDown:h})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-t border-border/50`,children:[(0,G.jsx)(`button`,{className:`flex-1 px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors`,onClick:c,children:`Cancel`}),v&&(0,G.jsx)(`button`,{className:`px-2 py-1 text-xs rounded border border-destructive/30 text-destructive hover:bg-destructive/10 transition-colors`,onClick:m,title:`Remove user override`,children:`Clear`}),(0,G.jsx)(`button`,{className:`flex-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,onClick:p,disabled:l.trim()===``,children:`Save`})]})]})]})},zq=({segments:e,selectedSegmentIds:t,onSelectSegment:n,userOutputOverrides:r=new Map,gridViewPreset:i=`default`,onPresetChange:a,hoveredBlockKey:o,onHoverBlockKey:s})=>{let{isDebugMode:c}=Vv(),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)({}),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(new Set),[y,b]=(0,W.useState)({}),[x,S]=(0,W.useState)(new Set),{overrides:C,setOverride:w,removeOverride:T}=eU(!0),[E,D]=(0,W.useState)({isOpen:!1,blockKey:``,type:`Time`,anchorRect:null,existingFragments:[]}),O=(0,W.useMemo)(()=>{let e=new Map;for(let[t,n]of r)e.set(t,n instanceof da?n:da.from(n,t));for(let[t,n]of C)e.set(t,n);return e},[r,C]),k=c?`debug`:i,A=(0,W.useMemo)(()=>vq(k),[k]),{rows:j,visibleColumns:M,availableColumns:N,graphTaggedColumnIds:P}=lq({segments:e,userOutputOverrides:O,presetId:k,isDebugMode:c,sortConfigs:l,filterOverrides:(0,W.useMemo)(()=>({searchText:d||void 0,columnFilters:Object.keys(p).length>0?p:void 0}),[d,p]),graphTaggedColumns:_,extraMetricTypes:x,columnVisibilityOverrides:y,addedColumnIds:x}),F=M,I=e.length,L=(0,W.useMemo)(()=>j.map(e=>e.id),[j]),R=(0,W.useCallback)((e,t)=>{u(n=>{let r=n.find(t=>t.columnId===e);return t?r?r.direction===`asc`?n.map(t=>t.columnId===e?{...t,direction:`desc`}:t):n.filter(t=>t.columnId!==e):[...n,{columnId:e,direction:`asc`}]:r?r.direction===`asc`?[{columnId:e,direction:`desc`}]:[]:[{columnId:e,direction:`asc`}]})},[]),ee=(0,W.useCallback)(e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),z=(0,W.useCallback)((e,t)=>{m(n=>{if(!t){let t={...n};return delete t[e],t}return{...n,[e]:t}})},[]),te=(0,W.useCallback)(e=>{b({}),m({}),f(``),a?.(e)},[a]),ne=(0,W.useCallback)(e=>{S(t=>{let n=new Set(t);return n.add(e),n})},[]),re=(0,W.useMemo)(()=>N.filter(e=>e.source.type===`metric-type`).map(e=>e.source.metricType),[N]),ie=(0,W.useCallback)((e,t)=>{n(e,t,L)},[n,L]),ae=(0,W.useCallback)(e=>{s?.(e)},[s]),oe=(0,W.useCallback)(e=>{n(e,{ctrlKey:!1,shiftKey:!1},L)},[n,L]),B=(0,W.useCallback)((e,t,n)=>{let r=(j.find(t=>t.sourceBlockKey===e)?.cells.get(t))?.metrics.toArray()??[],i=r.find(e=>e.origin===`user`),a=i?.value==null?void 0:String(i.value);D({isOpen:!0,blockKey:e,type:t,anchorRect:n,existingFragments:r,existingUserValue:a})},[j]),se=(0,W.useCallback)((e,t,n,r)=>{w(e,t,n,r),D(e=>({...e,isOpen:!1}))},[w]),V=(0,W.useCallback)(()=>{T(E.blockKey,E.type),D(e=>({...e,isOpen:!1}))},[E.blockKey,E.type,T]),ce=(0,W.useCallback)(()=>{D(e=>({...e,isOpen:!1}))},[]);return(0,G.jsxs)(`div`,{className:`h-full flex flex-col bg-background`,children:[(0,G.jsx)(yq,{activePreset:A,onPresetChange:te,searchText:d,onSearchChange:f,showFilters:h,onToggleFilters:()=>g(e=>!e),totalRows:I,visibleRows:j.length}),(0,G.jsx)(Lq,{rows:j,columns:M,graphTaggedColumnIds:P,selectedIds:t,onSelectRow:oe}),(0,G.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,G.jsxs)(`table`,{className:`text-left text-sm border-collapse min-w-[700px]`,children:[(0,G.jsx)(wq,{columns:F,sortConfigs:l,onSort:R,onToggleGraph:ee,showFilters:h,columnFilters:p,onColumnFilterChange:z,availableToAdd:re,onAddColumn:ne,graphTaggedColumnIds:_}),(0,G.jsx)(`tbody`,{className:`divide-y divide-border`,children:j.length===0?(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:F.length,className:`py-8 text-center text-muted-foreground text-sm`,children:e.length===0?`Finish or stop the timer — results land here`:`No rows match the current filters.`})}):j.map((e,n)=>(0,G.jsx)(kq,{row:e,allRows:j,rowIndex:n,columns:F,isSelected:t.has(e.id),onSelect:ie,isHovered:o===e.sourceBlockKey,onHover:ae,onCellDoubleClick:B},e.id))})]})}),(0,G.jsx)(Rq,{isOpen:E.isOpen,blockKey:E.blockKey,metricType:E.type,existingFragments:E.existingFragments,existingUserValue:E.existingUserValue,anchorRect:E.anchorRect??void 0,onSave:se,onRemove:V,onClose:ce}),(0,G.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-border bg-muted/10 text-xs text-muted-foreground flex items-center justify-between`,children:[(0,G.jsx)(`span`,{children:t.size>0?`${t.size} selected`:`Click a row to select`}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[j.length,` / `,I,` rows`]})]})]})};Kt();var Bq=({title:e,onClose:t,children:n,closeButtonClassName:r,floatingClose:i=!1,variant:a=`default`,actions:o,closeLabel:s})=>{(0,W.useEffect)(()=>(document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=``}),[]);let c=W.useRef(null);(0,W.useEffect)(()=>{let e=document.activeElement;return c.current?.focus({preventScroll:!0}),()=>e?.focus({preventScroll:!0})},[]);let l=e=>{if(e.key!==`Tab`||!c.current)return;let t=Array.from(c.current.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null);if(t.length===0){e.preventDefault();return}let n=document.activeElement,r=t[0],i=t[t.length-1];e.shiftKey&&(n===r||n===c.current||!c.current.contains(n))?(e.preventDefault(),i.focus()):!e.shiftKey&&n===i&&(e.preventDefault(),r.focus())},u=a===`minimal`,d=(0,G.jsx)(`button`,{onClick:t,className:r??`rounded-pill transition-colors shadow-[rgba(0,0,0,0.06)_0px_1px_2px] ${u?`bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground`:`bg-muted/50 hover:bg-muted text-muted-foreground hover:text-foreground`} ${s?`flex h-11 min-w-[44px] items-center justify-center px-4 text-sm font-medium hover:text-foreground`:`p-2`}`,title:s??`Close`,"data-testid":NB.FOCUSED_DIALOG_CLOSE,children:s??(0,G.jsx)(Se,{className:`h-5 w-5`})});return qx.createPortal((0,G.jsxs)(`div`,{ref:c,onKeyDown:l,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e??`Workout`,className:`fixed inset-0 z-[100] flex flex-col bg-background text-foreground outline-none animate-in fade-in duration-200`,children:[i||u&&!e?(0,G.jsxs)(`div`,{className:`absolute top-4 right-4 z-[110] flex items-center gap-2`,children:[o,d]}):e?(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border ${u?`bg-muted/10`:`bg-muted/30`} shrink-0`,children:[(0,G.jsx)(`h2`,{className:`text-lg ${u?`font-black tracking-tight uppercase text-[11px] text-muted-foreground`:`font-semibold`}`,children:e}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o,d]})]}):null,(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col`,children:n})]}),document.body)},Vq=(0,W.createContext)({updateFromSegments:()=>{},clear:()=>{}}),Hq=({children:e,chromecastSubscription:t=null})=>(0,G.jsx)(Vq.Provider,{value:{updateFromSegments:(e,n,r)=>{t&&t.sendAnalyticsSummary([],n,r)},clear:()=>{}},children:e}),Uq=new class{resolve(e){let t=this.resolveMode(e);return t===`active`?{type:`rpc-workbench-update`,mode:`active`}:t===`review`?XH(e.analyticsSegments):QH(e.selectedBlock,e.documentItems)}resolveMode(e){return e.viewMode===`track`?e.runtime&&(e.executionStatus===`running`||e.executionStatus===`paused`)?`active`:e.analyticsSegments.length>0?`review`:e.runtime?`active`:`preview`:e.viewMode===`review`&&e.analyticsSegments.length>0?`review`:`preview`}};function Wq(){if(!(`wakeLock`in navigator))return;let e=navigator.wakeLock;if(!(typeof e!=`object`||!e||!(`request`in e)))return e}function Gq(e){let t=(0,W.useRef)(null);(0,W.useEffect)(()=>{let n=Wq();if(!n||!e)return;let r=!1,i=async()=>{if(document.visibilityState===`visible`)try{let e=await n.request(`screen`);if(r){e.release();return}t.current=e,e.addEventListener(`release`,()=>{t.current===e&&(t.current=null)})}catch{}},a=()=>{document.visibilityState===`visible`&&!t.current&&i()};return i(),document.addEventListener(`visibilitychange`,a),()=>{r=!0,document.removeEventListener(`visibilitychange`,a);let e=t.current;t.current=null,e&&!e.released&&e.release()}},[e])}function Kq(e){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let{code:t,description:n}=e;if(t!==void 0||n!==void 0)return[t===void 0?null:String(t),n?String(n):null].filter(e=>e!==null).join(`: `)||`unknown`;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}var qq=``,Jq=null,Yq=()=>{let e=KV(),[t,n]=(0,W.useState)(e.state),[r,i]=(0,W.useState)(!1);Gq(r);let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null),d=(0,W.useRef)(null),p=pF,m=(0,W.useRef)(p.getActiveHandle()),h=(0,W.useRef)(!1),g=(0,W.useCallback)(e=>{let t=m.current;m.current=null,t&&p.dispose(e),GO(null),u(null),c(null),i(!1)},[p]),_=(0,W.useCallback)(async e=>{if(!h.current){h.current=!0;try{let t=bL.getState().subscriptionManager,n=p.connect(e,t);m.current=n,u(n),c(n.subscription),i(!0),GO(n.transport),n.eventProvider.onEvent(e=>{if(e.name===`clock-command`){let t=UH(e.data);if(!t){console.warn(`[CastButtonRpc] Dropped malformed clock-command payload`);return}uH(t.runId,t.command)||console.warn(`[CastButtonRpc] Clock command rejected by authority:`,t.command.kind);return}let t=cH(),n=WH(e.name,t);n&&t&&!uH(t.runId,n)&&console.warn(`[CastButtonRpc] Legacy receiver event rejected by authority:`,e.name)});let r=bL.getState(),a=Uq.resolve({viewMode:r.viewMode,executionStatus:r.execution.status,runtime:r.runtime,analyticsSegments:r.analyticsSegments,selectedBlock:r.selectedBlock,documentItems:r.documentItems});n.pushInitialWorkbench(a)}finally{h.current=!1}}},[p]),v=(0,W.useRef)(!1),y=(0,W.useCallback)(async()=>{if(p.isConnected&&p.getActiveHandle()){let e=p.getActiveHandle();m.current=e,u(e),c(e.subscription),i(!0);return}if(!(m.current||v.current)&&typeof e.resumeSession==`function`){v.current=!0;try{let t=await e.resumeSession();await _(t)}catch(t){console.warn(`[CastButtonRpc] Session resume failed:`,Kq(t)),g(!1),e.endSession()}finally{v.current=!1}}},[e,_,g,p]);(0,W.useEffect)(()=>e.onStateChanged(e=>{n(e),e===`session-active`?(i(!0),y()):e===`ready`||e===`unavailable`?i(!1):e===`session-ended`&&g(!1)}),[e,g,y]),(0,W.useEffect)(()=>{if(p.isConnected&&p.getActiveHandle()){let e=p.getActiveHandle();m.current=e,u(e),c(e.subscription),i(!0)}else e.state===`session-active`&&y()},[e,p]),(0,W.useEffect)(()=>{let e=l?.transport;if(!e)return;let t=()=>{let t=cH(),n=JSON.stringify(t);if(n!==qq||e!==Jq){qq=n,Jq=e;try{e.send({type:`rpc-clock-snapshot`,snapshot:t})}catch{}}};return t(),lH(t)},[l]),(0,W.useEffect)(()=>{let e=()=>{p.sendDisposeSignal()};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[p]),(0,W.useEffect)(()=>{let t=d.current;if(!t)return;let n=async()=>{if(b.current===`session-active`){if(x.current)return;o(!0);try{g(!0),e.endSession()}finally{setTimeout(()=>o(!1),2e3)}return}try{let t=await e.startSession();i(!0),await _(t)}catch(e){let t=Kq(e);t===`cancel`||t.includes(`cancel`)?console.log(`[CastButtonRpc] Cast request canceled or gesture expired`):console.error(`[CastButtonRpc] Cast failed:`,t),g(!1)}};return t.addEventListener(`click`,n),()=>t.removeEventListener(`click`,n)},[e,_,g]);let b=(0,W.useRef)(t);b.current=t;let x=(0,W.useRef)(a);x.current=a;let S=t===`unavailable`,C=t===`ready`,w=t===`session-active`,T=t===`connecting`,E=r&&w,D=T,O=D||a,k=C||w;return S?(0,G.jsx)(q,{variant:`ghost`,size:`icon`,disabled:!0,className:`opacity-20 cursor-not-allowed`,children:(0,G.jsx)(It,{className:`h-5 w-5`})}):(0,G.jsx)(XO,{transport:l?.transport??null,children:(0,G.jsx)(Hq,{chromecastSubscription:s,children:(0,G.jsx)(q,{ref:d,variant:`ghost`,size:`icon`,disabled:O,onClick:()=>{},className:K(`transition-all`,E&&`text-signal-positive ring-2 ring-signal-positive/30`,D&&`animate-pulse text-signal-caution`,!k&&`opacity-50`),"aria-label":E?`Stop casting`:`Cast to TV`,title:E?`Stop casting`:D?`Connecting...`:`Cast to TV`,children:E?(0,G.jsx)(f,{className:`h-5 w-5`}):(0,G.jsx)(It,{className:`h-5 w-5`})})})})};function Xq(){let{isEnabled:e,toggleAudio:t}=$O();return(0,G.jsxs)(q,{variant:`ghost`,size:`icon`,onClick:t,className:`h-9 w-9 text-muted-foreground hover:text-foreground`,title:e?`Mute audio`:`Enable audio`,children:[e?(0,G.jsx)(le,{className:`h-[1.2rem] w-[1.2rem]`}):(0,G.jsx)(ee,{className:`h-[1.2rem] w-[1.2rem]`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Toggle audio`})]})}async function Zq(e,t={}){let{resultId:n,occurrence:r,metric:i}=e;if(!n||typeof n!=`string`)throw TypeError(`captureMetricCorrection: resultId is required`);if(!r?.blockKey||typeof r.blockKey!=`string`)throw TypeError(`captureMetricCorrection: occurrence.blockKey is required`);if(!i||typeof i.image!=`string`||i.image.length===0)throw TypeError(`captureMetricCorrection: metric.image is required`);if(typeof i.value!=`number`||!Number.isFinite(i.value))throw RangeError(`captureMetricCorrection: metric.value must be finite, got ${i.value}`);if(i.type===J.Rep&&(!Number.isSafeInteger(i.value)||i.value<0))throw RangeError(`captureMetricCorrection: rep corrections must be nonnegative safe integers, got ${i.value}`);let a=t.storage??Z,o=t.persistence??new Lj(a);if(!await a.getSessionById(n)||await a.withTransaction([`events`],async e=>{let t=(await e.getEventsByResult(n)).filter(e=>e.grain===`event`&&e.outputType===`segment`&&e.sourceBlockKey===r.blockKey&&(r.sourceStatementId===void 0||e.sourceStatementId===r.sourceStatementId)&&(r.stackLevel===void 0||e.stackLevel===r.stackLevel));if(t.length===0)return`not-found`;if(t.length>1)throw Error(`captureMetricCorrection: ambiguous occurrence ${r.blockKey} in result ${n} — ${t.length} segments match; pass sourceStatementId/stackLevel`);let a=t[0],o=[...a.metrics.filter(e=>e.origin!==`user`||e.type!==i.type),{type:i.type,value:i.value,image:i.image,origin:`user`,timestamp:new Date}],s=a.timeSpan?.started??a.timestamp,c={...a,metrics:o,...a.metricTemporal?{metricTemporal:o.map(()=>({temporalKind:`instant`,instant:s}))}:{}};return await e.appendEvents([c]),`captured`})===`not-found`)return`not-found`;try{return await o.rederiveResultAnalytics(n),`captured`}catch(e){if(e instanceof Ty&&e.code===`BLOCK_REVISION_NOT_FOUND`)return`captured-no-rederive`;throw e}}var Qq=new Map,$q=({block:e,prepareRun:t,view:n,onClose:r,onCompleteWorkout:i,resultId:a,autoStart:o,onRuntimeReady:s,onRunStarted:c,externalStop:l,adoptRuntime:u,parkOnUnmount:d,onPark:f})=>{let[p,m]=(0,W.useState)(t?null:e),[h,g]=(0,W.useState)(null),_=(0,W.useRef)(!1),v=(0,W.useCallback)(async()=>{if(!(!t||_.current)){_.current=!0,g(null);try{m(await t())}catch(e){g(e instanceof Error?e.message:String(e))}finally{_.current=!1}}},[t]);(0,W.useEffect)(()=>{v()},[v]);let[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(new Set),{isDebugMode:C}=Vv(),w=(0,W.useRef)(Date.now()),T=(0,W.useRef)(typeof document<`u`?document.title:`Wod.Wiki`),E=(0,W.useRef)(null);(0,W.useEffect)(()=>{let t=e.label||e.id,n=y!==null,r=n?`Wod.Wiki - Workout Complete${t?`: `+t:``}`:`Wod.Wiki - Workout Timer${t?`: `+t:``}`,i=n?`/workout/review`:`/workout/timer`;document.title=r,E.current!==i&&(E.current=i,window.gtag?.(`event`,`page_view`,{page_title:r,page_path:i,page_location:typeof window<`u`?window.location.href:i,engagement_time_msec:tW()}));let a=nW.consent;n?a&&window.gtag?.(`event`,`runtime_dialog_review`,{workout_label:t,block_type:e.blockType}):(nW.record(`runtime:dialog_loaded`,{workout_label:t,block_type:e.blockType}),a&&window.gtag?.(`event`,`runtime_dialog_loaded`,{workout_label:t,block_type:e.blockType}))},[e.id,e.label,e.blockType,y]),(0,W.useEffect)(()=>{let t=T.current,n=e.label||e.id;return()=>{let e=Date.now()-w.current;e>=1e3&&window.gtag?.(`event`,`runtime_dialog_closed`,{workout_label:n,duration_seconds:Math.round(e/1e3),engagement_time_msec:e}),typeof document<`u`&&(document.title=t)}},[e.id,e.label]);let D=(0,W.useRef)(!1),O=(0,W.useRef)(!1),k=(0,W.useRef)(!1),[A,j]=(0,W.useState)(!1),[M,N]=(0,W.useState)(!1),P=(0,W.useRef)(!1),F=(0,W.useRef)(!1),I=(0,W.useRef)(null),[L,R]=(0,W.useState)(`idle`),[ee,z]=(0,W.useState)(null),[te,ne]=(0,W.useState)(!1),{collectionItems:re}=wU(y??[],Qq,null),[ie,ae]=(0,W.useState)(new Set),[oe,B]=(0,W.useState)(new Set),[se,V]=(0,W.useState)(!1),ce=(0,W.useMemo)(()=>re.filter(e=>{let t=uU(e);return!ie.has(t)&&!oe.has(t)}),[re,ie,oe]),le=y!==null&&!!a&&ce.length>0&&!se,ue=(0,W.useCallback)(async(e,t)=>{if(typeof t!=`number`||!Number.isFinite(t))throw Error(`Invalid value`);if(e.kind!==`value`)throw Error(`Unsupported entry`);if(!a)throw Error(`The saved run is unavailable.`);if(await Zq({resultId:a,occurrence:{blockKey:e.blockKey,...e.sourceStatementId===void 0?{}:{sourceStatementId:e.sourceStatementId},...e.stackLevel===void 0?{}:{stackLevel:e.stackLevel}},metric:{type:e.metricType,value:t,image:String(t)}})===`not-found`)throw Error(`This result entry could not be found — retry or skip.`);let{segments:n}=GP(Xh(await Z.getEventsByResult(a)).map(e=>Cj(new ma(e))));b(n),ae(t=>new Set(t).add(uU(e)))},[a]),de=(0,W.useCallback)(e=>{B(t=>new Set(t).add(uU(e)))},[]),fe=(0,W.useMemo)(()=>y===null||le?null:{runId:a?`result:${a}`:`review`,phase:`review`,status:`idle`,canNext:!1,canStop:!1,stopRequested:!1,reps:[],selectedOccurrenceId:null,entry:null,error:null,saving:!1},[y,le,a]),pe=async()=>{let e=I.current;if(!e||P.current)return;P.current=!0,F.current=!1,R(`saving`),z(null);let t;try{t=i?.(e.blockId,e.results),await t}catch(e){F.current=!0,z(e instanceof Error?e.message:String(e)),R(`error`),P.current=!1;return}P.current=!1,R(`idle`),ne(!0);let{results:n}=e;if(n.logs&&n.logs.length>0)try{let{segments:e}=GP(n.logs,n.startTime);b(e)}catch{b([])}else n.completed?b([]):k.current&&r()},me=(0,W.useCallback)(()=>{D.current=!0,c?.()},[c]),he=()=>{if(P.current||F.current){k.current=!0;return}if(y!==null||O.current||!D.current){r();return}if(!A&&!l){N(!0);return}k.current=!0,j(!0)},ge=()=>{N(!1),k.current=!0,j(!0)},_e=(0,W.useRef)(he);_e.current=he,qV(fe,(0,W.useCallback)(e=>e.kind===`dismiss`&&(_e.current(),!0),[]),20,{keyboard:!0});let ve=(e,t)=>{O.current||(O.current=!0,I.current={blockId:e,results:t},pe())},ye=(e,t,n)=>{S(r=>{let i=new Set(r);if(t?.ctrlKey)i.has(e)?i.delete(e):i.add(e);else if(t?.shiftKey&&n){let t=Array.from(r).pop();if(t!==void 0){let r=n.indexOf(t),a=n.indexOf(e);if(r!==-1&&a!==-1){let e=Math.min(r,a),t=Math.max(r,a);for(let r=e;r<=t;r++)i.add(n[r])}else i.add(e)}else i.add(e)}else i.clear(),i.add(e);return i})},be=L===`idle`?null:(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-border bg-muted/20 px-6 py-2 text-sm`,children:[L===`saving`&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Saving…`}),L===`error`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{role:`alert`,className:`text-destructive`,children:[`Save failed`,ee?` — ${ee}`:``]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void pe(),className:`rounded-pill border border-border px-3 py-1 text-xs font-medium text-foreground transition-colors hover:bg-accent`,children:`Retry save`})]})]});return p?y===null?(0,G.jsx)(Bq,{onClose:he,title:`Workout`,closeLabel:`Exit`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:he,title:`Stop Session`,className:`flex h-11 min-w-[44px] items-center justify-center rounded-pill bg-muted/50 px-4 text-sm font-medium text-muted-foreground shadow-[rgba(0,0,0,0.06)_0px_1px_2px] transition-colors hover:bg-muted hover:text-foreground`,children:`Stop`}),(0,G.jsx)(Yq,{}),(0,G.jsx)(Xq,{})]}),children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[be,h?(0,G.jsxs)(`div`,{className:`space-y-2 p-4`,children:[(0,G.jsxs)(`p`,{role:`alert`,children:[`Workout not started. `,h]}),(0,G.jsx)(`button`,{type:`button`,className:`rounded border px-3 py-2 hover:bg-accent focus-visible:ring-2`,onClick:()=>void v(),children:`Retry starting workout`})]}):p?null:(0,G.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`p-4`,children:`Saving workout before starting…`}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(JU,{block:p,view:n,onClose:he,onComplete:ve,isExpanded:!0,autoStart:o,onRuntimeReady:s,onRunStarted:me,externalStop:l||A,adoptRuntime:u,parkOnUnmount:d,onPark:f})}),M&&(0,G.jsx)(Bq,{title:`Stop workout?`,onClose:()=>N(!1),closeLabel:`Keep going`,actions:void 0,children:(0,G.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The run stops now and your partial results are kept.`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,G.jsx)(`button`,{type:`button`,"data-testid":`stop-cancel`,onClick:()=>N(!1),className:`rounded-lg border border-border px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent`,children:`Keep going`}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`stop-confirm`,onClick:ge,className:`rounded-lg bg-destructive px-4 py-2 text-sm font-bold text-destructive-foreground transition-colors hover:brightness-110`,children:`Stop — keep partial results`})]})]})})]})}):(0,G.jsx)(Bq,{title:`Workout Complete`,onClose:he,actions:(0,G.jsxs)(G.Fragment,{children:[te&&(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Saved ✓`}),(0,G.jsx)(Yq,{}),(0,G.jsx)(Xq,{})]}),children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[be,(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:le?(0,G.jsx)(kU,{mode:`post-run`,items:ce,onSave:ue,onSkip:de,onClose:()=>V(!0),runId:a?`result:${a}`:void 0,className:`mx-auto max-w-md`}):(0,G.jsx)(zq,{runtime:null,segments:y,selectedSegmentIds:x,onSelectSegment:ye,groups:[],gridViewPreset:C?`debug`:`default`})})]})}):(0,G.jsx)(Bq,{title:`Starting workout`,onClose:r,children:h?(0,G.jsxs)(`div`,{className:`space-y-3 p-6`,children:[(0,G.jsxs)(`p`,{role:`alert`,children:[`Workout not started. `,h,` Your draft is kept.`]}),(0,G.jsx)(`button`,{type:`button`,className:`rounded border px-3 py-2 focus-visible:ring-2`,onClick:()=>void v(),children:`Retry start`})]}):(0,G.jsx)(`p`,{role:`status`,className:`p-6`,children:`Saving workout before starting…`})})},eJ={play:!0,"add-to-today":!0,schedule:!0},tJ=`log`;function nJ(e,t){return e.filter(e=>e.id===tJ?t===`log`:!eJ[e.id]||t===`run`)}function rJ(e,t){let n=t.contentFrom!==void 0&&t.contentTo!==void 0?e.state.doc.sliceString(t.contentFrom,t.contentTo):``,r=t.type===`time`||t.type===`log`?t.type:`time`;return{id:t.id,contentId:t.contentId,dialect:r,sport:t.sport,startLine:t.startLine-1,endLine:t.endLine-1,content:n,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}}}function iJ(e){return function({className:t}){return W.isValidElement(e)?W.cloneElement(e,{className:K(e.props.className,t)}):(0,G.jsx)(`span`,{className:K(`flex items-center`,t),children:e})}}var aJ=({cmd:e,block:t})=>{let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),o=(0,W.useCallback)(async()=>{!e.onSplitClick||n||(await e.onSplitClick(t),r(!0),setTimeout(()=>r(!1),1500))},[e,t,n]),s=(0,W.useCallback)(async()=>{i||(await e.onClick(t),e.successIcon&&(a(!0),setTimeout(()=>a(!1),1500)))},[e,t,i]),c=(0,W.useMemo)(()=>iJ(i?e.successIcon??e.icon:e.icon),[e.icon,e.successIcon,i]),l=(0,W.useMemo)(()=>iJ(n?e.splitSuccessIcon??e.splitIcon:e.splitIcon),[n,e.splitIcon,e.splitSuccessIcon]),u=(0,W.useMemo)(()=>({id:e.id,label:e.label,icon:c,action:{type:`call`,handler:()=>s()}}),[e.id,e.label,c,s]),d=(0,W.useMemo)(()=>({id:`${e.id}-split`,label:`Copy link`,icon:l,action:{type:`call`,handler:o}}),[e.id,l,o]),f=(0,W.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]);if(!e.onSplitClick){let t=i?e.successIcon??e.icon:e.icon;return(0,G.jsxs)(q,{variant:e.primary?`default`:`secondary`,className:K(e.iconOnly?`h-11 w-11 rounded-full p-0 sm:h-auto sm:min-h-[44px] sm:min-w-[44px] sm:w-auto sm:rounded-sm sm:px-1.5 sm:py-0.5 text-[10px] font-medium shadow-sm`:`h-11 w-11 rounded-full p-0 text-[10px] font-medium shadow-sm gap-0 sm:h-auto sm:min-h-[44px] sm:w-auto sm:gap-1 sm:rounded-sm sm:px-2 sm:py-0.5`,!e.primary&&`border border-border/50`,i&&`text-emerald-600 bg-emerald-500/15 dark:text-emerald-400 dark:bg-emerald-500/20 border-emerald-500/30`),title:e.label,"aria-label":e.label,"data-testid":e.id===`run`?NB.EDITOR_START_WORKOUT:void 0,onClick:e=>{f(e),s()},onMouseDown:f,onPointerDown:f,children:[(0,G.jsx)(`span`,{className:`flex items-center justify-center size-4 sm:size-3`,children:t}),!e.iconOnly&&(0,G.jsx)(`span`,{className:`sr-only sm:not-sr-only sm:inline`,children:e.label})]})}return(0,G.jsx)(`div`,{onClick:f,onMouseDown:f,onPointerDown:f,children:(0,G.jsx)(xG,{primary:u,secondary:d,size:`xs`,variant:e.primary?`primary`:`default`,className:`rounded-full sm:rounded-sm`,labelClassName:`sr-only sm:not-sr-only sm:inline`})})},oJ=({view:e,commands:t})=>{let[n,r]=(0,W.useState)(()=>e?.plugin(rw)?.rects??[]),[i,a]=(0,W.useState)(0);(0,W.useEffect)(()=>{if(!e)return;let t=e.plugin(rw);t&&(r([...t.rects]),t.addListener(e=>r([...e])))},[e]),(0,W.useEffect)(()=>{if(!e)return;let t=e.scrollDOM,n=null,r=()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,a(t.scrollTop)}))};return t.addEventListener(`scroll`,r,{passive:!0}),a(t.scrollTop),()=>{n!==null&&cancelAnimationFrame(n),t.removeEventListener(`scroll`,r)}},[e]);let o=e?e.plugin(rw):null,s=(n.length>0?n:o?.rects??[]).filter(e=>e.type===`time`||e.type===`log`);if(s.length===0)return null;let{sections:c}=e.state.field(zC),l=new Map(c.map(e=>[e.id,e]));return(0,G.jsx)(G.Fragment,{children:s.map(n=>{let r=l.get(n.sectionId);if(!r)return null;let a=rJ(e,r),o=nJ(t,va(r.type));return o.length===0?null:(0,G.jsx)(`div`,{className:`absolute right-1 z-10 flex items-end gap-1 pointer-events-auto`,style:{top:n.top-i,height:n.firstLineHeight},children:o.map(e=>(0,G.jsx)(aJ,{cmd:e,block:a},e.id))},n.sectionId)})})},sJ=({sections:e,isRuntimeActive:t,editorState:n,onSelectBlock:r})=>{let i=YO(),a=(0,W.useRef)(``);return(0,W.useEffect)(()=>{if(!i?.connected||t||!n)return;let r=e.filter(e=>e.type===`time`).map(e=>{let t=e.contentFrom!==void 0&&e.contentTo!==void 0?n.doc.sliceString(e.contentFrom,e.contentTo):``,r=t.split(`
|
|
158
158
|
`).filter(e=>e.trim().length>0),i=r.slice(0,3).join(`
|
|
159
|
-
`),a=t.match(/^(\d{1,2}:\d{2}(?::\d{2})?)/m)?.[1],o=r[0]?.substring(0,60)||`Workout`,s=e.type===`time`||e.type===`log`?e.type:`time`;return{id:e.id,title:o,statementCount:r.length,contentPreview:i,timerHint:a,dialect:s}}),o={type:`rpc-workbench-update`,mode:r.length>0?`preview`:`idle`,previewData:r.length>0?{title:r[0].title,blocks:r}:void 0},s=JSON.stringify(o);if(s!==a.current){a.current=s;try{i.send(o)}catch{}}},[i,e,t,n]),(0,W.useEffect)(()=>{i?.connected||(a.current=``)},[i]),(0,W.useEffect)(()=>{t||(a.current=``)},[t]),(0,W.useEffect)(()=>{if(!(!i?.connected||!r||!n))return i.onMessage(t=>{if(t.type!==`rpc-event`||t.name!==`select-block`)return;let{index:i,blockId:a}=t.data??{},o=e.filter(e=>e.type===`time`),s=a?o.find(e=>e.id===a):o[i??0];if(!s||!n)return;let c=s.contentFrom!==void 0&&s.contentTo!==void 0?n.doc.sliceString(s.contentFrom,s.contentTo):``;r({id:s.id,dialect:s.type===`time`||s.type===`log`?s.type:`time`,sport:s.sport,startLine:s.startLine-1,endLine:s.endLine-1,content:c,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}})})},[i,e,n,r,t]),null},cJ={[J.Duration]:{label:`Timer`,icon:`⏱`,textClass:`text-metric-time`,bgClass:`bg-metric-time/10`,borderClass:`border-metric-time/30`},[J.Rep]:{label:`Reps`,icon:`✕`,textClass:`text-metric-rep`,bgClass:`bg-metric-rep/10`,borderClass:`border-metric-rep/30`},[J.Effort]:{label:`Exercise`,icon:`🏋`,textClass:`text-metric-effort`,bgClass:`bg-metric-effort/10`,borderClass:`border-metric-effort/30`},[J.Rounds]:{label:`Rounds`,icon:`↻`,textClass:`text-metric-rounds`,bgClass:`bg-metric-rounds/10`,borderClass:`border-metric-rounds/30`},[J.Distance]:{label:`Distance`,icon:`📏`,textClass:`text-metric-distance`,bgClass:`bg-metric-distance/10`,borderClass:`border-metric-distance/30`},[J.Resistance]:{label:`Weight`,icon:`⚖`,textClass:`text-metric-resistance`,bgClass:`bg-metric-resistance/10`,borderClass:`border-metric-resistance/30`},[J.Equipment]:{label:`Equipment`,icon:`🧰`,textClass:`text-foreground`,bgClass:`bg-muted/40`,borderClass:`border-border/50`},[J.Action]:{label:`Action`,icon:`⚡`,textClass:`text-metric-action`,bgClass:`bg-metric-action/10`,borderClass:`border-metric-action/30`},[J.Label]:{label:`Label`,icon:`🏷`,textClass:`text-muted-foreground`,bgClass:`bg-muted/30`,borderClass:`border-border/40`}},lJ={[J.Rep]:`reps`,[J.Effort]:`movement`,[J.Resistance]:`weight`},uJ=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=cJ[e.type],a=e.type===J.Hint,o=e.image??(e.value===void 0?``:String(e.value)),s=i?.label??String(e.type);return(0,G.jsxs)(`span`,{title:t,onClick:r,className:K(`inline-flex items-center gap-1 px-2 py-0.5 rounded border text-[11px] font-medium`,`pointer-events-auto transition-opacity hover:opacity-80`,i?.bgClass??`bg-muted/30`,i?.textClass??`text-muted-foreground`,i?.borderClass??`border-border/40`,r&&`cursor-pointer`,n&&`font-bold shadow-sm`),children:[(0,G.jsx)(`span`,{children:a?e.icon:i?.icon??`•`}),!a&&(0,G.jsx)(`span`,{children:s}),!a&&o&&(0,G.jsx)(`span`,{className:`font-semibold`,children:o})]})};function dJ(e){let t=la(e.metadata);return{refs:t?.refs??[],diagnostics:t?.diagnostics??[]}}function fJ(e,t){try{let n=e.coordsAtPos(t);if(!n)return null;let r=e.dom?.getBoundingClientRect?.()??{top:0,left:0},i=e.contentDOM?.getBoundingClientRect?.()??{left:0,width:0};return{top:n.bottom-r.top,left:i.left-r.left,width:i.width}}catch{return null}}var pJ=({view:e,cursorVersion:t,getCursorFocusState:n})=>{let[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),s=(0,W.useRef)(null),c=(0,W.useCallback)(()=>{if(!e){o(null),i(null);return}let t=(n??$W)(e.state);o(t),i(t?fJ(e,t.lineFrom):null)},[e,n]);if((0,W.useEffect)(()=>{c()},[c,t]),(0,W.useEffect)(()=>{if(!e)return;let t=()=>c();return window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t,!0),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t,!0)}},[e,c]),!r||!a?.section)return null;let l=a.allStatements?.filter(e=>e.meta?.line===a.cursorLine-a.section.startLine)??(a.statement?[a.statement]:[]),u=l.flatMap(e=>e.metrics.toArray()).filter(e=>e.type!==J.Sound&&e.type!==J.System&&!(e.type===J.Hint&&!e.icon)),d=sV(u,`runtime-badge`),f=l.flatMap(e=>e.metrics.toArray()),p=[],m=[],h=[];for(let e of f){let t=dJ(e);for(let e of t.refs){let t=`${e.kind}:${e.slug}`;p.includes(t)||(p.push(t),m.push(e))}h.push(...t.diagnostics)}let g=typeof e?.state?.facet==`function`?e.state.facet(_w)?.()??null:null,_=typeof e?.state?.doc?.sliceString==`function`?UW(e.state.doc.sliceString(a.lineFrom,a.lineTo)):null,v=e=>e.reason===`conflict`||e.reason.endsWith(`equipment`)||e.reason===`invalid-explicit`&&e.token&&_?.equipment.includes(e.token)?`equipment`:`effort`,y=e=>typeof e==`string`&&e.trim()?e:null,b=async t=>{if(!e)return;let n=e.state.doc.sliceString(a.lineFrom,a.lineTo),r=hz.getState();if(t===`effort`){let t=await r.open({placeholder:`Change effort…`,sources:[VW(`effort`)]});if(t.dismissed)return;let i=y(t.item.payload);if(!i)return;e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:WW(n,{effort:i})}});return}let i=[..._?.equipment??[]];for(;;){let e=await r.open({placeholder:i.length>0?`Add equipment (Esc to finish)…`:`Set equipment…`,sources:[VW(`equipment`)]});if(e.dismissed)break;let t=y(e.item.payload);t&&!i.includes(t)&&i.push(t)}((_?.jsonFrom??-1)>=0||i.length>0)&&e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:WW(n,{equipment:i})}})},x=async()=>{if(!e)return;let t=e.state.doc.sliceString(a.lineFrom,a.lineTo),n=hz.getState(),r,i=await n.open({placeholder:`Add effort (Esc to skip)…`,sources:[VW(`effort`)]});i.dismissed||(r=y(i.item.payload)??void 0);let o=[];for(;;){let e=await n.open({placeholder:`Add equipment (Esc to finish)…`,sources:[VW(`equipment`)]});if(e.dismissed)break;let t=y(e.item.payload);t&&!o.includes(t)&&o.push(t)}!r&&o.length===0||e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:WW(t,{effort:r,equipment:o})}})},S=async t=>{if(!e||!t.token)return;let n=v(t),r=await hz.getState().open({placeholder:`Replace “${t.token}”…`,sources:[VW(n,t.candidates)]});if(r.dismissed)return;let i=y(r.item.payload);if(!i)return;let o=e.state.doc.sliceString(a.lineFrom,a.lineTo).indexOf(t.token);o<0||e.dispatch({changes:{from:a.lineFrom+o,to:a.lineFrom+o+t.token.length,insert:i}})},C=t=>{let n=lJ[t.type];if(!n||!e)return;let r=t.type===J.Effort?`effort`:t.type===J.Equipment?`equipment`:null;if(r&&_?.jsonFrom!==void 0&&_.jsonFrom>=0){b(r);return}an(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-3pxq8hDy.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:t})=>{t(a,e,n)})};return(0,G.jsxs)(`div`,{ref:s,className:K(`cm-metric-inline-panel`,`absolute z-50 pointer-events-none`,`flex items-center gap-2 px-3 h-[28px]`,`bg-background/90 backdrop-blur-sm`,`border-l border-r border-border/50`,`transition-opacity duration-100`),style:{top:r.top,left:r.left,width:r.width,maxWidth:r.width},"aria-live":`polite`,"aria-label":`Metric inline panel`,children:[u.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-medium shrink-0 select-none`,children:`Metrics:`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[u.map((e,t)=>(0,G.jsx)(uJ,{metric:e,tooltip:e.type===J.Hint?String(e.value??``):d[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:lJ[e.type]?()=>C(e):void 0},`${e.type}-${t}`)),m.map(e=>(0,G.jsxs)(`span`,{title:`${e.kind===`effort`?`Effort`:`Equipment`} · click to change source`,onClick:()=>void b(e.kind),className:`pointer-events-auto inline-flex items-center gap-1 px-2 py-0.5 rounded border text-[11px] font-medium cursor-pointer hover:opacity-80 bg-muted/40 text-foreground border-border/50`,children:[(0,G.jsx)(`span`,{children:e.kind===`effort`?`🏋`:`🧰`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:e.label}),g&&(0,G.jsx)(`a`,{href:g.openHref(e.kind,e.slug),title:`Open ${e.label} page`,"aria-label":`Open ${e.label} page`,className:`text-muted-foreground/70 hover:text-foreground`,onClick:e=>e.stopPropagation(),children:`↗`})]},`${e.kind}:${e.slug}`)),_?.malformed&&(0,G.jsxs)(`span`,{"data-testid":`editor-ref-unknown`,title:`Reference JSON on this line does not parse — fix it in the raw text.`,className:`pointer-events-auto inline-flex items-center gap-1.5 px-2 py-0.5 rounded border text-[11px] font-medium bg-destructive/10 text-destructive border-destructive/30`,children:[(0,G.jsx)(`span`,{children:`⚠`}),(0,G.jsx)(`span`,{children:`Malformed reference JSON`})]}),h.map((e,t)=>{let n=v(e);return(0,G.jsxs)(`span`,{"data-testid":`editor-ref-unknown`,title:e.message,className:`pointer-events-auto inline-flex items-center gap-1.5 px-2 py-0.5 rounded border text-[11px] font-medium bg-destructive/10 text-destructive border-destructive/30`,children:[(0,G.jsx)(`span`,{children:`⚠`}),(0,G.jsx)(`span`,{children:e.token??e.reason}),(0,G.jsx)(`button`,{type:`button`,className:`underline cursor-pointer`,onClick:()=>void S(e),children:`Select existing`}),g&&(0,G.jsx)(`a`,{href:g.createHref(n),className:`underline hover:text-foreground`,children:`Create page`})]},`${e.reason}-${t}`)}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-add-metric-line`,title:`Add effort/equipment reference to this line`,onClick:()=>void x(),className:`pointer-events-auto inline-flex items-center px-1.5 py-0.5 rounded border border-dashed border-border/60 text-[10px] text-muted-foreground hover:text-foreground hover:border-primary/50 cursor-pointer`,children:`+ Metric`})]})]}):(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 italic select-none`,children:`No metrics on this line`}),(0,G.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground/40 shrink-0 select-none`,children:`Ctrl+↑↓ · adjust value`})]})},mJ=new si,hJ=new si,gJ=new si;async function _J(e){let t=new TextEncoder().encode(e);if(typeof CompressionStream<`u`)try{let e=new CompressionStream(`gzip`),n=e.writable.getWriter(),r=e.readable.getReader();n.write(t),n.close();let i=[];for(;;){let{done:e,value:t}=await r.read();if(e)break;i.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return btoa(String.fromCharCode(...o)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}catch{}return btoa(String.fromCharCode(...t)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}async function vJ(e){let t=await _J(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function yJ(e){let t=await _J(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${Ly()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var bJ=({noteId:e,noteBlocks:t,sourceRevision:n=0,onIdentityChange:r,onSaved:i,beforeRun:a,onSaveRequest:o,onCommitChange:s,value:c,onChange:l,onDocUpdate:u,onCursorPositionChange:d,onBlur:f,theme:p=`vs`,readonly:m=!1,className:h=``,onStartWorkout:g,onCompleteWorkout:_,onBlocksChange:v,onAddToPlan:y,notePersistence:b,onViewCreated:x,mode:S=`edit`,lineWrapping:w=!0,showLineNumbers:T=!0,enablePreview:E=!0,showFrontmatter:D=!0,enableLinting:O=!0,enableOverlay:k=!1,commands:A,hideDefaultCommands:j=!1,enableInlineRuntime:M=!0,extensions:N,widgetComponents:P,activeSectionId:F,scrollToSectionId:I,results:L,placeholder:R})=>{let ee=(0,W.useRef)(null),z=(0,W.useRef)(null),ne=(0,W.useRef)(null),re=(0,W.useRef)(``);(0,W.useEffect)(()=>{let e=async e=>{if(e.view!==z.current||!xJ(e.state,e.pos))return null;let t=e.state.doc.lineAt(e.pos),n=t.text.slice(0,e.pos-t.from).match(/^([a-zA-Z][\w.-]*)$/),r=SJ(e.state,e.pos);if(!n&&!r)return null;let[i,a]=await Promise.all([Z.getAllTagTypes().catch(()=>[]),Z.getAllTags().catch(()=>[])]);if(n)return{from:t.from,options:i.map(e=>({label:e.name,detail:`Tag Type (${e.label})`,type:`property`,apply:`${e.name}:\n - `})),validFor:(e,t,n,r)=>/^[a-zA-Z][\w.-]*$/.test(e)&&xJ(r,n)};if(!r)return null;let{propertyKey:o,from:s}=r,c={"metrics.effort":`effort`,"metrics.equipment":`equipment`,equipment:`equipment`}[o.toLowerCase()];if(c){let e=await zW();return{from:s,options:(c===`effort`?e.efforts:e.equipment).map(e=>({label:`${e.label} (${e.slug})`,detail:c===`effort`?`Effort`:`Equipment`,type:`constant`,apply:e.slug})),validFor:(e,t,n,r)=>{let i=SJ(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}}let l=i.find(e=>e.name.toLowerCase()===o.toLowerCase());if(!l)return null;let u=a.filter(e=>e.type?.toLowerCase()===l.name.toLowerCase());return u.length===0?null:{from:s,options:u.map(e=>({label:e.label,detail:l.label,type:`constant`})),validFor:(e,t,n,r)=>{let i=SJ(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}};return $C(e),()=>{ew(e)}},[]);let ie=p===`dark`||p===`vs-dark`,ae=GW(ne,b),[oe,B]=(0,W.useState)(null),[se,V]=(0,W.useState)([]),[ce,le]=(0,W.useState)(1),[ue,de]=(0,W.useState)(0),fe=F??oe,pe=uG(se,fe),[me,he]=(0,W.useState)(null),[ge,_e]=(0,W.useState)(null),[ve,ye]=(0,W.useState)(null),[be,xe]=(0,W.useState)(!1),Se=(0,W.useRef)(null),Ce=(0,W.useRef)(!1),we=(0,W.useRef)(n??0);(0,W.useEffect)(()=>{we.current=n??0},[n]);let[Te,Ee]=(0,W.useState)(null),De=(0,W.useRef)(null),Oe=(0,W.useCallback)(async(t,n=!1)=>{let r=z.current;if(!(!r||Ce.current)){Ce.current=!0,Ee(null);try{let o=await a?.();typeof o==`number`&&(we.current=o);let s=r.state.field(zC),c=await bF({noteId:e??C(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:we.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,C(),e?void 0:`playground`,ae);Se.current=c,De.current=null,we.current=c.note.sourceRevision,r.dispatch({effects:jC.of({blocks:c.note.blocks,sourceRevision:c.note.sourceRevision})}),i?.({rawContent:c.note.rawContent,blocks:c.note.blocks,sourceRevision:c.note.sourceRevision}),xe(n),_e(c.block),ye(c.session.id)}catch(e){Ee(e instanceof Error?e.message:String(e))}finally{Ce.current=!1}}},[e,ae,i,a]),ke=(0,W.useCallback)(()=>{_e(null),ye(null),xe(!1)},[]),Ae=(0,W.useCallback)(e=>{M&&Oe(e,!0)},[M,Oe]),je=(0,W.useRef)(null),Me=(0,W.useCallback)((e,t)=>{let n=je.current,r=n!==null&&n.results===t,i=Se.current;if(!i||!t)return Promise.reject(Error(`The saved run pin is unavailable.`));let a=i.session.id;if(De.current===a)return Promise.resolve();let o={id:i.block.id,contentId:i.session.blockContentId};if(!r&&t&&z.current){let t=z.current,n=PT(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Cr.scrollIntoView(e,{y:`start`,yMargin:96})]}),l?.(t.state.doc.toString())}}r||(je.current={results:t,resultId:a,runBlock:o});let s;try{s=JH(ae).record({resultId:a,noteId:i.session.noteId,blockId:i.session.blockId,data:t,createdAt:t.endTime}).then(()=>_?.(e,t,a,o))}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}return Promise.resolve(s).then(()=>{je.current?.results===t&&(je.current=null),De.current=a},()=>{}),s},[l,_,ae]),Ne=(0,W.useMemo)(()=>{if(j)return[];if(A&&A.length>0)return A;let e=[];return M?e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(un,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:Oe}):g&&e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(un,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:g}),e.push({id:`playground`,label:`Playground`,icon:(0,G.jsx)(Ke,{className:`h-3 w-3`}),splitIcon:(0,G.jsx)(te,{className:`h-3 w-3`}),splitSuccessIcon:(0,G.jsx)(sn,{className:`h-3 w-3`}),onClick:e=>{vJ(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await yJ(e.content);await navigator.clipboard.writeText(t)}}),y&&e.push({id:`plan`,label:`Plan`,icon:(0,G.jsx)(wn,{className:`h-3 w-3`}),onClick:y}),e},[A,g,y,M,j,Oe]),Pe=(0,W.useMemo)(()=>fi({codeLanguages:qW}),[]),Fe=(0,W.useMemo)(()=>[...T?[Yr(),zr()]:[],Vr(),ui(),Er(),di(),...w?[Cr.lineWrapping]:[],ei.allowMultipleSelections.of(!0),wr(),Si(),Br(),gi(),li.highest(gr.of([{key:`Tab`,run:e=>Fr(e.state)!==null&&(Ci(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=SJ(e.state,t.head),r=e.state.doc.lineAt(t.head);return!t.empty||n?.value.trim()!==``||r.text.slice(t.head-r.from).trim()?!1:(vr(e),Zr(e))}}])),gr.of([...Pr,...Xr,...oi,...ai,...xi,...ci,Qr,{key:`Mod-s`,run:()=>(o?.(),!0)},{key:`Ctrl-.`,run:e=>{let t=$W(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(an(()=>Promise.resolve().then(()=>mz).then(()=>{an(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-3pxq8hDy.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{hz.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),BT,zC,OC.of({blocks:t??Oa(c,{sourceRevision:Math.max(1,n),registeredWidgets:P?[...P.keys()]:Sa}),sourceRevision:Math.max(1,n),rawContent:c}),kC.of(P?[...P.keys()]:Sa),BC,yw.of(D),...E||!D?[Kw]:[],...E?[fw,hw,jW(),RW(),lT,rT(),bT]:[],...O?[GC]:[],tw,ZC,XC,...k?[VT]:[],rw,DC,nG,...ET,CC,...P&&P.size>0?[yE(P)]:[],YT({executor:eI,onResultSaved:KH,readOnly:m,noteHref:e=>Yz(`blockContentId`in e||`dataType`in e?yI(e):pI(e))}),KW(e,ae),Cr.domEventHandlers({blur:()=>(f?.(),!1)}),Cr.updateListener.of(e=>{if(e.docChanged){let t=e.state.field(zC);r?.({rawContent:t.rawContent,blocks:t.noteBlocks,sourceRevision:t.sourceRevision}),l(t.rawContent),u?.(e),wJ(e.state,v,re),e.transactions.some(e=>e.isUserEvent(`input`)||e.isUserEvent(`delete`)||e.isUserEvent(`paste`)||e.isUserEvent(`drop`))||s?.()}if(e.selectionSet||e.docChanged){de(e=>e+1),e.transactions.some(e=>e.isUserEvent(`delete.backward`))&&Fr(e.startState)!==null&&Fr(e.state)===null&&SJ(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&ti(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);d?.(n.number,t-n.from+1);let r=HC(e.state);B(r?.id??null),le(n.number);let{sections:i}=e.state.field(zC);V(i)}}),ei.readOnly.of(m),Cr.editable.of(!m),...R?[_i(R)]:[]],[l,d,f,u,v,r,m,o,s,T,w,E,D,O,k,e,ae,P,R]);return(0,W.useEffect)(()=>{let e=ee.current;if(!e)return;let t=ei.create({doc:c,extensions:[...Fe,mJ.of(SC(ie)),hJ.of(Pe),gJ.of([]),...N??[]]}),n=new Cr({state:t,parent:e}),i=window.visualViewport,a=0,o=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>{n.hasFocus&&i?.scale===1&&i.height<window.innerHeight&&n.dispatch({effects:Cr.scrollIntoView(n.state.selection.main.head,{y:`nearest`,yMargin:24})})})};i?.addEventListener(`resize`,o),n.contentDOM.addEventListener(`focus`,o),z.current=n,he(n),e.__codemirrorView=n,x?.(n);let{sections:s}=n.state.field(zC);V(s);let l=n.state.doc.lineAt(n.state.selection.main.head).number;le(l);let u=HC(n.state);B(u?.id??null);let d=n.state.field(zC);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),wJ(n.state,v,re),()=>{cancelAnimationFrame(a),i?.removeEventListener(`resize`,o),n.contentDOM.removeEventListener(`focus`,o),delete e.__codemirrorView,he(null),n.destroy()}},[]),(0,W.useEffect)(()=>{let e=z.current;if(!e)return;let r=e.state.field(zC);c===r.rawContent?t&&n!==r.sourceRevision&&e.dispatch({effects:jC.of({blocks:t,sourceRevision:n})}):e.dispatch({changes:{from:0,to:e.state.doc.length,insert:c},...t?{effects:MC.of({rawContent:c,blocks:t,sourceRevision:n})}:{}})},[c,t,n]),(0,W.useEffect)(()=>{z.current&&z.current.dispatch({effects:mJ.reconfigure(SC(ie))})},[ie]),(0,W.useEffect)(()=>{if(z.current){let e=[];z.current.dispatch({effects:[qr.reconfigure.of([...Fe,mJ.of(SC(ie)),hJ.of(Pe),gJ.of(e),...N??[]])]})}},[Fe,N,S,ie,Pe]),(0,W.useEffect)(()=>{m||z.current?.focus()},[m]),(0,W.useEffect)(()=>{if(I&&z.current){let e=z.current,t=e.state.doc.toString().split(`
|
|
159
|
+
`),a=t.match(/^(\d{1,2}:\d{2}(?::\d{2})?)/m)?.[1],o=r[0]?.substring(0,60)||`Workout`,s=e.type===`time`||e.type===`log`?e.type:`time`;return{id:e.id,title:o,statementCount:r.length,contentPreview:i,timerHint:a,dialect:s}}),o={type:`rpc-workbench-update`,mode:r.length>0?`preview`:`idle`,previewData:r.length>0?{title:r[0].title,blocks:r}:void 0},s=JSON.stringify(o);if(s!==a.current){a.current=s;try{i.send(o)}catch{}}},[i,e,t,n]),(0,W.useEffect)(()=>{i?.connected||(a.current=``)},[i]),(0,W.useEffect)(()=>{t||(a.current=``)},[t]),(0,W.useEffect)(()=>{if(!(!i?.connected||!r||!n))return i.onMessage(t=>{if(t.type!==`rpc-event`||t.name!==`select-block`)return;let{index:i,blockId:a}=t.data??{},o=e.filter(e=>e.type===`time`),s=a?o.find(e=>e.id===a):o[i??0];if(!s||!n)return;let c=s.contentFrom!==void 0&&s.contentTo!==void 0?n.doc.sliceString(s.contentFrom,s.contentTo):``;r({id:s.id,dialect:s.type===`time`||s.type===`log`?s.type:`time`,sport:s.sport,startLine:s.startLine-1,endLine:s.endLine-1,content:c,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}})})},[i,e,n,r,t]),null},cJ={[J.Duration]:{label:`Timer`,icon:`⏱`,textClass:`text-metric-time`,bgClass:`bg-metric-time/10`,borderClass:`border-metric-time/30`},[J.Rep]:{label:`Reps`,icon:`✕`,textClass:`text-metric-rep`,bgClass:`bg-metric-rep/10`,borderClass:`border-metric-rep/30`},[J.Effort]:{label:`Exercise`,icon:`🏋`,textClass:`text-metric-effort`,bgClass:`bg-metric-effort/10`,borderClass:`border-metric-effort/30`},[J.Rounds]:{label:`Rounds`,icon:`↻`,textClass:`text-metric-rounds`,bgClass:`bg-metric-rounds/10`,borderClass:`border-metric-rounds/30`},[J.Distance]:{label:`Distance`,icon:`📏`,textClass:`text-metric-distance`,bgClass:`bg-metric-distance/10`,borderClass:`border-metric-distance/30`},[J.Resistance]:{label:`Weight`,icon:`⚖`,textClass:`text-metric-resistance`,bgClass:`bg-metric-resistance/10`,borderClass:`border-metric-resistance/30`},[J.Equipment]:{label:`Equipment`,icon:`🧰`,textClass:`text-foreground`,bgClass:`bg-muted/40`,borderClass:`border-border/50`},[J.Action]:{label:`Action`,icon:`⚡`,textClass:`text-metric-action`,bgClass:`bg-metric-action/10`,borderClass:`border-metric-action/30`},[J.Label]:{label:`Label`,icon:`🏷`,textClass:`text-muted-foreground`,bgClass:`bg-muted/30`,borderClass:`border-border/40`}},lJ={[J.Rep]:`reps`,[J.Effort]:`movement`,[J.Resistance]:`weight`},uJ=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=cJ[e.type],a=e.type===J.Hint,o=e.image??(e.value===void 0?``:String(e.value)),s=i?.label??String(e.type);return(0,G.jsxs)(`span`,{title:t,onClick:r,className:K(`inline-flex items-center gap-1 px-2 py-0.5 rounded border text-[11px] font-medium`,`pointer-events-auto transition-opacity hover:opacity-80`,i?.bgClass??`bg-muted/30`,i?.textClass??`text-muted-foreground`,i?.borderClass??`border-border/40`,r&&`cursor-pointer`,n&&`font-bold shadow-sm`),children:[(0,G.jsx)(`span`,{children:a?e.icon:i?.icon??`•`}),!a&&(0,G.jsx)(`span`,{children:s}),!a&&o&&(0,G.jsx)(`span`,{className:`font-semibold`,children:o})]})};function dJ(e){let t=la(e.metadata);return{refs:t?.refs??[],diagnostics:t?.diagnostics??[]}}function fJ(e,t){try{let n=e.coordsAtPos(t);if(!n)return null;let r=e.dom?.getBoundingClientRect?.()??{top:0,left:0},i=e.contentDOM?.getBoundingClientRect?.()??{left:0,width:0};return{top:n.bottom-r.top,left:i.left-r.left,width:i.width}}catch{return null}}var pJ=({view:e,cursorVersion:t,getCursorFocusState:n})=>{let[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),s=(0,W.useRef)(null),c=(0,W.useCallback)(()=>{if(!e){o(null),i(null);return}let t=(n??$W)(e.state);o(t),i(t?fJ(e,t.lineFrom):null)},[e,n]);if((0,W.useEffect)(()=>{c()},[c,t]),(0,W.useEffect)(()=>{if(!e)return;let t=()=>c();return window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t,!0),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t,!0)}},[e,c]),!r||!a?.section)return null;let l=a.allStatements?.filter(e=>e.meta?.line===a.cursorLine-a.section.startLine)??(a.statement?[a.statement]:[]),u=l.flatMap(e=>e.metrics.toArray()).filter(e=>e.type!==J.Sound&&e.type!==J.System&&!(e.type===J.Hint&&!e.icon)),d=sV(u,`runtime-badge`),f=l.flatMap(e=>e.metrics.toArray()),p=[],m=[],h=[];for(let e of f){let t=dJ(e);for(let e of t.refs){let t=`${e.kind}:${e.slug}`;p.includes(t)||(p.push(t),m.push(e))}h.push(...t.diagnostics)}let g=typeof e?.state?.facet==`function`?e.state.facet(_w)?.()??null:null,_=typeof e?.state?.doc?.sliceString==`function`?UW(e.state.doc.sliceString(a.lineFrom,a.lineTo)):null,v=e=>e.reason===`conflict`||e.reason.endsWith(`equipment`)||e.reason===`invalid-explicit`&&e.token&&_?.equipment.includes(e.token)?`equipment`:`effort`,y=e=>typeof e==`string`&&e.trim()?e:null,b=async t=>{if(!e)return;let n=e.state.doc.sliceString(a.lineFrom,a.lineTo),r=hz.getState();if(t===`effort`){let t=await r.open({placeholder:`Change effort…`,sources:[VW(`effort`)]});if(t.dismissed)return;let i=y(t.item.payload);if(!i)return;e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:WW(n,{effort:i})}});return}let i=[..._?.equipment??[]];for(;;){let e=await r.open({placeholder:i.length>0?`Add equipment (Esc to finish)…`:`Set equipment…`,sources:[VW(`equipment`)]});if(e.dismissed)break;let t=y(e.item.payload);t&&!i.includes(t)&&i.push(t)}((_?.jsonFrom??-1)>=0||i.length>0)&&e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:WW(n,{equipment:i})}})},x=async()=>{if(!e)return;let t=e.state.doc.sliceString(a.lineFrom,a.lineTo),n=hz.getState(),r,i=await n.open({placeholder:`Add effort (Esc to skip)…`,sources:[VW(`effort`)]});i.dismissed||(r=y(i.item.payload)??void 0);let o=[];for(;;){let e=await n.open({placeholder:`Add equipment (Esc to finish)…`,sources:[VW(`equipment`)]});if(e.dismissed)break;let t=y(e.item.payload);t&&!o.includes(t)&&o.push(t)}!r&&o.length===0||e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:WW(t,{effort:r,equipment:o})}})},S=async t=>{if(!e||!t.token)return;let n=v(t),r=await hz.getState().open({placeholder:`Replace “${t.token}”…`,sources:[VW(n,t.candidates)]});if(r.dismissed)return;let i=y(r.item.payload);if(!i)return;let o=e.state.doc.sliceString(a.lineFrom,a.lineTo).indexOf(t.token);o<0||e.dispatch({changes:{from:a.lineFrom+o,to:a.lineFrom+o+t.token.length,insert:i}})},C=t=>{let n=lJ[t.type];if(!n||!e)return;let r=t.type===J.Effort?`effort`:t.type===J.Equipment?`equipment`:null;if(r&&_?.jsonFrom!==void 0&&_.jsonFrom>=0){b(r);return}an(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-XSY8fWC7.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:t})=>{t(a,e,n)})};return(0,G.jsxs)(`div`,{ref:s,className:K(`cm-metric-inline-panel`,`absolute z-50 pointer-events-none`,`flex items-center gap-2 px-3 h-[28px]`,`bg-background/90 backdrop-blur-sm`,`border-l border-r border-border/50`,`transition-opacity duration-100`),style:{top:r.top,left:r.left,width:r.width,maxWidth:r.width},"aria-live":`polite`,"aria-label":`Metric inline panel`,children:[u.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-medium shrink-0 select-none`,children:`Metrics:`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[u.map((e,t)=>(0,G.jsx)(uJ,{metric:e,tooltip:e.type===J.Hint?String(e.value??``):d[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:lJ[e.type]?()=>C(e):void 0},`${e.type}-${t}`)),m.map(e=>(0,G.jsxs)(`span`,{title:`${e.kind===`effort`?`Effort`:`Equipment`} · click to change source`,onClick:()=>void b(e.kind),className:`pointer-events-auto inline-flex items-center gap-1 px-2 py-0.5 rounded border text-[11px] font-medium cursor-pointer hover:opacity-80 bg-muted/40 text-foreground border-border/50`,children:[(0,G.jsx)(`span`,{children:e.kind===`effort`?`🏋`:`🧰`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:e.label}),g&&(0,G.jsx)(`a`,{href:g.openHref(e.kind,e.slug),title:`Open ${e.label} page`,"aria-label":`Open ${e.label} page`,className:`text-muted-foreground/70 hover:text-foreground`,onClick:e=>e.stopPropagation(),children:`↗`})]},`${e.kind}:${e.slug}`)),_?.malformed&&(0,G.jsxs)(`span`,{"data-testid":`editor-ref-unknown`,title:`Reference JSON on this line does not parse — fix it in the raw text.`,className:`pointer-events-auto inline-flex items-center gap-1.5 px-2 py-0.5 rounded border text-[11px] font-medium bg-destructive/10 text-destructive border-destructive/30`,children:[(0,G.jsx)(`span`,{children:`⚠`}),(0,G.jsx)(`span`,{children:`Malformed reference JSON`})]}),h.map((e,t)=>{let n=v(e);return(0,G.jsxs)(`span`,{"data-testid":`editor-ref-unknown`,title:e.message,className:`pointer-events-auto inline-flex items-center gap-1.5 px-2 py-0.5 rounded border text-[11px] font-medium bg-destructive/10 text-destructive border-destructive/30`,children:[(0,G.jsx)(`span`,{children:`⚠`}),(0,G.jsx)(`span`,{children:e.token??e.reason}),(0,G.jsx)(`button`,{type:`button`,className:`underline cursor-pointer`,onClick:()=>void S(e),children:`Select existing`}),g&&(0,G.jsx)(`a`,{href:g.createHref(n),className:`underline hover:text-foreground`,children:`Create page`})]},`${e.reason}-${t}`)}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-add-metric-line`,title:`Add effort/equipment reference to this line`,onClick:()=>void x(),className:`pointer-events-auto inline-flex items-center px-1.5 py-0.5 rounded border border-dashed border-border/60 text-[10px] text-muted-foreground hover:text-foreground hover:border-primary/50 cursor-pointer`,children:`+ Metric`})]})]}):(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 italic select-none`,children:`No metrics on this line`}),(0,G.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground/40 shrink-0 select-none`,children:`Ctrl+↑↓ · adjust value`})]})},mJ=new si,hJ=new si,gJ=new si;async function _J(e){let t=new TextEncoder().encode(e);if(typeof CompressionStream<`u`)try{let e=new CompressionStream(`gzip`),n=e.writable.getWriter(),r=e.readable.getReader();n.write(t),n.close();let i=[];for(;;){let{done:e,value:t}=await r.read();if(e)break;i.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return btoa(String.fromCharCode(...o)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}catch{}return btoa(String.fromCharCode(...t)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}async function vJ(e){let t=await _J(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function yJ(e){let t=await _J(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${Ly()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var bJ=({noteId:e,noteBlocks:t,sourceRevision:n=0,onIdentityChange:r,onSaved:i,beforeRun:a,onSaveRequest:o,onCommitChange:s,value:c,onChange:l,onDocUpdate:u,onCursorPositionChange:d,onBlur:f,theme:p=`vs`,readonly:m=!1,className:h=``,onStartWorkout:g,onCompleteWorkout:_,onBlocksChange:v,onAddToPlan:y,notePersistence:b,onViewCreated:x,mode:S=`edit`,lineWrapping:w=!0,showLineNumbers:T=!0,enablePreview:E=!0,showFrontmatter:D=!0,enableLinting:O=!0,enableOverlay:k=!1,commands:A,hideDefaultCommands:j=!1,enableInlineRuntime:M=!0,extensions:N,widgetComponents:P,activeSectionId:F,scrollToSectionId:I,results:L,placeholder:R})=>{let ee=(0,W.useRef)(null),z=(0,W.useRef)(null),ne=(0,W.useRef)(null),re=(0,W.useRef)(``);(0,W.useEffect)(()=>{let e=async e=>{if(e.view!==z.current||!xJ(e.state,e.pos))return null;let t=e.state.doc.lineAt(e.pos),n=t.text.slice(0,e.pos-t.from).match(/^([a-zA-Z][\w.-]*)$/),r=SJ(e.state,e.pos);if(!n&&!r)return null;let[i,a]=await Promise.all([Z.getAllTagTypes().catch(()=>[]),Z.getAllTags().catch(()=>[])]);if(n)return{from:t.from,options:i.map(e=>({label:e.name,detail:`Tag Type (${e.label})`,type:`property`,apply:`${e.name}:\n - `})),validFor:(e,t,n,r)=>/^[a-zA-Z][\w.-]*$/.test(e)&&xJ(r,n)};if(!r)return null;let{propertyKey:o,from:s}=r,c={"metrics.effort":`effort`,"metrics.equipment":`equipment`,equipment:`equipment`}[o.toLowerCase()];if(c){let e=await zW();return{from:s,options:(c===`effort`?e.efforts:e.equipment).map(e=>({label:`${e.label} (${e.slug})`,detail:c===`effort`?`Effort`:`Equipment`,type:`constant`,apply:e.slug})),validFor:(e,t,n,r)=>{let i=SJ(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}}let l=i.find(e=>e.name.toLowerCase()===o.toLowerCase());if(!l)return null;let u=a.filter(e=>e.type?.toLowerCase()===l.name.toLowerCase());return u.length===0?null:{from:s,options:u.map(e=>({label:e.label,detail:l.label,type:`constant`})),validFor:(e,t,n,r)=>{let i=SJ(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}};return $C(e),()=>{ew(e)}},[]);let ie=p===`dark`||p===`vs-dark`,ae=GW(ne,b),[oe,B]=(0,W.useState)(null),[se,V]=(0,W.useState)([]),[ce,le]=(0,W.useState)(1),[ue,de]=(0,W.useState)(0),fe=F??oe,pe=uG(se,fe),[me,he]=(0,W.useState)(null),[ge,_e]=(0,W.useState)(null),[ve,ye]=(0,W.useState)(null),[be,xe]=(0,W.useState)(!1),Se=(0,W.useRef)(null),Ce=(0,W.useRef)(!1),we=(0,W.useRef)(n??0);(0,W.useEffect)(()=>{we.current=n??0},[n]);let[Te,Ee]=(0,W.useState)(null),De=(0,W.useRef)(null),Oe=(0,W.useCallback)(async(t,n=!1)=>{let r=z.current;if(!(!r||Ce.current)){Ce.current=!0,Ee(null);try{let o=await a?.();typeof o==`number`&&(we.current=o);let s=r.state.field(zC),c=await bF({noteId:e??C(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:we.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,C(),e?void 0:`playground`,ae);Se.current=c,De.current=null,we.current=c.note.sourceRevision,r.dispatch({effects:jC.of({blocks:c.note.blocks,sourceRevision:c.note.sourceRevision})}),i?.({rawContent:c.note.rawContent,blocks:c.note.blocks,sourceRevision:c.note.sourceRevision}),xe(n),_e(c.block),ye(c.session.id)}catch(e){Ee(e instanceof Error?e.message:String(e))}finally{Ce.current=!1}}},[e,ae,i,a]),ke=(0,W.useCallback)(()=>{_e(null),ye(null),xe(!1)},[]),Ae=(0,W.useCallback)(e=>{M&&Oe(e,!0)},[M,Oe]),je=(0,W.useRef)(null),Me=(0,W.useCallback)((e,t)=>{let n=je.current,r=n!==null&&n.results===t,i=Se.current;if(!i||!t)return Promise.reject(Error(`The saved run pin is unavailable.`));let a=i.session.id;if(De.current===a)return Promise.resolve();let o={id:i.block.id,contentId:i.session.blockContentId};if(!r&&t&&z.current){let t=z.current,n=PT(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Cr.scrollIntoView(e,{y:`start`,yMargin:96})]}),l?.(t.state.doc.toString())}}r||(je.current={results:t,resultId:a,runBlock:o});let s;try{s=JH(ae).record({resultId:a,noteId:i.session.noteId,blockId:i.session.blockId,data:t,createdAt:t.endTime}).then(()=>_?.(e,t,a,o))}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}return Promise.resolve(s).then(()=>{je.current?.results===t&&(je.current=null),De.current=a},()=>{}),s},[l,_,ae]),Ne=(0,W.useMemo)(()=>{if(j)return[];if(A&&A.length>0)return A;let e=[];return M?e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(un,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:Oe}):g&&e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(un,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:g}),e.push({id:`playground`,label:`Playground`,icon:(0,G.jsx)(Ke,{className:`h-3 w-3`}),splitIcon:(0,G.jsx)(te,{className:`h-3 w-3`}),splitSuccessIcon:(0,G.jsx)(sn,{className:`h-3 w-3`}),onClick:e=>{vJ(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await yJ(e.content);await navigator.clipboard.writeText(t)}}),y&&e.push({id:`plan`,label:`Plan`,icon:(0,G.jsx)(wn,{className:`h-3 w-3`}),onClick:y}),e},[A,g,y,M,j,Oe]),Pe=(0,W.useMemo)(()=>fi({codeLanguages:qW}),[]),Fe=(0,W.useMemo)(()=>[...T?[Yr(),zr()]:[],Vr(),ui(),Er(),di(),...w?[Cr.lineWrapping]:[],ei.allowMultipleSelections.of(!0),wr(),Si(),Br(),gi(),li.highest(gr.of([{key:`Tab`,run:e=>Fr(e.state)!==null&&(Ci(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=SJ(e.state,t.head),r=e.state.doc.lineAt(t.head);return!t.empty||n?.value.trim()!==``||r.text.slice(t.head-r.from).trim()?!1:(vr(e),Zr(e))}}])),gr.of([...Pr,...Xr,...oi,...ai,...xi,...ci,Qr,{key:`Mod-s`,run:()=>(o?.(),!0)},{key:`Ctrl-.`,run:e=>{let t=$W(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(an(()=>Promise.resolve().then(()=>mz).then(()=>{an(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-XSY8fWC7.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{hz.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),BT,zC,OC.of({blocks:t??Oa(c,{sourceRevision:Math.max(1,n),registeredWidgets:P?[...P.keys()]:Sa}),sourceRevision:Math.max(1,n),rawContent:c}),kC.of(P?[...P.keys()]:Sa),BC,yw.of(D),...E||!D?[Kw]:[],...E?[fw,hw,jW(),RW(),lT,rT(),bT]:[],...O?[GC]:[],tw,ZC,XC,...k?[VT]:[],rw,DC,nG,...ET,CC,...P&&P.size>0?[yE(P)]:[],YT({executor:eI,onResultSaved:KH,readOnly:m,noteHref:e=>Yz(`blockContentId`in e||`dataType`in e?yI(e):pI(e))}),KW(e,ae),Cr.domEventHandlers({blur:()=>(f?.(),!1)}),Cr.updateListener.of(e=>{if(e.docChanged){let t=e.state.field(zC);r?.({rawContent:t.rawContent,blocks:t.noteBlocks,sourceRevision:t.sourceRevision}),l(t.rawContent),u?.(e),wJ(e.state,v,re),e.transactions.some(e=>e.isUserEvent(`input`)||e.isUserEvent(`delete`)||e.isUserEvent(`paste`)||e.isUserEvent(`drop`))||s?.()}if(e.selectionSet||e.docChanged){de(e=>e+1),e.transactions.some(e=>e.isUserEvent(`delete.backward`))&&Fr(e.startState)!==null&&Fr(e.state)===null&&SJ(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&ti(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);d?.(n.number,t-n.from+1);let r=HC(e.state);B(r?.id??null),le(n.number);let{sections:i}=e.state.field(zC);V(i)}}),ei.readOnly.of(m),Cr.editable.of(!m),...R?[_i(R)]:[]],[l,d,f,u,v,r,m,o,s,T,w,E,D,O,k,e,ae,P,R]);return(0,W.useEffect)(()=>{let e=ee.current;if(!e)return;let t=ei.create({doc:c,extensions:[...Fe,mJ.of(SC(ie)),hJ.of(Pe),gJ.of([]),...N??[]]}),n=new Cr({state:t,parent:e}),i=window.visualViewport,a=0,o=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>{n.hasFocus&&i?.scale===1&&i.height<window.innerHeight&&n.dispatch({effects:Cr.scrollIntoView(n.state.selection.main.head,{y:`nearest`,yMargin:24})})})};i?.addEventListener(`resize`,o),n.contentDOM.addEventListener(`focus`,o),z.current=n,he(n),e.__codemirrorView=n,x?.(n);let{sections:s}=n.state.field(zC);V(s);let l=n.state.doc.lineAt(n.state.selection.main.head).number;le(l);let u=HC(n.state);B(u?.id??null);let d=n.state.field(zC);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),wJ(n.state,v,re),()=>{cancelAnimationFrame(a),i?.removeEventListener(`resize`,o),n.contentDOM.removeEventListener(`focus`,o),delete e.__codemirrorView,he(null),n.destroy()}},[]),(0,W.useEffect)(()=>{let e=z.current;if(!e)return;let r=e.state.field(zC);c===r.rawContent?t&&n!==r.sourceRevision&&e.dispatch({effects:jC.of({blocks:t,sourceRevision:n})}):e.dispatch({changes:{from:0,to:e.state.doc.length,insert:c},...t?{effects:MC.of({rawContent:c,blocks:t,sourceRevision:n})}:{}})},[c,t,n]),(0,W.useEffect)(()=>{z.current&&z.current.dispatch({effects:mJ.reconfigure(SC(ie))})},[ie]),(0,W.useEffect)(()=>{if(z.current){let e=[];z.current.dispatch({effects:[qr.reconfigure.of([...Fe,mJ.of(SC(ie)),hJ.of(Pe),gJ.of(e),...N??[]])]})}},[Fe,N,S,ie,Pe]),(0,W.useEffect)(()=>{m||z.current?.focus()},[m]),(0,W.useEffect)(()=>{if(I&&z.current){let e=z.current,t=e.state.doc.toString().split(`
|
|
160
160
|
`),n=-1,r=I.match(/-line-(\d+)$/);if(n=r?parseInt(r[1],10)-1:t.findIndex(e=>{let t=e.match(/^(#{1,6})\s+(.*)$/);if(t){let e=t[2].trim(),n=e.match(/(\d{1,2}:\d{2})/);if(n){let t=n[1];e=e.replace(t,``).replace(/\s+/g,` `).trim(),e||=t}return e.toLowerCase().replace(/[^\w]+/g,`-`)===I}return!1}),n>=0&&n<t.length){let t=e.state.doc.line(n+1).from;e.dispatch({selection:{anchor:t,head:t},effects:[Cr.scrollIntoView(t,{y:`start`,yMargin:20})]})}}},[I]),(0,G.jsxs)(`div`,{ref:ee,className:`cm-note-editor relative w-full min-w-0 ${h}`,children:[k&&(0,G.jsx)(aG,{view:me??z.current,widths:pe.widths,activeSectionId:fe,renderSlot:t=>{if(!D&&t.sectionType===`frontmatter`)return null;if(t.sectionType===`time`||t.sectionType===`log`)return(0,G.jsx)(PG,{noteId:e,sectionId:t.sectionId,view:t.view,isActive:t.isActive,widthPercent:t.widthPercent,cursorLine:ce,docVersion:t.docVersion,commands:Ne,extendedResults:L,hoverLine:t.hoverLine,stickyTopOffset:t.stickyTopOffset,isPanelHovered:t.isPanelHovered,lineDocY:t.lineDocY,rect:t.rect});if(t.sectionType===`frontmatter`||t.sectionType===`embed`){let{sections:e}=t.view.state.field(zC),n=e.find(e=>e.id===t.sectionId);return(0,G.jsx)(mG,{sectionId:t.sectionId,section:n,view:t.view,isActive:t.isActive,widthPercent:t.widthPercent,docVersion:t.docVersion})}return t.sectionType===`widget`&&t.widgetName?(0,G.jsx)(FG,{sectionId:t.sectionId,widgetName:t.widgetName,view:t.view,registry:P??new Map,docVersion:t.docVersion}):(0,G.jsx)(`div`,{className:`h-full w-full bg-popover/80 backdrop-blur-sm border-l border-border rounded-l-md p-2 text-xs text-muted-foreground`,children:(0,G.jsx)(`div`,{className:`font-medium text-foreground`,children:t.sectionType})})},cursorLine:ce}),Te&&(0,G.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Workout not started. `,Te,` Your draft is kept.`]}),!k&&Ne.length>0&&(0,G.jsx)(oJ,{view:me??z.current,commands:Ne}),(0,G.jsx)(pJ,{view:me??z.current,cursorVersion:ue}),ge&&z.current&&(0,G.jsx)($q,{block:ge,view:me??z.current,onClose:ke,onCompleteWorkout:Me,resultId:ve??void 0,autoStart:be}),(0,G.jsx)(sJ,{sections:se,isRuntimeActive:ge!==null,editorState:(me??z.current)?.state??null,onSelectBlock:Ae})]})};function xJ(e,t){let n=e.doc.lineAt(t);if(n.number===1||e.doc.line(1).text.trim()!==`---`)return!1;for(let t=2;t<=n.number;t++)if(/^(---|\.\.\.)\s*$/.test(e.doc.line(t).text))return!1;return!0}function SJ(e,t){if(!xJ(e,t))return null;let n=e.doc.lineAt(t),r=n.text.slice(0,t-n.from),i=r.match(/^([a-zA-Z][\w.-]*)\s*:\s*(.*)$/);if(i)return{propertyKey:i[1],from:t-i[2].length,value:i[2]};let a=r.match(/^\s*-\s*(.*)$/);if(!a)return null;for(let r=n.number-1;r>1;r--){let n=e.doc.line(r).text.match(/^([a-zA-Z][\w.-]*)\s*:/);if(n)return{propertyKey:n[1],from:t-a[1].length,value:a[1]}}return null}function CJ(e,t){if(e.type!==`time`&&e.type!==`log`)return null;let n=e.contentFrom!==void 0&&e.contentTo!==void 0?t.doc.sliceString(e.contentFrom,e.contentTo):``,r=[];try{n.trim()&&(r=Ps().read(n,e.sport).statements??[])}catch{}return{id:e.id,contentId:e.contentId,dialect:e.type,sport:e.sport,startLine:e.startLine-1,endLine:e.endLine-1,content:n,statements:r,state:`idle`,version:t.field(zC).noteBlocks[e.id]?.version??1,createdAt:Date.now(),widgetIds:{}}}function wJ(e,t,n){if(!t)return;let r=e.field(zC).sections.filter(e=>e.type===`time`||e.type===`log`).map(t=>CJ(t,e)).filter(e=>e!==null),i=JSON.stringify(r.map(e=>({id:e.id,startLine:e.startLine,endLine:e.endLine,content:e.content})));i!==n.current&&(n.current=i,t(r))}function TJ({title:e,subtitle:t,doc:n,onDocChange:r,noteId:i,onBlocksChange:a,theme:o,readonly:s=!1,showLineNumbers:c=!1,enableOverlay:l=!1,enableInlineRuntime:u=!1,enablePreview:d=!0,showFrontmatter:f=!1,enableLinting:p=!0,commands:m,hideDefaultCommands:h,onViewCreated:g,onReset:_,run:v,headerActions:y,subheader:b,children:x,className:S,editorClassName:C,bodyRef:w}){let T=(0,W.useRef)([]),E=(0,W.useCallback)(e=>{T.current=e,a?.(e)},[a]),D=(0,W.useCallback)(()=>{v?.onRun(n,T.current[0]??null)},[v,n]),O=(0,G.jsxs)(G.Fragment,{children:[y,v&&(0,G.jsxs)(`button`,{ref:v.ref,type:`button`,title:v.title??`Run the workout`,onClick:D,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground transition-colors hover:bg-primary/90`,children:[(0,G.jsx)(un,{size:11,fill:`currentColor`}),v.label??`Run`]})]});return(0,G.jsx)(AW,{title:e,subtitle:t,onReset:_,headerActions:O,className:S,children:(0,G.jsxs)(`div`,{className:`flex h-full flex-col min-h-0`,children:[b,(0,G.jsxs)(`div`,{ref:w,className:K(`relative flex-1 min-h-0`,C),children:[(0,G.jsx)(bJ,{noteId:i,value:n,onChange:r,onBlocksChange:E,theme:o,readonly:s,showLineNumbers:c,enableOverlay:l,enableInlineRuntime:u,enablePreview:d,showFrontmatter:f,enableLinting:p,commands:m,hideDefaultCommands:h,onViewCreated:g,className:`h-full`}),x]})]})})}function EJ({editorSource:e,editorOpacity:t,activeOriginalSource:n,handleEditorChange:r,onResetToSource:i,canvasNoteId:a,theme:o,commands:s,onBlocksChange:c,onViewCreated:l,panelTitle:u,panelSubtitle:d,panelThemeClass:f,headerActions:p,onRun:m,readonly:h=!1,showFrontmatter:g}){return(0,G.jsx)(`div`,{className:`h-full`,style:{opacity:t,transition:`opacity 180ms ease`},children:(0,G.jsx)(TJ,{title:u,subtitle:d,doc:e,onDocChange:r,noteId:a,onBlocksChange:c,onViewCreated:l,theme:o,readonly:h,showLineNumbers:!1,showFrontmatter:g,enableOverlay:!1,enableInlineRuntime:!1,commands:s,hideDefaultCommands:!1,headerActions:p,className:f,subheader:(0,G.jsxs)(`div`,{style:{opacity:t,transition:`opacity 180ms ease`},className:`flex items-center justify-between gap-3 border-b border-border/40 bg-primary/5 px-4 py-2 text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:`Try editing this example ↓`}),e===n?null:(0,G.jsx)(`button`,{type:`button`,onClick:()=>{i()},className:`rounded-full border border-primary/30 px-3 py-1 text-[10px] font-black text-primary transition-colors hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:`Reset to example`})]}),run:m?{onRun:m}:void 0})})}function DJ(e,t){return e>=t?`split`:`stack`}function OJ(e,t){let n=(0,W.useCallback)(()=>{if(typeof window>`u`)return{width:0,height:0,mode:`stack`};let t=window.innerWidth,n=Math.max(0,window.innerHeight-e);return{width:t,height:n,mode:DJ(t,n)}},[e]),[r,i]=(0,W.useState)(n);return(0,W.useEffect)(()=>{if(t&&typeof ResizeObserver<`u`){let e=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect;i(e=>e.width===t&&e.height===n?e:{width:t,height:n,mode:DJ(t,n)})});return e.observe(t),()=>e.disconnect()}let e=()=>i(e=>{let t=n();return e.width===t.width&&e.height===t.height?e:t});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[t,n]),r}var kJ=e=>Math.max(0,Math.min(1,e)),AJ=(e,t,n)=>e+(t-e)*n,jJ=e=>1-(1-e)**2;function MJ(e,t){return e===``||t===e}var NJ={id:``,range:[0,1]};function PJ(e,t){if(!t||t.length===0)return{index:-1,stage:NJ,t:0,ring:null};let n=kJ(e),r=t.map(e=>({...e,start:kJ(Math.min(e.range[0],e.range[1])),end:kJ(Math.max(e.range[0],e.range[1]))})),i=r.findIndex(e=>n>=e.start&&n<e.end);i===-1&&(i=n>=1?r.length-1:0);let a=r[i]??NJ,o=(a.end??1)-(a.start??0),s=o>0?kJ((n-(a.start??0))/o):0,c=a.ring?{tag:a.ring===!0?void 0:a.ring.tag,key:a.ring===!0?void 0:a.ring.key,lines:a.ring===!0?void 0:a.ring.lines}:null;return{index:i,stage:a,t:s,ring:c}}function FJ(e,t,n){let r=t-n;return{progress:r>0?kJ(-e/r):0,reached:e<=0,inView:e<n&&e+t>0}}function IJ(e,t){let n=t/2;for(let t of e)if(t.top<=n&&t.bottom>n)return t.id;return null}var LJ=(0,W.createContext)(null);function RJ(){return(0,W.useContext)(LJ)}function zJ({children:e}){let t=(0,W.useRef)(new Map),n=(0,W.useRef)(new Map),r=(0,W.useRef)(null),i=(0,W.useRef)(0),[a,o]=(0,W.useState)(null),s=(0,W.useRef)(null),c=(0,W.useCallback)(e=>{r.current?.gateId===e&&(r.current=null,o(null))},[]),l=(0,W.useCallback)((e,t)=>{r.current={gateId:e,segmentId:t},o(e)},[]),u=(0,W.useCallback)(()=>{i.current&&cancelAnimationFrame(i.current),i.current=0;let e=window.innerHeight,a=new Map,c=(e,t)=>{let n=t();n&&a.set(e,n.getBoundingClientRect())};t.current.forEach((e,t)=>c(t,e)),n.current.forEach((e,t)=>c(t,e.getEl));let l=[];a.forEach((e,t)=>l.push({id:t,top:e.top,bottom:e.top+e.height}));let u=IJ(l,e);if(u!==s.current){s.current=u;let e=r.current;e&&e.segmentId!==u&&(r.current=null,o(null))}n.current.forEach((t,n)=>{let r=a.get(n);if(!r||r.height-e<=0)return;let i=FJ(r.top,r.height,e);t.onMeasure({slice:PJ(i.progress,t.getStages()),progress:i.progress,reached:i.reached})})},[]),d=(0,W.useCallback)(()=>{i.current||=requestAnimationFrame(u)},[u]);(0,W.useEffect)(()=>(window.addEventListener(`scroll`,d,{passive:!0,capture:!0}),window.addEventListener(`resize`,d),u(),()=>{window.removeEventListener(`scroll`,d,{capture:!0}),window.removeEventListener(`resize`,d),i.current&&cancelAnimationFrame(i.current)}),[d,u]);let f=(0,W.useCallback)((e,n)=>(t.current.set(e,n),d(),()=>{t.current.delete(e)}),[d]),p=(0,W.useCallback)((e,t)=>(n.current.set(e,t),d(),()=>{n.current.delete(e)}),[d]),m=(0,W.useCallback)(()=>u(),[u]),h=(0,W.useMemo)(()=>({registerAnchor:f,registerDriver:p,resync:m,capturedGateId:a,captureGate:l,releaseGate:c}),[f,p,m,a,l,c]);return(0,G.jsx)(LJ.Provider,{value:h,children:e})}function BJ(e,t){let n=RJ()?.registerAnchor;(0,W.useEffect)(()=>{if(n)return n(e,()=>t.current)},[n,e,t])}function VJ({gateId:e,segmentId:t,className:n,children:r}){let i=RJ(),a=(0,W.useRef)(null),[o,s]=(0,W.useState)(!1);if((0,W.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=e.querySelectorAll(`.cm-scroller, [data-scroll-pane], .overflow-auto, .overflow-y-auto`);s(e.scrollHeight>e.clientHeight+1||[...t].some(e=>e.scrollHeight>e.clientHeight+1))},n=new ResizeObserver(t);n.observe(e);let r=0,i=new MutationObserver(()=>{t(),window.clearTimeout(r),r=window.setTimeout(t,400)});i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`resize`,t);let o=window.setTimeout(t,1200);return t(),()=>{window.clearTimeout(r),window.clearTimeout(o),n.disconnect(),i.disconnect(),window.removeEventListener(`resize`,t)}},[]),!i)return(0,G.jsx)(`div`,{className:n,children:r});let c=i.capturedGateId===e?`captured`:`yield`;return(0,G.jsxs)(`div`,{"data-scroll-gate":c,"data-gate-id":e,className:`${n??``} flex flex-col`,onFocus:n=>{let r=n.target;r instanceof HTMLElement&&r.closest(`input:not([readonly]):not([disabled]), textarea:not([readonly]):not([disabled]), select:not([disabled]), [contenteditable="true"]`)&&i.captureGate(e,t??null)},onBlur:t=>{(!(t.relatedTarget instanceof Node)||!t.currentTarget.contains(t.relatedTarget))&&i.releaseGate(e)},children:[(0,G.jsx)(`div`,{ref:a,className:`relative min-h-0 flex-1`,children:r}),(o||c===`captured`)&&(0,G.jsx)(`button`,{type:`button`,className:`min-h-11 self-start rounded px-3 py-2 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-primary`,"aria-label":`Scroll ${e.replace(/-/g,` `)} content`,"aria-pressed":c===`captured`,onClick:()=>c===`captured`?i.releaseGate(e):i.captureGate(e,t??null),onKeyDown:t=>{t.key===`Escape`&&i.releaseGate(e)},children:c===`captured`?`Scroll page`:`Scroll panel`})]})}function HJ({trackRef:e,height:t,stages:n,activeIndex:r,pane:i,captions:a,status:o,segmentId:s,testId:c,className:l}){let[u,d]=(0,W.useState)(null),f=OJ(104,u).mode===`split`,p={status:o,pips:(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:n.map((e,t)=>{let n=r===t;return(0,G.jsx)(`span`,{className:`h-1 rounded-full transition-all duration-300`,style:{width:n?30:10,background:n?e.accent??`hsl(var(--primary))`:r>t?`hsl(var(--foreground))`:`hsl(var(--foreground) / 0.15)`}},e.id)})})};return(0,G.jsx)(`section`,{ref:e,"data-testid":c,className:l?`relative ${l}`:`relative`,style:{height:t},children:(0,G.jsx)(OW.Provider,{value:p,children:(0,G.jsx)(`div`,{className:`sticky top-[65px] flex h-[calc(100dvh-65px)] flex-col overflow-hidden lg:top-[104px] lg:h-[calc(100dvh-104px)]`,children:(0,G.jsxs)(`div`,{ref:d,className:`mx-auto flex min-h-0 w-full max-w-[1500px] 2xl:max-w-[1720px] flex-1 px-5 pt-2 pb-5 lg:px-10 lg:pt-3 xl:px-16 xl:pb-8 2xl:pb-10 ${f?`flex-row items-stretch gap-[clamp(20px,2.5vw,56px)] xl:gap-12 2xl:gap-16`:`flex-col gap-6 xl:gap-8`}`,children:[(0,G.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-[3_1_0%]`,children:i}),(0,G.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-[2_1_0%] flex-col`,children:s?(0,G.jsx)(VJ,{gateId:`${s}-captions`,segmentId:s,className:`relative min-h-0 flex-1`,children:a}):(0,G.jsx)(`div`,{className:`relative min-h-0 flex-1`,children:a})})]})})})})}function UJ(e){let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return window}function WJ(e,t,n=`smooth`){let r=UJ(e),i=e.offsetHeight-window.innerHeight;if(i<=0)return;if(r instanceof HTMLElement){let a=e.offsetTop;r.scrollTo({top:a+t*i,behavior:n});return}let a=e.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:a+t*i,behavior:n})}function GJ(e,t,n,r){let[i,a]=(0,W.useState)(()=>PJ(0,n)),[o,s]=(0,W.useState)(!1),c=(0,W.useRef)(0),l=(0,W.useRef)(i),u=(0,W.useRef)(new Set),d=(0,W.useRef)(0),f=(0,W.useRef)(t);f.current=t;let p=RJ(),m=p?.registerDriver,h=(0,W.useRef)(p);h.current=p;let g=(0,W.useId)(),_=r??g,v=(0,W.useRef)(n);v.current=n;let y=(0,W.useCallback)((e,t)=>{let n=l.current;l.current=e,c.current=t,(n.index!==e.index||n.ring?.key!==e.ring?.key)&&a(e),u.current.forEach(n=>n(e,t))},[]),b=(0,W.useCallback)(()=>{if(d.current=0,f.current)return;let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.height-window.innerHeight;if(r<=0)return;let i=Math.max(0,Math.min(1,-n.top/r));s(n.top<=0),y(PJ(i,v.current),i)},[e,y]),x=(0,W.useCallback)(()=>{if(h.current){h.current.resync();return}b()},[b]),S=(0,W.useCallback)(()=>{d.current||=requestAnimationFrame(x)},[x]);(0,W.useEffect)(()=>{if(m)return m(_,{getEl:()=>e.current,getStages:()=>v.current,onMeasure:({slice:e,progress:t,reached:n})=>{f.current||(s(n),y(e,t))}})},[m,_,e,y]),(0,W.useEffect)(()=>{if(!m)return window.addEventListener(`scroll`,S,{passive:!0,capture:!0}),window.addEventListener(`resize`,S),b(),()=>{window.removeEventListener(`scroll`,S,{capture:!0}),window.removeEventListener(`resize`,S),d.current&&cancelAnimationFrame(d.current)}},[m,S,b]);let C=(0,W.useCallback)(e=>(u.current.add(e),e(l.current,c.current),()=>{u.current.delete(e)}),[]),w=(0,W.useCallback)(()=>{x()},[x]);return{slice:i,progress:c.current,runwayReached:o,subscribe:C,resync:w}}var KJ={reference:!0},qJ={start:[[`fences`,`first-workout`],[`measurements`,`actions-comments`],[`system`,`try-it`]],protocols:[[`countdown-countup`,`required-rest`],[`amrap`,`emom`],[`tabata-intervals`,`caps`,`distance-intervals`,`try-it`]],structure:[[`rounds`,`rep-schemes`,`sets`],[`nesting`,`rep-math`,`named-sections`,`try-it`]],metrics:[[`planned-vs-recorded`,`custom-metrics`],[`capture`,`session-rpe`],[`calculated`,`try-it`]],clock:[[`run-next`,`pause-skip`],[`capture-prompts`,`casting`,`provenance`,`try-it`]],wql:[[`planes`,`aggregate`,`filters`,`sources`],[`windows`,`grouping-rollup`,`joins`],[`content`,`pipes`,`try-it`]],dashboards:[[`note-frontmatter`,`avg-tis`,`weekly-tonnage`,`widgets`],[`composer`,`cookbook`,`seeded-boards`,`try-it`]],sessions:[[`intent`,`full-session`],[`nested`,`partner`,`swimming`],[`barbell-cycling`,`climbing`,`try-it`]]};function JJ(e,t){let n=e.filter(e=>!KJ[e.id]),r=e.filter(e=>KJ[e.id]);if(n.length===0)return{groups:[],tail:r};let i=t?qJ[t]:void 0;if(i){let e=new Map(n.map(e=>[e.id,e])),t=new Set,a=[];for(let n of i){let r=n.map(t=>e.get(t)).filter(e=>!!e&&!t.has(e.id));for(let e of r)t.add(e.id);r.length>0&&a.push(r)}let o=n.filter(e=>!t.has(e.id));if(o.length>0){let e=a[a.length-1];if(e&&e.length+o.length<=4)e.push(...o);else for(let e=0;e<o.length;e+=4)a.push(o.slice(e,e+4))}if(a.length>0)return{groups:a,tail:r}}let a=Math.max(1,Math.ceil(n.length/4)),o=Math.floor(n.length/a),s=n.length%a,c=[],l=0;for(let e=0;e<a;e++){let t=o+ +(e<s);c.push(n.slice(l,l+t)),l+=t}return{groups:c,tail:r}}function YJ(e){let t=Math.max(1,e.length);return e.map((e,n)=>({id:e.id,range:[n/t,(n+1)/t]}))}var XJ=[{src:`/images/hero/editing.png`,alt:`WhiteboardScript editor with live syntax highlighting and inline previews`,eyebrow:`Write`,title:`Type your workout in plain Markdown.`,caption:"Movements, reps, time caps, and rounds — fenced in a familiar ```time block. No drag-and-drop. No proprietary DSL."},{src:`/images/hero/timer.png`,alt:`Live runtime timer HUD counting down an interval with active round and rest indicators`,eyebrow:`Run`,title:`Press Run. The compiler takes over.`,caption:`Your Markdown becomes a live wallclock. The JIT engine dispatches rounds, counts reps, and tracks rest — all offline.`},{src:`/images/hero/journal.png`,alt:`Unified Library listing journal notes, Catalog sessions, and dated posts`,eyebrow:`Library`,title:`Browse Notes, Sessions, and Posts in one Library.`,caption:`Your dated journal entries and preloaded Catalog benchmarks live in one unified surface. Search, filter by source, or clone to today’s entry.`},{src:`/images/hero/results.png`,alt:`WQL Metric Explorer displaying volume trends and embedded dashboard blocks`,eyebrow:`Query`,title:`Ask questions with Wod Query Language (WQL).`,caption:`Aggregate volume, track TIS intensity trends, or embed live query and dashboard blocks directly in your Markdown notes.`}];function ZJ({slides:e=XJ,className:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(0);(0,W.useEffect)(()=>{let t=n.current;if(!t)return;let r=()=>{let n=t.clientWidth,r=Math.round(t.scrollLeft/n);i(Math.min(Math.max(r,0),e.length-1))};return t.addEventListener(`scroll`,r,{passive:!0}),()=>t.removeEventListener(`scroll`,r)},[e.length]);let a=e=>{let t=n.current;t&&t.scrollTo({left:e*t.clientWidth,behavior:`smooth`})};return(0,G.jsxs)(`div`,{className:K(`relative w-full`,t),children:[(0,G.jsx)(`div`,{ref:n,className:`flex w-full snap-x snap-mandatory overflow-x-auto scroll-smooth scrollbar-none`,style:{scrollbarWidth:`none`},children:e.map((t,n)=>(0,G.jsxs)(`article`,{className:`relative flex w-full shrink-0 snap-start flex-col gap-4 sm:flex-row sm:items-center sm:gap-8`,"aria-label":`Slide ${n+1} of ${e.length}: ${t.title}`,children:[(0,G.jsx)(`div`,{className:`relative aspect-[16/10] w-full overflow-hidden rounded-2xl border border-border/60 bg-muted shadow-sm sm:w-1/2`,children:(0,G.jsx)(`img`,{src:t.src,alt:t.alt,loading:n===0?`eager`:`lazy`,className:`h-full w-full object-cover`})}),(0,G.jsxs)(`div`,{className:`flex w-full flex-col gap-2 sm:w-1/2 sm:gap-3`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-black uppercase tracking-[0.24em] text-primary/80`,children:t.eyebrow}),(0,G.jsx)(`h3`,{className:`text-2xl font-black tracking-[-0.04em] text-foreground sm:text-3xl`,children:t.title}),(0,G.jsx)(`p`,{className:`text-sm leading-7 text-muted-foreground sm:text-base`,children:t.caption}),(0,G.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-2 text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`text-primary`,children:[`Step `,n+1]}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,G.jsx)(`span`,{children:e.length})]})]})]},t.src))}),(0,G.jsx)(`div`,{className:`mt-4 flex items-center justify-center gap-2`,children:e.map((e,t)=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(t),"aria-label":`Go to slide ${t+1}: ${e.title}`,"aria-current":t===r?`true`:`false`,className:K(`h-2 rounded-full transition-all`,t===r?`w-8 bg-primary`:`w-2 bg-border hover:bg-muted-foreground/40`)},e.src))})]})}var QJ=`wodwiki:text-filter-navigation`,$J=({paramName:e=`q`,placeholder:t=`Search…`,autoFocus:n=!1,className:r,navigationScope:i,inputTestId:a})=>{let[o,s]=Ht(e,{defaultValue:``}),c=i??e,l=(0,W.useRef)(null);return(0,W.useEffect)(()=>{let e=e=>{e.key===`/`&&document.activeElement?.tagName!==`INPUT`&&document.activeElement?.tagName!==`TEXTAREA`&&(e.preventDefault(),l.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,G.jsxs)(`div`,{className:K(`flex items-center gap-3 px-6 lg:px-10 pb-3`,r),children:[(0,G.jsx)(Zt,{className:`size-5 text-muted-foreground shrink-0`}),(0,G.jsx)(`input`,{ref:l,type:`text`,"data-testid":a,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey||![`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Enter`].includes(e.key))return;let t=new CustomEvent(QJ,{detail:{key:e.key,scopeId:c},cancelable:!0});window.dispatchEvent(t),t.defaultPrevented&&e.preventDefault()},placeholder:t,autoFocus:n,autoComplete:`off`,spellCheck:!1,className:`flex-1 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground text-sm sm:text-base font-medium`}),o&&(0,G.jsx)(`button`,{onClick:()=>s(``),"aria-label":`Clear`,className:`text-muted-foreground hover:text-foreground transition-colors text-lg leading-none`,children:`×`})]})};function eY(e){let t=[],n=!1;for(let r of e){if(r.trim()===`---`){n=!n;continue}n||t.push(r)}return t}function tY(e){let t=e;return t=t.replace(/\*\*([^*]+)\*\*/g,`$1`),t=t.replace(/__([^_]+)__/g,`$1`),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`),t=t.replace(/\*\*/g,``),t=t.replace(/__/g,``),t=t.replace(/`/g,``),t.trim()}function nY(e){return new Date(e).toISOString().slice(0,10)}function rY(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.content.toLowerCase().includes(n)||e.date!==void 0&&nY(e.date).includes(n)}function iY(e){if(!e)return null;let t=eY(hb(e).split(`
|
|
161
161
|
`)).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`)&&!e.startsWith("```"))[0];return t?tY(t):null}var aY=({category:e,workoutItems:t,onSelect:n,showSearch:r=!0,variant:i=`card`,className:a,navigationScope:o=`q`,getItemActions:s})=>{let[c]=Ht(`q`,{defaultValue:``}),[l,u]=(0,W.useState)(0),[d,f]=(0,W.useState)(0),p=(0,W.useRef)([]),m=(0,W.useMemo)(()=>t.filter(t=>t.category===e&&t.name.toLowerCase()!==`readme`).filter(e=>rY(e,c)),[t,e,c]),h=(0,W.useMemo)(()=>m.map(e=>({item:e,preview:iY(e.content),actions:s?.(e)??[{id:`open`,label:`Open`,onSelect:n}]})),[m,s,n]);return(0,W.useEffect)(()=>{if(h.length===0){u(0),f(0);return}let e=Math.min(l,h.length-1),t=h[e]?.actions.length??1;e!==l&&u(e),d>t-1&&f(t-1)},[h,d,l]),(0,W.useEffect)(()=>{p.current=[]},[h]),(0,W.useEffect)(()=>{u(0),f(0)},[c]),(0,W.useEffect)(()=>{(p.current[l]?.[d])?.scrollIntoView({block:`nearest`,inline:`nearest`})},[d,l]),(0,W.useEffect)(()=>{let e=e=>{let t=e;if(t.detail.scopeId===o&&h.length!==0)switch(t.detail.key){case`ArrowDown`:t.preventDefault(),u(e=>Math.min(e+1,h.length-1)),f(0);break;case`ArrowUp`:t.preventDefault(),u(e=>Math.max(e-1,0)),f(0);break;case`ArrowRight`:{let e=h[l]?.actions.length??1;if(e<=1)return;t.preventDefault(),f(t=>Math.min(t+1,e-1));break}case`ArrowLeft`:if((h[l]?.actions.length??1)<=1)return;t.preventDefault(),f(e=>Math.max(e-1,0));break;case`Enter`:{let e=h[l]?.actions[d],n=h[l]?.item;if(!e||!n)return;t.preventDefault(),e.onSelect(n);break}}};return window.addEventListener(QJ,e),()=>{window.removeEventListener(QJ,e)}},[h,o,d,l]),(0,G.jsxs)(`div`,{className:K(`flex flex-col`,i===`card`&&`rounded-3xl border border-border bg-card overflow-hidden shadow-2xl shadow-black/5`,a),children:[r?(0,G.jsx)(`div`,{className:`border-b border-border/60 bg-background/95 backdrop-blur-md`,children:(0,G.jsx)($J,{placeholder:`Filter collection workouts…`,className:`pt-3`,navigationScope:o})}):null,h.length===0?(0,G.jsx)(`div`,{className:`px-6 py-10 text-sm font-medium text-muted-foreground`,children:`No workouts found.`}):(0,G.jsx)(`div`,{className:`divide-y divide-border/60`,role:`listbox`,"aria-label":`Collection workouts`,children:h.map((e,t)=>{let n=t===l;return(0,G.jsx)(`div`,{role:`option`,"aria-selected":n,className:K(`flex items-stretch gap-2 px-3 py-2 transition-colors`,n?`bg-muted/50`:`hover:bg-muted/40`),children:e.actions.map((r,i)=>{let a=i===0;return(0,G.jsx)(`button`,{ref:e=>{p.current[t]||(p.current[t]=[]),p.current[t][i]=e},onClick:()=>r.onSelect(e.item),onMouseEnter:()=>{u(t),f(i)},className:K(`transition-colors text-left`,a?`flex-1 flex items-center gap-4 rounded-2xl px-3 py-2 hover:bg-background/80`:`shrink-0 self-center rounded-full border border-border px-3 py-2 text-[11px] font-black uppercase tracking-[0.18em] text-muted-foreground hover:bg-background/80 hover:text-foreground`,n&&i===d&&`bg-background text-foreground ring-2 ring-primary/40`),children:a?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`flex-shrink-0 size-10 rounded-xl bg-muted flex items-center justify-center transition-colors`,children:(0,G.jsx)(k,{className:`size-4 text-primary`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-foreground truncate uppercase tracking-tight`,children:e.item.displayName??e.item.name}),e.preview?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium truncate mt-1`,children:e.preview}):null]}),e.item.date===void 0?null:(0,G.jsx)(`span`,{className:`shrink-0 self-center text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:qP(new Date(e.item.date))}),(0,G.jsx)(xn,{className:`size-4 text-muted-foreground shrink-0 transition-opacity`})]}):r.label},r.id)})},e.item.id)})})]})};function oY(){return(0,W.useEffect)(()=>{JF().catch(e=>console.warn(`[queryService] page source population failed`,e))},[]),(0,W.useSyncExternalStore)(ZF,XF)}function sY(e,t){let n=e.find(e=>e.key===t&&!e.negate);return n&&n.values.length===1?n.values[0].value:null}function cY(e){let t=e.trim();if(!t.startsWith(`:`))return null;let n=X(t);if(n.error||!Vp(n))return null;let r=`?q=${encodeURIComponent(t)}`;switch(n.target){case`effort`:return`/efforts${r}`;case`session`:case`segment`:case`event`:return`/sessions${r}`;case`note`:case`block`:{let e=sY(n.filters,`notebook`)??sY(n.filters,`catalog`);if(e){let t=ya(e);return t===`journal`?`/journal${r}`:t===`playground`?`/playgrounds${r}`:`/c/${encodeURIComponent(t)}${r}`}let t=sY(n.filters,`source`);return t===`journal`?`/journal${r}`:t===`playground`?`/playgrounds${r}`:t===`feeds`||t===`notebooks`||t===`notebook`||t===`guides`?`/feeds${r}`:sY(n.filters,`type`)===`dashboard`?`/dashboards${r}`:`/journal${r}`}default:return null}}var lY=new Set([`pdf`,`doc`,`docx`,`xls`,`xlsx`,`ppt`,`pptx`,`zip`,`tar`,`gz`,`rar`,`mp4`,`mov`,`avi`,`mkv`,`webm`,`mp3`,`wav`,`flac`,`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`]);function uY(e){let t=e.split(`.`).pop()?.split(`?`)[0]?.toLowerCase()??``;return lY.has(t)}function dY(e){return/^https?:\/\//.test(e)||e.startsWith(`//`)}function fY({queryText:e,widgetType:t,widgetError:n}){return oY()?(0,G.jsx)(`div`,{className:`my-5 not-prose`,children:(0,G.jsx)(gC,{query:e,widgetType:t,widgetError:n,executor:eI,readOnly:!0,noteHref:e=>Yz(`blockContentId`in e||`dataType`in e?yI(e):pI(e))})}):(0,G.jsx)(`div`,{className:`my-5 not-prose text-xs text-muted-foreground py-2`,children:`Loading…`})}function pY(e){let{meta:t,body:n}=ub(e);return Object.keys(t).length===0&&n===e?{fields:null,body:e}:{fields:t,body:n.trim()}}var mY={table({children:e}){return(0,G.jsx)(`div`,{className:`my-6 overflow-x-auto rounded-xl border border-border`,children:(0,G.jsx)(`table`,{className:`w-full text-sm border-collapse`,children:e})})},thead({children:e}){return(0,G.jsx)(`thead`,{className:`bg-muted/50 text-left`,children:e})},tbody({children:e}){return(0,G.jsx)(`tbody`,{className:`divide-y divide-border/50`,children:e})},tr({children:e}){return(0,G.jsx)(`tr`,{className:`hover:bg-muted/20 transition-colors`,children:e})},th({children:e}){return(0,G.jsx)(`th`,{className:`px-4 py-2.5 text-[11px] font-black tracking-widest uppercase text-muted-foreground border-b border-border`,children:e})},td({children:e}){return(0,G.jsx)(`td`,{className:`px-4 py-2.5 text-sm text-foreground`,children:e})},img({src:e,alt:t,node:n}){let r=n?.properties??{},i=r.width,a=r.height;return(0,G.jsxs)(`figure`,{className:`my-6`,children:[(0,G.jsx)(`img`,{src:e??``,alt:t??``,loading:`lazy`,width:i,height:a,className:`rounded-xl border border-border max-w-full h-auto`}),t&&(0,G.jsx)(`figcaption`,{className:`mt-2 text-center text-xs text-muted-foreground italic`,children:t})]})},a({href:e,children:t}){let n=e??``;if(n.startsWith(`:`)){let e=n;try{e=decodeURIComponent(n)}catch{}let r=cY(e);if(r)return(0,G.jsx)(Vn,{to:r,className:`underline underline-offset-2 transition-colors text-primary hover:text-primary/70`,children:t})}let r=dY(n),i=uY(n);return(0,G.jsxs)(`a`,{href:n,rel:r?`noopener noreferrer`:void 0,target:r||i?`_blank`:void 0,className:K(`underline underline-offset-2 transition-colors`,i?`text-primary font-medium`:`text-primary hover:text-primary/70`),children:[t,r&&(0,G.jsx)(`span`,{className:`ml-0.5 text-[10px] align-super opacity-60`,children:`↗`}),i&&!r&&(0,G.jsx)(`span`,{className:`ml-0.5 text-[10px] align-super opacity-60`,children:`⬇`})]})},code({children:e,className:t}){let n=t?.replace(`language-`,``)??``,r=typeof e==`string`?e:Array.isArray(e)?e.join(``):String(e??``);if(!t&&!r.includes(`
|
|
162
162
|
`))return(0,G.jsx)(`code`,{className:`px-1.5 py-0.5 rounded-md bg-muted font-mono text-[0.85em] text-foreground`,children:e});if(n===`query`||n.startsWith(`query:`)||n.startsWith(`query `)){let t=(typeof e==`string`?e:Array.isArray(e)?e.join(``):String(e??``)).trim(),r=n.replace(/^query[:\s]?/,``).trim(),i=r?Pg(r):void 0;return(0,G.jsx)(fY,{queryText:t,widgetType:i?.type,widgetError:i?.error})}return(0,G.jsxs)(`div`,{className:`my-5 rounded-xl overflow-hidden border border-border`,children:[n&&(0,G.jsx)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-muted border-b border-border`,children:(0,G.jsx)(`span`,{className:`text-[10px] font-black tracking-widest uppercase text-muted-foreground`,children:n})}),(0,G.jsx)(`pre`,{className:`overflow-x-auto p-4 bg-muted/30`,children:(0,G.jsx)(`code`,{className:`font-mono text-sm text-foreground`,children:e})})]})},h1({children:e,id:t}){return(0,G.jsx)(`h1`,{id:t,className:`text-2xl lg:text-3xl font-black tracking-tight text-foreground uppercase leading-tight mt-10 mb-4 first:mt-0`,children:e})},h2({children:e,id:t}){return(0,G.jsx)(`h2`,{id:t,className:`text-xl lg:text-2xl font-black tracking-tight text-foreground uppercase leading-tight mt-8 mb-3 first:mt-0`,children:e})},h3({children:e,id:t}){return(0,G.jsx)(`h3`,{id:t,className:`text-base lg:text-lg font-black tracking-wide text-foreground uppercase mt-6 mb-2 first:mt-0`,children:e})},h4({children:e,id:t}){return(0,G.jsx)(`h4`,{id:t,className:`text-sm font-black tracking-widest text-primary uppercase mt-5 mb-2 first:mt-0`,children:e})},p({children:e}){return(0,G.jsx)(`p`,{className:`text-sm lg:text-[15px] font-medium text-muted-foreground leading-relaxed my-4 first:mt-0`,children:e})},ul({children:e}){return(0,G.jsx)(`ul`,{className:`my-4 pl-5 space-y-1.5 list-disc list-outside text-left text-sm text-muted-foreground font-medium leading-relaxed`,children:e})},ol({children:e}){return(0,G.jsx)(`ol`,{className:`my-4 pl-5 space-y-1.5 list-decimal list-outside text-left text-sm text-muted-foreground font-medium leading-relaxed`,children:e})},li({children:e}){return(0,G.jsx)(`li`,{className:`leading-relaxed`,children:e})},blockquote({children:e}){return(0,G.jsx)(`blockquote`,{className:`my-5 pl-4 border-l-2 border-primary/40 text-muted-foreground italic text-sm`,children:e})},hr(){return(0,G.jsx)(`hr`,{className:`my-8 border-border/50`})},strong({children:e}){return(0,G.jsx)(`strong`,{className:`font-black text-foreground`,children:e})},em({children:e}){return(0,G.jsx)(`em`,{className:`italic text-foreground/80`,children:e})}},hY={...mY,p({children:e}){return(0,G.jsx)(`p`,{className:`text-3xl sm:text-4xl lg:text-5xl font-black tracking-tight text-foreground leading-[1.08] my-0`,children:e})},strong({children:e}){let t=W.Children.toArray(e).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``).trim();return t.includes(`Write it in Markdown`)&&t.includes(`Run it as a Timer`)&&t.includes(`Own the Analytics`)?(0,G.jsxs)(`span`,{className:`flex flex-col select-none mt-4 w-full gap-5 sm:gap-7`,children:[(0,G.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-left pl-[5%] sm:pl-[10%] transform hover:translate-x-1 transition-transform duration-200`,children:[`Write it in `,(0,G.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Markdown`}),`.`]}),(0,G.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-center transform hover:scale-[1.02] transition-transform duration-200`,children:[(0,G.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Run`}),` it as a Timer.`]}),(0,G.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-right pr-[5%] sm:pr-[10%] transform hover:-translate-x-1 transition-transform duration-200`,children:[`Own the `,(0,G.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Analytics`}),`.`]})]}):(0,G.jsx)(`strong`,{className:`font-black text-foreground`,children:e})}},gY={...mY,p({children:e}){return(0,G.jsx)(`p`,{className:`text-base lg:text-lg font-medium text-foreground/75 leading-relaxed my-4 first:mt-0`,children:e})}},_Y=[Bn];function vY(e){return e.startsWith(`:`)?e:jn(e)}function yY(e){return e.type===`text`&&typeof e.value==`string`?e.value:(e.children??[]).map(yY).join(``)}function bY(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N} _-]/gu,``).replace(/ /g,`-`).replace(/-+/g,`-`)||`heading`}var xY=()=>e=>{let t=new Map,n=e=>{if(e.tagName&&/^h[1-6]$/.test(e.tagName)){let n=bY(yY(e)),r=t.get(n)??0;t.set(n,r+1),(e.properties??={}).id=r===0?n:`${n}-${r}`}for(let t of e.children??[])n(t)};n(e)};function SY({fields:e}){let t=Object.entries(e);return t.length===0?null:(0,G.jsxs)(`div`,{className:`my-6 rounded-xl border border-border bg-muted/30 overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`px-4 py-2 border-b border-border bg-muted/50`,children:(0,G.jsx)(`span`,{className:`text-[10px] font-black tracking-[0.2em] uppercase text-muted-foreground`,children:`Metadata`})}),(0,G.jsx)(`dl`,{className:`divide-y divide-border/50`,children:t.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-baseline gap-4 px-4 py-2`,children:[(0,G.jsx)(`dt`,{className:`text-[11px] font-semibold text-muted-foreground uppercase tracking-wide min-w-[100px] shrink-0`,children:e}),(0,G.jsx)(`dd`,{className:`text-sm text-foreground break-words`,children:Array.isArray(t)?t.join(`, `):String(t)})]},e))})]})}var CY={default:mY,heroLead:hY,heroBody:gY};function wY({prose:e,className:t,variant:n=`default`}){if(!e)return null;let{fields:r,body:i}=pY(e);return(0,G.jsxs)(`div`,{className:K(`prose-canvas`,t),children:[r&&(0,G.jsx)(SY,{fields:r}),i&&(0,G.jsx)(pn,{remarkPlugins:_Y,rehypePlugins:[xY],urlTransform:vY,components:CY[n],children:i})]})}var TY=({activations:e,fullBleed:t,runState:n,deps:r})=>{if(e.length===0)return null;let i=e[0];if(eN(i)&&n){let a=e.slice(1),o=n.isReconnect?(0,G.jsxs)(`button`,{onClick:n.onReconnect,className:K(`flex items-center gap-2 px-5 py-2 text-[11px] font-black uppercase tracking-widest`,`rounded-full border transition-all active:scale-95`,`border-amber-500/40 bg-amber-500/15 text-amber-600 hover:bg-amber-500/20`,`dark:text-amber-400`,t&&`mx-auto`),children:[(0,G.jsx)(Re,{className:`size-3.5`}),`View`]}):(0,G.jsxs)(`button`,{type:`button`,onClick:n.onRun,className:K(`flex items-center gap-2 transition-all active:scale-95 bg-primary text-primary-foreground hover:bg-primary/90 font-black uppercase tracking-widest rounded-full shadow-lg shadow-primary/25 min-h-[44px] px-6 py-2 text-xs`,t&&`mx-auto`),children:[(()=>{let e=i.icon||un;return(0,G.jsx)(e,{className:`shrink-0 size-4 fill-current sm:size-3`})})(),(0,G.jsx)(`span`,{children:i.label})]});return(0,G.jsxs)(`div`,{className:K(`flex flex-wrap items-center gap-4 mt-8`,t&&`justify-center`),children:[o,a.map((e,t)=>(0,G.jsx)(`button`,{onClick:()=>ZM(e.action,r),className:`flex items-center gap-2 px-6 py-2 text-xs font-black uppercase tracking-widest rounded-full bg-background border border-border text-foreground hover:bg-muted transition-all active:scale-95`,children:e.label},e.id||t))]})}return(0,G.jsx)(`div`,{className:K(`flex flex-wrap gap-4 mt-8`,t&&`justify-center`),children:e.map((e,t)=>(0,G.jsx)(`button`,{onClick:()=>ZM(e.action,r),className:K(`flex items-center gap-2 px-8 py-4 text-xs font-black uppercase tracking-widest rounded-full transition-all active:scale-95`,t===0?`bg-primary text-primary-foreground shadow-xl shadow-primary/25 hover:scale-[1.04]`:`bg-background border border-border text-foreground hover:bg-muted`),children:e.label},e.id||t))})},EY=({examples:e,activeIndex:t,onSelect:n})=>e.length===0?null:(0,G.jsx)(`div`,{className:`mt-6 rounded-2xl border border-border/70 bg-card/80 backdrop-blur-sm`,children:(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-3`,children:e.map((e,r)=>{let i=r===t,a=e.anchor===!0&&!i,o=!!e.badge&&a;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(r),"aria-current":i?`true`:void 0,className:K(`relative rounded-full px-4 py-2 text-[11px] font-black uppercase tracking-[0.18em] transition-all active:scale-95`,i?`bg-primary text-primary-foreground shadow-lg shadow-primary/25`:a?`border border-brand bg-brand/5 text-brand-deep hover:bg-brand/10 dark:text-brand-light`:`border border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.label,o?(0,G.jsx)(`span`,{className:`ml-2 inline-block rounded-pill bg-brand px-1.5 py-0.5 align-middle text-[8px] font-black leading-none tracking-[0.12em] text-background`,children:e.badge}):null]},`${e.label}-${r}`)})})}),DY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M35 35 L65 35 L65 45 L45 45 L45 65 L35 65 Z`,fill:`url(#struct-grad)`}),(0,G.jsx)(`path`,{d:`M55 45 L65 45 L65 65 L45 65 L45 55 L55 55 Z`,fill:`url(#struct-grad)`,opacity:`0.7`})]}),OY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`proto-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#FFD600`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#FFAB00`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`4`}),(0,G.jsx)(`circle`,{cx:`50`,cy:`50`,r:`5`,fill:`url(#proto-grad)`}),(0,G.jsx)(`circle`,{cx:`50`,cy:`50`,r:`15`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`2`,strokeDasharray:`4 2`}),(0,G.jsx)(`circle`,{cx:`50`,cy:`50`,r:`25`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`1`,opacity:`0.5`}),(0,G.jsx)(`line`,{x1:`50`,y1:`50`,x2:`50`,y2:`25`,stroke:`url(#proto-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]}),kY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`complex-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#F50057`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#D500F9`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#complex-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M40 35 H60 V45 A5 5 0 0 1 60 55 V65 H40 V55 A5 5 0 0 0 40 45 Z`,fill:`url(#complex-grad)`})]}),AY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]}),(0,G.jsxs)(`filter`,{id:`glow`,x:`-20%`,y:`-20%`,width:`140%`,height:`140%`,children:[(0,G.jsx)(`feGaussianBlur`,{stdDeviation:`3`,result:`blur`}),(0,G.jsx)(`feComposite`,{in:`SourceGraphic`,in2:`blur`,operator:`over`})]})]}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M55 20 L30 55 L45 55 L40 85 L70 45 L55 45 Z`,fill:`url(#basics-grad)`,filter:`url(#glow)`})]}),jY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,G.jsx)(`text`,{x:`50`,y:`65`,fontFamily:`monospace`,fontSize:`40`,fontWeight:`bold`,fill:`url(#basics-grad)`,textAnchor:`middle`,children:`10`})]}),MY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,G.jsx)(`rect`,{x:`30`,y:`30`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`}),(0,G.jsx)(`rect`,{x:`30`,y:`45`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`}),(0,G.jsx)(`rect`,{x:`30`,y:`60`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`})]}),NY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M50 30 A20 20 0 1 1 35.8 35.8 L30 30 M35.8 35.8 L42 38`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`6`,strokeLinecap:`round`})]}),PY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M30 40 L45 40 M30 50 L55 50 M30 60 L70 60`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`6`,strokeLinecap:`round`}),(0,G.jsx)(`text`,{x:`50`,y:`30`,fontFamily:`monospace`,fontSize:`12`,fill:`url(#struct-grad)`,textAnchor:`middle`,children:`21-15-9`})]}),FY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`proto-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#FFD600`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#FFAB00`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M35 35 H65 V55 L50 70 L35 55 Z`,fill:`url(#proto-grad)`}),(0,G.jsx)(`circle`,{cx:`50`,cy:`45`,r:`4`,fill:`#0b1326`})]}),IY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`metric-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E5FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#1DE9B6`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`}),(0,G.jsx)(`rect`,{x:`30`,y:`60`,width:`10`,height:`15`,fill:`url(#metric-grad)`}),(0,G.jsx)(`rect`,{x:`45`,y:`40`,width:`10`,height:`35`,fill:`url(#metric-grad)`}),(0,G.jsx)(`rect`,{x:`60`,y:`25`,width:`10`,height:`50`,fill:`url(#metric-grad)`})]}),LY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`metric-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E5FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#1DE9B6`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M35 40 L65 60 M65 40 L35 60 M35 30 H65 M35 70 H65`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]}),RY=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`dialect-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#76FF03`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00E676`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#dialect-grad)`,strokeWidth:`4`,strokeLinecap:`round`}),(0,G.jsx)(`path`,{d:`M35 30 H65 M35 45 H65 M35 60 H55 M35 75 H65`,fill:`none`,stroke:`url(#dialect-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]});function zY(e){switch(e){case`trophy`:return AY;case`dumbbell`:return k;case`timer`:return OY;case`play`:return un;case`blocks`:return DY;case`puzzle`:return kY;case`activity`:return IY;case`file-text`:return RY;default:return We}}function BY(e){switch(e){case`basics-movement`:return AY;case`basics-reps`:return jY;case`basics-load`:return MY;case`structure-rounds`:case`complex-rounds`:case`protocols-rounds`:return NY;case`structure-repscheme`:return PY;case`protocols-timer`:case`complex-time`:return OY;case`protocols-tag`:return FY;case`metrics-custom`:return IY;case`metrics-calc`:return LY;case`dialects-log`:case`dialects-climb`:return RY;default:return null}}function VY({quest:e,onClick:t,className:n,compact:r=!1,disabled:i=!1}){let a=BY(e.id),o=t?`Select to jump to its section.`:`Open the editor to begin.`,s=e.isCompleted?`Challenge complete.`:e.result?e.result.pass?`Ready — ${e.result.detail??`looks good`}`:e.result.reason??o:o,c={"data-testid":`challenge-row-${e.id}`,"data-completed":e.isCompleted?`true`:`false`,className:K(`w-full text-left flex items-start gap-3 rounded-xl border px-3 py-2 text-sm transition-colors`,e.isCompleted?`border-primary/40 bg-primary/5`:`border-border/50 bg-background/60`,t&&!i&&`cursor-pointer hover:bg-background/80`,i&&`opacity-60 cursor-default`,r&&`px-2.5 py-1.5`,n)},l=(0,G.jsxs)(G.Fragment,{children:[a?(0,G.jsxs)(`span`,{className:K(`relative shrink-0 mt-0.5`,r?`size-5`:`size-6`),children:[(0,G.jsx)(a,{className:`w-full h-full`}),e.isCompleted&&(0,G.jsx)(`span`,{className:`absolute -bottom-1 -right-1 flex size-3.5 items-center justify-center rounded-full bg-emerald-500 text-white border border-background shadow`,children:(0,G.jsx)(sn,{className:`size-2`,strokeWidth:3})})]}):(0,G.jsx)(`span`,{className:K(`mt-0.5 shrink-0`,e.isCompleted?`text-primary`:`text-muted-foreground/50`),"aria-hidden":`true`,children:e.isCompleted?(0,G.jsx)(Un,{className:r?`size-3.5`:`size-4`}):(0,G.jsx)(jt,{className:r?`size-3.5`:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:K(`font-semibold`,e.isCompleted?`text-foreground line-through decoration-primary/40`:`text-foreground`,r&&`text-xs`),children:e.label}),e.desc&&!r&&(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.desc}),(0,G.jsx)(`p`,{"data-testid":`challenge-hint-${e.id}`,className:K(`mt-1 text-xs`,e.isCompleted||e.result?.pass?`text-primary/80`:`text-muted-foreground`),children:s})]})]});return t?(0,G.jsx)(`button`,{type:`button`,onClick:t,disabled:i,...c,children:l}):(0,G.jsx)(`div`,{...c,children:l})}function HY(e){let t=e.replace(/^\s+/,``),n=t.match(/\n\s*\n/);return!n||n.index===void 0?{lead:t,rest:``}:{lead:t.slice(0,n.index),rest:t.slice(n.index).trimStart()}}var UY=({section:e,idx:t,prose:n,blockId:r,keySuffix:i,showHeading:a=!0,showEyebrow:o=!0,renderButtons:s=!0,isActive:c=!1,hasViewDef:l=!1,runState:u,deps:d,onExampleSelect:f,selectedExampleIndex:p,chapters:m=[],challengeQuests:h=[],isCollection:g=!1,collectionSlug:_=null,workoutItems:v=[],handleSelectWorkout:y,onScrollToSection:b,variant:x=`default`})=>{let S=!!e.isFullBleed,C=!!e.isDark&&x!==`caption`,w=e.density,T=oP[e.theme||`slate`]??oP.slate,E=e.examples??[],D=t===-1,O=W.useMemo(()=>{if(!m||!h)return null;for(let t of m){let n=t.sectionIds.indexOf(e.id);if(n>=0&&t.questIds[n]){let e=t.questIds[n],r=h.find(t=>t.id===e);if(r)return{quest:r,chapterTitle:t.title}}}return null},[m,h,e.id]);if(D){let t=e.proseChunks.filter(e=>e.kind===`button`).map(e=>e.button),n=e.proseChunks.findIndex(e=>e.kind===`prose`&&e.text.trim()!==``),a=n>=0?e.proseChunks[n]:null,{lead:o,rest:s}=a&&a.kind===`prose`?HY(a.text.trim()):{lead:``,rest:``},c=e.proseChunks.slice(n+1);return(0,G.jsxs)(`div`,{id:r,"data-section-id":i==="default"?e.id:void 0,className:`group relative flex min-h-[70vh] lg:min-h-[80vh] items-center justify-center overflow-hidden border-b-2 border-primary/10 bg-gradient-to-b from-primary/[0.08] via-muted/30 to-background px-6 py-16 lg:px-10 lg:py-24`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_75%_60%_at_50%_0%,_var(--tw-gradient-stops))] from-primary/30 via-primary/5 to-transparent`}),(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 text-primary opacity-[0.15]`,style:{backgroundImage:`radial-gradient(circle, currentColor 1.5px, transparent 1.5px)`,backgroundSize:`24px 24px`,maskImage:`radial-gradient(ellipse 70% 60% at 50% 40%, black 40%, transparent 90%)`,WebkitMaskImage:`radial-gradient(ellipse 70% 60% at 50% 40%, black 40%, transparent 90%)`}}),(0,G.jsxs)(`div`,{className:`relative max-w-2xl w-full text-center`,children:[o&&(0,G.jsx)(wY,{prose:o,variant:`heroLead`,className:`mb-5`}),s&&(0,G.jsx)(wY,{prose:s,variant:`heroBody`,className:`mb-2`}),c.map((e,t)=>{if(e.kind===`prose`){let n=e.text.trim();return n?(0,G.jsx)(wY,{prose:n,className:`mt-6 mb-2`},`hero-prose-${t}`):null}if(e.kind===`challenge`){let n=h.find(t=>t.id===e.id);return n?(0,G.jsx)(`div`,{className:`my-4 flex justify-center`,children:(0,G.jsx)(VY,{quest:n,onClick:()=>b?.(r),compact:!0})},`hero-challenge-${t}`):null}return null}),t.length>0&&(0,G.jsx)(TY,{activations:t.map((e,t)=>$M(e,t)),fullBleed:!0,runState:l?u:void 0,deps:d})]})]})}let k=n===void 0?e.proseChunks??[]:[{kind:`prose`,text:n}],A=!k.some(e=>e.kind===`button`)&&(e.buttons??[]).length>0;return(0,G.jsxs)(`div`,{id:r,"data-section-id":i==="default"||i===`before-workouts`?e.id:void 0,className:K(`group relative border-b border-border/50 transition-colors duration-300`,x===`caption`?`py-6 pb-10`:l?S?`flex items-center justify-center min-h-[35vh] py-12 lg:py-16 px-6 lg:px-10`:w===`compact`?`py-10 lg:py-12 px-6 lg:px-10`:`py-14 lg:py-20 px-6 lg:px-10`:w===`compact`?`py-10 lg:py-12 px-6 lg:px-12`:`py-16 lg:py-20 px-6 lg:px-12`,!x||x==="default"?C&&`bg-muted/20 overflow-hidden`:void 0,x!==`caption`&&!C&&!S&&(t%2==0?`bg-background`:`bg-muted/[0.18]`)),children:[x!==`caption`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:K(`pointer-events-none absolute inset-y-0 left-0 w-px bg-gradient-to-b opacity-0 transition-opacity duration-300`,T.accent,c&&`opacity-100`)}),(0,G.jsx)(`div`,{className:K(`pointer-events-none absolute left-0 top-0 h-full w-1 origin-top rounded-r-full bg-gradient-to-b transition-all duration-300`,T.progress,c?`scale-y-100 opacity-100`:`scale-y-[0.18] opacity-25`)})]}),C&&(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 opacity-40 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-primary/20 via-transparent to-transparent`}),(0,G.jsxs)(`div`,{className:K(`relative`,x===`caption`?`max-w-none`:l?S?`max-w-md w-full text-center`:`max-w-sm`:`max-w-4xl w-full mx-auto`),children:[o&&(!S||!l)&&O&&(0,G.jsx)(`div`,{className:`mb-4 flex items-center gap-2 select-none min-h-[14px]`,children:O.quest.isCompleted?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-wider text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 px-2 py-0.5 rounded-full border border-emerald-500/20`,children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse`}),`Challenge Complete`]}):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-wider text-muted-foreground/80 bg-muted/60 px-2 py-0.5 rounded-full border border-border/50`,children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-zinc-400 dark:bg-zinc-500`}),O.chapterTitle,`: Challenge Pending`]})}),a?(0,G.jsx)(`h2`,{className:K(`font-bold tracking-tight text-foreground leading-tight`,x===`caption`?`text-xl lg:text-2xl mb-4`:`text-2xl lg:text-3xl font-black uppercase mb-5`),children:e.heading}):null,k.map((e,t)=>{if(e.kind===`prose`){let n=e.text.trim();return n?(0,G.jsx)(wY,{prose:n,className:t===0?`mb-6`:`mt-4 mb-6`},`prose-${t}`):null}if(e.kind===`button`)return(0,G.jsx)(TY,{activations:[$M(e.button,t)],fullBleed:S,runState:l?u:void 0,deps:d},`button-${t}`);if(e.kind===`widget`){if(e.widget===`hero-carousel`)return(0,G.jsx)(`div`,{className:`my-6`,children:(0,G.jsx)(ZJ,{})},`hero-carousel-${t}`);if(e.widget===`workouts-list`&&g&&_&&y)return(0,G.jsx)(`div`,{id:`collection-workouts`,className:`border-b border-border/50 bg-card my-6`,children:(0,G.jsx)(`div`,{className:`w-full mx-auto`,children:(0,G.jsx)(aY,{category:_,workoutItems:v,onSelect:y,showSearch:!1,variant:`flat`})})},`workouts-${t}`)}if(e.kind===`challenge`){let n=h.find(t=>t.id===e.id);return n?(0,G.jsx)(`div`,{className:`my-4`,children:(0,G.jsx)(VY,{quest:n,onClick:()=>b?.(r),compact:!0})},`challenge-${t}`):null}return null}),E.length>0?(0,G.jsx)(EY,{examples:E,activeIndex:Math.min(p,E.length-1),onSelect:t=>f(e,t)}):null,s&&A?(0,G.jsx)(TY,{activations:e.buttons.map((e,t)=>$M(e,t)),fullBleed:S,runState:l?u:void 0,deps:d}):null]})]},`${e.id}-${i}`)};function WY({sections:e,activeIndex:t,part:n,args:r}){return(0,G.jsx)(`div`,{className:`h-full min-h-0 pr-1`,"data-testid":`guide-captions-${n}`,children:e.map((e,n)=>{let i=n===t;return(0,G.jsx)(`div`,{className:`absolute inset-0 min-h-0 overflow-y-auto transition-opacity duration-300 ${i?`opacity-100`:`pointer-events-none invisible opacity-0`}`,"aria-hidden":!i,children:(0,G.jsx)(UY,{section:e,idx:n,blockId:`guide-caption-${e.id}`,keySuffix:`caption`,variant:`caption`,isActive:i,hasViewDef:r.hasViewDef??!0,runState:r.runState,deps:r.deps,onExampleSelect:r.onExampleSelect,selectedExampleIndex:r.selectedExamples[e.id]??0,chapters:r.chapters,challengeQuests:r.challengeQuests,onScrollToSection:r.onScrollToSection})},e.id)})})}function GY({sections:e,part:t,partCount:n,title:r,pane:i,cardArgs:a,onActivateSection:o}){let s=(0,W.useRef)(null),c=(0,W.useMemo)(()=>YJ(e),[e]),{slice:l,subscribe:u}=GJ(s,!1,c),d=(0,W.useRef)(e);d.current=e;let[f,p]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=s.current;if(!e||typeof IntersectionObserver>`u`){p(!0);return}let t=new IntersectionObserver(([e])=>{e.isIntersecting&&(p(!0),t.disconnect())},{rootMargin:`100px`});return t.observe(e),()=>t.disconnect()},[]);let m=()=>{let e=s.current;if(!e)return!1;let{top:t,bottom:n}=e.getBoundingClientRect();return t<=0&&n>window.innerHeight},[h,g]=(0,W.useState)(!1);(0,W.useEffect)(()=>u(()=>{let e=m();g(t=>t===e?t:e)}),[u]);let _=(0,W.useRef)(!1),v=(0,W.useRef)(-1),y=(0,W.useRef)(o);y.current=o,(0,W.useEffect)(()=>{let e=_.current,t=v.current;if(_.current=h,v.current=l.index,!h||e&&t===l.index)return;let n=d.current[l.index];n&&y.current(n)},[h,l.index]);let b=e[l.index]??null;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`header`,{"data-testid":`guide-runway-header-${t}`,className:`mx-auto w-full max-w-[1500px] px-6 pt-12 pb-6 lg:px-12`,children:[(0,G.jsxs)(`div`,{className:`font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground`,children:[`Part `,t,` / `,n]}),(0,G.jsx)(`h2`,{className:`mt-1 text-xl font-black uppercase tracking-tight text-foreground`,children:r})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(HJ,{trackRef:s,height:`${(e.length+1)*100}vh`,stages:c,activeIndex:l.index,pane:f?i:null,captions:(0,G.jsx)(WY,{sections:e,activeIndex:l.index,part:t,args:a}),status:(0,G.jsxs)(`div`,{className:`truncate font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground`,children:[String(l.index+1).padStart(2,`0`),b?` — ${b.heading}`:``]}),testId:`guide-runway-${t}`}),e.map((t,n)=>(0,G.jsx)(`span`,{id:t.id,"data-section-id":t.id,"aria-hidden":`true`,className:`pointer-events-none absolute left-0 h-px w-px`,style:{top:`calc((100% - 100vh) * ${n/e.length} + 50vh + 120px)`}},t.id))]})]})}function KY({sections:e,groupKey:t,title:n,pane:r,cardArgs:i,onActivateSection:a}){let{groups:o,tail:s}=JJ(e,t);return(0,G.jsxs)(G.Fragment,{children:[o.map((e,t)=>(0,G.jsx)(GY,{sections:e,part:t+1,partCount:o.length,title:n,pane:r,cardArgs:i,onActivateSection:a},e[0]?.id??t)),s.length>0&&(0,G.jsx)(`div`,{className:`mx-auto w-full max-w-[1500px] px-6 lg:px-12`,"data-testid":`guide-static-tail`,children:(0,G.jsx)(`div`,{className:`lg:max-w-[50%]`,children:s.map((e,t)=>(0,G.jsx)(UY,{section:e,idx:t,blockId:e.id,keySuffix:`default`,isActive:i.activeSectionId===e.id,hasViewDef:i.hasViewDef??!0,runState:i.runState,deps:i.deps,onExampleSelect:i.onExampleSelect,selectedExampleIndex:i.selectedExamples[e.id]??0,chapters:i.chapters,challengeQuests:i.challengeQuests,onScrollToSection:i.onScrollToSection},`tail-${e.id}`))})})]})}function qY({videoId:e,title:t=`YouTube video`,onClose:n}){return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,qx.createPortal)((0,G.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/90 p-4 animate-in fade-in duration-200`,"data-testid":`youtube-lightbox`,onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,title:`Close video`,"data-testid":`youtube-lightbox-close`,className:`absolute right-4 top-4 z-[110] flex size-11 items-center justify-center rounded-full border border-border bg-background/80 text-foreground transition-colors hover:bg-accent`,children:(0,G.jsx)(Se,{className:`size-5`})}),(0,G.jsx)(`div`,{className:`aspect-video w-full max-w-5xl overflow-hidden rounded-lg border border-border bg-black shadow-2xl`,children:(0,G.jsx)(`iframe`,{className:`h-full w-full border-0`,src:`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e)}?autoplay=1&rel=0`,title:t,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0})})]}),document.body)}function JY({index:e,before:t,accentText:n,after:r,accent:i,blurb:a}){return(0,G.jsx)(`header`,{className:`flex items-center px-6 py-14 lg:px-12 xl:py-20 2xl:py-24 xl:px-16`,children:(0,G.jsxs)(`div`,{className:`mx-auto w-full max-w-[1500px] 2xl:max-w-[1720px]`,children:[(0,G.jsxs)(`h2`,{className:`flex items-baseline gap-4 xl:gap-6 text-[clamp(26px,3.6vw,52px)] font-extrabold leading-[1.1] tracking-[-0.03em]`,children:[(0,G.jsx)(`span`,{className:`font-mono text-xs font-normal tracking-normal text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{children:[t,n,r]})]}),(0,G.jsx)(`p`,{className:`mt-3 xl:mt-4 max-w-xl xl:max-w-2xl 2xl:max-w-3xl text-[clamp(14px,1.2vw,18px)] leading-[1.65] text-muted-foreground`,children:a})]})})}var YY=`hsl(var(--primary))`,XY={ink:`hsl(var(--foreground))`,editor:YY,timer:YY,analytics:YY,library:YY,rounds:YY},ZY={editor:`WOD Editor & Autocomplete`,timer:`Clock`,analytics:`WQL Analytics`,metrics:`Own the Metrics`,result:`Run Results`},QY={start:`/guide/start`,protocols:`/guide/protocols`,structure:`/guide/structure`,metrics:`/guide/metrics`,clock:`/guide/clock`,wql:`/guide/wql`,dashboards:`/guide/dashboards`,sessions:`/guide/sessions`,basics:`/guide/start`,"custom-metrics":`/guide/metrics`,dialects:`/guide/sessions#intent`,complex:`/guide/sessions#full-session`},$Y=`dQw4w9WgXcQ`,eX=`https://i.ytimg.com/vi/${$Y}/hqdefault.jpg`;function tX({variant:e=`index`}){let t=IP(),{pathname:n}=dt(),[r,i]=(0,W.useState)(null),a=(0,W.useMemo)(()=>QN(t).flatMap(e=>e.action?.type===`route`?[{id:e.id,label:e.label,to:e.action.to}]:[]),[t]),o=(0,W.useMemo)(()=>{let e=new Map;for(let n of t){if(n.route.startsWith(`/collections`)||n.page.frontmatter?.type!==`guide`)continue;let t=n.page.frontmatter?.description;t&&e.set(`guide-${n.route}`,String(t))}return e},[t]);if(a.length===0)return null;let s=a.findIndex(e=>e.to===n),c=s>=0,l=c&&a.length>1?(s+1)%a.length:-1,u=r&&(0,G.jsx)(qY,{videoId:$Y,title:r.label,onClose:()=>i(null)});return e===`university`?(0,G.jsxs)(`section`,{id:`tour-section-university`,"data-testid":`tour-section-university`,"aria-label":`Wod Wiki University`,children:[(0,G.jsx)(JY,{index:`05`,before:`Wod Wiki `,accentText:`University`,after:``,accent:XY.library,blurb:`Eight short chapters take you from your first workout to querying your training history. Each guide pairs a video walkthrough with a runnable example.`}),(0,G.jsx)(`nav`,{"aria-label":`Wod Wiki University`,className:`px-6 pb-16 lg:px-12 xl:px-16`,children:(0,G.jsx)(`ul`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-5`,children:a.map((e,t)=>(0,G.jsxs)(`li`,{className:K(`flex flex-col gap-5 rounded-lg border border-border p-5 md:flex-row md:items-center md:gap-8 md:p-6`,t%2==1&&`md:flex-row-reverse`),children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i({id:e.id,label:e.label}),title:`Watch: ${e.label}`,"aria-label":`Watch: ${e.label}`,"data-testid":`guide-watch`,className:`group relative block w-full flex-none overflow-hidden rounded-md border border-border md:w-56`,children:[(0,G.jsx)(`img`,{src:eX,alt:``,loading:`lazy`,className:`aspect-video w-full object-cover transition-transform duration-300 group-hover:scale-105`}),(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/25 transition-colors group-hover:bg-black/40`,children:(0,G.jsx)(un,{className:`size-9 fill-white text-white`})})]}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,G.jsx)(Vn,{to:e.to,className:`font-semibold hover:underline`,children:e.label}),(0,G.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:o.get(e.id)??e.to})]})]},e.id))})}),u]}):(0,G.jsxs)(`nav`,{"aria-label":c?`What’s Next`:`Syntax & Guides`,"data-testid":`guide-index-footer`,className:`border-t border-border px-6 py-12 xl:py-16`,children:[(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col rounded-lg border border-border overflow-hidden`,children:[(0,G.jsxs)(`h2`,{className:`px-4 py-2 text-xs font-black uppercase tracking-wider text-muted-foreground bg-muted/40`,children:[c?`What’s Next`:`Syntax & Guides`,` · `,a.length]}),(0,G.jsx)(`ul`,{className:`flex flex-col divide-y divide-border`,children:a.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex items-stretch`,children:[(0,G.jsxs)(Vn,{to:e.to,"aria-current":t===s?`page`:void 0,className:K(`flex min-w-0 flex-1 flex-col gap-0.5 px-4 py-3 hover:bg-muted/50`,t===s&&`bg-muted/50`),children:[(0,G.jsxs)(`span`,{className:`flex w-full items-baseline justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.label}),t===l&&(0,G.jsx)(`span`,{className:`text-xs font-semibold text-primary`,"data-testid":`guide-next-marker`,children:`Next →`})]}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.to})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i({id:e.id,label:e.label}),title:`Watch: ${e.label}`,"aria-label":`Watch: ${e.label}`,"data-testid":`guide-watch`,className:`flex flex-none items-center gap-1.5 border-l border-border px-4 text-xs font-semibold text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,children:[(0,G.jsx)(un,{className:`size-3.5`}),`Watch`]})]},e.id))})]}),u]})}var nX=`22rem`,rX=`42rem`,iX=`20rem`,aX=`calc(100dvh - var(--canvas-sticky-top) - 2rem)`;function oX(e){return{editorWidth:e||`50%`,editorMinWidth:nX,editorMaxWidth:rX,editorMinHeight:iX,editorMaxHeight:aX}}function sX(e){let t=Math.max(1,e.split(`
|
|
@@ -203,4 +203,4 @@ Fran went unbroken until round three. Throat on fire.
|
|
|
203
203
|
`,l6]})]})}var g6=`✎`;function _6({wql:e,setWql:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(e);return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(f6,{wql:e}),!n&&(0,G.jsx)(`button`,{onClick:()=>{a(e),r(!0)},className:`absolute top-2 right-2 text-muted-foreground hover:text-foreground text-xs px-1.5 py-0.5 rounded hover:bg-muted`,children:g6})]}),n&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-sky-500/50 bg-card p-3 space-y-2 shadow-lg shadow-sky-500/5`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-sky-400 font-mono`,children:`editing query:table — Apply writes the fence`}),(0,G.jsx)(mC,{query:i,onQueryChange:a,autoFocus:!0,placeholder:`:session…`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>r(!1),className:`px-3 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground`,children:`Cancel`}),(0,G.jsx)(`button`,{onClick:()=>{t(i),r(!1)},className:`px-3 py-1 text-xs rounded-md bg-sky-500 text-zinc-950 font-medium`,children:`Apply to fence`})]})]})]})}function v6({wql:e,setWql:t}){let[n,r]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`space-y-3 pb-24`,children:[(0,G.jsx)(`button`,{onClick:()=>r(!0),className:`block w-full text-left rounded-lg transition-shadow ${n?`ring-2 ring-sky-500/70`:`hover:ring-1 hover:ring-border`}`,children:(0,G.jsx)(f6,{wql:e})}),(0,G.jsxs)(`div`,{className:`sticky bottom-20 rounded-xl border p-3 space-y-2 shadow-xl backdrop-blur transition-colors ${n?`border-sky-500/60 bg-card/95`:`border-border bg-card/80 opacity-70`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-mono ${n?`text-sky-400`:`text-muted-foreground`}`,children:n?`◉ bound: query:table · ${o6.slice(0,8)}…`:`○ click a query block to bind the composer`}),n&&(0,G.jsx)(`button`,{onClick:()=>r(!1),className:`text-[10px] text-muted-foreground hover:text-foreground`,children:`Done`})]}),n&&(0,G.jsx)(mC,{query:e,onQueryChange:t,autoFocus:!0,showDiagnostics:!1,placeholder:`:session…`})]})]})}function y6({wql:e,setWql:t}){let[n,r]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),n?(0,G.jsxs)(`div`,{className:`rounded-lg border border-sky-500/50 bg-muted/60 shadow-lg shadow-sky-500/5`,children:[(0,G.jsx)(`div`,{className:`px-3 pt-2 text-[10px] font-mono text-muted-foreground select-none`,children:"```query:table"}),(0,G.jsx)(`div`,{className:`px-3 py-2`,children:(0,G.jsx)(mC,{query:e,onQueryChange:t,autoFocus:!0,showDiagnostics:!1,placeholder:`:session…`,className:`bg-transparent border-0 shadow-none`})}),(0,G.jsxs)(`div`,{className:`px-3 pb-2 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground select-none`,children:"```"}),(0,G.jsx)(`button`,{onClick:()=>r(!1),className:`text-[10px] text-sky-400 hover:text-sky-300 font-mono`,children:`Esc / leave fence ↩`})]})]}):(0,G.jsx)(`button`,{onClick:()=>r(!0),className:`block w-full text-left hover:ring-1 hover:ring-border rounded-lg`,children:(0,G.jsx)(f6,{wql:e})})}var b6=[[`inline`,`A · in-flow expansion`],[`dock`,`B · bound dock`],[`fence`,`C · fence-as-composer`]];function x6(){let[e,t]=bt(),n=e.get(`v`)??`inline`,[r,i]=(0,W.useState)(s6),a=e=>{let r=b6[(b6.findIndex(([e])=>e===n)+e+b6.length)%b6.length][0];t({v:r})};return(0,W.useEffect)(()=>{let e=e=>{e.target.closest(`input, textarea, [contenteditable]`)||(e.key===`ArrowLeft`&&a(-1),e.key===`ArrowRight`&&a(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,G.jsxs)(`div`,{className:`min-h-screen bg-background text-foreground p-6`,children:[(0,G.jsxs)(`div`,{className:`max-w-5xl mx-auto grid grid-cols-[1fr_320px] gap-6 items-start`,children:[(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[11px] text-amber-500 mb-1`,children:`PROTOTYPE — throwaway · query:table editing via WqlComposer`}),(0,G.jsx)(`h1`,{className:`text-xl font-bold`,children:`Journal — 2026-09-13`})]}),(0,G.jsx)(p6,{children:c6.split("```time")[0].trim()}),(0,G.jsx)(m6,{}),n===`inline`&&(0,G.jsx)(_6,{wql:r,setWql:i}),n===`dock`&&(0,G.jsx)(v6,{wql:r,setWql:i}),n===`fence`&&(0,G.jsx)(y6,{wql:r,setWql:i}),(0,G.jsx)(p6,{children:l6})]}),(0,G.jsx)(`div`,{className:`sticky top-6`,children:(0,G.jsx)(h6,{wql:r})})]}),(0,G.jsxs)(`div`,{className:`fixed bottom-4 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-xl border border-border bg-card/95 backdrop-blur px-2 py-1.5 shadow-2xl z-50`,children:[(0,G.jsx)(`button`,{onClick:()=>a(-1),className:`px-2 text-muted-foreground hover:text-foreground`,children:`←`}),b6.map(([e,r])=>(0,G.jsx)(`button`,{onClick:()=>t({v:e}),className:`px-3 py-1 rounded-lg text-xs transition-colors ${n===e?`bg-sky-400 text-zinc-950 font-medium`:`text-muted-foreground hover:text-foreground`}`,children:r},e)),(0,G.jsx)(`button`,{onClick:()=>a(1),className:`px-2 text-muted-foreground hover:text-foreground`,children:`→`})]})]})}function S6(e,t,n=`absent`){return{id:e,fields:t,missPolicy:n,get:()=>void 0}}function C6(){let e=new zd;return e.register(S6(`effort`,{met:{dimension:Cu,type:`number`},disciplineFactor:{dimension:Cu,type:`number`},discipline:{dimension:Cu,type:`string`},intensityTier:{dimension:Cu,type:`string`},resolvedFrom:{dimension:Cu,type:`string`}},`default-row`)),e.register(S6(`rpe-labels`,{rpe:{dimension:Cu,type:`number`}})),e.register(S6(`profile`,{vo2max:{dimension:Cu,type:`number`}})),e.register(S6(`disciplines`,{disciplineFactor:{dimension:Cu,type:`number`}},`default-row`)),e}function w6(e,t){for(let n of t)try{e.register(n)}catch{}}function T6(e,t=`segment`){let n=[],r=[];try{let i=Of(e,{scope:t});r=i.defs;for(let e of i.warnings)n.push({severity:`warning`,message:e})}catch(e){return{defs:r,diagnostics:[{severity:`error`,message:e instanceof Error?e.message:String(e)}],dim:void 0,compound:void 0}}let i=new Cd(C6());w6(i,[...Vd,...Gd]);let a;for(let e of r){try{i.register(e)}catch(e){n.push({severity:`error`,message:e instanceof Error?e.message:String(e)});continue}let t=Hf(e)??(e.kind===`library`?Object.keys(e.variants[0]?.nodes??{})[0]:void 0),r=[...e.variants].sort((e,t)=>t.priority-e.priority)[0],o=t&&r.nodeDims?.[t];o&&(a=o)}let o;return a&&(o=Iu(a)),r.length===0&&n.push({severity:`warning`,message:`No calc line parsed.`}),{defs:r,diagnostics:n,dim:a,compound:o}}var E6=[`segment`,`workout`,`store`],D6=[`when`,`where`,`key`,`grouped`,`label`,`emit`,`meta`,`estimated`,`library`,`on`,`by`,`without`,`and`,`or`,`not`],O6=[`convert`,`lookup`,`has`,`round`,`floor`,`ceil`,`abs`,`clamp`,`min`,`max`,`sum`,`avg`,`count`,`last`,`windowMean`,`windowSum`,`windowSd`,`mean`],k6=[{name:`elapsed`,dim:Lu.elapsed.dim,detail:`s (time)`},{name:`reps`,dim:Lu.reps.dim,detail:`count`},{name:`resistance`,dim:Lu.resistance.dim,detail:`kg (mass)`},{name:`distance`,dim:Lu.distance.dim,detail:`m (length)`},{name:`effort`,dim:Ru.effort,detail:`resolved effort slug`},{name:`effortLabel`,dim:Ru.effortLabel,detail:`raw effort label`}],A6=[{name:`sessionRpe`,dim:Ru.sessionRpe,detail:`captured session RPE`},{name:`session.duration`,dim:Ru[`session.duration`],detail:`workout duration`},{name:`profile.vo2max`,dim:Ru[`profile.vo2max`],detail:`user VO₂max (mL/kg/min)`}],j6=Object.keys(Lu),M6=Object.keys(zu),N6=[{name:`effort`,detail:`effort catalog`,fields:[`met`,`disciplineFactor`,`discipline`,`intensityTier`,`resolvedFrom`]},{name:`rpe-labels`,detail:`effort label → RPE`,fields:[`rpe`]},{name:`profile`,detail:`user profile`,fields:[`vo2max`]},{name:`disciplines`,detail:`canonical disciplines`,fields:[`disciplineFactor`]}],P6=Object.keys(Uu),F6=Object.keys(zu);function I6(e){if(!e)return P6;let t=P6.filter(t=>{let n=Uu[t];return n?n.dim.every((t,n)=>t===e[n]):!1});return t.length?t:P6}var L6=new Set([...D6,...E6,`lookup`]),R6=new Set(O6),z6=new Set([...k6.map(e=>e.name),...A6.map(e=>e.name),...j6,...N6.map(e=>e.name)]),B6=/^\d*\.?\d+(?:d)?/,V6=/^[A-Za-z_][\w.]*/,H6=xr.define({name:`calcLine`,token(e){if(e.eatSpace())return null;if(e.match(`#`,!1))return e.skipToEnd(),`comment`;if(e.match(/^"([^"]*)"/)||e.match(/^'([^']*)'/))return`string`;if(e.match(/^(->|==|!=|<=|>=)/)||e.match(/^[+\-*/=<>(),:{}[\]]/))return`operator`;if(e.match(B6))return`number`;if(e.match(V6)){let t=e.current();return L6.has(t)?`keyword`:R6.has(t)?`function`:(z6.has(t),`variableName`)}return e.next(),null}}),U6=Or.define([{tag:U.keyword,color:`#c084fc`},{tag:U.function(U.variableName),color:`#60a5fa`},{tag:U.variableName,color:`#e4e4e7`},{tag:U.number,color:`#fbbf24`},{tag:U.string,color:`#34d399`},{tag:U.operator,color:`#a1a1aa`},{tag:U.comment,color:`#71717a`,fontStyle:`italic`}]);function W6(){return new jr(H6,[Dr(U6)])}var G6=[`effort`,`thruster`,`push-press`,`front-squat`,`wall-ball`,`row`,`run`];function K6(e={}){let t=e.scope??`segment`;return e=>{let n=e.state.sliceDoc(0,e.pos),r=e.matchBefore(/[\w./"]*/);if(!r)return null;if(/lookup\(\s*/.test(n)){let t=n.lastIndexOf(`lookup(`),r=n.slice(t+7);if(!/,/.test(r)&&/^"?[\w.-]*"?$/.test(r.replace(/"/g,``).trim()||``)){let t=r.replace(/"/g,``).trim(),n=N6.filter(e=>e.name.startsWith(t)).map(e=>({label:e.name,insert:`"${e.name}"`,detail:e.detail}));if(n.length)return{from:e.pos-t.length,options:n,validFor:/^[\w.-]*$/}}let i=/lookup\(\s*"[^"]+"\s*,\s*[^,]+,\s*"?([\w-]*)"?$/.exec(n);if(i){let t=/lookup\(\s*"([^"]+)"/.exec(n)?.[1],r=(N6.find(e=>e.name===t)?.fields??[]).filter(e=>e.startsWith(i[1])).map(e=>({label:e,insert:`"${e}"`,detail:`${t} field`}));return{from:e.pos-i[1].length,options:r,validFor:/^[\w-]*$/}}let a=/lookup\(\s*"(effort)"\s*,\s*"?([\w.-]*)"?$/.exec(n);if(a){let t=G6.filter(e=>e.startsWith(a[2])).map(e=>({label:e,insert:e===`effort`?e:`"${e}"`,detail:`effort key`}));return{from:e.pos-a[2].length,options:t,validFor:/^[\w.-]*$/}}}let i=/->\s*([\w/]*)$/.exec(n);if(i){let n=e.state.doc.lineAt(e.pos).text,r=T6(n,t),a=r.diagnostics.length===0?r.dim:void 0,o=I6(a).filter(e=>e.startsWith(i[1])).map(e=>({label:e,detail:a?`matches inferred dimension`:`unit`}));return{from:e.pos-i[1].length,options:o,validFor:/^[\w/]*$/}}if(t===`store`){let e=/^(sum|avg|max|min|count|last):([\w.]*)$/.exec(r.text);if(e){let t=j6.filter(t=>t.startsWith(e[2])).map(e=>({label:e,detail:`metric key`}));return{from:r.from+r.text.indexOf(`:`)+1,options:t,validFor:/^[\w.]*$/}}}let a=[];if(t===`segment`)a.push(...k6.map(e=>({label:e.name,insert:e.name,detail:e.detail})));else if(a.push(...A6.map(e=>({label:e.name,insert:e.name,detail:e.detail}))),t===`workout`){for(let e of M6)for(let t of[`reps`,`distance`,`segmentVolume`,`metMinutes`,`elapsed`,`effortRpe`])a.push({label:`${e}(${t})`,insert:`${e}(${t})`,detail:`aggregate`});a.push({label:`sum(reps, without: rest)`,insert:`sum(reps, without: rest)`,detail:`exclusion aggregate`})}a.push(...O6.map(e=>({label:`${e}()`,insert:`${e}()`,detail:`function`}))),t===`store`&&a.push(...F6.map(e=>({label:`${e}:{}`,insert:`${e}:`,detail:`WQL atom`}))),a.push(...D6.map(e=>({label:e,insert:e===`when`?`when `:e,detail:`clause`}))),a.push({label:`estimated`,insert:`estimated`,detail:`variant origin`}),a.push({label:`(library)`,insert:`(library)`,detail:`library calc`});let o=a.filter(e=>e.label.startsWith(r.text)).slice(0,20);return o.length?{from:r.from,options:o,validFor:/^[\w./]*$/}:null}}function q6(e){return Gr({override:[K6(e)]})}function J6({value:e,onChange:t,scope:n=`segment`,placeholder:r,readOnly:i=!1,autoFocus:a=!1,className:o}){let s=(0,W.useRef)(null),c=(0,W.useRef)(null),l=(0,W.useRef)(t);return l.current=t,(0,W.useEffect)(()=>{let t=s.current;if(!t)return;c.current?.destroy();let r=Cr.updateListener.of(e=>{e.docChanged&&l.current(e.state.doc.toString())}),o=new Cr({state:ei.create({doc:e,extensions:[W6(),q6({scope:n}),Yr(),ui(),gr.of([Qr,...Xr,...ai]),Cr.lineWrapping,ei.readOnly.of(i),r,Cr.theme({"&":{height:`auto`,minHeight:`120px`,fontSize:`13px`,border:`1px solid rgb(63 63 70)`,borderRadius:`8px`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,lineHeight:`1.55`},".cm-content":{padding:`8px 4px`},".cm-gutters":{borderRight:`1px solid rgb(63 63 70)`,minWidth:`28px`},"&.cm-focused":{outline:`2px solid rgb(139 92 246 / 0.5)`,outlineOffset:`1px`}})]}),parent:t});return a&&requestAnimationFrame(()=>o.focus()),c.current=o,()=>o.destroy()},[n,i]),(0,W.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&t.dispatch({changes:{from:0,to:n.length,insert:e}})},[e]),(0,G.jsx)(`div`,{ref:s,className:`calc-line-editor ${o??``}`,"data-testid":`calc-line-editor`})}function Y6({analysis:e}){let{dim:t,compound:n,diagnostics:r}=e,i=r.filter(e=>e.severity===`error`),a=r.filter(e=>e.severity===`warning`),o=i.length===0&&a.length===0&&t!==void 0;return(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,"data-testid":`calc-diagnostics`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[t?(0,G.jsxs)(`div`,{className:`text-muted-foreground`,children:[`computes `,(0,G.jsx)(`b`,{className:`text-foreground`,children:Z6(t)}),n&&(0,G.jsxs)(`span`,{className:`text-purple-400 dark:text-purple-300`,children:[` → `,n]})]}):!o&&(0,G.jsx)(`div`,{className:`text-muted-foreground`,children:`dimension unknown`}),o&&(0,G.jsx)(`span`,{className:`text-signal-positive`,children:`✓ valid`})]}),i.map((e,t)=>(0,G.jsxs)(`div`,{className:`text-destructive`,children:[`⚠ `,e.message]},`e-${t}`)),a.map((e,t)=>(0,G.jsxs)(`div`,{className:`text-signal-caution`,children:[`⚠ `,e.message]},`w-${t}`)),i.length===0&&a.length===0&&t===void 0&&(0,G.jsx)(`div`,{className:`text-muted-foreground`,children:`Type a calc line to see diagnostics.`})]})}var X6=[[`L`,`length`],[`M`,`mass`],[`T`,`time`],[`C`,`count`],[`E`,`energy`]];function Z6(e){let t=[];return e.forEach((e,n)=>{e!==0&&t.push(e===1?X6[n][1]:`${X6[n][1]}${e}`)}),t.length?t.join(`·`):`dimensionless`}function Q6(e){return new ma({outputType:e.outputType,timeSpan:e.timeSpan,sourceBlockKey:e.sourceBlockKey,stackLevel:e.stackLevel,sourceStatementId:e.sourceStatementId,line:e.line,text:e.text,dialect:e.dialect,metrics:e.metrics,parent:e.parent,completionReason:e.completionReason})}function $6(e){return{...e,metrics:e.metrics.filter(e=>e.origin!==`analyzed`)}}function e8(e){return e.output?.emitType??e.output?.key??e.id}function t8(e,t){for(let n of e){if(n.outputType!==`analytics`||!(n.metrics.find(e=>e.type?.toLowerCase()===`label`&&String(e.value)===t)??n.metrics.find(e=>String(e.value)===t)))continue;let e=n.metrics.find(e=>typeof e.value==`number`);if(e)return{value:e.value,unit:e.unit,origin:e.origin}}}function n8(e){return String(Number.isInteger(e)?e:Math.round(e*100)/100)}function r8(e,t,n){return nf(e,{userProfile:t.vo2max===void 0?void 0:{vo2max:t.vo2max},calcs:n}).engine}function i8(e){let t=[],n=e.defs[0];if(!n)return{rows:[],errors:[`No calc line to preview.`]};let r=e8(n),i=e.logs.filter(e=>e.outputType===`segment`);if(e.scope===`segment`){let n=r8(e.block,e,e.defs),a=[];for(let e of i){let t=n.run(Q6($6(e))).metrics.rawMetrics.find(e=>e.type===r);if(!t){a.push(null);continue}let i=typeof t.value==`number`?t.value:NaN;if(!Number.isFinite(i)){a.push(null);continue}a.push({label:e.metrics.find(e=>e.type===`effort-data`)?.value?.label??`segment`,text:n8(i),unit:t.unit,estimated:t.origin===`analyzed-estimated`,raw:i})}return{rows:a,errors:t}}if(e.scope===`workout`){let n=i.map($6),a=[];for(let t=1;t<=n.length;t++){let i=r8(e.block,e,e.defs);for(let e=0;e<t;e++)i.run(Q6(n[e]));let o=t8(i.finalize(),r),s=o&&typeof o.value==`number`?o.value:NaN;o&&Number.isFinite(s)?a.push({label:`after line ${t}`,text:n8(s),unit:o.unit,estimated:o.origin===`analyzed-estimated`,raw:s}):a.push(null)}return{rows:a,errors:t}}return o8(n,t)}var a8=[420,0,380,510,0,290,610,450,0,520,340,0,480,390,560,0,410,470,0,530,360,440,0,500,580,320,0,460];function o8(e,t){let n=[],r=e.variants[0]?.nodes[Hf(e)??`value`]?.expression??``,i=e=>e.reduce((e,t)=>e+t,0)/e.length,a=e=>{let t=i(e);return Math.sqrt(i(e.map(e=>(e-t)**2)))},o=(e,t)=>a8.map((n,r)=>r+1>=e?t(a8.slice(r+1-e,r+1)):NaN),s=o(7,i),c=o(28,i),l=o(7,a),u=o(7,e=>e.reduce((e,t)=>e+t,0)),d=r.includes(`windowSd`)||r.length===0?s.map((e,t)=>e/l[t]):s.map((e,t)=>e/c[t]);return s8(r.includes(`windowSum`)||r.includes(` * sum`)?u:d,n),{rows:[],series:n,errors:t}}function s8(e,t){for(let n of e.slice(-7))t.push(Number.isNaN(n)?null:Number(Math.round(n*100)/100))}var c8=[{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:21,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:21,resistanceKg:0},{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:15,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:15,resistanceKg:0},{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:9,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:9,resistanceKg:0}];function l8(e){return{type:`effort-data`,origin:`analyzed`,value:{slug:e.slug,label:e.label,aliases:[],baseAttributes:{met:e.met,discipline:e.discipline},registrySource:`bundled`}}}function u8(e,t){let n=[l8(e)];return n.push({type:`elapsed`,value:e.elapsedMs,origin:`runtime`}),e.reps!==void 0&&n.push({type:`rep`,value:e.reps,origin:`runtime`}),e.resistanceKg!==void 0&&n.push({type:`resistance`,value:e.resistanceKg,origin:`runtime`}),Cj(new ma({outputType:`segment`,timeSpan:{started:t*1e3,ended:t*1e3+e.elapsedMs},sourceBlockKey:`preview-block`,stackLevel:1,metrics:n}))}function d8(){return{id:`preview-block`,dialect:`time`,startLine:0,endLine:10,content:"```time\nFran preview\n```",state:`idle`,widgetIds:{},version:1,createdAt:0}}var f8=c8.map((e,t)=>u8(e,t+1)),p8=d8();function m8(e){return e==null?`—`:String(e)}function h8({scope:e,analysis:t,vo2max:n}){let r=(0,W.useMemo)(()=>t.defs.filter(()=>t.diagnostics.length===0),[t]),i=r[0],a=(0,W.useMemo)(()=>{if(i)return i8({logs:f8,block:p8,defs:r,scope:e,vo2max:n})},[i,e,n]);return(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60 p-3 text-xs`,"data-testid":`calc-preview`,children:[(0,G.jsxs)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wide text-muted-foreground`,children:[`Live preview — `,e===`store`?`last 7 of 28 fixture days`:`Fran (fixture)`]}),!i&&(0,G.jsx)(`div`,{className:`text-muted-foreground`,children:`Enter a valid calc line to see live results.`}),i&&a?.rows&&(0,G.jsxs)(`div`,{className:`space-y-1 font-mono`,children:[a.rows.length===0&&(0,G.jsx)(`div`,{className:`text-muted-foreground`,children:`No applicable segments.`}),a.rows.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex justify-between text-foreground`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e?e.label:`segment ${t+1}`}),(0,G.jsx)(`span`,{className:e?`text-sky-300 dark:text-sky-400`:`text-muted-foreground`,children:e?`${e.text}${e.unit?` ${e.unit}`:``}${e.estimated?` (est.)`:``}`:`—`})]},t))]}),i&&a?.series&&(0,G.jsx)(`div`,{className:`space-y-1 font-mono`,children:a.series.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex justify-between text-foreground`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`D-`,6-t]}),(0,G.jsx)(`span`,{className:`text-sky-300 dark:text-sky-400`,children:m8(e)})]},t))}),a?.errors?.length?a.errors.map((e,t)=>(0,G.jsxs)(`div`,{className:`text-destructive`,children:[`⚠ `,e]},`e-${t}`)):null]})}var g8=`wodwiki-user-calcs`,_8=1,v8=`calcs`,y8=`user-calc:`,b8;function x8(){return b8||=rr(g8,_8,{upgrade(e){e.objectStoreNames.contains(v8)||e.createObjectStore(v8,{keyPath:`id`})}}),b8}async function S8(){return PD?(await HD(y8)).map(e=>e.value).sort((e,t)=>t.updatedAt-e.updatedAt):(await(await x8()).getAll(v8)).sort((e,t)=>t.updatedAt-e.updatedAt)}async function C8(e){if(PD){await UD(y8+e.id,{id:e.id,lineForm:e.lineForm,updatedAt:e.updatedAt??Date.now()});return}await(await x8()).put(v8,{...e,updatedAt:e.updatedAt??Date.now()})}async function w8(e){if(PD)return WD(y8+e);await(await x8()).delete(v8,e)}var T8=[`segment`,`workout`,`store`];function E8(e,t){let n=e[0]?.id;if(n)return n;let r=/^[\s\S]*?^\s*([A-Za-z_][\w.-]*)\s*=.*$/m.exec(t);return r?r[1]:`custom-${Date.now().toString(36)}`}function D8({defaultScope:e=`segment`,initialId:t}){let[n,r]=(0,W.useState)(`# ${e} calc line
|
|
204
204
|
segmentVolume = reps * resistance (library) when has(reps) and has(resistance)
|
|
205
205
|
`),[i,a]=(0,W.useState)(e),[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)(),u=(0,W.useMemo)(()=>T6(n,i),[n,i]),d=E8(u.defs,n),f=u.diagnostics.every(e=>e.severity!==`error`)&&u.defs.length>0,p=async()=>{s(await S8())};(0,W.useEffect)(()=>{p()},[]),(0,W.useEffect)(()=>{t&&(async()=>{let e=(await S8()).find(e=>e.id===t);e&&(r(e.lineForm),l(`Loaded "${e.id}".`))})()},[t]);let m=async()=>{if(!f){l(`Cannot save: fix the errors first.`);return}try{await C8({id:d,lineForm:n,updatedAt:Date.now()}),await p(),l(`Saved "${d}".`)}catch(e){console.error(`[CalcAuthoringPanel] save failed:`,e),l(`Save failed: ${e instanceof Error?e.message:String(e)}`)}},h=async e=>{try{await w8(e),await p(),l(`Deleted "${e}".`)}catch(e){console.error(`[CalcAuthoringPanel] delete failed:`,e),l(`Delete failed: ${e instanceof Error?e.message:String(e)}`)}},g=e=>{let t=/^\s*(segment|workout|store)\b/.exec(e.lineForm);t&&a(t[1]),r(e.lineForm),l(`Loaded "${e.id}".`)};return(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`calc-authoring-panel`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Scope`}),(0,G.jsx)(`div`,{className:`flex gap-1`,children:T8.map(e=>(0,G.jsx)(`button`,{onClick:()=>a(e),className:`rounded px-2.5 py-1 text-xs font-medium transition-colors ${i===e?`bg-purple-600 text-white dark:bg-purple-700 dark:text-white`:`bg-muted text-muted-foreground hover:bg-muted/80`}`,children:e},e))}),(0,G.jsx)(`div`,{className:`ml-auto flex gap-2`,children:(0,G.jsx)(`button`,{onClick:m,disabled:!f,className:`rounded bg-signal-positive px-3 py-1 text-xs font-medium text-white dark:text-white disabled:opacity-40`,children:`Save`})})]}),(0,G.jsx)(J6,{value:n,onChange:r,scope:i,autoFocus:!0}),(0,G.jsx)(Y6,{analysis:u}),(0,G.jsx)(h8,{scope:i,analysis:u}),c&&(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:c}),o.length>0&&(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Saved user calcs`}),(0,G.jsx)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:o.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center justify-between px-3 py-2 text-sm`,children:[(0,G.jsx)(`button`,{onClick:()=>g(e),className:`text-left font-mono text-purple-300 dark:text-purple-400 hover:underline`,children:e.id}),(0,G.jsx)(`button`,{onClick:()=>h(e.id),className:`text-xs text-muted-foreground hover:text-destructive`,children:`delete`})]},e.id))})]})]})}function O8(){let e=yn(),[t]=Ht(`zip`),[n]=Ht(`z`),[r]=(0,W.useState)(()=>{let e=window.location.search;return e.includes(`zip=`)||e.includes(`z=`)});return(0,W.useEffect)(()=>{!t&&!n&&!r&&e(`/`,{replace:!0})},[t,n,e,r]),(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`})}async function k8(e){try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4!=0;)t+=`=`;let n=atob(t),r=Uint8Array.from(n,e=>e.charCodeAt(0));try{let e=new DecompressionStream(`gzip`),t=e.writable.getWriter(),n=e.readable.getReader();t.write(r),t.close();let i=[];for(;;){let{done:e,value:t}=await n.read();if(e)break;i.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return new TextDecoder().decode(o)}catch{return new TextDecoder().decode(r)}}catch{return null}}function A8(){let e=yn(),t=dt(),{date:n}=In(),[r]=Ht(`zip`),[i,a]=(0,W.useState)({state:`loading`});return(0,W.useEffect)(()=>{if(!(t.pathname===`/load/journal`||t.pathname.startsWith(`/load/journal/`)))return;if(!r){e($.journal,{replace:!0});return}let i=!1,o=async()=>{try{a({state:`loading`});let t;try{t=await k8(r)}catch(e){console.error(`Failed to decode zip:`,e),a({state:`error`,error:`Failed to decode the journal entry`,onRetry:()=>{o()}}),Q({title:`Error`,description:`Failed to decode the journal entry. Please check the link.`,variant:`destructive`});return}if(i)return;let c;if(n){let t=Jj(n);if(!t){a({state:`error`,error:`Invalid date format`}),Q({title:`Error`,description:`Invalid date format. Expected YYYY-MM-DD.`,variant:`destructive`}),e($.journal,{replace:!0});return}c=t.dateKey}else c=Kj();if(i)return;if(qj(c)){a({state:`pending-confirmation`,content:t,dateKey:c,onConfirmBackdate:async()=>{i||await s(t,c)}});return}await s(t,c)}catch(e){console.error(`Unexpected error in journal zip processor:`,e),i||(a({state:`error`,error:`An unexpected error occurred`,onRetry:()=>{o()}}),Q({title:`Error`,description:`An unexpected error occurred.`,variant:`destructive`}))}},s=async(t,n)=>{if(!i)try{a({state:`creating`});let r=await Zj.create({journalDate:n,title:n,rawContent:t});i||(a({state:`success`,content:t,dateKey:n}),e(QA(r.id),{replace:!0}))}catch(e){console.error(`Failed to create journal entry:`,e),i||(a({state:`error`,error:`Failed to create journal entry`,onRetry:()=>{s(t,n)}}),Q({title:`Error`,description:`Failed to create journal entry.`,variant:`destructive`}))}};return o(),()=>{i=!0}},[r,n,e]),i}var j8=({selectedDate:e,onImportToday:t,onDateSelect:n,entryDates:r,isLoading:i=!1,className:a})=>{let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1),{triggerRef:u,align:d,recompute:f}=IZ(`end`),p=async()=>{l(!0);try{await t()}finally{l(!1)}},m=async e=>{l(!0),s(!1);try{await n(e)}finally{l(!1)}},h=e=>{e&&f(),s(e)},g=e?qP(e):`Date`,_=i||c;return(0,G.jsxs)(`div`,{className:K(`inline-flex items-stretch rounded-lg overflow-hidden border border-border/70`,`bg-muted text-muted-foreground shadow-sm hover:shadow-md transition-shadow font-medium`,`text-xs`,a),children:[(0,G.jsxs)(`button`,{type:`button`,title:`Import to today's journal`,onClick:p,disabled:_,className:K(`flex items-center gap-2 px-3 py-2 transition-colors`,`hover:bg-accent hover:text-accent-foreground`,_&&`opacity-60 cursor-not-allowed`),children:[c?(0,G.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}):(0,G.jsx)(Un,{className:`h-4 w-4 shrink-0`}),(0,G.jsx)(`span`,{children:`Import Today`})]}),(0,G.jsx)(`div`,{className:`w-px bg-border/60 self-stretch`}),(0,G.jsxs)(HL,{open:o,onOpenChange:h,children:[(0,G.jsx)(UL,{asChild:!0,children:(0,G.jsxs)(`button`,{ref:e=>{u.current=e},type:`button`,title:`Select a date to plan for the future`,className:K(`flex items-center gap-1.5 px-2.5 py-2 transition-colors`,`hover:bg-accent hover:text-accent-foreground`,e&&`text-primary`,_&&`opacity-60 cursor-not-allowed`),disabled:_,children:[(0,G.jsx)(Bt,{className:`h-4 w-4 shrink-0`}),e&&(0,G.jsx)(`span`,{className:`leading-none text-xs`,children:g})]})}),(0,G.jsx)(WL,{align:d,className:`p-0 w-auto`,children:(0,G.jsx)(iZ,{selectedDate:e||null,onDateSelect:m,entryDates:r})})]})]})},M8=({dateKey:e,onConfirm:t,onCancel:n,isLoading:r=!1})=>{let[i,a]=W.useState(!1),o=KP(new Date(`${e}T00:00:00`));return(0,G.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center`,onKeyDown:e=>{e.key===`Escape`&&n()},onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/50 animate-in fade-in`}),(0,G.jsx)(`div`,{className:`relative z-10 w-full max-w-sm mx-auto px-4 animate-in zoom-in-95 fade-in`,children:(0,G.jsxs)(`div`,{className:`bg-background rounded-lg border border-border shadow-lg`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border`,children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:`Backdate Journal Entry`}),(0,G.jsx)(`button`,{onClick:n,className:`p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors`,"aria-label":`Close modal`,children:(0,G.jsx)(Se,{className:`h-4 w-4`})})]}),(0,G.jsxs)(`div`,{className:`px-6 py-4 space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The date you selected is in the past.`}),(0,G.jsxs)(`p`,{className:`text-sm`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Import to: `}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:o})]}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This will create a journal entry for the selected date. Are you sure you want to proceed?`})]}),(0,G.jsxs)(`div`,{className:`px-6 py-4 border-t border-border flex gap-2 justify-end`,children:[(0,G.jsx)(q,{variant:`outline`,onClick:n,disabled:r||i,children:`Cancel`}),(0,G.jsx)(q,{onClick:async()=>{a(!0);try{await t()}finally{a(!1)}},disabled:r||i,className:K(r||i?`opacity-70`:``),children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`inline-block animate-spin mr-2`,children:`⏳`}),`Importing...`]}):`Confirm & Import`})]})]})})]})},N8={h1:({children:e})=>(0,G.jsx)(`h1`,{className:`text-3xl font-bold mt-8 mb-4 first:mt-0 text-foreground`,children:e}),h2:({children:e})=>(0,G.jsx)(`h2`,{className:`text-2xl font-bold mt-6 mb-3 text-foreground`,children:e}),h3:({children:e})=>(0,G.jsx)(`h3`,{className:`text-xl font-semibold mt-5 mb-2 text-foreground`,children:e}),h4:({children:e})=>(0,G.jsx)(`h4`,{className:`text-lg font-semibold mt-4 mb-2 text-foreground`,children:e}),h5:({children:e})=>(0,G.jsx)(`h5`,{className:`text-base font-semibold mt-3 mb-1 text-foreground`,children:e}),h6:({children:e})=>(0,G.jsx)(`h6`,{className:`text-sm font-semibold mt-2 mb-1 text-muted-foreground`,children:e}),p:({children:e})=>(0,G.jsx)(`p`,{className:`text-sm leading-relaxed mb-4 text-muted-foreground`,children:e}),strong:({children:e})=>(0,G.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,G.jsx)(`em`,{className:`italic text-muted-foreground`,children:e}),ul:({children:e})=>(0,G.jsx)(`ul`,{className:`list-disc list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),ol:({children:e})=>(0,G.jsx)(`ol`,{className:`list-decimal list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),li:({children:e})=>(0,G.jsx)(`li`,{className:`ml-2`,children:e}),code:({children:e,className:t})=>t?null:(0,G.jsx)(`code`,{className:`px-1.5 py-0.5 rounded bg-muted text-primary font-mono text-xs`,children:e}),pre:({children:e})=>(0,G.jsx)(`pre`,{className:`bg-muted rounded-lg p-4 overflow-x-auto mb-4 text-xs font-mono text-muted-foreground border border-border`,children:e}),blockquote:({children:e})=>(0,G.jsx)(`blockquote`,{className:`border-l-4 border-primary/30 pl-4 py-2 mb-4 italic text-muted-foreground text-sm`,children:e}),a:({href:e,children:t})=>(0,G.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline font-medium`,children:t}),table:({children:e})=>(0,G.jsx)(`div`,{className:`my-4 overflow-x-auto rounded border border-border`,children:(0,G.jsx)(`table`,{className:`w-full text-xs`,children:e})}),thead:({children:e})=>(0,G.jsx)(`thead`,{className:`bg-muted/50`,children:e}),tbody:({children:e})=>(0,G.jsx)(`tbody`,{className:`divide-y divide-border/50`,children:e}),tr:({children:e})=>(0,G.jsx)(`tr`,{className:`hover:bg-muted/20 transition-colors`,children:e}),th:({children:e})=>(0,G.jsx)(`th`,{className:`px-3 py-2 text-left font-semibold text-foreground text-xs`,children:e}),td:({children:e})=>(0,G.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e}),hr:()=>(0,G.jsx)(`hr`,{className:`my-6 border-border/50`})};function P8(){let e=yn(),t=A8(),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(null),{state:o,content:s,dateKey:c,error:l,onConfirmBackdate:u,onRetry:d}=t;return(0,G.jsxs)(`div`,{className:`flex flex-col h-screen bg-background`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/50 bg-muted/30 px-6 py-4 flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`button`,{onClick:()=>{e(-1)},className:`p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Go back`,children:(0,G.jsx)(nr,{className:`h-5 w-5`})}),(0,G.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Import Journal Entry`})]}),o===`loading`?(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}),`Preparing preview...`]}):o===`error`?(0,G.jsx)(q,{variant:`outline`,size:`sm`,onClick:d,children:`Retry`}):o===`pending-confirmation`||o===`creating`?null:(0,G.jsx)(j8,{selectedDate:i,onImportToday:async()=>{u&&await u()},onDateSelect:async e=>{a(e);let t=new Date;t.setHours(0,0,0,0);let n=new Date(e);n.setHours(0,0,0,0),n<t?r(!0):u&&await u()},isLoading:o===`creating`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-6`,children:[o===`loading`&&(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,G.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading preview...`})]}),o===`error`&&(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,G.jsx)(`div`,{className:`bg-destructive/10 border border-destructive/50 rounded-lg p-4 max-w-md`,children:(0,G.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,G.jsx)(Yt,{className:`h-5 w-5 text-destructive mt-0.5 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Error Loading Preview`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:l||`Failed to decode the zip content`})]})]})}),(0,G.jsx)(q,{onClick:d,variant:`outline`,children:`Try Again`})]}),o===`pending-confirmation`&&(0,G.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`Backdate Confirmation Required`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`This date is in the past. Please confirm to proceed.`})]})}),o===`creating`&&(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,G.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Creating journal entry...`})]}),o===`success`&&(0,G.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`✓ Entry Created`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Redirecting...`})]})}),o===`loading`||o===`error`||o===`pending-confirmation`||o===`creating`||o===`success`?null:s?(0,G.jsx)(`article`,{className:`prose prose-sm max-w-2xl mx-auto`,children:(0,G.jsx)(pn,{remarkPlugins:[Bn],components:N8,children:s})}):null]}),n&&c&&(0,G.jsx)(M8,{dateKey:c,onConfirm:async()=>{u&&(r(!1),await u())},onCancel:()=>r(!1),isLoading:o===`creating`})]})}function F8(){let e=dt(),t=yn(),[n,r]=(0,W.useState)({kind:`loading`}),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null);(0,W.useEffect)(()=>{let n=!0,i=new URLSearchParams(e.search).get(`source`);if(!i){t($.catalogs,{replace:!0});return}return r({kind:`loading`}),a(!1),l(null),(async()=>{try{let e=new URL(i);if(e.protocol!==`https:`||e.username||e.password||e.search||e.hash)throw Error(`Enter an HTTPS seed directory URL without credentials, query parameters, or a fragment.`);e.pathname.endsWith(`/`)||(e.pathname+=`/`);let t=await new tk(e.href).fetchManifest();n&&r({kind:`ready`,url:e.href,manifest:t})}catch(e){n&&r({kind:`error`,message:e instanceof Error?e.message:`Unable to read the seed manifest.`})}})(),()=>{n=!1}},[e.search,t]);let u=async e=>{if(!(n.kind!==`ready`||o)){s(!0),l(null);try{let r=gk().find(e=>qD(new URL(e.url,window.location.href).href)===n.url)??eO(n.manifest.name?.trim()||new URL(n.url).hostname,n.url,{repositoryUrl:n.manifest.repositoryUrl}),a=await Lk(r.id,{subscribe:!1});if(a!==`imported`&&a!==`current`)throw Error(`Seed import did not complete (${a}). Your existing content was kept.`);if(e){let e=FO(r.id,i),t=jO(r.id,!0);if(!e||!t)throw Error(`Content imported, but subscription preferences could not be saved. Browser storage is unavailable; these choices last this session only.`)}t(`${$.catalogs}?manage=1`,{replace:!0})}catch(e){l(e instanceof Error?e.message:`Seed import failed. Your existing content was kept.`)}finally{s(!1)}}};return(0,G.jsxs)(`main`,{className:`mx-auto flex min-h-dvh w-full max-w-2xl flex-col justify-center gap-5 p-6`,"data-testid":`catalog-subscription-intake`,children:[n.kind===`loading`&&(0,G.jsx)(`p`,{role:`status`,children:`Checking the seed manifest…`}),n.kind===`error`&&(0,G.jsx)(`p`,{role:`alert`,className:`break-words text-destructive`,children:n.message}),n.kind===`ready`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`h1`,{className:`text-xl font-semibold`,children:[`Subscribe to `,n.manifest.name?.trim()||new URL(n.url).hostname,`?`]}),(0,G.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all text-sm underline`,children:n.url}),n.manifest.description&&(0,G.jsx)(`p`,{children:n.manifest.description}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Opening this link has not added any content or source. Choose whether to import once or subscribe for future update checks.`}),(0,G.jsxs)(`dl`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,G.jsx)(`dt`,{children:`Published version`}),(0,G.jsxs)(`dd`,{children:[`v`,n.manifest.version]}),(0,G.jsx)(`dt`,{children:`Published at`}),(0,G.jsx)(`dd`,{children:new Date(n.manifest.builtAt).toLocaleString()}),(0,G.jsx)(`dt`,{children:`Schema`}),(0,G.jsxs)(`dd`,{children:[`v`,n.manifest.schema]}),(0,G.jsx)(`dt`,{children:`Chunks`}),(0,G.jsx)(`dd`,{children:n.manifest.chunks.length}),(0,G.jsx)(`dt`,{children:`Catalog items`}),(0,G.jsx)(`dd`,{children:n.manifest.chunks.reduce((e,t)=>e+t.count,0)}),(0,G.jsx)(`dt`,{children:`Download size`}),(0,G.jsxs)(`dd`,{children:[(n.manifest.chunks.reduce((e,t)=>e+t.bytes,0)/1024).toFixed(1),` KB`]})]}),n.manifest.repositoryUrl&&(0,G.jsx)(`a`,{href:n.manifest.repositoryUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm underline`,children:`Git source directory`}),(0,G.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-border p-4`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),disabled:o,"aria-label":`Auto-sync this seed`,className:`mt-1 size-4 shrink-0`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Auto-sync this seed`}),(0,G.jsx)(`span`,{className:`mt-1 block text-sm text-muted-foreground`,children:`When subscribed, apply new versions in the background on page load. Off keeps updates manual. Import Once ignores this preference and creates no subscription.`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,G.jsx)(q,{variant:`outline`,disabled:o,onClick:()=>void u(!1),children:`Import Once`}),(0,G.jsx)(q,{disabled:o,onClick:()=>void u(!0),children:o?`Importing…`:`Import & Subscribe`})]})]}),c&&(0,G.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c}),(0,G.jsx)(q,{variant:`ghost`,disabled:o,onClick:()=>t($.catalogs,{replace:!0}),children:`Decline & Dismiss`})]})}async function I8(e,t,n){let r=await Z.getNote(e);if(!r)return;let i=`:session{result:${n}}`;if(r.rawContent.includes(i))return;let a=Object.values(r.blocks??{}).find(e=>e.id===t);if(!a||a.to==null)return;let o=`${r.rawContent.slice(0,a.to)}\n\n\`\`\`query:table\n${i}\n\`\`\`${r.rawContent.slice(a.to)}`;await new DD().updateEntry(r.id,{rawContent:o,expectedSourceRevision:r.sourceRevision})}function L8(){let{runtimeId:e}=In(),t=yn(),n=(0,W.useRef)(e?cZ.get(e):void 0),r=(0,W.useRef)(null),i=(0,W.useCallback)(async()=>{let t=n.current;if(!t||!e)throw Error(`The pending workout is unavailable.`);return t.captured?(r.current=t.captured,t.captured.block):(r.current||=t.snapshot?await bF(t.snapshot,t.block,e,t.origin):await xF(t.noteId,t.block,e,t.origin),r.current.block)},[e]);(0,W.useEffect)(()=>{e&&cZ.delete(e)},[e]);let a=n.current,o=(0,W.useRef)(!1),s=(0,W.useCallback)((t,n)=>!n||!e||!a?Promise.reject(Error(`Run cannot be saved — its session data or runtime id is missing.`)):(o.current=n.completed,YH.record({runBlock:a.block,blockId:a.block.id,noteId:a.noteId,resultId:e,data:n,createdAt:n.endTime||Date.now(),...a.origin?{origin:a.origin}:{}}).then(async()=>{if(n.completed)try{await I8(a.noteId,a.block.id,e)}catch{}})),[e,a]),c=(0,W.useCallback)(()=>{if(!a){t(`/`);return}if(o.current){t(aj(e),{replace:!0});return}if(a.returnTo){t(a.returnTo,{replace:!0});return}t(_Z(tI(a.noteId)),{replace:!0})},[e,a,t]);return a?(0,G.jsx)($q,{block:a.block,prepareRun:i,onClose:c,onCompleteWorkout:s,resultId:e,autoStart:!0}):(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-red-400`,children:`Runtime not found. Please start the workout from the editor.`})}var R8=null;async function z8(e){(!R8||R8.attempt!==e)&&(R8={attempt:e,promise:dW(HZ.content)});try{return await R8.promise}finally{R8?.attempt===e&&(R8=null)}}function B8(){let e=yn(),[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await z8(r);t||e(YA(n),{replace:!0})}catch{t||n(!0)}})(),()=>{t=!0}},[e,r]),t?(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-3 text-zinc-300 px-4 text-center`,children:[(0,G.jsx)(`p`,{role:`alert`,children:`Unable to create a new playground note.`}),(0,G.jsx)(`button`,{type:`button`,className:`rounded border border-zinc-600 px-3 py-1 text-sm hover:bg-zinc-800`,onClick:()=>{n(!1),i(e=>e+1)},children:`Try again`})]}):(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`})}function V8(){let e=yn(),t=dt(),[n]=Ht(`zip`),[r]=Ht(`z`),[i]=Ht(`by`),[a]=Ht(`src`);(0,W.useEffect)(()=>{if(t.pathname!==`/load`&&!(t.pathname===`/`&&r))return;if(r){let t=!1;return(async()=>{try{let e=await k8(r);if(e===null)throw Error(`Invalid workout link`);if(t)return;let n=GZ(e,i??void 0);if(await fW(n,{reuseKey:`home`,title:`Home playground`}),t)return;JZ({content:n,by:i??void 0})}catch(e){console.error(`Failed to decode zip:`,e),t||Q({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`})}t||e(`/`,{replace:!0})})(),()=>{t=!0}}if(!n)return;let o=!1,s=a&&a.startsWith(`/`)?a:void 0;return(async()=>{try{let t=await k8(n);if(t===null)throw Error(`Invalid workout link`);if(o)return;let r=s?await dW(t,{sourcePath:s}):await dW(t);o||e(YA(r),{replace:!0})}catch(t){console.error(`Failed to decode zip:`,t),o||(Q({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`}),e($.home,{replace:!0}))}})(),()=>{o=!0}},[n,r,i,a,e,t.pathname])}function H8(){let{pathname:e,hash:t}=dt(),{scrollToSection:n}=bA();return(0,W.useEffect)(()=>{if(t){let e=t.slice(1);n(e);let r=setTimeout(()=>{n(e)},50);return()=>clearTimeout(r)}window.scrollTo(0,0)},[e,t]),null}function U8(){return V8(),A8(),(0,W.useEffect)(()=>{lD.current().catch(console.error),$E(),q$()},[]),null}function W8({settling:e}){return e?(0,G.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Loading library…`}):(0,G.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold`,children:`The library's routed content failed to load.`}),(0,G.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:`The seed corpus is missing the root page. Re-running the seed import usually restores it.`}),(0,G.jsx)(q,{variant:`outline`,size:`sm`,"data-testid":`root-reseed`,onClick:()=>{Pk().then(()=>JE())},children:`Re-seed library`})]})}function G8(){let e=(0,W.useRef)(()=>{}),t=IP(),n=G$(),r=(0,W.useMemo)(()=>aP(()=>e.current(),t),[t]);return(0,G.jsx)(Di,{defaultTheme:`system`,storageKey:`wod-wiki-playground-theme`,children:(0,G.jsx)(Bv,{children:(0,G.jsx)(Gk,{children:(0,G.jsx)(Jk,{children:(0,G.jsx)(QO,{children:(0,G.jsx)(kt,{children:(0,G.jsxs)(i,{children:[(0,G.jsx)(U8,{}),(0,G.jsx)(hA,{}),(0,G.jsxs)(SA,{tree:r,children:[(0,G.jsx)(H8,{}),(0,G.jsxs)(qt,{children:[(0,G.jsx)(H,{path:`*`,element:t.some(({route:e})=>e===$.home)?(0,G.jsx)(x3,{}):(0,G.jsx)(W8,{settling:n===`preparing`})}),(0,G.jsx)(H,{path:`/proto/calc-authoring`,element:(0,G.jsx)(i6,{})}),(0,G.jsx)(H,{path:`/proto/query-block-composer`,element:(0,G.jsx)(x6,{})}),(0,G.jsx)(H,{path:`/settings`,element:(0,G.jsx)(mn,{to:`/settings/appearance`,replace:!0})}),(0,G.jsx)(H,{path:`/settings/appearance`,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsProfile,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsData,element:(0,G.jsx)(mn,{to:$.settingsStorage,replace:!0})}),(0,G.jsx)(H,{path:$.settingsDatabase,element:(0,G.jsx)(mn,{to:$.settingsStorage,replace:!0})}),(0,G.jsx)(H,{path:$.settingsStorage,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsSync,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:`/settings/system`,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsQueries,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsTags,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:`/settings/library/calcs`,element:(0,G.jsx)(`div`,{className:`p-6`,children:(0,G.jsx)(D8,{})})}),(0,G.jsx)(H,{path:`/legacy`,element:(0,G.jsx)(a3,{})}),(0,G.jsx)(H,{path:`/syntax`,element:(0,G.jsx)(b3,{})}),(0,G.jsx)(H,{path:`/chapters/basics`,element:(0,G.jsx)(mn,{to:`/guide/start`,replace:!0})}),(0,G.jsx)(H,{path:`/chapters/sequences`,element:(0,G.jsx)(mn,{to:`/guide/start`,replace:!0})}),(0,G.jsx)(H,{path:`/chapters/protocols`,element:(0,G.jsx)(mn,{to:`/guide/protocols`,replace:!0})}),(0,G.jsx)(H,{path:`/challenge`,element:(0,G.jsx)(mn,{to:`/`,replace:!0})}),(0,G.jsx)(H,{path:$.plan,element:(0,G.jsx)(G4,{})}),(0,G.jsx)(H,{path:$.feeds,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.feed,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.feedDetail,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.feedItem,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.catalogs,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.subscribe,element:(0,G.jsx)(F8,{})}),(0,G.jsx)(H,{path:$.collections,element:(0,G.jsx)(R4,{})}),(0,G.jsx)(H,{path:`/collections/:slug`,element:(0,G.jsx)(L4,{})}),(0,G.jsx)(H,{path:`/collections/:slug/:target`,element:(0,G.jsx)(L4,{})}),(0,G.jsx)(H,{path:$.collection,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.collectionTarget,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.load,element:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,G.jsx)(O8,{})})}),(0,G.jsx)(H,{path:$.loadJournal,element:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,G.jsx)(P8,{})})}),(0,G.jsx)(H,{path:$.loadJournalDate,element:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,G.jsx)(P8,{})})}),(0,G.jsx)(H,{path:$.playgroundRoot,element:(0,G.jsx)(B8,{})}),(0,G.jsx)(H,{path:$.playground,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.playgrounds,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.notePlaygroundAlias,element:(0,G.jsx)(F4,{})}),(0,G.jsx)(H,{path:$.note,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.journalNote,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.journalEntry,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.noteById,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.journal,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.pages,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.run,element:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,G.jsx)(L8,{})})}),(0,G.jsx)(H,{path:$.tracker,element:(0,G.jsx)(U4,{})}),(0,G.jsx)(H,{path:`/results`,element:(0,G.jsx)(B4,{})}),(0,G.jsx)(H,{path:`/results/segments`,element:(0,G.jsx)(V4,{})}),(0,G.jsx)(H,{path:$.sessionDetail,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.sessions,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.sessionDate,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:`/review/:runtimeId`,element:(0,G.jsx)(W4,{})}),(0,G.jsx)(H,{path:`/note/:noteId/review`,element:(0,G.jsx)(W4,{})}),(0,G.jsx)(H,{path:`/note/:noteId/review/:sectionId`,element:(0,G.jsx)(W4,{})}),(0,G.jsx)(H,{path:`/note/:noteId/review/:sectionId/:resultId`,element:(0,G.jsx)(W4,{})}),(0,G.jsx)(H,{path:`/workout/:category/:name`,element:(0,G.jsx)(I4,{})}),(0,G.jsx)(H,{path:$.efforts,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.effort,element:(0,G.jsx)(z4,{})}),(0,G.jsx)(H,{path:$.effortSlug,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.equipment,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.equipmentSlug,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.dashboard,element:(0,G.jsx)(H4,{})}),(0,G.jsx)(H,{path:$.dashboards,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.dashboardView,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.dashboardSlug,element:(0,G.jsx)(N4,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.analytics,element:(0,G.jsx)(mn,{to:`/dashboards`,replace:!0})}),(0,G.jsx)(H,{path:$.analyticsExplorer,element:(0,G.jsx)(K4,{})}),t.map(({route:t})=>(0,G.jsx)(H,{path:t,element:(0,G.jsx)(N4,{searchHandlerRef:e})},t))]}),(0,G.jsx)(Z4,{})]})]})})})})})})})}function K8({error:e,onRetry:t}){let n=e instanceof Error?e.message:String(e);return oD(),(0,G.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold`,children:`The API data store could not be opened.`}),(0,G.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground font-mono break-all`,"data-testid":`boot-recovery-error`,children:n}),(0,G.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`Your stored data has not been cleared. Retry after resolving the error above.`,!1]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`boot-recovery-retry`,className:`rounded-md border border-border bg-card px-3 py-1.5 text-xs font-medium hover:bg-accent`,children:`Retry`}),!1]}),!1]})}function q8(){let e=(0,W.useSyncExternalStore)(sb,ob),t=e.phase===`updating`;return(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex min-h-dvh flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold`,children:t?`Updating local database…`:`Checking for storage updates…`}),t&&e.fromVersion!==null&&(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Schema v`,e.fromVersion,` → v`,e.toVersion]}),e.message&&(0,G.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e.message})]})}var J8=(0,Ti.createRoot)(document.getElementById(`root`));function Y8(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(0),o=(0,W.useSyncExternalStore)(sb,ob);return(0,W.useEffect)(()=>{let e=!1,n;return mD().then(()=>PD?zD():void 0).then(()=>{e||(n=_D(),t(!0))}).catch(t=>{e||r(t)}),()=>{e=!0,n?.()}},[i]),n?(0,G.jsx)(K8,{error:n,onRetry:()=>{r(null),a(e=>e+1)}}):o.phase===`checking`||o.phase===`updating`?(0,G.jsx)(q8,{}):e?(0,G.jsx)(G8,{}):(0,G.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Loading…`})}J8.render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(Y8,{})}));export{hz as t};
|
|
206
|
-
//# sourceMappingURL=main-
|
|
206
|
+
//# sourceMappingURL=main-59F7JOmq.js.map
|