@bitcobblers/wod-wiki-tools 0.62.2260 → 0.62.2261
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/{agentCommands-FZEZLI5H.mjs → agentCommands-7ZTMAHHJ.mjs} +3 -3
- package/dist/{agentCommands-FZEZLI5H.mjs.map → agentCommands-7ZTMAHHJ.mjs.map} +1 -1
- 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-YBSWZ724.mjs → chunk-75JV5DYH.mjs} +3 -3
- package/dist/{chunk-YBSWZ724.mjs.map → chunk-75JV5DYH.mjs.map} +1 -1
- package/dist/{chunk-LFB3LMTB.mjs → chunk-B5EB3OTP.mjs} +3 -3
- package/dist/chunk-B5EB3OTP.mjs.map +1 -0
- package/dist/{chunk-4D6HEITD.mjs → chunk-F647AF44.mjs} +3 -3
- package/dist/{chunk-4D6HEITD.mjs.map → chunk-F647AF44.mjs.map} +1 -1
- package/dist/{chunk-PCJOLIY2.mjs → chunk-UZB7ZYX5.mjs} +8 -8
- package/dist/{chunk-PCJOLIY2.mjs.map → chunk-UZB7ZYX5.mjs.map} +1 -1
- package/dist/{chunk-WVQNAGMI.mjs → chunk-VYTZI4V6.mjs} +3 -3
- package/dist/{chunk-WVQNAGMI.mjs.map → chunk-VYTZI4V6.mjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{mcp-DB4ABDXN.mjs → mcp-YCX5IVDO.mjs} +4 -4
- package/dist/{mcp-DB4ABDXN.mjs.map → mcp-YCX5IVDO.mjs.map} +1 -1
- package/dist/{scaffoldFeed-74LK6MFH.mjs → scaffoldFeed-63JQVRNI.mjs} +3 -3
- package/dist/{scaffoldFeed-74LK6MFH.mjs.map → scaffoldFeed-63JQVRNI.mjs.map} +1 -1
- package/dist/server/app.cjs +1 -1
- package/dist/server/app.cjs.map +1 -1
- package/dist/server/app.mjs +3 -3
- package/dist/server-3RHUJ744.mjs +13 -0
- package/dist/{server-NFKI7TTY.mjs.map → server-3RHUJ744.mjs.map} +1 -1
- package/dist/web/playground/assets/{main-BjYSJxex.js → main-MZGOL_ej.js} +4 -4
- package/dist/web/playground/index.html +1 -1
- package/dist/web/playground/seed/core/chunks/{canvas.b5b21f61.json → canvas.ae4cc172.json} +1 -1
- package/dist/web/{server/seed/core/chunks/dashboards.04a93a89.json → playground/seed/core/chunks/dashboards.3385e48b.json} +1 -1
- package/dist/web/{server/seed/core/chunks/efforts.7703bcbe.json → playground/seed/core/chunks/efforts.5da5b1e0.json} +1 -1
- package/dist/web/playground/seed/core/chunks/{equipment.f113b687.json → equipment.c214f218.json} +1 -1
- package/dist/web/playground/seed/core/indexes/notebooks/canvas.json +180 -180
- package/dist/web/playground/seed/core/indexes/notebooks/dashboards.json +16 -16
- package/dist/web/playground/seed/core/indexes/notebooks/efforts.json +326 -326
- package/dist/web/playground/seed/core/indexes/notebooks/equipment.json +50 -50
- package/dist/web/playground/seed/core/manifest.json +27 -27
- package/dist/web/playground/seed/core/markdown/canvas/ai-first/README.json +1 -1
- package/dist/web/playground/seed/core/markdown/canvas/guide/README.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/guide/clock.json +1 -1
- package/dist/web/playground/seed/core/markdown/canvas/guide/dashboards.json +1 -1
- package/dist/web/playground/seed/core/markdown/canvas/guide/metrics-summaries.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/guide/metrics.json +12 -12
- package/dist/web/playground/seed/core/markdown/canvas/guide/protocols.json +20 -20
- package/dist/web/playground/seed/core/markdown/canvas/guide/sessions.json +33 -33
- package/dist/web/playground/seed/core/markdown/canvas/guide/start.json +11 -11
- package/dist/web/playground/seed/core/markdown/canvas/guide/structure.json +25 -25
- package/dist/web/playground/seed/core/markdown/canvas/guide/wql.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/home/sample-script.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/home/welcome-1.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/syntax/actions-comments.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/alternating-emom.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/basic-emom.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/calculated-metrics.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/classic-amrap.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-barbell-cycling.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-full-session.json +10 -10
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-nested-protocols.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-partner-workout.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-swimming.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/core-rules.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-and-calculated-metrics.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-intervals.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-1.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-2.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-3.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-4.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-5.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-bouldering.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-hangboard.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-sport.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-log.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-plan.json +8 -8
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-wod.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/distance-intervals.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/document-1.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/document-2.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/document-3.json +10 -10
- package/dist/web/playground/seed/core/markdown/canvas/syntax/document-4.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/effort-notes.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/frontmatter-summaries.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-1.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-2.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-3.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-4.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/longer-duration.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/longer-intervals.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/measurements.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-1.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-2.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-3.json +8 -8
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-4.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-5.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/mixed-sections.json +10 -10
- package/dist/web/playground/seed/core/markdown/canvas/syntax/mixed-timers.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/multiple-amrap-windows.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/multiple-sets.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/named-groups.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-1.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-2.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-3.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-4.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-5.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/single-movement.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-1.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-2.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-3.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-4.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/time-cap.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timer-modifiers.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-1.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-2.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-3.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-4.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-5.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-rest.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/aggregate-by-effort.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/aggregate-by-week.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/content-fran.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/filter-combos.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/pipes-limit.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/session-rpe.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/source-journal.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/tis-trend.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/where-join.json +2 -2
- package/dist/web/playground/seed/core/markdown/dashboards/benchmark-pr-board.json +6 -6
- package/dist/web/playground/seed/core/markdown/dashboards/finger-strength-v8.json +5 -5
- package/dist/web/playground/seed/core/markdown/dashboards/polarized-base-marathon.json +9 -9
- package/dist/web/playground/seed/core/markdown/dashboards/recovery-readiness.json +7 -7
- package/dist/web/playground/seed/core/markdown/dashboards/road-to-560-total.json +9 -9
- package/dist/web/playground/seed/core/markdown/dashboards/training-block-review.json +11 -11
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/air-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/box-jump.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/broad-jump.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee-box-jump-over.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee-over-dumbbell.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/dumbbell-squat-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/ghd-sit-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/ground-kong.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/jumping-jack.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/kong-walk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/lunge.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/overhead-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/parkour-roll.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/parkour-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/pistol-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/plank.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/precision-burpee.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/precision-jump.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/quadrupedal-movement.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/russian-twist.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/sit-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-hold.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-snatch.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/tuck-jump.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/wall-ball.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/wall-burpee.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/cycling/assault-bike.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/cycling/cycling-moderate.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/cycling/cycling-vigorous.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/assisted-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/burpee-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/chest-to-bar-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/dip.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/double-under.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-hold.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-push-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-walk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jump-rope.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jumping-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jumping-push-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/l-sit-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/muscle-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/push-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/reverse-wall-dip.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/rope-climb.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/toes-to-bar.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-arm-bar.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-around-the-world.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-bent-over-row.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-jerk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-floor-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-front-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-goblet-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-gorilla-row.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-halo.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-jerk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-overhead-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-snatch.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-swing.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-windmill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/turkish-get-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/recovery/rest.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/recovery/stretching.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/rowing/rowing-sprint.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/rowing/rowing.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/rowing/ski-erg.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/running/backward-running.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/running/running-6-mph.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/running/running-8-mph.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/running/running-sprint.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/snatch.json +4 -4
- package/dist/web/playground/seed/core/markdown/efforts/strength/back-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/bench-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/box-step-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/carioca.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/clean-and-jerk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/cluster.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dead-hang.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/devils-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-box-step-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-fly.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-row.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-snatch.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-thruster.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/elbows-to-knees.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/farmer-carry.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/frog-stand.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/front-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/good-morning.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/hanging-leg-raise.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/hollow-rock.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/knees-to-elbows.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/l-sit.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/man-maker.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/medicine-ball-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/overhead-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/parkour-vault.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/pig-flip.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/power-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/power-snatch.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/push-jerk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/push-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/romanian-deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/single-leg-deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/skull-crusher.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/slam-ball.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/sled-pull.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/sled-push.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/sumo-deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/thruster.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/triceps-extension.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/v-sit-hold.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/wall-walk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/yoga-sun-salutation.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-assisted-sprint.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-backstroke.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-breaststroke-kick.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-breaststroke.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-butterfly.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-catch-up-drill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-choice-stroke.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-dive-start.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-dolphin-kick.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-drafting.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-fingertip-drag.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-freestyle.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-individual-medley.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-kick.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-pull.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-resisted-sprint.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-rotation-drill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-sighting.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-single-arm-drill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-stroke-transition.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-two-kick-one-pull.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-vigorous.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-arm-cast.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-circles.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-mill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-reverse-mill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-shield-cast.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-10-to-2-swing.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-360-swing.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-barbarian-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-flow.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-gravedigger.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-touchdown.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-carry.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-extension.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-over-shoulder.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/walking/walking-3-mph.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/air-bike.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/barbell.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/bench.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/bike-erg.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/climbing-rope.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/clubs.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/dumbbell.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/ghd.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/gymnastic-rings.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/jump-rope.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/kettlebell.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/macebell.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/medicine-ball.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/parallettes.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/plyo-box.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/pull-up-bar.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/rower.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/sandbag.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/ski-erg.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/slam-ball.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/sled.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/sledgehammer.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/weight-vest.json +1 -1
- package/dist/web/playground/seed/core/report.html +13 -13
- package/dist/web/playground/version.json +3 -3
- package/dist/web/server/assets/{main-Cz8jfPio.js → main-bnWjDW6m.js} +4 -4
- package/dist/web/server/index.html +1 -1
- package/dist/web/server/seed/core/chunks/{canvas.b5b21f61.json → canvas.ae4cc172.json} +1 -1
- package/dist/web/{playground/seed/core/chunks/dashboards.04a93a89.json → server/seed/core/chunks/dashboards.3385e48b.json} +1 -1
- package/dist/web/{playground/seed/core/chunks/efforts.7703bcbe.json → server/seed/core/chunks/efforts.5da5b1e0.json} +1 -1
- package/dist/web/server/seed/core/chunks/{equipment.f113b687.json → equipment.c214f218.json} +1 -1
- package/dist/web/server/seed/core/indexes/notebooks/canvas.json +180 -180
- package/dist/web/server/seed/core/indexes/notebooks/dashboards.json +16 -16
- package/dist/web/server/seed/core/indexes/notebooks/efforts.json +326 -326
- package/dist/web/server/seed/core/indexes/notebooks/equipment.json +50 -50
- package/dist/web/server/seed/core/manifest.json +27 -27
- package/dist/web/server/seed/core/markdown/canvas/ai-first/README.json +1 -1
- package/dist/web/server/seed/core/markdown/canvas/guide/README.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/guide/clock.json +1 -1
- package/dist/web/server/seed/core/markdown/canvas/guide/dashboards.json +1 -1
- package/dist/web/server/seed/core/markdown/canvas/guide/metrics-summaries.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/guide/metrics.json +12 -12
- package/dist/web/server/seed/core/markdown/canvas/guide/protocols.json +20 -20
- package/dist/web/server/seed/core/markdown/canvas/guide/sessions.json +33 -33
- package/dist/web/server/seed/core/markdown/canvas/guide/start.json +11 -11
- package/dist/web/server/seed/core/markdown/canvas/guide/structure.json +25 -25
- package/dist/web/server/seed/core/markdown/canvas/guide/wql.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/home/sample-script.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/home/welcome-1.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/syntax/actions-comments.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/alternating-emom.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/basic-emom.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/calculated-metrics.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/classic-amrap.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-barbell-cycling.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-full-session.json +10 -10
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-nested-protocols.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-partner-workout.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-swimming.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/core-rules.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-and-calculated-metrics.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-intervals.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-1.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-2.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-3.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-4.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-5.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-bouldering.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-hangboard.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-sport.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-log.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-plan.json +8 -8
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-wod.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/distance-intervals.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/document-1.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/document-2.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/document-3.json +10 -10
- package/dist/web/server/seed/core/markdown/canvas/syntax/document-4.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/effort-notes.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/frontmatter-summaries.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/groups-1.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/groups-2.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/groups-3.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/groups-4.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/longer-duration.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/longer-intervals.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/measurements.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-1.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-2.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-3.json +8 -8
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-4.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-5.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/mixed-sections.json +10 -10
- package/dist/web/server/seed/core/markdown/canvas/syntax/mixed-timers.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/multiple-amrap-windows.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/multiple-sets.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/named-groups.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-1.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-2.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-3.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-4.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-5.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/single-movement.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-1.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-2.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-3.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-4.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/time-cap.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/timer-modifiers.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-1.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-2.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-3.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-4.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-5.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-rest.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/aggregate-by-effort.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/aggregate-by-week.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/content-fran.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/filter-combos.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/pipes-limit.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/session-rpe.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/source-journal.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/tis-trend.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/where-join.json +2 -2
- package/dist/web/server/seed/core/markdown/dashboards/benchmark-pr-board.json +6 -6
- package/dist/web/server/seed/core/markdown/dashboards/finger-strength-v8.json +5 -5
- package/dist/web/server/seed/core/markdown/dashboards/polarized-base-marathon.json +9 -9
- package/dist/web/server/seed/core/markdown/dashboards/recovery-readiness.json +7 -7
- package/dist/web/server/seed/core/markdown/dashboards/road-to-560-total.json +9 -9
- package/dist/web/server/seed/core/markdown/dashboards/training-block-review.json +11 -11
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/air-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/box-jump.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/broad-jump.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee-box-jump-over.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee-over-dumbbell.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/dumbbell-squat-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/ghd-sit-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/ground-kong.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/jumping-jack.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/kong-walk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/lunge.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/overhead-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/parkour-roll.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/parkour-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/pistol-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/plank.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/precision-burpee.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/precision-jump.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/quadrupedal-movement.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/russian-twist.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/sit-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-hold.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-snatch.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/tuck-jump.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/wall-ball.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/wall-burpee.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/cycling/assault-bike.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/cycling/cycling-moderate.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/cycling/cycling-vigorous.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/assisted-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/burpee-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/chest-to-bar-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/dip.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/double-under.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-hold.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-push-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-walk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/jump-rope.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/jumping-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/jumping-push-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/l-sit-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/muscle-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/push-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/reverse-wall-dip.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/rope-climb.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/toes-to-bar.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-arm-bar.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-around-the-world.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-bent-over-row.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-jerk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-floor-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-front-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-goblet-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-gorilla-row.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-halo.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-jerk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-overhead-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-snatch.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-swing.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-windmill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/turkish-get-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/recovery/rest.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/recovery/stretching.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/rowing/rowing-sprint.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/rowing/rowing.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/rowing/ski-erg.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/running/backward-running.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/running/running-6-mph.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/running/running-8-mph.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/running/running-sprint.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/snatch.json +4 -4
- package/dist/web/server/seed/core/markdown/efforts/strength/back-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/bench-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/box-step-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/carioca.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/clean-and-jerk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/cluster.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dead-hang.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/devils-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-box-step-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-fly.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-row.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-snatch.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-thruster.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/elbows-to-knees.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/farmer-carry.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/frog-stand.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/front-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/good-morning.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/hanging-leg-raise.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/hollow-rock.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/knees-to-elbows.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/l-sit.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/man-maker.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/medicine-ball-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/overhead-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/parkour-vault.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/pig-flip.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/power-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/power-snatch.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/push-jerk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/push-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/romanian-deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/single-leg-deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/skull-crusher.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/slam-ball.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/sled-pull.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/sled-push.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/sumo-deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/thruster.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/triceps-extension.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/v-sit-hold.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/wall-walk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/yoga-sun-salutation.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-assisted-sprint.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-backstroke.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-breaststroke-kick.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-breaststroke.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-butterfly.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-catch-up-drill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-choice-stroke.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-dive-start.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-dolphin-kick.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-drafting.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-fingertip-drag.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-freestyle.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-individual-medley.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-kick.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-pull.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-resisted-sprint.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-rotation-drill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-sighting.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-single-arm-drill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-stroke-transition.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-two-kick-one-pull.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-vigorous.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-arm-cast.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-circles.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-mill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-reverse-mill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-shield-cast.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-10-to-2-swing.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-360-swing.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-barbarian-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-flow.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-gravedigger.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-touchdown.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-carry.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-extension.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-over-shoulder.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/walking/walking-3-mph.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/air-bike.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/barbell.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/bench.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/bike-erg.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/climbing-rope.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/clubs.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/dumbbell.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/ghd.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/gymnastic-rings.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/jump-rope.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/kettlebell.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/macebell.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/medicine-ball.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/parallettes.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/plyo-box.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/pull-up-bar.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/rower.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/sandbag.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/ski-erg.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/slam-ball.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/sled.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/sledgehammer.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/weight-vest.json +1 -1
- package/dist/web/server/seed/core/report.html +13 -13
- package/dist/web/server/version.json +3 -3
- package/package.json +6 -6
- package/dist/chunk-LFB3LMTB.mjs.map +0 -1
- package/dist/server-NFKI7TTY.mjs +0 -13
|
@@ -151,7 +151,7 @@ query: sum:${r}{notebook:$notebook} by {week}
|
|
|
151
151
|
`)+`
|
|
152
152
|
`}function ES(e){let t=yS(e);if(t.length<2)return{bundles:[],errors:[]};let n=vS(t[0]);if(n[0]!==`recordKind`)try{let t=CS(e);return{bundles:[{sessions:[t.session],events:t.events}],errors:[]}}catch(e){return{bundles:[],errors:[e instanceof Error?e.message:String(e)]}}let r=new Map;n.forEach((e,t)=>r.set(e,t));let i=(e,t)=>{let n=r.get(t);return n===void 0?``:e[n]??``},a=new Map,o=new Map,s=new Map,c=[];for(let[e,n]of t.slice(1).entries()){let t=vS(n);if(t.length===1&&t[0]===``)continue;let r=i(t,`recordKind`),l=xS(i(t,`noteId`));if(!l){c.push(`Row ${e+2}: missing noteId`);continue}if(r===`revision`){let n=xS(i(t,`revisionKind`)),r=xS(i(t,`blockId`)),o=bS(i(t,`blockVersion`)),s=bS(i(t,`revisionSavedAt`));if(!n||!r||!o||s===void 0){c.push(`Row ${e+2}: invalid revision columns`);continue}let u={noteId:l,blockId:r,version:o,kind:n,rawContent:i(t,`revisionRawContent`),savedAt:s,...xS(i(t,`revisionDialect`))?{dialect:xS(i(t,`revisionDialect`))}:{},...xS(i(t,`revisionSport`))?{sport:xS(i(t,`revisionSport`))}:{}},d=a.get(l)??[];d.push(u),a.set(l,d)}else if(r===`parse`){let n=xS(i(t,`parseId`)),r=xS(i(t,`parseStage`)),a=xS(i(t,`parseStatus`)),s=bS(i(t,`timestamp`));if(!n||!r||!a||s===void 0){c.push(`Row ${e+2}: invalid parse columns`);continue}let u={id:n,noteId:l,...xS(i(t,`blockId`))?{blockId:xS(i(t,`blockId`))}:{},...bS(i(t,`blockVersion`))===void 0?{}:{blockVersion:bS(i(t,`blockVersion`))},stage:r,status:a,timestamp:s,...xS(i(t,`parseDiagnosticsJson`))?{diagnostics:SS(i(t,`parseDiagnosticsJson`))}:{},...xS(i(t,`parseMetricsJson`))?{metrics:SS(i(t,`parseMetricsJson`))}:{}},d=o.get(l)??[];d.push(u),o.set(l,d)}else if(r===`session`||r===`event`){let n=xS(i(t,`sessionId`));if(!n){c.push(`Row ${e+2}: missing sessionId`);continue}let r=hS.map(e=>gS(i(t,e))),a=s.get(n)??{noteId:l,lines:[hS.join(`,`)]};a.lines.push(r.join(`,`)),s.set(n,a)}else c.push(`Row ${e+2}: unknown recordKind '${r}'`)}let l=new Map,u=e=>{let t=l.get(e);if(t)return t;let n={sessions:[],events:[]};return l.set(e,n),n};for(let[e,t]of a)u(e).revisions=t;for(let[e,t]of o)u(e).parses=t;for(let[,{noteId:e,lines:t}]of s)try{let n=CS(t.join(`
|
|
153
153
|
`)+`
|
|
154
|
-
`),r=u(e);r.sessions.push(n.session),r.events.push(...n.events)}catch(e){c.push(e instanceof Error?e.message:String(e))}return{bundles:[...l.values()],errors:c}}var vie=`0.62.2260`,DS=Us,yie=`1b671a64-40d5-491e-99b0-da01ff1f3341`,bie={core:0,community:1,imported:2,user:3};function xie(e,t){if(t)return t;if(!e)return`core`;if(e===`user`)return`user`;let n=e.startsWith(`seed:`)?e.slice(5):e;return n===`core`||n===`efforts`||n===`equipment`?`core`:n===`community`||n.startsWith(`community-`)||n===`common`?`community`:`imported`}function OS(e,t){return bie[xie(e,t)]}var kS=`wodwiki.seed`,AS=`feed:index:`;function jS(e,t){return`${AS}${e}:${t}`}var MS=`efforts`,NS=`equipment`,PS=`canvas`;function FS(e){return`seed:${e}`}function Sie(e){return e.startsWith(`seed:`)?e.slice(5):e}function IS(e){return{key:e,schema:9,seedVersion:0,builtAt:``,importedAt:0,chunks:{},claim:null}}function LS(e){let t=/^notebook\.(.+)$/.exec(e)?.[1];return t&&t!==`_root`?t:void 0}function Cie(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);return t?.[1]&&!/^template:\s*canvas\s*$/m.test(t[1])?null:t?.[1]?.match(/^route:\s*(\S+)\s*$/m)?.[1]?.replace(/^\//,``)||null}function wie(e,t,n){let r=e.split(`/`),i=(r.at(-1)??``).replace(/\.md$/i,``),a=r.slice(2).map(e=>e.replace(/\.md$/i,``)).join(`/`);if(n===`canvas`)return`guides:${Cie(t)??a}`;if(n===`dashboards`)return`dashboards`;if(n===`efforts`)return`efforts`;if(n===`equipment`)return`equipment`;if(n.startsWith(`notebook.`)){let e=LS(n);return e?i.toLowerCase()===`readme`?`notebook:${e}`:`notebook:${a}`:`notebook:_root`}}var RS=[{name:`notes`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`]},{name:`by-created`,keyPath:[`createdAt`]},{name:`by-type`,keyPath:[`type`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`page`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`],unique:!0},{name:`by-slug`,keyPath:[`slug`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`page_notes`,keyPath:[`id`],indexes:[{name:`by-page`,keyPath:[`pageId`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-page-note`,keyPath:[`pageId`,`noteId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`tags`,keyPath:[`id`],indexes:[{name:`by-label`,keyPath:[`label`],unique:!0},{name:`by-type`,keyPath:[`type`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`tag_types`,keyPath:[`id`],indexes:[{name:`by-name`,keyPath:[`name`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`note_tags`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-tag`,keyPath:[`tagId`]},{name:`by-note-tag`,keyPath:[`noteId`,`tagId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_revisions`,keyPath:[`noteId`,`blockId`,`version`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-block`,keyPath:[`noteId`,`blockId`]}]},{name:`note_revisions`,keyPath:[`noteId`,`version`],indexes:[{name:`by-note`,keyPath:[`noteId`]}]},{name:`sessions`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-completed`,keyPath:[`createdAt`]},{name:`by-content`,keyPath:[`blockContentId`]},{name:`by-block`,keyPath:[`blockId`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-session-date`,keyPath:[`sessionDate`]},{name:`by-schedule-item`,keyPath:[`scheduleItemId`]},{name:`by-origin`,keyPath:[`origin`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`attachments`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-time`,keyPath:[`createdAt`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-result`,keyPath:[`resultId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`events`,keyPath:[`id`],indexes:[{name:`by-timestamp`,keyPath:[`timestamp`]},{name:`by-result-grain`,keyPath:[`resultId`,`grain`]},{name:`by-content-grain`,keyPath:[`blockContentId`,`grain`]},{name:`by-effort`,keyPath:[`effortSlug`]},{name:`by-outputType`,keyPath:[`outputType`]},{name:`by-grain`,keyPath:[`grain`]},{name:`by-metric-date`,keyPath:[`metricDateKeys`],multiEntry:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`field_catalog`,keyPath:[`id`],indexes:[{name:`by-path`,keyPath:[`path`]}]},{name:`field_sources`,keyPath:[`id`],indexes:[]},{name:`field_values`,keyPath:[`key`],indexes:[{name:`by-field`,keyPath:[`fieldId`]}]},{name:`field_catalog_meta`,keyPath:[`id`],indexes:[]},{name:`efforts`,keyPath:[`slug`],indexes:[{name:`by-discipline`,keyPath:[`baseAttributes.discipline`]},{name:`by-source`,keyPath:[`registrySource`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`equipment`,keyPath:[`slug`],indexes:[{name:`by-source`,keyPath:[`registrySource`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_index`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-content`,keyPath:[`blockContentId`]},{name:`by-type`,keyPath:[`dataType`]},{name:`by-source`,keyPath:[`sourceId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_efforts`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-effort`,keyPath:[`effortSlug`]},{name:`by-block`,keyPath:[`blockContentId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_equipment`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-equipment`,keyPath:[`equipmentSlug`]},{name:`by-block`,keyPath:[`blockContentId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`notebook_links`,keyPath:[`id`],indexes:[{name:`by-notebook`,keyPath:[`notebookId`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-target`,keyPath:[`targetKind`,`targetId`]},{name:`by-notebook-target`,keyPath:[`notebookId`,`targetKind`,`targetId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`property_overrides`,keyPath:[`id`],indexes:[{name:`by-notebook`,keyPath:[`notebookId`]},{name:`by-kind-slug`,keyPath:[`kind`,`slug`]},{name:`by-owner-note`,keyPath:[`ownerNoteId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`schedule_items`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-date-note`,keyPath:[`date`,`noteId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`meta`,keyPath:[`key`],indexes:[]},{name:`memberships`,keyPath:[`id`],indexes:[],system:!0}],zS=`default`;function BS(e=Date.now()){return{id:zS,displayName:`Anonymous`,createdAt:e}}var VS=[`notes`,`page`,`page_notes`,`tags`,`tag_types`,`note_tags`,`sessions`,`attachments`,`events`,`efforts`,`block_index`,`block_efforts`,`equipment`,`block_equipment`,`notebook_links`,`property_overrides`,`schedule_items`],Tie=Object.fromEntries(VS.map(e=>[e,!0]));function HS(e,t,n){if(!Tie[e]||typeof t!=`object`||!t||Array.isArray(t))return t;let r=t;return r.seedOrigin===`seed`||r.userId===n?t:{...r,userId:n}}function US(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&(`only`in e||`lower`in e||`upper`in e||`lowerOpen`in e||`upperOpen`in e)}function WS(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;let t=n;if(!(e in t))return;n=t[e]}if(n!==null&&typeof n!=`object`&&n!==void 0)return n}function GS(e,t){let n=e.keyPath.map(e=>WS(t,e));for(let[t,r]of n.entries())if(r===void 0)throw Error(`keyFromValue(${e.name}): keyPath part '${e.keyPath[t]}' missing on value`);let r=n;return r.length===1?r[0]:r}function Eie(e){return encodeURIComponent(JSON.stringify(e))}function KS(e){if(e===void 0)return;if(!US(e))return{only:e};if(e.only!==void 0)return e;let t={};return e.lower!==void 0&&e.lower!==null&&(t.lower=e.lower,t.lowerOpen=e.lowerOpen===!0),e.upper!==void 0&&e.upper!==null&&(t.upper=Array.isArray(e.upper)?e.upper.map(e=>Array.isArray(e)&&e.length===0?``:e):e.upper,t.upperOpen=e.upperOpen===!0),t.lower!==void 0||t.upper!==void 0?t:void 0}function qS(e,t){if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t))return Array.isArray(e)?1:-1;for(let n=0;n<Math.min(e.length,t.length);n++){let r=qS(e[n],t[n]);if(r!==0)return r}return e.length-t.length}return typeof e==`number`&&typeof t==`number`?e<t?-1:+(e>t):typeof e==`number`||typeof t==`number`?typeof e==`number`?-1:1:e<t?-1:+(e>t)}function JS(e,t){if(t.only!==void 0)return qS(e,t.only)===0;if(t.lower!==void 0){let n=qS(e,t.lower);if(n<0||n===0&&t.lowerOpen===!0)return!1}if(t.upper!==void 0){let n=qS(e,t.upper);if(n>0||n===0&&t.upperOpen===!0)return!1}return!0}function YS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function XS(e,t){return t.every(t=>e[t]===void 0||typeof e[t]==`string`)}function ZS(e,t){return t.every(t=>typeof e[t]==`number`&&Number.isFinite(e[t]))}function QS(e){if(!YS(e)||typeof e.id!=`string`||typeof e.title!=`string`||typeof e.rawContent!=`string`||!Number.isSafeInteger(e.sourceRevision)||typeof e.sourceRevision!=`number`||e.sourceRevision<1||!YS(e.blocks)||!ZS(e,[`createdAt`])||e.date!==void 0&&!ZS(e,[`date`])||!XS(e,[`type`,`sourceId`,`notebookId`,`sourcePath`,`seedOrigin`,`seedChunkId`,`feedOrigin`,`feedSourceId`])||e.tags!==void 0&&(!Array.isArray(e.tags)||!e.tags.every(e=>typeof e==`string`)))return!1;try{return Js(e.rawContent,e.blocks,e.sourceRevision),!0}catch{return!1}}function Die(e){return YS(e)&&typeof e.id==`string`&&typeof e.noteId==`string`&&typeof e.blockId==`string`&&ZS(e,[`blockVersion`,`sourceRevision`,`from`,`to`,`createdAt`])&&e.id===`${e.noteId}:${e.blockId}`&&typeof e.blockVersion==`number`&&Number.isSafeInteger(e.blockVersion)&&e.blockVersion>0&&typeof e.sourceRevision==`number`&&Number.isSafeInteger(e.sourceRevision)&&e.sourceRevision>0&&typeof e.from==`number`&&Number.isSafeInteger(e.from)&&e.from>=0&&typeof e.to==`number`&&Number.isSafeInteger(e.to)&&e.to>e.from&&[`wod`,`query`,`widget`,`embed`].includes(String(e.dataType))&&typeof e.rawContent==`string`&&typeof e.noteTitle==`string`&&XS(e,[`blockContentId`,`sourceId`,`sourcePath`,`routeId`])&&(e.position===void 0||ZS(e,[`position`]))&&(e.isStatic===void 0||typeof e.isStatic==`boolean`)}function Oie(e){return YS(e)&&typeof e.id==`string`&&typeof e.label==`string`&&ZS(e,[`createdAt`])&&XS(e,[`type`])}function kie(e){return YS(e)&&typeof e.id==`string`&&ZS(e,[`createdAt`])&&XS(e,[`date`,`slug`,`title`])}function Aie(e){return YS(e)&&typeof e.id==`string`&&typeof e.noteId==`string`&&typeof e.pageId==`string`&&ZS(e,[`createdAt`])&&(e.position===void 0||ZS(e,[`position`]))}function jie(e){return YS(e)&&QS(e.note)&&Array.isArray(e.tags)&&e.tags.every(Oie)&&Array.isArray(e.links)&&e.links.every(Aie)&&Array.isArray(e.pages)&&e.pages.every(kie)}function Mie(e,t){if(!YS(e)||e.projectionVersion!==5||e.plan!==t||!Array.isArray(e.rows)||typeof e.selectedCount!=`number`||!Number.isSafeInteger(e.selectedCount)||e.selectedCount<0||typeof e.matchedCount!=`number`||!Number.isSafeInteger(e.matchedCount)||e.matchedCount<0||e.matchedCount>e.selectedCount||e.rows.length>e.matchedCount)throw Error(`ApiStorage: invalid or stale domain projection response`);let n={projectionVersion:5,selectedCount:e.selectedCount,matchedCount:e.matchedCount};switch(t){case`notes`:if(e.rows.every(QS))return{...n,plan:t,rows:e.rows};break;case`blocks`:if(e.rows.every(Die))return{...n,plan:t,rows:e.rows};break;case`detail`:if(e.rows.every(jie))return{...n,plan:t,rows:e.rows}}throw Error(`ApiStorage: invalid domain query rows`)}var $S=(e,t)=>`${e}\u0000${JSON.stringify(t)}`;function eC(e,t,n){if(n?.has(e))return!0;if(!t)return!1;let r=`${e}\u0000`;for(let e of t.keys())if(e.startsWith(r))return!0;return!1}function Nie(e,t,n){if(!n)return;let r=n.get($S(e,t));if(r)return r.kind===`put`?{hit:!0,value:r.value}:{hit:!1}}function Pie(e,t,n,r,i,a,o,s){if(!n||!eC(t,n,r))return a===void 0?i:i.slice(0,a);let c=new Map;if(!r?.has(t))for(let t of i)c.set(JSON.stringify(GS(e,t)),t);let l=`${t}\u0000`;for(let[e,t]of n)e.startsWith(l)&&(t.kind===`put`?c.set(e.slice(l.length),t.value):c.delete(e.slice(l.length)));let u=s?e.indexes.find(e=>e.name===s):void 0;if(s&&!u)throw Error(`unknown index '${s}' for ${t}`);let d=t=>{if(!u)return GS(e,t);let n=u.keyPath.map(e=>WS(t,e));if(n.some(e=>e===void 0))return;let r=n.filter(e=>e!==void 0);return r.length===1?r[0]:r},f=e=>{if(u?.multiEntry){let t=e;for(let e of u.keyPath[0].split(`.`)){if(typeof t!=`object`||!t||!(e in t))return!1;t=Reflect.get(t,e)}return Array.isArray(t)&&t.some(e=>(typeof e==`string`||typeof e==`number`)&&(!o||JS(e,o)))}let t=d(e);return t!==void 0&&(!o||JS(t,o))},p=[...c.values()].filter(f);return p.sort((t,n)=>{let r=qS(GS(e,t),GS(e,n));if(u?.multiEntry)return r;let i=d(t),a=d(n);return i!==void 0&&a!==void 0&&qS(i,a)||r}),a===void 0?p:p.slice(0,a)}function Fie(e,t,n){let r=new Set(e),i=[];for(let e of n)r.has(e)&&i.push({op:`clear`,store:e});for(let[e,n]of t){let t=e.indexOf(`\0`),a=e.slice(0,t);r.has(a)&&(n.kind===`put`?i.push({op:`put`,store:a,value:n.value}):i.push({op:`delete`,store:a,key:JSON.parse(e.slice(t+1))}))}return i}var tC=class extends Error{status;code;constructor(e,t,n){super(t),this.status=e,this.code=n,this.name=`StorageError`}};function nC(e,t){if(Object.is(e,t))return!0;if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){let n=new Uint8Array(e),r=new Uint8Array(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>nC(e,t[n]));let n=Object.keys(e).filter(t=>Reflect.get(e,t)!==void 0),r=Object.keys(t).filter(e=>Reflect.get(t,e)!==void 0);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&nC(Reflect.get(e,n),Reflect.get(t,n)))}function rC(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new tC(400,`storage row must be an object`);return e}function iC(e,t){if(e!==`notes`&&e!==`block_revisions`&&e!==`note_revisions`&&e!==`sessions`&&e!==`block_index`&&e!==`schedule_items`)return;let n=rC(t),r=e=>typeof n[e]==`number`&&Number.isSafeInteger(n[e])&&n[e]>0,i=e=>typeof n[e]==`string`&&n[e].length>0;if(e===`notes`){if(!i(`id`)||typeof n.title!=`string`||typeof n.rawContent!=`string`||!r(`sourceRevision`)||typeof n.createdAt!=`number`||!Number.isFinite(n.createdAt)||`segments`in n||`segmentIds`in n||n.date!==void 0&&(typeof n.date!=`number`||!Number.isFinite(n.date))||n.seedOrigin!==void 0&&n.seedOrigin!==`seed`&&n.seedOrigin!==`user`||n.feedOrigin!==void 0&&n.feedOrigin!==`feed`&&n.feedOrigin!==`user`||n.feedOrigin===`feed`&&(n.seedOrigin===void 0||typeof n.feedSourceId!=`string`||n.feedSourceId.length===0)||n.feedOrigin===`user`&&n.seedOrigin===`seed`||n.feedSourceId!==void 0&&n.feedOrigin!==`feed`||n.seedVersion!==void 0&&!(typeof n.seedVersion==`number`&&Number.isSafeInteger(n.seedVersion)&&n.seedVersion>=0)||n.tags!==void 0&&(!Array.isArray(n.tags)||!n.tags.every(e=>typeof e==`string`))||n.public!==void 0&&typeof n.public!=`boolean`||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||n.provenance!==void 0&&(typeof n.provenance!=`object`||n.provenance===null||Array.isArray(n.provenance)||typeof n.provenance.sourceNoteId!=`string`)||[`type`,`sourceId`,`sourcePath`,`notebookId`,`seedChunkId`,`feedSourceId`].some(e=>n[e]!==void 0&&typeof n[e]!=`string`))throw new tC(400,`invalid whole Note`,`invalid_note_blocks`);try{Js(n.rawContent,rC(n.blocks),n.sourceRevision)}catch(e){throw new tC(400,e instanceof Error?e.message:`invalid block map`,`invalid_note_blocks`)}}else if(e===`block_revisions`){if(!i(`noteId`)||!i(`blockId`)||!r(`version`)||typeof n.rawContent!=`string`||typeof n.savedAt!=`number`||!Number.isFinite(n.savedAt)||![`wod`,`query`,`widget`,`embed`].includes(String(n.kind))||(n.kind===`wod`?n.dialect!==`time`&&n.dialect!==`log`:n.dialect!==void 0||n.sport!==void 0)||n.sport!==void 0&&typeof n.sport!=`string`)throw new tC(400,`invalid block revision`,`invalid_note_blocks`);try{Js(n.rawContent,{[String(n.blockId)]:{id:String(n.blockId),kind:n.kind,version:n.version,sourceRevision:1,from:0,to:n.rawContent.length,...n.dialect===void 0?{}:{dialect:n.dialect},...n.sport===void 0?{}:{sport:n.sport}}},1)}catch(e){throw new tC(400,e instanceof Error?e.message:`invalid revision source`,`invalid_note_blocks`)}}else if(e===`note_revisions`){if(!i(`noteId`)||!r(`version`)||typeof n.title!=`string`||typeof n.rawContent!=`string`||typeof n.savedAt!=`number`||!Number.isFinite(n.savedAt)||n.tags!==void 0&&(!Array.isArray(n.tags)||!n.tags.every(e=>typeof e==`string`))||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||n.type!==void 0&&typeof n.type!=`string`)throw new tC(400,`invalid note revision`,`invalid_note_blocks`);try{Js(n.rawContent,rC(n.blocks),n.version)}catch(e){throw new tC(400,e instanceof Error?e.message:`invalid note revision blocks`,`invalid_note_blocks`)}}else if(e===`schedule_items`){if(!i(`id`)||!i(`date`)||!i(`noteId`)||typeof n.position!=`number`||!Number.isFinite(n.position)||![`planned`,`completed`,`skipped`,`moved`].includes(String(n.status))||typeof n.createdAt!=`number`||!Number.isFinite(n.createdAt)||typeof n.updatedAt!=`number`||!Number.isFinite(n.updatedAt)||[`pageId`,`sourceNotebookId`,`fallbackTitle`,`blockId`,`slot`,`notes`,`movedFromDate`].some(e=>n[e]!==void 0&&typeof n[e]!=`string`))throw new tC(400,`invalid schedule item`,`invalid_schedule_item`)}else if(e===`sessions`){if(!i(`noteId`)||!i(`blockId`)||!r(`blockVersion`)||n.noteSourceRevision!==void 0&&!r(`noteSourceRevision`)||n.sessionDate!==void 0&&typeof n.sessionDate!=`string`||n.scheduleItemId!==void 0&&typeof n.scheduleItemId!=`string`||n.public!==void 0&&typeof n.public!=`boolean`||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||[`segmentId`,`segmentVersion`,`version`,`rawContent`,`script`,`serializedScript`,`source`,`data`,`logs`].some(e=>e in n))throw new tC(400,`Session requires immutable block pin`,`invalid_session_pin`)}else if(!i(`noteId`)||!i(`blockId`)||!r(`blockVersion`)||!r(`sourceRevision`)||n.id!==`${n.noteId}:${n.blockId}`||!Number.isSafeInteger(n.from)||!Number.isSafeInteger(n.to)||`segmentId`in n||`segmentVersion`in n||![`wod`,`query`,`widget`,`embed`].includes(String(n.dataType))||typeof n.rawContent!=`string`||typeof n.noteTitle!=`string`||typeof n.from!=`number`||typeof n.to!=`number`||n.from<0||n.to<=n.from)throw new tC(400,`invalid actionable block projection`,`invalid_note_blocks`)}function Iie(e,t){if(e===void 0||nC(e,t))return;let n=rC(e),r=rC(t);if(typeof n.sourceRevision!=`number`||typeof r.sourceRevision!=`number`||r.sourceRevision<n.sourceRevision||(!nC(n.blocks,r.blocks)||n.rawContent!==r.rawContent)&&r.sourceRevision<=n.sourceRevision)throw new tC(409,`stale Note source revision`,`transaction_conflict`)}function Lie(e,t){if(e===void 0)return;let n=rC(e),r=rC(t);if(n.noteId!==r.noteId||n.blockId!==r.blockId||n.blockVersion!==r.blockVersion)throw new tC(409,`Session pin is immutable`,`invalid_session_pin`)}async function aC(e,t,n){let r=[];for(let t of e)for(let e of Object.values(t.blocks))r.push([t.id,e.id,e.version]);for(let e of t)r.push([e.noteId,e.blockId,e.blockVersion]);let i=await n(r),a=0;for(let t of e)for(let e of Object.values(t.blocks)){let n=i[a++];if(n&&(n.kind!==e.kind||n.rawContent!==t.rawContent.slice(e.from,e.to)||n.dialect!==e.dialect||n.sport!==e.sport))throw new tC(409,`Note block has no matching immutable revision`,`invalid_note_blocks`)}for(let e=0;e<t.length;e++){let e=i[a++];if(!e||e.kind!==`wod`)throw new tC(409,`Session pin must reference a saved workout revision`,`invalid_session_pin`)}}async function oC(e,t,n,r){let i=r?.params?.toString(),a=await e.fetchImpl(`${e.baseUrl}/v1${n}${i?`?${i}`:``}`,{method:t,headers:r?.body===void 0?void 0:{"content-type":`application/json`},body:r?.body===void 0?void 0:JSON.stringify(r.body)});if(!a.ok)throw Error(`ApiStorage: ${t} /v1${n} → ${a.status}`);return a}async function Rie(e,t,n){let r=await e.fetchImpl(`${e.baseUrl}/v1/${t}/get?key=${Eie(n)}`);if(r.status!==404){if(!r.ok)throw Error(`ApiStorage: GET /v1/${t}/get → ${r.status}`);return await r.json()}}async function zie(e,t,n,r,i){let a=new URLSearchParams;return r&&a.set(`range`,JSON.stringify(r)),i!==void 0&&a.set(`count`,String(i)),await(await oC(e,`GET`,`/${t}/${n}`,{params:a})).json()}async function sC(e,t,n,r){let i=new URLSearchParams;return n&&i.set(`range`,JSON.stringify(n)),r!==void 0&&i.set(`index`,r),(await(await oC(e,`GET`,`/${t}/count`,{params:i})).json()).count}async function cC(e,t,n){await oC(e,`DELETE`,`/${t}`,{params:new URLSearchParams({key:JSON.stringify(n)})})}var Bie=class{http;defs;getUserId;writeChain=Promise.resolve();constructor(e=`/api`,t=globalThis.fetch.bind(globalThis),n={}){this.http={baseUrl:e,fetchImpl:t},this.getUserId=n.getUserId,this.defs=Object.fromEntries(RS.map(e=>[e.name,e]))}def(e){let t=this.defs[e];if(!t)throw Error(`ApiStorage: unknown store '${e}'`);return t}makeView(e,t,n,r,i=!1){return new Vie(this.http,this.def(e),e,t,n,this.getUserId,r,i)}readonly(e){return this.makeView(e)}readwrite(e){return this.makeView(e,void 0,void 0,void 0,!0)}async queryDomain(e){let t=await this.http.fetchImpl(`${this.http.baseUrl}/v1/query`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(t.status===409){let e=await t.json();if(typeof e==`object`&&e&&`code`in e&&e.code===`domain_projection_unavailable`)return}if(!t.ok)throw Error(`ApiStorage: POST /v1/query → ${t.status}`);return Mie(await t.json(),e.plan)}async transaction(e,t,n){let r=async()=>{let r=new Map,i=new Set,a=new Map,o=new Set(e),s=(e,n)=>{if(!o.has(e))throw Error(`store outside transaction scope`);if(n&&t!==`readwrite`)throw Error(`read-only transaction`);return this.makeView(e,r,i,a,n)},c=await n({readonly:e=>s(e,!1),readwrite:e=>s(e,!0)});return await this.flush(r,i,a),c};if(t!==`readwrite`)return r();let i=this.writeChain.then(r,r);return this.writeChain=i.then(()=>void 0,()=>void 0),i}async flush(e,t,n){let r=Fie(RS.map(e=>e.name),e,t);r.length>0&&await oC(this.http,`POST`,`/tx`,{body:{ops:[...n.values(),...r]}})}async wipe(){await oC(this.http,`POST`,`/wipe`)}async close(){}},Vie=class{http;def;store;buffer;cleared;getUserId;checks;mutable;constructor(e,t,n,r,i,a,o,s=!1){this.http=e,this.def=t,this.store=n,this.buffer=r,this.cleared=i,this.getUserId=a,this.checks=o,this.mutable=s}dirty(){return eC(this.store,this.buffer,this.cleared)}async get(e){let t=US(e)?e:void 0,n;if(t){if(t.only===void 0)throw Error(`ApiStorage.get: needs a plain key or {only}; bounded ranges match no single row`);n=t.only}else n=e;let r=Nie(this.store,n,this.buffer);if(r)return r.hit?r.value:void 0;if(this.cleared?.has(this.store))return;let i=await Rie(this.http,this.store,n),a=$S(this.store,n);return this.checks?.has(a)||this.checks?.set(a,{op:`check`,store:this.store,key:n,value:structuredClone(i??null)}),i}async getMany(e){return Promise.all(e.map(e=>this.get(e)))}async getAllFromIndexMany(e,t){return Promise.all(t.map(t=>this.getAllFromIndex(e,t)))}async getAll(e,t){let n=KS(e);return this.overlay(await this.serverRows(`all`,n,this.dirty()?void 0:t),t,n)}async getAllFromIndex(e,t,n){let r=KS(t);return this.overlay(await this.serverRows(`index/${encodeURIComponent(e)}`,r,this.dirty()?void 0:n),n,r,e)}async count(e){let t=KS(e);return this.dirty()?this.overlay(await this.serverRows(`all`,t),void 0,t).length:sC(this.http,this.store,t)}async countFromIndex(e,t){let n=KS(t);return this.dirty()?this.overlay(await this.serverRows(`index/${encodeURIComponent(e)}`,n),void 0,n,e).length:sC(this.http,this.store,n,e)}async serverRows(e,t,n){if(this.cleared?.has(this.store))return[];let r=await zie(this.http,this.store,e,t,n);for(let e of r){let t=GS(this.def,e),n=$S(this.store,t);this.checks?.has(n)||this.checks?.set(n,{op:`check`,store:this.store,key:t,value:structuredClone(e)})}return r}overlay(e,t,n,r){return Pie(this.def,this.store,this.buffer,this.cleared,e,t,n,r)}async put(e,t){if(!this.mutable)throw Error(`read-only store`);let n=this.getUserId?.(),r=n?HS(this.store,e,n):e,i=GS(this.def,r);if(this.store===`block_revisions`||this.store===`note_revisions`){let e=this.buffer?.get($S(this.store,i));if(e?.kind===`put`&&!nC(e.value,r))throw Error(this.store===`note_revisions`?`immutable note revision collision`:`immutable block revision collision`)}return this.buffer?(this.buffer.set($S(this.store,i),{kind:`put`,value:r}),i):(await oC(this.http,`POST`,`/tx`,{body:{ops:[{op:`put`,store:this.store,value:r}]}}),i)}async putMany(e,t){if(!this.mutable)throw Error(`read-only store`);if(this.buffer){let t=[];for(let n of e)t.push(await this.put(n));return t}let n=e.map(e=>this.getUserId?HS(this.store,e,this.getUserId()):e),r=n.map(e=>GS(this.def,e));return await oC(this.http,`POST`,`/tx`,{body:{ops:n.map(e=>({op:`put`,store:this.store,value:e}))}}),r}async delete(e){if(!this.mutable)throw Error(`read-only store`);if(this.store===`block_revisions`||this.store===`note_revisions`)throw Error(`block history requires explicit wipe`);let t=US(e)?e:void 0;if(t){if(this.buffer){let e=await this.getAll(t);for(let t of e){let e=GS(this.def,t);this.buffer.set($S(this.store,e),{kind:`delete`,key:e})}return}await cC(this.http,this.store,t);return}let n=e;if(this.buffer){this.buffer.set($S(this.store,n),{kind:`delete`,key:n});return}await cC(this.http,this.store,n)}async clear(){if(!this.mutable)throw Error(`read-only store`);if(this.store===`block_revisions`||this.store===`note_revisions`)throw Error(`block history requires explicit wipe`);if(this.buffer){this.cleared?.add(this.store);let e=`${this.store}\u0000`;for(let t of[...this.buffer.keys()])t.startsWith(e)&&this.buffer.delete(t);return}await oC(this.http,`POST`,`/tx`,{body:{ops:[{op:`clear`,store:this.store}]}})}},Hie=`user-deleted-seed:`;function lC(e){return`${Hie}${e}`}function Uie(e){if(!(typeof e!=`string`||!e.startsWith(`user-deleted-seed:`)))return e.slice(18)||void 0}function Wie(e){return typeof e==`string`&&e.startsWith(`seed:`)}function uC(e){let t=new Set;for(let n of e)typeof n==`object`&&n&&`seedOrigin`in n&&n.seedOrigin===`seed`&&`id`in n&&typeof n.id==`string`&&t.add(n.id);return{seedNoteIds:t}}function dC(e,t,n){if(typeof t!=`object`||!t)return!0;switch(e){case`notes`:return!(`seedOrigin`in t&&t.seedOrigin===`seed`);case`block_index`:case`block_efforts`:case`block_equipment`:return!(`isStatic`in t&&t.isStatic===!0&&`noteId`in t&&typeof t.noteId==`string`&&n.seedNoteIds.has(t.noteId));case`efforts`:case`equipment`:return!(`registrySource`in t&&t.registrySource===`bundled`);case`property_overrides`:return!(`seedOrigin`in t&&t.seedOrigin===`seed`);case`meta`:return!Wie(`key`in t?t.key:void 0);default:return!0}}function fC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pC(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function mC(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function hC(e){return typeof e==`number`&&Number.isFinite(e)}function gC(e){return typeof e==`string`&&e.length>0&&!e.startsWith(`/`)&&!e.split(`/`).includes(`..`)}function _C(e){if(typeof e!=`string`||!e.trim())return!1;if(/^https?:\/\//i.test(e))try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password}catch{return!1}return gC(e)}function vC(e){if(!fC(e))throw Error(`Incompatible seed schema; rebuild seed artifacts`);let t=Array.isArray(e.notebooks);if(e.schema===void 0){if(!t)throw Error(`Incompatible seed schema; rebuild seed artifacts`)}else if(!pC(e.schema)||e.schema!==9&&!t)throw Error(`Incompatible seed schema; rebuild seed artifacts`);let n=e.schema===void 0?9:e.schema,r=e.version===void 0&&t?1:e.version,i=e.builtAt===void 0&&t?new Date(0).toISOString():e.builtAt,a=e.chunks===void 0&&t?[]:e.chunks;if(!mC(r)||typeof i!=`string`||!Number.isFinite(Date.parse(i))||!Array.isArray(a))throw Error(`seed manifest failed shape validation`);for(let t of[`versionLabel`,`commit`,`name`,`description`])if(e[t]!==void 0&&typeof e[t]!=`string`)throw Error(`invalid seed manifest metadata`);if(e.repositoryUrl!==void 0&&(typeof e.repositoryUrl!=`string`||!/^https:\/\//.test(e.repositoryUrl)||new URL(e.repositoryUrl).username||new URL(e.repositoryUrl).password))throw Error(`invalid seed repository URL`);if(e.dirty!==void 0&&typeof e.dirty!=`boolean`)throw Error(`invalid seed manifest metadata`);for(let t of[`indexBytes`,`chunkBytes`])if(e[t]!==void 0&&!mC(e[t]))throw Error(`invalid seed manifest metadata`);let o=new Set,s=new Set;for(let e of a){if(!fC(e)||typeof e.id!=`string`||!e.id||typeof e.path!=`string`||!/^chunks\/[a-zA-Z0-9._-]+\.json$/.test(e.path)||typeof e.sha256!=`string`||!/^[0-9a-f]{64}$/.test(e.sha256)||!mC(e.bytes)||!mC(e.count)||e.kind!==void 0&&e.kind!==`notes`||o.has(e.id)||s.has(e.path))throw Error(`seed manifest failed shape validation`);o.add(e.id),s.add(e.path)}let c;if(e.notebooks!==void 0){if(!Array.isArray(e.notebooks))throw Error(`seed manifest failed shape validation`);c=[];for(let t of e.notebooks){if(!fC(t)||typeof t.notebookId!=`string`||!t.notebookId||typeof t.label!=`string`||!mC(t.count)||!_C(t.indexPath))throw Error(`seed manifest failed shape validation`);if(`records`in t&&Array.isArray(t.records))throw Error(`seed manifest failed shape validation: manifest.notebooks must not contain inline records`);if(t.version!==void 0&&!mC(t.version)||t.commit!==void 0&&typeof t.commit!=`string`||t.builtAt!==void 0&&typeof t.builtAt!=`string`||t.sha256!==void 0&&typeof t.sha256!=`string`||t.bytes!==void 0&&!mC(t.bytes)||t.indexBytes!==void 0&&!mC(t.indexBytes)||t.chunkBytes!==void 0&&!mC(t.chunkBytes))throw Error(`seed manifest failed shape validation`);c.push({...t,version:t.version??r,commit:t.commit??``,builtAt:t.builtAt??i,sha256:t.sha256??``,bytes:t.bytes??t.indexBytes??0})}}return{...e,schema:n,version:r,builtAt:i,chunks:a,...c===void 0?{}:{notebooks:c}}}function yC(e){if(!fC(e))throw Error(`notebook index failed shape validation`);if(typeof e.notebookId!=`string`||!e.notebookId||typeof e.label!=`string`||!e.label||!_C(e.indexPath)||!mC(e.count)||!Array.isArray(e.records)||e.version!==void 0&&!mC(e.version)||e.commit!==void 0&&typeof e.commit!=`string`||e.builtAt!==void 0&&typeof e.builtAt!=`string`||e.sha256!==void 0&&typeof e.sha256!=`string`||e.bytes!==void 0&&!mC(e.bytes))throw Error(`notebook index failed shape validation: missing required index summary or records`);let t=[];for(let n of e.records){if(!fC(n)||typeof n.uuid!=`string`||!n.uuid||!gC(n.path))throw Error(`notebook index failed shape validation: invalid record ref`);let e=n.recordPath!==void 0,r=n.rawUrl!==void 0,i=/\.md$/i.test(n.path);if(e&&!gC(n.recordPath)||r&&!_C(n.rawUrl)||!e&&!r&&!i||n.commit!==void 0&&typeof n.commit!=`string`||n.version!==void 0&&!mC(n.version)||n.sha256!==void 0&&typeof n.sha256!=`string`||n.title!==void 0&&typeof n.title!=`string`||n.date!==void 0&&!hC(n.date))throw Error(`notebook index failed shape validation: invalid record ref`);t.push({...n,commit:n.commit??``,version:n.version??1,sha256:n.sha256??``})}return{...e,version:e.version??1,commit:e.commit??``,builtAt:e.builtAt??new Date(0).toISOString(),sha256:e.sha256??``,bytes:e.bytes??0,records:t}}function Gie(e,t){if(e.telemetry===void 0)return;if(!fC(e.telemetry)||!Array.isArray(e.telemetry.sessions)||!Array.isArray(e.telemetry.events))throw Error(`invalid seed telemetry`);let n=new Map;for(let r of e.telemetry.sessions){if(!fC(r)||typeof r.id!=`string`||!r.id||n.has(r.id)||typeof r.noteId!=`string`||!r.noteId||typeof e.uuid==`string`&&r.noteId!==e.uuid||typeof r.blockId!=`string`||!pC(r.blockVersion)||typeof r.blockContentId!=`string`||!hC(r.startTime)||!hC(r.endTime)||!hC(r.duration)||typeof r.completed!=`boolean`||!hC(r.createdAt))throw Error(`invalid seed session`);let i=t.find(e=>fC(e)&&e.blockId===r.blockId);if(!fC(i)||i.dataType!==`wod`||i.blockVersion!==r.blockVersion||i.blockContentId!==r.blockContentId)throw Error(`orphan or incompatible seed session pin`);n.set(r.id,r)}let r=new Set;for(let t of e.telemetry.events){if(!fC(t)||typeof t.id!=`string`||!t.id||r.has(t.id)||typeof t.resultId!=`string`||typeof t.noteId!=`string`||!hC(t.timestamp)||t.grain!==`event`&&t.grain!==`summary`||typeof t.outputType!=`string`||!Array.isArray(t.metrics)||!t.metrics.every(e=>fC(e)&&typeof e.type==`string`)||t.grain===`summary`&&t.metrics.length!==1)throw Error(`invalid seed event`);let e=n.get(t.resultId);if(!e||t.noteId!==e.noteId||t.blockId!==e.blockId||t.blockVersion!==e.blockVersion||t.blockContentId!==e.blockContentId)throw Error(`orphan or incompatible seed event identity`);r.add(t.id)}}function bC(e){if(!Array.isArray(e))throw Error(`seed chunk is not an array`);let t=new Set;for(let n of e){if(!fC(n)||typeof n.path!=`string`||!n.path||n.path.startsWith(`/`)||n.path.split(`/`).includes(`..`)||t.has(n.path)||typeof n.content!=`string`||!fC(n.blocks)||!Array.isArray(n.blockIndex)||!Array.isArray(n.blockEfforts)||!Array.isArray(n.blockEquipment))throw Error(`seed chunk row failed shape validation`);t.add(n.path);for(let[e,t]of Object.entries(n.blocks))if(!fC(t)||t.id!==e||!e||t.version!==1||t.sourceRevision!==1||!mC(t.from)||!pC(t.to)||t.from>=t.to||t.to>n.content.length||![`wod`,`query`,`widget`,`embed`].includes(String(t.kind))||(t.kind===`wod`?![`time`,`log`].includes(String(t.dialect)):t.dialect!==void 0)||t.sport!==void 0&&typeof t.sport!=`string`)throw Error(`invalid seed block range or revision`);Js(n.content,n.blocks,1,{registeredWidgets:DS});let e=new Set,r=Gs(n.content,{registeredWidgets:DS});for(let t of n.blockIndex){if(!fC(t)||typeof t.blockId!=`string`)throw Error(`invalid seed projection`);let i=n.blocks[t.blockId];if(!fC(i)||e.has(t.blockId)||typeof t.id!=`string`||typeof t.noteId!=`string`||t.id!==`${t.noteId}:${t.blockId}`||t.blockVersion!==1||t.sourceRevision!==1||t.from!==i.from||t.to!==i.to||t.dataType!==i.kind||t.rawContent!==n.content.slice(Number(i.from),Number(i.to))||typeof t.noteTitle!=`string`||typeof t.createdAt!=`number`||!Number.isFinite(t.createdAt)||t.sourcePath!==n.path||t.isStatic!==!0)throw Error(`orphan or incompatible seed projection`);if(`segmentId`in t||`segmentVersion`in t)throw Error(`incompatible seed projection`);for(let e of[`sourceId`,`routeId`,`blockContentId`])if(t[e]!==void 0&&typeof t[e]!=`string`)throw Error(`invalid seed projection metadata`);if(t.position!==void 0&&!mC(t.position))throw Error(`invalid seed projection position`);if(i.kind===`wod`){let e=r.find(e=>e.from===i.from&&e.to===i.to);if(t.blockContentId!==ys(e?.scriptBlock?.content??n.content.slice(Number(i.from),Number(i.to))))throw Error(`invalid seed workout fingerprint`)}else if(t.blockContentId!==void 0)throw Error(`non-workout seed fingerprint`);e.add(t.blockId)}if(e.size!==Object.keys(n.blocks).length)throw Error(`missing actionable seed projection`);let i=new Set;for(let t of n.blockEfforts){if(!fC(t)||typeof t.blockId!=`string`||typeof t.noteId!=`string`||typeof t.effortSlug!=`string`||!t.effortSlug)throw Error(`invalid seed effort identity`);let r=n.blocks[t.blockId];if(t.id!==`${t.noteId}:${t.blockId}:${t.effortSlug}`||i.has(String(t.id))||!fC(r)||r.kind!==`wod`||!e.has(t.blockId)||t.sourcePath!==n.path||t.isStatic!==!0||typeof t.createdAt!=`number`)throw Error(`orphan or incompatible seed effort link`);let a=n.blockIndex.find(e=>fC(e)&&e.blockId===t.blockId);if(!fC(a)||t.noteId!==a.noteId||t.blockContentId!==a.blockContentId||!Number.isFinite(t.createdAt))throw Error(`invalid seed effort metadata`);i.add(String(t.id))}let a=new Set;for(let t of n.blockEquipment){if(!fC(t)||typeof t.blockId!=`string`||typeof t.noteId!=`string`||typeof t.equipmentSlug!=`string`||!t.equipmentSlug)throw Error(`invalid seed equipment identity`);let r=n.blocks[t.blockId];if(t.id!==`${t.noteId}:${t.blockId}:${t.equipmentSlug}`||a.has(String(t.id))||!fC(r)||r.kind!==`wod`||!e.has(t.blockId)||t.sourcePath!==n.path||t.isStatic!==!0||typeof t.createdAt!=`number`)throw Error(`orphan or incompatible seed equipment link`);let i=n.blockIndex.find(e=>fC(e)&&e.blockId===t.blockId);if(!fC(i)||t.noteId!==i.noteId||t.blockContentId!==i.blockContentId||!Number.isFinite(t.createdAt))throw Error(`invalid seed equipment metadata`);a.add(String(t.id))}Gie(n,n.blockIndex)}return e}function xC(e){return bC([e])[0]}function SC(e,t,n){return`${e}:${t}:${n}`}function CC(e){let t=[];for(let[n,r]of Object.entries(e.metrics)){if(typeof r!=`string`&&typeof r!=`number`)continue;let e=String(r).trim().match(/^([+-]?\d+(?:\.\d+)?)\s*([A-Za-z%/][\w%/.-]*)$/);e?t.push({kind:`metric`,type:n,value:Number(e[1]),unit:e[2]}):t.push({kind:`metric`,type:n,value:r})}for(let[n,r]of Object.entries(e.summaries))t.push({kind:`metric`,type:`summaries.${n}`,value:r});for(let[n,r]of Object.entries(e.widgets??{}))t.push({kind:`metric`,type:`widgets.${n}`,value:r});for(let n of e.tags)t.push({kind:`tag`,slug:n});for(let n of e.functions)t.push({kind:`function`,name:n});return t}async function wC(e,t){let n=Ps(t.targetNotebookId);if(js(n))throw Error(`Notebook '${n}' is read-only and cannot store overrides.`);if(n===`notebook/journal`||n===`notebook/playground`)throw Error(`Property overrides belong in 'notebook/custom' or a shared user Notebook, not '${n}'.`);let r=t.slug.trim().toLowerCase();if(!r)throw Error(`Property override requires a non-empty canonical slug.`);let i=Ns(n),a=`override/${i}/${t.kind}/${r}`,o=`${t.kind}-override-${i}-${r}`,s=Date.now(),c=t.rawContent,l=cS(c);(typeof l.id!=`string`||!l.id.trim())&&(c=rc(c,[`id`],o)),(typeof l.slug!=`string`||l.slug.trim()!==r)&&(c=rc(c,[`slug`],r));let u=t.title?.trim()||r,d;if(t.kind===`effort`){let e=Wd(c);if(e.errors.length>0)throw Error(e.errors.join(`
|
|
154
|
+
`),r=u(e);r.sessions.push(n.session),r.events.push(...n.events)}catch(e){c.push(e instanceof Error?e.message:String(e))}return{bundles:[...l.values()],errors:c}}var vie=`0.62.2261`,DS=Us,yie=`1b671a64-40d5-491e-99b0-da01ff1f3341`,bie={core:0,community:1,imported:2,user:3};function xie(e,t){if(t)return t;if(!e)return`core`;if(e===`user`)return`user`;let n=e.startsWith(`seed:`)?e.slice(5):e;return n===`core`||n===`efforts`||n===`equipment`?`core`:n===`community`||n.startsWith(`community-`)||n===`common`?`community`:`imported`}function OS(e,t){return bie[xie(e,t)]}var kS=`wodwiki.seed`,AS=`feed:index:`;function jS(e,t){return`${AS}${e}:${t}`}var MS=`efforts`,NS=`equipment`,PS=`canvas`;function FS(e){return`seed:${e}`}function Sie(e){return e.startsWith(`seed:`)?e.slice(5):e}function IS(e){return{key:e,schema:9,seedVersion:0,builtAt:``,importedAt:0,chunks:{},claim:null}}function LS(e){let t=/^notebook\.(.+)$/.exec(e)?.[1];return t&&t!==`_root`?t:void 0}function Cie(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);return t?.[1]&&!/^template:\s*canvas\s*$/m.test(t[1])?null:t?.[1]?.match(/^route:\s*(\S+)\s*$/m)?.[1]?.replace(/^\//,``)||null}function wie(e,t,n){let r=e.split(`/`),i=(r.at(-1)??``).replace(/\.md$/i,``),a=r.slice(2).map(e=>e.replace(/\.md$/i,``)).join(`/`);if(n===`canvas`)return`guides:${Cie(t)??a}`;if(n===`dashboards`)return`dashboards`;if(n===`efforts`)return`efforts`;if(n===`equipment`)return`equipment`;if(n.startsWith(`notebook.`)){let e=LS(n);return e?i.toLowerCase()===`readme`?`notebook:${e}`:`notebook:${a}`:`notebook:_root`}}var RS=[{name:`notes`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`]},{name:`by-created`,keyPath:[`createdAt`]},{name:`by-type`,keyPath:[`type`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`page`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`],unique:!0},{name:`by-slug`,keyPath:[`slug`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`page_notes`,keyPath:[`id`],indexes:[{name:`by-page`,keyPath:[`pageId`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-page-note`,keyPath:[`pageId`,`noteId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`tags`,keyPath:[`id`],indexes:[{name:`by-label`,keyPath:[`label`],unique:!0},{name:`by-type`,keyPath:[`type`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`tag_types`,keyPath:[`id`],indexes:[{name:`by-name`,keyPath:[`name`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`note_tags`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-tag`,keyPath:[`tagId`]},{name:`by-note-tag`,keyPath:[`noteId`,`tagId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_revisions`,keyPath:[`noteId`,`blockId`,`version`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-block`,keyPath:[`noteId`,`blockId`]}]},{name:`note_revisions`,keyPath:[`noteId`,`version`],indexes:[{name:`by-note`,keyPath:[`noteId`]}]},{name:`sessions`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-completed`,keyPath:[`createdAt`]},{name:`by-content`,keyPath:[`blockContentId`]},{name:`by-block`,keyPath:[`blockId`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-session-date`,keyPath:[`sessionDate`]},{name:`by-schedule-item`,keyPath:[`scheduleItemId`]},{name:`by-origin`,keyPath:[`origin`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`attachments`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-time`,keyPath:[`createdAt`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-result`,keyPath:[`resultId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`events`,keyPath:[`id`],indexes:[{name:`by-timestamp`,keyPath:[`timestamp`]},{name:`by-result-grain`,keyPath:[`resultId`,`grain`]},{name:`by-content-grain`,keyPath:[`blockContentId`,`grain`]},{name:`by-effort`,keyPath:[`effortSlug`]},{name:`by-outputType`,keyPath:[`outputType`]},{name:`by-grain`,keyPath:[`grain`]},{name:`by-metric-date`,keyPath:[`metricDateKeys`],multiEntry:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`field_catalog`,keyPath:[`id`],indexes:[{name:`by-path`,keyPath:[`path`]}]},{name:`field_sources`,keyPath:[`id`],indexes:[]},{name:`field_values`,keyPath:[`key`],indexes:[{name:`by-field`,keyPath:[`fieldId`]}]},{name:`field_catalog_meta`,keyPath:[`id`],indexes:[]},{name:`efforts`,keyPath:[`slug`],indexes:[{name:`by-discipline`,keyPath:[`baseAttributes.discipline`]},{name:`by-source`,keyPath:[`registrySource`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`equipment`,keyPath:[`slug`],indexes:[{name:`by-source`,keyPath:[`registrySource`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_index`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-content`,keyPath:[`blockContentId`]},{name:`by-type`,keyPath:[`dataType`]},{name:`by-source`,keyPath:[`sourceId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_efforts`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-effort`,keyPath:[`effortSlug`]},{name:`by-block`,keyPath:[`blockContentId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_equipment`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-equipment`,keyPath:[`equipmentSlug`]},{name:`by-block`,keyPath:[`blockContentId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`notebook_links`,keyPath:[`id`],indexes:[{name:`by-notebook`,keyPath:[`notebookId`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-target`,keyPath:[`targetKind`,`targetId`]},{name:`by-notebook-target`,keyPath:[`notebookId`,`targetKind`,`targetId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`property_overrides`,keyPath:[`id`],indexes:[{name:`by-notebook`,keyPath:[`notebookId`]},{name:`by-kind-slug`,keyPath:[`kind`,`slug`]},{name:`by-owner-note`,keyPath:[`ownerNoteId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`schedule_items`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-date-note`,keyPath:[`date`,`noteId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`meta`,keyPath:[`key`],indexes:[]},{name:`memberships`,keyPath:[`id`],indexes:[],system:!0}],zS=`default`;function BS(e=Date.now()){return{id:zS,displayName:`Anonymous`,createdAt:e}}var VS=[`notes`,`page`,`page_notes`,`tags`,`tag_types`,`note_tags`,`sessions`,`attachments`,`events`,`efforts`,`block_index`,`block_efforts`,`equipment`,`block_equipment`,`notebook_links`,`property_overrides`,`schedule_items`],Tie=Object.fromEntries(VS.map(e=>[e,!0]));function HS(e,t,n){if(!Tie[e]||typeof t!=`object`||!t||Array.isArray(t))return t;let r=t;return r.seedOrigin===`seed`||r.userId===n?t:{...r,userId:n}}function US(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&(`only`in e||`lower`in e||`upper`in e||`lowerOpen`in e||`upperOpen`in e)}function WS(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;let t=n;if(!(e in t))return;n=t[e]}if(n!==null&&typeof n!=`object`&&n!==void 0)return n}function GS(e,t){let n=e.keyPath.map(e=>WS(t,e));for(let[t,r]of n.entries())if(r===void 0)throw Error(`keyFromValue(${e.name}): keyPath part '${e.keyPath[t]}' missing on value`);let r=n;return r.length===1?r[0]:r}function Eie(e){return encodeURIComponent(JSON.stringify(e))}function KS(e){if(e===void 0)return;if(!US(e))return{only:e};if(e.only!==void 0)return e;let t={};return e.lower!==void 0&&e.lower!==null&&(t.lower=e.lower,t.lowerOpen=e.lowerOpen===!0),e.upper!==void 0&&e.upper!==null&&(t.upper=Array.isArray(e.upper)?e.upper.map(e=>Array.isArray(e)&&e.length===0?``:e):e.upper,t.upperOpen=e.upperOpen===!0),t.lower!==void 0||t.upper!==void 0?t:void 0}function qS(e,t){if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t))return Array.isArray(e)?1:-1;for(let n=0;n<Math.min(e.length,t.length);n++){let r=qS(e[n],t[n]);if(r!==0)return r}return e.length-t.length}return typeof e==`number`&&typeof t==`number`?e<t?-1:+(e>t):typeof e==`number`||typeof t==`number`?typeof e==`number`?-1:1:e<t?-1:+(e>t)}function JS(e,t){if(t.only!==void 0)return qS(e,t.only)===0;if(t.lower!==void 0){let n=qS(e,t.lower);if(n<0||n===0&&t.lowerOpen===!0)return!1}if(t.upper!==void 0){let n=qS(e,t.upper);if(n>0||n===0&&t.upperOpen===!0)return!1}return!0}function YS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function XS(e,t){return t.every(t=>e[t]===void 0||typeof e[t]==`string`)}function ZS(e,t){return t.every(t=>typeof e[t]==`number`&&Number.isFinite(e[t]))}function QS(e){if(!YS(e)||typeof e.id!=`string`||typeof e.title!=`string`||typeof e.rawContent!=`string`||!Number.isSafeInteger(e.sourceRevision)||typeof e.sourceRevision!=`number`||e.sourceRevision<1||!YS(e.blocks)||!ZS(e,[`createdAt`])||e.date!==void 0&&!ZS(e,[`date`])||!XS(e,[`type`,`sourceId`,`notebookId`,`sourcePath`,`seedOrigin`,`seedChunkId`,`feedOrigin`,`feedSourceId`])||e.tags!==void 0&&(!Array.isArray(e.tags)||!e.tags.every(e=>typeof e==`string`)))return!1;try{return Js(e.rawContent,e.blocks,e.sourceRevision),!0}catch{return!1}}function Die(e){return YS(e)&&typeof e.id==`string`&&typeof e.noteId==`string`&&typeof e.blockId==`string`&&ZS(e,[`blockVersion`,`sourceRevision`,`from`,`to`,`createdAt`])&&e.id===`${e.noteId}:${e.blockId}`&&typeof e.blockVersion==`number`&&Number.isSafeInteger(e.blockVersion)&&e.blockVersion>0&&typeof e.sourceRevision==`number`&&Number.isSafeInteger(e.sourceRevision)&&e.sourceRevision>0&&typeof e.from==`number`&&Number.isSafeInteger(e.from)&&e.from>=0&&typeof e.to==`number`&&Number.isSafeInteger(e.to)&&e.to>e.from&&[`wod`,`query`,`widget`,`embed`].includes(String(e.dataType))&&typeof e.rawContent==`string`&&typeof e.noteTitle==`string`&&XS(e,[`blockContentId`,`sourceId`,`sourcePath`,`routeId`])&&(e.position===void 0||ZS(e,[`position`]))&&(e.isStatic===void 0||typeof e.isStatic==`boolean`)}function Oie(e){return YS(e)&&typeof e.id==`string`&&typeof e.label==`string`&&ZS(e,[`createdAt`])&&XS(e,[`type`])}function kie(e){return YS(e)&&typeof e.id==`string`&&ZS(e,[`createdAt`])&&XS(e,[`date`,`slug`,`title`])}function Aie(e){return YS(e)&&typeof e.id==`string`&&typeof e.noteId==`string`&&typeof e.pageId==`string`&&ZS(e,[`createdAt`])&&(e.position===void 0||ZS(e,[`position`]))}function jie(e){return YS(e)&&QS(e.note)&&Array.isArray(e.tags)&&e.tags.every(Oie)&&Array.isArray(e.links)&&e.links.every(Aie)&&Array.isArray(e.pages)&&e.pages.every(kie)}function Mie(e,t){if(!YS(e)||e.projectionVersion!==5||e.plan!==t||!Array.isArray(e.rows)||typeof e.selectedCount!=`number`||!Number.isSafeInteger(e.selectedCount)||e.selectedCount<0||typeof e.matchedCount!=`number`||!Number.isSafeInteger(e.matchedCount)||e.matchedCount<0||e.matchedCount>e.selectedCount||e.rows.length>e.matchedCount)throw Error(`ApiStorage: invalid or stale domain projection response`);let n={projectionVersion:5,selectedCount:e.selectedCount,matchedCount:e.matchedCount};switch(t){case`notes`:if(e.rows.every(QS))return{...n,plan:t,rows:e.rows};break;case`blocks`:if(e.rows.every(Die))return{...n,plan:t,rows:e.rows};break;case`detail`:if(e.rows.every(jie))return{...n,plan:t,rows:e.rows}}throw Error(`ApiStorage: invalid domain query rows`)}var $S=(e,t)=>`${e}\u0000${JSON.stringify(t)}`;function eC(e,t,n){if(n?.has(e))return!0;if(!t)return!1;let r=`${e}\u0000`;for(let e of t.keys())if(e.startsWith(r))return!0;return!1}function Nie(e,t,n){if(!n)return;let r=n.get($S(e,t));if(r)return r.kind===`put`?{hit:!0,value:r.value}:{hit:!1}}function Pie(e,t,n,r,i,a,o,s){if(!n||!eC(t,n,r))return a===void 0?i:i.slice(0,a);let c=new Map;if(!r?.has(t))for(let t of i)c.set(JSON.stringify(GS(e,t)),t);let l=`${t}\u0000`;for(let[e,t]of n)e.startsWith(l)&&(t.kind===`put`?c.set(e.slice(l.length),t.value):c.delete(e.slice(l.length)));let u=s?e.indexes.find(e=>e.name===s):void 0;if(s&&!u)throw Error(`unknown index '${s}' for ${t}`);let d=t=>{if(!u)return GS(e,t);let n=u.keyPath.map(e=>WS(t,e));if(n.some(e=>e===void 0))return;let r=n.filter(e=>e!==void 0);return r.length===1?r[0]:r},f=e=>{if(u?.multiEntry){let t=e;for(let e of u.keyPath[0].split(`.`)){if(typeof t!=`object`||!t||!(e in t))return!1;t=Reflect.get(t,e)}return Array.isArray(t)&&t.some(e=>(typeof e==`string`||typeof e==`number`)&&(!o||JS(e,o)))}let t=d(e);return t!==void 0&&(!o||JS(t,o))},p=[...c.values()].filter(f);return p.sort((t,n)=>{let r=qS(GS(e,t),GS(e,n));if(u?.multiEntry)return r;let i=d(t),a=d(n);return i!==void 0&&a!==void 0&&qS(i,a)||r}),a===void 0?p:p.slice(0,a)}function Fie(e,t,n){let r=new Set(e),i=[];for(let e of n)r.has(e)&&i.push({op:`clear`,store:e});for(let[e,n]of t){let t=e.indexOf(`\0`),a=e.slice(0,t);r.has(a)&&(n.kind===`put`?i.push({op:`put`,store:a,value:n.value}):i.push({op:`delete`,store:a,key:JSON.parse(e.slice(t+1))}))}return i}var tC=class extends Error{status;code;constructor(e,t,n){super(t),this.status=e,this.code=n,this.name=`StorageError`}};function nC(e,t){if(Object.is(e,t))return!0;if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){let n=new Uint8Array(e),r=new Uint8Array(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>nC(e,t[n]));let n=Object.keys(e).filter(t=>Reflect.get(e,t)!==void 0),r=Object.keys(t).filter(e=>Reflect.get(t,e)!==void 0);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&nC(Reflect.get(e,n),Reflect.get(t,n)))}function rC(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new tC(400,`storage row must be an object`);return e}function iC(e,t){if(e!==`notes`&&e!==`block_revisions`&&e!==`note_revisions`&&e!==`sessions`&&e!==`block_index`&&e!==`schedule_items`)return;let n=rC(t),r=e=>typeof n[e]==`number`&&Number.isSafeInteger(n[e])&&n[e]>0,i=e=>typeof n[e]==`string`&&n[e].length>0;if(e===`notes`){if(!i(`id`)||typeof n.title!=`string`||typeof n.rawContent!=`string`||!r(`sourceRevision`)||typeof n.createdAt!=`number`||!Number.isFinite(n.createdAt)||`segments`in n||`segmentIds`in n||n.date!==void 0&&(typeof n.date!=`number`||!Number.isFinite(n.date))||n.seedOrigin!==void 0&&n.seedOrigin!==`seed`&&n.seedOrigin!==`user`||n.feedOrigin!==void 0&&n.feedOrigin!==`feed`&&n.feedOrigin!==`user`||n.feedOrigin===`feed`&&(n.seedOrigin===void 0||typeof n.feedSourceId!=`string`||n.feedSourceId.length===0)||n.feedOrigin===`user`&&n.seedOrigin===`seed`||n.feedSourceId!==void 0&&n.feedOrigin!==`feed`||n.seedVersion!==void 0&&!(typeof n.seedVersion==`number`&&Number.isSafeInteger(n.seedVersion)&&n.seedVersion>=0)||n.tags!==void 0&&(!Array.isArray(n.tags)||!n.tags.every(e=>typeof e==`string`))||n.public!==void 0&&typeof n.public!=`boolean`||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||n.provenance!==void 0&&(typeof n.provenance!=`object`||n.provenance===null||Array.isArray(n.provenance)||typeof n.provenance.sourceNoteId!=`string`)||[`type`,`sourceId`,`sourcePath`,`notebookId`,`seedChunkId`,`feedSourceId`].some(e=>n[e]!==void 0&&typeof n[e]!=`string`))throw new tC(400,`invalid whole Note`,`invalid_note_blocks`);try{Js(n.rawContent,rC(n.blocks),n.sourceRevision)}catch(e){throw new tC(400,e instanceof Error?e.message:`invalid block map`,`invalid_note_blocks`)}}else if(e===`block_revisions`){if(!i(`noteId`)||!i(`blockId`)||!r(`version`)||typeof n.rawContent!=`string`||typeof n.savedAt!=`number`||!Number.isFinite(n.savedAt)||![`wod`,`query`,`widget`,`embed`].includes(String(n.kind))||(n.kind===`wod`?n.dialect!==`time`&&n.dialect!==`log`:n.dialect!==void 0||n.sport!==void 0)||n.sport!==void 0&&typeof n.sport!=`string`)throw new tC(400,`invalid block revision`,`invalid_note_blocks`);try{Js(n.rawContent,{[String(n.blockId)]:{id:String(n.blockId),kind:n.kind,version:n.version,sourceRevision:1,from:0,to:n.rawContent.length,...n.dialect===void 0?{}:{dialect:n.dialect},...n.sport===void 0?{}:{sport:n.sport}}},1)}catch(e){throw new tC(400,e instanceof Error?e.message:`invalid revision source`,`invalid_note_blocks`)}}else if(e===`note_revisions`){if(!i(`noteId`)||!r(`version`)||typeof n.title!=`string`||typeof n.rawContent!=`string`||typeof n.savedAt!=`number`||!Number.isFinite(n.savedAt)||n.tags!==void 0&&(!Array.isArray(n.tags)||!n.tags.every(e=>typeof e==`string`))||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||n.type!==void 0&&typeof n.type!=`string`)throw new tC(400,`invalid note revision`,`invalid_note_blocks`);try{Js(n.rawContent,rC(n.blocks),n.version)}catch(e){throw new tC(400,e instanceof Error?e.message:`invalid note revision blocks`,`invalid_note_blocks`)}}else if(e===`schedule_items`){if(!i(`id`)||!i(`date`)||!i(`noteId`)||typeof n.position!=`number`||!Number.isFinite(n.position)||![`planned`,`completed`,`skipped`,`moved`].includes(String(n.status))||typeof n.createdAt!=`number`||!Number.isFinite(n.createdAt)||typeof n.updatedAt!=`number`||!Number.isFinite(n.updatedAt)||[`pageId`,`sourceNotebookId`,`fallbackTitle`,`blockId`,`slot`,`notes`,`movedFromDate`].some(e=>n[e]!==void 0&&typeof n[e]!=`string`))throw new tC(400,`invalid schedule item`,`invalid_schedule_item`)}else if(e===`sessions`){if(!i(`noteId`)||!i(`blockId`)||!r(`blockVersion`)||n.noteSourceRevision!==void 0&&!r(`noteSourceRevision`)||n.sessionDate!==void 0&&typeof n.sessionDate!=`string`||n.scheduleItemId!==void 0&&typeof n.scheduleItemId!=`string`||n.public!==void 0&&typeof n.public!=`boolean`||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||[`segmentId`,`segmentVersion`,`version`,`rawContent`,`script`,`serializedScript`,`source`,`data`,`logs`].some(e=>e in n))throw new tC(400,`Session requires immutable block pin`,`invalid_session_pin`)}else if(!i(`noteId`)||!i(`blockId`)||!r(`blockVersion`)||!r(`sourceRevision`)||n.id!==`${n.noteId}:${n.blockId}`||!Number.isSafeInteger(n.from)||!Number.isSafeInteger(n.to)||`segmentId`in n||`segmentVersion`in n||![`wod`,`query`,`widget`,`embed`].includes(String(n.dataType))||typeof n.rawContent!=`string`||typeof n.noteTitle!=`string`||typeof n.from!=`number`||typeof n.to!=`number`||n.from<0||n.to<=n.from)throw new tC(400,`invalid actionable block projection`,`invalid_note_blocks`)}function Iie(e,t){if(e===void 0||nC(e,t))return;let n=rC(e),r=rC(t);if(typeof n.sourceRevision!=`number`||typeof r.sourceRevision!=`number`||r.sourceRevision<n.sourceRevision||(!nC(n.blocks,r.blocks)||n.rawContent!==r.rawContent)&&r.sourceRevision<=n.sourceRevision)throw new tC(409,`stale Note source revision`,`transaction_conflict`)}function Lie(e,t){if(e===void 0)return;let n=rC(e),r=rC(t);if(n.noteId!==r.noteId||n.blockId!==r.blockId||n.blockVersion!==r.blockVersion)throw new tC(409,`Session pin is immutable`,`invalid_session_pin`)}async function aC(e,t,n){let r=[];for(let t of e)for(let e of Object.values(t.blocks))r.push([t.id,e.id,e.version]);for(let e of t)r.push([e.noteId,e.blockId,e.blockVersion]);let i=await n(r),a=0;for(let t of e)for(let e of Object.values(t.blocks)){let n=i[a++];if(n&&(n.kind!==e.kind||n.rawContent!==t.rawContent.slice(e.from,e.to)||n.dialect!==e.dialect||n.sport!==e.sport))throw new tC(409,`Note block has no matching immutable revision`,`invalid_note_blocks`)}for(let e=0;e<t.length;e++){let e=i[a++];if(!e||e.kind!==`wod`)throw new tC(409,`Session pin must reference a saved workout revision`,`invalid_session_pin`)}}async function oC(e,t,n,r){let i=r?.params?.toString(),a=await e.fetchImpl(`${e.baseUrl}/v1${n}${i?`?${i}`:``}`,{method:t,headers:r?.body===void 0?void 0:{"content-type":`application/json`},body:r?.body===void 0?void 0:JSON.stringify(r.body)});if(!a.ok)throw Error(`ApiStorage: ${t} /v1${n} → ${a.status}`);return a}async function Rie(e,t,n){let r=await e.fetchImpl(`${e.baseUrl}/v1/${t}/get?key=${Eie(n)}`);if(r.status!==404){if(!r.ok)throw Error(`ApiStorage: GET /v1/${t}/get → ${r.status}`);return await r.json()}}async function zie(e,t,n,r,i){let a=new URLSearchParams;return r&&a.set(`range`,JSON.stringify(r)),i!==void 0&&a.set(`count`,String(i)),await(await oC(e,`GET`,`/${t}/${n}`,{params:a})).json()}async function sC(e,t,n,r){let i=new URLSearchParams;return n&&i.set(`range`,JSON.stringify(n)),r!==void 0&&i.set(`index`,r),(await(await oC(e,`GET`,`/${t}/count`,{params:i})).json()).count}async function cC(e,t,n){await oC(e,`DELETE`,`/${t}`,{params:new URLSearchParams({key:JSON.stringify(n)})})}var Bie=class{http;defs;getUserId;writeChain=Promise.resolve();constructor(e=`/api`,t=globalThis.fetch.bind(globalThis),n={}){this.http={baseUrl:e,fetchImpl:t},this.getUserId=n.getUserId,this.defs=Object.fromEntries(RS.map(e=>[e.name,e]))}def(e){let t=this.defs[e];if(!t)throw Error(`ApiStorage: unknown store '${e}'`);return t}makeView(e,t,n,r,i=!1){return new Vie(this.http,this.def(e),e,t,n,this.getUserId,r,i)}readonly(e){return this.makeView(e)}readwrite(e){return this.makeView(e,void 0,void 0,void 0,!0)}async queryDomain(e){let t=await this.http.fetchImpl(`${this.http.baseUrl}/v1/query`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(t.status===409){let e=await t.json();if(typeof e==`object`&&e&&`code`in e&&e.code===`domain_projection_unavailable`)return}if(!t.ok)throw Error(`ApiStorage: POST /v1/query → ${t.status}`);return Mie(await t.json(),e.plan)}async transaction(e,t,n){let r=async()=>{let r=new Map,i=new Set,a=new Map,o=new Set(e),s=(e,n)=>{if(!o.has(e))throw Error(`store outside transaction scope`);if(n&&t!==`readwrite`)throw Error(`read-only transaction`);return this.makeView(e,r,i,a,n)},c=await n({readonly:e=>s(e,!1),readwrite:e=>s(e,!0)});return await this.flush(r,i,a),c};if(t!==`readwrite`)return r();let i=this.writeChain.then(r,r);return this.writeChain=i.then(()=>void 0,()=>void 0),i}async flush(e,t,n){let r=Fie(RS.map(e=>e.name),e,t);r.length>0&&await oC(this.http,`POST`,`/tx`,{body:{ops:[...n.values(),...r]}})}async wipe(){await oC(this.http,`POST`,`/wipe`)}async close(){}},Vie=class{http;def;store;buffer;cleared;getUserId;checks;mutable;constructor(e,t,n,r,i,a,o,s=!1){this.http=e,this.def=t,this.store=n,this.buffer=r,this.cleared=i,this.getUserId=a,this.checks=o,this.mutable=s}dirty(){return eC(this.store,this.buffer,this.cleared)}async get(e){let t=US(e)?e:void 0,n;if(t){if(t.only===void 0)throw Error(`ApiStorage.get: needs a plain key or {only}; bounded ranges match no single row`);n=t.only}else n=e;let r=Nie(this.store,n,this.buffer);if(r)return r.hit?r.value:void 0;if(this.cleared?.has(this.store))return;let i=await Rie(this.http,this.store,n),a=$S(this.store,n);return this.checks?.has(a)||this.checks?.set(a,{op:`check`,store:this.store,key:n,value:structuredClone(i??null)}),i}async getMany(e){return Promise.all(e.map(e=>this.get(e)))}async getAllFromIndexMany(e,t){return Promise.all(t.map(t=>this.getAllFromIndex(e,t)))}async getAll(e,t){let n=KS(e);return this.overlay(await this.serverRows(`all`,n,this.dirty()?void 0:t),t,n)}async getAllFromIndex(e,t,n){let r=KS(t);return this.overlay(await this.serverRows(`index/${encodeURIComponent(e)}`,r,this.dirty()?void 0:n),n,r,e)}async count(e){let t=KS(e);return this.dirty()?this.overlay(await this.serverRows(`all`,t),void 0,t).length:sC(this.http,this.store,t)}async countFromIndex(e,t){let n=KS(t);return this.dirty()?this.overlay(await this.serverRows(`index/${encodeURIComponent(e)}`,n),void 0,n,e).length:sC(this.http,this.store,n,e)}async serverRows(e,t,n){if(this.cleared?.has(this.store))return[];let r=await zie(this.http,this.store,e,t,n);for(let e of r){let t=GS(this.def,e),n=$S(this.store,t);this.checks?.has(n)||this.checks?.set(n,{op:`check`,store:this.store,key:t,value:structuredClone(e)})}return r}overlay(e,t,n,r){return Pie(this.def,this.store,this.buffer,this.cleared,e,t,n,r)}async put(e,t){if(!this.mutable)throw Error(`read-only store`);let n=this.getUserId?.(),r=n?HS(this.store,e,n):e,i=GS(this.def,r);if(this.store===`block_revisions`||this.store===`note_revisions`){let e=this.buffer?.get($S(this.store,i));if(e?.kind===`put`&&!nC(e.value,r))throw Error(this.store===`note_revisions`?`immutable note revision collision`:`immutable block revision collision`)}return this.buffer?(this.buffer.set($S(this.store,i),{kind:`put`,value:r}),i):(await oC(this.http,`POST`,`/tx`,{body:{ops:[{op:`put`,store:this.store,value:r}]}}),i)}async putMany(e,t){if(!this.mutable)throw Error(`read-only store`);if(this.buffer){let t=[];for(let n of e)t.push(await this.put(n));return t}let n=e.map(e=>this.getUserId?HS(this.store,e,this.getUserId()):e),r=n.map(e=>GS(this.def,e));return await oC(this.http,`POST`,`/tx`,{body:{ops:n.map(e=>({op:`put`,store:this.store,value:e}))}}),r}async delete(e){if(!this.mutable)throw Error(`read-only store`);if(this.store===`block_revisions`||this.store===`note_revisions`)throw Error(`block history requires explicit wipe`);let t=US(e)?e:void 0;if(t){if(this.buffer){let e=await this.getAll(t);for(let t of e){let e=GS(this.def,t);this.buffer.set($S(this.store,e),{kind:`delete`,key:e})}return}await cC(this.http,this.store,t);return}let n=e;if(this.buffer){this.buffer.set($S(this.store,n),{kind:`delete`,key:n});return}await cC(this.http,this.store,n)}async clear(){if(!this.mutable)throw Error(`read-only store`);if(this.store===`block_revisions`||this.store===`note_revisions`)throw Error(`block history requires explicit wipe`);if(this.buffer){this.cleared?.add(this.store);let e=`${this.store}\u0000`;for(let t of[...this.buffer.keys()])t.startsWith(e)&&this.buffer.delete(t);return}await oC(this.http,`POST`,`/tx`,{body:{ops:[{op:`clear`,store:this.store}]}})}},Hie=`user-deleted-seed:`;function lC(e){return`${Hie}${e}`}function Uie(e){if(!(typeof e!=`string`||!e.startsWith(`user-deleted-seed:`)))return e.slice(18)||void 0}function Wie(e){return typeof e==`string`&&e.startsWith(`seed:`)}function uC(e){let t=new Set;for(let n of e)typeof n==`object`&&n&&`seedOrigin`in n&&n.seedOrigin===`seed`&&`id`in n&&typeof n.id==`string`&&t.add(n.id);return{seedNoteIds:t}}function dC(e,t,n){if(typeof t!=`object`||!t)return!0;switch(e){case`notes`:return!(`seedOrigin`in t&&t.seedOrigin===`seed`);case`block_index`:case`block_efforts`:case`block_equipment`:return!(`isStatic`in t&&t.isStatic===!0&&`noteId`in t&&typeof t.noteId==`string`&&n.seedNoteIds.has(t.noteId));case`efforts`:case`equipment`:return!(`registrySource`in t&&t.registrySource===`bundled`);case`property_overrides`:return!(`seedOrigin`in t&&t.seedOrigin===`seed`);case`meta`:return!Wie(`key`in t?t.key:void 0);default:return!0}}function fC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pC(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function mC(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function hC(e){return typeof e==`number`&&Number.isFinite(e)}function gC(e){return typeof e==`string`&&e.length>0&&!e.startsWith(`/`)&&!e.split(`/`).includes(`..`)}function _C(e){if(typeof e!=`string`||!e.trim())return!1;if(/^https?:\/\//i.test(e))try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password}catch{return!1}return gC(e)}function vC(e){if(!fC(e))throw Error(`Incompatible seed schema; rebuild seed artifacts`);let t=Array.isArray(e.notebooks);if(e.schema===void 0){if(!t)throw Error(`Incompatible seed schema; rebuild seed artifacts`)}else if(!pC(e.schema)||e.schema!==9&&!t)throw Error(`Incompatible seed schema; rebuild seed artifacts`);let n=e.schema===void 0?9:e.schema,r=e.version===void 0&&t?1:e.version,i=e.builtAt===void 0&&t?new Date(0).toISOString():e.builtAt,a=e.chunks===void 0&&t?[]:e.chunks;if(!mC(r)||typeof i!=`string`||!Number.isFinite(Date.parse(i))||!Array.isArray(a))throw Error(`seed manifest failed shape validation`);for(let t of[`versionLabel`,`commit`,`name`,`description`])if(e[t]!==void 0&&typeof e[t]!=`string`)throw Error(`invalid seed manifest metadata`);if(e.repositoryUrl!==void 0&&(typeof e.repositoryUrl!=`string`||!/^https:\/\//.test(e.repositoryUrl)||new URL(e.repositoryUrl).username||new URL(e.repositoryUrl).password))throw Error(`invalid seed repository URL`);if(e.dirty!==void 0&&typeof e.dirty!=`boolean`)throw Error(`invalid seed manifest metadata`);for(let t of[`indexBytes`,`chunkBytes`])if(e[t]!==void 0&&!mC(e[t]))throw Error(`invalid seed manifest metadata`);let o=new Set,s=new Set;for(let e of a){if(!fC(e)||typeof e.id!=`string`||!e.id||typeof e.path!=`string`||!/^chunks\/[a-zA-Z0-9._-]+\.json$/.test(e.path)||typeof e.sha256!=`string`||!/^[0-9a-f]{64}$/.test(e.sha256)||!mC(e.bytes)||!mC(e.count)||e.kind!==void 0&&e.kind!==`notes`||o.has(e.id)||s.has(e.path))throw Error(`seed manifest failed shape validation`);o.add(e.id),s.add(e.path)}let c;if(e.notebooks!==void 0){if(!Array.isArray(e.notebooks))throw Error(`seed manifest failed shape validation`);c=[];for(let t of e.notebooks){if(!fC(t)||typeof t.notebookId!=`string`||!t.notebookId||typeof t.label!=`string`||!mC(t.count)||!_C(t.indexPath))throw Error(`seed manifest failed shape validation`);if(`records`in t&&Array.isArray(t.records))throw Error(`seed manifest failed shape validation: manifest.notebooks must not contain inline records`);if(t.version!==void 0&&!mC(t.version)||t.commit!==void 0&&typeof t.commit!=`string`||t.builtAt!==void 0&&typeof t.builtAt!=`string`||t.sha256!==void 0&&typeof t.sha256!=`string`||t.bytes!==void 0&&!mC(t.bytes)||t.indexBytes!==void 0&&!mC(t.indexBytes)||t.chunkBytes!==void 0&&!mC(t.chunkBytes))throw Error(`seed manifest failed shape validation`);c.push({...t,version:t.version??r,commit:t.commit??``,builtAt:t.builtAt??i,sha256:t.sha256??``,bytes:t.bytes??t.indexBytes??0})}}return{...e,schema:n,version:r,builtAt:i,chunks:a,...c===void 0?{}:{notebooks:c}}}function yC(e){if(!fC(e))throw Error(`notebook index failed shape validation`);if(typeof e.notebookId!=`string`||!e.notebookId||typeof e.label!=`string`||!e.label||!_C(e.indexPath)||!mC(e.count)||!Array.isArray(e.records)||e.version!==void 0&&!mC(e.version)||e.commit!==void 0&&typeof e.commit!=`string`||e.builtAt!==void 0&&typeof e.builtAt!=`string`||e.sha256!==void 0&&typeof e.sha256!=`string`||e.bytes!==void 0&&!mC(e.bytes))throw Error(`notebook index failed shape validation: missing required index summary or records`);let t=[];for(let n of e.records){if(!fC(n)||typeof n.uuid!=`string`||!n.uuid||!gC(n.path))throw Error(`notebook index failed shape validation: invalid record ref`);let e=n.recordPath!==void 0,r=n.rawUrl!==void 0,i=/\.md$/i.test(n.path);if(e&&!gC(n.recordPath)||r&&!_C(n.rawUrl)||!e&&!r&&!i||n.commit!==void 0&&typeof n.commit!=`string`||n.version!==void 0&&!mC(n.version)||n.sha256!==void 0&&typeof n.sha256!=`string`||n.title!==void 0&&typeof n.title!=`string`||n.date!==void 0&&!hC(n.date))throw Error(`notebook index failed shape validation: invalid record ref`);t.push({...n,commit:n.commit??``,version:n.version??1,sha256:n.sha256??``})}return{...e,version:e.version??1,commit:e.commit??``,builtAt:e.builtAt??new Date(0).toISOString(),sha256:e.sha256??``,bytes:e.bytes??0,records:t}}function Gie(e,t){if(e.telemetry===void 0)return;if(!fC(e.telemetry)||!Array.isArray(e.telemetry.sessions)||!Array.isArray(e.telemetry.events))throw Error(`invalid seed telemetry`);let n=new Map;for(let r of e.telemetry.sessions){if(!fC(r)||typeof r.id!=`string`||!r.id||n.has(r.id)||typeof r.noteId!=`string`||!r.noteId||typeof e.uuid==`string`&&r.noteId!==e.uuid||typeof r.blockId!=`string`||!pC(r.blockVersion)||typeof r.blockContentId!=`string`||!hC(r.startTime)||!hC(r.endTime)||!hC(r.duration)||typeof r.completed!=`boolean`||!hC(r.createdAt))throw Error(`invalid seed session`);let i=t.find(e=>fC(e)&&e.blockId===r.blockId);if(!fC(i)||i.dataType!==`wod`||i.blockVersion!==r.blockVersion||i.blockContentId!==r.blockContentId)throw Error(`orphan or incompatible seed session pin`);n.set(r.id,r)}let r=new Set;for(let t of e.telemetry.events){if(!fC(t)||typeof t.id!=`string`||!t.id||r.has(t.id)||typeof t.resultId!=`string`||typeof t.noteId!=`string`||!hC(t.timestamp)||t.grain!==`event`&&t.grain!==`summary`||typeof t.outputType!=`string`||!Array.isArray(t.metrics)||!t.metrics.every(e=>fC(e)&&typeof e.type==`string`)||t.grain===`summary`&&t.metrics.length!==1)throw Error(`invalid seed event`);let e=n.get(t.resultId);if(!e||t.noteId!==e.noteId||t.blockId!==e.blockId||t.blockVersion!==e.blockVersion||t.blockContentId!==e.blockContentId)throw Error(`orphan or incompatible seed event identity`);r.add(t.id)}}function bC(e){if(!Array.isArray(e))throw Error(`seed chunk is not an array`);let t=new Set;for(let n of e){if(!fC(n)||typeof n.path!=`string`||!n.path||n.path.startsWith(`/`)||n.path.split(`/`).includes(`..`)||t.has(n.path)||typeof n.content!=`string`||!fC(n.blocks)||!Array.isArray(n.blockIndex)||!Array.isArray(n.blockEfforts)||!Array.isArray(n.blockEquipment))throw Error(`seed chunk row failed shape validation`);t.add(n.path);for(let[e,t]of Object.entries(n.blocks))if(!fC(t)||t.id!==e||!e||t.version!==1||t.sourceRevision!==1||!mC(t.from)||!pC(t.to)||t.from>=t.to||t.to>n.content.length||![`wod`,`query`,`widget`,`embed`].includes(String(t.kind))||(t.kind===`wod`?![`time`,`log`].includes(String(t.dialect)):t.dialect!==void 0)||t.sport!==void 0&&typeof t.sport!=`string`)throw Error(`invalid seed block range or revision`);Js(n.content,n.blocks,1,{registeredWidgets:DS});let e=new Set,r=Gs(n.content,{registeredWidgets:DS});for(let t of n.blockIndex){if(!fC(t)||typeof t.blockId!=`string`)throw Error(`invalid seed projection`);let i=n.blocks[t.blockId];if(!fC(i)||e.has(t.blockId)||typeof t.id!=`string`||typeof t.noteId!=`string`||t.id!==`${t.noteId}:${t.blockId}`||t.blockVersion!==1||t.sourceRevision!==1||t.from!==i.from||t.to!==i.to||t.dataType!==i.kind||t.rawContent!==n.content.slice(Number(i.from),Number(i.to))||typeof t.noteTitle!=`string`||typeof t.createdAt!=`number`||!Number.isFinite(t.createdAt)||t.sourcePath!==n.path||t.isStatic!==!0)throw Error(`orphan or incompatible seed projection`);if(`segmentId`in t||`segmentVersion`in t)throw Error(`incompatible seed projection`);for(let e of[`sourceId`,`routeId`,`blockContentId`])if(t[e]!==void 0&&typeof t[e]!=`string`)throw Error(`invalid seed projection metadata`);if(t.position!==void 0&&!mC(t.position))throw Error(`invalid seed projection position`);if(i.kind===`wod`){let e=r.find(e=>e.from===i.from&&e.to===i.to);if(t.blockContentId!==ys(e?.scriptBlock?.content??n.content.slice(Number(i.from),Number(i.to))))throw Error(`invalid seed workout fingerprint`)}else if(t.blockContentId!==void 0)throw Error(`non-workout seed fingerprint`);e.add(t.blockId)}if(e.size!==Object.keys(n.blocks).length)throw Error(`missing actionable seed projection`);let i=new Set;for(let t of n.blockEfforts){if(!fC(t)||typeof t.blockId!=`string`||typeof t.noteId!=`string`||typeof t.effortSlug!=`string`||!t.effortSlug)throw Error(`invalid seed effort identity`);let r=n.blocks[t.blockId];if(t.id!==`${t.noteId}:${t.blockId}:${t.effortSlug}`||i.has(String(t.id))||!fC(r)||r.kind!==`wod`||!e.has(t.blockId)||t.sourcePath!==n.path||t.isStatic!==!0||typeof t.createdAt!=`number`)throw Error(`orphan or incompatible seed effort link`);let a=n.blockIndex.find(e=>fC(e)&&e.blockId===t.blockId);if(!fC(a)||t.noteId!==a.noteId||t.blockContentId!==a.blockContentId||!Number.isFinite(t.createdAt))throw Error(`invalid seed effort metadata`);i.add(String(t.id))}let a=new Set;for(let t of n.blockEquipment){if(!fC(t)||typeof t.blockId!=`string`||typeof t.noteId!=`string`||typeof t.equipmentSlug!=`string`||!t.equipmentSlug)throw Error(`invalid seed equipment identity`);let r=n.blocks[t.blockId];if(t.id!==`${t.noteId}:${t.blockId}:${t.equipmentSlug}`||a.has(String(t.id))||!fC(r)||r.kind!==`wod`||!e.has(t.blockId)||t.sourcePath!==n.path||t.isStatic!==!0||typeof t.createdAt!=`number`)throw Error(`orphan or incompatible seed equipment link`);let i=n.blockIndex.find(e=>fC(e)&&e.blockId===t.blockId);if(!fC(i)||t.noteId!==i.noteId||t.blockContentId!==i.blockContentId||!Number.isFinite(t.createdAt))throw Error(`invalid seed equipment metadata`);a.add(String(t.id))}Gie(n,n.blockIndex)}return e}function xC(e){return bC([e])[0]}function SC(e,t,n){return`${e}:${t}:${n}`}function CC(e){let t=[];for(let[n,r]of Object.entries(e.metrics)){if(typeof r!=`string`&&typeof r!=`number`)continue;let e=String(r).trim().match(/^([+-]?\d+(?:\.\d+)?)\s*([A-Za-z%/][\w%/.-]*)$/);e?t.push({kind:`metric`,type:n,value:Number(e[1]),unit:e[2]}):t.push({kind:`metric`,type:n,value:r})}for(let[n,r]of Object.entries(e.summaries))t.push({kind:`metric`,type:`summaries.${n}`,value:r});for(let[n,r]of Object.entries(e.widgets??{}))t.push({kind:`metric`,type:`widgets.${n}`,value:r});for(let n of e.tags)t.push({kind:`tag`,slug:n});for(let n of e.functions)t.push({kind:`function`,name:n});return t}async function wC(e,t){let n=Ps(t.targetNotebookId);if(js(n))throw Error(`Notebook '${n}' is read-only and cannot store overrides.`);if(n===`notebook/journal`||n===`notebook/playground`)throw Error(`Property overrides belong in 'notebook/custom' or a shared user Notebook, not '${n}'.`);let r=t.slug.trim().toLowerCase();if(!r)throw Error(`Property override requires a non-empty canonical slug.`);let i=Ns(n),a=`override/${i}/${t.kind}/${r}`,o=`${t.kind}-override-${i}-${r}`,s=Date.now(),c=t.rawContent,l=cS(c);(typeof l.id!=`string`||!l.id.trim())&&(c=rc(c,[`id`],o)),(typeof l.slug!=`string`||l.slug.trim()!==r)&&(c=rc(c,[`slug`],r));let u=t.title?.trim()||r,d;if(t.kind===`effort`){let e=Wd(c);if(e.errors.length>0)throw Error(e.errors.join(`
|
|
155
155
|
`));u=e.effort.label||u,d={...e.effort,id:typeof l.id==`string`&&l.id.trim()?l.id.trim():o,slug:r,label:u,registrySource:`user`,ownerNoteId:a,sourceId:n,updatedAt:new Date(s).toISOString()}}else if(t.kind===`equipment`){let e=qd(c);if(e.errors.length>0)throw Error(e.errors.join(`
|
|
156
156
|
`));u=e.equipment.label||u,d={...e.equipment,id:typeof l.id==`string`&&l.id.trim()?l.id.trim():o,slug:r,label:u,registrySource:`user`,ownerNoteId:a,sourceId:n,updatedAt:new Date(s).toISOString()}}else if(t.kind===`tag`){let e=t.category??`tag`,n=Yd(c,e);if(n.errors.length>0)throw Error(n.errors.join(`
|
|
157
157
|
`));let i=n.tag.category||e;u=n.tag.label||u,d={id:n.tag.id||o,label:r,...i===`tag`?{}:{type:i},contributions:CC(n.tag),createdAt:s}}else{let e=CC(Yd(c,`tag`).tag);u=typeof l.label==`string`&&l.label.trim()||u,d={id:o,name:r,label:u,...typeof l.color==`string`&&l.color.trim()?{color:l.color.trim()}:{},...e.length>0?{contributions:e}:{},createdAt:s}}let f={id:SC(n,t.kind,r),notebookId:n,kind:t.kind,slug:r,label:u,ownerNoteId:a,rawContent:c,payload:d,seedOrigin:`user`,updatedAt:s};return await e.transaction([`notes`,`block_revisions`,`property_overrides`,`tags`,`tag_types`],`readwrite`,async e=>{let r=await e.readonly(`notes`).get(n);if(r&&(r.feedOrigin===`feed`||r.seedOrigin===`seed`))throw Error(`Notebook '${n}' is feed-delivered and read-only.`);let i=await e.readonly(`notes`).get(a),o=(i?.sourceRevision??0)+1,l=qs(c,{sourceRevision:o,registeredWidgets:Us}),p=Object.values(l).map(e=>({noteId:a,blockId:e.id,version:e.version,kind:e.kind,rawContent:c.slice(e.from,e.to),savedAt:s,...e.dialect?{dialect:e.dialect}:{},...e.sport?{sport:e.sport}:{}}));await e.readwrite(`notes`).put({id:a,title:u,rawContent:c,sourceRevision:o,blocks:l,createdAt:i?.createdAt??s,notebookId:n,notebookIds:[n],seedOrigin:`user`}),p.length>0&&await e.readwrite(`block_revisions`).putMany(p),await e.readwrite(`property_overrides`).put(f),n===`notebook/custom`&&(t.kind===`tag`?await e.readwrite(`tags`).put(d):t.kind===`tag-type`&&await e.readwrite(`tag_types`).put(d))}),f}async function TC(e,t){let n;try{n=t?.notebookId?await e.readonly(`property_overrides`).getAllFromIndex(`by-notebook`,t.notebookId):t?.kind&&t?.slug?await e.readonly(`property_overrides`).getAllFromIndex(`by-kind-slug`,[t.kind,t.slug]):await e.readonly(`property_overrides`).getAll()}catch{return[]}return n.filter(e=>!(t?.notebookId&&e.notebookId!==t.notebookId||t?.kind&&e.kind!==t.kind||t?.slug&&e.slug!==t.slug))}function Kie(e){let t=[],n=e=>{if(!e||!e.trim())return;if(e.startsWith(`feed:`)){t.includes(e)||t.push(e);return}let n=Ps(e);n!==`notebook/defaults`&&n!==`notebook/custom`&&n!==`notebook/journal`&&n!==`notebook/playground`&&(t.includes(n)||t.push(n))};if(e.note){let t=e.note.provenance?.feedSourceId??e.note.feedSourceId;t&&t!==`core`&&t!==`local`&&n(`feed:${t}`),e.note.provenance?.sourceNotebookId&&n(e.note.provenance.sourceNotebookId);for(let t of vb(e.note))n(t);let r=yb(e.note);r&&n(r)}return e.notebookId&&n(e.notebookId),t}async function EC(e,t={}){let n=[];try{n=await e.readonly(`property_overrides`).getAll()}catch{}let r=[],i=[],a=[],o=[];try{[r,i,a,o]=await Promise.all([e.readonly(`efforts`).getAll(),e.readonly(`equipment`).getAll(),e.readonly(`tags`).getAll(),e.readonly(`tag_types`).getAll()])}catch{}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map;for(let e of r)e.registrySource===`bundled`&&(!e.sourceId||e.sourceId===`core`||e.sourceId===`efforts`)&&(s.set(e.slug,e),d.set(`effort:${e.slug}`,`notebook/defaults`));for(let e of i)e.registrySource===`bundled`&&(!e.sourceId||e.sourceId===`core`||e.sourceId===`equipment`)&&(c.set(e.slug,e),d.set(`equipment:${e.slug}`,`notebook/defaults`));for(let e of a)l.set(e.label,e),d.set(`tag:${e.label}`,`notebook/defaults`);for(let e of o)u.set(e.name,e),d.set(`tag-type:${e.name}`,`notebook/defaults`);let f=t.notebookId?Ps(t.notebookId):void 0,p=t.mode??`source-first`,m=Kie(t),h;if(h=f===`notebook/defaults`?[`notebook/defaults`]:p===`custom-runtime`||m.length===0?[`notebook/defaults`,...m,`notebook/custom`]:[`notebook/defaults`,`notebook/custom`,...m],h.includes(`notebook/custom`)){for(let e of r)e.registrySource===`user`&&!s.has(e.slug)&&(s.set(e.slug,e),d.set(`effort:${e.slug}`,`notebook/custom`));for(let e of i)e.registrySource===`user`&&!c.has(e.slug)&&(c.set(e.slug,e),d.set(`equipment:${e.slug}`,`notebook/custom`))}let g=new Map;for(let e of n){let t=g.get(e.notebookId)??[];t.push(e),g.set(e.notebookId,t)}for(let e of h){let t=g.get(e)??[];for(let n of t){let t=(e.startsWith(`feed:`),e);if(n.kind===`effort`){let e=n.payload??Wd(n.rawContent).effort;s.set(n.slug,{...e,slug:n.slug}),d.set(`effort:${n.slug}`,t)}else if(n.kind===`equipment`){let e=n.payload??qd(n.rawContent).equipment;c.set(n.slug,{...e,slug:n.slug}),d.set(`equipment:${n.slug}`,t)}else if(n.kind===`tag`){let e=n.payload;e&&(l.set(n.slug,e),d.set(`tag:${n.slug}`,t))}else if(n.kind===`tag-type`){let e=n.payload;e&&(u.set(n.slug,e),d.set(`tag-type:${n.slug}`,t))}}}let _=[...s.values()],v=[...c.values()],y=[...l.values()],b=[...u.values()],x=[...b.filter(e=>e.contributions&&e.contributions.length>0).map(e=>({slug:`category:${e.name}`,contributions:e.contributions??[]})),...y.map(e=>({slug:e.label,contributions:e.contributions??[]}))];return{efforts:_,equipment:v,tags:y,tagTypes:b,referenceIndex:lf({efforts:_,equipment:v}),tagIndex:gs(x),originByKey:d}}async function qie(e,t){let n=Ps(t.notebookId);if(Ms(n))return[];let r,i;try{[r,i]=await Promise.all([e.readonly(`property_overrides`).getAllFromIndex(`by-notebook`,`notebook/custom`),e.readonly(`property_overrides`).getAllFromIndex(`by-notebook`,n)])}catch{return[]}let a=new Map(i.map(e=>[`${e.kind}:${e.slug}`,e])),o=new Map(r.map(e=>[`${e.kind}:${e.slug}`,e])),s=new Set;for(let e of t.effortSlugs??[])s.add(`effort:${e}`);for(let e of t.equipmentSlugs??[])s.add(`equipment:${e}`);for(let e of t.tagSlugs??[])s.add(`tag:${e}`);let c=[],l=Date.now();for(let e of s){if(a.has(e))continue;let t=o.get(e);if(!t)continue;let r={...t,id:SC(n,t.kind,t.slug),notebookId:n,updatedAt:l};c.push(r),a.set(e,r)}return c.length>0&&await e.transaction([`property_overrides`],`readwrite`,async e=>{await e.readwrite(`property_overrides`).putMany(c)}),[...a.values()]}async function DC(e){let t=await crypto.subtle.digest(`SHA-1`,new TextEncoder().encode(`${yie}:${e}`)),n=new Uint8Array(t.slice(0,16));n[6]=n[6]&15|80,n[8]=n[8]&63|128;let r=Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``);return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function OC(e,t){if(Object.is(e,t))return!0;if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e).filter(t=>Reflect.get(e,t)!==void 0),r=Object.keys(t).filter(e=>Reflect.get(t,e)!==void 0);return n.length===r.length&&n.every(n=>n in t&&OC(Reflect.get(e,n),Reflect.get(t,n)))}function kC(e){return(e.split(`/`).at(-1)??e).replace(/\.md$/,``).replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Jie(e,t,n){let r=e.rawContent,i=0,a=r.length,o=t.length;for(;i<a&&i<o&&r[i]===t[i];)i++;for(;a>i&&o>i&&r[a-1]===t[o-1];)a--,o--;let s=Object.values(e.blocks).filter(e=>i<e.to&&a>e.from),c=Ys(s.length<=1?e.blocks:Object.fromEntries(Object.entries(e.blocks).filter(([,e])=>!s.includes(e))),[{from:i,to:a,insert:t.slice(i,o)}]),l=0;return qs(t,{sourceRevision:n,blocks:c,registeredWidgets:DS,createId:()=>`seed:${e.id}:r${n}:${l++}`})}async function AC(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=new Set(s),m=e=>{let t=-1;for(let n of o)n.noteIds.has(e)&&n.rank>t&&(t=n.rank);return t},h=[],g=i;for(let[e,t]of c.entries()){if(!u.has(l[e]))continue;let r=n(t.content);r&&h.push({...r,registrySource:`bundled`,ownerNoteId:l[e],sourceId:g,sourcePath:t.path})}let _=await e.getMany(h.map(e=>e.slug)),v=h.filter((e,t)=>{let n=_[t];if(!n)return!0;if(n.registrySource!==`bundled`)return!1;let r;if(n.ownerNoteId===e.ownerNoteId||n.ownerNoteId&&p.has(n.ownerNoteId)&&m(n.ownerNoteId)<a)r=a;else{let e=n.ownerNoteId?m(n.ownerNoteId):-1;r=e>=0?e:OS(n.sourceId)}return a>=r&&!OC(e,n)});v.length&&await e.putMany(v);let y=new Set(h.map(e=>e.slug)),b=new Map;for(let e of f){let t=d.get(e);if(!t||t.seedOrigin!==`seed`)continue;let r=n(t.rawContent)?.slug;r&&!y.has(r)&&b.set(r,e)}let x=[...b.keys()];if(x.length){let a=await e.getMany(x);for(let[s,c]of a.entries()){let a=x[s];if(!c||c.registrySource!==`bundled`)continue;let l=b.get(a);if(!(c.ownerNoteId===l&&(!c.sourceId||c.sourceId===i||c.sourceId===r)))continue;let u=!1;for(let i of o){let o=i.meta.chunks?.[r]?.noteIds??[];if(!o.length)continue;let s=await t.getMany(o);for(let t of s){if(!t||t.seedOrigin!==`seed`)continue;let r=n(t.rawContent);if(r&&r.slug===a){await e.put({...r,registrySource:`bundled`,ownerNoteId:t.id,sourceId:i.sourceId,sourcePath:t.sourcePath??``}),u=!0;break}}if(u)break}u||await e.delete(a)}}return v.length}async function jC(e,t,n){if(!t.length)return;let r=await e.getMany(n),i=t.filter((e,t)=>!OC(e,r[t]));i.length&&await e.putMany(i)}var Yie=[`notes`,`block_revisions`,`block_index`,`block_efforts`,`block_equipment`,`page`,`page_notes`,`tags`,`note_tags`,`efforts`,`equipment`,`property_overrides`,`meta`,`sessions`,`events`];async function Xie(e){vC(e.manifest),bC(e.rows);let t=await Promise.all(e.rows.map(e=>DC(e.path))),n=new Map,r=new Map,i=new Map;for(let[a,o]of e.rows.entries()){let e=cS(o.content).slug;typeof e==`string`&&e.trim()&&(n.set(e,await DC(`page:${e}`)),r.set(t[a],await DC(`pagenote:${e}:${o.path}`)));for(let{label:e}of uS(o.content))i.has(e)||i.set(e,await DC(`tag:${e}`))}return{write:e,ids:t,pagesBySlug:n,linkIds:r,tagIds:i}}async function MC(e,t){let n={totalNotes:0,totalEfforts:0,totalEquipment:0,totalBlocks:0,skippedUserOwned:0,deleted:0,preservedPinned:0,addedNotes:0,updatedNotes:0};if(!t.length)return n;let r=await Promise.all(t.map(Xie)),i={...n};for(let t=0;t<r.length;t++){let n=r[t],a=await e.transaction(Yie,`readwrite`,e=>Qie(e,n));i.totalNotes+=a.totalNotes,i.totalEfforts+=a.totalEfforts,i.totalEquipment+=a.totalEquipment,i.totalBlocks+=a.totalBlocks,i.skippedUserOwned+=a.skippedUserOwned,i.deleted+=a.deleted,i.preservedPinned=(i.preservedPinned??0)+(a.preservedPinned??0),i.addedNotes+=a.addedNotes,i.updatedNotes+=a.updatedNotes,t+1<r.length&&await new Promise(e=>setTimeout(e,0))}return i}async function Zie(e,t){return MC(e,[t])}async function Qie(e,t){let{write:n,ids:r,pagesBySlug:i,linkIds:a,tagIds:o}=t,s={totalNotes:0,totalEfforts:0,totalEquipment:0,totalBlocks:0,skippedUserOwned:0,deleted:0,preservedPinned:0,addedNotes:0,updatedNotes:0},c=e.readwrite(`meta`),l=new Set;for(let e of await c.getAll()){let t=Uie(e?.key);t!==void 0&&l.add(t)}if(!OC(await c.get(n.meta.key),n.expectedMeta))throw Error(`Seed checkpoint changed during import`);if(n.meta.schema!==9||n.manifest.schema!==9&&!Array.isArray(n.manifest.notebooks))throw Error(`Incompatible seed schema; recreate artifacts`);let u=e.readwrite(`notes`),d=n.chunkId?n.expectedMeta?.chunks[n.chunkId]?.noteIds??[]:[],f=new Set((n.chunkId?n.meta.chunks[n.chunkId]?.noteIds:void 0)??r),p=d.filter(e=>!f.has(e)),m=[...new Set([...r,...p])],h=await u.getMany(m),g=new Map(m.map((e,t)=>[e,h[t]])),_=n.meta.key.startsWith(`seed:`)?n.meta.key.slice(5):n.meta.key,v=Sie(n.meta.key),y=OS(n.meta.key,n.meta.tier),b=[];for(let e of await c.getAll()){let t=e;if(!t||typeof t.key!=`string`||!t.key.startsWith(`seed:`)||t.key===n.meta.key)continue;let r=new Set;for(let e of Object.values(t.chunks??{}))for(let t of e.noteIds??[])r.add(t);b.push({key:t.key,sourceId:t.key.slice(5),rank:OS(t.key,t.tier),meta:t,noteIds:r})}b.sort((e,t)=>t.rank-e.rank);let x=e=>{let t=-1;for(let n of b)n.noteIds.has(e)&&n.rank>t&&(t=n.rank);return t},S=m.filter(e=>{if(l.has(e))return!1;let t=g.get(e);if(!t)return f.has(e);if(t.seedOrigin!==`seed`)return!1;let r=x(e);return f.has(e)?y>=r:r<0&&t.seedChunkId===n.chunkId}),C=new Set(S),w=e.readwrite(`block_revisions`),T=r.filter((e,t)=>C.has(e)&&g.get(e)?.rawContent!==n.rows[t].content),E=await w.getAllFromIndexMany(`by-note`,T),D=new Map(T.map((e,t)=>[e,E[t]])),O=e.readwrite(`block_index`),k=e.readwrite(`block_efforts`),A=e.readwrite(`block_equipment`),j=e.readwrite(`note_tags`),M=e.readwrite(`page_notes`),N=await O.getAllFromIndexMany(`by-note`,S),P=await k.getAllFromIndexMany(`by-note`,S),F=await A.getAllFromIndexMany(`by-note`,S),I=await j.getAllFromIndexMany(`by-note`,S),ee=await M.getAllFromIndexMany(`by-note`,S),L=new Map(S.map((e,t)=>[e,t])),R=e.readwrite(`tags`),z=[...o.keys()],B=await R.getAllFromIndexMany(`by-label`,z),V=new Map(z.map((e,t)=>[e,B[t][0]])),H=[],U=[],te=[],W=[],ne=[],re=[],ie=[],ae=[],oe=[],se=e.readwrite(`sessions`),ce=e.readwrite(`events`),le=new Set;if(S.length>0){let e;try{e=await se.getAllFromIndexMany(`by-note`,S)}catch{let t=await se.getAll();e=S.map(e=>t.filter(t=>t.noteId===e))}for(let t=0;t<S.length;t++){let n=S[t];(g.get(n)?.retention===`session-pinned`||(e[t]?.length??0)>0)&&le.add(n)}}let ue=n.rows.flatMap(e=>e.telemetry?.sessions.map(e=>e.id)??[]),de=await se.getMany(ue),fe=new Map(ue.map((e,t)=>[e,de[t]])),pe=[],me=[];for(let[e,t]of n.rows.entries()){let c=r[e],l=g.get(c);if(!C.has(c)){l&&l.seedOrigin!==`seed`&&s.skippedUserOwned++;continue}l?l.rawContent!==t.content&&s.updatedNotes++:s.addedNotes++,Js(t.content,t.blocks,1,{registeredWidgets:DS});let u=l?l.sourceRevision+(l.rawContent===t.content?0:1):1,d=0,f=D.get(c)??[],p=l?l.rawContent===t.content?structuredClone(l.blocks):Jie(l,t.content,u):f.length?qs(t.content,{sourceRevision:u,registeredWidgets:DS,createId:()=>`seed:${c}:new${f.length}:${d++}`}):structuredClone(t.blocks);for(let e of Object.values(p)){let r=(D.get(c)??[]).filter(t=>t.blockId===e.id).sort((e,t)=>t.version-e.version)[0],i=t.content.slice(e.from,e.to);if(l?.rawContent===t.content)continue;let a=r&&r.kind===e.kind&&r.rawContent===i&&r.dialect===e.dialect&&r.sport===e.sport;e.version=l?a?r.version:(r?.version??0)+1:1,(!l||!a)&&te.push({noteId:c,blockId:e.id,version:e.version,kind:e.kind,rawContent:i,savedAt:n.meta.importedAt,...e.dialect?{dialect:e.dialect}:{},...e.sport?{sport:e.sport}:{}})}Js(t.content,p,u,{registeredWidgets:DS});let m=cS(t.content),h=typeof m.title==`string`&&m.title.trim()?m.title.trim():kC(t.path),_=n.chunkId?wie(t.path,t.content,n.chunkId):void 0;if(!_)throw Error(`Unknown seed source family ${n.chunkId}`);let y=typeof m.date==`string`?m.date.match(/^(\d{4})-(\d{2})-(\d{2})$/):null,b;if(y){let e=Date.parse(`${m.date}T12:00:00Z`);if(!(Number.isFinite(e)&&new Date(e).getUTCMonth()===Number(y[2])-1&&new Date(e).getUTCDate()===Number(y[3])))throw Error(`invalid frontmatter date '${m.date}' in '${t.path}' — expected a real calendar day (YYYY-MM-DD)`);b=e}let x=t.commit??n.manifest.commit,S=l,w=le.has(c)||S?.retention===`session-pinned`?`session-pinned`:S?.retention===`schedule-pinned`?`schedule-pinned`:void 0,T={...l,id:c,title:h,rawContent:t.content,sourceRevision:u,blocks:p,createdAt:n.manifest.version,...b===void 0?{}:{date:b},type:n.chunkId===`dashboards`?`dashboard`:`note`,sourceId:_,seedOrigin:`seed`,seedVersion:n.manifest.version,seedChunkId:n.chunkId??void 0,feedOrigin:`feed`,feedSourceId:v,sourcePath:t.path,...x?{seedCommit:x}:{},...w?{retention:w}:S?.retention?{retention:S.retention}:{},...w||S?.upstreamStatus?{upstreamStatus:`live`}:{}};b===void 0&&delete T.date,OC(T,l)||U.push(T);let E=new Map(Object.values(p).map(e=>[`${e.from}:${e.to}`,e])),O=new Map(t.blockIndex.map(e=>[e.blockId,e])),k=new Map;for(let e of t.blockIndex){let n=E.get(`${e.from}:${e.to}`);if(!n||n.kind!==e.dataType)throw Error(`Orphan seed projection`);k.set(e.blockId,n.id);let r={...e,id:`${c}:${n.id}`,noteId:c,blockId:n.id,blockVersion:n.version,sourceRevision:u,noteTitle:h,sourceId:_,sourcePath:t.path,rawContent:t.content.slice(n.from,n.to)},i=N[L.get(c)].find(e=>e.id===r.id);(!i||i.isStatic===!0)&&ie.push(r)}let A=new Map,M=new Set;for(let e of t.telemetry?.sessions??[]){if(O.get(e.blockId)?.dataType!==`wod`)throw Error(`Orphan seed session pin`);let t=fe.get(e.id);if(t&&t.noteId!==c)throw Error(`Seed session ${e.id} belongs to another note`);if(t&&(t.origin||!t.id.startsWith(`seed:`))){M.add(e.id);continue}let n=t?.blockId??k.get(e.blockId);if(!n)throw Error(`Orphan seed session pin`);let r=p[n];if(!t&&!r)throw Error(`Orphan seed session pin`);let i={...e,noteId:c,blockId:n,blockVersion:t?.blockVersion??r.version,blockContentId:t?.blockContentId??O.get(e.blockId)?.blockContentId};pe.push(i),A.set(i.id,i)}for(let e of t.telemetry?.events??[]){if(M.has(e.resultId))continue;let t=A.get(e.resultId);if(!t)throw Error(`Orphan seed event result`);me.push({...e,noteId:c,blockId:t.blockId,blockVersion:t.blockVersion,blockContentId:t.blockContentId})}for(let e of t.blockEfforts){let n=k.get(e.blockId);if(!n||O.get(e.blockId)?.dataType!==`wod`)throw Error(`Orphan seed effort link`);let r={...e,id:`${c}:${n}:${e.effortSlug}`,noteId:c,blockId:n,sourcePath:t.path},i=P[L.get(c)].find(e=>e.id===r.id);(!i||i.isStatic===!0)&&ae.push(i?{...r,createdAt:i.createdAt}:r)}for(let e of t.blockEquipment){let n=k.get(e.blockId);if(!n||O.get(e.blockId)?.dataType!==`wod`)throw Error(`Orphan seed equipment link`);let r={...e,id:`${c}:${n}:${e.equipmentSlug}`,noteId:c,blockId:n,sourcePath:t.path},i=F[L.get(c)].find(e=>e.id===r.id);(!i||i.isStatic===!0)&&oe.push(i?{...r,createdAt:i.createdAt}:r)}let ee=L.get(c),R=new Set;for(let e of uS(t.content)){let t=V.get(e.label);t?e.type&&!t.type&&(t={...t,type:e.type},H.push(t),V.set(e.label,t)):(t={id:o.get(e.label),label:e.label,type:e.type,createdAt:n.meta.importedAt},H.push(t),V.set(e.label,t)),!R.has(t.id)&&(R.add(t.id),I[ee].find(e=>e.tagId===t.id)||re.push({id:`${c}:${t.id}`,noteId:c,tagId:t.id}))}for(let e of I[ee])R.has(e.tagId)||await j.delete(e.id);let z=m.slug;if(typeof z==`string`&&i.has(z)){let e=i.get(z);W.push({id:e,slug:z,title:kC(t.path),createdAt:n.manifest.version}),ne.push({id:a.get(c),pageId:e,noteId:c,createdAt:n.manifest.version})}s.totalNotes++,s.totalBlocks+=Object.keys(p).length}let he=new Set(p.filter(e=>C.has(e)&&(le.has(e)||g.get(e)?.retention===`schedule-pinned`))),ge=new Set(ie.map(e=>e.id)),_e=new Set(ae.map(e=>e.id)),ve=new Set(oe.map(e=>e.id));for(let e of N)for(let t of e)t.isStatic===!0&&!ge.has(t.id)&&!he.has(t.noteId)&&await O.delete(t.id);for(let e of P)for(let t of e)t.isStatic===!0&&!_e.has(t.id)&&!he.has(t.noteId)&&await k.delete(t.id);for(let e of F)for(let t of e)t.isStatic===!0&&!ve.has(t.id)&&!he.has(t.noteId)&&await A.delete(t.id);for(let e of p){if(!C.has(e))continue;let t=g.get(e);if(!t)continue;let n=le.has(e)||t.retention===`session-pinned`?`session-pinned`:t.retention===`schedule-pinned`?`schedule-pinned`:void 0;if(n){let e={...t,retention:n,upstreamStatus:`removed`};OC(e,t)||U.push(e),s.preservedPinned=(s.preservedPinned??0)+1;continue}let r=L.get(e);await u.delete(e);for(let e of I[r])await j.delete(e.id);for(let e of ee[r])await M.delete(e.id);s.deleted++}let ye=async(t,i)=>{let a;try{a=e.readwrite(`property_overrides`)}catch{return}let o=v===`core`?[`notebook/defaults`]:[`feed:${v}`,...n.manifest.chunks.filter(e=>e.id.startsWith(`notebook.`)).map(e=>`notebook/${LS(e.id)}`)],s=new Set,c=[];for(let[e,a]of n.rows.entries()){let l=i(a.content);if(l)for(let i of o){let o=SC(i,t,l.slug);s.add(o),c.push({id:o,notebookId:i,kind:t,slug:l.slug,label:l.label,ownerNoteId:r[e],rawContent:a.content,payload:l,seedOrigin:`seed`,feedSourceId:v,updatedAt:n.meta.importedAt})}}c.length>0&&await a.putMany(c);let l=await a.getAll();for(let e of l)e.seedOrigin===`seed`&&e.feedSourceId===v&&e.kind===t&&!s.has(e.id)&&await a.delete(e.id)};return n.chunkId===`efforts`&&(s.totalEfforts=await AC(e.readwrite(`efforts`),u,Vd,`efforts`,_,y,b,d,n.rows,r,C,g,m),await ye(`effort`,Vd)),n.chunkId===`equipment`&&(s.totalEquipment=await AC(e.readwrite(`equipment`),u,Hd,`equipment`,_,y,b,d,n.rows,r,C,g,m),await ye(`equipment`,Hd)),U.length&&await u.putMany(U),te.length&&await w.putMany(te),await jC(O,ie,ie.map(e=>e.id)),await jC(k,ae,ae.map(e=>e.id)),await jC(A,oe,oe.map(e=>e.id)),await jC(se,pe,pe.map(e=>e.id)),await jC(ce,me,me.map(e=>e.id)),H.length&&await R.putMany([...new Map(H.map(e=>[e.id,e])).values()]),re.length&&await j.putMany(re),await jC(e.readwrite(`page`),W,W.map(e=>e.id)),await jC(M,ne,ne.map(e=>e.id)),await c.put(n.meta),s}function $ie(e,t){let n=t.seedChunkId?e.filter(e=>e.chunkId===t.seedChunkId):[];return[...n.length>0?n:e].sort((e,t)=>t.rank-e.rank||(e.key<t.key?-1:+(e.key>t.key)))[0]}async function eae(e){return e.transaction([`meta`,`notes`,`block_index`],`readwrite`,async e=>{let t=e.readwrite(`meta`),n=new Map;for(let e of await t.getAll()){let t=e;if(!t||typeof t.key!=`string`||!t.key.startsWith(`seed:`))continue;let r=t.key.slice(5),i=OS(t.key,t.tier);for(let[e,a]of Object.entries(t.chunks??{}))for(let o of a.noteIds??[]){let a=n.get(o)??[];a.push({sourceId:r,chunkId:e,rank:i,key:t.key}),n.set(o,a)}}if(n.size===0)return 0;let r=e.readwrite(`notes`),i=e.readwrite(`block_index`),a=[...n.keys()],o=await r.getMany(a),s=[];for(let e=0;e<a.length;e++){let t=a[e],i=o[e];if(!i||i.seedOrigin!==`seed`||i.feedSourceId)continue;let c=$ie(n.get(t),i),l=i.sourceRevision+1,u=Object.fromEntries(Object.entries(i.blocks).map(([e,t])=>[e,{...t,sourceRevision:l}]));await r.put({...i,blocks:u,sourceRevision:l,feedOrigin:`feed`,feedSourceId:c.sourceId}),s.push({id:t,sourceRevision:l})}if(s.length>0){let e=new Map(s.map(e=>[e.id,e.sourceRevision])),t=(await i.getAllFromIndexMany(`by-note`,s.map(e=>e.id))).flatMap(t=>t.flatMap(t=>{let n=e.get(t.noteId);return n!==void 0&&t.sourceRevision!==n?[{...t,sourceRevision:n}]:[]}));t.length>0&&await i.putMany(t)}return s.length})}async function tae(e){return e.transaction([`meta`,`notes`,`block_index`,`block_efforts`,`block_equipment`],`readwrite`,async e=>{let t=0,n=e.readwrite(`meta`);for(let e of await n.getAll()){let r=e;if(!r||typeof r.key!=`string`||!r.key.startsWith(`seed:`))continue;let i=r.chunks??{},a=!1,o={};for(let[e,t]of Object.entries(i)){let n=px(e);n!==e&&(a=!0),o[n]=o[n]&&o[n]!==t?{...o[n],noteIds:[...new Set([...o[n].noteIds??[],...t.noteIds??[]])]}:t}a&&(await n.put({...r,chunks:o}),t++)}for(let n of[`notes`,`block_index`,`block_efforts`,`block_equipment`]){let r=e.readwrite(n);for(let e of await r.getAll()){let n=e;vx(n)&&(await r.put(_x(n)),t++)}}return t})}function NC(e,t={}){let n=(e,t)=>typeof IDBKeyRange<`u`?IDBKeyRange.bound(e,t):{lower:e,upper:t},r=e=>n([e,``],[`${e}\uffff`,``]),i={getEventsByTimeRange:async(t,r)=>e.readonly(`events`).getAllFromIndex(`by-timestamp`,n(t,r)),getEventsByMetricDates:async t=>{let n=e.readonly(`events`),r=new Map;for(let e of t)for(let t of await n.getAllFromIndex(`by-metric-date`,e))r.set(t.id,t);return Array.from(r.values())},getEventsByResult:async t=>e.readonly(`events`).getAllFromIndex(`by-result-grain`,r(t)),getEventsForNote:async t=>(await e.readonly(`events`).getAll()).filter(e=>e.noteId===t),getEventsByContent:async t=>e.readonly(`events`).getAllFromIndex(`by-content-grain`,r(t)),scanAll:()=>e.readonly(`events`).getAll(),appendEvents:async t=>{t.length>0&&await e.readwrite(`events`).putMany(t)},finalizeSummaries:async(t,n)=>{await e.transaction([`events`],`readwrite`,async e=>{let r=(await e.readonly(`events`).getAll()).filter(e=>e.resultId===t&&e.grain===`summary`&&e.origin!==`user`);for(let t of r)await e.readwrite(`events`).delete(t.id);n.length>0&&await e.readwrite(`events`).putMany(n)})},deleteEvents:async t=>{for(let n of t)await e.readwrite(`events`).delete(n)}},a={eventStore:t.coalesce===!1?i:Kx(i),noteStore:{getAllNotes:()=>e.readonly(`notes`).getAll(),getNotesByIds:async t=>(await e.readonly(`notes`).getMany([...t])).filter(e=>e!==void 0),getNoteIdsForTag:async t=>{let n=new Set;for(let r of await e.readonly(`tags`).getAllFromIndex(`by-label`,t))for(let t of await e.readonly(`note_tags`).getAllFromIndex(`by-tag`,r.id))n.add(t.noteId);return n},getNoteTagLabels:async t=>{let n=await e.readonly(`note_tags`).getAllFromIndex(`by-note`,t);return(await e.readonly(`tags`).getMany(n.map(e=>e.tagId))).flatMap(e=>e?[e.label]:[])},queryDomain:async t=>{if(!e.queryDomain)return;let n=await e.queryDomain({...t,plan:`notes`});return n&&n.plan===`notes`?n:void 0}},blockStore:{getAllBlocks:()=>e.readonly(`block_index`).getAll(),queryDomain:async t=>{if(!e.queryDomain)return;let n=await e.queryDomain({...t,plan:`blocks`});return n&&n.plan===`blocks`?n:void 0}},effortStore:t.effortStore??{getAllEfforts:async()=>{let t=await e.readonly(`efforts`).getAll(),n=new Map;for(let e of ef)n.set(e.slug,e);for(let e of t)n.set(e.slug,e);return[...n.values()]}},blockEffortsStore:{getAllFromIndex:(t,n)=>e.readonly(`block_efforts`).getAllFromIndex(t,n)},blockEquipmentStore:{getAllFromIndex:(t,n)=>e.readonly(`block_equipment`).getAllFromIndex(t,n)},tagsStore:{getAllFromIndex:(t,n)=>e.readonly(`tags`).getAllFromIndex(t,n),getAll:()=>e.readonly(`tags`).getAll()},noteTagsStore:{getAllFromIndex:(t,n)=>e.readonly(`note_tags`).getAllFromIndex(t,n)},pageStore:{getNotePages:t=>e.readonly(`page_notes`).getAllFromIndex(`by-note`,t),getPage:t=>e.readonly(`page`).get(t),getAllPages:()=>e.readonly(`page`).getAll(),getAllLinks:()=>e.readonly(`page_notes`).getAll()},relationStore:{getBatches:async t=>{let n=new Map,r=[...new Set(t)];return r.length===0?n:e.transaction([`page_notes`,`note_tags`,`tags`,`page`],`readonly`,async e=>{let[t,i]=await Promise.all([e.readonly(`page_notes`).getAllFromIndexMany(`by-note`,r),e.readonly(`note_tags`).getAllFromIndexMany(`by-note`,r)]),a=new Set,o=new Set;for(let e of i)for(let t of e)a.add(t.tagId);for(let e of t)for(let t of e)o.add(t.pageId);let[s,c]=await Promise.all([e.readonly(`tags`).getMany([...a]),e.readonly(`page`).getMany([...o])]),l=new Map([...a].map((e,t)=>[e,s[t]])),u=new Map([...o].map((e,t)=>[e,c[t]]));for(let e=0;e<r.length;e++){let a=r[e],o=t[e]??[],s=i[e]??[];n.set(a,{tags:s.flatMap(e=>{let t=l.get(e.tagId);return t?[{label:t.label,...t.type?{type:t.type}:{}}]:[]}),links:o,pages:o.flatMap(e=>{let t=u.get(e.pageId);return t?[t]:[]})})}return n})}},feedCatalogStore:t.feedCatalogStore??{getAllFeeds:async()=>{let t=[];for(let n of await e.readonly(`meta`).getAll()){let e=n.key;if(typeof e!=`string`||!e.startsWith(`seed:`)||e===FS(`user`))continue;let r=e.slice(5);t.push({id:r,label:r,url:`https://${r}.example/feed/`,tier:`imported`,subscribed:!0,installed:!0,notebookCount:0,itemCount:0})}return t},getAllNotebooks:async()=>{let n=await e.readonly(`notebook_links`).getAll().catch(()=>[]),r=await e.readonly(`notes`).getAll(),i=new Map;for(let e of n)e.targetKind===`note`&&i.set(e.notebookId,(i.get(e.notebookId)??0)+1);let a=[];for(let[e,n]of i){let i=e.startsWith(`notebook/`)?e.slice(9):e,o=r.find(t=>t.id===e),s=o?.feedSourceId,c=`notebook.${i}`,l=s??`local`,u=s!==void 0;if(t.isNotebookSubscribed){let e=t.isNotebookSubscribed(l,c);u=typeof e==`boolean`?e:!!await e}a.push({id:e,feedId:l,feedLabel:s??`Yours (Local)`,chunkId:c,slug:i,label:o?.title??i,count:n,subscribed:u,installed:!0,origin:s?`feed`:`user`,...o?.public===void 0?{}:{public:o.public}})}return a}}};return Object.assign(a,{scheduleStore:{getAll:async()=>e.readonly(`schedule_items`).getAll().catch(()=>[]),getForNote:async t=>e.readonly(`schedule_items`).getAllFromIndex(`by-note`,t).catch(()=>[]),getByDateRange:async(t,n)=>{try{return(await e.readonly(`schedule_items`).getAll()).filter(e=>e.date>=t&&e.date<=n)}catch{return[]}}},sessionStore:{getAll:async()=>(await e.readonly(`sessions`).getAll()).map(e=>({id:e.id,noteId:e.noteId,startedAt:e.startTime,...e.completed?{completedAt:e.endTime}:{},...typeof e.duration==`number`?{duration:e.duration}:{},createdAt:e.createdAt,...e.notebookIds?{notebookIds:e.notebookIds}:{},...e.blockContentId?{blockContentId:e.blockContentId}:{},...e.completed===void 0?{}:{completed:e.completed},...e.sessionDate?{sessionDate:e.sessionDate}:{},...e.scheduleItemId?{scheduleItemId:e.scheduleItemId}:{}}))}}),t.datasetStore&&(a.datasetStore=t.datasetStore),t.isNotebookSubscribed&&(a.isNotebookSubscribed=(e,n)=>{let r=t.isNotebookSubscribed(e,n);return typeof r!=`boolean`||r}),a}async function nae(e,t){let n=new Map,[r,i]=await Promise.all([t.notebookSlug?e.readonly(`notes`).getAll():Promise.resolve([]),t.noteId?e.readonly(`notes`).get(t.noteId):Promise.resolve(void 0)]);if(t.resultId){let r=(await e.readonly(`events`).getAll()).filter(e=>e.resultId===t.resultId);n.set(`@session`,{events:r,notes:i?[i]:[]})}if(t.blockContentId){let r=(await e.readonly(`events`).getAll()).filter(e=>e.blockContentId===t.blockContentId);n.set(`@block`,{events:r,notes:i?[i]:[]})}if(t.noteId){let r=(await e.readonly(`events`).getAll()).filter(e=>e.noteId===t.noteId);n.set(`@note`,{events:r,notes:i?[i]:[]})}if(t.notebookSlug){let i=t.notebookSlug.replace(/^notebook\//,``),a=`notebook/${i}`,o=r.filter(e=>e.notebookId===a||e.notebookIds?.some(e=>e===a||e===i)||e.tags?.some(e=>e===`notebook:${i}`||e===a)?!0:i===`journal`&&!e.feedOrigin&&!e.feedSourceId&&!e.sourcePath?.startsWith(`markdown/`)&&e.type!==`dashboard`&&e.type!==`playground`?!e.notebookId:i===`playground`&&(e.sourceId===`playground`||e.type===`playground`)?!0:e.sourceId?.startsWith(`notebook:${i}`)??!1),s=new Set(o.map(e=>e.id)),c=(await e.readonly(`events`).getAll()).filter(e=>s.has(e.noteId));n.set(`@notebook`,{events:c,notes:o})}return n}var PC=`https://wod.wiki`,rae=`wod-feed-qr`;function iae(e=PC){return aae.replace(`__APP_ORIGIN__`,e)}var aae=`(function () {
|
|
@@ -807,7 +807,7 @@ ${t??`A WOD Wiki workout feed compiled from authored Markdown notes and optional
|
|
|
807
807
|
`));e?o?r[o]?console.warn(`[canvas] duplicate named \`\`\`scroll:${o} block ignored`):r[o]=e:n===null?n=e:console.warn("[canvas] duplicate unnamed ```scroll block ignored"):console.warn("[canvas] ```scroll block ignored: missing or malformed stages"),s=[],o=null};for(let e of t){if(a){/^```\s*$/.test(e)?(c(),a=!1):s.push(e);continue}let t=e.match(/^```scroll(?::([\w-]+))?\s*$/);if(t){a=!0,o=t[1]??null;continue}i.push(e)}return a&&c(),{scroll:n,namedScrolls:r,body:i.join(`
|
|
808
808
|
`)}}function gq(e){if(!e)return[];let t=[{token:`{{hero-carousel}}`,widget:`hero-carousel`}],n=[{kind:`prose`,text:e}];for(let{token:e,widget:r}of t){let t=[];for(let i of n){if(i.kind!==`prose`){t.push(i);continue}let n=i.text.split(e);for(let e=0;e<n.length;e++)e>0&&t.push({kind:`widget`,widget:r}),t.push({kind:`prose`,text:n[e]})}n=t}let r=/\{\{challenge:([^}]+)\}\}/g,i=[];for(let e of n){if(e.kind!==`prose`){i.push(e);continue}let t=e.text,n=0,a;for(r.lastIndex=0;(a=r.exec(t))!==null;)i.push({kind:`prose`,text:t.slice(n,a.index)}),i.push({kind:`challenge`,id:a[1].trim()}),n=a.index+a[0].length;i.push({kind:`prose`,text:t.slice(n)})}return n=i,n.filter(e=>e.kind!==`prose`||e.text!==``)}function _q(e){let t=/^```(\w+)\n([\s\S]*?)^```[ \t]*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,type:r[1],content:r[2]});let i,a=[],o=[],s=[],c=[];for(let e=0;e<n.length;e++){let{type:t,content:r}=n[e];if(t===`view`)i=nq(r),c.push(null);else if(t===`command`)a.push(rq(r)),c.push(null);else if(t===`button`){let e=iq(r);o.push(e),c.push(e)}else t===`example`&&s.push(aq(r)),c.push(null)}let l=new Set([`view`,`command`,`example`]),u=[],d=0;for(let t=0;t<n.length;t++){let r=n[t],i=c[t];i?(u.push(...gq(e.slice(d,r.start))),u.push({kind:`button`,button:i}),d=r.end):l.has(r.type)&&(u.push(...gq(e.slice(d,r.start))),d=r.end)}return u.push(...gq(e.slice(d))),{proseChunks:u,view:i,commands:a,buttons:o,examples:s}}function vq(e,t=`/`){let{meta:n,body:r}=sc(e);if(String(n.template??``)!==`canvas`)return null;let{quests:i,body:a}=sq(r),{scroll:o,namedScrolls:s,body:c}=hq(a),{chapters:l}=uq(c),u=String(n.route??t),d=[],f=null,p=e=>{let{proseChunks:t,view:n,commands:r,buttons:i,examples:a}=_q(e.lines.join(`
|
|
809
809
|
`)),o=e.attrs.find(e=>e.startsWith(`#`))?.slice(1),s=e.attrs.filter(e=>!e.startsWith(`#`)),c=e=>s.includes(e),l=e=>s.find(t=>t.startsWith(`${e}:`))?.slice(e.length+1);d.push({id:o||QK(e.heading)||`section-${d.length}`,heading:e.heading,level:e.level,attrs:s,theme:l(`theme`)??`slate`,density:l(`density`)??`default`,isDark:c(`dark`),isFullBleed:c(`full-bleed`),isSticky:c(`sticky`),prose:XK({proseChunks:t}),proseChunks:t,view:n,commands:r,buttons:i,examples:a})},m=!1;for(let e of c.split(`
|
|
810
|
-
`)){/^`{3,}/.test(e)&&(m=!m);let t=m?null:$K(e);t?(f&&p(f),f={heading:t.text,level:t.level,attrs:t.attrs,lines:[]}):f&&f.lines.push(e)}return f&&p(f),{template:`canvas`,route:u,type:n.type?String(n.type):void 0,sections:d,frontmatter:n,quests:i,chapters:l,scroll:o,namedScrolls:s}}function yq(e){if(!e)return`/`;let t=e.trim();return t.startsWith(`/`)||(t=`/`+t),t=t.replace(/\/+/g,`/`),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function bq(e,t){let n=yq(t);for(let t of e)if(t.route===n)return t.page;return null}function xq(e){return[yq(e)]}function Sq(e,t){for(let n of xq(t)){let t=bq(e,n);if(t!==null)return t}return null}function Cq(e){let t=[];for(let[n,r]of Object.entries(e))if(n.match(/^markdown\/canvas\/(.+\.md)$/)){let e=vq(r);e&&e.route!==Z.home&&t.push({route:e.route,page:e})}return t}function wq(e,t){return Sq(e,t)}function Tq(){let e=$P();return(0,K.useMemo)(()=>e?Cq(e):[],[e])}function Eq(e){let t=Tq();return(0,K.useMemo)(()=>wq(t,e),[t,e])}function Dq({className:e,...t}){return(0,q.jsx)(`nav`,{...t,className:na(e,`flex flex-1 items-center gap-2 sm:gap-4 py-2.5 min-w-0`)})}var Oq=(0,K.forwardRef)(function({current:e,className:t,children:n,...r},i){let a=na(`group relative flex min-w-0 min-h-11 min-w-11 items-center justify-center gap-3 rounded-lg p-2 text-left text-base/6 font-medium text-foreground sm:text-sm/5 sm:justify-start`,`[&>[data-slot=icon]]:size-6 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:fill-muted-foreground sm:[&>[data-slot=icon]]:size-5`,`[&>*:not(:nth-child(2)):last-child[data-slot=icon]]:ml-auto [&>*:not(:nth-child(2)):last-child[data-slot=icon]]:size-5 sm:[&>*:not(:nth-child(2)):last-child[data-slot=icon]]:size-4`,`[&>[data-slot=avatar]]:-m-0.5 [&>[data-slot=avatar]]:size-7 [&>[data-slot=avatar]]:[--avatar-radius:theme(borderRadius.md)] sm:[&>[data-slot=avatar]]:size-6`,`hover:bg-muted/50 hover:[&>[data-slot=icon]]:fill-foreground`,`active:bg-muted/50 active:[&>[data-slot=icon]]:fill-foreground`,`dark:hover:bg-white/5 dark:hover:[&>[data-slot=icon]]:fill-foreground`,`dark:active:bg-white/5 dark:active:[&>[data-slot=icon]]:fill-foreground`),o=r,s=r;return(0,q.jsxs)(`span`,{className:na(t,`relative`),children:[e&&(0,q.jsx)(_e.span,{layoutId:`current-indicator`,className:`absolute inset-x-2 -bottom-2.5 h-0.5 rounded-full bg-foreground`}),typeof r.href==`string`?(0,q.jsx)(WH,{...o,className:a,"data-current":e?`true`:void 0,"aria-current":e?`page`:void 0,ref:i,children:n}):(0,q.jsx)(`button`,{type:`button`,...s,className:na(`cursor-default`,a),"data-current":e?`true`:void 0,"aria-current":e?`page`:void 0,ref:i,children:n})]})});function kq({size:e=32,className:t,...n}){let r=!n[`aria-label`]&&!n[`aria-labelledby`];return(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,width:e,height:e,"aria-hidden":r?!0:void 0,role:r?void 0:`img`,className:t,...n,children:[(0,q.jsx)(`rect`,{x:`0`,y:`0`,width:`32`,height:`32`,rx:`8`,fill:`#49698d`}),(0,q.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`31`,height:`31`,rx:`7.5`,fill:`none`,stroke:`#fcfbf8`,strokeOpacity:`0.16`,strokeWidth:`1`}),(0,q.jsxs)(`g`,{transform:`translate(3.2 3.2) scale(0.8)`,children:[(0,q.jsx)(`path`,{d:`M10.5 6.5H7a1.5 1.5 0 0 0-1.5 1.5v16A1.5 1.5 0 0 0 7 25.5h3.5`,fill:`none`,stroke:`#fcfbf8`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`path`,{d:`M21.5 6.5H25a1.5 1.5 0 0 1 1.5 1.5v16a1.5 1.5 0 0 1-1.5 1.5h-3.5`,fill:`none`,stroke:`#fcfbf8`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`path`,{d:`M12.5 10.6a1.1 1.1 0 0 1 1.66-.95l7.9 4.86a1.15 1.15 0 0 1 0 1.98l-7.9 4.86a1.1 1.1 0 0 1-1.66-.95V10.6Z`,fill:`#d6e4f0`})]})]})}var Aq=class{async getAllEfforts(){let e=NP();return e.isInitialized()||await kP(e),[...e.list()]}},jq=NC(oF,{coalesce:!0,effortStore:new Aq});jq.eventStore,jq.noteStore,jq.blockStore;var Mq=new Jy,Nq={events:[],notes:[]},Pq={events:[],notes:[]};Mq.set(`@session`,Nq),Mq.set(`@today`,Pq);function Fq(){let{runtime:e,activeNoteId:t}=zz.getState(),n=e?.getOutputStatements()??[];if(Nq.notes=[],n.length===0)return Nq.events=[],Nq;let r=t??``;return Nq.events=ob(n.map(Gh),{noteId:r,resultId:`live:${r||`session`}`,origin:`playground`}),Nq}function Iq(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 by(e.date??e.createdAt,r)}async function Lq(e,t){let n=by(e.instant,e.timeZone),r=Dy(n,e.timeZone),i=Dy(xy(n,1),e.timeZone),[a,o,s,c,l]=await Promise.all([X.getEventsByTimeRange(r,i),X.getAllNotes(),X.getAllPageNotes(),X.getAllPages(),oF.readonly(`schedule_items`).getAllFromIndex(`by-date`,n).catch(()=>[])]),u=a.filter(e=>e.timestamp>=r&&e.timestamp<i),d=new Map(c.map(e=>[e.id,e])),f=new Set(l.map(e=>e.noteId)),p=new Map;for(let e of s){let t=p.get(e.noteId);t?t.push(e):p.set(e.noteId,[e])}let m=[];for(let t of o)(f.has(t.id)||Iq(t,p.get(t.id)??[],d,e.timeZone)===n)&&m.push(t);t===Bq&&(Pq.events=u,Pq.notes=m,Fq())}var Rq=null,zq=null,Bq=0,Vq=!1,Hq=new Set;function Uq(){for(let e of Hq)e()}function Wq(e,t){zq=t;let n=++Bq;return Rq=Lq(e,n),Rq.then(()=>{n===Bq&&Gq()},()=>{n===Bq&&Gq()}),Rq}function Gq(){Vq=!0,Uq()}function Kq(){let e=my(),t=by(e.instant,e.timeZone);return!Rq||zq!==t?Wq(e,t):Rq}function qq(){Vq=!1;let e=my();return Wq(e,by(e.instant,e.timeZone))}function Jq(){return Vq}function Yq(e){return Hq.add(e),()=>{Hq.delete(e)}}async function Xq(){await Promise.all([fR(),TR()])}function Zq(e){if(typeof e==`string`)return/@(?:today|session)\b/i.test(e);if(`source`in e&&e.source?.kind===`dataset`){let t=e.source.name.toLowerCase();return t===`@today`||t===`@session`}return`raw`in e&&typeof e.raw==`string`&&/@(?:today|session)\b/i.test(e.raw)}var Qq=class extends cx{async runQuery(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.runQuery(e,t)}async runPipeline(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.runPipeline(e,t)}async runFind(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.runFind(e,t)}async runRows(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.runRows(e,t)}async run(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.run(e,t)}},$q=null,eJ=0;async function tJ(e){let t=++eJ,n=await nae(oF,e);return t===eJ&&($q=n),n}function nJ(){eJ+=1,$q=null}function rJ(){return new Qq(NC(oF,{coalesce:!0,effortStore:new Aq,feedCatalogStore:HL,datasetStore:{getDataset:e=>e===`@session`?Fq()??$q?.get(`@session`):$q?.get(e)??Mq.getDataset(e)},isNotebookSubscribed:(e,t)=>WI(e,t)}))}var iJ=rJ();function aJ(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,sourceNotebook:`results`,sourceNote:i??r??`${t}:${n}`,title:a?rG(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function oJ(e){let t=e.parsed.family===`aggregate`?e.parsed.metric:`metric`;return e.series.map(e=>{let n=e.points.map(t=>`${t.value}${e.unit?` ${e.unit}`:``}`).join(` • `);return{id:`aggregate:${t}:${e.key}`,kind:`result`,sourceNotebook:`results`,sourceNote:e.label,title:`${t}: ${n}`,subtitle:e.label,date:null}})}function sJ(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function cJ(e){return typeof e==`object`&&!!e&&`runFind`in e}var lJ=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){cJ(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver),this.noteTitleResolver||=async e=>{try{let t=await X.getNote(e);return t?RT(t.title)||zT(t.rawContent??``):void 0}catch{return}}}get service(){return this.customService??iJ}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,n,r){if(t&&r)for(let t of e){let e=r[t.id];e&&e.length>0&&((!t.tags||t.tags.length===0)&&(t.tags=e.map(e=>e.label)),t.typedTags=e.map(e=>({label:e.label,type:e.type})))}let i=new Set;for(let r of e){if(r.kind===`feed`||r.kind===`notebook`||r.isRemotePreview)continue;let e=!!(n&&Object.prototype.hasOwnProperty.call(n,r.id));!e&&(r.kind===`note`||r.sourceNotebook===`journal`)&&i.add(r.id),t&&!e&&(!r.title||!r.tags||r.tags.length===0)&&i.add(r.id)}if(i.size===0)return;let a=await X.getDetailBatches([...i]);for(let t of e){if(t.kind===`feed`||t.kind===`notebook`||t.isRemotePreview)continue;let e=a.get(t.id),r=n?.[t.id];if(!e&&!r)continue;let i=r??Ss(e?.links??[],e?.pages??[]);t.placements=i;let o=Cs(i);t.pageId??=o.pageId,o.pageSlug&&(t.pageSlug=o.pageSlug)}if(t)for(let t of e){let e=a.get(t.id);!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,n){let r=typeof e==`string`?t_(e):e;if(!r||r.error)return[];if(Bg(r)){if(r.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(r):await this.service.runFind(r),n=new Map(e.notes.map(e=>[e.id,e])),i=(e.efforts??[]).map(e=>e.ownerNoteId&&n.has(e.ownerNoteId)?XW(n.get(e.ownerNoteId)):oG(e));return sJ(t,e.stages,i),i}if(r.target===`block`){let e=await this.service.runFind(r),n=e.blocks.map(nG);return await this.hydrateEntries(n,!0),sJ(t,e.stages,n),n}if(r.target===`session`){let e=await this.service.runFind(r);t?.(e.stages);let n;if(this.noteTitleResolver&&e.runs){n=new Map;for(let t of e.runs)if(!n.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&n.set(t.noteId,e)}}let i=vG(e,{noteTitles:n});return sJ(t,e.stages,i),i}if(r.target===`segment`||r.target===`event`){let e=r.target,n=await this.service.runFind(r),i=(n.table?.rows??[]).map((t,n)=>aJ(t,e,n));return sJ(t,n.stages,i),i}let e=await this.service.runFind(r,n?.notebookPlane?{notebookPlane:n.notebookPlane}:void 0),i=e.notes.map(XW);if(this.noteTagsResolver?(await this.hydrateEntries(i,!1,e.placements,e.typedTags),await Promise.all(i.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(i,!0,e.placements,e.typedTags),sJ(t,e.stages,i),this.noteBlockInfo)for(let t=0;t<i.length;t++){let n=i[t],r=e.notes[t];n.excerpt=tG(r.rawContent);try{Js(r.rawContent,r.blocks,r.sourceRevision)}catch{continue}let a=Object.values(r.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&Gs(r.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=ys(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return i}if(r.family===`aggregate`){if(!this.service.runQuery)return[];let e=await this.service.runQuery(r.raw),n=oJ(e);return t?.({selected:e.stages?.selected??n.length,matched:n.length}),n}return[]}};async function uJ(e,t=lJ,n){return t.query(e,n)}function dJ(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function fJ(e){try{let t=(await uJ(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 pJ(e){let t=dJ(e),n=(0,K.useRef)(e);n.current=e;let[r,i]=(0,K.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,K.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`?fJ(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),!e||!e.some(e=>e.kind===`wql`)?e??[]:r}function mJ(){let[e]=V(`h`,{shallow:!0}),[t]=V(`s`,{shallow:!0}),{navState:n}=MV(),r=n.activeL3Id??``;return e||t||r||``}function hJ({entry:e,active:t,onActivate:n,onRunAction:r,onFilter:i}){let a=e.onRun,o=e.filterTo,s=e.filterLabel??`Filter notes by ${e.label}`,c=e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,l=(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:$(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1.5 max-lg:min-h-11 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,!a&&!o&&`w-full`,e.muted?`text-xs`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[e.icon&&(0,q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4 shrink-0`}),e.timestamp&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums text-muted-foreground`,children:e.timestamp}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,q.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 py-0.5 font-mono text-xs uppercase tracking-wide text-muted-foreground`,children:e.badge})]});return!a&&!o?l:(0,q.jsxs)(`div`,{className:`group flex w-full items-center gap-0.5`,children:[l,o&&(0,q.jsx)(`button`,{type:`button`,"aria-label":s,title:s,"data-testid":`menu-filter-${e.id}`,onClick:()=>i(o),className:`flex size-7 max-lg:min-h-11 max-lg:min-w-11 shrink-0 items-center justify-center rounded-md text-foreground/75 transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,children:(0,q.jsx)(p,{"aria-hidden":`true`,className:`size-3.5`})}),a&&(0,q.jsx)(`button`,{type:`button`,"aria-label":c,title:c,onClick:()=>r(e),className:`flex size-7 max-lg:min-h-11 max-lg:min-w-11 shrink-0 items-center justify-center rounded text-primary opacity-70 lg:opacity-0 transition-all group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 hover:bg-primary/10 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,children:e.runIcon===`link`?(0,q.jsx)(Vn,{"aria-hidden":`true`,className:`size-3.5`}):e.runIcon===`stop`?(0,q.jsx)(ue,{"aria-hidden":`true`,className:`size-3.5`}):e.runIcon===`edit`?(0,q.jsx)(ke,{"aria-hidden":`true`,className:`size-3.5`}):(0,q.jsx)(re,{"aria-hidden":`true`,className:`size-3.5`})})]})}function gJ({entries:e,activeId:t,onSection:n,onSelect:r}){let i=dt(),{scrollToSection:a}=MV(),o=qH(),s=e=>{if(o(),n)return n(e);if(e.onSelect)return e.onSelect();if(r)return r(e);if(e.onRun)return e.onRun();if(e.to)return i(e.to);if(e.sectionId)return a(e.sectionId)},c=e=>{o(),e.onRun?.()},l=e=>{o(),i(e)};return(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,q.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,q.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,q.jsx)(gJ,{entries:e.entries,activeId:t,onSection:n,onSelect:r})]},e.id):e.kind===`wql`?null:e.kind===`widget`?(0,q.jsx)(`div`,{className:`px-1 py-1`,children:e.render()},e.id):(0,q.jsx)(hJ,{entry:e,active:t!=null&&e.sectionId===t,onActivate:s,onRunAction:c,onFilter:l},e.id))})}function _J(){let e=dt(),{scrollToSection:t}=MV();return{navigate:(t,n)=>{e(t,{replace:n?.replace})},setQueryParam:(e,t)=>{},scrollToSection:t}}function vJ(){let e=_J(),t=qH();return n=>{t(),DG(n.action,e)}}function yJ(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 bJ({items:e}){let{navState:t}=MV(),n=Qe(),r=vJ();return(0,q.jsx)(ZH,{children:e.map(e=>{let i=yJ(e,t,n);return e.children&&e.children.length>0?(0,q.jsx)(MG,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>yJ(e,t,n)),collapsible:e.id!==`syntax-group`,buttonClassName:`text-xs font-bold tracking-[0.14em] text-muted-foreground`,children:e.children.map(e=>{let i=yJ(e,t,n);return(0,q.jsxs)($H,{onClick:()=>r(e),current:i,children:[e.icon&&(0,q.jsx)(e.icon,{"data-slot":`icon`}),(0,q.jsx)(eU,{children:e.label})]},e.id)})},e.id):(0,q.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,q.jsxs)($H,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:$(`flex-1`,e.disabled&&`opacity-60`),children:[e.icon&&(0,q.jsx)(e.icon,{"data-slot":`icon`}),(0,q.jsx)(eU,{children:e.disabled?`+`:e.label})]}),e.onTogglePin&&(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onTogglePin?.()},title:e.pinned?`Unpin from sidebar`:`Pin to sidebar`,"aria-label":e.pinned?`Unpin ${e.label}`:`Pin ${e.label}`,className:`opacity-0 group-hover:opacity-100 focus-visible:opacity-100 p-1 max-lg:min-h-11 max-lg:min-w-11 flex items-center justify-center text-muted-foreground hover:text-foreground transition-opacity`,children:(0,q.jsx)(cee,{className:`size-3.5`})})]},e.id)})})}function xJ({navSpec:e}){let{tree:t,navState:n,dispatch:r}=MV(),i=pJ(e),a=(t??[]).find(e=>e?.id===n.activeL1Id)??null;return(0,q.jsxs)(JH,{"aria-label":a?`${a.label} places`:`Workspace`,children:[(0,q.jsx)(YH,{children:(0,q.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:a?.label??`Wod Wiki`})}),(0,q.jsxs)(XH,{children:[(()=>{if(!a)return null;if(a.panel){let e=a.panel;return(0,q.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,q.jsx)(e,{item:a,navState:n,dispatch:r})})}return a.children&&a.children.length>0?(0,q.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,q.jsx)(bJ,{items:a.children})}):null})(),i.length>0&&(0,q.jsx)(`div`,{className:`pt-1`,children:(0,q.jsx)(gJ,{entries:i})})]})]})}var SJ=`0.62.2260`,CJ={version:SJ,gitSha:`d3581b3384c3`,builtAt:`2026-11-23T01:03:49.761Z`},wJ=`https://github.com/bitcobblers/wod-wiki/releases`;function TJ(e){return/-pr\.\d+$/.test(e)?wJ:`${wJ}/tag/v${e}`}function EJ({onSearch:e,onCreate:t,variant:n=`rail`}){let{tree:r,navState:i,dispatch:a}=MV(),o=dt(),s=Qe(),c=qH(),l={navigate:(e,t)=>{o(e,{replace:t?.replace})},setQueryParam:()=>{},scrollToSection:()=>{}},u=n===`mobile-list`,d=(r??[]).find(e=>e?.id===`home`),f=d?yJ(d,i,s):s.pathname===`/`||s.pathname===``,p=(r??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`home`&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),m=s.pathname.startsWith(`/settings/profile`),h=s.pathname.startsWith(`/settings`),g=`pointer-events-none absolute left-full top-1/2 -translate-y-1/2 z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,_=e=>$(`flex w-full min-h-11 items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] transition-colors`,e?`bg-primary/10 font-semibold text-primary`:`font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground`);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),a({type:`SET_ACTIVE_L1`,id:`home`}),o(`/`)},title:`Wod Wiki home`,"aria-label":`Wod Wiki home`,"aria-current":f?`page`:void 0,"data-testid":Q.NAV_L1_HOME,className:u?$(_(f),`mb-1.5 shrink-0`):$(`group relative mb-3 grid size-9 shrink-0 place-items-center rounded-lg transition-colors`,f?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&f&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(kq,{size:u?24:32,className:$(`shrink-0 shadow-sm shadow-black/15`,u?`size-6 rounded-[6px]`:`size-8 rounded-[8px]`)}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Home`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Wod Wiki home`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Wod Wiki home`})]})]}),(0,q.jsx)(`nav`,{"aria-label":`Primary`,className:u?`flex w-full flex-col gap-0.5`:`flex w-full flex-col items-center gap-1.5`,children:p.map(e=>{let t=e.icon,n=yJ(e,i,s);return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=!!(e.panel||e.children&&e.children.length>0);(!u||!t||n)&&c(),a({type:`SET_ACTIVE_L1`,id:e.id}),DG(e.action,l)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,"data-testid":`nav-l1-${e.id}`,className:u?_(n):$(`group 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:[!u&&n&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(t,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:e.label}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:e.label})]})]},e.id)})}),(0,q.jsx)(`div`,{className:`flex-1 min-h-2`}),(0,q.jsxs)(`button`,{type:`button`,onClick:e,title:`Search (⌘/)`,"aria-label":`Search`,"data-testid":Q.NAV_L1_SEARCH,className:u?_(!1):`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,q.jsx)(gi,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Search`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Search`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Search (⌘/)`})]})]}),(0,q.jsxs)(`a`,{href:zK,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:u?_(!1):`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,q.jsx)(BK,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Buy Me a Coffee`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Buy Me a Coffee`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Buy Me a Coffee`})]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),o(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":m?`page`:void 0,"data-testid":`nav-profile`,className:u?$(_(m),`mt-0.5`):$(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,m?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&m&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(Zt,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Profile`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Profile`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Profile`})]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),o(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":h?`page`:void 0,"data-testid":`nav-settings`,className:u?$(_(h),`mt-0.5`):$(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,h?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&h&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(si,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Settings`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Settings`}),(0,q.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 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`Settings (v`,SJ,`)`]})]})]})]})}function DJ({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,q.jsx)(`nav`,{className:$(`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,q.jsx)(`button`,{onClick:()=>DG(e.action,r),className:$(`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 OJ=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=pf){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},kJ=20,AJ=e=>{let[t,n]=(0,K.useState)(`idle`),[r,i]=(0,K.useState)(0),[a,o]=(0,K.useState)(0),[s,c]=(0,K.useState)(null),l=(0,K.useRef)(null),u=(0,K.useRef)(`idle`),d=(0,K.useRef)(0),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useCallback)(()=>e?.nowProvider?.nowMs()??pf.nowMs(),[e]),h=(0,K.useCallback)(()=>e?.nowProvider?.now()??pf.now(),[e]),g=(0,K.useCallback)(()=>u.current===`running`&&f.current!==null?d.current+Math.max(0,m()-f.current):d.current,[m]),_=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null);let e=g();d.current=e,f.current=null,u.current=`idle`,i(e),n(`idle`)},[g]),v=(0,K.useCallback)(()=>{if(e)try{let t=new OJ(void 0,e.nowProvider);e.handle(t),o(e=>e+1)}catch{_(),u.current=`error`,n(`error`)}},[e,_]);(0,K.useEffect)(()=>{if(e)return e.subscribeToStack(e=>{if(e.blocks.length===0&&u.current!==`completed`){l.current&&=(clearInterval(l.current),null);let e=g();d.current=e,f.current=null,u.current=`completed`,i(e),n(`completed`)}})},[e,g]),(0,K.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]);let y=(0,K.useCallback)(()=>{if(!e){console.warn(`useRuntimeExecution: Cannot start execution without a runtime`);return}if(u.current===`running`){console.warn(`useRuntimeExecution: Runtime is already running`);return}u.current===`paused`&&e.handle({name:`timer:resume`,timestamp:h(),data:{}});let t=m();f.current=t,p.current||(p.current=!0,c(t)),u.current=`running`,n(`running`),l.current=setInterval(v,kJ)},[e,h,m,v]),b=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null);let t=g();d.current=t,f.current=null,i(t),e&&e.handle({name:`timer:pause`,timestamp:h(),data:{}}),u.current=`paused`,n(`paused`)},[e,g,h]),x=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),d.current=0,f.current=null,p.current=!1,u.current=`idle`,i(0),o(0),n(`idle`),c(null)},[]),S=(0,K.useCallback)(()=>{!e||u.current===`running`||(u.current=`paused`,n(`paused`),v())},[e,v]);return(0,K.useEffect)(()=>{if(t!==`running`)return;let e=setInterval(()=>{i(g())},100);return()=>clearInterval(e)},[t,g]),(0,K.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]),(0,K.useEffect)(()=>{x()},[e,x]),(0,K.useMemo)(()=>({status:t,elapsedTime:r,getElapsedTime:g,stepCount:a,startTime:s,start:y,pause:b,stop:_,reset:x,step:S}),[t,r,g,a,s,y,b,_,x,S])};function jJ(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,K.useState)(r);return(0,K.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 MJ(e){return jJ(e,`round`)}function NJ(e){return jJ(e,`display`)}function PJ(e){let t=MJ(e),n=NJ(e);return(0,K.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 FJ=(0,K.createContext)(void 0),IJ=({runtime:e,children:t})=>(0,q.jsx)(FJ.Provider,{value:e,children:t});function LJ(){let e=(0,K.useContext)(FJ);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function RJ(){return(0,K.useContext)(FJ)??null}function zJ(e){let t=LJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(()=>n?.getOutputStatements?.()??[]);return(0,K.useEffect)(()=>{if(!n){i([]);return}return i(n.getOutputStatements()),n.subscribeToOutput?.(()=>{i(n.getOutputStatements())})},[n]),(0,K.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 BJ(){let e=LJ(),[t,n]=(0,K.useState)({type:`initial`,blocks:e.stack.blocks,depth:e.stack.count,clockTime:e.clock.currentDate});return(0,K.useEffect)(()=>e.subscribeToStack(e=>{n(e)}),[e]),t}function VJ(){return BJ().blocks}function HJ(){let e=VJ(),[t,n]=(0,K.useState)(0);return(0,K.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,K.useMemo)(()=>{for(let t of e){let e=t.getMemoryByTag(`metric:next`);if(e.length===0)continue;let n=ds.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 UJ(){let e=VJ(),[t,n]=(0,K.useState)(0);return(0,K.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,K.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 WJ(){let e=VJ(),[t,n]=(0,K.useState)(0);return(0,K.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,K.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 GJ(e){let t=LJ(),n=(0,K.useMemo)(()=>t.stack.blocks.find(t=>t.key.toString()===e),[t,e]),[r,i]=(0,K.useState)(()=>n?.getMemoryByTag(`time`)[0]?.metrics[0]?.value);(0,K.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,K.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,K.useMemo)(()=>r?.spans??[],[r]),o=a.length>0&&a[a.length-1].ended===void 0,[s,c]=(0,K.useState)(tp()),l=(0,K.useMemo)(()=>a.length===0?0:Ih(a,s),[a,s]);return(0,K.useEffect)(()=>{if(!o)return;let e,t=()=>{c(tp()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}function KJ(e={}){let t=RJ(),n=e.runtime===void 0?t:e.runtime,r=e.active??!0,[i,a]=(0,K.useState)({revision:0,skipFlash:!1,skipFlashKey:0});(0,K.useEffect)(()=>{if(!(!n||!r))return Rh(n,({skipFlash:e,skipFlashKey:t})=>{a(n=>({revision:n.revision+1,skipFlash:e,skipFlashKey:t}))})},[n,r]);let[o,s]=(0,K.useState)(()=>tp()),c=(0,K.useMemo)(()=>(i.revision,zh(n,{nowMs:o,executionStatus:e.executionStatus,canNextOverride:e.canNextOverride,skipFlash:i.skipFlash,skipFlashKey:i.skipFlashKey})),[n,i.revision,i.skipFlash,i.skipFlashKey,o,e.executionStatus,e.canNextOverride]);return(0,K.useEffect)(()=>{if(!r||!c.isRunning||c.isPaused||typeof requestAnimationFrame!=`function`)return;let e=0,t=!0,n=()=>{t&&(s(tp()),e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>{t=!1,cancelAnimationFrame(e)}},[r,c.isRunning,c.isPaused]),c}function qJ(e){let t=RJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(0);return(0,K.useEffect)(()=>{if(!n){i(0);return}return n.subscribeToOutput?.(()=>{i(e=>e+1)})},[n]),(0,K.useMemo)(()=>Bh(n),[n,r])}function JJ(e){let t=RJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(0);return(0,K.useEffect)(()=>{if(!n)return;let e=n.subscribeToStack(()=>i(e=>e+1)),t=n.subscribeToOutput?.(()=>i(e=>e+1));return()=>{e(),t?.()}},[n]),(0,K.useMemo)(()=>nie(n),[n,r])}var YJ=(0,K.createContext)(void 0),XJ=(0,K.createContext)(null),ZJ=({factory:e,children:t})=>{let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),u=(0,K.useRef)(e);u.current=e;let d=(0,K.useRef)(null),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),zz.getState().setSubscriptionManager(null),zz.getState().setRuntime(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,K.useCallback)((e,t)=>{if(!p.current){p.current=!0,s(!0),l(null);try{f.current&&=(f.current.dispose(),null);let n=d.current;if(d.current=null,n)try{u.current.disposeRuntime(n)}catch(e){console.error(`[RuntimeProvider] Error disposing existing runtime:`,e)}let i=u.current.createRuntime(e,t);if(d.current=i,r(i),i){let e=new Hre(i);e.add(new Vre({id:`local`})),f.current=e,a(e),zz.getState().setRuntime(i),zz.getState().setSubscriptionManager(e)}else f.current=null,a(null),zz.getState().setRuntime(null),zz.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,K.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,q.jsx)(YJ.Provider,{value:g,children:(0,q.jsx)(XJ.Provider,{value:i,children:t})})};function QJ({factory:e,children:t}){return(0,q.jsx)(ZJ,{factory:e,children:t})}var $J=`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`,eY=`flex flex-col flex-1 min-w-0 min-h-screen lg:rounded-[2.5rem]`,tY=1023;function nY(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function rY(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);if(r===null)return null;let i=t[r],{meta:a,body:o}=sc(i),s=new Set([`search`,`template`,`route`,`type`,`title`,`description`,`subtitle`,`section`,`order`]);return Object.keys(a).some(e=>!s.has(e.trim().toLowerCase()))?i:o};if(e.startsWith(`markdown/`)){let t=r(e);if(t!==null)return t}let i;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(`canvas/`))i=`markdown/canvas/`+e.replace(/^canvas\//,``);else{let t=r(`markdown/canvas/`+e);if(t!==null)return t;i=`markdown/`+e}return r(i)??`# Source not found\n\nPath: \`${e}\`\nResolved: \`${i}\``}function iY(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function aY(e){let t=new Map,n=null;for(let r of e)iY(r)&&(n=r),t.set(r.id,n);return t}function oY(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${tY}px)`).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${tY}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function sY(e){return e.map(e=>{let t=e.action,n=e.secondaryAction?.action,r={kind:`link`,id:e.id,label:e.label};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})}function cY({onOpen:e}){let t=qH();return(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>{t(),e()},"data-testid":`query-settings-trigger`,className:`w-full max-lg:min-h-11 justify-start gap-2 rounded-lg text-xs`,children:[(0,q.jsx)(zi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate`,children:`Query settings`})]})}var lY=[4,8,16],uY=`sum:totalVolume{}`;function dY(e){let t=Number.parseInt(e??``,10);return lY.includes(t)?t:16}function fY(e={}){let{defaultQuery:t=uY,runOnLanding:n=!1}=e,[r,i]=be(),a=r.get(`q`)??``,o=dY(r.get(`weeks`)),s=a?!!t_(a).error:!1,[c,l]=(0,K.useState)(()=>a||t),[u,d]=(0,K.useState)(()=>s?a:null),[f,p]=(0,K.useState)(()=>a&&!s?a:n?t:``),m=(0,K.useRef)(c);m.current=c;let h=(0,K.useRef)(f);h.current=f;let g=(0,K.useRef)(r);g.current=r;let _=(0,K.useRef)(!0),v=(0,K.useRef)(a);v.current=a;let y=(0,K.useRef)(a);(0,K.useEffect)(()=>{if(a===y.current||(y.current=a,m.current===a))return;_.current=!0;let e=a?!!t_(a).error:!1;l(a||t),e?(d(a),p(e=>e||(n?t:``))):(d(null),p(a||(n?t:``)))},[a,t,n]);let b=(0,K.useRef)(t);return(0,K.useEffect)(()=>{t!==b.current&&(b.current=t,!a&&(d(null),l(t),p(n?t:``)))},[t,a,n]),{draft:c,setDraft:(0,K.useCallback)(e=>{if(e!==m.current){if(!t_(e).error){d(null);let t=new URLSearchParams(g.current);t.set(`q`,e),i(t,{replace:!_.current}),_.current=!1}l(e)}},[i]),submitted:f,invalidUrlQuery:u,revertDraft:(0,K.useCallback)(()=>{let e=h.current||t;d(null),l(e);let n=new URLSearchParams(g.current);h.current?n.set(`q`,h.current):n.delete(`q`),i(n,{replace:!0}),_.current=!0},[t,i]),submit:(0,K.useCallback)(e=>{let t=e??m.current;if(t_(t).error)return;if(d(null),_.current&&v.current===t){p(t);return}let n=new URLSearchParams(g.current);n.set(`q`,t),i(n,{replace:!0}),_.current=!0,p(t)},[i]),weeks:o,setWeeks:(0,K.useCallback)(e=>{let t=new URLSearchParams(g.current);t.set(`weeks`,String(e)),i(t,{replace:!0})},[i])}}var pY=4;function mY(e){return!e||e.length===0?!1:e.some(e=>e.kind===`wql`||e.kind!==`section`||mY(e.entries))}function hY(e,t){let n=NV();return!!(mY(e)||n?.l3Items&&n.l3Items.length>0||mY(n?.l3Connections)||n?.l3Actions&&n.l3Actions.length>0||n?.analyticsControls||t)}function gY({controls:e}){let{unit:t,setUnit:n}=yO(),r=e.showRange!==!1,i=e.showUnits!==!1,a=e.weeks!==void 0&&e.onWeeksChange!==void 0;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":Q.L3_ANALYTICS_CONTROLS,children:[e.onOpenQuerySettings&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`This page`}),(0,q.jsx)(cY,{onOpen:e.onOpenQuerySettings})]}),r&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date range`}),a?(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":Q.L3_RANGE_OPTIONS,children:lY.map(t=>{let n=e.weeks===t;return(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":n,onClick:()=>e.onWeeksChange?.(t),"data-testid":`l3-range-${t}w`,className:$(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 max-lg:min-h-11 text-xs transition-colors`,n?`bg-primary/10 font-semibold text-primary`:`text-foreground/85 hover:bg-muted/60 hover:text-foreground`),children:[(0,q.jsx)(`span`,{className:`w-3.5 text-primary`,children:n?(0,q.jsx)(Rr,{className:`size-3.5`,"aria-hidden":`true`}):null}),(0,q.jsxs)(`span`,{children:[`Past `,t,` weeks`]})]},t)})}):(0,q.jsx)(pO,{})]}),i&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[`Units`,e.unitForced?` — pinned by query`:``]}),(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,"data-testid":Q.L3_UNIT_OPTIONS,children:[`kg`,`lb`].map(r=>{let i=t===r;return(0,q.jsx)(`button`,{type:`button`,disabled:!!e.unitForced,"aria-pressed":i,onClick:()=>n(r),"data-testid":`l3-unit-${r}`,className:$(`flex min-h-8 max-lg:min-h-11 items-center justify-center rounded-md border px-2 py-1 text-xs font-medium transition-colors`,e.unitForced?`border-transparent text-muted-foreground/75 opacity-70 cursor-not-allowed`:i?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`),children:r},r)})})]})]})}function _Y({action:e,variant:t=`default`}){let n=qH(),r=e.icon;return(0,q.jsxs)(`button`,{type:`button`,disabled:e.disabled,"data-testid":e.testId,onClick:()=>{e.disabled||(n(),e.onRun())},className:$(`flex w-full items-center gap-2 rounded-lg transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,t===`primary`&&`justify-center bg-primary px-3 py-2 min-h-9 max-lg:min-h-11 text-sm font-semibold text-primary-foreground shadow-sm hover:bg-primary/90`,t==="default"&&`px-2 py-1.5 max-lg:min-h-11 text-left text-[13px] text-foreground/85 hover:bg-muted/60 hover:text-foreground`,t===`danger`&&`px-2 py-1.5 max-lg:min-h-11 text-left text-[13px] font-medium text-destructive hover:bg-destructive/10 hover:text-destructive`,e.disabled&&(t===`primary`?`cursor-not-allowed opacity-50`:t===`danger`?`cursor-not-allowed text-destructive/50 hover:bg-transparent`:`cursor-not-allowed text-muted-foreground/60 hover:bg-transparent`)),children:[r&&(0,q.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,q.jsx)(`span`,{className:$(`min-w-0 truncate`,t!==`primary`&&`flex-1`),title:e.label,children:e.label})]})}function vY({bucket:e}){let t=e.items.length+ +!!e.extraNode;return(0,q.jsxs)(`details`,{"data-testid":e.testId,className:`group rounded-lg border border-border/40 bg-muted/20`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-9 max-lg:min-h-11 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1.5 text-xs font-semibold text-foreground/85 select-none transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(ee,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 group-open:rotate-90`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,q.jsx)(`span`,{className:`shrink-0 text-xs font-medium tabular-nums text-muted-foreground`,children:t})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1 pb-1.5 pt-0.5`,children:[e.items.map(e=>(0,q.jsx)(_Y,{action:e},e.id)),e.extraNode&&(0,q.jsx)(`div`,{className:`pt-0.5`,children:e.extraNode})]})]})}function yY({actions:e,pageAction:t}){let n=(0,K.useMemo)(()=>e.filter(e=>e.group===`primary`),[e]),r=(0,K.useMemo)(()=>e.filter(e=>e.group===`author`),[e]),i=(0,K.useMemo)(()=>e.filter(e=>e.group===`organize`||e.group===void 0),[e]),a=(0,K.useMemo)(()=>e.filter(e=>e.group===`share`),[e]),o=(0,K.useMemo)(()=>e.filter(e=>e.group===`danger`),[e]),s=r.length+i.length+a.length,c=s>=pY,l=(0,K.useMemo)(()=>{let e=[];return r.length>0&&e.push({id:`author`,label:`Author`,testId:Q.L3_ACTIONS_GROUP_AUTHOR,items:r}),i.length>0&&e.push({id:`organize`,label:`Organize`,testId:Q.L3_ACTIONS_GROUP_ORGANIZE,items:i}),(a.length>0||c&&t)&&e.push({id:`share`,label:`Share & Export`,testId:Q.L3_ACTIONS_GROUP_SHARE,items:a,extraNode:c?t:void 0}),e},[r,i,a,c,t]);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n.length>0&&(0,q.jsx)(`div`,{"data-testid":Q.L3_ACTIONS_PRIMARY,className:`flex flex-col gap-1.5 pb-1`,children:n.map(e=>(0,q.jsx)(_Y,{action:e,variant:`primary`},e.id))}),c?(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:l.map(e=>(0,q.jsx)(vY,{bucket:e},e.id))}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:[...r,...i,...a].map(e=>(0,q.jsx)(_Y,{action:e},e.id))}),t&&(0,q.jsx)(`div`,{className:$(s>0&&`pt-1`),children:t})]}),o.length>0&&(0,q.jsx)(`div`,{"data-testid":Q.L3_ACTIONS_DANGER,className:`mt-1 flex flex-col gap-0.5 border-t border-destructive/25 pt-2`,children:o.map(e=>(0,q.jsx)(_Y,{action:e,variant:`danger`},e.id))})]})}function bY({spec:e,pageAction:t}){let{l3Items:n,l3Connections:r,l3Actions:i=[],analyticsControls:a}=MV(),o=pJ(e),s=pJ(r),c=(0,K.useMemo)(()=>sY(n),[n]),l=mJ(),u=!!a,d=mY(o),f=c.length>0,p=mY(s),m=d||f||p,h=i.length>0||!!t;return!u&&!m&&!h?null:(0,q.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[u&&(0,q.jsx)(`div`,{className:$(`flex flex-col gap-4`,(m||h)&&`pb-3 border-b border-border/50`),children:a&&(0,q.jsx)(gY,{controls:a})}),d&&(0,q.jsx)(gJ,{entries:o,activeId:l}),f&&(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,q.jsx)(gJ,{entries:c,activeId:l})]}),p&&(0,q.jsxs)(`div`,{"data-testid":Q.L3_CONNECTIONS,className:$(`flex flex-col gap-1`,(f||d)&&`pt-3 border-t border-border/50`),children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Connections`}),(0,q.jsx)(gJ,{entries:s,activeId:l})]}),h&&(0,q.jsxs)(`div`,{"data-testid":Q.L3_ACTIONS,className:$(`flex flex-col gap-1`,m&&`pt-3 border-t border-border/50`),children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Actions`}),(0,q.jsx)(yY,{actions:i,pageAction:t})]})]})}var xY=`(min-width: 1520px)`;function SY(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(xY).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(xY);if(t(e.matches),typeof e.addEventListener!=`function`)return;let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var CY=(0,K.createContext)(null);function wY({value:e,children:t}){return(0,q.jsx)(CY.Provider,{value:e,children:t})}function TY(){let e=(0,K.useContext)(CY),{dispatch:t,analyticsControls:n,l3Items:r,l3Connections:i,l3Actions:a=[],secondarySpec:o}=MV();return e||{railHasContent:!!(mY(o)||r&&r.length>0||mY(i)||a&&a.length>0||n),hasAppliedFilters:!1,openRightDrawer:()=>t({type:`SET_RIGHT_DRAWER`,open:!0})}}function EY(){let{railHasContent:e,hasAppliedFilters:t,openRightDrawer:n}=TY(),r=SY(),i=oY();return!e||r||i?null:(0,q.jsxs)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:n,"aria-label":`Page options`,title:`Page options (⌘.)`,"data-testid":`l3-drawer-trigger`,className:`relative hidden lg:inline-flex 2xl:hidden text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(zi,{className:`size-4`,"aria-hidden":`true`}),t&&(0,q.jsx)(`span`,{"data-testid":`header-filters-active`,className:`absolute top-1.5 right-1.5 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Page options`})]})}function DY({id:e,parent:t,title:n,subtitle:r,titleAccessory:i,actions:a,queryBar:o,subheader:s,titleTestId:c,className:l}){let{railHasContent:u}=TY(),d=!!(a||u);return(0,q.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:$(`max-lg:hidden lg:sticky lg:top-0 z-30 border-b border-border/50 bg-background/95 backdrop-blur-md transition-colors`,l),children:[(0,q.jsxs)(`div`,{className:$(`sph-row flex min-h-[54px] justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,o?`items-start`:`items-center`),children:[(t||n)&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[t&&(0,q.jsxs)(M,{to:t.to,"data-testid":Q.PAGE_HEADER_PARENT_BREADCRUMB,className:`inline-flex items-center gap-1 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground shrink-0 no-underline`,children:[(0,q.jsx)(j,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate max-w-[140px]`,children:t.label})]}),n&&(0,q.jsxs)(q.Fragment,{children:[!t&&(0,q.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{"data-testid":c,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:n}),r&&(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:r})]}),i]})]})]}),o&&(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:o}),d&&(0,q.jsxs)(`div`,{className:`sph-actions flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:[a,(0,q.jsx)(EY,{})]})]}),s&&(0,q.jsx)(`div`,{className:`bg-background/40`,children:s})]})}function OY({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,K.useRef)(``),u=(0,K.useRef)(i),d=(0,K.useRef)(a),f=(0,K.useRef)(null),p=(0,K.useRef)(1);(0,K.useEffect)(()=>{u.current=i},[i]),(0,K.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,K.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,K.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,K.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,K.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 kY({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]=V(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,K.useState)(c?.[0]?.id??``);if(OY({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}),OY({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,q.jsxs)(`div`,{className:$(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,q.jsx)(DJ,{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,q.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,q.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,q.jsx)(QJ,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,q.jsx)(`div`,{className:$(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,q.jsxs)(`div`,{className:$(eY,$J),children:[(0,q.jsx)(DY,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,q.jsx)(`div`,{className:`flex-1`,children:i})]})})}var AY=`[data-page-sticky-boundary="true"]`,jY=0;function MY(e,t=jY){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(AY)).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 NY(e,t=jY){let[n,r]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=0,i=()=>r(MY(e,t)),a=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(i)};i(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,i);let o=typeof ResizeObserver>`u`?void 0:new ResizeObserver(i);document.querySelectorAll(AY).forEach(e=>o?.observe(e));let s=typeof MutationObserver>`u`?void 0:new MutationObserver(()=>{document.querySelectorAll(AY).forEach(e=>o?.observe(e)),i()});return typeof document<`u`&&document.body&&s?.observe(document.body,{childList:!0,subtree:!0}),()=>{s?.disconnect(),o?.disconnect(),cancelAnimationFrame(n),window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,i)}},[e,t]),n}function PY({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,q.jsxs)(`div`,{"data-testid":a,className:$(`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,q.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,q.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var FY=(0,K.createContext)(null),IY=(0,K.createContext)(null);function LY({children:e}){let[t,n]=(0,K.useState)(null);return(0,q.jsx)(IY.Provider,{value:n,children:(0,q.jsx)(FY.Provider,{value:t,children:e})})}function RY({className:e}){let t=(0,K.useContext)(IY);return(0,q.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function zY(){return(0,K.useContext)(FY)}function BY({editor:e,parent:t,title:n,subtitle:r,titleAccessory:i,titleTestId:a,actions:o,timerOverlay:s,reviewOverlay:c,isTimerOpen:l=!1,isReviewOpen:u=!1,onCloseTimer:d,onCloseReview:f,className:p}){return(0,q.jsxs)(`div`,{className:$(`relative flex w-full min-h-screen justify-start items-start`,p),children:[(0,q.jsxs)(`div`,{className:$(eY,$J),children:[(0,q.jsx)(DY,{parent:t,title:n,subtitle:r,titleAccessory:i,titleTestId:a,actions:o}),(0,q.jsx)(`div`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),l&&s&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,q.jsx)(`button`,{onClick:d,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,q.jsx)(`div`,{className:`flex-1 min-h-0`,children:s})]})}),u&&c&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,q.jsx)(`button`,{onClick:f,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,q.jsx)(`div`,{className:`flex-1 min-h-0`,children:c})]})})]})}var VY=`wodwiki:fabAlignment`,HY=[{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 UY(){try{return WY(localStorage.getItem(VY))}catch{return}}function WY(e){return e===`right`||e===`left`?e:void 0}var GY=typeof window>`u`?void 0:UY();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===VY&&(GY=WY(e.newValue))});function KY(e){GY=e;try{e===`right`?localStorage.removeItem(VY):localStorage.setItem(VY,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:VY,newValue:e}))}function qY(){let[e,t]=(0,K.useState)(()=>GY??`right`);return(0,K.useEffect)(()=>{let e=e=>{e.key===VY&&t(WY(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,KY]}function JY({onOpen:e}){return(0,q.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,title:`Search`,"data-testid":`search-fab`,className:$(`size-12 rounded-full flex items-center justify-center`,`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:[(0,q.jsx)(gi,{className:`size-6`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Search`})]})}var YY=(0,K.createContext)(null),XY=(0,K.createContext)(!1),ZY=(0,K.createContext)(null),QY=(0,K.createContext)(null);function $Y(){return(0,K.useContext)(YY)!==null}function eX({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,K.useContext)(YY),o=(0,K.useContext)(XY),s=oY(),c=(0,K.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=K.Children.toArray(n).length>0,f=(0,K.useMemo)(()=>(0,q.jsx)(XY.Provider,{value:!0,children:n}),[n]),p=l||u,m=(0,K.useRef)(null);return m.current={id:c,primary:e,navbar:t,children:f,hasContent:d,label:r??`Page options`,fallback:i},(0,K.useEffect)(()=>{if(p)return a.register(m.current),()=>a.unregister(c)},[p,a,c]),(0,K.useEffect)(()=>{p&&a.register(m.current)},[p,a,e,t,f,d,r,i]),i||a&&s&&!o?null:(0,q.jsx)(XY.Provider,{value:!0,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function tX({onSearch:e,renderDock:t=!0,secondarySpec:n,pageAction:r,children:i}){let[a,o]=(0,K.useState)([]),s=(0,K.useCallback)(e=>o(t=>{let n=t.findIndex(t=>t.id===e.id);if(n===-1)return[...t,e];let r=t[n];if(r.primary===e.primary&&r.navbar===e.navbar&&r.children===e.children&&r.hasContent===e.hasContent&&r.label===e.label&&r.fallback===e.fallback)return t;let i=[...t];return i[n]=e,i}),[]),c=(0,K.useCallback)(e=>o(t=>t.filter(t=>t.id!==e)),[]),l=(0,K.useMemo)(()=>({register:s,unregister:c}),[s,c]),u=(0,K.useMemo)(()=>{for(let e=a.length-1;e>=0;--e)if(!a[e].fallback)return a[e].navbar??null;return null},[a]),d=(0,K.useMemo)(()=>({registrations:a,onSearch:e,secondarySpec:n,pageAction:r}),[a,e,n,r]);return(0,q.jsx)(YY.Provider,{value:l,children:(0,q.jsx)(ZY.Provider,{value:u,children:(0,q.jsxs)(QY.Provider,{value:d,children:[i,t&&(0,q.jsx)(aX,{registrations:a,onSearch:e,secondarySpec:n,pageAction:r})]})})})}function nX(){let e=(0,K.useContext)(QY);return e?(0,q.jsx)(aX,{registrations:e.registrations,onSearch:e.onSearch,secondarySpec:e.secondarySpec,pageAction:e.pageAction}):null}function rX(){let e=(0,K.useContext)(ZY);return e?(0,q.jsx)(q.Fragment,{children:e}):null}function iX(e){return`[data-testid="${e}"]`}function aX({registrations:e,onSearch:t,secondarySpec:n,pageAction:r}){let i=oY(),[a]=qY(),o=pA(),s=NV(),c=hY(n,r),l=!!s?.navState?.rightDrawerOpen,u=!!(s?.navState?.inspectorDrawerOpen||s?.peekTarget),d=s?.dispatch,f=s?.analyticsControls?.onReset,[p,m]=(0,K.useState)(!1),[g,_]=(0,K.useState)(!1),v=p||l,y=(0,K.useCallback)(()=>{m(!1),l&&d?.({type:`SET_RIGHT_DRAWER`,open:!1})},[l,d]),b=(0,K.useCallback)(()=>{v?y():m(!0)},[v,y]),x=(0,K.useId)(),S=(0,K.useRef)(null),C=(0,K.useRef)(null),w=(0,K.useRef)(null),T=(0,K.useRef)(null),E=(0,K.useRef)(v);E.current=v;let D=(0,K.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),O=(0,K.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]),k=(0,K.useCallback)(()=>{if(typeof document>`u`||!i){_(e=>e&&!1);return}if(u){m(e=>e&&!1),_(e=>e||!0);return}if(document.querySelector(`${iX(Q.MOBILE_WHEEL_COMPOSER)}, ${iX(Q.MOBILE_TYPING_BAR)}`)){m(e=>e&&!1),_(e=>e||!0);return}let e=window.visualViewport;if(e&&window.innerHeight-(e.height+e.offsetTop)>100){m(e=>e&&!1),_(e=>e||!0);return}let t=document.querySelector(iX(Q.RESULTS_MOBILE_BAR));if(t&&!t.hidden){let e=window.getComputedStyle(t);if(e.display!==`none`&&e.visibility!==`hidden`){m(e=>e&&!1),_(e=>e||!0);return}}if(!E.current&&S.current){let e=S.current.getBoundingClientRect();if(e.width>0&&e.height>0){let t=document.querySelectorAll(`.cm-frontmatter-preview input`);for(let n of t){let t=n.getBoundingClientRect();if(t.width<=4||t.height<=4||t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth)continue;let r=window.getComputedStyle(n);if(r.display!==`none`&&r.visibility!==`hidden`&&t.left<e.right+4&&e.left-4<t.right&&t.top<e.bottom+4&&e.top-4<t.bottom){_(e=>e||!0);return}}}}_(e=>e&&!1)},[i,u]);(0,K.useLayoutEffect)(()=>{k()},[k,a,v,D,O,t,o.height,c]),(0,K.useEffect)(()=>{if(!i||typeof document>`u`||!document.body)return;k();let e=new MutationObserver(e=>{S.current&&e.every(e=>S.current.contains(e.target))||k()});e.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`style`,`class`]});let t=new MutationObserver(()=>{k()});t.observe(document.documentElement,{attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`scroll`,k,{passive:!0,capture:!0}),window.addEventListener(`resize`,k,{passive:!0});let n=window.visualViewport;return n?.addEventListener(`resize`,k),n?.addEventListener(`scroll`,k),()=>{e.disconnect(),t.disconnect(),window.removeEventListener(`scroll`,k,{capture:!0}),window.removeEventListener(`resize`,k),n?.removeEventListener(`resize`,k),n?.removeEventListener(`scroll`,k)}},[i,k]),(0,K.useLayoutEffect)(()=>{v&&C.current?.focus({preventScroll:!0})},[v]);let A=!!(D?.hasContent||O?.hasContent||c),j=D?.hasContent?D.label:O?.hasContent?O.label:`Page options`;if(!i||!t&&!D&&!O&&!c)return null;let M=o.height===null?`100dvh`:`${o.height}px`;return(0,q.jsxs)(`div`,{ref:S,"data-testid":Q.ACTIONS_DOCK,"aria-hidden":g||void 0,className:$(`fixed z-40 lg:hidden flex flex-col gap-2 w-auto`,`transition-opacity duration-150 ease-out`,a===`left`?`left-4 items-start`:`right-4 items-end`,g&&`invisible pointer-events-none`),style:{bottom:`calc(1rem + var(--thumb-dock-lift, 0px) + env(safe-area-inset-bottom, 0px))`,maxHeight:`calc(${M} - 2rem - var(--thumb-dock-lift, 0px) - env(safe-area-inset-bottom, 0px))`},children:[v&&A&&(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 bg-black/20 dark:bg-black/35 cursor-default`,onClick:y}),(0,q.jsx)(`div`,{id:x,ref:C,role:v&&A?`dialog`:void 0,"aria-modal":v&&A?!0:void 0,"aria-label":v&&A?j:void 0,tabIndex:-1,hidden:!v||!A,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),y())},className:$(v&&A?`flex`:`hidden`,`relative z-40 min-h-0 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/10 outline-none`,c?`w-72`:`w-60`,`[&_button]:min-h-11 [&_button]:min-w-11 [&_summary]:min-h-11`),style:{maxHeight:`calc(${M} - 8rem - var(--thumb-dock-lift, 0px) - env(safe-area-inset-bottom, 0px))`},children:(0,q.jsxs)(KH,{close:y,children:[c&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/50 pb-2`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground truncate`,children:j}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[f&&(0,q.jsx)(`button`,{type:`button`,onClick:f,"data-testid":Q.L3_DRAWER_RESET_BTN,className:`inline-flex min-h-11 items-center justify-center rounded-lg px-2.5 text-xs font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground transition-colors`,children:`Reset`}),(0,q.jsx)(`button`,{type:`button`,onClick:y,"data-testid":Q.L3_DRAWER_DONE_BTN,className:`inline-flex min-h-11 items-center justify-center rounded-lg bg-primary/10 px-3 text-xs font-semibold text-primary hover:bg-primary/15 transition-colors`,children:`Done`})]})]}),D?.hasContent&&(0,q.jsx)(`div`,{ref:w,className:`contents`,children:D.children}),v&&c&&(0,q.jsxs)(q.Fragment,{children:[D?.hasContent&&(0,q.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{"data-testid":Q.ACTIONS_SHEET_L3,className:`-mx-3 -my-2 flex flex-col`,children:(0,q.jsx)(bY,{spec:n,pageAction:r})})]}),O?.hasContent&&(0,q.jsxs)(q.Fragment,{children:[(D?.hasContent||c)&&(0,q.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{ref:T,className:`contents`,children:O.children})]})]})}),(t||D?.primary)&&(0,q.jsxs)(`div`,{className:$(`relative z-40 flex shrink-0 flex-col gap-2`,a===`left`?`items-start`:`items-end`),children:[t&&(0,q.jsx)(JY,{onOpen:()=>{y(),t()}}),D?.primary&&(0,q.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:D.primary})]}),A&&(0,q.jsxs)(`button`,{type:`button`,onClick:b,"aria-label":j,title:j,"aria-expanded":v,"aria-controls":x,"data-testid":Q.ACTIONS_OVERFLOW,className:$(`relative z-40 flex size-12 shrink-0 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:[v?(0,q.jsx)(h,{className:`size-6`}):(0,q.jsx)(hn,{className:`size-6`}),(0,q.jsx)(`span`,{className:`sr-only`,children:j})]})]})}var oX=null,sX=new Set;function cX(e){oX=e;for(let e of sX)e();return()=>{if(oX===e){oX=null;for(let e of sX)e()}}}function lX(){return oX}function uX(e){return sX.add(e),()=>{sX.delete(e)}}function dX(){return(0,K.useSyncExternalStore)(uX,lX,()=>null)}var fX=null,pX=new Set;function mX(e){fX=e;for(let e of pX)e();return()=>{if(fX===e){fX=null;for(let e of pX)e()}}}function hX(){return fX}function gX(e){return pX.add(e),()=>{pX.delete(e)}}function _X(){return(0,K.useSyncExternalStore)(gX,hX,()=>null)}var vX=null,yX=new Set;function bX(e){vX=e;for(let e of yX)e();return()=>{if(vX===e){vX=null;for(let e of yX)e()}}}function xX(){return vX}function SX(e){return yX.add(e),()=>{yX.delete(e)}}function CX(){return(0,K.useSyncExternalStore)(SX,xX,()=>null)}var wX=null,TX=new Set;function EX(e){wX=e;for(let e of TX)e();return()=>{if(wX===e){wX=null;for(let e of TX)e()}}}function DX(){return wX}function OX(e){return TX.add(e),()=>{TX.delete(e)}}function kX(){return(0,K.useSyncExternalStore)(OX,DX,()=>null)}var AX=[],jX=null,MX=null,NX=null,PX=new Set;function FX(){let e=AX.length>0?AX[AX.length-1]:null;if(!e&&!jX&&!MX)NX=null;else{let t=jX,n=MX;NX={getTarget:()=>(e?e.getTarget():t)??null,openPeek:t=>{if(e)e.openPeek(t);else throw Error(`No Entity Peek host is registered to open new targets.`)},closePeek:()=>{n?.(),e?.closePeek()}}}for(let e of PX)e()}function IX(e){return AX.push(e),FX(),()=>{let t=AX.lastIndexOf(e);t!==-1&&(AX.splice(t,1),FX())}}function LX(e,t){return jX=e,MX=e?t:null,FX(),()=>{jX===e&&(jX=null,MX=null,FX())}}function RX(){return NX}function zX(e){return PX.add(e),()=>{PX.delete(e)}}function BX(){return(0,K.useSyncExternalStore)(zX,RX,()=>null)}var VX=0,HX=new Set;function UX(e){if(!e)return()=>{};VX+=1;for(let e of HX)e();let t=!1;return()=>{if(!t){t=!0,VX=Math.max(0,VX-1);for(let e of HX)e()}}}function WX(){return VX>0}function GX(e){return HX.add(e),()=>{HX.delete(e)}}function KX(){return(0,K.useSyncExternalStore)(GX,WX,()=>!1)}function qX(e){switch(e.phase){case`checking`:return`Checking the seed…`;case`fetching`:return`Downloading ${e.chunkId??`notebook`}…`;case`applying`:return`Importing ${e.chunkId??`notebook`}…`;case`committed`:return`Committed ${e.chunkId??`notebook`}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return`Done`;default:return e.phase}}function JX(e){if(!e||e.phase===`checking`||e.phase===`finished`)return null;let t=[];return typeof e.completedRecords==`number`&&typeof e.totalRecords==`number`&&t.push(`${e.completedRecords} / ${e.totalRecords} records`),e.totalChunks>0&&t.push(`${e.completedChunks} / ${e.totalChunks} notebooks`),t.length>0?t.join(` · `):null}var YX=[`samples-movement`,`samples-results`],XX=`wodwiki.seedSubscriptions`,ZX=`wodwiki.seedAutoSync`;function QX(e){try{let t=typeof localStorage<`u`?localStorage.getItem(e):null;if(!t)return new Set;let n=JSON.parse(t);return!n||typeof n!=`object`||Array.isArray(n)?new Set:new Set(Object.keys(n))}catch{return new Set}}function $X(e){let t=new Set(e.map(e=>e.id)),n=eI()??{},r=new Set([...QX(XX),...Object.keys(n)]),i=new Set([...QX(ZX),...Object.keys(rI()??{}),...Object.entries(n).filter(([,e])=>e.autoSync!==void 0).map(([e])=>e)]),a=aI()??{},o=[];for(let e of YX)t.has(e)&&(r.has(e)||(UI(e,!0),!a[e]&&!n[e]?.offlinePolicy&&QI(e,`index-only`),o.push(e)),i.has(e)||XI(e,!0));return o}var eZ=`idle`,tZ=null,nZ=!1,rZ=0,iZ=null,aZ=!1,oZ=new Set,sZ=null,cZ=null;function lZ(){for(let e of oZ)e()}function uZ(e){typeof document>`u`||(document.documentElement.dataset.feedState=e)}function dZ(e){typeof document>`u`||(e===null?delete document.documentElement.dataset.feedOutcome:document.documentElement.dataset.feedOutcome=e)}function fZ(e){typeof document>`u`||(e?document.documentElement.dataset.feedImportPending=`true`:delete document.documentElement.dataset.feedImportPending)}uZ(eZ);function pZ(e){eZ!==e&&(eZ=e,uZ(e),lZ())}function mZ(e){if(nZ===e)return;let t=nZ||rZ>0;nZ=e;let n=nZ||rZ>0;fZ(n),t!==n&&lZ()}function hZ(e){let t=nZ||rZ>0;rZ+=1,e!==void 0&&(iZ=e),fZ(nZ||rZ>0),(!t||e!==void 0)&&lZ()}function gZ(){if(rZ===0)return;let e=nZ||rZ>0;rZ=Math.max(0,rZ-1),rZ===0&&(iZ=null);let t=nZ||rZ>0;fZ(t),(e!==t||rZ===0)&&lZ()}function _Z(){return iZ}function vZ(){return(0,K.useSyncExternalStore)(DZ,_Z)}function yZ(){sZ&&=(clearTimeout(sZ),null),cZ&&=(cZ.close(),null)}function bZ(e){tZ=e,lZ()}function xZ(){yZ(),dZ(null);let e=tZ!==null,t=!nZ;if(tZ=null,nZ=!0,fZ(!0),eZ===`preparing`){(e||t)&&lZ();return}pZ(`preparing`)}function SZ(){eZ===`preparing`&&!nZ&&rZ===0&&pZ(`ready`)}function CZ(e){switch(dZ(e),e){case`busy`:if(eZ!==`preparing`&&!nZ)return;typeof BroadcastChannel<`u`&&!cZ&&(cZ=new BroadcastChannel(kS),cZ.onmessage=e=>{e.data?.kind===`seed-imported`&&(yZ(),aZ=!1,mZ(!1),pZ(`ready`))}),sZ=setTimeout(()=>{iV({onProgress:bZ}).then(CZ)},FB);break;case`error`:yZ(),aZ||mZ(!1),pZ(`error`);break;default:yZ(),aZ||mZ(!1),pZ(`ready`)}}function wZ(){return eZ===`idle`?`ready`:eZ}function TZ(){return nZ||rZ>0}function EZ(){return tZ}function DZ(e){return oZ.add(e),()=>oZ.delete(e)}function OZ(){return(0,K.useSyncExternalStore)(DZ,wZ)}function kZ(){return(0,K.useSyncExternalStore)(DZ,TZ)}function AZ(){return(0,K.useSyncExternalStore)(DZ,EZ)}var jZ=null;function MZ(e={}){return OE(`feedStart`),(e.isEnabled??BB)()&&mZ(!0),jZ??=PZ(e).finally(()=>{OE(`feedSettled`)}),jZ}async function NZ(e,t){for(let n of e)if(!(n.id===`core`||!HI(n.id)||!YI(n.id)))try{let e=await t.getSeedMeta(FS(n.id));if(!e||e.seedVersion<=0)return!0}catch{return!0}return!1}async function PZ(e){let t=t=>{bZ(t),e.onProgress?.(t)},n=e.storage??FI();n.storageInstance&&await $F(n.storageInstance).catch(e=>console.error(`[feedSync] registry hydration failed`,e));let r=e.sources??VB();await _V(e).catch(e=>console.error(`[feedSync] notebook vocabulary migration failed`,e)),await hV(e).catch(e=>console.error(`[feedSync] checkpoint adoption failed`,e)),await rue(r,n).catch(e=>console.error(`[feedSync] subscription migration failed`,e)),$X(r);let i;try{i=await n.getSeedMeta(FS(`core`))}catch{i=void 0}let a=(e.isEnabled??BB)(),o=!i||i.seedVersion<=0,s=!o&&await NZ(r,n);if(a&&(o||s)?(aZ=!0,xZ()):CZ(`current`),await gV(e).catch(e=>console.error(`[feedSync] feed provenance repair failed`,e)),o){try{let n=await iV({...e,sources:r,onProgress:t,onFirstPaint:()=>SZ()});n!==`busy`&&n!==`error`&&r.some(e=>e.id!==`core`&&HI(e.id))&&await iV({...e,sources:r.filter(e=>e.id!==`core`),onProgress:t}).catch(e=>console.error(`[feedSync] background boot sync failed`,e)),aZ=!1,CZ(n)}finally{aZ&&(aZ=!1,mZ(!1))}return}let c=`current`;try{c=await iV({...e,sources:r,onProgress:t}).catch(e=>(console.error(`[feedSync] background boot sync failed`,e),`error`))}finally{aZ&&(aZ=!1,CZ(c===`error`?`current`:c))}}function FZ(){let[e,t]=(0,K.useState)(null);return(0,K.useEffect)(()=>{let e=!1,n=()=>{fV().then(n=>{e||t(!n.libraryImported)}).catch(()=>{e||t(!0)})};n();let r=CE(()=>n()),i=QB(()=>n()),a=null;if(typeof BroadcastChannel<`u`)try{a=new BroadcastChannel(kS),a.onmessage=()=>n()}catch{}return()=>{e=!0,r(),i(),a?.close()}},[]),e}var IZ=`(min-width: 1520px)`;function LZ(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(IZ).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(IZ);if(t(e.matches),typeof e.addEventListener!=`function`)return;let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function RZ(){return(0,q.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,q.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 zZ(){return(0,q.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,q.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 BZ({open:e,close:t,onSearch:n,children:r}){let i=(0,K.useRef)(null);return(0,q.jsxs)(jr,{side:`start`,open:e,onOpenChange:e=>{e||t()},children:[(0,q.jsx)(We,{className:`bg-black/30 dark:bg-black/30 transition-none data-[closed]:hidden lg:hidden`}),(0,q.jsxs)(lt,{initialFocus:()=>i.current,"data-testid":Q.MOBILE_NAV_DRAWER,className:`w-full max-w-none h-dvh max-h-dvh p-0 gap-0 rounded-none border-0 bg-card transition-none data-[closed]:hidden lg:hidden`,children:[(0,q.jsx)(ve,{className:`sr-only`,children:`Navigation`}),(0,q.jsx)(KH,{close:t,children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,q.jsx)(`div`,{className:`flex h-full w-[156px] sm:w-44 shrink-0 flex-col overflow-y-auto border-r border-zinc-950/5 bg-background/72 px-2 py-3 dark:border-white/5`,children:(0,q.jsx)(EJ,{variant:`mobile-list`,onSearch:()=>{t(),n?.()}})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-end px-3 pt-3`,children:(0,q.jsx)(Xe,{render:(0,q.jsx)(Oq,{"aria-label":`Close navigation`,title:`Close navigation`,"data-testid":Q.MOBILE_NAV_CLOSE}),children:(0,q.jsx)(zZ,{})})}),(0,q.jsx)(`div`,{ref:i,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col outline-none`,children:r})]})]})})]})]})}function VZ({open:e,close:t,showControlsFooter:n=!1,onReset:r,children:i}){let a=(0,K.useRef)(null);return(0,q.jsxs)(jr,{side:`end`,open:e,onOpenChange:e=>{e||t()},children:[(0,q.jsx)(We,{className:`bg-black/25 dark:bg-black/40 transition-none data-[closed]:hidden 2xl:hidden`}),(0,q.jsx)(lt,{initialFocus:()=>a.current,"data-testid":Q.L3_RIGHT_DRAWER,"aria-label":`Page options panel`,className:`w-full lg:w-80 max-w-none h-dvh max-h-dvh p-0 gap-0 rounded-none border-0 lg:border-l lg:border-border/60 bg-card lg:shadow-2xl flex flex-col transition-none data-[closed]:hidden 2xl:hidden`,children:(0,q.jsxs)(KH,{close:t,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/40 px-4 py-2.5`,children:[(0,q.jsx)(ve,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Page options`}),(0,q.jsx)(Xe,{render:(0,q.jsx)(Oq,{"aria-label":`Close page options`,title:`Close page options`}),children:(0,q.jsx)(zZ,{})})]}),(0,q.jsx)(`div`,{ref:a,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col overflow-y-auto outline-none`,children:i}),n&&(0,q.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 border-t border-border/50 bg-card p-3`,children:[r&&(0,q.jsx)(`button`,{type:`button`,onClick:r,"data-testid":Q.L3_DRAWER_RESET_BTN,className:`h-10 max-lg:h-11 flex-1 rounded-lg border border-border bg-background px-3 text-sm font-medium text-foreground hover:bg-muted transition-colors`,children:`Reset`}),(0,q.jsx)(`button`,{type:`button`,onClick:t,"data-testid":Q.L3_DRAWER_DONE_BTN,className:`h-10 max-lg:h-11 flex-1 rounded-lg bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Done`})]})]})})]})}function HZ({navbar:e,sidebar:t,onSearch:n,secondary:r,pageAction:i,peekSlot:a,hideDesktopSidebar:o,children:s}){let[c,l]=(0,K.useState)(!1),u=LZ(),d=oY(),{navState:f,dispatch:p,peekTarget:m,closePeek:h,analyticsControls:g}=MV(),_=Qe().pathname===`/`||!!o,v=!!f?.rightDrawerOpen,y=!!(f?.inspectorDrawerOpen||m),b=!!(m&&a),x=(0,K.useCallback)(e=>p({type:`SET_RIGHT_DRAWER`,open:e}),[p]),S=(0,K.useCallback)(()=>x(!0),[x]),C=(0,K.useCallback)(()=>x(!1),[x]),w=hY(r,i),T=(0,K.useMemo)(()=>({railHasContent:w,hasAppliedFilters:!1,openRightDrawer:S}),[w,S]);(0,K.useEffect)(()=>{if(!c&&!v&&!m)return;let e=()=>{l(!1),x(!1),h?.()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[c,v,m,x,h]),(0,K.useEffect)(()=>{if(!w)return;let e=e=>{if(!e.defaultPrevented&&(e.metaKey||e.ctrlKey)&&e.key===`.`&&!e.shiftKey&&!e.altKey){if(window.innerWidth>=1520)return;e.preventDefault(),x(!v)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,v,x]),(0,K.useEffect)(()=>{if(!b)return;let e=e=>{e.defaultPrevented||e.key===`Escape`&&(e.preventDefault(),h?.())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,h]);let E=u&&w&&!y,D=!u&&!d&&v;return(0,q.jsx)(wY,{value:T,children:(0,q.jsx)(LY,{children:(0,q.jsx)(tX,{onSearch:n,renderDock:!1,secondarySpec:r,pageAction:i,children:(0,q.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,q.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,q.jsxs)(`div`,{"data-shell-nav":`desktop`,className:`hidden lg:flex`,children:[(0,q.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,q.jsx)(EJ,{onSearch:n??(()=>{})})}),(0,q.jsx)(`div`,{className:$(`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,q.jsx)(BZ,{open:c,close:()=>l(!1),onSearch:n,children:t}),(0,q.jsxs)(`div`,{className:$(`flex flex-1 flex-col min-w-0 2xl:max-w-none`,_||y?`xl:max-w-none`:`xl:max-w-[984px]`),children:[(0,q.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,q.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,q.jsxs)(Oq,{onClick:()=>l(!0),"aria-label":`Open navigation`,title:`Open navigation`,"data-testid":Q.MOBILE_NAV_OPEN,children:[(0,q.jsx)(RZ,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Open navigation`})]})}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:e})]}),(0,q.jsxs)(UZ,{children:[(0,q.jsx)(`div`,{className:`grow w-full max-lg:pb-[calc(12rem+var(--thumb-dock-lift,0px)+env(safe-area-inset-bottom,0px))] lg:overflow-visible`,children:s}),(0,q.jsx)(GZ,{}),(0,q.jsx)(nX,{})]})]}),E&&(0,q.jsx)(`aside`,{"aria-label":`Page outline and actions`,"data-testid":Q.L3_INLINE_RAIL,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,q.jsx)(bY,{spec:r,pageAction:i})}),y&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":Q.INSPECTOR_DRAWER_RAIL_SPACER,className:`hidden xl:block w-[340px] shrink-0`}),b&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Close peek drawer`,"data-testid":Q.PEEK_DRAWER_BACKDROP,onClick:()=>h?.(),className:`xl:hidden fixed inset-0 z-[29] bg-black/25 dark:bg-black/40 cursor-default`}),(0,q.jsx)(`div`,{"data-testid":Q.PEEK_DRAWER_SLOT,className:`fixed right-0 top-0 bottom-0 z-30 flex w-[340px] max-w-[92vw] flex-col overflow-hidden max-xl:shadow-2xl xl:shadow-none`,children:a})]}),D&&(0,q.jsx)(VZ,{open:v,close:C,showControlsFooter:!!g,onReset:g?.onReset,children:(0,q.jsx)(bY,{spec:r,pageAction:i})})]})})})})})}function UZ({children:e}){let t=Qe(),n=KX(),r=OZ(),i=kZ(),a=vZ(),o=AZ(),s=n||r===`preparing`||i,c=i&&t.pathname!==`/`,l=c?JX(o):null;return(0,q.jsxs)(`main`,{"aria-busy":s,"data-agent-status":s?`loading`:`ready`,className:`flex flex-1 flex-col lg:min-w-0`,children:[e,c&&(0,q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":Q.BOOT_IMPORT_PROGRESS,className:`pointer-events-none fixed z-30 max-lg:bottom-[calc(0.75rem+var(--thumb-dock-lift,0px)+env(safe-area-inset-bottom,0px))] max-lg:left-3 max-lg:right-auto max-lg:max-w-[calc(100vw-5.5rem)] lg:bottom-4 lg:right-4 lg:left-auto flex items-center gap-2 rounded-lg border border-border bg-card/95 px-3 py-1.5 text-xs text-foreground shadow-sm`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:a??(o?qX(o):`Importing library…`)}),l&&(0,q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:l})]})]})}var WZ=17;function GZ(){let e=(0,K.useRef)(null),[t,n]=(0,K.useState)(0);(0,K.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()},[]);let r=t>0?t+WZ:0;return(0,K.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${r}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[r]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:$(`lg:hidden fixed inset-x-0 bottom-0 z-30`,r>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,q.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,q.jsx)(RY,{className:`flex w-full min-w-0`})})}),(0,q.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:r}})]})}function KZ(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function qZ(e){return String(dc(sc(e).meta,`search`)??``).toLowerCase()===`hidden`}function JZ(e){let t=dc(sc(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 YZ(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=dc(sc(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():FP(r),category:KZ(n),content:i,date:JZ(i),searchHidden:qZ(i)}})}function XZ(){let e=$P();return(0,K.useMemo)(()=>e?YZ(e):[],[e])}var ZZ={};function QZ(e,t){let{canvasPage:n,workoutItems:r,selectWorkout:i}=t;if(e===`/`)return[];if(n){let t=/^\/notebook\//.test(e),a=t?e.split(`/`).pop()??null:null,o=[],s=e.startsWith(`/page/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=XK(e).split(`
|
|
810
|
+
`)){/^`{3,}/.test(e)&&(m=!m);let t=m?null:$K(e);t?(f&&p(f),f={heading:t.text,level:t.level,attrs:t.attrs,lines:[]}):f&&f.lines.push(e)}return f&&p(f),{template:`canvas`,route:u,type:n.type?String(n.type):void 0,sections:d,frontmatter:n,quests:i,chapters:l,scroll:o,namedScrolls:s}}function yq(e){if(!e)return`/`;let t=e.trim();return t.startsWith(`/`)||(t=`/`+t),t=t.replace(/\/+/g,`/`),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function bq(e,t){let n=yq(t);for(let t of e)if(t.route===n)return t.page;return null}function xq(e){return[yq(e)]}function Sq(e,t){for(let n of xq(t)){let t=bq(e,n);if(t!==null)return t}return null}function Cq(e){let t=[];for(let[n,r]of Object.entries(e))if(n.match(/^markdown\/canvas\/(.+\.md)$/)){let e=vq(r);e&&e.route!==Z.home&&t.push({route:e.route,page:e})}return t}function wq(e,t){return Sq(e,t)}function Tq(){let e=$P();return(0,K.useMemo)(()=>e?Cq(e):[],[e])}function Eq(e){let t=Tq();return(0,K.useMemo)(()=>wq(t,e),[t,e])}function Dq({className:e,...t}){return(0,q.jsx)(`nav`,{...t,className:na(e,`flex flex-1 items-center gap-2 sm:gap-4 py-2.5 min-w-0`)})}var Oq=(0,K.forwardRef)(function({current:e,className:t,children:n,...r},i){let a=na(`group relative flex min-w-0 min-h-11 min-w-11 items-center justify-center gap-3 rounded-lg p-2 text-left text-base/6 font-medium text-foreground sm:text-sm/5 sm:justify-start`,`[&>[data-slot=icon]]:size-6 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:fill-muted-foreground sm:[&>[data-slot=icon]]:size-5`,`[&>*:not(:nth-child(2)):last-child[data-slot=icon]]:ml-auto [&>*:not(:nth-child(2)):last-child[data-slot=icon]]:size-5 sm:[&>*:not(:nth-child(2)):last-child[data-slot=icon]]:size-4`,`[&>[data-slot=avatar]]:-m-0.5 [&>[data-slot=avatar]]:size-7 [&>[data-slot=avatar]]:[--avatar-radius:theme(borderRadius.md)] sm:[&>[data-slot=avatar]]:size-6`,`hover:bg-muted/50 hover:[&>[data-slot=icon]]:fill-foreground`,`active:bg-muted/50 active:[&>[data-slot=icon]]:fill-foreground`,`dark:hover:bg-white/5 dark:hover:[&>[data-slot=icon]]:fill-foreground`,`dark:active:bg-white/5 dark:active:[&>[data-slot=icon]]:fill-foreground`),o=r,s=r;return(0,q.jsxs)(`span`,{className:na(t,`relative`),children:[e&&(0,q.jsx)(_e.span,{layoutId:`current-indicator`,className:`absolute inset-x-2 -bottom-2.5 h-0.5 rounded-full bg-foreground`}),typeof r.href==`string`?(0,q.jsx)(WH,{...o,className:a,"data-current":e?`true`:void 0,"aria-current":e?`page`:void 0,ref:i,children:n}):(0,q.jsx)(`button`,{type:`button`,...s,className:na(`cursor-default`,a),"data-current":e?`true`:void 0,"aria-current":e?`page`:void 0,ref:i,children:n})]})});function kq({size:e=32,className:t,...n}){let r=!n[`aria-label`]&&!n[`aria-labelledby`];return(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,width:e,height:e,"aria-hidden":r?!0:void 0,role:r?void 0:`img`,className:t,...n,children:[(0,q.jsx)(`rect`,{x:`0`,y:`0`,width:`32`,height:`32`,rx:`8`,fill:`#49698d`}),(0,q.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`31`,height:`31`,rx:`7.5`,fill:`none`,stroke:`#fcfbf8`,strokeOpacity:`0.16`,strokeWidth:`1`}),(0,q.jsxs)(`g`,{transform:`translate(3.2 3.2) scale(0.8)`,children:[(0,q.jsx)(`path`,{d:`M10.5 6.5H7a1.5 1.5 0 0 0-1.5 1.5v16A1.5 1.5 0 0 0 7 25.5h3.5`,fill:`none`,stroke:`#fcfbf8`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`path`,{d:`M21.5 6.5H25a1.5 1.5 0 0 1 1.5 1.5v16a1.5 1.5 0 0 1-1.5 1.5h-3.5`,fill:`none`,stroke:`#fcfbf8`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`path`,{d:`M12.5 10.6a1.1 1.1 0 0 1 1.66-.95l7.9 4.86a1.15 1.15 0 0 1 0 1.98l-7.9 4.86a1.1 1.1 0 0 1-1.66-.95V10.6Z`,fill:`#d6e4f0`})]})]})}var Aq=class{async getAllEfforts(){let e=NP();return e.isInitialized()||await kP(e),[...e.list()]}},jq=NC(oF,{coalesce:!0,effortStore:new Aq});jq.eventStore,jq.noteStore,jq.blockStore;var Mq=new Jy,Nq={events:[],notes:[]},Pq={events:[],notes:[]};Mq.set(`@session`,Nq),Mq.set(`@today`,Pq);function Fq(){let{runtime:e,activeNoteId:t}=zz.getState(),n=e?.getOutputStatements()??[];if(Nq.notes=[],n.length===0)return Nq.events=[],Nq;let r=t??``;return Nq.events=ob(n.map(Gh),{noteId:r,resultId:`live:${r||`session`}`,origin:`playground`}),Nq}function Iq(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 by(e.date??e.createdAt,r)}async function Lq(e,t){let n=by(e.instant,e.timeZone),r=Dy(n,e.timeZone),i=Dy(xy(n,1),e.timeZone),[a,o,s,c,l]=await Promise.all([X.getEventsByTimeRange(r,i),X.getAllNotes(),X.getAllPageNotes(),X.getAllPages(),oF.readonly(`schedule_items`).getAllFromIndex(`by-date`,n).catch(()=>[])]),u=a.filter(e=>e.timestamp>=r&&e.timestamp<i),d=new Map(c.map(e=>[e.id,e])),f=new Set(l.map(e=>e.noteId)),p=new Map;for(let e of s){let t=p.get(e.noteId);t?t.push(e):p.set(e.noteId,[e])}let m=[];for(let t of o)(f.has(t.id)||Iq(t,p.get(t.id)??[],d,e.timeZone)===n)&&m.push(t);t===Bq&&(Pq.events=u,Pq.notes=m,Fq())}var Rq=null,zq=null,Bq=0,Vq=!1,Hq=new Set;function Uq(){for(let e of Hq)e()}function Wq(e,t){zq=t;let n=++Bq;return Rq=Lq(e,n),Rq.then(()=>{n===Bq&&Gq()},()=>{n===Bq&&Gq()}),Rq}function Gq(){Vq=!0,Uq()}function Kq(){let e=my(),t=by(e.instant,e.timeZone);return!Rq||zq!==t?Wq(e,t):Rq}function qq(){Vq=!1;let e=my();return Wq(e,by(e.instant,e.timeZone))}function Jq(){return Vq}function Yq(e){return Hq.add(e),()=>{Hq.delete(e)}}async function Xq(){await Promise.all([fR(),TR()])}function Zq(e){if(typeof e==`string`)return/@(?:today|session)\b/i.test(e);if(`source`in e&&e.source?.kind===`dataset`){let t=e.source.name.toLowerCase();return t===`@today`||t===`@session`}return`raw`in e&&typeof e.raw==`string`&&/@(?:today|session)\b/i.test(e.raw)}var Qq=class extends cx{async runQuery(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.runQuery(e,t)}async runPipeline(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.runPipeline(e,t)}async runFind(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.runFind(e,t)}async runRows(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.runRows(e,t)}async run(e,t){return Zq(e)?await Promise.all([Xq(),Kq()]):await Xq(),super.run(e,t)}},$q=null,eJ=0;async function tJ(e){let t=++eJ,n=await nae(oF,e);return t===eJ&&($q=n),n}function nJ(){eJ+=1,$q=null}function rJ(){return new Qq(NC(oF,{coalesce:!0,effortStore:new Aq,feedCatalogStore:HL,datasetStore:{getDataset:e=>e===`@session`?Fq()??$q?.get(`@session`):$q?.get(e)??Mq.getDataset(e)},isNotebookSubscribed:(e,t)=>WI(e,t)}))}var iJ=rJ();function aJ(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,sourceNotebook:`results`,sourceNote:i??r??`${t}:${n}`,title:a?rG(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function oJ(e){let t=e.parsed.family===`aggregate`?e.parsed.metric:`metric`;return e.series.map(e=>{let n=e.points.map(t=>`${t.value}${e.unit?` ${e.unit}`:``}`).join(` • `);return{id:`aggregate:${t}:${e.key}`,kind:`result`,sourceNotebook:`results`,sourceNote:e.label,title:`${t}: ${n}`,subtitle:e.label,date:null}})}function sJ(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function cJ(e){return typeof e==`object`&&!!e&&`runFind`in e}var lJ=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){cJ(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver),this.noteTitleResolver||=async e=>{try{let t=await X.getNote(e);return t?RT(t.title)||zT(t.rawContent??``):void 0}catch{return}}}get service(){return this.customService??iJ}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,n,r){if(t&&r)for(let t of e){let e=r[t.id];e&&e.length>0&&((!t.tags||t.tags.length===0)&&(t.tags=e.map(e=>e.label)),t.typedTags=e.map(e=>({label:e.label,type:e.type})))}let i=new Set;for(let r of e){if(r.kind===`feed`||r.kind===`notebook`||r.isRemotePreview)continue;let e=!!(n&&Object.prototype.hasOwnProperty.call(n,r.id));!e&&(r.kind===`note`||r.sourceNotebook===`journal`)&&i.add(r.id),t&&!e&&(!r.title||!r.tags||r.tags.length===0)&&i.add(r.id)}if(i.size===0)return;let a=await X.getDetailBatches([...i]);for(let t of e){if(t.kind===`feed`||t.kind===`notebook`||t.isRemotePreview)continue;let e=a.get(t.id),r=n?.[t.id];if(!e&&!r)continue;let i=r??Ss(e?.links??[],e?.pages??[]);t.placements=i;let o=Cs(i);t.pageId??=o.pageId,o.pageSlug&&(t.pageSlug=o.pageSlug)}if(t)for(let t of e){let e=a.get(t.id);!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,n){let r=typeof e==`string`?t_(e):e;if(!r||r.error)return[];if(Bg(r)){if(r.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(r):await this.service.runFind(r),n=new Map(e.notes.map(e=>[e.id,e])),i=(e.efforts??[]).map(e=>e.ownerNoteId&&n.has(e.ownerNoteId)?XW(n.get(e.ownerNoteId)):oG(e));return sJ(t,e.stages,i),i}if(r.target===`block`){let e=await this.service.runFind(r),n=e.blocks.map(nG);return await this.hydrateEntries(n,!0),sJ(t,e.stages,n),n}if(r.target===`session`){let e=await this.service.runFind(r);t?.(e.stages);let n;if(this.noteTitleResolver&&e.runs){n=new Map;for(let t of e.runs)if(!n.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&n.set(t.noteId,e)}}let i=vG(e,{noteTitles:n});return sJ(t,e.stages,i),i}if(r.target===`segment`||r.target===`event`){let e=r.target,n=await this.service.runFind(r),i=(n.table?.rows??[]).map((t,n)=>aJ(t,e,n));return sJ(t,n.stages,i),i}let e=await this.service.runFind(r,n?.notebookPlane?{notebookPlane:n.notebookPlane}:void 0),i=e.notes.map(XW);if(this.noteTagsResolver?(await this.hydrateEntries(i,!1,e.placements,e.typedTags),await Promise.all(i.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(i,!0,e.placements,e.typedTags),sJ(t,e.stages,i),this.noteBlockInfo)for(let t=0;t<i.length;t++){let n=i[t],r=e.notes[t];n.excerpt=tG(r.rawContent);try{Js(r.rawContent,r.blocks,r.sourceRevision)}catch{continue}let a=Object.values(r.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&Gs(r.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=ys(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return i}if(r.family===`aggregate`){if(!this.service.runQuery)return[];let e=await this.service.runQuery(r.raw),n=oJ(e);return t?.({selected:e.stages?.selected??n.length,matched:n.length}),n}return[]}};async function uJ(e,t=lJ,n){return t.query(e,n)}function dJ(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function fJ(e){try{let t=(await uJ(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 pJ(e){let t=dJ(e),n=(0,K.useRef)(e);n.current=e;let[r,i]=(0,K.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,K.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`?fJ(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),!e||!e.some(e=>e.kind===`wql`)?e??[]:r}function mJ(){let[e]=V(`h`,{shallow:!0}),[t]=V(`s`,{shallow:!0}),{navState:n}=MV(),r=n.activeL3Id??``;return e||t||r||``}function hJ({entry:e,active:t,onActivate:n,onRunAction:r,onFilter:i}){let a=e.onRun,o=e.filterTo,s=e.filterLabel??`Filter notes by ${e.label}`,c=e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,l=(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:$(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1.5 max-lg:min-h-11 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,!a&&!o&&`w-full`,e.muted?`text-xs`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[e.icon&&(0,q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4 shrink-0`}),e.timestamp&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums text-muted-foreground`,children:e.timestamp}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,q.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 py-0.5 font-mono text-xs uppercase tracking-wide text-muted-foreground`,children:e.badge})]});return!a&&!o?l:(0,q.jsxs)(`div`,{className:`group flex w-full items-center gap-0.5`,children:[l,o&&(0,q.jsx)(`button`,{type:`button`,"aria-label":s,title:s,"data-testid":`menu-filter-${e.id}`,onClick:()=>i(o),className:`flex size-7 max-lg:min-h-11 max-lg:min-w-11 shrink-0 items-center justify-center rounded-md text-foreground/75 transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,children:(0,q.jsx)(p,{"aria-hidden":`true`,className:`size-3.5`})}),a&&(0,q.jsx)(`button`,{type:`button`,"aria-label":c,title:c,onClick:()=>r(e),className:`flex size-7 max-lg:min-h-11 max-lg:min-w-11 shrink-0 items-center justify-center rounded text-primary opacity-70 lg:opacity-0 transition-all group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 hover:bg-primary/10 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,children:e.runIcon===`link`?(0,q.jsx)(Vn,{"aria-hidden":`true`,className:`size-3.5`}):e.runIcon===`stop`?(0,q.jsx)(ue,{"aria-hidden":`true`,className:`size-3.5`}):e.runIcon===`edit`?(0,q.jsx)(ke,{"aria-hidden":`true`,className:`size-3.5`}):(0,q.jsx)(re,{"aria-hidden":`true`,className:`size-3.5`})})]})}function gJ({entries:e,activeId:t,onSection:n,onSelect:r}){let i=dt(),{scrollToSection:a}=MV(),o=qH(),s=e=>{if(o(),n)return n(e);if(e.onSelect)return e.onSelect();if(r)return r(e);if(e.onRun)return e.onRun();if(e.to)return i(e.to);if(e.sectionId)return a(e.sectionId)},c=e=>{o(),e.onRun?.()},l=e=>{o(),i(e)};return(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,q.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,q.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,q.jsx)(gJ,{entries:e.entries,activeId:t,onSection:n,onSelect:r})]},e.id):e.kind===`wql`?null:e.kind===`widget`?(0,q.jsx)(`div`,{className:`px-1 py-1`,children:e.render()},e.id):(0,q.jsx)(hJ,{entry:e,active:t!=null&&e.sectionId===t,onActivate:s,onRunAction:c,onFilter:l},e.id))})}function _J(){let e=dt(),{scrollToSection:t}=MV();return{navigate:(t,n)=>{e(t,{replace:n?.replace})},setQueryParam:(e,t)=>{},scrollToSection:t}}function vJ(){let e=_J(),t=qH();return n=>{t(),DG(n.action,e)}}function yJ(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 bJ({items:e}){let{navState:t}=MV(),n=Qe(),r=vJ();return(0,q.jsx)(ZH,{children:e.map(e=>{let i=yJ(e,t,n);return e.children&&e.children.length>0?(0,q.jsx)(MG,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>yJ(e,t,n)),collapsible:e.id!==`syntax-group`,buttonClassName:`text-xs font-bold tracking-[0.14em] text-muted-foreground`,children:e.children.map(e=>{let i=yJ(e,t,n);return(0,q.jsxs)($H,{onClick:()=>r(e),current:i,children:[e.icon&&(0,q.jsx)(e.icon,{"data-slot":`icon`}),(0,q.jsx)(eU,{children:e.label})]},e.id)})},e.id):(0,q.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,q.jsxs)($H,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:$(`flex-1`,e.disabled&&`opacity-60`),children:[e.icon&&(0,q.jsx)(e.icon,{"data-slot":`icon`}),(0,q.jsx)(eU,{children:e.disabled?`+`:e.label})]}),e.onTogglePin&&(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onTogglePin?.()},title:e.pinned?`Unpin from sidebar`:`Pin to sidebar`,"aria-label":e.pinned?`Unpin ${e.label}`:`Pin ${e.label}`,className:`opacity-0 group-hover:opacity-100 focus-visible:opacity-100 p-1 max-lg:min-h-11 max-lg:min-w-11 flex items-center justify-center text-muted-foreground hover:text-foreground transition-opacity`,children:(0,q.jsx)(cee,{className:`size-3.5`})})]},e.id)})})}function xJ({navSpec:e}){let{tree:t,navState:n,dispatch:r}=MV(),i=pJ(e),a=(t??[]).find(e=>e?.id===n.activeL1Id)??null;return(0,q.jsxs)(JH,{"aria-label":a?`${a.label} places`:`Workspace`,children:[(0,q.jsx)(YH,{children:(0,q.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:a?.label??`Wod Wiki`})}),(0,q.jsxs)(XH,{children:[(()=>{if(!a)return null;if(a.panel){let e=a.panel;return(0,q.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,q.jsx)(e,{item:a,navState:n,dispatch:r})})}return a.children&&a.children.length>0?(0,q.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,q.jsx)(bJ,{items:a.children})}):null})(),i.length>0&&(0,q.jsx)(`div`,{className:`pt-1`,children:(0,q.jsx)(gJ,{entries:i})})]})]})}var SJ=`0.62.2261`,CJ={version:SJ,gitSha:`e0e9bb0b74bf`,builtAt:`2026-11-23T01:21:52.968Z`},wJ=`https://github.com/bitcobblers/wod-wiki/releases`;function TJ(e){return/-pr\.\d+$/.test(e)?wJ:`${wJ}/tag/v${e}`}function EJ({onSearch:e,onCreate:t,variant:n=`rail`}){let{tree:r,navState:i,dispatch:a}=MV(),o=dt(),s=Qe(),c=qH(),l={navigate:(e,t)=>{o(e,{replace:t?.replace})},setQueryParam:()=>{},scrollToSection:()=>{}},u=n===`mobile-list`,d=(r??[]).find(e=>e?.id===`home`),f=d?yJ(d,i,s):s.pathname===`/`||s.pathname===``,p=(r??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`home`&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),m=s.pathname.startsWith(`/settings/profile`),h=s.pathname.startsWith(`/settings`),g=`pointer-events-none absolute left-full top-1/2 -translate-y-1/2 z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,_=e=>$(`flex w-full min-h-11 items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] transition-colors`,e?`bg-primary/10 font-semibold text-primary`:`font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground`);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),a({type:`SET_ACTIVE_L1`,id:`home`}),o(`/`)},title:`Wod Wiki home`,"aria-label":`Wod Wiki home`,"aria-current":f?`page`:void 0,"data-testid":Q.NAV_L1_HOME,className:u?$(_(f),`mb-1.5 shrink-0`):$(`group relative mb-3 grid size-9 shrink-0 place-items-center rounded-lg transition-colors`,f?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&f&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(kq,{size:u?24:32,className:$(`shrink-0 shadow-sm shadow-black/15`,u?`size-6 rounded-[6px]`:`size-8 rounded-[8px]`)}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Home`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Wod Wiki home`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Wod Wiki home`})]})]}),(0,q.jsx)(`nav`,{"aria-label":`Primary`,className:u?`flex w-full flex-col gap-0.5`:`flex w-full flex-col items-center gap-1.5`,children:p.map(e=>{let t=e.icon,n=yJ(e,i,s);return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=!!(e.panel||e.children&&e.children.length>0);(!u||!t||n)&&c(),a({type:`SET_ACTIVE_L1`,id:e.id}),DG(e.action,l)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,"data-testid":`nav-l1-${e.id}`,className:u?_(n):$(`group 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:[!u&&n&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(t,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:e.label}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:e.label})]})]},e.id)})}),(0,q.jsx)(`div`,{className:`flex-1 min-h-2`}),(0,q.jsxs)(`button`,{type:`button`,onClick:e,title:`Search (⌘/)`,"aria-label":`Search`,"data-testid":Q.NAV_L1_SEARCH,className:u?_(!1):`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,q.jsx)(gi,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Search`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Search`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Search (⌘/)`})]})]}),(0,q.jsxs)(`a`,{href:zK,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:u?_(!1):`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,q.jsx)(BK,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Buy Me a Coffee`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Buy Me a Coffee`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Buy Me a Coffee`})]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),o(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":m?`page`:void 0,"data-testid":`nav-profile`,className:u?$(_(m),`mt-0.5`):$(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,m?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&m&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(Zt,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Profile`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Profile`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Profile`})]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),o(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":h?`page`:void 0,"data-testid":`nav-settings`,className:u?$(_(h),`mt-0.5`):$(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,h?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&h&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(si,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Settings`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Settings`}),(0,q.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 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`Settings (v`,SJ,`)`]})]})]})]})}function DJ({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,q.jsx)(`nav`,{className:$(`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,q.jsx)(`button`,{onClick:()=>DG(e.action,r),className:$(`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 OJ=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=pf){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},kJ=20,AJ=e=>{let[t,n]=(0,K.useState)(`idle`),[r,i]=(0,K.useState)(0),[a,o]=(0,K.useState)(0),[s,c]=(0,K.useState)(null),l=(0,K.useRef)(null),u=(0,K.useRef)(`idle`),d=(0,K.useRef)(0),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useCallback)(()=>e?.nowProvider?.nowMs()??pf.nowMs(),[e]),h=(0,K.useCallback)(()=>e?.nowProvider?.now()??pf.now(),[e]),g=(0,K.useCallback)(()=>u.current===`running`&&f.current!==null?d.current+Math.max(0,m()-f.current):d.current,[m]),_=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null);let e=g();d.current=e,f.current=null,u.current=`idle`,i(e),n(`idle`)},[g]),v=(0,K.useCallback)(()=>{if(e)try{let t=new OJ(void 0,e.nowProvider);e.handle(t),o(e=>e+1)}catch{_(),u.current=`error`,n(`error`)}},[e,_]);(0,K.useEffect)(()=>{if(e)return e.subscribeToStack(e=>{if(e.blocks.length===0&&u.current!==`completed`){l.current&&=(clearInterval(l.current),null);let e=g();d.current=e,f.current=null,u.current=`completed`,i(e),n(`completed`)}})},[e,g]),(0,K.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]);let y=(0,K.useCallback)(()=>{if(!e){console.warn(`useRuntimeExecution: Cannot start execution without a runtime`);return}if(u.current===`running`){console.warn(`useRuntimeExecution: Runtime is already running`);return}u.current===`paused`&&e.handle({name:`timer:resume`,timestamp:h(),data:{}});let t=m();f.current=t,p.current||(p.current=!0,c(t)),u.current=`running`,n(`running`),l.current=setInterval(v,kJ)},[e,h,m,v]),b=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null);let t=g();d.current=t,f.current=null,i(t),e&&e.handle({name:`timer:pause`,timestamp:h(),data:{}}),u.current=`paused`,n(`paused`)},[e,g,h]),x=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),d.current=0,f.current=null,p.current=!1,u.current=`idle`,i(0),o(0),n(`idle`),c(null)},[]),S=(0,K.useCallback)(()=>{!e||u.current===`running`||(u.current=`paused`,n(`paused`),v())},[e,v]);return(0,K.useEffect)(()=>{if(t!==`running`)return;let e=setInterval(()=>{i(g())},100);return()=>clearInterval(e)},[t,g]),(0,K.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]),(0,K.useEffect)(()=>{x()},[e,x]),(0,K.useMemo)(()=>({status:t,elapsedTime:r,getElapsedTime:g,stepCount:a,startTime:s,start:y,pause:b,stop:_,reset:x,step:S}),[t,r,g,a,s,y,b,_,x,S])};function jJ(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,K.useState)(r);return(0,K.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 MJ(e){return jJ(e,`round`)}function NJ(e){return jJ(e,`display`)}function PJ(e){let t=MJ(e),n=NJ(e);return(0,K.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 FJ=(0,K.createContext)(void 0),IJ=({runtime:e,children:t})=>(0,q.jsx)(FJ.Provider,{value:e,children:t});function LJ(){let e=(0,K.useContext)(FJ);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function RJ(){return(0,K.useContext)(FJ)??null}function zJ(e){let t=LJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(()=>n?.getOutputStatements?.()??[]);return(0,K.useEffect)(()=>{if(!n){i([]);return}return i(n.getOutputStatements()),n.subscribeToOutput?.(()=>{i(n.getOutputStatements())})},[n]),(0,K.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 BJ(){let e=LJ(),[t,n]=(0,K.useState)({type:`initial`,blocks:e.stack.blocks,depth:e.stack.count,clockTime:e.clock.currentDate});return(0,K.useEffect)(()=>e.subscribeToStack(e=>{n(e)}),[e]),t}function VJ(){return BJ().blocks}function HJ(){let e=VJ(),[t,n]=(0,K.useState)(0);return(0,K.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,K.useMemo)(()=>{for(let t of e){let e=t.getMemoryByTag(`metric:next`);if(e.length===0)continue;let n=ds.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 UJ(){let e=VJ(),[t,n]=(0,K.useState)(0);return(0,K.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,K.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 WJ(){let e=VJ(),[t,n]=(0,K.useState)(0);return(0,K.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,K.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 GJ(e){let t=LJ(),n=(0,K.useMemo)(()=>t.stack.blocks.find(t=>t.key.toString()===e),[t,e]),[r,i]=(0,K.useState)(()=>n?.getMemoryByTag(`time`)[0]?.metrics[0]?.value);(0,K.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,K.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,K.useMemo)(()=>r?.spans??[],[r]),o=a.length>0&&a[a.length-1].ended===void 0,[s,c]=(0,K.useState)(tp()),l=(0,K.useMemo)(()=>a.length===0?0:Ih(a,s),[a,s]);return(0,K.useEffect)(()=>{if(!o)return;let e,t=()=>{c(tp()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}function KJ(e={}){let t=RJ(),n=e.runtime===void 0?t:e.runtime,r=e.active??!0,[i,a]=(0,K.useState)({revision:0,skipFlash:!1,skipFlashKey:0});(0,K.useEffect)(()=>{if(!(!n||!r))return Rh(n,({skipFlash:e,skipFlashKey:t})=>{a(n=>({revision:n.revision+1,skipFlash:e,skipFlashKey:t}))})},[n,r]);let[o,s]=(0,K.useState)(()=>tp()),c=(0,K.useMemo)(()=>(i.revision,zh(n,{nowMs:o,executionStatus:e.executionStatus,canNextOverride:e.canNextOverride,skipFlash:i.skipFlash,skipFlashKey:i.skipFlashKey})),[n,i.revision,i.skipFlash,i.skipFlashKey,o,e.executionStatus,e.canNextOverride]);return(0,K.useEffect)(()=>{if(!r||!c.isRunning||c.isPaused||typeof requestAnimationFrame!=`function`)return;let e=0,t=!0,n=()=>{t&&(s(tp()),e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>{t=!1,cancelAnimationFrame(e)}},[r,c.isRunning,c.isPaused]),c}function qJ(e){let t=RJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(0);return(0,K.useEffect)(()=>{if(!n){i(0);return}return n.subscribeToOutput?.(()=>{i(e=>e+1)})},[n]),(0,K.useMemo)(()=>Bh(n),[n,r])}function JJ(e){let t=RJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(0);return(0,K.useEffect)(()=>{if(!n)return;let e=n.subscribeToStack(()=>i(e=>e+1)),t=n.subscribeToOutput?.(()=>i(e=>e+1));return()=>{e(),t?.()}},[n]),(0,K.useMemo)(()=>nie(n),[n,r])}var YJ=(0,K.createContext)(void 0),XJ=(0,K.createContext)(null),ZJ=({factory:e,children:t})=>{let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),u=(0,K.useRef)(e);u.current=e;let d=(0,K.useRef)(null),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),zz.getState().setSubscriptionManager(null),zz.getState().setRuntime(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,K.useCallback)((e,t)=>{if(!p.current){p.current=!0,s(!0),l(null);try{f.current&&=(f.current.dispose(),null);let n=d.current;if(d.current=null,n)try{u.current.disposeRuntime(n)}catch(e){console.error(`[RuntimeProvider] Error disposing existing runtime:`,e)}let i=u.current.createRuntime(e,t);if(d.current=i,r(i),i){let e=new Hre(i);e.add(new Vre({id:`local`})),f.current=e,a(e),zz.getState().setRuntime(i),zz.getState().setSubscriptionManager(e)}else f.current=null,a(null),zz.getState().setRuntime(null),zz.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,K.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,q.jsx)(YJ.Provider,{value:g,children:(0,q.jsx)(XJ.Provider,{value:i,children:t})})};function QJ({factory:e,children:t}){return(0,q.jsx)(ZJ,{factory:e,children:t})}var $J=`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`,eY=`flex flex-col flex-1 min-w-0 min-h-screen lg:rounded-[2.5rem]`,tY=1023;function nY(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function rY(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);if(r===null)return null;let i=t[r],{meta:a,body:o}=sc(i),s=new Set([`search`,`template`,`route`,`type`,`title`,`description`,`subtitle`,`section`,`order`]);return Object.keys(a).some(e=>!s.has(e.trim().toLowerCase()))?i:o};if(e.startsWith(`markdown/`)){let t=r(e);if(t!==null)return t}let i;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(`canvas/`))i=`markdown/canvas/`+e.replace(/^canvas\//,``);else{let t=r(`markdown/canvas/`+e);if(t!==null)return t;i=`markdown/`+e}return r(i)??`# Source not found\n\nPath: \`${e}\`\nResolved: \`${i}\``}function iY(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function aY(e){let t=new Map,n=null;for(let r of e)iY(r)&&(n=r),t.set(r.id,n);return t}function oY(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${tY}px)`).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${tY}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function sY(e){return e.map(e=>{let t=e.action,n=e.secondaryAction?.action,r={kind:`link`,id:e.id,label:e.label};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})}function cY({onOpen:e}){let t=qH();return(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>{t(),e()},"data-testid":`query-settings-trigger`,className:`w-full max-lg:min-h-11 justify-start gap-2 rounded-lg text-xs`,children:[(0,q.jsx)(zi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate`,children:`Query settings`})]})}var lY=[4,8,16],uY=`sum:totalVolume{}`;function dY(e){let t=Number.parseInt(e??``,10);return lY.includes(t)?t:16}function fY(e={}){let{defaultQuery:t=uY,runOnLanding:n=!1}=e,[r,i]=be(),a=r.get(`q`)??``,o=dY(r.get(`weeks`)),s=a?!!t_(a).error:!1,[c,l]=(0,K.useState)(()=>a||t),[u,d]=(0,K.useState)(()=>s?a:null),[f,p]=(0,K.useState)(()=>a&&!s?a:n?t:``),m=(0,K.useRef)(c);m.current=c;let h=(0,K.useRef)(f);h.current=f;let g=(0,K.useRef)(r);g.current=r;let _=(0,K.useRef)(!0),v=(0,K.useRef)(a);v.current=a;let y=(0,K.useRef)(a);(0,K.useEffect)(()=>{if(a===y.current||(y.current=a,m.current===a))return;_.current=!0;let e=a?!!t_(a).error:!1;l(a||t),e?(d(a),p(e=>e||(n?t:``))):(d(null),p(a||(n?t:``)))},[a,t,n]);let b=(0,K.useRef)(t);return(0,K.useEffect)(()=>{t!==b.current&&(b.current=t,!a&&(d(null),l(t),p(n?t:``)))},[t,a,n]),{draft:c,setDraft:(0,K.useCallback)(e=>{if(e!==m.current){if(!t_(e).error){d(null);let t=new URLSearchParams(g.current);t.set(`q`,e),i(t,{replace:!_.current}),_.current=!1}l(e)}},[i]),submitted:f,invalidUrlQuery:u,revertDraft:(0,K.useCallback)(()=>{let e=h.current||t;d(null),l(e);let n=new URLSearchParams(g.current);h.current?n.set(`q`,h.current):n.delete(`q`),i(n,{replace:!0}),_.current=!0},[t,i]),submit:(0,K.useCallback)(e=>{let t=e??m.current;if(t_(t).error)return;if(d(null),_.current&&v.current===t){p(t);return}let n=new URLSearchParams(g.current);n.set(`q`,t),i(n,{replace:!0}),_.current=!0,p(t)},[i]),weeks:o,setWeeks:(0,K.useCallback)(e=>{let t=new URLSearchParams(g.current);t.set(`weeks`,String(e)),i(t,{replace:!0})},[i])}}var pY=4;function mY(e){return!e||e.length===0?!1:e.some(e=>e.kind===`wql`||e.kind!==`section`||mY(e.entries))}function hY(e,t){let n=NV();return!!(mY(e)||n?.l3Items&&n.l3Items.length>0||mY(n?.l3Connections)||n?.l3Actions&&n.l3Actions.length>0||n?.analyticsControls||t)}function gY({controls:e}){let{unit:t,setUnit:n}=yO(),r=e.showRange!==!1,i=e.showUnits!==!1,a=e.weeks!==void 0&&e.onWeeksChange!==void 0;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":Q.L3_ANALYTICS_CONTROLS,children:[e.onOpenQuerySettings&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`This page`}),(0,q.jsx)(cY,{onOpen:e.onOpenQuerySettings})]}),r&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date range`}),a?(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":Q.L3_RANGE_OPTIONS,children:lY.map(t=>{let n=e.weeks===t;return(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":n,onClick:()=>e.onWeeksChange?.(t),"data-testid":`l3-range-${t}w`,className:$(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 max-lg:min-h-11 text-xs transition-colors`,n?`bg-primary/10 font-semibold text-primary`:`text-foreground/85 hover:bg-muted/60 hover:text-foreground`),children:[(0,q.jsx)(`span`,{className:`w-3.5 text-primary`,children:n?(0,q.jsx)(Rr,{className:`size-3.5`,"aria-hidden":`true`}):null}),(0,q.jsxs)(`span`,{children:[`Past `,t,` weeks`]})]},t)})}):(0,q.jsx)(pO,{})]}),i&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[`Units`,e.unitForced?` — pinned by query`:``]}),(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,"data-testid":Q.L3_UNIT_OPTIONS,children:[`kg`,`lb`].map(r=>{let i=t===r;return(0,q.jsx)(`button`,{type:`button`,disabled:!!e.unitForced,"aria-pressed":i,onClick:()=>n(r),"data-testid":`l3-unit-${r}`,className:$(`flex min-h-8 max-lg:min-h-11 items-center justify-center rounded-md border px-2 py-1 text-xs font-medium transition-colors`,e.unitForced?`border-transparent text-muted-foreground/75 opacity-70 cursor-not-allowed`:i?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`),children:r},r)})})]})]})}function _Y({action:e,variant:t=`default`}){let n=qH(),r=e.icon;return(0,q.jsxs)(`button`,{type:`button`,disabled:e.disabled,"data-testid":e.testId,onClick:()=>{e.disabled||(n(),e.onRun())},className:$(`flex w-full items-center gap-2 rounded-lg transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,t===`primary`&&`justify-center bg-primary px-3 py-2 min-h-9 max-lg:min-h-11 text-sm font-semibold text-primary-foreground shadow-sm hover:bg-primary/90`,t==="default"&&`px-2 py-1.5 max-lg:min-h-11 text-left text-[13px] text-foreground/85 hover:bg-muted/60 hover:text-foreground`,t===`danger`&&`px-2 py-1.5 max-lg:min-h-11 text-left text-[13px] font-medium text-destructive hover:bg-destructive/10 hover:text-destructive`,e.disabled&&(t===`primary`?`cursor-not-allowed opacity-50`:t===`danger`?`cursor-not-allowed text-destructive/50 hover:bg-transparent`:`cursor-not-allowed text-muted-foreground/60 hover:bg-transparent`)),children:[r&&(0,q.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,q.jsx)(`span`,{className:$(`min-w-0 truncate`,t!==`primary`&&`flex-1`),title:e.label,children:e.label})]})}function vY({bucket:e}){let t=e.items.length+ +!!e.extraNode;return(0,q.jsxs)(`details`,{"data-testid":e.testId,className:`group rounded-lg border border-border/40 bg-muted/20`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-9 max-lg:min-h-11 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1.5 text-xs font-semibold text-foreground/85 select-none transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(ee,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 group-open:rotate-90`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,q.jsx)(`span`,{className:`shrink-0 text-xs font-medium tabular-nums text-muted-foreground`,children:t})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1 pb-1.5 pt-0.5`,children:[e.items.map(e=>(0,q.jsx)(_Y,{action:e},e.id)),e.extraNode&&(0,q.jsx)(`div`,{className:`pt-0.5`,children:e.extraNode})]})]})}function yY({actions:e,pageAction:t}){let n=(0,K.useMemo)(()=>e.filter(e=>e.group===`primary`),[e]),r=(0,K.useMemo)(()=>e.filter(e=>e.group===`author`),[e]),i=(0,K.useMemo)(()=>e.filter(e=>e.group===`organize`||e.group===void 0),[e]),a=(0,K.useMemo)(()=>e.filter(e=>e.group===`share`),[e]),o=(0,K.useMemo)(()=>e.filter(e=>e.group===`danger`),[e]),s=r.length+i.length+a.length,c=s>=pY,l=(0,K.useMemo)(()=>{let e=[];return r.length>0&&e.push({id:`author`,label:`Author`,testId:Q.L3_ACTIONS_GROUP_AUTHOR,items:r}),i.length>0&&e.push({id:`organize`,label:`Organize`,testId:Q.L3_ACTIONS_GROUP_ORGANIZE,items:i}),(a.length>0||c&&t)&&e.push({id:`share`,label:`Share & Export`,testId:Q.L3_ACTIONS_GROUP_SHARE,items:a,extraNode:c?t:void 0}),e},[r,i,a,c,t]);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n.length>0&&(0,q.jsx)(`div`,{"data-testid":Q.L3_ACTIONS_PRIMARY,className:`flex flex-col gap-1.5 pb-1`,children:n.map(e=>(0,q.jsx)(_Y,{action:e,variant:`primary`},e.id))}),c?(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:l.map(e=>(0,q.jsx)(vY,{bucket:e},e.id))}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:[...r,...i,...a].map(e=>(0,q.jsx)(_Y,{action:e},e.id))}),t&&(0,q.jsx)(`div`,{className:$(s>0&&`pt-1`),children:t})]}),o.length>0&&(0,q.jsx)(`div`,{"data-testid":Q.L3_ACTIONS_DANGER,className:`mt-1 flex flex-col gap-0.5 border-t border-destructive/25 pt-2`,children:o.map(e=>(0,q.jsx)(_Y,{action:e,variant:`danger`},e.id))})]})}function bY({spec:e,pageAction:t}){let{l3Items:n,l3Connections:r,l3Actions:i=[],analyticsControls:a}=MV(),o=pJ(e),s=pJ(r),c=(0,K.useMemo)(()=>sY(n),[n]),l=mJ(),u=!!a,d=mY(o),f=c.length>0,p=mY(s),m=d||f||p,h=i.length>0||!!t;return!u&&!m&&!h?null:(0,q.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[u&&(0,q.jsx)(`div`,{className:$(`flex flex-col gap-4`,(m||h)&&`pb-3 border-b border-border/50`),children:a&&(0,q.jsx)(gY,{controls:a})}),d&&(0,q.jsx)(gJ,{entries:o,activeId:l}),f&&(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,q.jsx)(gJ,{entries:c,activeId:l})]}),p&&(0,q.jsxs)(`div`,{"data-testid":Q.L3_CONNECTIONS,className:$(`flex flex-col gap-1`,(f||d)&&`pt-3 border-t border-border/50`),children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Connections`}),(0,q.jsx)(gJ,{entries:s,activeId:l})]}),h&&(0,q.jsxs)(`div`,{"data-testid":Q.L3_ACTIONS,className:$(`flex flex-col gap-1`,m&&`pt-3 border-t border-border/50`),children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Actions`}),(0,q.jsx)(yY,{actions:i,pageAction:t})]})]})}var xY=`(min-width: 1520px)`;function SY(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(xY).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(xY);if(t(e.matches),typeof e.addEventListener!=`function`)return;let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var CY=(0,K.createContext)(null);function wY({value:e,children:t}){return(0,q.jsx)(CY.Provider,{value:e,children:t})}function TY(){let e=(0,K.useContext)(CY),{dispatch:t,analyticsControls:n,l3Items:r,l3Connections:i,l3Actions:a=[],secondarySpec:o}=MV();return e||{railHasContent:!!(mY(o)||r&&r.length>0||mY(i)||a&&a.length>0||n),hasAppliedFilters:!1,openRightDrawer:()=>t({type:`SET_RIGHT_DRAWER`,open:!0})}}function EY(){let{railHasContent:e,hasAppliedFilters:t,openRightDrawer:n}=TY(),r=SY(),i=oY();return!e||r||i?null:(0,q.jsxs)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:n,"aria-label":`Page options`,title:`Page options (⌘.)`,"data-testid":`l3-drawer-trigger`,className:`relative hidden lg:inline-flex 2xl:hidden text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(zi,{className:`size-4`,"aria-hidden":`true`}),t&&(0,q.jsx)(`span`,{"data-testid":`header-filters-active`,className:`absolute top-1.5 right-1.5 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Page options`})]})}function DY({id:e,parent:t,title:n,subtitle:r,titleAccessory:i,actions:a,queryBar:o,subheader:s,titleTestId:c,className:l}){let{railHasContent:u}=TY(),d=!!(a||u);return(0,q.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:$(`max-lg:hidden lg:sticky lg:top-0 z-30 border-b border-border/50 bg-background/95 backdrop-blur-md transition-colors`,l),children:[(0,q.jsxs)(`div`,{className:$(`sph-row flex min-h-[54px] justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,o?`items-start`:`items-center`),children:[(t||n)&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[t&&(0,q.jsxs)(M,{to:t.to,"data-testid":Q.PAGE_HEADER_PARENT_BREADCRUMB,className:`inline-flex items-center gap-1 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground shrink-0 no-underline`,children:[(0,q.jsx)(j,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate max-w-[140px]`,children:t.label})]}),n&&(0,q.jsxs)(q.Fragment,{children:[!t&&(0,q.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{"data-testid":c,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:n}),r&&(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:r})]}),i]})]})]}),o&&(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:o}),d&&(0,q.jsxs)(`div`,{className:`sph-actions flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:[a,(0,q.jsx)(EY,{})]})]}),s&&(0,q.jsx)(`div`,{className:`bg-background/40`,children:s})]})}function OY({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,K.useRef)(``),u=(0,K.useRef)(i),d=(0,K.useRef)(a),f=(0,K.useRef)(null),p=(0,K.useRef)(1);(0,K.useEffect)(()=>{u.current=i},[i]),(0,K.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,K.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,K.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,K.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,K.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 kY({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]=V(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,K.useState)(c?.[0]?.id??``);if(OY({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}),OY({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,q.jsxs)(`div`,{className:$(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,q.jsx)(DJ,{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,q.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,q.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,q.jsx)(QJ,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,q.jsx)(`div`,{className:$(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,q.jsxs)(`div`,{className:$(eY,$J),children:[(0,q.jsx)(DY,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,q.jsx)(`div`,{className:`flex-1`,children:i})]})})}var AY=`[data-page-sticky-boundary="true"]`,jY=0;function MY(e,t=jY){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(AY)).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 NY(e,t=jY){let[n,r]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=0,i=()=>r(MY(e,t)),a=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(i)};i(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,i);let o=typeof ResizeObserver>`u`?void 0:new ResizeObserver(i);document.querySelectorAll(AY).forEach(e=>o?.observe(e));let s=typeof MutationObserver>`u`?void 0:new MutationObserver(()=>{document.querySelectorAll(AY).forEach(e=>o?.observe(e)),i()});return typeof document<`u`&&document.body&&s?.observe(document.body,{childList:!0,subtree:!0}),()=>{s?.disconnect(),o?.disconnect(),cancelAnimationFrame(n),window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,i)}},[e,t]),n}function PY({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,q.jsxs)(`div`,{"data-testid":a,className:$(`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,q.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,q.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var FY=(0,K.createContext)(null),IY=(0,K.createContext)(null);function LY({children:e}){let[t,n]=(0,K.useState)(null);return(0,q.jsx)(IY.Provider,{value:n,children:(0,q.jsx)(FY.Provider,{value:t,children:e})})}function RY({className:e}){let t=(0,K.useContext)(IY);return(0,q.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function zY(){return(0,K.useContext)(FY)}function BY({editor:e,parent:t,title:n,subtitle:r,titleAccessory:i,titleTestId:a,actions:o,timerOverlay:s,reviewOverlay:c,isTimerOpen:l=!1,isReviewOpen:u=!1,onCloseTimer:d,onCloseReview:f,className:p}){return(0,q.jsxs)(`div`,{className:$(`relative flex w-full min-h-screen justify-start items-start`,p),children:[(0,q.jsxs)(`div`,{className:$(eY,$J),children:[(0,q.jsx)(DY,{parent:t,title:n,subtitle:r,titleAccessory:i,titleTestId:a,actions:o}),(0,q.jsx)(`div`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),l&&s&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,q.jsx)(`button`,{onClick:d,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,q.jsx)(`div`,{className:`flex-1 min-h-0`,children:s})]})}),u&&c&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,q.jsx)(`button`,{onClick:f,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,q.jsx)(`div`,{className:`flex-1 min-h-0`,children:c})]})})]})}var VY=`wodwiki:fabAlignment`,HY=[{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 UY(){try{return WY(localStorage.getItem(VY))}catch{return}}function WY(e){return e===`right`||e===`left`?e:void 0}var GY=typeof window>`u`?void 0:UY();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===VY&&(GY=WY(e.newValue))});function KY(e){GY=e;try{e===`right`?localStorage.removeItem(VY):localStorage.setItem(VY,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:VY,newValue:e}))}function qY(){let[e,t]=(0,K.useState)(()=>GY??`right`);return(0,K.useEffect)(()=>{let e=e=>{e.key===VY&&t(WY(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,KY]}function JY({onOpen:e}){return(0,q.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,title:`Search`,"data-testid":`search-fab`,className:$(`size-12 rounded-full flex items-center justify-center`,`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:[(0,q.jsx)(gi,{className:`size-6`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Search`})]})}var YY=(0,K.createContext)(null),XY=(0,K.createContext)(!1),ZY=(0,K.createContext)(null),QY=(0,K.createContext)(null);function $Y(){return(0,K.useContext)(YY)!==null}function eX({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,K.useContext)(YY),o=(0,K.useContext)(XY),s=oY(),c=(0,K.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=K.Children.toArray(n).length>0,f=(0,K.useMemo)(()=>(0,q.jsx)(XY.Provider,{value:!0,children:n}),[n]),p=l||u,m=(0,K.useRef)(null);return m.current={id:c,primary:e,navbar:t,children:f,hasContent:d,label:r??`Page options`,fallback:i},(0,K.useEffect)(()=>{if(p)return a.register(m.current),()=>a.unregister(c)},[p,a,c]),(0,K.useEffect)(()=>{p&&a.register(m.current)},[p,a,e,t,f,d,r,i]),i||a&&s&&!o?null:(0,q.jsx)(XY.Provider,{value:!0,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function tX({onSearch:e,renderDock:t=!0,secondarySpec:n,pageAction:r,children:i}){let[a,o]=(0,K.useState)([]),s=(0,K.useCallback)(e=>o(t=>{let n=t.findIndex(t=>t.id===e.id);if(n===-1)return[...t,e];let r=t[n];if(r.primary===e.primary&&r.navbar===e.navbar&&r.children===e.children&&r.hasContent===e.hasContent&&r.label===e.label&&r.fallback===e.fallback)return t;let i=[...t];return i[n]=e,i}),[]),c=(0,K.useCallback)(e=>o(t=>t.filter(t=>t.id!==e)),[]),l=(0,K.useMemo)(()=>({register:s,unregister:c}),[s,c]),u=(0,K.useMemo)(()=>{for(let e=a.length-1;e>=0;--e)if(!a[e].fallback)return a[e].navbar??null;return null},[a]),d=(0,K.useMemo)(()=>({registrations:a,onSearch:e,secondarySpec:n,pageAction:r}),[a,e,n,r]);return(0,q.jsx)(YY.Provider,{value:l,children:(0,q.jsx)(ZY.Provider,{value:u,children:(0,q.jsxs)(QY.Provider,{value:d,children:[i,t&&(0,q.jsx)(aX,{registrations:a,onSearch:e,secondarySpec:n,pageAction:r})]})})})}function nX(){let e=(0,K.useContext)(QY);return e?(0,q.jsx)(aX,{registrations:e.registrations,onSearch:e.onSearch,secondarySpec:e.secondarySpec,pageAction:e.pageAction}):null}function rX(){let e=(0,K.useContext)(ZY);return e?(0,q.jsx)(q.Fragment,{children:e}):null}function iX(e){return`[data-testid="${e}"]`}function aX({registrations:e,onSearch:t,secondarySpec:n,pageAction:r}){let i=oY(),[a]=qY(),o=pA(),s=NV(),c=hY(n,r),l=!!s?.navState?.rightDrawerOpen,u=!!(s?.navState?.inspectorDrawerOpen||s?.peekTarget),d=s?.dispatch,f=s?.analyticsControls?.onReset,[p,m]=(0,K.useState)(!1),[g,_]=(0,K.useState)(!1),v=p||l,y=(0,K.useCallback)(()=>{m(!1),l&&d?.({type:`SET_RIGHT_DRAWER`,open:!1})},[l,d]),b=(0,K.useCallback)(()=>{v?y():m(!0)},[v,y]),x=(0,K.useId)(),S=(0,K.useRef)(null),C=(0,K.useRef)(null),w=(0,K.useRef)(null),T=(0,K.useRef)(null),E=(0,K.useRef)(v);E.current=v;let D=(0,K.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),O=(0,K.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]),k=(0,K.useCallback)(()=>{if(typeof document>`u`||!i){_(e=>e&&!1);return}if(u){m(e=>e&&!1),_(e=>e||!0);return}if(document.querySelector(`${iX(Q.MOBILE_WHEEL_COMPOSER)}, ${iX(Q.MOBILE_TYPING_BAR)}`)){m(e=>e&&!1),_(e=>e||!0);return}let e=window.visualViewport;if(e&&window.innerHeight-(e.height+e.offsetTop)>100){m(e=>e&&!1),_(e=>e||!0);return}let t=document.querySelector(iX(Q.RESULTS_MOBILE_BAR));if(t&&!t.hidden){let e=window.getComputedStyle(t);if(e.display!==`none`&&e.visibility!==`hidden`){m(e=>e&&!1),_(e=>e||!0);return}}if(!E.current&&S.current){let e=S.current.getBoundingClientRect();if(e.width>0&&e.height>0){let t=document.querySelectorAll(`.cm-frontmatter-preview input`);for(let n of t){let t=n.getBoundingClientRect();if(t.width<=4||t.height<=4||t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth)continue;let r=window.getComputedStyle(n);if(r.display!==`none`&&r.visibility!==`hidden`&&t.left<e.right+4&&e.left-4<t.right&&t.top<e.bottom+4&&e.top-4<t.bottom){_(e=>e||!0);return}}}}_(e=>e&&!1)},[i,u]);(0,K.useLayoutEffect)(()=>{k()},[k,a,v,D,O,t,o.height,c]),(0,K.useEffect)(()=>{if(!i||typeof document>`u`||!document.body)return;k();let e=new MutationObserver(e=>{S.current&&e.every(e=>S.current.contains(e.target))||k()});e.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`style`,`class`]});let t=new MutationObserver(()=>{k()});t.observe(document.documentElement,{attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`scroll`,k,{passive:!0,capture:!0}),window.addEventListener(`resize`,k,{passive:!0});let n=window.visualViewport;return n?.addEventListener(`resize`,k),n?.addEventListener(`scroll`,k),()=>{e.disconnect(),t.disconnect(),window.removeEventListener(`scroll`,k,{capture:!0}),window.removeEventListener(`resize`,k),n?.removeEventListener(`resize`,k),n?.removeEventListener(`scroll`,k)}},[i,k]),(0,K.useLayoutEffect)(()=>{v&&C.current?.focus({preventScroll:!0})},[v]);let A=!!(D?.hasContent||O?.hasContent||c),j=D?.hasContent?D.label:O?.hasContent?O.label:`Page options`;if(!i||!t&&!D&&!O&&!c)return null;let M=o.height===null?`100dvh`:`${o.height}px`;return(0,q.jsxs)(`div`,{ref:S,"data-testid":Q.ACTIONS_DOCK,"aria-hidden":g||void 0,className:$(`fixed z-40 lg:hidden flex flex-col gap-2 w-auto`,`transition-opacity duration-150 ease-out`,a===`left`?`left-4 items-start`:`right-4 items-end`,g&&`invisible pointer-events-none`),style:{bottom:`calc(1rem + var(--thumb-dock-lift, 0px) + env(safe-area-inset-bottom, 0px))`,maxHeight:`calc(${M} - 2rem - var(--thumb-dock-lift, 0px) - env(safe-area-inset-bottom, 0px))`},children:[v&&A&&(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 bg-black/20 dark:bg-black/35 cursor-default`,onClick:y}),(0,q.jsx)(`div`,{id:x,ref:C,role:v&&A?`dialog`:void 0,"aria-modal":v&&A?!0:void 0,"aria-label":v&&A?j:void 0,tabIndex:-1,hidden:!v||!A,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),y())},className:$(v&&A?`flex`:`hidden`,`relative z-40 min-h-0 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/10 outline-none`,c?`w-72`:`w-60`,`[&_button]:min-h-11 [&_button]:min-w-11 [&_summary]:min-h-11`),style:{maxHeight:`calc(${M} - 8rem - var(--thumb-dock-lift, 0px) - env(safe-area-inset-bottom, 0px))`},children:(0,q.jsxs)(KH,{close:y,children:[c&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/50 pb-2`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground truncate`,children:j}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[f&&(0,q.jsx)(`button`,{type:`button`,onClick:f,"data-testid":Q.L3_DRAWER_RESET_BTN,className:`inline-flex min-h-11 items-center justify-center rounded-lg px-2.5 text-xs font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground transition-colors`,children:`Reset`}),(0,q.jsx)(`button`,{type:`button`,onClick:y,"data-testid":Q.L3_DRAWER_DONE_BTN,className:`inline-flex min-h-11 items-center justify-center rounded-lg bg-primary/10 px-3 text-xs font-semibold text-primary hover:bg-primary/15 transition-colors`,children:`Done`})]})]}),D?.hasContent&&(0,q.jsx)(`div`,{ref:w,className:`contents`,children:D.children}),v&&c&&(0,q.jsxs)(q.Fragment,{children:[D?.hasContent&&(0,q.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{"data-testid":Q.ACTIONS_SHEET_L3,className:`-mx-3 -my-2 flex flex-col`,children:(0,q.jsx)(bY,{spec:n,pageAction:r})})]}),O?.hasContent&&(0,q.jsxs)(q.Fragment,{children:[(D?.hasContent||c)&&(0,q.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{ref:T,className:`contents`,children:O.children})]})]})}),(t||D?.primary)&&(0,q.jsxs)(`div`,{className:$(`relative z-40 flex shrink-0 flex-col gap-2`,a===`left`?`items-start`:`items-end`),children:[t&&(0,q.jsx)(JY,{onOpen:()=>{y(),t()}}),D?.primary&&(0,q.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:D.primary})]}),A&&(0,q.jsxs)(`button`,{type:`button`,onClick:b,"aria-label":j,title:j,"aria-expanded":v,"aria-controls":x,"data-testid":Q.ACTIONS_OVERFLOW,className:$(`relative z-40 flex size-12 shrink-0 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:[v?(0,q.jsx)(h,{className:`size-6`}):(0,q.jsx)(hn,{className:`size-6`}),(0,q.jsx)(`span`,{className:`sr-only`,children:j})]})]})}var oX=null,sX=new Set;function cX(e){oX=e;for(let e of sX)e();return()=>{if(oX===e){oX=null;for(let e of sX)e()}}}function lX(){return oX}function uX(e){return sX.add(e),()=>{sX.delete(e)}}function dX(){return(0,K.useSyncExternalStore)(uX,lX,()=>null)}var fX=null,pX=new Set;function mX(e){fX=e;for(let e of pX)e();return()=>{if(fX===e){fX=null;for(let e of pX)e()}}}function hX(){return fX}function gX(e){return pX.add(e),()=>{pX.delete(e)}}function _X(){return(0,K.useSyncExternalStore)(gX,hX,()=>null)}var vX=null,yX=new Set;function bX(e){vX=e;for(let e of yX)e();return()=>{if(vX===e){vX=null;for(let e of yX)e()}}}function xX(){return vX}function SX(e){return yX.add(e),()=>{yX.delete(e)}}function CX(){return(0,K.useSyncExternalStore)(SX,xX,()=>null)}var wX=null,TX=new Set;function EX(e){wX=e;for(let e of TX)e();return()=>{if(wX===e){wX=null;for(let e of TX)e()}}}function DX(){return wX}function OX(e){return TX.add(e),()=>{TX.delete(e)}}function kX(){return(0,K.useSyncExternalStore)(OX,DX,()=>null)}var AX=[],jX=null,MX=null,NX=null,PX=new Set;function FX(){let e=AX.length>0?AX[AX.length-1]:null;if(!e&&!jX&&!MX)NX=null;else{let t=jX,n=MX;NX={getTarget:()=>(e?e.getTarget():t)??null,openPeek:t=>{if(e)e.openPeek(t);else throw Error(`No Entity Peek host is registered to open new targets.`)},closePeek:()=>{n?.(),e?.closePeek()}}}for(let e of PX)e()}function IX(e){return AX.push(e),FX(),()=>{let t=AX.lastIndexOf(e);t!==-1&&(AX.splice(t,1),FX())}}function LX(e,t){return jX=e,MX=e?t:null,FX(),()=>{jX===e&&(jX=null,MX=null,FX())}}function RX(){return NX}function zX(e){return PX.add(e),()=>{PX.delete(e)}}function BX(){return(0,K.useSyncExternalStore)(zX,RX,()=>null)}var VX=0,HX=new Set;function UX(e){if(!e)return()=>{};VX+=1;for(let e of HX)e();let t=!1;return()=>{if(!t){t=!0,VX=Math.max(0,VX-1);for(let e of HX)e()}}}function WX(){return VX>0}function GX(e){return HX.add(e),()=>{HX.delete(e)}}function KX(){return(0,K.useSyncExternalStore)(GX,WX,()=>!1)}function qX(e){switch(e.phase){case`checking`:return`Checking the seed…`;case`fetching`:return`Downloading ${e.chunkId??`notebook`}…`;case`applying`:return`Importing ${e.chunkId??`notebook`}…`;case`committed`:return`Committed ${e.chunkId??`notebook`}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return`Done`;default:return e.phase}}function JX(e){if(!e||e.phase===`checking`||e.phase===`finished`)return null;let t=[];return typeof e.completedRecords==`number`&&typeof e.totalRecords==`number`&&t.push(`${e.completedRecords} / ${e.totalRecords} records`),e.totalChunks>0&&t.push(`${e.completedChunks} / ${e.totalChunks} notebooks`),t.length>0?t.join(` · `):null}var YX=[`samples-movement`,`samples-results`],XX=`wodwiki.seedSubscriptions`,ZX=`wodwiki.seedAutoSync`;function QX(e){try{let t=typeof localStorage<`u`?localStorage.getItem(e):null;if(!t)return new Set;let n=JSON.parse(t);return!n||typeof n!=`object`||Array.isArray(n)?new Set:new Set(Object.keys(n))}catch{return new Set}}function $X(e){let t=new Set(e.map(e=>e.id)),n=eI()??{},r=new Set([...QX(XX),...Object.keys(n)]),i=new Set([...QX(ZX),...Object.keys(rI()??{}),...Object.entries(n).filter(([,e])=>e.autoSync!==void 0).map(([e])=>e)]),a=aI()??{},o=[];for(let e of YX)t.has(e)&&(r.has(e)||(UI(e,!0),!a[e]&&!n[e]?.offlinePolicy&&QI(e,`index-only`),o.push(e)),i.has(e)||XI(e,!0));return o}var eZ=`idle`,tZ=null,nZ=!1,rZ=0,iZ=null,aZ=!1,oZ=new Set,sZ=null,cZ=null;function lZ(){for(let e of oZ)e()}function uZ(e){typeof document>`u`||(document.documentElement.dataset.feedState=e)}function dZ(e){typeof document>`u`||(e===null?delete document.documentElement.dataset.feedOutcome:document.documentElement.dataset.feedOutcome=e)}function fZ(e){typeof document>`u`||(e?document.documentElement.dataset.feedImportPending=`true`:delete document.documentElement.dataset.feedImportPending)}uZ(eZ);function pZ(e){eZ!==e&&(eZ=e,uZ(e),lZ())}function mZ(e){if(nZ===e)return;let t=nZ||rZ>0;nZ=e;let n=nZ||rZ>0;fZ(n),t!==n&&lZ()}function hZ(e){let t=nZ||rZ>0;rZ+=1,e!==void 0&&(iZ=e),fZ(nZ||rZ>0),(!t||e!==void 0)&&lZ()}function gZ(){if(rZ===0)return;let e=nZ||rZ>0;rZ=Math.max(0,rZ-1),rZ===0&&(iZ=null);let t=nZ||rZ>0;fZ(t),(e!==t||rZ===0)&&lZ()}function _Z(){return iZ}function vZ(){return(0,K.useSyncExternalStore)(DZ,_Z)}function yZ(){sZ&&=(clearTimeout(sZ),null),cZ&&=(cZ.close(),null)}function bZ(e){tZ=e,lZ()}function xZ(){yZ(),dZ(null);let e=tZ!==null,t=!nZ;if(tZ=null,nZ=!0,fZ(!0),eZ===`preparing`){(e||t)&&lZ();return}pZ(`preparing`)}function SZ(){eZ===`preparing`&&!nZ&&rZ===0&&pZ(`ready`)}function CZ(e){switch(dZ(e),e){case`busy`:if(eZ!==`preparing`&&!nZ)return;typeof BroadcastChannel<`u`&&!cZ&&(cZ=new BroadcastChannel(kS),cZ.onmessage=e=>{e.data?.kind===`seed-imported`&&(yZ(),aZ=!1,mZ(!1),pZ(`ready`))}),sZ=setTimeout(()=>{iV({onProgress:bZ}).then(CZ)},FB);break;case`error`:yZ(),aZ||mZ(!1),pZ(`error`);break;default:yZ(),aZ||mZ(!1),pZ(`ready`)}}function wZ(){return eZ===`idle`?`ready`:eZ}function TZ(){return nZ||rZ>0}function EZ(){return tZ}function DZ(e){return oZ.add(e),()=>oZ.delete(e)}function OZ(){return(0,K.useSyncExternalStore)(DZ,wZ)}function kZ(){return(0,K.useSyncExternalStore)(DZ,TZ)}function AZ(){return(0,K.useSyncExternalStore)(DZ,EZ)}var jZ=null;function MZ(e={}){return OE(`feedStart`),(e.isEnabled??BB)()&&mZ(!0),jZ??=PZ(e).finally(()=>{OE(`feedSettled`)}),jZ}async function NZ(e,t){for(let n of e)if(!(n.id===`core`||!HI(n.id)||!YI(n.id)))try{let e=await t.getSeedMeta(FS(n.id));if(!e||e.seedVersion<=0)return!0}catch{return!0}return!1}async function PZ(e){let t=t=>{bZ(t),e.onProgress?.(t)},n=e.storage??FI();n.storageInstance&&await $F(n.storageInstance).catch(e=>console.error(`[feedSync] registry hydration failed`,e));let r=e.sources??VB();await _V(e).catch(e=>console.error(`[feedSync] notebook vocabulary migration failed`,e)),await hV(e).catch(e=>console.error(`[feedSync] checkpoint adoption failed`,e)),await rue(r,n).catch(e=>console.error(`[feedSync] subscription migration failed`,e)),$X(r);let i;try{i=await n.getSeedMeta(FS(`core`))}catch{i=void 0}let a=(e.isEnabled??BB)(),o=!i||i.seedVersion<=0,s=!o&&await NZ(r,n);if(a&&(o||s)?(aZ=!0,xZ()):CZ(`current`),await gV(e).catch(e=>console.error(`[feedSync] feed provenance repair failed`,e)),o){try{let n=await iV({...e,sources:r,onProgress:t,onFirstPaint:()=>SZ()});n!==`busy`&&n!==`error`&&r.some(e=>e.id!==`core`&&HI(e.id))&&await iV({...e,sources:r.filter(e=>e.id!==`core`),onProgress:t}).catch(e=>console.error(`[feedSync] background boot sync failed`,e)),aZ=!1,CZ(n)}finally{aZ&&(aZ=!1,mZ(!1))}return}let c=`current`;try{c=await iV({...e,sources:r,onProgress:t}).catch(e=>(console.error(`[feedSync] background boot sync failed`,e),`error`))}finally{aZ&&(aZ=!1,CZ(c===`error`?`current`:c))}}function FZ(){let[e,t]=(0,K.useState)(null);return(0,K.useEffect)(()=>{let e=!1,n=()=>{fV().then(n=>{e||t(!n.libraryImported)}).catch(()=>{e||t(!0)})};n();let r=CE(()=>n()),i=QB(()=>n()),a=null;if(typeof BroadcastChannel<`u`)try{a=new BroadcastChannel(kS),a.onmessage=()=>n()}catch{}return()=>{e=!0,r(),i(),a?.close()}},[]),e}var IZ=`(min-width: 1520px)`;function LZ(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(IZ).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(IZ);if(t(e.matches),typeof e.addEventListener!=`function`)return;let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function RZ(){return(0,q.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,q.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 zZ(){return(0,q.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,q.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 BZ({open:e,close:t,onSearch:n,children:r}){let i=(0,K.useRef)(null);return(0,q.jsxs)(jr,{side:`start`,open:e,onOpenChange:e=>{e||t()},children:[(0,q.jsx)(We,{className:`bg-black/30 dark:bg-black/30 transition-none data-[closed]:hidden lg:hidden`}),(0,q.jsxs)(lt,{initialFocus:()=>i.current,"data-testid":Q.MOBILE_NAV_DRAWER,className:`w-full max-w-none h-dvh max-h-dvh p-0 gap-0 rounded-none border-0 bg-card transition-none data-[closed]:hidden lg:hidden`,children:[(0,q.jsx)(ve,{className:`sr-only`,children:`Navigation`}),(0,q.jsx)(KH,{close:t,children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,q.jsx)(`div`,{className:`flex h-full w-[156px] sm:w-44 shrink-0 flex-col overflow-y-auto border-r border-zinc-950/5 bg-background/72 px-2 py-3 dark:border-white/5`,children:(0,q.jsx)(EJ,{variant:`mobile-list`,onSearch:()=>{t(),n?.()}})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-end px-3 pt-3`,children:(0,q.jsx)(Xe,{render:(0,q.jsx)(Oq,{"aria-label":`Close navigation`,title:`Close navigation`,"data-testid":Q.MOBILE_NAV_CLOSE}),children:(0,q.jsx)(zZ,{})})}),(0,q.jsx)(`div`,{ref:i,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col outline-none`,children:r})]})]})})]})]})}function VZ({open:e,close:t,showControlsFooter:n=!1,onReset:r,children:i}){let a=(0,K.useRef)(null);return(0,q.jsxs)(jr,{side:`end`,open:e,onOpenChange:e=>{e||t()},children:[(0,q.jsx)(We,{className:`bg-black/25 dark:bg-black/40 transition-none data-[closed]:hidden 2xl:hidden`}),(0,q.jsx)(lt,{initialFocus:()=>a.current,"data-testid":Q.L3_RIGHT_DRAWER,"aria-label":`Page options panel`,className:`w-full lg:w-80 max-w-none h-dvh max-h-dvh p-0 gap-0 rounded-none border-0 lg:border-l lg:border-border/60 bg-card lg:shadow-2xl flex flex-col transition-none data-[closed]:hidden 2xl:hidden`,children:(0,q.jsxs)(KH,{close:t,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/40 px-4 py-2.5`,children:[(0,q.jsx)(ve,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Page options`}),(0,q.jsx)(Xe,{render:(0,q.jsx)(Oq,{"aria-label":`Close page options`,title:`Close page options`}),children:(0,q.jsx)(zZ,{})})]}),(0,q.jsx)(`div`,{ref:a,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col overflow-y-auto outline-none`,children:i}),n&&(0,q.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 border-t border-border/50 bg-card p-3`,children:[r&&(0,q.jsx)(`button`,{type:`button`,onClick:r,"data-testid":Q.L3_DRAWER_RESET_BTN,className:`h-10 max-lg:h-11 flex-1 rounded-lg border border-border bg-background px-3 text-sm font-medium text-foreground hover:bg-muted transition-colors`,children:`Reset`}),(0,q.jsx)(`button`,{type:`button`,onClick:t,"data-testid":Q.L3_DRAWER_DONE_BTN,className:`h-10 max-lg:h-11 flex-1 rounded-lg bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Done`})]})]})})]})}function HZ({navbar:e,sidebar:t,onSearch:n,secondary:r,pageAction:i,peekSlot:a,hideDesktopSidebar:o,children:s}){let[c,l]=(0,K.useState)(!1),u=LZ(),d=oY(),{navState:f,dispatch:p,peekTarget:m,closePeek:h,analyticsControls:g}=MV(),_=Qe().pathname===`/`||!!o,v=!!f?.rightDrawerOpen,y=!!(f?.inspectorDrawerOpen||m),b=!!(m&&a),x=(0,K.useCallback)(e=>p({type:`SET_RIGHT_DRAWER`,open:e}),[p]),S=(0,K.useCallback)(()=>x(!0),[x]),C=(0,K.useCallback)(()=>x(!1),[x]),w=hY(r,i),T=(0,K.useMemo)(()=>({railHasContent:w,hasAppliedFilters:!1,openRightDrawer:S}),[w,S]);(0,K.useEffect)(()=>{if(!c&&!v&&!m)return;let e=()=>{l(!1),x(!1),h?.()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[c,v,m,x,h]),(0,K.useEffect)(()=>{if(!w)return;let e=e=>{if(!e.defaultPrevented&&(e.metaKey||e.ctrlKey)&&e.key===`.`&&!e.shiftKey&&!e.altKey){if(window.innerWidth>=1520)return;e.preventDefault(),x(!v)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,v,x]),(0,K.useEffect)(()=>{if(!b)return;let e=e=>{e.defaultPrevented||e.key===`Escape`&&(e.preventDefault(),h?.())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,h]);let E=u&&w&&!y,D=!u&&!d&&v;return(0,q.jsx)(wY,{value:T,children:(0,q.jsx)(LY,{children:(0,q.jsx)(tX,{onSearch:n,renderDock:!1,secondarySpec:r,pageAction:i,children:(0,q.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,q.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,q.jsxs)(`div`,{"data-shell-nav":`desktop`,className:`hidden lg:flex`,children:[(0,q.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,q.jsx)(EJ,{onSearch:n??(()=>{})})}),(0,q.jsx)(`div`,{className:$(`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,q.jsx)(BZ,{open:c,close:()=>l(!1),onSearch:n,children:t}),(0,q.jsxs)(`div`,{className:$(`flex flex-1 flex-col min-w-0 2xl:max-w-none`,_||y?`xl:max-w-none`:`xl:max-w-[984px]`),children:[(0,q.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,q.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,q.jsxs)(Oq,{onClick:()=>l(!0),"aria-label":`Open navigation`,title:`Open navigation`,"data-testid":Q.MOBILE_NAV_OPEN,children:[(0,q.jsx)(RZ,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Open navigation`})]})}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:e})]}),(0,q.jsxs)(UZ,{children:[(0,q.jsx)(`div`,{className:`grow w-full max-lg:pb-[calc(12rem+var(--thumb-dock-lift,0px)+env(safe-area-inset-bottom,0px))] lg:overflow-visible`,children:s}),(0,q.jsx)(GZ,{}),(0,q.jsx)(nX,{})]})]}),E&&(0,q.jsx)(`aside`,{"aria-label":`Page outline and actions`,"data-testid":Q.L3_INLINE_RAIL,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,q.jsx)(bY,{spec:r,pageAction:i})}),y&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":Q.INSPECTOR_DRAWER_RAIL_SPACER,className:`hidden xl:block w-[340px] shrink-0`}),b&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Close peek drawer`,"data-testid":Q.PEEK_DRAWER_BACKDROP,onClick:()=>h?.(),className:`xl:hidden fixed inset-0 z-[29] bg-black/25 dark:bg-black/40 cursor-default`}),(0,q.jsx)(`div`,{"data-testid":Q.PEEK_DRAWER_SLOT,className:`fixed right-0 top-0 bottom-0 z-30 flex w-[340px] max-w-[92vw] flex-col overflow-hidden max-xl:shadow-2xl xl:shadow-none`,children:a})]}),D&&(0,q.jsx)(VZ,{open:v,close:C,showControlsFooter:!!g,onReset:g?.onReset,children:(0,q.jsx)(bY,{spec:r,pageAction:i})})]})})})})})}function UZ({children:e}){let t=Qe(),n=KX(),r=OZ(),i=kZ(),a=vZ(),o=AZ(),s=n||r===`preparing`||i,c=i&&t.pathname!==`/`,l=c?JX(o):null;return(0,q.jsxs)(`main`,{"aria-busy":s,"data-agent-status":s?`loading`:`ready`,className:`flex flex-1 flex-col lg:min-w-0`,children:[e,c&&(0,q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":Q.BOOT_IMPORT_PROGRESS,className:`pointer-events-none fixed z-30 max-lg:bottom-[calc(0.75rem+var(--thumb-dock-lift,0px)+env(safe-area-inset-bottom,0px))] max-lg:left-3 max-lg:right-auto max-lg:max-w-[calc(100vw-5.5rem)] lg:bottom-4 lg:right-4 lg:left-auto flex items-center gap-2 rounded-lg border border-border bg-card/95 px-3 py-1.5 text-xs text-foreground shadow-sm`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:a??(o?qX(o):`Importing library…`)}),l&&(0,q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:l})]})]})}var WZ=17;function GZ(){let e=(0,K.useRef)(null),[t,n]=(0,K.useState)(0);(0,K.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()},[]);let r=t>0?t+WZ:0;return(0,K.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${r}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[r]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:$(`lg:hidden fixed inset-x-0 bottom-0 z-30`,r>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,q.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,q.jsx)(RY,{className:`flex w-full min-w-0`})})}),(0,q.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:r}})]})}function KZ(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function qZ(e){return String(dc(sc(e).meta,`search`)??``).toLowerCase()===`hidden`}function JZ(e){let t=dc(sc(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 YZ(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=dc(sc(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():FP(r),category:KZ(n),content:i,date:JZ(i),searchHidden:qZ(i)}})}function XZ(){let e=$P();return(0,K.useMemo)(()=>e?YZ(e):[],[e])}var ZZ={};function QZ(e,t){let{canvasPage:n,workoutItems:r,selectWorkout:i}=t;if(e===`/`)return[];if(n){let t=/^\/notebook\//.test(e),a=t?e.split(`/`).pop()??null:null,o=[],s=e.startsWith(`/page/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=XK(e).split(`
|
|
811
811
|
`),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&&a&&(o.push({id:`notebook-workouts`,label:`Explore`,type:`heading`}),r.filter(e=>e.category===a&&e.name.toLowerCase()!==`readme`).forEach(e=>{o.push({id:`workout-${e.id}`,label:e.name,type:`time`,onRun:()=>i(e),runIcon:`link`})})),o}return[]}var $Z=/^[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 eQ(e){return $Z.test(e)}function tQ(e){try{return decodeURIComponent(e)}catch{return null}}function nQ(e){if(!fU(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 rQ(e){let t=(e.length>1?e.replace(/\/+$/,``):e).match(/^\/day\/([^/]+)$/);if(!t)return{kind:`invalid`};let n=tQ(t[1]);return n!=null&&nQ(n)?{kind:`date`,date:n}:{kind:`invalid`}}var iQ=`# My Workout Notebook
|
|
812
812
|
|
|
813
813
|
Welcome to the **WOD.WIKI** playground.
|
|
@@ -1152,7 +1152,7 @@ domain: swimming
|
|
|
1152
1152
|
150m Cooldown
|
|
1153
1153
|
\`\`\`
|
|
1154
1154
|
`,m6=vq(j_e);if(!m6)throw Error(`The baked home page must remain a valid canvas document`);var h6=m6,z_e={"markdown/canvas/home/welcome-1.md":M_e,"markdown/canvas/syntax/single-movement.md":N_e,"markdown/canvas/syntax/timers-rest.md":P_e,"markdown/canvas/syntax/groups-1.md":F_e,"markdown/canvas/syntax/custom-metrics-1.md":I_e,"markdown/canvas/syntax/dialect-climb-bouldering.md":L_e,"markdown/canvas/syntax/complex-swimming.md":R_e};function g6(e){return{...z_e,...e}}function B_e(e,t){if(e.startsWith(`# 👋`))return e;let n=t?.replace(/^shared by:?\s*/i,``).trim();return`${n?`# 👋 ${n} sent you this workout`:`# 👋 Edit Me`}\n\nChange the reps, distance, or load below — this is live.\n\n${e}\n\n> Press **Run** ↑ to start the Clock.\n`}var _6=`wodwiki.homeShared.v1`;function v6(){return typeof window<`u`&&window.localStorage?window.localStorage:null}function V_e(e){try{v6()?.setItem(_6,JSON.stringify(e)),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`wodwiki:home-shared`,{detail:e}))}catch{}}function H_e(){try{let e=v6()?.getItem(_6);if(!e)return null;let t=JSON.parse(e);return typeof t?.content==`string`?{content:t.content,by:typeof t.by==`string`?t.by:void 0}:null}catch{return null}}function U_e(){try{v6()?.removeItem(_6)}catch{}}function W_e({pageRoute:e,quests:t,running:n}){let{markComplete:r}=$0(e,t),i=(0,K.useMemo)(()=>t.filter(e=>e.validation?.type===`run-started`),[t]);(0,K.useEffect)(()=>{if(n)for(let e of i)r(e.id)},[n,i,r])}var G_e={"session-insights":`qs-tour-analytics`},K_e={"workout-complete":!0,"run-started":!0};function q_e(e,t){let{markComplete:n}=$0(e,t),r=(0,K.useRef)(new Set);return r.current=new Set(t.filter(e=>!e.validation||!K_e[e.validation.type]).map(e=>e.id)),(0,K.useCallback)(e=>{let t=G_e[e];t&&r.current.has(t)&&n(t)},[n])}var J_e=.4;function Y_e(e){let{dispatch:t}=MV();(0,K.useEffect)(()=>{let n=e.map(e=>document.getElementById(e)).filter(e=>e!==null);if(n.length===0||typeof IntersectionObserver>`u`)return;let r=()=>{let e=window.innerHeight*J_e,t=null;for(let r of n){let n=r.getBoundingClientRect();if(n.width!==0||n.height!==0){if(n.top>e)break;t=r.id}}return t},i=new IntersectionObserver(()=>{let e=r();e&&t({type:`SET_ACTIVE_L3`,id:e})},{threshold:Array.from({length:21},(e,t)=>t/20)});return n.forEach(e=>i.observe(e)),()=>i.disconnect()},[e.join(`
|
|
1155
|
-
`),t])}var y6=(0,K.createContext)(null);function b6({children:e}){let t=(0,K.useRef)({"editor.window":null,"editor.wodBlock":null,"editor.runButton":null,"editor.typeahead":null,"timer.floor":null,"timer.nextButton":null,"timer.castButton":null,"metrics.efforts":null,"metrics.data":null,"metrics.compound":null,"analytics.vocab":null,"analytics.table":null,"analytics.graphs":null,"analytics.dashboard":null}),[n,r]=(0,K.useState)(0),i=(0,K.useCallback)((e,n)=>{t.current[e]!==n&&(t.current[e]=n,r(e=>e+1))},[]);return(0,q.jsx)(y6.Provider,{value:{register:i,registry:t,version:n},children:e})}function x6(){return(0,K.useContext)(y6)||{registry:{current:{}},register:()=>()=>{},version:0}}function S6(e){let t=(0,K.useContext)(y6)?.register;return(0,K.useCallback)(n=>t?.(e,n),[e,t])}function X_e({ringKey:e,el:t}){let{register:n}=x6();return(0,K.useLayoutEffect)(()=>{n(e,t)},[e,t,n]),null}function Z_e({target:e,accent:t,canvasRef:n}){let{registry:r,version:i}=x6(),[a,o]=(0,K.useState)(null),s=e?.key??null;return(0,K.useLayoutEffect)(()=>{if(!s){o(null);return}let e=()=>{let e=r.current[s],t=n.current;if(!e||!t){o(null);return}let i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),c=Math.round(i.left-a.left),l=Math.round(i.top-a.top),u=Math.round(i.width),d=Math.round(i.height);if(u<=0||d<=0||c+u<0||l+d<0||c>a.width||l>a.height){o(null);return}o({x:c,y:l,w:u,h:d})};e();let t=window.setTimeout(e,120),i=window.setTimeout(e,480),a=null,c=r.current[s];c&&typeof ResizeObserver<`u`&&(a=new ResizeObserver(e),a.observe(c));let l=new MutationObserver(e);return c&&l.observe(c,{attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`resize`,e),()=>{window.clearTimeout(t),window.clearTimeout(i),a?.disconnect(),l.disconnect(),window.removeEventListener(`resize`,e)}},[s,i,r,n]),!e||!a?null:(0,q.jsx)(`div`,{"data-testid":`tour-ring`,className:`pointer-events-none absolute z-30 rounded-2xl transition-all duration-500 ease-out`,style:{left:a.x-6,top:a.y-6,width:a.w+12,height:a.h+12,boxShadow:`0 0 0 2px ${t}`}})}function C6(){return(0,q.jsxs)(`div`,{className:`@container flex w-full flex-col items-center text-center`,children:[(0,q.jsxs)(`h1`,{className:`text-balance text-[clamp(32px,6.5cqi,64px)] font-extrabold leading-[1.02] tracking-[-0.04em]`,children:[(0,q.jsxs)(`span`,{className:`block`,children:[(0,q.jsx)(`span`,{className:`mr-[0.35em]`,children:`Write it.`}),(0,q.jsx)(`span`,{children:`Time it.`})]}),(0,q.jsxs)(`span`,{className:`block`,children:[(0,q.jsx)(`span`,{className:`mr-[0.35em]`,children:`Track it.`}),(0,q.jsx)(`span`,{children:`Own it.`})]})]}),(0,q.jsxs)(`p`,{className:`mt-4 xl:mt-6 max-w-xl xl:max-w-2xl 2xl:max-w-3xl text-pretty text-[15px] sm:text-base xl:text-lg leading-relaxed text-muted-foreground`,children:[`Plain-text Markdown becomes a step-through workout clock,`,` `,(0,q.jsx)(`br`,{className:`hidden sm:inline`}),`line and splits become queryable training data points.`]})]})}var w6=`dQw4w9WgXcQ`,Q_e=(0,K.memo)(function({onWatched:e}){let[t,n]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 xl:gap-5`,children:[(0,q.jsxs)(`div`,{className:`group relative aspect-video w-full max-w-2xl rounded-xl border border-border bg-black text-left shadow-xl transition-shadow hover:shadow-2xl 2xl:max-w-3xl`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),"data-testid":`tour-why-video`,"aria-label":`Play Why Wod Wiki? · YouTube video`,className:`block h-full w-full overflow-hidden rounded-xl`,children:[(0,q.jsx)(`img`,{src:`https://i.ytimg.com/vi/${w6}/hqdefault.jpg`,alt:`Why Wod Wiki? video thumbnail`,width:480,height:360,fetchPriority:`high`,decoding:`async`,className:`h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.02]`}),(0,q.jsx)(`span`,{className:`absolute inset-0 bg-gradient-to-t from-black/70 via-black/10 to-transparent`}),(0,q.jsx)(`span`,{className:`absolute left-1/2 top-1/2 flex size-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-background/90 text-foreground shadow-lg transition-transform duration-300 group-hover:scale-110 xl:size-16`,children:(0,q.jsx)(Sr,{className:`ml-1 size-6 fill-current xl:size-7`})}),(0,q.jsx)(`span`,{className:`absolute bottom-3 left-4 font-mono text-[11px] uppercase tracking-[0.2em] text-white/90`,children:`Why Wod Wiki? · YouTube`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{n(!1),e?.()},"data-testid":`tour-why-video-skip`,title:`Skip the video`,"aria-label":`Skip the Why Wod Wiki? video`,className:`absolute right-0 top-0 z-10 flex size-8 items-center justify-center rounded-full border border-border bg-background/90 text-foreground shadow-lg backdrop-blur-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary after:absolute after:-inset-3 after:content-[''] md:-right-2 md:-top-2`,children:(0,q.jsx)(ze,{className:`size-4`})})]}),(0,q.jsxs)(`p`,{"data-testid":`tour-scroll-hint`,className:`flex items-center gap-2 font-mono text-[11px] uppercase tracking-[0.3em] text-muted-foreground`,children:[(0,q.jsx)(rt,{className:`size-4`,"aria-hidden":!0}),`Keep scrolling for the demo`]}),t&&(0,q.jsx)(S3,{videoId:w6,title:`Why Wod Wiki?`,onClose:()=>{n(!1),e?.()}})]})}),$_e=`https://github.com/bitcobblers/wod-wiki`;function T6(){return(0,q.jsx)(`footer`,{"data-testid":`tour-footer`,className:`border-t border-border px-6 py-8`,children:(0,q.jsxs)(`p`,{className:`mx-auto flex max-w-3xl flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(kq,{size:20,className:`size-5 shrink-0`}),(0,q.jsxs)(`span`,{children:[`© `,new Date().getFullYear(),` WOD Wiki`]}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`a`,{href:$_e,target:`_blank`,rel:`noopener noreferrer`,className:`underline-offset-4 transition-colors hover:text-foreground hover:underline`,children:`GitHub repository`})]})})}async function E6(){await oF.wipe();try{for(let e=localStorage.length-1;e>=0;e--){let t=localStorage.key(e);t&&t!==`wodwiki.dataSettings.v1`&&localStorage.removeItem(t)}}catch{}try{sessionStorage.clear()}catch{}}var eve=`https://github.com/bitcobblers/wod-wiki`,tve=`https://forms.gle/6YHpxwAJh6PAsyAQ6`,nve=`https://app.turso.tech/signup`,rve=`m23.31.803-.563-.42-1.11 1.189-.891-1.286-.512.235.704 1.798-.326.35L18.082 0l-.574.284 2.25 4.836-2.108.741h-.05l-1.143-1.359-1.144 1.36H8.687l-1.144-1.36-1.146 1.363H6.36l-2.12-.745L6.491.284 5.919 0l-2.53 2.668-.327-.349.705-1.798-.512-.236-.89 1.287L1.253.382.69.804 2.42 3.69l-.89.939.311 2.375 2.061.787L3.9 8.817H1.947v.444l.755 1.078 1.197.433v6.971l3.057 4.55L7.657 24l1.101-1.606L9.9 24l.999-1.606L12 24l1.102-1.606L14.1 24l1.141-1.606L16.343 24l.701-1.706 3.058-4.55v-6.972l1.196-.433.756-1.078v-.444h-1.952l.003-1.03 2.054-.784.311-2.375-.89-.939zm-8.93 18.718H8.033l.793-1.615.794 1.615.793-1.083.793 1.083.794-1.083.793 1.083.794-1.083.793 1.083.793-1.615.794 1.615zm3.886-7.39-3.3 1.084-.143 3.061-2.827.627-2.826-.627-.142-3.06-3.3-1.085v-1.635l4.266 1.21-.052 4.126h4.109l-.052-4.127 4.266-1.209z`,ive=[{id:`managed-hosting`,label:`Managed hosting — we run the database.`},{id:`public-profile`,label:`Profile page with a public feed.`},{id:`device-sync`,label:`Sync across your apps and devices.`}],ave=[{id:`coach-views`,label:`Member accounts with coach views.`},{id:`coaches-portal`,label:`Programming dashboards and leaderboards.`},{id:`athlete-portal`,label:`Private journals that roll up to their coach.`},{id:`gym-hosting`,label:`Gym website, competition timers, whiteboard displays.`},{id:`branding`,label:`Your gym's brand on pages and feeds.`}],D6=`underline-offset-4 transition-colors hover:text-foreground hover:underline`;function O6(e){let t=`inline-flex min-h-10 max-lg:min-h-11 w-fit items-center gap-1.5 py-1 font-medium text-foreground underline-offset-4 transition-colors hover:underline`,n=(0,q.jsxs)(q.Fragment,{children:[e.children,(0,q.jsx)(ae,{className:`size-3.5 text-muted-foreground/50`,"aria-hidden":!0})]});return e.href===void 0?e.onClick===void 0?(0,q.jsx)(M,{to:e.to,className:t,children:n}):(0,q.jsx)(`button`,{type:`button`,onClick:e.onClick,className:`text-left ${t}`,children:n}):(0,q.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:t,children:n})}function k6({children:e}){return(0,q.jsxs)(`li`,{className:`flex gap-2.5 text-sm leading-6 text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`mt-[11px] size-1 shrink-0 rounded-full bg-muted-foreground/50`}),(0,q.jsx)(`span`,{children:e})]})}function ove(){return(0,q.jsx)(`span`,{className:`rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 font-mono text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Active`})}function sve(e){return(0,q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`flex gap-2.5 text-[13px] leading-5 text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`mt-[9px] size-1 shrink-0 rounded-full bg-muted-foreground/50`}),(0,q.jsx)(`span`,{children:e.feature.label})]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`hosted-interest-${e.feature.id}`,onClick:()=>e.onInterested(e.feature.id),disabled:e.interested,"aria-pressed":e.interested,className:`ml-[13px] inline-flex min-h-8 max-lg:min-h-9 w-fit shrink-0 items-center rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors ${e.interested?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`border-border text-muted-foreground hover:border-primary/50 hover:text-primary`}`,children:e.interested?`✓ Interested`:`Interested`})]})}function cve(){return(0,q.jsx)(`div`,{role:`status`,"data-testid":`hosted-survey-footer`,className:`mx-auto mt-5 max-w-5xl animate-in fade-in slide-in-from-bottom-4 rounded-xl border border-emerald-500/30 bg-emerald-500/10 p-4 duration-500`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(kt,{className:`size-5 shrink-0 text-emerald-700 dark:text-emerald-400`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Thanks for showing interest — please fill out the survey and give us feedback.`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Opens the interest survey in a new tab.`})]})]}),(0,q.jsxs)(J,{type:`button`,"data-testid":`hosted-survey-button`,onClick:()=>{QR.record($R.hostedSurveyOpened),window.open(tve,`_blank`,`noopener,noreferrer`)},children:[`Fill out interest survey`,(0,q.jsx)(ae,{className:`size-4`,"aria-hidden":!0})]})]})})}function A6(e){let t=e.icon;return(0,q.jsxs)(`article`,{className:`flex flex-col rounded-xl border border-border p-5 ${e.us?`bg-muted/40`:`bg-background`} ${e.className??``}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-foreground text-background`,children:(0,q.jsx)(t,{className:`size-5`,"aria-hidden":!0})}),e.badge]}),e.eyebrow&&(0,q.jsx)(`p`,{className:`mt-3.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] ${e.us?`text-emerald-800 dark:text-emerald-300`:`text-muted-foreground`}`,children:e.eyebrow}),(0,q.jsx)(`h3`,{className:`${e.eyebrow?`mt-1`:`mt-4`} text-base font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:e.text}),(0,q.jsx)(`div`,{className:`mt-4 flex flex-1 flex-col gap-2 text-sm`,children:e.children})]})}function j6({label:e,features:t,interested:n,onInterested:r}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2.5 font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground first:mt-0`,children:e}),(0,q.jsx)(`ul`,{className:`space-y-3 lg:space-y-2`,children:t.map(e=>(0,q.jsx)(sve,{feature:e,interested:n.has(e.id),onInterested:r},e.id))})]})}function M6(){let[e,t]=(0,K.useState)(!1),n=dt(),[r,i]=(0,K.useState)(new Set),a=e=>{i(t=>t.has(e)?t:new Set(t).add(e)),QR.record($R.hostedInterestClicked,{feature:e})},[o]=(0,K.useState)(rF),s=async()=>{window.confirm(`Wipe every note, result, and setting stored in this browser? This cannot be undone.`)&&(t(!0),await E6(),window.location.reload())},c=async()=>{let e=uU(),t=await CU.create({journalDate:e,title:e,rawContent:``});QR.record($R.noteCreated),n(vH(t.id))};return(0,q.jsxs)(`section`,{id:`tour-section-offerings`,"data-testid":`tour-section-offerings`,"aria-label":`You own your data`,children:[(0,q.jsx)(C3,{index:`04`,before:`Who owns the data? `,accentText:`You!!!`,after:``,accent:T3.library,blurb:`Run it in your browser, back it up to your own database, or host it on your own server — and if you'd rather hand the caretaking to us, mark the hosted features you want below and the interest survey unlocks.`}),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-[1500px] 2xl:max-w-[1720px] px-6 pb-16 pt-10 lg:px-12 xl:px-16`,children:[(0,q.jsxs)(`p`,{className:`mx-auto mb-5 flex max-w-5xl flex-wrap items-center justify-between gap-3 text-sm text-muted-foreground`,role:`status`,children:[(0,q.jsx)(`span`,{children:`Current mode: API server`}),(0,q.jsx)(M,{to:Z.settingsStorage,className:D6,children:`Configure data storage`})]}),(0,q.jsxs)(`div`,{className:`mx-auto grid max-w-5xl grid-cols-1 gap-5 md:grid-cols-3`,children:[(0,q.jsxs)(A6,{icon:Kt,eyebrow:`You own it`,title:`Playground in your browser`,badge:void 0,text:`Everything runs locally in this browser's IndexedDB — offline, no account, no server copy.`,children:[(0,q.jsx)(O6,{onClick:()=>void c(),children:`Create your journal`}),(0,q.jsx)(O6,{to:Z.playgroundRoot,children:`Start Writing in a Playground`}),(0,q.jsx)(O6,{to:`/feeds`,children:`Explore the notebooks`}),(0,q.jsxs)(`ul`,{className:`mt-1 space-y-1.5`,children:[(0,q.jsx)(k6,{children:`Offline and fast — notes and results never leave this browser by default.`}),(0,q.jsx)(k6,{children:`Tied to this browser — export or back it up before switching browsers or clearing site data.`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:s,disabled:e,className:`mt-1 inline-flex min-h-10 max-lg:min-h-11 items-center text-left text-xs text-muted-foreground disabled:opacity-50 ${D6}`,children:e?`Clearing…`:`Clear my data`}),(0,q.jsxs)(`div`,{className:`mt-auto border-t border-border pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg border border-border bg-background`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:`size-4`,"aria-hidden":!0,children:(0,q.jsx)(`path`,{d:rve})})}),(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Backup & sync, optional`}),(0,q.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:`Add a free Turso database you own — committed changes back up in the background; without network you keep working and upload later.`})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,q.jsx)(O6,{href:nve,children:`Create a free Turso account`}),(0,q.jsx)(O6,{to:Z.settingsStorage,children:`Configure backup & sync`})]})]})]}),(0,q.jsxs)(A6,{icon:er,eyebrow:`You own it`,title:`Self-hosted`,badge:(0,q.jsx)(ove,{}),text:`Build the app for API storage and run the Wod Wiki server yourself — local or cloud data access through a server you administer.`,children:[(0,q.jsxs)(`ul`,{className:`mt-1 space-y-1.5`,children:[(0,q.jsx)(k6,{children:`Centralized data for a team or gym — one SQLite, Turso, or Postgres backend.`}),(0,q.jsxs)(k6,{children:[`Publish your notebooks as a feed with `,(0,q.jsx)(`code`,{className:`font-mono text-xs`,children:`wod build`}),` — every browser subscribes and syncs.`]}),(0,q.jsx)(k6,{children:`You run the server — network required, and server admin is on you.`})]}),(0,q.jsx)(`div`,{className:`mt-auto border-t border-border pt-4`,children:(0,q.jsx)(O6,{href:eve,children:`View source`})})]}),(0,q.jsxs)(A6,{icon:di,us:!0,eyebrow:`Us — we'd host it`,title:`Wod-Wiki hosted`,text:`Mark the features you want — the survey unlocks below.`,children:[(0,q.jsx)(j6,{label:`Individuals`,features:ive,interested:r,onInterested:a}),(0,q.jsx)(j6,{label:`Coaching & gyms`,features:ave,interested:r,onInterested:a})]})]}),r.size>0&&(0,q.jsx)(cve,{})]})]})}var N6=({doc:e,onDocChange:t,onBlocksChange:n,onRun:r,theme:i,withRingTargets:a=!1,editorSlot:o})=>{let s=S6(`editor.wodBlock`),c=S6(`editor.runButton`),l=(0,K.useRef)(null),u=(0,K.useRef)(null),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),h=(0,K.useCallback)(()=>{if(!a)return null;let e=l.current;if(!e)return null;let t=null,n=e.querySelector(`.cm-wod-fence-open`),r=e.querySelector(`.cm-wod-fence-close`);if(n&&r){let i=e.getBoundingClientRect(),a=n.getBoundingClientRect(),o=r.getBoundingClientRect();if(a.top>=i.top-2&&o.bottom<=i.bottom+2){let n=e.offsetWidth?i.width/e.offsetWidth:1;t={top:(a.top-i.top)/n,left:(Math.min(a.left,o.left)-i.left)/n,width:(Math.max(a.right,o.right)-Math.min(a.left,o.left))/n,height:(o.bottom-a.top)/n}}}f(t);let i=null,o=e.querySelector(`[data-testid="${Q.EDITOR_START_WORKOUT}"]`);if(o){let t=e.getBoundingClientRect(),n=o.getBoundingClientRect();if(n.width>0&&n.height>0&&n.top>=t.top-2&&n.bottom<=t.bottom+2&&n.left>=t.left-2&&n.right<=t.right+2){let r=e.offsetWidth?t.width/e.offsetWidth:1;i={top:(n.top-t.top)/r,left:(n.left-t.left)/r,width:n.width/r,height:n.height/r}}}return m(i),{block:t,run:i}},[a]);(0,K.useLayoutEffect)(()=>{if(!a)return;let e=l.current;if(!e)return;h();let t=window.setTimeout(h,120),n=window.setTimeout(h,480),r=null;if(typeof ResizeObserver<`u`){r=new ResizeObserver(h),r.observe(e);let t=u.current?.contentDOM;t&&r.observe(t)}let i=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.closest(`.cm-note-editor`))&&h()});i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]});let o=0,s=0,c=()=>{h(),performance.now()-s<3e3&&(o=requestAnimationFrame(c))},d=()=>{s=performance.now(),cancelAnimationFrame(o),o=requestAnimationFrame(c)};d(),document.fonts?.ready?.then(d).catch(()=>{});let f=u.current?.scrollDOM;return f?.addEventListener(`scroll`,h,{passive:!0}),window.addEventListener(`resize`,h),()=>{window.clearTimeout(t),window.clearTimeout(n),r?.disconnect(),i.disconnect(),f?.removeEventListener(`scroll`,h),window.removeEventListener(`resize`,h),cancelAnimationFrame(o)}},[e,a,h]);let g=(0,K.useCallback)(()=>{r()},[r]),_=o??N4,v=(0,K.useMemo)(()=>[{id:`run`,label:`Run`,icon:(0,q.jsx)(Sr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:g},{id:`playground`,label:`Playground`,icon:(0,q.jsx)(Ci,{className:`h-3 w-3`}),onClick:e=>{O_e(e)},splitIcon:(0,q.jsx)(Vi,{className:`h-3 w-3`}),splitSuccessIcon:(0,q.jsx)(Rr,{className:`h-3 w-3 text-emerald-500`}),onSplitClick:e=>{p6(e)}}],[g]);return(0,q.jsx)(`div`,{className:`relative flex h-full flex-col bg-background text-left`,children:(0,q.jsxs)(`div`,{ref:l,className:`relative flex-1 min-h-0`,children:[(0,q.jsx)(_,{noteId:`canvas:home`,ariaLabel:`Home workout editor`,value:e,onChange:t,onBlocksChange:n,onStartWorkout:g,commands:v,onViewCreated:e=>{u.current=e,a&&h()},theme:i,readonly:!1,showLineNumbers:!1,showFrontmatter:!1,enableOverlay:!1,enableInlineRuntime:!1,autoFocus:!1,className:`h-full`}),a&&d&&(0,q.jsx)(`div`,{ref:s,"data-testid":`tour-wod-block-region`,"aria-hidden":!0,className:`pointer-events-none absolute`,style:{top:d.top,left:d.left,width:d.width,height:d.height}}),a&&p&&(0,q.jsx)(`div`,{ref:c,"data-testid":`tour-run-button-region`,"aria-hidden":!0,className:`pointer-events-none absolute`,style:{top:p.top,left:p.left,width:p.width,height:p.height}})]})})},lve=.9;function uve(e){let t=Number.isFinite(e.startTime)?e.startTime:0,n=[],r=[];for(let i of e.logs??[]){if(i.outputType!==`segment`||i.stackLevel!==1||i.line==null)continue;let e=i.timeSpan;if(!e||typeof e.started!=`number`||typeof e.ended!=`number`||e.ended<=e.started)continue;let a=i.metrics??[],o=e=>a.some(t=>t.type===e),s=a.find(e=>e.type===`effort`&&typeof e.value==`string`),c=o(`duration`)&&!o(`rep`)?`clock`:i.completionReason===`user-advance`?`next`:null;if(c){if(c===`clock`&&i.completionReason===`user-advance`){let t=a.find(e=>e.type===`duration`&&typeof e.value==`number`)?.value,n=a.find(e=>e.type===`total`&&typeof e.value==`number`)?.value;if(t!==void 0&&(n===void 0||n>=t*lve)&&t!==void 0){let n=t-(e.ended-e.started);n>0&&r.push(n)}}n.push({start:e.started-t,end:e.ended-t,kind:c,label:s?.value??`Line ${i.line+1}`})}}if(n.length===0)return null;let i=r.reduce((e,t)=>e+t,0);return{segments:n,totalMs:Number.isFinite(e.duration)&&e.duration>0?e.duration:Math.max(...n.map(e=>e.end)),impatienceMs:i,earlyClicks:r,reactions:n.filter(e=>e.kind===`next`).map(e=>e.end-e.start)}}var P6=e=>{let t=Math.max(0,Math.round(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},F6=e=>`${(Math.round(e/100)/10).toFixed(1)}s`;function dve({onRun:e}){return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center`,"data-testid":`tour-insights-empty`,children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-muted-foreground`,children:`Run the workout and this window turns your run into data — rest vs. work, how fast you answered the clock, round by round.`}),(0,q.jsxs)(J,{onClick:e,"data-testid":`tour-insights-run`,className:`min-h-11 rounded-full px-5 py-2.5 text-sm font-semibold shadow`,children:[(0,q.jsx)(Sr,{className:`size-4`,"aria-hidden":!0}),`Run to view the results`]})]})}function fve({onRun:e}){return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center`,"data-testid":Q.tour.INSIGHTS_RECORDED,children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-muted-foreground`,children:`Your run was saved — but this workout has nothing to measure yet. A line with a timer or a Next click turns into insights.`}),(0,q.jsxs)(J,{onClick:e,"data-testid":Q.tour.INSIGHTS_AGAIN,className:`min-h-11 rounded-full px-5 py-2.5 text-sm font-semibold shadow`,children:[(0,q.jsx)(Sr,{className:`size-4`,"aria-hidden":!0}),`Run again`]})]})}function pve({result:e,onRun:t}){let n=(0,K.useMemo)(()=>e?uve(e):null,[e]);if(!e)return(0,q.jsx)(dve,{onRun:t});if(!n)return(0,q.jsx)(fve,{onRun:t});let{segments:r,totalMs:i,impatienceMs:a,earlyClicks:o,reactions:s}=n,c=s.length>0?s.reduce((e,t)=>e+t,0)/s.length:0,l=s.length>0?Math.max(...s):0,u=o.length>0?Math.max(...o):0;return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`tour-insights`,children:[(0,q.jsxs)(`div`,{"data-testid":`tour-insights-timeline`,children:[(0,q.jsx)(`div`,{className:`flex h-3 w-full overflow-hidden rounded-full border border-border/60 bg-muted/40`,children:r.map((e,t)=>(0,q.jsx)(`div`,{title:`${e.label} — ${e.kind===`clock`?`countdown`:`to Next`} ${P6(e.end-e.start)}`,className:`h-full`,style:{flexGrow:e.end-e.start,flexBasis:0,backgroundColor:e.kind===`clock`?`hsl(var(--metric-rest))`:`hsl(var(--metric-time))`,marginLeft:+(t>0)}},t))}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-4 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-sm`,style:{backgroundColor:`hsl(var(--metric-rest))`}}),`Countdown`]}),(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-sm`,style:{backgroundColor:`hsl(var(--metric-time))`}}),`To Next click`]}),(0,q.jsxs)(`span`,{className:`ml-auto`,children:[P6(i),` total`]})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{"data-testid":`tour-insights-impatience`,className:`rounded-xl border border-border bg-card p-4`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Impatience Score`}),(0,q.jsx)(`p`,{className:`mt-2 text-2xl font-black tracking-tight tabular-nums text-foreground`,children:F6(a)}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o.length===0?`every countdown ran to zero`:`${o.length} early click${o.length===1?``:`s`}${o.length>1?` · worst ${F6(u)}`:``}`})]}),(0,q.jsxs)(`div`,{"data-testid":`tour-insights-reaction`,className:`rounded-xl border border-border bg-card p-4`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Reaction Time`}),(0,q.jsx)(`p`,{className:`mt-2 text-2xl font-black tracking-tight tabular-nums text-foreground`,children:s.length>0?F6(c):`—`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s.length===0?`no Next clicks yet`:`${s.length} click${s.length===1?``:`s`}${s.length>1?` · slowest ${F6(l)}`:``}`})]})]})]})}var I6=864e5;function L6(e){return Math.round(e*10)/10}function R6(e,t,n=9){let r=new Date(e-t*I6);return r.setHours(n,0,0,0),r.getTime()}function z6(e,t,n,r,i,a={}){let o={canonicalKey:i};a.effortSlug&&(o.effortSlug=a.effortSlug),a.discipline&&(o.effortDiscipline=a.discipline),a.intensityTier&&(o.effortIntensityTier=a.intensityTier),e.push({id:e.length,outputType:`analytics`,timeSpan:{started:0},metrics:[{type:Y.Label,value:t,origin:`analyzed`},{type:Y.Metric,value:n,unit:r,origin:`analyzed`,metadata:o}],sourceBlockKey:``,stackLevel:0})}var mve=new Set([`tis`,`calc.acwr`,`calc.adherence`,`calc.ef`,`calc.pct1rm`]);function B6(e,t){return sb(e,{noteId:t.noteId,resultId:t.resultId,blockId:`example-block`,blockVersion:1,blockContentId:t.blockContentId,origin:`journal`,workoutTimestamp:t.timestamp}).map(e=>{let t=e.metrics[0];if(!t||!(`metadata`in t))return e;let n=t.metadata?.canonicalKey;return typeof n!=`string`||!mve.has(n)||typeof t.value!=`number`?e:{...e,reducerStats:{observedCount:1,sum:t.value,min:t.value,max:t.value}}})}function hve(e=Date.now()){let t=[],n=new Map,r=[],i=[],a=(e,t)=>{let r=Wh(e);n.set(r,(n.get(r)??0)+t)};for(let n=0;n<16;n++){let o=(15-n)*7+1,s=R6(e,o);{let e=[{slug:`back-squat`,top:100+4*n,reps:5,tis:12.5},{slug:`bench-press`,top:80+2.5*n,reps:5,tis:10},{slug:`deadlift`,top:140+4*n,reps:3,tis:8.4}],r=[],i=0,o=0;for(let t of e){let e=t.reps*t.top;i+=e,o+=t.tis;let n={effortSlug:t.slug,discipline:`strength`,intensityTier:`high`};z6(r,`Total reps`,t.reps,`reps`,`totalReps`,n),z6(r,`Training intensity score`,t.tis,`pts`,`tis`,n),z6(r,`Total volume`,e,`kg`,`totalVolume`,n),z6(r,`Estimated 1RM`,L6(t.top*(1+t.reps/30)),`kg`,`calc.e1rm`,n),z6(r,`%1RM intensity`,L6(100/(1+t.reps/30)),`%`,`calc.pct1rm`,n)}let c=L6(i/100+13+o/10);z6(r,`Session load`,c,`AU`,`sessionLoad`,{discipline:`strength`,intensityTier:`high`}),t.push(...B6(r,{noteId:`example-strength-w${n}`,resultId:`example-strength-w${n}-r`,blockContentId:`example-content-strength`,timestamp:s})),a(s,c)}let c=R6(e,o+2);{let e=[],r;if(n%3==0){r=`high`;for(let[t,n,i,a]of[[`thruster`,45,2.2,42.5],[`pull-up`,45,1.6,0]]){let o={effortSlug:t,discipline:a?`strength`:`gymnastics`,intensityTier:r};z6(e,`Total reps`,n,`reps`,`totalReps`,o),z6(e,`Training intensity score`,L6(n*i),`pts`,`tis`,o),a&&z6(e,`Total volume`,n*a,`kg`,`totalVolume`,o)}}else if(n%3==1){r=`moderate`;let t=16+n%5;for(let[n,i,a]of[[`pull-up`,5,1.5],[`push-up`,10,1.2],[`air-squat`,15,1.1]]){let o=t*i,s={effortSlug:n,discipline:`gymnastics`,intensityTier:r};z6(e,`Total reps`,o,`reps`,`totalReps`,s),z6(e,`Training intensity score`,L6(o*a),`pts`,`tis`,s)}}else{r=`moderate`;for(let[t,n,i]of[[`double-under`,150,.5],[`sit-up`,150,1.3]]){let a={effortSlug:t,discipline:`gymnastics`,intensityTier:r};z6(e,`Total reps`,n,`reps`,`totalReps`,a),z6(e,`Training intensity score`,L6(n*i),`pts`,`tis`,a)}}let i=L6(30.6);z6(e,`Session load`,i,`AU`,`sessionLoad`,{intensityTier:r}),t.push(...B6(e,{noteId:`example-conditioning-w${n}`,resultId:`example-conditioning-w${n}-r`,blockContentId:`example-content-conditioning`,timestamp:c})),a(c,i)}let l=R6(e,o+4,8);if(n%4==1)r.push(Wh(l));else{let e=6e3+100*n,r=L6(e/2.8),o=[],s={effortSlug:`running`,discipline:`running`,intensityTier:`low`};z6(o,`Total distance`,e,`m`,`totalDistance`,s),z6(o,`Elapsed time`,r,`s`,`elapsed`,s),z6(o,`Training intensity score`,r,`pts`,`tis`,s);let c=L6(r/10);z6(o,`Session load`,c,`AU`,`sessionLoad`,{intensityTier:`low`}),t.push(...B6(o,{noteId:`example-run-w${n}`,resultId:`example-run-w${n}-r`,blockContentId:`example-content-run`,timestamp:l})),a(l,c),i.push({day:Wh(l),pace:e/r})}let u=R6(e,o+6,10);{let e=4e3+50*n,r=L6(e/2),i=[],o={effortSlug:`rowing`,discipline:`rowing`,intensityTier:`moderate`};z6(i,`Total distance`,e,`m`,`totalDistance`,o),z6(i,`Elapsed time`,r,`s`,`elapsed`,o),z6(i,`Training intensity score`,r,`pts`,`tis`,o);let s=L6(r/10);z6(i,`Session load`,s,`AU`,`sessionLoad`,{intensityTier:`moderate`}),t.push(...B6(i,{noteId:`example-row-w${n}`,resultId:`example-row-w${n}-r`,blockContentId:`example-content-row`,timestamp:u})),a(u,s)}}let o=Math.max(...n.keys()),s=(e,t=10)=>{let n=new Date(e*I6);return n.setHours(t,0,0,0),n.getTime()},c=(e,n,r)=>{let i=[];for(let[e,t,n]of r)z6(i,e,t,n,e);t.push(...B6(i,{noteId:`example-calc`,resultId:e,blockContentId:`example-content-calc`,timestamp:n}))};for(let e of cie(n,o))e.acwr!==void 0&&c(`example-calc-d${e.day}`,s(e.day),[[`calc.acwr`,L6(e.acwr),`ratio`]]);let l=0,u=0,d=Math.min(...n.keys());for(let e=d;e<=o;e++){let t=n.get(e)??0;l+=(t-l)/42,u+=(t-u)/7,n.has(e)&&c(`example-calc-pmc-d${e}`,s(e),[[`calc.ctl`,L6(l),`AU`],[`calc.atl`,L6(u),`AU`],[`calc.tsb`,L6(l-u),`AU`]])}let f=new Set([...n.keys()]);for(let e of r)f.add(e);for(let e of f){let t=+!!n.has(e);c(`example-calc-adh-d${e}`,s(e,7),[[`calc.adherence`,t,`ratio`]])}for(let e of i)c(`example-calc-ef-d${e.day}`,s(e.day,8),[[`calc.ef`,L6(e.pace/141*1e5),`pts`]]);return t}function gve(e=Date.now()){return new cx(qx(hve(e)))}var _ve=null;function vve(){return _ve??=gve()}var yve=[4,8,16],bve={parse(e){let t=Number.parseInt(e,10);return yve.includes(t)?t:null},serialize(e){return String(e)},withDefault(e){return{...this,defaultValue:e}}};function V6(){return V(`weeks`,bve.withDefault(16))}function xve({boardSlug:e}){let t=vve(),n=$P(),r=(0,K.useMemo)(()=>n?tU(n):[],[n]),i=(0,K.useMemo)(()=>r.find(t=>t.slug===e)??r[0],[r,e]),a=(0,K.useMemo)(()=>{if(!i?.rawContent)return null;try{let{meta:e,sections:t}=yx(i.rawContent);return qy(t,e)}catch{return null}},[i]),[o,s]=V6(),[c,l]=(0,K.useMemo)(()=>{let e=Date.now();return[e-o*7*864e5,e]},[o]),[u,d]=(0,K.useState)(null);return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col`,"data-testid":`tour-session-dashboard`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-5 pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-[11px] font-semibold uppercase tracking-wide text-primary`,children:i?.title??e}),(0,q.jsx)(`span`,{"data-testid":`tour-session-dashboard-source`,className:`flex-none rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:`Example data`})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(pO,{weeks:o,onWeeksChange:s})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-5 pb-5 pt-3 [&_[data-testid=dashboard-view]>div.grid]:grid-cols-1 [&_[data-testid=dashboard-view]>div.grid]:sm:grid-cols-2 [&_[data-testid=dashboard-view]>div.grid]:lg:grid-cols-2 [&_[data-testid=dashboard-view]>div.grid>*]:col-span-1`,children:a?(0,q.jsx)(fO,{document:a,executor:t,onInspectWidget:d,rangeStart:c,rangeEnd:l}):(0,q.jsx)(`p`,{className:`pt-8 text-center text-sm text-muted-foreground`,children:`Loading board…`})}),(0,q.jsx)(s3,{open:u!==null,onClose:()=>d(null),mode:`inspect`,initialWql:u?.body??`sum:totalVolume{}`,initial:u?{title:u.title,question:u.question,type:u.type,spanCols:u.spanCols,spanFull:u.spanFull,attributes:u.attributes}:void 0,executor:t,rangeStart:c,rangeEnd:l,tokenValues:a?Vy(a.tokens):void 0,onApply:void 0})]})}var Sve=[`analytics`,`boards`],Cve={analytics:{index:`01`,heading:`h2`,title:`Session Insights`,blurb:`Run the workout and this window turns your run into data — rest vs. work, how fast you answered the clock, round by round.`},boards:{index:`02`,heading:`h2`,title:`One Run Becomes Many`,blurb:`Dashboards let you visualise your progress — every recorded run rolls up into analytics boards. Aggregate results across flexible search criteria, from note frontmatter to session metrics: one run becomes many insights.`}};function H6({scope:e}){let t=Cve[e],n=t.heading;return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(n,{className:`flex items-baseline gap-4 text-balance text-[clamp(26px,3.2vw,44px)] font-extrabold leading-[1.1] tracking-[-0.03em]`,children:[t.index&&(0,q.jsx)(`span`,{className:`font-mono text-xs font-normal tracking-normal text-muted-foreground`,children:t.index}),(0,q.jsx)(`span`,{children:t.title})]}),(0,q.jsx)(`p`,{className:`mt-3 max-w-xl text-pretty text-[clamp(14px,1.2vw,18px)] leading-[1.65] text-muted-foreground`,children:t.blurb})]})}var U6=[{id:`road-to-560-total`,label:`Road to 560 Total`,title:`Road to 560 Total`},{id:`polarized-base-marathon`,label:`Polarized Base`,title:`Polarized Base Marathon`}];function W6({onClick:e}){return(0,q.jsxs)(`button`,{type:`button`,onClick:e,title:`Back to the editor`,"data-testid":`tour-pane-back-to-editor`,className:`relative flex shrink-0 items-center gap-1 rounded-md border border-border px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground transition-colors hover:bg-accent hover:text-foreground after:absolute after:-inset-2 after:content-['']`,children:[(0,q.jsx)(Ut,{className:`size-3`}),`Editor`]})}var G6=(0,K.memo)(function({session:e,onRun:t,onBackToEditor:n}){let[r,i]=(0,K.useState)(`analytics`),[a,o]=(0,K.useState)(0),s=U6[a],c=(0,K.useRef)(new Map);(0,K.useEffect)(()=>{if(typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target.getAttribute(`data-scope`);(e===`analytics`||e===`boards`)&&i(e)}},{rootMargin:`-45% 0px -45% 0px`});return c.current.forEach(t=>e.observe(t)),()=>e.disconnect()},[]);let l=e=>t=>{t?c.current.set(e,t):c.current.delete(e)},u=r=>r===`analytics`?(0,q.jsx)(i2,{title:`Session Insights`,className:`h-full`,headerActions:(0,q.jsx)(W6,{onClick:n}),children:(0,q.jsx)(pve,{result:e,onRun:t})}):(0,q.jsxs)(Ht,{value:s.id,onValueChange:e=>{let t=U6.findIndex(t=>t.id===e);t>=0&&o(t)},className:`flex h-full flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(nn,{"aria-label":`Dashboard slides`,className:`flex flex-wrap gap-1 border-b-0 rounded-lg border border-border bg-muted/30 p-1`,children:U6.map(e=>(0,q.jsx)(Ae,{value:e.id,"data-testid":`dashboard-slide-tab-${e.id}`,className:`min-h-11 rounded-md border-0 px-3 py-1.5 text-xs font-semibold transition-colors text-muted-foreground hover:text-foreground data-selected:bg-background data-selected:text-foreground data-selected:shadow`,children:e.label},e.id))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e=>(e+U6.length-1)%U6.length),"aria-label":`Previous dashboard`,"data-testid":`dashboard-slide-prev`,className:`flex size-11 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,q.jsx)(j,{className:`size-4`,"aria-hidden":`true`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e=>(e+1)%U6.length),"aria-label":`Next dashboard`,"data-testid":`dashboard-slide-next`,className:`flex size-11 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,q.jsx)(ee,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,q.jsx)(i2,{title:s.title,className:`min-h-0 flex-1`,headerActions:(0,q.jsx)(W6,{onClick:n}),children:(0,q.jsx)(ie,{value:s.id,className:`flex h-full w-full flex-col p-0`,children:(0,q.jsx)(xve,{boardSlug:s.id})})}),(0,q.jsxs)(`p`,{className:`text-center font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground`,children:[a+1,` / `,U6.length]})]}),d=(0,q.jsx)(`div`,{"data-testid":`tour-sticky-pane`,className:`sticky top-[104px] flex h-[calc(100dvh-104px)] flex-col items-center justify-center self-start`,children:(0,q.jsx)(`div`,{className:`relative w-full max-w-[700px]`,children:(0,q.jsx)(`div`,{className:`relative h-[460px]`,children:Sve.map(e=>(0,q.jsx)(`div`,{"aria-hidden":r!==e,"data-scope-active":r===e,className:$(`absolute inset-0 transition-opacity duration-500`,r===e?`opacity-100`:`invisible opacity-0`),children:u(e)},e))})})}),f=(e,t)=>(0,q.jsx)(`div`,{ref:l(e),"data-scope":e,className:`flex min-h-[85vh] flex-col justify-center scroll-mt-[104px]`,...t,children:(0,q.jsx)(H6,{scope:e})}),p=e=>(0,q.jsxs)(`div`,{id:e===`boards`?`tour-section-boards`:void 0,"data-testid":`tour-step-mobile-${e}`,"data-scope":e,className:`flex scroll-mt-[72px] flex-col gap-4`,children:[(0,q.jsx)(H6,{scope:e}),(0,q.jsx)(`div`,{className:e===`analytics`?`h-[340px] sm:h-[420px]`:`h-[460px]`,children:u(e)})]}),m=oY();return(0,q.jsx)(`section`,{id:`tour-section-insights`,"data-testid":`tour-section-insights`,className:`border-b border-border/60`,children:m?(0,q.jsxs)(`div`,{className:`flex flex-col gap-12 px-5 py-14`,children:[p(`analytics`),p(`boards`)]}):(0,q.jsxs)(`div`,{className:`mx-auto grid max-w-[1500px] gap-10 px-5 py-14 lg:grid-cols-2 lg:gap-16 lg:px-12 lg:py-0 xl:px-16 2xl:max-w-[1720px]`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`div`,{id:`tour-scroll-target-insights`,className:`scroll-mt-[104px]`,children:f(`analytics`)}),f(`boards`,{id:`tour-section-boards`,"data-testid":`tour-section-boards`})]}),d]})})});function wve(e){let t=e.match(/^notebook\.(.+)$/);return t?{slug:t[1]}:null}function Tve(e){let t=e.items.map(e=>e.date).filter(e=>!!e).sort();return{packageId:`local-notebooks-${e.id}`,slug:e.id,label:e.name,description:e.description,image:e.image,categories:e.categories,sourceLabel:`Local`,href:`/notebook/${encodeURIComponent(e.id)}`,itemCount:e.items.length,...t.length>0?{latestDate:t[t.length-1],firstDate:t[0]}:{},...e.readme===void 0?{}:{readme:e.readme},installed:!0}}function Eve(e,t,n){let r=[],i=new Map;if(t)for(let e of IP(`notebooks`,t))i.set(e.id,e),r.push(Tve(e));let a=e.map(e=>{let t=wve(e.chunkId);if(!t)return null;let r=i.get(t.slug),a=yI(e.feedId),o=(r?.items??[]).map(e=>e.date).filter(e=>!!e).sort();return{packageId:e.id,feedId:e.feedId,chunkId:e.chunkId,slug:t.slug,label:e.label,description:e.description||r?.description,image:r?.image,categories:r?.categories??[],sourceLabel:a?.label??e.feedId,...a?.repositoryUrl?{repositoryUrl:a.repositoryUrl}:{},href:`/notebook/${encodeURIComponent(t.slug)}`,itemCount:r?.items.length??0,...o.length>0?{latestDate:o[o.length-1],firstDate:o[0]}:{},...r?.readme===void 0?{}:{readme:r.readme},installed:!!r,subscribed:!n||n(e.feedId,e.chunkId)}}).filter(e=>e!==null),o=new Set(a.map(e=>e.slug));return[...a,...r.filter(e=>!o.has(e.slug)),...Dve(t)]}function Dve(e){return zs.filter(e=>e.feedEntryId===`core`&&e.slug!==`guides`&&typeof e.seedChunkId==`string`).map(t=>{let n=`markdown/${t.slug}/`,r=e?Object.keys(e).filter(e=>e.startsWith(n)&&e.endsWith(`.md`)&&!e.endsWith(`/README.md`)):[];return{packageId:`core-${t.slug}`,feedId:`core`,chunkId:t.seedChunkId,slug:t.slug,label:t.name,description:t.description,categories:[],sourceLabel:`Core`,href:t.href,itemCount:r.length,installed:e?r.length>0:!1,subscribed:!0}})}function Ove(e,t){let n={},r=[],i=new Set(t.map(e=>e.id));for(let t of e)t.feedId&&i.has(t.feedId)?(n[t.feedId]??=[]).push(t):r.push(t);let a=[];for(let e of t){let t=n[e.id];t?.length&&a.push({feed:e,label:e.label,...e.description?{description:e.description}:{},url:e.url,...e.repositoryUrl?{repositoryUrl:e.repositoryUrl}:{},notebooks:t})}return r.length>0&&a.push({label:`Local`,notebooks:r}),a}function kve(e,t,n,r){return Ove(Eve(e,t,r),n).map(e=>{let t=e.notebooks.map(e=>e.latestDate).filter(e=>!!e).sort();return{feedId:e.feed?.id,slug:e.feed?.id??`local`,label:e.label,...e.description?{description:e.description}:{},...e.url?{url:e.url}:{},...e.repositoryUrl?{repositoryUrl:e.repositoryUrl}:{},notebooks:e.notebooks,itemCount:e.notebooks.reduce((e,t)=>e+t.itemCount,0),installed:e.notebooks.every(e=>e.installed),subscribed:e.notebooks.some(e=>e.subscribed),...t.length>0?{latestDate:t[t.length-1]}:{},href:`/notebooks`}})}function Ave(e,t){let n=t.text?.trim().toLowerCase();return e.filter(e=>t.feedId&&e.feedId!==t.feedId||t.subscribedOnly&&!e.notebooks.some(e=>e.subscribed)?!1:!n||e.label.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)||e.notebooks.some(e=>e.label.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)))}function jve(e,t){let n=[...e];switch(t){case`name`:return n.sort((e,t)=>e.label.localeCompare(t.label));case`size`:return n.sort((e,t)=>t.itemCount-e.itemCount||e.label.localeCompare(t.label));default:return n.sort((e,t)=>e.latestDate&&t.latestDate?t.latestDate.localeCompare(e.latestDate):e.latestDate?-1:t.latestDate?1:e.label.localeCompare(t.label))}}var K6=[`bg-rose-500/12 text-rose-600 dark:text-rose-400`,`bg-amber-500/12 text-amber-600 dark:text-amber-400`,`bg-emerald-500/12 text-emerald-600 dark:text-emerald-400`,`bg-sky-500/12 text-sky-600 dark:text-sky-400`,`bg-violet-500/12 text-violet-600 dark:text-violet-400`,`bg-cyan-500/12 text-cyan-600 dark:text-cyan-400`];function Mve(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return K6[Math.abs(t)%K6.length]}function Nve(e){return(e.match(/[a-z0-9]/i)?.[0]??`•`).toUpperCase()}function Pve(e){if(!e)return null;let t=new Date(`${e}T00:00:00`);return isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}var Fve=4;function q6({feed:e,testId:t=`feed-card`,className:n,onImport:r,importing:i,busy:a,status:o,onToggleNotebookSubscription:s}){let[c,l]=Mve(e.slug).split(` `),u=Pve(e.latestDate),d=e.notebooks.slice(0,Fve),f=e.notebooks.length-d.length,p=e.feedId?SH(e.feedId):e.href,m=e.installed&&e.feedId?e.href:p,h=e.notebooks.find(e=>e.image)?.image,g=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[e.notebooks.length,` `,e.notebooks.length===1?`notebook`:`notebooks`]}),e.installed&&e.itemCount>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[e.itemCount,` `,e.itemCount===1?`item`:`items`]})]}),e.installed&&u&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[`updated `,u]})]}),!e.installed&&(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),!e.installed&&(0,q.jsx)(`span`,{children:e.subscribed?`index active`:`not subscribed`})]}),_=(0,q.jsx)(`div`,{className:$(`relative overflow-hidden bg-muted/40 aspect-[16/10]`,c),children:h?(0,q.jsx)(`img`,{src:h,alt:``,loading:`lazy`,className:`absolute inset-0 size-full object-cover`}):(0,q.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:[(0,q.jsx)(`span`,{className:$(`text-7xl font-black tracking-tighter select-none`,l),"aria-hidden":`true`,children:Nve(e.label)}),(0,q.jsx)(W,{className:$(`absolute bottom-4 right-4 size-6 opacity-50`,l),"aria-hidden":`true`})]})});return(0,q.jsxs)(`article`,{"data-testid":t,"data-installed":e.installed,className:$(`group relative flex flex-col overflow-hidden rounded-2xl border border-border bg-card`,`transition-colors hover:border-foreground/25 focus-within:border-foreground/25`,n),children:[(0,q.jsx)(M,{to:m,"data-testid":`${t}-open`,className:`block outline-none no-underline`,"aria-label":`Open ${e.label}`,children:_}),(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:`min-w-0 text-sm font-bold leading-snug text-foreground`,children:(0,q.jsx)(M,{to:m,className:`no-underline text-foreground transition-colors hover:text-primary`,children:e.label})}),e.installed||!r||!e.feedId?(0,q.jsx)(M,{to:m,"data-testid":`${t}-cta`,"aria-label":`Open ${e.label}`,className:`no-underline flex min-h-11 min-w-11 size-11 shrink-0 items-center justify-center rounded-full border border-border text-muted-foreground transition-colors hover:border-primary/50 hover:text-primary`,children:(0,q.jsx)(ae,{className:`size-3.5`,"aria-hidden":`true`})}):(0,q.jsxs)(`button`,{type:`button`,"data-testid":`${t}-import`,disabled:i||a,onClick:()=>r(e.feedId),className:$(`flex min-h-11 shrink-0 items-center gap-1.5 rounded-full border px-4`,`text-[11px] font-bold uppercase tracking-wider`,`border-primary/30 bg-primary/10 text-primary`,`transition-colors hover:bg-primary/20`,`disabled:cursor-wait disabled:opacity-60`),children:[i?(0,q.jsx)(ot,{className:`size-3 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(yr,{className:`size-3`,"aria-hidden":`true`}),i?`Importing`:`Subscribe`]})]}),e.description&&(0,q.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-muted-foreground text-pretty`,children:e.description}),e.notebooks.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`${t}-notebooks`,children:[d.map(n=>{let r=n.installed?n.href:`${n.href}${e.feedId?`?feed=${encodeURIComponent(e.feedId)}`:``}`,i=!!(s&&e.feedId&&n.chunkId);return(0,q.jsxs)(`span`,{"data-testid":`${t}-notebook-${n.packageId}`,className:$(`inline-flex items-center gap-1 rounded-full border text-[11px] font-semibold tracking-wide transition-colors`,i?`pl-2.5 pr-1 py-0.5`:`px-2.5 py-1`,n.subscribed?`border-emerald-600/30 bg-emerald-100 text-emerald-800 dark:border-emerald-500/30 dark:bg-emerald-500/15 dark:text-emerald-300`:`border-border text-muted-foreground`),children:[(0,q.jsx)(M,{to:r,className:`no-underline text-current hover:text-primary`,children:n.label}),i&&(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e.feedId,n.chunkId,!n.subscribed)},title:n.subscribed?`Unsubscribe ${n.label}`:`Subscribe ${n.label}`,"aria-label":n.subscribed?`Unsubscribe ${n.label}`:`Subscribe ${n.label}`,"data-testid":`${t}-notebook-toggle-${n.packageId}`,className:`inline-flex size-7 items-center justify-center rounded-full font-bold hover:bg-foreground/10 hover:text-foreground`,children:n.subscribed?`✓`:`+`})]},n.packageId)}),f>0&&(0,q.jsxs)(`span`,{className:`rounded-full border border-dashed border-border px-2.5 py-1 text-[11px] font-semibold tracking-wide text-muted-foreground`,children:[`+`,f,` more`]})]}),(0,q.jsxs)(`div`,{className:`mt-auto pt-1`,children:[g,o&&(0,q.jsx)(`p`,{role:o.tone===`error`?`alert`:`status`,"data-testid":`${t}-status`,className:$(`mt-1.5 flex items-start gap-1.5 text-xs`,o.tone===`error`?`text-destructive`:`text-muted-foreground`),children:(0,q.jsx)(`span`,{children:o.text})})]})]})]})}function J6({direction:e,children:t,testId:n,className:r}){let i=(0,K.useRef)(null),a=(0,K.useRef)(null),[o,s]=(0,K.useState)(1),c=n2(`(prefers-reduced-motion: reduce)`);(0,K.useEffect)(()=>{let e=i.current,t=a.current;if(!e||!t)return;let n=()=>{let n=o*2,r=t.scrollWidth/n;if(r<=0)return;let i=Math.max(1,Math.ceil(e.clientWidth/r));i!==o&&s(i)};n();let r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[o,t]);let l=c?1:o*2;return(0,q.jsx)(`div`,{ref:i,"data-testid":n,className:$(`wod-marquee`,c?`overflow-x-auto px-4 sm:px-6`:`overflow-hidden [mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-16px),transparent)] sm:[mask-image:linear-gradient(to_right,transparent,black_48px,black_calc(100%-48px),transparent)]`,r),children:(0,q.jsx)(`div`,{ref:a,className:$(`flex w-max`,!c&&`wod-marquee-track`,!c&&e===`left`&&`wod-marquee-track--left`,!c&&e===`right`&&`wod-marquee-track--right`,!c&&e===`alternate`&&`wod-marquee-track--left wod-marquee-track--alternate`),children:Array.from({length:l},(e,n)=>(0,q.jsx)(`div`,{"data-marquee-copy":n,"aria-hidden":n>0,inert:n>0,className:`flex shrink-0 items-stretch gap-4 pr-4`,children:t},n))})})}var Ive=[{value:`updated`,label:`Updated`},{value:`name`,label:`Name`},{value:`size`,label:`Size`}],Y6=`group flex flex-col justify-between rounded-2xl border border-border bg-card p-5 text-left transition-colors hover:border-primary/40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`;function X6(e){let t=e.icon;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-foreground text-background`,children:(0,q.jsx)(t,{className:`size-5`,"aria-hidden":!0})}),(0,q.jsx)(`h3`,{className:`mt-4 text-base font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:e.description})]}),e.note?(0,q.jsx)(`span`,{className:`mt-4 text-xs font-medium text-muted-foreground`,children:e.note}):(0,q.jsxs)(`span`,{className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,q.jsx)(`span`,{children:e.action}),(0,q.jsx)(ae,{className:`size-4 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})]})}var Z6=(0,K.memo)(function({feedDeps:e}={}){let t=(0,K.useMemo)(()=>({isNotebookSubscribed:WI,setNotebookSubscribed:GI,setFeedSubscribed:UI,subscribeFeedSubscriptions:qI,syncFeedSource:oV,readFeedCoverage:fV,...e}),[e]),n=dt(),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(`updated`),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)({}),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(),[_,v]=(0,K.useState)(0);(0,K.useEffect)(()=>t.subscribeFeedSubscriptions(()=>v(e=>e+1)),[t]);let y=l!==null,b=$P(),x=n2(`(min-width: 1024px)`),S=(0,K.useMemo)(()=>kve(wI(),b,CI(),(e,n)=>t.isNotebookSubscribed(e,n)),[b,_,t]),C=(0,K.useMemo)(()=>jve(Ave(S,{text:r,feedId:h,subscribedOnly:p}),s),[S,r,s,h,p]),w=Math.ceil(C.length/2),T=C.slice(0,w),E=C.slice(w),D=(0,K.useCallback)(()=>{QR.record($R.libraryOpened)},[]),[O,k]=(0,K.useState)(!0);(0,K.useEffect)(()=>{let e=!1,n=()=>{t.readFeedCoverage().then(t=>{e||k(t.libraryImported)}).catch(()=>{})};n();let r=t.subscribeFeedSubscriptions(n);return()=>{e=!0,r()}},[y,t]);let A=(0,K.useCallback)(async e=>{if(l)return;u(e);let n=t=>f(n=>({...n,[e]:t}));n({text:`Checking the feed…`,tone:`muted`});try{let r=await t.syncFeedSource(e,{onProgress:e=>n({text:qX(e),tone:`muted`})});n(r===`imported`||r===`current`?{text:t.setFeedSubscribed(e,!0)?r===`imported`?`Imported — this feed is available offline.`:`Already up to date.`:`Subscribed for this session only — browser storage is unavailable.`,tone:`muted`}:{text:r===`server-stale`?`Published version is older than stored copy.`:r===`busy`?`Another tab is syncing. Try again shortly.`:`Sync failed. Check connection and try again.`,tone:`error`})}catch(e){n({text:e instanceof Error?e.message:String(e),tone:`error`})}finally{u(null)}},[l,t]),j=(0,K.useCallback)(async(e,n,r)=>{t.setNotebookSubscribed(e,n,r),r&&t.syncFeedSource(e,{force:!1})},[t]),N=(0,K.useCallback)(async()=>{let e=uU(),t=await CU.create({journalDate:e,title:e,rawContent:``});QR.record($R.noteCreated),n(vH(t.id))},[n]),P=!!(r.trim()||h||p),F=!!(h||p||s!==`updated`),I=(0,K.useMemo)(()=>CI(),[]);return(0,q.jsxs)(`section`,{id:`tour-section-community-feeds`,"data-testid":`tour-jump-section`,className:`flex flex-col border-b border-border bg-muted/20 pb-8 xl:pb-12`,"aria-label":`Library and community feeds`,children:[(0,q.jsx)(C3,{index:`03`,before:`Library & `,accentText:`Community Feeds`,after:``,accent:``,blurb:`Subscribe to a feed — one Markdown repository compiled with npx wod build into a versioned manifest, served from its own GitHub Pages. One Subscribe imports every notebook the feed publishes; browse the feeds below, notebooks and all.`}),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`label`,{className:`relative w-full sm:w-64`,children:[(0,q.jsx)(Jr,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground/60`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:`Search feeds…`,"aria-label":`Search feeds`,"data-testid":`package-search-input`,className:`h-11 w-full rounded-full border border-border bg-background pl-9 pr-9 text-base lg:text-sm text-foreground placeholder:text-muted-foreground outline-none transition-colors focus:border-primary/50`}),r&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(``),"aria-label":`Clear search`,className:`absolute right-0 top-1/2 -translate-y-1/2 size-11 inline-flex items-center justify-center text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(ze,{className:`size-3.5`})})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-controls":`jump-filters-panel`,"data-testid":Q.tour.JUMP_FILTERS_TOGGLE,className:$(`ml-auto inline-flex min-h-11 items-center gap-1.5 rounded-full border bg-background px-3 text-[10px] font-black uppercase tracking-widest transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,F?`border-primary/50 text-foreground hover:border-primary`:`border-border text-muted-foreground hover:border-foreground/25 hover:text-foreground`),children:[`Filters`,F&&!a&&(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,"aria-hidden":!0}),(0,q.jsx)(rt,{className:$(`size-3.5 transition-transform`,a&&`rotate-180`),"aria-hidden":!0})]}),(0,q.jsx)(`div`,{id:`jump-filters-panel`,"data-testid":Q.tour.JUMP_FILTERS_PANEL,className:$(`w-full flex-wrap items-center gap-2 pt-1`,a?`flex`:`hidden`),children:a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 cursor-pointer select-none text-muted-foreground hover:text-foreground px-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),"data-testid":`filter-subscribed-only`,className:`size-4 accent-primary rounded`}),(0,q.jsx)(`span`,{className:`text-[10px] font-black uppercase tracking-widest`,children:`Subscribed only`})]}),(0,q.jsxs)(`select`,{value:h??``,onChange:e=>g(e.target.value?e.target.value:void 0),"aria-label":`Filter by feed`,"data-testid":`filter-feed-source`,className:`min-h-11 h-11 rounded-full border border-border bg-background px-3 text-base font-semibold uppercase tracking-widest text-muted-foreground outline-none transition-colors hover:border-foreground/25 focus:border-primary/50 lg:text-[10px] lg:font-black`,children:[(0,q.jsx)(`option`,{value:``,children:`All feeds`}),I.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`group`,"aria-label":`Sort feeds`,children:Ive.map(e=>{let t=s===e.value;return(0,q.jsx)(`button`,{type:`button`,"aria-pressed":t,"data-testid":`package-sort-${e.value}`,onClick:()=>c(e.value),className:$(`inline-flex min-h-11 items-center justify-center rounded-full px-3 text-[10px] font-black uppercase tracking-widest transition-colors`,t?`bg-foreground text-background`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value)})})]})})]}),(0,q.jsx)(`div`,{"data-testid":`jump-grid`,className:`mt-6`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[O?(0,q.jsx)(M,{to:`/notebooks`,onClick:D,"data-testid":`jump-library`,className:Y6,children:(0,q.jsx)(X6,{icon:qe,title:`Library`,description:`Curated workouts and sessions, organized by tag.`,action:`Open the library`})}):(0,q.jsx)(`div`,{"data-testid":`jump-library`,"aria-disabled":`true`,className:`${Y6} cursor-not-allowed opacity-60`,children:(0,q.jsx)(X6,{icon:qe,title:`Library`,description:`Curated workouts and sessions, organized by tag.`,action:`Open the library`,note:`0 feeds synchronized`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{N()},"data-testid":`jump-new-note`,className:Y6,children:(0,q.jsx)(X6,{icon:ye,title:`Start your own journal`,description:`Create today's note and log your first workout.`,action:`Create today's note`})})]})})]}),(0,q.jsx)(`div`,{"data-testid":`jump-rows`,className:`mt-6`,children:C.length>0?x?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(J6,{direction:`left`,testId:`jump-row-a`,children:T.map(e=>(0,q.jsx)(q6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] sm:w-[320px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))}),E.length>0&&(0,q.jsx)(J6,{direction:`right`,testId:`jump-row-b`,className:`mt-4`,children:E.map(e=>(0,q.jsx)(q6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] sm:w-[320px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))})]}):(0,q.jsx)(J6,{direction:`alternate`,testId:`jump-row-mobile`,children:C.map(e=>(0,q.jsx)(q6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))}):(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:(0,q.jsxs)(`div`,{"data-testid":`jump-empty`,className:`flex flex-col items-center justify-center rounded-2xl border border-dashed border-border p-10 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-bold text-muted-foreground`,children:`No feeds match your search.`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Try a different term or clear the filters.`}),P&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`jump-clear-filters`,onClick:()=>{i(``),g(void 0),m(!1)},className:`mt-3 inline-flex min-h-11 items-center justify-center rounded-full border border-border px-4 text-[10px] font-black uppercase tracking-widest text-muted-foreground transition-colors hover:border-primary/50 hover:text-primary`,children:`Clear filters`})]})})}),(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:(0,q.jsx)(`p`,{className:`mt-4 font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground xl:text-[11px]`,children:`— or keep scrolling ↓`})})]})}),Lve=`wods/examples/home/welcome-1.md`;function Rve({wodFiles:e,theme:t,quests:n,editorSlot:r,timerSlot:i,deps:a,jumpFeedDeps:o}){let s=a?.usePlaygroundRun??q0,c=a?.useQuickStartAutoComplete??t2,l=a?.useCompletionChallenge??e2,u=a?.useRunStartedChallenge??W_e,d=a?.useTourScrollQuests??q_e,f=a?.toast??pQ,p=n2(`(prefers-reduced-motion: reduce)`),m=ez()?.track;nz(`/`);let h=(0,K.useMemo)(()=>rY(Lve,e),[e]),[g,_]=(0,K.useState)(()=>H_e()),v=g?.content??h,y=g?g.by?.trim()||`anonymous`:void 0;(0,K.useEffect)(()=>{let e=e=>{let t=e.detail;t?.content&&(_(t),x(t.content))};return window.addEventListener(`wodwiki:home-shared`,e),()=>window.removeEventListener(`wodwiki:home-shared`,e)},[]);let[b,x]=(0,K.useState)(v),S=(0,K.useRef)(b);S.current=b;let C=(0,K.useRef)([]),w=(0,K.useRef)(!1),{run:T,start:E,finalize:D,end:O}=s(),k=(0,K.useRef)(T);k.current=T;let A=(0,K.useRef)(!1),j=(0,K.useRef)(!1),N=(0,K.useRef)(null),[P,F]=(0,K.useState)(!1),I=(0,K.useRef)(!1),ee=(0,K.useRef)(null),[L,R]=(0,K.useState)(null),[z,B]=(0,K.useState)(!1),V=(0,K.useRef)(z);V.current=z;let H=(0,K.useRef)(!1),U=(0,K.useRef)(()=>{}),[te,W]=(0,K.useState)(0),[ne,re]=(0,K.useState)(!1),[ie,ae]=(0,K.useState)(!1),[oe,se]=(0,K.useState)(null),ce=(0,K.useCallback)(async(e,t,n)=>{if(!t||H.current)return!1;H.current=!0,j.current=!1,A.current=!1,N.current=null,se(t),W(e=>e+1),re(!0),R(null),B(!0);try{await E(e,t,{pageTitle:`Home`,sectionTitle:n})}catch(e){return console.error(`[HomeTour] failed to persist playground run note:`,e),B(!1),se(null),f({title:`Could not start workout`,description:`The playground entry could not be saved.`,variant:`destructive`}),!1}finally{H.current=!1}return!0},[E]),le=(0,K.useCallback)(async()=>{if(I.current=!1,F(!1),N.current)try{await D(N.current,!1),N.current=null}catch(e){console.error(`[HomeTour] retry save failed:`,e),f({title:`Session still not saved`,description:`The run is kept — try again.`,variant:`destructive`});return}let e=ee.current;if(ee.current=null,e)switch(e.kind){case`apply-doc`:w.current=!1,x(e.doc),B(!1),se(null),W(e=>e+1),re(!1);break;case`restart`:await ce(e.doc,e.block,e.sectionTitle)}},[ce,D]),ue=(0,K.useCallback)(e=>{if(!ee.current){if(!k.current||j.current||!A.current||N.current){ee.current=e,le();return}ee.current=e,I.current=!0,F(!0)}},[le]),de=(0,K.useRef)(null),fe=(0,K.useRef)(null),pe=(0,K.useRef)(null);Lhe(`hero`,pe);let[me,he]=(0,K.useState)(!1),ge=(0,K.useRef)(me);ge.current=me;let _e=(0,K.useRef)(null),ve=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{ve.current?.(),ve.current=null},[]);let ye=(0,K.useCallback)(e=>{ve.current?.(),ve.current=null;let t=!1,n=0,r=0,i=_e.current,a=e=>{e.target===i&&(!i||i.getBoundingClientRect().height<=1)&&s()},o=()=>{t=!0,n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),i?.removeEventListener(`transitionend`,a),ve.current===o&&(ve.current=null)},s=()=>{t||(t=!0,o(),e())};ve.current=o;let c=()=>{if(!t){if(p||!i||i.getBoundingClientRect().height<=1){s();return}i.addEventListener(`transitionend`,a),r=window.setTimeout(s,350)}};typeof requestAnimationFrame==`function`?n=requestAnimationFrame(()=>{n=0,c()}):c()},[p]),be=(0,K.useCallback)(()=>{let e=document.getElementById(`tour-section-editor`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,e.getBoundingClientRect().top+window.scrollY-n),behavior:p?`auto`:`smooth`})},[p]),xe=(0,K.useCallback)(()=>{he(!0),ye(be)},[ye,be]),Se=(0,K.useCallback)(()=>{ve.current&&=(ve.current(),null),he(!1),window.scrollTo({top:0,behavior:p?`auto`:`smooth`})},[p]),Ce=(0,K.useRef)(!1),we=b!==v,Te=(0,K.useRef)(we);Te.current=we;let Ee=(0,K.useCallback)(()=>{ue({kind:`apply-doc`,doc:v})},[v,ue]);(0,K.useEffect)(()=>{let e=fe.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting?Ce.current&&!V.current&&(Ce.current=!1,Te.current||Ee()):Ce.current=!0});return t.observe(e),()=>t.disconnect()},[Ee]);let G=(0,K.useCallback)(()=>{U_e(),_(null),ue({kind:`apply-doc`,doc:h})},[h,ue]),De=(0,K.useCallback)(()=>{ve.current&&=(ve.current(),null),ue({kind:`apply-doc`,doc:S.current});let e=document.getElementById(`tour-section-editor`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,e.getBoundingClientRect().top+window.scrollY-n),behavior:p?`auto`:`smooth`})},[p,ue]);c({pageRoute:`/`,quests:n,initialSource:v,currentSource:b}),l({pageRoute:`/`,quests:n,completedResults:L}),U.current=d(`/`,n),u({pageRoute:`/`,quests:n,running:ie}),(0,K.useEffect)(()=>{let e=document.getElementById(`tour-section-insights`);if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting&&U.current?.(`session-insights`)});return t.observe(e),()=>t.disconnect()},[]);let Oe=(0,K.useCallback)(e=>{x(e),e!==v&&!w.current&&(w.current=!0,m?.($R.demoEdited))},[v,m]),ke=(0,K.useCallback)(e=>{C.current=e},[]),Ae=(0,K.useCallback)((e,t,n,r)=>{if(n){if(m?.($R.demoRun),r&&ae(!0),se(n),B(!0),re(!0),W(e=>e+1),R(null),H.current||ee.current){ee.current={kind:`restart`,doc:t,block:n,sectionTitle:e};return}if(k.current&&A.current&&!j.current){ee.current={kind:`restart`,doc:t,block:n,sectionTitle:e},I.current=!0,F(!0);return}if(k.current&&!j.current){O().then(()=>ce(t,n,e));return}ce(t,n,e)}},[ce,O,m]),je=(0,K.useCallback)(()=>{Ae(`Run`,S.current,C.current[0],!0)},[Ae]),Me=(0,K.useCallback)(()=>{ge.current||he(!0),ye(()=>{let e=document.getElementById(`tour-section-insights`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY,r=Math.max(0,e.getBoundingClientRect().top+window.scrollY-n);window.scrollTo({top:r,behavior:p?`auto`:`smooth`})})},[p,ye]),Ne=(0,K.useCallback)((e,t)=>{if(!(j.current&&!N.current))return(t.logs??[]).length===0?(j.current=!0,R(t),B(!1),Me(),le()):(j.current=!0,D(t,t.completed).then(()=>{if(N.current=null,R(t),I.current||ee.current)return B(!1),le()}).catch(e=>{throw j.current=!1,A.current=!1,N.current=t,I.current=!1,F(!1),ee.current=null,f({title:`Session not saved`,description:`The run could not be recorded. Nothing was lost — your next action retries the save.`,variant:`destructive`}),e}))},[D,le,Me]),Pe=(0,K.useCallback)(()=>{B(!1),Me()},[Me]),Fe=(0,K.useRef)(null),Ie=(0,K.useCallback)(e=>{Fe.current=e},[]),Le=(0,K.useCallback)(()=>{A.current=!0;let e=Fe.current;ne&&e&&e.handle(new Nh(void 0,e.nowProvider)),re(!1)},[ne]),{setL3Items:Re}=MV(),ze=(0,K.useMemo)(()=>[{id:`tour-hero`,label:`Welcome`,level:3,action:{type:`scroll`,sectionId:`tour-hero`}},{id:`editor`,label:`Live Preview`,level:3,action:{type:`scroll`,sectionId:`tour-section-editor`}},{id:`insights`,label:`Session Insights`,level:3,action:{type:`scroll`,sectionId:`tour-section-insights`},secondaryAction:{id:`run-start`,label:`Run the workout`,action:{type:`call`,handler:je}}},{id:`boards`,label:`One Run Becomes Many`,level:3,action:{type:`scroll`,sectionId:`tour-section-boards`}},{id:`community-feeds`,label:`Library & Community Feeds`,level:3,action:{type:`scroll`,sectionId:`tour-section-community-feeds`}},{id:`offerings`,label:`Who owns the Data?`,level:3,action:{type:`scroll`,sectionId:`tour-section-offerings`}},{id:`university`,label:`Wod Wiki University`,level:3,action:{type:`scroll`,sectionId:`tour-section-university`}}],[je]);(0,K.useEffect)(()=>(Re(ze),()=>Re([])),[Re,ze]),Y_e((0,K.useMemo)(()=>ze.map(e=>e.action.type===`scroll`?e.action.sectionId:e.id),[ze]));let Be=T?.block??oe,Ve=z&&Be&&(0,q.jsx)(i??B2,{block:Be,resultId:T?.resultId,autoStart:ne,externalStop:P,onRunStarted:Le,onRuntimeReady:Ie,onClose:Pe,onCompleteWorkout:Ne},te),He=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(M6,{}),(0,q.jsxs)(`p`,{className:`-mt-4 px-4 pb-8 text-center font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground xl:text-[11px]`,children:[`— or learn the language with examples`,` `,(0,q.jsx)(M,{to:`/syntax`,className:`inline-flex min-h-11 items-center text-foreground underline underline-offset-4 transition-colors hover:text-primary`,children:`on the syntax page →`})]})]}),Ue=(0,q.jsx)(Y4,{gateId:`editor-pane`,segmentId:`hero`,className:`w-full max-w-[720px] xl:max-w-[820px] 2xl:max-w-[920px]`,children:(0,q.jsx)(i2,{title:y?y.toLowerCase().startsWith(`shared by`)?y:`shared by: ${y}`:`welcome-1.md`,headerActions:y&&(0,q.jsx)(`button`,{type:`button`,onClick:G,title:`Reset`,className:`rounded-md border border-border px-2 py-1 text-[10px] transition-colors hover:bg-accent`,"data-testid":Q.tour.HERO_RESET_SHARED,children:`Reset`}),className:`h-[clamp(260px,42svh,360px)] sm:h-[clamp(300px,46svh,420px)] lg:h-[clamp(380px,50svh,480px)] 2xl:h-[520px]`,children:(0,q.jsx)(N6,{doc:b,theme:t,onDocChange:Oe,onBlocksChange:ke,onRun:je,editorSlot:r})})}),We=(0,q.jsx)(`div`,{ref:_e,id:`tour-why-video-wrap`,"aria-hidden":me,className:$(`grid w-full transition-all duration-300 motion-reduce:transition-none`,me?`grid-rows-[0fr] opacity-0 invisible`:`grid-rows-[1fr] opacity-100`),children:(0,q.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,q.jsx)(Q_e,{onWatched:xe})})}),Ge=(0,q.jsxs)(`div`,{ref:fe,id:`tour-section-editor`,"data-testid":Q.tour.SECTION_EDITOR,className:`flex w-full scroll-mt-[72px] flex-col items-center px-4 py-6 text-center sm:px-5 sm:py-8 lg:scroll-mt-[104px] lg:px-10 xl:py-10 2xl:px-16`,children:[(me||we)&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-center gap-2`,children:[me&&(0,q.jsxs)(`button`,{type:`button`,onClick:Se,"data-testid":Q.tour.WHY_WATCH_AGAIN,className:`relative inline-flex min-h-9 items-center gap-1.5 rounded-t-lg border border-b-0 border-border bg-muted/40 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-['']`,children:[(0,q.jsx)(Sr,{className:`size-3`,"aria-hidden":!0}),`Watch again`]}),we&&(0,q.jsxs)(`button`,{type:`button`,onClick:Ee,"data-testid":Q.tour.EDITOR_RESET_EDITED,className:`relative inline-flex min-h-9 items-center gap-1.5 rounded-t-lg border border-b-0 border-border bg-muted/40 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-['']`,children:[(0,q.jsx)(hr,{className:`size-3`,"aria-hidden":!0}),`Edited — reset to the welcome doc`]})]}),Ue]});return p?(0,q.jsxs)(`div`,{"data-testid":Q.tour.HOME_TOUR,children:[(0,q.jsxs)(`section`,{id:`tour-hero`,"data-testid":Q.tour.HERO,className:`flex flex-col items-center gap-5 px-6 py-6 text-center`,children:[(0,q.jsx)(C6,{}),We,Ge]}),(0,q.jsx)(G6,{session:L,onRun:je,onBackToEditor:De}),(0,q.jsx)(Z6,{feedDeps:o}),He,(0,q.jsx)(O3,{variant:`university`}),(0,q.jsx)(T6,{}),Ve]}):(0,q.jsxs)(`div`,{"data-testid":Q.tour.HOME_TOUR,children:[(0,q.jsx)(`div`,{ref:de,"aria-hidden":!0,className:`h-px`}),(0,q.jsxs)(`section`,{ref:pe,id:`tour-hero`,"data-testid":Q.tour.HERO,className:`relative flex min-h-[calc(100svh-65px)] flex-col items-center justify-center gap-5 px-5 py-6 text-center lg:min-h-[calc(100svh-104px)] lg:px-10 xl:gap-7 xl:py-8 2xl:px-16`,children:[(0,q.jsx)(C6,{}),We,Ge]}),(0,q.jsx)(G6,{session:L,onRun:je,onBackToEditor:De}),(0,q.jsx)(Z6,{feedDeps:o}),He,(0,q.jsx)(O3,{variant:`university`}),(0,q.jsx)(T6,{}),Ve]})}function zve(e){return(0,q.jsx)(b6,{children:(0,q.jsx)(Ihe,{children:(0,q.jsx)(Rve,{...e})})})}function Bve({wodFiles:e,theme:t}){let n=(0,K.useMemo)(()=>g6(e),[e]);return(0,K.useEffect)(()=>{OE(`homeFirstPaint`)},[]),(0,q.jsx)(zve,{wodFiles:n,theme:t,quests:h6.quests})}var Vve=[`📓`,`🏋️`,`🔥`,`💪`,`⭐`,`🎯`,`🏃`,`🧘`,`🥊`,`🚴`],Hve=({open:e,onOpenChange:t,onCreate:n,notebook:r,onSave:i})=>{let[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(`📓`),[d,f]=(0,K.useState)(!1),p=!!r;K.useEffect(()=>{e&&(o(r?.name??``),c(r?.description??``),u(r?.icon??`📓`))},[e,r]);let m=async()=>{if(!(!a.trim()||d)){f(!0);try{let e=a.trim();if(!(p&&r&&i?await i(r,e,s.trim(),l):await n(e,s.trim(),l)))return;p||(o(``),c(``),u(`📓`)),t(!1)}finally{f(!1)}}};return(0,q.jsxs)(Le,{open:e,onOpenChange:t,children:[(0,q.jsx)(xt,{}),(0,q.jsxs)(g,{className:`bg-popover text-popover-foreground border border-border`,children:[(0,q.jsxs)(Io,{children:[(0,q.jsx)(de,{className:`text-foreground`,children:p?`Edit Notebook`:`Create Notebook`}),(0,q.jsx)(Yt,{children:p?`Rename, describe or re-icon this notebook.`:`Organize your sessions into collections.`})]}),(0,q.jsxs)(`div`,{className:`space-y-4 mt-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-foreground/80 mb-2 block`,children:`Icon`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Vve.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:$(`w-9 h-9 rounded-md flex items-center justify-center text-lg transition-all`,`hover:bg-accent hover:scale-110`,l===e?`bg-primary/20 ring-2 ring-primary scale-110`:`bg-muted/50`),children:e},e))})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`label`,{className:`text-sm font-medium text-foreground/80 mb-1 block`,children:[`Name `,(0,q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,q.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&!e.shiftKey&&a.trim()&&(e.preventDefault(),m())},placeholder:`e.g., Morning Routines`,autoFocus:!0,className:$(`w-full px-3 py-2 rounded-md text-sm`,`bg-background border border-border`,`text-foreground placeholder:text-muted-foreground`,`focus:outline-none focus:ring-2 focus:ring-primary/50`,`transition-colors`)})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`label`,{className:`text-sm font-medium text-foreground/80 mb-1 block`,children:[`Description `,(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`(optional)`})]}),(0,q.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`A brief description of this notebook...`,rows:2,className:$(`w-full px-3 py-2 rounded-md text-sm resize-none`,`bg-background border border-border`,`text-foreground placeholder:text-muted-foreground`,`focus:outline-none focus:ring-2 focus:ring-primary/50`,`transition-colors`)})]}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(J,{variant:`default`,size:`sm`,onClick:()=>void m(),disabled:!a.trim()||d,children:d?`Saving…`:p?`Save`:`Create`})]})]})]})]})};function Q6({value:e,max:t,label:n,className:r}){let a=Math.max(1,t),o=Math.min(Math.max(e,0),a),s=(0,K.useRef)(o),[c,l]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(o>s.current){l(!0);let e=setTimeout(()=>l(!1),200);return s.current=o,()=>clearTimeout(e)}s.current=o},[o]),(0,q.jsxs)(wn,{value:o,max:a,"aria-label":n?void 0:`Progress`,className:$(`w-full min-w-0 gap-1.5`,r),children:[n?(0,q.jsxs)(`span`,{className:`flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.14em] text-brand-deep dark:text-brand-light`,children:[(0,q.jsx)(i,{className:`font-semibold text-brand-deep dark:text-brand-light`,children:n}),(0,q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[o,`/`,a]})]}):null,(0,q.jsx)(cr,{render:(0,q.jsx)(`span`,{}),className:`block h-2 w-full overflow-hidden rounded-pill bg-brand/10`,children:(0,q.jsx)(gt,{className:$(`h-full rounded-pill transition-[width] duration-500 ease-out`,c?`bg-brand-deep`:`bg-brand`)})})]})}var $6=e(ga(),1),e8=[`agg`,`metric`,`rollup`,`pipes`];function t8(e){let t=t_(e);if(t.error||!Bg(t))return null;let n=t.filters.filter(e=>e.key===`source`&&!e.negate);return n.length===1&&n[0].values.length===1?n[0].values[0].value:n.length===0&&t.sourceScope?.length===1?t.sourceScope[0]:null}function Uve({initialQuery:e,onApply:t}){let[n,r]=(0,K.useState)(e),i=(0,K.useCallback)(e=>{r(e),t(e)},[t]);return(0,q.jsx)(`div`,{"data-testid":Q.STREAM_MOBILE_FACETS,className:`max-h-[42vh] overflow-y-auto border-t border-border/60 bg-background/60 px-3 py-2`,children:(0,q.jsx)(cK,{query:n,onQueryChange:i,heading:`Guided filters`})})}function n8(e,t,n,r){xQ.getState().open({placeholder:`Craft the query…`,header:(0,q.jsx)(Uve,{initialQuery:e,onApply:n}),wql:{initialQuery:e,execute:t,onApply:n,preferredChoices:r,hideResults:!0},sources:[$$()]})}function r8({query:e,onQueryChange:t,scopeOptions:n,execute:r,defaultQuery:i,compact:a=!1,hasAppliedFilters:o=!1,activeFilterCount:s=0,className:c}){let[u,d]=(0,K.useState)(!1),f=e||i||``,p=(0,K.useMemo)(()=>ok(f,`Filter or search…`),[f]),m=(0,K.useMemo)(()=>{if(u)return e8;let e=[`kind`,`target`,...e8];if(i){let t=t8(i),n=t8(f);t&&n===t&&e.push(`source`)}return e},[u,i,f]),h=(0,K.useCallback)(()=>n8(f,r,t,n),[f,r,t,n]);return a?(0,q.jsx)(`div`,{"data-testid":Q.STREAM_QUERY_BAR_DOCK,className:$(`flex min-h-12 w-full items-stretch overflow-hidden rounded-xl border border-border bg-card shadow-xs`,c),children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":Q.STREAM_QUERY_BAR,onClick:h,title:f||void 0,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-2.5 px-3 text-left transition-colors hover:bg-muted/60`,children:[(0,q.jsx)(zi,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{"data-testid":Q.STREAM_QUERY_SUMMARY,"data-wql":f,className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground`,children:p}),o&&s>0&&(0,q.jsx)(`span`,{"data-testid":Q.STREAM_FACET_FILTER_BADGE,className:`inline-flex min-w-5 items-center justify-center rounded-full bg-primary px-1.5 py-0.5 text-[11px] font-bold text-primary-foreground`,children:s}),(0,q.jsx)(It,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]})}):(0,q.jsxs)(`div`,{"data-testid":Q.STREAM_QUERY_BAR,className:$(`flex min-w-0 flex-1 items-center gap-1.5 text-xs`,c),children:[(0,q.jsx)(Nk,{query:e,onQueryChange:t,onScopeOpenChange:d,compact:!0,surface:`popover`,showDiagnostics:!1,hiddenClauseTypes:m,preferredChoices:n,placeholder:`Filter or search…`,className:`min-w-0 flex-1`}),(0,q.jsxs)(nt,{children:[(0,q.jsxs)(l,{render:(0,q.jsx)(J,{type:`button`,variant:o?`secondary`:`outline`,size:`sm`,"data-testid":Q.STREAM_FACET_FILTER_TRIGGER,"aria-label":o&&s>0?`Guided filters (${s} active)`:`Open guided filters`,className:`h-8 shrink-0 gap-1.5 px-2.5 text-xs font-semibold`}),children:[(0,q.jsx)(bi,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Filters`}),o&&s>0&&(0,q.jsx)(`span`,{"data-testid":Q.STREAM_FACET_FILTER_BADGE,className:`inline-flex min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-bold text-primary-foreground`,children:s})]}),(0,q.jsx)(Lr,{align:`start`,sideOffset:6,"data-testid":Q.STREAM_FACET_FILTER_POPOVER,className:`w-80 max-h-[70vh] overflow-y-auto p-3`,children:(0,q.jsx)(cK,{query:f,onQueryChange:t,heading:`Filter facets`})})]})]})}function i8(e,t){let n=t??t_(e);return n.error?null:n.groupBy?.length?n.groupBy.map(e=>String(e).toLowerCase()):null}function a8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/(^-|-$)/g,``)||`default`}function o8(e,t=`date`,n){let r=(Array.isArray(t)?t:[t]).map(e=>String(e).toLowerCase()).filter(Boolean);r.length===0&&r.push(`date`);let i=(e,t)=>{let r=Wve(e,t[0],n);return t.length===1?r:r.flatMap(e=>e.key===`shelf`?[e]:i(e.entries,t.slice(1)).map(t=>({...t,key:`${e.key}/${t.key}`,id:`${e.id}--${t.id}`,label:`${e.label} / ${t.label}`,isToday:e.isToday||t.isToday})))};return i(e,r)}function s8(e){return e.date??(e.sourceNotebook===`playground`&&e.createdAt&&e.createdAt>9466848e5?new Date(e.createdAt).toISOString().slice(0,10):null)}function Wve(e,t,n){let r=t.toLowerCase(),i=fT();if(r===`date`||r===`day`){let t=new Map,r=[],a=[];for(let i of e){let e=s8(i);if(n?.shelfVisible&&(e==null||i.kind===`note`&&!i.sourceNote))r.push(i);else if(e){let n=t.get(e);n?n.push(i):t.set(e,[i])}else a.push(i)}let o=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)),s=[];n?.shelfVisible&&r.length>0&&s.push({id:`group-shelf`,key:`shelf`,label:`Notebook Sessions`,entries:r});for(let e of o)s.push({id:`date-group-${e}`,key:e,label:e===i?`Today`:pT(e),isToday:e===i,entries:t.get(e)??[]});return a.length>0&&s.push({id:`group-date-undated`,key:`undated`,label:`Undated`,entries:a}),s}if(r===`week`){let t=new Map,n=[];for(let r of e){let e=s8(r);if(!e){n.push(r);continue}let[i,a,o]=e.split(`-`).map(Number),s=new Date(Date.UTC(i,a-1,o)),c=s.getUTCDay(),l=s.getUTCDate()-c+(c===0?-6:1),u=new Date(Date.UTC(i,a-1,l)),d=u.toISOString().slice(0,10),f=`Week of ${u.toLocaleDateString(`en`,{month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`})}`,p=t.get(d);p?p.entries.push(r):t.set(d,{label:f,entries:[r]})}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-week-${e}`,key:e,label:t.get(e).label,entries:t.get(e).entries}));return n.length>0&&r.push({id:`group-week-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`month`){let t=new Map,n=[];for(let r of e){let e=s8(r);if(!e){n.push(r);continue}let i=e.slice(0,7),[a,o]=i.split(`-`).map(Number),s=new Date(Date.UTC(a,o-1,1)).toLocaleDateString(`en`,{month:`long`,year:`numeric`,timeZone:`UTC`}),c=t.get(i);c?c.entries.push(r):t.set(i,{label:s,entries:[r]})}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-month-${e}`,key:e,label:t.get(e).label,entries:t.get(e).entries}));return n.length>0&&r.push({id:`group-month-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`year`){let t=new Map,n=[];for(let r of e){let e=s8(r);if(!e){n.push(r);continue}let i=e.slice(0,4),a=t.get(i);a?a.push(r):t.set(i,[r])}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-year-${e}`,key:e,label:e,entries:t.get(e)??[]}));return n.length>0&&r.push({id:`group-year-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`discipline`){let t=new Map;for(let n of e){let e=n.effort?.discipline||n.tags?.find(e=>[`strength`,`gymnastics`,`cardio`,`running`,`rowing`,`weightlifting`,`olympic-weightlifting`].includes(e.toLowerCase()))||`General`,r=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),i=t.get(r);i?i.push(n):t.set(r,[n])}return MU(Array.from(t.entries()),`priority-then-alpha`,{priority:[`Strength`,`Gymnastics`,`Cardio`,`Running`,`Rowing`,`Weightlifting`]}).map(([e])=>e).map(e=>({id:`group-discipline-${a8(e)}`,key:e,label:e,entries:t.get(e)??[]}))}if(r===`origin`){let t=new Map;for(let n of e){let e=n.effort?.registrySource===`bundled`?`Bundled Standards`:`Custom Movements`,r=t.get(e);r?r.push(n):t.set(e,[n])}return MU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-origin-${a8(e)}`,key:e,label:e,entries:t}))}if(r===`source`||r===`notebook`){let t=new Map;for(let n of e){let e=n.sourceNotebook||`Other`,r=e.charAt(0).toUpperCase()+e.slice(1),i=t.get(r);i?i.push(n):t.set(r,[n])}return MU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-source-${a8(e)}`,key:e,label:e,entries:t}))}if(r===`kind`||r===`type`){let t=new Map;for(let n of e){let e=n.kind.charAt(0).toUpperCase()+n.kind.slice(1)+`s`,r=t.get(e);r?r.push(n):t.set(e,[n])}return MU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-kind-${a8(e)}`,key:e,label:e,entries:t}))}if(r===`feed`){let t=new Map;for(let n of e){let e=n.feedId??(n.sourceNotebook===`journal`||n.sourceNotebook===`playground`?`local`:`core`),r=t.get(e);r?r.push(n):t.set(e,[n])}return MU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-feed-${a8(e)}`,key:e,label:e===`local`?`Local`:e===`core`?`Core`:e,entries:t}))}if(!dg.includes(r)){let t=new Map;for(let n of e){let e=n.typedTags?.find(e=>e.type?.toLowerCase()===r)?.label??`Unassigned`,i=t.get(e);i?i.push(n):t.set(e,[n])}return MU(Array.from(t.entries()),`alpha-sink-last`,{sink:`Unassigned`}).map(([e,t])=>({id:`group-property-${a8(r)}-${a8(e)}`,key:e,label:e,entries:t}))}let a=new Map;for(let t of e){let e=t.tags?.[0]?`#${t.tags[0]}`:`Untagged`,n=a.get(e);n?n.push(t):a.set(e,[t])}return MU(Array.from(a.entries()),`alpha-sink-last`,{sink:`Untagged`}).map(([e,t])=>({id:`group-tag-${a8(e)}`,key:e,label:e,entries:t}))}var Gve=[{id:XV.route,label:`Journal`,profile:XV,scopeChoices:kO,shortcuts:!0},{id:QV.route,label:`Notes`,profile:QV,scopeChoices:kO,shortcuts:!0},{id:ZV.route,label:`Notebooks`,profile:ZV,scopeChoices:kO,shortcuts:!0},{id:$V.route,label:`Feeds`,profile:$V,scopeChoices:kO,shortcuts:!0},{id:eH.route,label:`Pages`,profile:eH,scopeChoices:kO,shortcuts:!0},{id:tH.route,label:`Efforts`,profile:tH,scopeChoices:kO,shortcuts:!0},{id:nH.route,label:`Equipment`,profile:nH,scopeChoices:kO,shortcuts:!0},{id:rH.route,label:`Tags`,profile:rH,shortcuts:!0},{id:iH.route,label:`Sessions`,profile:iH,scopeChoices:kO,shortcuts:!0},{id:aH.route,label:`Playgrounds`,profile:aH,scopeChoices:kO,shortcuts:!0}],c8={id:`/dashboards`,label:`Dashboards`,systemDefaultWql:`:dashboard{}`},l8={id:IU,label:`Command palette`,systemDefaultWql:Xue,scopeChoices:kO},Kve=[...Gve,c8,l8];function qve(e){return Kve.find(t=>t.id===e)}var u8=`w-full rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`;function Jve({open:e,onOpenChange:t,route:n,editing:r=null,initialQuery:i=``}){let[a,o]=(0,K.useState)(r?.label??``),[s,c]=(0,K.useState)(r?.icon??`bookmark`),[l,u]=(0,K.useState)(r?r.wql:i),[d,f]=(0,K.useState)(null),p=dW(n);(0,K.useEffect)(()=>{e&&(o(r?.label??``),c(r?.icon??`bookmark`),u(r?r.wql:i),f(null))},[e,r,i]);let m=r!==null&&!!r.to,h=r?.id!==`all`,g=a.trim(),_=l.trim(),v=_?nk(_).error??null:null,y=g?null:`Label is required.`,b=!!g&&!m&&(!h||!!_)&&!v;return(0,q.jsx)(pD,{open:e,onClose:()=>t(!1),title:r?`Edit shortcut`:`Save search shortcut`,description:`Saved shortcuts appear in this route's navigation panel. Stored ${PR?`on the server.`:`in this browser only.`}`,footer:(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(J,{type:`submit`,form:`save-wql-shortcut-form`,size:`sm`,disabled:!b,"data-testid":`shortcut-save`,children:`Save`})]}),children:(0,q.jsxs)(`form`,{id:`save-wql-shortcut-form`,onSubmit:async e=>{if(e.preventDefault(),!b)return;let i={id:r?.id??crypto.randomUUID(),label:g,icon:s,wql:m?r.wql:_,...r?.to===void 0?{}:{to:r.to}};if(!await yW(n,[...vW(n,void 0,p).filter(e=>e.id!==i.id),i])){f(`Couldn’t save — storage is unavailable. Your input is kept.`);return}t(!1)},className:`flex flex-col gap-4`,noValidate:!0,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-label`,className:`text-xs font-semibold text-muted-foreground`,children:`Label`}),(0,q.jsx)(`input`,{id:`shortcut-label`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Strength this month`,"data-testid":`shortcut-label-input`,"aria-invalid":y?!0:void 0,className:u8}),y&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-label-error`,children:y})]}),m?(0,q.jsxs)(`p`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:[`Route action — always opens `,r?.to,`. Label and icon are editable.`]}):(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-query`,className:`text-xs font-semibold text-muted-foreground`,children:`Query (WQL)`}),(0,q.jsx)(`textarea`,{id:`shortcut-query`,rows:2,value:l,onChange:e=>u(e.target.value),placeholder:h?`find …`:`Empty — the plain route landing`,"data-testid":`shortcut-query-input`,"aria-invalid":v?!0:void 0,className:`${u8} font-mono text-xs`}),v?(0,q.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-query-error`,children:[`Couldn't parse — `,v]}):!_&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h?`A shortcut needs a query.`:`Empty — opens the plain route landing.`})]}),(0,q.jsxs)(`fieldset`,{className:`space-y-1.5`,children:[(0,q.jsx)(`legend`,{className:`text-xs font-semibold text-muted-foreground`,children:`Icon`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Object.entries(iW).map(([e,t])=>(0,q.jsxs)(`label`,{title:e,className:s===e?`cursor-pointer rounded-md border border-primary bg-primary/10 p-1.5 text-primary`:`cursor-pointer rounded-md border border-border p-1.5 text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`shortcut-icon`,value:e,checked:s===e,onChange:()=>c(e),"aria-label":`Icon ${e}`,"data-testid":`shortcut-icon-${e}`,className:`sr-only`}),(0,q.jsx)(t,{className:`size-4`,"aria-hidden":`true`})]},e))})]}),d&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-storage-error`,children:d})]})})}var Yve=Object.fromEntries([...kO,...OO].map(e=>[e.value,e.label]));function d8({values:e,choices:t,labels:n,onChange:r,testPrefix:i,reorderable:a=!1}){let o=(t,n)=>{let i=[...e],a=t+n;if(a<0||a>=i.length)return;let o=i[t];i[t]=i[a],i[a]=o,r(i)};return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[e.length>0&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((t,s)=>(0,q.jsxs)(`span`,{"data-testid":`${i}-chip-${t}`,className:`inline-flex items-center gap-1 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium`,children:[n[t]??t,a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`Move ${t} up`,"data-testid":`${i}-up-${t}`,disabled:s===0,onClick:()=>o(s,-1),className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,q.jsx)(Ut,{className:`size-3`})}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Move ${t} down`,"data-testid":`${i}-down-${t}`,disabled:s===e.length-1,onClick:()=>o(s,1),className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,q.jsx)(bee,{className:`size-3`})})]}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t}`,"data-testid":`${i}-remove-${t}`,onClick:()=>r(e.filter(e=>e!==t)),className:`text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(ze,{className:`size-3`})})]},t))}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.filter(t=>!e.includes(t.value)).map(t=>(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Add ${t.value}`,"data-testid":`${i}-add-${t.value}`,onClick:()=>r([...e,t.value]),className:`rounded-full border border-dashed border-border/70 px-2.5 py-1 text-xs text-muted-foreground hover:text-foreground hover:border-foreground/40`,children:[`+ `,t.label]},t.value))})]})}function Xve({values:e,choices:t,onChange:n,testPrefix:r}){return(0,q.jsx)(d8,{values:e,choices:t,labels:Yve,onChange:n,testPrefix:r,reorderable:!0})}function Zve({values:e,onChange:t,testPrefix:n}){return(0,q.jsx)(d8,{values:e,choices:OU.map(e=>({value:e.id,label:e.label})),labels:Object.fromEntries(OU.map(e=>[e.id,e.label])),onChange:t,testPrefix:n,reorderable:!0})}function f8({label:e,enabled:t,onEnabledChange:n,testId:r,children:i}){return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:e}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[`Custom`,(0,q.jsx)(un,{checked:t,onCheckedChange:n,"data-testid":r,children:(0,q.jsx)(Cn,{})})]})]}),i]})}function Qve({shortcuts:e,icons:t,landingId:n,onEdit:r,onDelete:i,onCreate:a,error:o,testPrefix:s}){return(0,q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`${s}-shortcuts`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:`Saved shortcuts`}),(0,q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:a,"data-testid":`${s}-shortcut-new`,children:`New shortcut`})]}),e.map(e=>{let a=t[e.icon]??t.bookmark,o=e.to?`Opens ${e.to}`:e.wql||`Landing (no query)`;return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 px-2 py-1.5`,"data-testid":`${s}-shortcut-${e.id}`,children:[(0,q.jsx)(a,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`min-w-0 max-w-40 truncate text-xs font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10px] text-muted-foreground`,children:o}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.label}`,"data-testid":`${s}-shortcut-edit-${e.id}`,onClick:()=>r(e),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Nn,{className:`size-3`})}),!e.to&&e.id!==n&&(0,q.jsx)(`button`,{type:`button`,"aria-label":`Delete ${e.label}`,"data-testid":`${s}-shortcut-delete-${e.id}`,onClick:()=>i(e.id),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,q.jsx)(Me,{className:`size-3`})})]},e.id)}),o&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`${s}-shortcut-error`,children:o})]})}function p8(e){return{defaultWql:e.defaultWql??``,customScope:e.typeOptions!==void 0,scopeOptions:e.typeOptions??[],customGroupBy:e.groupByOptions!==void 0,groupByOptions:e.groupByOptions??[]}}function $ve(e){return{defaultWql:e.defaultWql.trim()||void 0,typeOptions:e.customScope?e.scopeOptions:void 0,groupByOptions:e.customGroupBy?e.groupByOptions:void 0}}function m8({surface:e,onSaved:t}){let n=tW(e.id),r=TW(e.id),[i,a]=(0,K.useState)(()=>p8(n)),[o,s]=(0,K.useState)(()=>n),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(null);(0,K.useEffect)(()=>{a(p8(n)),s(n),l(null),d(null)},[n]);let m=e.profile?.defaultWql??e.systemDefaultWql??``,h=(()=>{let e=i.defaultWql.trim();return e?nk(e).error??null:null})(),g=$ve(i),_=JSON.stringify(g)!==JSON.stringify(o),v=Object.values(o).some(e=>e!==void 0),y=[...o.invalidTypeOptions??[],...o.invalidGroupByOptions??[]],b=async()=>{if(!_)return;let n=i.defaultWql.trim();if(!(n&&nk(n).error)){if(!await JU(e.id,g)){l(`Save failed — storage is unavailable; the previous default still stands.`);return}l(null),s(qU(e.id)),t?.()}},x=async()=>{if(!await YU(e.id)){l(`Reset failed — storage is unavailable; the stored override still stands.`);return}l(null),s({}),a(p8({})),t?.()},S=async t=>{d(null),await yW(e.id,r.filter(e=>e.id!==t))||d(`Delete failed — storage is unavailable. Nothing was lost; the link remains.`)},C=e.scopeChoices??[],w=C.length>0;return(0,q.jsxs)(`div`,{className:`space-y-5`,"data-testid":`query-settings-panel`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:`Landing default query`}),(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`System default: `,(0,q.jsx)(`span`,{className:`font-mono`,children:m})]}),(0,q.jsx)(`textarea`,{rows:2,value:i.defaultWql,onChange:e=>a({...i,defaultWql:e.target.value}),placeholder:m,"data-testid":`query-settings-wql`,className:`w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-primary/40`}),h?(0,q.jsxs)(`p`,{className:`text-xs text-destructive`,"data-testid":`query-settings-wql-error`,children:[`Couldn't parse — `,h]}):!i.defaultWql.trim()&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Empty — the system default is used.`})]}),y.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-invalid`,children:[`Stored options no longer recognized: `,y.join(`, `),` — remove them; they are never turned into query clauses.`]}),w&&(0,q.jsx)(f8,{label:`Where-stored options`,enabled:i.customScope,onEnabledChange:e=>a({...i,customScope:e}),testId:`query-settings-scope-custom`,children:i.customScope&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Xve,{values:i.scopeOptions,choices:C,onChange:e=>a({...i,scopeOptions:e}),testPrefix:`query-settings-scope`}),i.scopeOptions.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-scope-empty`,children:`No predefined options — the page nudges for a pick instead.`})]})}),e.profile&&(0,q.jsxs)(f8,{label:`Group-by options`,enabled:i.customGroupBy,onEnabledChange:e=>a({...i,customGroupBy:e}),testId:`query-settings-group-custom`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The dimensions this page offers first, and the one a bare landing groups by. Order is the priority.`}),i.customGroupBy&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Zve,{values:i.groupByOptions,onChange:e=>a({...i,groupByOptions:e}),testPrefix:`query-settings-group`}),i.groupByOptions.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-group-empty`,children:`No favorites — the page groups by its own default.`})]})]}),e.shortcuts&&(0,q.jsx)(Qve,{shortcuts:r,icons:iW,landingId:`all`,onEdit:e=>p({editing:e}),onDelete:S,onCreate:()=>p({editing:null}),error:u,testPrefix:`query-settings`}),c&&(0,q.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`query-settings-storage-error`,role:`alert`,children:c}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:x,disabled:!v,"data-testid":`query-settings-reset`,children:[(0,q.jsx)(hr,{className:`size-3.5`}),(0,q.jsx)(`span`,{children:`Reset to system default`})]}),(0,q.jsx)(J,{size:`sm`,onClick:b,disabled:!_||!!h,"data-testid":`query-settings-save`,children:`Save`})]}),f&&(0,q.jsx)(Jve,{open:!0,onOpenChange:e=>{e||p(null)},route:e.id,editing:f.editing})]})}function h8({surface:e,open:t,onOpenChange:n}){return(0,q.jsx)(pD,{open:t,onClose:()=>n(!1),title:`${e.label} query settings`,description:`Override the landing query and the Where-stored / Group-By options for this page. An empty query uses the system default; an emptied options list nudges you to pick instead of presetting one. Option lists are favorites — they reorder choices, they don't change what queries mean.`,presentation:`sheet`,children:(0,q.jsx)(m8,{surface:e})})}var g8=e=>coe(new Date(e));function _8(e,t){pQ(e===`imported`?{title:`${t} synced`,description:`Content was synced from the published feed. Your own edits and logged workouts were kept.`}:e===`error`?{title:`${t} sync failed`,description:`Check your connection and try again.`,variant:`destructive`}:e===`busy`?{title:`Another tab is already syncing`,description:`Wait for it to finish, then try again.`}:{title:`${t} is up to date`})}var v8={imported:`Synced`,current:`Up to date`,"server-stale":`Published version is older than the stored version`,"update-pending":`Update available`,busy:`Another tab is syncing`,disabled:`Feed import is disabled`,error:`Sync failed`};function y8(e){switch(e.phase){case`checking`:return`Checking source…`;case`fetching`:return`Downloading ${e.chunkId}…`;case`applying`:return`Importing ${e.chunkId}…`;case`committed`:return`Committed ${e.chunkId}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return e.error??v8[e.outcome]}}function eye({source:e,running:t,subscribing:n=!1,disabled:r,onSync:i,onSubscribe:a,onDownloadOffline:o,onSwitchIndexOnly:s,onUnsubscribe:c,onDelete:l,onAutoSync:u,onToggleNotebook:d}){let f=dt(),p=(0,K.useSyncExternalStore)(qI,()=>YI(e.id)),m=e.notebooks.filter(t=>t.id!==e.id),h=VI(e.id),g=m.filter(e=>e.subscribed).length,_=e.autoImport,v=_||e.offlinePolicy===`offline-full`,y=e.subscribed&&!v,b=e.subscribed&&v&&!e.upToDate&&e.remote!==null,x=(0,K.useRef)(null);(0,K.useLayoutEffect)(()=>{let e=e=>{e.key===`Escape`&&x.current?.open&&(e.preventDefault(),x.current.open=!1,x.current.removeAttribute(`open`),x.current.querySelector(`summary`)?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let S=e=>{let t=e.currentTarget.closest(`details`);t&&(t.open=!1)},C=y?e.indexBytes&&e.indexBytes>0?`${B3(e.indexBytes)} index`:`Index-only`:B3(e.chunkBytes??e.bytes);return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 space-y-3`,"data-testid":`feed-source-${e.id}`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,q.jsx)(M,{to:SH(e.id),className:`no-underline hover:underline text-sm font-semibold text-foreground truncate`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded shrink-0 ${e.subscribed?`bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`:`bg-muted text-muted-foreground`}`,children:e.subscribed?`Subscribed`:`Not subscribed`}),_&&(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-muted text-muted-foreground shrink-0`,children:`Core`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 flex-wrap justify-end`,children:[!e.subscribed||n?(0,q.jsxs)(J,{size:`sm`,onClick:()=>a(e.id),disabled:r||!!n,"aria-busy":t||!!n,"data-testid":`feed-subscribe-${e.id}`,className:`gap-2`,children:[t||n?(0,q.jsx)(mi,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(yr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:t||n?`Subscribing…`:`Subscribe`})]}):b?(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>i(e.id),disabled:r,"data-testid":`feed-sync-${e.id}`,className:`gap-2`,children:[(0,q.jsx)(mi,{className:`size-3.5 ${t?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:t?`Syncing…`:`Sync`})]}):(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,"data-testid":`feed-current-${e.id}`,children:[(0,q.jsx)(kt,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),y?`Index active`:e.remote===null?`Remote unreachable`:`Up to date`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:e.subscribed?`Apply new published versions automatically during the load-time check. Turning it off never removes content.`:`Unsubscribed sources never auto-import.`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 accent-primary`,checked:p,disabled:r||!e.subscribed,onChange:t=>u(e.id,t.target.checked),"aria-label":`Auto-sync ${e.label}`,"data-testid":`feed-autosync-${e.id}`}),(0,q.jsx)(`span`,{children:`Auto-sync`})]}),(0,q.jsxs)(`details`,{ref:x,className:`relative shrink-0`,"data-testid":`feed-more-${e.id}`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,q.jsx)(`summary`,{"aria-label":`More actions for ${e.label}`,className:`flex cursor-pointer list-none items-center justify-center rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:`…`}),(0,q.jsx)(`div`,{className:`fixed inset-0 z-50`,"data-testid":`feed-more-backdrop`,"aria-hidden":`true`,onClick:e=>{e.stopPropagation(),S(e)}}),(0,q.jsxs)(`div`,{className:`absolute right-0 z-[60] mt-1 flex w-64 max-w-[80vw] flex-col items-stretch gap-1.5 rounded-lg border border-border bg-card p-2 text-xs shadow-lg`,onClick:e=>{let t=e.target;(t.closest(`button`)||t.closest(`a`))&&S(e)},children:[e.url?(0,q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`no-underline hover:underline break-all font-mono text-primary`,children:[`Published HTML: `,e.url]}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Published HTML: bundled with this app (no standalone URL)`}),e.repositoryUrl?(0,q.jsx)(`a`,{href:e.repositoryUrl,target:`_blank`,rel:`noopener noreferrer`,className:`no-underline hover:underline break-all text-primary`,children:`Git source directory`}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Git repository: not published`}),!_&&e.subscribed&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:`Refresh now`}),e.hasOfflineChunks&&!v?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:[`Download for offline`,e.chunkBytes&&e.chunkBytes>0?` (${B3(e.chunkBytes)})`:``]}):v?(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:`Use index-only for future updates`}):null]}),!_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),disabled:r||!e.subscribed,"data-testid":`feed-unsubscribe-${e.id}`,className:`min-h-8 rounded-md px-2 text-left text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:`Unsubscribe`}),!_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),disabled:r,"data-testid":`feed-delete-${e.id}`,className:`min-h-8 rounded-md px-2 text-left text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:`Delete source`})]})]})]})]}),e.url&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono break-all`,"data-testid":`feed-origin-${e.id}`,children:e.url}),e.description&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,"data-testid":`feed-description-${e.id}`,children:e.description}),(0,q.jsxs)(`div`,{className:`border-t border-border/60 pt-3 space-y-2.5`,"data-testid":`feed-notebooks-${e.id}`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Subscription`}),(0,q.jsx)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-semibold ${h===`full`?`bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`:h===`partial`?`bg-amber-100 text-amber-900 dark:bg-amber-500/15 dark:text-amber-300`:`bg-muted text-muted-foreground`}`,"data-testid":`feed-sub-mode-${e.id}`,children:h===`full`?`Full`:h===`partial`?`Partial (${g} of ${m.length} subscribed)`:`Unsubscribed`}),e.subscribed&&!_&&(0,q.jsx)(`span`,{className:`text-[11px] font-medium px-2 py-0.5 rounded bg-muted text-foreground`,children:v?`Offline copy`:`Index-only`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(`/notebooks?q=:notebook{feed:${e.id},subscribed:true,false}`),"data-testid":`browse-notebooks-link-${e.id}`,className:`no-underline hover:underline text-xs font-semibold text-primary flex items-center gap-1 cursor-pointer`,children:`Browse notebooks in Library →`})]}),!_&&m.length>0&&(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-1.5`,children:m.map(t=>(0,q.jsxs)(`label`,{className:`flex items-center justify-between gap-2 rounded-md px-2 py-1 text-xs hover:bg-muted/50 cursor-pointer`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:!!t.subscribed,disabled:r,onChange:n=>d(e.id,t.chunkId,n.target.checked),"data-testid":`feed-notebook-toggle-${e.id}-${t.chunkId}`,className:`size-3.5 accent-primary rounded shrink-0`}),(0,q.jsx)(`span`,{className:`truncate text-foreground font-medium`,children:t.label})]}),t.count>0&&(0,q.jsx)(`span`,{className:`text-[11px] tabular-nums text-muted-foreground shrink-0`,children:t.count.toLocaleString()})]},t.chunkId))})]}),(0,q.jsxs)(`div`,{className:`border-t border-border/60 pt-2.5 space-y-2 text-xs`,"data-testid":`feed-status-card`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`font-medium flex items-center gap-1.5 text-foreground`,"data-testid":`feed-sync-status`,children:e.subscribed?y?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(kt,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),`Index active. Workouts load on demand.`]}):e.upToDate?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(kt,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),`Up to date`]}):e.remote==null?`Status unknown (remote unreachable)`:p?`Update available. Applied automatically on next load.`:`Update available. Sync to apply.`:`Not subscribed`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsxs)(`span`,{className:`font-medium text-muted-foreground tabular-nums`,"data-testid":`feed-source-size`,children:[e.count.toLocaleString(),` feed `,e.count===1?`item`:`items`,` · `,C]}),!_&&e.subscribed&&!v&&e.hasOfflineChunks&&(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:r,onClick:()=>o(e.id),"data-testid":`feed-download-offline-${e.id}`,className:`h-7 px-2.5 text-xs gap-1.5`,children:[(0,q.jsx)(sn,{className:`size-3`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{children:[`Download offline`,e.chunkBytes&&e.chunkBytes>0?` (${B3(e.chunkBytes)})`:``]})]})]})]}),(0,q.jsxs)(`details`,{className:`text-xs`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer select-none text-muted-foreground hover:text-foreground`,children:`Sync & version details`}),(0,q.jsxs)(`div`,{className:`mt-2 grid gap-1.5 pl-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Local copy`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`feed-local-version`,children:e.stored?`v${e.stored.version} · synced ${g8(e.stored.importedAt)}`:`Not imported yet`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Published version`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground flex items-center gap-1.5`,"data-testid":`feed-remote-version`,children:e.remote?`v${e.remote.version}`:e.remoteError?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Yi,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),`Unavailable`]}):`Not checked yet`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Last check`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`feed-last-check`,children:e.checkedAt?g8(e.checkedAt):`Not checked`})]})]})]})]})]})}function tye({deps:e={}}={}){let{readFeedStatus:t=pV,syncFeedSource:n=oV,subscribeFeed:r=sV,downloadFeedOffline:i=cV,toggleNotebookSubscription:a=lV,runFeedSync:o=rV,probeFeedManifest:s=wL,unsubscribeFeedSource:c=uV,deleteFeedSource:l=dV}=e,[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(!0),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[b,x]=(0,K.useState)(null),[S,C]=(0,K.useState)([]),[w,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(``),[O,k]=(0,K.useState)(!1),[A,j]=(0,K.useState)(null),[M,N]=(0,K.useState)(null),[P,F]=(0,K.useState)(!1),[I,ee]=(0,K.useState)(),[L,R]=(0,K.useState)(null),[z,B]=(0,K.useState)(!1),V=(0,K.useCallback)(async(e=!1)=>{_(null),e&&h(!0);try{d(await t(e?{probe:!0}:void 0))}catch(e){_(e instanceof Error?e.message:String(e))}finally{p(!1),e&&h(!1)}},[t]);(0,K.useEffect)(()=>{V(!1)},[V]),(0,K.useEffect)(()=>qI(()=>{V(!1)}),[V]),(0,K.useEffect)(()=>QB(()=>{V(!1)}),[V]);let H=(0,K.useCallback)(()=>e=>C(t=>{let n=t.find(t=>t.event.sourceId===e.sourceId),r={event:e,imported:e.phase===`checking`||e.phase===`finished`?n?.imported??null:e,chunks:e.phase===`committed`&&e.chunkId!==null?[...n?.chunks??[],e.chunkId]:n?.chunks??[]};return n?t.map(t=>t.event.sourceId===e.sourceId?r:t):[...t,r]}),[]),U=(0,K.useCallback)(async e=>{y(e??`all`),C([]);let t=H();try{_8(e?await n(e,{force:!0,onProgress:t}):await o({force:!0,onProgress:t}),e?u?.sources.find(t=>t.id===e)?.label??e:`All sources`),await V(!1)}finally{y(null)}},[H,V,o,u,n]),te=(0,K.useCallback)(async t=>{y(t),x(t),C([]);let i=H();try{let a;e.subscribeFeed?a=await r(t,{offlinePolicy:`index-only`,onProgress:i}):(UI(t,!0),QI(t,`index-only`),await XF(),a=await n(t,{offlinePolicy:`index-only`,subscribe:!0,onProgress:i}));let o=u?.sources.find(e=>e.id===t)?.label??t;_8(a,o),await V(!1)}finally{x(null),y(null)}},[e.subscribeFeed,H,V,u,r,n]),W=(0,K.useCallback)(async e=>{y(e),C([]);let t=H();try{_8(await i(e,void 0,{onProgress:t}),u?.sources.find(t=>t.id===e)?.label??e),await V(!1)}finally{y(null)}},[i,H,V,u]),ne=(0,K.useCallback)(e=>{QI(e,`index-only`),XF(),pQ({title:`${u?.sources.find(t=>t.id===e)?.label??e} set to index-only`,description:`Future updates will sync lightweight indexes only.`}),V(!1)},[V,u]),re=(0,K.useCallback)(async(e,t,n)=>{y(e);try{let r=await a(e,t,n);!n&&(r.preservedPinned??0)>0&&pQ({title:`Notebook unsubscribed`,description:`${(r.deleted??0).toLocaleString()} cached items removed. ${r.preservedPinned.toLocaleString()} logged workouts kept pinned locally.`}),await V(!1)}finally{y(null)}},[V,a]),ie=(0,K.useCallback)(async e=>{if(e?.preventDefault(),!(!E.trim()||O)){N(null),j(null),k(!0);try{let e=await s(E.trim());j(e)}catch(e){N(V3(e))}finally{k(!1)}}},[E,s,O]),ae=(0,K.useCallback)((e,t)=>{XI(e,t)?XF():pQ({title:`Couldn't save Auto-sync`,description:`Browser storage is unavailable. The choice lasts this session only.`,variant:`destructive`}),V(!1)},[V]),oe=(0,K.useCallback)(e=>{let t=u?.sources.find(t=>t.id===e)?.label??e;R({kind:`unsubscribe`,id:e,label:t})},[u]),se=(0,K.useCallback)(e=>{let t=u?.sources.find(t=>t.id===e)?.label??e;R({kind:`delete`,id:e,label:t})},[u]),ce=(0,K.useCallback)(async()=>{if(!L||z)return;B(!0);let{kind:e,id:t,label:n}=L;try{if(e===`unsubscribe`){let{deleted:e,preservedPinned:r}=await c(t),i=r??0;pQ({title:`${n} unsubscribed`,description:i>0?`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed. ${i.toLocaleString()} logged ${i===1?`workout`:`workouts`} kept pinned locally.`:`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed. Any logged workouts and your own notes remain intact.`})}else{let{deleted:e,preservedPinned:r}=await l(t),i=r??0;pQ({title:`${n} deleted`,description:i>0?`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed and source unregistered. ${i.toLocaleString()} logged ${i===1?`workout`:`workouts`} kept pinned locally.`:`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed and source unregistered.`})}R(null),await V(!1)}catch(t){pQ({title:`${n} ${e} failed`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}finally{B(!1)}},[z,l,L,V,c]),le=S.at(-1)?.event;return(0,q.jsxs)(`div`,{className:`space-y-8`,children:[(0,q.jsxs)(`section`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`text-base font-semibold text-foreground flex items-center gap-2`,children:[(0,q.jsx)(yr,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Content Sources`]}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:`Each feed publishes notebooks and workouts from its own repository. Subscribing indexes the catalog immediately and loads individual workouts when you open them, or you can opt into a full offline download.`})]}),(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void V(!0),disabled:m||v!==null,className:`gap-2 shrink-0`,children:[(0,q.jsx)(mi,{className:`size-3.5 ${m?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:m?`Checking…`:`Check updates`})]})]}),g&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-destructive`,"data-testid":`feed-status-error`,children:[(0,q.jsx)(Yi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),`Couldn't read the feed status from the active storage: `,g]}),le&&(0,q.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"data-testid":`feed-sync-progress`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm font-medium`,children:[(0,q.jsx)(`span`,{children:v===null?S.some(e=>e.event.phase===`finished`&&e.event.outcome===`error`)?`Sync finished with errors`:`Sync finished`:`Syncing…`}),(0,q.jsxs)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:[`Source `,le.sourceIndex,` of `,le.totalSources]})]}),(0,q.jsxs)(`p`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`feed-sync-live-status`,children:[le.sourceLabel,`: `,y8(le)]}),S.map(({event:e,imported:t,chunks:n})=>(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-border/50 pt-3`,children:[(0,q.jsxs)(`p`,{className:`text-xs ${e.phase===`finished`&&e.outcome===`error`?`text-destructive`:`text-muted-foreground`}`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.sourceLabel}),` · `,y8(e)]}),t&&t.totalChunks>0?(0,q.jsx)(Q6,{value:t.completedChunks,max:t.totalChunks,label:`Chunks committed · ${e.sourceLabel}`}):e.phase===`finished`?null:(0,q.jsx)(`progress`,{"aria-label":`Checking ${e.sourceLabel}`,className:`h-2 w-full`}),t&&(0,q.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-xs tabular-nums`,"data-testid":`feed-sync-totals`,children:[(0,q.jsxs)(`span`,{children:[t.totalNotes.toLocaleString(),` notes`]}),(0,q.jsxs)(`span`,{children:[t.totalEfforts.toLocaleString(),` efforts`]}),(0,q.jsxs)(`span`,{children:[t.totalBlocks.toLocaleString(),` blocks`]}),t.skippedUserOwned>0&&(0,q.jsxs)(`span`,{children:[t.skippedUserOwned.toLocaleString(),` user-owned rows preserved`]}),t.deleted>0&&(0,q.jsxs)(`span`,{children:[t.deleted.toLocaleString(),` feed rows removed`]})]}),n.length>0&&(0,q.jsxs)(`details`,{className:`text-xs`,"data-testid":`feed-sync-chunks`,children:[(0,q.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:[`Committed chunks (`,n.length,`)`]}),(0,q.jsx)(`ul`,{className:`mt-2 max-h-32 space-y-1 overflow-y-auto font-mono text-muted-foreground`,children:n.map(e=>(0,q.jsx)(`li`,{children:e},e))})]})]},e.sourceId))]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 p-2.5 rounded-lg border border-border bg-card text-xs`,children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer select-none text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>F(e.target.checked),"data-testid":`sync-subscribed-only-toggle`,className:`size-3.5 accent-primary rounded`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Subscribed only`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Source:`}),(0,q.jsxs)(`select`,{value:I??``,onChange:e=>ee(e.target.value?e.target.value:void 0),"data-testid":`sync-feed-source-filter`,"aria-label":`Filter notebooks by feed`,className:`h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none transition-colors hover:border-foreground/25 focus:border-primary/50`,children:[(0,q.jsx)(`option`,{value:``,children:`All feeds`}),u?.sources.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3`,"data-testid":`feed-source-list`,children:[u?.sources.filter(e=>{if(I&&e.id!==I)return!1;if(P){let t=e.notebooks.some(e=>e.subscribed);if(!e.subscribed&&!t)return!1}return!0}).map(e=>(0,q.jsx)(eye,{source:e,running:v===e.id||v===`all`,subscribing:b===e.id,disabled:v!==null,onSync:e=>{U(e)},onSubscribe:e=>{te(e)},onDownloadOffline:e=>{W(e)},onSwitchIndexOnly:ne,onUnsubscribe:oe,onDelete:se,onAutoSync:ae,onToggleNotebook:(e,t,n)=>{re(e,t,n)}},e.id)),f&&u===null&&(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-4 text-sm text-muted-foreground`,children:`Checking sources…`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 pt-3 border-t border-border/50`,children:[(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,children:`Syncing refreshes subscribed sources. Your own notes, workout results, and logged sessions are never overwritten.`}),(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>{U(null)},disabled:v!==null||f,"data-testid":`feed-resync-button`,className:`gap-2`,children:[(0,q.jsx)(mi,{className:`size-3.5 ${v===`all`?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:v===`all`?`Syncing all…`:`Sync All Sources`})]})]})]}),(0,q.jsxs)(`section`,{className:`space-y-4 pt-4 border-t border-border/50`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`text-base font-semibold text-foreground flex items-center gap-2`,children:[(0,q.jsx)(Pr,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Add a Source`]}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:[`Inspect any URL serving a Wod Wiki feed (a directory with `,(0,q.jsx)(`code`,{children:`manifest.json`}),`). The host must allow cross-origin reads (CORS). Nothing is saved until you review the feed and confirm Subscribe.`]})]}),(0,q.jsxs)(`form`,{onSubmit:e=>void ie(e),className:`rounded-xl border border-border bg-card p-4 space-y-3`,"data-testid":`feed-add-source-form`,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`feed-source-label`,className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Label (optional)`}),(0,q.jsx)(Fo,{id:`feed-source-label`,value:w,onValueChange:T,placeholder:`Defaults to manifest name`,className:`h-10`,disabled:v!==null||O})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`feed-source-url`,className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Feed directory URL`}),(0,q.jsx)(Fo,{id:`feed-source-url`,type:`text`,autoComplete:`off`,spellCheck:!1,value:E,onValueChange:e=>{D(e),A&&j(null),M&&N(null)},placeholder:`https://example.com/feed/library/`,className:`h-10 font-mono`,disabled:v!==null||O})]})]}),M&&(0,q.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-1.5 text-xs text-destructive`,"data-testid":`feed-add-error`,children:[(0,q.jsx)(Yi,{className:`size-3.5 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:M})]}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(J,{type:`submit`,size:`default`,disabled:v!==null||O||!E.trim(),"data-testid":`feed-add-button`,className:`h-10 gap-2`,children:O?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ot,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Inspecting…`})]}):(0,q.jsx)(`span`,{children:`Inspect Feed`})})})]}),A&&(0,q.jsx)(U3,{preProbed:A,initialLabel:w,cancelLabel:`Cancel`,onCancel:()=>j(null),onSubscribed:()=>{j(null),T(``),D(``),V(!1)}})]}),(0,q.jsx)(pD,{open:L!==null,onClose:()=>{z||R(null)},title:L?.kind===`delete`?`Delete "${L.label}"?`:`Unsubscribe from "${L?.label??``}"?`,description:L?.kind===`delete`?`Remove cached content and unregister this feed source.`:`Remove cached content from your library and stop syncing.`,footer:(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:z,onClick:()=>R(null),children:`Cancel`}),(0,q.jsx)(J,{type:`button`,variant:`destructive`,size:`sm`,disabled:z,onClick:()=>void ce(),children:z?L?.kind===`delete`?`Deleting…`:`Unsubscribing…`:L?.kind===`delete`?`Delete source`:`Unsubscribe`})]}),children:(0,q.jsxs)(`div`,{className:`space-y-3 text-sm text-foreground`,children:[(0,q.jsx)(`p`,{className:`text-pretty`,children:L?.kind===`delete`?`Imported content and cached indexes for "${L.label}" will be removed and the source will be unregistered.`:`Imported content and cached indexes for "${L?.label??``}" will be removed from your library, and automatic syncing will stop. The source stays listed so you can subscribe again anytime.`}),(0,q.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/40 p-3 text-xs text-foreground text-pretty`,children:`Workouts you have logged sessions against remain safely pinned locally and will not be deleted. Your own notes and workout history are never touched.`})]})})]})}var nye={journal:{kind:`journal`,label:`Journal entry`,icon:Cee},playground:{kind:`playground`,label:`Playground`,icon:Di},notebook:{kind:`notebook`,label:`Notebook`,icon:ni},note:{kind:`note`,label:`Note`,icon:ln},effort:{kind:`effort`,label:`Effort`,icon:vt},equipment:{kind:`equipment`,label:`Equipment`,icon:ai},tag:{kind:`tag`,label:`Tag`,icon:Jt},page:{kind:`page`,label:`Page`,icon:Vt}};function b8(e){return e===`/`||/^\/(?:journal|playgrounds|notebooks|pages|efforts|equipment|tags)\/?$/.test(e)||/^\/notebook\/[^/]+\/?$/.test(e)}function x8(){return oY()?(0,q.jsx)(C8,{}):null}function S8(e){let t=/^\/notebook\/([^/]+)\/(\d{4}-\d{2}-\d{2})\/?$/.exec(e);if(t?.[1]&&t?.[2])return{defaultKind:`note`,notebookSlug:decodeURIComponent(t[1]),defaultDate:t[2]};let n=/^\/notebook\/([^/]+)/.exec(e);if(n?.[1])return{defaultKind:`note`,notebookSlug:decodeURIComponent(n[1])};let r=/^\/day\/(\d{4}-\d{2}-\d{2})\/?$/.exec(e);return r?.[1]?{defaultKind:`journal`,defaultDate:r[1]}:e===`/notebooks`?{defaultKind:`notebook`}:e===`/pages`?{defaultKind:`page`}:e===`/tags`?{defaultKind:`tag`}:e.startsWith(`/playground`)?{defaultKind:`playground`}:e.startsWith(`/effort`)?{defaultKind:`effort`}:e.startsWith(`/equipment`)?{defaultKind:`equipment`}:{defaultKind:`journal`}}function rye(e,t){return e?!!(t===`feed`||js(e)):!1}function C8(){let e=Qe(),t=dt(),n=oY(),{openCreateJournal:r}=MV(),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),c=S8(e.pathname),l=nye[c.defaultKind],u=c.defaultKind===`note`&&rye(c.notebookSlug,o),d=u?Sn:l.icon,f=u?`Clone notebook`:`New ${l.label}`,p=u?`Clone notebook`:`+ Add`;(0,K.useEffect)(()=>{let e=!1;if(s(null),!c.notebookSlug)return;let t=c.notebookSlug;if(js(t)){s(`default`);return}return(async()=>{try{let n=await NI.getAllNotebooks();if(e)return;let r=n.find(e=>e.slug===t);if(r){s(r.origin);return}let i=await HL.getAllNotebooks().catch(()=>[]);if(e)return;let a=i.some(e=>e.slug===t||EI(e.slug)===EI(t));s(a?`feed`:`user`)}catch{e||s(`user`)}})(),()=>{e=!0}},[c.notebookSlug]);let m=async e=>{a(!0);try{let n=(await NI.getAllNotebooks()).find(t=>t.slug===e),r=n?.name??e,i=await NI.create(`${r} copy`,n?.description??``,n?.icon??`📓`),a=await NI.listNotes(e);for(let e of a)await NI.cloneNote(e.id,i.slug);t(yH(i.slug))}finally{a(!1)}},h=()=>{if(!i){if(u&&c.notebookSlug){m(c.notebookSlug);return}r({kind:c.defaultKind,notebookSlug:c.notebookSlug,date:c.defaultDate})}},g=c.defaultKind===`note`&&o===null;return(0,q.jsx)(`div`,{className:`inline-flex items-center`,"data-testid":`new-entry-combo`,children:(0,q.jsxs)(J,{type:`button`,size:`sm`,className:n?`h-11 rounded-full px-3.5 gap-1.5 shadow-lg text-xs font-semibold`:`h-9 gap-1.5 px-3 text-xs`,disabled:i||g,onClick:h,"aria-label":n||u?f:`${p} ${l.label}`,title:f,"data-testid":c.defaultKind===`effort`?`efforts-create-btn`:c.defaultKind===`notebook`?`notebooks-create-button`:`new-entry-primary`,children:[n?u?(0,q.jsx)(Sn,{className:$(`size-4 shrink-0`,i&&`animate-spin`)}):(0,q.jsx)(tn,{className:$(`size-4 shrink-0`,i&&`animate-spin`)}):i?(0,q.jsx)(tn,{className:`size-3.5 animate-spin`}):(0,q.jsx)(d,{className:`size-3.5`}),n?(0,q.jsx)(`span`,{children:i?`Cloning…`:u?`Clone`:`New`}):(0,q.jsx)(`span`,{children:i?`Cloning…`:p})]})})}function iye(e){switch(e.kind){case`note`:return`note`;case`result`:return`result`;case`segment`:case`event`:return`segment`;case`effort`:return`effort`;default:return`note`}}var w8=[{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:`sourceNotebook`,label:`Notebook`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.sourceNotebook,formatValue:e=>String(e??``)},{id:`date`,label:`Date`,level:`note`,defaultVisible:!0,align:`right`,getValue:e=>e.date,formatValue:e=>String(e??``)}],aye={note:w8,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?``:iG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>{if(e.execution?.loadLbs!=null)return`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`;if(e.execution?.sessionLoadAu!=null)return`${Number.isInteger(e.execution.sessionLoadAu)?e.execution.sessionLoadAu.toLocaleString():Number(e.execution.sessionLoadAu.toFixed(1)).toLocaleString()} AU`},formatValue:e=>e==null?``:String(e)}],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?``:iG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs==null?void 0:`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`,formatValue:e=>e==null?``:String(e)},{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.execution?.prCount??0)>0?`${e.execution.prCount} PR`:e.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)},{id:`rpe`,label:`RPE`,level:`result`,defaultVisible:!1,align:`right`,getValue:e=>e.execution?.rpe,formatValue:e=>typeof e==`number`?`${e}/10`:``}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:iG(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==null?void 0:`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`,formatValue:e=>e==null?``:String(e)},{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 T8(e){return aye[e]??w8}function E8(e){return T8(e).filter(e=>e.defaultVisible).map(e=>e.id)}var D8=[`cards`,`rows`,`feed`,`agenda`,`planner`],oye={stream:`cards`,table:`rows`},sye=`wodwiki.viewSettings.v1`,O8={"/notebooks":`/catalogs`,"/notes":`/feeds`,"/sessions":`/results`,"/dashboards":`/dashboard`},k8={"/notes":`/collections`},cye={"/feeds":`/feeds@2`};function A8(e){let t=e.startsWith(`/`)?e:`/${e}`;return cye[t]??t}var j8=new sE(sye);function M8(e,t){return{level:e,layout:t??`cards`,visibleFields:E8(e),groupBy:void 0}}function N8(e,t,n=j8,r){let i=M8(t,r),a=A8(e),o=O8[a],s=n.get(a,{alias:o});if(s==null&&o&&(s=n.get(o,{alias:k8[a]})),!s)return i;let c=typeof s.layout==`string`?s.layout:``,l=D8.includes(c)?c:oye[c]??`cards`,u=new Set(T8(t).map(e=>e.id)),d=Array.isArray(s.visibleFields)?s.visibleFields.filter(e=>typeof e==`string`&&u.has(e)):i.visibleFields,f=typeof s.groupBy==`string`?s.groupBy:void 0;return{level:t,layout:l,visibleFields:d.length>0?d:i.visibleFields,groupBy:f}}function lye(e,t,n=j8){let r=A8(e);n.set(r,{level:t.level,layout:t.layout,visibleFields:t.visibleFields,groupBy:t.groupBy})}function uye(e,t,n=j8){let r=A8(e),i=O8[r],a=k8[r];return n.remove(r,i),a&&n.remove(a),M8(t)}function dye(e,t,n){let[r,i]=(0,K.useState)(()=>N8(e,t,j8,n));(0,K.useEffect)(()=>{i(N8(e,t,j8,n))},[e,t,n]);let a=(0,K.useCallback)(t=>{i(n=>{let r=t(n);return lye(e,r),r})},[e]);return{settings:r,setLayout:(0,K.useCallback)(e=>{a(t=>({...t,layout:e}))},[a]),toggleField:(0,K.useCallback)(e=>{a(t=>{let n=new Set(t.visibleFields);return n.has(e)?n.delete(e):n.add(e),{...t,visibleFields:Array.from(n)}})},[a]),setVisibleFields:(0,K.useCallback)(e=>{a(t=>({...t,visibleFields:e}))},[a]),setGroupBy:(0,K.useCallback)(e=>{a(t=>({...t,groupBy:e}))},[a]),resetSettings:(0,K.useCallback)(()=>{let n=uye(e,t);i(n)},[e,t])}}function fye(e,t=200){let[n,r]=(0,K.useState)(()=>({items:e,batchSize:t,count:t})),i=(0,K.useRef)(null),a=n.items===e&&n.batchSize===t?n.count:t,o=a<e.length,s=(0,K.useCallback)(n=>{r(r=>{let i=r.items===e&&r.batchSize===t,a=n(i?r.count:t);return i&&r.count===a?r:{items:e,batchSize:t,count:a}})},[e,t]),c=(0,K.useCallback)(t=>s(n=>Math.max(n,Math.min(Math.max(t,0),e.length))),[s,e.length]);return(0,K.useEffect)(()=>{let n=i.current;if(!n||!o)return;let r=new IntersectionObserver(n=>{n.some(e=>e.isIntersecting)&&s(n=>Math.min(n+t,e.length))},{rootMargin:`400px`});return r.observe(n),()=>r.disconnect()},[o,e.length,t,s]),{visible:e.slice(0,a),hasMore:o,sentinelRef:i,total:e.length,growTo:c}}var P8={source:!0,tags:!0,notebook:!0,text:!0,type:!0,has:!0};function pye(e,t){let n=t_(e);if(n.error)return e;if(Vg(n)){let e=t===`note`?`count`:n.agg;return F_({...n,agg:e,metric:t})}if(!Bg(n))return e;let r=/^:(journal|notebooks|playground)(?:[{\s]|$)/.exec(e.trim())?.[1],i=n.filters.filter(e=>!(!P8[e.key]||r&&e.key===`source`&&e.values.length===1&&e.values[0].value===r)),a=n.filters.filter(e=>!P8[e.key]);return F_({family:`aggregate`,raw:``,agg:t===`note`?`count`:`sum`,metric:t,filters:a,groupBy:[`week`],window:n.window,...i.length>0||r||n.target!==`note`?{join:{target:r??n.target,filters:i}}:{}}).replace(/ where :(journal|notebooks|playground)$/,` where :$1{}`)}function mye(e){let t=t_(e);return t.error?e:F_({...t,window:void 0})}function hye(e,t){let n=t_(e);return n.error||n.family===`pipeline`?e:F_({...n,groupBy:[t]})}var gye={note:lr,effort:vt,result:an,segment:W,event:dn,dashboard:ft,equipment:ai,tag:Ee,feed:or,notebook:Xt},_ye={note:`Note`,effort:`Effort`,result:`Result`,segment:`Segment`,event:`Event`,dashboard:`Dashboard`,equipment:`Equipment`,tag:`Tag`,feed:`Feed`,notebook:`Notebook`},vye={note:`bg-primary/15 text-primary group-hover:bg-primary/20`,effort:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 group-hover:bg-emerald-500/20`,result:`bg-sky-500/15 text-sky-800 dark:text-sky-200 group-hover:bg-sky-500/20`,segment:`bg-indigo-500/15 text-indigo-800 dark:text-indigo-200 group-hover:bg-indigo-500/20`,event:`bg-indigo-500/15 text-indigo-800 dark:text-indigo-200 group-hover:bg-indigo-500/20`,dashboard:`bg-cyan-500/15 text-cyan-800 dark:text-cyan-200 group-hover:bg-cyan-500/20`,equipment:`bg-orange-500/15 text-orange-800 dark:text-orange-200 group-hover:bg-orange-500/20`,tag:`bg-violet-500/15 text-violet-800 dark:text-violet-200 group-hover:bg-violet-500/20`,feed:`bg-amber-500/15 text-amber-900 dark:text-amber-200 group-hover:bg-amber-500/20`,notebook:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 group-hover:bg-emerald-500/20`};function F8({entry:e,leading:t,actions:n,dateLabel:r,visibleFieldIds:i,tone:a=`secondary`,onAddToToday:o,onRunStart:s,moveNotebookTargets:c,onMoveNotebook:l,onToggleSubscribe:u,subscribing:d,onCloneRemote:f,onPublishFeed:p,onTogglePublicNotebook:m,onEditNotebook:h,onDeleteNotebook:g,selected:_,onToggleSelect:v}){let y=dt(),b=e.kind===`note`?e.sourceNotebook:void 0,x=!!b&&b!==`journal`&&b!==`playground`&&b!==`guides`,S=e.ownership?.kind,C=e.kind===`note`&&S===`feed-archived`,w=e.kind===`note`&&(S===`system`||b===`guides`||!!b&&js(b)),T=e.kind===`note`&&!C&&!w&&(S===`feed`||e.isRemotePreview===!0||e.editable===!1&&!!e.feedId&&e.feedId!==`local`),E=e.kind===`note`&&x&&!C&&!w&&!T,D=T||C?GQ(e.ownership?.feedSourceId??(e.feedId!==`local`&&e.feedId!==`core`?e.feedId:void 0),e=>yI(e)?.label):void 0,O=b===`playground`?En:C?Or:w?Xt:T?or:E?lr:gye[e.kind],k=b===`playground`?`Playground`:C?e.ownership?.upstreamStatus===`removed`||e.ownership?.upstreamStatus===`unsubscribed`?`Upstream Removed`:`Saved Copy`:w?b===`guides`?`Guide`:`System`:T?D??`Feed`:E?`My Note`:_ye[e.kind],A=C?`bg-amber-500/15 text-amber-900 dark:text-amber-200 group-hover:bg-amber-500/20`:w?`bg-muted text-foreground group-hover:bg-muted/80`:T?`bg-sky-500/15 text-sky-800 dark:text-sky-200 group-hover:bg-sky-500/20`:E?`bg-primary/15 text-primary group-hover:bg-primary/20`:vye[e.kind],j=a===`primary`,P=wG(e),F=SG(e),I=i?new Set(i):null,ee=!I||I.has(`date`),L=!I||I.has(`sourceNotebook`)||I.has(`protocol`)||I.has(`elapsedTime`)||I.has(`splitDuration`)||I.has(`discipline`)||I.has(`met`)||I.has(`canonicalSlug`),R=!I||I.has(`excerpt`)||I.has(`movements`)||I.has(`tags`)||I.has(`aliases`);return(0,q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>y(SG(e)),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),y(SG(e)))},className:`flex flex-wrap sm:flex-nowrap items-center gap-3 sm:gap-4 px-4 sm:px-6 py-3.5 hover:bg-muted/40 transition-colors text-left group w-full cursor-pointer ${j?`bg-primary/[0.025]`:``}`,"data-testid":`library-row-${e.kind}`,children:[v&&e.kind===`note`&&(0,q.jsx)(`input`,{type:`checkbox`,checked:!!_,onChange:()=>v(e),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.title||`note`} for batch scheduling`,className:`size-4 shrink-0 rounded border-input accent-primary`}),t,(0,q.jsx)(`div`,{className:`flex-shrink-0 size-9 rounded-xl flex items-center justify-center transition-colors ${A}`,children:(0,q.jsx)(O,{className:`size-4`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-bold text-foreground min-w-0 basis-full sm:basis-auto sm:truncate`,children:(0,q.jsx)(M,{to:SG(e),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`hover:underline focus-visible:outline-none focus-visible:underline`,children:e.title})}),e.block&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-sky-800 dark:text-sky-200 border border-sky-700/30 dark:border-sky-400/30 bg-sky-500/15 rounded-full px-2 py-0.5`,"data-testid":`library-row-block-type`,children:e.block.dataType}),(0,q.jsx)(`span`,{"data-ownership":e.kind===`note`?C?`feed-archived`:T?`feed`:w?`system`:`user`:void 0,className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${C?`border-amber-700/30 bg-amber-500/15 text-amber-900 dark:border-amber-400/30 dark:text-amber-200`:T?`border-sky-700/30 bg-sky-500/15 text-sky-800 dark:border-sky-400/30 dark:text-sky-200`:`text-foreground border-border bg-muted/50`}`,children:k}),e.kind===`note`&&e.ownership?.kind===`user`&&Array.isArray(e.notebookIds)&&e.notebookIds.length===0&&(0,q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider rounded-full border border-dashed border-border px-2 py-0.5 text-muted-foreground`,title:`Not assigned to any Notebook`,children:`Unfiled`}),e.kind===`note`&&(e.scheduleCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[10px] font-semibold rounded-full bg-primary/10 px-2 py-0.5 text-primary`,title:`Scheduled ${e.scheduleCount} time${e.scheduleCount===1?``:`s`}`,children:[`Scheduled ×`,e.scheduleCount]}),e.kind===`note`&&(e.sessionCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[10px] font-semibold rounded-full bg-emerald-500/10 px-2 py-0.5 text-emerald-700 dark:text-emerald-300`,title:`${e.sessionCount} logged session${e.sessionCount===1?``:`s`}`,children:[e.sessionCount,` run`,e.sessionCount===1?``:`s`]}),e.kind===`result`&&e.execution?.rpe!=null&&(0,q.jsxs)(`span`,{className:`text-[11px] font-mono font-semibold tabular-nums rounded-full border border-border bg-muted/60 px-2 py-0.5 text-foreground`,children:[`RPE `,e.execution.rpe,`/10`]}),e.kind===`result`&&(e.execution?.prCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full border border-amber-400 bg-amber-100 px-2 py-0.5 text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/20 dark:text-amber-200`,children:[e.execution.prCount,` PR`]}),(e.kind===`feed`||e.kind===`notebook`)&&e.feedId!==`local`&&e.feedId!==`core`&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${e.subscribed?`border-emerald-700/30 dark:border-emerald-400/30 bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:`border-border bg-muted text-foreground`}`,"data-testid":`library-row-sub-status-${e.sourceNote}`,children:e.subscribed?`Subscribed`:`Unsubscribed`}),e.kind===`notebook`&&e.feedId===`local`&&(Vs({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}).isSystem?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-border bg-muted text-foreground`,children:[(0,q.jsx)(Xt,{className:`size-3`,"aria-hidden":`true`}),`System`]}):(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${e.isPublic?`border-emerald-700/30 dark:border-emerald-400/30 bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:`border-border bg-muted text-foreground`}`,"data-testid":`library-row-visibility-${e.sourceNotebook}`,children:[e.isPublic?(0,q.jsx)(ce,{className:`size-3`}):(0,q.jsx)(N,{className:`size-3`}),e.isPublic?`Public`:`Private`]})),e.kind===`feed`&&e.unpublishedChanges&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-amber-700/30 dark:border-amber-400/30 bg-amber-500/15 text-amber-900 dark:text-amber-200`,children:`Unpublished changes`}),e.isRemotePreview&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-sky-700/30 dark:border-sky-400/30 bg-sky-500/15 text-sky-800 dark:text-sky-200`,children:`Index Preview`}),e.execution?.effortSlug&&(0,q.jsx)(M,{to:IH(e.execution.effortSlug),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),"data-testid":`library-row-effort-link`,className:`text-[11px] font-semibold tracking-wide text-primary bg-primary/15 hover:bg-primary/20 border border-primary/25 rounded-full px-2 py-0.5 transition-colors shrink-0`,title:`View movement history for ${e.detail??e.execution.effortSlug}`,children:e.detail??e.execution.effortSlug}),P&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(M,{to:F,"data-testid":`library-row-details-link`,className:`text-[11px] font-semibold tracking-wide text-foreground bg-muted hover:bg-muted/80 border border-border rounded-full px-2 py-0.5 transition-colors`,title:`View notebook details`,children:`Details`}),(0,q.jsx)(M,{to:P,"data-testid":`library-row-feed-link`,className:`text-[11px] font-semibold tracking-wide text-primary bg-primary/15 hover:bg-primary/20 border border-primary/25 rounded-full px-2 py-0.5 transition-colors`,title:`View feed`,children:`Feed`})]}),e.subtitle&&L&&(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground truncate`,children:e.subtitle})]}),R&&(e.block?(0,q.jsx)(`div`,{className:`mt-0.5`,"data-testid":`library-row-block-preview`,children:e.block.preview.map((e,t)=>(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate font-mono`,children:e},t))}):e.detail?(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate mt-0.5`,children:e.detail}):null)]}),(()=>{let t=r??(e.execution?.timestamp?new Date(e.execution.timestamp).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}):void 0);return t&&ee?(0,q.jsx)(`span`,{className:`flex-shrink-0 text-[11px] text-muted-foreground tabular-nums self-start sm:self-auto pt-0.5 sm:pt-0`,"data-testid":`library-row-date`,children:t}):null})(),n??(0,q.jsx)(yye,{entry:e,onAddToToday:o,onRunStart:s,moveNotebookTargets:c,onMoveNotebook:l,onToggleSubscribe:u,subscribing:d,onCloneRemote:f,onPublishFeed:p,onTogglePublicNotebook:m,onEditNotebook:h,onDeleteNotebook:g})]})}function yye({entry:e,onAddToToday:t,onRunStart:n,moveNotebookTargets:r,onMoveNotebook:i,onToggleSubscribe:a,subscribing:o,onCloneRemote:s,onPublishFeed:c,onTogglePublicNotebook:l,onEditNotebook:u,onDeleteNotebook:d}){let f=dt(),p=TG(e),m=wG(e),h=EG(e)&&!!t,g=r$(e)&&!!n,_=e.notebookId??`notebook/journal`,v=r?.filter(e=>e.id!==_)??[],y=!!i&&e.kind===`note`&&(e.editable??!0)&&v.length>0,b=e.kind===`notebook`?Vs({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}):null,x=!!(b?.canTogglePublic&&l),S=!!(b?.canEdit&&u),w=!!(b?.canDelete&&d),T=(e.kind===`feed`||e.kind===`notebook`)&&e.feedId!==`local`&&e.feedId!==`core`&&!!a,E=e.kind===`feed`&&e.sourceNote===`local`&&!!c,D=!!e.isRemotePreview&&!!s,O=!T&&!E&&!D&&g,k=!T&&!E&&!D&&!O,j=!k||!!m||g&&D||h||!!p||x||S||w||y&&v.length>0;return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:[T&&(0,q.jsxs)(`button`,{type:`button`,disabled:!!o,"aria-busy":!!o,onClick:()=>a(e),"data-testid":e.subscribed?`row-unsubscribe-${e.sourceNote}`:`row-subscribe-${e.sourceNote}`,className:`h-8 max-sm:min-h-11 px-3 rounded-lg text-xs font-semibold flex items-center gap-1.5 transition-colors disabled:opacity-60 disabled:cursor-wait ${e.subscribed?`border border-border text-foreground hover:text-destructive hover:border-destructive/40`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:[o?(0,q.jsx)(ot,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(yr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:o?e.subscribed?`Unsubscribing…`:`Subscribing…`:e.subscribed?`Unsubscribe`:`Subscribe`})]}),E&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>c(e),"data-testid":Q.LIBRARY_PUBLISH_LOCAL_FEED,className:`h-8 max-sm:min-h-11 px-3 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 text-xs font-semibold flex items-center gap-1.5 transition-colors`,children:[(0,q.jsx)(Bn,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Publish / Export`})]}),D&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>s(e),"data-testid":`row-clone-remote-${e.id}`,className:`h-8 max-sm:min-h-11 px-3 rounded-lg border border-primary/40 bg-primary/15 text-primary hover:bg-primary/20 text-xs font-semibold flex items-center gap-1.5 transition-colors`,children:[(0,q.jsx)(Vi,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Clone`})]}),O&&(0,q.jsx)(I8,{title:`Run`,testId:Q.LIBRARY_ACTION_RUN,onClick:()=>n?.(e),children:(0,q.jsx)(Sr,{className:`size-3.5`,"aria-hidden":`true`})}),k&&(0,q.jsx)(I8,{title:m?`Details`:`Open`,testId:Q.LIBRARY_ACTION_OPEN,onClick:()=>f(SG(e)),children:(0,q.jsx)(rn,{className:`size-3.5`,"aria-hidden":`true`})}),j&&(0,q.jsxs)($i,{children:[(0,q.jsx)(A,{"aria-label":`Actions for ${e.title}`,title:`Actions for ${e.title}`,"data-testid":Q.LIBRARY_ROW_OVERFLOW,className:`size-8 max-sm:min-h-11 max-sm:min-w-11 inline-flex items-center justify-center rounded-lg border-0 bg-transparent p-0 text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,children:(0,q.jsx)(Tr,{className:`size-4 sm:size-5`,"aria-hidden":`true`})}),(0,q.jsxs)(Ot,{align:`end`,sideOffset:6,children:[(0,q.jsxs)(C,{children:[!k&&(0,q.jsxs)(Ft,{value:`open`,"data-testid":Q.LIBRARY_ACTION_OPEN,onClick:()=>f(SG(e)),children:[(0,q.jsx)(rn,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:m?`Details`:`Open`})]}),m&&(0,q.jsxs)(Ft,{value:`notebook`,"data-testid":Q.LIBRARY_ACTION_NOTEBOOK,onClick:()=>f(m),children:[(0,q.jsx)(or,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Open Notebook`})]}),g&&D&&(0,q.jsxs)(Ft,{value:`run`,"data-testid":Q.LIBRARY_ACTION_RUN,onClick:()=>n?.(e),children:[(0,q.jsx)(Sr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Start workout`})]}),h&&(0,q.jsxs)(Ft,{value:`add-to-today`,"data-testid":Q.LIBRARY_ACTION_ADD,onClick:()=>t?.(e),children:[(0,q.jsx)(Zr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Add to today`})]}),p&&(0,q.jsxs)(Ft,{value:`compare`,"data-testid":Q.LIBRARY_ACTION_COMPARE,onClick:()=>f(p),children:[(0,q.jsx)(Mr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Compare`})]}),x&&(0,q.jsxs)(Ft,{value:`toggle-public`,"data-testid":`row-toggle-public-${e.sourceNotebook}`,onClick:()=>l(e),children:[e.isPublic?(0,q.jsx)(N,{className:`size-4 shrink-0`,"aria-hidden":`true`}):(0,q.jsx)(ce,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:e.isPublic?`Make Private`:`Make Public`})]}),S&&(0,q.jsxs)(Ft,{value:`edit-notebook`,"data-testid":`notebook-edit-${e.sourceNotebook}`,onClick:()=>u(e),children:[(0,q.jsx)(Nn,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Edit notebook`})]}),w&&(0,q.jsxs)(Ft,{value:`delete-notebook`,"data-testid":`notebook-delete-${e.sourceNotebook}`,onClick:()=>d(e),children:[(0,q.jsx)(Me,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Delete notebook`})]})]}),y&&v.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(I,{}),(0,q.jsxs)(C,{children:[(0,q.jsx)(Ji,{children:`Move to notebook`}),v.map(t=>(0,q.jsxs)(Ft,{value:`move-${t.id}`,"data-testid":`action-move-${t.id}`,onClick:()=>i?.(e,t.id),children:[(0,q.jsx)(`span`,{className:`w-5 text-center`,children:t.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:t.name})]},t.id))]})]})]})]})]})}function bye({targets:e,triggerTestId:t,itemTestIdPrefix:n,triggerClassName:r,onMove:i}){return(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,q.jsxs)($i,{children:[(0,q.jsx)(A,{"aria-label":`Move to notebook`,title:`Move to notebook`,"data-testid":t,className:`${r} border-0 bg-transparent p-0`,children:(0,q.jsx)(pn,{className:`size-3.5`,"aria-hidden":`true`})}),(0,q.jsx)(Ot,{align:`end`,sideOffset:6,children:(0,q.jsxs)(C,{children:[(0,q.jsx)(Ji,{children:`Move to notebook`}),(0,q.jsx)(I,{}),e.map(e=>(0,q.jsxs)(Ft,{value:e.id,"data-testid":`${n}${e.id}`,onClick:()=>i(e.id),children:[(0,q.jsx)(`span`,{className:`w-5 text-center`,children:e.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})]},e.id))]})})]})})}function I8({title:e,testId:t,onClick:n,children:r}){return(0,q.jsx)(`button`,{type:`button`,title:e,"aria-label":e,onClick:n,"data-testid":t,className:`size-8 max-sm:min-h-11 max-sm:min-w-11 rounded-lg flex items-center justify-center text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,children:r})}function xye({entries:e,level:t,visibleFieldIds:n,onRowClick:r,emptyMessage:i=`No entries to display`,className:a=``,stickyHeaderTop:o}){let s=dt(),c=(0,K.useMemo)(()=>t||(e.length>0?iye(e[0]):`note`),[t,e]),l=(0,K.useMemo)(()=>T8(c),[c]),u=(0,K.useMemo)(()=>{let e=new Set(n??E8(c));return l.filter(t=>e.has(t.id))},[l,n,c]),d=e=>{r?r(e):s(SG(e))},[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(`asc`),g=e=>{f===e?h(e=>e===`asc`?`desc`:`asc`):(p(e),h(`asc`))},_=(0,K.useMemo)(()=>{if(!f)return e;let t=l.find(e=>e.id===f);return t?[...e].sort((e,n)=>{let r=t.getValue(e),i=t.getValue(n);if(r==null&&i==null)return 0;if(r==null)return m===`asc`?1:-1;if(i==null)return m===`asc`?-1:1;if(typeof r==`number`&&typeof i==`number`)return m===`asc`?r-i:i-r;if(Array.isArray(r)&&Array.isArray(i)){let e=r.join(`, `),t=i.join(`, `);return m===`asc`?e.localeCompare(t):t.localeCompare(e)}let a=String(r),o=String(i);return m===`asc`?a.localeCompare(o):o.localeCompare(a)}):e},[e,f,m,l]);return e.length===0?(0,q.jsx)(`div`,{className:`w-full py-16 text-center text-sm text-muted-foreground ${a}`,"data-testid":`property-table-empty`,children:i}):(0,q.jsx)(`div`,{className:`w-full overflow-x-auto border-y border-border bg-card/50 ${a}`,"data-testid":`property-table`,children:(0,q.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,q.jsx)(`thead`,{className:o===void 0?void 0:`sticky z-10`,style:o===void 0?void 0:{top:`${o}px`},children:(0,q.jsx)(`tr`,{className:`border-b border-border`,children:u.map(e=>{let t=e.align===`right`?`text-right`:e.align===`center`?`text-center`:`text-left`,n=f===e.id;return(0,q.jsx)(`th`,{scope:`col`,"aria-sort":n?m===`asc`?`ascending`:`descending`:`none`,className:`border-b border-border font-semibold uppercase tracking-wider text-[11px] text-muted-foreground whitespace-nowrap ${o===void 0?`bg-muted/30`:`bg-muted/95 backdrop-blur-sm`} ${t}`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e.id),"data-testid":`property-table-header-${e.id}`,className:`inline-flex w-full items-center gap-1.5 px-4 py-3 font-semibold uppercase tracking-wider text-[11px] text-muted-foreground select-none hover:text-foreground transition-colors group/th focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${t===`text-right`?`justify-end`:t===`text-center`?`justify-center`:`justify-start`}`,children:[(0,q.jsx)(`span`,{children:e.label}),n?(0,q.jsx)(`span`,{className:`text-primary font-bold text-xs`,"aria-label":m===`asc`?`sorted ascending`:`sorted descending`,children:m===`asc`?`↑`:`↓`}):(0,q.jsx)(`span`,{className:`opacity-0 group-hover/th:opacity-40 text-muted-foreground text-[10px]`,"aria-hidden":`true`,children:`↕`})]})},e.id)})})}),(0,q.jsx)(`tbody`,{className:`divide-y divide-border/60`,children:_.map(e=>{let t=wG(e),n=SG(e);return(0,q.jsx)(`tr`,{onClick:t=>{t.target.closest(`a, button`)||d(e)},className:`hover:bg-muted/40 transition-colors cursor-pointer group`,"data-testid":`property-table-row-${e.id}`,children:u.map((r,i)=>{let a=r.getValue(e),o=r.formatValue(a,e),s=r.align===`right`?`text-right tabular-nums`:r.align===`center`?`text-center`:`text-left`;return(0,q.jsx)(`td`,{className:`px-4 py-3 whitespace-nowrap text-foreground/90 ${s}`,"data-testid":`property-table-cell-${r.id}`,children:r.id===`pacingTier`&&e.execution?.effortSlug?(0,q.jsx)(M,{to:IH(e.execution.effortSlug),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),"data-testid":`property-table-effort-link`,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors`,title:`View movement history for ${e.detail??e.execution.effortSlug}`,children:o}):r.id===`title`||r.id===`label`||i===0&&!u.some(e=>e.id===`title`||e.id===`label`)?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,q.jsx)(M,{to:n,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`text-left font-medium text-foreground group-hover:text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,children:o}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`text-left font-medium text-foreground group-hover:text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,children:o}),t&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(M,{to:n,"data-testid":`property-table-details-link`,className:`rounded px-1.5 py-0.5 text-[10px] font-semibold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted border border-border transition-colors`,title:`View catalog details`,children:`Details`}),(0,q.jsx)(M,{to:t,"data-testid":`property-table-feed-link`,className:`rounded px-1.5 py-0.5 text-[10px] font-semibold bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors`,title:`View feed`,children:`Feed`})]})]}):o},r.id)})},e.id)})})]})})}var Sye={note:lr,effort:vt,result:an,segment:W,event:dn,dashboard:ft,equipment:ai,tag:Ee,feed:or,notebook:Xt},Cye={note:`Note`,effort:`Effort`,result:`Result`,segment:`Segment`,event:`Event`,dashboard:`Dashboard`,equipment:`Equipment`,tag:`Tag`,feed:`Feed`,notebook:`Notebook`},L8=8;function wye({entry:e}){let t=e.execution;if(!t)return null;let n=[];return t.elapsedMs!=null&&n.push({label:iG(t.elapsedMs)}),t.reps!=null&&n.push({label:`${t.reps} reps`}),t.loadLbs!=null&&n.push({label:`${t.loadLbs} lb`}),t.distanceMeters!=null&&n.push({label:`${(t.distanceMeters/1e3).toFixed(2)} km`}),t.tis!=null&&n.push({label:`TIS Score ${t.tis.toFixed(1)}`,title:`Training Intensity Score`}),n.length===0?null:(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`stream-feed-metrics`,children:n.map(e=>(0,q.jsx)(`span`,{title:e.title,className:`rounded-full bg-muted/70 border border-border/60 px-2 py-0.5 text-[10px] font-bold tabular-nums text-muted-foreground`,children:e.label},e.label))})}function Tye({entry:e}){let[t,n]=(0,K.useState)(!1),r=e.wodBlock?.content.trim(),i=r?r.split(`
|
|
1155
|
+
`),t])}var y6=(0,K.createContext)(null);function b6({children:e}){let t=(0,K.useRef)({"editor.window":null,"editor.wodBlock":null,"editor.runButton":null,"editor.typeahead":null,"timer.floor":null,"timer.nextButton":null,"timer.castButton":null,"metrics.efforts":null,"metrics.data":null,"metrics.compound":null,"analytics.vocab":null,"analytics.table":null,"analytics.graphs":null,"analytics.dashboard":null}),[n,r]=(0,K.useState)(0),i=(0,K.useCallback)((e,n)=>{t.current[e]!==n&&(t.current[e]=n,r(e=>e+1))},[]);return(0,q.jsx)(y6.Provider,{value:{register:i,registry:t,version:n},children:e})}function x6(){return(0,K.useContext)(y6)||{registry:{current:{}},register:()=>()=>{},version:0}}function S6(e){let t=(0,K.useContext)(y6)?.register;return(0,K.useCallback)(n=>t?.(e,n),[e,t])}function X_e({ringKey:e,el:t}){let{register:n}=x6();return(0,K.useLayoutEffect)(()=>{n(e,t)},[e,t,n]),null}function Z_e({target:e,accent:t,canvasRef:n}){let{registry:r,version:i}=x6(),[a,o]=(0,K.useState)(null),s=e?.key??null;return(0,K.useLayoutEffect)(()=>{if(!s){o(null);return}let e=()=>{let e=r.current[s],t=n.current;if(!e||!t){o(null);return}let i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),c=Math.round(i.left-a.left),l=Math.round(i.top-a.top),u=Math.round(i.width),d=Math.round(i.height);if(u<=0||d<=0||c+u<0||l+d<0||c>a.width||l>a.height){o(null);return}o({x:c,y:l,w:u,h:d})};e();let t=window.setTimeout(e,120),i=window.setTimeout(e,480),a=null,c=r.current[s];c&&typeof ResizeObserver<`u`&&(a=new ResizeObserver(e),a.observe(c));let l=new MutationObserver(e);return c&&l.observe(c,{attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`resize`,e),()=>{window.clearTimeout(t),window.clearTimeout(i),a?.disconnect(),l.disconnect(),window.removeEventListener(`resize`,e)}},[s,i,r,n]),!e||!a?null:(0,q.jsx)(`div`,{"data-testid":`tour-ring`,className:`pointer-events-none absolute z-30 rounded-2xl transition-all duration-500 ease-out`,style:{left:a.x-6,top:a.y-6,width:a.w+12,height:a.h+12,boxShadow:`0 0 0 2px ${t}`}})}function C6(){return(0,q.jsxs)(`div`,{className:`@container flex w-full flex-col items-center text-center`,children:[(0,q.jsxs)(`h1`,{className:`text-balance text-[clamp(32px,6.5cqi,64px)] font-extrabold leading-[1.02] tracking-[-0.04em]`,children:[(0,q.jsxs)(`span`,{className:`block`,children:[(0,q.jsx)(`span`,{className:`mr-[0.35em]`,children:`Write it.`}),(0,q.jsx)(`span`,{children:`Time it.`})]}),(0,q.jsxs)(`span`,{className:`block`,children:[(0,q.jsx)(`span`,{className:`mr-[0.35em]`,children:`Track it.`}),(0,q.jsx)(`span`,{children:`Own it.`})]})]}),(0,q.jsxs)(`p`,{className:`mt-4 xl:mt-6 max-w-xl xl:max-w-2xl 2xl:max-w-3xl text-pretty text-[15px] sm:text-base xl:text-lg leading-relaxed text-muted-foreground`,children:[`Plain-text Markdown becomes a step-through workout clock,`,` `,(0,q.jsx)(`br`,{className:`hidden sm:inline`}),`line and splits become queryable training data points.`]})]})}var w6=`SE1nlszA9Vw`,Q_e=(0,K.memo)(function({onWatched:e}){let[t,n]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 xl:gap-5`,children:[(0,q.jsxs)(`div`,{className:`group relative aspect-video w-full max-w-2xl rounded-xl border border-border bg-black text-left shadow-xl transition-shadow hover:shadow-2xl 2xl:max-w-3xl`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),"data-testid":`tour-why-video`,"aria-label":`Play Why Wod Wiki? · YouTube video`,className:`block h-full w-full overflow-hidden rounded-xl`,children:[(0,q.jsx)(`img`,{src:`https://i.ytimg.com/vi/${w6}/hqdefault.jpg`,alt:`Why Wod Wiki? video thumbnail`,width:480,height:360,fetchPriority:`high`,decoding:`async`,className:`h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.02]`}),(0,q.jsx)(`span`,{className:`absolute inset-0 bg-gradient-to-t from-black/70 via-black/10 to-transparent`}),(0,q.jsx)(`span`,{className:`absolute left-1/2 top-1/2 flex size-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-background/90 text-foreground shadow-lg transition-transform duration-300 group-hover:scale-110 xl:size-16`,children:(0,q.jsx)(Sr,{className:`ml-1 size-6 fill-current xl:size-7`})}),(0,q.jsx)(`span`,{className:`absolute bottom-3 left-4 font-mono text-[11px] uppercase tracking-[0.2em] text-white/90`,children:`Why Wod Wiki? · YouTube`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{n(!1),e?.()},"data-testid":`tour-why-video-skip`,title:`Skip the video`,"aria-label":`Skip the Why Wod Wiki? video`,className:`absolute right-0 top-0 z-10 flex size-8 items-center justify-center rounded-full border border-border bg-background/90 text-foreground shadow-lg backdrop-blur-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary after:absolute after:-inset-3 after:content-[''] md:-right-2 md:-top-2`,children:(0,q.jsx)(ze,{className:`size-4`})})]}),(0,q.jsxs)(`p`,{"data-testid":`tour-scroll-hint`,className:`flex items-center gap-2 font-mono text-[11px] uppercase tracking-[0.3em] text-muted-foreground`,children:[(0,q.jsx)(rt,{className:`size-4`,"aria-hidden":!0}),`Keep scrolling for the demo`]}),t&&(0,q.jsx)(S3,{videoId:w6,title:`Why Wod Wiki?`,onClose:()=>{n(!1),e?.()}})]})}),$_e=`https://github.com/bitcobblers/wod-wiki`;function T6(){return(0,q.jsx)(`footer`,{"data-testid":`tour-footer`,className:`border-t border-border px-6 py-8`,children:(0,q.jsxs)(`p`,{className:`mx-auto flex max-w-3xl flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(kq,{size:20,className:`size-5 shrink-0`}),(0,q.jsxs)(`span`,{children:[`© `,new Date().getFullYear(),` WOD Wiki`]}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`a`,{href:$_e,target:`_blank`,rel:`noopener noreferrer`,className:`underline-offset-4 transition-colors hover:text-foreground hover:underline`,children:`GitHub repository`})]})})}async function E6(){await oF.wipe();try{for(let e=localStorage.length-1;e>=0;e--){let t=localStorage.key(e);t&&t!==`wodwiki.dataSettings.v1`&&localStorage.removeItem(t)}}catch{}try{sessionStorage.clear()}catch{}}var eve=`https://github.com/bitcobblers/wod-wiki`,tve=`https://forms.gle/6YHpxwAJh6PAsyAQ6`,nve=`https://app.turso.tech/signup`,rve=`m23.31.803-.563-.42-1.11 1.189-.891-1.286-.512.235.704 1.798-.326.35L18.082 0l-.574.284 2.25 4.836-2.108.741h-.05l-1.143-1.359-1.144 1.36H8.687l-1.144-1.36-1.146 1.363H6.36l-2.12-.745L6.491.284 5.919 0l-2.53 2.668-.327-.349.705-1.798-.512-.236-.89 1.287L1.253.382.69.804 2.42 3.69l-.89.939.311 2.375 2.061.787L3.9 8.817H1.947v.444l.755 1.078 1.197.433v6.971l3.057 4.55L7.657 24l1.101-1.606L9.9 24l.999-1.606L12 24l1.102-1.606L14.1 24l1.141-1.606L16.343 24l.701-1.706 3.058-4.55v-6.972l1.196-.433.756-1.078v-.444h-1.952l.003-1.03 2.054-.784.311-2.375-.89-.939zm-8.93 18.718H8.033l.793-1.615.794 1.615.793-1.083.793 1.083.794-1.083.793 1.083.794-1.083.793 1.083.793-1.615.794 1.615zm3.886-7.39-3.3 1.084-.143 3.061-2.827.627-2.826-.627-.142-3.06-3.3-1.085v-1.635l4.266 1.21-.052 4.126h4.109l-.052-4.127 4.266-1.209z`,ive=[{id:`managed-hosting`,label:`Managed hosting — we run the database.`},{id:`public-profile`,label:`Profile page with a public feed.`},{id:`device-sync`,label:`Sync across your apps and devices.`}],ave=[{id:`coach-views`,label:`Member accounts with coach views.`},{id:`coaches-portal`,label:`Programming dashboards and leaderboards.`},{id:`athlete-portal`,label:`Private journals that roll up to their coach.`},{id:`gym-hosting`,label:`Gym website, competition timers, whiteboard displays.`},{id:`branding`,label:`Your gym's brand on pages and feeds.`}],D6=`underline-offset-4 transition-colors hover:text-foreground hover:underline`;function O6(e){let t=`inline-flex min-h-10 max-lg:min-h-11 w-fit items-center gap-1.5 py-1 font-medium text-foreground underline-offset-4 transition-colors hover:underline`,n=(0,q.jsxs)(q.Fragment,{children:[e.children,(0,q.jsx)(ae,{className:`size-3.5 text-muted-foreground/50`,"aria-hidden":!0})]});return e.href===void 0?e.onClick===void 0?(0,q.jsx)(M,{to:e.to,className:t,children:n}):(0,q.jsx)(`button`,{type:`button`,onClick:e.onClick,className:`text-left ${t}`,children:n}):(0,q.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:t,children:n})}function k6({children:e}){return(0,q.jsxs)(`li`,{className:`flex gap-2.5 text-sm leading-6 text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`mt-[11px] size-1 shrink-0 rounded-full bg-muted-foreground/50`}),(0,q.jsx)(`span`,{children:e})]})}function ove(){return(0,q.jsx)(`span`,{className:`rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 font-mono text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Active`})}function sve(e){return(0,q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`flex gap-2.5 text-[13px] leading-5 text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`mt-[9px] size-1 shrink-0 rounded-full bg-muted-foreground/50`}),(0,q.jsx)(`span`,{children:e.feature.label})]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`hosted-interest-${e.feature.id}`,onClick:()=>e.onInterested(e.feature.id),disabled:e.interested,"aria-pressed":e.interested,className:`ml-[13px] inline-flex min-h-8 max-lg:min-h-9 w-fit shrink-0 items-center rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors ${e.interested?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`border-border text-muted-foreground hover:border-primary/50 hover:text-primary`}`,children:e.interested?`✓ Interested`:`Interested`})]})}function cve(){return(0,q.jsx)(`div`,{role:`status`,"data-testid":`hosted-survey-footer`,className:`mx-auto mt-5 max-w-5xl animate-in fade-in slide-in-from-bottom-4 rounded-xl border border-emerald-500/30 bg-emerald-500/10 p-4 duration-500`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(kt,{className:`size-5 shrink-0 text-emerald-700 dark:text-emerald-400`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Thanks for showing interest — please fill out the survey and give us feedback.`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Opens the interest survey in a new tab.`})]})]}),(0,q.jsxs)(J,{type:`button`,"data-testid":`hosted-survey-button`,onClick:()=>{QR.record($R.hostedSurveyOpened),window.open(tve,`_blank`,`noopener,noreferrer`)},children:[`Fill out interest survey`,(0,q.jsx)(ae,{className:`size-4`,"aria-hidden":!0})]})]})})}function A6(e){let t=e.icon;return(0,q.jsxs)(`article`,{className:`flex flex-col rounded-xl border border-border p-5 ${e.us?`bg-muted/40`:`bg-background`} ${e.className??``}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-foreground text-background`,children:(0,q.jsx)(t,{className:`size-5`,"aria-hidden":!0})}),e.badge]}),e.eyebrow&&(0,q.jsx)(`p`,{className:`mt-3.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] ${e.us?`text-emerald-800 dark:text-emerald-300`:`text-muted-foreground`}`,children:e.eyebrow}),(0,q.jsx)(`h3`,{className:`${e.eyebrow?`mt-1`:`mt-4`} text-base font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:e.text}),(0,q.jsx)(`div`,{className:`mt-4 flex flex-1 flex-col gap-2 text-sm`,children:e.children})]})}function j6({label:e,features:t,interested:n,onInterested:r}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2.5 font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground first:mt-0`,children:e}),(0,q.jsx)(`ul`,{className:`space-y-3 lg:space-y-2`,children:t.map(e=>(0,q.jsx)(sve,{feature:e,interested:n.has(e.id),onInterested:r},e.id))})]})}function M6(){let[e,t]=(0,K.useState)(!1),n=dt(),[r,i]=(0,K.useState)(new Set),a=e=>{i(t=>t.has(e)?t:new Set(t).add(e)),QR.record($R.hostedInterestClicked,{feature:e})},[o]=(0,K.useState)(rF),s=async()=>{window.confirm(`Wipe every note, result, and setting stored in this browser? This cannot be undone.`)&&(t(!0),await E6(),window.location.reload())},c=async()=>{let e=uU(),t=await CU.create({journalDate:e,title:e,rawContent:``});QR.record($R.noteCreated),n(vH(t.id))};return(0,q.jsxs)(`section`,{id:`tour-section-offerings`,"data-testid":`tour-section-offerings`,"aria-label":`You own your data`,children:[(0,q.jsx)(C3,{index:`04`,before:`Who owns the data? `,accentText:`You!!!`,after:``,accent:T3.library,blurb:`Run it in your browser, back it up to your own database, or host it on your own server — and if you'd rather hand the caretaking to us, mark the hosted features you want below and the interest survey unlocks.`}),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-[1500px] 2xl:max-w-[1720px] px-6 pb-16 pt-10 lg:px-12 xl:px-16`,children:[(0,q.jsxs)(`p`,{className:`mx-auto mb-5 flex max-w-5xl flex-wrap items-center justify-between gap-3 text-sm text-muted-foreground`,role:`status`,children:[(0,q.jsx)(`span`,{children:`Current mode: API server`}),(0,q.jsx)(M,{to:Z.settingsStorage,className:D6,children:`Configure data storage`})]}),(0,q.jsxs)(`div`,{className:`mx-auto grid max-w-5xl grid-cols-1 gap-5 md:grid-cols-3`,children:[(0,q.jsxs)(A6,{icon:Kt,eyebrow:`You own it`,title:`Playground in your browser`,badge:void 0,text:`Everything runs locally in this browser's IndexedDB — offline, no account, no server copy.`,children:[(0,q.jsx)(O6,{onClick:()=>void c(),children:`Create your journal`}),(0,q.jsx)(O6,{to:Z.playgroundRoot,children:`Start Writing in a Playground`}),(0,q.jsx)(O6,{to:`/feeds`,children:`Explore the notebooks`}),(0,q.jsxs)(`ul`,{className:`mt-1 space-y-1.5`,children:[(0,q.jsx)(k6,{children:`Offline and fast — notes and results never leave this browser by default.`}),(0,q.jsx)(k6,{children:`Tied to this browser — export or back it up before switching browsers or clearing site data.`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:s,disabled:e,className:`mt-1 inline-flex min-h-10 max-lg:min-h-11 items-center text-left text-xs text-muted-foreground disabled:opacity-50 ${D6}`,children:e?`Clearing…`:`Clear my data`}),(0,q.jsxs)(`div`,{className:`mt-auto border-t border-border pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg border border-border bg-background`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:`size-4`,"aria-hidden":!0,children:(0,q.jsx)(`path`,{d:rve})})}),(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Backup & sync, optional`}),(0,q.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:`Add a free Turso database you own — committed changes back up in the background; without network you keep working and upload later.`})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,q.jsx)(O6,{href:nve,children:`Create a free Turso account`}),(0,q.jsx)(O6,{to:Z.settingsStorage,children:`Configure backup & sync`})]})]})]}),(0,q.jsxs)(A6,{icon:er,eyebrow:`You own it`,title:`Self-hosted`,badge:(0,q.jsx)(ove,{}),text:`Build the app for API storage and run the Wod Wiki server yourself — local or cloud data access through a server you administer.`,children:[(0,q.jsxs)(`ul`,{className:`mt-1 space-y-1.5`,children:[(0,q.jsx)(k6,{children:`Centralized data for a team or gym — one SQLite, Turso, or Postgres backend.`}),(0,q.jsxs)(k6,{children:[`Publish your notebooks as a feed with `,(0,q.jsx)(`code`,{className:`font-mono text-xs`,children:`wod build`}),` — every browser subscribes and syncs.`]}),(0,q.jsx)(k6,{children:`You run the server — network required, and server admin is on you.`})]}),(0,q.jsx)(`div`,{className:`mt-auto border-t border-border pt-4`,children:(0,q.jsx)(O6,{href:eve,children:`View source`})})]}),(0,q.jsxs)(A6,{icon:di,us:!0,eyebrow:`Us — we'd host it`,title:`Wod-Wiki hosted`,text:`Mark the features you want — the survey unlocks below.`,children:[(0,q.jsx)(j6,{label:`Individuals`,features:ive,interested:r,onInterested:a}),(0,q.jsx)(j6,{label:`Coaching & gyms`,features:ave,interested:r,onInterested:a})]})]}),r.size>0&&(0,q.jsx)(cve,{})]})]})}var N6=({doc:e,onDocChange:t,onBlocksChange:n,onRun:r,theme:i,withRingTargets:a=!1,editorSlot:o})=>{let s=S6(`editor.wodBlock`),c=S6(`editor.runButton`),l=(0,K.useRef)(null),u=(0,K.useRef)(null),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),h=(0,K.useCallback)(()=>{if(!a)return null;let e=l.current;if(!e)return null;let t=null,n=e.querySelector(`.cm-wod-fence-open`),r=e.querySelector(`.cm-wod-fence-close`);if(n&&r){let i=e.getBoundingClientRect(),a=n.getBoundingClientRect(),o=r.getBoundingClientRect();if(a.top>=i.top-2&&o.bottom<=i.bottom+2){let n=e.offsetWidth?i.width/e.offsetWidth:1;t={top:(a.top-i.top)/n,left:(Math.min(a.left,o.left)-i.left)/n,width:(Math.max(a.right,o.right)-Math.min(a.left,o.left))/n,height:(o.bottom-a.top)/n}}}f(t);let i=null,o=e.querySelector(`[data-testid="${Q.EDITOR_START_WORKOUT}"]`);if(o){let t=e.getBoundingClientRect(),n=o.getBoundingClientRect();if(n.width>0&&n.height>0&&n.top>=t.top-2&&n.bottom<=t.bottom+2&&n.left>=t.left-2&&n.right<=t.right+2){let r=e.offsetWidth?t.width/e.offsetWidth:1;i={top:(n.top-t.top)/r,left:(n.left-t.left)/r,width:n.width/r,height:n.height/r}}}return m(i),{block:t,run:i}},[a]);(0,K.useLayoutEffect)(()=>{if(!a)return;let e=l.current;if(!e)return;h();let t=window.setTimeout(h,120),n=window.setTimeout(h,480),r=null;if(typeof ResizeObserver<`u`){r=new ResizeObserver(h),r.observe(e);let t=u.current?.contentDOM;t&&r.observe(t)}let i=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.closest(`.cm-note-editor`))&&h()});i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]});let o=0,s=0,c=()=>{h(),performance.now()-s<3e3&&(o=requestAnimationFrame(c))},d=()=>{s=performance.now(),cancelAnimationFrame(o),o=requestAnimationFrame(c)};d(),document.fonts?.ready?.then(d).catch(()=>{});let f=u.current?.scrollDOM;return f?.addEventListener(`scroll`,h,{passive:!0}),window.addEventListener(`resize`,h),()=>{window.clearTimeout(t),window.clearTimeout(n),r?.disconnect(),i.disconnect(),f?.removeEventListener(`scroll`,h),window.removeEventListener(`resize`,h),cancelAnimationFrame(o)}},[e,a,h]);let g=(0,K.useCallback)(()=>{r()},[r]),_=o??N4,v=(0,K.useMemo)(()=>[{id:`run`,label:`Run`,icon:(0,q.jsx)(Sr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:g},{id:`playground`,label:`Playground`,icon:(0,q.jsx)(Ci,{className:`h-3 w-3`}),onClick:e=>{O_e(e)},splitIcon:(0,q.jsx)(Vi,{className:`h-3 w-3`}),splitSuccessIcon:(0,q.jsx)(Rr,{className:`h-3 w-3 text-emerald-500`}),onSplitClick:e=>{p6(e)}}],[g]);return(0,q.jsx)(`div`,{className:`relative flex h-full flex-col bg-background text-left`,children:(0,q.jsxs)(`div`,{ref:l,className:`relative flex-1 min-h-0`,children:[(0,q.jsx)(_,{noteId:`canvas:home`,ariaLabel:`Home workout editor`,value:e,onChange:t,onBlocksChange:n,onStartWorkout:g,commands:v,onViewCreated:e=>{u.current=e,a&&h()},theme:i,readonly:!1,showLineNumbers:!1,showFrontmatter:!1,enableOverlay:!1,enableInlineRuntime:!1,autoFocus:!1,className:`h-full`}),a&&d&&(0,q.jsx)(`div`,{ref:s,"data-testid":`tour-wod-block-region`,"aria-hidden":!0,className:`pointer-events-none absolute`,style:{top:d.top,left:d.left,width:d.width,height:d.height}}),a&&p&&(0,q.jsx)(`div`,{ref:c,"data-testid":`tour-run-button-region`,"aria-hidden":!0,className:`pointer-events-none absolute`,style:{top:p.top,left:p.left,width:p.width,height:p.height}})]})})},lve=.9;function uve(e){let t=Number.isFinite(e.startTime)?e.startTime:0,n=[],r=[];for(let i of e.logs??[]){if(i.outputType!==`segment`||i.stackLevel!==1||i.line==null)continue;let e=i.timeSpan;if(!e||typeof e.started!=`number`||typeof e.ended!=`number`||e.ended<=e.started)continue;let a=i.metrics??[],o=e=>a.some(t=>t.type===e),s=a.find(e=>e.type===`effort`&&typeof e.value==`string`),c=o(`duration`)&&!o(`rep`)?`clock`:i.completionReason===`user-advance`?`next`:null;if(c){if(c===`clock`&&i.completionReason===`user-advance`){let t=a.find(e=>e.type===`duration`&&typeof e.value==`number`)?.value,n=a.find(e=>e.type===`total`&&typeof e.value==`number`)?.value;if(t!==void 0&&(n===void 0||n>=t*lve)&&t!==void 0){let n=t-(e.ended-e.started);n>0&&r.push(n)}}n.push({start:e.started-t,end:e.ended-t,kind:c,label:s?.value??`Line ${i.line+1}`})}}if(n.length===0)return null;let i=r.reduce((e,t)=>e+t,0);return{segments:n,totalMs:Number.isFinite(e.duration)&&e.duration>0?e.duration:Math.max(...n.map(e=>e.end)),impatienceMs:i,earlyClicks:r,reactions:n.filter(e=>e.kind===`next`).map(e=>e.end-e.start)}}var P6=e=>{let t=Math.max(0,Math.round(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},F6=e=>`${(Math.round(e/100)/10).toFixed(1)}s`;function dve({onRun:e}){return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center`,"data-testid":`tour-insights-empty`,children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-muted-foreground`,children:`Run the workout and this window turns your run into data — rest vs. work, how fast you answered the clock, round by round.`}),(0,q.jsxs)(J,{onClick:e,"data-testid":`tour-insights-run`,className:`min-h-11 rounded-full px-5 py-2.5 text-sm font-semibold shadow`,children:[(0,q.jsx)(Sr,{className:`size-4`,"aria-hidden":!0}),`Run to view the results`]})]})}function fve({onRun:e}){return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center`,"data-testid":Q.tour.INSIGHTS_RECORDED,children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-muted-foreground`,children:`Your run was saved — but this workout has nothing to measure yet. A line with a timer or a Next click turns into insights.`}),(0,q.jsxs)(J,{onClick:e,"data-testid":Q.tour.INSIGHTS_AGAIN,className:`min-h-11 rounded-full px-5 py-2.5 text-sm font-semibold shadow`,children:[(0,q.jsx)(Sr,{className:`size-4`,"aria-hidden":!0}),`Run again`]})]})}function pve({result:e,onRun:t}){let n=(0,K.useMemo)(()=>e?uve(e):null,[e]);if(!e)return(0,q.jsx)(dve,{onRun:t});if(!n)return(0,q.jsx)(fve,{onRun:t});let{segments:r,totalMs:i,impatienceMs:a,earlyClicks:o,reactions:s}=n,c=s.length>0?s.reduce((e,t)=>e+t,0)/s.length:0,l=s.length>0?Math.max(...s):0,u=o.length>0?Math.max(...o):0;return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`tour-insights`,children:[(0,q.jsxs)(`div`,{"data-testid":`tour-insights-timeline`,children:[(0,q.jsx)(`div`,{className:`flex h-3 w-full overflow-hidden rounded-full border border-border/60 bg-muted/40`,children:r.map((e,t)=>(0,q.jsx)(`div`,{title:`${e.label} — ${e.kind===`clock`?`countdown`:`to Next`} ${P6(e.end-e.start)}`,className:`h-full`,style:{flexGrow:e.end-e.start,flexBasis:0,backgroundColor:e.kind===`clock`?`hsl(var(--metric-rest))`:`hsl(var(--metric-time))`,marginLeft:+(t>0)}},t))}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-4 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-sm`,style:{backgroundColor:`hsl(var(--metric-rest))`}}),`Countdown`]}),(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-sm`,style:{backgroundColor:`hsl(var(--metric-time))`}}),`To Next click`]}),(0,q.jsxs)(`span`,{className:`ml-auto`,children:[P6(i),` total`]})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{"data-testid":`tour-insights-impatience`,className:`rounded-xl border border-border bg-card p-4`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Impatience Score`}),(0,q.jsx)(`p`,{className:`mt-2 text-2xl font-black tracking-tight tabular-nums text-foreground`,children:F6(a)}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o.length===0?`every countdown ran to zero`:`${o.length} early click${o.length===1?``:`s`}${o.length>1?` · worst ${F6(u)}`:``}`})]}),(0,q.jsxs)(`div`,{"data-testid":`tour-insights-reaction`,className:`rounded-xl border border-border bg-card p-4`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Reaction Time`}),(0,q.jsx)(`p`,{className:`mt-2 text-2xl font-black tracking-tight tabular-nums text-foreground`,children:s.length>0?F6(c):`—`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s.length===0?`no Next clicks yet`:`${s.length} click${s.length===1?``:`s`}${s.length>1?` · slowest ${F6(l)}`:``}`})]})]})]})}var I6=864e5;function L6(e){return Math.round(e*10)/10}function R6(e,t,n=9){let r=new Date(e-t*I6);return r.setHours(n,0,0,0),r.getTime()}function z6(e,t,n,r,i,a={}){let o={canonicalKey:i};a.effortSlug&&(o.effortSlug=a.effortSlug),a.discipline&&(o.effortDiscipline=a.discipline),a.intensityTier&&(o.effortIntensityTier=a.intensityTier),e.push({id:e.length,outputType:`analytics`,timeSpan:{started:0},metrics:[{type:Y.Label,value:t,origin:`analyzed`},{type:Y.Metric,value:n,unit:r,origin:`analyzed`,metadata:o}],sourceBlockKey:``,stackLevel:0})}var mve=new Set([`tis`,`calc.acwr`,`calc.adherence`,`calc.ef`,`calc.pct1rm`]);function B6(e,t){return sb(e,{noteId:t.noteId,resultId:t.resultId,blockId:`example-block`,blockVersion:1,blockContentId:t.blockContentId,origin:`journal`,workoutTimestamp:t.timestamp}).map(e=>{let t=e.metrics[0];if(!t||!(`metadata`in t))return e;let n=t.metadata?.canonicalKey;return typeof n!=`string`||!mve.has(n)||typeof t.value!=`number`?e:{...e,reducerStats:{observedCount:1,sum:t.value,min:t.value,max:t.value}}})}function hve(e=Date.now()){let t=[],n=new Map,r=[],i=[],a=(e,t)=>{let r=Wh(e);n.set(r,(n.get(r)??0)+t)};for(let n=0;n<16;n++){let o=(15-n)*7+1,s=R6(e,o);{let e=[{slug:`back-squat`,top:100+4*n,reps:5,tis:12.5},{slug:`bench-press`,top:80+2.5*n,reps:5,tis:10},{slug:`deadlift`,top:140+4*n,reps:3,tis:8.4}],r=[],i=0,o=0;for(let t of e){let e=t.reps*t.top;i+=e,o+=t.tis;let n={effortSlug:t.slug,discipline:`strength`,intensityTier:`high`};z6(r,`Total reps`,t.reps,`reps`,`totalReps`,n),z6(r,`Training intensity score`,t.tis,`pts`,`tis`,n),z6(r,`Total volume`,e,`kg`,`totalVolume`,n),z6(r,`Estimated 1RM`,L6(t.top*(1+t.reps/30)),`kg`,`calc.e1rm`,n),z6(r,`%1RM intensity`,L6(100/(1+t.reps/30)),`%`,`calc.pct1rm`,n)}let c=L6(i/100+13+o/10);z6(r,`Session load`,c,`AU`,`sessionLoad`,{discipline:`strength`,intensityTier:`high`}),t.push(...B6(r,{noteId:`example-strength-w${n}`,resultId:`example-strength-w${n}-r`,blockContentId:`example-content-strength`,timestamp:s})),a(s,c)}let c=R6(e,o+2);{let e=[],r;if(n%3==0){r=`high`;for(let[t,n,i,a]of[[`thruster`,45,2.2,42.5],[`pull-up`,45,1.6,0]]){let o={effortSlug:t,discipline:a?`strength`:`gymnastics`,intensityTier:r};z6(e,`Total reps`,n,`reps`,`totalReps`,o),z6(e,`Training intensity score`,L6(n*i),`pts`,`tis`,o),a&&z6(e,`Total volume`,n*a,`kg`,`totalVolume`,o)}}else if(n%3==1){r=`moderate`;let t=16+n%5;for(let[n,i,a]of[[`pull-up`,5,1.5],[`push-up`,10,1.2],[`air-squat`,15,1.1]]){let o=t*i,s={effortSlug:n,discipline:`gymnastics`,intensityTier:r};z6(e,`Total reps`,o,`reps`,`totalReps`,s),z6(e,`Training intensity score`,L6(o*a),`pts`,`tis`,s)}}else{r=`moderate`;for(let[t,n,i]of[[`double-under`,150,.5],[`sit-up`,150,1.3]]){let a={effortSlug:t,discipline:`gymnastics`,intensityTier:r};z6(e,`Total reps`,n,`reps`,`totalReps`,a),z6(e,`Training intensity score`,L6(n*i),`pts`,`tis`,a)}}let i=L6(30.6);z6(e,`Session load`,i,`AU`,`sessionLoad`,{intensityTier:r}),t.push(...B6(e,{noteId:`example-conditioning-w${n}`,resultId:`example-conditioning-w${n}-r`,blockContentId:`example-content-conditioning`,timestamp:c})),a(c,i)}let l=R6(e,o+4,8);if(n%4==1)r.push(Wh(l));else{let e=6e3+100*n,r=L6(e/2.8),o=[],s={effortSlug:`running`,discipline:`running`,intensityTier:`low`};z6(o,`Total distance`,e,`m`,`totalDistance`,s),z6(o,`Elapsed time`,r,`s`,`elapsed`,s),z6(o,`Training intensity score`,r,`pts`,`tis`,s);let c=L6(r/10);z6(o,`Session load`,c,`AU`,`sessionLoad`,{intensityTier:`low`}),t.push(...B6(o,{noteId:`example-run-w${n}`,resultId:`example-run-w${n}-r`,blockContentId:`example-content-run`,timestamp:l})),a(l,c),i.push({day:Wh(l),pace:e/r})}let u=R6(e,o+6,10);{let e=4e3+50*n,r=L6(e/2),i=[],o={effortSlug:`rowing`,discipline:`rowing`,intensityTier:`moderate`};z6(i,`Total distance`,e,`m`,`totalDistance`,o),z6(i,`Elapsed time`,r,`s`,`elapsed`,o),z6(i,`Training intensity score`,r,`pts`,`tis`,o);let s=L6(r/10);z6(i,`Session load`,s,`AU`,`sessionLoad`,{intensityTier:`moderate`}),t.push(...B6(i,{noteId:`example-row-w${n}`,resultId:`example-row-w${n}-r`,blockContentId:`example-content-row`,timestamp:u})),a(u,s)}}let o=Math.max(...n.keys()),s=(e,t=10)=>{let n=new Date(e*I6);return n.setHours(t,0,0,0),n.getTime()},c=(e,n,r)=>{let i=[];for(let[e,t,n]of r)z6(i,e,t,n,e);t.push(...B6(i,{noteId:`example-calc`,resultId:e,blockContentId:`example-content-calc`,timestamp:n}))};for(let e of cie(n,o))e.acwr!==void 0&&c(`example-calc-d${e.day}`,s(e.day),[[`calc.acwr`,L6(e.acwr),`ratio`]]);let l=0,u=0,d=Math.min(...n.keys());for(let e=d;e<=o;e++){let t=n.get(e)??0;l+=(t-l)/42,u+=(t-u)/7,n.has(e)&&c(`example-calc-pmc-d${e}`,s(e),[[`calc.ctl`,L6(l),`AU`],[`calc.atl`,L6(u),`AU`],[`calc.tsb`,L6(l-u),`AU`]])}let f=new Set([...n.keys()]);for(let e of r)f.add(e);for(let e of f){let t=+!!n.has(e);c(`example-calc-adh-d${e}`,s(e,7),[[`calc.adherence`,t,`ratio`]])}for(let e of i)c(`example-calc-ef-d${e.day}`,s(e.day,8),[[`calc.ef`,L6(e.pace/141*1e5),`pts`]]);return t}function gve(e=Date.now()){return new cx(qx(hve(e)))}var _ve=null;function vve(){return _ve??=gve()}var yve=[4,8,16],bve={parse(e){let t=Number.parseInt(e,10);return yve.includes(t)?t:null},serialize(e){return String(e)},withDefault(e){return{...this,defaultValue:e}}};function V6(){return V(`weeks`,bve.withDefault(16))}function xve({boardSlug:e}){let t=vve(),n=$P(),r=(0,K.useMemo)(()=>n?tU(n):[],[n]),i=(0,K.useMemo)(()=>r.find(t=>t.slug===e)??r[0],[r,e]),a=(0,K.useMemo)(()=>{if(!i?.rawContent)return null;try{let{meta:e,sections:t}=yx(i.rawContent);return qy(t,e)}catch{return null}},[i]),[o,s]=V6(),[c,l]=(0,K.useMemo)(()=>{let e=Date.now();return[e-o*7*864e5,e]},[o]),[u,d]=(0,K.useState)(null);return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col`,"data-testid":`tour-session-dashboard`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-5 pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-[11px] font-semibold uppercase tracking-wide text-primary`,children:i?.title??e}),(0,q.jsx)(`span`,{"data-testid":`tour-session-dashboard-source`,className:`flex-none rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:`Example data`})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(pO,{weeks:o,onWeeksChange:s})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-5 pb-5 pt-3 [&_[data-testid=dashboard-view]>div.grid]:grid-cols-1 [&_[data-testid=dashboard-view]>div.grid]:sm:grid-cols-2 [&_[data-testid=dashboard-view]>div.grid]:lg:grid-cols-2 [&_[data-testid=dashboard-view]>div.grid>*]:col-span-1`,children:a?(0,q.jsx)(fO,{document:a,executor:t,onInspectWidget:d,rangeStart:c,rangeEnd:l}):(0,q.jsx)(`p`,{className:`pt-8 text-center text-sm text-muted-foreground`,children:`Loading board…`})}),(0,q.jsx)(s3,{open:u!==null,onClose:()=>d(null),mode:`inspect`,initialWql:u?.body??`sum:totalVolume{}`,initial:u?{title:u.title,question:u.question,type:u.type,spanCols:u.spanCols,spanFull:u.spanFull,attributes:u.attributes}:void 0,executor:t,rangeStart:c,rangeEnd:l,tokenValues:a?Vy(a.tokens):void 0,onApply:void 0})]})}var Sve=[`analytics`,`boards`],Cve={analytics:{index:`01`,heading:`h2`,title:`Session Insights`,blurb:`Run the workout and this window turns your run into data — rest vs. work, how fast you answered the clock, round by round.`},boards:{index:`02`,heading:`h2`,title:`One Run Becomes Many`,blurb:`Dashboards let you visualise your progress — every recorded run rolls up into analytics boards. Aggregate results across flexible search criteria, from note frontmatter to session metrics: one run becomes many insights.`}};function H6({scope:e}){let t=Cve[e],n=t.heading;return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(n,{className:`flex items-baseline gap-4 text-balance text-[clamp(26px,3.2vw,44px)] font-extrabold leading-[1.1] tracking-[-0.03em]`,children:[t.index&&(0,q.jsx)(`span`,{className:`font-mono text-xs font-normal tracking-normal text-muted-foreground`,children:t.index}),(0,q.jsx)(`span`,{children:t.title})]}),(0,q.jsx)(`p`,{className:`mt-3 max-w-xl text-pretty text-[clamp(14px,1.2vw,18px)] leading-[1.65] text-muted-foreground`,children:t.blurb})]})}var U6=[{id:`road-to-560-total`,label:`Road to 560 Total`,title:`Road to 560 Total`},{id:`polarized-base-marathon`,label:`Polarized Base`,title:`Polarized Base Marathon`}];function W6({onClick:e}){return(0,q.jsxs)(`button`,{type:`button`,onClick:e,title:`Back to the editor`,"data-testid":`tour-pane-back-to-editor`,className:`relative flex shrink-0 items-center gap-1 rounded-md border border-border px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground transition-colors hover:bg-accent hover:text-foreground after:absolute after:-inset-2 after:content-['']`,children:[(0,q.jsx)(Ut,{className:`size-3`}),`Editor`]})}var G6=(0,K.memo)(function({session:e,onRun:t,onBackToEditor:n}){let[r,i]=(0,K.useState)(`analytics`),[a,o]=(0,K.useState)(0),s=U6[a],c=(0,K.useRef)(new Map);(0,K.useEffect)(()=>{if(typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target.getAttribute(`data-scope`);(e===`analytics`||e===`boards`)&&i(e)}},{rootMargin:`-45% 0px -45% 0px`});return c.current.forEach(t=>e.observe(t)),()=>e.disconnect()},[]);let l=e=>t=>{t?c.current.set(e,t):c.current.delete(e)},u=r=>r===`analytics`?(0,q.jsx)(i2,{title:`Session Insights`,className:`h-full`,headerActions:(0,q.jsx)(W6,{onClick:n}),children:(0,q.jsx)(pve,{result:e,onRun:t})}):(0,q.jsxs)(Ht,{value:s.id,onValueChange:e=>{let t=U6.findIndex(t=>t.id===e);t>=0&&o(t)},className:`flex h-full flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(nn,{"aria-label":`Dashboard slides`,className:`flex flex-wrap gap-1 border-b-0 rounded-lg border border-border bg-muted/30 p-1`,children:U6.map(e=>(0,q.jsx)(Ae,{value:e.id,"data-testid":`dashboard-slide-tab-${e.id}`,className:`min-h-11 rounded-md border-0 px-3 py-1.5 text-xs font-semibold transition-colors text-muted-foreground hover:text-foreground data-selected:bg-background data-selected:text-foreground data-selected:shadow`,children:e.label},e.id))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e=>(e+U6.length-1)%U6.length),"aria-label":`Previous dashboard`,"data-testid":`dashboard-slide-prev`,className:`flex size-11 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,q.jsx)(j,{className:`size-4`,"aria-hidden":`true`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e=>(e+1)%U6.length),"aria-label":`Next dashboard`,"data-testid":`dashboard-slide-next`,className:`flex size-11 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,q.jsx)(ee,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,q.jsx)(i2,{title:s.title,className:`min-h-0 flex-1`,headerActions:(0,q.jsx)(W6,{onClick:n}),children:(0,q.jsx)(ie,{value:s.id,className:`flex h-full w-full flex-col p-0`,children:(0,q.jsx)(xve,{boardSlug:s.id})})}),(0,q.jsxs)(`p`,{className:`text-center font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground`,children:[a+1,` / `,U6.length]})]}),d=(0,q.jsx)(`div`,{"data-testid":`tour-sticky-pane`,className:`sticky top-[104px] flex h-[calc(100dvh-104px)] flex-col items-center justify-center self-start`,children:(0,q.jsx)(`div`,{className:`relative w-full max-w-[700px]`,children:(0,q.jsx)(`div`,{className:`relative h-[460px]`,children:Sve.map(e=>(0,q.jsx)(`div`,{"aria-hidden":r!==e,"data-scope-active":r===e,className:$(`absolute inset-0 transition-opacity duration-500`,r===e?`opacity-100`:`invisible opacity-0`),children:u(e)},e))})})}),f=(e,t)=>(0,q.jsx)(`div`,{ref:l(e),"data-scope":e,className:`flex min-h-[85vh] flex-col justify-center scroll-mt-[104px]`,...t,children:(0,q.jsx)(H6,{scope:e})}),p=e=>(0,q.jsxs)(`div`,{id:e===`boards`?`tour-section-boards`:void 0,"data-testid":`tour-step-mobile-${e}`,"data-scope":e,className:`flex scroll-mt-[72px] flex-col gap-4`,children:[(0,q.jsx)(H6,{scope:e}),(0,q.jsx)(`div`,{className:e===`analytics`?`h-[340px] sm:h-[420px]`:`h-[460px]`,children:u(e)})]}),m=oY();return(0,q.jsx)(`section`,{id:`tour-section-insights`,"data-testid":`tour-section-insights`,className:`border-b border-border/60`,children:m?(0,q.jsxs)(`div`,{className:`flex flex-col gap-12 px-5 py-14`,children:[p(`analytics`),p(`boards`)]}):(0,q.jsxs)(`div`,{className:`mx-auto grid max-w-[1500px] gap-10 px-5 py-14 lg:grid-cols-2 lg:gap-16 lg:px-12 lg:py-0 xl:px-16 2xl:max-w-[1720px]`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`div`,{id:`tour-scroll-target-insights`,className:`scroll-mt-[104px]`,children:f(`analytics`)}),f(`boards`,{id:`tour-section-boards`,"data-testid":`tour-section-boards`})]}),d]})})});function wve(e){let t=e.match(/^notebook\.(.+)$/);return t?{slug:t[1]}:null}function Tve(e){let t=e.items.map(e=>e.date).filter(e=>!!e).sort();return{packageId:`local-notebooks-${e.id}`,slug:e.id,label:e.name,description:e.description,image:e.image,categories:e.categories,sourceLabel:`Local`,href:`/notebook/${encodeURIComponent(e.id)}`,itemCount:e.items.length,...t.length>0?{latestDate:t[t.length-1],firstDate:t[0]}:{},...e.readme===void 0?{}:{readme:e.readme},installed:!0}}function Eve(e,t,n){let r=[],i=new Map;if(t)for(let e of IP(`notebooks`,t))i.set(e.id,e),r.push(Tve(e));let a=e.map(e=>{let t=wve(e.chunkId);if(!t)return null;let r=i.get(t.slug),a=yI(e.feedId),o=(r?.items??[]).map(e=>e.date).filter(e=>!!e).sort();return{packageId:e.id,feedId:e.feedId,chunkId:e.chunkId,slug:t.slug,label:e.label,description:e.description||r?.description,image:r?.image,categories:r?.categories??[],sourceLabel:a?.label??e.feedId,...a?.repositoryUrl?{repositoryUrl:a.repositoryUrl}:{},href:`/notebook/${encodeURIComponent(t.slug)}`,itemCount:r?.items.length??0,...o.length>0?{latestDate:o[o.length-1],firstDate:o[0]}:{},...r?.readme===void 0?{}:{readme:r.readme},installed:!!r,subscribed:!n||n(e.feedId,e.chunkId)}}).filter(e=>e!==null),o=new Set(a.map(e=>e.slug));return[...a,...r.filter(e=>!o.has(e.slug)),...Dve(t)]}function Dve(e){return zs.filter(e=>e.feedEntryId===`core`&&e.slug!==`guides`&&typeof e.seedChunkId==`string`).map(t=>{let n=`markdown/${t.slug}/`,r=e?Object.keys(e).filter(e=>e.startsWith(n)&&e.endsWith(`.md`)&&!e.endsWith(`/README.md`)):[];return{packageId:`core-${t.slug}`,feedId:`core`,chunkId:t.seedChunkId,slug:t.slug,label:t.name,description:t.description,categories:[],sourceLabel:`Core`,href:t.href,itemCount:r.length,installed:e?r.length>0:!1,subscribed:!0}})}function Ove(e,t){let n={},r=[],i=new Set(t.map(e=>e.id));for(let t of e)t.feedId&&i.has(t.feedId)?(n[t.feedId]??=[]).push(t):r.push(t);let a=[];for(let e of t){let t=n[e.id];t?.length&&a.push({feed:e,label:e.label,...e.description?{description:e.description}:{},url:e.url,...e.repositoryUrl?{repositoryUrl:e.repositoryUrl}:{},notebooks:t})}return r.length>0&&a.push({label:`Local`,notebooks:r}),a}function kve(e,t,n,r){return Ove(Eve(e,t,r),n).map(e=>{let t=e.notebooks.map(e=>e.latestDate).filter(e=>!!e).sort();return{feedId:e.feed?.id,slug:e.feed?.id??`local`,label:e.label,...e.description?{description:e.description}:{},...e.url?{url:e.url}:{},...e.repositoryUrl?{repositoryUrl:e.repositoryUrl}:{},notebooks:e.notebooks,itemCount:e.notebooks.reduce((e,t)=>e+t.itemCount,0),installed:e.notebooks.every(e=>e.installed),subscribed:e.notebooks.some(e=>e.subscribed),...t.length>0?{latestDate:t[t.length-1]}:{},href:`/notebooks`}})}function Ave(e,t){let n=t.text?.trim().toLowerCase();return e.filter(e=>t.feedId&&e.feedId!==t.feedId||t.subscribedOnly&&!e.notebooks.some(e=>e.subscribed)?!1:!n||e.label.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)||e.notebooks.some(e=>e.label.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)))}function jve(e,t){let n=[...e];switch(t){case`name`:return n.sort((e,t)=>e.label.localeCompare(t.label));case`size`:return n.sort((e,t)=>t.itemCount-e.itemCount||e.label.localeCompare(t.label));default:return n.sort((e,t)=>e.latestDate&&t.latestDate?t.latestDate.localeCompare(e.latestDate):e.latestDate?-1:t.latestDate?1:e.label.localeCompare(t.label))}}var K6=[`bg-rose-500/12 text-rose-600 dark:text-rose-400`,`bg-amber-500/12 text-amber-600 dark:text-amber-400`,`bg-emerald-500/12 text-emerald-600 dark:text-emerald-400`,`bg-sky-500/12 text-sky-600 dark:text-sky-400`,`bg-violet-500/12 text-violet-600 dark:text-violet-400`,`bg-cyan-500/12 text-cyan-600 dark:text-cyan-400`];function Mve(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return K6[Math.abs(t)%K6.length]}function Nve(e){return(e.match(/[a-z0-9]/i)?.[0]??`•`).toUpperCase()}function Pve(e){if(!e)return null;let t=new Date(`${e}T00:00:00`);return isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}var Fve=4;function q6({feed:e,testId:t=`feed-card`,className:n,onImport:r,importing:i,busy:a,status:o,onToggleNotebookSubscription:s}){let[c,l]=Mve(e.slug).split(` `),u=Pve(e.latestDate),d=e.notebooks.slice(0,Fve),f=e.notebooks.length-d.length,p=e.feedId?SH(e.feedId):e.href,m=e.installed&&e.feedId?e.href:p,h=e.notebooks.find(e=>e.image)?.image,g=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[e.notebooks.length,` `,e.notebooks.length===1?`notebook`:`notebooks`]}),e.installed&&e.itemCount>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[e.itemCount,` `,e.itemCount===1?`item`:`items`]})]}),e.installed&&u&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[`updated `,u]})]}),!e.installed&&(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),!e.installed&&(0,q.jsx)(`span`,{children:e.subscribed?`index active`:`not subscribed`})]}),_=(0,q.jsx)(`div`,{className:$(`relative overflow-hidden bg-muted/40 aspect-[16/10]`,c),children:h?(0,q.jsx)(`img`,{src:h,alt:``,loading:`lazy`,className:`absolute inset-0 size-full object-cover`}):(0,q.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:[(0,q.jsx)(`span`,{className:$(`text-7xl font-black tracking-tighter select-none`,l),"aria-hidden":`true`,children:Nve(e.label)}),(0,q.jsx)(W,{className:$(`absolute bottom-4 right-4 size-6 opacity-50`,l),"aria-hidden":`true`})]})});return(0,q.jsxs)(`article`,{"data-testid":t,"data-installed":e.installed,className:$(`group relative flex flex-col overflow-hidden rounded-2xl border border-border bg-card`,`transition-colors hover:border-foreground/25 focus-within:border-foreground/25`,n),children:[(0,q.jsx)(M,{to:m,"data-testid":`${t}-open`,className:`block outline-none no-underline`,"aria-label":`Open ${e.label}`,children:_}),(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:`min-w-0 text-sm font-bold leading-snug text-foreground`,children:(0,q.jsx)(M,{to:m,className:`no-underline text-foreground transition-colors hover:text-primary`,children:e.label})}),e.installed||!r||!e.feedId?(0,q.jsx)(M,{to:m,"data-testid":`${t}-cta`,"aria-label":`Open ${e.label}`,className:`no-underline flex min-h-11 min-w-11 size-11 shrink-0 items-center justify-center rounded-full border border-border text-muted-foreground transition-colors hover:border-primary/50 hover:text-primary`,children:(0,q.jsx)(ae,{className:`size-3.5`,"aria-hidden":`true`})}):(0,q.jsxs)(`button`,{type:`button`,"data-testid":`${t}-import`,disabled:i||a,onClick:()=>r(e.feedId),className:$(`flex min-h-11 shrink-0 items-center gap-1.5 rounded-full border px-4`,`text-[11px] font-bold uppercase tracking-wider`,`border-primary/30 bg-primary/10 text-primary`,`transition-colors hover:bg-primary/20`,`disabled:cursor-wait disabled:opacity-60`),children:[i?(0,q.jsx)(ot,{className:`size-3 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(yr,{className:`size-3`,"aria-hidden":`true`}),i?`Importing`:`Subscribe`]})]}),e.description&&(0,q.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-muted-foreground text-pretty`,children:e.description}),e.notebooks.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`${t}-notebooks`,children:[d.map(n=>{let r=n.installed?n.href:`${n.href}${e.feedId?`?feed=${encodeURIComponent(e.feedId)}`:``}`,i=!!(s&&e.feedId&&n.chunkId);return(0,q.jsxs)(`span`,{"data-testid":`${t}-notebook-${n.packageId}`,className:$(`inline-flex items-center gap-1 rounded-full border text-[11px] font-semibold tracking-wide transition-colors`,i?`pl-2.5 pr-1 py-0.5`:`px-2.5 py-1`,n.subscribed?`border-emerald-600/30 bg-emerald-100 text-emerald-800 dark:border-emerald-500/30 dark:bg-emerald-500/15 dark:text-emerald-300`:`border-border text-muted-foreground`),children:[(0,q.jsx)(M,{to:r,className:`no-underline text-current hover:text-primary`,children:n.label}),i&&(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e.feedId,n.chunkId,!n.subscribed)},title:n.subscribed?`Unsubscribe ${n.label}`:`Subscribe ${n.label}`,"aria-label":n.subscribed?`Unsubscribe ${n.label}`:`Subscribe ${n.label}`,"data-testid":`${t}-notebook-toggle-${n.packageId}`,className:`inline-flex size-7 items-center justify-center rounded-full font-bold hover:bg-foreground/10 hover:text-foreground`,children:n.subscribed?`✓`:`+`})]},n.packageId)}),f>0&&(0,q.jsxs)(`span`,{className:`rounded-full border border-dashed border-border px-2.5 py-1 text-[11px] font-semibold tracking-wide text-muted-foreground`,children:[`+`,f,` more`]})]}),(0,q.jsxs)(`div`,{className:`mt-auto pt-1`,children:[g,o&&(0,q.jsx)(`p`,{role:o.tone===`error`?`alert`:`status`,"data-testid":`${t}-status`,className:$(`mt-1.5 flex items-start gap-1.5 text-xs`,o.tone===`error`?`text-destructive`:`text-muted-foreground`),children:(0,q.jsx)(`span`,{children:o.text})})]})]})]})}function J6({direction:e,children:t,testId:n,className:r}){let i=(0,K.useRef)(null),a=(0,K.useRef)(null),[o,s]=(0,K.useState)(1),c=n2(`(prefers-reduced-motion: reduce)`);(0,K.useEffect)(()=>{let e=i.current,t=a.current;if(!e||!t)return;let n=()=>{let n=o*2,r=t.scrollWidth/n;if(r<=0)return;let i=Math.max(1,Math.ceil(e.clientWidth/r));i!==o&&s(i)};n();let r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[o,t]);let l=c?1:o*2;return(0,q.jsx)(`div`,{ref:i,"data-testid":n,className:$(`wod-marquee`,c?`overflow-x-auto px-4 sm:px-6`:`overflow-hidden [mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-16px),transparent)] sm:[mask-image:linear-gradient(to_right,transparent,black_48px,black_calc(100%-48px),transparent)]`,r),children:(0,q.jsx)(`div`,{ref:a,className:$(`flex w-max`,!c&&`wod-marquee-track`,!c&&e===`left`&&`wod-marquee-track--left`,!c&&e===`right`&&`wod-marquee-track--right`,!c&&e===`alternate`&&`wod-marquee-track--left wod-marquee-track--alternate`),children:Array.from({length:l},(e,n)=>(0,q.jsx)(`div`,{"data-marquee-copy":n,"aria-hidden":n>0,inert:n>0,className:`flex shrink-0 items-stretch gap-4 pr-4`,children:t},n))})})}var Ive=[{value:`updated`,label:`Updated`},{value:`name`,label:`Name`},{value:`size`,label:`Size`}],Y6=`group flex flex-col justify-between rounded-2xl border border-border bg-card p-5 text-left transition-colors hover:border-primary/40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`;function X6(e){let t=e.icon;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-foreground text-background`,children:(0,q.jsx)(t,{className:`size-5`,"aria-hidden":!0})}),(0,q.jsx)(`h3`,{className:`mt-4 text-base font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:e.description})]}),e.note?(0,q.jsx)(`span`,{className:`mt-4 text-xs font-medium text-muted-foreground`,children:e.note}):(0,q.jsxs)(`span`,{className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,q.jsx)(`span`,{children:e.action}),(0,q.jsx)(ae,{className:`size-4 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})]})}var Z6=(0,K.memo)(function({feedDeps:e}={}){let t=(0,K.useMemo)(()=>({isNotebookSubscribed:WI,setNotebookSubscribed:GI,setFeedSubscribed:UI,subscribeFeedSubscriptions:qI,syncFeedSource:oV,readFeedCoverage:fV,...e}),[e]),n=dt(),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(`updated`),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)({}),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(),[_,v]=(0,K.useState)(0);(0,K.useEffect)(()=>t.subscribeFeedSubscriptions(()=>v(e=>e+1)),[t]);let y=l!==null,b=$P(),x=n2(`(min-width: 1024px)`),S=(0,K.useMemo)(()=>kve(wI(),b,CI(),(e,n)=>t.isNotebookSubscribed(e,n)),[b,_,t]),C=(0,K.useMemo)(()=>jve(Ave(S,{text:r,feedId:h,subscribedOnly:p}),s),[S,r,s,h,p]),w=Math.ceil(C.length/2),T=C.slice(0,w),E=C.slice(w),D=(0,K.useCallback)(()=>{QR.record($R.libraryOpened)},[]),[O,k]=(0,K.useState)(!0);(0,K.useEffect)(()=>{let e=!1,n=()=>{t.readFeedCoverage().then(t=>{e||k(t.libraryImported)}).catch(()=>{})};n();let r=t.subscribeFeedSubscriptions(n);return()=>{e=!0,r()}},[y,t]);let A=(0,K.useCallback)(async e=>{if(l)return;u(e);let n=t=>f(n=>({...n,[e]:t}));n({text:`Checking the feed…`,tone:`muted`});try{let r=await t.syncFeedSource(e,{onProgress:e=>n({text:qX(e),tone:`muted`})});n(r===`imported`||r===`current`?{text:t.setFeedSubscribed(e,!0)?r===`imported`?`Imported — this feed is available offline.`:`Already up to date.`:`Subscribed for this session only — browser storage is unavailable.`,tone:`muted`}:{text:r===`server-stale`?`Published version is older than stored copy.`:r===`busy`?`Another tab is syncing. Try again shortly.`:`Sync failed. Check connection and try again.`,tone:`error`})}catch(e){n({text:e instanceof Error?e.message:String(e),tone:`error`})}finally{u(null)}},[l,t]),j=(0,K.useCallback)(async(e,n,r)=>{t.setNotebookSubscribed(e,n,r),r&&t.syncFeedSource(e,{force:!1})},[t]),N=(0,K.useCallback)(async()=>{let e=uU(),t=await CU.create({journalDate:e,title:e,rawContent:``});QR.record($R.noteCreated),n(vH(t.id))},[n]),P=!!(r.trim()||h||p),F=!!(h||p||s!==`updated`),I=(0,K.useMemo)(()=>CI(),[]);return(0,q.jsxs)(`section`,{id:`tour-section-community-feeds`,"data-testid":`tour-jump-section`,className:`flex flex-col border-b border-border bg-muted/20 pb-8 xl:pb-12`,"aria-label":`Library and community feeds`,children:[(0,q.jsx)(C3,{index:`03`,before:`Library & `,accentText:`Community Feeds`,after:``,accent:``,blurb:`Subscribe to a feed — one Markdown repository compiled with npx wod build into a versioned manifest, served from its own GitHub Pages. One Subscribe imports every notebook the feed publishes; browse the feeds below, notebooks and all.`}),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`label`,{className:`relative w-full sm:w-64`,children:[(0,q.jsx)(Jr,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground/60`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:`Search feeds…`,"aria-label":`Search feeds`,"data-testid":`package-search-input`,className:`h-11 w-full rounded-full border border-border bg-background pl-9 pr-9 text-base lg:text-sm text-foreground placeholder:text-muted-foreground outline-none transition-colors focus:border-primary/50`}),r&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(``),"aria-label":`Clear search`,className:`absolute right-0 top-1/2 -translate-y-1/2 size-11 inline-flex items-center justify-center text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(ze,{className:`size-3.5`})})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-controls":`jump-filters-panel`,"data-testid":Q.tour.JUMP_FILTERS_TOGGLE,className:$(`ml-auto inline-flex min-h-11 items-center gap-1.5 rounded-full border bg-background px-3 text-[10px] font-black uppercase tracking-widest transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,F?`border-primary/50 text-foreground hover:border-primary`:`border-border text-muted-foreground hover:border-foreground/25 hover:text-foreground`),children:[`Filters`,F&&!a&&(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,"aria-hidden":!0}),(0,q.jsx)(rt,{className:$(`size-3.5 transition-transform`,a&&`rotate-180`),"aria-hidden":!0})]}),(0,q.jsx)(`div`,{id:`jump-filters-panel`,"data-testid":Q.tour.JUMP_FILTERS_PANEL,className:$(`w-full flex-wrap items-center gap-2 pt-1`,a?`flex`:`hidden`),children:a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 cursor-pointer select-none text-muted-foreground hover:text-foreground px-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),"data-testid":`filter-subscribed-only`,className:`size-4 accent-primary rounded`}),(0,q.jsx)(`span`,{className:`text-[10px] font-black uppercase tracking-widest`,children:`Subscribed only`})]}),(0,q.jsxs)(`select`,{value:h??``,onChange:e=>g(e.target.value?e.target.value:void 0),"aria-label":`Filter by feed`,"data-testid":`filter-feed-source`,className:`min-h-11 h-11 rounded-full border border-border bg-background px-3 text-base font-semibold uppercase tracking-widest text-muted-foreground outline-none transition-colors hover:border-foreground/25 focus:border-primary/50 lg:text-[10px] lg:font-black`,children:[(0,q.jsx)(`option`,{value:``,children:`All feeds`}),I.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`group`,"aria-label":`Sort feeds`,children:Ive.map(e=>{let t=s===e.value;return(0,q.jsx)(`button`,{type:`button`,"aria-pressed":t,"data-testid":`package-sort-${e.value}`,onClick:()=>c(e.value),className:$(`inline-flex min-h-11 items-center justify-center rounded-full px-3 text-[10px] font-black uppercase tracking-widest transition-colors`,t?`bg-foreground text-background`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value)})})]})})]}),(0,q.jsx)(`div`,{"data-testid":`jump-grid`,className:`mt-6`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[O?(0,q.jsx)(M,{to:`/notebooks`,onClick:D,"data-testid":`jump-library`,className:Y6,children:(0,q.jsx)(X6,{icon:qe,title:`Library`,description:`Curated workouts and sessions, organized by tag.`,action:`Open the library`})}):(0,q.jsx)(`div`,{"data-testid":`jump-library`,"aria-disabled":`true`,className:`${Y6} cursor-not-allowed opacity-60`,children:(0,q.jsx)(X6,{icon:qe,title:`Library`,description:`Curated workouts and sessions, organized by tag.`,action:`Open the library`,note:`0 feeds synchronized`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{N()},"data-testid":`jump-new-note`,className:Y6,children:(0,q.jsx)(X6,{icon:ye,title:`Start your own journal`,description:`Create today's note and log your first workout.`,action:`Create today's note`})})]})})]}),(0,q.jsx)(`div`,{"data-testid":`jump-rows`,className:`mt-6`,children:C.length>0?x?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(J6,{direction:`left`,testId:`jump-row-a`,children:T.map(e=>(0,q.jsx)(q6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] sm:w-[320px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))}),E.length>0&&(0,q.jsx)(J6,{direction:`right`,testId:`jump-row-b`,className:`mt-4`,children:E.map(e=>(0,q.jsx)(q6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] sm:w-[320px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))})]}):(0,q.jsx)(J6,{direction:`alternate`,testId:`jump-row-mobile`,children:C.map(e=>(0,q.jsx)(q6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))}):(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:(0,q.jsxs)(`div`,{"data-testid":`jump-empty`,className:`flex flex-col items-center justify-center rounded-2xl border border-dashed border-border p-10 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-bold text-muted-foreground`,children:`No feeds match your search.`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Try a different term or clear the filters.`}),P&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`jump-clear-filters`,onClick:()=>{i(``),g(void 0),m(!1)},className:`mt-3 inline-flex min-h-11 items-center justify-center rounded-full border border-border px-4 text-[10px] font-black uppercase tracking-widest text-muted-foreground transition-colors hover:border-primary/50 hover:text-primary`,children:`Clear filters`})]})})}),(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:(0,q.jsx)(`p`,{className:`mt-4 font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground xl:text-[11px]`,children:`— or keep scrolling ↓`})})]})}),Lve=`wods/examples/home/welcome-1.md`;function Rve({wodFiles:e,theme:t,quests:n,editorSlot:r,timerSlot:i,deps:a,jumpFeedDeps:o}){let s=a?.usePlaygroundRun??q0,c=a?.useQuickStartAutoComplete??t2,l=a?.useCompletionChallenge??e2,u=a?.useRunStartedChallenge??W_e,d=a?.useTourScrollQuests??q_e,f=a?.toast??pQ,p=n2(`(prefers-reduced-motion: reduce)`),m=ez()?.track;nz(`/`);let h=(0,K.useMemo)(()=>rY(Lve,e),[e]),[g,_]=(0,K.useState)(()=>H_e()),v=g?.content??h,y=g?g.by?.trim()||`anonymous`:void 0;(0,K.useEffect)(()=>{let e=e=>{let t=e.detail;t?.content&&(_(t),x(t.content))};return window.addEventListener(`wodwiki:home-shared`,e),()=>window.removeEventListener(`wodwiki:home-shared`,e)},[]);let[b,x]=(0,K.useState)(v),S=(0,K.useRef)(b);S.current=b;let C=(0,K.useRef)([]),w=(0,K.useRef)(!1),{run:T,start:E,finalize:D,end:O}=s(),k=(0,K.useRef)(T);k.current=T;let A=(0,K.useRef)(!1),j=(0,K.useRef)(!1),N=(0,K.useRef)(null),[P,F]=(0,K.useState)(!1),I=(0,K.useRef)(!1),ee=(0,K.useRef)(null),[L,R]=(0,K.useState)(null),[z,B]=(0,K.useState)(!1),V=(0,K.useRef)(z);V.current=z;let H=(0,K.useRef)(!1),U=(0,K.useRef)(()=>{}),[te,W]=(0,K.useState)(0),[ne,re]=(0,K.useState)(!1),[ie,ae]=(0,K.useState)(!1),[oe,se]=(0,K.useState)(null),ce=(0,K.useCallback)(async(e,t,n)=>{if(!t||H.current)return!1;H.current=!0,j.current=!1,A.current=!1,N.current=null,se(t),W(e=>e+1),re(!0),R(null),B(!0);try{await E(e,t,{pageTitle:`Home`,sectionTitle:n})}catch(e){return console.error(`[HomeTour] failed to persist playground run note:`,e),B(!1),se(null),f({title:`Could not start workout`,description:`The playground entry could not be saved.`,variant:`destructive`}),!1}finally{H.current=!1}return!0},[E]),le=(0,K.useCallback)(async()=>{if(I.current=!1,F(!1),N.current)try{await D(N.current,!1),N.current=null}catch(e){console.error(`[HomeTour] retry save failed:`,e),f({title:`Session still not saved`,description:`The run is kept — try again.`,variant:`destructive`});return}let e=ee.current;if(ee.current=null,e)switch(e.kind){case`apply-doc`:w.current=!1,x(e.doc),B(!1),se(null),W(e=>e+1),re(!1);break;case`restart`:await ce(e.doc,e.block,e.sectionTitle)}},[ce,D]),ue=(0,K.useCallback)(e=>{if(!ee.current){if(!k.current||j.current||!A.current||N.current){ee.current=e,le();return}ee.current=e,I.current=!0,F(!0)}},[le]),de=(0,K.useRef)(null),fe=(0,K.useRef)(null),pe=(0,K.useRef)(null);Lhe(`hero`,pe);let[me,he]=(0,K.useState)(!1),ge=(0,K.useRef)(me);ge.current=me;let _e=(0,K.useRef)(null),ve=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{ve.current?.(),ve.current=null},[]);let ye=(0,K.useCallback)(e=>{ve.current?.(),ve.current=null;let t=!1,n=0,r=0,i=_e.current,a=e=>{e.target===i&&(!i||i.getBoundingClientRect().height<=1)&&s()},o=()=>{t=!0,n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),i?.removeEventListener(`transitionend`,a),ve.current===o&&(ve.current=null)},s=()=>{t||(t=!0,o(),e())};ve.current=o;let c=()=>{if(!t){if(p||!i||i.getBoundingClientRect().height<=1){s();return}i.addEventListener(`transitionend`,a),r=window.setTimeout(s,350)}};typeof requestAnimationFrame==`function`?n=requestAnimationFrame(()=>{n=0,c()}):c()},[p]),be=(0,K.useCallback)(()=>{let e=document.getElementById(`tour-section-editor`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,e.getBoundingClientRect().top+window.scrollY-n),behavior:p?`auto`:`smooth`})},[p]),xe=(0,K.useCallback)(()=>{he(!0),ye(be)},[ye,be]),Se=(0,K.useCallback)(()=>{ve.current&&=(ve.current(),null),he(!1),window.scrollTo({top:0,behavior:p?`auto`:`smooth`})},[p]),Ce=(0,K.useRef)(!1),we=b!==v,Te=(0,K.useRef)(we);Te.current=we;let Ee=(0,K.useCallback)(()=>{ue({kind:`apply-doc`,doc:v})},[v,ue]);(0,K.useEffect)(()=>{let e=fe.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting?Ce.current&&!V.current&&(Ce.current=!1,Te.current||Ee()):Ce.current=!0});return t.observe(e),()=>t.disconnect()},[Ee]);let G=(0,K.useCallback)(()=>{U_e(),_(null),ue({kind:`apply-doc`,doc:h})},[h,ue]),De=(0,K.useCallback)(()=>{ve.current&&=(ve.current(),null),ue({kind:`apply-doc`,doc:S.current});let e=document.getElementById(`tour-section-editor`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,e.getBoundingClientRect().top+window.scrollY-n),behavior:p?`auto`:`smooth`})},[p,ue]);c({pageRoute:`/`,quests:n,initialSource:v,currentSource:b}),l({pageRoute:`/`,quests:n,completedResults:L}),U.current=d(`/`,n),u({pageRoute:`/`,quests:n,running:ie}),(0,K.useEffect)(()=>{let e=document.getElementById(`tour-section-insights`);if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting&&U.current?.(`session-insights`)});return t.observe(e),()=>t.disconnect()},[]);let Oe=(0,K.useCallback)(e=>{x(e),e!==v&&!w.current&&(w.current=!0,m?.($R.demoEdited))},[v,m]),ke=(0,K.useCallback)(e=>{C.current=e},[]),Ae=(0,K.useCallback)((e,t,n,r)=>{if(n){if(m?.($R.demoRun),r&&ae(!0),se(n),B(!0),re(!0),W(e=>e+1),R(null),H.current||ee.current){ee.current={kind:`restart`,doc:t,block:n,sectionTitle:e};return}if(k.current&&A.current&&!j.current){ee.current={kind:`restart`,doc:t,block:n,sectionTitle:e},I.current=!0,F(!0);return}if(k.current&&!j.current){O().then(()=>ce(t,n,e));return}ce(t,n,e)}},[ce,O,m]),je=(0,K.useCallback)(()=>{Ae(`Run`,S.current,C.current[0],!0)},[Ae]),Me=(0,K.useCallback)(()=>{ge.current||he(!0),ye(()=>{let e=document.getElementById(`tour-section-insights`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY,r=Math.max(0,e.getBoundingClientRect().top+window.scrollY-n);window.scrollTo({top:r,behavior:p?`auto`:`smooth`})})},[p,ye]),Ne=(0,K.useCallback)((e,t)=>{if(!(j.current&&!N.current))return(t.logs??[]).length===0?(j.current=!0,R(t),B(!1),Me(),le()):(j.current=!0,D(t,t.completed).then(()=>{if(N.current=null,R(t),I.current||ee.current)return B(!1),le()}).catch(e=>{throw j.current=!1,A.current=!1,N.current=t,I.current=!1,F(!1),ee.current=null,f({title:`Session not saved`,description:`The run could not be recorded. Nothing was lost — your next action retries the save.`,variant:`destructive`}),e}))},[D,le,Me]),Pe=(0,K.useCallback)(()=>{B(!1),Me()},[Me]),Fe=(0,K.useRef)(null),Ie=(0,K.useCallback)(e=>{Fe.current=e},[]),Le=(0,K.useCallback)(()=>{A.current=!0;let e=Fe.current;ne&&e&&e.handle(new Nh(void 0,e.nowProvider)),re(!1)},[ne]),{setL3Items:Re}=MV(),ze=(0,K.useMemo)(()=>[{id:`tour-hero`,label:`Welcome`,level:3,action:{type:`scroll`,sectionId:`tour-hero`}},{id:`editor`,label:`Live Preview`,level:3,action:{type:`scroll`,sectionId:`tour-section-editor`}},{id:`insights`,label:`Session Insights`,level:3,action:{type:`scroll`,sectionId:`tour-section-insights`},secondaryAction:{id:`run-start`,label:`Run the workout`,action:{type:`call`,handler:je}}},{id:`boards`,label:`One Run Becomes Many`,level:3,action:{type:`scroll`,sectionId:`tour-section-boards`}},{id:`community-feeds`,label:`Library & Community Feeds`,level:3,action:{type:`scroll`,sectionId:`tour-section-community-feeds`}},{id:`offerings`,label:`Who owns the Data?`,level:3,action:{type:`scroll`,sectionId:`tour-section-offerings`}},{id:`university`,label:`Wod Wiki University`,level:3,action:{type:`scroll`,sectionId:`tour-section-university`}}],[je]);(0,K.useEffect)(()=>(Re(ze),()=>Re([])),[Re,ze]),Y_e((0,K.useMemo)(()=>ze.map(e=>e.action.type===`scroll`?e.action.sectionId:e.id),[ze]));let Be=T?.block??oe,Ve=z&&Be&&(0,q.jsx)(i??B2,{block:Be,resultId:T?.resultId,autoStart:ne,externalStop:P,onRunStarted:Le,onRuntimeReady:Ie,onClose:Pe,onCompleteWorkout:Ne},te),He=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(M6,{}),(0,q.jsxs)(`p`,{className:`-mt-4 px-4 pb-8 text-center font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground xl:text-[11px]`,children:[`— or learn the language with examples`,` `,(0,q.jsx)(M,{to:`/syntax`,className:`inline-flex min-h-11 items-center text-foreground underline underline-offset-4 transition-colors hover:text-primary`,children:`on the syntax page →`})]})]}),Ue=(0,q.jsx)(Y4,{gateId:`editor-pane`,segmentId:`hero`,className:`w-full max-w-[720px] xl:max-w-[820px] 2xl:max-w-[920px]`,children:(0,q.jsx)(i2,{title:y?y.toLowerCase().startsWith(`shared by`)?y:`shared by: ${y}`:`welcome-1.md`,headerActions:y&&(0,q.jsx)(`button`,{type:`button`,onClick:G,title:`Reset`,className:`rounded-md border border-border px-2 py-1 text-[10px] transition-colors hover:bg-accent`,"data-testid":Q.tour.HERO_RESET_SHARED,children:`Reset`}),className:`h-[clamp(260px,42svh,360px)] sm:h-[clamp(300px,46svh,420px)] lg:h-[clamp(380px,50svh,480px)] 2xl:h-[520px]`,children:(0,q.jsx)(N6,{doc:b,theme:t,onDocChange:Oe,onBlocksChange:ke,onRun:je,editorSlot:r})})}),We=(0,q.jsx)(`div`,{ref:_e,id:`tour-why-video-wrap`,"aria-hidden":me,className:$(`grid w-full transition-all duration-300 motion-reduce:transition-none`,me?`grid-rows-[0fr] opacity-0 invisible`:`grid-rows-[1fr] opacity-100`),children:(0,q.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,q.jsx)(Q_e,{onWatched:xe})})}),Ge=(0,q.jsxs)(`div`,{ref:fe,id:`tour-section-editor`,"data-testid":Q.tour.SECTION_EDITOR,className:`flex w-full scroll-mt-[72px] flex-col items-center px-4 py-6 text-center sm:px-5 sm:py-8 lg:scroll-mt-[104px] lg:px-10 xl:py-10 2xl:px-16`,children:[(me||we)&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-center gap-2`,children:[me&&(0,q.jsxs)(`button`,{type:`button`,onClick:Se,"data-testid":Q.tour.WHY_WATCH_AGAIN,className:`relative inline-flex min-h-9 items-center gap-1.5 rounded-t-lg border border-b-0 border-border bg-muted/40 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-['']`,children:[(0,q.jsx)(Sr,{className:`size-3`,"aria-hidden":!0}),`Watch again`]}),we&&(0,q.jsxs)(`button`,{type:`button`,onClick:Ee,"data-testid":Q.tour.EDITOR_RESET_EDITED,className:`relative inline-flex min-h-9 items-center gap-1.5 rounded-t-lg border border-b-0 border-border bg-muted/40 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-['']`,children:[(0,q.jsx)(hr,{className:`size-3`,"aria-hidden":!0}),`Edited — reset to the welcome doc`]})]}),Ue]});return p?(0,q.jsxs)(`div`,{"data-testid":Q.tour.HOME_TOUR,children:[(0,q.jsxs)(`section`,{id:`tour-hero`,"data-testid":Q.tour.HERO,className:`flex flex-col items-center gap-5 px-6 py-6 text-center`,children:[(0,q.jsx)(C6,{}),We,Ge]}),(0,q.jsx)(G6,{session:L,onRun:je,onBackToEditor:De}),(0,q.jsx)(Z6,{feedDeps:o}),He,(0,q.jsx)(O3,{variant:`university`}),(0,q.jsx)(T6,{}),Ve]}):(0,q.jsxs)(`div`,{"data-testid":Q.tour.HOME_TOUR,children:[(0,q.jsx)(`div`,{ref:de,"aria-hidden":!0,className:`h-px`}),(0,q.jsxs)(`section`,{ref:pe,id:`tour-hero`,"data-testid":Q.tour.HERO,className:`relative flex min-h-[calc(100svh-65px)] flex-col items-center justify-center gap-5 px-5 py-6 text-center lg:min-h-[calc(100svh-104px)] lg:px-10 xl:gap-7 xl:py-8 2xl:px-16`,children:[(0,q.jsx)(C6,{}),We,Ge]}),(0,q.jsx)(G6,{session:L,onRun:je,onBackToEditor:De}),(0,q.jsx)(Z6,{feedDeps:o}),He,(0,q.jsx)(O3,{variant:`university`}),(0,q.jsx)(T6,{}),Ve]})}function zve(e){return(0,q.jsx)(b6,{children:(0,q.jsx)(Ihe,{children:(0,q.jsx)(Rve,{...e})})})}function Bve({wodFiles:e,theme:t}){let n=(0,K.useMemo)(()=>g6(e),[e]);return(0,K.useEffect)(()=>{OE(`homeFirstPaint`)},[]),(0,q.jsx)(zve,{wodFiles:n,theme:t,quests:h6.quests})}var Vve=[`📓`,`🏋️`,`🔥`,`💪`,`⭐`,`🎯`,`🏃`,`🧘`,`🥊`,`🚴`],Hve=({open:e,onOpenChange:t,onCreate:n,notebook:r,onSave:i})=>{let[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(`📓`),[d,f]=(0,K.useState)(!1),p=!!r;K.useEffect(()=>{e&&(o(r?.name??``),c(r?.description??``),u(r?.icon??`📓`))},[e,r]);let m=async()=>{if(!(!a.trim()||d)){f(!0);try{let e=a.trim();if(!(p&&r&&i?await i(r,e,s.trim(),l):await n(e,s.trim(),l)))return;p||(o(``),c(``),u(`📓`)),t(!1)}finally{f(!1)}}};return(0,q.jsxs)(Le,{open:e,onOpenChange:t,children:[(0,q.jsx)(xt,{}),(0,q.jsxs)(g,{className:`bg-popover text-popover-foreground border border-border`,children:[(0,q.jsxs)(Io,{children:[(0,q.jsx)(de,{className:`text-foreground`,children:p?`Edit Notebook`:`Create Notebook`}),(0,q.jsx)(Yt,{children:p?`Rename, describe or re-icon this notebook.`:`Organize your sessions into collections.`})]}),(0,q.jsxs)(`div`,{className:`space-y-4 mt-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-foreground/80 mb-2 block`,children:`Icon`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Vve.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:$(`w-9 h-9 rounded-md flex items-center justify-center text-lg transition-all`,`hover:bg-accent hover:scale-110`,l===e?`bg-primary/20 ring-2 ring-primary scale-110`:`bg-muted/50`),children:e},e))})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`label`,{className:`text-sm font-medium text-foreground/80 mb-1 block`,children:[`Name `,(0,q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,q.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&!e.shiftKey&&a.trim()&&(e.preventDefault(),m())},placeholder:`e.g., Morning Routines`,autoFocus:!0,className:$(`w-full px-3 py-2 rounded-md text-sm`,`bg-background border border-border`,`text-foreground placeholder:text-muted-foreground`,`focus:outline-none focus:ring-2 focus:ring-primary/50`,`transition-colors`)})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`label`,{className:`text-sm font-medium text-foreground/80 mb-1 block`,children:[`Description `,(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`(optional)`})]}),(0,q.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`A brief description of this notebook...`,rows:2,className:$(`w-full px-3 py-2 rounded-md text-sm resize-none`,`bg-background border border-border`,`text-foreground placeholder:text-muted-foreground`,`focus:outline-none focus:ring-2 focus:ring-primary/50`,`transition-colors`)})]}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(J,{variant:`default`,size:`sm`,onClick:()=>void m(),disabled:!a.trim()||d,children:d?`Saving…`:p?`Save`:`Create`})]})]})]})]})};function Q6({value:e,max:t,label:n,className:r}){let a=Math.max(1,t),o=Math.min(Math.max(e,0),a),s=(0,K.useRef)(o),[c,l]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(o>s.current){l(!0);let e=setTimeout(()=>l(!1),200);return s.current=o,()=>clearTimeout(e)}s.current=o},[o]),(0,q.jsxs)(wn,{value:o,max:a,"aria-label":n?void 0:`Progress`,className:$(`w-full min-w-0 gap-1.5`,r),children:[n?(0,q.jsxs)(`span`,{className:`flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.14em] text-brand-deep dark:text-brand-light`,children:[(0,q.jsx)(i,{className:`font-semibold text-brand-deep dark:text-brand-light`,children:n}),(0,q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[o,`/`,a]})]}):null,(0,q.jsx)(cr,{render:(0,q.jsx)(`span`,{}),className:`block h-2 w-full overflow-hidden rounded-pill bg-brand/10`,children:(0,q.jsx)(gt,{className:$(`h-full rounded-pill transition-[width] duration-500 ease-out`,c?`bg-brand-deep`:`bg-brand`)})})]})}var $6=e(ga(),1),e8=[`agg`,`metric`,`rollup`,`pipes`];function t8(e){let t=t_(e);if(t.error||!Bg(t))return null;let n=t.filters.filter(e=>e.key===`source`&&!e.negate);return n.length===1&&n[0].values.length===1?n[0].values[0].value:n.length===0&&t.sourceScope?.length===1?t.sourceScope[0]:null}function Uve({initialQuery:e,onApply:t}){let[n,r]=(0,K.useState)(e),i=(0,K.useCallback)(e=>{r(e),t(e)},[t]);return(0,q.jsx)(`div`,{"data-testid":Q.STREAM_MOBILE_FACETS,className:`max-h-[42vh] overflow-y-auto border-t border-border/60 bg-background/60 px-3 py-2`,children:(0,q.jsx)(cK,{query:n,onQueryChange:i,heading:`Guided filters`})})}function n8(e,t,n,r){xQ.getState().open({placeholder:`Craft the query…`,header:(0,q.jsx)(Uve,{initialQuery:e,onApply:n}),wql:{initialQuery:e,execute:t,onApply:n,preferredChoices:r,hideResults:!0},sources:[$$()]})}function r8({query:e,onQueryChange:t,scopeOptions:n,execute:r,defaultQuery:i,compact:a=!1,hasAppliedFilters:o=!1,activeFilterCount:s=0,className:c}){let[u,d]=(0,K.useState)(!1),f=e||i||``,p=(0,K.useMemo)(()=>ok(f,`Filter or search…`),[f]),m=(0,K.useMemo)(()=>{if(u)return e8;let e=[`kind`,`target`,...e8];if(i){let t=t8(i),n=t8(f);t&&n===t&&e.push(`source`)}return e},[u,i,f]),h=(0,K.useCallback)(()=>n8(f,r,t,n),[f,r,t,n]);return a?(0,q.jsx)(`div`,{"data-testid":Q.STREAM_QUERY_BAR_DOCK,className:$(`flex min-h-12 w-full items-stretch overflow-hidden rounded-xl border border-border bg-card shadow-xs`,c),children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":Q.STREAM_QUERY_BAR,onClick:h,title:f||void 0,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-2.5 px-3 text-left transition-colors hover:bg-muted/60`,children:[(0,q.jsx)(zi,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{"data-testid":Q.STREAM_QUERY_SUMMARY,"data-wql":f,className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground`,children:p}),o&&s>0&&(0,q.jsx)(`span`,{"data-testid":Q.STREAM_FACET_FILTER_BADGE,className:`inline-flex min-w-5 items-center justify-center rounded-full bg-primary px-1.5 py-0.5 text-[11px] font-bold text-primary-foreground`,children:s}),(0,q.jsx)(It,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]})}):(0,q.jsxs)(`div`,{"data-testid":Q.STREAM_QUERY_BAR,className:$(`flex min-w-0 flex-1 items-center gap-1.5 text-xs`,c),children:[(0,q.jsx)(Nk,{query:e,onQueryChange:t,onScopeOpenChange:d,compact:!0,surface:`popover`,showDiagnostics:!1,hiddenClauseTypes:m,preferredChoices:n,placeholder:`Filter or search…`,className:`min-w-0 flex-1`}),(0,q.jsxs)(nt,{children:[(0,q.jsxs)(l,{render:(0,q.jsx)(J,{type:`button`,variant:o?`secondary`:`outline`,size:`sm`,"data-testid":Q.STREAM_FACET_FILTER_TRIGGER,"aria-label":o&&s>0?`Guided filters (${s} active)`:`Open guided filters`,className:`h-8 shrink-0 gap-1.5 px-2.5 text-xs font-semibold`}),children:[(0,q.jsx)(bi,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Filters`}),o&&s>0&&(0,q.jsx)(`span`,{"data-testid":Q.STREAM_FACET_FILTER_BADGE,className:`inline-flex min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-bold text-primary-foreground`,children:s})]}),(0,q.jsx)(Lr,{align:`start`,sideOffset:6,"data-testid":Q.STREAM_FACET_FILTER_POPOVER,className:`w-80 max-h-[70vh] overflow-y-auto p-3`,children:(0,q.jsx)(cK,{query:f,onQueryChange:t,heading:`Filter facets`})})]})]})}function i8(e,t){let n=t??t_(e);return n.error?null:n.groupBy?.length?n.groupBy.map(e=>String(e).toLowerCase()):null}function a8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/(^-|-$)/g,``)||`default`}function o8(e,t=`date`,n){let r=(Array.isArray(t)?t:[t]).map(e=>String(e).toLowerCase()).filter(Boolean);r.length===0&&r.push(`date`);let i=(e,t)=>{let r=Wve(e,t[0],n);return t.length===1?r:r.flatMap(e=>e.key===`shelf`?[e]:i(e.entries,t.slice(1)).map(t=>({...t,key:`${e.key}/${t.key}`,id:`${e.id}--${t.id}`,label:`${e.label} / ${t.label}`,isToday:e.isToday||t.isToday})))};return i(e,r)}function s8(e){return e.date??(e.sourceNotebook===`playground`&&e.createdAt&&e.createdAt>9466848e5?new Date(e.createdAt).toISOString().slice(0,10):null)}function Wve(e,t,n){let r=t.toLowerCase(),i=fT();if(r===`date`||r===`day`){let t=new Map,r=[],a=[];for(let i of e){let e=s8(i);if(n?.shelfVisible&&(e==null||i.kind===`note`&&!i.sourceNote))r.push(i);else if(e){let n=t.get(e);n?n.push(i):t.set(e,[i])}else a.push(i)}let o=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)),s=[];n?.shelfVisible&&r.length>0&&s.push({id:`group-shelf`,key:`shelf`,label:`Notebook Sessions`,entries:r});for(let e of o)s.push({id:`date-group-${e}`,key:e,label:e===i?`Today`:pT(e),isToday:e===i,entries:t.get(e)??[]});return a.length>0&&s.push({id:`group-date-undated`,key:`undated`,label:`Undated`,entries:a}),s}if(r===`week`){let t=new Map,n=[];for(let r of e){let e=s8(r);if(!e){n.push(r);continue}let[i,a,o]=e.split(`-`).map(Number),s=new Date(Date.UTC(i,a-1,o)),c=s.getUTCDay(),l=s.getUTCDate()-c+(c===0?-6:1),u=new Date(Date.UTC(i,a-1,l)),d=u.toISOString().slice(0,10),f=`Week of ${u.toLocaleDateString(`en`,{month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`})}`,p=t.get(d);p?p.entries.push(r):t.set(d,{label:f,entries:[r]})}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-week-${e}`,key:e,label:t.get(e).label,entries:t.get(e).entries}));return n.length>0&&r.push({id:`group-week-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`month`){let t=new Map,n=[];for(let r of e){let e=s8(r);if(!e){n.push(r);continue}let i=e.slice(0,7),[a,o]=i.split(`-`).map(Number),s=new Date(Date.UTC(a,o-1,1)).toLocaleDateString(`en`,{month:`long`,year:`numeric`,timeZone:`UTC`}),c=t.get(i);c?c.entries.push(r):t.set(i,{label:s,entries:[r]})}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-month-${e}`,key:e,label:t.get(e).label,entries:t.get(e).entries}));return n.length>0&&r.push({id:`group-month-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`year`){let t=new Map,n=[];for(let r of e){let e=s8(r);if(!e){n.push(r);continue}let i=e.slice(0,4),a=t.get(i);a?a.push(r):t.set(i,[r])}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-year-${e}`,key:e,label:e,entries:t.get(e)??[]}));return n.length>0&&r.push({id:`group-year-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`discipline`){let t=new Map;for(let n of e){let e=n.effort?.discipline||n.tags?.find(e=>[`strength`,`gymnastics`,`cardio`,`running`,`rowing`,`weightlifting`,`olympic-weightlifting`].includes(e.toLowerCase()))||`General`,r=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),i=t.get(r);i?i.push(n):t.set(r,[n])}return MU(Array.from(t.entries()),`priority-then-alpha`,{priority:[`Strength`,`Gymnastics`,`Cardio`,`Running`,`Rowing`,`Weightlifting`]}).map(([e])=>e).map(e=>({id:`group-discipline-${a8(e)}`,key:e,label:e,entries:t.get(e)??[]}))}if(r===`origin`){let t=new Map;for(let n of e){let e=n.effort?.registrySource===`bundled`?`Bundled Standards`:`Custom Movements`,r=t.get(e);r?r.push(n):t.set(e,[n])}return MU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-origin-${a8(e)}`,key:e,label:e,entries:t}))}if(r===`source`||r===`notebook`){let t=new Map;for(let n of e){let e=n.sourceNotebook||`Other`,r=e.charAt(0).toUpperCase()+e.slice(1),i=t.get(r);i?i.push(n):t.set(r,[n])}return MU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-source-${a8(e)}`,key:e,label:e,entries:t}))}if(r===`kind`||r===`type`){let t=new Map;for(let n of e){let e=n.kind.charAt(0).toUpperCase()+n.kind.slice(1)+`s`,r=t.get(e);r?r.push(n):t.set(e,[n])}return MU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-kind-${a8(e)}`,key:e,label:e,entries:t}))}if(r===`feed`){let t=new Map;for(let n of e){let e=n.feedId??(n.sourceNotebook===`journal`||n.sourceNotebook===`playground`?`local`:`core`),r=t.get(e);r?r.push(n):t.set(e,[n])}return MU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-feed-${a8(e)}`,key:e,label:e===`local`?`Local`:e===`core`?`Core`:e,entries:t}))}if(!dg.includes(r)){let t=new Map;for(let n of e){let e=n.typedTags?.find(e=>e.type?.toLowerCase()===r)?.label??`Unassigned`,i=t.get(e);i?i.push(n):t.set(e,[n])}return MU(Array.from(t.entries()),`alpha-sink-last`,{sink:`Unassigned`}).map(([e,t])=>({id:`group-property-${a8(r)}-${a8(e)}`,key:e,label:e,entries:t}))}let a=new Map;for(let t of e){let e=t.tags?.[0]?`#${t.tags[0]}`:`Untagged`,n=a.get(e);n?n.push(t):a.set(e,[t])}return MU(Array.from(a.entries()),`alpha-sink-last`,{sink:`Untagged`}).map(([e,t])=>({id:`group-tag-${a8(e)}`,key:e,label:e,entries:t}))}var Gve=[{id:XV.route,label:`Journal`,profile:XV,scopeChoices:kO,shortcuts:!0},{id:QV.route,label:`Notes`,profile:QV,scopeChoices:kO,shortcuts:!0},{id:ZV.route,label:`Notebooks`,profile:ZV,scopeChoices:kO,shortcuts:!0},{id:$V.route,label:`Feeds`,profile:$V,scopeChoices:kO,shortcuts:!0},{id:eH.route,label:`Pages`,profile:eH,scopeChoices:kO,shortcuts:!0},{id:tH.route,label:`Efforts`,profile:tH,scopeChoices:kO,shortcuts:!0},{id:nH.route,label:`Equipment`,profile:nH,scopeChoices:kO,shortcuts:!0},{id:rH.route,label:`Tags`,profile:rH,shortcuts:!0},{id:iH.route,label:`Sessions`,profile:iH,scopeChoices:kO,shortcuts:!0},{id:aH.route,label:`Playgrounds`,profile:aH,scopeChoices:kO,shortcuts:!0}],c8={id:`/dashboards`,label:`Dashboards`,systemDefaultWql:`:dashboard{}`},l8={id:IU,label:`Command palette`,systemDefaultWql:Xue,scopeChoices:kO},Kve=[...Gve,c8,l8];function qve(e){return Kve.find(t=>t.id===e)}var u8=`w-full rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`;function Jve({open:e,onOpenChange:t,route:n,editing:r=null,initialQuery:i=``}){let[a,o]=(0,K.useState)(r?.label??``),[s,c]=(0,K.useState)(r?.icon??`bookmark`),[l,u]=(0,K.useState)(r?r.wql:i),[d,f]=(0,K.useState)(null),p=dW(n);(0,K.useEffect)(()=>{e&&(o(r?.label??``),c(r?.icon??`bookmark`),u(r?r.wql:i),f(null))},[e,r,i]);let m=r!==null&&!!r.to,h=r?.id!==`all`,g=a.trim(),_=l.trim(),v=_?nk(_).error??null:null,y=g?null:`Label is required.`,b=!!g&&!m&&(!h||!!_)&&!v;return(0,q.jsx)(pD,{open:e,onClose:()=>t(!1),title:r?`Edit shortcut`:`Save search shortcut`,description:`Saved shortcuts appear in this route's navigation panel. Stored ${PR?`on the server.`:`in this browser only.`}`,footer:(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(J,{type:`submit`,form:`save-wql-shortcut-form`,size:`sm`,disabled:!b,"data-testid":`shortcut-save`,children:`Save`})]}),children:(0,q.jsxs)(`form`,{id:`save-wql-shortcut-form`,onSubmit:async e=>{if(e.preventDefault(),!b)return;let i={id:r?.id??crypto.randomUUID(),label:g,icon:s,wql:m?r.wql:_,...r?.to===void 0?{}:{to:r.to}};if(!await yW(n,[...vW(n,void 0,p).filter(e=>e.id!==i.id),i])){f(`Couldn’t save — storage is unavailable. Your input is kept.`);return}t(!1)},className:`flex flex-col gap-4`,noValidate:!0,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-label`,className:`text-xs font-semibold text-muted-foreground`,children:`Label`}),(0,q.jsx)(`input`,{id:`shortcut-label`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Strength this month`,"data-testid":`shortcut-label-input`,"aria-invalid":y?!0:void 0,className:u8}),y&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-label-error`,children:y})]}),m?(0,q.jsxs)(`p`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:[`Route action — always opens `,r?.to,`. Label and icon are editable.`]}):(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-query`,className:`text-xs font-semibold text-muted-foreground`,children:`Query (WQL)`}),(0,q.jsx)(`textarea`,{id:`shortcut-query`,rows:2,value:l,onChange:e=>u(e.target.value),placeholder:h?`find …`:`Empty — the plain route landing`,"data-testid":`shortcut-query-input`,"aria-invalid":v?!0:void 0,className:`${u8} font-mono text-xs`}),v?(0,q.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-query-error`,children:[`Couldn't parse — `,v]}):!_&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h?`A shortcut needs a query.`:`Empty — opens the plain route landing.`})]}),(0,q.jsxs)(`fieldset`,{className:`space-y-1.5`,children:[(0,q.jsx)(`legend`,{className:`text-xs font-semibold text-muted-foreground`,children:`Icon`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Object.entries(iW).map(([e,t])=>(0,q.jsxs)(`label`,{title:e,className:s===e?`cursor-pointer rounded-md border border-primary bg-primary/10 p-1.5 text-primary`:`cursor-pointer rounded-md border border-border p-1.5 text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`shortcut-icon`,value:e,checked:s===e,onChange:()=>c(e),"aria-label":`Icon ${e}`,"data-testid":`shortcut-icon-${e}`,className:`sr-only`}),(0,q.jsx)(t,{className:`size-4`,"aria-hidden":`true`})]},e))})]}),d&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-storage-error`,children:d})]})})}var Yve=Object.fromEntries([...kO,...OO].map(e=>[e.value,e.label]));function d8({values:e,choices:t,labels:n,onChange:r,testPrefix:i,reorderable:a=!1}){let o=(t,n)=>{let i=[...e],a=t+n;if(a<0||a>=i.length)return;let o=i[t];i[t]=i[a],i[a]=o,r(i)};return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[e.length>0&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((t,s)=>(0,q.jsxs)(`span`,{"data-testid":`${i}-chip-${t}`,className:`inline-flex items-center gap-1 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium`,children:[n[t]??t,a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`Move ${t} up`,"data-testid":`${i}-up-${t}`,disabled:s===0,onClick:()=>o(s,-1),className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,q.jsx)(Ut,{className:`size-3`})}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Move ${t} down`,"data-testid":`${i}-down-${t}`,disabled:s===e.length-1,onClick:()=>o(s,1),className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,q.jsx)(bee,{className:`size-3`})})]}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t}`,"data-testid":`${i}-remove-${t}`,onClick:()=>r(e.filter(e=>e!==t)),className:`text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(ze,{className:`size-3`})})]},t))}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.filter(t=>!e.includes(t.value)).map(t=>(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Add ${t.value}`,"data-testid":`${i}-add-${t.value}`,onClick:()=>r([...e,t.value]),className:`rounded-full border border-dashed border-border/70 px-2.5 py-1 text-xs text-muted-foreground hover:text-foreground hover:border-foreground/40`,children:[`+ `,t.label]},t.value))})]})}function Xve({values:e,choices:t,onChange:n,testPrefix:r}){return(0,q.jsx)(d8,{values:e,choices:t,labels:Yve,onChange:n,testPrefix:r,reorderable:!0})}function Zve({values:e,onChange:t,testPrefix:n}){return(0,q.jsx)(d8,{values:e,choices:OU.map(e=>({value:e.id,label:e.label})),labels:Object.fromEntries(OU.map(e=>[e.id,e.label])),onChange:t,testPrefix:n,reorderable:!0})}function f8({label:e,enabled:t,onEnabledChange:n,testId:r,children:i}){return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:e}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[`Custom`,(0,q.jsx)(un,{checked:t,onCheckedChange:n,"data-testid":r,children:(0,q.jsx)(Cn,{})})]})]}),i]})}function Qve({shortcuts:e,icons:t,landingId:n,onEdit:r,onDelete:i,onCreate:a,error:o,testPrefix:s}){return(0,q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`${s}-shortcuts`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:`Saved shortcuts`}),(0,q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:a,"data-testid":`${s}-shortcut-new`,children:`New shortcut`})]}),e.map(e=>{let a=t[e.icon]??t.bookmark,o=e.to?`Opens ${e.to}`:e.wql||`Landing (no query)`;return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 px-2 py-1.5`,"data-testid":`${s}-shortcut-${e.id}`,children:[(0,q.jsx)(a,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`min-w-0 max-w-40 truncate text-xs font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10px] text-muted-foreground`,children:o}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.label}`,"data-testid":`${s}-shortcut-edit-${e.id}`,onClick:()=>r(e),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Nn,{className:`size-3`})}),!e.to&&e.id!==n&&(0,q.jsx)(`button`,{type:`button`,"aria-label":`Delete ${e.label}`,"data-testid":`${s}-shortcut-delete-${e.id}`,onClick:()=>i(e.id),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,q.jsx)(Me,{className:`size-3`})})]},e.id)}),o&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`${s}-shortcut-error`,children:o})]})}function p8(e){return{defaultWql:e.defaultWql??``,customScope:e.typeOptions!==void 0,scopeOptions:e.typeOptions??[],customGroupBy:e.groupByOptions!==void 0,groupByOptions:e.groupByOptions??[]}}function $ve(e){return{defaultWql:e.defaultWql.trim()||void 0,typeOptions:e.customScope?e.scopeOptions:void 0,groupByOptions:e.customGroupBy?e.groupByOptions:void 0}}function m8({surface:e,onSaved:t}){let n=tW(e.id),r=TW(e.id),[i,a]=(0,K.useState)(()=>p8(n)),[o,s]=(0,K.useState)(()=>n),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(null);(0,K.useEffect)(()=>{a(p8(n)),s(n),l(null),d(null)},[n]);let m=e.profile?.defaultWql??e.systemDefaultWql??``,h=(()=>{let e=i.defaultWql.trim();return e?nk(e).error??null:null})(),g=$ve(i),_=JSON.stringify(g)!==JSON.stringify(o),v=Object.values(o).some(e=>e!==void 0),y=[...o.invalidTypeOptions??[],...o.invalidGroupByOptions??[]],b=async()=>{if(!_)return;let n=i.defaultWql.trim();if(!(n&&nk(n).error)){if(!await JU(e.id,g)){l(`Save failed — storage is unavailable; the previous default still stands.`);return}l(null),s(qU(e.id)),t?.()}},x=async()=>{if(!await YU(e.id)){l(`Reset failed — storage is unavailable; the stored override still stands.`);return}l(null),s({}),a(p8({})),t?.()},S=async t=>{d(null),await yW(e.id,r.filter(e=>e.id!==t))||d(`Delete failed — storage is unavailable. Nothing was lost; the link remains.`)},C=e.scopeChoices??[],w=C.length>0;return(0,q.jsxs)(`div`,{className:`space-y-5`,"data-testid":`query-settings-panel`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:`Landing default query`}),(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`System default: `,(0,q.jsx)(`span`,{className:`font-mono`,children:m})]}),(0,q.jsx)(`textarea`,{rows:2,value:i.defaultWql,onChange:e=>a({...i,defaultWql:e.target.value}),placeholder:m,"data-testid":`query-settings-wql`,className:`w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-primary/40`}),h?(0,q.jsxs)(`p`,{className:`text-xs text-destructive`,"data-testid":`query-settings-wql-error`,children:[`Couldn't parse — `,h]}):!i.defaultWql.trim()&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Empty — the system default is used.`})]}),y.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-invalid`,children:[`Stored options no longer recognized: `,y.join(`, `),` — remove them; they are never turned into query clauses.`]}),w&&(0,q.jsx)(f8,{label:`Where-stored options`,enabled:i.customScope,onEnabledChange:e=>a({...i,customScope:e}),testId:`query-settings-scope-custom`,children:i.customScope&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Xve,{values:i.scopeOptions,choices:C,onChange:e=>a({...i,scopeOptions:e}),testPrefix:`query-settings-scope`}),i.scopeOptions.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-scope-empty`,children:`No predefined options — the page nudges for a pick instead.`})]})}),e.profile&&(0,q.jsxs)(f8,{label:`Group-by options`,enabled:i.customGroupBy,onEnabledChange:e=>a({...i,customGroupBy:e}),testId:`query-settings-group-custom`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The dimensions this page offers first, and the one a bare landing groups by. Order is the priority.`}),i.customGroupBy&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Zve,{values:i.groupByOptions,onChange:e=>a({...i,groupByOptions:e}),testPrefix:`query-settings-group`}),i.groupByOptions.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-group-empty`,children:`No favorites — the page groups by its own default.`})]})]}),e.shortcuts&&(0,q.jsx)(Qve,{shortcuts:r,icons:iW,landingId:`all`,onEdit:e=>p({editing:e}),onDelete:S,onCreate:()=>p({editing:null}),error:u,testPrefix:`query-settings`}),c&&(0,q.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`query-settings-storage-error`,role:`alert`,children:c}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:x,disabled:!v,"data-testid":`query-settings-reset`,children:[(0,q.jsx)(hr,{className:`size-3.5`}),(0,q.jsx)(`span`,{children:`Reset to system default`})]}),(0,q.jsx)(J,{size:`sm`,onClick:b,disabled:!_||!!h,"data-testid":`query-settings-save`,children:`Save`})]}),f&&(0,q.jsx)(Jve,{open:!0,onOpenChange:e=>{e||p(null)},route:e.id,editing:f.editing})]})}function h8({surface:e,open:t,onOpenChange:n}){return(0,q.jsx)(pD,{open:t,onClose:()=>n(!1),title:`${e.label} query settings`,description:`Override the landing query and the Where-stored / Group-By options for this page. An empty query uses the system default; an emptied options list nudges you to pick instead of presetting one. Option lists are favorites — they reorder choices, they don't change what queries mean.`,presentation:`sheet`,children:(0,q.jsx)(m8,{surface:e})})}var g8=e=>coe(new Date(e));function _8(e,t){pQ(e===`imported`?{title:`${t} synced`,description:`Content was synced from the published feed. Your own edits and logged workouts were kept.`}:e===`error`?{title:`${t} sync failed`,description:`Check your connection and try again.`,variant:`destructive`}:e===`busy`?{title:`Another tab is already syncing`,description:`Wait for it to finish, then try again.`}:{title:`${t} is up to date`})}var v8={imported:`Synced`,current:`Up to date`,"server-stale":`Published version is older than the stored version`,"update-pending":`Update available`,busy:`Another tab is syncing`,disabled:`Feed import is disabled`,error:`Sync failed`};function y8(e){switch(e.phase){case`checking`:return`Checking source…`;case`fetching`:return`Downloading ${e.chunkId}…`;case`applying`:return`Importing ${e.chunkId}…`;case`committed`:return`Committed ${e.chunkId}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return e.error??v8[e.outcome]}}function eye({source:e,running:t,subscribing:n=!1,disabled:r,onSync:i,onSubscribe:a,onDownloadOffline:o,onSwitchIndexOnly:s,onUnsubscribe:c,onDelete:l,onAutoSync:u,onToggleNotebook:d}){let f=dt(),p=(0,K.useSyncExternalStore)(qI,()=>YI(e.id)),m=e.notebooks.filter(t=>t.id!==e.id),h=VI(e.id),g=m.filter(e=>e.subscribed).length,_=e.autoImport,v=_||e.offlinePolicy===`offline-full`,y=e.subscribed&&!v,b=e.subscribed&&v&&!e.upToDate&&e.remote!==null,x=(0,K.useRef)(null);(0,K.useLayoutEffect)(()=>{let e=e=>{e.key===`Escape`&&x.current?.open&&(e.preventDefault(),x.current.open=!1,x.current.removeAttribute(`open`),x.current.querySelector(`summary`)?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let S=e=>{let t=e.currentTarget.closest(`details`);t&&(t.open=!1)},C=y?e.indexBytes&&e.indexBytes>0?`${B3(e.indexBytes)} index`:`Index-only`:B3(e.chunkBytes??e.bytes);return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 space-y-3`,"data-testid":`feed-source-${e.id}`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,q.jsx)(M,{to:SH(e.id),className:`no-underline hover:underline text-sm font-semibold text-foreground truncate`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded shrink-0 ${e.subscribed?`bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`:`bg-muted text-muted-foreground`}`,children:e.subscribed?`Subscribed`:`Not subscribed`}),_&&(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-muted text-muted-foreground shrink-0`,children:`Core`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 flex-wrap justify-end`,children:[!e.subscribed||n?(0,q.jsxs)(J,{size:`sm`,onClick:()=>a(e.id),disabled:r||!!n,"aria-busy":t||!!n,"data-testid":`feed-subscribe-${e.id}`,className:`gap-2`,children:[t||n?(0,q.jsx)(mi,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(yr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:t||n?`Subscribing…`:`Subscribe`})]}):b?(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>i(e.id),disabled:r,"data-testid":`feed-sync-${e.id}`,className:`gap-2`,children:[(0,q.jsx)(mi,{className:`size-3.5 ${t?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:t?`Syncing…`:`Sync`})]}):(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,"data-testid":`feed-current-${e.id}`,children:[(0,q.jsx)(kt,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),y?`Index active`:e.remote===null?`Remote unreachable`:`Up to date`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:e.subscribed?`Apply new published versions automatically during the load-time check. Turning it off never removes content.`:`Unsubscribed sources never auto-import.`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 accent-primary`,checked:p,disabled:r||!e.subscribed,onChange:t=>u(e.id,t.target.checked),"aria-label":`Auto-sync ${e.label}`,"data-testid":`feed-autosync-${e.id}`}),(0,q.jsx)(`span`,{children:`Auto-sync`})]}),(0,q.jsxs)(`details`,{ref:x,className:`relative shrink-0`,"data-testid":`feed-more-${e.id}`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,q.jsx)(`summary`,{"aria-label":`More actions for ${e.label}`,className:`flex cursor-pointer list-none items-center justify-center rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:`…`}),(0,q.jsx)(`div`,{className:`fixed inset-0 z-50`,"data-testid":`feed-more-backdrop`,"aria-hidden":`true`,onClick:e=>{e.stopPropagation(),S(e)}}),(0,q.jsxs)(`div`,{className:`absolute right-0 z-[60] mt-1 flex w-64 max-w-[80vw] flex-col items-stretch gap-1.5 rounded-lg border border-border bg-card p-2 text-xs shadow-lg`,onClick:e=>{let t=e.target;(t.closest(`button`)||t.closest(`a`))&&S(e)},children:[e.url?(0,q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`no-underline hover:underline break-all font-mono text-primary`,children:[`Published HTML: `,e.url]}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Published HTML: bundled with this app (no standalone URL)`}),e.repositoryUrl?(0,q.jsx)(`a`,{href:e.repositoryUrl,target:`_blank`,rel:`noopener noreferrer`,className:`no-underline hover:underline break-all text-primary`,children:`Git source directory`}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Git repository: not published`}),!_&&e.subscribed&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:`Refresh now`}),e.hasOfflineChunks&&!v?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:[`Download for offline`,e.chunkBytes&&e.chunkBytes>0?` (${B3(e.chunkBytes)})`:``]}):v?(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:`Use index-only for future updates`}):null]}),!_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),disabled:r||!e.subscribed,"data-testid":`feed-unsubscribe-${e.id}`,className:`min-h-8 rounded-md px-2 text-left text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:`Unsubscribe`}),!_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),disabled:r,"data-testid":`feed-delete-${e.id}`,className:`min-h-8 rounded-md px-2 text-left text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:`Delete source`})]})]})]})]}),e.url&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono break-all`,"data-testid":`feed-origin-${e.id}`,children:e.url}),e.description&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,"data-testid":`feed-description-${e.id}`,children:e.description}),(0,q.jsxs)(`div`,{className:`border-t border-border/60 pt-3 space-y-2.5`,"data-testid":`feed-notebooks-${e.id}`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Subscription`}),(0,q.jsx)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-semibold ${h===`full`?`bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`:h===`partial`?`bg-amber-100 text-amber-900 dark:bg-amber-500/15 dark:text-amber-300`:`bg-muted text-muted-foreground`}`,"data-testid":`feed-sub-mode-${e.id}`,children:h===`full`?`Full`:h===`partial`?`Partial (${g} of ${m.length} subscribed)`:`Unsubscribed`}),e.subscribed&&!_&&(0,q.jsx)(`span`,{className:`text-[11px] font-medium px-2 py-0.5 rounded bg-muted text-foreground`,children:v?`Offline copy`:`Index-only`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(`/notebooks?q=:notebook{feed:${e.id},subscribed:true,false}`),"data-testid":`browse-notebooks-link-${e.id}`,className:`no-underline hover:underline text-xs font-semibold text-primary flex items-center gap-1 cursor-pointer`,children:`Browse notebooks in Library →`})]}),!_&&m.length>0&&(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-1.5`,children:m.map(t=>(0,q.jsxs)(`label`,{className:`flex items-center justify-between gap-2 rounded-md px-2 py-1 text-xs hover:bg-muted/50 cursor-pointer`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:!!t.subscribed,disabled:r,onChange:n=>d(e.id,t.chunkId,n.target.checked),"data-testid":`feed-notebook-toggle-${e.id}-${t.chunkId}`,className:`size-3.5 accent-primary rounded shrink-0`}),(0,q.jsx)(`span`,{className:`truncate text-foreground font-medium`,children:t.label})]}),t.count>0&&(0,q.jsx)(`span`,{className:`text-[11px] tabular-nums text-muted-foreground shrink-0`,children:t.count.toLocaleString()})]},t.chunkId))})]}),(0,q.jsxs)(`div`,{className:`border-t border-border/60 pt-2.5 space-y-2 text-xs`,"data-testid":`feed-status-card`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`font-medium flex items-center gap-1.5 text-foreground`,"data-testid":`feed-sync-status`,children:e.subscribed?y?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(kt,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),`Index active. Workouts load on demand.`]}):e.upToDate?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(kt,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),`Up to date`]}):e.remote==null?`Status unknown (remote unreachable)`:p?`Update available. Applied automatically on next load.`:`Update available. Sync to apply.`:`Not subscribed`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsxs)(`span`,{className:`font-medium text-muted-foreground tabular-nums`,"data-testid":`feed-source-size`,children:[e.count.toLocaleString(),` feed `,e.count===1?`item`:`items`,` · `,C]}),!_&&e.subscribed&&!v&&e.hasOfflineChunks&&(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:r,onClick:()=>o(e.id),"data-testid":`feed-download-offline-${e.id}`,className:`h-7 px-2.5 text-xs gap-1.5`,children:[(0,q.jsx)(sn,{className:`size-3`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{children:[`Download offline`,e.chunkBytes&&e.chunkBytes>0?` (${B3(e.chunkBytes)})`:``]})]})]})]}),(0,q.jsxs)(`details`,{className:`text-xs`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer select-none text-muted-foreground hover:text-foreground`,children:`Sync & version details`}),(0,q.jsxs)(`div`,{className:`mt-2 grid gap-1.5 pl-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Local copy`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`feed-local-version`,children:e.stored?`v${e.stored.version} · synced ${g8(e.stored.importedAt)}`:`Not imported yet`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Published version`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground flex items-center gap-1.5`,"data-testid":`feed-remote-version`,children:e.remote?`v${e.remote.version}`:e.remoteError?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Yi,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),`Unavailable`]}):`Not checked yet`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Last check`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`feed-last-check`,children:e.checkedAt?g8(e.checkedAt):`Not checked`})]})]})]})]})]})}function tye({deps:e={}}={}){let{readFeedStatus:t=pV,syncFeedSource:n=oV,subscribeFeed:r=sV,downloadFeedOffline:i=cV,toggleNotebookSubscription:a=lV,runFeedSync:o=rV,probeFeedManifest:s=wL,unsubscribeFeedSource:c=uV,deleteFeedSource:l=dV}=e,[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(!0),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[b,x]=(0,K.useState)(null),[S,C]=(0,K.useState)([]),[w,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(``),[O,k]=(0,K.useState)(!1),[A,j]=(0,K.useState)(null),[M,N]=(0,K.useState)(null),[P,F]=(0,K.useState)(!1),[I,ee]=(0,K.useState)(),[L,R]=(0,K.useState)(null),[z,B]=(0,K.useState)(!1),V=(0,K.useCallback)(async(e=!1)=>{_(null),e&&h(!0);try{d(await t(e?{probe:!0}:void 0))}catch(e){_(e instanceof Error?e.message:String(e))}finally{p(!1),e&&h(!1)}},[t]);(0,K.useEffect)(()=>{V(!1)},[V]),(0,K.useEffect)(()=>qI(()=>{V(!1)}),[V]),(0,K.useEffect)(()=>QB(()=>{V(!1)}),[V]);let H=(0,K.useCallback)(()=>e=>C(t=>{let n=t.find(t=>t.event.sourceId===e.sourceId),r={event:e,imported:e.phase===`checking`||e.phase===`finished`?n?.imported??null:e,chunks:e.phase===`committed`&&e.chunkId!==null?[...n?.chunks??[],e.chunkId]:n?.chunks??[]};return n?t.map(t=>t.event.sourceId===e.sourceId?r:t):[...t,r]}),[]),U=(0,K.useCallback)(async e=>{y(e??`all`),C([]);let t=H();try{_8(e?await n(e,{force:!0,onProgress:t}):await o({force:!0,onProgress:t}),e?u?.sources.find(t=>t.id===e)?.label??e:`All sources`),await V(!1)}finally{y(null)}},[H,V,o,u,n]),te=(0,K.useCallback)(async t=>{y(t),x(t),C([]);let i=H();try{let a;e.subscribeFeed?a=await r(t,{offlinePolicy:`index-only`,onProgress:i}):(UI(t,!0),QI(t,`index-only`),await XF(),a=await n(t,{offlinePolicy:`index-only`,subscribe:!0,onProgress:i}));let o=u?.sources.find(e=>e.id===t)?.label??t;_8(a,o),await V(!1)}finally{x(null),y(null)}},[e.subscribeFeed,H,V,u,r,n]),W=(0,K.useCallback)(async e=>{y(e),C([]);let t=H();try{_8(await i(e,void 0,{onProgress:t}),u?.sources.find(t=>t.id===e)?.label??e),await V(!1)}finally{y(null)}},[i,H,V,u]),ne=(0,K.useCallback)(e=>{QI(e,`index-only`),XF(),pQ({title:`${u?.sources.find(t=>t.id===e)?.label??e} set to index-only`,description:`Future updates will sync lightweight indexes only.`}),V(!1)},[V,u]),re=(0,K.useCallback)(async(e,t,n)=>{y(e);try{let r=await a(e,t,n);!n&&(r.preservedPinned??0)>0&&pQ({title:`Notebook unsubscribed`,description:`${(r.deleted??0).toLocaleString()} cached items removed. ${r.preservedPinned.toLocaleString()} logged workouts kept pinned locally.`}),await V(!1)}finally{y(null)}},[V,a]),ie=(0,K.useCallback)(async e=>{if(e?.preventDefault(),!(!E.trim()||O)){N(null),j(null),k(!0);try{let e=await s(E.trim());j(e)}catch(e){N(V3(e))}finally{k(!1)}}},[E,s,O]),ae=(0,K.useCallback)((e,t)=>{XI(e,t)?XF():pQ({title:`Couldn't save Auto-sync`,description:`Browser storage is unavailable. The choice lasts this session only.`,variant:`destructive`}),V(!1)},[V]),oe=(0,K.useCallback)(e=>{let t=u?.sources.find(t=>t.id===e)?.label??e;R({kind:`unsubscribe`,id:e,label:t})},[u]),se=(0,K.useCallback)(e=>{let t=u?.sources.find(t=>t.id===e)?.label??e;R({kind:`delete`,id:e,label:t})},[u]),ce=(0,K.useCallback)(async()=>{if(!L||z)return;B(!0);let{kind:e,id:t,label:n}=L;try{if(e===`unsubscribe`){let{deleted:e,preservedPinned:r}=await c(t),i=r??0;pQ({title:`${n} unsubscribed`,description:i>0?`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed. ${i.toLocaleString()} logged ${i===1?`workout`:`workouts`} kept pinned locally.`:`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed. Any logged workouts and your own notes remain intact.`})}else{let{deleted:e,preservedPinned:r}=await l(t),i=r??0;pQ({title:`${n} deleted`,description:i>0?`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed and source unregistered. ${i.toLocaleString()} logged ${i===1?`workout`:`workouts`} kept pinned locally.`:`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed and source unregistered.`})}R(null),await V(!1)}catch(t){pQ({title:`${n} ${e} failed`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}finally{B(!1)}},[z,l,L,V,c]),le=S.at(-1)?.event;return(0,q.jsxs)(`div`,{className:`space-y-8`,children:[(0,q.jsxs)(`section`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`text-base font-semibold text-foreground flex items-center gap-2`,children:[(0,q.jsx)(yr,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Content Sources`]}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:`Each feed publishes notebooks and workouts from its own repository. Subscribing indexes the catalog immediately and loads individual workouts when you open them, or you can opt into a full offline download.`})]}),(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void V(!0),disabled:m||v!==null,className:`gap-2 shrink-0`,children:[(0,q.jsx)(mi,{className:`size-3.5 ${m?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:m?`Checking…`:`Check updates`})]})]}),g&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-destructive`,"data-testid":`feed-status-error`,children:[(0,q.jsx)(Yi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),`Couldn't read the feed status from the active storage: `,g]}),le&&(0,q.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"data-testid":`feed-sync-progress`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm font-medium`,children:[(0,q.jsx)(`span`,{children:v===null?S.some(e=>e.event.phase===`finished`&&e.event.outcome===`error`)?`Sync finished with errors`:`Sync finished`:`Syncing…`}),(0,q.jsxs)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:[`Source `,le.sourceIndex,` of `,le.totalSources]})]}),(0,q.jsxs)(`p`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`feed-sync-live-status`,children:[le.sourceLabel,`: `,y8(le)]}),S.map(({event:e,imported:t,chunks:n})=>(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-border/50 pt-3`,children:[(0,q.jsxs)(`p`,{className:`text-xs ${e.phase===`finished`&&e.outcome===`error`?`text-destructive`:`text-muted-foreground`}`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.sourceLabel}),` · `,y8(e)]}),t&&t.totalChunks>0?(0,q.jsx)(Q6,{value:t.completedChunks,max:t.totalChunks,label:`Chunks committed · ${e.sourceLabel}`}):e.phase===`finished`?null:(0,q.jsx)(`progress`,{"aria-label":`Checking ${e.sourceLabel}`,className:`h-2 w-full`}),t&&(0,q.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-xs tabular-nums`,"data-testid":`feed-sync-totals`,children:[(0,q.jsxs)(`span`,{children:[t.totalNotes.toLocaleString(),` notes`]}),(0,q.jsxs)(`span`,{children:[t.totalEfforts.toLocaleString(),` efforts`]}),(0,q.jsxs)(`span`,{children:[t.totalBlocks.toLocaleString(),` blocks`]}),t.skippedUserOwned>0&&(0,q.jsxs)(`span`,{children:[t.skippedUserOwned.toLocaleString(),` user-owned rows preserved`]}),t.deleted>0&&(0,q.jsxs)(`span`,{children:[t.deleted.toLocaleString(),` feed rows removed`]})]}),n.length>0&&(0,q.jsxs)(`details`,{className:`text-xs`,"data-testid":`feed-sync-chunks`,children:[(0,q.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:[`Committed chunks (`,n.length,`)`]}),(0,q.jsx)(`ul`,{className:`mt-2 max-h-32 space-y-1 overflow-y-auto font-mono text-muted-foreground`,children:n.map(e=>(0,q.jsx)(`li`,{children:e},e))})]})]},e.sourceId))]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 p-2.5 rounded-lg border border-border bg-card text-xs`,children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer select-none text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>F(e.target.checked),"data-testid":`sync-subscribed-only-toggle`,className:`size-3.5 accent-primary rounded`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Subscribed only`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Source:`}),(0,q.jsxs)(`select`,{value:I??``,onChange:e=>ee(e.target.value?e.target.value:void 0),"data-testid":`sync-feed-source-filter`,"aria-label":`Filter notebooks by feed`,className:`h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none transition-colors hover:border-foreground/25 focus:border-primary/50`,children:[(0,q.jsx)(`option`,{value:``,children:`All feeds`}),u?.sources.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3`,"data-testid":`feed-source-list`,children:[u?.sources.filter(e=>{if(I&&e.id!==I)return!1;if(P){let t=e.notebooks.some(e=>e.subscribed);if(!e.subscribed&&!t)return!1}return!0}).map(e=>(0,q.jsx)(eye,{source:e,running:v===e.id||v===`all`,subscribing:b===e.id,disabled:v!==null,onSync:e=>{U(e)},onSubscribe:e=>{te(e)},onDownloadOffline:e=>{W(e)},onSwitchIndexOnly:ne,onUnsubscribe:oe,onDelete:se,onAutoSync:ae,onToggleNotebook:(e,t,n)=>{re(e,t,n)}},e.id)),f&&u===null&&(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-4 text-sm text-muted-foreground`,children:`Checking sources…`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 pt-3 border-t border-border/50`,children:[(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,children:`Syncing refreshes subscribed sources. Your own notes, workout results, and logged sessions are never overwritten.`}),(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>{U(null)},disabled:v!==null||f,"data-testid":`feed-resync-button`,className:`gap-2`,children:[(0,q.jsx)(mi,{className:`size-3.5 ${v===`all`?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:v===`all`?`Syncing all…`:`Sync All Sources`})]})]})]}),(0,q.jsxs)(`section`,{className:`space-y-4 pt-4 border-t border-border/50`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`text-base font-semibold text-foreground flex items-center gap-2`,children:[(0,q.jsx)(Pr,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Add a Source`]}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:[`Inspect any URL serving a Wod Wiki feed (a directory with `,(0,q.jsx)(`code`,{children:`manifest.json`}),`). The host must allow cross-origin reads (CORS). Nothing is saved until you review the feed and confirm Subscribe.`]})]}),(0,q.jsxs)(`form`,{onSubmit:e=>void ie(e),className:`rounded-xl border border-border bg-card p-4 space-y-3`,"data-testid":`feed-add-source-form`,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`feed-source-label`,className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Label (optional)`}),(0,q.jsx)(Fo,{id:`feed-source-label`,value:w,onValueChange:T,placeholder:`Defaults to manifest name`,className:`h-10`,disabled:v!==null||O})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`feed-source-url`,className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Feed directory URL`}),(0,q.jsx)(Fo,{id:`feed-source-url`,type:`text`,autoComplete:`off`,spellCheck:!1,value:E,onValueChange:e=>{D(e),A&&j(null),M&&N(null)},placeholder:`https://example.com/feed/library/`,className:`h-10 font-mono`,disabled:v!==null||O})]})]}),M&&(0,q.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-1.5 text-xs text-destructive`,"data-testid":`feed-add-error`,children:[(0,q.jsx)(Yi,{className:`size-3.5 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:M})]}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(J,{type:`submit`,size:`default`,disabled:v!==null||O||!E.trim(),"data-testid":`feed-add-button`,className:`h-10 gap-2`,children:O?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ot,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Inspecting…`})]}):(0,q.jsx)(`span`,{children:`Inspect Feed`})})})]}),A&&(0,q.jsx)(U3,{preProbed:A,initialLabel:w,cancelLabel:`Cancel`,onCancel:()=>j(null),onSubscribed:()=>{j(null),T(``),D(``),V(!1)}})]}),(0,q.jsx)(pD,{open:L!==null,onClose:()=>{z||R(null)},title:L?.kind===`delete`?`Delete "${L.label}"?`:`Unsubscribe from "${L?.label??``}"?`,description:L?.kind===`delete`?`Remove cached content and unregister this feed source.`:`Remove cached content from your library and stop syncing.`,footer:(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:z,onClick:()=>R(null),children:`Cancel`}),(0,q.jsx)(J,{type:`button`,variant:`destructive`,size:`sm`,disabled:z,onClick:()=>void ce(),children:z?L?.kind===`delete`?`Deleting…`:`Unsubscribing…`:L?.kind===`delete`?`Delete source`:`Unsubscribe`})]}),children:(0,q.jsxs)(`div`,{className:`space-y-3 text-sm text-foreground`,children:[(0,q.jsx)(`p`,{className:`text-pretty`,children:L?.kind===`delete`?`Imported content and cached indexes for "${L.label}" will be removed and the source will be unregistered.`:`Imported content and cached indexes for "${L?.label??``}" will be removed from your library, and automatic syncing will stop. The source stays listed so you can subscribe again anytime.`}),(0,q.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/40 p-3 text-xs text-foreground text-pretty`,children:`Workouts you have logged sessions against remain safely pinned locally and will not be deleted. Your own notes and workout history are never touched.`})]})})]})}var nye={journal:{kind:`journal`,label:`Journal entry`,icon:Cee},playground:{kind:`playground`,label:`Playground`,icon:Di},notebook:{kind:`notebook`,label:`Notebook`,icon:ni},note:{kind:`note`,label:`Note`,icon:ln},effort:{kind:`effort`,label:`Effort`,icon:vt},equipment:{kind:`equipment`,label:`Equipment`,icon:ai},tag:{kind:`tag`,label:`Tag`,icon:Jt},page:{kind:`page`,label:`Page`,icon:Vt}};function b8(e){return e===`/`||/^\/(?:journal|playgrounds|notebooks|pages|efforts|equipment|tags)\/?$/.test(e)||/^\/notebook\/[^/]+\/?$/.test(e)}function x8(){return oY()?(0,q.jsx)(C8,{}):null}function S8(e){let t=/^\/notebook\/([^/]+)\/(\d{4}-\d{2}-\d{2})\/?$/.exec(e);if(t?.[1]&&t?.[2])return{defaultKind:`note`,notebookSlug:decodeURIComponent(t[1]),defaultDate:t[2]};let n=/^\/notebook\/([^/]+)/.exec(e);if(n?.[1])return{defaultKind:`note`,notebookSlug:decodeURIComponent(n[1])};let r=/^\/day\/(\d{4}-\d{2}-\d{2})\/?$/.exec(e);return r?.[1]?{defaultKind:`journal`,defaultDate:r[1]}:e===`/notebooks`?{defaultKind:`notebook`}:e===`/pages`?{defaultKind:`page`}:e===`/tags`?{defaultKind:`tag`}:e.startsWith(`/playground`)?{defaultKind:`playground`}:e.startsWith(`/effort`)?{defaultKind:`effort`}:e.startsWith(`/equipment`)?{defaultKind:`equipment`}:{defaultKind:`journal`}}function rye(e,t){return e?!!(t===`feed`||js(e)):!1}function C8(){let e=Qe(),t=dt(),n=oY(),{openCreateJournal:r}=MV(),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),c=S8(e.pathname),l=nye[c.defaultKind],u=c.defaultKind===`note`&&rye(c.notebookSlug,o),d=u?Sn:l.icon,f=u?`Clone notebook`:`New ${l.label}`,p=u?`Clone notebook`:`+ Add`;(0,K.useEffect)(()=>{let e=!1;if(s(null),!c.notebookSlug)return;let t=c.notebookSlug;if(js(t)){s(`default`);return}return(async()=>{try{let n=await NI.getAllNotebooks();if(e)return;let r=n.find(e=>e.slug===t);if(r){s(r.origin);return}let i=await HL.getAllNotebooks().catch(()=>[]);if(e)return;let a=i.some(e=>e.slug===t||EI(e.slug)===EI(t));s(a?`feed`:`user`)}catch{e||s(`user`)}})(),()=>{e=!0}},[c.notebookSlug]);let m=async e=>{a(!0);try{let n=(await NI.getAllNotebooks()).find(t=>t.slug===e),r=n?.name??e,i=await NI.create(`${r} copy`,n?.description??``,n?.icon??`📓`),a=await NI.listNotes(e);for(let e of a)await NI.cloneNote(e.id,i.slug);t(yH(i.slug))}finally{a(!1)}},h=()=>{if(!i){if(u&&c.notebookSlug){m(c.notebookSlug);return}r({kind:c.defaultKind,notebookSlug:c.notebookSlug,date:c.defaultDate})}},g=c.defaultKind===`note`&&o===null;return(0,q.jsx)(`div`,{className:`inline-flex items-center`,"data-testid":`new-entry-combo`,children:(0,q.jsxs)(J,{type:`button`,size:`sm`,className:n?`h-11 rounded-full px-3.5 gap-1.5 shadow-lg text-xs font-semibold`:`h-9 gap-1.5 px-3 text-xs`,disabled:i||g,onClick:h,"aria-label":n||u?f:`${p} ${l.label}`,title:f,"data-testid":c.defaultKind===`effort`?`efforts-create-btn`:c.defaultKind===`notebook`?`notebooks-create-button`:`new-entry-primary`,children:[n?u?(0,q.jsx)(Sn,{className:$(`size-4 shrink-0`,i&&`animate-spin`)}):(0,q.jsx)(tn,{className:$(`size-4 shrink-0`,i&&`animate-spin`)}):i?(0,q.jsx)(tn,{className:`size-3.5 animate-spin`}):(0,q.jsx)(d,{className:`size-3.5`}),n?(0,q.jsx)(`span`,{children:i?`Cloning…`:u?`Clone`:`New`}):(0,q.jsx)(`span`,{children:i?`Cloning…`:p})]})})}function iye(e){switch(e.kind){case`note`:return`note`;case`result`:return`result`;case`segment`:case`event`:return`segment`;case`effort`:return`effort`;default:return`note`}}var w8=[{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:`sourceNotebook`,label:`Notebook`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.sourceNotebook,formatValue:e=>String(e??``)},{id:`date`,label:`Date`,level:`note`,defaultVisible:!0,align:`right`,getValue:e=>e.date,formatValue:e=>String(e??``)}],aye={note:w8,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?``:iG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>{if(e.execution?.loadLbs!=null)return`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`;if(e.execution?.sessionLoadAu!=null)return`${Number.isInteger(e.execution.sessionLoadAu)?e.execution.sessionLoadAu.toLocaleString():Number(e.execution.sessionLoadAu.toFixed(1)).toLocaleString()} AU`},formatValue:e=>e==null?``:String(e)}],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?``:iG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs==null?void 0:`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`,formatValue:e=>e==null?``:String(e)},{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.execution?.prCount??0)>0?`${e.execution.prCount} PR`:e.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)},{id:`rpe`,label:`RPE`,level:`result`,defaultVisible:!1,align:`right`,getValue:e=>e.execution?.rpe,formatValue:e=>typeof e==`number`?`${e}/10`:``}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:iG(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==null?void 0:`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`,formatValue:e=>e==null?``:String(e)},{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 T8(e){return aye[e]??w8}function E8(e){return T8(e).filter(e=>e.defaultVisible).map(e=>e.id)}var D8=[`cards`,`rows`,`feed`,`agenda`,`planner`],oye={stream:`cards`,table:`rows`},sye=`wodwiki.viewSettings.v1`,O8={"/notebooks":`/catalogs`,"/notes":`/feeds`,"/sessions":`/results`,"/dashboards":`/dashboard`},k8={"/notes":`/collections`},cye={"/feeds":`/feeds@2`};function A8(e){let t=e.startsWith(`/`)?e:`/${e}`;return cye[t]??t}var j8=new sE(sye);function M8(e,t){return{level:e,layout:t??`cards`,visibleFields:E8(e),groupBy:void 0}}function N8(e,t,n=j8,r){let i=M8(t,r),a=A8(e),o=O8[a],s=n.get(a,{alias:o});if(s==null&&o&&(s=n.get(o,{alias:k8[a]})),!s)return i;let c=typeof s.layout==`string`?s.layout:``,l=D8.includes(c)?c:oye[c]??`cards`,u=new Set(T8(t).map(e=>e.id)),d=Array.isArray(s.visibleFields)?s.visibleFields.filter(e=>typeof e==`string`&&u.has(e)):i.visibleFields,f=typeof s.groupBy==`string`?s.groupBy:void 0;return{level:t,layout:l,visibleFields:d.length>0?d:i.visibleFields,groupBy:f}}function lye(e,t,n=j8){let r=A8(e);n.set(r,{level:t.level,layout:t.layout,visibleFields:t.visibleFields,groupBy:t.groupBy})}function uye(e,t,n=j8){let r=A8(e),i=O8[r],a=k8[r];return n.remove(r,i),a&&n.remove(a),M8(t)}function dye(e,t,n){let[r,i]=(0,K.useState)(()=>N8(e,t,j8,n));(0,K.useEffect)(()=>{i(N8(e,t,j8,n))},[e,t,n]);let a=(0,K.useCallback)(t=>{i(n=>{let r=t(n);return lye(e,r),r})},[e]);return{settings:r,setLayout:(0,K.useCallback)(e=>{a(t=>({...t,layout:e}))},[a]),toggleField:(0,K.useCallback)(e=>{a(t=>{let n=new Set(t.visibleFields);return n.has(e)?n.delete(e):n.add(e),{...t,visibleFields:Array.from(n)}})},[a]),setVisibleFields:(0,K.useCallback)(e=>{a(t=>({...t,visibleFields:e}))},[a]),setGroupBy:(0,K.useCallback)(e=>{a(t=>({...t,groupBy:e}))},[a]),resetSettings:(0,K.useCallback)(()=>{let n=uye(e,t);i(n)},[e,t])}}function fye(e,t=200){let[n,r]=(0,K.useState)(()=>({items:e,batchSize:t,count:t})),i=(0,K.useRef)(null),a=n.items===e&&n.batchSize===t?n.count:t,o=a<e.length,s=(0,K.useCallback)(n=>{r(r=>{let i=r.items===e&&r.batchSize===t,a=n(i?r.count:t);return i&&r.count===a?r:{items:e,batchSize:t,count:a}})},[e,t]),c=(0,K.useCallback)(t=>s(n=>Math.max(n,Math.min(Math.max(t,0),e.length))),[s,e.length]);return(0,K.useEffect)(()=>{let n=i.current;if(!n||!o)return;let r=new IntersectionObserver(n=>{n.some(e=>e.isIntersecting)&&s(n=>Math.min(n+t,e.length))},{rootMargin:`400px`});return r.observe(n),()=>r.disconnect()},[o,e.length,t,s]),{visible:e.slice(0,a),hasMore:o,sentinelRef:i,total:e.length,growTo:c}}var P8={source:!0,tags:!0,notebook:!0,text:!0,type:!0,has:!0};function pye(e,t){let n=t_(e);if(n.error)return e;if(Vg(n)){let e=t===`note`?`count`:n.agg;return F_({...n,agg:e,metric:t})}if(!Bg(n))return e;let r=/^:(journal|notebooks|playground)(?:[{\s]|$)/.exec(e.trim())?.[1],i=n.filters.filter(e=>!(!P8[e.key]||r&&e.key===`source`&&e.values.length===1&&e.values[0].value===r)),a=n.filters.filter(e=>!P8[e.key]);return F_({family:`aggregate`,raw:``,agg:t===`note`?`count`:`sum`,metric:t,filters:a,groupBy:[`week`],window:n.window,...i.length>0||r||n.target!==`note`?{join:{target:r??n.target,filters:i}}:{}}).replace(/ where :(journal|notebooks|playground)$/,` where :$1{}`)}function mye(e){let t=t_(e);return t.error?e:F_({...t,window:void 0})}function hye(e,t){let n=t_(e);return n.error||n.family===`pipeline`?e:F_({...n,groupBy:[t]})}var gye={note:lr,effort:vt,result:an,segment:W,event:dn,dashboard:ft,equipment:ai,tag:Ee,feed:or,notebook:Xt},_ye={note:`Note`,effort:`Effort`,result:`Result`,segment:`Segment`,event:`Event`,dashboard:`Dashboard`,equipment:`Equipment`,tag:`Tag`,feed:`Feed`,notebook:`Notebook`},vye={note:`bg-primary/15 text-primary group-hover:bg-primary/20`,effort:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 group-hover:bg-emerald-500/20`,result:`bg-sky-500/15 text-sky-800 dark:text-sky-200 group-hover:bg-sky-500/20`,segment:`bg-indigo-500/15 text-indigo-800 dark:text-indigo-200 group-hover:bg-indigo-500/20`,event:`bg-indigo-500/15 text-indigo-800 dark:text-indigo-200 group-hover:bg-indigo-500/20`,dashboard:`bg-cyan-500/15 text-cyan-800 dark:text-cyan-200 group-hover:bg-cyan-500/20`,equipment:`bg-orange-500/15 text-orange-800 dark:text-orange-200 group-hover:bg-orange-500/20`,tag:`bg-violet-500/15 text-violet-800 dark:text-violet-200 group-hover:bg-violet-500/20`,feed:`bg-amber-500/15 text-amber-900 dark:text-amber-200 group-hover:bg-amber-500/20`,notebook:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 group-hover:bg-emerald-500/20`};function F8({entry:e,leading:t,actions:n,dateLabel:r,visibleFieldIds:i,tone:a=`secondary`,onAddToToday:o,onRunStart:s,moveNotebookTargets:c,onMoveNotebook:l,onToggleSubscribe:u,subscribing:d,onCloneRemote:f,onPublishFeed:p,onTogglePublicNotebook:m,onEditNotebook:h,onDeleteNotebook:g,selected:_,onToggleSelect:v}){let y=dt(),b=e.kind===`note`?e.sourceNotebook:void 0,x=!!b&&b!==`journal`&&b!==`playground`&&b!==`guides`,S=e.ownership?.kind,C=e.kind===`note`&&S===`feed-archived`,w=e.kind===`note`&&(S===`system`||b===`guides`||!!b&&js(b)),T=e.kind===`note`&&!C&&!w&&(S===`feed`||e.isRemotePreview===!0||e.editable===!1&&!!e.feedId&&e.feedId!==`local`),E=e.kind===`note`&&x&&!C&&!w&&!T,D=T||C?GQ(e.ownership?.feedSourceId??(e.feedId!==`local`&&e.feedId!==`core`?e.feedId:void 0),e=>yI(e)?.label):void 0,O=b===`playground`?En:C?Or:w?Xt:T?or:E?lr:gye[e.kind],k=b===`playground`?`Playground`:C?e.ownership?.upstreamStatus===`removed`||e.ownership?.upstreamStatus===`unsubscribed`?`Upstream Removed`:`Saved Copy`:w?b===`guides`?`Guide`:`System`:T?D??`Feed`:E?`My Note`:_ye[e.kind],A=C?`bg-amber-500/15 text-amber-900 dark:text-amber-200 group-hover:bg-amber-500/20`:w?`bg-muted text-foreground group-hover:bg-muted/80`:T?`bg-sky-500/15 text-sky-800 dark:text-sky-200 group-hover:bg-sky-500/20`:E?`bg-primary/15 text-primary group-hover:bg-primary/20`:vye[e.kind],j=a===`primary`,P=wG(e),F=SG(e),I=i?new Set(i):null,ee=!I||I.has(`date`),L=!I||I.has(`sourceNotebook`)||I.has(`protocol`)||I.has(`elapsedTime`)||I.has(`splitDuration`)||I.has(`discipline`)||I.has(`met`)||I.has(`canonicalSlug`),R=!I||I.has(`excerpt`)||I.has(`movements`)||I.has(`tags`)||I.has(`aliases`);return(0,q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>y(SG(e)),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),y(SG(e)))},className:`flex flex-wrap sm:flex-nowrap items-center gap-3 sm:gap-4 px-4 sm:px-6 py-3.5 hover:bg-muted/40 transition-colors text-left group w-full cursor-pointer ${j?`bg-primary/[0.025]`:``}`,"data-testid":`library-row-${e.kind}`,children:[v&&e.kind===`note`&&(0,q.jsx)(`input`,{type:`checkbox`,checked:!!_,onChange:()=>v(e),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.title||`note`} for batch scheduling`,className:`size-4 shrink-0 rounded border-input accent-primary`}),t,(0,q.jsx)(`div`,{className:`flex-shrink-0 size-9 rounded-xl flex items-center justify-center transition-colors ${A}`,children:(0,q.jsx)(O,{className:`size-4`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-bold text-foreground min-w-0 basis-full sm:basis-auto sm:truncate`,children:(0,q.jsx)(M,{to:SG(e),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`hover:underline focus-visible:outline-none focus-visible:underline`,children:e.title})}),e.block&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-sky-800 dark:text-sky-200 border border-sky-700/30 dark:border-sky-400/30 bg-sky-500/15 rounded-full px-2 py-0.5`,"data-testid":`library-row-block-type`,children:e.block.dataType}),(0,q.jsx)(`span`,{"data-ownership":e.kind===`note`?C?`feed-archived`:T?`feed`:w?`system`:`user`:void 0,className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${C?`border-amber-700/30 bg-amber-500/15 text-amber-900 dark:border-amber-400/30 dark:text-amber-200`:T?`border-sky-700/30 bg-sky-500/15 text-sky-800 dark:border-sky-400/30 dark:text-sky-200`:`text-foreground border-border bg-muted/50`}`,children:k}),e.kind===`note`&&e.ownership?.kind===`user`&&Array.isArray(e.notebookIds)&&e.notebookIds.length===0&&(0,q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider rounded-full border border-dashed border-border px-2 py-0.5 text-muted-foreground`,title:`Not assigned to any Notebook`,children:`Unfiled`}),e.kind===`note`&&(e.scheduleCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[10px] font-semibold rounded-full bg-primary/10 px-2 py-0.5 text-primary`,title:`Scheduled ${e.scheduleCount} time${e.scheduleCount===1?``:`s`}`,children:[`Scheduled ×`,e.scheduleCount]}),e.kind===`note`&&(e.sessionCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[10px] font-semibold rounded-full bg-emerald-500/10 px-2 py-0.5 text-emerald-700 dark:text-emerald-300`,title:`${e.sessionCount} logged session${e.sessionCount===1?``:`s`}`,children:[e.sessionCount,` run`,e.sessionCount===1?``:`s`]}),e.kind===`result`&&e.execution?.rpe!=null&&(0,q.jsxs)(`span`,{className:`text-[11px] font-mono font-semibold tabular-nums rounded-full border border-border bg-muted/60 px-2 py-0.5 text-foreground`,children:[`RPE `,e.execution.rpe,`/10`]}),e.kind===`result`&&(e.execution?.prCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full border border-amber-400 bg-amber-100 px-2 py-0.5 text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/20 dark:text-amber-200`,children:[e.execution.prCount,` PR`]}),(e.kind===`feed`||e.kind===`notebook`)&&e.feedId!==`local`&&e.feedId!==`core`&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${e.subscribed?`border-emerald-700/30 dark:border-emerald-400/30 bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:`border-border bg-muted text-foreground`}`,"data-testid":`library-row-sub-status-${e.sourceNote}`,children:e.subscribed?`Subscribed`:`Unsubscribed`}),e.kind===`notebook`&&e.feedId===`local`&&(Vs({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}).isSystem?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-border bg-muted text-foreground`,children:[(0,q.jsx)(Xt,{className:`size-3`,"aria-hidden":`true`}),`System`]}):(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${e.isPublic?`border-emerald-700/30 dark:border-emerald-400/30 bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:`border-border bg-muted text-foreground`}`,"data-testid":`library-row-visibility-${e.sourceNotebook}`,children:[e.isPublic?(0,q.jsx)(ce,{className:`size-3`}):(0,q.jsx)(N,{className:`size-3`}),e.isPublic?`Public`:`Private`]})),e.kind===`feed`&&e.unpublishedChanges&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-amber-700/30 dark:border-amber-400/30 bg-amber-500/15 text-amber-900 dark:text-amber-200`,children:`Unpublished changes`}),e.isRemotePreview&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-sky-700/30 dark:border-sky-400/30 bg-sky-500/15 text-sky-800 dark:text-sky-200`,children:`Index Preview`}),e.execution?.effortSlug&&(0,q.jsx)(M,{to:IH(e.execution.effortSlug),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),"data-testid":`library-row-effort-link`,className:`text-[11px] font-semibold tracking-wide text-primary bg-primary/15 hover:bg-primary/20 border border-primary/25 rounded-full px-2 py-0.5 transition-colors shrink-0`,title:`View movement history for ${e.detail??e.execution.effortSlug}`,children:e.detail??e.execution.effortSlug}),P&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(M,{to:F,"data-testid":`library-row-details-link`,className:`text-[11px] font-semibold tracking-wide text-foreground bg-muted hover:bg-muted/80 border border-border rounded-full px-2 py-0.5 transition-colors`,title:`View notebook details`,children:`Details`}),(0,q.jsx)(M,{to:P,"data-testid":`library-row-feed-link`,className:`text-[11px] font-semibold tracking-wide text-primary bg-primary/15 hover:bg-primary/20 border border-primary/25 rounded-full px-2 py-0.5 transition-colors`,title:`View feed`,children:`Feed`})]}),e.subtitle&&L&&(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground truncate`,children:e.subtitle})]}),R&&(e.block?(0,q.jsx)(`div`,{className:`mt-0.5`,"data-testid":`library-row-block-preview`,children:e.block.preview.map((e,t)=>(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate font-mono`,children:e},t))}):e.detail?(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate mt-0.5`,children:e.detail}):null)]}),(()=>{let t=r??(e.execution?.timestamp?new Date(e.execution.timestamp).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}):void 0);return t&&ee?(0,q.jsx)(`span`,{className:`flex-shrink-0 text-[11px] text-muted-foreground tabular-nums self-start sm:self-auto pt-0.5 sm:pt-0`,"data-testid":`library-row-date`,children:t}):null})(),n??(0,q.jsx)(yye,{entry:e,onAddToToday:o,onRunStart:s,moveNotebookTargets:c,onMoveNotebook:l,onToggleSubscribe:u,subscribing:d,onCloneRemote:f,onPublishFeed:p,onTogglePublicNotebook:m,onEditNotebook:h,onDeleteNotebook:g})]})}function yye({entry:e,onAddToToday:t,onRunStart:n,moveNotebookTargets:r,onMoveNotebook:i,onToggleSubscribe:a,subscribing:o,onCloneRemote:s,onPublishFeed:c,onTogglePublicNotebook:l,onEditNotebook:u,onDeleteNotebook:d}){let f=dt(),p=TG(e),m=wG(e),h=EG(e)&&!!t,g=r$(e)&&!!n,_=e.notebookId??`notebook/journal`,v=r?.filter(e=>e.id!==_)??[],y=!!i&&e.kind===`note`&&(e.editable??!0)&&v.length>0,b=e.kind===`notebook`?Vs({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}):null,x=!!(b?.canTogglePublic&&l),S=!!(b?.canEdit&&u),w=!!(b?.canDelete&&d),T=(e.kind===`feed`||e.kind===`notebook`)&&e.feedId!==`local`&&e.feedId!==`core`&&!!a,E=e.kind===`feed`&&e.sourceNote===`local`&&!!c,D=!!e.isRemotePreview&&!!s,O=!T&&!E&&!D&&g,k=!T&&!E&&!D&&!O,j=!k||!!m||g&&D||h||!!p||x||S||w||y&&v.length>0;return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:[T&&(0,q.jsxs)(`button`,{type:`button`,disabled:!!o,"aria-busy":!!o,onClick:()=>a(e),"data-testid":e.subscribed?`row-unsubscribe-${e.sourceNote}`:`row-subscribe-${e.sourceNote}`,className:`h-8 max-sm:min-h-11 px-3 rounded-lg text-xs font-semibold flex items-center gap-1.5 transition-colors disabled:opacity-60 disabled:cursor-wait ${e.subscribed?`border border-border text-foreground hover:text-destructive hover:border-destructive/40`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:[o?(0,q.jsx)(ot,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(yr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:o?e.subscribed?`Unsubscribing…`:`Subscribing…`:e.subscribed?`Unsubscribe`:`Subscribe`})]}),E&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>c(e),"data-testid":Q.LIBRARY_PUBLISH_LOCAL_FEED,className:`h-8 max-sm:min-h-11 px-3 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 text-xs font-semibold flex items-center gap-1.5 transition-colors`,children:[(0,q.jsx)(Bn,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Publish / Export`})]}),D&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>s(e),"data-testid":`row-clone-remote-${e.id}`,className:`h-8 max-sm:min-h-11 px-3 rounded-lg border border-primary/40 bg-primary/15 text-primary hover:bg-primary/20 text-xs font-semibold flex items-center gap-1.5 transition-colors`,children:[(0,q.jsx)(Vi,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Clone`})]}),O&&(0,q.jsx)(I8,{title:`Run`,testId:Q.LIBRARY_ACTION_RUN,onClick:()=>n?.(e),children:(0,q.jsx)(Sr,{className:`size-3.5`,"aria-hidden":`true`})}),k&&(0,q.jsx)(I8,{title:m?`Details`:`Open`,testId:Q.LIBRARY_ACTION_OPEN,onClick:()=>f(SG(e)),children:(0,q.jsx)(rn,{className:`size-3.5`,"aria-hidden":`true`})}),j&&(0,q.jsxs)($i,{children:[(0,q.jsx)(A,{"aria-label":`Actions for ${e.title}`,title:`Actions for ${e.title}`,"data-testid":Q.LIBRARY_ROW_OVERFLOW,className:`size-8 max-sm:min-h-11 max-sm:min-w-11 inline-flex items-center justify-center rounded-lg border-0 bg-transparent p-0 text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,children:(0,q.jsx)(Tr,{className:`size-4 sm:size-5`,"aria-hidden":`true`})}),(0,q.jsxs)(Ot,{align:`end`,sideOffset:6,children:[(0,q.jsxs)(C,{children:[!k&&(0,q.jsxs)(Ft,{value:`open`,"data-testid":Q.LIBRARY_ACTION_OPEN,onClick:()=>f(SG(e)),children:[(0,q.jsx)(rn,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:m?`Details`:`Open`})]}),m&&(0,q.jsxs)(Ft,{value:`notebook`,"data-testid":Q.LIBRARY_ACTION_NOTEBOOK,onClick:()=>f(m),children:[(0,q.jsx)(or,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Open Notebook`})]}),g&&D&&(0,q.jsxs)(Ft,{value:`run`,"data-testid":Q.LIBRARY_ACTION_RUN,onClick:()=>n?.(e),children:[(0,q.jsx)(Sr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Start workout`})]}),h&&(0,q.jsxs)(Ft,{value:`add-to-today`,"data-testid":Q.LIBRARY_ACTION_ADD,onClick:()=>t?.(e),children:[(0,q.jsx)(Zr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Add to today`})]}),p&&(0,q.jsxs)(Ft,{value:`compare`,"data-testid":Q.LIBRARY_ACTION_COMPARE,onClick:()=>f(p),children:[(0,q.jsx)(Mr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Compare`})]}),x&&(0,q.jsxs)(Ft,{value:`toggle-public`,"data-testid":`row-toggle-public-${e.sourceNotebook}`,onClick:()=>l(e),children:[e.isPublic?(0,q.jsx)(N,{className:`size-4 shrink-0`,"aria-hidden":`true`}):(0,q.jsx)(ce,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:e.isPublic?`Make Private`:`Make Public`})]}),S&&(0,q.jsxs)(Ft,{value:`edit-notebook`,"data-testid":`notebook-edit-${e.sourceNotebook}`,onClick:()=>u(e),children:[(0,q.jsx)(Nn,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Edit notebook`})]}),w&&(0,q.jsxs)(Ft,{value:`delete-notebook`,"data-testid":`notebook-delete-${e.sourceNotebook}`,onClick:()=>d(e),children:[(0,q.jsx)(Me,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Delete notebook`})]})]}),y&&v.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(I,{}),(0,q.jsxs)(C,{children:[(0,q.jsx)(Ji,{children:`Move to notebook`}),v.map(t=>(0,q.jsxs)(Ft,{value:`move-${t.id}`,"data-testid":`action-move-${t.id}`,onClick:()=>i?.(e,t.id),children:[(0,q.jsx)(`span`,{className:`w-5 text-center`,children:t.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:t.name})]},t.id))]})]})]})]})]})}function bye({targets:e,triggerTestId:t,itemTestIdPrefix:n,triggerClassName:r,onMove:i}){return(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,q.jsxs)($i,{children:[(0,q.jsx)(A,{"aria-label":`Move to notebook`,title:`Move to notebook`,"data-testid":t,className:`${r} border-0 bg-transparent p-0`,children:(0,q.jsx)(pn,{className:`size-3.5`,"aria-hidden":`true`})}),(0,q.jsx)(Ot,{align:`end`,sideOffset:6,children:(0,q.jsxs)(C,{children:[(0,q.jsx)(Ji,{children:`Move to notebook`}),(0,q.jsx)(I,{}),e.map(e=>(0,q.jsxs)(Ft,{value:e.id,"data-testid":`${n}${e.id}`,onClick:()=>i(e.id),children:[(0,q.jsx)(`span`,{className:`w-5 text-center`,children:e.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})]},e.id))]})})]})})}function I8({title:e,testId:t,onClick:n,children:r}){return(0,q.jsx)(`button`,{type:`button`,title:e,"aria-label":e,onClick:n,"data-testid":t,className:`size-8 max-sm:min-h-11 max-sm:min-w-11 rounded-lg flex items-center justify-center text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,children:r})}function xye({entries:e,level:t,visibleFieldIds:n,onRowClick:r,emptyMessage:i=`No entries to display`,className:a=``,stickyHeaderTop:o}){let s=dt(),c=(0,K.useMemo)(()=>t||(e.length>0?iye(e[0]):`note`),[t,e]),l=(0,K.useMemo)(()=>T8(c),[c]),u=(0,K.useMemo)(()=>{let e=new Set(n??E8(c));return l.filter(t=>e.has(t.id))},[l,n,c]),d=e=>{r?r(e):s(SG(e))},[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(`asc`),g=e=>{f===e?h(e=>e===`asc`?`desc`:`asc`):(p(e),h(`asc`))},_=(0,K.useMemo)(()=>{if(!f)return e;let t=l.find(e=>e.id===f);return t?[...e].sort((e,n)=>{let r=t.getValue(e),i=t.getValue(n);if(r==null&&i==null)return 0;if(r==null)return m===`asc`?1:-1;if(i==null)return m===`asc`?-1:1;if(typeof r==`number`&&typeof i==`number`)return m===`asc`?r-i:i-r;if(Array.isArray(r)&&Array.isArray(i)){let e=r.join(`, `),t=i.join(`, `);return m===`asc`?e.localeCompare(t):t.localeCompare(e)}let a=String(r),o=String(i);return m===`asc`?a.localeCompare(o):o.localeCompare(a)}):e},[e,f,m,l]);return e.length===0?(0,q.jsx)(`div`,{className:`w-full py-16 text-center text-sm text-muted-foreground ${a}`,"data-testid":`property-table-empty`,children:i}):(0,q.jsx)(`div`,{className:`w-full overflow-x-auto border-y border-border bg-card/50 ${a}`,"data-testid":`property-table`,children:(0,q.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,q.jsx)(`thead`,{className:o===void 0?void 0:`sticky z-10`,style:o===void 0?void 0:{top:`${o}px`},children:(0,q.jsx)(`tr`,{className:`border-b border-border`,children:u.map(e=>{let t=e.align===`right`?`text-right`:e.align===`center`?`text-center`:`text-left`,n=f===e.id;return(0,q.jsx)(`th`,{scope:`col`,"aria-sort":n?m===`asc`?`ascending`:`descending`:`none`,className:`border-b border-border font-semibold uppercase tracking-wider text-[11px] text-muted-foreground whitespace-nowrap ${o===void 0?`bg-muted/30`:`bg-muted/95 backdrop-blur-sm`} ${t}`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e.id),"data-testid":`property-table-header-${e.id}`,className:`inline-flex w-full items-center gap-1.5 px-4 py-3 font-semibold uppercase tracking-wider text-[11px] text-muted-foreground select-none hover:text-foreground transition-colors group/th focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${t===`text-right`?`justify-end`:t===`text-center`?`justify-center`:`justify-start`}`,children:[(0,q.jsx)(`span`,{children:e.label}),n?(0,q.jsx)(`span`,{className:`text-primary font-bold text-xs`,"aria-label":m===`asc`?`sorted ascending`:`sorted descending`,children:m===`asc`?`↑`:`↓`}):(0,q.jsx)(`span`,{className:`opacity-0 group-hover/th:opacity-40 text-muted-foreground text-[10px]`,"aria-hidden":`true`,children:`↕`})]})},e.id)})})}),(0,q.jsx)(`tbody`,{className:`divide-y divide-border/60`,children:_.map(e=>{let t=wG(e),n=SG(e);return(0,q.jsx)(`tr`,{onClick:t=>{t.target.closest(`a, button`)||d(e)},className:`hover:bg-muted/40 transition-colors cursor-pointer group`,"data-testid":`property-table-row-${e.id}`,children:u.map((r,i)=>{let a=r.getValue(e),o=r.formatValue(a,e),s=r.align===`right`?`text-right tabular-nums`:r.align===`center`?`text-center`:`text-left`;return(0,q.jsx)(`td`,{className:`px-4 py-3 whitespace-nowrap text-foreground/90 ${s}`,"data-testid":`property-table-cell-${r.id}`,children:r.id===`pacingTier`&&e.execution?.effortSlug?(0,q.jsx)(M,{to:IH(e.execution.effortSlug),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),"data-testid":`property-table-effort-link`,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors`,title:`View movement history for ${e.detail??e.execution.effortSlug}`,children:o}):r.id===`title`||r.id===`label`||i===0&&!u.some(e=>e.id===`title`||e.id===`label`)?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,q.jsx)(M,{to:n,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`text-left font-medium text-foreground group-hover:text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,children:o}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`text-left font-medium text-foreground group-hover:text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,children:o}),t&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(M,{to:n,"data-testid":`property-table-details-link`,className:`rounded px-1.5 py-0.5 text-[10px] font-semibold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted border border-border transition-colors`,title:`View catalog details`,children:`Details`}),(0,q.jsx)(M,{to:t,"data-testid":`property-table-feed-link`,className:`rounded px-1.5 py-0.5 text-[10px] font-semibold bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors`,title:`View feed`,children:`Feed`})]})]}):o},r.id)})},e.id)})})]})})}var Sye={note:lr,effort:vt,result:an,segment:W,event:dn,dashboard:ft,equipment:ai,tag:Ee,feed:or,notebook:Xt},Cye={note:`Note`,effort:`Effort`,result:`Result`,segment:`Segment`,event:`Event`,dashboard:`Dashboard`,equipment:`Equipment`,tag:`Tag`,feed:`Feed`,notebook:`Notebook`},L8=8;function wye({entry:e}){let t=e.execution;if(!t)return null;let n=[];return t.elapsedMs!=null&&n.push({label:iG(t.elapsedMs)}),t.reps!=null&&n.push({label:`${t.reps} reps`}),t.loadLbs!=null&&n.push({label:`${t.loadLbs} lb`}),t.distanceMeters!=null&&n.push({label:`${(t.distanceMeters/1e3).toFixed(2)} km`}),t.tis!=null&&n.push({label:`TIS Score ${t.tis.toFixed(1)}`,title:`Training Intensity Score`}),n.length===0?null:(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`stream-feed-metrics`,children:n.map(e=>(0,q.jsx)(`span`,{title:e.title,className:`rounded-full bg-muted/70 border border-border/60 px-2 py-0.5 text-[10px] font-bold tabular-nums text-muted-foreground`,children:e.label},e.label))})}function Tye({entry:e}){let[t,n]=(0,K.useState)(!1),r=e.wodBlock?.content.trim(),i=r?r.split(`
|
|
1156
1156
|
`):e.excerpt??e.block?.preview??[],a=i.length>L8,o=t||!a?i:i.slice(0,L8);return i.length===0&&!e.detail?null:(0,q.jsxs)(`div`,{className:`mt-1.5`,"data-testid":`stream-feed-preview`,children:[i.length>0&&(0,q.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-muted-foreground ${a&&!t?`max-h-40 overflow-hidden`:``}`,children:o.join(`
|
|
1157
1157
|
`)}),i.length===0&&e.detail&&(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.detail}),a&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(e=>!e),"data-testid":`stream-feed-preview-toggle`,className:`mt-1 min-h-[44px] px-2 -ml-2 text-[10px] font-black uppercase tracking-widest text-primary hover:text-primary/80 transition-colors`,children:t?`Show less`:`Show more (${i.length-L8} lines)`})]})}function Eye({groups:e,batch:t,onRunEntry:n,onSendToPlayground:r,onAddToToday:i,moveNotebookTargets:a,onMoveNotebook:o,onEditNotebook:s,onDeleteNotebook:c,stickyOffset:l}){return(0,q.jsxs)(`div`,{className:`flex-1 divide-y divide-border/40`,"data-testid":`stream-feed`,children:[e.map(e=>(0,q.jsxs)(`section`,{id:e.id,"data-testid":`stream-feed-group-${e.key}`,children:[(0,q.jsx)(PY,{top:l,icon:(0,q.jsx)(U,{className:`size-3 shrink-0 text-muted-foreground`}),label:e.label,badge:e.isToday?(0,q.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-primary`,children:`Today`}):void 0,meta:`${e.entries.length} ${e.entries.length===1?`entry`:`entries`}`}),(0,q.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.entries.map(e=>{let t=e.kind===`note`?e.sourceNotebook:void 0,l=!!t&&t!==`journal`&&t!==`playground`&&t!==`guides`,u=t===`playground`?En:t===`guides`?Xt:l?or:Sye[e.kind],d=t===`playground`?`Playground`:t===`guides`?`Guide`:l?`Notebook`:Cye[e.kind],f=SG(e),p=wG(e),m=!CG(e)&&e.kind===`note`,h=EG(e)&&!!i,g=e.notebookId??`notebook/journal`,_=a?.filter(e=>e.id!==g)??[],v=!!o&&e.kind===`note`&&(e.editable??!0)&&_.length>0,y=e.kind===`notebook`?Vs({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}):null;return(0,q.jsx)(`article`,{"data-testid":`stream-feed-item`,className:`px-6 py-4`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`div`,{className:`flex-shrink-0 size-9 rounded-xl bg-primary/10 flex items-center justify-center`,children:(0,q.jsx)(u,{className:`size-4 text-primary`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-bold text-foreground min-w-0 basis-full sm:basis-auto sm:truncate`,children:(0,q.jsx)(M,{to:f,className:`hover:text-primary transition-colors`,children:e.title})}),(0,q.jsx)(`span`,{className:`text-[9px] font-black uppercase tracking-widest text-muted-foreground/60 border border-border rounded-full px-1.5 py-0.5`,children:d}),e.subtitle&&(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:e.subtitle})]}),(0,q.jsx)(Tye,{entry:e}),(0,q.jsx)(wye,{entry:e}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(M,{to:f,"data-testid":`stream-feed-open`,className:`inline-flex min-h-[44px] items-center rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,children:p?`Details`:`Open`}),p&&(0,q.jsxs)(M,{to:p,"data-testid":`stream-feed-collection-feed`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full bg-primary/10 border border-primary/30 px-3 text-[10px] font-black uppercase tracking-widest text-primary hover:bg-primary/20 transition-colors`,children:[(0,q.jsx)(or,{className:`size-3`}),`Feed`]}),r$(e)&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),"data-testid":`stream-feed-run`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full bg-primary/10 border border-primary/30 px-3 text-[10px] font-black uppercase tracking-widest text-primary hover:bg-primary/20 transition-colors`,children:[(0,q.jsx)(Sr,{className:`size-3`}),`Run`]}),m&&r&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"data-testid":`stream-feed-playground`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,children:[(0,q.jsx)(kee,{className:`size-3`}),`Playground`]}),h&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>i?.(e),"data-testid":`stream-feed-add`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,children:[(0,q.jsx)(Zr,{className:`size-3`}),`Add`]}),v&&(0,q.jsx)(bye,{targets:_,triggerTestId:`stream-feed-move`,itemTestIdPrefix:`stream-feed-move-`,triggerClassName:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,onMove:t=>o?.(e,t)}),y?.canEdit&&s&&(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Edit ${e.title}`,onClick:()=>s(e),"data-testid":`notebook-edit-${e.sourceNotebook}`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,children:[(0,q.jsx)(Nn,{className:`size-3`}),`Edit`]}),y?.canDelete&&c&&(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Delete ${e.title}`,onClick:()=>c(e),"data-testid":`notebook-delete-${e.sourceNotebook}`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-destructive hover:border-destructive/50 transition-colors`,children:[(0,q.jsx)(Me,{className:`size-3`}),`Delete`]})]})]})]})},e.id)})})]},e.id)),t.hasMore&&(0,q.jsxs)(`div`,{ref:t.sentinelRef,className:`px-6 py-4 text-center text-xs text-muted-foreground/60`,"data-testid":`stream-feed-load-more`,children:[`Loading more — `,t.total-t.visible.length,` remaining…`]})]})}function R8(e){return lU(e)}function z8(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,(n??1)-1,r??1)}function B8(e){let t=new Map,n=[];for(let r of e){let e=r.scheduledDates&&r.scheduledDates.length>0?r.scheduledDates:r.date?[r.date]:[];if(e.length===0){n.push(r);continue}let i=new Set;for(let n of e){if(!n||i.has(n))continue;i.add(n);let e=t.get(n);e?e.push(r):t.set(n,[r])}}return{byDay:t,undated:n}}function V8(e){return(e.getDay()+6)%7}function H8(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function U8(e,t,n,r){let i=R8(e),a=e.getDay();return{key:i,date:e,dayOfMonth:e.getDate(),inMonth:t,isToday:i===r,isWeekend:a===0||a===6,entries:n.byDay.get(i)??[]}}function Dye(e,t,n=R8(new Date)){let r=e.getFullYear(),i=e.getMonth(),a=new Date(r,i,1),o=H8(a,-V8(a)),s=[];for(let e=0;e<6;e++){let a=[];for(let s=0;s<7;s++){let c=H8(o,e*7+s);a.push(U8(c,c.getMonth()===i&&c.getFullYear()===r,t,n))}s.push({label:`${Y8[a[0].date.getMonth()]} ${a[0].date.getDate()}`,days:a})}return s}function Oye(e,t,n=R8(new Date)){let r=e.getFullYear(),i=e.getMonth(),a=new Date(r,i,1),o=new Date(r,i+1,0),s=H8(a,-V8(a)),c=H8(o,6-V8(o)),l=[];for(let e=s;e<=c;e=H8(e,7)){let a=[];for(let o=0;o<7;o++){let s=H8(e,o);a.push(U8(s,s.getMonth()===i&&s.getFullYear()===r,t,n))}l.push({label:`${Y8[a[0].date.getMonth()]} ${a[0].date.getDate()}`,days:a})}return l}function kye(e,t,n=R8(new Date)){let r=e.getFullYear(),i=e.getMonth();return[...t.byDay.keys()].filter(e=>{let t=z8(e);return t.getFullYear()===r&&t.getMonth()===i}).sort().map(e=>U8(z8(e),!0,t,n))}function Aye(e){return`${Mye[e.getMonth()]} ${e.getFullYear()}`}function W8(e){return Y8[e.getMonth()]}function G8(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function jye(e){return e<=0?0:e===1?1:e===2?2:3}function K8(e){let t=e.notebookId;return t?t.replace(/^notebook\//,``):e.sourceNotebook}var q8=[{bar:`bg-rose-500`,chip:`bg-rose-500/12 text-rose-700 dark:text-rose-300`},{bar:`bg-amber-500`,chip:`bg-amber-500/12 text-amber-700 dark:text-amber-300`},{bar:`bg-emerald-500`,chip:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`},{bar:`bg-sky-500`,chip:`bg-sky-500/12 text-sky-700 dark:text-sky-300`},{bar:`bg-violet-500`,chip:`bg-violet-500/12 text-violet-700 dark:text-violet-300`},{bar:`bg-cyan-500`,chip:`bg-cyan-500/12 text-cyan-700 dark:text-cyan-300`}];function J8(e){if(!e)return{bar:`bg-muted-foreground`,chip:`bg-muted text-muted-foreground`};let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return q8[Math.abs(t)%q8.length]}var Y8=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Mye=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],X8=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function Nye(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}`}function Z8(e){return!e||!/^\d{4}-\d{2}$/.test(e)?null:z8(`${e}-01`)}function Q8(e,t){let n=typeof e==`string`?e:``,r=n?Z8(n):void 0,[i,a]=(0,K.useState)(()=>r??(e instanceof Date?e:new Date));(0,K.useEffect)(()=>{let e=n?Z8(n):null;e&&a(e)},[n]);let o=r??i,s=(0,K.useCallback)(e=>{let n=e(o);a(n),t?.(Nye(n))},[o,t]);return{anchor:o,label:Aye(o),previous:(0,K.useCallback)(()=>s(e=>G8(e,-1)),[s]),next:(0,K.useCallback)(()=>s(e=>G8(e,1)),[s]),today:(0,K.useCallback)(()=>s(()=>new Date),[s])}}var Pye=[{id:`all`,label:`All`},{id:`planned`,label:`Planned`},{id:`logged`,label:`Logged`}];function $8({nav:e,meta:t,right:n,overlayMode:r,onOverlayModeChange:i}){return(0,q.jsx)(`div`,{className:`border-b border-border/60 px-4 py-2`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(J,{variant:`ghost`,size:`icon`,onClick:e.previous,"aria-label":`Previous month`,className:`size-11 shrink-0`,children:(0,q.jsx)(j,{className:`size-4`,"aria-hidden":!0})}),(0,q.jsxs)(`div`,{className:`min-w-[9rem] flex-1 px-1`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:e.label}),t&&(0,q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t})]}),i&&(0,q.jsx)(`div`,{"data-testid":Q.CALENDAR_OVERLAY_FILTER,role:`group`,"aria-label":`Overlay filter`,className:`inline-flex items-center rounded-md border border-border bg-muted/40 p-0.5 max-sm:order-last max-sm:w-full max-sm:justify-center`,children:Pye.map(e=>{let t=(r??`all`)===e.id;return(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),"aria-pressed":t,className:`rounded px-2.5 py-1 text-xs font-semibold max-lg:min-h-11 max-sm:flex-1 transition-colors ${t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:e.label},e.id)})}),(0,q.jsx)(J,{variant:`ghost`,size:`icon`,onClick:e.next,"aria-label":`Next month`,className:`size-11 shrink-0`,children:(0,q.jsx)(ee,{className:`size-4`,"aria-hidden":!0})}),(0,q.jsx)(J,{variant:`outline`,size:`sm`,onClick:e.today,className:`min-h-11 shrink-0`,children:`Today`}),n]})})}function e5({entry:e,onInspect:t}){let n=J8(K8(e)),r=e.pairedSessions?.[0]?.duration,i=e.scheduleStatus===`completed`||(e.pairedSessions?.length??0)>0,a=e.scheduleStatus===`skipped`,o=e.overlayKind===`logged`&&!e.scheduleItemId,s=e.overlayKind===`planned`&&!i&&!a,c=a?`border-border/50 bg-muted/40 text-muted-foreground line-through`:i?`border-emerald-500/40 bg-emerald-500/10 text-foreground hover:bg-emerald-500/15`:s?`border-dashed border-border bg-card/70 text-foreground hover:bg-muted/60`:o?`border-sky-500/40 bg-sky-500/10 text-foreground hover:bg-sky-500/15`:`border-border/60 bg-card text-foreground hover:bg-muted/60`,l=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`h-3 w-0.5 shrink-0 rounded-full ${n.bar}`,"aria-hidden":!0}),i&&(0,q.jsx)(kt,{className:`size-3 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),a&&(0,q.jsx)(ti,{className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),o&&(0,q.jsx)(ea,{className:`size-3 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title||`Untitled`}),e.scheduleSlot&&(0,q.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1 text-[11px] font-bold uppercase text-muted-foreground`,children:e.scheduleSlot}),typeof r==`number`&&r>0&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-emerald-800 dark:text-emerald-300`,children:Es(r)})]});return t?(0,q.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:`flex min-h-6 w-full items-center gap-1 rounded border px-1.5 py-0.5 text-left text-[11px] transition-colors ${c}`,title:`${e.title} — ${K8(e)}`,"data-testid":`calendar-entry-chip`,"data-overlay-state":a?`skipped`:i?`completed`:o?`logged`:s?`planned`:`note`,children:l}):(0,q.jsx)(M,{to:SG(e),onClick:e=>e.stopPropagation(),className:`flex min-h-6 items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] transition-colors ${c}`,title:`${e.title} — ${K8(e)}`,"data-testid":`calendar-entry-chip`,children:l})}function t5({entries:e}){let[t,n]=(0,K.useState)(!1);return e.length===0?null:(0,q.jsxs)(`div`,{className:`mx-4 mb-6 rounded-lg border border-dashed border-border bg-muted/30 p-2.5`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-expanded":t,"data-testid":Q.CALENDAR_UNDATED_TOGGLE,className:`flex w-full items-center gap-1.5 text-left`,children:[t?(0,q.jsx)(rt,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}):(0,q.jsx)(ee,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,q.jsx)(U,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,q.jsxs)(`span`,{className:`text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:[`Undated · `,e.length]}),(0,q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:t?`Hide undated notes`:`Show undated notes`})]}),t&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`The calendar has no day for these. Open or schedule one onto a day to place it.`}),(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.map(e=>(0,q.jsxs)(M,{to:SG(e),className:`inline-flex min-h-7 items-center gap-1.5 rounded border border-border/60 bg-card px-2 py-0.5 text-xs text-foreground hover:bg-muted/60`,children:[(0,q.jsx)(`span`,{className:`h-3 w-0.5 shrink-0 rounded-full ${J8(K8(e)).bar}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:e.title||`Untitled`})]},e.id))})]})]})}function n5(e,t){let n=e===1?`entry`:`entries`;return t?`${e} ${t} ${n}`:`${e} ${n}`}function Fye({day:e,top:t,onCreateOnDay:n,onInspectDay:r}){let i=X8[(e.date.getDay()+6)%7],a=`${W8(e.date)} ${e.dayOfMonth}`,o=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex w-10 shrink-0 flex-col items-center leading-none`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:i}),(0,q.jsx)(`span`,{className:`text-xl font-extrabold tracking-tight ${e.isToday?`text-primary`:`text-foreground`}`,children:e.dayOfMonth})]}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 text-xs font-medium text-muted-foreground`,children:[W8(e.date),` `,e.date.getFullYear()]})]});return(0,q.jsxs)(`div`,{id:`calendar-day-${e.key}`,style:{top:`${t}px`},className:`sticky z-10 flex items-center gap-3 border-y border-border/60 bg-card/95 px-4 py-1.5 backdrop-blur`,"data-testid":`calendar-agenda-day`,children:[r?(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(e.key),"data-testid":Q.CALENDAR_DAY_HEADER,title:`Inspect ${a}`,className:`flex min-w-0 flex-1 max-lg:min-h-11 items-center gap-3 rounded-md px-1 py-0.5 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:o}):(0,q.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:o}),e.isToday&&(0,q.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-bold uppercase tracking-wider text-primary`,children:`Today`}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:n5(e.entries.length)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(e.key),className:`grid size-8 max-lg:size-11 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-primary`,"aria-label":`Add an entry on ${a}`,title:`Add an entry on this day`,"data-testid":`calendar-agenda-add-button`,children:(0,q.jsx)(Zr,{className:`size-3.5`,"aria-hidden":!0})})]})}function Iye({days:e}){let t=e.filter(e=>e.inMonth),n=t[0]?.date.getMonth()??0,r=t[0]?.date.getFullYear()??new Date().getFullYear(),i=new Date(r,n+1,0).getDate(),a=new Map(t.map(e=>[e.dayOfMonth,e])),o=[];for(let e=1;e<=i;e++){let t=a.get(e),i=jye(t?.entries.length??0),s=i===0?`bg-muted`:i===1?`bg-primary/25`:i===2?`bg-primary/50`:`bg-primary`,c=n5(t?.entries.length??0),l=`${e} ${W8(new Date(r,n,e))} — ${c}`;o.push((0,q.jsx)(`button`,{type:`button`,onClick:()=>document.getElementById(`calendar-day-${t?.key}`)?.scrollIntoView({block:`start`}),disabled:!t,title:l,"aria-label":l,className:`h-6 flex-1 rounded-sm ${s} ${t?`cursor-pointer`:`cursor-default`}`},e))}return(0,q.jsxs)(`div`,{className:`hidden items-center gap-3 border-b border-border/60 px-4 py-2 lg:flex`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Load`}),(0,q.jsx)(`div`,{className:`flex flex-1 gap-0.5`,children:o}),(0,q.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`1 → `,i]})]})}function Lye({entries:e,stickyOffset:t,visibleFieldIds:n,onAddToToday:r,onRunStart:i,moveNotebookTargets:a,onMoveNotebook:o,onCreateOnDay:s,monthParam:c,onMonthChange:l,overlayMode:u,onOverlayModeChange:d,onInspectEntry:f,onInspectDay:p}){let m=Q8(c,l),h=(0,K.useMemo)(()=>B8(e),[e]),g=(0,K.useMemo)(()=>kye(m.anchor,h),[m.anchor,h]),_=(0,K.useMemo)(()=>Dye(m.anchor,h),[m.anchor,h]),v=`${m.anchor.getFullYear()}-${String(m.anchor.getMonth()+1).padStart(2,`0`)}`,y=e.filter(e=>e.scheduledDates?.some(e=>e.startsWith(v))||e.date?.startsWith(v)),b=e.filter(e=>!!e.date||!!e.scheduledDates?.length).length;return e.length===0?(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col bg-background`,"data-testid":`calendar-agenda-view`,children:[(0,q.jsx)($8,{nav:m,overlayMode:u,onOverlayModeChange:d}),(0,q.jsx)(`p`,{className:`px-4 py-16 text-center text-xs text-muted-foreground`,children:`No entries match your search.`})]}):(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col bg-background`,"data-testid":`calendar-agenda-view`,children:[(0,q.jsx)($8,{nav:m,meta:`${y.length} of ${n5(b,`dated`)} in ${m.label}`,overlayMode:u,onOverlayModeChange:d}),(0,q.jsx)(Iye,{days:_.flatMap(e=>e.days)}),g.length===0?(0,q.jsxs)(`p`,{className:`px-4 py-16 text-center text-xs text-muted-foreground`,children:[`Nothing dated in `,m.label,`. Step to another month, or widen the date window.`]}):(0,q.jsx)(`div`,{className:`flex-1 pb-6`,children:g.map(e=>(0,q.jsxs)(`section`,{children:[(0,q.jsx)(Fye,{day:e,top:t,onCreateOnDay:s??(()=>{}),onInspectDay:p}),(0,q.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.entries.map((t,s)=>(0,q.jsx)(`div`,{onClick:f?()=>f(t):void 0,className:f?`cursor-pointer`:void 0,children:(0,q.jsx)(F8,{entry:t,visibleFieldIds:n,tone:e.isToday?`primary`:`secondary`,onAddToToday:r,onRunStart:i,moveNotebookTargets:a,onMoveNotebook:o})},t.scheduleItemId??`${t.id}-${s}`))})]},e.key))}),(0,q.jsx)(t5,{entries:h.undated})]})}var Rye=3;function zye({day:e,onCreateOnDay:t,onInspectEntry:n,onInspectDay:r}){let i=e.entries.slice(0,Rye),a=e.entries.length-i.length,o=`${W8(e.date)} ${e.dayOfMonth}`,s=`pointer-events-auto rounded px-1 py-0.5 font-mono text-xs font-bold hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${e.isToday?`text-primary`:e.inMonth?`text-foreground`:`text-muted-foreground`}`;return(0,q.jsxs)(`div`,{className:`group/cell relative flex min-h-[5.5rem] min-w-0 flex-col gap-1 border-l border-border/50 p-1.5 first:border-l-0 ${e.inMonth?``:`bg-muted/40`}`,"data-testid":`calendar-planner-cell`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.key),className:`absolute inset-0 h-full w-full cursor-pointer`,"aria-label":`Add an entry on ${o}`,"data-testid":`calendar-planner-cell-add`}),(0,q.jsxs)(`div`,{className:`pointer-events-none relative flex items-center gap-1`,children:[r?(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.key)},"data-testid":Q.CALENDAR_DAY_HEADER,"aria-label":`Inspect ${o}`,title:`Inspect ${o}`,className:s,children:e.dayOfMonth}):(0,q.jsx)(M,{to:gH(e.key),onClick:e=>e.stopPropagation(),className:s,title:`Open ${o}`,children:e.dayOfMonth}),e.isToday&&(0,q.jsx)(`span`,{className:`rounded-full bg-primary/10 px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider text-primary`,children:`Today`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.key),className:`pointer-events-auto ml-auto grid size-6 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-primary`,"aria-label":`Add an entry on ${o}`,title:`Add an entry on this day`,"data-testid":`calendar-planner-add-button`,children:(0,q.jsx)(Zr,{className:`size-3.5`,"aria-hidden":!0})}),e.entries.length>0&&(0,q.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-muted-foreground`,children:e.entries.length})]}),(0,q.jsxs)(`div`,{className:`pointer-events-none relative flex flex-col gap-1`,children:[i.map((e,t)=>(0,q.jsx)(`span`,{className:`pointer-events-auto`,children:(0,q.jsx)(e5,{entry:e,onInspect:n})},e.scheduleItemId??`${e.id}-${t}`)),a>0&&(0,q.jsx)(`span`,{className:`pointer-events-auto`,children:(0,q.jsxs)(nt,{children:[(0,q.jsxs)(l,{render:(0,q.jsx)(`button`,{type:`button`,onClick:e=>e.stopPropagation(),className:`w-full rounded px-1 py-0.5 text-left text-[11px] font-semibold text-primary hover:bg-muted`}),children:[`+`,a,` more`]}),(0,q.jsxs)(Lr,{align:`start`,sideOffset:4,"data-testid":Q.CALENDAR_MORE_POPOVER,className:`w-64 space-y-2 p-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 pb-1.5 text-xs font-bold`,children:[(0,q.jsx)(`span`,{children:o}),(0,q.jsx)(M,{to:gH(e.key),className:`text-xs font-medium text-primary hover:underline`,children:`Open day`})]}),(0,q.jsx)(`div`,{className:`flex max-h-56 flex-col gap-1 overflow-y-auto`,children:e.entries.map((e,t)=>(0,q.jsx)(e5,{entry:e,onInspect:n},e.scheduleItemId??`${e.id}-more-${t}`))})]})]})})]})]})}function Bye({week:e,onCreateOnDay:t,onInspectEntry:n,onInspectDay:r}){return(0,q.jsxs)(`div`,{className:`grid grid-cols-[3.75rem_repeat(7,minmax(0,1fr))] border-t border-border/60`,"data-testid":`calendar-planner-week`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col justify-start gap-0.5 p-1.5`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-foreground/85`,children:e.label}),(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.days.reduce((e,t)=>e+t.entries.length,0)})]}),e.days.map(e=>(0,q.jsx)(zye,{day:e,onCreateOnDay:t,onInspectEntry:n,onInspectDay:r},e.key))]})}function Vye({weeks:e,visibleFieldIds:t,onAddToToday:n,onRunStart:r,moveNotebookTargets:i,onMoveNotebook:a,onCreateOnDay:o,onInspectDay:s}){let c=e.filter(e=>e.days.some(e=>e.entries.length>0));return c.length===0?(0,q.jsx)(`p`,{className:`px-4 py-16 text-center text-xs text-muted-foreground`,children:`No dated entries in this month.`}):(0,q.jsx)(`div`,{className:`space-y-3 p-3`,children:c.map(e=>(0,q.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border/60 bg-card`,"data-testid":`calendar-planner-week-card`,children:[(0,q.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/60 bg-muted/30 px-3 py-2`,children:[(0,q.jsx)(U,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,q.jsxs)(`span`,{className:`font-mono text-xs font-bold text-foreground`,children:[`Week of `,e.label]}),(0,q.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:[e.days.reduce((e,t)=>e+t.entries.length,0),` `,e.days.reduce((e,t)=>e+t.entries.length,0)===1?`entry`:`entries`]})]}),e.days.filter(e=>e.entries.length>0).map(e=>(0,q.jsxs)(`div`,{className:`border-b border-border/40 last:border-b-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-2`,children:[s?(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.key),"data-testid":Q.CALENDAR_DAY_HEADER,className:`inline-flex min-h-11 items-center gap-1.5 rounded-md px-1 font-mono text-xs font-bold hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${e.isToday?`text-primary`:`text-foreground`}`,children:(0,q.jsxs)(`span`,{children:[X8[(e.date.getDay()+6)%7],` `,e.dayOfMonth]})}):(0,q.jsxs)(`span`,{className:`font-mono text-xs font-bold ${e.isToday?`text-primary`:`text-foreground`}`,children:[X8[(e.date.getDay()+6)%7],` `,e.dayOfMonth]}),e.isToday&&(0,q.jsx)(`span`,{className:`rounded-full bg-primary/10 px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider text-primary`,children:`Today`}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[e.entries.slice(0,4).map(e=>(0,q.jsx)(`span`,{className:`size-1.5 rounded-full ${J8(K8(e)).bar}`,title:e.title,"aria-hidden":!0},e.id)),(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e.key),className:`grid size-11 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-primary`,"aria-label":`Add an entry on ${X8[(e.date.getDay()+6)%7]} ${e.dayOfMonth}`,title:`Add an entry on this day`,"data-testid":`calendar-planner-add-button`,children:(0,q.jsx)(Zr,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,q.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.entries.map(o=>(0,q.jsx)(F8,{entry:o,visibleFieldIds:t,tone:e.isToday?`primary`:`secondary`,onAddToToday:n,onRunStart:r,moveNotebookTargets:i,onMoveNotebook:a},o.id))})]},e.key))]},e.label))})}function Hye({entries:e,visibleFieldIds:t,onAddToToday:n,onRunStart:r,moveNotebookTargets:i,onMoveNotebook:a,onCreateOnDay:o,monthParam:s,onMonthChange:c,overlayMode:l,onOverlayModeChange:u,onInspectEntry:d,onInspectDay:f}){let p=oY(),m=Q8(s,c),h=(0,K.useMemo)(()=>B8(e),[e]),g=(0,K.useMemo)(()=>Oye(m.anchor,h),[m.anchor,h]),_=`${m.anchor.getFullYear()}-${String(m.anchor.getMonth()+1).padStart(2,`0`)}`,v=e.filter(e=>e.scheduledDates?.some(e=>e.startsWith(_))||e.date?.startsWith(_)).length;return e.length===0?(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col bg-background`,"data-testid":`calendar-planner-view`,children:[(0,q.jsx)($8,{nav:m,overlayMode:l,onOverlayModeChange:u}),(0,q.jsx)(`p`,{className:`px-4 py-16 text-center text-xs text-muted-foreground`,children:`No entries match your search.`})]}):(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col bg-background`,"data-testid":`calendar-planner-view`,children:[(0,q.jsx)($8,{nav:m,meta:`${v} dated ${v===1?`entry`:`entries`} in ${m.label}`,overlayMode:l,onOverlayModeChange:u}),p?(0,q.jsx)(Vye,{weeks:g,visibleFieldIds:t,onAddToToday:n,onRunStart:r,moveNotebookTargets:i,onMoveNotebook:a,onCreateOnDay:o??(()=>{}),onInspectDay:f}):(0,q.jsx)(`div`,{className:`flex-1 overflow-x-auto pb-6`,children:(0,q.jsxs)(`div`,{className:`min-w-[52rem]`,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-[3.75rem_repeat(7,minmax(0,1fr))] bg-muted/40`,children:[(0,q.jsx)(`div`,{}),X8.map(e=>(0,q.jsx)(`div`,{className:`border-l border-border/50 px-1.5 py-1.5 text-[11px] font-bold uppercase tracking-[0.08em] text-muted-foreground first:border-l-0`,children:e},e))]}),g.map(e=>(0,q.jsx)(Bye,{week:e,onCreateOnDay:o??(()=>{}),onInspectEntry:d,onInspectDay:f},e.label))]})}),(0,q.jsx)(t5,{entries:h.undated})]})}function Uye(e,t,n){return{journalDate:n,title:e.title,rawContent:t,sourceId:e.sourceId,type:`journal`}}var Wye=[{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`}],Gye=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function Kye(e,t){return new Date(e,t+1,0).getDate()}function qye(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function r5(e,t){let n=t_(e);if(n.error)return e;if(!t||t===`all`)return F_({...n,window:void 0});let r=t_(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:F_({...n,window:r.window})}function Jye(e){let t=t_(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function Yye({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,K.useMemo)(()=>Jye(e),[e]),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(()=>new Date),u=s.getFullYear(),d=s.getMonth(),f=(0,K.useMemo)(()=>i?i.kind===`relative`?`last ${i.size}${i.unit}`:i.kind===`param`?`last $${i.param}${i.unit?` ${i.unit}`:``}`:i.end?`from ${i.start} to ${i.end}`:`from ${i.start}`:`All time`,[i]),p=(0,K.useMemo)(()=>{if(!i||i.kind===`param`)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:lU(t),end:lU(e)}},[i]),m=(0,K.useMemo)(()=>{let e=Kye(u,d),t=qye(u,d),n=[];for(let e=0;e<t;e++)n.push(null);for(let t=1;t<=e;t++)n.push(t);return n},[u,d]),h=n=>{if(!a)o(n),t(r5(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(r5(e,`from ${r} to ${i}`))}},g=e=>{e.stopPropagation(),c(new Date(u,d-1,1))},_=e=>{e.stopPropagation(),c(new Date(u,d+1,1))},v=s.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`}),y=lU(new Date);return(0,q.jsxs)(`div`,{className:$(`relative inline-flex items-center`,r),children:[(0,q.jsxs)(nt,{children:[(0,q.jsxs)(l,{"data-testid":`wql-window-picker-trigger`,className:`flex h-9 max-lg:min-h-11 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`,children:[(0,q.jsx)(U,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`font-mono text-xs`,children:f}),(0,q.jsx)(rt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]}),(0,q.jsxs)(Lr,{align:`end`,sideOffset:6,"aria-label":`Time window filter`,className:`w-72 p-3`,children:[(0,q.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1 border-b border-border/60 pb-2`,children:Wye.map(n=>{let r=n.value===`all`?!i:i?.kind===`relative`&&`last ${i.size}${i.unit}`===n.value;return(0,q.jsx)(`button`,{type:`button`,"data-testid":`wql-window-preset-${n.value}`,onClick:()=>{o(null),t(r5(e,n.value))},className:$(`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,q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:g,"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,q.jsx)(j,{className:`size-4`})}),(0,q.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:v}),(0,q.jsx)(`button`,{type:`button`,onClick:_,"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,q.jsx)(ee,{className:`size-4`})})]}),(0,q.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:Gye.map(e=>(0,q.jsx)(`div`,{className:`text-center text-[10px] font-medium text-muted-foreground`,children:e},e))}),(0,q.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,"data-testid":`wql-calendar-grid`,children:m.map((e,t)=>{if(e===null)return(0,q.jsx)(`div`,{className:`size-8`},`empty-${t}`);let r=`${u}-${String(d+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,i=p&&r>=p.start&&r<=p.end,o=p&&r===p.start||a===r,s=p&&r===p.end,c=r===y,l=n.has(r);return(0,q.jsxs)(`button`,{type:`button`,"data-testid":`wql-calendar-day-${r}`,onClick:()=>h(r),className:$(`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,q.jsx)(`span`,{children:e}),l&&!o&&!s&&(0,q.jsx)(`span`,{className:`absolute bottom-0.5 size-1 rounded-full bg-primary`})]},r)})}),a&&(0,q.jsxs)(`div`,{className:`mt-2 text-center text-[10px] text-muted-foreground`,children:[`Select second date to complete range (starting from `,a,`)`]})]})]}),i&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`wql-window-picker-clear`,onClick:()=>{o(null),t(r5(e,null))},title:`Clear time window`,"aria-label":`Clear time window`,className:`ml-1 grid size-7 max-lg:min-h-11 max-lg:min-w-11 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,q.jsx)(ze,{className:`size-3.5`})})]})}var Xye={cards:`Cards`,rows:`Rows`,feed:`Feed`,agenda:`Agenda`,planner:`Planner`},Zye={cards:`CRD`,rows:`ROW`,feed:`FED`,agenda:`AGD`,planner:`PLN`},Qye=new Set([`date`,`day`,`week`,`month`,`year`]);function $ye({level:e,settings:t,availableLayouts:n,availableGroupDims:r,groupDims:i,onLayoutChange:a,onToggleGroupDim:o,onToggleField:s,onOpenQuerySettings:c,calendarCapable:u=!0,query:d,onQueryChange:f,addActionLabel:p,onAddAction:m,onAddToDashboard:h,addToDashboardDisabled:g=!1}){let _=T8(e),v=new Set(t.visibleFields),y=u?r:r.filter(e=>!Qye.has(e.toLowerCase())),b=u&&d!==void 0&&!!f,x=!!(m||h||c);return(0,q.jsxs)(nt,{children:[(0,q.jsxs)(l,{render:(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-testid":Q.STREAM_VIEW_POPOVER_TRIGGER,className:`h-8 gap-1.5 px-2.5 text-xs font-semibold`}),children:[(0,q.jsx)(zi,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`View`}),(0,q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:Zye[t.layout]})]}),(0,q.jsxs)(Lr,{align:`end`,sideOffset:6,"data-testid":Q.STREAM_VIEW_POPOVER_CONTENT,className:`w-72 space-y-3 p-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-1.5 text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Layout`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Stream layout`,children:n.map(e=>{let n=t.layout===e;return(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(e),"aria-pressed":n,className:`rounded-md border px-2 py-1 text-xs font-medium max-lg:min-h-11 transition-colors ${n?`border-primary bg-primary text-primary-foreground`:`border-border bg-card text-foreground hover:bg-muted`}`,children:Xye[e]},e)})})]}),b&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-1.5 text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Date window`}),(0,q.jsx)(Yye,{query:d,onQueryChange:f,className:`w-full`})]}),y.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-1.5 text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Group by`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Group by dimension`,children:y.map(e=>{let t=i.some(t=>t.toLowerCase()===e.toLowerCase());return(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e),"aria-pressed":t,className:`rounded-md border px-2 py-1 text-xs font-medium max-lg:min-h-11 transition-colors ${t?`border-primary bg-primary/15 text-primary`:`border-border bg-card text-foreground hover:bg-muted`}`,children:e},e)})})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-1.5 text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Visible fields`}),(0,q.jsx)(`div`,{className:`max-h-40 space-y-1.5 overflow-y-auto pr-1`,children:(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:_.map(e=>{let t=v.has(e.id);return(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),"aria-pressed":t,className:`rounded border px-2 py-0.5 text-xs max-lg:min-h-11 transition-colors ${t?`border-primary/40 bg-primary/10 font-medium text-primary`:`border-border bg-background text-muted-foreground hover:text-foreground`}`,children:e.label},e.id)})})})]}),x&&(0,q.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[m&&(0,q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:m,"data-testid":Q.STREAM_VIEW_ADD_ACTION,className:`h-8 max-lg:min-h-11 w-full justify-start gap-2 text-xs font-medium`,children:[(0,q.jsx)(Zr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:p??`+ Add`})]}),h&&(0,q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,disabled:g,onClick:h,"data-testid":Q.SAVE_STREAM_QUERY,className:`h-8 max-lg:min-h-11 w-full justify-start gap-2 text-xs font-medium`,children:[(0,q.jsx)(Ui,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Add to dashboard`})]}),c&&(0,q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,className:`h-8 max-lg:min-h-11 w-full justify-start text-xs`,children:`Configure view defaults…`})]})]})]})}function ebe(e,t){return yU.updateItem(e,t)}function tbe(e){return e?.blocks?Object.values(e.blocks).filter(e=>e.kind===`wod`).sort((e,t)=>e.from-t.from).map((t,n)=>{let r=e.rawContent.slice(t.from,t.to).split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith("```")),i=r[0]?r[0].length>36?`${r[0].slice(0,35)}…`:r[0]:`Workout block ${n+1}`;return{id:t.id,label:`Block ${n+1}: ${i}`}}):[]}function i5(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=z8(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`})}async function a5(e){let t=((await X.getNote(e.sourceNoteId).catch(()=>void 0))?.title||e.fallbackTitle||`Workout`).trim(),n=e.date?`${t} (${e.date})`:`${t} (Copy)`,r=await Rw(X.storage,e.sourceNoteId,`notebook/journal`,{title:n});return await X.storage.transaction([`schedule_items`],`readwrite`,async t=>{let n=await t.readonly(`schedule_items`).get(e.scheduleItemId);if(!n)return;let i={...n,noteId:r.id,fallbackTitle:r.title,sourceNotebookId:r.notebookId??`notebook/journal`,updatedAt:Date.now()};delete i.blockId,await t.readwrite(`schedule_items`).put(i)}),gU(),r}function nbe({entry:e,dayDate:t=null,dayEntries:n,onClose:r,onRunEntry:i,onPlanForDate:a,onSelectEntry:o,onMutated:s}){let c=dt(),l=NV(),u=l?.dispatch,d=!!l?.navState?.rightDrawerOpen,f=!!l?.navState?.peekTarget,p=!!(e||t),m=(0,K.useRef)(d),h=(0,K.useRef)(f),g=(0,K.useRef)(!1),_=(0,K.useRef)(r);_.current=r;let[v,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(``),[S,C]=(0,K.useState)(``),[w,T]=(0,K.useState)(!1),[E,D]=(0,K.useState)([]),[O,k]=(0,K.useState)(``),[A,j]=(0,K.useState)(!1),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)([]),[ee,L]=(0,K.useState)(null),[R,z]=(0,K.useState)(!1),[B,V]=(0,K.useState)(0);(0,K.useEffect)(()=>{if(!(!p||!u))return g.current=!1,u({type:`SET_INSPECTOR_DRAWER`,open:!0}),()=>{g.current||u({type:`SET_INSPECTOR_DRAWER`,open:!1})}},[p,u]),(0,K.useEffect)(()=>{let e=!m.current&&d,t=!h.current&&f;m.current=d,h.current=f,p&&(t?(g.current=!0,_.current()):e&&_.current())},[p,d,f]),(0,K.useEffect)(()=>{if(!(!t||e))return _U(()=>V(e=>e+1))},[t,e]);let H=e?.id,te=e?.date,ne=e?.scheduleItemId,re=e?.scheduleNotes,ie=e?.adHocSessionId;if((0,K.useEffect)(()=>{let e=re??``;if(y(te??``),x(e),C(e),T(!1),D([]),k(``),P(null),I([]),!H)return;let t=!1;return ie&&X.getSessionById(ie).then(e=>e?yU.findNearbyMatches(e,2):[]).then(e=>{t||I(e)}).catch(()=>{}),ne&&Promise.all([X.getNote(H).catch(()=>void 0),X.storage.readonly(`schedule_items`).get(ne).catch(()=>void 0)]).then(([n,r])=>{if(t)return;let i=tbe(n);D(i);let a=r?.blockId??``;k(a),r&&r.notes!==void 0&&!e&&(x(r.notes),C(r.notes))}).catch(()=>{}),()=>{t=!0}},[H,te,ne,re,ie]),(0,K.useEffect)(()=>{if(!t||e){L(null),z(!1);return}let n=!1;return z(!0),P(null),yU.getDayOverlay(t).then(e=>{n||(L(e),z(!1))}).catch(()=>{n||(L(null),z(!1))}),()=>{n=!0}},[t,e,B]),(0,K.useEffect)(()=>{if(!p)return;let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[p,r]),!p)return null;let ae=(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":Q.CALENDAR_PEEK_BACKDROP,onClick:r,className:`fixed inset-0 z-30 bg-black/30 backdrop-blur-[1px] xl:hidden`});if(!e&&t){let e=ee?.planned??[],i=e.flatMap(({item:e,note:t,pairedSessions:n})=>n.map(n=>({sess:n,item:e,note:t}))),s=ee?.adhocSessions??[],c=e.length>0||i.length>0||s.length>0,l=c?[]:n??[];return(0,q.jsxs)(q.Fragment,{children:[ae,(0,q.jsxs)(`aside`,{"data-testid":Q.CALENDAR_PEEK_DRAWER,"data-peek-mode":`day`,"aria-label":`Day schedule for ${t}`,className:`fixed inset-y-0 right-0 z-40 flex w-[340px] max-w-full flex-col border-l border-border bg-background shadow-2xl`,children:[(0,q.jsxs)(`header`,{className:`flex items-start justify-between gap-2 border-b border-border/60 px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider text-primary`,children:`Day Summary`}),(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:t})]}),(0,q.jsx)(`h2`,{className:`truncate text-base font-bold text-foreground`,children:i5(t)})]}),(0,q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:r,"aria-label":`Close peek drawer`,"data-testid":Q.CALENDAR_PEEK_CLOSE,className:`size-8 max-lg:size-11 shrink-0`,children:(0,q.jsx)(ze,{className:`size-4`,"aria-hidden":!0})})]}),(0,q.jsx)(`div`,{className:`flex-1 space-y-4 overflow-y-auto px-4 py-4`,children:R?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading day schedule…`}):!c&&l.length===0?(0,q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-xs text-muted-foreground`,children:[`Nothing scheduled or logged for `,i5(t),` yet.`]}):(0,q.jsxs)(q.Fragment,{children:[e.length>0&&(0,q.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Planned workouts`,children:[(0,q.jsxs)(`h3`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[`Planned (`,e.length,`)`]}),(0,q.jsx)(`ul`,{className:`space-y-2`,children:e.map(({item:e,note:t,pairedSessions:n})=>{let i=e.status===`completed`||n.length>0,a=e.status===`skipped`;return(0,q.jsxs)(`li`,{className:`rounded-md border border-border/60 bg-card px-3 py-2 text-xs space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(M,{to:vH(e.noteId),onClick:r,className:`min-w-0 flex-1 truncate font-semibold text-foreground hover:underline`,children:t?.title||e.fallbackTitle||`Untitled Workout`}),(0,q.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-semibold ${i?`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:a?`bg-muted text-muted-foreground line-through`:`bg-primary/10 text-primary`}`,children:i?`Completed`:a?`Skipped`:`Planned`})]}),e.slot&&(0,q.jsxs)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`Slot: `,e.slot]}),e.notes&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground whitespace-pre-wrap`,children:e.notes})]},e.id)})})]}),(i.length>0||s.length>0)&&(0,q.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Logged sessions`,children:[(0,q.jsxs)(`h3`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[`Logged Sessions (`,i.length+s.length,`)`]}),(0,q.jsxs)(`ul`,{className:`space-y-2`,children:[i.map(({sess:e,note:t})=>(0,q.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-xs`,children:[(0,q.jsx)(M,{to:EH(e.id),onClick:r,className:`min-w-0 flex-1 truncate font-semibold text-foreground hover:underline`,children:t?.title||`Logged Session`}),typeof e.duration==`number`&&e.duration>0&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-emerald-800 dark:text-emerald-200`,children:Es(e.duration)})]},e.id)),s.map(({session:e,note:t})=>(0,q.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-2 text-xs`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(M,{to:EH(e.id),onClick:r,className:`block truncate font-semibold text-foreground hover:underline`,children:t?.title||`Ad-hoc Workout`}),(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Ad-hoc log`})]}),typeof e.duration==`number`&&e.duration>0&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-sky-900 dark:text-sky-200`,children:Es(e.duration)})]},e.id))]})]}),l.length>0&&(0,q.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Entries on this date`,children:[(0,q.jsxs)(`h3`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[`Entries (`,l.length,`)`]}),(0,q.jsx)(`ul`,{className:`space-y-1.5`,children:l.map((e,t)=>(0,q.jsx)(`li`,{children:o?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex w-full items-center justify-between gap-2 rounded-md border border-border/60 bg-card px-3 py-2 text-left text-xs font-medium text-foreground hover:bg-muted/60 max-lg:min-h-11`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title||`Untitled Workout`}),(0,q.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:`Inspect`})]}):(0,q.jsxs)(M,{to:SG(e),onClick:r,className:`flex w-full items-center justify-between gap-2 rounded-md border border-border/60 bg-card px-3 py-2 text-xs font-medium text-foreground hover:bg-muted/60`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title||`Untitled Workout`}),(0,q.jsx)(rn,{className:`size-3.5 shrink-0`,"aria-hidden":!0})]})},e.scheduleItemId??`${e.id}-${t}`))})]})]})}),(0,q.jsxs)(`footer`,{className:`flex flex-col gap-2 border-t border-border/60 px-4 py-3`,children:[a&&(0,q.jsxs)(J,{type:`button`,onClick:()=>{r(),a(t)},"data-testid":Q.SCHEDULE_PEEK_PLAN_FOR_DATE,className:`w-full justify-center gap-1.5 max-lg:min-h-11`,children:[(0,q.jsx)(Zr,{className:`size-4`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Plan for date`})]}),(0,q.jsx)(M,{to:gH(t),onClick:r,"data-testid":Q.SCHEDULE_PEEK_OPEN_DAY,className:`inline-flex w-full items-center justify-center gap-1.5 rounded-md border border-border bg-card px-3 py-2 text-xs font-semibold text-foreground hover:bg-muted max-lg:min-h-11`,children:(0,q.jsx)(`span`,{children:`Open day →`})})]})]})]})}if(!e)return null;let oe=K8(e),se=J8(oe),ce=!!e.scheduleItemId,le=e.pairedSessions?.[0],ue=e.scheduleStatus===`completed`||(e.pairedSessions?.length??0)>0?`Completed`:e.scheduleStatus===`skipped`?`Skipped`:e.overlayKind===`logged`?`Ad-hoc Logged`:`Planned`,de=b.trim()!==S.trim(),fe=async()=>{if(e.scheduleItemId){j(!0),P(null),T(!1);try{let t=b.trim();await yU.updateItem(e.scheduleItemId,{notes:t}),C(t),x(t),T(!0),s?.()}catch(e){P(e instanceof Error?e.message:`Could not save day cue.`)}finally{j(!1)}}},pe=async t=>{if(e.scheduleItemId){k(t),j(!0),P(null);try{await ebe(e.scheduleItemId,{blockId:t||null}),s?.()}catch(e){P(e instanceof Error?e.message:`Could not update target block.`)}finally{j(!1)}}},me=async()=>{if(e.scheduleItemId){j(!0),P(null);try{let t=await a5({scheduleItemId:e.scheduleItemId,sourceNoteId:e.id,date:e.date??v,fallbackTitle:e.title});s?.(),r(),c(`${vH(t.id)}?edit=1`)}catch(e){P(e instanceof Error?e.message:`Could not fork copy for this day.`)}finally{j(!1)}}},he=async()=>{if(!(!e.scheduleItemId||!v.trim())){j(!0),P(null);try{await yU.updateItem(e.scheduleItemId,{date:v.trim()}),s?.(),r()}catch(e){P(e instanceof Error?e.message:`Could not move schedule item.`)}finally{j(!1)}}},ge=async t=>{if(e.scheduleItemId){j(!0),P(null);try{await yU.updateItem(e.scheduleItemId,{status:t}),s?.()}catch(e){P(e instanceof Error?e.message:`Could not update status.`)}finally{j(!1)}}},_e=async()=>{if(e.scheduleItemId){j(!0),P(null);try{await yU.removeItem(e.scheduleItemId),s?.(),r()}catch(e){P(e instanceof Error?e.message:`Could not remove from schedule.`)}finally{j(!1)}}},ve=async t=>{if(e.adHocSessionId){j(!0),P(null);try{await yU.attributeSession({sessionId:e.adHocSessionId,sessionDate:t.date,scheduleItemId:t.id}),s?.(),r()}catch(e){P(e instanceof Error?e.message:`Could not link session to plan.`)}finally{j(!1)}}};return(0,q.jsxs)(q.Fragment,{children:[ae,(0,q.jsxs)(`aside`,{"data-testid":Q.CALENDAR_PEEK_DRAWER,"data-peek-mode":`entry`,"aria-label":`Schedule details for ${e.title||`Workout`}`,className:`fixed inset-y-0 right-0 z-40 flex w-[340px] max-w-full flex-col border-l border-border bg-background shadow-2xl`,children:[(0,q.jsxs)(`header`,{className:`flex items-start justify-between gap-2 border-b border-border/60 px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2.5 w-1 rounded-full ${se.bar}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider ${se.chip}`,children:oe===`journal`&&e.notebookIds?.length===0?`Unfiled`:oe}),(0,q.jsx)(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[11px] font-semibold text-muted-foreground`,children:ue}),e.scheduleSlot&&(0,q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[11px] font-semibold text-foreground`,children:e.scheduleSlot})]}),(0,q.jsx)(`h2`,{className:`truncate text-base font-bold text-foreground`,children:e.title||`Untitled Workout`}),e.date&&(0,q.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,q.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:e.date})]})]}),(0,q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:r,"aria-label":`Close peek drawer`,"data-testid":Q.CALENDAR_PEEK_CLOSE,className:`size-8 max-lg:size-11 shrink-0`,children:(0,q.jsx)(ze,{className:`size-4`,"aria-hidden":!0})})]}),(0,q.jsxs)(`div`,{className:`flex-1 space-y-4 overflow-y-auto px-4 py-4`,children:[N&&(0,q.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:N}),ce?(0,q.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-border/60 bg-muted/20 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`label`,{htmlFor:`peek-day-cue`,className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Day Cue`}),w&&!de&&(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-emerald-700 dark:text-emerald-300`,children:`Saved`})]}),(0,q.jsx)(`textarea`,{id:`peek-day-cue`,rows:2,value:b,onChange:e=>{x(e.target.value),w&&T(!1)},disabled:A,placeholder:`Add a day-specific cue (canonical Note stays unchanged)…`,"data-testid":Q.SCHEDULE_PEEK_DAY_CUE_INPUT,className:`w-full rounded-md border border-input bg-background px-2.5 py-2 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring max-lg:min-h-11`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Applies only to this date.`}),(0,q.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:A||!de,onClick:()=>void fe(),"data-testid":Q.SCHEDULE_PEEK_DAY_CUE_SAVE,className:`h-8 gap-1.5 px-2.5 text-xs max-lg:min-h-11`,children:[(0,q.jsx)(Ui,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Save cue`})]})]})]}):e.scheduleNotes&&(0,q.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-foreground`,children:[(0,q.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Day Cue`}),(0,q.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap`,children:e.scheduleNotes})]}),ce&&E.length>=2&&(0,q.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-border/60 bg-muted/20 p-3`,children:[(0,q.jsxs)(`label`,{htmlFor:`peek-block-select`,className:`flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Target workout block`})]}),(0,q.jsxs)(`select`,{id:`peek-block-select`,value:O,onChange:e=>void pe(e.target.value),disabled:A,"data-testid":Q.SCHEDULE_PEEK_BLOCK_SELECT,className:`h-9 max-lg:min-h-11 w-full rounded-md border border-input bg-background px-2.5 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,q.jsxs)(`option`,{value:``,children:[`Whole note (all `,E.length,` blocks)`]}),E.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),le&&(0,q.jsxs)(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 p-3 text-xs`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 font-semibold text-emerald-800 dark:text-emerald-200`,children:[(0,q.jsx)(kt,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Logged Session`}),typeof le.duration==`number`&&le.duration>0&&(0,q.jsx)(`span`,{className:`ml-auto font-mono`,children:Es(le.duration)})]}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsxs)(M,{to:EH(le.sessionId),onClick:r,className:`inline-flex items-center gap-1 font-medium text-emerald-800 underline dark:text-emerald-200`,children:[(0,q.jsx)(`span`,{children:`Open session results`}),(0,q.jsx)(rn,{className:`size-3`,"aria-hidden":!0})]})})]}),e.adHocSessionId&&(0,q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-sky-500/30 bg-sky-500/10 p-3 text-xs`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 font-semibold text-sky-900 dark:text-sky-200`,children:[(0,q.jsx)(_r,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Unlinked Session Log`}),e.noteSourceRevision&&(0,q.jsxs)(`span`,{className:`ml-auto font-mono text-[11px]`,children:[`v`,e.noteSourceRevision]})]}),(0,q.jsxs)(M,{to:EH(e.adHocSessionId),onClick:r,className:`inline-flex items-center gap-1 font-medium text-sky-900 underline dark:text-sky-200`,children:[(0,q.jsx)(`span`,{children:`Inspect session & attribute`}),(0,q.jsx)(rn,{className:`size-3`,"aria-hidden":!0})]}),F.length>0&&(0,q.jsxs)(`div`,{className:`space-y-1 border-t border-sky-500/20 pt-2`,children:[(0,q.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Match nearby plan (±2d)`}),F.map(e=>(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void ve(e),className:`h-8 max-lg:min-h-11 w-full justify-start gap-1.5 text-xs`,children:[(0,q.jsx)(Pr,{className:`size-3`,"aria-hidden":!0}),(0,q.jsxs)(`span`,{children:[`Pair with `,e.date,e.slot?` (${e.slot})`:``]})]},e.id))]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i&&(0,q.jsxs)(J,{type:`button`,onClick:()=>{i(e),r()},disabled:A,className:`w-full justify-start gap-2 max-lg:min-h-11`,children:[(0,q.jsx)(Sr,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Run workout now`})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(M,{to:SG(e),onClick:r,className:`inline-flex flex-1 items-center justify-center gap-1.5 rounded-md border border-border bg-card px-3 py-2 text-xs font-medium text-foreground hover:bg-muted max-lg:min-h-11`,children:[(0,q.jsx)(`span`,{children:`Open note`}),(0,q.jsx)(rn,{className:`size-3.5`,"aria-hidden":!0})]}),e.date&&(0,q.jsxs)(M,{to:gH(e.date),onClick:r,className:`inline-flex flex-1 items-center justify-center gap-1.5 rounded-md border border-border bg-card px-3 py-2 text-xs font-medium text-foreground hover:bg-muted max-lg:min-h-11`,children:[(0,q.jsx)(`span`,{children:`Open day`}),(0,q.jsx)(rn,{className:`size-3.5`,"aria-hidden":!0})]})]}),ce&&(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void me(),"data-testid":Q.SCHEDULE_PEEK_FORK_BTN,className:`w-full justify-start gap-2 text-xs max-lg:min-h-11`,children:[(0,q.jsx)(Pe,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Fork copy for this day`})]})]}),ce&&(0,q.jsxs)(`div`,{className:`space-y-3 border-t border-border/60 pt-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`peek-reschedule-date`,className:`text-xs font-semibold text-muted-foreground`,children:`Move to date`}),(0,q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,q.jsx)(`input`,{id:`peek-reschedule-date`,type:`date`,value:v,onChange:e=>y(e.target.value),disabled:A,className:`h-9 max-lg:min-h-11 flex-1 rounded-md border border-input bg-background px-2.5 text-xs text-foreground`}),(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A||!v||v===e.date,onClick:()=>void he(),className:`max-lg:min-h-11`,children:`Move`})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.scheduleStatus===`skipped`?(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void ge(`planned`),className:`gap-1.5 text-xs max-lg:min-h-11`,children:[(0,q.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Restore to planned`})]}):(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void ge(`skipped`),className:`gap-1.5 text-xs max-lg:min-h-11`,children:[(0,q.jsx)(ti,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Mark skipped`})]}),(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void _e(),className:`gap-1.5 border-destructive/40 text-xs text-destructive hover:bg-destructive/10 max-lg:min-h-11`,children:[(0,q.jsx)(Me,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Unschedule`})]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Unscheduling removes only this calendar slot — the canonical Note stays intact.`})]})]})]})]})}var rbe=/(?:^|\n)```(query[^\n]*)\n([\s\S]*?)\n```|\[([^\]]*)\]\((:[^)]*)\)!/g;function o5(e){let t=e.trim();return KU((()=>{try{return decodeURIComponent(t)}catch{return t}})())}function ibe(e){let t=o5(e);return t.startsWith(`:`)&&!t_(t).error}function abe(e){let t=[],n=0;for(let r of e.matchAll(rbe)){let i=r[0],a=i.startsWith(`
|
|
1158
1158
|
`),o=(r.index??0)+ +!!a,s=i.length-+!!a;if(r[1]!==void 0&&r[2]!==void 0){let i=hv(r[2],{fenceTag:r[1]}),a=i.query?KU(i.query.trim()):``;if(!a||!a.startsWith(`:`)||t_(a).error)continue;o>n&&t.push({kind:`markdown`,text:e.slice(n,o)}),t.push({kind:`query`,query:a,heading:i.title??``}),n=o+s;continue}let c=o5(r[4]??``);ibe(c)&&(o>n&&t.push({kind:`markdown`,text:e.slice(n,o)}),t.push({kind:`query`,query:c.trim(),heading:r[3]??``}),n=o+s)}n<e.length&&t.push({kind:`markdown`,text:e.slice(n)});let r=[];for(let e of t){let t=r[r.length-1];e.kind===`markdown`&&t?.kind===`markdown`?t.text+=e.text:r.push(e)}return r}function obe(e){return e.some(e=>e.kind===`query`)}var s5=`9999-12-31`;function sbe(e,t){return(e.date??s5).localeCompare(t.date??s5)||e.title.localeCompare(t.title,void 0,{numeric:!0,sensitivity:`base`})}function cbe(e){let t=new Date(`${e}T12:00:00`);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`,year:`numeric`})}function lbe({query:e,heading:t,onAddToToday:n,onRunStart:r,queryEngine:i=lJ}){let[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(null);(0,K.useEffect)(()=>{let t=!1;return o(null),c(null),i.query(e).then(e=>{t||o([...e].sort(sbe))}).catch(e=>{t||c(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e,i]);let l=(0,K.useMemo)(()=>{if(!a)return null;let t=t_(e);if(t.error||!(`groupBy`in t)||!t.groupBy?.includes(`date`))return null;let n=new Map;for(let e of a){let t=e.date??``,r=n.get(t);r?r.push(e):n.set(t,[e])}return[...n.entries()]},[a,e]);if(s)return(0,q.jsxs)(`p`,{className:`my-3 text-xs text-destructive`,"data-testid":`readme-query-error`,children:[`Query failed: `,s]});if(a===null)return(0,q.jsx)(`div`,{className:`my-3 text-xs text-muted-foreground/60`,"data-testid":`readme-query-loading`,children:`Loading…`});if(a.length===0)return(0,q.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground/60`,"data-testid":`readme-query-empty`,children:`No entries match this query.`});let u=e=>(0,q.jsx)(F8,{entry:e,onAddToToday:n,onRunStart:r},e.id);return(0,q.jsxs)(`div`,{className:`my-3 not-prose`,"data-testid":`readme-query-block`,children:[t&&(0,q.jsx)(`p`,{className:`mt-4 mb-1 text-sm font-bold text-foreground`,"data-testid":`readme-query-heading`,children:t}),l?l.map(([e,t])=>(0,q.jsxs)(`div`,{className:`mt-3`,"data-testid":`readme-query-date-group`,children:[(0,q.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:e?cbe(e):`Undated`}),(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:t.map(u)})]},e||`undated`)):(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:a.map(u)})]})}var ube=new ER;function dbe({batch:e,testId:t=`stream-load-more`}){return e.hasMore?(0,q.jsx)(`div`,{ref:e.sentinelRef,className:`px-6 py-4 text-center`,"data-testid":t,children:(0,q.jsxs)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground hover:underline underline-offset-2`,"data-testid":`${t}-button`,onClick:()=>e.growTo(e.visible.length+200),children:[`Show more (`,(e.total-e.visible.length).toLocaleString(),` remaining)`]})}):null}function c5(e,t){return zV(e,t)}var fbe=150,pbe=/^\/notebook\/([^/]+)\/?$/,mbe=[`journal`,`playground`,`defaults`,`custom`,`guides`,`efforts`,`equipment`,`dashboards`];function hbe(e){switch(e.phase){case`checking`:return`Checking ${e.sourceLabel}…`;case`fetching`:return`Downloading ${e.chunkId??`library`}…`;case`applying`:return`Importing ${e.chunkId??`library`}…`;case`committed`:return`Committed ${e.chunkId??`chunk`}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return e.error??v8[e.outcome]}}function l5(e){return`${e.negate?`!`:``}${e.key}=${e.values.map(e=>`${e.wildcard?`*`:``}${e.value}`).sort().join(`|`)}`}function u5(e,t){let n={};for(let e of t){let t=l5(e);n[t]=(n[t]??0)+1}return e.filter(e=>{let t=l5(e),r=n[t]??0;return n[t]=r-1,r<=0})}var gbe={note:{singular:`note`,plural:`notes`},block:{singular:`block`,plural:`blocks`},effort:{singular:`effort`,plural:`efforts`},session:{singular:`session`,plural:`sessions`},segment:{singular:`segment`,plural:`segments`},event:{singular:`event`,plural:`events`},notebook:{singular:`notebook`,plural:`notebooks`},page:{singular:`page`,plural:`pages`},tag:{singular:`tag`,plural:`tags`},equipment:{singular:`equipment item`,plural:`equipment items`},feed:{singular:`feed`,plural:`feeds`}};function _be({error:e,syntaxHint:t,target:n,matched:r,total:i,countsPending:a,applied:o,ignored:s,advisories:c,groupDims:l,groupingSource:u,hasAppliedFilters:d,isCustomQuery:f,itemNoun:p}){return e||d||f||s>0||c.length>0?(0,q.jsxs)(`div`,{role:`status`,"data-testid":`stream-query-status`,className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[e?(0,q.jsx)(`span`,{className:`font-semibold text-destructive`,children:`Invalid query — showing previous results`}):n?(0,q.jsxs)(`span`,{className:`font-mono`,children:[`:`,n]}):null,(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`span`,{"data-testid":`stream-query-counts`,children:a?`Searching…`:`${r} of ${i}`}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{"data-testid":`stream-query-filters`,children:[o,` applied`,s>0?`, ${s} ignored`:``]}),l.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{"data-grouping-source":u,children:[`by `,l.join(`, `)]})]}),c.map(e=>(0,q.jsx)(`p`,{className:`w-full break-words text-amber-700 dark:text-amber-400`,children:e},e)),e&&t&&(0,q.jsx)(`p`,{className:`w-full break-words text-muted-foreground`,"data-testid":`stream-query-syntax-hint`,children:t})]}):(0,q.jsxs)(`div`,{role:`status`,"data-testid":`stream-query-status`,className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,q.jsx)(`span`,{"data-testid":`stream-query-counts`,children:a?`Searching…`:`${r.toLocaleString()} ${r===1?p.singular:p.plural}`}),l.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{"data-grouping-source":u,children:[`by `,l.join(`, `)]})]})]})}function vbe({profile:e,actions:t,queryEngine:n,deps:r,onAddToToday:i,registerStreamDraft:a}){let o=dt(),s=Qe(),c=OZ(),l=kZ(),u=FZ(),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!1),[h,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),b=(0,K.useSyncExternalStore)(qI,()=>VB().filter(e=>e.autoImport===!1&&HI(e.id)).map(e=>e.id).join(`
|
|
@@ -1198,4 +1198,4 @@ segmentVolume = reps * resistance (library) when has(reps) and has(resistance)
|
|
|
1198
1198
|
`));e(hH(n))},[e]),m=(0,K.useCallback)(t=>{if(/^https?:\/\//i.test(t)){window.open(t,`_blank`,`noopener,noreferrer`);return}e(t)},[e]);return(0,q.jsxs)(cCe,{actionsSlot:(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-2xl border border-zinc-200 bg-zinc-50/80 px-4 py-3 dark:border-zinc-700 dark:bg-zinc-900/70`,children:[(0,q.jsx)(fn,{className:`size-4 text-zinc-500`,"aria-hidden":`true`}),(0,q.jsx)(un,{checked:l,onCheckedChange:e=>n(e?`dark`:`light`),"aria-label":`Toggle dark mode`,children:(0,q.jsx)(Cn,{})}),(0,q.jsx)(zt,{className:`size-4 text-zinc-500`,"aria-hidden":`true`})]}),heroSlot:(0,q.jsx)(S5,{config:lCe,onAction:f}),children:[(0,q.jsxs)(`section`,{ref:r,id:`workout-widget-surface`,className:`mt-8 grid grid-cols-1 gap-4 xl:grid-cols-3`,children:[(0,q.jsx)(`div`,{className:`xl:col-span-2`,children:(0,q.jsx)(C5,{config:s,isDarkMode:l,onRun:p})}),(0,q.jsx)(`div`,{className:`space-y-4`,children:c.map(e=>(0,q.jsx)(w5,{config:e,onOpenDocs:m},e.title))})]}),(0,q.jsx)(M6,{})]})}function v9(e){let[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)({});(0,K.useEffect)(()=>{i(X0()),n(!0);let e=e=>{e.key===`wodwiki.quests.v1`&&i(X0())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let a=e=>{for(let t in r)if(r[t]?.[e])return!0;return!1};return{chapters:e.map(e=>{let t=(e.questIds??[]).map(e=>({id:e,isComplete:a(e)})),n=t.filter(e=>e.isComplete).length;return{chapter:e,completedCount:n,totalCount:t.length,isComplete:t.length>0&&n===t.length,quests:t}}),isHydrated:t}}function dCe({activeIndex:e,onCommand:t,captions:n}){return(0,q.jsx)(`div`,{className:`relative h-full w-full`,"data-testid":`tour-captions`,children:n.map((n,r)=>(0,q.jsx)(`div`,{"data-scroll-pane":!0,className:`absolute inset-0 overflow-y-auto transition-opacity duration-300`,style:{opacity:+(r===e),pointerEvents:r===e?`auto`:`none`},"aria-hidden":r!==e,inert:r!==e,children:(0,q.jsx)(fCe,{cap:n,onCommand:t})},n.id))})}function fCe({cap:e,onCommand:t}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`h3`,{className:`mb-3.5 xl:mb-5 text-[clamp(22px,2vw,32px)] font-extrabold leading-[1.12] tracking-[-0.03em]`,children:[(0,q.jsx)(`span`,{className:`mr-2 align-[0.2em] font-mono text-[0.5em] font-semibold tracking-[0.08em] text-muted-foreground`,children:e.num}),e.title]}),(0,q.jsx)(`p`,{className:`text-[14.5px] sm:text-base xl:text-[17px] leading-[1.7] xl:leading-[1.75] text-muted-foreground`,children:e.body}),e.bullets&&e.bullets.length>0&&(0,q.jsx)(`ul`,{className:`mt-3 space-y-1.5 text-sm xl:text-[15px] leading-relaxed text-foreground/85`,children:e.bullets.map((e,t)=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`span`,{className:`text-primary font-bold`,children:`›`}),(0,q.jsx)(`span`,{children:e})]},t))}),e.foot&&(0,q.jsx)(`div`,{className:`mt-4 xl:mt-6 border-t border-border pt-3 xl:pt-4 font-mono text-[10px] xl:text-[11px] tracking-[0.06em] text-muted-foreground`,children:e.foot}),e.extra&&(0,q.jsx)(`div`,{className:`mt-3`,children:e.extra}),e.commands&&e.commands.length>0&&t&&(0,q.jsx)(`div`,{className:`mt-4 xl:mt-6 flex flex-wrap items-center gap-2`,"data-testid":`tour-caption-commands-${e.id}`,children:e.commands.map(n=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,n.key),className:`inline-flex items-center rounded-full border border-border px-3.5 py-1.5 text-[13px] font-medium text-foreground transition-colors hover:border-primary/40 hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,"data-testid":`tour-caption-command-${e.id}-${n.key}`,children:n.label},n.key))}),e.actions&&e.actions.length>0&&(0,q.jsx)(`div`,{className:`mt-4 xl:mt-6 flex flex-wrap items-center gap-3`,children:e.actions.map((e,t)=>{let n=t===0;return(0,q.jsx)(M,{to:e.href,onClick:()=>QR.record(e.event,e.data),"data-testid":e.testId,className:n?`inline-flex items-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90`:`text-sm text-primary underline-offset-2 hover:underline`,children:e.label},e.label)})})]})}function pCe({visible:e,children:t}){return(0,q.jsx)(`div`,{className:`absolute inset-0 transition-opacity duration-500`,style:{opacity:+!!e,pointerEvents:e?`auto`:`none`},"aria-hidden":!e,inert:!e,children:t})}var mCe=(0,K.forwardRef)(function({id:e,heightVh:t,header:n,stages:r,captions:i,onActiveStageChange:a,onViewportChange:o,onReachedChange:s,onCommand:c,editor:l},u){let d=(0,K.useRef)(null),f=(0,K.useRef)(null),[p,m]=(0,K.useState)(null),h=(0,K.useCallback)(e=>{f.current=e,m(e)},[]),{slice:g,subscribe:_,resync:v,runwayReached:y}=Z4(d,!1,r,e),b=gCe(d);(0,K.useEffect)(()=>{o?.(b)},[b,o]),(0,K.useEffect)(()=>{s?.(y)},[y,s]);let[x,S]=(0,K.useState)(!1),C=hCe(d);(0,K.useEffect)(()=>{(C||y)&&S(!0)},[C,y]);let w=g.stage?.screen??`editor`,T=(0,K.useRef)(null);return(0,K.useEffect)(()=>{x&&T.current!==g.stage?.id&&(T.current=g.stage?.id??null,g.stage?.id&&a?.(g.stage.id))},[g.stage?.id,a,x]),(0,K.useImperativeHandle)(u,()=>({scrollToStage:e=>{let t=d.current,n=r.find(t=>t.id===e);!t||!n||zhe(t,Math.min(n.range[0]+.02,n.range[1]-.005))},subscribe:_,resync:v}),[r,_,v]),(0,q.jsxs)(`section`,{id:`tour-section-${e}`,"data-testid":`tour-section-${e}`,children:[n,(0,q.jsx)(X4,{trackRef:d,height:t,stages:r,activeIndex:g.index,segmentId:e,testId:`tour-runway`,pane:(0,q.jsx)(`div`,{ref:h,className:`absolute inset-0 flex flex-col justify-center`,children:(0,q.jsxs)(b6,{children:[(0,q.jsx)(X_e,{ringKey:`editor.window`,el:p}),(0,q.jsx)(i2,{title:Tge[w],className:`relative h-full max-h-[760px]`,children:(0,q.jsx)(Y4,{gateId:`${e}-pane`,segmentId:e,className:`relative h-full`,children:l&&(0,q.jsx)(pCe,{visible:w===`editor`,children:(0,q.jsx)(N6,{doc:l.doc,onDocChange:l.onDocChange,onBlocksChange:l.onBlocksChange,onRun:l.onRun,theme:l.theme,withRingTargets:!0})})})}),(0,q.jsx)(Z_e,{target:g.ring?.key?{key:g.ring.key}:null,accent:g.stage.accent??T3.editor,canvasRef:f})]})}),captions:(0,q.jsx)(dCe,{activeIndex:g.index,captions:i,onCommand:c})})]})});function hCe(e){let[t,n]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>{e.isIntersecting&&(n(!0),r.disconnect())},{threshold:.05});return r.observe(t),()=>r.disconnect()},[e]),t}function gCe(e){let[t,n]=(0,K.useState)(()=>typeof IntersectionObserver>`u`);return(0,K.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>n(e.isIntersecting),{threshold:.05});return r.observe(t),()=>r.disconnect()},[e]),t}var _Ce={basics:`wods/examples/syntax/single-movement.md`,protocols:`wods/examples/syntax/timers-rest.md`,structure:`wods/examples/syntax/groups-1.md`,"custom-metrics":`wods/syntax/custom-metrics-1.md`,dialects:`wods/examples/syntax/dialect-climb-bouldering.md`,complex:`wods/examples/syntax/complex-swimming.md`},y9={basics:{summary:`Statements and metrics — how a workout line reads, from movement names to reps, loads, and timed rests.`,bullets:["Freeform Markdown + fenced ```time blocks",`Single movements: 10 Pushups, 15 Air Squats`,`Inline resistance: 225lb, 100kg, 24kg`]},protocols:{summary:`Time-capped and paced protocols: AMRAP, EMOM, Tabata intervals, and required rest that paces the room.`,bullets:[`20:00 AMRAP (As Many Rounds As Possible)`,`(10) :60 EMOM (Every Minute on the Minute)`,`*:30 Rest (required, unskippable recovery)`]},structure:{summary:`Rounds, rep ladders, and nested grouping — how blocks compose into multi-part workout schemes.`,bullets:[`(3 Rounds) and (5 Sets) block repetition`,`Ladders & schemes: 21-15-9, 10-8-6-4-2`,`Section labels: (Warmup) and // Strength`]},"custom-metrics":{summary:`Capture typed data points right inline: effort intensity, heart rate, RPE, and custom JSON metrics.`,bullets:[`Inline JSON metrics: {"intensity": 80}`,`Capture prompts: :? time, ? reps, ?lb load`,`Session-level RPE & custom dimensions`]},dialects:{summary:`Dialect fences for specialized domains: workout, log, plan, and climbing session notes.`,bullets:["```time for workouts, ```log for recorded efforts","Sport dialect suffixes like ```log:climbing",`Discipline tags and session intent`]},complex:{summary:`Multi-set training sessions that chain intervals, strength, and conditioning into one complete program.`,bullets:[`Multi-set swimming and track intervals`,`Strength blocks paired with conditioned finishers`,`Full training session flow`]}},vCe=[{id:`basics`,title:`Basics`,badge:`trophy`,questIds:[],sectionIds:[]},{id:`protocols`,title:`Protocols`,badge:`timer`,questIds:[],sectionIds:[]},{id:`structure`,title:`Structure`,badge:`dumbbell`,questIds:[],sectionIds:[]},{id:`custom-metrics`,title:`Custom Metrics`,badge:`trophy`,questIds:[],sectionIds:[]},{id:`dialects`,title:`Dialects`,badge:`trophy`,questIds:[],sectionIds:[]},{id:`complex`,title:`Complex Workouts`,badge:`dumbbell`,questIds:[],sectionIds:[]}];function yCe({chapters:e=[],allQuests:t=[],theme:n,wodFiles:r={},onRun:i}){let a=(0,K.useMemo)(()=>{let t=(e??[]).filter(e=>e.id!==`home-tour`);return t.length>0?t:vCe},[e]),o=n2(`(prefers-reduced-motion: reduce)`),{markComplete:s}=$0(`/`,t),{chapters:c}=v9(a),[l,u]=(0,K.useState)(()=>a[0]?.id??`basics`),[d,f]=(0,K.useState)(``),p=(0,K.useRef)([]),m=(0,K.useRef)(l);m.current=l;let h=(0,K.useMemo)(()=>Object.fromEntries(a.map(e=>[e.id,rY(_Ce[e.id]??``,r)])),[a,r]);(0,K.useEffect)(()=>{p.current=[],f(h[l]??``)},[l,h]);let g=(0,K.useCallback)(e=>{p.current=e},[]),_=(0,K.useCallback)(()=>{let e=m.current;s(`${e}-run`),i?.(e,p.current[0]??null,d)},[d,s,i]),v=(0,K.useMemo)(()=>a.map((e,t)=>{let n=Math.max(1,a.length);return{id:e.id,range:[t/n,(t+1)/n],screen:`editor`,accent:`hsl(var(--primary))`,label:e.title,source:h[e.id]}}),[a,h]),y=(0,K.useMemo)(()=>Object.fromEntries(c.map(e=>[e.chapter.id,e])),[c]),b=(0,K.useMemo)(()=>a.map((e,t)=>{let n=y9[e.id],r=y[e.id];return{id:e.id,num:`05${String.fromCharCode(97+t)}`,title:e.title,body:n?.summary??e.title,bullets:n?.bullets,accent:`hsl(var(--primary))`,extra:r&&(0,q.jsx)(`span`,{"data-testid":`chapter-picker-progress-${e.id}`,className:$(`font-mono text-[11px] font-semibold tabular-nums`,r.isComplete?`font-bold text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`),children:r.isComplete?`done ✓`:`${r.completedCount}/${r.totalCount}`}),actions:[{label:`Read guide →`,href:E3[e.id]??`/page/guide-start`,event:$R.chapterGuideClicked,data:{chapter:e.id},testId:`chapter-picker-guide-${e.id}`}]}}),[a,y]);return(0,q.jsxs)(`section`,{id:`tour-chapter-picker`,"data-testid":`tour-chapter-picker`,className:`flex flex-col`,children:[(0,q.jsx)(C3,{index:`05`,before:`Learning with `,accentText:`Examples`,after:``,accent:`hsl(var(--primary))`,blurb:`Six chapters on the syntax, each with a runnable example and quests to earn. Scroll into each section to load its example code into the editor.`}),o?(0,q.jsx)(bCe,{chapters:a,selectedId:l,onSelect:u,doc:d,onDocChange:f,theme:n,onBlocksChange:g,onRun:_,progressByChapter:y}):(0,q.jsx)(mCe,{id:`learn`,heightVh:`600vh`,stages:v,captions:b,onActiveStageChange:u,editor:{doc:d,theme:n,onDocChange:f,onBlocksChange:g,onRun:_}})]})}function bCe({chapters:e,selectedId:t,onSelect:n,doc:r,onDocChange:i,theme:a,onBlocksChange:o,onRun:s,progressByChapter:c}){return(0,q.jsx)(`div`,{className:`relative mx-auto w-full max-w-[1500px] 2xl:max-w-[1720px] px-6 py-8 lg:px-12 xl:px-16`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-10 lg:flex-row lg:items-start lg:gap-12 xl:gap-16`,children:[(0,q.jsx)(`div`,{className:`w-full lg:w-[58%] xl:w-[60%] lg:sticky lg:top-[110px] z-10 flex-none`,children:(0,q.jsx)(`div`,{className:`h-[420px] sm:h-[480px] lg:h-[calc(100dvh-150px)] max-h-[700px] w-full rounded-2xl border border-border shadow-2xl overflow-hidden bg-background`,children:(0,q.jsx)(i2,{title:E3[t]?.split(`/`).pop()??`example.md`,subtitle:`Lesson: ${e.find(e=>e.id===t)?.title??t}`,className:`h-full`,children:(0,q.jsx)(N6,{doc:r,onDocChange:i,onBlocksChange:o,onRun:s,theme:a,withRingTargets:!1})})})}),(0,q.jsx)(`div`,{className:`w-full lg:w-[42%] xl:w-[40%] flex flex-col gap-16 lg:py-6`,"data-testid":`chapter-picker-list`,children:e.map((e,r)=>{let i=c[e.id],a=y3(e.badge),o=e.id===t,s=y9[e.id];return(0,q.jsxs)(`div`,{"data-testid":`chapter-picker-row-${e.id}`,className:$(`rounded-2xl border p-6 sm:p-8 transition-all duration-300 min-h-[340px] flex flex-col justify-between`,o?`border-primary bg-primary/5 ring-1 ring-primary/30 shadow-lg dark:bg-primary/10`:`border-border/70 bg-card hover:border-primary/40`),children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`font-mono text-xs font-bold uppercase tracking-wider text-primary`,children:[`Chapter 0`,r+1]}),a&&(0,q.jsx)(a,{className:`size-4 text-primary`})]}),(0,q.jsx)(`span`,{className:$(`font-mono text-xs font-semibold tabular-nums`,i?.isComplete?`text-emerald-600 dark:text-emerald-400 font-bold`:`text-muted-foreground`),children:i?.isComplete?`done ✓`:`${i?.completedCount??0}/${i?.totalCount??e.questIds.length}`})]}),(0,q.jsx)(`h3`,{className:`mt-3 text-2xl font-bold tracking-tight text-foreground sm:text-3xl`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-3 text-sm sm:text-base leading-relaxed text-muted-foreground`,children:s?.summary??e.title}),s?.bullets&&(0,q.jsx)(`ul`,{className:`mt-4 space-y-1.5 text-xs sm:text-sm text-foreground/80 font-mono`,children:s.bullets.map((e,t)=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`span`,{className:`text-primary font-bold`,children:`›`}),(0,q.jsx)(`span`,{children:e})]},t))})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-3 pt-4 border-t border-border/50`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"data-testid":`chapter-picker-select-${e.id}`,"aria-pressed":o,className:$(`inline-flex items-center gap-2 rounded-lg px-4 py-2 text-xs sm:text-sm font-semibold transition-colors shadow-xs`,o?`bg-primary text-primary-foreground hover:bg-primary/90`:`border border-border bg-background text-foreground hover:bg-muted`),children:[(0,q.jsx)(Sr,{className:`size-3.5 fill-current`}),(0,q.jsx)(`span`,{children:o?`Loaded in editor`:`Load example`})]}),(0,q.jsxs)(M,{to:E3[e.id]??`/page/guide-start`,"data-testid":`chapter-picker-guide-${e.id}`,"aria-label":`Read guide for ${e.title}`,onClick:()=>QR.record($R.chapterGuideClicked,{chapter:e.id}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-background/80 px-3.5 py-2 text-xs sm:text-sm font-medium text-muted-foreground transition-colors hover:border-primary/50 hover:bg-background hover:text-primary`,children:[(0,q.jsx)(fe,{className:`size-3.5`}),(0,q.jsx)(`span`,{children:`Read guide →`})]})]})]},e.id)})})]})})}function xCe({chapters:e}){let t=()=>QR.record($R.lessonStarted),n=()=>QR.record($R.cheatsheetOpened),{chapters:r}=v9(e),i=r.filter(e=>e.chapter.id!==`home-tour`);return(0,q.jsxs)(`section`,{"data-testid":`tour-learn`,className:`mx-auto max-w-5xl px-6 py-16 border-b border-border/60`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-end lg:justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-bold tracking-tight`,children:`Learn the Language`}),(0,q.jsx)(`p`,{className:`mt-2 text-muted-foreground leading-relaxed max-w-xl`,children:`Six chapters, each with a runnable example and quests to earn — progress shows on the chapter cards above.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,q.jsx)(M,{to:`/page/guide-start`,onClick:t,className:`inline-flex items-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90`,children:`Start Lesson 1`}),(0,q.jsx)(M,{to:`/page/guide-start?h=reference`,onClick:n,className:`text-sm font-semibold text-primary underline-offset-2 hover:underline`,children:`Cheat sheet →`})]})]}),(0,q.jsx)(`div`,{className:`mt-8 flex flex-wrap items-center gap-2`,children:i.map(({chapter:e,completedCount:t,totalCount:n,isComplete:r})=>{let i=E3[e.id]??`/page/guide-start`,a=y3(e.badge);return(0,q.jsxs)(M,{to:i,"data-testid":`learn-progress-chip-${e.id}`,className:$(`group inline-flex items-center gap-2 rounded-full border px-3 py-1.5 transition-colors hover:border-primary/40`,r?`border-emerald-500/30 bg-emerald-500/5`:`border-border bg-card`),children:[a&&(0,q.jsx)(a,{className:`size-3.5 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`span`,{className:$(`font-mono text-[10px] font-bold tabular-nums`,r?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`),children:r?`done ✓`:`${t}/${n}`})]},e.id)})})]})}var SCe=xCe;function CCe(){let e=$P(),t=(0,K.useMemo)(()=>g6(e??{}),[e]),{theme:n}=Co(),[r,i]=(0,K.useState)(()=>typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches);(0,K.useEffect)(()=>{if(n!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[n]);let a=(0,K.useMemo)(()=>n===`system`?r?`vs-dark`:`vs`:n===`dark`?`vs-dark`:`vs`,[n,r]),o=Tq(),s=h6.chapters,c=h6.quests,l=(0,K.useMemo)(()=>{let e={};for(let t of h6.quests)e[t.id]=t.label;for(let{page:t}of o)for(let n of t.quests)e[n.id]=n.label;return e},[o]),u=ez()?.track,{run:d,start:f,finalize:p,end:m}=q0(),[h,g]=(0,K.useState)(null),[_,v]=(0,K.useState)(0),[y,b]=(0,K.useState)(!1),x=(0,K.useCallback)(()=>{g(null),b(!1)},[]),S=(0,K.useCallback)(async(e,t,n)=>{if(t){u?.($R.chapterExampleRun,{chapter:e});try{let r=await f(n,t,{pageTitle:`Syntax`,sectionTitle:`Chapter ${e}`});g(r.block),v(e=>e+1),b(!0)}catch(e){console.error(`[SyntaxView] failed to persist playground run note:`,e),x(),pQ({title:`Could not start workout`,variant:`destructive`})}}},[x,f,u]),C=(0,K.useCallback)(async(e,t)=>{try{(t.logs??[]).length===0?(await m(),x()):await p(t,t.completed)}catch(e){throw console.error(`[SyntaxView] failed to save session:`,e),pQ({title:`Session not saved`,variant:`destructive`}),e}},[x,m,p]);return(0,q.jsx)(b6,{children:(0,q.jsxs)(`div`,{"data-testid":`syntax-view`,children:[(0,q.jsx)(C3,{index:`S`,before:`Syntax `,accentText:`Learning with Examples`,after:``,accent:`hsl(var(--primary))`,blurb:`Six chapters on the syntax, each with a runnable example. Press run to start a timed workout from any chapter.`}),(0,q.jsx)(yCe,{wodFiles:t,chapters:s,allQuests:c,theme:a,onRun:S}),(0,q.jsx)(SCe,{quests:c,chapters:s,questLabels:l}),(0,q.jsx)(O3,{}),(0,q.jsx)(T6,{}),h&&y&&d&&(0,q.jsx)(B2,{block:d.block,resultId:d.resultId,autoStart:!0,onClose:x,onCompleteWorkout:C},_)]})})}function wCe(){let e=dt();return(0,q.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Not found navigation`,className:`flex items-center gap-5 px-6 py-3 border-b bg-background`,children:[(0,q.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:`WOD Wiki`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`notfound-nav-home`,onClick:()=>e(`/`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Home`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`notfound-nav-journal`,onClick:()=>e(`/journal`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Journal`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`notfound-nav-notebooks`,onClick:()=>e(`/notebooks`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Notebooks`})]}),(0,q.jsxs)(`main`,{"data-agent-status":`ready`,"aria-busy":!1,className:`flex-1 flex flex-col items-center justify-center gap-6 p-8 text-center`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-muted`,children:(0,q.jsx)(Li,{className:`w-8 h-8 text-muted-foreground`})}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Page not found`}),(0,q.jsx)(`p`,{className:`text-muted-foreground max-w-sm`,children:`The page you are looking for does not exist or has been moved.`})]}),(0,q.jsxs)(`button`,{type:`button`,"data-testid":`notfound-go-home`,onClick:()=>e(`/`),className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 transition-colors`,children:[(0,q.jsx)(_a,{className:`w-4 h-4`}),`Go home`]})]})]})}function TCe(){return(0,q.jsx)(at,{to:`/sessions?q=%3Asegment%7B%7D%20last%208w`,replace:!0})}function ECe(){let{runtimeId:e}=te();return(0,q.jsx)(at,{to:CH(e),replace:!0})}function b9(){let{runtimeId:e,noteId:t,resultId:n}=te(),r=n??e;return r?(0,q.jsx)(at,{to:EH(r),replace:!0}):t?(0,q.jsx)(at,{to:`/sessions?q=${encodeURIComponent(`:session{note:${t}}`)}`,replace:!0}):(0,q.jsx)(at,{to:`/sessions`,replace:!0})}function DCe(){let e=Qe().search,t=e&&e.startsWith(`?`)?`${e}&mode=plan`:`?mode=plan`;return(0,q.jsx)(at,{to:`/journal${t}`,replace:!0})}var x9=null;async function OCe(e,t,n){(!x9||x9.attempt!==e)&&(x9={attempt:e,promise:t(M$.content)});try{let t=await x9.promise;return!n()&&x9?.attempt===e&&(x9=null),t}catch(t){throw x9?.attempt===e&&(x9=null),t}}var kCe=()=>D$(M$.content);function ACe({createPage:e=kCe}={}){let t=dt(),n=(0,K.useRef)(t);(0,K.useLayoutEffect)(()=>{n.current=t},[t]);let[r,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await OCe(a,e,()=>t);t||n.current(hH(r),{replace:!0})}catch{t||i(!0)}})(),()=>{t=!0}},[a,e]),r?(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-3 text-zinc-300 px-4 text-center`,children:[(0,q.jsx)(`p`,{role:`alert`,children:`Unable to create a new playground note.`}),(0,q.jsx)(`button`,{type:`button`,className:`rounded border border-zinc-600 px-3 py-1 text-sm hover:bg-zinc-800`,onClick:()=>{i(!1),o(e=>e+1)},children:`Try again`})]}):(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`})}function jCe(e){if(!e)return null;let t=e.trim();if(!t)return null;let n=yI(t);if(n&&n.id!==`core`)return n;let r=oI(t);return r?CI().find(e=>oI(e.url)===r)??null:null}function MCe(){let e=Qe(),t=dt(),n=(0,K.useMemo)(()=>new URLSearchParams(e.search),[e.search]),r=n.get(`source`)??n.get(`feed`),[i,a]=(0,K.useState)(()=>r??``),[o,s]=(0,K.useState)(()=>r),[c,l]=(0,K.useState)(null);(0,K.useEffect)(()=>{a(r??``),s(r)},[r]);let u=(0,K.useMemo)(()=>jCe(o),[o]),d=(0,K.useSyncExternalStore)(qI,()=>CI().map(e=>`${e.id}:${HI(e.id)?`1`:`0`}`).join(`,`)),f=(0,K.useMemo)(()=>CI().filter(e=>!HI(e.id)),[d]),p=(0,K.useCallback)(async e=>{if(c===null){l(e.id);try{if(await sV(e.id,{offlinePolicy:`index-only`})===`error`){pQ({title:`${e.label} sync failed`,description:`Check your connection and try again.`,variant:`destructive`});return}t(`${Z.notebooks}?q=:notebook{feed:${e.id}}`)}finally{l(null)}}},[c,t]);return(0,q.jsxs)(`div`,{className:`min-h-svh flex flex-col bg-background text-foreground overflow-x-hidden`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Subscribe navigation`,className:`flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3 sm:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,q.jsx)(or,{className:`size-4 text-primary`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`WOD Wiki Feeds`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 text-xs`,children:[(0,q.jsx)(M,{to:Z.feeds,className:`no-underline hover:underline text-muted-foreground hover:text-foreground transition-colors`,children:`Browse Feeds`}),(0,q.jsx)(M,{to:Z.notebooks,className:`no-underline hover:underline text-muted-foreground hover:text-foreground transition-colors`,children:`Notebooks`}),(0,q.jsx)(M,{to:Z.settingsSync,className:`no-underline hover:underline text-muted-foreground hover:text-foreground transition-colors`,children:`Sync Settings`})]})]}),(0,q.jsxs)(`main`,{"data-agent-status":c?`loading`:`ready`,"aria-busy":c!==null,"data-testid":Q.FEED_SUBSCRIPTION_INTAKE,className:`w-full max-w-2xl min-w-0 mx-auto flex-1 px-4 py-8 sm:px-6 space-y-6`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-bold tracking-tight`,children:`Subscribe to a Feed`}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:`Inspect any workout catalog URL before subscribing. Choose which notebooks to include and keep workouts lightweight until you open them.`})]}),(0,q.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 sm:p-5 space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Inspect a Feed URL`}),(0,q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=i.trim();t&&s(t)},className:`flex flex-col sm:flex-row gap-2`,children:[(0,q.jsx)(Fo,{type:`url`,value:i,onValueChange:a,placeholder:`https://example.com/seed/`,"aria-label":`Feed directory URL`,className:`w-full sm:w-auto sm:flex-1 min-w-0 h-10 text-sm`}),(0,q.jsx)(J,{type:`submit`,className:`h-10 shrink-0`,disabled:!i.trim()||c!==null,children:`Inspect Feed`})]})]}),o&&u?(0,q.jsx)(U3,{registeredFeed:u,testId:Q.REGISTERED_FEED_INTAKE_CARD,subscribeButtonTestId:Q.REGISTERED_FEED_SUBSCRIBE_BTN,previewHref:SH(u.id),cancelLabel:`Decline`,onCancel:()=>t(Z.feeds),onSubscribed:e=>t(`${Z.notebooks}?q=:notebook{feed:${e}}`)}):o?(0,q.jsx)(W3,{feedParam:o,showUrlInputWhenInvalid:!1,onDismiss:()=>t(Z.notebooks),onSubscribed:e=>t(`${Z.notebooks}?q=:notebook{feed:${e}}`)}):null,!o&&f.length>0&&(0,q.jsxs)(`section`,{className:`space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Available Community Feeds`}),(0,q.jsx)(`div`,{className:`divide-y divide-border rounded-xl border border-border bg-card`,children:f.map(e=>(0,q.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-4`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(M,{to:SH(e.id),className:`no-underline hover:underline text-sm font-semibold text-foreground`,children:e.label})}),e.description&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,children:e.description})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 shrink-0`,children:[(0,q.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:c!==null,onClick:()=>{a(e.url),s(e.id)},children:`Inspect`}),(0,q.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`subscribe-catalog-${e.id}`,disabled:c!==null,onClick:()=>void p(e),children:c===e.id?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ot,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Subscribing…`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(yr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Subscribe`})]})})]})]},e.id))})]})]})]})}async function NCe(e,t,n){let r=await X.getNote(e);if(!r||r.feedOrigin===`feed`||r.retention===`schedule-pinned`||r.retention===`session-pinned`||Array.isArray(r.notebookIds)&&r.notebookIds.length>0&&r.type!==`journal`&&r.type!==`playground`)return;let i=iP(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${aP(n)}${r.rawContent.slice(a.to)}`;await new ER().updateRecord(r.id,{rawContent:o,expectedSourceRevision:r.sourceRevision})}function PCe(e){if(!e)return{pending:void 0,adoptedRuntime:null};let t=Ez.get(e);if(t)return{pending:t,adoptedRuntime:null};let n=Az(e);return n?{pending:{block:n.block,noteId:n.noteId,captured:n.captured,origin:n.origin,returnTo:n.returnTo,scheduleItemId:n.scheduleItemId,sessionDate:n.sessionDate},adoptedRuntime:n.runtime}:{pending:void 0,adoptedRuntime:null}}function FCe(){let{runtimeId:e}=te();return(0,q.jsx)(ICe,{runtimeId:e},e??`missing`)}function ICe({runtimeId:e}){let[t]=be(),n=dt(),[r]=(0,K.useState)(()=>PCe(e)),i=(0,K.useRef)(r.pending),a=t.get(`note`),o=t.get(`block`),[s,c]=(0,K.useState)(()=>!r.pending&&!!a),[l,u]=(0,K.useState)(void 0),d=(0,K.useRef)(r.pending?.captured??null),f=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(i.current||!a||!e){c(!1);return}let t=!1;return c(!0),X.getNote(a).then(e=>{if(t)return;if(!e){c(!1);return}let n=Object.values(e.blocks??{}).filter(e=>e.kind===`wod`),r=o?n.find(e=>e.id===o):n[0];if(!r){c(!1);return}let a=e.rawContent.slice(r.from,r.to),s=Gs(a,{registeredWidgets:Us})[0],l=s?.scriptBlock?.content??a,d=Gu().read(l,r.sport).statements??[],f={block:{id:r.id,contentId:s?.scriptBlock?.contentId,dialect:r.dialect??`time`,sport:r.sport,startLine:0,endLine:Math.max(0,a.split(/\r?\n/).length-1),content:l,statements:d,state:`idle`,version:r.version,createdAt:e.createdAt,widgetIds:{}},noteId:e.id};i.current=f,u(f),c(!1)}).catch(()=>{t||c(!1)}),()=>{t=!0}},[a,o,e]);let p=(0,K.useCallback)(async()=>{let t=i.current;if(!t||!e)throw Error(`The pending workout is unavailable.`);return t.captured?(d.current=t.captured,t.captured.block):(d.current||=t.snapshot?await Jz(t.snapshot,t.block,e,t.origin,void 0,{deferPersist:!0,...t.scheduleItemId?{scheduleItemId:t.scheduleItemId}:{},...t.sessionDate?{sessionDate:t.sessionDate}:{}}):await Yz(t.noteId,t.block,e,t.origin,{deferPersist:!0,...t.scheduleItemId?{scheduleItemId:t.scheduleItemId}:{},...t.sessionDate?{sessionDate:t.sessionDate}:{}}),d.current.block)},[e]);(0,K.useEffect)(()=>{e&&Ez.delete(e)},[e]);let m=r.pending??l,h=(0,K.useRef)(!1),g=(0,K.useCallback)((t,n)=>!n||!e||!m?Promise.reject(Error(`Run cannot be saved — its session data or runtime id is missing.`)):(h.current=n.completed,yR.record({runBlock:m.block,blockId:m.block.id,noteId:m.noteId,resultId:e,data:n,createdAt:n.endTime||Date.now(),...m.origin?{origin:m.origin}:{},...m.scheduleItemId?{scheduleItemId:m.scheduleItemId}:{},...m.sessionDate?{sessionDate:m.sessionDate}:{}}).then(async()=>{if(gU(),f.current=!0,Mz(e),n.completed)try{await NCe(m.noteId,m.block.id,e)}catch{}})),[e,m]),_=(0,K.useCallback)(()=>{if(f.current=!0,e&&Mz(e),!m){n(`/`);return}if(h.current&&e){n(EH(e),{replace:!0});return}if(m.returnTo){n(m.returnTo,{replace:!0});return}n(IW(FW(m.noteId)),{replace:!0})},[e,m,n]),v=(0,K.useCallback)(t=>{let n=i.current;if(!e||!n||f.current){t.dispose();return}Oz({runtimeId:e,block:n.block,noteId:n.noteId,captured:d.current??n.captured,origin:n.origin,returnTo:n.returnTo,scheduleItemId:n.scheduleItemId,sessionDate:n.sessionDate,runtime:t})},[e]),y=(0,K.useCallback)(t=>{if(!e)return;let n=kz(e);n&&n.runtime!==t&&n.runtime.dispose()},[e]);if(s)return(0,q.jsx)(`main`,{"data-agent-status":`loading`,"aria-busy":!0,role:`status`,className:`flex-1 flex items-center justify-center text-muted-foreground`,children:`Preparing workout timer…`});if(!m)return(0,q.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Workout runner navigation`,className:`flex items-center gap-5 px-6 py-3 border-b bg-background`,children:[(0,q.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:`WOD Wiki`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`run-notfound-nav-home`,onClick:()=>n(`/`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Home`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`run-notfound-nav-journal`,onClick:()=>n(`/journal`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Journal`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`run-notfound-nav-notebooks`,onClick:()=>n(`/notebooks`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Notebooks`})]}),(0,q.jsxs)(`main`,{"data-agent-status":`ready`,"aria-busy":!1,className:`flex-1 flex flex-col items-center justify-center gap-6 p-8 text-center`,children:[(0,q.jsx)(G0,{}),(0,q.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-muted`,children:(0,q.jsx)(Li,{className:`w-8 h-8 text-muted-foreground`})}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Workout session not found`}),(0,q.jsx)(`p`,{className:`text-muted-foreground max-w-sm`,children:`Runtime not found. Please start the workout from the editor.`})]}),(0,q.jsxs)(`button`,{type:`button`,"data-testid":`run-notfound-go-home`,onClick:()=>n(`/`),className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 transition-colors`,children:[(0,q.jsx)(_a,{className:`w-4 h-4`}),`Go home`]})]})]});let b=m.captured?.note.rawContent??m.snapshot?.rawContent,x=m.scheduleItemId?`Scheduled${m.sessionDate?` · ${m.sessionDate}`:``}`:m.sessionDate?`Logged for ${m.sessionDate}`:`Ad-hoc · Today`;return(0,q.jsxs)(`main`,{"data-agent-status":`ready`,"aria-busy":!1,className:`contents`,children:[(0,q.jsx)(`div`,{"data-testid":Q.RUNNER_CONTEXT_PILL,className:`pointer-events-none fixed left-1/2 top-2.5 z-50 -translate-x-1/2 rounded-full border border-border/70 bg-background/90 px-3 py-1 text-[11px] font-semibold text-foreground shadow-sm backdrop-blur-sm`,children:x}),(0,q.jsx)(B2,{block:m.block,noteContent:b,prepareRun:p,onClose:_,onCompleteWorkout:g,resultId:e,noteId:m.noteId,autoStart:!0,adoptRuntime:r.adoptedRuntime,parkOnUnmount:!0,onPark:v,onRuntimeReady:y})]})}var LCe=new ER;function RCe(){let e=dt(),[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(null),a=(0,K.useRef)(null),o=async r=>{if(!(!r||t)){n(!0),i(null);try{let t=await dL(r,LCe);if(t.imported+(t.sessionsImported??0)===0){i(t.errors.length>0?t.errors.slice(0,2).join(`; `):`No portable notes or sessions were found in that bundle.`);return}pQ({title:`Imported ${t.imported} note(s), ${t.sessionsImported??0} session(s)`,description:t.errors.length>0?t.errors.slice(0,2).join(`; `):`Import complete.`}),e(Z.home)}catch(e){i(e instanceof Error?e.message:`That file is not a valid portable bundle (.zip).`)}finally{n(!1)}}};return(0,q.jsxs)(`main`,{"data-agent-status":`ready`,"aria-busy":t,"data-testid":`load-zip-intake`,className:`w-full max-w-xl min-w-0 mx-auto px-4 py-10 sm:px-6 flex flex-col gap-4 overflow-x-hidden`,children:[(0,q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Import Workout Bundle`}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`A portable bundle is the `,(0,q.jsx)(`code`,{className:`font-mono`,children:`.zip`}),` (or`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`.md`}),` / `,(0,q.jsx)(`code`,{className:`font-mono`,children:`.jsonl`}),` /`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`.csv`}),`) export from Settings → Data, or a`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`wod export`}),` archive. Importing never runs the workout.`]}),(0,q.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border bg-card p-5 flex flex-col items-center gap-3 text-center`,children:[(0,q.jsx)(_n,{className:`size-6 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`input`,{ref:a,type:`file`,accept:`.zip,.md,.markdown,.jsonl,.csv`,"data-testid":`bundle-file-input`,className:`text-xs text-muted-foreground file:mr-3 file:rounded-md file:border-0 file:bg-primary file:px-3 file:py-1.5 file:text-xs file:font-semibold file:text-primary-foreground hover:file:opacity-90 max-w-full`,"aria-label":`Portable bundle file`,disabled:t,onChange:e=>{o(e.target.files?.[0]),e.target.value=``}}),r&&(0,q.jsxs)(`div`,{role:`alert`,"data-testid":`bundle-import-error`,className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,q.jsx)(Yi,{className:`size-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:r})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e(RH(`data`)),children:`Storage settings`}),(0,q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>e(`/`),children:`Back to Home`})]})]})}function zCe(){let[e]=V(`zip`),[t]=V(`z`),n=Qe(),[r]=(0,K.useState)(()=>{let e=new URLSearchParams(n.search||window.location.search);return!!(e.get(`zip`)||e.get(`z`))}),i=new URLSearchParams(n.search);return e||t||i.get(`zip`)||i.get(`z`)||r?(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}):(0,q.jsx)(`div`,{className:`flex-1 flex items-start justify-center`,children:(0,q.jsx)(RCe,{})})}async function S9(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 C9(e={}){let{decodeZip:t=S9,getTodayDateKey:n=uU,isDateInPast:r=dU,journalNotes:i=CU,toast:a=pQ}=e,o=dt(),s=Qe(),{date:c}=te(),[l]=V(`zip`),[u,d]=(0,K.useState)({state:`loading`});return(0,K.useEffect)(()=>{if(!(s.pathname===`/load/journal`||s.pathname.startsWith(`/load/journal/`)))return;if(!l){d({state:`missing-zip`});return}let e=!1,u=async()=>{try{d({state:`loading`});let i;try{i=await t(l)}catch(e){console.error(`Failed to decode zip:`,e),d({state:`error`,error:`Failed to decode the journal entry`,onRetry:()=>{u()}}),a({title:`Error`,description:`Failed to decode the journal entry. Please check the link.`,variant:`destructive`});return}if(e)return;let s;if(c){let e=fU(c);if(!e){d({state:`error`,error:`Invalid date format`}),a({title:`Error`,description:`Invalid date format. Expected YYYY-MM-DD.`,variant:`destructive`}),o(Z.journal,{replace:!0});return}s=e.dateKey}else s=n();if(e)return;if(r(s)){d({state:`pending-confirmation`,content:i,dateKey:s,onConfirmBackdate:async()=>{e||await f(i,s)}});return}await f(i,s)}catch(t){console.error(`Unexpected error in journal zip processor:`,t),e||(d({state:`error`,error:`An unexpected error occurred`,onRetry:()=>{u()}}),a({title:`Error`,description:`An unexpected error occurred.`,variant:`destructive`}))}},f=async(t,n)=>{if(!e)try{d({state:`creating`});let r=await i.create({journalDate:n,title:n,rawContent:t});e||(o(vH(r.id),{replace:!0}),d({state:`success`,content:t,dateKey:n}))}catch(r){console.error(`Failed to create journal entry:`,r),e||(d({state:`error`,error:`Failed to create journal entry`,onRetry:()=>{f(t,n)}}),a({title:`Error`,description:`Failed to create journal entry.`,variant:`destructive`}))}};return u(),()=>{e=!0}},[l,c,o,t,n,r,i,a]),u}var BCe=({selectedDate:e,onImportToday:t,onDateSelect:n,entryDates:r,isLoading:i=!1,className:a})=>{let[o,s]=(0,K.useState)(!1),[c,u]=(0,K.useState)(!1),d=async()=>{u(!0);try{await t()}finally{u(!1)}},f=async e=>{u(!0),s(!1);try{await n(e)}finally{u(!1)}},p=e?mT(e):`Date`,m=i||c;return(0,q.jsxs)(`div`,{className:$(`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,q.jsxs)(`button`,{type:`button`,title:`Import to today's journal`,onClick:()=>void d(),disabled:m,className:$(`flex items-center gap-2 px-3 py-2 transition-colors hover:bg-accent hover:text-accent-foreground`,m&&`opacity-60 cursor-not-allowed`),children:[c?(0,q.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}):(0,q.jsx)(kt,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Import Today`})]}),(0,q.jsx)(`div`,{className:`w-px bg-border/60 self-stretch`}),(0,q.jsxs)(nt,{open:o,onOpenChange:s,children:[(0,q.jsxs)(l,{disabled:m,"aria-label":`Plan for future date`,title:`Select a date to plan for the future`,className:$(`flex h-auto rounded-none border-0 bg-transparent items-center gap-1.5 px-2.5 py-2 transition-colors hover:bg-accent hover:text-accent-foreground`,e&&`text-primary`,m&&`opacity-60 cursor-not-allowed`),children:[(0,q.jsx)(Re,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),e&&(0,q.jsx)(`span`,{className:`leading-none text-xs`,children:p})]}),(0,q.jsx)(Lr,{align:`end`,sideOffset:6,"aria-label":`Plan date`,className:`p-0 w-auto`,children:(0,q.jsx)(a6,{selectedDate:e||null,onDateSelect:e=>void f(e),entryDates:r})})]})]})},VCe=({dateKey:e,onConfirm:t,onCancel:n,isLoading:r=!1})=>{let i=pT(new Date(`${e}T00:00:00`));return(0,q.jsxs)(Xr,{open:!0,onOpenChange:(e,t)=>{!e&&t.reason!==`action`&&!r&&n()},children:[(0,q.jsx)(xr,{}),(0,q.jsxs)(Mn,{className:`max-w-sm`,children:[(0,q.jsxs)(Io,{children:[(0,q.jsx)(la,{children:`Backdate Journal Entry`}),(0,q.jsxs)(Ki,{children:[`The date you selected (`,i,`) is in the past. This will create a journal entry for the selected date.`]})]}),(0,q.jsxs)(Lo,{children:[(0,q.jsx)(vr,{disabled:r,onClick:n,children:`Cancel`}),(0,q.jsx)(vr,{value:`confirm`,"data-variant":`solid`,disabled:r,action:()=>t(),children:r?`Importing…`:`Import`})]})]})]})},HCe=new ER,UCe={h1:({children:e})=>(0,q.jsx)(`h1`,{className:`text-3xl font-bold mt-8 mb-4 first:mt-0 text-foreground`,children:e}),h2:({children:e})=>(0,q.jsx)(`h2`,{className:`text-2xl font-bold mt-6 mb-3 text-foreground`,children:e}),h3:({children:e})=>(0,q.jsx)(`h3`,{className:`text-xl font-semibold mt-5 mb-2 text-foreground`,children:e}),h4:({children:e})=>(0,q.jsx)(`h4`,{className:`text-lg font-semibold mt-4 mb-2 text-foreground`,children:e}),h5:({children:e})=>(0,q.jsx)(`h5`,{className:`text-base font-semibold mt-3 mb-1 text-foreground`,children:e}),h6:({children:e})=>(0,q.jsx)(`h6`,{className:`text-sm font-semibold mt-2 mb-1 text-muted-foreground`,children:e}),p:({children:e})=>(0,q.jsx)(`p`,{className:`text-sm leading-relaxed mb-4 text-muted-foreground`,children:e}),strong:({children:e})=>(0,q.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,q.jsx)(`em`,{className:`italic text-muted-foreground`,children:e}),ul:({children:e})=>(0,q.jsx)(`ul`,{className:`list-disc list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),ol:({children:e})=>(0,q.jsx)(`ol`,{className:`list-decimal list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),li:({children:e})=>(0,q.jsx)(`li`,{className:`ml-2`,children:e}),code:({children:e,className:t})=>t?null:(0,q.jsx)(`code`,{className:`px-1.5 py-0.5 rounded bg-muted text-primary font-mono text-xs`,children:e}),pre:({children:e})=>(0,q.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,q.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,q.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline font-medium`,children:t}),table:({children:e})=>(0,q.jsx)(`div`,{className:`my-4 overflow-x-auto rounded border border-border`,children:(0,q.jsx)(`table`,{className:`w-full text-xs`,children:e})}),thead:({children:e})=>(0,q.jsx)(`thead`,{className:`bg-muted/50`,children:e}),tbody:({children:e})=>(0,q.jsx)(`tbody`,{className:`divide-y divide-border/50`,children:e}),tr:({children:e})=>(0,q.jsx)(`tr`,{className:`hover:bg-muted/20 transition-colors`,children:e}),th:({children:e})=>(0,q.jsx)(`th`,{className:`px-3 py-2 text-left font-semibold text-foreground text-xs`,children:e}),td:({children:e})=>(0,q.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e}),hr:()=>(0,q.jsx)(`hr`,{className:`my-6 border-border/50`})};function w9(){let e=dt(),t=C9(),[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(null),{state:o,content:s,dateKey:c,error:l,onConfirmBackdate:u,onRetry:d}=t;return(0,q.jsxs)(`main`,{"data-agent-status":o===`loading`?`loading`:`ready`,"aria-busy":o===`loading`,className:`flex flex-col flex-1 min-h-0 bg-background`,children:[(0,q.jsxs)(`div`,{className:`border-b border-border/50 bg-muted/30 px-6 py-4 flex items-center justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`button`,{type:`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,q.jsx)(je,{className:`h-5 w-5`})}),(0,q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Import Journal Entry`})]}),o===`loading`?(0,q.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}),`Preparing preview...`]}):o===`error`?(0,q.jsx)(J,{variant:`outline`,size:`sm`,onClick:d,children:`Retry`}):o===`pending-confirmation`||o===`creating`||o===`missing-zip`?null:(0,q.jsx)(BCe,{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:!1})]}),(0,q.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-6`,children:[o===`missing-zip`&&(0,q.jsx)(WCe,{}),o===`loading`&&(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,q.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading preview...`})]}),o===`error`&&(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,q.jsx)(`div`,{className:`bg-destructive/10 border border-destructive/50 rounded-lg p-4 max-w-md`,children:(0,q.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,q.jsx)(Yi,{className:`h-5 w-5 text-destructive mt-0.5 shrink-0`}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Error Loading Preview`}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:l||`Failed to decode the zip content`})]})]})}),(0,q.jsx)(J,{onClick:d,variant:`outline`,children:`Try Again`})]}),o===`pending-confirmation`&&(0,q.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,q.jsxs)(`div`,{className:`text-center`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`Backdate Confirmation Required`}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`This date is in the past. Please confirm to proceed.`})]})}),o===`creating`&&(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,q.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Creating journal entry...`})]}),o===`success`&&(0,q.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,q.jsxs)(`div`,{className:`text-center`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`✓ Entry Created`}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Redirecting...`})]})}),o===`loading`||o===`error`||o===`pending-confirmation`||o===`creating`||o===`success`?null:s?(0,q.jsx)(`article`,{className:`prose prose-sm max-w-2xl mx-auto`,children:(0,q.jsx)(ri,{remarkPlugins:[Fn],components:UCe,children:s})}):null]}),n&&c&&(0,q.jsx)(VCe,{dateKey:c,onConfirm:async()=>{u&&(r(!1),await u())},onCancel:()=>r(!1),isLoading:o===`creating`})]})}function WCe(){let e=dt(),[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(null),a=async r=>{if(!(!r||t)){n(!0),i(null);try{let t=await dL(r,HCe);pQ({title:`Imported ${t.imported} note(s)`,description:t.errors.length>0?t.errors.slice(0,2).join(`; `):`Open the entry from your journal.`}),e(Z.journal)}catch(e){i(e instanceof Error?e.message:`That file is not a valid portable bundle (.zip).`)}finally{n(!1)}}};return(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 max-w-md min-w-0 mx-auto text-center`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`This import link is missing its bundle`}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The journal import link carries a compressed bundle in its`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`?zip=`}),` parameter. Re-open the original link, or import a portable bundle file directly — entries land in your journal.`]}),(0,q.jsx)(`input`,{type:`file`,accept:`.zip,.md,.markdown,.jsonl,.csv`,"data-testid":`journal-zip-upload`,"aria-label":`Journal bundle file`,disabled:t,className:`text-xs text-muted-foreground file:mr-3 file:rounded-md file:border-0 file:bg-primary file:px-3 file:py-1.5 file:text-xs file:font-semibold file:text-primary-foreground hover:file:opacity-90 max-w-full`,onChange:e=>{a(e.target.files?.[0]),e.target.value=``}}),r&&(0,q.jsxs)(`div`,{role:`alert`,"data-testid":`journal-zip-error`,className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,q.jsx)(Yi,{className:`size-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:r})]}),(0,q.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>e(Z.journal),children:`Back to Journal`})]})}function GCe(){let{slug:e}=te(),t=Qe(),n=e?.startsWith(`guide-`)?e:`guide-${e??`start`}`;return(0,q.jsx)(at,{to:`/page/${encodeURIComponent(n)}${t.search}${t.hash}`,replace:!0})}function KCe({searchHandlerRef:e,canvasRouteList:t=[],rootUnavailable:n,pageSettlingFallback:r}){return(0,q.jsxs)(Nr,{children:[(0,q.jsx)(f,{path:Z.home,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`*`,element:n??(0,q.jsx)(wCe,{})}),(0,q.jsx)(f,{path:`/proto/calc-authoring`,element:(0,q.jsx)(dSe,{})}),(0,q.jsx)(f,{path:`/proto/query-block-composer`,element:(0,q.jsx)(xSe,{})}),(0,q.jsx)(f,{path:`/settings`,element:(0,q.jsx)(at,{to:`/settings/appearance`,replace:!0})}),(0,q.jsx)(f,{path:`/settings/appearance`,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.settingsProfile,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:mH.settingsData,element:(0,q.jsx)(at,{to:Z.settingsStorage,replace:!0})}),(0,q.jsx)(f,{path:mH.settingsDatabase,element:(0,q.jsx)(at,{to:Z.settingsStorage,replace:!0})}),(0,q.jsx)(f,{path:Z.settingsStorage,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.settingsSync,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`/settings/system`,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:mH.settingsQueries,element:(0,q.jsx)(at,{to:Z.journal,replace:!0})}),(0,q.jsx)(f,{path:Z.settingsTags,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.settingsSoundProfiles,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`/settings/library/calcs`,element:(0,q.jsx)(`div`,{className:`p-6`,children:(0,q.jsx)(rCe,{})})}),(0,q.jsx)(f,{path:`/legacy`,element:(0,q.jsx)(uCe,{})}),(0,q.jsx)(f,{path:`/syntax`,element:(0,q.jsx)(CCe,{})}),(0,q.jsx)(f,{path:Z.plan,element:(0,q.jsx)(DCe,{})}),(0,q.jsx)(f,{path:Z.feeds,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.feed,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notebooks,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notebook,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notebookTarget,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notebookItem,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.subscribe,element:(0,q.jsx)(MCe,{})}),(0,q.jsx)(f,{path:Z.pages,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.page,element:r??(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`/guide/:slug`,element:(0,q.jsx)(GCe,{})}),(0,q.jsx)(f,{path:Z.load,element:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,q.jsx)(zCe,{})})}),(0,q.jsx)(f,{path:Z.loadJournal,element:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,q.jsx)(w9,{})})}),(0,q.jsx)(f,{path:Z.loadJournalDate,element:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,q.jsx)(w9,{})})}),(0,q.jsx)(f,{path:Z.playgroundRoot,element:(0,q.jsx)(ACe,{})}),(0,q.jsx)(f,{path:Z.playground,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.playgrounds,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notes,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.note,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.journal,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.day,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.run,element:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,q.jsx)(FCe,{})})}),(0,q.jsx)(f,{path:Z.tracker,element:(0,q.jsx)(ECe,{})}),(0,q.jsx)(f,{path:`/results/segments`,element:(0,q.jsx)(TCe,{})}),(0,q.jsx)(f,{path:Z.sessionDetail,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.sessions,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.sessionDate,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`/review/:runtimeId`,element:(0,q.jsx)(b9,{})}),(0,q.jsx)(f,{path:`/note/:noteId/review`,element:(0,q.jsx)(b9,{})}),(0,q.jsx)(f,{path:`/note/:noteId/review/:sectionId`,element:(0,q.jsx)(b9,{})}),(0,q.jsx)(f,{path:`/note/:noteId/review/:sectionId/:resultId`,element:(0,q.jsx)(b9,{})}),(0,q.jsx)(f,{path:Z.efforts,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.effort,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.equipment,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.equipmentSlug,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.tags,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.tagCategory,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.tag,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.dashboards,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.dashboardView,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),t.map(({route:t})=>(0,q.jsx)(f,{path:t,element:(0,q.jsx)(S7,{searchHandlerRef:e})},t))]})}var T9=`G-PROD-ID`,E9=!1;function D9(){if(E9||typeof document>`u`)return;E9=!0,window.dataLayer=window.dataLayer??[],window.gtag=function(){window.dataLayer.push(arguments)};let e=document.createElement(`script`);e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${T9}`,document.head.appendChild(e),window.gtag(`js`,new Date),window.gtag(`config`,T9,{send_page_view:!1})}function O9(e,t){typeof window>`u`||!QR.consent||window.gtag?.(`event`,`page_view`,{page_title:e??document.title,page_location:window.location.href,page_path:t??window.location.pathname+window.location.search,engagement_time_msec:ZR()})}QR.setForwarder(e=>{window.gtag?.(`event`,e.name,e.payload??{})}),QR.consent?D9():QR.subscribeConsent(e=>{e&&(D9(),O9())});function qCe(){let e=Qe();return(0,K.useEffect)(()=>{let t=e.pathname;if(!t.startsWith(`/effort/`)&&!t.startsWith(`/playground/`)&&!t.startsWith(`/equipment/`)){let e=`Wod.Wiki`;t.startsWith(`/day/`)?e=`Wod.Wiki - Day`:t.startsWith(`/journal`)?e=`Wod.Wiki - Journal`:t.startsWith(`/notebooks`)||t.startsWith(`/notebook/`)?e=`Wod.Wiki - Notebooks`:t===`/notes`?e=`Wod.Wiki - Notes`:t.startsWith(`/note/`)?e=`Wod.Wiki - Note`:t.startsWith(`/pages`)||t.startsWith(`/page/`)?e=`Wod.Wiki - Pages`:t.startsWith(`/tags`)||t.startsWith(`/t/`)?e=`Wod.Wiki - Tags`:t===`/feeds`?e=`Wod.Wiki - Feeds`:t.startsWith(`/feed/`)?e=`Wod.Wiki - Feed`:t.startsWith(`/efforts`)?e=`Wod.Wiki - Efforts`:t.startsWith(`/equipment`)?e=`Wod.Wiki - Equipment`:t.startsWith(`/sessions`)||t.startsWith(`/session/`)?e=`Wod.Wiki - Sessions`:t.startsWith(`/dashboards`)||t.startsWith(`/dashboard/`)?e=`Wod.Wiki - Dashboards`:t.startsWith(`/playgrounds`)&&(e=`Wod.Wiki - Playgrounds`),document.title=e}let n=setTimeout(()=>{O9(document.title,e.pathname+e.search)},0);return()=>clearTimeout(n)},[e.pathname]),null}function JCe(e={}){let{decodeZip:t=S9,intake:n=E$,toast:r=pQ}=e,i=dt(),a=Qe(),[o]=V(`zip`),[s]=V(`z`),[c]=V(`by`),[l]=V(`src`),u=(0,K.useRef)(null);(0,K.useEffect)(()=>{if(a.pathname!==`/load`&&!(a.pathname===`/`&&s))return;if(s){let e=`${s}:${c??``}`;if(u.current===e)return;u.current=e;let a=!1;return(async()=>{try{let e=await t(s);if(e===null)throw Error(`Invalid workout link`);if(a)return;let r=B_e(e,c??void 0);if(await n.ensureEntry(r,{reuseKey:`home`,title:`Home playground`}),a)return;V_e({content:r,by:c??void 0})}catch(e){console.error(`Failed to decode zip:`,e),a||r({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`})}a||i(`/`,{replace:!0})})(),()=>{a=!0}}if(!o)return;let e=!1,d=l&&l.startsWith(`/`)?l:void 0;return(async()=>{try{let r=await t(o);if(r===null)throw Error(`Invalid workout link`);if(e)return;let a=d?await n.createPage(r,{sourcePath:d}):await n.createPage(r);e||i(hH(a),{replace:!0})}catch(t){console.error(`Failed to decode zip:`,t),e||(r({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`}),i(Z.home,{replace:!0}))}})(),()=>{e=!0}},[o,s,c,l,i,a.pathname,t,n,r])}var k9=null,YCe=1,A9=new Set;function j9(){for(let e of A9)e()}function M9(e){return k9&&k9.resolve(!1),new Promise(t=>{let n=YCe++;k9={id:n,request:e,resolve:e=>{k9?.id===n&&(k9=null,j9()),t(e)}},j9()})}async function N9(e,t){let n=t&&typeof t==`object`?t:void 0,r=n?.client?.requestUserInteraction??n?.requestUserInteraction;return typeof r==`function`?r(()=>M9(e)):M9(e)}var XCe=()=>{let e=(0,K.useSyncExternalStore)(e=>(A9.add(e),()=>A9.delete(e)),()=>k9,()=>null);return e?(0,q.jsx)(`div`,{"data-agent-hidden":``,children:(0,q.jsxs)(Xr,{open:!0,onOpenChange:t=>{t||e.resolve(!1)},children:[(0,q.jsx)(xr,{}),(0,q.jsxs)(Mn,{"data-testid":`agent-confirm-dialog`,children:[(0,q.jsxs)(Io,{children:[(0,q.jsxs)(la,{className:`flex items-center gap-2 text-destructive`,children:[(0,q.jsx)(oe,{className:`size-5 shrink-0`,"aria-hidden":`true`}),`Confirm Agent Action`]}),(0,q.jsxs)(Ki,{children:[`An AI agent requested a destructive operation (`,(0,q.jsx)(`strong`,{children:e.request.action}),`).`]})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/40 p-3 text-xs space-y-1`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:e.request.summary}),(0,q.jsxs)(`div`,{className:`font-mono text-muted-foreground`,children:[`Target: `,(0,q.jsx)(`span`,{"data-testid":`agent-confirm-target`,children:e.request.targetId})]})]}),(0,q.jsxs)(Lo,{className:`gap-2 sm:gap-0`,children:[(0,q.jsx)(vr,{"data-testid":`agent-confirm-cancel`,onClick:()=>e.resolve(!1),children:`Deny`}),(0,q.jsx)(vr,{value:`confirm`,"data-variant":`destructive`,"data-testid":`agent-confirm-approve`,onClick:()=>e.resolve(!0),children:`Approve Action`})]})]})]})}):null};function ZCe(e){return JSON.stringify(e).replace(/</g,`\\u003c`)}var QCe=()=>{let e=Qe(),t=OZ(),n=kZ(),r=KX(),i=_X(),a=CX(),o=PW(),s=dX(),c=kX(),l=(0,K.useSyncExternalStore)(t0,e0,()=>null),u=r||t===`preparing`||n,d=(0,K.useMemo)(()=>{let r=i&&o&&o.pathname===e.pathname?o:null;return ZCe({schemaVersion:`1.0`,build:CJ,hydrated:!0,status:u?`loading`:`ready`,feedReadiness:t,importPending:n,route:{pathname:e.pathname,search:e.search,hash:e.hash},stream:i?{route:i.route,query:i.query,defaultQuery:i.defaultQuery,layout:i.layout,availableLayouts:i.availableLayouts,groupBy:i.groupBy??null,loading:i.loading,totalUnbatchedCount:r?r.entries.length:null,sampleEntries:r?r.entries.slice(0,25).map(e=>({id:e.id,title:e.title,date:e.date??null,notebookId:e.notebookId??null})):[]}:null,explorer:a?{draft:a.draft,submitted:a.submitted,weeks:a.weeks,loading:a.loading,saveReady:a.saveReady}:null,editor:s?{noteId:s.noteId??null,readonly:s.readonly,sourceRevision:s.sourceRevision??null,workoutBlockIds:s.getBlocks().map(e=>e.id)}:null,results:c?{resultId:c.resultId,activeTab:c.activeTab,mobileViewMode:c.mobileViewMode,sourceDrawerOpen:c.sourceDrawerOpen,addToDashboardOpen:c.addToDashboardOpen}:null,clock:l})},[u,t,n,e.pathname,e.search,e.hash,i,a,o,s,c,l]);return(0,q.jsx)(`script`,{id:`agent-view-state`,type:`application/json`,dangerouslySetInnerHTML:{__html:d}})},P9=class extends Error{code=`CONFIRMATION_REQUIRED`;targetId;action;constructor(e,t){super(t??`Destructive action '${e.action}' on '${e.targetId}' requires confirmation (${e.summary}).`),this.name=`AgentConfirmationRequiredError`,this.action=e.action,this.targetId=e.targetId}};function F9(e){return e}async function I9(e,t,n){if(n===void 0||n!==t.targetId){if(e.confirmDestructive){let n=e.confirmTimeoutMs??1500,r;if(await Promise.race([e.confirmDestructive(t).finally(()=>{r!==void 0&&clearTimeout(r)}),new Promise(e=>{r=setTimeout(()=>e(!1),n)})]))return;throw new P9(t,`User declined or did not confirm '${t.action}' on '${t.targetId}'.`)}throw new P9(t,`Destructive action '${t.action}' requires confirmId="${t.targetId}" (or --yes "${t.targetId}" on CLI).`)}}function L9(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function $Ce(e){let t=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``);for(let e of t.split(/\r?\n/)){let t=e.match(/^#\s+(.+)$/);if(t?.[1]?.trim())return t[1].trim()}}function R9(e,t,n){let r=e.trim();if(!r)return n?`# ${n}\n`:``;let i=e.replace(/^(\s*`{3,})(?:wod|whiteboard)(?=(?::[\w-]+)?\s*$)/gim,`$1time`);if(Gs(i,{registeredWidgets:Us}).some(e=>e.scriptBlock)||/^---\r?\n/.test(i)||/^#\s+/m.test(i))return i.endsWith(`
|
|
1199
1199
|
`)?i:`${i}\n`;let a=3;for(let e of i.matchAll(/`+/g))a=Math.max(a,e[0].length+1);let o="`".repeat(a);return`${n?`# ${n}\n\n`:``}${o}time${t?`:${t}`:``}\n${r}\n${o}\n`}function z9(e,t=Date.now()){if(!e||e.trim().toLowerCase()===`today`){let e=new Date(t);return`${e.getUTCFullYear()}-${String(e.getUTCMonth()+1).padStart(2,`0`)}-${String(e.getUTCDate()).padStart(2,`0`)}`}let n=e.trim();if(!/^\d{4}-\d{2}-\d{2}$/.test(n))throw Error(`Invalid date '${e}'; expected YYYY-MM-DD or 'today'.`);return n}function ewe(e){return new cx(NC(e))}async function B9(e,t,n,r){let i=new Set(r.map(e=>e.id));for(let r of n)i.has(r.id)||await e.readwrite(t).delete(r.id);let a=new Map(n.map(e=>[e.id,e]));for(let n of r)nC(a.get(n.id),n)||(t===`block_index`&&`blockVersion`in n&&await e.readwrite(`block_index`).put(n),t===`block_efforts`&&`effortSlug`in n&&await e.readwrite(`block_efforts`).put(n),t===`block_equipment`&&`equipmentSlug`in n&&await e.readwrite(`block_equipment`).put(n))}async function V9(e,t){let n=t.now??Date.now(),r=eS(t.rawContent),i=t.noteId??r?.noteId??L9(),a=t.tags??uS(t.rawContent);return e.transaction([`notes`,`block_revisions`,`note_revisions`,`block_index`,`block_efforts`,`block_equipment`,`efforts`,`equipment`,`tags`,`note_tags`,`page`,`page_notes`,`schedule_items`,`sessions`,`notebook_links`],`readwrite`,async e=>{let o=await e.readonly(`notes`).get(i);if(o){let e=bb(o),t=yb(o);if(!(o.seedOrigin!==`seed`&&o.feedOrigin!==`feed`&&Rs(o,e,t)))throw Error(`Note '${i}' is read-only (seed/feed). Clone it first with wod_note_clone before editing.`)}if(t.expectedSourceRevision!==void 0&&(o?.sourceRevision??0)!==t.expectedSourceRevision)throw Error(`CONFLICT: Stale sourceRevision on note '${i}': expected ${t.expectedSourceRevision}, actual ${o?.sourceRevision??0}.`);let s=o&&o.rawContent===t.rawContent?o.sourceRevision:(o?.sourceRevision??0)+1,c=await e.readonly(`block_revisions`).getAllFromIndex(`by-note`,i),l=new Map;for(let e of c)(l.get(e.blockId)?.version??0)<e.version&&l.set(e.blockId,e);let u=0,d=qs(t.rawContent,{sourceRevision:s,blocks:o?.blocks,registeredWidgets:Us,createId:()=>{for(;;){let e=`blk-${i.slice(0,8)}-${u++}`;if(!l.has(e))return e}}});Js(t.rawContent,d,s,{registeredWidgets:Us});let f=[];for(let e of Object.values(d)){let r=l.get(e.id),a=t.rawContent.slice(e.from,e.to),o=r&&r.rawContent===a&&r.kind===e.kind&&r.dialect===e.dialect&&r.sport===e.sport;e.version=o?r.version:(r?.version??0)+1,o||f.push({noteId:i,blockId:e.id,version:e.version,kind:e.kind,rawContent:a,savedAt:n,...e.dialect?{dialect:e.dialect}:{},...e.sport?{sport:e.sport}:{}})}if(o?.rawContent===t.rawContent&&!nC(o.blocks,d)){s+=1;for(let e of Object.values(d))e.sourceRevision=s}let p=t.title??r?.title??$Ce(t.rawContent)??o?.title??`Untitled Workout`,m=t.notebookId?Ps(t.notebookId):o?.notebookId,h=m?Array.from(new Set([...o?.notebookIds??[],m])):o?[...o.notebookIds??[]]:[],g=a.map(e=>e.label),_=t.type??o?.type??(t.journalDate?`journal`:`note`);if(o&&(o.rawContent!==t.rawContent||o.title!==p||o.type!==_||!nC(o.blocks,d)||!nC(o.tags??[],g))&&await qw(e,i)&&(await Jw(e,o,n),s<=o.sourceRevision)){s=o.sourceRevision+1;for(let e of Object.values(d))e.sourceRevision=s}let v=t.journalDate?Date.parse(`${z9(t.journalDate,n)}T12:00:00Z`):o?.date??n,y={...o??{},id:i,title:p,rawContent:t.rawContent,sourceRevision:s,blocks:d,type:_,date:v,createdAt:o?.createdAt??n,notebookIds:h,...m&&m!==`notebook/journal`?{notebookId:m}:{},tags:g,seedOrigin:`user`},b=await e.readonly(`efforts`).getAll(),x=new Map;for(let e of ef)x.set(e.slug,e);for(let e of b)x.set(e.slug,e);let S=lf({efforts:[...x.values()],equipment:await e.readonly(`equipment`).getAll()}),C=await e.readonly(`block_index`).getAllFromIndex(`by-note`,i),w=await e.readonly(`block_efforts`).getAllFromIndex(`by-note`,i),T=await e.readonly(`block_equipment`).getAllFromIndex(`by-note`,i),E=new Map(C.map(e=>[e.id,e])),D=[],O=[],k=[],A=new Set,j=new Set;for(let[e,r]of Object.values(d).sort((e,t)=>e.from-t.from).entries()){let a=`${i}:${r.id}`,o=E.get(a),c=t.rawContent.slice(r.from,r.to),l=Gs(c,{registeredWidgets:Us})[0]?.displayContent??c,u=r.kind===`wod`?ys(l):void 0;if(D.push({...o??{},id:a,noteId:i,blockId:r.id,blockVersion:r.version,dataType:r.kind,sourceRevision:s,from:r.from,to:r.to,position:e,rawContent:c,noteTitle:y.title,createdAt:o?.createdAt??n,...u?{blockContentId:u}:{},...y.notebookId?{notebookId:y.notebookId}:{}}),r.kind===`wod`){let e=Uu(l,{...r.sport?{sport:r.sport}:{},references:S}),t=uf(e.statements),a=new Set(t.efforts);if(a.size===0)for(let t of e.statements){let e=t.metrics?.getMetric?.(Y.Effort),n=(typeof e?.value==`string`?e.value:``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``);n&&![`rest`,`amrap`,`emom`,`tabata`,`for-time`].includes(n)&&a.add(n)}for(let e of a){A.add(e);let t=`${i}:${r.id}:${e}`,a=w.find(e=>e.id===t);O.push({...a??{},id:t,noteId:i,blockId:r.id,...u?{blockContentId:u}:{},effortSlug:e,createdAt:a?.createdAt??n})}for(let e of t.equipment){j.add(e);let t=`${i}:${r.id}:${e}`,a=T.find(e=>e.id===t);k.push({...a??{},id:t,noteId:i,blockId:r.id,...u?{blockContentId:u}:{},equipmentSlug:e,createdAt:a?.createdAt??n})}}}nC(o,y)||await e.readwrite(`notes`).put(y),f.length>0&&await e.readwrite(`block_revisions`).putMany(f),await B9(e,`block_index`,C,D),await B9(e,`block_efforts`,w,O),await B9(e,`block_equipment`,T,k);let M=await e.readonly(`note_tags`).getAllFromIndex(`by-note`,i),N=new Map;for(let t of a){let r=t.label.trim();if(!r)continue;let a=(await e.readonly(`tags`).getAllFromIndex(`by-label`,r))[0],o=a?{...a,...!a.type&&t.type?{type:t.type}:{}}:{id:L9(),label:r,...t.type?{type:t.type}:{},createdAt:n};nC(a,o)||await e.readwrite(`tags`).put(o);let s=M.find(e=>e.tagId===o.id)?.id??`${i}:${o.id}`;N.set(s,{id:s,noteId:i,tagId:o.id})}for(let t of M)N.has(t.id)||await e.readwrite(`note_tags`).delete(t.id);for(let t of N.values())await e.readwrite(`note_tags`).put(t);let P=h.map(e=>({id:ZC(Ps(e),`note`,i),notebookId:Ps(e),targetKind:`note`,targetId:i,noteId:i,createdAt:n}));P.length>0&&await e.readwrite(`notebook_links`).putMany(P);let F;if(t.journalDate){let r=z9(t.journalDate,n),a;try{a=await e.readonly(`page`).getAllFromIndex(`by-date`,r)}catch{a=(await e.readonly(`page`).getAll()).filter(e=>e.date===r)}let o=a[0];o||(o={id:L9(),date:r,title:r,createdAt:n},await e.readwrite(`page`).put(o));let s=await e.readonly(`page_notes`).getAllFromIndex(`by-page`,o.id);if(!s.some(e=>e.noteId===i)){let t=s.reduce((e,t)=>typeof t.position==`number`&&t.position>e?t.position:e,-1);await e.readwrite(`page_notes`).put({id:L9(),pageId:o.id,noteId:i,position:t+1,createdAt:n})}try{let t=await e.readonly(`schedule_items`).getAllFromIndex(`by-date`,r),a=t.find(e=>e.noteId===i);if(a)F=a.id;else{let a=t.reduce((e,t)=>typeof t.position==`number`&&t.position>e?t.position:e,-1),s=L9();await e.readwrite(`schedule_items`).put({id:s,date:r,noteId:i,pageId:o.id,...y.notebookId?{sourceNotebookId:y.notebookId}:{},fallbackTitle:y.title,position:a+1,status:`planned`,createdAt:n,updatedAt:n}),F=s}}catch{}}return{note:y,created:!o,blockCount:D.length,effortSlugs:[...A],equipmentSlugs:[...j],tagLabels:a.map(e=>e.label),...F?{scheduleItemId:F}:{}}})}async function twe(e,t){return e.transaction([`notes`,`attachments`,`note_tags`,`block_index`,`block_efforts`,`block_equipment`,`page_notes`,`schedule_items`,`notebook_links`,`meta`],`readwrite`,async e=>{let n=await e.readonly(`notes`).get(t);if(!n)return!1;await e.readwrite(`notes`).delete(t);for(let n of await e.readonly(`attachments`).getAllFromIndex(`by-note`,t))await e.readwrite(`attachments`).delete(n.id);for(let n of await e.readonly(`note_tags`).getAllFromIndex(`by-note`,t))await e.readwrite(`note_tags`).delete(n.id);for(let n of await e.readonly(`block_index`).getAllFromIndex(`by-note`,t))await e.readwrite(`block_index`).delete(n.id);for(let n of await e.readonly(`block_efforts`).getAllFromIndex(`by-note`,t))await e.readwrite(`block_efforts`).delete(n.id);for(let n of await e.readonly(`block_equipment`).getAllFromIndex(`by-note`,t))await e.readwrite(`block_equipment`).delete(n.id);for(let n of await e.readonly(`page_notes`).getAllFromIndex(`by-note`,t))await e.readwrite(`page_notes`).delete(n.id);try{for(let n of await e.readonly(`schedule_items`).getAllFromIndex(`by-note`,t))await e.readwrite(`schedule_items`).delete(n.id)}catch{}try{for(let n of await e.readonly(`notebook_links`).getAllFromIndex(`by-note`,t))await e.readwrite(`notebook_links`).delete(n.id)}catch{}return(n.seedOrigin===`seed`||n.seedChunkId!==void 0||n.sourcePath!==void 0)&&await e.readwrite(`meta`).put({key:lC(t),value:Date.now()}),!0})}async function nwe(e,t){return e.transaction([`sessions`,`events`,`notebook_links`],`readwrite`,async e=>{if(!await e.readonly(`sessions`).get(t))return!1;await e.readwrite(`sessions`).delete(t);let n=await e.readonly(`events`).getAll();for(let r of n)r.resultId===t&&await e.readwrite(`events`).delete(r.id);try{let n=await e.readonly(`notebook_links`).getAll();for(let r of n)r.targetKind===`session`&&r.targetId===t&&await e.readwrite(`notebook_links`).delete(r.id)}catch{}return!0})}function H9(e,t=``){return`${t.replace(/\/+$/,``)}/note/${encodeURIComponent(e.id)}`}var rwe=F9({name:`wod_catalog_lookup`,title:`Lookup Efforts, Equipment & Tags`,description:"Search or inspect the Effort movement registry, Equipment catalog, Tags, and Tag Categories with Notebook-scoped override precedence (`notebook/defaults` -> Feed/Notebook -> `notebook/custom`).",tier:0,domain:`catalog`,annotations:{title:`Lookup Catalog`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({kind:Qt([`effort`,`equipment`,`tag`,`tag-type`]).describe(`Catalog family to search or inspect.`),search:G().optional().describe(`Case-insensitive slug, label, or alias filter.`),slug:G().optional().describe(`Exact canonical slug/name to look up.`),notebookId:G().optional().describe(`Optional Notebook scope for property inheritance resolution.`),limit:se().int().min(1).max(250).optional().describe(`Max entries to return (default 50).`)}),cliEquivalent:`wod catalog <efforts|equipment|tags> --json`,async execute(e,t){let n=await EC(t.storage,{...e.notebookId?{notebookId:e.notebookId}:{},mode:`custom-runtime`}),r=e.limit??50,i=e.search?.trim().toLowerCase(),a=e.slug?.trim().toLowerCase();if(e.kind===`effort`){let e=new Map;for(let t of ef)e.set(t.slug,t);for(let t of n.efforts)e.set(t.slug,t);let t=[...e.values()].filter(e=>a?e.slug.toLowerCase()===a:!i||e.slug.toLowerCase().includes(i)||e.label.toLowerCase().includes(i)||(e.aliases??[]).some(e=>e.toLowerCase().includes(i)));return{kind:`effort`,totalCount:t.length,items:t.slice(0,r).map(e=>({slug:e.slug,label:e.label,aliases:e.aliases??[],met:e.baseAttributes?.met,scope:n.originByKey.get(`effort:${e.slug}`)??`notebook/defaults`,...a?{markdown:dS(e)}:{}}))}}if(e.kind===`equipment`){let e=n.equipment.filter(e=>a?e.slug.toLowerCase()===a:!i||e.slug.toLowerCase().includes(i)||e.label.toLowerCase().includes(i)||(e.aliases??[]).some(e=>e.toLowerCase().includes(i)));return{kind:`equipment`,totalCount:e.length,items:e.slice(0,r).map(e=>({slug:e.slug,label:e.label,aliases:e.aliases??[],scope:n.originByKey.get(`equipment:${e.slug}`)??`notebook/defaults`,...a?{markdown:fS(e)}:{}}))}}if(e.kind===`tag`){let e=n.tags.filter(e=>a?e.label.toLowerCase()===a:!i||e.label.toLowerCase().includes(i)||(e.type??``).toLowerCase().includes(i));return{kind:`tag`,totalCount:e.length,items:e.slice(0,r).map(e=>({id:e.id,label:e.label,type:e.type??`general`,contributions:e.contributions??[],scope:n.originByKey.get(`tag:${e.label}`)??`notebook/defaults`}))}}let o=n.tagTypes.filter(e=>a?e.name.toLowerCase()===a:!i||e.name.toLowerCase().includes(i)||e.label.toLowerCase().includes(i));return{kind:`tag-type`,totalCount:o.length,items:o.slice(0,r)}}}),iwe=yi({kind:Qt([`effort`,`equipment`,`tag`,`tag-type`]).describe(`Property definition family to create or override.`),slug:G().min(1).describe(`Canonical kebab-case slug (e.g. "kettlebell-swing", "barbell").`),label:G().optional().describe(`Human-readable display label.`),targetNotebookId:G().optional().describe(`Target Notebook scope: defaults to "notebook/custom" (personal runtime) or a writable user Notebook.`),markdown:G().optional().describe(`Full Property Note Markdown with YAML frontmatter. If omitted, synthesized from structured fields below.`),met:se().positive().optional().describe(`MET metabolic equivalent (for kind="effort", default 5.0).`),aliases:me(G()).optional().describe(`Optional movement/equipment aliases.`),category:G().optional().describe(`Tag category when kind="tag" (e.g. "equipment", "quality", "format").`),color:G().optional().describe(`Hex color when kind="tag-type" (e.g. "#10b981").`)});function awe(e){if(e.markdown?.trim())return e.markdown;let t=e.slug.trim().toLowerCase(),n=e.label?.trim()||t,r=e.aliases&&e.aliases.length>0?`\naliases:\n${e.aliases.map(e=>` - ${JSON.stringify(e)}`).join(`
|
|
1200
1200
|
`)}`:``;if(e.kind===`effort`){let i=e.met??5;return`---\nid: effort-${t}\nslug: ${t}\nlabel: ${JSON.stringify(n)}${r}\nbaseAttributes:\n met: ${i}\n---\n\n# ${n}\n`}if(e.kind===`equipment`)return`---\ntype: equipment\nid: equipment-${t}\nslug: ${t}\nlabel: ${JSON.stringify(n)}${r}\n---\n\n# ${n}\n`;if(e.kind===`tag`){let r=e.category??`general`;return`---\ntype: tag\nid: tag-${t}\nslug: ${t}\nlabel: ${JSON.stringify(n)}\ncategory: ${r}\n---\n\n# ${n}\n`}let i=e.color??`#6366f1`;return`---\ntype: tag-type\nid: type-${t}\nslug: ${t}\nlabel: ${JSON.stringify(n)}\ncolor: ${JSON.stringify(i)}\n---\n\n# ${n}\n`}var owe=[rwe,F9({name:`wod_catalog_upsert`,title:`Save Effort, Equipment, or Tag Property Note`,description:"Create or update a Scoped Property Override (`effort`, `equipment`, `tag`, or `tag-type`) in `notebook/custom` or a shared user Notebook.",tier:1,domain:`catalog`,annotations:{title:`Save Catalog Property`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:iwe,cliEquivalent:`wod catalog save <kind> <file|-> --json`,async execute(e,t){let n=awe(e),r=await wC(t.storage,{targetNotebookId:e.targetNotebookId??`notebook/custom`,kind:e.kind,slug:e.slug,rawContent:n,title:e.label,category:e.category});return await t.onMutated?.([`notes`,`block_revisions`,`property_overrides`,`efforts`,`equipment`,`tags`,`tag_types`]),{id:r.id,kind:r.kind,slug:r.slug,label:r.label,notebookId:r.notebookId,ownerNoteId:r.ownerNoteId}}})],swe=[F9({name:`wod_feed_manage`,title:`Manage Feeds & Portability`,description:"Inspect installed Seed/Feed sources (`list`), check unpublished public Notebook changes (`status`), compile and publish public Notebooks (`publish`), import portable Markdown + JSONL/CSV files (`import-bundle`), or subscribe/unsubscribe/delete a Feed source.",tier:1,domain:`feed`,annotations:{title:`Manage Feeds`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({action:Qt([`list`,`status`,`publish`,`import-bundle`,`subscribe`,`unsubscribe`,`delete`]).describe(`Feed or portability operation to run.`),sourceId:G().min(1).optional().describe(`Target Feed source ID when action is "subscribe", "unsubscribe", or "delete".`),notebookIds:me(G().min(1)).optional().describe(`Optional subset of Notebook IDs when action="subscribe".`),url:G().min(1).optional().describe(`Optional Feed manifest URL when subscribing to a custom source.`),confirmId:G().optional().describe(`Confirmation token (must match sourceId) for non-interactive unsubscribe/delete calls.`),notebookSlug:G().optional().describe(`Optional Notebook slug filter when publishing.`),name:G().optional().describe(`Optional Feed display name when publishing or subscribing.`),description:G().optional().describe(`Optional Feed description when publishing.`),files:me(yi({path:G().min(1),content:G()})).optional().describe('Portable `.md` / `.jsonl` / `.csv` files when action="import-bundle".')}),cliEquivalent:`wod feed <list|status|publish|subscribe|unsubscribe|delete> --json`,async execute(e,t){if(e.action===`list`){let e=await t.storage.readonly(`meta`).getAll(),n=await kae(t.storage),r=[];for(let t of e){let e=t;if(typeof e.key==`string`&&e.key.startsWith(`seed:`)&&e.key!==FS(`user`)){let t=e.key.slice(5),i=n[t];r.push({sourceId:t,seedVersion:e.seedVersion,builtAt:e.builtAt,importedAt:e.importedAt,chunkCount:Object.keys(e.chunks??{}).length,subscribed:i?.subscribed??!0,offlinePolicy:i?.offlinePolicy??(t===`core`?`offline-full`:`index-only`),autoSync:i?.autoSync??t===`core`})}}return{action:`list`,installedCount:r.length,feeds:r,subscriptions:n}}if(e.action===`subscribe`){if(!e.sourceId)throw Error('Provide `sourceId` when action="subscribe".');let n=t.feedLifecycle?.subscribe?await t.feedLifecycle.subscribe(e.sourceId,{notebookIds:e.notebookIds,url:e.url,name:e.name}):await Aae(t.storage,e.sourceId,{notebookIds:e.notebookIds,url:e.url,name:e.name});return await t.onMutated?.([`meta`,`notes`]),{action:`subscribe`,...n}}if(e.action===`unsubscribe`){if(!e.sourceId)throw Error('Provide `sourceId` when action="unsubscribe".');if(e.sourceId===`core`)throw Error(`Core feed cannot be unsubscribed.`);await I9(t,{action:`wod_feed_manage:unsubscribe`,targetId:e.sourceId,summary:`Unsubscribe from feed '${e.sourceId}' and purge its imported notes`},e.confirmId);let n=t.feedLifecycle?.unsubscribe?await t.feedLifecycle.unsubscribe(e.sourceId):await jae(t.storage,e.sourceId);return await t.onMutated?.([`meta`,`notes`,`tags`,`note_tags`,`block_index`,`block_efforts`,`block_equipment`,`page_notes`,`efforts`,`equipment`,`property_overrides`]),{action:`unsubscribe`,...n}}if(e.action===`delete`){if(!e.sourceId)throw Error('Provide `sourceId` when action="delete".');if(e.sourceId===`core`)throw Error(`Core feed cannot be deleted.`);await I9(t,{action:`wod_feed_manage:delete`,targetId:e.sourceId,summary:`Delete feed source '${e.sourceId}' and purge all of its imported notes`},e.confirmId);let n=t.feedLifecycle?.delete?await t.feedLifecycle.delete(e.sourceId):await Mae(t.storage,e.sourceId);return await t.onMutated?.([`meta`,`notes`,`tags`,`note_tags`,`block_index`,`block_efforts`,`block_equipment`,`page_notes`,`efforts`,`equipment`,`property_overrides`]),{action:`delete`,...n}}if(e.action===`status`)return{action:`status`,...await XC(t.storage,t.feedTree)};if(e.action===`publish`){let n=t.feedTree??new HC,r=await YC(t.storage,n,{layout:`feed`,notebookSlug:e.notebookSlug,name:e.name,description:e.description});return await t.onMutated?.([`meta`,`property_overrides`]),{action:`publish`,notebooks:r.notebooks,totalNotes:r.totalNotes,totalPublicSessions:r.totalPublicSessions,manifestVersion:r.manifest.version,manifestSha256:r.manifestSha256}}if(!e.files||e.files.length===0)throw Error('Provide non-empty `files` array when action="import-bundle".');let n=await Sae(t.storage,e.files,{defaultNotebookId:e.notebookSlug});return await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`tags`,`note_tags`,`sessions`,`events`]),{action:`import-bundle`,...n}}}),F9({name:`wod_export_bundle`,title:`Export Portable Markdown & Telemetry Bundle`,description:"Export user Notes and attached Session telemetry directly as structured `{ path, content }` strings (Markdown + JSONL/CSV) without triggering synthetic browser file downloads.",tier:0,domain:`feed`,annotations:{title:`Export Portable Bundle`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({noteIds:me(G()).optional().describe(`Optional Note IDs to export (defaults to all user-owned Notes).`),telemetryFormat:Qt([`jsonl`,`csv`,`both`]).optional().describe(`Format for companion Session/Event telemetry files (default "jsonl").`)}),cliEquivalent:`wod export note <id> -o -`,async execute(e,t){let n=await xae(t.storage,{noteIds:e.noteIds,telemetryFormat:e.telemetryFormat??`jsonl`});return{fileCount:n.length,files:n}}}),F9({name:`wod_reset_storage`,title:`Wipe Storage Data`,description:`Wipe user Notes, Sessions, Events, and Notebook data from the active storage backend (Tier 2 destructive — requires explicit user confirmation).`,tier:2,domain:`system`,annotations:{title:`Wipe Storage Data`,readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({confirmToken:G().optional().describe(`For non-interactive MCP/CLI calls, pass confirmToken="WIPE_STORAGE" to confirm wiping user storage.`)}),cliEquivalent:`wod reset --yes WIPE_STORAGE --json`,async execute(e,t){return await I9(t,{action:`wod_reset_storage`,targetId:`WIPE_STORAGE`,summary:`Wipe all user Notes, Sessions, and telemetry from WOD Wiki storage`},e.confirmToken),await t.storage.wipe(),await t.onMutated?.([`notes`,`sessions`,`events`,`page`,`page_notes`,`notebook_links`]),{wiped:!0}}})],cwe=[F9({name:`wod_journal_day`,title:`Get Journal Day`,description:"Fetch all scheduled/authored workout Notes and recorded Sessions for a specific Journal calendar day (`YYYY-MM-DD` or `today`).",tier:0,domain:`journal`,annotations:{title:`Get Journal Day`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({date:G().optional().describe(`Calendar date in YYYY-MM-DD format, or "today" (defaults to "today").`)}),cliEquivalent:`wod journal [today|YYYY-MM-DD] --json`,async execute(e,t){let n=z9(e.date),r=await rT(t.storage,n),i=Date.parse(`${n}T00:00:00Z`),a=Date.parse(`${n}T23:59:59.999Z`),o;try{o=await t.storage.readonly(`page`).getAllFromIndex(`by-date`,n)}catch{o=(await t.storage.readonly(`page`).getAll()).filter(e=>e.date===n)}let s=o[0],c=[];if(s){let e=xs(await t.storage.readonly(`page_notes`).getAllFromIndex(`by-page`,s.id));for(let t of e)c.includes(t.noteId)||c.push(t.noteId)}let l=await t.storage.readonly(`notes`).getAll(),u=new Map(l.map(e=>[e.id,e])),d=[],f=new Set;for(let{item:e,note:t}of r.planned){let n=t??u.get(e.noteId);n&&!f.has(n.id)&&(d.push(n),f.add(n.id))}for(let e of c){let t=u.get(e);t&&!f.has(t.id)&&(d.push(t),f.add(t.id))}for(let e of l){if(f.has(e.id)||e.seedOrigin===`seed`||e.feedOrigin===`feed`||e.id.startsWith(`notebook/`)&&e.notebookId===e.id)continue;let t=e.date??e.createdAt;t>=i&&t<=a&&(d.push(e),f.add(e.id))}let p=new Map;for(let e of r.planned)for(let t of e.pairedSessions)p.set(t.id,t);for(let e of r.adhocSessions)p.set(e.session.id,e.session);let m=Array.from(p.values()).sort((e,t)=>e.startTime-t.startTime);for(let e of m){if(f.has(e.noteId))continue;let t=u.get(e.noteId);t&&(d.push(t),f.add(t.id))}return{date:n,url:`${(t.baseUrl??``).replace(/\/+$/,``)}/day/${n}`,pageId:s?.id??null,plannedCount:r.planned.length,planned:r.planned.map(({item:e,note:t,pairedSessions:n})=>({scheduleItemId:e.id,noteId:e.noteId,noteTitle:t?.title??e.noteId,status:n.length>0?`completed`:e.status,...e.slot?{slot:e.slot}:{},...e.notes?{notes:e.notes}:{},pairedSessionIds:n.map(e=>e.id)})),adhocSessionCount:r.adhocSessions.length,adhocSessions:r.adhocSessions.map(({session:e,note:t})=>({id:e.id,noteId:e.noteId,noteTitle:t?.title??e.noteId,status:e.status,completed:e.completed,duration:e.duration,startTime:e.startTime,...e.noteSourceRevision?{noteSourceRevision:e.noteSourceRevision}:{}})),noteCount:d.length,notes:d.map(e=>({id:e.id,title:e.title,sourceRevision:e.sourceRevision,rawContent:e.rawContent,tags:e.tags??[],wodBlockIds:Object.values(e.blocks??{}).filter(e=>e.kind===`wod`).map(e=>e.id),url:H9(e,t.baseUrl)})),sessionCount:m.length,sessions:m.map(e=>({id:e.id,noteId:e.noteId,blockId:e.blockId,status:e.status,completed:e.completed,duration:e.duration,startTime:e.startTime,...e.scheduleItemId?{scheduleItemId:e.scheduleItemId}:{},...e.sessionDate?{sessionDate:e.sessionDate}:{},...e.noteSourceRevision?{noteSourceRevision:e.noteSourceRevision}:{}}))}}}),F9({name:`wod_journal_add`,title:`Add Workout to Journal Day`,description:"Create a lightweight workout Note (unfiled unless `notebookId` is given) and schedule it onto the specified calendar day via a `ScheduleItem`.",tier:1,domain:`journal`,annotations:{title:`Add Workout to Journal Day`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:yi({date:G().optional().describe(`Target Journal date in YYYY-MM-DD format or "today" (defaults to "today").`),title:G().optional().describe(`Workout title (defaults to # H1 heading or date).`),content:G().min(1).describe(`Markdown workout note or bare Whiteboard Script to schedule onto the Journal day.`),sport:G().optional().describe(`Optional sport fence tag when passing bare Whiteboard Script.`),notebookId:G().optional().describe(`Optional user Notebook ID to assign this Note into (omit to keep unfiled on Journal).`)}),cliEquivalent:`wod journal add <file|-> --date YYYY-MM-DD --json`,async execute(e,t){let n=z9(e.date),r=e.title??`Workout ${n}`,i=R9(e.content,e.sport,e.title),a=await V9(t.storage,{title:r,rawContent:i,journalDate:n,notebookId:e.notebookId,type:`journal`});await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`block_efforts`,`block_equipment`,`page`,`page_notes`,`notebook_links`,`schedule_items`]);let o=(t.baseUrl??``).replace(/\/+$/,``);return{date:n,noteId:a.note.id,...a.scheduleItemId?{scheduleItemId:a.scheduleItemId}:{},journalUrl:`${o}/day/${n}`,note:{id:a.note.id,title:a.note.title,sourceRevision:a.note.sourceRevision,blockCount:a.blockCount,effortSlugs:a.effortSlugs,url:H9(a.note,t.baseUrl)}}}})],U9=new Set(zs.map(e=>e.slug)),lwe=[F9({name:`wod_notebook_list`,title:`List Notebooks`,description:`List built-in, user-created, and feed-subscribed Notebooks along with member Note counts and publication status.`,tier:0,domain:`notebook`,annotations:{title:`List Notebooks`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({origin:Qt([`all`,`default`,`user`,`feed`]).optional().describe(`Filter notebooks by origin (default "all").`)}),cliEquivalent:`wod notebook list --json`,async execute(e,t){let[n,r]=await Promise.all([t.storage.readonly(`notes`).getAll(),t.storage.readonly(`notebook_links`).getAll().catch(()=>[])]),i=Hs(n,r,vb),a=new Map;for(let e of zs)a.set(e.notebookId,{notebookId:e.notebookId,slug:e.slug,name:e.name,description:e.description,icon:e.icon,origin:`default`,writable:!js(e.notebookId),public:!1,noteCount:i.get(e.notebookId)??0});for(let e of n){if(!Bs(e))continue;let t=Ns(e.id),n=cS(e.rawContent),r=typeof n.description==`string`?n.description.replace(/^"|"$/g,``):``,o=typeof n.icon==`string`?n.icon.replace(/^"|"$/g,``):`📓`,s=e.feedOrigin===`feed`||e.seedOrigin===`seed`,c=a.get(e.id);a.set(e.id,{notebookId:e.id,slug:t,name:e.title||c?.name||t,description:r||c?.description||``,icon:o||c?.icon||`📓`,origin:c?.origin??(s?`feed`:`user`),writable:!js(e.id)&&!s,public:e.public===!0,noteCount:i.get(Ps(e.id))??0})}let o=e.origin??`all`,s=(t.baseUrl??``).replace(/\/+$/,``),c=[...a.values()].filter(e=>o===`all`||e.origin===o).map(e=>({id:e.notebookId,...e,url:`${s}/notebook/${encodeURIComponent(e.slug)}`}));return{totalCount:c.length,notebooks:c}}}),F9({name:`wod_notebook_save`,title:`Create, Update, or Promote Notebook`,description:"Create or update a user-owned Notebook, promote/detach a Note across Notebooks (`notebook/journal` permanence preserved), or toggle Notebook publication visibility.",tier:1,domain:`notebook`,annotations:{title:`Save or Promote Notebook`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({action:Qt([`create`,`update`,`promote`,`detach`,`set-public`]).describe(`Operation to perform on a user Notebook.`),notebookId:G().optional().describe(`Target Notebook slug or ID (required for update, promote, detach, set-public).`),name:G().optional().describe(`Display name when creating or renaming a Notebook.`),description:G().optional().describe(`Notebook description.`),icon:G().optional().describe(`Notebook icon/emoji.`),noteId:G().optional().describe(`Note ID to promote into or detach from the Notebook.`),sessionIds:me(G()).optional().describe("Optional Session IDs on `noteId` to promote alongside the Note."),public:Gt().optional().describe(`Visibility flag when action="set-public" or promoting sessions.`)}),cliEquivalent:`wod notebook <create|update|promote> --json`,async execute(e,t){if(e.action===`create`){let n=e.name?.trim()||e.notebookId?.trim();if(!n)throw Error('`name` is required when action="create".');let r=await nw(t.storage,n);if(e.description!==void 0||e.icon!==void 0){let i=`---\ndescription: ${JSON.stringify(e.description??``)}\nicon: ${JSON.stringify(e.icon??`📓`)}\n---\n\n# ${n}\n`,a=await V9(t.storage,{noteId:r,title:n,rawContent:i});await t.storage.readwrite(`notes`).put({...a.note,notebookId:r})}return e.public!==void 0&&await lw(t.storage,r,e.public),await t.onMutated?.([`notes`,`block_revisions`,`notebook_links`]),{action:`create`,notebookId:r,slug:Ns(r),name:n}}if(!e.notebookId)throw Error(`'notebookId' is required for action="${e.action}".`);let n=Ps(e.notebookId),r=Ns(n);if(e.action===`update`){if(U9.has(r))throw Error(`Built-in Notebook '${n}' cannot be modified.`);let i=await t.storage.readonly(`notes`).get(n);if(!i)throw Error(`Notebook not found: ${n}`);let a=cS(i.rawContent),o=e.name??i.title??r,s=e.description??(typeof a.description==`string`?a.description.replace(/^"|"$/g,``):``),c=e.icon??(typeof a.icon==`string`?a.icon.replace(/^"|"$/g,``):`📓`),l=`---\ndescription: ${JSON.stringify(s)}\nicon: ${JSON.stringify(c)}\n---\n\n# ${o}\n`,u=await V9(t.storage,{noteId:n,title:o,rawContent:l});return await t.storage.readwrite(`notes`).put({...u.note,notebookId:n,...i.public===void 0?{}:{public:i.public}}),await t.onMutated?.([`notes`,`block_revisions`]),{action:`update`,notebookId:n,slug:r,name:o}}if(e.action===`promote`){if(!e.noteId)throw Error('`noteId` is required when action="promote".');let r=await rw(t.storage,{noteId:e.noteId,notebookIds:[n],sessionIds:e.sessionIds,shareSessionsPublicly:e.public});return await t.onMutated?.([`notes`,`sessions`,`notebook_links`]),{action:`promote`,noteId:e.noteId,notebookIds:r.notebookIds,promotedSessionIds:r.promotedSessionIds}}if(e.action===`detach`){if(!e.noteId)throw Error('`noteId` is required when action="detach".');let r=await aw(t.storage,e.noteId,n);return await t.onMutated?.([`notes`,`notebook_links`]),{action:`detach`,noteId:e.noteId,notebookIds:r}}if(Ms(n))throw Error(`Notebook '${n}' is private/system and cannot be published.`);let i=await lw(t.storage,n,e.public??!0);return await t.onMutated?.([`notes`]),{action:`set-public`,notebookId:n,public:i.public===!0}}}),F9({name:`wod_notebook_delete`,title:`Delete User Notebook`,description:"Delete a user-created Notebook landing note and detach member links while keeping all member Notes safely in `notebook/journal` (Tier 2 destructive).",tier:2,domain:`notebook`,annotations:{title:`Delete User Notebook`,readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({notebookId:G().min(1).describe(`User Notebook ID or slug to delete (member Notes stay safe in notebook/journal).`),confirmId:G().optional().describe(`For non-interactive MCP/CLI calls, repeat the exact notebookId or slug to confirm deletion.`)}),cliEquivalent:`wod notebook delete <slug> --yes <slug> --json`,async execute(e,t){let n=Ps(e.notebookId),r=Ns(n);if(U9.has(r))throw Error(`Built-in Notebook '${n}' cannot be deleted.`);let i=e.confirmId===n||e.confirmId===r?n:void 0;await I9(t,{action:`wod_notebook_delete`,targetId:n,summary:`Delete user Notebook "${r}" (${n}); member Notes remain in notebook/journal`},i);let a=await kw(t.storage,n);return await t.onMutated?.([`notes`,`notebook_links`]),a}})];function uwe(e){return e.id.startsWith(`notebook/`)&&e.notebookId===e.id}var dwe=[F9({name:`wod_note_list`,title:`List Notes`,description:`List workout and reference Notes with optional filtering by Notebook, search query, tag, and origin.`,tier:0,domain:`note`,annotations:{title:`List Notes`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({notebookId:G().optional().describe(`Filter by notebook ID or slug (e.g. "journal", "custom", "guides", "notebook/strength").`),search:G().optional().describe(`Case-insensitive substring filter over title and Markdown content.`),tag:G().optional().describe(`Filter to Notes carrying this tag label.`),origin:Qt([`all`,`user`,`feed`,`seed`]).optional().describe(`Filter by Note origin ("user", "feed", "seed", or "all"; defaults to "all").`),includeSeed:Gt().optional().describe(`Include read-only Seed/Feed notes (default true; pass false for user-authored notes only).`),orphanedOnly:Gt().optional().describe("When true, return only user Notes not belonging to any Notebook (equivalent to `:note{!notebook:*}`)."),limit:se().int().min(1).max(200).optional().describe(`Max notes to return (default 50).`)}),cliEquivalent:`wod note list --json`,async execute(e,t){let n=e.notebookId?Ps(e.notebookId):void 0,r=e.includeSeed??!0,i=e.origin??`all`,a=e.orphanedOnly===!0,o=e.search?.trim().toLowerCase(),s=e.tag?.trim().toLowerCase(),c=e.limit??50,{allNotes:l,linkedNoteIdsForNb:u,noteIdsWithLinks:d}=await t.storage.transaction([`notes`,`notebook_links`],`readonly`,async e=>{let t=await e.readonly(`notes`).getAll(),r,i=new Set;try{if(n){let t=await e.readonly(`notebook_links`).getAllFromIndex(`by-notebook`,n);r=new Set(t.filter(e=>e.targetKind===`note`).map(e=>e.noteId))}if(a){let t=await e.readonly(`notebook_links`).getAll();for(let e of t)e.targetKind===`note`&&i.add(e.noteId)}}catch{r=new Set}return{allNotes:t,linkedNoteIdsForNb:r,noteIdsWithLinks:i}}),f=l.filter(e=>{if(uwe(e))return!1;let t=e.seedOrigin===`seed`||e.feedOrigin===`feed`;return!(i===`user`&&t||i===`feed`&&e.feedOrigin!==`feed`||i===`seed`&&e.seedOrigin!==`seed`||!r&&t||a&&(t||d.has(e.id)||vb(e).length>0)||n&&!(u?.has(e.id)||e.notebookId===n||(e.notebookIds??[]).includes(n)||vb(e).includes(n))||s&&!(e.tags??[]).some(e=>e.toLowerCase()===s)||o&&!e.title.toLowerCase().includes(o)&&!e.rawContent.toLowerCase().includes(o))}).sort((e,t)=>(t.date??t.createdAt)-(e.date??e.createdAt));return{totalCount:f.length,notes:f.slice(0,c).map(e=>{let n=bb(e),r=yb(e);return{id:e.id,title:e.title,sourceRevision:e.sourceRevision,date:e.date,createdAt:e.createdAt,editable:Rs(e,n,r),notebooks:vb(e),tags:e.tags??[],wodBlockCount:Object.values(e.blocks??{}).filter(e=>e.kind===`wod`).length,url:H9(e,t.baseUrl)}})}}}),F9({name:`wod_note_get`,title:`Get Note Details`,description:"Read a full Note by ID including authored Markdown, `sourceRevision`, parsed workout blocks, attached Session count, upstream provenance, and publication visibility.",tier:0,domain:`note`,annotations:{title:`Get Note Details`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({noteId:G().min(1).describe(`Unique Note ID (UUID or seed route ID).`)}),cliEquivalent:`wod note get <noteId> --json`,async execute(e,t){let n=await t.storage.readonly(`notes`).get(e.noteId);if(!n)throw Error(`Note not found: ${e.noteId}`);let r=Rs(n,bb(n),yb(n)),[i,a,o,s,c,l]=await Promise.all([ow(t.storage,n.id),zw(t.storage,n),cw(t.storage,n.id),t.storage.readonly(`sessions`).getAllFromIndex(`by-note`,n.id).catch(async()=>(await t.storage.readonly(`sessions`).getAll()).filter(e=>e.noteId===n.id)),tT(t.storage,n.id).catch(()=>[]),Yw(t.storage,n.id).catch(()=>[])]),u=Gs(n.rawContent,{registeredWidgets:Us}),d=Object.values(n.blocks??{}).sort((e,t)=>e.from-t.from).map(e=>{let t=u.find(t=>t.from===e.from&&t.to===e.to);return{id:e.id,kind:e.kind,version:e.version,...e.dialect?{dialect:e.dialect}:{},...e.sport?{sport:e.sport}:{},content:t?.scriptBlock?.content??n.rawContent.slice(e.from,e.to)}});return{id:n.id,title:n.title,rawContent:n.rawContent,portableMarkdown:aS(n),sourceRevision:n.sourceRevision,editable:r,date:n.date,createdAt:n.createdAt,tags:n.tags??[],notebooks:i.map(e=>({id:e,slug:Ns(e)})),scheduleCount:c.length,scheduleItems:c,revisionCount:l.length,blocks:d,sessionCount:s.length,recentSessions:s.sort((e,t)=>t.startTime-e.startTime).slice(0,10).map(e=>({id:e.id,blockId:e.blockId,status:e.status,completed:e.completed,duration:e.duration,startTime:e.startTime,public:e.public===!0})),...a?{provenance:a}:{},visibility:o,url:H9(n,t.baseUrl)}}}),F9({name:`wod_note_upsert`,title:`Create or Update Note`,description:"Create a new workout/reference Note or update an existing editable Note with full block-revision pinning, effort/equipment indexing, and optimistic concurrency (`expectedSourceRevision`).",tier:1,domain:`note`,annotations:{title:`Create or Update Note`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({noteId:G().optional().describe(`Existing Note ID to update, or omit to create a new Note.`),title:G().optional().describe(`Note title (defaults to # H1 heading in content).`),content:G().min(1).describe(`Full Markdown document or Whiteboard Script body.`),sport:G().optional().describe(`Optional sport fence tag when passing bare Whiteboard Script.`),expectedSourceRevision:se().int().min(0).optional().describe(`Optimistic concurrency guard: pass the current sourceRevision from wod_note_get when updating.`),notebookId:G().optional().describe(`Optional user Notebook ID/slug to assign this Note into (omit for unfiled/existing memberships).`),journalDate:G().optional().describe(`Optional YYYY-MM-DD or "today" to place the Note on that Journal calendar day.`)}),cliEquivalent:`wod note save <file|-> --json`,async execute(e,t){let n=R9(e.content,e.sport,e.title),r=await V9(t.storage,{noteId:e.noteId,title:e.title,rawContent:n,expectedSourceRevision:e.expectedSourceRevision,notebookId:e.notebookId,journalDate:e.journalDate});return await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`block_efforts`,`block_equipment`,`tags`,`note_tags`,`page`,`page_notes`,`notebook_links`]),{id:r.note.id,noteId:r.note.id,title:r.note.title,created:r.created,sourceRevision:r.note.sourceRevision,blockCount:r.blockCount,effortSlugs:r.effortSlugs,equipmentSlugs:r.equipmentSlugs,tags:r.tagLabels,url:H9(r.note,t.baseUrl)}}}),F9({name:`wod_note_clone`,title:`Clone Note with Provenance`,description:"Clone any Note (especially read-only Seed or Feed workouts) into a writable user Notebook or Journal day while recording structured upstream `NoteProvenance`.",tier:1,domain:`note`,annotations:{title:`Clone Note`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:yi({sourceNoteId:G().min(1).describe(`Source Note ID (including read-only Seed/Feed Notes) to clone.`),targetNotebookId:G().optional().describe(`Target writable user Notebook ID/slug (defaults to "notebook/journal").`),title:G().optional().describe(`Optional title override for the cloned Note.`),journalDate:G().optional().describe(`Optional YYYY-MM-DD or "today" to pin the clone onto a Journal day.`)}),cliEquivalent:`wod note clone <sourceNoteId> --notebook <slug> --json`,async execute(e,t){let n=await t.storage.readonly(`notes`).get(e.sourceNoteId);if(!n)throw Error(`Source Note not found: ${e.sourceNoteId}`);let r=Ps(e.targetNotebookId??`notebook/journal`);if(js(r))throw Error(`Target Notebook '${r}' is read-only.`);let i=Date.now(),a=L9(),o=vb(n)[0],s=Bw(n,o,i),c={...(await V9(t.storage,{noteId:a,title:e.title??n.title,rawContent:n.rawContent,notebookId:r,journalDate:e.journalDate,tags:(n.tags??[]).map(e=>({label:e})),now:i})).note,sourceId:n.id,provenance:s};return await t.storage.readwrite(`notes`).put(c),r!==`notebook/journal`&&await rw(t.storage,{noteId:a,notebookIds:[r]}),await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`notebook_links`,`page`,`page_notes`]),{id:c.id,noteId:c.id,title:c.title,sourceRevision:c.sourceRevision,targetNotebookId:r,provenance:s,url:H9(c,t.baseUrl)}}}),F9({name:`wod_note_delete`,title:`Delete Note`,description:`Permanently delete a Note and detach its projections, tag links, and calendar placements (Tier 2 destructive — requires user confirmation or matching confirmId).`,tier:2,domain:`note`,annotations:{title:`Delete Note`,readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({noteId:G().min(1).describe(`ID of the Note to delete.`),confirmId:G().optional().describe(`For non-interactive MCP/CLI calls, repeat the exact noteId to confirm deletion.`)}),cliEquivalent:`wod note delete <noteId> --yes <noteId> --json`,async execute(e,t){let n=await t.storage.readonly(`notes`).get(e.noteId);if(!n)return{deleted:!1,noteId:e.noteId,reason:`not_found`};await I9(t,{action:`wod_note_delete`,targetId:e.noteId,summary:`Delete Note "${n.title||e.noteId}" (${e.noteId})`},e.confirmId);let r=await twe(t.storage,e.noteId);return r&&await t.onMutated?.([`notes`,`block_index`,`block_efforts`,`block_equipment`,`note_tags`,`page_notes`,`notebook_links`,`meta`]),{deleted:r,noteId:e.noteId,title:n.title}}})],fwe=[F9({name:`wod_schedule_list`,title:`List Scheduled Workouts`,description:"List M:N ScheduleItem instances by date range (`from`/`to`) or for a specific Note ID.",tier:0,domain:`journal`,annotations:{title:`List Scheduled Workouts`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({from:G().optional().describe(`Start date in YYYY-MM-DD format (inclusive, or "today").`),to:G().optional().describe(`End date in YYYY-MM-DD format (inclusive, or "today").`),noteId:G().optional().describe(`Optional Note ID to list scheduled dates for one workout.`)}),cliEquivalent:`wod schedule list --json`,async execute(e,t){let n;if(e.noteId){if(n=await tT(t.storage,e.noteId),e.from){let t=z9(e.from);n=n.filter(e=>e.date>=t)}if(e.to){let t=z9(e.to);n=n.filter(e=>e.date<=t)}}else if(e.from||e.to){let r=z9(e.from??e.to),i=z9(e.to??e.from);n=await eT(t.storage,r,i)}else n=(await t.storage.readonly(`schedule_items`).getAll()).sort((e,t)=>e.date.localeCompare(t.date)||(e.position??0)-(t.position??0));let r=[...new Set(n.map(e=>e.noteId))],i=await t.storage.readonly(`notes`).getMany(r),a=new Map;return i.forEach((e,t)=>{e&&a.set(r[t],e.title)}),{totalCount:n.length,items:n.map(e=>({...e,noteTitle:a.get(e.noteId)??e.noteId}))}}}),F9({name:`wod_schedule_add`,title:`Schedule Workout onto Day`,description:`Link an existing Note onto a Journal calendar date via a ScheduleItem (M:N link-first scheduling without cloning user Notes or forcing notebook/journal).`,tier:1,domain:`journal`,annotations:{title:`Schedule Workout`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:yi({noteId:G().min(1).describe(`Canonical Note ID to schedule onto a calendar day.`),date:G().optional().describe(`Calendar date YYYY-MM-DD or "today" (defaults to "today").`),slot:G().optional().describe(`Optional slot badge such as "AM", "PM", or "Warmup".`),position:se().int().optional().describe(`Optional ordering index within the day.`),notes:G().optional().describe(`Optional scaling or session intent notes for this scheduled instance.`)}),cliEquivalent:`wod schedule add <noteId> --date YYYY-MM-DD --json`,async execute(e,t){let n=z9(e.date),r=await Xw(t.storage,{noteId:e.noteId,date:n,...e.slot===void 0?{}:{slot:e.slot},...e.position===void 0?{}:{position:e.position},...e.notes===void 0?{}:{notes:e.notes}});return await t.onMutated?.([`schedule_items`,`notes`]),{item:r}}}),F9({name:`wod_schedule_batch`,title:`Batch Schedule Workouts`,description:`Schedule one or more existing Notes across target calendar dates atomically via ScheduleItem links.`,tier:1,domain:`journal`,annotations:{title:`Batch Schedule Workouts`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:yi({items:me(yi({noteId:G().min(1),date:G().describe(`Calendar date YYYY-MM-DD or "today".`),slot:G().optional(),position:se().int().optional(),notes:G().optional()})).min(1).describe(`List of Note + date pairs to schedule atomically.`)}),cliEquivalent:`wod schedule batch --json`,async execute(e,t){let n=await Zw(t.storage,e.items.map(e=>({noteId:e.noteId,date:z9(e.date),...e.slot===void 0?{}:{slot:e.slot},...e.position===void 0?{}:{position:e.position},...e.notes===void 0?{}:{notes:e.notes}})));return await t.onMutated?.([`schedule_items`,`notes`]),{scheduledCount:n.length,items:n}}}),F9({name:`wod_schedule_update`,title:`Update Scheduled Workout`,description:"Reschedule, reorder, or update status (`planned`, `completed`, `moved`, `skipped`) on a ScheduleItem.",tier:1,domain:`journal`,annotations:{title:`Update Scheduled Workout`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({scheduleItemId:G().min(1).describe(`ScheduleItem ID to update.`),date:G().optional().describe(`New calendar date YYYY-MM-DD or "today".`),status:Qt([`planned`,`completed`,`moved`,`skipped`]).optional().describe(`Updated schedule status.`),slot:G().optional().describe(`Updated slot label.`),position:se().int().optional().describe(`Updated intra-day ordering index.`),notes:G().optional().describe(`Updated intent or scaling notes.`)}),cliEquivalent:`wod schedule update <scheduleItemId> --json`,async execute(e,t){let n=await Qw(t.storage,e.scheduleItemId,{...e.date===void 0?{}:{date:z9(e.date)},...e.status===void 0?{}:{status:e.status},...e.slot===void 0?{}:{slot:e.slot},...e.position===void 0?{}:{position:e.position},...e.notes===void 0?{}:{notes:e.notes}});return await t.onMutated?.([`schedule_items`]),{item:n}}}),F9({name:`wod_schedule_remove`,title:`Unschedule Workout Instance`,description:`Remove a single ScheduleItem from a calendar day while leaving the canonical Note and recorded Sessions intact.`,tier:1,domain:`journal`,annotations:{title:`Unschedule Workout`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({scheduleItemId:G().min(1).describe(`ScheduleItem ID to remove from the calendar.`)}),cliEquivalent:`wod schedule remove <scheduleItemId> --json`,async execute(e,t){return await $w(t.storage,e.scheduleItemId),await t.onMutated?.([`schedule_items`]),{removed:!0,scheduleItemId:e.scheduleItemId}}})];function W9(e,t=[]){for(let n of e.metrics??[])(n.value===`?`||n.origin===`collectible`)&&t.push({...e.id===void 0?{}:{id:e.id},text:e.raw??``,metricType:n.type});for(let n of e.children??[])W9(n,t);return t}var pwe=[F9({name:`wod_parse_script`,title:`Parse Whiteboard Script`,description:"Validate Whiteboard Script syntax, inspect parsed statements, typed metrics, unresolved choices, and collectible `?` placeholders. Defaults to dry-run (`save: false`); pass `save: true` to persist as a Note.",tier:0,domain:`script`,annotations:{title:`Parse Whiteboard Script`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({source:G().min(1).describe("Whiteboard Script body OR full Markdown document containing ```time / ```wod blocks."),sport:G().optional().describe(`Optional sport fence dialect override (e.g. "crossfit", "climbing", "running").`),save:Gt().optional().describe(`Default false (dry-run syntax & metric inspection). Set true to persist as a Note.`),noteId:G().optional().describe(`Optional target Note ID when save=true.`),title:G().optional().describe(`Optional Note title when save=true.`),notebookId:G().optional().describe(`Optional user Notebook slug/ID when save=true.`)}),cliEquivalent:`wod parse - --no-save --json`,async execute(e,t){let n=await EC(t.storage,{...e.notebookId?{notebookId:e.notebookId}:{}}).catch(()=>void 0),r=Gs(e.source,{registeredWidgets:Us}).filter(e=>e.scriptBlock),i=Gu({...n?{references:n.referenceIndex,tags:n.tagIndex}:{}}),a=(r.length>0?r.map((t,n)=>({index:n,sport:e.sport??t.scriptBlock?.sport,dialect:t.scriptBlock?.dialect??`time`,body:t.scriptBlock.content})):[{index:0,sport:e.sport,dialect:`time`,body:e.source}]).map(e=>{let t=i.read(e.body,e.sport),n=Yx(t),r=Ah(t.statements).map(e=>({statementIndex:e.statementIndex,statementId:e.statementId,choice:e.choice})),a=W9(n);return{index:e.index,dialect:e.dialect,...e.sport?{sport:e.sport}:{},valid:(t.errors?.length??0)===0,errors:t.errors??[],statementCount:t.statements.length,tree:n,unresolvedChoices:r,collectibles:a}}),o=a.every(e=>e.valid),s;if(e.save&&o){let n=R9(e.source,e.sport,e.title),r=await V9(t.storage,{noteId:e.noteId,title:e.title,rawContent:n,notebookId:e.notebookId});await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`block_efforts`,`block_equipment`]),s={noteId:r.note.id,title:r.note.title,sourceRevision:r.note.sourceRevision,created:r.created}}return{valid:o,blockCount:a.length,blocks:a,...s?{savedNote:s}:{}}}})];function mwe(e,t){if(!t||Object.keys(t).length===0)return e;let n=Object.entries(t),r=e;for(let[e,t]of n){let n=String(t);if(e===`?`||e==="default")r=r.replace(/\?/g,n);else{let t=RegExp(`\\?\\s*${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}\\b`,`gi`);r=t.test(r)?r.replace(t,`${n} ${e}`):r.replace(/\?/,n)}}return r}var hwe=F9({name:`wod_session_run_headless`,title:`Run Workout Session Headlessly`,description:"Execute a workout block through the headless JIT compiler and runtime state machine, recording a pinned `Session` and derived `EventRecord`s in storage. Automatically clones read-only Seed/Feed Notes into `notebook/journal`.",tier:1,domain:`session`,annotations:{title:`Run Workout Headlessly`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:yi({noteId:G().optional().describe(`Existing Note ID to execute (read-only Seed/Feed Notes pin one immutable copy on first run).`),blockId:G().optional().describe("Optional workout block ID on `noteId` (defaults to first wod block)."),source:G().optional().describe("Inline Whiteboard Script or Markdown to persist & run when `noteId` is not supplied."),title:G().optional().describe("Optional Note title when running inline `source`."),sport:G().optional().describe(`Optional sport dialect override.`),journalDate:G().optional().describe(`Optional YYYY-MM-DD or "today" attributed Session calendar date.`),scheduleItemId:G().optional().describe(`Optional ScheduleItem ID that triggered this workout run.`),collectibles:Ne(G(),yn([G(),se()])).optional().describe('Optional values for collectible `?` metrics (e.g. `{ "lb": 185, "reps": 12 }`).'),stepAdvanceMs:se().int().min(100).max(36e5).optional().describe(`Simulated clock advance per step in milliseconds (default 10000).`),maxSteps:se().int().min(1).max(5e3).optional().describe(`Safety cap on execution steps (default 500).`),public:Gt().optional().describe(`Mark the recorded Session public for Feed publication.`)}),cliEquivalent:`wod run <file|--note id> --json`,async execute(e,t){let n=e.noteId;if(!n){if(!e.source?.trim())throw Error("Provide either `noteId` or inline `source` to execute a workout session.");let r=R9(e.source,e.sport,e.title);n=(await V9(t.storage,{title:e.title,rawContent:r,journalDate:e.journalDate,type:`journal`})).note.id}let r=Date.now(),i=await Lw(t.storage,{noteId:n,blockId:e.blockId,journalDate:e.journalDate,...e.scheduleItemId?{scheduleItemId:e.scheduleItemId}:{},startedAt:r}),a=mwe(Gs(i.revision.rawContent,{registeredWidgets:Us}).find(e=>e.scriptBlock)?.scriptBlock?.content??i.revision.rawContent,e.collectibles),o=await EC(t.storage,{note:i.note}).catch(()=>void 0),s=e.sport??i.revision.sport,c=Gu({...o?{references:o.referenceIndex,tags:o.tagIndex}:{}}).read(a,s);if(c.errors&&c.errors.length>0)throw Error(`Whiteboard Script syntax error: ${c.errors.map(e=>e.message).join(`; `)}`);let l=vf(new Date(r)),u=new ep,d=new ah,f=mf(new Date(r)),p=new Wf(c,Fh(),{stack:u,clock:l,eventBus:d},{},f),{engine:m,analyticsContext:h}=kh({id:i.session.blockId,content:a,statements:c.statements,sport:s,version:i.session.blockVersion,startLine:0,endLine:0,dialect:i.revision.dialect??`time`,state:`idle`,createdAt:r});p.analyticsContext=h,p.setAnalyticsEngine(m);let g=[];p.subscribeToOutput(e=>{g.push(e)}),p.do(new sh),u.current?.key.toString().startsWith(`waiting-to-start`)&&p.handle(new Nh(void 0,{nowMs:()=>l.currentDate.getTime(),now:()=>l.currentDate}));let _=e.stepAdvanceMs??1e4,v=e.maxSteps??500,y=0;for(;u.count>0&&y<v;)l.advance(_),p.handle(new Nh(void 0,{nowMs:()=>l.currentDate.getTime(),now:()=>l.currentDate})),y+=1;let b=u.count===0,x=l.currentDate.getTime();p.dispose();let S=g.map(Gh),C={noteId:i.session.noteId,resultId:i.session.id,blockId:i.session.blockId,blockVersion:i.session.blockVersion,...i.session.blockContentId?{blockContentId:i.session.blockContentId}:{},...i.session.pageId?{pageId:i.session.pageId}:{},origin:i.session.origin,workoutTimestamp:x},w=ob(S,C),T=sb(S,C),E=[...w,...T],D={...i.session,sessionDate:i.session.sessionDate??Hw(r),status:b?`completed`:`in-progress`,endTime:x,duration:Math.max(0,x-r),completed:b,...e.public===void 0?{}:{public:e.public}};return await t.storage.transaction([`sessions`,`events`,`notebook_links`,`schedule_items`],`readwrite`,async e=>{await e.readwrite(`sessions`).put(D);let t=(D.notebookIds??[]).map(e=>({id:ZC(Ps(e),`session`,D.id),notebookId:Ps(e),targetKind:`session`,targetId:D.id,noteId:D.noteId,createdAt:D.createdAt}));if(t.length>0&&await e.readwrite(`notebook_links`).putMany(t),D.scheduleItemId)try{let t=e.readwrite(`schedule_items`),n=await t.get(D.scheduleItemId);n&&n.status!==`completed`&&await t.put({...n,status:`completed`,updatedAt:x})}catch{}E.length>0&&await e.readwrite(`events`).putMany(E)}),e.public!==void 0&&await uw(t.storage,D.id,e.public),await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`sessions`,`events`,`page`,`page_notes`,`notebook_links`]),{sessionId:D.id,noteId:D.noteId,blockId:D.blockId,blockVersion:D.blockVersion,clonedFromReadOnly:i.clonedFromReadOnly,pinnedExternalWorkout:i.pinnedExternalWorkout,...i.upstreamNoteId?{upstreamNoteId:i.upstreamNoteId}:{},completed:b,stepsExecuted:y,durationMs:D.duration,eventCount:w.length,summaryCount:T.length}}}),gwe=F9({name:`wod_session_list`,title:`List Recorded Sessions`,description:`List recorded workout Sessions ordered newest-first, optionally filtered by Note ID.`,tier:0,domain:`session`,annotations:{title:`List Sessions`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({noteId:G().optional().describe(`Filter Sessions by owning Note ID.`),completedOnly:Gt().optional().describe(`Filter to completed Sessions only.`),limit:se().int().min(1).max(200).optional().describe(`Max Sessions to return (default 50).`)}),cliEquivalent:`wod session list --json`,async execute(e,t){let n=e.limit??50,r;if(e.noteId)try{r=await t.storage.readonly(`sessions`).getAllFromIndex(`by-note`,e.noteId)}catch{r=(await t.storage.readonly(`sessions`).getAll()).filter(t=>t.noteId===e.noteId)}else r=await t.storage.readonly(`sessions`).getAll();e.completedOnly&&(r=r.filter(e=>e.completed)),r.sort((e,t)=>t.startTime-e.startTime);let i=[...new Set(r.slice(0,n).map(e=>e.noteId))],a=await t.storage.readonly(`notes`).getMany(i),o=new Map;return a.forEach((e,t)=>{e&&o.set(i[t],e.title)}),{totalCount:r.length,sessions:r.slice(0,n).map(e=>({id:e.id,noteId:e.noteId,noteTitle:o.get(e.noteId)??e.noteId,blockId:e.blockId,blockVersion:e.blockVersion,status:e.status,completed:e.completed,duration:e.duration,startTime:e.startTime,endTime:e.endTime,public:e.public===!0}))}}}),_we=F9({name:`wod_session_get`,title:`Get Session Telemetry`,description:"Read a recorded workout Session along with its pinned `BlockRevision` and derived event/summary telemetry rows.",tier:0,domain:`session`,annotations:{title:`Get Session Telemetry`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({sessionId:G().min(1).describe(`Session ID to inspect.`)}),cliEquivalent:`wod session get <sessionId> --json`,async execute(e,t){let n=await t.storage.readonly(`sessions`).get(e.sessionId);if(!n)throw Error(`Session not found: ${e.sessionId}`);let[r,i,a]=await Promise.all([t.storage.readonly(`notes`).get(n.noteId),t.storage.readonly(`block_revisions`).get([n.noteId,n.blockId,n.blockVersion]),t.storage.readonly(`events`).getAll()]),o=a.filter(e=>e.resultId===n.id).sort((e,t)=>e.timestamp-t.timestamp);return{session:n,noteTitle:r?.title,pinnedRevision:i??null,eventCount:o.filter(e=>e.grain===`event`).length,summaryCount:o.filter(e=>e.grain===`summary`).length,events:o}}}),vwe=F9({name:`wod_session_delete`,title:`Delete Recorded Session`,description:`Permanently delete a recorded workout Session and its telemetry events (Tier 2 destructive — requires confirmation).`,tier:2,domain:`session`,annotations:{title:`Delete Session`,readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({sessionId:G().min(1).describe(`Session ID to delete.`),confirmId:G().optional().describe(`For non-interactive MCP/CLI calls, repeat the exact sessionId to confirm deletion.`)}),cliEquivalent:`wod session delete <sessionId> --yes <sessionId> --json`,async execute(e,t){let n=await t.storage.readonly(`sessions`).get(e.sessionId);if(!n)return{deleted:!1,sessionId:e.sessionId,reason:`not_found`};await I9(t,{action:`wod_session_delete`,targetId:e.sessionId,summary:`Delete workout Session ${e.sessionId} on Note ${n.noteId}`},e.confirmId);let r=await nwe(t.storage,e.sessionId);return r&&await t.onMutated?.([`sessions`,`events`,`notebook_links`]),{deleted:r,sessionId:e.sessionId}}}),ywe=[hwe,gwe,_we,F9({name:`wod_session_attribute`,title:`Attribute Session to Day or Plan`,description:`Associate a recorded workout Session with a specific Journal civil date and/or pair or unlink it with a planned ScheduleItem.`,tier:1,domain:`session`,annotations:{title:`Attribute Session`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({sessionId:G().min(1).describe(`Session ID to attribute to a calendar date or ScheduleItem.`),sessionDate:G().optional().describe(`Attributed Journal date (YYYY-MM-DD).`),scheduleItemId:G().nullable().optional().describe(`ScheduleItem ID to link this Session with, or null to unlink into an ad-hoc Session.`)}),cliEquivalent:`wod session attribute <sessionId> --json`,async execute(e,t){let n=await nT(t.storage,{sessionId:e.sessionId,...e.sessionDate===void 0?{}:{sessionDate:e.sessionDate},...e.scheduleItemId===void 0?{}:{scheduleItemId:e.scheduleItemId}});return await t.onMutated?.([`sessions`,`schedule_items`]),{session:n}}}),vwe],bwe=F9({name:`wod_validate_wql`,title:`Validate & Inspect WQL Query`,description:"Parse a WQL string without executing it. Returns syntax validity, query family (find, aggregate, pipeline), normalized WQL string, and the allowed filter keys and `by {}` grouping dimensions for that plane.",tier:0,domain:`wql`,annotations:{title:`Validate WQL Query`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({query:G().describe(`WQL query string to validate and inspect (e.g. ":note{notebook:journal} last 7d" or "sum:volume by {effort}").`),targetHint:G().optional().describe(`Optional target plane to list valid filter keys & grouping dimensions for (note, session, effort, equipment, tag, feed, block, event).`)}),cliEquivalent:`wod query "<wql>" --format json`,async execute(e){let t=t_(e.query),n=!t.error,r=Hg(t)?`pipeline`:Bg(t)?`find`:`aggregate`,i=e.targetHint??(Bg(t)?t.target:Vg(t)?`event`:`note`),a=r===`find`?`find`:`aggregate`;return{valid:n,...t.error?{error:t.error}:{},family:r,target:i,normalized:n?r_(e.query):e.query,allowedTargets:[...tg],allowedAggregators:[...Jh],allowedRollupPeriods:[...lg],validFilterKeys:[...Cg(i,a)],validGroupingDimensions:[...wg(i,a)]}}}),xwe=[F9({name:`wod_query_wql`,title:`Execute WQL Query`,description:"Run any WQL find (`:note`, `:session`, `:effort`, `:equipment`, `:tag`, `:feed`, `:block`), aggregate (`sum:volume`, `max:weight`, `count:sessions`), or pipeline query against the active WOD Wiki storage.",tier:0,domain:`wql`,annotations:{title:`Execute WQL Query`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:yi({query:G().min(1).describe(`WQL query expression (e.g. ":note{notebook:journal}", ":session last 30d", "sum:volume by {week}").`),preferredUnit:G().optional().describe(`Optional display unit conversion preference (e.g. "lb", "kg", "m", "mi").`),limit:se().int().min(1).max(500).optional().describe(`Maximum rows/items to return in the response payload (default 100).`)}),cliEquivalent:`wod query '<wql>' --format json`,async execute(e,t){let n=t_(e.query);if(n.error)throw Error(`WQL Syntax Error in "${e.query}": ${n.error}. Call wod_validate_wql to inspect valid targets and filter keys.`);let r=ewe(t.storage),i=e.limit??100;if(Hg(n)){let t=await r.runPipeline(e.query,{preferredUnit:e.preferredUnit});return{kind:`pipeline-result`,query:e.query,result:t}}if(Bg(n)){let t=await r.runFind(n);return Array.isArray(t.runs)?{kind:`rows-result`,target:n.target,query:e.query,totalRuns:t.runs.length,totalCount:t.runs.length,runs:t.runs.slice(0,i),truncated:t.runs.length>i}:Array.isArray(t.efforts)?{kind:`find-result`,target:n.target,query:e.query,totalCount:t.efforts.length,items:t.efforts.slice(0,i),truncated:t.efforts.length>i}:t.table?{kind:`find-result`,target:n.target,query:e.query,columns:t.table.columns,totalCount:t.table.rows.length,items:t.table.rows.slice(0,i),truncated:t.table.rows.length>i}:n.target===`block`?{kind:`find-result`,target:n.target,query:e.query,totalCount:t.blocks.length,items:t.blocks.slice(0,i),truncated:t.blocks.length>i}:{kind:`find-result`,target:n.target,query:e.query,totalCount:t.notes.length,items:t.notes.slice(0,i),truncated:t.notes.length>i}}let a=await r.runQuery(e.query,{preferredUnit:e.preferredUnit});return{kind:`query-result`,query:e.query,result:a}}}),bwe],G9=[...pwe,...xwe,...dwe,...cwe,...fwe,...lwe,...ywe,...owe,...swe];new Map(G9.map(e=>[e.name,e]));async function K9(){if(typeof window>`u`||typeof window.requestAnimationFrame!=`function`){await new Promise(e=>setTimeout(e,0));return}await new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}async function q9(e=2e3){let t=Date.now()+e;for(await new Promise(e=>setTimeout(e,200));WX()&&Date.now()<t;)await new Promise(e=>setTimeout(e,25));await K9()}var Swe=yi({includeSampleEntries:Gt().optional().describe(`Include up to 50 unbatched stream entries when on a stream route (default true).`)}),Cwe=yi({path:G().min(1).describe(`Internal app path (with optional ?query and #hash) to navigate to, e.g. "/journal", "/day/2026-11-11", "/note/<id>", "/notebooks", "/dashboards".`),replace:Gt().optional().describe(`Replace current history entry instead of pushing.`)}),wwe=yi({action:Qt([`status`,`disconnect`]).describe(`Inspect active Chromecast/receiver session status or disconnect an active session.`)}),Twe=yi({query:G().optional().describe(`WQL query string to apply to the mounted stream view (e.g. ":note{tags:benchmark}").`),layout:Qt([`cards`,`rows`,`feed`,`agenda`,`planner`]).optional().describe(`Switch stream layout mode and sync ?layout= in URL.`),groupBy:G().nullable().optional().describe(`Grouping dimension (e.g. "date", "week", "notebook") or null to clear.`),month:G().regex(/^\d{4}-\d{2}$/,`Expected YYYY-MM calendar month`).optional().describe(`Calendar month anchor in YYYY-MM format (syncs ?month= on calendar/journal views).`),overlayMode:Qt([`all`,`planned`,`logged`]).optional().describe("Calendar schedule/session overlay filter (`all`, `planned`, or `logged`)."),resetToDefault:Gt().optional().describe(`Undo custom stream filter and restore the route default WQL query.`)}),Ewe=yi({operation:Qt([`read`,`replace`,`append`,`undo`]).describe(`Read live editor buffer, replace document content, append Markdown/workout block, or undo last edit.`),content:G().optional().describe(`Markdown or Whiteboard Script content for replace / append operations.`),save:Gt().optional().describe(`Flush and persist the draft to storage immediately after applying the edit (default false).`)}),Dwe=yi({blockId:G().optional().describe("Optional workout block ID in the active Note editor (defaults to first ```time block)."),autoStart:Gt().optional().describe(`Automatically start the timer after mounting the workout clock (default true).`)}),Owe=yi({command:Qt([`next`,`playback`,`stop-request`,`stop-confirm`,`stop-cancel`,`values-open`,`entry-cancel`,`entry-save`,`entry-skip`,`reps-adjust`,`reps-set`,`reps-select`,`choice-select`,`ready-start`,`dismiss`,`status`]).describe(`Live workout clock command to dispatch (or "status" to read current ClockSnapshot).`),fieldId:G().optional().describe(`Target fieldId for entry-save, entry-skip, or choice-select.`),value:se().optional().describe(`Numeric value for entry-save or reps-set.`),occurrenceId:G().optional().describe(`Rep occurrenceId for reps-adjust, reps-set, or reps-select.`),delta:yn([on(1),on(-1)]).optional().describe(`+1 or -1 delta for reps-adjust.`),index:se().int().min(0).optional().describe(`Zero-based alternative index for choice-select.`)}),kwe=yi({action:Qt([`get`,`set`]).describe(`Read current Playground UI preferences ("get") or update preferences ("set").`),theme:Qt([`light`,`dark`,`system`]).optional().describe("Color theme preference (`light`, `dark`, or `system`)."),audioEnabled:Gt().optional().describe(`Enable or mute workout timer audio cues.`),debugMode:Gt().optional().describe(`Enable or disable global runtime debug mode.`),analyticsUnit:Qt([`kg`,`lb`]).optional().describe("Preferred display unit for analytics charts (`kg` or `lb`)."),leftDrawerOpen:Gt().optional().describe(`Open or close the primary navigation drawer on mobile/tablet.`),rightDrawerOpen:Gt().optional().describe(`Open or close the secondary L3 context drawer on mobile/tablet.`)}),Awe=yi({query:G().optional().describe('WQL aggregate or find query string to set on the Metric Explorer (`/dashboards`), e.g. "sum:totalVolume{} by {week}".'),submit:Gt().optional().describe("Execute/submit the query immediately (default true when `query` is provided)."),weeks:yn([on(4),on(8),on(16)]).optional().describe("Analytics lookback range in weeks (`4`, `8`, or `16`)."),openSaveDialog:Gt().optional().describe(`Open the "Save to dashboard" dialog for the active query.`),openQuerySettings:Gt().optional().describe("Open the surface query settings dialog on `/dashboards`.")}),jwe=yi({action:Qt([`get_state`,`open_popover`,`close_popover`,`open_drawer`,`close_drawer`,`toggle_drawer`]).describe(`Inspect cursor line tokens & lint fixes, open/close the anchored Option A popover, or toggle the Option B right inspector drawer.`),mode:Qt([`token`,`add`,`block`,`wiki`,`prose-tag`,`query`,`markdown`]).optional().describe(`Optional inspector view mode when opening the popover or drawer.`),tokenIndex:se().int().min(0).optional().describe(`Zero-based index of the token on the current cursor line to target.`)}),Mwe=yi({activeTab:Qt([`splits`,`movement`,`compare`,`raw`]).optional().describe(`Switch the active results workbook tab.`),mobileViewMode:Qt([`grid`,`cards`]).optional().describe("Switch the mobile results presentation mode (`grid` or `cards`)."),sourceDrawerOpen:Gt().optional().describe(`Open or close the Pinned Workout Source & History drawer.`),openAddToDashboard:Gt().optional().describe(`Open the 2-step Add to Dashboard promotion sheet for the session.`),closeModals:Gt().optional().describe(`Close any open source drawer or dashboard dialog on the results workbench.`)}),Nwe=yi({action:Qt([`status`,`open`,`close`]).describe(`Read active Entity Peek Drawer state ("status"), open a preview for a target entity ("open"), or dismiss it ("close").`),kind:Qt([`effort`,`equipment`,`tag`,`unrecognized`,`note`,`notebook`,`day`]).optional().describe(`Target entity kind when action="open".`),slug:G().optional().describe(`Canonical slug when kind is "effort", "equipment", or "notebook".`),label:G().optional().describe(`Tag label (required when kind="tag") or optional display label for effort/equipment.`),tagType:G().optional().describe(`Optional tag category/type when kind="tag" (e.g. "domain", "format", "general").`),term:G().optional().describe(`Unrecognized term to quick-define when kind="unrecognized".`),noteId:G().optional().describe(`Target Note ID when kind="note".`),title:G().optional().describe(`Optional display title hint when kind is "note" or "notebook".`),date:G().regex(/^\d{4}-\d{2}-\d{2}$/,`Expected YYYY-MM-DD civil date`).optional().describe(`Civil date (YYYY-MM-DD) when kind="day".`)});function Pwe(e){switch(e.kind){case`effort`:if(!e.slug?.trim())throw Error(`'slug' is required when kind="effort".`);return{kind:`effort`,slug:e.slug.trim(),...e.label?.trim()?{label:e.label.trim()}:{}};case`equipment`:if(!e.slug?.trim())throw Error(`'slug' is required when kind="equipment".`);return{kind:`equipment`,slug:e.slug.trim(),...e.label?.trim()?{label:e.label.trim()}:{}};case`tag`:if(!e.label?.trim())throw Error(`'label' is required when kind="tag".`);return{kind:`tag`,label:e.label.trim().replace(/^#/,``),...e.tagType?.trim()?{tagType:e.tagType.trim()}:{}};case`unrecognized`:if(!e.term?.trim())throw Error(`'term' is required when kind="unrecognized".`);return{kind:`unrecognized`,term:e.term.trim()};case`note`:if(!e.noteId?.trim())throw Error(`'noteId' is required when kind="note".`);return{kind:`note`,noteId:e.noteId.trim(),...e.title?.trim()?{title:e.title.trim()}:{}};case`notebook`:if(!e.slug?.trim())throw Error(`'slug' is required when kind="notebook".`);return{kind:`notebook`,slug:e.slug.trim(),...e.title?.trim()?{title:e.title.trim()}:{}};case`day`:if(!e.date?.trim())throw Error(`'date' is required when kind="day".`);return{kind:`day`,date:e.date.trim()};default:throw Error(`'kind' is required when action="open".`)}}function Fwe(){(0,K.useEffect)(()=>d7({name:`ui_peek_entity`,title:`Inspect, Open, or Close Entity Peek Drawer`,description:`Inspect, open, or close the 340px right-edge Entity Peek Drawer on the live UI.`,tier:1,scope:`editor-ui`}),[]),wr({name:`ui_peek_entity`,title:`Inspect, Open, or Close Entity Peek Drawer`,description:"Read active Entity Peek Drawer state (`status`), open a non-destructive 340px right-edge preview for an effort, equipment, tag, unrecognized term, note, notebook, or day (`open`), or dismiss the drawer (`close`). Mutually exclusive with the Whiteboard Token Inspector drawer.",inputSchema:Nwe,annotations:{title:`Inspect or Control Entity Peek Drawer`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=RX(),r=lX();if(e.action===`status`){let r=n?.getTarget()??null,i={ok:!0,open:r!==null,target:r};return f7({toolName:`ui_peek_entity`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),i}if(e.action===`close`){n?n.closePeek():r?.closePeek&&r.closePeek(),await K9();let i=RX()?.getTarget()??null,a={ok:!0,open:i!==null,target:i};return f7({toolName:`ui_peek_entity`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),a}let i=Pwe(e);if(n)try{n.openPeek(i)}catch(e){if(r?.peekEntity)r.peekEntity(i);else throw e}else if(r?.peekEntity)r.peekEntity(i);else throw Error(`No Entity Peek surface is currently mounted.`);await K9();let a=RX()?.getTarget()??i,o={ok:!0,open:a!==null,target:a};return f7({toolName:`ui_peek_entity`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),o}catch(n){throw f7({toolName:`ui_peek_entity`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}})}var Iwe=()=>(Fwe(),null),Lwe=()=>((0,K.useEffect)(()=>{let e=d7({name:`ui_editor_draft`,title:`Read, Edit, or Undo Live Note Editor Buffer`,description:`Inspect or modify the live CodeMirror 6 Note buffer.`,tier:1,scope:`editor-ui`}),t=d7({name:`ui_start_live_workout`,title:`Start Live Interactive Workout Timer`,description:`Start the live interactive workout clock from the active Note editor.`,tier:1,scope:`editor-ui`}),n=d7({name:`ui_editor_inspector`,title:`Inspect or Control Whiteboard Token Inspector & Drawer`,description:`Inspect cursor-line tokens or control the Option A popover and Option B drawer.`,tier:1,scope:`editor-ui`});return()=>{e(),t(),n()}},[]),wr({name:`ui_editor_draft`,title:`Read, Edit, or Undo Live Note Editor Buffer`,description:"Inspect or modify the live CodeMirror 6 Note buffer (`read`, `replace`, `append`, `undo`) with full undo support and optional immediate save (`save: true`).",inputSchema:Ewe,annotations:{title:`Edit Live Note Draft`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=lX();if(!n)throw Error(`No Note editor is currently mounted.`);if(e.operation===`read`){let e=n.getValue();return{operation:`read`,noteId:n.noteId??null,readonly:n.readonly,sourceRevision:n.sourceRevision??null,content:e,workoutBlockIds:n.getBlocks().map(e=>e.id)}}if(e.operation===`undo`){let e=n.undoEdit();return await K9(),{operation:`undo`,undone:e,content:n.getValue()}}if(!e.content)throw Error(`'content' is required when operation="${e.operation}".`);let r=n.getValue(),i=e.operation===`replace`?R9(e.content):`${r.trimEnd()}\n\n${R9(e.content)}`;await n.applyEdit(i,e.save===!0),await K9();let a=lX()??n,o={operation:e.operation,saved:e.save===!0,noteId:a.noteId??null,sourceRevision:a.sourceRevision??null,workoutBlockIds:a.getBlocks().map(e=>e.id),length:a.getValue().length};return f7({toolName:`ui_editor_draft`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify({operation:e.operation,save:e.save}).slice(0,120)}),o}catch(n){throw f7({toolName:`ui_editor_draft`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify({operation:e.operation}).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),wr({name:`ui_start_live_workout`,title:`Start Live Interactive Workout Timer`,description:"Launch the live interactive workout clock on screen from a workout block in the active Note editor so the human athlete and agent can co-drive the session via `ui_clock_control`.",inputSchema:Dwe,annotations:{title:`Start Live Workout Timer`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=lX();if(!n)throw Error(`No Note editor is currently mounted.`);let r=await n.startLiveWorkout(e.blockId,e.autoStart??!0);if(!r.started)throw Error(r.error??`Failed to start workout timer.`);let i=Date.now()+1500;for(;!e0()&&Date.now()<i;)await new Promise(e=>setTimeout(e,25));await K9();let a={started:!0,blockId:r.blockId??null,clock:e0()};return f7({toolName:`ui_start_live_workout`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),a}catch(n){throw f7({toolName:`ui_start_live_workout`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),wr({name:`ui_editor_inspector`,title:`Inspect or Control Whiteboard Token Inspector & Drawer`,description:"Read parsed cursor-line tokens and inline lint fixes, open or close the Option A anchored token inspector popover (`Alt+.`), or toggle the Option B right inspector drawer (`Ctrl+Alt+I` / `Cmd+Alt+I`).",inputSchema:jwe,annotations:{title:`Inspect or Control Token Inspector`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=lX();if(!n)throw Error(`No Note editor is currently mounted.`);if(e.action===`open_popover`)n.openTokenInspector?.({mode:e.mode,tokenIndex:e.tokenIndex});else if(e.action===`close_popover`)n.closeTokenInspector?.();else if(e.action===`open_drawer`)n.setInspectorDrawer?.(!0),(e.mode||e.tokenIndex!==void 0)&&n.openTokenInspector?.({mode:e.mode,tokenIndex:e.tokenIndex});else if(e.action===`close_drawer`)n.setInspectorDrawer?.(!1);else if(e.action===`toggle_drawer`){let e=n.getInspectorState?.()?.drawerOpen??!1;n.setInspectorDrawer?.(!e)}await K9();let r={ok:!0,inspector:n.getInspectorState?.()??null};return f7({toolName:`ui_editor_inspector`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),r}catch(n){throw f7({toolName:`ui_editor_inspector`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),Rwe=()=>((0,K.useEffect)(()=>d7({name:`ui_set_explorer_query`,title:`Set or Run Analytics Explorer WQL Query`,description:`Update or run WQL queries, week windows, or dialogs on the Metric Explorer (/dashboards).`,tier:1,scope:`explorer-ui`}),[]),wr({name:`ui_set_explorer_query`,title:`Set or Run Analytics Explorer WQL Query`,description:"Set or execute an aggregate or find WQL query on the Metric Explorer (`/dashboards`), change the week window (`4`, `8`, `16`), or open the Save-to-Dashboard / Query Settings dialogs.",inputSchema:Awe,annotations:{title:`Set Analytics Explorer Query`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=xX();if(!n)throw Error(`Metric Explorer (/dashboards) is not currently mounted.`);e.weeks!==void 0&&n.setWeeks(e.weeks),e.query===void 0?e.submit===!0&&n.submit():(n.setDraft(e.query),e.submit!==!1&&n.submit(e.query)),e.openSaveDialog&&n.openSaveDialog(),e.openQuerySettings&&n.openQuerySettings(),await q9();let r=xX()??n,i={draft:r.draft,submitted:r.submitted,weeks:r.weeks,saveReady:r.saveReady,loading:r.loading};return f7({toolName:`ui_set_explorer_query`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),i}catch(n){throw f7({toolName:`ui_set_explorer_query`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),zwe=()=>((0,K.useEffect)(()=>d7({name:`ui_clock_control`,title:`Control Live Workout Clock`,description:`Dispatch live clock commands to the active workout timer.`,tier:1,scope:`clock-ui`}),[]),wr({name:`ui_clock_control`,title:`Control Live Workout Clock`,description:"Inspect or dispatch commands (`next`, `playback`, `ready-start`, `entry-save`, `entry-skip`, `reps-adjust`, `reps-set`, `choice-select`, `stop-request`, `stop-confirm`, `dismiss`) to the active on-screen workout clock.",inputSchema:Owe,annotations:{title:`Control Live Workout Clock`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},async execute(e,t){let n=performance.now();try{let r=e0();if(!r)throw Error(`No live workout clock is currently mounted.`);if(e.command===`status`)return{accepted:!0,snapshot:r};if(e.command===`stop-confirm`){if(!await N9({action:`ui_clock_control:stop-confirm`,targetId:r.runId,summary:`Stop and end the active live workout timer early`},t))throw Error(`User declined early termination of the active workout timer.`);r.stopRequested||(n0(r.runId,{kind:`stop-request`}),await K9())}let i;switch(e.command){case`entry-save`:{let t=e.fieldId??r.entry?.fieldId;if(!t||typeof e.value!=`number`)throw Error("`entry-save` requires `value` (number) and an active or explicit `fieldId`.");i={kind:`entry-save`,fieldId:t,value:e.value};break}case`entry-skip`:{let t=e.fieldId??r.entry?.fieldId;if(!t)throw Error("`entry-skip` requires `fieldId`.");i={kind:`entry-skip`,fieldId:t};break}case`reps-adjust`:{let t=e.occurrenceId??r.selectedOccurrenceId??r.reps[0]?.occurrenceId;if(!t||e.delta!==1&&e.delta!==-1)throw Error("`reps-adjust` requires `occurrenceId` and `delta` (+1 or -1).");i={kind:`reps-adjust`,occurrenceId:t,delta:e.delta};break}case`reps-set`:{let t=e.occurrenceId??r.selectedOccurrenceId??r.reps[0]?.occurrenceId;if(!t||typeof e.value!=`number`)throw Error("`reps-set` requires `occurrenceId` and integer `value`.");i={kind:`reps-set`,occurrenceId:t,value:e.value};break}case`reps-select`:if(!e.occurrenceId)throw Error("`reps-select` requires `occurrenceId`.");i={kind:`reps-select`,occurrenceId:e.occurrenceId};break;case`choice-select`:{let t=e.fieldId??r.entry?.fieldId;if(!t||typeof e.index!=`number`)throw Error("`choice-select` requires `fieldId` and `index`.");i={kind:`choice-select`,fieldId:t,index:e.index};break}default:i={kind:e.command}}let a=n0((e0()??r).runId,i);await K9();let o={accepted:a,command:e.command,snapshot:e0()};return f7({toolName:`ui_clock_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-n),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),o}catch(t){throw f7({toolName:`ui_clock_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-n),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:t instanceof Error?t.message:String(t)}),t}}}),null),Bwe=()=>((0,K.useEffect)(()=>d7({name:`ui_results_control`,title:`Control Session Results Workbench`,description:"Switch tabs, toggle mobile grid/cards layout, open/close Source & History drawer, or open the Add-to-Dashboard sheet on `/results/:sessionId`.",tier:1,scope:`results-ui`}),[]),wr({name:`ui_results_control`,title:`Control Session Results Workbench`,description:"Control the mounted `/results/:sessionId` workbench (`activeTab`: splits|movement|compare|raw, `mobileViewMode`: grid|cards, `sourceDrawerOpen`, `openAddToDashboard`, `closeModals`).",inputSchema:Mwe,annotations:{title:`Control Session Results Workbench`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=DX();if(!n)throw Error(`No session results workbench is currently mounted.`);e.closeModals&&n.closeModals(),e.activeTab!==void 0&&n.setTab(e.activeTab),e.mobileViewMode!==void 0&&n.setMobileViewMode(e.mobileViewMode),e.sourceDrawerOpen!==void 0&&n.openSourceDrawer(e.sourceDrawerOpen),e.openAddToDashboard&&n.openAddToDashboard(),await K9();let r=DX()??n,i={resultId:r.resultId,activeTab:r.activeTab,mobileViewMode:r.mobileViewMode,sourceDrawerOpen:r.sourceDrawerOpen,addToDashboardOpen:r.addToDashboardOpen};return f7({toolName:`ui_results_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),i}catch(n){throw f7({toolName:`ui_results_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),Vwe=()=>((0,K.useEffect)(()=>d7({name:`ui_set_stream_query`,title:`Set Live Stream WQL Query or Layout`,description:`Update live WQL query, layout, grouping, calendar month, or overlay filter on the mounted stream view.`,tier:1,scope:`stream-ui`}),[]),wr({name:`ui_set_stream_query`,title:`Set Live Stream WQL Query or Layout`,description:"Update the live WQL query, layout (`cards`, `rows`, `feed`, `agenda`, `planner`), grouping, calendar `month` (`YYYY-MM`), or calendar `overlayMode` (`all`, `planned`, `logged`) on the currently mounted stream view, or pass `resetToDefault: true` to restore the route default query.",inputSchema:Twe,annotations:{title:`Set Live Stream Query`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=hX();if(!n)throw Error(`No stream view is currently mounted.`);e.resetToDefault?n.setQuery(n.defaultQuery):e.query!==void 0&&n.setQuery(e.query),e.layout!==void 0&&n.setLayout(e.layout),e.groupBy!==void 0&&n.setGroupBy(e.groupBy===null?void 0:e.groupBy),e.month!==void 0&&n.setMonth?.(e.month),e.overlayMode!==void 0&&n.setOverlayMode?.(e.overlayMode),await q9();let r=hX()??n,i=document.getElementById(`agent-view-state`)?.textContent,a=i?JSON.parse(i):null,o={route:r.route,query:r.query,layout:r.layout,groupBy:r.groupBy??null,month:r.month??null,overlayMode:r.overlayMode??null,totalUnbatchedCount:a?.stream?.totalUnbatchedCount??null};return f7({toolName:`ui_set_stream_query`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),o}catch(n){throw f7({toolName:`ui_set_stream_query`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),Hwe=_ee({allow:(e,t)=>!e.confirm||N9({action:`ui.${e.action}`,targetId:String(e.ref),summary:e.confirm},t)}),J9=Symbol(`wodWrappedExecuteTool`);function Y9(e){return typeof e!=`object`||!e?!1:`name`in e&&typeof e.name==`string`&&`origin`in e&&typeof e.origin==`string`&&`window`in e&&typeof e.window==`object`}function Uwe(e){return typeof e==`object`&&!!e&&`name`in e}function Wwe(e){let t=e.arguments??e.input??e.params??e.args;if(typeof t==`string`)try{return JSON.parse(t)}catch{return{}}return t??{}}function X9(e,t){let n=t??{};if(e===`ui_navigate`&&typeof n.path!=`string`&&typeof n.href==`string`){let e=n.href.trim();if(/^https?:\/\//i.test(e))try{let t=new URL(e);e=`${t.pathname}${t.search}${t.hash}`||`/`}catch{}return{...n,path:e}}return n}async function Z9(e,t,n){if(typeof t==`string`){let n=(await e()).find(e=>Y9(e)&&e.name===t);if(n)return n}if(Y9(n))return n;throw Error(typeof t==`string`?`executeTool: no registered tool named "${t}"`:`executeTool: expected a registered tool descriptor or a { name, arguments } envelope`)}function Q9(e){if(typeof e!=`object`||!e)return;let t=e,n=t.executeTool;if(typeof n!=`function`)return;let r;if(n[J9])r=n;else{let e=async()=>typeof t.getTools==`function`?t.getTools():typeof t.listTools==`function`?t.listTools():[],i=async(...r)=>{let[i,a]=r;if(r.length>=2&&Y9(i))return n.call(t,i,X9(i.name,a),r[2]);if(typeof i==`string`){let o=await Z9(e,i,void 0);return n.call(t,o,X9(i,a??{}),r[2])}if(Uwe(i)){let r=X9(i.name,Wwe(i)),a=await Z9(e,i.name,i);return n.call(t,a,r)}return n.apply(t,r)};i[J9]=!0,Object.defineProperty(t,"executeTool",{configurable:!0,writable:!0,value:i}),r=i}if(typeof t.callTool!=`function`||!t.callTool[J9]){let e=async(...e)=>r.apply(t,e);e[J9]=!0,Object.defineProperty(t,"callTool",{configurable:!0,writable:!0,value:e})}}var Gwe=({spec:e})=>((0,K.useEffect)(()=>d7({name:e.name,title:e.title,description:e.description,tier:e.tier,scope:`domain`}),[e]),wr({name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema,annotations:e.annotations,async execute(t,n){let r=performance.now(),i={storage:X.storage,baseUrl:typeof window<`u`?window.location.origin:``,feedLifecycle:{subscribe:async(e,t)=>{if(t?.notebookIds?.length){UI(e,!0);for(let n of t.notebookIds)GI(e,n,!0);await XF()}let n=t?.notebookIds?.length?await oV(e,{notebookIds:t.notebookIds,preserveSubscriptionState:!0}):await sV(e,{offlinePolicy:e===`core`?`offline-full`:`index-only`});return{sourceId:e,subscribed:!0,notebookIds:t?.notebookIds??null,synced:n!==`error`}},unsubscribe:async e=>{let{deleted:t}=await uV(e);return{sourceId:e,unsubscribed:!0,deletedNotes:t}},delete:async e=>{let{deleted:t}=await dV(e);return{sourceId:e,deleted:!0,deletedNotes:t}}},confirmDestructive:e=>N9(e,n),onMutated:async()=>{ZP(),await qq().catch(()=>{})}};try{let n=await e.execute(t,i);return await K9(),f7({toolName:e.name,timestamp:Date.now(),durationMs:Math.round(performance.now()-r),ok:!0,argsPreview:JSON.stringify(t??{}).slice(0,120)}),n}catch(n){throw f7({toolName:e.name,timestamp:Date.now(),durationMs:Math.round(performance.now()-r),ok:!1,argsPreview:JSON.stringify(t??{}).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),Kwe=()=>{let e=dt(),t=Qe(),n=OZ(),r=kZ(),i=KX(),a=_X(),o=CX(),s=PW(),c=dX(),l=BX(),u=kX(),d=(0,K.useSyncExternalStore)(t0,e0,()=>null),{theme:f,setTheme:p}=Co(),m=OB(),{isDebugMode:h,toggleDebugMode:g}=uT(),{unit:_,setUnit:v}=yO(typeof window<`u`?window.localStorage:void 0),{navState:y,dispatch:b}=MV();return(0,K.useEffect)(()=>{if(typeof navigator<`u`&&typeof document<`u`){let e=document,t=navigator;if(e.modelContext&&!t.modelContext)try{Object.defineProperty(navigator,"modelContext",{configurable:!0,enumerable:!0,get:()=>e.modelContext})}catch{}let n=e.modelContext,r=t.modelContext;Q9(n),r!==n&&Q9(r);let i=navigator;if((r||n)&&!i.modelContextTesting)try{Object.defineProperty(navigator,"modelContextTesting",{configurable:!0,enumerable:!0,value:{listTools:async()=>{let e=i.modelContext;return e&&typeof e.listTools==`function`?e.listTools():e&&typeof e.getTools==`function`?e.getTools():[]},executeTool:async(...e)=>{let t=i.modelContext;if(!t||typeof t.executeTool!=`function`)throw Error(`navigator.modelContext.executeTool is unavailable`);return t.executeTool(...e)},callTool:async(...e)=>{let t=i.modelContext;if(t&&typeof t.callTool==`function`)return t.callTool(...e);if(t&&typeof t.executeTool==`function`)return t.executeTool(...e);throw Error(`navigator.modelContext.callTool is unavailable`)}}})}catch{}let a=xi(Hwe,{allow:()=>!0});return()=>{a()}}},[]),(0,K.useEffect)(()=>{let e=d7({name:`ui_get_view_context`,title:`Get Active UI View Context`,description:`Read current browser route, readiness, stream results, editor, and clock.`,tier:0,scope:`global-ui`}),t=d7({name:`ui_navigate`,title:`Navigate Playground Route`,description:`Navigate the SPA router to any internal WOD Wiki path.`,tier:1,scope:`global-ui`}),n=d7({name:`ui_cast_control`,title:`Inspect or Disconnect Cast Session`,description:`Inspect or disconnect Chromecast / receiver display session.`,tier:1,scope:`global-ui`}),r=d7({name:`ui_preferences`,title:`Get or Set Playground UI Preferences`,description:`Read or update theme, audio cues, debug mode, analytics units, and mobile drawers.`,tier:1,scope:`global-ui`}),i=Fi.map(e=>d7({name:e.name,title:`UI-SDK ${e.name[0].toUpperCase()}${e.name.slice(1)}`,description:e.description,tier:+(e.name===`act`),scope:`global-ui`}));return()=>{e(),t(),n(),r();for(let e of i)e()}},[]),wr({name:`ui_get_view_context`,title:`Get Active UI View Context`,description:`Read the current browser route, hydration/loading state, unbatched stream results, active editor metadata, and live workout clock snapshot.`,inputSchema:Swe,annotations:{title:`Get Active UI View Context`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let l=performance.now(),u=e.includeSampleEntries!==!1,p=a&&s&&s.pathname===t.pathname?s:null,g={hydrated:document.body.dataset.appHydrated===`true`,status:i||n===`preparing`||r?`loading`:`ready`,feedReadiness:n,importPending:r,route:{pathname:t.pathname,search:t.search,hash:t.hash,href:window.location.href},stream:a?{route:a.route,query:a.query,defaultQuery:a.defaultQuery,layout:a.layout,availableLayouts:a.availableLayouts,groupBy:a.groupBy??null,loading:a.loading,totalUnbatchedCount:p?p.entries.length:null,...u&&p?{entries:p.entries.slice(0,50).map(e=>({id:e.id,title:e.title,date:e.date??null,notebookId:e.notebookId??null}))}:{}}:null,editor:c?{noteId:c.noteId??null,readonly:c.readonly,sourceRevision:c.sourceRevision??null,workoutBlockIds:c.getBlocks().map(e=>e.id)}:null,explorer:o?{draft:o.draft,submitted:o.submitted,weeks:o.weeks,loading:o.loading,saveReady:o.saveReady}:null,preferences:{theme:f,audioEnabled:m?.isEnabled??!1,debugMode:h,analyticsUnit:_,leftDrawerOpen:y.leftDrawerOpen,rightDrawerOpen:y.rightDrawerOpen},clock:d};return f7({toolName:`ui_get_view_context`,timestamp:Date.now(),durationMs:Math.round(performance.now()-l),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),g}}),wr({name:`ui_navigate`,title:`Navigate Playground Route`,description:"Navigate the React Router SPA to any WOD Wiki route (`/journal`, `/day/:date`, `/note/:id`, `/notebooks`, `/dashboards`, `/run/:id?note=:noteId`) and wait for UI commit.",inputSchema:Cwe,annotations:{title:`Navigate Route`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(t){let n=performance.now(),r=t.path.startsWith(`/`)?t.path:`/${t.path}`;e(r,{replace:t.replace===!0}),await K9();let i={navigatedTo:r,href:window.location.href};return f7({toolName:`ui_navigate`,timestamp:Date.now(),durationMs:Math.round(performance.now()-n),ok:!0,argsPreview:JSON.stringify(t).slice(0,120)}),i}}),wr({name:`ui_cast_control`,title:`Inspect or Disconnect Cast Session`,description:`Check active Chromecast / receiver display session state or cleanly disconnect an active Cast session.`,inputSchema:wwe,annotations:{title:`Cast Session Control`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now(),n=H1(),r=W1.getActiveHandle();e.action===`disconnect`&&r&&(W1.dispose(!0),vB(null),await K9());let i={action:e.action,backendState:n.state,connected:!!W1.getActiveHandle()};return f7({toolName:`ui_cast_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),i}}),wr({name:`ui_preferences`,title:`Get or Set Playground UI Preferences`,description:"Read or update global Playground UI preferences (`theme`, `audioEnabled`, `debugMode`, `analyticsUnit`, and mobile navigation drawers).",inputSchema:kwe,annotations:{title:`Playground UI Preferences`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now(),n=f,r=m?.isEnabled??!1,i=h,a=_,o=y.leftDrawerOpen,s=y.rightDrawerOpen;e.action===`set`&&(e.theme!==void 0&&e.theme!==f&&(p(e.theme),n=e.theme),e.audioEnabled!==void 0&&m&&e.audioEnabled!==m.isEnabled&&(m.toggleAudio(),r=e.audioEnabled),e.debugMode!==void 0&&e.debugMode!==h&&(g(),i=e.debugMode),e.analyticsUnit!==void 0&&e.analyticsUnit!==_&&(v(e.analyticsUnit),a=e.analyticsUnit),e.leftDrawerOpen!==void 0&&(b({type:`SET_LEFT_DRAWER`,open:e.leftDrawerOpen}),o=e.leftDrawerOpen),e.rightDrawerOpen!==void 0&&(b({type:`SET_RIGHT_DRAWER`,open:e.rightDrawerOpen}),s=e.rightDrawerOpen),await K9());let c={theme:n,audioEnabled:r,debugMode:i,analyticsUnit:a,leftDrawerOpen:o,rightDrawerOpen:s};return f7({toolName:`ui_preferences`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),c}}),(0,q.jsxs)(q.Fragment,{children:[G9.map(e=>(0,q.jsx)(Gwe,{spec:e},e.name)),a&&(0,q.jsx)(Vwe,{stream:a}),o&&(0,q.jsx)(Rwe,{explorer:o}),c&&(0,q.jsx)(Lwe,{editor:c}),(l||c)&&(0,q.jsx)(Iwe,{}),u&&(0,q.jsx)(Bwe,{results:u}),d&&(0,q.jsx)(zwe,{clock:d})]})};function qwe(){let{pathname:e,hash:t}=Qe(),{scrollToSection:n}=MV();return(0,K.useLayoutEffect)(()=>{if(yK(e),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 Jwe(){return JCe(),C9(),(0,K.useEffect)(()=>{iF.current().catch(console.error),vle(),MZ(),Cz().catch(()=>{}),H5().catch(()=>{})},[]),null}function $9({settling:e}){let t=AZ();if(e){let e=JX(t);return(0,q.jsxs)(`div`,{role:`status`,className:`flex min-h-dvh flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:t?qX(t):`Loading library…`}),e&&(0,q.jsx)(`span`,{className:`text-xs`,"data-testid":`boot-progress-detail`,children:e})]})}return(0,q.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-semibold`,children:`The library's routed content failed to load.`}),(0,q.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:`The feed corpus has not supplied this page. Re-running the feed import usually restores it.`}),(0,q.jsx)(J,{variant:`outline`,size:`sm`,"data-testid":`root-refeed`,onClick:()=>{rV().then(()=>ZP())},children:`Re-import library`})]})}function Ywe(){let e=(0,K.useRef)(()=>{}),t=Tq(),n=OZ(),r=(0,K.useMemo)(()=>JK(()=>e.current(),t),[t]);return(0,q.jsx)(Yee,{defaultTheme:`system`,storageKey:`wod-wiki-playground-theme`,children:(0,q.jsx)(aoe,{children:(0,q.jsx)(bV,{children:(0,q.jsx)(wV,{children:(0,q.jsx)(TB,{children:(0,q.jsx)(R,{children:(0,q.jsxs)(Rt,{children:[(0,q.jsx)(Jwe,{}),(0,q.jsx)(Po,{}),(0,q.jsxs)(LV,{tree:r,children:[(0,q.jsx)(qwe,{}),(0,q.jsx)(Kwe,{}),(0,q.jsx)(XCe,{}),(0,q.jsx)(QCe,{}),(0,q.jsx)(KCe,{searchHandlerRef:e,canvasRouteList:t,rootUnavailable:t.length===0?(0,q.jsx)($9,{settling:n===`preparing`||BB()&&n!==`error`}):void 0,pageSettlingFallback:t.length===0&&(n===`preparing`||BB()&&n!==`error`)?(0,q.jsx)($9,{settling:!0}):void 0}),(0,q.jsx)(qCe,{})]})]})})})})})})})}function Xwe({error:e,onRetry:t}){let n=e instanceof Error?e.message:String(e);return rF(),(0,q.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-semibold`,children:`The API data store could not be opened.`}),(0,q.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground font-mono break-all`,"data-testid":`boot-recovery-error`,children:n}),(0,q.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`Your stored data has not been cleared. Retry after resolving the error above.`,!1]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`boot-recovery-retry`,className:`rounded-md border border-border bg-card px-3 py-1.5 text-xs font-medium hover:bg-accent`,children:`Retry`}),!1]}),!1]})}function Zwe(){let e=(0,K.useSyncExternalStore)(EE,TE),t=e.phase===`updating`;return(0,q.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,q.jsx)(`p`,{className:`text-sm font-semibold`,children:t?`Updating local database…`:`Checking for storage updates…`}),t&&e.fromVersion!==null&&(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Schema v`,e.fromVersion,` → v`,e.toVersion]}),e.message&&(0,q.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e.message})]})}var Qwe=(0,xo.createRoot)(document.getElementById(`root`));function $we(){let[e,t]=(0,K.useState)(!1),[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(0),o=(0,K.useSyncExternalStore)(EE,TE);return(0,K.useEffect)(()=>{let e=!1,n;return cF().then(()=>$F(X.storage)).then(()=>PR?zR():void 0).then(()=>NI.ensureNotebooks().catch(e=>pR(`NotebookService`,`ensureNotebooks failed`,e))).then(()=>{e||(n=dF(),t(!0))}).catch(t=>{e||r(t)}),()=>{e=!0,n?.()}},[i]),(0,K.useEffect)(()=>{if(!e){delete document.body.dataset.appHydrated;return}return document.body.dataset.appHydrated=`true`,()=>{delete document.body.dataset.appHydrated}},[e]),n?(0,q.jsx)(Xwe,{error:n,onRetry:()=>{r(null),a(e=>e+1)}}):o.phase===`checking`||o.phase===`updating`?(0,q.jsx)(Zwe,{}):e?(0,q.jsx)(Ywe,{}):(0,q.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Opening local library…`})}Qwe.render((0,q.jsx)(K.StrictMode,{children:(0,q.jsx)($we,{})}));
|
|
1201
|
-
//# sourceMappingURL=main-
|
|
1201
|
+
//# sourceMappingURL=main-bnWjDW6m.js.map
|