@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-BxaSCews.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,Ct as g,D as _,Dn as v,Dr as y,Dt as b,E as x,En as S,Er as C,Et as w,F as T,Fn as E,Fr as D,Ft as O,G as k,Gn as A,Gr as j,Gt as M,H as N,Hn as P,Hr as F,Ht as I,I as L,In as R,Ir as ee,It as z,J as te,Jn as ne,Jr as re,Jt as ie,K as ae,Kn as oe,Kr as B,Kt as se,L as V,Ln as ce,Lr as le,Lt as ue,M as de,Mn as fe,Mr as pe,N as me,Nn as he,Nr as ge,O as _e,On as ve,Or as ye,P as be,Pn as xe,Pr as Se,Pt as Ce,Q as we,Qn as Te,Qr as Ee,Qt as De,R as Oe,Rn as ke,Rr as Ae,Rt as je,S as Me,Sn as Ne,Sr as Pe,St as Fe,T as Ie,Tn as Le,Tr as Re,U as ze,Un as Be,Ur as Ve,Ut as He,V as Ue,Vn as We,Vr as Ge,Vt as Ke,W as qe,Wn as Je,Wr as Ye,Wt as Xe,X as Ze,Xn as Qe,Xr as $e,Xt as et,Y as tt,Yn as nt,Yr as rt,Yt as it,Z as at,Zn as ot,Zr as st,Zt as ct,_ as lt,_n as ut,_r as dt,_t as ft,a as pt,ai as mt,an as ht,ar as gt,at as _t,b as vt,bn as yt,br as bt,bt as xt,c as St,ci as Ct,cn as wt,cr as Tt,ct as Et,d as Dt,di as Ot,dn as kt,dr as At,dt as jt,ei as Mt,en as Nt,er as Pt,et as Ft,f as It,fi as Lt,fn as Rt,fr as zt,ft as Bt,g as Vt,gn as Ht,gr as Ut,gt as Wt,h as Gt,hn as Kt,hr as qt,ht as Jt,i as Yt,ii as Xt,in as Zt,ir as Qt,it as $t,j as en,jn as tn,jr as nn,k as rn,kn as an,kr as on,l as sn,li as cn,ln,lr as un,lt as dn,m as fn,mn as pn,mr as mn,mt as hn,n as gn,ni as _n,nn as vn,nr as yn,nt as bn,o as xn,oi as Sn,on as Cn,or as wn,ot as Tn,p as En,pn as Dn,pr as On,pt as kn,q as An,qn as jn,qr as Mn,qt as Nn,r as Pn,ri as H,rn as Fn,rr as In,rt as Ln,s as Rn,si as zn,sn as Bn,sr as Vn,st as Hn,t as Un,ti as Wn,tn as Gn,tr as Kn,tt as qn,u as Jn,ui as Yn,un as Xn,ur as Zn,ut as Qn,v as $n,vn as er,vr as tr,vt as nr,w as rr,wn as ir,wr as ar,wt as or,x as sr,xn as cr,xr as lr,xt as ur,y as dr,yn as fr,yr as pr,yt as mr,z as hr,zn as gr,zr as _r,zt as vr}from"./vendor-BFExl-KH.js";import{$ as yr,A as br,B as U,C as xr,D as Sr,E as Cr,F as wr,G as Tr,H as Er,I as Dr,J as Or,K as kr,L as Ar,M as jr,N as Mr,O as Nr,P as Pr,Q as Fr,R as Ir,S as Lr,T as Rr,U as zr,V as Br,W as Vr,X as Hr,Y as Ur,Z as Wr,_ as Gr,a as Kr,at as qr,b as Jr,c as Yr,ct as Xr,d as Zr,et as Qr,f as $r,g as ei,h as ti,i as ni,it as ri,j as ii,k as ai,l as oi,lt as si,m as ci,n as li,nt as ui,o as di,ot as fi,p as pi,q as mi,r as hi,rt as gi,s as _i,st as vi,t as yi,tt as bi,u as xi,ut as Si,v as Ci,w as wi,x as Ti,y as Ei,z as Di}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 Oi=Yn(),W=e(Lt(),1),G=Ee(),ki=(0,W.createContext)({theme:`system`,setTheme:()=>null});function Ai({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)(ki.Provider,{value:o,children:e})}var ji=()=>{let e=(0,W.useContext)(ki);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function K(...e){return y(st(e))}function Mi(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 Ni=ye(`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?on:`button`;return(0,G.jsx)($e,{as:o,className:K(Ni({variant:t,size:n,className:e})),ref:a,...i})}));q.displayName=`Button`;var Pi=[`parser`,`dialect`,`user-plan`,`runtime`,`user-entry`],Fi={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 Ii(e){return Fi[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}({}),Li={parser:0,dialect:1,"user-plan":2,runtime:3,"user-entry":4};function Ri(e){return e.ownershipLayer??Ii(e.origin)}function zi(e){return Li[Ri(e)]??0}function Bi(e){return e.map((e,t)=>{let n=Ri(e);return{metric:e,type:e.type,layer:n,layerRank:Li[n]??0,index:t,isSuppressor:e.action===`suppress`}})}function Vi(e,t){return t?e.filter(e=>!(t.types&&!t.types.includes(e.type)||t.layers&&!t.layers.includes(e.layer))):[...e]}function Hi(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 Ui(e){let t;for(let n of e)n.isSuppressor||(t==null||n.layerRank>t)&&(t=n.layerRank);return t}function Wi(e,t){return{metric:e.metric,type:e.type,layer:e.layer,outcome:t}}function Gi(e,t){return e.index-t.index}function Ki(e){let t=Bi(e);return{raw(e){return Vi(t,e).map(e=>e.metric)},visible(e){let n=Hi(Vi(t,e)),r=[];for(let e of n.values()){if(e.some(e=>e.isSuppressor))continue;let t=Ui(e);if(t!=null)for(let n of e)!n.isSuppressor&&n.layerRank===t&&r.push(n)}return r.sort(Gi),r.map(e=>e.metric)},byLayer(e){let n=Vi(t,e),r={};for(let e of Pi)r[e]=[];for(let e of n)r[e.layer].push(e.metric);for(let e of Pi)r[e]?.length===0&&delete r[e];return r},promotionCandidates(e){let n=Hi(Vi(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:Pi[i]});continue}let i=Ui(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:Pi[i]})}return r.sort((e,t)=>{let n=(Li[t.layer]??0)-(Li[e.layer]??0);return n===0?0:n}),r},explain(e){let n=Hi(Vi(t,e)),r=[];for(let[e,t]of n.entries()){let n=t.some(e=>e.isSuppressor),i=n?void 0:Ui(t),a=t.map(e=>e.isSuppressor?Wi(e,`suppressor`):n?Wi(e,`hidden-by-suppressor`):i!=null&&e.layerRank===i?Wi(e,`visible`):Wi(e,`hidden-by-layer`));r.push({type:e,winnerLayer:i==null?void 0:Pi[i],suppressed:n,entries:a})}return r}}}function qi(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 Ji=class{resolve(e,t){return Ki(qi(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)=>zi(t)-zi(e))}};function Yi(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 Xi(e){let t=Yi(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 Zi(e){return e.split(`.`).map(Xi).filter(e=>e.length>0).join(`.`)}function Qi(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 $i(e){return JSON.stringify([e.path,e.kind,e.dimension??null])}var ea=class extends Error{code;constructor(e,t){super(t),this.name=`UnitConversionError`,this.code=e}},ta=[{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`]}],na=(()=>{let e=new Map;for(let t of ta){e.set(t.canonical.toLowerCase(),t);for(let n of t.aliases??[])e.has(n.toLowerCase())||e.set(n.toLowerCase(),t)}return e})();function ra(e){if(typeof e==`string`)return na.get(e.trim().toLowerCase())}function ia(e){return ra(e)?.dimension}var aa=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 oa(e){return aa[e]}function sa(e,t,n){let r=ra(t);if(!r)throw new ea(`unknown-unit`,`Unknown unit "${t}"`);let i=ra(n);if(!i)throw new ea(`unknown-unit`,`Unknown unit "${n}"`);if(r.dimension!==i.dimension)throw new ea(`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 ea(`scale-mismatch`,`Named scales ${t} and ${n} are not interchangeable`);if(!Number.isFinite(e))throw new ea(`non-finite`,`Non-finite value cannot be converted`);return e*r.factor/i.factor}var ca=`references`,la=[`explicit`,`split`,`whole`,`default`,`none`];function ua(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 da(e){return!e||typeof e!=`object`?!1:typeof e.reason==`string`}function fa(e){let t=e?.[ca];if(!t||typeof t!=`object`)return;let n=t;if(!(typeof n.matched!=`string`||!la.includes(n.matched))&&typeof n.source==`string`&&!(n.refs!==void 0&&(!Array.isArray(n.refs)||!n.refs.every(ua)))&&!(n.diagnostics!==void 0&&(!Array.isArray(n.diagnostics)||!n.diagnostics.every(da))))return t}var pa=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}},ma=class e{_metrics;_indexedLength=0;_resolver=new Ji;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)=>zi(t)-zi(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=>zi(e))),i=Math.max(...t.map(e=>zi(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(`, `)}]`}},ha=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 ma?this.metrics:ma.from(this.metrics,this.id)}},ga=class extends ha{id=0;parent;children=[];meta=new pa(0,0,0,0);_metrics=ma.empty();metricMeta=new Map;isLeaf;get metrics(){return this._metrics}set metrics(e){this._metrics=ma.from(e,this.id)}constructor(e){super(),e&&(Object.assign(this,e),e.metrics&&(this.metrics=ma.from(e.metrics,this.id)),this.metricMeta||=new Map)}},_a=class e extends ha{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=ma.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 pa(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=ma.from(n,this.id),this.metricMeta=new Map,this.children=[],this.isLeaf=!0,this.meta=i?.meta??new pa(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}},va=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 ya(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 ba=[`segment`,`system`,`load`,`event`,`compiler`,`completion`,`analytics`,`wellness`];function xa(e){return e===`time`?`run`:e===`log`?`log`:null}function Sa(e){let t=e.trim();return t.startsWith(`notebook/`)||t.startsWith(`notebook:`)?t.slice(9):t}function Ca(e){return`notebook/${Sa(e)}`}function wa(e){return e.seedOrigin!==`seed`}var Ta=[`playground-run-tip`,`attention`,`code-example`,`syntax-group`];function Ea(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 Da(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 Oa(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 ka(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]==="`"?Ea(`\`\`\`${h}`):null,_=a[0]==="`"?h.match(/^widget:([\w-]+)$/):null,v=a[0]==="`"?h.match(/^query(?:[:\s](.*))?$/i):null,y=t.registeredWidgets??Ta,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=ya(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=Da(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=Oa(m.displayContent.trim()),a&&(c=!1),o.push(m),l=p+1}return o}function Aa(e){return e.type===`time`||e.type===`log`?`wod`:e.type===`query`||e.type===`widget`||e.type===`embed`?e.type:null}function ja(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 ka(e,t)){let e=Aa(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 Ma(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=ja(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 Na(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 Pa=/^[A-Za-z][\w.-]*$/,Fa=/^---\r?\n([\s\S]*?)\r?\n---/;function Ia(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function La(e){let t=e.trim();return t===``||t.startsWith(`#`)}function Ra(e){return Array.isArray(e)}function za(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 Ba(e,t,n){let r=` `.repeat(e);return Ra(n)?n.length===0?[`${r}${t}: []`]:[`${r}${t}:`,...n.map(e=>`${r} - ${typeof e==`number`?String(e):za(e)}`)]:[`${r}${t}: ${typeof n==`number`?String(n):za(n)}`]}function Va(e,t,n,r){let i=[],a=r;for(let r=t;r<e.length;r++)r===e.length-1?i.push(...Ba(a,e[r],n)):i.push(`${` `.repeat(a)}${e[r]}:`),a+=2;return i}function Ha(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 Ua(e,t,n){let r=[t],i=[];for(let a=t+1;a<e.length;a++){let t=e[a];if(La(t)){i.push(a);continue}if(t.length-t.trimStart().length>n)r.push(...i,a),i=[];else break}return r}function Wa(e,t,n,r,i){let a=RegExp(`^ {${n}}${Ia(t)}\\s*:`);for(let t=r;t<i;t++)if(a.test(e[t]))return t;return-1}function Ga(e,t,n){if(t.length===0||!t.every(e=>typeof e==`string`&&Pa.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:As(ri.create({doc:n,extensions:[Rs]}),t),errors:[],success:!0}}catch(e){return{statements:[],errors:[{message:e instanceof Error?e.message:`Unknown parse error`,severity:`error`}],success:!1}}}function YF(e,...t){console.warn(`[${e}]`,...t)}function XF(e,...t){console.error(`[${e}]`,...t)}function ZF(e,t={}){let n=t.sourceRevision??1,r=ja(e,{...t,blocks:t.noteBlocks,sourceRevision:n}),i=ka(e,t),a=[];for(let e of i){if(!Aa(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=QF({...e.scriptBlock,id:t.id,version:t.version}),a.push(e.scriptBlock)))}return{sections:i,blocks:a,noteBlocks:r,rawContent:e,sourceRevision:n}}function QF(e){try{let t=JF(e.content,e.sport);return{...e,statements:t.statements,errors:t.errors,state:t.success?`parsed`:`error`}}catch(t){return XF(`WorkbenchDocumentModel`,`Block parse error:`,t),e}}function $F(e){if(e.kind!==`wod`||!e.dialect)throw Error(`The saved revision is not a workout.`);let t=ka(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:Ls().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 eI(e,t,n,r,i=vM){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:$F(o.revision)}}async function tI(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 eI({noteId:i.id,rawContent:i.rawContent,blocks:i.blocks,expectedSourceRevision:i.sourceRevision},t,n,r)}var nI={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`},rI=5e3;function iI(e={}){let t=e.listeners??[],n=e.nowProvider??Ic,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=fn()((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{...nI,setContent:r=>{let s=ZF(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(()=>{})},rI))),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(()=>{})},rI))},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=jF({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=ZF(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 eI({noteId:a,rawContent:i.content,blocks:i.noteBlocks,expectedSourceRevision:i.sourceRevision},e,w(),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=ZF(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 xv.process(r),{v7:c}=await cn(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=ZF(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 PF(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}=wF(t.runtime);return t.runtime?{outputStatementList:n,analyticsSegments:r,analyticsGroups:i}:{outputStatementList:n}}),clearOutputStatementList:()=>t({outputStatementList:[]}),feedLogOutputs:(e,n)=>{let{segments:r,groups:i}=TF(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,ma.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}),qF.setSubscriptionRegistry(e)},setViewMode:e=>t({viewMode:e}),setRuntime:e=>{for(let e of s)e();if(s=[],e){let r=wF(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(Mi(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=Ek();if(i?.connected){let t=new HF(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({...nI})}}});return t.length>0&&c.subscribe(e=>{for(let n of t)n(e)}),Object.assign(c,{__nowProvider:n})}var aI=iI();function oI(e){let t=aI;return aI=e,t}function sI(){return aI}var cI=e=>En(aI,e),lI=({nowProvider:e,notePersistence:t,provider:n,navigate:r,children:i})=>{let a=(0,W.useMemo)(()=>iI({nowProvider:e,notePersistence:t,provider:n,navigate:r}),[e,t,n,r]);return(0,W.useEffect)(()=>{let e=oI(a);return()=>{oI(e),a.getState().resetStore()}},[a]),W.createElement(W.Fragment,null,i)},uI={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)},dI={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}},fI={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}},pI=class{async getAllEfforts(){let e=IE();return e.isInitialized()||await PE(e),[...e.list()]}},mI=new zh,hI={events:[],notes:[]},gI={events:[],notes:[]};mI.set(`@session`,hI),mI.set(`@today`,gI);function _I(){let e=sI().getState(),t=e.runtime?.getOutputStatements()??[],n=e.currentEntry;return hI.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?(hI.events=[],hI):(hI.events=Xh(t.map(Kf),{noteId:n?.id??``,resultId:`live:${n?.id??`session`}`,origin:`playground`,workoutTimestamp:n?.targetDate}),hI)}function vI(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 Ch(e.date??e.createdAt,r)}async function yI(e,t){let n=Ch(e.instant,e.timeZone),r=Oh(n,e.timeZone),i=Oh(wh(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)vI(t,d.get(t.id)??[],u,e.timeZone)===n&&f.push(t);t===SI&&(gI.events=l,gI.notes=f,_I())}var bI=null,xI=null,SI=0,CI=!1,wI=new Set;function TI(){for(let e of wI)e()}function EI(e,t){xI=t;let n=++SI;return bI=yI(e,n),bI.then(()=>{n===SI&&DI()},()=>{n===SI&&DI()}),bI}function DI(){CI=!0,TI()}function OI(){let e=_h(),t=Ch(e.instant,e.timeZone);return!bI||xI!==t?EI(e,t):bI}function kI(){CI=!1;let e=_h();return EI(e,Ch(e.instant,e.timeZone))}function AI(){return CI}function jI(e){return wI.add(e),()=>{wI.delete(e)}}var MI=class extends Ag{async runQuery(e,t){return await OI(),super.runQuery(e,t)}async runPipeline(e,t){return await OI(),super.runPipeline(e,t)}async runFind(e,t){return await OI(),super.runFind(e,t)}async runRows(e,t){return await OI(),super.runRows(e,t)}async run(e,t){return await OI(),super.run(e,t)}};function NI(){return new MI({eventStore:uI,noteStore:dI,blockStore:fI,effortStore:new pI,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`?_I():mI.getDataset(e)}})}var PI=NI();function FI(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 II=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function LI(e){return typeof e==`string`&&e&&!II.test(e)?e:void 0}function RI(e){return!!e.sourceId?.startsWith(`collection:`)||!!e.sourceId?.startsWith(`page:collection:`)||e.type===`feed`||/^markdown\/collections\/[^/]+\/.+/.test(e.sourcePath??``)}function zI(e){return!!e.sourceId?.startsWith(`feed:`)||e.sourcePath?.startsWith(`markdown/feeds/`)===!0}function BI(e){return e.type===`dashboard`||e.sourceId===`dashboards`||e.sourcePath?.startsWith(`markdown/dashboards/`)===!0}function VI(e){return e.sourceId===`efforts`||e.sourcePath?.startsWith(`markdown/efforts/`)===!0}function HI(e){return e.sourceId===`equipment`||e.sourcePath?.startsWith(`markdown/equipment/`)===!0}function UI(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 WI(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(II.test(r))return{catalog:e.catalog??``,item:``};let[i,...a]=r.split(`/`);return{catalog:i,item:a.join(`/`)}}function GI(e){return e.sourceId===`playground`||e.type===`playground`||e.id.startsWith(`playground/`)}function KI(e){return e.id.startsWith(`playground/`)?e.id.slice(11):e.id}function qI(e){return{...JI(e),noteType:e.type,catalog:ag(e),notebookId:og(e),editable:wa(e),noteId:e.id}}function JI(e){let t=e.id,n=e.title,r=e.tags&&e.tags.length>0?e.tags:void 0;if(GI(e))return{id:t,kind:`note`,sourceCatalog:`playground`,sourceItem:KI(e),sourceId:e.sourceId,title:n,date:null,createdAt:e.createdAt,...r?{tags:r}:{}};if(RI(e)){let i=t.replace(/^page:collection:/,``),{catalog:a,item:o}=WI(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?LI(e.slug):void 0,title:n,date:e.date?TM(new Date(e.date)):null,createdAt:e.createdAt,subtitle:e.catalog??a,...r?{tags:r}:{}}}if(zI(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(BI(e))return{id:t,kind:`dashboard`,sourceCatalog:`dashboards`,sourceItem:UI(e,1)??t,sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:null,createdAt:e.createdAt,subtitle:e.catalog??`dashboards`,...r?{tags:r}:{}};if(VI(e)){let i=UI(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(HI(e))return{id:t,kind:`equipment`,sourceCatalog:`equipment`,sourceItem:UI(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:LI(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=TM(new Date(e.targetDate)):e.createdAt&&(i=TM(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?LI(e.slug):void 0,title:n,date:i,createdAt:e.createdAt,...r?{tags:r}:{}}}function YI(e){return{id:e.noteId,title:e.noteTitle,createdAt:e.createdAt,type:`note`,sourceId:e.sourceId,sourcePath:e.sourcePath,rawContent:``,sourceRevision:1,blocks:{}}}var XI=3,ZI=120;function QI(e){return e.split(`
|
|
100
|
-
`).map(e=>e.trim()).filter(Boolean).slice(0,XI).map(e=>e.length>ZI?`${e.slice(0,119)}…`:e)}function $I(e){let t=qI(YI(e));return{...t,blockContentId:e.blockContentId??t.blockContentId,catalog:ag(e),block:{blockId:e.blockId,dataType:e.dataType,preview:QI(e.rawContent)}}}function eL(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 tL(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 nL(e){if(!e)return`Workout Session`;let t=FI(e);return t.kind===`journal`?t.id?`Journal: ${t.id}`:`Journal Entry`:t.kind===`workout`?eL(t.id)||t.id:t.id?eL(t.id):e}function rL(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 iL(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 aL(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=iL(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 oL(e,t){let n=aL(e),r=[];n.elapsedMs!=null&&r.push(tL(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(eL),a=TM(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??nL(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 sL(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=iL(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?eL(e.effortSlug):e.outputType===`segment`?`Round ${c+1}`:`${e.outputType.charAt(0).toUpperCase()+e.outputType.slice(1)} ${c+1}`,u=[];n!=null&&u.push(tL(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=TM(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?eL(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 cL(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(sL(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(sL(i,{index:e++}))}return t}return e.runs.map(e=>oL(e,{noteTitle:t?.noteTitles?.get(e.noteId)}))}function lL(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?eL(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function uL(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function dL(e){return typeof e==`object`&&!!e&&`runFind`in e}var fL=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){dL(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??PI}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(Wp(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=(e.efforts??[]).map(rL);return uL(t,e.stages,r),r}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map($I);return await this.hydrateEntries(r,!0),uL(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=cL(e,{noteTitles:r});return uL(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)=>lL(t,e,n));return uL(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(qI);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),uL(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=QI(i.rawContent);try{Ma(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&&ka(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=ya(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}return[]}};async function pL(e,t=fL,n){return t.query(e,n)}function mL(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function hL(e){try{let t=(await pL(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 gL(e){let t=mL(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`?hL(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function _L(){let[e]=Gt(`s`,{shallow:!0}),{navState:t}=ej(),n=t.activeL3Id??``;return e||n||``}function vL({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)(x,{className:`size-3.5`}):e.runIcon===`edit`?(0,G.jsx)(o,{className:`size-3.5`}):(0,G.jsx)(rn,{className:`size-3.5`})})]})}function yL({entries:e,activeId:t,onSection:n}){let r=Sn(),{scrollToSection:i}=ej(),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)(yL,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:(0,G.jsx)(vL,{entry:e,active:t!=null&&e.sectionId===t,onActivate:a},e.id))})}function bL(){let e=Sn(),{scrollToSection:t}=ej();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function xL(){let e=bL(),{openCreateJournal:t}=ej();return n=>{if(n.id===`home-new-journal`){t({mode:`blank`});return}jN(n.action,e)}}function SL(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 CL({items:e}){let{navState:t}=ej(),n=mt(),r=xL();return(0,G.jsx)(KM,{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)(Dn,{className:`size-4 shrink-0`}),(0,G.jsx)(`span`,{children:e.label})]})},e.id);let i=SL(e,t,n);return e.children&&e.children.length>0?(0,G.jsx)(IN,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>SL(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=SL(e,t,n);return(0,G.jsxs)(qM,{onClick:()=>r(e),current:i,children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(JM,{children:e.label})]},e.id)})},e.id):(0,G.jsxs)(qM,{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)(JM,{children:e.disabled?`+`:e.label})]},e.id)})})}function wL({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=ej(),a=mt(),o=gL(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,G.jsxs)(UM,{children:[(0,G.jsx)(WM,{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)(GM,{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)(CL,{items:s.children})}):null})(),c?(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(yL,{entries:c.spec})}):o.length>0&&(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(yL,{entries:o})})]})]})}var TL=`0.43.2151`,EL=`https://github.com/bitcobblers/wod-wiki/releases`;function DL(e){return/-pr\.\d+$/.test(e)?EL:`${EL}/tag/v${e}`}function OL({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=ej(),a=Sn(),o=mt(),s=LM(),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)(A,{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=SL(e,r,o);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{i({type:`SET_ACTIVE_L1`,id:e.id}),jN(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)(en,{className:`size-5`})}),(0,G.jsx)(`a`,{href:kP,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)(AP,{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)(je,{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)(ht,{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`,TL]})]})]})}function kL({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:()=>jN(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 AL=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=Ic){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},jL=20,ML=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 AL(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()??Ic.nowMs();u.current=i-r,r===0&&c(i),l.current=setInterval(f,jL)},[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()??Ic.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])},NL=(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 PL(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 FL(e){return PL(e,`round`)}function IL(e){return PL(e,`display`)}function LL(e){let t=FL(e),n=IL(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 RL=(0,W.createContext)(void 0),zL=({runtime:e,children:t})=>(0,G.jsx)(RL.Provider,{value:e,children:t});function BL(){let e=(0,W.useContext)(RL);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function VL(e){let t=BL(),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 HL(e){let t=BL(),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 UL(){let e=BL(),[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 WL(){return UL().blocks}function GL(){let e=WL(),[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=ma.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 KL(){let e=WL(),[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 qL(){let e=KL();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 JL(){let e=KL(),t=qL();return(0,W.useMemo)(()=>t?e.filter(e=>e.block!==t.block):[],[e,t])}function YL(){let e=WL(),[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 XL(){let e=WL(),[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 ZL(e){let t=BL(),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)(wl()),l=(0,W.useMemo)(()=>a.length===0?0:NL(a,s),[a,s]);return(0,W.useEffect)(()=>{if(!o)return;let e,t=()=>{c(wl()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}var QL=(0,W.createContext)(void 0),$L=(0,W.createContext)(null),eR={getState:()=>sI().getState(),setState:(e,t)=>{let n=sI();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>sI().subscribe(e)},tR=({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),eR.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 kf(n);e.add(new Of({id:`local`})),f.current=e,a(e),eR.getState().setSubscriptionManager(e)}else f.current=null,a(null),eR.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)(QL.Provider,{value:g,children:(0,G.jsx)($L.Provider,{value:i,children:t})})};function nR({factory:e,children:t}){return(0,G.jsx)(tR,{factory:e,children:t})}var rR=`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`,iR=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function aR({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 oR({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 sR({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]=Gt(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,W.useState)(c?.[0]?.id??``);if(oR({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}),oR({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)(kL,{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)(nR,{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(iR,rR),children:[(0,G.jsx)(aR,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,G.jsx)(`div`,{className:`flex-1`,children:i})]})})}var cR=`[data-page-sticky-boundary="true"]`,lR=0;function uR(e,t=lR){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(cR)).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 dR(e,t=lR){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r(uR(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 fR({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 pR=(0,W.createContext)(null),mR=(0,W.createContext)(null);function hR({children:e}){let[t,n]=(0,W.useState)(null);return(0,G.jsx)(mR.Provider,{value:n,children:(0,G.jsx)(pR.Provider,{value:t,children:e})})}function gR({className:e}){let t=(0,W.useContext)(mR);return(0,G.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function _R(){return(0,W.useContext)(pR)}function vR({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(iR,rR),children:[(0,G.jsx)(aR,{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 yR(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 bR=W.createContext(null);function xR(){let e=W.useContext(bR);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}var SR=({children:e,open:t,onOpenChange:n})=>{let r=W.useContext(bR),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)(bR.Provider,{value:v,children:(0,G.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},CR=W.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=xR(),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})});CR.displayName=`DropdownMenuTrigger`;var wR=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}=xR(),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%)`),aS.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)});wR.displayName=`DropdownMenuContent`;var TR=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}=xR(),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})});TR.displayName=`DropdownMenuItem`;var ER=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}));ER.displayName=`DropdownMenuLabel`;var DR=W.forwardRef(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:K(`-mx-1 my-1 h-px bg-muted`,e),...t}));DR.displayName=`DropdownMenuSeparator`;function OR({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 kR=[{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`}],AR=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function jR(e,t){return new Date(e,t+1,0).getDate()}function MR(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function NR(e,t){let n=X(e);if(n.error)return e;if(!t||t===`all`)return Fm({...n,window:void 0});let r=X(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:Fm({...n,window:r.window})}function PR(e){let t=X(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function FR({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,W.useMemo)(()=>PR(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:TM(t),end:TM(e)}},[i]),p=(0,W.useMemo)(()=>{let e=jR(l,u),t=MR(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(NR(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(NR(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=TM(new Date);return(0,G.jsxs)(`div`,{className:K(`relative inline-flex items-center`,r),children:[(0,G.jsxs)(SR,{children:[(0,G.jsx)(CR,{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)(mn,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,G.jsx)(Tt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,G.jsxs)(wR,{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:kR.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(NR(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)(Vn,{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)(wn,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:AR.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(NR(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)(Ce,{className:`size-3.5`})})]})}function IR(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 LR=[{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??``)}],RR={note:LR,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?``:tL(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?``:tL(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?``:tL(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 zR(e){return RR[e]??LR}function BR(e){return zR(e).filter(e=>e.defaultVisible).map(e=>e.id)}var VR=[{id:`cards`,label:`Cards`,icon:an},{id:`rows`,label:`Rows`,icon:se},{id:`feed`,label:`Feed`,icon:Xn}];function HR({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)(FR,{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:VR.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:zR(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 UR({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=ej(),i=gL(e),a=(0,W.useMemo)(()=>yR(n),[n]),o=_L();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)(HR,{streamControls:r})}),i.length>0&&(0,G.jsx)(yL,{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)(yL,{entries:a,activeId:o})]}),t&&(0,G.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var WR=1023;function GR(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function KR(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:Db(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 qR(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function JR(e){let t=new Map,n=null;for(let r of e)qR(r)&&(n=r),t.set(r.id,n);return t}function YR(){let[e,t]=(0,W.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${WR}px)`).matches);return(0,W.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${WR}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var XR=`wodwiki:fabAlignment`,ZR=[{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 QR(){try{return $R(localStorage.getItem(XR))}catch{return}}function $R(e){return e===`right`||e===`left`?e:void 0}var ez=typeof window>`u`?void 0:QR();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===XR&&(ez=$R(e.newValue))});function tz(e){ez=e;try{e===`right`?localStorage.removeItem(XR):localStorage.setItem(XR,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:XR,newValue:e}))}function nz(){let[e,t]=(0,W.useState)(()=>ez??`right`);return(0,W.useEffect)(()=>{let e=e=>{e.key===XR&&t($R(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,tz]}function rz({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)(en,{className:`size-6`})})}var iz=(0,W.createContext)(null),az=(0,W.createContext)(!1),oz=(0,W.createContext)(null);function sz(){return(0,W.useContext)(iz)!==null}function cz({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,W.useContext)(iz),o=(0,W.useContext)(az),s=YR(),c=(0,W.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=(0,G.jsx)(az.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)(az.Provider,{value:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function lz({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)(iz.Provider,{value:o,children:(0,G.jsxs)(oz.Provider,{value:s,children:[t,(0,G.jsx)(dz,{registrations:n,onSearch:e})]})})}function uz(){let e=(0,W.useContext)(oz);return e?(0,G.jsx)(G.Fragment,{children:e}):null}function dz({registrations:e,onSearch:t}){let n=YR(),[r]=nz(),i=sS(),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=mt(),[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)(rz,{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)(Ie,{className:`size-6`}):(0,G.jsx)(me,{className:`size-6`})})]})}function fz(){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 pz(){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 mz(){let{tree:e,navState:t,contextNav:n}=ej(),r=mt(),i=LM();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 hz({open:e,close:t,onSearch:n,onCreate:r,children:i}){return(0,G.jsxs)(Ve,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Ge,{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)(j,{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)(IM,{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)(OL,{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)(rt,{as:yF,"aria-label":`Close navigation`,children:(0,G.jsx)(pz,{})})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),(0,G.jsx)(mz,{})]})]})})})]})}function gz({open:e,close:t,children:n}){return(0,G.jsxs)(Ve,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Ge,{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)(j,{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)(IM,{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)(rt,{as:yF,"aria-label":`Close page options`,children:(0,G.jsx)(pz,{})})}),(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 _z({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}=ej(),g=(0,W.useMemo)(()=>{let e=X(h?.query??``);return!e.error&&Wp(e)&&e.filters.length>0},[h?.query]);return(0,G.jsx)(hR,{children:(0,G.jsx)(lz,{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)(OL,{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)(hz,{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)(yF,{onClick:()=>l(!0),"aria-label":`Open navigation`,children:(0,G.jsx)(fz,{})})}),(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)(yF,{onClick:r,"aria-label":`New journal note`,children:(0,G.jsx)(qt,{className:`size-5`})})}),p&&(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsx)(yF,{onClick:()=>d(!0),"aria-label":`Open page options`,children:(0,G.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,G.jsx)(vn,{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)(vz,{})]})]}),(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)(UR,{spec:i,pageAction:a})})}),(0,G.jsx)(gz,{open:u,close:()=>d(!1),children:(0,G.jsx)(UR,{spec:i,pageAction:a})})]})})})})}function vz(){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)(gR,{className:`flex w-full min-w-0`})})}),(0,G.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function yz(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function bz(e){return String(Ob(Sb(e).meta,`search`)??``).toLowerCase()===`hidden`}function xz(e){let t=Ob(Sb(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 Sz(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=Ob(Sb(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():VE(r),category:yz(n),content:i,date:xz(i),searchHidden:bz(i)}})}function Cz(){let e=lD();return(0,W.useMemo)(()=>e?Sz(e):[],[e])}var wz={};function Tz(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 Ez(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=VP(e).split(`
|
|
100
|
+
`).map(e=>e.trim()).filter(Boolean).slice(0,XI).map(e=>e.length>ZI?`${e.slice(0,119)}…`:e)}function $I(e){let t=qI(YI(e));return{...t,blockContentId:e.blockContentId??t.blockContentId,catalog:ag(e),block:{blockId:e.blockId,dataType:e.dataType,preview:QI(e.rawContent)}}}function eL(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 tL(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 nL(e){if(!e)return`Workout Session`;let t=FI(e);return t.kind===`journal`?t.id?`Journal: ${t.id}`:`Journal Entry`:t.kind===`workout`?eL(t.id)||t.id:t.id?eL(t.id):e}function rL(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 iL(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 aL(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=iL(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 oL(e,t){let n=aL(e),r=[];n.elapsedMs!=null&&r.push(tL(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(eL),a=TM(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??nL(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 sL(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=iL(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?eL(e.effortSlug):e.outputType===`segment`?`Round ${c+1}`:`${e.outputType.charAt(0).toUpperCase()+e.outputType.slice(1)} ${c+1}`,u=[];n!=null&&u.push(tL(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=TM(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?eL(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 cL(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(sL(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(sL(i,{index:e++}))}return t}return e.runs.map(e=>oL(e,{noteTitle:t?.noteTitles?.get(e.noteId)}))}function lL(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?eL(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function uL(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function dL(e){return typeof e==`object`&&!!e&&`runFind`in e}var fL=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){dL(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??PI}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(Wp(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=(e.efforts??[]).map(rL);return uL(t,e.stages,r),r}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map($I);return await this.hydrateEntries(r,!0),uL(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=cL(e,{noteTitles:r});return uL(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)=>lL(t,e,n));return uL(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(qI);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),uL(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=QI(i.rawContent);try{Ma(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&&ka(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=ya(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}return[]}};async function pL(e,t=fL,n){return t.query(e,n)}function mL(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function hL(e){try{let t=(await pL(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 gL(e){let t=mL(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`?hL(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function _L(){let[e]=Gt(`s`,{shallow:!0}),{navState:t}=ej(),n=t.activeL3Id??``;return e||n||``}function vL({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)(x,{className:`size-3.5`}):e.runIcon===`edit`?(0,G.jsx)(o,{className:`size-3.5`}):(0,G.jsx)(rn,{className:`size-3.5`})})]})}function yL({entries:e,activeId:t,onSection:n}){let r=Sn(),{scrollToSection:i}=ej(),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)(yL,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:(0,G.jsx)(vL,{entry:e,active:t!=null&&e.sectionId===t,onActivate:a},e.id))})}function bL(){let e=Sn(),{scrollToSection:t}=ej();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function xL(){let e=bL(),{openCreateJournal:t}=ej();return n=>{if(n.id===`home-new-journal`){t({mode:`blank`});return}jN(n.action,e)}}function SL(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 CL({items:e}){let{navState:t}=ej(),n=mt(),r=xL();return(0,G.jsx)(KM,{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)(Dn,{className:`size-4 shrink-0`}),(0,G.jsx)(`span`,{children:e.label})]})},e.id);let i=SL(e,t,n);return e.children&&e.children.length>0?(0,G.jsx)(IN,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>SL(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=SL(e,t,n);return(0,G.jsxs)(qM,{onClick:()=>r(e),current:i,children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(JM,{children:e.label})]},e.id)})},e.id):(0,G.jsxs)(qM,{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)(JM,{children:e.disabled?`+`:e.label})]},e.id)})})}function wL({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=ej(),a=mt(),o=gL(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,G.jsxs)(UM,{children:[(0,G.jsx)(WM,{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)(GM,{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)(CL,{items:s.children})}):null})(),c?(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(yL,{entries:c.spec})}):o.length>0&&(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(yL,{entries:o})})]})]})}var TL=`0.43.2152`,EL=`https://github.com/bitcobblers/wod-wiki/releases`;function DL(e){return/-pr\.\d+$/.test(e)?EL:`${EL}/tag/v${e}`}function OL({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=ej(),a=Sn(),o=mt(),s=LM(),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)(A,{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=SL(e,r,o);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{i({type:`SET_ACTIVE_L1`,id:e.id}),jN(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)(en,{className:`size-5`})}),(0,G.jsx)(`a`,{href:kP,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)(AP,{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)(je,{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)(ht,{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`,TL]})]})]})}function kL({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:()=>jN(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 AL=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=Ic){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},jL=20,ML=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 AL(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()??Ic.nowMs();u.current=i-r,r===0&&c(i),l.current=setInterval(f,jL)},[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()??Ic.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])},NL=(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 PL(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 FL(e){return PL(e,`round`)}function IL(e){return PL(e,`display`)}function LL(e){let t=FL(e),n=IL(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 RL=(0,W.createContext)(void 0),zL=({runtime:e,children:t})=>(0,G.jsx)(RL.Provider,{value:e,children:t});function BL(){let e=(0,W.useContext)(RL);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function VL(e){let t=BL(),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 HL(e){let t=BL(),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 UL(){let e=BL(),[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 WL(){return UL().blocks}function GL(){let e=WL(),[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=ma.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 KL(){let e=WL(),[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 qL(){let e=KL();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 JL(){let e=KL(),t=qL();return(0,W.useMemo)(()=>t?e.filter(e=>e.block!==t.block):[],[e,t])}function YL(){let e=WL(),[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 XL(){let e=WL(),[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 ZL(e){let t=BL(),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)(wl()),l=(0,W.useMemo)(()=>a.length===0?0:NL(a,s),[a,s]);return(0,W.useEffect)(()=>{if(!o)return;let e,t=()=>{c(wl()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}var QL=(0,W.createContext)(void 0),$L=(0,W.createContext)(null),eR={getState:()=>sI().getState(),setState:(e,t)=>{let n=sI();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>sI().subscribe(e)},tR=({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),eR.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 kf(n);e.add(new Of({id:`local`})),f.current=e,a(e),eR.getState().setSubscriptionManager(e)}else f.current=null,a(null),eR.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)(QL.Provider,{value:g,children:(0,G.jsx)($L.Provider,{value:i,children:t})})};function nR({factory:e,children:t}){return(0,G.jsx)(tR,{factory:e,children:t})}var rR=`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`,iR=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function aR({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 oR({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 sR({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]=Gt(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,W.useState)(c?.[0]?.id??``);if(oR({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}),oR({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)(kL,{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)(nR,{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(iR,rR),children:[(0,G.jsx)(aR,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,G.jsx)(`div`,{className:`flex-1`,children:i})]})})}var cR=`[data-page-sticky-boundary="true"]`,lR=0;function uR(e,t=lR){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(cR)).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 dR(e,t=lR){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r(uR(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 fR({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 pR=(0,W.createContext)(null),mR=(0,W.createContext)(null);function hR({children:e}){let[t,n]=(0,W.useState)(null);return(0,G.jsx)(mR.Provider,{value:n,children:(0,G.jsx)(pR.Provider,{value:t,children:e})})}function gR({className:e}){let t=(0,W.useContext)(mR);return(0,G.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function _R(){return(0,W.useContext)(pR)}function vR({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(iR,rR),children:[(0,G.jsx)(aR,{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 yR(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 bR=W.createContext(null);function xR(){let e=W.useContext(bR);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}var SR=({children:e,open:t,onOpenChange:n})=>{let r=W.useContext(bR),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)(bR.Provider,{value:v,children:(0,G.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},CR=W.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=xR(),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})});CR.displayName=`DropdownMenuTrigger`;var wR=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}=xR(),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%)`),aS.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)});wR.displayName=`DropdownMenuContent`;var TR=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}=xR(),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})});TR.displayName=`DropdownMenuItem`;var ER=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}));ER.displayName=`DropdownMenuLabel`;var DR=W.forwardRef(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:K(`-mx-1 my-1 h-px bg-muted`,e),...t}));DR.displayName=`DropdownMenuSeparator`;function OR({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 kR=[{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`}],AR=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function jR(e,t){return new Date(e,t+1,0).getDate()}function MR(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function NR(e,t){let n=X(e);if(n.error)return e;if(!t||t===`all`)return Fm({...n,window:void 0});let r=X(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:Fm({...n,window:r.window})}function PR(e){let t=X(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function FR({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,W.useMemo)(()=>PR(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:TM(t),end:TM(e)}},[i]),p=(0,W.useMemo)(()=>{let e=jR(l,u),t=MR(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(NR(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(NR(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=TM(new Date);return(0,G.jsxs)(`div`,{className:K(`relative inline-flex items-center`,r),children:[(0,G.jsxs)(SR,{children:[(0,G.jsx)(CR,{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)(mn,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,G.jsx)(Tt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,G.jsxs)(wR,{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:kR.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(NR(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)(Vn,{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)(wn,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:AR.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(NR(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)(Ce,{className:`size-3.5`})})]})}function IR(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 LR=[{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??``)}],RR={note:LR,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?``:tL(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?``:tL(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?``:tL(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 zR(e){return RR[e]??LR}function BR(e){return zR(e).filter(e=>e.defaultVisible).map(e=>e.id)}var VR=[{id:`cards`,label:`Cards`,icon:an},{id:`rows`,label:`Rows`,icon:se},{id:`feed`,label:`Feed`,icon:Xn}];function HR({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)(FR,{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:VR.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:zR(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 UR({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=ej(),i=gL(e),a=(0,W.useMemo)(()=>yR(n),[n]),o=_L();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)(HR,{streamControls:r})}),i.length>0&&(0,G.jsx)(yL,{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)(yL,{entries:a,activeId:o})]}),t&&(0,G.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var WR=1023;function GR(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function KR(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:Db(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 qR(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function JR(e){let t=new Map,n=null;for(let r of e)qR(r)&&(n=r),t.set(r.id,n);return t}function YR(){let[e,t]=(0,W.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${WR}px)`).matches);return(0,W.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${WR}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var XR=`wodwiki:fabAlignment`,ZR=[{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 QR(){try{return $R(localStorage.getItem(XR))}catch{return}}function $R(e){return e===`right`||e===`left`?e:void 0}var ez=typeof window>`u`?void 0:QR();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===XR&&(ez=$R(e.newValue))});function tz(e){ez=e;try{e===`right`?localStorage.removeItem(XR):localStorage.setItem(XR,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:XR,newValue:e}))}function nz(){let[e,t]=(0,W.useState)(()=>ez??`right`);return(0,W.useEffect)(()=>{let e=e=>{e.key===XR&&t($R(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,tz]}function rz({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)(en,{className:`size-6`})})}var iz=(0,W.createContext)(null),az=(0,W.createContext)(!1),oz=(0,W.createContext)(null);function sz(){return(0,W.useContext)(iz)!==null}function cz({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,W.useContext)(iz),o=(0,W.useContext)(az),s=YR(),c=(0,W.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=(0,G.jsx)(az.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)(az.Provider,{value:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function lz({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)(iz.Provider,{value:o,children:(0,G.jsxs)(oz.Provider,{value:s,children:[t,(0,G.jsx)(dz,{registrations:n,onSearch:e})]})})}function uz(){let e=(0,W.useContext)(oz);return e?(0,G.jsx)(G.Fragment,{children:e}):null}function dz({registrations:e,onSearch:t}){let n=YR(),[r]=nz(),i=sS(),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=mt(),[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)(rz,{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)(Ie,{className:`size-6`}):(0,G.jsx)(me,{className:`size-6`})})]})}function fz(){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 pz(){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 mz(){let{tree:e,navState:t,contextNav:n}=ej(),r=mt(),i=LM();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 hz({open:e,close:t,onSearch:n,onCreate:r,children:i}){return(0,G.jsxs)(Ve,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Ge,{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)(j,{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)(IM,{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)(OL,{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)(rt,{as:yF,"aria-label":`Close navigation`,children:(0,G.jsx)(pz,{})})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),(0,G.jsx)(mz,{})]})]})})})]})}function gz({open:e,close:t,children:n}){return(0,G.jsxs)(Ve,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Ge,{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)(j,{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)(IM,{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)(rt,{as:yF,"aria-label":`Close page options`,children:(0,G.jsx)(pz,{})})}),(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 _z({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}=ej(),g=(0,W.useMemo)(()=>{let e=X(h?.query??``);return!e.error&&Wp(e)&&e.filters.length>0},[h?.query]);return(0,G.jsx)(hR,{children:(0,G.jsx)(lz,{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)(OL,{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)(hz,{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)(yF,{onClick:()=>l(!0),"aria-label":`Open navigation`,children:(0,G.jsx)(fz,{})})}),(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)(yF,{onClick:r,"aria-label":`New journal note`,children:(0,G.jsx)(qt,{className:`size-5`})})}),p&&(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsx)(yF,{onClick:()=>d(!0),"aria-label":`Open page options`,children:(0,G.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,G.jsx)(vn,{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)(vz,{})]})]}),(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)(UR,{spec:i,pageAction:a})})}),(0,G.jsx)(gz,{open:u,close:()=>d(!1),children:(0,G.jsx)(UR,{spec:i,pageAction:a})})]})})})})}function vz(){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)(gR,{className:`flex w-full min-w-0`})})}),(0,G.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function yz(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function bz(e){return String(Ob(Sb(e).meta,`search`)??``).toLowerCase()===`hidden`}function xz(e){let t=Ob(Sb(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 Sz(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=Ob(Sb(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():VE(r),category:yz(n),content:i,date:xz(i),searchHidden:bz(i)}})}function Cz(){let e=lD();return(0,W.useMemo)(()=>e?Sz(e):[],[e])}var wz={};function Tz(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 Ez(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=VP(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(TM(new Date(n)))}),r.forEach(t=>{let n=Tz(t);n&&Number.isFinite(new Date(n).getTime())&&e.add(TM(new Date(n)))}),Array.from(e).sort().reverse().slice(0,10).map(e=>({id:e,label:OF(new Date(e+`T00:00:00`)),type:`heading`}))}return[]}var Dz=/^[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 Oz(e){return Dz.test(e)}function kz(e){try{return decodeURIComponent(e)}catch{return null}}function Az(e){if(!OM(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 jz(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(kz);if(n.some(e=>e==null))return{kind:`invalid`};let r=n;if(r.length===1){let e=r[0];return Az(e)?{kind:`date`,journalDate:e}:Dz.test(e)?{kind:`uuid-alias`,noteId:e}:e?{kind:`slug-alias`,slug:e}:{kind:`invalid`}}if(r.length===2){let[e,t]=r;if(Az(e)&&Dz.test(t))return{kind:`note`,journalDate:e,noteId:t}}return{kind:`invalid`}}var Mz=`# 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:T,children:T||(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)(lK,{summary:w}),(0,G.jsx)(`div`,{className:`border-t border-border/40 shrink-0`,children:(0,G.jsx)(pK,{commands:d,section:m,view:n})})]})]})},hK=({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 gK(e,t,n,r,i){switch(t.type){case`fixed-field`:return _K(e,t);case`metric-type`:return vK(e,t);case`derived`:return yK(e,t,n,r,i);case`fallback`:return bK(e,t,n,r,i);default:return}}function _K(e,t){return e[t.field]}function vK(e,t){return e.cells.get(t.metricType)}function yK(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=gK(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 bK(e,t,n,r,i){return xK(e,t,n,r,i)}function xK(e,t,n,r,i){if(!(!t.sources||t.sources.length===0))switch(t.semantics){case`first-present`:return SK(e,t.sources,n,r,i);case`all-present-joined`:return CK(e,t.sources,t.joinString,n,r,i);case`all-present-combined`:return wK(e,t.sources,n,r,i);default:return}}function SK(e,t,n,r,i){for(let a of t){let t=gK(e,a,n,r,i);if(t!=null)return t}}function CK(e,t,n,r,i,a){let o=[];for(let n of t){let t=gK(e,n,r,i,a);if(t==null)return;o.push(t)}let s=n??` `;return o.map(e=>EK(e)).join(s)}function wK(e,t,n,r,i){let a=[];for(let o of t){let t=gK(e,o,n,r,i);if(t==null)return;a.push(t)}return a}function TK(e){if(e==null)return``;let t=Array.isArray(e)?e:e instanceof ma?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 EK(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=TK(e.metrics);if(t.length>0)return t}return String(e)}function DK(e,t,n,r){if(!t.sort)return``;let i=gK(e,t.source,n,r);return(t.sort.type===`custom`?typeof i==`number`||typeof i==`string`?i:String(i??``):t.sort.extractor(i))??``}function OK(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 kK(e,t,n,r){if(!t.graph)return;let i=gK(e,t.source,n,r);return t.graph.extractor(i)}function AK(e,t,n,r){if(!t.filter)return``;let i=gK(e,t.source,n,r);return t.filter.extractor(i)??``}function jK(e,t,n,r,i){if(!n||n.trim().length===0||!t.filter)return!0;let a=AK(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 MK=({metric:e})=>{let t=e.origin===`hinted`||e.image===`?`,n=(0,W.useMemo)(()=>BV(vo.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:`👤`})]})},NK=({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)(()=>gK(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)(()=>PK(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 PK(e,t,n,r){if(e==null)return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[qK(n),(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`})]});switch(t.type){case`text`:return FK(e,t,n);case`time`:return IK(e,t);case`number`:return LK(e,t);case`badge`:return RK(e,t);case`pill`:return zK(e,t);case`combined`:return VK(e,t,n);case`custom`:return UK(e,t,r);default:return GK(e,n)}}function FK(e,t,n){let r=t.transform?t.transform(e):JK(e);return(0,G.jsxs)(`span`,{className:K(`inline-flex items-center gap-1`,t.className),children:[qK(n),r]})}function IK(e,t){let n=YK(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=rV(n);break;case`precise`:r=`${n.toFixed(2)}s`;break;default:r=nV(n)}return t.transform&&(r=t.transform(r)),(0,G.jsx)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:r})}function LK(e,t){let n=YK(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 RK(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 zK(e,t){let n=t.transform?t.transform(e):JK(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 BK={primary:`text-sm font-semibold text-foreground`,secondary:`text-xs text-muted-foreground`,tertiary:`text-[11px] text-muted-foreground opacity-80`};function VK(e,t,n,r){let[i,a,o]=Array.isArray(e)?e:[e],s=i===void 0?null:HK(i,t.primaryFormat??{type:`text`},r,`primary`),c=a===void 0?null:HK(a,t.secondaryFormat??{type:`text`},r,`secondary`),l=o===void 0?null:HK(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:[qK(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 HK(e,t,n,r){let i=PK(e,t,0,n);return r?(0,G.jsx)(`span`,{className:K(`inline-flex items-center`,BK[r]),children:i}):i}function UK(e,t,n){let r=n?{...t.context,row:n}:t.context;return t.render(e,r)}function WK(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 GK(e,t){return e?.metrics?KK(e,t):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[qK(t),JK(e)]})}function KK(e,t){let n=WK(e);return n.length===0?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[qK(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:[qK(t),n.map((e,t)=>(0,G.jsx)(MK,{metric:e},t))]})}function qK(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 JK(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=WK(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 YK(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=WK(e);if(t.length>0&&typeof t[0]?.value==`number`)return t[0].value}var XK=e=>e;function ZK(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 QK(e){let t=ZK(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 $K(e){let t=ZK(e);for(let e of t)if(typeof e?.value==`number`)return e.value}function eq(e){return ZK(e).map(e=>e.image??String(e.value??``)).join(`, `)}function tq(e){return e==null?``:Array.isArray(e)?e.map(e=>tq(e)).filter(Boolean).join(` — `):typeof e==`string`?e:typeof e==`number`?String(e):eq(e)}function nq(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 rq(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 iq(e,t){let n=mo(e),r=SV(e)??void 0,i=t?.graphable??nq(e);return{id:e,label:n,icon:r,source:{type:`metric-type`,metricType:e},format:{type:`custom`,render:e=>KK(e,0)},sort:nq(e)?{type:`numeric`,extractor:e=>$K(e)}:{type:`text`,extractor:e=>{let t=QK(e);return t===void 0?void 0:String(t)}},graph:i?{extractor:e=>$K(e),axisLabel:n,unit:rq(e)}:void 0,filter:{extractor:e=>eq(e),caseInsensitive:!0},meta:{defaultVisible:t?.defaultVisible??!0,debugOnly:t?.debugOnly,tags:[e]}}}function aq(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 oq(e,t){if(!e||e.length===0)return``;let n=e=>nV(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 sq(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 cq({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 lq({elapsed:e,duration:t}){let n=nV(e);return(0,G.jsxs)(`span`,{className:`inline-flex items-baseline gap-0.5`,children:[(0,G.jsx)(cq,{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)(cq,{value:nV(t)})})]})]})}var uq={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`,aq(n)),title:`Type: ${n}\nBlock: ${r}`,children:t})}},sort:{type:`numeric`,extractor:e=>XK(e)?.index||0},meta:{tags:[`layout`],defaultVisible:!0,width:`40px`,resizable:!1}},dq={id:`timestamp`,label:`Timestamp`,source:{type:`fixed-field`,field:`absoluteStartTime`},format:{type:`custom`,render:(e,t)=>{let n=e,r=XK(t)?.hideMs!==!1;return(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px] text-center w-24 whitespace-nowrap`,children:sq(n,r)})},context:{hideMs:!1}},sort:{type:`numeric`,extractor:e=>XK(e)?.absoluteStartTime??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},fq={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:oq(t,n)})}},sort:{type:`numeric`,extractor:e=>(XK(e)?.spans)?.[0]?.started??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},pq={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:sq(t,!1)}),(0,G.jsx)(lq,{elapsed:n,duration:r})]})}},sort:{type:`numeric`,extractor:e=>XK(e)?.elapsed??0},graph:{extractor:e=>XK(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(sq(t,!1)),n!==void 0&&i.push(nV(n)),r!==void 0&&r>0&&r!==n&&i.push(nV(r)),i.join(` `)},caseInsensitive:!0},meta:{tags:[`timing`,`compound`],defaultVisible:!0,width:`100px`,subsumes:[`duration`,`elapsedTotal`]}},mq={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=>XK(e)?.sourceBlockKey??``},filter:{extractor:e=>XK(e)?.sourceBlockKey??``,caseInsensitive:!0},meta:{tags:[`layout`],defaultVisible:!1}},hq={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`,aq(t)),children:t})}},sort:{type:`text`,extractor:e=>XK(e)?.outputType??``},filter:{extractor:e=>XK(e)?.outputType??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1}},gq={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=>XK(e)?.stackLevel??0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},_q={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?nV(t):`${nV(t)} / ${nV(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=>XK(e)?.elapsed??0},graph:{extractor:e=>XK(e)?.elapsed,axisLabel:`Elapsed`,unit:`s`,color:`#14b8a6`},meta:{tags:[`timing`],defaultVisible:!1}},vq={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=>XK(e)?.completionReason??``},filter:{extractor:e=>XK(e)?.completionReason??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},yq=iq(J.Effort,{defaultVisible:!1}),bq=iq(J.Duration,{debugOnly:!0}),xq=iq(J.Rep),Sq=iq(J.Rounds,{defaultVisible:!1}),Cq=iq(J.Distance),wq=iq(J.Resistance),Tq=iq(J.Action),Eq=iq(J.Increment),Dq=iq(J.Metric),Oq=iq(J.Calculated),kq=iq(J.Custom,{defaultVisible:!1}),Aq=iq(J.Group,{defaultVisible:!1}),jq=iq(J.System,{defaultVisible:!1}),Mq=iq(J.Label,{defaultVisible:!1}),Nq=iq(J.Text),Pq=iq(J.CurrentRound,{defaultVisible:!1}),Fq=iq(J.Volume),Iq=iq(J.Intensity),Lq=iq(J.Load),Rq=iq(J.Work),zq=[uq,pq,dq,fq,mq,hq,gq,_q,vq,{id:`exercise`,label:`Exercise`,icon:SV(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=>tq(e)},filter:{extractor:e=>tq(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`grouping`,`fallback`,`descriptor`],subsumes:[`effort`,`text`,`label`]}},{id:`descriptor`,label:`Descriptor`,icon:SV(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=>KK(e,0)},sort:{type:`text`,extractor:e=>tq(e)},filter:{extractor:e=>tq(e),caseInsensitive:!0},meta:{defaultVisible:!0,subsumes:[`effort`,`label`,`rounds`,`current-round`]}},yq,Nq,Mq,bq,{id:`pace`,label:`Pace`,icon:`⏱️`,source:{type:`derived`,dependencies:[`distance`,`duration`],compute:(e,t)=>{let n=$K(t.dependencies.get(`distance`)),r=$K(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:[nV(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?``:`${nV(1e3/e)}/km`,caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`endurance`,`derived`]}},xq,Sq,Cq,wq,Tq,Eq,Dq,Oq,kq,Pq,Fq,Iq,{id:`loadFocus`,label:`Load`,icon:SV(J.Load)??SV(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=>KK(e,0)},sort:{type:`numeric`,extractor:e=>$K(e)},graph:{extractor:e=>$K(e),axisLabel:`Load`,unit:`kg`},filter:{extractor:e=>eq(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`strength`,`fallback`]}},Lq,Rq,Aq,jq],Bq={outputTypes:[`segment`,`milestone`,`group`,`analytics`]},Vq={definitions:zq,presets:{default:{label:`Default`,filters:Bq,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:Bq,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`rep`,`loadFocus`,`volume`,`intensity`,`load`,`work`,`elapsedTotal`]},endurance:{label:`Endurance`,filters:Bq,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`distance`,`duration`,`pace`,`rounds`,`increment`,`work`,`elapsedTotal`]}},defaultPreset:`default`},Hq=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 gK(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}}}(Vq);function Uq(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)(()=>Wq(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)(()=>Hq.getVisibleColumns(p),[p]),h=(0,W.useMemo)(()=>Hq.getAvailableColumns(p),[p]),g=(0,W.useMemo)(()=>({...Hq.getPreset(r).filters??{},...o}),[r,o]);return{rows:(0,W.useMemo)(()=>Jq(qq(d,g,m,Hq.definitions),a,m,Hq.definitions),[d,g,a,m]),visibleColumns:m,availableColumns:h,graphTaggedColumnIds:(0,W.useMemo)(()=>Array.from(s??[]),[s])}}function Wq(e,t){return e.map((e,n)=>{let r=new Map;if(e.metrics)for(let t of e.metrics)Kq(r,t);let i=Gq(e),a=i?t.get(i):void 0;if(a)for(let e of a)Kq(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 Gq(e){let t=e.context;return t?.sourceBlockKey?t.sourceBlockKey:e.name}function Kq(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:ma.empty(n).add(t),hasUserOverride:!1})}function qq(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&&AK(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 jK(n,t,o,i,r)}))}return i}function Jq(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=OK(DK(i,t,s,r),DK(a,t,c,r));if(l!==0)return o.direction===`asc`?l:-l}return i.index-a.index}),i}function Yq(e,t){return{id:e,label:t.label,filters:t.filters??{},visibleColumns:[...t.visibleColumnIds],isDefault:e===Vq.defaultPreset}}var Xq=Object.fromEntries(Object.entries(Vq.presets).map(([e,t])=>[e,Yq(e,t)])),Zq=Xq.default;Xq.debug,Xq.strength,Xq.endurance;function Qq(e){return Xq[e]??Zq}var $q=({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(Xq).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`})]}),eJ={"#":`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`},tJ=`48px`;function nJ(e){return e.meta?.width??eJ[e.id]??`96px`}function rJ(){return tJ}var iJ=({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)(aJ,{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:rJ()},children:(0,G.jsx)(cJ,{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)(sJ,{column:e,value:a[e.id]??``,onChange:o},e.id)),c&&(0,G.jsx)(`th`,{className:`py-1 px-1`,style:{minWidth:rJ()}})]})]}),aJ=({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:nJ(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)(oJ,{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:`📊`})]})})},oJ=({direction:e})=>(0,G.jsx)(`span`,{className:`text-primary text-[10px] ml-0.5`,children:e===`asc`?`▲`:`▼`}),sJ=({column:e,value:t,onChange:n})=>e.filter?(0,G.jsx)(`th`,{className:`py-1 px-2`,style:{minWidth:nJ(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:nJ(e)}}),cJ=({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=SV(e)??`•`,i=vo.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)})]})]})},lJ=({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)(NK,{columnDef:r,row:e,allRows:t,rowIndex:n,indent:i?e.stackLevel:0,onDoubleClick:c,style:{minWidth:nJ(r)}},r.id)})})};function uJ(e){let{rows:t,columns:n,graphTaggedColumnIds:r,definitionMap:i}=e,a=(0,W.useMemo)(()=>dJ(r,n),[r,n]),o=(0,W.useMemo)(()=>fJ(t,r,n,i),[t,r,n,i]);return{data:o,graphConfigs:a,hasData:a.length>0&&o.length>0}}function dJ(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:gJ(e),color:pJ(e),dataKey:r,icon:e.icon})}return n}function fJ(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]=kK(i,t,{allRows:e,rowIndex:a,columnDef:t,dependencies:new Map},r)??0}return o})}function pJ(e){if(e.graph?.color)return e.graph.color;let t=mJ(e);return t?hJ[t]??`#888888`:`#888888`}function mJ(e){if(e.source.type===`metric-type`)return e.source.metricType}var hJ={[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 gJ(e){if(e.graph?.unit)return e.graph.unit;let t=mJ(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 _J=({rows:e,columns:t,graphTaggedColumnIds:n,selectedIds:r,onSelectRow:i})=>{let[a,o]=(0,W.useState)(!1),{data:s,graphConfigs:c,hasData:l}=uJ({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)(Ln,{width:`100%`,height:`100%`,children:(0,G.jsxs)(An,{data:s,onClick:u,children:[(0,G.jsx)(we,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,G.jsx)(tt,{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)(te,{stroke:`hsl(var(--muted-foreground))`,tick:{fontSize:10},domain:[`auto`,`auto`]}),(0,G.jsx)(qn,{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)(bn,{verticalAlign:`top`,height:24,wrapperStyle:{fontSize:`11px`}}),c.map(e=>(0,G.jsx)(at,{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.`})})]})},vJ=({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=SV(n),_=bV(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`})]})]})]})},yJ=({segments:e,selectedSegmentIds:t,onSelectSegment:n,userOutputOverrides:r=new Map,gridViewPreset:i=`default`,onPresetChange:a,hoveredBlockKey:o,onHoverBlockKey:s})=>{let{isDebugMode:c}=_v(),[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}=PU(!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 ma?n:ma.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)(()=>Qq(k),[k]),{rows:j,visibleColumns:M,availableColumns:N,graphTaggedColumnIds:P}=Uq({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)($q,{activePreset:A,onPresetChange:te,searchText:d,onSearchChange:f,showFilters:h,onToggleFilters:()=>g(e=>!e),totalRows:I,visibleRows:j.length}),(0,G.jsx)(_J,{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)(iJ,{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)(lJ,{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)(vJ,{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`]})]})]})};Yt();var bJ=({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":pV.FOCUSED_DIALOG_CLOSE,children:s??(0,G.jsx)(Ce,{className:`h-5 w-5`})});return aS.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)},xJ=(0,W.createContext)({updateFromSegments:()=>{},clear:()=>{}}),SJ=({children:e,chromecastSubscription:t=null})=>(0,G.jsx)(xJ.Provider,{value:{updateFromSegments:(e,n,r)=>{t&&t.sendAnalyticsSummary([],n,r)},clear:()=>{}},children:e}),CJ=new class{resolve(e){let t=this.resolveMode(e);return t===`active`?{type:`rpc-workbench-update`,mode:`active`}:t===`review`?AU(e.analyticsSegments):MU(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 wJ(){if(!(`wakeLock`in navigator))return;let e=navigator.wakeLock;if(!(typeof e!=`object`||!e||!(`request`in e)))return e}function TJ(e){let t=(0,W.useRef)(null);(0,W.useEffect)(()=>{let n=wJ();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 EJ(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 DJ=``,OJ=null,kJ=()=>{let e=EH(),[t,n]=(0,W.useState)(e.state),[r,i]=(0,W.useState)(!1);TJ(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=qF,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),Tk(null),u(null),c(null),i(!1)},[p]),_=(0,W.useCallback)(async e=>{if(!h.current){h.current=!0;try{let t=eR.getState().subscriptionManager,n=p.connect(e,t);m.current=n,u(n),c(n.subscription),i(!0),Tk(n.transport),n.eventProvider.onEvent(e=>{if(e.name===`clock-command`){let t=CU(e.data);if(!t){console.warn(`[CastButtonRpc] Dropped malformed clock-command payload`);return}WH(t.runId,t.command)||console.warn(`[CastButtonRpc] Clock command rejected by authority:`,t.command.kind);return}let t=HH(),n=wU(e.name,t);n&&t&&!WH(t.runId,n)&&console.warn(`[CastButtonRpc] Legacy receiver event rejected by authority:`,e.name)});let r=eR.getState(),a=CJ.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:`,EJ(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=HH(),n=JSON.stringify(t);if(n!==DJ||e!==OJ){DJ=n,OJ=e;try{e.send({type:`rpc-clock-snapshot`,snapshot:t})}catch{}}};return t(),UH(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=EJ(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)(zt,{className:`h-5 w-5`})}):(0,G.jsx)(Ak,{transport:l?.transport??null,children:(0,G.jsx)(SJ,{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)(zt,{className:`h-5 w-5`})})})})};function AJ(){let{isEnabled:e,toggleAudio:t}=Nk();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)(ue,{className:`h-[1.2rem] w-[1.2rem]`}):(0,G.jsx)(z,{className:`h-[1.2rem] w-[1.2rem]`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Toggle audio`})]})}async function jJ(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 _M(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 Ay&&e.code===`BLOCK_REVISION_NOT_FOUND`)return`captured-no-rederive`;throw e}}var MJ=new Map,NJ=({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}=_v(),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:FW()}));let a=IW.consent;n?a&&window.gtag?.(`event`,`runtime_dialog_review`,{workout_label:t,block_type:e.blockType}):(IW.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}=iW(y??[],MJ,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=WU(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 jJ({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}=TF($h(await Z.getEventsByResult(a)).map(e=>rM(new _a(e))));b(n),ae(t=>new Set(t).add(WU(e)))},[a]),de=(0,W.useCallback)(e=>{B(t=>new Set(t).add(WU(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}=TF(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,DH(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)(bJ,{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)(kJ,{}),(0,G.jsx)(AJ,{})]}),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)(OW,{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)(bJ,{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)(bJ,{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)(kJ,{}),(0,G.jsx)(AJ,{})]}),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)(lW,{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)(yJ,{runtime:null,segments:y,selectedSegmentIds:x,onSelectSegment:ye,groups:[],gridViewPreset:C?`debug`:`default`})})]})}):(0,G.jsx)(bJ,{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…`})})},PJ={play:!0,"add-to-today":!0,schedule:!0},FJ=`log`;function IJ(e,t){return e.filter(e=>e.id===FJ?t===`log`:!PJ[e.id]||t===`run`)}function LJ(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 RJ(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 zJ=({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)(()=>RJ(i?e.successIcon??e.icon:e.icon),[e.icon,e.successIcon,i]),l=(0,W.useMemo)(()=>RJ(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`?pV.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)(tK,{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`})})},BJ=({view:e,commands:t})=>{let[n,r]=(0,W.useState)(()=>e?.plugin(hw)?.rects??[]),[i,a]=(0,W.useState)(0);(0,W.useEffect)(()=>{if(!e)return;let t=e.plugin(hw);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(hw):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=LJ(e,r),o=IJ(t,xa(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)(zJ,{cmd:e,block:a},e.id))},n.sectionId)})})},VJ=({sections:e,isRuntimeActive:t,editorState:n,onSelectBlock:r})=>{let i=kk(),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},HJ={[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`}},UJ={[J.Rep]:`reps`,[J.Effort]:`movement`,[J.Resistance]:`weight`},WJ=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=HJ[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 GJ(e){let t=fa(e.metadata);return{refs:t?.refs??[],diagnostics:t?.diagnostics??[]}}function KJ(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 qJ=({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??NG)(e.state);o(t),i(t?KJ(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=VV(u,`runtime-badge`),f=l.flatMap(e=>e.metrics.toArray()),p=[],m=[],h=[];for(let e of f){let t=GJ(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(kw)?.()??null:null,_=typeof e?.state?.doc?.sliceString==`function`?CG(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=Yz.getState();if(t===`effort`){let t=await r.open({placeholder:`Change effort…`,sources:[xG(`effort`)]});if(t.dismissed)return;let i=y(t.item.payload);if(!i)return;e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:wG(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:[xG(`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:wG(n,{equipment:i})}})},x=async()=>{if(!e)return;let t=e.state.doc.sliceString(a.lineFrom,a.lineTo),n=Yz.getState(),r,i=await n.open({placeholder:`Add effort (Esc to skip)…`,sources:[xG(`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:[xG(`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:wG(t,{effort:r,equipment:o})}})},S=async t=>{if(!e||!t.token)return;let n=v(t),r=await Yz.getState().open({placeholder:`Replace “${t.token}”…`,sources:[xG(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=UJ[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}cn(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-CazhcFP3.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)(WJ,{metric:e,tooltip:e.type===J.Hint?String(e.value??``):d[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:UJ[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`})]})},JJ=new ui,YJ=new ui,XJ=new ui;async function ZJ(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 QJ(e){let t=await ZJ(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function $J(e){let t=await ZJ(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${Hy()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var eY=({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:C=!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),te=(0,W.useRef)(null),re=(0,W.useRef)(``);(0,W.useEffect)(()=>{let e=async e=>{if(e.view!==z.current||!tY(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=nY(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)&&tY(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 yG();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=nY(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=nY(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}};return dw(e),()=>{fw(e)}},[]);let ie=p===`dark`||p===`vs-dark`,ae=TG(te,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=WG(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 eI({noteId:e??w(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:we.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,w(),e?void 0:`playground`,ae);Se.current=c,De.current=null,we.current=c.note.sourceRevision,r.dispatch({effects:UC.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=KT(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Er.scrollIntoView(e,{y:`start`,yMargin:96})]}),l?.(t.state.doc.toString())}}r||(je.current={results:t,resultId:a,runBlock:o});let s;try{s=OU(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)(pn,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:Oe}):g&&e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(pn,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:g}),e.push({id:`playground`,label:`Playground`,icon:(0,G.jsx)(Je,{className:`h-3 w-3`}),splitIcon:(0,G.jsx)(ne,{className:`h-3 w-3`}),splitSuccessIcon:(0,G.jsx)(un,{className:`h-3 w-3`}),onClick:e=>{QJ(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await $J(e.content);await navigator.clipboard.writeText(t)}}),y&&e.push({id:`plan`,label:`Plan`,icon:(0,G.jsx)(Dn,{className:`h-3 w-3`}),onClick:y}),e},[A,g,y,M,j,Oe]),Pe=(0,W.useMemo)(()=>hi({codeLanguages:DG}),[]),Fe=(0,W.useMemo)(()=>[...T?[Qr(),Hr()]:[],Wr(),pi(),kr(),mi(),...C?[Er.lineWrapping]:[],ri.allowMultipleSelections.of(!0),Dr(),Ti(),Ur(),yi(),fi.highest(yr.of([{key:`Tab`,run:e=>Rr(e.state)!==null&&(Ei(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=nY(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:(xr(e),ei(e))}}])),yr.of([...Lr,...$r,...li,...ci,...wi,...di,ti,{key:`Mod-s`,run:()=>(o?.(),!0)},{key:`Ctrl-.`,run:e=>{let t=NG(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(cn(()=>Promise.resolve().then(()=>Jz).then(()=>{cn(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-CazhcFP3.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{Yz.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),QT,ZC,BC.of({blocks:t??ja(c,{sourceRevision:Math.max(1,n),registeredWidgets:P?[...P.keys()]:Ta}),sourceRevision:Math.max(1,n),rawContent:c}),VC.of(P?[...P.keys()]:Ta),QC,jw.of(D),...E||!D?[iT]:[],...E?[ww,Dw,dG(),vG(),xT,hT(),MT]:[],...O?[rw]:[],pw,lw,cw,...k?[$T]:[],hw,zC,IG,...RT,FC,...P&&P.size>0?[jE(P)]:[],sE({executor:PI,onResultSaved:EU,readOnly:m,noteHref:e=>kB(`blockContentId`in e||`dataType`in e?$I(e):qI(e))}),EG(e,ae),Er.domEventHandlers({blur:()=>(f?.(),!1)}),Er.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),iY(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`))&&Rr(e.startState)!==null&&Rr(e.state)===null&&nY(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&ii(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);d?.(n.number,t-n.from+1);let r=ew(e.state);B(r?.id??null),le(n.number);let{sections:i}=e.state.field(ZC);V(i)}}),ri.readOnly.of(m),Er.editable.of(!m),...R?[bi(R)]:[]],[l,d,f,u,v,r,m,o,s,T,C,E,D,O,k,e,ae,P,R]);return(0,W.useEffect)(()=>{let e=ee.current;if(!e)return;let t=ri.create({doc:c,extensions:[...Fe,JJ.of(PC(ie)),YJ.of(Pe),XJ.of([]),...N??[]]}),n=new Er({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:Er.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=ew(n.state);B(u?.id??null);let d=n.state.field(ZC);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),iY(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:UC.of({blocks:t,sourceRevision:n})}):e.dispatch({changes:{from:0,to:e.state.doc.length,insert:c},...t?{effects:WC.of({rawContent:c,blocks:t,sourceRevision:n})}:{}})},[c,t,n]),(0,W.useEffect)(()=>{z.current&&z.current.dispatch({effects:JJ.reconfigure(PC(ie))})},[ie]),(0,W.useEffect)(()=>{if(z.current){let e=[];z.current.dispatch({effects:[Xr.reconfigure.of([...Fe,JJ.of(PC(ie)),YJ.of(Pe),XJ.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},HJ={[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`}},UJ={[J.Rep]:`reps`,[J.Effort]:`movement`,[J.Resistance]:`weight`},WJ=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=HJ[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 GJ(e){let t=fa(e.metadata);return{refs:t?.refs??[],diagnostics:t?.diagnostics??[]}}function KJ(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 qJ=({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??NG)(e.state);o(t),i(t?KJ(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=VV(u,`runtime-badge`),f=l.flatMap(e=>e.metrics.toArray()),p=[],m=[],h=[];for(let e of f){let t=GJ(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(kw)?.()??null:null,_=typeof e?.state?.doc?.sliceString==`function`?CG(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=Yz.getState();if(t===`effort`){let t=await r.open({placeholder:`Change effort…`,sources:[xG(`effort`)]});if(t.dismissed)return;let i=y(t.item.payload);if(!i)return;e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:wG(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:[xG(`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:wG(n,{equipment:i})}})},x=async()=>{if(!e)return;let t=e.state.doc.sliceString(a.lineFrom,a.lineTo),n=Yz.getState(),r,i=await n.open({placeholder:`Add effort (Esc to skip)…`,sources:[xG(`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:[xG(`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:wG(t,{effort:r,equipment:o})}})},S=async t=>{if(!e||!t.token)return;let n=v(t),r=await Yz.getState().open({placeholder:`Replace “${t.token}”…`,sources:[xG(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=UJ[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}cn(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-BxaSCews.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)(WJ,{metric:e,tooltip:e.type===J.Hint?String(e.value??``):d[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:UJ[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`})]})},JJ=new ui,YJ=new ui,XJ=new ui;async function ZJ(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 QJ(e){let t=await ZJ(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function $J(e){let t=await ZJ(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${Hy()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var eY=({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:C=!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),te=(0,W.useRef)(null),re=(0,W.useRef)(``);(0,W.useEffect)(()=>{let e=async e=>{if(e.view!==z.current||!tY(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=nY(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)&&tY(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 yG();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=nY(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=nY(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}};return dw(e),()=>{fw(e)}},[]);let ie=p===`dark`||p===`vs-dark`,ae=TG(te,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=WG(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 eI({noteId:e??w(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:we.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,w(),e?void 0:`playground`,ae);Se.current=c,De.current=null,we.current=c.note.sourceRevision,r.dispatch({effects:UC.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=KT(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Er.scrollIntoView(e,{y:`start`,yMargin:96})]}),l?.(t.state.doc.toString())}}r||(je.current={results:t,resultId:a,runBlock:o});let s;try{s=OU(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)(pn,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:Oe}):g&&e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(pn,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:g}),e.push({id:`playground`,label:`Playground`,icon:(0,G.jsx)(Je,{className:`h-3 w-3`}),splitIcon:(0,G.jsx)(ne,{className:`h-3 w-3`}),splitSuccessIcon:(0,G.jsx)(un,{className:`h-3 w-3`}),onClick:e=>{QJ(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await $J(e.content);await navigator.clipboard.writeText(t)}}),y&&e.push({id:`plan`,label:`Plan`,icon:(0,G.jsx)(Dn,{className:`h-3 w-3`}),onClick:y}),e},[A,g,y,M,j,Oe]),Pe=(0,W.useMemo)(()=>hi({codeLanguages:DG}),[]),Fe=(0,W.useMemo)(()=>[...T?[Qr(),Hr()]:[],Wr(),pi(),kr(),mi(),...C?[Er.lineWrapping]:[],ri.allowMultipleSelections.of(!0),Dr(),Ti(),Ur(),yi(),fi.highest(yr.of([{key:`Tab`,run:e=>Rr(e.state)!==null&&(Ei(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=nY(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:(xr(e),ei(e))}}])),yr.of([...Lr,...$r,...li,...ci,...wi,...di,ti,{key:`Mod-s`,run:()=>(o?.(),!0)},{key:`Ctrl-.`,run:e=>{let t=NG(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(cn(()=>Promise.resolve().then(()=>Jz).then(()=>{cn(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-BxaSCews.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{Yz.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),QT,ZC,BC.of({blocks:t??ja(c,{sourceRevision:Math.max(1,n),registeredWidgets:P?[...P.keys()]:Ta}),sourceRevision:Math.max(1,n),rawContent:c}),VC.of(P?[...P.keys()]:Ta),QC,jw.of(D),...E||!D?[iT]:[],...E?[ww,Dw,dG(),vG(),xT,hT(),MT]:[],...O?[rw]:[],pw,lw,cw,...k?[$T]:[],hw,zC,IG,...RT,FC,...P&&P.size>0?[jE(P)]:[],sE({executor:PI,onResultSaved:EU,readOnly:m,noteHref:e=>kB(`blockContentId`in e||`dataType`in e?$I(e):qI(e))}),EG(e,ae),Er.domEventHandlers({blur:()=>(f?.(),!1)}),Er.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),iY(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`))&&Rr(e.startState)!==null&&Rr(e.state)===null&&nY(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&ii(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);d?.(n.number,t-n.from+1);let r=ew(e.state);B(r?.id??null),le(n.number);let{sections:i}=e.state.field(ZC);V(i)}}),ri.readOnly.of(m),Er.editable.of(!m),...R?[bi(R)]:[]],[l,d,f,u,v,r,m,o,s,T,C,E,D,O,k,e,ae,P,R]);return(0,W.useEffect)(()=>{let e=ee.current;if(!e)return;let t=ri.create({doc:c,extensions:[...Fe,JJ.of(PC(ie)),YJ.of(Pe),XJ.of([]),...N??[]]}),n=new Er({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:Er.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=ew(n.state);B(u?.id??null);let d=n.state.field(ZC);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),iY(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:UC.of({blocks:t,sourceRevision:n})}):e.dispatch({changes:{from:0,to:e.state.doc.length,insert:c},...t?{effects:WC.of({rawContent:c,blocks:t,sourceRevision:n})}:{}})},[c,t,n]),(0,W.useEffect)(()=>{z.current&&z.current.dispatch({effects:JJ.reconfigure(PC(ie))})},[ie]),(0,W.useEffect)(()=>{if(z.current){let e=[];z.current.dispatch({effects:[Xr.reconfigure.of([...Fe,JJ.of(PC(ie)),YJ.of(Pe),XJ.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:[Er.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)(zG,{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)(mK,{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)(JG,{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)(hK,{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)(BJ,{view:me??z.current,commands:Ne}),(0,G.jsx)(qJ,{view:me??z.current,cursorVersion:ue}),ge&&z.current&&(0,G.jsx)(NJ,{block:ge,view:me??z.current,onClose:ke,onCompleteWorkout:Me,resultId:ve??void 0,autoStart:be}),(0,G.jsx)(VJ,{sections:se,isRuntimeActive:ge!==null,editorState:(me??z.current)?.state??null,onSelectBlock:Ae})]})};function tY(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 nY(e,t){if(!tY(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 rY(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=Ls().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 iY(e,t,n){if(!t)return;let r=e.field(ZC).sections.filter(e=>e.type===`time`||e.type===`log`).map(t=>rY(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 aY({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)(pn,{size:11,fill:`currentColor`}),v.label??`Run`]})]});return(0,G.jsx)(uG,{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)(eY,{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 oY({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)(aY,{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 sY(e,t){return e>=t?`split`:`stack`}function cY(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:sY(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:sY(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 lY=e=>Math.max(0,Math.min(1,e)),uY=(e,t,n)=>e+(t-e)*n,dY=e=>1-(1-e)**2;function fY(e,t){return e===``||t===e}var pY={id:``,range:[0,1]};function mY(e,t){if(!t||t.length===0)return{index:-1,stage:pY,t:0,ring:null};let n=lY(e),r=t.map(e=>({...e,start:lY(Math.min(e.range[0],e.range[1])),end:lY(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]??pY,o=(a.end??1)-(a.start??0),s=o>0?lY((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 hY(e,t,n){let r=t-n;return{progress:r>0?lY(-e/r):0,reached:e<=0,inView:e<n&&e+t>0}}function gY(e,t){let n=t/2;for(let t of e)if(t.top<=n&&t.bottom>n)return t.id;return null}var _Y=(0,W.createContext)(null);function vY(){return(0,W.useContext)(_Y)}function yY({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=gY(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=hY(r.top,r.height,e);t.onMeasure({slice:mY(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)(_Y.Provider,{value:h,children:e})}function bY(e,t){let n=vY()?.registerAnchor;(0,W.useEffect)(()=>{if(n)return n(e,()=>t.current)},[n,e,t])}function xY({gateId:e,segmentId:t,className:n,children:r}){let i=vY(),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 SY({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=cY(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)(cG.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)(xY,{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 CY(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 wY(e,t,n=`smooth`){let r=CY(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 TY(e,t,n,r){let[i,a]=(0,W.useState)(()=>mY(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=vY(),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(mY(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 EY={reference:!0},DY={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 OY(e,t){let n=e.filter(e=>!EY[e.id]),r=e.filter(e=>EY[e.id]);if(n.length===0)return{groups:[],tail:r};let i=t?DY[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 kY(e){let t=Math.max(1,e.length);return e.map((e,n)=>({id:e.id,range:[n/t,(n+1)/t]}))}var AY=[{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 jY({slides:e=AY,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 MY=`wodwiki:text-filter-navigation`,NY=({paramName:e=`q`,placeholder:t=`Search…`,autoFocus:n=!1,className:r,navigationScope:i,inputTestId:a})=>{let[o,s]=Gt(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)(en,{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(MY,{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 PY(e){let t=[],n=!1;for(let r of e){if(r.trim()===`---`){n=!n;continue}n||t.push(r)}return t}function FY(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 IY(e){return new Date(e).toISOString().slice(0,10)}function LY(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.content.toLowerCase().includes(n)||e.date!==void 0&&IY(e.date).includes(n)}function RY(e){if(!e)return null;let t=PY(Db(e).split(`
|
|
161
161
|
`)).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`)&&!e.startsWith("```"))[0];return t?FY(t):null}var zY=({category:e,workoutItems:t,onSelect:n,showSearch:r=!0,variant:i=`card`,className:a,navigationScope:o=`q`,getItemActions:s})=>{let[c]=Gt(`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=>LY(e,c)),[t,e,c]),h=(0,W.useMemo)(()=>m.map(e=>({item:e,preview:RY(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(MY,e),()=>{window.removeEventListener(MY,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)(NY,{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)(A,{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:DF(new Date(e.item.date))}),(0,G.jsx)(wn,{className:`size-4 text-muted-foreground shrink-0 transition-opacity`})]}):r.label},r.id)})},e.item.id)})})]})};function BY(){return(0,W.useEffect)(()=>{OI().catch(e=>console.warn(`[queryService] page source population failed`,e))},[]),(0,W.useSyncExternalStore)(jI,AI)}function VY(e,t){let n=e.find(e=>e.key===t&&!e.negate);return n&&n.values.length===1?n.values[0].value:null}function HY(e){let t=e.trim();if(!t.startsWith(`:`))return null;let n=X(t);if(n.error||!Wp(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=VY(n.filters,`notebook`)??VY(n.filters,`catalog`);if(e){let t=Sa(e);return t===`journal`?`/journal${r}`:t===`playground`?`/playgrounds${r}`:`/c/${encodeURIComponent(t)}${r}`}let t=VY(n.filters,`source`);return t===`journal`?`/journal${r}`:t===`playground`?`/playgrounds${r}`:t===`feeds`||t===`notebooks`||t===`notebook`||t===`guides`?`/feeds${r}`:VY(n.filters,`type`)===`dashboard`?`/dashboards${r}`:`/journal${r}`}default:return null}}var UY=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 WY(e){let t=e.split(`.`).pop()?.split(`?`)[0]?.toLowerCase()??``;return UY.has(t)}function GY(e){return/^https?:\/\//.test(e)||e.startsWith(`//`)}function KY({queryText:e,widgetType:t,widgetError:n}){return BY()?(0,G.jsx)(`div`,{className:`my-5 not-prose`,children:(0,G.jsx)(OC,{query:e,widgetType:t,widgetError:n,executor:PI,readOnly:!0,noteHref:e=>kB(`blockContentId`in e||`dataType`in e?$I(e):qI(e))})}):(0,G.jsx)(`div`,{className:`my-5 not-prose text-xs text-muted-foreground py-2`,children:`Loading…`})}function qY(e){let{meta:t,body:n}=Sb(e);return Object.keys(t).length===0&&n===e?{fields:null,body:e}:{fields:t,body:n.trim()}}var JY={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=HY(e);if(r)return(0,G.jsx)(Wn,{to:r,className:`underline underline-offset-2 transition-colors text-primary hover:text-primary/70`,children:t})}let r=GY(n),i=WY(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?Lg(r):void 0;return(0,G.jsx)(KY,{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})}},YY={...JY,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})}},XY={...JY,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})}},ZY=[Un];function QY(e){return e.startsWith(`:`)?e:Pn(e)}function $Y(e){return e.type===`text`&&typeof e.value==`string`?e.value:(e.children??[]).map($Y).join(``)}function eX(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N} _-]/gu,``).replace(/ /g,`-`).replace(/-+/g,`-`)||`heading`}var tX=()=>e=>{let t=new Map,n=e=>{if(e.tagName&&/^h[1-6]$/.test(e.tagName)){let n=eX($Y(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 nX({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 rX={default:JY,heroLead:YY,heroBody:XY};function iX({prose:e,className:t,variant:n=`default`}){if(!e)return null;let{fields:r,body:i}=qY(e);return(0,G.jsxs)(`div`,{className:K(`prose-canvas`,t),children:[r&&(0,G.jsx)(nX,{fields:r}),i&&(0,G.jsx)(gn,{remarkPlugins:ZY,rehypePlugins:[tX],urlTransform:QY,components:rX[n],children:i})]})}var aX=({activations:e,fullBleed:t,runState:n,deps:r})=>{if(e.length===0)return null;let i=e[0];if(PN(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)(Be,{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||pn;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:()=>jN(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:()=>jN(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))})},oX=({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}`)})})}),sX=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`})]}),cX=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`})]}),lX=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)`})]}),uX=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)`})]}),dX=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`})]}),fX=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)`})]}),pX=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`})]}),mX=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`})]}),hX=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`})]}),gX=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)`})]}),_X=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`})]}),vX=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 yX(e){switch(e){case`trophy`:return uX;case`dumbbell`:return A;case`timer`:return cX;case`play`:return pn;case`blocks`:return sX;case`puzzle`:return lX;case`activity`:return gX;case`file-text`:return vX;default:return Ke}}function bX(e){switch(e){case`basics-movement`:return uX;case`basics-reps`:return dX;case`basics-load`:return fX;case`structure-rounds`:case`complex-rounds`:case`protocols-rounds`:return pX;case`structure-repscheme`:return mX;case`protocols-timer`:case`complex-time`:return cX;case`protocols-tag`:return hX;case`metrics-custom`:return gX;case`metrics-calc`:return _X;case`dialects-log`:case`dialects-climb`:return vX;default:return null}}function xX({quest:e,onClick:t,className:n,compact:r=!1,disabled:i=!1}){let a=bX(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)(un,{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)(Kn,{className:r?`size-3.5`:`size-4`}):(0,G.jsx)(Pt,{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 SX(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 CX=({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=BP[e.theme||`slate`]??BP.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`?SX(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)(iX,{prose:o,variant:`heroLead`,className:`mb-5`}),s&&(0,G.jsx)(iX,{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)(iX,{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)(xX,{quest:n,onClick:()=>b?.(r),compact:!0})},`hero-challenge-${t}`):null}return null}),t.length>0&&(0,G.jsx)(aX,{activations:t.map((e,t)=>NN(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)(iX,{prose:n,className:t===0?`mb-6`:`mt-4 mb-6`},`prose-${t}`):null}if(e.kind===`button`)return(0,G.jsx)(aX,{activations:[NN(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)(jY,{})},`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)(zY,{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)(xX,{quest:n,onClick:()=>b?.(r),compact:!0})},`challenge-${t}`):null}return null}),E.length>0?(0,G.jsx)(oX,{examples:E,activeIndex:Math.min(p,E.length-1),onSelect:t=>f(e,t)}):null,s&&A?(0,G.jsx)(aX,{activations:e.buttons.map((e,t)=>NN(e,t)),fullBleed:S,runState:l?u:void 0,deps:d}):null]})]},`${e.id}-${i}`)};function wX({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)(CX,{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 TX({sections:e,part:t,partCount:n,title:r,pane:i,cardArgs:a,onActivateSection:o}){let s=(0,W.useRef)(null),c=(0,W.useMemo)(()=>kY(e),[e]),{slice:l,subscribe:u}=TY(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)(SY,{trackRef:s,height:`${(e.length+1)*100}vh`,stages:c,activeIndex:l.index,pane:f?i:null,captions:(0,G.jsx)(wX,{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 EX({sections:e,groupKey:t,title:n,pane:r,cardArgs:i,onActivateSection:a}){let{groups:o,tail:s}=OY(e,t);return(0,G.jsxs)(G.Fragment,{children:[o.map((e,t)=>(0,G.jsx)(TX,{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)(CX,{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 DX({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,aS.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)(Ce,{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 OX({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 kX=`hsl(var(--primary))`,AX={ink:`hsl(var(--foreground))`,editor:kX,timer:kX,analytics:kX,library:kX,rounds:kX},jX={editor:`WOD Editor & Autocomplete`,timer:`Clock`,analytics:`WQL Analytics`,metrics:`Own the Metrics`,result:`Run Results`},MX={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`},NX=`dQw4w9WgXcQ`,PX=`https://i.ytimg.com/vi/${NX}/hqdefault.jpg`;function FX({variant:e=`index`}){let t=gF(),{pathname:n}=mt(),[r,i]=(0,W.useState)(null),a=(0,W.useMemo)(()=>MP(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)(DX,{videoId:NX,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)(OX,{index:`05`,before:`Wod Wiki `,accentText:`University`,after:``,accent:AX.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:PX,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)(pn,{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)(Wn,{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)(Wn,{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)(pn,{className:`size-3.5`}),`Watch`]})]},e.id))})]}),u]})}var IX=`22rem`,LX=`42rem`,RX=`20rem`,zX=`calc(100dvh - var(--canvas-sticky-top) - 2rem)`;function BX(e){return{editorWidth:e||`50%`,editorMinWidth:IX,editorMaxWidth:LX,editorMinHeight:RX,editorMaxHeight:zX}}function VX(e){let t=Math.max(1,e.split(`
|
|
@@ -203,4 +203,4 @@ Fran went unbroken until round three. Throat on fire.
|
|
|
203
203
|
`,r8]})]})}var u8=`✎`;function d8({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)(o8,{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:u8})]}),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)(EC,{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 f8({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)(o8,{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 · ${e8.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)(EC,{query:e,onQueryChange:t,autoFocus:!0,showDiagnostics:!1,placeholder:`:session…`})]})]})}function p8({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)(EC,{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)(o8,{wql:e})})}var m8=[[`inline`,`A · in-flow expansion`],[`dock`,`B · bound dock`],[`fence`,`C · fence-as-composer`]];function h8(){let[e,t]=Ct(),n=e.get(`v`)??`inline`,[r,i]=(0,W.useState)(t8),a=e=>{let r=m8[(m8.findIndex(([e])=>e===n)+e+m8.length)%m8.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)(s8,{children:n8.split("```time")[0].trim()}),(0,G.jsx)(c8,{}),n===`inline`&&(0,G.jsx)(d8,{wql:r,setWql:i}),n===`dock`&&(0,G.jsx)(f8,{wql:r,setWql:i}),n===`fence`&&(0,G.jsx)(p8,{wql:r,setWql:i}),(0,G.jsx)(s8,{children:r8})]}),(0,G.jsx)(`div`,{className:`sticky top-6`,children:(0,G.jsx)(l8,{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:`←`}),m8.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 g8(e,t,n=`absent`){return{id:e,fields:t,missPolicy:n,get:()=>void 0}}function _8(){let e=new Hd;return e.register(g8(`effort`,{met:{dimension:Eu,type:`number`},disciplineFactor:{dimension:Eu,type:`number`},discipline:{dimension:Eu,type:`string`},intensityTier:{dimension:Eu,type:`string`},resolvedFrom:{dimension:Eu,type:`string`}},`default-row`)),e.register(g8(`rpe-labels`,{rpe:{dimension:Eu,type:`number`}})),e.register(g8(`profile`,{vo2max:{dimension:Eu,type:`number`}})),e.register(g8(`disciplines`,{disciplineFactor:{dimension:Eu,type:`number`}},`default-row`)),e}function v8(e,t){for(let n of t)try{e.register(n)}catch{}}function y8(e,t=`segment`){let n=[],r=[];try{let i=jf(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 Ed(_8());v8(i,[...Wd,...Jd]);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=Gf(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=zu(a)),r.length===0&&n.push({severity:`warning`,message:`No calc line parsed.`}),{defs:r,diagnostics:n,dim:a,compound:o}}var b8=[`segment`,`workout`,`store`],x8=[`when`,`where`,`key`,`grouped`,`label`,`emit`,`meta`,`estimated`,`library`,`on`,`by`,`without`,`and`,`or`,`not`],S8=[`convert`,`lookup`,`has`,`round`,`floor`,`ceil`,`abs`,`clamp`,`min`,`max`,`sum`,`avg`,`count`,`last`,`windowMean`,`windowSum`,`windowSd`,`mean`],C8=[{name:`elapsed`,dim:Bu.elapsed.dim,detail:`s (time)`},{name:`reps`,dim:Bu.reps.dim,detail:`count`},{name:`resistance`,dim:Bu.resistance.dim,detail:`kg (mass)`},{name:`distance`,dim:Bu.distance.dim,detail:`m (length)`},{name:`effort`,dim:Vu.effort,detail:`resolved effort slug`},{name:`effortLabel`,dim:Vu.effortLabel,detail:`raw effort label`}],w8=[{name:`sessionRpe`,dim:Vu.sessionRpe,detail:`captured session RPE`},{name:`session.duration`,dim:Vu[`session.duration`],detail:`workout duration`},{name:`profile.vo2max`,dim:Vu[`profile.vo2max`],detail:`user VO₂max (mL/kg/min)`}],T8=Object.keys(Bu),E8=Object.keys(Hu),D8=[{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`]}],O8=Object.keys(Ku),k8=Object.keys(Hu);function A8(e){if(!e)return O8;let t=O8.filter(t=>{let n=Ku[t];return n?n.dim.every((t,n)=>t===e[n]):!1});return t.length?t:O8}var j8=new Set([...x8,...b8,`lookup`]),M8=new Set(S8),N8=new Set([...C8.map(e=>e.name),...w8.map(e=>e.name),...T8,...D8.map(e=>e.name)]),P8=/^\d*\.?\d+(?:d)?/,F8=/^[A-Za-z_][\w.]*/,I8=wr.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(P8))return`number`;if(e.match(F8)){let t=e.current();return j8.has(t)?`keyword`:M8.has(t)?`function`:(N8.has(t),`variableName`)}return e.next(),null}}),L8=jr.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 R8(){return new Pr(I8,[Ar(L8)])}var z8=[`effort`,`thruster`,`push-press`,`front-squat`,`wall-ball`,`row`,`run`];function B8(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=D8.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=(D8.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=z8.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=y8(n,t),a=r.diagnostics.length===0?r.dim:void 0,o=A8(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=T8.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(...C8.map(e=>({label:e.name,insert:e.name,detail:e.detail})));else if(a.push(...w8.map(e=>({label:e.name,insert:e.name,detail:e.detail}))),t===`workout`){for(let e of E8)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(...S8.map(e=>({label:`${e}()`,insert:`${e}()`,detail:`function`}))),t===`store`&&a.push(...k8.map(e=>({label:`${e}:{}`,insert:`${e}:`,detail:`WQL atom`}))),a.push(...x8.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 V8(e){return Jr({override:[B8(e)]})}function H8({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=Er.updateListener.of(e=>{e.docChanged&&l.current(e.state.doc.toString())}),o=new Er({state:ri.create({doc:e,extensions:[R8(),V8({scope:n}),Qr(),pi(),yr.of([ti,...$r,...ci]),Er.lineWrapping,ri.readOnly.of(i),r,Er.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 U8({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:G8(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 W8=[[`L`,`length`],[`M`,`mass`],[`T`,`time`],[`C`,`count`],[`E`,`energy`]];function G8(e){let t=[];return e.forEach((e,n)=>{e!==0&&t.push(e===1?W8[n][1]:`${W8[n][1]}${e}`)}),t.length?t.join(`·`):`dimensionless`}function K8(e){return new _a({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 q8(e){return{...e,metrics:e.metrics.filter(e=>e.origin!==`analyzed`)}}function J8(e){return e.output?.emitType??e.output?.key??e.id}function Y8(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 X8(e){return String(Number.isInteger(e)?e:Math.round(e*100)/100)}function Z8(e,t,n){return of(e,{userProfile:t.vo2max===void 0?void 0:{vo2max:t.vo2max},calcs:n}).engine}function Q8(e){let t=[],n=e.defs[0];if(!n)return{rows:[],errors:[`No calc line to preview.`]};let r=J8(n),i=e.logs.filter(e=>e.outputType===`segment`);if(e.scope===`segment`){let n=Z8(e.block,e,e.defs),a=[];for(let e of i){let t=n.run(K8(q8(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:X8(i),unit:t.unit,estimated:t.origin===`analyzed-estimated`,raw:i})}return{rows:a,errors:t}}if(e.scope===`workout`){let n=i.map(q8),a=[];for(let t=1;t<=n.length;t++){let i=Z8(e.block,e,e.defs);for(let e=0;e<t;e++)i.run(K8(n[e]));let o=Y8(i.finalize(),r),s=o&&typeof o.value==`number`?o.value:NaN;o&&Number.isFinite(s)?a.push({label:`after line ${t}`,text:X8(s),unit:o.unit,estimated:o.origin===`analyzed-estimated`,raw:s}):a.push(null)}return{rows:a,errors:t}}return e5(n,t)}var $8=[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 e5(e,t){let n=[],r=e.variants[0]?.nodes[Gf(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)=>$8.map((n,r)=>r+1>=e?t($8.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 t5(r.includes(`windowSum`)||r.includes(` * sum`)?u:d,n),{rows:[],series:n,errors:t}}function t5(e,t){for(let n of e.slice(-7))t.push(Number.isNaN(n)?null:Number(Math.round(n*100)/100))}var n5=[{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 r5(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 i5(e,t){let n=[r5(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`}),rM(new _a({outputType:`segment`,timeSpan:{started:t*1e3,ended:t*1e3+e.elapsedMs},sourceBlockKey:`preview-block`,stackLevel:1,metrics:n}))}function a5(){return{id:`preview-block`,dialect:`time`,startLine:0,endLine:10,content:"```time\nFran preview\n```",state:`idle`,widgetIds:{},version:1,createdAt:0}}var o5=n5.map((e,t)=>i5(e,t+1)),s5=a5();function c5(e){return e==null?`—`:String(e)}function l5({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 Q8({logs:o5,block:s5,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:c5(e)})]},t))}),a?.errors?.length?a.errors.map((e,t)=>(0,G.jsxs)(`div`,{className:`text-destructive`,children:[`⚠ `,e]},`e-${t}`)):null]})}var u5=`wodwiki-user-calcs`,d5=1,f5=`calcs`,p5=`user-calc:`,m5;function h5(){return m5||=or(u5,d5,{upgrade(e){e.objectStoreNames.contains(f5)||e.createObjectStore(f5,{keyPath:`id`})}}),m5}async function g5(){return mO?(await SO(p5)).map(e=>e.value).sort((e,t)=>t.updatedAt-e.updatedAt):(await(await h5()).getAll(f5)).sort((e,t)=>t.updatedAt-e.updatedAt)}async function _5(e){if(mO){await CO(p5+e.id,{id:e.id,lineForm:e.lineForm,updatedAt:e.updatedAt??Date.now()});return}await(await h5()).put(f5,{...e,updatedAt:e.updatedAt??Date.now()})}async function v5(e){if(mO)return wO(p5+e);await(await h5()).delete(f5,e)}var y5=[`segment`,`workout`,`store`];function b5(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 x5({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)(()=>y8(n,i),[n,i]),d=b5(u.defs,n),f=u.diagnostics.every(e=>e.severity!==`error`)&&u.defs.length>0,p=async()=>{s(await g5())};(0,W.useEffect)(()=>{p()},[]),(0,W.useEffect)(()=>{t&&(async()=>{let e=(await g5()).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 _5({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 v5(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:y5.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)(H8,{value:n,onChange:r,scope:i,autoFocus:!0}),(0,G.jsx)(U8,{analysis:u}),(0,G.jsx)(l5,{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 S5(){let e=Sn(),[t]=Gt(`zip`),[n]=Gt(`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 C5(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 w5(){let e=Sn(),t=mt(),{date:n}=zn(),[r]=Gt(`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 C5(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=OM(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=EM();if(i)return;if(DM(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 jM.create({journalDate:n,title:n,rawContent:t});i||(a({state:`success`,content:t,dateKey:n}),e(Mj(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 T5=({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}=gQ(`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?DF(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)(Kn,{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)(SR,{open:o,onOpenChange:h,children:[(0,G.jsx)(CR,{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)(Ut,{className:`h-4 w-4 shrink-0`}),e&&(0,G.jsx)(`span`,{className:`leading-none text-xs`,children:g})]})}),(0,G.jsx)(wR,{align:d,className:`p-0 w-auto`,children:(0,G.jsx)(RZ,{selectedDate:e||null,onDateSelect:m,entryDates:r})})]})]})},E5=({dateKey:e,onConfirm:t,onCancel:n,isLoading:r=!1})=>{let[i,a]=W.useState(!1),o=EF(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)(Ce,{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`})]})]})})]})},D5={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 O5(){let e=Sn(),t=w5(),[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)(ar,{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)(T5,{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)(Qt,{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)(gn,{remarkPlugins:[Un],components:D5,children:s})}):null]}),n&&c&&(0,G.jsx)(E5,{dateKey:c,onConfirm:async()=>{u&&(r(!1),await u())},onCancel:()=>r(!1),isLoading:o===`creating`})]})}function k5(){let e=mt(),t=Sn(),[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 Fk(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=Xk().find(e=>DO(new URL(e.url,window.location.href).href)===n.url)??PO(n.manifest.name?.trim()||new URL(n.url).hostname,n.url,{repositoryUrl:n.manifest.repositoryUrl}),a=await _A(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=hk(r.id,i),t=dk(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 A5(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 sO().updateEntry(r.id,{rawContent:o,expectedSourceRevision:r.sourceRevision})}function j5(){let{runtimeId:e}=zn(),t=Sn(),n=(0,W.useRef)(e?HZ.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 eI(t.snapshot,t.block,e,t.origin):await tI(t.noteId,t.block,e,t.origin),r.current.block)},[e]);(0,W.useEffect)(()=>{e&&HZ.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,kU.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 A5(a.noteId,a.block.id,e)}catch{}})),[e,a]),c=(0,W.useCallback)(()=>{if(!a){t(`/`);return}if(o.current){t(zj(e),{replace:!0});return}if(a.returnTo){t(a.returnTo,{replace:!0});return}t(ZZ(FI(a.noteId)),{replace:!0})},[e,a,t]);return a?(0,G.jsx)(NJ,{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 M5=null;async function N5(e){(!M5||M5.attempt!==e)&&(M5={attempt:e,promise:GW(SQ.content)});try{return await M5.promise}finally{M5?.attempt===e&&(M5=null)}}function P5(){let e=Sn(),[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 N5(r);t||e(kj(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 F5(){let e=Sn(),t=mt(),[n]=Gt(`zip`),[r]=Gt(`z`),[i]=Gt(`by`),[a]=Gt(`src`);(0,W.useEffect)(()=>{if(t.pathname!==`/load`&&!(t.pathname===`/`&&r))return;if(r){let t=!1;return(async()=>{try{let e=await C5(r);if(e===null)throw Error(`Invalid workout link`);if(t)return;let n=TQ(e,i??void 0);if(await KW(n,{reuseKey:`home`,title:`Home playground`}),t)return;OQ({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 C5(n);if(t===null)throw Error(`Invalid workout link`);if(o)return;let r=s?await GW(t,{sourcePath:s}):await GW(t);o||e(kj(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 I5(){let{pathname:e,hash:t}=mt(),{scrollToSection:n}=ej();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 L5(){return F5(),w5(),(0,W.useEffect)(()=>{HD.current().catch(console.error),dD(),D1()},[]),null}function R5({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:()=>{mA().then(()=>oD())},children:`Re-seed library`})]})}function z5(){let e=(0,W.useRef)(()=>{}),t=gF(),n=T1(),r=(0,W.useMemo)(()=>zP(()=>e.current(),t),[t]);return(0,G.jsx)(Ai,{defaultTheme:`system`,storageKey:`wod-wiki-playground-theme`,children:(0,G.jsx)(gv,{children:(0,G.jsx)(TA,{children:(0,G.jsx)(OA,{children:(0,G.jsx)(Mk,{children:(0,G.jsx)(Mt,{children:(0,G.jsxs)(i,{children:[(0,G.jsx)(L5,{}),(0,G.jsx)(YA,{}),(0,G.jsxs)(nj,{tree:r,children:[(0,G.jsx)(I5,{}),(0,G.jsxs)(Xt,{children:[(0,G.jsx)(H,{path:`*`,element:t.some(({route:e})=>e===$.home)?(0,G.jsx)(h6,{}):(0,G.jsx)(R5,{settling:n===`preparing`})}),(0,G.jsx)(H,{path:`/proto/calc-authoring`,element:(0,G.jsx)(Q6,{})}),(0,G.jsx)(H,{path:`/proto/query-block-composer`,element:(0,G.jsx)(h8,{})}),(0,G.jsx)(H,{path:`/settings`,element:(0,G.jsx)(_n,{to:`/settings/appearance`,replace:!0})}),(0,G.jsx)(H,{path:`/settings/appearance`,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsProfile,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsData,element:(0,G.jsx)(_n,{to:$.settingsStorage,replace:!0})}),(0,G.jsx)(H,{path:$.settingsDatabase,element:(0,G.jsx)(_n,{to:$.settingsStorage,replace:!0})}),(0,G.jsx)(H,{path:$.settingsStorage,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsSync,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:`/settings/system`,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsQueries,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.settingsTags,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:`/settings/library/calcs`,element:(0,G.jsx)(`div`,{className:`p-6`,children:(0,G.jsx)(x5,{})})}),(0,G.jsx)(H,{path:`/legacy`,element:(0,G.jsx)($3,{})}),(0,G.jsx)(H,{path:`/syntax`,element:(0,G.jsx)(m6,{})}),(0,G.jsx)(H,{path:`/chapters/basics`,element:(0,G.jsx)(_n,{to:`/guide/start`,replace:!0})}),(0,G.jsx)(H,{path:`/chapters/sequences`,element:(0,G.jsx)(_n,{to:`/guide/start`,replace:!0})}),(0,G.jsx)(H,{path:`/chapters/protocols`,element:(0,G.jsx)(_n,{to:`/guide/protocols`,replace:!0})}),(0,G.jsx)(H,{path:`/challenge`,element:(0,G.jsx)(_n,{to:`/`,replace:!0})}),(0,G.jsx)(H,{path:$.plan,element:(0,G.jsx)(z3,{})}),(0,G.jsx)(H,{path:$.feeds,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.feed,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.feedDetail,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.feedItem,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.catalogs,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.subscribe,element:(0,G.jsx)(k5,{})}),(0,G.jsx)(H,{path:$.collections,element:(0,G.jsx)(M3,{})}),(0,G.jsx)(H,{path:`/collections/:slug`,element:(0,G.jsx)(j3,{})}),(0,G.jsx)(H,{path:`/collections/:slug/:target`,element:(0,G.jsx)(j3,{})}),(0,G.jsx)(H,{path:$.collection,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.collectionTarget,element:(0,G.jsx)(D3,{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)(S5,{})})}),(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)(O5,{})})}),(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)(O5,{})})}),(0,G.jsx)(H,{path:$.playgroundRoot,element:(0,G.jsx)(P5,{})}),(0,G.jsx)(H,{path:$.playground,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.playgrounds,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.notePlaygroundAlias,element:(0,G.jsx)(k3,{})}),(0,G.jsx)(H,{path:$.note,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.journalNote,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.journalEntry,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.noteById,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.journal,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.pages,element:(0,G.jsx)(D3,{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)(j5,{})})}),(0,G.jsx)(H,{path:$.tracker,element:(0,G.jsx)(L3,{})}),(0,G.jsx)(H,{path:`/results`,element:(0,G.jsx)(P3,{})}),(0,G.jsx)(H,{path:`/results/segments`,element:(0,G.jsx)(F3,{})}),(0,G.jsx)(H,{path:$.sessionDetail,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.sessions,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.sessionDate,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:`/review/:runtimeId`,element:(0,G.jsx)(R3,{})}),(0,G.jsx)(H,{path:`/note/:noteId/review`,element:(0,G.jsx)(R3,{})}),(0,G.jsx)(H,{path:`/note/:noteId/review/:sectionId`,element:(0,G.jsx)(R3,{})}),(0,G.jsx)(H,{path:`/note/:noteId/review/:sectionId/:resultId`,element:(0,G.jsx)(R3,{})}),(0,G.jsx)(H,{path:`/workout/:category/:name`,element:(0,G.jsx)(A3,{})}),(0,G.jsx)(H,{path:$.efforts,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.effort,element:(0,G.jsx)(N3,{})}),(0,G.jsx)(H,{path:$.effortSlug,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.equipment,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.equipmentSlug,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.dashboard,element:(0,G.jsx)(I3,{})}),(0,G.jsx)(H,{path:$.dashboards,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.dashboardView,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.dashboardSlug,element:(0,G.jsx)(D3,{searchHandlerRef:e})}),(0,G.jsx)(H,{path:$.analytics,element:(0,G.jsx)(_n,{to:`/dashboards`,replace:!0})}),(0,G.jsx)(H,{path:$.analyticsExplorer,element:(0,G.jsx)(B3,{})}),t.map(({route:t})=>(0,G.jsx)(H,{path:t,element:(0,G.jsx)(D3,{searchHandlerRef:e})},t))]}),(0,G.jsx)(G3,{})]})]})})})})})})})}function B5({error:e,onRetry:t}){let n=e instanceof Error?e.message:String(e),r=MD();return(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 local database 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.`,r.state!==`indexed-db`&&` Turn off Turso Sync to skip backup comparison. Settings → Storage has the full controls once the app loads.`]}),(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`}),r.state!==`indexed-db`&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{RD(),window.location.reload()},"data-testid":`boot-recovery-local`,className:`rounded-md border border-border bg-card px-3 py-1.5 text-xs font-medium hover:bg-accent`,children:`Turn off Turso Sync`})]}),r.state!==`indexed-db`&&(0,G.jsxs)(`details`,{className:`w-full max-w-md rounded-xl border border-border bg-card p-4 text-left`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium`,children:`Fix Turso credentials`}),(0,G.jsx)(`div`,{className:`pt-3`,children:(0,G.jsx)(m3,{saved:r.state===`turso`?{url:r.url,authToken:r.authToken}:void 0})})]})]})}function V5(){let e=(0,W.useSyncExternalStore)(hb,mb),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 H5=(0,Oi.createRoot)(document.getElementById(`root`));function U5(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(0),o=(0,W.useSyncExternalStore)(hb,mb);return(0,W.useEffect)(()=>{let e=!1,n;return qD().then(()=>mO?yO():void 0).then(()=>{e||(n=ZD(),t(!0))}).catch(t=>{e||r(t)}),()=>{e=!0,n?.()}},[i]),n?(0,G.jsx)(B5,{error:n,onRetry:()=>{r(null),a(e=>e+1)}}):o.phase===`checking`||o.phase===`updating`?(0,G.jsx)(V5,{}):e?(0,G.jsx)(z5,{}):(0,G.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Loading…`})}H5.render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(U5,{})}));export{Yz as t};
|
|
206
|
-
//# sourceMappingURL=main-
|
|
206
|
+
//# sourceMappingURL=main-Dqtuz8vM.js.map
|